1 #include <linux/delay.h>
10 #define TVCLKBASE_315_25 (TVCLKBASE_315 + 25)
12 static const unsigned short XGINew_VGA_DAC
[] = {
13 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
14 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
15 0x00, 0x05, 0x08, 0x0B, 0x0E, 0x11, 0x14, 0x18,
16 0x1C, 0x20, 0x24, 0x28, 0x2D, 0x32, 0x38, 0x3F,
17 0x00, 0x10, 0x1F, 0x2F, 0x3F, 0x1F, 0x27, 0x2F,
18 0x37, 0x3F, 0x2D, 0x31, 0x36, 0x3A, 0x3F, 0x00,
19 0x07, 0x0E, 0x15, 0x1C, 0x0E, 0x11, 0x15, 0x18,
20 0x1C, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x00, 0x04,
21 0x08, 0x0C, 0x10, 0x08, 0x0A, 0x0C, 0x0E, 0x10,
22 0x0B, 0x0C, 0x0D, 0x0F, 0x10};
24 void InitTo330Pointer(unsigned char ChipType
, struct vb_device_info
*pVBInfo
)
26 pVBInfo
->StandTable
= (struct SiS_StandTable_S
*) &XGI330_StandTable
;
27 pVBInfo
->EModeIDTable
= (struct XGI_ExtStruct
*) XGI330_EModeIDTable
;
28 pVBInfo
->RefIndex
= (struct XGI_Ext2Struct
*) XGI330_RefIndex
;
29 pVBInfo
->XGINEWUB_CRT1Table
30 = (struct XGI_CRT1TableStruct
*) XGI_CRT1Table
;
32 pVBInfo
->MCLKData
= (struct SiS_MCLKData
*) XGI340New_MCLKData
;
33 pVBInfo
->ECLKData
= (struct XGI_ECLKDataStruct
*) XGI340_ECLKData
;
34 pVBInfo
->VCLKData
= (struct SiS_VCLKData
*) XGI_VCLKData
;
35 pVBInfo
->VBVCLKData
= (struct SiS_VBVCLKData
*) XGI_VBVCLKData
;
36 pVBInfo
->ScreenOffset
= XGI330_ScreenOffset
;
37 pVBInfo
->StResInfo
= (struct SiS_StResInfo_S
*) XGI330_StResInfo
;
39 = (struct SiS_ModeResInfo_S
*) XGI330_ModeResInfo
;
41 pVBInfo
->pOutputSelect
= &XGI330_OutputSelect
;
42 pVBInfo
->pSoftSetting
= &XGI330_SoftSetting
;
43 pVBInfo
->pSR07
= &XGI330_SR07
;
44 pVBInfo
->LCDResInfo
= 0;
45 pVBInfo
->LCDTypeInfo
= 0;
50 pVBInfo
->SR15
= XGI340_SR13
;
51 pVBInfo
->CR40
= XGI340_cr41
;
52 pVBInfo
->SR25
= XGI330_sr25
;
53 pVBInfo
->pSR31
= &XGI330_sr31
;
54 pVBInfo
->pSR32
= &XGI330_sr32
;
55 pVBInfo
->CR6B
= XGI340_CR6B
;
56 pVBInfo
->CR6E
= XGI340_CR6E
;
57 pVBInfo
->CR6F
= XGI340_CR6F
;
58 pVBInfo
->CR89
= XGI340_CR89
;
59 pVBInfo
->AGPReg
= XGI340_AGPReg
;
60 pVBInfo
->SR16
= XGI340_SR16
;
61 pVBInfo
->pCRCF
= &XG40_CRCF
;
62 pVBInfo
->pXGINew_DRAMTypeDefinition
= &XG40_DRAMTypeDefinition
;
64 pVBInfo
->CR49
= XGI330_CR49
;
65 pVBInfo
->pSR1F
= &XGI330_SR1F
;
66 pVBInfo
->pSR21
= &XGI330_SR21
;
67 pVBInfo
->pSR22
= &XGI330_SR22
;
68 pVBInfo
->pSR23
= &XGI330_SR23
;
69 pVBInfo
->pSR24
= &XGI330_SR24
;
70 pVBInfo
->pSR33
= &XGI330_SR33
;
72 pVBInfo
->pCRT2Data_1_2
= &XGI330_CRT2Data_1_2
;
73 pVBInfo
->pCRT2Data_4_D
= &XGI330_CRT2Data_4_D
;
74 pVBInfo
->pCRT2Data_4_E
= &XGI330_CRT2Data_4_E
;
75 pVBInfo
->pCRT2Data_4_10
= &XGI330_CRT2Data_4_10
;
76 pVBInfo
->pRGBSenseData
= &XGI330_RGBSenseData
;
77 pVBInfo
->pVideoSenseData
= &XGI330_VideoSenseData
;
78 pVBInfo
->pYCSenseData
= &XGI330_YCSenseData
;
79 pVBInfo
->pRGBSenseData2
= &XGI330_RGBSenseData2
;
80 pVBInfo
->pVideoSenseData2
= &XGI330_VideoSenseData2
;
81 pVBInfo
->pYCSenseData2
= &XGI330_YCSenseData2
;
83 pVBInfo
->NTSCTiming
= XGI330_NTSCTiming
;
84 pVBInfo
->PALTiming
= XGI330_PALTiming
;
85 pVBInfo
->HiTVExtTiming
= XGI330_HiTVExtTiming
;
86 pVBInfo
->HiTVSt1Timing
= XGI330_HiTVSt1Timing
;
87 pVBInfo
->HiTVSt2Timing
= XGI330_HiTVSt2Timing
;
88 pVBInfo
->HiTVTextTiming
= XGI330_HiTVTextTiming
;
89 pVBInfo
->YPbPr750pTiming
= XGI330_YPbPr750pTiming
;
90 pVBInfo
->YPbPr525pTiming
= XGI330_YPbPr525pTiming
;
91 pVBInfo
->YPbPr525iTiming
= XGI330_YPbPr525iTiming
;
92 pVBInfo
->HiTVGroup3Data
= XGI330_HiTVGroup3Data
;
93 pVBInfo
->HiTVGroup3Simu
= XGI330_HiTVGroup3Simu
;
94 pVBInfo
->HiTVGroup3Text
= XGI330_HiTVGroup3Text
;
95 pVBInfo
->Ren525pGroup3
= XGI330_Ren525pGroup3
;
96 pVBInfo
->Ren750pGroup3
= XGI330_Ren750pGroup3
;
98 pVBInfo
->TimingH
= (struct XGI_TimingHStruct
*) XGI_TimingH
;
99 pVBInfo
->TimingV
= (struct XGI_TimingVStruct
*) XGI_TimingV
;
100 pVBInfo
->UpdateCRT1
= (struct XGI_XG21CRT1Struct
*) XGI_UpdateCRT1Table
;
102 /* 310 customization related */
103 if ((pVBInfo
->VBType
& VB_SIS301LV
) || (pVBInfo
->VBType
& VB_SIS302LV
))
104 pVBInfo
->LCDCapList
= XGI_LCDDLCapList
;
106 pVBInfo
->LCDCapList
= XGI_LCDCapList
;
108 pVBInfo
->pXGINew_I2CDefinition
= &XG40_I2CDefinition
;
110 if (ChipType
>= XG20
)
111 pVBInfo
->pXGINew_CR97
= &XG20_CR97
;
113 if (ChipType
== XG27
) {
116 = (struct SiS_MCLKData
*) XGI27New_MCLKData
;
117 pVBInfo
->CR40
= XGI27_cr41
;
118 pVBInfo
->pXGINew_CR97
= &XG27_CR97
;
119 pVBInfo
->pSR36
= &XG27_SR36
;
120 pVBInfo
->pCR8F
= &XG27_CR8F
;
121 pVBInfo
->pCRD0
= XG27_CRD0
;
122 pVBInfo
->pCRDE
= XG27_CRDE
;
123 pVBInfo
->pSR40
= &XG27_SR40
;
124 pVBInfo
->pSR41
= &XG27_SR41
;
125 pVBInfo
->SR15
= XG27_SR13
;
128 temp
= xgifb_reg_get(pVBInfo
->P3c4
, 0x3B);
129 /* SR3B[7][3]MAA15 MAA11 (Power on Trapping) */
130 if (((temp
& 0x88) == 0x80) || ((temp
& 0x88) == 0x08))
131 pVBInfo
->pXGINew_CR97
= &Z11m_CR97
;
134 if (ChipType
>= XG20
) {
135 pVBInfo
->pDVOSetting
= &XG21_DVOSetting
;
136 pVBInfo
->pCR2E
= &XG21_CR2E
;
137 pVBInfo
->pCR2F
= &XG21_CR2F
;
138 pVBInfo
->pCR46
= &XG21_CR46
;
139 pVBInfo
->pCR47
= &XG21_CR47
;
144 static void XGI_SetSeqRegs(unsigned short ModeNo
,
145 unsigned short ModeIdIndex
,
146 struct vb_device_info
*pVBInfo
)
148 unsigned char tempah
, SRdata
;
149 unsigned short i
, modeflag
;
151 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
153 xgifb_reg_set(pVBInfo
->P3c4
, 0x00, 0x03); /* Set SR0 */
154 tempah
= pVBInfo
->StandTable
->SR
[0];
156 i
= XGI_SetCRT2ToLCDA
;
157 if (pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
) {
160 if (pVBInfo
->VBInfo
& (SetCRT2ToTV
| SetCRT2ToLCD
)) {
161 if (pVBInfo
->VBInfo
& SetInSlaveMode
)
166 tempah
|= 0x20; /* screen off */
167 xgifb_reg_set(pVBInfo
->P3c4
, 0x01, tempah
); /* Set SR1 */
169 for (i
= 02; i
<= 04; i
++) {
170 /* Get SR2,3,4 from file */
171 SRdata
= pVBInfo
->StandTable
->SR
[i
- 1];
172 xgifb_reg_set(pVBInfo
->P3c4
, i
, SRdata
); /* Set SR2 3 4 */
176 static void XGI_SetCRTCRegs(struct xgi_hw_device_info
*HwDeviceExtension
,
177 struct vb_device_info
*pVBInfo
)
179 unsigned char CRTCdata
;
182 CRTCdata
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x11);
184 xgifb_reg_set(pVBInfo
->P3d4
, 0x11, CRTCdata
); /* Unlock CRTC */
186 for (i
= 0; i
<= 0x18; i
++) {
187 /* Get CRTC from file */
188 CRTCdata
= pVBInfo
->StandTable
->CRTC
[i
];
189 xgifb_reg_set(pVBInfo
->P3d4
, i
, CRTCdata
); /* Set CRTC(3d4) */
193 static void XGI_SetATTRegs(unsigned short ModeNo
,
194 unsigned short ModeIdIndex
,
195 struct vb_device_info
*pVBInfo
)
197 unsigned char ARdata
;
198 unsigned short i
, modeflag
;
200 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
202 for (i
= 0; i
<= 0x13; i
++) {
203 ARdata
= pVBInfo
->StandTable
->ATTR
[i
];
204 if (modeflag
& Charx8Dot
) { /* ifndef Dot9 */
206 if (pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
) {
209 if (pVBInfo
->VBInfo
& (SetCRT2ToTV
211 if (pVBInfo
->VBInfo
&
219 inb(pVBInfo
->P3da
); /* reset 3da */
220 outb(i
, pVBInfo
->P3c0
); /* set index */
221 outb(ARdata
, pVBInfo
->P3c0
); /* set data */
224 inb(pVBInfo
->P3da
); /* reset 3da */
225 outb(0x14, pVBInfo
->P3c0
); /* set index */
226 outb(0x00, pVBInfo
->P3c0
); /* set data */
227 inb(pVBInfo
->P3da
); /* Enable Attribute */
228 outb(0x20, pVBInfo
->P3c0
);
231 static void XGI_SetGRCRegs(struct vb_device_info
*pVBInfo
)
233 unsigned char GRdata
;
236 for (i
= 0; i
<= 0x08; i
++) {
237 /* Get GR from file */
238 GRdata
= pVBInfo
->StandTable
->GRC
[i
];
239 xgifb_reg_set(pVBInfo
->P3ce
, i
, GRdata
); /* Set GR(3ce) */
242 if (pVBInfo
->ModeType
> ModeVGA
) {
243 GRdata
= (unsigned char) xgifb_reg_get(pVBInfo
->P3ce
, 0x05);
244 GRdata
&= 0xBF; /* 256 color disable */
245 xgifb_reg_set(pVBInfo
->P3ce
, 0x05, GRdata
);
249 static void XGI_ClearExt1Regs(struct vb_device_info
*pVBInfo
)
253 for (i
= 0x0A; i
<= 0x0E; i
++)
254 xgifb_reg_set(pVBInfo
->P3c4
, i
, 0x00); /* Clear SR0A-SR0E */
257 static unsigned char XGI_SetDefaultVCLK(struct vb_device_info
*pVBInfo
)
260 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x31, ~0x30, 0x20);
261 xgifb_reg_set(pVBInfo
->P3c4
, 0x2B, pVBInfo
->VCLKData
[0].SR2B
);
262 xgifb_reg_set(pVBInfo
->P3c4
, 0x2C, pVBInfo
->VCLKData
[0].SR2C
);
264 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x31, ~0x30, 0x10);
265 xgifb_reg_set(pVBInfo
->P3c4
, 0x2B, pVBInfo
->VCLKData
[1].SR2B
);
266 xgifb_reg_set(pVBInfo
->P3c4
, 0x2C, pVBInfo
->VCLKData
[1].SR2C
);
268 xgifb_reg_and(pVBInfo
->P3c4
, 0x31, ~0x30);
272 static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo
,
273 unsigned short ModeIdIndex
,
274 unsigned short RefreshRateTableIndex
, unsigned short *i
,
275 struct vb_device_info
*pVBInfo
)
277 unsigned short tempax
, tempbx
, resinfo
, modeflag
, infoflag
;
279 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
280 resinfo
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
281 tempbx
= pVBInfo
->RefIndex
[RefreshRateTableIndex
+ (*i
)].ModeID
;
284 if (pVBInfo
->IF_DEF_LVDS
== 0) {
285 if (pVBInfo
->VBInfo
& SetCRT2ToRAMDAC
) {
286 tempax
|= SupportRAMDAC2
;
288 if (pVBInfo
->VBType
& VB_XGI301C
)
289 tempax
|= SupportCRT2in301C
;
293 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| XGI_SetCRT2ToLCDA
)) {
294 tempax
|= SupportLCD
;
296 if (pVBInfo
->LCDResInfo
!= Panel_1280x1024
) {
297 if (pVBInfo
->LCDResInfo
!= Panel_1280x960
) {
298 if (pVBInfo
->LCDInfo
&
309 if (pVBInfo
->VBInfo
& SetCRT2ToHiVision
) { /* for HiTV */
310 if ((pVBInfo
->VBType
& VB_SIS301LV
) &&
311 (pVBInfo
->VBExtInfo
== VB_YPbPr1080i
)) {
312 tempax
|= SupportYPbPr750p
;
313 if (pVBInfo
->VBInfo
& SetInSlaveMode
) {
324 tempax
|= SupportHiVision
;
325 if (pVBInfo
->VBInfo
& SetInSlaveMode
) {
340 if (pVBInfo
->VBInfo
& (SetCRT2ToAVIDEO
|
343 SetCRT2ToYPbPr525750
|
344 SetCRT2ToHiVision
)) {
347 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
348 | VB_SIS301LV
| VB_SIS302LV
350 tempax
|= SupportTV1024
;
353 if (!(pVBInfo
->VBInfo
& TVSetPAL
)) {
354 if (modeflag
& NoSupportSimuTV
) {
355 if (pVBInfo
->VBInfo
&
357 if (!(pVBInfo
->VBInfo
&
366 } else { /* for LVDS */
367 if (pVBInfo
->VBInfo
& SetCRT2ToLCD
) {
368 tempax
|= SupportLCD
;
371 return 0; /* 1024x768 */
373 if (pVBInfo
->LCDResInfo
< Panel_1024x768
) {
375 return 0; /* 800x600 */
378 return 0; /* 512x384 */
383 for (; pVBInfo
->RefIndex
[RefreshRateTableIndex
+ (*i
)].ModeID
==
385 infoflag
= pVBInfo
->RefIndex
[RefreshRateTableIndex
+ (*i
)].
387 if (infoflag
& tempax
)
394 for ((*i
) = 0;; (*i
)++) {
395 infoflag
= pVBInfo
->RefIndex
[RefreshRateTableIndex
+ (*i
)].
397 if (pVBInfo
->RefIndex
[RefreshRateTableIndex
+ (*i
)].ModeID
402 if (infoflag
& tempax
)
408 static void XGI_SetSync(unsigned short RefreshRateTableIndex
,
409 struct vb_device_info
*pVBInfo
)
411 unsigned short sync
, temp
;
414 sync
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_InfoFlag
>> 8;
418 outb(temp
, pVBInfo
->P3c2
); /* Set Misc(3c2) */
421 static void XGI_SetCRT1Timing_H(struct vb_device_info
*pVBInfo
,
422 struct xgi_hw_device_info
*HwDeviceExtension
)
424 unsigned char data
, data1
, pushax
;
428 data
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x11);
430 xgifb_reg_set(pVBInfo
->P3d4
, 0x11, data
);
432 data
= pVBInfo
->TimingH
[0].data
[0];
433 xgifb_reg_set(pVBInfo
->P3d4
, 0, data
);
435 for (i
= 0x01; i
<= 0x04; i
++) {
436 data
= pVBInfo
->TimingH
[0].data
[i
];
437 xgifb_reg_set(pVBInfo
->P3d4
, (unsigned short) (i
+ 1), data
);
440 for (i
= 0x05; i
<= 0x06; i
++) {
441 data
= pVBInfo
->TimingH
[0].data
[i
];
442 xgifb_reg_set(pVBInfo
->P3c4
, (unsigned short) (i
+ 6), data
);
445 j
= (unsigned char) xgifb_reg_get(pVBInfo
->P3c4
, 0x0e);
447 data
= pVBInfo
->TimingH
[0].data
[7];
450 xgifb_reg_set(pVBInfo
->P3c4
, 0x0e, data
);
452 if (HwDeviceExtension
->jChipType
>= XG20
) {
453 data
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x04);
455 xgifb_reg_set(pVBInfo
->P3d4
, 0x04, data
);
456 data
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x05);
462 data
= (unsigned char) xgifb_reg_get(pVBInfo
->P3c4
,
465 xgifb_reg_set(pVBInfo
->P3c4
, 0x0c, data
);
470 xgifb_reg_set(pVBInfo
->P3d4
, 0x05, data
);
471 data
= (unsigned char) xgifb_reg_get(pVBInfo
->P3c4
, 0x0e);
477 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0e, ~0xE0, data
);
481 static void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex
,
482 unsigned short ModeNo
,
483 struct vb_device_info
*pVBInfo
)
488 for (i
= 0x00; i
<= 0x01; i
++) {
489 data
= pVBInfo
->TimingV
[0].data
[i
];
490 xgifb_reg_set(pVBInfo
->P3d4
, (unsigned short) (i
+ 6), data
);
493 for (i
= 0x02; i
<= 0x03; i
++) {
494 data
= pVBInfo
->TimingV
[0].data
[i
];
495 xgifb_reg_set(pVBInfo
->P3d4
, (unsigned short) (i
+ 0x0e), data
);
498 for (i
= 0x04; i
<= 0x05; i
++) {
499 data
= pVBInfo
->TimingV
[0].data
[i
];
500 xgifb_reg_set(pVBInfo
->P3d4
, (unsigned short) (i
+ 0x11), data
);
503 j
= (unsigned char) xgifb_reg_get(pVBInfo
->P3c4
, 0x0a);
505 data
= pVBInfo
->TimingV
[0].data
[6];
508 xgifb_reg_set(pVBInfo
->P3c4
, 0x0a, data
);
510 data
= pVBInfo
->TimingV
[0].data
[6];
514 i
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
519 j
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x09);
522 xgifb_reg_set(pVBInfo
->P3d4
, 0x09, data
);
525 static void XGI_SetCRT1CRTC(unsigned short ModeNo
, unsigned short ModeIdIndex
,
526 unsigned short RefreshRateTableIndex
,
527 struct vb_device_info
*pVBInfo
,
528 struct xgi_hw_device_info
*HwDeviceExtension
)
530 unsigned char index
, data
;
534 index
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRT1CRTC
;
535 index
= index
& IndexMask
;
537 data
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x11);
539 xgifb_reg_set(pVBInfo
->P3d4
, 0x11, data
); /* Unlock CRTC */
541 for (i
= 0; i
< 8; i
++)
542 pVBInfo
->TimingH
[0].data
[i
]
543 = pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[i
];
545 for (i
= 0; i
< 7; i
++)
546 pVBInfo
->TimingV
[0].data
[i
]
547 = pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[i
+ 8];
549 XGI_SetCRT1Timing_H(pVBInfo
, HwDeviceExtension
);
551 XGI_SetCRT1Timing_V(ModeIdIndex
, ModeNo
, pVBInfo
);
553 if (pVBInfo
->ModeType
> 0x03)
554 xgifb_reg_set(pVBInfo
->P3d4
, 0x14, 0x4F);
557 /* --------------------------------------------------------------------- */
558 /* Function : XGI_SetXG21CRTC */
559 /* Input : Stand or enhance CRTC table */
560 /* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */
561 /* Description : Set LCD timing */
562 /* --------------------------------------------------------------------- */
563 static void XGI_SetXG21CRTC(unsigned short ModeNo
, unsigned short ModeIdIndex
,
564 unsigned short RefreshRateTableIndex
,
565 struct vb_device_info
*pVBInfo
)
567 unsigned char index
, Tempax
, Tempbx
, Tempcx
, Tempdx
;
568 unsigned short Temp1
, Temp2
, Temp3
;
570 index
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRT1CRTC
;
571 /* Tempax: CR4 HRS */
572 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[3];
573 Tempcx
= Tempax
; /* Tempcx: HRS */
575 xgifb_reg_set(pVBInfo
->P3c4
, 0x2E, Tempax
);
577 Tempdx
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[5]; /* SRB */
578 Tempdx
&= 0xC0; /* Tempdx[7:6]: SRB[7:6] */
579 Temp1
= Tempdx
; /* Temp1[7:6]: HRS[9:8] */
580 Temp1
<<= 2; /* Temp1[9:8]: HRS[9:8] */
581 Temp1
|= Tempax
; /* Temp1[9:0]: HRS[9:0] */
583 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[4]; /* CR5 HRE */
584 Tempax
&= 0x1F; /* Tempax[4:0]: HRE[4:0] */
586 Tempbx
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[6]; /* SRC */
587 Tempbx
&= 0x04; /* Tempbx[2]: HRE[5] */
588 Tempbx
<<= 3; /* Tempbx[5]: HRE[5] */
589 Tempax
|= Tempbx
; /* Tempax[5:0]: HRE[5:0] */
591 Temp2
= Temp1
& 0x3C0; /* Temp2[9:6]: HRS[9:6] */
592 Temp2
|= Tempax
; /* Temp2[9:0]: HRE[9:0] */
594 Tempcx
&= 0x3F; /* Tempcx[5:0]: HRS[5:0] */
595 if (Tempax
< Tempcx
) /* HRE < HRS */
596 Temp2
|= 0x40; /* Temp2 + 0x40 */
599 Tempax
= (unsigned char) Temp2
; /* Tempax: HRE[7:0] */
600 Tempax
<<= 2; /* Tempax[7:2]: HRE[5:0] */
601 Tempdx
>>= 6; /* Tempdx[7:6]->[1:0] HRS[9:8] */
602 Tempax
|= Tempdx
; /* HRE[5:0]HRS[9:8] */
603 /* SR2F D[7:2]->HRE, D[1:0]->HRS */
604 xgifb_reg_set(pVBInfo
->P3c4
, 0x2F, Tempax
);
605 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x30, 0xE3, 00);
608 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[10];
609 Tempbx
= Tempax
; /* Tempbx: VRS */
610 Tempax
&= 0x01; /* Tempax[0]: VRS[0] */
611 xgifb_reg_or(pVBInfo
->P3c4
, 0x33, Tempax
); /* SR33[0]->VRS[0] */
613 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[9];
614 Tempcx
= Tempbx
>> 1; /* Tempcx[6:0]: VRS[7:1] */
615 Tempdx
= Tempax
& 0x04; /* Tempdx[2]: CR7[2] */
616 Tempdx
<<= 5; /* Tempdx[7]: VRS[8] */
617 Tempcx
|= Tempdx
; /* Tempcx[7:0]: VRS[8:1] */
618 xgifb_reg_set(pVBInfo
->P3c4
, 0x34, Tempcx
); /* SR34[8:1]->VRS */
620 Temp1
= Tempdx
; /* Temp1[7]: Tempdx[7] */
621 Temp1
<<= 1; /* Temp1[8]: VRS[8] */
622 Temp1
|= Tempbx
; /* Temp1[8:0]: VRS[8:0] */
624 Temp2
= Tempax
<< 2; /* Temp2[9]: VRS[9] */
625 Temp1
|= Temp2
; /* Temp1[9:0]: VRS[9:0] */
627 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[14];
628 Tempax
&= 0x08; /* Tempax[3]: VRS[3] */
630 Temp2
<<= 7; /* Temp2[10]: VRS[10] */
631 Temp1
|= Temp2
; /* Temp1[10:0]: VRS[10:0] */
633 /* Tempax: CR11 VRE */
634 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[11];
635 Tempax
&= 0x0F; /* Tempax[3:0]: VRE[3:0] */
637 Tempbx
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[14];
638 Tempbx
&= 0x20; /* Tempbx[5]: VRE[5] */
639 Tempbx
>>= 1; /* Tempbx[4]: VRE[4] */
640 Tempax
|= Tempbx
; /* Tempax[4:0]: VRE[4:0] */
641 Temp2
= Temp1
& 0x7E0; /* Temp2[10:5]: VRS[10:5] */
642 Temp2
|= Tempax
; /* Temp2[10:5]: VRE[10:5] */
644 Temp3
= Temp1
& 0x1F; /* Temp3[4:0]: VRS[4:0] */
645 if (Tempax
< Temp3
) /* VRE < VRS */
646 Temp2
|= 0x20; /* VRE + 0x20 */
649 Tempax
= (unsigned char) Temp2
; /* Tempax: VRE[7:0] */
650 Tempax
<<= 2; /* Tempax[7:0]; VRE[5:0]00 */
651 Temp1
&= 0x600; /* Temp1[10:9]: VRS[10:9] */
652 Temp1
>>= 9; /* Temp1[1:0]: VRS[10:9] */
653 Tempbx
= (unsigned char) Temp1
;
654 Tempax
|= Tempbx
; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */
656 /* SR3F D[7:2]->VRE D[1:0]->VRS */
657 xgifb_reg_set(pVBInfo
->P3c4
, 0x3F, Tempax
);
660 static void XGI_SetXG27CRTC(unsigned short ModeNo
,
661 unsigned short ModeIdIndex
,
662 unsigned short RefreshRateTableIndex
,
663 struct vb_device_info
*pVBInfo
)
665 unsigned short index
, Tempax
, Tempbx
, Tempcx
;
667 index
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRT1CRTC
;
668 /* Tempax: CR4 HRS */
669 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[3];
670 Tempbx
= Tempax
; /* Tempbx: HRS[7:0] */
672 xgifb_reg_set(pVBInfo
->P3c4
, 0x2E, Tempax
);
675 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[5];
676 Tempax
&= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
677 Tempbx
|= (Tempax
<< 2); /* Tempbx: HRS[9:0] */
679 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[4]; /* CR5 HRE */
680 Tempax
&= 0x1F; /* Tempax[4:0]: HRE[4:0] */
681 Tempcx
= Tempax
; /* Tempcx: HRE[4:0] */
683 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[6]; /* SRC */
684 Tempax
&= 0x04; /* Tempax[2]: HRE[5] */
685 Tempax
<<= 3; /* Tempax[5]: HRE[5] */
686 Tempcx
|= Tempax
; /* Tempcx[5:0]: HRE[5:0] */
688 Tempbx
= Tempbx
& 0x3C0; /* Tempbx[9:6]: HRS[9:6] */
689 Tempbx
|= Tempcx
; /* Tempbx: HRS[9:6]HRE[5:0] */
691 /* Tempax: CR4 HRS */
692 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[3];
693 Tempax
&= 0x3F; /* Tempax: HRS[5:0] */
694 if (Tempcx
<= Tempax
) /* HRE[5:0] < HRS[5:0] */
695 Tempbx
+= 0x40; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/
697 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[5]; /* SR0B */
698 Tempax
&= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
699 Tempax
>>= 6; /* Tempax[1:0]: HRS[9:8]*/
700 Tempax
|= ((Tempbx
<< 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */
701 /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */
702 xgifb_reg_set(pVBInfo
->P3c4
, 0x2F, Tempax
);
703 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x30, 0xE3, 00);
706 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[10];
707 /* SR34[7:0]->VRS[7:0] */
708 xgifb_reg_set(pVBInfo
->P3c4
, 0x34, Tempax
);
710 Tempcx
= Tempax
; /* Tempcx <= VRS[7:0] */
711 /* CR7[7][2] VRS[9][8] */
712 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[9];
713 Tempbx
= Tempax
; /* Tempbx <= CR07[7:0] */
714 Tempax
= Tempax
& 0x04; /* Tempax[2]: CR7[2]: VRS[8] */
715 Tempax
>>= 2; /* Tempax[0]: VRS[8] */
716 /* SR35[0]: VRS[8] */
717 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x35, ~0x01, Tempax
);
718 Tempcx
|= (Tempax
<< 8); /* Tempcx <= VRS[8:0] */
719 Tempcx
|= ((Tempbx
& 0x80) << 2); /* Tempcx <= VRS[9:0] */
721 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[14];
722 Tempax
&= 0x08; /* SR0A[3] VRS[10] */
723 Tempcx
|= (Tempax
<< 7); /* Tempcx <= VRS[10:0] */
725 /* Tempax: CR11 VRE */
726 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[11];
727 Tempax
&= 0x0F; /* Tempax[3:0]: VRE[3:0] */
729 Tempbx
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[14];
730 Tempbx
&= 0x20; /* Tempbx[5]: SR0A[5]: VRE[4] */
731 Tempbx
>>= 1; /* Tempbx[4]: VRE[4] */
732 Tempax
|= Tempbx
; /* Tempax[4:0]: VRE[4:0] */
733 Tempbx
= Tempcx
; /* Tempbx: VRS[10:0] */
734 Tempbx
&= 0x7E0; /* Tempbx[10:5]: VRS[10:5] */
735 Tempbx
|= Tempax
; /* Tempbx: VRS[10:5]VRE[4:0] */
737 if (Tempbx
<= Tempcx
) /* VRE <= VRS */
738 Tempbx
|= 0x20; /* VRE + 0x20 */
740 /* Tempax: Tempax[7:0]; VRE[5:0]00 */
741 Tempax
= (Tempbx
<< 2) & 0xFF;
742 /* SR3F[7:2]:VRE[5:0] */
743 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x3F, ~0xFC, Tempax
);
744 Tempax
= Tempcx
>> 8;
745 /* SR35[2:0]:VRS[10:8] */
746 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x35, ~0x07, Tempax
);
749 static void XGI_SetXG27FPBits(struct vb_device_info
*pVBInfo
)
753 /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */
754 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x37);
755 temp
= (temp
& 3) << 6;
756 /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */
757 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x06, ~0xc0, temp
& 0x80);
758 /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */
759 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x09, ~0xc0, temp
| 0x80);
763 static void xgifb_set_lcd(int chip_id
,
764 struct vb_device_info
*pVBInfo
,
765 unsigned short RefreshRateTableIndex
,
766 unsigned short ModeNo
)
768 unsigned short Data
, Temp
;
769 unsigned short XGI_P3cc
;
771 XGI_P3cc
= pVBInfo
->P3cc
;
773 xgifb_reg_set(pVBInfo
->P3d4
, 0x2E, 0x00);
774 xgifb_reg_set(pVBInfo
->P3d4
, 0x2F, 0x00);
775 xgifb_reg_set(pVBInfo
->P3d4
, 0x46, 0x00);
776 xgifb_reg_set(pVBInfo
->P3d4
, 0x47, 0x00);
778 if (chip_id
== XG27
) {
779 Temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x37);
780 if ((Temp
& 0x03) == 0) { /* dual 12 */
781 xgifb_reg_set(pVBInfo
->P3d4
, 0x46, 0x13);
782 xgifb_reg_set(pVBInfo
->P3d4
, 0x47, 0x13);
786 if (((*pVBInfo
->pDVOSetting
) & 0xC0) == 0xC0) {
787 xgifb_reg_set(pVBInfo
->P3d4
, 0x2E, *pVBInfo
->pCR2E
);
788 xgifb_reg_set(pVBInfo
->P3d4
, 0x2F, *pVBInfo
->pCR2F
);
789 xgifb_reg_set(pVBInfo
->P3d4
, 0x46, *pVBInfo
->pCR46
);
790 xgifb_reg_set(pVBInfo
->P3d4
, 0x47, *pVBInfo
->pCR47
);
793 if (chip_id
== XG27
) {
794 XGI_SetXG27FPBits(pVBInfo
);
796 Temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x37);
799 xgifb_reg_or(pVBInfo
->P3c4
, 0x06, 0x40);
800 xgifb_reg_or(pVBInfo
->P3c4
, 0x09, 0x40);
804 xgifb_reg_or(pVBInfo
->P3c4
, 0x1E, 0x01); /* Negative blank polarity */
806 xgifb_reg_and(pVBInfo
->P3c4
, 0x30, ~0x20); /* Hsync polarity */
807 xgifb_reg_and(pVBInfo
->P3c4
, 0x35, ~0x80); /* Vsync polarity */
809 Data
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_InfoFlag
;
812 xgifb_reg_or(pVBInfo
->P3c4
, 0x30, 0x20);
815 xgifb_reg_or(pVBInfo
->P3c4
, 0x35, 0x80);
818 /* --------------------------------------------------------------------- */
819 /* Function : XGI_UpdateXG21CRTC */
821 /* Output : CRT1 CRTC */
822 /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */
823 /* --------------------------------------------------------------------- */
824 static void XGI_UpdateXG21CRTC(unsigned short ModeNo
,
825 struct vb_device_info
*pVBInfo
,
826 unsigned short RefreshRateTableIndex
)
830 xgifb_reg_and(pVBInfo
->P3d4
, 0x11, 0x7F); /* Unlock CR0~7 */
831 if (ModeNo
== 0x2E &&
832 (pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRT1CRTC
==
835 else if (ModeNo
== 0x2E && (pVBInfo
->RefIndex
[RefreshRateTableIndex
].
836 Ext_CRT1CRTC
== RES640x480x72
))
838 else if (ModeNo
== 0x2F)
840 else if (ModeNo
== 0x50)
842 else if (ModeNo
== 0x59)
846 xgifb_reg_set(pVBInfo
->P3d4
, 0x02,
847 pVBInfo
->UpdateCRT1
[index
].CR02
);
848 xgifb_reg_set(pVBInfo
->P3d4
, 0x03,
849 pVBInfo
->UpdateCRT1
[index
].CR03
);
850 xgifb_reg_set(pVBInfo
->P3d4
, 0x15,
851 pVBInfo
->UpdateCRT1
[index
].CR15
);
852 xgifb_reg_set(pVBInfo
->P3d4
, 0x16,
853 pVBInfo
->UpdateCRT1
[index
].CR16
);
857 static void XGI_SetCRT1DE(struct xgi_hw_device_info
*HwDeviceExtension
,
858 unsigned short ModeNo
, unsigned short ModeIdIndex
,
859 unsigned short RefreshRateTableIndex
,
860 struct vb_device_info
*pVBInfo
)
862 unsigned short resindex
, tempax
, tempbx
, tempcx
, temp
, modeflag
;
866 resindex
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
868 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
869 tempax
= pVBInfo
->ModeResInfo
[resindex
].HTotal
;
870 tempbx
= pVBInfo
->ModeResInfo
[resindex
].VTotal
;
872 if (modeflag
& HalfDCLK
)
873 tempax
= tempax
>> 1;
875 if (modeflag
& HalfDCLK
)
876 tempax
= tempax
<< 1;
878 temp
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_InfoFlag
;
880 if (temp
& InterlaceMode
)
881 tempbx
= tempbx
>> 1;
883 if (modeflag
& DoubleScanMode
)
884 tempbx
= tempbx
<< 1;
892 temp
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x11);
893 data
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x11);
895 xgifb_reg_set(pVBInfo
->P3d4
, 0x11, data
); /* Unlock CRTC */
896 xgifb_reg_set(pVBInfo
->P3d4
, 0x01, (unsigned short) (tempcx
& 0xff));
897 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x0b, ~0x0c,
898 (unsigned short) ((tempcx
& 0x0ff00) >> 10));
899 xgifb_reg_set(pVBInfo
->P3d4
, 0x12, (unsigned short) (tempbx
& 0xff));
901 tempbx
= tempbx
>> 8;
909 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x07, ~0x42, tempax
);
910 data
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x07);
917 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x0a, ~0x02, tempax
);
918 xgifb_reg_set(pVBInfo
->P3d4
, 0x11, temp
);
921 static void XGI_SetCRT1Offset(unsigned short ModeNo
,
922 unsigned short ModeIdIndex
,
923 unsigned short RefreshRateTableIndex
,
924 struct xgi_hw_device_info
*HwDeviceExtension
,
925 struct vb_device_info
*pVBInfo
)
927 unsigned short temp
, ah
, al
, temp2
, i
, DisplayUnit
;
930 temp
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeInfo
;
932 temp
= pVBInfo
->ScreenOffset
[temp
];
934 temp2
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_InfoFlag
;
935 temp2
&= InterlaceMode
;
940 temp2
= pVBInfo
->ModeType
- ModeEGA
;
965 if ((ModeNo
>= 0x26) && (ModeNo
<= 0x28))
966 temp
= temp
* temp2
+ temp2
/ 2;
973 temp
= temp
>> 8; /* ah */
975 i
= xgifb_reg_get(pVBInfo
->P3c4
, 0x0E);
978 xgifb_reg_set(pVBInfo
->P3c4
, 0x0E, i
);
980 temp
= (unsigned char) temp2
;
981 temp
&= 0xFF; /* al */
982 xgifb_reg_set(pVBInfo
->P3d4
, 0x13, temp
);
985 temp2
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_InfoFlag
;
986 temp2
&= InterlaceMode
;
990 DisplayUnit
= DisplayUnit
<< 5;
991 ah
= (DisplayUnit
& 0xff00) >> 8;
992 al
= DisplayUnit
& 0x00ff;
998 if (HwDeviceExtension
->jChipType
>= XG20
)
999 if ((ModeNo
== 0x4A) | (ModeNo
== 0x49))
1002 xgifb_reg_set(pVBInfo
->P3c4
, 0x10, ah
);
1005 static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo
,
1006 unsigned short ModeIdIndex
,
1007 unsigned short RefreshRateTableIndex
,
1008 struct xgi_hw_device_info
*HwDeviceExtension
,
1009 struct vb_device_info
*pVBInfo
)
1011 unsigned short CRT2Index
, VCLKIndex
;
1012 unsigned short modeflag
, resinfo
;
1014 /* si+Ext_ResInfo */
1015 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
1016 resinfo
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
1017 CRT2Index
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRT2CRTC
;
1019 if (pVBInfo
->IF_DEF_LVDS
== 0) {
1020 CRT2Index
= CRT2Index
>> 6; /* for LCD */
1021 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| XGI_SetCRT2ToLCDA
)) { /*301b*/
1022 if (pVBInfo
->LCDResInfo
!= Panel_1024x768
)
1023 VCLKIndex
= VCLK108_2_315
+ 5; /* LCDXlat2VCLK */
1025 VCLKIndex
= VCLK65_315
+ 2; /* LCDXlat1VCLK */
1026 } else if (pVBInfo
->VBInfo
& SetCRT2ToHiVision
) {
1027 if (pVBInfo
->SetFlag
& RPLLDIV2XO
) {
1028 VCLKIndex
= TVCLKBASE_315_25
+ HiTVVCLKDIV2
;
1030 VCLKIndex
= TVCLKBASE_315_25
+ HiTVVCLK
;
1033 if (pVBInfo
->SetFlag
& TVSimuMode
) {
1034 if (modeflag
& Charx8Dot
) {
1035 VCLKIndex
= TVCLKBASE_315_25
+ HiTVSimuVCLK
;
1037 VCLKIndex
= TVCLKBASE_315_25
+ HiTVTextVCLK
;
1042 if ((pVBInfo
->VBType
& VB_SIS301LV
) &&
1043 !(pVBInfo
->VBExtInfo
== VB_YPbPr1080i
)) {
1044 if (pVBInfo
->VBExtInfo
== YPbPr750p
)
1045 VCLKIndex
= XGI_YPbPr750pVCLK
;
1046 else if (pVBInfo
->VBExtInfo
== YPbPr525p
)
1047 VCLKIndex
= YPbPr525pVCLK
;
1048 else if (pVBInfo
->SetFlag
& RPLLDIV2XO
)
1049 VCLKIndex
= YPbPr525iVCLK_2
;
1051 VCLKIndex
= YPbPr525iVCLK
;
1053 } else if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
1054 if (pVBInfo
->SetFlag
& RPLLDIV2XO
) {
1055 VCLKIndex
= TVCLKBASE_315_25
+ TVVCLKDIV2
;
1057 VCLKIndex
= TVCLKBASE_315_25
+ TVVCLK
;
1059 } else { /* for CRT2 */
1060 /* di+Ext_CRTVCLK */
1061 VCLKIndex
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].
1063 VCLKIndex
&= IndexMask
;
1066 if ((pVBInfo
->LCDResInfo
== Panel_800x600
) ||
1067 (pVBInfo
->LCDResInfo
== Panel_320x480
))
1068 VCLKIndex
= VCLK40
; /* LVDSXlat1VCLK */
1070 VCLKIndex
= VCLK65_315
+ 2; /* LVDSXlat2VCLK, LVDSXlat3VCLK */
1076 static void XGI_SetCRT1VCLK(unsigned short ModeNo
,
1077 unsigned short ModeIdIndex
,
1078 struct xgi_hw_device_info
*HwDeviceExtension
,
1079 unsigned short RefreshRateTableIndex
,
1080 struct vb_device_info
*pVBInfo
)
1082 unsigned char index
, data
;
1083 unsigned short vclkindex
;
1085 if (pVBInfo
->IF_DEF_LVDS
== 1) {
1086 index
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRTVCLK
;
1087 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x31) & 0xCF;
1088 xgifb_reg_set(pVBInfo
->P3c4
, 0x31, data
);
1089 xgifb_reg_set(pVBInfo
->P3c4
, 0x2B,
1090 pVBInfo
->VCLKData
[index
].SR2B
);
1091 xgifb_reg_set(pVBInfo
->P3c4
, 0x2C,
1092 pVBInfo
->VCLKData
[index
].SR2C
);
1093 xgifb_reg_set(pVBInfo
->P3c4
, 0x2D, 0x01);
1094 } else if ((pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
1095 | VB_SIS302LV
| VB_XGI301C
)) && (pVBInfo
->VBInfo
1096 & XGI_SetCRT2ToLCDA
)) {
1097 vclkindex
= XGI_GetVCLK2Ptr(ModeNo
, ModeIdIndex
,
1098 RefreshRateTableIndex
, HwDeviceExtension
,
1100 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x31) & 0xCF;
1101 xgifb_reg_set(pVBInfo
->P3c4
, 0x31, data
);
1102 data
= pVBInfo
->VBVCLKData
[vclkindex
].Part4_A
;
1103 xgifb_reg_set(pVBInfo
->P3c4
, 0x2B, data
);
1104 data
= pVBInfo
->VBVCLKData
[vclkindex
].Part4_B
;
1105 xgifb_reg_set(pVBInfo
->P3c4
, 0x2C, data
);
1106 xgifb_reg_set(pVBInfo
->P3c4
, 0x2D, 0x01);
1108 index
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRTVCLK
;
1109 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x31) & 0xCF;
1110 xgifb_reg_set(pVBInfo
->P3c4
, 0x31, data
);
1111 xgifb_reg_set(pVBInfo
->P3c4
, 0x2B,
1112 pVBInfo
->VCLKData
[index
].SR2B
);
1113 xgifb_reg_set(pVBInfo
->P3c4
, 0x2C,
1114 pVBInfo
->VCLKData
[index
].SR2C
);
1115 xgifb_reg_set(pVBInfo
->P3c4
, 0x2D, 0x01);
1118 if (HwDeviceExtension
->jChipType
>= XG20
) {
1119 if (pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
&
1121 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x2B);
1122 xgifb_reg_set(pVBInfo
->P3c4
, 0x2B, data
);
1123 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x2C);
1130 xgifb_reg_set(pVBInfo
->P3c4
, 0x2C, data
);
1135 static void XGI_SetXG21FPBits(struct vb_device_info
*pVBInfo
)
1139 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x37); /* D[0] 1: 18bit */
1140 temp
= (temp
& 1) << 6;
1141 /* SR06[6] 18bit Dither */
1142 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x06, ~0x40, temp
);
1143 /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */
1144 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x09, ~0xc0, temp
| 0x80);
1148 static void XGI_SetCRT1FIFO(unsigned short ModeNo
,
1149 struct xgi_hw_device_info
*HwDeviceExtension
,
1150 struct vb_device_info
*pVBInfo
)
1152 unsigned short data
;
1154 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x3D);
1156 xgifb_reg_set(pVBInfo
->P3c4
, 0x3D, data
); /* diable auto-threshold */
1158 xgifb_reg_set(pVBInfo
->P3c4
, 0x08, 0x34);
1159 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x09);
1161 xgifb_reg_set(pVBInfo
->P3c4
, 0x09, data
| 0x30);
1162 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x3D);
1164 xgifb_reg_set(pVBInfo
->P3c4
, 0x3D, data
);
1166 if (HwDeviceExtension
->jChipType
== XG21
)
1167 XGI_SetXG21FPBits(pVBInfo
); /* Fix SR9[7:6] can't read back */
1170 static void XGI_SetVCLKState(struct xgi_hw_device_info
*HwDeviceExtension
,
1171 unsigned short ModeNo
, unsigned short RefreshRateTableIndex
,
1172 struct vb_device_info
*pVBInfo
)
1174 unsigned short data
, data2
= 0;
1177 unsigned char index
;
1179 index
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRTVCLK
;
1181 VCLK
= pVBInfo
->VCLKData
[index
].CLOCK
;
1183 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x32);
1186 data
|= 0x0c; /* VCLK > 200 */
1188 if (HwDeviceExtension
->jChipType
>= XG20
)
1189 data
&= ~0x04; /* 2 pixel mode */
1191 xgifb_reg_set(pVBInfo
->P3c4
, 0x32, data
);
1193 if (HwDeviceExtension
->jChipType
< XG20
) {
1194 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x1F);
1198 xgifb_reg_set(pVBInfo
->P3c4
, 0x1F, data
);
1203 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x07, 0xFC, data2
);
1204 if (HwDeviceExtension
->jChipType
>= XG27
)
1205 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x40, 0xFC, data2
& 0x03);
1209 static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info
*HwDeviceExtension
,
1210 unsigned short ModeNo
, unsigned short ModeIdIndex
,
1211 unsigned short RefreshRateTableIndex
,
1212 struct vb_device_info
*pVBInfo
)
1214 unsigned short data
, data2
, data3
, infoflag
= 0, modeflag
, resindex
,
1217 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
1218 infoflag
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_InfoFlag
;
1220 if (xgifb_reg_get(pVBInfo
->P3d4
, 0x31) & 0x01)
1221 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x1F, 0x3F, 0x00);
1226 data3
= pVBInfo
->ModeType
- ModeVGA
;
1229 data
&= InterlaceMode
;
1234 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x06, ~0x3F, data2
);
1235 resindex
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
1236 xres
= pVBInfo
->ModeResInfo
[resindex
].HTotal
; /* xres->ax */
1239 if (infoflag
& InterlaceMode
) {
1242 else if (xres
== 1280)
1246 data2
= data
& 0x00FF;
1247 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x19, 0xFF, data2
);
1248 data2
= (data
& 0xFF00) >> 8;
1249 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x19, 0xFC, data2
);
1251 if (modeflag
& HalfDCLK
)
1252 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x01, 0xF7, 0x08);
1256 if (modeflag
& LineCompareOff
)
1259 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0F, ~0x48, data2
);
1263 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x21, 0x1F, data
);
1265 XGI_SetVCLKState(HwDeviceExtension
, ModeNo
, RefreshRateTableIndex
,
1268 data
= xgifb_reg_get(pVBInfo
->P3d4
, 0x31);
1270 if (HwDeviceExtension
->jChipType
== XG27
) {
1275 xgifb_reg_set(pVBInfo
->P3d4
, 0x52, data
);
1276 xgifb_reg_or(pVBInfo
->P3d4
, 0x51, 0x10);
1277 } else if (HwDeviceExtension
->jChipType
>= XG20
) {
1282 xgifb_reg_set(pVBInfo
->P3d4
, 0x52, data
);
1283 xgifb_reg_set(pVBInfo
->P3d4
, 0x51, 0x02);
1289 xgifb_reg_set(pVBInfo
->P3d4
, 0x52, data
);
1294 static void XGI_WriteDAC(unsigned short dl
,
1298 struct vb_device_info
*pVBInfo
)
1300 unsigned short temp
, bh
, bl
;
1319 outb((unsigned short) dh
, pVBInfo
->P3c9
);
1320 outb((unsigned short) bh
, pVBInfo
->P3c9
);
1321 outb((unsigned short) bl
, pVBInfo
->P3c9
);
1324 static void XGI_LoadDAC(unsigned short ModeNo
, unsigned short ModeIdIndex
,
1325 struct vb_device_info
*pVBInfo
)
1327 unsigned short data
, data2
, i
, k
, m
, n
, o
, si
, di
, bx
, dl
, al
, ah
, dh
;
1328 const unsigned short *table
= XGINew_VGA_DAC
;
1330 outb(0xFF, pVBInfo
->P3c6
);
1331 outb(0x00, pVBInfo
->P3c8
);
1333 for (i
= 0; i
< 16; i
++) {
1336 for (k
= 0; k
< 3; k
++) {
1345 outb(data2
, pVBInfo
->P3c9
);
1350 for (i
= 16; i
< 32; i
++) {
1353 for (k
= 0; k
< 3; k
++)
1354 outb(data
, pVBInfo
->P3c9
);
1359 for (m
= 0; m
< 9; m
++) {
1364 for (n
= 0; n
< 3; n
++) {
1365 for (o
= 0; o
< 5; o
++) {
1370 XGI_WriteDAC(dl
, ah
, al
, dh
, pVBInfo
);
1375 for (o
= 0; o
< 3; o
++) {
1380 XGI_WriteDAC(dl
, ah
, al
, dh
, pVBInfo
);
1390 static void XGI_GetLVDSResInfo(unsigned short ModeNo
,
1391 unsigned short ModeIdIndex
,
1392 struct vb_device_info
*pVBInfo
)
1394 unsigned short resindex
, xres
, yres
, modeflag
;
1396 /* si+Ext_ResInfo */
1397 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
1399 /* si+Ext_ResInfo */
1400 resindex
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
1402 xres
= pVBInfo
->ModeResInfo
[resindex
].HTotal
;
1403 yres
= pVBInfo
->ModeResInfo
[resindex
].VTotal
;
1405 if (modeflag
& HalfDCLK
)
1408 if (modeflag
& DoubleScanMode
)
1414 pVBInfo
->VGAHDE
= xres
;
1415 pVBInfo
->HDE
= xres
;
1416 pVBInfo
->VGAVDE
= yres
;
1417 pVBInfo
->VDE
= yres
;
1420 static void *XGI_GetLcdPtr(unsigned short BX
, unsigned short ModeNo
,
1421 unsigned short ModeIdIndex
,
1422 unsigned short RefreshRateTableIndex
,
1423 struct vb_device_info
*pVBInfo
)
1425 unsigned short i
, tempdx
, tempcx
, tempbx
, tempal
, modeflag
, table
;
1427 struct XGI330_LCDDataTablStruct
*tempdi
= NULL
;
1431 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
1432 tempal
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRT2CRTC
;
1434 tempal
= tempal
& 0x0f;
1436 if (tempbx
<= 1) { /* ExpLink */
1437 tempal
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRT2CRTC
;
1439 if (pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
) {
1440 tempal
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].
1445 tempal
= (tempal
>> 4);
1447 tempal
= (tempal
& 0x0f);
1450 tempcx
= LCDLenList
[tempbx
];
1452 if (pVBInfo
->LCDInfo
& EnableScalingLCD
) { /* ScaleLCD */
1453 if ((tempbx
== 5) || (tempbx
) == 7)
1454 tempcx
= LCDDesDataLen2
;
1455 else if ((tempbx
== 3) || (tempbx
== 8))
1456 tempcx
= LVDSDesDataLen2
;
1462 tempdi
= xgifb_epllcd_crt1
;
1465 tempdi
= XGI_EPLLCDDataPtr
;
1468 tempdi
= XGI_EPLLCDDesDataPtr
;
1471 tempdi
= XGI_LCDDataTable
;
1474 tempdi
= XGI_LCDDesDataTable
;
1477 tempdi
= XGI_EPLCHLCDRegPtr
;
1488 if (tempdi
== NULL
) /* OEMUtil */
1494 while (tempdi
[i
].PANELID
!= 0xff) {
1495 tempdx
= pVBInfo
->LCDResInfo
;
1496 if (tempbx
& 0x0080) { /* OEMUtil */
1497 tempbx
&= (~0x0080);
1498 tempdx
= pVBInfo
->LCDTypeInfo
;
1501 if (pVBInfo
->LCDInfo
& EnableScalingLCD
)
1502 tempdx
&= (~PanelResInfo
);
1504 if (tempdi
[i
].PANELID
== tempdx
) {
1505 tempbx
= tempdi
[i
].MASK
;
1506 tempdx
= pVBInfo
->LCDInfo
;
1508 if (modeflag
& HalfDCLK
)
1509 tempdx
|= SetLCDLowResolution
;
1512 if (tempbx
== tempdi
[i
].CAP
)
1519 switch (tempdi
[i
].DATAPTR
) {
1521 return &XGI_LVDSCRT11024x768_1_H
[tempal
];
1524 return &XGI_LVDSCRT11024x768_2_H
[tempal
];
1527 return &XGI_LVDSCRT11280x1024_1_H
[tempal
];
1530 return &XGI_LVDSCRT11280x1024_2_H
[tempal
];
1533 return &XGI_LVDSCRT11400x1050_1_H
[tempal
];
1536 return &XGI_LVDSCRT11400x1050_2_H
[tempal
];
1539 return &XGI_LVDSCRT11600x1200_1_H
[tempal
];
1542 return &XGI_LVDSCRT11024x768_1_Hx75
[tempal
];
1545 return &XGI_LVDSCRT11024x768_2_Hx75
[tempal
];
1548 return &XGI_LVDSCRT11280x1024_1_Hx75
[tempal
];
1551 return &XGI_LVDSCRT11280x1024_2_Hx75
[tempal
];
1556 } else if (table
== 1) {
1557 switch (tempdi
[i
].DATAPTR
) {
1559 return &XGI_LVDSCRT11024x768_1_V
[tempal
];
1562 return &XGI_LVDSCRT11024x768_2_V
[tempal
];
1565 return &XGI_LVDSCRT11280x1024_1_V
[tempal
];
1568 return &XGI_LVDSCRT11280x1024_2_V
[tempal
];
1571 return &XGI_LVDSCRT11400x1050_1_V
[tempal
];
1574 return &XGI_LVDSCRT11400x1050_2_V
[tempal
];
1577 return &XGI_LVDSCRT11600x1200_1_V
[tempal
];
1580 return &XGI_LVDSCRT11024x768_1_Vx75
[tempal
];
1583 return &XGI_LVDSCRT11024x768_2_Vx75
[tempal
];
1586 return &XGI_LVDSCRT11280x1024_1_Vx75
[tempal
];
1589 return &XGI_LVDSCRT11280x1024_2_Vx75
[tempal
];
1594 } else if (table
== 2) {
1595 switch (tempdi
[i
].DATAPTR
) {
1597 return &XGI_LVDS1024x768Data_1
[tempal
];
1600 return &XGI_LVDS1024x768Data_2
[tempal
];
1603 return &XGI_LVDS1280x1024Data_1
[tempal
];
1606 return &XGI_LVDS1280x1024Data_2
[tempal
];
1609 return &XGI_LVDS1400x1050Data_1
[tempal
];
1612 return &XGI_LVDS1400x1050Data_2
[tempal
];
1615 return &XGI_LVDS1600x1200Data_1
[tempal
];
1618 return &XGI_LVDSNoScalingData
[tempal
];
1621 return &XGI_LVDS1024x768Data_1x75
[tempal
];
1624 return &XGI_LVDS1024x768Data_2x75
[tempal
];
1627 return &XGI_LVDS1280x1024Data_1x75
[tempal
];
1630 return &XGI_LVDS1280x1024Data_2x75
[tempal
];
1633 return &XGI_LVDSNoScalingDatax75
[tempal
];
1638 } else if (table
== 3) {
1639 switch (tempdi
[i
].DATAPTR
) {
1641 return &XGI_LVDS1024x768Des_1
[tempal
];
1644 return &XGI_LVDS1024x768Des_3
[tempal
];
1647 return &XGI_LVDS1024x768Des_2
[tempal
];
1650 return &XGI_LVDS1280x1024Des_1
[tempal
];
1653 return &XGI_LVDS1280x1024Des_2
[tempal
];
1656 return &XGI_LVDS1400x1050Des_1
[tempal
];
1659 return &XGI_LVDS1400x1050Des_2
[tempal
];
1662 return &XGI_LVDS1600x1200Des_1
[tempal
];
1665 return &XGI_LVDSNoScalingDesData
[tempal
];
1668 return &XGI_LVDS1024x768Des_1x75
[tempal
];
1671 return &XGI_LVDS1024x768Des_3x75
[tempal
];
1674 return &XGI_LVDS1024x768Des_2x75
[tempal
];
1677 return &XGI_LVDS1280x1024Des_1x75
[tempal
];
1680 return &XGI_LVDS1280x1024Des_2x75
[tempal
];
1683 return &XGI_LVDSNoScalingDesDatax75
[tempal
];
1688 } else if (table
== 4) {
1689 switch (tempdi
[i
].DATAPTR
) {
1691 return &XGI_ExtLCD1024x768Data
[tempal
];
1694 return &XGI_StLCD1024x768Data
[tempal
];
1697 return &XGI_CetLCD1024x768Data
[tempal
];
1700 return &XGI_ExtLCD1280x1024Data
[tempal
];
1703 return &XGI_StLCD1280x1024Data
[tempal
];
1706 return &XGI_CetLCD1280x1024Data
[tempal
];
1710 return &xgifb_lcd_1400x1050
[tempal
];
1713 return &XGI_CetLCD1400x1050Data
[tempal
];
1716 return &XGI_ExtLCD1600x1200Data
[tempal
];
1719 return &XGI_StLCD1600x1200Data
[tempal
];
1722 return &XGI_NoScalingData
[tempal
];
1725 return &XGI_ExtLCD1024x768x75Data
[tempal
];
1728 return &XGI_ExtLCD1024x768x75Data
[tempal
];
1731 return &XGI_CetLCD1024x768x75Data
[tempal
];
1735 return &xgifb_lcd_1280x1024x75
[tempal
];
1738 return &XGI_CetLCD1280x1024x75Data
[tempal
];
1741 return &XGI_NoScalingDatax75
[tempal
];
1746 } else if (table
== 5) {
1747 switch (tempdi
[i
].DATAPTR
) {
1749 return &XGI_ExtLCDDes1024x768Data
[tempal
];
1752 return &XGI_StLCDDes1024x768Data
[tempal
];
1755 return &XGI_CetLCDDes1024x768Data
[tempal
];
1758 if ((pVBInfo
->VBType
& VB_SIS301LV
) ||
1759 (pVBInfo
->VBType
& VB_SIS302LV
))
1760 return &XGI_ExtLCDDLDes1280x1024Data
[tempal
];
1762 return &XGI_ExtLCDDes1280x1024Data
[tempal
];
1765 if ((pVBInfo
->VBType
& VB_SIS301LV
) ||
1766 (pVBInfo
->VBType
& VB_SIS302LV
))
1767 return &XGI_StLCDDLDes1280x1024Data
[tempal
];
1769 return &XGI_StLCDDes1280x1024Data
[tempal
];
1772 if ((pVBInfo
->VBType
& VB_SIS301LV
) ||
1773 (pVBInfo
->VBType
& VB_SIS302LV
))
1774 return &XGI_CetLCDDLDes1280x1024Data
[tempal
];
1776 return &XGI_CetLCDDes1280x1024Data
[tempal
];
1780 if ((pVBInfo
->VBType
& VB_SIS301LV
) ||
1781 (pVBInfo
->VBType
& VB_SIS302LV
))
1782 return &xgifb_lcddldes_1400x1050
[tempal
];
1784 return &xgifb_lcddes_1400x1050
[tempal
];
1787 return &XGI_CetLCDDes1400x1050Data
[tempal
];
1790 return &XGI_CetLCDDes1400x1050Data2
[tempal
];
1793 if ((pVBInfo
->VBType
& VB_SIS301LV
) ||
1794 (pVBInfo
->VBType
& VB_SIS302LV
))
1795 return &XGI_ExtLCDDLDes1600x1200Data
[tempal
];
1797 return &XGI_ExtLCDDes1600x1200Data
[tempal
];
1800 if ((pVBInfo
->VBType
& VB_SIS301LV
) ||
1801 (pVBInfo
->VBType
& VB_SIS302LV
))
1802 return &XGI_StLCDDLDes1600x1200Data
[tempal
];
1804 return &XGI_StLCDDes1600x1200Data
[tempal
];
1807 return &XGI_NoScalingDesData
[tempal
];
1811 return &xgifb_lcddes_1024x768x75
[tempal
];
1814 return &XGI_CetLCDDes1024x768x75Data
[tempal
];
1818 if ((pVBInfo
->VBType
& VB_SIS301LV
) ||
1819 (pVBInfo
->VBType
& VB_SIS302LV
))
1820 return &xgifb_lcddldes_1280x1024x75
[tempal
];
1822 return &xgifb_lcddes_1280x1024x75
[tempal
];
1825 if ((pVBInfo
->VBType
& VB_SIS301LV
) ||
1826 (pVBInfo
->VBType
& VB_SIS302LV
))
1827 return &XGI_CetLCDDLDes1280x1024x75Data
[tempal
];
1829 return &XGI_CetLCDDes1280x1024x75Data
[tempal
];
1832 return &XGI_NoScalingDesDatax75
[tempal
];
1837 } else if (table
== 6) {
1838 switch (tempdi
[i
].DATAPTR
) {
1840 return &XGI_CH7017LV1024x768
[tempal
];
1843 return &XGI_CH7017LV1400x1050
[tempal
];
1852 static void *XGI_GetTVPtr(unsigned short BX
, unsigned short ModeNo
,
1853 unsigned short ModeIdIndex
,
1854 unsigned short RefreshRateTableIndex
,
1855 struct vb_device_info
*pVBInfo
)
1857 unsigned short i
, tempdx
, tempbx
, tempal
, modeflag
, table
;
1858 struct XGI330_TVDataTablStruct
*tempdi
= NULL
;
1861 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
1862 tempal
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRT2CRTC
;
1863 tempal
= tempal
& 0x3f;
1875 tempdi
= xgifb_chrontel_tv
;
1881 tempdi
= XGI_TVDataTable
;
1890 if (tempdi
== NULL
) /* OEMUtil */
1893 tempdx
= pVBInfo
->TVInfo
;
1895 if (pVBInfo
->VBInfo
& SetInSlaveMode
)
1896 tempdx
= tempdx
| SetTVLockMode
;
1898 if (modeflag
& HalfDCLK
)
1899 tempdx
= tempdx
| SetTVLowResolution
;
1903 while (tempdi
[i
].MASK
!= 0xffff) {
1904 if ((tempdx
& tempdi
[i
].MASK
) == tempdi
[i
].CAP
)
1910 if (table
== 0x04) {
1911 switch (tempdi
[i
].DATAPTR
) {
1913 return &XGI_ExtPALData
[tempal
];
1916 return &XGI_ExtNTSCData
[tempal
];
1919 return &XGI_StPALData
[tempal
];
1922 return &XGI_StNTSCData
[tempal
];
1925 return &XGI_ExtHiTVData
[tempal
];
1928 return &XGI_St2HiTVData
[tempal
];
1931 return &XGI_ExtYPbPr525iData
[tempal
];
1934 return &XGI_ExtYPbPr525pData
[tempal
];
1937 return &XGI_ExtYPbPr750pData
[tempal
];
1940 return &XGI_StYPbPr525iData
[tempal
];
1943 return &XGI_StYPbPr525pData
[tempal
];
1946 return &XGI_StYPbPr750pData
[tempal
];
1948 case 12: /* avoid system hang */
1949 return &XGI_ExtNTSCData
[tempal
];
1952 return &XGI_St1HiTVData
[tempal
];
1957 } else if (table
== 0x02) {
1958 switch (tempdi
[i
].DATAPTR
) {
1960 return &XGI_CHTVUNTSCData
[tempal
];
1963 return &XGI_CHTVONTSCData
[tempal
];
1966 return &XGI_CHTVUPALData
[tempal
];
1969 return &XGI_CHTVOPALData
[tempal
];
1978 static void XGI_GetLVDSData(unsigned short ModeNo
, unsigned short ModeIdIndex
,
1979 unsigned short RefreshRateTableIndex
,
1980 struct vb_device_info
*pVBInfo
)
1982 unsigned short tempbx
;
1983 struct SiS_LVDSData
*LCDPtr
= NULL
;
1987 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| XGI_SetCRT2ToLCDA
)) {
1988 LCDPtr
= (struct SiS_LVDSData
*)XGI_GetLcdPtr(tempbx
,
1989 ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
1991 pVBInfo
->VGAHT
= LCDPtr
->VGAHT
;
1992 pVBInfo
->VGAVT
= LCDPtr
->VGAVT
;
1993 pVBInfo
->HT
= LCDPtr
->LCDHT
;
1994 pVBInfo
->VT
= LCDPtr
->LCDVT
;
1997 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| XGI_SetCRT2ToLCDA
)) {
1998 if (!(pVBInfo
->LCDInfo
& (SetLCDtoNonExpanding
1999 | EnableScalingLCD
))) {
2000 if ((pVBInfo
->LCDResInfo
== Panel_1024x768
) ||
2001 (pVBInfo
->LCDResInfo
== Panel_1024x768x75
)) {
2002 pVBInfo
->HDE
= 1024;
2004 } else if ((pVBInfo
->LCDResInfo
== Panel_1280x1024
) ||
2005 (pVBInfo
->LCDResInfo
== Panel_1280x1024x75
)) {
2006 pVBInfo
->HDE
= 1280;
2007 pVBInfo
->VDE
= 1024;
2008 } else if (pVBInfo
->LCDResInfo
== Panel_1400x1050
) {
2009 pVBInfo
->HDE
= 1400;
2010 pVBInfo
->VDE
= 1050;
2012 pVBInfo
->HDE
= 1600;
2013 pVBInfo
->VDE
= 1200;
2019 static void XGI_ModCRT1Regs(unsigned short ModeNo
, unsigned short ModeIdIndex
,
2020 unsigned short RefreshRateTableIndex
,
2021 struct xgi_hw_device_info
*HwDeviceExtension
,
2022 struct vb_device_info
*pVBInfo
)
2024 unsigned char index
;
2025 unsigned short tempbx
, i
;
2026 struct XGI_LVDSCRT1HDataStruct
*LCDPtr
= NULL
;
2027 struct XGI_LVDSCRT1VDataStruct
*LCDPtr1
= NULL
;
2029 index
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRT2CRTC
;
2030 index
= index
& IndexMask
;
2034 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| XGI_SetCRT2ToLCDA
)) {
2035 LCDPtr
= (struct XGI_LVDSCRT1HDataStruct
*)
2036 XGI_GetLcdPtr(tempbx
, ModeNo
,
2038 RefreshRateTableIndex
,
2041 for (i
= 0; i
< 8; i
++)
2042 pVBInfo
->TimingH
[0].data
[i
] = LCDPtr
[0].Reg
[i
];
2045 XGI_SetCRT1Timing_H(pVBInfo
, HwDeviceExtension
);
2049 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| XGI_SetCRT2ToLCDA
)) {
2050 LCDPtr1
= (struct XGI_LVDSCRT1VDataStruct
*)
2055 RefreshRateTableIndex
,
2057 for (i
= 0; i
< 7; i
++)
2058 pVBInfo
->TimingV
[0].data
[i
] = LCDPtr1
[0].Reg
[i
];
2061 XGI_SetCRT1Timing_V(ModeIdIndex
, ModeNo
, pVBInfo
);
2064 static unsigned short XGI_GetLCDCapPtr(struct vb_device_info
*pVBInfo
)
2066 unsigned char tempal
, tempah
, tempbl
, i
;
2068 tempah
= xgifb_reg_get(pVBInfo
->P3d4
, 0x36);
2069 tempal
= tempah
& 0x0F;
2070 tempah
= tempah
& 0xF0;
2072 tempbl
= pVBInfo
->LCDCapList
[i
].LCD_ID
;
2074 while (tempbl
!= 0xFF) {
2075 if (tempbl
& 0x80) { /* OEMUtil */
2077 tempbl
= tempbl
& ~(0x80);
2080 if (tempal
== tempbl
)
2085 tempbl
= pVBInfo
->LCDCapList
[i
].LCD_ID
;
2091 static unsigned short XGI_GetLCDCapPtr1(struct vb_device_info
*pVBInfo
)
2093 unsigned short tempah
, tempal
, tempbl
, i
;
2095 tempal
= pVBInfo
->LCDResInfo
;
2096 tempah
= pVBInfo
->LCDTypeInfo
;
2099 tempbl
= pVBInfo
->LCDCapList
[i
].LCD_ID
;
2101 while (tempbl
!= 0xFF) {
2102 if ((tempbl
& 0x80) && (tempbl
!= 0x80)) {
2107 if (tempal
== tempbl
)
2111 tempbl
= pVBInfo
->LCDCapList
[i
].LCD_ID
;
2114 if (tempbl
== 0xFF) {
2115 pVBInfo
->LCDResInfo
= Panel_1024x768
;
2116 pVBInfo
->LCDTypeInfo
= 0;
2123 static void XGI_GetLCDSync(unsigned short *HSyncWidth
,
2124 unsigned short *VSyncWidth
,
2125 struct vb_device_info
*pVBInfo
)
2127 unsigned short Index
;
2129 Index
= XGI_GetLCDCapPtr(pVBInfo
);
2130 *HSyncWidth
= pVBInfo
->LCDCapList
[Index
].LCD_HSyncWidth
;
2131 *VSyncWidth
= pVBInfo
->LCDCapList
[Index
].LCD_VSyncWidth
;
2136 static void XGI_SetLVDSRegs(unsigned short ModeNo
, unsigned short ModeIdIndex
,
2137 unsigned short RefreshRateTableIndex
,
2138 struct vb_device_info
*pVBInfo
)
2140 unsigned short tempbx
, tempax
, tempcx
, tempdx
, push1
, push2
, modeflag
;
2141 unsigned long temp
, temp1
, temp2
, temp3
, push3
;
2142 struct XGI_LCDDesStruct
*LCDPtr
= NULL
;
2143 struct XGI330_LCDDataDesStruct2
*LCDPtr1
= NULL
;
2145 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
2147 if (pVBInfo
->LCDInfo
& EnableScalingLCD
)
2149 (struct XGI330_LCDDataDesStruct2
*)
2154 RefreshRateTableIndex
,
2158 (struct XGI_LCDDesStruct
*)
2163 RefreshRateTableIndex
,
2166 XGI_GetLCDSync(&tempax
, &tempbx
, pVBInfo
);
2171 if ((pVBInfo
->LCDResInfo
== Panel_1024x768
) ||
2172 (pVBInfo
->LCDResInfo
== Panel_1024x768x75
)) {
2175 } else if ((pVBInfo
->LCDResInfo
== Panel_1280x1024
) ||
2176 (pVBInfo
->LCDResInfo
== Panel_1280x1024x75
)) {
2179 } else if (pVBInfo
->LCDResInfo
== Panel_1400x1050
) {
2187 if (pVBInfo
->LCDInfo
& SetLCDtoNonExpanding
) {
2188 pVBInfo
->HDE
= tempax
;
2189 pVBInfo
->VDE
= tempbx
;
2190 pVBInfo
->VGAHDE
= tempax
;
2191 pVBInfo
->VGAVDE
= tempbx
;
2194 tempax
= pVBInfo
->HT
;
2196 if (pVBInfo
->LCDInfo
& EnableScalingLCD
)
2197 tempbx
= LCDPtr1
->LCDHDES
;
2199 tempbx
= LCDPtr
->LCDHDES
;
2201 tempcx
= pVBInfo
->HDE
;
2202 tempbx
= tempbx
& 0x0fff;
2205 if (tempcx
>= tempax
)
2208 xgifb_reg_set(pVBInfo
->Part1Port
, 0x1A, tempbx
& 0x07);
2210 tempcx
= tempcx
>> 3;
2211 tempbx
= tempbx
>> 3;
2213 xgifb_reg_set(pVBInfo
->Part1Port
, 0x16,
2214 (unsigned short) (tempbx
& 0xff));
2215 xgifb_reg_set(pVBInfo
->Part1Port
, 0x17,
2216 (unsigned short) (tempcx
& 0xff));
2218 tempax
= pVBInfo
->HT
;
2220 if (pVBInfo
->LCDInfo
& EnableScalingLCD
)
2221 tempbx
= LCDPtr1
->LCDHRS
;
2223 tempbx
= LCDPtr
->LCDHRS
;
2227 if (pVBInfo
->LCDInfo
& EnableScalingLCD
)
2228 tempcx
= LCDPtr1
->LCDHSync
;
2232 if (tempcx
>= tempax
)
2235 tempax
= tempbx
& 0x07;
2236 tempax
= tempax
>> 5;
2237 tempcx
= tempcx
>> 3;
2238 tempbx
= tempbx
>> 3;
2243 xgifb_reg_set(pVBInfo
->Part1Port
, 0x15, tempax
);
2244 xgifb_reg_set(pVBInfo
->Part1Port
, 0x14,
2245 (unsigned short) (tempbx
& 0xff));
2247 tempax
= pVBInfo
->VT
;
2248 if (pVBInfo
->LCDInfo
& EnableScalingLCD
)
2249 tempbx
= LCDPtr1
->LCDVDES
;
2251 tempbx
= LCDPtr
->LCDVDES
;
2252 tempcx
= pVBInfo
->VDE
;
2254 tempbx
= tempbx
& 0x0fff;
2256 if (tempcx
>= tempax
)
2259 xgifb_reg_set(pVBInfo
->Part1Port
, 0x1b,
2260 (unsigned short) (tempbx
& 0xff));
2261 xgifb_reg_set(pVBInfo
->Part1Port
, 0x1c,
2262 (unsigned short) (tempcx
& 0xff));
2264 tempbx
= (tempbx
>> 8) & 0x07;
2265 tempcx
= (tempcx
>> 8) & 0x07;
2267 xgifb_reg_set(pVBInfo
->Part1Port
, 0x1d,
2268 (unsigned short) ((tempcx
<< 3)
2271 tempax
= pVBInfo
->VT
;
2272 if (pVBInfo
->LCDInfo
& EnableScalingLCD
)
2273 tempbx
= LCDPtr1
->LCDVRS
;
2275 tempbx
= LCDPtr
->LCDVRS
;
2279 if (pVBInfo
->LCDInfo
& EnableScalingLCD
)
2280 tempcx
= LCDPtr1
->LCDVSync
;
2283 if (tempcx
>= tempax
)
2286 xgifb_reg_set(pVBInfo
->Part1Port
, 0x18,
2287 (unsigned short) (tempbx
& 0xff));
2288 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x19, ~0x0f,
2289 (unsigned short) (tempcx
& 0x0f));
2291 tempax
= ((tempbx
>> 8) & 0x07) << 3;
2293 tempbx
= pVBInfo
->VGAVDE
;
2294 if (tempbx
!= pVBInfo
->VDE
)
2297 if (pVBInfo
->LCDInfo
& XGI_EnableLVDSDDA
)
2300 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x1a, 0x07,
2303 tempcx
= pVBInfo
->VGAVT
;
2304 tempbx
= pVBInfo
->VDE
;
2305 tempax
= pVBInfo
->VGAVDE
;
2308 temp
= tempax
; /* 0430 ylshieh */
2309 temp1
= (temp
<< 18) / tempbx
;
2311 tempdx
= (unsigned short) ((temp
<< 18) % tempbx
);
2319 xgifb_reg_set(pVBInfo
->Part1Port
, 0x37,
2320 (unsigned short) (temp2
& 0xff));
2321 xgifb_reg_set(pVBInfo
->Part1Port
, 0x36,
2322 (unsigned short) ((temp2
>> 8) & 0xff));
2324 tempbx
= (unsigned short) (temp2
>> 16);
2325 tempax
= tempbx
& 0x03;
2327 tempbx
= pVBInfo
->VGAVDE
;
2328 if (tempbx
== pVBInfo
->VDE
)
2331 xgifb_reg_set(pVBInfo
->Part1Port
, 0x35, tempax
);
2333 if (pVBInfo
->VBType
& VB_XGI301C
) {
2335 xgifb_reg_set(pVBInfo
->Part4Port
,
2337 (unsigned short) (temp2
& 0xff));
2338 xgifb_reg_set(pVBInfo
->Part4Port
,
2340 (unsigned short) ((temp2
>> 8) &
2342 tempbx
= (unsigned short) (temp2
>> 16);
2343 xgifb_reg_and_or(pVBInfo
->Part4Port
, 0x3a,
2345 (unsigned short) ((tempbx
&
2348 tempcx
= pVBInfo
->VGAVDE
;
2349 if (tempcx
== pVBInfo
->VDE
)
2350 xgifb_reg_and_or(pVBInfo
->Part4Port
,
2353 xgifb_reg_and_or(pVBInfo
->Part4Port
,
2357 tempcx
= pVBInfo
->VGAHDE
;
2358 tempbx
= pVBInfo
->HDE
;
2360 temp1
= tempcx
<< 16;
2362 tempax
= (unsigned short) (temp1
/ tempbx
);
2364 if ((tempbx
& 0xffff) == (tempcx
& 0xffff))
2368 temp1
= pVBInfo
->VGAHDE
<< 16;
2371 temp3
= temp3
<< 16;
2374 temp3
= (temp3
& 0xffff0000) + (temp1
& 0xffff);
2376 tempax
= (unsigned short) (temp3
& 0xff);
2377 xgifb_reg_set(pVBInfo
->Part1Port
, 0x1f, tempax
);
2379 temp1
= pVBInfo
->VGAVDE
<< 18;
2380 temp1
= temp1
/ push3
;
2381 tempbx
= (unsigned short) (temp1
& 0xffff);
2383 if (pVBInfo
->LCDResInfo
== Panel_1024x768
)
2386 tempax
= ((tempbx
>> 8) & 0xff) << 3;
2387 tempax
|= (unsigned short) ((temp3
>> 8) & 0x07);
2388 xgifb_reg_set(pVBInfo
->Part1Port
, 0x20,
2389 (unsigned short) (tempax
& 0xff));
2390 xgifb_reg_set(pVBInfo
->Part1Port
, 0x21,
2391 (unsigned short) (tempbx
& 0xff));
2393 temp3
= temp3
>> 16;
2395 if (modeflag
& HalfDCLK
)
2398 xgifb_reg_set(pVBInfo
->Part1Port
, 0x22,
2399 (unsigned short) ((temp3
>> 8) & 0xff));
2400 xgifb_reg_set(pVBInfo
->Part1Port
, 0x23,
2401 (unsigned short) (temp3
& 0xff));
2404 /* --------------------------------------------------------------------- */
2405 /* Function : XGI_GETLCDVCLKPtr */
2407 /* Output : al -> VCLK Index */
2409 /* --------------------------------------------------------------------- */
2410 static void XGI_GetLCDVCLKPtr(unsigned char *di_0
, unsigned char *di_1
,
2411 struct vb_device_info
*pVBInfo
)
2413 unsigned short index
;
2415 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| XGI_SetCRT2ToLCDA
)) {
2416 index
= XGI_GetLCDCapPtr1(pVBInfo
);
2418 if (pVBInfo
->VBInfo
& SetCRT2ToLCD
) { /* LCDB */
2419 *di_0
= pVBInfo
->LCDCapList
[index
].LCUCHAR_VCLKData1
;
2420 *di_1
= pVBInfo
->LCDCapList
[index
].LCUCHAR_VCLKData2
;
2422 *di_0
= pVBInfo
->LCDCapList
[index
].LCDA_VCLKData1
;
2423 *di_1
= pVBInfo
->LCDCapList
[index
].LCDA_VCLKData2
;
2429 static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex
,
2430 unsigned short ModeNo
, unsigned short ModeIdIndex
,
2431 struct vb_device_info
*pVBInfo
)
2434 unsigned short index
, modeflag
;
2435 unsigned char tempal
;
2437 /* si+Ext_ResInfo */
2438 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
2440 if ((pVBInfo
->SetFlag
& ProgrammingCRT2
) &&
2441 (!(pVBInfo
->LCDInfo
& EnableScalingLCD
))) { /* {LCDA/LCDB} */
2442 index
= XGI_GetLCDCapPtr(pVBInfo
);
2443 tempal
= pVBInfo
->LCDCapList
[index
].LCD_VCLK
;
2445 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| XGI_SetCRT2ToLCDA
))
2449 if (pVBInfo
->VBType
&
2455 if (pVBInfo
->VBInfo
& SetCRT2ToHiVision
) {
2456 tempal
= TVCLKBASE_315
+ HiTVVCLKDIV2
;
2457 if (!(pVBInfo
->TVInfo
& RPLLDIV2XO
))
2458 tempal
= TVCLKBASE_315
+ HiTVVCLK
;
2459 if (pVBInfo
->TVInfo
& TVSimuMode
) {
2460 tempal
= TVCLKBASE_315
+ HiTVSimuVCLK
;
2461 if (!(modeflag
& Charx8Dot
))
2462 tempal
= TVCLKBASE_315
+ HiTVTextVCLK
;
2468 if (pVBInfo
->TVInfo
& TVSetYPbPr750p
) {
2469 tempal
= XGI_YPbPr750pVCLK
;
2473 if (pVBInfo
->TVInfo
& TVSetYPbPr525p
) {
2474 tempal
= YPbPr525pVCLK
;
2478 tempal
= NTSC1024VCLK
;
2480 if (!(pVBInfo
->TVInfo
& NTSC1024x768
)) {
2481 tempal
= TVCLKBASE_315
+ TVVCLKDIV2
;
2482 if (!(pVBInfo
->TVInfo
& RPLLDIV2XO
))
2483 tempal
= TVCLKBASE_315
+ TVVCLK
;
2486 if (pVBInfo
->VBInfo
& SetCRT2ToTV
)
2491 tempal
= (unsigned char) inb((pVBInfo
->P3ca
+ 0x02));
2492 tempal
= tempal
>> 2;
2495 /* for Dot8 Scaling LCD */
2496 if ((pVBInfo
->LCDInfo
& EnableScalingLCD
) && (modeflag
& Charx8Dot
))
2497 tempal
= tempal
^ tempal
; /* ; set to VCLK25MHz always */
2499 tempal
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRTVCLK
;
2503 static void XGI_GetVCLKLen(unsigned char tempal
, unsigned char *di_0
,
2504 unsigned char *di_1
, struct vb_device_info
*pVBInfo
)
2506 if (pVBInfo
->VBType
& (VB_SIS301
| VB_SIS301B
| VB_SIS302B
2507 | VB_SIS301LV
| VB_SIS302LV
| VB_XGI301C
)) {
2508 if ((!(pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
)) && (pVBInfo
->SetFlag
2509 & ProgrammingCRT2
)) {
2510 *di_0
= (unsigned char) XGI_VBVCLKData
[tempal
].SR2B
;
2511 *di_1
= XGI_VBVCLKData
[tempal
].SR2C
;
2514 *di_0
= XGI_VCLKData
[tempal
].SR2B
;
2515 *di_1
= XGI_VCLKData
[tempal
].SR2C
;
2519 static void XGI_SetCRT2ECLK(unsigned short ModeNo
, unsigned short ModeIdIndex
,
2520 unsigned short RefreshRateTableIndex
,
2521 struct vb_device_info
*pVBInfo
)
2523 unsigned char di_0
, di_1
, tempal
;
2526 tempal
= XGI_GetVCLKPtr(RefreshRateTableIndex
, ModeNo
, ModeIdIndex
,
2528 XGI_GetVCLKLen(tempal
, &di_0
, &di_1
, pVBInfo
);
2529 XGI_GetLCDVCLKPtr(&di_0
, &di_1
, pVBInfo
);
2531 for (i
= 0; i
< 4; i
++) {
2532 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x31, ~0x30,
2533 (unsigned short) (0x10 * i
));
2534 if ((!(pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
))
2535 && (!(pVBInfo
->VBInfo
& SetInSlaveMode
))) {
2536 xgifb_reg_set(pVBInfo
->P3c4
, 0x2e, di_0
);
2537 xgifb_reg_set(pVBInfo
->P3c4
, 0x2f, di_1
);
2539 xgifb_reg_set(pVBInfo
->P3c4
, 0x2b, di_0
);
2540 xgifb_reg_set(pVBInfo
->P3c4
, 0x2c, di_1
);
2545 static void XGI_UpdateModeInfo(struct xgi_hw_device_info
*HwDeviceExtension
,
2546 struct vb_device_info
*pVBInfo
)
2548 unsigned short tempcl
, tempch
, temp
, tempbl
, tempax
;
2550 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
2551 | VB_SIS302LV
| VB_XGI301C
)) {
2554 temp
= xgifb_reg_get(pVBInfo
->P3c4
, 0x01);
2556 if (!(temp
& 0x20)) {
2557 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x17);
2559 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x53);
2561 tempcl
|= ActiveCRT1
;
2565 temp
= xgifb_reg_get(pVBInfo
->Part1Port
, 0x2e);
2568 if (!(temp
== 0x08)) {
2569 /* Check ChannelA by Part1_13 [2003/10/03] */
2570 tempax
= xgifb_reg_get(pVBInfo
->Part1Port
, 0x13);
2572 tempcl
= tempcl
| ActiveLCD
;
2576 if (!(tempcl
& ActiveLCD
))
2578 tempcl
|= ActiveCRT2
;
2581 tempcl
|= ActiveLCD
;
2584 temp
= xgifb_reg_get(pVBInfo
->Part2Port
, 0x00);
2587 tempch
|= ActiveAVideo
;
2590 tempch
|= ActiveSVideo
;
2593 tempch
|= ActiveSCART
;
2595 if (pVBInfo
->VBInfo
& SetCRT2ToHiVision
) {
2597 tempch
|= ActiveHiTV
;
2600 if (pVBInfo
->VBInfo
& SetCRT2ToYPbPr525750
) {
2601 temp
= xgifb_reg_get(
2606 tempch
|= ActiveYPbPr
;
2614 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x3d);
2615 if (tempcl
& ActiveLCD
) {
2616 if ((pVBInfo
->SetFlag
& ReserveTVOption
)) {
2617 if (temp
& ActiveTV
)
2622 tempbl
= ~XGI_ModeSwitchStatus
;
2623 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x3d, tempbl
, temp
);
2625 if (!(pVBInfo
->SetFlag
& ReserveTVOption
))
2626 xgifb_reg_set(pVBInfo
->P3d4
, 0x3e, tempch
);
2632 void XGI_GetVBType(struct vb_device_info
*pVBInfo
)
2634 unsigned short flag
, tempbx
, tempah
;
2636 if (pVBInfo
->IF_DEF_LVDS
== 0) {
2637 tempbx
= VB_SIS302B
;
2638 flag
= xgifb_reg_get(pVBInfo
->Part4Port
, 0x00);
2641 flag
= xgifb_reg_get(pVBInfo
->Part4Port
, 0x01);
2643 tempbx
= VB_SIS301B
;
2645 tempbx
= VB_XGI301C
;
2647 tempbx
= VB_SIS301LV
;
2649 tempbx
= VB_SIS302LV
;
2650 tempah
= xgifb_reg_get(
2660 if (tempbx
& (VB_SIS301B
| VB_SIS302B
)) {
2661 flag
= xgifb_reg_get(
2666 tempbx
= tempbx
| VB_NoLCD
;
2670 pVBInfo
->VBType
= tempbx
;
2674 static void XGI_GetVBInfo(unsigned short ModeNo
, unsigned short ModeIdIndex
,
2675 struct xgi_hw_device_info
*HwDeviceExtension
,
2676 struct vb_device_info
*pVBInfo
)
2678 unsigned short tempax
, push
, tempbx
, temp
, modeflag
;
2680 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
2681 pVBInfo
->SetFlag
= 0;
2682 pVBInfo
->ModeType
= modeflag
& ModeTypeMask
;
2685 if (pVBInfo
->VBType
& 0xFFFF) {
2686 /* Check Display Device */
2687 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x30);
2688 tempbx
= tempbx
| temp
;
2689 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x31);
2693 tempbx
= tempbx
| tempax
;
2694 temp
= (SetCRT2ToDualEdge
| SetCRT2ToYPbPr525750
| XGI_SetCRT2ToLCDA
2695 | SetInSlaveMode
| DisableCRT2Display
);
2696 temp
= 0xFFFF ^ temp
;
2699 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x38);
2701 if (pVBInfo
->IF_DEF_LCDA
== 1) {
2703 if ((HwDeviceExtension
->jChipType
>= XG20
) ||
2704 (HwDeviceExtension
->jChipType
>= XG40
)) {
2705 if (pVBInfo
->IF_DEF_LVDS
== 0) {
2706 if (pVBInfo
->VBType
&
2711 if (temp
& EnableDualEdge
) {
2715 if (temp
& SetToLCDA
)
2724 if (pVBInfo
->IF_DEF_YPbPr
== 1) {
2725 /* [Billy] 07/05/04 */
2726 if (((pVBInfo
->IF_DEF_LVDS
== 0) &&
2727 ((pVBInfo
->VBType
& VB_SIS301LV
) ||
2728 (pVBInfo
->VBType
& VB_SIS302LV
) ||
2729 (pVBInfo
->VBType
& VB_XGI301C
)))) {
2730 if (temp
& SetYPbPr
) {
2731 if (pVBInfo
->IF_DEF_HiVision
== 1) {
2732 /* shampoo add for new
2734 temp
= xgifb_reg_get(
2738 tempbx
|= SetCRT2ToHiVision
;
2740 if (temp
!= YPbPrMode1080i
) {
2742 (~SetCRT2ToHiVision
);
2744 SetCRT2ToYPbPr525750
;
2751 tempax
= push
; /* restore CR31 */
2753 if (pVBInfo
->IF_DEF_LVDS
== 0) {
2754 if (pVBInfo
->IF_DEF_YPbPr
== 1) {
2755 if (pVBInfo
->IF_DEF_HiVision
== 1)
2760 if (pVBInfo
->IF_DEF_HiVision
== 1)
2765 } else { /* 3nd party chip */
2766 temp
= SetCRT2ToLCD
;
2769 if (!(tempbx
& temp
)) {
2770 tempax
|= DisableCRT2Display
;
2774 if (pVBInfo
->IF_DEF_LCDA
== 1) { /* Select Display Device */
2775 if (!(pVBInfo
->VBType
& VB_NoLCD
)) {
2776 if (tempbx
& XGI_SetCRT2ToLCDA
) {
2777 if (tempbx
& SetSimuScanMode
)
2778 tempbx
&= (~(SetCRT2ToLCD
|
2782 tempbx
&= (~(SetCRT2ToLCD
|
2791 /* for driver abnormal */
2792 if (!(tempbx
& (SwitchCRT2
| SetSimuScanMode
))) {
2793 if (pVBInfo
->IF_DEF_CRT2Monitor
== 1) {
2794 if (tempbx
& SetCRT2ToRAMDAC
) {
2799 tempbx
&= (0x00FF | (~SetCRT2ToYPbPr525750
));
2802 tempbx
&= (~(SetCRT2ToRAMDAC
|
2808 if (!(pVBInfo
->VBType
& VB_NoLCD
)) {
2809 if (tempbx
& SetCRT2ToLCD
) {
2814 tempbx
&= (0x00FF | (~SetCRT2ToYPbPr525750
));
2818 if (tempbx
& SetCRT2ToSCART
) {
2823 tempbx
&= (0x00FF | (~SetCRT2ToYPbPr525750
));
2826 if (pVBInfo
->IF_DEF_YPbPr
== 1) {
2827 if (tempbx
& SetCRT2ToYPbPr525750
)
2833 if (pVBInfo
->IF_DEF_HiVision
== 1) {
2834 if (tempbx
& SetCRT2ToHiVision
)
2841 if (tempax
& DisableCRT2Display
) { /* Set Display Device Info */
2842 if (!(tempbx
& (SwitchCRT2
| SetSimuScanMode
)))
2843 tempbx
= DisableCRT2Display
;
2846 if (!(tempbx
& DisableCRT2Display
)) {
2847 if ((!(tempbx
& DriverMode
)) ||
2848 (!(modeflag
& CRT2Mode
))) {
2849 if (pVBInfo
->IF_DEF_LCDA
== 1) {
2850 if (!(tempbx
& XGI_SetCRT2ToLCDA
))
2851 tempbx
|= (SetInSlaveMode
|
2856 /* LCD+TV can't support in slave mode
2857 * (Force LCDA+TV->LCDB) */
2858 if ((tempbx
& SetInSlaveMode
) &&
2859 (tempbx
& XGI_SetCRT2ToLCDA
)) {
2860 tempbx
^= (SetCRT2ToLCD
|
2863 pVBInfo
->SetFlag
|= ReserveTVOption
;
2868 pVBInfo
->VBInfo
= tempbx
;
2871 static void XGI_GetTVInfo(unsigned short ModeNo
, unsigned short ModeIdIndex
,
2872 struct vb_device_info
*pVBInfo
)
2874 unsigned short temp
, tempbx
= 0, resinfo
= 0, modeflag
, index1
;
2879 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
2880 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
2881 resinfo
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
2883 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
2884 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x35);
2886 if (tempbx
& TVSetPAL
) {
2887 tempbx
&= (SetCHTVOverScan
|
2891 if (tempbx
& TVSetPALM
)
2892 /* set to NTSC if PAL-M */
2893 tempbx
&= ~TVSetPAL
;
2895 tempbx
&= (SetCHTVOverScan
|
2900 if (pVBInfo
->IF_DEF_LVDS
== 0) {
2901 if (pVBInfo
->VBInfo
& SetCRT2ToSCART
)
2905 if (pVBInfo
->IF_DEF_YPbPr
== 1) {
2906 if (pVBInfo
->VBInfo
& SetCRT2ToYPbPr525750
) {
2907 index1
= xgifb_reg_get(pVBInfo
->P3d4
, 0x35);
2908 index1
&= YPbPrMode
;
2910 if (index1
== YPbPrMode525i
)
2911 tempbx
|= TVSetYPbPr525i
;
2913 if (index1
== YPbPrMode525p
)
2914 tempbx
= tempbx
| TVSetYPbPr525p
;
2915 if (index1
== YPbPrMode750p
)
2916 tempbx
= tempbx
| TVSetYPbPr750p
;
2920 if (pVBInfo
->IF_DEF_HiVision
== 1) {
2921 if (pVBInfo
->VBInfo
& SetCRT2ToHiVision
)
2922 tempbx
= tempbx
| TVSetHiVision
| TVSetPAL
;
2925 if (pVBInfo
->IF_DEF_LVDS
== 0) { /* shampoo */
2926 if ((pVBInfo
->VBInfo
& SetInSlaveMode
) &&
2927 (!(pVBInfo
->VBInfo
& SetNotSimuMode
)))
2928 tempbx
|= TVSimuMode
;
2930 if (!(tempbx
& TVSetPAL
) &&
2932 (resinfo
== 8)) /* NTSC 1024x768, */
2933 tempbx
|= NTSC1024x768
;
2935 tempbx
|= RPLLDIV2XO
;
2937 if (pVBInfo
->VBInfo
& SetCRT2ToHiVision
) {
2938 if (pVBInfo
->VBInfo
& SetInSlaveMode
)
2939 tempbx
&= (~RPLLDIV2XO
);
2942 (TVSetYPbPr525p
| TVSetYPbPr750p
))
2943 tempbx
&= (~RPLLDIV2XO
);
2944 else if (!(pVBInfo
->VBType
&
2950 if (tempbx
& TVSimuMode
)
2951 tempbx
&= (~RPLLDIV2XO
);
2956 pVBInfo
->TVInfo
= tempbx
;
2959 static unsigned char XGI_GetLCDInfo(unsigned short ModeNo
,
2960 unsigned short ModeIdIndex
, struct vb_device_info
*pVBInfo
)
2962 unsigned short temp
, tempax
, tempbx
, modeflag
, resinfo
= 0, LCDIdIndex
;
2964 pVBInfo
->LCDResInfo
= 0;
2965 pVBInfo
->LCDTypeInfo
= 0;
2966 pVBInfo
->LCDInfo
= 0;
2968 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
2969 /* si+Ext_ResInfo // */
2970 resinfo
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
2971 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x36); /* Get LCD Res.Info */
2972 tempbx
= temp
& 0x0F;
2975 tempbx
= Panel_1024x768
; /* default */
2977 /* LCD75 [2003/8/22] Vicent */
2978 if ((tempbx
== Panel_1024x768
) || (tempbx
== Panel_1280x1024
)) {
2979 if (pVBInfo
->VBInfo
& DriverMode
) {
2980 tempax
= xgifb_reg_get(pVBInfo
->P3d4
, 0x33);
2981 if (pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
)
2984 tempax
= tempax
>> 4;
2986 if ((resinfo
== 6) || (resinfo
== 9)) {
2988 tempbx
|= PanelRef75Hz
;
2989 } else if ((resinfo
== 7) || (resinfo
== 8)) {
2991 tempbx
|= PanelRef75Hz
;
2996 pVBInfo
->LCDResInfo
= tempbx
;
3000 if (!(pVBInfo
->VBInfo
& (SetCRT2ToLCD
| XGI_SetCRT2ToLCDA
)))
3005 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x37);
3007 temp
&= (ScalingLCD
| LCDNonExpanding
| LCDSyncBit
| SetPWDEnable
);
3011 LCDIdIndex
= XGI_GetLCDCapPtr1(pVBInfo
);
3013 tempax
= pVBInfo
->LCDCapList
[LCDIdIndex
].LCD_Capability
;
3015 if (pVBInfo
->IF_DEF_LVDS
== 0) { /* shampoo */
3016 if (((pVBInfo
->VBType
& VB_SIS302LV
) || (pVBInfo
->VBType
3017 & VB_XGI301C
)) && (tempax
& XGI_LCDDualLink
)) {
3018 tempbx
|= SetLCDDualLink
;
3022 if (pVBInfo
->IF_DEF_LVDS
== 0) {
3023 if ((pVBInfo
->LCDResInfo
== Panel_1400x1050
) && (pVBInfo
->VBInfo
3024 & SetCRT2ToLCD
) && (resinfo
== 9) &&
3025 (!(tempbx
& EnableScalingLCD
)))
3026 /* set to center in 1280x1024 LCDB for Panel_1400x1050 */
3027 tempbx
|= SetLCDtoNonExpanding
;
3030 if (pVBInfo
->IF_DEF_ExpLink
== 1) {
3031 if (modeflag
& HalfDCLK
) {
3032 if (!(tempbx
& SetLCDtoNonExpanding
)) {
3033 tempbx
|= XGI_EnableLVDSDDA
;
3035 if (pVBInfo
->LCDResInfo
== Panel_1024x768
) {
3036 if (resinfo
== 4) {/* 512x384 */
3037 tempbx
|= XGI_EnableLVDSDDA
;
3044 if (pVBInfo
->VBInfo
& SetInSlaveMode
) {
3045 if (pVBInfo
->VBInfo
& SetNotSimuMode
)
3046 tempbx
|= XGI_LCDVESATiming
;
3048 tempbx
|= XGI_LCDVESATiming
;
3051 pVBInfo
->LCDInfo
= tempbx
;
3056 unsigned char XGI_SearchModeID(unsigned short ModeNo
,
3057 unsigned short *ModeIdIndex
, struct vb_device_info
*pVBInfo
)
3059 for (*ModeIdIndex
= 0;; (*ModeIdIndex
)++) {
3060 if (pVBInfo
->EModeIDTable
[*ModeIdIndex
].Ext_ModeID
== ModeNo
)
3062 if (pVBInfo
->EModeIDTable
[*ModeIdIndex
].Ext_ModeID
== 0xFF)
3069 static unsigned char XG21GPIODataTransfer(unsigned char ujDate
)
3071 unsigned char ujRet
= 0;
3072 unsigned char i
= 0;
3074 for (i
= 0; i
< 8; i
++) {
3076 ujRet
|= (ujDate
>> i
) & 1;
3082 /*----------------------------------------------------------------------------*/
3084 /* bl[5] : LVDS signal */
3085 /* bl[1] : LVDS backlight */
3086 /* bl[0] : LVDS VDD */
3087 /*----------------------------------------------------------------------------*/
3088 static unsigned char XGI_XG21GetPSCValue(struct vb_device_info
*pVBInfo
)
3090 unsigned char CR4A
, temp
;
3092 CR4A
= xgifb_reg_get(pVBInfo
->P3d4
, 0x4A);
3093 xgifb_reg_and(pVBInfo
->P3d4
, 0x4A, ~0x23); /* enable GPIO write */
3095 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x48);
3097 temp
= XG21GPIODataTransfer(temp
);
3099 xgifb_reg_set(pVBInfo
->P3d4
, 0x4A, CR4A
);
3103 /*----------------------------------------------------------------------------*/
3105 /* bl[5] : LVDS signal */
3106 /* bl[1] : LVDS backlight */
3107 /* bl[0] : LVDS VDD */
3108 /*----------------------------------------------------------------------------*/
3109 static unsigned char XGI_XG27GetPSCValue(struct vb_device_info
*pVBInfo
)
3111 unsigned char CR4A
, CRB4
, temp
;
3113 CR4A
= xgifb_reg_get(pVBInfo
->P3d4
, 0x4A);
3114 xgifb_reg_and(pVBInfo
->P3d4
, 0x4A, ~0x0C); /* enable GPIO write */
3116 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x48);
3120 xgifb_reg_set(pVBInfo
->P3d4
, 0x4A, CR4A
);
3121 CRB4
= xgifb_reg_get(pVBInfo
->P3d4
, 0xB4);
3122 temp
|= ((CRB4
& 0x04) << 3);
3126 /*----------------------------------------------------------------------------*/
3128 /* bl[5] : 1;LVDS signal on */
3129 /* bl[1] : 1;LVDS backlight on */
3130 /* bl[0] : 1:LVDS VDD on */
3131 /* bh: 100000b : clear bit 5, to set bit5 */
3132 /* 000010b : clear bit 1, to set bit1 */
3133 /* 000001b : clear bit 0, to set bit0 */
3134 /*----------------------------------------------------------------------------*/
3135 static void XGI_XG21BLSignalVDD(unsigned short tempbh
, unsigned short tempbl
,
3136 struct vb_device_info
*pVBInfo
)
3138 unsigned char CR4A
, temp
;
3140 CR4A
= xgifb_reg_get(pVBInfo
->P3d4
, 0x4A);
3143 xgifb_reg_and(pVBInfo
->P3d4
, 0x4A, ~tempbh
); /* enable GPIO write */
3145 if (tempbh
& 0x20) {
3146 temp
= (tempbl
>> 4) & 0x02;
3149 xgifb_reg_and_or(pVBInfo
->P3d4
, 0xB4, ~0x02, temp
);
3153 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x48);
3155 temp
= XG21GPIODataTransfer(temp
);
3158 xgifb_reg_set(pVBInfo
->P3d4
, 0x48, temp
);
3161 static void XGI_XG27BLSignalVDD(unsigned short tempbh
, unsigned short tempbl
,
3162 struct vb_device_info
*pVBInfo
)
3164 unsigned char CR4A
, temp
;
3165 unsigned short tempbh0
, tempbl0
;
3174 if (tempbh
& 0x20) {
3175 temp
= (tempbl
>> 4) & 0x02;
3178 xgifb_reg_and_or(pVBInfo
->P3d4
, 0xB4, ~0x02, temp
);
3181 xgifb_reg_and_or(pVBInfo
->P3d4
, 0xB4, ~tempbh0
, tempbl0
);
3183 CR4A
= xgifb_reg_get(pVBInfo
->P3d4
, 0x4A);
3187 tempbl
<<= 2; /* GPIOC,GPIOD */
3188 xgifb_reg_and(pVBInfo
->P3d4
, 0x4A, ~tempbh
); /* enable GPIO write */
3189 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x48, ~tempbh
, tempbl
);
3192 /* --------------------------------------------------------------------- */
3193 /* Function : XGI_XG21SetPanelDelay */
3197 /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
3198 /* : bl : 2 ; T2 : the duration signal on and Vdd on */
3199 /* : bl : 3 ; T3 : the duration between CPL off and signal off */
3200 /* : bl : 4 ; T4 : the duration signal off and Vdd off */
3201 /* --------------------------------------------------------------------- */
3202 static void XGI_XG21SetPanelDelay(struct xgifb_video_info
*xgifb_info
,
3203 unsigned short tempbl
,
3204 struct vb_device_info
*pVBInfo
)
3207 mdelay(xgifb_info
->lvds_data
.PSC_S1
);
3210 mdelay(xgifb_info
->lvds_data
.PSC_S2
);
3213 mdelay(xgifb_info
->lvds_data
.PSC_S3
);
3216 mdelay(xgifb_info
->lvds_data
.PSC_S4
);
3219 static void XGI_DisplayOn(struct xgifb_video_info
*xgifb_info
,
3220 struct xgi_hw_device_info
*pXGIHWDE
,
3221 struct vb_device_info
*pVBInfo
)
3224 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x01, 0xDF, 0x00);
3225 if (pXGIHWDE
->jChipType
== XG21
) {
3226 if (pVBInfo
->IF_DEF_LVDS
== 1) {
3227 if (!(XGI_XG21GetPSCValue(pVBInfo
) & 0x1)) {
3229 XGI_XG21BLSignalVDD(0x01, 0x01, pVBInfo
);
3230 XGI_XG21SetPanelDelay(xgifb_info
, 2, pVBInfo
);
3232 if (!(XGI_XG21GetPSCValue(pVBInfo
) & 0x20))
3233 /* LVDS signal on */
3234 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo
);
3235 XGI_XG21SetPanelDelay(xgifb_info
, 3, pVBInfo
);
3236 /* LVDS backlight on */
3237 XGI_XG21BLSignalVDD(0x02, 0x02, pVBInfo
);
3239 /* DVO/DVI signal on */
3240 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo
);
3245 if (pXGIHWDE
->jChipType
== XG27
) {
3246 if (pVBInfo
->IF_DEF_LVDS
== 1) {
3247 if (!(XGI_XG27GetPSCValue(pVBInfo
) & 0x1)) {
3249 XGI_XG27BLSignalVDD(0x01, 0x01, pVBInfo
);
3250 XGI_XG21SetPanelDelay(xgifb_info
, 2, pVBInfo
);
3252 if (!(XGI_XG27GetPSCValue(pVBInfo
) & 0x20))
3253 /* LVDS signal on */
3254 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo
);
3255 XGI_XG21SetPanelDelay(xgifb_info
, 3, pVBInfo
);
3256 /* LVDS backlight on */
3257 XGI_XG27BLSignalVDD(0x02, 0x02, pVBInfo
);
3259 /* DVO/DVI signal on */
3260 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo
);
3266 void XGI_DisplayOff(struct xgifb_video_info
*xgifb_info
,
3267 struct xgi_hw_device_info
*pXGIHWDE
,
3268 struct vb_device_info
*pVBInfo
)
3271 if (pXGIHWDE
->jChipType
== XG21
) {
3272 if (pVBInfo
->IF_DEF_LVDS
== 1) {
3273 /* LVDS backlight off */
3274 XGI_XG21BLSignalVDD(0x02, 0x00, pVBInfo
);
3275 XGI_XG21SetPanelDelay(xgifb_info
, 3, pVBInfo
);
3277 /* DVO/DVI signal off */
3278 XGI_XG21BLSignalVDD(0x20, 0x00, pVBInfo
);
3282 if (pXGIHWDE
->jChipType
== XG27
) {
3283 if ((XGI_XG27GetPSCValue(pVBInfo
) & 0x2)) {
3284 /* LVDS backlight off */
3285 XGI_XG27BLSignalVDD(0x02, 0x00, pVBInfo
);
3286 XGI_XG21SetPanelDelay(xgifb_info
, 3, pVBInfo
);
3289 if (pVBInfo
->IF_DEF_LVDS
== 0)
3290 /* DVO/DVI signal off */
3291 XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo
);
3294 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x01, 0xDF, 0x20);
3297 static void XGI_WaitDisply(struct vb_device_info
*pVBInfo
)
3299 while ((inb(pVBInfo
->P3da
) & 0x01))
3302 while (!(inb(pVBInfo
->P3da
) & 0x01))
3306 static void XGI_AutoThreshold(struct vb_device_info
*pVBInfo
)
3308 xgifb_reg_or(pVBInfo
->Part1Port
, 0x01, 0x40);
3311 static void XGI_SaveCRT2Info(unsigned short ModeNo
,
3312 struct vb_device_info
*pVBInfo
)
3314 unsigned short temp1
, temp2
;
3316 /* reserve CR34 for CRT1 Mode No */
3317 xgifb_reg_set(pVBInfo
->P3d4
, 0x34, ModeNo
);
3318 temp1
= (pVBInfo
->VBInfo
& SetInSlaveMode
) >> 8;
3319 temp2
= ~(SetInSlaveMode
>> 8);
3320 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x31, temp2
, temp1
);
3323 static void XGI_GetCRT2ResInfo(unsigned short ModeNo
,
3324 unsigned short ModeIdIndex
,
3325 struct vb_device_info
*pVBInfo
)
3327 unsigned short xres
, yres
, modeflag
, resindex
;
3329 resindex
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
3330 xres
= pVBInfo
->ModeResInfo
[resindex
].HTotal
; /* xres->ax */
3331 yres
= pVBInfo
->ModeResInfo
[resindex
].VTotal
; /* yres->bx */
3332 /* si+St_ModeFlag */
3333 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
3335 if (modeflag
& HalfDCLK
)
3338 if (modeflag
& DoubleScanMode
)
3341 if (pVBInfo
->VBInfo
& SetCRT2ToLCD
) {
3342 if (pVBInfo
->IF_DEF_LVDS
== 0) {
3343 if (pVBInfo
->LCDResInfo
== Panel_1600x1200
) {
3344 if (!(pVBInfo
->LCDInfo
& XGI_LCDVESATiming
)) {
3350 if (pVBInfo
->LCDResInfo
== Panel_1280x1024
) {
3353 else if (yres
== 350)
3356 if (pVBInfo
->LCDInfo
& XGI_LCDVESATiming
) {
3362 if (pVBInfo
->LCDResInfo
== Panel_1024x768
) {
3363 if (!(pVBInfo
->LCDInfo
& XGI_LCDVESATiming
)) {
3364 if (!(pVBInfo
->LCDInfo
3365 & LCDNonExpanding
)) {
3368 else if (yres
== 400)
3370 else if (yres
== 480)
3381 pVBInfo
->VGAHDE
= xres
;
3382 pVBInfo
->HDE
= xres
;
3383 pVBInfo
->VGAVDE
= yres
;
3384 pVBInfo
->VDE
= yres
;
3387 static unsigned char XGI_IsLCDDualLink(struct vb_device_info
*pVBInfo
)
3390 if ((pVBInfo
->VBInfo
& (SetCRT2ToLCD
| XGI_SetCRT2ToLCDA
)) &&
3391 (pVBInfo
->LCDInfo
& SetLCDDualLink
)) /* shampoo0129 */
3397 static void XGI_GetRAMDAC2DATA(unsigned short ModeNo
,
3398 unsigned short ModeIdIndex
,
3399 unsigned short RefreshRateTableIndex
,
3400 struct vb_device_info
*pVBInfo
)
3402 unsigned short tempax
, tempbx
, temp1
, temp2
, modeflag
= 0, tempcx
,
3405 pVBInfo
->RVBHCMAX
= 1;
3406 pVBInfo
->RVBHCFACT
= 1;
3407 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
3408 CRT1Index
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRT1CRTC
;
3409 CRT1Index
&= IndexMask
;
3410 temp1
= (unsigned short) pVBInfo
->XGINEWUB_CRT1Table
[CRT1Index
].CR
[0];
3411 temp2
= (unsigned short) pVBInfo
->XGINEWUB_CRT1Table
[CRT1Index
].CR
[5];
3412 tempax
= (temp1
& 0xFF) | ((temp2
& 0x03) << 8);
3413 tempbx
= (unsigned short) pVBInfo
->XGINEWUB_CRT1Table
[CRT1Index
].CR
[8];
3414 tempcx
= (unsigned short)
3415 pVBInfo
->XGINEWUB_CRT1Table
[CRT1Index
].CR
[14] << 8;
3417 tempcx
= tempcx
<< 2;
3419 temp1
= (unsigned short) pVBInfo
->XGINEWUB_CRT1Table
[CRT1Index
].CR
[9];
3428 if (modeflag
& Charx8Dot
)
3433 pVBInfo
->VGAHT
= tempax
;
3434 pVBInfo
->HT
= tempax
;
3436 pVBInfo
->VGAVT
= tempbx
;
3437 pVBInfo
->VT
= tempbx
;
3440 static void XGI_GetCRT2Data(unsigned short ModeNo
, unsigned short ModeIdIndex
,
3441 unsigned short RefreshRateTableIndex
,
3442 struct vb_device_info
*pVBInfo
)
3444 unsigned short tempax
= 0, tempbx
, modeflag
, resinfo
;
3446 struct SiS_LCDData
*LCDPtr
= NULL
;
3447 struct SiS_TVData
*TVPtr
= NULL
;
3449 /* si+Ext_ResInfo */
3450 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
3451 resinfo
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
3452 pVBInfo
->NewFlickerMode
= 0;
3453 pVBInfo
->RVBHRS
= 50;
3455 if (pVBInfo
->VBInfo
& SetCRT2ToRAMDAC
) {
3456 XGI_GetRAMDAC2DATA(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
3463 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| XGI_SetCRT2ToLCDA
)) {
3464 LCDPtr
= (struct SiS_LCDData
*) XGI_GetLcdPtr(tempbx
,
3465 ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
3468 pVBInfo
->RVBHCMAX
= LCDPtr
->RVBHCMAX
;
3469 pVBInfo
->RVBHCFACT
= LCDPtr
->RVBHCFACT
;
3470 pVBInfo
->VGAHT
= LCDPtr
->VGAHT
;
3471 pVBInfo
->VGAVT
= LCDPtr
->VGAVT
;
3472 pVBInfo
->HT
= LCDPtr
->LCDHT
;
3473 pVBInfo
->VT
= LCDPtr
->LCDVT
;
3475 if (pVBInfo
->LCDResInfo
== Panel_1024x768
) {
3479 if (!(pVBInfo
->LCDInfo
& XGI_LCDVESATiming
)) {
3480 if (pVBInfo
->VGAVDE
== 357)
3482 else if (pVBInfo
->VGAVDE
== 420)
3484 else if (pVBInfo
->VGAVDE
== 525)
3486 else if (pVBInfo
->VGAVDE
== 600)
3492 } else if (pVBInfo
->LCDResInfo
== Panel_1024x768x75
) {
3495 } else if (pVBInfo
->LCDResInfo
== Panel_1280x1024
) {
3497 if (pVBInfo
->VGAVDE
== 360)
3499 else if (pVBInfo
->VGAVDE
== 375)
3501 else if (pVBInfo
->VGAVDE
== 405)
3505 } else if (pVBInfo
->LCDResInfo
== Panel_1280x1024x75
) {
3508 } else if (pVBInfo
->LCDResInfo
== Panel_1280x960
) {
3510 if (pVBInfo
->VGAVDE
== 350)
3512 else if (pVBInfo
->VGAVDE
== 400)
3514 else if (pVBInfo
->VGAVDE
== 1024)
3518 } else if (pVBInfo
->LCDResInfo
== Panel_1400x1050
) {
3522 if (pVBInfo
->VGAVDE
== 1024) {
3526 } else if (pVBInfo
->LCDResInfo
== Panel_1600x1200
) {
3528 tempbx
= 1200; /* alan 10/14/2003 */
3529 if (!(pVBInfo
->LCDInfo
& XGI_LCDVESATiming
)) {
3530 if (pVBInfo
->VGAVDE
== 350)
3532 else if (pVBInfo
->VGAVDE
== 400)
3537 if (pVBInfo
->LCDInfo
& LCDNonExpanding
) {
3538 tempax
= pVBInfo
->VGAHDE
;
3539 tempbx
= pVBInfo
->VGAVDE
;
3542 pVBInfo
->HDE
= tempax
;
3543 pVBInfo
->VDE
= tempbx
;
3547 if (pVBInfo
->VBInfo
& (SetCRT2ToTV
)) {
3549 TVPtr
= (struct SiS_TVData
*) XGI_GetTVPtr(tempbx
,
3550 ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
3553 pVBInfo
->RVBHCMAX
= TVPtr
->RVBHCMAX
;
3554 pVBInfo
->RVBHCFACT
= TVPtr
->RVBHCFACT
;
3555 pVBInfo
->VGAHT
= TVPtr
->VGAHT
;
3556 pVBInfo
->VGAVT
= TVPtr
->VGAVT
;
3557 pVBInfo
->HDE
= TVPtr
->TVHDE
;
3558 pVBInfo
->VDE
= TVPtr
->TVVDE
;
3559 pVBInfo
->RVBHRS
= TVPtr
->RVBHRS
;
3560 pVBInfo
->NewFlickerMode
= TVPtr
->FlickerMode
;
3562 if (pVBInfo
->VBInfo
& SetCRT2ToHiVision
) {
3563 if (resinfo
== 0x08)
3564 pVBInfo
->NewFlickerMode
= 0x40;
3565 else if (resinfo
== 0x09)
3566 pVBInfo
->NewFlickerMode
= 0x40;
3567 else if (resinfo
== 0x12)
3568 pVBInfo
->NewFlickerMode
= 0x40;
3570 if (pVBInfo
->VGAVDE
== 350)
3571 pVBInfo
->TVInfo
|= TVSimuMode
;
3576 if (pVBInfo
->VBInfo
& SetInSlaveMode
) {
3577 if (pVBInfo
->TVInfo
& TVSimuMode
) {
3581 if (!(modeflag
& Charx8Dot
)) {
3582 tempax
= StHiTextTVHT
;
3583 tempbx
= StHiTextTVVT
;
3587 } else if (pVBInfo
->VBInfo
& SetCRT2ToYPbPr525750
) {
3588 if (pVBInfo
->TVInfo
& TVSetYPbPr750p
) {
3589 tempax
= YPbPrTV750pHT
; /* Ext750pTVHT */
3590 tempbx
= YPbPrTV750pVT
; /* Ext750pTVVT */
3593 if (pVBInfo
->TVInfo
& TVSetYPbPr525p
) {
3594 tempax
= YPbPrTV525pHT
; /* Ext525pTVHT */
3595 tempbx
= YPbPrTV525pVT
; /* Ext525pTVVT */
3596 } else if (pVBInfo
->TVInfo
& TVSetYPbPr525i
) {
3597 tempax
= YPbPrTV525iHT
; /* Ext525iTVHT */
3598 tempbx
= YPbPrTV525iVT
; /* Ext525iTVVT */
3599 if (pVBInfo
->TVInfo
& NTSC1024x768
)
3600 tempax
= NTSC1024x768HT
;
3605 if (!(pVBInfo
->TVInfo
& TVSetPAL
)) {
3608 if (pVBInfo
->TVInfo
& NTSC1024x768
)
3609 tempax
= NTSC1024x768HT
;
3613 pVBInfo
->HT
= tempax
;
3614 pVBInfo
->VT
= tempbx
;
3619 static void XGI_SetCRT2VCLK(unsigned short ModeNo
, unsigned short ModeIdIndex
,
3620 unsigned short RefreshRateTableIndex
,
3621 struct vb_device_info
*pVBInfo
)
3623 unsigned char di_0
, di_1
, tempal
;
3625 tempal
= XGI_GetVCLKPtr(RefreshRateTableIndex
, ModeNo
, ModeIdIndex
,
3627 XGI_GetVCLKLen(tempal
, &di_0
, &di_1
, pVBInfo
);
3628 XGI_GetLCDVCLKPtr(&di_0
, &di_1
, pVBInfo
);
3630 if (pVBInfo
->VBType
& VB_SIS301
) { /* shampoo 0129 */
3632 xgifb_reg_set(pVBInfo
->Part4Port
, 0x0A, 0x10);
3633 xgifb_reg_set(pVBInfo
->Part4Port
, 0x0B, di_1
);
3634 xgifb_reg_set(pVBInfo
->Part4Port
, 0x0A, di_0
);
3635 } else { /* 301b/302b/301lv/302lv */
3636 xgifb_reg_set(pVBInfo
->Part4Port
, 0x0A, di_0
);
3637 xgifb_reg_set(pVBInfo
->Part4Port
, 0x0B, di_1
);
3640 xgifb_reg_set(pVBInfo
->Part4Port
, 0x00, 0x12);
3642 if (pVBInfo
->VBInfo
& SetCRT2ToRAMDAC
)
3643 xgifb_reg_or(pVBInfo
->Part4Port
, 0x12, 0x28);
3645 xgifb_reg_or(pVBInfo
->Part4Port
, 0x12, 0x08);
3648 static unsigned short XGI_GetColorDepth(unsigned short ModeNo
,
3649 unsigned short ModeIdIndex
, struct vb_device_info
*pVBInfo
)
3651 unsigned short ColorDepth
[6] = { 1, 2, 4, 4, 6, 8 };
3653 unsigned short modeflag
;
3655 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
3656 index
= (modeflag
& ModeTypeMask
) - ModeEGA
;
3661 return ColorDepth
[index
];
3664 static unsigned short XGI_GetOffset(unsigned short ModeNo
,
3665 unsigned short ModeIdIndex
,
3666 unsigned short RefreshRateTableIndex
,
3667 struct xgi_hw_device_info
*HwDeviceExtension
,
3668 struct vb_device_info
*pVBInfo
)
3670 unsigned short temp
, colordepth
, modeinfo
, index
, infoflag
,
3671 ColorDepth
[] = { 0x01, 0x02, 0x04 };
3673 modeinfo
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeInfo
;
3674 infoflag
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_InfoFlag
;
3676 index
= (modeinfo
>> 8) & 0xFF;
3678 temp
= pVBInfo
->ScreenOffset
[index
];
3680 if (infoflag
& InterlaceMode
)
3683 colordepth
= XGI_GetColorDepth(ModeNo
, ModeIdIndex
, pVBInfo
);
3685 if ((ModeNo
>= 0x7C) && (ModeNo
<= 0x7E)) {
3686 temp
= ModeNo
- 0x7C;
3687 colordepth
= ColorDepth
[temp
];
3689 if (infoflag
& InterlaceMode
)
3691 return temp
* colordepth
;
3693 return temp
* colordepth
;
3697 static void XGI_SetCRT2Offset(unsigned short ModeNo
,
3698 unsigned short ModeIdIndex
,
3699 unsigned short RefreshRateTableIndex
,
3700 struct xgi_hw_device_info
*HwDeviceExtension
,
3701 struct vb_device_info
*pVBInfo
)
3703 unsigned short offset
;
3706 if (pVBInfo
->VBInfo
& SetInSlaveMode
)
3709 offset
= XGI_GetOffset(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
3710 HwDeviceExtension
, pVBInfo
);
3711 temp
= (unsigned char) (offset
& 0xFF);
3712 xgifb_reg_set(pVBInfo
->Part1Port
, 0x07, temp
);
3713 temp
= (unsigned char) ((offset
& 0xFF00) >> 8);
3714 xgifb_reg_set(pVBInfo
->Part1Port
, 0x09, temp
);
3715 temp
= (unsigned char) (((offset
>> 3) & 0xFF) + 1);
3716 xgifb_reg_set(pVBInfo
->Part1Port
, 0x03, temp
);
3719 static void XGI_SetCRT2FIFO(struct vb_device_info
*pVBInfo
)
3721 /* threshold high ,disable auto threshold */
3722 xgifb_reg_set(pVBInfo
->Part1Port
, 0x01, 0x3B);
3723 /* threshold low default 04h */
3724 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x02, ~(0x3F), 0x04);
3727 static void XGI_PreSetGroup1(unsigned short ModeNo
, unsigned short ModeIdIndex
,
3728 struct xgi_hw_device_info
*HwDeviceExtension
,
3729 unsigned short RefreshRateTableIndex
,
3730 struct vb_device_info
*pVBInfo
)
3732 unsigned short tempcx
= 0, CRT1Index
= 0, resinfo
= 0;
3734 CRT1Index
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRT1CRTC
;
3735 CRT1Index
&= IndexMask
;
3736 resinfo
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
3738 XGI_SetCRT2Offset(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
3739 HwDeviceExtension
, pVBInfo
);
3740 XGI_SetCRT2FIFO(pVBInfo
);
3742 for (tempcx
= 4; tempcx
< 7; tempcx
++)
3743 xgifb_reg_set(pVBInfo
->Part1Port
, tempcx
, 0x0);
3745 xgifb_reg_set(pVBInfo
->Part1Port
, 0x50, 0x00);
3746 xgifb_reg_set(pVBInfo
->Part1Port
, 0x02, 0x44); /* temp 0206 */
3749 static void XGI_SetGroup1(unsigned short ModeNo
, unsigned short ModeIdIndex
,
3750 struct xgi_hw_device_info
*HwDeviceExtension
,
3751 unsigned short RefreshRateTableIndex
,
3752 struct vb_device_info
*pVBInfo
)
3754 unsigned short temp
= 0, tempax
= 0, tempbx
= 0, tempcx
= 0,
3755 pushbx
= 0, CRT1Index
= 0, modeflag
, resinfo
= 0;
3757 CRT1Index
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRT1CRTC
;
3758 CRT1Index
&= IndexMask
;
3759 resinfo
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
3760 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
3762 /* bainy change table name */
3763 if (modeflag
& HalfDCLK
) {
3764 /* BTVGA2HT 0x08,0x09 */
3765 temp
= (pVBInfo
->VGAHT
/ 2 - 1) & 0x0FF;
3766 xgifb_reg_set(pVBInfo
->Part1Port
, 0x08, temp
);
3767 temp
= (((pVBInfo
->VGAHT
/ 2 - 1) & 0xFF00) >> 8) << 4;
3768 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x09, ~0x0F0, temp
);
3769 /* BTVGA2HDEE 0x0A,0x0C */
3770 temp
= (pVBInfo
->VGAHDE
/ 2 + 16) & 0x0FF;
3771 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0A, temp
);
3772 tempcx
= ((pVBInfo
->VGAHT
- pVBInfo
->VGAHDE
) / 2) >> 2;
3773 pushbx
= pVBInfo
->VGAHDE
/ 2 + 16;
3774 tempcx
= tempcx
>> 1;
3775 tempbx
= pushbx
+ tempcx
; /* bx BTVGA@HRS 0x0B,0x0C */
3778 if (pVBInfo
->VBInfo
& SetCRT2ToRAMDAC
) {
3779 tempbx
= pVBInfo
->XGINEWUB_CRT1Table
[CRT1Index
].CR
[4];
3780 tempbx
|= ((pVBInfo
->
3781 XGINEWUB_CRT1Table
[CRT1Index
].CR
[14] &
3783 tempbx
= (tempbx
- 3) << 3; /* (VGAHRS-3)*8 */
3784 tempcx
= pVBInfo
->XGINEWUB_CRT1Table
[CRT1Index
].CR
[5];
3786 temp
= pVBInfo
->XGINEWUB_CRT1Table
[CRT1Index
].CR
[15];
3787 temp
= (temp
& 0x04) << (5 - 2); /* VGAHRE D[5] */
3788 tempcx
= ((tempcx
| temp
) - 3) << 3; /* (VGAHRE-3)*8 */
3794 if (tempcx
> (pVBInfo
->VGAHT
/ 2))
3795 tempcx
= pVBInfo
->VGAHT
/ 2;
3797 temp
= tempbx
& 0x00FF;
3799 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0B, temp
);
3801 temp
= (pVBInfo
->VGAHT
- 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */
3802 xgifb_reg_set(pVBInfo
->Part1Port
, 0x08, temp
);
3803 temp
= (((pVBInfo
->VGAHT
- 1) & 0xFF00) >> 8) << 4;
3804 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x09, ~0x0F0, temp
);
3805 /* BTVGA2HDEE 0x0A,0x0C */
3806 temp
= (pVBInfo
->VGAHDE
+ 16) & 0x0FF;
3807 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0A, temp
);
3808 tempcx
= (pVBInfo
->VGAHT
- pVBInfo
->VGAHDE
) >> 2; /* cx */
3809 pushbx
= pVBInfo
->VGAHDE
+ 16;
3810 tempcx
= tempcx
>> 1;
3811 tempbx
= pushbx
+ tempcx
; /* bx BTVGA@HRS 0x0B,0x0C */
3814 if (pVBInfo
->VBInfo
& SetCRT2ToRAMDAC
) {
3815 tempbx
= pVBInfo
->XGINEWUB_CRT1Table
[CRT1Index
].CR
[3];
3816 tempbx
|= ((pVBInfo
->
3817 XGINEWUB_CRT1Table
[CRT1Index
].CR
[5] &
3819 tempbx
= (tempbx
- 3) << 3; /* (VGAHRS-3)*8 */
3820 tempcx
= pVBInfo
->XGINEWUB_CRT1Table
[CRT1Index
].CR
[4];
3822 temp
= pVBInfo
->XGINEWUB_CRT1Table
[CRT1Index
].CR
[6];
3823 temp
= (temp
& 0x04) << (5 - 2); /* VGAHRE D[5] */
3824 tempcx
= ((tempcx
| temp
) - 3) << 3; /* (VGAHRE-3)*8 */
3829 if (tempcx
> pVBInfo
->VGAHT
)
3830 tempcx
= pVBInfo
->VGAHT
;
3832 temp
= tempbx
& 0x00FF;
3833 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0B, temp
);
3836 tempax
= (tempax
& 0x00FF) | (tempbx
& 0xFF00);
3838 tempbx
= (tempbx
& 0x00FF) | ((tempbx
& 0xFF00) << 4);
3839 tempax
|= (tempbx
& 0xFF00);
3840 temp
= (tempax
& 0xFF00) >> 8;
3841 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0C, temp
);
3842 temp
= tempcx
& 0x00FF;
3843 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0D, temp
);
3844 tempcx
= (pVBInfo
->VGAVT
- 1);
3845 temp
= tempcx
& 0x00FF;
3847 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0E, temp
);
3848 tempbx
= pVBInfo
->VGAVDE
- 1;
3849 temp
= tempbx
& 0x00FF;
3850 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0F, temp
);
3851 temp
= ((tempbx
& 0xFF00) << 3) >> 8;
3852 temp
|= ((tempcx
& 0xFF00) >> 8);
3853 xgifb_reg_set(pVBInfo
->Part1Port
, 0x12, temp
);
3855 tempax
= pVBInfo
->VGAVDE
;
3856 tempbx
= pVBInfo
->VGAVDE
;
3857 tempcx
= pVBInfo
->VGAVT
;
3858 /* BTVGA2VRS 0x10,0x11 */
3859 tempbx
= (pVBInfo
->VGAVT
+ pVBInfo
->VGAVDE
) >> 1;
3860 /* BTVGA2VRE 0x11 */
3861 tempcx
= ((pVBInfo
->VGAVT
- pVBInfo
->VGAVDE
) >> 4) + tempbx
+ 1;
3863 if (pVBInfo
->VBInfo
& SetCRT2ToRAMDAC
) {
3864 tempbx
= pVBInfo
->XGINEWUB_CRT1Table
[CRT1Index
].CR
[10];
3865 temp
= pVBInfo
->XGINEWUB_CRT1Table
[CRT1Index
].CR
[9];
3873 temp
= pVBInfo
->XGINEWUB_CRT1Table
[CRT1Index
].CR
[14];
3878 temp
= pVBInfo
->XGINEWUB_CRT1Table
[CRT1Index
].CR
[11];
3879 tempcx
= (tempcx
& 0xFF00) | (temp
& 0x00FF);
3882 temp
= tempbx
& 0x00FF;
3883 xgifb_reg_set(pVBInfo
->Part1Port
, 0x10, temp
);
3884 temp
= ((tempbx
& 0xFF00) >> 8) << 4;
3885 temp
= ((tempcx
& 0x000F) | (temp
));
3886 xgifb_reg_set(pVBInfo
->Part1Port
, 0x11, temp
);
3889 if (modeflag
& DoubleScanMode
)
3892 if (modeflag
& HalfDCLK
)
3895 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x2C, ~0x0C0, tempax
);
3898 static unsigned short XGI_GetVGAHT2(struct vb_device_info
*pVBInfo
)
3900 unsigned long tempax
, tempbx
;
3902 tempbx
= ((pVBInfo
->VGAVT
- pVBInfo
->VGAVDE
) * pVBInfo
->RVBHCMAX
)
3904 tempax
= (pVBInfo
->VT
- pVBInfo
->VDE
) * pVBInfo
->RVBHCFACT
;
3905 tempax
= (tempax
* pVBInfo
->HT
) / tempbx
;
3907 return (unsigned short) tempax
;
3910 static void XGI_SetLockRegs(unsigned short ModeNo
, unsigned short ModeIdIndex
,
3911 struct xgi_hw_device_info
*HwDeviceExtension
,
3912 unsigned short RefreshRateTableIndex
,
3913 struct vb_device_info
*pVBInfo
)
3915 unsigned short push1
, push2
, tempax
, tempbx
= 0, tempcx
, temp
, resinfo
,
3916 modeflag
, CRT1Index
;
3918 /* si+Ext_ResInfo */
3919 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
3920 resinfo
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
3921 CRT1Index
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRT1CRTC
;
3922 CRT1Index
&= IndexMask
;
3924 if (!(pVBInfo
->VBInfo
& SetInSlaveMode
))
3927 temp
= 0xFF; /* set MAX HT */
3928 xgifb_reg_set(pVBInfo
->Part1Port
, 0x03, temp
);
3931 if (pVBInfo
->VBType
& (VB_SIS301LV
| VB_SIS302LV
| VB_XGI301C
))
3932 modeflag
|= Charx8Dot
;
3934 tempax
= pVBInfo
->VGAHDE
; /* 0x04 Horizontal Display End */
3936 if (modeflag
& HalfDCLK
)
3937 tempax
= tempax
>> 1;
3939 tempax
= (tempax
/ tempcx
) - 1;
3940 tempbx
|= ((tempax
& 0x00FF) << 8);
3941 temp
= tempax
& 0x00FF;
3942 xgifb_reg_set(pVBInfo
->Part1Port
, 0x04, temp
);
3944 temp
= (tempbx
& 0xFF00) >> 8;
3946 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
3947 if (!(pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
3948 | VB_SIS302LV
| VB_XGI301C
)))
3951 if (pVBInfo
->VBInfo
& SetCRT2ToHiVision
) {
3952 if (pVBInfo
->VBType
& VB_SIS301LV
) {
3953 if (pVBInfo
->VBExtInfo
== VB_YPbPr1080i
) {
3957 } else if (resinfo
== 7) {
3963 /* 0x05 Horizontal Display Start */
3964 xgifb_reg_set(pVBInfo
->Part1Port
, 0x05, temp
);
3965 /* 0x06 Horizontal Blank end */
3966 xgifb_reg_set(pVBInfo
->Part1Port
, 0x06, 0x03);
3968 if (!(pVBInfo
->VBInfo
& DisableCRT2Display
)) { /* 030226 bainy */
3969 if (pVBInfo
->VBInfo
& SetCRT2ToTV
)
3970 tempax
= pVBInfo
->VGAHT
;
3972 tempax
= XGI_GetVGAHT2(pVBInfo
);
3975 if (tempax
>= pVBInfo
->VGAHT
)
3976 tempax
= pVBInfo
->VGAHT
;
3978 if (modeflag
& HalfDCLK
)
3979 tempax
= tempax
>> 1;
3981 tempax
= (tempax
/ tempcx
) - 5;
3982 tempcx
= tempax
; /* 20030401 0x07 horizontal Retrace Start */
3983 if (pVBInfo
->VBInfo
& SetCRT2ToHiVision
) {
3984 temp
= (tempbx
& 0x00FF) - 1;
3985 if (!(modeflag
& HalfDCLK
)) {
3987 if (pVBInfo
->TVInfo
& TVSimuMode
) {
3993 tempbx
= (tempbx
& 0xFF00) >> 8;
3994 tempcx
= (tempcx
+ tempbx
) >> 1;
3995 temp
= (tempcx
& 0x00FF) + 2;
3997 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
3999 if (!(modeflag
& HalfDCLK
)) {
4000 if ((modeflag
& Charx8Dot
)) {
4002 if (pVBInfo
->VGAHDE
>= 800)
4006 } else if (!(modeflag
& HalfDCLK
)) {
4008 if (pVBInfo
->LCDResInfo
!= Panel_1280x960
&&
4009 pVBInfo
->VGAHDE
>= 800) {
4011 if (pVBInfo
->VGAHDE
>= 1280 &&
4012 pVBInfo
->LCDResInfo
!= Panel_1280x960
&&
4013 (pVBInfo
->LCDInfo
& LCDNonExpanding
))
4019 /* 0x07 Horizontal Retrace Start */
4020 xgifb_reg_set(pVBInfo
->Part1Port
, 0x07, temp
);
4021 /* 0x08 Horizontal Retrace End */
4022 xgifb_reg_set(pVBInfo
->Part1Port
, 0x08, 0);
4024 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
4025 if (pVBInfo
->TVInfo
& TVSimuMode
) {
4026 if (ModeNo
== 0x50) {
4027 if (pVBInfo
->TVInfo
& SetNTSCTV
) {
4028 xgifb_reg_set(pVBInfo
->Part1Port
,
4030 xgifb_reg_set(pVBInfo
->Part1Port
,
4033 xgifb_reg_set(pVBInfo
->Part1Port
,
4035 xgifb_reg_set(pVBInfo
->Part1Port
,
4042 xgifb_reg_set(pVBInfo
->Part1Port
, 0x18, 0x03); /* 0x18 SR0B */
4043 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x19, 0xF0, 0x00);
4044 xgifb_reg_set(pVBInfo
->Part1Port
, 0x09, 0xFF); /* 0x09 Set Max VT */
4046 tempbx
= pVBInfo
->VGAVT
;
4049 tempbx
= pVBInfo
->VGAVDE
; /* 0x0E Virtical Display End */
4064 if (pVBInfo
->VBInfo
& SetCRT2ToLCD
) {
4065 if (pVBInfo
->LCDResInfo
== Panel_1024x768
) {
4066 if (!(pVBInfo
->LCDInfo
& XGI_LCDVESATiming
)) {
4075 temp
= tempbx
& 0x00FF;
4077 temp
= tempbx
& 0x00FF;
4078 /* 0x10 vertical Blank Start */
4079 xgifb_reg_set(pVBInfo
->Part1Port
, 0x10, temp
);
4082 temp
= tempbx
& 0x00FF;
4083 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0E, temp
);
4085 if (tempbx
& 0x0100)
4090 if (modeflag
& DoubleScanMode
)
4093 if (tempbx
& 0x0200)
4096 temp
= (tempax
& 0xFF00) >> 8;
4097 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0B, temp
);
4099 if (tempbx
& 0x0400)
4102 /* 0x11 Vertival Blank End */
4103 xgifb_reg_set(pVBInfo
->Part1Port
, 0x11, 0x00);
4106 tempax
-= tempbx
; /* 0x0C Vertical Retrace Start */
4107 tempax
= tempax
>> 2;
4108 push1
= tempax
; /* push ax */
4110 if (resinfo
!= 0x09) {
4111 tempax
= tempax
<< 1;
4115 if (pVBInfo
->VBInfo
& SetCRT2ToHiVision
) {
4116 if (pVBInfo
->VBType
& VB_SIS301LV
) {
4117 if (pVBInfo
->TVInfo
& TVSetHiVision
) {
4120 if (pVBInfo
->TVInfo
& TVSimuMode
) {
4121 if (pVBInfo
->TVInfo
& TVSetPAL
) {
4122 if (pVBInfo
->VBType
&
4124 if (!(pVBInfo
->TVInfo
&
4139 if (pVBInfo
->TVInfo
& TVSimuMode
) {
4140 if (pVBInfo
->TVInfo
& TVSetPAL
) {
4141 if (pVBInfo
->VBType
& VB_SIS301LV
) {
4142 if (!(pVBInfo
->TVInfo
&
4154 tempax
= tempax
>> 2;
4157 push1
= tempax
; /* push ax */
4159 if ((pVBInfo
->TVInfo
& TVSetPAL
)) {
4160 if (tempbx
<= 513) {
4166 temp
= tempbx
& 0x00FF;
4167 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0C, temp
);
4169 temp
= tempbx
& 0x00FF;
4170 xgifb_reg_set(pVBInfo
->Part1Port
, 0x10, temp
);
4172 if (tempbx
& 0x0100)
4175 if (tempbx
& 0x0200)
4176 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x0B, 0x0FF, 0x20);
4180 if (tempbx
& 0x0100)
4183 if (tempbx
& 0x0200)
4186 if (tempbx
& 0x0400)
4189 tempbx
= push1
; /* pop ax */
4190 temp
= tempbx
& 0x00FF;
4192 /* 0x0D vertical Retrace End */
4193 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0D, temp
);
4195 if (tempbx
& 0x0010)
4198 temp
= tempcx
& 0x00FF;
4199 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0A, temp
); /* 0x0A CR07 */
4200 temp
= (tempcx
& 0x0FF00) >> 8;
4201 xgifb_reg_set(pVBInfo
->Part1Port
, 0x17, temp
); /* 0x17 SR0A */
4203 temp
= (tempax
& 0xFF00) >> 8;
4205 temp
= (temp
>> 1) & 0x09;
4207 if (pVBInfo
->VBType
& (VB_SIS301LV
| VB_SIS302LV
| VB_XGI301C
))
4210 xgifb_reg_set(pVBInfo
->Part1Port
, 0x16, temp
); /* 0x16 SR01 */
4211 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0F, 0); /* 0x0F CR14 */
4212 xgifb_reg_set(pVBInfo
->Part1Port
, 0x12, 0); /* 0x12 CR17 */
4214 if (pVBInfo
->LCDInfo
& LCDRGB18Bit
)
4219 xgifb_reg_set(pVBInfo
->Part1Port
, 0x1A, temp
); /* 0x1A SR0E */
4224 static void XGI_SetGroup2(unsigned short ModeNo
, unsigned short ModeIdIndex
,
4225 unsigned short RefreshRateTableIndex
,
4226 struct xgi_hw_device_info
*HwDeviceExtension
,
4227 struct vb_device_info
*pVBInfo
)
4229 unsigned short i
, j
, tempax
, tempbx
, tempcx
, temp
, push1
, push2
,
4230 modeflag
, resinfo
, crt2crtc
;
4231 unsigned char *TimingPoint
;
4233 unsigned long longtemp
, tempeax
, tempebx
, temp2
, tempecx
;
4235 /* si+Ext_ResInfo */
4236 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
4237 resinfo
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
4238 crt2crtc
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRT2CRTC
;
4242 if (!(pVBInfo
->VBInfo
& SetCRT2ToAVIDEO
))
4245 if (!(pVBInfo
->VBInfo
& SetCRT2ToSVIDEO
))
4248 if (pVBInfo
->VBInfo
& SetCRT2ToSCART
)
4251 if (!(pVBInfo
->TVInfo
& TVSetPAL
))
4254 if (pVBInfo
->VBInfo
& SetCRT2ToHiVision
)
4257 if (pVBInfo
->TVInfo
& (TVSetYPbPr525p
| TVSetYPbPr750p
))
4260 tempax
= (tempax
& 0xff00) >> 8;
4262 xgifb_reg_set(pVBInfo
->Part2Port
, 0x0, tempax
);
4263 TimingPoint
= pVBInfo
->NTSCTiming
;
4265 if (pVBInfo
->TVInfo
& TVSetPAL
)
4266 TimingPoint
= pVBInfo
->PALTiming
;
4268 if (pVBInfo
->VBInfo
& SetCRT2ToHiVision
) {
4269 TimingPoint
= pVBInfo
->HiTVExtTiming
;
4271 if (pVBInfo
->VBInfo
& SetInSlaveMode
)
4272 TimingPoint
= pVBInfo
->HiTVSt2Timing
;
4274 if (pVBInfo
->SetFlag
& TVSimuMode
)
4275 TimingPoint
= pVBInfo
->HiTVSt1Timing
;
4277 if (!(modeflag
& Charx8Dot
))
4278 TimingPoint
= pVBInfo
->HiTVTextTiming
;
4281 if (pVBInfo
->VBInfo
& SetCRT2ToYPbPr525750
) {
4282 if (pVBInfo
->TVInfo
& TVSetYPbPr525i
)
4283 TimingPoint
= pVBInfo
->YPbPr525iTiming
;
4285 if (pVBInfo
->TVInfo
& TVSetYPbPr525p
)
4286 TimingPoint
= pVBInfo
->YPbPr525pTiming
;
4288 if (pVBInfo
->TVInfo
& TVSetYPbPr750p
)
4289 TimingPoint
= pVBInfo
->YPbPr750pTiming
;
4292 for (i
= 0x01, j
= 0; i
<= 0x2D; i
++, j
++)
4293 xgifb_reg_set(pVBInfo
->Part2Port
, i
, TimingPoint
[j
]);
4295 for (i
= 0x39; i
<= 0x45; i
++, j
++)
4297 xgifb_reg_set(pVBInfo
->Part2Port
, i
, TimingPoint
[j
]);
4299 if (pVBInfo
->VBInfo
& SetCRT2ToTV
)
4300 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x3A, 0x1F, 0x00);
4302 temp
= pVBInfo
->NewFlickerMode
;
4304 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x0A, 0xFF, temp
);
4306 if (pVBInfo
->VBInfo
& SetCRT2ToHiVision
)
4309 if (pVBInfo
->TVInfo
& TVSetPAL
)
4314 if (pVBInfo
->VDE
<= tempax
) {
4315 tempax
-= pVBInfo
->VDE
;
4316 tempax
= tempax
>> 2;
4317 tempax
= (tempax
& 0x00FF) | ((tempax
& 0x00FF) << 8);
4319 temp
= (tempax
& 0xFF00) >> 8;
4320 temp
+= (unsigned short) TimingPoint
[0];
4322 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
4323 | VB_SIS302LV
| VB_XGI301C
)) {
4324 if (pVBInfo
->VBInfo
& (SetCRT2ToAVIDEO
4325 | SetCRT2ToSVIDEO
| SetCRT2ToSCART
4326 | SetCRT2ToYPbPr525750
)) {
4327 tempcx
= pVBInfo
->VGAHDE
;
4328 if (tempcx
>= 1024) {
4329 temp
= 0x17; /* NTSC */
4330 if (pVBInfo
->TVInfo
& TVSetPAL
)
4331 temp
= 0x19; /* PAL */
4336 xgifb_reg_set(pVBInfo
->Part2Port
, 0x01, temp
);
4338 temp
= (tempax
& 0xFF00) >> 8;
4339 temp
+= TimingPoint
[1];
4341 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
4342 | VB_SIS302LV
| VB_XGI301C
)) {
4343 if ((pVBInfo
->VBInfo
& (SetCRT2ToAVIDEO
4344 | SetCRT2ToSVIDEO
| SetCRT2ToSCART
4345 | SetCRT2ToYPbPr525750
))) {
4346 tempcx
= pVBInfo
->VGAHDE
;
4347 if (tempcx
>= 1024) {
4348 temp
= 0x1D; /* NTSC */
4349 if (pVBInfo
->TVInfo
& TVSetPAL
)
4350 temp
= 0x52; /* PAL */
4354 xgifb_reg_set(pVBInfo
->Part2Port
, 0x02, temp
);
4358 tempcx
= pVBInfo
->HT
;
4360 if (XGI_IsLCDDualLink(pVBInfo
))
4361 tempcx
= tempcx
>> 1;
4364 temp
= tempcx
& 0x00FF;
4365 xgifb_reg_set(pVBInfo
->Part2Port
, 0x1B, temp
);
4367 temp
= (tempcx
& 0xFF00) >> 8;
4368 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x1D, ~0x0F, temp
);
4370 tempcx
= pVBInfo
->HT
>> 1;
4371 push1
= tempcx
; /* push cx */
4374 if (pVBInfo
->VBInfo
& SetCRT2ToHiVision
)
4377 temp
= tempcx
& 0x00FF;
4379 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x22, 0x0F, temp
);
4381 tempbx
= TimingPoint
[j
] | ((TimingPoint
[j
+ 1]) << 8);
4384 temp
= tempbx
& 0x00FF;
4385 xgifb_reg_set(pVBInfo
->Part2Port
, 0x24, temp
);
4386 temp
= (tempbx
& 0xFF00) >> 8;
4388 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x25, 0x0F, temp
);
4391 tempbx
= tempbx
+ 8;
4392 if (pVBInfo
->VBInfo
& SetCRT2ToHiVision
) {
4393 tempbx
= tempbx
- 4;
4397 temp
= (tempbx
& 0x00FF) << 4;
4398 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x29, 0x0F, temp
);
4401 tempcx
+= (TimingPoint
[j
] | ((TimingPoint
[j
+ 1]) << 8));
4402 temp
= tempcx
& 0x00FF;
4403 xgifb_reg_set(pVBInfo
->Part2Port
, 0x27, temp
);
4404 temp
= ((tempcx
& 0xFF00) >> 8) << 4;
4405 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x28, 0x0F, temp
);
4408 if (pVBInfo
->VBInfo
& SetCRT2ToHiVision
)
4411 temp
= tempcx
& 0xFF;
4413 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x2A, 0x0F, temp
);
4415 tempcx
= push1
; /* pop cx */
4417 temp
= TimingPoint
[j
] | ((TimingPoint
[j
+ 1]) << 8);
4419 temp
= tempcx
& 0x00FF;
4421 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x2D, 0x0F, temp
);
4425 if (!(pVBInfo
->VBInfo
& SetCRT2ToTV
)) {
4426 tempax
= XGI_GetVGAHT2(pVBInfo
);
4427 tempcx
= tempax
- 1;
4429 temp
= tempcx
& 0x00FF;
4430 xgifb_reg_set(pVBInfo
->Part2Port
, 0x2E, temp
);
4432 tempbx
= pVBInfo
->VDE
;
4434 if (pVBInfo
->VGAVDE
== 360)
4436 if (pVBInfo
->VGAVDE
== 375)
4438 if (pVBInfo
->VGAVDE
== 405)
4441 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
4442 if (pVBInfo
->VBType
&
4443 (VB_SIS301LV
| VB_SIS302LV
| VB_XGI301C
)) {
4444 if (!(pVBInfo
->TVInfo
&
4445 (TVSetYPbPr525p
| TVSetYPbPr750p
)))
4446 tempbx
= tempbx
>> 1;
4448 tempbx
= tempbx
>> 1;
4452 temp
= tempbx
& 0x00FF;
4454 if (pVBInfo
->VBInfo
& SetCRT2ToHiVision
) {
4455 if (pVBInfo
->VBType
& VB_SIS301LV
) {
4456 if (pVBInfo
->TVInfo
& TVSetHiVision
) {
4457 if (pVBInfo
->VBInfo
& SetInSlaveMode
) {
4463 if (pVBInfo
->VBInfo
& SetInSlaveMode
) {
4470 xgifb_reg_set(pVBInfo
->Part2Port
, 0x2F, temp
);
4472 temp
= (tempcx
& 0xFF00) >> 8;
4473 temp
|= ((tempbx
& 0xFF00) >> 8) << 6;
4475 if (!(pVBInfo
->VBInfo
& SetCRT2ToHiVision
)) {
4476 if (pVBInfo
->VBType
& VB_SIS301LV
) {
4477 if (pVBInfo
->TVInfo
& TVSetHiVision
) {
4480 if (!(pVBInfo
->VBInfo
& SetCRT2ToSVIDEO
))
4485 if (!(pVBInfo
->VBInfo
& SetCRT2ToSVIDEO
))
4490 xgifb_reg_set(pVBInfo
->Part2Port
, 0x30, temp
);
4492 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
4493 | VB_SIS302LV
| VB_XGI301C
)) { /* TV gatingno */
4494 tempbx
= pVBInfo
->VDE
;
4495 tempcx
= tempbx
- 2;
4497 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
4498 if (!(pVBInfo
->TVInfo
& (TVSetYPbPr525p
4500 tempbx
= tempbx
>> 1;
4503 if (pVBInfo
->VBType
& (VB_SIS302LV
| VB_XGI301C
)) {
4505 if (tempcx
& 0x0400)
4508 if (tempbx
& 0x0400)
4511 xgifb_reg_set(pVBInfo
->Part4Port
, 0x10, temp
);
4514 temp
= (((tempbx
- 3) & 0x0300) >> 8) << 5;
4515 xgifb_reg_set(pVBInfo
->Part2Port
, 0x46, temp
);
4516 temp
= (tempbx
- 3) & 0x00FF;
4517 xgifb_reg_set(pVBInfo
->Part2Port
, 0x47, temp
);
4520 tempbx
= tempbx
& 0x00FF;
4522 if (!(modeflag
& HalfDCLK
)) {
4523 tempcx
= pVBInfo
->VGAHDE
;
4524 if (tempcx
>= pVBInfo
->HDE
) {
4532 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) { /*301b*/
4533 if (pVBInfo
->VGAHDE
>= 1024) {
4535 if (pVBInfo
->VGAHDE
>= 1280) {
4537 tempbx
= tempbx
& 0xDFFF;
4542 if (!(tempbx
& 0x2000)) {
4543 if (modeflag
& HalfDCLK
)
4544 tempcx
= (tempcx
& 0xFF00) | ((tempcx
& 0x00FF) << 1);
4547 tempeax
= pVBInfo
->VGAHDE
;
4548 tempebx
= (tempcx
& 0xFF00) >> 8;
4549 longtemp
= tempeax
* tempebx
;
4550 tempecx
= tempcx
& 0x00FF;
4551 longtemp
= longtemp
/ tempecx
;
4556 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
4557 | VB_SIS302LV
| VB_XGI301C
)) {
4558 tempecx
= tempecx
* 8;
4561 longtemp
= longtemp
* tempecx
;
4562 tempecx
= pVBInfo
->HDE
;
4563 temp2
= longtemp
% tempecx
;
4564 tempeax
= longtemp
/ tempecx
;
4568 tempax
= (unsigned short) tempeax
;
4571 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
4572 | VB_SIS302LV
| VB_XGI301C
)) {
4573 tempcx
= ((tempax
& 0xFF00) >> 5) >> 8;
4578 tempbx
= (unsigned short) (((tempeax
& 0x0000FF00) & 0x1F00)
4579 | (tempbx
& 0x00FF));
4580 tempax
= (unsigned short) (((tempeax
& 0x000000FF) << 8)
4581 | (tempax
& 0x00FF));
4582 temp
= (tempax
& 0xFF00) >> 8;
4584 temp
= (tempax
& 0x00FF) >> 8;
4587 xgifb_reg_set(pVBInfo
->Part2Port
, 0x44, temp
);
4588 temp
= (tempbx
& 0xFF00) >> 8;
4589 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x45, ~0x03F, temp
);
4590 temp
= tempcx
& 0x00FF;
4592 if (tempbx
& 0x2000)
4595 if (!(pVBInfo
->VBInfo
& SetCRT2ToLCD
))
4598 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x46, ~0x1F, temp
);
4599 if (pVBInfo
->TVInfo
& TVSetPAL
) {
4607 temp
= tempbx
& 0x00FF;
4608 xgifb_reg_set(pVBInfo
->Part2Port
, 0x4b, temp
);
4609 temp
= tempcx
& 0x00FF;
4610 xgifb_reg_set(pVBInfo
->Part2Port
, 0x4c, temp
);
4612 temp
= ((tempcx
& 0xFF00) >> 8) & 0x03;
4614 temp
|= ((tempbx
& 0xFF00) >> 8) & 0x03;
4616 if (pVBInfo
->VBInfo
& SetCRT2ToYPbPr525750
) {
4619 if (pVBInfo
->TVInfo
& TVSetYPbPr525p
)
4622 if (pVBInfo
->TVInfo
& TVSetYPbPr750p
)
4626 xgifb_reg_set(pVBInfo
->Part2Port
, 0x4d, temp
);
4627 temp
= xgifb_reg_get(pVBInfo
->Part2Port
, 0x43); /* 301b change */
4628 xgifb_reg_set(pVBInfo
->Part2Port
, 0x43, (unsigned short) (temp
- 3));
4630 if (!(pVBInfo
->TVInfo
& (TVSetYPbPr525p
| TVSetYPbPr750p
))) {
4631 if (pVBInfo
->TVInfo
& NTSC1024x768
) {
4632 TimingPoint
= XGI_NTSC1024AdjTime
;
4633 for (i
= 0x1c, j
= 0; i
<= 0x30; i
++, j
++) {
4634 xgifb_reg_set(pVBInfo
->Part2Port
, i
,
4637 xgifb_reg_set(pVBInfo
->Part2Port
, 0x43, 0x72);
4641 /* [ycchen] 01/14/03 Modify for 301C PALM Support */
4642 if (pVBInfo
->VBType
& VB_XGI301C
) {
4643 if (pVBInfo
->TVInfo
& TVSetPALM
)
4644 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x4E, ~0x08,
4645 0x08); /* PALM Mode */
4648 if (pVBInfo
->TVInfo
& TVSetPALM
) {
4649 tempax
= (unsigned char) xgifb_reg_get(pVBInfo
->Part2Port
,
4652 xgifb_reg_and(pVBInfo
->Part2Port
, 0x01, tempax
);
4654 xgifb_reg_and(pVBInfo
->Part2Port
, 0x00, 0xEF);
4657 if (pVBInfo
->VBInfo
& SetCRT2ToHiVision
) {
4658 if (!(pVBInfo
->VBInfo
& SetInSlaveMode
))
4659 xgifb_reg_set(pVBInfo
->Part2Port
, 0x0B, 0x00);
4662 if (pVBInfo
->VBInfo
& SetCRT2ToTV
)
4666 static void XGI_SetLCDRegs(unsigned short ModeNo
, unsigned short ModeIdIndex
,
4667 struct xgi_hw_device_info
*HwDeviceExtension
,
4668 unsigned short RefreshRateTableIndex
,
4669 struct vb_device_info
*pVBInfo
)
4671 unsigned short push1
, push2
, pushbx
, tempax
, tempbx
, tempcx
, temp
,
4672 tempah
, tempbh
, tempch
, resinfo
, modeflag
, CRT1Index
;
4674 struct XGI_LCDDesStruct
*LCDBDesPtr
= NULL
;
4676 /* si+Ext_ResInfo */
4677 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
4678 resinfo
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
4679 CRT1Index
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRT1CRTC
;
4680 CRT1Index
&= IndexMask
;
4682 if (!(pVBInfo
->VBInfo
& SetCRT2ToLCD
))
4685 tempbx
= pVBInfo
->HDE
; /* RHACTE=HDE-1 */
4687 if (XGI_IsLCDDualLink(pVBInfo
))
4688 tempbx
= tempbx
>> 1;
4691 temp
= tempbx
& 0x00FF;
4692 xgifb_reg_set(pVBInfo
->Part2Port
, 0x2C, temp
);
4693 temp
= (tempbx
& 0xFF00) >> 8;
4695 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x2B, 0x0F, temp
);
4698 xgifb_reg_set(pVBInfo
->Part2Port
, 0x0B, temp
);
4699 tempbx
= pVBInfo
->VDE
; /* RTVACTEO=(VDE-1)&0xFF */
4702 temp
= tempbx
& 0x00FF;
4703 xgifb_reg_set(pVBInfo
->Part2Port
, 0x03, temp
);
4704 temp
= ((tempbx
& 0xFF00) >> 8) & 0x07;
4705 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x0C, ~0x07, temp
);
4707 tempcx
= pVBInfo
->VT
- 1;
4709 temp
= tempcx
& 0x00FF; /* RVTVT=VT-1 */
4710 xgifb_reg_set(pVBInfo
->Part2Port
, 0x19, temp
);
4711 temp
= (tempcx
& 0xFF00) >> 8;
4713 xgifb_reg_set(pVBInfo
->Part2Port
, 0x1A, temp
);
4714 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x09, 0xF0, 0x00);
4715 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x0A, 0xF0, 0x00);
4716 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x17, 0xFB, 0x00);
4717 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x18, 0xDF, 0x00);
4719 /* Customized LCDB Des no add */
4721 LCDBDesPtr
= (struct XGI_LCDDesStruct
*) XGI_GetLcdPtr(tempbx
, ModeNo
,
4722 ModeIdIndex
, RefreshRateTableIndex
, pVBInfo
);
4723 tempah
= pVBInfo
->LCDResInfo
;
4724 tempah
&= PanelResInfo
;
4726 if ((tempah
== Panel_1024x768
) || (tempah
== Panel_1024x768x75
)) {
4729 } else if ((tempah
== Panel_1280x1024
) ||
4730 (tempah
== Panel_1280x1024x75
)) {
4733 } else if (tempah
== Panel_1400x1050
) {
4741 if (pVBInfo
->LCDInfo
& EnableScalingLCD
) {
4742 tempbx
= pVBInfo
->HDE
;
4743 tempcx
= pVBInfo
->VDE
;
4747 tempax
= pVBInfo
->VT
;
4748 pVBInfo
->LCDHDES
= LCDBDesPtr
->LCDHDES
;
4749 pVBInfo
->LCDHRS
= LCDBDesPtr
->LCDHRS
;
4750 pVBInfo
->LCDVDES
= LCDBDesPtr
->LCDVDES
;
4751 pVBInfo
->LCDVRS
= LCDBDesPtr
->LCDVRS
;
4752 tempbx
= pVBInfo
->LCDVDES
;
4755 if (tempcx
>= tempax
)
4756 tempcx
-= tempax
; /* lcdvdes */
4758 temp
= tempbx
& 0x00FF; /* RVEQ1EQ=lcdvdes */
4759 xgifb_reg_set(pVBInfo
->Part2Port
, 0x05, temp
);
4760 temp
= tempcx
& 0x00FF;
4761 xgifb_reg_set(pVBInfo
->Part2Port
, 0x06, temp
);
4762 tempch
= ((tempcx
& 0xFF00) >> 8) & 0x07;
4763 tempbh
= ((tempbx
& 0xFF00) >> 8) & 0x07;
4765 tempah
= tempah
<< 3;
4767 xgifb_reg_set(pVBInfo
->Part2Port
, 0x02, tempah
);
4770 XGI_GetLCDSync(&tempax
, &tempbx
, pVBInfo
);
4772 tempax
= pVBInfo
->VT
;
4773 tempbx
= pVBInfo
->LCDVRS
;
4776 if (tempcx
>= tempax
)
4779 temp
= tempbx
& 0x00FF; /* RTVACTEE=lcdvrs */
4780 xgifb_reg_set(pVBInfo
->Part2Port
, 0x04, temp
);
4781 temp
= (tempbx
& 0xFF00) >> 8;
4783 temp
|= (tempcx
& 0x000F);
4784 xgifb_reg_set(pVBInfo
->Part2Port
, 0x01, temp
);
4786 tempax
= pVBInfo
->HT
;
4787 tempbx
= pVBInfo
->LCDHDES
;
4790 if (XGI_IsLCDDualLink(pVBInfo
)) {
4791 tempax
= tempax
>> 1;
4792 tempbx
= tempbx
>> 1;
4793 tempcx
= tempcx
>> 1;
4796 if (pVBInfo
->VBType
& VB_SIS302LV
)
4799 if (pVBInfo
->VBType
& VB_XGI301C
) /* tap4 */
4804 if (tempcx
>= tempax
)
4807 temp
= tempbx
& 0x00FF;
4808 xgifb_reg_set(pVBInfo
->Part2Port
, 0x1F, temp
); /* RHBLKE=lcdhdes */
4809 temp
= ((tempbx
& 0xFF00) >> 8) << 4;
4810 xgifb_reg_set(pVBInfo
->Part2Port
, 0x20, temp
);
4811 temp
= tempcx
& 0x00FF;
4812 xgifb_reg_set(pVBInfo
->Part2Port
, 0x23, temp
); /* RHEQPLE=lcdhdee */
4813 temp
= (tempcx
& 0xFF00) >> 8;
4814 xgifb_reg_set(pVBInfo
->Part2Port
, 0x25, temp
);
4816 XGI_GetLCDSync(&tempax
, &tempbx
, pVBInfo
);
4818 tempax
= pVBInfo
->HT
;
4819 tempbx
= pVBInfo
->LCDHRS
;
4820 if (XGI_IsLCDDualLink(pVBInfo
)) {
4821 tempax
= tempax
>> 1;
4822 tempbx
= tempbx
>> 1;
4823 tempcx
= tempcx
>> 1;
4826 if (pVBInfo
->VBType
& VB_SIS302LV
)
4831 if (tempcx
>= tempax
)
4834 temp
= tempbx
& 0x00FF; /* RHBURSTS=lcdhrs */
4835 xgifb_reg_set(pVBInfo
->Part2Port
, 0x1C, temp
);
4837 temp
= (tempbx
& 0xFF00) >> 8;
4839 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x1D, ~0x0F0, temp
);
4840 temp
= tempcx
& 0x00FF; /* RHSYEXP2S=lcdhre */
4841 xgifb_reg_set(pVBInfo
->Part2Port
, 0x21, temp
);
4843 if (!(pVBInfo
->LCDInfo
& XGI_LCDVESATiming
)) {
4844 if (pVBInfo
->VGAVDE
== 525) {
4845 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
4846 | VB_SIS301LV
| VB_SIS302LV
4852 xgifb_reg_set(pVBInfo
->Part2Port
, 0x2f, temp
);
4853 xgifb_reg_set(pVBInfo
->Part2Port
, 0x30, 0xB3);
4856 if (pVBInfo
->VGAVDE
== 420) {
4857 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
4858 | VB_SIS301LV
| VB_SIS302LV
4863 xgifb_reg_set(pVBInfo
->Part2Port
, 0x2f, temp
);
4868 /* --------------------------------------------------------------------- */
4869 /* Function : XGI_GetTap4Ptr */
4871 /* Output : di -> Tap4 Reg. Setting Pointer */
4873 /* --------------------------------------------------------------------- */
4874 static struct XGI301C_Tap4TimingStruct
*XGI_GetTap4Ptr(unsigned short tempcx
,
4875 struct vb_device_info
*pVBInfo
)
4877 unsigned short tempax
, tempbx
, i
;
4879 struct XGI301C_Tap4TimingStruct
*Tap4TimingPtr
;
4882 tempax
= pVBInfo
->VGAHDE
;
4883 tempbx
= pVBInfo
->HDE
;
4885 tempax
= pVBInfo
->VGAVDE
;
4886 tempbx
= pVBInfo
->VDE
;
4889 if (tempax
<= tempbx
)
4890 return &xgifb_tap4_timing
[0];
4892 Tap4TimingPtr
= xgifb_ntsc_525_tap4_timing
; /* NTSC */
4894 if (pVBInfo
->TVInfo
& TVSetPAL
)
4895 Tap4TimingPtr
= PALTap4Timing
;
4897 if (pVBInfo
->VBInfo
& SetCRT2ToYPbPr525750
) {
4898 if ((pVBInfo
->TVInfo
& TVSetYPbPr525i
) ||
4899 (pVBInfo
->TVInfo
& TVSetYPbPr525p
))
4900 Tap4TimingPtr
= xgifb_ntsc_525_tap4_timing
;
4901 if (pVBInfo
->TVInfo
& TVSetYPbPr750p
)
4902 Tap4TimingPtr
= YPbPr750pTap4Timing
;
4905 if (pVBInfo
->VBInfo
& SetCRT2ToHiVision
)
4906 Tap4TimingPtr
= xgifb_tap4_timing
;
4909 while (Tap4TimingPtr
[i
].DE
!= 0xFFFF) {
4910 if (Tap4TimingPtr
[i
].DE
== tempax
)
4914 return &Tap4TimingPtr
[i
];
4917 static void XGI_SetTap4Regs(struct vb_device_info
*pVBInfo
)
4919 unsigned short i
, j
;
4921 struct XGI301C_Tap4TimingStruct
*Tap4TimingPtr
;
4923 if (!(pVBInfo
->VBType
& VB_XGI301C
))
4926 Tap4TimingPtr
= XGI_GetTap4Ptr(0, pVBInfo
); /* Set Horizontal Scaling */
4927 for (i
= 0x80, j
= 0; i
<= 0xBF; i
++, j
++)
4928 xgifb_reg_set(pVBInfo
->Part2Port
, i
, Tap4TimingPtr
->Reg
[j
]);
4930 if ((pVBInfo
->VBInfo
& SetCRT2ToTV
) &&
4931 (!(pVBInfo
->VBInfo
& SetCRT2ToHiVision
))) {
4932 /* Set Vertical Scaling */
4933 Tap4TimingPtr
= XGI_GetTap4Ptr(1, pVBInfo
);
4934 for (i
= 0xC0, j
= 0; i
< 0xFF; i
++, j
++)
4935 xgifb_reg_set(pVBInfo
->Part2Port
,
4937 Tap4TimingPtr
->Reg
[j
]);
4940 if ((pVBInfo
->VBInfo
& SetCRT2ToTV
) &&
4941 (!(pVBInfo
->VBInfo
& SetCRT2ToHiVision
)))
4942 /* Enable V.Scaling */
4943 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x4E, ~0x14, 0x04);
4945 /* Enable H.Scaling */
4946 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x4E, ~0x14, 0x10);
4949 static void XGI_SetGroup3(unsigned short ModeNo
, unsigned short ModeIdIndex
,
4950 struct vb_device_info
*pVBInfo
)
4953 unsigned char *tempdi
;
4954 unsigned short modeflag
;
4956 /* si+Ext_ResInfo */
4957 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
4959 xgifb_reg_set(pVBInfo
->Part3Port
, 0x00, 0x00);
4960 if (pVBInfo
->TVInfo
& TVSetPAL
) {
4961 xgifb_reg_set(pVBInfo
->Part3Port
, 0x13, 0xFA);
4962 xgifb_reg_set(pVBInfo
->Part3Port
, 0x14, 0xC8);
4964 xgifb_reg_set(pVBInfo
->Part3Port
, 0x13, 0xF5);
4965 xgifb_reg_set(pVBInfo
->Part3Port
, 0x14, 0xB7);
4968 if (!(pVBInfo
->VBInfo
& SetCRT2ToTV
))
4971 if (pVBInfo
->TVInfo
& TVSetPALM
) {
4972 xgifb_reg_set(pVBInfo
->Part3Port
, 0x13, 0xFA);
4973 xgifb_reg_set(pVBInfo
->Part3Port
, 0x14, 0xC8);
4974 xgifb_reg_set(pVBInfo
->Part3Port
, 0x3D, 0xA8);
4977 if ((pVBInfo
->VBInfo
& SetCRT2ToHiVision
) || (pVBInfo
->VBInfo
4978 & SetCRT2ToYPbPr525750
)) {
4979 if (pVBInfo
->TVInfo
& TVSetYPbPr525i
)
4982 tempdi
= pVBInfo
->HiTVGroup3Data
;
4983 if (pVBInfo
->SetFlag
& TVSimuMode
) {
4984 tempdi
= pVBInfo
->HiTVGroup3Simu
;
4985 if (!(modeflag
& Charx8Dot
))
4986 tempdi
= pVBInfo
->HiTVGroup3Text
;
4989 if (pVBInfo
->TVInfo
& TVSetYPbPr525p
)
4990 tempdi
= pVBInfo
->Ren525pGroup3
;
4992 if (pVBInfo
->TVInfo
& TVSetYPbPr750p
)
4993 tempdi
= pVBInfo
->Ren750pGroup3
;
4995 for (i
= 0; i
<= 0x3E; i
++)
4996 xgifb_reg_set(pVBInfo
->Part3Port
, i
, tempdi
[i
]);
4998 if (pVBInfo
->VBType
& VB_XGI301C
) { /* Marcovision */
4999 if (pVBInfo
->TVInfo
& TVSetYPbPr525p
)
5000 xgifb_reg_set(pVBInfo
->Part3Port
, 0x28, 0x3f);
5004 } /* {end of XGI_SetGroup3} */
5006 static void XGI_SetGroup4(unsigned short ModeNo
, unsigned short ModeIdIndex
,
5007 unsigned short RefreshRateTableIndex
,
5008 struct xgi_hw_device_info
*HwDeviceExtension
,
5009 struct vb_device_info
*pVBInfo
)
5011 unsigned short tempax
, tempcx
, tempbx
, modeflag
, temp
, temp2
;
5013 unsigned long tempebx
, tempeax
, templong
;
5015 /* si+Ext_ResInfo */
5016 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
5017 temp
= pVBInfo
->RVBHCFACT
;
5018 xgifb_reg_set(pVBInfo
->Part4Port
, 0x13, temp
);
5020 tempbx
= pVBInfo
->RVBHCMAX
;
5021 temp
= tempbx
& 0x00FF;
5022 xgifb_reg_set(pVBInfo
->Part4Port
, 0x14, temp
);
5023 temp2
= ((tempbx
& 0xFF00) >> 8) << 7;
5024 tempcx
= pVBInfo
->VGAHT
- 1;
5025 temp
= tempcx
& 0x00FF;
5026 xgifb_reg_set(pVBInfo
->Part4Port
, 0x16, temp
);
5028 temp
= ((tempcx
& 0xFF00) >> 8) << 3;
5031 tempcx
= pVBInfo
->VGAVT
- 1;
5032 if (!(pVBInfo
->VBInfo
& SetCRT2ToTV
))
5035 temp
= tempcx
& 0x00FF;
5036 xgifb_reg_set(pVBInfo
->Part4Port
, 0x17, temp
);
5037 temp
= temp2
| ((tempcx
& 0xFF00) >> 8);
5038 xgifb_reg_set(pVBInfo
->Part4Port
, 0x15, temp
);
5039 xgifb_reg_or(pVBInfo
->Part4Port
, 0x0D, 0x08);
5040 tempcx
= pVBInfo
->VBInfo
;
5041 tempbx
= pVBInfo
->VGAHDE
;
5043 if (modeflag
& HalfDCLK
)
5044 tempbx
= tempbx
>> 1;
5046 if (XGI_IsLCDDualLink(pVBInfo
))
5047 tempbx
= tempbx
>> 1;
5049 if (tempcx
& SetCRT2ToHiVision
) {
5055 } else if (tempcx
& SetCRT2ToTV
) {
5061 if (pVBInfo
->VBInfo
& SetCRT2ToLCD
) {
5068 if (pVBInfo
->TVInfo
& (TVSetYPbPr525p
| TVSetYPbPr750p
)) {
5070 if (pVBInfo
->VGAHDE
== 1280)
5072 if (pVBInfo
->VGAHDE
== 1024)
5075 xgifb_reg_and_or(pVBInfo
->Part4Port
, 0x0E, ~0xEF, temp
);
5077 tempebx
= pVBInfo
->VDE
;
5079 if (tempcx
& SetCRT2ToHiVision
) {
5080 if (!(temp
& 0xE000))
5081 tempbx
= tempbx
>> 1;
5084 tempcx
= pVBInfo
->RVBHRS
;
5085 temp
= tempcx
& 0x00FF;
5086 xgifb_reg_set(pVBInfo
->Part4Port
, 0x18, temp
);
5088 tempeax
= pVBInfo
->VGAVDE
;
5091 if (tempeax
<= tempebx
) {
5092 tempcx
= (tempcx
& (~0x4000));
5093 tempeax
= pVBInfo
->VGAVDE
;
5098 templong
= (tempeax
* 256 * 1024) % tempebx
;
5099 tempeax
= (tempeax
* 256 * 1024) / tempebx
;
5105 temp
= (unsigned short) (tempebx
& 0x000000FF);
5106 xgifb_reg_set(pVBInfo
->Part4Port
, 0x1B, temp
);
5108 temp
= (unsigned short) ((tempebx
& 0x0000FF00) >> 8);
5109 xgifb_reg_set(pVBInfo
->Part4Port
, 0x1A, temp
);
5110 tempbx
= (unsigned short) (tempebx
>> 16);
5111 temp
= tempbx
& 0x00FF;
5113 temp
|= ((tempcx
& 0xFF00) >> 8);
5114 xgifb_reg_set(pVBInfo
->Part4Port
, 0x19, temp
);
5117 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
5118 | VB_SIS302LV
| VB_XGI301C
)) {
5120 xgifb_reg_set(pVBInfo
->Part4Port
, 0x1C, temp
);
5121 tempax
= pVBInfo
->VGAHDE
;
5122 if (modeflag
& HalfDCLK
)
5123 tempax
= tempax
>> 1;
5125 if (XGI_IsLCDDualLink(pVBInfo
))
5126 tempax
= tempax
>> 1;
5128 if (pVBInfo
->VBInfo
& SetCRT2ToLCD
) {
5132 if (pVBInfo
->VGAHDE
> 800) {
5133 if (pVBInfo
->VGAHDE
== 1024)
5134 tempax
= (tempax
* 25 / 32) - 1;
5136 tempax
= (tempax
* 20 / 32) - 1;
5141 temp
= (tempax
& 0xFF00) >> 8;
5142 temp
= ((temp
& 0x0003) << 4);
5143 xgifb_reg_set(pVBInfo
->Part4Port
, 0x1E, temp
);
5144 temp
= (tempax
& 0x00FF);
5145 xgifb_reg_set(pVBInfo
->Part4Port
, 0x1D, temp
);
5147 if (pVBInfo
->VBInfo
& (SetCRT2ToTV
| SetCRT2ToHiVision
)) {
5148 if (pVBInfo
->VGAHDE
> 800)
5149 xgifb_reg_or(pVBInfo
->Part4Port
, 0x1E, 0x08);
5154 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
5155 if (!(pVBInfo
->TVInfo
& (NTSC1024x768
5156 | TVSetYPbPr525p
| TVSetYPbPr750p
5157 | TVSetHiVision
))) {
5159 if ((pVBInfo
->VBInfo
& SetInSlaveMode
)
5160 && (!(pVBInfo
->TVInfo
5166 xgifb_reg_and_or(pVBInfo
->Part4Port
, 0x1F, 0x00C0, temp
);
5167 tempbx
= pVBInfo
->HT
;
5168 if (XGI_IsLCDDualLink(pVBInfo
))
5169 tempbx
= tempbx
>> 1;
5170 tempbx
= (tempbx
>> 1) - 2;
5171 temp
= ((tempbx
& 0x0700) >> 8) << 3;
5172 xgifb_reg_and_or(pVBInfo
->Part4Port
, 0x21, 0x00C0, temp
);
5173 temp
= tempbx
& 0x00FF;
5174 xgifb_reg_set(pVBInfo
->Part4Port
, 0x22, temp
);
5178 if (pVBInfo
->ISXPDOS
== 0)
5179 XGI_SetCRT2VCLK(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
5183 static void XGINew_EnableCRT2(struct vb_device_info
*pVBInfo
)
5185 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x1E, 0xFF, 0x20);
5188 static void XGI_SetGroup5(unsigned short ModeNo
, unsigned short ModeIdIndex
,
5189 struct vb_device_info
*pVBInfo
)
5191 unsigned short Pindex
, Pdata
;
5193 Pindex
= pVBInfo
->Part5Port
;
5194 Pdata
= pVBInfo
->Part5Port
+ 1;
5195 if (pVBInfo
->ModeType
== ModeVGA
) {
5196 if (!(pVBInfo
->VBInfo
& (SetInSlaveMode
| LoadDACFlag
5197 | DisableCRT2Display
))) {
5198 XGINew_EnableCRT2(pVBInfo
);
5204 static void XGI_EnableGatingCRT(struct xgi_hw_device_info
*HwDeviceExtension
,
5205 struct vb_device_info
*pVBInfo
)
5207 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x63, 0xBF, 0x40);
5210 static void XGI_DisableGatingCRT(struct xgi_hw_device_info
*HwDeviceExtension
,
5211 struct vb_device_info
*pVBInfo
)
5214 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x63, 0xBF, 0x00);
5217 static unsigned char XGI_XG21CheckLVDSMode(struct xgifb_video_info
*xgifb_info
,
5218 unsigned short ModeNo
, unsigned short ModeIdIndex
,
5219 struct vb_device_info
*pVBInfo
)
5221 unsigned short xres
, yres
, colordepth
, modeflag
, resindex
;
5223 resindex
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
5224 xres
= pVBInfo
->ModeResInfo
[resindex
].HTotal
; /* xres->ax */
5225 yres
= pVBInfo
->ModeResInfo
[resindex
].VTotal
; /* yres->bx */
5226 /* si+St_ModeFlag */
5227 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
5229 if (!(modeflag
& Charx8Dot
)) {
5234 if ((ModeNo
> 0x13) && (modeflag
& HalfDCLK
))
5237 if ((ModeNo
> 0x13) && (modeflag
& DoubleScanMode
))
5240 if (xres
> xgifb_info
->lvds_data
.LVDSHDE
)
5243 if (yres
> xgifb_info
->lvds_data
.LVDSVDE
)
5246 if (xres
!= xgifb_info
->lvds_data
.LVDSHDE
||
5247 yres
!= xgifb_info
->lvds_data
.LVDSVDE
) {
5248 colordepth
= XGI_GetColorDepth(ModeNo
, ModeIdIndex
, pVBInfo
);
5255 static void xgifb_set_lvds(struct xgifb_video_info
*xgifb_info
,
5257 unsigned short ModeNo
,
5258 unsigned short ModeIdIndex
,
5259 struct vb_device_info
*pVBInfo
)
5261 unsigned char temp
, Miscdata
;
5262 unsigned short xres
, yres
, modeflag
, resindex
;
5263 unsigned short LVDSHT
, LVDSHBS
, LVDSHRS
, LVDSHRE
, LVDSHBE
;
5264 unsigned short LVDSVT
, LVDSVBS
, LVDSVRS
, LVDSVRE
, LVDSVBE
;
5265 unsigned short value
;
5267 temp
= (unsigned char) ((xgifb_info
->lvds_data
.LVDS_Capability
&
5268 (LCDPolarity
<< 8)) >> 8);
5269 temp
&= LCDPolarity
;
5270 Miscdata
= (unsigned char) inb(pVBInfo
->P3cc
);
5272 outb((Miscdata
& 0x3F) | temp
, pVBInfo
->P3c2
);
5274 temp
= xgifb_info
->lvds_data
.LVDS_Capability
& LCDPolarity
;
5275 /* SR35[7] FP VSync polarity */
5276 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x35, ~0x80, temp
& 0x80);
5277 /* SR30[5] FP HSync polarity */
5278 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x30, ~0x20, (temp
& 0x40) >> 1);
5280 if (chip_id
== XG27
)
5281 XGI_SetXG27FPBits(pVBInfo
);
5283 XGI_SetXG21FPBits(pVBInfo
);
5285 resindex
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
5286 xres
= pVBInfo
->ModeResInfo
[resindex
].HTotal
; /* xres->ax */
5287 yres
= pVBInfo
->ModeResInfo
[resindex
].VTotal
; /* yres->bx */
5288 /* si+St_ModeFlag */
5289 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
5291 if (!(modeflag
& Charx8Dot
))
5292 xres
= xres
* 8 / 9;
5294 LVDSHT
= xgifb_info
->lvds_data
.LVDSHT
;
5296 LVDSHBS
= xres
+ (xgifb_info
->lvds_data
.LVDSHDE
- xres
) / 2;
5298 if (LVDSHBS
> LVDSHT
)
5301 LVDSHRS
= LVDSHBS
+ xgifb_info
->lvds_data
.LVDSHFP
;
5302 if (LVDSHRS
> LVDSHT
)
5305 LVDSHRE
= LVDSHRS
+ xgifb_info
->lvds_data
.LVDSHSYNC
;
5306 if (LVDSHRE
> LVDSHT
)
5309 LVDSHBE
= LVDSHBS
+ LVDSHT
- xgifb_info
->lvds_data
.LVDSHDE
;
5311 LVDSVT
= xgifb_info
->lvds_data
.LVDSVT
;
5313 LVDSVBS
= yres
+ (xgifb_info
->lvds_data
.LVDSVDE
- yres
) / 2;
5314 if (modeflag
& DoubleScanMode
)
5315 LVDSVBS
+= yres
/ 2;
5317 if (LVDSVBS
> LVDSVT
)
5320 LVDSVRS
= LVDSVBS
+ xgifb_info
->lvds_data
.LVDSVFP
;
5321 if (LVDSVRS
> LVDSVT
)
5324 LVDSVRE
= LVDSVRS
+ xgifb_info
->lvds_data
.LVDSVSYNC
;
5325 if (LVDSVRE
> LVDSVT
)
5328 LVDSVBE
= LVDSVBS
+ LVDSVT
- xgifb_info
->lvds_data
.LVDSVDE
;
5330 temp
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x11);
5331 xgifb_reg_set(pVBInfo
->P3d4
, 0x11, temp
& 0x7f); /* Unlock CRTC */
5333 if (!(modeflag
& Charx8Dot
))
5334 xgifb_reg_or(pVBInfo
->P3c4
, 0x1, 0x1);
5336 /* HT SR0B[1:0] CR00 */
5337 value
= (LVDSHT
>> 3) - 5;
5338 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0B, ~0x03, (value
& 0x300) >> 8);
5339 xgifb_reg_set(pVBInfo
->P3d4
, 0x0, (value
& 0xFF));
5341 /* HBS SR0B[5:4] CR02 */
5342 value
= (LVDSHBS
>> 3) - 1;
5343 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0B, ~0x30, (value
& 0x300) >> 4);
5344 xgifb_reg_set(pVBInfo
->P3d4
, 0x2, (value
& 0xFF));
5346 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
5347 value
= (LVDSHBE
>> 3) - 1;
5348 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0C, ~0x03, (value
& 0xC0) >> 6);
5349 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x05, ~0x80, (value
& 0x20) << 2);
5350 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x03, ~0x1F, value
& 0x1F);
5352 /* HRS SR0B[7:6] CR04 */
5353 value
= (LVDSHRS
>> 3) + 2;
5354 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0B, ~0xC0, (value
& 0x300) >> 2);
5355 xgifb_reg_set(pVBInfo
->P3d4
, 0x4, (value
& 0xFF));
5357 /* Panel HRS SR2F[1:0] SR2E[7:0] */
5359 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x2F, ~0x03, (value
& 0x300) >> 8);
5360 xgifb_reg_set(pVBInfo
->P3c4
, 0x2E, (value
& 0xFF));
5362 /* HRE SR0C[2] CR05[4:0] */
5363 value
= (LVDSHRE
>> 3) + 2;
5364 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0C, ~0x04, (value
& 0x20) >> 3);
5365 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x05, ~0x1F, value
& 0x1F);
5367 /* Panel HRE SR2F[7:2] */
5369 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x2F, ~0xFC, value
<< 2);
5371 /* VT SR0A[0] CR07[5][0] CR06 */
5373 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0A, ~0x01, (value
& 0x400) >> 10);
5374 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x07, ~0x20, (value
& 0x200) >> 4);
5375 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x07, ~0x01, (value
& 0x100) >> 8);
5376 xgifb_reg_set(pVBInfo
->P3d4
, 0x06, (value
& 0xFF));
5378 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
5379 value
= LVDSVBS
- 1;
5380 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0A, ~0x04, (value
& 0x400) >> 8);
5381 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x09, ~0x20, (value
& 0x200) >> 4);
5382 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x07, ~0x08, (value
& 0x100) >> 5);
5383 xgifb_reg_set(pVBInfo
->P3d4
, 0x15, (value
& 0xFF));
5385 /* VBE SR0A[4] CR16 */
5386 value
= LVDSVBE
- 1;
5387 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0A, ~0x10, (value
& 0x100) >> 4);
5388 xgifb_reg_set(pVBInfo
->P3d4
, 0x16, (value
& 0xFF));
5390 /* VRS SR0A[3] CR7[7][2] CR10 */
5391 value
= LVDSVRS
- 1;
5392 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0A, ~0x08, (value
& 0x400) >> 7);
5393 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x07, ~0x80, (value
& 0x200) >> 2);
5394 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x07, ~0x04, (value
& 0x100) >> 6);
5395 xgifb_reg_set(pVBInfo
->P3d4
, 0x10, (value
& 0xFF));
5397 if (chip_id
== XG27
) {
5398 /* Panel VRS SR35[2:0] SR34[7:0] */
5399 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x35, ~0x07,
5400 (value
& 0x700) >> 8);
5401 xgifb_reg_set(pVBInfo
->P3c4
, 0x34, value
& 0xFF);
5403 /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */
5404 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x3F, ~0x03,
5405 (value
& 0x600) >> 9);
5406 xgifb_reg_set(pVBInfo
->P3c4
, 0x34, (value
>> 1) & 0xFF);
5407 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x33, ~0x01, value
& 0x01);
5410 /* VRE SR0A[5] CR11[3:0] */
5411 value
= LVDSVRE
- 1;
5412 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0A, ~0x20, (value
& 0x10) << 1);
5413 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x11, ~0x0F, value
& 0x0F);
5415 /* Panel VRE SR3F[7:2] */
5416 if (chip_id
== XG27
)
5417 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x3F, ~0xFC,
5418 (value
<< 2) & 0xFC);
5420 /* SR3F[7] has to be 0, h/w bug */
5421 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x3F, ~0xFC,
5422 (value
<< 2) & 0x7C);
5424 for (temp
= 0, value
= 0; temp
< 3; temp
++) {
5426 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x31, ~0x30, value
);
5427 xgifb_reg_set(pVBInfo
->P3c4
,
5428 0x2B, xgifb_info
->lvds_data
.VCLKData1
);
5429 xgifb_reg_set(pVBInfo
->P3c4
,
5430 0x2C, xgifb_info
->lvds_data
.VCLKData2
);
5434 if (!(modeflag
& Charx8Dot
)) {
5435 inb(pVBInfo
->P3da
); /* reset 3da */
5436 outb(0x13, pVBInfo
->P3c0
); /* set index */
5437 /* set data, panning = 0, shift left 1 dot*/
5438 outb(0x00, pVBInfo
->P3c0
);
5440 inb(pVBInfo
->P3da
); /* Enable Attribute */
5441 outb(0x20, pVBInfo
->P3c0
);
5443 inb(pVBInfo
->P3da
); /* reset 3da */
5448 /* --------------------------------------------------------------------- */
5449 /* Function : XGI_IsLCDON */
5451 /* Output : 0 : Skip PSC Control */
5452 /* 1: Disable PSC */
5454 /* --------------------------------------------------------------------- */
5455 static unsigned char XGI_IsLCDON(struct vb_device_info
*pVBInfo
)
5457 unsigned short tempax
;
5459 tempax
= pVBInfo
->VBInfo
;
5460 if (tempax
& SetCRT2ToDualEdge
)
5462 else if (tempax
& (DisableCRT2Display
| SwitchCRT2
| SetSimuScanMode
))
5468 /* --------------------------------------------------------------------- */
5469 /* Function : XGI_DisableChISLCD */
5471 /* Output : 0 -> Not LCD Mode */
5473 /* --------------------------------------------------------------------- */
5474 static unsigned char XGI_DisableChISLCD(struct vb_device_info
*pVBInfo
)
5476 unsigned short tempbx
, tempah
;
5478 tempbx
= pVBInfo
->SetFlag
& (DisableChA
| DisableChB
);
5479 tempah
= ~((unsigned short) xgifb_reg_get(pVBInfo
->Part1Port
, 0x2E));
5481 if (tempbx
& (EnableChA
| DisableChA
)) {
5482 if (!(tempah
& 0x08)) /* Chk LCDA Mode */
5486 if (!(tempbx
& (EnableChB
| DisableChB
)))
5489 if (tempah
& 0x01) /* Chk LCDB Mode */
5495 /* --------------------------------------------------------------------- */
5496 /* Function : XGI_EnableChISLCD */
5498 /* Output : 0 -> Not LCD mode */
5500 /* --------------------------------------------------------------------- */
5501 static unsigned char XGI_EnableChISLCD(struct vb_device_info
*pVBInfo
)
5503 unsigned short tempbx
, tempah
;
5505 tempbx
= pVBInfo
->SetFlag
& (EnableChA
| EnableChB
);
5506 tempah
= ~((unsigned short) xgifb_reg_get(pVBInfo
->Part1Port
, 0x2E));
5508 if (tempbx
& (EnableChA
| DisableChA
)) {
5509 if (!(tempah
& 0x08)) /* Chk LCDA Mode */
5513 if (!(tempbx
& (EnableChB
| DisableChB
)))
5516 if (tempah
& 0x01) /* Chk LCDB Mode */
5522 static void XGI_DisableBridge(struct xgifb_video_info
*xgifb_info
,
5523 struct xgi_hw_device_info
*HwDeviceExtension
,
5524 struct vb_device_info
*pVBInfo
)
5526 unsigned short tempah
= 0;
5528 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
5529 | VB_SIS302LV
| VB_XGI301C
)) {
5531 if (!(pVBInfo
->VBInfo
&
5532 (DisableCRT2Display
| SetSimuScanMode
))) {
5533 if (pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
) {
5534 if (pVBInfo
->VBInfo
& SetCRT2ToDualEdge
) {
5535 tempah
= 0x7F; /* Disable Channel A */
5536 if (!(pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
))
5537 /* Disable Channel B */
5540 if (pVBInfo
->SetFlag
& DisableChB
)
5541 /* force to disable Cahnnel */
5544 if (pVBInfo
->SetFlag
& DisableChA
)
5545 /* Force to disable Channel B */
5551 /* disable part4_1f */
5552 xgifb_reg_and(pVBInfo
->Part4Port
, 0x1F, tempah
);
5554 if (pVBInfo
->VBType
& (VB_SIS302LV
| VB_XGI301C
)) {
5555 if (((pVBInfo
->VBInfo
& (SetCRT2ToLCD
| XGI_SetCRT2ToLCDA
)))
5556 || (XGI_DisableChISLCD(pVBInfo
))
5557 || (XGI_IsLCDON(pVBInfo
)))
5558 /* LVDS Driver power down */
5559 xgifb_reg_or(pVBInfo
->Part4Port
, 0x30, 0x80);
5562 if ((pVBInfo
->SetFlag
& DisableChA
) || (pVBInfo
->VBInfo
5563 & (DisableCRT2Display
| XGI_SetCRT2ToLCDA
5564 | SetSimuScanMode
))) {
5565 if (pVBInfo
->SetFlag
& GatingCRT
)
5566 XGI_EnableGatingCRT(HwDeviceExtension
, pVBInfo
);
5567 XGI_DisplayOff(xgifb_info
, HwDeviceExtension
, pVBInfo
);
5570 if (pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
) {
5571 if ((pVBInfo
->SetFlag
& DisableChA
) || (pVBInfo
->VBInfo
5572 & XGI_SetCRT2ToLCDA
))
5574 xgifb_reg_and(pVBInfo
->Part1Port
, 0x1e, 0xdf);
5577 /* disable TV as primary VGA swap */
5578 xgifb_reg_and(pVBInfo
->P3c4
, 0x32, 0xdf);
5580 if ((pVBInfo
->VBInfo
& (SetSimuScanMode
| SetCRT2ToDualEdge
)))
5581 xgifb_reg_and(pVBInfo
->Part2Port
, 0x00, 0xdf);
5583 if ((pVBInfo
->SetFlag
& DisableChB
) ||
5585 (DisableCRT2Display
| SetSimuScanMode
)) ||
5586 ((!(pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
)) &&
5588 (SetCRT2ToRAMDAC
| SetCRT2ToLCD
| SetCRT2ToTV
))))
5589 xgifb_reg_or(pVBInfo
->Part1Port
, 0x00, 0x80);
5591 if ((pVBInfo
->SetFlag
& DisableChB
) ||
5593 (DisableCRT2Display
| SetSimuScanMode
)) ||
5594 (!(pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
)) ||
5596 (SetCRT2ToRAMDAC
| SetCRT2ToLCD
| SetCRT2ToTV
))) {
5597 /* save Part1 index 0 */
5598 tempah
= xgifb_reg_get(pVBInfo
->Part1Port
, 0x00);
5599 /* BTDAC = 1, avoid VB reset */
5600 xgifb_reg_or(pVBInfo
->Part1Port
, 0x00, 0x10);
5602 xgifb_reg_and(pVBInfo
->Part1Port
, 0x1E, 0xDF);
5603 /* restore Part1 index 0 */
5604 xgifb_reg_set(pVBInfo
->Part1Port
, 0x00, tempah
);
5606 } else { /* {301} */
5607 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToTV
)) {
5608 xgifb_reg_or(pVBInfo
->Part1Port
, 0x00, 0x80);
5610 xgifb_reg_and(pVBInfo
->Part1Port
, 0x1E, 0xDF);
5611 /* Disable TV asPrimary VGA swap */
5612 xgifb_reg_and(pVBInfo
->P3c4
, 0x32, 0xDF);
5615 if (pVBInfo
->VBInfo
& (DisableCRT2Display
| XGI_SetCRT2ToLCDA
5617 XGI_DisplayOff(xgifb_info
, HwDeviceExtension
, pVBInfo
);
5621 /* --------------------------------------------------------------------- */
5622 /* Function : XGI_GetTVPtrIndex */
5625 /* Description : bx 0 : ExtNTSC */
5637 /* --------------------------------------------------------------------- */
5638 static unsigned short XGI_GetTVPtrIndex(struct vb_device_info
*pVBInfo
)
5640 unsigned short tempbx
= 0;
5642 if (pVBInfo
->TVInfo
& TVSetPAL
)
5644 if (pVBInfo
->TVInfo
& TVSetHiVision
)
5646 if (pVBInfo
->TVInfo
& TVSetYPbPr525i
)
5648 if (pVBInfo
->TVInfo
& TVSetYPbPr525p
)
5650 if (pVBInfo
->TVInfo
& TVSetYPbPr750p
)
5652 if (pVBInfo
->TVInfo
& TVSimuMode
)
5658 /* --------------------------------------------------------------------- */
5659 /* Function : XGI_GetTVPtrIndex2 */
5661 /* Output : bx 0 : NTSC */
5665 /* 4 : NTSC1024x768 */
5666 /* 5 : PAL-M 1024x768 */
5668 /* cl 0 : YFilter1 */
5671 /* 1 : 301B/302B/301LV/302LV */
5673 /* --------------------------------------------------------------------- */
5674 static void XGI_GetTVPtrIndex2(unsigned short *tempbx
, unsigned char *tempcl
,
5675 unsigned char *tempch
, struct vb_device_info
*pVBInfo
)
5681 if (pVBInfo
->TVInfo
& TVSetPAL
)
5684 if (pVBInfo
->TVInfo
& TVSetPALM
)
5687 if (pVBInfo
->TVInfo
& TVSetPALN
)
5690 if (pVBInfo
->TVInfo
& NTSC1024x768
) {
5692 if (pVBInfo
->TVInfo
& TVSetPALM
)
5696 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
5697 | VB_SIS302LV
| VB_XGI301C
)) {
5698 if ((!(pVBInfo
->VBInfo
& SetInSlaveMode
)) || (pVBInfo
->TVInfo
5705 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
5706 | VB_SIS302LV
| VB_XGI301C
))
5710 static void XGI_SetDelayComp(struct vb_device_info
*pVBInfo
)
5712 unsigned char tempah
, tempbl
, tempbh
;
5714 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
5715 | VB_SIS302LV
| VB_XGI301C
)) {
5716 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| XGI_SetCRT2ToLCDA
5717 | SetCRT2ToTV
| SetCRT2ToRAMDAC
)) {
5719 tempbl
= XGI301TVDelay
;
5721 if (pVBInfo
->VBInfo
& SetCRT2ToDualEdge
)
5722 tempbl
= tempbl
>> 4;
5723 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| XGI_SetCRT2ToLCDA
)) {
5724 tempbh
= XGI301LCDDelay
;
5726 if (!(pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
))
5732 tempah
= xgifb_reg_get(pVBInfo
->Part1Port
, 0x2D);
5734 if (pVBInfo
->VBInfo
& (SetCRT2ToRAMDAC
| SetCRT2ToLCD
5735 | SetCRT2ToTV
)) { /* Channel B */
5740 if (pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
) { /* Channel A */
5744 xgifb_reg_set(pVBInfo
->Part1Port
, 0x2D, tempah
);
5746 } else if (pVBInfo
->IF_DEF_LVDS
== 1) {
5749 if (pVBInfo
->VBInfo
& SetCRT2ToLCD
) {
5750 tempah
= XGI301LCDDelay
;
5752 tempah
= tempah
<< 4;
5753 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x2D, 0x0f,
5759 static void XGI_SetLCDCap_A(unsigned short tempcx
,
5760 struct vb_device_info
*pVBInfo
)
5762 unsigned short temp
;
5764 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x37);
5766 if (temp
& LCDRGB18Bit
) {
5767 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x19, 0x0F,
5769 (unsigned short) (0x20 | (tempcx
& 0x00C0)));
5770 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x1A, 0x7F, 0x80);
5772 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x19, 0x0F,
5773 (unsigned short) (0x30 | (tempcx
& 0x00C0)));
5774 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x1A, 0x7F, 0x00);
5778 /* --------------------------------------------------------------------- */
5779 /* Function : XGI_SetLCDCap_B */
5780 /* Input : cx -> LCD Capability */
5783 /* --------------------------------------------------------------------- */
5784 static void XGI_SetLCDCap_B(unsigned short tempcx
,
5785 struct vb_device_info
*pVBInfo
)
5787 if (tempcx
& EnableLCD24bpp
) /* 24bits */
5788 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x1A, 0xE0,
5789 (unsigned short) (((tempcx
& 0x00ff) >> 6)
5792 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x1A, 0xE0,
5793 (unsigned short) (((tempcx
& 0x00ff) >> 6)
5794 | 0x18)); /* Enable Dither */
5797 static void XGI_LongWait(struct vb_device_info
*pVBInfo
)
5801 i
= xgifb_reg_get(pVBInfo
->P3c4
, 0x1F);
5804 for (i
= 0; i
< 0xFFFF; i
++) {
5805 if (!(inb(pVBInfo
->P3da
) & 0x08))
5809 for (i
= 0; i
< 0xFFFF; i
++) {
5810 if ((inb(pVBInfo
->P3da
) & 0x08))
5816 static void SetSpectrum(struct vb_device_info
*pVBInfo
)
5818 unsigned short index
;
5820 index
= XGI_GetLCDCapPtr(pVBInfo
);
5822 /* disable down spectrum D[4] */
5823 xgifb_reg_and(pVBInfo
->Part4Port
, 0x30, 0x8F);
5824 XGI_LongWait(pVBInfo
);
5825 xgifb_reg_or(pVBInfo
->Part4Port
, 0x30, 0x20); /* reset spectrum */
5826 XGI_LongWait(pVBInfo
);
5828 xgifb_reg_set(pVBInfo
->Part4Port
, 0x31,
5829 pVBInfo
->LCDCapList
[index
].Spectrum_31
);
5830 xgifb_reg_set(pVBInfo
->Part4Port
, 0x32,
5831 pVBInfo
->LCDCapList
[index
].Spectrum_32
);
5832 xgifb_reg_set(pVBInfo
->Part4Port
, 0x33,
5833 pVBInfo
->LCDCapList
[index
].Spectrum_33
);
5834 xgifb_reg_set(pVBInfo
->Part4Port
, 0x34,
5835 pVBInfo
->LCDCapList
[index
].Spectrum_34
);
5836 XGI_LongWait(pVBInfo
);
5837 xgifb_reg_or(pVBInfo
->Part4Port
, 0x30, 0x40); /* enable spectrum */
5840 static void XGI_SetLCDCap(struct vb_device_info
*pVBInfo
)
5842 unsigned short tempcx
;
5844 tempcx
= pVBInfo
->LCDCapList
[XGI_GetLCDCapPtr(pVBInfo
)].LCD_Capability
;
5846 if (pVBInfo
->VBType
&
5851 VB_XGI301C
)) { /* 301LV/302LV only */
5852 if (pVBInfo
->VBType
&
5853 (VB_SIS301LV
| VB_SIS302LV
| VB_XGI301C
)) {
5854 /* Set 301LV Capability */
5855 xgifb_reg_set(pVBInfo
->Part4Port
, 0x24,
5856 (unsigned char) (tempcx
& 0x1F));
5859 xgifb_reg_and_or(pVBInfo
->Part4Port
, 0x0D,
5860 ~((EnableVBCLKDRVLOW
| EnablePLLSPLOW
) >> 8),
5861 (unsigned short) ((tempcx
& (EnableVBCLKDRVLOW
5862 | EnablePLLSPLOW
)) >> 8));
5865 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
5866 | VB_SIS302LV
| VB_XGI301C
)) {
5867 if (pVBInfo
->VBInfo
& SetCRT2ToLCD
)
5868 XGI_SetLCDCap_B(tempcx
, pVBInfo
);
5869 else if (pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
)
5870 XGI_SetLCDCap_A(tempcx
, pVBInfo
);
5872 if (pVBInfo
->VBType
& (VB_SIS302LV
| VB_XGI301C
)) {
5873 if (tempcx
& EnableSpectrum
)
5874 SetSpectrum(pVBInfo
);
5878 XGI_SetLCDCap_A(tempcx
, pVBInfo
);
5882 /* --------------------------------------------------------------------- */
5883 /* Function : XGI_SetAntiFlicker */
5886 /* Description : Set TV Customized Param. */
5887 /* --------------------------------------------------------------------- */
5888 static void XGI_SetAntiFlicker(unsigned short ModeNo
,
5889 unsigned short ModeIdIndex
,
5890 struct vb_device_info
*pVBInfo
)
5892 unsigned short tempbx
;
5894 unsigned char tempah
;
5896 if (pVBInfo
->TVInfo
& (TVSetYPbPr525p
| TVSetYPbPr750p
))
5899 tempbx
= XGI_GetTVPtrIndex(pVBInfo
);
5901 tempah
= TVAntiFlickList
[tempbx
];
5902 tempah
= tempah
<< 4;
5904 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x0A, 0x8F, tempah
);
5907 static void XGI_SetEdgeEnhance(unsigned short ModeNo
,
5908 unsigned short ModeIdIndex
,
5909 struct vb_device_info
*pVBInfo
)
5911 unsigned short tempbx
;
5913 unsigned char tempah
;
5915 tempbx
= XGI_GetTVPtrIndex(pVBInfo
);
5917 tempah
= TVEdgeList
[tempbx
];
5918 tempah
= tempah
<< 5;
5920 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x3A, 0x1F, tempah
);
5923 static void XGI_SetPhaseIncr(struct vb_device_info
*pVBInfo
)
5925 unsigned short tempbx
;
5927 unsigned char tempcl
, tempch
;
5929 unsigned long tempData
;
5931 XGI_GetTVPtrIndex2(&tempbx
, &tempcl
, &tempch
, pVBInfo
); /* bx, cl, ch */
5932 tempData
= TVPhaseList
[tempbx
];
5934 xgifb_reg_set(pVBInfo
->Part2Port
, 0x31, (unsigned short) (tempData
5936 xgifb_reg_set(pVBInfo
->Part2Port
, 0x32, (unsigned short) ((tempData
5937 & 0x0000FF00) >> 8));
5938 xgifb_reg_set(pVBInfo
->Part2Port
, 0x33, (unsigned short) ((tempData
5939 & 0x00FF0000) >> 16));
5940 xgifb_reg_set(pVBInfo
->Part2Port
, 0x34, (unsigned short) ((tempData
5941 & 0xFF000000) >> 24));
5944 static void XGI_SetYFilter(unsigned short ModeNo
, unsigned short ModeIdIndex
,
5945 struct vb_device_info
*pVBInfo
)
5947 unsigned short tempbx
, index
;
5949 unsigned char tempcl
, tempch
, tempal
, *filterPtr
;
5951 XGI_GetTVPtrIndex2(&tempbx
, &tempcl
, &tempch
, pVBInfo
); /* bx, cl, ch */
5956 filterPtr
= NTSCYFilter1
;
5960 filterPtr
= PALYFilter1
;
5967 filterPtr
= xgifb_palmn_yfilter1
;
5975 filterPtr
= xgifb_yfilter2
;
5982 tempal
= pVBInfo
->EModeIDTable
[ModeIdIndex
].VB_ExtTVYFilterIndex
;
5988 if ((tempcl
== 0) && (tempch
== 1)) {
5989 xgifb_reg_set(pVBInfo
->Part2Port
, 0x35, 0);
5990 xgifb_reg_set(pVBInfo
->Part2Port
, 0x36, 0);
5991 xgifb_reg_set(pVBInfo
->Part2Port
, 0x37, 0);
5992 xgifb_reg_set(pVBInfo
->Part2Port
, 0x38, filterPtr
[index
++]);
5994 xgifb_reg_set(pVBInfo
->Part2Port
, 0x35, filterPtr
[index
++]);
5995 xgifb_reg_set(pVBInfo
->Part2Port
, 0x36, filterPtr
[index
++]);
5996 xgifb_reg_set(pVBInfo
->Part2Port
, 0x37, filterPtr
[index
++]);
5997 xgifb_reg_set(pVBInfo
->Part2Port
, 0x38, filterPtr
[index
++]);
6000 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
6001 | VB_SIS302LV
| VB_XGI301C
)) {
6002 xgifb_reg_set(pVBInfo
->Part2Port
, 0x48, filterPtr
[index
++]);
6003 xgifb_reg_set(pVBInfo
->Part2Port
, 0x49, filterPtr
[index
++]);
6004 xgifb_reg_set(pVBInfo
->Part2Port
, 0x4A, filterPtr
[index
++]);
6008 /* --------------------------------------------------------------------- */
6009 /* Function : XGI_OEM310Setting */
6012 /* Description : Customized Param. for 301 */
6013 /* --------------------------------------------------------------------- */
6014 static void XGI_OEM310Setting(unsigned short ModeNo
,
6015 unsigned short ModeIdIndex
,
6016 struct vb_device_info
*pVBInfo
)
6018 XGI_SetDelayComp(pVBInfo
);
6020 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| XGI_SetCRT2ToLCDA
))
6021 XGI_SetLCDCap(pVBInfo
);
6023 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
6024 XGI_SetPhaseIncr(pVBInfo
);
6025 XGI_SetYFilter(ModeNo
, ModeIdIndex
, pVBInfo
);
6026 XGI_SetAntiFlicker(ModeNo
, ModeIdIndex
, pVBInfo
);
6028 if (pVBInfo
->VBType
& VB_SIS301
)
6029 XGI_SetEdgeEnhance(ModeNo
, ModeIdIndex
, pVBInfo
);
6033 /* --------------------------------------------------------------------- */
6034 /* Function : XGI_SetCRT2ModeRegs */
6037 /* Description : Origin code for crt2group */
6038 /* --------------------------------------------------------------------- */
6039 static void XGI_SetCRT2ModeRegs(unsigned short ModeNo
,
6040 struct xgi_hw_device_info
*HwDeviceExtension
,
6041 struct vb_device_info
*pVBInfo
)
6043 unsigned short tempbl
;
6046 unsigned char tempah
;
6049 if (!(pVBInfo
->VBInfo
& DisableCRT2Display
)) {
6050 tempah
= xgifb_reg_get(pVBInfo
->Part1Port
, 0x00);
6051 tempah
&= ~0x10; /* BTRAMDAC */
6052 tempah
|= 0x40; /* BTRAM */
6054 if (pVBInfo
->VBInfo
& (SetCRT2ToRAMDAC
| SetCRT2ToTV
6056 tempah
= 0x40; /* BTDRAM */
6057 tempcl
= pVBInfo
->ModeType
;
6061 tempah
= (0x008 >> tempcl
);
6066 if (pVBInfo
->VBInfo
& SetInSlaveMode
)
6067 tempah
^= 0x50; /* BTDAC */
6071 xgifb_reg_set(pVBInfo
->Part1Port
, 0x00, tempah
);
6075 if (pVBInfo
->VBInfo
& DisableCRT2Display
) {
6076 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x2e, tempbl
, tempah
);
6081 if (pVBInfo
->VBInfo
& (SetCRT2ToRAMDAC
| SetCRT2ToTV
6082 | SetCRT2ToLCD
| XGI_SetCRT2ToLCDA
)) {
6083 if ((pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
) &&
6084 (!(pVBInfo
->VBInfo
& SetSimuScanMode
))) {
6087 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x2e,
6090 if (pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
) {
6095 if (pVBInfo
->VBInfo
&
6102 if (!(pVBInfo
->VBInfo
& SetInSlaveMode
))
6105 if (!(pVBInfo
->VBInfo
&
6107 tempah
= tempah
^ 0x05;
6108 if (!(pVBInfo
->VBInfo
&
6110 tempah
= tempah
^ 0x01;
6113 if (!(pVBInfo
->VBInfo
&
6116 xgifb_reg_and_or(pVBInfo
->Part1Port
,
6117 0x2e, tempbl
, tempah
);
6119 xgifb_reg_and_or(pVBInfo
->Part1Port
,
6120 0x2e, tempbl
, tempah
);
6124 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x2e, tempbl
,
6129 if (pVBInfo
->VBInfo
& (SetCRT2ToRAMDAC
| SetCRT2ToTV
| SetCRT2ToLCD
6130 | XGI_SetCRT2ToLCDA
)) {
6132 if ((pVBInfo
->ModeType
== ModeVGA
) && (!(pVBInfo
->VBInfo
6133 & SetInSlaveMode
))) {
6138 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
6140 if (pVBInfo
->VBInfo
& DriverMode
)
6141 tempah
= tempah
^ 0x20;
6144 xgifb_reg_and_or(pVBInfo
->Part4Port
, 0x0D, ~0x0BF, tempah
);
6147 if (pVBInfo
->LCDInfo
& SetLCDDualLink
)
6150 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
6151 if (pVBInfo
->TVInfo
& RPLLDIV2XO
)
6155 if ((pVBInfo
->LCDResInfo
== Panel_1280x1024
)
6156 || (pVBInfo
->LCDResInfo
== Panel_1280x1024x75
))
6159 if (pVBInfo
->LCDResInfo
== Panel_1280x960
)
6162 xgifb_reg_set(pVBInfo
->Part4Port
, 0x0C, tempah
);
6165 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
6166 | VB_SIS302LV
| VB_XGI301C
)) {
6170 if (pVBInfo
->VBInfo
& SetCRT2ToDualEdge
) {
6172 if (pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
)
6173 tempah
|= 0x04; /* shampoo 0129 */
6176 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x13, tempbl
, tempah
);
6179 if (!(pVBInfo
->VBInfo
& DisableCRT2Display
)) {
6180 if (pVBInfo
->VBInfo
& SetCRT2ToDualEdge
)
6184 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x2c, tempbl
, tempah
);
6188 if (!(pVBInfo
->VBInfo
& DisableCRT2Display
)) {
6189 if (pVBInfo
->VBInfo
& SetCRT2ToDualEdge
)
6192 xgifb_reg_and_or(pVBInfo
->Part4Port
, 0x21, tempbl
, tempah
);
6197 if (!(pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
)) {
6199 if (!(pVBInfo
->VBInfo
& SetCRT2ToDualEdge
))
6203 xgifb_reg_and_or(pVBInfo
->Part4Port
, 0x23, tempbl
, tempah
);
6205 if (pVBInfo
->VBType
& (VB_SIS302LV
| VB_XGI301C
)) {
6206 if (pVBInfo
->LCDInfo
& SetLCDDualLink
) {
6207 xgifb_reg_or(pVBInfo
->Part4Port
, 0x27, 0x20);
6208 xgifb_reg_or(pVBInfo
->Part4Port
, 0x34, 0x10);
6214 void XGI_UnLockCRT2(struct xgi_hw_device_info
*HwDeviceExtension
,
6215 struct vb_device_info
*pVBInfo
)
6218 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x2f, 0xFF, 0x01);
6222 void XGI_LockCRT2(struct xgi_hw_device_info
*HwDeviceExtension
,
6223 struct vb_device_info
*pVBInfo
)
6226 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x2F, 0xFE, 0x00);
6230 unsigned char XGI_BridgeIsOn(struct vb_device_info
*pVBInfo
)
6232 unsigned short flag
;
6234 if (pVBInfo
->IF_DEF_LVDS
== 1) {
6237 flag
= xgifb_reg_get(pVBInfo
->Part4Port
, 0x00);
6238 if ((flag
== 1) || (flag
== 2))
6239 return 1; /* 301b */
6245 unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info
*pXGIHWDE
,
6246 unsigned short ModeNo
, unsigned short ModeIdIndex
,
6247 struct vb_device_info
*pVBInfo
)
6249 short LCDRefreshIndex
[] = { 0x00, 0x00, 0x03, 0x01 },
6250 LCDARefreshIndex
[] = { 0x00, 0x00, 0x03, 0x01, 0x01,
6253 unsigned short RefreshRateTableIndex
, i
, modeflag
, index
, temp
;
6255 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
6257 index
= xgifb_reg_get(pVBInfo
->P3d4
, 0x33);
6258 index
= index
>> pVBInfo
->SelectCRT2Rate
;
6261 if (pVBInfo
->LCDInfo
& LCDNonExpanding
)
6267 if (pVBInfo
->SetFlag
& ProgrammingCRT2
) {
6268 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| XGI_SetCRT2ToLCDA
)) {
6269 if (pVBInfo
->IF_DEF_LVDS
== 0) {
6270 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
6271 | VB_SIS301LV
| VB_SIS302LV
6274 temp
= LCDARefreshIndex
[
6275 pVBInfo
->LCDResInfo
& 0x0F];
6277 temp
= LCDRefreshIndex
[
6278 pVBInfo
->LCDResInfo
& 0x0F];
6288 RefreshRateTableIndex
= pVBInfo
->EModeIDTable
[ModeIdIndex
].REFindex
;
6289 ModeNo
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].ModeID
;
6290 if (pXGIHWDE
->jChipType
>= XG20
) { /* for XG20, XG21, XG27 */
6291 if ((pVBInfo
->RefIndex
[RefreshRateTableIndex
].XRes
== 800) &&
6292 (pVBInfo
->RefIndex
[RefreshRateTableIndex
].YRes
== 600)) {
6296 * do the similar adjustment like XGISearchCRT1Rate() */
6297 if ((pVBInfo
->RefIndex
[RefreshRateTableIndex
].XRes
== 1024) &&
6298 (pVBInfo
->RefIndex
[RefreshRateTableIndex
].YRes
== 768)) {
6301 if ((pVBInfo
->RefIndex
[RefreshRateTableIndex
].XRes
== 1280) &&
6302 (pVBInfo
->RefIndex
[RefreshRateTableIndex
].YRes
== 1024)) {
6309 if (pVBInfo
->RefIndex
[RefreshRateTableIndex
+ i
].
6312 temp
= pVBInfo
->RefIndex
[RefreshRateTableIndex
+ i
].
6314 temp
&= ModeTypeMask
;
6315 if (temp
< pVBInfo
->ModeType
)
6320 } while (index
!= 0xFFFF);
6321 if (!(pVBInfo
->VBInfo
& SetCRT2ToRAMDAC
)) {
6322 if (pVBInfo
->VBInfo
& SetInSlaveMode
) {
6323 temp
= pVBInfo
->RefIndex
[RefreshRateTableIndex
+ i
- 1].
6325 if (temp
& InterlaceMode
)
6330 if ((pVBInfo
->SetFlag
& ProgrammingCRT2
)) {
6331 temp
= XGI_AjustCRT2Rate(ModeNo
, ModeIdIndex
,
6332 RefreshRateTableIndex
, &i
, pVBInfo
);
6334 return RefreshRateTableIndex
+ i
;
6337 static void XGI_SetLCDAGroup(unsigned short ModeNo
, unsigned short ModeIdIndex
,
6338 struct xgi_hw_device_info
*HwDeviceExtension
,
6339 struct vb_device_info
*pVBInfo
)
6341 unsigned short RefreshRateTableIndex
;
6343 pVBInfo
->SetFlag
|= ProgrammingCRT2
;
6344 RefreshRateTableIndex
= XGI_GetRatePtrCRT2(HwDeviceExtension
, ModeNo
,
6345 ModeIdIndex
, pVBInfo
);
6346 XGI_GetLVDSResInfo(ModeNo
, ModeIdIndex
, pVBInfo
);
6347 XGI_GetLVDSData(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
, pVBInfo
);
6348 XGI_ModCRT1Regs(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
6349 HwDeviceExtension
, pVBInfo
);
6350 XGI_SetLVDSRegs(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
, pVBInfo
);
6351 XGI_SetCRT2ECLK(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
, pVBInfo
);
6354 static unsigned char XGI_SetCRT2Group301(unsigned short ModeNo
,
6355 struct xgi_hw_device_info
*HwDeviceExtension
,
6356 struct vb_device_info
*pVBInfo
)
6358 unsigned short tempbx
, ModeIdIndex
, RefreshRateTableIndex
;
6360 tempbx
= pVBInfo
->VBInfo
;
6361 pVBInfo
->SetFlag
|= ProgrammingCRT2
;
6362 XGI_SearchModeID(ModeNo
, &ModeIdIndex
, pVBInfo
);
6363 pVBInfo
->SelectCRT2Rate
= 4;
6364 RefreshRateTableIndex
= XGI_GetRatePtrCRT2(HwDeviceExtension
, ModeNo
,
6365 ModeIdIndex
, pVBInfo
);
6366 XGI_SaveCRT2Info(ModeNo
, pVBInfo
);
6367 XGI_GetCRT2ResInfo(ModeNo
, ModeIdIndex
, pVBInfo
);
6368 XGI_GetCRT2Data(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
, pVBInfo
);
6369 XGI_PreSetGroup1(ModeNo
, ModeIdIndex
, HwDeviceExtension
,
6370 RefreshRateTableIndex
, pVBInfo
);
6371 XGI_SetGroup1(ModeNo
, ModeIdIndex
, HwDeviceExtension
,
6372 RefreshRateTableIndex
, pVBInfo
);
6373 XGI_SetLockRegs(ModeNo
, ModeIdIndex
, HwDeviceExtension
,
6374 RefreshRateTableIndex
, pVBInfo
);
6375 XGI_SetGroup2(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
6376 HwDeviceExtension
, pVBInfo
);
6377 XGI_SetLCDRegs(ModeNo
, ModeIdIndex
, HwDeviceExtension
,
6378 RefreshRateTableIndex
, pVBInfo
);
6379 XGI_SetTap4Regs(pVBInfo
);
6380 XGI_SetGroup3(ModeNo
, ModeIdIndex
, pVBInfo
);
6381 XGI_SetGroup4(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
6382 HwDeviceExtension
, pVBInfo
);
6383 XGI_SetCRT2VCLK(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
, pVBInfo
);
6384 XGI_SetGroup5(ModeNo
, ModeIdIndex
, pVBInfo
);
6385 XGI_AutoThreshold(pVBInfo
);
6389 void XGI_SenseCRT1(struct vb_device_info
*pVBInfo
)
6391 unsigned char CRTCData
[17] = { 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81,
6392 0x0B, 0x3E, 0xE9, 0x0B, 0xDF, 0xE7, 0x04, 0x00, 0x00,
6395 unsigned char SR01
= 0, SR1F
= 0, SR07
= 0, SR06
= 0;
6397 unsigned char CR17
, CR63
, SR31
;
6398 unsigned short temp
;
6399 unsigned char DAC_TEST_PARMS
[3] = { 0x0F, 0x0F, 0x0F };
6402 xgifb_reg_set(pVBInfo
->P3c4
, 0x05, 0x86);
6404 /* [2004/05/06] Vicent to fix XG42 single LCD sense to CRT+LCD */
6405 xgifb_reg_set(pVBInfo
->P3d4
, 0x57, 0x4A);
6406 xgifb_reg_set(pVBInfo
->P3d4
, 0x53, (unsigned char) (xgifb_reg_get(
6407 pVBInfo
->P3d4
, 0x53) | 0x02));
6409 SR31
= (unsigned char) xgifb_reg_get(pVBInfo
->P3c4
, 0x31);
6410 CR63
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x63);
6411 SR01
= (unsigned char) xgifb_reg_get(pVBInfo
->P3c4
, 0x01);
6413 xgifb_reg_set(pVBInfo
->P3c4
, 0x01, (unsigned char) (SR01
& 0xDF));
6414 xgifb_reg_set(pVBInfo
->P3d4
, 0x63, (unsigned char) (CR63
& 0xBF));
6416 CR17
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x17);
6417 xgifb_reg_set(pVBInfo
->P3d4
, 0x17, (unsigned char) (CR17
| 0x80));
6419 SR1F
= (unsigned char) xgifb_reg_get(pVBInfo
->P3c4
, 0x1F);
6420 xgifb_reg_set(pVBInfo
->P3c4
, 0x1F, (unsigned char) (SR1F
| 0x04));
6422 SR07
= (unsigned char) xgifb_reg_get(pVBInfo
->P3c4
, 0x07);
6423 xgifb_reg_set(pVBInfo
->P3c4
, 0x07, (unsigned char) (SR07
& 0xFB));
6424 SR06
= (unsigned char) xgifb_reg_get(pVBInfo
->P3c4
, 0x06);
6425 xgifb_reg_set(pVBInfo
->P3c4
, 0x06, (unsigned char) (SR06
& 0xC3));
6427 xgifb_reg_set(pVBInfo
->P3d4
, 0x11, 0x00);
6429 for (i
= 0; i
< 8; i
++)
6430 xgifb_reg_set(pVBInfo
->P3d4
, (unsigned short) i
, CRTCData
[i
]);
6432 for (i
= 8; i
< 11; i
++)
6433 xgifb_reg_set(pVBInfo
->P3d4
, (unsigned short) (i
+ 8),
6436 for (i
= 11; i
< 13; i
++)
6437 xgifb_reg_set(pVBInfo
->P3d4
, (unsigned short) (i
+ 4),
6440 for (i
= 13; i
< 16; i
++)
6441 xgifb_reg_set(pVBInfo
->P3c4
, (unsigned short) (i
- 3),
6444 xgifb_reg_set(pVBInfo
->P3c4
, 0x0E, (unsigned char) (CRTCData
[16]
6447 xgifb_reg_set(pVBInfo
->P3c4
, 0x31, 0x00);
6448 xgifb_reg_set(pVBInfo
->P3c4
, 0x2B, 0x1B);
6449 xgifb_reg_set(pVBInfo
->P3c4
, 0x2C, 0xE1);
6451 outb(0x00, pVBInfo
->P3c8
);
6453 for (i
= 0; i
< 256; i
++) {
6454 outb((unsigned char) DAC_TEST_PARMS
[0], (pVBInfo
->P3c8
+ 1));
6455 outb((unsigned char) DAC_TEST_PARMS
[1], (pVBInfo
->P3c8
+ 1));
6456 outb((unsigned char) DAC_TEST_PARMS
[2], (pVBInfo
->P3c8
+ 1));
6461 XGI_WaitDisply(pVBInfo
);
6462 temp
= inb(pVBInfo
->P3c2
);
6465 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x32, 0xDF, 0x20);
6467 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x32, 0xDF, 0x00);
6469 /* alan, avoid display something, set BLACK DAC if not restore DAC */
6470 outb(0x00, pVBInfo
->P3c8
);
6472 for (i
= 0; i
< 256; i
++) {
6473 outb(0, (pVBInfo
->P3c8
+ 1));
6474 outb(0, (pVBInfo
->P3c8
+ 1));
6475 outb(0, (pVBInfo
->P3c8
+ 1));
6478 xgifb_reg_set(pVBInfo
->P3c4
, 0x01, SR01
);
6479 xgifb_reg_set(pVBInfo
->P3d4
, 0x63, CR63
);
6480 xgifb_reg_set(pVBInfo
->P3c4
, 0x31, SR31
);
6482 /* [2004/05/11] Vicent */
6483 xgifb_reg_set(pVBInfo
->P3d4
, 0x53, (unsigned char) (xgifb_reg_get(
6484 pVBInfo
->P3d4
, 0x53) & 0xFD));
6485 xgifb_reg_set(pVBInfo
->P3c4
, 0x1F, (unsigned char) SR1F
);
6488 static void XGI_EnableBridge(struct xgifb_video_info
*xgifb_info
,
6489 struct xgi_hw_device_info
*HwDeviceExtension
,
6490 struct vb_device_info
*pVBInfo
)
6492 unsigned short tempah
;
6494 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
6495 | VB_SIS302LV
| VB_XGI301C
)) {
6496 if (!(pVBInfo
->SetFlag
& DisableChA
)) {
6497 if (pVBInfo
->SetFlag
& EnableChA
) {
6499 xgifb_reg_set(pVBInfo
->Part1Port
, 0x1E, 0x20);
6501 if (pVBInfo
->VBInfo
& SetCRT2ToDualEdge
) {
6503 xgifb_reg_set(pVBInfo
->Part1Port
,
6509 if (!(pVBInfo
->SetFlag
& DisableChB
)) {
6510 if ((pVBInfo
->SetFlag
& EnableChB
) || (pVBInfo
->VBInfo
6511 & (SetCRT2ToLCD
| SetCRT2ToTV
6512 | SetCRT2ToRAMDAC
))) {
6513 tempah
= (unsigned char) xgifb_reg_get(
6514 pVBInfo
->P3c4
, 0x32);
6516 if (pVBInfo
->VBInfo
& SetInSlaveMode
) {
6517 if (!(pVBInfo
->VBInfo
&
6521 xgifb_reg_set(pVBInfo
->P3c4
, 0x32, tempah
);
6522 xgifb_reg_or(pVBInfo
->P3c4
, 0x1E, 0x20);
6524 tempah
= (unsigned char) xgifb_reg_get(
6525 pVBInfo
->Part1Port
, 0x2E);
6527 if (!(tempah
& 0x80))
6528 xgifb_reg_or(pVBInfo
->Part1Port
,
6530 xgifb_reg_and(pVBInfo
->Part1Port
, 0x00, 0x7F);
6534 if ((pVBInfo
->SetFlag
& (EnableChA
| EnableChB
))
6535 || (!(pVBInfo
->VBInfo
& DisableCRT2Display
))) {
6536 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x00, ~0xE0,
6537 0x20); /* shampoo 0129 */
6538 if (pVBInfo
->VBType
& (VB_SIS302LV
| VB_XGI301C
)) {
6539 if (!XGI_DisableChISLCD(pVBInfo
)) {
6540 if (XGI_EnableChISLCD(pVBInfo
) ||
6542 (SetCRT2ToLCD
| XGI_SetCRT2ToLCDA
)))
6543 /* LVDS PLL power on */
6549 /* LVDS Driver power on */
6550 xgifb_reg_and(pVBInfo
->Part4Port
, 0x30, 0x7F);
6556 if (!(pVBInfo
->VBInfo
& DisableCRT2Display
)) {
6559 if (!(pVBInfo
->VBInfo
& SetSimuScanMode
)) {
6560 if (pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
) {
6561 if (pVBInfo
->VBInfo
&
6562 SetCRT2ToDualEdge
) {
6563 tempah
= tempah
& 0x40;
6564 if (pVBInfo
->VBInfo
&
6566 tempah
= tempah
^ 0xC0;
6568 if (pVBInfo
->SetFlag
&
6572 if (pVBInfo
->SetFlag
&
6576 if (pVBInfo
->SetFlag
&
6580 if (pVBInfo
->SetFlag
&
6588 /* EnablePart4_1F */
6589 xgifb_reg_or(pVBInfo
->Part4Port
, 0x1F, tempah
);
6591 if (!(pVBInfo
->SetFlag
& DisableChA
)) {
6592 if (!(pVBInfo
->SetFlag
& GatingCRT
)) {
6593 XGI_DisableGatingCRT(HwDeviceExtension
,
6595 XGI_DisplayOn(xgifb_info
, HwDeviceExtension
,
6601 if (pVBInfo
->VBInfo
& (SetCRT2ToTV
| SetCRT2ToLCD
6602 | XGI_SetCRT2ToLCDA
))
6604 xgifb_reg_or(pVBInfo
->Part1Port
, 0x1E, 0x20);
6606 tempah
= (unsigned char) xgifb_reg_get(pVBInfo
->Part1Port
,
6608 if (!(tempah
& 0x80))
6609 xgifb_reg_or(pVBInfo
->Part1Port
, 0x2E, 0x80);
6611 xgifb_reg_and(pVBInfo
->Part1Port
, 0x00, 0x7F);
6612 XGI_DisplayOn(xgifb_info
, HwDeviceExtension
, pVBInfo
);
6616 static void XGI_SetCRT1Group(struct xgifb_video_info
*xgifb_info
,
6617 struct xgi_hw_device_info
*HwDeviceExtension
,
6618 unsigned short ModeNo
, unsigned short ModeIdIndex
,
6619 struct vb_device_info
*pVBInfo
)
6621 unsigned short RefreshRateTableIndex
, temp
;
6623 XGI_SetSeqRegs(ModeNo
, ModeIdIndex
, pVBInfo
);
6624 outb(pVBInfo
->StandTable
->MISC
, pVBInfo
->P3c2
);
6625 XGI_SetCRTCRegs(HwDeviceExtension
, pVBInfo
);
6626 XGI_SetATTRegs(ModeNo
, ModeIdIndex
, pVBInfo
);
6627 XGI_SetGRCRegs(pVBInfo
);
6628 XGI_ClearExt1Regs(pVBInfo
);
6630 if (HwDeviceExtension
->jChipType
== XG27
) {
6631 if (pVBInfo
->IF_DEF_LVDS
== 0)
6632 XGI_SetDefaultVCLK(pVBInfo
);
6635 temp
= ~ProgrammingCRT2
;
6636 pVBInfo
->SetFlag
&= temp
;
6637 pVBInfo
->SelectCRT2Rate
= 0;
6639 if (pVBInfo
->VBType
& (VB_SIS301B
| VB_SIS302B
| VB_SIS301LV
6640 | VB_SIS302LV
| VB_XGI301C
)) {
6641 if (pVBInfo
->VBInfo
& (SetSimuScanMode
| XGI_SetCRT2ToLCDA
6642 | SetInSlaveMode
)) {
6643 pVBInfo
->SetFlag
|= ProgrammingCRT2
;
6647 RefreshRateTableIndex
= XGI_GetRatePtrCRT2(HwDeviceExtension
, ModeNo
,
6648 ModeIdIndex
, pVBInfo
);
6649 if (RefreshRateTableIndex
!= 0xFFFF) {
6650 XGI_SetSync(RefreshRateTableIndex
, pVBInfo
);
6651 XGI_SetCRT1CRTC(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
6652 pVBInfo
, HwDeviceExtension
);
6653 XGI_SetCRT1DE(HwDeviceExtension
, ModeNo
, ModeIdIndex
,
6654 RefreshRateTableIndex
, pVBInfo
);
6655 XGI_SetCRT1Offset(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
6656 HwDeviceExtension
, pVBInfo
);
6657 XGI_SetCRT1VCLK(ModeNo
, ModeIdIndex
, HwDeviceExtension
,
6658 RefreshRateTableIndex
, pVBInfo
);
6661 if (HwDeviceExtension
->jChipType
>= XG21
) {
6662 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x38);
6665 if (HwDeviceExtension
->jChipType
== XG27
)
6666 XGI_SetXG27CRTC(ModeNo
, ModeIdIndex
,
6667 RefreshRateTableIndex
, pVBInfo
);
6669 XGI_SetXG21CRTC(ModeNo
, ModeIdIndex
,
6670 RefreshRateTableIndex
, pVBInfo
);
6672 XGI_UpdateXG21CRTC(ModeNo
, pVBInfo
,
6673 RefreshRateTableIndex
);
6675 xgifb_set_lcd(HwDeviceExtension
->jChipType
,
6676 pVBInfo
, RefreshRateTableIndex
, ModeNo
);
6678 if (pVBInfo
->IF_DEF_LVDS
== 1)
6679 xgifb_set_lvds(xgifb_info
,
6680 HwDeviceExtension
->jChipType
,
6681 ModeNo
, ModeIdIndex
, pVBInfo
);
6685 pVBInfo
->SetFlag
&= (~ProgrammingCRT2
);
6686 XGI_SetCRT1FIFO(ModeNo
, HwDeviceExtension
, pVBInfo
);
6687 XGI_SetCRT1ModeRegs(HwDeviceExtension
, ModeNo
, ModeIdIndex
,
6688 RefreshRateTableIndex
, pVBInfo
);
6689 XGI_LoadDAC(ModeNo
, ModeIdIndex
, pVBInfo
);
6692 unsigned char XGISetModeNew(struct xgifb_video_info
*xgifb_info
,
6693 struct xgi_hw_device_info
*HwDeviceExtension
,
6694 unsigned short ModeNo
)
6696 unsigned short ModeIdIndex
;
6697 struct vb_device_info VBINF
;
6698 struct vb_device_info
*pVBInfo
= &VBINF
;
6699 pVBInfo
->BaseAddr
= xgifb_info
->vga_base
;
6700 pVBInfo
->IF_DEF_LVDS
= 0;
6701 pVBInfo
->IF_DEF_LCDA
= 1;
6703 if (HwDeviceExtension
->jChipType
>= XG20
) { /* kuku 2004/06/25 */
6704 pVBInfo
->IF_DEF_YPbPr
= 0;
6705 pVBInfo
->IF_DEF_HiVision
= 0;
6706 pVBInfo
->IF_DEF_CRT2Monitor
= 0;
6707 pVBInfo
->VBType
= 0; /*set VBType default 0*/
6709 pVBInfo
->IF_DEF_YPbPr
= 1;
6710 pVBInfo
->IF_DEF_HiVision
= 1;
6711 pVBInfo
->IF_DEF_CRT2Monitor
= 1;
6714 pVBInfo
->P3c4
= pVBInfo
->BaseAddr
+ 0x14;
6715 pVBInfo
->P3d4
= pVBInfo
->BaseAddr
+ 0x24;
6716 pVBInfo
->P3c0
= pVBInfo
->BaseAddr
+ 0x10;
6717 pVBInfo
->P3ce
= pVBInfo
->BaseAddr
+ 0x1e;
6718 pVBInfo
->P3c2
= pVBInfo
->BaseAddr
+ 0x12;
6719 pVBInfo
->P3cc
= pVBInfo
->BaseAddr
+ 0x1C;
6720 pVBInfo
->P3ca
= pVBInfo
->BaseAddr
+ 0x1a;
6721 pVBInfo
->P3c6
= pVBInfo
->BaseAddr
+ 0x16;
6722 pVBInfo
->P3c7
= pVBInfo
->BaseAddr
+ 0x17;
6723 pVBInfo
->P3c8
= pVBInfo
->BaseAddr
+ 0x18;
6724 pVBInfo
->P3c9
= pVBInfo
->BaseAddr
+ 0x19;
6725 pVBInfo
->P3da
= pVBInfo
->BaseAddr
+ 0x2A;
6726 pVBInfo
->Part0Port
= pVBInfo
->BaseAddr
+ XGI_CRT2_PORT_00
;
6727 pVBInfo
->Part1Port
= pVBInfo
->BaseAddr
+ SIS_CRT2_PORT_04
;
6728 pVBInfo
->Part2Port
= pVBInfo
->BaseAddr
+ SIS_CRT2_PORT_10
;
6729 pVBInfo
->Part3Port
= pVBInfo
->BaseAddr
+ SIS_CRT2_PORT_12
;
6730 pVBInfo
->Part4Port
= pVBInfo
->BaseAddr
+ SIS_CRT2_PORT_14
;
6731 pVBInfo
->Part5Port
= pVBInfo
->BaseAddr
+ SIS_CRT2_PORT_14
+ 2;
6733 /* for x86 Linux, XG21 LVDS */
6734 if (HwDeviceExtension
->jChipType
== XG21
) {
6735 if ((xgifb_reg_get(pVBInfo
->P3d4
, 0x38) & 0xE0) == 0xC0)
6736 pVBInfo
->IF_DEF_LVDS
= 1;
6738 if (HwDeviceExtension
->jChipType
== XG27
) {
6739 if ((xgifb_reg_get(pVBInfo
->P3d4
, 0x38) & 0xE0) == 0xC0) {
6740 if (xgifb_reg_get(pVBInfo
->P3d4
, 0x30) & 0x20)
6741 pVBInfo
->IF_DEF_LVDS
= 1;
6745 if (HwDeviceExtension
->jChipType
< XG20
) /* kuku 2004/06/25 */
6746 XGI_GetVBType(pVBInfo
);
6748 InitTo330Pointer(HwDeviceExtension
->jChipType
, pVBInfo
);
6750 ModeNo
= ModeNo
& 0x7F;
6751 xgifb_reg_set(pVBInfo
->P3c4
, 0x05, 0x86);
6753 if (HwDeviceExtension
->jChipType
< XG20
) /* kuku 2004/06/25 1.Openkey */
6754 XGI_UnLockCRT2(HwDeviceExtension
, pVBInfo
);
6756 XGI_SearchModeID(ModeNo
, &ModeIdIndex
, pVBInfo
);
6758 if (HwDeviceExtension
->jChipType
< XG20
) { /* kuku 2004/06/25 */
6759 XGI_GetVBInfo(ModeNo
, ModeIdIndex
, HwDeviceExtension
, pVBInfo
);
6760 XGI_GetTVInfo(ModeNo
, ModeIdIndex
, pVBInfo
);
6761 XGI_GetLCDInfo(ModeNo
, ModeIdIndex
, pVBInfo
);
6762 XGI_DisableBridge(xgifb_info
, HwDeviceExtension
, pVBInfo
);
6764 if (pVBInfo
->VBInfo
& (SetSimuScanMode
| XGI_SetCRT2ToLCDA
)) {
6765 XGI_SetCRT1Group(xgifb_info
, HwDeviceExtension
, ModeNo
,
6766 ModeIdIndex
, pVBInfo
);
6768 if (pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
) {
6769 XGI_SetLCDAGroup(ModeNo
, ModeIdIndex
,
6770 HwDeviceExtension
, pVBInfo
);
6773 if (!(pVBInfo
->VBInfo
& SwitchCRT2
)) {
6774 XGI_SetCRT1Group(xgifb_info
,
6775 HwDeviceExtension
, ModeNo
,
6776 ModeIdIndex
, pVBInfo
);
6777 if (pVBInfo
->VBInfo
& XGI_SetCRT2ToLCDA
) {
6778 XGI_SetLCDAGroup(ModeNo
, ModeIdIndex
,
6785 if (pVBInfo
->VBInfo
& (SetSimuScanMode
| SwitchCRT2
)) {
6786 switch (HwDeviceExtension
->ujVBChipID
) {
6788 XGI_SetCRT2Group301(ModeNo
, HwDeviceExtension
,
6789 pVBInfo
); /*add for CRT2 */
6793 XGI_SetCRT2Group301(ModeNo
, HwDeviceExtension
,
6794 pVBInfo
); /*add for CRT2 */
6802 XGI_SetCRT2ModeRegs(ModeNo
, HwDeviceExtension
, pVBInfo
);
6803 XGI_OEM310Setting(ModeNo
, ModeIdIndex
, pVBInfo
); /*0212*/
6804 XGI_EnableBridge(xgifb_info
, HwDeviceExtension
, pVBInfo
);
6807 if (pVBInfo
->IF_DEF_LVDS
== 1)
6808 if (!XGI_XG21CheckLVDSMode(xgifb_info
, ModeNo
,
6813 pVBInfo
->ModeType
= pVBInfo
->EModeIDTable
[ModeIdIndex
].
6814 Ext_ModeFlag
& ModeTypeMask
;
6816 pVBInfo
->SetFlag
= 0;
6817 pVBInfo
->VBInfo
= DisableCRT2Display
;
6819 XGI_DisplayOff(xgifb_info
, HwDeviceExtension
, pVBInfo
);
6821 XGI_SetCRT1Group(xgifb_info
, HwDeviceExtension
, ModeNo
,
6822 ModeIdIndex
, pVBInfo
);
6824 XGI_DisplayOn(xgifb_info
, HwDeviceExtension
, pVBInfo
);
6827 XGI_UpdateModeInfo(HwDeviceExtension
, pVBInfo
);
6829 if (HwDeviceExtension
->jChipType
< XG20
) { /* kuku 2004/06/25 */
6830 XGI_LockCRT2(HwDeviceExtension
, pVBInfo
);