1 #include <linux/delay.h>
8 #include "vb_setmode.h"
10 #define IndexMask 0xff
11 #define TVCLKBASE_315_25 (TVCLKBASE_315 + 25)
13 static const unsigned short XGINew_VGA_DAC
[] = {
14 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
15 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
16 0x00, 0x05, 0x08, 0x0B, 0x0E, 0x11, 0x14, 0x18,
17 0x1C, 0x20, 0x24, 0x28, 0x2D, 0x32, 0x38, 0x3F,
18 0x00, 0x10, 0x1F, 0x2F, 0x3F, 0x1F, 0x27, 0x2F,
19 0x37, 0x3F, 0x2D, 0x31, 0x36, 0x3A, 0x3F, 0x00,
20 0x07, 0x0E, 0x15, 0x1C, 0x0E, 0x11, 0x15, 0x18,
21 0x1C, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x00, 0x04,
22 0x08, 0x0C, 0x10, 0x08, 0x0A, 0x0C, 0x0E, 0x10,
23 0x0B, 0x0C, 0x0D, 0x0F, 0x10};
25 void InitTo330Pointer(unsigned char ChipType
, struct vb_device_info
*pVBInfo
)
27 pVBInfo
->MCLKData
= XGI340New_MCLKData
;
29 pVBInfo
->LCDResInfo
= 0;
30 pVBInfo
->LCDTypeInfo
= 0;
35 pVBInfo
->SR18
= XGI340_SR18
;
36 pVBInfo
->CR40
= XGI340_cr41
;
39 XGI_GetVBType(pVBInfo
);
41 /* 310 customization related */
42 if ((pVBInfo
->VBType
& VB_SIS301LV
) || (pVBInfo
->VBType
& VB_SIS302LV
))
43 pVBInfo
->LCDCapList
= XGI_LCDDLCapList
;
45 pVBInfo
->LCDCapList
= XGI_LCDCapList
;
48 pVBInfo
->XGINew_CR97
= 0x10;
50 if (ChipType
== XG27
) {
53 pVBInfo
->MCLKData
= XGI27New_MCLKData
;
54 pVBInfo
->CR40
= XGI27_cr41
;
55 pVBInfo
->XGINew_CR97
= 0xc1;
56 pVBInfo
->SR18
= XG27_SR18
;
59 temp
= xgifb_reg_get(pVBInfo
->P3c4
, 0x3B);
60 /* SR3B[7][3]MAA15 MAA11 (Power on Trapping) */
61 if (((temp
& 0x88) == 0x80) || ((temp
& 0x88) == 0x08))
62 pVBInfo
->XGINew_CR97
= 0x80;
67 static void XGI_SetSeqRegs(struct vb_device_info
*pVBInfo
)
69 unsigned char SRdata
, i
;
71 xgifb_reg_set(pVBInfo
->P3c4
, 0x00, 0x03); /* Set SR0 */
73 for (i
= 0; i
< 4; i
++) {
74 /* Get SR1,2,3,4 from file */
75 /* SR1 is with screen off 0x20 */
76 SRdata
= XGI330_StandTable
.SR
[i
];
77 xgifb_reg_set(pVBInfo
->P3c4
, i
+1, SRdata
); /* Set SR 1 2 3 4 */
81 static void XGI_SetCRTCRegs(struct vb_device_info
*pVBInfo
)
83 unsigned char CRTCdata
;
86 CRTCdata
= xgifb_reg_get(pVBInfo
->P3d4
, 0x11);
88 xgifb_reg_set(pVBInfo
->P3d4
, 0x11, CRTCdata
); /* Unlock CRTC */
90 for (i
= 0; i
<= 0x18; i
++) {
91 /* Get CRTC from file */
92 CRTCdata
= XGI330_StandTable
.CRTC
[i
];
93 xgifb_reg_set(pVBInfo
->P3d4
, i
, CRTCdata
); /* Set CRTC(3d4) */
97 static void XGI_SetATTRegs(unsigned short ModeIdIndex
,
98 struct vb_device_info
*pVBInfo
)
100 unsigned char ARdata
;
101 unsigned short i
, modeflag
;
103 modeflag
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
105 for (i
= 0; i
<= 0x13; i
++) {
106 ARdata
= XGI330_StandTable
.ATTR
[i
];
108 if ((modeflag
& Charx8Dot
) && i
== 0x13) { /* ifndef Dot9 */
109 if (pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
) {
111 } else if ((pVBInfo
->VBInfo
&
112 (SetCRT2ToTV
| SetCRT2ToLCD
)) &&
113 (pVBInfo
->VBInfo
& SetInSlaveMode
)) {
118 inb(pVBInfo
->P3da
); /* reset 3da */
119 outb(i
, pVBInfo
->P3c0
); /* set index */
120 outb(ARdata
, pVBInfo
->P3c0
); /* set data */
123 inb(pVBInfo
->P3da
); /* reset 3da */
124 outb(0x14, pVBInfo
->P3c0
); /* set index */
125 outb(0x00, pVBInfo
->P3c0
); /* set data */
126 inb(pVBInfo
->P3da
); /* Enable Attribute */
127 outb(0x20, pVBInfo
->P3c0
);
130 static void XGI_SetGRCRegs(struct vb_device_info
*pVBInfo
)
132 unsigned char GRdata
;
135 for (i
= 0; i
<= 0x08; i
++) {
136 /* Get GR from file */
137 GRdata
= XGI330_StandTable
.GRC
[i
];
138 xgifb_reg_set(pVBInfo
->P3ce
, i
, GRdata
); /* Set GR(3ce) */
141 if (pVBInfo
->ModeType
> ModeVGA
) {
142 GRdata
= xgifb_reg_get(pVBInfo
->P3ce
, 0x05);
143 GRdata
&= 0xBF; /* 256 color disable */
144 xgifb_reg_set(pVBInfo
->P3ce
, 0x05, GRdata
);
148 static void XGI_ClearExt1Regs(struct vb_device_info
*pVBInfo
)
152 for (i
= 0x0A; i
<= 0x0E; i
++)
153 xgifb_reg_set(pVBInfo
->P3c4
, i
, 0x00); /* Clear SR0A-SR0E */
156 static unsigned char XGI_SetDefaultVCLK(struct vb_device_info
*pVBInfo
)
159 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x31, ~0x30, 0x20);
160 xgifb_reg_set(pVBInfo
->P3c4
, 0x2B, XGI_VCLKData
[0].SR2B
);
161 xgifb_reg_set(pVBInfo
->P3c4
, 0x2C, XGI_VCLKData
[0].SR2C
);
163 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x31, ~0x30, 0x10);
164 xgifb_reg_set(pVBInfo
->P3c4
, 0x2B, XGI_VCLKData
[1].SR2B
);
165 xgifb_reg_set(pVBInfo
->P3c4
, 0x2C, XGI_VCLKData
[1].SR2C
);
167 xgifb_reg_and(pVBInfo
->P3c4
, 0x31, ~0x30);
171 static unsigned char XGI_AjustCRT2Rate(unsigned short ModeIdIndex
,
172 unsigned short RefreshRateTableIndex
, unsigned short *i
,
173 struct vb_device_info
*pVBInfo
)
175 unsigned short tempax
, tempbx
, resinfo
, modeflag
, infoflag
;
177 modeflag
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
178 resinfo
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
179 tempbx
= XGI330_RefIndex
[RefreshRateTableIndex
+ (*i
)].ModeID
;
182 if (pVBInfo
->VBInfo
& SetCRT2ToRAMDAC
) {
183 tempax
|= SupportRAMDAC2
;
185 if (pVBInfo
->VBType
& VB_XGI301C
)
186 tempax
|= SupportCRT2in301C
;
190 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| XGI_SetCRT2ToLCDA
)) {
191 tempax
|= SupportLCD
;
193 if (pVBInfo
->LCDResInfo
!= Panel_1280x1024
&&
194 pVBInfo
->LCDResInfo
!= Panel_1280x960
&&
195 (pVBInfo
->LCDInfo
& LCDNonExpanding
) &&
200 if (pVBInfo
->VBInfo
& SetCRT2ToHiVision
) { /* for HiTV */
201 tempax
|= SupportHiVision
;
202 if ((pVBInfo
->VBInfo
& SetInSlaveMode
) &&
204 (resinfo
== 3 && (pVBInfo
->SetFlag
& TVSimuMode
)) ||
207 } else if (pVBInfo
->VBInfo
& (SetCRT2ToAVIDEO
| SetCRT2ToSVIDEO
|
208 SetCRT2ToSCART
| SetCRT2ToYPbPr525750
|
209 SetCRT2ToHiVision
)) {
212 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
|
213 VB_SIS302LV
| VB_XGI301C
))
214 tempax
|= SupportTV1024
;
216 if (!(pVBInfo
->VBInfo
& TVSetPAL
) &&
217 (modeflag
& NoSupportSimuTV
) &&
218 (pVBInfo
->VBInfo
& SetInSlaveMode
) &&
219 (!(pVBInfo
->VBInfo
& SetNotSimuMode
)))
223 for (; XGI330_RefIndex
[RefreshRateTableIndex
+ (*i
)].ModeID
==
225 infoflag
= XGI330_RefIndex
[RefreshRateTableIndex
+ (*i
)].
227 if (infoflag
& tempax
)
234 for ((*i
) = 0;; (*i
)++) {
235 infoflag
= XGI330_RefIndex
[RefreshRateTableIndex
+ (*i
)].
237 if (XGI330_RefIndex
[RefreshRateTableIndex
+ (*i
)].ModeID
242 if (infoflag
& tempax
)
248 static void XGI_SetSync(unsigned short RefreshRateTableIndex
,
249 struct vb_device_info
*pVBInfo
)
251 unsigned short sync
, temp
;
254 sync
= XGI330_RefIndex
[RefreshRateTableIndex
].Ext_InfoFlag
>> 8;
258 outb(temp
, pVBInfo
->P3c2
); /* Set Misc(3c2) */
261 static void XGI_SetCRT1Timing_H(struct vb_device_info
*pVBInfo
,
262 struct xgi_hw_device_info
*HwDeviceExtension
)
264 unsigned char data
, data1
, pushax
;
268 data
= xgifb_reg_get(pVBInfo
->P3d4
, 0x11);
270 xgifb_reg_set(pVBInfo
->P3d4
, 0x11, data
);
272 data
= pVBInfo
->TimingH
.data
[0];
273 xgifb_reg_set(pVBInfo
->P3d4
, 0, data
);
275 for (i
= 0x01; i
<= 0x04; i
++) {
276 data
= pVBInfo
->TimingH
.data
[i
];
277 xgifb_reg_set(pVBInfo
->P3d4
, (unsigned short) (i
+ 1), data
);
280 for (i
= 0x05; i
<= 0x06; i
++) {
281 data
= pVBInfo
->TimingH
.data
[i
];
282 xgifb_reg_set(pVBInfo
->P3c4
, (unsigned short) (i
+ 6), data
);
285 j
= xgifb_reg_get(pVBInfo
->P3c4
, 0x0e);
287 data
= pVBInfo
->TimingH
.data
[7];
290 xgifb_reg_set(pVBInfo
->P3c4
, 0x0e, data
);
292 if (HwDeviceExtension
->jChipType
>= XG20
) {
293 data
= xgifb_reg_get(pVBInfo
->P3d4
, 0x04);
295 xgifb_reg_set(pVBInfo
->P3d4
, 0x04, data
);
296 data
= xgifb_reg_get(pVBInfo
->P3d4
, 0x05);
302 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x0c);
304 xgifb_reg_set(pVBInfo
->P3c4
, 0x0c, data
);
309 xgifb_reg_set(pVBInfo
->P3d4
, 0x05, data
);
310 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x0e);
316 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0e, ~0xE0, data
);
320 static void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex
,
321 struct vb_device_info
*pVBInfo
)
326 for (i
= 0x00; i
<= 0x01; i
++) {
327 data
= pVBInfo
->TimingV
.data
[i
];
328 xgifb_reg_set(pVBInfo
->P3d4
, (unsigned short) (i
+ 6), data
);
331 for (i
= 0x02; i
<= 0x03; i
++) {
332 data
= pVBInfo
->TimingV
.data
[i
];
333 xgifb_reg_set(pVBInfo
->P3d4
, (unsigned short) (i
+ 0x0e), data
);
336 for (i
= 0x04; i
<= 0x05; i
++) {
337 data
= pVBInfo
->TimingV
.data
[i
];
338 xgifb_reg_set(pVBInfo
->P3d4
, (unsigned short) (i
+ 0x11), data
);
341 j
= xgifb_reg_get(pVBInfo
->P3c4
, 0x0a);
343 data
= pVBInfo
->TimingV
.data
[6];
346 xgifb_reg_set(pVBInfo
->P3c4
, 0x0a, data
);
348 data
= pVBInfo
->TimingV
.data
[6];
352 i
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
357 j
= xgifb_reg_get(pVBInfo
->P3d4
, 0x09);
360 xgifb_reg_set(pVBInfo
->P3d4
, 0x09, data
);
363 static void XGI_SetCRT1CRTC(unsigned short ModeIdIndex
,
364 unsigned short RefreshRateTableIndex
,
365 struct vb_device_info
*pVBInfo
,
366 struct xgi_hw_device_info
*HwDeviceExtension
)
368 unsigned char index
, data
;
372 index
= XGI330_RefIndex
[RefreshRateTableIndex
].Ext_CRT1CRTC
;
373 index
= index
& IndexMask
;
375 data
= xgifb_reg_get(pVBInfo
->P3d4
, 0x11);
377 xgifb_reg_set(pVBInfo
->P3d4
, 0x11, data
); /* Unlock CRTC */
379 for (i
= 0; i
< 8; i
++)
380 pVBInfo
->TimingH
.data
[i
]
381 = XGI_CRT1Table
[index
].CR
[i
];
383 for (i
= 0; i
< 7; i
++)
384 pVBInfo
->TimingV
.data
[i
]
385 = XGI_CRT1Table
[index
].CR
[i
+ 8];
387 XGI_SetCRT1Timing_H(pVBInfo
, HwDeviceExtension
);
389 XGI_SetCRT1Timing_V(ModeIdIndex
, pVBInfo
);
391 if (pVBInfo
->ModeType
> 0x03)
392 xgifb_reg_set(pVBInfo
->P3d4
, 0x14, 0x4F);
395 /* --------------------------------------------------------------------- */
396 /* Function : XGI_SetXG21CRTC */
397 /* Input : Stand or enhance CRTC table */
398 /* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */
399 /* Description : Set LCD timing */
400 /* --------------------------------------------------------------------- */
401 static void XGI_SetXG21CRTC(unsigned short RefreshRateTableIndex
,
402 struct vb_device_info
*pVBInfo
)
404 unsigned char index
, Tempax
, Tempbx
, Tempcx
, Tempdx
;
405 unsigned short Temp1
, Temp2
, Temp3
;
407 index
= XGI330_RefIndex
[RefreshRateTableIndex
].Ext_CRT1CRTC
;
408 /* Tempax: CR4 HRS */
409 Tempax
= XGI_CRT1Table
[index
].CR
[3];
410 Tempcx
= Tempax
; /* Tempcx: HRS */
412 xgifb_reg_set(pVBInfo
->P3c4
, 0x2E, Tempax
);
414 Tempdx
= XGI_CRT1Table
[index
].CR
[5]; /* SRB */
415 Tempdx
&= 0xC0; /* Tempdx[7:6]: SRB[7:6] */
416 Temp1
= Tempdx
; /* Temp1[7:6]: HRS[9:8] */
417 Temp1
<<= 2; /* Temp1[9:8]: HRS[9:8] */
418 Temp1
|= Tempax
; /* Temp1[9:0]: HRS[9:0] */
420 Tempax
= XGI_CRT1Table
[index
].CR
[4]; /* CR5 HRE */
421 Tempax
&= 0x1F; /* Tempax[4:0]: HRE[4:0] */
423 Tempbx
= XGI_CRT1Table
[index
].CR
[6]; /* SRC */
424 Tempbx
&= 0x04; /* Tempbx[2]: HRE[5] */
425 Tempbx
<<= 3; /* Tempbx[5]: HRE[5] */
426 Tempax
|= Tempbx
; /* Tempax[5:0]: HRE[5:0] */
428 Temp2
= Temp1
& 0x3C0; /* Temp2[9:6]: HRS[9:6] */
429 Temp2
|= Tempax
; /* Temp2[9:0]: HRE[9:0] */
431 Tempcx
&= 0x3F; /* Tempcx[5:0]: HRS[5:0] */
432 if (Tempax
< Tempcx
) /* HRE < HRS */
433 Temp2
|= 0x40; /* Temp2 + 0x40 */
436 Tempax
= (unsigned char) Temp2
; /* Tempax: HRE[7:0] */
437 Tempax
<<= 2; /* Tempax[7:2]: HRE[5:0] */
438 Tempdx
>>= 6; /* Tempdx[7:6]->[1:0] HRS[9:8] */
439 Tempax
|= Tempdx
; /* HRE[5:0]HRS[9:8] */
440 /* SR2F D[7:2]->HRE, D[1:0]->HRS */
441 xgifb_reg_set(pVBInfo
->P3c4
, 0x2F, Tempax
);
442 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x30, 0xE3, 00);
445 Tempax
= XGI_CRT1Table
[index
].CR
[10];
446 Tempbx
= Tempax
; /* Tempbx: VRS */
447 Tempax
&= 0x01; /* Tempax[0]: VRS[0] */
448 xgifb_reg_or(pVBInfo
->P3c4
, 0x33, Tempax
); /* SR33[0]->VRS[0] */
450 Tempax
= XGI_CRT1Table
[index
].CR
[9];
451 Tempcx
= Tempbx
>> 1; /* Tempcx[6:0]: VRS[7:1] */
452 Tempdx
= Tempax
& 0x04; /* Tempdx[2]: CR7[2] */
453 Tempdx
<<= 5; /* Tempdx[7]: VRS[8] */
454 Tempcx
|= Tempdx
; /* Tempcx[7:0]: VRS[8:1] */
455 xgifb_reg_set(pVBInfo
->P3c4
, 0x34, Tempcx
); /* SR34[8:1]->VRS */
457 Temp1
= Tempdx
; /* Temp1[7]: Tempdx[7] */
458 Temp1
<<= 1; /* Temp1[8]: VRS[8] */
459 Temp1
|= Tempbx
; /* Temp1[8:0]: VRS[8:0] */
461 Temp2
= Tempax
<< 2; /* Temp2[9]: VRS[9] */
462 Temp1
|= Temp2
; /* Temp1[9:0]: VRS[9:0] */
464 Tempax
= XGI_CRT1Table
[index
].CR
[14];
465 Tempax
&= 0x08; /* Tempax[3]: VRS[3] */
467 Temp2
<<= 7; /* Temp2[10]: VRS[10] */
468 Temp1
|= Temp2
; /* Temp1[10:0]: VRS[10:0] */
470 /* Tempax: CR11 VRE */
471 Tempax
= XGI_CRT1Table
[index
].CR
[11];
472 Tempax
&= 0x0F; /* Tempax[3:0]: VRE[3:0] */
474 Tempbx
= XGI_CRT1Table
[index
].CR
[14];
475 Tempbx
&= 0x20; /* Tempbx[5]: VRE[5] */
476 Tempbx
>>= 1; /* Tempbx[4]: VRE[4] */
477 Tempax
|= Tempbx
; /* Tempax[4:0]: VRE[4:0] */
478 Temp2
= Temp1
& 0x7E0; /* Temp2[10:5]: VRS[10:5] */
479 Temp2
|= Tempax
; /* Temp2[10:5]: VRE[10:5] */
481 Temp3
= Temp1
& 0x1F; /* Temp3[4:0]: VRS[4:0] */
482 if (Tempax
< Temp3
) /* VRE < VRS */
483 Temp2
|= 0x20; /* VRE + 0x20 */
486 Tempax
= (unsigned char) Temp2
; /* Tempax: VRE[7:0] */
487 Tempax
<<= 2; /* Tempax[7:0]; VRE[5:0]00 */
488 Temp1
&= 0x600; /* Temp1[10:9]: VRS[10:9] */
489 Temp1
>>= 9; /* Temp1[1:0]: VRS[10:9] */
490 Tempbx
= (unsigned char) Temp1
;
491 Tempax
|= Tempbx
; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */
493 /* SR3F D[7:2]->VRE D[1:0]->VRS */
494 xgifb_reg_set(pVBInfo
->P3c4
, 0x3F, Tempax
);
497 static void XGI_SetXG27CRTC(unsigned short RefreshRateTableIndex
,
498 struct vb_device_info
*pVBInfo
)
500 unsigned short index
, Tempax
, Tempbx
, Tempcx
;
502 index
= XGI330_RefIndex
[RefreshRateTableIndex
].Ext_CRT1CRTC
;
503 /* Tempax: CR4 HRS */
504 Tempax
= XGI_CRT1Table
[index
].CR
[3];
505 Tempbx
= Tempax
; /* Tempbx: HRS[7:0] */
507 xgifb_reg_set(pVBInfo
->P3c4
, 0x2E, Tempax
);
510 Tempax
= XGI_CRT1Table
[index
].CR
[5];
511 Tempax
&= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
512 Tempbx
|= (Tempax
<< 2); /* Tempbx: HRS[9:0] */
514 Tempax
= XGI_CRT1Table
[index
].CR
[4]; /* CR5 HRE */
515 Tempax
&= 0x1F; /* Tempax[4:0]: HRE[4:0] */
516 Tempcx
= Tempax
; /* Tempcx: HRE[4:0] */
518 Tempax
= XGI_CRT1Table
[index
].CR
[6]; /* SRC */
519 Tempax
&= 0x04; /* Tempax[2]: HRE[5] */
520 Tempax
<<= 3; /* Tempax[5]: HRE[5] */
521 Tempcx
|= Tempax
; /* Tempcx[5:0]: HRE[5:0] */
523 Tempbx
= Tempbx
& 0x3C0; /* Tempbx[9:6]: HRS[9:6] */
524 Tempbx
|= Tempcx
; /* Tempbx: HRS[9:6]HRE[5:0] */
526 /* Tempax: CR4 HRS */
527 Tempax
= XGI_CRT1Table
[index
].CR
[3];
528 Tempax
&= 0x3F; /* Tempax: HRS[5:0] */
529 if (Tempcx
<= Tempax
) /* HRE[5:0] < HRS[5:0] */
530 Tempbx
+= 0x40; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/
532 Tempax
= XGI_CRT1Table
[index
].CR
[5]; /* SR0B */
533 Tempax
&= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
534 Tempax
>>= 6; /* Tempax[1:0]: HRS[9:8]*/
535 Tempax
|= ((Tempbx
<< 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */
536 /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */
537 xgifb_reg_set(pVBInfo
->P3c4
, 0x2F, Tempax
);
538 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x30, 0xE3, 00);
541 Tempax
= XGI_CRT1Table
[index
].CR
[10];
542 /* SR34[7:0]->VRS[7:0] */
543 xgifb_reg_set(pVBInfo
->P3c4
, 0x34, Tempax
);
545 Tempcx
= Tempax
; /* Tempcx <= VRS[7:0] */
546 /* CR7[7][2] VRS[9][8] */
547 Tempax
= XGI_CRT1Table
[index
].CR
[9];
548 Tempbx
= Tempax
; /* Tempbx <= CR07[7:0] */
549 Tempax
= Tempax
& 0x04; /* Tempax[2]: CR7[2]: VRS[8] */
550 Tempax
>>= 2; /* Tempax[0]: VRS[8] */
551 /* SR35[0]: VRS[8] */
552 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x35, ~0x01, Tempax
);
553 Tempcx
|= (Tempax
<< 8); /* Tempcx <= VRS[8:0] */
554 Tempcx
|= ((Tempbx
& 0x80) << 2); /* Tempcx <= VRS[9:0] */
556 Tempax
= XGI_CRT1Table
[index
].CR
[14];
557 Tempax
&= 0x08; /* SR0A[3] VRS[10] */
558 Tempcx
|= (Tempax
<< 7); /* Tempcx <= VRS[10:0] */
560 /* Tempax: CR11 VRE */
561 Tempax
= XGI_CRT1Table
[index
].CR
[11];
562 Tempax
&= 0x0F; /* Tempax[3:0]: VRE[3:0] */
564 Tempbx
= XGI_CRT1Table
[index
].CR
[14];
565 Tempbx
&= 0x20; /* Tempbx[5]: SR0A[5]: VRE[4] */
566 Tempbx
>>= 1; /* Tempbx[4]: VRE[4] */
567 Tempax
|= Tempbx
; /* Tempax[4:0]: VRE[4:0] */
568 Tempbx
= Tempcx
; /* Tempbx: VRS[10:0] */
569 Tempbx
&= 0x7E0; /* Tempbx[10:5]: VRS[10:5] */
570 Tempbx
|= Tempax
; /* Tempbx: VRS[10:5]VRE[4:0] */
572 if (Tempbx
<= Tempcx
) /* VRE <= VRS */
573 Tempbx
|= 0x20; /* VRE + 0x20 */
575 /* Tempax: Tempax[7:0]; VRE[5:0]00 */
576 Tempax
= (Tempbx
<< 2) & 0xFF;
577 /* SR3F[7:2]:VRE[5:0] */
578 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x3F, ~0xFC, Tempax
);
579 Tempax
= Tempcx
>> 8;
580 /* SR35[2:0]:VRS[10:8] */
581 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x35, ~0x07, Tempax
);
584 static void XGI_SetXG27FPBits(struct vb_device_info
*pVBInfo
)
588 /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */
589 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x37);
590 temp
= (temp
& 3) << 6;
591 /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */
592 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x06, ~0xc0, temp
& 0x80);
593 /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */
594 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x09, ~0xc0, temp
| 0x80);
598 static void xgifb_set_lcd(int chip_id
,
599 struct vb_device_info
*pVBInfo
,
600 unsigned short RefreshRateTableIndex
)
604 xgifb_reg_set(pVBInfo
->P3d4
, 0x2E, 0x00);
605 xgifb_reg_set(pVBInfo
->P3d4
, 0x2F, 0x00);
606 xgifb_reg_set(pVBInfo
->P3d4
, 0x46, 0x00);
607 xgifb_reg_set(pVBInfo
->P3d4
, 0x47, 0x00);
609 if (chip_id
== XG27
) {
610 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x37);
611 if ((temp
& 0x03) == 0) { /* dual 12 */
612 xgifb_reg_set(pVBInfo
->P3d4
, 0x46, 0x13);
613 xgifb_reg_set(pVBInfo
->P3d4
, 0x47, 0x13);
617 if (chip_id
== XG27
) {
618 XGI_SetXG27FPBits(pVBInfo
);
620 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x37);
623 xgifb_reg_or(pVBInfo
->P3c4
, 0x06, 0x40);
624 xgifb_reg_or(pVBInfo
->P3c4
, 0x09, 0x40);
628 xgifb_reg_or(pVBInfo
->P3c4
, 0x1E, 0x01); /* Negative blank polarity */
630 xgifb_reg_and(pVBInfo
->P3c4
, 0x30, ~0x20); /* Hsync polarity */
631 xgifb_reg_and(pVBInfo
->P3c4
, 0x35, ~0x80); /* Vsync polarity */
633 temp
= XGI330_RefIndex
[RefreshRateTableIndex
].Ext_InfoFlag
;
636 xgifb_reg_or(pVBInfo
->P3c4
, 0x30, 0x20);
639 xgifb_reg_or(pVBInfo
->P3c4
, 0x35, 0x80);
642 /* --------------------------------------------------------------------- */
643 /* Function : XGI_UpdateXG21CRTC */
645 /* Output : CRT1 CRTC */
646 /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */
647 /* --------------------------------------------------------------------- */
648 static void XGI_UpdateXG21CRTC(unsigned short ModeNo
,
649 struct vb_device_info
*pVBInfo
,
650 unsigned short RefreshRateTableIndex
)
654 xgifb_reg_and(pVBInfo
->P3d4
, 0x11, 0x7F); /* Unlock CR0~7 */
655 if (ModeNo
== 0x2E &&
656 (XGI330_RefIndex
[RefreshRateTableIndex
].Ext_CRT1CRTC
==
659 else if (ModeNo
== 0x2E && (XGI330_RefIndex
[RefreshRateTableIndex
].
660 Ext_CRT1CRTC
== RES640x480x72
))
662 else if (ModeNo
== 0x2F)
664 else if (ModeNo
== 0x50)
666 else if (ModeNo
== 0x59)
670 xgifb_reg_set(pVBInfo
->P3d4
, 0x02,
671 XGI_UpdateCRT1Table
[index
].CR02
);
672 xgifb_reg_set(pVBInfo
->P3d4
, 0x03,
673 XGI_UpdateCRT1Table
[index
].CR03
);
674 xgifb_reg_set(pVBInfo
->P3d4
, 0x15,
675 XGI_UpdateCRT1Table
[index
].CR15
);
676 xgifb_reg_set(pVBInfo
->P3d4
, 0x16,
677 XGI_UpdateCRT1Table
[index
].CR16
);
681 static void XGI_SetCRT1DE(unsigned short ModeIdIndex
,
682 unsigned short RefreshRateTableIndex
,
683 struct vb_device_info
*pVBInfo
)
685 unsigned short resindex
, tempax
, tempbx
, tempcx
, temp
, modeflag
;
689 resindex
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
691 modeflag
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
692 tempax
= XGI330_ModeResInfo
[resindex
].HTotal
;
693 tempbx
= XGI330_ModeResInfo
[resindex
].VTotal
;
695 if (modeflag
& HalfDCLK
)
696 tempax
= tempax
>> 1;
698 if (modeflag
& HalfDCLK
)
699 tempax
= tempax
<< 1;
701 temp
= XGI330_RefIndex
[RefreshRateTableIndex
].Ext_InfoFlag
;
703 if (temp
& InterlaceMode
)
704 tempbx
= tempbx
>> 1;
706 if (modeflag
& DoubleScanMode
)
707 tempbx
= tempbx
<< 1;
715 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x11);
716 data
= xgifb_reg_get(pVBInfo
->P3d4
, 0x11);
718 xgifb_reg_set(pVBInfo
->P3d4
, 0x11, data
); /* Unlock CRTC */
719 xgifb_reg_set(pVBInfo
->P3d4
, 0x01, (unsigned short) (tempcx
& 0xff));
720 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x0b, ~0x0c,
721 (unsigned short) ((tempcx
& 0x0ff00) >> 10));
722 xgifb_reg_set(pVBInfo
->P3d4
, 0x12, (unsigned short) (tempbx
& 0xff));
724 tempbx
= tempbx
>> 8;
732 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x07, ~0x42, tempax
);
733 data
= xgifb_reg_get(pVBInfo
->P3d4
, 0x07);
739 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x0a, ~0x02, tempax
);
740 xgifb_reg_set(pVBInfo
->P3d4
, 0x11, temp
);
743 static void XGI_SetCRT1Offset(unsigned short ModeNo
,
744 unsigned short ModeIdIndex
,
745 unsigned short RefreshRateTableIndex
,
746 struct xgi_hw_device_info
*HwDeviceExtension
,
747 struct vb_device_info
*pVBInfo
)
749 unsigned short temp
, ah
, al
, temp2
, i
, DisplayUnit
;
752 temp
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_ModeInfo
;
754 temp
= XGI330_ScreenOffset
[temp
];
756 temp2
= XGI330_RefIndex
[RefreshRateTableIndex
].Ext_InfoFlag
;
757 temp2
&= InterlaceMode
;
762 temp2
= pVBInfo
->ModeType
- ModeEGA
;
787 if ((ModeNo
>= 0x26) && (ModeNo
<= 0x28))
788 temp
= temp
* temp2
+ temp2
/ 2;
795 temp
= temp
>> 8; /* ah */
797 i
= xgifb_reg_get(pVBInfo
->P3c4
, 0x0E);
800 xgifb_reg_set(pVBInfo
->P3c4
, 0x0E, i
);
802 temp
= (unsigned char) temp2
;
803 temp
&= 0xFF; /* al */
804 xgifb_reg_set(pVBInfo
->P3d4
, 0x13, temp
);
807 temp2
= XGI330_RefIndex
[RefreshRateTableIndex
].Ext_InfoFlag
;
808 temp2
&= InterlaceMode
;
812 DisplayUnit
= DisplayUnit
<< 5;
813 ah
= (DisplayUnit
& 0xff00) >> 8;
814 al
= DisplayUnit
& 0x00ff;
820 if (HwDeviceExtension
->jChipType
>= XG20
)
821 if ((ModeNo
== 0x4A) | (ModeNo
== 0x49))
824 xgifb_reg_set(pVBInfo
->P3c4
, 0x10, ah
);
827 static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeIdIndex
,
828 unsigned short RefreshRateTableIndex
,
829 struct vb_device_info
*pVBInfo
)
831 unsigned short VCLKIndex
, modeflag
;
834 modeflag
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
836 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| XGI_SetCRT2ToLCDA
)) { /*301b*/
837 if (pVBInfo
->LCDResInfo
!= Panel_1024x768
)
839 VCLKIndex
= VCLK108_2_315
+ 5;
841 VCLKIndex
= VCLK65_315
+ 2; /* LCDXlat1VCLK */
842 } else if (pVBInfo
->VBInfo
& SetCRT2ToHiVision
) {
843 if (pVBInfo
->SetFlag
& RPLLDIV2XO
)
844 VCLKIndex
= TVCLKBASE_315_25
+ HiTVVCLKDIV2
;
846 VCLKIndex
= TVCLKBASE_315_25
+ HiTVVCLK
;
848 if (pVBInfo
->SetFlag
& TVSimuMode
) {
849 if (modeflag
& Charx8Dot
)
850 VCLKIndex
= TVCLKBASE_315_25
+ HiTVSimuVCLK
;
852 VCLKIndex
= TVCLKBASE_315_25
+ HiTVTextVCLK
;
856 if (pVBInfo
->VBType
& VB_SIS301LV
) {
857 if (pVBInfo
->SetFlag
& RPLLDIV2XO
)
858 VCLKIndex
= YPbPr525iVCLK_2
;
860 VCLKIndex
= YPbPr525iVCLK
;
862 } else if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
863 if (pVBInfo
->SetFlag
& RPLLDIV2XO
)
864 VCLKIndex
= TVCLKBASE_315_25
+ TVVCLKDIV2
;
866 VCLKIndex
= TVCLKBASE_315_25
+ TVVCLK
;
867 } else { /* for CRT2 */
869 VCLKIndex
= XGI330_RefIndex
[RefreshRateTableIndex
].Ext_CRTVCLK
;
870 VCLKIndex
&= IndexMask
;
876 static void XGI_SetCRT1VCLK(unsigned short ModeIdIndex
,
877 struct xgi_hw_device_info
*HwDeviceExtension
,
878 unsigned short RefreshRateTableIndex
,
879 struct vb_device_info
*pVBInfo
)
881 unsigned char index
, data
;
882 unsigned short vclkindex
;
884 if ((pVBInfo
->IF_DEF_LVDS
== 0) &&
885 (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
|
886 VB_SIS302LV
| VB_XGI301C
)) &&
887 (pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
)) {
888 vclkindex
= XGI_GetVCLK2Ptr(ModeIdIndex
, RefreshRateTableIndex
,
890 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x31) & 0xCF;
891 xgifb_reg_set(pVBInfo
->P3c4
, 0x31, data
);
892 data
= XGI_VBVCLKData
[vclkindex
].Part4_A
;
893 xgifb_reg_set(pVBInfo
->P3c4
, 0x2B, data
);
894 data
= XGI_VBVCLKData
[vclkindex
].Part4_B
;
895 xgifb_reg_set(pVBInfo
->P3c4
, 0x2C, data
);
896 xgifb_reg_set(pVBInfo
->P3c4
, 0x2D, 0x01);
898 index
= XGI330_RefIndex
[RefreshRateTableIndex
].Ext_CRTVCLK
;
899 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x31) & 0xCF;
900 xgifb_reg_set(pVBInfo
->P3c4
, 0x31, data
);
901 xgifb_reg_set(pVBInfo
->P3c4
, 0x2B, XGI_VCLKData
[index
].SR2B
);
902 xgifb_reg_set(pVBInfo
->P3c4
, 0x2C, XGI_VCLKData
[index
].SR2C
);
903 xgifb_reg_set(pVBInfo
->P3c4
, 0x2D, 0x01);
906 if (HwDeviceExtension
->jChipType
>= XG20
) {
907 if (XGI330_EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
&
909 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x2B);
910 xgifb_reg_set(pVBInfo
->P3c4
, 0x2B, data
);
911 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x2C);
918 xgifb_reg_set(pVBInfo
->P3c4
, 0x2C, data
);
923 static void XGI_SetXG21FPBits(struct vb_device_info
*pVBInfo
)
927 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x37); /* D[0] 1: 18bit */
928 temp
= (temp
& 1) << 6;
929 /* SR06[6] 18bit Dither */
930 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x06, ~0x40, temp
);
931 /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */
932 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x09, ~0xc0, temp
| 0x80);
936 static void XGI_SetCRT1FIFO(struct xgi_hw_device_info
*HwDeviceExtension
,
937 struct vb_device_info
*pVBInfo
)
941 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x3D);
943 xgifb_reg_set(pVBInfo
->P3c4
, 0x3D, data
); /* diable auto-threshold */
945 xgifb_reg_set(pVBInfo
->P3c4
, 0x08, 0x34);
946 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x09);
948 xgifb_reg_set(pVBInfo
->P3c4
, 0x09, data
| 0x30);
949 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x3D);
951 xgifb_reg_set(pVBInfo
->P3c4
, 0x3D, data
);
953 if (HwDeviceExtension
->jChipType
== XG21
)
954 XGI_SetXG21FPBits(pVBInfo
); /* Fix SR9[7:6] can't read back */
957 static void XGI_SetVCLKState(struct xgi_hw_device_info
*HwDeviceExtension
,
958 unsigned short RefreshRateTableIndex
,
959 struct vb_device_info
*pVBInfo
)
961 unsigned short data
, data2
= 0;
966 index
= XGI330_RefIndex
[RefreshRateTableIndex
].Ext_CRTVCLK
;
968 VCLK
= XGI_VCLKData
[index
].CLOCK
;
970 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x32);
973 data
|= 0x0c; /* VCLK > 200 */
975 if (HwDeviceExtension
->jChipType
>= XG20
)
976 data
&= ~0x04; /* 2 pixel mode */
978 xgifb_reg_set(pVBInfo
->P3c4
, 0x32, data
);
980 if (HwDeviceExtension
->jChipType
< XG20
) {
981 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x1F);
985 xgifb_reg_set(pVBInfo
->P3c4
, 0x1F, data
);
990 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x07, 0xFC, data2
);
991 if (HwDeviceExtension
->jChipType
>= XG27
)
992 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x40, 0xFC, data2
& 0x03);
996 static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info
*HwDeviceExtension
,
997 unsigned short ModeIdIndex
,
998 unsigned short RefreshRateTableIndex
,
999 struct vb_device_info
*pVBInfo
)
1001 unsigned short data
, data2
, data3
, infoflag
= 0, modeflag
, resindex
,
1004 modeflag
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
1005 infoflag
= XGI330_RefIndex
[RefreshRateTableIndex
].Ext_InfoFlag
;
1007 if (xgifb_reg_get(pVBInfo
->P3d4
, 0x31) & 0x01)
1008 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x1F, 0x3F, 0x00);
1013 data3
= pVBInfo
->ModeType
- ModeVGA
;
1016 data
&= InterlaceMode
;
1021 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x06, ~0x3F, data2
);
1022 resindex
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
1023 xres
= XGI330_ModeResInfo
[resindex
].HTotal
; /* xres->ax */
1026 if (infoflag
& InterlaceMode
) {
1029 else if (xres
== 1280)
1033 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x19, 0xFF, data
);
1034 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x19, 0xFC, 0);
1036 if (modeflag
& HalfDCLK
)
1037 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x01, 0xF7, 0x08);
1041 if (modeflag
& LineCompareOff
)
1044 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0F, ~0x48, data2
);
1048 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x21, 0x1F, data
);
1050 XGI_SetVCLKState(HwDeviceExtension
, RefreshRateTableIndex
, pVBInfo
);
1052 data
= xgifb_reg_get(pVBInfo
->P3d4
, 0x31);
1054 if (HwDeviceExtension
->jChipType
== XG27
) {
1059 xgifb_reg_set(pVBInfo
->P3d4
, 0x52, data
);
1060 xgifb_reg_or(pVBInfo
->P3d4
, 0x51, 0x10);
1061 } else if (HwDeviceExtension
->jChipType
>= XG20
) {
1066 xgifb_reg_set(pVBInfo
->P3d4
, 0x52, data
);
1067 xgifb_reg_set(pVBInfo
->P3d4
, 0x51, 0x02);
1073 xgifb_reg_set(pVBInfo
->P3d4
, 0x52, data
);
1078 static void XGI_WriteDAC(unsigned short dl
,
1082 struct vb_device_info
*pVBInfo
)
1084 unsigned short temp
, bh
, bl
;
1103 outb((unsigned short) dh
, pVBInfo
->P3c9
);
1104 outb((unsigned short) bh
, pVBInfo
->P3c9
);
1105 outb((unsigned short) bl
, pVBInfo
->P3c9
);
1108 static void XGI_LoadDAC(struct vb_device_info
*pVBInfo
)
1110 unsigned short data
, data2
, i
, k
, m
, n
, o
, si
, di
, bx
, dl
, al
, ah
, dh
;
1111 const unsigned short *table
= XGINew_VGA_DAC
;
1113 outb(0xFF, pVBInfo
->P3c6
);
1114 outb(0x00, pVBInfo
->P3c8
);
1116 for (i
= 0; i
< 16; i
++) {
1119 for (k
= 0; k
< 3; k
++) {
1128 outb(data2
, pVBInfo
->P3c9
);
1133 for (i
= 16; i
< 32; i
++) {
1136 for (k
= 0; k
< 3; k
++)
1137 outb(data
, pVBInfo
->P3c9
);
1142 for (m
= 0; m
< 9; m
++) {
1147 for (n
= 0; n
< 3; n
++) {
1148 for (o
= 0; o
< 5; o
++) {
1153 XGI_WriteDAC(dl
, ah
, al
, dh
, pVBInfo
);
1158 for (o
= 0; o
< 3; o
++) {
1163 XGI_WriteDAC(dl
, ah
, al
, dh
, pVBInfo
);
1173 static void XGI_GetLVDSResInfo(unsigned short ModeIdIndex
,
1174 struct vb_device_info
*pVBInfo
)
1176 unsigned short resindex
, xres
, yres
, modeflag
;
1178 /* si+Ext_ResInfo */
1179 modeflag
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
1181 /* si+Ext_ResInfo */
1182 resindex
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
1184 xres
= XGI330_ModeResInfo
[resindex
].HTotal
;
1185 yres
= XGI330_ModeResInfo
[resindex
].VTotal
;
1187 if (modeflag
& HalfDCLK
)
1190 if (modeflag
& DoubleScanMode
)
1196 pVBInfo
->VGAHDE
= xres
;
1197 pVBInfo
->HDE
= xres
;
1198 pVBInfo
->VGAVDE
= yres
;
1199 pVBInfo
->VDE
= yres
;
1202 static void const *XGI_GetLcdPtr(struct XGI330_LCDDataTablStruct
const *table
,
1203 unsigned short ModeIdIndex
,
1204 struct vb_device_info
*pVBInfo
)
1206 unsigned short i
, tempdx
, tempbx
, modeflag
;
1210 modeflag
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
1214 while (table
[i
].PANELID
!= 0xff) {
1215 tempdx
= pVBInfo
->LCDResInfo
;
1216 if (tempbx
& 0x0080) { /* OEMUtil */
1217 tempbx
&= (~0x0080);
1218 tempdx
= pVBInfo
->LCDTypeInfo
;
1221 if (pVBInfo
->LCDInfo
& EnableScalingLCD
)
1222 tempdx
&= (~PanelResInfo
);
1224 if (table
[i
].PANELID
== tempdx
) {
1225 tempbx
= table
[i
].MASK
;
1226 tempdx
= pVBInfo
->LCDInfo
;
1228 if (modeflag
& HalfDCLK
)
1229 tempdx
|= SetLCDLowResolution
;
1232 if (tempbx
== table
[i
].CAP
)
1238 return table
[i
].DATAPTR
;
1241 static struct SiS_TVData
const *XGI_GetTVPtr(unsigned short ModeIdIndex
,
1242 unsigned short RefreshRateTableIndex
,
1243 struct vb_device_info
*pVBInfo
)
1245 unsigned short i
, tempdx
, tempal
, modeflag
;
1247 modeflag
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
1248 tempal
= XGI330_RefIndex
[RefreshRateTableIndex
].Ext_CRT2CRTC
;
1249 tempal
= tempal
& 0x3f;
1250 tempdx
= pVBInfo
->TVInfo
;
1252 if (pVBInfo
->VBInfo
& SetInSlaveMode
)
1253 tempdx
= tempdx
| SetTVLockMode
;
1255 if (modeflag
& HalfDCLK
)
1256 tempdx
= tempdx
| SetTVLowResolution
;
1260 while (XGI_TVDataTable
[i
].MASK
!= 0xffff) {
1261 if ((tempdx
& XGI_TVDataTable
[i
].MASK
) ==
1262 XGI_TVDataTable
[i
].CAP
)
1267 return &XGI_TVDataTable
[i
].DATAPTR
[tempal
];
1270 static void XGI_GetLVDSData(unsigned short ModeIdIndex
,
1271 struct vb_device_info
*pVBInfo
)
1273 struct SiS_LVDSData
const *LCDPtr
;
1275 if (!(pVBInfo
->VBInfo
& (SetCRT2ToLCD
| XGI_SetCRT2ToLCDA
)))
1278 LCDPtr
= XGI_GetLcdPtr(XGI_EPLLCDDataPtr
, ModeIdIndex
, pVBInfo
);
1279 pVBInfo
->VGAHT
= LCDPtr
->VGAHT
;
1280 pVBInfo
->VGAVT
= LCDPtr
->VGAVT
;
1281 pVBInfo
->HT
= LCDPtr
->LCDHT
;
1282 pVBInfo
->VT
= LCDPtr
->LCDVT
;
1284 if (pVBInfo
->LCDInfo
& (SetLCDtoNonExpanding
| EnableScalingLCD
))
1287 if ((pVBInfo
->LCDResInfo
== Panel_1024x768
) ||
1288 (pVBInfo
->LCDResInfo
== Panel_1024x768x75
)) {
1289 pVBInfo
->HDE
= 1024;
1291 } else if ((pVBInfo
->LCDResInfo
== Panel_1280x1024
) ||
1292 (pVBInfo
->LCDResInfo
== Panel_1280x1024x75
)) {
1293 pVBInfo
->HDE
= 1280;
1294 pVBInfo
->VDE
= 1024;
1295 } else if (pVBInfo
->LCDResInfo
== Panel_1400x1050
) {
1296 pVBInfo
->HDE
= 1400;
1297 pVBInfo
->VDE
= 1050;
1299 pVBInfo
->HDE
= 1600;
1300 pVBInfo
->VDE
= 1200;
1304 static void XGI_ModCRT1Regs(unsigned short ModeIdIndex
,
1305 struct xgi_hw_device_info
*HwDeviceExtension
,
1306 struct vb_device_info
*pVBInfo
)
1309 struct XGI_LVDSCRT1HDataStruct
const *LCDPtr
= NULL
;
1310 struct XGI_LVDSCRT1VDataStruct
const *LCDPtr1
= NULL
;
1312 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| XGI_SetCRT2ToLCDA
)) {
1313 LCDPtr
= XGI_GetLcdPtr(xgifb_epllcd_crt1_h
, ModeIdIndex
,
1316 for (i
= 0; i
< 8; i
++)
1317 pVBInfo
->TimingH
.data
[i
] = LCDPtr
[0].Reg
[i
];
1320 XGI_SetCRT1Timing_H(pVBInfo
, HwDeviceExtension
);
1322 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| XGI_SetCRT2ToLCDA
)) {
1323 LCDPtr1
= XGI_GetLcdPtr(xgifb_epllcd_crt1_v
, ModeIdIndex
,
1325 for (i
= 0; i
< 7; i
++)
1326 pVBInfo
->TimingV
.data
[i
] = LCDPtr1
[0].Reg
[i
];
1329 XGI_SetCRT1Timing_V(ModeIdIndex
, pVBInfo
);
1332 static unsigned short XGI_GetLCDCapPtr(struct vb_device_info
*pVBInfo
)
1334 unsigned char tempal
, tempah
, tempbl
, i
;
1336 tempah
= xgifb_reg_get(pVBInfo
->P3d4
, 0x36);
1337 tempal
= tempah
& 0x0F;
1338 tempah
= tempah
& 0xF0;
1340 tempbl
= pVBInfo
->LCDCapList
[i
].LCD_ID
;
1342 while (tempbl
!= 0xFF) {
1343 if (tempbl
& 0x80) { /* OEMUtil */
1345 tempbl
= tempbl
& ~(0x80);
1348 if (tempal
== tempbl
)
1353 tempbl
= pVBInfo
->LCDCapList
[i
].LCD_ID
;
1359 static unsigned short XGI_GetLCDCapPtr1(struct vb_device_info
*pVBInfo
)
1361 unsigned short tempah
, tempal
, tempbl
, i
;
1363 tempal
= pVBInfo
->LCDResInfo
;
1364 tempah
= pVBInfo
->LCDTypeInfo
;
1367 tempbl
= pVBInfo
->LCDCapList
[i
].LCD_ID
;
1369 while (tempbl
!= 0xFF) {
1370 if ((tempbl
& 0x80) && (tempbl
!= 0x80)) {
1375 if (tempal
== tempbl
)
1379 tempbl
= pVBInfo
->LCDCapList
[i
].LCD_ID
;
1382 if (tempbl
== 0xFF) {
1383 pVBInfo
->LCDResInfo
= Panel_1024x768
;
1384 pVBInfo
->LCDTypeInfo
= 0;
1391 static void XGI_GetLCDSync(unsigned short *HSyncWidth
,
1392 unsigned short *VSyncWidth
,
1393 struct vb_device_info
*pVBInfo
)
1395 unsigned short Index
;
1397 Index
= XGI_GetLCDCapPtr(pVBInfo
);
1398 *HSyncWidth
= pVBInfo
->LCDCapList
[Index
].LCD_HSyncWidth
;
1399 *VSyncWidth
= pVBInfo
->LCDCapList
[Index
].LCD_VSyncWidth
;
1402 static void XGI_SetLVDSRegs(unsigned short ModeIdIndex
,
1403 struct vb_device_info
*pVBInfo
)
1405 unsigned short tempbx
, tempax
, tempcx
, tempdx
, push1
, push2
, modeflag
;
1406 unsigned long temp
, temp1
, temp2
, temp3
, push3
;
1407 struct XGI330_LCDDataDesStruct2
const *LCDPtr1
= NULL
;
1409 modeflag
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
1410 LCDPtr1
= XGI_GetLcdPtr(XGI_EPLLCDDesDataPtr
, ModeIdIndex
, pVBInfo
);
1412 XGI_GetLCDSync(&tempax
, &tempbx
, pVBInfo
);
1417 if ((pVBInfo
->LCDResInfo
== Panel_1024x768
) ||
1418 (pVBInfo
->LCDResInfo
== Panel_1024x768x75
)) {
1421 } else if ((pVBInfo
->LCDResInfo
== Panel_1280x1024
) ||
1422 (pVBInfo
->LCDResInfo
== Panel_1280x1024x75
)) {
1425 } else if (pVBInfo
->LCDResInfo
== Panel_1400x1050
) {
1433 if (pVBInfo
->LCDInfo
& SetLCDtoNonExpanding
) {
1434 pVBInfo
->HDE
= tempax
;
1435 pVBInfo
->VDE
= tempbx
;
1436 pVBInfo
->VGAHDE
= tempax
;
1437 pVBInfo
->VGAVDE
= tempbx
;
1440 tempax
= pVBInfo
->HT
;
1442 tempbx
= LCDPtr1
->LCDHDES
;
1444 tempcx
= pVBInfo
->HDE
;
1445 tempbx
= tempbx
& 0x0fff;
1448 if (tempcx
>= tempax
)
1451 xgifb_reg_set(pVBInfo
->Part1Port
, 0x1A, tempbx
& 0x07);
1453 tempcx
= tempcx
>> 3;
1454 tempbx
= tempbx
>> 3;
1456 xgifb_reg_set(pVBInfo
->Part1Port
, 0x16,
1457 (unsigned short) (tempbx
& 0xff));
1458 xgifb_reg_set(pVBInfo
->Part1Port
, 0x17,
1459 (unsigned short) (tempcx
& 0xff));
1461 tempax
= pVBInfo
->HT
;
1463 tempbx
= LCDPtr1
->LCDHRS
;
1467 if (pVBInfo
->LCDInfo
& EnableScalingLCD
)
1468 tempcx
= LCDPtr1
->LCDHSync
;
1472 if (tempcx
>= tempax
)
1475 tempax
= tempbx
& 0x07;
1476 tempax
= tempax
>> 5;
1477 tempcx
= tempcx
>> 3;
1478 tempbx
= tempbx
>> 3;
1483 xgifb_reg_set(pVBInfo
->Part1Port
, 0x15, tempax
);
1484 xgifb_reg_set(pVBInfo
->Part1Port
, 0x14,
1485 (unsigned short) (tempbx
& 0xff));
1487 tempax
= pVBInfo
->VT
;
1488 tempbx
= LCDPtr1
->LCDVDES
;
1489 tempcx
= pVBInfo
->VDE
;
1491 tempbx
= tempbx
& 0x0fff;
1493 if (tempcx
>= tempax
)
1496 xgifb_reg_set(pVBInfo
->Part1Port
, 0x1b,
1497 (unsigned short) (tempbx
& 0xff));
1498 xgifb_reg_set(pVBInfo
->Part1Port
, 0x1c,
1499 (unsigned short) (tempcx
& 0xff));
1501 tempbx
= (tempbx
>> 8) & 0x07;
1502 tempcx
= (tempcx
>> 8) & 0x07;
1504 xgifb_reg_set(pVBInfo
->Part1Port
, 0x1d,
1505 (unsigned short) ((tempcx
<< 3)
1508 tempax
= pVBInfo
->VT
;
1509 tempbx
= LCDPtr1
->LCDVRS
;
1513 if (pVBInfo
->LCDInfo
& EnableScalingLCD
)
1514 tempcx
= LCDPtr1
->LCDVSync
;
1517 if (tempcx
>= tempax
)
1520 xgifb_reg_set(pVBInfo
->Part1Port
, 0x18,
1521 (unsigned short) (tempbx
& 0xff));
1522 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x19, ~0x0f,
1523 (unsigned short) (tempcx
& 0x0f));
1525 tempax
= ((tempbx
>> 8) & 0x07) << 3;
1527 tempbx
= pVBInfo
->VGAVDE
;
1528 if (tempbx
!= pVBInfo
->VDE
)
1531 if (pVBInfo
->LCDInfo
& XGI_EnableLVDSDDA
)
1534 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x1a, 0x07,
1537 tempbx
= pVBInfo
->VDE
;
1538 tempax
= pVBInfo
->VGAVDE
;
1540 temp
= tempax
; /* 0430 ylshieh */
1541 temp1
= (temp
<< 18) / tempbx
;
1543 tempdx
= (unsigned short) ((temp
<< 18) % tempbx
);
1551 xgifb_reg_set(pVBInfo
->Part1Port
, 0x37,
1552 (unsigned short) (temp2
& 0xff));
1553 xgifb_reg_set(pVBInfo
->Part1Port
, 0x36,
1554 (unsigned short) ((temp2
>> 8) & 0xff));
1556 tempbx
= (unsigned short) (temp2
>> 16);
1557 tempax
= tempbx
& 0x03;
1559 tempbx
= pVBInfo
->VGAVDE
;
1560 if (tempbx
== pVBInfo
->VDE
)
1563 xgifb_reg_set(pVBInfo
->Part1Port
, 0x35, tempax
);
1565 if (pVBInfo
->VBType
& VB_XGI301C
) {
1567 xgifb_reg_set(pVBInfo
->Part4Port
,
1569 (unsigned short) (temp2
& 0xff));
1570 xgifb_reg_set(pVBInfo
->Part4Port
,
1572 (unsigned short) ((temp2
>> 8) &
1574 tempbx
= (unsigned short) (temp2
>> 16);
1575 xgifb_reg_and_or(pVBInfo
->Part4Port
, 0x3a,
1577 (unsigned short) ((tempbx
&
1580 tempcx
= pVBInfo
->VGAVDE
;
1581 if (tempcx
== pVBInfo
->VDE
)
1582 xgifb_reg_and_or(pVBInfo
->Part4Port
,
1585 xgifb_reg_and_or(pVBInfo
->Part4Port
,
1589 tempcx
= pVBInfo
->VGAHDE
;
1590 tempbx
= pVBInfo
->HDE
;
1592 temp1
= tempcx
<< 16;
1594 tempax
= (unsigned short) (temp1
/ tempbx
);
1596 if ((tempbx
& 0xffff) == (tempcx
& 0xffff))
1600 temp1
= pVBInfo
->VGAHDE
<< 16;
1603 temp3
= temp3
<< 16;
1606 temp3
= (temp3
& 0xffff0000) + (temp1
& 0xffff);
1608 tempax
= (unsigned short) (temp3
& 0xff);
1609 xgifb_reg_set(pVBInfo
->Part1Port
, 0x1f, tempax
);
1611 temp1
= pVBInfo
->VGAVDE
<< 18;
1612 temp1
= temp1
/ push3
;
1613 tempbx
= (unsigned short) (temp1
& 0xffff);
1615 if (pVBInfo
->LCDResInfo
== Panel_1024x768
)
1618 tempax
= ((tempbx
>> 8) & 0xff) << 3;
1619 tempax
|= (unsigned short) ((temp3
>> 8) & 0x07);
1620 xgifb_reg_set(pVBInfo
->Part1Port
, 0x20,
1621 (unsigned short) (tempax
& 0xff));
1622 xgifb_reg_set(pVBInfo
->Part1Port
, 0x21,
1623 (unsigned short) (tempbx
& 0xff));
1625 temp3
= temp3
>> 16;
1627 if (modeflag
& HalfDCLK
)
1630 xgifb_reg_set(pVBInfo
->Part1Port
, 0x22,
1631 (unsigned short) ((temp3
>> 8) & 0xff));
1632 xgifb_reg_set(pVBInfo
->Part1Port
, 0x23,
1633 (unsigned short) (temp3
& 0xff));
1636 /* --------------------------------------------------------------------- */
1637 /* Function : XGI_GETLCDVCLKPtr */
1639 /* Output : al -> VCLK Index */
1641 /* --------------------------------------------------------------------- */
1642 static void XGI_GetLCDVCLKPtr(unsigned char *di_0
, unsigned char *di_1
,
1643 struct vb_device_info
*pVBInfo
)
1645 unsigned short index
;
1647 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| XGI_SetCRT2ToLCDA
)) {
1648 index
= XGI_GetLCDCapPtr1(pVBInfo
);
1650 if (pVBInfo
->VBInfo
& SetCRT2ToLCD
) { /* LCDB */
1651 *di_0
= pVBInfo
->LCDCapList
[index
].LCUCHAR_VCLKData1
;
1652 *di_1
= pVBInfo
->LCDCapList
[index
].LCUCHAR_VCLKData2
;
1654 *di_0
= pVBInfo
->LCDCapList
[index
].LCDA_VCLKData1
;
1655 *di_1
= pVBInfo
->LCDCapList
[index
].LCDA_VCLKData2
;
1660 static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex
,
1661 unsigned short ModeIdIndex
, struct vb_device_info
*pVBInfo
)
1664 unsigned short index
, modeflag
;
1665 unsigned char tempal
;
1667 /* si+Ext_ResInfo */
1668 modeflag
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
1670 if ((pVBInfo
->SetFlag
& ProgrammingCRT2
) &&
1671 (!(pVBInfo
->LCDInfo
& EnableScalingLCD
))) { /* {LCDA/LCDB} */
1672 index
= XGI_GetLCDCapPtr(pVBInfo
);
1673 tempal
= pVBInfo
->LCDCapList
[index
].LCD_VCLK
;
1675 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| XGI_SetCRT2ToLCDA
))
1679 if (pVBInfo
->VBType
&
1685 if (pVBInfo
->VBInfo
& SetCRT2ToHiVision
) {
1686 tempal
= TVCLKBASE_315
+ HiTVVCLKDIV2
;
1687 if (!(pVBInfo
->TVInfo
& RPLLDIV2XO
))
1688 tempal
= TVCLKBASE_315
+ HiTVVCLK
;
1689 if (pVBInfo
->TVInfo
& TVSimuMode
) {
1690 tempal
= TVCLKBASE_315
+ HiTVSimuVCLK
;
1691 if (!(modeflag
& Charx8Dot
))
1692 tempal
= TVCLKBASE_315
+
1699 if (pVBInfo
->TVInfo
& TVSetYPbPr750p
) {
1700 tempal
= XGI_YPbPr750pVCLK
;
1704 if (pVBInfo
->TVInfo
& TVSetYPbPr525p
) {
1705 tempal
= YPbPr525pVCLK
;
1709 tempal
= NTSC1024VCLK
;
1711 if (!(pVBInfo
->TVInfo
& NTSC1024x768
)) {
1712 tempal
= TVCLKBASE_315
+ TVVCLKDIV2
;
1713 if (!(pVBInfo
->TVInfo
& RPLLDIV2XO
))
1714 tempal
= TVCLKBASE_315
+ TVVCLK
;
1717 if (pVBInfo
->VBInfo
& SetCRT2ToTV
)
1722 inb((pVBInfo
->P3ca
+ 0x02));
1723 tempal
= XGI330_RefIndex
[RefreshRateTableIndex
].Ext_CRTVCLK
;
1727 static void XGI_GetVCLKLen(unsigned char tempal
, unsigned char *di_0
,
1728 unsigned char *di_1
, struct vb_device_info
*pVBInfo
)
1730 if (pVBInfo
->VBType
& (VB_SIS301
| VB_SIS301B
| VB_SIS302B
1731 | VB_SIS301LV
| VB_SIS302LV
| VB_XGI301C
)) {
1732 if ((!(pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
)) &&
1733 (pVBInfo
->SetFlag
& ProgrammingCRT2
)) {
1734 *di_0
= XGI_VBVCLKData
[tempal
].Part4_A
;
1735 *di_1
= XGI_VBVCLKData
[tempal
].Part4_B
;
1738 *di_0
= XGI_VCLKData
[tempal
].SR2B
;
1739 *di_1
= XGI_VCLKData
[tempal
].SR2C
;
1743 static void XGI_SetCRT2ECLK(unsigned short ModeIdIndex
,
1744 unsigned short RefreshRateTableIndex
,
1745 struct vb_device_info
*pVBInfo
)
1747 unsigned char di_0
, di_1
, tempal
;
1750 tempal
= XGI_GetVCLKPtr(RefreshRateTableIndex
, ModeIdIndex
, pVBInfo
);
1751 XGI_GetVCLKLen(tempal
, &di_0
, &di_1
, pVBInfo
);
1752 XGI_GetLCDVCLKPtr(&di_0
, &di_1
, pVBInfo
);
1754 for (i
= 0; i
< 4; i
++) {
1755 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x31, ~0x30,
1756 (unsigned short) (0x10 * i
));
1757 if ((!(pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
))
1758 && (!(pVBInfo
->VBInfo
& SetInSlaveMode
))) {
1759 xgifb_reg_set(pVBInfo
->P3c4
, 0x2e, di_0
);
1760 xgifb_reg_set(pVBInfo
->P3c4
, 0x2f, di_1
);
1762 xgifb_reg_set(pVBInfo
->P3c4
, 0x2b, di_0
);
1763 xgifb_reg_set(pVBInfo
->P3c4
, 0x2c, di_1
);
1768 static void XGI_UpdateModeInfo(struct vb_device_info
*pVBInfo
)
1770 unsigned short tempcl
, tempch
, temp
, tempbl
, tempax
;
1772 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
1773 | VB_SIS302LV
| VB_XGI301C
)) {
1776 temp
= xgifb_reg_get(pVBInfo
->P3c4
, 0x01);
1778 if (!(temp
& 0x20)) {
1779 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x17);
1781 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x53);
1783 tempcl
|= ActiveCRT1
;
1787 temp
= xgifb_reg_get(pVBInfo
->Part1Port
, 0x2e);
1790 if (!(temp
== 0x08)) {
1791 /* Check ChannelA */
1792 tempax
= xgifb_reg_get(pVBInfo
->Part1Port
, 0x13);
1794 tempcl
= tempcl
| ActiveLCD
;
1798 if (!(tempcl
& ActiveLCD
))
1800 tempcl
|= ActiveCRT2
;
1803 tempcl
|= ActiveLCD
;
1806 temp
= xgifb_reg_get(pVBInfo
->Part2Port
, 0x00);
1809 tempch
|= ActiveAVideo
;
1812 tempch
|= ActiveSVideo
;
1815 tempch
|= ActiveSCART
;
1817 if (pVBInfo
->VBInfo
& SetCRT2ToHiVision
) {
1819 tempch
|= ActiveHiTV
;
1822 if (pVBInfo
->VBInfo
& SetCRT2ToYPbPr525750
) {
1823 temp
= xgifb_reg_get(
1828 tempch
|= ActiveYPbPr
;
1836 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x3d);
1837 if (tempcl
& ActiveLCD
) {
1838 if ((pVBInfo
->SetFlag
& ReserveTVOption
)) {
1839 if (temp
& ActiveTV
)
1844 tempbl
= ~XGI_ModeSwitchStatus
;
1845 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x3d, tempbl
, temp
);
1847 if (!(pVBInfo
->SetFlag
& ReserveTVOption
))
1848 xgifb_reg_set(pVBInfo
->P3d4
, 0x3e, tempch
);
1852 void XGI_GetVBType(struct vb_device_info
*pVBInfo
)
1854 unsigned short flag
, tempbx
, tempah
;
1856 tempbx
= VB_SIS302B
;
1857 flag
= xgifb_reg_get(pVBInfo
->Part4Port
, 0x00);
1862 flag
= xgifb_reg_get(pVBInfo
->Part4Port
, 0x01);
1866 tempbx
= VB_SIS301B
;
1868 goto bigger_than_0xB0
;
1870 tempbx
= VB_XGI301C
;
1872 goto bigger_than_0xB0
;
1874 tempbx
= VB_SIS301LV
;
1876 goto bigger_than_0xB0
;
1878 tempbx
= VB_SIS302LV
;
1879 tempah
= xgifb_reg_get(pVBInfo
->Part4Port
, 0x39);
1881 tempbx
= VB_XGI301C
;
1884 if (tempbx
& (VB_SIS301B
| VB_SIS302B
)) {
1885 flag
= xgifb_reg_get(pVBInfo
->Part4Port
, 0x23);
1887 tempbx
= tempbx
| VB_NoLCD
;
1891 pVBInfo
->VBType
= tempbx
;
1894 static void XGI_GetVBInfo(unsigned short ModeIdIndex
,
1895 struct vb_device_info
*pVBInfo
)
1897 unsigned short tempax
, push
, tempbx
, temp
, modeflag
;
1899 modeflag
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
1900 pVBInfo
->SetFlag
= 0;
1901 pVBInfo
->ModeType
= modeflag
& ModeTypeMask
;
1904 if (!(pVBInfo
->VBType
& 0xFFFF))
1907 /* Check Display Device */
1908 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x30);
1909 tempbx
= tempbx
| temp
;
1910 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x31);
1914 tempbx
= tempbx
| tempax
;
1915 temp
= (SetCRT2ToDualEdge
| SetCRT2ToYPbPr525750
| XGI_SetCRT2ToLCDA
1916 | SetInSlaveMode
| DisableCRT2Display
);
1917 temp
= 0xFFFF ^ temp
;
1920 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x38);
1922 if (pVBInfo
->VBType
& (VB_SIS302B
| VB_SIS301LV
| VB_SIS302LV
|
1924 if (temp
& EnableDualEdge
) {
1925 tempbx
|= SetCRT2ToDualEdge
;
1926 if (temp
& SetToLCDA
)
1927 tempbx
|= XGI_SetCRT2ToLCDA
;
1931 if (pVBInfo
->VBType
& (VB_SIS301LV
|VB_SIS302LV
|VB_XGI301C
)) {
1932 if (temp
& SetYPbPr
) {
1933 /* shampoo add for new scratch */
1934 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x35);
1936 tempbx
|= SetCRT2ToHiVision
;
1938 if (temp
!= YPbPrMode1080i
) {
1939 tempbx
&= (~SetCRT2ToHiVision
);
1940 tempbx
|= SetCRT2ToYPbPr525750
;
1945 tempax
= push
; /* restore CR31 */
1949 if (!(tempbx
& temp
)) {
1950 tempax
|= DisableCRT2Display
;
1954 if (!(pVBInfo
->VBType
& VB_NoLCD
)) {
1955 if (tempbx
& XGI_SetCRT2ToLCDA
) {
1956 if (tempbx
& SetSimuScanMode
)
1957 tempbx
&= (~(SetCRT2ToLCD
| SetCRT2ToRAMDAC
|
1960 tempbx
&= (~(SetCRT2ToLCD
| SetCRT2ToRAMDAC
|
1961 SetCRT2ToTV
| SwitchCRT2
));
1966 /* for driver abnormal */
1967 if (!(tempbx
& (SwitchCRT2
| SetSimuScanMode
))) {
1968 if (tempbx
& SetCRT2ToRAMDAC
) {
1969 tempbx
&= (0xFF00 | SetCRT2ToRAMDAC
|
1970 SwitchCRT2
| SetSimuScanMode
);
1971 tempbx
&= (0x00FF | (~SetCRT2ToYPbPr525750
));
1975 if (!(pVBInfo
->VBType
& VB_NoLCD
)) {
1976 if (tempbx
& SetCRT2ToLCD
) {
1977 tempbx
&= (0xFF00 | SetCRT2ToLCD
| SwitchCRT2
|
1979 tempbx
&= (0x00FF | (~SetCRT2ToYPbPr525750
));
1983 if (tempbx
& SetCRT2ToSCART
) {
1984 tempbx
&= (0xFF00 | SetCRT2ToSCART
| SwitchCRT2
|
1986 tempbx
&= (0x00FF | (~SetCRT2ToYPbPr525750
));
1989 if (tempbx
& SetCRT2ToYPbPr525750
)
1990 tempbx
&= (0xFF00 | SwitchCRT2
| SetSimuScanMode
);
1992 if (tempbx
& SetCRT2ToHiVision
)
1993 tempbx
&= (0xFF00 | SetCRT2ToHiVision
| SwitchCRT2
|
1996 if (tempax
& DisableCRT2Display
) { /* Set Display Device Info */
1997 if (!(tempbx
& (SwitchCRT2
| SetSimuScanMode
)))
1998 tempbx
= DisableCRT2Display
;
2001 if (!(tempbx
& DisableCRT2Display
)) {
2002 if ((!(tempbx
& DriverMode
)) || (!(modeflag
& CRT2Mode
))) {
2003 if (!(tempbx
& XGI_SetCRT2ToLCDA
))
2004 tempbx
|= (SetInSlaveMode
| SetSimuScanMode
);
2007 /* LCD+TV can't support in slave mode
2008 * (Force LCDA+TV->LCDB) */
2009 if ((tempbx
& SetInSlaveMode
) && (tempbx
& XGI_SetCRT2ToLCDA
)) {
2010 tempbx
^= (SetCRT2ToLCD
| XGI_SetCRT2ToLCDA
|
2012 pVBInfo
->SetFlag
|= ReserveTVOption
;
2016 pVBInfo
->VBInfo
= tempbx
;
2019 static void XGI_GetTVInfo(unsigned short ModeIdIndex
,
2020 struct vb_device_info
*pVBInfo
)
2022 unsigned short tempbx
= 0, resinfo
= 0, modeflag
, index1
;
2024 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
2025 modeflag
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
2026 resinfo
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
2028 tempbx
= xgifb_reg_get(pVBInfo
->P3d4
, 0x35);
2029 if (tempbx
& TVSetPAL
) {
2030 tempbx
&= (SetCHTVOverScan
|
2034 if (tempbx
& TVSetPALM
)
2035 /* set to NTSC if PAL-M */
2036 tempbx
&= ~TVSetPAL
;
2038 tempbx
&= (SetCHTVOverScan
|
2042 if (pVBInfo
->VBInfo
& SetCRT2ToSCART
)
2045 if (pVBInfo
->VBInfo
& SetCRT2ToYPbPr525750
) {
2046 index1
= xgifb_reg_get(pVBInfo
->P3d4
, 0x35);
2047 index1
&= YPbPrMode
;
2049 if (index1
== YPbPrMode525i
)
2050 tempbx
|= TVSetYPbPr525i
;
2052 if (index1
== YPbPrMode525p
)
2053 tempbx
= tempbx
| TVSetYPbPr525p
;
2054 if (index1
== YPbPrMode750p
)
2055 tempbx
= tempbx
| TVSetYPbPr750p
;
2058 if (pVBInfo
->VBInfo
& SetCRT2ToHiVision
)
2059 tempbx
= tempbx
| TVSetHiVision
| TVSetPAL
;
2061 if ((pVBInfo
->VBInfo
& SetInSlaveMode
) &&
2062 (!(pVBInfo
->VBInfo
& SetNotSimuMode
)))
2063 tempbx
|= TVSimuMode
;
2065 if (!(tempbx
& TVSetPAL
) && (modeflag
> 13) && (resinfo
== 8))
2066 /* NTSC 1024x768, */
2067 tempbx
|= NTSC1024x768
;
2069 tempbx
|= RPLLDIV2XO
;
2071 if (pVBInfo
->VBInfo
& SetCRT2ToHiVision
) {
2072 if (pVBInfo
->VBInfo
& SetInSlaveMode
)
2073 tempbx
&= (~RPLLDIV2XO
);
2074 } else if (tempbx
& (TVSetYPbPr525p
| TVSetYPbPr750p
)) {
2075 tempbx
&= (~RPLLDIV2XO
);
2076 } else if (!(pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
|
2077 VB_SIS301LV
| VB_SIS302LV
|
2079 if (tempbx
& TVSimuMode
)
2080 tempbx
&= (~RPLLDIV2XO
);
2083 pVBInfo
->TVInfo
= tempbx
;
2086 static unsigned char XGI_GetLCDInfo(unsigned short ModeIdIndex
,
2087 struct vb_device_info
*pVBInfo
)
2089 unsigned short temp
, tempax
, tempbx
, resinfo
= 0, LCDIdIndex
;
2091 pVBInfo
->LCDResInfo
= 0;
2092 pVBInfo
->LCDTypeInfo
= 0;
2093 pVBInfo
->LCDInfo
= 0;
2095 /* si+Ext_ResInfo // */
2096 resinfo
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
2097 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x36); /* Get LCD Res.Info */
2098 tempbx
= temp
& 0x0F;
2101 tempbx
= Panel_1024x768
; /* default */
2104 if ((tempbx
== Panel_1024x768
) || (tempbx
== Panel_1280x1024
)) {
2105 if (pVBInfo
->VBInfo
& DriverMode
) {
2106 tempax
= xgifb_reg_get(pVBInfo
->P3d4
, 0x33);
2107 if (pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
)
2110 tempax
= tempax
>> 4;
2112 if ((resinfo
== 6) || (resinfo
== 9)) {
2114 tempbx
|= PanelRef75Hz
;
2115 } else if ((resinfo
== 7) || (resinfo
== 8)) {
2117 tempbx
|= PanelRef75Hz
;
2122 pVBInfo
->LCDResInfo
= tempbx
;
2126 if (!(pVBInfo
->VBInfo
& (SetCRT2ToLCD
| XGI_SetCRT2ToLCDA
)))
2131 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x37);
2133 temp
&= (ScalingLCD
| LCDNonExpanding
| LCDSyncBit
| SetPWDEnable
);
2137 LCDIdIndex
= XGI_GetLCDCapPtr1(pVBInfo
);
2139 tempax
= pVBInfo
->LCDCapList
[LCDIdIndex
].LCD_Capability
;
2141 if (((pVBInfo
->VBType
& VB_SIS302LV
) ||
2142 (pVBInfo
->VBType
& VB_XGI301C
)) && (tempax
& XGI_LCDDualLink
))
2143 tempbx
|= SetLCDDualLink
;
2145 if ((pVBInfo
->LCDResInfo
== Panel_1400x1050
) &&
2146 (pVBInfo
->VBInfo
& SetCRT2ToLCD
) && (resinfo
== 9) &&
2147 (!(tempbx
& EnableScalingLCD
)))
2149 * set to center in 1280x1024 LCDB
2150 * for Panel_1400x1050
2152 tempbx
|= SetLCDtoNonExpanding
;
2154 if (pVBInfo
->VBInfo
& SetInSlaveMode
) {
2155 if (pVBInfo
->VBInfo
& SetNotSimuMode
)
2156 tempbx
|= XGI_LCDVESATiming
;
2158 tempbx
|= XGI_LCDVESATiming
;
2161 pVBInfo
->LCDInfo
= tempbx
;
2166 unsigned char XGI_SearchModeID(unsigned short ModeNo
,
2167 unsigned short *ModeIdIndex
)
2169 for (*ModeIdIndex
= 0;; (*ModeIdIndex
)++) {
2170 if (XGI330_EModeIDTable
[*ModeIdIndex
].Ext_ModeID
== ModeNo
)
2172 if (XGI330_EModeIDTable
[*ModeIdIndex
].Ext_ModeID
== 0xFF)
2179 static unsigned char XG21GPIODataTransfer(unsigned char ujDate
)
2181 unsigned char ujRet
= 0;
2182 unsigned char i
= 0;
2184 for (i
= 0; i
< 8; i
++) {
2186 ujRet
|= (ujDate
>> i
) & 1;
2192 /*----------------------------------------------------------------------------*/
2194 /* bl[5] : LVDS signal */
2195 /* bl[1] : LVDS backlight */
2196 /* bl[0] : LVDS VDD */
2197 /*----------------------------------------------------------------------------*/
2198 static unsigned char XGI_XG21GetPSCValue(struct vb_device_info
*pVBInfo
)
2200 unsigned char CR4A
, temp
;
2202 CR4A
= xgifb_reg_get(pVBInfo
->P3d4
, 0x4A);
2203 xgifb_reg_and(pVBInfo
->P3d4
, 0x4A, ~0x23); /* enable GPIO write */
2205 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x48);
2207 temp
= XG21GPIODataTransfer(temp
);
2209 xgifb_reg_set(pVBInfo
->P3d4
, 0x4A, CR4A
);
2213 /*----------------------------------------------------------------------------*/
2215 /* bl[5] : LVDS signal */
2216 /* bl[1] : LVDS backlight */
2217 /* bl[0] : LVDS VDD */
2218 /*----------------------------------------------------------------------------*/
2219 static unsigned char XGI_XG27GetPSCValue(struct vb_device_info
*pVBInfo
)
2221 unsigned char CR4A
, CRB4
, temp
;
2223 CR4A
= xgifb_reg_get(pVBInfo
->P3d4
, 0x4A);
2224 xgifb_reg_and(pVBInfo
->P3d4
, 0x4A, ~0x0C); /* enable GPIO write */
2226 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x48);
2230 xgifb_reg_set(pVBInfo
->P3d4
, 0x4A, CR4A
);
2231 CRB4
= xgifb_reg_get(pVBInfo
->P3d4
, 0xB4);
2232 temp
|= ((CRB4
& 0x04) << 3);
2236 /*----------------------------------------------------------------------------*/
2238 /* bl[5] : 1;LVDS signal on */
2239 /* bl[1] : 1;LVDS backlight on */
2240 /* bl[0] : 1:LVDS VDD on */
2241 /* bh: 100000b : clear bit 5, to set bit5 */
2242 /* 000010b : clear bit 1, to set bit1 */
2243 /* 000001b : clear bit 0, to set bit0 */
2244 /*----------------------------------------------------------------------------*/
2245 static void XGI_XG21BLSignalVDD(unsigned short tempbh
, unsigned short tempbl
,
2246 struct vb_device_info
*pVBInfo
)
2248 unsigned char CR4A
, temp
;
2250 CR4A
= xgifb_reg_get(pVBInfo
->P3d4
, 0x4A);
2253 xgifb_reg_and(pVBInfo
->P3d4
, 0x4A, ~tempbh
); /* enable GPIO write */
2255 if (tempbh
& 0x20) {
2256 temp
= (tempbl
>> 4) & 0x02;
2259 xgifb_reg_and_or(pVBInfo
->P3d4
, 0xB4, ~0x02, temp
);
2263 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x48);
2265 temp
= XG21GPIODataTransfer(temp
);
2268 xgifb_reg_set(pVBInfo
->P3d4
, 0x48, temp
);
2271 static void XGI_XG27BLSignalVDD(unsigned short tempbh
, unsigned short tempbl
,
2272 struct vb_device_info
*pVBInfo
)
2274 unsigned char CR4A
, temp
;
2275 unsigned short tempbh0
, tempbl0
;
2284 if (tempbh
& 0x20) {
2285 temp
= (tempbl
>> 4) & 0x02;
2288 xgifb_reg_and_or(pVBInfo
->P3d4
, 0xB4, ~0x02, temp
);
2291 xgifb_reg_and_or(pVBInfo
->P3d4
, 0xB4, ~tempbh0
, tempbl0
);
2293 CR4A
= xgifb_reg_get(pVBInfo
->P3d4
, 0x4A);
2297 tempbl
<<= 2; /* GPIOC,GPIOD */
2298 xgifb_reg_and(pVBInfo
->P3d4
, 0x4A, ~tempbh
); /* enable GPIO write */
2299 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x48, ~tempbh
, tempbl
);
2302 static void XGI_DisplayOn(struct xgifb_video_info
*xgifb_info
,
2303 struct xgi_hw_device_info
*pXGIHWDE
,
2304 struct vb_device_info
*pVBInfo
)
2307 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x01, 0xDF, 0x00);
2308 if (pXGIHWDE
->jChipType
== XG21
) {
2309 if (pVBInfo
->IF_DEF_LVDS
== 1) {
2310 if (!(XGI_XG21GetPSCValue(pVBInfo
) & 0x1)) {
2312 XGI_XG21BLSignalVDD(0x01, 0x01, pVBInfo
);
2313 mdelay(xgifb_info
->lvds_data
.PSC_S2
);
2315 if (!(XGI_XG21GetPSCValue(pVBInfo
) & 0x20))
2316 /* LVDS signal on */
2317 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo
);
2318 mdelay(xgifb_info
->lvds_data
.PSC_S3
);
2319 /* LVDS backlight on */
2320 XGI_XG21BLSignalVDD(0x02, 0x02, pVBInfo
);
2322 /* DVO/DVI signal on */
2323 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo
);
2328 if (pXGIHWDE
->jChipType
== XG27
) {
2329 if (pVBInfo
->IF_DEF_LVDS
== 1) {
2330 if (!(XGI_XG27GetPSCValue(pVBInfo
) & 0x1)) {
2332 XGI_XG27BLSignalVDD(0x01, 0x01, pVBInfo
);
2333 mdelay(xgifb_info
->lvds_data
.PSC_S2
);
2335 if (!(XGI_XG27GetPSCValue(pVBInfo
) & 0x20))
2336 /* LVDS signal on */
2337 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo
);
2338 mdelay(xgifb_info
->lvds_data
.PSC_S3
);
2339 /* LVDS backlight on */
2340 XGI_XG27BLSignalVDD(0x02, 0x02, pVBInfo
);
2342 /* DVO/DVI signal on */
2343 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo
);
2349 void XGI_DisplayOff(struct xgifb_video_info
*xgifb_info
,
2350 struct xgi_hw_device_info
*pXGIHWDE
,
2351 struct vb_device_info
*pVBInfo
)
2354 if (pXGIHWDE
->jChipType
== XG21
) {
2355 if (pVBInfo
->IF_DEF_LVDS
== 1) {
2356 /* LVDS backlight off */
2357 XGI_XG21BLSignalVDD(0x02, 0x00, pVBInfo
);
2358 mdelay(xgifb_info
->lvds_data
.PSC_S3
);
2360 /* DVO/DVI signal off */
2361 XGI_XG21BLSignalVDD(0x20, 0x00, pVBInfo
);
2365 if (pXGIHWDE
->jChipType
== XG27
) {
2366 if ((XGI_XG27GetPSCValue(pVBInfo
) & 0x2)) {
2367 /* LVDS backlight off */
2368 XGI_XG27BLSignalVDD(0x02, 0x00, pVBInfo
);
2369 mdelay(xgifb_info
->lvds_data
.PSC_S3
);
2372 if (pVBInfo
->IF_DEF_LVDS
== 0)
2373 /* DVO/DVI signal off */
2374 XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo
);
2377 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x01, 0xDF, 0x20);
2380 static void XGI_WaitDisply(struct vb_device_info
*pVBInfo
)
2382 while ((inb(pVBInfo
->P3da
) & 0x01))
2385 while (!(inb(pVBInfo
->P3da
) & 0x01))
2389 static void XGI_AutoThreshold(struct vb_device_info
*pVBInfo
)
2391 xgifb_reg_or(pVBInfo
->Part1Port
, 0x01, 0x40);
2394 static void XGI_SaveCRT2Info(unsigned short ModeNo
,
2395 struct vb_device_info
*pVBInfo
)
2397 unsigned short temp1
, temp2
;
2399 /* reserve CR34 for CRT1 Mode No */
2400 xgifb_reg_set(pVBInfo
->P3d4
, 0x34, ModeNo
);
2401 temp1
= (pVBInfo
->VBInfo
& SetInSlaveMode
) >> 8;
2402 temp2
= ~(SetInSlaveMode
>> 8);
2403 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x31, temp2
, temp1
);
2406 static void XGI_GetCRT2ResInfo(unsigned short ModeIdIndex
,
2407 struct vb_device_info
*pVBInfo
)
2409 unsigned short xres
, yres
, modeflag
, resindex
;
2411 resindex
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
2412 xres
= XGI330_ModeResInfo
[resindex
].HTotal
; /* xres->ax */
2413 yres
= XGI330_ModeResInfo
[resindex
].VTotal
; /* yres->bx */
2414 /* si+St_ModeFlag */
2415 modeflag
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
2417 if (modeflag
& HalfDCLK
)
2420 if (modeflag
& DoubleScanMode
)
2423 if (!(pVBInfo
->VBInfo
& SetCRT2ToLCD
))
2426 if (pVBInfo
->LCDResInfo
== Panel_1600x1200
) {
2427 if (!(pVBInfo
->LCDInfo
& XGI_LCDVESATiming
)) {
2433 if (pVBInfo
->LCDResInfo
== Panel_1280x1024
) {
2436 else if (yres
== 350)
2439 if (pVBInfo
->LCDInfo
& XGI_LCDVESATiming
) {
2445 if (pVBInfo
->LCDResInfo
== Panel_1024x768
) {
2446 if (!(pVBInfo
->LCDInfo
& XGI_LCDVESATiming
)) {
2447 if (!(pVBInfo
->LCDInfo
& LCDNonExpanding
)) {
2450 else if (yres
== 400)
2452 else if (yres
== 480)
2462 pVBInfo
->VGAHDE
= xres
;
2463 pVBInfo
->HDE
= xres
;
2464 pVBInfo
->VGAVDE
= yres
;
2465 pVBInfo
->VDE
= yres
;
2468 static unsigned char XGI_IsLCDDualLink(struct vb_device_info
*pVBInfo
)
2471 if ((pVBInfo
->VBInfo
& (SetCRT2ToLCD
| XGI_SetCRT2ToLCDA
)) &&
2472 (pVBInfo
->LCDInfo
& SetLCDDualLink
)) /* shampoo0129 */
2478 static void XGI_GetRAMDAC2DATA(unsigned short ModeIdIndex
,
2479 unsigned short RefreshRateTableIndex
,
2480 struct vb_device_info
*pVBInfo
)
2482 unsigned short tempax
, tempbx
, temp1
, temp2
, modeflag
= 0, tempcx
,
2485 pVBInfo
->RVBHCMAX
= 1;
2486 pVBInfo
->RVBHCFACT
= 1;
2487 modeflag
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
2488 CRT1Index
= XGI330_RefIndex
[RefreshRateTableIndex
].Ext_CRT1CRTC
;
2489 CRT1Index
&= IndexMask
;
2490 temp1
= (unsigned short) XGI_CRT1Table
[CRT1Index
].CR
[0];
2491 temp2
= (unsigned short) XGI_CRT1Table
[CRT1Index
].CR
[5];
2492 tempax
= (temp1
& 0xFF) | ((temp2
& 0x03) << 8);
2493 tempbx
= (unsigned short) XGI_CRT1Table
[CRT1Index
].CR
[8];
2494 tempcx
= (unsigned short)
2495 XGI_CRT1Table
[CRT1Index
].CR
[14] << 8;
2497 tempcx
= tempcx
<< 2;
2499 temp1
= (unsigned short) XGI_CRT1Table
[CRT1Index
].CR
[9];
2508 if (modeflag
& Charx8Dot
)
2513 pVBInfo
->VGAHT
= tempax
;
2514 pVBInfo
->HT
= tempax
;
2516 pVBInfo
->VGAVT
= tempbx
;
2517 pVBInfo
->VT
= tempbx
;
2520 static void XGI_GetCRT2Data(unsigned short ModeIdIndex
,
2521 unsigned short RefreshRateTableIndex
,
2522 struct vb_device_info
*pVBInfo
)
2524 unsigned short tempax
= 0, tempbx
= 0, modeflag
, resinfo
;
2526 struct SiS_LCDData
const *LCDPtr
= NULL
;
2528 /* si+Ext_ResInfo */
2529 modeflag
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
2530 resinfo
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
2531 pVBInfo
->NewFlickerMode
= 0;
2532 pVBInfo
->RVBHRS
= 50;
2534 if (pVBInfo
->VBInfo
& SetCRT2ToRAMDAC
) {
2535 XGI_GetRAMDAC2DATA(ModeIdIndex
, RefreshRateTableIndex
, pVBInfo
);
2539 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| XGI_SetCRT2ToLCDA
)) {
2540 LCDPtr
= XGI_GetLcdPtr(XGI_LCDDataTable
, ModeIdIndex
,
2543 pVBInfo
->RVBHCMAX
= LCDPtr
->RVBHCMAX
;
2544 pVBInfo
->RVBHCFACT
= LCDPtr
->RVBHCFACT
;
2545 pVBInfo
->VGAHT
= LCDPtr
->VGAHT
;
2546 pVBInfo
->VGAVT
= LCDPtr
->VGAVT
;
2547 pVBInfo
->HT
= LCDPtr
->LCDHT
;
2548 pVBInfo
->VT
= LCDPtr
->LCDVT
;
2550 if (pVBInfo
->LCDResInfo
== Panel_1024x768
) {
2554 if (!(pVBInfo
->LCDInfo
& XGI_LCDVESATiming
)) {
2555 if (pVBInfo
->VGAVDE
== 357)
2557 else if (pVBInfo
->VGAVDE
== 420)
2559 else if (pVBInfo
->VGAVDE
== 525)
2561 else if (pVBInfo
->VGAVDE
== 600)
2564 } else if (pVBInfo
->LCDResInfo
== Panel_1024x768x75
) {
2567 } else if (pVBInfo
->LCDResInfo
== Panel_1280x1024
) {
2569 if (pVBInfo
->VGAVDE
== 360)
2571 else if (pVBInfo
->VGAVDE
== 375)
2573 else if (pVBInfo
->VGAVDE
== 405)
2577 } else if (pVBInfo
->LCDResInfo
== Panel_1280x1024x75
) {
2580 } else if (pVBInfo
->LCDResInfo
== Panel_1280x960
) {
2582 if (pVBInfo
->VGAVDE
== 350)
2584 else if (pVBInfo
->VGAVDE
== 400)
2586 else if (pVBInfo
->VGAVDE
== 1024)
2590 } else if (pVBInfo
->LCDResInfo
== Panel_1400x1050
) {
2594 if (pVBInfo
->VGAVDE
== 1024) {
2598 } else if (pVBInfo
->LCDResInfo
== Panel_1600x1200
) {
2600 tempbx
= 1200; /* alan 10/14/2003 */
2601 if (!(pVBInfo
->LCDInfo
& XGI_LCDVESATiming
)) {
2602 if (pVBInfo
->VGAVDE
== 350)
2604 else if (pVBInfo
->VGAVDE
== 400)
2609 if (pVBInfo
->LCDInfo
& LCDNonExpanding
) {
2610 tempax
= pVBInfo
->VGAHDE
;
2611 tempbx
= pVBInfo
->VGAVDE
;
2614 pVBInfo
->HDE
= tempax
;
2615 pVBInfo
->VDE
= tempbx
;
2619 if (pVBInfo
->VBInfo
& (SetCRT2ToTV
)) {
2620 struct SiS_TVData
const *TVPtr
;
2622 TVPtr
= XGI_GetTVPtr(ModeIdIndex
, RefreshRateTableIndex
,
2625 pVBInfo
->RVBHCMAX
= TVPtr
->RVBHCMAX
;
2626 pVBInfo
->RVBHCFACT
= TVPtr
->RVBHCFACT
;
2627 pVBInfo
->VGAHT
= TVPtr
->VGAHT
;
2628 pVBInfo
->VGAVT
= TVPtr
->VGAVT
;
2629 pVBInfo
->HDE
= TVPtr
->TVHDE
;
2630 pVBInfo
->VDE
= TVPtr
->TVVDE
;
2631 pVBInfo
->RVBHRS
= TVPtr
->RVBHRS
;
2632 pVBInfo
->NewFlickerMode
= TVPtr
->FlickerMode
;
2634 if (pVBInfo
->VBInfo
& SetCRT2ToHiVision
) {
2635 if (resinfo
== 0x08)
2636 pVBInfo
->NewFlickerMode
= 0x40;
2637 else if (resinfo
== 0x09)
2638 pVBInfo
->NewFlickerMode
= 0x40;
2639 else if (resinfo
== 0x12)
2640 pVBInfo
->NewFlickerMode
= 0x40;
2642 if (pVBInfo
->VGAVDE
== 350)
2643 pVBInfo
->TVInfo
|= TVSimuMode
;
2648 if (pVBInfo
->VBInfo
& SetInSlaveMode
) {
2649 if (pVBInfo
->TVInfo
& TVSimuMode
) {
2653 if (!(modeflag
& Charx8Dot
)) {
2654 tempax
= StHiTextTVHT
;
2655 tempbx
= StHiTextTVVT
;
2659 } else if (pVBInfo
->VBInfo
& SetCRT2ToYPbPr525750
) {
2660 if (pVBInfo
->TVInfo
& TVSetYPbPr750p
) {
2661 tempax
= YPbPrTV750pHT
; /* Ext750pTVHT */
2662 tempbx
= YPbPrTV750pVT
; /* Ext750pTVVT */
2665 if (pVBInfo
->TVInfo
& TVSetYPbPr525p
) {
2666 tempax
= YPbPrTV525pHT
; /* Ext525pTVHT */
2667 tempbx
= YPbPrTV525pVT
; /* Ext525pTVVT */
2668 } else if (pVBInfo
->TVInfo
& TVSetYPbPr525i
) {
2669 tempax
= YPbPrTV525iHT
; /* Ext525iTVHT */
2670 tempbx
= YPbPrTV525iVT
; /* Ext525iTVVT */
2671 if (pVBInfo
->TVInfo
& NTSC1024x768
)
2672 tempax
= NTSC1024x768HT
;
2677 if (!(pVBInfo
->TVInfo
& TVSetPAL
)) {
2680 if (pVBInfo
->TVInfo
& NTSC1024x768
)
2681 tempax
= NTSC1024x768HT
;
2685 pVBInfo
->HT
= tempax
;
2686 pVBInfo
->VT
= tempbx
;
2690 static void XGI_SetCRT2VCLK(unsigned short ModeIdIndex
,
2691 unsigned short RefreshRateTableIndex
,
2692 struct vb_device_info
*pVBInfo
)
2694 unsigned char di_0
, di_1
, tempal
;
2696 tempal
= XGI_GetVCLKPtr(RefreshRateTableIndex
, ModeIdIndex
, pVBInfo
);
2697 XGI_GetVCLKLen(tempal
, &di_0
, &di_1
, pVBInfo
);
2698 XGI_GetLCDVCLKPtr(&di_0
, &di_1
, pVBInfo
);
2700 if (pVBInfo
->VBType
& VB_SIS301
) { /* shampoo 0129 */
2702 xgifb_reg_set(pVBInfo
->Part4Port
, 0x0A, 0x10);
2703 xgifb_reg_set(pVBInfo
->Part4Port
, 0x0B, di_1
);
2704 xgifb_reg_set(pVBInfo
->Part4Port
, 0x0A, di_0
);
2705 } else { /* 301b/302b/301lv/302lv */
2706 xgifb_reg_set(pVBInfo
->Part4Port
, 0x0A, di_0
);
2707 xgifb_reg_set(pVBInfo
->Part4Port
, 0x0B, di_1
);
2710 xgifb_reg_set(pVBInfo
->Part4Port
, 0x00, 0x12);
2712 if (pVBInfo
->VBInfo
& SetCRT2ToRAMDAC
)
2713 xgifb_reg_or(pVBInfo
->Part4Port
, 0x12, 0x28);
2715 xgifb_reg_or(pVBInfo
->Part4Port
, 0x12, 0x08);
2718 static unsigned short XGI_GetColorDepth(unsigned short ModeIdIndex
)
2720 unsigned short ColorDepth
[6] = { 1, 2, 4, 4, 6, 8 };
2722 unsigned short modeflag
;
2724 modeflag
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
2725 index
= (modeflag
& ModeTypeMask
) - ModeEGA
;
2730 return ColorDepth
[index
];
2733 static unsigned short XGI_GetOffset(unsigned short ModeNo
,
2734 unsigned short ModeIdIndex
,
2735 unsigned short RefreshRateTableIndex
)
2737 unsigned short temp
, colordepth
, modeinfo
, index
, infoflag
,
2738 ColorDepth
[] = { 0x01, 0x02, 0x04 };
2740 modeinfo
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_ModeInfo
;
2741 infoflag
= XGI330_RefIndex
[RefreshRateTableIndex
].Ext_InfoFlag
;
2743 index
= (modeinfo
>> 8) & 0xFF;
2745 temp
= XGI330_ScreenOffset
[index
];
2747 if (infoflag
& InterlaceMode
)
2750 colordepth
= XGI_GetColorDepth(ModeIdIndex
);
2752 if ((ModeNo
>= 0x7C) && (ModeNo
<= 0x7E)) {
2753 temp
= ModeNo
- 0x7C;
2754 colordepth
= ColorDepth
[temp
];
2756 if (infoflag
& InterlaceMode
)
2759 return temp
* colordepth
;
2762 static void XGI_SetCRT2Offset(unsigned short ModeNo
,
2763 unsigned short ModeIdIndex
,
2764 unsigned short RefreshRateTableIndex
,
2765 struct vb_device_info
*pVBInfo
)
2767 unsigned short offset
;
2770 if (pVBInfo
->VBInfo
& SetInSlaveMode
)
2773 offset
= XGI_GetOffset(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
);
2774 temp
= (unsigned char) (offset
& 0xFF);
2775 xgifb_reg_set(pVBInfo
->Part1Port
, 0x07, temp
);
2776 temp
= (unsigned char) ((offset
& 0xFF00) >> 8);
2777 xgifb_reg_set(pVBInfo
->Part1Port
, 0x09, temp
);
2778 temp
= (unsigned char) (((offset
>> 3) & 0xFF) + 1);
2779 xgifb_reg_set(pVBInfo
->Part1Port
, 0x03, temp
);
2782 static void XGI_SetCRT2FIFO(struct vb_device_info
*pVBInfo
)
2784 /* threshold high ,disable auto threshold */
2785 xgifb_reg_set(pVBInfo
->Part1Port
, 0x01, 0x3B);
2786 /* threshold low default 04h */
2787 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x02, ~(0x3F), 0x04);
2790 static void XGI_PreSetGroup1(unsigned short ModeNo
, unsigned short ModeIdIndex
,
2791 unsigned short RefreshRateTableIndex
,
2792 struct vb_device_info
*pVBInfo
)
2796 XGI_SetCRT2Offset(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
, pVBInfo
);
2797 XGI_SetCRT2FIFO(pVBInfo
);
2799 for (tempcx
= 4; tempcx
< 7; tempcx
++)
2800 xgifb_reg_set(pVBInfo
->Part1Port
, tempcx
, 0x0);
2802 xgifb_reg_set(pVBInfo
->Part1Port
, 0x50, 0x00);
2803 xgifb_reg_set(pVBInfo
->Part1Port
, 0x02, 0x44); /* temp 0206 */
2806 static void XGI_SetGroup1(unsigned short ModeIdIndex
,
2807 unsigned short RefreshRateTableIndex
,
2808 struct vb_device_info
*pVBInfo
)
2810 unsigned short temp
= 0, tempax
= 0, tempbx
= 0, tempcx
= 0,
2811 pushbx
= 0, CRT1Index
, modeflag
;
2813 CRT1Index
= XGI330_RefIndex
[RefreshRateTableIndex
].Ext_CRT1CRTC
;
2814 CRT1Index
&= IndexMask
;
2815 modeflag
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
2817 /* bainy change table name */
2818 if (modeflag
& HalfDCLK
) {
2819 /* BTVGA2HT 0x08,0x09 */
2820 temp
= (pVBInfo
->VGAHT
/ 2 - 1) & 0x0FF;
2821 xgifb_reg_set(pVBInfo
->Part1Port
, 0x08, temp
);
2822 temp
= (((pVBInfo
->VGAHT
/ 2 - 1) & 0xFF00) >> 8) << 4;
2823 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x09, ~0x0F0, temp
);
2824 /* BTVGA2HDEE 0x0A,0x0C */
2825 temp
= (pVBInfo
->VGAHDE
/ 2 + 16) & 0x0FF;
2826 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0A, temp
);
2827 tempcx
= ((pVBInfo
->VGAHT
- pVBInfo
->VGAHDE
) / 2) >> 2;
2828 pushbx
= pVBInfo
->VGAHDE
/ 2 + 16;
2829 tempcx
= tempcx
>> 1;
2830 tempbx
= pushbx
+ tempcx
; /* bx BTVGA@HRS 0x0B,0x0C */
2833 if (pVBInfo
->VBInfo
& SetCRT2ToRAMDAC
) {
2834 tempbx
= XGI_CRT1Table
[CRT1Index
].CR
[4];
2835 tempbx
|= ((XGI_CRT1Table
[CRT1Index
].CR
[14] &
2837 tempbx
= (tempbx
- 3) << 3; /* (VGAHRS-3)*8 */
2838 tempcx
= XGI_CRT1Table
[CRT1Index
].CR
[5];
2840 temp
= XGI_CRT1Table
[CRT1Index
].CR
[15];
2841 temp
= (temp
& 0x04) << (5 - 2); /* VGAHRE D[5] */
2842 tempcx
= ((tempcx
| temp
) - 3) << 3; /* (VGAHRE-3)*8 */
2848 if (tempcx
> (pVBInfo
->VGAHT
/ 2))
2849 tempcx
= pVBInfo
->VGAHT
/ 2;
2851 temp
= tempbx
& 0x00FF;
2853 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0B, temp
);
2855 temp
= (pVBInfo
->VGAHT
- 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */
2856 xgifb_reg_set(pVBInfo
->Part1Port
, 0x08, temp
);
2857 temp
= (((pVBInfo
->VGAHT
- 1) & 0xFF00) >> 8) << 4;
2858 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x09, ~0x0F0, temp
);
2859 /* BTVGA2HDEE 0x0A,0x0C */
2860 temp
= (pVBInfo
->VGAHDE
+ 16) & 0x0FF;
2861 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0A, temp
);
2862 tempcx
= (pVBInfo
->VGAHT
- pVBInfo
->VGAHDE
) >> 2; /* cx */
2863 pushbx
= pVBInfo
->VGAHDE
+ 16;
2864 tempcx
= tempcx
>> 1;
2865 tempbx
= pushbx
+ tempcx
; /* bx BTVGA@HRS 0x0B,0x0C */
2868 if (pVBInfo
->VBInfo
& SetCRT2ToRAMDAC
) {
2869 tempbx
= XGI_CRT1Table
[CRT1Index
].CR
[3];
2870 tempbx
|= ((XGI_CRT1Table
[CRT1Index
].CR
[5] &
2872 tempbx
= (tempbx
- 3) << 3; /* (VGAHRS-3)*8 */
2873 tempcx
= XGI_CRT1Table
[CRT1Index
].CR
[4];
2875 temp
= XGI_CRT1Table
[CRT1Index
].CR
[6];
2876 temp
= (temp
& 0x04) << (5 - 2); /* VGAHRE D[5] */
2877 tempcx
= ((tempcx
| temp
) - 3) << 3; /* (VGAHRE-3)*8 */
2882 if (tempcx
> pVBInfo
->VGAHT
)
2883 tempcx
= pVBInfo
->VGAHT
;
2885 temp
= tempbx
& 0x00FF;
2886 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0B, temp
);
2889 tempax
= (tempax
& 0x00FF) | (tempbx
& 0xFF00);
2891 tempbx
= (tempbx
& 0x00FF) | ((tempbx
& 0xFF00) << 4);
2892 tempax
|= (tempbx
& 0xFF00);
2893 temp
= (tempax
& 0xFF00) >> 8;
2894 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0C, temp
);
2895 temp
= tempcx
& 0x00FF;
2896 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0D, temp
);
2897 tempcx
= (pVBInfo
->VGAVT
- 1);
2898 temp
= tempcx
& 0x00FF;
2900 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0E, temp
);
2901 tempbx
= pVBInfo
->VGAVDE
- 1;
2902 temp
= tempbx
& 0x00FF;
2903 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0F, temp
);
2904 temp
= ((tempbx
& 0xFF00) << 3) >> 8;
2905 temp
|= ((tempcx
& 0xFF00) >> 8);
2906 xgifb_reg_set(pVBInfo
->Part1Port
, 0x12, temp
);
2908 /* BTVGA2VRS 0x10,0x11 */
2909 tempbx
= (pVBInfo
->VGAVT
+ pVBInfo
->VGAVDE
) >> 1;
2910 /* BTVGA2VRE 0x11 */
2911 tempcx
= ((pVBInfo
->VGAVT
- pVBInfo
->VGAVDE
) >> 4) + tempbx
+ 1;
2913 if (pVBInfo
->VBInfo
& SetCRT2ToRAMDAC
) {
2914 tempbx
= XGI_CRT1Table
[CRT1Index
].CR
[10];
2915 temp
= XGI_CRT1Table
[CRT1Index
].CR
[9];
2923 temp
= XGI_CRT1Table
[CRT1Index
].CR
[14];
2928 temp
= XGI_CRT1Table
[CRT1Index
].CR
[11];
2929 tempcx
= (tempcx
& 0xFF00) | (temp
& 0x00FF);
2932 temp
= tempbx
& 0x00FF;
2933 xgifb_reg_set(pVBInfo
->Part1Port
, 0x10, temp
);
2934 temp
= ((tempbx
& 0xFF00) >> 8) << 4;
2935 temp
= ((tempcx
& 0x000F) | (temp
));
2936 xgifb_reg_set(pVBInfo
->Part1Port
, 0x11, temp
);
2939 if (modeflag
& DoubleScanMode
)
2942 if (modeflag
& HalfDCLK
)
2945 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x2C, ~0x0C0, tempax
);
2948 static unsigned short XGI_GetVGAHT2(struct vb_device_info
*pVBInfo
)
2950 unsigned long tempax
, tempbx
;
2952 tempbx
= ((pVBInfo
->VGAVT
- pVBInfo
->VGAVDE
) * pVBInfo
->RVBHCMAX
)
2954 tempax
= (pVBInfo
->VT
- pVBInfo
->VDE
) * pVBInfo
->RVBHCFACT
;
2955 tempax
= (tempax
* pVBInfo
->HT
) / tempbx
;
2957 return (unsigned short) tempax
;
2960 static void XGI_SetLockRegs(unsigned short ModeNo
, unsigned short ModeIdIndex
,
2961 struct vb_device_info
*pVBInfo
)
2963 unsigned short push1
, push2
, tempax
, tempbx
= 0, tempcx
, temp
, resinfo
,
2966 /* si+Ext_ResInfo */
2967 modeflag
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
2968 resinfo
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
2970 if (!(pVBInfo
->VBInfo
& SetInSlaveMode
))
2973 temp
= 0xFF; /* set MAX HT */
2974 xgifb_reg_set(pVBInfo
->Part1Port
, 0x03, temp
);
2977 if (pVBInfo
->VBType
& (VB_SIS301LV
| VB_SIS302LV
| VB_XGI301C
))
2978 modeflag
|= Charx8Dot
;
2980 tempax
= pVBInfo
->VGAHDE
; /* 0x04 Horizontal Display End */
2982 if (modeflag
& HalfDCLK
)
2983 tempax
= tempax
>> 1;
2985 tempax
= (tempax
/ tempcx
) - 1;
2986 tempbx
|= ((tempax
& 0x00FF) << 8);
2987 temp
= tempax
& 0x00FF;
2988 xgifb_reg_set(pVBInfo
->Part1Port
, 0x04, temp
);
2990 temp
= (tempbx
& 0xFF00) >> 8;
2992 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
2993 if (!(pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
2994 | VB_SIS302LV
| VB_XGI301C
)))
2997 if ((pVBInfo
->VBInfo
& SetCRT2ToHiVision
) &&
2998 !(pVBInfo
->VBType
& VB_SIS301LV
) && (resinfo
== 7))
3002 /* 0x05 Horizontal Display Start */
3003 xgifb_reg_set(pVBInfo
->Part1Port
, 0x05, temp
);
3004 /* 0x06 Horizontal Blank end */
3005 xgifb_reg_set(pVBInfo
->Part1Port
, 0x06, 0x03);
3007 if (!(pVBInfo
->VBInfo
& DisableCRT2Display
)) { /* 030226 bainy */
3008 if (pVBInfo
->VBInfo
& SetCRT2ToTV
)
3009 tempax
= pVBInfo
->VGAHT
;
3011 tempax
= XGI_GetVGAHT2(pVBInfo
);
3014 if (tempax
>= pVBInfo
->VGAHT
)
3015 tempax
= pVBInfo
->VGAHT
;
3017 if (modeflag
& HalfDCLK
)
3018 tempax
= tempax
>> 1;
3020 tempax
= (tempax
/ tempcx
) - 5;
3021 tempcx
= tempax
; /* 20030401 0x07 horizontal Retrace Start */
3022 if (pVBInfo
->VBInfo
& SetCRT2ToHiVision
) {
3023 temp
= (tempbx
& 0x00FF) - 1;
3024 if (!(modeflag
& HalfDCLK
)) {
3026 if (pVBInfo
->TVInfo
& TVSimuMode
) {
3032 tempbx
= (tempbx
& 0xFF00) >> 8;
3033 tempcx
= (tempcx
+ tempbx
) >> 1;
3034 temp
= (tempcx
& 0x00FF) + 2;
3036 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
3038 if (!(modeflag
& HalfDCLK
)) {
3039 if ((modeflag
& Charx8Dot
)) {
3041 if (pVBInfo
->VGAHDE
>= 800)
3045 } else if (!(modeflag
& HalfDCLK
)) {
3047 if (pVBInfo
->LCDResInfo
!= Panel_1280x960
&&
3048 pVBInfo
->VGAHDE
>= 800) {
3050 if (pVBInfo
->VGAHDE
>= 1280 &&
3051 pVBInfo
->LCDResInfo
!= Panel_1280x960
&&
3052 (pVBInfo
->LCDInfo
& LCDNonExpanding
))
3058 /* 0x07 Horizontal Retrace Start */
3059 xgifb_reg_set(pVBInfo
->Part1Port
, 0x07, temp
);
3060 /* 0x08 Horizontal Retrace End */
3061 xgifb_reg_set(pVBInfo
->Part1Port
, 0x08, 0);
3063 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
3064 if (pVBInfo
->TVInfo
& TVSimuMode
) {
3065 if (ModeNo
== 0x50) {
3066 if (pVBInfo
->TVInfo
== SetNTSCTV
) {
3067 xgifb_reg_set(pVBInfo
->Part1Port
,
3069 xgifb_reg_set(pVBInfo
->Part1Port
,
3072 xgifb_reg_set(pVBInfo
->Part1Port
,
3074 xgifb_reg_set(pVBInfo
->Part1Port
,
3081 xgifb_reg_set(pVBInfo
->Part1Port
, 0x18, 0x03); /* 0x18 SR0B */
3082 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x19, 0xF0, 0x00);
3083 xgifb_reg_set(pVBInfo
->Part1Port
, 0x09, 0xFF); /* 0x09 Set Max VT */
3085 tempbx
= pVBInfo
->VGAVT
;
3088 tempbx
= pVBInfo
->VGAVDE
; /* 0x0E Virtical Display End */
3103 if (pVBInfo
->VBInfo
& SetCRT2ToLCD
) {
3104 if (pVBInfo
->LCDResInfo
== Panel_1024x768
) {
3105 if (!(pVBInfo
->LCDInfo
& XGI_LCDVESATiming
)) {
3115 temp
= tempbx
& 0x00FF;
3116 /* 0x10 vertical Blank Start */
3117 xgifb_reg_set(pVBInfo
->Part1Port
, 0x10, temp
);
3120 temp
= tempbx
& 0x00FF;
3121 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0E, temp
);
3123 if (tempbx
& 0x0100)
3128 if (modeflag
& DoubleScanMode
)
3131 if (tempbx
& 0x0200)
3134 temp
= (tempax
& 0xFF00) >> 8;
3135 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0B, temp
);
3137 if (tempbx
& 0x0400)
3140 /* 0x11 Vertival Blank End */
3141 xgifb_reg_set(pVBInfo
->Part1Port
, 0x11, 0x00);
3144 tempax
-= tempbx
; /* 0x0C Vertical Retrace Start */
3145 tempax
= tempax
>> 2;
3146 push1
= tempax
; /* push ax */
3148 if (resinfo
!= 0x09) {
3149 tempax
= tempax
<< 1;
3153 if (pVBInfo
->VBInfo
& SetCRT2ToHiVision
) {
3154 if ((pVBInfo
->VBType
& VB_SIS301LV
) &&
3155 !(pVBInfo
->TVInfo
& TVSetHiVision
)) {
3156 if ((pVBInfo
->TVInfo
& TVSimuMode
) &&
3157 (pVBInfo
->TVInfo
& TVSetPAL
)) {
3158 if (!(pVBInfo
->VBType
& VB_SIS301LV
) ||
3168 } else if (pVBInfo
->TVInfo
& TVSimuMode
) {
3169 if (pVBInfo
->TVInfo
& TVSetPAL
) {
3170 if (pVBInfo
->VBType
& VB_SIS301LV
) {
3171 if (!(pVBInfo
->TVInfo
&
3182 tempax
= tempax
>> 2;
3185 push1
= tempax
; /* push ax */
3187 if ((pVBInfo
->TVInfo
& TVSetPAL
)) {
3188 if (tempbx
<= 513) {
3194 temp
= tempbx
& 0x00FF;
3195 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0C, temp
);
3197 temp
= tempbx
& 0x00FF;
3198 xgifb_reg_set(pVBInfo
->Part1Port
, 0x10, temp
);
3200 if (tempbx
& 0x0100)
3203 if (tempbx
& 0x0200)
3204 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x0B, 0x0FF, 0x20);
3208 if (tempbx
& 0x0100)
3211 if (tempbx
& 0x0200)
3214 if (tempbx
& 0x0400)
3217 tempbx
= push1
; /* pop ax */
3218 temp
= tempbx
& 0x00FF;
3220 /* 0x0D vertical Retrace End */
3221 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0D, temp
);
3223 if (tempbx
& 0x0010)
3226 temp
= tempcx
& 0x00FF;
3227 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0A, temp
); /* 0x0A CR07 */
3228 temp
= (tempcx
& 0x0FF00) >> 8;
3229 xgifb_reg_set(pVBInfo
->Part1Port
, 0x17, temp
); /* 0x17 SR0A */
3231 temp
= (tempax
& 0xFF00) >> 8;
3233 temp
= (temp
>> 1) & 0x09;
3235 if (pVBInfo
->VBType
& (VB_SIS301LV
| VB_SIS302LV
| VB_XGI301C
))
3238 xgifb_reg_set(pVBInfo
->Part1Port
, 0x16, temp
); /* 0x16 SR01 */
3239 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0F, 0); /* 0x0F CR14 */
3240 xgifb_reg_set(pVBInfo
->Part1Port
, 0x12, 0); /* 0x12 CR17 */
3242 if (pVBInfo
->LCDInfo
& LCDRGB18Bit
)
3247 xgifb_reg_set(pVBInfo
->Part1Port
, 0x1A, temp
); /* 0x1A SR0E */
3250 static void XGI_SetGroup2(unsigned short ModeNo
, unsigned short ModeIdIndex
,
3251 struct vb_device_info
*pVBInfo
)
3253 unsigned short i
, j
, tempax
, tempbx
, tempcx
, temp
, push1
, push2
,
3255 unsigned char const *TimingPoint
;
3257 unsigned long longtemp
, tempeax
, tempebx
, temp2
, tempecx
;
3259 /* si+Ext_ResInfo */
3260 modeflag
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
3264 if (!(pVBInfo
->VBInfo
& SetCRT2ToAVIDEO
))
3267 if (!(pVBInfo
->VBInfo
& SetCRT2ToSVIDEO
))
3270 if (pVBInfo
->VBInfo
& SetCRT2ToSCART
)
3273 if (!(pVBInfo
->TVInfo
& TVSetPAL
))
3276 if (pVBInfo
->VBInfo
& SetCRT2ToHiVision
)
3279 if (pVBInfo
->TVInfo
& (TVSetYPbPr525p
| TVSetYPbPr750p
))
3282 tempax
= (tempax
& 0xff00) >> 8;
3284 xgifb_reg_set(pVBInfo
->Part2Port
, 0x0, tempax
);
3285 TimingPoint
= XGI330_NTSCTiming
;
3287 if (pVBInfo
->TVInfo
& TVSetPAL
)
3288 TimingPoint
= XGI330_PALTiming
;
3290 if (pVBInfo
->VBInfo
& SetCRT2ToHiVision
) {
3291 TimingPoint
= XGI330_HiTVExtTiming
;
3293 if (pVBInfo
->VBInfo
& SetInSlaveMode
)
3294 TimingPoint
= XGI330_HiTVSt2Timing
;
3296 if (pVBInfo
->SetFlag
& TVSimuMode
)
3297 TimingPoint
= XGI330_HiTVSt1Timing
;
3299 if (!(modeflag
& Charx8Dot
))
3300 TimingPoint
= XGI330_HiTVTextTiming
;
3303 if (pVBInfo
->VBInfo
& SetCRT2ToYPbPr525750
) {
3304 if (pVBInfo
->TVInfo
& TVSetYPbPr525i
)
3305 TimingPoint
= XGI330_YPbPr525iTiming
;
3307 if (pVBInfo
->TVInfo
& TVSetYPbPr525p
)
3308 TimingPoint
= XGI330_YPbPr525pTiming
;
3310 if (pVBInfo
->TVInfo
& TVSetYPbPr750p
)
3311 TimingPoint
= XGI330_YPbPr750pTiming
;
3314 for (i
= 0x01, j
= 0; i
<= 0x2D; i
++, j
++)
3315 xgifb_reg_set(pVBInfo
->Part2Port
, i
, TimingPoint
[j
]);
3317 for (i
= 0x39; i
<= 0x45; i
++, j
++)
3319 xgifb_reg_set(pVBInfo
->Part2Port
, i
, TimingPoint
[j
]);
3321 if (pVBInfo
->VBInfo
& SetCRT2ToTV
)
3322 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x3A, 0x1F, 0x00);
3324 temp
= pVBInfo
->NewFlickerMode
;
3326 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x0A, 0xFF, temp
);
3328 if (pVBInfo
->TVInfo
& TVSetPAL
)
3333 if (pVBInfo
->VDE
<= tempax
) {
3334 tempax
-= pVBInfo
->VDE
;
3335 tempax
= tempax
>> 2;
3336 tempax
= (tempax
& 0x00FF) | ((tempax
& 0x00FF) << 8);
3338 temp
= (tempax
& 0xFF00) >> 8;
3339 temp
+= (unsigned short) TimingPoint
[0];
3341 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
3342 | VB_SIS302LV
| VB_XGI301C
)) {
3343 if (pVBInfo
->VBInfo
& (SetCRT2ToAVIDEO
3344 | SetCRT2ToSVIDEO
| SetCRT2ToSCART
3345 | SetCRT2ToYPbPr525750
)) {
3346 tempcx
= pVBInfo
->VGAHDE
;
3347 if (tempcx
>= 1024) {
3348 temp
= 0x17; /* NTSC */
3349 if (pVBInfo
->TVInfo
& TVSetPAL
)
3350 temp
= 0x19; /* PAL */
3355 xgifb_reg_set(pVBInfo
->Part2Port
, 0x01, temp
);
3357 temp
= (tempax
& 0xFF00) >> 8;
3358 temp
+= TimingPoint
[1];
3360 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
3361 | VB_SIS302LV
| VB_XGI301C
)) {
3362 if ((pVBInfo
->VBInfo
& (SetCRT2ToAVIDEO
3363 | SetCRT2ToSVIDEO
| SetCRT2ToSCART
3364 | SetCRT2ToYPbPr525750
))) {
3365 tempcx
= pVBInfo
->VGAHDE
;
3366 if (tempcx
>= 1024) {
3367 temp
= 0x1D; /* NTSC */
3368 if (pVBInfo
->TVInfo
& TVSetPAL
)
3369 temp
= 0x52; /* PAL */
3373 xgifb_reg_set(pVBInfo
->Part2Port
, 0x02, temp
);
3377 tempcx
= pVBInfo
->HT
;
3379 if (XGI_IsLCDDualLink(pVBInfo
))
3380 tempcx
= tempcx
>> 1;
3383 temp
= tempcx
& 0x00FF;
3384 xgifb_reg_set(pVBInfo
->Part2Port
, 0x1B, temp
);
3386 temp
= (tempcx
& 0xFF00) >> 8;
3387 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x1D, ~0x0F, temp
);
3389 tempcx
= pVBInfo
->HT
>> 1;
3390 push1
= tempcx
; /* push cx */
3393 if (pVBInfo
->VBInfo
& SetCRT2ToHiVision
)
3396 temp
= tempcx
& 0x00FF;
3398 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x22, 0x0F, temp
);
3400 tempbx
= TimingPoint
[j
] | ((TimingPoint
[j
+ 1]) << 8);
3403 temp
= tempbx
& 0x00FF;
3404 xgifb_reg_set(pVBInfo
->Part2Port
, 0x24, temp
);
3405 temp
= (tempbx
& 0xFF00) >> 8;
3407 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x25, 0x0F, temp
);
3410 tempbx
= tempbx
+ 8;
3411 if (pVBInfo
->VBInfo
& SetCRT2ToHiVision
) {
3412 tempbx
= tempbx
- 4;
3416 temp
= (tempbx
& 0x00FF) << 4;
3417 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x29, 0x0F, temp
);
3420 tempcx
+= (TimingPoint
[j
] | ((TimingPoint
[j
+ 1]) << 8));
3421 temp
= tempcx
& 0x00FF;
3422 xgifb_reg_set(pVBInfo
->Part2Port
, 0x27, temp
);
3423 temp
= ((tempcx
& 0xFF00) >> 8) << 4;
3424 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x28, 0x0F, temp
);
3427 if (pVBInfo
->VBInfo
& SetCRT2ToHiVision
)
3430 temp
= tempcx
& 0xFF;
3432 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x2A, 0x0F, temp
);
3434 tempcx
= push1
; /* pop cx */
3436 temp
= TimingPoint
[j
] | ((TimingPoint
[j
+ 1]) << 8);
3438 temp
= tempcx
& 0x00FF;
3440 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x2D, 0x0F, temp
);
3444 if (!(pVBInfo
->VBInfo
& SetCRT2ToTV
)) {
3445 tempax
= XGI_GetVGAHT2(pVBInfo
);
3446 tempcx
= tempax
- 1;
3448 temp
= tempcx
& 0x00FF;
3449 xgifb_reg_set(pVBInfo
->Part2Port
, 0x2E, temp
);
3451 tempbx
= pVBInfo
->VDE
;
3453 if (pVBInfo
->VGAVDE
== 360)
3455 if (pVBInfo
->VGAVDE
== 375)
3457 if (pVBInfo
->VGAVDE
== 405)
3460 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
3461 if (pVBInfo
->VBType
&
3462 (VB_SIS301LV
| VB_SIS302LV
| VB_XGI301C
)) {
3463 if (!(pVBInfo
->TVInfo
&
3464 (TVSetYPbPr525p
| TVSetYPbPr750p
)))
3465 tempbx
= tempbx
>> 1;
3467 tempbx
= tempbx
>> 1;
3471 temp
= tempbx
& 0x00FF;
3473 if (pVBInfo
->VBInfo
& SetCRT2ToHiVision
) {
3474 if (pVBInfo
->VBType
& VB_SIS301LV
) {
3475 if (pVBInfo
->TVInfo
& TVSetHiVision
) {
3476 if (pVBInfo
->VBInfo
& SetInSlaveMode
) {
3481 } else if (pVBInfo
->VBInfo
& SetInSlaveMode
) {
3487 xgifb_reg_set(pVBInfo
->Part2Port
, 0x2F, temp
);
3489 temp
= (tempcx
& 0xFF00) >> 8;
3490 temp
|= ((tempbx
& 0xFF00) >> 8) << 6;
3492 if (!(pVBInfo
->VBInfo
& SetCRT2ToHiVision
)) {
3493 if (pVBInfo
->VBType
& VB_SIS301LV
) {
3494 if (pVBInfo
->TVInfo
& TVSetHiVision
) {
3497 if (!(pVBInfo
->VBInfo
& SetCRT2ToSVIDEO
))
3502 if (!(pVBInfo
->VBInfo
& SetCRT2ToSVIDEO
))
3507 xgifb_reg_set(pVBInfo
->Part2Port
, 0x30, temp
);
3509 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
3510 | VB_SIS302LV
| VB_XGI301C
)) { /* TV gatingno */
3511 tempbx
= pVBInfo
->VDE
;
3512 tempcx
= tempbx
- 2;
3514 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
3515 if (!(pVBInfo
->TVInfo
& (TVSetYPbPr525p
3517 tempbx
= tempbx
>> 1;
3520 if (pVBInfo
->VBType
& (VB_SIS302LV
| VB_XGI301C
)) {
3522 if (tempcx
& 0x0400)
3525 if (tempbx
& 0x0400)
3528 xgifb_reg_set(pVBInfo
->Part4Port
, 0x10, temp
);
3531 temp
= (((tempbx
- 3) & 0x0300) >> 8) << 5;
3532 xgifb_reg_set(pVBInfo
->Part2Port
, 0x46, temp
);
3533 temp
= (tempbx
- 3) & 0x00FF;
3534 xgifb_reg_set(pVBInfo
->Part2Port
, 0x47, temp
);
3537 tempbx
= tempbx
& 0x00FF;
3539 if (!(modeflag
& HalfDCLK
)) {
3540 tempcx
= pVBInfo
->VGAHDE
;
3541 if (tempcx
>= pVBInfo
->HDE
) {
3549 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) { /*301b*/
3550 if (pVBInfo
->VGAHDE
>= 1024) {
3552 if (pVBInfo
->VGAHDE
>= 1280) {
3554 tempbx
= tempbx
& 0xDFFF;
3559 if (!(tempbx
& 0x2000)) {
3560 if (modeflag
& HalfDCLK
)
3561 tempcx
= (tempcx
& 0xFF00) | ((tempcx
& 0x00FF) << 1);
3564 tempeax
= pVBInfo
->VGAHDE
;
3565 tempebx
= (tempcx
& 0xFF00) >> 8;
3566 longtemp
= tempeax
* tempebx
;
3567 tempecx
= tempcx
& 0x00FF;
3568 longtemp
= longtemp
/ tempecx
;
3573 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
3574 | VB_SIS302LV
| VB_XGI301C
)) {
3575 tempecx
= tempecx
* 8;
3578 longtemp
= longtemp
* tempecx
;
3579 tempecx
= pVBInfo
->HDE
;
3580 temp2
= longtemp
% tempecx
;
3581 tempeax
= longtemp
/ tempecx
;
3585 tempax
= (unsigned short) tempeax
;
3588 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
3589 | VB_SIS302LV
| VB_XGI301C
)) {
3590 tempcx
= ((tempax
& 0xFF00) >> 5) >> 8;
3595 tempbx
= (unsigned short) (((tempeax
& 0x0000FF00) & 0x1F00)
3596 | (tempbx
& 0x00FF));
3597 tempax
= (unsigned short) (((tempeax
& 0x000000FF) << 8)
3598 | (tempax
& 0x00FF));
3599 temp
= (tempax
& 0xFF00) >> 8;
3601 temp
= (tempax
& 0x00FF) >> 8;
3604 xgifb_reg_set(pVBInfo
->Part2Port
, 0x44, temp
);
3605 temp
= (tempbx
& 0xFF00) >> 8;
3606 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x45, ~0x03F, temp
);
3607 temp
= tempcx
& 0x00FF;
3609 if (tempbx
& 0x2000)
3612 if (!(pVBInfo
->VBInfo
& SetCRT2ToLCD
))
3615 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x46, ~0x1F, temp
);
3616 if (pVBInfo
->TVInfo
& TVSetPAL
) {
3624 temp
= tempbx
& 0x00FF;
3625 xgifb_reg_set(pVBInfo
->Part2Port
, 0x4b, temp
);
3626 temp
= tempcx
& 0x00FF;
3627 xgifb_reg_set(pVBInfo
->Part2Port
, 0x4c, temp
);
3629 temp
= ((tempcx
& 0xFF00) >> 8) & 0x03;
3631 temp
|= ((tempbx
& 0xFF00) >> 8) & 0x03;
3633 if (pVBInfo
->VBInfo
& SetCRT2ToYPbPr525750
) {
3636 if (pVBInfo
->TVInfo
& TVSetYPbPr525p
)
3639 if (pVBInfo
->TVInfo
& TVSetYPbPr750p
)
3643 xgifb_reg_set(pVBInfo
->Part2Port
, 0x4d, temp
);
3644 temp
= xgifb_reg_get(pVBInfo
->Part2Port
, 0x43); /* 301b change */
3645 xgifb_reg_set(pVBInfo
->Part2Port
, 0x43, (unsigned short) (temp
- 3));
3647 if (!(pVBInfo
->TVInfo
& (TVSetYPbPr525p
| TVSetYPbPr750p
))) {
3648 if (pVBInfo
->TVInfo
& NTSC1024x768
) {
3649 TimingPoint
= XGI_NTSC1024AdjTime
;
3650 for (i
= 0x1c, j
= 0; i
<= 0x30; i
++, j
++) {
3651 xgifb_reg_set(pVBInfo
->Part2Port
, i
,
3654 xgifb_reg_set(pVBInfo
->Part2Port
, 0x43, 0x72);
3658 /* Modify for 301C PALM Support */
3659 if (pVBInfo
->VBType
& VB_XGI301C
) {
3660 if (pVBInfo
->TVInfo
& TVSetPALM
)
3661 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x4E, ~0x08,
3662 0x08); /* PALM Mode */
3665 if (pVBInfo
->TVInfo
& TVSetPALM
) {
3666 tempax
= xgifb_reg_get(pVBInfo
->Part2Port
, 0x01);
3668 xgifb_reg_and(pVBInfo
->Part2Port
, 0x01, tempax
);
3670 xgifb_reg_and(pVBInfo
->Part2Port
, 0x00, 0xEF);
3673 if (pVBInfo
->VBInfo
& SetCRT2ToHiVision
) {
3674 if (!(pVBInfo
->VBInfo
& SetInSlaveMode
))
3675 xgifb_reg_set(pVBInfo
->Part2Port
, 0x0B, 0x00);
3679 static void XGI_SetLCDRegs(unsigned short ModeIdIndex
,
3680 struct vb_device_info
*pVBInfo
)
3682 unsigned short pushbx
, tempax
, tempbx
, tempcx
, temp
, tempah
,
3685 struct XGI_LCDDesStruct
const *LCDBDesPtr
= NULL
;
3687 /* si+Ext_ResInfo */
3688 if (!(pVBInfo
->VBInfo
& SetCRT2ToLCD
))
3691 tempbx
= pVBInfo
->HDE
; /* RHACTE=HDE-1 */
3693 if (XGI_IsLCDDualLink(pVBInfo
))
3694 tempbx
= tempbx
>> 1;
3697 temp
= tempbx
& 0x00FF;
3698 xgifb_reg_set(pVBInfo
->Part2Port
, 0x2C, temp
);
3699 temp
= (tempbx
& 0xFF00) >> 8;
3701 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x2B, 0x0F, temp
);
3704 xgifb_reg_set(pVBInfo
->Part2Port
, 0x0B, temp
);
3705 tempbx
= pVBInfo
->VDE
; /* RTVACTEO=(VDE-1)&0xFF */
3707 temp
= tempbx
& 0x00FF;
3708 xgifb_reg_set(pVBInfo
->Part2Port
, 0x03, temp
);
3709 temp
= ((tempbx
& 0xFF00) >> 8) & 0x07;
3710 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x0C, ~0x07, temp
);
3712 tempcx
= pVBInfo
->VT
- 1;
3713 temp
= tempcx
& 0x00FF; /* RVTVT=VT-1 */
3714 xgifb_reg_set(pVBInfo
->Part2Port
, 0x19, temp
);
3715 temp
= (tempcx
& 0xFF00) >> 8;
3717 xgifb_reg_set(pVBInfo
->Part2Port
, 0x1A, temp
);
3718 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x09, 0xF0, 0x00);
3719 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x0A, 0xF0, 0x00);
3720 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x17, 0xFB, 0x00);
3721 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x18, 0xDF, 0x00);
3723 /* Customized LCDB Does not add */
3724 if ((pVBInfo
->VBType
& VB_SIS301LV
) || (pVBInfo
->VBType
& VB_SIS302LV
))
3725 LCDBDesPtr
= XGI_GetLcdPtr(xgifb_lcddldes
, ModeIdIndex
,
3728 LCDBDesPtr
= XGI_GetLcdPtr(XGI_LCDDesDataTable
, ModeIdIndex
,
3731 tempah
= pVBInfo
->LCDResInfo
;
3732 tempah
&= PanelResInfo
;
3734 if ((tempah
== Panel_1024x768
) || (tempah
== Panel_1024x768x75
)) {
3737 } else if ((tempah
== Panel_1280x1024
) ||
3738 (tempah
== Panel_1280x1024x75
)) {
3741 } else if (tempah
== Panel_1400x1050
) {
3749 if (pVBInfo
->LCDInfo
& EnableScalingLCD
) {
3750 tempbx
= pVBInfo
->HDE
;
3751 tempcx
= pVBInfo
->VDE
;
3755 tempax
= pVBInfo
->VT
;
3756 pVBInfo
->LCDHDES
= LCDBDesPtr
->LCDHDES
;
3757 pVBInfo
->LCDHRS
= LCDBDesPtr
->LCDHRS
;
3758 pVBInfo
->LCDVDES
= LCDBDesPtr
->LCDVDES
;
3759 pVBInfo
->LCDVRS
= LCDBDesPtr
->LCDVRS
;
3760 tempbx
= pVBInfo
->LCDVDES
;
3763 if (tempcx
>= tempax
)
3764 tempcx
-= tempax
; /* lcdvdes */
3766 temp
= tempbx
& 0x00FF; /* RVEQ1EQ=lcdvdes */
3767 xgifb_reg_set(pVBInfo
->Part2Port
, 0x05, temp
);
3768 temp
= tempcx
& 0x00FF;
3769 xgifb_reg_set(pVBInfo
->Part2Port
, 0x06, temp
);
3770 tempch
= ((tempcx
& 0xFF00) >> 8) & 0x07;
3771 tempbh
= ((tempbx
& 0xFF00) >> 8) & 0x07;
3773 tempah
= tempah
<< 3;
3775 xgifb_reg_set(pVBInfo
->Part2Port
, 0x02, tempah
);
3778 XGI_GetLCDSync(&tempax
, &tempbx
, pVBInfo
);
3780 tempax
= pVBInfo
->VT
;
3781 tempbx
= pVBInfo
->LCDVRS
;
3784 if (tempcx
>= tempax
)
3787 temp
= tempbx
& 0x00FF; /* RTVACTEE=lcdvrs */
3788 xgifb_reg_set(pVBInfo
->Part2Port
, 0x04, temp
);
3789 temp
= (tempbx
& 0xFF00) >> 8;
3791 temp
|= (tempcx
& 0x000F);
3792 xgifb_reg_set(pVBInfo
->Part2Port
, 0x01, temp
);
3794 tempax
= pVBInfo
->HT
;
3795 tempbx
= pVBInfo
->LCDHDES
;
3798 if (XGI_IsLCDDualLink(pVBInfo
)) {
3799 tempax
= tempax
>> 1;
3800 tempbx
= tempbx
>> 1;
3801 tempcx
= tempcx
>> 1;
3804 if (pVBInfo
->VBType
& VB_SIS302LV
)
3807 if (pVBInfo
->VBType
& VB_XGI301C
) /* tap4 */
3812 if (tempcx
>= tempax
)
3815 temp
= tempbx
& 0x00FF;
3816 xgifb_reg_set(pVBInfo
->Part2Port
, 0x1F, temp
); /* RHBLKE=lcdhdes */
3817 temp
= ((tempbx
& 0xFF00) >> 8) << 4;
3818 xgifb_reg_set(pVBInfo
->Part2Port
, 0x20, temp
);
3819 temp
= tempcx
& 0x00FF;
3820 xgifb_reg_set(pVBInfo
->Part2Port
, 0x23, temp
); /* RHEQPLE=lcdhdee */
3821 temp
= (tempcx
& 0xFF00) >> 8;
3822 xgifb_reg_set(pVBInfo
->Part2Port
, 0x25, temp
);
3824 XGI_GetLCDSync(&tempax
, &tempbx
, pVBInfo
);
3826 tempax
= pVBInfo
->HT
;
3827 tempbx
= pVBInfo
->LCDHRS
;
3828 if (XGI_IsLCDDualLink(pVBInfo
)) {
3829 tempax
= tempax
>> 1;
3830 tempbx
= tempbx
>> 1;
3831 tempcx
= tempcx
>> 1;
3834 if (pVBInfo
->VBType
& VB_SIS302LV
)
3839 if (tempcx
>= tempax
)
3842 temp
= tempbx
& 0x00FF; /* RHBURSTS=lcdhrs */
3843 xgifb_reg_set(pVBInfo
->Part2Port
, 0x1C, temp
);
3845 temp
= (tempbx
& 0xFF00) >> 8;
3847 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x1D, ~0x0F0, temp
);
3848 temp
= tempcx
& 0x00FF; /* RHSYEXP2S=lcdhre */
3849 xgifb_reg_set(pVBInfo
->Part2Port
, 0x21, temp
);
3851 if (!(pVBInfo
->LCDInfo
& XGI_LCDVESATiming
)) {
3852 if (pVBInfo
->VGAVDE
== 525) {
3853 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
3854 | VB_SIS301LV
| VB_SIS302LV
3860 xgifb_reg_set(pVBInfo
->Part2Port
, 0x2f, temp
);
3861 xgifb_reg_set(pVBInfo
->Part2Port
, 0x30, 0xB3);
3864 if (pVBInfo
->VGAVDE
== 420) {
3865 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
3866 | VB_SIS301LV
| VB_SIS302LV
3871 xgifb_reg_set(pVBInfo
->Part2Port
, 0x2f, temp
);
3876 /* --------------------------------------------------------------------- */
3877 /* Function : XGI_GetTap4Ptr */
3879 /* Output : di -> Tap4 Reg. Setting Pointer */
3881 /* --------------------------------------------------------------------- */
3882 static struct XGI301C_Tap4TimingStruct
const
3883 *XGI_GetTap4Ptr(unsigned short tempcx
, struct vb_device_info
*pVBInfo
)
3885 unsigned short tempax
, tempbx
, i
;
3886 struct XGI301C_Tap4TimingStruct
const *Tap4TimingPtr
;
3889 tempax
= pVBInfo
->VGAHDE
;
3890 tempbx
= pVBInfo
->HDE
;
3892 tempax
= pVBInfo
->VGAVDE
;
3893 tempbx
= pVBInfo
->VDE
;
3896 if (tempax
<= tempbx
)
3897 return &xgifb_tap4_timing
[0];
3898 Tap4TimingPtr
= xgifb_ntsc_525_tap4_timing
; /* NTSC */
3900 if (pVBInfo
->TVInfo
& TVSetPAL
)
3901 Tap4TimingPtr
= PALTap4Timing
;
3903 if (pVBInfo
->VBInfo
& SetCRT2ToYPbPr525750
) {
3904 if ((pVBInfo
->TVInfo
& TVSetYPbPr525i
) ||
3905 (pVBInfo
->TVInfo
& TVSetYPbPr525p
))
3906 Tap4TimingPtr
= xgifb_ntsc_525_tap4_timing
;
3907 if (pVBInfo
->TVInfo
& TVSetYPbPr750p
)
3908 Tap4TimingPtr
= YPbPr750pTap4Timing
;
3911 if (pVBInfo
->VBInfo
& SetCRT2ToHiVision
)
3912 Tap4TimingPtr
= xgifb_tap4_timing
;
3915 while (Tap4TimingPtr
[i
].DE
!= 0xFFFF) {
3916 if (Tap4TimingPtr
[i
].DE
== tempax
)
3920 return &Tap4TimingPtr
[i
];
3923 static void XGI_SetTap4Regs(struct vb_device_info
*pVBInfo
)
3925 unsigned short i
, j
;
3926 struct XGI301C_Tap4TimingStruct
const *Tap4TimingPtr
;
3928 if (!(pVBInfo
->VBType
& VB_XGI301C
))
3931 Tap4TimingPtr
= XGI_GetTap4Ptr(0, pVBInfo
); /* Set Horizontal Scaling */
3932 for (i
= 0x80, j
= 0; i
<= 0xBF; i
++, j
++)
3933 xgifb_reg_set(pVBInfo
->Part2Port
, i
, Tap4TimingPtr
->Reg
[j
]);
3935 if ((pVBInfo
->VBInfo
& SetCRT2ToTV
) &&
3936 (!(pVBInfo
->VBInfo
& SetCRT2ToHiVision
))) {
3937 /* Set Vertical Scaling */
3938 Tap4TimingPtr
= XGI_GetTap4Ptr(1, pVBInfo
);
3939 for (i
= 0xC0, j
= 0; i
< 0xFF; i
++, j
++)
3940 xgifb_reg_set(pVBInfo
->Part2Port
,
3942 Tap4TimingPtr
->Reg
[j
]);
3945 if ((pVBInfo
->VBInfo
& SetCRT2ToTV
) &&
3946 (!(pVBInfo
->VBInfo
& SetCRT2ToHiVision
)))
3947 /* Enable V.Scaling */
3948 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x4E, ~0x14, 0x04);
3950 /* Enable H.Scaling */
3951 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x4E, ~0x14, 0x10);
3954 static void XGI_SetGroup3(unsigned short ModeIdIndex
,
3955 struct vb_device_info
*pVBInfo
)
3958 unsigned char const *tempdi
;
3959 unsigned short modeflag
;
3961 /* si+Ext_ResInfo */
3962 modeflag
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
3964 xgifb_reg_set(pVBInfo
->Part3Port
, 0x00, 0x00);
3965 if (pVBInfo
->TVInfo
& TVSetPAL
) {
3966 xgifb_reg_set(pVBInfo
->Part3Port
, 0x13, 0xFA);
3967 xgifb_reg_set(pVBInfo
->Part3Port
, 0x14, 0xC8);
3969 xgifb_reg_set(pVBInfo
->Part3Port
, 0x13, 0xF5);
3970 xgifb_reg_set(pVBInfo
->Part3Port
, 0x14, 0xB7);
3973 if (!(pVBInfo
->VBInfo
& SetCRT2ToTV
))
3976 if (pVBInfo
->TVInfo
& TVSetPALM
) {
3977 xgifb_reg_set(pVBInfo
->Part3Port
, 0x13, 0xFA);
3978 xgifb_reg_set(pVBInfo
->Part3Port
, 0x14, 0xC8);
3979 xgifb_reg_set(pVBInfo
->Part3Port
, 0x3D, 0xA8);
3982 if ((pVBInfo
->VBInfo
& SetCRT2ToHiVision
) || (pVBInfo
->VBInfo
3983 & SetCRT2ToYPbPr525750
)) {
3984 if (pVBInfo
->TVInfo
& TVSetYPbPr525i
)
3987 tempdi
= XGI330_HiTVGroup3Data
;
3988 if (pVBInfo
->SetFlag
& TVSimuMode
) {
3989 tempdi
= XGI330_HiTVGroup3Simu
;
3990 if (!(modeflag
& Charx8Dot
))
3991 tempdi
= XGI330_HiTVGroup3Text
;
3994 if (pVBInfo
->TVInfo
& TVSetYPbPr525p
)
3995 tempdi
= XGI330_Ren525pGroup3
;
3997 if (pVBInfo
->TVInfo
& TVSetYPbPr750p
)
3998 tempdi
= XGI330_Ren750pGroup3
;
4000 for (i
= 0; i
<= 0x3E; i
++)
4001 xgifb_reg_set(pVBInfo
->Part3Port
, i
, tempdi
[i
]);
4003 if (pVBInfo
->VBType
& VB_XGI301C
) { /* Marcovision */
4004 if (pVBInfo
->TVInfo
& TVSetYPbPr525p
)
4005 xgifb_reg_set(pVBInfo
->Part3Port
, 0x28, 0x3f);
4010 static void XGI_SetGroup4(unsigned short ModeIdIndex
,
4011 unsigned short RefreshRateTableIndex
,
4012 struct vb_device_info
*pVBInfo
)
4014 unsigned short tempax
, tempcx
, tempbx
, modeflag
, temp
, temp2
;
4016 unsigned long tempebx
, tempeax
, templong
;
4018 /* si+Ext_ResInfo */
4019 modeflag
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
4020 temp
= pVBInfo
->RVBHCFACT
;
4021 xgifb_reg_set(pVBInfo
->Part4Port
, 0x13, temp
);
4023 tempbx
= pVBInfo
->RVBHCMAX
;
4024 temp
= tempbx
& 0x00FF;
4025 xgifb_reg_set(pVBInfo
->Part4Port
, 0x14, temp
);
4026 temp2
= ((tempbx
& 0xFF00) >> 8) << 7;
4027 tempcx
= pVBInfo
->VGAHT
- 1;
4028 temp
= tempcx
& 0x00FF;
4029 xgifb_reg_set(pVBInfo
->Part4Port
, 0x16, temp
);
4031 temp
= ((tempcx
& 0xFF00) >> 8) << 3;
4034 tempcx
= pVBInfo
->VGAVT
- 1;
4035 if (!(pVBInfo
->VBInfo
& SetCRT2ToTV
))
4038 temp
= tempcx
& 0x00FF;
4039 xgifb_reg_set(pVBInfo
->Part4Port
, 0x17, temp
);
4040 temp
= temp2
| ((tempcx
& 0xFF00) >> 8);
4041 xgifb_reg_set(pVBInfo
->Part4Port
, 0x15, temp
);
4042 xgifb_reg_or(pVBInfo
->Part4Port
, 0x0D, 0x08);
4043 tempcx
= pVBInfo
->VBInfo
;
4044 tempbx
= pVBInfo
->VGAHDE
;
4046 if (modeflag
& HalfDCLK
)
4047 tempbx
= tempbx
>> 1;
4049 if (XGI_IsLCDDualLink(pVBInfo
))
4050 tempbx
= tempbx
>> 1;
4052 if (tempcx
& SetCRT2ToHiVision
) {
4058 } else if (tempcx
& SetCRT2ToTV
) {
4064 if (pVBInfo
->VBInfo
& SetCRT2ToLCD
) {
4071 if (pVBInfo
->TVInfo
& (TVSetYPbPr525p
| TVSetYPbPr750p
)) {
4073 if (pVBInfo
->VGAHDE
== 1280)
4075 if (pVBInfo
->VGAHDE
== 1024)
4078 xgifb_reg_and_or(pVBInfo
->Part4Port
, 0x0E, ~0xEF, temp
);
4080 tempebx
= pVBInfo
->VDE
;
4082 tempcx
= pVBInfo
->RVBHRS
;
4083 temp
= tempcx
& 0x00FF;
4084 xgifb_reg_set(pVBInfo
->Part4Port
, 0x18, temp
);
4086 tempeax
= pVBInfo
->VGAVDE
;
4089 if (tempeax
<= tempebx
) {
4090 tempcx
= (tempcx
& (~0x4000));
4091 tempeax
= pVBInfo
->VGAVDE
;
4096 templong
= (tempeax
* 256 * 1024) % tempebx
;
4097 tempeax
= (tempeax
* 256 * 1024) / tempebx
;
4103 temp
= (unsigned short) (tempebx
& 0x000000FF);
4104 xgifb_reg_set(pVBInfo
->Part4Port
, 0x1B, temp
);
4106 temp
= (unsigned short) ((tempebx
& 0x0000FF00) >> 8);
4107 xgifb_reg_set(pVBInfo
->Part4Port
, 0x1A, temp
);
4108 tempbx
= (unsigned short) (tempebx
>> 16);
4109 temp
= tempbx
& 0x00FF;
4111 temp
|= ((tempcx
& 0xFF00) >> 8);
4112 xgifb_reg_set(pVBInfo
->Part4Port
, 0x19, temp
);
4115 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
4116 | VB_SIS302LV
| VB_XGI301C
)) {
4118 xgifb_reg_set(pVBInfo
->Part4Port
, 0x1C, temp
);
4119 tempax
= pVBInfo
->VGAHDE
;
4120 if (modeflag
& HalfDCLK
)
4121 tempax
= tempax
>> 1;
4123 if (XGI_IsLCDDualLink(pVBInfo
))
4124 tempax
= tempax
>> 1;
4126 if (pVBInfo
->VBInfo
& SetCRT2ToLCD
) {
4129 } else if (pVBInfo
->VGAHDE
> 800) {
4130 if (pVBInfo
->VGAHDE
== 1024)
4131 tempax
= (tempax
* 25 / 32) - 1;
4133 tempax
= (tempax
* 20 / 32) - 1;
4137 temp
= (tempax
& 0xFF00) >> 8;
4138 temp
= (temp
& 0x0003) << 4;
4139 xgifb_reg_set(pVBInfo
->Part4Port
, 0x1E, temp
);
4140 temp
= (tempax
& 0x00FF);
4141 xgifb_reg_set(pVBInfo
->Part4Port
, 0x1D, temp
);
4143 if (pVBInfo
->VBInfo
& (SetCRT2ToTV
| SetCRT2ToHiVision
)) {
4144 if (pVBInfo
->VGAHDE
> 800)
4145 xgifb_reg_or(pVBInfo
->Part4Port
, 0x1E, 0x08);
4150 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
4151 if (!(pVBInfo
->TVInfo
& (NTSC1024x768
4152 | TVSetYPbPr525p
| TVSetYPbPr750p
4153 | TVSetHiVision
))) {
4155 if ((pVBInfo
->VBInfo
& SetInSlaveMode
)
4156 && (!(pVBInfo
->TVInfo
4162 xgifb_reg_and_or(pVBInfo
->Part4Port
, 0x1F, 0x00C0, temp
);
4163 tempbx
= pVBInfo
->HT
;
4164 if (XGI_IsLCDDualLink(pVBInfo
))
4165 tempbx
= tempbx
>> 1;
4166 tempbx
= (tempbx
>> 1) - 2;
4167 temp
= ((tempbx
& 0x0700) >> 8) << 3;
4168 xgifb_reg_and_or(pVBInfo
->Part4Port
, 0x21, 0x00C0, temp
);
4169 temp
= tempbx
& 0x00FF;
4170 xgifb_reg_set(pVBInfo
->Part4Port
, 0x22, temp
);
4174 XGI_SetCRT2VCLK(ModeIdIndex
, RefreshRateTableIndex
, pVBInfo
);
4177 static void XGINew_EnableCRT2(struct vb_device_info
*pVBInfo
)
4179 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x1E, 0xFF, 0x20);
4182 static void XGI_SetGroup5(struct vb_device_info
*pVBInfo
)
4184 if (pVBInfo
->ModeType
== ModeVGA
) {
4185 if (!(pVBInfo
->VBInfo
& (SetInSlaveMode
| LoadDACFlag
4186 | DisableCRT2Display
))) {
4187 XGINew_EnableCRT2(pVBInfo
);
4192 static void XGI_DisableGatingCRT(struct vb_device_info
*pVBInfo
)
4194 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x63, 0xBF, 0x00);
4197 static unsigned char XGI_XG21CheckLVDSMode(struct xgifb_video_info
*xgifb_info
,
4198 unsigned short ModeNo
, unsigned short ModeIdIndex
)
4200 unsigned short xres
, yres
, colordepth
, modeflag
, resindex
;
4202 resindex
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
4203 xres
= XGI330_ModeResInfo
[resindex
].HTotal
; /* xres->ax */
4204 yres
= XGI330_ModeResInfo
[resindex
].VTotal
; /* yres->bx */
4205 /* si+St_ModeFlag */
4206 modeflag
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
4208 if (!(modeflag
& Charx8Dot
)) {
4213 if ((ModeNo
> 0x13) && (modeflag
& HalfDCLK
))
4216 if ((ModeNo
> 0x13) && (modeflag
& DoubleScanMode
))
4219 if (xres
> xgifb_info
->lvds_data
.LVDSHDE
)
4222 if (yres
> xgifb_info
->lvds_data
.LVDSVDE
)
4225 if (xres
!= xgifb_info
->lvds_data
.LVDSHDE
||
4226 yres
!= xgifb_info
->lvds_data
.LVDSVDE
) {
4227 colordepth
= XGI_GetColorDepth(ModeIdIndex
);
4234 static void xgifb_set_lvds(struct xgifb_video_info
*xgifb_info
,
4236 unsigned short ModeIdIndex
,
4237 struct vb_device_info
*pVBInfo
)
4239 unsigned char temp
, Miscdata
;
4240 unsigned short xres
, yres
, modeflag
, resindex
;
4241 unsigned short LVDSHT
, LVDSHBS
, LVDSHRS
, LVDSHRE
, LVDSHBE
;
4242 unsigned short LVDSVT
, LVDSVBS
, LVDSVRS
, LVDSVRE
, LVDSVBE
;
4243 unsigned short value
;
4245 temp
= (unsigned char) ((xgifb_info
->lvds_data
.LVDS_Capability
&
4246 (LCDPolarity
<< 8)) >> 8);
4247 temp
&= LCDPolarity
;
4248 Miscdata
= inb(pVBInfo
->P3cc
);
4250 outb((Miscdata
& 0x3F) | temp
, pVBInfo
->P3c2
);
4252 temp
= xgifb_info
->lvds_data
.LVDS_Capability
& LCDPolarity
;
4253 /* SR35[7] FP VSync polarity */
4254 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x35, ~0x80, temp
& 0x80);
4255 /* SR30[5] FP HSync polarity */
4256 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x30, ~0x20, (temp
& 0x40) >> 1);
4258 if (chip_id
== XG27
)
4259 XGI_SetXG27FPBits(pVBInfo
);
4261 XGI_SetXG21FPBits(pVBInfo
);
4263 resindex
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
4264 xres
= XGI330_ModeResInfo
[resindex
].HTotal
; /* xres->ax */
4265 yres
= XGI330_ModeResInfo
[resindex
].VTotal
; /* yres->bx */
4266 /* si+St_ModeFlag */
4267 modeflag
= XGI330_EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
4269 if (!(modeflag
& Charx8Dot
))
4270 xres
= xres
* 8 / 9;
4272 LVDSHT
= xgifb_info
->lvds_data
.LVDSHT
;
4274 LVDSHBS
= xres
+ (xgifb_info
->lvds_data
.LVDSHDE
- xres
) / 2;
4276 if (LVDSHBS
> LVDSHT
)
4279 LVDSHRS
= LVDSHBS
+ xgifb_info
->lvds_data
.LVDSHFP
;
4280 if (LVDSHRS
> LVDSHT
)
4283 LVDSHRE
= LVDSHRS
+ xgifb_info
->lvds_data
.LVDSHSYNC
;
4284 if (LVDSHRE
> LVDSHT
)
4287 LVDSHBE
= LVDSHBS
+ LVDSHT
- xgifb_info
->lvds_data
.LVDSHDE
;
4289 LVDSVT
= xgifb_info
->lvds_data
.LVDSVT
;
4291 LVDSVBS
= yres
+ (xgifb_info
->lvds_data
.LVDSVDE
- yres
) / 2;
4292 if (modeflag
& DoubleScanMode
)
4293 LVDSVBS
+= yres
/ 2;
4295 if (LVDSVBS
> LVDSVT
)
4298 LVDSVRS
= LVDSVBS
+ xgifb_info
->lvds_data
.LVDSVFP
;
4299 if (LVDSVRS
> LVDSVT
)
4302 LVDSVRE
= LVDSVRS
+ xgifb_info
->lvds_data
.LVDSVSYNC
;
4303 if (LVDSVRE
> LVDSVT
)
4306 LVDSVBE
= LVDSVBS
+ LVDSVT
- xgifb_info
->lvds_data
.LVDSVDE
;
4308 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x11);
4309 xgifb_reg_set(pVBInfo
->P3d4
, 0x11, temp
& 0x7f); /* Unlock CRTC */
4311 if (!(modeflag
& Charx8Dot
))
4312 xgifb_reg_or(pVBInfo
->P3c4
, 0x1, 0x1);
4314 /* HT SR0B[1:0] CR00 */
4315 value
= (LVDSHT
>> 3) - 5;
4316 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0B, ~0x03, (value
& 0x300) >> 8);
4317 xgifb_reg_set(pVBInfo
->P3d4
, 0x0, (value
& 0xFF));
4319 /* HBS SR0B[5:4] CR02 */
4320 value
= (LVDSHBS
>> 3) - 1;
4321 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0B, ~0x30, (value
& 0x300) >> 4);
4322 xgifb_reg_set(pVBInfo
->P3d4
, 0x2, (value
& 0xFF));
4324 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
4325 value
= (LVDSHBE
>> 3) - 1;
4326 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0C, ~0x03, (value
& 0xC0) >> 6);
4327 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x05, ~0x80, (value
& 0x20) << 2);
4328 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x03, ~0x1F, value
& 0x1F);
4330 /* HRS SR0B[7:6] CR04 */
4331 value
= (LVDSHRS
>> 3) + 2;
4332 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0B, ~0xC0, (value
& 0x300) >> 2);
4333 xgifb_reg_set(pVBInfo
->P3d4
, 0x4, (value
& 0xFF));
4335 /* Panel HRS SR2F[1:0] SR2E[7:0] */
4337 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x2F, ~0x03, (value
& 0x300) >> 8);
4338 xgifb_reg_set(pVBInfo
->P3c4
, 0x2E, (value
& 0xFF));
4340 /* HRE SR0C[2] CR05[4:0] */
4341 value
= (LVDSHRE
>> 3) + 2;
4342 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0C, ~0x04, (value
& 0x20) >> 3);
4343 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x05, ~0x1F, value
& 0x1F);
4345 /* Panel HRE SR2F[7:2] */
4347 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x2F, ~0xFC, value
<< 2);
4349 /* VT SR0A[0] CR07[5][0] CR06 */
4351 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0A, ~0x01, (value
& 0x400) >> 10);
4352 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x07, ~0x20, (value
& 0x200) >> 4);
4353 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x07, ~0x01, (value
& 0x100) >> 8);
4354 xgifb_reg_set(pVBInfo
->P3d4
, 0x06, (value
& 0xFF));
4356 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
4357 value
= LVDSVBS
- 1;
4358 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0A, ~0x04, (value
& 0x400) >> 8);
4359 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x09, ~0x20, (value
& 0x200) >> 4);
4360 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x07, ~0x08, (value
& 0x100) >> 5);
4361 xgifb_reg_set(pVBInfo
->P3d4
, 0x15, (value
& 0xFF));
4363 /* VBE SR0A[4] CR16 */
4364 value
= LVDSVBE
- 1;
4365 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0A, ~0x10, (value
& 0x100) >> 4);
4366 xgifb_reg_set(pVBInfo
->P3d4
, 0x16, (value
& 0xFF));
4368 /* VRS SR0A[3] CR7[7][2] CR10 */
4369 value
= LVDSVRS
- 1;
4370 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0A, ~0x08, (value
& 0x400) >> 7);
4371 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x07, ~0x80, (value
& 0x200) >> 2);
4372 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x07, ~0x04, (value
& 0x100) >> 6);
4373 xgifb_reg_set(pVBInfo
->P3d4
, 0x10, (value
& 0xFF));
4375 if (chip_id
== XG27
) {
4376 /* Panel VRS SR35[2:0] SR34[7:0] */
4377 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x35, ~0x07,
4378 (value
& 0x700) >> 8);
4379 xgifb_reg_set(pVBInfo
->P3c4
, 0x34, value
& 0xFF);
4381 /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */
4382 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x3F, ~0x03,
4383 (value
& 0x600) >> 9);
4384 xgifb_reg_set(pVBInfo
->P3c4
, 0x34, (value
>> 1) & 0xFF);
4385 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x33, ~0x01, value
& 0x01);
4388 /* VRE SR0A[5] CR11[3:0] */
4389 value
= LVDSVRE
- 1;
4390 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0A, ~0x20, (value
& 0x10) << 1);
4391 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x11, ~0x0F, value
& 0x0F);
4393 /* Panel VRE SR3F[7:2] */
4394 if (chip_id
== XG27
)
4395 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x3F, ~0xFC,
4396 (value
<< 2) & 0xFC);
4398 /* SR3F[7] has to be 0, h/w bug */
4399 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x3F, ~0xFC,
4400 (value
<< 2) & 0x7C);
4402 for (temp
= 0, value
= 0; temp
< 3; temp
++) {
4404 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x31, ~0x30, value
);
4405 xgifb_reg_set(pVBInfo
->P3c4
,
4406 0x2B, xgifb_info
->lvds_data
.VCLKData1
);
4407 xgifb_reg_set(pVBInfo
->P3c4
,
4408 0x2C, xgifb_info
->lvds_data
.VCLKData2
);
4412 if (!(modeflag
& Charx8Dot
)) {
4413 inb(pVBInfo
->P3da
); /* reset 3da */
4414 outb(0x13, pVBInfo
->P3c0
); /* set index */
4415 /* set data, panning = 0, shift left 1 dot*/
4416 outb(0x00, pVBInfo
->P3c0
);
4418 inb(pVBInfo
->P3da
); /* Enable Attribute */
4419 outb(0x20, pVBInfo
->P3c0
);
4421 inb(pVBInfo
->P3da
); /* reset 3da */
4426 /* --------------------------------------------------------------------- */
4427 /* Function : XGI_IsLCDON */
4429 /* Output : 0 : Skip PSC Control */
4430 /* 1: Disable PSC */
4432 /* --------------------------------------------------------------------- */
4433 static unsigned char XGI_IsLCDON(struct vb_device_info
*pVBInfo
)
4435 unsigned short tempax
;
4437 tempax
= pVBInfo
->VBInfo
;
4438 if (tempax
& SetCRT2ToDualEdge
)
4440 else if (tempax
& (DisableCRT2Display
| SwitchCRT2
| SetSimuScanMode
))
4446 static void XGI_DisableBridge(struct xgifb_video_info
*xgifb_info
,
4447 struct xgi_hw_device_info
*HwDeviceExtension
,
4448 struct vb_device_info
*pVBInfo
)
4450 unsigned short tempah
= 0;
4452 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
4453 | VB_SIS302LV
| VB_XGI301C
)) {
4455 if (!(pVBInfo
->VBInfo
&
4456 (DisableCRT2Display
| SetSimuScanMode
))) {
4457 if (pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
) {
4458 if (pVBInfo
->VBInfo
& SetCRT2ToDualEdge
)
4459 tempah
= 0x7F; /* Disable Channel A */
4463 /* disable part4_1f */
4464 xgifb_reg_and(pVBInfo
->Part4Port
, 0x1F, tempah
);
4466 if (pVBInfo
->VBType
& (VB_SIS302LV
| VB_XGI301C
)) {
4467 if (((pVBInfo
->VBInfo
&
4468 (SetCRT2ToLCD
| XGI_SetCRT2ToLCDA
))) ||
4469 (XGI_IsLCDON(pVBInfo
)))
4470 /* LVDS Driver power down */
4471 xgifb_reg_or(pVBInfo
->Part4Port
, 0x30, 0x80);
4474 if (pVBInfo
->VBInfo
& (DisableCRT2Display
| XGI_SetCRT2ToLCDA
|
4476 XGI_DisplayOff(xgifb_info
, HwDeviceExtension
, pVBInfo
);
4478 if (pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
)
4480 xgifb_reg_and(pVBInfo
->Part1Port
, 0x1e, 0xdf);
4482 /* disable TV as primary VGA swap */
4483 xgifb_reg_and(pVBInfo
->P3c4
, 0x32, 0xdf);
4485 if ((pVBInfo
->VBInfo
& (SetSimuScanMode
| SetCRT2ToDualEdge
)))
4486 xgifb_reg_and(pVBInfo
->Part2Port
, 0x00, 0xdf);
4488 if ((pVBInfo
->VBInfo
&
4489 (DisableCRT2Display
| SetSimuScanMode
)) ||
4490 ((!(pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
)) &&
4492 (SetCRT2ToRAMDAC
| SetCRT2ToLCD
| SetCRT2ToTV
))))
4493 xgifb_reg_or(pVBInfo
->Part1Port
, 0x00, 0x80);
4495 if ((pVBInfo
->VBInfo
&
4496 (DisableCRT2Display
| SetSimuScanMode
)) ||
4497 (!(pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
)) ||
4499 (SetCRT2ToRAMDAC
| SetCRT2ToLCD
| SetCRT2ToTV
))) {
4500 /* save Part1 index 0 */
4501 tempah
= xgifb_reg_get(pVBInfo
->Part1Port
, 0x00);
4502 /* BTDAC = 1, avoid VB reset */
4503 xgifb_reg_or(pVBInfo
->Part1Port
, 0x00, 0x10);
4505 xgifb_reg_and(pVBInfo
->Part1Port
, 0x1E, 0xDF);
4506 /* restore Part1 index 0 */
4507 xgifb_reg_set(pVBInfo
->Part1Port
, 0x00, tempah
);
4509 } else { /* {301} */
4510 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToTV
)) {
4511 xgifb_reg_or(pVBInfo
->Part1Port
, 0x00, 0x80);
4513 xgifb_reg_and(pVBInfo
->Part1Port
, 0x1E, 0xDF);
4514 /* Disable TV asPrimary VGA swap */
4515 xgifb_reg_and(pVBInfo
->P3c4
, 0x32, 0xDF);
4518 if (pVBInfo
->VBInfo
& (DisableCRT2Display
| XGI_SetCRT2ToLCDA
4520 XGI_DisplayOff(xgifb_info
, HwDeviceExtension
, pVBInfo
);
4524 /* --------------------------------------------------------------------- */
4525 /* Function : XGI_GetTVPtrIndex */
4528 /* Description : bx 0 : ExtNTSC */
4540 /* --------------------------------------------------------------------- */
4541 static unsigned short XGI_GetTVPtrIndex(struct vb_device_info
*pVBInfo
)
4543 unsigned short tempbx
= 0;
4545 if (pVBInfo
->TVInfo
& TVSetPAL
)
4547 if (pVBInfo
->TVInfo
& TVSetHiVision
)
4549 if (pVBInfo
->TVInfo
& TVSetYPbPr525i
)
4551 if (pVBInfo
->TVInfo
& TVSetYPbPr525p
)
4553 if (pVBInfo
->TVInfo
& TVSetYPbPr750p
)
4555 if (pVBInfo
->TVInfo
& TVSimuMode
)
4561 /* --------------------------------------------------------------------- */
4562 /* Function : XGI_GetTVPtrIndex2 */
4564 /* Output : bx 0 : NTSC */
4568 /* 4 : NTSC1024x768 */
4569 /* 5 : PAL-M 1024x768 */
4571 /* cl 0 : YFilter1 */
4574 /* 1 : 301B/302B/301LV/302LV */
4576 /* --------------------------------------------------------------------- */
4577 static void XGI_GetTVPtrIndex2(unsigned short *tempbx
, unsigned char *tempcl
,
4578 unsigned char *tempch
, struct vb_device_info
*pVBInfo
)
4584 if (pVBInfo
->TVInfo
& TVSetPAL
)
4587 if (pVBInfo
->TVInfo
& TVSetPALM
)
4590 if (pVBInfo
->TVInfo
& TVSetPALN
)
4593 if (pVBInfo
->TVInfo
& NTSC1024x768
) {
4595 if (pVBInfo
->TVInfo
& TVSetPALM
)
4599 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
4600 | VB_SIS302LV
| VB_XGI301C
)) {
4601 if ((!(pVBInfo
->VBInfo
& SetInSlaveMode
)) || (pVBInfo
->TVInfo
4608 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
4609 | VB_SIS302LV
| VB_XGI301C
))
4613 static void XGI_SetDelayComp(struct vb_device_info
*pVBInfo
)
4615 unsigned char tempah
, tempbl
, tempbh
;
4617 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
4618 | VB_SIS302LV
| VB_XGI301C
)) {
4619 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| XGI_SetCRT2ToLCDA
4620 | SetCRT2ToTV
| SetCRT2ToRAMDAC
)) {
4622 tempbl
= XGI301TVDelay
;
4624 if (pVBInfo
->VBInfo
& SetCRT2ToDualEdge
)
4625 tempbl
= tempbl
>> 4;
4626 if (pVBInfo
->VBInfo
&
4627 (SetCRT2ToLCD
| XGI_SetCRT2ToLCDA
)) {
4628 tempbh
= XGI301LCDDelay
;
4630 if (!(pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
))
4636 tempah
= xgifb_reg_get(pVBInfo
->Part1Port
, 0x2D);
4638 if (pVBInfo
->VBInfo
& (SetCRT2ToRAMDAC
| SetCRT2ToLCD
4639 | SetCRT2ToTV
)) { /* Channel B */
4644 if (pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
) {
4649 xgifb_reg_set(pVBInfo
->Part1Port
, 0x2D, tempah
);
4654 static void XGI_SetLCDCap_A(unsigned short tempcx
,
4655 struct vb_device_info
*pVBInfo
)
4657 unsigned short temp
;
4659 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x37);
4661 if (temp
& LCDRGB18Bit
) {
4662 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x19, 0x0F,
4664 (unsigned short) (0x20 | (tempcx
& 0x00C0)));
4665 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x1A, 0x7F, 0x80);
4667 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x19, 0x0F,
4668 (unsigned short) (0x30 | (tempcx
& 0x00C0)));
4669 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x1A, 0x7F, 0x00);
4673 /* --------------------------------------------------------------------- */
4674 /* Function : XGI_SetLCDCap_B */
4675 /* Input : cx -> LCD Capability */
4678 /* --------------------------------------------------------------------- */
4679 static void XGI_SetLCDCap_B(unsigned short tempcx
,
4680 struct vb_device_info
*pVBInfo
)
4682 if (tempcx
& EnableLCD24bpp
) /* 24bits */
4683 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x1A, 0xE0,
4684 (unsigned short) (((tempcx
& 0x00ff) >> 6)
4687 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x1A, 0xE0,
4688 (unsigned short) (((tempcx
& 0x00ff) >> 6)
4689 | 0x18)); /* Enable Dither */
4692 static void XGI_LongWait(struct vb_device_info
*pVBInfo
)
4696 i
= xgifb_reg_get(pVBInfo
->P3c4
, 0x1F);
4699 for (i
= 0; i
< 0xFFFF; i
++) {
4700 if (!(inb(pVBInfo
->P3da
) & 0x08))
4704 for (i
= 0; i
< 0xFFFF; i
++) {
4705 if ((inb(pVBInfo
->P3da
) & 0x08))
4711 static void SetSpectrum(struct vb_device_info
*pVBInfo
)
4713 unsigned short index
;
4715 index
= XGI_GetLCDCapPtr(pVBInfo
);
4717 /* disable down spectrum D[4] */
4718 xgifb_reg_and(pVBInfo
->Part4Port
, 0x30, 0x8F);
4719 XGI_LongWait(pVBInfo
);
4720 xgifb_reg_or(pVBInfo
->Part4Port
, 0x30, 0x20); /* reset spectrum */
4721 XGI_LongWait(pVBInfo
);
4723 xgifb_reg_set(pVBInfo
->Part4Port
, 0x31,
4724 pVBInfo
->LCDCapList
[index
].Spectrum_31
);
4725 xgifb_reg_set(pVBInfo
->Part4Port
, 0x32,
4726 pVBInfo
->LCDCapList
[index
].Spectrum_32
);
4727 xgifb_reg_set(pVBInfo
->Part4Port
, 0x33,
4728 pVBInfo
->LCDCapList
[index
].Spectrum_33
);
4729 xgifb_reg_set(pVBInfo
->Part4Port
, 0x34,
4730 pVBInfo
->LCDCapList
[index
].Spectrum_34
);
4731 XGI_LongWait(pVBInfo
);
4732 xgifb_reg_or(pVBInfo
->Part4Port
, 0x30, 0x40); /* enable spectrum */
4735 static void XGI_SetLCDCap(struct vb_device_info
*pVBInfo
)
4737 unsigned short tempcx
;
4739 tempcx
= pVBInfo
->LCDCapList
[XGI_GetLCDCapPtr(pVBInfo
)].LCD_Capability
;
4741 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
|
4742 VB_SIS302LV
| VB_XGI301C
)) {
4743 if (pVBInfo
->VBType
&
4744 (VB_SIS301LV
| VB_SIS302LV
| VB_XGI301C
)) {
4745 /* Set 301LV Capability */
4746 xgifb_reg_set(pVBInfo
->Part4Port
, 0x24,
4747 (unsigned char) (tempcx
& 0x1F));
4750 xgifb_reg_and_or(pVBInfo
->Part4Port
, 0x0D,
4751 ~((EnableVBCLKDRVLOW
| EnablePLLSPLOW
) >> 8),
4752 (unsigned short) ((tempcx
& (EnableVBCLKDRVLOW
4753 | EnablePLLSPLOW
)) >> 8));
4755 if (pVBInfo
->VBInfo
& SetCRT2ToLCD
)
4756 XGI_SetLCDCap_B(tempcx
, pVBInfo
);
4757 else if (pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
)
4758 XGI_SetLCDCap_A(tempcx
, pVBInfo
);
4760 if (pVBInfo
->VBType
& (VB_SIS302LV
| VB_XGI301C
)) {
4761 if (tempcx
& EnableSpectrum
)
4762 SetSpectrum(pVBInfo
);
4766 XGI_SetLCDCap_A(tempcx
, pVBInfo
);
4770 /* --------------------------------------------------------------------- */
4771 /* Function : XGI_SetAntiFlicker */
4774 /* Description : Set TV Customized Param. */
4775 /* --------------------------------------------------------------------- */
4776 static void XGI_SetAntiFlicker(struct vb_device_info
*pVBInfo
)
4778 unsigned short tempbx
;
4780 unsigned char tempah
;
4782 if (pVBInfo
->TVInfo
& (TVSetYPbPr525p
| TVSetYPbPr750p
))
4785 tempbx
= XGI_GetTVPtrIndex(pVBInfo
);
4787 tempah
= TVAntiFlickList
[tempbx
];
4788 tempah
= tempah
<< 4;
4790 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x0A, 0x8F, tempah
);
4793 static void XGI_SetEdgeEnhance(struct vb_device_info
*pVBInfo
)
4795 unsigned short tempbx
;
4797 unsigned char tempah
;
4799 tempbx
= XGI_GetTVPtrIndex(pVBInfo
);
4801 tempah
= TVEdgeList
[tempbx
];
4802 tempah
= tempah
<< 5;
4804 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x3A, 0x1F, tempah
);
4807 static void XGI_SetPhaseIncr(struct vb_device_info
*pVBInfo
)
4809 unsigned short tempbx
;
4811 unsigned char tempcl
, tempch
;
4813 unsigned long tempData
;
4815 XGI_GetTVPtrIndex2(&tempbx
, &tempcl
, &tempch
, pVBInfo
); /* bx, cl, ch */
4816 tempData
= TVPhaseList
[tempbx
];
4818 xgifb_reg_set(pVBInfo
->Part2Port
, 0x31, (unsigned short) (tempData
4820 xgifb_reg_set(pVBInfo
->Part2Port
, 0x32, (unsigned short) ((tempData
4821 & 0x0000FF00) >> 8));
4822 xgifb_reg_set(pVBInfo
->Part2Port
, 0x33, (unsigned short) ((tempData
4823 & 0x00FF0000) >> 16));
4824 xgifb_reg_set(pVBInfo
->Part2Port
, 0x34, (unsigned short) ((tempData
4825 & 0xFF000000) >> 24));
4828 static void XGI_SetYFilter(unsigned short ModeIdIndex
,
4829 struct vb_device_info
*pVBInfo
)
4831 unsigned short tempbx
, index
;
4832 unsigned char const *filterPtr
;
4833 unsigned char tempcl
, tempch
, tempal
;
4835 XGI_GetTVPtrIndex2(&tempbx
, &tempcl
, &tempch
, pVBInfo
); /* bx, cl, ch */
4840 filterPtr
= NTSCYFilter1
;
4844 filterPtr
= PALYFilter1
;
4851 filterPtr
= xgifb_palmn_yfilter1
;
4859 filterPtr
= xgifb_yfilter2
;
4866 tempal
= XGI330_EModeIDTable
[ModeIdIndex
].VB_ExtTVYFilterIndex
;
4872 if ((tempcl
== 0) && (tempch
== 1)) {
4873 xgifb_reg_set(pVBInfo
->Part2Port
, 0x35, 0);
4874 xgifb_reg_set(pVBInfo
->Part2Port
, 0x36, 0);
4875 xgifb_reg_set(pVBInfo
->Part2Port
, 0x37, 0);
4876 xgifb_reg_set(pVBInfo
->Part2Port
, 0x38, filterPtr
[index
++]);
4878 xgifb_reg_set(pVBInfo
->Part2Port
, 0x35, filterPtr
[index
++]);
4879 xgifb_reg_set(pVBInfo
->Part2Port
, 0x36, filterPtr
[index
++]);
4880 xgifb_reg_set(pVBInfo
->Part2Port
, 0x37, filterPtr
[index
++]);
4881 xgifb_reg_set(pVBInfo
->Part2Port
, 0x38, filterPtr
[index
++]);
4884 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
4885 | VB_SIS302LV
| VB_XGI301C
)) {
4886 xgifb_reg_set(pVBInfo
->Part2Port
, 0x48, filterPtr
[index
++]);
4887 xgifb_reg_set(pVBInfo
->Part2Port
, 0x49, filterPtr
[index
++]);
4888 xgifb_reg_set(pVBInfo
->Part2Port
, 0x4A, filterPtr
[index
++]);
4892 /* --------------------------------------------------------------------- */
4893 /* Function : XGI_OEM310Setting */
4896 /* Description : Customized Param. for 301 */
4897 /* --------------------------------------------------------------------- */
4898 static void XGI_OEM310Setting(unsigned short ModeIdIndex
,
4899 struct vb_device_info
*pVBInfo
)
4901 XGI_SetDelayComp(pVBInfo
);
4903 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| XGI_SetCRT2ToLCDA
))
4904 XGI_SetLCDCap(pVBInfo
);
4906 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
4907 XGI_SetPhaseIncr(pVBInfo
);
4908 XGI_SetYFilter(ModeIdIndex
, pVBInfo
);
4909 XGI_SetAntiFlicker(pVBInfo
);
4911 if (pVBInfo
->VBType
& VB_SIS301
)
4912 XGI_SetEdgeEnhance(pVBInfo
);
4916 /* --------------------------------------------------------------------- */
4917 /* Function : XGI_SetCRT2ModeRegs */
4920 /* Description : Origin code for crt2group */
4921 /* --------------------------------------------------------------------- */
4922 static void XGI_SetCRT2ModeRegs(struct vb_device_info
*pVBInfo
)
4924 unsigned short tempbl
;
4927 unsigned char tempah
;
4930 if (!(pVBInfo
->VBInfo
& DisableCRT2Display
)) {
4931 tempah
= xgifb_reg_get(pVBInfo
->Part1Port
, 0x00);
4932 tempah
&= ~0x10; /* BTRAMDAC */
4933 tempah
|= 0x40; /* BTRAM */
4935 if (pVBInfo
->VBInfo
& (SetCRT2ToRAMDAC
| SetCRT2ToTV
4937 tempah
= 0x40; /* BTDRAM */
4938 tempcl
= pVBInfo
->ModeType
;
4942 tempah
= (0x008 >> tempcl
);
4947 if (pVBInfo
->VBInfo
& SetInSlaveMode
)
4948 tempah
^= 0x50; /* BTDAC */
4952 xgifb_reg_set(pVBInfo
->Part1Port
, 0x00, tempah
);
4956 if (pVBInfo
->VBInfo
& DisableCRT2Display
)
4962 if (!(pVBInfo
->VBInfo
& (SetCRT2ToRAMDAC
| SetCRT2ToTV
|
4963 SetCRT2ToLCD
| XGI_SetCRT2ToLCDA
)))
4966 if ((pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
) &&
4967 (!(pVBInfo
->VBInfo
& SetSimuScanMode
))) {
4973 if (pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
) {
4978 if (!(pVBInfo
->VBInfo
& (SetCRT2ToRAMDAC
| SetCRT2ToTV
| SetCRT2ToLCD
)))
4984 if (!(pVBInfo
->VBInfo
& SetInSlaveMode
))
4987 if (!(pVBInfo
->VBInfo
& SetCRT2ToRAMDAC
)) {
4988 tempah
= tempah
^ 0x05;
4989 if (!(pVBInfo
->VBInfo
& SetCRT2ToLCD
))
4990 tempah
= tempah
^ 0x01;
4993 if (!(pVBInfo
->VBInfo
& SetCRT2ToDualEdge
))
4997 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x2e, tempbl
, tempah
);
4999 if (pVBInfo
->VBInfo
& (SetCRT2ToRAMDAC
| SetCRT2ToTV
| SetCRT2ToLCD
5000 | XGI_SetCRT2ToLCDA
)) {
5002 if ((pVBInfo
->ModeType
== ModeVGA
) && (!(pVBInfo
->VBInfo
5003 & SetInSlaveMode
))) {
5008 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
5010 if (pVBInfo
->VBInfo
& DriverMode
)
5011 tempah
= tempah
^ 0x20;
5014 xgifb_reg_and_or(pVBInfo
->Part4Port
, 0x0D, ~0x0BF, tempah
);
5017 if (pVBInfo
->LCDInfo
& SetLCDDualLink
)
5020 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
5021 if (pVBInfo
->TVInfo
& RPLLDIV2XO
)
5025 if ((pVBInfo
->LCDResInfo
== Panel_1280x1024
)
5026 || (pVBInfo
->LCDResInfo
== Panel_1280x1024x75
))
5029 if (pVBInfo
->LCDResInfo
== Panel_1280x960
)
5032 xgifb_reg_set(pVBInfo
->Part4Port
, 0x0C, tempah
);
5035 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
5036 | VB_SIS302LV
| VB_XGI301C
)) {
5040 if (pVBInfo
->VBInfo
& SetCRT2ToDualEdge
) {
5042 if (pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
)
5043 tempah
|= 0x04; /* shampoo 0129 */
5046 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x13, tempbl
, tempah
);
5049 if (!(pVBInfo
->VBInfo
& DisableCRT2Display
)) {
5050 if (pVBInfo
->VBInfo
& SetCRT2ToDualEdge
)
5054 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x2c, tempbl
, tempah
);
5058 if (!(pVBInfo
->VBInfo
& DisableCRT2Display
)) {
5059 if (pVBInfo
->VBInfo
& SetCRT2ToDualEdge
)
5062 xgifb_reg_and_or(pVBInfo
->Part4Port
, 0x21, tempbl
, tempah
);
5067 if (!(pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
)) {
5069 if (!(pVBInfo
->VBInfo
& SetCRT2ToDualEdge
))
5073 xgifb_reg_and_or(pVBInfo
->Part4Port
, 0x23, tempbl
, tempah
);
5075 if (pVBInfo
->VBType
& (VB_SIS302LV
| VB_XGI301C
)) {
5076 if (pVBInfo
->LCDInfo
& SetLCDDualLink
) {
5077 xgifb_reg_or(pVBInfo
->Part4Port
, 0x27, 0x20);
5078 xgifb_reg_or(pVBInfo
->Part4Port
, 0x34, 0x10);
5084 void XGI_UnLockCRT2(struct vb_device_info
*pVBInfo
)
5086 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x2f, 0xFF, 0x01);
5089 void XGI_LockCRT2(struct vb_device_info
*pVBInfo
)
5091 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x2F, 0xFE, 0x00);
5094 unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info
*pXGIHWDE
,
5095 unsigned short ModeNo
, unsigned short ModeIdIndex
,
5096 struct vb_device_info
*pVBInfo
)
5098 const u8 LCDARefreshIndex
[] = {
5099 0x00, 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x00 };
5101 unsigned short RefreshRateTableIndex
, i
, index
, temp
;
5103 index
= xgifb_reg_get(pVBInfo
->P3d4
, 0x33);
5104 index
= index
>> pVBInfo
->SelectCRT2Rate
;
5107 if (pVBInfo
->LCDInfo
& LCDNonExpanding
)
5113 if (pVBInfo
->SetFlag
& ProgrammingCRT2
) {
5114 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| XGI_SetCRT2ToLCDA
)) {
5115 temp
= LCDARefreshIndex
[pVBInfo
->LCDResInfo
& 0x07];
5122 RefreshRateTableIndex
= XGI330_EModeIDTable
[ModeIdIndex
].REFindex
;
5123 ModeNo
= XGI330_RefIndex
[RefreshRateTableIndex
].ModeID
;
5124 if (pXGIHWDE
->jChipType
>= XG20
) { /* for XG20, XG21, XG27 */
5125 if ((XGI330_RefIndex
[RefreshRateTableIndex
].XRes
== 800) &&
5126 (XGI330_RefIndex
[RefreshRateTableIndex
].YRes
== 600)) {
5129 /* do the similar adjustment like XGISearchCRT1Rate() */
5130 if ((XGI330_RefIndex
[RefreshRateTableIndex
].XRes
== 1024) &&
5131 (XGI330_RefIndex
[RefreshRateTableIndex
].YRes
== 768)) {
5134 if ((XGI330_RefIndex
[RefreshRateTableIndex
].XRes
== 1280) &&
5135 (XGI330_RefIndex
[RefreshRateTableIndex
].YRes
== 1024)) {
5142 if (XGI330_RefIndex
[RefreshRateTableIndex
+ i
].
5145 temp
= XGI330_RefIndex
[RefreshRateTableIndex
+ i
].Ext_InfoFlag
;
5146 temp
&= ModeTypeMask
;
5147 if (temp
< pVBInfo
->ModeType
)
5152 } while (index
!= 0xFFFF);
5153 if (!(pVBInfo
->VBInfo
& SetCRT2ToRAMDAC
)) {
5154 if (pVBInfo
->VBInfo
& SetInSlaveMode
) {
5155 temp
= XGI330_RefIndex
[RefreshRateTableIndex
+ i
- 1].
5157 if (temp
& InterlaceMode
)
5162 if ((pVBInfo
->SetFlag
& ProgrammingCRT2
)) {
5163 temp
= XGI_AjustCRT2Rate(ModeIdIndex
, RefreshRateTableIndex
,
5166 return RefreshRateTableIndex
+ i
;
5169 static void XGI_SetLCDAGroup(unsigned short ModeNo
, unsigned short ModeIdIndex
,
5170 struct xgi_hw_device_info
*HwDeviceExtension
,
5171 struct vb_device_info
*pVBInfo
)
5173 unsigned short RefreshRateTableIndex
;
5175 pVBInfo
->SetFlag
|= ProgrammingCRT2
;
5176 RefreshRateTableIndex
= XGI_GetRatePtrCRT2(HwDeviceExtension
, ModeNo
,
5177 ModeIdIndex
, pVBInfo
);
5178 XGI_GetLVDSResInfo(ModeIdIndex
, pVBInfo
);
5179 XGI_GetLVDSData(ModeIdIndex
, pVBInfo
);
5180 XGI_ModCRT1Regs(ModeIdIndex
, HwDeviceExtension
, pVBInfo
);
5181 XGI_SetLVDSRegs(ModeIdIndex
, pVBInfo
);
5182 XGI_SetCRT2ECLK(ModeIdIndex
, RefreshRateTableIndex
, pVBInfo
);
5185 static unsigned char XGI_SetCRT2Group301(unsigned short ModeNo
,
5186 struct xgi_hw_device_info
*HwDeviceExtension
,
5187 struct vb_device_info
*pVBInfo
)
5189 unsigned short ModeIdIndex
, RefreshRateTableIndex
;
5191 pVBInfo
->SetFlag
|= ProgrammingCRT2
;
5192 XGI_SearchModeID(ModeNo
, &ModeIdIndex
);
5193 pVBInfo
->SelectCRT2Rate
= 4;
5194 RefreshRateTableIndex
= XGI_GetRatePtrCRT2(HwDeviceExtension
, ModeNo
,
5195 ModeIdIndex
, pVBInfo
);
5196 XGI_SaveCRT2Info(ModeNo
, pVBInfo
);
5197 XGI_GetCRT2ResInfo(ModeIdIndex
, pVBInfo
);
5198 XGI_GetCRT2Data(ModeIdIndex
, RefreshRateTableIndex
, pVBInfo
);
5199 XGI_PreSetGroup1(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
, pVBInfo
);
5200 XGI_SetGroup1(ModeIdIndex
, RefreshRateTableIndex
, pVBInfo
);
5201 XGI_SetLockRegs(ModeNo
, ModeIdIndex
, pVBInfo
);
5202 XGI_SetGroup2(ModeNo
, ModeIdIndex
, pVBInfo
);
5203 XGI_SetLCDRegs(ModeIdIndex
, pVBInfo
);
5204 XGI_SetTap4Regs(pVBInfo
);
5205 XGI_SetGroup3(ModeIdIndex
, pVBInfo
);
5206 XGI_SetGroup4(ModeIdIndex
, RefreshRateTableIndex
, pVBInfo
);
5207 XGI_SetCRT2VCLK(ModeIdIndex
, RefreshRateTableIndex
, pVBInfo
);
5208 XGI_SetGroup5(pVBInfo
);
5209 XGI_AutoThreshold(pVBInfo
);
5213 void XGI_SenseCRT1(struct vb_device_info
*pVBInfo
)
5215 unsigned char CRTCData
[17] = { 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81,
5216 0x0B, 0x3E, 0xE9, 0x0B, 0xDF, 0xE7, 0x04, 0x00, 0x00,
5219 unsigned char SR01
= 0, SR1F
= 0, SR07
= 0, SR06
= 0;
5221 unsigned char CR17
, CR63
, SR31
;
5222 unsigned short temp
;
5226 xgifb_reg_set(pVBInfo
->P3c4
, 0x05, 0x86);
5228 /* to fix XG42 single LCD sense to CRT+LCD */
5229 xgifb_reg_set(pVBInfo
->P3d4
, 0x57, 0x4A);
5230 xgifb_reg_set(pVBInfo
->P3d4
, 0x53, (xgifb_reg_get(
5231 pVBInfo
->P3d4
, 0x53) | 0x02));
5233 SR31
= xgifb_reg_get(pVBInfo
->P3c4
, 0x31);
5234 CR63
= xgifb_reg_get(pVBInfo
->P3d4
, 0x63);
5235 SR01
= xgifb_reg_get(pVBInfo
->P3c4
, 0x01);
5237 xgifb_reg_set(pVBInfo
->P3c4
, 0x01, (unsigned char) (SR01
& 0xDF));
5238 xgifb_reg_set(pVBInfo
->P3d4
, 0x63, (unsigned char) (CR63
& 0xBF));
5240 CR17
= xgifb_reg_get(pVBInfo
->P3d4
, 0x17);
5241 xgifb_reg_set(pVBInfo
->P3d4
, 0x17, (unsigned char) (CR17
| 0x80));
5243 SR1F
= xgifb_reg_get(pVBInfo
->P3c4
, 0x1F);
5244 xgifb_reg_set(pVBInfo
->P3c4
, 0x1F, (unsigned char) (SR1F
| 0x04));
5246 SR07
= xgifb_reg_get(pVBInfo
->P3c4
, 0x07);
5247 xgifb_reg_set(pVBInfo
->P3c4
, 0x07, (unsigned char) (SR07
& 0xFB));
5248 SR06
= xgifb_reg_get(pVBInfo
->P3c4
, 0x06);
5249 xgifb_reg_set(pVBInfo
->P3c4
, 0x06, (unsigned char) (SR06
& 0xC3));
5251 xgifb_reg_set(pVBInfo
->P3d4
, 0x11, 0x00);
5253 for (i
= 0; i
< 8; i
++)
5254 xgifb_reg_set(pVBInfo
->P3d4
, (unsigned short) i
, CRTCData
[i
]);
5256 for (i
= 8; i
< 11; i
++)
5257 xgifb_reg_set(pVBInfo
->P3d4
, (unsigned short) (i
+ 8),
5260 for (i
= 11; i
< 13; i
++)
5261 xgifb_reg_set(pVBInfo
->P3d4
, (unsigned short) (i
+ 4),
5264 for (i
= 13; i
< 16; i
++)
5265 xgifb_reg_set(pVBInfo
->P3c4
, (unsigned short) (i
- 3),
5268 xgifb_reg_set(pVBInfo
->P3c4
, 0x0E, (unsigned char) (CRTCData
[16]
5271 xgifb_reg_set(pVBInfo
->P3c4
, 0x31, 0x00);
5272 xgifb_reg_set(pVBInfo
->P3c4
, 0x2B, 0x1B);
5273 xgifb_reg_set(pVBInfo
->P3c4
, 0x2C, 0xE1);
5275 outb(0x00, pVBInfo
->P3c8
);
5277 for (i
= 0; i
< 256 * 3; i
++)
5278 outb(0x0F, (pVBInfo
->P3c8
+ 1)); /* DAC_TEST_PARMS */
5282 XGI_WaitDisply(pVBInfo
);
5283 temp
= inb(pVBInfo
->P3c2
);
5286 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x32, 0xDF, 0x20);
5288 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x32, 0xDF, 0x00);
5290 /* avoid display something, set BLACK DAC if not restore DAC */
5291 outb(0x00, pVBInfo
->P3c8
);
5293 for (i
= 0; i
< 256 * 3; i
++)
5294 outb(0, (pVBInfo
->P3c8
+ 1));
5296 xgifb_reg_set(pVBInfo
->P3c4
, 0x01, SR01
);
5297 xgifb_reg_set(pVBInfo
->P3d4
, 0x63, CR63
);
5298 xgifb_reg_set(pVBInfo
->P3c4
, 0x31, SR31
);
5300 xgifb_reg_set(pVBInfo
->P3d4
, 0x53, (xgifb_reg_get(
5301 pVBInfo
->P3d4
, 0x53) & 0xFD));
5302 xgifb_reg_set(pVBInfo
->P3c4
, 0x1F, (unsigned char) SR1F
);
5305 static void XGI_EnableBridge(struct xgifb_video_info
*xgifb_info
,
5306 struct xgi_hw_device_info
*HwDeviceExtension
,
5307 struct vb_device_info
*pVBInfo
)
5309 unsigned short tempah
;
5311 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
5312 | VB_SIS302LV
| VB_XGI301C
)) {
5313 if (pVBInfo
->VBInfo
& SetCRT2ToDualEdge
)
5315 xgifb_reg_set(pVBInfo
->Part1Port
, 0x1E, 0x20);
5317 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToTV
|
5319 tempah
= xgifb_reg_get(pVBInfo
->P3c4
, 0x32);
5321 if (pVBInfo
->VBInfo
& SetInSlaveMode
) {
5322 if (!(pVBInfo
->VBInfo
& SetCRT2ToRAMDAC
))
5325 xgifb_reg_set(pVBInfo
->P3c4
, 0x32, tempah
);
5326 xgifb_reg_or(pVBInfo
->P3c4
, 0x1E, 0x20);
5328 tempah
= xgifb_reg_get(pVBInfo
->Part1Port
, 0x2E);
5330 if (!(tempah
& 0x80))
5331 xgifb_reg_or(pVBInfo
->Part1Port
, 0x2E, 0x80);
5332 xgifb_reg_and(pVBInfo
->Part1Port
, 0x00, 0x7F);
5335 if (!(pVBInfo
->VBInfo
& DisableCRT2Display
)) {
5336 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x00, ~0xE0,
5337 0x20); /* shampoo 0129 */
5338 if (pVBInfo
->VBType
& (VB_SIS302LV
| VB_XGI301C
)) {
5339 if (pVBInfo
->VBInfo
&
5340 (SetCRT2ToLCD
| XGI_SetCRT2ToLCDA
))
5341 /* LVDS PLL power on */
5342 xgifb_reg_and(pVBInfo
->Part4Port
, 0x2A,
5344 /* LVDS Driver power on */
5345 xgifb_reg_and(pVBInfo
->Part4Port
, 0x30, 0x7F);
5351 if (!(pVBInfo
->VBInfo
& DisableCRT2Display
)) {
5354 if (!(pVBInfo
->VBInfo
& SetSimuScanMode
) &&
5355 (pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
) &&
5356 (pVBInfo
->VBInfo
& SetCRT2ToDualEdge
)) {
5357 tempah
= tempah
& 0x40;
5358 if (pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
)
5359 tempah
= tempah
^ 0xC0;
5363 /* EnablePart4_1F */
5364 xgifb_reg_or(pVBInfo
->Part4Port
, 0x1F, tempah
);
5366 XGI_DisableGatingCRT(pVBInfo
);
5367 XGI_DisplayOn(xgifb_info
, HwDeviceExtension
, pVBInfo
);
5370 if (pVBInfo
->VBInfo
& (SetCRT2ToTV
| SetCRT2ToLCD
5371 | XGI_SetCRT2ToLCDA
))
5373 xgifb_reg_or(pVBInfo
->Part1Port
, 0x1E, 0x20);
5375 tempah
= xgifb_reg_get(pVBInfo
->Part1Port
, 0x2E);
5376 if (!(tempah
& 0x80))
5377 xgifb_reg_or(pVBInfo
->Part1Port
, 0x2E, 0x80);
5379 xgifb_reg_and(pVBInfo
->Part1Port
, 0x00, 0x7F);
5380 XGI_DisplayOn(xgifb_info
, HwDeviceExtension
, pVBInfo
);
5384 static void XGI_SetCRT1Group(struct xgifb_video_info
*xgifb_info
,
5385 struct xgi_hw_device_info
*HwDeviceExtension
,
5386 unsigned short ModeNo
, unsigned short ModeIdIndex
,
5387 struct vb_device_info
*pVBInfo
)
5389 unsigned short RefreshRateTableIndex
, temp
;
5391 XGI_SetSeqRegs(pVBInfo
);
5392 outb(XGI330_StandTable
.MISC
, pVBInfo
->P3c2
);
5393 XGI_SetCRTCRegs(pVBInfo
);
5394 XGI_SetATTRegs(ModeIdIndex
, pVBInfo
);
5395 XGI_SetGRCRegs(pVBInfo
);
5396 XGI_ClearExt1Regs(pVBInfo
);
5398 if (HwDeviceExtension
->jChipType
== XG27
) {
5399 if (pVBInfo
->IF_DEF_LVDS
== 0)
5400 XGI_SetDefaultVCLK(pVBInfo
);
5403 temp
= ~ProgrammingCRT2
;
5404 pVBInfo
->SetFlag
&= temp
;
5405 pVBInfo
->SelectCRT2Rate
= 0;
5407 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
5408 | VB_SIS302LV
| VB_XGI301C
)) {
5409 if (pVBInfo
->VBInfo
& (SetSimuScanMode
| XGI_SetCRT2ToLCDA
5410 | SetInSlaveMode
)) {
5411 pVBInfo
->SetFlag
|= ProgrammingCRT2
;
5415 RefreshRateTableIndex
= XGI_GetRatePtrCRT2(HwDeviceExtension
, ModeNo
,
5416 ModeIdIndex
, pVBInfo
);
5417 if (RefreshRateTableIndex
!= 0xFFFF) {
5418 XGI_SetSync(RefreshRateTableIndex
, pVBInfo
);
5419 XGI_SetCRT1CRTC(ModeIdIndex
, RefreshRateTableIndex
,
5420 pVBInfo
, HwDeviceExtension
);
5421 XGI_SetCRT1DE(ModeIdIndex
, RefreshRateTableIndex
, pVBInfo
);
5422 XGI_SetCRT1Offset(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
5423 HwDeviceExtension
, pVBInfo
);
5424 XGI_SetCRT1VCLK(ModeIdIndex
, HwDeviceExtension
,
5425 RefreshRateTableIndex
, pVBInfo
);
5428 if (HwDeviceExtension
->jChipType
>= XG21
) {
5429 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x38);
5432 if (HwDeviceExtension
->jChipType
== XG27
)
5433 XGI_SetXG27CRTC(RefreshRateTableIndex
, pVBInfo
);
5435 XGI_SetXG21CRTC(RefreshRateTableIndex
, pVBInfo
);
5437 XGI_UpdateXG21CRTC(ModeNo
, pVBInfo
,
5438 RefreshRateTableIndex
);
5440 xgifb_set_lcd(HwDeviceExtension
->jChipType
,
5441 pVBInfo
, RefreshRateTableIndex
);
5443 if (pVBInfo
->IF_DEF_LVDS
== 1)
5444 xgifb_set_lvds(xgifb_info
,
5445 HwDeviceExtension
->jChipType
,
5446 ModeIdIndex
, pVBInfo
);
5450 pVBInfo
->SetFlag
&= (~ProgrammingCRT2
);
5451 XGI_SetCRT1FIFO(HwDeviceExtension
, pVBInfo
);
5452 XGI_SetCRT1ModeRegs(HwDeviceExtension
, ModeIdIndex
,
5453 RefreshRateTableIndex
, pVBInfo
);
5454 XGI_LoadDAC(pVBInfo
);
5457 unsigned char XGISetModeNew(struct xgifb_video_info
*xgifb_info
,
5458 struct xgi_hw_device_info
*HwDeviceExtension
,
5459 unsigned short ModeNo
)
5461 unsigned short ModeIdIndex
;
5462 struct vb_device_info VBINF
;
5463 struct vb_device_info
*pVBInfo
= &VBINF
;
5465 pVBInfo
->IF_DEF_LVDS
= 0;
5467 if (HwDeviceExtension
->jChipType
>= XG20
)
5468 pVBInfo
->VBType
= 0; /*set VBType default 0*/
5470 XGIRegInit(pVBInfo
, xgifb_info
->vga_base
);
5472 /* for x86 Linux, XG21 LVDS */
5473 if (HwDeviceExtension
->jChipType
== XG21
) {
5474 if ((xgifb_reg_get(pVBInfo
->P3d4
, 0x38) & 0xE0) == 0xC0)
5475 pVBInfo
->IF_DEF_LVDS
= 1;
5477 if (HwDeviceExtension
->jChipType
== XG27
) {
5478 if ((xgifb_reg_get(pVBInfo
->P3d4
, 0x38) & 0xE0) == 0xC0) {
5479 if (xgifb_reg_get(pVBInfo
->P3d4
, 0x30) & 0x20)
5480 pVBInfo
->IF_DEF_LVDS
= 1;
5484 InitTo330Pointer(HwDeviceExtension
->jChipType
, pVBInfo
);
5486 ModeNo
= ModeNo
& 0x7F;
5487 xgifb_reg_set(pVBInfo
->P3c4
, 0x05, 0x86);
5489 if (HwDeviceExtension
->jChipType
< XG20
)
5490 XGI_UnLockCRT2(pVBInfo
);
5492 XGI_SearchModeID(ModeNo
, &ModeIdIndex
);
5494 if (HwDeviceExtension
->jChipType
< XG20
) {
5495 XGI_GetVBInfo(ModeIdIndex
, pVBInfo
);
5496 XGI_GetTVInfo(ModeIdIndex
, pVBInfo
);
5497 XGI_GetLCDInfo(ModeIdIndex
, pVBInfo
);
5498 XGI_DisableBridge(xgifb_info
, HwDeviceExtension
, pVBInfo
);
5500 if (pVBInfo
->VBInfo
& (SetSimuScanMode
| XGI_SetCRT2ToLCDA
) ||
5501 (!(pVBInfo
->VBInfo
& SwitchCRT2
))) {
5502 XGI_SetCRT1Group(xgifb_info
, HwDeviceExtension
, ModeNo
,
5503 ModeIdIndex
, pVBInfo
);
5505 if (pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
) {
5506 XGI_SetLCDAGroup(ModeNo
, ModeIdIndex
,
5507 HwDeviceExtension
, pVBInfo
);
5511 if (pVBInfo
->VBInfo
& (SetSimuScanMode
| SwitchCRT2
)) {
5512 switch (HwDeviceExtension
->ujVBChipID
) {
5513 case VB_CHIP_301
: /* fall through */
5515 XGI_SetCRT2Group301(ModeNo
, HwDeviceExtension
,
5516 pVBInfo
); /*add for CRT2 */
5524 XGI_SetCRT2ModeRegs(pVBInfo
);
5525 XGI_OEM310Setting(ModeIdIndex
, pVBInfo
); /*0212*/
5526 XGI_EnableBridge(xgifb_info
, HwDeviceExtension
, pVBInfo
);
5529 if (pVBInfo
->IF_DEF_LVDS
== 1)
5530 if (!XGI_XG21CheckLVDSMode(xgifb_info
, ModeNo
,
5534 pVBInfo
->ModeType
= XGI330_EModeIDTable
[ModeIdIndex
].
5535 Ext_ModeFlag
& ModeTypeMask
;
5537 pVBInfo
->SetFlag
= 0;
5538 pVBInfo
->VBInfo
= DisableCRT2Display
;
5540 XGI_DisplayOff(xgifb_info
, HwDeviceExtension
, pVBInfo
);
5542 XGI_SetCRT1Group(xgifb_info
, HwDeviceExtension
, ModeNo
,
5543 ModeIdIndex
, pVBInfo
);
5545 XGI_DisplayOn(xgifb_info
, HwDeviceExtension
, pVBInfo
);
5548 XGI_UpdateModeInfo(pVBInfo
);
5550 if (HwDeviceExtension
->jChipType
< XG20
)
5551 XGI_LockCRT2(pVBInfo
);