init.c 155 KB
Newer Older
1
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/init.c,v 1.20 2003/09/05 09:38:32 twini Exp $ */
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
2
/*
3 4
 * Mode switching code (CRT1 section) for
 * SiS 300/540/630/730/315/550/650/M650/651/M652/740/330/660/M660/760
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
5 6
 * (Universal module for Linux kernel framebuffer and XFree86 4.x)
 *
7 8 9
 * Assembler-To-C translation
 * Copyright 2002, 2003 by Thomas Winischhofer <thomas@winischhofer.net>
 * Formerly based on non-functional code-fragements by SiS, Inc.
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
10
 *
11 12
 * If distributed as part of the linux kernel, the contents of this file
 * is entirely covered by the GPL.
13
 *
14
 * Otherwise, the following terms apply:
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
15
 *
16 17 18 19 20 21 22 23 24
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that
 * copyright notice and this permission notice appear in supporting
 * documentation, and that the name of the copyright holder not be used in
 * advertising or publicity pertaining to distribution of the software without
 * specific, written prior permission.  The copyright holder makes no representations
 * about the suitability of this software for any purpose.  It is provided
 * "as is" without express or implied warranty.
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
25
 *
26 27 28 29 30 31 32
 * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 * PERFORMANCE OF THIS SOFTWARE.
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
 *
 * TW says: This code looks awful, I know. But please don't do anything about
 * this otherwise debugging will be hell.
 * The code is extremely fragile as regards the different chipsets, different
 * video bridges and combinations thereof. If anything is changed, extreme
 * care has to be taken that that change doesn't break it for other chipsets,
 * bridges or combinations thereof.
 * All comments in this file are by me, regardless if they are marked TW or not.
 *
 */
 
#include "init.h"

#ifdef SIS300
#include "300vtbl.h"
#endif

#ifdef SIS315H
#include "310vtbl.h"
#endif

54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
#ifdef LINUX_XF86
BOOLEAN SiSBIOSSetMode(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,
                       ScrnInfoPtr pScrn, DisplayModePtr mode, BOOLEAN IsCustom);
DisplayModePtr SiSBuildBuiltInModeList(ScrnInfoPtr pScrn, BOOLEAN includelcdmodes, BOOLEAN isfordvi);
int    SiSTranslateToVESA(ScrnInfoPtr pScrn, int modenumber);
#ifdef SISDUALHEAD
BOOLEAN SiSBIOSSetModeCRT1(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,
                       ScrnInfoPtr pScrn, DisplayModePtr mode, BOOLEAN IsCustom);
BOOLEAN SiSBIOSSetModeCRT2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,
                       ScrnInfoPtr pScrn, DisplayModePtr mode, BOOLEAN IsCustom);
#endif /* dual head */
#endif /* linux_xf86 */

#ifdef LINUX_XF86
BOOLEAN SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,
                   ScrnInfoPtr pScrn,USHORT ModeNo, BOOLEAN dosetpitch);
#else
BOOLEAN SiSSetMode(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,
                   USHORT ModeNo);
#endif

#ifndef LINUX_XF86
static ULONG GetDRAMSize(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension);
#endif

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
79 80
#if defined(ALLOC_PRAGMA)
#pragma alloc_text(PAGE,SiSSetMode)
81
#pragma alloc_text(PAGE,SiSInit)
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
82 83 84
#endif

static void
85
InitCommonPointer(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension)
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
86
{
87 88 89
   SiS_Pr->SiS_StResInfo     = SiS_StResInfo;
   SiS_Pr->SiS_ModeResInfo   = SiS_ModeResInfo;
   SiS_Pr->SiS_StandTable    = SiS_StandTable;
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
   if(HwDeviceExtension->jChipType < SIS_315H) {
      SiS_StandTable[0x04].CRTC[4] = 0x2b;
      SiS_StandTable[0x05].CRTC[4] = 0x2b;
      SiS_StandTable[0x06].CRTC[4] = 0x54;
      SiS_StandTable[0x06].CRTC[5] = 0x80;
      SiS_StandTable[0x0d].CRTC[4] = 0x2b;
      SiS_StandTable[0x0e].CRTC[4] = 0x54;
      SiS_StandTable[0x0e].CRTC[5] = 0x80;
      SiS_StandTable[0x11].CRTC[4] = 0x54;
      SiS_StandTable[0x11].CRTC[5] = 0x80;
      SiS_StandTable[0x11].CRTC[16] = 0x83;
      SiS_StandTable[0x11].CRTC[17] = 0x85;
      SiS_StandTable[0x12].CRTC[4] = 0x54;
      SiS_StandTable[0x12].CRTC[5] = 0x80;
      SiS_StandTable[0x12].CRTC[16] = 0x83;
      SiS_StandTable[0x12].CRTC[17] = 0x85;
      SiS_StandTable[0x13].CRTC[5] = 0xa0;
      SiS_StandTable[0x17].CRTC[5] = 0xa0;
      SiS_StandTable[0x1a].CRTC[4] = 0x54;
      SiS_StandTable[0x1a].CRTC[5] = 0x80;
      SiS_StandTable[0x1a].CRTC[16] = 0xea;
      SiS_StandTable[0x1a].CRTC[17] = 0x8c;
      SiS_StandTable[0x1b].CRTC[4] = 0x54;
      SiS_StandTable[0x1b].CRTC[5] = 0x80;
      SiS_StandTable[0x1b].CRTC[16] = 0xea;
      SiS_StandTable[0x1b].CRTC[17] = 0x8c;
      SiS_StandTable[0x1c].CRTC[4] = 0x54;
      SiS_StandTable[0x1c].CRTC[5] = 0x80;
   } else {
      SiS_StandTable[0x04].CRTC[4] = 0x2c;
      SiS_StandTable[0x05].CRTC[4] = 0x2c;
      SiS_StandTable[0x06].CRTC[4] = 0x55;
      SiS_StandTable[0x06].CRTC[5] = 0x81;
      SiS_StandTable[0x0d].CRTC[4] = 0x2c;
      SiS_StandTable[0x0e].CRTC[4] = 0x55;
      SiS_StandTable[0x0e].CRTC[5] = 0x81;
      SiS_StandTable[0x11].CRTC[4] = 0x55;
      SiS_StandTable[0x11].CRTC[5] = 0x81;
      SiS_StandTable[0x11].CRTC[16] = 0x82;
      SiS_StandTable[0x11].CRTC[17] = 0x84;
      SiS_StandTable[0x12].CRTC[4] = 0x55;
      SiS_StandTable[0x12].CRTC[5] = 0x81;
      SiS_StandTable[0x12].CRTC[16] = 0x82;
      SiS_StandTable[0x12].CRTC[17] = 0x84;
      SiS_StandTable[0x13].CRTC[5] = 0xb1;
      SiS_StandTable[0x17].CRTC[5] = 0xb1;
      SiS_StandTable[0x1a].CRTC[4] = 0x55;
      SiS_StandTable[0x1a].CRTC[5] = 0x81;
      SiS_StandTable[0x1a].CRTC[16] = 0xe9;
      SiS_StandTable[0x1a].CRTC[17] = 0x8b;
      SiS_StandTable[0x1b].CRTC[4] = 0x55;
      SiS_StandTable[0x1b].CRTC[5] = 0x81;
      SiS_StandTable[0x1b].CRTC[16] = 0xe9;
      SiS_StandTable[0x1b].CRTC[17] = 0x8b;
      SiS_StandTable[0x1c].CRTC[4] = 0x55;
      SiS_StandTable[0x1c].CRTC[5] = 0x81;
   }
147

148 149 150 151 152 153 154 155 156
   SiS_Pr->SiS_NTSCPhase    = SiS_NTSCPhase;
   SiS_Pr->SiS_PALPhase     = SiS_PALPhase;
   SiS_Pr->SiS_NTSCPhase2   = SiS_NTSCPhase2;
   SiS_Pr->SiS_PALPhase2    = SiS_PALPhase2;
   SiS_Pr->SiS_PALMPhase    = SiS_PALMPhase;
   SiS_Pr->SiS_PALNPhase    = SiS_PALNPhase;
   SiS_Pr->SiS_PALMPhase2   = SiS_PALMPhase2;
   SiS_Pr->SiS_PALNPhase2   = SiS_PALNPhase2;
   SiS_Pr->SiS_SpecialPhase = SiS_SpecialPhase;
157 158 159 160 161

   SiS_Pr->SiS_NTSCTiming     = SiS_NTSCTiming;
   SiS_Pr->SiS_PALTiming      = SiS_PALTiming;
   SiS_Pr->SiS_HiTVSt1Timing  = SiS_HiTVSt1Timing;
   SiS_Pr->SiS_HiTVSt2Timing  = SiS_HiTVSt2Timing;
162
   SiS_Pr->SiS_HiTVTextTiming = SiS_HiTVTextTiming;
163 164 165 166 167 168 169 170 171
   SiS_Pr->SiS_HiTVExtTiming  = SiS_HiTVExtTiming;
   SiS_Pr->SiS_HiTVGroup3Data = SiS_HiTVGroup3Data;
   SiS_Pr->SiS_HiTVGroup3Simu = SiS_HiTVGroup3Simu;
   SiS_Pr->SiS_HiTVGroup3Text = SiS_HiTVGroup3Text;

   SiS_Pr->SiS_StPALData   = SiS_StPALData;
   SiS_Pr->SiS_ExtPALData  = SiS_ExtPALData;
   SiS_Pr->SiS_StNTSCData  = SiS_StNTSCData;
   SiS_Pr->SiS_ExtNTSCData = SiS_ExtNTSCData;
172
/* SiS_Pr->SiS_St1HiTVData = SiS_St1HiTVData;  */
173 174 175 176 177 178 179
   SiS_Pr->SiS_St2HiTVData = SiS_St2HiTVData;
   SiS_Pr->SiS_ExtHiTVData = SiS_ExtHiTVData;

   SiS_Pr->pSiS_OutputSelect = &SiS_OutputSelect;
   SiS_Pr->pSiS_SoftSetting  = &SiS_SoftSetting;

   SiS_Pr->SiS_LCD1280x960Data      = SiS_LCD1280x960Data;
180 181
   SiS_Pr->SiS_ExtLCD1400x1050Data  = SiS_ExtLCD1400x1050Data;
   SiS_Pr->SiS_ExtLCD1600x1200Data  = SiS_ExtLCD1600x1200Data;
182 183 184 185 186 187 188
   SiS_Pr->SiS_StLCD1400x1050Data   = SiS_StLCD1400x1050Data;
   SiS_Pr->SiS_StLCD1600x1200Data   = SiS_StLCD1600x1200Data;
   SiS_Pr->SiS_NoScaleData1400x1050 = SiS_NoScaleData1400x1050;
   SiS_Pr->SiS_NoScaleData1600x1200 = SiS_NoScaleData1600x1200;
   SiS_Pr->SiS_ExtLCD1280x768Data   = SiS_ExtLCD1280x768Data;
   SiS_Pr->SiS_StLCD1280x768Data    = SiS_StLCD1280x768Data;
   SiS_Pr->SiS_NoScaleData1280x768  = SiS_NoScaleData1280x768;
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
   SiS_Pr->SiS_NoScaleData          = SiS_NoScaleData;

   SiS_Pr->SiS_LVDS320x480Data_1   = SiS_LVDS320x480Data_1;
   SiS_Pr->SiS_LVDS800x600Data_1   = SiS_LVDS800x600Data_1;
   SiS_Pr->SiS_LVDS800x600Data_2   = SiS_LVDS800x600Data_2;
   SiS_Pr->SiS_LVDS1024x768Data_1  = SiS_LVDS1024x768Data_1;
   SiS_Pr->SiS_LVDS1024x768Data_2  = SiS_LVDS1024x768Data_2;
   SiS_Pr->SiS_LVDS1280x1024Data_1 = SiS_LVDS1280x1024Data_1;
   SiS_Pr->SiS_LVDS1280x1024Data_2 = SiS_LVDS1280x1024Data_2;
   SiS_Pr->SiS_LVDS1400x1050Data_1 = SiS_LVDS1400x1050Data_1;
   SiS_Pr->SiS_LVDS1400x1050Data_2 = SiS_LVDS1400x1050Data_2;
   SiS_Pr->SiS_LVDS1600x1200Data_1 = SiS_LVDS1600x1200Data_1;
   SiS_Pr->SiS_LVDS1600x1200Data_2 = SiS_LVDS1600x1200Data_2;
   SiS_Pr->SiS_LVDS1280x768Data_1  = SiS_LVDS1280x768Data_1;
   SiS_Pr->SiS_LVDS1280x768Data_2  = SiS_LVDS1280x768Data_2;
   SiS_Pr->SiS_LVDS1024x600Data_1  = SiS_LVDS1024x600Data_1;
   SiS_Pr->SiS_LVDS1024x600Data_2  = SiS_LVDS1024x600Data_2;
   SiS_Pr->SiS_LVDS1152x768Data_1  = SiS_LVDS1152x768Data_1;
   SiS_Pr->SiS_LVDS1152x768Data_2  = SiS_LVDS1152x768Data_2;
   SiS_Pr->SiS_LVDSXXXxXXXData_1   = SiS_LVDSXXXxXXXData_1;
   SiS_Pr->SiS_LVDS1280x960Data_1  = SiS_LVDS1280x960Data_1;
   SiS_Pr->SiS_LVDS1280x960Data_2  = SiS_LVDS1280x960Data_2;
   SiS_Pr->SiS_LVDS640x480Data_1   = SiS_LVDS640x480Data_1;
   SiS_Pr->SiS_LVDS1280x960Data_1  = SiS_LVDS1280x1024Data_1;
   SiS_Pr->SiS_LVDS1280x960Data_2  = SiS_LVDS1280x1024Data_2;
   SiS_Pr->SiS_LVDS640x480Data_1   = SiS_LVDS640x480Data_1;
   SiS_Pr->SiS_LVDS640x480Data_2   = SiS_LVDS640x480Data_2;

217 218
   SiS_Pr->SiS_LVDSBARCO1366Data_1 = SiS_LVDSBARCO1366Data_1;
   SiS_Pr->SiS_LVDSBARCO1366Data_2 = SiS_LVDSBARCO1366Data_2;
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
   SiS_Pr->SiS_LVDSBARCO1024Data_1 = SiS_LVDSBARCO1024Data_1;
   SiS_Pr->SiS_LVDSBARCO1024Data_2 = SiS_LVDSBARCO1024Data_2;
   SiS_Pr->SiS_LVDS848x480Data_1   = SiS_LVDS848x480Data_1;
   SiS_Pr->SiS_LVDS848x480Data_2   = SiS_LVDS848x480Data_2;

   SiS_Pr->SiS_LCDA1400x1050Data_1 = SiS_LCDA1400x1050Data_1;
   SiS_Pr->SiS_LCDA1400x1050Data_2 = SiS_LCDA1400x1050Data_2;
   SiS_Pr->SiS_LCDA1600x1200Data_1 = SiS_LCDA1600x1200Data_1;
   SiS_Pr->SiS_LCDA1600x1200Data_2 = SiS_LCDA1600x1200Data_2;
   SiS_Pr->SiS_CHTVUNTSCData = SiS_CHTVUNTSCData;
   SiS_Pr->SiS_CHTVONTSCData = SiS_CHTVONTSCData;

   SiS_Pr->LVDS1024x768Des_1  = SiS_PanelType1076_1;
   SiS_Pr->LVDS1280x1024Des_1 = SiS_PanelType1210_1;
   SiS_Pr->LVDS1400x1050Des_1 = SiS_PanelType1296_1;
   SiS_Pr->LVDS1600x1200Des_1 = SiS_PanelType1600_1;
   SiS_Pr->LVDS1024x768Des_2  = SiS_PanelType1076_2;
   SiS_Pr->LVDS1280x1024Des_2 = SiS_PanelType1210_2;
   SiS_Pr->LVDS1400x1050Des_2 = SiS_PanelType1296_2;
   SiS_Pr->LVDS1600x1200Des_2 = SiS_PanelType1600_2;

   SiS_Pr->SiS_PanelTypeNS_1 = SiS_PanelTypeNS_1;
   SiS_Pr->SiS_PanelTypeNS_2 = SiS_PanelTypeNS_2;

   SiS_Pr->SiS_CHTVUNTSCDesData = SiS_CHTVUNTSCDesData;
   SiS_Pr->SiS_CHTVONTSCDesData = SiS_CHTVONTSCDesData;
   SiS_Pr->SiS_CHTVUPALDesData  = SiS_CHTVUPALDesData;
   SiS_Pr->SiS_CHTVOPALDesData  = SiS_CHTVOPALDesData;
247 248 249 250 251 252 253 254 255 256 257 258 259 260

   SiS_Pr->SiS_LVDSCRT11280x768_1    = SiS_LVDSCRT11280x768_1;
   SiS_Pr->SiS_LVDSCRT11024x600_1    = SiS_LVDSCRT11024x600_1;
   SiS_Pr->SiS_LVDSCRT11152x768_1    = SiS_LVDSCRT11152x768_1;
   SiS_Pr->SiS_LVDSCRT11280x768_1_H  = SiS_LVDSCRT11280x768_1_H;
   SiS_Pr->SiS_LVDSCRT11024x600_1_H  = SiS_LVDSCRT11024x600_1_H;
   SiS_Pr->SiS_LVDSCRT11152x768_1_H  = SiS_LVDSCRT11152x768_1_H;
   SiS_Pr->SiS_LVDSCRT11280x768_2    = SiS_LVDSCRT11280x768_2;
   SiS_Pr->SiS_LVDSCRT11024x600_2    = SiS_LVDSCRT11024x600_2;
   SiS_Pr->SiS_LVDSCRT11152x768_2    = SiS_LVDSCRT11152x768_2;
   SiS_Pr->SiS_LVDSCRT11280x768_2_H  = SiS_LVDSCRT11280x768_2_H;
   SiS_Pr->SiS_LVDSCRT11024x600_2_H  = SiS_LVDSCRT11024x600_2_H;
   SiS_Pr->SiS_LVDSCRT11152x768_2_H  = SiS_LVDSCRT11152x768_2_H;
   SiS_Pr->SiS_LVDSCRT1320x480_1     = SiS_LVDSCRT1320x480_1;
261 262
   SiS_Pr->SiS_LVDSCRT1XXXxXXX_1     = SiS_LVDSCRT1XXXxXXX_1;
   SiS_Pr->SiS_LVDSCRT1XXXxXXX_1_H   = SiS_LVDSCRT1XXXxXXX_1_H;
263 264 265 266 267 268
   SiS_Pr->SiS_LVDSCRT1640x480_1     = SiS_LVDSCRT1640x480_1;
   SiS_Pr->SiS_LVDSCRT1640x480_1_H   = SiS_LVDSCRT1640x480_1_H;
   SiS_Pr->SiS_LVDSCRT1640x480_2     = SiS_LVDSCRT1640x480_2;
   SiS_Pr->SiS_LVDSCRT1640x480_2_H   = SiS_LVDSCRT1640x480_2_H;
   SiS_Pr->SiS_LVDSCRT1640x480_3     = SiS_LVDSCRT1640x480_3;
   SiS_Pr->SiS_LVDSCRT1640x480_3_H   = SiS_LVDSCRT1640x480_3_H;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
269 270 271 272
}

#ifdef SIS300
static void
273
InitTo300Pointer(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension)
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
274
{
275 276 277 278 279 280 281 282 283
   InitCommonPointer(SiS_Pr, HwDeviceExtension);

   SiS_Pr->SiS_SModeIDTable  = (SiS_StStruct *)SiS300_SModeIDTable;
   SiS_Pr->SiS_VBModeIDTable = (SiS_VBModeStruct *)SiS300_VBModeIDTable;
   SiS_Pr->SiS_EModeIDTable  = (SiS_ExtStruct *)SiS300_EModeIDTable;
   SiS_Pr->SiS_RefIndex      = (SiS_Ext2Struct *)SiS300_RefIndex;
   SiS_Pr->SiS_CRT1Table     = (SiS_CRT1TableStruct *)SiS300_CRT1Table;
   if(HwDeviceExtension->jChipType == SIS_300) {
      SiS_Pr->SiS_MCLKData_0    = (SiS_MCLKDataStruct *)SiS300_MCLKData_300; /* 300 */
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
284
   } else {
285
      SiS_Pr->SiS_MCLKData_0    = (SiS_MCLKDataStruct *)SiS300_MCLKData_630; /* 630, 730 */
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
286
   }
287 288 289 290
#ifdef LINUXBIOS
   SiS_Pr->SiS_ECLKData      = (SiS_ECLKDataStruct *)SiS300_ECLKData;
#endif
   SiS_Pr->SiS_VCLKData      = (SiS_VCLKDataStruct *)SiS300_VCLKData;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
291
   SiS_Pr->SiS_VBVCLKData    = (SiS_VBVCLKDataStruct *)SiS300_VCLKData;
292
   SiS_Pr->SiS_ScreenOffset  = SiS300_ScreenOffset;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320

   SiS_Pr->SiS_SR15  = SiS300_SR15;

#ifndef LINUX_XF86
   SiS_Pr->pSiS_SR07 = &SiS300_SR07;
   SiS_Pr->SiS_CR40  = SiS300_CR40;
   SiS_Pr->SiS_CR49  = SiS300_CR49;
   SiS_Pr->pSiS_SR1F = &SiS300_SR1F;
   SiS_Pr->pSiS_SR21 = &SiS300_SR21;
   SiS_Pr->pSiS_SR22 = &SiS300_SR22;
   SiS_Pr->pSiS_SR23 = &SiS300_SR23;
   SiS_Pr->pSiS_SR24 = &SiS300_SR24;
   SiS_Pr->SiS_SR25  = SiS300_SR25;
   SiS_Pr->pSiS_SR31 = &SiS300_SR31;
   SiS_Pr->pSiS_SR32 = &SiS300_SR32;
   SiS_Pr->pSiS_SR33 = &SiS300_SR33;
   SiS_Pr->pSiS_CRT2Data_1_2  = &SiS300_CRT2Data_1_2;
   SiS_Pr->pSiS_CRT2Data_4_D  = &SiS300_CRT2Data_4_D;
   SiS_Pr->pSiS_CRT2Data_4_E  = &SiS300_CRT2Data_4_E;
   SiS_Pr->pSiS_CRT2Data_4_10 = &SiS300_CRT2Data_4_10;
   SiS_Pr->pSiS_RGBSenseData    = &SiS300_RGBSenseData;
   SiS_Pr->pSiS_VideoSenseData  = &SiS300_VideoSenseData;
   SiS_Pr->pSiS_YCSenseData     = &SiS300_YCSenseData;
   SiS_Pr->pSiS_RGBSenseData2   = &SiS300_RGBSenseData2;
   SiS_Pr->pSiS_VideoSenseData2 = &SiS300_VideoSenseData2;
   SiS_Pr->pSiS_YCSenseData2    = &SiS300_YCSenseData2;
#endif

321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372
   SiS_Pr->SiS_StLCD1024x768Data    = (SiS_LCDDataStruct *)SiS300_StLCD1024x768Data;
   SiS_Pr->SiS_ExtLCD1024x768Data   = (SiS_LCDDataStruct *)SiS300_ExtLCD1024x768Data;
   SiS_Pr->SiS_St2LCD1024x768Data   = (SiS_LCDDataStruct *)SiS300_St2LCD1024x768Data;
   SiS_Pr->SiS_StLCD1280x1024Data   = (SiS_LCDDataStruct *)SiS300_StLCD1280x1024Data;
   SiS_Pr->SiS_ExtLCD1280x1024Data  = (SiS_LCDDataStruct *)SiS300_ExtLCD1280x1024Data;
   SiS_Pr->SiS_St2LCD1280x1024Data  = (SiS_LCDDataStruct *)SiS300_St2LCD1280x1024Data;
   SiS_Pr->SiS_NoScaleData1024x768  = (SiS_LCDDataStruct *)SiS300_NoScaleData1024x768;
   SiS_Pr->SiS_NoScaleData1280x1024 = (SiS_LCDDataStruct *)SiS300_NoScaleData1280x1024;

   SiS_Pr->SiS_PanelDelayTbl     = (SiS_PanelDelayTblStruct *)SiS300_PanelDelayTbl;
   SiS_Pr->SiS_PanelDelayTblLVDS = (SiS_PanelDelayTblStruct *)SiS300_PanelDelayTblLVDS;

   SiS_Pr->SiS_CHTVUPALData  = (SiS_LVDSDataStruct *)SiS300_CHTVUPALData;
   SiS_Pr->SiS_CHTVOPALData  = (SiS_LVDSDataStruct *)SiS300_CHTVOPALData;
   SiS_Pr->SiS_CHTVUPALMData = SiS_CHTVUNTSCData; 			   /* not supported on 300 series */
   SiS_Pr->SiS_CHTVOPALMData = SiS_CHTVONTSCData; 			   /* not supported on 300 series */
   SiS_Pr->SiS_CHTVUPALNData = (SiS_LVDSDataStruct *)SiS300_CHTVUPALData;  /* not supported on 300 series */
   SiS_Pr->SiS_CHTVOPALNData = (SiS_LVDSDataStruct *)SiS300_CHTVOPALData;  /* not supported on 300 series */
   SiS_Pr->SiS_CHTVSOPALData = (SiS_LVDSDataStruct *)SiS300_CHTVSOPALData;

   SiS_Pr->SiS_PanelType00_1 = (SiS_LVDSDesStruct *)SiS300_PanelType00_1;
   SiS_Pr->SiS_PanelType01_1 = (SiS_LVDSDesStruct *)SiS300_PanelType01_1;
   SiS_Pr->SiS_PanelType02_1 = (SiS_LVDSDesStruct *)SiS300_PanelType02_1;
   SiS_Pr->SiS_PanelType03_1 = (SiS_LVDSDesStruct *)SiS300_PanelType03_1;
   SiS_Pr->SiS_PanelType04_1 = (SiS_LVDSDesStruct *)SiS300_PanelType04_1;
   SiS_Pr->SiS_PanelType05_1 = (SiS_LVDSDesStruct *)SiS300_PanelType05_1;
   SiS_Pr->SiS_PanelType06_1 = (SiS_LVDSDesStruct *)SiS300_PanelType06_1;
   SiS_Pr->SiS_PanelType07_1 = (SiS_LVDSDesStruct *)SiS300_PanelType07_1;
   SiS_Pr->SiS_PanelType08_1 = (SiS_LVDSDesStruct *)SiS300_PanelType08_1;
   SiS_Pr->SiS_PanelType09_1 = (SiS_LVDSDesStruct *)SiS300_PanelType09_1;
   SiS_Pr->SiS_PanelType0a_1 = (SiS_LVDSDesStruct *)SiS300_PanelType0a_1;
   SiS_Pr->SiS_PanelType0b_1 = (SiS_LVDSDesStruct *)SiS300_PanelType0b_1;
   SiS_Pr->SiS_PanelType0c_1 = (SiS_LVDSDesStruct *)SiS300_PanelType0c_1;
   SiS_Pr->SiS_PanelType0d_1 = (SiS_LVDSDesStruct *)SiS300_PanelType0d_1;
   SiS_Pr->SiS_PanelType0e_1 = (SiS_LVDSDesStruct *)SiS300_PanelType0e_1;
   SiS_Pr->SiS_PanelType0f_1 = (SiS_LVDSDesStruct *)SiS300_PanelType0f_1;
   SiS_Pr->SiS_PanelType00_2 = (SiS_LVDSDesStruct *)SiS300_PanelType00_2;
   SiS_Pr->SiS_PanelType01_2 = (SiS_LVDSDesStruct *)SiS300_PanelType01_2;
   SiS_Pr->SiS_PanelType02_2 = (SiS_LVDSDesStruct *)SiS300_PanelType02_2;
   SiS_Pr->SiS_PanelType03_2 = (SiS_LVDSDesStruct *)SiS300_PanelType03_2;
   SiS_Pr->SiS_PanelType04_2 = (SiS_LVDSDesStruct *)SiS300_PanelType04_2;
   SiS_Pr->SiS_PanelType05_2 = (SiS_LVDSDesStruct *)SiS300_PanelType05_2;
   SiS_Pr->SiS_PanelType06_2 = (SiS_LVDSDesStruct *)SiS300_PanelType06_2;
   SiS_Pr->SiS_PanelType07_2 = (SiS_LVDSDesStruct *)SiS300_PanelType07_2;
   SiS_Pr->SiS_PanelType08_2 = (SiS_LVDSDesStruct *)SiS300_PanelType08_2;
   SiS_Pr->SiS_PanelType09_2 = (SiS_LVDSDesStruct *)SiS300_PanelType09_2;
   SiS_Pr->SiS_PanelType0a_2 = (SiS_LVDSDesStruct *)SiS300_PanelType0a_2;
   SiS_Pr->SiS_PanelType0b_2 = (SiS_LVDSDesStruct *)SiS300_PanelType0b_2;
   SiS_Pr->SiS_PanelType0c_2 = (SiS_LVDSDesStruct *)SiS300_PanelType0c_2;
   SiS_Pr->SiS_PanelType0d_2 = (SiS_LVDSDesStruct *)SiS300_PanelType0d_2;
   SiS_Pr->SiS_PanelType0e_2 = (SiS_LVDSDesStruct *)SiS300_PanelType0e_2;
   SiS_Pr->SiS_PanelType0f_2 = (SiS_LVDSDesStruct *)SiS300_PanelType0f_2;
373 374

   if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) {
375 376
      SiS_Pr->SiS_PanelType04_1 = (SiS_LVDSDesStruct *)SiS300_PanelType04_1a;
      SiS_Pr->SiS_PanelType04_2 = (SiS_LVDSDesStruct *)SiS300_PanelType04_2a;
377 378
   }
   if(SiS_Pr->SiS_CustomT == CUT_BARCO1024) {
379 380
      SiS_Pr->SiS_PanelType04_1 = (SiS_LVDSDesStruct *)SiS300_PanelType04_1b;
      SiS_Pr->SiS_PanelType04_2 = (SiS_LVDSDesStruct *)SiS300_PanelType04_2b;
381 382
   }

383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408
   SiS_Pr->SiS_LVDSCRT1800x600_1     = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT1800x600_1;
   SiS_Pr->SiS_LVDSCRT11024x768_1    = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11024x768_1;
   SiS_Pr->SiS_LVDSCRT11280x1024_1   = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11280x1024_1;
   SiS_Pr->SiS_LVDSCRT1800x600_1_H   = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT1800x600_1_H;
   SiS_Pr->SiS_LVDSCRT11024x768_1_H  = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11024x768_1_H;
   SiS_Pr->SiS_LVDSCRT11280x1024_1_H = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11280x1024_1_H;
   SiS_Pr->SiS_LVDSCRT1800x600_2     = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT1800x600_2;
   SiS_Pr->SiS_LVDSCRT11024x768_2    = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11024x768_2;
   SiS_Pr->SiS_LVDSCRT11280x1024_2   = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11280x1024_2;
   SiS_Pr->SiS_LVDSCRT1800x600_2_H   = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT1800x600_2_H;
   SiS_Pr->SiS_LVDSCRT11024x768_2_H  = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11024x768_2_H;
   SiS_Pr->SiS_LVDSCRT11280x1024_2_H = (SiS_LVDSCRT1DataStruct *)SiS300_LVDSCRT11280x1024_2_H;
   SiS_Pr->SiS_CHTVCRT1UNTSC = (SiS_LVDSCRT1DataStruct *)SiS300_CHTVCRT1UNTSC;
   SiS_Pr->SiS_CHTVCRT1ONTSC = (SiS_LVDSCRT1DataStruct *)SiS300_CHTVCRT1ONTSC;
   SiS_Pr->SiS_CHTVCRT1UPAL  = (SiS_LVDSCRT1DataStruct *)SiS300_CHTVCRT1UPAL;
   SiS_Pr->SiS_CHTVCRT1OPAL  = (SiS_LVDSCRT1DataStruct *)SiS300_CHTVCRT1OPAL;
   SiS_Pr->SiS_CHTVCRT1SOPAL = (SiS_LVDSCRT1DataStruct *)SiS300_CHTVCRT1SOPAL;
   SiS_Pr->SiS_CHTVReg_UNTSC = (SiS_CHTVRegDataStruct *)SiS300_CHTVReg_UNTSC;
   SiS_Pr->SiS_CHTVReg_ONTSC = (SiS_CHTVRegDataStruct *)SiS300_CHTVReg_ONTSC;
   SiS_Pr->SiS_CHTVReg_UPAL  = (SiS_CHTVRegDataStruct *)SiS300_CHTVReg_UPAL;
   SiS_Pr->SiS_CHTVReg_OPAL  = (SiS_CHTVRegDataStruct *)SiS300_CHTVReg_OPAL;
   SiS_Pr->SiS_CHTVReg_UPALM = (SiS_CHTVRegDataStruct *)SiS300_CHTVReg_UNTSC;  /* not supported on 300 series */
   SiS_Pr->SiS_CHTVReg_OPALM = (SiS_CHTVRegDataStruct *)SiS300_CHTVReg_ONTSC;  /* not supported on 300 series */
   SiS_Pr->SiS_CHTVReg_UPALN = (SiS_CHTVRegDataStruct *)SiS300_CHTVReg_UPAL;   /* not supported on 300 series */
   SiS_Pr->SiS_CHTVReg_OPALN = (SiS_CHTVRegDataStruct *)SiS300_CHTVReg_OPAL;   /* not supported on 300 series */
   SiS_Pr->SiS_CHTVReg_SOPAL = (SiS_CHTVRegDataStruct *)SiS300_CHTVReg_SOPAL;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
409 410 411 412 413 414 415 416 417
   SiS_Pr->SiS_CHTVVCLKUNTSC = SiS300_CHTVVCLKUNTSC;
   SiS_Pr->SiS_CHTVVCLKONTSC = SiS300_CHTVVCLKONTSC;
   SiS_Pr->SiS_CHTVVCLKUPAL  = SiS300_CHTVVCLKUPAL;
   SiS_Pr->SiS_CHTVVCLKOPAL  = SiS300_CHTVVCLKOPAL;
   SiS_Pr->SiS_CHTVVCLKUPALM = SiS300_CHTVVCLKUNTSC;  /* not supported on 300 series */
   SiS_Pr->SiS_CHTVVCLKOPALM = SiS300_CHTVVCLKONTSC;  /* not supported on 300 series */
   SiS_Pr->SiS_CHTVVCLKUPALN = SiS300_CHTVVCLKUPAL;   /* not supported on 300 series */
   SiS_Pr->SiS_CHTVVCLKOPALN = SiS300_CHTVVCLKOPAL;   /* not supported on 300 series */
   SiS_Pr->SiS_CHTVVCLKSOPAL = SiS300_CHTVVCLKSOPAL;
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451

   SiS_Pr->SiS_CRT2Part2_1024x768_1  = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1024x768_1;
   SiS_Pr->SiS_CRT2Part2_1280x1024_1 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1280x1024_1;
   SiS_Pr->SiS_CRT2Part2_1400x1050_1 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1400x1050_1;
   SiS_Pr->SiS_CRT2Part2_1600x1200_1 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1600x1200_1;
   SiS_Pr->SiS_CRT2Part2_1024x768_2  = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1024x768_2;
   SiS_Pr->SiS_CRT2Part2_1280x1024_2 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1280x1024_2;
   SiS_Pr->SiS_CRT2Part2_1400x1050_2 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1400x1050_2;
   SiS_Pr->SiS_CRT2Part2_1600x1200_2 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1600x1200_2;
   SiS_Pr->SiS_CRT2Part2_1024x768_3  = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1024x768_3;
   SiS_Pr->SiS_CRT2Part2_1280x1024_3 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1280x1024_3;
   SiS_Pr->SiS_CRT2Part2_1400x1050_3 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1400x1050_3;
   SiS_Pr->SiS_CRT2Part2_1600x1200_3 = (SiS_Part2PortTblStruct *)SiS300_CRT2Part2_1600x1200_3;

   /* TW: LCDResInfo will on 300 series be translated to 315 series definitions */
   SiS_Pr->SiS_Panel320x480   = Panel_320x480;
   SiS_Pr->SiS_Panel640x480   = Panel_640x480;
   SiS_Pr->SiS_Panel800x600   = Panel_800x600;
   SiS_Pr->SiS_Panel1024x768  = Panel_1024x768;
   SiS_Pr->SiS_Panel1280x1024 = Panel_1280x1024;
   SiS_Pr->SiS_Panel1280x960  = Panel_1280x960;
   SiS_Pr->SiS_Panel1024x600  = Panel_1024x600;
   SiS_Pr->SiS_Panel1152x768  = Panel_1152x768;
   SiS_Pr->SiS_Panel1280x768  = Panel_1280x768;
   SiS_Pr->SiS_Panel1600x1200 = 255;  		/* TW: Something illegal */
   SiS_Pr->SiS_Panel1400x1050 = 255;  		/* TW: Something illegal */
   SiS_Pr->SiS_Panel640x480_2 = 255;  		/* TW: Something illegal */
   SiS_Pr->SiS_Panel640x480_3 = 255;  		/* TW: Something illegal */
   SiS_Pr->SiS_Panel1152x864  = 255;   		/* TW: Something illegal */
   SiS_Pr->SiS_PanelMax       = Panel_320x480;     /* TW: highest value */
   SiS_Pr->SiS_PanelMinLVDS   = Panel_800x600;     /* TW: Lowest value LVDS */
   SiS_Pr->SiS_PanelMin301    = Panel_1024x768;    /* TW: lowest value 301 */
   SiS_Pr->SiS_PanelCustom    = Panel_Custom;
   SiS_Pr->SiS_PanelBarco1366 = Panel_Barco1366;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
452 453 454 455 456
}
#endif

#ifdef SIS315H
static void
457
InitTo310Pointer(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension)
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
458
{
459 460 461 462
   InitCommonPointer(SiS_Pr, HwDeviceExtension);

   SiS_Pr->SiS_SModeIDTable  = (SiS_StStruct *)SiS310_SModeIDTable;
   SiS_Pr->SiS_EModeIDTable  = (SiS_ExtStruct *)SiS310_EModeIDTable;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
463
   SiS_Pr->SiS_RefIndex      = (SiS_Ext2Struct *)SiS310_RefIndex;
464 465 466 467 468 469 470 471 472 473 474
   SiS_Pr->SiS_CRT1Table     = (SiS_CRT1TableStruct *)SiS310_CRT1Table;
   /* TW: MCLK is different */
#ifdef LINUXBIOS
   if(HwDeviceExtension->jChipType >= SIS_660) {
      SiS_Pr->SiS_MCLKData_0 = (SiS_MCLKDataStruct *)SiS310_MCLKData_0_660;  /* 660/760 */
   } else if(HwDeviceExtension->jChipType == SIS_330) {
#endif
      SiS_Pr->SiS_MCLKData_0 = (SiS_MCLKDataStruct *)SiS310_MCLKData_0_330;  /* 330 */
#ifdef LINUXBIOS
   } else if(HwDeviceExtension->jChipType > SIS_315PRO) {
      SiS_Pr->SiS_MCLKData_0 = (SiS_MCLKDataStruct *)SiS310_MCLKData_0_650;  /* 550, 650, 740 */
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
475
   } else {
476
      SiS_Pr->SiS_MCLKData_0 = (SiS_MCLKDataStruct *)SiS310_MCLKData_0_315;  /* 315 */
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
477
   }
478 479 480 481 482 483 484 485
#endif
   SiS_Pr->SiS_MCLKData_1    = (SiS_MCLKDataStruct *)SiS310_MCLKData_1;
#ifdef LINUXBIOS
   SiS_Pr->SiS_ECLKData      = (SiS_ECLKDataStruct *)SiS310_ECLKData;
#endif
   SiS_Pr->SiS_VCLKData      = (SiS_VCLKDataStruct *)SiS310_VCLKData;
   SiS_Pr->SiS_VBVCLKData    = (SiS_VBVCLKDataStruct *)SiS310_VBVCLKData;
   SiS_Pr->SiS_ScreenOffset  = SiS310_ScreenOffset;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513

   SiS_Pr->SiS_SR15  = SiS310_SR15;

#ifndef LINUX_XF86
   SiS_Pr->pSiS_SR07 = &SiS310_SR07;
   SiS_Pr->SiS_CR40  = SiS310_CR40;
   SiS_Pr->SiS_CR49  = SiS310_CR49;
   SiS_Pr->pSiS_SR1F = &SiS310_SR1F;
   SiS_Pr->pSiS_SR21 = &SiS310_SR21;
   SiS_Pr->pSiS_SR22 = &SiS310_SR22;
   SiS_Pr->pSiS_SR23 = &SiS310_SR23;
   SiS_Pr->pSiS_SR24 = &SiS310_SR24;
   SiS_Pr->SiS_SR25  = SiS310_SR25;
   SiS_Pr->pSiS_SR31 = &SiS310_SR31;
   SiS_Pr->pSiS_SR32 = &SiS310_SR32;
   SiS_Pr->pSiS_SR33 = &SiS310_SR33;
   SiS_Pr->pSiS_CRT2Data_1_2  = &SiS310_CRT2Data_1_2;
   SiS_Pr->pSiS_CRT2Data_4_D  = &SiS310_CRT2Data_4_D;
   SiS_Pr->pSiS_CRT2Data_4_E  = &SiS310_CRT2Data_4_E;
   SiS_Pr->pSiS_CRT2Data_4_10 = &SiS310_CRT2Data_4_10;
   SiS_Pr->pSiS_RGBSenseData    = &SiS310_RGBSenseData;
   SiS_Pr->pSiS_VideoSenseData  = &SiS310_VideoSenseData;
   SiS_Pr->pSiS_YCSenseData     = &SiS310_YCSenseData;
   SiS_Pr->pSiS_RGBSenseData2   = &SiS310_RGBSenseData2;
   SiS_Pr->pSiS_VideoSenseData2 = &SiS310_VideoSenseData2;
   SiS_Pr->pSiS_YCSenseData2    = &SiS310_YCSenseData2;
#endif

514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635
   SiS_Pr->SiS_StLCD1024x768Data    = (SiS_LCDDataStruct *)SiS310_StLCD1024x768Data;
   SiS_Pr->SiS_ExtLCD1024x768Data   = (SiS_LCDDataStruct *)SiS310_ExtLCD1024x768Data;
   SiS_Pr->SiS_St2LCD1024x768Data   = (SiS_LCDDataStruct *)SiS310_St2LCD1024x768Data;
   SiS_Pr->SiS_StLCD1280x1024Data   = (SiS_LCDDataStruct *)SiS310_StLCD1280x1024Data;
   SiS_Pr->SiS_ExtLCD1280x1024Data  = (SiS_LCDDataStruct *)SiS310_ExtLCD1280x1024Data;
   SiS_Pr->SiS_St2LCD1280x1024Data  = (SiS_LCDDataStruct *)SiS310_St2LCD1280x1024Data;
   SiS_Pr->SiS_NoScaleData1024x768  = (SiS_LCDDataStruct *)SiS310_NoScaleData1024x768;
   SiS_Pr->SiS_NoScaleData1280x1024 = (SiS_LCDDataStruct *)SiS310_NoScaleData1280x1024;

   SiS_Pr->SiS_PanelDelayTbl     = (SiS_PanelDelayTblStruct *)SiS310_PanelDelayTbl;
   SiS_Pr->SiS_PanelDelayTblLVDS = (SiS_PanelDelayTblStruct *)SiS310_PanelDelayTblLVDS;

   SiS_Pr->SiS_CHTVUPALData  = (SiS_LVDSDataStruct *)SiS310_CHTVUPALData;
   SiS_Pr->SiS_CHTVOPALData  = (SiS_LVDSDataStruct *)SiS310_CHTVOPALData;
   SiS_Pr->SiS_CHTVUPALMData = (SiS_LVDSDataStruct *)SiS310_CHTVUPALMData;
   SiS_Pr->SiS_CHTVOPALMData = (SiS_LVDSDataStruct *)SiS310_CHTVOPALMData;
   SiS_Pr->SiS_CHTVUPALNData = (SiS_LVDSDataStruct *)SiS310_CHTVUPALNData;
   SiS_Pr->SiS_CHTVOPALNData = (SiS_LVDSDataStruct *)SiS310_CHTVOPALNData;
   SiS_Pr->SiS_CHTVSOPALData = (SiS_LVDSDataStruct *)SiS310_CHTVSOPALData;

   SiS_Pr->SiS_PanelType00_1 = (SiS_LVDSDesStruct *)SiS310_PanelType00_1;
   SiS_Pr->SiS_PanelType01_1 = (SiS_LVDSDesStruct *)SiS310_PanelType01_1;
   SiS_Pr->SiS_PanelType02_1 = (SiS_LVDSDesStruct *)SiS310_PanelType02_1;
   SiS_Pr->SiS_PanelType03_1 = (SiS_LVDSDesStruct *)SiS310_PanelType03_1;
   SiS_Pr->SiS_PanelType04_1 = (SiS_LVDSDesStruct *)SiS310_PanelType04_1;
   SiS_Pr->SiS_PanelType05_1 = (SiS_LVDSDesStruct *)SiS310_PanelType05_1;
   SiS_Pr->SiS_PanelType06_1 = (SiS_LVDSDesStruct *)SiS310_PanelType06_1;
   SiS_Pr->SiS_PanelType07_1 = (SiS_LVDSDesStruct *)SiS310_PanelType07_1;
   SiS_Pr->SiS_PanelType08_1 = (SiS_LVDSDesStruct *)SiS310_PanelType08_1;
   SiS_Pr->SiS_PanelType09_1 = (SiS_LVDSDesStruct *)SiS310_PanelType09_1;
   SiS_Pr->SiS_PanelType0a_1 = (SiS_LVDSDesStruct *)SiS310_PanelType0a_1;
   SiS_Pr->SiS_PanelType0b_1 = (SiS_LVDSDesStruct *)SiS310_PanelType0b_1;
   SiS_Pr->SiS_PanelType0c_1 = (SiS_LVDSDesStruct *)SiS310_PanelType0c_1;
   SiS_Pr->SiS_PanelType0d_1 = (SiS_LVDSDesStruct *)SiS310_PanelType0d_1;
   SiS_Pr->SiS_PanelType0e_1 = (SiS_LVDSDesStruct *)SiS310_PanelType0e_1;
   SiS_Pr->SiS_PanelType0f_1 = (SiS_LVDSDesStruct *)SiS310_PanelType0f_1;
   SiS_Pr->SiS_PanelType00_2 = (SiS_LVDSDesStruct *)SiS310_PanelType00_2;
   SiS_Pr->SiS_PanelType01_2 = (SiS_LVDSDesStruct *)SiS310_PanelType01_2;
   SiS_Pr->SiS_PanelType02_2 = (SiS_LVDSDesStruct *)SiS310_PanelType02_2;
   SiS_Pr->SiS_PanelType03_2 = (SiS_LVDSDesStruct *)SiS310_PanelType03_2;
   SiS_Pr->SiS_PanelType04_2 = (SiS_LVDSDesStruct *)SiS310_PanelType04_2;
   SiS_Pr->SiS_PanelType05_2 = (SiS_LVDSDesStruct *)SiS310_PanelType05_2;
   SiS_Pr->SiS_PanelType06_2 = (SiS_LVDSDesStruct *)SiS310_PanelType06_2;
   SiS_Pr->SiS_PanelType07_2 = (SiS_LVDSDesStruct *)SiS310_PanelType07_2;
   SiS_Pr->SiS_PanelType08_2 = (SiS_LVDSDesStruct *)SiS310_PanelType08_2;
   SiS_Pr->SiS_PanelType09_2 = (SiS_LVDSDesStruct *)SiS310_PanelType09_2;
   SiS_Pr->SiS_PanelType0a_2 = (SiS_LVDSDesStruct *)SiS310_PanelType0a_2;
   SiS_Pr->SiS_PanelType0b_2 = (SiS_LVDSDesStruct *)SiS310_PanelType0b_2;
   SiS_Pr->SiS_PanelType0c_2 = (SiS_LVDSDesStruct *)SiS310_PanelType0c_2;
   SiS_Pr->SiS_PanelType0d_2 = (SiS_LVDSDesStruct *)SiS310_PanelType0d_2;
   SiS_Pr->SiS_PanelType0e_2 = (SiS_LVDSDesStruct *)SiS310_PanelType0e_2;
   SiS_Pr->SiS_PanelType0f_2 = (SiS_LVDSDesStruct *)SiS310_PanelType0f_2;

   SiS_Pr->SiS_CRT2Part2_1024x768_1  = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1024x768_1;
   SiS_Pr->SiS_CRT2Part2_1280x1024_1 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1280x1024_1;
   SiS_Pr->SiS_CRT2Part2_1400x1050_1 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1400x1050_1;
   SiS_Pr->SiS_CRT2Part2_1600x1200_1 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1600x1200_1;
   SiS_Pr->SiS_CRT2Part2_1024x768_2  = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1024x768_2;
   SiS_Pr->SiS_CRT2Part2_1280x1024_2 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1280x1024_2;
   SiS_Pr->SiS_CRT2Part2_1400x1050_2 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1400x1050_2;
   SiS_Pr->SiS_CRT2Part2_1600x1200_2 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1600x1200_2;
   SiS_Pr->SiS_CRT2Part2_1024x768_3  = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1024x768_3;
   SiS_Pr->SiS_CRT2Part2_1280x1024_3 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1280x1024_3;
   SiS_Pr->SiS_CRT2Part2_1400x1050_3 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1400x1050_3;
   SiS_Pr->SiS_CRT2Part2_1600x1200_3 = (SiS_Part2PortTblStruct *)SiS310_CRT2Part2_1600x1200_3;

   SiS_Pr->SiS_LVDSCRT1800x600_1     = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT1800x600_1;
   SiS_Pr->SiS_LVDSCRT11024x768_1    = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11024x768_1;
   SiS_Pr->SiS_LVDSCRT11280x1024_1   = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11280x1024_1;
   SiS_Pr->SiS_LVDSCRT11400x1050_1   = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11400x1050_1;
   SiS_Pr->SiS_LVDSCRT11600x1200_1   = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11600x1200_1;
   SiS_Pr->SiS_LVDSCRT1800x600_1_H   = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT1800x600_1_H;
   SiS_Pr->SiS_LVDSCRT11024x768_1_H  = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11024x768_1_H;
   SiS_Pr->SiS_LVDSCRT11280x1024_1_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11280x1024_1_H;
   SiS_Pr->SiS_LVDSCRT11400x1050_1_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11400x1050_1_H;
   SiS_Pr->SiS_LVDSCRT11600x1200_1_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11600x1200_1_H;
   SiS_Pr->SiS_LVDSCRT1800x600_2     = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT1800x600_2;
   SiS_Pr->SiS_LVDSCRT11024x768_2    = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11024x768_2;
   SiS_Pr->SiS_LVDSCRT11280x1024_2   = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11280x1024_2;
   SiS_Pr->SiS_LVDSCRT11400x1050_2   = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11400x1050_2;
   SiS_Pr->SiS_LVDSCRT11600x1200_2   = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11600x1200_2;
   SiS_Pr->SiS_LVDSCRT1800x600_2_H   = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT1800x600_2_H;
   SiS_Pr->SiS_LVDSCRT11024x768_2_H  = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11024x768_2_H;
   SiS_Pr->SiS_LVDSCRT11280x1024_2_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11280x1024_2_H;
   SiS_Pr->SiS_LVDSCRT11400x1050_2_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11400x1050_2_H;
   SiS_Pr->SiS_LVDSCRT11600x1200_2_H = (SiS_LVDSCRT1DataStruct *)SiS310_LVDSCRT11600x1200_2_H;
   SiS_Pr->SiS_CHTVCRT1UNTSC         = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1UNTSC;
   SiS_Pr->SiS_CHTVCRT1ONTSC         = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1ONTSC;
   SiS_Pr->SiS_CHTVCRT1UPAL          = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1UPAL;
   SiS_Pr->SiS_CHTVCRT1OPAL          = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1OPAL;
   SiS_Pr->SiS_CHTVCRT1SOPAL         = (SiS_LVDSCRT1DataStruct *)SiS310_CHTVCRT1SOPAL;

   SiS_Pr->SiS_CHTVReg_UNTSC = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_UNTSC;
   SiS_Pr->SiS_CHTVReg_ONTSC = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_ONTSC;
   SiS_Pr->SiS_CHTVReg_UPAL  = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_UPAL;
   SiS_Pr->SiS_CHTVReg_OPAL  = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_OPAL;
   SiS_Pr->SiS_CHTVReg_UPALM = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_UPALM;
   SiS_Pr->SiS_CHTVReg_OPALM = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_OPALM;
   SiS_Pr->SiS_CHTVReg_UPALN = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_UPALN;
   SiS_Pr->SiS_CHTVReg_OPALN = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_OPALN;
   SiS_Pr->SiS_CHTVReg_SOPAL = (SiS_CHTVRegDataStruct *)SiS310_CHTVReg_SOPAL;

   SiS_Pr->SiS_LCDACRT1800x600_1     = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT1800x600_1;
   SiS_Pr->SiS_LCDACRT11024x768_1    = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11024x768_1;
   SiS_Pr->SiS_LCDACRT11280x1024_1   = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11280x1024_1;
   SiS_Pr->SiS_LCDACRT11400x1050_1   = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11400x1050_1;
   SiS_Pr->SiS_LCDACRT11600x1200_1   = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11600x1200_1;
   SiS_Pr->SiS_LCDACRT1800x600_1_H   = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT1800x600_1_H;
   SiS_Pr->SiS_LCDACRT11024x768_1_H  = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11024x768_1_H;
   SiS_Pr->SiS_LCDACRT11280x1024_1_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11280x1024_1_H;
   SiS_Pr->SiS_LCDACRT11400x1050_1_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11400x1050_1_H;
   SiS_Pr->SiS_LCDACRT11600x1200_1_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11600x1200_1_H;
   SiS_Pr->SiS_LCDACRT1800x600_2     = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT1800x600_2;
   SiS_Pr->SiS_LCDACRT11024x768_2    = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11024x768_2;
   SiS_Pr->SiS_LCDACRT11280x1024_2   = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11280x1024_2;
   SiS_Pr->SiS_LCDACRT11400x1050_2   = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11400x1050_2;
   SiS_Pr->SiS_LCDACRT11600x1200_2   = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11600x1200_2;
   SiS_Pr->SiS_LCDACRT1800x600_2_H   = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT1800x600_2_H;
   SiS_Pr->SiS_LCDACRT11024x768_2_H  = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11024x768_2_H;
   SiS_Pr->SiS_LCDACRT11280x1024_2_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11280x1024_2_H;
   SiS_Pr->SiS_LCDACRT11400x1050_2_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11400x1050_2_H;
   SiS_Pr->SiS_LCDACRT11600x1200_2_H = (SiS_LCDACRT1DataStruct *)SiS310_LCDACRT11600x1200_2_H;
636

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
637 638 639 640 641 642 643
   SiS_Pr->SiS_CHTVVCLKUNTSC = SiS310_CHTVVCLKUNTSC;
   SiS_Pr->SiS_CHTVVCLKONTSC = SiS310_CHTVVCLKONTSC;
   SiS_Pr->SiS_CHTVVCLKUPAL  = SiS310_CHTVVCLKUPAL;
   SiS_Pr->SiS_CHTVVCLKOPAL  = SiS310_CHTVVCLKOPAL;
   SiS_Pr->SiS_CHTVVCLKUPALM = SiS310_CHTVVCLKUPALM;
   SiS_Pr->SiS_CHTVVCLKOPALM = SiS310_CHTVVCLKOPALM;
   SiS_Pr->SiS_CHTVVCLKUPALN = SiS310_CHTVVCLKUPALN;
644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665
   SiS_Pr->SiS_CHTVVCLKOPALN = SiS310_CHTVVCLKOPALN;   
   SiS_Pr->SiS_CHTVVCLKSOPAL = SiS310_CHTVVCLKSOPAL;

   SiS_Pr->SiS_Panel320x480   = Panel_320x480;
   SiS_Pr->SiS_Panel640x480   = Panel_640x480;
   SiS_Pr->SiS_Panel800x600   = Panel_800x600;
   SiS_Pr->SiS_Panel1024x768  = Panel_1024x768;
   SiS_Pr->SiS_Panel1280x1024 = Panel_1280x1024;
   SiS_Pr->SiS_Panel1280x960  = Panel_1280x960;
   SiS_Pr->SiS_Panel1600x1200 = Panel_1600x1200;
   SiS_Pr->SiS_Panel1400x1050 = Panel_1400x1050;
   SiS_Pr->SiS_Panel1152x768  = Panel_1152x768;
   SiS_Pr->SiS_Panel1152x864  = Panel_1152x864;
   SiS_Pr->SiS_Panel1280x768  = Panel_1280x768;
   SiS_Pr->SiS_Panel1024x600  = Panel_1024x600;
   SiS_Pr->SiS_Panel640x480_2 = Panel_640x480_2;
   SiS_Pr->SiS_Panel640x480_3 = Panel_640x480_3;
   SiS_Pr->SiS_PanelMax       = Panel_320x480;    /* TW: highest value */
   SiS_Pr->SiS_PanelMinLVDS   = Panel_800x600;    /* TW: lowest value LVDS/LCDA */
   SiS_Pr->SiS_PanelMin301    = Panel_1024x768;   /* TW: lowest value 301 */
   SiS_Pr->SiS_PanelCustom    = Panel_Custom;
   SiS_Pr->SiS_PanelBarco1366 = 255;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
666 667 668
}
#endif

669 670
#ifdef SIS315H
UCHAR
671
SiS_Get310DRAMType(SiS_Private *SiS_Pr, UCHAR *ROMAddr,PSIS_HW_DEVICE_INFO HwDeviceExtension)
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
672
{
673
   UCHAR data, temp;
674

675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696
   if(*SiS_Pr->pSiS_SoftSetting & SoftDRAMType) {
     data = *SiS_Pr->pSiS_SoftSetting & 0x03;
   } else {
     if(IS_SIS550650740660) {
        data = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x13) & 0x07;
     } else {	/* TW: 315, 330 */
        data = SiS_GetReg1(SiS_Pr->SiS_P3c4,0x3a) & 0x03;
        if(HwDeviceExtension->jChipType == SIS_330) {
	   if(data > 1) {
	      temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x5f) & 0x30;
	      switch(temp) {
	      case 0x00: data = 1; break;
	      case 0x10: data = 3; break;
	      case 0x20: data = 3; break;
	      case 0x30: data = 2; break;
	      }
	   } else {
	      data = 0;
	   }
	}
     }
   }
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
697

698
   return data;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
699
}
700
#endif
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
701

702
/* ----------------------------------------- */
703

704
void SiSRegInit(SiS_Private *SiS_Pr, USHORT BaseAddr)
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
705
{
706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727
   SiS_Pr->SiS_P3c4 = BaseAddr + 0x14;
   SiS_Pr->SiS_P3d4 = BaseAddr + 0x24;
   SiS_Pr->SiS_P3c0 = BaseAddr + 0x10;
   SiS_Pr->SiS_P3ce = BaseAddr + 0x1e;
   SiS_Pr->SiS_P3c2 = BaseAddr + 0x12;
   SiS_Pr->SiS_P3ca = BaseAddr + 0x1a;
   SiS_Pr->SiS_P3c6 = BaseAddr + 0x16;
   SiS_Pr->SiS_P3c7 = BaseAddr + 0x17;
   SiS_Pr->SiS_P3c8 = BaseAddr + 0x18;
   SiS_Pr->SiS_P3c9 = BaseAddr + 0x19;
   SiS_Pr->SiS_P3cb = BaseAddr + 0x1b;
   SiS_Pr->SiS_P3cd = BaseAddr + 0x1d;
   SiS_Pr->SiS_P3da = BaseAddr + 0x2a;
   SiS_Pr->SiS_Part1Port = BaseAddr + SIS_CRT2_PORT_04;     /* Digital video interface registers (LCD) */
   SiS_Pr->SiS_Part2Port = BaseAddr + SIS_CRT2_PORT_10;     /* 301 TV Encoder registers */
   SiS_Pr->SiS_Part3Port = BaseAddr + SIS_CRT2_PORT_12;     /* 301 Macrovision registers */
   SiS_Pr->SiS_Part4Port = BaseAddr + SIS_CRT2_PORT_14;     /* 301 VGA2 (and LCD) registers */
   SiS_Pr->SiS_Part5Port = BaseAddr + SIS_CRT2_PORT_14 + 2; /* 301 palette address port registers */
   SiS_Pr->SiS_DDC_Port = BaseAddr + 0x14;                  /* DDC Port ( = P3C4, SR11/0A) */
   SiS_Pr->SiS_VidCapt = BaseAddr + SIS_VIDEO_CAPTURE;
   SiS_Pr->SiS_VidPlay = BaseAddr + SIS_VIDEO_PLAYBACK;
}
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
728

729 730
void
SiSInitPCIetc(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension)
731
{
732
   switch(HwDeviceExtension->jChipType) {
733 734 735 736 737 738 739 740
   case SIS_300:
   case SIS_540:
   case SIS_630:
   case SIS_730:
      /* Set - PCI LINEAR ADDRESSING ENABLE (0x80)
       *     - RELOCATED VGA IO  (0x20)
       *     - MMIO ENABLE (0x1)
       */
741
      SiS_SetReg1(SiS_Pr->SiS_P3c4,0x20,0xa1);
742 743 744 745 746 747 748 749 750 751 752 753 754 755 756
      /*  - Enable 2D (0x40)
       *  - Enable 3D (0x02)
       *  - Enable 3D Vertex command fetch (0x10) ?
       *  - Enable 3D command parser (0x08) ?
       */
      SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x5A);
      break;
   case SIS_315H:
   case SIS_315:
   case SIS_315PRO:
   case SIS_650:
   case SIS_740:
   case SIS_330:
   case SIS_660:
   case SIS_760:
757
      SiS_SetReg1(SiS_Pr->SiS_P3c4,0x20,0xa1);
758 759 760 761 762 763 764 765 766
      /*  - Enable 2D (0x40)
       *  - Enable 3D (0x02)
       *  - Enable 3D vertex command fetch (0x10)
       *  - Enable 3D command parser (0x08)
       *  - Enable 3D G/L transformation engine (0x80)
       */
      SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0xDA);
      break;
   case SIS_550:
767
      SiS_SetReg1(SiS_Pr->SiS_P3c4,0x20,0xa1);
768 769 770 771 772
      /* No 3D engine ! */
      /*  - Enable 2D (0x40)
       */
      SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x40);
   }
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
773 774 775
}

void
776
SiSSetLVDSetc(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension,USHORT ModeNo)
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
777
{
778
   ULONG   temp;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
779

780 781 782
   SiS_Pr->SiS_IF_DEF_LVDS = 0;
   SiS_Pr->SiS_IF_DEF_TRUMPION = 0;
   SiS_Pr->SiS_IF_DEF_CH70xx = 0;
783
   SiS_Pr->SiS_IF_DEF_HiVision = 0;
784 785
   SiS_Pr->SiS_IF_DEF_DSTN = 0;
   SiS_Pr->SiS_IF_DEF_FSTN = 0;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
786

787
   SiS_Pr->SiS_ChrontelInit = 0;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
788

789 790 791 792 793 794 795 796
#if 0
   if(HwDeviceExtension->jChipType >= SIS_315H) {
      if((ModeNo == 0x5a) || (ModeNo == 0x5b)) {
   	 SiS_Pr->SiS_IF_DEF_DSTN = 1;   /* for 550 dstn */
   	 SiS_Pr->SiS_IF_DEF_FSTN = 1;   /* for fstn */
      }
   }
#endif
797

798
   switch(HwDeviceExtension->jChipType) {
799 800 801 802
#ifdef SIS300
   case SIS_540:
   case SIS_630:
   case SIS_730:
803 804 805 806
        /* Check for SiS30x first */
        temp = SiS_GetReg1(SiS_Pr->SiS_Part4Port,0x00);
	if((temp == 1) || (temp == 2)) return;
      	temp = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x37);
807
      	temp = (temp & 0x0E) >> 1;
808 809
      	if((temp >= 2) && (temp <= 5)) SiS_Pr->SiS_IF_DEF_LVDS = 1;
      	if(temp == 3)   SiS_Pr->SiS_IF_DEF_TRUMPION = 1;
810 811 812 813 814 815 816 817 818 819 820 821 822 823
      	if((temp == 4) || (temp == 5)) {
		/* Save power status (and error check) - UNUSED */
		SiS_Pr->SiS_Backup70xx = SiS_GetCH700x(SiS_Pr, 0x0e);
		SiS_Pr->SiS_IF_DEF_CH70xx = 1;
        }
	break;
#endif
#ifdef SIS315H
   case SIS_550:
   case SIS_650:
   case SIS_740:
   case SIS_330:
   case SIS_660:
   case SIS_760:
824 825 826 827
	temp=SiS_GetReg1(SiS_Pr->SiS_P3d4,0x37);
      	temp = (temp & 0x0E) >> 1;
      	if((temp >= 2) && (temp <= 3)) SiS_Pr->SiS_IF_DEF_LVDS = 1;
      	if(temp == 3)  SiS_Pr->SiS_IF_DEF_CH70xx = 2;
828 829 830 831 832 833
        break;
#endif
   default:
        break;
   }
}
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
834

835
void
836
SiSInitPtr(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension)
837
{
838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862
   switch(HwDeviceExtension->jChipType) {
#ifdef SIS315H
   case SIS_315H:
   case SIS_315:
   case SIS_315PRO:
   case SIS_550:
   case SIS_650:
   case SIS_740:
   case SIS_330:
   case SIS_660:
   case SIS_760:
      InitTo310Pointer(SiS_Pr, HwDeviceExtension);
      break;
#endif
#ifdef SIS300
   case SIS_300:
   case SIS_540:
   case SIS_630:
   case SIS_730:
      InitTo300Pointer(SiS_Pr, HwDeviceExtension);
      break;
#endif
   default:
      break;
   }
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
863 864
}

865
void
866
SiSDetermineROMUsage(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, UCHAR *ROMAddr)
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
867
{
868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898
   if((ROMAddr) && (HwDeviceExtension->UseROM)) {
     if((ROMAddr[0x00] != 0x55) || (ROMAddr[0x01] != 0xAA)) {
        SiS_Pr->SiS_UseROM = FALSE;
     } else if(HwDeviceExtension->jChipType == SIS_300) {
        /* TW: 300: We check if the code starts below 0x220 by
	 *     checking the jmp instruction at the beginning
	 *     of the BIOS image.
	 */
	 if((ROMAddr[3] == 0xe9) &&
	    ((ROMAddr[5] << 8) | ROMAddr[4]) > 0x21a)
	      SiS_Pr->SiS_UseROM = TRUE;
	 else SiS_Pr->SiS_UseROM = FALSE;
     } else if(HwDeviceExtension->jChipType < SIS_315H) {
#if 0
        /* TW: Rest of 300 series: We don't use the ROM image if
	 *     the BIOS version < 2.0.0 as such old BIOSes don't
	 *     have the needed data at the expected locations.
	 */
        if(ROMAddr[0x06] < '2')  SiS_Pr->SiS_UseROM = FALSE;
	else                     SiS_Pr->SiS_UseROM = TRUE;
#else
	/* Sony's VAIO BIOS 1.09 follows the standard, so perhaps
	 * the others do as well
	 */
	SiS_Pr->SiS_UseROM = TRUE;
#endif
     } else {
        /* TW: 315/330 series stick to the standard */
	SiS_Pr->SiS_UseROM = TRUE;
     }
   } else SiS_Pr->SiS_UseROM = FALSE;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
899

900
}
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
901

902 903 904 905 906 907 908
/*
 	=========================================
 	======== SiS SetMode Functions ==========
 	=========================================
*/
#ifdef LINUX_XF86
/* TW: This is used for non-Dual-Head mode from X */
909
BOOLEAN
910 911
SiSBIOSSetMode(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, ScrnInfoPtr pScrn,
               DisplayModePtr mode, BOOLEAN IsCustom)
912
{
913 914 915 916
   SISPtr  pSiS = SISPTR(pScrn);
   UShort  ModeNo=0;
   
   SiS_Pr->UseCustomMode = FALSE;
917

918 919 920 921 922 923 924
   if((IsCustom) && (SiS_CheckBuildCustomMode(pScrn, mode, pSiS->VBFlags))) {

         xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "Setting custom mode %dx%d\n",
	 	SiS_Pr->CHDisplay,
		(mode->Flags & V_INTERLACE ? SiS_Pr->CVDisplay * 2 :
		   (mode->Flags & V_DBLSCAN ? SiS_Pr->CVDisplay / 2 :
		      SiS_Pr->CVDisplay)));
925

926
	 return(SiSSetMode(SiS_Pr, HwDeviceExtension, pScrn, ModeNo, TRUE));
927

928
   }
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
929

930 931
   ModeNo = SiS_CalcModeIndex(pScrn, mode, pSiS->HaveCustomModes);
   if(!ModeNo) return FALSE;
932

933
   xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "Setting standard mode 0x%x\n", ModeNo);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
934

935
   return(SiSSetMode(SiS_Pr, HwDeviceExtension, pScrn, ModeNo, TRUE));
936
}
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
937

938 939 940 941 942
#ifdef SISDUALHEAD
/* TW: Set CRT1 mode (used for dual head and MergedFB) */
BOOLEAN
SiSBIOSSetModeCRT1(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, ScrnInfoPtr pScrn,
               DisplayModePtr mode, BOOLEAN IsCustom)
943
{
944 945 946 947 948 949 950 951 952 953 954
   ULONG   temp;
   USHORT  ModeIdIndex;
   UCHAR  *ROMAddr  = HwDeviceExtension->pjVirtualRomBase;
   USHORT  BaseAddr = (USHORT)HwDeviceExtension->ulIOAddress;
   SISPtr  pSiS = SISPTR(pScrn);
   SISEntPtr pSiSEnt = pSiS->entityPrivate;
   unsigned char backupreg=0;
   BOOLEAN backupcustom;
   UShort  ModeNo=0;
   
   SiS_Pr->UseCustomMode = FALSE;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
955

956
   if((IsCustom) && (SiS_CheckBuildCustomMode(pScrn, mode, pSiS->VBFlags))) {
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
957

958
         USHORT temptemp = SiS_Pr->CVDisplay;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
959

960 961
         if(SiS_Pr->CModeFlag & DoubleScanMode)     temptemp >>= 1;
         else if(SiS_Pr->CInfoFlag & InterlaceMode) temptemp <<= 1;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
962

963 964 965 966
         xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
	 	"Setting custom mode %dx%d on CRT1\n",
	 	SiS_Pr->CHDisplay, temptemp);
	 ModeNo = 0xfe;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
967

968
   } else {
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
969

970 971
         ModeNo = SiS_CalcModeIndex(pScrn, mode, pSiS->HaveCustomModes);
         if(!ModeNo) return FALSE;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
972

973 974 975
         xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
	 	"Setting standard mode 0x%x on CRT1\n", ModeNo);
   }
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
976

977
   SiSInitPtr(SiS_Pr, HwDeviceExtension);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
978

979
   SiSRegInit(SiS_Pr, BaseAddr);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
980

981
   SiS_GetSysFlags(SiS_Pr, HwDeviceExtension);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
982

983
   SiS_Pr->SiS_VGAINFO = SiS_GetSetBIOSScratch(pScrn, 0x489, 0xff);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
984

985
   SiSInitPCIetc(SiS_Pr, HwDeviceExtension);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
986

987
   SiSSetLVDSetc(SiS_Pr, HwDeviceExtension, ModeNo);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
988

989
   SiSDetermineROMUsage(SiS_Pr, HwDeviceExtension, ROMAddr);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
990

991 992
   /* We don't clear the buffer under X */
   SiS_Pr->SiS_flag_clearbuffer = 0;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
993

994 995
   /* 1.Openkey */
   SiS_SetReg1(SiS_Pr->SiS_P3c4,0x05,0x86);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
996

997
   SiS_UnLockCRT2(SiS_Pr, HwDeviceExtension, BaseAddr);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
998

999 1000 1001 1002 1003 1004 1005
   /* 2.Get ModeID Table  */
   if(!SiS_Pr->UseCustomMode) {
      temp = SiS_SearchModeID(SiS_Pr, ROMAddr,&ModeNo,&ModeIdIndex);
      if(temp == 0)  return(0);
   } else {
      ModeIdIndex = 0;
   }
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1006

1007 1008
   /* TW: Determine VBType (301,301B,301LV,302B,302LV) */
   SiS_GetVBType(SiS_Pr, BaseAddr,HwDeviceExtension);
1009

1010 1011 1012 1013 1014 1015 1016
   if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
      if(HwDeviceExtension->jChipType >= SIS_315H) {
         backupreg = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38);
      } else {
         backupreg = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x35);
      }
   }
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1017

1018 1019 1020 1021 1022
   /* TW: Get VB information (connectors, connected devices) */
   /* (We don't care if the current mode is a CRT2 mode) */
   SiS_GetVBInfo(SiS_Pr, BaseAddr,ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension,0);
   SiS_SetHiVision(SiS_Pr, BaseAddr,HwDeviceExtension);
   SiS_GetLCDResInfo(SiS_Pr, ROMAddr,ModeNo,ModeIdIndex,HwDeviceExtension);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1023

1024 1025 1026 1027 1028 1029 1030 1031
   if(HwDeviceExtension->jChipType >= SIS_315H) {
      if(SiS_GetReg1(SiS_Pr->SiS_P3c4,0x17) & 0x08)  {
         if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
            if(ModeNo != 0x10)  SiS_Pr->SiS_SetFlag |= SetDOSMode;
         } else if((IS_SIS651) && (SiS_Pr->SiS_VBType & VB_NoLCD)) {
            SiS_Pr->SiS_SetFlag |= SetDOSMode;
         }
      }
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1032

1033 1034 1035 1036 1037 1038 1039 1040
      if(IS_SIS650) {
         if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
	    SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x51,0x1f);
	    if(IS_SIS651) SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x51,0x20);
	    SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x56,0xe7);
	 }
      }
   }
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1041

1042 1043
   /* Set mode on CRT1 */
   SiS_SetCRT1Group(SiS_Pr, ROMAddr,HwDeviceExtension,ModeNo,ModeIdIndex,BaseAddr);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1044

1045 1046
   /* SetPitch: Adapt to virtual size & position */
   SiS_SetPitchCRT1(SiS_Pr, pScrn, BaseAddr);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1047

1048 1049 1050 1051
   if(pSiS->DualHeadMode) {
      pSiSEnt->CRT1ModeNo = ModeNo;
      pSiSEnt->CRT1DMode = mode;
   }
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1052

1053 1054 1055 1056 1057 1058 1059
   if(SiS_Pr->UseCustomMode) {
      SiS_Pr->CRT1UsesCustomMode = TRUE;
      SiS_Pr->CSRClock_CRT1 = SiS_Pr->CSRClock;
      SiS_Pr->CModeFlag_CRT1 = SiS_Pr->CModeFlag;
   } else {
      SiS_Pr->CRT1UsesCustomMode = FALSE;
   }
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1060

1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071
   /* We have to reset CRT2 if changing mode on CRT1 */
   if(pSiS->DualHeadMode) {
      if(pSiSEnt->CRT2ModeNo != -1) {
         xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
				"(Re-)Setting mode for CRT2\n");
	 backupcustom = SiS_Pr->UseCustomMode;
	 SiSBIOSSetModeCRT2(SiS_Pr, HwDeviceExtension, pSiSEnt->pScrn_1,
			    pSiSEnt->CRT2DMode, pSiSEnt->CRT2IsCustom);
	 SiS_Pr->UseCustomMode = backupcustom;
      }
   }
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1072

1073 1074 1075
   /* Warning: From here, the custom mode entries in SiS_Pr are
    * possibly overwritten
    */
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1076

1077
   SiS_HandleCRT1(SiS_Pr);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1078

1079
   SiS_StrangeStuff(SiS_Pr, HwDeviceExtension);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1080

1081 1082
   SiS_DisplayOn(SiS_Pr);
   SiS_SetReg3(SiS_Pr->SiS_P3c6,0xFF);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1083

1084 1085 1086 1087 1088 1089 1090 1091
   if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
      if(HwDeviceExtension->jChipType >= SIS_315H) {
	 SiS_SetReg1(SiS_Pr->SiS_P3d4,0x38,backupreg);
      } else if((HwDeviceExtension->jChipType == SIS_630) ||
                (HwDeviceExtension->jChipType == SIS_730)) {
         SiS_SetReg1(SiS_Pr->SiS_P3d4,0x35,backupreg);
      }
   }
1092

1093 1094
   /* Backup/Set ModeNo in BIOS scratch area */
   SiS_GetSetModeID(pScrn,ModeNo);
1095

1096
   return TRUE;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1097
}
1098

1099
/* TW: Set CRT2 mode (used for dual head) */
1100
BOOLEAN
1101 1102
SiSBIOSSetModeCRT2(SiS_Private *SiS_Pr, PSIS_HW_DEVICE_INFO HwDeviceExtension, ScrnInfoPtr pScrn,
               DisplayModePtr mode, BOOLEAN IsCustom)
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1103
{
1104 1105 1106 1107 1108 1109 1110 1111
   ULONG   temp;
   USHORT  ModeIdIndex;
   UCHAR  *ROMAddr  = HwDeviceExtension->pjVirtualRomBase;
   USHORT  BaseAddr = (USHORT)HwDeviceExtension->ulIOAddress;
   UShort  ModeNo   = 0;
   SISPtr  pSiS     = SISPTR(pScrn);
   SISEntPtr pSiSEnt = pSiS->entityPrivate;
   unsigned char tempr1, tempr2, backupreg=0;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1112

1113
   SiS_Pr->UseCustomMode = FALSE;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1114

1115 1116 1117 1118 1119
   /* Remember: Custom modes for CRT2 are ONLY supported
    * 		-) on 315/330 series,
    *           -) on the 301 and 30xB, and
    *           -) if CRT2 is LCD or VGA
    */
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1120

1121
   if((IsCustom) && (SiS_CheckBuildCustomMode(pScrn, mode, pSiS->VBFlags))) {
1122

1123
	 ModeNo = 0xfe;
1124 1125 1126

   } else {

1127
         BOOLEAN havecustommodes = pSiS->HaveCustomModes;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1128

1129 1130 1131
#ifdef SISMERGED
	 if(pSiS->MergedFB) havecustommodes = pSiS->HaveCustomModes2;
#endif
1132

1133 1134
         ModeNo = SiS_CalcModeIndex(pScrn, mode, havecustommodes);
         if(!ModeNo) return FALSE;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1135

1136
   }
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1137

1138 1139 1140 1141 1142
   /* Save mode info so we can set it from within SetMode for CRT1 */
   if(pSiS->DualHeadMode) {
      pSiSEnt->CRT2ModeNo = ModeNo;
      pSiSEnt->CRT2DMode = mode;
      pSiSEnt->CRT2IsCustom = IsCustom;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1143

1144 1145 1146 1147 1148 1149 1150
      /* We can't set CRT2 mode before CRT1 mode is set */
      if(pSiSEnt->CRT1ModeNo == -1) {
    	 xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
		"Setting CRT2 mode delayed until after setting CRT1 mode\n");
   	 return TRUE;
      }
   }
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1151

1152
   SiSInitPtr(SiS_Pr, HwDeviceExtension);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1153

1154
   SiSRegInit(SiS_Pr, BaseAddr);
1155

1156
   SiS_GetSysFlags(SiS_Pr, HwDeviceExtension);
1157

1158
   SiS_Pr->SiS_VGAINFO = SiS_GetSetBIOSScratch(pScrn, 0x489, 0xff);
1159

1160
   SiSInitPCIetc(SiS_Pr, HwDeviceExtension);
1161

1162
   SiSSetLVDSetc(SiS_Pr, HwDeviceExtension, ModeNo);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1163

1164
   SiSDetermineROMUsage(SiS_Pr, HwDeviceExtension, ROMAddr);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1165

1166 1167 1168 1169
   /* We don't clear the buffer under X */
   SiS_Pr->SiS_flag_clearbuffer=0;

   if(SiS_Pr->UseCustomMode) {
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1170

1171
      USHORT temptemp = SiS_Pr->CVDisplay;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1172

1173 1174
      if(SiS_Pr->CModeFlag & DoubleScanMode)     temptemp >>= 1;
      else if(SiS_Pr->CInfoFlag & InterlaceMode) temptemp <<= 1;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1175

1176 1177 1178
      xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
	  "Setting custom mode %dx%d on CRT2\n",
	  SiS_Pr->CHDisplay, temptemp);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1179

1180
   } else {
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1181

1182 1183
      xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
   	  "Setting standard mode 0x%x on CRT2\n", ModeNo);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1184

1185
   }
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1186

1187 1188
   /* 1.Openkey */
   SiS_SetReg1(SiS_Pr->SiS_P3c4,0x05,0x86);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1189

1190
   SiS_UnLockCRT2(SiS_Pr, HwDeviceExtension, BaseAddr);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1191

1192 1193 1194 1195 1196 1197 1198
   /* 2.Get ModeID */
   if(!SiS_Pr->UseCustomMode) {
      temp = SiS_SearchModeID(SiS_Pr, ROMAddr,&ModeNo,&ModeIdIndex);
      if(temp == 0)  return(0);
   } else {
      ModeIdIndex = 0;
   }
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1199

1200 1201
   /* Determine VBType (301,301B,301LV,302B,302LV) */
   SiS_GetVBType(SiS_Pr, BaseAddr,HwDeviceExtension);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1202 1203

   if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
1204 1205 1206 1207 1208 1209 1210 1211
      if(HwDeviceExtension->jChipType >= SIS_315H) {
         SiS_UnLockCRT2(SiS_Pr,HwDeviceExtension,BaseAddr);
	 if(HwDeviceExtension->jChipType < SIS_330) {
           if(ROMAddr && SiS_Pr->SiS_UseROM) {
             temp = ROMAddr[VB310Data_1_2_Offset];
	     temp |= 0x40;
             SiS_SetReg1(SiS_Pr->SiS_Part1Port,0x02,temp);
           }
1212
	 }
1213 1214 1215 1216 1217 1218 1219
	 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x32,0x10);

	 SiS_SetRegOR(SiS_Pr->SiS_Part2Port,0x02,0x0c);

         backupreg = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x38);
      } else {
         backupreg = SiS_GetReg1(SiS_Pr->SiS_P3d4,0x35);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1220 1221 1222
      }
   }

1223 1224 1225 1226 1227 1228