aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/misc
diff options
context:
space:
mode:
authorFelipe Balbi <felipe.lima@indt.org.br>2007-08-10 09:34:31 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2007-10-12 17:55:11 -0400
commit22b2c526e70741ce8a244cab339fe0f56ace8cb6 (patch)
treeaf3e69a804266e5e5b3ca50d9ae94f1ae5bf56f5 /drivers/usb/misc
parent1c1772a2609a16b3b590f8390a337dbe25859118 (diff)
USB: SisUSB2VGA: Lindent drivers/usb/misc/sisusbvga/sisusb_init.c
Better indentation Signed-off-by: Felipe Balbi <felipe.lima@indt.org.br> Cc: Thomas Winischhofer <thomas@winischhofer.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/misc')
-rw-r--r--drivers/usb/misc/sisusbvga/sisusb_init.c262
1 files changed, 133 insertions, 129 deletions
diff --git a/drivers/usb/misc/sisusbvga/sisusb_init.c b/drivers/usb/misc/sisusbvga/sisusb_init.c
index 5d8358295e71..273de5d0934e 100644
--- a/drivers/usb/misc/sisusbvga/sisusb_init.c
+++ b/drivers/usb/misc/sisusbvga/sisusb_init.c
@@ -55,18 +55,17 @@
55/* POINTER INITIALIZATION */ 55/* POINTER INITIALIZATION */
56/*********************************************/ 56/*********************************************/
57 57
58static void 58static void SiSUSB_InitPtr(struct SiS_Private *SiS_Pr)
59SiSUSB_InitPtr(struct SiS_Private *SiS_Pr)
60{ 59{
61 SiS_Pr->SiS_ModeResInfo = SiSUSB_ModeResInfo; 60 SiS_Pr->SiS_ModeResInfo = SiSUSB_ModeResInfo;
62 SiS_Pr->SiS_StandTable = SiSUSB_StandTable; 61 SiS_Pr->SiS_StandTable = SiSUSB_StandTable;
63 62
64 SiS_Pr->SiS_SModeIDTable = SiSUSB_SModeIDTable; 63 SiS_Pr->SiS_SModeIDTable = SiSUSB_SModeIDTable;
65 SiS_Pr->SiS_EModeIDTable = SiSUSB_EModeIDTable; 64 SiS_Pr->SiS_EModeIDTable = SiSUSB_EModeIDTable;
66 SiS_Pr->SiS_RefIndex = SiSUSB_RefIndex; 65 SiS_Pr->SiS_RefIndex = SiSUSB_RefIndex;
67 SiS_Pr->SiS_CRT1Table = SiSUSB_CRT1Table; 66 SiS_Pr->SiS_CRT1Table = SiSUSB_CRT1Table;
68 67
69 SiS_Pr->SiS_VCLKData = SiSUSB_VCLKData; 68 SiS_Pr->SiS_VCLKData = SiSUSB_VCLKData;
70} 69}
71 70
72/*********************************************/ 71/*********************************************/
@@ -75,21 +74,20 @@ SiSUSB_InitPtr(struct SiS_Private *SiS_Pr)
75 74
76static void 75static void
77SiS_SetReg(struct SiS_Private *SiS_Pr, unsigned long port, 76SiS_SetReg(struct SiS_Private *SiS_Pr, unsigned long port,
78 unsigned short index, unsigned short data) 77 unsigned short index, unsigned short data)
79{ 78{
80 sisusb_setidxreg(SiS_Pr->sisusb, port, index, data); 79 sisusb_setidxreg(SiS_Pr->sisusb, port, index, data);
81} 80}
82 81
83static void 82static void
84SiS_SetRegByte(struct SiS_Private *SiS_Pr, unsigned long port, 83SiS_SetRegByte(struct SiS_Private *SiS_Pr, unsigned long port,
85 unsigned short data) 84 unsigned short data)
86{ 85{
87 sisusb_setreg(SiS_Pr->sisusb, port, data); 86 sisusb_setreg(SiS_Pr->sisusb, port, data);
88} 87}
89 88
90static unsigned char 89static unsigned char
91SiS_GetReg(struct SiS_Private *SiS_Pr, unsigned long port, 90SiS_GetReg(struct SiS_Private *SiS_Pr, unsigned long port, unsigned short index)
92 unsigned short index)
93{ 91{
94 u8 data; 92 u8 data;
95 93
@@ -110,22 +108,22 @@ SiS_GetRegByte(struct SiS_Private *SiS_Pr, unsigned long port)
110 108
111static void 109static void
112SiS_SetRegANDOR(struct SiS_Private *SiS_Pr, unsigned long port, 110SiS_SetRegANDOR(struct SiS_Private *SiS_Pr, unsigned long port,
113 unsigned short index, unsigned short DataAND, 111 unsigned short index, unsigned short DataAND,
114 unsigned short DataOR) 112 unsigned short DataOR)
115{ 113{
116 sisusb_setidxregandor(SiS_Pr->sisusb, port, index, DataAND, DataOR); 114 sisusb_setidxregandor(SiS_Pr->sisusb, port, index, DataAND, DataOR);
117} 115}
118 116
119static void 117static void
120SiS_SetRegAND(struct SiS_Private *SiS_Pr, unsigned long port, 118SiS_SetRegAND(struct SiS_Private *SiS_Pr, unsigned long port,
121 unsigned short index, unsigned short DataAND) 119 unsigned short index, unsigned short DataAND)
122{ 120{
123 sisusb_setidxregand(SiS_Pr->sisusb, port, index, DataAND); 121 sisusb_setidxregand(SiS_Pr->sisusb, port, index, DataAND);
124} 122}
125 123
126static void 124static void
127SiS_SetRegOR(struct SiS_Private *SiS_Pr,unsigned long port, 125SiS_SetRegOR(struct SiS_Private *SiS_Pr, unsigned long port,
128 unsigned short index, unsigned short DataOR) 126 unsigned short index, unsigned short DataOR)
129{ 127{
130 sisusb_setidxregor(SiS_Pr->sisusb, port, index, DataOR); 128 sisusb_setidxregor(SiS_Pr->sisusb, port, index, DataOR);
131} 129}
@@ -134,8 +132,7 @@ SiS_SetRegOR(struct SiS_Private *SiS_Pr,unsigned long port,
134/* HELPER: DisplayOn, DisplayOff */ 132/* HELPER: DisplayOn, DisplayOff */
135/*********************************************/ 133/*********************************************/
136 134
137static void 135static void SiS_DisplayOn(struct SiS_Private *SiS_Pr)
138SiS_DisplayOn(struct SiS_Private *SiS_Pr)
139{ 136{
140 SiS_SetRegAND(SiS_Pr, SiS_Pr->SiS_P3c4, 0x01, 0xDF); 137 SiS_SetRegAND(SiS_Pr, SiS_Pr->SiS_P3c4, 0x01, 0xDF);
141} 138}
@@ -144,8 +141,7 @@ SiS_DisplayOn(struct SiS_Private *SiS_Pr)
144/* HELPER: Init Port Addresses */ 141/* HELPER: Init Port Addresses */
145/*********************************************/ 142/*********************************************/
146 143
147static void 144static void SiSUSBRegInit(struct SiS_Private *SiS_Pr, unsigned long BaseAddr)
148SiSUSBRegInit(struct SiS_Private *SiS_Pr, unsigned long BaseAddr)
149{ 145{
150 SiS_Pr->SiS_P3c4 = BaseAddr + 0x14; 146 SiS_Pr->SiS_P3c4 = BaseAddr + 0x14;
151 SiS_Pr->SiS_P3d4 = BaseAddr + 0x24; 147 SiS_Pr->SiS_P3d4 = BaseAddr + 0x24;
@@ -168,8 +164,7 @@ SiSUSBRegInit(struct SiS_Private *SiS_Pr, unsigned long BaseAddr)
168/* HELPER: GetSysFlags */ 164/* HELPER: GetSysFlags */
169/*********************************************/ 165/*********************************************/
170 166
171static void 167static void SiS_GetSysFlags(struct SiS_Private *SiS_Pr)
172SiS_GetSysFlags(struct SiS_Private *SiS_Pr)
173{ 168{
174 SiS_Pr->SiS_MyCR63 = 0x63; 169 SiS_Pr->SiS_MyCR63 = 0x63;
175} 170}
@@ -178,8 +173,7 @@ SiS_GetSysFlags(struct SiS_Private *SiS_Pr)
178/* HELPER: Init PCI & Engines */ 173/* HELPER: Init PCI & Engines */
179/*********************************************/ 174/*********************************************/
180 175
181static void 176static void SiSInitPCIetc(struct SiS_Private *SiS_Pr)
182SiSInitPCIetc(struct SiS_Private *SiS_Pr)
183{ 177{
184 SiS_SetReg(SiS_Pr, SiS_Pr->SiS_P3c4, 0x20, 0xa1); 178 SiS_SetReg(SiS_Pr, SiS_Pr->SiS_P3c4, 0x20, 0xa1);
185 /* - Enable 2D (0x40) 179 /* - Enable 2D (0x40)
@@ -195,8 +189,7 @@ SiSInitPCIetc(struct SiS_Private *SiS_Pr)
195/* HELPER: SET SEGMENT REGISTERS */ 189/* HELPER: SET SEGMENT REGISTERS */
196/*********************************************/ 190/*********************************************/
197 191
198static void 192static void SiS_SetSegRegLower(struct SiS_Private *SiS_Pr, unsigned short value)
199SiS_SetSegRegLower(struct SiS_Private *SiS_Pr, unsigned short value)
200{ 193{
201 unsigned short temp; 194 unsigned short temp;
202 195
@@ -209,8 +202,7 @@ SiS_SetSegRegLower(struct SiS_Private *SiS_Pr, unsigned short value)
209 SiS_SetRegByte(SiS_Pr, SiS_Pr->SiS_P3cd, temp); 202 SiS_SetRegByte(SiS_Pr, SiS_Pr->SiS_P3cd, temp);
210} 203}
211 204
212static void 205static void SiS_SetSegRegUpper(struct SiS_Private *SiS_Pr, unsigned short value)
213SiS_SetSegRegUpper(struct SiS_Private *SiS_Pr, unsigned short value)
214{ 206{
215 unsigned short temp; 207 unsigned short temp;
216 208
@@ -223,15 +215,13 @@ SiS_SetSegRegUpper(struct SiS_Private *SiS_Pr, unsigned short value)
223 SiS_SetRegByte(SiS_Pr, SiS_Pr->SiS_P3cd, temp); 215 SiS_SetRegByte(SiS_Pr, SiS_Pr->SiS_P3cd, temp);
224} 216}
225 217
226static void 218static void SiS_SetSegmentReg(struct SiS_Private *SiS_Pr, unsigned short value)
227SiS_SetSegmentReg(struct SiS_Private *SiS_Pr, unsigned short value)
228{ 219{
229 SiS_SetSegRegLower(SiS_Pr, value); 220 SiS_SetSegRegLower(SiS_Pr, value);
230 SiS_SetSegRegUpper(SiS_Pr, value); 221 SiS_SetSegRegUpper(SiS_Pr, value);
231} 222}
232 223
233static void 224static void SiS_ResetSegmentReg(struct SiS_Private *SiS_Pr)
234SiS_ResetSegmentReg(struct SiS_Private *SiS_Pr)
235{ 225{
236 SiS_SetSegmentReg(SiS_Pr, 0); 226 SiS_SetSegmentReg(SiS_Pr, 0);
237} 227}
@@ -247,14 +237,12 @@ SiS_SetSegmentRegOver(struct SiS_Private *SiS_Pr, unsigned short value)
247 SiS_SetSegmentReg(SiS_Pr, value); 237 SiS_SetSegmentReg(SiS_Pr, value);
248} 238}
249 239
250static void 240static void SiS_ResetSegmentRegOver(struct SiS_Private *SiS_Pr)
251SiS_ResetSegmentRegOver(struct SiS_Private *SiS_Pr)
252{ 241{
253 SiS_SetSegmentRegOver(SiS_Pr, 0); 242 SiS_SetSegmentRegOver(SiS_Pr, 0);
254} 243}
255 244
256static void 245static void SiS_ResetSegmentRegisters(struct SiS_Private *SiS_Pr)
257SiS_ResetSegmentRegisters(struct SiS_Private *SiS_Pr)
258{ 246{
259 SiS_ResetSegmentReg(SiS_Pr); 247 SiS_ResetSegmentReg(SiS_Pr);
260 SiS_ResetSegmentRegOver(SiS_Pr); 248 SiS_ResetSegmentRegOver(SiS_Pr);
@@ -266,7 +254,7 @@ SiS_ResetSegmentRegisters(struct SiS_Private *SiS_Pr)
266 254
267static int 255static int
268SiS_SearchModeID(struct SiS_Private *SiS_Pr, unsigned short *ModeNo, 256SiS_SearchModeID(struct SiS_Private *SiS_Pr, unsigned short *ModeNo,
269 unsigned short *ModeIdIndex) 257 unsigned short *ModeIdIndex)
270{ 258{
271 if ((*ModeNo) <= 0x13) { 259 if ((*ModeNo) <= 0x13) {
272 260
@@ -277,12 +265,14 @@ SiS_SearchModeID(struct SiS_Private *SiS_Pr, unsigned short *ModeNo,
277 265
278 } else { 266 } else {
279 267
280 for(*ModeIdIndex = 0; ;(*ModeIdIndex)++) { 268 for (*ModeIdIndex = 0;; (*ModeIdIndex)++) {
281 269
282 if (SiS_Pr->SiS_EModeIDTable[*ModeIdIndex].Ext_ModeID == (*ModeNo)) 270 if (SiS_Pr->SiS_EModeIDTable[*ModeIdIndex].Ext_ModeID ==
271 (*ModeNo))
283 break; 272 break;
284 273
285 if (SiS_Pr->SiS_EModeIDTable[*ModeIdIndex].Ext_ModeID == 0xFF) 274 if (SiS_Pr->SiS_EModeIDTable[*ModeIdIndex].Ext_ModeID ==
275 0xFF)
286 return 0; 276 return 0;
287 } 277 }
288 278
@@ -295,8 +285,7 @@ SiS_SearchModeID(struct SiS_Private *SiS_Pr, unsigned short *ModeNo,
295/* HELPER: ENABLE CRT1 */ 285/* HELPER: ENABLE CRT1 */
296/*********************************************/ 286/*********************************************/
297 287
298static void 288static void SiS_HandleCRT1(struct SiS_Private *SiS_Pr)
299SiS_HandleCRT1(struct SiS_Private *SiS_Pr)
300{ 289{
301 /* Enable CRT1 gating */ 290 /* Enable CRT1 gating */
302 SiS_SetRegAND(SiS_Pr, SiS_Pr->SiS_P3d4, SiS_Pr->SiS_MyCR63, 0xbf); 291 SiS_SetRegAND(SiS_Pr, SiS_Pr->SiS_P3d4, SiS_Pr->SiS_MyCR63, 0xbf);
@@ -308,9 +297,9 @@ SiS_HandleCRT1(struct SiS_Private *SiS_Pr)
308 297
309static unsigned short 298static unsigned short
310SiS_GetColorDepth(struct SiS_Private *SiS_Pr, unsigned short ModeNo, 299SiS_GetColorDepth(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
311 unsigned short ModeIdIndex) 300 unsigned short ModeIdIndex)
312{ 301{
313 static const unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8}; 302 static const unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8 };
314 unsigned short modeflag; 303 unsigned short modeflag;
315 short index; 304 short index;
316 305
@@ -321,7 +310,8 @@ SiS_GetColorDepth(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
321 } 310 }
322 311
323 index = (modeflag & ModeTypeMask) - ModeEGA; 312 index = (modeflag & ModeTypeMask) - ModeEGA;
324 if (index < 0) index = 0; 313 if (index < 0)
314 index = 0;
325 return ColorDepth[index]; 315 return ColorDepth[index];
326} 316}
327 317
@@ -331,7 +321,7 @@ SiS_GetColorDepth(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
331 321
332static unsigned short 322static unsigned short
333SiS_GetOffset(struct SiS_Private *SiS_Pr, unsigned short ModeNo, 323SiS_GetOffset(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
334 unsigned short ModeIdIndex, unsigned short rrti) 324 unsigned short ModeIdIndex, unsigned short rrti)
335{ 325{
336 unsigned short xres, temp, colordepth, infoflag; 326 unsigned short xres, temp, colordepth, infoflag;
337 327
@@ -368,8 +358,8 @@ SiS_SetSeqRegs(struct SiS_Private *SiS_Pr, unsigned short StandTableIndex)
368 SRdata = SiS_Pr->SiS_StandTable[StandTableIndex].SR[0] | 0x20; 358 SRdata = SiS_Pr->SiS_StandTable[StandTableIndex].SR[0] | 0x20;
369 SiS_SetReg(SiS_Pr, SiS_Pr->SiS_P3c4, 0x01, SRdata); 359 SiS_SetReg(SiS_Pr, SiS_Pr->SiS_P3c4, 0x01, SRdata);
370 360
371 for(i = 2; i <= 4; i++) { 361 for (i = 2; i <= 4; i++) {
372 SRdata = SiS_Pr->SiS_StandTable[StandTableIndex].SR[i-1]; 362 SRdata = SiS_Pr->SiS_StandTable[StandTableIndex].SR[i - 1];
373 SiS_SetReg(SiS_Pr, SiS_Pr->SiS_P3c4, i, SRdata); 363 SiS_SetReg(SiS_Pr, SiS_Pr->SiS_P3c4, i, SRdata);
374 } 364 }
375} 365}
@@ -398,7 +388,7 @@ SiS_SetCRTCRegs(struct SiS_Private *SiS_Pr, unsigned short StandTableIndex)
398 388
399 SiS_SetRegAND(SiS_Pr, SiS_Pr->SiS_P3d4, 0x11, 0x7f); 389 SiS_SetRegAND(SiS_Pr, SiS_Pr->SiS_P3d4, 0x11, 0x7f);
400 390
401 for(i = 0; i <= 0x18; i++) { 391 for (i = 0; i <= 0x18; i++) {
402 CRTCdata = SiS_Pr->SiS_StandTable[StandTableIndex].CRTC[i]; 392 CRTCdata = SiS_Pr->SiS_StandTable[StandTableIndex].CRTC[i];
403 SiS_SetReg(SiS_Pr, SiS_Pr->SiS_P3d4, i, CRTCdata); 393 SiS_SetReg(SiS_Pr, SiS_Pr->SiS_P3d4, i, CRTCdata);
404 } 394 }
@@ -414,7 +404,7 @@ SiS_SetATTRegs(struct SiS_Private *SiS_Pr, unsigned short StandTableIndex)
414 unsigned char ARdata; 404 unsigned char ARdata;
415 unsigned short i; 405 unsigned short i;
416 406
417 for(i = 0; i <= 0x13; i++) { 407 for (i = 0; i <= 0x13; i++) {
418 ARdata = SiS_Pr->SiS_StandTable[StandTableIndex].ATTR[i]; 408 ARdata = SiS_Pr->SiS_StandTable[StandTableIndex].ATTR[i];
419 SiS_GetRegByte(SiS_Pr, SiS_Pr->SiS_P3da); 409 SiS_GetRegByte(SiS_Pr, SiS_Pr->SiS_P3da);
420 SiS_SetRegByte(SiS_Pr, SiS_Pr->SiS_P3c0, i); 410 SiS_SetRegByte(SiS_Pr, SiS_Pr->SiS_P3c0, i);
@@ -439,7 +429,7 @@ SiS_SetGRCRegs(struct SiS_Private *SiS_Pr, unsigned short StandTableIndex)
439 unsigned char GRdata; 429 unsigned char GRdata;
440 unsigned short i; 430 unsigned short i;
441 431
442 for(i = 0; i <= 0x08; i++) { 432 for (i = 0; i <= 0x08; i++) {
443 GRdata = SiS_Pr->SiS_StandTable[StandTableIndex].GRC[i]; 433 GRdata = SiS_Pr->SiS_StandTable[StandTableIndex].GRC[i];
444 SiS_SetReg(SiS_Pr, SiS_Pr->SiS_P3ce, i, GRdata); 434 SiS_SetReg(SiS_Pr, SiS_Pr->SiS_P3ce, i, GRdata);
445 } 435 }
@@ -454,12 +444,11 @@ SiS_SetGRCRegs(struct SiS_Private *SiS_Pr, unsigned short StandTableIndex)
454/* CLEAR EXTENDED REGISTERS */ 444/* CLEAR EXTENDED REGISTERS */
455/*********************************************/ 445/*********************************************/
456 446
457static void 447static void SiS_ClearExt1Regs(struct SiS_Private *SiS_Pr, unsigned short ModeNo)
458SiS_ClearExt1Regs(struct SiS_Private *SiS_Pr, unsigned short ModeNo)
459{ 448{
460 int i; 449 int i;
461 450
462 for(i = 0x0A; i <= 0x0E; i++) { 451 for (i = 0x0A; i <= 0x0E; i++) {
463 SiS_SetReg(SiS_Pr, SiS_Pr->SiS_P3c4, i, 0x00); 452 SiS_SetReg(SiS_Pr, SiS_Pr->SiS_P3c4, i, 0x00);
464 } 453 }
465 454
@@ -472,15 +461,16 @@ SiS_ClearExt1Regs(struct SiS_Private *SiS_Pr, unsigned short ModeNo)
472 461
473static unsigned short 462static unsigned short
474SiS_GetRatePtr(struct SiS_Private *SiS_Pr, unsigned short ModeNo, 463SiS_GetRatePtr(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
475 unsigned short ModeIdIndex) 464 unsigned short ModeIdIndex)
476{ 465{
477 unsigned short rrti, i, index, temp; 466 unsigned short rrti, i, index, temp;
478 467
479 if (ModeNo <= 0x13) 468 if (ModeNo <= 0x13)
480 return 0xFFFF; 469 return 0xFFFF;
481 470
482 index = SiS_GetReg(SiS_Pr,SiS_Pr->SiS_P3d4, 0x33) & 0x0F; 471 index = SiS_GetReg(SiS_Pr, SiS_Pr->SiS_P3d4, 0x33) & 0x0F;
483 if (index > 0) index--; 472 if (index > 0)
473 index--;
484 474
485 rrti = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].REFindex; 475 rrti = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].REFindex;
486 ModeNo = SiS_Pr->SiS_RefIndex[rrti].ModeID; 476 ModeNo = SiS_Pr->SiS_RefIndex[rrti].ModeID;
@@ -490,13 +480,14 @@ SiS_GetRatePtr(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
490 if (SiS_Pr->SiS_RefIndex[rrti + i].ModeID != ModeNo) 480 if (SiS_Pr->SiS_RefIndex[rrti + i].ModeID != ModeNo)
491 break; 481 break;
492 482
493 temp = SiS_Pr->SiS_RefIndex[rrti + i].Ext_InfoFlag & ModeTypeMask; 483 temp =
484 SiS_Pr->SiS_RefIndex[rrti + i].Ext_InfoFlag & ModeTypeMask;
494 if (temp < SiS_Pr->SiS_ModeType) 485 if (temp < SiS_Pr->SiS_ModeType)
495 break; 486 break;
496 487
497 i++; 488 i++;
498 index--; 489 index--;
499 } while(index != 0xFFFF); 490 } while (index != 0xFFFF);
500 491
501 i--; 492 i--;
502 493
@@ -507,8 +498,7 @@ SiS_GetRatePtr(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
507/* SYNC */ 498/* SYNC */
508/*********************************************/ 499/*********************************************/
509 500
510static void 501static void SiS_SetCRT1Sync(struct SiS_Private *SiS_Pr, unsigned short rrti)
511SiS_SetCRT1Sync(struct SiS_Private *SiS_Pr, unsigned short rrti)
512{ 502{
513 unsigned short sync = SiS_Pr->SiS_RefIndex[rrti].Ext_InfoFlag >> 8; 503 unsigned short sync = SiS_Pr->SiS_RefIndex[rrti].Ext_InfoFlag >> 8;
514 sync &= 0xC0; 504 sync &= 0xC0;
@@ -522,39 +512,40 @@ SiS_SetCRT1Sync(struct SiS_Private *SiS_Pr, unsigned short rrti)
522 512
523static void 513static void
524SiS_SetCRT1CRTC(struct SiS_Private *SiS_Pr, unsigned short ModeNo, 514SiS_SetCRT1CRTC(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
525 unsigned short ModeIdIndex, unsigned short rrti) 515 unsigned short ModeIdIndex, unsigned short rrti)
526{ 516{
527 unsigned char index; 517 unsigned char index;
528 unsigned short temp, i, j, modeflag; 518 unsigned short temp, i, j, modeflag;
529 519
530 SiS_SetRegAND(SiS_Pr, SiS_Pr->SiS_P3d4,0x11,0x7f); 520 SiS_SetRegAND(SiS_Pr, SiS_Pr->SiS_P3d4, 0x11, 0x7f);
531 521
532 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag; 522 modeflag = SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
533 523
534 index = SiS_Pr->SiS_RefIndex[rrti].Ext_CRT1CRTC; 524 index = SiS_Pr->SiS_RefIndex[rrti].Ext_CRT1CRTC;
535 525
536 for(i = 0,j = 0; i <= 7; i++, j++) { 526 for (i = 0, j = 0; i <= 7; i++, j++) {
537 SiS_SetReg(SiS_Pr, SiS_Pr->SiS_P3d4, j, 527 SiS_SetReg(SiS_Pr, SiS_Pr->SiS_P3d4, j,
538 SiS_Pr->SiS_CRT1Table[index].CR[i]); 528 SiS_Pr->SiS_CRT1Table[index].CR[i]);
539 } 529 }
540 for(j = 0x10; i <= 10; i++, j++) { 530 for (j = 0x10; i <= 10; i++, j++) {
541 SiS_SetReg(SiS_Pr, SiS_Pr->SiS_P3d4, j, 531 SiS_SetReg(SiS_Pr, SiS_Pr->SiS_P3d4, j,
542 SiS_Pr->SiS_CRT1Table[index].CR[i]); 532 SiS_Pr->SiS_CRT1Table[index].CR[i]);
543 } 533 }
544 for(j = 0x15; i <= 12; i++, j++) { 534 for (j = 0x15; i <= 12; i++, j++) {
545 SiS_SetReg(SiS_Pr, SiS_Pr->SiS_P3d4, j, 535 SiS_SetReg(SiS_Pr, SiS_Pr->SiS_P3d4, j,
546 SiS_Pr->SiS_CRT1Table[index].CR[i]); 536 SiS_Pr->SiS_CRT1Table[index].CR[i]);
547 } 537 }
548 for(j = 0x0A; i <= 15; i++, j++) { 538 for (j = 0x0A; i <= 15; i++, j++) {
549 SiS_SetReg(SiS_Pr, SiS_Pr->SiS_P3c4, j, 539 SiS_SetReg(SiS_Pr, SiS_Pr->SiS_P3c4, j,
550 SiS_Pr->SiS_CRT1Table[index].CR[i]); 540 SiS_Pr->SiS_CRT1Table[index].CR[i]);
551 } 541 }
552 542
553 temp = SiS_Pr->SiS_CRT1Table[index].CR[16] & 0xE0; 543 temp = SiS_Pr->SiS_CRT1Table[index].CR[16] & 0xE0;
554 SiS_SetReg(SiS_Pr,SiS_Pr->SiS_P3c4, 0x0E, temp); 544 SiS_SetReg(SiS_Pr, SiS_Pr->SiS_P3c4, 0x0E, temp);
555 545
556 temp = ((SiS_Pr->SiS_CRT1Table[index].CR[16]) & 0x01) << 5; 546 temp = ((SiS_Pr->SiS_CRT1Table[index].CR[16]) & 0x01) << 5;
557 if (modeflag & DoubleScanMode) temp |= 0x80; 547 if (modeflag & DoubleScanMode)
548 temp |= 0x80;
558 SiS_SetRegANDOR(SiS_Pr, SiS_Pr->SiS_P3d4, 0x09, 0x5F, temp); 549 SiS_SetRegANDOR(SiS_Pr, SiS_Pr->SiS_P3d4, 0x09, 0x5F, temp);
559 550
560 if (SiS_Pr->SiS_ModeType > ModeVGA) 551 if (SiS_Pr->SiS_ModeType > ModeVGA)
@@ -569,10 +560,10 @@ SiS_SetCRT1CRTC(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
569 560
570static void 561static void
571SiS_SetCRT1Offset(struct SiS_Private *SiS_Pr, unsigned short ModeNo, 562SiS_SetCRT1Offset(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
572 unsigned short ModeIdIndex, unsigned short rrti) 563 unsigned short ModeIdIndex, unsigned short rrti)
573{ 564{
574 unsigned short du = SiS_GetOffset(SiS_Pr, ModeNo, ModeIdIndex, rrti); 565 unsigned short du = SiS_GetOffset(SiS_Pr, ModeNo, ModeIdIndex, rrti);
575 unsigned short infoflag = SiS_Pr->SiS_RefIndex[rrti].Ext_InfoFlag; 566 unsigned short infoflag = SiS_Pr->SiS_RefIndex[rrti].Ext_InfoFlag;
576 unsigned short temp; 567 unsigned short temp;
577 568
578 temp = (du >> 8) & 0x0f; 569 temp = (du >> 8) & 0x0f;
@@ -580,11 +571,13 @@ SiS_SetCRT1Offset(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
580 571
581 SiS_SetReg(SiS_Pr, SiS_Pr->SiS_P3d4, 0x13, (du & 0xFF)); 572 SiS_SetReg(SiS_Pr, SiS_Pr->SiS_P3d4, 0x13, (du & 0xFF));
582 573
583 if (infoflag & InterlaceMode) du >>= 1; 574 if (infoflag & InterlaceMode)
575 du >>= 1;
584 576
585 du <<= 5; 577 du <<= 5;
586 temp = (du >> 8) & 0xff; 578 temp = (du >> 8) & 0xff;
587 if (du & 0xff) temp++; 579 if (du & 0xff)
580 temp++;
588 temp++; 581 temp++;
589 SiS_SetReg(SiS_Pr, SiS_Pr->SiS_P3c4, 0x10, temp); 582 SiS_SetReg(SiS_Pr, SiS_Pr->SiS_P3c4, 0x10, temp);
590} 583}
@@ -595,17 +588,17 @@ SiS_SetCRT1Offset(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
595 588
596static void 589static void
597SiS_SetCRT1VCLK(struct SiS_Private *SiS_Pr, unsigned short ModeNo, 590SiS_SetCRT1VCLK(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
598 unsigned short rrti) 591 unsigned short rrti)
599{ 592{
600 unsigned short index = SiS_Pr->SiS_RefIndex[rrti].Ext_CRTVCLK; 593 unsigned short index = SiS_Pr->SiS_RefIndex[rrti].Ext_CRTVCLK;
601 unsigned short clka = SiS_Pr->SiS_VCLKData[index].SR2B; 594 unsigned short clka = SiS_Pr->SiS_VCLKData[index].SR2B;
602 unsigned short clkb = SiS_Pr->SiS_VCLKData[index].SR2C; 595 unsigned short clkb = SiS_Pr->SiS_VCLKData[index].SR2C;
603 596
604 SiS_SetRegAND(SiS_Pr, SiS_Pr->SiS_P3c4,0x31,0xCF); 597 SiS_SetRegAND(SiS_Pr, SiS_Pr->SiS_P3c4, 0x31, 0xCF);
605 598
606 SiS_SetReg(SiS_Pr,SiS_Pr->SiS_P3c4,0x2B,clka); 599 SiS_SetReg(SiS_Pr, SiS_Pr->SiS_P3c4, 0x2B, clka);
607 SiS_SetReg(SiS_Pr,SiS_Pr->SiS_P3c4,0x2C,clkb); 600 SiS_SetReg(SiS_Pr, SiS_Pr->SiS_P3c4, 0x2C, clkb);
608 SiS_SetReg(SiS_Pr,SiS_Pr->SiS_P3c4,0x2D,0x01); 601 SiS_SetReg(SiS_Pr, SiS_Pr->SiS_P3c4, 0x2D, 0x01);
609} 602}
610 603
611/*********************************************/ 604/*********************************************/
@@ -614,7 +607,7 @@ SiS_SetCRT1VCLK(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
614 607
615static void 608static void
616SiS_SetCRT1FIFO_310(struct SiS_Private *SiS_Pr, unsigned short ModeNo, 609SiS_SetCRT1FIFO_310(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
617 unsigned short mi) 610 unsigned short mi)
618{ 611{
619 unsigned short modeflag = SiS_Pr->SiS_EModeIDTable[mi].Ext_ModeFlag; 612 unsigned short modeflag = SiS_Pr->SiS_EModeIDTable[mi].Ext_ModeFlag;
620 613
@@ -639,7 +632,7 @@ SiS_SetCRT1FIFO_310(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
639 632
640static void 633static void
641SiS_SetVCLKState(struct SiS_Private *SiS_Pr, unsigned short ModeNo, 634SiS_SetVCLKState(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
642 unsigned short rrti) 635 unsigned short rrti)
643{ 636{
644 unsigned short data = 0, VCLK = 0, index = 0; 637 unsigned short data = 0, VCLK = 0, index = 0;
645 638
@@ -648,7 +641,8 @@ SiS_SetVCLKState(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
648 VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK; 641 VCLK = SiS_Pr->SiS_VCLKData[index].CLOCK;
649 } 642 }
650 643
651 if (VCLK >= 166) data |= 0x0c; 644 if (VCLK >= 166)
645 data |= 0x0c;
652 SiS_SetRegANDOR(SiS_Pr, SiS_Pr->SiS_P3c4, 0x32, 0xf3, data); 646 SiS_SetRegANDOR(SiS_Pr, SiS_Pr->SiS_P3c4, 0x32, 0xf3, data);
653 647
654 if (VCLK >= 166) 648 if (VCLK >= 166)
@@ -668,7 +662,7 @@ SiS_SetVCLKState(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
668 662
669static void 663static void
670SiS_SetCRT1ModeRegs(struct SiS_Private *SiS_Pr, unsigned short ModeNo, 664SiS_SetCRT1ModeRegs(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
671 unsigned short ModeIdIndex, unsigned short rrti) 665 unsigned short ModeIdIndex, unsigned short rrti)
672{ 666{
673 unsigned short data, infoflag = 0, modeflag; 667 unsigned short data, infoflag = 0, modeflag;
674 668
@@ -688,17 +682,22 @@ SiS_SetCRT1ModeRegs(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
688 data |= 0x02; 682 data |= 0x02;
689 data |= ((SiS_Pr->SiS_ModeType - ModeVGA) << 2); 683 data |= ((SiS_Pr->SiS_ModeType - ModeVGA) << 2);
690 } 684 }
691 if (infoflag & InterlaceMode) data |= 0x20; 685 if (infoflag & InterlaceMode)
686 data |= 0x20;
692 } 687 }
693 SiS_SetRegANDOR(SiS_Pr, SiS_Pr->SiS_P3c4, 0x06, 0xC0, data); 688 SiS_SetRegANDOR(SiS_Pr, SiS_Pr->SiS_P3c4, 0x06, 0xC0, data);
694 689
695 data = 0; 690 data = 0;
696 if (infoflag & InterlaceMode) { 691 if (infoflag & InterlaceMode) {
697 /* data = (Hsync / 8) - ((Htotal / 8) / 2) + 3 */ 692 /* data = (Hsync / 8) - ((Htotal / 8) / 2) + 3 */
698 unsigned short hrs = (SiS_GetReg(SiS_Pr, SiS_Pr->SiS_P3d4, 0x04) | 693 unsigned short hrs =
699 ((SiS_GetReg(SiS_Pr, SiS_Pr->SiS_P3c4, 0x0b) & 0xc0) << 2)) - 3; 694 (SiS_GetReg(SiS_Pr, SiS_Pr->SiS_P3d4, 0x04) |
700 unsigned short hto = (SiS_GetReg(SiS_Pr, SiS_Pr->SiS_P3d4, 0x00) | 695 ((SiS_GetReg(SiS_Pr, SiS_Pr->SiS_P3c4, 0x0b) & 0xc0) << 2))
701 ((SiS_GetReg(SiS_Pr, SiS_Pr->SiS_P3c4, 0x0b) & 0x03) << 8)) + 5; 696 - 3;
697 unsigned short hto =
698 (SiS_GetReg(SiS_Pr, SiS_Pr->SiS_P3d4, 0x00) |
699 ((SiS_GetReg(SiS_Pr, SiS_Pr->SiS_P3c4, 0x0b) & 0x03) << 8))
700 + 5;
702 data = hrs - (hto >> 1) + 3; 701 data = hrs - (hto >> 1) + 3;
703 } 702 }
704 SiS_SetReg(SiS_Pr, SiS_Pr->SiS_P3d4, 0x19, (data & 0xFF)); 703 SiS_SetReg(SiS_Pr, SiS_Pr->SiS_P3d4, 0x19, (data & 0xFF));
@@ -739,20 +738,26 @@ SiS_SetCRT1ModeRegs(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
739 738
740static void 739static void
741SiS_WriteDAC(struct SiS_Private *SiS_Pr, unsigned long DACData, 740SiS_WriteDAC(struct SiS_Private *SiS_Pr, unsigned long DACData,
742 unsigned short shiftflag, unsigned short dl, unsigned short ah, 741 unsigned short shiftflag, unsigned short dl, unsigned short ah,
743 unsigned short al, unsigned short dh) 742 unsigned short al, unsigned short dh)
744{ 743{
745 unsigned short d1, d2, d3; 744 unsigned short d1, d2, d3;
746 745
747 switch (dl) { 746 switch (dl) {
748 case 0: 747 case 0:
749 d1 = dh; d2 = ah; d3 = al; 748 d1 = dh;
750 break; 749 d2 = ah;
751 case 1: 750 d3 = al;
752 d1 = ah; d2 = al; d3 = dh; 751 break;
753 break; 752 case 1:
754 default: 753 d1 = ah;
755 d1 = al; d2 = dh; d3 = ah; 754 d2 = al;
755 d3 = dh;
756 break;
757 default:
758 d1 = al;
759 d2 = dh;
760 d3 = ah;
756 } 761 }
757 SiS_SetRegByte(SiS_Pr, DACData, (d1 << shiftflag)); 762 SiS_SetRegByte(SiS_Pr, DACData, (d1 << shiftflag));
758 SiS_SetRegByte(SiS_Pr, DACData, (d2 << shiftflag)); 763 SiS_SetRegByte(SiS_Pr, DACData, (d2 << shiftflag));
@@ -760,7 +765,8 @@ SiS_WriteDAC(struct SiS_Private *SiS_Pr, unsigned long DACData,
760} 765}
761 766
762static void 767static void
763SiS_LoadDAC(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short mi) 768SiS_LoadDAC(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
769 unsigned short mi)
764{ 770{
765 unsigned short data, data2, time, i, j, k, m, n, o; 771 unsigned short data, data2, time, i, j, k, m, n, o;
766 unsigned short si, di, bx, sf; 772 unsigned short si, di, bx, sf;
@@ -794,41 +800,45 @@ SiS_LoadDAC(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short mi
794 800
795 SiS_SetRegByte(SiS_Pr, DACAddr, 0x00); 801 SiS_SetRegByte(SiS_Pr, DACAddr, 0x00);
796 802
797 for(i = 0; i < j; i++) { 803 for (i = 0; i < j; i++) {
798 data = table[i]; 804 data = table[i];
799 for(k = 0; k < 3; k++) { 805 for (k = 0; k < 3; k++) {
800 data2 = 0; 806 data2 = 0;
801 if (data & 0x01) data2 += 0x2A; 807 if (data & 0x01)
802 if (data & 0x02) data2 += 0x15; 808 data2 += 0x2A;
809 if (data & 0x02)
810 data2 += 0x15;
803 SiS_SetRegByte(SiS_Pr, DACData, (data2 << sf)); 811 SiS_SetRegByte(SiS_Pr, DACData, (data2 << sf));
804 data >>= 2; 812 data >>= 2;
805 } 813 }
806 } 814 }
807 815
808 if (time == 256) { 816 if (time == 256) {
809 for(i = 16; i < 32; i++) { 817 for (i = 16; i < 32; i++) {
810 data = table[i] << sf; 818 data = table[i] << sf;
811 for(k = 0; k < 3; k++) 819 for (k = 0; k < 3; k++)
812 SiS_SetRegByte(SiS_Pr, DACData, data); 820 SiS_SetRegByte(SiS_Pr, DACData, data);
813 } 821 }
814 si = 32; 822 si = 32;
815 for(m = 0; m < 9; m++) { 823 for (m = 0; m < 9; m++) {
816 di = si; 824 di = si;
817 bx = si + 4; 825 bx = si + 4;
818 for(n = 0; n < 3; n++) { 826 for (n = 0; n < 3; n++) {
819 for(o = 0; o < 5; o++) { 827 for (o = 0; o < 5; o++) {
820 SiS_WriteDAC(SiS_Pr, DACData, sf, n, 828 SiS_WriteDAC(SiS_Pr, DACData, sf, n,
821 table[di], table[bx], table[si]); 829 table[di], table[bx],
830 table[si]);
822 si++; 831 si++;
823 } 832 }
824 si -= 2; 833 si -= 2;
825 for(o = 0; o < 3; o++) { 834 for (o = 0; o < 3; o++) {
826 SiS_WriteDAC(SiS_Pr, DACData, sf, n, 835 SiS_WriteDAC(SiS_Pr, DACData, sf, n,
827 table[di], table[si], table[bx]); 836 table[di], table[si],
837 table[bx]);
828 si--; 838 si--;
829 } 839 }
830 } 840 }
831 si += 5; 841 si += 5;
832 } 842 }
833 } 843 }
834} 844}
@@ -839,7 +849,7 @@ SiS_LoadDAC(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short mi
839 849
840static void 850static void
841SiS_SetCRT1Group(struct SiS_Private *SiS_Pr, unsigned short ModeNo, 851SiS_SetCRT1Group(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
842 unsigned short ModeIdIndex) 852 unsigned short ModeIdIndex)
843{ 853{
844 unsigned short StandTableIndex, rrti; 854 unsigned short StandTableIndex, rrti;
845 855
@@ -880,11 +890,10 @@ SiS_SetCRT1Group(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
880/* SiSSetMode() */ 890/* SiSSetMode() */
881/*********************************************/ 891/*********************************************/
882 892
883int 893int SiSUSBSetMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo)
884SiSUSBSetMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo)
885{ 894{
886 unsigned short ModeIdIndex; 895 unsigned short ModeIdIndex;
887 unsigned long BaseAddr = SiS_Pr->IOAddress; 896 unsigned long BaseAddr = SiS_Pr->IOAddress;
888 897
889 SiSUSB_InitPtr(SiS_Pr); 898 SiSUSB_InitPtr(SiS_Pr);
890 SiSUSBRegInit(SiS_Pr, BaseAddr); 899 SiSUSBRegInit(SiS_Pr, BaseAddr);
@@ -900,7 +909,7 @@ SiSUSBSetMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo)
900 ModeNo &= 0x7f; 909 ModeNo &= 0x7f;
901 910
902 SiS_Pr->SiS_ModeType = 911 SiS_Pr->SiS_ModeType =
903 SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag & ModeTypeMask; 912 SiS_Pr->SiS_EModeIDTable[ModeIdIndex].Ext_ModeFlag & ModeTypeMask;
904 913
905 SiS_Pr->SiS_SetFlag = LowModeTests; 914 SiS_Pr->SiS_SetFlag = LowModeTests;
906 915
@@ -918,8 +927,7 @@ SiSUSBSetMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo)
918 return 1; 927 return 1;
919} 928}
920 929
921int 930int SiSUSBSetVESAMode(struct SiS_Private *SiS_Pr, unsigned short VModeNo)
922SiSUSBSetVESAMode(struct SiS_Private *SiS_Pr, unsigned short VModeNo)
923{ 931{
924 unsigned short ModeNo = 0; 932 unsigned short ModeNo = 0;
925 int i; 933 int i;
@@ -951,7 +959,3 @@ SiSUSBSetVESAMode(struct SiS_Private *SiS_Pr, unsigned short VModeNo)
951} 959}
952 960
953#endif /* INCL_SISUSB_CON */ 961#endif /* INCL_SISUSB_CON */
954
955
956
957