aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/sis/init301.c
diff options
context:
space:
mode:
authorThomas Winischhofer <thomas@winischhofer.net>2005-09-09 16:04:45 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-09-09 16:58:01 -0400
commit544393fe584d333480659a4bed30f5295355df11 (patch)
tree873b30c67cdbb5cb93e6fd816692db312ed6ddd6 /drivers/video/sis/init301.c
parent5c06e2aa6339112befdc87b350b8bf712890d7a7 (diff)
[PATCH] sisfb update
This lifts sisfb from version 1.7.17 to version 1.8.9. Changes include: - Added support for XGI V3XT, V5, V8, Z7 chipsets, including POSTing of all of these chipsets. - Added support for latest SiS chipsets (761). - Added support for SiS76x memory "hybrid" mode. - Added support for new LCD resolutions (eg 1280x854, 856x480). - Fixed support for 320x240 STN panels (for embedded devices). - Fixed many HDTV modes (525p, 750p, 1080i). - Fixed PCI config register reading/writing to use proper kernel functions for this purpose. - Fixed PCI ROM handling to use the kernel's proper functions. - Removed lots of "typedef"s. - Removed lots of code which was for X.org/XFree86 only. - Fixed coding style in many places. - Removed lots of 2.4 cruft. - Reduced stack size by unifying two previously separate structs into one. - Added new hooks for memory allocation (for DRM). Now the driver can truly handle multiple cards, including memory management. - Fixed numerous minor bugs. Signed-off-by: Thomas Winischhofer <thomas@winischhofer.net> Cc: "Antonino A. Daplas" <adaplas@pol.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/video/sis/init301.c')
-rw-r--r--drivers/video/sis/init301.c9630
1 files changed, 4331 insertions, 5299 deletions
diff --git a/drivers/video/sis/init301.c b/drivers/video/sis/init301.c
index 274dacd54bb8..2d88f908170a 100644
--- a/drivers/video/sis/init301.c
+++ b/drivers/video/sis/init301.c
@@ -2,11 +2,12 @@
2/* $XdotOrg$ */ 2/* $XdotOrg$ */
3/* 3/*
4 * Mode initializing code (CRT2 section) 4 * Mode initializing code (CRT2 section)
5 * for SiS 300/305/540/630/730 and 5 * for SiS 300/305/540/630/730,
6 * SiS 315/550/650/M650/651/661FX/M661xX/740/741(GX)/M741/330/660/M660/760/M760 6 * SiS 315/550/[M]650/651/[M]661[FGM]X/[M]74x[GX]/330/[M]76x[GX],
7 * (Universal module for Linux kernel framebuffer and XFree86/X.org 4.x) 7 * XGI V3XT/V5/V8, Z7
8 * (Universal module for Linux kernel framebuffer and X.org/XFree86 4.x)
8 * 9 *
9 * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria 10 * Copyright (C) 2001-2005 by Thomas Winischhofer, Vienna, Austria
10 * 11 *
11 * If distributed as part of the Linux kernel, the following license terms 12 * If distributed as part of the Linux kernel, the following license terms
12 * apply: 13 * apply:
@@ -38,7 +39,7 @@
38 * * 3) The name of the author may not be used to endorse or promote products 39 * * 3) The name of the author may not be used to endorse or promote products
39 * * derived from this software without specific prior written permission. 40 * * derived from this software without specific prior written permission.
40 * * 41 * *
41 * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR 42 * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
42 * * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 43 * * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
43 * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 44 * * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
44 * * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 45 * * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
@@ -54,20 +55,20 @@
54 * Formerly based on non-functional code-fragements for 300 series by SiS, Inc. 55 * Formerly based on non-functional code-fragements for 300 series by SiS, Inc.
55 * Used by permission. 56 * Used by permission.
56 * 57 *
57 * TW says: This code looks awful, I know. But please don't do anything about
58 * this otherwise debugging will be hell.
59 * The code is extremely fragile as regards the different chipsets, different
60 * video bridges and combinations thereof. If anything is changed, extreme
61 * care has to be taken that that change doesn't break it for other chipsets,
62 * bridges or combinations thereof.
63 * All comments in this file are by me, regardless if marked TW or not.
64 *
65 */ 58 */
66 59
60#ifdef HAVE_CONFIG_H
61#include "config.h"
62#endif
63
67#if 1 64#if 1
68#define SET_EMI /* 302LV/ELV: Set EMI values */ 65#define SET_EMI /* 302LV/ELV: Set EMI values */
69#endif 66#endif
70 67
68#if 1
69#define SET_PWD /* 301/302LV: Set PWD */
70#endif
71
71#define COMPAL_HACK /* Needed for Compal 1400x1050 (EMI) */ 72#define COMPAL_HACK /* Needed for Compal 1400x1050 (EMI) */
72#define COMPAQ_HACK /* Needed for Inventec/Compaq 1280x1024 (EMI) */ 73#define COMPAQ_HACK /* Needed for Inventec/Compaq 1280x1024 (EMI) */
73#define ASUS_HACK /* Needed for Asus A2H 1024x768 (EMI) */ 74#define ASUS_HACK /* Needed for Asus A2H 1024x768 (EMI) */
@@ -85,26 +86,35 @@
85#define SiS_I2CDELAY 1000 86#define SiS_I2CDELAY 1000
86#define SiS_I2CDELAYSHORT 150 87#define SiS_I2CDELAYSHORT 150
87 88
88static USHORT SiS_GetBIOSLCDResInfo(SiS_Private *SiS_Pr); 89static unsigned short SiS_GetBIOSLCDResInfo(struct SiS_Private *SiS_Pr);
89static void SiS_SetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx); 90#ifdef SIS_LINUX_KERNEL
91static void SiS_SetCH70xx(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val);
92#endif
90 93
91/*********************************************/ 94/*********************************************/
92/* HELPER: Lock/Unlock CRT2 */ 95/* HELPER: Lock/Unlock CRT2 */
93/*********************************************/ 96/*********************************************/
94 97
95void 98void
96SiS_UnLockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 99SiS_UnLockCRT2(struct SiS_Private *SiS_Pr)
97{ 100{
98 if(HwInfo->jChipType >= SIS_315H) 101 if(SiS_Pr->ChipType == XGI_20)
102 return;
103 else if(SiS_Pr->ChipType >= SIS_315H)
99 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2f,0x01); 104 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2f,0x01);
100 else 105 else
101 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x24,0x01); 106 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x24,0x01);
102} 107}
103 108
104static void 109#ifdef SIS_LINUX_KERNEL
105SiS_LockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 110static
111#endif
112void
113SiS_LockCRT2(struct SiS_Private *SiS_Pr)
106{ 114{
107 if(HwInfo->jChipType >= SIS_315H) 115 if(SiS_Pr->ChipType == XGI_20)
116 return;
117 else if(SiS_Pr->ChipType >= SIS_315H)
108 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2F,0xFE); 118 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2F,0xFE);
109 else 119 else
110 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x24,0xFE); 120 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x24,0xFE);
@@ -115,9 +125,9 @@ SiS_LockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
115/*********************************************/ 125/*********************************************/
116 126
117static void 127static void
118SiS_SetRegSR11ANDOR(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT DataAND, USHORT DataOR) 128SiS_SetRegSR11ANDOR(struct SiS_Private *SiS_Pr, unsigned short DataAND, unsigned short DataOR)
119{ 129{
120 if(HwInfo->jChipType >= SIS_661) { 130 if(SiS_Pr->ChipType >= SIS_661) {
121 DataAND &= 0x0f; 131 DataAND &= 0x0f;
122 DataOR &= 0x0f; 132 DataOR &= 0x0f;
123 } 133 }
@@ -129,12 +139,12 @@ SiS_SetRegSR11ANDOR(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT DataAND, US
129/*********************************************/ 139/*********************************************/
130 140
131#ifdef SIS315H 141#ifdef SIS315H
132static UCHAR * 142static unsigned char *
133GetLCDStructPtr661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 143GetLCDStructPtr661(struct SiS_Private *SiS_Pr)
134{ 144{
135 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; 145 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
136 UCHAR *myptr = NULL; 146 unsigned char *myptr = NULL;
137 USHORT romindex = 0, reg = 0, idx = 0; 147 unsigned short romindex = 0, reg = 0, idx = 0;
138 148
139 /* Use the BIOS tables only for LVDS panels; TMDS is unreliable 149 /* Use the BIOS tables only for LVDS panels; TMDS is unreliable
140 * due to the variaty of panels the BIOS doesn't know about. 150 * due to the variaty of panels the BIOS doesn't know about.
@@ -144,15 +154,15 @@ GetLCDStructPtr661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
144 */ 154 */
145 155
146 if((SiS_Pr->SiS_ROMNew) && 156 if((SiS_Pr->SiS_ROMNew) &&
147 ((SiS_Pr->SiS_VBType & VB_SIS301LV302LV) || (!SiS_Pr->PanelSelfDetected))) { 157 ((SiS_Pr->SiS_VBType & VB_SISLVDS) || (!SiS_Pr->PanelSelfDetected))) {
148 158
149 if(HwInfo->jChipType < SIS_661) reg = 0x3c; 159 if(SiS_Pr->ChipType < SIS_661) reg = 0x3c;
150 else reg = 0x7d; 160 else reg = 0x7d;
151 161
152 idx = (SiS_GetReg(SiS_Pr->SiS_P3d4,reg) & 0x1f) * 26; 162 idx = (SiS_GetReg(SiS_Pr->SiS_P3d4,reg) & 0x1f) * 26;
153 163
154 if(idx < (8*26)) { 164 if(idx < (8*26)) {
155 myptr = (UCHAR *)&SiS_LCDStruct661[idx]; 165 myptr = (unsigned char *)&SiS_LCDStruct661[idx];
156 } 166 }
157 romindex = SISGETROMW(0x100); 167 romindex = SISGETROMW(0x100);
158 if(romindex) { 168 if(romindex) {
@@ -163,11 +173,11 @@ GetLCDStructPtr661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
163 return myptr; 173 return myptr;
164} 174}
165 175
166static USHORT 176static unsigned short
167GetLCDStructPtr661_2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 177GetLCDStructPtr661_2(struct SiS_Private *SiS_Pr)
168{ 178{
169 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; 179 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
170 USHORT romptr = 0; 180 unsigned short romptr = 0;
171 181
172 /* Use the BIOS tables only for LVDS panels; TMDS is unreliable 182 /* Use the BIOS tables only for LVDS panels; TMDS is unreliable
173 * due to the variaty of panels the BIOS doesn't know about. 183 * due to the variaty of panels the BIOS doesn't know about.
@@ -177,12 +187,12 @@ GetLCDStructPtr661_2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
177 */ 187 */
178 188
179 if((SiS_Pr->SiS_ROMNew) && 189 if((SiS_Pr->SiS_ROMNew) &&
180 ((SiS_Pr->SiS_VBType & VB_SIS301LV302LV) || (!SiS_Pr->PanelSelfDetected))) { 190 ((SiS_Pr->SiS_VBType & VB_SISLVDS) || (!SiS_Pr->PanelSelfDetected))) {
181 romptr = SISGETROMW(0x102); 191 romptr = SISGETROMW(0x102);
182 romptr += ((SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4) * SiS_Pr->SiS661LCD2TableSize); 192 romptr += ((SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4) * SiS_Pr->SiS661LCD2TableSize);
183 } 193 }
184 194
185 return(romptr); 195 return romptr;
186} 196}
187#endif 197#endif
188 198
@@ -191,186 +201,187 @@ GetLCDStructPtr661_2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
191/*********************************************/ 201/*********************************************/
192 202
193static BOOLEAN 203static BOOLEAN
194SiS_AdjustCRT2Rate(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, 204SiS_AdjustCRT2Rate(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex,
195 USHORT RRTI, USHORT *i, PSIS_HW_INFO HwInfo) 205 unsigned short RRTI, unsigned short *i)
196{ 206{
197 USHORT checkmask=0,modeid,infoflag; 207 unsigned short checkmask=0, modeid, infoflag;
198 208
199 modeid = SiS_Pr->SiS_RefIndex[RRTI + (*i)].ModeID; 209 modeid = SiS_Pr->SiS_RefIndex[RRTI + (*i)].ModeID;
200 210
201 if(SiS_Pr->SiS_VBType & VB_SISVB) { 211 if(SiS_Pr->SiS_VBType & VB_SISVB) {
202 212
203 if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { 213 if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) {
204 214
205 checkmask |= SupportRAMDAC2; 215 checkmask |= SupportRAMDAC2;
206 if(HwInfo->jChipType >= SIS_315H) { 216 if(SiS_Pr->ChipType >= SIS_315H) {
207 checkmask |= SupportRAMDAC2_135; 217 checkmask |= SupportRAMDAC2_135;
208 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { 218 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) {
209 checkmask |= SupportRAMDAC2_162; 219 checkmask |= SupportRAMDAC2_162;
210 if(SiS_Pr->SiS_VBType & VB_SIS301C) { 220 if(SiS_Pr->SiS_VBType & VB_SISRAMDAC202) {
211 checkmask |= SupportRAMDAC2_202; 221 checkmask |= SupportRAMDAC2_202;
212 } 222 }
213 } 223 }
214 } 224 }
215 225
216 } else if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { 226 } else if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
217 227
218 checkmask |= SupportLCD; 228 checkmask |= SupportLCD;
219 if(HwInfo->jChipType >= SIS_315H) { 229 if(SiS_Pr->ChipType >= SIS_315H) {
220 if(SiS_Pr->SiS_VBType & VB_SISVB) { 230 if(SiS_Pr->SiS_VBType & VB_SISVB) {
221 if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (SiS_Pr->SiS_LCDInfo & LCDPass11)) { 231 if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (SiS_Pr->SiS_LCDInfo & LCDPass11)) {
222 if(modeid == 0x2e) checkmask |= Support64048060Hz; 232 if(modeid == 0x2e) checkmask |= Support64048060Hz;
223 } 233 }
224 } 234 }
225 } 235 }
226 236
227 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { 237 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {
228 238
229 checkmask |= SupportHiVision; 239 checkmask |= SupportHiVision;
230 240
231 } else if(SiS_Pr->SiS_VBInfo & (SetCRT2ToYPbPr525750|SetCRT2ToAVIDEO|SetCRT2ToSVIDEO|SetCRT2ToSCART)) { 241 } else if(SiS_Pr->SiS_VBInfo & (SetCRT2ToYPbPr525750|SetCRT2ToAVIDEO|SetCRT2ToSVIDEO|SetCRT2ToSCART)) {
232 242
233 checkmask |= SupportTV; 243 checkmask |= SupportTV;
234 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { 244 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) {
235 checkmask |= SupportTV1024; 245 checkmask |= SupportTV1024;
236 if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { 246 if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) {
237 if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) { 247 if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) {
238 checkmask |= SupportYPbPr750p; 248 checkmask |= SupportYPbPr750p;
239 } 249 }
240 } 250 }
241 } 251 }
242 252
243 } 253 }
244 254
245 } else { /* LVDS */ 255 } else { /* LVDS */
246 256
247 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { 257 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
248 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 258 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
249 checkmask |= SupportCHTV; 259 checkmask |= SupportCHTV;
250 } 260 }
251 } 261 }
252 262
253 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 263 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
254 checkmask |= SupportLCD; 264 checkmask |= SupportLCD;
255 } 265 }
256 266
257 } 267 }
258 268
259 /* Look backwards in table for matching CRT2 mode */ 269 /* Look backwards in table for matching CRT2 mode */
260 for(; SiS_Pr->SiS_RefIndex[RRTI + (*i)].ModeID == modeid; (*i)--) { 270 for(; SiS_Pr->SiS_RefIndex[RRTI + (*i)].ModeID == modeid; (*i)--) {
261 infoflag = SiS_Pr->SiS_RefIndex[RRTI + (*i)].Ext_InfoFlag; 271 infoflag = SiS_Pr->SiS_RefIndex[RRTI + (*i)].Ext_InfoFlag;
262 if(infoflag & checkmask) return TRUE; 272 if(infoflag & checkmask) return TRUE;
263 if((*i) == 0) break; 273 if((*i) == 0) break;
264 } 274 }
265 275
266 /* Look through the whole mode-section of the table from the beginning 276 /* Look through the whole mode-section of the table from the beginning
267 * for a matching CRT2 mode if no mode was found yet. 277 * for a matching CRT2 mode if no mode was found yet.
268 */ 278 */
269 for((*i) = 0; ; (*i)++) { 279 for((*i) = 0; ; (*i)++) {
270 if(SiS_Pr->SiS_RefIndex[RRTI + (*i)].ModeID != modeid) break; 280 if(SiS_Pr->SiS_RefIndex[RRTI + (*i)].ModeID != modeid) break;
271 infoflag = SiS_Pr->SiS_RefIndex[RRTI + (*i)].Ext_InfoFlag; 281 infoflag = SiS_Pr->SiS_RefIndex[RRTI + (*i)].Ext_InfoFlag;
272 if(infoflag & checkmask) return TRUE; 282 if(infoflag & checkmask) return TRUE;
273 } 283 }
274 return FALSE; 284 return FALSE;
275} 285}
276 286
277/*********************************************/ 287/*********************************************/
278/* Get rate index */ 288/* Get rate index */
279/*********************************************/ 289/*********************************************/
280 290
281USHORT 291unsigned short
282SiS_GetRatePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, 292SiS_GetRatePtr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex)
283 PSIS_HW_INFO HwInfo) 293{
284{ 294 unsigned short RRTI,i,backup_i;
285 SHORT LCDRefreshIndex[] = { 0x00, 0x00, 0x01, 0x01, 295 unsigned short modeflag,index,temp,backupindex;
286 0x01, 0x01, 0x01, 0x01, 296 static const unsigned short LCDRefreshIndex[] = {
287 0x01, 0x01, 0x01, 0x01, 297 0x00, 0x00, 0x01, 0x01,
288 0x01, 0x01, 0x01, 0x01, 298 0x01, 0x01, 0x01, 0x01,
289 0x00, 0x00, 0x00, 0x00 }; 299 0x01, 0x01, 0x01, 0x01,
290 USHORT RRTI,i,backup_i; 300 0x01, 0x01, 0x01, 0x01,
291 USHORT modeflag,index,temp,backupindex; 301 0x00, 0x00, 0x00, 0x00
302 };
292 303
293 /* Do NOT check for UseCustomMode here, will skrew up FIFO */ 304 /* Do NOT check for UseCustomMode here, will skrew up FIFO */
294 if(ModeNo == 0xfe) return 0; 305 if(ModeNo == 0xfe) return 0;
295 306
296 if(ModeNo <= 0x13) { 307 if(ModeNo <= 0x13) {
297 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; 308 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
298 } else { 309 } else {
299 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; 310 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
300 } 311 }
301 312
302 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { 313 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
303 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 314 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
304 if(modeflag & HalfDCLK) return 0; 315 if(modeflag & HalfDCLK) return 0;
305 } 316 }
306 } 317 }
307 318
308 if(ModeNo < 0x14) return 0xFFFF; 319 if(ModeNo < 0x14) return 0xFFFF;
309 320
310 index = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x33) >> SiS_Pr->SiS_SelectCRT2Rate) & 0x0F; 321 index = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x33) >> SiS_Pr->SiS_SelectCRT2Rate) & 0x0F;
311 backupindex = index; 322 backupindex = index;
312 323
313 if(index > 0) index--; 324 if(index > 0) index--;
314 325
315 if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) { 326 if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) {
316 if(SiS_Pr->SiS_VBType & VB_SISVB) { 327 if(SiS_Pr->SiS_VBType & VB_SISVB) {
317 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 328 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
318 if(SiS_Pr->SiS_VBType & VB_NoLCD) index = 0; 329 if(SiS_Pr->SiS_VBType & VB_NoLCD) index = 0;
319 else if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) index = backupindex = 0; 330 else if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) index = backupindex = 0;
320 } 331 }
321 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { 332 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
322 if(!(SiS_Pr->SiS_VBType & VB_NoLCD)) { 333 if(!(SiS_Pr->SiS_VBType & VB_NoLCD)) {
323 temp = LCDRefreshIndex[SiS_GetBIOSLCDResInfo(SiS_Pr)]; 334 temp = LCDRefreshIndex[SiS_GetBIOSLCDResInfo(SiS_Pr)];
324 if(index > temp) index = temp; 335 if(index > temp) index = temp;
325 } 336 }
326 } 337 }
327 } else { 338 } else {
328 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) index = 0; 339 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) index = 0;
329 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { 340 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
330 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) index = 0; 341 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) index = 0;
331 } 342 }
332 } 343 }
333 } 344 }
334 345
335 RRTI = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].REFindex; 346 RRTI = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].REFindex;
336 ModeNo = SiS_Pr->SiS_RefIndex[RRTI].ModeID; 347 ModeNo = SiS_Pr->SiS_RefIndex[RRTI].ModeID;
337 348
338 if(HwInfo->jChipType >= SIS_315H) { 349 if(SiS_Pr->ChipType >= SIS_315H) {
339 if(!(SiS_Pr->SiS_VBInfo & DriverMode)) { 350 if(!(SiS_Pr->SiS_VBInfo & DriverMode)) {
340 if( (SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_VESAID == 0x105) || 351 if( (SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_VESAID == 0x105) ||
341 (SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_VESAID == 0x107) ) { 352 (SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_VESAID == 0x107) ) {
342 if(backupindex <= 1) RRTI++; 353 if(backupindex <= 1) RRTI++;
343 } 354 }
344 } 355 }
345 } 356 }
346 357
347 i = 0; 358 i = 0;
348 do { 359 do {
349 if(SiS_Pr->SiS_RefIndex[RRTI + i].ModeID != ModeNo) break; 360 if(SiS_Pr->SiS_RefIndex[RRTI + i].ModeID != ModeNo) break;
350 temp = SiS_Pr->SiS_RefIndex[RRTI + i].Ext_InfoFlag; 361 temp = SiS_Pr->SiS_RefIndex[RRTI + i].Ext_InfoFlag;
351 temp &= ModeTypeMask; 362 temp &= ModeTypeMask;
352 if(temp < SiS_Pr->SiS_ModeType) break; 363 if(temp < SiS_Pr->SiS_ModeType) break;
353 i++; 364 i++;
354 index--; 365 index--;
355 } while(index != 0xFFFF); 366 } while(index != 0xFFFF);
356 367
357 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { 368 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) {
358 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { 369 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
359 temp = SiS_Pr->SiS_RefIndex[RRTI + i - 1].Ext_InfoFlag; 370 temp = SiS_Pr->SiS_RefIndex[RRTI + i - 1].Ext_InfoFlag;
360 if(temp & InterlaceMode) i++; 371 if(temp & InterlaceMode) i++;
361 } 372 }
362 } 373 }
363 374
364 i--; 375 i--;
365 376
366 if((SiS_Pr->SiS_SetFlag & ProgrammingCRT2) && (!(SiS_Pr->SiS_VBInfo & DisableCRT2Display))) { 377 if((SiS_Pr->SiS_SetFlag & ProgrammingCRT2) && (!(SiS_Pr->SiS_VBInfo & DisableCRT2Display))) {
367 backup_i = i; 378 backup_i = i;
368 if(!(SiS_AdjustCRT2Rate(SiS_Pr, ModeNo, ModeIdIndex, RRTI, &i, HwInfo))) { 379 if(!(SiS_AdjustCRT2Rate(SiS_Pr, ModeNo, ModeIdIndex, RRTI, &i))) {
369 i = backup_i; 380 i = backup_i;
370 } 381 }
371 } 382 }
372 383
373 return(RRTI + i); 384 return (RRTI + i);
374} 385}
375 386
376/*********************************************/ 387/*********************************************/
@@ -378,15 +389,15 @@ SiS_GetRatePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
378/*********************************************/ 389/*********************************************/
379 390
380static void 391static void
381SiS_SaveCRT2Info(SiS_Private *SiS_Pr, USHORT ModeNo) 392SiS_SaveCRT2Info(struct SiS_Private *SiS_Pr, unsigned short ModeNo)
382{ 393{
383 USHORT temp1,temp2; 394 unsigned short temp1, temp2;
384 395
385 /* Store CRT1 ModeNo in CR34 */ 396 /* Store CRT1 ModeNo in CR34 */
386 SiS_SetReg(SiS_Pr->SiS_P3d4,0x34,ModeNo); 397 SiS_SetReg(SiS_Pr->SiS_P3d4,0x34,ModeNo);
387 temp1 = (SiS_Pr->SiS_VBInfo & SetInSlaveMode) >> 8; 398 temp1 = (SiS_Pr->SiS_VBInfo & SetInSlaveMode) >> 8;
388 temp2 = ~(SetInSlaveMode >> 8); 399 temp2 = ~(SetInSlaveMode >> 8);
389 SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x31,temp2,temp1); 400 SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x31,temp2,temp1);
390} 401}
391 402
392/*********************************************/ 403/*********************************************/
@@ -395,35 +406,35 @@ SiS_SaveCRT2Info(SiS_Private *SiS_Pr, USHORT ModeNo)
395 406
396#ifdef SIS300 407#ifdef SIS300
397static BOOLEAN 408static BOOLEAN
398SiS_CR36BIOSWord23b(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 409SiS_CR36BIOSWord23b(struct SiS_Private *SiS_Pr)
399{ 410{
400 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; 411 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
401 USHORT temp,temp1; 412 unsigned short temp,temp1;
402 413
403 if(SiS_Pr->SiS_UseROM) { 414 if(SiS_Pr->SiS_UseROM) {
404 if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) { 415 if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) {
405 temp = 1 << ((SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4) & 0x0f); 416 temp = 1 << ((SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4) & 0x0f);
406 temp1 = SISGETROMW(0x23b); 417 temp1 = SISGETROMW(0x23b);
407 if(temp1 & temp) return TRUE; 418 if(temp1 & temp) return TRUE;
408 } 419 }
409 } 420 }
410 return FALSE; 421 return FALSE;
411} 422}
412 423
413static BOOLEAN 424static BOOLEAN
414SiS_CR36BIOSWord23d(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 425SiS_CR36BIOSWord23d(struct SiS_Private *SiS_Pr)
415{ 426{
416 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; 427 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
417 USHORT temp,temp1; 428 unsigned short temp,temp1;
418 429
419 if(SiS_Pr->SiS_UseROM) { 430 if(SiS_Pr->SiS_UseROM) {
420 if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) { 431 if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) {
421 temp = 1 << ((SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4) & 0x0f); 432 temp = 1 << ((SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4) & 0x0f);
422 temp1 = SISGETROMW(0x23d); 433 temp1 = SISGETROMW(0x23d);
423 if(temp1 & temp) return TRUE; 434 if(temp1 & temp) return TRUE;
424 } 435 }
425 } 436 }
426 return FALSE; 437 return FALSE;
427} 438}
428#endif 439#endif
429 440
@@ -432,85 +443,76 @@ SiS_CR36BIOSWord23d(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
432/*********************************************/ 443/*********************************************/
433 444
434void 445void
435SiS_DDC2Delay(SiS_Private *SiS_Pr, USHORT delaytime) 446SiS_DDC2Delay(struct SiS_Private *SiS_Pr, unsigned int delaytime)
436{ 447{
437 USHORT i, j; 448 unsigned int i, j;
438 449
439 for(i=0; i<delaytime; i++) { 450 for(i = 0; i < delaytime; i++) {
440 j += SiS_GetReg(SiS_Pr->SiS_P3c4,0x05); 451 j += SiS_GetReg(SiS_Pr->SiS_P3c4,0x05);
441 } 452 }
442} 453}
443 454
444#if defined(SIS300) || defined(SIS315H) 455#if defined(SIS300) || defined(SIS315H)
445static void 456static void
446SiS_GenericDelay(SiS_Private *SiS_Pr, USHORT delay) 457SiS_GenericDelay(struct SiS_Private *SiS_Pr, unsigned short delay)
447{ 458{
448 USHORT temp,flag; 459 SiS_DDC2Delay(SiS_Pr, delay * 36);
449
450 flag = SiS_GetRegByte(0x61) & 0x10;
451
452 while(delay) {
453 temp = SiS_GetRegByte(0x61) & 0x10;
454 if(temp == flag) continue;
455 flag = temp;
456 delay--;
457 }
458} 460}
459#endif 461#endif
460 462
461#ifdef SIS315H 463#ifdef SIS315H
462static void 464static void
463SiS_LongDelay(SiS_Private *SiS_Pr, USHORT delay) 465SiS_LongDelay(struct SiS_Private *SiS_Pr, unsigned short delay)
464{ 466{
465 while(delay--) { 467 while(delay--) {
466 SiS_GenericDelay(SiS_Pr,0x19df); 468 SiS_GenericDelay(SiS_Pr, 6623);
467 } 469 }
468} 470}
469#endif 471#endif
470 472
471#if defined(SIS300) || defined(SIS315H) 473#if defined(SIS300) || defined(SIS315H)
472static void 474static void
473SiS_ShortDelay(SiS_Private *SiS_Pr, USHORT delay) 475SiS_ShortDelay(struct SiS_Private *SiS_Pr, unsigned short delay)
474{ 476{
475 while(delay--) { 477 while(delay--) {
476 SiS_GenericDelay(SiS_Pr,0x42); 478 SiS_GenericDelay(SiS_Pr, 66);
477 } 479 }
478} 480}
479#endif 481#endif
480 482
481static void 483static void
482SiS_PanelDelay(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT DelayTime) 484SiS_PanelDelay(struct SiS_Private *SiS_Pr, unsigned short DelayTime)
483{ 485{
484#if defined(SIS300) || defined(SIS315H) 486#if defined(SIS300) || defined(SIS315H)
485 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; 487 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
486 USHORT PanelID, DelayIndex, Delay=0; 488 unsigned short PanelID, DelayIndex, Delay=0;
487#endif 489#endif
488 490
489 if(HwInfo->jChipType < SIS_315H) { 491 if(SiS_Pr->ChipType < SIS_315H) {
490 492
491#ifdef SIS300 493#ifdef SIS300
492 494
493 PanelID = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36); 495 PanelID = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36);
494 if(SiS_Pr->SiS_VBType & VB_SISVB) { 496 if(SiS_Pr->SiS_VBType & VB_SISVB) {
495 if(SiS_Pr->SiS_VBType & VB_SIS301) PanelID &= 0xf7; 497 if(SiS_Pr->SiS_VBType & VB_SIS301) PanelID &= 0xf7;
496 if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x18) & 0x10)) PanelID = 0x12; 498 if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x18) & 0x10)) PanelID = 0x12;
497 } 499 }
498 DelayIndex = PanelID >> 4; 500 DelayIndex = PanelID >> 4;
499 if((DelayTime >= 2) && ((PanelID & 0x0f) == 1)) { 501 if((DelayTime >= 2) && ((PanelID & 0x0f) == 1)) {
500 Delay = 3; 502 Delay = 3;
501 } else { 503 } else {
502 if(DelayTime >= 2) DelayTime -= 2; 504 if(DelayTime >= 2) DelayTime -= 2;
503 if(!(DelayTime & 0x01)) { 505 if(!(DelayTime & 0x01)) {
504 Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[0]; 506 Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[0];
505 } else { 507 } else {
506 Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[1]; 508 Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[1];
507 } 509 }
508 if(SiS_Pr->SiS_UseROM) { 510 if(SiS_Pr->SiS_UseROM) {
509 if(ROMAddr[0x220] & 0x40) { 511 if(ROMAddr[0x220] & 0x40) {
510 if(!(DelayTime & 0x01)) Delay = (USHORT)ROMAddr[0x225]; 512 if(!(DelayTime & 0x01)) Delay = (unsigned short)ROMAddr[0x225];
511 else Delay = (USHORT)ROMAddr[0x226]; 513 else Delay = (unsigned short)ROMAddr[0x226];
512 } 514 }
513 } 515 }
514 } 516 }
515 SiS_ShortDelay(SiS_Pr, Delay); 517 SiS_ShortDelay(SiS_Pr, Delay);
516 518
@@ -520,23 +522,23 @@ SiS_PanelDelay(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT DelayTime)
520 522
521#ifdef SIS315H 523#ifdef SIS315H
522 524
523 if((HwInfo->jChipType >= SIS_661) || 525 if((SiS_Pr->ChipType >= SIS_661) ||
524 (HwInfo->jChipType <= SIS_315PRO) || 526 (SiS_Pr->ChipType <= SIS_315PRO) ||
525 (HwInfo->jChipType == SIS_330) || 527 (SiS_Pr->ChipType == SIS_330) ||
526 (SiS_Pr->SiS_ROMNew)) { 528 (SiS_Pr->SiS_ROMNew)) {
527 529
528 if(!(DelayTime & 0x01)) { 530 if(!(DelayTime & 0x01)) {
529 SiS_DDC2Delay(SiS_Pr, 0x1000); 531 SiS_DDC2Delay(SiS_Pr, 0x1000);
530 } else { 532 } else {
531 SiS_DDC2Delay(SiS_Pr, 0x4000); 533 SiS_DDC2Delay(SiS_Pr, 0x4000);
532 } 534 }
533 535
534 } else if((SiS_Pr->SiS_IF_DEF_LVDS == 1) /* || 536 } else if((SiS_Pr->SiS_IF_DEF_LVDS == 1) /* ||
535 (SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || 537 (SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) ||
536 (SiS_Pr->SiS_CustomT == CUT_CLEVO1400) */ ) { /* 315 series, LVDS; Special */ 538 (SiS_Pr->SiS_CustomT == CUT_CLEVO1400) */ ) { /* 315 series, LVDS; Special */
537 539
538 if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { 540 if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) {
539 PanelID = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36); 541 PanelID = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36);
540 if(SiS_Pr->SiS_CustomT == CUT_CLEVO1400) { 542 if(SiS_Pr->SiS_CustomT == CUT_CLEVO1400) {
541 if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x1b) & 0x10)) PanelID = 0x12; 543 if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x1b) & 0x10)) PanelID = 0x12;
542 } 544 }
@@ -546,35 +548,35 @@ SiS_PanelDelay(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT DelayTime)
546 DelayIndex = PanelID >> 4; 548 DelayIndex = PanelID >> 4;
547 } 549 }
548 if((DelayTime >= 2) && ((PanelID & 0x0f) == 1)) { 550 if((DelayTime >= 2) && ((PanelID & 0x0f) == 1)) {
549 Delay = 3; 551 Delay = 3;
550 } else { 552 } else {
551 if(DelayTime >= 2) DelayTime -= 2; 553 if(DelayTime >= 2) DelayTime -= 2;
552 if(!(DelayTime & 0x01)) { 554 if(!(DelayTime & 0x01)) {
553 Delay = SiS_Pr->SiS_PanelDelayTblLVDS[DelayIndex].timer[0]; 555 Delay = SiS_Pr->SiS_PanelDelayTblLVDS[DelayIndex].timer[0];
554 } else { 556 } else {
555 Delay = SiS_Pr->SiS_PanelDelayTblLVDS[DelayIndex].timer[1]; 557 Delay = SiS_Pr->SiS_PanelDelayTblLVDS[DelayIndex].timer[1];
556 } 558 }
557 if((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) { 559 if((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) {
558 if(ROMAddr[0x13c] & 0x40) { 560 if(ROMAddr[0x13c] & 0x40) {
559 if(!(DelayTime & 0x01)) { 561 if(!(DelayTime & 0x01)) {
560 Delay = (USHORT)ROMAddr[0x17e]; 562 Delay = (unsigned short)ROMAddr[0x17e];
561 } else { 563 } else {
562 Delay = (USHORT)ROMAddr[0x17f]; 564 Delay = (unsigned short)ROMAddr[0x17f];
563 } 565 }
564 } 566 }
565 } 567 }
566 } 568 }
567 SiS_ShortDelay(SiS_Pr, Delay); 569 SiS_ShortDelay(SiS_Pr, Delay);
568 } 570 }
569 571
570 } else if(SiS_Pr->SiS_VBType & VB_SISVB) { /* 315 series, all bridges */ 572 } else if(SiS_Pr->SiS_VBType & VB_SISVB) { /* 315 series, all bridges */
571 573
572 DelayIndex = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4; 574 DelayIndex = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) >> 4;
573 if(!(DelayTime & 0x01)) { 575 if(!(DelayTime & 0x01)) {
574 Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[0]; 576 Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[0];
575 } else { 577 } else {
576 Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[1]; 578 Delay = SiS_Pr->SiS_PanelDelayTbl[DelayIndex].timer[1];
577 } 579 }
578 Delay <<= 8; 580 Delay <<= 8;
579 SiS_DDC2Delay(SiS_Pr, Delay); 581 SiS_DDC2Delay(SiS_Pr, Delay);
580 582
@@ -587,12 +589,11 @@ SiS_PanelDelay(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT DelayTime)
587 589
588#ifdef SIS315H 590#ifdef SIS315H
589static void 591static void
590SiS_PanelDelayLoop(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, 592SiS_PanelDelayLoop(struct SiS_Private *SiS_Pr, unsigned short DelayTime, unsigned short DelayLoop)
591 USHORT DelayTime, USHORT DelayLoop)
592{ 593{
593 int i; 594 int i;
594 for(i=0; i<DelayLoop; i++) { 595 for(i = 0; i < DelayLoop; i++) {
595 SiS_PanelDelay(SiS_Pr, HwInfo, DelayTime); 596 SiS_PanelDelay(SiS_Pr, DelayTime);
596 } 597 }
597} 598}
598#endif 599#endif
@@ -602,86 +603,86 @@ SiS_PanelDelayLoop(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
602/*********************************************/ 603/*********************************************/
603 604
604void 605void
605SiS_WaitRetrace1(SiS_Private *SiS_Pr) 606SiS_WaitRetrace1(struct SiS_Private *SiS_Pr)
606{ 607{
607 USHORT watchdog; 608 unsigned short watchdog;
608 609
609 if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x1f) & 0xc0) return; 610 if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x1f) & 0xc0) return;
610 if(!(SiS_GetReg(SiS_Pr->SiS_P3d4,0x17) & 0x80)) return; 611 if(!(SiS_GetReg(SiS_Pr->SiS_P3d4,0x17) & 0x80)) return;
611 612
612 watchdog = 65535; 613 watchdog = 65535;
613 while((SiS_GetRegByte(SiS_Pr->SiS_P3da) & 0x08) && --watchdog); 614 while((SiS_GetRegByte(SiS_Pr->SiS_P3da) & 0x08) && --watchdog);
614 watchdog = 65535; 615 watchdog = 65535;
615 while((!(SiS_GetRegByte(SiS_Pr->SiS_P3da) & 0x08)) && --watchdog); 616 while((!(SiS_GetRegByte(SiS_Pr->SiS_P3da) & 0x08)) && --watchdog);
616} 617}
617 618
618#if defined(SIS300) || defined(SIS315H) 619#if defined(SIS300) || defined(SIS315H)
619static void 620static void
620SiS_WaitRetrace2(SiS_Private *SiS_Pr, USHORT reg) 621SiS_WaitRetrace2(struct SiS_Private *SiS_Pr, unsigned short reg)
621{ 622{
622 USHORT watchdog; 623 unsigned short watchdog;
623 624
624 watchdog = 65535; 625 watchdog = 65535;
625 while((SiS_GetReg(SiS_Pr->SiS_Part1Port,reg) & 0x02) && --watchdog); 626 while((SiS_GetReg(SiS_Pr->SiS_Part1Port,reg) & 0x02) && --watchdog);
626 watchdog = 65535; 627 watchdog = 65535;
627 while((!(SiS_GetReg(SiS_Pr->SiS_Part1Port,reg) & 0x02)) && --watchdog); 628 while((!(SiS_GetReg(SiS_Pr->SiS_Part1Port,reg) & 0x02)) && --watchdog);
628} 629}
629#endif 630#endif
630 631
631static void 632static void
632SiS_WaitVBRetrace(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 633SiS_WaitVBRetrace(struct SiS_Private *SiS_Pr)
633{ 634{
634 if(HwInfo->jChipType < SIS_315H) { 635 if(SiS_Pr->ChipType < SIS_315H) {
635#ifdef SIS300 636#ifdef SIS300
636 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { 637 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) {
637 if(!(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x20)) return; 638 if(!(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x20)) return;
638 } 639 }
639 if(!(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x80)) { 640 if(!(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x80)) {
640 SiS_WaitRetrace1(SiS_Pr); 641 SiS_WaitRetrace1(SiS_Pr);
641 } else { 642 } else {
642 SiS_WaitRetrace2(SiS_Pr, 0x25); 643 SiS_WaitRetrace2(SiS_Pr, 0x25);
643 } 644 }
644#endif 645#endif
645 } else { 646 } else {
646#ifdef SIS315H 647#ifdef SIS315H
647 if(!(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x40)) { 648 if(!(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x40)) {
648 SiS_WaitRetrace1(SiS_Pr); 649 SiS_WaitRetrace1(SiS_Pr);
649 } else { 650 } else {
650 SiS_WaitRetrace2(SiS_Pr, 0x30); 651 SiS_WaitRetrace2(SiS_Pr, 0x30);
651 } 652 }
652#endif 653#endif
653 } 654 }
654} 655}
655 656
656static void 657static void
657SiS_VBWait(SiS_Private *SiS_Pr) 658SiS_VBWait(struct SiS_Private *SiS_Pr)
658{ 659{
659 USHORT tempal,temp,i,j; 660 unsigned short tempal,temp,i,j;
660 661
661 temp = 0; 662 temp = 0;
662 for(i=0; i<3; i++) { 663 for(i = 0; i < 3; i++) {
663 for(j=0; j<100; j++) { 664 for(j = 0; j < 100; j++) {
664 tempal = SiS_GetRegByte(SiS_Pr->SiS_P3da); 665 tempal = SiS_GetRegByte(SiS_Pr->SiS_P3da);
665 if(temp & 0x01) { 666 if(temp & 0x01) {
666 if((tempal & 0x08)) continue; 667 if((tempal & 0x08)) continue;
667 else break; 668 else break;
668 } else { 669 } else {
669 if(!(tempal & 0x08)) continue; 670 if(!(tempal & 0x08)) continue;
670 else break; 671 else break;
671 } 672 }
672 } 673 }
673 temp ^= 0x01; 674 temp ^= 0x01;
674 } 675 }
675} 676}
676 677
677static void 678static void
678SiS_VBLongWait(SiS_Private *SiS_Pr) 679SiS_VBLongWait(struct SiS_Private *SiS_Pr)
679{ 680{
680 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 681 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
681 SiS_VBWait(SiS_Pr); 682 SiS_VBWait(SiS_Pr);
682 } else { 683 } else {
683 SiS_WaitRetrace1(SiS_Pr); 684 SiS_WaitRetrace1(SiS_Pr);
684 } 685 }
685} 686}
686 687
687/*********************************************/ 688/*********************************************/
@@ -690,237 +691,225 @@ SiS_VBLongWait(SiS_Private *SiS_Pr)
690 691
691#ifdef SIS300 692#ifdef SIS300
692static BOOLEAN 693static BOOLEAN
693SiS_Is301B(SiS_Private *SiS_Pr) 694SiS_Is301B(struct SiS_Private *SiS_Pr)
694{ 695{
695 if(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x01) >= 0xb0) return TRUE; 696 if(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x01) >= 0xb0) return TRUE;
696 return FALSE; 697 return FALSE;
697} 698}
698#endif 699#endif
699 700
700static BOOLEAN 701static BOOLEAN
701SiS_CRT2IsLCD(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 702SiS_CRT2IsLCD(struct SiS_Private *SiS_Pr)
702{ 703{
703 USHORT flag; 704 if(SiS_Pr->ChipType == SIS_730) {
704 705 if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x20) return TRUE;
705 if(HwInfo->jChipType == SIS_730) { 706 }
706 flag = SiS_GetReg(SiS_Pr->SiS_P3c4,0x13); 707 if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x30) & 0x20) return TRUE;
707 if(flag & 0x20) return TRUE; 708 return FALSE;
708 }
709 flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30);
710 if(flag & 0x20) return TRUE;
711 return FALSE;
712} 709}
713 710
714BOOLEAN 711BOOLEAN
715SiS_IsDualEdge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 712SiS_IsDualEdge(struct SiS_Private *SiS_Pr)
716{ 713{
717#ifdef SIS315H 714#ifdef SIS315H
718 USHORT flag; 715 if(SiS_Pr->ChipType >= SIS_315H) {
719 716 if((SiS_Pr->ChipType != SIS_650) || (SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f) & 0xf0)) {
720 if(HwInfo->jChipType >= SIS_315H) { 717 if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x38) & EnableDualEdge) return TRUE;
721 if((HwInfo->jChipType != SIS_650) || (SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f) & 0xf0)) { 718 }
722 flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); 719 }
723 if(flag & EnableDualEdge) return TRUE;
724 }
725 }
726#endif 720#endif
727 return FALSE; 721 return FALSE;
728} 722}
729 723
730BOOLEAN 724BOOLEAN
731SiS_IsVAMode(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 725SiS_IsVAMode(struct SiS_Private *SiS_Pr)
732{ 726{
733#ifdef SIS315H 727#ifdef SIS315H
734 USHORT flag; 728 unsigned short flag;
735 729
736 if(HwInfo->jChipType >= SIS_315H) { 730 if(SiS_Pr->ChipType >= SIS_315H) {
737 flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); 731 flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38);
738 if((flag & EnableDualEdge) && (flag & SetToLCDA)) return TRUE; 732 if((flag & EnableDualEdge) && (flag & SetToLCDA)) return TRUE;
739 } 733 }
740#endif 734#endif
741 return FALSE; 735 return FALSE;
742} 736}
743 737
744#ifdef SIS315H 738#ifdef SIS315H
745static BOOLEAN 739static BOOLEAN
746SiS_IsVAorLCD(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 740SiS_IsVAorLCD(struct SiS_Private *SiS_Pr)
747{ 741{
748 if(SiS_IsVAMode(SiS_Pr,HwInfo)) return TRUE; 742 if(SiS_IsVAMode(SiS_Pr)) return TRUE;
749 if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) return TRUE; 743 if(SiS_CRT2IsLCD(SiS_Pr)) return TRUE;
750 return FALSE; 744 return FALSE;
751} 745}
752#endif 746#endif
753 747
754static BOOLEAN 748static BOOLEAN
755SiS_IsDualLink(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 749SiS_IsDualLink(struct SiS_Private *SiS_Pr)
756{ 750{
757#ifdef SIS315H 751#ifdef SIS315H
758 if(HwInfo->jChipType >= SIS_315H) { 752 if(SiS_Pr->ChipType >= SIS_315H) {
759 if((SiS_CRT2IsLCD(SiS_Pr, HwInfo)) || 753 if((SiS_CRT2IsLCD(SiS_Pr)) ||
760 (SiS_IsVAMode(SiS_Pr, HwInfo))) { 754 (SiS_IsVAMode(SiS_Pr))) {
761 if(SiS_Pr->SiS_LCDInfo & LCDDualLink) return TRUE; 755 if(SiS_Pr->SiS_LCDInfo & LCDDualLink) return TRUE;
762 } 756 }
763 } 757 }
764#endif 758#endif
765 return FALSE; 759 return FALSE;
766} 760}
767 761
768#ifdef SIS315H 762#ifdef SIS315H
769static BOOLEAN 763static BOOLEAN
770SiS_TVEnabled(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 764SiS_TVEnabled(struct SiS_Private *SiS_Pr)
771{ 765{
772 if((SiS_GetReg(SiS_Pr->SiS_Part2Port,0x00) & 0x0f) != 0x0c) return TRUE; 766 if((SiS_GetReg(SiS_Pr->SiS_Part2Port,0x00) & 0x0f) != 0x0c) return TRUE;
773 if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS301LV302LV)) { 767 if(SiS_Pr->SiS_VBType & VB_SISYPBPR) {
774 if(SiS_GetReg(SiS_Pr->SiS_Part2Port,0x4d) & 0x10) return TRUE; 768 if(SiS_GetReg(SiS_Pr->SiS_Part2Port,0x4d) & 0x10) return TRUE;
775 } 769 }
776 return FALSE; 770 return FALSE;
777} 771}
778#endif 772#endif
779 773
780#ifdef SIS315H 774#ifdef SIS315H
781static BOOLEAN 775static BOOLEAN
782SiS_LCDAEnabled(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 776SiS_LCDAEnabled(struct SiS_Private *SiS_Pr)
783{ 777{
784 if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x13) & 0x04) return TRUE; 778 if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x13) & 0x04) return TRUE;
785 return FALSE; 779 return FALSE;
786} 780}
787#endif 781#endif
788 782
789#ifdef SIS315H 783#ifdef SIS315H
790static BOOLEAN 784static BOOLEAN
791SiS_WeHaveBacklightCtrl(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 785SiS_WeHaveBacklightCtrl(struct SiS_Private *SiS_Pr)
792{ 786{
793 if((HwInfo->jChipType >= SIS_315H) && (HwInfo->jChipType < SIS_661)) { 787 if((SiS_Pr->ChipType >= SIS_315H) && (SiS_Pr->ChipType < SIS_661)) {
794 if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x79) & 0x10) return TRUE; 788 if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x79) & 0x10) return TRUE;
795 } 789 }
796 return FALSE; 790 return FALSE;
797} 791}
798#endif 792#endif
799 793
800#ifdef SIS315H 794#ifdef SIS315H
801static BOOLEAN 795static BOOLEAN
802SiS_IsNotM650orLater(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 796SiS_IsNotM650orLater(struct SiS_Private *SiS_Pr)
803{ 797{
804 USHORT flag; 798 unsigned short flag;
805 799
806 if(HwInfo->jChipType == SIS_650) { 800 if(SiS_Pr->ChipType == SIS_650) {
807 flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f); 801 flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f) & 0xf0;
808 flag &= 0xF0; 802 /* Check for revision != A0 only */
809 /* Check for revision != A0 only */ 803 if((flag == 0xe0) || (flag == 0xc0) ||
810 if((flag == 0xe0) || (flag == 0xc0) || 804 (flag == 0xb0) || (flag == 0x90)) return FALSE;
811 (flag == 0xb0) || (flag == 0x90)) return FALSE; 805 } else if(SiS_Pr->ChipType >= SIS_661) return FALSE;
812 } else if(HwInfo->jChipType >= SIS_661) return FALSE; 806 return TRUE;
813 return TRUE;
814} 807}
815#endif 808#endif
816 809
817#ifdef SIS315H 810#ifdef SIS315H
818static BOOLEAN 811static BOOLEAN
819SiS_IsYPbPr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 812SiS_IsYPbPr(struct SiS_Private *SiS_Pr)
820{ 813{
821 USHORT flag; 814 if(SiS_Pr->ChipType >= SIS_315H) {
822 815 /* YPrPb = 0x08 */
823 if(HwInfo->jChipType >= SIS_315H) { 816 if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x38) & EnableCHYPbPr) return TRUE;
824 flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); 817 }
825 if(flag & EnableCHYPbPr) return TRUE; /* = YPrPb = 0x08 */ 818 return FALSE;
826 }
827 return FALSE;
828} 819}
829#endif 820#endif
830 821
831#ifdef SIS315H 822#ifdef SIS315H
832static BOOLEAN 823static BOOLEAN
833SiS_IsChScart(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 824SiS_IsChScart(struct SiS_Private *SiS_Pr)
834{ 825{
835 USHORT flag; 826 if(SiS_Pr->ChipType >= SIS_315H) {
836 827 /* Scart = 0x04 */
837 if(HwInfo->jChipType >= SIS_315H) { 828 if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x38) & EnableCHScart) return TRUE;
838 flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); 829 }
839 if(flag & EnableCHScart) return TRUE; /* = Scart = 0x04 */ 830 return FALSE;
840 }
841 return FALSE;
842} 831}
843#endif 832#endif
844 833
845#ifdef SIS315H 834#ifdef SIS315H
846static BOOLEAN 835static BOOLEAN
847SiS_IsTVOrYPbPrOrScart(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 836SiS_IsTVOrYPbPrOrScart(struct SiS_Private *SiS_Pr)
848{ 837{
849 USHORT flag; 838 unsigned short flag;
850 839
851 if(HwInfo->jChipType >= SIS_315H) { 840 if(SiS_Pr->ChipType >= SIS_315H) {
852 flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); 841 flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30);
853 if(flag & SetCRT2ToTV) return TRUE; 842 if(flag & SetCRT2ToTV) return TRUE;
854 flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); 843 flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38);
855 if(flag & EnableCHYPbPr) return TRUE; /* = YPrPb = 0x08 */ 844 if(flag & EnableCHYPbPr) return TRUE; /* = YPrPb = 0x08 */
856 if(flag & EnableCHScart) return TRUE; /* = Scart = 0x04 - TW */ 845 if(flag & EnableCHScart) return TRUE; /* = Scart = 0x04 - TW */
857 } else { 846 } else {
858 flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); 847 flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30);
859 if(flag & SetCRT2ToTV) return TRUE; 848 if(flag & SetCRT2ToTV) return TRUE;
860 } 849 }
861 return FALSE; 850 return FALSE;
862} 851}
863#endif 852#endif
864 853
865#ifdef SIS315H 854#ifdef SIS315H
866static BOOLEAN 855static BOOLEAN
867SiS_IsLCDOrLCDA(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 856SiS_IsLCDOrLCDA(struct SiS_Private *SiS_Pr)
868{ 857{
869 USHORT flag; 858 unsigned short flag;
870 859
871 if(HwInfo->jChipType >= SIS_315H) { 860 if(SiS_Pr->ChipType >= SIS_315H) {
872 flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); 861 flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30);
873 if(flag & SetCRT2ToLCD) return TRUE; 862 if(flag & SetCRT2ToLCD) return TRUE;
874 flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); 863 flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38);
875 if(flag & SetToLCDA) return TRUE; 864 if(flag & SetToLCDA) return TRUE;
876 } else { 865 } else {
877 flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); 866 flag = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30);
878 if(flag & SetCRT2ToLCD) return TRUE; 867 if(flag & SetCRT2ToLCD) return TRUE;
879 } 868 }
880 return FALSE; 869 return FALSE;
881} 870}
882#endif 871#endif
883 872
884static BOOLEAN 873static BOOLEAN
885SiS_BridgeIsOn(SiS_Private *SiS_Pr) 874SiS_HaveBridge(struct SiS_Private *SiS_Pr)
886{ 875{
887 USHORT flag; 876 unsigned short flag;
888 877
889 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { 878 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
890 return TRUE; 879 return TRUE;
891 } else if(SiS_Pr->SiS_VBType & VB_SISVB) { 880 } else if(SiS_Pr->SiS_VBType & VB_SISVB) {
892 flag = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x00); 881 flag = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x00);
893 if((flag == 1) || (flag == 2)) return TRUE; 882 if((flag == 1) || (flag == 2)) return TRUE;
894 } 883 }
895 return FALSE; 884 return FALSE;
896} 885}
897 886
898static BOOLEAN 887static BOOLEAN
899SiS_BridgeIsEnabled(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 888SiS_BridgeIsEnabled(struct SiS_Private *SiS_Pr)
900{ 889{
901 USHORT flag; 890 unsigned short flag;
902 891
903 if(SiS_BridgeIsOn(SiS_Pr)) { 892 if(SiS_HaveBridge(SiS_Pr)) {
904 flag = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00); 893 flag = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00);
905 if(HwInfo->jChipType < SIS_315H) { 894 if(SiS_Pr->ChipType < SIS_315H) {
906 flag &= 0xa0; 895 flag &= 0xa0;
907 if((flag == 0x80) || (flag == 0x20)) return TRUE; 896 if((flag == 0x80) || (flag == 0x20)) return TRUE;
908 } else { 897 } else {
909 flag &= 0x50; 898 flag &= 0x50;
910 if((flag == 0x40) || (flag == 0x10)) return TRUE; 899 if((flag == 0x40) || (flag == 0x10)) return TRUE;
911 } 900 }
912 } 901 }
913 return FALSE; 902 return FALSE;
914} 903}
915 904
916static BOOLEAN 905static BOOLEAN
917SiS_BridgeInSlavemode(SiS_Private *SiS_Pr) 906SiS_BridgeInSlavemode(struct SiS_Private *SiS_Pr)
918{ 907{
919 USHORT flag1; 908 unsigned short flag1;
920 909
921 flag1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x31); 910 flag1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x31);
922 if(flag1 & (SetInSlaveMode >> 8)) return TRUE; 911 if(flag1 & (SetInSlaveMode >> 8)) return TRUE;
923 return FALSE; 912 return FALSE;
924} 913}
925 914
926/*********************************************/ 915/*********************************************/
@@ -928,119 +917,97 @@ SiS_BridgeInSlavemode(SiS_Private *SiS_Pr)
928/*********************************************/ 917/*********************************************/
929 918
930/* Setup general purpose IO for Chrontel communication */ 919/* Setup general purpose IO for Chrontel communication */
920#ifdef SIS300
931void 921void
932SiS_SetChrontelGPIO(SiS_Private *SiS_Pr, USHORT myvbinfo) 922SiS_SetChrontelGPIO(struct SiS_Private *SiS_Pr, unsigned short myvbinfo)
933{ 923{
934 unsigned long acpibase; 924 unsigned int acpibase;
935 unsigned short temp; 925 unsigned short temp;
936 926
937 if(!(SiS_Pr->SiS_ChSW)) return; 927 if(!(SiS_Pr->SiS_ChSW)) return;
938 928
939#ifdef LINUX_KERNEL 929#ifdef SIS_LINUX_KERNEL
940 SiS_SetRegLong(0xcf8,0x80000874); /* get ACPI base */ 930 acpibase = sisfb_read_lpc_pci_dword(SiS_Pr, 0x74);
941 acpibase = SiS_GetRegLong(0xcfc);
942#else 931#else
943 acpibase = pciReadLong(0x00000800, 0x74); 932 acpibase = pciReadLong(0x00000800, 0x74);
944#endif 933#endif
945 acpibase &= 0xFFFF; 934 acpibase &= 0xFFFF;
946 temp = SiS_GetRegShort((USHORT)(acpibase + 0x3c)); /* ACPI register 0x3c: GP Event 1 I/O mode select */ 935 if(!acpibase) return;
936 temp = SiS_GetRegShort((acpibase + 0x3c)); /* ACPI register 0x3c: GP Event 1 I/O mode select */
947 temp &= 0xFEFF; 937 temp &= 0xFEFF;
948 SiS_SetRegShort((USHORT)(acpibase + 0x3c), temp); 938 SiS_SetRegShort((acpibase + 0x3c), temp);
949 temp = SiS_GetRegShort((USHORT)(acpibase + 0x3c)); 939 temp = SiS_GetRegShort((acpibase + 0x3c));
950 temp = SiS_GetRegShort((USHORT)(acpibase + 0x3a)); /* ACPI register 0x3a: GP Pin Level (low/high) */ 940 temp = SiS_GetRegShort((acpibase + 0x3a)); /* ACPI register 0x3a: GP Pin Level (low/high) */
951 temp &= 0xFEFF; 941 temp &= 0xFEFF;
952 if(!(myvbinfo & SetCRT2ToTV)) temp |= 0x0100; 942 if(!(myvbinfo & SetCRT2ToTV)) temp |= 0x0100;
953 SiS_SetRegShort((USHORT)(acpibase + 0x3a), temp); 943 SiS_SetRegShort((acpibase + 0x3a), temp);
954 temp = SiS_GetRegShort((USHORT)(acpibase + 0x3a)); 944 temp = SiS_GetRegShort((acpibase + 0x3a));
955} 945}
946#endif
956 947
957void 948void
958SiS_GetVBInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, 949SiS_GetVBInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
959 PSIS_HW_INFO HwInfo, int checkcrt2mode) 950 unsigned short ModeIdIndex, int checkcrt2mode)
960{ 951{
961 USHORT tempax,tempbx,temp; 952 unsigned short tempax, tempbx, temp;
962 USHORT modeflag, resinfo=0; 953 unsigned short modeflag, resinfo = 0;
963 954
964 if(ModeNo <= 0x13) { 955 SiS_Pr->SiS_SetFlag = 0;
965 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
966 } else if(SiS_Pr->UseCustomMode) {
967 modeflag = SiS_Pr->CModeFlag;
968 } else {
969 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
970 resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
971 }
972 956
973 SiS_Pr->SiS_SetFlag = 0; 957 modeflag = SiS_GetModeFlag(SiS_Pr, ModeNo, ModeIdIndex);
974 958
975 SiS_Pr->SiS_ModeType = modeflag & ModeTypeMask; 959 SiS_Pr->SiS_ModeType = modeflag & ModeTypeMask;
976 960
977 tempbx = 0; 961 if((ModeNo > 0x13) && (!SiS_Pr->UseCustomMode)) {
978 if(SiS_BridgeIsOn(SiS_Pr)) { 962 resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
979 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); 963 }
980#if 0 964
981 if(HwInfo->jChipType < SIS_661) { 965 tempbx = 0;
982 /* NO - YPbPr not set yet ! */ 966
983 if(SiS_Pr->SiS_YPbPr & <all ypbpr except 525i>) { 967 if(SiS_HaveBridge(SiS_Pr)) {
984 temp &= (SetCRT2ToHiVision | SwitchCRT2 | SetSimuScanMode); /* 0x83 */ 968
985 temp |= SetCRT2ToHiVision; /* 0x80 */ 969 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30);
986 } 970 tempbx |= temp;
987 if(SiS_Pr->SiS_YPbPr & <ypbpr525i>) { 971 tempax = SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) << 8;
988 temp &= (SetCRT2ToHiVision | SwitchCRT2 | SetSimuScanMode); /* 0x83 */ 972 tempax &= (DriverMode | LoadDACFlag | SetNotSimuMode | SetPALTV);
989 temp |= SetCRT2ToSVIDEO; /* 0x08 */ 973 tempbx |= tempax;
990 }
991 }
992#endif
993 tempbx |= temp;
994 tempax = SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) << 8;
995 tempax &= (DriverMode | LoadDACFlag | SetNotSimuMode | SetPALTV);
996 tempbx |= tempax;
997 974
998#ifdef SIS315H 975#ifdef SIS315H
999 if(HwInfo->jChipType >= SIS_315H) { 976 if(SiS_Pr->ChipType >= SIS_315H) {
1000 if(SiS_Pr->SiS_VBType & VB_SISLCDA) { 977 if(SiS_Pr->SiS_VBType & VB_SISLCDA) {
1001 if(ModeNo == 0x03) { 978 if(ModeNo == 0x03) {
1002 /* Mode 0x03 is never in driver mode */ 979 /* Mode 0x03 is never in driver mode */
1003 SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x31,0xbf); 980 SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x31,0xbf);
1004 } 981 }
1005 if(!(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & (DriverMode >> 8))) { 982 if(!(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & (DriverMode >> 8))) {
1006 /* Reset LCDA setting if not driver mode */ 983 /* Reset LCDA setting if not driver mode */
1007 SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x38,0xfc); 984 SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x38,0xfc);
1008 } 985 }
1009 if(IS_SIS650) { 986 if(IS_SIS650) {
1010 if(SiS_Pr->SiS_UseLCDA) { 987 if(SiS_Pr->SiS_UseLCDA) {
1011 if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f) & 0xF0) { 988 if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x5f) & 0xF0) {
1012 if((ModeNo <= 0x13) || (!(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & (DriverMode >> 8)))) { 989 if((ModeNo <= 0x13) || (!(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & (DriverMode >> 8)))) {
1013 SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x38,(EnableDualEdge | SetToLCDA)); 990 SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x38,(EnableDualEdge | SetToLCDA));
1014 } 991 }
1015 } 992 }
1016 } 993 }
1017 } 994 }
1018 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); 995 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38);
1019 if((temp & (EnableDualEdge | SetToLCDA)) == (EnableDualEdge | SetToLCDA)) { 996 if((temp & (EnableDualEdge | SetToLCDA)) == (EnableDualEdge | SetToLCDA)) {
1020 tempbx |= SetCRT2ToLCDA; 997 tempbx |= SetCRT2ToLCDA;
1021 } 998 }
1022 } 999 }
1023 1000
1024 if(SiS_Pr->SiS_VBType & (VB_SIS301LV|VB_SIS302LV|VB_SIS302ELV)) { 1001 if(SiS_Pr->ChipType >= SIS_661) { /* New CR layout */
1025 tempbx &= ~(SetCRT2ToRAMDAC);
1026 }
1027
1028 if(HwInfo->jChipType >= SIS_661) {
1029 tempbx &= ~(SetCRT2ToYPbPr525750 | SetCRT2ToHiVision); 1002 tempbx &= ~(SetCRT2ToYPbPr525750 | SetCRT2ToHiVision);
1030 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); 1003 if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x38) & 0x04) {
1031 if(SiS_Pr->SiS_VBType & VB_SISYPBPR) { 1004 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35) & 0xe0;
1032 if(temp & 0x04) { 1005 if(temp == 0x60) tempbx |= SetCRT2ToHiVision;
1033 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35) & 0xe0; 1006 else if(SiS_Pr->SiS_VBType & VB_SISYPBPR) {
1034 if(temp == 0x60) tempbx |= SetCRT2ToHiVision; 1007 tempbx |= SetCRT2ToYPbPr525750;
1035 else tempbx |= SetCRT2ToYPbPr525750;
1036 }
1037 } else if(SiS_Pr->SiS_VBType & VB_SISHIVISION) {
1038 if(temp & 0x04) {
1039 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35) & 0xe0;
1040 if(temp == 0x60) tempbx |= SetCRT2ToHiVision;
1041 } 1008 }
1042 } 1009 }
1043 } 1010 }
1044 1011
1045 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { 1012 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
1046 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); 1013 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38);
@@ -1048,7 +1015,7 @@ SiS_GetVBInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
1048 tempbx |= SetCRT2ToLCDA; 1015 tempbx |= SetCRT2ToLCDA;
1049 } 1016 }
1050 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { 1017 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
1051 if(temp & EnableCHYPbPr) { 1018 if(temp & EnableCHYPbPr) {
1052 tempbx |= SetCRT2ToCHYPbPr; 1019 tempbx |= SetCRT2ToCHYPbPr;
1053 } 1020 }
1054 } 1021 }
@@ -1057,44 +1024,49 @@ SiS_GetVBInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
1057 1024
1058#endif /* SIS315H */ 1025#endif /* SIS315H */
1059 1026
1060 if(SiS_Pr->SiS_VBType & VB_SISVB) { 1027 if(!(SiS_Pr->SiS_VBType & VB_SISVGA2)) {
1028 tempbx &= ~(SetCRT2ToRAMDAC);
1029 }
1030
1031 if(SiS_Pr->SiS_VBType & VB_SISVB) {
1061 temp = SetCRT2ToSVIDEO | 1032 temp = SetCRT2ToSVIDEO |
1062 SetCRT2ToAVIDEO | 1033 SetCRT2ToAVIDEO |
1063 SetCRT2ToSCART | 1034 SetCRT2ToSCART |
1064 SetCRT2ToLCDA | 1035 SetCRT2ToLCDA |
1065 SetCRT2ToLCD | 1036 SetCRT2ToLCD |
1066 SetCRT2ToRAMDAC | 1037 SetCRT2ToRAMDAC |
1067 SetCRT2ToHiVision | 1038 SetCRT2ToHiVision |
1068 SetCRT2ToYPbPr525750; 1039 SetCRT2ToYPbPr525750;
1069 } else { 1040 } else {
1070 if(HwInfo->jChipType >= SIS_315H) { 1041 if(SiS_Pr->ChipType >= SIS_315H) {
1071 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { 1042 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
1072 temp = SetCRT2ToAVIDEO | 1043 temp = SetCRT2ToAVIDEO |
1073 SetCRT2ToSVIDEO | 1044 SetCRT2ToSVIDEO |
1074 SetCRT2ToSCART | 1045 SetCRT2ToSCART |
1075 SetCRT2ToLCDA | 1046 SetCRT2ToLCDA |
1076 SetCRT2ToLCD | 1047 SetCRT2ToLCD |
1077 SetCRT2ToCHYPbPr; 1048 SetCRT2ToCHYPbPr;
1078 } else { 1049 } else {
1079 temp = SetCRT2ToLCDA | 1050 temp = SetCRT2ToLCDA |
1080 SetCRT2ToLCD; 1051 SetCRT2ToLCD;
1081 } 1052 }
1082 } else { 1053 } else {
1083 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { 1054 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
1084 temp = SetCRT2ToTV | SetCRT2ToLCD; 1055 temp = SetCRT2ToTV | SetCRT2ToLCD;
1085 } else { 1056 } else {
1086 temp = SetCRT2ToLCD; 1057 temp = SetCRT2ToLCD;
1087 } 1058 }
1088 } 1059 }
1089 } 1060 }
1061
1062 if(!(tempbx & temp)) {
1063 tempax = DisableCRT2Display;
1064 tempbx = 0;
1065 }
1090 1066
1091 if(!(tempbx & temp)) { 1067 if(SiS_Pr->SiS_VBType & VB_SISVB) {
1092 tempax = DisableCRT2Display;
1093 tempbx = 0;
1094 }
1095 1068
1096 if(SiS_Pr->SiS_VBType & VB_SISVB) { 1069 unsigned short clearmask = ( DriverMode |
1097 USHORT clearmask = ( DriverMode |
1098 DisableCRT2Display | 1070 DisableCRT2Display |
1099 LoadDACFlag | 1071 LoadDACFlag |
1100 SetNotSimuMode | 1072 SetNotSimuMode |
@@ -1102,106 +1074,104 @@ SiS_GetVBInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
1102 SetPALTV | 1074 SetPALTV |
1103 SwitchCRT2 | 1075 SwitchCRT2 |
1104 SetSimuScanMode ); 1076 SetSimuScanMode );
1105 if(tempbx & SetCRT2ToLCDA) tempbx &= (clearmask | SetCRT2ToLCDA); 1077
1078 if(tempbx & SetCRT2ToLCDA) tempbx &= (clearmask | SetCRT2ToLCDA);
1106 if(tempbx & SetCRT2ToRAMDAC) tempbx &= (clearmask | SetCRT2ToRAMDAC); 1079 if(tempbx & SetCRT2ToRAMDAC) tempbx &= (clearmask | SetCRT2ToRAMDAC);
1107 if(tempbx & SetCRT2ToLCD) tempbx &= (clearmask | SetCRT2ToLCD); 1080 if(tempbx & SetCRT2ToLCD) tempbx &= (clearmask | SetCRT2ToLCD);
1108 if(tempbx & SetCRT2ToSCART) tempbx &= (clearmask | SetCRT2ToSCART); 1081 if(tempbx & SetCRT2ToSCART) tempbx &= (clearmask | SetCRT2ToSCART);
1109 if(tempbx & SetCRT2ToHiVision) tempbx &= (clearmask | SetCRT2ToHiVision); 1082 if(tempbx & SetCRT2ToHiVision) tempbx &= (clearmask | SetCRT2ToHiVision);
1110 if(tempbx & SetCRT2ToYPbPr525750) tempbx &= (clearmask | SetCRT2ToYPbPr525750); 1083 if(tempbx & SetCRT2ToYPbPr525750) tempbx &= (clearmask | SetCRT2ToYPbPr525750);
1111 } else { 1084
1112 if(HwInfo->jChipType >= SIS_315H) { 1085 } else {
1086
1087 if(SiS_Pr->ChipType >= SIS_315H) {
1113 if(tempbx & SetCRT2ToLCDA) { 1088 if(tempbx & SetCRT2ToLCDA) {
1114 tempbx &= (0xFF00|SwitchCRT2|SetSimuScanMode); 1089 tempbx &= (0xFF00|SwitchCRT2|SetSimuScanMode);
1115 } 1090 }
1116 } 1091 }
1117 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { 1092 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
1118 if(tempbx & SetCRT2ToTV) { 1093 if(tempbx & SetCRT2ToTV) {
1119 tempbx &= (0xFF00|SetCRT2ToTV|SwitchCRT2|SetSimuScanMode); 1094 tempbx &= (0xFF00|SetCRT2ToTV|SwitchCRT2|SetSimuScanMode);
1120 } 1095 }
1121 }
1122 if(tempbx & SetCRT2ToLCD) {
1123 tempbx &= (0xFF00|SetCRT2ToLCD|SwitchCRT2|SetSimuScanMode);
1124 } 1096 }
1125 if(HwInfo->jChipType >= SIS_315H) { 1097 if(tempbx & SetCRT2ToLCD) {
1098 tempbx &= (0xFF00|SetCRT2ToLCD|SwitchCRT2|SetSimuScanMode);
1099 }
1100 if(SiS_Pr->ChipType >= SIS_315H) {
1126 if(tempbx & SetCRT2ToLCDA) { 1101 if(tempbx & SetCRT2ToLCDA) {
1127 tempbx |= SetCRT2ToLCD; 1102 tempbx |= SetCRT2ToLCD;
1128 } 1103 }
1129 } 1104 }
1105
1130 } 1106 }
1131 1107
1132 if(tempax & DisableCRT2Display) { 1108 if(tempax & DisableCRT2Display) {
1133 if(!(tempbx & (SwitchCRT2 | SetSimuScanMode))) { 1109 if(!(tempbx & (SwitchCRT2 | SetSimuScanMode))) {
1134 tempbx = SetSimuScanMode | DisableCRT2Display; 1110 tempbx = SetSimuScanMode | DisableCRT2Display;
1135 } 1111 }
1136 } 1112 }
1137 1113
1138 if(!(tempbx & DriverMode)) tempbx |= SetSimuScanMode; 1114 if(!(tempbx & DriverMode)) tempbx |= SetSimuScanMode;
1139 1115
1140 /* LVDS/CHRONTEL (LCD/TV) and 301BDH (LCD) can only be slave in 8bpp modes */ 1116 /* LVDS/CHRONTEL (LCD/TV) and 301BDH (LCD) can only be slave in 8bpp modes */
1141 if(SiS_Pr->SiS_ModeType <= ModeVGA) { 1117 if(SiS_Pr->SiS_ModeType <= ModeVGA) {
1142 if( (SiS_Pr->SiS_IF_DEF_LVDS == 1) || 1118 if( (SiS_Pr->SiS_IF_DEF_LVDS == 1) ||
1143 ((SiS_Pr->SiS_VBType & VB_NoLCD) && (tempbx & SetCRT2ToLCD)) ) { 1119 ((SiS_Pr->SiS_VBType & VB_NoLCD) && (tempbx & SetCRT2ToLCD)) ) {
1144 modeflag &= (~CRT2Mode); 1120 modeflag &= (~CRT2Mode);
1145 } 1121 }
1146 } 1122 }
1147 1123
1148 if(!(tempbx & SetSimuScanMode)) { 1124 if(!(tempbx & SetSimuScanMode)) {
1149 if(tempbx & SwitchCRT2) { 1125 if(tempbx & SwitchCRT2) {
1150 if((!(modeflag & CRT2Mode)) && (checkcrt2mode)) { 1126 if((!(modeflag & CRT2Mode)) && (checkcrt2mode)) {
1151 if( (HwInfo->jChipType >= SIS_315H) && 1127 if(resinfo != SIS_RI_1600x1200) {
1152 (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) ) { 1128 tempbx |= SetSimuScanMode;
1153 if(resinfo != SIS_RI_1600x1200) { 1129 }
1154 tempbx |= SetSimuScanMode;
1155 }
1156 } else {
1157 tempbx |= SetSimuScanMode;
1158 }
1159 } 1130 }
1160 } else { 1131 } else {
1161 if(SiS_BridgeIsEnabled(SiS_Pr,HwInfo)) { 1132 if(SiS_BridgeIsEnabled(SiS_Pr)) {
1162 if(!(tempbx & DriverMode)) { 1133 if(!(tempbx & DriverMode)) {
1163 if(SiS_BridgeInSlavemode(SiS_Pr)) { 1134 if(SiS_BridgeInSlavemode(SiS_Pr)) {
1164 tempbx |= SetSimuScanMode; 1135 tempbx |= SetSimuScanMode;
1165 } 1136 }
1166 } 1137 }
1167 } 1138 }
1168 } 1139 }
1169 } 1140 }
1170
1171 if(!(tempbx & DisableCRT2Display)) {
1172 if(tempbx & DriverMode) {
1173 if(tempbx & SetSimuScanMode) {
1174 if((!(modeflag & CRT2Mode)) && (checkcrt2mode)) {
1175 if( (HwInfo->jChipType >= SIS_315H) &&
1176 (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) ) {
1177 if(resinfo != SIS_RI_1600x1200) {
1178 tempbx |= SetInSlaveMode;
1179 }
1180 } else {
1181 tempbx |= SetInSlaveMode;
1182 }
1183 }
1184 }
1185 } else {
1186 tempbx |= SetInSlaveMode;
1187 }
1188 }
1189 1141
1190 } 1142 if(!(tempbx & DisableCRT2Display)) {
1143 if(tempbx & DriverMode) {
1144 if(tempbx & SetSimuScanMode) {
1145 if((!(modeflag & CRT2Mode)) && (checkcrt2mode)) {
1146 if(resinfo != SIS_RI_1600x1200) {
1147 tempbx |= SetInSlaveMode;
1148 }
1149 }
1150 }
1151 } else {
1152 tempbx |= SetInSlaveMode;
1153 }
1154 }
1191 1155
1192 SiS_Pr->SiS_VBInfo = tempbx; 1156 }
1193 1157
1194 if(HwInfo->jChipType == SIS_630) { 1158 SiS_Pr->SiS_VBInfo = tempbx;
1195 SiS_SetChrontelGPIO(SiS_Pr, SiS_Pr->SiS_VBInfo);
1196 }
1197 1159
1198#ifdef TWDEBUG 1160#ifdef SIS300
1199#ifdef LINUX_KERNEL 1161 if(SiS_Pr->ChipType == SIS_630) {
1200 printk(KERN_DEBUG "sisfb: (VBInfo= 0x%04x, SetFlag=0x%04x)\n", 1162 SiS_SetChrontelGPIO(SiS_Pr, SiS_Pr->SiS_VBInfo);
1163 }
1164#endif
1165
1166#ifdef SIS_LINUX_KERNEL
1167#if 0
1168 printk(KERN_DEBUG "sisfb: (init301: VBInfo= 0x%04x, SetFlag=0x%04x)\n",
1201 SiS_Pr->SiS_VBInfo, SiS_Pr->SiS_SetFlag); 1169 SiS_Pr->SiS_VBInfo, SiS_Pr->SiS_SetFlag);
1202#endif 1170#endif
1203#ifdef LINUX_XF86 1171#endif
1204 xf86DrvMsgVerb(0, X_PROBED, 3, "(init301: VBInfo=0x%04x, SetFlag=0x%04x)\n", 1172#ifdef SIS_XORG_XF86
1173#ifdef TWDEBUG
1174 xf86DrvMsg(0, X_PROBED, "(init301: VBInfo=0x%04x, SetFlag=0x%04x)\n",
1205 SiS_Pr->SiS_VBInfo, SiS_Pr->SiS_SetFlag); 1175 SiS_Pr->SiS_VBInfo, SiS_Pr->SiS_SetFlag);
1206#endif 1176#endif
1207#endif 1177#endif
@@ -1212,41 +1182,41 @@ SiS_GetVBInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
1212/*********************************************/ 1182/*********************************************/
1213 1183
1214void 1184void
1215SiS_SetYPbPr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 1185SiS_SetYPbPr(struct SiS_Private *SiS_Pr)
1216{ 1186{
1217 1187
1218 UCHAR temp; 1188 unsigned char temp;
1219 1189
1220 /* Note: This variable is only used on 30xLV systems. 1190 /* Note: This variable is only used on 30xLV systems.
1221 * CR38 has a different meaning on LVDS/CH7019 systems. 1191 * CR38 has a different meaning on LVDS/CH7019 systems.
1222 * On 661 and later, these bits moved to CR35. 1192 * On 661 and later, these bits moved to CR35.
1223 * 1193 *
1224 * On 301, 301B, only HiVision 1080i is supported. 1194 * On 301, 301B, only HiVision 1080i is supported.
1225 * On 30xLV, 301C, only YPbPr 1080i is supported. 1195 * On 30xLV, 301C, only YPbPr 1080i is supported.
1226 */ 1196 */
1227 1197
1228 SiS_Pr->SiS_YPbPr = 0; 1198 SiS_Pr->SiS_YPbPr = 0;
1229 if(HwInfo->jChipType >= SIS_661) return; 1199 if(SiS_Pr->ChipType >= SIS_661) return;
1230 1200
1231 if(SiS_Pr->SiS_VBType) { 1201 if(SiS_Pr->SiS_VBType) {
1232 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { 1202 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {
1233 SiS_Pr->SiS_YPbPr = YPbPrHiVision; 1203 SiS_Pr->SiS_YPbPr = YPbPrHiVision;
1234 } 1204 }
1235 } 1205 }
1236 1206
1237 if(HwInfo->jChipType >= SIS_315H) { 1207 if(SiS_Pr->ChipType >= SIS_315H) {
1238 if(SiS_Pr->SiS_VBType & (VB_SIS301LV302LV | VB_SIS301C)) { 1208 if(SiS_Pr->SiS_VBType & VB_SISYPBPR) {
1239 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); 1209 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38);
1240 if(temp & 0x08) { 1210 if(temp & 0x08) {
1241 switch((temp >> 4)) { 1211 switch((temp >> 4)) {
1242 case 0x00: SiS_Pr->SiS_YPbPr = YPbPr525i; break; 1212 case 0x00: SiS_Pr->SiS_YPbPr = YPbPr525i; break;
1243 case 0x01: SiS_Pr->SiS_YPbPr = YPbPr525p; break; 1213 case 0x01: SiS_Pr->SiS_YPbPr = YPbPr525p; break;
1244 case 0x02: SiS_Pr->SiS_YPbPr = YPbPr750p; break; 1214 case 0x02: SiS_Pr->SiS_YPbPr = YPbPr750p; break;
1245 case 0x03: SiS_Pr->SiS_YPbPr = YPbPrHiVision; break; 1215 case 0x03: SiS_Pr->SiS_YPbPr = YPbPrHiVision; break;
1246 } 1216 }
1247 } 1217 }
1248 } 1218 }
1249 } 1219 }
1250 1220
1251} 1221}
1252 1222
@@ -1255,199 +1225,204 @@ SiS_SetYPbPr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
1255/*********************************************/ 1225/*********************************************/
1256 1226
1257void 1227void
1258SiS_SetTVMode(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, PSIS_HW_INFO HwInfo) 1228SiS_SetTVMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex)
1259{ 1229{
1260 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; 1230 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
1261 USHORT temp, temp1, resinfo = 0, romindex = 0; 1231 unsigned short temp, temp1, resinfo = 0, romindex = 0;
1262 UCHAR OutputSelect = *SiS_Pr->pSiS_OutputSelect; 1232 unsigned char OutputSelect = *SiS_Pr->pSiS_OutputSelect;
1263 1233
1264 SiS_Pr->SiS_TVMode = 0; 1234 SiS_Pr->SiS_TVMode = 0;
1265 1235
1266 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) return; 1236 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) return;
1267 if(SiS_Pr->UseCustomMode) return; 1237 if(SiS_Pr->UseCustomMode) return;
1268 1238
1269 if(ModeNo > 0x13) { 1239 if(ModeNo > 0x13) {
1270 resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; 1240 resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
1271 } 1241 }
1272 1242
1273 if(HwInfo->jChipType < SIS_661) { 1243 if(SiS_Pr->ChipType < SIS_661) {
1274 1244
1275 if(SiS_Pr->SiS_VBInfo & SetPALTV) SiS_Pr->SiS_TVMode |= TVSetPAL; 1245 if(SiS_Pr->SiS_VBInfo & SetPALTV) SiS_Pr->SiS_TVMode |= TVSetPAL;
1276 1246
1277 if(SiS_Pr->SiS_VBType & VB_SISVB) { 1247 if(SiS_Pr->SiS_VBType & VB_SISVB) {
1278 temp = 0; 1248 temp = 0;
1279 if((HwInfo->jChipType == SIS_630) || 1249 if((SiS_Pr->ChipType == SIS_630) ||
1280 (HwInfo->jChipType == SIS_730)) { 1250 (SiS_Pr->ChipType == SIS_730)) {
1281 temp = 0x35; 1251 temp = 0x35;
1282 romindex = 0xfe; 1252 romindex = 0xfe;
1283 } else if(HwInfo->jChipType >= SIS_315H) { 1253 } else if(SiS_Pr->ChipType >= SIS_315H) {
1284 temp = 0x38; 1254 temp = 0x38;
1285 romindex = 0xf3; 1255 if(SiS_Pr->ChipType < XGI_20) {
1286 if(HwInfo->jChipType >= SIS_330) romindex = 0x11b; 1256 romindex = 0xf3;
1287 } 1257 if(SiS_Pr->ChipType >= SIS_330) romindex = 0x11b;
1288 if(temp) { 1258 }
1289 if(romindex && SiS_Pr->SiS_UseROM && (!(SiS_Pr->SiS_ROMNew))) { 1259 }
1290 OutputSelect = ROMAddr[romindex]; 1260 if(temp) {
1291 if(!(OutputSelect & EnablePALMN)) { 1261 if(romindex && SiS_Pr->SiS_UseROM && (!(SiS_Pr->SiS_ROMNew))) {
1292 SiS_SetRegAND(SiS_Pr->SiS_P3d4,temp,0x3F); 1262 OutputSelect = ROMAddr[romindex];
1293 } 1263 if(!(OutputSelect & EnablePALMN)) {
1294 } 1264 SiS_SetRegAND(SiS_Pr->SiS_P3d4,temp,0x3F);
1295 temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,temp); 1265 }
1296 if(SiS_Pr->SiS_TVMode & TVSetPAL) { 1266 }
1297 if(temp1 & EnablePALM) { /* 0x40 */ 1267 temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,temp);
1298 SiS_Pr->SiS_TVMode |= TVSetPALM; 1268 if(SiS_Pr->SiS_TVMode & TVSetPAL) {
1299 SiS_Pr->SiS_TVMode &= ~TVSetPAL; 1269 if(temp1 & EnablePALM) { /* 0x40 */
1300 } else if(temp1 & EnablePALN) { /* 0x80 */ 1270 SiS_Pr->SiS_TVMode |= TVSetPALM;
1301 SiS_Pr->SiS_TVMode |= TVSetPALN; 1271 SiS_Pr->SiS_TVMode &= ~TVSetPAL;
1302 } 1272 } else if(temp1 & EnablePALN) { /* 0x80 */
1303 } else { 1273 SiS_Pr->SiS_TVMode |= TVSetPALN;
1304 if(temp1 & EnableNTSCJ) { /* 0x40 */ 1274 }
1305 SiS_Pr->SiS_TVMode |= TVSetNTSCJ; 1275 } else {
1306 } 1276 if(temp1 & EnableNTSCJ) { /* 0x40 */
1307 } 1277 SiS_Pr->SiS_TVMode |= TVSetNTSCJ;
1308 } 1278 }
1309 /* Translate HiVision/YPbPr to our new flags */ 1279 }
1310 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { 1280 }
1311 if(SiS_Pr->SiS_YPbPr == YPbPr750p) SiS_Pr->SiS_TVMode |= TVSetYPbPr750p; 1281 /* Translate HiVision/YPbPr to our new flags */
1312 else if(SiS_Pr->SiS_YPbPr == YPbPr525p) SiS_Pr->SiS_TVMode |= TVSetYPbPr525p; 1282 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {
1313 else if(SiS_Pr->SiS_YPbPr == YPbPrHiVision) SiS_Pr->SiS_TVMode |= TVSetHiVision; 1283 if(SiS_Pr->SiS_YPbPr == YPbPr750p) SiS_Pr->SiS_TVMode |= TVSetYPbPr750p;
1314 else SiS_Pr->SiS_TVMode |= TVSetYPbPr525i; 1284 else if(SiS_Pr->SiS_YPbPr == YPbPr525p) SiS_Pr->SiS_TVMode |= TVSetYPbPr525p;
1315 if(SiS_Pr->SiS_TVMode & (TVSetYPbPr750p | TVSetYPbPr525p | TVSetYPbPr525i)) { 1285 else if(SiS_Pr->SiS_YPbPr == YPbPrHiVision) SiS_Pr->SiS_TVMode |= TVSetHiVision;
1316 SiS_Pr->SiS_VBInfo &= ~SetCRT2ToHiVision; 1286 else SiS_Pr->SiS_TVMode |= TVSetYPbPr525i;
1317 SiS_Pr->SiS_VBInfo |= SetCRT2ToYPbPr525750; 1287 if(SiS_Pr->SiS_TVMode & (TVSetYPbPr750p | TVSetYPbPr525p | TVSetYPbPr525i)) {
1318 } else if(SiS_Pr->SiS_TVMode & TVSetHiVision) { 1288 SiS_Pr->SiS_VBInfo &= ~SetCRT2ToHiVision;
1319 SiS_Pr->SiS_TVMode |= TVSetPAL; 1289 SiS_Pr->SiS_VBInfo |= SetCRT2ToYPbPr525750;
1320 } 1290 } else if(SiS_Pr->SiS_TVMode & TVSetHiVision) {
1321 } 1291 SiS_Pr->SiS_TVMode |= TVSetPAL;
1322 } else if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { 1292 }
1323 if(SiS_Pr->SiS_CHOverScan) { 1293 }
1324 if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { 1294 } else if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
1325 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); 1295 if(SiS_Pr->SiS_CHOverScan) {
1326 if((temp & TVOverScan) || (SiS_Pr->SiS_CHOverScan == 1)) { 1296 if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) {
1327 SiS_Pr->SiS_TVMode |= TVSetCHOverScan; 1297 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35);
1328 } 1298 if((temp & TVOverScan) || (SiS_Pr->SiS_CHOverScan == 1)) {
1329 } else if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { 1299 SiS_Pr->SiS_TVMode |= TVSetCHOverScan;
1330 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x79); 1300 }
1331 if((temp & 0x80) || (SiS_Pr->SiS_CHOverScan == 1)) { 1301 } else if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
1332 SiS_Pr->SiS_TVMode |= TVSetCHOverScan; 1302 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x79);
1333 } 1303 if((temp & 0x80) || (SiS_Pr->SiS_CHOverScan == 1)) {
1334 } 1304 SiS_Pr->SiS_TVMode |= TVSetCHOverScan;
1335 if(SiS_Pr->SiS_CHSOverScan) { 1305 }
1336 SiS_Pr->SiS_TVMode |= TVSetCHOverScan; 1306 }
1337 } 1307 if(SiS_Pr->SiS_CHSOverScan) {
1338 } 1308 SiS_Pr->SiS_TVMode |= TVSetCHOverScan;
1339 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { 1309 }
1340 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38); 1310 }
1341 if(SiS_Pr->SiS_TVMode & TVSetPAL) { 1311 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
1342 if(temp & EnablePALM) SiS_Pr->SiS_TVMode |= TVSetPALM; 1312 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x38);
1343 else if(temp & EnablePALN) SiS_Pr->SiS_TVMode |= TVSetPALN; 1313 if(SiS_Pr->SiS_TVMode & TVSetPAL) {
1344 } else { 1314 if(temp & EnablePALM) SiS_Pr->SiS_TVMode |= TVSetPALM;
1345 if(temp & EnableNTSCJ) { 1315 else if(temp & EnablePALN) SiS_Pr->SiS_TVMode |= TVSetPALN;
1346 SiS_Pr->SiS_TVMode |= TVSetNTSCJ; 1316 } else {
1347 } 1317 if(temp & EnableNTSCJ) {
1348 } 1318 SiS_Pr->SiS_TVMode |= TVSetNTSCJ;
1349 } 1319 }
1350 } 1320 }
1321 }
1322 }
1351 1323
1352 } else { /* 661 and later */ 1324 } else { /* 661 and later */
1353 1325
1354 temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); 1326 temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35);
1355 if(temp1 & 0x01) { 1327 if(temp1 & 0x01) {
1356 SiS_Pr->SiS_TVMode |= TVSetPAL; 1328 SiS_Pr->SiS_TVMode |= TVSetPAL;
1357 if(temp1 & 0x08) { 1329 if(temp1 & 0x08) {
1358 SiS_Pr->SiS_TVMode |= TVSetPALN; 1330 SiS_Pr->SiS_TVMode |= TVSetPALN;
1359 } else if(temp1 & 0x04) { 1331 } else if(temp1 & 0x04) {
1360 if(SiS_Pr->SiS_VBType & VB_SISVB) { 1332 if(SiS_Pr->SiS_VBType & VB_SISVB) {
1361 SiS_Pr->SiS_TVMode &= ~TVSetPAL; 1333 SiS_Pr->SiS_TVMode &= ~TVSetPAL;
1362 } 1334 }
1363 SiS_Pr->SiS_TVMode |= TVSetPALM; 1335 SiS_Pr->SiS_TVMode |= TVSetPALM;
1364 } 1336 }
1365 } else { 1337 } else {
1366 if(temp1 & 0x02) { 1338 if(temp1 & 0x02) {
1367 SiS_Pr->SiS_TVMode |= TVSetNTSCJ; 1339 SiS_Pr->SiS_TVMode |= TVSetNTSCJ;
1368 } 1340 }
1369 } 1341 }
1370 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { 1342 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
1371 if(SiS_Pr->SiS_CHOverScan) { 1343 if(SiS_Pr->SiS_CHOverScan) {
1372 if((temp1 & 0x10) || (SiS_Pr->SiS_CHOverScan == 1)) { 1344 if((temp1 & 0x10) || (SiS_Pr->SiS_CHOverScan == 1)) {
1373 SiS_Pr->SiS_TVMode |= TVSetCHOverScan; 1345 SiS_Pr->SiS_TVMode |= TVSetCHOverScan;
1374 } 1346 }
1375 } 1347 }
1376 } 1348 }
1377 if(SiS_Pr->SiS_VBType & VB_SISVB) { 1349 if(SiS_Pr->SiS_VBType & VB_SISVB) {
1378 if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { 1350 if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) {
1379 temp1 &= 0xe0; 1351 temp1 &= 0xe0;
1380 if(temp1 == 0x00) SiS_Pr->SiS_TVMode |= TVSetYPbPr525i; 1352 if(temp1 == 0x00) SiS_Pr->SiS_TVMode |= TVSetYPbPr525i;
1381 else if(temp1 == 0x20) SiS_Pr->SiS_TVMode |= TVSetYPbPr525p; 1353 else if(temp1 == 0x20) SiS_Pr->SiS_TVMode |= TVSetYPbPr525p;
1382 else if(temp1 == 0x40) SiS_Pr->SiS_TVMode |= TVSetYPbPr750p; 1354 else if(temp1 == 0x40) SiS_Pr->SiS_TVMode |= TVSetYPbPr750p;
1383 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { 1355 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {
1384 SiS_Pr->SiS_TVMode |= (TVSetHiVision | TVSetPAL); 1356 SiS_Pr->SiS_TVMode |= (TVSetHiVision | TVSetPAL);
1385 } 1357 }
1386 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToYPbPr525750 | SetCRT2ToHiVision)) { 1358 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToYPbPr525750 | SetCRT2ToHiVision)) {
1387 if(resinfo == SIS_RI_800x480 || resinfo == SIS_RI_1024x576 || resinfo == SIS_RI_1280x720) { 1359 if(resinfo == SIS_RI_800x480 || resinfo == SIS_RI_1024x576 || resinfo == SIS_RI_1280x720) {
1388 SiS_Pr->SiS_TVMode |= TVAspect169; 1360 SiS_Pr->SiS_TVMode |= TVAspect169;
1389 } else { 1361 } else {
1390 temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x39); 1362 temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x39);
1391 if(temp1 & 0x02) { 1363 if(temp1 & 0x02) {
1392 if(SiS_Pr->SiS_TVMode & (TVSetYPbPr750p | TVSetHiVision)) { 1364 if(SiS_Pr->SiS_TVMode & (TVSetYPbPr750p | TVSetHiVision)) {
1393 SiS_Pr->SiS_TVMode |= TVAspect169; 1365 SiS_Pr->SiS_TVMode |= TVAspect169;
1394 } else { 1366 } else {
1395 SiS_Pr->SiS_TVMode |= TVAspect43LB; 1367 SiS_Pr->SiS_TVMode |= TVAspect43LB;
1396 } 1368 }
1397 } else { 1369 } else {
1398 SiS_Pr->SiS_TVMode |= TVAspect43; 1370 SiS_Pr->SiS_TVMode |= TVAspect43;
1399 } 1371 }
1400 } 1372 }
1401 } 1373 }
1402 } 1374 }
1403 } 1375 }
1404 1376
1405 if(SiS_Pr->SiS_VBInfo & SetCRT2ToSCART) SiS_Pr->SiS_TVMode |= TVSetPAL; 1377 if(SiS_Pr->SiS_VBInfo & SetCRT2ToSCART) SiS_Pr->SiS_TVMode |= TVSetPAL;
1406 1378
1407 if(SiS_Pr->SiS_VBType & VB_SISVB) { 1379 if(SiS_Pr->SiS_VBType & VB_SISVB) {
1408 1380
1409 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { 1381 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {
1410 SiS_Pr->SiS_TVMode |= TVSetPAL; 1382 SiS_Pr->SiS_TVMode |= TVSetPAL;
1411 SiS_Pr->SiS_TVMode &= ~(TVSetPALM | TVSetPALN | TVSetNTSCJ); 1383 SiS_Pr->SiS_TVMode &= ~(TVSetPALM | TVSetPALN | TVSetNTSCJ);
1412 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { 1384 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) {
1413 if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525i | TVSetYPbPr525p | TVSetYPbPr750p)) { 1385 if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525i | TVSetYPbPr525p | TVSetYPbPr750p)) {
1414 SiS_Pr->SiS_TVMode &= ~(TVSetPAL | TVSetNTSCJ | TVSetPALM | TVSetPALN); 1386 SiS_Pr->SiS_TVMode &= ~(TVSetPAL | TVSetNTSCJ | TVSetPALM | TVSetPALN);
1415 } 1387 }
1416 } 1388 }
1417 1389
1418 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { 1390 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
1419 if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) { 1391 if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) {
1420 SiS_Pr->SiS_TVMode |= TVSetTVSimuMode; 1392 SiS_Pr->SiS_TVMode |= TVSetTVSimuMode;
1421 } 1393 }
1422 } 1394 }
1423 1395
1424 if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { 1396 if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) {
1425 /* BIOS sets TVNTSC1024 without checking 525p here. Wrong? */ 1397 if(resinfo == SIS_RI_1024x768) {
1426 if(!(SiS_Pr->SiS_TVMode & (TVSetHiVision | TVSetYPbPr525p | TVSetYPbPr750p))) { 1398 if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) {
1427 if(resinfo == SIS_RI_1024x768) { 1399 SiS_Pr->SiS_TVMode |= TVSet525p1024;
1428 SiS_Pr->SiS_TVMode |= TVSetNTSC1024; 1400 } else if(!(SiS_Pr->SiS_TVMode & (TVSetHiVision | TVSetYPbPr750p))) {
1429 } 1401 SiS_Pr->SiS_TVMode |= TVSetNTSC1024;
1430 } 1402 }
1431 } 1403 }
1404 }
1432 1405
1433 SiS_Pr->SiS_TVMode |= TVRPLLDIV2XO; 1406 SiS_Pr->SiS_TVMode |= TVRPLLDIV2XO;
1434 if((SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) && 1407 if((SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) &&
1435 (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { 1408 (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
1436 SiS_Pr->SiS_TVMode &= ~TVRPLLDIV2XO; 1409 SiS_Pr->SiS_TVMode &= ~TVRPLLDIV2XO;
1437 } else if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p)) { 1410 } else if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p)) {
1438 SiS_Pr->SiS_TVMode &= ~TVRPLLDIV2XO; 1411 SiS_Pr->SiS_TVMode &= ~TVRPLLDIV2XO;
1439 } else if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) { 1412 } else if(!(SiS_Pr->SiS_VBType & VB_SIS30xBLV)) {
1440 if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { 1413 if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) {
1441 SiS_Pr->SiS_TVMode &= ~TVRPLLDIV2XO; 1414 SiS_Pr->SiS_TVMode &= ~TVRPLLDIV2XO;
1442 } 1415 }
1443 } 1416 }
1444 1417
1445 } 1418 }
1446 1419
1447 SiS_Pr->SiS_VBInfo &= ~SetPALTV; 1420 SiS_Pr->SiS_VBInfo &= ~SetPALTV;
1448 1421
1422#ifdef SIS_XORG_XF86
1449#ifdef TWDEBUG 1423#ifdef TWDEBUG
1450 xf86DrvMsg(0, X_INFO, "(init301: TVMode %x, VBInfo %x)\n", SiS_Pr->SiS_TVMode, SiS_Pr->SiS_VBInfo); 1424 xf86DrvMsg(0, X_INFO, "(init301: TVMode %x, VBInfo %x)\n", SiS_Pr->SiS_TVMode, SiS_Pr->SiS_VBInfo);
1425#endif
1451#endif 1426#endif
1452} 1427}
1453 1428
@@ -1455,41 +1430,46 @@ SiS_SetTVMode(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, PSIS_HW_IN
1455/* GET LCD INFO */ 1430/* GET LCD INFO */
1456/*********************************************/ 1431/*********************************************/
1457 1432
1458static USHORT 1433static unsigned short
1459SiS_GetBIOSLCDResInfo(SiS_Private *SiS_Pr) 1434SiS_GetBIOSLCDResInfo(struct SiS_Private *SiS_Pr)
1460{ 1435{
1461 USHORT temp = SiS_Pr->SiS_LCDResInfo; 1436 unsigned short temp = SiS_Pr->SiS_LCDResInfo;
1462 /* Translate my LCDResInfo to BIOS value */ 1437 /* Translate my LCDResInfo to BIOS value */
1463 if(temp == Panel_1280x768_2) temp = Panel_1280x768; 1438 switch(temp) {
1464 if(temp == Panel_1280x800_2) temp = Panel_1280x800; 1439 case Panel_1280x768_2: temp = Panel_1280x768; break;
1440 case Panel_1280x800_2: temp = Panel_1280x800; break;
1441 case Panel_1280x854: temp = Panel661_1280x854; break;
1442 }
1465 return temp; 1443 return temp;
1466} 1444}
1467 1445
1468static void 1446static void
1469SiS_GetLCDInfoBIOS(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 1447SiS_GetLCDInfoBIOS(struct SiS_Private *SiS_Pr)
1470{ 1448{
1471#ifdef SIS315H 1449#ifdef SIS315H
1472 UCHAR *ROMAddr; 1450 unsigned char *ROMAddr;
1473 USHORT temp; 1451 unsigned short temp;
1474 1452
1453#ifdef SIS_XORG_XF86
1475#ifdef TWDEBUG 1454#ifdef TWDEBUG
1476 xf86DrvMsg(0, X_INFO, "Paneldata driver: [%d %d] [H %d %d] [V %d %d] [C %d 0x%02x 0x%02x]\n", 1455 xf86DrvMsg(0, X_INFO, "Paneldata driver: [%d %d] [H %d %d] [V %d %d] [C %d 0x%02x 0x%02x]\n",
1477 SiS_Pr->PanelHT, SiS_Pr->PanelVT, 1456 SiS_Pr->PanelHT, SiS_Pr->PanelVT,
1478 SiS_Pr->PanelHRS, SiS_Pr->PanelHRE, 1457 SiS_Pr->PanelHRS, SiS_Pr->PanelHRE,
1479 SiS_Pr->PanelVRS, SiS_Pr->PanelVRE, 1458 SiS_Pr->PanelVRS, SiS_Pr->PanelVRE,
1480 SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].CLOCK, 1459 SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].CLOCK,
1481 SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].Part4_A, 1460 SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].Part4_A,
1482 SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].Part4_B); 1461 SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].Part4_B);
1483#endif 1462#endif
1463#endif
1484 1464
1485 if((ROMAddr = GetLCDStructPtr661(SiS_Pr, HwInfo))) { 1465 if((ROMAddr = GetLCDStructPtr661(SiS_Pr))) {
1486 if((temp = SISGETROMW(6)) != SiS_Pr->PanelHT) { 1466 if((temp = SISGETROMW(6)) != SiS_Pr->PanelHT) {
1487 SiS_Pr->SiS_NeedRomModeData = TRUE; 1467 SiS_Pr->SiS_NeedRomModeData = TRUE;
1488 SiS_Pr->PanelHT = temp; 1468 SiS_Pr->PanelHT = temp;
1489 } 1469 }
1490 if((temp = SISGETROMW(8)) != SiS_Pr->PanelVT) { 1470 if((temp = SISGETROMW(8)) != SiS_Pr->PanelVT) {
1491 SiS_Pr->SiS_NeedRomModeData = TRUE; 1471 SiS_Pr->SiS_NeedRomModeData = TRUE;
1492 SiS_Pr->PanelVT = temp; 1472 SiS_Pr->PanelVT = temp;
1493 } 1473 }
1494 SiS_Pr->PanelHRS = SISGETROMW(10); 1474 SiS_Pr->PanelHRS = SISGETROMW(10);
1495 SiS_Pr->PanelHRE = SISGETROMW(12); 1475 SiS_Pr->PanelHRE = SISGETROMW(12);
@@ -1497,56 +1477,58 @@ SiS_GetLCDInfoBIOS(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
1497 SiS_Pr->PanelVRE = SISGETROMW(16); 1477 SiS_Pr->PanelVRE = SISGETROMW(16);
1498 SiS_Pr->PanelVCLKIdx315 = VCLK_CUSTOM_315; 1478 SiS_Pr->PanelVCLKIdx315 = VCLK_CUSTOM_315;
1499 SiS_Pr->SiS_VCLKData[VCLK_CUSTOM_315].CLOCK = 1479 SiS_Pr->SiS_VCLKData[VCLK_CUSTOM_315].CLOCK =
1500 SiS_Pr->SiS_VBVCLKData[VCLK_CUSTOM_315].CLOCK = (USHORT)((UCHAR)ROMAddr[18]); 1480 SiS_Pr->SiS_VBVCLKData[VCLK_CUSTOM_315].CLOCK = (unsigned short)((unsigned char)ROMAddr[18]);
1501 SiS_Pr->SiS_VCLKData[VCLK_CUSTOM_315].SR2B = 1481 SiS_Pr->SiS_VCLKData[VCLK_CUSTOM_315].SR2B =
1502 SiS_Pr->SiS_VBVCLKData[VCLK_CUSTOM_315].Part4_A = ROMAddr[19]; 1482 SiS_Pr->SiS_VBVCLKData[VCLK_CUSTOM_315].Part4_A = ROMAddr[19];
1503 SiS_Pr->SiS_VCLKData[VCLK_CUSTOM_315].SR2C = 1483 SiS_Pr->SiS_VCLKData[VCLK_CUSTOM_315].SR2C =
1504 SiS_Pr->SiS_VBVCLKData[VCLK_CUSTOM_315].Part4_B = ROMAddr[20]; 1484 SiS_Pr->SiS_VBVCLKData[VCLK_CUSTOM_315].Part4_B = ROMAddr[20];
1505 1485
1486#ifdef SIS_XORG_XF86
1506#ifdef TWDEBUG 1487#ifdef TWDEBUG
1507 xf86DrvMsg(0, X_INFO, "Paneldata BIOS: [%d %d] [H %d %d] [V %d %d] [C %d 0x%02x 0x%02x]\n", 1488 xf86DrvMsg(0, X_INFO, "Paneldata BIOS: [%d %d] [H %d %d] [V %d %d] [C %d 0x%02x 0x%02x]\n",
1508 SiS_Pr->PanelHT, SiS_Pr->PanelVT, 1489 SiS_Pr->PanelHT, SiS_Pr->PanelVT,
1509 SiS_Pr->PanelHRS, SiS_Pr->PanelHRE, 1490 SiS_Pr->PanelHRS, SiS_Pr->PanelHRE,
1510 SiS_Pr->PanelVRS, SiS_Pr->PanelVRE, 1491 SiS_Pr->PanelVRS, SiS_Pr->PanelVRE,
1511 SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].CLOCK, 1492 SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].CLOCK,
1512 SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].Part4_A, 1493 SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].Part4_A,
1513 SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].Part4_B); 1494 SiS_Pr->SiS_VBVCLKData[SiS_Pr->PanelVCLKIdx315].Part4_B);
1514#endif 1495#endif
1496#endif
1515 1497
1516 } 1498 }
1517#endif 1499#endif
1518} 1500}
1519 1501
1520static void 1502static void
1521SiS_CheckScaling(SiS_Private *SiS_Pr, USHORT resinfo, const UCHAR *nonscalingmodes) 1503SiS_CheckScaling(struct SiS_Private *SiS_Pr, unsigned short resinfo,
1522{ 1504 const unsigned char *nonscalingmodes)
1523 int i = 0; 1505{
1524 while(nonscalingmodes[i] != 0xff) { 1506 int i = 0;
1525 if(nonscalingmodes[i++] == resinfo) { 1507 while(nonscalingmodes[i] != 0xff) {
1526 if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) || 1508 if(nonscalingmodes[i++] == resinfo) {
1527 (SiS_Pr->UsePanelScaler == -1)) { 1509 if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) ||
1528 SiS_Pr->SiS_LCDInfo |= DontExpandLCD; 1510 (SiS_Pr->UsePanelScaler == -1)) {
1529 } 1511 SiS_Pr->SiS_LCDInfo |= DontExpandLCD;
1530 break; 1512 }
1531 } 1513 break;
1532 } 1514 }
1515 }
1533} 1516}
1534 1517
1535void 1518void
1536SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, 1519SiS_GetLCDResInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex)
1537 PSIS_HW_INFO HwInfo)
1538{ 1520{
1521 unsigned short temp,modeflag,resinfo=0,modexres=0,modeyres=0;
1522 BOOLEAN panelcanscale = FALSE;
1539#ifdef SIS300 1523#ifdef SIS300
1540 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; 1524 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
1541 const unsigned char SiS300SeriesLCDRes[] = 1525 static const unsigned char SiS300SeriesLCDRes[] =
1542 { 0, 1, 2, 3, 7, 4, 5, 8, 1526 { 0, 1, 2, 3, 7, 4, 5, 8,
1543 0, 0, 10, 0, 0, 0, 0, 15 }; 1527 0, 0, 10, 0, 0, 0, 0, 15 };
1544#endif 1528#endif
1545#ifdef SIS315H 1529#ifdef SIS315H
1546 UCHAR *myptr = NULL; 1530 unsigned char *myptr = NULL;
1547#endif 1531#endif
1548 USHORT temp,modeflag,resinfo=0,modexres=0,modeyres=0;
1549 BOOLEAN panelcanscale = FALSE;
1550 1532
1551 SiS_Pr->SiS_LCDResInfo = 0; 1533 SiS_Pr->SiS_LCDResInfo = 0;
1552 SiS_Pr->SiS_LCDTypeInfo = 0; 1534 SiS_Pr->SiS_LCDTypeInfo = 0;
@@ -1557,14 +1539,14 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
1557 SiS_Pr->PanelVRE = 999; /* VSync end */ 1539 SiS_Pr->PanelVRE = 999; /* VSync end */
1558 SiS_Pr->SiS_NeedRomModeData = FALSE; 1540 SiS_Pr->SiS_NeedRomModeData = FALSE;
1559 1541
1542 /* Alternative 1600x1200@60 timing for 1600x1200 LCDA */
1543 SiS_Pr->Alternate1600x1200 = FALSE;
1544
1560 if(!(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))) return; 1545 if(!(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))) return;
1561 1546
1562 if(ModeNo <= 0x13) { 1547 modeflag = SiS_GetModeFlag(SiS_Pr, ModeNo, ModeIdIndex);
1563 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; 1548
1564 } else if(SiS_Pr->UseCustomMode) { 1549 if((ModeNo > 0x13) && (!SiS_Pr->UseCustomMode)) {
1565 modeflag = SiS_Pr->CModeFlag;
1566 } else {
1567 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1568 resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; 1550 resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
1569 modexres = SiS_Pr->SiS_ModeResInfo[resinfo].HTotal; 1551 modexres = SiS_Pr->SiS_ModeResInfo[resinfo].HTotal;
1570 modeyres = SiS_Pr->SiS_ModeResInfo[resinfo].VTotal; 1552 modeyres = SiS_Pr->SiS_ModeResInfo[resinfo].VTotal;
@@ -1575,16 +1557,16 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
1575 /* For broken BIOSes: Assume 1024x768 */ 1557 /* For broken BIOSes: Assume 1024x768 */
1576 if(temp == 0) temp = 0x02; 1558 if(temp == 0) temp = 0x02;
1577 1559
1578 if((HwInfo->jChipType >= SIS_661) || (SiS_Pr->SiS_ROMNew)) { 1560 if((SiS_Pr->ChipType >= SIS_661) || (SiS_Pr->SiS_ROMNew)) {
1579 SiS_Pr->SiS_LCDTypeInfo = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x39) & 0x7c) >> 2; 1561 SiS_Pr->SiS_LCDTypeInfo = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x39) & 0x7c) >> 2;
1580 } else if((HwInfo->jChipType < SIS_315H) || (HwInfo->jChipType >= SIS_661)) { 1562 } else if((SiS_Pr->ChipType < SIS_315H) || (SiS_Pr->ChipType >= SIS_661)) {
1581 SiS_Pr->SiS_LCDTypeInfo = temp >> 4; 1563 SiS_Pr->SiS_LCDTypeInfo = temp >> 4;
1582 } else { 1564 } else {
1583 SiS_Pr->SiS_LCDTypeInfo = (temp & 0x0F) - 1; 1565 SiS_Pr->SiS_LCDTypeInfo = (temp & 0x0F) - 1;
1584 } 1566 }
1585 temp &= 0x0f; 1567 temp &= 0x0f;
1586#ifdef SIS300 1568#ifdef SIS300
1587 if(HwInfo->jChipType < SIS_315H) { 1569 if(SiS_Pr->ChipType < SIS_315H) {
1588 /* Very old BIOSes only know 7 sizes (NetVista 2179, 1.01g) */ 1570 /* Very old BIOSes only know 7 sizes (NetVista 2179, 1.01g) */
1589 if(SiS_Pr->SiS_VBType & VB_SIS301) { 1571 if(SiS_Pr->SiS_VBType & VB_SIS301) {
1590 if(temp < 0x0f) temp &= 0x07; 1572 if(temp < 0x0f) temp &= 0x07;
@@ -1595,17 +1577,22 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
1595#endif 1577#endif
1596 1578
1597 /* Translate to our internal types */ 1579 /* Translate to our internal types */
1598 if(HwInfo->jChipType == SIS_550) { 1580#ifdef SIS315H
1599 if(temp == Panel310_640x480_2) temp = Panel_640x480_2; 1581 if(SiS_Pr->ChipType == SIS_550) {
1600 if(temp == Panel310_640x480_3) temp = Panel_640x480_3; 1582 if (temp == Panel310_1152x768) temp = Panel_320x240_2; /* Verified working */
1583 else if(temp == Panel310_320x240_2) temp = Panel_320x240_2;
1584 else if(temp == Panel310_320x240_3) temp = Panel_320x240_3;
1585 } else if(SiS_Pr->ChipType >= SIS_661) {
1586 if(temp == Panel661_1280x854) temp = Panel_1280x854;
1601 } 1587 }
1588#endif
1602 1589
1603 if(SiS_Pr->SiS_VBType & VB_SISLVDS) { /* SiS LVDS */ 1590 if(SiS_Pr->SiS_VBType & VB_SISLVDS) { /* SiS LVDS */
1604 if(temp == Panel310_1280x768) { 1591 if(temp == Panel310_1280x768) {
1605 temp = Panel_1280x768_2; 1592 temp = Panel_1280x768_2;
1606 } 1593 }
1607 if(SiS_Pr->SiS_ROMNew) { 1594 if(SiS_Pr->SiS_ROMNew) {
1608 if(temp == Panel661_1280x800) { 1595 if(temp == Panel661_1280x800) {
1609 temp = Panel_1280x800_2; 1596 temp = Panel_1280x800_2;
1610 } 1597 }
1611 } 1598 }
@@ -1613,13 +1600,17 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
1613 1600
1614 SiS_Pr->SiS_LCDResInfo = temp; 1601 SiS_Pr->SiS_LCDResInfo = temp;
1615 1602
1603#ifdef SIS300
1616 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { 1604 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
1617 if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) { 1605 if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) {
1618 SiS_Pr->SiS_LCDResInfo = Panel_Barco1366; 1606 SiS_Pr->SiS_LCDResInfo = Panel_Barco1366;
1619 } else if(SiS_Pr->SiS_CustomT == CUT_PANEL848) { 1607 } else if(SiS_Pr->SiS_CustomT == CUT_PANEL848) {
1620 SiS_Pr->SiS_LCDResInfo = Panel_848x480; 1608 SiS_Pr->SiS_LCDResInfo = Panel_848x480;
1609 } else if(SiS_Pr->SiS_CustomT == CUT_PANEL856) {
1610 SiS_Pr->SiS_LCDResInfo = Panel_856x480;
1621 } 1611 }
1622 } 1612 }
1613#endif
1623 1614
1624 if(SiS_Pr->SiS_VBType & VB_SISVB) { 1615 if(SiS_Pr->SiS_VBType & VB_SISVB) {
1625 if(SiS_Pr->SiS_LCDResInfo < SiS_Pr->SiS_PanelMin301) 1616 if(SiS_Pr->SiS_LCDResInfo < SiS_Pr->SiS_PanelMin301)
@@ -1633,10 +1624,16 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
1633 SiS_Pr->SiS_LCDInfo = temp & ~0x000e; 1624 SiS_Pr->SiS_LCDInfo = temp & ~0x000e;
1634 /* Need temp below! */ 1625 /* Need temp below! */
1635 1626
1636 /* These can't scale no matter what */ 1627 /* These must/can't scale no matter what */
1637 switch(SiS_Pr->SiS_LCDResInfo) { 1628 switch(SiS_Pr->SiS_LCDResInfo) {
1629 case Panel_320x240_1:
1630 case Panel_320x240_2:
1631 case Panel_320x240_3:
1638 case Panel_1280x960: 1632 case Panel_1280x960:
1639 SiS_Pr->SiS_LCDInfo &= ~DontExpandLCD; 1633 SiS_Pr->SiS_LCDInfo &= ~DontExpandLCD;
1634 break;
1635 case Panel_640x480:
1636 SiS_Pr->SiS_LCDInfo |= DontExpandLCD;
1640 } 1637 }
1641 1638
1642 panelcanscale = (SiS_Pr->SiS_LCDInfo & DontExpandLCD) ? TRUE : FALSE; 1639 panelcanscale = (SiS_Pr->SiS_LCDInfo & DontExpandLCD) ? TRUE : FALSE;
@@ -1646,41 +1643,41 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
1646 1643
1647 /* Dual link, Pass 1:1 BIOS default, etc. */ 1644 /* Dual link, Pass 1:1 BIOS default, etc. */
1648#ifdef SIS315H 1645#ifdef SIS315H
1649 if(HwInfo->jChipType >= SIS_661) { 1646 if(SiS_Pr->ChipType >= SIS_661) {
1650 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { 1647 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
1651 if(temp & 0x08) SiS_Pr->SiS_LCDInfo |= LCDPass11; 1648 if(temp & 0x08) SiS_Pr->SiS_LCDInfo |= LCDPass11;
1652 } 1649 }
1653 if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { 1650 if(SiS_Pr->SiS_VBType & VB_SISDUALLINK) {
1654 if(SiS_Pr->SiS_ROMNew) { 1651 if(SiS_Pr->SiS_ROMNew) {
1655 if(temp & 0x02) SiS_Pr->SiS_LCDInfo |= LCDDualLink; 1652 if(temp & 0x02) SiS_Pr->SiS_LCDInfo |= LCDDualLink;
1656 } else if((myptr = GetLCDStructPtr661(SiS_Pr, HwInfo))) { 1653 } else if((myptr = GetLCDStructPtr661(SiS_Pr))) {
1657 if(myptr[2] & 0x01) SiS_Pr->SiS_LCDInfo |= LCDDualLink; 1654 if(myptr[2] & 0x01) SiS_Pr->SiS_LCDInfo |= LCDDualLink;
1658 } 1655 }
1659 } 1656 }
1660 } else if(HwInfo->jChipType >= SIS_315H) { 1657 } else if(SiS_Pr->ChipType >= SIS_315H) {
1661 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { 1658 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
1662 if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x39) & 0x01) SiS_Pr->SiS_LCDInfo |= LCDPass11; 1659 if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x39) & 0x01) SiS_Pr->SiS_LCDInfo |= LCDPass11;
1663 } 1660 }
1664 if((SiS_Pr->SiS_ROMNew) && (!(SiS_Pr->PanelSelfDetected))) { 1661 if((SiS_Pr->SiS_ROMNew) && (!(SiS_Pr->PanelSelfDetected))) {
1665 SiS_Pr->SiS_LCDInfo &= ~(LCDRGB18Bit); 1662 SiS_Pr->SiS_LCDInfo &= ~(LCDRGB18Bit);
1666 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35); 1663 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x35);
1667 if(temp & 0x01) SiS_Pr->SiS_LCDInfo |= LCDRGB18Bit; 1664 if(temp & 0x01) SiS_Pr->SiS_LCDInfo |= LCDRGB18Bit;
1668 if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { 1665 if(SiS_Pr->SiS_VBType & VB_SISDUALLINK) {
1669 if(temp & 0x02) SiS_Pr->SiS_LCDInfo |= LCDDualLink; 1666 if(temp & 0x02) SiS_Pr->SiS_LCDInfo |= LCDDualLink;
1670 } 1667 }
1671 } else if(!(SiS_Pr->SiS_ROMNew)) { 1668 } else if(!(SiS_Pr->SiS_ROMNew)) {
1672 if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { 1669 if(SiS_Pr->SiS_VBType & VB_SISDUALLINK) {
1673 if((SiS_Pr->SiS_CustomT == CUT_CLEVO1024) && 1670 if((SiS_Pr->SiS_CustomT == CUT_CLEVO1024) &&
1674 (SiS_Pr->SiS_LCDResInfo == Panel_1024x768)) { 1671 (SiS_Pr->SiS_LCDResInfo == Panel_1024x768)) {
1675 SiS_Pr->SiS_LCDInfo |= LCDDualLink; 1672 SiS_Pr->SiS_LCDInfo |= LCDDualLink;
1676 } 1673 }
1677 if((SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) || 1674 if((SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) ||
1678 (SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) || 1675 (SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) ||
1679 (SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) || 1676 (SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) ||
1680 (SiS_Pr->SiS_LCDResInfo == Panel_1680x1050)) { 1677 (SiS_Pr->SiS_LCDResInfo == Panel_1680x1050)) {
1681 SiS_Pr->SiS_LCDInfo |= LCDDualLink; 1678 SiS_Pr->SiS_LCDInfo |= LCDDualLink;
1682 } 1679 }
1683 } 1680 }
1684 } 1681 }
1685 } 1682 }
1686#endif 1683#endif
@@ -1691,12 +1688,12 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
1691 SiS_Pr->SiS_LCDInfo &= ~LCDPass11; 1688 SiS_Pr->SiS_LCDInfo &= ~LCDPass11;
1692 } else if(SiS_Pr->SiS_VBType & VB_SISVB) { 1689 } else if(SiS_Pr->SiS_VBType & VB_SISVB) {
1693 if(SiS_Pr->SiS_VBType & VB_SISLVDS) { 1690 if(SiS_Pr->SiS_VBType & VB_SISLVDS) {
1694 /* Always center screen on SiS LVDS (if scaling is disabled) */ 1691 /* Always center screen on SiS LVDS (if scaling is disabled) */
1695 SiS_Pr->SiS_LCDInfo &= ~LCDPass11; 1692 SiS_Pr->SiS_LCDInfo &= ~LCDPass11;
1696 } else { 1693 } else {
1697 /* By default, pass 1:1 on SiS TMDS (if scaling is supported) */ 1694 /* By default, pass 1:1 on SiS TMDS (if scaling is supported) */
1698 if(panelcanscale) SiS_Pr->SiS_LCDInfo |= LCDPass11; 1695 if(panelcanscale) SiS_Pr->SiS_LCDInfo |= LCDPass11;
1699 if(SiS_Pr->CenterScreen == 1) SiS_Pr->SiS_LCDInfo &= ~LCDPass11; 1696 if(SiS_Pr->CenterScreen == 1) SiS_Pr->SiS_LCDInfo &= ~LCDPass11;
1700 } 1697 }
1701 } 1698 }
1702 1699
@@ -1704,19 +1701,15 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
1704 SiS_Pr->PanelVCLKIdx315 = VCLK108_2_315; 1701 SiS_Pr->PanelVCLKIdx315 = VCLK108_2_315;
1705 1702
1706 switch(SiS_Pr->SiS_LCDResInfo) { 1703 switch(SiS_Pr->SiS_LCDResInfo) {
1707 case Panel_320x480: SiS_Pr->PanelXRes = 320; SiS_Pr->PanelYRes = 480; 1704 case Panel_320x240_1:
1708 SiS_Pr->PanelHT = 400; SiS_Pr->PanelVT = 525; 1705 case Panel_320x240_2:
1709 SiS_Pr->PanelVCLKIdx300 = VCLK28; 1706 case Panel_320x240_3: SiS_Pr->PanelXRes = 640; SiS_Pr->PanelYRes = 480;
1710 SiS_Pr->PanelVCLKIdx315 = VCLK28; 1707 SiS_Pr->PanelVRS = 24; SiS_Pr->PanelVRE = 3;
1711 break;
1712 case Panel_640x480_2:
1713 case Panel_640x480_3: SiS_Pr->PanelXRes = 640; SiS_Pr->PanelYRes = 480;
1714 SiS_Pr->PanelVRS = 24; SiS_Pr->PanelVRE = 3;
1715 SiS_Pr->PanelVCLKIdx300 = VCLK28; 1708 SiS_Pr->PanelVCLKIdx300 = VCLK28;
1716 SiS_Pr->PanelVCLKIdx315 = VCLK28; 1709 SiS_Pr->PanelVCLKIdx315 = VCLK28;
1717 break; 1710 break;
1718 case Panel_640x480: SiS_Pr->PanelXRes = 640; SiS_Pr->PanelYRes = 480; 1711 case Panel_640x480: SiS_Pr->PanelXRes = 640; SiS_Pr->PanelYRes = 480;
1719 SiS_Pr->PanelVRE = 3; 1712 SiS_Pr->PanelVRE = 3;
1720 SiS_Pr->PanelVCLKIdx300 = VCLK28; 1713 SiS_Pr->PanelVCLKIdx300 = VCLK28;
1721 SiS_Pr->PanelVCLKIdx315 = VCLK28; 1714 SiS_Pr->PanelVCLKIdx315 = VCLK28;
1722 break; 1715 break;
@@ -1728,52 +1721,52 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
1728 SiS_Pr->PanelVCLKIdx315 = VCLK40; 1721 SiS_Pr->PanelVCLKIdx315 = VCLK40;
1729 break; 1722 break;
1730 case Panel_1024x600: SiS_Pr->PanelXRes = 1024; SiS_Pr->PanelYRes = 600; 1723 case Panel_1024x600: SiS_Pr->PanelXRes = 1024; SiS_Pr->PanelYRes = 600;
1731 SiS_Pr->PanelHT = 1344; SiS_Pr->PanelVT = 800; 1724 SiS_Pr->PanelHT = 1344; SiS_Pr->PanelVT = 800;
1732 SiS_Pr->PanelHRS = 24; SiS_Pr->PanelHRE = 136; 1725 SiS_Pr->PanelHRS = 24; SiS_Pr->PanelHRE = 136;
1733 SiS_Pr->PanelVRS = 2 /* 88 */ ; SiS_Pr->PanelVRE = 6; 1726 SiS_Pr->PanelVRS = 2 /* 88 */ ; SiS_Pr->PanelVRE = 6;
1734 SiS_Pr->PanelVCLKIdx300 = VCLK65_300; 1727 SiS_Pr->PanelVCLKIdx300 = VCLK65_300;
1735 SiS_Pr->PanelVCLKIdx315 = VCLK65_315; 1728 SiS_Pr->PanelVCLKIdx315 = VCLK65_315;
1736 break; 1729 break;
1737 case Panel_1024x768: SiS_Pr->PanelXRes = 1024; SiS_Pr->PanelYRes = 768; 1730 case Panel_1024x768: SiS_Pr->PanelXRes = 1024; SiS_Pr->PanelYRes = 768;
1738 SiS_Pr->PanelHT = 1344; SiS_Pr->PanelVT = 806; 1731 SiS_Pr->PanelHT = 1344; SiS_Pr->PanelVT = 806;
1739 SiS_Pr->PanelHRS = 24; SiS_Pr->PanelHRE = 136; 1732 SiS_Pr->PanelHRS = 24; SiS_Pr->PanelHRE = 136;
1740 SiS_Pr->PanelVRS = 3; SiS_Pr->PanelVRE = 6; 1733 SiS_Pr->PanelVRS = 3; SiS_Pr->PanelVRE = 6;
1741 if(HwInfo->jChipType < SIS_315H) { 1734 if(SiS_Pr->ChipType < SIS_315H) {
1742 SiS_Pr->PanelHRS = 23; 1735 SiS_Pr->PanelHRS = 23;
1743 SiS_Pr->PanelVRE = 5; 1736 SiS_Pr->PanelVRE = 5;
1744 } 1737 }
1745 SiS_Pr->PanelVCLKIdx300 = VCLK65_300; 1738 SiS_Pr->PanelVCLKIdx300 = VCLK65_300;
1746 SiS_Pr->PanelVCLKIdx315 = VCLK65_315; 1739 SiS_Pr->PanelVCLKIdx315 = VCLK65_315;
1747 SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo); 1740 SiS_GetLCDInfoBIOS(SiS_Pr);
1748 break; 1741 break;
1749 case Panel_1152x768: SiS_Pr->PanelXRes = 1152; SiS_Pr->PanelYRes = 768; 1742 case Panel_1152x768: SiS_Pr->PanelXRes = 1152; SiS_Pr->PanelYRes = 768;
1750 SiS_Pr->PanelHT = 1344; SiS_Pr->PanelVT = 806; 1743 SiS_Pr->PanelHT = 1344; SiS_Pr->PanelVT = 806;
1751 SiS_Pr->PanelHRS = 24; 1744 SiS_Pr->PanelHRS = 24; SiS_Pr->PanelHRE = 136;
1752 SiS_Pr->PanelVRS = 3; SiS_Pr->PanelVRE = 6; 1745 SiS_Pr->PanelVRS = 3; SiS_Pr->PanelVRE = 6;
1753 if(HwInfo->jChipType < SIS_315H) { 1746 if(SiS_Pr->ChipType < SIS_315H) {
1754 SiS_Pr->PanelHRS = 23; 1747 SiS_Pr->PanelHRS = 23;
1755 SiS_Pr->PanelVRE = 5; 1748 SiS_Pr->PanelVRE = 5;
1756 } 1749 }
1757 SiS_Pr->PanelVCLKIdx300 = VCLK65_300; 1750 SiS_Pr->PanelVCLKIdx300 = VCLK65_300;
1758 SiS_Pr->PanelVCLKIdx315 = VCLK65_315; 1751 SiS_Pr->PanelVCLKIdx315 = VCLK65_315;
1759 break; 1752 break;
1760 case Panel_1152x864: SiS_Pr->PanelXRes = 1152; SiS_Pr->PanelYRes = 864; 1753 case Panel_1152x864: SiS_Pr->PanelXRes = 1152; SiS_Pr->PanelYRes = 864;
1761 break; 1754 break;
1762 case Panel_1280x720: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 720; 1755 case Panel_1280x720: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 720;
1763 SiS_Pr->PanelHT = 1650; SiS_Pr->PanelVT = 750; 1756 SiS_Pr->PanelHT = 1650; SiS_Pr->PanelVT = 750;
1764 SiS_Pr->PanelHRS = 110; SiS_Pr->PanelHRE = 40; 1757 SiS_Pr->PanelHRS = 110; SiS_Pr->PanelHRE = 40;
1765 SiS_Pr->PanelVRS = 5; SiS_Pr->PanelVRE = 5; 1758 SiS_Pr->PanelVRS = 5; SiS_Pr->PanelVRE = 5;
1766 SiS_Pr->PanelVCLKIdx315 = VCLK_1280x720; 1759 SiS_Pr->PanelVCLKIdx315 = VCLK_1280x720;
1767 /* Data above for TMDS (projector); get from BIOS for LVDS */ 1760 /* Data above for TMDS (projector); get from BIOS for LVDS */
1768 SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo); 1761 SiS_GetLCDInfoBIOS(SiS_Pr);
1769 break; 1762 break;
1770 case Panel_1280x768: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 768; 1763 case Panel_1280x768: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 768;
1771 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { 1764 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
1772 SiS_Pr->PanelHT = 1408; SiS_Pr->PanelVT = 806; 1765 SiS_Pr->PanelHT = 1408; SiS_Pr->PanelVT = 806;
1773 SiS_Pr->PanelVCLKIdx300 = VCLK81_300; /* ? */ 1766 SiS_Pr->PanelVCLKIdx300 = VCLK81_300; /* ? */
1774 SiS_Pr->PanelVCLKIdx315 = VCLK81_315; /* ? */ 1767 SiS_Pr->PanelVCLKIdx315 = VCLK81_315; /* ? */
1775 } else { 1768 } else {
1776 SiS_Pr->PanelHT = 1688; SiS_Pr->PanelVT = 802; 1769 SiS_Pr->PanelHT = 1688; SiS_Pr->PanelVT = 802;
1777 SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRS = 112; 1770 SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRS = 112;
1778 SiS_Pr->PanelVRS = 3; SiS_Pr->PanelVRE = 6; 1771 SiS_Pr->PanelVRS = 3; SiS_Pr->PanelVRE = 6;
1779 SiS_Pr->PanelVCLKIdx300 = VCLK81_300; 1772 SiS_Pr->PanelVCLKIdx300 = VCLK81_300;
@@ -1781,77 +1774,100 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
1781 } 1774 }
1782 break; 1775 break;
1783 case Panel_1280x768_2: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 768; 1776 case Panel_1280x768_2: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 768;
1784 SiS_Pr->PanelHT = 1660; SiS_Pr->PanelVT = 806; 1777 SiS_Pr->PanelHT = 1660; SiS_Pr->PanelVT = 806;
1785 SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRE = 112; 1778 SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRE = 112;
1786 SiS_Pr->PanelVRS = 3; SiS_Pr->PanelVRE = 6; 1779 SiS_Pr->PanelVRS = 3; SiS_Pr->PanelVRE = 6;
1787 SiS_Pr->PanelVCLKIdx315 = VCLK_1280x768_2; 1780 SiS_Pr->PanelVCLKIdx315 = VCLK_1280x768_2;
1788 SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo); 1781 SiS_GetLCDInfoBIOS(SiS_Pr);
1789 break; 1782 break;
1790 case Panel_1280x800: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 800; 1783 case Panel_1280x800: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 800;
1791 SiS_Pr->PanelHT = 1408; SiS_Pr->PanelVT = 816; 1784 SiS_Pr->PanelHT = 1408; SiS_Pr->PanelVT = 816;
1792 SiS_Pr->PanelHRS = 21; SiS_Pr->PanelHRE = 24; 1785 SiS_Pr->PanelHRS = 21; SiS_Pr->PanelHRE = 24;
1793 SiS_Pr->PanelVRS = 4; SiS_Pr->PanelVRE = 3; 1786 SiS_Pr->PanelVRS = 4; SiS_Pr->PanelVRE = 3;
1794 SiS_Pr->PanelVCLKIdx315 = VCLK_1280x800_315; 1787 SiS_Pr->PanelVCLKIdx315 = VCLK_1280x800_315;
1795 SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo); 1788 SiS_GetLCDInfoBIOS(SiS_Pr);
1796 break; 1789 break;
1797 case Panel_1280x800_2: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 800; 1790 case Panel_1280x800_2: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 800;
1798 SiS_Pr->PanelHT = 1552; SiS_Pr->PanelVT = 812; 1791 SiS_Pr->PanelHT = 1552; SiS_Pr->PanelVT = 812;
1799 SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRE = 112; 1792 SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRE = 112;
1800 SiS_Pr->PanelVRS = 4; SiS_Pr->PanelVRE = 3; 1793 SiS_Pr->PanelVRS = 4; SiS_Pr->PanelVRE = 3;
1801 SiS_Pr->PanelVCLKIdx315 = VCLK_1280x800_315_2; 1794 SiS_Pr->PanelVCLKIdx315 = VCLK_1280x800_315_2;
1802 SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo); 1795 SiS_GetLCDInfoBIOS(SiS_Pr);
1796 break;
1797 case Panel_1280x854: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 854;
1798 SiS_Pr->PanelHT = 1664; SiS_Pr->PanelVT = 861;
1799 SiS_Pr->PanelHRS = 16; SiS_Pr->PanelHRE = 112;
1800 SiS_Pr->PanelVRS = 1; SiS_Pr->PanelVRE = 3;
1801 SiS_Pr->PanelVCLKIdx315 = VCLK_1280x854;
1802 SiS_GetLCDInfoBIOS(SiS_Pr);
1803 break; 1803 break;
1804 case Panel_1280x960: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 960; 1804 case Panel_1280x960: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 960;
1805 SiS_Pr->PanelHT = 1800; SiS_Pr->PanelVT = 1000; 1805 SiS_Pr->PanelHT = 1800; SiS_Pr->PanelVT = 1000;
1806 SiS_Pr->PanelVCLKIdx300 = VCLK108_3_300; 1806 SiS_Pr->PanelVCLKIdx300 = VCLK108_3_300;
1807 SiS_Pr->PanelVCLKIdx315 = VCLK108_3_315; 1807 SiS_Pr->PanelVCLKIdx315 = VCLK108_3_315;
1808 if(resinfo == SIS_RI_1280x1024) { 1808 if(resinfo == SIS_RI_1280x1024) {
1809 SiS_Pr->PanelVCLKIdx300 = VCLK100_300; 1809 SiS_Pr->PanelVCLKIdx300 = VCLK100_300;
1810 SiS_Pr->PanelVCLKIdx315 = VCLK100_315; 1810 SiS_Pr->PanelVCLKIdx315 = VCLK100_315;
1811 } 1811 }
1812 break; 1812 break;
1813 case Panel_1280x1024: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 1024; 1813 case Panel_1280x1024: SiS_Pr->PanelXRes = 1280; SiS_Pr->PanelYRes = 1024;
1814 SiS_Pr->PanelHT = 1688; SiS_Pr->PanelVT = 1066; 1814 SiS_Pr->PanelHT = 1688; SiS_Pr->PanelVT = 1066;
1815 SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRE = 112; 1815 SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRE = 112;
1816 SiS_Pr->PanelVRS = 1; SiS_Pr->PanelVRE = 3; 1816 SiS_Pr->PanelVRS = 1; SiS_Pr->PanelVRE = 3;
1817 SiS_Pr->PanelVCLKIdx300 = VCLK108_3_300; 1817 SiS_Pr->PanelVCLKIdx300 = VCLK108_3_300;
1818 SiS_Pr->PanelVCLKIdx315 = VCLK108_2_315; 1818 SiS_Pr->PanelVCLKIdx315 = VCLK108_2_315;
1819 SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo); 1819 SiS_GetLCDInfoBIOS(SiS_Pr);
1820 break; 1820 break;
1821 case Panel_1400x1050: SiS_Pr->PanelXRes = 1400; SiS_Pr->PanelYRes = 1050; 1821 case Panel_1400x1050: SiS_Pr->PanelXRes = 1400; SiS_Pr->PanelYRes = 1050;
1822 SiS_Pr->PanelHT = 1688; SiS_Pr->PanelVT = 1066; 1822 SiS_Pr->PanelHT = 1688; SiS_Pr->PanelVT = 1066;
1823 SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRE = 112; /* HRE OK for LVDS, not for LCDA */ 1823 SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRE = 112;
1824 SiS_Pr->PanelVRS = 1; SiS_Pr->PanelVRE = 3; 1824 SiS_Pr->PanelVRS = 1; SiS_Pr->PanelVRE = 3;
1825 SiS_Pr->PanelVCLKIdx315 = VCLK108_2_315; 1825 SiS_Pr->PanelVCLKIdx315 = VCLK108_2_315;
1826 SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo); 1826 SiS_GetLCDInfoBIOS(SiS_Pr);
1827 break; 1827 break;
1828 case Panel_1600x1200: SiS_Pr->PanelXRes = 1600; SiS_Pr->PanelYRes = 1200; 1828 case Panel_1600x1200: SiS_Pr->PanelXRes = 1600; SiS_Pr->PanelYRes = 1200;
1829 SiS_Pr->PanelHT = 2160; SiS_Pr->PanelVT = 1250; 1829 SiS_Pr->PanelHT = 2160; SiS_Pr->PanelVT = 1250;
1830 SiS_Pr->PanelHRS = 64; SiS_Pr->PanelHRE = 192; 1830 SiS_Pr->PanelHRS = 64; SiS_Pr->PanelHRE = 192;
1831 SiS_Pr->PanelVRS = 1; SiS_Pr->PanelVRE = 3; 1831 SiS_Pr->PanelVRS = 1; SiS_Pr->PanelVRE = 3;
1832 SiS_Pr->PanelVCLKIdx315 = VCLK162_315; 1832 SiS_Pr->PanelVCLKIdx315 = VCLK162_315;
1833 SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo); 1833 if(SiS_Pr->SiS_VBType & VB_SISTMDSLCDA) {
1834 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
1835 SiS_Pr->PanelHT = 1760; SiS_Pr->PanelVT = 1235;
1836 SiS_Pr->PanelHRS = 48; SiS_Pr->PanelHRE = 32;
1837 SiS_Pr->PanelVRS = 2; SiS_Pr->PanelVRE = 4;
1838 SiS_Pr->PanelVCLKIdx315 = VCLK130_315;
1839 SiS_Pr->Alternate1600x1200 = TRUE;
1840 }
1841 } else if(SiS_Pr->SiS_IF_DEF_LVDS) {
1842 SiS_Pr->PanelHT = 2048; SiS_Pr->PanelVT = 1320;
1843 SiS_Pr->PanelHRS = SiS_Pr->PanelHRE = 999;
1844 SiS_Pr->PanelVRS = SiS_Pr->PanelVRE = 999;
1845 }
1846 SiS_GetLCDInfoBIOS(SiS_Pr);
1834 break; 1847 break;
1835 case Panel_1680x1050: SiS_Pr->PanelXRes = 1680; SiS_Pr->PanelYRes = 1050; 1848 case Panel_1680x1050: SiS_Pr->PanelXRes = 1680; SiS_Pr->PanelYRes = 1050;
1836 SiS_Pr->PanelHT = 1900; SiS_Pr->PanelVT = 1066; 1849 SiS_Pr->PanelHT = 1900; SiS_Pr->PanelVT = 1066;
1837 SiS_Pr->PanelHRS = 26; SiS_Pr->PanelHRE = 76; 1850 SiS_Pr->PanelHRS = 26; SiS_Pr->PanelHRE = 76;
1838 SiS_Pr->PanelVRS = 3; SiS_Pr->PanelVRE = 6; 1851 SiS_Pr->PanelVRS = 3; SiS_Pr->PanelVRE = 6;
1839 SiS_Pr->PanelVCLKIdx315 = VCLK121_315; 1852 SiS_Pr->PanelVCLKIdx315 = VCLK121_315;
1840 SiS_GetLCDInfoBIOS(SiS_Pr, HwInfo); 1853 SiS_GetLCDInfoBIOS(SiS_Pr);
1841 break; 1854 break;
1842 case Panel_Barco1366: SiS_Pr->PanelXRes = 1360; SiS_Pr->PanelYRes = 1024; 1855 case Panel_Barco1366: SiS_Pr->PanelXRes = 1360; SiS_Pr->PanelYRes = 1024;
1843 SiS_Pr->PanelHT = 1688; SiS_Pr->PanelVT = 1066; 1856 SiS_Pr->PanelHT = 1688; SiS_Pr->PanelVT = 1066;
1844 break; 1857 break;
1845 case Panel_848x480: SiS_Pr->PanelXRes = 848; SiS_Pr->PanelYRes = 480; 1858 case Panel_848x480: SiS_Pr->PanelXRes = 848; SiS_Pr->PanelYRes = 480;
1846 SiS_Pr->PanelHT = 1088; SiS_Pr->PanelVT = 525; 1859 SiS_Pr->PanelHT = 1088; SiS_Pr->PanelVT = 525;
1847 break; 1860 break;
1861 case Panel_856x480: SiS_Pr->PanelXRes = 856; SiS_Pr->PanelYRes = 480;
1862 SiS_Pr->PanelHT = 1088; SiS_Pr->PanelVT = 525;
1863 break;
1848 case Panel_Custom: SiS_Pr->PanelXRes = SiS_Pr->CP_MaxX; 1864 case Panel_Custom: SiS_Pr->PanelXRes = SiS_Pr->CP_MaxX;
1849 SiS_Pr->PanelYRes = SiS_Pr->CP_MaxY; 1865 SiS_Pr->PanelYRes = SiS_Pr->CP_MaxY;
1850 SiS_Pr->PanelHT = SiS_Pr->CHTotal; 1866 SiS_Pr->PanelHT = SiS_Pr->CHTotal;
1851 SiS_Pr->PanelVT = SiS_Pr->CVTotal; 1867 SiS_Pr->PanelVT = SiS_Pr->CVTotal;
1852 if(SiS_Pr->CP_PreferredIndex != -1) { 1868 if(SiS_Pr->CP_PreferredIndex != -1) {
1853 SiS_Pr->PanelXRes = SiS_Pr->CP_HDisplay[SiS_Pr->CP_PreferredIndex]; 1869 SiS_Pr->PanelXRes = SiS_Pr->CP_HDisplay[SiS_Pr->CP_PreferredIndex];
1854 SiS_Pr->PanelYRes = SiS_Pr->CP_VDisplay[SiS_Pr->CP_PreferredIndex]; 1870 SiS_Pr->PanelYRes = SiS_Pr->CP_VDisplay[SiS_Pr->CP_PreferredIndex];
1855 SiS_Pr->PanelHT = SiS_Pr->CP_HTotal[SiS_Pr->CP_PreferredIndex]; 1871 SiS_Pr->PanelHT = SiS_Pr->CP_HTotal[SiS_Pr->CP_PreferredIndex];
1856 SiS_Pr->PanelVT = SiS_Pr->CP_VTotal[SiS_Pr->CP_PreferredIndex]; 1872 SiS_Pr->PanelVT = SiS_Pr->CP_VTotal[SiS_Pr->CP_PreferredIndex];
1857 SiS_Pr->PanelHRS = SiS_Pr->CP_HSyncStart[SiS_Pr->CP_PreferredIndex]; 1873 SiS_Pr->PanelHRS = SiS_Pr->CP_HSyncStart[SiS_Pr->CP_PreferredIndex];
@@ -1863,22 +1879,22 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
1863 SiS_Pr->PanelVRS -= SiS_Pr->PanelYRes; 1879 SiS_Pr->PanelVRS -= SiS_Pr->PanelYRes;
1864 SiS_Pr->PanelVRE -= SiS_Pr->PanelVRS; 1880 SiS_Pr->PanelVRE -= SiS_Pr->PanelVRS;
1865 if(SiS_Pr->CP_PrefClock) { 1881 if(SiS_Pr->CP_PrefClock) {
1866 int idx; 1882 int idx;
1867 SiS_Pr->PanelVCLKIdx315 = VCLK_CUSTOM_315; 1883 SiS_Pr->PanelVCLKIdx315 = VCLK_CUSTOM_315;
1868 SiS_Pr->PanelVCLKIdx300 = VCLK_CUSTOM_300; 1884 SiS_Pr->PanelVCLKIdx300 = VCLK_CUSTOM_300;
1869 if(HwInfo->jChipType < SIS_315H) idx = VCLK_CUSTOM_300; 1885 if(SiS_Pr->ChipType < SIS_315H) idx = VCLK_CUSTOM_300;
1870 else idx = VCLK_CUSTOM_315; 1886 else idx = VCLK_CUSTOM_315;
1871 SiS_Pr->SiS_VCLKData[idx].CLOCK = 1887 SiS_Pr->SiS_VCLKData[idx].CLOCK =
1872 SiS_Pr->SiS_VBVCLKData[idx].CLOCK = SiS_Pr->CP_PrefClock; 1888 SiS_Pr->SiS_VBVCLKData[idx].CLOCK = SiS_Pr->CP_PrefClock;
1873 SiS_Pr->SiS_VCLKData[idx].SR2B = 1889 SiS_Pr->SiS_VCLKData[idx].SR2B =
1874 SiS_Pr->SiS_VBVCLKData[idx].Part4_A = SiS_Pr->CP_PrefSR2B; 1890 SiS_Pr->SiS_VBVCLKData[idx].Part4_A = SiS_Pr->CP_PrefSR2B;
1875 SiS_Pr->SiS_VCLKData[idx].SR2C = 1891 SiS_Pr->SiS_VCLKData[idx].SR2C =
1876 SiS_Pr->SiS_VBVCLKData[idx].Part4_B = SiS_Pr->CP_PrefSR2C; 1892 SiS_Pr->SiS_VBVCLKData[idx].Part4_B = SiS_Pr->CP_PrefSR2C;
1877 } 1893 }
1878 } 1894 }
1879 break; 1895 break;
1880 default: SiS_Pr->PanelXRes = 1024; SiS_Pr->PanelYRes = 768; 1896 default: SiS_Pr->PanelXRes = 1024; SiS_Pr->PanelYRes = 768;
1881 SiS_Pr->PanelHT = 1344; SiS_Pr->PanelVT = 806; 1897 SiS_Pr->PanelHT = 1344; SiS_Pr->PanelVT = 806;
1882 break; 1898 break;
1883 } 1899 }
1884 1900
@@ -1887,14 +1903,16 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
1887 (SiS_Pr->SiS_IF_DEF_DSTN) || 1903 (SiS_Pr->SiS_IF_DEF_DSTN) ||
1888 (SiS_Pr->SiS_CustomT == CUT_BARCO1366) || 1904 (SiS_Pr->SiS_CustomT == CUT_BARCO1366) ||
1889 (SiS_Pr->SiS_CustomT == CUT_BARCO1024) || 1905 (SiS_Pr->SiS_CustomT == CUT_BARCO1024) ||
1890 (SiS_Pr->SiS_CustomT == CUT_PANEL848) ) { 1906 (SiS_Pr->SiS_CustomT == CUT_PANEL848) ||
1907 (SiS_Pr->SiS_CustomT == CUT_PANEL856) ) {
1891 SiS_Pr->PanelHRS = 999; 1908 SiS_Pr->PanelHRS = 999;
1892 SiS_Pr->PanelHRE = 999; 1909 SiS_Pr->PanelHRE = 999;
1893 } 1910 }
1894 1911
1895 if( (SiS_Pr->SiS_CustomT == CUT_BARCO1366) || 1912 if( (SiS_Pr->SiS_CustomT == CUT_BARCO1366) ||
1896 (SiS_Pr->SiS_CustomT == CUT_BARCO1024) || 1913 (SiS_Pr->SiS_CustomT == CUT_BARCO1024) ||
1897 (SiS_Pr->SiS_CustomT == CUT_PANEL848) ) { 1914 (SiS_Pr->SiS_CustomT == CUT_PANEL848) ||
1915 (SiS_Pr->SiS_CustomT == CUT_PANEL856) ) {
1898 SiS_Pr->PanelVRS = 999; 1916 SiS_Pr->PanelVRS = 999;
1899 SiS_Pr->PanelVRE = 999; 1917 SiS_Pr->PanelVRE = 999;
1900 } 1918 }
@@ -1912,18 +1930,18 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
1912 case Panel_Custom: 1930 case Panel_Custom:
1913 case Panel_1152x864: 1931 case Panel_1152x864:
1914 case Panel_1280x768: /* TMDS only */ 1932 case Panel_1280x768: /* TMDS only */
1915 SiS_Pr->SiS_LCDInfo |= DontExpandLCD; 1933 SiS_Pr->SiS_LCDInfo |= DontExpandLCD;
1916 break; 1934 break;
1917 1935
1918 case Panel_800x600: { 1936 case Panel_800x600: {
1919 static const UCHAR nonscalingmodes[] = { 1937 static const unsigned char nonscalingmodes[] = {
1920 SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, 0xff 1938 SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, 0xff
1921 }; 1939 };
1922 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); 1940 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes);
1923 break; 1941 break;
1924 } 1942 }
1925 case Panel_1024x768: { 1943 case Panel_1024x768: {
1926 static const UCHAR nonscalingmodes[] = { 1944 static const unsigned char nonscalingmodes[] = {
1927 SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, 1945 SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480,
1928 SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, 1946 SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600,
1929 0xff 1947 0xff
@@ -1932,7 +1950,7 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
1932 break; 1950 break;
1933 } 1951 }
1934 case Panel_1280x720: { 1952 case Panel_1280x720: {
1935 static const UCHAR nonscalingmodes[] = { 1953 static const unsigned char nonscalingmodes[] = {
1936 SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, 1954 SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480,
1937 SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, 1955 SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600,
1938 0xff 1956 0xff
@@ -1944,7 +1962,7 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
1944 break; 1962 break;
1945 } 1963 }
1946 case Panel_1280x768_2: { /* LVDS only */ 1964 case Panel_1280x768_2: { /* LVDS only */
1947 static const UCHAR nonscalingmodes[] = { 1965 static const unsigned char nonscalingmodes[] = {
1948 SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, 1966 SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480,
1949 SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, 1967 SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600,
1950 SIS_RI_1152x768,0xff 1968 SIS_RI_1152x768,0xff
@@ -1952,23 +1970,23 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
1952 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); 1970 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes);
1953 switch(resinfo) { 1971 switch(resinfo) {
1954 case SIS_RI_1280x720: if(SiS_Pr->UsePanelScaler == -1) { 1972 case SIS_RI_1280x720: if(SiS_Pr->UsePanelScaler == -1) {
1955 SiS_Pr->SiS_LCDInfo |= DontExpandLCD; 1973 SiS_Pr->SiS_LCDInfo |= DontExpandLCD;
1956 } 1974 }
1957 break; 1975 break;
1958 } 1976 }
1959 break; 1977 break;
1960 } 1978 }
1961 case Panel_1280x800: { /* SiS TMDS special (Averatec 6200 series) */ 1979 case Panel_1280x800: { /* SiS TMDS special (Averatec 6200 series) */
1962 static const UCHAR nonscalingmodes[] = { 1980 static const unsigned char nonscalingmodes[] = {
1963 SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, 1981 SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480,
1964 SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, 1982 SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600,
1965 SIS_RI_1152x768,SIS_RI_1280x720,SIS_RI_1280x768,0xff 1983 SIS_RI_1152x768,SIS_RI_1280x720,SIS_RI_1280x768,0xff
1966 }; 1984 };
1967 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); 1985 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes);
1968 break; 1986 break;
1969 } 1987 }
1970 case Panel_1280x800_2: { /* SiS LVDS */ 1988 case Panel_1280x800_2: { /* SiS LVDS */
1971 static const UCHAR nonscalingmodes[] = { 1989 static const unsigned char nonscalingmodes[] = {
1972 SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, 1990 SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480,
1973 SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, 1991 SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600,
1974 SIS_RI_1152x768,0xff 1992 SIS_RI_1152x768,0xff
@@ -1977,66 +1995,83 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
1977 switch(resinfo) { 1995 switch(resinfo) {
1978 case SIS_RI_1280x720: 1996 case SIS_RI_1280x720:
1979 case SIS_RI_1280x768: if(SiS_Pr->UsePanelScaler == -1) { 1997 case SIS_RI_1280x768: if(SiS_Pr->UsePanelScaler == -1) {
1980 SiS_Pr->SiS_LCDInfo |= DontExpandLCD; 1998 SiS_Pr->SiS_LCDInfo |= DontExpandLCD;
1981 } 1999 }
1982 break; 2000 break;
1983 } 2001 }
1984 break; 2002 break;
2003 }
2004 case Panel_1280x854: { /* SiS LVDS */
2005 static const unsigned char nonscalingmodes[] = {
2006 SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480,
2007 SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600,
2008 SIS_RI_1152x768,0xff
2009 };
2010 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes);
2011 switch(resinfo) {
2012 case SIS_RI_1280x720:
2013 case SIS_RI_1280x768:
2014 case SIS_RI_1280x800: if(SiS_Pr->UsePanelScaler == -1) {
2015 SiS_Pr->SiS_LCDInfo |= DontExpandLCD;
2016 }
2017 break;
2018 }
2019 break;
1985 } 2020 }
1986 case Panel_1280x960: { 2021 case Panel_1280x960: {
1987 static const UCHAR nonscalingmodes[] = { 2022 static const unsigned char nonscalingmodes[] = {
1988 SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, 2023 SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480,
1989 SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, 2024 SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600,
1990 SIS_RI_1152x768,SIS_RI_1152x864,SIS_RI_1280x720,SIS_RI_1280x768,SIS_RI_1280x800, 2025 SIS_RI_1152x768,SIS_RI_1152x864,SIS_RI_1280x720,SIS_RI_1280x768,SIS_RI_1280x800,
1991 0xff 2026 SIS_RI_1280x854,0xff
1992 }; 2027 };
1993 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); 2028 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes);
1994 break; 2029 break;
1995 } 2030 }
1996 case Panel_1280x1024: { 2031 case Panel_1280x1024: {
1997 static const UCHAR nonscalingmodes[] = { 2032 static const unsigned char nonscalingmodes[] = {
1998 SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, 2033 SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480,
1999 SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, 2034 SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600,
2000 SIS_RI_1152x768,SIS_RI_1152x864,SIS_RI_1280x720,SIS_RI_1280x768,SIS_RI_1280x800, 2035 SIS_RI_1152x768,SIS_RI_1152x864,SIS_RI_1280x720,SIS_RI_1280x768,SIS_RI_1280x800,
2001 SIS_RI_1280x960,0xff 2036 SIS_RI_1280x854,SIS_RI_1280x960,0xff
2002 }; 2037 };
2003 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); 2038 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes);
2004 break; 2039 break;
2005 } 2040 }
2006 case Panel_1400x1050: { 2041 case Panel_1400x1050: {
2007 static const UCHAR nonscalingmodes[] = { 2042 static const unsigned char nonscalingmodes[] = {
2008 SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, 2043 SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480,
2009 SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, 2044 SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600,
2010 SIS_RI_1152x768,SIS_RI_1152x864,SIS_RI_1280x768,SIS_RI_1280x800,SIS_RI_1280x960, 2045 SIS_RI_1152x768,SIS_RI_1152x864,SIS_RI_1280x768,SIS_RI_1280x800,SIS_RI_1280x854,
2011 0xff 2046 SIS_RI_1280x960,0xff
2012 }; 2047 };
2013 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); 2048 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes);
2014 switch(resinfo) { 2049 switch(resinfo) {
2015 case SIS_RI_1280x720: if(SiS_Pr->UsePanelScaler == -1) { 2050 case SIS_RI_1280x720: if(SiS_Pr->UsePanelScaler == -1) {
2016 SiS_Pr->SiS_LCDInfo |= DontExpandLCD; 2051 SiS_Pr->SiS_LCDInfo |= DontExpandLCD;
2017 } 2052 }
2018 break; 2053 break;
2019 case SIS_RI_1280x1024: SiS_Pr->SiS_LCDInfo |= DontExpandLCD; 2054 case SIS_RI_1280x1024: SiS_Pr->SiS_LCDInfo |= DontExpandLCD;
2020 break; 2055 break;
2021 } 2056 }
2022 break; 2057 break;
2023 } 2058 }
2024 case Panel_1600x1200: { 2059 case Panel_1600x1200: {
2025 static const UCHAR nonscalingmodes[] = { 2060 static const unsigned char nonscalingmodes[] = {
2026 SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, 2061 SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480,
2027 SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, 2062 SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600,
2028 SIS_RI_1152x768,SIS_RI_1152x864,SIS_RI_1280x720,SIS_RI_1280x768,SIS_RI_1280x800, 2063 SIS_RI_1152x768,SIS_RI_1152x864,SIS_RI_1280x720,SIS_RI_1280x768,SIS_RI_1280x800,
2029 SIS_RI_1280x960,SIS_RI_1360x768,SIS_RI_1360x1024,0xff 2064 SIS_RI_1280x854,SIS_RI_1280x960,SIS_RI_1360x768,SIS_RI_1360x1024,0xff
2030 }; 2065 };
2031 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); 2066 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes);
2032 break; 2067 break;
2033 } 2068 }
2034 case Panel_1680x1050: { 2069 case Panel_1680x1050: {
2035 static const UCHAR nonscalingmodes[] = { 2070 static const unsigned char nonscalingmodes[] = {
2036 SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480, 2071 SIS_RI_720x480, SIS_RI_720x576, SIS_RI_768x576, SIS_RI_800x480, SIS_RI_848x480,
2037 SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600, 2072 SIS_RI_856x480, SIS_RI_960x540, SIS_RI_960x600, SIS_RI_1024x576,SIS_RI_1024x600,
2038 SIS_RI_1152x768,SIS_RI_1152x864,SIS_RI_1280x960,SIS_RI_1360x768,SIS_RI_1360x1024, 2073 SIS_RI_1152x768,SIS_RI_1152x864,SIS_RI_1280x854,SIS_RI_1280x960,SIS_RI_1360x768,
2039 0xff 2074 SIS_RI_1360x1024,0xff
2040 }; 2075 };
2041 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes); 2076 SiS_CheckScaling(SiS_Pr, resinfo, nonscalingmodes);
2042 break; 2077 break;
@@ -2044,25 +2079,25 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2044 } 2079 }
2045 } 2080 }
2046 2081
2082#ifdef SIS300
2047 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { 2083 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
2048 if(SiS_Pr->SiS_CustomT == CUT_PANEL848) { 2084 if(SiS_Pr->SiS_CustomT == CUT_PANEL848 || SiS_Pr->SiS_CustomT == CUT_PANEL856) {
2049 SiS_Pr->SiS_LCDInfo = 0x80 | 0x40 | 0x20; /* neg h/v sync, RGB24(D0 = 0) */ 2085 SiS_Pr->SiS_LCDInfo = 0x80 | 0x40 | 0x20; /* neg h/v sync, RGB24(D0 = 0) */
2050 } 2086 }
2051 } 2087 }
2052 2088
2053#ifdef SIS300 2089 if(SiS_Pr->ChipType < SIS_315H) {
2054 if(HwInfo->jChipType < SIS_315H) {
2055 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { 2090 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
2056 if(SiS_Pr->SiS_UseROM) { 2091 if(SiS_Pr->SiS_UseROM) {
2057 if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) { 2092 if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) {
2058 if(!(ROMAddr[0x235] & 0x02)) { 2093 if(!(ROMAddr[0x235] & 0x02)) {
2059 SiS_Pr->SiS_LCDInfo &= (~DontExpandLCD); 2094 SiS_Pr->SiS_LCDInfo &= (~DontExpandLCD);
2060 } 2095 }
2061 } 2096 }
2062 } 2097 }
2063 } else if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { 2098 } else if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) {
2064 if((SiS_Pr->SiS_SetFlag & SetDOSMode) && ((ModeNo == 0x03) || (ModeNo == 0x10))) { 2099 if((SiS_Pr->SiS_SetFlag & SetDOSMode) && ((ModeNo == 0x03) || (ModeNo == 0x10))) {
2065 SiS_Pr->SiS_LCDInfo &= (~DontExpandLCD); 2100 SiS_Pr->SiS_LCDInfo &= (~DontExpandLCD);
2066 } 2101 }
2067 } 2102 }
2068 } 2103 }
@@ -2080,7 +2115,7 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2080 2115
2081 switch(SiS_Pr->SiS_LCDResInfo) { 2116 switch(SiS_Pr->SiS_LCDResInfo) {
2082 case Panel_640x480: 2117 case Panel_640x480:
2083 SiS_Pr->SiS_LCDInfo |= LCDPass11; 2118 SiS_Pr->SiS_LCDInfo |= (DontExpandLCD | LCDPass11);
2084 break; 2119 break;
2085 case Panel_1280x800: 2120 case Panel_1280x800:
2086 /* Don't pass 1:1 by default (TMDS special) */ 2121 /* Don't pass 1:1 by default (TMDS special) */
@@ -2097,7 +2132,7 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2097 break; 2132 break;
2098 } 2133 }
2099 2134
2100 if(SiS_Pr->UseCustomMode) { 2135 if((SiS_Pr->UseCustomMode) || (SiS_Pr->SiS_CustomT == CUT_UNKNOWNLCD)) {
2101 SiS_Pr->SiS_LCDInfo |= (DontExpandLCD | LCDPass11); 2136 SiS_Pr->SiS_LCDInfo |= (DontExpandLCD | LCDPass11);
2102 } 2137 }
2103 2138
@@ -2107,19 +2142,19 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2107 } 2142 }
2108 2143
2109 /* LVDS DDA */ 2144 /* LVDS DDA */
2110 if(!((HwInfo->jChipType < SIS_315H) && (SiS_Pr->SiS_SetFlag & SetDOSMode))) { 2145 if(!((SiS_Pr->ChipType < SIS_315H) && (SiS_Pr->SiS_SetFlag & SetDOSMode))) {
2111 2146
2112 if((SiS_Pr->SiS_IF_DEF_LVDS == 1) || (SiS_Pr->SiS_VBType & VB_NoLCD)) { 2147 if((SiS_Pr->SiS_IF_DEF_LVDS == 1) || (SiS_Pr->SiS_VBType & VB_NoLCD)) {
2113 if(SiS_Pr->SiS_IF_DEF_TRUMPION == 0) { 2148 if(SiS_Pr->SiS_IF_DEF_TRUMPION == 0) {
2114 if(ModeNo == 0x12) { 2149 if(ModeNo == 0x12) {
2115 if(SiS_Pr->SiS_LCDInfo & LCDPass11) { 2150 if(SiS_Pr->SiS_LCDInfo & LCDPass11) {
2116 SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; 2151 SiS_Pr->SiS_SetFlag |= EnableLVDSDDA;
2117 } 2152 }
2118 } else if(ModeNo > 0x13) { 2153 } else if(ModeNo > 0x13) {
2119 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x600) { 2154 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x600) {
2120 if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { 2155 if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) {
2121 if((resinfo == SIS_RI_800x600) || (resinfo == SIS_RI_400x300)) { 2156 if((resinfo == SIS_RI_800x600) || (resinfo == SIS_RI_400x300)) {
2122 SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; 2157 SiS_Pr->SiS_SetFlag |= EnableLVDSDDA;
2123 } 2158 }
2124 } 2159 }
2125 } 2160 }
@@ -2128,18 +2163,18 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2128 } 2163 }
2129 2164
2130 if(modeflag & HalfDCLK) { 2165 if(modeflag & HalfDCLK) {
2131 if(SiS_Pr->SiS_IF_DEF_TRUMPION == 1) { 2166 if(SiS_Pr->SiS_IF_DEF_TRUMPION == 1) {
2132 SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; 2167 SiS_Pr->SiS_SetFlag |= EnableLVDSDDA;
2133 } else if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { 2168 } else if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
2134 SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; 2169 SiS_Pr->SiS_SetFlag |= EnableLVDSDDA;
2135 } else if(SiS_Pr->SiS_LCDResInfo == Panel_640x480) { 2170 } else if(SiS_Pr->SiS_LCDResInfo == Panel_640x480) {
2136 SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; 2171 SiS_Pr->SiS_SetFlag |= EnableLVDSDDA;
2137 } else if(ModeNo > 0x13) { 2172 } else if(ModeNo > 0x13) {
2138 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { 2173 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) {
2139 if(resinfo == SIS_RI_512x384) SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; 2174 if(resinfo == SIS_RI_512x384) SiS_Pr->SiS_SetFlag |= EnableLVDSDDA;
2140 } else if(SiS_Pr->SiS_LCDResInfo == Panel_800x600) { 2175 } else if(SiS_Pr->SiS_LCDResInfo == Panel_800x600) {
2141 if(resinfo == SIS_RI_400x300) SiS_Pr->SiS_SetFlag |= EnableLVDSDDA; 2176 if(resinfo == SIS_RI_400x300) SiS_Pr->SiS_SetFlag |= EnableLVDSDDA;
2142 } 2177 }
2143 } 2178 }
2144 } 2179 }
2145 2180
@@ -2148,21 +2183,21 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2148 /* VESA timing */ 2183 /* VESA timing */
2149 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { 2184 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
2150 if(SiS_Pr->SiS_VBInfo & SetNotSimuMode) { 2185 if(SiS_Pr->SiS_VBInfo & SetNotSimuMode) {
2151 SiS_Pr->SiS_SetFlag |= LCDVESATiming; 2186 SiS_Pr->SiS_SetFlag |= LCDVESATiming;
2152 } 2187 }
2153 } else { 2188 } else {
2154 SiS_Pr->SiS_SetFlag |= LCDVESATiming; 2189 SiS_Pr->SiS_SetFlag |= LCDVESATiming;
2155 } 2190 }
2156 2191
2157#ifdef LINUX_KERNEL 2192#ifdef SIS_LINUX_KERNEL
2158#ifdef TWDEBUG 2193#if 0
2159 printk(KERN_DEBUG "sisfb: (LCDInfo=0x%04x LCDResInfo=0x%02x LCDTypeInfo=0x%02x)\n", 2194 printk(KERN_DEBUG "sisfb: (LCDInfo=0x%04x LCDResInfo=0x%02x LCDTypeInfo=0x%02x)\n",
2160 SiS_Pr->SiS_LCDInfo, SiS_Pr->SiS_LCDResInfo, SiS_Pr->SiS_LCDTypeInfo); 2195 SiS_Pr->SiS_LCDInfo, SiS_Pr->SiS_LCDResInfo, SiS_Pr->SiS_LCDTypeInfo);
2161#endif 2196#endif
2162#endif 2197#endif
2163#ifdef LINUX_XF86 2198#ifdef SIS_XORG_XF86
2164 xf86DrvMsgVerb(0, X_PROBED, 4, 2199 xf86DrvMsgVerb(0, X_PROBED, 4,
2165 "(init301: LCDInfo=0x%04x LCDResInfo=0x%02x LCDTypeInfo=0x%02x SetFlag=0x%04x)\n", 2200 "(init301: LCDInfo=0x%04x LCDResInfo=0x%02x LCDTypeInfo=0x%02x SetFlag=0x%04x)\n",
2166 SiS_Pr->SiS_LCDInfo, SiS_Pr->SiS_LCDResInfo, SiS_Pr->SiS_LCDTypeInfo, SiS_Pr->SiS_SetFlag); 2201 SiS_Pr->SiS_LCDInfo, SiS_Pr->SiS_LCDResInfo, SiS_Pr->SiS_LCDTypeInfo, SiS_Pr->SiS_SetFlag);
2167#endif 2202#endif
2168} 2203}
@@ -2171,45 +2206,46 @@ SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2171/* GET VCLK */ 2206/* GET VCLK */
2172/*********************************************/ 2207/*********************************************/
2173 2208
2174USHORT 2209unsigned short
2175SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, 2210SiS_GetVCLK2Ptr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex,
2176 USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) 2211 unsigned short RefreshRateTableIndex)
2177{ 2212{
2178 USHORT CRT2Index,VCLKIndex=0,VCLKIndexGEN=0; 2213 unsigned short CRT2Index, VCLKIndex = 0, VCLKIndexGEN = 0, VCLKIndexGENCRT = 0;
2179 USHORT modeflag,resinfo,tempbx; 2214 unsigned short modeflag, resinfo, tempbx;
2180 const UCHAR *CHTVVCLKPtr = NULL; 2215 const unsigned char *CHTVVCLKPtr = NULL;
2181 2216
2182 if(ModeNo <= 0x13) { 2217 if(ModeNo <= 0x13) {
2183 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; 2218 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
2184 resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo; 2219 resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo;
2185 CRT2Index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; 2220 CRT2Index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
2186 VCLKIndexGEN = (SiS_GetRegByte((SiS_Pr->SiS_P3ca+0x02)) >> 2) & 0x03; 2221 VCLKIndexGEN = (SiS_GetRegByte((SiS_Pr->SiS_P3ca+0x02)) >> 2) & 0x03;
2222 VCLKIndexGENCRT = VCLKIndexGEN;
2187 } else { 2223 } else {
2188 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; 2224 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2189 resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; 2225 resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
2190 CRT2Index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; 2226 CRT2Index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
2191 VCLKIndexGEN = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; 2227 VCLKIndexGEN = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
2192 if(HwInfo->jChipType < SIS_315H) VCLKIndexGEN &= 0x3f; 2228 VCLKIndexGENCRT = SiS_GetRefCRTVCLK(SiS_Pr, RefreshRateTableIndex,
2229 (SiS_Pr->SiS_SetFlag & ProgrammingCRT2) ? SiS_Pr->SiS_UseWideCRT2 : SiS_Pr->SiS_UseWide);
2193 } 2230 }
2194 2231
2195 if(SiS_Pr->SiS_VBType & VB_SISVB) { /* 30x/B/LV */ 2232 if(SiS_Pr->SiS_VBType & VB_SISVB) { /* 30x/B/LV */
2196 2233
2197 if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) { 2234 if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) {
2198 2235
2199 CRT2Index >>= 6; 2236 CRT2Index >>= 6;
2200 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { /* LCD */ 2237 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { /* LCD */
2201 2238
2202 if(HwInfo->jChipType < SIS_315H) { 2239 if(SiS_Pr->ChipType < SIS_315H) {
2203 VCLKIndex = SiS_Pr->PanelVCLKIdx300; 2240 VCLKIndex = SiS_Pr->PanelVCLKIdx300;
2204 if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (SiS_Pr->SiS_LCDInfo & LCDPass11)) { 2241 if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (SiS_Pr->SiS_LCDInfo & LCDPass11)) {
2205 VCLKIndex = VCLKIndexGEN; 2242 VCLKIndex = VCLKIndexGEN;
2206 } 2243 }
2207 } else { 2244 } else {
2208 VCLKIndex = SiS_Pr->PanelVCLKIdx315; 2245 VCLKIndex = SiS_Pr->PanelVCLKIdx315;
2209 if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (SiS_Pr->SiS_LCDInfo & LCDPass11)) { 2246 if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (SiS_Pr->SiS_LCDInfo & LCDPass11)) {
2210 switch(resinfo) { 2247 switch(resinfo) {
2211 /* Only those whose IndexGEN doesn't match VBVCLK array */ 2248 /* Correct those whose IndexGEN doesn't match VBVCLK array */
2212 case SIS_RI_1280x720: VCLKIndex = VCLK_1280x720; break;
2213 case SIS_RI_720x480: VCLKIndex = VCLK_720x480; break; 2249 case SIS_RI_720x480: VCLKIndex = VCLK_720x480; break;
2214 case SIS_RI_720x576: VCLKIndex = VCLK_720x576; break; 2250 case SIS_RI_720x576: VCLKIndex = VCLK_720x576; break;
2215 case SIS_RI_768x576: VCLKIndex = VCLK_768x576; break; 2251 case SIS_RI_768x576: VCLKIndex = VCLK_768x576; break;
@@ -2218,18 +2254,19 @@ SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2218 case SIS_RI_800x480: VCLKIndex = VCLK_800x480; break; 2254 case SIS_RI_800x480: VCLKIndex = VCLK_800x480; break;
2219 case SIS_RI_1024x576: VCLKIndex = VCLK_1024x576; break; 2255 case SIS_RI_1024x576: VCLKIndex = VCLK_1024x576; break;
2220 case SIS_RI_1152x864: VCLKIndex = VCLK_1152x864; break; 2256 case SIS_RI_1152x864: VCLKIndex = VCLK_1152x864; break;
2257 case SIS_RI_1280x720: VCLKIndex = VCLK_1280x720; break;
2221 case SIS_RI_1360x768: VCLKIndex = VCLK_1360x768; break; 2258 case SIS_RI_1360x768: VCLKIndex = VCLK_1360x768; break;
2222 default: VCLKIndex = VCLKIndexGEN; 2259 default: VCLKIndex = VCLKIndexGEN;
2223 } 2260 }
2224 2261
2225 if(ModeNo <= 0x13) { 2262 if(ModeNo <= 0x13) {
2226 if(HwInfo->jChipType <= SIS_315PRO) { 2263 if(SiS_Pr->ChipType <= SIS_315PRO) {
2227 if(SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC == 1) VCLKIndex = 0x42; 2264 if(SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC == 1) VCLKIndex = 0x42;
2228 } else { 2265 } else {
2229 if(SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC == 1) VCLKIndex = 0x00; 2266 if(SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC == 1) VCLKIndex = 0x00;
2230 } 2267 }
2231 } 2268 }
2232 if(HwInfo->jChipType <= SIS_315PRO) { 2269 if(SiS_Pr->ChipType <= SIS_315PRO) {
2233 if(VCLKIndex == 0) VCLKIndex = 0x41; 2270 if(VCLKIndex == 0) VCLKIndex = 0x41;
2234 if(VCLKIndex == 1) VCLKIndex = 0x43; 2271 if(VCLKIndex == 1) VCLKIndex = 0x43;
2235 if(VCLKIndex == 4) VCLKIndex = 0x44; 2272 if(VCLKIndex == 4) VCLKIndex = 0x44;
@@ -2237,49 +2274,46 @@ SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2237 } 2274 }
2238 } 2275 }
2239 2276
2240 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { /* TV */ 2277 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { /* TV */
2241 2278
2242 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { 2279 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {
2243 if(SiS_Pr->SiS_TVMode & TVRPLLDIV2XO) VCLKIndex = HiTVVCLKDIV2; 2280 if(SiS_Pr->SiS_TVMode & TVRPLLDIV2XO) VCLKIndex = HiTVVCLKDIV2;
2244 else VCLKIndex = HiTVVCLK; 2281 else VCLKIndex = HiTVVCLK;
2245 if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { 2282 if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) VCLKIndex = HiTVSimuVCLK;
2246 if(modeflag & Charx8Dot) VCLKIndex = HiTVSimuVCLK; 2283 } else if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) VCLKIndex = YPbPr750pVCLK;
2247 else VCLKIndex = HiTVTextVCLK; 2284 else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) VCLKIndex = TVVCLKDIV2;
2248 } 2285 else if(SiS_Pr->SiS_TVMode & TVRPLLDIV2XO) VCLKIndex = TVVCLKDIV2;
2249 } else if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) VCLKIndex = YPbPr750pVCLK; 2286 else VCLKIndex = TVVCLK;
2250 else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) VCLKIndex = TVVCLKDIV2; 2287
2251 else if(SiS_Pr->SiS_TVMode & TVRPLLDIV2XO) VCLKIndex = TVVCLKDIV2; 2288 if(SiS_Pr->ChipType < SIS_315H) VCLKIndex += TVCLKBASE_300;
2252 else VCLKIndex = TVVCLK; 2289 else VCLKIndex += TVCLKBASE_315;
2253 2290
2254 if(HwInfo->jChipType < SIS_315H) VCLKIndex += TVCLKBASE_300; 2291 } else { /* VGA2 */
2255 else VCLKIndex += TVCLKBASE_315; 2292
2256 2293 VCLKIndex = VCLKIndexGENCRT;
2257 } else { /* VGA2 */ 2294 if(SiS_Pr->ChipType < SIS_315H) {
2258 2295 if(ModeNo > 0x13) {
2259 VCLKIndex = VCLKIndexGEN; 2296 if( (SiS_Pr->ChipType == SIS_630) &&
2260 if(HwInfo->jChipType < SIS_315H) { 2297 (SiS_Pr->ChipRevision >= 0x30)) {
2261 if(ModeNo > 0x13) {
2262 if( (HwInfo->jChipType == SIS_630) &&
2263 (HwInfo->jChipRevision >= 0x30)) {
2264 if(VCLKIndex == 0x14) VCLKIndex = 0x34; 2298 if(VCLKIndex == 0x14) VCLKIndex = 0x34;
2265 } 2299 }
2266 /* Better VGA2 clock for 1280x1024@75 */ 2300 /* Better VGA2 clock for 1280x1024@75 */
2267 if(VCLKIndex == 0x17) VCLKIndex = 0x45; 2301 if(VCLKIndex == 0x17) VCLKIndex = 0x45;
2268 } 2302 }
2269 } 2303 }
2270 } 2304 }
2271 2305
2272 } else { /* If not programming CRT2 */ 2306 } else { /* If not programming CRT2 */
2273 2307
2274 VCLKIndex = VCLKIndexGEN; 2308 VCLKIndex = VCLKIndexGENCRT;
2275 if(HwInfo->jChipType < SIS_315H) { 2309 if(SiS_Pr->ChipType < SIS_315H) {
2276 if(ModeNo > 0x13) { 2310 if(ModeNo > 0x13) {
2277 if( (HwInfo->jChipType != SIS_630) && 2311 if( (SiS_Pr->ChipType != SIS_630) &&
2278 (HwInfo->jChipType != SIS_300) ) { 2312 (SiS_Pr->ChipType != SIS_300) ) {
2279 if(VCLKIndex == 0x1b) VCLKIndex = 0x48; 2313 if(VCLKIndex == 0x1b) VCLKIndex = 0x48;
2280 } 2314 }
2281 } 2315 }
2282 } 2316 }
2283 } 2317 }
2284 2318
2285 } else { /* LVDS */ 2319 } else { /* LVDS */
@@ -2288,12 +2322,12 @@ SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2288 2322
2289 if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) { 2323 if(SiS_Pr->SiS_SetFlag & ProgrammingCRT2) {
2290 2324
2291 if( (SiS_Pr->SiS_IF_DEF_CH70xx != 0) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) ) { 2325 if( (SiS_Pr->SiS_IF_DEF_CH70xx != 0) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) ) {
2292 2326
2293 VCLKIndex &= 0x1f; 2327 VCLKIndex &= 0x1f;
2294 tempbx = 0; 2328 tempbx = 0;
2295 if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1; 2329 if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1;
2296 if(SiS_Pr->SiS_TVMode & TVSetPAL) { 2330 if(SiS_Pr->SiS_TVMode & TVSetPAL) {
2297 tempbx += 2; 2331 tempbx += 2;
2298 if(SiS_Pr->SiS_ModeType > ModeVGA) { 2332 if(SiS_Pr->SiS_ModeType > ModeVGA) {
2299 if(SiS_Pr->SiS_CHSOverScan) tempbx = 8; 2333 if(SiS_Pr->SiS_CHSOverScan) tempbx = 8;
@@ -2306,66 +2340,68 @@ SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2306 if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1; 2340 if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1;
2307 } 2341 }
2308 } 2342 }
2309 switch(tempbx) { 2343 switch(tempbx) {
2310 case 0: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUNTSC; break; 2344 case 0: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUNTSC; break;
2311 case 1: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKONTSC; break; 2345 case 1: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKONTSC; break;
2312 case 2: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUPAL; break; 2346 case 2: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUPAL; break;
2313 case 3: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPAL; break; 2347 case 3: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPAL; break;
2314 case 4: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUPALM; break; 2348 case 4: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUPALM; break;
2315 case 5: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPALM; break; 2349 case 5: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPALM; break;
2316 case 6: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUPALN; break; 2350 case 6: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKUPALN; break;
2317 case 7: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPALN; break; 2351 case 7: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPALN; break;
2318 case 8: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKSOPAL; break; 2352 case 8: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKSOPAL; break;
2319 default: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPAL; break; 2353 default: CHTVVCLKPtr = SiS_Pr->SiS_CHTVVCLKOPAL; break;
2320 } 2354 }
2321 VCLKIndex = CHTVVCLKPtr[VCLKIndex]; 2355 VCLKIndex = CHTVVCLKPtr[VCLKIndex];
2322 2356
2323 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 2357 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
2324 2358
2325 if(HwInfo->jChipType < SIS_315H) { 2359 if(SiS_Pr->ChipType < SIS_315H) {
2326 VCLKIndex = SiS_Pr->PanelVCLKIdx300; 2360 VCLKIndex = SiS_Pr->PanelVCLKIdx300;
2327 } else { 2361 } else {
2328 VCLKIndex = SiS_Pr->PanelVCLKIdx315; 2362 VCLKIndex = SiS_Pr->PanelVCLKIdx315;
2329 } 2363 }
2330 2364
2365#ifdef SIS300
2331 /* Special Timing: Barco iQ Pro R series */ 2366 /* Special Timing: Barco iQ Pro R series */
2332 if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) VCLKIndex = 0x44; 2367 if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) VCLKIndex = 0x44;
2333 2368
2334 /* Special Timing: 848x480 parallel lvds */ 2369 /* Special Timing: 848x480 and 856x480 parallel lvds panels */
2335 if(SiS_Pr->SiS_CustomT == CUT_PANEL848) { 2370 if(SiS_Pr->SiS_CustomT == CUT_PANEL848 || SiS_Pr->SiS_CustomT == CUT_PANEL856) {
2336 if(HwInfo->jChipType < SIS_315H) { 2371 if(SiS_Pr->ChipType < SIS_315H) {
2337 VCLKIndex = VCLK34_300; 2372 VCLKIndex = VCLK34_300;
2338 /* if(resinfo == SIS_RI_1360x768) VCLKIndex = ?; */ 2373 /* if(resinfo == SIS_RI_1360x768) VCLKIndex = ?; */
2339 } else { 2374 } else {
2340 VCLKIndex = VCLK34_315; 2375 VCLKIndex = VCLK34_315;
2341 /* if(resinfo == SIS_RI_1360x768) VCLKIndex = ?; */ 2376 /* if(resinfo == SIS_RI_1360x768) VCLKIndex = ?; */
2342 } 2377 }
2343 } 2378 }
2379#endif
2344 2380
2345 } else { 2381 } else {
2346 2382
2347 VCLKIndex = VCLKIndexGEN; 2383 VCLKIndex = VCLKIndexGENCRT;
2348 if(HwInfo->jChipType < SIS_315H) { 2384 if(SiS_Pr->ChipType < SIS_315H) {
2349 if(ModeNo > 0x13) { 2385 if(ModeNo > 0x13) {
2350 if( (HwInfo->jChipType == SIS_630) && 2386 if( (SiS_Pr->ChipType == SIS_630) &&
2351 (HwInfo->jChipRevision >= 0x30) ) { 2387 (SiS_Pr->ChipRevision >= 0x30) ) {
2352 if(VCLKIndex == 0x14) VCLKIndex = 0x2e; 2388 if(VCLKIndex == 0x14) VCLKIndex = 0x2e;
2353 } 2389 }
2354 } 2390 }
2355 } 2391 }
2356 } 2392 }
2357 2393
2358 } else { /* if not programming CRT2 */ 2394 } else { /* if not programming CRT2 */
2359 2395
2360 VCLKIndex = VCLKIndexGEN; 2396 VCLKIndex = VCLKIndexGENCRT;
2361 if(HwInfo->jChipType < SIS_315H) { 2397 if(SiS_Pr->ChipType < SIS_315H) {
2362 if(ModeNo > 0x13) { 2398 if(ModeNo > 0x13) {
2363 if( (HwInfo->jChipType != SIS_630) && 2399 if( (SiS_Pr->ChipType != SIS_630) &&
2364 (HwInfo->jChipType != SIS_300) ) { 2400 (SiS_Pr->ChipType != SIS_300) ) {
2365 if(VCLKIndex == 0x1b) VCLKIndex = 0x48; 2401 if(VCLKIndex == 0x1b) VCLKIndex = 0x48;
2366 } 2402 }
2367#if 0 2403#if 0
2368 if(HwInfo->jChipType == SIS_730) { 2404 if(SiS_Pr->ChipType == SIS_730) {
2369 if(VCLKIndex == 0x0b) VCLKIndex = 0x40; /* 1024x768-70 */ 2405 if(VCLKIndex == 0x0b) VCLKIndex = 0x40; /* 1024x768-70 */
2370 if(VCLKIndex == 0x0d) VCLKIndex = 0x41; /* 1024x768-75 */ 2406 if(VCLKIndex == 0x0d) VCLKIndex = 0x41; /* 1024x768-75 */
2371 } 2407 }
@@ -2377,11 +2413,13 @@ SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2377 2413
2378 } 2414 }
2379 2415
2416#ifdef SIS_XORG_XF86
2380#ifdef TWDEBUG 2417#ifdef TWDEBUG
2381 xf86DrvMsg(0, X_INFO, "VCLKIndex %d (0x%x)\n", VCLKIndex, VCLKIndex); 2418 xf86DrvMsg(0, X_INFO, "VCLKIndex %d (0x%x)\n", VCLKIndex, VCLKIndex);
2382#endif 2419#endif
2420#endif
2383 2421
2384 return(VCLKIndex); 2422 return VCLKIndex;
2385} 2423}
2386 2424
2387/*********************************************/ 2425/*********************************************/
@@ -2389,26 +2427,19 @@ SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2389/*********************************************/ 2427/*********************************************/
2390 2428
2391static void 2429static void
2392SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, 2430SiS_SetCRT2ModeRegs(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex)
2393 PSIS_HW_INFO HwInfo)
2394{ 2431{
2395 USHORT i,j,modeflag; 2432 unsigned short i, j, modeflag, tempah=0;
2396 USHORT tempcl,tempah=0; 2433 short tempcl;
2397#if defined(SIS300) || defined(SIS315H) 2434#if defined(SIS300) || defined(SIS315H)
2398 USHORT tempbl; 2435 unsigned short tempbl;
2399#endif 2436#endif
2400#ifdef SIS315H 2437#ifdef SIS315H
2401 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; 2438 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
2402 USHORT tempah2, tempbl2; 2439 unsigned short tempah2, tempbl2;
2403#endif 2440#endif
2404 2441
2405 if(ModeNo <= 0x13) { 2442 modeflag = SiS_GetModeFlag(SiS_Pr, ModeNo, ModeIdIndex);
2406 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
2407 } else if(SiS_Pr->UseCustomMode) {
2408 modeflag = SiS_Pr->CModeFlag;
2409 } else {
2410 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2411 }
2412 2443
2413 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { 2444 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
2414 2445
@@ -2418,18 +2449,18 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2418 } else { 2449 } else {
2419 2450
2420 for(i=0,j=4; i<3; i++,j++) SiS_SetReg(SiS_Pr->SiS_Part1Port,j,0); 2451 for(i=0,j=4; i<3; i++,j++) SiS_SetReg(SiS_Pr->SiS_Part1Port,j,0);
2421 if(HwInfo->jChipType >= SIS_315H) { 2452 if(SiS_Pr->ChipType >= SIS_315H) {
2422 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0x7F); 2453 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0x7F);
2423 } 2454 }
2424 2455
2425 tempcl = SiS_Pr->SiS_ModeType; 2456 tempcl = SiS_Pr->SiS_ModeType;
2426 2457
2427 if(HwInfo->jChipType < SIS_315H) { 2458 if(SiS_Pr->ChipType < SIS_315H) {
2428 2459
2429#ifdef SIS300 /* ---- 300 series ---- */ 2460#ifdef SIS300 /* ---- 300 series ---- */
2430 2461
2431 /* For 301BDH: (with LCD via LVDS) */ 2462 /* For 301BDH: (with LCD via LVDS) */
2432 if(SiS_Pr->SiS_VBType & VB_NoLCD) { 2463 if(SiS_Pr->SiS_VBType & VB_NoLCD) {
2433 tempbl = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32); 2464 tempbl = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32);
2434 tempbl &= 0xef; 2465 tempbl &= 0xef;
2435 tempbl |= 0x02; 2466 tempbl |= 0x02;
@@ -2438,16 +2469,16 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2438 tempbl &= 0xfd; 2469 tempbl &= 0xfd;
2439 } 2470 }
2440 SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,tempbl); 2471 SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,tempbl);
2441 } 2472 }
2442 2473
2443 if(ModeNo > 0x13) { 2474 if(ModeNo > 0x13) {
2444 tempcl -= ModeVGA; 2475 tempcl -= ModeVGA;
2445 if((tempcl > 0) || (tempcl == 0)) { /* tempcl is USHORT -> always true! */ 2476 if(tempcl >= 0) {
2446 tempah = ((0x10 >> tempcl) | 0x80); 2477 tempah = ((0x10 >> tempcl) | 0x80);
2447 } 2478 }
2448 } else tempah = 0x80; 2479 } else tempah = 0x80;
2449 2480
2450 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempah ^= 0xA0; 2481 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempah ^= 0xA0;
2451 2482
2452#endif /* SIS300 */ 2483#endif /* SIS300 */
2453 2484
@@ -2455,22 +2486,16 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2455 2486
2456#ifdef SIS315H /* ------- 315/330 series ------ */ 2487#ifdef SIS315H /* ------- 315/330 series ------ */
2457 2488
2458 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { 2489 if(ModeNo > 0x13) {
2459 if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { 2490 tempcl -= ModeVGA;
2460 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x08); 2491 if(tempcl >= 0) {
2461 } 2492 tempah = (0x08 >> tempcl);
2462 } 2493 if (tempah == 0) tempah = 1;
2463 2494 tempah |= 0x40;
2464 if(ModeNo > 0x13) { 2495 }
2465 tempcl -= ModeVGA; 2496 } else tempah = 0x40;
2466 if((tempcl > 0) || (tempcl == 0)) { /* tempcl is USHORT -> always true! */
2467 tempah = (0x08 >> tempcl);
2468 if (tempah == 0) tempah = 1;
2469 tempah |= 0x40;
2470 }
2471 } else tempah = 0x40;
2472 2497
2473 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempah ^= 0x50; 2498 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) tempah ^= 0x50;
2474 2499
2475#endif /* SIS315H */ 2500#endif /* SIS315H */
2476 2501
@@ -2478,84 +2503,89 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2478 2503
2479 if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0; 2504 if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0;
2480 2505
2481 if(HwInfo->jChipType < SIS_315H) { 2506 if(SiS_Pr->ChipType < SIS_315H) {
2482 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,tempah); 2507 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,tempah);
2483 } else { 2508 } else {
2484 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { 2509#ifdef SIS315H
2485 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x00,0xa0,tempah); 2510 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
2486 } else if(SiS_Pr->SiS_VBType & VB_SISVB) { 2511 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x00,0xa0,tempah);
2487 if(IS_SIS740) { 2512 } else if(SiS_Pr->SiS_VBType & VB_SISVB) {
2513 if(IS_SIS740) {
2488 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,tempah); 2514 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,tempah);
2489 } else { 2515 } else {
2490 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x00,0xa0,tempah); 2516 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x00,0xa0,tempah);
2491 } 2517 }
2492 } 2518 }
2519#endif
2493 } 2520 }
2494 2521
2495 if(SiS_Pr->SiS_VBType & VB_SISVB) { 2522 if(SiS_Pr->SiS_VBType & VB_SISVB) {
2496 2523
2497 tempah = 0x01; 2524 tempah = 0x01;
2498 if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { 2525 if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
2499 tempah |= 0x02; 2526 tempah |= 0x02;
2500 } 2527 }
2501 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { 2528 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) {
2502 tempah ^= 0x05; 2529 tempah ^= 0x05;
2503 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { 2530 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) {
2504 tempah ^= 0x01; 2531 tempah ^= 0x01;
2505 } 2532 }
2506 } 2533 }
2507 2534
2508 if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0; 2535 if(SiS_Pr->ChipType < SIS_315H) {
2509 2536
2510 if(HwInfo->jChipType < SIS_315H) { 2537 if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0;
2511 2538
2512 tempah = (tempah << 5) & 0xFF; 2539 tempah = (tempah << 5) & 0xFF;
2513 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x01,tempah); 2540 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x01,tempah);
2514 tempah = (tempah >> 5) & 0xFF; 2541 tempah = (tempah >> 5) & 0xFF;
2515 2542
2516 } else { 2543 } else {
2517 2544
2518 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2E,0xF8,tempah); 2545 if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0x08;
2546 else if(!(SiS_IsDualEdge(SiS_Pr))) tempah |= 0x08;
2547 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2E,0xF0,tempah);
2548 tempah &= ~0x08;
2519 2549
2520 } 2550 }
2521 2551
2522 if((SiS_Pr->SiS_ModeType == ModeVGA) && (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode))) { 2552 if((SiS_Pr->SiS_ModeType == ModeVGA) && (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode))) {
2523 tempah |= 0x10; 2553 tempah |= 0x10;
2524 } 2554 }
2525 2555
2526 tempah |= 0x80; 2556 tempah |= 0x80;
2527 if(SiS_Pr->SiS_VBType & VB_SIS301) { 2557 if(SiS_Pr->SiS_VBType & VB_SIS301) {
2528 if(SiS_Pr->PanelXRes < 1280 && SiS_Pr->PanelYRes < 960) tempah &= ~0x80; 2558 if(SiS_Pr->PanelXRes < 1280 && SiS_Pr->PanelYRes < 960) tempah &= ~0x80;
2529 } 2559 }
2530 2560
2531 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 2561 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
2532 if(!(SiS_Pr->SiS_TVMode & (TVSetYPbPr750p | TVSetYPbPr525p))) { 2562 if(!(SiS_Pr->SiS_TVMode & (TVSetYPbPr750p | TVSetYPbPr525p))) {
2533 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { 2563 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
2534 tempah |= 0x20; 2564 tempah |= 0x20;
2535 } 2565 }
2536 } 2566 }
2537 } 2567 }
2538 2568
2539 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0D,0x40,tempah); 2569 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0D,0x40,tempah);
2540 2570
2541 tempah = 0x80; 2571 tempah = 0x80;
2542 if(SiS_Pr->SiS_VBType & VB_SIS301) { 2572 if(SiS_Pr->SiS_VBType & VB_SIS301) {
2543 if(SiS_Pr->PanelXRes < 1280 && SiS_Pr->PanelYRes < 960) tempah = 0; 2573 if(SiS_Pr->PanelXRes < 1280 && SiS_Pr->PanelYRes < 960) tempah = 0;
2544 } 2574 }
2545 2575
2546 if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempah |= 0x40; 2576 if(SiS_IsDualLink(SiS_Pr)) tempah |= 0x40;
2547 2577
2548 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 2578 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
2549 if(SiS_Pr->SiS_TVMode & TVRPLLDIV2XO) { 2579 if(SiS_Pr->SiS_TVMode & TVRPLLDIV2XO) {
2550 tempah |= 0x40; 2580 tempah |= 0x40;
2551 } 2581 }
2552 } 2582 }
2553 2583
2554 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0C,tempah); 2584 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0C,tempah);
2555 2585
2556 } else { /* LVDS */ 2586 } else { /* LVDS */
2557 2587
2558 if(HwInfo->jChipType >= SIS_315H) { 2588 if(SiS_Pr->ChipType >= SIS_315H) {
2559 2589
2560#ifdef SIS315H 2590#ifdef SIS315H
2561 /* LVDS can only be slave in 8bpp modes */ 2591 /* LVDS can only be slave in 8bpp modes */
@@ -2566,36 +2596,30 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2566 } 2596 }
2567 } 2597 }
2568 2598
2569 if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { 2599 if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) tempah |= 0x02;
2570 tempah |= 0x02;
2571 }
2572 2600
2573 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 2601 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) tempah ^= 0x01;
2574 tempah ^= 0x01;
2575 }
2576 2602
2577 if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { 2603 if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 1;
2578 tempah = 1;
2579 }
2580 2604
2581 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2e,0xF0,tempah); 2605 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2e,0xF0,tempah);
2582#endif 2606#endif
2583 2607
2584 } else { 2608 } else {
2585 2609
2586#ifdef SIS300 2610#ifdef SIS300
2587 tempah = 0; 2611 tempah = 0;
2588 if( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) && (SiS_Pr->SiS_ModeType > ModeVGA) ) { 2612 if( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) && (SiS_Pr->SiS_ModeType > ModeVGA) ) {
2589 tempah |= 0x02; 2613 tempah |= 0x02;
2590 } 2614 }
2591 tempah <<= 5; 2615 tempah <<= 5;
2592 2616
2593 if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0; 2617 if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) tempah = 0;
2594 2618
2595 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x01,tempah); 2619 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x01,tempah);
2596#endif 2620#endif
2597 2621
2598 } 2622 }
2599 2623
2600 } 2624 }
2601 2625
@@ -2603,10 +2627,10 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2603 2627
2604 if(SiS_Pr->SiS_VBType & VB_SISVB) { 2628 if(SiS_Pr->SiS_VBType & VB_SISVB) {
2605 2629
2606 if(HwInfo->jChipType >= SIS_315H) { 2630 if(SiS_Pr->ChipType >= SIS_315H) {
2607 2631
2608#ifdef SIS315H 2632#ifdef SIS315H
2609 unsigned char bridgerev = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x01); 2633 /* unsigned char bridgerev = SiS_GetReg(SiS_Pr->SiS_Part4Port,0x01); */
2610 2634
2611 /* The following is nearly unpreditable and varies from machine 2635 /* The following is nearly unpreditable and varies from machine
2612 * to machine. Especially the 301DH seems to be a real trouble 2636 * to machine. Especially the 301DH seems to be a real trouble
@@ -2619,25 +2643,28 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2619 2643
2620 /* 740 variants match for 30xB, 301B-DH, 30xLV */ 2644 /* 740 variants match for 30xB, 301B-DH, 30xLV */
2621 2645
2622 if(!(IS_SIS740)) { 2646 if(!(IS_SIS740)) {
2623 tempah = 0x04; /* For all bridges */ 2647 tempah = 0x04; /* For all bridges */
2624 tempbl = 0xfb; 2648 tempbl = 0xfb;
2625 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { 2649 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
2626 tempah = 0x00; 2650 tempah = 0x00;
2627 if(SiS_IsDualEdge(SiS_Pr, HwInfo)) { 2651 if(SiS_IsDualEdge(SiS_Pr)) {
2628 tempbl = 0xff; 2652 tempbl = 0xff;
2629 } 2653 }
2630 } 2654 }
2631 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,tempbl,tempah); 2655 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,tempbl,tempah);
2632 } 2656 }
2633 2657
2634 /* The following two are responsible for eventually wrong colors 2658 /* The following two are responsible for eventually wrong colors
2635 * in TV output. The DH (VB_NoLCD) conditions are unknown; the 2659 * in TV output. The DH (VB_NoLCD) conditions are unknown; the
2636 * b0 was found in some 651 machine (Pim; P4_23=0xe5); the b1 version 2660 * b0 was found in some 651 machine (Pim; P4_23=0xe5); the b1 version
2637 * in a 650 box (Jake). What is the criteria? 2661 * in a 650 box (Jake). What is the criteria?
2662 * Addendum: Another combination 651+301B-DH(b1) (Rapo) needs same
2663 * treatment like the 651+301B-DH(b0) case. Seems more to be the
2664 * chipset than the bridge revision.
2638 */ 2665 */
2639 2666
2640 if((IS_SIS740) || (HwInfo->jChipType >= SIS_661) || (SiS_Pr->SiS_ROMNew)) { 2667 if((IS_SIS740) || (SiS_Pr->ChipType >= SIS_661) || (SiS_Pr->SiS_ROMNew)) {
2641 tempah = 0x30; 2668 tempah = 0x30;
2642 tempbl = 0xc0; 2669 tempbl = 0xc0;
2643 if((SiS_Pr->SiS_VBInfo & DisableCRT2Display) || 2670 if((SiS_Pr->SiS_VBInfo & DisableCRT2Display) ||
@@ -2649,20 +2676,30 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2649 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,0x3f,tempbl); 2676 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,0x3f,tempbl);
2650 } else if(SiS_Pr->SiS_VBType & VB_SIS301) { 2677 } else if(SiS_Pr->SiS_VBType & VB_SIS301) {
2651 /* Fixes "TV-blue-bug" on 315+301 */ 2678 /* Fixes "TV-blue-bug" on 315+301 */
2652 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2c,0xcf); /* For 301 */ 2679 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2c,0xcf); /* For 301 */
2653 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x21,0x3f); 2680 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x21,0x3f);
2654 } else if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { 2681 } else if(SiS_Pr->SiS_VBType & VB_SISLVDS) {
2655 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30); /* For 30xLV */ 2682 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30); /* For 30xLV */
2656 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x21,0xc0);
2657 } else if((SiS_Pr->SiS_VBType & VB_NoLCD) && (bridgerev == 0xb0)) {
2658 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30); /* For 30xB-DH rev b0 (or "DH on 651"?) */
2659 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x21,0xc0); 2683 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x21,0xc0);
2684 } else if(SiS_Pr->SiS_VBType & VB_NoLCD) { /* For 301B-DH */
2685 tempah = 0x30; tempah2 = 0xc0;
2686 tempbl = 0xcf; tempbl2 = 0x3f;
2687 if(SiS_Pr->SiS_TVBlue == 0) {
2688 tempah = tempah2 = 0x00;
2689 } else if(SiS_Pr->SiS_TVBlue == -1) {
2690 /* Set on 651/M650, clear on 315/650 */
2691 if(!(IS_SIS65x)) /* (bridgerev != 0xb0) */ {
2692 tempah = tempah2 = 0x00;
2693 }
2694 }
2695 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2c,tempbl,tempah);
2696 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,tempbl2,tempah2);
2660 } else { 2697 } else {
2661 tempah = 0x30; tempah2 = 0xc0; /* For 30xB (and 301BDH rev b1) */ 2698 tempah = 0x30; tempah2 = 0xc0; /* For 30xB, 301C */
2662 tempbl = 0xcf; tempbl2 = 0x3f; 2699 tempbl = 0xcf; tempbl2 = 0x3f;
2663 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { 2700 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
2664 tempah = tempah2 = 0x00; 2701 tempah = tempah2 = 0x00;
2665 if(SiS_IsDualEdge(SiS_Pr, HwInfo)) { 2702 if(SiS_IsDualEdge(SiS_Pr)) {
2666 tempbl = tempbl2 = 0xff; 2703 tempbl = tempbl2 = 0xff;
2667 } 2704 }
2668 } 2705 }
@@ -2676,23 +2713,23 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2676 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x23,0x7f,tempah); 2713 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x23,0x7f,tempah);
2677 } else { 2714 } else {
2678 tempah = 0x00; 2715 tempah = 0x00;
2679 tempbl = 0x7f; 2716 tempbl = 0x7f;
2680 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { 2717 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
2681 tempbl = 0xff; 2718 tempbl = 0xff;
2682 if(!(SiS_IsDualEdge(SiS_Pr, HwInfo))) tempah = 0x80; 2719 if(!(SiS_IsDualEdge(SiS_Pr))) tempah = 0x80;
2683 } 2720 }
2684 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x23,tempbl,tempah); 2721 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x23,tempbl,tempah);
2685 } 2722 }
2686 2723
2687#endif /* SIS315H */ 2724#endif /* SIS315H */
2688 2725
2689 } else if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { 2726 } else if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) {
2690 2727
2691#ifdef SIS300 2728#ifdef SIS300
2692 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x21,0x3f); 2729 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x21,0x3f);
2693 2730
2694 if((SiS_Pr->SiS_VBInfo & DisableCRT2Display) || 2731 if((SiS_Pr->SiS_VBInfo & DisableCRT2Display) ||
2695 ((SiS_Pr->SiS_VBType & VB_NoLCD) && 2732 ((SiS_Pr->SiS_VBType & VB_NoLCD) &&
2696 (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD))) { 2733 (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD))) {
2697 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x23,0x7F); 2734 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x23,0x7F);
2698 } else { 2735 } else {
@@ -2702,9 +2739,9 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2702 2739
2703 } 2740 }
2704 2741
2705 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { 2742 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) {
2706 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x0D,0x80); 2743 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x0D,0x80);
2707 if(SiS_Pr->SiS_VBType & VB_SIS301C) { 2744 if(SiS_Pr->SiS_VBType & VB_SIS30xCLV) {
2708 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x3A,0xC0); 2745 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x3A,0xC0);
2709 } 2746 }
2710 } 2747 }
@@ -2712,16 +2749,16 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2712 } else { /* LVDS */ 2749 } else { /* LVDS */
2713 2750
2714#ifdef SIS315H 2751#ifdef SIS315H
2715 if(HwInfo->jChipType >= SIS_315H) { 2752 if(SiS_Pr->ChipType >= SIS_315H) {
2716 2753
2717 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { 2754 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
2718 2755
2719 tempah = 0x04; 2756 tempah = 0x04;
2720 tempbl = 0xfb; 2757 tempbl = 0xfb;
2721 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { 2758 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
2722 tempah = 0x00; 2759 tempah = 0x00;
2723 if(SiS_IsDualEdge(SiS_Pr, HwInfo)) tempbl = 0xff; 2760 if(SiS_IsDualEdge(SiS_Pr)) tempbl = 0xff;
2724 } 2761 }
2725 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,tempbl,tempah); 2762 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,tempbl,tempah);
2726 2763
2727 if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { 2764 if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) {
@@ -2730,7 +2767,7 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2730 2767
2731 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30); 2768 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30);
2732 2769
2733 } else if(HwInfo->jChipType == SIS_550) { 2770 } else if(SiS_Pr->ChipType == SIS_550) {
2734 2771
2735 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb); 2772 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb);
2736 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30); 2773 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2c,0x30);
@@ -2748,212 +2785,120 @@ SiS_SetCRT2ModeRegs(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2748/* GET RESOLUTION DATA */ 2785/* GET RESOLUTION DATA */
2749/*********************************************/ 2786/*********************************************/
2750 2787
2751USHORT 2788unsigned short
2752SiS_GetResInfo(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex) 2789SiS_GetResInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex)
2753{ 2790{
2754 if(ModeNo <= 0x13) return((USHORT)SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo); 2791 if(ModeNo <= 0x13)
2755 else return((USHORT)SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO); 2792 return ((unsigned short)SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo);
2793 else
2794 return ((unsigned short)SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO);
2756} 2795}
2757 2796
2758static void 2797static void
2759SiS_GetCRT2ResInfo(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, 2798SiS_GetCRT2ResInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex)
2760 PSIS_HW_INFO HwInfo)
2761{ 2799{
2762 USHORT xres,yres,modeflag=0,resindex; 2800 unsigned short xres, yres, modeflag=0, resindex;
2763 2801
2764 if(SiS_Pr->UseCustomMode) { 2802 if(SiS_Pr->UseCustomMode) {
2765 xres = SiS_Pr->CHDisplay; 2803 xres = SiS_Pr->CHDisplay;
2766 if(SiS_Pr->CModeFlag & HalfDCLK) xres *= 2; 2804 if(SiS_Pr->CModeFlag & HalfDCLK) xres <<= 1;
2767 SiS_Pr->SiS_VGAHDE = SiS_Pr->SiS_HDE = xres; 2805 SiS_Pr->SiS_VGAHDE = SiS_Pr->SiS_HDE = xres;
2768 yres = SiS_Pr->CVDisplay; 2806 /* DoubleScanMode-check done in CheckCalcCustomMode()! */
2769 if(SiS_Pr->CModeFlag & DoubleScanMode) yres *= 2; 2807 SiS_Pr->SiS_VGAVDE = SiS_Pr->SiS_VDE = SiS_Pr->CVDisplay;
2770 SiS_Pr->SiS_VGAVDE = SiS_Pr->SiS_VDE = yres; 2808 return;
2771 return; 2809 }
2772 }
2773
2774 resindex = SiS_GetResInfo(SiS_Pr,ModeNo,ModeIdIndex);
2775 2810
2776 if(ModeNo <= 0x13) { 2811 resindex = SiS_GetResInfo(SiS_Pr,ModeNo,ModeIdIndex);
2777 xres = SiS_Pr->SiS_StResInfo[resindex].HTotal;
2778 yres = SiS_Pr->SiS_StResInfo[resindex].VTotal;
2779 } else {
2780 xres = SiS_Pr->SiS_ModeResInfo[resindex].HTotal;
2781 yres = SiS_Pr->SiS_ModeResInfo[resindex].VTotal;
2782 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2783 }
2784 2812
2785 if(!SiS_Pr->SiS_IF_DEF_DSTN && !SiS_Pr->SiS_IF_DEF_FSTN) { 2813 if(ModeNo <= 0x13) {
2814 xres = SiS_Pr->SiS_StResInfo[resindex].HTotal;
2815 yres = SiS_Pr->SiS_StResInfo[resindex].VTotal;
2816 } else {
2817 xres = SiS_Pr->SiS_ModeResInfo[resindex].HTotal;
2818 yres = SiS_Pr->SiS_ModeResInfo[resindex].VTotal;
2819 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2820 }
2786 2821
2787 if((HwInfo->jChipType >= SIS_315H) && (SiS_Pr->SiS_IF_DEF_LVDS == 1)) { 2822 if(!SiS_Pr->SiS_IF_DEF_DSTN && !SiS_Pr->SiS_IF_DEF_FSTN) {
2788 if((ModeNo != 0x03) && (SiS_Pr->SiS_SetFlag & SetDOSMode)) {
2789 if(yres == 350) yres = 400;
2790 }
2791 if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x3a) & 0x01) {
2792 if(ModeNo == 0x12) yres = 400;
2793 }
2794 }
2795 2823
2796 if(modeflag & HalfDCLK) xres *= 2; 2824 if((SiS_Pr->ChipType >= SIS_315H) && (SiS_Pr->SiS_IF_DEF_LVDS == 1)) {
2797 if(modeflag & DoubleScanMode) yres *= 2; 2825 if((ModeNo != 0x03) && (SiS_Pr->SiS_SetFlag & SetDOSMode)) {
2826 if(yres == 350) yres = 400;
2827 }
2828 if(SiS_GetReg(SiS_Pr->SiS_P3d4,0x3a) & 0x01) {
2829 if(ModeNo == 0x12) yres = 400;
2830 }
2831 }
2798 2832
2799 } 2833 if(modeflag & HalfDCLK) xres <<= 1;
2834 if(modeflag & DoubleScanMode) yres <<= 1;
2800 2835
2801 if((SiS_Pr->SiS_VBType & VB_SISVB) && (!(SiS_Pr->SiS_VBType & VB_NoLCD))) { 2836 }
2802 2837
2803#if 0 2838 if((SiS_Pr->SiS_VBType & VB_SISVB) && (!(SiS_Pr->SiS_VBType & VB_NoLCD))) {
2804 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCDA | SetCRT2ToLCD | SetCRT2ToHiVision)) {
2805 if(xres == 720) xres = 640;
2806 }
2807#endif
2808 2839
2809 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 2840 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
2810 switch(SiS_Pr->SiS_LCDResInfo) { 2841 switch(SiS_Pr->SiS_LCDResInfo) {
2811 case Panel_1024x768: 2842 case Panel_1024x768:
2812 if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { 2843 if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) {
2813 if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { 2844 if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) {
2814 if(yres == 350) yres = 357; 2845 if(yres == 350) yres = 357;
2815 if(yres == 400) yres = 420; 2846 if(yres == 400) yres = 420;
2816 if(yres == 480) yres = 525; 2847 if(yres == 480) yres = 525;
2817 } 2848 }
2818 } 2849 }
2819 break; 2850 break;
2820 case Panel_1280x1024: 2851 case Panel_1280x1024:
2821 if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { 2852 if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) {
2822 /* BIOS bug - does this regardless of scaling */ 2853 /* BIOS bug - does this regardless of scaling */
2823 if(yres == 400) yres = 405; 2854 if(yres == 400) yres = 405;
2855 }
2856 if(yres == 350) yres = 360;
2857 if(SiS_Pr->SiS_SetFlag & LCDVESATiming) {
2858 if(yres == 360) yres = 375;
2824 } 2859 }
2825 if(yres == 350) yres = 360;
2826 if(SiS_Pr->SiS_SetFlag & LCDVESATiming) {
2827 if(yres == 360) yres = 375;
2828 }
2829 break; 2860 break;
2830 case Panel_1600x1200: 2861 case Panel_1600x1200:
2831 if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { 2862 if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) {
2832 if(yres == 1024) yres = 1056; 2863 if(yres == 1024) yres = 1056;
2833 } 2864 }
2834 break; 2865 break;
2835 } 2866 }
2836 } 2867 }
2837 2868
2838 } else { 2869 } else {
2839 2870
2840 if(SiS_Pr->SiS_VBType & VB_SISVB) { 2871 if(SiS_Pr->SiS_VBType & VB_SISVB) {
2841 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToHiVision)) { 2872 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToHiVision)) {
2842 if(xres == 720) xres = 640; 2873 if(xres == 720) xres = 640;
2843 } 2874 }
2844 } else if(xres == 720) xres = 640; 2875 } else if(xres == 720) xres = 640;
2845 2876
2846 if(SiS_Pr->SiS_SetFlag & SetDOSMode) { 2877 if(SiS_Pr->SiS_SetFlag & SetDOSMode) {
2847 yres = 400; 2878 yres = 400;
2848 if(HwInfo->jChipType >= SIS_315H) { 2879 if(SiS_Pr->ChipType >= SIS_315H) {
2849 if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x17) & 0x80) yres = 480; 2880 if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x17) & 0x80) yres = 480;
2850 } else { 2881 } else {
2851 if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x80) yres = 480; 2882 if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x80) yres = 480;
2852 } 2883 }
2853 if(SiS_Pr->SiS_IF_DEF_DSTN || SiS_Pr->SiS_IF_DEF_FSTN) yres = 480; 2884 if(SiS_Pr->SiS_IF_DEF_DSTN || SiS_Pr->SiS_IF_DEF_FSTN) yres = 480;
2854 } 2885 }
2855 2886
2856 } 2887 }
2857 SiS_Pr->SiS_VGAHDE = SiS_Pr->SiS_HDE = xres; 2888 SiS_Pr->SiS_VGAHDE = SiS_Pr->SiS_HDE = xres;
2858 SiS_Pr->SiS_VGAVDE = SiS_Pr->SiS_VDE = yres; 2889 SiS_Pr->SiS_VGAVDE = SiS_Pr->SiS_VDE = yres;
2859} 2890}
2860 2891
2861/*********************************************/ 2892/*********************************************/
2862/* GET CRT2 TIMING DATA */ 2893/* GET CRT2 TIMING DATA */
2863/*********************************************/ 2894/*********************************************/
2864 2895
2865static BOOLEAN
2866SiS_GetLVDSCRT1Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
2867 USHORT RefreshRateTableIndex, USHORT *ResIndex,
2868 USHORT *DisplayType)
2869 {
2870 USHORT modeflag=0;
2871
2872 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
2873 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
2874 if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) return FALSE;
2875 }
2876 } else if(SiS_Pr->SiS_VBType & VB_SISVB) {
2877 if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) return FALSE;
2878 } else
2879 return FALSE;
2880
2881 if(ModeNo <= 0x13) {
2882 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
2883 (*ResIndex) = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
2884 } else {
2885 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2886 (*ResIndex) = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
2887 }
2888
2889 (*ResIndex) &= 0x3F;
2890
2891 if((SiS_Pr->SiS_IF_DEF_CH70xx) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) {
2892 (*DisplayType) = 18;
2893 if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) (*DisplayType)++;
2894 if(SiS_Pr->SiS_TVMode & TVSetPAL) {
2895 (*DisplayType) += 2;
2896 if(SiS_Pr->SiS_ModeType > ModeVGA) {
2897 if(SiS_Pr->SiS_CHSOverScan) (*DisplayType) = 99;
2898 }
2899 if(SiS_Pr->SiS_TVMode & TVSetPALM) {
2900 (*DisplayType) = 18; /* PALM uses NTSC data */
2901 if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) (*DisplayType)++;
2902 } else if(SiS_Pr->SiS_TVMode & TVSetPALN) {
2903 (*DisplayType) = 20; /* PALN uses PAL data */
2904 if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) (*DisplayType)++;
2905 }
2906 }
2907 } else {
2908 switch(SiS_Pr->SiS_LCDResInfo) {
2909 case Panel_640x480: (*DisplayType) = 50; break;
2910 case Panel_640x480_2: (*DisplayType) = 52; break;
2911 case Panel_640x480_3: (*DisplayType) = 54; break;
2912 case Panel_800x600: (*DisplayType) = 0; break;
2913 case Panel_1024x600: (*DisplayType) = 23; break;
2914 case Panel_1024x768: (*DisplayType) = 4; break;
2915 case Panel_1152x768: (*DisplayType) = 27; break;
2916 case Panel_1280x768: (*DisplayType) = 40; break;
2917 case Panel_1280x1024: (*DisplayType) = 8; break;
2918 case Panel_1400x1050: (*DisplayType) = 14; break;
2919 case Panel_1600x1200: (*DisplayType) = 36; break;
2920 default: return FALSE;
2921 }
2922
2923 if(modeflag & HalfDCLK) (*DisplayType)++;
2924
2925 switch(SiS_Pr->SiS_LCDResInfo) {
2926 case Panel_640x480:
2927 case Panel_640x480_2:
2928 case Panel_640x480_3:
2929 break;
2930 default:
2931 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) (*DisplayType) += 2;
2932 }
2933
2934 if(SiS_Pr->SiS_LCDInfo & LCDPass11) {
2935 (*DisplayType) = 12;
2936 if(modeflag & HalfDCLK) (*DisplayType)++;
2937 }
2938 }
2939
2940#if 0
2941 if(SiS_Pr->SiS_IF_DEF_FSTN) {
2942 if(SiS_Pr->SiS_LCDResInfo == SiS_Pr->SiS_Panel320x480){
2943 (*DisplayType) = 22;
2944 }
2945 }
2946#endif
2947
2948 return TRUE;
2949}
2950
2951static void 2896static void
2952SiS_GetCRT2Ptr(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, 2897SiS_GetCRT2Ptr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex,
2953 USHORT RefreshRateTableIndex,USHORT *CRT2Index,USHORT *ResIndex, 2898 unsigned short RefreshRateTableIndex, unsigned short *CRT2Index,
2954 PSIS_HW_INFO HwInfo) 2899 unsigned short *ResIndex)
2955{ 2900{
2956 USHORT tempbx=0,tempal=0,resinfo=0; 2901 unsigned short tempbx=0, tempal=0, resinfo=0;
2957 2902
2958 if(ModeNo <= 0x13) { 2903 if(ModeNo <= 0x13) {
2959 tempal = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; 2904 tempal = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
@@ -2966,18 +2911,20 @@ SiS_GetCRT2Ptr(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex,
2966 2911
2967 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { /* LCD */ 2912 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { /* LCD */
2968 2913
2969 tempbx = SiS_Pr->SiS_LCDResInfo; 2914 tempbx = SiS_Pr->SiS_LCDResInfo;
2970 if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx += 32; 2915 if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx += 32;
2971 2916
2917 /* patch index */
2972 if(SiS_Pr->SiS_LCDResInfo == Panel_1680x1050) { 2918 if(SiS_Pr->SiS_LCDResInfo == Panel_1680x1050) {
2973 if (resinfo == SIS_RI_1280x800) tempal = 9; 2919 if (resinfo == SIS_RI_1280x800) tempal = 9;
2974 else if(resinfo == SIS_RI_1400x1050) tempal = 11; 2920 else if(resinfo == SIS_RI_1400x1050) tempal = 11;
2975 } else if((SiS_Pr->SiS_LCDResInfo == Panel_1280x800) || 2921 } else if((SiS_Pr->SiS_LCDResInfo == Panel_1280x800) ||
2976 (SiS_Pr->SiS_LCDResInfo == Panel_1280x800_2)) { 2922 (SiS_Pr->SiS_LCDResInfo == Panel_1280x800_2) ||
2923 (SiS_Pr->SiS_LCDResInfo == Panel_1280x854)) {
2977 if (resinfo == SIS_RI_1280x768) tempal = 9; 2924 if (resinfo == SIS_RI_1280x768) tempal = 9;
2978 } 2925 }
2979 2926
2980 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { 2927 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
2981 /* Pass 1:1 only (center-screen handled outside) */ 2928 /* Pass 1:1 only (center-screen handled outside) */
2982 /* This is never called for the panel's native resolution */ 2929 /* This is never called for the panel's native resolution */
2983 /* since Pass1:1 will not be set in this case */ 2930 /* since Pass1:1 will not be set in this case */
@@ -2991,8 +2938,8 @@ SiS_GetCRT2Ptr(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex,
2991 if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) { 2938 if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) {
2992 if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) { 2939 if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) {
2993 if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { 2940 if(!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) {
2994 tempbx = 200; 2941 tempbx = 200;
2995 if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx++; 2942 if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) tempbx++;
2996 } 2943 }
2997 } 2944 }
2998 } 2945 }
@@ -3000,23 +2947,23 @@ SiS_GetCRT2Ptr(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex,
3000 2947
3001 } else { /* TV */ 2948 } else { /* TV */
3002 2949
3003 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { 2950 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {
3004 /* if(SiS_Pr->SiS_VGAVDE > 480) SiS_Pr->SiS_TVMode &= (~TVSetTVSimuMode); */ 2951 /* if(SiS_Pr->SiS_VGAVDE > 480) SiS_Pr->SiS_TVMode &= (~TVSetTVSimuMode); */
3005 tempbx = 2; 2952 tempbx = 2;
3006 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { 2953 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
3007 tempbx = 13; 2954 tempbx = 13;
3008 if(!(SiS_Pr->SiS_TVMode & TVSetTVSimuMode)) tempbx = 14; 2955 if(!(SiS_Pr->SiS_TVMode & TVSetTVSimuMode)) tempbx = 14;
3009 } 2956 }
3010 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { 2957 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) {
3011 if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) tempbx = 7; 2958 if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) tempbx = 7;
3012 else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) tempbx = 6; 2959 else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) tempbx = 6;
3013 else tempbx = 5; 2960 else tempbx = 5;
3014 if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) tempbx += 5; 2961 if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) tempbx += 5;
3015 } else { 2962 } else {
3016 if(SiS_Pr->SiS_TVMode & TVSetPAL) tempbx = 3; 2963 if(SiS_Pr->SiS_TVMode & TVSetPAL) tempbx = 3;
3017 else tempbx = 4; 2964 else tempbx = 4;
3018 if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) tempbx += 5; 2965 if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) tempbx += 5;
3019 } 2966 }
3020 2967
3021 } 2968 }
3022 2969
@@ -3024,26 +2971,34 @@ SiS_GetCRT2Ptr(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex,
3024 2971
3025 if(ModeNo > 0x13) { 2972 if(ModeNo > 0x13) {
3026 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoHiVision) { 2973 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoHiVision) {
3027 if(tempal == 6) tempal = 7; 2974 switch(resinfo) {
3028 if((resinfo == SIS_RI_720x480) || 2975 case SIS_RI_720x480:
3029 (resinfo == SIS_RI_720x576) ||
3030 (resinfo == SIS_RI_768x576)) {
3031 tempal = 6; 2976 tempal = 6;
3032 if(SiS_Pr->SiS_TVMode & (TVSetPAL | TVSetPALN)) { 2977 if(SiS_Pr->SiS_TVMode & (TVSetPAL | TVSetPALN)) tempal = 9;
3033 if(resinfo == SIS_RI_720x480) tempal = 9; 2978 break;
2979 case SIS_RI_720x576:
2980 case SIS_RI_768x576:
2981 case SIS_RI_1024x576: /* Not in NTSC or YPBPR mode (except 1080i)! */
2982 tempal = 6;
2983 if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) {
2984 if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) tempal = 8;
3034 } 2985 }
3035 } 2986 break;
3036 if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { 2987 case SIS_RI_800x480:
3037 if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) { 2988 tempal = 4;
3038 if(resinfo == SIS_RI_1024x768) tempal = 8; 2989 break;
2990 case SIS_RI_512x384:
2991 case SIS_RI_1024x768:
2992 tempal = 7;
2993 if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) {
2994 if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) tempal = 8;
3039 } 2995 }
3040 if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) { 2996 break;
3041 if((resinfo == SIS_RI_720x576) || 2997 case SIS_RI_1280x720:
3042 (resinfo == SIS_RI_768x576)) { 2998 if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) {
3043 tempal = 8; 2999 if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) tempal = 9;
3044 }
3045 if(resinfo == SIS_RI_1280x720) tempal = 9;
3046 } 3000 }
3001 break;
3047 } 3002 }
3048 } 3003 }
3049 } 3004 }
@@ -3056,65 +3011,60 @@ SiS_GetCRT2Ptr(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex,
3056 tempbx = 0; 3011 tempbx = 0;
3057 if((SiS_Pr->SiS_IF_DEF_CH70xx) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) { 3012 if((SiS_Pr->SiS_IF_DEF_CH70xx) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) {
3058 3013
3059 tempbx = 10; 3014 tempbx = 90;
3060 if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1; 3015 if(SiS_Pr->SiS_TVMode & TVSetPAL) {
3061 if(SiS_Pr->SiS_TVMode & TVSetPAL) { 3016 tempbx = 92;
3062 tempbx += 2;
3063 if(SiS_Pr->SiS_ModeType > ModeVGA) { 3017 if(SiS_Pr->SiS_ModeType > ModeVGA) {
3064 if(SiS_Pr->SiS_CHSOverScan) tempbx = 99; 3018 if(SiS_Pr->SiS_CHSOverScan) tempbx = 99;
3065 } 3019 }
3066 if(SiS_Pr->SiS_TVMode & TVSetPALM) { 3020 if(SiS_Pr->SiS_TVMode & TVSetPALM) tempbx = 94;
3067 tempbx = 90; 3021 else if(SiS_Pr->SiS_TVMode & TVSetPALN) tempbx = 96;
3068 if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1; 3022 }
3069 } else if(SiS_Pr->SiS_TVMode & TVSetPALN) { 3023 if(tempbx != 99) {
3070 tempbx = 92; 3024 if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx++;
3071 if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) tempbx += 1; 3025 }
3072 }
3073 }
3074 3026
3075 } else { 3027 } else {
3076 3028
3077 switch(SiS_Pr->SiS_LCDResInfo) { 3029 switch(SiS_Pr->SiS_LCDResInfo) {
3078 case Panel_640x480: tempbx = 6; break; 3030 case Panel_640x480: tempbx = 12; break;
3079 case Panel_640x480_2: 3031 case Panel_320x240_1: tempbx = 10; break;
3080 case Panel_640x480_3: tempbx = 30; break; 3032 case Panel_320x240_2:
3081 case Panel_800x600: tempbx = 0; break; 3033 case Panel_320x240_3: tempbx = 14; break;
3082 case Panel_1024x600: tempbx = 15; break; 3034 case Panel_800x600: tempbx = 16; break;
3083 case Panel_1024x768: tempbx = 2; break; 3035 case Panel_1024x600: tempbx = 18; break;
3084 case Panel_1152x768: tempbx = 17; break; 3036 case Panel_1152x768:
3085 case Panel_1280x768: tempbx = 18; break; 3037 case Panel_1024x768: tempbx = 20; break;
3086 case Panel_1280x1024: tempbx = 4; break; 3038 case Panel_1280x768: tempbx = 22; break;
3087 case Panel_1400x1050: tempbx = 8; break; 3039 case Panel_1280x1024: tempbx = 24; break;
3088 case Panel_1600x1200: tempbx = 21; break; 3040 case Panel_1400x1050: tempbx = 26; break;
3041 case Panel_1600x1200: tempbx = 28; break;
3042#ifdef SIS300
3089 case Panel_Barco1366: tempbx = 80; break; 3043 case Panel_Barco1366: tempbx = 80; break;
3044#endif
3090 } 3045 }
3091 3046
3092 switch(SiS_Pr->SiS_LCDResInfo) { 3047 switch(SiS_Pr->SiS_LCDResInfo) {
3048 case Panel_320x240_1:
3049 case Panel_320x240_2:
3050 case Panel_320x240_3:
3093 case Panel_640x480: 3051 case Panel_640x480:
3094 case Panel_640x480_2:
3095 case Panel_640x480_3:
3096 break; 3052 break;
3097 default: 3053 default:
3098 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; 3054 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++;
3099 } 3055 }
3100 3056
3101 if(SiS_Pr->SiS_LCDInfo & LCDPass11) tempbx = 7; 3057 if(SiS_Pr->SiS_LCDInfo & LCDPass11) tempbx = 30;
3102 3058
3059#ifdef SIS300
3103 if(SiS_Pr->SiS_CustomT == CUT_BARCO1024) { 3060 if(SiS_Pr->SiS_CustomT == CUT_BARCO1024) {
3104 tempbx = 82; 3061 tempbx = 82;
3105 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; 3062 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++;
3106 } else if(SiS_Pr->SiS_CustomT == CUT_PANEL848) { 3063 } else if(SiS_Pr->SiS_CustomT == CUT_PANEL848 || SiS_Pr->SiS_CustomT == CUT_PANEL856) {
3107 tempbx = 84; 3064 tempbx = 84;
3108 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++; 3065 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) tempbx++;
3109 } 3066 }
3110 3067#endif
3111 if((SiS_Pr->SiS_CustomT != CUT_BARCO1366) &&
3112 (SiS_Pr->SiS_CustomT != CUT_PANEL848)) {
3113 if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) &&
3114 (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) {
3115 tempal = 0;
3116 }
3117 }
3118 3068
3119 } 3069 }
3120 3070
@@ -3124,12 +3074,11 @@ SiS_GetCRT2Ptr(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex,
3124} 3074}
3125 3075
3126static void 3076static void
3127SiS_GetRAMDAC2DATA(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, 3077SiS_GetRAMDAC2DATA(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex,
3128 USHORT RefreshRateTableIndex,PSIS_HW_INFO HwInfo) 3078 unsigned short RefreshRateTableIndex)
3129{ 3079{
3130 USHORT tempax=0,tempbx=0; 3080 unsigned short tempax=0, tempbx=0, index, dotclock;
3131 USHORT temp1=0,modeflag=0,tempcx=0; 3081 unsigned short temp1=0, modeflag=0, tempcx=0;
3132 USHORT index;
3133 3082
3134 SiS_Pr->SiS_RVBHCMAX = 1; 3083 SiS_Pr->SiS_RVBHCMAX = 1;
3135 SiS_Pr->SiS_RVBHCFACT = 1; 3084 SiS_Pr->SiS_RVBHCFACT = 1;
@@ -3143,10 +3092,12 @@ SiS_GetRAMDAC2DATA(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex,
3143 tempbx = SiS_Pr->SiS_StandTable[index].CRTC[6]; 3092 tempbx = SiS_Pr->SiS_StandTable[index].CRTC[6];
3144 temp1 = SiS_Pr->SiS_StandTable[index].CRTC[7]; 3093 temp1 = SiS_Pr->SiS_StandTable[index].CRTC[7];
3145 3094
3095 dotclock = (modeflag & Charx8Dot) ? 8 : 9;
3096
3146 } else { 3097 } else {
3147 3098
3148 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; 3099 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3149 index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; 3100 index = SiS_GetRefCRT1CRTC(SiS_Pr, RefreshRateTableIndex, SiS_Pr->SiS_UseWideCRT2);
3150 3101
3151 tempax = SiS_Pr->SiS_CRT1Table[index].CR[0]; 3102 tempax = SiS_Pr->SiS_CRT1Table[index].CR[0];
3152 tempax |= (SiS_Pr->SiS_CRT1Table[index].CR[14] << 8); 3103 tempax |= (SiS_Pr->SiS_CRT1Table[index].CR[14] << 8);
@@ -3158,22 +3109,16 @@ SiS_GetRAMDAC2DATA(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex,
3158 tempbx |= tempcx; 3109 tempbx |= tempcx;
3159 temp1 = SiS_Pr->SiS_CRT1Table[index].CR[7]; 3110 temp1 = SiS_Pr->SiS_CRT1Table[index].CR[7];
3160 3111
3112 dotclock = 8;
3113
3161 } 3114 }
3162 3115
3163 if(temp1 & 0x01) tempbx |= 0x0100; 3116 if(temp1 & 0x01) tempbx |= 0x0100;
3164 if(temp1 & 0x20) tempbx |= 0x0200; 3117 if(temp1 & 0x20) tempbx |= 0x0200;
3165 3118
3166 tempax += 5; 3119 tempax += 5;
3167 3120 tempax *= dotclock;
3168 /* Charx8Dot is no more used (and assumed), so we set it */ 3121 if(modeflag & HalfDCLK) tempax <<= 1;
3169 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
3170 modeflag |= Charx8Dot;
3171 }
3172
3173 if(modeflag & Charx8Dot) tempax *= 8;
3174 else tempax *= 9;
3175
3176 if(modeflag & HalfDCLK) tempax <<= 1;
3177 3122
3178 tempbx++; 3123 tempbx++;
3179 3124
@@ -3182,13 +3127,56 @@ SiS_GetRAMDAC2DATA(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex,
3182} 3127}
3183 3128
3184static void 3129static void
3185SiS_GetCRT2DataLVDS(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, 3130SiS_CalcPanelLinkTiming(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
3186 USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) 3131 unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex)
3132{
3133 unsigned short ResIndex;
3134
3135 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
3136 if(SiS_Pr->SiS_LCDInfo & LCDPass11) {
3137 if(SiS_Pr->UseCustomMode) {
3138 ResIndex = SiS_Pr->CHTotal;
3139 if(SiS_Pr->CModeFlag & HalfDCLK) ResIndex <<= 1;
3140 SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = ResIndex;
3141 SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_VT = SiS_Pr->CVTotal;
3142 } else {
3143 if(ModeNo < 0x13) {
3144 ResIndex = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
3145 } else {
3146 ResIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC_NS;
3147 }
3148 if(ResIndex == 0x09) {
3149 if(SiS_Pr->Alternate1600x1200) ResIndex = 0x20; /* 1600x1200 LCDA */
3150 else if(SiS_Pr->SiS_IF_DEF_LVDS == 1) ResIndex = 0x21; /* 1600x1200 LVDS */
3151 }
3152 SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_NoScaleData[ResIndex].VGAHT;
3153 SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_NoScaleData[ResIndex].VGAVT;
3154 SiS_Pr->SiS_HT = SiS_Pr->SiS_NoScaleData[ResIndex].LCDHT;
3155 SiS_Pr->SiS_VT = SiS_Pr->SiS_NoScaleData[ResIndex].LCDVT;
3156 }
3157 } else {
3158 SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = SiS_Pr->PanelHT;
3159 SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_VT = SiS_Pr->PanelVT;
3160 }
3161 } else {
3162 /* This handles custom modes and custom panels */
3163 SiS_Pr->SiS_HDE = SiS_Pr->PanelXRes;
3164 SiS_Pr->SiS_VDE = SiS_Pr->PanelYRes;
3165 SiS_Pr->SiS_HT = SiS_Pr->PanelHT;
3166 SiS_Pr->SiS_VT = SiS_Pr->PanelVT;
3167 SiS_Pr->SiS_VGAHT = SiS_Pr->PanelHT - (SiS_Pr->PanelXRes - SiS_Pr->SiS_VGAHDE);
3168 SiS_Pr->SiS_VGAVT = SiS_Pr->PanelVT - (SiS_Pr->PanelYRes - SiS_Pr->SiS_VGAVDE);
3169 }
3170}
3171
3172static void
3173SiS_GetCRT2DataLVDS(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex,
3174 unsigned short RefreshRateTableIndex)
3187{ 3175{
3188 USHORT CRT2Index, ResIndex; 3176 unsigned short CRT2Index, ResIndex, backup;
3189 const SiS_LVDSDataStruct *LVDSData = NULL; 3177 const struct SiS_LVDSData *LVDSData = NULL;
3190 3178
3191 SiS_GetCRT2ResInfo(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); 3179 SiS_GetCRT2ResInfo(SiS_Pr, ModeNo, ModeIdIndex);
3192 3180
3193 if(SiS_Pr->SiS_VBType & VB_SISVB) { 3181 if(SiS_Pr->SiS_VBType & VB_SISVB) {
3194 SiS_Pr->SiS_RVBHCMAX = 1; 3182 SiS_Pr->SiS_RVBHCMAX = 1;
@@ -3199,133 +3187,94 @@ SiS_GetCRT2DataLVDS(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex,
3199 SiS_Pr->SiS_RY2COE = 0; 3187 SiS_Pr->SiS_RY2COE = 0;
3200 SiS_Pr->SiS_RY3COE = 0; 3188 SiS_Pr->SiS_RY3COE = 0;
3201 SiS_Pr->SiS_RY4COE = 0; 3189 SiS_Pr->SiS_RY4COE = 0;
3190 SiS_Pr->SiS_RVBHRS2 = 0;
3202 } 3191 }
3203 3192
3204 if((SiS_Pr->SiS_VBType & VB_SISVB) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { 3193 if((SiS_Pr->SiS_VBType & VB_SISVB) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
3205 3194
3206#ifdef SIS315H 3195#ifdef SIS315H
3207 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { 3196 SiS_CalcPanelLinkTiming(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
3208 if(SiS_Pr->SiS_LCDInfo & LCDPass11) { 3197 SiS_CalcLCDACRT1Timing(SiS_Pr, ModeNo, ModeIdIndex);
3209 if(SiS_Pr->UseCustomMode) {
3210 SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = SiS_Pr->CHTotal;
3211 SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_VT = SiS_Pr->CVTotal;
3212 } else {
3213 if(ModeNo < 0x13) {
3214 ResIndex = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
3215 } else {
3216 ResIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC_NS;
3217 }
3218 SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_NoScaleData[ResIndex].VGAHT;
3219 SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_NoScaleData[ResIndex].VGAVT;
3220 SiS_Pr->SiS_HT = SiS_Pr->SiS_NoScaleData[ResIndex].LCDHT;
3221 SiS_Pr->SiS_VT = SiS_Pr->SiS_NoScaleData[ResIndex].LCDVT;
3222 }
3223 } else {
3224 SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = SiS_Pr->PanelHT;
3225 SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_VT = SiS_Pr->PanelVT;
3226 }
3227 } else {
3228 /* This handles custom modes and custom panels */
3229 SiS_Pr->SiS_HDE = SiS_Pr->PanelXRes;
3230 SiS_Pr->SiS_VDE = SiS_Pr->PanelYRes;
3231 SiS_Pr->SiS_HT = SiS_Pr->PanelHT;
3232 SiS_Pr->SiS_VT = SiS_Pr->PanelVT;
3233 SiS_Pr->SiS_VGAHT = SiS_Pr->PanelHT - (SiS_Pr->PanelXRes - SiS_Pr->SiS_VGAHDE);
3234 SiS_Pr->SiS_VGAVT = SiS_Pr->PanelVT - (SiS_Pr->PanelYRes - SiS_Pr->SiS_VGAVDE);
3235 }
3236
3237 SiS_CalcLCDACRT1Timing(SiS_Pr,ModeNo,ModeIdIndex);
3238
3239#endif 3198#endif
3240 3199
3241 } else { 3200 } else {
3242 3201
3243 /* 301BDH needs LVDS Data */ 3202 /* 301BDH needs LVDS Data */
3203 backup = SiS_Pr->SiS_IF_DEF_LVDS;
3244 if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { 3204 if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) {
3245 SiS_Pr->SiS_IF_DEF_LVDS = 1; 3205 SiS_Pr->SiS_IF_DEF_LVDS = 1;
3246 } 3206 }
3247 3207
3248 SiS_GetCRT2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, 3208 SiS_GetCRT2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex,
3249 &CRT2Index, &ResIndex, HwInfo); 3209 &CRT2Index, &ResIndex);
3250 3210
3251 /* 301BDH needs LVDS Data */ 3211 SiS_Pr->SiS_IF_DEF_LVDS = backup;
3252 if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) {
3253 SiS_Pr->SiS_IF_DEF_LVDS = 0;
3254 }
3255 3212
3256 switch (CRT2Index) { 3213 switch(CRT2Index) {
3257 case 0: LVDSData = SiS_Pr->SiS_LVDS800x600Data_1; break; 3214 case 10: LVDSData = SiS_Pr->SiS_LVDS320x240Data_1; break;
3258 case 1: LVDSData = SiS_Pr->SiS_LVDS800x600Data_2; break; 3215 case 14: LVDSData = SiS_Pr->SiS_LVDS320x240Data_2; break;
3259 case 2: LVDSData = SiS_Pr->SiS_LVDS1024x768Data_1; break; 3216 case 12: LVDSData = SiS_Pr->SiS_LVDS640x480Data_1; break;
3260 case 3: LVDSData = SiS_Pr->SiS_LVDS1024x768Data_2; break; 3217 case 16: LVDSData = SiS_Pr->SiS_LVDS800x600Data_1; break;
3261 case 4: LVDSData = SiS_Pr->SiS_LVDS1280x1024Data_1; break; 3218 case 18: LVDSData = SiS_Pr->SiS_LVDS1024x600Data_1; break;
3262 case 5: LVDSData = SiS_Pr->SiS_LVDS1280x1024Data_2; break; 3219 case 20: LVDSData = SiS_Pr->SiS_LVDS1024x768Data_1; break;
3263 case 6: LVDSData = SiS_Pr->SiS_LVDS640x480Data_1; break; 3220#ifdef SIS300
3264 case 7: LVDSData = SiS_Pr->SiS_LVDSXXXxXXXData_1; break;
3265 case 8: LVDSData = SiS_Pr->SiS_LVDS1400x1050Data_1; break;
3266 case 9: LVDSData = SiS_Pr->SiS_LVDS1400x1050Data_2; break;
3267 case 10: LVDSData = SiS_Pr->SiS_CHTVUNTSCData; break;
3268 case 11: LVDSData = SiS_Pr->SiS_CHTVONTSCData; break;
3269 case 12: LVDSData = SiS_Pr->SiS_CHTVUPALData; break;
3270 case 13: LVDSData = SiS_Pr->SiS_CHTVOPALData; break;
3271 case 14: LVDSData = SiS_Pr->SiS_LVDS320x480Data_1; break;
3272 case 15: LVDSData = SiS_Pr->SiS_LVDS1024x600Data_1; break;
3273 case 16: LVDSData = SiS_Pr->SiS_LVDS1024x600Data_2; break;
3274 case 17: LVDSData = SiS_Pr->SiS_LVDS1152x768Data_1; break;
3275 case 18: LVDSData = SiS_Pr->SiS_LVDS1152x768Data_2; break;
3276 case 19: LVDSData = SiS_Pr->SiS_LVDS1280x768Data_1; break;
3277 case 20: LVDSData = SiS_Pr->SiS_LVDS1280x768Data_2; break;
3278 case 21: LVDSData = SiS_Pr->SiS_LVDS1600x1200Data_1; break;
3279 case 22: LVDSData = SiS_Pr->SiS_LVDS1600x1200Data_2; break;
3280 case 30: LVDSData = SiS_Pr->SiS_LVDS640x480Data_2; break;
3281 case 80: LVDSData = SiS_Pr->SiS_LVDSBARCO1366Data_1; break; 3221 case 80: LVDSData = SiS_Pr->SiS_LVDSBARCO1366Data_1; break;
3282 case 81: LVDSData = SiS_Pr->SiS_LVDSBARCO1366Data_2; break; 3222 case 81: LVDSData = SiS_Pr->SiS_LVDSBARCO1366Data_2; break;
3283 case 82: LVDSData = SiS_Pr->SiS_LVDSBARCO1024Data_1; break; 3223 case 82: LVDSData = SiS_Pr->SiS_LVDSBARCO1024Data_1; break;
3284 case 83: LVDSData = SiS_Pr->SiS_LVDSBARCO1024Data_2; break;
3285 case 84: LVDSData = SiS_Pr->SiS_LVDS848x480Data_1; break; 3224 case 84: LVDSData = SiS_Pr->SiS_LVDS848x480Data_1; break;
3286 case 85: LVDSData = SiS_Pr->SiS_LVDS848x480Data_2; break; 3225 case 85: LVDSData = SiS_Pr->SiS_LVDS848x480Data_2; break;
3287 case 90: LVDSData = SiS_Pr->SiS_CHTVUPALMData; break; 3226#endif
3288 case 91: LVDSData = SiS_Pr->SiS_CHTVOPALMData; break; 3227 case 90: LVDSData = SiS_Pr->SiS_CHTVUNTSCData; break;
3289 case 92: LVDSData = SiS_Pr->SiS_CHTVUPALNData; break; 3228 case 91: LVDSData = SiS_Pr->SiS_CHTVONTSCData; break;
3290 case 93: LVDSData = SiS_Pr->SiS_CHTVOPALNData; break; 3229 case 92: LVDSData = SiS_Pr->SiS_CHTVUPALData; break;
3291 case 99: LVDSData = SiS_Pr->SiS_CHTVSOPALData; break; /* Super Overscan */ 3230 case 93: LVDSData = SiS_Pr->SiS_CHTVOPALData; break;
3292 default: LVDSData = SiS_Pr->SiS_LVDS1024x768Data_1; break; 3231 case 94: LVDSData = SiS_Pr->SiS_CHTVUPALMData; break;
3232 case 95: LVDSData = SiS_Pr->SiS_CHTVOPALMData; break;
3233 case 96: LVDSData = SiS_Pr->SiS_CHTVUPALNData; break;
3234 case 97: LVDSData = SiS_Pr->SiS_CHTVOPALNData; break;
3235 case 99: LVDSData = SiS_Pr->SiS_CHTVSOPALData; break;
3293 } 3236 }
3294 3237
3295 SiS_Pr->SiS_VGAHT = (LVDSData+ResIndex)->VGAHT; 3238 if(LVDSData) {
3296 SiS_Pr->SiS_VGAVT = (LVDSData+ResIndex)->VGAVT; 3239 SiS_Pr->SiS_VGAHT = (LVDSData+ResIndex)->VGAHT;
3297 SiS_Pr->SiS_HT = (LVDSData+ResIndex)->LCDHT; 3240 SiS_Pr->SiS_VGAVT = (LVDSData+ResIndex)->VGAVT;
3298 SiS_Pr->SiS_VT = (LVDSData+ResIndex)->LCDVT; 3241 SiS_Pr->SiS_HT = (LVDSData+ResIndex)->LCDHT;
3299 3242 SiS_Pr->SiS_VT = (LVDSData+ResIndex)->LCDVT;
3300 if(!(SiS_Pr->SiS_VBType & VB_SISVB)) { 3243 } else {
3301 if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) { 3244 SiS_CalcPanelLinkTiming(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
3302 if((!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) || (SiS_Pr->SiS_SetFlag & SetDOSMode)) { 3245 }
3303 SiS_Pr->SiS_HDE = SiS_Pr->PanelXRes; 3246
3304 SiS_Pr->SiS_VDE = SiS_Pr->PanelYRes; 3247 if( (!(SiS_Pr->SiS_VBType & VB_SISVB)) &&
3305 if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) { 3248 (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) &&
3306 if(ResIndex < 0x08) { 3249 (!(SiS_Pr->SiS_LCDInfo & LCDPass11)) ) {
3307 SiS_Pr->SiS_HDE = 1280; 3250 if( (!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) ||
3308 SiS_Pr->SiS_VDE = 1024; 3251 (SiS_Pr->SiS_SetFlag & SetDOSMode) ) {
3309 } 3252 SiS_Pr->SiS_HDE = SiS_Pr->PanelXRes;
3310 } 3253 SiS_Pr->SiS_VDE = SiS_Pr->PanelYRes;
3311 } 3254#ifdef SIS300
3255 if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) {
3256 if(ResIndex < 0x08) {
3257 SiS_Pr->SiS_HDE = 1280;
3258 SiS_Pr->SiS_VDE = 1024;
3259 }
3260 }
3261#endif
3312 } 3262 }
3313 } 3263 }
3314 } 3264 }
3315} 3265}
3316 3266
3317static void 3267static void
3318SiS_GetCRT2Data301(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, 3268SiS_GetCRT2Data301(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex,
3319 USHORT RefreshRateTableIndex, 3269 unsigned short RefreshRateTableIndex)
3320 PSIS_HW_INFO HwInfo) 3270{
3321{ 3271 unsigned char *ROMAddr = NULL;
3322 UCHAR *ROMAddr = NULL; 3272 unsigned short tempax, tempbx, modeflag, romptr=0;
3323 USHORT tempax,tempbx,modeflag,romptr=0; 3273 unsigned short resinfo, CRT2Index, ResIndex;
3324 USHORT resinfo,CRT2Index,ResIndex; 3274 const struct SiS_LCDData *LCDPtr = NULL;
3325 const SiS_LCDDataStruct *LCDPtr = NULL; 3275 const struct SiS_TVData *TVPtr = NULL;
3326 const SiS_TVDataStruct *TVPtr = NULL;
3327#ifdef SIS315H 3276#ifdef SIS315H
3328 SHORT resinfo661; 3277 short resinfo661;
3329#endif 3278#endif
3330 3279
3331 if(ModeNo <= 0x13) { 3280 if(ModeNo <= 0x13) {
@@ -3340,67 +3289,69 @@ SiS_GetCRT2Data301(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex,
3340#ifdef SIS315H 3289#ifdef SIS315H
3341 resinfo661 = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].ROMMODEIDX661; 3290 resinfo661 = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].ROMMODEIDX661;
3342 if( (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && 3291 if( (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) &&
3343 (SiS_Pr->SiS_SetFlag & LCDVESATiming) && 3292 (SiS_Pr->SiS_SetFlag & LCDVESATiming) &&
3344 (resinfo661 >= 0) && 3293 (resinfo661 >= 0) &&
3345 (SiS_Pr->SiS_NeedRomModeData) ) { 3294 (SiS_Pr->SiS_NeedRomModeData) ) {
3346 if((ROMAddr = GetLCDStructPtr661(SiS_Pr, HwInfo))) { 3295 if((ROMAddr = GetLCDStructPtr661(SiS_Pr))) {
3347 if((romptr = (SISGETROMW(21)))) { 3296 if((romptr = (SISGETROMW(21)))) {
3348 romptr += (resinfo661 * 10); 3297 romptr += (resinfo661 * 10);
3349 ROMAddr = HwInfo->pjVirtualRomBase; 3298 ROMAddr = SiS_Pr->VirtualRomBase;
3350 } 3299 }
3351 } 3300 }
3352 } 3301 }
3353#endif 3302#endif
3354 } 3303 }
3355 3304
3356 SiS_Pr->SiS_NewFlickerMode = 0; 3305 SiS_Pr->SiS_NewFlickerMode = 0;
3357 SiS_Pr->SiS_RVBHRS = 50; 3306 SiS_Pr->SiS_RVBHRS = 50;
3358 SiS_Pr->SiS_RY1COE = 0; 3307 SiS_Pr->SiS_RY1COE = 0;
3359 SiS_Pr->SiS_RY2COE = 0; 3308 SiS_Pr->SiS_RY2COE = 0;
3360 SiS_Pr->SiS_RY3COE = 0; 3309 SiS_Pr->SiS_RY3COE = 0;
3361 SiS_Pr->SiS_RY4COE = 0; 3310 SiS_Pr->SiS_RY4COE = 0;
3311 SiS_Pr->SiS_RVBHRS2 = 0;
3362 3312
3363 SiS_GetCRT2ResInfo(SiS_Pr,ModeNo,ModeIdIndex,HwInfo); 3313 SiS_GetCRT2ResInfo(SiS_Pr,ModeNo,ModeIdIndex);
3364 3314
3365 if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC){ 3315 if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) {
3366 3316
3367 if(SiS_Pr->UseCustomMode) { 3317 if(SiS_Pr->UseCustomMode) {
3368 3318
3369 SiS_Pr->SiS_RVBHCMAX = 1; 3319 SiS_Pr->SiS_RVBHCMAX = 1;
3370 SiS_Pr->SiS_RVBHCFACT = 1; 3320 SiS_Pr->SiS_RVBHCFACT = 1;
3371 SiS_Pr->SiS_VGAHT = SiS_Pr->CHTotal;
3372 SiS_Pr->SiS_VGAVT = SiS_Pr->CVTotal;
3373 SiS_Pr->SiS_HT = SiS_Pr->CHTotal;
3374 SiS_Pr->SiS_VT = SiS_Pr->CVTotal;
3375 SiS_Pr->SiS_HDE = SiS_Pr->SiS_VGAHDE; 3321 SiS_Pr->SiS_HDE = SiS_Pr->SiS_VGAHDE;
3376 SiS_Pr->SiS_VDE = SiS_Pr->SiS_VGAVDE; 3322 SiS_Pr->SiS_VDE = SiS_Pr->SiS_VGAVDE;
3323
3324 tempax = SiS_Pr->CHTotal;
3325 if(modeflag & HalfDCLK) tempax <<= 1;
3326 SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = tempax;
3327 SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_VT = SiS_Pr->CVTotal;
3377 3328
3378 } else { 3329 } else {
3379 3330
3380 SiS_GetRAMDAC2DATA(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); 3331 SiS_GetRAMDAC2DATA(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
3381 3332
3382 } 3333 }
3383 3334
3384 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 3335 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
3385 3336
3386 SiS_GetCRT2Ptr(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex, 3337 SiS_GetCRT2Ptr(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex,
3387 &CRT2Index,&ResIndex,HwInfo); 3338 &CRT2Index,&ResIndex);
3388 3339
3389 switch(CRT2Index) { 3340 switch(CRT2Index) {
3390 case 2: TVPtr = SiS_Pr->SiS_ExtHiTVData; break; 3341 case 2: TVPtr = SiS_Pr->SiS_ExtHiTVData; break;
3391 case 3: TVPtr = SiS_Pr->SiS_ExtPALData; break; 3342 case 3: TVPtr = SiS_Pr->SiS_ExtPALData; break;
3392 case 4: TVPtr = SiS_Pr->SiS_ExtNTSCData; break; 3343 case 4: TVPtr = SiS_Pr->SiS_ExtNTSCData; break;
3393 case 5: TVPtr = SiS_Pr->SiS_Ext525iData; break; 3344 case 5: TVPtr = SiS_Pr->SiS_Ext525iData; break;
3394 case 6: TVPtr = SiS_Pr->SiS_Ext525pData; break; 3345 case 6: TVPtr = SiS_Pr->SiS_Ext525pData; break;
3395 case 7: TVPtr = SiS_Pr->SiS_Ext750pData; break; 3346 case 7: TVPtr = SiS_Pr->SiS_Ext750pData; break;
3396 case 8: TVPtr = SiS_Pr->SiS_StPALData; break; 3347 case 8: TVPtr = SiS_Pr->SiS_StPALData; break;
3397 case 9: TVPtr = SiS_Pr->SiS_StNTSCData; break; 3348 case 9: TVPtr = SiS_Pr->SiS_StNTSCData; break;
3398 case 10: TVPtr = SiS_Pr->SiS_St525iData; break; 3349 case 10: TVPtr = SiS_Pr->SiS_St525iData; break;
3399 case 11: TVPtr = SiS_Pr->SiS_St525pData; break; 3350 case 11: TVPtr = SiS_Pr->SiS_St525pData; break;
3400 case 12: TVPtr = SiS_Pr->SiS_St750pData; break; 3351 case 12: TVPtr = SiS_Pr->SiS_St750pData; break;
3401 case 13: TVPtr = SiS_Pr->SiS_St1HiTVData; break; 3352 case 13: TVPtr = SiS_Pr->SiS_St1HiTVData; break;
3402 case 14: TVPtr = SiS_Pr->SiS_St2HiTVData; break; 3353 case 14: TVPtr = SiS_Pr->SiS_St2HiTVData; break;
3403 default: TVPtr = SiS_Pr->SiS_StPALData; break; 3354 default: TVPtr = SiS_Pr->SiS_StPALData; break;
3404 } 3355 }
3405 3356
3406 SiS_Pr->SiS_RVBHCMAX = (TVPtr+ResIndex)->RVBHCMAX; 3357 SiS_Pr->SiS_RVBHCMAX = (TVPtr+ResIndex)->RVBHCMAX;
@@ -3409,73 +3360,77 @@ SiS_GetCRT2Data301(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex,
3409 SiS_Pr->SiS_VGAVT = (TVPtr+ResIndex)->VGAVT; 3360 SiS_Pr->SiS_VGAVT = (TVPtr+ResIndex)->VGAVT;
3410 SiS_Pr->SiS_HDE = (TVPtr+ResIndex)->TVHDE; 3361 SiS_Pr->SiS_HDE = (TVPtr+ResIndex)->TVHDE;
3411 SiS_Pr->SiS_VDE = (TVPtr+ResIndex)->TVVDE; 3362 SiS_Pr->SiS_VDE = (TVPtr+ResIndex)->TVVDE;
3412 SiS_Pr->SiS_RVBHRS = (TVPtr+ResIndex)->RVBHRS; 3363 SiS_Pr->SiS_RVBHRS2 = (TVPtr+ResIndex)->RVBHRS2 & 0x0fff;
3413 SiS_Pr->SiS_NewFlickerMode = (TVPtr+ResIndex)->FlickerMode;
3414 if(modeflag & HalfDCLK) { 3364 if(modeflag & HalfDCLK) {
3415 SiS_Pr->SiS_RVBHRS = (TVPtr+ResIndex)->HALFRVBHRS; 3365 SiS_Pr->SiS_RVBHRS = (TVPtr+ResIndex)->HALFRVBHRS;
3366 if(SiS_Pr->SiS_RVBHRS2) {
3367 SiS_Pr->SiS_RVBHRS2 = ((SiS_Pr->SiS_RVBHRS2 + 3) >> 1) - 3;
3368 tempax = ((TVPtr+ResIndex)->RVBHRS2 >> 12) & 0x07;
3369 if((TVPtr+ResIndex)->RVBHRS2 & 0x8000) SiS_Pr->SiS_RVBHRS2 -= tempax;
3370 else SiS_Pr->SiS_RVBHRS2 += tempax;
3371 }
3372 } else {
3373 SiS_Pr->SiS_RVBHRS = (TVPtr+ResIndex)->RVBHRS;
3416 } 3374 }
3375 SiS_Pr->SiS_NewFlickerMode = ((TVPtr+ResIndex)->FlickerMode) << 7;
3417 3376
3418 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { 3377 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {
3419 3378
3420 if((resinfo == SIS_RI_1024x768) || 3379 if((resinfo == SIS_RI_960x600) ||
3421 (resinfo == SIS_RI_1280x1024) || 3380 (resinfo == SIS_RI_1024x768) ||
3422 (resinfo == SIS_RI_1280x720)) { 3381 (resinfo == SIS_RI_1280x1024) ||
3382 (resinfo == SIS_RI_1280x720)) {
3423 SiS_Pr->SiS_NewFlickerMode = 0x40; 3383 SiS_Pr->SiS_NewFlickerMode = 0x40;
3424 } 3384 }
3425 3385
3426 if(SiS_Pr->SiS_VGAVDE == 350) SiS_Pr->SiS_TVMode |= TVSetTVSimuMode; 3386 if(SiS_Pr->SiS_VGAVDE == 350) SiS_Pr->SiS_TVMode |= TVSetTVSimuMode;
3427 3387
3428 SiS_Pr->SiS_HT = ExtHiTVHT; 3388 SiS_Pr->SiS_HT = ExtHiTVHT;
3429 SiS_Pr->SiS_VT = ExtHiTVVT; 3389 SiS_Pr->SiS_VT = ExtHiTVVT;
3430 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { 3390 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
3431 if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { 3391 if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) {
3432 SiS_Pr->SiS_HT = StHiTVHT; 3392 SiS_Pr->SiS_HT = StHiTVHT;
3433 SiS_Pr->SiS_VT = StHiTVVT; 3393 SiS_Pr->SiS_VT = StHiTVVT;
3434#if 0 3394 }
3435 if(!(modeflag & Charx8Dot)) { 3395 }
3436 SiS_Pr->SiS_HT = StHiTextTVHT;
3437 SiS_Pr->SiS_VT = StHiTextTVVT;
3438 }
3439#endif
3440 }
3441 }
3442 3396
3443 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { 3397 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) {
3444 3398
3445 if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) { 3399 if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) {
3446 SiS_Pr->SiS_HT = 1650; 3400 SiS_Pr->SiS_HT = 1650;
3447 SiS_Pr->SiS_VT = 750; 3401 SiS_Pr->SiS_VT = 750;
3448 } else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) { 3402 } else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) {
3449 SiS_Pr->SiS_HT = NTSCHT; 3403 SiS_Pr->SiS_HT = NTSCHT;
3404 if(SiS_Pr->SiS_TVMode & TVSet525p1024) SiS_Pr->SiS_HT = NTSC2HT;
3450 SiS_Pr->SiS_VT = NTSCVT; 3405 SiS_Pr->SiS_VT = NTSCVT;
3451 } else { 3406 } else {
3452 SiS_Pr->SiS_HT = NTSCHT; 3407 SiS_Pr->SiS_HT = NTSCHT;
3453 if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) SiS_Pr->SiS_HT = NTSC2HT; 3408 if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) SiS_Pr->SiS_HT = NTSC2HT;
3454 SiS_Pr->SiS_VT = NTSCVT; 3409 SiS_Pr->SiS_VT = NTSCVT;
3455 } 3410 }
3456 3411
3457 } else { 3412 } else {
3458 3413
3459 SiS_Pr->SiS_RY1COE = (TVPtr+ResIndex)->RY1COE; 3414 SiS_Pr->SiS_RY1COE = (TVPtr+ResIndex)->RY1COE;
3460 SiS_Pr->SiS_RY2COE = (TVPtr+ResIndex)->RY2COE; 3415 SiS_Pr->SiS_RY2COE = (TVPtr+ResIndex)->RY2COE;
3461 SiS_Pr->SiS_RY3COE = (TVPtr+ResIndex)->RY3COE; 3416 SiS_Pr->SiS_RY3COE = (TVPtr+ResIndex)->RY3COE;
3462 SiS_Pr->SiS_RY4COE = (TVPtr+ResIndex)->RY4COE; 3417 SiS_Pr->SiS_RY4COE = (TVPtr+ResIndex)->RY4COE;
3463 3418
3464 if(modeflag & HalfDCLK) { 3419 if(modeflag & HalfDCLK) {
3465 SiS_Pr->SiS_RY1COE = 0x00; 3420 SiS_Pr->SiS_RY1COE = 0x00;
3466 SiS_Pr->SiS_RY2COE = 0xf4; 3421 SiS_Pr->SiS_RY2COE = 0xf4;
3467 SiS_Pr->SiS_RY3COE = 0x10; 3422 SiS_Pr->SiS_RY3COE = 0x10;
3468 SiS_Pr->SiS_RY4COE = 0x38; 3423 SiS_Pr->SiS_RY4COE = 0x38;
3469 } 3424 }
3470 3425
3471 if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { 3426 if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) {
3472 SiS_Pr->SiS_HT = NTSCHT; 3427 SiS_Pr->SiS_HT = NTSCHT;
3473 if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) SiS_Pr->SiS_HT = NTSC2HT; 3428 if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) SiS_Pr->SiS_HT = NTSC2HT;
3474 SiS_Pr->SiS_VT = NTSCVT; 3429 SiS_Pr->SiS_VT = NTSCVT;
3475 } else { 3430 } else {
3476 SiS_Pr->SiS_HT = PALHT; 3431 SiS_Pr->SiS_HT = PALHT;
3477 SiS_Pr->SiS_VT = PALVT; 3432 SiS_Pr->SiS_VT = PALVT;
3478 } 3433 }
3479 3434
3480 } 3435 }
3481 3436
@@ -3486,42 +3441,53 @@ SiS_GetCRT2Data301(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex,
3486 3441
3487 if(SiS_Pr->UseCustomMode) { 3442 if(SiS_Pr->UseCustomMode) {
3488 3443
3489 SiS_Pr->SiS_VGAHT = SiS_Pr->CHTotal;
3490 SiS_Pr->SiS_VGAVT = SiS_Pr->CVTotal;
3491 SiS_Pr->SiS_HT = SiS_Pr->CHTotal;
3492 SiS_Pr->SiS_VT = SiS_Pr->CVTotal;
3493 SiS_Pr->SiS_HDE = SiS_Pr->SiS_VGAHDE; 3444 SiS_Pr->SiS_HDE = SiS_Pr->SiS_VGAHDE;
3494 SiS_Pr->SiS_VDE = SiS_Pr->SiS_VGAVDE; 3445 SiS_Pr->SiS_VDE = SiS_Pr->SiS_VGAVDE;
3446
3447 tempax = SiS_Pr->CHTotal;
3448 if(modeflag & HalfDCLK) tempax <<= 1;
3449 SiS_Pr->SiS_VGAHT = SiS_Pr->SiS_HT = tempax;
3450 SiS_Pr->SiS_VGAVT = SiS_Pr->SiS_VT = SiS_Pr->CVTotal;
3495 3451
3496 } else { 3452 } else {
3497 3453
3498 BOOLEAN gotit = FALSE; 3454 BOOLEAN gotit = FALSE;
3499 3455
3500 if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) { 3456 if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) {
3501 3457
3502 SiS_Pr->SiS_VGAHT = SiS_Pr->PanelHT; 3458 SiS_Pr->SiS_VGAHT = SiS_Pr->PanelHT;
3503 SiS_Pr->SiS_VGAVT = SiS_Pr->PanelVT; 3459 SiS_Pr->SiS_VGAVT = SiS_Pr->PanelVT;
3504 SiS_Pr->SiS_HT = SiS_Pr->PanelHT; 3460 SiS_Pr->SiS_HT = SiS_Pr->PanelHT;
3505 SiS_Pr->SiS_VT = SiS_Pr->PanelVT; 3461 SiS_Pr->SiS_VT = SiS_Pr->PanelVT;
3506 gotit = TRUE; 3462 gotit = TRUE;
3507 3463
3508 } else if( (!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) && (romptr) && (ROMAddr) ) { 3464 } else if( (!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) && (romptr) && (ROMAddr) ) {
3509 3465
3510#ifdef SIS315H 3466#ifdef SIS315H
3511 SiS_Pr->SiS_RVBHCMAX = ROMAddr[romptr]; 3467 SiS_Pr->SiS_RVBHCMAX = ROMAddr[romptr];
3512 SiS_Pr->SiS_RVBHCFACT = ROMAddr[romptr+1]; 3468 SiS_Pr->SiS_RVBHCFACT = ROMAddr[romptr+1];
3513 SiS_Pr->SiS_VGAHT = ROMAddr[romptr+2] | ((ROMAddr[romptr+3] & 0x0f) << 8); 3469 SiS_Pr->SiS_VGAHT = ROMAddr[romptr+2] | ((ROMAddr[romptr+3] & 0x0f) << 8);
3514 SiS_Pr->SiS_VGAVT = ROMAddr[romptr+4] | ((ROMAddr[romptr+3] & 0xf0) << 4); 3470 SiS_Pr->SiS_VGAVT = (ROMAddr[romptr+4] << 4) | ((ROMAddr[romptr+3] & 0xf0) >> 4);
3515 SiS_Pr->SiS_HT = ROMAddr[romptr+5] | ((ROMAddr[romptr+6] & 0x0f) << 8); 3471 SiS_Pr->SiS_HT = ROMAddr[romptr+5] | ((ROMAddr[romptr+6] & 0x0f) << 8);
3516 SiS_Pr->SiS_VT = ROMAddr[romptr+7] | ((ROMAddr[romptr+6] & 0xf0) << 4); 3472 SiS_Pr->SiS_VT = (ROMAddr[romptr+7] << 4) | ((ROMAddr[romptr+6] & 0xf0) >> 4);
3473 SiS_Pr->SiS_RVBHRS2 = ROMAddr[romptr+8] | ((ROMAddr[romptr+9] & 0x0f) << 8);
3474 if((SiS_Pr->SiS_RVBHRS2) && (modeflag & HalfDCLK)) {
3475 SiS_Pr->SiS_RVBHRS2 = ((SiS_Pr->SiS_RVBHRS2 + 3) >> 1) - 3;
3476 tempax = (ROMAddr[romptr+9] >> 4) & 0x07;
3477 if(ROMAddr[romptr+9] & 0x80) SiS_Pr->SiS_RVBHRS2 -= tempax;
3478 else SiS_Pr->SiS_RVBHRS2 += tempax;
3479 }
3517 if(SiS_Pr->SiS_VGAHT) gotit = TRUE; 3480 if(SiS_Pr->SiS_VGAHT) gotit = TRUE;
3518 else { 3481 else {
3519 SiS_Pr->SiS_LCDInfo |= DontExpandLCD; 3482 SiS_Pr->SiS_LCDInfo |= DontExpandLCD;
3520 SiS_Pr->SiS_LCDInfo &= ~LCDPass11; 3483 SiS_Pr->SiS_LCDInfo &= ~LCDPass11;
3484 SiS_Pr->SiS_RVBHCMAX = 1;
3485 SiS_Pr->SiS_RVBHCFACT = 1;
3521 SiS_Pr->SiS_VGAHT = SiS_Pr->PanelHT; 3486 SiS_Pr->SiS_VGAHT = SiS_Pr->PanelHT;
3522 SiS_Pr->SiS_VGAVT = SiS_Pr->PanelVT; 3487 SiS_Pr->SiS_VGAVT = SiS_Pr->PanelVT;
3523 SiS_Pr->SiS_HT = SiS_Pr->PanelHT; 3488 SiS_Pr->SiS_HT = SiS_Pr->PanelHT;
3524 SiS_Pr->SiS_VT = SiS_Pr->PanelVT; 3489 SiS_Pr->SiS_VT = SiS_Pr->PanelVT;
3490 SiS_Pr->SiS_RVBHRS2 = 0;
3525 gotit = TRUE; 3491 gotit = TRUE;
3526 } 3492 }
3527#endif 3493#endif
@@ -3530,28 +3496,30 @@ SiS_GetCRT2Data301(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex,
3530 3496
3531 if(!gotit) { 3497 if(!gotit) {
3532 3498
3533 SiS_GetCRT2Ptr(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex, 3499 SiS_GetCRT2Ptr(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex,
3534 &CRT2Index,&ResIndex,HwInfo); 3500 &CRT2Index,&ResIndex);
3535 3501
3536 switch(CRT2Index) { 3502 switch(CRT2Index) {
3537 case Panel_1024x768 : LCDPtr = SiS_Pr->SiS_ExtLCD1024x768Data; break; 3503 case Panel_1024x768 : LCDPtr = SiS_Pr->SiS_ExtLCD1024x768Data; break;
3538 case Panel_1024x768 + 32: LCDPtr = SiS_Pr->SiS_St2LCD1024x768Data; break; 3504 case Panel_1024x768 + 32: LCDPtr = SiS_Pr->SiS_St2LCD1024x768Data; break;
3539 case Panel_1280x720 : 3505 case Panel_1280x720 :
3540 case Panel_1280x720 + 32: LCDPtr = SiS_Pr->SiS_LCD1280x720Data; break; 3506 case Panel_1280x720 + 32: LCDPtr = SiS_Pr->SiS_LCD1280x720Data; break;
3541 case Panel_1280x768_2 : LCDPtr = SiS_Pr->SiS_ExtLCD1280x768_2Data; break; 3507 case Panel_1280x768_2 : LCDPtr = SiS_Pr->SiS_ExtLCD1280x768_2Data; break;
3542 case Panel_1280x768_2+ 32: LCDPtr = SiS_Pr->SiS_StLCD1280x768_2Data; break; 3508 case Panel_1280x768_2+ 32: LCDPtr = SiS_Pr->SiS_StLCD1280x768_2Data; break;
3543 case Panel_1280x800 : 3509 case Panel_1280x800 :
3544 case Panel_1280x800 + 32: LCDPtr = SiS_Pr->SiS_LCD1280x800Data; break; 3510 case Panel_1280x800 + 32: LCDPtr = SiS_Pr->SiS_LCD1280x800Data; break;
3545 case Panel_1280x800_2 : 3511 case Panel_1280x800_2 :
3546 case Panel_1280x800_2+ 32: LCDPtr = SiS_Pr->SiS_LCD1280x800_2Data; break; 3512 case Panel_1280x800_2+ 32: LCDPtr = SiS_Pr->SiS_LCD1280x800_2Data; break;
3513 case Panel_1280x854 :
3514 case Panel_1280x854 + 32: LCDPtr = SiS_Pr->SiS_LCD1280x854Data; break;
3547 case Panel_1280x960 : 3515 case Panel_1280x960 :
3548 case Panel_1280x960 + 32: LCDPtr = SiS_Pr->SiS_LCD1280x960Data; break; 3516 case Panel_1280x960 + 32: LCDPtr = SiS_Pr->SiS_LCD1280x960Data; break;
3549 case Panel_1280x1024 : LCDPtr = SiS_Pr->SiS_ExtLCD1280x1024Data; break; 3517 case Panel_1280x1024 : LCDPtr = SiS_Pr->SiS_ExtLCD1280x1024Data; break;
3550 case Panel_1280x1024 + 32: LCDPtr = SiS_Pr->SiS_St2LCD1280x1024Data; break; 3518 case Panel_1280x1024 + 32: LCDPtr = SiS_Pr->SiS_St2LCD1280x1024Data; break;
3551 case Panel_1400x1050 : LCDPtr = SiS_Pr->SiS_ExtLCD1400x1050Data; break; 3519 case Panel_1400x1050 : LCDPtr = SiS_Pr->SiS_ExtLCD1400x1050Data; break;
3552 case Panel_1400x1050 + 32: LCDPtr = SiS_Pr->SiS_StLCD1400x1050Data; break; 3520 case Panel_1400x1050 + 32: LCDPtr = SiS_Pr->SiS_StLCD1400x1050Data; break;
3553 case Panel_1600x1200 : LCDPtr = SiS_Pr->SiS_ExtLCD1600x1200Data; break; 3521 case Panel_1600x1200 : LCDPtr = SiS_Pr->SiS_ExtLCD1600x1200Data; break;
3554 case Panel_1600x1200 + 32: LCDPtr = SiS_Pr->SiS_StLCD1600x1200Data; break; 3522 case Panel_1600x1200 + 32: LCDPtr = SiS_Pr->SiS_StLCD1600x1200Data; break;
3555 case Panel_1680x1050 : 3523 case Panel_1680x1050 :
3556 case Panel_1680x1050 + 32: LCDPtr = SiS_Pr->SiS_LCD1680x1050Data; break; 3524 case Panel_1680x1050 + 32: LCDPtr = SiS_Pr->SiS_LCD1680x1050Data; break;
3557 case 100 : LCDPtr = SiS_Pr->SiS_NoScaleData; break; 3525 case 100 : LCDPtr = SiS_Pr->SiS_NoScaleData; break;
@@ -3559,271 +3527,340 @@ SiS_GetCRT2Data301(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex,
3559 case 200 : LCDPtr = SiS310_ExtCompaq1280x1024Data; break; 3527 case 200 : LCDPtr = SiS310_ExtCompaq1280x1024Data; break;
3560 case 201 : LCDPtr = SiS_Pr->SiS_St2LCD1280x1024Data; break; 3528 case 201 : LCDPtr = SiS_Pr->SiS_St2LCD1280x1024Data; break;
3561#endif 3529#endif
3562 default : LCDPtr = SiS_Pr->SiS_ExtLCD1024x768Data; break; 3530 default : LCDPtr = SiS_Pr->SiS_ExtLCD1024x768Data; break;
3563 } 3531 }
3564 3532
3533#ifdef SIS_XORG_XF86
3565#ifdef TWDEBUG 3534#ifdef TWDEBUG
3566 xf86DrvMsg(0, X_INFO, "GetCRT2Data: Index %d ResIndex %d\n", CRT2Index, ResIndex); 3535 xf86DrvMsg(0, X_INFO, "GetCRT2Data: Index %d ResIndex %d\n", CRT2Index, ResIndex);
3536#endif
3567#endif 3537#endif
3568 3538
3569 SiS_Pr->SiS_RVBHCMAX = (LCDPtr+ResIndex)->RVBHCMAX; 3539 SiS_Pr->SiS_RVBHCMAX = (LCDPtr+ResIndex)->RVBHCMAX;
3570 SiS_Pr->SiS_RVBHCFACT = (LCDPtr+ResIndex)->RVBHCFACT; 3540 SiS_Pr->SiS_RVBHCFACT = (LCDPtr+ResIndex)->RVBHCFACT;
3571 SiS_Pr->SiS_VGAHT = (LCDPtr+ResIndex)->VGAHT; 3541 SiS_Pr->SiS_VGAHT = (LCDPtr+ResIndex)->VGAHT;
3572 SiS_Pr->SiS_VGAVT = (LCDPtr+ResIndex)->VGAVT; 3542 SiS_Pr->SiS_VGAVT = (LCDPtr+ResIndex)->VGAVT;
3573 SiS_Pr->SiS_HT = (LCDPtr+ResIndex)->LCDHT; 3543 SiS_Pr->SiS_HT = (LCDPtr+ResIndex)->LCDHT;
3574 SiS_Pr->SiS_VT = (LCDPtr+ResIndex)->LCDVT; 3544 SiS_Pr->SiS_VT = (LCDPtr+ResIndex)->LCDVT;
3575 3545
3576 } 3546 }
3577 3547
3578 tempax = SiS_Pr->PanelXRes; 3548 tempax = SiS_Pr->PanelXRes;
3579 tempbx = SiS_Pr->PanelYRes; 3549 tempbx = SiS_Pr->PanelYRes;
3580 3550
3581 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { 3551 switch(SiS_Pr->SiS_LCDResInfo) {
3582 if(SiS_Pr->SiS_SetFlag & LCDVESATiming) { 3552 case Panel_1024x768:
3583 if(HwInfo->jChipType < SIS_315H) { 3553 if(SiS_Pr->SiS_SetFlag & LCDVESATiming) {
3584 if (SiS_Pr->SiS_VGAVDE == 350) tempbx = 560; 3554 if(SiS_Pr->ChipType < SIS_315H) {
3585 else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 640; 3555 if (SiS_Pr->SiS_VGAVDE == 350) tempbx = 560;
3586 } 3556 else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 640;
3587 } else { 3557 }
3588 if (SiS_Pr->SiS_VGAVDE == 357) tempbx = 527; 3558 } else {
3589 else if(SiS_Pr->SiS_VGAVDE == 420) tempbx = 620; 3559 if (SiS_Pr->SiS_VGAVDE == 357) tempbx = 527;
3590 else if(SiS_Pr->SiS_VGAVDE == 525) tempbx = 775; 3560 else if(SiS_Pr->SiS_VGAVDE == 420) tempbx = 620;
3591 else if(SiS_Pr->SiS_VGAVDE == 600) tempbx = 775; 3561 else if(SiS_Pr->SiS_VGAVDE == 525) tempbx = 775;
3592 else if(SiS_Pr->SiS_VGAVDE == 350) tempbx = 560; 3562 else if(SiS_Pr->SiS_VGAVDE == 600) tempbx = 775;
3593 else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 640; 3563 else if(SiS_Pr->SiS_VGAVDE == 350) tempbx = 560;
3594 } 3564 else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 640;
3595 } else if(SiS_Pr->SiS_LCDResInfo == Panel_1280x960) { 3565 }
3596 if (SiS_Pr->SiS_VGAVDE == 350) tempbx = 700; 3566 break;
3597 else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 800; 3567 case Panel_1280x960:
3598 else if(SiS_Pr->SiS_VGAVDE == 1024) tempbx = 960; 3568 if (SiS_Pr->SiS_VGAVDE == 350) tempbx = 700;
3599 } else if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) { 3569 else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 800;
3600 if (SiS_Pr->SiS_VGAVDE == 360) tempbx = 768; 3570 else if(SiS_Pr->SiS_VGAVDE == 1024) tempbx = 960;
3601 else if(SiS_Pr->SiS_VGAVDE == 375) tempbx = 800; 3571 break;
3602 else if(SiS_Pr->SiS_VGAVDE == 405) tempbx = 864; 3572 case Panel_1280x1024:
3603 } else if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) { 3573 if (SiS_Pr->SiS_VGAVDE == 360) tempbx = 768;
3574 else if(SiS_Pr->SiS_VGAVDE == 375) tempbx = 800;
3575 else if(SiS_Pr->SiS_VGAVDE == 405) tempbx = 864;
3576 break;
3577 case Panel_1600x1200:
3604 if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { 3578 if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) {
3605 if (SiS_Pr->SiS_VGAVDE == 350) tempbx = 875; 3579 if (SiS_Pr->SiS_VGAVDE == 350) tempbx = 875;
3606 else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 1000; 3580 else if(SiS_Pr->SiS_VGAVDE == 400) tempbx = 1000;
3607 } 3581 }
3608 } 3582 break;
3583 }
3609 3584
3610 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { 3585 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
3611 tempax = SiS_Pr->SiS_VGAHDE; 3586 tempax = SiS_Pr->SiS_VGAHDE;
3612 tempbx = SiS_Pr->SiS_VGAVDE; 3587 tempbx = SiS_Pr->SiS_VGAVDE;
3613 } 3588 }
3614 3589
3615 SiS_Pr->SiS_HDE = tempax; 3590 SiS_Pr->SiS_HDE = tempax;
3616 SiS_Pr->SiS_VDE = tempbx; 3591 SiS_Pr->SiS_VDE = tempbx;
3617 } 3592 }
3618 } 3593 }
3619} 3594}
3620 3595
3621static void 3596static void
3622SiS_GetCRT2Data(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, 3597SiS_GetCRT2Data(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex,
3623 USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) 3598 unsigned short RefreshRateTableIndex)
3624{ 3599{
3625 3600
3626 if(SiS_Pr->SiS_VBType & VB_SISVB) { 3601 if(SiS_Pr->SiS_VBType & VB_SISVB) {
3627 3602
3628 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { 3603 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
3629 SiS_GetCRT2DataLVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); 3604 SiS_GetCRT2DataLVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
3630 } else { 3605 } else {
3631 if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { 3606 if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) {
3632 /* Need LVDS Data for LCD on 301B-DH */ 3607 /* Need LVDS Data for LCD on 301B-DH */
3633 SiS_GetCRT2DataLVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); 3608 SiS_GetCRT2DataLVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
3634 } else { 3609 } else {
3635 SiS_GetCRT2Data301(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); 3610 SiS_GetCRT2Data301(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
3636 } 3611 }
3637 } 3612 }
3638 3613
3639 } else { 3614 } else {
3640 3615
3641 SiS_GetCRT2DataLVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); 3616 SiS_GetCRT2DataLVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
3642 3617
3643 } 3618 }
3644} 3619}
3645 3620
3646/*********************************************/ 3621/*********************************************/
3647/* GET LVDS DES (SKEW) DATA */ 3622/* GET LVDS DES (SKEW) DATA */
3648/*********************************************/ 3623/*********************************************/
3649 3624
3650static void 3625static const struct SiS_LVDSDes *
3651SiS_GetLVDSDesPtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, 3626SiS_GetLVDSDesPtr(struct SiS_Private *SiS_Pr)
3652 USHORT RefreshRateTableIndex, USHORT *PanelIndex,
3653 USHORT *ResIndex, PSIS_HW_INFO HwInfo)
3654{ 3627{
3655 USHORT modeflag; 3628 const struct SiS_LVDSDes *PanelDesPtr = NULL;
3656 3629
3657 if(ModeNo <= 0x13) { 3630#ifdef SIS300
3658 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; 3631 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
3659 (*ResIndex) = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; 3632
3660 } else { 3633 if(SiS_Pr->ChipType < SIS_315H) {
3661 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; 3634 if(SiS_Pr->SiS_LCDTypeInfo == 4) {
3662 (*ResIndex) = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; 3635 if(SiS_Pr->SiS_CustomT == CUT_BARCO1366) {
3663 } 3636 PanelDesPtr = SiS_Pr->SiS_PanelType04_1a;
3637 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
3638 PanelDesPtr = SiS_Pr->SiS_PanelType04_2a;
3639 }
3640 } else if(SiS_Pr->SiS_CustomT == CUT_BARCO1024) {
3641 PanelDesPtr = SiS_Pr->SiS_PanelType04_1b;
3642 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
3643 PanelDesPtr = SiS_Pr->SiS_PanelType04_2b;
3644 }
3645 }
3646 }
3647 }
3648 }
3649#endif
3650 return PanelDesPtr;
3651}
3664 3652
3665 (*ResIndex) &= 0x1F; 3653static void
3666 (*PanelIndex) = 0; 3654SiS_GetLVDSDesData(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex,
3655 unsigned short RefreshRateTableIndex)
3656{
3657 unsigned short modeflag, ResIndex;
3658 const struct SiS_LVDSDes *PanelDesPtr = NULL;
3667 3659
3668 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { 3660 SiS_Pr->SiS_LCDHDES = 0;
3669 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 3661 SiS_Pr->SiS_LCDVDES = 0;
3670 (*PanelIndex) = 50;
3671 if((SiS_Pr->SiS_TVMode & TVSetPAL) && (!(SiS_Pr->SiS_TVMode & TVSetPALM))) (*PanelIndex) += 2;
3672 if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) (*PanelIndex) += 1;
3673 /* Nothing special needed for SOverscan */
3674 /* PALM uses NTSC data, PALN uses PAL data */
3675 }
3676 }
3677 3662
3663 /* Some special cases */
3678 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 3664 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
3679 *PanelIndex = SiS_Pr->SiS_LCDTypeInfo; 3665
3680 if(HwInfo->jChipType >= SIS_661) { 3666 /* Trumpion */
3681 /* As long as we don's use the BIOS tables, we 3667 if(SiS_Pr->SiS_IF_DEF_TRUMPION) {
3682 * need to convert the TypeInfo as for 315 series 3668 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) {
3683 */ 3669 if(SiS_Pr->SiS_VGAVDE == SiS_Pr->PanelYRes) {
3684 (*PanelIndex) = SiS_Pr->SiS_LCDResInfo - 1; 3670 SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1;
3685 } 3671 }
3686 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
3687 (*PanelIndex) += 16;
3688 if(SiS_Pr->SiS_LCDInfo & LCDPass11) {
3689 (*PanelIndex) = 32;
3690 if(modeflag & HalfDCLK) (*PanelIndex)++;
3691 } 3672 }
3673 return;
3692 } 3674 }
3693 }
3694 3675
3695 if(SiS_Pr->SiS_SetFlag & SetDOSMode) { 3676 /* 640x480 on LVDS */
3696 if(SiS_Pr->SiS_LCDResInfo != Panel_640x480) { 3677 if(SiS_Pr->ChipType < SIS_315H) {
3697 (*ResIndex) = 7; 3678 if(SiS_Pr->SiS_LCDResInfo == Panel_640x480 && SiS_Pr->SiS_LCDTypeInfo == 3) {
3698 if(HwInfo->jChipType < SIS_315H) { 3679 SiS_Pr->SiS_LCDHDES = 8;
3699 if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x80) (*ResIndex)++; 3680 if (SiS_Pr->SiS_VGAVDE >= 480) SiS_Pr->SiS_LCDVDES = 512;
3700 } 3681 else if(SiS_Pr->SiS_VGAVDE >= 400) SiS_Pr->SiS_LCDVDES = 436;
3682 else if(SiS_Pr->SiS_VGAVDE >= 350) SiS_Pr->SiS_LCDVDES = 440;
3683 return;
3684 }
3701 } 3685 }
3702 }
3703}
3704
3705static void
3706SiS_GetLVDSDesData(SiS_Private *SiS_Pr, USHORT ModeNo,USHORT ModeIdIndex,
3707 USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo)
3708{
3709 USHORT modeflag;
3710 USHORT PanelIndex,ResIndex;
3711 const SiS_LVDSDesStruct *PanelDesPtr = NULL;
3712 3686
3713 SiS_Pr->SiS_LCDHDES = 0; 3687 } /* LCD */
3714 SiS_Pr->SiS_LCDVDES = 0;
3715 3688
3716 if( (SiS_Pr->UseCustomMode) || 3689 if( (SiS_Pr->UseCustomMode) ||
3717 (SiS_Pr->SiS_LCDResInfo == Panel_Custom) || 3690 (SiS_Pr->SiS_LCDResInfo == Panel_Custom) ||
3718 (SiS_Pr->SiS_CustomT == CUT_PANEL848) || 3691 (SiS_Pr->SiS_CustomT == CUT_PANEL848) ||
3719 ((SiS_Pr->SiS_VBType & VB_SISVB) && 3692 (SiS_Pr->SiS_CustomT == CUT_PANEL856) ||
3720 (SiS_Pr->SiS_LCDInfo & DontExpandLCD) && 3693 (SiS_Pr->SiS_LCDInfo & LCDPass11) ) {
3721 (SiS_Pr->SiS_LCDInfo & LCDPass11)) ) {
3722 return; 3694 return;
3723 } 3695 }
3724 3696
3725 if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { 3697 if(ModeNo <= 0x13) ResIndex = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
3698 else ResIndex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
3699
3700 if((SiS_Pr->SiS_VBType & VB_SIS30xBLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
3726 3701
3727#ifdef SIS315H 3702#ifdef SIS315H
3728 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { 3703 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
3729 /* non-pass 1:1 only, see above */ 3704 /* non-pass 1:1 only, see above */
3730 if(SiS_Pr->SiS_VGAHDE != SiS_Pr->PanelXRes) { 3705 if(SiS_Pr->SiS_VGAHDE != SiS_Pr->PanelXRes) {
3731 SiS_Pr->SiS_LCDHDES = SiS_Pr->SiS_HT - ((SiS_Pr->PanelXRes - SiS_Pr->SiS_VGAHDE) / 2); 3706 SiS_Pr->SiS_LCDHDES = SiS_Pr->SiS_HT - ((SiS_Pr->PanelXRes - SiS_Pr->SiS_VGAHDE) / 2);
3732 } 3707 }
3733 if(SiS_Pr->SiS_VGAVDE != SiS_Pr->PanelYRes) { 3708 if(SiS_Pr->SiS_VGAVDE != SiS_Pr->PanelYRes) {
3734 SiS_Pr->SiS_LCDVDES = SiS_Pr->SiS_VT - ((SiS_Pr->PanelYRes - SiS_Pr->SiS_VGAVDE) / 2); 3709 SiS_Pr->SiS_LCDVDES = SiS_Pr->SiS_VT - ((SiS_Pr->PanelYRes - SiS_Pr->SiS_VGAVDE) / 2);
3735 } 3710 }
3736 } 3711 }
3737 if(SiS_Pr->SiS_VGAVDE == SiS_Pr->PanelYRes) { 3712 if(SiS_Pr->SiS_VGAVDE == SiS_Pr->PanelYRes) {
3738 switch(SiS_Pr->SiS_CustomT) { 3713 switch(SiS_Pr->SiS_CustomT) {
3739 case CUT_UNIWILL1024: 3714 case CUT_UNIWILL1024:
3740 case CUT_UNIWILL10242: 3715 case CUT_UNIWILL10242:
3741 case CUT_CLEVO1400: 3716 case CUT_CLEVO1400:
3742 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { 3717 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) {
3743 SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1; 3718 SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1;
3744 } 3719 }
3745 break; 3720 break;
3746 } 3721 }
3747 if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) { 3722 switch(SiS_Pr->SiS_LCDResInfo) {
3723 case Panel_1280x1024:
3748 if(SiS_Pr->SiS_CustomT != CUT_COMPAQ1280) { 3724 if(SiS_Pr->SiS_CustomT != CUT_COMPAQ1280) {
3749 SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1; 3725 SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1;
3750 } 3726 }
3727 break;
3728 case Panel_1280x800: /* Verified for Averatec 6240 */
3729 case Panel_1280x800_2: /* Verified for Asus A4L */
3730 case Panel_1280x854: /* Not verified yet FIXME */
3731 SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1;
3732 break;
3751 } 3733 }
3752 } 3734 }
3753#endif 3735#endif
3754 3736
3755 } else { 3737 } else {
3756 3738
3757 SiS_GetLVDSDesPtr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, 3739 if((SiS_Pr->SiS_IF_DEF_CH70xx != 0) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) {
3758 &PanelIndex, &ResIndex, HwInfo); 3740
3759 3741 if((SiS_Pr->SiS_TVMode & TVSetPAL) && (!(SiS_Pr->SiS_TVMode & TVSetPALM))) {
3760 switch(PanelIndex) { 3742 if(ResIndex <= 3) SiS_Pr->SiS_LCDHDES = 256;
3761 case 0: PanelDesPtr = SiS_Pr->SiS_PanelType00_1; break; /* --- */ 3743 }
3762 case 1: PanelDesPtr = SiS_Pr->SiS_PanelType01_1; break; 3744
3763 case 2: PanelDesPtr = SiS_Pr->SiS_PanelType02_1; break; 3745 } else if((PanelDesPtr = SiS_GetLVDSDesPtr(SiS_Pr))) {
3764 case 3: PanelDesPtr = SiS_Pr->SiS_PanelType03_1; break; 3746
3765 case 4: PanelDesPtr = SiS_Pr->SiS_PanelType04_1; break; 3747 SiS_Pr->SiS_LCDHDES = (PanelDesPtr+ResIndex)->LCDHDES;
3766 case 5: PanelDesPtr = SiS_Pr->SiS_PanelType05_1; break; 3748 SiS_Pr->SiS_LCDVDES = (PanelDesPtr+ResIndex)->LCDVDES;
3767 case 6: PanelDesPtr = SiS_Pr->SiS_PanelType06_1; break; 3749
3768 case 7: PanelDesPtr = SiS_Pr->SiS_PanelType07_1; break; 3750 } else if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
3769 case 8: PanelDesPtr = SiS_Pr->SiS_PanelType08_1; break; 3751
3770 case 9: PanelDesPtr = SiS_Pr->SiS_PanelType09_1; break; 3752 if(SiS_Pr->SiS_VGAHDE != SiS_Pr->PanelXRes) {
3771 case 10: PanelDesPtr = SiS_Pr->SiS_PanelType0a_1; break; 3753 SiS_Pr->SiS_LCDHDES = SiS_Pr->SiS_HT - ((SiS_Pr->PanelXRes - SiS_Pr->SiS_VGAHDE) / 2);
3772 case 11: PanelDesPtr = SiS_Pr->SiS_PanelType0b_1; break; 3754 }
3773 case 12: PanelDesPtr = SiS_Pr->SiS_PanelType0c_1; break; 3755 if(SiS_Pr->SiS_VGAVDE != SiS_Pr->PanelYRes) {
3774 case 13: PanelDesPtr = SiS_Pr->SiS_PanelType0d_1; break; 3756 SiS_Pr->SiS_LCDVDES = SiS_Pr->SiS_VT - ((SiS_Pr->PanelYRes - SiS_Pr->SiS_VGAVDE) / 2);
3775 case 14: PanelDesPtr = SiS_Pr->SiS_PanelType0e_1; break; 3757 } else {
3776 case 15: PanelDesPtr = SiS_Pr->SiS_PanelType0f_1; break; 3758 if(SiS_Pr->ChipType < SIS_315H) {
3777 case 16: PanelDesPtr = SiS_Pr->SiS_PanelType00_2; break; /* --- */ 3759 SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1;
3778 case 17: PanelDesPtr = SiS_Pr->SiS_PanelType01_2; break; 3760 } else {
3779 case 18: PanelDesPtr = SiS_Pr->SiS_PanelType02_2; break; 3761 switch(SiS_Pr->SiS_LCDResInfo) {
3780 case 19: PanelDesPtr = SiS_Pr->SiS_PanelType03_2; break; 3762 case Panel_800x600:
3781 case 20: PanelDesPtr = SiS_Pr->SiS_PanelType04_2; break; 3763 case Panel_1024x768:
3782 case 21: PanelDesPtr = SiS_Pr->SiS_PanelType05_2; break; 3764 case Panel_1280x1024:
3783 case 22: PanelDesPtr = SiS_Pr->SiS_PanelType06_2; break; 3765 SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT;
3784 case 23: PanelDesPtr = SiS_Pr->SiS_PanelType07_2; break; 3766 break;
3785 case 24: PanelDesPtr = SiS_Pr->SiS_PanelType08_2; break; 3767 case Panel_1400x1050:
3786 case 25: PanelDesPtr = SiS_Pr->SiS_PanelType09_2; break; 3768 SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1;
3787 case 26: PanelDesPtr = SiS_Pr->SiS_PanelType0a_2; break; 3769 break;
3788 case 27: PanelDesPtr = SiS_Pr->SiS_PanelType0b_2; break; 3770 }
3789 case 28: PanelDesPtr = SiS_Pr->SiS_PanelType0c_2; break; 3771 }
3790 case 29: PanelDesPtr = SiS_Pr->SiS_PanelType0d_2; break; 3772 }
3791 case 30: PanelDesPtr = SiS_Pr->SiS_PanelType0e_2; break; 3773
3792 case 31: PanelDesPtr = SiS_Pr->SiS_PanelType0f_2; break; 3774 } else {
3793 case 32: PanelDesPtr = SiS_Pr->SiS_PanelTypeNS_1; break; /* pass 1:1 */ 3775
3794 case 33: PanelDesPtr = SiS_Pr->SiS_PanelTypeNS_2; break; 3776 if(SiS_Pr->ChipType < SIS_315H) {
3795 case 50: PanelDesPtr = SiS_Pr->SiS_CHTVUNTSCDesData; break; /* TV */ 3777#ifdef SIS300
3796 case 51: PanelDesPtr = SiS_Pr->SiS_CHTVONTSCDesData; break; 3778 switch(SiS_Pr->SiS_LCDResInfo) {
3797 case 52: PanelDesPtr = SiS_Pr->SiS_CHTVUPALDesData; break; 3779 case Panel_800x600:
3798 case 53: PanelDesPtr = SiS_Pr->SiS_CHTVOPALDesData; break; 3780 if(SiS_Pr->SiS_VGAVDE == SiS_Pr->PanelYRes) {
3799 default: return; 3781 SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1;
3800 } 3782 } else {
3801 3783 SiS_Pr->SiS_LCDHDES = SiS_Pr->PanelHT + 3;
3802 SiS_Pr->SiS_LCDHDES = (PanelDesPtr+ResIndex)->LCDHDES; 3784 SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT;
3803 SiS_Pr->SiS_LCDVDES = (PanelDesPtr+ResIndex)->LCDVDES; 3785 if(SiS_Pr->SiS_VGAVDE == 400) SiS_Pr->SiS_LCDVDES -= 2;
3786 else SiS_Pr->SiS_LCDVDES -= 4;
3787 }
3788 break;
3789 case Panel_1024x768:
3790 if(SiS_Pr->SiS_VGAVDE == SiS_Pr->PanelYRes) {
3791 SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1;
3792 } else {
3793 SiS_Pr->SiS_LCDHDES = SiS_Pr->PanelHT - 1;
3794 if(SiS_Pr->SiS_VGAVDE <= 400) SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 8;
3795 if(SiS_Pr->SiS_VGAVDE <= 350) SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 12;
3796 }
3797 break;
3798 case Panel_1024x600:
3799 default:
3800 if( (SiS_Pr->SiS_VGAHDE == SiS_Pr->PanelXRes) &&
3801 (SiS_Pr->SiS_VGAVDE == SiS_Pr->PanelYRes) ) {
3802 SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1;
3803 } else {
3804 SiS_Pr->SiS_LCDHDES = SiS_Pr->PanelHT - 1;
3805 }
3806 break;
3807 }
3808
3809 switch(SiS_Pr->SiS_LCDTypeInfo) {
3810 case 1:
3811 SiS_Pr->SiS_LCDHDES = SiS_Pr->SiS_LCDVDES = 0;
3812 break;
3813 case 3: /* 640x480 only? */
3814 SiS_Pr->SiS_LCDHDES = 8;
3815 if (SiS_Pr->SiS_VGAVDE >= 480) SiS_Pr->SiS_LCDVDES = 512;
3816 else if(SiS_Pr->SiS_VGAVDE >= 400) SiS_Pr->SiS_LCDVDES = 436;
3817 else if(SiS_Pr->SiS_VGAVDE >= 350) SiS_Pr->SiS_LCDVDES = 440;
3818 break;
3819 }
3820#endif
3821 } else {
3822#ifdef SIS315H
3823 switch(SiS_Pr->SiS_LCDResInfo) {
3824 case Panel_1024x768:
3825 case Panel_1280x1024:
3826 if(SiS_Pr->SiS_VGAVDE == SiS_Pr->PanelYRes) {
3827 SiS_Pr->SiS_LCDVDES = SiS_Pr->PanelVT - 1;
3828 }
3829 break;
3830 case Panel_320x240_1:
3831 case Panel_320x240_2:
3832 case Panel_320x240_3:
3833 SiS_Pr->SiS_LCDVDES = 524;
3834 break;
3835 }
3836#endif
3837 }
3838 }
3804 3839
3805 if((ModeNo <= 0x13) && (SiS_Pr->SiS_LCDInfo & DontExpandLCD)) { 3840 if((ModeNo <= 0x13) && (SiS_Pr->SiS_LCDInfo & DontExpandLCD)) {
3806 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; 3841 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
3807 if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { 3842 if((SiS_Pr->SiS_VBType & VB_SIS30xBLV) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
3808 if(!(modeflag & HalfDCLK)) SiS_Pr->SiS_LCDHDES = 632; 3843 if(!(modeflag & HalfDCLK)) SiS_Pr->SiS_LCDHDES = 632;
3809 } else if(!(SiS_Pr->SiS_SetFlag & SetDOSMode)) { 3844 } else if(!(SiS_Pr->SiS_SetFlag & SetDOSMode)) {
3810 if(SiS_Pr->SiS_LCDResInfo != Panel_1280x1024) { 3845 if(SiS_Pr->SiS_LCDResInfo != Panel_1280x1024) {
3811 if(SiS_Pr->SiS_LCDResInfo >= Panel_1024x768) { 3846 if(SiS_Pr->SiS_LCDResInfo >= Panel_1024x768) {
3812 if(HwInfo->jChipType < SIS_315H) { 3847 if(SiS_Pr->ChipType < SIS_315H) {
3813 if(!(modeflag & HalfDCLK)) SiS_Pr->SiS_LCDHDES = 320; 3848 if(!(modeflag & HalfDCLK)) SiS_Pr->SiS_LCDHDES = 320;
3814 } else { 3849 } else {
3815 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) SiS_Pr->SiS_LCDHDES = 480; 3850#ifdef SIS315H
3816 if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) SiS_Pr->SiS_LCDHDES = 804; 3851 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) SiS_Pr->SiS_LCDHDES = 480;
3852 if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) SiS_Pr->SiS_LCDHDES = 804;
3817 if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) SiS_Pr->SiS_LCDHDES = 704; 3853 if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) SiS_Pr->SiS_LCDHDES = 704;
3818 if(!(modeflag & HalfDCLK)) { 3854 if(!(modeflag & HalfDCLK)) {
3819 SiS_Pr->SiS_LCDHDES = 320; 3855 SiS_Pr->SiS_LCDHDES = 320;
3820 if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) SiS_Pr->SiS_LCDHDES = 632; 3856 if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) SiS_Pr->SiS_LCDHDES = 632;
3821 if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) SiS_Pr->SiS_LCDHDES = 542; 3857 if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) SiS_Pr->SiS_LCDHDES = 542;
3822 } 3858 }
3823 } 3859#endif
3824 } 3860 }
3825 } 3861 }
3826 } 3862 }
3863 }
3827 } 3864 }
3828 } 3865 }
3829} 3866}
@@ -3832,54 +3869,90 @@ SiS_GetLVDSDesData(SiS_Private *SiS_Pr, USHORT ModeNo,USHORT ModeIdIndex,
3832/* DISABLE VIDEO BRIDGE */ 3869/* DISABLE VIDEO BRIDGE */
3833/*********************************************/ 3870/*********************************************/
3834 3871
3872#ifdef SIS315H
3873static int
3874SiS_HandlePWD(struct SiS_Private *SiS_Pr)
3875{
3876 int ret = 0;
3877#ifdef SET_PWD
3878 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
3879 unsigned short romptr = GetLCDStructPtr661_2(SiS_Pr);
3880 unsigned char drivermode = SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & 0x40;
3881 unsigned short temp;
3882
3883 if( (SiS_Pr->SiS_VBType & VB_SISPWD) &&
3884 (romptr) &&
3885 (SiS_Pr->SiS_PWDOffset) ) {
3886 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2b,ROMAddr[romptr + SiS_Pr->SiS_PWDOffset + 0]);
3887 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2c,ROMAddr[romptr + SiS_Pr->SiS_PWDOffset + 1]);
3888 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2d,ROMAddr[romptr + SiS_Pr->SiS_PWDOffset + 2]);
3889 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2e,ROMAddr[romptr + SiS_Pr->SiS_PWDOffset + 3]);
3890 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2f,ROMAddr[romptr + SiS_Pr->SiS_PWDOffset + 4]);
3891 temp = 0x00;
3892 if((ROMAddr[romptr + 2] & (0x06 << 1)) && !drivermode) {
3893 temp = 0x80;
3894 ret = 1;
3895 }
3896 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x27,0x7f,temp);
3897#ifdef SIS_XORG_XF86
3898#ifdef TWDEBUG
3899 xf86DrvMsg(0, 0, "Setting PWD %x\n", temp);
3900#endif
3901#endif
3902 }
3903#endif
3904 return ret;
3905}
3906#endif
3907
3835/* NEVER use any variables (VBInfo), this will be called 3908/* NEVER use any variables (VBInfo), this will be called
3836 * from outside the context of modeswitch! 3909 * from outside the context of modeswitch!
3837 * MUST call getVBType before calling this 3910 * MUST call getVBType before calling this
3838 */ 3911 */
3839void 3912void
3840SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 3913SiS_DisableBridge(struct SiS_Private *SiS_Pr)
3841{ 3914{
3842#ifdef SIS315H 3915#ifdef SIS315H
3843 USHORT tempah,pushax=0,modenum; 3916 unsigned short tempah, pushax=0, modenum;
3844#endif 3917#endif
3845 USHORT temp=0; 3918 unsigned short temp=0;
3846 3919
3847 if(SiS_Pr->SiS_VBType & VB_SISVB) { 3920 if(SiS_Pr->SiS_VBType & VB_SISVB) {
3848 3921
3849 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* ===== For 30xB/LV ===== */ 3922 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { /* ===== For 30xB/C/LV ===== */
3850 3923
3851 if(HwInfo->jChipType < SIS_315H) { 3924 if(SiS_Pr->ChipType < SIS_315H) {
3852 3925
3853#ifdef SIS300 /* 300 series */ 3926#ifdef SIS300 /* 300 series */
3854 3927
3855 if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) { 3928 if(!(SiS_CR36BIOSWord23b(SiS_Pr))) {
3856 if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { 3929 if(SiS_Pr->SiS_VBType & VB_SISLVDS) {
3857 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFE); 3930 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFE);
3858 } else { 3931 } else {
3859 SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x08); 3932 SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x08);
3860 } 3933 }
3861 SiS_PanelDelay(SiS_Pr, HwInfo, 3); 3934 SiS_PanelDelay(SiS_Pr, 3);
3862 } 3935 }
3863 if(SiS_Is301B(SiS_Pr)) { 3936 if(SiS_Is301B(SiS_Pr)) {
3864 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1f,0x3f); 3937 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1f,0x3f);
3865 SiS_ShortDelay(SiS_Pr,1); 3938 SiS_ShortDelay(SiS_Pr,1);
3866 } 3939 }
3867 SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xDF); 3940 SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xDF);
3868 SiS_DisplayOff(SiS_Pr); 3941 SiS_DisplayOff(SiS_Pr);
3869 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); 3942 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF);
3870 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); 3943 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF);
3871 SiS_UnLockCRT2(SiS_Pr,HwInfo); 3944 SiS_UnLockCRT2(SiS_Pr);
3872 if(!(SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) { 3945 if(!(SiS_Pr->SiS_VBType & VB_SISLVDS)) {
3873 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x80); 3946 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x80);
3874 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x02,0x40); 3947 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x02,0x40);
3875 } 3948 }
3876 if( (!(SiS_CRT2IsLCD(SiS_Pr, HwInfo))) || 3949 if( (!(SiS_CRT2IsLCD(SiS_Pr))) ||
3877 (!(SiS_CR36BIOSWord23d(SiS_Pr, HwInfo))) ) { 3950 (!(SiS_CR36BIOSWord23d(SiS_Pr))) ) {
3878 SiS_PanelDelay(SiS_Pr, HwInfo, 2); 3951 SiS_PanelDelay(SiS_Pr, 2);
3879 if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { 3952 if(SiS_Pr->SiS_VBType & VB_SISLVDS) {
3880 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFD); 3953 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFD);
3881 } else { 3954 } else {
3882 SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x04); 3955 SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x04);
3883 } 3956 }
3884 } 3957 }
3885 3958
@@ -3889,130 +3962,127 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
3889 3962
3890#ifdef SIS315H /* 315 series */ 3963#ifdef SIS315H /* 315 series */
3891 3964
3965 int didpwd = 0;
3892 BOOLEAN custom1 = ((SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) || 3966 BOOLEAN custom1 = ((SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) ||
3893 (SiS_Pr->SiS_CustomT == CUT_CLEVO1400)) ? TRUE : FALSE; 3967 (SiS_Pr->SiS_CustomT == CUT_CLEVO1400)) ? TRUE : FALSE;
3894 3968
3895 modenum = SiS_GetReg(SiS_Pr->SiS_P3d4,0x34) & 0x7f; 3969 modenum = SiS_GetReg(SiS_Pr->SiS_P3d4,0x34) & 0x7f;
3896 3970
3897 if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { 3971 if(SiS_Pr->SiS_VBType & VB_SISLVDS) {
3898 3972
3899#ifdef SET_EMI 3973#ifdef SET_EMI
3900 if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { 3974 if(SiS_Pr->SiS_VBType & VB_SISEMI) {
3901 if(SiS_Pr->SiS_CustomT != CUT_CLEVO1400) { 3975 if(SiS_Pr->SiS_CustomT != CUT_CLEVO1400) {
3902 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); 3976 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c);
3903 } 3977 }
3904 } 3978 }
3905#endif 3979#endif
3906 if( (modenum <= 0x13) || 3980
3907 (SiS_IsVAMode(SiS_Pr,HwInfo)) || 3981 didpwd = SiS_HandlePWD(SiS_Pr);
3908 (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) ) { 3982
3909 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFE); 3983 if( (modenum <= 0x13) ||
3910 if(custom1) SiS_PanelDelay(SiS_Pr, HwInfo, 3); 3984 (SiS_IsVAMode(SiS_Pr)) ||
3985 (!(SiS_IsDualEdge(SiS_Pr))) ) {
3986 if(!didpwd) {
3987 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xfe);
3988 if(custom1) SiS_PanelDelay(SiS_Pr, 3);
3989 } else {
3990 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xfc);
3991 }
3911 } 3992 }
3912 3993
3913 if(!custom1) { 3994 if(!custom1) {
3914 SiS_DDC2Delay(SiS_Pr,0xff00); 3995 SiS_DDC2Delay(SiS_Pr,0xff00);
3915 SiS_DDC2Delay(SiS_Pr,0xe000); 3996 SiS_DDC2Delay(SiS_Pr,0xe000);
3916 SiS_SetRegByte(SiS_Pr->SiS_P3c6,0x00); 3997 SiS_SetRegByte(SiS_Pr->SiS_P3c6,0x00);
3917 pushax = SiS_GetReg(SiS_Pr->SiS_P3c4,0x06); 3998 pushax = SiS_GetReg(SiS_Pr->SiS_P3c4,0x06);
3918 if(IS_SIS740) { 3999 if(IS_SIS740) {
3919 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x06,0xE3); 4000 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x06,0xE3);
3920 } 4001 }
3921 SiS_PanelDelay(SiS_Pr, HwInfo, 3); 4002 SiS_PanelDelay(SiS_Pr, 3);
3922 } 4003 }
3923 4004
3924 } 4005 }
3925 4006
3926 if(!(SiS_IsNotM650orLater(SiS_Pr, HwInfo))) { 4007 if(!(SiS_IsNotM650orLater(SiS_Pr))) {
3927 if(HwInfo->jChipType < SIS_340) { 4008 /* if(SiS_Pr->ChipType < SIS_340) {*/
3928 tempah = 0xef; 4009 tempah = 0xef;
3929 if(SiS_IsVAMode(SiS_Pr,HwInfo)) tempah = 0xf7; 4010 if(SiS_IsVAMode(SiS_Pr)) tempah = 0xf7;
3930 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x4c,tempah); 4011 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x4c,tempah);
3931 } 4012 /*}*/
3932 } 4013 }
3933 4014
3934 if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { 4015 if(SiS_Pr->SiS_VBType & VB_SISLVDS) {
3935 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1F,~0x10); 4016 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1F,~0x10);
3936 } 4017 }
3937 4018
3938 tempah = 0x3f; 4019 tempah = 0x3f;
3939 if(SiS_IsDualEdge(SiS_Pr,HwInfo)) { 4020 if(SiS_IsDualEdge(SiS_Pr)) {
3940 tempah = 0x7f; 4021 tempah = 0x7f;
3941 if(!(SiS_IsVAMode(SiS_Pr,HwInfo))) tempah = 0xbf; 4022 if(!(SiS_IsVAMode(SiS_Pr))) tempah = 0xbf;
3942 } 4023 }
3943 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1F,tempah); 4024 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1F,tempah);
3944 4025
3945 if((SiS_IsVAMode(SiS_Pr,HwInfo)) || 4026 if((SiS_IsVAMode(SiS_Pr)) ||
3946 ((SiS_Pr->SiS_VBType & VB_SIS301LV302LV) && (modenum <= 0x13))) { 4027 ((SiS_Pr->SiS_VBType & VB_SISLVDS) && (modenum <= 0x13))) {
3947 4028
3948 SiS_DisplayOff(SiS_Pr); 4029 SiS_DisplayOff(SiS_Pr);
3949 if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { 4030 if(SiS_Pr->SiS_VBType & VB_SISLVDS) {
3950 SiS_PanelDelay(SiS_Pr, HwInfo, 2); 4031 SiS_PanelDelay(SiS_Pr, 2);
3951 } 4032 }
3952 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); 4033 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF);
3953 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1E,0xDF); 4034 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1E,0xDF);
3954 4035
3955 } 4036 }
3956 4037
3957 if((!(SiS_IsVAMode(SiS_Pr,HwInfo))) || 4038 if((!(SiS_IsVAMode(SiS_Pr))) ||
3958 ((SiS_Pr->SiS_VBType & VB_SIS301LV302LV) && (modenum <= 0x13))) { 4039 ((SiS_Pr->SiS_VBType & VB_SISLVDS) && (modenum <= 0x13))) {
3959 4040
3960 if(!(SiS_IsDualEdge(SiS_Pr,HwInfo))) { 4041 if(!(SiS_IsDualEdge(SiS_Pr))) {
3961 SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xdf); 4042 SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xdf);
3962 SiS_DisplayOff(SiS_Pr); 4043 SiS_DisplayOff(SiS_Pr);
3963 } 4044 }
3964 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); 4045 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80);
3965 4046
3966 if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { 4047 if(SiS_Pr->SiS_VBType & VB_SISLVDS) {
3967 SiS_PanelDelay(SiS_Pr, HwInfo, 2); 4048 SiS_PanelDelay(SiS_Pr, 2);
3968 } 4049 }
3969 4050
3970 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); 4051 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF);
3971 temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00); 4052 temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00);
3972 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x10); 4053 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x10);
3973 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); 4054 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF);
3974 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,temp); 4055 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,temp);
3975 4056
3976 } 4057 }
3977 4058
3978 if(SiS_IsNotM650orLater(SiS_Pr,HwInfo)) { 4059 if(SiS_IsNotM650orLater(SiS_Pr)) {
3979 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); 4060 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f);
3980 } 4061 }
3981 4062
3982 if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { 4063 if(SiS_Pr->SiS_VBType & VB_SISLVDS) {
3983
3984 if(!custom1) {
3985
3986 if(!(SiS_IsVAMode(SiS_Pr,HwInfo))) {
3987 if(!(SiS_CRT2IsLCD(SiS_Pr,HwInfo))) {
3988 if(!(SiS_IsDualEdge(SiS_Pr,HwInfo))) {
3989 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFD);
3990 }
3991 }
3992 }
3993 4064
3994 SiS_SetReg(SiS_Pr->SiS_P3c4,0x06,pushax); 4065 if( (!(SiS_IsVAMode(SiS_Pr))) &&
4066 (!(SiS_CRT2IsLCD(SiS_Pr))) &&
4067 (!(SiS_IsDualEdge(SiS_Pr))) ) {
3995 4068
3996 if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { 4069 if(custom1) SiS_PanelDelay(SiS_Pr, 2);
3997 if(SiS_IsVAorLCD(SiS_Pr, HwInfo)) { 4070 if(!didpwd) {
3998 SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 20); 4071 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFD);
3999 } 4072 }
4000 } 4073 if(custom1) SiS_PanelDelay(SiS_Pr, 4);
4001 4074 }
4002 } else {
4003 4075
4004 if((SiS_IsVAMode(SiS_Pr,HwInfo)) || 4076 if(!custom1) {
4005 (!(SiS_IsDualEdge(SiS_Pr,HwInfo)))) { 4077 SiS_SetReg(SiS_Pr->SiS_P3c4,0x06,pushax);
4006 if((!(SiS_WeHaveBacklightCtrl(SiS_Pr, HwInfo))) || 4078 if(SiS_Pr->SiS_VBType & VB_SISEMI) {
4007 (!(SiS_CRT2IsLCD(SiS_Pr, HwInfo)))) { 4079 if(SiS_IsVAorLCD(SiS_Pr)) {
4008 SiS_PanelDelay(SiS_Pr, HwInfo, 2); 4080 SiS_PanelDelayLoop(SiS_Pr, 3, 20);
4009 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFD);
4010 SiS_PanelDelay(SiS_Pr, HwInfo, 4);
4011 } 4081 }
4012 } 4082 }
4013
4014 } 4083 }
4015 } 4084
4085 }
4016 4086
4017#endif /* SIS315H */ 4087#endif /* SIS315H */
4018 4088
@@ -4020,36 +4090,36 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
4020 4090
4021 } else { /* ============ For 301 ================ */ 4091 } else { /* ============ For 301 ================ */
4022 4092
4023 if(HwInfo->jChipType < SIS_315H) { 4093 if(SiS_Pr->ChipType < SIS_315H) {
4024#ifdef SIS300 4094#ifdef SIS300
4025 if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) { 4095 if(!(SiS_CR36BIOSWord23b(SiS_Pr))) {
4026 SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x08); 4096 SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x08);
4027 SiS_PanelDelay(SiS_Pr, HwInfo, 3); 4097 SiS_PanelDelay(SiS_Pr, 3);
4028 } 4098 }
4029#endif 4099#endif
4030 } 4100 }
4031 4101
4032 SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xDF); /* disable VB */ 4102 SiS_SetRegAND(SiS_Pr->SiS_Part2Port,0x00,0xDF); /* disable VB */
4033 SiS_DisplayOff(SiS_Pr); 4103 SiS_DisplayOff(SiS_Pr);
4034 4104
4035 if(HwInfo->jChipType >= SIS_315H) { 4105 if(SiS_Pr->ChipType >= SIS_315H) {
4036 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); 4106 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80);
4037 } 4107 }
4038 4108
4039 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); /* disable lock mode */ 4109 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); /* disable lock mode */
4040 4110
4041 if(HwInfo->jChipType >= SIS_315H) { 4111 if(SiS_Pr->ChipType >= SIS_315H) {
4042 temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00); 4112 temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00);
4043 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x10); 4113 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x10);
4044 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); 4114 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20);
4045 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,temp); 4115 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,temp);
4046 } else { 4116 } else {
4047#ifdef SIS300 4117#ifdef SIS300
4048 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); /* disable CRT2 */ 4118 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); /* disable CRT2 */
4049 if( (!(SiS_CRT2IsLCD(SiS_Pr, HwInfo))) || 4119 if( (!(SiS_CRT2IsLCD(SiS_Pr))) ||
4050 (!(SiS_CR36BIOSWord23d(SiS_Pr,HwInfo))) ) { 4120 (!(SiS_CR36BIOSWord23d(SiS_Pr))) ) {
4051 SiS_PanelDelay(SiS_Pr, HwInfo, 2); 4121 SiS_PanelDelay(SiS_Pr, 2);
4052 SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x04); 4122 SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x04);
4053 } 4123 }
4054#endif 4124#endif
4055 } 4125 }
@@ -4058,34 +4128,34 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
4058 4128
4059 } else { /* ============ For LVDS =============*/ 4129 } else { /* ============ For LVDS =============*/
4060 4130
4061 if(HwInfo->jChipType < SIS_315H) { 4131 if(SiS_Pr->ChipType < SIS_315H) {
4062 4132
4063#ifdef SIS300 /* 300 series */ 4133#ifdef SIS300 /* 300 series */
4064 4134
4065 if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { 4135 if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) {
4066 SiS_SetCH700x(SiS_Pr,0x090E); 4136 SiS_SetCH700x(SiS_Pr,0x0E,0x09);
4067 } 4137 }
4068 4138
4069 if(HwInfo->jChipType == SIS_730) { 4139 if(SiS_Pr->ChipType == SIS_730) {
4070 if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x11) & 0x08)) { 4140 if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x11) & 0x08)) {
4071 SiS_WaitVBRetrace(SiS_Pr,HwInfo); 4141 SiS_WaitVBRetrace(SiS_Pr);
4072 } 4142 }
4073 if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) { 4143 if(!(SiS_CR36BIOSWord23b(SiS_Pr))) {
4074 SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x08); 4144 SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x08);
4075 SiS_PanelDelay(SiS_Pr, HwInfo, 3); 4145 SiS_PanelDelay(SiS_Pr, 3);
4076 } 4146 }
4077 } else { 4147 } else {
4078 if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x11) & 0x08)) { 4148 if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x11) & 0x08)) {
4079 if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x40)) { 4149 if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x40)) {
4080 if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) { 4150 if(!(SiS_CR36BIOSWord23b(SiS_Pr))) {
4081 SiS_WaitVBRetrace(SiS_Pr,HwInfo); 4151 SiS_WaitVBRetrace(SiS_Pr);
4082 if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x06) & 0x1c)) { 4152 if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x06) & 0x1c)) {
4083 SiS_DisplayOff(SiS_Pr); 4153 SiS_DisplayOff(SiS_Pr);
4084 } 4154 }
4085 SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x08); 4155 SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x08);
4086 SiS_PanelDelay(SiS_Pr, HwInfo, 3); 4156 SiS_PanelDelay(SiS_Pr, 3);
4087 } 4157 }
4088 } 4158 }
4089 } 4159 }
4090 } 4160 }
4091 4161
@@ -4094,14 +4164,14 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
4094 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); 4164 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF);
4095 4165
4096 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); 4166 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF);
4097 SiS_UnLockCRT2(SiS_Pr,HwInfo); 4167 SiS_UnLockCRT2(SiS_Pr);
4098 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x80); 4168 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x80);
4099 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x02,0x40); 4169 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x02,0x40);
4100 4170
4101 if( (!(SiS_CRT2IsLCD(SiS_Pr, HwInfo))) || 4171 if( (!(SiS_CRT2IsLCD(SiS_Pr))) ||
4102 (!(SiS_CR36BIOSWord23d(SiS_Pr,HwInfo))) ) { 4172 (!(SiS_CR36BIOSWord23d(SiS_Pr))) ) {
4103 SiS_PanelDelay(SiS_Pr, HwInfo, 2); 4173 SiS_PanelDelay(SiS_Pr, 2);
4104 SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x04); 4174 SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x04);
4105 } 4175 }
4106 4176
4107#endif /* SIS300 */ 4177#endif /* SIS300 */
@@ -4110,113 +4180,113 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
4110 4180
4111#ifdef SIS315H /* 315 series */ 4181#ifdef SIS315H /* 315 series */
4112 4182
4113 if(!(SiS_IsNotM650orLater(SiS_Pr,HwInfo))) { 4183 if(!(SiS_IsNotM650orLater(SiS_Pr))) {
4114 if(HwInfo->jChipType < SIS_340) { 4184 /*if(SiS_Pr->ChipType < SIS_340) { */ /* XGI needs this */
4115 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x4c,~0x18); 4185 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x4c,~0x18);
4116 } 4186 /* } */
4117 } 4187 }
4118 4188
4119 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { 4189 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
4120 4190
4121 if(HwInfo->jChipType == SIS_740) { 4191 if(SiS_Pr->ChipType == SIS_740) {
4122 temp = SiS_GetCH701x(SiS_Pr,0x61); 4192 temp = SiS_GetCH701x(SiS_Pr,0x61);
4123 if(temp < 1) { 4193 if(temp < 1) {
4124 SiS_SetCH701x(SiS_Pr,0xac76); 4194 SiS_SetCH701x(SiS_Pr,0x76,0xac);
4125 SiS_SetCH701x(SiS_Pr,0x0066); 4195 SiS_SetCH701x(SiS_Pr,0x66,0x00);
4126 } 4196 }
4127 4197
4128 if( (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) || 4198 if( (!(SiS_IsDualEdge(SiS_Pr))) ||
4129 (SiS_IsTVOrYPbPrOrScart(SiS_Pr,HwInfo)) ) { 4199 (SiS_IsTVOrYPbPrOrScart(SiS_Pr)) ) {
4130 SiS_SetCH701x(SiS_Pr,0x3e49); 4200 SiS_SetCH701x(SiS_Pr,0x49,0x3e);
4131 } 4201 }
4132 } 4202 }
4133 4203
4134 if( (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) || 4204 if( (!(SiS_IsDualEdge(SiS_Pr))) ||
4135 (SiS_IsVAMode(SiS_Pr,HwInfo)) ) { 4205 (SiS_IsVAMode(SiS_Pr)) ) {
4136 SiS_Chrontel701xBLOff(SiS_Pr); 4206 SiS_Chrontel701xBLOff(SiS_Pr);
4137 SiS_Chrontel701xOff(SiS_Pr,HwInfo); 4207 SiS_Chrontel701xOff(SiS_Pr);
4138 } 4208 }
4139 4209
4140 if(HwInfo->jChipType != SIS_740) { 4210 if(SiS_Pr->ChipType != SIS_740) {
4141 if( (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) || 4211 if( (!(SiS_IsDualEdge(SiS_Pr))) ||
4142 (SiS_IsTVOrYPbPrOrScart(SiS_Pr,HwInfo)) ) { 4212 (SiS_IsTVOrYPbPrOrScart(SiS_Pr)) ) {
4143 SiS_SetCH701x(SiS_Pr,0x0149); 4213 SiS_SetCH701x(SiS_Pr,0x49,0x01);
4144 } 4214 }
4145 } 4215 }
4146 4216
4147 } 4217 }
4148 4218
4149 if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { 4219 if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) {
4150 SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x08); 4220 SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x08);
4151 SiS_PanelDelay(SiS_Pr, HwInfo, 3); 4221 SiS_PanelDelay(SiS_Pr, 3);
4152 } 4222 }
4153 4223
4154 if( (SiS_Pr->SiS_IF_DEF_CH70xx == 0) || 4224 if( (SiS_Pr->SiS_IF_DEF_CH70xx == 0) ||
4155 (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) || 4225 (!(SiS_IsDualEdge(SiS_Pr))) ||
4156 (!(SiS_IsTVOrYPbPrOrScart(SiS_Pr,HwInfo))) ) { 4226 (!(SiS_IsTVOrYPbPrOrScart(SiS_Pr))) ) {
4157 SiS_DisplayOff(SiS_Pr); 4227 SiS_DisplayOff(SiS_Pr);
4158 } 4228 }
4159 4229
4160 if( (SiS_Pr->SiS_IF_DEF_CH70xx == 0) || 4230 if( (SiS_Pr->SiS_IF_DEF_CH70xx == 0) ||
4161 (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) || 4231 (!(SiS_IsDualEdge(SiS_Pr))) ||
4162 (!(SiS_IsVAMode(SiS_Pr,HwInfo))) ) { 4232 (!(SiS_IsVAMode(SiS_Pr))) ) {
4163 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80); 4233 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x00,0x80);
4164 } 4234 }
4165 4235
4166 if(HwInfo->jChipType == SIS_740) { 4236 if(SiS_Pr->ChipType == SIS_740) {
4167 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); 4237 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f);
4168 } 4238 }
4169 4239
4170 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF); 4240 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x32,0xDF);
4171 4241
4172 if( (SiS_Pr->SiS_IF_DEF_CH70xx == 0) || 4242 if( (SiS_Pr->SiS_IF_DEF_CH70xx == 0) ||
4173 (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) || 4243 (!(SiS_IsDualEdge(SiS_Pr))) ||
4174 (!(SiS_IsVAMode(SiS_Pr,HwInfo))) ) { 4244 (!(SiS_IsVAMode(SiS_Pr))) ) {
4175 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF); 4245 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x1E,0xDF);
4176 } 4246 }
4177 4247
4178 if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { 4248 if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) {
4179 if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { 4249 if(SiS_CRT2IsLCD(SiS_Pr)) {
4180 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf); 4250 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf);
4181 if(HwInfo->jChipType == SIS_550) { 4251 if(SiS_Pr->ChipType == SIS_550) {
4182 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xbf); 4252 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xbf);
4183 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xef); 4253 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xef);
4184 } 4254 }
4185 } 4255 }
4186 } else { 4256 } else {
4187 if(HwInfo->jChipType == SIS_740) { 4257 if(SiS_Pr->ChipType == SIS_740) {
4188 if(SiS_IsLCDOrLCDA(SiS_Pr,HwInfo)) { 4258 if(SiS_IsLCDOrLCDA(SiS_Pr)) {
4189 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf); 4259 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf);
4190 } 4260 }
4191 } else if(SiS_IsVAMode(SiS_Pr,HwInfo)) { 4261 } else if(SiS_IsVAMode(SiS_Pr)) {
4192 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf); 4262 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x1e,0xdf);
4193 } 4263 }
4194 } 4264 }
4195 4265
4196 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { 4266 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
4197 if(SiS_IsDualEdge(SiS_Pr,HwInfo)) { 4267 if(SiS_IsDualEdge(SiS_Pr)) {
4198 /* SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xff); */ 4268 /* SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xff); */
4199 } else { 4269 } else {
4200 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb); 4270 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x13,0xfb);
4201 } 4271 }
4202 } 4272 }
4203 4273
4204 SiS_UnLockCRT2(SiS_Pr,HwInfo); 4274 SiS_UnLockCRT2(SiS_Pr);
4205 4275
4206 if(HwInfo->jChipType == SIS_550) { 4276 if(SiS_Pr->ChipType == SIS_550) {
4207 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x80); /* DirectDVD PAL?*/ 4277 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x80); /* DirectDVD PAL?*/
4208 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x02,0x40); /* VB clock / 4 ? */ 4278 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x02,0x40); /* VB clock / 4 ? */
4209 } else if( (SiS_Pr->SiS_IF_DEF_CH70xx == 0) || 4279 } else if( (SiS_Pr->SiS_IF_DEF_CH70xx == 0) ||
4210 (!(SiS_IsDualEdge(SiS_Pr,HwInfo))) || 4280 (!(SiS_IsDualEdge(SiS_Pr))) ||
4211 (!(SiS_IsVAMode(SiS_Pr,HwInfo))) ) { 4281 (!(SiS_IsVAMode(SiS_Pr))) ) {
4212 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0xf7); 4282 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0xf7);
4213 } 4283 }
4214 4284
4215 if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { 4285 if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) {
4216 if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { 4286 if(SiS_CRT2IsLCD(SiS_Pr)) {
4217 if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) { 4287 if(!(SiS_WeHaveBacklightCtrl(SiS_Pr))) {
4218 SiS_PanelDelay(SiS_Pr, HwInfo, 2); 4288 SiS_PanelDelay(SiS_Pr, 2);
4219 SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x04); 4289 SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x04);
4220 } 4290 }
4221 } 4291 }
4222 } 4292 }
@@ -4237,78 +4307,81 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
4237 * from outside the context of a mode switch! 4307 * from outside the context of a mode switch!
4238 * MUST call getVBType before calling this 4308 * MUST call getVBType before calling this
4239 */ 4309 */
4240static void 4310#ifdef SIS_LINUX_KERNEL
4241SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 4311static
4312#endif
4313void
4314SiS_EnableBridge(struct SiS_Private *SiS_Pr)
4242{ 4315{
4243 USHORT temp=0,tempah; 4316 unsigned short temp=0, tempah;
4244#ifdef SIS315H 4317#ifdef SIS315H
4245 USHORT temp1,pushax=0; 4318 unsigned short temp1, pushax=0;
4246 BOOLEAN delaylong = FALSE; 4319 BOOLEAN delaylong = FALSE;
4247#endif 4320#endif
4248 4321
4249 if(SiS_Pr->SiS_VBType & VB_SISVB) { 4322 if(SiS_Pr->SiS_VBType & VB_SISVB) {
4250 4323
4251 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* ====== For 301B et al ====== */ 4324 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { /* ====== For 301B et al ====== */
4252 4325
4253 if(HwInfo->jChipType < SIS_315H) { 4326 if(SiS_Pr->ChipType < SIS_315H) {
4254 4327
4255#ifdef SIS300 /* 300 series */ 4328#ifdef SIS300 /* 300 series */
4256 4329
4257 if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { 4330 if(SiS_CRT2IsLCD(SiS_Pr)) {
4258 if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { 4331 if(SiS_Pr->SiS_VBType & VB_SISLVDS) {
4259 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02); 4332 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02);
4260 } else if(SiS_Pr->SiS_VBType & VB_NoLCD) { 4333 } else if(SiS_Pr->SiS_VBType & VB_NoLCD) {
4261 SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x00); 4334 SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x00);
4262 } 4335 }
4263 if(SiS_Pr->SiS_VBType & (VB_SIS301LV302LV | VB_NoLCD)) { 4336 if(SiS_Pr->SiS_VBType & (VB_SISLVDS | VB_NoLCD)) {
4264 if(!(SiS_CR36BIOSWord23d(SiS_Pr, HwInfo))) { 4337 if(!(SiS_CR36BIOSWord23d(SiS_Pr))) {
4265 SiS_PanelDelay(SiS_Pr, HwInfo, 0); 4338 SiS_PanelDelay(SiS_Pr, 0);
4266 } 4339 }
4267 } 4340 }
4268 } 4341 }
4269 4342
4270 if((SiS_Pr->SiS_VBType & VB_NoLCD) && 4343 if((SiS_Pr->SiS_VBType & VB_NoLCD) &&
4271 (SiS_CRT2IsLCD(SiS_Pr, HwInfo))) { 4344 (SiS_CRT2IsLCD(SiS_Pr))) {
4272 4345
4273 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* Enable CRT2 */ 4346 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* Enable CRT2 */
4274 SiS_DisplayOn(SiS_Pr); 4347 SiS_DisplayOn(SiS_Pr);
4275 SiS_UnLockCRT2(SiS_Pr,HwInfo); 4348 SiS_UnLockCRT2(SiS_Pr);
4276 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0xBF); 4349 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0xBF);
4277 if(SiS_BridgeInSlavemode(SiS_Pr)) { 4350 if(SiS_BridgeInSlavemode(SiS_Pr)) {
4278 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x01,0x1F); 4351 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x01,0x1F);
4279 } else { 4352 } else {
4280 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0x1F,0x40); 4353 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0x1F,0x40);
4281 } 4354 }
4282 if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x40)) { 4355 if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x40)) {
4283 if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x16) & 0x10)) { 4356 if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x16) & 0x10)) {
4284 if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) { 4357 if(!(SiS_CR36BIOSWord23b(SiS_Pr))) {
4285 SiS_PanelDelay(SiS_Pr, HwInfo, 1); 4358 SiS_PanelDelay(SiS_Pr, 1);
4286 } 4359 }
4287 SiS_WaitVBRetrace(SiS_Pr,HwInfo); 4360 SiS_WaitVBRetrace(SiS_Pr);
4288 SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x00); 4361 SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x00);
4289 } 4362 }
4290 } 4363 }
4291 4364
4292 } else { 4365 } else {
4293 4366
4294 temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32) & 0xDF; /* lock mode */ 4367 temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32) & 0xDF; /* lock mode */
4295 if(SiS_BridgeInSlavemode(SiS_Pr)) { 4368 if(SiS_BridgeInSlavemode(SiS_Pr)) {
4296 tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); 4369 tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30);
4297 if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20; 4370 if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20;
4298 } 4371 }
4299 SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,temp); 4372 SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,temp);
4300 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); 4373 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20);
4301 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1F,0x20); /* enable VB processor */ 4374 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1F,0x20); /* enable VB processor */
4302 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,0xC0); 4375 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,0xC0);
4303 SiS_DisplayOn(SiS_Pr); 4376 SiS_DisplayOn(SiS_Pr);
4304 if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { 4377 if(SiS_Pr->SiS_VBType & VB_SISLVDS) {
4305 if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { 4378 if(SiS_CRT2IsLCD(SiS_Pr)) {
4306 if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x16) & 0x10)) { 4379 if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x16) & 0x10)) {
4307 if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) { 4380 if(!(SiS_CR36BIOSWord23b(SiS_Pr))) {
4308 SiS_PanelDelay(SiS_Pr, HwInfo, 1); 4381 SiS_PanelDelay(SiS_Pr, 1);
4309 } 4382 }
4310 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x01); 4383 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x01);
4311 } 4384 }
4312 } 4385 }
4313 } 4386 }
4314 4387
@@ -4322,31 +4395,32 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
4322#ifdef SIS315H /* 315 series */ 4395#ifdef SIS315H /* 315 series */
4323 4396
4324#ifdef SET_EMI 4397#ifdef SET_EMI
4325 UCHAR r30=0, r31=0, r32=0, r33=0, cr36=0; 4398 unsigned char r30=0, r31=0, r32=0, r33=0, cr36=0;
4326 /* USHORT emidelay=0; */ 4399 int didpwd = 0;
4400 /* unsigned short emidelay=0; */
4327#endif 4401#endif
4328 4402
4329 if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { 4403 if(SiS_Pr->SiS_VBType & VB_SISLVDS) {
4330 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1f,0xef); 4404 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x1f,0xef);
4331#ifdef SET_EMI 4405#ifdef SET_EMI
4332 if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { 4406 if(SiS_Pr->SiS_VBType & VB_SISEMI) {
4333 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); 4407 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c);
4334 } 4408 }
4335#endif 4409#endif
4336 } 4410 }
4337 4411
4338 if(!(SiS_IsNotM650orLater(SiS_Pr, HwInfo))) { 4412 if(!(SiS_IsNotM650orLater(SiS_Pr))) {
4339 if(HwInfo->jChipType < SIS_340) { 4413 /*if(SiS_Pr->ChipType < SIS_340) { */
4340 tempah = 0x10; 4414 tempah = 0x10;
4341 if(SiS_LCDAEnabled(SiS_Pr, HwInfo)) { 4415 if(SiS_LCDAEnabled(SiS_Pr)) {
4342 if(SiS_TVEnabled(SiS_Pr, HwInfo)) tempah = 0x18; 4416 if(SiS_TVEnabled(SiS_Pr)) tempah = 0x18;
4343 else tempah = 0x08; 4417 else tempah = 0x08;
4344 } 4418 }
4345 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x4c,tempah); 4419 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x4c,tempah);
4346 } 4420 /*}*/
4347 } 4421 }
4348 4422
4349 if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { 4423 if(SiS_Pr->SiS_VBType & VB_SISLVDS) {
4350 4424
4351 SiS_SetRegByte(SiS_Pr->SiS_P3c6,0x00); 4425 SiS_SetRegByte(SiS_Pr->SiS_P3c6,0x00);
4352 SiS_DisplayOff(SiS_Pr); 4426 SiS_DisplayOff(SiS_Pr);
@@ -4355,42 +4429,51 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
4355 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x06,0xE3); 4429 SiS_SetRegAND(SiS_Pr->SiS_P3c4,0x06,0xE3);
4356 } 4430 }
4357 4431
4358 if(SiS_IsVAorLCD(SiS_Pr, HwInfo)) { 4432 didpwd = SiS_HandlePWD(SiS_Pr);
4359 if(!(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x26) & 0x02)) { 4433
4360 SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 2); 4434 if(SiS_IsVAorLCD(SiS_Pr)) {
4361 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02); 4435 if(!didpwd) {
4362 SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 2); 4436 if(!(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x26) & 0x02)) {
4363 if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { 4437 SiS_PanelDelayLoop(SiS_Pr, 3, 2);
4364 SiS_GenericDelay(SiS_Pr, 0x4500); 4438 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02);
4439 SiS_PanelDelayLoop(SiS_Pr, 3, 2);
4440 if(SiS_Pr->SiS_VBType & VB_SISEMI) {
4441 SiS_GenericDelay(SiS_Pr, 17664);
4442 }
4443 }
4444 } else {
4445 SiS_PanelDelayLoop(SiS_Pr, 3, 2);
4446 if(SiS_Pr->SiS_VBType & VB_SISEMI) {
4447 SiS_GenericDelay(SiS_Pr, 17664);
4365 } 4448 }
4366 } 4449 }
4367 } 4450 }
4368 4451
4369 if(!(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & 0x40)) { 4452 if(!(SiS_GetReg(SiS_Pr->SiS_P3d4,0x31) & 0x40)) {
4370 SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 10); 4453 SiS_PanelDelayLoop(SiS_Pr, 3, 10);
4371 delaylong = TRUE; 4454 delaylong = TRUE;
4372 } 4455 }
4373 4456
4374 } 4457 }
4375 4458
4376 if(!(SiS_IsVAMode(SiS_Pr,HwInfo))) { 4459 if(!(SiS_IsVAMode(SiS_Pr))) {
4377 4460
4378 temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32) & 0xDF; 4461 temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32) & 0xDF;
4379 if(SiS_BridgeInSlavemode(SiS_Pr)) { 4462 if(SiS_BridgeInSlavemode(SiS_Pr)) {
4380 tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); 4463 tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30);
4381 if(!(tempah & SetCRT2ToRAMDAC)) { 4464 if(!(tempah & SetCRT2ToRAMDAC)) {
4382 if(!(SiS_LCDAEnabled(SiS_Pr, HwInfo))) temp |= 0x20; 4465 if(!(SiS_LCDAEnabled(SiS_Pr))) temp |= 0x20;
4383 } 4466 }
4384 } 4467 }
4385 SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,temp); 4468 SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,temp);
4386 4469
4387 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* enable CRT2 */ 4470 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* enable CRT2 */
4388 4471
4389 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); 4472 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f);
4390 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x80); 4473 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x80);
4391 4474
4392 if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { 4475 if(SiS_Pr->SiS_VBType & VB_SISLVDS) {
4393 SiS_PanelDelay(SiS_Pr, HwInfo, 2); 4476 SiS_PanelDelay(SiS_Pr, 2);
4394 } 4477 }
4395 4478
4396 } else { 4479 } else {
@@ -4402,38 +4485,48 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
4402 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1f,0x20); 4485 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x00,0x1f,0x20);
4403 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x80); 4486 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x80);
4404 4487
4488 if(SiS_Pr->SiS_VBType & VB_SISPOWER) {
4489 if( (SiS_LCDAEnabled(SiS_Pr)) ||
4490 (SiS_CRT2IsLCD(SiS_Pr)) ) {
4491 /* Enable "LVDS PLL power on" (even on 301C) */
4492 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x2a,0x7f);
4493 /* Enable "LVDS Driver Power on" (even on 301C) */
4494 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x7f);
4495 }
4496 }
4497
4405 tempah = 0xc0; 4498 tempah = 0xc0;
4406 if(SiS_IsDualEdge(SiS_Pr, HwInfo)) { 4499 if(SiS_IsDualEdge(SiS_Pr)) {
4407 tempah = 0x80; 4500 tempah = 0x80;
4408 if(!(SiS_IsVAMode(SiS_Pr, HwInfo))) tempah = 0x40; 4501 if(!(SiS_IsVAMode(SiS_Pr))) tempah = 0x40;
4409 } 4502 }
4410 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,tempah); 4503 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1F,tempah);
4411 4504
4412 if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { 4505 if(SiS_Pr->SiS_VBType & VB_SISLVDS) {
4413 4506
4414 SiS_PanelDelay(SiS_Pr, HwInfo, 2); 4507 SiS_PanelDelay(SiS_Pr, 2);
4415 4508
4416 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1f,0x10); 4509 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x1f,0x10);
4417 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x80); 4510 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2e,0x80);
4418 4511
4419 if(SiS_Pr->SiS_CustomT != CUT_CLEVO1400) { 4512 if(SiS_Pr->SiS_CustomT != CUT_CLEVO1400) {
4420#ifdef SET_EMI 4513#ifdef SET_EMI
4421 if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { 4514 if(SiS_Pr->SiS_VBType & VB_SISEMI) {
4422 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); 4515 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c);
4423 SiS_GenericDelay(SiS_Pr, 0x500); 4516 SiS_GenericDelay(SiS_Pr, 2048);
4424 } 4517 }
4425#endif 4518#endif
4426 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x0c); 4519 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x0c);
4427 4520
4428 if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { 4521 if(SiS_Pr->SiS_VBType & VB_SISEMI) {
4429#ifdef SET_EMI 4522#ifdef SET_EMI
4430 cr36 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36); 4523 cr36 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36);
4431 4524
4432 if(SiS_Pr->SiS_ROMNew) { 4525 if(SiS_Pr->SiS_ROMNew) {
4433 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; 4526 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
4434 USHORT romptr = GetLCDStructPtr661_2(SiS_Pr, HwInfo); 4527 unsigned short romptr = GetLCDStructPtr661_2(SiS_Pr);
4435 if(romptr) { 4528 if(romptr) {
4436 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x20); /* Reset */ 4529 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x20); /* Reset */
4437 SiS_Pr->EMI_30 = 0; 4530 SiS_Pr->EMI_30 = 0;
4438 SiS_Pr->EMI_31 = ROMAddr[romptr + SiS_Pr->SiS_EMIOffset + 0]; 4531 SiS_Pr->EMI_31 = ROMAddr[romptr + SiS_Pr->SiS_EMIOffset + 0];
4439 SiS_Pr->EMI_32 = ROMAddr[romptr + SiS_Pr->SiS_EMIOffset + 1]; 4532 SiS_Pr->EMI_32 = ROMAddr[romptr + SiS_Pr->SiS_EMIOffset + 1];
@@ -4511,21 +4604,21 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
4511 if(!SiS_Pr->OverruleEMI) { 4604 if(!SiS_Pr->OverruleEMI) {
4512#ifdef COMPAL_HACK 4605#ifdef COMPAL_HACK
4513 if(SiS_Pr->SiS_CustomT == CUT_COMPAL1400_2) { 4606 if(SiS_Pr->SiS_CustomT == CUT_COMPAL1400_2) {
4514 if((cr36 & 0x0f) == 0x09) { 4607 if((cr36 & 0x0f) == 0x09) {
4515 r30 = 0x60; r31 = 0x05; r32 = 0x60; r33 = 0x00; 4608 r30 = 0x60; r31 = 0x05; r32 = 0x60; r33 = 0x00;
4516 } 4609 }
4517 } 4610 }
4518#endif 4611#endif
4519#ifdef COMPAQ_HACK 4612#ifdef COMPAQ_HACK
4520 if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) { 4613 if(SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) {
4521 if((cr36 & 0x0f) == 0x03) { 4614 if((cr36 & 0x0f) == 0x03) {
4522 r30 = 0x20; r31 = 0x12; r32 = 0xd0; r33 = 0x6b; 4615 r30 = 0x20; r31 = 0x12; r32 = 0xd0; r33 = 0x6b;
4523 } 4616 }
4524 } 4617 }
4525#endif 4618#endif
4526#ifdef ASUS_HACK 4619#ifdef ASUS_HACK
4527 if(SiS_Pr->SiS_CustomT == CUT_ASUSA2H_2) { 4620 if(SiS_Pr->SiS_CustomT == CUT_ASUSA2H_2) {
4528 if((cr36 & 0x0f) == 0x02) { 4621 if((cr36 & 0x0f) == 0x02) {
4529 /* r30 = 0x60; r31 = 0x05; r32 = 0x60; r33 = 0x33; */ /* rev 2 */ 4622 /* r30 = 0x60; r31 = 0x05; r32 = 0x60; r33 = 0x33; */ /* rev 2 */
4530 /* r30 = 0x20; r31 = 0x05; r32 = 0x60; r33 = 0x33; */ /* rev 3 */ 4623 /* r30 = 0x20; r31 = 0x05; r32 = 0x60; r33 = 0x33; */ /* rev 3 */
4531 /* r30 = 0x60; r31 = 0x0d; r32 = 0x70; r33 = 0x40; */ /* rev 4 */ 4624 /* r30 = 0x60; r31 = 0x0d; r32 = 0x70; r33 = 0x40; */ /* rev 4 */
@@ -4533,11 +4626,11 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
4533 } 4626 }
4534 } 4627 }
4535#endif 4628#endif
4536 } 4629 }
4537 4630
4538 if(!(SiS_Pr->OverruleEMI && (!r30) && (!r31) && (!r32) && (!r33))) { 4631 if(!(SiS_Pr->OverruleEMI && (!r30) && (!r31) && (!r32) && (!r33))) {
4539 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x20); /* Reset */ 4632 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x20); /* Reset */
4540 SiS_GenericDelay(SiS_Pr, 0x500); 4633 SiS_GenericDelay(SiS_Pr, 2048);
4541 } 4634 }
4542 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x31,r31); 4635 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x31,r31);
4543 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x32,r32); 4636 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x32,r32);
@@ -4547,36 +4640,44 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
4547 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x10); 4640 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x10);
4548 4641
4549#ifdef SET_EMI 4642#ifdef SET_EMI
4550 if( (SiS_LCDAEnabled(SiS_Pr, HwInfo)) || 4643 if( (SiS_LCDAEnabled(SiS_Pr)) ||
4551 (SiS_CRT2IsLCD(SiS_Pr, HwInfo)) ) { 4644 (SiS_CRT2IsLCD(SiS_Pr)) ) {
4552 if(r30 & 0x40) { 4645 if(r30 & 0x40) {
4553 SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 5); 4646 /*SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x2a,0x80);*/
4647 SiS_PanelDelayLoop(SiS_Pr, 3, 5);
4554 if(delaylong) { 4648 if(delaylong) {
4555 SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 5); 4649 SiS_PanelDelayLoop(SiS_Pr, 3, 5);
4556 delaylong = FALSE; 4650 delaylong = FALSE;
4557 } 4651 }
4558 SiS_WaitVBRetrace(SiS_Pr,HwInfo); 4652 SiS_WaitVBRetrace(SiS_Pr);
4653 SiS_WaitVBRetrace(SiS_Pr);
4559 if(SiS_Pr->SiS_CustomT == CUT_ASUSA2H_2) { 4654 if(SiS_Pr->SiS_CustomT == CUT_ASUSA2H_2) {
4560 SiS_GenericDelay(SiS_Pr, 0x500); 4655 SiS_GenericDelay(SiS_Pr, 1280);
4561 } 4656 }
4562 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x40); /* Enable */ 4657 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x30,0x40); /* Enable */
4563 } 4658 /*SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x2a,0x7f);*/
4659 }
4564 } 4660 }
4565#endif 4661#endif
4566 } 4662 }
4567 } 4663 }
4568 4664
4569 if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) { 4665 if(!(SiS_WeHaveBacklightCtrl(SiS_Pr))) {
4570 if(SiS_IsVAorLCD(SiS_Pr, HwInfo)) { 4666 if(SiS_IsVAorLCD(SiS_Pr)) {
4571 SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 10); 4667 SiS_PanelDelayLoop(SiS_Pr, 3, 10);
4572 if(delaylong) { 4668 if(delaylong) {
4573 SiS_PanelDelayLoop(SiS_Pr, HwInfo, 3, 10); 4669 SiS_PanelDelayLoop(SiS_Pr, 3, 10);
4574 } 4670 }
4575 SiS_WaitVBRetrace(SiS_Pr,HwInfo); 4671 SiS_WaitVBRetrace(SiS_Pr);
4576 if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { 4672 if(SiS_Pr->SiS_VBType & VB_SISEMI) {
4577 SiS_GenericDelay(SiS_Pr, 0x500); 4673 SiS_GenericDelay(SiS_Pr, 2048);
4674 SiS_WaitVBRetrace(SiS_Pr);
4675 }
4676 if(!didpwd) {
4677 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x01);
4678 } else {
4679 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x03);
4578 } 4680 }
4579 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x01);
4580 } 4681 }
4581 } 4682 }
4582 4683
@@ -4586,7 +4687,7 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
4586 4687
4587 } 4688 }
4588 4689
4589 if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) { 4690 if(!(SiS_WeHaveBacklightCtrl(SiS_Pr))) {
4590 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); 4691 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f);
4591 } 4692 }
4592 4693
@@ -4596,26 +4697,26 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
4596 4697
4597 } else { /* ============ For 301 ================ */ 4698 } else { /* ============ For 301 ================ */
4598 4699
4599 if(HwInfo->jChipType < SIS_315H) { 4700 if(SiS_Pr->ChipType < SIS_315H) {
4600 if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { 4701 if(SiS_CRT2IsLCD(SiS_Pr)) {
4601 SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x00); 4702 SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x00);
4602 SiS_PanelDelay(SiS_Pr, HwInfo, 0); 4703 SiS_PanelDelay(SiS_Pr, 0);
4603 } 4704 }
4604 } 4705 }
4605 4706
4606 temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32) & 0xDF; /* lock mode */ 4707 temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x32) & 0xDF; /* lock mode */
4607 if(SiS_BridgeInSlavemode(SiS_Pr)) { 4708 if(SiS_BridgeInSlavemode(SiS_Pr)) {
4608 tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30); 4709 tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x30);
4609 if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20; 4710 if(!(tempah & SetCRT2ToRAMDAC)) temp |= 0x20;
4610 } 4711 }
4611 SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,temp); 4712 SiS_SetReg(SiS_Pr->SiS_P3c4,0x32,temp);
4612 4713
4613 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* enable CRT2 */ 4714 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); /* enable CRT2 */
4614 4715
4615 if(HwInfo->jChipType >= SIS_315H) { 4716 if(SiS_Pr->ChipType >= SIS_315H) {
4616 temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x2E); 4717 temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x2E);
4617 if(!(temp & 0x80)) { 4718 if(!(temp & 0x80)) {
4618 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80); /* BVBDOENABLE=1 */ 4719 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80); /* BVBDOENABLE=1 */
4619 } 4720 }
4620 } 4721 }
4621 4722
@@ -4623,15 +4724,15 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
4623 4724
4624 SiS_VBLongWait(SiS_Pr); 4725 SiS_VBLongWait(SiS_Pr);
4625 SiS_DisplayOn(SiS_Pr); 4726 SiS_DisplayOn(SiS_Pr);
4626 if(HwInfo->jChipType >= SIS_315H) { 4727 if(SiS_Pr->ChipType >= SIS_315H) {
4627 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); 4728 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f);
4628 } 4729 }
4629 SiS_VBLongWait(SiS_Pr); 4730 SiS_VBLongWait(SiS_Pr);
4630 4731
4631 if(HwInfo->jChipType < SIS_315H) { 4732 if(SiS_Pr->ChipType < SIS_315H) {
4632 if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { 4733 if(SiS_CRT2IsLCD(SiS_Pr)) {
4633 SiS_PanelDelay(SiS_Pr, HwInfo, 1); 4734 SiS_PanelDelay(SiS_Pr, 1);
4634 SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x00); 4735 SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x00);
4635 } 4736 }
4636 } 4737 }
4637 4738
@@ -4639,49 +4740,49 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
4639 4740
4640 } else { /* =================== For LVDS ================== */ 4741 } else { /* =================== For LVDS ================== */
4641 4742
4642 if(HwInfo->jChipType < SIS_315H) { 4743 if(SiS_Pr->ChipType < SIS_315H) {
4643 4744
4644#ifdef SIS300 /* 300 series */ 4745#ifdef SIS300 /* 300 series */
4645 4746
4646 if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { 4747 if(SiS_CRT2IsLCD(SiS_Pr)) {
4647 if(HwInfo->jChipType == SIS_730) { 4748 if(SiS_Pr->ChipType == SIS_730) {
4648 SiS_PanelDelay(SiS_Pr, HwInfo, 1); 4749 SiS_PanelDelay(SiS_Pr, 1);
4649 SiS_PanelDelay(SiS_Pr, HwInfo, 1); 4750 SiS_PanelDelay(SiS_Pr, 1);
4650 SiS_PanelDelay(SiS_Pr, HwInfo, 1); 4751 SiS_PanelDelay(SiS_Pr, 1);
4651 } 4752 }
4652 SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x00); 4753 SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x00);
4653 if(!(SiS_CR36BIOSWord23d(SiS_Pr,HwInfo))) { 4754 if(!(SiS_CR36BIOSWord23d(SiS_Pr))) {
4654 SiS_PanelDelay(SiS_Pr, HwInfo, 0); 4755 SiS_PanelDelay(SiS_Pr, 0);
4655 } 4756 }
4656 } 4757 }
4657 4758
4658 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); 4759 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20);
4659 SiS_DisplayOn(SiS_Pr); 4760 SiS_DisplayOn(SiS_Pr);
4660 SiS_UnLockCRT2(SiS_Pr,HwInfo); 4761 SiS_UnLockCRT2(SiS_Pr);
4661 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0xBF); 4762 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0xBF);
4662 if(SiS_BridgeInSlavemode(SiS_Pr)) { 4763 if(SiS_BridgeInSlavemode(SiS_Pr)) {
4663 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x01,0x1F); 4764 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x01,0x1F);
4664 } else { 4765 } else {
4665 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0x1F,0x40); 4766 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0x1F,0x40);
4666 } 4767 }
4667 4768
4668 if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { 4769 if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) {
4669 if(!(SiS_CRT2IsLCD(SiS_Pr, HwInfo))) { 4770 if(!(SiS_CRT2IsLCD(SiS_Pr))) {
4670 SiS_WaitVBRetrace(SiS_Pr, HwInfo); 4771 SiS_WaitVBRetrace(SiS_Pr);
4671 SiS_SetCH700x(SiS_Pr,0x0B0E); 4772 SiS_SetCH700x(SiS_Pr,0x0E,0x0B);
4672 } 4773 }
4673 } 4774 }
4674 4775
4675 if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { 4776 if(SiS_CRT2IsLCD(SiS_Pr)) {
4676 if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x40)) { 4777 if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x13) & 0x40)) {
4677 if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x16) & 0x10)) { 4778 if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x16) & 0x10)) {
4678 if(!(SiS_CR36BIOSWord23b(SiS_Pr,HwInfo))) { 4779 if(!(SiS_CR36BIOSWord23b(SiS_Pr))) {
4679 SiS_PanelDelay(SiS_Pr, HwInfo, 1); 4780 SiS_PanelDelay(SiS_Pr, 1);
4680 SiS_PanelDelay(SiS_Pr, HwInfo, 1); 4781 SiS_PanelDelay(SiS_Pr, 1);
4681 } 4782 }
4682 SiS_WaitVBRetrace(SiS_Pr, HwInfo); 4783 SiS_WaitVBRetrace(SiS_Pr);
4683 SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x00); 4784 SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x00);
4684 } 4785 }
4685 } 4786 }
4686 } 4787 }
4687 4788
@@ -4691,94 +4792,94 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
4691 4792
4692#ifdef SIS315H /* 315 series */ 4793#ifdef SIS315H /* 315 series */
4693 4794
4694 if(!(SiS_IsNotM650orLater(SiS_Pr,HwInfo))) { 4795 if(!(SiS_IsNotM650orLater(SiS_Pr))) {
4695 if(HwInfo->jChipType < SIS_340) { 4796 /*if(SiS_Pr->ChipType < SIS_340) {*/ /* XGI needs this */
4696 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x4c,0x18); 4797 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x4c,0x18);
4697 } 4798 /*}*/
4698 } 4799 }
4699 4800
4700 if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { 4801 if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) {
4701 if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { 4802 if(SiS_CRT2IsLCD(SiS_Pr)) {
4702 SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFB,0x00); 4803 SiS_SetRegSR11ANDOR(SiS_Pr,0xFB,0x00);
4703 SiS_PanelDelay(SiS_Pr, HwInfo, 0); 4804 SiS_PanelDelay(SiS_Pr, 0);
4704 } 4805 }
4705 } 4806 }
4706 4807
4707 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); 4808 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20);
4708 SiS_UnLockCRT2(SiS_Pr,HwInfo); 4809 SiS_UnLockCRT2(SiS_Pr);
4709 4810
4710 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0xf7); 4811 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0xf7);
4711 4812
4712 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { 4813 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
4713 temp = SiS_GetCH701x(SiS_Pr,0x66); 4814 temp = SiS_GetCH701x(SiS_Pr,0x66);
4714 temp &= 0x20; 4815 temp &= 0x20;
4715 SiS_Chrontel701xBLOff(SiS_Pr); 4816 SiS_Chrontel701xBLOff(SiS_Pr);
4716 } 4817 }
4717 4818
4718 if(HwInfo->jChipType != SIS_550) { 4819 if(SiS_Pr->ChipType != SIS_550) {
4719 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f); 4820 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2e,0x7f);
4720 } 4821 }
4721 4822
4722 if(HwInfo->jChipType == SIS_740) { 4823 if(SiS_Pr->ChipType == SIS_740) {
4723 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { 4824 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
4724 if(SiS_IsLCDOrLCDA(SiS_Pr, HwInfo)) { 4825 if(SiS_IsLCDOrLCDA(SiS_Pr)) {
4725 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20); 4826 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20);
4726 } 4827 }
4727 } 4828 }
4728 } 4829 }
4729 4830
4730 temp1 = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x2E); 4831 temp1 = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x2E);
4731 if(!(temp1 & 0x80)) { 4832 if(!(temp1 & 0x80)) {
4732 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80); 4833 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2E,0x80);
4733 } 4834 }
4734 4835
4735 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { 4836 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
4736 if(temp) { 4837 if(temp) {
4737 SiS_Chrontel701xBLOn(SiS_Pr, HwInfo); 4838 SiS_Chrontel701xBLOn(SiS_Pr);
4738 } 4839 }
4739 } 4840 }
4740 4841
4741 if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { 4842 if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) {
4742 if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { 4843 if(SiS_CRT2IsLCD(SiS_Pr)) {
4743 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20); 4844 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20);
4744 if(HwInfo->jChipType == SIS_550) { 4845 if(SiS_Pr->ChipType == SIS_550) {
4745 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x40); 4846 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x40);
4746 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x10); 4847 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x10);
4747 } 4848 }
4748 } 4849 }
4749 } else if(SiS_IsVAMode(SiS_Pr,HwInfo)) { 4850 } else if(SiS_IsVAMode(SiS_Pr)) {
4750 if(HwInfo->jChipType != SIS_740) { 4851 if(SiS_Pr->ChipType != SIS_740) {
4751 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20); 4852 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1E,0x20);
4752 } 4853 }
4753 } 4854 }
4754 4855
4755 if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) { 4856 if(!(SiS_WeHaveBacklightCtrl(SiS_Pr))) {
4756 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f); 4857 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x00,0x7f);
4757 } 4858 }
4758 4859
4759 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { 4860 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
4760 if(SiS_IsTVOrYPbPrOrScart(SiS_Pr,HwInfo)) { 4861 if(SiS_IsTVOrYPbPrOrScart(SiS_Pr)) {
4761 SiS_Chrontel701xOn(SiS_Pr,HwInfo); 4862 SiS_Chrontel701xOn(SiS_Pr);
4762 } 4863 }
4763 if( (SiS_IsVAMode(SiS_Pr,HwInfo)) || 4864 if( (SiS_IsVAMode(SiS_Pr)) ||
4764 (SiS_IsLCDOrLCDA(SiS_Pr,HwInfo)) ) { 4865 (SiS_IsLCDOrLCDA(SiS_Pr)) ) {
4765 SiS_ChrontelDoSomething1(SiS_Pr,HwInfo); 4866 SiS_ChrontelDoSomething1(SiS_Pr);
4766 } 4867 }
4767 } 4868 }
4768 4869
4769 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { 4870 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
4770 if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) { 4871 if(!(SiS_WeHaveBacklightCtrl(SiS_Pr))) {
4771 if( (SiS_IsVAMode(SiS_Pr,HwInfo)) || 4872 if( (SiS_IsVAMode(SiS_Pr)) ||
4772 (SiS_IsLCDOrLCDA(SiS_Pr,HwInfo)) ) { 4873 (SiS_IsLCDOrLCDA(SiS_Pr)) ) {
4773 SiS_Chrontel701xBLOn(SiS_Pr, HwInfo); 4874 SiS_Chrontel701xBLOn(SiS_Pr);
4774 SiS_ChrontelInitTVVSync(SiS_Pr,HwInfo); 4875 SiS_ChrontelInitTVVSync(SiS_Pr);
4775 } 4876 }
4776 } 4877 }
4777 } else if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) { 4878 } else if(SiS_Pr->SiS_IF_DEF_CH70xx == 0) {
4778 if(!(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo))) { 4879 if(!(SiS_WeHaveBacklightCtrl(SiS_Pr))) {
4779 if(SiS_CRT2IsLCD(SiS_Pr, HwInfo)) { 4880 if(SiS_CRT2IsLCD(SiS_Pr)) {
4780 SiS_PanelDelay(SiS_Pr, HwInfo, 1); 4881 SiS_PanelDelay(SiS_Pr, 1);
4781 SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xF7,0x00); 4882 SiS_SetRegSR11ANDOR(SiS_Pr,0xF7,0x00);
4782 } 4883 }
4783 } 4884 }
4784 } 4885 }
@@ -4797,243 +4898,204 @@ SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
4797 4898
4798/* Set CRT2 OFFSET / PITCH */ 4899/* Set CRT2 OFFSET / PITCH */
4799static void 4900static void
4800SiS_SetCRT2Offset(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, 4901SiS_SetCRT2Offset(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex,
4801 USHORT RRTI, PSIS_HW_INFO HwInfo) 4902 unsigned short RRTI)
4802{ 4903{
4803 USHORT offset; 4904 unsigned short offset;
4804 UCHAR temp; 4905 unsigned char temp;
4805 4906
4806 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) return; 4907 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) return;
4807 4908
4808 offset = SiS_GetOffset(SiS_Pr,ModeNo,ModeIdIndex,RRTI,HwInfo); 4909 offset = SiS_GetOffset(SiS_Pr,ModeNo,ModeIdIndex,RRTI);
4809 4910
4810 if((SiS_Pr->SiS_LCDResInfo == Panel_640x480_2) || 4911 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x07,(offset & 0xFF));
4811 (SiS_Pr->SiS_LCDResInfo == Panel_640x480_3)) { 4912 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x09,(offset >> 8));
4812 offset >>= 1;
4813 }
4814 4913
4815 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x07,(offset & 0xFF)); 4914 temp = (unsigned char)(((offset >> 3) & 0xFF) + 1);
4816 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x09,(offset >> 8)); 4915 if(offset & 0x07) temp++;
4817 temp = (UCHAR)(((offset >> 3) & 0xFF) + 1); 4916 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x03,temp);
4818 if(offset % 8) temp++;
4819 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x03,temp);
4820} 4917}
4821 4918
4822/* Set CRT2 sync and PanelLink mode */ 4919/* Set CRT2 sync and PanelLink mode */
4823static void 4920static void
4824SiS_SetCRT2Sync(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT RefreshRateTableIndex, 4921SiS_SetCRT2Sync(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short RefreshRateTableIndex)
4825 PSIS_HW_INFO HwInfo)
4826{ 4922{
4827 USHORT tempah=0,tempbl,infoflag; 4923 unsigned short tempah=0, tempbl, infoflag;
4828 4924
4829 tempbl = 0xC0; 4925 tempbl = 0xC0;
4830 4926
4831 if(SiS_Pr->UseCustomMode) { 4927 if(SiS_Pr->UseCustomMode) {
4832 infoflag = SiS_Pr->CInfoFlag; 4928 infoflag = SiS_Pr->CInfoFlag;
4833 } else { 4929 } else {
4834 infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag; 4930 infoflag = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
4835 } 4931 }
4836 4932
4837 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { /* LVDS */ 4933 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { /* LVDS */
4838 4934
4839 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 4935 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
4840 tempah = 0; 4936 tempah = 0;
4841 } else if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (SiS_Pr->SiS_LCDInfo & LCDSync)) { 4937 } else if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (SiS_Pr->SiS_LCDInfo & LCDSync)) {
4842 tempah = SiS_Pr->SiS_LCDInfo; 4938 tempah = SiS_Pr->SiS_LCDInfo;
4843 } else tempah = infoflag >> 8; 4939 } else tempah = infoflag >> 8;
4844 tempah &= 0xC0; 4940 tempah &= 0xC0;
4845 tempah |= 0x20; 4941 tempah |= 0x20;
4846 if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; 4942 if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10;
4847 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 4943 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
4848 if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || 4944 if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) ||
4849 (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) { 4945 (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) {
4850 tempah |= 0xf0; 4946 tempah |= 0xf0;
4851 } 4947 }
4852 if( (SiS_Pr->SiS_IF_DEF_FSTN) || 4948 if( (SiS_Pr->SiS_IF_DEF_FSTN) ||
4853 (SiS_Pr->SiS_IF_DEF_DSTN) || 4949 (SiS_Pr->SiS_IF_DEF_DSTN) ||
4854 (SiS_Pr->SiS_IF_DEF_TRUMPION) || 4950 (SiS_Pr->SiS_IF_DEF_TRUMPION) ||
4855 (SiS_Pr->SiS_CustomT == CUT_PANEL848) ) { 4951 (SiS_Pr->SiS_CustomT == CUT_PANEL848) ||
4856 tempah |= 0x30; 4952 (SiS_Pr->SiS_CustomT == CUT_PANEL856) ) {
4857 } 4953 tempah |= 0x30;
4858 } 4954 }
4859 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 4955 if( (SiS_Pr->SiS_IF_DEF_FSTN) ||
4860 if(HwInfo->jChipType >= SIS_315H) { 4956 (SiS_Pr->SiS_IF_DEF_DSTN) ) {
4861 tempah >>= 3; 4957 tempah &= ~0xc0;
4862 tempah &= 0x18; 4958 }
4863 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xE7,tempah); 4959 }
4864 /* Don't care about 12/18/24 bit mode - TV is via VGA, not PL */ 4960 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
4865 } else { 4961 if(SiS_Pr->ChipType >= SIS_315H) {
4866 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,0xe0); 4962 tempah >>= 3;
4867 } 4963 tempah &= 0x18;
4868 } else { 4964 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xE7,tempah);
4869 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); 4965 /* Don't care about 12/18/24 bit mode - TV is via VGA, not PL */
4870 } 4966 } else {
4967 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,0xe0);
4968 }
4969 } else {
4970 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah);
4971 }
4871 4972
4872 } else if(SiS_Pr->SiS_VBType & VB_SISVB) { 4973 } else if(SiS_Pr->SiS_VBType & VB_SISVB) {
4873 4974
4874 if(HwInfo->jChipType < SIS_315H) { 4975 if(SiS_Pr->ChipType < SIS_315H) {
4875 4976
4876#ifdef SIS300 /* ---- 300 series --- */ 4977#ifdef SIS300 /* ---- 300 series --- */
4877 4978
4878 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { /* 630 - 301B(-DH) */ 4979 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) { /* 630 - 301B(-DH) */
4879 4980
4880 tempah = infoflag >> 8; 4981 tempah = infoflag >> 8;
4881 tempbl = 0; 4982 tempbl = 0;
4882 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 4983 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
4883 if(SiS_Pr->SiS_LCDInfo & LCDSync) { 4984 if(SiS_Pr->SiS_LCDInfo & LCDSync) {
4884 tempah = SiS_Pr->SiS_LCDInfo; 4985 tempah = SiS_Pr->SiS_LCDInfo;
4885 tempbl = (tempah >> 6) & 0x03; 4986 tempbl = (tempah >> 6) & 0x03;
4886 } 4987 }
4887 } 4988 }
4888 tempah &= 0xC0; 4989 tempah &= 0xC0;
4889 tempah |= 0x20; 4990 tempah |= 0x20;
4890 if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; 4991 if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10;
4891 tempah |= 0xc0; 4992 tempah |= 0xc0;
4892 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); 4993 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah);
4893 if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (!(SiS_Pr->SiS_VBType & VB_NoLCD))) { 4994 if((SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) && (!(SiS_Pr->SiS_VBType & VB_NoLCD))) {
4894 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xf0,tempbl); 4995 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xf0,tempbl);
4895 } 4996 }
4896 4997
4897 } else { /* 630 - 301 */ 4998 } else { /* 630 - 301 */
4898 4999
4899 tempah = infoflag >> 8; 5000 tempah = ((infoflag >> 8) & 0xc0) | 0x20;
4900 tempah &= 0xC0; 5001 if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10;
4901 tempah |= 0x20; 5002 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah);
4902 if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10;
4903 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah);
4904 5003
4905 } 5004 }
4906 5005
4907#endif /* SIS300 */ 5006#endif /* SIS300 */
4908 5007
4909 } else { 5008 } else {
4910 5009
4911#ifdef SIS315H /* ------- 315 series ------ */ 5010#ifdef SIS315H /* ------- 315 series ------ */
4912 5011
4913 if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { /* 315 - LVDS */ 5012 if(SiS_Pr->SiS_VBType & VB_SISLVDS) { /* 315 - LVDS */
4914 5013
4915 tempbl = 0; 5014 tempbl = 0;
4916 if((SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) && 5015 if((SiS_Pr->SiS_CustomT == CUT_COMPAQ1280) &&
4917 (SiS_Pr->SiS_LCDResInfo == Panel_1280x1024)) { 5016 (SiS_Pr->SiS_LCDResInfo == Panel_1280x1024)) {
4918 tempah = infoflag >> 8; 5017 tempah = infoflag >> 8;
4919 if(SiS_Pr->SiS_LCDInfo & LCDSync) { 5018 if(SiS_Pr->SiS_LCDInfo & LCDSync) {
4920 tempbl = ((SiS_Pr->SiS_LCDInfo & 0xc0) >> 6); 5019 tempbl = ((SiS_Pr->SiS_LCDInfo & 0xc0) >> 6);
4921 } 5020 }
4922 } else if((SiS_Pr->SiS_CustomT == CUT_CLEVO1400) && 5021 } else if((SiS_Pr->SiS_CustomT == CUT_CLEVO1400) &&
4923 (SiS_Pr->SiS_LCDResInfo == Panel_1400x1050)) { 5022 (SiS_Pr->SiS_LCDResInfo == Panel_1400x1050)) {
4924 tempah = infoflag >> 8; 5023 tempah = infoflag >> 8;
4925 tempbl = 0x03; 5024 tempbl = 0x03;
4926 } else { 5025 } else {
4927 tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x37); 5026 tempah = SiS_GetReg(SiS_Pr->SiS_P3d4,0x37);
4928 tempbl = (tempah >> 6) & 0x03; 5027 tempbl = (tempah >> 6) & 0x03;
4929 tempbl |= 0x08; 5028 tempbl |= 0x08;
4930 if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempbl |= 0x04; 5029 if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempbl |= 0x04;
4931 } 5030 }
4932 tempah &= 0xC0; 5031 tempah &= 0xC0;
4933 tempah |= 0x20; 5032 tempah |= 0x20;
4934 if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; 5033 if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10;
4935 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) tempah |= 0xc0; 5034 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) tempah |= 0xc0;
4936 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); 5035 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah);
4937 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { 5036 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) {
4938 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 5037 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
4939 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xf0,tempbl); 5038 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xf0,tempbl);
4940 } 5039 }
4941 } 5040 }
4942 5041
4943 } else { /* 315 - TMDS */ 5042 } else { /* 315 - TMDS */
4944 5043
4945 tempah = tempbl = infoflag >> 8; 5044 tempah = tempbl = infoflag >> 8;
4946 if(!SiS_Pr->UseCustomMode) { 5045 if(!SiS_Pr->UseCustomMode) {
4947 tempbl = 0; 5046 tempbl = 0;
4948 if((SiS_Pr->SiS_VBType & VB_SIS301C) && (SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { 5047 if((SiS_Pr->SiS_VBType & VB_SIS30xC) && (SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) {
4949 if(ModeNo <= 0x13) { 5048 if(ModeNo <= 0x13) {
4950 tempah = SiS_GetRegByte((SiS_Pr->SiS_P3ca+0x02)); 5049 tempah = SiS_GetRegByte((SiS_Pr->SiS_P3ca+0x02));
4951 } 5050 }
4952 } 5051 }
4953 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { 5052 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
4954 if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { 5053 if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) {
4955 if(SiS_Pr->SiS_LCDInfo & LCDSync) { 5054 if(SiS_Pr->SiS_LCDInfo & LCDSync) {
4956 tempah = SiS_Pr->SiS_LCDInfo; 5055 tempah = SiS_Pr->SiS_LCDInfo;
4957 tempbl = (tempah >> 6) & 0x03; 5056 tempbl = (tempah >> 6) & 0x03;
4958 } 5057 }
4959 } 5058 }
4960 } 5059 }
4961 } 5060 }
4962 tempah &= 0xC0; 5061 tempah &= 0xC0;
4963 tempah |= 0x20; 5062 tempah |= 0x20;
4964 if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10; 5063 if(!(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit)) tempah |= 0x10;
4965 if(SiS_Pr->SiS_VBType & VB_NoLCD) { 5064 if(SiS_Pr->SiS_VBType & VB_NoLCD) {
4966 /* Imitate BIOS bug */ 5065 /* Imitate BIOS bug */
4967 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) tempah |= 0xc0; 5066 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) tempah |= 0xc0;
4968 } 5067 }
4969 if((SiS_Pr->SiS_VBType & VB_SIS301C) && (SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) { 5068 if((SiS_Pr->SiS_VBType & VB_SIS30xC) && (SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC)) {
4970 tempah >>= 3; 5069 tempah >>= 3;
4971 tempah &= 0x18; 5070 tempah &= 0x18;
4972 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xe7,tempah); 5071 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,0xe7,tempah);
4973 } else { 5072 } else {
4974 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah); 5073 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x19,0x0F,tempah);
4975 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { 5074 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) {
4976 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 5075 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
4977 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xf0,tempbl); 5076 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1a,0xf0,tempbl);
4978 } 5077 }
4979 } 5078 }
4980 } 5079 }
4981 5080
4982 } 5081 }
4983#endif /* SIS315H */ 5082#endif /* SIS315H */
4984 } 5083 }
4985 } 5084 }
4986} 5085}
4987 5086
4988/* Set CRT2 FIFO on 300/630/730 */ 5087/* Set CRT2 FIFO on 300/540/630/730 */
4989#ifdef SIS300 5088#ifdef SIS300
4990static void 5089static void
4991SiS_SetCRT2FIFO_300(SiS_Private *SiS_Pr,USHORT ModeNo, 5090SiS_SetCRT2FIFO_300(struct SiS_Private *SiS_Pr,unsigned short ModeNo)
4992 PSIS_HW_INFO HwInfo) 5091{
4993{ 5092 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
4994 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; 5093 unsigned short temp, index, modeidindex, refreshratetableindex;
4995 USHORT temp,index; 5094 unsigned short VCLK = 0, MCLK, colorth = 0, data2 = 0;
4996 USHORT modeidindex,refreshratetableindex; 5095 unsigned short tempbx, tempcl, CRT1ModeNo, CRT2ModeNo, SelectRate_backup;
4997 USHORT VCLK=0,MCLK,colorth=0,data2=0; 5096 unsigned int data, pci50, pciA0;
4998 USHORT tempal, tempah, tempbx, tempcl, tempax; 5097 static const unsigned char colortharray[] = {
4999 USHORT CRT1ModeNo,CRT2ModeNo; 5098 1, 1, 2, 2, 3, 4
5000 USHORT SelectRate_backup;
5001 ULONG data,eax;
5002 const UCHAR LatencyFactor[] = {
5003 97, 88, 86, 79, 77, 00, /*; 64 bit BQ=2 */
5004 00, 87, 85, 78, 76, 54, /*; 64 bit BQ=1 */
5005 97, 88, 86, 79, 77, 00, /*; 128 bit BQ=2 */
5006 00, 79, 77, 70, 68, 48, /*; 128 bit BQ=1 */
5007 80, 72, 69, 63, 61, 00, /*; 64 bit BQ=2 */
5008 00, 70, 68, 61, 59, 37, /*; 64 bit BQ=1 */
5009 86, 77, 75, 68, 66, 00, /*; 128 bit BQ=2 */
5010 00, 68, 66, 59, 57, 37 /*; 128 bit BQ=1 */
5011 };
5012 const UCHAR LatencyFactor730[] = {
5013 69, 63, 61,
5014 86, 79, 77,
5015 103, 96, 94,
5016 120,113,111,
5017 137,130,128, /* <-- last entry, data below */
5018 137,130,128, /* to avoid using illegal values */
5019 137,130,128,
5020 137,130,128,
5021 137,130,128,
5022 137,130,128,
5023 137,130,128,
5024 137,130,128,
5025 137,130,128,
5026 137,130,128,
5027 137,130,128,
5028 137,130,128,
5029 };
5030 const UCHAR ThLowB[] = {
5031 81, 4, 72, 6, 88, 8,120,12,
5032 55, 4, 54, 6, 66, 8, 90,12,
5033 42, 4, 45, 6, 55, 8, 75,12
5034 };
5035 const UCHAR ThTiming[] = {
5036 1, 2, 2, 3, 0, 1, 1, 2
5037 }; 5099 };
5038 5100
5039 SelectRate_backup = SiS_Pr->SiS_SelectCRT2Rate; 5101 SelectRate_backup = SiS_Pr->SiS_SelectCRT2Rate;
@@ -5044,232 +5106,159 @@ SiS_SetCRT2FIFO_300(SiS_Private *SiS_Pr,USHORT ModeNo,
5044 SiS_SearchModeID(SiS_Pr, &CRT1ModeNo, &modeidindex); 5106 SiS_SearchModeID(SiS_Pr, &CRT1ModeNo, &modeidindex);
5045 SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2); 5107 SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2);
5046 SiS_Pr->SiS_SelectCRT2Rate = 0; 5108 SiS_Pr->SiS_SelectCRT2Rate = 0;
5047 refreshratetableindex = SiS_GetRatePtr(SiS_Pr, CRT1ModeNo, modeidindex, HwInfo); 5109 refreshratetableindex = SiS_GetRatePtr(SiS_Pr, CRT1ModeNo, modeidindex);
5048 5110
5049 if(CRT1ModeNo >= 0x13) { 5111 if(CRT1ModeNo >= 0x13) {
5050 index = SiS_Pr->SiS_RefIndex[refreshratetableindex].Ext_CRTVCLK; 5112 /* Get VCLK */
5051 index &= 0x3F; 5113 index = SiS_GetRefCRTVCLK(SiS_Pr, refreshratetableindex, SiS_Pr->SiS_UseWide);
5052 VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; /* Get VCLK */ 5114 VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK;
5053 5115
5054 colorth = SiS_GetColorDepth(SiS_Pr,CRT1ModeNo,modeidindex); /* Get colordepth */ 5116 /* Get colordepth */
5055 colorth >>= 1; 5117 colorth = SiS_GetColorDepth(SiS_Pr,CRT1ModeNo,modeidindex) >> 1;
5056 if(!colorth) colorth++; 5118 if(!colorth) colorth++;
5057 } 5119 }
5058 5120
5059 } else { 5121 } else {
5060 5122
5061 CRT1ModeNo = 0xfe; 5123 CRT1ModeNo = 0xfe;
5062 VCLK = SiS_Pr->CSRClock_CRT1; /* Get VCLK */ 5124
5063 data2 = (SiS_Pr->CModeFlag_CRT1 & ModeTypeMask) - 2; 5125 /* Get VCLK */
5064 switch(data2) { /* Get color depth */ 5126 VCLK = SiS_Pr->CSRClock_CRT1;
5065 case 0 : colorth = 1; break; 5127
5066 case 1 : colorth = 1; break; 5128 /* Get color depth */
5067 case 2 : colorth = 2; break; 5129 colorth = colortharray[((SiS_Pr->CModeFlag_CRT1 & ModeTypeMask) - 2)];
5068 case 3 : colorth = 2; break;
5069 case 4 : colorth = 3; break;
5070 case 5 : colorth = 4; break;
5071 default: colorth = 2;
5072 }
5073 5130
5074 } 5131 }
5075 5132
5076 if(CRT1ModeNo >= 0x13) { 5133 if(CRT1ModeNo >= 0x13) {
5077 if(HwInfo->jChipType == SIS_300) { 5134 /* Get MCLK */
5078 index = SiS_GetReg(SiS_Pr->SiS_P3c4,0x3A); 5135 if(SiS_Pr->ChipType == SIS_300) {
5079 } else { 5136 index = SiS_GetReg(SiS_Pr->SiS_P3c4,0x3A);
5080 index = SiS_GetReg(SiS_Pr->SiS_P3c4,0x1A); 5137 } else {
5081 } 5138 index = SiS_GetReg(SiS_Pr->SiS_P3c4,0x1A);
5082 index &= 0x07; 5139 }
5083 MCLK = SiS_Pr->SiS_MCLKData_0[index].CLOCK; /* Get MCLK */ 5140 index &= 0x07;
5141 MCLK = SiS_Pr->SiS_MCLKData_0[index].CLOCK;
5084 5142
5085 data2 = (colorth * VCLK) / MCLK; 5143 temp = ((SiS_GetReg(SiS_Pr->SiS_P3c4,0x14) >> 6) & 0x03) << 1;
5144 if(!temp) temp++;
5145 temp <<= 2;
5086 5146
5087 temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14); 5147 data2 = temp - ((colorth * VCLK) / MCLK);
5088 temp = ((temp & 0x00FF) >> 6) << 1;
5089 if(temp == 0) temp = 1;
5090 temp <<= 2;
5091 temp &= 0xff;
5092 5148
5093 data2 = temp - data2; 5149 temp = (28 * 16) % data2;
5150 data2 = (28 * 16) / data2;
5151 if(temp) data2++;
5094 5152
5095 if((28 * 16) % data2) { 5153 if(SiS_Pr->ChipType == SIS_300) {
5096 data2 = (28 * 16) / data2;
5097 data2++;
5098 } else {
5099 data2 = (28 * 16) / data2;
5100 }
5101 5154
5102 if(HwInfo->jChipType == SIS_300) { 5155 SiS_GetFIFOThresholdIndex300(SiS_Pr, &tempbx, &tempcl);
5103 5156 data = SiS_GetFIFOThresholdB300(tempbx, tempcl);
5104 tempah = SiS_GetReg(SiS_Pr->SiS_P3c4,0x18); 5157
5105 tempah &= 0x62; 5158 } else {
5106 tempah >>= 1; 5159
5107 tempal = tempah; 5160#ifdef SIS_LINUX_KERNEL
5108 tempah >>= 3; 5161 pci50 = sisfb_read_nbridge_pci_dword(SiS_Pr, 0x50);
5109 tempal |= tempah; 5162 pciA0 = sisfb_read_nbridge_pci_dword(SiS_Pr, 0xa0);
5110 tempal &= 0x07;
5111 tempcl = ThTiming[tempal];
5112 tempbx = SiS_GetReg(SiS_Pr->SiS_P3c4,0x16);
5113 tempbx >>= 6;
5114 tempah = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14);
5115 tempah >>= 4;
5116 tempah &= 0x0c;
5117 tempbx |= tempah;
5118 tempbx <<= 1;
5119 tempal = ThLowB[tempbx + 1];
5120 tempal *= tempcl;
5121 tempal += ThLowB[tempbx];
5122 data = tempal;
5123
5124 } else if(HwInfo->jChipType == SIS_730) {
5125
5126#ifdef LINUX_KERNEL
5127 SiS_SetRegLong(0xcf8,0x80000050);
5128 eax = SiS_GetRegLong(0xcfc);
5129#else 5163#else
5130 eax = pciReadLong(0x00000000, 0x50); 5164 pci50 = pciReadLong(0x00000000, 0x50);
5165 pciA0 = pciReadLong(0x00000000, 0xA0);
5131#endif 5166#endif
5132 tempal = (USHORT)(eax >> 8);
5133 tempal &= 0x06;
5134 tempal <<= 5;
5135 5167
5136#ifdef LINUX_KERNEL 5168 if(SiS_Pr->ChipType == SIS_730) {
5137 SiS_SetRegLong(0xcf8,0x800000A0);
5138 eax = SiS_GetRegLong(0xcfc);
5139#else
5140 eax = pciReadLong(0x00000000, 0xA0);
5141#endif
5142 temp = (USHORT)(eax >> 28);
5143 temp &= 0x0F;
5144 tempal |= temp;
5145
5146 tempbx = tempal; /* BIOS BUG (2.04.5d, 2.04.6a use ah here, which is unset!) */
5147 tempbx = 0; /* -- do it like the BIOS anyway... */
5148 tempax = tempbx;
5149 tempbx &= 0xc0;
5150 tempbx >>= 6;
5151 tempax &= 0x0f;
5152 tempax *= 3;
5153 tempbx += tempax;
5154
5155 data = LatencyFactor730[tempbx];
5156 data += 15;
5157 temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14);
5158 if(!(temp & 0x80)) data += 5;
5159 5169
5160 } else { 5170 index = (unsigned short)(((pciA0 >> 28) & 0x0f) * 3);
5171 index += (unsigned short)(((pci50 >> 9)) & 0x03);
5161 5172
5162 index = 0; 5173 /* BIOS BUG (2.04.5d, 2.04.6a use ah here, which is unset!) */
5163 temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14); 5174 index = 0; /* -- do it like the BIOS anyway... */
5164 if(temp & 0x0080) index += 12;
5165 5175
5166#ifdef LINUX_KERNEL 5176 } else {
5167 SiS_SetRegLong(0xcf8,0x800000A0);
5168 eax = SiS_GetRegLong(0xcfc);
5169#else
5170 /* We use pci functions X offers. We use tag 0, because
5171 * we want to read/write to the host bridge (which is always
5172 * 00:00.0 on 630, 730 and 540), not the VGA device.
5173 */
5174 eax = pciReadLong(0x00000000, 0xA0);
5175#endif
5176 temp = (USHORT)(eax >> 24);
5177 if(!(temp&0x01)) index += 24;
5178
5179#ifdef LINUX_KERNEL
5180 SiS_SetRegLong(0xcf8,0x80000050);
5181 eax = SiS_GetRegLong(0xcfc);
5182#else
5183 eax = pciReadLong(0x00000000, 0x50);
5184#endif
5185 temp=(USHORT)(eax >> 24);
5186 if(temp & 0x01) index += 6;
5187 5177
5188 temp = (temp & 0x0F) >> 1; 5178 pci50 >>= 24;
5189 index += temp; 5179 pciA0 >>= 24;
5190 5180
5191 data = LatencyFactor[index]; 5181 index = (pci50 >> 1) & 0x07;
5192 data += 15;
5193 temp = SiS_GetReg(SiS_Pr->SiS_P3c4,0x14);
5194 if(!(temp & 0x80)) data += 5;
5195 }
5196 5182
5197 data += data2; /* CRT1 Request Period */ 5183 if(pci50 & 0x01) index += 6;
5184 if(!(pciA0 & 0x01)) index += 24;
5198 5185
5199 SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; 5186 if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x14) & 0x80) index += 12;
5200 SiS_Pr->SiS_SelectCRT2Rate = SelectRate_backup;
5201 5187
5202 if(!SiS_Pr->UseCustomMode) { 5188 }
5203 5189
5204 CRT2ModeNo = ModeNo; 5190 data = SiS_GetLatencyFactor630(SiS_Pr, index) + 15;
5205 SiS_SearchModeID(SiS_Pr, &CRT2ModeNo, &modeidindex); 5191 if(!(SiS_GetReg(SiS_Pr->SiS_P3c4,0x14) & 0x80)) data += 5;
5206 5192
5207 refreshratetableindex = SiS_GetRatePtr(SiS_Pr, CRT2ModeNo, modeidindex, HwInfo); 5193 }
5208 5194
5209 index = SiS_GetVCLK2Ptr(SiS_Pr,CRT2ModeNo,modeidindex, 5195 data += data2; /* CRT1 Request Period */
5210 refreshratetableindex,HwInfo);
5211 VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; /* Get VCLK */
5212 5196
5213 if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) { 5197 SiS_Pr->SiS_SetFlag |= ProgrammingCRT2;
5214 if(SiS_Pr->SiS_UseROM) { 5198 SiS_Pr->SiS_SelectCRT2Rate = SelectRate_backup;
5215 if(ROMAddr[0x220] & 0x01) {
5216 VCLK = ROMAddr[0x229] | (ROMAddr[0x22a] << 8);
5217 }
5218 }
5219 }
5220 5199
5221 } else { 5200 if(!SiS_Pr->UseCustomMode) {
5222 5201
5223 CRT2ModeNo = 0xfe; 5202 CRT2ModeNo = ModeNo;
5224 VCLK = SiS_Pr->CSRClock; /* Get VCLK */ 5203 SiS_SearchModeID(SiS_Pr, &CRT2ModeNo, &modeidindex);
5225 5204
5226 } 5205 refreshratetableindex = SiS_GetRatePtr(SiS_Pr, CRT2ModeNo, modeidindex);
5227 5206
5228 colorth = SiS_GetColorDepth(SiS_Pr,CRT2ModeNo,modeidindex); /* Get colordepth */ 5207 /* Get VCLK */
5229 colorth >>= 1; 5208 index = SiS_GetVCLK2Ptr(SiS_Pr, CRT2ModeNo, modeidindex, refreshratetableindex);
5230 if(!colorth) colorth++; 5209 VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK;
5231 5210
5232 data = data * VCLK * colorth; 5211 if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) {
5233 if(data % (MCLK << 4)) { 5212 if(SiS_Pr->SiS_UseROM) {
5234 data = data / (MCLK << 4); 5213 if(ROMAddr[0x220] & 0x01) {
5235 data++; 5214 VCLK = ROMAddr[0x229] | (ROMAddr[0x22a] << 8);
5236 } else { 5215 }
5237 data = data / (MCLK << 4); 5216 }
5238 } 5217 }
5239 5218
5240 if(data <= 6) data = 6; 5219 } else {
5241 if(data > 0x14) data = 0x14;
5242 5220
5243 temp = SiS_GetReg(SiS_Pr->SiS_Part1Port,0x01); 5221 /* Get VCLK */
5244 if(HwInfo->jChipType == SIS_300) { 5222 CRT2ModeNo = 0xfe;
5245 if(data <= 0x0f) temp = (temp & (~0x1F)) | 0x13; 5223 VCLK = SiS_Pr->CSRClock;
5246 else temp = (temp & (~0x1F)) | 0x16;
5247 if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) {
5248 temp = (temp & (~0x1F)) | 0x13;
5249 }
5250 } else {
5251 if( ( (HwInfo->jChipType == SIS_630) ||
5252 (HwInfo->jChipType == SIS_730) ) &&
5253 (HwInfo->jChipRevision >= 0x30) ) /* 630s or 730(s?) */
5254 {
5255 temp = (temp & (~0x1F)) | 0x1b;
5256 } else {
5257 temp = (temp & (~0x1F)) | 0x16;
5258 }
5259 }
5260 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0xe0,temp);
5261 5224
5262 if( (HwInfo->jChipType == SIS_630) && 5225 }
5263 (HwInfo->jChipRevision >= 0x30) ) /* 630s, NOT 730 */ 5226
5264 { 5227 /* Get colordepth */
5265 if(data > 0x13) data = 0x13; 5228 colorth = SiS_GetColorDepth(SiS_Pr,CRT2ModeNo,modeidindex) >> 1;
5266 } 5229 if(!colorth) colorth++;
5267 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x02,0xe0,data); 5230
5231 data = data * VCLK * colorth;
5232 temp = data % (MCLK << 4);
5233 data = data / (MCLK << 4);
5234 if(temp) data++;
5235
5236 if(data < 6) data = 6;
5237 else if(data > 0x14) data = 0x14;
5238
5239 if(SiS_Pr->ChipType == SIS_300) {
5240 temp = 0x16;
5241 if((data <= 0x0f) || (SiS_Pr->SiS_LCDResInfo == Panel_1280x1024))
5242 temp = 0x13;
5243 } else {
5244 temp = 0x16;
5245 if(( (SiS_Pr->ChipType == SIS_630) ||
5246 (SiS_Pr->ChipType == SIS_730) ) &&
5247 (SiS_Pr->ChipRevision >= 0x30))
5248 temp = 0x1b;
5249 }
5250 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x01,0xe0,temp);
5251
5252 if((SiS_Pr->ChipType == SIS_630) &&
5253 (SiS_Pr->ChipRevision >= 0x30)) {
5254 if(data > 0x13) data = 0x13;
5255 }
5256 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x02,0xe0,data);
5268 5257
5269 } else { /* If mode <= 0x13, we just restore everything */ 5258 } else { /* If mode <= 0x13, we just restore everything */
5270 5259
5271 SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; 5260 SiS_Pr->SiS_SetFlag |= ProgrammingCRT2;
5272 SiS_Pr->SiS_SelectCRT2Rate = SelectRate_backup; 5261 SiS_Pr->SiS_SelectCRT2Rate = SelectRate_backup;
5273 5262
5274 } 5263 }
5275} 5264}
@@ -5278,10 +5267,10 @@ SiS_SetCRT2FIFO_300(SiS_Private *SiS_Pr,USHORT ModeNo,
5278/* Set CRT2 FIFO on 315/330 series */ 5267/* Set CRT2 FIFO on 315/330 series */
5279#ifdef SIS315H 5268#ifdef SIS315H
5280static void 5269static void
5281SiS_SetCRT2FIFO_310(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 5270SiS_SetCRT2FIFO_310(struct SiS_Private *SiS_Pr)
5282{ 5271{
5283 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x01,0x3B); 5272 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x01,0x3B);
5284 if( (HwInfo->jChipType == SIS_760) && 5273 if( (SiS_Pr->ChipType == SIS_760) &&
5285 (SiS_Pr->SiS_SysFlags & SF_760LFB) && 5274 (SiS_Pr->SiS_SysFlags & SF_760LFB) &&
5286 (SiS_Pr->SiS_ModeType == Mode32Bpp) && 5275 (SiS_Pr->SiS_ModeType == Mode32Bpp) &&
5287 (SiS_Pr->SiS_VGAHDE >= 1280) && 5276 (SiS_Pr->SiS_VGAHDE >= 1280) &&
@@ -5299,337 +5288,162 @@ SiS_SetCRT2FIFO_310(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
5299} 5288}
5300#endif 5289#endif
5301 5290
5302static USHORT 5291static unsigned short
5303SiS_GetVGAHT2(SiS_Private *SiS_Pr) 5292SiS_GetVGAHT2(struct SiS_Private *SiS_Pr)
5304{ 5293{
5305 ULONG tempax,tempbx; 5294 unsigned int tempax,tempbx;
5306 5295
5307 tempbx = (SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE) * SiS_Pr->SiS_RVBHCMAX; 5296 tempbx = (SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE) * SiS_Pr->SiS_RVBHCMAX;
5308 tempax = (SiS_Pr->SiS_VT - SiS_Pr->SiS_VDE) * SiS_Pr->SiS_RVBHCFACT; 5297 tempax = (SiS_Pr->SiS_VT - SiS_Pr->SiS_VDE) * SiS_Pr->SiS_RVBHCFACT;
5309 tempax = (tempax * SiS_Pr->SiS_HT) / tempbx; 5298 tempax = (tempax * SiS_Pr->SiS_HT) / tempbx;
5310 return((USHORT)tempax); 5299 return (unsigned short)tempax;
5311} 5300}
5312 5301
5313/* Set Part 1 / SiS bridge slave mode */ 5302/* Set Part 1 / SiS bridge slave mode */
5314static void 5303static void
5315SiS_SetGroup1_301(SiS_Private *SiS_Pr, USHORT ModeNo,USHORT ModeIdIndex, 5304SiS_SetGroup1_301(struct SiS_Private *SiS_Pr, unsigned short ModeNo,unsigned short ModeIdIndex,
5316 PSIS_HW_INFO HwInfo,USHORT RefreshRateTableIndex) 5305 unsigned short RefreshRateTableIndex)
5317{ 5306{
5318 USHORT push1,push2; 5307 unsigned short temp, modeflag, i, j, xres=0, VGAVDE;
5319 USHORT tempax,tempbx,tempcx,temp; 5308 static const unsigned short CRTranslation[] = {
5320 USHORT resinfo,modeflag,xres=0; 5309 /* CR0 CR1 CR2 CR3 CR4 CR5 CR6 CR7 */
5321 unsigned char p1_7, p1_8; 5310 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a,
5311 /* CR8 CR9 SR0A SR0B SR0C SR0D SR0E CR0F */
5312 0x00, 0x0b, 0x17, 0x18, 0x19, 0x00, 0x1a, 0x00,
5313 /* CR10 CR11 CR12 CR13 CR14 CR15 CR16 CR17 */
5314 0x0c, 0x0d, 0x0e, 0x00, 0x0f, 0x10, 0x11, 0x00
5315 };
5322 5316
5323 if(ModeNo <= 0x13) { 5317 if(ModeNo <= 0x13) {
5324 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; 5318 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
5325 resinfo = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ResInfo;
5326 } else if(SiS_Pr->UseCustomMode) { 5319 } else if(SiS_Pr->UseCustomMode) {
5327 modeflag = SiS_Pr->CModeFlag; 5320 modeflag = SiS_Pr->CModeFlag;
5328 resinfo = 0;
5329 xres = SiS_Pr->CHDisplay; 5321 xres = SiS_Pr->CHDisplay;
5330 } else { 5322 } else {
5331 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; 5323 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
5332 resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
5333 xres = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].XRes; 5324 xres = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].XRes;
5334 } 5325 }
5335 5326
5336 /* The following is only done if bridge is in slave mode: */ 5327 /* The following is only done if bridge is in slave mode: */
5337 5328
5338 if((HwInfo->jChipType >= SIS_661) && (ModeNo > 0x13)) { 5329 if(SiS_Pr->ChipType >= SIS_315H) {
5339 if(xres >= 1600) { 5330 if(xres >= 1600) { /* BIOS: == 1600 */
5340 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x31,0x04); 5331 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x31,0x04);
5341 } 5332 }
5342 } 5333 }
5343 5334
5344 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x03,0xff); /* set MAX HT */ 5335 SiS_Pr->CHTotal = 8224; /* Max HT, 0x2020, results in 0x3ff in registers */
5345
5346 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) modeflag |= Charx8Dot;
5347 5336
5348 if(modeflag & Charx8Dot) tempcx = 0x08; 5337 SiS_Pr->CHDisplay = SiS_Pr->SiS_VGAHDE;
5349 else tempcx = 0x09; 5338 if(modeflag & HalfDCLK) SiS_Pr->CHDisplay >>= 1;
5350
5351 tempax = SiS_Pr->SiS_VGAHDE; /* 0x04 Horizontal Display End */
5352 if(modeflag & HalfDCLK) tempax >>= 1;
5353 tempax = ((tempax / tempcx) - 1) & 0xff;
5354 tempbx = tempax;
5355
5356 temp = tempax;
5357 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x04,temp);
5358 5339
5340 SiS_Pr->CHBlankStart = SiS_Pr->CHDisplay;
5359 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 5341 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
5360 if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) { 5342 SiS_Pr->CHBlankStart += 16;
5361 temp += 2;
5362 }
5363 }
5364 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {
5365 if(resinfo == SIS_RI_800x600) temp -= 2;
5366 }
5367 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x05,temp); /* 0x05 Horizontal Display Start */
5368
5369 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x06,0x03); /* 0x06 Horizontal Blank end */
5370
5371 tempax = 0xFFFF;
5372 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) tempax = SiS_GetVGAHT2(SiS_Pr);
5373 if(tempax >= SiS_Pr->SiS_VGAHT) tempax = SiS_Pr->SiS_VGAHT;
5374 if(modeflag & HalfDCLK) tempax >>= 1;
5375 tempax = (tempax / tempcx) - 5;
5376 tempcx = tempax;
5377
5378 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {
5379 temp = tempcx - 1;
5380 if(!(modeflag & HalfDCLK)) {
5381 temp -= 6;
5382 if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) {
5383 temp -= 2;
5384 if(ModeNo > 0x13) temp -= 10;
5385 }
5386 }
5387 } else {
5388 tempcx = (tempcx + tempbx) >> 1;
5389 temp = (tempcx & 0x00FF) + 2;
5390 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
5391 temp--;
5392 if(!(modeflag & HalfDCLK)) {
5393 if((modeflag & Charx8Dot)) {
5394 temp += 4;
5395 if(SiS_Pr->SiS_VGAHDE >= 800) temp -= 6;
5396 if(HwInfo->jChipType >= SIS_315H) {
5397 if(SiS_Pr->SiS_VGAHDE == 800) temp += 2;
5398 }
5399 }
5400 }
5401 } else {
5402 if(!(modeflag & HalfDCLK)) {
5403 temp -= 4;
5404 if((SiS_Pr->SiS_LCDResInfo != Panel_1280x960) &&
5405 (SiS_Pr->SiS_LCDResInfo != Panel_1600x1200)) {
5406 if(SiS_Pr->SiS_VGAHDE >= 800) {
5407 temp -= 7;
5408 if(HwInfo->jChipType < SIS_315H) {
5409 if(SiS_Pr->SiS_ModeType == ModeEGA) {
5410 if(SiS_Pr->SiS_VGAVDE == 1024) {
5411 temp += 15;
5412 if(SiS_Pr->SiS_LCDResInfo != Panel_1280x1024)
5413 temp += 7;
5414 }
5415 }
5416 }
5417 if(SiS_Pr->SiS_LCDResInfo != Panel_1400x1050) {
5418 if(SiS_Pr->SiS_VGAHDE >= 1280) {
5419 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) temp += 28;
5420 }
5421 }
5422 }
5423 }
5424 }
5425 }
5426 } 5343 }
5427 5344
5428 p1_7 = temp; 5345 SiS_Pr->CHBlankEnd = 32;
5429 p1_8 = 0x00; 5346 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
5430 5347 if(xres == 1600) SiS_Pr->CHBlankEnd += 80;
5431 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
5432 if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) {
5433 if(ModeNo <= 0x01) {
5434 p1_7 = 0x2a;
5435 if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) p1_8 = 0x61;
5436 else p1_8 = 0x41;
5437 } else if(SiS_Pr->SiS_ModeType == ModeText) {
5438 if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) p1_7 = 0x54;
5439 else p1_7 = 0x55;
5440 p1_8 = 0x00;
5441 } else if(ModeNo <= 0x13) {
5442 if(modeflag & HalfDCLK) {
5443 if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) {
5444 p1_7 = 0x30;
5445 p1_8 = 0x03;
5446 } else {
5447 p1_7 = 0x2f;
5448 p1_8 = 0x02;
5449 }
5450 } else {
5451 p1_7 = 0x5b;
5452 p1_8 = 0x03;
5453 }
5454 } else if( ((HwInfo->jChipType >= SIS_315H) &&
5455 ((ModeNo == 0x50) || (ModeNo == 0x56) || (ModeNo == 0x53))) ||
5456 ((HwInfo->jChipType < SIS_315H) &&
5457 (resinfo == SIS_RI_320x200 || resinfo == SIS_RI_320x240)) ) {
5458 if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) {
5459 p1_7 = 0x30,
5460 p1_8 = 0x03;
5461 } else {
5462 p1_7 = 0x2f;
5463 p1_8 = 0x03;
5464 }
5465 }
5466 }
5467 } 5348 }
5468 5349
5469 if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { 5350 temp = SiS_Pr->SiS_VGAHT - 96;
5470 if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p|TVSetYPbPr750p)) { 5351 if(!(modeflag & HalfDCLK)) temp -= 32;
5471 p1_7 = 0x63; 5352 if(SiS_Pr->SiS_LCDInfo & LCDPass11) {
5472 if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) p1_7 = 0x55; 5353 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x04);
5473 } 5354 temp |= ((SiS_GetReg(SiS_Pr->SiS_P3c4,0x0b) & 0xc0) << 2);
5474 if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { 5355 temp -= 3;
5475 if(!(modeflag & HalfDCLK)) { 5356 temp <<= 3;
5476 p1_7 = 0xb2; 5357 } else {
5477 if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) { 5358 if(SiS_Pr->SiS_RVBHRS2) temp = SiS_Pr->SiS_RVBHRS2;
5478 p1_7 = 0xab;
5479 }
5480 }
5481 } else {
5482 if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) {
5483 if(modeflag & HalfDCLK) p1_7 = 0x30;
5484 }
5485 }
5486 } 5359 }
5360 SiS_Pr->CHSyncStart = temp;
5487 5361
5488 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x07,p1_7); /* 0x07 Horizontal Retrace Start */ 5362 SiS_Pr->CHSyncEnd = 0xffe8; /* results in 0x2000 in registers */
5489 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x08,p1_8); /* 0x08 Horizontal Retrace End */
5490 5363
5491 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,0x03); /* 0x18 SR08 (FIFO Threshold?) */ 5364 SiS_Pr->CVTotal = 2049; /* Max VT, 0x0801, results in 0x7ff in registers */
5492 5365
5493 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x19,0xF0); 5366 VGAVDE = SiS_Pr->SiS_VGAVDE;
5367 if (VGAVDE == 357) VGAVDE = 350;
5368 else if(VGAVDE == 360) VGAVDE = 350;
5369 else if(VGAVDE == 375) VGAVDE = 350;
5370 else if(VGAVDE == 405) VGAVDE = 400;
5371 else if(VGAVDE == 420) VGAVDE = 400;
5372 else if(VGAVDE == 525) VGAVDE = 480;
5373 else if(VGAVDE == 1056) VGAVDE = 1024;
5374 SiS_Pr->CVDisplay = VGAVDE;
5494 5375
5495 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x09,0xFF); /* 0x09 Set Max VT */ 5376 SiS_Pr->CVBlankStart = SiS_Pr->CVDisplay;
5496 5377
5497 tempcx = 0x121; 5378 SiS_Pr->CVBlankEnd = 1;
5498 tempbx = SiS_Pr->SiS_VGAVDE; /* 0x0E Vertical Display End */ 5379 if(ModeNo == 0x3c) SiS_Pr->CVBlankEnd = 226;
5499 if (tempbx == 357) tempbx = 350;
5500 else if(tempbx == 360) tempbx = 350;
5501 else if(tempbx == 375) tempbx = 350;
5502 else if(tempbx == 405) tempbx = 400;
5503 else if(tempbx == 420) tempbx = 400;
5504 else if(tempbx == 525) tempbx = 480;
5505 push2 = tempbx;
5506 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
5507 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) {
5508 if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) {
5509 if (tempbx == 350) tempbx += 5;
5510 else if(tempbx == 480) tempbx += 5;
5511 }
5512 }
5513 }
5514 tempbx -= 2;
5515 temp = tempbx & 0x00FF;
5516 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x10,temp); /* 0x10 vertical Blank Start */
5517
5518 tempbx = push2;
5519 tempbx--;
5520 temp = tempbx & 0x00FF;
5521#if 0
5522 /* Missing code from 630/301B 2.04.5a and 650/302LV 1.10.6s (calles int 2f) */
5523 if(xxx()) {
5524 if(temp == 0xdf) temp = 0xda;
5525 }
5526#endif
5527 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0E,temp);
5528
5529 temp = 0;
5530 if(modeflag & DoubleScanMode) temp |= 0x80;
5531 if(HwInfo->jChipType >= SIS_661) {
5532 if(tempbx & 0x0200) temp |= 0x20;
5533 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x0B,0x5F,temp);
5534 if(tempbx & 0x0100) tempcx |= 0x000a;
5535 if(tempbx & 0x0400) tempcx |= 0x1200;
5536 } else {
5537 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0B,temp);
5538 if(tempbx & 0x0100) tempcx |= 0x0002;
5539 if(tempbx & 0x0400) tempcx |= 0x0600;
5540 }
5541 5380
5542 if(tempbx & 0x0200) tempcx |= 0x0040; 5381 temp = (SiS_Pr->SiS_VGAVT - VGAVDE) >> 1;
5382 SiS_Pr->CVSyncStart = VGAVDE + temp;
5543 5383
5544 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x11,0x00); /* 0x11 Vertical Blank End */ 5384 temp >>= 3;
5385 SiS_Pr->CVSyncEnd = SiS_Pr->CVSyncStart + temp;
5545 5386
5546 tempax = (SiS_Pr->SiS_VGAVT - tempbx) >> 2; 5387 SiS_CalcCRRegisters(SiS_Pr, 0);
5388 SiS_Pr->CCRT1CRTC[16] &= ~0xE0;
5547 5389
5548 if((ModeNo > 0x13) || (HwInfo->jChipType < SIS_315H)) { 5390 for(i = 0; i <= 7; i++) {
5549 if(resinfo != SIS_RI_1280x1024) { 5391 SiS_SetReg(SiS_Pr->SiS_Part1Port,CRTranslation[i],SiS_Pr->CCRT1CRTC[i]);
5550 tempbx += (tempax << 1);
5551 }
5552 } else if(HwInfo->jChipType >= SIS_315H) {
5553 if(SiS_Pr->SiS_LCDResInfo != Panel_1400x1050) {
5554 tempbx += (tempax << 1);
5555 }
5556 } 5392 }
5557 5393 for(i = 0x10, j = 8; i <= 0x12; i++, j++) {
5558 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { 5394 SiS_SetReg(SiS_Pr->SiS_Part1Port,CRTranslation[i],SiS_Pr->CCRT1CRTC[j]);
5559 tempbx -= 10;
5560 } else {
5561 if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) {
5562 if(SiS_Pr->SiS_TVMode & TVSetPAL) {
5563 tempbx += 40;
5564 if(HwInfo->jChipType >= SIS_315H) {
5565 if(SiS_Pr->SiS_VGAHDE == 800) tempbx += 10;
5566 }
5567 }
5568 }
5569 }
5570 tempax >>= 2;
5571 tempax++;
5572 tempax += tempbx;
5573 push1 = tempax;
5574 if(SiS_Pr->SiS_TVMode & TVSetPAL) {
5575 if(tempbx <= 513) {
5576 if(tempax >= 513) tempbx = 513;
5577 }
5578 } 5395 }
5579 temp = tempbx & 0x00FF; 5396 for(i = 0x15, j = 11; i <= 0x16; i++, j++) {
5580 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0C,temp); /* 0x0C Vertical Retrace Start */ 5397 SiS_SetReg(SiS_Pr->SiS_Part1Port,CRTranslation[i],SiS_Pr->CCRT1CRTC[j]);
5581
5582 tempbx--;
5583 temp = tempbx & 0x00FF;
5584 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x10,temp);
5585
5586 if(tempbx & 0x0100) tempcx |= 0x0008;
5587
5588 if(tempbx & 0x0200) {
5589 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x0B,0x20);
5590 } 5398 }
5591 tempbx++; 5399 for(i = 0x0a, j = 13; i <= 0x0c; i++, j++) {
5592 5400 SiS_SetReg(SiS_Pr->SiS_Part1Port,CRTranslation[i],SiS_Pr->CCRT1CRTC[j]);
5593 if(tempbx & 0x0100) tempcx |= 0x0004;
5594 if(tempbx & 0x0200) tempcx |= 0x0080;
5595 if(tempbx & 0x0400) {
5596 if(HwInfo->jChipType >= SIS_661) tempcx |= 0x0800;
5597 else if(SiS_Pr->SiS_VBType & VB_SIS301) tempcx |= 0x0800;
5598 else tempcx |= 0x0C00;
5599 } 5401 }
5600 5402
5601 tempbx = push1; 5403 temp = SiS_Pr->CCRT1CRTC[16] & 0xE0;
5602 temp = tempbx & 0x000F; 5404 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,CRTranslation[0x0E],0x1F,temp);
5603 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0D,temp); /* 0x0D vertical Retrace End */
5604
5605 if(tempbx & 0x0010) tempcx |= 0x2000;
5606
5607 temp = tempcx & 0x00FF;
5608 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0A,temp); /* 0x0A CR07 */
5609
5610 temp = (tempcx & 0xFF00) >> 8;
5611 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x17,temp); /* 0x17 SR0A */
5612 5405
5613 tempax = modeflag; 5406 temp = (SiS_Pr->CCRT1CRTC[16] & 0x01) << 5;
5614 temp = (tempax & 0xFF00) >> 8; 5407 if(modeflag & DoubleScanMode) temp |= 0x80;
5615 temp = (temp >> 1) & 0x09; 5408 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,CRTranslation[0x09],0x5F,temp);
5616 if(!(SiS_Pr->SiS_VBType & VB_SIS301)) temp |= 0x01; /* Always 8 dotclock */
5617 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x16,temp); /* 0x16 SR01 */
5618 5409
5619 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0F,0x00); /* 0x0F CR14 */ 5410 temp = 0;
5411 temp |= (SiS_GetReg(SiS_Pr->SiS_P3c4,0x01) & 0x01);
5412 if(modeflag & HalfDCLK) temp |= 0x08;
5413 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x16,temp); /* SR01: HalfDCLK[3], 8/9 div dotclock[0] */
5620 5414
5621 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x12,0x00); /* 0x12 CR17 */ 5415 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0F,0x00); /* CR14: (text mode: underline location) */
5416 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x12,0x00); /* CR17: n/a */
5622 5417
5623 temp = 0x00; 5418 temp = 0;
5624 if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) { 5419 if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) {
5625 if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x01) { 5420 temp = (SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x01) << 7;
5626 temp = 0x80;
5627 }
5628 } 5421 }
5629 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1A,temp); /* 0x1A SR0E */ 5422 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1A,temp); /* SR0E, dither[7] */
5630 5423
5631 temp = SiS_GetRegByte((SiS_Pr->SiS_P3ca+0x02)); 5424 temp = SiS_GetRegByte((SiS_Pr->SiS_P3ca+0x02));
5632 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,temp); 5425 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1b,temp); /* ? */
5426
5427#ifdef SIS_XORG_XF86
5428#ifdef TWDEBUG
5429 xf86DrvMsg(0, X_INFO, "%d %d %d %d %d %d %d %d (%d %d %d %d)\n",
5430 SiS_Pr->CHDisplay, SiS_Pr->CHSyncStart, SiS_Pr->CHSyncEnd, SiS_Pr->CHTotal,
5431 SiS_Pr->CVDisplay, SiS_Pr->CVSyncStart, SiS_Pr->CVSyncEnd, SiS_Pr->CVTotal,
5432 SiS_Pr->CHBlankStart, SiS_Pr->CHBlankEnd, SiS_Pr->CVBlankStart, SiS_Pr->CVBlankEnd);
5433
5434 xf86DrvMsg(0, X_INFO, " {{0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,\n",
5435 SiS_Pr->CCRT1CRTC[0], SiS_Pr->CCRT1CRTC[1],
5436 SiS_Pr->CCRT1CRTC[2], SiS_Pr->CCRT1CRTC[3],
5437 SiS_Pr->CCRT1CRTC[4], SiS_Pr->CCRT1CRTC[5],
5438 SiS_Pr->CCRT1CRTC[6], SiS_Pr->CCRT1CRTC[7]);
5439 xf86DrvMsg(0, X_INFO, " 0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,\n",
5440 SiS_Pr->CCRT1CRTC[8], SiS_Pr->CCRT1CRTC[9],
5441 SiS_Pr->CCRT1CRTC[10], SiS_Pr->CCRT1CRTC[11],
5442 SiS_Pr->CCRT1CRTC[12], SiS_Pr->CCRT1CRTC[13],
5443 SiS_Pr->CCRT1CRTC[14], SiS_Pr->CCRT1CRTC[15]);
5444 xf86DrvMsg(0, X_INFO, " 0x%02x}},\n", SiS_Pr->CCRT1CRTC[16]);
5445#endif
5446#endif
5633} 5447}
5634 5448
5635/* Setup panel link 5449/* Setup panel link
@@ -5637,18 +5451,18 @@ SiS_SetGroup1_301(SiS_Private *SiS_Pr, USHORT ModeNo,USHORT ModeIdIndex,
5637 * 300/LVDS+TV, 300/301B-DH, 315/LVDS+TV, 315/LCDA 5451 * 300/LVDS+TV, 300/301B-DH, 315/LVDS+TV, 315/LCDA
5638 */ 5452 */
5639static void 5453static void
5640SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, 5454SiS_SetGroup1_LVDS(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex,
5641 PSIS_HW_INFO HwInfo, USHORT RefreshRateTableIndex) 5455 unsigned short RefreshRateTableIndex)
5642{ 5456{
5643 USHORT modeflag,resinfo; 5457 unsigned short modeflag, resinfo = 0;
5644 USHORT push2,tempax,tempbx,tempcx,temp; 5458 unsigned short push2, tempax, tempbx, tempcx, temp;
5645 ULONG tempeax=0,tempebx,tempecx,tempvcfact=0; 5459 unsigned int tempeax = 0, tempebx, tempecx, tempvcfact = 0;
5646 BOOLEAN islvds = FALSE, issis = FALSE, chkdclkfirst = FALSE; 5460 BOOLEAN islvds = FALSE, issis = FALSE, chkdclkfirst = FALSE;
5647#ifdef SIS300 5461#ifdef SIS300
5648 USHORT crt2crtc; 5462 unsigned short crt2crtc = 0;
5649#endif 5463#endif
5650#ifdef SIS315H 5464#ifdef SIS315H
5651 USHORT pushcx; 5465 unsigned short pushcx;
5652#endif 5466#endif
5653 5467
5654 if(ModeNo <= 0x13) { 5468 if(ModeNo <= 0x13) {
@@ -5659,15 +5473,11 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
5659#endif 5473#endif
5660 } else if(SiS_Pr->UseCustomMode) { 5474 } else if(SiS_Pr->UseCustomMode) {
5661 modeflag = SiS_Pr->CModeFlag; 5475 modeflag = SiS_Pr->CModeFlag;
5662 resinfo = 0;
5663#ifdef SIS300
5664 crt2crtc = 0;
5665#endif
5666 } else { 5476 } else {
5667 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; 5477 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
5668 resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; 5478 resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
5669#ifdef SIS300 5479#ifdef SIS300
5670 crt2crtc = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; 5480 crt2crtc = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
5671#endif 5481#endif
5672 } 5482 }
5673 5483
@@ -5681,14 +5491,14 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
5681 issis = TRUE; 5491 issis = TRUE;
5682 } 5492 }
5683 5493
5684 if((HwInfo->jChipType >= SIS_315H) && (islvds) && (!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA))) { 5494 if((SiS_Pr->ChipType >= SIS_315H) && (islvds) && (!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA))) {
5685 if((!SiS_Pr->SiS_IF_DEF_FSTN) && (!SiS_Pr->SiS_IF_DEF_DSTN)) { 5495 if((!SiS_Pr->SiS_IF_DEF_FSTN) && (!SiS_Pr->SiS_IF_DEF_DSTN)) {
5686 chkdclkfirst = TRUE; 5496 chkdclkfirst = TRUE;
5687 } 5497 }
5688 } 5498 }
5689 5499
5690#ifdef SIS315H 5500#ifdef SIS315H
5691 if((HwInfo->jChipType >= SIS_315H) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { 5501 if((SiS_Pr->ChipType >= SIS_315H) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
5692 if(IS_SIS330) { 5502 if(IS_SIS330) {
5693 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x10); 5503 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x10);
5694 } else if(IS_SIS740) { 5504 } else if(IS_SIS740) {
@@ -5704,7 +5514,7 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
5704 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x00); 5514 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x00);
5705 } else if(SiS_Pr->SiS_VBType & VB_SISVB) { 5515 } else if(SiS_Pr->SiS_VBType & VB_SISVB) {
5706 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2D,0x0f); 5516 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x2D,0x0f);
5707 if(SiS_Pr->SiS_VBType & VB_SIS301C) { 5517 if(SiS_Pr->SiS_VBType & VB_SIS30xC) {
5708 if((SiS_Pr->SiS_LCDResInfo == Panel_1024x768) || 5518 if((SiS_Pr->SiS_LCDResInfo == Panel_1024x768) ||
5709 (SiS_Pr->SiS_LCDResInfo == Panel_1280x1024)) { 5519 (SiS_Pr->SiS_LCDResInfo == Panel_1280x1024)) {
5710 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x20); 5520 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x2D,0x20);
@@ -5720,10 +5530,10 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
5720 tempax = SiS_Pr->SiS_LCDHDES; 5530 tempax = SiS_Pr->SiS_LCDHDES;
5721 if(islvds) { 5531 if(islvds) {
5722 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { 5532 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
5723 if((!SiS_Pr->SiS_IF_DEF_FSTN) && (!SiS_Pr->SiS_IF_DEF_DSTN)) { 5533 if(!SiS_Pr->SiS_IF_DEF_FSTN && !SiS_Pr->SiS_IF_DEF_DSTN) {
5724 if((SiS_Pr->SiS_LCDResInfo == Panel_640x480) && 5534 if((SiS_Pr->SiS_LCDResInfo == Panel_640x480) &&
5725 (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode))) { 5535 (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode))) {
5726 tempax -= 8; 5536 tempax -= 8;
5727 } 5537 }
5728 } 5538 }
5729 } 5539 }
@@ -5736,13 +5546,14 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
5736 5546
5737 tempbx = SiS_Pr->SiS_HDE; 5547 tempbx = SiS_Pr->SiS_HDE;
5738 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { 5548 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
5739 if((SiS_Pr->SiS_LCDResInfo == Panel_640x480_2) ||
5740 (SiS_Pr->SiS_LCDResInfo == Panel_640x480_3)) {
5741 tempbx >>= 1;
5742 }
5743 if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { 5549 if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) {
5744 tempbx = SiS_Pr->PanelXRes; 5550 tempbx = SiS_Pr->PanelXRes;
5745 } 5551 }
5552 if((SiS_Pr->SiS_LCDResInfo == Panel_320x240_1) ||
5553 (SiS_Pr->SiS_LCDResInfo == Panel_320x240_2) ||
5554 (SiS_Pr->SiS_LCDResInfo == Panel_320x240_3)) {
5555 tempbx >>= 1;
5556 }
5746 } 5557 }
5747 5558
5748 tempax += tempbx; 5559 tempax += tempbx;
@@ -5767,25 +5578,25 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
5767 temp = (tempcx >> 3) & 0x00FF; 5578 temp = (tempcx >> 3) & 0x00FF;
5768 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { 5579 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
5769 if(SiS_Pr->SiS_IF_DEF_TRUMPION) { 5580 if(SiS_Pr->SiS_IF_DEF_TRUMPION) {
5770 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { 5581 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) {
5771 switch(ModeNo) { 5582 switch(ModeNo) {
5772 case 0x04: 5583 case 0x04:
5773 case 0x05: 5584 case 0x05:
5774 case 0x0d: temp = 0x56; break; 5585 case 0x0d: temp = 0x56; break;
5775 case 0x10: temp = 0x60; break; 5586 case 0x10: temp = 0x60; break;
5776 case 0x13: temp = 0x5f; break; 5587 case 0x13: temp = 0x5f; break;
5777 case 0x40: 5588 case 0x40:
5778 case 0x41: 5589 case 0x41:
5779 case 0x4f: 5590 case 0x4f:
5780 case 0x43: 5591 case 0x43:
5781 case 0x44: 5592 case 0x44:
5782 case 0x62: 5593 case 0x62:
5783 case 0x56: 5594 case 0x56:
5784 case 0x53: 5595 case 0x53:
5785 case 0x5d: 5596 case 0x5d:
5786 case 0x5e: temp = 0x54; break; 5597 case 0x5e: temp = 0x54; break;
5787 } 5598 }
5788 } 5599 }
5789 } 5600 }
5790 } 5601 }
5791 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x14,temp); /* BPLHRS */ 5602 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x14,temp); /* BPLHRS */
@@ -5793,12 +5604,12 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
5793 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { 5604 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
5794 temp += 2; 5605 temp += 2;
5795 if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { 5606 if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) {
5796 temp += 8; 5607 temp += 8;
5797 if(SiS_Pr->PanelHRE != 999) { 5608 if(SiS_Pr->PanelHRE != 999) {
5798 temp = tempcx + SiS_Pr->PanelHRE; 5609 temp = tempcx + SiS_Pr->PanelHRE;
5799 if(temp >= SiS_Pr->SiS_HT) temp -= SiS_Pr->SiS_HT; 5610 if(temp >= SiS_Pr->SiS_HT) temp -= SiS_Pr->SiS_HT;
5800 temp >>= 3; 5611 temp >>= 3;
5801 } 5612 }
5802 } 5613 }
5803 } else { 5614 } else {
5804 temp += 10; 5615 temp += 10;
@@ -5806,9 +5617,6 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
5806 5617
5807 temp &= 0x1F; 5618 temp &= 0x1F;
5808 temp |= ((tempcx & 0x07) << 5); 5619 temp |= ((tempcx & 0x07) << 5);
5809#if 0
5810 if(SiS_Pr->SiS_IF_DEF_FSTN) temp = 0x20; /* WRONG? BIOS loads cl, not ah */
5811#endif
5812 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x15,temp); /* BPLHRE */ 5620 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x15,temp); /* BPLHRE */
5813 5621
5814 /* Vertical */ 5622 /* Vertical */
@@ -5826,9 +5634,9 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
5826 push2 = tempbx; 5634 push2 = tempbx;
5827 5635
5828 tempcx = SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE; 5636 tempcx = SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE;
5829 if(HwInfo->jChipType < SIS_315H) { 5637 if(SiS_Pr->ChipType < SIS_315H) {
5830 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { 5638 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
5831 if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { 5639 if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) {
5832 tempcx = SiS_Pr->SiS_VGAVT - SiS_Pr->PanelYRes; 5640 tempcx = SiS_Pr->SiS_VGAVT - SiS_Pr->PanelYRes;
5833 } 5641 }
5834 } 5642 }
@@ -5844,19 +5652,19 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
5844 if(issis) tempbx++; 5652 if(issis) tempbx++;
5845 } else { 5653 } else {
5846 tempbx += tempcx; 5654 tempbx += tempcx;
5847 if(HwInfo->jChipType < SIS_315H) tempbx++; 5655 if(SiS_Pr->ChipType < SIS_315H) tempbx++;
5848 else if(issis) tempbx++; 5656 else if(issis) tempbx++;
5849 } 5657 }
5850 5658
5851 if(tempbx >= SiS_Pr->SiS_VT) tempbx -= SiS_Pr->SiS_VT; /* BPLVRS */ 5659 if(tempbx >= SiS_Pr->SiS_VT) tempbx -= SiS_Pr->SiS_VT;
5852 5660
5853 temp = tempbx & 0x00FF; 5661 temp = tempbx & 0x00FF;
5854 if(SiS_Pr->SiS_IF_DEF_TRUMPION) { 5662 if(SiS_Pr->SiS_IF_DEF_TRUMPION) {
5855 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { 5663 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) {
5856 if(ModeNo == 0x10) temp = 0xa9; 5664 if(ModeNo == 0x10) temp = 0xa9;
5857 } 5665 }
5858 } 5666 }
5859 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,temp); 5667 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x18,temp); /* BPLVRS */
5860 5668
5861 tempcx >>= 3; 5669 tempcx >>= 3;
5862 tempcx++; 5670 tempcx++;
@@ -5879,13 +5687,13 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
5879 } else if(SiS_Pr->SiS_VGAVDE != SiS_Pr->SiS_VDE) temp |= 0x40; 5687 } else if(SiS_Pr->SiS_VGAVDE != SiS_Pr->SiS_VDE) temp |= 0x40;
5880 if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) temp |= 0x40; 5688 if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) temp |= 0x40;
5881 tempbx = 0x87; 5689 tempbx = 0x87;
5882 if((HwInfo->jChipType >= SIS_315H) || 5690 if((SiS_Pr->ChipType >= SIS_315H) ||
5883 (HwInfo->jChipRevision >= 0x30)) { 5691 (SiS_Pr->ChipRevision >= 0x30)) {
5884 tempbx = 0x07; 5692 tempbx = 0x07;
5885 if((SiS_Pr->SiS_IF_DEF_CH70xx == 1) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) { 5693 if((SiS_Pr->SiS_IF_DEF_CH70xx == 1) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) {
5886 if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x03) temp |= 0x80; 5694 if(SiS_GetReg(SiS_Pr->SiS_Part1Port,0x00) & 0x03) temp |= 0x80;
5887 } 5695 }
5888 /* Chrontel 701x operates in 24bit mode (8-8-8, 2x12bit mutliplexed) via VGA2 */ 5696 /* Chrontel 701x operates in 24bit mode (8-8-8, 2x12bit multiplexed) via VGA2 */
5889 if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) { 5697 if(SiS_Pr->SiS_LCDInfo & LCDRGB18Bit) {
5890 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { 5698 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
5891 if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x06) & 0x10) temp |= 0x80; 5699 if(SiS_GetReg(SiS_Pr->SiS_P3c4,0x06) & 0x10) temp |= 0x80;
@@ -5896,59 +5704,58 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
5896 } 5704 }
5897 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x1A,tempbx,temp); 5705 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x1A,tempbx,temp);
5898 5706
5899 tempbx = push2; /* BPLVDEE */ 5707 tempbx = push2; /* BPLVDEE */
5900 5708
5901 tempcx = SiS_Pr->SiS_LCDVDES; /* BPLVDES */ 5709 tempcx = SiS_Pr->SiS_LCDVDES; /* BPLVDES */
5902 5710
5903 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { 5711 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
5904 switch(SiS_Pr->SiS_LCDResInfo) { 5712 switch(SiS_Pr->SiS_LCDResInfo) {
5905 case Panel_640x480: 5713 case Panel_640x480:
5906 tempbx = SiS_Pr->SiS_VGAVDE - 1; 5714 tempbx = SiS_Pr->SiS_VGAVDE - 1;
5907 tempcx = SiS_Pr->SiS_VGAVDE; 5715 tempcx = SiS_Pr->SiS_VGAVDE;
5908 break; 5716 break;
5909 case Panel_800x600: 5717 case Panel_800x600:
5910 if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { 5718 if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
5911 if(resinfo == SIS_RI_800x600) tempcx++; 5719 if(resinfo == SIS_RI_800x600) tempcx++;
5912 } 5720 }
5913 break; 5721 break;
5914 case Panel_1024x600: 5722 case Panel_1024x600:
5915 if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { 5723 if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
5916 if(resinfo == SIS_RI_1024x600) tempcx++; 5724 if(resinfo == SIS_RI_1024x600) tempcx++;
5917 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) { 5725 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) {
5918 if(resinfo == SIS_RI_800x600) tempcx++; 5726 if(resinfo == SIS_RI_800x600) tempcx++;
5919 } 5727 }
5920 } 5728 }
5921 break; 5729 break;
5922 case Panel_1024x768: 5730 case Panel_1024x768:
5923 if(HwInfo->jChipType < SIS_315H) { 5731 if(SiS_Pr->ChipType < SIS_315H) {
5924 if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { 5732 if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
5925 if(resinfo == SIS_RI_1024x768) tempcx++; 5733 if(resinfo == SIS_RI_1024x768) tempcx++;
5926 } 5734 }
5927 } 5735 }
5928 break; 5736 break;
5929 } 5737 }
5930 } 5738 }
5931 5739
5932 temp = ((tempbx >> 8) & 0x07) << 3; 5740 temp = ((tempbx >> 8) & 0x07) << 3;
5933 temp = temp | ((tempcx >> 8) & 0x07); 5741 temp |= ((tempcx >> 8) & 0x07);
5934 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1D,temp); 5742 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1D,temp);
5935 /* if(SiS_Pr->SiS_IF_DEF_FSTN) tempbx++; */
5936 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1C,tempbx); 5743 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1C,tempbx);
5937 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1B,tempcx); 5744 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1B,tempcx);
5938 5745
5939 /* Vertical scaling */ 5746 /* Vertical scaling */
5940 5747
5941 if(HwInfo->jChipType < SIS_315H) { 5748 if(SiS_Pr->ChipType < SIS_315H) {
5942 5749
5943#ifdef SIS300 /* 300 series */ 5750#ifdef SIS300 /* 300 series */
5944 tempeax = SiS_Pr->SiS_VGAVDE << 6; 5751 tempeax = SiS_Pr->SiS_VGAVDE << 6;
5945 temp = (tempeax % (ULONG)SiS_Pr->SiS_VDE); 5752 temp = (tempeax % (unsigned int)SiS_Pr->SiS_VDE);
5946 tempeax = tempeax / (ULONG)SiS_Pr->SiS_VDE; 5753 tempeax = tempeax / (unsigned int)SiS_Pr->SiS_VDE;
5947 if(temp) tempeax++; 5754 if(temp) tempeax++;
5948 5755
5949 if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) tempeax = 0x3F; 5756 if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) tempeax = 0x3F;
5950 5757
5951 temp = (USHORT)(tempeax & 0x00FF); 5758 temp = (unsigned short)(tempeax & 0x00FF);
5952 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1E,temp); /* BPLVCFACT */ 5759 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1E,temp); /* BPLVCFACT */
5953 tempvcfact = temp; 5760 tempvcfact = temp;
5954#endif /* SIS300 */ 5761#endif /* SIS300 */
@@ -5963,20 +5770,20 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
5963 if(temp) tempeax++; 5770 if(temp) tempeax++;
5964 tempvcfact = tempeax; 5771 tempvcfact = tempeax;
5965 5772
5966 temp = (USHORT)(tempeax & 0x00FF); 5773 temp = (unsigned short)(tempeax & 0x00FF);
5967 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x37,temp); 5774 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x37,temp);
5968 temp = (USHORT)((tempeax & 0x00FF00) >> 8); 5775 temp = (unsigned short)((tempeax & 0x00FF00) >> 8);
5969 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x36,temp); 5776 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x36,temp);
5970 temp = (USHORT)((tempeax & 0x00030000) >> 16); 5777 temp = (unsigned short)((tempeax & 0x00030000) >> 16);
5971 if(SiS_Pr->SiS_VDE == SiS_Pr->SiS_VGAVDE) temp |= 0x04; 5778 if(SiS_Pr->SiS_VDE == SiS_Pr->SiS_VGAVDE) temp |= 0x04;
5972 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x35,temp); 5779 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x35,temp);
5973 5780
5974 if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302ELV)) { 5781 if(SiS_Pr->SiS_VBType & VB_SISPART4SCALER) {
5975 temp = (USHORT)(tempeax & 0x00FF); 5782 temp = (unsigned short)(tempeax & 0x00FF);
5976 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x3c,temp); 5783 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x3c,temp);
5977 temp = (USHORT)((tempeax & 0x00FF00) >> 8); 5784 temp = (unsigned short)((tempeax & 0x00FF00) >> 8);
5978 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x3b,temp); 5785 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x3b,temp);
5979 temp = (USHORT)(((tempeax & 0x00030000) >> 16) << 6); 5786 temp = (unsigned short)(((tempeax & 0x00030000) >> 16) << 6);
5980 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x3a,0x3f,temp); 5787 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x3a,0x3f,temp);
5981 temp = 0; 5788 temp = 0;
5982 if(SiS_Pr->SiS_VDE != SiS_Pr->SiS_VGAVDE) temp |= 0x08; 5789 if(SiS_Pr->SiS_VDE != SiS_Pr->SiS_VGAVDE) temp |= 0x08;
@@ -5997,29 +5804,29 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
5997 tempecx = 0xFFFF; 5804 tempecx = 0xFFFF;
5998 } else { 5805 } else {
5999 tempecx = tempebx / SiS_Pr->SiS_HDE; 5806 tempecx = tempebx / SiS_Pr->SiS_HDE;
6000 if(HwInfo->jChipType >= SIS_315H) { 5807 if(SiS_Pr->ChipType >= SIS_315H) {
6001 if(tempebx % SiS_Pr->SiS_HDE) tempecx++; 5808 if(tempebx % SiS_Pr->SiS_HDE) tempecx++;
6002 } 5809 }
6003 } 5810 }
6004 5811
6005 if(HwInfo->jChipType >= SIS_315H) { 5812 if(SiS_Pr->ChipType >= SIS_315H) {
6006 tempeax = (tempebx / tempecx) - 1; 5813 tempeax = (tempebx / tempecx) - 1;
6007 } else { 5814 } else {
6008 tempeax = ((SiS_Pr->SiS_VGAHT << 16) / tempecx) - 1; 5815 tempeax = ((SiS_Pr->SiS_VGAHT << 16) / tempecx) - 1;
6009 } 5816 }
6010 tempecx = (tempecx << 16) | (tempeax & 0xFFFF); 5817 tempecx = (tempecx << 16) | (tempeax & 0xFFFF);
6011 temp = (USHORT)(tempecx & 0x00FF); 5818 temp = (unsigned short)(tempecx & 0x00FF);
6012 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1F,temp); 5819 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1F,temp);
6013 5820
6014 if(HwInfo->jChipType >= SIS_315H) { 5821 if(SiS_Pr->ChipType >= SIS_315H) {
6015 tempeax = (SiS_Pr->SiS_VGAVDE << 18) / tempvcfact; 5822 tempeax = (SiS_Pr->SiS_VGAVDE << 18) / tempvcfact;
6016 tempbx = (USHORT)(tempeax & 0xFFFF); 5823 tempbx = (unsigned short)(tempeax & 0xFFFF);
6017 } else { 5824 } else {
6018 tempeax = SiS_Pr->SiS_VGAVDE << 6; 5825 tempeax = SiS_Pr->SiS_VGAVDE << 6;
6019 tempbx = tempvcfact & 0x3f; 5826 tempbx = tempvcfact & 0x3f;
6020 if(tempbx == 0) tempbx = 64; 5827 if(tempbx == 0) tempbx = 64;
6021 tempeax /= tempbx; 5828 tempeax /= tempbx;
6022 tempbx = (USHORT)(tempeax & 0xFFFF); 5829 tempbx = (unsigned short)(tempeax & 0xFFFF);
6023 } 5830 }
6024 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) tempbx--; 5831 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) tempbx--;
6025 if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) { 5832 if(SiS_Pr->SiS_SetFlag & EnableLVDSDDA) {
@@ -6032,24 +5839,24 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
6032 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x20,temp); 5839 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x20,temp);
6033 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x21,tempbx); 5840 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x21,tempbx);
6034 5841
6035 tempecx >>= 16; /* BPLHCFACT */ 5842 tempecx >>= 16; /* BPLHCFACT */
6036 if(!chkdclkfirst) { 5843 if(!chkdclkfirst) {
6037 if(modeflag & HalfDCLK) tempecx >>= 1; 5844 if(modeflag & HalfDCLK) tempecx >>= 1;
6038 } 5845 }
6039 temp = (USHORT)((tempecx & 0xFF00) >> 8); 5846 temp = (unsigned short)((tempecx & 0xFF00) >> 8);
6040 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x22,temp); 5847 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x22,temp);
6041 temp = (USHORT)(tempecx & 0x00FF); 5848 temp = (unsigned short)(tempecx & 0x00FF);
6042 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x23,temp); 5849 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x23,temp);
6043 5850
6044#ifdef SIS315H 5851#ifdef SIS315H
6045 if(HwInfo->jChipType >= SIS_315H) { 5852 if(SiS_Pr->ChipType >= SIS_315H) {
6046 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { 5853 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
6047 if((islvds) || (SiS_Pr->SiS_VBInfo & VB_SIS301LV302LV)) { 5854 if((islvds) || (SiS_Pr->SiS_VBInfo & VB_SISLVDS)) {
6048 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1e,0x20); 5855 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1e,0x20);
6049 } 5856 }
6050 } else { 5857 } else {
6051 if(islvds) { 5858 if(islvds) {
6052 if(HwInfo->jChipType == SIS_740) { 5859 if(SiS_Pr->ChipType == SIS_740) {
6053 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1e,0x03); 5860 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x1e,0x03);
6054 } else { 5861 } else {
6055 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1e,0x23); 5862 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x1e,0x23);
@@ -6061,17 +5868,26 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
6061 5868
6062#ifdef SIS300 5869#ifdef SIS300
6063 if(SiS_Pr->SiS_IF_DEF_TRUMPION) { 5870 if(SiS_Pr->SiS_IF_DEF_TRUMPION) {
6064 int i; 5871 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
6065 UCHAR TrumpMode13[4] = { 0x01, 0x10, 0x2c, 0x00 }; 5872 unsigned char *trumpdata;
6066 UCHAR TrumpMode10_1[4] = { 0x01, 0x10, 0x27, 0x00 }; 5873 int i, j = crt2crtc;
6067 UCHAR TrumpMode10_2[4] = { 0x01, 0x16, 0x10, 0x00 }; 5874 unsigned char TrumpMode13[4] = { 0x01, 0x10, 0x2c, 0x00 };
5875 unsigned char TrumpMode10_1[4] = { 0x01, 0x10, 0x27, 0x00 };
5876 unsigned char TrumpMode10_2[4] = { 0x01, 0x16, 0x10, 0x00 };
5877
5878 if(SiS_Pr->SiS_UseROM) {
5879 trumpdata = &ROMAddr[0x8001 + (j * 80)];
5880 } else {
5881 if(SiS_Pr->SiS_LCDTypeInfo == 0x0e) j += 7;
5882 trumpdata = &SiS300_TrumpionData[j][0];
5883 }
6068 5884
6069 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0xbf); 5885 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x02,0xbf);
6070 for(i=0; i<5; i++) { 5886 for(i=0; i<5; i++) {
6071 SiS_SetTrumpionBlock(SiS_Pr, &SiS300_TrumpionData[crt2crtc][0]); 5887 SiS_SetTrumpionBlock(SiS_Pr, trumpdata);
6072 } 5888 }
6073 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { 5889 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) {
6074 if(ModeNo == 0x13) { 5890 if(ModeNo == 0x13) {
6075 for(i=0; i<4; i++) { 5891 for(i=0; i<4; i++) {
6076 SiS_SetTrumpionBlock(SiS_Pr, &TrumpMode13[0]); 5892 SiS_SetTrumpionBlock(SiS_Pr, &TrumpMode13[0]);
6077 } 5893 }
@@ -6095,67 +5911,66 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
6095 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x29,0x5A); 5911 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x29,0x5A);
6096 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2A,0x4B); 5912 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2A,0x4B);
6097 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x44,~0x07,0x03); 5913 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x44,~0x07,0x03);
6098 tempax = SiS_Pr->SiS_HDE; /* Blps = lcdhdee(lcdhdes+HDE) + 64 */ 5914 tempax = SiS_Pr->SiS_HDE; /* Blps = lcdhdee(lcdhdes+HDE) + 64 */
6099 if(SiS_Pr->SiS_LCDResInfo == Panel_640x480_2 || 5915 if(SiS_Pr->SiS_LCDResInfo == Panel_320x240_1 ||
6100 SiS_Pr->SiS_LCDResInfo == Panel_640x480_3) tempax >>= 1; 5916 SiS_Pr->SiS_LCDResInfo == Panel_320x240_2 ||
5917 SiS_Pr->SiS_LCDResInfo == Panel_320x240_3) tempax >>= 1;
6101 tempax += 64; 5918 tempax += 64;
6102 temp = tempax & 0x00FF; 5919 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x38,tempax & 0xff);
6103 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x38,temp); 5920 temp = (tempax >> 8) << 3;
6104 temp = ((tempax & 0xFF00) >> 8) << 3;
6105 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x35,~0x078,temp); 5921 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x35,~0x078,temp);
6106 tempax += 32; /* Blpe=lBlps+32 */ 5922 tempax += 32; /* Blpe = lBlps+32 */
6107 temp = tempax & 0x00FF; 5923 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x39,tempax & 0xff);
6108 if(SiS_Pr->SiS_IF_DEF_FSTN) temp = 0; 5924 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3A,0x00); /* Bflml = 0 */
6109 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x39,temp); 5925 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x3C,~0x007);
6110 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3A,0x00); /* Bflml=0 */
6111 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x007,0x00);
6112 5926
6113 tempax = SiS_Pr->SiS_VDE; 5927 tempax = SiS_Pr->SiS_VDE;
6114 if(SiS_Pr->SiS_LCDResInfo == Panel_640x480_2 || 5928 if(SiS_Pr->SiS_LCDResInfo == Panel_320x240_1 ||
6115 SiS_Pr->SiS_LCDResInfo == Panel_640x480_3) tempax >>= 1; 5929 SiS_Pr->SiS_LCDResInfo == Panel_320x240_2 ||
5930 SiS_Pr->SiS_LCDResInfo == Panel_320x240_3) tempax >>= 1;
6116 tempax >>= 1; 5931 tempax >>= 1;
6117 temp = tempax & 0x00FF; 5932 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3B,tempax & 0xff);
6118 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3B,temp); 5933 temp = (tempax >> 8) << 3;
6119 temp = ((tempax & 0xFF00) >> 8) << 3;
6120 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x038,temp); 5934 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x038,temp);
6121 5935
6122 tempeax = SiS_Pr->SiS_HDE; 5936 tempeax = SiS_Pr->SiS_HDE;
6123 if(SiS_Pr->SiS_LCDResInfo == Panel_640x480_2 || 5937 if(SiS_Pr->SiS_LCDResInfo == Panel_320x240_1 ||
6124 SiS_Pr->SiS_LCDResInfo == Panel_640x480_3) tempeax >>= 1; 5938 SiS_Pr->SiS_LCDResInfo == Panel_320x240_2 ||
6125 tempeax <<= 2; /* BDxFIFOSTOP = (HDE*4)/128 */ 5939 SiS_Pr->SiS_LCDResInfo == Panel_320x240_3) tempeax >>= 1;
6126 tempebx = 128; 5940 tempeax <<= 2; /* BDxFIFOSTOP = (HDE*4)/128 */
6127 temp = (USHORT)(tempeax % tempebx); 5941 temp = tempeax & 0x7f;
6128 tempeax = tempeax / tempebx; 5942 tempeax >>= 7;
6129 if(temp) tempeax++; 5943 if(temp) tempeax++;
6130 temp = (USHORT)(tempeax & 0x003F); 5944 temp = tempeax & 0x3f;
6131 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x45,~0x0FF,temp); 5945 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x45,temp);
6132 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3F,0x00); /* BDxWadrst0 */ 5946 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3F,0x00); /* BDxWadrst0 */
6133 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3E,0x00); 5947 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3E,0x00);
6134 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3D,0x10); 5948 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x3D,0x10);
6135 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x040,0x00); 5949 SiS_SetRegAND(SiS_Pr->SiS_Part1Port,0x3C,~0x040);
6136 5950
6137 tempax = SiS_Pr->SiS_HDE; 5951 tempax = SiS_Pr->SiS_HDE;
6138 if(SiS_Pr->SiS_LCDResInfo == Panel_640x480_2 || 5952 if(SiS_Pr->SiS_LCDResInfo == Panel_320x240_1 ||
6139 SiS_Pr->SiS_LCDResInfo == Panel_640x480_3) tempax >>= 1; 5953 SiS_Pr->SiS_LCDResInfo == Panel_320x240_2 ||
6140 tempax >>= 4; /* BDxWadroff = HDE*4/8/8 */ 5954 SiS_Pr->SiS_LCDResInfo == Panel_320x240_3) tempax >>= 1;
5955 tempax >>= 4; /* BDxWadroff = HDE*4/8/8 */
6141 pushcx = tempax; 5956 pushcx = tempax;
6142 temp = tempax & 0x00FF; 5957 temp = tempax & 0x00FF;
6143 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x43,temp); 5958 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x43,temp);
6144 temp = ((tempax & 0xFF00) >> 8) << 3; 5959 temp = ((tempax & 0xFF00) >> 8) << 3;
6145 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x44,~0x0F8,temp); 5960 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x44,~0x0F8,temp);
6146 5961
6147 tempax = SiS_Pr->SiS_VDE; /* BDxWadrst1 = BDxWadrst0 + BDxWadroff * VDE */ 5962 tempax = SiS_Pr->SiS_VDE; /* BDxWadrst1 = BDxWadrst0 + BDxWadroff * VDE */
6148 if(SiS_Pr->SiS_LCDResInfo == Panel_640x480_2 || 5963 if(SiS_Pr->SiS_LCDResInfo == Panel_320x240_1 ||
6149 SiS_Pr->SiS_LCDResInfo == Panel_640x480_3) tempax >>= 1; 5964 SiS_Pr->SiS_LCDResInfo == Panel_320x240_2 ||
6150 tempeax = (tempax * pushcx); 5965 SiS_Pr->SiS_LCDResInfo == Panel_320x240_3) tempax >>= 1;
6151 tempebx = 0x00100000 + tempeax; 5966 tempeax = tempax * pushcx;
6152 temp = (USHORT)tempebx & 0x000000FF; 5967 temp = tempeax & 0xFF;
6153 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x42,temp); 5968 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x42,temp);
6154 temp = (USHORT)((tempebx & 0x0000FF00) >> 8); 5969 temp = (tempeax & 0xFF00) >> 8;
6155 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x41,temp); 5970 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x41,temp);
6156 temp = (USHORT)((tempebx & 0x00FF0000) >> 16); 5971 temp = ((tempeax & 0xFF0000) >> 16) | 0x10;
6157 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x40,temp); 5972 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x40,temp);
6158 temp = (USHORT)(((tempebx & 0x01000000) >> 24) << 7); 5973 temp = ((tempeax & 0x01000000) >> 24) << 7;
6159 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x080,temp); 5974 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x3C,~0x080,temp);
6160 5975
6161 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2F,0x03); 5976 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2F,0x03);
@@ -6192,20 +6007,20 @@ SiS_SetGroup1_LVDS(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
6192 6007
6193/* Set Part 1 */ 6008/* Set Part 1 */
6194static void 6009static void
6195SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, 6010SiS_SetGroup1(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex,
6196 PSIS_HW_INFO HwInfo, USHORT RefreshRateTableIndex) 6011 unsigned short RefreshRateTableIndex)
6197{ 6012{
6198#if defined(SIS300) || defined(SIS315H) 6013#if defined(SIS300) || defined(SIS315H)
6199 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; 6014 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
6200#endif 6015#endif
6201 USHORT temp=0, tempax=0, tempbx=0, tempcx=0, bridgeadd=0; 6016 unsigned short temp=0, tempax=0, tempbx=0, tempcx=0, bridgeadd=0;
6202 USHORT pushbx=0, CRT1Index=0, modeflag, resinfo=0; 6017 unsigned short pushbx=0, CRT1Index=0, modeflag, resinfo=0;
6203#ifdef SIS315H 6018#ifdef SIS315H
6204 USHORT tempbl=0; 6019 unsigned short tempbl=0;
6205#endif 6020#endif
6206 6021
6207 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { 6022 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
6208 SiS_SetGroup1_LVDS(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, RefreshRateTableIndex); 6023 SiS_SetGroup1_LVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
6209 return; 6024 return;
6210 } 6025 }
6211 6026
@@ -6214,47 +6029,47 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
6214 } else if(SiS_Pr->UseCustomMode) { 6029 } else if(SiS_Pr->UseCustomMode) {
6215 modeflag = SiS_Pr->CModeFlag; 6030 modeflag = SiS_Pr->CModeFlag;
6216 } else { 6031 } else {
6217 CRT1Index = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; 6032 CRT1Index = SiS_GetRefCRT1CRTC(SiS_Pr, RefreshRateTableIndex, SiS_Pr->SiS_UseWideCRT2);
6218 resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; 6033 resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
6219 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; 6034 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
6220 } 6035 }
6221 6036
6222 SiS_SetCRT2Offset(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); 6037 SiS_SetCRT2Offset(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
6223 6038
6224 if( ! ((HwInfo->jChipType >= SIS_315H) && 6039 if( ! ((SiS_Pr->ChipType >= SIS_315H) &&
6225 (SiS_Pr->SiS_IF_DEF_LVDS == 1) && 6040 (SiS_Pr->SiS_IF_DEF_LVDS == 1) &&
6226 (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ) { 6041 (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ) {
6227 6042
6228 if(HwInfo->jChipType < SIS_315H ) { 6043 if(SiS_Pr->ChipType < SIS_315H ) {
6229#ifdef SIS300 6044#ifdef SIS300
6230 SiS_SetCRT2FIFO_300(SiS_Pr, ModeNo, HwInfo); 6045 SiS_SetCRT2FIFO_300(SiS_Pr, ModeNo);
6231#endif 6046#endif
6232 } else { 6047 } else {
6233#ifdef SIS315H 6048#ifdef SIS315H
6234 SiS_SetCRT2FIFO_310(SiS_Pr, HwInfo); 6049 SiS_SetCRT2FIFO_310(SiS_Pr);
6235#endif 6050#endif
6236 } 6051 }
6237 6052
6238 /* 1. Horizontal setup */ 6053 /* 1. Horizontal setup */
6239 6054
6240 if(HwInfo->jChipType < SIS_315H ) { 6055 if(SiS_Pr->ChipType < SIS_315H ) {
6241 6056
6242#ifdef SIS300 /* ------------- 300 series --------------*/ 6057#ifdef SIS300 /* ------------- 300 series --------------*/
6243 6058
6244 temp = (SiS_Pr->SiS_VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */ 6059 temp = (SiS_Pr->SiS_VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */
6245 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x08,temp); /* CRT2 Horizontal Total */ 6060 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x08,temp); /* CRT2 Horizontal Total */
6246 6061
6247 temp = (((SiS_Pr->SiS_VGAHT - 1) & 0xFF00) >> 8) << 4; 6062 temp = (((SiS_Pr->SiS_VGAHT - 1) & 0xFF00) >> 8) << 4;
6248 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x09,0x0f,temp); /* CRT2 Horizontal Total Overflow [7:4] */ 6063 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x09,0x0f,temp); /* CRT2 Horizontal Total Overflow [7:4] */
6249 6064
6250 temp = (SiS_Pr->SiS_VGAHDE + 12) & 0x0FF; /* BTVGA2HDEE 0x0A,0x0C */ 6065 temp = (SiS_Pr->SiS_VGAHDE + 12) & 0x0FF; /* BTVGA2HDEE 0x0A,0x0C */
6251 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0A,temp); /* CRT2 Horizontal Display Enable End */ 6066 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x0A,temp); /* CRT2 Horizontal Display Enable End */
6252 6067
6253 pushbx = SiS_Pr->SiS_VGAHDE + 12; /* bx BTVGA2HRS 0x0B,0x0C */ 6068 pushbx = SiS_Pr->SiS_VGAHDE + 12; /* bx BTVGA2HRS 0x0B,0x0C */
6254 tempcx = (SiS_Pr->SiS_VGAHT - SiS_Pr->SiS_VGAHDE) >> 2; 6069 tempcx = (SiS_Pr->SiS_VGAHT - SiS_Pr->SiS_VGAHDE) >> 2;
6255 tempbx = pushbx + tempcx; 6070 tempbx = pushbx + tempcx;
6256 tempcx <<= 1; 6071 tempcx <<= 1;
6257 tempcx += tempbx; 6072 tempcx += tempbx;
6258 6073
6259 bridgeadd = 12; 6074 bridgeadd = 12;
6260 6075
@@ -6301,7 +6116,7 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
6301 bridgeadd = 16; 6116 bridgeadd = 16;
6302 6117
6303 if(SiS_Pr->SiS_VBType & VB_SISVB) { 6118 if(SiS_Pr->SiS_VBType & VB_SISVB) {
6304 if(HwInfo->jChipType >= SIS_661) { 6119 if(SiS_Pr->ChipType >= SIS_661) {
6305 if((SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) || 6120 if((SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) ||
6306 (SiS_Pr->SiS_LCDResInfo == Panel_1280x1024)) { 6121 (SiS_Pr->SiS_LCDResInfo == Panel_1280x1024)) {
6307 if(resinfo == SIS_RI_1280x1024) { 6122 if(resinfo == SIS_RI_1280x1024) {
@@ -6319,7 +6134,7 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
6319 6134
6320 if(SiS_Pr->SiS_VBType & VB_SISVB) { 6135 if(SiS_Pr->SiS_VBType & VB_SISVB) {
6321 6136
6322 if(SiS_Pr->UseCustomMode) { 6137 if(SiS_Pr->UseCustomMode) {
6323 tempbx = SiS_Pr->CHSyncStart + bridgeadd; 6138 tempbx = SiS_Pr->CHSyncStart + bridgeadd;
6324 tempcx = SiS_Pr->CHSyncEnd + bridgeadd; 6139 tempcx = SiS_Pr->CHSyncEnd + bridgeadd;
6325 tempax = SiS_Pr->SiS_VGAHT; 6140 tempax = SiS_Pr->SiS_VGAHT;
@@ -6341,22 +6156,22 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
6341 cr5 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[5]; 6156 cr5 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[5];
6342 cr15 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[15]; 6157 cr15 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[15];
6343 } 6158 }
6344 tempbx = ((cr4 | ((cr14 & 0xC0) << 2)) - 3) << 3; /* (VGAHRS-3)*8 */ 6159 tempbx = ((cr4 | ((cr14 & 0xC0) << 2)) - 3) << 3; /* (VGAHRS-3)*8 */
6345 tempcx = (((cr5 & 0x1f) | ((cr15 & 0x04) << (5-2))) - 3) << 3; /* (VGAHRE-3)*8 */ 6160 tempcx = (((cr5 & 0x1f) | ((cr15 & 0x04) << (5-2))) - 3) << 3; /* (VGAHRE-3)*8 */
6346 tempcx &= 0x00FF; 6161 tempcx &= 0x00FF;
6347 tempcx |= (tempbx & 0xFF00); 6162 tempcx |= (tempbx & 0xFF00);
6348 tempbx += bridgeadd; 6163 tempbx += bridgeadd;
6349 tempcx += bridgeadd; 6164 tempcx += bridgeadd;
6350 tempax = SiS_Pr->SiS_VGAHT; 6165 tempax = SiS_Pr->SiS_VGAHT;
6351 if(modeflag & HalfDCLK) tempax >>= 1; 6166 if(modeflag & HalfDCLK) tempax >>= 1;
6352 tempax--; 6167 tempax--;
6353 if(tempcx > tempax) tempcx = tempax; 6168 if(tempcx > tempax) tempcx = tempax;
6354 } 6169 }
6355 6170
6356 if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) { 6171 if(SiS_Pr->SiS_TVMode & (TVSetNTSC1024 | TVSet525p1024)) {
6357 tempbx = 1040; 6172 tempbx = 1040;
6358 tempcx = 1044; /* HWCursor bug! */ 6173 tempcx = 1044; /* HWCursor bug! */
6359 } 6174 }
6360 6175
6361 } 6176 }
6362 6177
@@ -6372,18 +6187,18 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
6372 tempcx = SiS_Pr->SiS_VGAVT - 1; 6187 tempcx = SiS_Pr->SiS_VGAVT - 1;
6373 temp = tempcx & 0x00FF; 6188 temp = tempcx & 0x00FF;
6374 6189
6375 if(HwInfo->jChipType < SIS_661) { 6190 if(SiS_Pr->ChipType < SIS_661) {
6376 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { 6191 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
6377 if(HwInfo->jChipType < SIS_315H) { 6192 if(SiS_Pr->ChipType < SIS_315H) {
6378 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { 6193 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
6379 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToSVIDEO | SetCRT2ToAVIDEO)) { 6194 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToSVIDEO | SetCRT2ToAVIDEO)) {
6380 temp--; 6195 temp--;
6381 } 6196 }
6382 } 6197 }
6383 } else { 6198 } else {
6384 temp--; 6199 temp--;
6385 } 6200 }
6386 } else if(HwInfo->jChipType >= SIS_315H) { 6201 } else if(SiS_Pr->ChipType >= SIS_315H) {
6387 temp--; 6202 temp--;
6388 } 6203 }
6389 } 6204 }
@@ -6395,9 +6210,9 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
6395 temp = ((tempbx >> 5) & 0x38) | ((tempcx >> 8) & 0x07); 6210 temp = ((tempbx >> 5) & 0x38) | ((tempcx >> 8) & 0x07);
6396 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x12,temp); /* Overflow */ 6211 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x12,temp); /* Overflow */
6397 6212
6398 if((HwInfo->jChipType >= SIS_315H) && (HwInfo->jChipType < SIS_661)) { 6213 if((SiS_Pr->ChipType >= SIS_315H) && (SiS_Pr->ChipType < SIS_661)) {
6399 tempbx++; 6214 tempbx++;
6400 tempax = tempbx; 6215 tempax = tempbx;
6401 tempcx++; 6216 tempcx++;
6402 tempcx -= tempax; 6217 tempcx -= tempax;
6403 tempcx >>= 2; 6218 tempcx >>= 2;
@@ -6407,8 +6222,8 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
6407 tempcx += tempbx; 6222 tempcx += tempbx;
6408 tempcx++; 6223 tempcx++;
6409 } else { 6224 } else {
6410 tempbx = (SiS_Pr->SiS_VGAVT + SiS_Pr->SiS_VGAVDE) >> 1; /* BTVGA2VRS 0x10,0x11 */ 6225 tempbx = (SiS_Pr->SiS_VGAVT + SiS_Pr->SiS_VGAVDE) >> 1; /* BTVGA2VRS 0x10,0x11 */
6411 tempcx = ((SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE) >> 4) + tempbx + 1; /* BTVGA2VRE 0x11 */ 6226 tempcx = ((SiS_Pr->SiS_VGAVT - SiS_Pr->SiS_VGAVDE) >> 4) + tempbx + 1; /* BTVGA2VRE 0x11 */
6412 } 6227 }
6413 6228
6414 if(SiS_Pr->SiS_VBType & VB_SISVB) { 6229 if(SiS_Pr->SiS_VBType & VB_SISVB) {
@@ -6416,7 +6231,7 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
6416 tempbx = SiS_Pr->CVSyncStart; 6231 tempbx = SiS_Pr->CVSyncStart;
6417 tempcx = SiS_Pr->CVSyncEnd; 6232 tempcx = SiS_Pr->CVSyncEnd;
6418 } 6233 }
6419 if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { 6234 if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) {
6420 unsigned char cr8, cr7, cr13; 6235 unsigned char cr8, cr7, cr13;
6421 if(SiS_Pr->UseCustomMode) { 6236 if(SiS_Pr->UseCustomMode) {
6422 cr8 = SiS_Pr->CCRT1CRTC[8]; 6237 cr8 = SiS_Pr->CCRT1CRTC[8];
@@ -6429,11 +6244,11 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
6429 cr13 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[13]; 6244 cr13 = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[13];
6430 tempcx = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[9]; 6245 tempcx = SiS_Pr->SiS_CRT1Table[CRT1Index].CR[9];
6431 } 6246 }
6432 tempbx = cr8; 6247 tempbx = cr8;
6433 if(cr7 & 0x04) tempbx |= 0x0100; 6248 if(cr7 & 0x04) tempbx |= 0x0100;
6434 if(cr7 & 0x80) tempbx |= 0x0200; 6249 if(cr7 & 0x80) tempbx |= 0x0200;
6435 if(cr13 & 0x08) tempbx |= 0x0400; 6250 if(cr13 & 0x08) tempbx |= 0x0400;
6436 } 6251 }
6437 } 6252 }
6438 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x10,tempbx); /* CRT2 Vertical Retrace Start */ 6253 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x10,tempbx); /* CRT2 Vertical Retrace Start */
6439 6254
@@ -6442,13 +6257,13 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
6442 6257
6443 /* 3. Panel delay compensation */ 6258 /* 3. Panel delay compensation */
6444 6259
6445 if(HwInfo->jChipType < SIS_315H) { 6260 if(SiS_Pr->ChipType < SIS_315H) {
6446 6261
6447#ifdef SIS300 /* ---------- 300 series -------------- */ 6262#ifdef SIS300 /* ---------- 300 series -------------- */
6448 6263
6449 if(SiS_Pr->SiS_VBType & VB_SISVB) { 6264 if(SiS_Pr->SiS_VBType & VB_SISVB) {
6450 temp = 0x20; 6265 temp = 0x20;
6451 if(HwInfo->jChipType == SIS_300) { 6266 if(SiS_Pr->ChipType == SIS_300) {
6452 temp = 0x10; 6267 temp = 0x10;
6453 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) temp = 0x2c; 6268 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) temp = 0x2c;
6454 if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) temp = 0x20; 6269 if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) temp = 0x20;
@@ -6460,24 +6275,23 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
6460 if(SiS_Pr->SiS_LCDResInfo == Panel_Custom) temp = 0x2c; 6275 if(SiS_Pr->SiS_LCDResInfo == Panel_Custom) temp = 0x2c;
6461 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) temp = 0x08; 6276 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) temp = 0x08;
6462 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { 6277 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {
6463 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) temp = 0x2c; 6278 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) temp = 0x2c;
6464 else temp = 0x20; 6279 else temp = 0x20;
6465 } 6280 }
6466 if(SiS_Pr->SiS_UseROM) { 6281 if(SiS_Pr->SiS_UseROM) {
6467 if(ROMAddr[0x220] & 0x80) { 6282 if(ROMAddr[0x220] & 0x80) {
6468 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoYPbPrHiVision) 6283 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoYPbPrHiVision)
6469 temp = ROMAddr[0x221]; 6284 temp = ROMAddr[0x221];
6470 else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) 6285 else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision)
6471 temp = ROMAddr[0x222]; 6286 temp = ROMAddr[0x222];
6472 else if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) 6287 else if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024)
6473 temp = ROMAddr[0x223]; 6288 temp = ROMAddr[0x223];
6474 else 6289 else
6475 temp = ROMAddr[0x224]; 6290 temp = ROMAddr[0x224];
6476 temp &= 0x3c;
6477 } 6291 }
6478 } 6292 }
6479 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 6293 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
6480 if(SiS_Pr->PDC != -1) temp = SiS_Pr->PDC & 0x3c; 6294 if(SiS_Pr->PDC != -1) temp = SiS_Pr->PDC;
6481 } 6295 }
6482 6296
6483 } else { 6297 } else {
@@ -6487,15 +6301,17 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
6487 } 6301 }
6488 if(SiS_Pr->SiS_UseROM) { 6302 if(SiS_Pr->SiS_UseROM) {
6489 if(ROMAddr[0x220] & 0x80) { 6303 if(ROMAddr[0x220] & 0x80) {
6490 temp = ROMAddr[0x220] & 0x3c; 6304 temp = ROMAddr[0x220];
6491 } 6305 }
6492 } 6306 }
6493 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 6307 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
6494 if(SiS_Pr->PDC != -1) temp = SiS_Pr->PDC & 0x3c; 6308 if(SiS_Pr->PDC != -1) temp = SiS_Pr->PDC;
6495 } 6309 }
6496 } 6310 }
6497 6311
6498 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,~0x3C,temp); /* Panel Link Delay Compensation; (Software Command Reset; Power Saving) */ 6312 temp &= 0x3c;
6313
6314 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x13,~0x3C,temp); /* Panel Link Delay Compensation; (Software Command Reset; Power Saving) */
6499 6315
6500#endif /* SIS300 */ 6316#endif /* SIS300 */
6501 6317
@@ -6503,16 +6319,16 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
6503 6319
6504#ifdef SIS315H /* --------------- 315/330 series ---------------*/ 6320#ifdef SIS315H /* --------------- 315/330 series ---------------*/
6505 6321
6506 if(HwInfo->jChipType < SIS_661) { 6322 if(SiS_Pr->ChipType < SIS_661) {
6507 6323
6508 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { 6324 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
6509 6325
6510 if(HwInfo->jChipType == SIS_740) temp = 0x03; 6326 if(SiS_Pr->ChipType == SIS_740) temp = 0x03;
6511 else temp = 0x00; 6327 else temp = 0x00;
6512 6328
6513 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) temp = 0x0a; 6329 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) temp = 0x0a;
6514 tempbl = 0xF0; 6330 tempbl = 0xF0;
6515 if(HwInfo->jChipType == SIS_650) { 6331 if(SiS_Pr->ChipType == SIS_650) {
6516 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { 6332 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
6517 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) tempbl = 0x0F; 6333 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) tempbl = 0x0F;
6518 } 6334 }
@@ -6531,10 +6347,10 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
6531 6347
6532 } /* < 661 */ 6348 } /* < 661 */
6533 6349
6534 tempax = 0; 6350 tempax = 0;
6535 if(modeflag & DoubleScanMode) tempax |= 0x80; 6351 if(modeflag & DoubleScanMode) tempax |= 0x80;
6536 if(modeflag & HalfDCLK) tempax |= 0x40; 6352 if(modeflag & HalfDCLK) tempax |= 0x40;
6537 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2C,0x3f,tempax); 6353 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2C,0x3f,tempax);
6538 6354
6539#endif /* SIS315H */ 6355#endif /* SIS315H */
6540 6356
@@ -6544,21 +6360,21 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
6544 6360
6545 if(SiS_Pr->SiS_VBType & VB_SISVB) { 6361 if(SiS_Pr->SiS_VBType & VB_SISVB) {
6546 if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { 6362 if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) {
6547 /* For 301BDH with LCD, we set up the Panel Link */ 6363 /* For 301BDH with LCD, we set up the Panel Link */
6548 SiS_SetGroup1_LVDS(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, RefreshRateTableIndex); 6364 SiS_SetGroup1_LVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
6549 } else if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { 6365 } else if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
6550 SiS_SetGroup1_301(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, RefreshRateTableIndex); 6366 SiS_SetGroup1_301(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
6551 } 6367 }
6552 } else { 6368 } else {
6553 if(HwInfo->jChipType < SIS_315H) { 6369 if(SiS_Pr->ChipType < SIS_315H) {
6554 SiS_SetGroup1_LVDS(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, RefreshRateTableIndex); 6370 SiS_SetGroup1_LVDS(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
6555 } else { 6371 } else {
6556 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { 6372 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
6557 if((!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) || (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { 6373 if((!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) || (SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
6558 SiS_SetGroup1_LVDS(SiS_Pr, ModeNo,ModeIdIndex, HwInfo,RefreshRateTableIndex); 6374 SiS_SetGroup1_LVDS(SiS_Pr, ModeNo,ModeIdIndex,RefreshRateTableIndex);
6559 } 6375 }
6560 } else { 6376 } else {
6561 SiS_SetGroup1_LVDS(SiS_Pr, ModeNo,ModeIdIndex, HwInfo,RefreshRateTableIndex); 6377 SiS_SetGroup1_LVDS(SiS_Pr, ModeNo,ModeIdIndex,RefreshRateTableIndex);
6562 } 6378 }
6563 } 6379 }
6564 } 6380 }
@@ -6569,11 +6385,11 @@ SiS_SetGroup1(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
6569/*********************************************/ 6385/*********************************************/
6570 6386
6571#ifdef SIS315H 6387#ifdef SIS315H
6572static UCHAR * 6388static unsigned char *
6573SiS_GetGroup2CLVXPtr(SiS_Private *SiS_Pr, int tabletype, PSIS_HW_INFO HwInfo) 6389SiS_GetGroup2CLVXPtr(struct SiS_Private *SiS_Pr, int tabletype)
6574{ 6390{
6575 const UCHAR *tableptr = NULL; 6391 const unsigned char *tableptr = NULL;
6576 USHORT a, b, p = 0; 6392 unsigned short a, b, p = 0;
6577 6393
6578 a = SiS_Pr->SiS_VGAHDE; 6394 a = SiS_Pr->SiS_VGAHDE;
6579 b = SiS_Pr->SiS_HDE; 6395 b = SiS_Pr->SiS_HDE;
@@ -6606,25 +6422,25 @@ SiS_GetGroup2CLVXPtr(SiS_Private *SiS_Pr, int tabletype, PSIS_HW_INFO HwInfo)
6606 if((tableptr[p] | tableptr[p+1] << 8) == 0xffff) p -= 0x42; 6422 if((tableptr[p] | tableptr[p+1] << 8) == 0xffff) p -= 0x42;
6607 } 6423 }
6608 p += 2; 6424 p += 2;
6609 return((UCHAR *)&tableptr[p]); 6425 return ((unsigned char *)&tableptr[p]);
6610} 6426}
6611 6427
6612static void 6428static void
6613SiS_SetGroup2_C_ELV(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, 6429SiS_SetGroup2_C_ELV(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex,
6614 USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) 6430 unsigned short RefreshRateTableIndex)
6615{ 6431{
6616 UCHAR *tableptr; 6432 unsigned char *tableptr;
6433 unsigned char temp;
6617 int i, j; 6434 int i, j;
6618 UCHAR temp;
6619 6435
6620 if(!(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302ELV))) return; 6436 if(!(SiS_Pr->SiS_VBType & VB_SISTAP4SCALER)) return;
6621 6437
6622 tableptr = SiS_GetGroup2CLVXPtr(SiS_Pr, 0, HwInfo); 6438 tableptr = SiS_GetGroup2CLVXPtr(SiS_Pr, 0);
6623 for(i = 0x80, j = 0; i <= 0xbf; i++, j++) { 6439 for(i = 0x80, j = 0; i <= 0xbf; i++, j++) {
6624 SiS_SetReg(SiS_Pr->SiS_Part2Port, i, tableptr[j]); 6440 SiS_SetReg(SiS_Pr->SiS_Part2Port, i, tableptr[j]);
6625 } 6441 }
6626 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 6442 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
6627 tableptr = SiS_GetGroup2CLVXPtr(SiS_Pr, 1, HwInfo); 6443 tableptr = SiS_GetGroup2CLVXPtr(SiS_Pr, 1);
6628 for(i = 0xc0, j = 0; i <= 0xff; i++, j++) { 6444 for(i = 0xc0, j = 0; i <= 0xff; i++, j++) {
6629 SiS_SetReg(SiS_Pr->SiS_Part2Port, i, tableptr[j]); 6445 SiS_SetReg(SiS_Pr->SiS_Part2Port, i, tableptr[j]);
6630 } 6446 }
@@ -6635,12 +6451,12 @@ SiS_SetGroup2_C_ELV(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
6635} 6451}
6636 6452
6637static BOOLEAN 6453static BOOLEAN
6638SiS_GetCRT2Part2Ptr(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex, 6454SiS_GetCRT2Part2Ptr(struct SiS_Private *SiS_Pr,unsigned short ModeNo,unsigned short ModeIdIndex,
6639 USHORT RefreshRateTableIndex,USHORT *CRT2Index, 6455 unsigned short RefreshRateTableIndex,unsigned short *CRT2Index,
6640 USHORT *ResIndex,PSIS_HW_INFO HwInfo) 6456 unsigned short *ResIndex)
6641{ 6457{
6642 6458
6643 if(HwInfo->jChipType < SIS_315H) return FALSE; 6459 if(SiS_Pr->ChipType < SIS_315H) return FALSE;
6644 6460
6645 if(ModeNo <= 0x13) 6461 if(ModeNo <= 0x13)
6646 (*ResIndex) = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; 6462 (*ResIndex) = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
@@ -6661,82 +6477,79 @@ SiS_GetCRT2Part2Ptr(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex,
6661 if(SiS_Pr->SiS_SetFlag & LCDVESATiming) (*CRT2Index) = 206; 6477 if(SiS_Pr->SiS_SetFlag & LCDVESATiming) (*CRT2Index) = 206;
6662 } 6478 }
6663 } 6479 }
6664 return(((*CRT2Index) != 0)); 6480 return (((*CRT2Index) != 0));
6665} 6481}
6666#endif 6482#endif
6667 6483
6668#ifdef SIS300 6484#ifdef SIS300
6669static void 6485static void
6670SiS_Group2LCDSpecial(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo, USHORT crt2crtc) 6486SiS_Group2LCDSpecial(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short crt2crtc)
6671{ 6487{
6672 USHORT tempcx; 6488 unsigned short tempcx;
6673 const UCHAR atable[] = { 6489 static const unsigned char atable[] = {
6674 0xc3,0x9e,0xc3,0x9e,0x02,0x02,0x02, 6490 0xc3,0x9e,0xc3,0x9e,0x02,0x02,0x02,
6675 0xab,0x87,0xab,0x9e,0xe7,0x02,0x02 6491 0xab,0x87,0xab,0x9e,0xe7,0x02,0x02
6676 }; 6492 };
6677 6493
6678 if(!SiS_Pr->UseCustomMode) { 6494 if(!SiS_Pr->UseCustomMode) {
6679 if( ( ( (HwInfo->jChipType == SIS_630) || 6495 if( ( ( (SiS_Pr->ChipType == SIS_630) ||
6680 (HwInfo->jChipType == SIS_730) ) && 6496 (SiS_Pr->ChipType == SIS_730) ) &&
6681 (HwInfo->jChipRevision > 2) ) && 6497 (SiS_Pr->ChipRevision > 2) ) &&
6682 (SiS_Pr->SiS_LCDResInfo == Panel_1024x768) && 6498 (SiS_Pr->SiS_LCDResInfo == Panel_1024x768) &&
6683 (!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) && 6499 (!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) &&
6684 (!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) ) { 6500 (!(SiS_Pr->SiS_LCDInfo & DontExpandLCD)) ) {
6685 if(ModeNo == 0x13) { 6501 if(ModeNo == 0x13) {
6686 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,0xB9); 6502 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,0xB9);
6687 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x05,0xCC); 6503 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x05,0xCC);
6688 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,0xA6); 6504 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,0xA6);
6689 } else { 6505 } else if((crt2crtc & 0x3F) == 4) {
6690 if((crt2crtc & 0x3F) == 4) { 6506 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x2B);
6691 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x2B); 6507 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x13);
6692 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x13); 6508 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,0xE5);
6693 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,0xE5); 6509 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x05,0x08);
6694 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x05,0x08); 6510 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,0xE2);
6695 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,0xE2); 6511 }
6696 }
6697 }
6698 } 6512 }
6699 6513
6700 if(HwInfo->jChipType < SIS_315H) { 6514 if(SiS_Pr->ChipType < SIS_315H) {
6701 if(SiS_Pr->SiS_LCDTypeInfo == 0x0c) { 6515 if(SiS_Pr->SiS_LCDTypeInfo == 0x0c) {
6702 crt2crtc &= 0x1f; 6516 crt2crtc &= 0x1f;
6703 tempcx = 0; 6517 tempcx = 0;
6704 if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) { 6518 if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) {
6705 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { 6519 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
6706 tempcx += 7; 6520 tempcx += 7;
6707 } 6521 }
6708 } 6522 }
6709 tempcx += crt2crtc; 6523 tempcx += crt2crtc;
6710 if(crt2crtc >= 4) { 6524 if(crt2crtc >= 4) {
6711 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,0xff); 6525 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,0xff);
6712 } 6526 }
6713 6527
6714 if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) { 6528 if(!(SiS_Pr->SiS_VBInfo & SetNotSimuMode)) {
6715 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { 6529 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
6716 if(crt2crtc == 4) { 6530 if(crt2crtc == 4) {
6717 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x28); 6531 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x28);
6718 } 6532 }
6719 } 6533 }
6720 } 6534 }
6721 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x18); 6535 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x18);
6722 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,atable[tempcx]); 6536 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,atable[tempcx]);
6723 } 6537 }
6724 } 6538 }
6725 } 6539 }
6726} 6540}
6727 6541
6728/* For ECS A907. Highly preliminary. */ 6542/* For ECS A907. Highly preliminary. */
6729static void 6543static void
6730SiS_Set300Part2Regs(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, 6544SiS_Set300Part2Regs(struct SiS_Private *SiS_Pr, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex,
6731 USHORT ModeIdIndex, USHORT RefreshRateTableIndex, 6545 unsigned short ModeNo)
6732 USHORT ModeNo)
6733{ 6546{
6734 USHORT crt2crtc, resindex; 6547 const struct SiS_Part2PortTbl *CRT2Part2Ptr = NULL;
6735 int i,j; 6548 unsigned short crt2crtc, resindex;
6736 const SiS_Part2PortTblStruct *CRT2Part2Ptr = NULL; 6549 int i, j;
6737 6550
6738 if(HwInfo->jChipType != SIS_300) return; 6551 if(SiS_Pr->ChipType != SIS_300) return;
6739 if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) return; 6552 if(!(SiS_Pr->SiS_VBType & VB_SIS30xBLV)) return;
6740 if(SiS_Pr->UseCustomMode) return; 6553 if(SiS_Pr->UseCustomMode) return;
6741 6554
6742 if(ModeNo <= 0x13) { 6555 if(ModeNo <= 0x13) {
@@ -6758,13 +6571,13 @@ SiS_Set300Part2Regs(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
6758 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x01,0x80,(CRT2Part2Ptr+resindex)->CR[0]); 6571 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x01,0x80,(CRT2Part2Ptr+resindex)->CR[0]);
6759 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x02,0x80,(CRT2Part2Ptr+resindex)->CR[1]); 6572 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x02,0x80,(CRT2Part2Ptr+resindex)->CR[1]);
6760 for(i = 2, j = 0x04; j <= 0x06; i++, j++ ) { 6573 for(i = 2, j = 0x04; j <= 0x06; i++, j++ ) {
6761 SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]); 6574 SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]);
6762 } 6575 }
6763 for(j = 0x1c; j <= 0x1d; i++, j++ ) { 6576 for(j = 0x1c; j <= 0x1d; i++, j++ ) {
6764 SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]); 6577 SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]);
6765 } 6578 }
6766 for(j = 0x1f; j <= 0x21; i++, j++ ) { 6579 for(j = 0x1f; j <= 0x21; i++, j++ ) {
6767 SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]); 6580 SiS_SetReg(SiS_Pr->SiS_Part2Port,j,(CRT2Part2Ptr+resindex)->CR[i]);
6768 } 6581 }
6769 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x23,(CRT2Part2Ptr+resindex)->CR[10]); 6582 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x23,(CRT2Part2Ptr+resindex)->CR[10]);
6770 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x25,0x0f,(CRT2Part2Ptr+resindex)->CR[11]); 6583 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x25,0x0f,(CRT2Part2Ptr+resindex)->CR[11]);
@@ -6772,15 +6585,15 @@ SiS_Set300Part2Regs(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
6772#endif 6585#endif
6773 6586
6774static void 6587static void
6775SiS_SetTVSpecial(SiS_Private *SiS_Pr, USHORT ModeNo) 6588SiS_SetTVSpecial(struct SiS_Private *SiS_Pr, unsigned short ModeNo)
6776{ 6589{
6777 if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) return; 6590 if(!(SiS_Pr->SiS_VBType & VB_SIS30xBLV)) return;
6778 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoHiVision)) return; 6591 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoHiVision)) return;
6779 if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p)) return; 6592 if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p)) return;
6780 6593
6781 if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { 6594 if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) {
6782 if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) { 6595 if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) {
6783 const UCHAR specialtv[] = { 6596 const unsigned char specialtv[] = {
6784 0xa7,0x07,0xf2,0x6e,0x17,0x8b,0x73,0x53, 6597 0xa7,0x07,0xf2,0x6e,0x17,0x8b,0x73,0x53,
6785 0x13,0x40,0x34,0xf4,0x63,0xbb,0xcc,0x7a, 6598 0x13,0x40,0x34,0xf4,0x63,0xbb,0xcc,0x7a,
6786 0x58,0xe4,0x73,0xda,0x13 6599 0x58,0xe4,0x73,0xda,0x13
@@ -6813,16 +6626,16 @@ SiS_SetTVSpecial(SiS_Private *SiS_Pr, USHORT ModeNo)
6813} 6626}
6814 6627
6815static void 6628static void
6816SiS_SetGroup2_Tail(SiS_Private *SiS_Pr, USHORT ModeNo) 6629SiS_SetGroup2_Tail(struct SiS_Private *SiS_Pr, unsigned short ModeNo)
6817{ 6630{
6818 USHORT temp; 6631 unsigned short temp;
6819 6632
6820 if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) { 6633 if(!(SiS_Pr->SiS_SetFlag & LCDVESATiming)) {
6821 if(SiS_Pr->SiS_VGAVDE == 525) { 6634 if(SiS_Pr->SiS_VGAVDE == 525) {
6822 temp = 0xc3; 6635 temp = 0xc3;
6823 if(SiS_Pr->SiS_ModeType <= ModeVGA) { 6636 if(SiS_Pr->SiS_ModeType <= ModeVGA) {
6824 temp++; 6637 temp++;
6825 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) temp += 2; 6638 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) temp += 2;
6826 } 6639 }
6827 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2f,temp); 6640 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2f,temp);
6828 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x30,0xb3); 6641 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x30,0xb3);
@@ -6830,7 +6643,7 @@ SiS_SetGroup2_Tail(SiS_Private *SiS_Pr, USHORT ModeNo)
6830 temp = 0x4d; 6643 temp = 0x4d;
6831 if(SiS_Pr->SiS_ModeType <= ModeVGA) { 6644 if(SiS_Pr->SiS_ModeType <= ModeVGA) {
6832 temp++; 6645 temp++;
6833 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) temp++; 6646 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) temp++;
6834 } 6647 }
6835 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2f,temp); 6648 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2f,temp);
6836 } 6649 }
@@ -6838,7 +6651,7 @@ SiS_SetGroup2_Tail(SiS_Private *SiS_Pr, USHORT ModeNo)
6838 6651
6839 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 6652 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
6840 if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) { 6653 if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) {
6841 if(SiS_Pr->SiS_VBType & VB_SIS301B302B) { 6654 if(SiS_Pr->SiS_VBType & VB_SIS30xB) {
6842 SiS_SetRegOR(SiS_Pr->SiS_Part2Port,0x1a,0x03); 6655 SiS_SetRegOR(SiS_Pr->SiS_Part2Port,0x1a,0x03);
6843 /* Not always for LV, see SetGrp2 */ 6656 /* Not always for LV, see SetGrp2 */
6844 } 6657 }
@@ -6872,17 +6685,17 @@ SiS_SetGroup2_Tail(SiS_Private *SiS_Pr, USHORT ModeNo)
6872} 6685}
6873 6686
6874static void 6687static void
6875SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT RefreshRateTableIndex, 6688SiS_SetGroup2(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex,
6876 PSIS_HW_INFO HwInfo) 6689 unsigned short RefreshRateTableIndex)
6877{ 6690{
6878 USHORT i, j, tempax, tempbx, tempcx, tempch, tempcl, temp; 6691 unsigned short i, j, tempax, tempbx, tempcx, tempch, tempcl, temp;
6879 USHORT push2, modeflag, crt2crtc, bridgeoffset; 6692 unsigned short push2, modeflag, crt2crtc, bridgeoffset;
6880 ULONG longtemp; 6693 unsigned int longtemp, PhaseIndex;
6881 const UCHAR *PhasePoint; 6694 BOOLEAN newtvphase;
6882 const UCHAR *TimingPoint; 6695 const unsigned char *TimingPoint;
6883#ifdef SIS315H 6696#ifdef SIS315H
6884 USHORT resindex, CRT2Index; 6697 unsigned short resindex, CRT2Index;
6885 const SiS_Part2PortTblStruct *CRT2Part2Ptr = NULL; 6698 const struct SiS_Part2PortTbl *CRT2Part2Ptr = NULL;
6886 6699
6887 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) return; 6700 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) return;
6888#endif 6701#endif
@@ -6908,9 +6721,16 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr
6908 6721
6909 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x00,temp); 6722 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x00,temp);
6910 6723
6911 PhasePoint = SiS_Pr->SiS_PALPhase; 6724 PhaseIndex = 0x01; /* SiS_PALPhase */
6912 TimingPoint = SiS_Pr->SiS_PALTiming; 6725 TimingPoint = SiS_Pr->SiS_PALTiming;
6913 6726
6727 newtvphase = FALSE;
6728 if( (SiS_Pr->SiS_VBType & VB_SIS30xBLV) &&
6729 ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||
6730 (SiS_Pr->SiS_TVMode & TVSetTVSimuMode) ) ) {
6731 newtvphase = TRUE;
6732 }
6733
6914 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { 6734 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {
6915 6735
6916 TimingPoint = SiS_Pr->SiS_HiTVExtTiming; 6736 TimingPoint = SiS_Pr->SiS_HiTVExtTiming;
@@ -6918,82 +6738,54 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr
6918 TimingPoint = SiS_Pr->SiS_HiTVSt2Timing; 6738 TimingPoint = SiS_Pr->SiS_HiTVSt2Timing;
6919 if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { 6739 if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) {
6920 TimingPoint = SiS_Pr->SiS_HiTVSt1Timing; 6740 TimingPoint = SiS_Pr->SiS_HiTVSt1Timing;
6921#if 0
6922 if(!(modeflag & Charx8Dot)) TimingPoint = SiS_Pr->SiS_HiTVTextTiming;
6923#endif
6924 } 6741 }
6925 } 6742 }
6926 6743
6927 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) { 6744 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) {
6928 6745
6929 if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) TimingPoint = &SiS_YPbPrTable[2][0]; 6746 i = 0;
6930 else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) TimingPoint = &SiS_YPbPrTable[1][0]; 6747 if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) i = 2;
6931 else TimingPoint = &SiS_YPbPrTable[0][0]; 6748 else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) i = 1;
6749
6750 TimingPoint = &SiS_YPbPrTable[i][0];
6932 6751
6933 PhasePoint = SiS_Pr->SiS_NTSCPhase; 6752 PhaseIndex = 0x00; /* SiS_NTSCPhase */
6934 6753
6935 } else if(SiS_Pr->SiS_TVMode & TVSetPAL) { 6754 } else if(SiS_Pr->SiS_TVMode & TVSetPAL) {
6936 6755
6937 if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && 6756 if(newtvphase) PhaseIndex = 0x09; /* SiS_PALPhase2 */
6938 ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||
6939 (SiS_Pr->SiS_TVMode & TVSetTVSimuMode) ) ) {
6940 PhasePoint = SiS_Pr->SiS_PALPhase2;
6941 }
6942 6757
6943 } else { 6758 } else {
6944 6759
6945 TimingPoint = SiS_Pr->SiS_NTSCTiming; 6760 TimingPoint = SiS_Pr->SiS_NTSCTiming;
6946 PhasePoint = SiS_Pr->SiS_NTSCPhase; 6761 PhaseIndex = (SiS_Pr->SiS_TVMode & TVSetNTSCJ) ? 0x01 : 0x00; /* SiS_PALPhase : SiS_NTSCPhase */
6947 if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) { 6762 if(newtvphase) PhaseIndex += 8; /* SiS_PALPhase2 : SiS_NTSCPhase2 */
6948 PhasePoint = SiS_Pr->SiS_PALPhase;
6949 }
6950
6951 if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) &&
6952 ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||
6953 (SiS_Pr->SiS_TVMode & TVSetTVSimuMode) ) ) {
6954 PhasePoint = SiS_Pr->SiS_NTSCPhase2;
6955 if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) {
6956 PhasePoint = SiS_Pr->SiS_PALPhase2;
6957 }
6958 }
6959
6960 }
6961 6763
6962 if(SiS_Pr->SiS_TVMode & TVSetPALM) {
6963 PhasePoint = SiS_Pr->SiS_PALMPhase;
6964 if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) &&
6965 ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||
6966 (SiS_Pr->SiS_TVMode & TVSetTVSimuMode) ) ) {
6967 PhasePoint = SiS_Pr->SiS_PALMPhase2;
6968 }
6969 } 6764 }
6970 6765
6971 if(SiS_Pr->SiS_TVMode & TVSetPALN) { 6766 if(SiS_Pr->SiS_TVMode & (TVSetPALM | TVSetPALN)) {
6972 PhasePoint = SiS_Pr->SiS_PALNPhase; 6767 PhaseIndex = (SiS_Pr->SiS_TVMode & TVSetPALM) ? 0x02 : 0x03; /* SiS_PALMPhase : SiS_PALNPhase */
6973 if( (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && 6768 if(newtvphase) PhaseIndex += 8; /* SiS_PALMPhase2 : SiS_PALNPhase2 */
6974 ( (!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||
6975 (SiS_Pr->SiS_TVMode & TVSetTVSimuMode) ) ) {
6976 PhasePoint = SiS_Pr->SiS_PALNPhase2;
6977 }
6978 } 6769 }
6979 6770
6980 if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) { 6771 if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) {
6981 PhasePoint = SiS_Pr->SiS_SpecialPhase;
6982 if(SiS_Pr->SiS_TVMode & TVSetPALM) { 6772 if(SiS_Pr->SiS_TVMode & TVSetPALM) {
6983 PhasePoint = SiS_Pr->SiS_SpecialPhaseM; 6773 PhaseIndex = 0x05; /* SiS_SpecialPhaseM */
6984 } else if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) { 6774 } else if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) {
6985 PhasePoint = SiS_Pr->SiS_SpecialPhaseJ; 6775 PhaseIndex = 0x11; /* SiS_SpecialPhaseJ */
6776 } else {
6777 PhaseIndex = 0x10; /* SiS_SpecialPhase */
6986 } 6778 }
6987 } 6779 }
6988 6780
6989 for(i=0x31, j=0; i<=0x34; i++, j++) { 6781 for(i = 0x31, j = 0; i <= 0x34; i++, j++) {
6990 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,PhasePoint[j]); 6782 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS_TVPhase[(PhaseIndex * 4) + j]);
6991 } 6783 }
6992 6784
6993 for(i=0x01, j=0; i<=0x2D; i++, j++) { 6785 for(i = 0x01, j = 0; i <= 0x2D; i++, j++) {
6994 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,TimingPoint[j]); 6786 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,TimingPoint[j]);
6995 } 6787 }
6996 for(i=0x39; i<=0x45; i++, j++) { 6788 for(i = 0x39; i <= 0x45; i++, j++) {
6997 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,TimingPoint[j]); 6789 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,TimingPoint[j]);
6998 } 6790 }
6999 6791
@@ -7010,28 +6802,32 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr
7010 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x37,SiS_Pr->SiS_RY3COE); 6802 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x37,SiS_Pr->SiS_RY3COE);
7011 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x38,SiS_Pr->SiS_RY4COE); 6803 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x38,SiS_Pr->SiS_RY4COE);
7012 6804
7013 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) tempax = 950; 6805 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) tempax = 950;
7014 else if(SiS_Pr->SiS_TVMode & TVSetPAL) tempax = 520; 6806 else if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) tempax = 680;
7015 else tempax = 440; /* NTSC, YPbPr 525, 750 */ 6807 else if(SiS_Pr->SiS_TVMode & TVSetPAL) tempax = 520;
6808 else tempax = 440; /* NTSC, YPbPr 525 */
7016 6809
7017 if( ( (!(SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoHiVision)) && (SiS_Pr->SiS_VDE <= tempax) ) || 6810 if( ((SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) && (SiS_Pr->SiS_VDE <= tempax)) ||
7018 ( (SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoHiVision) && 6811 ( (SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoHiVision) &&
7019 ((SiS_Pr->SiS_VGAHDE == 1024) || (SiS_Pr->SiS_VDE <= tempax)) ) ) { 6812 ((SiS_Pr->SiS_VGAHDE == 1024) || (SiS_Pr->SiS_VDE <= tempax)) ) ) {
7020 6813
7021 tempax -= SiS_Pr->SiS_VDE; 6814 tempax -= SiS_Pr->SiS_VDE;
7022 tempax >>= 2; 6815 tempax >>= 1;
6816 if(!(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p))) {
6817 tempax >>= 1;
6818 }
7023 tempax &= 0x00ff; 6819 tempax &= 0x00ff;
7024 6820
7025 temp = tempax + (USHORT)TimingPoint[0]; 6821 temp = tempax + (unsigned short)TimingPoint[0];
7026 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,temp); 6822 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,temp);
7027 6823
7028 temp = tempax + (USHORT)TimingPoint[1]; 6824 temp = tempax + (unsigned short)TimingPoint[1];
7029 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,temp); 6825 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,temp);
7030 6826
7031 if((SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoYPbPrHiVision) && (SiS_Pr->SiS_VGAHDE >= 1024)) { 6827 if((SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoYPbPrHiVision) && (SiS_Pr->SiS_VGAHDE >= 1024)) {
7032 if(SiS_Pr->SiS_TVMode & TVSetPAL) { 6828 if(SiS_Pr->SiS_TVMode & TVSetPAL) {
7033 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x1b); /* 19 */ 6829 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x1b);
7034 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x54); /* 52 */ 6830 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x54);
7035 } else { 6831 } else {
7036 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x17); 6832 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,0x17);
7037 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x1d); 6833 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x02,0x1d);
@@ -7041,14 +6837,14 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr
7041 } 6837 }
7042 6838
7043 tempcx = SiS_Pr->SiS_HT; 6839 tempcx = SiS_Pr->SiS_HT;
7044 if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempcx >>= 1; 6840 if(SiS_IsDualLink(SiS_Pr)) tempcx >>= 1;
7045 tempcx--; 6841 tempcx--;
7046 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) tempcx--; 6842 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) tempcx--;
7047 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1B,tempcx); 6843 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1B,tempcx);
7048 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1D,0xF0,((tempcx >> 8) & 0x0f)); 6844 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1D,0xF0,((tempcx >> 8) & 0x0f));
7049 6845
7050 tempcx = SiS_Pr->SiS_HT >> 1; 6846 tempcx = SiS_Pr->SiS_HT >> 1;
7051 if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempcx >>= 1; 6847 if(SiS_IsDualLink(SiS_Pr)) tempcx >>= 1;
7052 tempcx += 7; 6848 tempcx += 7;
7053 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) tempcx -= 4; 6849 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) tempcx -= 4;
7054 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x22,0x0F,((tempcx << 4) & 0xf0)); 6850 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x22,0x0F,((tempcx << 4) & 0xf0));
@@ -7075,7 +6871,7 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr
7075 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2A,0x0F,((tempcx << 4) & 0xf0)); 6871 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2A,0x0F,((tempcx << 4) & 0xf0));
7076 6872
7077 tempcx = SiS_Pr->SiS_HT >> 1; 6873 tempcx = SiS_Pr->SiS_HT >> 1;
7078 if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempcx >>= 1; 6874 if(SiS_IsDualLink(SiS_Pr)) tempcx >>= 1;
7079 j += 2; 6875 j += 2;
7080 tempcx -= (TimingPoint[j] | ((TimingPoint[j+1]) << 8)); 6876 tempcx -= (TimingPoint[j] | ((TimingPoint[j+1]) << 8));
7081 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2D,0x0F,((tempcx << 4) & 0xf0)); 6877 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2D,0x0F,((tempcx << 4) & 0xf0));
@@ -7094,7 +6890,7 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr
7094 } else if( (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && 6890 } else if( (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) &&
7095 (!(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p|TVSetYPbPr750p))) ) { 6891 (!(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p|TVSetYPbPr750p))) ) {
7096 tempbx >>= 1; 6892 tempbx >>= 1;
7097 if(HwInfo->jChipType >= SIS_315H) { 6893 if(SiS_Pr->ChipType >= SIS_315H) {
7098 if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) { 6894 if(SiS_Pr->SiS_TVMode & TVSetTVSimuMode) {
7099 if((ModeNo <= 0x13) && (crt2crtc == 1)) tempbx++; 6895 if((ModeNo <= 0x13) && (crt2crtc == 1)) tempbx++;
7100 } else if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { 6896 } else if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
@@ -7123,23 +6919,11 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr
7123 } 6919 }
7124 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x30,temp); 6920 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x30,temp);
7125 6921
7126 if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302LV | VB_SIS302ELV)) { 6922 if(SiS_Pr->SiS_VBType & VB_SISPART4OVERFLOW) {
7127 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x10,0xdf,((tempbx & 0x0400) >> 5)); 6923 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x10,0xdf,((tempbx & 0x0400) >> 5));
7128 } 6924 }
7129 6925
7130#if 0 6926 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) {
7131 /* TEST qqqq */
7132 if(SiS_Pr->SiS_VBInfo & SetCRT2ToYPbPr525750) {
7133 for(i=0x01, j=0; i<=0x2D; i++, j++) {
7134 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,TimingPoint[j]);
7135 }
7136 for(i=0x39; i<=0x45; i++, j++) {
7137 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,TimingPoint[j]);
7138 }
7139 }
7140#endif
7141
7142 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) {
7143 tempbx = SiS_Pr->SiS_VDE; 6927 tempbx = SiS_Pr->SiS_VDE;
7144 if( (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) && 6928 if( (SiS_Pr->SiS_VBInfo & SetCRT2ToTV) &&
7145 (!(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p))) ) { 6929 (!(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p))) ) {
@@ -7150,7 +6934,7 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr
7150 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x46,temp); 6934 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x46,temp);
7151 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x47,tempbx); 6935 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x47,tempbx);
7152 6936
7153 if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302LV | VB_SIS302ELV)) { 6937 if(SiS_Pr->SiS_VBType & VB_SISPART4OVERFLOW) {
7154 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x10,0xbf,((tempbx & 0x0400) >> 4)); 6938 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x10,0xbf,((tempbx & 0x0400) >> 4));
7155 } 6939 }
7156 } 6940 }
@@ -7165,14 +6949,17 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr
7165 6949
7166 tempch = tempcl = 0x01; 6950 tempch = tempcl = 0x01;
7167 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 6951 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
7168 if(SiS_Pr->SiS_VGAHDE >= 1024) { 6952 if(SiS_Pr->SiS_VGAHDE >= 960) {
7169 if((!(modeflag & HalfDCLK)) || (HwInfo->jChipType < SIS_315H)) { 6953 if((!(modeflag & HalfDCLK)) || (SiS_Pr->ChipType < SIS_315H)) {
7170 tempch = 0x19;
7171 tempcl = 0x20; 6954 tempcl = 0x20;
7172 if(SiS_Pr->SiS_VGAHDE >= 1280) { 6955 if(SiS_Pr->SiS_VGAHDE >= 1280) {
7173 tempch = 0x14; 6956 tempch = 20;
7174 tempbx &= ~0x20; 6957 tempbx &= ~0x20;
7175 } 6958 } else if(SiS_Pr->SiS_VGAHDE >= 1024) {
6959 tempch = 25;
6960 } else {
6961 tempch = 25; /* OK */
6962 }
7176 } 6963 }
7177 } 6964 }
7178 } 6965 }
@@ -7180,7 +6967,7 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr
7180 if(!(tempbx & 0x20)) { 6967 if(!(tempbx & 0x20)) {
7181 if(modeflag & HalfDCLK) tempcl <<= 1; 6968 if(modeflag & HalfDCLK) tempcl <<= 1;
7182 longtemp = ((SiS_Pr->SiS_VGAHDE * tempch) / tempcl) << 13; 6969 longtemp = ((SiS_Pr->SiS_VGAHDE * tempch) / tempcl) << 13;
7183 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) longtemp <<= 3; 6970 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) longtemp <<= 3;
7184 tempax = longtemp / SiS_Pr->SiS_HDE; 6971 tempax = longtemp / SiS_Pr->SiS_HDE;
7185 if(longtemp % SiS_Pr->SiS_HDE) tempax++; 6972 if(longtemp % SiS_Pr->SiS_HDE) tempax++;
7186 tempbx |= ((tempax >> 8) & 0x1F); 6973 tempbx |= ((tempax >> 8) & 0x1F);
@@ -7190,7 +6977,7 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr
7190 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x44,tempax); 6977 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x44,tempax);
7191 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x45,0xC0,tempbx); 6978 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x45,0xC0,tempbx);
7192 6979
7193 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { 6980 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) {
7194 6981
7195 tempcx &= 0x07; 6982 tempcx &= 0x07;
7196 if(tempbx & 0x20) tempcx = 0; 6983 if(tempbx & 0x20) tempcx = 0;
@@ -7219,7 +7006,7 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr
7219 7006
7220 SiS_SetTVSpecial(SiS_Pr, ModeNo); 7007 SiS_SetTVSpecial(SiS_Pr, ModeNo);
7221 7008
7222 if(SiS_Pr->SiS_VBType & VB_SIS301C) { 7009 if(SiS_Pr->SiS_VBType & VB_SIS30xCLV) {
7223 temp = 0; 7010 temp = 0;
7224 if(SiS_Pr->SiS_TVMode & TVSetPALM) temp = 8; 7011 if(SiS_Pr->SiS_TVMode & TVSetPALM) temp = 8;
7225 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x4e,0xf7,temp); 7012 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x4e,0xf7,temp);
@@ -7246,7 +7033,7 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr
7246 /* From here: Part2 LCD setup */ 7033 /* From here: Part2 LCD setup */
7247 7034
7248 tempbx = SiS_Pr->SiS_HDE; 7035 tempbx = SiS_Pr->SiS_HDE;
7249 if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempbx >>= 1; 7036 if(SiS_IsDualLink(SiS_Pr)) tempbx >>= 1;
7250 tempbx--; /* RHACTE = HDE - 1 */ 7037 tempbx--; /* RHACTE = HDE - 1 */
7251 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2C,tempbx); 7038 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x2C,tempbx);
7252 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2B,0x0F,((tempbx >> 4) & 0xf0)); 7039 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2B,0x0F,((tempbx >> 4) & 0xf0));
@@ -7256,10 +7043,8 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr
7256 if(SiS_Pr->SiS_ModeType == ModeEGA) { 7043 if(SiS_Pr->SiS_ModeType == ModeEGA) {
7257 if(SiS_Pr->SiS_VGAHDE >= 1024) { 7044 if(SiS_Pr->SiS_VGAHDE >= 1024) {
7258 temp = 0x02; 7045 temp = 0x02;
7259 if(HwInfo->jChipType >= SIS_315H) { 7046 if(SiS_Pr->SiS_SetFlag & LCDVESATiming) {
7260 if(SiS_Pr->SiS_SetFlag & LCDVESATiming) { 7047 temp = 0x01;
7261 temp = 0x01;
7262 }
7263 } 7048 }
7264 } 7049 }
7265 } 7050 }
@@ -7289,11 +7074,11 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr
7289 7074
7290#ifdef SIS315H 7075#ifdef SIS315H
7291 if(SiS_GetCRT2Part2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, 7076 if(SiS_GetCRT2Part2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex,
7292 &CRT2Index, &resindex, HwInfo)) { 7077 &CRT2Index, &resindex)) {
7293 switch(CRT2Index) { 7078 switch(CRT2Index) {
7079 case 206: CRT2Part2Ptr = SiS310_CRT2Part2_Asus1024x768_3; break;
7080 default:
7294 case 200: CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_1; break; 7081 case 200: CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_1; break;
7295 case 206: CRT2Part2Ptr = SiS310_CRT2Part2_Asus1024x768_3; break;
7296 default: CRT2Part2Ptr = SiS_Pr->SiS_CRT2Part2_1024x768_3; break;
7297 } 7082 }
7298 7083
7299 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x01,0x80,(CRT2Part2Ptr+resindex)->CR[0]); 7084 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x01,0x80,(CRT2Part2Ptr+resindex)->CR[0]);
@@ -7312,7 +7097,6 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr
7312 7097
7313 SiS_SetGroup2_Tail(SiS_Pr, ModeNo); 7098 SiS_SetGroup2_Tail(SiS_Pr, ModeNo);
7314 7099
7315
7316 } else { 7100 } else {
7317#endif 7101#endif
7318 7102
@@ -7349,9 +7133,11 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr
7349 7133
7350 /* Non-expanding: lcdvdes = tempcx = VT-1; lcdvdee = tempbx = VDE-1 */ 7134 /* Non-expanding: lcdvdes = tempcx = VT-1; lcdvdee = tempbx = VDE-1 */
7351 7135
7136#ifdef SIS_XORG_XF86
7352#ifdef TWDEBUG 7137#ifdef TWDEBUG
7353 xf86DrvMsg(0, X_INFO, "lcdvdes 0x%x lcdvdee 0x%x\n", tempcx, tempbx); 7138 xf86DrvMsg(0, X_INFO, "lcdvdes 0x%x lcdvdee 0x%x\n", tempcx, tempbx);
7354#endif 7139#endif
7140#endif
7355 7141
7356 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x05,tempcx); /* lcdvdes */ 7142 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x05,tempcx); /* lcdvdes */
7357 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,tempbx); /* lcdvdee */ 7143 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x06,tempbx); /* lcdvdee */
@@ -7401,9 +7187,11 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr
7401 tempbx = SiS_Pr->CVSyncStart; 7187 tempbx = SiS_Pr->CVSyncStart;
7402 } 7188 }
7403 7189
7190#ifdef SIS_XORG_XF86
7404#ifdef TWDEBUG 7191#ifdef TWDEBUG
7405 xf86DrvMsg(0, X_INFO, "lcdvrs 0x%x\n", tempbx); 7192 xf86DrvMsg(0, X_INFO, "lcdvrs 0x%x\n", tempbx);
7406#endif 7193#endif
7194#endif
7407 7195
7408 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,tempbx); /* lcdvrs */ 7196 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x04,tempbx); /* lcdvrs */
7409 7197
@@ -7416,26 +7204,30 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr
7416 temp |= (SiS_Pr->CVSyncEnd & 0x0f); 7204 temp |= (SiS_Pr->CVSyncEnd & 0x0f);
7417 } 7205 }
7418 7206
7207#ifdef SIS_XORG_XF86
7419#ifdef TWDEBUG 7208#ifdef TWDEBUG
7420 xf86DrvMsg(0, X_INFO, "lcdvre[3:0] 0x%x\n", (temp & 0x0f)); 7209 xf86DrvMsg(0, X_INFO, "lcdvre[3:0] 0x%x\n", (temp & 0x0f));
7421#endif 7210#endif
7211#endif
7422 7212
7423 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,temp); 7213 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x01,temp);
7424 7214
7425#ifdef SIS300 7215#ifdef SIS300
7426 SiS_Group2LCDSpecial(SiS_Pr, HwInfo, ModeNo, crt2crtc); 7216 SiS_Group2LCDSpecial(SiS_Pr, ModeNo, crt2crtc);
7427#endif 7217#endif
7428 7218
7429 bridgeoffset = 7; 7219 bridgeoffset = 7;
7430 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) bridgeoffset += 2; 7220 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) bridgeoffset += 2;
7431 if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302ELV)) bridgeoffset++; 7221 if(SiS_Pr->SiS_VBType & VB_SIS30xCLV) bridgeoffset += 2; /* OK for Averatec 1280x800 (301C) */
7432 if(SiS_IsDualLink(SiS_Pr, HwInfo)) bridgeoffset++; 7222 if(SiS_IsDualLink(SiS_Pr)) bridgeoffset++;
7223 else if(SiS_Pr->SiS_VBType & VB_SIS302LV) bridgeoffset++; /* OK for Asus A4L 1280x800 */
7224 /* Higher bridgeoffset shifts to the LEFT */
7433 7225
7434 temp = 0; 7226 temp = 0;
7435 if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) { 7227 if((SiS_Pr->SiS_LCDInfo & DontExpandLCD) && (!(SiS_Pr->SiS_LCDInfo & LCDPass11))) {
7436 if(SiS_Pr->PanelXRes != SiS_Pr->SiS_HDE) { 7228 if(SiS_Pr->PanelXRes != SiS_Pr->SiS_HDE) {
7437 temp = SiS_Pr->SiS_HT - ((SiS_Pr->PanelXRes - SiS_Pr->SiS_HDE) / 2); 7229 temp = SiS_Pr->SiS_HT - ((SiS_Pr->PanelXRes - SiS_Pr->SiS_HDE) / 2);
7438 if(SiS_IsDualLink(SiS_Pr, HwInfo)) temp >>= 1; 7230 if(SiS_IsDualLink(SiS_Pr)) temp >>= 1;
7439 } 7231 }
7440 } 7232 }
7441 temp += bridgeoffset; 7233 temp += bridgeoffset;
@@ -7450,15 +7242,17 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr
7450 tempbx = SiS_Pr->PanelXRes - ((SiS_Pr->PanelXRes - SiS_Pr->SiS_HDE) / 2); 7242 tempbx = SiS_Pr->PanelXRes - ((SiS_Pr->PanelXRes - SiS_Pr->SiS_HDE) / 2);
7451 } 7243 }
7452 } 7244 }
7453 if(SiS_IsDualLink(SiS_Pr, HwInfo)) { 7245 if(SiS_IsDualLink(SiS_Pr)) {
7454 tempcx >>= 1; 7246 tempcx >>= 1;
7455 tempbx >>= 1; 7247 tempbx >>= 1;
7456 tempax >>= 1; 7248 tempax >>= 1;
7457 } 7249 }
7458 7250
7251#ifdef SIS_XORG_XF86
7459#ifdef TWDEBUG 7252#ifdef TWDEBUG
7460 xf86DrvMsg(0, X_INFO, "lcdhdee 0x%x\n", tempbx); 7253 xf86DrvMsg(0, X_INFO, "lcdhdee 0x%x\n", tempbx);
7461#endif 7254#endif
7255#endif
7462 7256
7463 tempbx += bridgeoffset; 7257 tempbx += bridgeoffset;
7464 7258
@@ -7480,13 +7274,16 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr
7480 7274
7481 if(SiS_Pr->UseCustomMode) { 7275 if(SiS_Pr->UseCustomMode) {
7482 tempbx = SiS_Pr->CHSyncStart; 7276 tempbx = SiS_Pr->CHSyncStart;
7483 if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempbx >>= 1; 7277 if(modeflag & HalfDCLK) tempbx <<= 1;
7278 if(SiS_IsDualLink(SiS_Pr)) tempbx >>= 1;
7484 tempbx += bridgeoffset; 7279 tempbx += bridgeoffset;
7485 } 7280 }
7486 7281
7282#ifdef SIS_XORG_XF86
7487#ifdef TWDEBUG 7283#ifdef TWDEBUG
7488 xf86DrvMsg(0, X_INFO, "lcdhrs 0x%x\n", tempbx); 7284 xf86DrvMsg(0, X_INFO, "lcdhrs 0x%x\n", tempbx);
7489#endif 7285#endif
7286#endif
7490 7287
7491 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1C,tempbx); /* lcdhrs */ 7288 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1C,tempbx); /* lcdhrs */
7492 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1D,0x0F,((tempbx >> 4) & 0xf0)); 7289 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x1D,0x0F,((tempbx >> 4) & 0xf0));
@@ -7501,20 +7298,23 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr
7501 7298
7502 if(SiS_Pr->UseCustomMode) { 7299 if(SiS_Pr->UseCustomMode) {
7503 tempbx = SiS_Pr->CHSyncEnd; 7300 tempbx = SiS_Pr->CHSyncEnd;
7504 if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempbx >>= 1; 7301 if(modeflag & HalfDCLK) tempbx <<= 1;
7302 if(SiS_IsDualLink(SiS_Pr)) tempbx >>= 1;
7505 tempbx += bridgeoffset; 7303 tempbx += bridgeoffset;
7506 } 7304 }
7507 7305
7306#ifdef SIS_XORG_XF86
7508#ifdef TWDEBUG 7307#ifdef TWDEBUG
7509 xf86DrvMsg(0, X_INFO, "lcdhre 0x%x\n", tempbx); 7308 xf86DrvMsg(0, X_INFO, "lcdhre 0x%x\n", tempbx);
7510#endif 7309#endif
7310#endif
7511 7311
7512 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x21,tempbx); /* lcdhre */ 7312 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x21,tempbx); /* lcdhre */
7513 7313
7514 SiS_SetGroup2_Tail(SiS_Pr, ModeNo); 7314 SiS_SetGroup2_Tail(SiS_Pr, ModeNo);
7515 7315
7516#ifdef SIS300 7316#ifdef SIS300
7517 SiS_Set300Part2Regs(SiS_Pr, HwInfo, ModeIdIndex, RefreshRateTableIndex, ModeNo); 7317 SiS_Set300Part2Regs(SiS_Pr, ModeIdIndex, RefreshRateTableIndex, ModeNo);
7518#endif 7318#endif
7519#ifdef SIS315H 7319#ifdef SIS315H
7520 } /* CRT2-LCD from table */ 7320 } /* CRT2-LCD from table */
@@ -7526,11 +7326,10 @@ SiS_SetGroup2(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,USHORT Refr
7526/*********************************************/ 7326/*********************************************/
7527 7327
7528static void 7328static void
7529SiS_SetGroup3(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, 7329SiS_SetGroup3(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex)
7530 PSIS_HW_INFO HwInfo)
7531{ 7330{
7532 USHORT i; 7331 unsigned short i;
7533 const UCHAR *tempdi; 7332 const unsigned char *tempdi;
7534 7333
7535 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) return; 7334 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) return;
7536 7335
@@ -7570,7 +7369,7 @@ SiS_SetGroup3(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
7570 for(i=0; i<=0x3E; i++) { 7369 for(i=0; i<=0x3E; i++) {
7571 SiS_SetReg(SiS_Pr->SiS_Part3Port,i,tempdi[i]); 7370 SiS_SetReg(SiS_Pr->SiS_Part3Port,i,tempdi[i]);
7572 } 7371 }
7573 if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302ELV)) { 7372 if(SiS_Pr->SiS_VBType & VB_SIS30xCLV) {
7574 if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) { 7373 if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) {
7575 SiS_SetReg(SiS_Pr->SiS_Part3Port,0x28,0x3f); 7374 SiS_SetReg(SiS_Pr->SiS_Part3Port,0x28,0x3f);
7576 } 7375 }
@@ -7587,35 +7386,43 @@ SiS_SetGroup3(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
7587/*********************************************/ 7386/*********************************************/
7588 7387
7589#ifdef SIS315H 7388#ifdef SIS315H
7389#if 0
7590static void 7390static void
7591SiS_ShiftXPos(SiS_Private *SiS_Pr, int shift) 7391SiS_ShiftXPos(struct SiS_Private *SiS_Pr, int shift)
7592{ 7392{
7593 USHORT temp, temp1, temp2; 7393 unsigned short temp, temp1, temp2;
7594 7394
7595 temp1 = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x1f); 7395 temp1 = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x1f);
7596 temp2 = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x20); 7396 temp2 = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x20);
7597 temp = (USHORT)((int)((temp1 | ((temp2 & 0xf0) << 4))) + shift); 7397 temp = (unsigned short)((int)((temp1 | ((temp2 & 0xf0) << 4))) + shift);
7598 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1f,temp); 7398 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x1f,temp);
7599 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x20,0x0f,((temp >> 4) & 0xf0)); 7399 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x20,0x0f,((temp >> 4) & 0xf0));
7600 temp = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x2b) & 0x0f; 7400 temp = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x2b) & 0x0f;
7601 temp = (USHORT)((int)(temp) + shift); 7401 temp = (unsigned short)((int)(temp) + shift);
7602 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2b,0xf0,(temp & 0x0f)); 7402 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x2b,0xf0,(temp & 0x0f));
7603 temp1 = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x43); 7403 temp1 = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x43);
7604 temp2 = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x42); 7404 temp2 = SiS_GetReg(SiS_Pr->SiS_Part2Port,0x42);
7605 temp = (USHORT)((int)((temp1 | ((temp2 & 0xf0) << 4))) + shift); 7405 temp = (unsigned short)((int)((temp1 | ((temp2 & 0xf0) << 4))) + shift);
7606 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x43,temp); 7406 SiS_SetReg(SiS_Pr->SiS_Part2Port,0x43,temp);
7607 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x42,0x0f,((temp >> 4) & 0xf0)); 7407 SiS_SetRegANDOR(SiS_Pr->SiS_Part2Port,0x42,0x0f,((temp >> 4) & 0xf0));
7608} 7408}
7409#endif
7609 7410
7610static void 7411static void
7611SiS_SetGroup4_C_ELV(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, 7412SiS_SetGroup4_C_ELV(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex)
7612 USHORT ModeNo, USHORT ModeIdIndex)
7613{ 7413{
7614 USHORT temp, temp1, resinfo = 0; 7414 unsigned short temp, temp1, resinfo = 0;
7415 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
7615 7416
7616 if(!(SiS_Pr->SiS_VBType & VB_SIS301C)) return; 7417 if(!(SiS_Pr->SiS_VBType & VB_SIS30xCLV)) return;
7617 if(!(SiS_Pr->SiS_VBInfo & (SetCRT2ToHiVision | SetCRT2ToYPbPr525750))) return; 7418 if(!(SiS_Pr->SiS_VBInfo & (SetCRT2ToHiVision | SetCRT2ToYPbPr525750))) return;
7618 7419
7420 if(SiS_Pr->ChipType >= XGI_20) return;
7421
7422 if((SiS_Pr->ChipType >= SIS_661) && (SiS_Pr->SiS_ROMNew)) {
7423 if(!(ROMAddr[0x61] & 0x04)) return;
7424 }
7425
7619 if(ModeNo > 0x13) { 7426 if(ModeNo > 0x13) {
7620 resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; 7427 resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
7621 } 7428 }
@@ -7625,7 +7432,7 @@ SiS_SetGroup4_C_ELV(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
7625 if(!(temp & 0x01)) { 7432 if(!(temp & 0x01)) {
7626 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x3a,0xdf); 7433 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x3a,0xdf);
7627 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x25,0xfc); 7434 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x25,0xfc);
7628 if((HwInfo->jChipType < SIS_661) && (!(SiS_Pr->SiS_ROMNew))) { 7435 if((SiS_Pr->ChipType < SIS_661) && (!(SiS_Pr->SiS_ROMNew))) {
7629 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x25,0xf8); 7436 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x25,0xf8);
7630 } 7437 }
7631 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x0f,0xfb); 7438 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x0f,0xfb);
@@ -7633,24 +7440,29 @@ SiS_SetGroup4_C_ELV(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
7633 else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) temp = 0x0002; 7440 else if(SiS_Pr->SiS_TVMode & TVSetYPbPr525p) temp = 0x0002;
7634 else if(SiS_Pr->SiS_TVMode & TVSetHiVision) temp = 0x0400; 7441 else if(SiS_Pr->SiS_TVMode & TVSetHiVision) temp = 0x0400;
7635 else temp = 0x0402; 7442 else temp = 0x0402;
7636 if((HwInfo->jChipType >= SIS_661) || (SiS_Pr->SiS_ROMNew)) { 7443 if((SiS_Pr->ChipType >= SIS_661) || (SiS_Pr->SiS_ROMNew)) {
7637 temp1 = 0; 7444 temp1 = 0;
7638 if(SiS_Pr->SiS_TVMode & TVAspect43) temp1 = 4; 7445 if(SiS_Pr->SiS_TVMode & TVAspect43) temp1 = 4;
7639 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0f,0xfb,temp1); 7446 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0f,0xfb,temp1);
7640 if(SiS_Pr->SiS_TVMode & TVAspect43LB) temp |= 0x01; 7447 if(SiS_Pr->SiS_TVMode & TVAspect43LB) temp |= 0x01;
7641 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0x7c,(temp & 0xff)); 7448 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0x7c,(temp & 0xff));
7449 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x3a,0xfb,(temp >> 8));
7450 if(ModeNo > 0x13) {
7451 SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x39,0xfd);
7452 }
7642 } else { 7453 } else {
7643 temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x3b) & 0x03; 7454 temp1 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x3b) & 0x03;
7644 if(temp1 == 0x01) temp |= 0x01; 7455 if(temp1 == 0x01) temp |= 0x01;
7645 if(temp1 == 0x03) temp |= 0x04; /* ? why not 0x10? */ 7456 if(temp1 == 0x03) temp |= 0x04; /* ? why not 0x10? */
7646 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xf8,(temp & 0xff)); 7457 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x26,0xf8,(temp & 0xff));
7647 } 7458 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x3a,0xfb,(temp >> 8));
7648 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x3a,0xfb,(temp >> 8)); 7459 if(ModeNo > 0x13) {
7649 if(ModeNo > 0x13) { 7460 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x3b,0xfd);
7650 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x3b,0xfd); 7461 }
7651 } 7462 }
7652 7463
7653 if(HwInfo->jChipType >= SIS_661) { /* ? */ 7464#if 0
7465 if(SiS_Pr->ChipType >= SIS_661) { /* ? */
7654 if(SiS_Pr->SiS_TVMode & TVAspect43) { 7466 if(SiS_Pr->SiS_TVMode & TVAspect43) {
7655 if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) { 7467 if(SiS_Pr->SiS_TVMode & TVSetYPbPr750p) {
7656 if(resinfo == SIS_RI_1024x768) { 7468 if(resinfo == SIS_RI_1024x768) {
@@ -7663,29 +7475,30 @@ SiS_SetGroup4_C_ELV(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
7663 } 7475 }
7664 } 7476 }
7665 } 7477 }
7478#endif
7479
7666 } 7480 }
7481
7667} 7482}
7668#endif 7483#endif
7669 7484
7670static void 7485static void
7671SiS_SetCRT2VCLK(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, 7486SiS_SetCRT2VCLK(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex,
7672 USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) 7487 unsigned short RefreshRateTableIndex)
7673{ 7488{
7674 USHORT vclkindex; 7489 unsigned short vclkindex, temp, reg1, reg2;
7675 USHORT temp, reg1, reg2;
7676 7490
7677 if(SiS_Pr->UseCustomMode) { 7491 if(SiS_Pr->UseCustomMode) {
7678 reg1 = SiS_Pr->CSR2B; 7492 reg1 = SiS_Pr->CSR2B;
7679 reg2 = SiS_Pr->CSR2C; 7493 reg2 = SiS_Pr->CSR2C;
7680 } else { 7494 } else {
7681 vclkindex = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, 7495 vclkindex = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
7682 HwInfo);
7683 reg1 = SiS_Pr->SiS_VBVCLKData[vclkindex].Part4_A; 7496 reg1 = SiS_Pr->SiS_VBVCLKData[vclkindex].Part4_A;
7684 reg2 = SiS_Pr->SiS_VBVCLKData[vclkindex].Part4_B; 7497 reg2 = SiS_Pr->SiS_VBVCLKData[vclkindex].Part4_B;
7685 } 7498 }
7686 7499
7687 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { 7500 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) {
7688 if(SiS_Pr->SiS_TVMode & TVSetNTSC1024) { 7501 if(SiS_Pr->SiS_TVMode & (TVSetNTSC1024 | TVSet525p1024)) {
7689 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0a,0x57); 7502 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0a,0x57);
7690 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0b,0x46); 7503 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x0b,0x46);
7691 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1f,0xf6); 7504 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1f,0xf6);
@@ -7705,11 +7518,35 @@ SiS_SetCRT2VCLK(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
7705} 7518}
7706 7519
7707static void 7520static void
7708SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, 7521SiS_SetDualLinkEtc(struct SiS_Private *SiS_Pr)
7709 USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) 7522{
7523 if(SiS_Pr->ChipType >= SIS_315H) {
7524 if(SiS_Pr->SiS_VBType & VB_SISDUALLINK) {
7525 if((SiS_CRT2IsLCD(SiS_Pr)) ||
7526 (SiS_IsVAMode(SiS_Pr))) {
7527 if(SiS_Pr->SiS_LCDInfo & LCDDualLink) {
7528 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x2c);
7529 } else {
7530 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x27,~0x20);
7531 }
7532 }
7533 }
7534 }
7535 if(SiS_Pr->SiS_VBType & VB_SISEMI) {
7536 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2a,0x00);
7537#ifdef SET_EMI
7538 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c);
7539#endif
7540 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x10);
7541 }
7542}
7543
7544static void
7545SiS_SetGroup4(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex,
7546 unsigned short RefreshRateTableIndex)
7710{ 7547{
7711 USHORT tempax,tempcx,tempbx,modeflag,temp,resinfo; 7548 unsigned short tempax, tempcx, tempbx, modeflag, temp, resinfo;
7712 ULONG tempebx,tempeax,templong; 7549 unsigned int tempebx, tempeax, templong;
7713 7550
7714 if(ModeNo <= 0x13) { 7551 if(ModeNo <= 0x13) {
7715 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; 7552 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
@@ -7722,38 +7559,24 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
7722 resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO; 7559 resinfo = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_RESINFO;
7723 } 7560 }
7724 7561
7725 if(HwInfo->jChipType >= SIS_315H) { 7562 if(SiS_Pr->ChipType >= SIS_315H) {
7726 if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { 7563 if(SiS_Pr->SiS_VBType & VB_SISLVDS) {
7727 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { 7564 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
7728 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x24,0x0e); 7565 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x24,0x0e);
7729 } 7566 }
7730 } 7567 }
7731 } 7568 }
7732 7569
7733 if(SiS_Pr->SiS_VBType & (VB_SIS301C | VB_SIS302LV)) { 7570 if(SiS_Pr->SiS_VBType & (VB_SIS30xCLV | VB_SIS302LV)) {
7734 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 7571 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
7735 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x10,0x9f); 7572 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x10,0x9f);
7736 } 7573 }
7737 } 7574 }
7738 7575
7739 if(HwInfo->jChipType >= SIS_315H) { 7576 if(SiS_Pr->ChipType >= SIS_315H) {
7740 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { 7577 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
7741 if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { 7578 SiS_SetDualLinkEtc(SiS_Pr);
7742 if(SiS_IsDualLink(SiS_Pr, HwInfo)) { 7579 return;
7743 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x2c);
7744 } else {
7745 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x27,~0x20);
7746 }
7747
7748 if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) {
7749 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2a,0x00);
7750#ifdef SET_EMI
7751 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c);
7752#endif
7753 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x10);
7754 }
7755 }
7756 return;
7757 } 7580 }
7758 } 7581 }
7759 7582
@@ -7777,16 +7600,16 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
7777 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x15,temp); 7600 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x15,temp);
7778 7601
7779 tempbx = SiS_Pr->SiS_VGAHDE; 7602 tempbx = SiS_Pr->SiS_VGAHDE;
7780 if(modeflag & HalfDCLK) tempbx >>= 1; 7603 if(modeflag & HalfDCLK) tempbx >>= 1;
7781 if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempbx >>= 1; 7604 if(SiS_IsDualLink(SiS_Pr)) tempbx >>= 1;
7782 7605
7783 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 7606 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
7784 temp = 0; 7607 temp = 0;
7785 if(tempbx > 800) temp = 0x60; 7608 if(tempbx > 800) temp = 0x60;
7786 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) { 7609 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {
7787 temp = 0; 7610 temp = 0;
7788 if(tempbx == 1024) temp = 0xA0; 7611 if(tempbx > 1024) temp = 0xC0;
7789 else if(tempbx > 1024) temp = 0xC0; 7612 else if(tempbx >= 960) temp = 0xA0;
7790 } else if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p)) { 7613 } else if(SiS_Pr->SiS_TVMode & (TVSetYPbPr525p | TVSetYPbPr750p)) {
7791 temp = 0; 7614 temp = 0;
7792 if(tempbx >= 1280) temp = 0x40; 7615 if(tempbx >= 1280) temp = 0x40;
@@ -7796,8 +7619,13 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
7796 if(tempbx >= 1024) temp = 0xA0; 7619 if(tempbx >= 1024) temp = 0xA0;
7797 } 7620 }
7798 7621
7622 temp |= SiS_Pr->Init_P4_0E;
7623
7799 if(SiS_Pr->SiS_VBType & VB_SIS301) { 7624 if(SiS_Pr->SiS_VBType & VB_SIS301) {
7800 if(SiS_Pr->SiS_LCDResInfo != Panel_1280x1024) temp |= 0x0A; 7625 if(SiS_Pr->SiS_LCDResInfo != Panel_1280x1024) {
7626 temp &= 0xf0;
7627 temp |= 0x0A;
7628 }
7801 } 7629 }
7802 7630
7803 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0E,0x10,temp); 7631 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x0E,0x10,temp);
@@ -7824,15 +7652,15 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
7824 tempeax /= tempebx; 7652 tempeax /= tempebx;
7825 if(templong) tempeax++; 7653 if(templong) tempeax++;
7826 7654
7827 temp = (USHORT)(tempeax & 0x000000FF); 7655 temp = (unsigned short)(tempeax & 0x000000FF);
7828 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1B,temp); 7656 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1B,temp);
7829 temp = (USHORT)((tempeax & 0x0000FF00) >> 8); 7657 temp = (unsigned short)((tempeax & 0x0000FF00) >> 8);
7830 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1A,temp); 7658 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1A,temp);
7831 temp = (USHORT)((tempeax >> 12) & 0x70); /* sic! */ 7659 temp = (unsigned short)((tempeax >> 12) & 0x70); /* sic! */
7832 temp |= (tempcx & 0x4F); 7660 temp |= (tempcx & 0x4F);
7833 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x19,temp); 7661 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x19,temp);
7834 7662
7835 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { 7663 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) {
7836 7664
7837 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1C,0x28); 7665 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1C,0x28);
7838 7666
@@ -7840,23 +7668,26 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
7840 tempbx = 0; 7668 tempbx = 0;
7841 if(SiS_Pr->SiS_TVMode & (TVSetHiVision | TVSetYPbPr750p)) tempbx = 0x08; 7669 if(SiS_Pr->SiS_TVMode & (TVSetHiVision | TVSetYPbPr750p)) tempbx = 0x08;
7842 tempax = SiS_Pr->SiS_VGAHDE; 7670 tempax = SiS_Pr->SiS_VGAHDE;
7843 if(modeflag & HalfDCLK) tempax >>= 1; 7671 if(modeflag & HalfDCLK) tempax >>= 1;
7844 if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempax >>= 1; 7672 if(SiS_IsDualLink(SiS_Pr)) tempax >>= 1;
7845 if(tempax > 800) { 7673 if(tempax > 800) {
7846 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 7674 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
7847 tempax -= 800; 7675 tempax -= 800;
7848 } else { /* 651+301C: Only if TVNoHiviNoYPbPr */ 7676 } else {
7849 tempbx = 0x08; 7677 tempbx = 0x08;
7850 if(tempax == 1024) tempax *= 25; 7678 if(tempax == 960) tempax *= 25; /* Correct */
7851 else tempax *= 20; 7679 else if(tempax == 1024) tempax *= 25;
7680 else tempax *= 20;
7852 temp = tempax % 32; 7681 temp = tempax % 32;
7853 tempax /= 32; 7682 tempax /= 32;
7854 if(temp) tempax++; 7683 if(temp) tempax++;
7855 tempax++; 7684 tempax++;
7856 if((SiS_Pr->SiS_VBInfo & SetCRT2ToTVNoYPbPrHiVision) || 7685 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
7857 (SiS_Pr->SiS_TVMode & TVSetYPbPr525i)) { 7686 if(resinfo == SIS_RI_1024x768 ||
7858 if(resinfo == SIS_RI_1024x768) { 7687 resinfo == SIS_RI_1024x576 ||
7859 /* Otherwise white line at right edge */ 7688 resinfo == SIS_RI_1280x1024 ||
7689 resinfo == SIS_RI_1280x720) {
7690 /* Otherwise white line or garbage at right edge */
7860 tempax = (tempax & 0xff00) | 0x20; 7691 tempax = (tempax & 0xff00) | 0x20;
7861 } 7692 }
7862 } 7693 }
@@ -7868,7 +7699,7 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
7868 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1E,temp); 7699 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x1E,temp);
7869 7700
7870 temp = 0x0036; tempbx = 0xD0; 7701 temp = 0x0036; tempbx = 0xD0;
7871 if((HwInfo->jChipType >= SIS_315H) && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) { 7702 if((SiS_Pr->ChipType >= SIS_315H) && (SiS_Pr->SiS_VBType & VB_SISLVDS)) {
7872 temp = 0x0026; tempbx = 0xC0; /* See En/DisableBridge() */ 7703 temp = 0x0026; tempbx = 0xC0; /* See En/DisableBridge() */
7873 } 7704 }
7874 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 7705 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
@@ -7884,36 +7715,24 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
7884 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x1F,tempbx,temp); 7715 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x1F,tempbx,temp);
7885 7716
7886 tempbx = SiS_Pr->SiS_HT >> 1; 7717 tempbx = SiS_Pr->SiS_HT >> 1;
7887 if(SiS_IsDualLink(SiS_Pr, HwInfo)) tempbx >>= 1; 7718 if(SiS_IsDualLink(SiS_Pr)) tempbx >>= 1;
7888 tempbx -= 2; 7719 tempbx -= 2;
7889 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x22,tempbx); 7720 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x22,tempbx);
7890 temp = (tempbx >> 5) & 0x38; 7721 temp = (tempbx >> 5) & 0x38;
7891 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,0xC0,temp); 7722 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x21,0xC0,temp);
7892 7723
7893 if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { 7724 if(SiS_Pr->SiS_VBType & VB_SISLVDS) {
7894 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 7725 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
7895 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x24,0x0e); 7726 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x24,0x0e);
7896 /* LCD-too-dark-error-source, see FinalizeLCD() */ 7727 /* LCD-too-dark-error-source, see FinalizeLCD() */
7897 } 7728 }
7898 if(HwInfo->jChipType >= SIS_315H) {
7899 if(SiS_IsDualLink(SiS_Pr, HwInfo)) {
7900 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x27,0x2c);
7901 } else {
7902 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x27,~0x20);
7903 }
7904 }
7905 if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) {
7906 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2a,0x00);
7907#ifdef SET_EMI
7908 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c);
7909#endif
7910 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x34,0x10);
7911 }
7912 } 7729 }
7913 7730
7731 SiS_SetDualLinkEtc(SiS_Pr);
7732
7914 } /* 301B */ 7733 } /* 301B */
7915 7734
7916 SiS_SetCRT2VCLK(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); 7735 SiS_SetCRT2VCLK(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
7917} 7736}
7918 7737
7919/*********************************************/ 7738/*********************************************/
@@ -7921,8 +7740,7 @@ SiS_SetGroup4(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
7921/*********************************************/ 7740/*********************************************/
7922 7741
7923static void 7742static void
7924SiS_SetGroup5(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, 7743SiS_SetGroup5(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex)
7925 PSIS_HW_INFO HwInfo)
7926{ 7744{
7927 7745
7928 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) return; 7746 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) return;
@@ -7930,7 +7748,7 @@ SiS_SetGroup5(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
7930 if(SiS_Pr->SiS_ModeType == ModeVGA) { 7748 if(SiS_Pr->SiS_ModeType == ModeVGA) {
7931 if(!(SiS_Pr->SiS_VBInfo & (SetInSlaveMode | LoadDACFlag))) { 7749 if(!(SiS_Pr->SiS_VBInfo & (SetInSlaveMode | LoadDACFlag))) {
7932 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20); 7750 SiS_SetRegOR(SiS_Pr->SiS_P3c4,0x1E,0x20);
7933 SiS_LoadDAC(SiS_Pr, HwInfo, ModeNo, ModeIdIndex); 7751 SiS_LoadDAC(SiS_Pr, ModeNo, ModeIdIndex);
7934 } 7752 }
7935 } 7753 }
7936} 7754}
@@ -7939,116 +7757,156 @@ SiS_SetGroup5(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
7939/* MODIFY CRT1 GROUP FOR SLAVE MODE */ 7757/* MODIFY CRT1 GROUP FOR SLAVE MODE */
7940/*********************************************/ 7758/*********************************************/
7941 7759
7942static void 7760static BOOLEAN
7943SiS_ModCRT1CRTC(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, 7761SiS_GetLVDSCRT1Ptr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex,
7944 USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) 7762 unsigned short RefreshRateTableIndex, unsigned short *ResIndex,
7945{ 7763 unsigned short *DisplayType)
7946 USHORT tempah,i,modeflag,j; 7764 {
7947 USHORT ResIndex,DisplayType; 7765 unsigned short modeflag = 0;
7948 const SiS_LVDSCRT1DataStruct *LVDSCRT1Ptr=NULL; 7766 BOOLEAN checkhd = TRUE;
7949 7767
7950 if(ModeNo <= 0x13) modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag; 7768 /* Pass 1:1 not supported here */
7951 else modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; 7769
7770 if(ModeNo <= 0x13) {
7771 modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
7772 (*ResIndex) = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
7773 } else {
7774 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
7775 (*ResIndex) = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
7776 }
7777
7778 (*ResIndex) &= 0x3F;
7779
7780 if((SiS_Pr->SiS_IF_DEF_CH70xx) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) {
7781
7782 (*DisplayType) = 80;
7783 if((SiS_Pr->SiS_TVMode & TVSetPAL) && (!(SiS_Pr->SiS_TVMode & TVSetPALM))) {
7784 (*DisplayType) = 82;
7785 if(SiS_Pr->SiS_ModeType > ModeVGA) {
7786 if(SiS_Pr->SiS_CHSOverScan) (*DisplayType) = 84;
7787 }
7788 }
7789 if((*DisplayType) != 84) {
7790 if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) (*DisplayType)++;
7791 }
7792
7793 } else {
7794
7795 (*DisplayType = 0);
7796 switch(SiS_Pr->SiS_LCDResInfo) {
7797 case Panel_320x240_1: (*DisplayType) = 50;
7798 checkhd = FALSE;
7799 break;
7800 case Panel_320x240_2: (*DisplayType) = 14;
7801 break;
7802 case Panel_320x240_3: (*DisplayType) = 18;
7803 break;
7804 case Panel_640x480: (*DisplayType) = 10;
7805 break;
7806 case Panel_1024x600: (*DisplayType) = 26;
7807 break;
7808 default: return TRUE;
7809 }
7810
7811 if(checkhd) {
7812 if(modeflag & HalfDCLK) (*DisplayType)++;
7813 }
7814
7815 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x600) {
7816 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) (*DisplayType) += 2;
7817 }
7818
7819 }
7820
7821 return TRUE;
7822}
7823
7824static void
7825SiS_ModCRT1CRTC(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex,
7826 unsigned short RefreshRateTableIndex)
7827{
7828 unsigned short tempah, i, modeflag, j, ResIndex, DisplayType;
7829 const struct SiS_LVDSCRT1Data *LVDSCRT1Ptr=NULL;
7830 static const unsigned short CRIdx[] = {
7831 0x00, 0x02, 0x03, 0x04, 0x05, 0x06,
7832 0x07, 0x10, 0x11, 0x15, 0x16
7833 };
7952 7834
7953 if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || 7835 if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) ||
7954 (SiS_Pr->SiS_CustomT == CUT_BARCO1024) || 7836 (SiS_Pr->SiS_CustomT == CUT_BARCO1024) ||
7955 (SiS_Pr->SiS_CustomT == CUT_PANEL848)) 7837 (SiS_Pr->SiS_CustomT == CUT_PANEL848) ||
7838 (SiS_Pr->SiS_CustomT == CUT_PANEL856) )
7956 return; 7839 return;
7957 7840
7841 if(SiS_Pr->SiS_IF_DEF_LVDS) {
7842 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
7843 if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) return;
7844 }
7845 } else if(SiS_Pr->SiS_VBType & VB_SISVB) {
7846 if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) return;
7847 } else return;
7848
7849 if(SiS_Pr->SiS_LCDInfo & LCDPass11) return;
7850
7851 if(SiS_Pr->ChipType < SIS_315H) {
7852 if(SiS_Pr->SiS_SetFlag & SetDOSMode) return;
7853 }
7854
7958 if(!(SiS_GetLVDSCRT1Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, 7855 if(!(SiS_GetLVDSCRT1Ptr(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex,
7959 &ResIndex, &DisplayType))) { 7856 &ResIndex, &DisplayType))) {
7960 return; 7857 return;
7961 } 7858 }
7962 7859
7963 if(HwInfo->jChipType < SIS_315H) { 7860 switch(DisplayType) {
7964 if(SiS_Pr->SiS_SetFlag & SetDOSMode) return; 7861 case 50: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1320x240_1; break; /* xSTN */
7862 case 14: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1320x240_2; break; /* xSTN */
7863 case 15: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1320x240_2_H; break; /* xSTN */
7864 case 18: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1320x240_3; break; /* xSTN */
7865 case 19: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1320x240_3_H; break; /* xSTN */
7866 case 10: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_1; break;
7867 case 11: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_1_H; break;
7868#if 0 /* Works better with calculated numbers */
7869 case 26: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_1; break;
7870 case 27: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_1_H; break;
7871 case 28: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_2; break;
7872 case 29: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_2_H; break;
7873#endif
7874 case 80: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1UNTSC; break;
7875 case 81: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1ONTSC; break;
7876 case 82: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1UPAL; break;
7877 case 83: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1OPAL; break;
7878 case 84: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1SOPAL; break;
7965 } 7879 }
7966 7880
7967 switch(DisplayType) { 7881 if(LVDSCRT1Ptr) {
7968 case 0 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_1; break; 7882
7969 case 1 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_1_H; break; 7883 SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f);
7970 case 2 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_2; break; 7884
7971 case 3 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1800x600_2_H; break; 7885 for(i = 0; i <= 10; i++) {
7972 case 4 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_1; break; 7886 tempah = (LVDSCRT1Ptr + ResIndex)->CR[i];
7973 case 5 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_1_H; break; 7887 SiS_SetReg(SiS_Pr->SiS_P3d4,CRIdx[i],tempah);
7974 case 6 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_2; break; 7888 }
7975 case 7 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_2_H; break; 7889
7976 case 8 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_1; break; 7890 for(i = 0x0A, j = 11; i <= 0x0C; i++, j++) {
7977 case 9 : LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_1_H; break; 7891 tempah = (LVDSCRT1Ptr + ResIndex)->CR[j];
7978 case 10: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_2; break; 7892 SiS_SetReg(SiS_Pr->SiS_P3c4,i,tempah);
7979 case 11: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x1024_2_H; break; 7893 }
7980 case 12: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1XXXxXXX_1; break; 7894
7981 case 13: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1XXXxXXX_1_H; break; 7895 tempah = (LVDSCRT1Ptr + ResIndex)->CR[14] & 0xE0;
7982 case 14: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11400x1050_1; break; 7896 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0E,0x1f,tempah);
7983 case 15: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11400x1050_1_H; break; 7897
7984 case 16: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11400x1050_2; break; 7898 if(ModeNo <= 0x13) modeflag = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_ModeFlag;
7985 case 17: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11400x1050_2_H; break; 7899 else modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
7986 case 18: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1UNTSC; break; 7900
7987 case 19: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1ONTSC; break; 7901 tempah = ((LVDSCRT1Ptr + ResIndex)->CR[14] & 0x01) << 5;
7988 case 20: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1UPAL; break; 7902 if(modeflag & DoubleScanMode) tempah |= 0x80;
7989 case 21: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1OPAL; break; 7903 SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,~0x020,tempah);
7990 case 22: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1320x480_1; break; /* FSTN */ 7904
7991 case 23: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_1; break; 7905 } else {
7992 case 24: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_1_H; break; 7906
7993 case 25: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_2; break; 7907 SiS_CalcLCDACRT1Timing(SiS_Pr, ModeNo, ModeIdIndex);
7994 case 26: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x600_2_H; break; 7908
7995 case 27: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11152x768_1; break; 7909 }
7996 case 28: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11152x768_1_H; break;
7997 case 29: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11152x768_2; break;
7998 case 30: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11152x768_2_H; break;
7999 case 36: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11600x1200_1; break;
8000 case 37: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11600x1200_1_H; break;
8001 case 38: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11600x1200_2; break;
8002 case 39: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11600x1200_2_H; break;
8003 case 40: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x768_1; break;
8004 case 41: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x768_1_H; break;
8005 case 42: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x768_2; break;
8006 case 43: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11280x768_2_H; break;
8007 case 50: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_1; break;
8008 case 51: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_1_H; break;
8009 case 52: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_2; break;
8010 case 53: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_2_H; break;
8011 case 54: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_3; break;
8012 case 55: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT1640x480_3_H; break;
8013 case 99: LVDSCRT1Ptr = SiS_Pr->SiS_CHTVCRT1SOPAL; break;
8014 default: LVDSCRT1Ptr = SiS_Pr->SiS_LVDSCRT11024x768_1; break;
8015 }
8016
8017 SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x11,0x7f);
8018
8019 tempah = (LVDSCRT1Ptr + ResIndex)->CR[0];
8020 SiS_SetReg(SiS_Pr->SiS_P3d4,0x00,tempah);
8021
8022 for(i=0x02,j=1;i<=0x05;i++,j++){
8023 tempah = (LVDSCRT1Ptr + ResIndex)->CR[j];
8024 SiS_SetReg(SiS_Pr->SiS_P3d4,i,tempah);
8025 }
8026 for(i=0x06,j=5;i<=0x07;i++,j++){
8027 tempah = (LVDSCRT1Ptr + ResIndex)->CR[j];
8028 SiS_SetReg(SiS_Pr->SiS_P3d4,i,tempah);
8029 }
8030 for(i=0x10,j=7;i<=0x11;i++,j++){
8031 tempah = (LVDSCRT1Ptr + ResIndex)->CR[j];
8032 SiS_SetReg(SiS_Pr->SiS_P3d4,i,tempah);
8033 }
8034 for(i=0x15,j=9;i<=0x16;i++,j++){
8035 tempah = (LVDSCRT1Ptr + ResIndex)->CR[j];
8036 SiS_SetReg(SiS_Pr->SiS_P3d4,i,tempah);
8037 }
8038 for(i=0x0A,j=11;i<=0x0C;i++,j++){
8039 tempah = (LVDSCRT1Ptr + ResIndex)->CR[j];
8040 SiS_SetReg(SiS_Pr->SiS_P3c4,i,tempah);
8041 }
8042
8043 tempah = (LVDSCRT1Ptr + ResIndex)->CR[14];
8044 tempah &= 0xE0;
8045 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x0E,0x1f,tempah);
8046
8047 tempah = (LVDSCRT1Ptr + ResIndex)->CR[14];
8048 tempah &= 0x01;
8049 tempah <<= 5;
8050 if(modeflag & DoubleScanMode) tempah |= 0x080;
8051 SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x09,~0x020,tempah);
8052} 7910}
8053 7911
8054/*********************************************/ 7912/*********************************************/
@@ -8056,24 +7914,24 @@ SiS_ModCRT1CRTC(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
8056/*********************************************/ 7914/*********************************************/
8057 7915
8058static void 7916static void
8059SiS_SetCRT2ECLK(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, 7917SiS_SetCRT2ECLK(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex,
8060 USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo) 7918 unsigned short RefreshRateTableIndex)
8061{ 7919{
8062 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; 7920 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
8063 USHORT clkbase, vclkindex=0; 7921 unsigned short clkbase, vclkindex = 0;
8064 UCHAR sr2b, sr2c; 7922 unsigned char sr2b, sr2c;
8065 7923
8066 if((SiS_Pr->SiS_LCDResInfo == Panel_640x480) || (SiS_Pr->SiS_LCDInfo & LCDPass11)) { 7924 if(SiS_Pr->SiS_LCDInfo & LCDPass11) {
8067 SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2); 7925 SiS_Pr->SiS_SetFlag &= (~ProgrammingCRT2);
8068 if((SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK & 0x3f) == 2) { 7926 if(SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK == 2) {
8069 RefreshRateTableIndex--; 7927 RefreshRateTableIndex--;
8070 } 7928 }
8071 vclkindex = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex, 7929 vclkindex = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex,
8072 RefreshRateTableIndex, HwInfo); 7930 RefreshRateTableIndex);
8073 SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; 7931 SiS_Pr->SiS_SetFlag |= ProgrammingCRT2;
8074 } else { 7932 } else {
8075 vclkindex = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex, 7933 vclkindex = SiS_GetVCLK2Ptr(SiS_Pr, ModeNo, ModeIdIndex,
8076 RefreshRateTableIndex, HwInfo); 7934 RefreshRateTableIndex);
8077 } 7935 }
8078 7936
8079 sr2b = SiS_Pr->SiS_VCLKData[vclkindex].SR2B; 7937 sr2b = SiS_Pr->SiS_VCLKData[vclkindex].SR2B;
@@ -8082,7 +7940,7 @@ SiS_SetCRT2ECLK(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
8082 if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) { 7940 if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) {
8083 if(SiS_Pr->SiS_UseROM) { 7941 if(SiS_Pr->SiS_UseROM) {
8084 if(ROMAddr[0x220] & 0x01) { 7942 if(ROMAddr[0x220] & 0x01) {
8085 sr2b = ROMAddr[0x227]; 7943 sr2b = ROMAddr[0x227];
8086 sr2c = ROMAddr[0x228]; 7944 sr2c = ROMAddr[0x228];
8087 } 7945 }
8088 } 7946 }
@@ -8091,7 +7949,7 @@ SiS_SetCRT2ECLK(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
8091 clkbase = 0x02B; 7949 clkbase = 0x02B;
8092 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) { 7950 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA)) {
8093 if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) { 7951 if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) {
8094 clkbase += 3; 7952 clkbase += 3;
8095 } 7953 }
8096 } 7954 }
8097 7955
@@ -8111,368 +7969,331 @@ SiS_SetCRT2ECLK(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
8111/*********************************************/ 7969/*********************************************/
8112 7970
8113static void 7971static void
8114SiS_SetCHTVReg(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, 7972SiS_SetCHTVReg(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex,
8115 USHORT RefreshRateTableIndex) 7973 unsigned short RefreshRateTableIndex)
8116{ 7974{
8117#if defined(SIS300) || defined(SIS315H) 7975 unsigned short TVType, resindex;
8118 USHORT temp, tempbx; 7976 const struct SiS_CHTVRegData *CHTVRegData = NULL;
8119#endif
8120 USHORT tempcl;
8121 USHORT TVType, resindex;
8122 const SiS_CHTVRegDataStruct *CHTVRegData = NULL;
8123 7977
8124 if(ModeNo <= 0x13) 7978 if(ModeNo <= 0x13)
8125 tempcl = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC; 7979 resindex = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].St_CRT2CRTC;
8126 else 7980 else
8127 tempcl = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; 7981 resindex = SiS_Pr->SiS_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
8128 7982
8129 TVType = 0; 7983 resindex &= 0x3F;
8130 if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) TVType += 1; 7984
8131 if(SiS_Pr->SiS_TVMode & TVSetPAL) { 7985 TVType = 0;
8132 TVType += 2; 7986 if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) TVType += 1;
8133 if(SiS_Pr->SiS_ModeType > ModeVGA) { 7987 if(SiS_Pr->SiS_TVMode & TVSetPAL) {
8134 if(SiS_Pr->SiS_CHSOverScan) TVType = 8; 7988 TVType += 2;
8135 } 7989 if(SiS_Pr->SiS_ModeType > ModeVGA) {
8136 if(SiS_Pr->SiS_TVMode & TVSetPALM) { 7990 if(SiS_Pr->SiS_CHSOverScan) TVType = 8;
8137 TVType = 4; 7991 }
8138 if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) TVType += 1; 7992 if(SiS_Pr->SiS_TVMode & TVSetPALM) {
8139 } else if(SiS_Pr->SiS_TVMode & TVSetPALN) { 7993 TVType = 4;
8140 TVType = 6; 7994 if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) TVType += 1;
8141 if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) TVType += 1; 7995 } else if(SiS_Pr->SiS_TVMode & TVSetPALN) {
8142 } 7996 TVType = 6;
8143 } 7997 if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) TVType += 1;
8144 switch(TVType) { 7998 }
8145 case 0: CHTVRegData = SiS_Pr->SiS_CHTVReg_UNTSC; break; 7999 }
8146 case 1: CHTVRegData = SiS_Pr->SiS_CHTVReg_ONTSC; break; 8000
8147 case 2: CHTVRegData = SiS_Pr->SiS_CHTVReg_UPAL; break; 8001 switch(TVType) {
8148 case 3: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPAL; break; 8002 case 0: CHTVRegData = SiS_Pr->SiS_CHTVReg_UNTSC; break;
8149 case 4: CHTVRegData = SiS_Pr->SiS_CHTVReg_UPALM; break; 8003 case 1: CHTVRegData = SiS_Pr->SiS_CHTVReg_ONTSC; break;
8150 case 5: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPALM; break; 8004 case 2: CHTVRegData = SiS_Pr->SiS_CHTVReg_UPAL; break;
8151 case 6: CHTVRegData = SiS_Pr->SiS_CHTVReg_UPALN; break; 8005 case 3: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPAL; break;
8152 case 7: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPALN; break; 8006 case 4: CHTVRegData = SiS_Pr->SiS_CHTVReg_UPALM; break;
8153 case 8: CHTVRegData = SiS_Pr->SiS_CHTVReg_SOPAL; break; 8007 case 5: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPALM; break;
8154 default: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPAL; break; 8008 case 6: CHTVRegData = SiS_Pr->SiS_CHTVReg_UPALN; break;
8155 } 8009 case 7: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPALN; break;
8156 resindex = tempcl & 0x3F; 8010 case 8: CHTVRegData = SiS_Pr->SiS_CHTVReg_SOPAL; break;
8011 default: CHTVRegData = SiS_Pr->SiS_CHTVReg_OPAL; break;
8012 }
8157 8013
8158 if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { 8014
8015 if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) {
8159 8016
8160#ifdef SIS300 8017#ifdef SIS300
8161 8018
8162 /* Chrontel 7005 - I assume that it does not come with a 315 series chip */ 8019 /* Chrontel 7005 - I assume that it does not come with a 315 series chip */
8163 8020
8164 /* We don't support modes >800x600 */ 8021 /* We don't support modes >800x600 */
8165 if (resindex > 5) return; 8022 if (resindex > 5) return;
8166 8023
8167 if(SiS_Pr->SiS_TVMode & TVSetPAL) { 8024 if(SiS_Pr->SiS_TVMode & TVSetPAL) {
8168 SiS_SetCH700x(SiS_Pr,0x4304); /* 0x40=76uA (PAL); 0x03=15bit non-multi RGB*/ 8025 SiS_SetCH700x(SiS_Pr,0x04,0x43); /* 0x40=76uA (PAL); 0x03=15bit non-multi RGB*/
8169 SiS_SetCH700x(SiS_Pr,0x6909); /* Black level for PAL (105)*/ 8026 SiS_SetCH700x(SiS_Pr,0x09,0x69); /* Black level for PAL (105)*/
8170 } else { 8027 } else {
8171 SiS_SetCH700x(SiS_Pr,0x0304); /* upper nibble=71uA (NTSC), 0x03=15bit non-multi RGB*/ 8028 SiS_SetCH700x(SiS_Pr,0x04,0x03); /* upper nibble=71uA (NTSC), 0x03=15bit non-multi RGB*/
8172 SiS_SetCH700x(SiS_Pr,0x7109); /* Black level for NTSC (113)*/ 8029 SiS_SetCH700x(SiS_Pr,0x09,0x71); /* Black level for NTSC (113)*/
8173 } 8030 }
8174 8031
8175 temp = CHTVRegData[resindex].Reg[0]; 8032 SiS_SetCH700x(SiS_Pr,0x00,CHTVRegData[resindex].Reg[0]); /* Mode register */
8176 tempbx=((temp&0x00FF)<<8)|0x00; /* Mode register */ 8033 SiS_SetCH700x(SiS_Pr,0x07,CHTVRegData[resindex].Reg[1]); /* Start active video register */
8177 SiS_SetCH700x(SiS_Pr,tempbx); 8034 SiS_SetCH700x(SiS_Pr,0x08,CHTVRegData[resindex].Reg[2]); /* Position overflow register */
8178 temp = CHTVRegData[resindex].Reg[1]; 8035 SiS_SetCH700x(SiS_Pr,0x0a,CHTVRegData[resindex].Reg[3]); /* Horiz Position register */
8179 tempbx=((temp&0x00FF)<<8)|0x07; /* Start active video register */ 8036 SiS_SetCH700x(SiS_Pr,0x0b,CHTVRegData[resindex].Reg[4]); /* Vertical Position register */
8180 SiS_SetCH700x(SiS_Pr,tempbx); 8037
8181 temp = CHTVRegData[resindex].Reg[2]; 8038 /* Set minimum flicker filter for Luma channel (SR1-0=00),
8182 tempbx=((temp&0x00FF)<<8)|0x08; /* Position overflow register */
8183 SiS_SetCH700x(SiS_Pr,tempbx);
8184 temp = CHTVRegData[resindex].Reg[3];
8185 tempbx=((temp&0x00FF)<<8)|0x0A; /* Horiz Position register */
8186 SiS_SetCH700x(SiS_Pr,tempbx);
8187 temp = CHTVRegData[resindex].Reg[4];
8188 tempbx=((temp&0x00FF)<<8)|0x0B; /* Vertical Position register */
8189 SiS_SetCH700x(SiS_Pr,tempbx);
8190
8191 /* Set minimum flicker filter for Luma channel (SR1-0=00),
8192 minimum text enhancement (S3-2=10), 8039 minimum text enhancement (S3-2=10),
8193 maximum flicker filter for Chroma channel (S5-4=10) 8040 maximum flicker filter for Chroma channel (S5-4=10)
8194 =00101000=0x28 (When reading, S1-0->S3-2, and S3-2->S1-0!) 8041 =00101000=0x28 (When reading, S1-0->S3-2, and S3-2->S1-0!)
8195 */ 8042 */
8196 SiS_SetCH700x(SiS_Pr,0x2801); 8043 SiS_SetCH700x(SiS_Pr,0x01,0x28);
8197 8044
8198 /* Set video bandwidth 8045 /* Set video bandwidth
8199 High bandwith Luma composite video filter(S0=1) 8046 High bandwith Luma composite video filter(S0=1)
8200 low bandwith Luma S-video filter (S2-1=00) 8047 low bandwith Luma S-video filter (S2-1=00)
8201 disable peak filter in S-video channel (S3=0) 8048 disable peak filter in S-video channel (S3=0)
8202 high bandwidth Chroma Filter (S5-4=11) 8049 high bandwidth Chroma Filter (S5-4=11)
8203 =00110001=0x31 8050 =00110001=0x31
8204 */ 8051 */
8205 SiS_SetCH700x(SiS_Pr,0xb103); /* old: 3103 */ 8052 SiS_SetCH700x(SiS_Pr,0x03,0xb1); /* old: 3103 */
8206 8053
8207 /* Register 0x3D does not exist in non-macrovision register map 8054 /* Register 0x3D does not exist in non-macrovision register map
8208 (Maybe this is a macrovision register?) 8055 (Maybe this is a macrovision register?)
8209 */ 8056 */
8210#ifndef SIS_CP 8057#ifndef SIS_CP
8211 SiS_SetCH70xx(SiS_Pr,0x003D); 8058 SiS_SetCH70xx(SiS_Pr,0x3d,0x00);
8212#endif 8059#endif
8213 8060
8214 /* Register 0x10 only contains 1 writable bit (S0) for sensing, 8061 /* Register 0x10 only contains 1 writable bit (S0) for sensing,
8215 all other bits a read-only. Macrovision? 8062 all other bits a read-only. Macrovision?
8216 */ 8063 */
8217 SiS_SetCH70xxANDOR(SiS_Pr,0x0010,0x1F); 8064 SiS_SetCH70xxANDOR(SiS_Pr,0x10,0x00,0x1F);
8218 8065
8219 /* Register 0x11 only contains 3 writable bits (S0-S2) for 8066 /* Register 0x11 only contains 3 writable bits (S0-S2) for
8220 contrast enhancement (set to 010 -> gain 1 Yout = 17/16*(Yin-30) ) 8067 contrast enhancement (set to 010 -> gain 1 Yout = 17/16*(Yin-30) )
8221 */ 8068 */
8222 SiS_SetCH70xxANDOR(SiS_Pr,0x0211,0xF8); 8069 SiS_SetCH70xxANDOR(SiS_Pr,0x11,0x02,0xF8);
8223 8070
8224 /* Clear DSEN 8071 /* Clear DSEN
8225 */ 8072 */
8226 SiS_SetCH70xxANDOR(SiS_Pr,0x001C,0xEF); 8073 SiS_SetCH70xxANDOR(SiS_Pr,0x1c,0x00,0xEF);
8227 8074
8228 if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { /* ---- NTSC ---- */ 8075 if(!(SiS_Pr->SiS_TVMode & TVSetPAL)) { /* ---- NTSC ---- */
8229 if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) { 8076 if(SiS_Pr->SiS_TVMode & TVSetCHOverScan) {
8230 if(resindex == 0x04) { /* 640x480 overscan: Mode 16 */ 8077 if(resindex == 0x04) { /* 640x480 overscan: Mode 16 */
8231 SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off */ 8078 SiS_SetCH70xxANDOR(SiS_Pr,0x20,0x00,0xEF); /* loop filter off */
8232 SiS_SetCH70xxANDOR(SiS_Pr,0x0121,0xFE); /* ACIV on, no need to set FSCI */ 8079 SiS_SetCH70xxANDOR(SiS_Pr,0x21,0x01,0xFE); /* ACIV on, no need to set FSCI */
8233 } else if(resindex == 0x05) { /* 800x600 overscan: Mode 23 */ 8080 } else if(resindex == 0x05) { /* 800x600 overscan: Mode 23 */
8234 SiS_SetCH70xxANDOR(SiS_Pr,0x0118,0xF0); /* 0x18-0x1f: FSCI 469,762,048 */ 8081 SiS_SetCH70xxANDOR(SiS_Pr,0x18,0x01,0xF0); /* 0x18-0x1f: FSCI 469,762,048 */
8235 SiS_SetCH70xxANDOR(SiS_Pr,0x0C19,0xF0); 8082 SiS_SetCH70xxANDOR(SiS_Pr,0x19,0x0C,0xF0);
8236 SiS_SetCH70xxANDOR(SiS_Pr,0x001A,0xF0); 8083 SiS_SetCH70xxANDOR(SiS_Pr,0x1a,0x00,0xF0);
8237 SiS_SetCH70xxANDOR(SiS_Pr,0x001B,0xF0); 8084 SiS_SetCH70xxANDOR(SiS_Pr,0x1b,0x00,0xF0);
8238 SiS_SetCH70xxANDOR(SiS_Pr,0x001C,0xF0); 8085 SiS_SetCH70xxANDOR(SiS_Pr,0x1c,0x00,0xF0);
8239 SiS_SetCH70xxANDOR(SiS_Pr,0x001D,0xF0); 8086 SiS_SetCH70xxANDOR(SiS_Pr,0x1d,0x00,0xF0);
8240 SiS_SetCH70xxANDOR(SiS_Pr,0x001E,0xF0); 8087 SiS_SetCH70xxANDOR(SiS_Pr,0x1e,0x00,0xF0);
8241 SiS_SetCH70xxANDOR(SiS_Pr,0x001F,0xF0); 8088 SiS_SetCH70xxANDOR(SiS_Pr,0x1f,0x00,0xF0);
8242 SiS_SetCH70xxANDOR(SiS_Pr,0x0120,0xEF); /* Loop filter on for mode 23 */ 8089 SiS_SetCH70xxANDOR(SiS_Pr,0x20,0x01,0xEF); /* Loop filter on for mode 23 */
8243 SiS_SetCH70xxANDOR(SiS_Pr,0x0021,0xFE); /* ACIV off, need to set FSCI */ 8090 SiS_SetCH70xxANDOR(SiS_Pr,0x21,0x00,0xFE); /* ACIV off, need to set FSCI */
8244 } 8091 }
8245 } else { 8092 } else {
8246 if(resindex == 0x04) { /* ----- 640x480 underscan; Mode 17 */ 8093 if(resindex == 0x04) { /* ----- 640x480 underscan; Mode 17 */
8247 SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off */ 8094 SiS_SetCH70xxANDOR(SiS_Pr,0x20,0x00,0xEF); /* loop filter off */
8248 SiS_SetCH70xxANDOR(SiS_Pr,0x0121,0xFE); 8095 SiS_SetCH70xxANDOR(SiS_Pr,0x21,0x01,0xFE);
8249 } else if(resindex == 0x05) { /* ----- 800x600 underscan: Mode 24 */ 8096 } else if(resindex == 0x05) { /* ----- 800x600 underscan: Mode 24 */
8250#if 0 8097#if 0
8251 SiS_SetCH70xxANDOR(SiS_Pr,0x0118,0xF0); /* (FSCI was 0x1f1c71c7 - this is for mode 22) */ 8098 SiS_SetCH70xxANDOR(SiS_Pr,0x18,0x01,0xF0); /* (FSCI was 0x1f1c71c7 - this is for mode 22) */
8252 SiS_SetCH70xxANDOR(SiS_Pr,0x0919,0xF0); /* FSCI for mode 24 is 428,554,851 */ 8099 SiS_SetCH70xxANDOR(SiS_Pr,0x19,0x09,0xF0); /* FSCI for mode 24 is 428,554,851 */
8253 SiS_SetCH70xxANDOR(SiS_Pr,0x081A,0xF0); /* 198b3a63 */ 8100 SiS_SetCH70xxANDOR(SiS_Pr,0x1a,0x08,0xF0); /* 198b3a63 */
8254 SiS_SetCH70xxANDOR(SiS_Pr,0x0b1B,0xF0); 8101 SiS_SetCH70xxANDOR(SiS_Pr,0x1b,0x0b,0xF0);
8255 SiS_SetCH70xxANDOR(SiS_Pr,0x041C,0xF0); 8102 SiS_SetCH70xxANDOR(SiS_Pr,0x1c,0x04,0xF0);
8256 SiS_SetCH70xxANDOR(SiS_Pr,0x011D,0xF0); 8103 SiS_SetCH70xxANDOR(SiS_Pr,0x1d,0x01,0xF0);
8257 SiS_SetCH70xxANDOR(SiS_Pr,0x061E,0xF0); 8104 SiS_SetCH70xxANDOR(SiS_Pr,0x1e,0x06,0xF0);
8258 SiS_SetCH70xxANDOR(SiS_Pr,0x051F,0xF0); 8105 SiS_SetCH70xxANDOR(SiS_Pr,0x1f,0x05,0xF0);
8259 SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off for mode 24 */ 8106 SiS_SetCH70xxANDOR(SiS_Pr,0x20,0x00,0xEF); /* loop filter off for mode 24 */
8260 SiS_SetCH70xxANDOR(SiS_Pr,0x0021,0xFE); /* ACIV off, need to set FSCI */ 8107 SiS_SetCH70xxANDOR(SiS_Pr,0x21,0x00,0xFE); * ACIV off, need to set FSCI */
8261#endif /* All alternatives wrong (datasheet wrong?), don't use FSCI */ 8108#endif /* All alternatives wrong (datasheet wrong?), don't use FSCI */
8262 SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off */ 8109 SiS_SetCH70xxANDOR(SiS_Pr,0x20,0x00,0xEF); /* loop filter off */
8263 SiS_SetCH70xxANDOR(SiS_Pr,0x0121,0xFE); 8110 SiS_SetCH70xxANDOR(SiS_Pr,0x21,0x01,0xFE);
8111 }
8264 } 8112 }
8265 } 8113 } else { /* ---- PAL ---- */
8266 } else { /* ---- PAL ---- */ 8114 /* We don't play around with FSCI in PAL mode */
8267 /* We don't play around with FSCI in PAL mode */
8268 if(resindex == 0x04) { 8115 if(resindex == 0x04) {
8269 SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off */ 8116 SiS_SetCH70xxANDOR(SiS_Pr,0x20,0x00,0xEF); /* loop filter off */
8270 SiS_SetCH70xxANDOR(SiS_Pr,0x0121,0xFE); /* ACIV on */ 8117 SiS_SetCH70xxANDOR(SiS_Pr,0x21,0x01,0xFE); /* ACIV on */
8271 } else { 8118 } else {
8272 SiS_SetCH70xxANDOR(SiS_Pr,0x0020,0xEF); /* loop filter off */ 8119 SiS_SetCH70xxANDOR(SiS_Pr,0x20,0x00,0xEF); /* loop filter off */
8273 SiS_SetCH70xxANDOR(SiS_Pr,0x0121,0xFE); /* ACIV on */ 8120 SiS_SetCH70xxANDOR(SiS_Pr,0x21,0x01,0xFE); /* ACIV on */
8274 } 8121 }
8275 } 8122 }
8276 8123
8277#endif /* 300 */ 8124#endif /* 300 */
8278 8125
8279 } else { 8126 } else {
8280 8127
8281 /* Chrontel 7019 - assumed that it does not come with a 300 series chip */ 8128 /* Chrontel 7019 - assumed that it does not come with a 300 series chip */
8282 8129
8283#ifdef SIS315H 8130#ifdef SIS315H
8284 8131
8285 /* We don't support modes >1024x768 */ 8132 unsigned short temp;
8286 if (resindex > 6) return; 8133
8287 8134 /* We don't support modes >1024x768 */
8288 temp = CHTVRegData[resindex].Reg[0]; 8135 if (resindex > 6) return;
8289 if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) { 8136
8290 temp |= 0x10; 8137 temp = CHTVRegData[resindex].Reg[0];
8291 } 8138 if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) temp |= 0x10;
8292 tempbx=((temp & 0x00FF) << 8) | 0x00; 8139 SiS_SetCH701x(SiS_Pr,0x00,temp);
8293 SiS_SetCH701x(SiS_Pr,tempbx); 8140
8294 8141 SiS_SetCH701x(SiS_Pr,0x01,CHTVRegData[resindex].Reg[1]);
8295 temp = CHTVRegData[resindex].Reg[1]; 8142 SiS_SetCH701x(SiS_Pr,0x02,CHTVRegData[resindex].Reg[2]);
8296 tempbx=((temp & 0x00FF) << 8) | 0x01; 8143 SiS_SetCH701x(SiS_Pr,0x04,CHTVRegData[resindex].Reg[3]);
8297 SiS_SetCH701x(SiS_Pr,tempbx); 8144 SiS_SetCH701x(SiS_Pr,0x03,CHTVRegData[resindex].Reg[4]);
8298 8145 SiS_SetCH701x(SiS_Pr,0x05,CHTVRegData[resindex].Reg[5]);
8299 temp = CHTVRegData[resindex].Reg[2]; 8146 SiS_SetCH701x(SiS_Pr,0x06,CHTVRegData[resindex].Reg[6]);
8300 tempbx=((temp & 0x00FF) << 8) | 0x02; 8147
8301 SiS_SetCH701x(SiS_Pr,tempbx); 8148 temp = CHTVRegData[resindex].Reg[7];
8302 8149 if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) temp = 0x66;
8303 temp = CHTVRegData[resindex].Reg[3]; 8150 SiS_SetCH701x(SiS_Pr,0x07,temp);
8304 tempbx=((temp & 0x00FF) << 8) | 0x04; 8151
8305 SiS_SetCH701x(SiS_Pr,tempbx); 8152 SiS_SetCH701x(SiS_Pr,0x08,CHTVRegData[resindex].Reg[8]);
8306 8153 SiS_SetCH701x(SiS_Pr,0x15,CHTVRegData[resindex].Reg[9]);
8307 temp = CHTVRegData[resindex].Reg[4]; 8154 SiS_SetCH701x(SiS_Pr,0x1f,CHTVRegData[resindex].Reg[10]);
8308 tempbx=((temp & 0x00FF) << 8) | 0x03; 8155 SiS_SetCH701x(SiS_Pr,0x0c,CHTVRegData[resindex].Reg[11]);
8309 SiS_SetCH701x(SiS_Pr,tempbx); 8156 SiS_SetCH701x(SiS_Pr,0x0d,CHTVRegData[resindex].Reg[12]);
8310 8157 SiS_SetCH701x(SiS_Pr,0x0e,CHTVRegData[resindex].Reg[13]);
8311 temp = CHTVRegData[resindex].Reg[5]; 8158 SiS_SetCH701x(SiS_Pr,0x0f,CHTVRegData[resindex].Reg[14]);
8312 tempbx=((temp & 0x00FF) << 8) | 0x05; 8159 SiS_SetCH701x(SiS_Pr,0x10,CHTVRegData[resindex].Reg[15]);
8313 SiS_SetCH701x(SiS_Pr,tempbx); 8160
8314 8161 temp = SiS_GetCH701x(SiS_Pr,0x21) & ~0x02;
8315 temp = CHTVRegData[resindex].Reg[6]; 8162 /* D1 should be set for PAL, PAL-N and NTSC-J,
8316 tempbx=((temp & 0x00FF) << 8) | 0x06; 8163 but I won't do that for PAL unless somebody
8317 SiS_SetCH701x(SiS_Pr,tempbx); 8164 tells me to do so. Since the BIOS uses
8318 8165 non-default CIV values and blacklevels,
8319 temp = CHTVRegData[resindex].Reg[7]; 8166 this might be compensated anyway.
8320 if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) { 8167 */
8321 temp = 0x66; 8168 if(SiS_Pr->SiS_TVMode & (TVSetPALN | TVSetNTSCJ)) temp |= 0x02;
8322 } 8169 SiS_SetCH701x(SiS_Pr,0x21,temp);
8323 tempbx=((temp & 0x00FF) << 8) | 0x07;
8324 SiS_SetCH701x(SiS_Pr,tempbx);
8325
8326 temp = CHTVRegData[resindex].Reg[8];
8327 tempbx=((temp & 0x00FF) << 8) | 0x08;
8328 SiS_SetCH701x(SiS_Pr,tempbx);
8329
8330 temp = CHTVRegData[resindex].Reg[9];
8331 tempbx=((temp & 0x00FF) << 8) | 0x15;
8332 SiS_SetCH701x(SiS_Pr,tempbx);
8333
8334 temp = CHTVRegData[resindex].Reg[10];
8335 tempbx=((temp & 0x00FF) << 8) | 0x1f;
8336 SiS_SetCH701x(SiS_Pr,tempbx);
8337
8338 temp = CHTVRegData[resindex].Reg[11];
8339 tempbx=((temp & 0x00FF) << 8) | 0x0c;
8340 SiS_SetCH701x(SiS_Pr,tempbx);
8341
8342 temp = CHTVRegData[resindex].Reg[12];
8343 tempbx=((temp & 0x00FF) << 8) | 0x0d;
8344 SiS_SetCH701x(SiS_Pr,tempbx);
8345
8346 temp = CHTVRegData[resindex].Reg[13];
8347 tempbx=((temp & 0x00FF) << 8) | 0x0e;
8348 SiS_SetCH701x(SiS_Pr,tempbx);
8349
8350 temp = CHTVRegData[resindex].Reg[14];
8351 tempbx=((temp & 0x00FF) << 8) | 0x0f;
8352 SiS_SetCH701x(SiS_Pr,tempbx);
8353
8354 temp = CHTVRegData[resindex].Reg[15];
8355 tempbx=((temp & 0x00FF) << 8) | 0x10;
8356 SiS_SetCH701x(SiS_Pr,tempbx);
8357
8358 temp = SiS_GetCH701x(SiS_Pr,0x21) & ~0x02;
8359 /* D1 should be set for PAL, PAL-N and NTSC-J,
8360 but I won't do that for PAL unless somebody
8361 tells me to do so. Since the BIOS uses
8362 non-default CIV values and blacklevels,
8363 this might be compensated anyway.
8364 */
8365 if(SiS_Pr->SiS_TVMode & (TVSetPALN | TVSetNTSCJ)) temp |= 0x02;
8366 SiS_SetCH701x(SiS_Pr,((temp << 8) | 0x21));
8367 8170
8368#endif /* 315 */ 8171#endif /* 315 */
8369 8172
8370 } 8173 }
8371 8174
8372#ifdef SIS_CP 8175#ifdef SIS_CP
8373 SIS_CP_INIT301_CP3 8176 SIS_CP_INIT301_CP3
8374#endif 8177#endif
8375 8178
8376} 8179}
8377 8180
8181#ifdef SIS315H /* ----------- 315 series only ---------- */
8182
8378void 8183void
8379SiS_Chrontel701xBLOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 8184SiS_Chrontel701xBLOn(struct SiS_Private *SiS_Pr)
8380{ 8185{
8381 USHORT temp; 8186 unsigned short temp;
8382 8187
8383 /* Enable Chrontel 7019 LCD panel backlight */ 8188 /* Enable Chrontel 7019 LCD panel backlight */
8384 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { 8189 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
8385 if(HwInfo->jChipType == SIS_740) { 8190 if(SiS_Pr->ChipType == SIS_740) {
8386 SiS_SetCH701x(SiS_Pr,0x6566); 8191 SiS_SetCH701x(SiS_Pr,0x66,0x65);
8387 } else { 8192 } else {
8388 temp = SiS_GetCH701x(SiS_Pr,0x66); 8193 temp = SiS_GetCH701x(SiS_Pr,0x66);
8389 temp |= 0x20; 8194 temp |= 0x20;
8390 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66); 8195 SiS_SetCH701x(SiS_Pr,0x66,temp);
8391 } 8196 }
8392 } 8197 }
8393} 8198}
8394 8199
8395void 8200void
8396SiS_Chrontel701xBLOff(SiS_Private *SiS_Pr) 8201SiS_Chrontel701xBLOff(struct SiS_Private *SiS_Pr)
8397{ 8202{
8398 USHORT temp; 8203 unsigned short temp;
8399 8204
8400 /* Disable Chrontel 7019 LCD panel backlight */ 8205 /* Disable Chrontel 7019 LCD panel backlight */
8401 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { 8206 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
8402 temp = SiS_GetCH701x(SiS_Pr,0x66); 8207 temp = SiS_GetCH701x(SiS_Pr,0x66);
8403 temp &= 0xDF; 8208 temp &= 0xDF;
8404 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66); 8209 SiS_SetCH701x(SiS_Pr,0x66,temp);
8405 } 8210 }
8406} 8211}
8407 8212
8408#ifdef SIS315H /* ----------- 315 series only ---------- */
8409
8410static void 8213static void
8411SiS_ChrontelPowerSequencing(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 8214SiS_ChrontelPowerSequencing(struct SiS_Private *SiS_Pr)
8412{ 8215{
8413 UCHAR regtable[] = { 0x67, 0x68, 0x69, 0x6a, 0x6b }; 8216 static const unsigned char regtable[] = { 0x67, 0x68, 0x69, 0x6a, 0x6b };
8414 UCHAR table1024_740[] = { 0x01, 0x02, 0x01, 0x01, 0x01 }; 8217 static const unsigned char table1024_740[] = { 0x01, 0x02, 0x01, 0x01, 0x01 };
8415 UCHAR table1400_740[] = { 0x01, 0x6e, 0x01, 0x01, 0x01 }; 8218 static const unsigned char table1400_740[] = { 0x01, 0x6e, 0x01, 0x01, 0x01 };
8416 UCHAR asus1024_740[] = { 0x19, 0x6e, 0x01, 0x19, 0x09 }; 8219 static const unsigned char asus1024_740[] = { 0x19, 0x6e, 0x01, 0x19, 0x09 };
8417 UCHAR asus1400_740[] = { 0x19, 0x6e, 0x01, 0x19, 0x09 }; 8220 static const unsigned char asus1400_740[] = { 0x19, 0x6e, 0x01, 0x19, 0x09 };
8418 UCHAR table1024_650[] = { 0x01, 0x02, 0x01, 0x01, 0x02 }; 8221 static const unsigned char table1024_650[] = { 0x01, 0x02, 0x01, 0x01, 0x02 };
8419 UCHAR table1400_650[] = { 0x01, 0x02, 0x01, 0x01, 0x02 }; 8222 static const unsigned char table1400_650[] = { 0x01, 0x02, 0x01, 0x01, 0x02 };
8420 UCHAR *tableptr = NULL; 8223 const unsigned char *tableptr = NULL;
8421 int i; 8224 int i;
8422 8225
8423 /* Set up Power up/down timing */ 8226 /* Set up Power up/down timing */
8424 8227
8425 if(HwInfo->jChipType == SIS_740) { 8228 if(SiS_Pr->ChipType == SIS_740) {
8426 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { 8229 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) {
8427 if(SiS_Pr->SiS_CustomT == CUT_ASUSL3000D) tableptr = asus1024_740; 8230 if(SiS_Pr->SiS_CustomT == CUT_ASUSL3000D) tableptr = asus1024_740;
8428 else tableptr = table1024_740; 8231 else tableptr = table1024_740;
8429 } else if((SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) || 8232 } else if((SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) ||
8430 (SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) || 8233 (SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) ||
8431 (SiS_Pr->SiS_LCDResInfo == Panel_1600x1200)) { 8234 (SiS_Pr->SiS_LCDResInfo == Panel_1600x1200)) {
8432 if(SiS_Pr->SiS_CustomT == CUT_ASUSL3000D) tableptr = asus1400_740; 8235 if(SiS_Pr->SiS_CustomT == CUT_ASUSL3000D) tableptr = asus1400_740;
8433 else tableptr = table1400_740; 8236 else tableptr = table1400_740;
8434 } else return; 8237 } else return;
8435 } else { 8238 } else {
8436 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { 8239 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) {
8437 tableptr = table1024_650; 8240 tableptr = table1024_650;
8438 } else if((SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) || 8241 } else if((SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) ||
8439 (SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) || 8242 (SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) ||
8440 (SiS_Pr->SiS_LCDResInfo == Panel_1600x1200)) { 8243 (SiS_Pr->SiS_LCDResInfo == Panel_1600x1200)) {
8441 tableptr = table1400_650; 8244 tableptr = table1400_650;
8442 } else return; 8245 } else return;
8443 } 8246 }
8444 8247
8445 for(i=0; i<5; i++) { 8248 for(i=0; i<5; i++) {
8446 SiS_SetCH701x(SiS_Pr,(tableptr[i] << 8) | regtable[i]); 8249 SiS_SetCH701x(SiS_Pr, regtable[i], tableptr[i]);
8447 } 8250 }
8448} 8251}
8449 8252
8450static void 8253static void
8451SiS_SetCH701xForLCD(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 8254SiS_SetCH701xForLCD(struct SiS_Private *SiS_Pr)
8452{ 8255{
8453 UCHAR regtable[] = { 0x1c, 0x5f, 0x64, 0x6f, 0x70, 0x71, 8256 const unsigned char *tableptr = NULL;
8454 0x72, 0x73, 0x74, 0x76, 0x78, 0x7d, 0x66 }; 8257 unsigned short tempbh;
8455 UCHAR table1024_740[] = { 0x60, 0x02, 0x00, 0x07, 0x40, 0xed,
8456 0xa3, 0xc8, 0xc7, 0xac, 0xe0, 0x02, 0x44 };
8457 UCHAR table1280_740[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3,
8458 0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02, 0x44 };
8459 UCHAR table1400_740[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3,
8460 0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02, 0x44 };
8461 UCHAR table1600_740[] = { 0x60, 0x04, 0x11, 0x00, 0x40, 0xe3,
8462 0xad, 0xde, 0xf6, 0xac, 0x60, 0x1a, 0x44 };
8463 UCHAR table1024_650[] = { 0x60, 0x02, 0x00, 0x07, 0x40, 0xed,
8464 0xa3, 0xc8, 0xc7, 0xac, 0x60, 0x02 };
8465 UCHAR table1280_650[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3,
8466 0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02 };
8467 UCHAR table1400_650[] = { 0x60, 0x03, 0x11, 0x00, 0x40, 0xef,
8468 0xad, 0xdb, 0xf6, 0xac, 0x60, 0x02 };
8469 UCHAR table1600_650[] = { 0x60, 0x04, 0x11, 0x00, 0x40, 0xe3,
8470 0xad, 0xde, 0xf6, 0xac, 0x60, 0x1a };
8471 UCHAR *tableptr = NULL;
8472 USHORT tempbh;
8473 int i; 8258 int i;
8259 static const unsigned char regtable[] = {
8260 0x1c, 0x5f, 0x64, 0x6f, 0x70, 0x71,
8261 0x72, 0x73, 0x74, 0x76, 0x78, 0x7d, 0x66
8262 };
8263 static const unsigned char table1024_740[] = {
8264 0x60, 0x02, 0x00, 0x07, 0x40, 0xed,
8265 0xa3, 0xc8, 0xc7, 0xac, 0xe0, 0x02, 0x44
8266 };
8267 static const unsigned char table1280_740[] = {
8268 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3,
8269 0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02, 0x44
8270 };
8271 static const unsigned char table1400_740[] = {
8272 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3,
8273 0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02, 0x44
8274 };
8275 static const unsigned char table1600_740[] = {
8276 0x60, 0x04, 0x11, 0x00, 0x40, 0xe3,
8277 0xad, 0xde, 0xf6, 0xac, 0x60, 0x1a, 0x44
8278 };
8279 static const unsigned char table1024_650[] = {
8280 0x60, 0x02, 0x00, 0x07, 0x40, 0xed,
8281 0xa3, 0xc8, 0xc7, 0xac, 0x60, 0x02
8282 };
8283 static const unsigned char table1280_650[] = {
8284 0x60, 0x03, 0x11, 0x00, 0x40, 0xe3,
8285 0xad, 0xdb, 0xf6, 0xac, 0xe0, 0x02
8286 };
8287 static const unsigned char table1400_650[] = {
8288 0x60, 0x03, 0x11, 0x00, 0x40, 0xef,
8289 0xad, 0xdb, 0xf6, 0xac, 0x60, 0x02
8290 };
8291 static const unsigned char table1600_650[] = {
8292 0x60, 0x04, 0x11, 0x00, 0x40, 0xe3,
8293 0xad, 0xde, 0xf6, 0xac, 0x60, 0x1a
8294 };
8474 8295
8475 if(HwInfo->jChipType == SIS_740) { 8296 if(SiS_Pr->ChipType == SIS_740) {
8476 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) tableptr = table1024_740; 8297 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) tableptr = table1024_740;
8477 else if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) tableptr = table1280_740; 8298 else if(SiS_Pr->SiS_LCDResInfo == Panel_1280x1024) tableptr = table1280_740;
8478 else if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) tableptr = table1400_740; 8299 else if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) tableptr = table1400_740;
@@ -8499,138 +8320,139 @@ SiS_SetCH701xForLCD(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
8499 } 8320 }
8500 } 8321 }
8501 8322
8502 if(HwInfo->jChipType == SIS_740) tempbh = 0x0d; 8323 if(SiS_Pr->ChipType == SIS_740) tempbh = 0x0d;
8503 else tempbh = 0x0c; 8324 else tempbh = 0x0c;
8504 8325
8505 for(i = 0; i < tempbh; i++) { 8326 for(i = 0; i < tempbh; i++) {
8506 SiS_SetCH701x(SiS_Pr,(tableptr[i] << 8) | regtable[i]); 8327 SiS_SetCH701x(SiS_Pr, regtable[i], tableptr[i]);
8507 } 8328 }
8508 SiS_ChrontelPowerSequencing(SiS_Pr,HwInfo); 8329 SiS_ChrontelPowerSequencing(SiS_Pr);
8509 tempbh = SiS_GetCH701x(SiS_Pr,0x1e); 8330 tempbh = SiS_GetCH701x(SiS_Pr,0x1e);
8510 tempbh |= 0xc0; 8331 tempbh |= 0xc0;
8511 SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x1e); 8332 SiS_SetCH701x(SiS_Pr,0x1e,tempbh);
8512 8333
8513 if(HwInfo->jChipType == SIS_740) { 8334 if(SiS_Pr->ChipType == SIS_740) {
8514 tempbh = SiS_GetCH701x(SiS_Pr,0x1c); 8335 tempbh = SiS_GetCH701x(SiS_Pr,0x1c);
8515 tempbh &= 0xfb; 8336 tempbh &= 0xfb;
8516 SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x1c); 8337 SiS_SetCH701x(SiS_Pr,0x1c,tempbh);
8517 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2d,0x03); 8338 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2d,0x03);
8518 tempbh = SiS_GetCH701x(SiS_Pr,0x64); 8339 tempbh = SiS_GetCH701x(SiS_Pr,0x64);
8519 tempbh |= 0x40; 8340 tempbh |= 0x40;
8520 SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x64); 8341 SiS_SetCH701x(SiS_Pr,0x64,tempbh);
8521 tempbh = SiS_GetCH701x(SiS_Pr,0x03); 8342 tempbh = SiS_GetCH701x(SiS_Pr,0x03);
8522 tempbh &= 0x3f; 8343 tempbh &= 0x3f;
8523 SiS_SetCH701x(SiS_Pr,(tempbh << 8) | 0x03); 8344 SiS_SetCH701x(SiS_Pr,0x03,tempbh);
8524 } 8345 }
8525} 8346}
8526 8347
8527static void 8348static void
8528SiS_ChrontelResetVSync(SiS_Private *SiS_Pr) 8349SiS_ChrontelResetVSync(struct SiS_Private *SiS_Pr)
8529{ 8350{
8530 unsigned char temp, temp1; 8351 unsigned char temp, temp1;
8531 8352
8532 temp1 = SiS_GetCH701x(SiS_Pr,0x49); 8353 temp1 = SiS_GetCH701x(SiS_Pr,0x49);
8533 SiS_SetCH701x(SiS_Pr,0x3e49); 8354 SiS_SetCH701x(SiS_Pr,0x49,0x3e);
8534 temp = SiS_GetCH701x(SiS_Pr,0x47); 8355 temp = SiS_GetCH701x(SiS_Pr,0x47);
8535 temp &= 0x7f; /* Use external VSYNC */ 8356 temp &= 0x7f; /* Use external VSYNC */
8536 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); 8357 SiS_SetCH701x(SiS_Pr,0x47,temp);
8537 SiS_LongDelay(SiS_Pr,3); 8358 SiS_LongDelay(SiS_Pr, 3);
8538 temp = SiS_GetCH701x(SiS_Pr,0x47); 8359 temp = SiS_GetCH701x(SiS_Pr,0x47);
8539 temp |= 0x80; /* Use internal VSYNC */ 8360 temp |= 0x80; /* Use internal VSYNC */
8540 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); 8361 SiS_SetCH701x(SiS_Pr,0x47,temp);
8541 SiS_SetCH701x(SiS_Pr,(temp1 << 8) | 0x49); 8362 SiS_SetCH701x(SiS_Pr,0x49,temp1);
8542} 8363}
8543 8364
8544static void 8365static void
8545SiS_Chrontel701xOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 8366SiS_Chrontel701xOn(struct SiS_Private *SiS_Pr)
8546{ 8367{
8547 USHORT temp; 8368 unsigned short temp;
8548 8369
8549 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { 8370 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
8550 if(HwInfo->jChipType == SIS_740) { 8371 if(SiS_Pr->ChipType == SIS_740) {
8551 temp = SiS_GetCH701x(SiS_Pr,0x1c); 8372 temp = SiS_GetCH701x(SiS_Pr,0x1c);
8552 temp |= 0x04; /* Invert XCLK phase */ 8373 temp |= 0x04; /* Invert XCLK phase */
8553 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x1c); 8374 SiS_SetCH701x(SiS_Pr,0x1c,temp);
8554 } 8375 }
8555 if(SiS_IsYPbPr(SiS_Pr, HwInfo)) { 8376 if(SiS_IsYPbPr(SiS_Pr)) {
8556 temp = SiS_GetCH701x(SiS_Pr,0x01); 8377 temp = SiS_GetCH701x(SiS_Pr,0x01);
8557 temp &= 0x3f; 8378 temp &= 0x3f;
8558 temp |= 0x80; /* Enable YPrPb (HDTV) */ 8379 temp |= 0x80; /* Enable YPrPb (HDTV) */
8559 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x01); 8380 SiS_SetCH701x(SiS_Pr,0x01,temp);
8560 } 8381 }
8561 if(SiS_IsChScart(SiS_Pr, HwInfo)) { 8382 if(SiS_IsChScart(SiS_Pr)) {
8562 temp = SiS_GetCH701x(SiS_Pr,0x01); 8383 temp = SiS_GetCH701x(SiS_Pr,0x01);
8563 temp &= 0x3f; 8384 temp &= 0x3f;
8564 temp |= 0xc0; /* Enable SCART + CVBS */ 8385 temp |= 0xc0; /* Enable SCART + CVBS */
8565 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x01); 8386 SiS_SetCH701x(SiS_Pr,0x01,temp);
8566 } 8387 }
8567 if(HwInfo->jChipType == SIS_740) { 8388 if(SiS_Pr->ChipType == SIS_740) {
8568 SiS_ChrontelResetVSync(SiS_Pr); 8389 SiS_ChrontelResetVSync(SiS_Pr);
8569 SiS_SetCH701x(SiS_Pr,0x2049); /* Enable TV path */ 8390 SiS_SetCH701x(SiS_Pr,0x49,0x20); /* Enable TV path */
8570 } else { 8391 } else {
8571 SiS_SetCH701x(SiS_Pr,0x2049); /* Enable TV path */ 8392 SiS_SetCH701x(SiS_Pr,0x49,0x20); /* Enable TV path */
8572 temp = SiS_GetCH701x(SiS_Pr,0x49); 8393 temp = SiS_GetCH701x(SiS_Pr,0x49);
8573 if(SiS_IsYPbPr(SiS_Pr,HwInfo)) { 8394 if(SiS_IsYPbPr(SiS_Pr)) {
8574 temp = SiS_GetCH701x(SiS_Pr,0x73); 8395 temp = SiS_GetCH701x(SiS_Pr,0x73);
8575 temp |= 0x60; 8396 temp |= 0x60;
8576 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x73); 8397 SiS_SetCH701x(SiS_Pr,0x73,temp);
8577 } 8398 }
8578 temp = SiS_GetCH701x(SiS_Pr,0x47); 8399 temp = SiS_GetCH701x(SiS_Pr,0x47);
8579 temp &= 0x7f; 8400 temp &= 0x7f;
8580 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); 8401 SiS_SetCH701x(SiS_Pr,0x47,temp);
8581 SiS_LongDelay(SiS_Pr,2); 8402 SiS_LongDelay(SiS_Pr, 2);
8582 temp = SiS_GetCH701x(SiS_Pr,0x47); 8403 temp = SiS_GetCH701x(SiS_Pr,0x47);
8583 temp |= 0x80; 8404 temp |= 0x80;
8584 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); 8405 SiS_SetCH701x(SiS_Pr,0x47,temp);
8585 } 8406 }
8586 } 8407 }
8587} 8408}
8588 8409
8589static void 8410static void
8590SiS_Chrontel701xOff(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 8411SiS_Chrontel701xOff(struct SiS_Private *SiS_Pr)
8591{ 8412{
8592 USHORT temp; 8413 unsigned short temp;
8593 8414
8594 /* Complete power down of LVDS */ 8415 /* Complete power down of LVDS */
8595 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { 8416 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
8596 if(HwInfo->jChipType == SIS_740) { 8417 if(SiS_Pr->ChipType == SIS_740) {
8597 SiS_LongDelay(SiS_Pr,1); 8418 SiS_LongDelay(SiS_Pr, 1);
8598 SiS_GenericDelay(SiS_Pr,0x16ff); 8419 SiS_GenericDelay(SiS_Pr, 5887);
8599 SiS_SetCH701x(SiS_Pr,0xac76); 8420 SiS_SetCH701x(SiS_Pr,0x76,0xac);
8600 SiS_SetCH701x(SiS_Pr,0x0066); 8421 SiS_SetCH701x(SiS_Pr,0x66,0x00);
8601 } else { 8422 } else {
8602 SiS_LongDelay(SiS_Pr,2); 8423 SiS_LongDelay(SiS_Pr, 2);
8603 temp = SiS_GetCH701x(SiS_Pr,0x76); 8424 temp = SiS_GetCH701x(SiS_Pr,0x76);
8604 temp &= 0xfc; 8425 temp &= 0xfc;
8605 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76); 8426 SiS_SetCH701x(SiS_Pr,0x76,temp);
8606 SiS_SetCH701x(SiS_Pr,0x0066); 8427 SiS_SetCH701x(SiS_Pr,0x66,0x00);
8607 } 8428 }
8608 } 8429 }
8609} 8430}
8610 8431
8611static void 8432static void
8612SiS_ChrontelResetDB(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 8433SiS_ChrontelResetDB(struct SiS_Private *SiS_Pr)
8613{ 8434{
8614 USHORT temp; 8435 unsigned short temp;
8615 8436
8616 if(HwInfo->jChipType == SIS_740) { 8437 if(SiS_Pr->ChipType == SIS_740) {
8617 8438
8618 temp = SiS_GetCH701x(SiS_Pr,0x4a); /* Version ID */ 8439 temp = SiS_GetCH701x(SiS_Pr,0x4a); /* Version ID */
8619 temp &= 0x01; 8440 temp &= 0x01;
8620 if(!temp) { 8441 if(!temp) {
8621 8442
8622 if(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo)) { 8443 if(SiS_WeHaveBacklightCtrl(SiS_Pr)) {
8623 temp = SiS_GetCH701x(SiS_Pr,0x49); 8444 temp = SiS_GetCH701x(SiS_Pr,0x49);
8624 SiS_SetCH701x(SiS_Pr,0x3e49); 8445 SiS_SetCH701x(SiS_Pr,0x49,0x3e);
8625 } 8446 }
8447
8626 /* Reset Chrontel 7019 datapath */ 8448 /* Reset Chrontel 7019 datapath */
8627 SiS_SetCH701x(SiS_Pr,0x1048); 8449 SiS_SetCH701x(SiS_Pr,0x48,0x10);
8628 SiS_LongDelay(SiS_Pr,1); 8450 SiS_LongDelay(SiS_Pr, 1);
8629 SiS_SetCH701x(SiS_Pr,0x1848); 8451 SiS_SetCH701x(SiS_Pr,0x48,0x18);
8630 8452
8631 if(SiS_WeHaveBacklightCtrl(SiS_Pr, HwInfo)) { 8453 if(SiS_WeHaveBacklightCtrl(SiS_Pr)) {
8632 SiS_ChrontelResetVSync(SiS_Pr); 8454 SiS_ChrontelResetVSync(SiS_Pr);
8633 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x49); 8455 SiS_SetCH701x(SiS_Pr,0x49,temp);
8634 } 8456 }
8635 8457
8636 } else { 8458 } else {
@@ -8638,72 +8460,72 @@ SiS_ChrontelResetDB(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
8638 /* Clear/set/clear GPIO */ 8460 /* Clear/set/clear GPIO */
8639 temp = SiS_GetCH701x(SiS_Pr,0x5c); 8461 temp = SiS_GetCH701x(SiS_Pr,0x5c);
8640 temp &= 0xef; 8462 temp &= 0xef;
8641 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x5c); 8463 SiS_SetCH701x(SiS_Pr,0x5c,temp);
8642 temp = SiS_GetCH701x(SiS_Pr,0x5c); 8464 temp = SiS_GetCH701x(SiS_Pr,0x5c);
8643 temp |= 0x10; 8465 temp |= 0x10;
8644 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x5c); 8466 SiS_SetCH701x(SiS_Pr,0x5c,temp);
8645 temp = SiS_GetCH701x(SiS_Pr,0x5c); 8467 temp = SiS_GetCH701x(SiS_Pr,0x5c);
8646 temp &= 0xef; 8468 temp &= 0xef;
8647 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x5c); 8469 SiS_SetCH701x(SiS_Pr,0x5c,temp);
8648 temp = SiS_GetCH701x(SiS_Pr,0x61); 8470 temp = SiS_GetCH701x(SiS_Pr,0x61);
8649 if(!temp) { 8471 if(!temp) {
8650 SiS_SetCH701xForLCD(SiS_Pr, HwInfo); 8472 SiS_SetCH701xForLCD(SiS_Pr);
8651 } 8473 }
8652 } 8474 }
8653 8475
8654 } else { /* 650 */ 8476 } else { /* 650 */
8655 /* Reset Chrontel 7019 datapath */ 8477 /* Reset Chrontel 7019 datapath */
8656 SiS_SetCH701x(SiS_Pr,0x1048); 8478 SiS_SetCH701x(SiS_Pr,0x48,0x10);
8657 SiS_LongDelay(SiS_Pr,1); 8479 SiS_LongDelay(SiS_Pr, 1);
8658 SiS_SetCH701x(SiS_Pr,0x1848); 8480 SiS_SetCH701x(SiS_Pr,0x48,0x18);
8659 } 8481 }
8660} 8482}
8661 8483
8662static void 8484static void
8663SiS_ChrontelInitTVVSync(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 8485SiS_ChrontelInitTVVSync(struct SiS_Private *SiS_Pr)
8664{ 8486{
8665 USHORT temp; 8487 unsigned short temp;
8666 8488
8667 if(HwInfo->jChipType == SIS_740) { 8489 if(SiS_Pr->ChipType == SIS_740) {
8668 8490
8669 if(SiS_WeHaveBacklightCtrl(SiS_Pr,HwInfo)) { 8491 if(SiS_WeHaveBacklightCtrl(SiS_Pr)) {
8670 SiS_ChrontelResetVSync(SiS_Pr); 8492 SiS_ChrontelResetVSync(SiS_Pr);
8671 } 8493 }
8672 8494
8673 } else { 8495 } else {
8674 8496
8675 SiS_SetCH701x(SiS_Pr,0xaf76); /* Power up LVDS block */ 8497 SiS_SetCH701x(SiS_Pr,0x76,0xaf); /* Power up LVDS block */
8676 temp = SiS_GetCH701x(SiS_Pr,0x49); 8498 temp = SiS_GetCH701x(SiS_Pr,0x49);
8677 temp &= 1; 8499 temp &= 1;
8678 if(temp != 1) { /* TV block powered? (0 = yes, 1 = no) */ 8500 if(temp != 1) { /* TV block powered? (0 = yes, 1 = no) */
8679 temp = SiS_GetCH701x(SiS_Pr,0x47); 8501 temp = SiS_GetCH701x(SiS_Pr,0x47);
8680 temp &= 0x70; 8502 temp &= 0x70;
8681 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); /* enable VSYNC */ 8503 SiS_SetCH701x(SiS_Pr,0x47,temp); /* enable VSYNC */
8682 SiS_LongDelay(SiS_Pr,3); 8504 SiS_LongDelay(SiS_Pr, 3);
8683 temp = SiS_GetCH701x(SiS_Pr,0x47); 8505 temp = SiS_GetCH701x(SiS_Pr,0x47);
8684 temp |= 0x80; 8506 temp |= 0x80;
8685 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x47); /* disable VSYNC */ 8507 SiS_SetCH701x(SiS_Pr,0x47,temp); /* disable VSYNC */
8686 } 8508 }
8687 8509
8688 } 8510 }
8689} 8511}
8690 8512
8691static void 8513static void
8692SiS_ChrontelDoSomething3(SiS_Private *SiS_Pr, USHORT ModeNo, PSIS_HW_INFO HwInfo) 8514SiS_ChrontelDoSomething3(struct SiS_Private *SiS_Pr, unsigned short ModeNo)
8693{ 8515{
8694 USHORT temp,temp1; 8516 unsigned short temp,temp1;
8695 8517
8696 if(HwInfo->jChipType == SIS_740) { 8518 if(SiS_Pr->ChipType == SIS_740) {
8697 8519
8698 temp = SiS_GetCH701x(SiS_Pr,0x61); 8520 temp = SiS_GetCH701x(SiS_Pr,0x61);
8699 if(temp < 1) { 8521 if(temp < 1) {
8700 temp++; 8522 temp++;
8701 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x61); 8523 SiS_SetCH701x(SiS_Pr,0x61,temp);
8702 } 8524 }
8703 SiS_SetCH701x(SiS_Pr,0x4566); /* Panel power on */ 8525 SiS_SetCH701x(SiS_Pr,0x66,0x45); /* Panel power on */
8704 SiS_SetCH701x(SiS_Pr,0xaf76); /* All power on */ 8526 SiS_SetCH701x(SiS_Pr,0x76,0xaf); /* All power on */
8705 SiS_LongDelay(SiS_Pr,1); 8527 SiS_LongDelay(SiS_Pr, 1);
8706 SiS_GenericDelay(SiS_Pr,0x16ff); 8528 SiS_GenericDelay(SiS_Pr, 5887);
8707 8529
8708 } else { /* 650 */ 8530 } else { /* 650 */
8709 8531
@@ -8711,38 +8533,38 @@ SiS_ChrontelDoSomething3(SiS_Private *SiS_Pr, USHORT ModeNo, PSIS_HW_INFO HwInfo
8711 temp = SiS_GetCH701x(SiS_Pr,0x61); 8533 temp = SiS_GetCH701x(SiS_Pr,0x61);
8712 if(temp < 2) { 8534 if(temp < 2) {
8713 temp++; 8535 temp++;
8714 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x61); 8536 SiS_SetCH701x(SiS_Pr,0x61,temp);
8715 temp1 = 1; 8537 temp1 = 1;
8716 } 8538 }
8717 SiS_SetCH701x(SiS_Pr,0xac76); 8539 SiS_SetCH701x(SiS_Pr,0x76,0xac);
8718 temp = SiS_GetCH701x(SiS_Pr,0x66); 8540 temp = SiS_GetCH701x(SiS_Pr,0x66);
8719 temp |= 0x5f; 8541 temp |= 0x5f;
8720 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66); 8542 SiS_SetCH701x(SiS_Pr,0x66,temp);
8721 if(ModeNo > 0x13) { 8543 if(ModeNo > 0x13) {
8722 if(SiS_WeHaveBacklightCtrl(SiS_Pr, HwInfo)) { 8544 if(SiS_WeHaveBacklightCtrl(SiS_Pr)) {
8723 SiS_GenericDelay(SiS_Pr,0x3ff); 8545 SiS_GenericDelay(SiS_Pr, 1023);
8724 } else { 8546 } else {
8725 SiS_GenericDelay(SiS_Pr,0x2ff); 8547 SiS_GenericDelay(SiS_Pr, 767);
8726 } 8548 }
8727 } else { 8549 } else {
8728 if(!temp1) 8550 if(!temp1)
8729 SiS_GenericDelay(SiS_Pr,0x2ff); 8551 SiS_GenericDelay(SiS_Pr, 767);
8730 } 8552 }
8731 temp = SiS_GetCH701x(SiS_Pr,0x76); 8553 temp = SiS_GetCH701x(SiS_Pr,0x76);
8732 temp |= 0x03; 8554 temp |= 0x03;
8733 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76); 8555 SiS_SetCH701x(SiS_Pr,0x76,temp);
8734 temp = SiS_GetCH701x(SiS_Pr,0x66); 8556 temp = SiS_GetCH701x(SiS_Pr,0x66);
8735 temp &= 0x7f; 8557 temp &= 0x7f;
8736 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x66); 8558 SiS_SetCH701x(SiS_Pr,0x66,temp);
8737 SiS_LongDelay(SiS_Pr,1); 8559 SiS_LongDelay(SiS_Pr, 1);
8738 8560
8739 } 8561 }
8740} 8562}
8741 8563
8742static void 8564static void
8743SiS_ChrontelDoSomething2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 8565SiS_ChrontelDoSomething2(struct SiS_Private *SiS_Pr)
8744{ 8566{
8745 USHORT temp,tempcl,tempch; 8567 unsigned short temp,tempcl,tempch;
8746 8568
8747 SiS_LongDelay(SiS_Pr, 1); 8569 SiS_LongDelay(SiS_Pr, 1);
8748 tempcl = 3; 8570 tempcl = 3;
@@ -8753,87 +8575,87 @@ SiS_ChrontelDoSomething2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
8753 temp &= 0x04; /* PLL stable? -> bail out */ 8575 temp &= 0x04; /* PLL stable? -> bail out */
8754 if(temp == 0x04) break; 8576 if(temp == 0x04) break;
8755 8577
8756 if(HwInfo->jChipType == SIS_740) { 8578 if(SiS_Pr->ChipType == SIS_740) {
8757 /* Power down LVDS output, PLL normal operation */ 8579 /* Power down LVDS output, PLL normal operation */
8758 SiS_SetCH701x(SiS_Pr,0xac76); 8580 SiS_SetCH701x(SiS_Pr,0x76,0xac);
8759 } 8581 }
8760 8582
8761 SiS_SetCH701xForLCD(SiS_Pr,HwInfo); 8583 SiS_SetCH701xForLCD(SiS_Pr);
8762 8584
8763 if(tempcl == 0) { 8585 if(tempcl == 0) {
8764 if(tempch == 3) break; 8586 if(tempch == 3) break;
8765 SiS_ChrontelResetDB(SiS_Pr,HwInfo); 8587 SiS_ChrontelResetDB(SiS_Pr);
8766 tempcl = 3; 8588 tempcl = 3;
8767 tempch++; 8589 tempch++;
8768 } 8590 }
8769 tempcl--; 8591 tempcl--;
8770 temp = SiS_GetCH701x(SiS_Pr,0x76); 8592 temp = SiS_GetCH701x(SiS_Pr,0x76);
8771 temp &= 0xfb; /* Reset PLL */ 8593 temp &= 0xfb; /* Reset PLL */
8772 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76); 8594 SiS_SetCH701x(SiS_Pr,0x76,temp);
8773 SiS_LongDelay(SiS_Pr,2); 8595 SiS_LongDelay(SiS_Pr, 2);
8774 temp = SiS_GetCH701x(SiS_Pr,0x76); 8596 temp = SiS_GetCH701x(SiS_Pr,0x76);
8775 temp |= 0x04; /* PLL normal operation */ 8597 temp |= 0x04; /* PLL normal operation */
8776 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x76); 8598 SiS_SetCH701x(SiS_Pr,0x76,temp);
8777 if(HwInfo->jChipType == SIS_740) { 8599 if(SiS_Pr->ChipType == SIS_740) {
8778 SiS_SetCH701x(SiS_Pr,0xe078); /* PLL loop filter */ 8600 SiS_SetCH701x(SiS_Pr,0x78,0xe0); /* PLL loop filter */
8779 } else { 8601 } else {
8780 SiS_SetCH701x(SiS_Pr,0x6078); 8602 SiS_SetCH701x(SiS_Pr,0x78,0x60);
8781 } 8603 }
8782 SiS_LongDelay(SiS_Pr,2); 8604 SiS_LongDelay(SiS_Pr, 2);
8783 } while(0); 8605 } while(0);
8784 8606
8785 SiS_SetCH701x(SiS_Pr,0x0077); /* MV? */ 8607 SiS_SetCH701x(SiS_Pr,0x77,0x00); /* MV? */
8786} 8608}
8787 8609
8788static void 8610static void
8789SiS_ChrontelDoSomething1(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 8611SiS_ChrontelDoSomething1(struct SiS_Private *SiS_Pr)
8790{ 8612{
8791 USHORT temp; 8613 unsigned short temp;
8792 8614
8793 temp = SiS_GetCH701x(SiS_Pr,0x03); 8615 temp = SiS_GetCH701x(SiS_Pr,0x03);
8794 temp |= 0x80; /* Set datapath 1 to TV */ 8616 temp |= 0x80; /* Set datapath 1 to TV */
8795 temp &= 0xbf; /* Set datapath 2 to LVDS */ 8617 temp &= 0xbf; /* Set datapath 2 to LVDS */
8796 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x03); 8618 SiS_SetCH701x(SiS_Pr,0x03,temp);
8797 8619
8798 if(HwInfo->jChipType == SIS_740) { 8620 if(SiS_Pr->ChipType == SIS_740) {
8799 8621
8800 temp = SiS_GetCH701x(SiS_Pr,0x1c); 8622 temp = SiS_GetCH701x(SiS_Pr,0x1c);
8801 temp &= 0xfb; /* Normal XCLK phase */ 8623 temp &= 0xfb; /* Normal XCLK phase */
8802 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x1c); 8624 SiS_SetCH701x(SiS_Pr,0x1c,temp);
8803 8625
8804 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2d,0x03); 8626 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x2d,0x03);
8805 8627
8806 temp = SiS_GetCH701x(SiS_Pr,0x64); 8628 temp = SiS_GetCH701x(SiS_Pr,0x64);
8807 temp |= 0x40; /* ? Bit not defined */ 8629 temp |= 0x40; /* ? Bit not defined */
8808 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x64); 8630 SiS_SetCH701x(SiS_Pr,0x64,temp);
8809 8631
8810 temp = SiS_GetCH701x(SiS_Pr,0x03); 8632 temp = SiS_GetCH701x(SiS_Pr,0x03);
8811 temp &= 0x3f; /* D1 input to both LVDS and TV */ 8633 temp &= 0x3f; /* D1 input to both LVDS and TV */
8812 SiS_SetCH701x(SiS_Pr,(temp << 8) | 0x03); 8634 SiS_SetCH701x(SiS_Pr,0x03,temp);
8813 8635
8814 if(SiS_Pr->SiS_CustomT == CUT_ASUSL3000D) { 8636 if(SiS_Pr->SiS_CustomT == CUT_ASUSL3000D) {
8815 SiS_SetCH701x(SiS_Pr,0x4063); /* LVDS off */ 8637 SiS_SetCH701x(SiS_Pr,0x63,0x40); /* LVDS off */
8816 SiS_LongDelay(SiS_Pr, 1); 8638 SiS_LongDelay(SiS_Pr, 1);
8817 SiS_SetCH701x(SiS_Pr,0x0063); /* LVDS on */ 8639 SiS_SetCH701x(SiS_Pr,0x63,0x00); /* LVDS on */
8818 SiS_ChrontelResetDB(SiS_Pr, HwInfo); 8640 SiS_ChrontelResetDB(SiS_Pr);
8819 SiS_ChrontelDoSomething2(SiS_Pr, HwInfo); 8641 SiS_ChrontelDoSomething2(SiS_Pr);
8820 SiS_ChrontelDoSomething3(SiS_Pr, 0, HwInfo); 8642 SiS_ChrontelDoSomething3(SiS_Pr, 0);
8821 } else { 8643 } else {
8822 temp = SiS_GetCH701x(SiS_Pr,0x66); 8644 temp = SiS_GetCH701x(SiS_Pr,0x66);
8823 if(temp != 0x45) { 8645 if(temp != 0x45) {
8824 SiS_ChrontelResetDB(SiS_Pr, HwInfo); 8646 SiS_ChrontelResetDB(SiS_Pr);
8825 SiS_ChrontelDoSomething2(SiS_Pr, HwInfo); 8647 SiS_ChrontelDoSomething2(SiS_Pr);
8826 SiS_ChrontelDoSomething3(SiS_Pr, 0, HwInfo); 8648 SiS_ChrontelDoSomething3(SiS_Pr, 0);
8827 } 8649 }
8828 } 8650 }
8829 8651
8830 } else { /* 650 */ 8652 } else { /* 650 */
8831 8653
8832 SiS_ChrontelResetDB(SiS_Pr,HwInfo); 8654 SiS_ChrontelResetDB(SiS_Pr);
8833 SiS_ChrontelDoSomething2(SiS_Pr,HwInfo); 8655 SiS_ChrontelDoSomething2(SiS_Pr);
8834 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x34); 8656 temp = SiS_GetReg(SiS_Pr->SiS_P3d4,0x34);
8835 SiS_ChrontelDoSomething3(SiS_Pr,temp,HwInfo); 8657 SiS_ChrontelDoSomething3(SiS_Pr,temp);
8836 SiS_SetCH701x(SiS_Pr,0xaf76); /* All power on, LVDS normal operation */ 8658 SiS_SetCH701x(SiS_Pr,0x76,0xaf); /* All power on, LVDS normal operation */
8837 8659
8838 } 8660 }
8839 8661
@@ -8845,15 +8667,12 @@ SiS_ChrontelDoSomething1(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
8845/*********************************************/ 8667/*********************************************/
8846 8668
8847BOOLEAN 8669BOOLEAN
8848SiS_SetCRT2Group(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) 8670SiS_SetCRT2Group(struct SiS_Private *SiS_Pr, unsigned short ModeNo)
8849{ 8671{
8850#ifdef SIS300 8672#ifdef SIS300
8851 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; 8673 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
8852#endif
8853 USHORT ModeIdIndex, RefreshRateTableIndex;
8854#if 0
8855 USHORT temp;
8856#endif 8674#endif
8675 unsigned short ModeIdIndex, RefreshRateTableIndex;
8857 8676
8858 SiS_Pr->SiS_SetFlag |= ProgrammingCRT2; 8677 SiS_Pr->SiS_SetFlag |= ProgrammingCRT2;
8859 8678
@@ -8866,37 +8685,37 @@ SiS_SetCRT2Group(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo)
8866 /* Used for shifting CR33 */ 8685 /* Used for shifting CR33 */
8867 SiS_Pr->SiS_SelectCRT2Rate = 4; 8686 SiS_Pr->SiS_SelectCRT2Rate = 4;
8868 8687
8869 SiS_UnLockCRT2(SiS_Pr, HwInfo); 8688 SiS_UnLockCRT2(SiS_Pr);
8870 8689
8871 RefreshRateTableIndex = SiS_GetRatePtr(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); 8690 RefreshRateTableIndex = SiS_GetRatePtr(SiS_Pr, ModeNo, ModeIdIndex);
8872 8691
8873 SiS_SaveCRT2Info(SiS_Pr,ModeNo); 8692 SiS_SaveCRT2Info(SiS_Pr,ModeNo);
8874 8693
8875 if(SiS_Pr->SiS_SetFlag & LowModeTests) { 8694 if(SiS_Pr->SiS_SetFlag & LowModeTests) {
8876 SiS_DisableBridge(SiS_Pr,HwInfo); 8695 SiS_DisableBridge(SiS_Pr);
8877 if((SiS_Pr->SiS_IF_DEF_LVDS == 1) && (HwInfo->jChipType == SIS_730)) { 8696 if((SiS_Pr->SiS_IF_DEF_LVDS == 1) && (SiS_Pr->ChipType == SIS_730)) {
8878 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,0x80); 8697 SiS_SetReg(SiS_Pr->SiS_Part1Port,0x00,0x80);
8879 } 8698 }
8880 SiS_SetCRT2ModeRegs(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); 8699 SiS_SetCRT2ModeRegs(SiS_Pr, ModeNo, ModeIdIndex);
8881 } 8700 }
8882 8701
8883 if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) { 8702 if(SiS_Pr->SiS_VBInfo & DisableCRT2Display) {
8884 SiS_LockCRT2(SiS_Pr, HwInfo); 8703 SiS_LockCRT2(SiS_Pr);
8885 SiS_DisplayOn(SiS_Pr); 8704 SiS_DisplayOn(SiS_Pr);
8886 return TRUE; 8705 return TRUE;
8887 } 8706 }
8888 8707
8889 SiS_GetCRT2Data(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); 8708 SiS_GetCRT2Data(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
8890 8709
8891 /* Set up Panel Link for LVDS and LCDA */ 8710 /* Set up Panel Link for LVDS and LCDA */
8892 SiS_Pr->SiS_LCDHDES = SiS_Pr->SiS_LCDVDES = 0; 8711 SiS_Pr->SiS_LCDHDES = SiS_Pr->SiS_LCDVDES = 0;
8893 if( (SiS_Pr->SiS_IF_DEF_LVDS == 1) || 8712 if( (SiS_Pr->SiS_IF_DEF_LVDS == 1) ||
8894 ((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) || 8713 ((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) ||
8895 ((HwInfo->jChipType >= SIS_315H) && (SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) ) { 8714 ((SiS_Pr->ChipType >= SIS_315H) && (SiS_Pr->SiS_VBType & VB_SIS30xBLV)) ) {
8896 SiS_GetLVDSDesData(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); 8715 SiS_GetLVDSDesData(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
8897 } 8716 }
8898 8717
8899#ifdef LINUX_XF86 8718#ifdef SIS_XORG_XF86
8900#ifdef TWDEBUG 8719#ifdef TWDEBUG
8901 xf86DrvMsg(0, X_INFO, "(init301: LCDHDES 0x%03x LCDVDES 0x%03x)\n", SiS_Pr->SiS_LCDHDES, SiS_Pr->SiS_LCDVDES); 8720 xf86DrvMsg(0, X_INFO, "(init301: LCDHDES 0x%03x LCDVDES 0x%03x)\n", SiS_Pr->SiS_LCDHDES, SiS_Pr->SiS_LCDVDES);
8902 xf86DrvMsg(0, X_INFO, "(init301: HDE 0x%03x VDE 0x%03x)\n", SiS_Pr->SiS_HDE, SiS_Pr->SiS_VDE); 8721 xf86DrvMsg(0, X_INFO, "(init301: HDE 0x%03x VDE 0x%03x)\n", SiS_Pr->SiS_HDE, SiS_Pr->SiS_VDE);
@@ -8907,86 +8726,79 @@ SiS_SetCRT2Group(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo)
8907#endif 8726#endif
8908 8727
8909 if(SiS_Pr->SiS_SetFlag & LowModeTests) { 8728 if(SiS_Pr->SiS_SetFlag & LowModeTests) {
8910 SiS_SetGroup1(SiS_Pr, ModeNo, ModeIdIndex, HwInfo, RefreshRateTableIndex); 8729 SiS_SetGroup1(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
8911 } 8730 }
8912 8731
8913 if(SiS_Pr->SiS_VBType & VB_SISVB) { 8732 if(SiS_Pr->SiS_VBType & VB_SISVB) {
8914 8733
8915 if(SiS_Pr->SiS_SetFlag & LowModeTests) { 8734 if(SiS_Pr->SiS_SetFlag & LowModeTests) {
8916 8735
8917 SiS_SetGroup2(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); 8736 SiS_SetGroup2(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
8918#ifdef SIS315H 8737#ifdef SIS315H
8919 SiS_SetGroup2_C_ELV(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); 8738 SiS_SetGroup2_C_ELV(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
8920#endif 8739#endif
8921 SiS_SetGroup3(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); 8740 SiS_SetGroup3(SiS_Pr, ModeNo, ModeIdIndex);
8922 SiS_SetGroup4(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex, HwInfo); 8741 SiS_SetGroup4(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
8923#ifdef SIS315H 8742#ifdef SIS315H
8924 SiS_SetGroup4_C_ELV(SiS_Pr, HwInfo, ModeNo, ModeIdIndex); 8743 SiS_SetGroup4_C_ELV(SiS_Pr, ModeNo, ModeIdIndex);
8925#endif 8744#endif
8926 SiS_SetGroup5(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); 8745 SiS_SetGroup5(SiS_Pr, ModeNo, ModeIdIndex);
8927 8746
8928 SiS_SetCRT2Sync(SiS_Pr, ModeNo, RefreshRateTableIndex, HwInfo); 8747 SiS_SetCRT2Sync(SiS_Pr, ModeNo, RefreshRateTableIndex);
8929 8748
8930 /* For 301BDH (Panel link initialization): */ 8749 /* For 301BDH (Panel link initialization): */
8931 if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) { 8750 if((SiS_Pr->SiS_VBType & VB_NoLCD) && (SiS_Pr->SiS_VBInfo & SetCRT2ToLCD)) {
8932 if(SiS_Pr->SiS_LCDResInfo != Panel_640x480) { 8751
8933 if(!((SiS_Pr->SiS_SetFlag & SetDOSMode) && ((ModeNo == 0x03) || (ModeNo == 0x10)))) { 8752 if(!((SiS_Pr->SiS_SetFlag & SetDOSMode) && ((ModeNo == 0x03) || (ModeNo == 0x10)))) {
8934 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) { 8753 if(SiS_Pr->SiS_VBInfo & SetInSlaveMode) {
8935 SiS_ModCRT1CRTC(SiS_Pr,ModeNo,ModeIdIndex, 8754 SiS_ModCRT1CRTC(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
8936 RefreshRateTableIndex,HwInfo); 8755 }
8937 } 8756 }
8938 } 8757 SiS_SetCRT2ECLK(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
8939 } 8758 }
8940 SiS_SetCRT2ECLK(SiS_Pr,ModeNo,ModeIdIndex, 8759 }
8941 RefreshRateTableIndex,HwInfo);
8942 }
8943 }
8944 8760
8945 } else { 8761 } else {
8946 8762
8947 SiS_SetCRT2Sync(SiS_Pr, ModeNo, RefreshRateTableIndex, HwInfo); 8763 SiS_SetCRT2Sync(SiS_Pr, ModeNo, RefreshRateTableIndex);
8948 8764
8949 if(!(SiS_Pr->SiS_LCDInfo & LCDPass11)) { 8765 SiS_ModCRT1CRTC(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex);
8950 SiS_ModCRT1CRTC(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex,HwInfo);
8951 }
8952 8766
8953 SiS_SetCRT2ECLK(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex,HwInfo); 8767 SiS_SetCRT2ECLK(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex);
8954 8768
8955 if(SiS_Pr->SiS_SetFlag & LowModeTests) { 8769 if(SiS_Pr->SiS_SetFlag & LowModeTests) {
8956 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) { 8770 if(SiS_Pr->SiS_IF_DEF_CH70xx != 0) {
8957 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { 8771 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
8958 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) { 8772 if(SiS_Pr->SiS_IF_DEF_CH70xx == 2) {
8959#ifdef SIS315H 8773#ifdef SIS315H
8960 SiS_SetCH701xForLCD(SiS_Pr,HwInfo); 8774 SiS_SetCH701xForLCD(SiS_Pr);
8961#endif 8775#endif
8962 } 8776 }
8963 } 8777 }
8964 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 8778 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
8965 SiS_SetCHTVReg(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex); 8779 SiS_SetCHTVReg(SiS_Pr,ModeNo,ModeIdIndex,RefreshRateTableIndex);
8966 } 8780 }
8967 } 8781 }
8968 } 8782 }
8969 8783
8970 } 8784 }
8971 8785
8972#ifdef SIS300 8786#ifdef SIS300
8973 if(HwInfo->jChipType < SIS_315H) { 8787 if(SiS_Pr->ChipType < SIS_315H) {
8974 if(SiS_Pr->SiS_SetFlag & LowModeTests) { 8788 if(SiS_Pr->SiS_SetFlag & LowModeTests) {
8975 if(SiS_Pr->SiS_UseOEM) { 8789 if(SiS_Pr->SiS_UseOEM) {
8976 if((SiS_Pr->SiS_UseROM) && (SiS_Pr->SiS_UseOEM == -1)) { 8790 if((SiS_Pr->SiS_UseROM) && (SiS_Pr->SiS_UseOEM == -1)) {
8977 if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) { 8791 if((ROMAddr[0x233] == 0x12) && (ROMAddr[0x234] == 0x34)) {
8978 SiS_OEM300Setting(SiS_Pr,HwInfo,ModeNo,ModeIdIndex, 8792 SiS_OEM300Setting(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
8979 RefreshRateTableIndex);
8980 } 8793 }
8981 } else { 8794 } else {
8982 SiS_OEM300Setting(SiS_Pr,HwInfo,ModeNo,ModeIdIndex, 8795 SiS_OEM300Setting(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
8983 RefreshRateTableIndex);
8984 } 8796 }
8985 } 8797 }
8986 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { 8798 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
8987 if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) || 8799 if((SiS_Pr->SiS_CustomT == CUT_BARCO1366) ||
8988 (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) { 8800 (SiS_Pr->SiS_CustomT == CUT_BARCO1024)) {
8989 SetOEMLCDData2(SiS_Pr, HwInfo, ModeNo, ModeIdIndex,RefreshRateTableIndex); 8801 SetOEMLCDData2(SiS_Pr, ModeNo, ModeIdIndex,RefreshRateTableIndex);
8990 } 8802 }
8991 SiS_DisplayOn(SiS_Pr); 8803 SiS_DisplayOn(SiS_Pr);
8992 } 8804 }
@@ -8995,21 +8807,21 @@ SiS_SetCRT2Group(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo)
8995#endif 8807#endif
8996 8808
8997#ifdef SIS315H 8809#ifdef SIS315H
8998 if(HwInfo->jChipType >= SIS_315H) { 8810 if(SiS_Pr->ChipType >= SIS_315H) {
8999 if(SiS_Pr->SiS_SetFlag & LowModeTests) { 8811 if(SiS_Pr->SiS_SetFlag & LowModeTests) {
9000 if(HwInfo->jChipType < SIS_661) { 8812 if(SiS_Pr->ChipType < SIS_661) {
9001 SiS_FinalizeLCD(SiS_Pr, ModeNo, ModeIdIndex, HwInfo); 8813 SiS_FinalizeLCD(SiS_Pr, ModeNo, ModeIdIndex);
9002 SiS_OEM310Setting(SiS_Pr, HwInfo, ModeNo, ModeIdIndex, RefreshRateTableIndex); 8814 SiS_OEM310Setting(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
9003 } else { 8815 } else {
9004 SiS_OEM661Setting(SiS_Pr, HwInfo, ModeNo, ModeIdIndex, RefreshRateTableIndex); 8816 SiS_OEM661Setting(SiS_Pr, ModeNo, ModeIdIndex, RefreshRateTableIndex);
9005 } 8817 }
9006 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x40); 8818 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x01,0x40);
9007 } 8819 }
9008 } 8820 }
9009#endif 8821#endif
9010 8822
9011 if(SiS_Pr->SiS_SetFlag & LowModeTests) { 8823 if(SiS_Pr->SiS_SetFlag & LowModeTests) {
9012 SiS_EnableBridge(SiS_Pr, HwInfo); 8824 SiS_EnableBridge(SiS_Pr);
9013 } 8825 }
9014 8826
9015 SiS_DisplayOn(SiS_Pr); 8827 SiS_DisplayOn(SiS_Pr);
@@ -9017,15 +8829,15 @@ SiS_SetCRT2Group(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo)
9017 if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) { 8829 if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) {
9018 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 8830 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
9019 /* Disable LCD panel when using TV */ 8831 /* Disable LCD panel when using TV */
9020 SiS_SetRegSR11ANDOR(SiS_Pr,HwInfo,0xFF,0x0C); 8832 SiS_SetRegSR11ANDOR(SiS_Pr,0xFF,0x0C);
9021 } else { 8833 } else {
9022 /* Disable TV when using LCD */ 8834 /* Disable TV when using LCD */
9023 SiS_SetCH70xxANDOR(SiS_Pr,0x010E,0xF8); 8835 SiS_SetCH70xxANDOR(SiS_Pr,0x0e,0x01,0xf8);
9024 } 8836 }
9025 } 8837 }
9026 8838
9027 if(SiS_Pr->SiS_SetFlag & LowModeTests) { 8839 if(SiS_Pr->SiS_SetFlag & LowModeTests) {
9028 SiS_LockCRT2(SiS_Pr,HwInfo); 8840 SiS_LockCRT2(SiS_Pr);
9029 } 8841 }
9030 8842
9031 return TRUE; 8843 return TRUE;
@@ -9037,13 +8849,13 @@ SiS_SetCRT2Group(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo)
9037/*********************************************/ 8849/*********************************************/
9038 8850
9039void 8851void
9040SiS_SiS30xBLOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 8852SiS_SiS30xBLOn(struct SiS_Private *SiS_Pr)
9041{ 8853{
9042 /* Switch on LCD backlight on SiS30xLV */ 8854 /* Switch on LCD backlight on SiS30xLV */
9043 SiS_DDC2Delay(SiS_Pr,0xff00); 8855 SiS_DDC2Delay(SiS_Pr,0xff00);
9044 if(!(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x26) & 0x02)) { 8856 if(!(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x26) & 0x02)) {
9045 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02); 8857 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x02);
9046 SiS_WaitVBRetrace(SiS_Pr,HwInfo); 8858 SiS_WaitVBRetrace(SiS_Pr);
9047 } 8859 }
9048 if(!(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x26) & 0x01)) { 8860 if(!(SiS_GetReg(SiS_Pr->SiS_Part4Port,0x26) & 0x01)) {
9049 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x01); 8861 SiS_SetRegOR(SiS_Pr->SiS_Part4Port,0x26,0x01);
@@ -9051,12 +8863,11 @@ SiS_SiS30xBLOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
9051} 8863}
9052 8864
9053void 8865void
9054SiS_SiS30xBLOff(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 8866SiS_SiS30xBLOff(struct SiS_Private *SiS_Pr)
9055{ 8867{
9056 /* Switch off LCD backlight on SiS30xLV */ 8868 /* Switch off LCD backlight on SiS30xLV */
9057 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFE); 8869 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFE);
9058 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x26,0xFD); 8870 SiS_DDC2Delay(SiS_Pr,0xff00);
9059 SiS_DDC2Delay(SiS_Pr,0xe000);
9060} 8871}
9061 8872
9062/*********************************************/ 8873/*********************************************/
@@ -9064,7 +8875,7 @@ SiS_SiS30xBLOff(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
9064/*********************************************/ 8875/*********************************************/
9065 8876
9066static void 8877static void
9067SiS_SetupDDCN(SiS_Private *SiS_Pr) 8878SiS_SetupDDCN(struct SiS_Private *SiS_Pr)
9068{ 8879{
9069 SiS_Pr->SiS_DDC_NData = ~SiS_Pr->SiS_DDC_Data; 8880 SiS_Pr->SiS_DDC_NData = ~SiS_Pr->SiS_DDC_Data;
9070 SiS_Pr->SiS_DDC_NClk = ~SiS_Pr->SiS_DDC_Clk; 8881 SiS_Pr->SiS_DDC_NClk = ~SiS_Pr->SiS_DDC_Clk;
@@ -9075,12 +8886,12 @@ SiS_SetupDDCN(SiS_Private *SiS_Pr)
9075} 8886}
9076 8887
9077#ifdef SIS300 8888#ifdef SIS300
9078static UCHAR * 8889static unsigned char *
9079SiS_SetTrumpBlockLoop(SiS_Private *SiS_Pr, UCHAR *dataptr) 8890SiS_SetTrumpBlockLoop(struct SiS_Private *SiS_Pr, unsigned char *dataptr)
9080{ 8891{
9081 int i, j, num; 8892 int i, j, num;
9082 USHORT tempah,temp; 8893 unsigned short tempah,temp;
9083 UCHAR *mydataptr; 8894 unsigned char *mydataptr;
9084 8895
9085 for(i=0; i<20; i++) { /* Do 20 attempts to write */ 8896 for(i=0; i<20; i++) { /* Do 20 attempts to write */
9086 mydataptr = dataptr; 8897 mydataptr = dataptr;
@@ -9088,7 +8899,7 @@ SiS_SetTrumpBlockLoop(SiS_Private *SiS_Pr, UCHAR *dataptr)
9088 if(!num) return mydataptr; 8899 if(!num) return mydataptr;
9089 if(i) { 8900 if(i) {
9090 SiS_SetStop(SiS_Pr); 8901 SiS_SetStop(SiS_Pr);
9091 SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT*2); 8902 SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT * 2);
9092 } 8903 }
9093 if(SiS_SetStart(SiS_Pr)) continue; /* Set start condition */ 8904 if(SiS_SetStart(SiS_Pr)) continue; /* Set start condition */
9094 tempah = SiS_Pr->SiS_DDC_DeviceAddr; 8905 tempah = SiS_Pr->SiS_DDC_DeviceAddr;
@@ -9110,12 +8921,12 @@ SiS_SetTrumpBlockLoop(SiS_Private *SiS_Pr, UCHAR *dataptr)
9110} 8921}
9111 8922
9112static BOOLEAN 8923static BOOLEAN
9113SiS_SetTrumpionBlock(SiS_Private *SiS_Pr, UCHAR *dataptr) 8924SiS_SetTrumpionBlock(struct SiS_Private *SiS_Pr, unsigned char *dataptr)
9114{ 8925{
9115 SiS_Pr->SiS_DDC_DeviceAddr = 0xF0; /* DAB (Device Address Byte) */ 8926 SiS_Pr->SiS_DDC_DeviceAddr = 0xF0; /* DAB (Device Address Byte) */
9116 SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */ 8927 SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */
9117 SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */ 8928 SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */
9118 SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */ 8929 SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */
9119 SiS_SetupDDCN(SiS_Pr); 8930 SiS_SetupDDCN(SiS_Pr);
9120 8931
9121 SiS_SetSwitchDDC2(SiS_Pr); 8932 SiS_SetSwitchDDC2(SiS_Pr);
@@ -9124,9 +8935,11 @@ SiS_SetTrumpionBlock(SiS_Private *SiS_Pr, UCHAR *dataptr)
9124 dataptr = SiS_SetTrumpBlockLoop(SiS_Pr, dataptr); 8935 dataptr = SiS_SetTrumpBlockLoop(SiS_Pr, dataptr);
9125 if(!dataptr) return FALSE; 8936 if(!dataptr) return FALSE;
9126 } 8937 }
8938#ifdef SIS_XORG_XF86
9127#ifdef TWDEBUG 8939#ifdef TWDEBUG
9128 xf86DrvMsg(0, X_INFO, "Trumpion block success\n"); 8940 xf86DrvMsg(0, X_INFO, "Trumpion block success\n");
9129#endif 8941#endif
8942#endif
9130 return TRUE; 8943 return TRUE;
9131} 8944}
9132#endif 8945#endif
@@ -9139,155 +8952,121 @@ SiS_SetTrumpionBlock(SiS_Private *SiS_Pr, UCHAR *dataptr)
9139 */ 8952 */
9140 8953
9141static BOOLEAN 8954static BOOLEAN
9142SiS_SetChReg(SiS_Private *SiS_Pr, USHORT tempbx, USHORT myor) 8955SiS_SetChReg(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val, unsigned short myor)
9143{ 8956{
9144 USHORT tempah,temp,i; 8957 unsigned short temp, i;
9145 8958
9146 for(i=0; i<20; i++) { /* Do 20 attempts to write */ 8959 for(i=0; i<20; i++) { /* Do 20 attempts to write */
9147 if(i) { 8960 if(i) {
9148 SiS_SetStop(SiS_Pr); 8961 SiS_SetStop(SiS_Pr);
9149 SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT); 8962 SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT * 4);
9150 } 8963 }
9151 if(SiS_SetStart(SiS_Pr)) continue; /* Set start condition */ 8964 if(SiS_SetStart(SiS_Pr)) continue; /* Set start condition */
9152 tempah = SiS_Pr->SiS_DDC_DeviceAddr; 8965 temp = SiS_WriteDDC2Data(SiS_Pr, SiS_Pr->SiS_DDC_DeviceAddr); /* Write DAB (S0=0=write) */
9153 temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* Write DAB (S0=0=write) */ 8966 if(temp) continue; /* (ERROR: no ack) */
9154 if(temp) continue; /* (ERROR: no ack) */ 8967 temp = SiS_WriteDDC2Data(SiS_Pr, (reg | myor)); /* Write RAB (700x: set bit 7, see datasheet) */
9155 tempah = tempbx & 0x00FF; /* Write RAB */ 8968 if(temp) continue; /* (ERROR: no ack) */
9156 tempah |= myor; /* (700x: set bit 7, see datasheet) */ 8969 temp = SiS_WriteDDC2Data(SiS_Pr, val); /* Write data */
9157 temp = SiS_WriteDDC2Data(SiS_Pr,tempah); 8970 if(temp) continue; /* (ERROR: no ack) */
9158 if(temp) continue; /* (ERROR: no ack) */ 8971 if(SiS_SetStop(SiS_Pr)) continue; /* Set stop condition */
9159 tempah = (tempbx & 0xFF00) >> 8;
9160 temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* Write data */
9161 if(temp) continue; /* (ERROR: no ack) */
9162 if(SiS_SetStop(SiS_Pr)) continue; /* Set stop condition */
9163 SiS_Pr->SiS_ChrontelInit = 1; 8972 SiS_Pr->SiS_ChrontelInit = 1;
9164 return TRUE; 8973 return TRUE;
9165 } 8974 }
9166 return FALSE; 8975 return FALSE;
9167} 8976}
9168 8977
9169#if 0
9170#ifdef SIS300
9171/* Write Trumpion register */
9172static void
9173SiS_SetTrumpReg(SiS_Private *SiS_Pr, USHORT tempbx)
9174{
9175 SiS_Pr->SiS_DDC_DeviceAddr = 0xF0; /* DAB (Device Address Byte) */
9176 SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */
9177 SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */
9178 SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */
9179 SiS_SetupDDCN(SiS_Pr);
9180 SiS_SetChReg(SiS_Pr, tempbx, 0);
9181}
9182#endif
9183#endif
9184
9185/* Write to Chrontel 700x */ 8978/* Write to Chrontel 700x */
9186/* Parameter is [Data (S15-S8) | Register no (S7-S0)] */
9187void 8979void
9188SiS_SetCH700x(SiS_Private *SiS_Pr, USHORT tempbx) 8980SiS_SetCH700x(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val)
9189{ 8981{
9190 SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* DAB (Device Address Byte) */ 8982 SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* DAB (Device Address Byte) */
9191 8983
8984 SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT);
8985
9192 if(!(SiS_Pr->SiS_ChrontelInit)) { 8986 if(!(SiS_Pr->SiS_ChrontelInit)) {
9193 SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */ 8987 SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */
9194 SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */ 8988 SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */
9195 SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */ 8989 SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */
9196 SiS_SetupDDCN(SiS_Pr); 8990 SiS_SetupDDCN(SiS_Pr);
9197 } 8991 }
9198 8992
9199 if( (!(SiS_SetChReg(SiS_Pr, tempbx, 0x80))) && 8993 if( (!(SiS_SetChReg(SiS_Pr, reg, val, 0x80))) &&
9200 (!(SiS_Pr->SiS_ChrontelInit)) ) { 8994 (!(SiS_Pr->SiS_ChrontelInit)) ) {
9201 SiS_Pr->SiS_DDC_Index = 0x0a; /* Bit 7 = SC; Bit 6 = SD */ 8995 SiS_Pr->SiS_DDC_Index = 0x0a;
9202 SiS_Pr->SiS_DDC_Data = 0x80; /* Bitmask in IndexReg for Data */ 8996 SiS_Pr->SiS_DDC_Data = 0x80;
9203 SiS_Pr->SiS_DDC_Clk = 0x40; /* Bitmask in IndexReg for Clk */ 8997 SiS_Pr->SiS_DDC_Clk = 0x40;
9204 SiS_SetupDDCN(SiS_Pr); 8998 SiS_SetupDDCN(SiS_Pr);
9205 8999
9206 SiS_SetChReg(SiS_Pr, tempbx, 0x80); 9000 SiS_SetChReg(SiS_Pr, reg, val, 0x80);
9207 } 9001 }
9208} 9002}
9209 9003
9210/* Write to Chrontel 701x */ 9004/* Write to Chrontel 701x */
9211/* Parameter is [Data (S15-S8) | Register no (S7-S0)] */ 9005/* Parameter is [Data (S15-S8) | Register no (S7-S0)] */
9212void 9006void
9213SiS_SetCH701x(SiS_Private *SiS_Pr, USHORT tempbx) 9007SiS_SetCH701x(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val)
9214{ 9008{
9215 SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */ 9009 SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */
9216 SiS_Pr->SiS_DDC_Data = 0x08; /* Bitmask in IndexReg for Data */ 9010 SiS_Pr->SiS_DDC_Data = 0x08; /* Bitmask in IndexReg for Data */
9217 SiS_Pr->SiS_DDC_Clk = 0x04; /* Bitmask in IndexReg for Clk */ 9011 SiS_Pr->SiS_DDC_Clk = 0x04; /* Bitmask in IndexReg for Clk */
9218 SiS_SetupDDCN(SiS_Pr); 9012 SiS_SetupDDCN(SiS_Pr);
9219 SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* DAB (Device Address Byte) */ 9013 SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* DAB (Device Address Byte) */
9220 SiS_SetChReg(SiS_Pr, tempbx, 0); 9014 SiS_SetChReg(SiS_Pr, reg, val, 0);
9221} 9015}
9222 9016
9223static void 9017#ifdef SIS_LINUX_KERNEL
9224SiS_SetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx) 9018static
9019#endif
9020void
9021SiS_SetCH70xx(struct SiS_Private *SiS_Pr, unsigned short reg, unsigned char val)
9225{ 9022{
9226 if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) 9023 if(SiS_Pr->SiS_IF_DEF_CH70xx == 1)
9227 SiS_SetCH700x(SiS_Pr,tempbx); 9024 SiS_SetCH700x(SiS_Pr, reg, val);
9228 else 9025 else
9229 SiS_SetCH701x(SiS_Pr,tempbx); 9026 SiS_SetCH701x(SiS_Pr, reg, val);
9230} 9027}
9231 9028
9232static USHORT 9029static unsigned short
9233SiS_GetChReg(SiS_Private *SiS_Pr, USHORT myor) 9030SiS_GetChReg(struct SiS_Private *SiS_Pr, unsigned short myor)
9234{ 9031{
9235 USHORT tempah,temp,i; 9032 unsigned short tempah, temp, i;
9236 9033
9237 for(i=0; i<20; i++) { /* Do 20 attempts to read */ 9034 for(i=0; i<20; i++) { /* Do 20 attempts to read */
9238 if(i) { 9035 if(i) {
9239 SiS_SetStop(SiS_Pr); 9036 SiS_SetStop(SiS_Pr);
9240 SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT); 9037 SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT * 4);
9241 } 9038 }
9242 if(SiS_SetStart(SiS_Pr)) continue; /* Set start condition */ 9039 if(SiS_SetStart(SiS_Pr)) continue; /* Set start condition */
9243 tempah = SiS_Pr->SiS_DDC_DeviceAddr; 9040 temp = SiS_WriteDDC2Data(SiS_Pr,SiS_Pr->SiS_DDC_DeviceAddr); /* Write DAB (S0=0=write) */
9244 temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* Write DAB (S0=0=write) */ 9041 if(temp) continue; /* (ERROR: no ack) */
9245 if(temp) continue; /* (ERROR: no ack) */ 9042 temp = SiS_WriteDDC2Data(SiS_Pr,SiS_Pr->SiS_DDC_ReadAddr | myor); /* Write RAB (700x: | 0x80) */
9246 tempah = SiS_Pr->SiS_DDC_ReadAddr | myor; /* Write RAB (700x: | 0x80) */ 9043 if(temp) continue; /* (ERROR: no ack) */
9247 temp = SiS_WriteDDC2Data(SiS_Pr,tempah); 9044 if (SiS_SetStart(SiS_Pr)) continue; /* Re-start */
9248 if(temp) continue; /* (ERROR: no ack) */ 9045 temp = SiS_WriteDDC2Data(SiS_Pr,SiS_Pr->SiS_DDC_DeviceAddr | 0x01);/* DAB (S0=1=read) */
9249 if (SiS_SetStart(SiS_Pr)) continue; /* Re-start */ 9046 if(temp) continue; /* (ERROR: no ack) */
9250 tempah = SiS_Pr->SiS_DDC_DeviceAddr | 0x01;/* DAB | 0x01 = Read */ 9047 tempah = SiS_ReadDDC2Data(SiS_Pr); /* Read byte */
9251 temp = SiS_WriteDDC2Data(SiS_Pr,tempah); /* DAB (S0=1=read) */ 9048 if(SiS_SetStop(SiS_Pr)) continue; /* Stop condition */
9252 if(temp) continue; /* (ERROR: no ack) */
9253 tempah = SiS_ReadDDC2Data(SiS_Pr,tempah); /* Read byte */
9254 if(SiS_SetStop(SiS_Pr)) continue; /* Stop condition */
9255 SiS_Pr->SiS_ChrontelInit = 1; 9049 SiS_Pr->SiS_ChrontelInit = 1;
9256 return(tempah); 9050 return tempah;
9257 } 9051 }
9258 return 0xFFFF; 9052 return 0xFFFF;
9259} 9053}
9260 9054
9261#if 0
9262#ifdef SIS300
9263/* Read from Trumpion */
9264static USHORT
9265SiS_GetTrumpReg(SiS_Private *SiS_Pr, USHORT tempbx)
9266{
9267 SiS_Pr->SiS_DDC_DeviceAddr = 0xF0; /* DAB */
9268 SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */
9269 SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */
9270 SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */
9271 SiS_SetupDDCN(SiS_Pr);
9272 SiS_Pr->SiS_DDC_ReadAddr = tempbx;
9273 return(SiS_GetChReg(SiS_Pr,0));
9274}
9275#endif
9276#endif
9277
9278/* Read from Chrontel 700x */ 9055/* Read from Chrontel 700x */
9279/* Parameter is [Register no (S7-S0)] */ 9056/* Parameter is [Register no (S7-S0)] */
9280USHORT 9057unsigned short
9281SiS_GetCH700x(SiS_Private *SiS_Pr, USHORT tempbx) 9058SiS_GetCH700x(struct SiS_Private *SiS_Pr, unsigned short tempbx)
9282{ 9059{
9283 USHORT result; 9060 unsigned short result;
9284 9061
9285 SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* DAB */ 9062 SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* DAB */
9286 9063
9064 SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT);
9065
9287 if(!(SiS_Pr->SiS_ChrontelInit)) { 9066 if(!(SiS_Pr->SiS_ChrontelInit)) {
9288 SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */ 9067 SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */
9289 SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */ 9068 SiS_Pr->SiS_DDC_Data = 0x02; /* Bitmask in IndexReg for Data */
9290 SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */ 9069 SiS_Pr->SiS_DDC_Clk = 0x01; /* Bitmask in IndexReg for Clk */
9291 SiS_SetupDDCN(SiS_Pr); 9070 SiS_SetupDDCN(SiS_Pr);
9292 } 9071 }
9293 9072
@@ -9303,52 +9082,69 @@ SiS_GetCH700x(SiS_Private *SiS_Pr, USHORT tempbx)
9303 9082
9304 result = SiS_GetChReg(SiS_Pr,0x80); 9083 result = SiS_GetChReg(SiS_Pr,0x80);
9305 } 9084 }
9306 return(result); 9085 return result;
9307} 9086}
9308 9087
9309/* Read from Chrontel 701x */ 9088/* Read from Chrontel 701x */
9310/* Parameter is [Register no (S7-S0)] */ 9089/* Parameter is [Register no (S7-S0)] */
9311USHORT 9090unsigned short
9312SiS_GetCH701x(SiS_Private *SiS_Pr, USHORT tempbx) 9091SiS_GetCH701x(struct SiS_Private *SiS_Pr, unsigned short tempbx)
9313{ 9092{
9314 SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */ 9093 SiS_Pr->SiS_DDC_Index = 0x11; /* Bit 0 = SC; Bit 1 = SD */
9315 SiS_Pr->SiS_DDC_Data = 0x08; /* Bitmask in IndexReg for Data */ 9094 SiS_Pr->SiS_DDC_Data = 0x08; /* Bitmask in IndexReg for Data */
9316 SiS_Pr->SiS_DDC_Clk = 0x04; /* Bitmask in IndexReg for Clk */ 9095 SiS_Pr->SiS_DDC_Clk = 0x04; /* Bitmask in IndexReg for Clk */
9317 SiS_SetupDDCN(SiS_Pr); 9096 SiS_SetupDDCN(SiS_Pr);
9318 SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* DAB */ 9097 SiS_Pr->SiS_DDC_DeviceAddr = 0xEA; /* DAB */
9319 9098
9320 SiS_Pr->SiS_DDC_ReadAddr = tempbx; 9099 SiS_Pr->SiS_DDC_ReadAddr = tempbx;
9321 9100
9322 return(SiS_GetChReg(SiS_Pr,0)); 9101 return SiS_GetChReg(SiS_Pr,0);
9323} 9102}
9324 9103
9325/* Read from Chrontel 70xx */ 9104/* Read from Chrontel 70xx */
9326/* Parameter is [Register no (S7-S0)] */ 9105/* Parameter is [Register no (S7-S0)] */
9327static USHORT 9106#ifdef SIS_LINUX_KERNEL
9328SiS_GetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx) 9107static
9108#endif
9109unsigned short
9110SiS_GetCH70xx(struct SiS_Private *SiS_Pr, unsigned short tempbx)
9329{ 9111{
9330 if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) 9112 if(SiS_Pr->SiS_IF_DEF_CH70xx == 1)
9331 return(SiS_GetCH700x(SiS_Pr, tempbx)); 9113 return SiS_GetCH700x(SiS_Pr, tempbx);
9332 else 9114 else
9333 return(SiS_GetCH701x(SiS_Pr, tempbx)); 9115 return SiS_GetCH701x(SiS_Pr, tempbx);
9116}
9117
9118void
9119SiS_SetCH70xxANDOR(struct SiS_Private *SiS_Pr, unsigned short reg,
9120 unsigned char myor, unsigned short myand)
9121{
9122 unsigned short tempbl;
9123
9124 tempbl = (SiS_GetCH70xx(SiS_Pr, (reg & 0xFF)) & myand) | myor;
9125 SiS_SetCH70xx(SiS_Pr, reg, tempbl);
9334} 9126}
9335 9127
9336/* Our own DDC functions */ 9128/* Our own DDC functions */
9337static USHORT 9129#ifndef SIS_XORG_XF86
9338SiS_InitDDCRegs(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine, 9130static
9339 USHORT adaptnum, USHORT DDCdatatype, BOOLEAN checkcr32) 9131#endif
9132unsigned short
9133SiS_InitDDCRegs(struct SiS_Private *SiS_Pr, unsigned int VBFlags, int VGAEngine,
9134 unsigned short adaptnum, unsigned short DDCdatatype, BOOLEAN checkcr32,
9135 unsigned int VBFlags2)
9340{ 9136{
9341 unsigned char ddcdtype[] = { 0xa0, 0xa0, 0xa0, 0xa2, 0xa6 }; 9137 unsigned char ddcdtype[] = { 0xa0, 0xa0, 0xa0, 0xa2, 0xa6 };
9342 unsigned char flag, cr32; 9138 unsigned char flag, cr32;
9343 USHORT temp = 0, myadaptnum = adaptnum; 9139 unsigned short temp = 0, myadaptnum = adaptnum;
9344 9140
9345 if(adaptnum != 0) { 9141 if(adaptnum != 0) {
9346 if(!(VBFlags & (VB_301|VB_301B|VB_301C|VB_302B))) return 0xFFFF; 9142 if(!(VBFlags2 & VB2_SISTMDSBRIDGE)) return 0xFFFF;
9347 if((VBFlags & VB_30xBDH) && (adaptnum == 1)) return 0xFFFF; 9143 if((VBFlags2 & VB2_30xBDH) && (adaptnum == 1)) return 0xFFFF;
9348 } 9144 }
9349 9145
9350 /* adapternum for SiS bridges: 0 = CRT1, 1 = LCD, 2 = VGA2 */ 9146 /* adapternum for SiS bridges: 0 = CRT1, 1 = LCD, 2 = VGA2 */
9351 9147
9352 SiS_Pr->SiS_ChrontelInit = 0; /* force re-detection! */ 9148 SiS_Pr->SiS_ChrontelInit = 0; /* force re-detection! */
9353 9149
9354 SiS_Pr->SiS_DDC_SecAddr = 0; 9150 SiS_Pr->SiS_DDC_SecAddr = 0;
@@ -9360,7 +9156,7 @@ SiS_InitDDCRegs(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine,
9360 cr32 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x32); 9156 cr32 = SiS_GetReg(SiS_Pr->SiS_P3d4,0x32);
9361 9157
9362#if 0 9158#if 0
9363 if(VBFlags & VB_SISBRIDGE) { 9159 if(VBFlags2 & VB2_SISBRIDGE) {
9364 if(myadaptnum == 0) { 9160 if(myadaptnum == 0) {
9365 if(!(cr32 & 0x20)) { 9161 if(!(cr32 & 0x20)) {
9366 myadaptnum = 2; 9162 myadaptnum = 2;
@@ -9376,20 +9172,20 @@ SiS_InitDDCRegs(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine,
9376#endif 9172#endif
9377 9173
9378 if(VGAEngine == SIS_300_VGA) { /* 300 series */ 9174 if(VGAEngine == SIS_300_VGA) { /* 300 series */
9379 9175
9380 if(myadaptnum != 0) { 9176 if(myadaptnum != 0) {
9381 flag = 0; 9177 flag = 0;
9382 if(VBFlags & VB_SISBRIDGE) { 9178 if(VBFlags2 & VB2_SISBRIDGE) {
9383 SiS_Pr->SiS_DDC_Port = SiS_Pr->SiS_Part4Port; 9179 SiS_Pr->SiS_DDC_Port = SiS_Pr->SiS_Part4Port;
9384 SiS_Pr->SiS_DDC_Index = 0x0f; 9180 SiS_Pr->SiS_DDC_Index = 0x0f;
9385 } 9181 }
9386 } 9182 }
9387 9183
9388 if(!(VBFlags & VB_301)) { 9184 if(!(VBFlags2 & VB2_301)) {
9389 if((cr32 & 0x80) && (checkcr32)) { 9185 if((cr32 & 0x80) && (checkcr32)) {
9390 if(myadaptnum >= 1) { 9186 if(myadaptnum >= 1) {
9391 if(!(cr32 & 0x08)) { 9187 if(!(cr32 & 0x08)) {
9392 myadaptnum = 1; 9188 myadaptnum = 1;
9393 if(!(cr32 & 0x10)) return 0xFFFF; 9189 if(!(cr32 & 0x10)) return 0xFFFF;
9394 } 9190 }
9395 } 9191 }
@@ -9401,17 +9197,17 @@ SiS_InitDDCRegs(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine,
9401 9197
9402 } else { /* 315/330 series */ 9198 } else { /* 315/330 series */
9403 9199
9404 /* here we simplify: 0 = CRT1, 1 = CRT2 (VGA, LCD) */ 9200 /* here we simplify: 0 = CRT1, 1 = CRT2 (VGA, LCD) */
9405 9201
9406 if(VBFlags & VB_SISBRIDGE) { 9202 if(VBFlags2 & VB2_SISBRIDGE) {
9407 if(myadaptnum == 2) { 9203 if(myadaptnum == 2) {
9408 myadaptnum = 1; 9204 myadaptnum = 1;
9409 } 9205 }
9410 } 9206 }
9411 9207
9412 if(myadaptnum == 1) { 9208 if(myadaptnum == 1) {
9413 flag = 0; 9209 flag = 0;
9414 if(VBFlags & VB_SISBRIDGE) { 9210 if(VBFlags2 & VB2_SISBRIDGE) {
9415 SiS_Pr->SiS_DDC_Port = SiS_Pr->SiS_Part4Port; 9211 SiS_Pr->SiS_DDC_Port = SiS_Pr->SiS_Part4Port;
9416 SiS_Pr->SiS_DDC_Index = 0x0f; 9212 SiS_Pr->SiS_DDC_Index = 0x0f;
9417 } 9213 }
@@ -9429,93 +9225,96 @@ SiS_InitDDCRegs(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine,
9429 temp = myadaptnum; 9225 temp = myadaptnum;
9430 if(myadaptnum == 1) { 9226 if(myadaptnum == 1) {
9431 temp = 0; 9227 temp = 0;
9432 if(VBFlags & VB_LVDS) flag = 0xff; 9228 if(VBFlags2 & VB2_LVDS) flag = 0xff;
9433 } 9229 }
9434 9230
9435 if(flag) temp = 0; 9231 if(flag) temp = 0;
9436 } 9232 }
9437 9233
9438 SiS_Pr->SiS_DDC_Data = 0x02 << temp; 9234 SiS_Pr->SiS_DDC_Data = 0x02 << temp;
9439 SiS_Pr->SiS_DDC_Clk = 0x01 << temp; 9235 SiS_Pr->SiS_DDC_Clk = 0x01 << temp;
9440 9236
9441 SiS_SetupDDCN(SiS_Pr); 9237 SiS_SetupDDCN(SiS_Pr);
9442 9238
9239#ifdef SIS_XORG_XF86
9443#ifdef TWDEBUG 9240#ifdef TWDEBUG
9444 xf86DrvMsg(0, X_INFO, "DDC Port %x Index %x Shift %d\n", 9241 xf86DrvMsg(0, X_INFO, "DDC Port %x Index %x Shift %d\n",
9445 SiS_Pr->SiS_DDC_Port, SiS_Pr->SiS_DDC_Index, temp); 9242 SiS_Pr->SiS_DDC_Port, SiS_Pr->SiS_DDC_Index, temp);
9446#endif 9243#endif
9447 9244#endif
9448 return 0; 9245 return 0;
9449} 9246}
9450 9247
9451static USHORT 9248static unsigned short
9452SiS_WriteDABDDC(SiS_Private *SiS_Pr) 9249SiS_WriteDABDDC(struct SiS_Private *SiS_Pr)
9453{ 9250{
9454 if(SiS_SetStart(SiS_Pr)) return 0xFFFF; 9251 if(SiS_SetStart(SiS_Pr)) return 0xFFFF;
9455 if(SiS_WriteDDC2Data(SiS_Pr, SiS_Pr->SiS_DDC_DeviceAddr)) { 9252 if(SiS_WriteDDC2Data(SiS_Pr, SiS_Pr->SiS_DDC_DeviceAddr)) {
9456 return 0xFFFF; 9253 return 0xFFFF;
9457 } 9254 }
9458 if(SiS_WriteDDC2Data(SiS_Pr, SiS_Pr->SiS_DDC_SecAddr)) { 9255 if(SiS_WriteDDC2Data(SiS_Pr, SiS_Pr->SiS_DDC_SecAddr)) {
9459 return 0xFFFF; 9256 return 0xFFFF;
9460 } 9257 }
9461 return(0); 9258 return 0;
9462} 9259}
9463 9260
9464static USHORT 9261static unsigned short
9465SiS_PrepareReadDDC(SiS_Private *SiS_Pr) 9262SiS_PrepareReadDDC(struct SiS_Private *SiS_Pr)
9466{ 9263{
9467 if(SiS_SetStart(SiS_Pr)) return 0xFFFF; 9264 if(SiS_SetStart(SiS_Pr)) return 0xFFFF;
9468 if(SiS_WriteDDC2Data(SiS_Pr, (SiS_Pr->SiS_DDC_DeviceAddr | 0x01))) { 9265 if(SiS_WriteDDC2Data(SiS_Pr, (SiS_Pr->SiS_DDC_DeviceAddr | 0x01))) {
9469 return 0xFFFF; 9266 return 0xFFFF;
9470 } 9267 }
9471 return(0); 9268 return 0;
9472} 9269}
9473 9270
9474static USHORT 9271static unsigned short
9475SiS_PrepareDDC(SiS_Private *SiS_Pr) 9272SiS_PrepareDDC(struct SiS_Private *SiS_Pr)
9476{ 9273{
9477 if(SiS_WriteDABDDC(SiS_Pr)) SiS_WriteDABDDC(SiS_Pr); 9274 if(SiS_WriteDABDDC(SiS_Pr)) SiS_WriteDABDDC(SiS_Pr);
9478 if(SiS_PrepareReadDDC(SiS_Pr)) return(SiS_PrepareReadDDC(SiS_Pr)); 9275 if(SiS_PrepareReadDDC(SiS_Pr)) return (SiS_PrepareReadDDC(SiS_Pr));
9479 return(0); 9276 return 0;
9480} 9277}
9481 9278
9482static void 9279static void
9483SiS_SendACK(SiS_Private *SiS_Pr, USHORT yesno) 9280SiS_SendACK(struct SiS_Private *SiS_Pr, unsigned short yesno)
9484{ 9281{
9485 SiS_SetSCLKLow(SiS_Pr); 9282 SiS_SetSCLKLow(SiS_Pr);
9486 if(yesno) { 9283 if(yesno) {
9487 SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, 9284 SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,
9488 SiS_Pr->SiS_DDC_Index, 9285 SiS_Pr->SiS_DDC_Index,
9489 SiS_Pr->SiS_DDC_NData, 9286 SiS_Pr->SiS_DDC_NData,
9490 SiS_Pr->SiS_DDC_Data); 9287 SiS_Pr->SiS_DDC_Data);
9491 } else { 9288 } else {
9492 SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, 9289 SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,
9493 SiS_Pr->SiS_DDC_Index, 9290 SiS_Pr->SiS_DDC_Index,
9494 SiS_Pr->SiS_DDC_NData, 9291 SiS_Pr->SiS_DDC_NData,
9495 0); 9292 0);
9496 } 9293 }
9497 SiS_SetSCLKHigh(SiS_Pr); 9294 SiS_SetSCLKHigh(SiS_Pr);
9498} 9295}
9499 9296
9500static USHORT 9297static unsigned short
9501SiS_DoProbeDDC(SiS_Private *SiS_Pr) 9298SiS_DoProbeDDC(struct SiS_Private *SiS_Pr)
9502{ 9299{
9503 unsigned char mask, value; 9300 unsigned char mask, value;
9504 USHORT temp, ret=0; 9301 unsigned short temp, ret=0;
9505 BOOLEAN failed = FALSE; 9302 BOOLEAN failed = FALSE;
9506 9303
9507 SiS_SetSwitchDDC2(SiS_Pr); 9304 SiS_SetSwitchDDC2(SiS_Pr);
9508 if(SiS_PrepareDDC(SiS_Pr)) { 9305 if(SiS_PrepareDDC(SiS_Pr)) {
9509 SiS_SetStop(SiS_Pr); 9306 SiS_SetStop(SiS_Pr);
9307#ifdef SIS_XORG_XF86
9510#ifdef TWDEBUG 9308#ifdef TWDEBUG
9511 xf86DrvMsg(0, X_INFO, "Probe: Prepare failed\n"); 9309 xf86DrvMsg(0, X_INFO, "Probe: Prepare failed\n");
9512#endif 9310#endif
9513 return(0xFFFF); 9311#endif
9312 return 0xFFFF;
9514 } 9313 }
9515 mask = 0xf0; 9314 mask = 0xf0;
9516 value = 0x20; 9315 value = 0x20;
9517 if(SiS_Pr->SiS_DDC_DeviceAddr == 0xa0) { 9316 if(SiS_Pr->SiS_DDC_DeviceAddr == 0xa0) {
9518 temp = (unsigned char)SiS_ReadDDC2Data(SiS_Pr, 0); 9317 temp = (unsigned char)SiS_ReadDDC2Data(SiS_Pr);
9519 SiS_SendACK(SiS_Pr, 0); 9318 SiS_SendACK(SiS_Pr, 0);
9520 if(temp == 0) { 9319 if(temp == 0) {
9521 mask = 0xff; 9320 mask = 0xff;
@@ -9523,34 +9322,41 @@ SiS_DoProbeDDC(SiS_Private *SiS_Pr)
9523 } else { 9322 } else {
9524 failed = TRUE; 9323 failed = TRUE;
9525 ret = 0xFFFF; 9324 ret = 0xFFFF;
9325#ifdef SIS_XORG_XF86
9526#ifdef TWDEBUG 9326#ifdef TWDEBUG
9527 xf86DrvMsg(0, X_INFO, "Probe: Read 1 failed\n"); 9327 xf86DrvMsg(0, X_INFO, "Probe: Read 1 failed\n");
9528#endif 9328#endif
9329#endif
9529 } 9330 }
9530 } 9331 }
9531 if(failed == FALSE) { 9332 if(failed == FALSE) {
9532 temp = (unsigned char)SiS_ReadDDC2Data(SiS_Pr, 0); 9333 temp = (unsigned char)SiS_ReadDDC2Data(SiS_Pr);
9533 SiS_SendACK(SiS_Pr, 1); 9334 SiS_SendACK(SiS_Pr, 1);
9534 temp &= mask; 9335 temp &= mask;
9535 if(temp == value) ret = 0; 9336 if(temp == value) ret = 0;
9536 else { 9337 else {
9537 ret = 0xFFFF; 9338 ret = 0xFFFF;
9339#ifdef SIS_XORG_XF86
9538#ifdef TWDEBUG 9340#ifdef TWDEBUG
9539 xf86DrvMsg(0, X_INFO, "Probe: Read 2 failed\n"); 9341 xf86DrvMsg(0, X_INFO, "Probe: Read 2 failed\n");
9540#endif 9342#endif
9343#endif
9541 if(SiS_Pr->SiS_DDC_DeviceAddr == 0xa0) { 9344 if(SiS_Pr->SiS_DDC_DeviceAddr == 0xa0) {
9542 if(temp == 0x30) ret = 0; 9345 if(temp == 0x30) ret = 0;
9543 } 9346 }
9544 } 9347 }
9545 } 9348 }
9546 SiS_SetStop(SiS_Pr); 9349 SiS_SetStop(SiS_Pr);
9547 return(ret); 9350 return ret;
9548} 9351}
9549 9352
9550static USHORT 9353#ifndef SIS_XORG_XF86
9551SiS_ProbeDDC(SiS_Private *SiS_Pr) 9354static
9355#endif
9356unsigned short
9357SiS_ProbeDDC(struct SiS_Private *SiS_Pr)
9552{ 9358{
9553 USHORT flag; 9359 unsigned short flag;
9554 9360
9555 flag = 0x180; 9361 flag = 0x180;
9556 SiS_Pr->SiS_DDC_DeviceAddr = 0xa0; 9362 SiS_Pr->SiS_DDC_DeviceAddr = 0xa0;
@@ -9560,16 +9366,19 @@ SiS_ProbeDDC(SiS_Private *SiS_Pr)
9560 SiS_Pr->SiS_DDC_DeviceAddr = 0xa6; 9366 SiS_Pr->SiS_DDC_DeviceAddr = 0xa6;
9561 if(!(SiS_DoProbeDDC(SiS_Pr))) flag |= 0x10; 9367 if(!(SiS_DoProbeDDC(SiS_Pr))) flag |= 0x10;
9562 if(!(flag & 0x1a)) flag = 0; 9368 if(!(flag & 0x1a)) flag = 0;
9563 return(flag); 9369 return flag;
9564} 9370}
9565 9371
9566static USHORT 9372#ifndef SIS_XORG_XF86
9567SiS_ReadDDC(SiS_Private *SiS_Pr, USHORT DDCdatatype, unsigned char *buffer) 9373static
9374#endif
9375unsigned short
9376SiS_ReadDDC(struct SiS_Private *SiS_Pr, unsigned short DDCdatatype, unsigned char *buffer)
9568{ 9377{
9569 USHORT flag, length, i; 9378 unsigned short flag, length, i;
9570 unsigned char chksum,gotcha; 9379 unsigned char chksum,gotcha;
9571 9380
9572 if(DDCdatatype > 4) return 0xFFFF; 9381 if(DDCdatatype > 4) return 0xFFFF;
9573 9382
9574 flag = 0; 9383 flag = 0;
9575 SiS_SetSwitchDDC2(SiS_Pr); 9384 SiS_SetSwitchDDC2(SiS_Pr);
@@ -9579,21 +9388,21 @@ SiS_ReadDDC(SiS_Private *SiS_Pr, USHORT DDCdatatype, unsigned char *buffer)
9579 chksum = 0; 9388 chksum = 0;
9580 gotcha = 0; 9389 gotcha = 0;
9581 for(i=0; i<length; i++) { 9390 for(i=0; i<length; i++) {
9582 buffer[i] = (unsigned char)SiS_ReadDDC2Data(SiS_Pr, 0); 9391 buffer[i] = (unsigned char)SiS_ReadDDC2Data(SiS_Pr);
9583 chksum += buffer[i]; 9392 chksum += buffer[i];
9584 gotcha |= buffer[i]; 9393 gotcha |= buffer[i];
9585 SiS_SendACK(SiS_Pr, 0); 9394 SiS_SendACK(SiS_Pr, 0);
9586 } 9395 }
9587 buffer[i] = (unsigned char)SiS_ReadDDC2Data(SiS_Pr, 0); 9396 buffer[i] = (unsigned char)SiS_ReadDDC2Data(SiS_Pr);
9588 chksum += buffer[i]; 9397 chksum += buffer[i];
9589 SiS_SendACK(SiS_Pr, 1); 9398 SiS_SendACK(SiS_Pr, 1);
9590 if(gotcha) flag = (USHORT)chksum; 9399 if(gotcha) flag = (unsigned short)chksum;
9591 else flag = 0xFFFF; 9400 else flag = 0xFFFF;
9592 } else { 9401 } else {
9593 flag = 0xFFFF; 9402 flag = 0xFFFF;
9594 } 9403 }
9595 SiS_SetStop(SiS_Pr); 9404 SiS_SetStop(SiS_Pr);
9596 return(flag); 9405 return flag;
9597} 9406}
9598 9407
9599/* Our private DDC functions 9408/* Our private DDC functions
@@ -9617,17 +9426,25 @@ SiS_ReadDDC(SiS_Private *SiS_Pr, USHORT DDCdatatype, unsigned char *buffer)
9617 if DDCdatatype = 0: Returns supported DDC modes 9426 if DDCdatatype = 0: Returns supported DDC modes
9618 9427
9619 */ 9428 */
9620USHORT 9429unsigned short
9621SiS_HandleDDC(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine, 9430SiS_HandleDDC(struct SiS_Private *SiS_Pr, unsigned int VBFlags, int VGAEngine,
9622 USHORT adaptnum, USHORT DDCdatatype, unsigned char *buffer) 9431 unsigned short adaptnum, unsigned short DDCdatatype, unsigned char *buffer,
9432 unsigned int VBFlags2)
9623{ 9433{
9624 unsigned char sr1f,cr17=1; 9434 unsigned char sr1f, cr17=1;
9625 USHORT result; 9435 unsigned short result;
9626 9436
9627 if(adaptnum > 2) return 0xFFFF; 9437 if(adaptnum > 2)
9628 if(DDCdatatype > 4) return 0xFFFF; 9438 return 0xFFFF;
9629 if((!(VBFlags & VB_VIDEOBRIDGE)) && (adaptnum > 0)) return 0xFFFF; 9439
9630 if(SiS_InitDDCRegs(SiS_Pr, VBFlags, VGAEngine, adaptnum, DDCdatatype, FALSE) == 0xFFFF) return 0xFFFF; 9440 if(DDCdatatype > 4)
9441 return 0xFFFF;
9442
9443 if((!(VBFlags2 & VB2_VIDEOBRIDGE)) && (adaptnum > 0))
9444 return 0xFFFF;
9445
9446 if(SiS_InitDDCRegs(SiS_Pr, VBFlags, VGAEngine, adaptnum, DDCdatatype, FALSE, VBFlags2) == 0xFFFF)
9447 return 0xFFFF;
9631 9448
9632 sr1f = SiS_GetReg(SiS_Pr->SiS_P3c4,0x1f); 9449 sr1f = SiS_GetReg(SiS_Pr->SiS_P3c4,0x1f);
9633 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x1f,0x3f,0x04); 9450 SiS_SetRegANDOR(SiS_Pr->SiS_P3c4,0x1f,0x3f,0x04);
@@ -9656,10 +9473,12 @@ SiS_HandleDDC(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine,
9656 (buffer[4] == 0xff) && (buffer[5] == 0xff) && 9473 (buffer[4] == 0xff) && (buffer[5] == 0xff) &&
9657 (buffer[6] == 0xff) && (buffer[7] == 0x00) && 9474 (buffer[6] == 0xff) && (buffer[7] == 0x00) &&
9658 (buffer[0x12] == 1)) { 9475 (buffer[0x12] == 1)) {
9659 if(adaptnum == 1) { 9476 if(!SiS_Pr->DDCPortMixup) {
9660 if(!(buffer[0x14] & 0x80)) result = 0xFFFE; 9477 if(adaptnum == 1) {
9661 } else { 9478 if(!(buffer[0x14] & 0x80)) result = 0xFFFE;
9662 if(buffer[0x14] & 0x80) result = 0xFFFE; 9479 } else {
9480 if(buffer[0x14] & 0x80) result = 0xFFFE;
9481 }
9663 } 9482 }
9664 } 9483 }
9665 } 9484 }
@@ -9671,832 +9490,10 @@ SiS_HandleDDC(SiS_Private *SiS_Pr, unsigned long VBFlags, int VGAEngine,
9671 return result; 9490 return result;
9672} 9491}
9673 9492
9674#ifdef LINUX_XF86
9675
9676static BOOLEAN
9677checkedid1(unsigned char *buffer)
9678{
9679 /* Check header */
9680 if((buffer[0] != 0x00) ||
9681 (buffer[1] != 0xff) ||
9682 (buffer[2] != 0xff) ||
9683 (buffer[3] != 0xff) ||
9684 (buffer[4] != 0xff) ||
9685 (buffer[5] != 0xff) ||
9686 (buffer[6] != 0xff) ||
9687 (buffer[7] != 0x00))
9688 return FALSE;
9689
9690 /* Check EDID version and revision */
9691 if((buffer[0x12] != 1) || (buffer[0x13] > 4)) return FALSE;
9692
9693 /* Check week of manufacture for sanity */
9694 if(buffer[0x10] > 53) return FALSE;
9695
9696 /* Check year of manufacture for sanity */
9697 if(buffer[0x11] > 40) return FALSE;
9698
9699 return TRUE;
9700}
9701
9702static BOOLEAN
9703checkedid2(unsigned char *buffer)
9704{
9705 USHORT year = buffer[6] | (buffer[7] << 8);
9706
9707 /* Check EDID version */
9708 if((buffer[0] & 0xf0) != 0x20) return FALSE;
9709
9710 /* Check week of manufacture for sanity */
9711 if(buffer[5] > 53) return FALSE;
9712
9713 /* Check year of manufacture for sanity */
9714 if((year != 0) && ((year < 1990) || (year > 2030))) return FALSE;
9715
9716 return TRUE;
9717}
9718
9719/* Sense the LCD parameters (CR36, CR37) via DDC */
9720/* SiS30x(B) only */
9721USHORT
9722SiS_SenseLCDDDC(SiS_Private *SiS_Pr, SISPtr pSiS)
9723{
9724 USHORT DDCdatatype, paneltype, flag, xres=0, yres=0;
9725 USHORT index, myindex, lumsize, numcodes, panelvendor, panelproduct;
9726 int maxx=0, maxy=0, prefx=0, prefy=0;
9727 unsigned char cr37=0, seekcode;
9728 BOOLEAN checkexpand = FALSE;
9729 BOOLEAN havesync = FALSE;
9730 BOOLEAN indb = FALSE;
9731 int retry, i;
9732 unsigned char buffer[256];
9733
9734 for(i=0; i<7; i++) SiS_Pr->CP_DataValid[i] = FALSE;
9735 SiS_Pr->CP_HaveCustomData = FALSE;
9736 SiS_Pr->CP_MaxX = SiS_Pr->CP_MaxY = SiS_Pr->CP_MaxClock = 0;
9737 SiS_Pr->CP_PreferredX = SiS_Pr->CP_PreferredY = 0;
9738 SiS_Pr->CP_PreferredIndex = -1;
9739 SiS_Pr->CP_PrefClock = 0;
9740 SiS_Pr->PanelSelfDetected = FALSE;
9741
9742 if(!(pSiS->VBFlags & (VB_301|VB_301B|VB_301C|VB_302B))) return 0;
9743 if(pSiS->VBFlags & VB_30xBDH) return 0;
9744
9745 if(SiS_InitDDCRegs(SiS_Pr, pSiS->VBFlags, pSiS->VGAEngine, 1, 0, FALSE) == 0xFFFF) return 0;
9746
9747 SiS_Pr->SiS_DDC_SecAddr = 0x00;
9748
9749 /* Probe supported DA's */
9750 flag = SiS_ProbeDDC(SiS_Pr);
9751#ifdef TWDEBUG
9752 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_INFO,
9753 "CRT2 DDC capabilities 0x%x\n", flag);
9754#endif
9755 if(flag & 0x10) {
9756 SiS_Pr->SiS_DDC_DeviceAddr = 0xa6; /* EDID V2 (FP) */
9757 DDCdatatype = 4;
9758 } else if(flag & 0x08) {
9759 SiS_Pr->SiS_DDC_DeviceAddr = 0xa2; /* EDID V2 (P&D-D Monitor) */
9760 DDCdatatype = 3;
9761 } else if(flag & 0x02) {
9762 SiS_Pr->SiS_DDC_DeviceAddr = 0xa0; /* EDID V1 */
9763 DDCdatatype = 1;
9764 } else return 0; /* no DDC support (or no device attached) */
9765
9766 /* Read the entire EDID */
9767 retry = 2;
9768 do {
9769 if(SiS_ReadDDC(SiS_Pr, DDCdatatype, buffer)) {
9770 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED,
9771 "CRT2: DDC read failed (attempt %d), %s\n",
9772 (3-retry), (retry == 1) ? "giving up" : "retrying");
9773 retry--;
9774 if(retry == 0) return 0xFFFF;
9775 } else break;
9776 } while(1);
9777
9778#ifdef TWDEBUG
9779 for(i=0; i<256; i+=16) {
9780 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED,
9781 "%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
9782 buffer[i], buffer[i+1], buffer[i+2], buffer[i+3],
9783 buffer[i+4], buffer[i+5], buffer[i+6], buffer[i+7],
9784 buffer[i+8], buffer[i+9], buffer[i+10], buffer[i+11],
9785 buffer[i+12], buffer[i+13], buffer[i+14], buffer[i+15]);
9786 }
9787#endif
9788
9789 /* Analyze EDID and retrieve LCD panel information */
9790 paneltype = 0;
9791 switch(DDCdatatype) {
9792 case 1: /* Analyze EDID V1 */
9793 /* Catch a few clear cases: */
9794 if(!(checkedid1(buffer))) {
9795 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED,
9796 "LCD sense: EDID corrupt\n");
9797 return 0;
9798 }
9799
9800 if(!(buffer[0x14] & 0x80)) {
9801 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED,
9802 "LCD sense: Attached display expects analog input (0x%02x)\n",
9803 buffer[0x14]);
9804 return 0;
9805 }
9806
9807 if((buffer[0x18] & 0x18) != 0x08) {
9808 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED,
9809 "LCD sense: Warning: Attached display is not of RGB but of %s type (0x%02x)\n",
9810 ((buffer[0x18] & 0x18) == 0x00) ? "monochrome/greyscale" :
9811 ( ((buffer[0x18] & 0x18) == 0x10) ? "non-RGB multicolor" :
9812 "undefined"),
9813 buffer[0x18]);
9814 }
9815
9816 /* Now analyze the first Detailed Timing Block and see
9817 * if the preferred timing mode is stored there. If so,
9818 * check if this is a standard panel for which we already
9819 * know the timing.
9820 */
9821
9822 paneltype = Panel_Custom;
9823 checkexpand = FALSE;
9824
9825 panelvendor = buffer[9] | (buffer[8] << 8);
9826 panelproduct = buffer[10] | (buffer[11] << 8);
9827
9828 /* Overrule bogus preferred modes from database */
9829 if((indb = SiS_FindPanelFromDB(pSiS, panelvendor, panelproduct, &maxx, &maxy, &prefx, &prefy))) {
9830 if(prefx) SiS_Pr->CP_PreferredX = xres = prefx;
9831 if(prefy) SiS_Pr->CP_PreferredY = yres = prefy;
9832 }
9833
9834 if(buffer[0x18] & 0x02) {
9835
9836 USHORT pclk = (buffer[0x36] | (buffer[0x37] << 8));
9837 USHORT phb = (buffer[0x39] | ((buffer[0x3a] & 0x0f) << 8));
9838 USHORT pvb = (buffer[0x3c] | ((buffer[0x3d] & 0x0f) << 8));
9839
9840 if(!xres) SiS_Pr->CP_PreferredX = xres = buffer[0x38] | ((buffer[0x3a] & 0xf0) << 4);
9841 if(!yres) SiS_Pr->CP_PreferredY = yres = buffer[0x3b] | ((buffer[0x3d] & 0xf0) << 4);
9842
9843 switch(xres) {
9844#if 0 /* Treat as custom */
9845 case 800:
9846 if(yres == 600) {
9847 paneltype = Panel_800x600;
9848 checkexpand = TRUE;
9849 }
9850 break;
9851#endif
9852 case 1024:
9853 if(yres == 768) {
9854 paneltype = Panel_1024x768;
9855 checkexpand = TRUE;
9856 }
9857 break;
9858 case 1280:
9859 if(yres == 1024) {
9860 paneltype = Panel_1280x1024;
9861 checkexpand = TRUE;
9862 } else if(yres == 960) {
9863 if(pSiS->VGAEngine == SIS_300_VGA) {
9864 paneltype = Panel300_1280x960;
9865 } else {
9866 paneltype = Panel310_1280x960;
9867 }
9868 } else if(yres == 768) {
9869 if( (pclk == 8100) &&
9870 (phb == (1688 - 1280)) &&
9871 (pvb == (802 - 768)) ) {
9872 paneltype = Panel_1280x768;
9873 checkexpand = FALSE;
9874 cr37 |= 0x10;
9875 }
9876 } else if(yres == 800) {
9877 if( (pclk == 6900) &&
9878 (phb == (1408 - 1280)) &&
9879 (pvb == (816 - 800)) ) {
9880 paneltype = Panel_1280x800;
9881 }
9882 }
9883 break;
9884 case 1400:
9885 if(pSiS->VGAEngine == SIS_315_VGA) {
9886 if(yres == 1050) {
9887 paneltype = Panel310_1400x1050;
9888 checkexpand = TRUE;
9889 }
9890 }
9891 break;
9892 case 1600:
9893 if(pSiS->VGAEngine == SIS_315_VGA) {
9894 if(pSiS->VBFlags & VB_301C) {
9895 if(yres == 1200) {
9896 paneltype = Panel310_1600x1200;
9897 checkexpand = TRUE;
9898 }
9899 }
9900 }
9901 break;
9902 }
9903
9904 /* Save sync: This is used if "Pass 1:1" is off; in this case
9905 * we always use the panel's native mode = this "preferred mode"
9906 * we just have been analysing. Hence, we also need its sync.
9907 */
9908 if((buffer[0x47] & 0x18) == 0x18) {
9909 cr37 |= ((((buffer[0x47] & 0x06) ^ 0x06) << 5) | 0x20);
9910 havesync = TRUE;
9911 } else {
9912 /* What now? There is no digital separate output timing... */
9913 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_WARNING,
9914 "LCD sense: Unable to retrieve Sync polarity information\n");
9915 cr37 |= 0xc0; /* Default */
9916 }
9917
9918 }
9919
9920 /* Check against our database; eg. Sanyo Z2 projector reports
9921 * 1024x768 as preferred mode, although it supports 1280x720
9922 * natively in non-HDCP mode. Treat such wrongly reporting
9923 * panels as custom and fixup actual maximum resolutions.
9924 */
9925 if(paneltype != Panel_Custom) {
9926 if(indb) {
9927 paneltype = Panel_Custom;
9928 SiS_Pr->CP_MaxX = maxx;
9929 SiS_Pr->CP_MaxY = maxy;
9930 /* Leave preferred unchanged (MUST contain a valid mode!) */
9931 }
9932 }
9933
9934 /* If we still don't know what panel this is, we take it
9935 * as a custom panel and derive the timing data from the
9936 * detailed timing blocks
9937 */
9938 if(paneltype == Panel_Custom) {
9939
9940 int i, temp, base = 0x36;
9941 unsigned long estpack;
9942 const unsigned short estx[] = {
9943 720, 720, 640, 640, 640, 640, 800, 800,
9944 800, 800, 832,1024,1024,1024,1024,1280,
9945 1152
9946 };
9947 const unsigned short esty[] = {
9948 400, 400, 480, 480, 480, 480, 600, 600,
9949 600, 600, 624, 768, 768, 768, 768,1024,
9950 870
9951 };
9952 const int estclk[] = {
9953 0, 0, 25100, 0, 31500, 31500, 36100, 40000,
9954 50100, 49500, 0, 0, 65100, 75200, 78700,135200,
9955 0
9956 };
9957
9958 paneltype = 0;
9959 SiS_Pr->CP_Supports64048075 = TRUE;
9960
9961 /* Find the maximum resolution */
9962
9963 /* 1. From Established timings */
9964 estpack = (buffer[0x23] << 9) | (buffer[0x24] << 1) | ((buffer[0x25] >> 7) & 0x01);
9965 for(i=16; i>=0; i--) {
9966 if(estpack & (1 << i)) {
9967 if(estx[16 - i] > SiS_Pr->CP_MaxX) SiS_Pr->CP_MaxX = estx[16 - i];
9968 if(esty[16 - i] > SiS_Pr->CP_MaxY) SiS_Pr->CP_MaxY = esty[16 - i];
9969 if(estclk[16 - i] > SiS_Pr->CP_MaxClock) SiS_Pr->CP_MaxClock = estclk[16 - i];
9970 }
9971 }
9972
9973 /* By default we drive the LCD at 75Hz in 640x480 mode; if
9974 * the panel does not provide this mode, use 60hz
9975 */
9976 if(!(buffer[0x23] & 0x04)) SiS_Pr->CP_Supports64048075 = FALSE;
9977
9978 /* 2. From Standard Timings */
9979 for(i=0x26; i < 0x36; i+=2) {
9980 if((buffer[i] != 0x01) && (buffer[i+1] != 0x01)) {
9981 temp = (buffer[i] + 31) * 8;
9982 if(temp > SiS_Pr->CP_MaxX) SiS_Pr->CP_MaxX = temp;
9983 switch((buffer[i+1] & 0xc0) >> 6) {
9984 case 0x03: temp = temp * 9 / 16; break;
9985 case 0x02: temp = temp * 4 / 5; break;
9986 case 0x01: temp = temp * 3 / 4; break;
9987 }
9988 if(temp > SiS_Pr->CP_MaxY) SiS_Pr->CP_MaxY = temp;
9989 }
9990 }
9991
9992 /* Now extract the Detailed Timings and convert them into modes */
9993
9994 for(i = 0; i < 4; i++, base += 18) {
9995
9996 /* Is this a detailed timing block or a monitor descriptor? */
9997 if(buffer[base] || buffer[base+1] || buffer[base+2]) {
9998
9999 xres = buffer[base+2] | ((buffer[base+4] & 0xf0) << 4);
10000 yres = buffer[base+5] | ((buffer[base+7] & 0xf0) << 4);
10001
10002 SiS_Pr->CP_HDisplay[i] = xres;
10003 SiS_Pr->CP_HSyncStart[i] = xres + (buffer[base+8] | ((buffer[base+11] & 0xc0) << 2));
10004 SiS_Pr->CP_HSyncEnd[i] = SiS_Pr->CP_HSyncStart[i] + (buffer[base+9] | ((buffer[base+11] & 0x30) << 4));
10005 SiS_Pr->CP_HTotal[i] = xres + (buffer[base+3] | ((buffer[base+4] & 0x0f) << 8));
10006 SiS_Pr->CP_HBlankStart[i] = xres + 1;
10007 SiS_Pr->CP_HBlankEnd[i] = SiS_Pr->CP_HTotal[i];
10008
10009 SiS_Pr->CP_VDisplay[i] = yres;
10010 SiS_Pr->CP_VSyncStart[i] = yres + (((buffer[base+10] & 0xf0) >> 4) | ((buffer[base+11] & 0x0c) << 2));
10011 SiS_Pr->CP_VSyncEnd[i] = SiS_Pr->CP_VSyncStart[i] + ((buffer[base+10] & 0x0f) | ((buffer[base+11] & 0x03) << 4));
10012 SiS_Pr->CP_VTotal[i] = yres + (buffer[base+6] | ((buffer[base+7] & 0x0f) << 8));
10013 SiS_Pr->CP_VBlankStart[i] = yres + 1;
10014 SiS_Pr->CP_VBlankEnd[i] = SiS_Pr->CP_VTotal[i];
10015
10016 SiS_Pr->CP_Clock[i] = (buffer[base] | (buffer[base+1] << 8)) * 10;
10017
10018 SiS_Pr->CP_DataValid[i] = TRUE;
10019
10020 /* Sort out invalid timings, interlace and too high clocks */
10021 if((SiS_Pr->CP_HDisplay[i] & 7) ||
10022 (SiS_Pr->CP_HDisplay[i] > SiS_Pr->CP_HSyncStart[i]) ||
10023 (SiS_Pr->CP_HDisplay[i] >= SiS_Pr->CP_HSyncEnd[i]) ||
10024 (SiS_Pr->CP_HDisplay[i] >= SiS_Pr->CP_HTotal[i]) ||
10025 (SiS_Pr->CP_HSyncStart[i] >= SiS_Pr->CP_HSyncEnd[i]) ||
10026 (SiS_Pr->CP_HSyncStart[i] > SiS_Pr->CP_HTotal[i]) ||
10027 (SiS_Pr->CP_HSyncEnd[i] > SiS_Pr->CP_HTotal[i]) ||
10028 (SiS_Pr->CP_VDisplay[i] > SiS_Pr->CP_VSyncStart[i]) ||
10029 (SiS_Pr->CP_VDisplay[i] >= SiS_Pr->CP_VSyncEnd[i]) ||
10030 (SiS_Pr->CP_VDisplay[i] >= SiS_Pr->CP_VTotal[i]) ||
10031 (SiS_Pr->CP_VSyncStart[i] > SiS_Pr->CP_VSyncEnd[i]) ||
10032 (SiS_Pr->CP_VSyncStart[i] > SiS_Pr->CP_VTotal[i]) ||
10033 (SiS_Pr->CP_VSyncEnd[i] > SiS_Pr->CP_VTotal[i]) ||
10034 (((pSiS->VBFlags & VB_301C) && (SiS_Pr->CP_Clock[i] > 162500)) ||
10035 ((!(pSiS->VBFlags & VB_301C)) &&
10036 ((SiS_Pr->CP_Clock[i] > 108200) || (SiS_Pr->CP_VDisplay[i] > 1024) ||
10037 (SiS_Pr->CP_HDisplay[i] > 1600)))) ||
10038 (buffer[base+17] & 0x80)) {
10039
10040 SiS_Pr->CP_DataValid[i] = FALSE;
10041
10042 } else {
10043
10044 SiS_Pr->CP_HaveCustomData = TRUE;
10045
10046 if(xres > SiS_Pr->CP_MaxX) SiS_Pr->CP_MaxX = xres;
10047 if(yres > SiS_Pr->CP_MaxY) SiS_Pr->CP_MaxY = yres;
10048 if(SiS_Pr->CP_Clock[i] > SiS_Pr->CP_MaxClock) SiS_Pr->CP_MaxClock = SiS_Pr->CP_Clock[i];
10049
10050 if((SiS_Pr->CP_PreferredX == xres) && (SiS_Pr->CP_PreferredY == yres)) {
10051 SiS_Pr->CP_PreferredIndex = i;
10052 SiS_MakeClockRegs(pSiS->pScrn, SiS_Pr->CP_Clock[i], &SiS_Pr->CP_PrefSR2B, &SiS_Pr->CP_PrefSR2C);
10053 SiS_Pr->CP_PrefClock = (SiS_Pr->CP_Clock[i] / 1000) + 1;
10054 }
10055
10056 /* Extract the sync polarisation information. This only works
10057 * if the Flags indicate a digital separate output.
10058 */
10059 if((buffer[base+17] & 0x18) == 0x18) {
10060 SiS_Pr->CP_HSync_P[i] = (buffer[base+17] & 0x02) ? TRUE : FALSE;
10061 SiS_Pr->CP_VSync_P[i] = (buffer[base+17] & 0x04) ? TRUE : FALSE;
10062 SiS_Pr->CP_SyncValid[i] = TRUE;
10063 if((i == SiS_Pr->CP_PreferredIndex) && (!havesync)) {
10064 cr37 |= ((((buffer[base+17] & 0x06) ^ 0x06) << 5) | 0x20);
10065 havesync = TRUE;
10066 }
10067 } else {
10068 SiS_Pr->CP_SyncValid[i] = FALSE;
10069 }
10070
10071 }
10072
10073 } else if((!buffer[base]) && (!buffer[base+1]) && (!buffer[base+2]) && (!buffer[base+4])) {
10074
10075 /* Maximum pixclock from Monitor Range Limits */
10076 if((buffer[base+3] == 0xfd) && (buffer[base+9] != 0xff)) {
10077 int maxclk = buffer[base+9] * 10;
10078 /* More than 170 is not supported anyway */
10079 if(maxclk <= 170) SiS_Pr->CP_MaxClock = maxclk * 1000;
10080 }
10081
10082 }
10083
10084 }
10085
10086 if(SiS_Pr->CP_MaxX && SiS_Pr->CP_MaxY) {
10087 paneltype = Panel_Custom;
10088 checkexpand = FALSE;
10089 cr37 |= 0x10;
10090 SiS_Pr->CP_Vendor = panelvendor;
10091 SiS_Pr->CP_Product = panelproduct;
10092 }
10093
10094 }
10095
10096 if(paneltype && checkexpand) {
10097 /* If any of the Established low-res modes is supported, the
10098 * panel can scale automatically. For 800x600 panels, we only
10099 * check the even lower ones.
10100 */
10101 if(paneltype == Panel_800x600) {
10102 if(buffer[0x23] & 0xfc) cr37 |= 0x10;
10103 } else {
10104 if(buffer[0x23]) cr37 |= 0x10;
10105 }
10106 }
10107
10108 break;
10109
10110 case 3: /* Analyze EDID V2 */
10111 case 4:
10112 index = 0;
10113
10114 if(!(checkedid2(buffer))) {
10115 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED,
10116 "LCD sense: EDID corrupt\n");
10117 return 0;
10118 }
10119
10120 if((buffer[0x41] & 0x0f) == 0x03) {
10121 index = 0x42 + 3;
10122 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED,
10123 "LCD sense: Display supports TMDS input on primary interface\n");
10124 } else if((buffer[0x41] & 0xf0) == 0x30) {
10125 index = 0x46 + 3;
10126 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED,
10127 "LCD sense: Display supports TMDS input on secondary interface\n");
10128 } else {
10129 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED,
10130 "LCD sense: Display does not support TMDS video interface (0x%02x)\n",
10131 buffer[0x41]);
10132 return 0;
10133 }
10134
10135 SiS_Pr->CP_Vendor = panelvendor = buffer[2] | (buffer[1] << 8);
10136 SiS_Pr->CP_Product = panelproduct = buffer[3] | (buffer[4] << 8);
10137
10138 paneltype = Panel_Custom;
10139 SiS_Pr->CP_MaxX = SiS_Pr->CP_PreferredX = xres = buffer[0x76] | (buffer[0x77] << 8);
10140 SiS_Pr->CP_MaxY = SiS_Pr->CP_PreferredY = yres = buffer[0x78] | (buffer[0x79] << 8);
10141
10142 switch(xres) {
10143#if 0
10144 case 800:
10145 if(yres == 600) {
10146 paneltype = Panel_800x600;
10147 checkexpand = TRUE;
10148 }
10149 break;
10150#endif
10151 case 1024:
10152 if(yres == 768) {
10153 paneltype = Panel_1024x768;
10154 checkexpand = TRUE;
10155 }
10156 break;
10157 case 1280:
10158 if(yres == 960) {
10159 if(pSiS->VGAEngine == SIS_315_VGA) {
10160 paneltype = Panel310_1280x960;
10161 } else {
10162 paneltype = Panel300_1280x960;
10163 }
10164 } else if(yres == 1024) {
10165 paneltype = Panel_1280x1024;
10166 checkexpand = TRUE;
10167 }
10168 /* 1280x768 treated as custom here */
10169 break;
10170 case 1400:
10171 if(pSiS->VGAEngine == SIS_315_VGA) {
10172 if(yres == 1050) {
10173 paneltype = Panel310_1400x1050;
10174 checkexpand = TRUE;
10175 }
10176 }
10177 break;
10178 case 1600:
10179 if(pSiS->VGAEngine == SIS_315_VGA) {
10180 if(pSiS->VBFlags & VB_301C) {
10181 if(yres == 1200) {
10182 paneltype = Panel310_1600x1200;
10183 checkexpand = TRUE;
10184 }
10185 }
10186 }
10187 break;
10188 }
10189
10190 /* Determine if RGB18 or RGB24 */
10191 if(index) {
10192 if((buffer[index] == 0x20) || (buffer[index] == 0x34)) {
10193 cr37 |= 0x01;
10194 }
10195 }
10196
10197 if(checkexpand) {
10198 /* TODO - for now, we let the panel scale */
10199 cr37 |= 0x10;
10200 }
10201
10202 /* Now seek 4-Byte Timing codes and extract sync pol info */
10203 index = 0x80;
10204 if(buffer[0x7e] & 0x20) { /* skip Luminance Table (if provided) */
10205 lumsize = buffer[0x80] & 0x1f;
10206 if(buffer[0x80] & 0x80) lumsize *= 3;
10207 lumsize++; /* luminance header byte */
10208 index += lumsize;
10209 }
10210#if 0 /* "pixel rate" = pixel clock? */
10211 if(buffer[0x7e] & 0x1c) {
10212 for(i=0; i<((buffer[0x7e] & 0x1c) >> 2); i++) {
10213 if(buffer[index + (i*8) + 6] && (buffer[index + (i*8) + 7] & 0x0f)) {
10214 int clk = (buffer[index + (i*8) + 6] | ((buffer[index + (i*8) + 7] & 0x0f) << 4)) * 1000;
10215 if(clk > SiS_Pr->CP_MaxClock) SiS_Pr->CP_MaxClock = clk;
10216 }
10217 }
10218 }
10219#endif
10220 index += (((buffer[0x7e] & 0x1c) >> 2) * 8); /* skip Frequency Ranges */
10221 if(buffer[0x7e] & 0x03) {
10222 for(i=0; i<(buffer[0x7e] & 0x03); i++) {
10223 if((buffer[index + (i*27) + 9]) || (buffer[index + (i*27) + 10])) {
10224 int clk = ((buffer[index + (i*27) + 9]) | ((buffer[index + (i*27) + 9]) << 8)) * 10;
10225 if(clk > SiS_Pr->CP_MaxClock) SiS_Pr->CP_MaxClock = clk;
10226 }
10227 }
10228 }
10229 index += ((buffer[0x7e] & 0x03) * 27); /* skip Detailed Range Limits */
10230 numcodes = (buffer[0x7f] & 0xf8) >> 3;
10231 if(numcodes) {
10232 myindex = index;
10233 seekcode = (xres - 256) / 16;
10234 for(i=0; i<numcodes; i++) {
10235 if(buffer[myindex] == seekcode) break;
10236 myindex += 4;
10237 }
10238 if(buffer[myindex] == seekcode) {
10239 cr37 |= ((((buffer[myindex + 1] & 0x0c) ^ 0x0c) << 4) | 0x20);
10240 havesync = TRUE;
10241 } else {
10242 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_WARNING,
10243 "LCD sense: Unable to retrieve Sync polarity information\n");
10244 }
10245 } else {
10246 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_WARNING,
10247 "LCD sense: Unable to retrieve Sync polarity information\n");
10248 }
10249
10250 /* Check against our database; Eg. Sanyo projector reports
10251 * 1024x768 in non-HDPC mode, although it supports 1280x720.
10252 * Treat such wrongly reporting panels as custom.
10253 */
10254 if(paneltype != Panel_Custom) {
10255 int maxx, maxy, prefx, prefy;
10256 if((SiS_FindPanelFromDB(pSiS, panelvendor, panelproduct, &maxx, &maxy, &prefx, &prefy))) {
10257 paneltype = Panel_Custom;
10258 SiS_Pr->CP_MaxX = maxx;
10259 SiS_Pr->CP_MaxY = maxy;
10260 cr37 |= 0x10;
10261 /* Leave preferred unchanged (MUST be a valid mode!) */
10262 }
10263 }
10264
10265 /* Now seek the detailed timing descriptions for custom panels */
10266 if(paneltype == Panel_Custom) {
10267
10268 SiS_Pr->CP_Supports64048075 = TRUE;
10269
10270 index += (numcodes * 4);
10271 numcodes = buffer[0x7f] & 0x07;
10272 for(i=0; i<numcodes; i++, index += 18) {
10273 xres = buffer[index+2] | ((buffer[index+4] & 0xf0) << 4);
10274 yres = buffer[index+5] | ((buffer[index+7] & 0xf0) << 4);
10275
10276 SiS_Pr->CP_HDisplay[i] = xres;
10277 SiS_Pr->CP_HSyncStart[i] = xres + (buffer[index+8] | ((buffer[index+11] & 0xc0) << 2));
10278 SiS_Pr->CP_HSyncEnd[i] = SiS_Pr->CP_HSyncStart[i] + (buffer[index+9] | ((buffer[index+11] & 0x30) << 4));
10279 SiS_Pr->CP_HTotal[i] = xres + (buffer[index+3] | ((buffer[index+4] & 0x0f) << 8));
10280 SiS_Pr->CP_HBlankStart[i] = xres + 1;
10281 SiS_Pr->CP_HBlankEnd[i] = SiS_Pr->CP_HTotal[i];
10282
10283 SiS_Pr->CP_VDisplay[i] = yres;
10284 SiS_Pr->CP_VSyncStart[i] = yres + (((buffer[index+10] & 0xf0) >> 4) | ((buffer[index+11] & 0x0c) << 2));
10285 SiS_Pr->CP_VSyncEnd[i] = SiS_Pr->CP_VSyncStart[i] + ((buffer[index+10] & 0x0f) | ((buffer[index+11] & 0x03) << 4));
10286 SiS_Pr->CP_VTotal[i] = yres + (buffer[index+6] | ((buffer[index+7] & 0x0f) << 8));
10287 SiS_Pr->CP_VBlankStart[i] = yres + 1;
10288 SiS_Pr->CP_VBlankEnd[i] = SiS_Pr->CP_VTotal[i];
10289
10290 SiS_Pr->CP_Clock[i] = (buffer[index] | (buffer[index+1] << 8)) * 10;
10291
10292 SiS_Pr->CP_DataValid[i] = TRUE;
10293
10294 if((SiS_Pr->CP_HDisplay[i] & 7) ||
10295 (SiS_Pr->CP_HDisplay[i] > SiS_Pr->CP_HSyncStart[i]) ||
10296 (SiS_Pr->CP_HDisplay[i] >= SiS_Pr->CP_HSyncEnd[i]) ||
10297 (SiS_Pr->CP_HDisplay[i] >= SiS_Pr->CP_HTotal[i]) ||
10298 (SiS_Pr->CP_HSyncStart[i] >= SiS_Pr->CP_HSyncEnd[i]) ||
10299 (SiS_Pr->CP_HSyncStart[i] > SiS_Pr->CP_HTotal[i]) ||
10300 (SiS_Pr->CP_HSyncEnd[i] > SiS_Pr->CP_HTotal[i]) ||
10301 (SiS_Pr->CP_VDisplay[i] > SiS_Pr->CP_VSyncStart[i]) ||
10302 (SiS_Pr->CP_VDisplay[i] >= SiS_Pr->CP_VSyncEnd[i]) ||
10303 (SiS_Pr->CP_VDisplay[i] >= SiS_Pr->CP_VTotal[i]) ||
10304 (SiS_Pr->CP_VSyncStart[i] > SiS_Pr->CP_VSyncEnd[i]) ||
10305 (SiS_Pr->CP_VSyncStart[i] > SiS_Pr->CP_VTotal[i]) ||
10306 (SiS_Pr->CP_VSyncEnd[i] > SiS_Pr->CP_VTotal[i]) ||
10307 (((pSiS->VBFlags & VB_301C) && (SiS_Pr->CP_Clock[i] > 162500)) ||
10308 ((!(pSiS->VBFlags & VB_301C)) &&
10309 ((SiS_Pr->CP_Clock[i] > 108200) || (SiS_Pr->CP_VDisplay[i] > 1024)))) ||
10310 (buffer[index + 17] & 0x80)) {
10311
10312 SiS_Pr->CP_DataValid[i] = FALSE;
10313
10314 } else {
10315
10316 SiS_Pr->CP_HaveCustomData = TRUE;
10317
10318 if(SiS_Pr->CP_Clock[i] > SiS_Pr->CP_MaxClock) SiS_Pr->CP_MaxClock = SiS_Pr->CP_Clock[i];
10319
10320 if((SiS_Pr->CP_PreferredX == xres) && (SiS_Pr->CP_PreferredY == yres)) {
10321 SiS_Pr->CP_PreferredIndex = i;
10322 SiS_MakeClockRegs(pSiS->pScrn, SiS_Pr->CP_Clock[i], &SiS_Pr->CP_PrefSR2B, &SiS_Pr->CP_PrefSR2C);
10323 SiS_Pr->CP_PrefClock = (SiS_Pr->CP_Clock[i] / 1000) + 1;
10324 if(!havesync) {
10325 cr37 |= ((((buffer[index + 17] & 0x06) ^ 0x06) << 5) | 0x20);
10326 havesync = TRUE;
10327 }
10328 }
10329
10330 SiS_Pr->CP_HSync_P[i] = (buffer[index + 17] & 0x02) ? TRUE : FALSE;
10331 SiS_Pr->CP_VSync_P[i] = (buffer[index + 17] & 0x04) ? TRUE : FALSE;
10332 SiS_Pr->CP_SyncValid[i] = TRUE;
10333
10334 }
10335 }
10336
10337 cr37 |= 0x10;
10338
10339 }
10340
10341 break;
10342
10343 }
10344
10345 /* 1280x960 panels are always RGB24, unable to scale and use
10346 * high active sync polarity
10347 */
10348 if(pSiS->VGAEngine == SIS_315_VGA) {
10349 if(paneltype == Panel310_1280x960) cr37 &= 0x0e;
10350 } else {
10351 if(paneltype == Panel300_1280x960) cr37 &= 0x0e;
10352 }
10353
10354 for(i = 0; i < 7; i++) {
10355 if(SiS_Pr->CP_DataValid[i]) {
10356 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED,
10357 "Non-standard LCD/DVI-D timing data no. %d:\n", i);
10358 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED,
10359 " HDisplay %d HSync %d HSyncEnd %d HTotal %d\n",
10360 SiS_Pr->CP_HDisplay[i], SiS_Pr->CP_HSyncStart[i],
10361 SiS_Pr->CP_HSyncEnd[i], SiS_Pr->CP_HTotal[i]);
10362 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED,
10363 " VDisplay %d VSync %d VSyncEnd %d VTotal %d\n",
10364 SiS_Pr->CP_VDisplay[i], SiS_Pr->CP_VSyncStart[i],
10365 SiS_Pr->CP_VSyncEnd[i], SiS_Pr->CP_VTotal[i]);
10366 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED,
10367 " Pixel clock: %3.3fMhz\n", (float)SiS_Pr->CP_Clock[i] / 1000);
10368 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_INFO,
10369 " To use this, add \"%dx%d\" to the list of Modes in the Screen section\n",
10370 SiS_Pr->CP_HDisplay[i],
10371 SiS_Pr->CP_VDisplay[i]);
10372 }
10373 }
10374
10375 if(paneltype) {
10376 if(!SiS_Pr->CP_PreferredX) SiS_Pr->CP_PreferredX = SiS_Pr->CP_MaxX;
10377 if(!SiS_Pr->CP_PreferredY) SiS_Pr->CP_PreferredY = SiS_Pr->CP_MaxY;
10378 SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x32,0x08);
10379 SiS_SetReg(SiS_Pr->SiS_P3d4,0x36,paneltype);
10380 cr37 &= 0xf1;
10381 SiS_SetRegANDOR(SiS_Pr->SiS_P3d4,0x37,0x0c,cr37);
10382 SiS_Pr->PanelSelfDetected = TRUE;
10383#ifdef TWDEBUG
10384 xf86DrvMsgVerb(pSiS->pScrn->scrnIndex, X_PROBED, 3,
10385 "LCD sense: [DDC LCD results: 0x%02x, 0x%02x]\n", paneltype, cr37);
10386#endif
10387 } else {
10388 SiS_SetRegAND(SiS_Pr->SiS_P3d4,0x32,~0x08);
10389 SiS_SetReg(SiS_Pr->SiS_P3d4,0x36,0x00);
10390 }
10391 return 0;
10392}
10393
10394USHORT
10395SiS_SenseVGA2DDC(SiS_Private *SiS_Pr, SISPtr pSiS)
10396{
10397 USHORT DDCdatatype,flag;
10398 BOOLEAN foundcrt = FALSE;
10399 int retry;
10400 unsigned char buffer[256];
10401
10402 if(!(pSiS->VBFlags & (VB_301|VB_301B|VB_301C|VB_302B))) return 0;
10403
10404 if(SiS_InitDDCRegs(SiS_Pr, pSiS->VBFlags, pSiS->VGAEngine, 2, 0, FALSE) == 0xFFFF) return 0;
10405
10406 SiS_Pr->SiS_DDC_SecAddr = 0x00;
10407
10408 /* Probe supported DA's */
10409 flag = SiS_ProbeDDC(SiS_Pr);
10410 if(flag & 0x10) {
10411 SiS_Pr->SiS_DDC_DeviceAddr = 0xa6; /* EDID V2 (FP) */
10412 DDCdatatype = 4;
10413 } else if(flag & 0x08) {
10414 SiS_Pr->SiS_DDC_DeviceAddr = 0xa2; /* EDID V2 (P&D-D Monitor) */
10415 DDCdatatype = 3;
10416 } else if(flag & 0x02) {
10417 SiS_Pr->SiS_DDC_DeviceAddr = 0xa0; /* EDID V1 */
10418 DDCdatatype = 1;
10419 } else {
10420 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED,
10421 "VGA2 sense: Do DDC answer\n");
10422 return 0; /* no DDC support (or no device attached) */
10423 }
10424
10425 /* Read the entire EDID */
10426 retry = 2;
10427 do {
10428 if(SiS_ReadDDC(SiS_Pr, DDCdatatype, buffer)) {
10429 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_PROBED,
10430 "VGA2 sense: DDC read failed (attempt %d), %s\n",
10431 (3-retry), (retry == 1) ? "giving up" : "retrying");
10432 retry--;
10433 if(retry == 0) return 0xFFFF;
10434 } else break;
10435 } while(1);
10436
10437 /* Analyze EDID. We don't have many chances to
10438 * distinguish a flat panel from a CRT...
10439 */
10440 switch(DDCdatatype) {
10441 case 1:
10442 if(!(checkedid1(buffer))) {
10443 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_ERROR,
10444 "VGA2 sense: EDID corrupt\n");
10445 return 0;
10446 }
10447 if(buffer[0x14] & 0x80) { /* Display uses digital input */
10448 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_ERROR,
10449 "VGA2 sense: Attached display expects digital input\n");
10450 return 0;
10451 }
10452 SiS_Pr->CP_Vendor = buffer[9] | (buffer[8] << 8);
10453 SiS_Pr->CP_Product = buffer[10] | (buffer[11] << 8);
10454 foundcrt = TRUE;
10455 break;
10456 case 3:
10457 case 4:
10458 if(!(checkedid2(buffer))) {
10459 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_ERROR,
10460 "VGA2 sense: EDID corrupt\n");
10461 return 0;
10462 }
10463 if( ((buffer[0x41] & 0x0f) != 0x01) && /* Display does not support analog input */
10464 ((buffer[0x41] & 0x0f) != 0x02) &&
10465 ((buffer[0x41] & 0xf0) != 0x10) &&
10466 ((buffer[0x41] & 0xf0) != 0x20) ) {
10467 xf86DrvMsg(pSiS->pScrn->scrnIndex, X_ERROR,
10468 "VGA2 sense: Attached display does not support analog input (0x%02x)\n",
10469 buffer[0x41]);
10470 return 0;
10471 }
10472 SiS_Pr->CP_Vendor = buffer[2] | (buffer[1] << 8);
10473 SiS_Pr->CP_Product = buffer[3] | (buffer[4] << 8);
10474 foundcrt = TRUE;
10475 break;
10476 }
10477
10478 if(foundcrt) {
10479 SiS_SetRegOR(SiS_Pr->SiS_P3d4,0x32,0x10);
10480 }
10481 return(0);
10482}
10483
10484#endif
10485
10486void
10487SiS_SetCH70xxANDOR(SiS_Private *SiS_Pr, USHORT tempax,USHORT tempbh)
10488{
10489 USHORT tempbl;
10490
10491 tempbl = SiS_GetCH70xx(SiS_Pr,(tempax & 0x00FF));
10492 tempbl = (((tempbl & tempbh) << 8) | tempax);
10493 SiS_SetCH70xx(SiS_Pr,tempbl);
10494}
10495
10496/* Generic I2C functions for Chrontel & DDC --------- */ 9493/* Generic I2C functions for Chrontel & DDC --------- */
10497 9494
10498static void 9495static void
10499SiS_SetSwitchDDC2(SiS_Private *SiS_Pr) 9496SiS_SetSwitchDDC2(struct SiS_Private *SiS_Pr)
10500{ 9497{
10501 SiS_SetSCLKHigh(SiS_Pr); 9498 SiS_SetSCLKHigh(SiS_Pr);
10502 SiS_WaitRetrace1(SiS_Pr); 9499 SiS_WaitRetrace1(SiS_Pr);
@@ -10505,125 +9502,127 @@ SiS_SetSwitchDDC2(SiS_Private *SiS_Pr)
10505 SiS_WaitRetrace1(SiS_Pr); 9502 SiS_WaitRetrace1(SiS_Pr);
10506} 9503}
10507 9504
10508USHORT 9505unsigned short
10509SiS_ReadDDC1Bit(SiS_Private *SiS_Pr) 9506SiS_ReadDDC1Bit(struct SiS_Private *SiS_Pr)
10510{ 9507{
10511 SiS_WaitRetrace1(SiS_Pr); 9508 SiS_WaitRetrace1(SiS_Pr);
10512 return((SiS_GetReg(SiS_Pr->SiS_P3c4,0x11) & 0x02) >> 1); 9509 return ((SiS_GetReg(SiS_Pr->SiS_P3c4,0x11) & 0x02) >> 1);
10513} 9510}
10514 9511
10515/* Set I2C start condition */ 9512/* Set I2C start condition */
10516/* This is done by a SD high-to-low transition while SC is high */ 9513/* This is done by a SD high-to-low transition while SC is high */
10517static USHORT 9514static unsigned short
10518SiS_SetStart(SiS_Private *SiS_Pr) 9515SiS_SetStart(struct SiS_Private *SiS_Pr)
10519{ 9516{
10520 if(SiS_SetSCLKLow(SiS_Pr)) return 0xFFFF; /* (SC->low) */ 9517 if(SiS_SetSCLKLow(SiS_Pr)) return 0xFFFF; /* (SC->low) */
10521 SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, 9518 SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,
10522 SiS_Pr->SiS_DDC_Index, 9519 SiS_Pr->SiS_DDC_Index,
10523 SiS_Pr->SiS_DDC_NData, 9520 SiS_Pr->SiS_DDC_NData,
10524 SiS_Pr->SiS_DDC_Data); /* SD->high */ 9521 SiS_Pr->SiS_DDC_Data); /* SD->high */
10525 if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* SC->high */ 9522 if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* SC->high */
10526 SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, 9523 SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,
10527 SiS_Pr->SiS_DDC_Index, 9524 SiS_Pr->SiS_DDC_Index,
10528 SiS_Pr->SiS_DDC_NData, 9525 SiS_Pr->SiS_DDC_NData,
10529 0x00); /* SD->low = start condition */ 9526 0x00); /* SD->low = start condition */
10530 if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* (SC->low) */ 9527 if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* (SC->low) */
10531 return 0; 9528 return 0;
10532} 9529}
10533 9530
10534/* Set I2C stop condition */ 9531/* Set I2C stop condition */
10535/* This is done by a SD low-to-high transition while SC is high */ 9532/* This is done by a SD low-to-high transition while SC is high */
10536static USHORT 9533static unsigned short
10537SiS_SetStop(SiS_Private *SiS_Pr) 9534SiS_SetStop(struct SiS_Private *SiS_Pr)
10538{ 9535{
10539 if(SiS_SetSCLKLow(SiS_Pr)) return 0xFFFF; /* (SC->low) */ 9536 if(SiS_SetSCLKLow(SiS_Pr)) return 0xFFFF; /* (SC->low) */
10540 SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, 9537 SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,
10541 SiS_Pr->SiS_DDC_Index, 9538 SiS_Pr->SiS_DDC_Index,
10542 SiS_Pr->SiS_DDC_NData, 9539 SiS_Pr->SiS_DDC_NData,
10543 0x00); /* SD->low */ 9540 0x00); /* SD->low */
10544 if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* SC->high */ 9541 if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* SC->high */
10545 SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, 9542 SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,
10546 SiS_Pr->SiS_DDC_Index, 9543 SiS_Pr->SiS_DDC_Index,
10547 SiS_Pr->SiS_DDC_NData, 9544 SiS_Pr->SiS_DDC_NData,
10548 SiS_Pr->SiS_DDC_Data); /* SD->high = stop condition */ 9545 SiS_Pr->SiS_DDC_Data); /* SD->high = stop condition */
10549 if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* (SC->high) */ 9546 if(SiS_SetSCLKHigh(SiS_Pr)) return 0xFFFF; /* (SC->high) */
10550 return 0; 9547 return 0;
10551} 9548}
10552 9549
10553/* Write 8 bits of data */ 9550/* Write 8 bits of data */
10554static USHORT 9551static unsigned short
10555SiS_WriteDDC2Data(SiS_Private *SiS_Pr, USHORT tempax) 9552SiS_WriteDDC2Data(struct SiS_Private *SiS_Pr, unsigned short tempax)
10556{ 9553{
10557 USHORT i,flag,temp; 9554 unsigned short i,flag,temp;
10558 9555
10559 flag = 0x80; 9556 flag = 0x80;
10560 for(i=0; i<8; i++) { 9557 for(i = 0; i < 8; i++) {
10561 SiS_SetSCLKLow(SiS_Pr); /* SC->low */ 9558 SiS_SetSCLKLow(SiS_Pr); /* SC->low */
10562 if(tempax & flag) { 9559 if(tempax & flag) {
10563 SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, 9560 SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,
10564 SiS_Pr->SiS_DDC_Index, 9561 SiS_Pr->SiS_DDC_Index,
10565 SiS_Pr->SiS_DDC_NData, 9562 SiS_Pr->SiS_DDC_NData,
10566 SiS_Pr->SiS_DDC_Data); /* Write bit (1) to SD */ 9563 SiS_Pr->SiS_DDC_Data); /* Write bit (1) to SD */
10567 } else { 9564 } else {
10568 SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, 9565 SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,
10569 SiS_Pr->SiS_DDC_Index, 9566 SiS_Pr->SiS_DDC_Index,
10570 SiS_Pr->SiS_DDC_NData, 9567 SiS_Pr->SiS_DDC_NData,
10571 0x00); /* Write bit (0) to SD */ 9568 0x00); /* Write bit (0) to SD */
10572 } 9569 }
10573 SiS_SetSCLKHigh(SiS_Pr); /* SC->high */ 9570 SiS_SetSCLKHigh(SiS_Pr); /* SC->high */
10574 flag >>= 1; 9571 flag >>= 1;
10575 } 9572 }
10576 temp = SiS_CheckACK(SiS_Pr); /* Check acknowledge */ 9573 temp = SiS_CheckACK(SiS_Pr); /* Check acknowledge */
10577 return(temp); 9574 return temp;
10578} 9575}
10579 9576
10580static USHORT 9577static unsigned short
10581SiS_ReadDDC2Data(SiS_Private *SiS_Pr, USHORT tempax) 9578SiS_ReadDDC2Data(struct SiS_Private *SiS_Pr)
10582{ 9579{
10583 USHORT i,temp,getdata; 9580 unsigned short i, temp, getdata;
10584 9581
10585 getdata=0; 9582 getdata = 0;
10586 for(i=0; i<8; i++) { 9583 for(i = 0; i < 8; i++) {
10587 getdata <<= 1; 9584 getdata <<= 1;
10588 SiS_SetSCLKLow(SiS_Pr); 9585 SiS_SetSCLKLow(SiS_Pr);
10589 SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, 9586 SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,
10590 SiS_Pr->SiS_DDC_Index, 9587 SiS_Pr->SiS_DDC_Index,
10591 SiS_Pr->SiS_DDC_NData, 9588 SiS_Pr->SiS_DDC_NData,
10592 SiS_Pr->SiS_DDC_Data); 9589 SiS_Pr->SiS_DDC_Data);
10593 SiS_SetSCLKHigh(SiS_Pr); 9590 SiS_SetSCLKHigh(SiS_Pr);
10594 temp = SiS_GetReg(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index); 9591 temp = SiS_GetReg(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index);
10595 if(temp & SiS_Pr->SiS_DDC_Data) getdata |= 0x01; 9592 if(temp & SiS_Pr->SiS_DDC_Data) getdata |= 0x01;
10596 } 9593 }
10597 return(getdata); 9594 return getdata;
10598} 9595}
10599 9596
10600static USHORT 9597static unsigned short
10601SiS_SetSCLKLow(SiS_Private *SiS_Pr) 9598SiS_SetSCLKLow(struct SiS_Private *SiS_Pr)
10602{ 9599{
10603 SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, 9600 SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,
10604 SiS_Pr->SiS_DDC_Index, 9601 SiS_Pr->SiS_DDC_Index,
10605 SiS_Pr->SiS_DDC_NClk, 9602 SiS_Pr->SiS_DDC_NClk,
10606 0x00); /* SetSCLKLow() */ 9603 0x00); /* SetSCLKLow() */
10607 SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT); 9604 SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT);
10608 return 0; 9605 return 0;
10609} 9606}
10610 9607
10611static USHORT 9608static unsigned short
10612SiS_SetSCLKHigh(SiS_Private *SiS_Pr) 9609SiS_SetSCLKHigh(struct SiS_Private *SiS_Pr)
10613{ 9610{
10614 USHORT temp, watchdog=1000; 9611 unsigned short temp, watchdog=1000;
10615 9612
10616 SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, 9613 SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,
10617 SiS_Pr->SiS_DDC_Index, 9614 SiS_Pr->SiS_DDC_Index,
10618 SiS_Pr->SiS_DDC_NClk, 9615 SiS_Pr->SiS_DDC_NClk,
10619 SiS_Pr->SiS_DDC_Clk); /* SetSCLKHigh() */ 9616 SiS_Pr->SiS_DDC_Clk); /* SetSCLKHigh() */
10620 do { 9617 do {
10621 temp = SiS_GetReg(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index); 9618 temp = SiS_GetReg(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index);
10622 } while((!(temp & SiS_Pr->SiS_DDC_Clk)) && --watchdog); 9619 } while((!(temp & SiS_Pr->SiS_DDC_Clk)) && --watchdog);
10623 if (!watchdog) { 9620 if (!watchdog) {
9621#ifdef SIS_XORG_XF86
10624#ifdef TWDEBUG 9622#ifdef TWDEBUG
10625 xf86DrvMsg(0, X_INFO, "SetClkHigh failed\n"); 9623 xf86DrvMsg(0, X_INFO, "SetClkHigh failed\n");
10626#endif 9624#endif
9625#endif
10627 return 0xFFFF; 9626 return 0xFFFF;
10628 } 9627 }
10629 SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT); 9628 SiS_DDC2Delay(SiS_Pr,SiS_I2CDELAYSHORT);
@@ -10632,21 +9631,21 @@ SiS_SetSCLKHigh(SiS_Private *SiS_Pr)
10632 9631
10633/* Check I2C acknowledge */ 9632/* Check I2C acknowledge */
10634/* Returns 0 if ack ok, non-0 if ack not ok */ 9633/* Returns 0 if ack ok, non-0 if ack not ok */
10635static USHORT 9634static unsigned short
10636SiS_CheckACK(SiS_Private *SiS_Pr) 9635SiS_CheckACK(struct SiS_Private *SiS_Pr)
10637{ 9636{
10638 USHORT tempah; 9637 unsigned short tempah;
10639 9638
10640 SiS_SetSCLKLow(SiS_Pr); /* (SC->low) */ 9639 SiS_SetSCLKLow(SiS_Pr); /* (SC->low) */
10641 SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port, 9640 SiS_SetRegANDOR(SiS_Pr->SiS_DDC_Port,
10642 SiS_Pr->SiS_DDC_Index, 9641 SiS_Pr->SiS_DDC_Index,
10643 SiS_Pr->SiS_DDC_NData, 9642 SiS_Pr->SiS_DDC_NData,
10644 SiS_Pr->SiS_DDC_Data); /* (SD->high) */ 9643 SiS_Pr->SiS_DDC_Data); /* (SD->high) */
10645 SiS_SetSCLKHigh(SiS_Pr); /* SC->high = clock impulse for ack */ 9644 SiS_SetSCLKHigh(SiS_Pr); /* SC->high = clock impulse for ack */
10646 tempah = SiS_GetReg(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index); /* Read SD */ 9645 tempah = SiS_GetReg(SiS_Pr->SiS_DDC_Port,SiS_Pr->SiS_DDC_Index); /* Read SD */
10647 SiS_SetSCLKLow(SiS_Pr); /* SC->low = end of clock impulse */ 9646 SiS_SetSCLKLow(SiS_Pr); /* SC->low = end of clock impulse */
10648 if(tempah & SiS_Pr->SiS_DDC_Data) return(1); /* Ack OK if bit = 0 */ 9647 if(tempah & SiS_Pr->SiS_DDC_Data) return 1; /* Ack OK if bit = 0 */
10649 else return(0); 9648 return 0;
10650} 9649}
10651 9650
10652/* End of I2C functions ----------------------- */ 9651/* End of I2C functions ----------------------- */
@@ -10656,67 +9655,67 @@ SiS_CheckACK(SiS_Private *SiS_Pr)
10656 9655
10657#ifdef SIS315H 9656#ifdef SIS315H
10658 9657
10659static USHORT 9658static unsigned short
10660GetRAMDACromptr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 9659GetRAMDACromptr(struct SiS_Private *SiS_Pr)
10661{ 9660{
10662 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; 9661 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
10663 USHORT romptr; 9662 unsigned short romptr;
10664 9663
10665 if(HwInfo->jChipType < SIS_330) { 9664 if(SiS_Pr->ChipType < SIS_330) {
10666 romptr = SISGETROMW(0x128); 9665 romptr = SISGETROMW(0x128);
10667 if(SiS_Pr->SiS_VBType & VB_SIS301B302B) 9666 if(SiS_Pr->SiS_VBType & VB_SIS30xB)
10668 romptr = SISGETROMW(0x12a); 9667 romptr = SISGETROMW(0x12a);
10669 } else { 9668 } else {
10670 romptr = SISGETROMW(0x1a8); 9669 romptr = SISGETROMW(0x1a8);
10671 if(SiS_Pr->SiS_VBType & VB_SIS301B302B) 9670 if(SiS_Pr->SiS_VBType & VB_SIS30xB)
10672 romptr = SISGETROMW(0x1aa); 9671 romptr = SISGETROMW(0x1aa);
10673 } 9672 }
10674 return(romptr); 9673 return romptr;
10675} 9674}
10676 9675
10677static USHORT 9676static unsigned short
10678GetLCDromptr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 9677GetLCDromptr(struct SiS_Private *SiS_Pr)
10679{ 9678{
10680 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; 9679 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
10681 USHORT romptr; 9680 unsigned short romptr;
10682 9681
10683 if(HwInfo->jChipType < SIS_330) { 9682 if(SiS_Pr->ChipType < SIS_330) {
10684 romptr = SISGETROMW(0x120); 9683 romptr = SISGETROMW(0x120);
10685 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) 9684 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV)
10686 romptr = SISGETROMW(0x122); 9685 romptr = SISGETROMW(0x122);
10687 } else { 9686 } else {
10688 romptr = SISGETROMW(0x1a0); 9687 romptr = SISGETROMW(0x1a0);
10689 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) 9688 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV)
10690 romptr = SISGETROMW(0x1a2); 9689 romptr = SISGETROMW(0x1a2);
10691 } 9690 }
10692 return(romptr); 9691 return romptr;
10693} 9692}
10694 9693
10695static USHORT 9694static unsigned short
10696GetTVromptr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 9695GetTVromptr(struct SiS_Private *SiS_Pr)
10697{ 9696{
10698 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; 9697 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
10699 USHORT romptr; 9698 unsigned short romptr;
10700 9699
10701 if(HwInfo->jChipType < SIS_330) { 9700 if(SiS_Pr->ChipType < SIS_330) {
10702 romptr = SISGETROMW(0x114); 9701 romptr = SISGETROMW(0x114);
10703 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) 9702 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV)
10704 romptr = SISGETROMW(0x11a); 9703 romptr = SISGETROMW(0x11a);
10705 } else { 9704 } else {
10706 romptr = SISGETROMW(0x194); 9705 romptr = SISGETROMW(0x194);
10707 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) 9706 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV)
10708 romptr = SISGETROMW(0x19a); 9707 romptr = SISGETROMW(0x19a);
10709 } 9708 }
10710 return(romptr); 9709 return romptr;
10711} 9710}
10712 9711
10713static USHORT 9712static unsigned short
10714GetLCDPtrIndexBIOS(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 9713GetLCDPtrIndexBIOS(struct SiS_Private *SiS_Pr)
10715{ 9714{
10716 USHORT index; 9715 unsigned short index;
10717 9716
10718 if((IS_SIS650) && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) { 9717 if((IS_SIS650) && (SiS_Pr->SiS_VBType & VB_SISLVDS)) {
10719 if(!(SiS_IsNotM650orLater(SiS_Pr, HwInfo))) { 9718 if(!(SiS_IsNotM650orLater(SiS_Pr))) {
10720 if((index = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) & 0xf0)) { 9719 if((index = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) & 0xf0)) {
10721 index >>= 4; 9720 index >>= 4;
10722 index *= 3; 9721 index *= 3;
@@ -10729,7 +9728,12 @@ GetLCDPtrIndexBIOS(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
10729 9728
10730 index = SiS_GetBIOSLCDResInfo(SiS_Pr) & 0x0F; 9729 index = SiS_GetBIOSLCDResInfo(SiS_Pr) & 0x0F;
10731 if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) index -= 5; 9730 if(SiS_Pr->SiS_LCDResInfo == Panel_1400x1050) index -= 5;
10732 else if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) index -= 6; 9731 if(SiS_Pr->SiS_VBType & VB_SIS301C) { /* 1.15.20 and later (not VB specific) */
9732 if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) index -= 5;
9733 if(SiS_Pr->SiS_LCDResInfo == Panel_1280x768) index -= 5;
9734 } else {
9735 if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) index -= 6;
9736 }
10733 index--; 9737 index--;
10734 index *= 3; 9738 index *= 3;
10735 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) index += 2; 9739 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) index += 2;
@@ -10737,10 +9741,10 @@ GetLCDPtrIndexBIOS(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
10737 return index; 9741 return index;
10738} 9742}
10739 9743
10740static USHORT 9744static unsigned short
10741GetLCDPtrIndex(SiS_Private *SiS_Pr) 9745GetLCDPtrIndex(struct SiS_Private *SiS_Pr)
10742{ 9746{
10743 USHORT index; 9747 unsigned short index;
10744 9748
10745 index = ((SiS_GetBIOSLCDResInfo(SiS_Pr) & 0x0F) - 1) * 3; 9749 index = ((SiS_GetBIOSLCDResInfo(SiS_Pr) & 0x0F) - 1) * 3;
10746 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) index += 2; 9750 if(SiS_Pr->SiS_LCDInfo & DontExpandLCD) index += 2;
@@ -10748,10 +9752,10 @@ GetLCDPtrIndex(SiS_Private *SiS_Pr)
10748 return index; 9752 return index;
10749} 9753}
10750 9754
10751static USHORT 9755static unsigned short
10752GetTVPtrIndex(SiS_Private *SiS_Pr) 9756GetTVPtrIndex(struct SiS_Private *SiS_Pr)
10753{ 9757{
10754 USHORT index; 9758 unsigned short index;
10755 9759
10756 index = 0; 9760 index = 0;
10757 if(SiS_Pr->SiS_TVMode & TVSetPAL) index = 1; 9761 if(SiS_Pr->SiS_TVMode & TVSetPAL) index = 1;
@@ -10769,10 +9773,10 @@ GetTVPtrIndex(SiS_Private *SiS_Pr)
10769 return index; 9773 return index;
10770} 9774}
10771 9775
10772static ULONG 9776static unsigned int
10773GetOEMTVPtr661_2_GEN(SiS_Private *SiS_Pr, int addme) 9777GetOEMTVPtr661_2_GEN(struct SiS_Private *SiS_Pr, int addme)
10774{ 9778{
10775 USHORT index = 0, temp = 0; 9779 unsigned short index = 0, temp = 0;
10776 9780
10777 if(SiS_Pr->SiS_TVMode & TVSetPAL) index = 1; 9781 if(SiS_Pr->SiS_TVMode & TVSetPAL) index = 1;
10778 if(SiS_Pr->SiS_TVMode & TVSetPALM) index = 2; 9782 if(SiS_Pr->SiS_TVMode & TVSetPALM) index = 2;
@@ -10784,7 +9788,7 @@ GetOEMTVPtr661_2_GEN(SiS_Private *SiS_Pr, int addme)
10784 if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) index = 7; 9788 if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) index = 7;
10785 } 9789 }
10786 9790
10787 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { 9791 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) {
10788 if((!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || 9792 if((!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) ||
10789 (SiS_Pr->SiS_TVMode & TVSetTVSimuMode)) { 9793 (SiS_Pr->SiS_TVMode & TVSetTVSimuMode)) {
10790 index += addme; 9794 index += addme;
@@ -10792,25 +9796,25 @@ GetOEMTVPtr661_2_GEN(SiS_Private *SiS_Pr, int addme)
10792 } 9796 }
10793 temp += 0x0100; 9797 temp += 0x0100;
10794 } 9798 }
10795 return(ULONG)(index | (temp << 16)); 9799 return (unsigned int)(index | (temp << 16));
10796} 9800}
10797 9801
10798static ULONG 9802static unsigned int
10799GetOEMTVPtr661_2_OLD(SiS_Private *SiS_Pr) 9803GetOEMTVPtr661_2_OLD(struct SiS_Private *SiS_Pr)
10800{ 9804{
10801 return(GetOEMTVPtr661_2_GEN(SiS_Pr, 8)); 9805 return (GetOEMTVPtr661_2_GEN(SiS_Pr, 8));
10802} 9806}
10803 9807
10804#if 0 9808#if 0
10805static ULONG 9809static unsigned int
10806GetOEMTVPtr661_2_NEW(SiS_Private *SiS_Pr) 9810GetOEMTVPtr661_2_NEW(struct SiS_Private *SiS_Pr)
10807{ 9811{
10808 return(GetOEMTVPtr661_2_GEN(SiS_Pr, 6)); 9812 return (GetOEMTVPtr661_2_GEN(SiS_Pr, 6));
10809} 9813}
10810#endif 9814#endif
10811 9815
10812static int 9816static int
10813GetOEMTVPtr661(SiS_Private *SiS_Pr) 9817GetOEMTVPtr661(struct SiS_Private *SiS_Pr)
10814{ 9818{
10815 int index = 0; 9819 int index = 0;
10816 9820
@@ -10833,10 +9837,10 @@ GetOEMTVPtr661(SiS_Private *SiS_Pr)
10833} 9837}
10834 9838
10835static void 9839static void
10836SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo) 9840SetDelayComp(struct SiS_Private *SiS_Pr, unsigned short ModeNo)
10837{ 9841{
10838 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; 9842 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
10839 USHORT delay=0,index,myindex,temp,romptr=0; 9843 unsigned short delay=0,index,myindex,temp,romptr=0;
10840 BOOLEAN dochiptest = TRUE; 9844 BOOLEAN dochiptest = TRUE;
10841 9845
10842 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) { 9846 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCDA) {
@@ -10848,19 +9852,19 @@ SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo)
10848 /* Find delay (from ROM, internal tables, PCI subsystem) */ 9852 /* Find delay (from ROM, internal tables, PCI subsystem) */
10849 9853
10850 if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { /* ------------ VGA */ 9854 if(SiS_Pr->SiS_VBInfo & SetCRT2ToRAMDAC) { /* ------------ VGA */
10851 9855
10852 if((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) { 9856 if((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) {
10853 romptr = GetRAMDACromptr(SiS_Pr, HwInfo); 9857 romptr = GetRAMDACromptr(SiS_Pr);
10854 } 9858 }
10855 if(romptr) delay = ROMAddr[romptr]; 9859 if(romptr) delay = ROMAddr[romptr];
10856 else { 9860 else {
10857 delay = 0x04; 9861 delay = 0x04;
10858 if(SiS_Pr->SiS_VBType & VB_SIS301B302B) { 9862 if(SiS_Pr->SiS_VBType & VB_SIS30xB) {
10859 if(IS_SIS650) { 9863 if(IS_SIS650) {
10860 delay = 0x0a; 9864 delay = 0x0a;
10861 } else if(IS_SIS740) { 9865 } else if(IS_SIS740) {
10862 delay = 0x00; 9866 delay = 0x00;
10863 } else if(HwInfo->jChipType < SIS_330) { 9867 } else if(SiS_Pr->ChipType < SIS_330) {
10864 delay = 0x0c; 9868 delay = 0x0c;
10865 } else { 9869 } else {
10866 delay = 0x0c; 9870 delay = 0x0c;
@@ -10901,8 +9905,12 @@ SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo)
10901 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2d,0x0f,delay); 9905 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2d,0x0f,delay);
10902 } else { 9906 } else {
10903 delay = 0x0c; 9907 delay = 0x0c;
10904 if(SiS_Pr->SiS_VBType & VB_SIS301C) delay = 0x03; 9908 if(SiS_Pr->SiS_VBType & VB_SIS301C) {
10905 else if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { 9909 delay = 0x03;
9910 if((SiS_Pr->PanelXRes > 1280) && (SiS_Pr->PanelYRes > 1024)) {
9911 delay = 0x00;
9912 }
9913 } else if(SiS_Pr->SiS_VBType & VB_SISLVDS) {
10906 if(IS_SIS740) delay = 0x01; 9914 if(IS_SIS740) delay = 0x01;
10907 else delay = 0x03; 9915 else delay = 0x03;
10908 } 9916 }
@@ -10947,12 +9955,12 @@ SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo)
10947 9955
10948 if(!gotitfrompci) { 9956 if(!gotitfrompci) {
10949 9957
10950 index = GetLCDPtrIndexBIOS(SiS_Pr, HwInfo); 9958 index = GetLCDPtrIndexBIOS(SiS_Pr);
10951 myindex = GetLCDPtrIndex(SiS_Pr); 9959 myindex = GetLCDPtrIndex(SiS_Pr);
10952 9960
10953 if(IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) { 9961 if(IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SISLVDS)) {
10954 9962
10955 if(SiS_IsNotM650orLater(SiS_Pr, HwInfo)) { 9963 if(SiS_IsNotM650orLater(SiS_Pr)) {
10956 9964
10957 if((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) { 9965 if((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) {
10958 /* Always use the second pointer on 650; some BIOSes */ 9966 /* Always use the second pointer on 650; some BIOSes */
@@ -10978,11 +9986,12 @@ SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo)
10978 (!(SiS_Pr->SiS_ROMNew)) && 9986 (!(SiS_Pr->SiS_ROMNew)) &&
10979 (SiS_Pr->SiS_LCDResInfo != Panel_1280x1024) && 9987 (SiS_Pr->SiS_LCDResInfo != Panel_1280x1024) &&
10980 (SiS_Pr->SiS_LCDResInfo != Panel_1280x768) && 9988 (SiS_Pr->SiS_LCDResInfo != Panel_1280x768) &&
10981 (SiS_Pr->SiS_LCDResInfo != Panel_1280x960)) { 9989 (SiS_Pr->SiS_LCDResInfo != Panel_1280x960) &&
9990 (SiS_Pr->SiS_LCDResInfo != Panel_1600x1200) &&
9991 ((romptr = GetLCDromptr(SiS_Pr)))) {
10982 9992
10983 /* Data for 1280x1024 wrong in 301B BIOS */ 9993 /* Data for 1280x1024 wrong in 301B BIOS */
10984 romptr = GetLCDromptr(SiS_Pr, HwInfo); 9994 /* Data for 1600x1200 wrong in 301C BIOS */
10985 if(!romptr) return;
10986 delay = ROMAddr[(romptr + index)]; 9995 delay = ROMAddr[(romptr + index)];
10987 9996
10988 } else if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { 9997 } else if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
@@ -10993,14 +10002,15 @@ SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo)
10993 } else { 10002 } else {
10994 10003
10995 delay = SiS310_LCDDelayCompensation_301[myindex]; 10004 delay = SiS310_LCDDelayCompensation_301[myindex];
10996 if(SiS_Pr->SiS_VBType & VB_SIS301LV302LV) { 10005 if(SiS_Pr->SiS_VBType & VB_SISLVDS) {
10997 if(IS_SIS740) delay = 0x01; 10006 if(IS_SIS740) delay = 0x01;
10998 else if(HwInfo->jChipType <= SIS_315PRO) delay = SiS310_LCDDelayCompensation_3xx301LV[myindex]; 10007 else if(SiS_Pr->ChipType <= SIS_315PRO) delay = SiS310_LCDDelayCompensation_3xx301LV[myindex];
10999 else delay = SiS310_LCDDelayCompensation_650301LV[myindex]; 10008 else delay = SiS310_LCDDelayCompensation_650301LV[myindex];
11000 } else if(SiS_Pr->SiS_VBType & VB_SIS301C) { 10009 } else if(SiS_Pr->SiS_VBType & VB_SIS301C) {
11001 if(IS_SIS740) delay = 0x01; /* ? */ 10010 if(IS_SIS740) delay = 0x01; /* ? */
11002 else delay = 0x03; 10011 else delay = 0x03;
11003 } else if(SiS_Pr->SiS_VBType & VB_SIS301B302B) { 10012 if(SiS_Pr->SiS_LCDResInfo == Panel_1600x1200) delay = 0x00; /* experience */
10013 } else if(SiS_Pr->SiS_VBType & VB_SIS30xB) {
11004 if(IS_SIS740) delay = 0x01; 10014 if(IS_SIS740) delay = 0x01;
11005 else delay = SiS310_LCDDelayCompensation_3xx301B[myindex]; 10015 else delay = SiS310_LCDDelayCompensation_3xx301B[myindex];
11006 } 10016 }
@@ -11013,14 +10023,14 @@ SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo)
11013 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,0x0F,((delay << 4) & 0xf0)); 10023 SiS_SetRegANDOR(SiS_Pr->SiS_Part1Port,0x2D,0x0F,((delay << 4) & 0xf0));
11014 dochiptest = FALSE; 10024 dochiptest = FALSE;
11015 } 10025 }
11016 10026
11017 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { /* ------------ TV */ 10027 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { /* ------------ TV */
11018 10028
11019 index = GetTVPtrIndex(SiS_Pr); 10029 index = GetTVPtrIndex(SiS_Pr);
11020
11021 if(IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) {
11022 10030
11023 if(SiS_IsNotM650orLater(SiS_Pr,HwInfo)) { 10031 if(IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SISLVDS)) {
10032
10033 if(SiS_IsNotM650orLater(SiS_Pr)) {
11024 10034
11025 if((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) { 10035 if((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) {
11026 /* Always use the second pointer on 650; some BIOSes */ 10036 /* Always use the second pointer on 650; some BIOSes */
@@ -11062,7 +10072,7 @@ SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo)
11062 10072
11063 } else if((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) { 10073 } else if((SiS_Pr->SiS_UseROM) && (!(SiS_Pr->SiS_ROMNew))) {
11064 10074
11065 romptr = GetTVromptr(SiS_Pr, HwInfo); 10075 romptr = GetTVromptr(SiS_Pr);
11066 if(!romptr) return; 10076 if(!romptr) return;
11067 delay = ROMAddr[romptr + index]; 10077 delay = ROMAddr[romptr + index];
11068 10078
@@ -11073,7 +10083,7 @@ SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo)
11073 } else { 10083 } else {
11074 10084
11075 delay = SiS310_TVDelayCompensation_301[index]; 10085 delay = SiS310_TVDelayCompensation_301[index];
11076 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { 10086 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) {
11077 if(IS_SIS740) { 10087 if(IS_SIS740) {
11078 delay = SiS310_TVDelayCompensation_740301B[index]; 10088 delay = SiS310_TVDelayCompensation_740301B[index];
11079 /* LV: use 301 data? BIOS bug? */ 10089 /* LV: use 301 data? BIOS bug? */
@@ -11085,18 +10095,18 @@ SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo)
11085 10095
11086 } 10096 }
11087 10097
11088 if(SiS_LCDAEnabled(SiS_Pr, HwInfo)) { 10098 if(SiS_LCDAEnabled(SiS_Pr)) {
11089 delay &= 0x0f; 10099 delay &= 0x0f;
11090 dochiptest = FALSE; 10100 dochiptest = FALSE;
11091 } 10101 }
11092 10102
11093 } else return; 10103 } else return;
11094 10104
11095 /* Write delay */ 10105 /* Write delay */
11096 10106
11097 if(SiS_Pr->SiS_VBType & VB_SISVB) { 10107 if(SiS_Pr->SiS_VBType & VB_SISVB) {
11098 10108
11099 if(IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SIS301LV302LV) && dochiptest) { 10109 if(IS_SIS650 && (SiS_Pr->SiS_VBType & VB_SISLVDS) && dochiptest) {
11100 10110
11101 temp = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) & 0xf0) >> 4; 10111 temp = (SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) & 0xf0) >> 4;
11102 if(temp == 8) { /* 1400x1050 BIOS (COMPAL) */ 10112 if(temp == 8) { /* 1400x1050 BIOS (COMPAL) */
@@ -11134,11 +10144,10 @@ SetDelayComp(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo)
11134} 10144}
11135 10145
11136static void 10146static void
11137SetAntiFlicker(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, 10147SetAntiFlicker(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex)
11138 USHORT ModeNo,USHORT ModeIdIndex)
11139{ 10148{
11140 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; 10149 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
11141 USHORT index,temp,temp1,romptr=0; 10150 unsigned short index,temp,temp1,romptr=0;
11142 10151
11143 if(SiS_Pr->SiS_TVMode & (TVSetYPbPr750p|TVSetYPbPr525p)) return; 10152 if(SiS_Pr->SiS_TVMode & (TVSetYPbPr750p|TVSetYPbPr525p)) return;
11144 10153
@@ -11152,14 +10161,14 @@ SetAntiFlicker(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
11152 temp1 = temp; 10161 temp1 = temp;
11153 10162
11154 if(SiS_Pr->SiS_UseROM && (!(SiS_Pr->SiS_ROMNew))) { 10163 if(SiS_Pr->SiS_UseROM && (!(SiS_Pr->SiS_ROMNew))) {
11155 if(HwInfo->jChipType >= SIS_661) { 10164 if(SiS_Pr->ChipType >= SIS_661) {
11156 temp1 = GetOEMTVPtr661(SiS_Pr); 10165 temp1 = GetOEMTVPtr661(SiS_Pr);
11157 temp1 >>= 1; 10166 temp1 >>= 1;
11158 romptr = SISGETROMW(0x260); 10167 romptr = SISGETROMW(0x260);
11159 if(HwInfo->jChipType >= SIS_760) { 10168 if(SiS_Pr->ChipType >= SIS_760) {
11160 romptr = SISGETROMW(0x360); 10169 romptr = SISGETROMW(0x360);
11161 } 10170 }
11162 } else if(HwInfo->jChipType >= SIS_330) { 10171 } else if(SiS_Pr->ChipType >= SIS_330) {
11163 romptr = SISGETROMW(0x192); 10172 romptr = SISGETROMW(0x192);
11164 } else { 10173 } else {
11165 romptr = SISGETROMW(0x112); 10174 romptr = SISGETROMW(0x112);
@@ -11178,11 +10187,10 @@ SetAntiFlicker(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
11178} 10187}
11179 10188
11180static void 10189static void
11181SetEdgeEnhance(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, 10190SetEdgeEnhance(struct SiS_Private *SiS_Pr, unsigned short ModeNo,unsigned short ModeIdIndex)
11182 USHORT ModeNo,USHORT ModeIdIndex)
11183{ 10191{
11184 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; 10192 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
11185 USHORT index,temp,temp1,romptr=0; 10193 unsigned short index,temp,temp1,romptr=0;
11186 10194
11187 temp = temp1 = GetTVPtrIndex(SiS_Pr) >> 1; /* 0: NTSC/YPbPr, 1: PAL, 2: HiTV */ 10195 temp = temp1 = GetTVPtrIndex(SiS_Pr) >> 1; /* 0: NTSC/YPbPr, 1: PAL, 2: HiTV */
11188 10196
@@ -11192,14 +10200,14 @@ SetEdgeEnhance(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
11192 index = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].VB_ExtTVEdgeIndex; 10200 index = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].VB_ExtTVEdgeIndex;
11193 10201
11194 if(SiS_Pr->SiS_UseROM && (!(SiS_Pr->SiS_ROMNew))) { 10202 if(SiS_Pr->SiS_UseROM && (!(SiS_Pr->SiS_ROMNew))) {
11195 if(HwInfo->jChipType >= SIS_661) { 10203 if(SiS_Pr->ChipType >= SIS_661) {
11196 romptr = SISGETROMW(0x26c); 10204 romptr = SISGETROMW(0x26c);
11197 if(HwInfo->jChipType >= SIS_760) { 10205 if(SiS_Pr->ChipType >= SIS_760) {
11198 romptr = SISGETROMW(0x36c); 10206 romptr = SISGETROMW(0x36c);
11199 } 10207 }
11200 temp1 = GetOEMTVPtr661(SiS_Pr); 10208 temp1 = GetOEMTVPtr661(SiS_Pr);
11201 temp1 >>= 1; 10209 temp1 >>= 1;
11202 } else if(HwInfo->jChipType >= SIS_330) { 10210 } else if(SiS_Pr->ChipType >= SIS_330) {
11203 romptr = SISGETROMW(0x1a4); 10211 romptr = SISGETROMW(0x1a4);
11204 } else { 10212 } else {
11205 romptr = SISGETROMW(0x124); 10213 romptr = SISGETROMW(0x124);
@@ -11217,10 +10225,9 @@ SetEdgeEnhance(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
11217} 10225}
11218 10226
11219static void 10227static void
11220SetYFilter(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, 10228SetYFilter(struct SiS_Private *SiS_Pr, unsigned short ModeNo,unsigned short ModeIdIndex)
11221 USHORT ModeNo,USHORT ModeIdIndex)
11222{ 10229{
11223 USHORT index, temp, i, j; 10230 unsigned short index, temp, i, j;
11224 10231
11225 if(ModeNo <= 0x13) { 10232 if(ModeNo <= 0x13) {
11226 index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].VB_StTVYFilterIndex; 10233 index = SiS_Pr->SiS_SModeIDTable[ModeIdIndex].VB_StTVYFilterIndex;
@@ -11235,7 +10242,7 @@ SetYFilter(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
11235 else if(SiS_Pr->SiS_TVMode & TVSetPALN) temp = 4; /* PAL-N */ 10242 else if(SiS_Pr->SiS_TVMode & TVSetPALN) temp = 4; /* PAL-N */
11236 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) temp = 1; /* HiVision uses PAL */ 10243 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) temp = 1; /* HiVision uses PAL */
11237 10244
11238 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { 10245 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) {
11239 for(i=0x35, j=0; i<=0x38; i++, j++) { 10246 for(i=0x35, j=0; i<=0x38; i++, j++) {
11240 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS310_TVYFilter2[temp][index][j]); 10247 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS310_TVYFilter2[temp][index][j]);
11241 } 10248 }
@@ -11250,23 +10257,22 @@ SetYFilter(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
11250} 10257}
11251 10258
11252static void 10259static void
11253SetPhaseIncr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, 10260SetPhaseIncr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex)
11254 USHORT ModeNo,USHORT ModeIdIndex)
11255{ 10261{
11256 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; 10262 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
11257 USHORT index,temp,i,j,resinfo,romptr=0; 10263 unsigned short index,temp,i,j,resinfo,romptr=0;
11258 ULONG lindex; 10264 unsigned int lindex;
11259 10265
11260 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) return; 10266 if(!(SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) return;
11261 10267
11262 /* NTSC-J data not in BIOS, and already set in SetGroup2 */ 10268 /* NTSC-J data not in BIOS, and already set in SetGroup2 */
11263 if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) return; 10269 if(SiS_Pr->SiS_TVMode & TVSetNTSCJ) return;
11264 10270
11265 if((HwInfo->jChipType >= SIS_661) || SiS_Pr->SiS_ROMNew) { 10271 if((SiS_Pr->ChipType >= SIS_661) || SiS_Pr->SiS_ROMNew) {
11266 lindex = GetOEMTVPtr661_2_OLD(SiS_Pr) & 0xffff; 10272 lindex = GetOEMTVPtr661_2_OLD(SiS_Pr) & 0xffff;
11267 lindex <<= 2; 10273 lindex <<= 2;
11268 for(j=0, i=0x31; i<=0x34; i++, j++) { 10274 for(j=0, i=0x31; i<=0x34; i++, j++) {
11269 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS661_TVPhase[lindex + j]); 10275 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS_TVPhase[lindex + j]);
11270 } 10276 }
11271 return; 10277 return;
11272 } 10278 }
@@ -11286,17 +10292,17 @@ SetPhaseIncr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
11286 */ 10292 */
11287 if(SiS_Pr->SiS_UseROM) { 10293 if(SiS_Pr->SiS_UseROM) {
11288 romptr = SISGETROMW(0x116); 10294 romptr = SISGETROMW(0x116);
11289 if(HwInfo->jChipType >= SIS_330) { 10295 if(SiS_Pr->ChipType >= SIS_330) {
11290 romptr = SISGETROMW(0x196); 10296 romptr = SISGETROMW(0x196);
11291 } 10297 }
11292 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { 10298 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) {
11293 romptr = SISGETROMW(0x11c); 10299 romptr = SISGETROMW(0x11c);
11294 if(HwInfo->jChipType >= SIS_330) { 10300 if(SiS_Pr->ChipType >= SIS_330) {
11295 romptr = SISGETROMW(0x19c); 10301 romptr = SISGETROMW(0x19c);
11296 } 10302 }
11297 if((SiS_Pr->SiS_VBInfo & SetInSlaveMode) && (!(SiS_Pr->SiS_TVMode & TVSetTVSimuMode))) { 10303 if((SiS_Pr->SiS_VBInfo & SetInSlaveMode) && (!(SiS_Pr->SiS_TVMode & TVSetTVSimuMode))) {
11298 romptr = SISGETROMW(0x116); 10304 romptr = SISGETROMW(0x116);
11299 if(HwInfo->jChipType >= SIS_330) { 10305 if(SiS_Pr->ChipType >= SIS_330) {
11300 romptr = SISGETROMW(0x196); 10306 romptr = SISGETROMW(0x196);
11301 } 10307 }
11302 } 10308 }
@@ -11311,7 +10317,7 @@ SetPhaseIncr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
11311 index = temp % 2; 10317 index = temp % 2;
11312 temp >>= 1; /* 0:NTSC, 1:PAL, 2:HiTV */ 10318 temp >>= 1; /* 0:NTSC, 1:PAL, 2:HiTV */
11313 for(j=0, i=0x31; i<=0x34; i++, j++) { 10319 for(j=0, i=0x31; i<=0x34; i++, j++) {
11314 if(!(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV)) 10320 if(!(SiS_Pr->SiS_VBType & VB_SIS30xBLV))
11315 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS310_TVPhaseIncr1[temp][index][j]); 10321 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS310_TVPhaseIncr1[temp][index][j]);
11316 else if((!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || (SiS_Pr->SiS_TVMode & TVSetTVSimuMode)) 10322 else if((!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) || (SiS_Pr->SiS_TVMode & TVSetTVSimuMode))
11317 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS310_TVPhaseIncr2[temp][index][j]); 10323 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS310_TVPhaseIncr2[temp][index][j]);
@@ -11320,7 +10326,7 @@ SetPhaseIncr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
11320 } 10326 }
11321 } 10327 }
11322 10328
11323 if((SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) && (!(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision))) { 10329 if((SiS_Pr->SiS_VBType & VB_SIS30xBLV) && (!(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision))) {
11324 if((!(SiS_Pr->SiS_TVMode & (TVSetPAL | TVSetYPbPr525p | TVSetYPbPr750p))) && (ModeNo > 0x13)) { 10330 if((!(SiS_Pr->SiS_TVMode & (TVSetPAL | TVSetYPbPr525p | TVSetYPbPr750p))) && (ModeNo > 0x13)) {
11325 if((resinfo == SIS_RI_640x480) || 10331 if((resinfo == SIS_RI_640x480) ||
11326 (resinfo == SIS_RI_800x600)) { 10332 (resinfo == SIS_RI_800x600)) {
@@ -11339,11 +10345,11 @@ SetPhaseIncr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
11339} 10345}
11340 10346
11341static void 10347static void
11342SetDelayComp661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo, 10348SetDelayComp661(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
11343 USHORT ModeIdIndex, USHORT RTI) 10349 unsigned short ModeIdIndex, unsigned short RTI)
11344{ 10350{
11345 USHORT delay = 0, romptr = 0, index, lcdpdcindex; 10351 unsigned short delay = 0, romptr = 0, index, lcdpdcindex;
11346 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; 10352 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
11347 10353
11348 if(!(SiS_Pr->SiS_VBInfo & (SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA | SetCRT2ToRAMDAC))) 10354 if(!(SiS_Pr->SiS_VBInfo & (SetCRT2ToTV | SetCRT2ToLCD | SetCRT2ToLCDA | SetCRT2ToRAMDAC)))
11349 return; 10355 return;
@@ -11359,7 +10365,7 @@ SetDelayComp661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo,
11359 if(SiS_Pr->UseCustomMode) { 10365 if(SiS_Pr->UseCustomMode) {
11360 index = SiS_Pr->CSRClock; 10366 index = SiS_Pr->CSRClock;
11361 } else if(ModeNo > 0x13) { 10367 } else if(ModeNo > 0x13) {
11362 index = SiS_GetVCLK2Ptr(SiS_Pr,ModeNo,ModeIdIndex,RTI,HwInfo); 10368 index = SiS_GetVCLK2Ptr(SiS_Pr,ModeNo,ModeIdIndex,RTI);
11363 index = SiS_Pr->SiS_VCLKData[index].CLOCK; 10369 index = SiS_Pr->SiS_VCLKData[index].CLOCK;
11364 } 10370 }
11365 if(index < 25) index = 25; 10371 if(index < 25) index = 25;
@@ -11387,7 +10393,36 @@ SetDelayComp661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo,
11387 else delay = (SiS_Pr->SiS_RefIndex[RTI].Ext_PDC >> 4); 10393 else delay = (SiS_Pr->SiS_RefIndex[RTI].Ext_PDC >> 4);
11388 delay |= (delay << 8); 10394 delay |= (delay << 8);
11389 10395
11390 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 10396 if(SiS_Pr->ChipType >= XGI_20) {
10397
10398 delay = 0x0606;
10399 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
10400
10401 delay = 0x0404;
10402 if(SiS_Pr->SiS_XGIROM) {
10403 index = GetTVPtrIndex(SiS_Pr);
10404 if((romptr = SISGETROMW(0x35e))) {
10405 delay = (ROMAddr[romptr + index] & 0x0f) << 1;
10406 delay |= (delay << 8);
10407 }
10408 }
10409
10410 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) {
10411 if(SiS_Pr->ChipType == XGI_40 && SiS_Pr->ChipRevision == 0x02) {
10412 delay -= 0x0404;
10413 }
10414 }
10415 }
10416
10417 } else if(SiS_Pr->ChipType >= SIS_340) {
10418
10419 delay = 0x0606;
10420 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
10421 delay = 0x0404;
10422 }
10423 /* TODO (eventually) */
10424
10425 } else if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
11391 10426
11392 /* 3. TV */ 10427 /* 3. TV */
11393 10428
@@ -11406,7 +10441,7 @@ SetDelayComp661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo,
11406 /* 4. LCD, LCDA (for new ROM only LV and non-Pass 1:1) */ 10441 /* 4. LCD, LCDA (for new ROM only LV and non-Pass 1:1) */
11407 10442
11408 if( (SiS_Pr->SiS_LCDResInfo != Panel_Custom) && 10443 if( (SiS_Pr->SiS_LCDResInfo != Panel_Custom) &&
11409 ((romptr = GetLCDStructPtr661_2(SiS_Pr, HwInfo))) ) { 10444 ((romptr = GetLCDStructPtr661_2(SiS_Pr))) ) {
11410 10445
11411 lcdpdcindex = (SiS_Pr->SiS_VBType & VB_UMC) ? 14 : 12; 10446 lcdpdcindex = (SiS_Pr->SiS_VBType & VB_UMC) ? 14 : 12;
11412 10447
@@ -11426,6 +10461,7 @@ SetDelayComp661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo,
11426 case Panel_1280x768_2:delay = 0x0004; break; 10461 case Panel_1280x768_2:delay = 0x0004; break;
11427 case Panel_1280x800: 10462 case Panel_1280x800:
11428 case Panel_1280x800_2:delay = 0x0004; break; /* Verified for 1280x800 */ 10463 case Panel_1280x800_2:delay = 0x0004; break; /* Verified for 1280x800 */
10464 case Panel_1280x854: delay = 0x0004; break; /* FIXME */
11429 case Panel_1280x1024: delay = 0x1e04; break; 10465 case Panel_1280x1024: delay = 0x1e04; break;
11430 case Panel_1400x1050: delay = 0x0004; break; 10466 case Panel_1400x1050: delay = 0x0004; break;
11431 case Panel_1600x1200: delay = 0x0400; break; 10467 case Panel_1600x1200: delay = 0x0400; break;
@@ -11469,10 +10505,10 @@ SetDelayComp661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo,
11469} 10505}
11470 10506
11471static void 10507static void
11472SetCRT2SyncDither661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo, USHORT RTI) 10508SetCRT2SyncDither661(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short RTI)
11473{ 10509{
11474 USHORT infoflag; 10510 unsigned short infoflag;
11475 UCHAR temp; 10511 unsigned char temp;
11476 10512
11477 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { 10513 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
11478 10514
@@ -11513,12 +10549,16 @@ SetCRT2SyncDither661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo, US
11513} 10549}
11514 10550
11515static void 10551static void
11516SetPanelParms661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 10552SetPanelParms661(struct SiS_Private *SiS_Pr)
11517{ 10553{
11518 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; 10554 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
11519 USHORT romptr, temp1, temp2; 10555 unsigned short romptr, temp1, temp2;
10556
10557 if(SiS_Pr->SiS_VBType & (VB_SISLVDS | VB_SIS30xC)) {
10558 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x24,0x0f);
10559 }
11520 10560
11521 if(SiS_Pr->SiS_VBType & (VB_SIS301LV | VB_SIS302LV | VB_SIS302ELV)) { 10561 if(SiS_Pr->SiS_VBType & VB_SISLVDS) {
11522 if(SiS_Pr->LVDSHL != -1) { 10562 if(SiS_Pr->LVDSHL != -1) {
11523 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x24,0xfc,SiS_Pr->LVDSHL); 10563 SiS_SetRegANDOR(SiS_Pr->SiS_Part4Port,0x24,0xfc,SiS_Pr->LVDSHL);
11524 } 10564 }
@@ -11526,8 +10566,8 @@ SetPanelParms661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
11526 10566
11527 if(SiS_Pr->SiS_ROMNew) { 10567 if(SiS_Pr->SiS_ROMNew) {
11528 10568
11529 if((romptr = GetLCDStructPtr661_2(SiS_Pr, HwInfo))) { 10569 if((romptr = GetLCDStructPtr661_2(SiS_Pr))) {
11530 if(SiS_Pr->SiS_VBType & (VB_SIS301LV | VB_SIS302LV | VB_SIS302ELV)) { 10570 if(SiS_Pr->SiS_VBType & VB_SISLVDS) {
11531 temp1 = (ROMAddr[romptr] & 0x03) | 0x0c; 10571 temp1 = (ROMAddr[romptr] & 0x03) | 0x0c;
11532 temp2 = 0xfc; 10572 temp2 = 0xfc;
11533 if(SiS_Pr->LVDSHL != -1) { 10573 if(SiS_Pr->LVDSHL != -1) {
@@ -11546,48 +10586,47 @@ SetPanelParms661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
11546} 10586}
11547 10587
11548static void 10588static void
11549SiS_OEM310Setting(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, 10589SiS_OEM310Setting(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RRTI)
11550 USHORT ModeNo,USHORT ModeIdIndex,USHORT RRTI)
11551{ 10590{
11552 if((SiS_Pr->SiS_ROMNew) && (SiS_Pr->SiS_VBType & VB_SISLVDS)) { 10591 if((SiS_Pr->SiS_ROMNew) && (SiS_Pr->SiS_VBType & VB_SISLVDS)) {
11553 SetDelayComp661(SiS_Pr,HwInfo,ModeNo,ModeIdIndex,RRTI); 10592 SetDelayComp661(SiS_Pr, ModeNo, ModeIdIndex, RRTI);
11554 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { 10593 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
11555 SetCRT2SyncDither661(SiS_Pr,HwInfo,ModeNo,RRTI); 10594 SetCRT2SyncDither661(SiS_Pr, ModeNo, RRTI);
11556 SetPanelParms661(SiS_Pr,HwInfo); 10595 SetPanelParms661(SiS_Pr);
11557 } 10596 }
11558 } else { 10597 } else {
11559 SetDelayComp(SiS_Pr,HwInfo,ModeNo); 10598 SetDelayComp(SiS_Pr,ModeNo);
11560 } 10599 }
11561 10600
11562 if((SiS_Pr->SiS_VBType & VB_SISVB) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) { 10601 if((SiS_Pr->SiS_VBType & VB_SISVB) && (SiS_Pr->SiS_VBInfo & SetCRT2ToTV)) {
11563 SetAntiFlicker(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); 10602 SetAntiFlicker(SiS_Pr,ModeNo,ModeIdIndex);
11564 SetPhaseIncr(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); 10603 SetPhaseIncr(SiS_Pr,ModeNo,ModeIdIndex);
11565 SetYFilter(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); 10604 SetYFilter(SiS_Pr,ModeNo,ModeIdIndex);
11566 if(SiS_Pr->SiS_VBType & VB_SIS301) { 10605 if(SiS_Pr->SiS_VBType & VB_SIS301) {
11567 SetEdgeEnhance(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); 10606 SetEdgeEnhance(SiS_Pr,ModeNo,ModeIdIndex);
11568 } 10607 }
11569 } 10608 }
11570} 10609}
11571 10610
11572static void 10611static void
11573SiS_OEM661Setting(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, 10612SiS_OEM661Setting(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
11574 USHORT ModeNo,USHORT ModeIdIndex, USHORT RRTI) 10613 unsigned short ModeIdIndex, unsigned short RRTI)
11575{ 10614{
11576 if(SiS_Pr->SiS_VBType & VB_SISVB) { 10615 if(SiS_Pr->SiS_VBType & VB_SISVB) {
11577 10616
11578 SetDelayComp661(SiS_Pr,HwInfo,ModeNo,ModeIdIndex,RRTI); 10617 SetDelayComp661(SiS_Pr, ModeNo, ModeIdIndex, RRTI);
11579 10618
11580 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { 10619 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
11581 SetCRT2SyncDither661(SiS_Pr,HwInfo,ModeNo,RRTI); 10620 SetCRT2SyncDither661(SiS_Pr, ModeNo, RRTI);
11582 SetPanelParms661(SiS_Pr,HwInfo); 10621 SetPanelParms661(SiS_Pr);
11583 } 10622 }
11584 10623
11585 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 10624 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
11586 SetPhaseIncr(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); 10625 SetPhaseIncr(SiS_Pr, ModeNo, ModeIdIndex);
11587 SetYFilter(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); 10626 SetYFilter(SiS_Pr, ModeNo, ModeIdIndex);
11588 SetAntiFlicker(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); 10627 SetAntiFlicker(SiS_Pr, ModeNo, ModeIdIndex);
11589 if(SiS_Pr->SiS_VBType & VB_SIS301) { 10628 if(SiS_Pr->SiS_VBType & VB_SIS301) {
11590 SetEdgeEnhance(SiS_Pr,HwInfo,ModeNo,ModeIdIndex); 10629 SetEdgeEnhance(SiS_Pr, ModeNo, ModeIdIndex);
11591 } 10630 }
11592 } 10631 }
11593 } 10632 }
@@ -11601,13 +10640,12 @@ SiS_OEM661Setting(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
11601 * pray that we have a backup... 10640 * pray that we have a backup...
11602 */ 10641 */
11603static void 10642static void
11604SiS_FinalizeLCD(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, 10643SiS_FinalizeLCD(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex)
11605 PSIS_HW_INFO HwInfo)
11606{ 10644{
11607 USHORT tempcl,tempch,tempbl,tempbh,tempbx,tempax,temp; 10645 unsigned short tempcl,tempch,tempbl,tempbh,tempbx,tempax,temp;
11608 USHORT resinfo,modeflag; 10646 unsigned short resinfo,modeflag;
11609 10647
11610 if(!(SiS_Pr->SiS_VBType & VB_SIS301LV302LV)) return; 10648 if(!(SiS_Pr->SiS_VBType & VB_SISLVDS)) return;
11611 if(SiS_Pr->SiS_ROMNew) return; 10649 if(SiS_Pr->SiS_ROMNew) return;
11612 10650
11613 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { 10651 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
@@ -11678,7 +10716,7 @@ SiS_FinalizeLCD(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
11678 10716
11679 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { 10717 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
11680 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) { 10718 if(SiS_Pr->SiS_LCDResInfo == Panel_1024x768) {
11681 if(SiS_Pr->SiS_VBType & (VB_SIS302LV | VB_SIS302ELV)) { 10719 if(SiS_Pr->SiS_VBType & VB_SISEMI) {
11682 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2a,0x00); 10720 SiS_SetReg(SiS_Pr->SiS_Part4Port,0x2a,0x00);
11683#ifdef SET_EMI 10721#ifdef SET_EMI
11684 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c); 10722 SiS_SetRegAND(SiS_Pr->SiS_Part4Port,0x30,0x0c);
@@ -11806,11 +10844,11 @@ SiS_FinalizeLCD(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
11806#ifdef SIS300 10844#ifdef SIS300
11807 10845
11808static void 10846static void
11809SetOEMLCDData2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, 10847SetOEMLCDData2(struct SiS_Private *SiS_Pr, unsigned short ModeNo,unsigned short ModeIdIndex,
11810 USHORT ModeNo,USHORT ModeIdIndex, USHORT RefTabIndex) 10848 unsigned short RefTabIndex)
11811{ 10849{
11812 USHORT crt2crtc=0, modeflag, myindex=0; 10850 unsigned short crt2crtc=0, modeflag, myindex=0;
11813 UCHAR temp; 10851 unsigned char temp;
11814 int i; 10852 int i;
11815 10853
11816 if(ModeNo <= 0x13) { 10854 if(ModeNo <= 0x13) {
@@ -11849,21 +10887,21 @@ SetOEMLCDData2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
11849 } 10887 }
11850} 10888}
11851 10889
11852static USHORT 10890static unsigned short
11853GetOEMLCDPtr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, int Flag) 10891GetOEMLCDPtr(struct SiS_Private *SiS_Pr, int Flag)
11854{ 10892{
11855 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; 10893 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
11856 USHORT tempbx=0,romptr=0; 10894 unsigned short tempbx=0,romptr=0;
11857 UCHAR customtable300[] = { 10895 static const unsigned char customtable300[] = {
11858 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 10896 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
11859 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff 10897 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
11860 }; 10898 };
11861 UCHAR customtable630[] = { 10899 static const unsigned char customtable630[] = {
11862 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 10900 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
11863 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff 10901 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
11864 }; 10902 };
11865 10903
11866 if(HwInfo->jChipType == SIS_300) { 10904 if(SiS_Pr->ChipType == SIS_300) {
11867 10905
11868 tempbx = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) & 0x0f; 10906 tempbx = SiS_GetReg(SiS_Pr->SiS_P3d4,0x36) & 0x0f;
11869 if(SiS_Pr->SiS_VBType & VB_SIS301) tempbx &= 0x07; 10907 if(SiS_Pr->SiS_VBType & VB_SIS301) tempbx &= 0x07;
@@ -11912,11 +10950,10 @@ GetOEMLCDPtr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, int Flag)
11912} 10950}
11913 10951
11914static void 10952static void
11915SetOEMLCDDelay(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, 10953SetOEMLCDDelay(struct SiS_Private *SiS_Pr, unsigned short ModeNo,unsigned short ModeIdIndex)
11916 USHORT ModeNo,USHORT ModeIdIndex)
11917{ 10954{
11918 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; 10955 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
11919 USHORT index,temp,romptr=0; 10956 unsigned short index,temp,romptr=0;
11920 10957
11921 if(SiS_Pr->SiS_LCDResInfo == Panel_Custom) return; 10958 if(SiS_Pr->SiS_LCDResInfo == Panel_Custom) return;
11922 10959
@@ -11927,22 +10964,22 @@ SetOEMLCDDelay(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
11927 } 10964 }
11928 10965
11929 /* The Panel Compensation Delay should be set according to tables 10966 /* The Panel Compensation Delay should be set according to tables
11930 * here. Unfortunately, various BIOS versions don't case about 10967 * here. Unfortunately, various BIOS versions don't care about
11931 * a uniform way using eg. ROM byte 0x220, but use different 10968 * a uniform way using eg. ROM byte 0x220, but use different
11932 * hard coded delays (0x04, 0x20, 0x18) in SetGroup1(). 10969 * hard coded delays (0x04, 0x20, 0x18) in SetGroup1().
11933 * Thus we don't set this if the user select a custom pdc or if 10970 * Thus we don't set this if the user selected a custom pdc or if
11934 * we otherwise detected a valid pdc. 10971 * we otherwise detected a valid pdc.
11935 */ 10972 */
11936 if(SiS_Pr->PDC != -1) return; 10973 if(SiS_Pr->PDC != -1) return;
11937 10974
11938 temp = GetOEMLCDPtr(SiS_Pr,HwInfo, 0); 10975 temp = GetOEMLCDPtr(SiS_Pr, 0);
11939 10976
11940 if(SiS_Pr->UseCustomMode) 10977 if(SiS_Pr->UseCustomMode)
11941 index = 0; 10978 index = 0;
11942 else 10979 else
11943 index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].VB_LCDDelayIndex; 10980 index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].VB_LCDDelayIndex;
11944 10981
11945 if(HwInfo->jChipType != SIS_300) { 10982 if(SiS_Pr->ChipType != SIS_300) {
11946 if(romptr) { 10983 if(romptr) {
11947 romptr += (temp * 2); 10984 romptr += (temp * 2);
11948 romptr = SISGETROMW(romptr); 10985 romptr = SISGETROMW(romptr);
@@ -11986,12 +11023,11 @@ SetOEMLCDDelay(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
11986} 11023}
11987 11024
11988static void 11025static void
11989SetOEMLCDData(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, 11026SetOEMLCDData(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex)
11990 USHORT ModeNo,USHORT ModeIdIndex)
11991{ 11027{
11992#if 0 /* Unfinished; Data table missing */ 11028#if 0 /* Unfinished; Data table missing */
11993 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; 11029 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
11994 USHORT index,temp; 11030 unsigned short index,temp;
11995 11031
11996 if((SiS_Pr->SiS_UseROM) { 11032 if((SiS_Pr->SiS_UseROM) {
11997 if(!(ROMAddr[0x237] & 0x01)) return; 11033 if(!(ROMAddr[0x237] & 0x01)) return;
@@ -11999,8 +11035,8 @@ SetOEMLCDData(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
11999 /* No rom pointer in BIOS header! */ 11035 /* No rom pointer in BIOS header! */
12000 } 11036 }
12001 11037
12002 temp = GetOEMLCDPtr(SiS_Pr,HwInfo, 1); 11038 temp = GetOEMLCDPtr(SiS_Pr, 1);
12003 if(temp = 0xFFFF) return; 11039 if(temp == 0xFFFF) return;
12004 11040
12005 index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex]._VB_LCDHIndex; 11041 index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex]._VB_LCDHIndex;
12006 for(i=0x14, j=0; i<=0x17; i++, j++) { 11042 for(i=0x14, j=0; i<=0x17; i++, j++) {
@@ -12018,10 +11054,10 @@ SetOEMLCDData(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
12018#endif 11054#endif
12019} 11055}
12020 11056
12021static USHORT 11057static unsigned short
12022GetOEMTVPtr(SiS_Private *SiS_Pr) 11058GetOEMTVPtr(struct SiS_Private *SiS_Pr)
12023{ 11059{
12024 USHORT index; 11060 unsigned short index;
12025 11061
12026 index = 0; 11062 index = 0;
12027 if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) index += 4; 11063 if(!(SiS_Pr->SiS_VBInfo & SetInSlaveMode)) index += 4;
@@ -12037,11 +11073,10 @@ GetOEMTVPtr(SiS_Private *SiS_Pr)
12037} 11073}
12038 11074
12039static void 11075static void
12040SetOEMTVDelay(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, 11076SetOEMTVDelay(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex)
12041 USHORT ModeNo,USHORT ModeIdIndex)
12042{ 11077{
12043 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; 11078 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
12044 USHORT index,temp,romptr=0; 11079 unsigned short index,temp,romptr=0;
12045 11080
12046 if(SiS_Pr->SiS_UseROM) { 11081 if(SiS_Pr->SiS_UseROM) {
12047 if(!(ROMAddr[0x238] & 0x01)) return; 11082 if(!(ROMAddr[0x238] & 0x01)) return;
@@ -12070,11 +11105,10 @@ SetOEMTVDelay(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
12070} 11105}
12071 11106
12072static void 11107static void
12073SetOEMAntiFlicker(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, 11108SetOEMAntiFlicker(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex)
12074 USHORT ModeNo, USHORT ModeIdIndex)
12075{ 11109{
12076 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; 11110 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
12077 USHORT index,temp,romptr=0; 11111 unsigned short index,temp,romptr=0;
12078 11112
12079 if(SiS_Pr->SiS_UseROM) { 11113 if(SiS_Pr->SiS_UseROM) {
12080 if(!(ROMAddr[0x238] & 0x01)) return; 11114 if(!(ROMAddr[0x238] & 0x01)) return;
@@ -12099,11 +11133,10 @@ SetOEMAntiFlicker(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
12099} 11133}
12100 11134
12101static void 11135static void
12102SetOEMPhaseIncr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, 11136SetOEMPhaseIncr(struct SiS_Private *SiS_Pr, unsigned short ModeNo,unsigned short ModeIdIndex)
12103 USHORT ModeNo,USHORT ModeIdIndex)
12104{ 11137{
12105 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; 11138 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
12106 USHORT index,i,j,temp,romptr=0; 11139 unsigned short index,i,j,temp,romptr=0;
12107 11140
12108 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) return; 11141 if(SiS_Pr->SiS_VBInfo & SetCRT2ToHiVision) return;
12109 11142
@@ -12119,7 +11152,7 @@ SetOEMPhaseIncr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
12119 11152
12120 index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].VB_TVPhaseIndex; 11153 index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].VB_TVPhaseIndex;
12121 11154
12122 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { 11155 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) {
12123 for(i=0x31, j=0; i<=0x34; i++, j++) { 11156 for(i=0x31, j=0; i<=0x34; i++, j++) {
12124 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS300_Phase2[temp][index][j]); 11157 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS300_Phase2[temp][index][j]);
12125 } 11158 }
@@ -12140,11 +11173,10 @@ SetOEMPhaseIncr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
12140} 11173}
12141 11174
12142static void 11175static void
12143SetOEMYFilter(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, 11176SetOEMYFilter(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex)
12144 USHORT ModeNo,USHORT ModeIdIndex)
12145{ 11177{
12146 UCHAR *ROMAddr = HwInfo->pjVirtualRomBase; 11178 unsigned char *ROMAddr = SiS_Pr->VirtualRomBase;
12147 USHORT index,temp,i,j,romptr=0; 11179 unsigned short index,temp,i,j,romptr=0;
12148 11180
12149 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToSCART | SetCRT2ToHiVision | SetCRT2ToYPbPr525750)) return; 11181 if(SiS_Pr->SiS_VBInfo & (SetCRT2ToSCART | SetCRT2ToHiVision | SetCRT2ToYPbPr525750)) return;
12150 11182
@@ -12162,7 +11194,7 @@ SetOEMYFilter(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
12162 11194
12163 index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].VB_TVYFilterIndex; 11195 index = SiS_Pr->SiS_VBModeIDTable[ModeIdIndex].VB_TVYFilterIndex;
12164 11196
12165 if(SiS_Pr->SiS_VBType & VB_SIS301BLV302BLV) { 11197 if(SiS_Pr->SiS_VBType & VB_SIS30xBLV) {
12166 for(i=0x35, j=0; i<=0x38; i++, j++) { 11198 for(i=0x35, j=0; i<=0x38; i++, j++) {
12167 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS300_Filter2[temp][index][j]); 11199 SiS_SetReg(SiS_Pr->SiS_Part2Port,i,SiS300_Filter2[temp][index][j]);
12168 } 11200 }
@@ -12185,11 +11217,11 @@ SetOEMYFilter(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
12185 } 11217 }
12186} 11218}
12187 11219
12188static USHORT 11220static unsigned short
12189SiS_SearchVBModeID(SiS_Private *SiS_Pr, USHORT *ModeNo) 11221SiS_SearchVBModeID(struct SiS_Private *SiS_Pr, unsigned short *ModeNo)
12190{ 11222{
12191 USHORT ModeIdIndex; 11223 unsigned short ModeIdIndex;
12192 UCHAR VGAINFO = SiS_Pr->SiS_VGAINFO; 11224 unsigned char VGAINFO = SiS_Pr->SiS_VGAINFO;
12193 11225
12194 if(*ModeNo <= 5) *ModeNo |= 1; 11226 if(*ModeNo <= 5) *ModeNo |= 1;
12195 11227
@@ -12210,10 +11242,10 @@ SiS_SearchVBModeID(SiS_Private *SiS_Pr, USHORT *ModeNo)
12210} 11242}
12211 11243
12212static void 11244static void
12213SiS_OEM300Setting(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, 11245SiS_OEM300Setting(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex,
12214 USHORT ModeNo, USHORT ModeIdIndex, USHORT RefTableIndex) 11246 unsigned short RefTableIndex)
12215{ 11247{
12216 USHORT OEMModeIdIndex=0; 11248 unsigned short OEMModeIdIndex = 0;
12217 11249
12218 if(!SiS_Pr->UseCustomMode) { 11250 if(!SiS_Pr->UseCustomMode) {
12219 OEMModeIdIndex = SiS_SearchVBModeID(SiS_Pr,&ModeNo); 11251 OEMModeIdIndex = SiS_SearchVBModeID(SiS_Pr,&ModeNo);
@@ -12221,18 +11253,18 @@ SiS_OEM300Setting(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo,
12221 } 11253 }
12222 11254
12223 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) { 11255 if(SiS_Pr->SiS_VBInfo & SetCRT2ToLCD) {
12224 SetOEMLCDDelay(SiS_Pr, HwInfo, ModeNo, OEMModeIdIndex); 11256 SetOEMLCDDelay(SiS_Pr, ModeNo, OEMModeIdIndex);
12225 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) { 11257 if(SiS_Pr->SiS_IF_DEF_LVDS == 1) {
12226 SetOEMLCDData(SiS_Pr, HwInfo, ModeNo, OEMModeIdIndex); 11258 SetOEMLCDData(SiS_Pr, ModeNo, OEMModeIdIndex);
12227 } 11259 }
12228 } 11260 }
12229 if(SiS_Pr->UseCustomMode) return; 11261 if(SiS_Pr->UseCustomMode) return;
12230 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) { 11262 if(SiS_Pr->SiS_VBInfo & SetCRT2ToTV) {
12231 SetOEMTVDelay(SiS_Pr, HwInfo, ModeNo,OEMModeIdIndex); 11263 SetOEMTVDelay(SiS_Pr, ModeNo,OEMModeIdIndex);
12232 if(SiS_Pr->SiS_VBType & VB_SISVB) { 11264 if(SiS_Pr->SiS_VBType & VB_SISVB) {
12233 SetOEMAntiFlicker(SiS_Pr, HwInfo, ModeNo, OEMModeIdIndex); 11265 SetOEMAntiFlicker(SiS_Pr, ModeNo, OEMModeIdIndex);
12234 SetOEMPhaseIncr(SiS_Pr, HwInfo, ModeNo, OEMModeIdIndex); 11266 SetOEMPhaseIncr(SiS_Pr, ModeNo, OEMModeIdIndex);
12235 SetOEMYFilter(SiS_Pr, HwInfo, ModeNo, OEMModeIdIndex); 11267 SetOEMYFilter(SiS_Pr, ModeNo, OEMModeIdIndex);
12236 } 11268 }
12237 } 11269 }
12238} 11270}