3 #include <linux/delay.h>
4 #include <linux/types.h>
10 #include "vb_struct.h"
14 #include "vb_setmode.h"
17 #define IndexMask 0xff
19 static const unsigned short XGINew_MDA_DAC
[] = {
20 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
22 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
23 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
24 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
26 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
27 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F};
29 static const unsigned short XGINew_CGA_DAC
[] = {
30 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
31 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
32 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
33 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
34 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
35 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
36 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
37 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F};
39 static const unsigned short XGINew_EGA_DAC
[] = {
40 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x05, 0x15,
41 0x20, 0x30, 0x24, 0x34, 0x21, 0x31, 0x25, 0x35,
42 0x08, 0x18, 0x0C, 0x1C, 0x09, 0x19, 0x0D, 0x1D,
43 0x28, 0x38, 0x2C, 0x3C, 0x29, 0x39, 0x2D, 0x3D,
44 0x02, 0x12, 0x06, 0x16, 0x03, 0x13, 0x07, 0x17,
45 0x22, 0x32, 0x26, 0x36, 0x23, 0x33, 0x27, 0x37,
46 0x0A, 0x1A, 0x0E, 0x1E, 0x0B, 0x1B, 0x0F, 0x1F,
47 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F};
49 static const unsigned short XGINew_VGA_DAC
[] = {
50 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
51 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
52 0x00, 0x05, 0x08, 0x0B, 0x0E, 0x11, 0x14, 0x18,
53 0x1C, 0x20, 0x24, 0x28, 0x2D, 0x32, 0x38, 0x3F,
54 0x00, 0x10, 0x1F, 0x2F, 0x3F, 0x1F, 0x27, 0x2F,
55 0x37, 0x3F, 0x2D, 0x31, 0x36, 0x3A, 0x3F, 0x00,
56 0x07, 0x0E, 0x15, 0x1C, 0x0E, 0x11, 0x15, 0x18,
57 0x1C, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x00, 0x04,
58 0x08, 0x0C, 0x10, 0x08, 0x0A, 0x0C, 0x0E, 0x10,
59 0x0B, 0x0C, 0x0D, 0x0F, 0x10};
61 void InitTo330Pointer(unsigned char ChipType
, struct vb_device_info
*pVBInfo
)
63 pVBInfo
->SModeIDTable
= (struct XGI_StStruct
*) XGI330_SModeIDTable
;
64 pVBInfo
->StandTable
= (struct XGI_StandTableStruct
*) XGI330_StandTable
;
65 pVBInfo
->EModeIDTable
= (struct XGI_ExtStruct
*) XGI330_EModeIDTable
;
66 pVBInfo
->RefIndex
= (struct XGI_Ext2Struct
*) XGI330_RefIndex
;
67 pVBInfo
->XGINEWUB_CRT1Table
68 = (struct XGI_CRT1TableStruct
*) XGI_CRT1Table
;
70 pVBInfo
->MCLKData
= (struct XGI_MCLKDataStruct
*) XGI340New_MCLKData
;
71 pVBInfo
->ECLKData
= (struct XGI_ECLKDataStruct
*) XGI340_ECLKData
;
72 pVBInfo
->VCLKData
= (struct XGI_VCLKDataStruct
*) XGI_VCLKData
;
73 pVBInfo
->VBVCLKData
= (struct XGI_VBVCLKDataStruct
*) XGI_VBVCLKData
;
74 pVBInfo
->ScreenOffset
= XGI330_ScreenOffset
;
75 pVBInfo
->StResInfo
= (struct XGI_StResInfoStruct
*) XGI330_StResInfo
;
77 = (struct XGI_ModeResInfoStruct
*) XGI330_ModeResInfo
;
79 pVBInfo
->pOutputSelect
= &XGI330_OutputSelect
;
80 pVBInfo
->pSoftSetting
= &XGI330_SoftSetting
;
81 pVBInfo
->pSR07
= &XGI330_SR07
;
82 pVBInfo
->LCDResInfo
= 0;
83 pVBInfo
->LCDTypeInfo
= 0;
88 pVBInfo
->SR15
= XGI340_SR13
;
89 pVBInfo
->CR40
= XGI340_cr41
;
90 pVBInfo
->SR25
= XGI330_sr25
;
91 pVBInfo
->pSR31
= &XGI330_sr31
;
92 pVBInfo
->pSR32
= &XGI330_sr32
;
93 pVBInfo
->CR6B
= XGI340_CR6B
;
94 pVBInfo
->CR6E
= XGI340_CR6E
;
95 pVBInfo
->CR6F
= XGI340_CR6F
;
96 pVBInfo
->CR89
= XGI340_CR89
;
97 pVBInfo
->AGPReg
= XGI340_AGPReg
;
98 pVBInfo
->SR16
= XGI340_SR16
;
99 pVBInfo
->pCRCF
= &XG40_CRCF
;
100 pVBInfo
->pXGINew_DRAMTypeDefinition
= &XG40_DRAMTypeDefinition
;
102 pVBInfo
->CR49
= XGI330_CR49
;
103 pVBInfo
->pSR1F
= &XGI330_SR1F
;
104 pVBInfo
->pSR21
= &XGI330_SR21
;
105 pVBInfo
->pSR22
= &XGI330_SR22
;
106 pVBInfo
->pSR23
= &XGI330_SR23
;
107 pVBInfo
->pSR24
= &XGI330_SR24
;
108 pVBInfo
->pSR33
= &XGI330_SR33
;
110 pVBInfo
->pCRT2Data_1_2
= &XGI330_CRT2Data_1_2
;
111 pVBInfo
->pCRT2Data_4_D
= &XGI330_CRT2Data_4_D
;
112 pVBInfo
->pCRT2Data_4_E
= &XGI330_CRT2Data_4_E
;
113 pVBInfo
->pCRT2Data_4_10
= &XGI330_CRT2Data_4_10
;
114 pVBInfo
->pRGBSenseData
= &XGI330_RGBSenseData
;
115 pVBInfo
->pVideoSenseData
= &XGI330_VideoSenseData
;
116 pVBInfo
->pYCSenseData
= &XGI330_YCSenseData
;
117 pVBInfo
->pRGBSenseData2
= &XGI330_RGBSenseData2
;
118 pVBInfo
->pVideoSenseData2
= &XGI330_VideoSenseData2
;
119 pVBInfo
->pYCSenseData2
= &XGI330_YCSenseData2
;
121 pVBInfo
->NTSCTiming
= XGI330_NTSCTiming
;
122 pVBInfo
->PALTiming
= XGI330_PALTiming
;
123 pVBInfo
->HiTVExtTiming
= XGI330_HiTVExtTiming
;
124 pVBInfo
->HiTVSt1Timing
= XGI330_HiTVSt1Timing
;
125 pVBInfo
->HiTVSt2Timing
= XGI330_HiTVSt2Timing
;
126 pVBInfo
->HiTVTextTiming
= XGI330_HiTVTextTiming
;
127 pVBInfo
->YPbPr750pTiming
= XGI330_YPbPr750pTiming
;
128 pVBInfo
->YPbPr525pTiming
= XGI330_YPbPr525pTiming
;
129 pVBInfo
->YPbPr525iTiming
= XGI330_YPbPr525iTiming
;
130 pVBInfo
->HiTVGroup3Data
= XGI330_HiTVGroup3Data
;
131 pVBInfo
->HiTVGroup3Simu
= XGI330_HiTVGroup3Simu
;
132 pVBInfo
->HiTVGroup3Text
= XGI330_HiTVGroup3Text
;
133 pVBInfo
->Ren525pGroup3
= XGI330_Ren525pGroup3
;
134 pVBInfo
->Ren750pGroup3
= XGI330_Ren750pGroup3
;
136 pVBInfo
->TimingH
= (struct XGI_TimingHStruct
*) XGI_TimingH
;
137 pVBInfo
->TimingV
= (struct XGI_TimingVStruct
*) XGI_TimingV
;
138 pVBInfo
->UpdateCRT1
= (struct XGI_XG21CRT1Struct
*) XGI_UpdateCRT1Table
;
140 /* 310 customization related */
141 if ((pVBInfo
->VBType
& VB_XGI301LV
) || (pVBInfo
->VBType
& VB_XGI302LV
))
142 pVBInfo
->LCDCapList
= XGI_LCDDLCapList
;
144 pVBInfo
->LCDCapList
= XGI_LCDCapList
;
146 pVBInfo
->XGI_TVDelayList
= XGI301TVDelayList
;
147 pVBInfo
->XGI_TVDelayList2
= XGI301TVDelayList2
;
149 pVBInfo
->pXGINew_I2CDefinition
= &XG40_I2CDefinition
;
151 if (ChipType
>= XG20
)
152 pVBInfo
->pXGINew_CR97
= &XG20_CR97
;
154 if (ChipType
== XG27
) {
156 = (struct XGI_MCLKDataStruct
*) XGI27New_MCLKData
;
157 pVBInfo
->CR40
= XGI27_cr41
;
158 pVBInfo
->pXGINew_CR97
= &XG27_CR97
;
159 pVBInfo
->pSR36
= &XG27_SR36
;
160 pVBInfo
->pCR8F
= &XG27_CR8F
;
161 pVBInfo
->pCRD0
= XG27_CRD0
;
162 pVBInfo
->pCRDE
= XG27_CRDE
;
163 pVBInfo
->pSR40
= &XG27_SR40
;
164 pVBInfo
->pSR41
= &XG27_SR41
;
168 if (ChipType
>= XG20
) {
169 pVBInfo
->pDVOSetting
= &XG21_DVOSetting
;
170 pVBInfo
->pCR2E
= &XG21_CR2E
;
171 pVBInfo
->pCR2F
= &XG21_CR2F
;
172 pVBInfo
->pCR46
= &XG21_CR46
;
173 pVBInfo
->pCR47
= &XG21_CR47
;
178 static unsigned char XGI_GetModePtr(unsigned short ModeNo
,
179 unsigned short ModeIdIndex
,
180 struct vb_device_info
*pVBInfo
)
185 index
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_StTableIndex
;
187 if (pVBInfo
->ModeType
<= 0x02)
188 index
= 0x1B; /* 02 -> ModeEGA */
192 return index
; /* Get pVBInfo->StandTable index */
195 static void XGI_SetSeqRegs(unsigned short ModeNo
,
196 unsigned short StandTableIndex
,
197 unsigned short ModeIdIndex
,
198 struct vb_device_info
*pVBInfo
)
200 unsigned char tempah
, SRdata
;
201 unsigned short i
, modeflag
;
204 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
206 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
208 xgifb_reg_set(pVBInfo
->P3c4
, 0x00, 0x03); /* Set SR0 */
209 tempah
= pVBInfo
->StandTable
[StandTableIndex
].SR
[0];
212 if (pVBInfo
->VBInfo
& SetCRT2ToLCDA
) {
215 if (pVBInfo
->VBInfo
& (SetCRT2ToTV
| SetCRT2ToLCD
)) {
216 if (pVBInfo
->VBInfo
& SetInSlaveMode
)
221 tempah
|= 0x20; /* screen off */
222 xgifb_reg_set(pVBInfo
->P3c4
, 0x01, tempah
); /* Set SR1 */
224 for (i
= 02; i
<= 04; i
++) {
225 /* Get SR2,3,4 from file */
226 SRdata
= pVBInfo
->StandTable
[StandTableIndex
].SR
[i
- 1];
227 xgifb_reg_set(pVBInfo
->P3c4
, i
, SRdata
); /* Set SR2 3 4 */
231 static void XGI_SetCRTCRegs(struct xgi_hw_device_info
*HwDeviceExtension
,
232 unsigned short StandTableIndex
,
233 struct vb_device_info
*pVBInfo
)
235 unsigned char CRTCdata
;
238 CRTCdata
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x11);
240 xgifb_reg_set(pVBInfo
->P3d4
, 0x11, CRTCdata
); /* Unlock CRTC */
242 for (i
= 0; i
<= 0x18; i
++) {
243 /* Get CRTC from file */
244 CRTCdata
= pVBInfo
->StandTable
[StandTableIndex
].CRTC
[i
];
245 xgifb_reg_set(pVBInfo
->P3d4
, i
, CRTCdata
); /* Set CRTC(3d4) */
249 static void XGI_SetATTRegs(unsigned short ModeNo
,
250 unsigned short StandTableIndex
,
251 unsigned short ModeIdIndex
,
252 struct vb_device_info
*pVBInfo
)
254 unsigned char ARdata
;
255 unsigned short i
, modeflag
;
258 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
260 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
262 for (i
= 0; i
<= 0x13; i
++) {
263 ARdata
= pVBInfo
->StandTable
[StandTableIndex
].ATTR
[i
];
264 if (modeflag
& Charx8Dot
) { /* ifndef Dot9 */
266 if (pVBInfo
->VBInfo
& SetCRT2ToLCDA
) {
269 if (pVBInfo
->VBInfo
& (SetCRT2ToTV
271 if (pVBInfo
->VBInfo
&
279 inb(pVBInfo
->P3da
); /* reset 3da */
280 outb(i
, pVBInfo
->P3c0
); /* set index */
281 outb(ARdata
, pVBInfo
->P3c0
); /* set data */
284 inb(pVBInfo
->P3da
); /* reset 3da */
285 outb(0x14, pVBInfo
->P3c0
); /* set index */
286 outb(0x00, pVBInfo
->P3c0
); /* set data */
287 inb(pVBInfo
->P3da
); /* Enable Attribute */
288 outb(0x20, pVBInfo
->P3c0
);
291 static void XGI_SetGRCRegs(unsigned short StandTableIndex
,
292 struct vb_device_info
*pVBInfo
)
294 unsigned char GRdata
;
297 for (i
= 0; i
<= 0x08; i
++) {
298 /* Get GR from file */
299 GRdata
= pVBInfo
->StandTable
[StandTableIndex
].GRC
[i
];
300 xgifb_reg_set(pVBInfo
->P3ce
, i
, GRdata
); /* Set GR(3ce) */
303 if (pVBInfo
->ModeType
> ModeVGA
) {
304 GRdata
= (unsigned char) xgifb_reg_get(pVBInfo
->P3ce
, 0x05);
305 GRdata
&= 0xBF; /* 256 color disable */
306 xgifb_reg_set(pVBInfo
->P3ce
, 0x05, GRdata
);
310 static void XGI_ClearExt1Regs(struct vb_device_info
*pVBInfo
)
314 for (i
= 0x0A; i
<= 0x0E; i
++)
315 xgifb_reg_set(pVBInfo
->P3c4
, i
, 0x00); /* Clear SR0A-SR0E */
318 static unsigned char XGI_SetDefaultVCLK(struct vb_device_info
*pVBInfo
)
321 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x31, ~0x30, 0x20);
322 xgifb_reg_set(pVBInfo
->P3c4
, 0x2B, pVBInfo
->VCLKData
[0].SR2B
);
323 xgifb_reg_set(pVBInfo
->P3c4
, 0x2C, pVBInfo
->VCLKData
[0].SR2C
);
325 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x31, ~0x30, 0x10);
326 xgifb_reg_set(pVBInfo
->P3c4
, 0x2B, pVBInfo
->VCLKData
[1].SR2B
);
327 xgifb_reg_set(pVBInfo
->P3c4
, 0x2C, pVBInfo
->VCLKData
[1].SR2C
);
329 xgifb_reg_and(pVBInfo
->P3c4
, 0x31, ~0x30);
333 static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo
,
334 unsigned short ModeIdIndex
,
335 unsigned short RefreshRateTableIndex
, unsigned short *i
,
336 struct vb_device_info
*pVBInfo
)
338 unsigned short tempax
, tempbx
, resinfo
, modeflag
, infoflag
;
342 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
344 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
346 resinfo
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
347 tempbx
= pVBInfo
->RefIndex
[RefreshRateTableIndex
+ (*i
)].ModeID
;
350 if (pVBInfo
->IF_DEF_LVDS
== 0) {
351 if (pVBInfo
->VBInfo
& SetCRT2ToRAMDAC
) {
352 tempax
|= SupportRAMDAC2
;
354 if (pVBInfo
->VBType
& VB_XGI301C
)
355 tempax
|= SupportCRT2in301C
;
359 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToLCDA
)) {
360 tempax
|= SupportLCD
;
362 if (pVBInfo
->LCDResInfo
!= Panel1280x1024
) {
363 if (pVBInfo
->LCDResInfo
!= Panel1280x960
) {
364 if (pVBInfo
->LCDInfo
&
375 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
) { /* for HiTV */
376 if ((pVBInfo
->VBType
& VB_XGI301LV
) &&
377 (pVBInfo
->VBExtInfo
== VB_YPbPr1080i
)) {
378 tempax
|= SupportYPbPr
;
379 if (pVBInfo
->VBInfo
& SetInSlaveMode
) {
390 tempax
|= SupportHiVisionTV
;
391 if (pVBInfo
->VBInfo
& SetInSlaveMode
) {
406 if (pVBInfo
->VBInfo
& (SetCRT2ToAVIDEO
|
410 SetCRT2ToHiVisionTV
)) {
413 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
414 | VB_XGI301LV
| VB_XGI302LV
416 tempax
|= SupportTV1024
;
419 if (!(pVBInfo
->VBInfo
& SetPALTV
)) {
420 if (modeflag
& NoSupportSimuTV
) {
421 if (pVBInfo
->VBInfo
&
423 if (!(pVBInfo
->VBInfo
&
432 } else { /* for LVDS */
433 if (pVBInfo
->VBInfo
& SetCRT2ToLCD
) {
434 tempax
|= SupportLCD
;
437 return 0; /* 1024x768 */
439 if (pVBInfo
->LCDResInfo
< Panel1024x768
) {
441 return 0; /* 800x600 */
444 return 0; /* 512x384 */
449 for (; pVBInfo
->RefIndex
[RefreshRateTableIndex
+ (*i
)].ModeID
==
451 infoflag
= pVBInfo
->RefIndex
[RefreshRateTableIndex
+ (*i
)].
453 if (infoflag
& tempax
)
460 for ((*i
) = 0;; (*i
)++) {
461 infoflag
= pVBInfo
->RefIndex
[RefreshRateTableIndex
+ (*i
)].
463 if (pVBInfo
->RefIndex
[RefreshRateTableIndex
+ (*i
)].ModeID
468 if (infoflag
& tempax
)
474 static void XGI_SetSync(unsigned short RefreshRateTableIndex
,
475 struct vb_device_info
*pVBInfo
)
477 unsigned short sync
, temp
;
480 sync
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_InfoFlag
>> 8;
484 outb(temp
, pVBInfo
->P3c2
); /* Set Misc(3c2) */
487 static void XGI_SetCRT1Timing_H(struct vb_device_info
*pVBInfo
,
488 struct xgi_hw_device_info
*HwDeviceExtension
)
490 unsigned char data
, data1
, pushax
;
494 data
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x11);
496 xgifb_reg_set(pVBInfo
->P3d4
, 0x11, data
);
498 data
= pVBInfo
->TimingH
[0].data
[0];
499 xgifb_reg_set(pVBInfo
->P3d4
, 0, data
);
501 for (i
= 0x01; i
<= 0x04; i
++) {
502 data
= pVBInfo
->TimingH
[0].data
[i
];
503 xgifb_reg_set(pVBInfo
->P3d4
, (unsigned short) (i
+ 1), data
);
506 for (i
= 0x05; i
<= 0x06; i
++) {
507 data
= pVBInfo
->TimingH
[0].data
[i
];
508 xgifb_reg_set(pVBInfo
->P3c4
, (unsigned short) (i
+ 6), data
);
511 j
= (unsigned char) xgifb_reg_get(pVBInfo
->P3c4
, 0x0e);
513 data
= pVBInfo
->TimingH
[0].data
[7];
516 xgifb_reg_set(pVBInfo
->P3c4
, 0x0e, data
);
518 if (HwDeviceExtension
->jChipType
>= XG20
) {
519 data
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x04);
521 xgifb_reg_set(pVBInfo
->P3d4
, 0x04, data
);
522 data
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x05);
528 data
= (unsigned char) xgifb_reg_get(pVBInfo
->P3c4
,
531 xgifb_reg_set(pVBInfo
->P3c4
, 0x0c, data
);
536 xgifb_reg_set(pVBInfo
->P3d4
, 0x05, data
);
537 data
= (unsigned char) xgifb_reg_get(pVBInfo
->P3c4
, 0x0e);
543 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0e, ~0xE0, data
);
547 static void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex
,
548 unsigned short ModeNo
,
549 struct vb_device_info
*pVBInfo
)
554 for (i
= 0x00; i
<= 0x01; i
++) {
555 data
= pVBInfo
->TimingV
[0].data
[i
];
556 xgifb_reg_set(pVBInfo
->P3d4
, (unsigned short) (i
+ 6), data
);
559 for (i
= 0x02; i
<= 0x03; i
++) {
560 data
= pVBInfo
->TimingV
[0].data
[i
];
561 xgifb_reg_set(pVBInfo
->P3d4
, (unsigned short) (i
+ 0x0e), data
);
564 for (i
= 0x04; i
<= 0x05; i
++) {
565 data
= pVBInfo
->TimingV
[0].data
[i
];
566 xgifb_reg_set(pVBInfo
->P3d4
, (unsigned short) (i
+ 0x11), data
);
569 j
= (unsigned char) xgifb_reg_get(pVBInfo
->P3c4
, 0x0a);
571 data
= pVBInfo
->TimingV
[0].data
[6];
574 xgifb_reg_set(pVBInfo
->P3c4
, 0x0a, data
);
576 data
= pVBInfo
->TimingV
[0].data
[6];
581 i
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
583 i
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
589 j
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x09);
592 xgifb_reg_set(pVBInfo
->P3d4
, 0x09, data
);
595 static void XGI_SetCRT1CRTC(unsigned short ModeNo
, unsigned short ModeIdIndex
,
596 unsigned short RefreshRateTableIndex
,
597 struct vb_device_info
*pVBInfo
,
598 struct xgi_hw_device_info
*HwDeviceExtension
)
600 unsigned char index
, data
;
604 index
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRT1CRTC
;
605 index
= index
& IndexMask
;
607 data
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x11);
609 xgifb_reg_set(pVBInfo
->P3d4
, 0x11, data
); /* Unlock CRTC */
611 for (i
= 0; i
< 8; i
++)
612 pVBInfo
->TimingH
[0].data
[i
]
613 = pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[i
];
615 for (i
= 0; i
< 7; i
++)
616 pVBInfo
->TimingV
[0].data
[i
]
617 = pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[i
+ 8];
619 XGI_SetCRT1Timing_H(pVBInfo
, HwDeviceExtension
);
621 XGI_SetCRT1Timing_V(ModeIdIndex
, ModeNo
, pVBInfo
);
623 if (pVBInfo
->ModeType
> 0x03)
624 xgifb_reg_set(pVBInfo
->P3d4
, 0x14, 0x4F);
627 /* --------------------------------------------------------------------- */
628 /* Function : XGI_SetXG21CRTC */
629 /* Input : Stand or enhance CRTC table */
630 /* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */
631 /* Description : Set LCD timing */
632 /* --------------------------------------------------------------------- */
633 static void XGI_SetXG21CRTC(unsigned short ModeNo
, unsigned short ModeIdIndex
,
634 unsigned short RefreshRateTableIndex
,
635 struct vb_device_info
*pVBInfo
)
637 unsigned char StandTableIndex
, index
, Tempax
, Tempbx
, Tempcx
, Tempdx
;
638 unsigned short Temp1
, Temp2
, Temp3
;
640 if (ModeNo
<= 0x13) {
641 StandTableIndex
= XGI_GetModePtr(ModeNo
, ModeIdIndex
, pVBInfo
);
643 Tempax
= pVBInfo
->StandTable
[StandTableIndex
].CRTC
[4];
644 /* SR2E [7:0]->HRS */
645 xgifb_reg_set(pVBInfo
->P3c4
, 0x2E, Tempax
);
646 /* Tempbx: CR05 HRE */
647 Tempbx
= pVBInfo
->StandTable
[StandTableIndex
].CRTC
[5];
648 Tempbx
&= 0x1F; /* Tempbx: HRE[4:0] */
650 Tempcx
&= 0xE0; /* Tempcx: HRS[7:5] */
651 Tempdx
= Tempcx
| Tempbx
; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
652 if (Tempbx
< (Tempax
& 0x1F)) /* IF HRE < HRS */
653 Tempdx
|= 0x20; /* Tempdx: HRE = HRE + 0x20 */
654 Tempdx
<<= 2; /* Tempdx << 2 */
655 /* SR2F [7:2]->HRE */
656 xgifb_reg_set(pVBInfo
->P3c4
, 0x2F, Tempdx
);
657 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x30, 0xE3, 00);
659 /* Tempax: CR16 VRS */
660 Tempax
= pVBInfo
->StandTable
[StandTableIndex
].CRTC
[16];
661 Tempbx
= Tempax
; /* Tempbx=Tempax */
662 Tempax
&= 0x01; /* Tempax: VRS[0] */
663 xgifb_reg_or(pVBInfo
->P3c4
, 0x33, Tempax
); /* SR33[0]->VRS */
665 /* Tempax: CR7 VRS */
666 Tempax
= pVBInfo
->StandTable
[StandTableIndex
].CRTC
[7];
667 Tempdx
= Tempbx
>> 1; /* Tempdx: VRS[7:1] */
668 Tempcx
= Tempax
& 0x04; /* Tempcx: CR7[2] */
669 Tempcx
<<= 5; /* Tempcx[7]: VRS[8] */
670 Tempdx
|= Tempcx
; /* Tempdx: VRS[8:1] */
671 /* SR34[7:0]: VRS[8:1] */
672 xgifb_reg_set(pVBInfo
->P3c4
, 0x34, Tempdx
);
674 /* Temp1[8]: VRS[8] unsigned char -> unsigned short */
676 Temp1
|= Tempbx
; /* Temp1[8:0]: VRS[8:0] */
677 Tempax
&= 0x80; /* Tempax[7]: CR7[7] */
678 Temp2
= Tempax
<< 2; /* Temp2[9]: VRS[9] */
679 Temp1
|= Temp2
; /* Temp1[9:0]: VRS[9:0] */
682 Tempax
= pVBInfo
->StandTable
[StandTableIndex
].CRTC
[17];
683 Tempax
&= 0x0F; /* Tempax[3:0]: VRE[3:0] */
684 Temp2
= Temp1
& 0x3F0; /* Temp2[9:4]: VRS[9:4] */
685 Temp2
|= Tempax
; /* Temp2[9:0]: VRE[9:0] */
686 Temp3
= Temp1
& 0x0F; /* Temp3[3:0]: VRS[3:0] */
687 if (Tempax
< Temp3
) /* VRE[3:0]<VRS[3:0] */
688 Temp2
|= 0x10; /* Temp2: VRE + 0x10 */
689 Temp2
&= 0xFF; /* Temp2[7:0]: VRE[7:0] */
690 Tempax
= (unsigned char) Temp2
; /* Tempax[7:0]: VRE[7:0] */
691 Tempax
<<= 2; /* Tempax << 2: VRE[5:0] */
692 Temp1
&= 0x600; /* Temp1[10:9]: VRS[10:9] */
693 Temp1
>>= 9; /* [10:9]->[1:0] */
694 Tempbx
= (unsigned char) Temp1
; /* Tempbx[1:0]: VRS[10:9] */
695 Tempax
|= Tempbx
; /* VRE[5:0]VRS[10:9] */
697 /* SR3F D[7:2]->VRE D[1:0]->VRS */
698 xgifb_reg_set(pVBInfo
->P3c4
, 0x3F, Tempax
);
700 index
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRT1CRTC
;
701 /* Tempax: CR4 HRS */
702 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[3];
703 Tempcx
= Tempax
; /* Tempcx: HRS */
705 xgifb_reg_set(pVBInfo
->P3c4
, 0x2E, Tempax
);
707 Tempdx
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[5]; /* SRB */
708 Tempdx
&= 0xC0; /* Tempdx[7:6]: SRB[7:6] */
709 Temp1
= Tempdx
; /* Temp1[7:6]: HRS[9:8] */
710 Temp1
<<= 2; /* Temp1[9:8]: HRS[9:8] */
711 Temp1
|= Tempax
; /* Temp1[9:0]: HRS[9:0] */
713 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[4]; /* CR5 HRE */
714 Tempax
&= 0x1F; /* Tempax[4:0]: HRE[4:0] */
716 Tempbx
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[6]; /* SRC */
717 Tempbx
&= 0x04; /* Tempbx[2]: HRE[5] */
718 Tempbx
<<= 3; /* Tempbx[5]: HRE[5] */
719 Tempax
|= Tempbx
; /* Tempax[5:0]: HRE[5:0] */
721 Temp2
= Temp1
& 0x3C0; /* Temp2[9:6]: HRS[9:6] */
722 Temp2
|= Tempax
; /* Temp2[9:0]: HRE[9:0] */
724 Tempcx
&= 0x3F; /* Tempcx[5:0]: HRS[5:0] */
725 if (Tempax
< Tempcx
) /* HRE < HRS */
726 Temp2
|= 0x40; /* Temp2 + 0x40 */
729 Tempax
= (unsigned char) Temp2
; /* Tempax: HRE[7:0] */
730 Tempax
<<= 2; /* Tempax[7:2]: HRE[5:0] */
731 Tempdx
>>= 6; /* Tempdx[7:6]->[1:0] HRS[9:8] */
732 Tempax
|= Tempdx
; /* HRE[5:0]HRS[9:8] */
733 /* SR2F D[7:2]->HRE, D[1:0]->HRS */
734 xgifb_reg_set(pVBInfo
->P3c4
, 0x2F, Tempax
);
735 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x30, 0xE3, 00);
738 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[10];
739 Tempbx
= Tempax
; /* Tempbx: VRS */
740 Tempax
&= 0x01; /* Tempax[0]: VRS[0] */
741 xgifb_reg_or(pVBInfo
->P3c4
, 0x33, Tempax
); /* SR33[0]->VRS[0] */
743 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[9];
744 Tempcx
= Tempbx
>> 1; /* Tempcx[6:0]: VRS[7:1] */
745 Tempdx
= Tempax
& 0x04; /* Tempdx[2]: CR7[2] */
746 Tempdx
<<= 5; /* Tempdx[7]: VRS[8] */
747 Tempcx
|= Tempdx
; /* Tempcx[7:0]: VRS[8:1] */
748 xgifb_reg_set(pVBInfo
->P3c4
, 0x34, Tempcx
); /* SR34[8:1]->VRS */
750 Temp1
= Tempdx
; /* Temp1[7]: Tempdx[7] */
751 Temp1
<<= 1; /* Temp1[8]: VRS[8] */
752 Temp1
|= Tempbx
; /* Temp1[8:0]: VRS[8:0] */
754 Temp2
= Tempax
<< 2; /* Temp2[9]: VRS[9] */
755 Temp1
|= Temp2
; /* Temp1[9:0]: VRS[9:0] */
757 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[14];
758 Tempax
&= 0x08; /* Tempax[3]: VRS[3] */
760 Temp2
<<= 7; /* Temp2[10]: VRS[10] */
761 Temp1
|= Temp2
; /* Temp1[10:0]: VRS[10:0] */
763 /* Tempax: CR11 VRE */
764 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[11];
765 Tempax
&= 0x0F; /* Tempax[3:0]: VRE[3:0] */
767 Tempbx
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[14];
768 Tempbx
&= 0x20; /* Tempbx[5]: VRE[5] */
769 Tempbx
>>= 1; /* Tempbx[4]: VRE[4] */
770 Tempax
|= Tempbx
; /* Tempax[4:0]: VRE[4:0] */
771 Temp2
= Temp1
& 0x7E0; /* Temp2[10:5]: VRS[10:5] */
772 Temp2
|= Tempax
; /* Temp2[10:5]: VRE[10:5] */
774 Temp3
= Temp1
& 0x1F; /* Temp3[4:0]: VRS[4:0] */
775 if (Tempax
< Temp3
) /* VRE < VRS */
776 Temp2
|= 0x20; /* VRE + 0x20 */
779 Tempax
= (unsigned char) Temp2
; /* Tempax: VRE[7:0] */
780 Tempax
<<= 2; /* Tempax[7:0]; VRE[5:0]00 */
781 Temp1
&= 0x600; /* Temp1[10:9]: VRS[10:9] */
782 Temp1
>>= 9; /* Temp1[1:0]: VRS[10:9] */
783 Tempbx
= (unsigned char) Temp1
;
784 Tempax
|= Tempbx
; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */
786 /* SR3F D[7:2]->VRE D[1:0]->VRS */
787 xgifb_reg_set(pVBInfo
->P3c4
, 0x3F, Tempax
);
791 static void XGI_SetXG27CRTC(unsigned short ModeNo
,
792 unsigned short ModeIdIndex
,
793 unsigned short RefreshRateTableIndex
,
794 struct vb_device_info
*pVBInfo
)
796 unsigned short StandTableIndex
, index
, Tempax
, Tempbx
, Tempcx
, Tempdx
;
798 if (ModeNo
<= 0x13) {
799 StandTableIndex
= XGI_GetModePtr(ModeNo
, ModeIdIndex
, pVBInfo
);
801 Tempax
= pVBInfo
->StandTable
[StandTableIndex
].CRTC
[4];
802 /* SR2E [7:0]->HRS */
803 xgifb_reg_set(pVBInfo
->P3c4
, 0x2E, Tempax
);
804 /* Tempbx: CR05 HRE */
805 Tempbx
= pVBInfo
->StandTable
[StandTableIndex
].CRTC
[5];
806 Tempbx
&= 0x1F; /* Tempbx: HRE[4:0] */
808 Tempcx
&= 0xE0; /* Tempcx: HRS[7:5] */
809 Tempdx
= Tempcx
| Tempbx
; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
810 if (Tempbx
< (Tempax
& 0x1F)) /* IF HRE < HRS */
811 Tempdx
|= 0x20; /* Tempdx: HRE = HRE + 0x20 */
812 Tempdx
<<= 2; /* Tempdx << 2 */
813 /* SR2F [7:2]->HRE */
814 xgifb_reg_set(pVBInfo
->P3c4
, 0x2F, Tempdx
);
815 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x30, 0xE3, 00);
817 /* Tempax: CR10 VRS */
818 Tempax
= pVBInfo
->StandTable
[StandTableIndex
].CRTC
[16];
819 xgifb_reg_set(pVBInfo
->P3c4
, 0x34, Tempax
); /* SR34[7:0]->VRS */
820 Tempcx
= Tempax
; /* Tempcx=Tempax=VRS[7:0] */
821 /* Tempax[7][2]: CR7[7][2] VRS[9][8] */
822 Tempax
= pVBInfo
->StandTable
[StandTableIndex
].CRTC
[7];
823 Tempbx
= Tempax
; /* Tempbx=CR07 */
824 Tempax
&= 0x04; /* Tempax[2]: CR07[2] VRS[8] */
826 /* SR35 D[0]->VRS D[8] */
827 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x35, ~0x01, Tempax
);
828 Tempcx
|= (Tempax
<< 8); /* Tempcx[8] |= VRS[8] */
829 Tempcx
|= (Tempbx
& 0x80) << 2; /* Tempcx[9] |= VRS[9] */
832 Tempax
= pVBInfo
->StandTable
[StandTableIndex
].CRTC
[17];
833 Tempax
&= 0x0F; /* Tempax: VRE[3:0] */
834 Tempbx
= Tempcx
; /* Tempbx=Tempcx=VRS[9:0] */
835 Tempbx
&= 0x3F0; /* Tempbx[9:4]: VRS[9:4] */
836 Tempbx
|= Tempax
; /* Tempbx[9:0]: VRE[9:0] */
837 if (Tempax
<= (Tempcx
& 0x0F)) /* VRE[3:0]<=VRS[3:0] */
838 Tempbx
|= 0x10; /* Tempbx: VRE + 0x10 */
839 /* Tempax[7:0]: VRE[7:0] */
840 Tempax
= (unsigned char) Tempbx
& 0xFF;
841 Tempax
<<= 2; /* Tempax << 2: VRE[5:0] */
842 Tempcx
= (Tempcx
& 0x600) >> 8; /* Tempcx VRS[10:9] */
843 /* SR3F D[7:2]->VRE D[5:0] */
844 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x3F, ~0xFC, Tempax
);
845 /* SR35 D[2:1]->VRS[10:9] */
846 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x35, ~0x06, Tempcx
);
848 index
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRT1CRTC
;
849 /* Tempax: CR4 HRS */
850 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[3];
851 Tempbx
= Tempax
; /* Tempbx: HRS[7:0] */
853 xgifb_reg_set(pVBInfo
->P3c4
, 0x2E, Tempax
);
856 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[5];
857 Tempax
&= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
858 Tempbx
|= (Tempax
<< 2); /* Tempbx: HRS[9:0] */
860 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[4]; /* CR5 HRE */
861 Tempax
&= 0x1F; /* Tempax[4:0]: HRE[4:0] */
862 Tempcx
= Tempax
; /* Tempcx: HRE[4:0] */
864 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[6]; /* SRC */
865 Tempax
&= 0x04; /* Tempax[2]: HRE[5] */
866 Tempax
<<= 3; /* Tempax[5]: HRE[5] */
867 Tempcx
|= Tempax
; /* Tempcx[5:0]: HRE[5:0] */
869 Tempbx
= Tempbx
& 0x3C0; /* Tempbx[9:6]: HRS[9:6] */
870 Tempbx
|= Tempcx
; /* Tempbx: HRS[9:6]HRE[5:0] */
872 /* Tempax: CR4 HRS */
873 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[3];
874 Tempax
&= 0x3F; /* Tempax: HRS[5:0] */
875 if (Tempcx
<= Tempax
) /* HRE[5:0] < HRS[5:0] */
876 Tempbx
+= 0x40; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/
878 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[5]; /* SR0B */
879 Tempax
&= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
880 Tempax
>>= 6; /* Tempax[1:0]: HRS[9:8]*/
881 Tempax
|= ((Tempbx
<< 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */
882 /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */
883 xgifb_reg_set(pVBInfo
->P3c4
, 0x2F, Tempax
);
884 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x30, 0xE3, 00);
887 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[10];
888 /* SR34[7:0]->VRS[7:0] */
889 xgifb_reg_set(pVBInfo
->P3c4
, 0x34, Tempax
);
891 Tempcx
= Tempax
; /* Tempcx <= VRS[7:0] */
892 /* CR7[7][2] VRS[9][8] */
893 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[9];
894 Tempbx
= Tempax
; /* Tempbx <= CR07[7:0] */
895 Tempax
= Tempax
& 0x04; /* Tempax[2]: CR7[2]: VRS[8] */
896 Tempax
>>= 2; /* Tempax[0]: VRS[8] */
897 /* SR35[0]: VRS[8] */
898 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x35, ~0x01, Tempax
);
899 Tempcx
|= (Tempax
<< 8); /* Tempcx <= VRS[8:0] */
900 Tempcx
|= ((Tempbx
& 0x80) << 2); /* Tempcx <= VRS[9:0] */
902 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[14];
903 Tempax
&= 0x08; /* SR0A[3] VRS[10] */
904 Tempcx
|= (Tempax
<< 7); /* Tempcx <= VRS[10:0] */
906 /* Tempax: CR11 VRE */
907 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[11];
908 Tempax
&= 0x0F; /* Tempax[3:0]: VRE[3:0] */
910 Tempbx
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[14];
911 Tempbx
&= 0x20; /* Tempbx[5]: SR0A[5]: VRE[4] */
912 Tempbx
>>= 1; /* Tempbx[4]: VRE[4] */
913 Tempax
|= Tempbx
; /* Tempax[4:0]: VRE[4:0] */
914 Tempbx
= Tempcx
; /* Tempbx: VRS[10:0] */
915 Tempbx
&= 0x7E0; /* Tempbx[10:5]: VRS[10:5] */
916 Tempbx
|= Tempax
; /* Tempbx: VRS[10:5]VRE[4:0] */
918 if (Tempbx
<= Tempcx
) /* VRE <= VRS */
919 Tempbx
|= 0x20; /* VRE + 0x20 */
921 /* Tempax: Tempax[7:0]; VRE[5:0]00 */
922 Tempax
= (Tempbx
<< 2) & 0xFF;
923 /* SR3F[7:2]:VRE[5:0] */
924 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x3F, ~0xFC, Tempax
);
925 Tempax
= Tempcx
>> 8;
926 /* SR35[2:0]:VRS[10:8] */
927 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x35, ~0x07, Tempax
);
931 static void XGI_SetXG27FPBits(struct vb_device_info
*pVBInfo
)
935 /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */
936 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x37);
937 temp
= (temp
& 3) << 6;
938 /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */
939 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x06, ~0xc0, temp
& 0x80);
940 /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */
941 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x09, ~0xc0, temp
| 0x80);
945 static void xgifb_set_lcd(int chip_id
,
946 struct vb_device_info
*pVBInfo
,
947 unsigned short RefreshRateTableIndex
,
948 unsigned short ModeNo
)
950 unsigned short Data
, Temp
, b3CC
;
951 unsigned short XGI_P3cc
;
953 XGI_P3cc
= pVBInfo
->P3cc
;
955 xgifb_reg_set(pVBInfo
->P3d4
, 0x2E, 0x00);
956 xgifb_reg_set(pVBInfo
->P3d4
, 0x2F, 0x00);
957 xgifb_reg_set(pVBInfo
->P3d4
, 0x46, 0x00);
958 xgifb_reg_set(pVBInfo
->P3d4
, 0x47, 0x00);
960 if (chip_id
== XG27
) {
961 Temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x37);
962 if ((Temp
& 0x03) == 0) { /* dual 12 */
963 xgifb_reg_set(pVBInfo
->P3d4
, 0x46, 0x13);
964 xgifb_reg_set(pVBInfo
->P3d4
, 0x47, 0x13);
968 if (((*pVBInfo
->pDVOSetting
) & 0xC0) == 0xC0) {
969 xgifb_reg_set(pVBInfo
->P3d4
, 0x2E, *pVBInfo
->pCR2E
);
970 xgifb_reg_set(pVBInfo
->P3d4
, 0x2F, *pVBInfo
->pCR2F
);
971 xgifb_reg_set(pVBInfo
->P3d4
, 0x46, *pVBInfo
->pCR46
);
972 xgifb_reg_set(pVBInfo
->P3d4
, 0x47, *pVBInfo
->pCR47
);
975 if (chip_id
== XG27
) {
976 XGI_SetXG27FPBits(pVBInfo
);
978 Temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x37);
981 xgifb_reg_or(pVBInfo
->P3c4
, 0x06, 0x40);
982 xgifb_reg_or(pVBInfo
->P3c4
, 0x09, 0x40);
986 xgifb_reg_or(pVBInfo
->P3c4
, 0x1E, 0x01); /* Negative blank polarity */
988 xgifb_reg_and(pVBInfo
->P3c4
, 0x30, ~0x20); /* Hsync polarity */
989 xgifb_reg_and(pVBInfo
->P3c4
, 0x35, ~0x80); /* Vsync polarity */
991 if (ModeNo
<= 0x13) {
992 b3CC
= (unsigned char) inb(XGI_P3cc
);
995 xgifb_reg_or(pVBInfo
->P3c4
, 0x30, 0x20);
998 xgifb_reg_or(pVBInfo
->P3c4
, 0x35, 0x80);
1000 Data
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_InfoFlag
;
1002 /* Hsync polarity */
1003 xgifb_reg_or(pVBInfo
->P3c4
, 0x30, 0x20);
1005 /* Vsync polarity */
1006 xgifb_reg_or(pVBInfo
->P3c4
, 0x35, 0x80);
1010 /* --------------------------------------------------------------------- */
1011 /* Function : XGI_UpdateXG21CRTC */
1013 /* Output : CRT1 CRTC */
1014 /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */
1015 /* --------------------------------------------------------------------- */
1016 static void XGI_UpdateXG21CRTC(unsigned short ModeNo
,
1017 struct vb_device_info
*pVBInfo
,
1018 unsigned short RefreshRateTableIndex
)
1022 xgifb_reg_and(pVBInfo
->P3d4
, 0x11, 0x7F); /* Unlock CR0~7 */
1023 if (ModeNo
<= 0x13) {
1024 for (i
= 0; i
< 12; i
++) {
1025 if (ModeNo
== pVBInfo
->UpdateCRT1
[i
].ModeID
)
1029 if (ModeNo
== 0x2E &&
1030 (pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRT1CRTC
==
1033 else if (ModeNo
== 0x2E &&
1034 (pVBInfo
->RefIndex
[RefreshRateTableIndex
].
1035 Ext_CRT1CRTC
== RES640x480x72
))
1037 else if (ModeNo
== 0x2F)
1039 else if (ModeNo
== 0x50)
1041 else if (ModeNo
== 0x59)
1046 xgifb_reg_set(pVBInfo
->P3d4
, 0x02,
1047 pVBInfo
->UpdateCRT1
[index
].CR02
);
1048 xgifb_reg_set(pVBInfo
->P3d4
, 0x03,
1049 pVBInfo
->UpdateCRT1
[index
].CR03
);
1050 xgifb_reg_set(pVBInfo
->P3d4
, 0x15,
1051 pVBInfo
->UpdateCRT1
[index
].CR15
);
1052 xgifb_reg_set(pVBInfo
->P3d4
, 0x16,
1053 pVBInfo
->UpdateCRT1
[index
].CR16
);
1057 static unsigned short XGI_GetResInfo(unsigned short ModeNo
,
1058 unsigned short ModeIdIndex
, struct vb_device_info
*pVBInfo
)
1060 unsigned short resindex
;
1064 resindex
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ResInfo
;
1066 /* si+Ext_ResInfo */
1067 resindex
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
1071 static void XGI_SetCRT1DE(struct xgi_hw_device_info
*HwDeviceExtension
,
1072 unsigned short ModeNo
, unsigned short ModeIdIndex
,
1073 unsigned short RefreshRateTableIndex
,
1074 struct vb_device_info
*pVBInfo
)
1076 unsigned short resindex
, tempax
, tempbx
, tempcx
, temp
, modeflag
;
1080 resindex
= XGI_GetResInfo(ModeNo
, ModeIdIndex
, pVBInfo
);
1082 if (ModeNo
<= 0x13) {
1083 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
1084 tempax
= pVBInfo
->StResInfo
[resindex
].HTotal
;
1085 tempbx
= pVBInfo
->StResInfo
[resindex
].VTotal
;
1087 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
1088 tempax
= pVBInfo
->ModeResInfo
[resindex
].HTotal
;
1089 tempbx
= pVBInfo
->ModeResInfo
[resindex
].VTotal
;
1092 if (modeflag
& HalfDCLK
)
1093 tempax
= tempax
>> 1;
1095 if (ModeNo
> 0x13) {
1096 if (modeflag
& HalfDCLK
)
1097 tempax
= tempax
<< 1;
1099 temp
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_InfoFlag
;
1101 if (temp
& InterlaceMode
)
1102 tempbx
= tempbx
>> 1;
1104 if (modeflag
& DoubleScanMode
)
1105 tempbx
= tempbx
<< 1;
1114 temp
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x11);
1115 data
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x11);
1117 xgifb_reg_set(pVBInfo
->P3d4
, 0x11, data
); /* Unlock CRTC */
1118 xgifb_reg_set(pVBInfo
->P3d4
, 0x01, (unsigned short) (tempcx
& 0xff));
1119 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x0b, ~0x0c,
1120 (unsigned short) ((tempcx
& 0x0ff00) >> 10));
1121 xgifb_reg_set(pVBInfo
->P3d4
, 0x12, (unsigned short) (tempbx
& 0xff));
1123 tempbx
= tempbx
>> 8;
1131 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x07, ~0x42, tempax
);
1132 data
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x07);
1139 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x0a, ~0x02, tempax
);
1140 xgifb_reg_set(pVBInfo
->P3d4
, 0x11, temp
);
1143 static void XGI_SetCRT1Offset(unsigned short ModeNo
,
1144 unsigned short ModeIdIndex
,
1145 unsigned short RefreshRateTableIndex
,
1146 struct xgi_hw_device_info
*HwDeviceExtension
,
1147 struct vb_device_info
*pVBInfo
)
1149 unsigned short temp
, ah
, al
, temp2
, i
, DisplayUnit
;
1152 temp
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeInfo
;
1154 temp
= pVBInfo
->ScreenOffset
[temp
];
1156 temp2
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_InfoFlag
;
1157 temp2
&= InterlaceMode
;
1162 temp2
= pVBInfo
->ModeType
- ModeEGA
;
1187 if ((ModeNo
>= 0x26) && (ModeNo
<= 0x28))
1188 temp
= temp
* temp2
+ temp2
/ 2;
1195 temp
= temp
>> 8; /* ah */
1197 i
= xgifb_reg_get(pVBInfo
->P3c4
, 0x0E);
1200 xgifb_reg_set(pVBInfo
->P3c4
, 0x0E, i
);
1202 temp
= (unsigned char) temp2
;
1203 temp
&= 0xFF; /* al */
1204 xgifb_reg_set(pVBInfo
->P3d4
, 0x13, temp
);
1206 /* SetDisplayUnit */
1207 temp2
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_InfoFlag
;
1208 temp2
&= InterlaceMode
;
1212 DisplayUnit
= DisplayUnit
<< 5;
1213 ah
= (DisplayUnit
& 0xff00) >> 8;
1214 al
= DisplayUnit
& 0x00ff;
1220 if (HwDeviceExtension
->jChipType
>= XG20
)
1221 if ((ModeNo
== 0x4A) | (ModeNo
== 0x49))
1224 xgifb_reg_set(pVBInfo
->P3c4
, 0x10, ah
);
1227 static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo
,
1228 unsigned short ModeIdIndex
,
1229 unsigned short RefreshRateTableIndex
,
1230 struct xgi_hw_device_info
*HwDeviceExtension
,
1231 struct vb_device_info
*pVBInfo
)
1233 unsigned short LCDXlat1VCLK
[4] = { VCLK65
+ 2,
1237 unsigned short LCDXlat2VCLK
[4] = { VCLK108_2
+ 5,
1241 unsigned short LVDSXlat1VCLK
[4] = { VCLK40
, VCLK40
, VCLK40
, VCLK40
};
1242 unsigned short LVDSXlat2VCLK
[4] = { VCLK65
+ 2,
1246 unsigned short LVDSXlat3VCLK
[4] = { VCLK65
+ 2,
1251 unsigned short CRT2Index
, VCLKIndex
;
1252 unsigned short modeflag
, resinfo
;
1254 if (ModeNo
<= 0x13) {
1256 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
1257 resinfo
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ResInfo
;
1258 CRT2Index
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_CRT2CRTC
;
1260 /* si+Ext_ResInfo */
1261 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
1262 resinfo
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
1263 CRT2Index
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].
1267 if (pVBInfo
->IF_DEF_LVDS
== 0) {
1268 CRT2Index
= CRT2Index
>> 6; /* for LCD */
1269 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToLCDA
)) { /*301b*/
1270 if (pVBInfo
->LCDResInfo
!= Panel1024x768
)
1271 VCLKIndex
= LCDXlat2VCLK
[CRT2Index
];
1273 VCLKIndex
= LCDXlat1VCLK
[CRT2Index
];
1274 } else if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
) {
1275 if (pVBInfo
->SetFlag
& RPLLDIV2XO
) {
1276 VCLKIndex
= HiTVVCLKDIV2
;
1279 VCLKIndex
= HiTVVCLK
;
1283 if (pVBInfo
->SetFlag
& TVSimuMode
) {
1284 if (modeflag
& Charx8Dot
) {
1285 VCLKIndex
= HiTVSimuVCLK
;
1288 VCLKIndex
= HiTVTextVCLK
;
1294 if ((pVBInfo
->VBType
& VB_XGI301LV
) &&
1295 !(pVBInfo
->VBExtInfo
== VB_YPbPr1080i
)) {
1296 if (pVBInfo
->VBExtInfo
== VB_YPbPr750p
)
1297 VCLKIndex
= YPbPr750pVCLK
;
1298 else if (pVBInfo
->VBExtInfo
== VB_YPbPr525p
)
1299 VCLKIndex
= YPbPr525pVCLK
;
1300 else if (pVBInfo
->SetFlag
& RPLLDIV2XO
)
1301 VCLKIndex
= YPbPr525iVCLK_2
;
1303 VCLKIndex
= YPbPr525iVCLK
;
1305 } else if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
1306 if (pVBInfo
->SetFlag
& RPLLDIV2XO
) {
1307 VCLKIndex
= TVVCLKDIV2
;
1313 } else { /* for CRT2 */
1315 VCLKIndex
= (unsigned char) inb((pVBInfo
->P3ca
+ 0x02));
1316 VCLKIndex
= ((VCLKIndex
>> 2) & 0x03);
1317 if (ModeNo
> 0x13) {
1318 /* di+Ext_CRTVCLK */
1319 VCLKIndex
= pVBInfo
->RefIndex
[
1320 RefreshRateTableIndex
].
1322 VCLKIndex
&= IndexMask
;
1327 VCLKIndex
= CRT2Index
;
1329 VCLKIndex
= CRT2Index
;
1331 VCLKIndex
= VCLKIndex
>> 6;
1332 if ((pVBInfo
->LCDResInfo
== Panel800x600
) ||
1333 (pVBInfo
->LCDResInfo
== Panel320x480
))
1334 VCLKIndex
= LVDSXlat1VCLK
[VCLKIndex
];
1335 else if ((pVBInfo
->LCDResInfo
== Panel1024x768
) ||
1336 (pVBInfo
->LCDResInfo
== Panel1024x768x75
))
1337 VCLKIndex
= LVDSXlat2VCLK
[VCLKIndex
];
1339 VCLKIndex
= LVDSXlat3VCLK
[VCLKIndex
];
1345 static void XGI_SetCRT1VCLK(unsigned short ModeNo
,
1346 unsigned short ModeIdIndex
,
1347 struct xgi_hw_device_info
*HwDeviceExtension
,
1348 unsigned short RefreshRateTableIndex
,
1349 struct vb_device_info
*pVBInfo
)
1351 unsigned char index
, data
;
1352 unsigned short vclkindex
;
1354 if (pVBInfo
->IF_DEF_LVDS
== 1) {
1355 index
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRTVCLK
;
1356 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x31) & 0xCF;
1357 xgifb_reg_set(pVBInfo
->P3c4
, 0x31, data
);
1358 xgifb_reg_set(pVBInfo
->P3c4
, 0x2B,
1359 pVBInfo
->VCLKData
[index
].SR2B
);
1360 xgifb_reg_set(pVBInfo
->P3c4
, 0x2C,
1361 pVBInfo
->VCLKData
[index
].SR2C
);
1362 xgifb_reg_set(pVBInfo
->P3c4
, 0x2D, 0x01);
1363 } else if ((pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
| VB_XGI301LV
1364 | VB_XGI302LV
| VB_XGI301C
)) && (pVBInfo
->VBInfo
1366 vclkindex
= XGI_GetVCLK2Ptr(ModeNo
, ModeIdIndex
,
1367 RefreshRateTableIndex
, HwDeviceExtension
,
1369 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x31) & 0xCF;
1370 xgifb_reg_set(pVBInfo
->P3c4
, 0x31, data
);
1371 data
= pVBInfo
->VBVCLKData
[vclkindex
].Part4_A
;
1372 xgifb_reg_set(pVBInfo
->P3c4
, 0x2B, data
);
1373 data
= pVBInfo
->VBVCLKData
[vclkindex
].Part4_B
;
1374 xgifb_reg_set(pVBInfo
->P3c4
, 0x2C, data
);
1375 xgifb_reg_set(pVBInfo
->P3c4
, 0x2D, 0x01);
1377 index
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRTVCLK
;
1378 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x31) & 0xCF;
1379 xgifb_reg_set(pVBInfo
->P3c4
, 0x31, data
);
1380 xgifb_reg_set(pVBInfo
->P3c4
, 0x2B,
1381 pVBInfo
->VCLKData
[index
].SR2B
);
1382 xgifb_reg_set(pVBInfo
->P3c4
, 0x2C,
1383 pVBInfo
->VCLKData
[index
].SR2C
);
1384 xgifb_reg_set(pVBInfo
->P3c4
, 0x2D, 0x01);
1387 if (HwDeviceExtension
->jChipType
>= XG20
) {
1388 if (pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
&
1390 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x2B);
1391 xgifb_reg_set(pVBInfo
->P3c4
, 0x2B, data
);
1392 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x2C);
1399 xgifb_reg_set(pVBInfo
->P3c4
, 0x2C, data
);
1404 static void XGI_SetXG21FPBits(struct vb_device_info
*pVBInfo
)
1408 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x37); /* D[0] 1: 18bit */
1409 temp
= (temp
& 1) << 6;
1410 /* SR06[6] 18bit Dither */
1411 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x06, ~0x40, temp
);
1412 /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */
1413 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x09, ~0xc0, temp
| 0x80);
1417 static void XGI_SetCRT1FIFO(unsigned short ModeNo
,
1418 struct xgi_hw_device_info
*HwDeviceExtension
,
1419 struct vb_device_info
*pVBInfo
)
1421 unsigned short data
;
1423 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x3D);
1425 xgifb_reg_set(pVBInfo
->P3c4
, 0x3D, data
); /* diable auto-threshold */
1427 if (ModeNo
> 0x13) {
1428 xgifb_reg_set(pVBInfo
->P3c4
, 0x08, 0x34);
1429 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x09);
1431 xgifb_reg_set(pVBInfo
->P3c4
, 0x09, data
| 0x30);
1432 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x3D);
1434 xgifb_reg_set(pVBInfo
->P3c4
, 0x3D, data
);
1436 if (HwDeviceExtension
->jChipType
== XG27
) {
1437 xgifb_reg_set(pVBInfo
->P3c4
, 0x08, 0x0E);
1438 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x09);
1440 xgifb_reg_set(pVBInfo
->P3c4
, 0x09, data
| 0x20);
1442 xgifb_reg_set(pVBInfo
->P3c4
, 0x08, 0xAE);
1443 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x09);
1445 xgifb_reg_set(pVBInfo
->P3c4
, 0x09, data
);
1449 if (HwDeviceExtension
->jChipType
== XG21
)
1450 XGI_SetXG21FPBits(pVBInfo
); /* Fix SR9[7:6] can't read back */
1453 static void XGI_SetVCLKState(struct xgi_hw_device_info
*HwDeviceExtension
,
1454 unsigned short ModeNo
, unsigned short RefreshRateTableIndex
,
1455 struct vb_device_info
*pVBInfo
)
1457 unsigned short data
, data2
= 0;
1460 unsigned char index
;
1465 index
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRTVCLK
;
1467 VCLK
= pVBInfo
->VCLKData
[index
].CLOCK
;
1470 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x32);
1473 data
|= 0x0c; /* VCLK > 200 */
1475 if (HwDeviceExtension
->jChipType
>= XG20
)
1476 data
&= ~0x04; /* 2 pixel mode */
1478 xgifb_reg_set(pVBInfo
->P3c4
, 0x32, data
);
1480 if (HwDeviceExtension
->jChipType
< XG20
) {
1481 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x1F);
1485 xgifb_reg_set(pVBInfo
->P3c4
, 0x1F, data
);
1490 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x07, 0xFC, data2
);
1491 if (HwDeviceExtension
->jChipType
>= XG27
)
1492 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x40, 0xFC, data2
& 0x03);
1496 static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info
*HwDeviceExtension
,
1497 unsigned short ModeNo
, unsigned short ModeIdIndex
,
1498 unsigned short RefreshRateTableIndex
,
1499 struct vb_device_info
*pVBInfo
)
1501 unsigned short data
, data2
, data3
, infoflag
= 0, modeflag
, resindex
,
1504 if (ModeNo
> 0x13) {
1505 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
1506 infoflag
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].
1509 /* si+St_ModeFlag */
1510 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
1512 if (xgifb_reg_get(pVBInfo
->P3d4
, 0x31) & 0x01)
1513 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x1F, 0x3F, 0x00);
1522 if (ModeNo
> 0x13) {
1523 if (pVBInfo
->ModeType
> 0x02) {
1525 data3
= pVBInfo
->ModeType
- ModeVGA
;
1531 data
&= InterlaceMode
;
1536 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x06, ~0x3F, data2
);
1537 resindex
= XGI_GetResInfo(ModeNo
, ModeIdIndex
, pVBInfo
);
1539 xres
= pVBInfo
->StResInfo
[resindex
].HTotal
;
1541 xres
= pVBInfo
->ModeResInfo
[resindex
].HTotal
; /* xres->ax */
1544 if (infoflag
& InterlaceMode
) {
1547 else if (xres
== 1280)
1551 data2
= data
& 0x00FF;
1552 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x19, 0xFF, data2
);
1553 data2
= (data
& 0xFF00) >> 8;
1554 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x19, 0xFC, data2
);
1556 if (modeflag
& HalfDCLK
)
1557 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x01, 0xF7, 0x08);
1561 if (modeflag
& LineCompareOff
)
1564 if (ModeNo
> 0x13) {
1565 if (pVBInfo
->ModeType
== ModeEGA
)
1569 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0F, ~0x48, data2
);
1571 if (pVBInfo
->ModeType
!= ModeText
) {
1573 if (pVBInfo
->ModeType
!= ModeEGA
)
1576 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x21, 0x1F, data
);
1578 XGI_SetVCLKState(HwDeviceExtension
, ModeNo
, RefreshRateTableIndex
,
1581 data
= xgifb_reg_get(pVBInfo
->P3d4
, 0x31);
1583 if (HwDeviceExtension
->jChipType
== XG27
) {
1588 xgifb_reg_set(pVBInfo
->P3d4
, 0x52, data
);
1589 xgifb_reg_or(pVBInfo
->P3d4
, 0x51, 0x10);
1590 } else if (HwDeviceExtension
->jChipType
>= XG20
) {
1595 xgifb_reg_set(pVBInfo
->P3d4
, 0x52, data
);
1596 xgifb_reg_set(pVBInfo
->P3d4
, 0x51, 0x02);
1602 xgifb_reg_set(pVBInfo
->P3d4
, 0x52, data
);
1607 static void XGI_WriteDAC(unsigned short dl
,
1611 struct vb_device_info
*pVBInfo
)
1613 unsigned short temp
, bh
, bl
;
1632 outb((unsigned short) dh
, pVBInfo
->P3c9
);
1633 outb((unsigned short) bh
, pVBInfo
->P3c9
);
1634 outb((unsigned short) bl
, pVBInfo
->P3c9
);
1637 static void XGI_LoadDAC(unsigned short ModeNo
, unsigned short ModeIdIndex
,
1638 struct vb_device_info
*pVBInfo
)
1640 unsigned short data
, data2
, time
, i
, j
, k
, m
, n
, o
, si
, di
, bx
, dl
, al
,
1642 const unsigned short *table
= NULL
;
1645 data
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
1647 data
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
1649 data
&= DACInfoFlag
;
1653 table
= XGINew_MDA_DAC
;
1654 else if (data
== 0x08)
1655 table
= XGINew_CGA_DAC
;
1656 else if (data
== 0x10)
1657 table
= XGINew_EGA_DAC
;
1658 else if (data
== 0x18) {
1660 table
= XGINew_VGA_DAC
;
1668 outb(0xFF, pVBInfo
->P3c6
);
1669 outb(0x00, pVBInfo
->P3c8
);
1671 for (i
= 0; i
< j
; i
++) {
1674 for (k
= 0; k
< 3; k
++) {
1683 outb(data2
, pVBInfo
->P3c9
);
1689 for (i
= 16; i
< 32; i
++) {
1692 for (k
= 0; k
< 3; k
++)
1693 outb(data
, pVBInfo
->P3c9
);
1698 for (m
= 0; m
< 9; m
++) {
1703 for (n
= 0; n
< 3; n
++) {
1704 for (o
= 0; o
< 5; o
++) {
1709 XGI_WriteDAC(dl
, ah
, al
, dh
, pVBInfo
);
1714 for (o
= 0; o
< 3; o
++) {
1719 XGI_WriteDAC(dl
, ah
, al
, dh
, pVBInfo
);
1730 static void XGI_GetLVDSResInfo(unsigned short ModeNo
,
1731 unsigned short ModeIdIndex
,
1732 struct vb_device_info
*pVBInfo
)
1734 unsigned short resindex
, xres
, yres
, modeflag
;
1738 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ResInfo
;
1740 /* si+Ext_ResInfo */
1741 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
1745 resindex
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ResInfo
;
1747 /* si+Ext_ResInfo */
1748 resindex
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
1750 if (ModeNo
<= 0x13) {
1751 xres
= pVBInfo
->StResInfo
[resindex
].HTotal
;
1752 yres
= pVBInfo
->StResInfo
[resindex
].VTotal
;
1754 xres
= pVBInfo
->ModeResInfo
[resindex
].HTotal
;
1755 yres
= pVBInfo
->ModeResInfo
[resindex
].VTotal
;
1757 if (ModeNo
> 0x13) {
1758 if (modeflag
& HalfDCLK
)
1761 if (modeflag
& DoubleScanMode
)
1768 pVBInfo
->VGAHDE
= xres
;
1769 pVBInfo
->HDE
= xres
;
1770 pVBInfo
->VGAVDE
= yres
;
1771 pVBInfo
->VDE
= yres
;
1774 static void *XGI_GetLcdPtr(unsigned short BX
, unsigned short ModeNo
,
1775 unsigned short ModeIdIndex
,
1776 unsigned short RefreshRateTableIndex
,
1777 struct vb_device_info
*pVBInfo
)
1779 unsigned short i
, tempdx
, tempcx
, tempbx
, tempal
, modeflag
, table
;
1781 struct XGI330_LCDDataTablStruct
*tempdi
= NULL
;
1785 if (ModeNo
<= 0x13) {
1786 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
1787 tempal
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_CRT2CRTC
;
1789 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
1790 tempal
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRT2CRTC
;
1793 tempal
= tempal
& 0x0f;
1795 if (tempbx
<= 1) { /* ExpLink */
1796 if (ModeNo
<= 0x13) {
1797 /* find no Ext_CRT2CRTC2 */
1798 tempal
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_CRT2CRTC
;
1800 tempal
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].
1804 if (pVBInfo
->VBInfo
& SetCRT2ToLCDA
) {
1806 tempal
= pVBInfo
->SModeIDTable
[ModeIdIndex
].
1809 tempal
= pVBInfo
->RefIndex
[
1810 RefreshRateTableIndex
].
1815 tempal
= (tempal
>> 4);
1817 tempal
= (tempal
& 0x0f);
1820 tempcx
= LCDLenList
[tempbx
];
1822 if (pVBInfo
->LCDInfo
& EnableScalingLCD
) { /* ScaleLCD */
1823 if ((tempbx
== 5) || (tempbx
) == 7)
1824 tempcx
= LCDDesDataLen2
;
1825 else if ((tempbx
== 3) || (tempbx
== 8))
1826 tempcx
= LVDSDesDataLen2
;
1832 tempdi
= xgifb_epllcd_crt1
;
1835 tempdi
= XGI_EPLLCDDataPtr
;
1838 tempdi
= XGI_EPLLCDDesDataPtr
;
1841 tempdi
= XGI_LCDDataTable
;
1844 tempdi
= XGI_LCDDesDataTable
;
1847 tempdi
= XGI_EPLCHLCDRegPtr
;
1858 if (tempdi
== NULL
) /* OEMUtil */
1864 while (tempdi
[i
].PANELID
!= 0xff) {
1865 tempdx
= pVBInfo
->LCDResInfo
;
1866 if (tempbx
& 0x0080) { /* OEMUtil */
1867 tempbx
&= (~0x0080);
1868 tempdx
= pVBInfo
->LCDTypeInfo
;
1871 if (pVBInfo
->LCDInfo
& EnableScalingLCD
)
1872 tempdx
&= (~PanelResInfo
);
1874 if (tempdi
[i
].PANELID
== tempdx
) {
1875 tempbx
= tempdi
[i
].MASK
;
1876 tempdx
= pVBInfo
->LCDInfo
;
1878 if (ModeNo
<= 0x13) /* alan 09/10/2003 */
1879 tempdx
|= SetLCDStdMode
;
1881 if (modeflag
& HalfDCLK
)
1882 tempdx
|= SetLCDLowResolution
;
1885 if (tempbx
== tempdi
[i
].CAP
)
1892 switch (tempdi
[i
].DATAPTR
) {
1894 return &XGI_LVDSCRT11024x768_1_H
[tempal
];
1897 return &XGI_LVDSCRT11024x768_2_H
[tempal
];
1900 return &XGI_LVDSCRT11280x1024_1_H
[tempal
];
1903 return &XGI_LVDSCRT11280x1024_2_H
[tempal
];
1906 return &XGI_LVDSCRT11400x1050_1_H
[tempal
];
1909 return &XGI_LVDSCRT11400x1050_2_H
[tempal
];
1912 return &XGI_LVDSCRT11600x1200_1_H
[tempal
];
1915 return &XGI_LVDSCRT11024x768_1_Hx75
[tempal
];
1918 return &XGI_LVDSCRT11024x768_2_Hx75
[tempal
];
1921 return &XGI_LVDSCRT11280x1024_1_Hx75
[tempal
];
1924 return &XGI_LVDSCRT11280x1024_2_Hx75
[tempal
];
1929 } else if (table
== 1) {
1930 switch (tempdi
[i
].DATAPTR
) {
1932 return &XGI_LVDSCRT11024x768_1_V
[tempal
];
1935 return &XGI_LVDSCRT11024x768_2_V
[tempal
];
1938 return &XGI_LVDSCRT11280x1024_1_V
[tempal
];
1941 return &XGI_LVDSCRT11280x1024_2_V
[tempal
];
1944 return &XGI_LVDSCRT11400x1050_1_V
[tempal
];
1947 return &XGI_LVDSCRT11400x1050_2_V
[tempal
];
1950 return &XGI_LVDSCRT11600x1200_1_V
[tempal
];
1953 return &XGI_LVDSCRT11024x768_1_Vx75
[tempal
];
1956 return &XGI_LVDSCRT11024x768_2_Vx75
[tempal
];
1959 return &XGI_LVDSCRT11280x1024_1_Vx75
[tempal
];
1962 return &XGI_LVDSCRT11280x1024_2_Vx75
[tempal
];
1967 } else if (table
== 2) {
1968 switch (tempdi
[i
].DATAPTR
) {
1970 return &XGI_LVDS1024x768Data_1
[tempal
];
1973 return &XGI_LVDS1024x768Data_2
[tempal
];
1976 return &XGI_LVDS1280x1024Data_1
[tempal
];
1979 return &XGI_LVDS1280x1024Data_2
[tempal
];
1982 return &XGI_LVDS1400x1050Data_1
[tempal
];
1985 return &XGI_LVDS1400x1050Data_2
[tempal
];
1988 return &XGI_LVDS1600x1200Data_1
[tempal
];
1991 return &XGI_LVDSNoScalingData
[tempal
];
1994 return &XGI_LVDS1024x768Data_1x75
[tempal
];
1997 return &XGI_LVDS1024x768Data_2x75
[tempal
];
2000 return &XGI_LVDS1280x1024Data_1x75
[tempal
];
2003 return &XGI_LVDS1280x1024Data_2x75
[tempal
];
2006 return &XGI_LVDSNoScalingDatax75
[tempal
];
2011 } else if (table
== 3) {
2012 switch (tempdi
[i
].DATAPTR
) {
2014 return &XGI_LVDS1024x768Des_1
[tempal
];
2017 return &XGI_LVDS1024x768Des_3
[tempal
];
2020 return &XGI_LVDS1024x768Des_2
[tempal
];
2023 return &XGI_LVDS1280x1024Des_1
[tempal
];
2026 return &XGI_LVDS1280x1024Des_2
[tempal
];
2029 return &XGI_LVDS1400x1050Des_1
[tempal
];
2032 return &XGI_LVDS1400x1050Des_2
[tempal
];
2035 return &XGI_LVDS1600x1200Des_1
[tempal
];
2038 return &XGI_LVDSNoScalingDesData
[tempal
];
2041 return &XGI_LVDS1024x768Des_1x75
[tempal
];
2044 return &XGI_LVDS1024x768Des_3x75
[tempal
];
2047 return &XGI_LVDS1024x768Des_2x75
[tempal
];
2050 return &XGI_LVDS1280x1024Des_1x75
[tempal
];
2053 return &XGI_LVDS1280x1024Des_2x75
[tempal
];
2056 return &XGI_LVDSNoScalingDesDatax75
[tempal
];
2061 } else if (table
== 4) {
2062 switch (tempdi
[i
].DATAPTR
) {
2064 return &XGI_ExtLCD1024x768Data
[tempal
];
2067 return &XGI_StLCD1024x768Data
[tempal
];
2070 return &XGI_CetLCD1024x768Data
[tempal
];
2073 return &XGI_ExtLCD1280x1024Data
[tempal
];
2076 return &XGI_StLCD1280x1024Data
[tempal
];
2079 return &XGI_CetLCD1280x1024Data
[tempal
];
2083 return &xgifb_lcd_1400x1050
[tempal
];
2086 return &XGI_CetLCD1400x1050Data
[tempal
];
2089 return &XGI_ExtLCD1600x1200Data
[tempal
];
2092 return &XGI_StLCD1600x1200Data
[tempal
];
2095 return &XGI_NoScalingData
[tempal
];
2098 return &XGI_ExtLCD1024x768x75Data
[tempal
];
2101 return &XGI_ExtLCD1024x768x75Data
[tempal
];
2104 return &XGI_CetLCD1024x768x75Data
[tempal
];
2108 return &xgifb_lcd_1280x1024x75
[tempal
];
2111 return &XGI_CetLCD1280x1024x75Data
[tempal
];
2114 return &XGI_NoScalingDatax75
[tempal
];
2119 } else if (table
== 5) {
2120 switch (tempdi
[i
].DATAPTR
) {
2122 return &XGI_ExtLCDDes1024x768Data
[tempal
];
2125 return &XGI_StLCDDes1024x768Data
[tempal
];
2128 return &XGI_CetLCDDes1024x768Data
[tempal
];
2131 if ((pVBInfo
->VBType
& VB_XGI301LV
) ||
2132 (pVBInfo
->VBType
& VB_XGI302LV
))
2133 return &XGI_ExtLCDDLDes1280x1024Data
[tempal
];
2135 return &XGI_ExtLCDDes1280x1024Data
[tempal
];
2138 if ((pVBInfo
->VBType
& VB_XGI301LV
) ||
2139 (pVBInfo
->VBType
& VB_XGI302LV
))
2140 return &XGI_StLCDDLDes1280x1024Data
[tempal
];
2142 return &XGI_StLCDDes1280x1024Data
[tempal
];
2145 if ((pVBInfo
->VBType
& VB_XGI301LV
) ||
2146 (pVBInfo
->VBType
& VB_XGI302LV
))
2147 return &XGI_CetLCDDLDes1280x1024Data
[tempal
];
2149 return &XGI_CetLCDDes1280x1024Data
[tempal
];
2153 if ((pVBInfo
->VBType
& VB_XGI301LV
) ||
2154 (pVBInfo
->VBType
& VB_XGI302LV
))
2155 return &xgifb_lcddldes_1400x1050
[tempal
];
2157 return &xgifb_lcddes_1400x1050
[tempal
];
2160 return &XGI_CetLCDDes1400x1050Data
[tempal
];
2163 return &XGI_CetLCDDes1400x1050Data2
[tempal
];
2166 if ((pVBInfo
->VBType
& VB_XGI301LV
) ||
2167 (pVBInfo
->VBType
& VB_XGI302LV
))
2168 return &XGI_ExtLCDDLDes1600x1200Data
[tempal
];
2170 return &XGI_ExtLCDDes1600x1200Data
[tempal
];
2173 if ((pVBInfo
->VBType
& VB_XGI301LV
) ||
2174 (pVBInfo
->VBType
& VB_XGI302LV
))
2175 return &XGI_StLCDDLDes1600x1200Data
[tempal
];
2177 return &XGI_StLCDDes1600x1200Data
[tempal
];
2180 return &XGI_NoScalingDesData
[tempal
];
2184 return &xgifb_lcddes_1024x768x75
[tempal
];
2187 return &XGI_CetLCDDes1024x768x75Data
[tempal
];
2191 if ((pVBInfo
->VBType
& VB_XGI301LV
) ||
2192 (pVBInfo
->VBType
& VB_XGI302LV
))
2193 return &xgifb_lcddldes_1280x1024x75
[tempal
];
2195 return &xgifb_lcddes_1280x1024x75
[tempal
];
2198 if ((pVBInfo
->VBType
& VB_XGI301LV
) ||
2199 (pVBInfo
->VBType
& VB_XGI302LV
))
2200 return &XGI_CetLCDDLDes1280x1024x75Data
[tempal
];
2202 return &XGI_CetLCDDes1280x1024x75Data
[tempal
];
2205 return &XGI_NoScalingDesDatax75
[tempal
];
2210 } else if (table
== 6) {
2211 switch (tempdi
[i
].DATAPTR
) {
2213 return &XGI_CH7017LV1024x768
[tempal
];
2216 return &XGI_CH7017LV1400x1050
[tempal
];
2225 static void *XGI_GetTVPtr(unsigned short BX
, unsigned short ModeNo
,
2226 unsigned short ModeIdIndex
,
2227 unsigned short RefreshRateTableIndex
,
2228 struct vb_device_info
*pVBInfo
)
2230 unsigned short i
, tempdx
, tempbx
, tempal
, modeflag
, table
;
2231 struct XGI330_TVDataTablStruct
*tempdi
= NULL
;
2235 if (ModeNo
<= 0x13) {
2236 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
2237 tempal
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_CRT2CRTC
;
2239 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
2240 tempal
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRT2CRTC
;
2243 tempal
= tempal
& 0x3f;
2255 tempdi
= xgifb_chrontel_tv
;
2261 tempdi
= XGI_TVDataTable
;
2270 if (tempdi
== NULL
) /* OEMUtil */
2273 tempdx
= pVBInfo
->TVInfo
;
2275 if (pVBInfo
->VBInfo
& SetInSlaveMode
)
2276 tempdx
= tempdx
| SetTVLockMode
;
2278 if (modeflag
& HalfDCLK
)
2279 tempdx
= tempdx
| SetTVLowResolution
;
2283 while (tempdi
[i
].MASK
!= 0xffff) {
2284 if ((tempdx
& tempdi
[i
].MASK
) == tempdi
[i
].CAP
)
2290 if (table
== 0x04) {
2291 switch (tempdi
[i
].DATAPTR
) {
2293 return &XGI_ExtPALData
[tempal
];
2296 return &XGI_ExtNTSCData
[tempal
];
2299 return &XGI_StPALData
[tempal
];
2302 return &XGI_StNTSCData
[tempal
];
2305 return &XGI_ExtHiTVData
[tempal
];
2308 return &XGI_St2HiTVData
[tempal
];
2311 return &XGI_ExtYPbPr525iData
[tempal
];
2314 return &XGI_ExtYPbPr525pData
[tempal
];
2317 return &XGI_ExtYPbPr750pData
[tempal
];
2320 return &XGI_StYPbPr525iData
[tempal
];
2323 return &XGI_StYPbPr525pData
[tempal
];
2326 return &XGI_StYPbPr750pData
[tempal
];
2328 case 12: /* avoid system hang */
2329 return &XGI_ExtNTSCData
[tempal
];
2332 return &XGI_St1HiTVData
[tempal
];
2337 } else if (table
== 0x02) {
2338 switch (tempdi
[i
].DATAPTR
) {
2340 return &XGI_CHTVUNTSCData
[tempal
];
2343 return &XGI_CHTVONTSCData
[tempal
];
2346 return &XGI_CHTVUPALData
[tempal
];
2349 return &XGI_CHTVOPALData
[tempal
];
2358 static void XGI_GetLVDSData(unsigned short ModeNo
, unsigned short ModeIdIndex
,
2359 unsigned short RefreshRateTableIndex
,
2360 struct vb_device_info
*pVBInfo
)
2362 unsigned short tempbx
;
2363 struct XGI330_LVDSDataStruct
*LCDPtr
= NULL
;
2367 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToLCDA
)) {
2368 LCDPtr
= (struct XGI330_LVDSDataStruct
*) XGI_GetLcdPtr(tempbx
,
2369 ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
2371 pVBInfo
->VGAHT
= LCDPtr
->VGAHT
;
2372 pVBInfo
->VGAVT
= LCDPtr
->VGAVT
;
2373 pVBInfo
->HT
= LCDPtr
->LCDHT
;
2374 pVBInfo
->VT
= LCDPtr
->LCDVT
;
2377 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToLCDA
)) {
2378 if (!(pVBInfo
->LCDInfo
& (SetLCDtoNonExpanding
2379 | EnableScalingLCD
))) {
2380 if ((pVBInfo
->LCDResInfo
== Panel1024x768
) ||
2381 (pVBInfo
->LCDResInfo
== Panel1024x768x75
)) {
2382 pVBInfo
->HDE
= 1024;
2384 } else if ((pVBInfo
->LCDResInfo
== Panel1280x1024
) ||
2385 (pVBInfo
->LCDResInfo
== Panel1280x1024x75
)) {
2386 pVBInfo
->HDE
= 1280;
2387 pVBInfo
->VDE
= 1024;
2388 } else if (pVBInfo
->LCDResInfo
== Panel1400x1050
) {
2389 pVBInfo
->HDE
= 1400;
2390 pVBInfo
->VDE
= 1050;
2392 pVBInfo
->HDE
= 1600;
2393 pVBInfo
->VDE
= 1200;
2399 static void XGI_ModCRT1Regs(unsigned short ModeNo
, unsigned short ModeIdIndex
,
2400 unsigned short RefreshRateTableIndex
,
2401 struct xgi_hw_device_info
*HwDeviceExtension
,
2402 struct vb_device_info
*pVBInfo
)
2404 unsigned char index
;
2405 unsigned short tempbx
, i
;
2406 struct XGI_LVDSCRT1HDataStruct
*LCDPtr
= NULL
;
2407 struct XGI_LVDSCRT1VDataStruct
*LCDPtr1
= NULL
;
2410 index
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_CRT2CRTC
;
2412 index
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRT2CRTC
;
2414 index
= index
& IndexMask
;
2418 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToLCDA
)) {
2419 LCDPtr
= (struct XGI_LVDSCRT1HDataStruct
*)
2420 XGI_GetLcdPtr(tempbx
, ModeNo
,
2422 RefreshRateTableIndex
,
2425 for (i
= 0; i
< 8; i
++)
2426 pVBInfo
->TimingH
[0].data
[i
] = LCDPtr
[0].Reg
[i
];
2429 XGI_SetCRT1Timing_H(pVBInfo
, HwDeviceExtension
);
2433 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToLCDA
)) {
2434 LCDPtr1
= (struct XGI_LVDSCRT1VDataStruct
*)
2439 RefreshRateTableIndex
,
2441 for (i
= 0; i
< 7; i
++)
2442 pVBInfo
->TimingV
[0].data
[i
] = LCDPtr1
[0].Reg
[i
];
2445 XGI_SetCRT1Timing_V(ModeIdIndex
, ModeNo
, pVBInfo
);
2448 static unsigned short XGI_GetLCDCapPtr(struct vb_device_info
*pVBInfo
)
2450 unsigned char tempal
, tempah
, tempbl
, i
;
2452 tempah
= xgifb_reg_get(pVBInfo
->P3d4
, 0x36);
2453 tempal
= tempah
& 0x0F;
2454 tempah
= tempah
& 0xF0;
2456 tempbl
= pVBInfo
->LCDCapList
[i
].LCD_ID
;
2458 while (tempbl
!= 0xFF) {
2459 if (tempbl
& 0x80) { /* OEMUtil */
2461 tempbl
= tempbl
& ~(0x80);
2464 if (tempal
== tempbl
)
2469 tempbl
= pVBInfo
->LCDCapList
[i
].LCD_ID
;
2475 static unsigned short XGI_GetLCDCapPtr1(struct vb_device_info
*pVBInfo
)
2477 unsigned short tempah
, tempal
, tempbl
, i
;
2479 tempal
= pVBInfo
->LCDResInfo
;
2480 tempah
= pVBInfo
->LCDTypeInfo
;
2483 tempbl
= pVBInfo
->LCDCapList
[i
].LCD_ID
;
2485 while (tempbl
!= 0xFF) {
2486 if ((tempbl
& 0x80) && (tempbl
!= 0x80)) {
2491 if (tempal
== tempbl
)
2495 tempbl
= pVBInfo
->LCDCapList
[i
].LCD_ID
;
2498 if (tempbl
== 0xFF) {
2499 pVBInfo
->LCDResInfo
= Panel1024x768
;
2500 pVBInfo
->LCDTypeInfo
= 0;
2507 static void XGI_GetLCDSync(unsigned short *HSyncWidth
,
2508 unsigned short *VSyncWidth
,
2509 struct vb_device_info
*pVBInfo
)
2511 unsigned short Index
;
2513 Index
= XGI_GetLCDCapPtr(pVBInfo
);
2514 *HSyncWidth
= pVBInfo
->LCDCapList
[Index
].LCD_HSyncWidth
;
2515 *VSyncWidth
= pVBInfo
->LCDCapList
[Index
].LCD_VSyncWidth
;
2520 static void XGI_SetLVDSRegs(unsigned short ModeNo
, unsigned short ModeIdIndex
,
2521 unsigned short RefreshRateTableIndex
,
2522 struct vb_device_info
*pVBInfo
)
2524 unsigned short tempbx
, tempax
, tempcx
, tempdx
, push1
, push2
, modeflag
;
2525 unsigned long temp
, temp1
, temp2
, temp3
, push3
;
2526 struct XGI330_LCDDataDesStruct
*LCDPtr
= NULL
;
2527 struct XGI330_LCDDataDesStruct2
*LCDPtr1
= NULL
;
2530 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
2532 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
2535 if (pVBInfo
->LCDInfo
& EnableScalingLCD
)
2537 (struct XGI330_LCDDataDesStruct2
*)
2542 RefreshRateTableIndex
,
2546 (struct XGI330_LCDDataDesStruct
*)
2551 RefreshRateTableIndex
,
2554 XGI_GetLCDSync(&tempax
, &tempbx
, pVBInfo
);
2559 if ((pVBInfo
->LCDResInfo
== Panel1024x768
) ||
2560 (pVBInfo
->LCDResInfo
== Panel1024x768x75
)) {
2563 } else if ((pVBInfo
->LCDResInfo
== Panel1280x1024
) ||
2564 (pVBInfo
->LCDResInfo
== Panel1280x1024x75
)) {
2567 } else if (pVBInfo
->LCDResInfo
== Panel1400x1050
) {
2575 if (pVBInfo
->LCDInfo
& SetLCDtoNonExpanding
) {
2576 pVBInfo
->HDE
= tempax
;
2577 pVBInfo
->VDE
= tempbx
;
2578 pVBInfo
->VGAHDE
= tempax
;
2579 pVBInfo
->VGAVDE
= tempbx
;
2582 tempax
= pVBInfo
->HT
;
2584 if (pVBInfo
->LCDInfo
& EnableScalingLCD
)
2585 tempbx
= LCDPtr1
->LCDHDES
;
2587 tempbx
= LCDPtr
->LCDHDES
;
2589 tempcx
= pVBInfo
->HDE
;
2590 tempbx
= tempbx
& 0x0fff;
2593 if (tempcx
>= tempax
)
2596 xgifb_reg_set(pVBInfo
->Part1Port
, 0x1A, tempbx
& 0x07);
2598 tempcx
= tempcx
>> 3;
2599 tempbx
= tempbx
>> 3;
2601 xgifb_reg_set(pVBInfo
->Part1Port
, 0x16,
2602 (unsigned short) (tempbx
& 0xff));
2603 xgifb_reg_set(pVBInfo
->Part1Port
, 0x17,
2604 (unsigned short) (tempcx
& 0xff));
2606 tempax
= pVBInfo
->HT
;
2608 if (pVBInfo
->LCDInfo
& EnableScalingLCD
)
2609 tempbx
= LCDPtr1
->LCDHRS
;
2611 tempbx
= LCDPtr
->LCDHRS
;
2615 if (pVBInfo
->LCDInfo
& EnableScalingLCD
)
2616 tempcx
= LCDPtr1
->LCDHSync
;
2620 if (tempcx
>= tempax
)
2623 tempax
= tempbx
& 0x07;
2624 tempax
= tempax
>> 5;
2625 tempcx
= tempcx
>> 3;
2626 tempbx
= tempbx
>> 3;
2631 xgifb_reg_set(pVBInfo
->Part1Port
, 0x15, tempax
);
2632 xgifb_reg_set(pVBInfo
->Part1Port
, 0x14,
2633 (unsigned short) (tempbx
& 0xff));
2635 tempax
= pVBInfo
->VT
;
2636 if (pVBInfo
->LCDInfo
& EnableScalingLCD
)
2637 tempbx
= LCDPtr1
->LCDVDES
;
2639 tempbx
= LCDPtr
->LCDVDES
;
2640 tempcx
= pVBInfo
->VDE
;
2642 tempbx
= tempbx
& 0x0fff;
2644 if (tempcx
>= tempax
)
2647 xgifb_reg_set(pVBInfo
->Part1Port
, 0x1b,
2648 (unsigned short) (tempbx
& 0xff));
2649 xgifb_reg_set(pVBInfo
->Part1Port
, 0x1c,
2650 (unsigned short) (tempcx
& 0xff));
2652 tempbx
= (tempbx
>> 8) & 0x07;
2653 tempcx
= (tempcx
>> 8) & 0x07;
2655 xgifb_reg_set(pVBInfo
->Part1Port
, 0x1d,
2656 (unsigned short) ((tempcx
<< 3)
2659 tempax
= pVBInfo
->VT
;
2660 if (pVBInfo
->LCDInfo
& EnableScalingLCD
)
2661 tempbx
= LCDPtr1
->LCDVRS
;
2663 tempbx
= LCDPtr
->LCDVRS
;
2667 if (pVBInfo
->LCDInfo
& EnableScalingLCD
)
2668 tempcx
= LCDPtr1
->LCDVSync
;
2671 if (tempcx
>= tempax
)
2674 xgifb_reg_set(pVBInfo
->Part1Port
, 0x18,
2675 (unsigned short) (tempbx
& 0xff));
2676 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x19, ~0x0f,
2677 (unsigned short) (tempcx
& 0x0f));
2679 tempax
= ((tempbx
>> 8) & 0x07) << 3;
2681 tempbx
= pVBInfo
->VGAVDE
;
2682 if (tempbx
!= pVBInfo
->VDE
)
2685 if (pVBInfo
->LCDInfo
& EnableLVDSDDA
)
2688 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x1a, 0x07,
2691 tempcx
= pVBInfo
->VGAVT
;
2692 tempbx
= pVBInfo
->VDE
;
2693 tempax
= pVBInfo
->VGAVDE
;
2696 temp
= tempax
; /* 0430 ylshieh */
2697 temp1
= (temp
<< 18) / tempbx
;
2699 tempdx
= (unsigned short) ((temp
<< 18) % tempbx
);
2707 xgifb_reg_set(pVBInfo
->Part1Port
, 0x37,
2708 (unsigned short) (temp2
& 0xff));
2709 xgifb_reg_set(pVBInfo
->Part1Port
, 0x36,
2710 (unsigned short) ((temp2
>> 8) & 0xff));
2712 tempbx
= (unsigned short) (temp2
>> 16);
2713 tempax
= tempbx
& 0x03;
2715 tempbx
= pVBInfo
->VGAVDE
;
2716 if (tempbx
== pVBInfo
->VDE
)
2719 xgifb_reg_set(pVBInfo
->Part1Port
, 0x35, tempax
);
2721 if (pVBInfo
->VBType
& VB_XGI301C
) {
2723 xgifb_reg_set(pVBInfo
->Part4Port
,
2725 (unsigned short) (temp2
& 0xff));
2726 xgifb_reg_set(pVBInfo
->Part4Port
,
2728 (unsigned short) ((temp2
>> 8) &
2730 tempbx
= (unsigned short) (temp2
>> 16);
2731 xgifb_reg_and_or(pVBInfo
->Part4Port
, 0x3a,
2733 (unsigned short) ((tempbx
&
2736 tempcx
= pVBInfo
->VGAVDE
;
2737 if (tempcx
== pVBInfo
->VDE
)
2738 xgifb_reg_and_or(pVBInfo
->Part4Port
,
2741 xgifb_reg_and_or(pVBInfo
->Part4Port
,
2745 tempcx
= pVBInfo
->VGAHDE
;
2746 tempbx
= pVBInfo
->HDE
;
2748 temp1
= tempcx
<< 16;
2750 tempax
= (unsigned short) (temp1
/ tempbx
);
2752 if ((tempbx
& 0xffff) == (tempcx
& 0xffff))
2756 temp1
= pVBInfo
->VGAHDE
<< 16;
2759 temp3
= temp3
<< 16;
2762 temp3
= (temp3
& 0xffff0000) + (temp1
& 0xffff);
2764 tempax
= (unsigned short) (temp3
& 0xff);
2765 xgifb_reg_set(pVBInfo
->Part1Port
, 0x1f, tempax
);
2767 temp1
= pVBInfo
->VGAVDE
<< 18;
2768 temp1
= temp1
/ push3
;
2769 tempbx
= (unsigned short) (temp1
& 0xffff);
2771 if (pVBInfo
->LCDResInfo
== Panel1024x768
)
2774 tempax
= ((tempbx
>> 8) & 0xff) << 3;
2775 tempax
|= (unsigned short) ((temp3
>> 8) & 0x07);
2776 xgifb_reg_set(pVBInfo
->Part1Port
, 0x20,
2777 (unsigned short) (tempax
& 0xff));
2778 xgifb_reg_set(pVBInfo
->Part1Port
, 0x21,
2779 (unsigned short) (tempbx
& 0xff));
2781 temp3
= temp3
>> 16;
2783 if (modeflag
& HalfDCLK
)
2786 xgifb_reg_set(pVBInfo
->Part1Port
, 0x22,
2787 (unsigned short) ((temp3
>> 8) & 0xff));
2788 xgifb_reg_set(pVBInfo
->Part1Port
, 0x23,
2789 (unsigned short) (temp3
& 0xff));
2792 /* --------------------------------------------------------------------- */
2793 /* Function : XGI_GETLCDVCLKPtr */
2795 /* Output : al -> VCLK Index */
2797 /* --------------------------------------------------------------------- */
2798 static void XGI_GetLCDVCLKPtr(unsigned char *di_0
, unsigned char *di_1
,
2799 struct vb_device_info
*pVBInfo
)
2801 unsigned short index
;
2803 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToLCDA
)) {
2804 index
= XGI_GetLCDCapPtr1(pVBInfo
);
2806 if (pVBInfo
->VBInfo
& SetCRT2ToLCD
) { /* LCDB */
2807 *di_0
= pVBInfo
->LCDCapList
[index
].LCUCHAR_VCLKData1
;
2808 *di_1
= pVBInfo
->LCDCapList
[index
].LCUCHAR_VCLKData2
;
2810 *di_0
= pVBInfo
->LCDCapList
[index
].LCDA_VCLKData1
;
2811 *di_1
= pVBInfo
->LCDCapList
[index
].LCDA_VCLKData2
;
2817 static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex
,
2818 unsigned short ModeNo
, unsigned short ModeIdIndex
,
2819 struct vb_device_info
*pVBInfo
)
2822 unsigned short index
, modeflag
;
2823 unsigned char tempal
;
2827 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
2829 /* si+Ext_ResInfo */
2830 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
2832 if ((pVBInfo
->SetFlag
& ProgrammingCRT2
) &&
2833 (!(pVBInfo
->LCDInfo
& EnableScalingLCD
))) { /* {LCDA/LCDB} */
2834 index
= XGI_GetLCDCapPtr(pVBInfo
);
2835 tempal
= pVBInfo
->LCDCapList
[index
].LCD_VCLK
;
2837 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToLCDA
))
2841 if (pVBInfo
->VBType
&
2847 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
) {
2848 tempal
= HiTVVCLKDIV2
;
2849 if (!(pVBInfo
->TVInfo
& RPLLDIV2XO
))
2851 if (pVBInfo
->TVInfo
& TVSimuMode
) {
2852 tempal
= HiTVSimuVCLK
;
2853 if (!(modeflag
& Charx8Dot
))
2854 tempal
= HiTVTextVCLK
;
2860 if (pVBInfo
->TVInfo
& SetYPbPrMode750p
) {
2861 tempal
= YPbPr750pVCLK
;
2865 if (pVBInfo
->TVInfo
& SetYPbPrMode525p
) {
2866 tempal
= YPbPr525pVCLK
;
2870 tempal
= NTSC1024VCLK
;
2872 if (!(pVBInfo
->TVInfo
& NTSC1024x768
)) {
2873 tempal
= TVVCLKDIV2
;
2874 if (!(pVBInfo
->TVInfo
& RPLLDIV2XO
))
2878 if (pVBInfo
->VBInfo
& SetCRT2ToTV
)
2883 tempal
= (unsigned char) inb((pVBInfo
->P3ca
+ 0x02));
2884 tempal
= tempal
>> 2;
2887 /* for Dot8 Scaling LCD */
2888 if ((pVBInfo
->LCDInfo
& EnableScalingLCD
) && (modeflag
& Charx8Dot
))
2889 tempal
= tempal
^ tempal
; /* ; set to VCLK25MHz always */
2894 tempal
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRTVCLK
;
2898 static void XGI_GetVCLKLen(unsigned char tempal
, unsigned char *di_0
,
2899 unsigned char *di_1
, struct vb_device_info
*pVBInfo
)
2901 if (pVBInfo
->VBType
& (VB_XGI301
| VB_XGI301B
| VB_XGI302B
2902 | VB_XGI301LV
| VB_XGI302LV
| VB_XGI301C
)) {
2903 if ((!(pVBInfo
->VBInfo
& SetCRT2ToLCDA
)) && (pVBInfo
->SetFlag
2904 & ProgrammingCRT2
)) {
2905 *di_0
= (unsigned char) XGI_VBVCLKData
[tempal
].SR2B
;
2906 *di_1
= XGI_VBVCLKData
[tempal
].SR2C
;
2909 *di_0
= XGI_VCLKData
[tempal
].SR2B
;
2910 *di_1
= XGI_VCLKData
[tempal
].SR2C
;
2914 static void XGI_SetCRT2ECLK(unsigned short ModeNo
, unsigned short ModeIdIndex
,
2915 unsigned short RefreshRateTableIndex
,
2916 struct vb_device_info
*pVBInfo
)
2918 unsigned char di_0
, di_1
, tempal
;
2921 tempal
= XGI_GetVCLKPtr(RefreshRateTableIndex
, ModeNo
, ModeIdIndex
,
2923 XGI_GetVCLKLen(tempal
, &di_0
, &di_1
, pVBInfo
);
2924 XGI_GetLCDVCLKPtr(&di_0
, &di_1
, pVBInfo
);
2926 for (i
= 0; i
< 4; i
++) {
2927 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x31, ~0x30,
2928 (unsigned short) (0x10 * i
));
2929 if ((!(pVBInfo
->VBInfo
& SetCRT2ToLCDA
))
2930 && (!(pVBInfo
->VBInfo
& SetInSlaveMode
))) {
2931 xgifb_reg_set(pVBInfo
->P3c4
, 0x2e, di_0
);
2932 xgifb_reg_set(pVBInfo
->P3c4
, 0x2f, di_1
);
2934 xgifb_reg_set(pVBInfo
->P3c4
, 0x2b, di_0
);
2935 xgifb_reg_set(pVBInfo
->P3c4
, 0x2c, di_1
);
2940 static void XGI_UpdateModeInfo(struct xgi_hw_device_info
*HwDeviceExtension
,
2941 struct vb_device_info
*pVBInfo
)
2943 unsigned short tempcl
, tempch
, temp
, tempbl
, tempax
;
2945 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
| VB_XGI301LV
2946 | VB_XGI302LV
| VB_XGI301C
)) {
2949 temp
= xgifb_reg_get(pVBInfo
->P3c4
, 0x01);
2951 if (!(temp
& 0x20)) {
2952 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x17);
2954 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x53);
2956 tempcl
|= ActiveCRT1
;
2960 temp
= xgifb_reg_get(pVBInfo
->Part1Port
, 0x2e);
2963 if (!(temp
== 0x08)) {
2964 /* Check ChannelA by Part1_13 [2003/10/03] */
2965 tempax
= xgifb_reg_get(pVBInfo
->Part1Port
, 0x13);
2967 tempcl
= tempcl
| ActiveLCD
;
2971 if (!(tempcl
& ActiveLCD
))
2973 tempcl
|= ActiveCRT2
;
2976 tempcl
|= ActiveLCD
;
2979 temp
= xgifb_reg_get(pVBInfo
->Part2Port
, 0x00);
2982 tempch
|= ActiveAVideo
;
2985 tempch
|= ActiveSVideo
;
2988 tempch
|= ActiveSCART
;
2990 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
) {
2992 tempch
|= ActiveHiTV
;
2995 if (pVBInfo
->VBInfo
& SetCRT2ToYPbPr
) {
2996 temp
= xgifb_reg_get(
3001 tempch
|= ActiveYPbPr
;
3009 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x3d);
3010 if (tempcl
& ActiveLCD
) {
3011 if ((pVBInfo
->SetFlag
& ReserveTVOption
)) {
3012 if (temp
& ActiveTV
)
3017 tempbl
= ~ModeSwitchStatus
;
3018 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x3d, tempbl
, temp
);
3020 if (!(pVBInfo
->SetFlag
& ReserveTVOption
))
3021 xgifb_reg_set(pVBInfo
->P3d4
, 0x3e, tempch
);
3027 void XGI_GetVBType(struct vb_device_info
*pVBInfo
)
3029 unsigned short flag
, tempbx
, tempah
;
3031 if (pVBInfo
->IF_DEF_LVDS
== 0) {
3032 tempbx
= VB_XGI302B
;
3033 flag
= xgifb_reg_get(pVBInfo
->Part4Port
, 0x00);
3036 flag
= xgifb_reg_get(pVBInfo
->Part4Port
, 0x01);
3038 tempbx
= VB_XGI301B
;
3040 tempbx
= VB_XGI301C
;
3042 tempbx
= VB_XGI301LV
;
3044 tempbx
= VB_XGI302LV
;
3045 tempah
= xgifb_reg_get(
3055 if (tempbx
& (VB_XGI301B
| VB_XGI302B
)) {
3056 flag
= xgifb_reg_get(
3061 tempbx
= tempbx
| VB_NoLCD
;
3065 pVBInfo
->VBType
= tempbx
;
3069 static void XGI_GetVBInfo(unsigned short ModeNo
, unsigned short ModeIdIndex
,
3070 struct xgi_hw_device_info
*HwDeviceExtension
,
3071 struct vb_device_info
*pVBInfo
)
3073 unsigned short tempax
, push
, tempbx
, temp
, modeflag
;
3076 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
3078 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
3080 pVBInfo
->SetFlag
= 0;
3081 pVBInfo
->ModeType
= modeflag
& ModeInfoFlag
;
3084 if (pVBInfo
->VBType
& 0xFFFF) {
3085 /* Check Display Device */
3086 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x30);
3087 tempbx
= tempbx
| temp
;
3088 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x31);
3092 tempbx
= tempbx
| tempax
;
3093 temp
= (SetCRT2ToDualEdge
| SetCRT2ToYPbPr
| SetCRT2ToLCDA
3094 | SetInSlaveMode
| DisableCRT2Display
);
3095 temp
= 0xFFFF ^ temp
;
3098 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x38);
3100 if (pVBInfo
->IF_DEF_LCDA
== 1) {
3102 if ((HwDeviceExtension
->jChipType
>= XG20
) ||
3103 (HwDeviceExtension
->jChipType
>= XG40
)) {
3104 if (pVBInfo
->IF_DEF_LVDS
== 0) {
3105 if (pVBInfo
->VBType
&
3110 if (temp
& EnableDualEdge
) {
3114 if (temp
& SetToLCDA
)
3123 if (pVBInfo
->IF_DEF_YPbPr
== 1) {
3124 /* [Billy] 07/05/04 */
3125 if (((pVBInfo
->IF_DEF_LVDS
== 0) &&
3126 ((pVBInfo
->VBType
& VB_XGI301LV
) ||
3127 (pVBInfo
->VBType
& VB_XGI302LV
) ||
3128 (pVBInfo
->VBType
& VB_XGI301C
)))) {
3129 if (temp
& SetYPbPr
) {
3130 if (pVBInfo
->IF_DEF_HiVision
== 1) {
3131 /* shampoo add for new
3133 temp
= xgifb_reg_get(
3137 tempbx
|= SetCRT2ToHiVisionTV
;
3139 if (temp
!= YPbPrMode1080i
) {
3141 (~SetCRT2ToHiVisionTV
);
3150 tempax
= push
; /* restore CR31 */
3152 if (pVBInfo
->IF_DEF_LVDS
== 0) {
3153 if (pVBInfo
->IF_DEF_YPbPr
== 1) {
3154 if (pVBInfo
->IF_DEF_HiVision
== 1)
3159 if (pVBInfo
->IF_DEF_HiVision
== 1)
3164 } else { /* 3nd party chip */
3165 temp
= SetCRT2ToLCD
;
3168 if (!(tempbx
& temp
)) {
3169 tempax
|= DisableCRT2Display
;
3173 if (pVBInfo
->IF_DEF_LCDA
== 1) { /* Select Display Device */
3174 if (!(pVBInfo
->VBType
& VB_NoLCD
)) {
3175 if (tempbx
& SetCRT2ToLCDA
) {
3176 if (tempbx
& SetSimuScanMode
)
3177 tempbx
&= (~(SetCRT2ToLCD
|
3181 tempbx
&= (~(SetCRT2ToLCD
|
3190 /* for driver abnormal */
3191 if (!(tempbx
& (SwitchToCRT2
| SetSimuScanMode
))) {
3192 if (pVBInfo
->IF_DEF_CRT2Monitor
== 1) {
3193 if (tempbx
& SetCRT2ToRAMDAC
) {
3198 tempbx
&= (0x00FF | (~SetCRT2ToYPbPr
));
3201 tempbx
&= (~(SetCRT2ToRAMDAC
|
3207 if (!(pVBInfo
->VBType
& VB_NoLCD
)) {
3208 if (tempbx
& SetCRT2ToLCD
) {
3213 tempbx
&= (0x00FF | (~SetCRT2ToYPbPr
));
3217 if (tempbx
& SetCRT2ToSCART
) {
3222 tempbx
&= (0x00FF | (~SetCRT2ToYPbPr
));
3225 if (pVBInfo
->IF_DEF_YPbPr
== 1) {
3226 if (tempbx
& SetCRT2ToYPbPr
)
3232 if (pVBInfo
->IF_DEF_HiVision
== 1) {
3233 if (tempbx
& SetCRT2ToHiVisionTV
)
3235 SetCRT2ToHiVisionTV
|
3240 if (tempax
& DisableCRT2Display
) { /* Set Display Device Info */
3241 if (!(tempbx
& (SwitchToCRT2
| SetSimuScanMode
)))
3242 tempbx
= DisableCRT2Display
;
3245 if (!(tempbx
& DisableCRT2Display
)) {
3246 if ((!(tempbx
& DriverMode
)) ||
3247 (!(modeflag
& CRT2Mode
))) {
3248 if (pVBInfo
->IF_DEF_LCDA
== 1) {
3249 if (!(tempbx
& SetCRT2ToLCDA
))
3250 tempbx
|= (SetInSlaveMode
|
3255 /* LCD+TV can't support in slave mode
3256 * (Force LCDA+TV->LCDB) */
3257 if ((tempbx
& SetInSlaveMode
) &&
3258 (tempbx
& SetCRT2ToLCDA
)) {
3259 tempbx
^= (SetCRT2ToLCD
|
3262 pVBInfo
->SetFlag
|= ReserveTVOption
;
3267 pVBInfo
->VBInfo
= tempbx
;
3270 static void XGI_GetTVInfo(unsigned short ModeNo
, unsigned short ModeIdIndex
,
3271 struct vb_device_info
*pVBInfo
)
3273 unsigned short temp
, tempbx
= 0, resinfo
= 0, modeflag
, index1
;
3278 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
3279 if (ModeNo
<= 0x13) {
3280 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].
3281 St_ModeFlag
; /* si+St_ModeFlag */
3282 resinfo
= pVBInfo
->SModeIDTable
[ModeIdIndex
].
3283 St_ResInfo
; /* si+St_ResInfo */
3285 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].
3287 resinfo
= pVBInfo
->EModeIDTable
[ModeIdIndex
].
3288 Ext_RESINFO
; /* si+Ext_ResInfo */
3291 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
3292 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x35);
3294 if (tempbx
& SetPALTV
) {
3295 tempbx
&= (SetCHTVOverScan
|
3299 if (tempbx
& SetPALMTV
)
3300 /* set to NTSC if PAL-M */
3301 tempbx
&= ~SetPALTV
;
3303 tempbx
&= (SetCHTVOverScan
|
3308 if (pVBInfo
->IF_DEF_LVDS
== 0) {
3309 if (pVBInfo
->VBInfo
& SetCRT2ToSCART
)
3313 if (pVBInfo
->IF_DEF_YPbPr
== 1) {
3314 if (pVBInfo
->VBInfo
& SetCRT2ToYPbPr
) {
3315 index1
= xgifb_reg_get(pVBInfo
->P3d4
, 0x35);
3316 index1
&= YPbPrMode
;
3318 if (index1
== YPbPrMode525i
)
3319 tempbx
|= SetYPbPrMode525i
;
3321 if (index1
== YPbPrMode525p
)
3322 tempbx
= tempbx
| SetYPbPrMode525p
;
3323 if (index1
== YPbPrMode750p
)
3324 tempbx
= tempbx
| SetYPbPrMode750p
;
3328 if (pVBInfo
->IF_DEF_HiVision
== 1) {
3329 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
)
3330 tempbx
= tempbx
| SetYPbPrMode1080i
| SetPALTV
;
3333 if (pVBInfo
->IF_DEF_LVDS
== 0) { /* shampoo */
3334 if ((pVBInfo
->VBInfo
& SetInSlaveMode
) &&
3335 (!(pVBInfo
->VBInfo
& SetNotSimuMode
)))
3336 tempbx
|= TVSimuMode
;
3338 if (!(tempbx
& SetPALTV
) &&
3340 (resinfo
== 8)) /* NTSC 1024x768, */
3341 tempbx
|= NTSC1024x768
;
3343 tempbx
|= RPLLDIV2XO
;
3345 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
) {
3346 if (pVBInfo
->VBInfo
& SetInSlaveMode
)
3347 tempbx
&= (~RPLLDIV2XO
);
3350 (SetYPbPrMode525p
| SetYPbPrMode750p
))
3351 tempbx
&= (~RPLLDIV2XO
);
3352 else if (!(pVBInfo
->VBType
&
3358 if (tempbx
& TVSimuMode
)
3359 tempbx
&= (~RPLLDIV2XO
);
3364 pVBInfo
->TVInfo
= tempbx
;
3367 static unsigned char XGI_GetLCDInfo(unsigned short ModeNo
,
3368 unsigned short ModeIdIndex
, struct vb_device_info
*pVBInfo
)
3370 unsigned short temp
, tempax
, tempbx
, modeflag
, resinfo
= 0, LCDIdIndex
;
3372 pVBInfo
->LCDResInfo
= 0;
3373 pVBInfo
->LCDTypeInfo
= 0;
3374 pVBInfo
->LCDInfo
= 0;
3376 if (ModeNo
<= 0x13) {
3377 /* si+St_ModeFlag // */
3378 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
3380 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
3381 /* si+Ext_ResInfo // */
3382 resinfo
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
3385 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x36); /* Get LCD Res.Info */
3386 tempbx
= temp
& 0x0F;
3389 tempbx
= Panel1024x768
; /* default */
3391 /* LCD75 [2003/8/22] Vicent */
3392 if ((tempbx
== Panel1024x768
) || (tempbx
== Panel1280x1024
)) {
3393 if (pVBInfo
->VBInfo
& DriverMode
) {
3394 tempax
= xgifb_reg_get(pVBInfo
->P3d4
, 0x33);
3395 if (pVBInfo
->VBInfo
& SetCRT2ToLCDA
)
3398 tempax
= tempax
>> 4;
3400 if ((resinfo
== 6) || (resinfo
== 9)) {
3402 tempbx
|= PanelRef75Hz
;
3403 } else if ((resinfo
== 7) || (resinfo
== 8)) {
3405 tempbx
|= PanelRef75Hz
;
3410 pVBInfo
->LCDResInfo
= tempbx
;
3414 if (!(pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToLCDA
)))
3419 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x37);
3421 temp
&= (ScalingLCD
| LCDNonExpanding
| LCDSyncBit
| SetPWDEnable
);
3425 LCDIdIndex
= XGI_GetLCDCapPtr1(pVBInfo
);
3427 tempax
= pVBInfo
->LCDCapList
[LCDIdIndex
].LCD_Capability
;
3429 if (pVBInfo
->IF_DEF_LVDS
== 0) { /* shampoo */
3430 if (((pVBInfo
->VBType
& VB_XGI302LV
) || (pVBInfo
->VBType
3431 & VB_XGI301C
)) && (tempax
& LCDDualLink
)) {
3432 tempbx
|= SetLCDDualLink
;
3436 if (pVBInfo
->IF_DEF_LVDS
== 0) {
3437 if ((pVBInfo
->LCDResInfo
== Panel1400x1050
) && (pVBInfo
->VBInfo
3438 & SetCRT2ToLCD
) && (ModeNo
> 0x13) && (resinfo
3439 == 9) && (!(tempbx
& EnableScalingLCD
)))
3440 /* set to center in 1280x1024 LCDB for Panel1400x1050 */
3441 tempbx
|= SetLCDtoNonExpanding
;
3444 if (pVBInfo
->IF_DEF_ExpLink
== 1) {
3445 if (modeflag
& HalfDCLK
) {
3446 if (!(tempbx
& SetLCDtoNonExpanding
)) {
3447 tempbx
|= EnableLVDSDDA
;
3449 if (ModeNo
> 0x13) {
3450 if (pVBInfo
->LCDResInfo
3452 if (resinfo
== 4) {/* 512x384 */
3453 tempbx
|= EnableLVDSDDA
;
3461 if (pVBInfo
->VBInfo
& SetInSlaveMode
) {
3462 if (pVBInfo
->VBInfo
& SetNotSimuMode
)
3463 tempbx
|= LCDVESATiming
;
3465 tempbx
|= LCDVESATiming
;
3468 pVBInfo
->LCDInfo
= tempbx
;
3470 if (pVBInfo
->IF_DEF_LVDS
== 0) {
3471 if (tempax
& (LockLCDBToA
| StLCDBToA
)) {
3472 if (pVBInfo
->VBInfo
& SetInSlaveMode
) {
3473 if (!(tempax
& LockLCDBToA
)) {
3474 if (ModeNo
<= 0x13) {
3491 unsigned char XGI_SearchModeID(unsigned short ModeNo
,
3492 unsigned short *ModeIdIndex
, struct vb_device_info
*pVBInfo
)
3496 if (ModeNo
<= 0x13) {
3497 for (*ModeIdIndex
= 0;; (*ModeIdIndex
)++) {
3498 if (pVBInfo
->SModeIDTable
[*ModeIdIndex
].St_ModeID
==
3501 if (pVBInfo
->SModeIDTable
[*ModeIdIndex
].St_ModeID
==
3507 (*ModeIdIndex
)++; /* 400 lines */
3509 (*ModeIdIndex
) += 2; /* 400 lines */
3510 /* else 350 lines */
3512 for (*ModeIdIndex
= 0;; (*ModeIdIndex
)++) {
3513 if (pVBInfo
->EModeIDTable
[*ModeIdIndex
].Ext_ModeID
==
3516 if (pVBInfo
->EModeIDTable
[*ModeIdIndex
].Ext_ModeID
==
3525 static unsigned char XG21GPIODataTransfer(unsigned char ujDate
)
3527 unsigned char ujRet
= 0;
3528 unsigned char i
= 0;
3530 for (i
= 0; i
< 8; i
++) {
3532 ujRet
|= (ujDate
>> i
) & 1;
3538 /*----------------------------------------------------------------------------*/
3540 /* bl[5] : LVDS signal */
3541 /* bl[1] : LVDS backlight */
3542 /* bl[0] : LVDS VDD */
3543 /*----------------------------------------------------------------------------*/
3544 static unsigned char XGI_XG21GetPSCValue(struct vb_device_info
*pVBInfo
)
3546 unsigned char CR4A
, temp
;
3548 CR4A
= xgifb_reg_get(pVBInfo
->P3d4
, 0x4A);
3549 xgifb_reg_and(pVBInfo
->P3d4
, 0x4A, ~0x23); /* enable GPIO write */
3551 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x48);
3553 temp
= XG21GPIODataTransfer(temp
);
3555 xgifb_reg_set(pVBInfo
->P3d4
, 0x4A, CR4A
);
3559 /*----------------------------------------------------------------------------*/
3561 /* bl[5] : LVDS signal */
3562 /* bl[1] : LVDS backlight */
3563 /* bl[0] : LVDS VDD */
3564 /*----------------------------------------------------------------------------*/
3565 static unsigned char XGI_XG27GetPSCValue(struct vb_device_info
*pVBInfo
)
3567 unsigned char CR4A
, CRB4
, temp
;
3569 CR4A
= xgifb_reg_get(pVBInfo
->P3d4
, 0x4A);
3570 xgifb_reg_and(pVBInfo
->P3d4
, 0x4A, ~0x0C); /* enable GPIO write */
3572 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x48);
3576 xgifb_reg_set(pVBInfo
->P3d4
, 0x4A, CR4A
);
3577 CRB4
= xgifb_reg_get(pVBInfo
->P3d4
, 0xB4);
3578 temp
|= ((CRB4
& 0x04) << 3);
3582 /*----------------------------------------------------------------------------*/
3584 /* bl[5] : 1;LVDS signal on */
3585 /* bl[1] : 1;LVDS backlight on */
3586 /* bl[0] : 1:LVDS VDD on */
3587 /* bh: 100000b : clear bit 5, to set bit5 */
3588 /* 000010b : clear bit 1, to set bit1 */
3589 /* 000001b : clear bit 0, to set bit0 */
3590 /*----------------------------------------------------------------------------*/
3591 static void XGI_XG21BLSignalVDD(unsigned short tempbh
, unsigned short tempbl
,
3592 struct vb_device_info
*pVBInfo
)
3594 unsigned char CR4A
, temp
;
3596 CR4A
= xgifb_reg_get(pVBInfo
->P3d4
, 0x4A);
3599 xgifb_reg_and(pVBInfo
->P3d4
, 0x4A, ~tempbh
); /* enable GPIO write */
3601 if (tempbh
& 0x20) {
3602 temp
= (tempbl
>> 4) & 0x02;
3605 xgifb_reg_and_or(pVBInfo
->P3d4
, 0xB4, ~0x02, temp
);
3609 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x48);
3611 temp
= XG21GPIODataTransfer(temp
);
3614 xgifb_reg_set(pVBInfo
->P3d4
, 0x48, temp
);
3617 static void XGI_XG27BLSignalVDD(unsigned short tempbh
, unsigned short tempbl
,
3618 struct vb_device_info
*pVBInfo
)
3620 unsigned char CR4A
, temp
;
3621 unsigned short tempbh0
, tempbl0
;
3630 if (tempbh
& 0x20) {
3631 temp
= (tempbl
>> 4) & 0x02;
3634 xgifb_reg_and_or(pVBInfo
->P3d4
, 0xB4, ~0x02, temp
);
3637 xgifb_reg_and_or(pVBInfo
->P3d4
, 0xB4, ~tempbh0
, tempbl0
);
3639 CR4A
= xgifb_reg_get(pVBInfo
->P3d4
, 0x4A);
3643 tempbl
<<= 2; /* GPIOC,GPIOD */
3644 xgifb_reg_and(pVBInfo
->P3d4
, 0x4A, ~tempbh
); /* enable GPIO write */
3645 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x48, ~tempbh
, tempbl
);
3648 /* --------------------------------------------------------------------- */
3649 /* Function : XGI_XG21SetPanelDelay */
3653 /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
3654 /* : bl : 2 ; T2 : the duration signal on and Vdd on */
3655 /* : bl : 3 ; T3 : the duration between CPL off and signal off */
3656 /* : bl : 4 ; T4 : the duration signal off and Vdd off */
3657 /* --------------------------------------------------------------------- */
3658 static void XGI_XG21SetPanelDelay(struct xgifb_video_info
*xgifb_info
,
3659 unsigned short tempbl
,
3660 struct vb_device_info
*pVBInfo
)
3663 mdelay(xgifb_info
->lvds_data
.PSC_S1
);
3666 mdelay(xgifb_info
->lvds_data
.PSC_S2
);
3669 mdelay(xgifb_info
->lvds_data
.PSC_S3
);
3672 mdelay(xgifb_info
->lvds_data
.PSC_S4
);
3675 static void XGI_DisplayOn(struct xgifb_video_info
*xgifb_info
,
3676 struct xgi_hw_device_info
*pXGIHWDE
,
3677 struct vb_device_info
*pVBInfo
)
3680 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x01, 0xDF, 0x00);
3681 if (pXGIHWDE
->jChipType
== XG21
) {
3682 if (pVBInfo
->IF_DEF_LVDS
== 1) {
3683 if (!(XGI_XG21GetPSCValue(pVBInfo
) & 0x1)) {
3685 XGI_XG21BLSignalVDD(0x01, 0x01, pVBInfo
);
3686 XGI_XG21SetPanelDelay(xgifb_info
, 2, pVBInfo
);
3688 if (!(XGI_XG21GetPSCValue(pVBInfo
) & 0x20))
3689 /* LVDS signal on */
3690 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo
);
3691 XGI_XG21SetPanelDelay(xgifb_info
, 3, pVBInfo
);
3692 /* LVDS backlight on */
3693 XGI_XG21BLSignalVDD(0x02, 0x02, pVBInfo
);
3695 /* DVO/DVI signal on */
3696 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo
);
3701 if (pXGIHWDE
->jChipType
== XG27
) {
3702 if (pVBInfo
->IF_DEF_LVDS
== 1) {
3703 if (!(XGI_XG27GetPSCValue(pVBInfo
) & 0x1)) {
3705 XGI_XG27BLSignalVDD(0x01, 0x01, pVBInfo
);
3706 XGI_XG21SetPanelDelay(xgifb_info
, 2, pVBInfo
);
3708 if (!(XGI_XG27GetPSCValue(pVBInfo
) & 0x20))
3709 /* LVDS signal on */
3710 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo
);
3711 XGI_XG21SetPanelDelay(xgifb_info
, 3, pVBInfo
);
3712 /* LVDS backlight on */
3713 XGI_XG27BLSignalVDD(0x02, 0x02, pVBInfo
);
3715 /* DVO/DVI signal on */
3716 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo
);
3722 void XGI_DisplayOff(struct xgifb_video_info
*xgifb_info
,
3723 struct xgi_hw_device_info
*pXGIHWDE
,
3724 struct vb_device_info
*pVBInfo
)
3727 if (pXGIHWDE
->jChipType
== XG21
) {
3728 if (pVBInfo
->IF_DEF_LVDS
== 1) {
3729 /* LVDS backlight off */
3730 XGI_XG21BLSignalVDD(0x02, 0x00, pVBInfo
);
3731 XGI_XG21SetPanelDelay(xgifb_info
, 3, pVBInfo
);
3733 /* DVO/DVI signal off */
3734 XGI_XG21BLSignalVDD(0x20, 0x00, pVBInfo
);
3738 if (pXGIHWDE
->jChipType
== XG27
) {
3739 if ((XGI_XG27GetPSCValue(pVBInfo
) & 0x2)) {
3740 /* LVDS backlight off */
3741 XGI_XG27BLSignalVDD(0x02, 0x00, pVBInfo
);
3742 XGI_XG21SetPanelDelay(xgifb_info
, 3, pVBInfo
);
3745 if (pVBInfo
->IF_DEF_LVDS
== 0)
3746 /* DVO/DVI signal off */
3747 XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo
);
3750 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x01, 0xDF, 0x20);
3753 static void XGI_WaitDisply(struct vb_device_info
*pVBInfo
)
3755 while ((inb(pVBInfo
->P3da
) & 0x01))
3758 while (!(inb(pVBInfo
->P3da
) & 0x01))
3762 static void XGI_AutoThreshold(struct vb_device_info
*pVBInfo
)
3764 xgifb_reg_or(pVBInfo
->Part1Port
, 0x01, 0x40);
3767 static void XGI_SaveCRT2Info(unsigned short ModeNo
,
3768 struct vb_device_info
*pVBInfo
)
3770 unsigned short temp1
, temp2
;
3772 /* reserve CR34 for CRT1 Mode No */
3773 xgifb_reg_set(pVBInfo
->P3d4
, 0x34, ModeNo
);
3774 temp1
= (pVBInfo
->VBInfo
& SetInSlaveMode
) >> 8;
3775 temp2
= ~(SetInSlaveMode
>> 8);
3776 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x31, temp2
, temp1
);
3779 static void XGI_GetCRT2ResInfo(unsigned short ModeNo
,
3780 unsigned short ModeIdIndex
,
3781 struct vb_device_info
*pVBInfo
)
3783 unsigned short xres
, yres
, modeflag
, resindex
;
3785 resindex
= XGI_GetResInfo(ModeNo
, ModeIdIndex
, pVBInfo
);
3786 if (ModeNo
<= 0x13) {
3787 xres
= pVBInfo
->StResInfo
[resindex
].HTotal
;
3788 yres
= pVBInfo
->StResInfo
[resindex
].VTotal
;
3790 xres
= pVBInfo
->ModeResInfo
[resindex
].HTotal
; /* xres->ax */
3791 yres
= pVBInfo
->ModeResInfo
[resindex
].VTotal
; /* yres->bx */
3792 /* si+St_ModeFlag */
3793 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
3795 if (modeflag
& HalfDCLK
)
3798 if (modeflag
& DoubleScanMode
)
3802 if (pVBInfo
->VBInfo
& SetCRT2ToLCD
) {
3803 if (pVBInfo
->IF_DEF_LVDS
== 0) {
3804 if (pVBInfo
->LCDResInfo
== Panel1600x1200
) {
3805 if (!(pVBInfo
->LCDInfo
& LCDVESATiming
)) {
3811 if (pVBInfo
->LCDResInfo
== Panel1280x1024
) {
3814 else if (yres
== 350)
3817 if (pVBInfo
->LCDInfo
& LCDVESATiming
) {
3823 if (pVBInfo
->LCDResInfo
== Panel1024x768
) {
3824 if (!(pVBInfo
->LCDInfo
& LCDVESATiming
)) {
3825 if (!(pVBInfo
->LCDInfo
3826 & LCDNonExpanding
)) {
3829 else if (yres
== 400)
3831 else if (yres
== 480)
3842 pVBInfo
->VGAHDE
= xres
;
3843 pVBInfo
->HDE
= xres
;
3844 pVBInfo
->VGAVDE
= yres
;
3845 pVBInfo
->VDE
= yres
;
3848 static unsigned char XGI_IsLCDDualLink(struct vb_device_info
*pVBInfo
)
3851 if ((pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToLCDA
)) &&
3852 (pVBInfo
->LCDInfo
& SetLCDDualLink
)) /* shampoo0129 */
3858 static void XGI_GetRAMDAC2DATA(unsigned short ModeNo
,
3859 unsigned short ModeIdIndex
,
3860 unsigned short RefreshRateTableIndex
,
3861 struct vb_device_info
*pVBInfo
)
3863 unsigned short tempax
, tempbx
, temp1
, temp2
, modeflag
= 0, tempcx
,
3864 StandTableIndex
, CRT1Index
;
3866 pVBInfo
->RVBHCMAX
= 1;
3867 pVBInfo
->RVBHCFACT
= 1;
3869 if (ModeNo
<= 0x13) {
3870 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
3871 StandTableIndex
= XGI_GetModePtr(ModeNo
, ModeIdIndex
, pVBInfo
);
3872 tempax
= pVBInfo
->StandTable
[StandTableIndex
].CRTC
[0];
3873 tempbx
= pVBInfo
->StandTable
[StandTableIndex
].CRTC
[6];
3874 temp1
= pVBInfo
->StandTable
[StandTableIndex
].CRTC
[7];
3876 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
3877 CRT1Index
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].
3879 CRT1Index
&= IndexMask
;
3880 temp1
= (unsigned short) pVBInfo
->
3881 XGINEWUB_CRT1Table
[CRT1Index
].CR
[0];
3882 temp2
= (unsigned short) pVBInfo
->
3883 XGINEWUB_CRT1Table
[CRT1Index
].CR
[5];
3884 tempax
= (temp1
& 0xFF) | ((temp2
& 0x03) << 8);
3885 tempbx
= (unsigned short) pVBInfo
->
3886 XGINEWUB_CRT1Table
[CRT1Index
].CR
[8];
3887 tempcx
= (unsigned short) pVBInfo
->
3888 XGINEWUB_CRT1Table
[CRT1Index
].CR
[14] << 8;
3890 tempcx
= tempcx
<< 2;
3892 temp1
= (unsigned short) pVBInfo
->
3893 XGINEWUB_CRT1Table
[CRT1Index
].CR
[9];
3903 if (modeflag
& Charx8Dot
)
3908 pVBInfo
->VGAHT
= tempax
;
3909 pVBInfo
->HT
= tempax
;
3911 pVBInfo
->VGAVT
= tempbx
;
3912 pVBInfo
->VT
= tempbx
;
3915 static void XGI_GetCRT2Data(unsigned short ModeNo
, unsigned short ModeIdIndex
,
3916 unsigned short RefreshRateTableIndex
,
3917 struct vb_device_info
*pVBInfo
)
3919 unsigned short tempax
= 0, tempbx
, modeflag
, resinfo
;
3921 struct XGI_LCDDataStruct
*LCDPtr
= NULL
;
3922 struct XGI_TVDataStruct
*TVPtr
= NULL
;
3924 if (ModeNo
<= 0x13) {
3926 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
3927 resinfo
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ResInfo
;
3929 /* si+Ext_ResInfo */
3930 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
3931 resinfo
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
3934 pVBInfo
->NewFlickerMode
= 0;
3935 pVBInfo
->RVBHRS
= 50;
3937 if (pVBInfo
->VBInfo
& SetCRT2ToRAMDAC
) {
3938 XGI_GetRAMDAC2DATA(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
3945 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToLCDA
)) {
3946 LCDPtr
= (struct XGI_LCDDataStruct
*) XGI_GetLcdPtr(tempbx
,
3947 ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
3950 pVBInfo
->RVBHCMAX
= LCDPtr
->RVBHCMAX
;
3951 pVBInfo
->RVBHCFACT
= LCDPtr
->RVBHCFACT
;
3952 pVBInfo
->VGAHT
= LCDPtr
->VGAHT
;
3953 pVBInfo
->VGAVT
= LCDPtr
->VGAVT
;
3954 pVBInfo
->HT
= LCDPtr
->LCDHT
;
3955 pVBInfo
->VT
= LCDPtr
->LCDVT
;
3957 if (pVBInfo
->LCDResInfo
== Panel1024x768
) {
3961 if (!(pVBInfo
->LCDInfo
& LCDVESATiming
)) {
3962 if (pVBInfo
->VGAVDE
== 357)
3964 else if (pVBInfo
->VGAVDE
== 420)
3966 else if (pVBInfo
->VGAVDE
== 525)
3968 else if (pVBInfo
->VGAVDE
== 600)
3974 } else if (pVBInfo
->LCDResInfo
== Panel1024x768x75
) {
3977 } else if (pVBInfo
->LCDResInfo
== Panel1280x1024
) {
3979 if (pVBInfo
->VGAVDE
== 360)
3981 else if (pVBInfo
->VGAVDE
== 375)
3983 else if (pVBInfo
->VGAVDE
== 405)
3987 } else if (pVBInfo
->LCDResInfo
== Panel1280x1024x75
) {
3990 } else if (pVBInfo
->LCDResInfo
== Panel1280x960
) {
3992 if (pVBInfo
->VGAVDE
== 350)
3994 else if (pVBInfo
->VGAVDE
== 400)
3996 else if (pVBInfo
->VGAVDE
== 1024)
4000 } else if (pVBInfo
->LCDResInfo
== Panel1400x1050
) {
4004 if (pVBInfo
->VGAVDE
== 1024) {
4008 } else if (pVBInfo
->LCDResInfo
== Panel1600x1200
) {
4010 tempbx
= 1200; /* alan 10/14/2003 */
4011 if (!(pVBInfo
->LCDInfo
& LCDVESATiming
)) {
4012 if (pVBInfo
->VGAVDE
== 350)
4014 else if (pVBInfo
->VGAVDE
== 400)
4019 if (pVBInfo
->LCDInfo
& LCDNonExpanding
) {
4020 tempax
= pVBInfo
->VGAHDE
;
4021 tempbx
= pVBInfo
->VGAVDE
;
4024 pVBInfo
->HDE
= tempax
;
4025 pVBInfo
->VDE
= tempbx
;
4029 if (pVBInfo
->VBInfo
& (SetCRT2ToTV
)) {
4031 TVPtr
= (struct XGI_TVDataStruct
*) XGI_GetTVPtr(tempbx
,
4032 ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
4035 pVBInfo
->RVBHCMAX
= TVPtr
->RVBHCMAX
;
4036 pVBInfo
->RVBHCFACT
= TVPtr
->RVBHCFACT
;
4037 pVBInfo
->VGAHT
= TVPtr
->VGAHT
;
4038 pVBInfo
->VGAVT
= TVPtr
->VGAVT
;
4039 pVBInfo
->HDE
= TVPtr
->TVHDE
;
4040 pVBInfo
->VDE
= TVPtr
->TVVDE
;
4041 pVBInfo
->RVBHRS
= TVPtr
->RVBHRS
;
4042 pVBInfo
->NewFlickerMode
= TVPtr
->FlickerMode
;
4044 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
) {
4045 if (resinfo
== 0x08)
4046 pVBInfo
->NewFlickerMode
= 0x40;
4047 else if (resinfo
== 0x09)
4048 pVBInfo
->NewFlickerMode
= 0x40;
4049 else if (resinfo
== 0x12)
4050 pVBInfo
->NewFlickerMode
= 0x40;
4052 if (pVBInfo
->VGAVDE
== 350)
4053 pVBInfo
->TVInfo
|= TVSimuMode
;
4058 if (pVBInfo
->VBInfo
& SetInSlaveMode
) {
4059 if (pVBInfo
->TVInfo
& TVSimuMode
) {
4063 if (!(modeflag
& Charx8Dot
)) {
4064 tempax
= StHiTextTVHT
;
4065 tempbx
= StHiTextTVVT
;
4069 } else if (pVBInfo
->VBInfo
& SetCRT2ToYPbPr
) {
4070 if (pVBInfo
->TVInfo
& SetYPbPrMode750p
) {
4071 tempax
= YPbPrTV750pHT
; /* Ext750pTVHT */
4072 tempbx
= YPbPrTV750pVT
; /* Ext750pTVVT */
4075 if (pVBInfo
->TVInfo
& SetYPbPrMode525p
) {
4076 tempax
= YPbPrTV525pHT
; /* Ext525pTVHT */
4077 tempbx
= YPbPrTV525pVT
; /* Ext525pTVVT */
4078 } else if (pVBInfo
->TVInfo
& SetYPbPrMode525i
) {
4079 tempax
= YPbPrTV525iHT
; /* Ext525iTVHT */
4080 tempbx
= YPbPrTV525iVT
; /* Ext525iTVVT */
4081 if (pVBInfo
->TVInfo
& NTSC1024x768
)
4082 tempax
= NTSC1024x768HT
;
4087 if (!(pVBInfo
->TVInfo
& SetPALTV
)) {
4090 if (pVBInfo
->TVInfo
& NTSC1024x768
)
4091 tempax
= NTSC1024x768HT
;
4095 pVBInfo
->HT
= tempax
;
4096 pVBInfo
->VT
= tempbx
;
4101 static void XGI_SetCRT2VCLK(unsigned short ModeNo
, unsigned short ModeIdIndex
,
4102 unsigned short RefreshRateTableIndex
,
4103 struct vb_device_info
*pVBInfo
)
4105 unsigned char di_0
, di_1
, tempal
;
4107 tempal
= XGI_GetVCLKPtr(RefreshRateTableIndex
, ModeNo
, ModeIdIndex
,
4109 XGI_GetVCLKLen(tempal
, &di_0
, &di_1
, pVBInfo
);
4110 XGI_GetLCDVCLKPtr(&di_0
, &di_1
, pVBInfo
);
4112 if (pVBInfo
->VBType
& VB_XGI301
) { /* shampoo 0129 */
4114 xgifb_reg_set(pVBInfo
->Part4Port
, 0x0A, 0x10);
4115 xgifb_reg_set(pVBInfo
->Part4Port
, 0x0B, di_1
);
4116 xgifb_reg_set(pVBInfo
->Part4Port
, 0x0A, di_0
);
4117 } else { /* 301b/302b/301lv/302lv */
4118 xgifb_reg_set(pVBInfo
->Part4Port
, 0x0A, di_0
);
4119 xgifb_reg_set(pVBInfo
->Part4Port
, 0x0B, di_1
);
4122 xgifb_reg_set(pVBInfo
->Part4Port
, 0x00, 0x12);
4124 if (pVBInfo
->VBInfo
& SetCRT2ToRAMDAC
)
4125 xgifb_reg_or(pVBInfo
->Part4Port
, 0x12, 0x28);
4127 xgifb_reg_or(pVBInfo
->Part4Port
, 0x12, 0x08);
4130 static unsigned short XGI_GetColorDepth(unsigned short ModeNo
,
4131 unsigned short ModeIdIndex
, struct vb_device_info
*pVBInfo
)
4133 unsigned short ColorDepth
[6] = { 1, 2, 4, 4, 6, 8 };
4135 unsigned short modeflag
;
4138 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
4140 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
4142 index
= (modeflag
& ModeInfoFlag
) - ModeEGA
;
4147 return ColorDepth
[index
];
4150 static unsigned short XGI_GetOffset(unsigned short ModeNo
,
4151 unsigned short ModeIdIndex
,
4152 unsigned short RefreshRateTableIndex
,
4153 struct xgi_hw_device_info
*HwDeviceExtension
,
4154 struct vb_device_info
*pVBInfo
)
4156 unsigned short temp
, colordepth
, modeinfo
, index
, infoflag
,
4157 ColorDepth
[] = { 0x01, 0x02, 0x04 };
4159 modeinfo
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeInfo
;
4163 infoflag
= pVBInfo
->
4164 RefIndex
[RefreshRateTableIndex
].Ext_InfoFlag
;
4166 index
= (modeinfo
>> 8) & 0xFF;
4168 temp
= pVBInfo
->ScreenOffset
[index
];
4170 if (infoflag
& InterlaceMode
)
4173 colordepth
= XGI_GetColorDepth(ModeNo
, ModeIdIndex
, pVBInfo
);
4175 if ((ModeNo
>= 0x7C) && (ModeNo
<= 0x7E)) {
4176 temp
= ModeNo
- 0x7C;
4177 colordepth
= ColorDepth
[temp
];
4179 if (infoflag
& InterlaceMode
)
4181 return temp
* colordepth
;
4183 return temp
* colordepth
;
4187 static void XGI_SetCRT2Offset(unsigned short ModeNo
,
4188 unsigned short ModeIdIndex
,
4189 unsigned short RefreshRateTableIndex
,
4190 struct xgi_hw_device_info
*HwDeviceExtension
,
4191 struct vb_device_info
*pVBInfo
)
4193 unsigned short offset
;
4196 if (pVBInfo
->VBInfo
& SetInSlaveMode
)
4199 offset
= XGI_GetOffset(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
4200 HwDeviceExtension
, pVBInfo
);
4201 temp
= (unsigned char) (offset
& 0xFF);
4202 xgifb_reg_set(pVBInfo
->Part1Port
, 0x07, temp
);
4203 temp
= (unsigned char) ((offset
& 0xFF00) >> 8);
4204 xgifb_reg_set(pVBInfo
->Part1Port
, 0x09, temp
);
4205 temp
= (unsigned char) (((offset
>> 3) & 0xFF) + 1);
4206 xgifb_reg_set(pVBInfo
->Part1Port
, 0x03, temp
);
4209 static void XGI_SetCRT2FIFO(struct vb_device_info
*pVBInfo
)
4211 /* threshold high ,disable auto threshold */
4212 xgifb_reg_set(pVBInfo
->Part1Port
, 0x01, 0x3B);
4213 /* threshold low default 04h */
4214 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x02, ~(0x3F), 0x04);
4217 static void XGI_PreSetGroup1(unsigned short ModeNo
, unsigned short ModeIdIndex
,
4218 struct xgi_hw_device_info
*HwDeviceExtension
,
4219 unsigned short RefreshRateTableIndex
,
4220 struct vb_device_info
*pVBInfo
)
4222 unsigned short tempcx
= 0, CRT1Index
= 0, resinfo
= 0;
4224 if (ModeNo
> 0x13) {
4225 CRT1Index
= pVBInfo
->
4226 RefIndex
[RefreshRateTableIndex
].Ext_CRT1CRTC
;
4227 CRT1Index
&= IndexMask
;
4228 resinfo
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
4231 XGI_SetCRT2Offset(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
4232 HwDeviceExtension
, pVBInfo
);
4233 XGI_SetCRT2FIFO(pVBInfo
);
4235 for (tempcx
= 4; tempcx
< 7; tempcx
++)
4236 xgifb_reg_set(pVBInfo
->Part1Port
, tempcx
, 0x0);
4238 xgifb_reg_set(pVBInfo
->Part1Port
, 0x50, 0x00);
4239 xgifb_reg_set(pVBInfo
->Part1Port
, 0x02, 0x44); /* temp 0206 */
4242 static void XGI_SetGroup1(unsigned short ModeNo
, unsigned short ModeIdIndex
,
4243 struct xgi_hw_device_info
*HwDeviceExtension
,
4244 unsigned short RefreshRateTableIndex
,
4245 struct vb_device_info
*pVBInfo
)
4247 unsigned short temp
= 0, tempax
= 0, tempbx
= 0, tempcx
= 0,
4248 pushbx
= 0, CRT1Index
= 0, modeflag
, resinfo
= 0;
4250 if (ModeNo
> 0x13) {
4251 CRT1Index
= pVBInfo
->
4252 RefIndex
[RefreshRateTableIndex
].Ext_CRT1CRTC
;
4253 CRT1Index
&= IndexMask
;
4254 resinfo
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
4258 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
4260 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
4262 /* bainy change table name */
4263 if (modeflag
& HalfDCLK
) {
4264 /* BTVGA2HT 0x08,0x09 */
4265 temp
= (pVBInfo
->VGAHT
/ 2 - 1) & 0x0FF;
4266 xgifb_reg_set(pVBInfo
->Part1Port
, 0x08, temp
);
4267 temp
= (((pVBInfo
->VGAHT
/ 2 - 1) & 0xFF00) >> 8) << 4;
4268 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x09, ~0x0F0, temp
);
4269 /* BTVGA2HDEE 0x0A,0x0C */
4270 temp
= (pVBInfo
->VGAHDE
/ 2 + 16) & 0x0FF;
4271 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0A, temp
);
4272 tempcx
= ((pVBInfo
->VGAHT
- pVBInfo
->VGAHDE
) / 2) >> 2;
4273 pushbx
= pVBInfo
->VGAHDE
/ 2 + 16;
4274 tempcx
= tempcx
>> 1;
4275 tempbx
= pushbx
+ tempcx
; /* bx BTVGA@HRS 0x0B,0x0C */
4278 if (pVBInfo
->VBInfo
& SetCRT2ToRAMDAC
) {
4279 tempbx
= pVBInfo
->XGINEWUB_CRT1Table
[CRT1Index
].CR
[4];
4280 tempbx
|= ((pVBInfo
->
4281 XGINEWUB_CRT1Table
[CRT1Index
].CR
[14] &
4283 tempbx
= (tempbx
- 3) << 3; /* (VGAHRS-3)*8 */
4284 tempcx
= pVBInfo
->XGINEWUB_CRT1Table
[CRT1Index
].CR
[5];
4286 temp
= pVBInfo
->XGINEWUB_CRT1Table
[CRT1Index
].CR
[15];
4287 temp
= (temp
& 0x04) << (5 - 2); /* VGAHRE D[5] */
4288 tempcx
= ((tempcx
| temp
) - 3) << 3; /* (VGAHRE-3)*8 */
4294 if (tempcx
> (pVBInfo
->VGAHT
/ 2))
4295 tempcx
= pVBInfo
->VGAHT
/ 2;
4297 temp
= tempbx
& 0x00FF;
4299 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0B, temp
);
4301 temp
= (pVBInfo
->VGAHT
- 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */
4302 xgifb_reg_set(pVBInfo
->Part1Port
, 0x08, temp
);
4303 temp
= (((pVBInfo
->VGAHT
- 1) & 0xFF00) >> 8) << 4;
4304 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x09, ~0x0F0, temp
);
4305 /* BTVGA2HDEE 0x0A,0x0C */
4306 temp
= (pVBInfo
->VGAHDE
+ 16) & 0x0FF;
4307 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0A, temp
);
4308 tempcx
= (pVBInfo
->VGAHT
- pVBInfo
->VGAHDE
) >> 2; /* cx */
4309 pushbx
= pVBInfo
->VGAHDE
+ 16;
4310 tempcx
= tempcx
>> 1;
4311 tempbx
= pushbx
+ tempcx
; /* bx BTVGA@HRS 0x0B,0x0C */
4314 if (pVBInfo
->VBInfo
& SetCRT2ToRAMDAC
) {
4315 tempbx
= pVBInfo
->XGINEWUB_CRT1Table
[CRT1Index
].CR
[3];
4316 tempbx
|= ((pVBInfo
->
4317 XGINEWUB_CRT1Table
[CRT1Index
].CR
[5] &
4319 tempbx
= (tempbx
- 3) << 3; /* (VGAHRS-3)*8 */
4320 tempcx
= pVBInfo
->XGINEWUB_CRT1Table
[CRT1Index
].CR
[4];
4322 temp
= pVBInfo
->XGINEWUB_CRT1Table
[CRT1Index
].CR
[6];
4323 temp
= (temp
& 0x04) << (5 - 2); /* VGAHRE D[5] */
4324 tempcx
= ((tempcx
| temp
) - 3) << 3; /* (VGAHRE-3)*8 */
4329 if (tempcx
> pVBInfo
->VGAHT
)
4330 tempcx
= pVBInfo
->VGAHT
;
4332 temp
= tempbx
& 0x00FF;
4333 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0B, temp
);
4336 tempax
= (tempax
& 0x00FF) | (tempbx
& 0xFF00);
4338 tempbx
= (tempbx
& 0x00FF) | ((tempbx
& 0xFF00) << 4);
4339 tempax
|= (tempbx
& 0xFF00);
4340 temp
= (tempax
& 0xFF00) >> 8;
4341 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0C, temp
);
4342 temp
= tempcx
& 0x00FF;
4343 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0D, temp
);
4344 tempcx
= (pVBInfo
->VGAVT
- 1);
4345 temp
= tempcx
& 0x00FF;
4347 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0E, temp
);
4348 tempbx
= pVBInfo
->VGAVDE
- 1;
4349 temp
= tempbx
& 0x00FF;
4350 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0F, temp
);
4351 temp
= ((tempbx
& 0xFF00) << 3) >> 8;
4352 temp
|= ((tempcx
& 0xFF00) >> 8);
4353 xgifb_reg_set(pVBInfo
->Part1Port
, 0x12, temp
);
4355 tempax
= pVBInfo
->VGAVDE
;
4356 tempbx
= pVBInfo
->VGAVDE
;
4357 tempcx
= pVBInfo
->VGAVT
;
4358 /* BTVGA2VRS 0x10,0x11 */
4359 tempbx
= (pVBInfo
->VGAVT
+ pVBInfo
->VGAVDE
) >> 1;
4360 /* BTVGA2VRE 0x11 */
4361 tempcx
= ((pVBInfo
->VGAVT
- pVBInfo
->VGAVDE
) >> 4) + tempbx
+ 1;
4363 if (pVBInfo
->VBInfo
& SetCRT2ToRAMDAC
) {
4364 tempbx
= pVBInfo
->XGINEWUB_CRT1Table
[CRT1Index
].CR
[10];
4365 temp
= pVBInfo
->XGINEWUB_CRT1Table
[CRT1Index
].CR
[9];
4373 temp
= pVBInfo
->XGINEWUB_CRT1Table
[CRT1Index
].CR
[14];
4378 temp
= pVBInfo
->XGINEWUB_CRT1Table
[CRT1Index
].CR
[11];
4379 tempcx
= (tempcx
& 0xFF00) | (temp
& 0x00FF);
4382 temp
= tempbx
& 0x00FF;
4383 xgifb_reg_set(pVBInfo
->Part1Port
, 0x10, temp
);
4384 temp
= ((tempbx
& 0xFF00) >> 8) << 4;
4385 temp
= ((tempcx
& 0x000F) | (temp
));
4386 xgifb_reg_set(pVBInfo
->Part1Port
, 0x11, temp
);
4389 if (modeflag
& DoubleScanMode
)
4392 if (modeflag
& HalfDCLK
)
4395 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x2C, ~0x0C0, tempax
);
4398 static unsigned short XGI_GetVGAHT2(struct vb_device_info
*pVBInfo
)
4400 unsigned long tempax
, tempbx
;
4402 tempbx
= ((pVBInfo
->VGAVT
- pVBInfo
->VGAVDE
) * pVBInfo
->RVBHCMAX
)
4404 tempax
= (pVBInfo
->VT
- pVBInfo
->VDE
) * pVBInfo
->RVBHCFACT
;
4405 tempax
= (tempax
* pVBInfo
->HT
) / tempbx
;
4407 return (unsigned short) tempax
;
4410 static void XGI_SetLockRegs(unsigned short ModeNo
, unsigned short ModeIdIndex
,
4411 struct xgi_hw_device_info
*HwDeviceExtension
,
4412 unsigned short RefreshRateTableIndex
,
4413 struct vb_device_info
*pVBInfo
)
4415 unsigned short push1
, push2
, tempax
, tempbx
= 0, tempcx
, temp
, resinfo
,
4416 modeflag
, CRT1Index
;
4418 if (ModeNo
<= 0x13) {
4420 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
4421 resinfo
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ResInfo
;
4423 /* si+Ext_ResInfo */
4424 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
4425 resinfo
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
4426 CRT1Index
= pVBInfo
->
4427 RefIndex
[RefreshRateTableIndex
].Ext_CRT1CRTC
;
4428 CRT1Index
&= IndexMask
;
4431 if (!(pVBInfo
->VBInfo
& SetInSlaveMode
))
4434 temp
= 0xFF; /* set MAX HT */
4435 xgifb_reg_set(pVBInfo
->Part1Port
, 0x03, temp
);
4438 if (pVBInfo
->VBType
& (VB_XGI301LV
| VB_XGI302LV
| VB_XGI301C
))
4439 modeflag
|= Charx8Dot
;
4441 tempax
= pVBInfo
->VGAHDE
; /* 0x04 Horizontal Display End */
4443 if (modeflag
& HalfDCLK
)
4444 tempax
= tempax
>> 1;
4446 tempax
= (tempax
/ tempcx
) - 1;
4447 tempbx
|= ((tempax
& 0x00FF) << 8);
4448 temp
= tempax
& 0x00FF;
4449 xgifb_reg_set(pVBInfo
->Part1Port
, 0x04, temp
);
4451 temp
= (tempbx
& 0xFF00) >> 8;
4453 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
4454 if (!(pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
| VB_XGI301LV
4455 | VB_XGI302LV
| VB_XGI301C
)))
4458 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
) {
4459 if (pVBInfo
->VBType
& VB_XGI301LV
) {
4460 if (pVBInfo
->VBExtInfo
== VB_YPbPr1080i
) {
4464 } else if (resinfo
== 7) {
4470 /* 0x05 Horizontal Display Start */
4471 xgifb_reg_set(pVBInfo
->Part1Port
, 0x05, temp
);
4472 /* 0x06 Horizontal Blank end */
4473 xgifb_reg_set(pVBInfo
->Part1Port
, 0x06, 0x03);
4475 if (!(pVBInfo
->VBInfo
& DisableCRT2Display
)) { /* 030226 bainy */
4476 if (pVBInfo
->VBInfo
& SetCRT2ToTV
)
4477 tempax
= pVBInfo
->VGAHT
;
4479 tempax
= XGI_GetVGAHT2(pVBInfo
);
4482 if (tempax
>= pVBInfo
->VGAHT
)
4483 tempax
= pVBInfo
->VGAHT
;
4485 if (modeflag
& HalfDCLK
)
4486 tempax
= tempax
>> 1;
4488 tempax
= (tempax
/ tempcx
) - 5;
4489 tempcx
= tempax
; /* 20030401 0x07 horizontal Retrace Start */
4490 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
) {
4491 temp
= (tempbx
& 0x00FF) - 1;
4492 if (!(modeflag
& HalfDCLK
)) {
4494 if (pVBInfo
->TVInfo
& TVSimuMode
) {
4501 tempbx
= (tempbx
& 0xFF00) >> 8;
4502 tempcx
= (tempcx
+ tempbx
) >> 1;
4503 temp
= (tempcx
& 0x00FF) + 2;
4505 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
4507 if (!(modeflag
& HalfDCLK
)) {
4508 if ((modeflag
& Charx8Dot
)) {
4510 if (pVBInfo
->VGAHDE
>= 800)
4514 } else if (!(modeflag
& HalfDCLK
)) {
4516 if (pVBInfo
->LCDResInfo
!= Panel1280x960
&&
4517 pVBInfo
->VGAHDE
>= 800) {
4519 if (pVBInfo
->ModeType
== ModeEGA
&&
4520 pVBInfo
->VGAVDE
== 1024) {
4522 if (pVBInfo
->LCDResInfo
!=
4527 if (pVBInfo
->VGAHDE
>= 1280 &&
4528 pVBInfo
->LCDResInfo
!= Panel1280x960
&&
4529 (pVBInfo
->LCDInfo
& LCDNonExpanding
))
4535 /* 0x07 Horizontal Retrace Start */
4536 xgifb_reg_set(pVBInfo
->Part1Port
, 0x07, temp
);
4537 /* 0x08 Horizontal Retrace End */
4538 xgifb_reg_set(pVBInfo
->Part1Port
, 0x08, 0);
4540 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
4541 if (pVBInfo
->TVInfo
& TVSimuMode
) {
4542 if ((ModeNo
== 0x06) || (ModeNo
== 0x10) || (ModeNo
4543 == 0x11) || (ModeNo
== 0x13) || (ModeNo
4545 xgifb_reg_set(pVBInfo
->Part1Port
, 0x07, 0x5b);
4546 xgifb_reg_set(pVBInfo
->Part1Port
, 0x08, 0x03);
4549 if ((ModeNo
== 0x00) || (ModeNo
== 0x01)) {
4550 if (pVBInfo
->TVInfo
& SetNTSCTV
) {
4551 xgifb_reg_set(pVBInfo
->Part1Port
,
4553 xgifb_reg_set(pVBInfo
->Part1Port
,
4556 xgifb_reg_set(pVBInfo
->Part1Port
,
4558 xgifb_reg_set(pVBInfo
->Part1Port
,
4560 xgifb_reg_set(pVBInfo
->Part1Port
,
4565 if ((ModeNo
== 0x02) || (ModeNo
== 0x03) || (ModeNo
4567 if (pVBInfo
->TVInfo
& SetNTSCTV
) {
4568 xgifb_reg_set(pVBInfo
->Part1Port
,
4570 xgifb_reg_set(pVBInfo
->Part1Port
,
4573 xgifb_reg_set(pVBInfo
->Part1Port
,
4575 xgifb_reg_set(pVBInfo
->Part1Port
,
4577 xgifb_reg_set(pVBInfo
->Part1Port
,
4582 if ((ModeNo
== 0x04) || (ModeNo
== 0x05) || (ModeNo
4583 == 0x0D) || (ModeNo
== 0x50)) {
4584 if (pVBInfo
->TVInfo
& SetNTSCTV
) {
4585 xgifb_reg_set(pVBInfo
->Part1Port
,
4587 xgifb_reg_set(pVBInfo
->Part1Port
,
4590 xgifb_reg_set(pVBInfo
->Part1Port
,
4592 xgifb_reg_set(pVBInfo
->Part1Port
,
4599 xgifb_reg_set(pVBInfo
->Part1Port
, 0x18, 0x03); /* 0x18 SR0B */
4600 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x19, 0xF0, 0x00);
4601 xgifb_reg_set(pVBInfo
->Part1Port
, 0x09, 0xFF); /* 0x09 Set Max VT */
4603 tempbx
= pVBInfo
->VGAVT
;
4606 tempbx
= pVBInfo
->VGAVDE
; /* 0x0E Virtical Display End */
4621 if (pVBInfo
->VBInfo
& SetCRT2ToLCD
) {
4622 if (pVBInfo
->LCDResInfo
== Panel1024x768
) {
4623 if (!(pVBInfo
->LCDInfo
& LCDVESATiming
)) {
4632 temp
= tempbx
& 0x00FF;
4634 temp
= tempbx
& 0x00FF;
4635 /* 0x10 vertical Blank Start */
4636 xgifb_reg_set(pVBInfo
->Part1Port
, 0x10, temp
);
4639 temp
= tempbx
& 0x00FF;
4640 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0E, temp
);
4642 if (tempbx
& 0x0100)
4647 if (modeflag
& DoubleScanMode
)
4650 if (tempbx
& 0x0200)
4653 temp
= (tempax
& 0xFF00) >> 8;
4654 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0B, temp
);
4656 if (tempbx
& 0x0400)
4659 /* 0x11 Vertival Blank End */
4660 xgifb_reg_set(pVBInfo
->Part1Port
, 0x11, 0x00);
4663 tempax
-= tempbx
; /* 0x0C Vertical Retrace Start */
4664 tempax
= tempax
>> 2;
4665 push1
= tempax
; /* push ax */
4667 if (resinfo
!= 0x09) {
4668 tempax
= tempax
<< 1;
4672 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
) {
4673 if (pVBInfo
->VBType
& VB_XGI301LV
) {
4674 if (pVBInfo
->TVInfo
& SetYPbPrMode1080i
) {
4677 if (pVBInfo
->TVInfo
& TVSimuMode
) {
4678 if (pVBInfo
->TVInfo
& SetPALTV
) {
4679 if (pVBInfo
->VBType
&
4681 if (!(pVBInfo
->TVInfo
&
4684 SetYPbPrMode1080i
)))
4696 if (pVBInfo
->TVInfo
& TVSimuMode
) {
4697 if (pVBInfo
->TVInfo
& SetPALTV
) {
4698 if (pVBInfo
->VBType
& VB_XGI301LV
) {
4699 if (!(pVBInfo
->TVInfo
&
4702 SetYPbPrMode1080i
)))
4711 tempax
= tempax
>> 2;
4714 push1
= tempax
; /* push ax */
4716 if ((pVBInfo
->TVInfo
& SetPALTV
)) {
4717 if (tempbx
<= 513) {
4723 temp
= tempbx
& 0x00FF;
4724 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0C, temp
);
4726 temp
= tempbx
& 0x00FF;
4727 xgifb_reg_set(pVBInfo
->Part1Port
, 0x10, temp
);
4729 if (tempbx
& 0x0100)
4732 if (tempbx
& 0x0200)
4733 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x0B, 0x0FF, 0x20);
4737 if (tempbx
& 0x0100)
4740 if (tempbx
& 0x0200)
4743 if (tempbx
& 0x0400)
4746 tempbx
= push1
; /* pop ax */
4747 temp
= tempbx
& 0x00FF;
4749 /* 0x0D vertical Retrace End */
4750 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0D, temp
);
4752 if (tempbx
& 0x0010)
4755 temp
= tempcx
& 0x00FF;
4756 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0A, temp
); /* 0x0A CR07 */
4757 temp
= (tempcx
& 0x0FF00) >> 8;
4758 xgifb_reg_set(pVBInfo
->Part1Port
, 0x17, temp
); /* 0x17 SR0A */
4760 temp
= (tempax
& 0xFF00) >> 8;
4762 temp
= (temp
>> 1) & 0x09;
4764 if (pVBInfo
->VBType
& (VB_XGI301LV
| VB_XGI302LV
| VB_XGI301C
))
4767 xgifb_reg_set(pVBInfo
->Part1Port
, 0x16, temp
); /* 0x16 SR01 */
4768 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0F, 0); /* 0x0F CR14 */
4769 xgifb_reg_set(pVBInfo
->Part1Port
, 0x12, 0); /* 0x12 CR17 */
4771 if (pVBInfo
->LCDInfo
& LCDRGB18Bit
)
4776 xgifb_reg_set(pVBInfo
->Part1Port
, 0x1A, temp
); /* 0x1A SR0E */
4781 static void XGI_SetGroup2(unsigned short ModeNo
, unsigned short ModeIdIndex
,
4782 unsigned short RefreshRateTableIndex
,
4783 struct xgi_hw_device_info
*HwDeviceExtension
,
4784 struct vb_device_info
*pVBInfo
)
4786 unsigned short i
, j
, tempax
, tempbx
, tempcx
, temp
, push1
, push2
,
4787 modeflag
, resinfo
, crt2crtc
;
4788 unsigned char *TimingPoint
;
4790 unsigned long longtemp
, tempeax
, tempebx
, temp2
, tempecx
;
4792 if (ModeNo
<= 0x13) {
4794 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
4795 resinfo
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ResInfo
;
4796 crt2crtc
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_CRT2CRTC
;
4798 /* si+Ext_ResInfo */
4799 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
4800 resinfo
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
4801 crt2crtc
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].
4807 if (!(pVBInfo
->VBInfo
& SetCRT2ToAVIDEO
))
4810 if (!(pVBInfo
->VBInfo
& SetCRT2ToSVIDEO
))
4813 if (pVBInfo
->VBInfo
& SetCRT2ToSCART
)
4816 if (!(pVBInfo
->TVInfo
& SetPALTV
))
4819 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
)
4822 if (pVBInfo
->TVInfo
& (SetYPbPrMode525p
| SetYPbPrMode750p
))
4825 tempax
= (tempax
& 0xff00) >> 8;
4827 xgifb_reg_set(pVBInfo
->Part2Port
, 0x0, tempax
);
4828 TimingPoint
= pVBInfo
->NTSCTiming
;
4830 if (pVBInfo
->TVInfo
& SetPALTV
)
4831 TimingPoint
= pVBInfo
->PALTiming
;
4833 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
) {
4834 TimingPoint
= pVBInfo
->HiTVExtTiming
;
4836 if (pVBInfo
->VBInfo
& SetInSlaveMode
)
4837 TimingPoint
= pVBInfo
->HiTVSt2Timing
;
4839 if (pVBInfo
->SetFlag
& TVSimuMode
)
4840 TimingPoint
= pVBInfo
->HiTVSt1Timing
;
4842 if (!(modeflag
& Charx8Dot
))
4843 TimingPoint
= pVBInfo
->HiTVTextTiming
;
4846 if (pVBInfo
->VBInfo
& SetCRT2ToYPbPr
) {
4847 if (pVBInfo
->TVInfo
& SetYPbPrMode525i
)
4848 TimingPoint
= pVBInfo
->YPbPr525iTiming
;
4850 if (pVBInfo
->TVInfo
& SetYPbPrMode525p
)
4851 TimingPoint
= pVBInfo
->YPbPr525pTiming
;
4853 if (pVBInfo
->TVInfo
& SetYPbPrMode750p
)
4854 TimingPoint
= pVBInfo
->YPbPr750pTiming
;
4857 for (i
= 0x01, j
= 0; i
<= 0x2D; i
++, j
++)
4858 xgifb_reg_set(pVBInfo
->Part2Port
, i
, TimingPoint
[j
]);
4860 for (i
= 0x39; i
<= 0x45; i
++, j
++)
4862 xgifb_reg_set(pVBInfo
->Part2Port
, i
, TimingPoint
[j
]);
4864 if (pVBInfo
->VBInfo
& SetCRT2ToTV
)
4865 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x3A, 0x1F, 0x00);
4867 temp
= pVBInfo
->NewFlickerMode
;
4869 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x0A, 0xFF, temp
);
4871 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
)
4874 if (pVBInfo
->TVInfo
& SetPALTV
)
4879 if (pVBInfo
->VDE
<= tempax
) {
4880 tempax
-= pVBInfo
->VDE
;
4881 tempax
= tempax
>> 2;
4882 tempax
= (tempax
& 0x00FF) | ((tempax
& 0x00FF) << 8);
4884 temp
= (tempax
& 0xFF00) >> 8;
4885 temp
+= (unsigned short) TimingPoint
[0];
4887 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
| VB_XGI301LV
4888 | VB_XGI302LV
| VB_XGI301C
)) {
4889 if (pVBInfo
->VBInfo
& (SetCRT2ToAVIDEO
4890 | SetCRT2ToSVIDEO
| SetCRT2ToSCART
4891 | SetCRT2ToYPbPr
)) {
4892 tempcx
= pVBInfo
->VGAHDE
;
4893 if (tempcx
>= 1024) {
4894 temp
= 0x17; /* NTSC */
4895 if (pVBInfo
->TVInfo
& SetPALTV
)
4896 temp
= 0x19; /* PAL */
4901 xgifb_reg_set(pVBInfo
->Part2Port
, 0x01, temp
);
4903 temp
= (tempax
& 0xFF00) >> 8;
4904 temp
+= TimingPoint
[1];
4906 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
| VB_XGI301LV
4907 | VB_XGI302LV
| VB_XGI301C
)) {
4908 if ((pVBInfo
->VBInfo
& (SetCRT2ToAVIDEO
4909 | SetCRT2ToSVIDEO
| SetCRT2ToSCART
4910 | SetCRT2ToYPbPr
))) {
4911 tempcx
= pVBInfo
->VGAHDE
;
4912 if (tempcx
>= 1024) {
4913 temp
= 0x1D; /* NTSC */
4914 if (pVBInfo
->TVInfo
& SetPALTV
)
4915 temp
= 0x52; /* PAL */
4919 xgifb_reg_set(pVBInfo
->Part2Port
, 0x02, temp
);
4923 tempcx
= pVBInfo
->HT
;
4925 if (XGI_IsLCDDualLink(pVBInfo
))
4926 tempcx
= tempcx
>> 1;
4929 temp
= tempcx
& 0x00FF;
4930 xgifb_reg_set(pVBInfo
->Part2Port
, 0x1B, temp
);
4932 temp
= (tempcx
& 0xFF00) >> 8;
4933 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x1D, ~0x0F, temp
);
4935 tempcx
= pVBInfo
->HT
>> 1;
4936 push1
= tempcx
; /* push cx */
4939 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
)
4942 temp
= tempcx
& 0x00FF;
4944 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x22, 0x0F, temp
);
4946 tempbx
= TimingPoint
[j
] | ((TimingPoint
[j
+ 1]) << 8);
4949 temp
= tempbx
& 0x00FF;
4950 xgifb_reg_set(pVBInfo
->Part2Port
, 0x24, temp
);
4951 temp
= (tempbx
& 0xFF00) >> 8;
4953 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x25, 0x0F, temp
);
4956 tempbx
= tempbx
+ 8;
4957 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
) {
4958 tempbx
= tempbx
- 4;
4962 temp
= (tempbx
& 0x00FF) << 4;
4963 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x29, 0x0F, temp
);
4966 tempcx
+= (TimingPoint
[j
] | ((TimingPoint
[j
+ 1]) << 8));
4967 temp
= tempcx
& 0x00FF;
4968 xgifb_reg_set(pVBInfo
->Part2Port
, 0x27, temp
);
4969 temp
= ((tempcx
& 0xFF00) >> 8) << 4;
4970 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x28, 0x0F, temp
);
4973 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
)
4976 temp
= tempcx
& 0xFF;
4978 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x2A, 0x0F, temp
);
4980 tempcx
= push1
; /* pop cx */
4982 temp
= TimingPoint
[j
] | ((TimingPoint
[j
+ 1]) << 8);
4984 temp
= tempcx
& 0x00FF;
4986 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x2D, 0x0F, temp
);
4990 if (!(pVBInfo
->VBInfo
& SetCRT2ToTV
)) {
4991 tempax
= XGI_GetVGAHT2(pVBInfo
);
4992 tempcx
= tempax
- 1;
4994 temp
= tempcx
& 0x00FF;
4995 xgifb_reg_set(pVBInfo
->Part2Port
, 0x2E, temp
);
4997 tempbx
= pVBInfo
->VDE
;
4999 if (pVBInfo
->VGAVDE
== 360)
5001 if (pVBInfo
->VGAVDE
== 375)
5003 if (pVBInfo
->VGAVDE
== 405)
5006 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
5007 if (pVBInfo
->VBType
&
5008 (VB_XGI301LV
| VB_XGI302LV
| VB_XGI301C
)) {
5009 if (!(pVBInfo
->TVInfo
&
5010 (SetYPbPrMode525p
| SetYPbPrMode750p
)))
5011 tempbx
= tempbx
>> 1;
5013 tempbx
= tempbx
>> 1;
5017 temp
= tempbx
& 0x00FF;
5019 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
) {
5020 if (pVBInfo
->VBType
& VB_XGI301LV
) {
5021 if (pVBInfo
->TVInfo
& SetYPbPrMode1080i
) {
5022 if (pVBInfo
->VBInfo
& SetInSlaveMode
) {
5028 if (pVBInfo
->VBInfo
& SetInSlaveMode
) {
5035 xgifb_reg_set(pVBInfo
->Part2Port
, 0x2F, temp
);
5037 temp
= (tempcx
& 0xFF00) >> 8;
5038 temp
|= ((tempbx
& 0xFF00) >> 8) << 6;
5040 if (!(pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
)) {
5041 if (pVBInfo
->VBType
& VB_XGI301LV
) {
5042 if (pVBInfo
->TVInfo
& SetYPbPrMode1080i
) {
5045 if (!(pVBInfo
->VBInfo
& SetCRT2ToSVIDEO
))
5050 if (!(pVBInfo
->VBInfo
& SetCRT2ToSVIDEO
))
5055 xgifb_reg_set(pVBInfo
->Part2Port
, 0x30, temp
);
5057 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
| VB_XGI301LV
5058 | VB_XGI302LV
| VB_XGI301C
)) { /* TV gatingno */
5059 tempbx
= pVBInfo
->VDE
;
5060 tempcx
= tempbx
- 2;
5062 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
5063 if (!(pVBInfo
->TVInfo
& (SetYPbPrMode525p
5064 | SetYPbPrMode750p
)))
5065 tempbx
= tempbx
>> 1;
5068 if (pVBInfo
->VBType
& (VB_XGI302LV
| VB_XGI301C
)) {
5070 if (tempcx
& 0x0400)
5073 if (tempbx
& 0x0400)
5076 xgifb_reg_set(pVBInfo
->Part4Port
, 0x10, temp
);
5079 temp
= (((tempbx
- 3) & 0x0300) >> 8) << 5;
5080 xgifb_reg_set(pVBInfo
->Part2Port
, 0x46, temp
);
5081 temp
= (tempbx
- 3) & 0x00FF;
5082 xgifb_reg_set(pVBInfo
->Part2Port
, 0x47, temp
);
5085 tempbx
= tempbx
& 0x00FF;
5087 if (!(modeflag
& HalfDCLK
)) {
5088 tempcx
= pVBInfo
->VGAHDE
;
5089 if (tempcx
>= pVBInfo
->HDE
) {
5097 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) { /*301b*/
5098 if (pVBInfo
->VGAHDE
>= 1024) {
5100 if (pVBInfo
->VGAHDE
>= 1280) {
5102 tempbx
= tempbx
& 0xDFFF;
5107 if (!(tempbx
& 0x2000)) {
5108 if (modeflag
& HalfDCLK
)
5109 tempcx
= (tempcx
& 0xFF00) | ((tempcx
& 0x00FF) << 1);
5112 tempeax
= pVBInfo
->VGAHDE
;
5113 tempebx
= (tempcx
& 0xFF00) >> 8;
5114 longtemp
= tempeax
* tempebx
;
5115 tempecx
= tempcx
& 0x00FF;
5116 longtemp
= longtemp
/ tempecx
;
5121 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
| VB_XGI301LV
5122 | VB_XGI302LV
| VB_XGI301C
)) {
5123 tempecx
= tempecx
* 8;
5126 longtemp
= longtemp
* tempecx
;
5127 tempecx
= pVBInfo
->HDE
;
5128 temp2
= longtemp
% tempecx
;
5129 tempeax
= longtemp
/ tempecx
;
5133 tempax
= (unsigned short) tempeax
;
5136 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
| VB_XGI301LV
5137 | VB_XGI302LV
| VB_XGI301C
)) {
5138 tempcx
= ((tempax
& 0xFF00) >> 5) >> 8;
5143 tempbx
= (unsigned short) (((tempeax
& 0x0000FF00) & 0x1F00)
5144 | (tempbx
& 0x00FF));
5145 tempax
= (unsigned short) (((tempeax
& 0x000000FF) << 8)
5146 | (tempax
& 0x00FF));
5147 temp
= (tempax
& 0xFF00) >> 8;
5149 temp
= (tempax
& 0x00FF) >> 8;
5152 xgifb_reg_set(pVBInfo
->Part2Port
, 0x44, temp
);
5153 temp
= (tempbx
& 0xFF00) >> 8;
5154 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x45, ~0x03F, temp
);
5155 temp
= tempcx
& 0x00FF;
5157 if (tempbx
& 0x2000)
5160 if (!(pVBInfo
->VBInfo
& SetCRT2ToLCD
))
5163 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x46, ~0x1F, temp
);
5164 if (pVBInfo
->TVInfo
& SetPALTV
) {
5172 temp
= tempbx
& 0x00FF;
5173 xgifb_reg_set(pVBInfo
->Part2Port
, 0x4b, temp
);
5174 temp
= tempcx
& 0x00FF;
5175 xgifb_reg_set(pVBInfo
->Part2Port
, 0x4c, temp
);
5177 temp
= ((tempcx
& 0xFF00) >> 8) & 0x03;
5179 temp
|= ((tempbx
& 0xFF00) >> 8) & 0x03;
5181 if (pVBInfo
->VBInfo
& SetCRT2ToYPbPr
) {
5184 if (pVBInfo
->TVInfo
& SetYPbPrMode525p
)
5187 if (pVBInfo
->TVInfo
& SetYPbPrMode750p
)
5191 xgifb_reg_set(pVBInfo
->Part2Port
, 0x4d, temp
);
5192 temp
= xgifb_reg_get(pVBInfo
->Part2Port
, 0x43); /* 301b change */
5193 xgifb_reg_set(pVBInfo
->Part2Port
, 0x43, (unsigned short) (temp
- 3));
5195 if (!(pVBInfo
->TVInfo
& (SetYPbPrMode525p
| SetYPbPrMode750p
))) {
5196 if (pVBInfo
->TVInfo
& NTSC1024x768
) {
5197 TimingPoint
= XGI_NTSC1024AdjTime
;
5198 for (i
= 0x1c, j
= 0; i
<= 0x30; i
++, j
++) {
5199 xgifb_reg_set(pVBInfo
->Part2Port
, i
,
5202 xgifb_reg_set(pVBInfo
->Part2Port
, 0x43, 0x72);
5206 /* [ycchen] 01/14/03 Modify for 301C PALM Support */
5207 if (pVBInfo
->VBType
& VB_XGI301C
) {
5208 if (pVBInfo
->TVInfo
& SetPALMTV
)
5209 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x4E, ~0x08,
5210 0x08); /* PALM Mode */
5213 if (pVBInfo
->TVInfo
& SetPALMTV
) {
5214 tempax
= (unsigned char) xgifb_reg_get(pVBInfo
->Part2Port
,
5217 xgifb_reg_and(pVBInfo
->Part2Port
, 0x01, tempax
);
5219 xgifb_reg_and(pVBInfo
->Part2Port
, 0x00, 0xEF);
5222 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
) {
5223 if (!(pVBInfo
->VBInfo
& SetInSlaveMode
))
5224 xgifb_reg_set(pVBInfo
->Part2Port
, 0x0B, 0x00);
5227 if (pVBInfo
->VBInfo
& SetCRT2ToTV
)
5231 static void XGI_SetLCDRegs(unsigned short ModeNo
, unsigned short ModeIdIndex
,
5232 struct xgi_hw_device_info
*HwDeviceExtension
,
5233 unsigned short RefreshRateTableIndex
,
5234 struct vb_device_info
*pVBInfo
)
5236 unsigned short push1
, push2
, pushbx
, tempax
, tempbx
, tempcx
, temp
,
5237 tempah
, tempbh
, tempch
, resinfo
, modeflag
, CRT1Index
;
5239 struct XGI_LCDDesStruct
*LCDBDesPtr
= NULL
;
5241 if (ModeNo
<= 0x13) {
5243 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
5244 resinfo
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ResInfo
;
5246 /* si+Ext_ResInfo */
5247 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
5248 resinfo
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
5249 CRT1Index
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].
5251 CRT1Index
&= IndexMask
;
5254 if (!(pVBInfo
->VBInfo
& SetCRT2ToLCD
))
5257 tempbx
= pVBInfo
->HDE
; /* RHACTE=HDE-1 */
5259 if (XGI_IsLCDDualLink(pVBInfo
))
5260 tempbx
= tempbx
>> 1;
5263 temp
= tempbx
& 0x00FF;
5264 xgifb_reg_set(pVBInfo
->Part2Port
, 0x2C, temp
);
5265 temp
= (tempbx
& 0xFF00) >> 8;
5267 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x2B, 0x0F, temp
);
5270 if (pVBInfo
->LCDResInfo
== Panel1280x1024
) {
5271 if (pVBInfo
->ModeType
== ModeEGA
) {
5272 if (pVBInfo
->VGAHDE
>= 1024) {
5274 if (pVBInfo
->LCDInfo
& LCDVESATiming
)
5280 xgifb_reg_set(pVBInfo
->Part2Port
, 0x0B, temp
);
5281 tempbx
= pVBInfo
->VDE
; /* RTVACTEO=(VDE-1)&0xFF */
5284 temp
= tempbx
& 0x00FF;
5285 xgifb_reg_set(pVBInfo
->Part2Port
, 0x03, temp
);
5286 temp
= ((tempbx
& 0xFF00) >> 8) & 0x07;
5287 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x0C, ~0x07, temp
);
5289 tempcx
= pVBInfo
->VT
- 1;
5291 temp
= tempcx
& 0x00FF; /* RVTVT=VT-1 */
5292 xgifb_reg_set(pVBInfo
->Part2Port
, 0x19, temp
);
5293 temp
= (tempcx
& 0xFF00) >> 8;
5295 xgifb_reg_set(pVBInfo
->Part2Port
, 0x1A, temp
);
5296 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x09, 0xF0, 0x00);
5297 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x0A, 0xF0, 0x00);
5298 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x17, 0xFB, 0x00);
5299 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x18, 0xDF, 0x00);
5301 /* Customized LCDB Des no add */
5303 LCDBDesPtr
= (struct XGI_LCDDesStruct
*) XGI_GetLcdPtr(tempbx
, ModeNo
,
5304 ModeIdIndex
, RefreshRateTableIndex
, pVBInfo
);
5305 tempah
= pVBInfo
->LCDResInfo
;
5306 tempah
&= PanelResInfo
;
5308 if ((tempah
== Panel1024x768
) || (tempah
== Panel1024x768x75
)) {
5311 } else if ((tempah
== Panel1280x1024
) ||
5312 (tempah
== Panel1280x1024x75
)) {
5315 } else if (tempah
== Panel1400x1050
) {
5323 if (pVBInfo
->LCDInfo
& EnableScalingLCD
) {
5324 tempbx
= pVBInfo
->HDE
;
5325 tempcx
= pVBInfo
->VDE
;
5329 tempax
= pVBInfo
->VT
;
5330 pVBInfo
->LCDHDES
= LCDBDesPtr
->LCDHDES
;
5331 pVBInfo
->LCDHRS
= LCDBDesPtr
->LCDHRS
;
5332 pVBInfo
->LCDVDES
= LCDBDesPtr
->LCDVDES
;
5333 pVBInfo
->LCDVRS
= LCDBDesPtr
->LCDVRS
;
5334 tempbx
= pVBInfo
->LCDVDES
;
5337 if (tempcx
>= tempax
)
5338 tempcx
-= tempax
; /* lcdvdes */
5340 temp
= tempbx
& 0x00FF; /* RVEQ1EQ=lcdvdes */
5341 xgifb_reg_set(pVBInfo
->Part2Port
, 0x05, temp
);
5342 temp
= tempcx
& 0x00FF;
5343 xgifb_reg_set(pVBInfo
->Part2Port
, 0x06, temp
);
5344 tempch
= ((tempcx
& 0xFF00) >> 8) & 0x07;
5345 tempbh
= ((tempbx
& 0xFF00) >> 8) & 0x07;
5347 tempah
= tempah
<< 3;
5349 xgifb_reg_set(pVBInfo
->Part2Port
, 0x02, tempah
);
5352 XGI_GetLCDSync(&tempax
, &tempbx
, pVBInfo
);
5354 tempax
= pVBInfo
->VT
;
5355 tempbx
= pVBInfo
->LCDVRS
;
5358 if (tempcx
>= tempax
)
5361 temp
= tempbx
& 0x00FF; /* RTVACTEE=lcdvrs */
5362 xgifb_reg_set(pVBInfo
->Part2Port
, 0x04, temp
);
5363 temp
= (tempbx
& 0xFF00) >> 8;
5365 temp
|= (tempcx
& 0x000F);
5366 xgifb_reg_set(pVBInfo
->Part2Port
, 0x01, temp
);
5368 tempax
= pVBInfo
->HT
;
5369 tempbx
= pVBInfo
->LCDHDES
;
5372 if (XGI_IsLCDDualLink(pVBInfo
)) {
5373 tempax
= tempax
>> 1;
5374 tempbx
= tempbx
>> 1;
5375 tempcx
= tempcx
>> 1;
5378 if (pVBInfo
->VBType
& VB_XGI302LV
)
5381 if (pVBInfo
->VBType
& VB_XGI301C
) /* tap4 */
5386 if (tempcx
>= tempax
)
5389 temp
= tempbx
& 0x00FF;
5390 xgifb_reg_set(pVBInfo
->Part2Port
, 0x1F, temp
); /* RHBLKE=lcdhdes */
5391 temp
= ((tempbx
& 0xFF00) >> 8) << 4;
5392 xgifb_reg_set(pVBInfo
->Part2Port
, 0x20, temp
);
5393 temp
= tempcx
& 0x00FF;
5394 xgifb_reg_set(pVBInfo
->Part2Port
, 0x23, temp
); /* RHEQPLE=lcdhdee */
5395 temp
= (tempcx
& 0xFF00) >> 8;
5396 xgifb_reg_set(pVBInfo
->Part2Port
, 0x25, temp
);
5398 XGI_GetLCDSync(&tempax
, &tempbx
, pVBInfo
);
5400 tempax
= pVBInfo
->HT
;
5401 tempbx
= pVBInfo
->LCDHRS
;
5402 if (XGI_IsLCDDualLink(pVBInfo
)) {
5403 tempax
= tempax
>> 1;
5404 tempbx
= tempbx
>> 1;
5405 tempcx
= tempcx
>> 1;
5408 if (pVBInfo
->VBType
& VB_XGI302LV
)
5413 if (tempcx
>= tempax
)
5416 temp
= tempbx
& 0x00FF; /* RHBURSTS=lcdhrs */
5417 xgifb_reg_set(pVBInfo
->Part2Port
, 0x1C, temp
);
5419 temp
= (tempbx
& 0xFF00) >> 8;
5421 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x1D, ~0x0F0, temp
);
5422 temp
= tempcx
& 0x00FF; /* RHSYEXP2S=lcdhre */
5423 xgifb_reg_set(pVBInfo
->Part2Port
, 0x21, temp
);
5425 if (!(pVBInfo
->LCDInfo
& LCDVESATiming
)) {
5426 if (pVBInfo
->VGAVDE
== 525) {
5427 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
5428 | VB_XGI301LV
| VB_XGI302LV
5434 xgifb_reg_set(pVBInfo
->Part2Port
, 0x2f, temp
);
5435 xgifb_reg_set(pVBInfo
->Part2Port
, 0x30, 0xB3);
5438 if (pVBInfo
->VGAVDE
== 420) {
5439 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
5440 | VB_XGI301LV
| VB_XGI302LV
5445 xgifb_reg_set(pVBInfo
->Part2Port
, 0x2f, temp
);
5450 /* --------------------------------------------------------------------- */
5451 /* Function : XGI_GetTap4Ptr */
5453 /* Output : di -> Tap4 Reg. Setting Pointer */
5455 /* --------------------------------------------------------------------- */
5456 static struct XGI301C_Tap4TimingStruct
*XGI_GetTap4Ptr(unsigned short tempcx
,
5457 struct vb_device_info
*pVBInfo
)
5459 unsigned short tempax
, tempbx
, i
;
5461 struct XGI301C_Tap4TimingStruct
*Tap4TimingPtr
;
5464 tempax
= pVBInfo
->VGAHDE
;
5465 tempbx
= pVBInfo
->HDE
;
5467 tempax
= pVBInfo
->VGAVDE
;
5468 tempbx
= pVBInfo
->VDE
;
5471 if (tempax
<= tempbx
)
5472 return &xgifb_tap4_timing
[0];
5474 Tap4TimingPtr
= xgifb_ntsc_525_tap4_timing
; /* NTSC */
5476 if (pVBInfo
->TVInfo
& SetPALTV
)
5477 Tap4TimingPtr
= PALTap4Timing
;
5479 if (pVBInfo
->VBInfo
& SetCRT2ToYPbPr
) {
5480 if ((pVBInfo
->TVInfo
& SetYPbPrMode525i
) ||
5481 (pVBInfo
->TVInfo
& SetYPbPrMode525p
))
5482 Tap4TimingPtr
= xgifb_ntsc_525_tap4_timing
;
5483 if (pVBInfo
->TVInfo
& SetYPbPrMode750p
)
5484 Tap4TimingPtr
= YPbPr750pTap4Timing
;
5487 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
)
5488 Tap4TimingPtr
= xgifb_tap4_timing
;
5491 while (Tap4TimingPtr
[i
].DE
!= 0xFFFF) {
5492 if (Tap4TimingPtr
[i
].DE
== tempax
)
5496 return &Tap4TimingPtr
[i
];
5499 static void XGI_SetTap4Regs(struct vb_device_info
*pVBInfo
)
5501 unsigned short i
, j
;
5503 struct XGI301C_Tap4TimingStruct
*Tap4TimingPtr
;
5505 if (!(pVBInfo
->VBType
& VB_XGI301C
))
5508 Tap4TimingPtr
= XGI_GetTap4Ptr(0, pVBInfo
); /* Set Horizontal Scaling */
5509 for (i
= 0x80, j
= 0; i
<= 0xBF; i
++, j
++)
5510 xgifb_reg_set(pVBInfo
->Part2Port
, i
, Tap4TimingPtr
->Reg
[j
]);
5512 if ((pVBInfo
->VBInfo
& SetCRT2ToTV
) &&
5513 (!(pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
))) {
5514 /* Set Vertical Scaling */
5515 Tap4TimingPtr
= XGI_GetTap4Ptr(1, pVBInfo
);
5516 for (i
= 0xC0, j
= 0; i
< 0xFF; i
++, j
++)
5517 xgifb_reg_set(pVBInfo
->Part2Port
,
5519 Tap4TimingPtr
->Reg
[j
]);
5522 if ((pVBInfo
->VBInfo
& SetCRT2ToTV
) &&
5523 (!(pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
)))
5524 /* Enable V.Scaling */
5525 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x4E, ~0x14, 0x04);
5527 /* Enable H.Scaling */
5528 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x4E, ~0x14, 0x10);
5531 static void XGI_SetGroup3(unsigned short ModeNo
, unsigned short ModeIdIndex
,
5532 struct vb_device_info
*pVBInfo
)
5535 unsigned char *tempdi
;
5536 unsigned short modeflag
;
5540 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
5542 /* si+Ext_ResInfo */
5543 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
5545 xgifb_reg_set(pVBInfo
->Part3Port
, 0x00, 0x00);
5546 if (pVBInfo
->TVInfo
& SetPALTV
) {
5547 xgifb_reg_set(pVBInfo
->Part3Port
, 0x13, 0xFA);
5548 xgifb_reg_set(pVBInfo
->Part3Port
, 0x14, 0xC8);
5550 xgifb_reg_set(pVBInfo
->Part3Port
, 0x13, 0xF5);
5551 xgifb_reg_set(pVBInfo
->Part3Port
, 0x14, 0xB7);
5554 if (!(pVBInfo
->VBInfo
& SetCRT2ToTV
))
5557 if (pVBInfo
->TVInfo
& SetPALMTV
) {
5558 xgifb_reg_set(pVBInfo
->Part3Port
, 0x13, 0xFA);
5559 xgifb_reg_set(pVBInfo
->Part3Port
, 0x14, 0xC8);
5560 xgifb_reg_set(pVBInfo
->Part3Port
, 0x3D, 0xA8);
5563 if ((pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
) || (pVBInfo
->VBInfo
5564 & SetCRT2ToYPbPr
)) {
5565 if (pVBInfo
->TVInfo
& SetYPbPrMode525i
)
5568 tempdi
= pVBInfo
->HiTVGroup3Data
;
5569 if (pVBInfo
->SetFlag
& TVSimuMode
) {
5570 tempdi
= pVBInfo
->HiTVGroup3Simu
;
5571 if (!(modeflag
& Charx8Dot
))
5572 tempdi
= pVBInfo
->HiTVGroup3Text
;
5575 if (pVBInfo
->TVInfo
& SetYPbPrMode525p
)
5576 tempdi
= pVBInfo
->Ren525pGroup3
;
5578 if (pVBInfo
->TVInfo
& SetYPbPrMode750p
)
5579 tempdi
= pVBInfo
->Ren750pGroup3
;
5581 for (i
= 0; i
<= 0x3E; i
++)
5582 xgifb_reg_set(pVBInfo
->Part3Port
, i
, tempdi
[i
]);
5584 if (pVBInfo
->VBType
& VB_XGI301C
) { /* Marcovision */
5585 if (pVBInfo
->TVInfo
& SetYPbPrMode525p
)
5586 xgifb_reg_set(pVBInfo
->Part3Port
, 0x28, 0x3f);
5590 } /* {end of XGI_SetGroup3} */
5592 static void XGI_SetGroup4(unsigned short ModeNo
, unsigned short ModeIdIndex
,
5593 unsigned short RefreshRateTableIndex
,
5594 struct xgi_hw_device_info
*HwDeviceExtension
,
5595 struct vb_device_info
*pVBInfo
)
5597 unsigned short tempax
, tempcx
, tempbx
, modeflag
, temp
, temp2
;
5599 unsigned long tempebx
, tempeax
, templong
;
5603 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
5605 /* si+Ext_ResInfo */
5606 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
5608 temp
= pVBInfo
->RVBHCFACT
;
5609 xgifb_reg_set(pVBInfo
->Part4Port
, 0x13, temp
);
5611 tempbx
= pVBInfo
->RVBHCMAX
;
5612 temp
= tempbx
& 0x00FF;
5613 xgifb_reg_set(pVBInfo
->Part4Port
, 0x14, temp
);
5614 temp2
= ((tempbx
& 0xFF00) >> 8) << 7;
5615 tempcx
= pVBInfo
->VGAHT
- 1;
5616 temp
= tempcx
& 0x00FF;
5617 xgifb_reg_set(pVBInfo
->Part4Port
, 0x16, temp
);
5619 temp
= ((tempcx
& 0xFF00) >> 8) << 3;
5622 tempcx
= pVBInfo
->VGAVT
- 1;
5623 if (!(pVBInfo
->VBInfo
& SetCRT2ToTV
))
5626 temp
= tempcx
& 0x00FF;
5627 xgifb_reg_set(pVBInfo
->Part4Port
, 0x17, temp
);
5628 temp
= temp2
| ((tempcx
& 0xFF00) >> 8);
5629 xgifb_reg_set(pVBInfo
->Part4Port
, 0x15, temp
);
5630 xgifb_reg_or(pVBInfo
->Part4Port
, 0x0D, 0x08);
5631 tempcx
= pVBInfo
->VBInfo
;
5632 tempbx
= pVBInfo
->VGAHDE
;
5634 if (modeflag
& HalfDCLK
)
5635 tempbx
= tempbx
>> 1;
5637 if (XGI_IsLCDDualLink(pVBInfo
))
5638 tempbx
= tempbx
>> 1;
5640 if (tempcx
& SetCRT2ToHiVisionTV
) {
5646 } else if (tempcx
& SetCRT2ToTV
) {
5652 if (pVBInfo
->VBInfo
& SetCRT2ToLCD
) {
5659 if (pVBInfo
->TVInfo
& (SetYPbPrMode525p
| SetYPbPrMode750p
)) {
5661 if (pVBInfo
->VGAHDE
== 1280)
5663 if (pVBInfo
->VGAHDE
== 1024)
5666 xgifb_reg_and_or(pVBInfo
->Part4Port
, 0x0E, ~0xEF, temp
);
5668 tempebx
= pVBInfo
->VDE
;
5670 if (tempcx
& SetCRT2ToHiVisionTV
) {
5671 if (!(temp
& 0xE000))
5672 tempbx
= tempbx
>> 1;
5675 tempcx
= pVBInfo
->RVBHRS
;
5676 temp
= tempcx
& 0x00FF;
5677 xgifb_reg_set(pVBInfo
->Part4Port
, 0x18, temp
);
5679 tempeax
= pVBInfo
->VGAVDE
;
5682 if (tempeax
<= tempebx
) {
5683 tempcx
= (tempcx
& (~0x4000));
5684 tempeax
= pVBInfo
->VGAVDE
;
5689 templong
= (tempeax
* 256 * 1024) % tempebx
;
5690 tempeax
= (tempeax
* 256 * 1024) / tempebx
;
5696 temp
= (unsigned short) (tempebx
& 0x000000FF);
5697 xgifb_reg_set(pVBInfo
->Part4Port
, 0x1B, temp
);
5699 temp
= (unsigned short) ((tempebx
& 0x0000FF00) >> 8);
5700 xgifb_reg_set(pVBInfo
->Part4Port
, 0x1A, temp
);
5701 tempbx
= (unsigned short) (tempebx
>> 16);
5702 temp
= tempbx
& 0x00FF;
5704 temp
|= ((tempcx
& 0xFF00) >> 8);
5705 xgifb_reg_set(pVBInfo
->Part4Port
, 0x19, temp
);
5708 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
| VB_XGI301LV
5709 | VB_XGI302LV
| VB_XGI301C
)) {
5711 xgifb_reg_set(pVBInfo
->Part4Port
, 0x1C, temp
);
5712 tempax
= pVBInfo
->VGAHDE
;
5713 if (modeflag
& HalfDCLK
)
5714 tempax
= tempax
>> 1;
5716 if (XGI_IsLCDDualLink(pVBInfo
))
5717 tempax
= tempax
>> 1;
5719 if (pVBInfo
->VBInfo
& SetCRT2ToLCD
) {
5723 if (pVBInfo
->VGAHDE
> 800) {
5724 if (pVBInfo
->VGAHDE
== 1024)
5725 tempax
= (tempax
* 25 / 32) - 1;
5727 tempax
= (tempax
* 20 / 32) - 1;
5732 temp
= (tempax
& 0xFF00) >> 8;
5733 temp
= ((temp
& 0x0003) << 4);
5734 xgifb_reg_set(pVBInfo
->Part4Port
, 0x1E, temp
);
5735 temp
= (tempax
& 0x00FF);
5736 xgifb_reg_set(pVBInfo
->Part4Port
, 0x1D, temp
);
5738 if (pVBInfo
->VBInfo
& (SetCRT2ToTV
| SetCRT2ToHiVisionTV
)) {
5739 if (pVBInfo
->VGAHDE
> 800)
5740 xgifb_reg_or(pVBInfo
->Part4Port
, 0x1E, 0x08);
5745 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
5746 if (!(pVBInfo
->TVInfo
& (NTSC1024x768
5747 | SetYPbPrMode525p
| SetYPbPrMode750p
5748 | SetYPbPrMode1080i
))) {
5750 if ((pVBInfo
->VBInfo
& SetInSlaveMode
)
5751 && (!(pVBInfo
->TVInfo
5757 xgifb_reg_and_or(pVBInfo
->Part4Port
, 0x1F, 0x00C0, temp
);
5758 tempbx
= pVBInfo
->HT
;
5759 if (XGI_IsLCDDualLink(pVBInfo
))
5760 tempbx
= tempbx
>> 1;
5761 tempbx
= (tempbx
>> 1) - 2;
5762 temp
= ((tempbx
& 0x0700) >> 8) << 3;
5763 xgifb_reg_and_or(pVBInfo
->Part4Port
, 0x21, 0x00C0, temp
);
5764 temp
= tempbx
& 0x00FF;
5765 xgifb_reg_set(pVBInfo
->Part4Port
, 0x22, temp
);
5769 if (pVBInfo
->ISXPDOS
== 0)
5770 XGI_SetCRT2VCLK(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
5774 static void XGINew_EnableCRT2(struct vb_device_info
*pVBInfo
)
5776 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x1E, 0xFF, 0x20);
5779 static void XGI_SetGroup5(unsigned short ModeNo
, unsigned short ModeIdIndex
,
5780 struct vb_device_info
*pVBInfo
)
5782 unsigned short Pindex
, Pdata
;
5784 Pindex
= pVBInfo
->Part5Port
;
5785 Pdata
= pVBInfo
->Part5Port
+ 1;
5786 if (pVBInfo
->ModeType
== ModeVGA
) {
5787 if (!(pVBInfo
->VBInfo
& (SetInSlaveMode
| LoadDACFlag
5788 | CRT2DisplayFlag
))) {
5789 XGINew_EnableCRT2(pVBInfo
);
5795 static void XGI_EnableGatingCRT(struct xgi_hw_device_info
*HwDeviceExtension
,
5796 struct vb_device_info
*pVBInfo
)
5798 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x63, 0xBF, 0x40);
5801 static void XGI_DisableGatingCRT(struct xgi_hw_device_info
*HwDeviceExtension
,
5802 struct vb_device_info
*pVBInfo
)
5805 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x63, 0xBF, 0x00);
5808 static unsigned char XGI_XG21CheckLVDSMode(struct xgifb_video_info
*xgifb_info
,
5809 unsigned short ModeNo
, unsigned short ModeIdIndex
,
5810 struct vb_device_info
*pVBInfo
)
5812 unsigned short xres
, yres
, colordepth
, modeflag
, resindex
;
5814 resindex
= XGI_GetResInfo(ModeNo
, ModeIdIndex
, pVBInfo
);
5815 if (ModeNo
<= 0x13) {
5816 xres
= pVBInfo
->StResInfo
[resindex
].HTotal
;
5817 yres
= pVBInfo
->StResInfo
[resindex
].VTotal
;
5819 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
5821 xres
= pVBInfo
->ModeResInfo
[resindex
].HTotal
; /* xres->ax */
5822 yres
= pVBInfo
->ModeResInfo
[resindex
].VTotal
; /* yres->bx */
5823 /* si+St_ModeFlag */
5824 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
5827 if (!(modeflag
& Charx8Dot
)) {
5832 if (ModeNo
> 0x13) {
5833 if ((ModeNo
> 0x13) && (modeflag
& HalfDCLK
))
5836 if ((ModeNo
> 0x13) && (modeflag
& DoubleScanMode
))
5841 if (xres
> xgifb_info
->lvds_data
.LVDSHDE
)
5844 if (yres
> xgifb_info
->lvds_data
.LVDSVDE
)
5847 if (ModeNo
> 0x13) {
5848 if (xres
!= xgifb_info
->lvds_data
.LVDSHDE
||
5849 yres
!= xgifb_info
->lvds_data
.LVDSVDE
) {
5850 colordepth
= XGI_GetColorDepth(ModeNo
,
5861 static void xgifb_set_lvds(struct xgifb_video_info
*xgifb_info
,
5863 unsigned short ModeNo
,
5864 unsigned short ModeIdIndex
,
5865 struct vb_device_info
*pVBInfo
)
5867 unsigned char temp
, Miscdata
;
5868 unsigned short xres
, yres
, modeflag
, resindex
;
5869 unsigned short LVDSHT
, LVDSHBS
, LVDSHRS
, LVDSHRE
, LVDSHBE
;
5870 unsigned short LVDSVT
, LVDSVBS
, LVDSVRS
, LVDSVRE
, LVDSVBE
;
5871 unsigned short value
;
5873 temp
= (unsigned char) ((xgifb_info
->lvds_data
.LVDS_Capability
&
5874 (LCDPolarity
<< 8)) >> 8);
5875 temp
&= LCDPolarity
;
5876 Miscdata
= (unsigned char) inb(pVBInfo
->P3cc
);
5878 outb((Miscdata
& 0x3F) | temp
, pVBInfo
->P3c2
);
5880 temp
= xgifb_info
->lvds_data
.LVDS_Capability
& LCDPolarity
;
5881 /* SR35[7] FP VSync polarity */
5882 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x35, ~0x80, temp
& 0x80);
5883 /* SR30[5] FP HSync polarity */
5884 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x30, ~0x20, (temp
& 0x40) >> 1);
5886 if (chip_id
== XG27
)
5887 XGI_SetXG27FPBits(pVBInfo
);
5889 XGI_SetXG21FPBits(pVBInfo
);
5891 resindex
= XGI_GetResInfo(ModeNo
, ModeIdIndex
, pVBInfo
);
5892 if (ModeNo
<= 0x13) {
5893 xres
= pVBInfo
->StResInfo
[resindex
].HTotal
;
5894 yres
= pVBInfo
->StResInfo
[resindex
].VTotal
;
5896 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
5898 xres
= pVBInfo
->ModeResInfo
[resindex
].HTotal
; /* xres->ax */
5899 yres
= pVBInfo
->ModeResInfo
[resindex
].VTotal
; /* yres->bx */
5900 /* si+St_ModeFlag */
5901 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
5904 if (!(modeflag
& Charx8Dot
))
5905 xres
= xres
* 8 / 9;
5907 LVDSHT
= xgifb_info
->lvds_data
.LVDSHT
;
5909 LVDSHBS
= xres
+ (xgifb_info
->lvds_data
.LVDSHDE
- xres
) / 2;
5910 if ((ModeNo
<= 0x13) && (modeflag
& HalfDCLK
))
5911 LVDSHBS
-= xres
/ 4;
5913 if (LVDSHBS
> LVDSHT
)
5916 LVDSHRS
= LVDSHBS
+ xgifb_info
->lvds_data
.LVDSHFP
;
5917 if (LVDSHRS
> LVDSHT
)
5920 LVDSHRE
= LVDSHRS
+ xgifb_info
->lvds_data
.LVDSHSYNC
;
5921 if (LVDSHRE
> LVDSHT
)
5924 LVDSHBE
= LVDSHBS
+ LVDSHT
- xgifb_info
->lvds_data
.LVDSHDE
;
5926 LVDSVT
= xgifb_info
->lvds_data
.LVDSVT
;
5928 LVDSVBS
= yres
+ (xgifb_info
->lvds_data
.LVDSVDE
- yres
) / 2;
5929 if ((ModeNo
> 0x13) && (modeflag
& DoubleScanMode
))
5930 LVDSVBS
+= yres
/ 2;
5932 if (LVDSVBS
> LVDSVT
)
5935 LVDSVRS
= LVDSVBS
+ xgifb_info
->lvds_data
.LVDSVFP
;
5936 if (LVDSVRS
> LVDSVT
)
5939 LVDSVRE
= LVDSVRS
+ xgifb_info
->lvds_data
.LVDSVSYNC
;
5940 if (LVDSVRE
> LVDSVT
)
5943 LVDSVBE
= LVDSVBS
+ LVDSVT
- xgifb_info
->lvds_data
.LVDSVDE
;
5945 temp
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x11);
5946 xgifb_reg_set(pVBInfo
->P3d4
, 0x11, temp
& 0x7f); /* Unlock CRTC */
5948 if (!(modeflag
& Charx8Dot
))
5949 xgifb_reg_or(pVBInfo
->P3c4
, 0x1, 0x1);
5951 /* HT SR0B[1:0] CR00 */
5952 value
= (LVDSHT
>> 3) - 5;
5953 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0B, ~0x03, (value
& 0x300) >> 8);
5954 xgifb_reg_set(pVBInfo
->P3d4
, 0x0, (value
& 0xFF));
5956 /* HBS SR0B[5:4] CR02 */
5957 value
= (LVDSHBS
>> 3) - 1;
5958 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0B, ~0x30, (value
& 0x300) >> 4);
5959 xgifb_reg_set(pVBInfo
->P3d4
, 0x2, (value
& 0xFF));
5961 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
5962 value
= (LVDSHBE
>> 3) - 1;
5963 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0C, ~0x03, (value
& 0xC0) >> 6);
5964 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x05, ~0x80, (value
& 0x20) << 2);
5965 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x03, ~0x1F, value
& 0x1F);
5967 /* HRS SR0B[7:6] CR04 */
5968 value
= (LVDSHRS
>> 3) + 2;
5969 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0B, ~0xC0, (value
& 0x300) >> 2);
5970 xgifb_reg_set(pVBInfo
->P3d4
, 0x4, (value
& 0xFF));
5972 /* Panel HRS SR2F[1:0] SR2E[7:0] */
5974 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x2F, ~0x03, (value
& 0x300) >> 8);
5975 xgifb_reg_set(pVBInfo
->P3c4
, 0x2E, (value
& 0xFF));
5977 /* HRE SR0C[2] CR05[4:0] */
5978 value
= (LVDSHRE
>> 3) + 2;
5979 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0C, ~0x04, (value
& 0x20) >> 3);
5980 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x05, ~0x1F, value
& 0x1F);
5982 /* Panel HRE SR2F[7:2] */
5984 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x2F, ~0xFC, value
<< 2);
5986 /* VT SR0A[0] CR07[5][0] CR06 */
5988 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0A, ~0x01, (value
& 0x400) >> 10);
5989 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x07, ~0x20, (value
& 0x200) >> 4);
5990 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x07, ~0x01, (value
& 0x100) >> 8);
5991 xgifb_reg_set(pVBInfo
->P3d4
, 0x06, (value
& 0xFF));
5993 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
5994 value
= LVDSVBS
- 1;
5995 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0A, ~0x04, (value
& 0x400) >> 8);
5996 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x09, ~0x20, (value
& 0x200) >> 4);
5997 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x07, ~0x08, (value
& 0x100) >> 5);
5998 xgifb_reg_set(pVBInfo
->P3d4
, 0x15, (value
& 0xFF));
6000 /* VBE SR0A[4] CR16 */
6001 value
= LVDSVBE
- 1;
6002 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0A, ~0x10, (value
& 0x100) >> 4);
6003 xgifb_reg_set(pVBInfo
->P3d4
, 0x16, (value
& 0xFF));
6005 /* VRS SR0A[3] CR7[7][2] CR10 */
6006 value
= LVDSVRS
- 1;
6007 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0A, ~0x08, (value
& 0x400) >> 7);
6008 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x07, ~0x80, (value
& 0x200) >> 2);
6009 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x07, ~0x04, (value
& 0x100) >> 6);
6010 xgifb_reg_set(pVBInfo
->P3d4
, 0x10, (value
& 0xFF));
6012 if (chip_id
== XG27
) {
6013 /* Panel VRS SR35[2:0] SR34[7:0] */
6014 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x35, ~0x07,
6015 (value
& 0x700) >> 8);
6016 xgifb_reg_set(pVBInfo
->P3c4
, 0x34, value
& 0xFF);
6018 /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */
6019 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x3F, ~0x03,
6020 (value
& 0x600) >> 9);
6021 xgifb_reg_set(pVBInfo
->P3c4
, 0x34, (value
>> 1) & 0xFF);
6022 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x33, ~0x01, value
& 0x01);
6025 /* VRE SR0A[5] CR11[3:0] */
6026 value
= LVDSVRE
- 1;
6027 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0A, ~0x20, (value
& 0x10) << 1);
6028 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x11, ~0x0F, value
& 0x0F);
6030 /* Panel VRE SR3F[7:2] */
6031 if (chip_id
== XG27
)
6032 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x3F, ~0xFC,
6033 (value
<< 2) & 0xFC);
6035 /* SR3F[7] has to be 0, h/w bug */
6036 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x3F, ~0xFC,
6037 (value
<< 2) & 0x7C);
6039 for (temp
= 0, value
= 0; temp
< 3; temp
++) {
6041 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x31, ~0x30, value
);
6042 xgifb_reg_set(pVBInfo
->P3c4
,
6043 0x2B, xgifb_info
->lvds_data
.VCLKData1
);
6044 xgifb_reg_set(pVBInfo
->P3c4
,
6045 0x2C, xgifb_info
->lvds_data
.VCLKData2
);
6049 if (!(modeflag
& Charx8Dot
)) {
6050 inb(pVBInfo
->P3da
); /* reset 3da */
6051 outb(0x13, pVBInfo
->P3c0
); /* set index */
6052 /* set data, panning = 0, shift left 1 dot*/
6053 outb(0x00, pVBInfo
->P3c0
);
6055 inb(pVBInfo
->P3da
); /* Enable Attribute */
6056 outb(0x20, pVBInfo
->P3c0
);
6058 inb(pVBInfo
->P3da
); /* reset 3da */
6063 /* --------------------------------------------------------------------- */
6064 /* Function : XGI_IsLCDON */
6066 /* Output : 0 : Skip PSC Control */
6067 /* 1: Disable PSC */
6069 /* --------------------------------------------------------------------- */
6070 static unsigned char XGI_IsLCDON(struct vb_device_info
*pVBInfo
)
6072 unsigned short tempax
;
6074 tempax
= pVBInfo
->VBInfo
;
6075 if (tempax
& SetCRT2ToDualEdge
)
6077 else if (tempax
& (DisableCRT2Display
| SwitchToCRT2
| SetSimuScanMode
))
6083 /* --------------------------------------------------------------------- */
6084 /* Function : XGI_DisableChISLCD */
6086 /* Output : 0 -> Not LCD Mode */
6088 /* --------------------------------------------------------------------- */
6089 static unsigned char XGI_DisableChISLCD(struct vb_device_info
*pVBInfo
)
6091 unsigned short tempbx
, tempah
;
6093 tempbx
= pVBInfo
->SetFlag
& (DisableChA
| DisableChB
);
6094 tempah
= ~((unsigned short) xgifb_reg_get(pVBInfo
->Part1Port
, 0x2E));
6096 if (tempbx
& (EnableChA
| DisableChA
)) {
6097 if (!(tempah
& 0x08)) /* Chk LCDA Mode */
6101 if (!(tempbx
& (EnableChB
| DisableChB
)))
6104 if (tempah
& 0x01) /* Chk LCDB Mode */
6110 /* --------------------------------------------------------------------- */
6111 /* Function : XGI_EnableChISLCD */
6113 /* Output : 0 -> Not LCD mode */
6115 /* --------------------------------------------------------------------- */
6116 static unsigned char XGI_EnableChISLCD(struct vb_device_info
*pVBInfo
)
6118 unsigned short tempbx
, tempah
;
6120 tempbx
= pVBInfo
->SetFlag
& (EnableChA
| EnableChB
);
6121 tempah
= ~((unsigned short) xgifb_reg_get(pVBInfo
->Part1Port
, 0x2E));
6123 if (tempbx
& (EnableChA
| DisableChA
)) {
6124 if (!(tempah
& 0x08)) /* Chk LCDA Mode */
6128 if (!(tempbx
& (EnableChB
| DisableChB
)))
6131 if (tempah
& 0x01) /* Chk LCDB Mode */
6137 static void XGI_DisableBridge(struct xgifb_video_info
*xgifb_info
,
6138 struct xgi_hw_device_info
*HwDeviceExtension
,
6139 struct vb_device_info
*pVBInfo
)
6141 unsigned short tempah
= 0;
6143 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
| VB_XGI301LV
6144 | VB_XGI302LV
| VB_XGI301C
)) {
6146 if (!(pVBInfo
->VBInfo
&
6147 (DisableCRT2Display
| SetSimuScanMode
))) {
6148 if (pVBInfo
->VBInfo
& SetCRT2ToLCDA
) {
6149 if (pVBInfo
->VBInfo
& SetCRT2ToDualEdge
) {
6150 tempah
= 0x7F; /* Disable Channel A */
6151 if (!(pVBInfo
->VBInfo
& SetCRT2ToLCDA
))
6152 /* Disable Channel B */
6155 if (pVBInfo
->SetFlag
& DisableChB
)
6156 /* force to disable Cahnnel */
6159 if (pVBInfo
->SetFlag
& DisableChA
)
6160 /* Force to disable Channel B */
6166 /* disable part4_1f */
6167 xgifb_reg_and(pVBInfo
->Part4Port
, 0x1F, tempah
);
6169 if (pVBInfo
->VBType
& (VB_XGI302LV
| VB_XGI301C
)) {
6170 if (((pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToLCDA
)))
6171 || (XGI_DisableChISLCD(pVBInfo
))
6172 || (XGI_IsLCDON(pVBInfo
)))
6173 /* LVDS Driver power down */
6174 xgifb_reg_or(pVBInfo
->Part4Port
, 0x30, 0x80);
6177 if ((pVBInfo
->SetFlag
& DisableChA
) || (pVBInfo
->VBInfo
6178 & (DisableCRT2Display
| SetCRT2ToLCDA
6179 | SetSimuScanMode
))) {
6180 if (pVBInfo
->SetFlag
& GatingCRT
)
6181 XGI_EnableGatingCRT(HwDeviceExtension
, pVBInfo
);
6182 XGI_DisplayOff(xgifb_info
, HwDeviceExtension
, pVBInfo
);
6185 if (pVBInfo
->VBInfo
& SetCRT2ToLCDA
) {
6186 if ((pVBInfo
->SetFlag
& DisableChA
) || (pVBInfo
->VBInfo
6189 xgifb_reg_and(pVBInfo
->Part1Port
, 0x1e, 0xdf);
6192 /* disable TV as primary VGA swap */
6193 xgifb_reg_and(pVBInfo
->P3c4
, 0x32, 0xdf);
6195 if ((pVBInfo
->VBInfo
& (SetSimuScanMode
| SetCRT2ToDualEdge
)))
6196 xgifb_reg_and(pVBInfo
->Part2Port
, 0x00, 0xdf);
6198 if ((pVBInfo
->SetFlag
& DisableChB
) ||
6200 (DisableCRT2Display
| SetSimuScanMode
)) ||
6201 ((!(pVBInfo
->VBInfo
& SetCRT2ToLCDA
)) &&
6203 (SetCRT2ToRAMDAC
| SetCRT2ToLCD
| SetCRT2ToTV
))))
6204 xgifb_reg_or(pVBInfo
->Part1Port
, 0x00, 0x80);
6206 if ((pVBInfo
->SetFlag
& DisableChB
) ||
6208 (DisableCRT2Display
| SetSimuScanMode
)) ||
6209 (!(pVBInfo
->VBInfo
& SetCRT2ToLCDA
)) ||
6211 (SetCRT2ToRAMDAC
| SetCRT2ToLCD
| SetCRT2ToTV
))) {
6212 /* save Part1 index 0 */
6213 tempah
= xgifb_reg_get(pVBInfo
->Part1Port
, 0x00);
6214 /* BTDAC = 1, avoid VB reset */
6215 xgifb_reg_or(pVBInfo
->Part1Port
, 0x00, 0x10);
6217 xgifb_reg_and(pVBInfo
->Part1Port
, 0x1E, 0xDF);
6218 /* restore Part1 index 0 */
6219 xgifb_reg_set(pVBInfo
->Part1Port
, 0x00, tempah
);
6221 } else { /* {301} */
6222 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToTV
)) {
6223 xgifb_reg_or(pVBInfo
->Part1Port
, 0x00, 0x80);
6225 xgifb_reg_and(pVBInfo
->Part1Port
, 0x1E, 0xDF);
6226 /* Disable TV asPrimary VGA swap */
6227 xgifb_reg_and(pVBInfo
->P3c4
, 0x32, 0xDF);
6230 if (pVBInfo
->VBInfo
& (DisableCRT2Display
| SetCRT2ToLCDA
6232 XGI_DisplayOff(xgifb_info
, HwDeviceExtension
, pVBInfo
);
6236 /* --------------------------------------------------------------------- */
6237 /* Function : XGI_GetTVPtrIndex */
6240 /* Description : bx 0 : ExtNTSC */
6252 /* --------------------------------------------------------------------- */
6253 static unsigned short XGI_GetTVPtrIndex(struct vb_device_info
*pVBInfo
)
6255 unsigned short tempbx
= 0;
6257 if (pVBInfo
->TVInfo
& SetPALTV
)
6259 if (pVBInfo
->TVInfo
& SetYPbPrMode1080i
)
6261 if (pVBInfo
->TVInfo
& SetYPbPrMode525i
)
6263 if (pVBInfo
->TVInfo
& SetYPbPrMode525p
)
6265 if (pVBInfo
->TVInfo
& SetYPbPrMode750p
)
6267 if (pVBInfo
->TVInfo
& TVSimuMode
)
6273 /* --------------------------------------------------------------------- */
6274 /* Function : XGI_GetTVPtrIndex2 */
6276 /* Output : bx 0 : NTSC */
6280 /* 4 : NTSC1024x768 */
6281 /* 5 : PAL-M 1024x768 */
6283 /* cl 0 : YFilter1 */
6286 /* 1 : 301B/302B/301LV/302LV */
6288 /* --------------------------------------------------------------------- */
6289 static void XGI_GetTVPtrIndex2(unsigned short *tempbx
, unsigned char *tempcl
,
6290 unsigned char *tempch
, struct vb_device_info
*pVBInfo
)
6296 if (pVBInfo
->TVInfo
& SetPALTV
)
6299 if (pVBInfo
->TVInfo
& SetPALMTV
)
6302 if (pVBInfo
->TVInfo
& SetPALNTV
)
6305 if (pVBInfo
->TVInfo
& NTSC1024x768
) {
6307 if (pVBInfo
->TVInfo
& SetPALMTV
)
6311 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
| VB_XGI301LV
6312 | VB_XGI302LV
| VB_XGI301C
)) {
6313 if ((!(pVBInfo
->VBInfo
& SetInSlaveMode
)) || (pVBInfo
->TVInfo
6320 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
| VB_XGI301LV
6321 | VB_XGI302LV
| VB_XGI301C
))
6325 static void XGI_SetDelayComp(struct vb_device_info
*pVBInfo
)
6327 unsigned short index
;
6329 unsigned char tempah
, tempbl
, tempbh
;
6331 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
| VB_XGI301LV
6332 | VB_XGI302LV
| VB_XGI301C
)) {
6333 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToLCDA
6334 | SetCRT2ToTV
| SetCRT2ToRAMDAC
)) {
6338 index
= XGI_GetTVPtrIndex(pVBInfo
); /* Get TV Delay */
6339 tempbl
= pVBInfo
->XGI_TVDelayList
[index
];
6341 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
6342 | VB_XGI301LV
| VB_XGI302LV
6344 tempbl
= pVBInfo
->XGI_TVDelayList2
[index
];
6346 if (pVBInfo
->VBInfo
& SetCRT2ToDualEdge
)
6347 tempbl
= tempbl
>> 4;
6348 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToLCDA
)) {
6350 index
= XGI_GetLCDCapPtr(pVBInfo
);
6351 tempbh
= pVBInfo
->LCDCapList
[index
].
6352 LCD_DelayCompensation
;
6354 if (!(pVBInfo
->VBInfo
& SetCRT2ToLCDA
))
6360 tempah
= xgifb_reg_get(pVBInfo
->Part1Port
, 0x2D);
6362 if (pVBInfo
->VBInfo
& (SetCRT2ToRAMDAC
| SetCRT2ToLCD
6363 | SetCRT2ToTV
)) { /* Channel B */
6368 if (pVBInfo
->VBInfo
& SetCRT2ToLCDA
) { /* Channel A */
6372 xgifb_reg_set(pVBInfo
->Part1Port
, 0x2D, tempah
);
6374 } else if (pVBInfo
->IF_DEF_LVDS
== 1) {
6377 if (pVBInfo
->VBInfo
& SetCRT2ToLCD
) {
6378 /* / Get LCD Delay */
6379 tempah
= pVBInfo
->LCDCapList
[
6380 XGI_GetLCDCapPtr(pVBInfo
)].
6381 LCD_DelayCompensation
;
6383 tempah
= tempah
<< 4;
6384 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x2D, 0x0f,
6390 static void XGI_SetLCDCap_A(unsigned short tempcx
,
6391 struct vb_device_info
*pVBInfo
)
6393 unsigned short temp
;
6395 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x37);
6397 if (temp
& LCDRGB18Bit
) {
6398 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x19, 0x0F,
6400 (unsigned short) (0x20 | (tempcx
& 0x00C0)));
6401 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x1A, 0x7F, 0x80);
6403 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x19, 0x0F,
6404 (unsigned short) (0x30 | (tempcx
& 0x00C0)));
6405 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x1A, 0x7F, 0x00);
6409 /* --------------------------------------------------------------------- */
6410 /* Function : XGI_SetLCDCap_B */
6411 /* Input : cx -> LCD Capability */
6414 /* --------------------------------------------------------------------- */
6415 static void XGI_SetLCDCap_B(unsigned short tempcx
,
6416 struct vb_device_info
*pVBInfo
)
6418 if (tempcx
& EnableLCD24bpp
) /* 24bits */
6419 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x1A, 0xE0,
6420 (unsigned short) (((tempcx
& 0x00ff) >> 6)
6423 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x1A, 0xE0,
6424 (unsigned short) (((tempcx
& 0x00ff) >> 6)
6425 | 0x18)); /* Enable Dither */
6428 static void XGI_LongWait(struct vb_device_info
*pVBInfo
)
6432 i
= xgifb_reg_get(pVBInfo
->P3c4
, 0x1F);
6435 for (i
= 0; i
< 0xFFFF; i
++) {
6436 if (!(inb(pVBInfo
->P3da
) & 0x08))
6440 for (i
= 0; i
< 0xFFFF; i
++) {
6441 if ((inb(pVBInfo
->P3da
) & 0x08))
6447 static void SetSpectrum(struct vb_device_info
*pVBInfo
)
6449 unsigned short index
;
6451 index
= XGI_GetLCDCapPtr(pVBInfo
);
6453 /* disable down spectrum D[4] */
6454 xgifb_reg_and(pVBInfo
->Part4Port
, 0x30, 0x8F);
6455 XGI_LongWait(pVBInfo
);
6456 xgifb_reg_or(pVBInfo
->Part4Port
, 0x30, 0x20); /* reset spectrum */
6457 XGI_LongWait(pVBInfo
);
6459 xgifb_reg_set(pVBInfo
->Part4Port
, 0x31,
6460 pVBInfo
->LCDCapList
[index
].Spectrum_31
);
6461 xgifb_reg_set(pVBInfo
->Part4Port
, 0x32,
6462 pVBInfo
->LCDCapList
[index
].Spectrum_32
);
6463 xgifb_reg_set(pVBInfo
->Part4Port
, 0x33,
6464 pVBInfo
->LCDCapList
[index
].Spectrum_33
);
6465 xgifb_reg_set(pVBInfo
->Part4Port
, 0x34,
6466 pVBInfo
->LCDCapList
[index
].Spectrum_34
);
6467 XGI_LongWait(pVBInfo
);
6468 xgifb_reg_or(pVBInfo
->Part4Port
, 0x30, 0x40); /* enable spectrum */
6471 static void XGI_SetLCDCap(struct vb_device_info
*pVBInfo
)
6473 unsigned short tempcx
;
6475 tempcx
= pVBInfo
->LCDCapList
[XGI_GetLCDCapPtr(pVBInfo
)].LCD_Capability
;
6477 if (pVBInfo
->VBType
&
6482 VB_XGI301C
)) { /* 301LV/302LV only */
6483 if (pVBInfo
->VBType
&
6484 (VB_XGI301LV
| VB_XGI302LV
| VB_XGI301C
)) {
6485 /* Set 301LV Capability */
6486 xgifb_reg_set(pVBInfo
->Part4Port
, 0x24,
6487 (unsigned char) (tempcx
& 0x1F));
6490 xgifb_reg_and_or(pVBInfo
->Part4Port
, 0x0D,
6491 ~((EnableVBCLKDRVLOW
| EnablePLLSPLOW
) >> 8),
6492 (unsigned short) ((tempcx
& (EnableVBCLKDRVLOW
6493 | EnablePLLSPLOW
)) >> 8));
6496 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
| VB_XGI301LV
6497 | VB_XGI302LV
| VB_XGI301C
)) {
6498 if (pVBInfo
->VBInfo
& SetCRT2ToLCD
)
6499 XGI_SetLCDCap_B(tempcx
, pVBInfo
);
6500 else if (pVBInfo
->VBInfo
& SetCRT2ToLCDA
)
6501 XGI_SetLCDCap_A(tempcx
, pVBInfo
);
6503 if (pVBInfo
->VBType
& (VB_XGI302LV
| VB_XGI301C
)) {
6504 if (tempcx
& EnableSpectrum
)
6505 SetSpectrum(pVBInfo
);
6509 XGI_SetLCDCap_A(tempcx
, pVBInfo
);
6513 /* --------------------------------------------------------------------- */
6514 /* Function : XGI_SetAntiFlicker */
6517 /* Description : Set TV Customized Param. */
6518 /* --------------------------------------------------------------------- */
6519 static void XGI_SetAntiFlicker(unsigned short ModeNo
,
6520 unsigned short ModeIdIndex
,
6521 struct vb_device_info
*pVBInfo
)
6523 unsigned short tempbx
, index
;
6525 unsigned char tempah
;
6527 if (pVBInfo
->TVInfo
& (SetYPbPrMode525p
| SetYPbPrMode750p
))
6530 tempbx
= XGI_GetTVPtrIndex(pVBInfo
);
6534 index
= pVBInfo
->SModeIDTable
[ModeIdIndex
].VB_StTVFlickerIndex
;
6536 index
= pVBInfo
->EModeIDTable
[ModeIdIndex
].VB_ExtTVFlickerIndex
;
6539 tempah
= TVAntiFlickList
[tempbx
];
6540 tempah
= tempah
<< 4;
6542 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x0A, 0x8F, tempah
);
6545 static void XGI_SetEdgeEnhance(unsigned short ModeNo
,
6546 unsigned short ModeIdIndex
,
6547 struct vb_device_info
*pVBInfo
)
6549 unsigned short tempbx
, index
;
6551 unsigned char tempah
;
6553 tempbx
= XGI_GetTVPtrIndex(pVBInfo
);
6557 index
= pVBInfo
->SModeIDTable
[ModeIdIndex
].VB_StTVEdgeIndex
;
6559 index
= pVBInfo
->EModeIDTable
[ModeIdIndex
].VB_ExtTVEdgeIndex
;
6562 tempah
= TVEdgeList
[tempbx
];
6563 tempah
= tempah
<< 5;
6565 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x3A, 0x1F, tempah
);
6568 static void XGI_SetPhaseIncr(struct vb_device_info
*pVBInfo
)
6570 unsigned short tempbx
;
6572 unsigned char tempcl
, tempch
;
6574 unsigned long tempData
;
6576 XGI_GetTVPtrIndex2(&tempbx
, &tempcl
, &tempch
, pVBInfo
); /* bx, cl, ch */
6577 tempData
= TVPhaseList
[tempbx
];
6579 xgifb_reg_set(pVBInfo
->Part2Port
, 0x31, (unsigned short) (tempData
6581 xgifb_reg_set(pVBInfo
->Part2Port
, 0x32, (unsigned short) ((tempData
6582 & 0x0000FF00) >> 8));
6583 xgifb_reg_set(pVBInfo
->Part2Port
, 0x33, (unsigned short) ((tempData
6584 & 0x00FF0000) >> 16));
6585 xgifb_reg_set(pVBInfo
->Part2Port
, 0x34, (unsigned short) ((tempData
6586 & 0xFF000000) >> 24));
6589 static void XGI_SetYFilter(unsigned short ModeNo
, unsigned short ModeIdIndex
,
6590 struct vb_device_info
*pVBInfo
)
6592 unsigned short tempbx
, index
;
6594 unsigned char tempcl
, tempch
, tempal
, *filterPtr
;
6596 XGI_GetTVPtrIndex2(&tempbx
, &tempcl
, &tempch
, pVBInfo
); /* bx, cl, ch */
6601 filterPtr
= NTSCYFilter1
;
6605 filterPtr
= PALYFilter1
;
6612 filterPtr
= xgifb_palmn_yfilter1
;
6620 filterPtr
= xgifb_yfilter2
;
6628 tempal
= pVBInfo
->SModeIDTable
[ModeIdIndex
].
6629 VB_StTVYFilterIndex
;
6631 tempal
= pVBInfo
->EModeIDTable
[ModeIdIndex
].
6632 VB_ExtTVYFilterIndex
;
6639 if ((tempcl
== 0) && (tempch
== 1)) {
6640 xgifb_reg_set(pVBInfo
->Part2Port
, 0x35, 0);
6641 xgifb_reg_set(pVBInfo
->Part2Port
, 0x36, 0);
6642 xgifb_reg_set(pVBInfo
->Part2Port
, 0x37, 0);
6643 xgifb_reg_set(pVBInfo
->Part2Port
, 0x38, filterPtr
[index
++]);
6645 xgifb_reg_set(pVBInfo
->Part2Port
, 0x35, filterPtr
[index
++]);
6646 xgifb_reg_set(pVBInfo
->Part2Port
, 0x36, filterPtr
[index
++]);
6647 xgifb_reg_set(pVBInfo
->Part2Port
, 0x37, filterPtr
[index
++]);
6648 xgifb_reg_set(pVBInfo
->Part2Port
, 0x38, filterPtr
[index
++]);
6651 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
| VB_XGI301LV
6652 | VB_XGI302LV
| VB_XGI301C
)) {
6653 xgifb_reg_set(pVBInfo
->Part2Port
, 0x48, filterPtr
[index
++]);
6654 xgifb_reg_set(pVBInfo
->Part2Port
, 0x49, filterPtr
[index
++]);
6655 xgifb_reg_set(pVBInfo
->Part2Port
, 0x4A, filterPtr
[index
++]);
6659 /* --------------------------------------------------------------------- */
6660 /* Function : XGI_OEM310Setting */
6663 /* Description : Customized Param. for 301 */
6664 /* --------------------------------------------------------------------- */
6665 static void XGI_OEM310Setting(unsigned short ModeNo
,
6666 unsigned short ModeIdIndex
,
6667 struct vb_device_info
*pVBInfo
)
6669 XGI_SetDelayComp(pVBInfo
);
6671 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToLCDA
))
6672 XGI_SetLCDCap(pVBInfo
);
6674 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
6675 XGI_SetPhaseIncr(pVBInfo
);
6676 XGI_SetYFilter(ModeNo
, ModeIdIndex
, pVBInfo
);
6677 XGI_SetAntiFlicker(ModeNo
, ModeIdIndex
, pVBInfo
);
6679 if (pVBInfo
->VBType
& VB_XGI301
)
6680 XGI_SetEdgeEnhance(ModeNo
, ModeIdIndex
, pVBInfo
);
6684 /* --------------------------------------------------------------------- */
6685 /* Function : XGI_SetCRT2ModeRegs */
6688 /* Description : Origin code for crt2group */
6689 /* --------------------------------------------------------------------- */
6690 static void XGI_SetCRT2ModeRegs(unsigned short ModeNo
,
6691 struct xgi_hw_device_info
*HwDeviceExtension
,
6692 struct vb_device_info
*pVBInfo
)
6694 unsigned short tempbl
;
6697 unsigned char tempah
;
6700 if (!(pVBInfo
->VBInfo
& DisableCRT2Display
)) {
6701 tempah
= xgifb_reg_get(pVBInfo
->Part1Port
, 0x00);
6702 tempah
&= ~0x10; /* BTRAMDAC */
6703 tempah
|= 0x40; /* BTRAM */
6705 if (pVBInfo
->VBInfo
& (SetCRT2ToRAMDAC
| SetCRT2ToTV
6707 tempah
= 0x40; /* BTDRAM */
6708 if (ModeNo
> 0x13) {
6709 tempcl
= pVBInfo
->ModeType
;
6713 tempah
= (0x008 >> tempcl
);
6719 if (pVBInfo
->VBInfo
& SetInSlaveMode
)
6720 tempah
^= 0x50; /* BTDAC */
6724 xgifb_reg_set(pVBInfo
->Part1Port
, 0x00, tempah
);
6728 if (pVBInfo
->VBInfo
& DisableCRT2Display
) {
6729 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x2e, tempbl
, tempah
);
6734 if (pVBInfo
->VBInfo
& (SetCRT2ToRAMDAC
| SetCRT2ToTV
6735 | SetCRT2ToLCD
| SetCRT2ToLCDA
)) {
6736 if ((pVBInfo
->VBInfo
& SetCRT2ToLCDA
) &&
6737 (!(pVBInfo
->VBInfo
& SetSimuScanMode
))) {
6740 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x2e,
6743 if (pVBInfo
->VBInfo
& SetCRT2ToLCDA
) {
6748 if (pVBInfo
->VBInfo
&
6755 if (!(pVBInfo
->VBInfo
& SetInSlaveMode
))
6758 if (!(pVBInfo
->VBInfo
&
6760 tempah
= tempah
^ 0x05;
6761 if (!(pVBInfo
->VBInfo
&
6763 tempah
= tempah
^ 0x01;
6766 if (!(pVBInfo
->VBInfo
&
6769 xgifb_reg_and_or(pVBInfo
->Part1Port
,
6770 0x2e, tempbl
, tempah
);
6772 xgifb_reg_and_or(pVBInfo
->Part1Port
,
6773 0x2e, tempbl
, tempah
);
6777 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x2e, tempbl
,
6782 if (pVBInfo
->VBInfo
& (SetCRT2ToRAMDAC
| SetCRT2ToTV
| SetCRT2ToLCD
6785 if ((pVBInfo
->ModeType
== ModeVGA
) && (!(pVBInfo
->VBInfo
6786 & SetInSlaveMode
))) {
6791 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
6793 if (ModeNo
> 0x13) {
6794 if (pVBInfo
->VBInfo
& DriverMode
)
6795 tempah
= tempah
^ 0x20;
6799 xgifb_reg_and_or(pVBInfo
->Part4Port
, 0x0D, ~0x0BF, tempah
);
6802 if (pVBInfo
->LCDInfo
& SetLCDDualLink
)
6805 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
6806 if (pVBInfo
->TVInfo
& RPLLDIV2XO
)
6810 if ((pVBInfo
->LCDResInfo
== Panel1280x1024
)
6811 || (pVBInfo
->LCDResInfo
== Panel1280x1024x75
))
6814 if (pVBInfo
->LCDResInfo
== Panel1280x960
)
6817 xgifb_reg_set(pVBInfo
->Part4Port
, 0x0C, tempah
);
6820 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
| VB_XGI301LV
6821 | VB_XGI302LV
| VB_XGI301C
)) {
6825 if (pVBInfo
->VBInfo
& SetCRT2ToDualEdge
) {
6827 if (pVBInfo
->VBInfo
& SetCRT2ToLCDA
)
6828 tempah
|= 0x04; /* shampoo 0129 */
6831 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x13, tempbl
, tempah
);
6834 if (!(pVBInfo
->VBInfo
& DisableCRT2Display
)) {
6835 if (pVBInfo
->VBInfo
& SetCRT2ToDualEdge
)
6839 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x2c, tempbl
, tempah
);
6843 if (!(pVBInfo
->VBInfo
& DisableCRT2Display
)) {
6844 if (pVBInfo
->VBInfo
& SetCRT2ToDualEdge
)
6847 xgifb_reg_and_or(pVBInfo
->Part4Port
, 0x21, tempbl
, tempah
);
6852 if (!(pVBInfo
->VBInfo
& SetCRT2ToLCDA
)) {
6854 if (!(pVBInfo
->VBInfo
& SetCRT2ToDualEdge
))
6858 xgifb_reg_and_or(pVBInfo
->Part4Port
, 0x23, tempbl
, tempah
);
6860 if (pVBInfo
->VBType
& (VB_XGI302LV
| VB_XGI301C
)) {
6861 if (pVBInfo
->LCDInfo
& SetLCDDualLink
) {
6862 xgifb_reg_or(pVBInfo
->Part4Port
, 0x27, 0x20);
6863 xgifb_reg_or(pVBInfo
->Part4Port
, 0x34, 0x10);
6868 static void XGI_CloseCRTC(struct xgi_hw_device_info
*HwDeviceExtension
,
6869 struct vb_device_info
*pVBInfo
)
6871 unsigned short tempbx
;
6875 if (pVBInfo
->VBInfo
& SetCRT2ToLCDA
)
6880 void XGI_UnLockCRT2(struct xgi_hw_device_info
*HwDeviceExtension
,
6881 struct vb_device_info
*pVBInfo
)
6884 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x2f, 0xFF, 0x01);
6888 void XGI_LockCRT2(struct xgi_hw_device_info
*HwDeviceExtension
,
6889 struct vb_device_info
*pVBInfo
)
6892 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x2F, 0xFE, 0x00);
6896 unsigned char XGI_BridgeIsOn(struct vb_device_info
*pVBInfo
)
6898 unsigned short flag
;
6900 if (pVBInfo
->IF_DEF_LVDS
== 1) {
6903 flag
= xgifb_reg_get(pVBInfo
->Part4Port
, 0x00);
6904 if ((flag
== 1) || (flag
== 2))
6905 return 1; /* 301b */
6911 unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info
*pXGIHWDE
,
6912 unsigned short ModeNo
, unsigned short ModeIdIndex
,
6913 struct vb_device_info
*pVBInfo
)
6915 short LCDRefreshIndex
[] = { 0x00, 0x00, 0x03, 0x01 },
6916 LCDARefreshIndex
[] = { 0x00, 0x00, 0x03, 0x01, 0x01,
6919 unsigned short RefreshRateTableIndex
, i
, modeflag
, index
, temp
;
6922 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
6924 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
6929 index
= xgifb_reg_get(pVBInfo
->P3d4
, 0x33);
6930 index
= index
>> pVBInfo
->SelectCRT2Rate
;
6933 if (pVBInfo
->LCDInfo
& LCDNonExpanding
)
6939 if (pVBInfo
->SetFlag
& ProgrammingCRT2
) {
6940 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToLCDA
)) {
6941 if (pVBInfo
->IF_DEF_LVDS
== 0) {
6942 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
6943 | VB_XGI301LV
| VB_XGI302LV
6946 temp
= LCDARefreshIndex
[
6947 pVBInfo
->LCDResInfo
& 0x0F];
6949 temp
= LCDRefreshIndex
[
6950 pVBInfo
->LCDResInfo
& 0x0F];
6960 RefreshRateTableIndex
= pVBInfo
->EModeIDTable
[ModeIdIndex
].REFindex
;
6961 ModeNo
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].ModeID
;
6962 if (pXGIHWDE
->jChipType
>= XG20
) { /* for XG20, XG21, XG27 */
6963 if ((pVBInfo
->RefIndex
[RefreshRateTableIndex
].XRes
== 800) &&
6964 (pVBInfo
->RefIndex
[RefreshRateTableIndex
].YRes
== 600)) {
6968 * do the similar adjustment like XGISearchCRT1Rate() */
6969 if ((pVBInfo
->RefIndex
[RefreshRateTableIndex
].XRes
== 1024) &&
6970 (pVBInfo
->RefIndex
[RefreshRateTableIndex
].YRes
== 768)) {
6973 if ((pVBInfo
->RefIndex
[RefreshRateTableIndex
].XRes
== 1280) &&
6974 (pVBInfo
->RefIndex
[RefreshRateTableIndex
].YRes
== 1024)) {
6981 if (pVBInfo
->RefIndex
[RefreshRateTableIndex
+ i
].
6984 temp
= pVBInfo
->RefIndex
[RefreshRateTableIndex
+ i
].
6986 temp
&= ModeInfoFlag
;
6987 if (temp
< pVBInfo
->ModeType
)
6992 } while (index
!= 0xFFFF);
6993 if (!(pVBInfo
->VBInfo
& SetCRT2ToRAMDAC
)) {
6994 if (pVBInfo
->VBInfo
& SetInSlaveMode
) {
6995 temp
= pVBInfo
->RefIndex
[RefreshRateTableIndex
+ i
- 1].
6997 if (temp
& InterlaceMode
)
7002 if ((pVBInfo
->SetFlag
& ProgrammingCRT2
)) {
7003 temp
= XGI_AjustCRT2Rate(ModeNo
, ModeIdIndex
,
7004 RefreshRateTableIndex
, &i
, pVBInfo
);
7006 return RefreshRateTableIndex
+ i
;
7009 static void XGI_SetLCDAGroup(unsigned short ModeNo
, unsigned short ModeIdIndex
,
7010 struct xgi_hw_device_info
*HwDeviceExtension
,
7011 struct vb_device_info
*pVBInfo
)
7013 unsigned short RefreshRateTableIndex
;
7015 pVBInfo
->SetFlag
|= ProgrammingCRT2
;
7016 RefreshRateTableIndex
= XGI_GetRatePtrCRT2(HwDeviceExtension
, ModeNo
,
7017 ModeIdIndex
, pVBInfo
);
7018 XGI_GetLVDSResInfo(ModeNo
, ModeIdIndex
, pVBInfo
);
7019 XGI_GetLVDSData(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
, pVBInfo
);
7020 XGI_ModCRT1Regs(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
7021 HwDeviceExtension
, pVBInfo
);
7022 XGI_SetLVDSRegs(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
, pVBInfo
);
7023 XGI_SetCRT2ECLK(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
, pVBInfo
);
7026 static unsigned char XGI_SetCRT2Group301(unsigned short ModeNo
,
7027 struct xgi_hw_device_info
*HwDeviceExtension
,
7028 struct vb_device_info
*pVBInfo
)
7030 unsigned short tempbx
, ModeIdIndex
, RefreshRateTableIndex
;
7032 tempbx
= pVBInfo
->VBInfo
;
7033 pVBInfo
->SetFlag
|= ProgrammingCRT2
;
7034 XGI_SearchModeID(ModeNo
, &ModeIdIndex
, pVBInfo
);
7035 pVBInfo
->SelectCRT2Rate
= 4;
7036 RefreshRateTableIndex
= XGI_GetRatePtrCRT2(HwDeviceExtension
, ModeNo
,
7037 ModeIdIndex
, pVBInfo
);
7038 XGI_SaveCRT2Info(ModeNo
, pVBInfo
);
7039 XGI_GetCRT2ResInfo(ModeNo
, ModeIdIndex
, pVBInfo
);
7040 XGI_GetCRT2Data(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
, pVBInfo
);
7041 XGI_PreSetGroup1(ModeNo
, ModeIdIndex
, HwDeviceExtension
,
7042 RefreshRateTableIndex
, pVBInfo
);
7043 XGI_SetGroup1(ModeNo
, ModeIdIndex
, HwDeviceExtension
,
7044 RefreshRateTableIndex
, pVBInfo
);
7045 XGI_SetLockRegs(ModeNo
, ModeIdIndex
, HwDeviceExtension
,
7046 RefreshRateTableIndex
, pVBInfo
);
7047 XGI_SetGroup2(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
7048 HwDeviceExtension
, pVBInfo
);
7049 XGI_SetLCDRegs(ModeNo
, ModeIdIndex
, HwDeviceExtension
,
7050 RefreshRateTableIndex
, pVBInfo
);
7051 XGI_SetTap4Regs(pVBInfo
);
7052 XGI_SetGroup3(ModeNo
, ModeIdIndex
, pVBInfo
);
7053 XGI_SetGroup4(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
7054 HwDeviceExtension
, pVBInfo
);
7055 XGI_SetCRT2VCLK(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
, pVBInfo
);
7056 XGI_SetGroup5(ModeNo
, ModeIdIndex
, pVBInfo
);
7057 XGI_AutoThreshold(pVBInfo
);
7061 void XGI_SenseCRT1(struct vb_device_info
*pVBInfo
)
7063 unsigned char CRTCData
[17] = { 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81,
7064 0x0B, 0x3E, 0xE9, 0x0B, 0xDF, 0xE7, 0x04, 0x00, 0x00,
7067 unsigned char SR01
= 0, SR1F
= 0, SR07
= 0, SR06
= 0;
7069 unsigned char CR17
, CR63
, SR31
;
7070 unsigned short temp
;
7071 unsigned char DAC_TEST_PARMS
[3] = { 0x0F, 0x0F, 0x0F };
7074 xgifb_reg_set(pVBInfo
->P3c4
, 0x05, 0x86);
7076 /* [2004/05/06] Vicent to fix XG42 single LCD sense to CRT+LCD */
7077 xgifb_reg_set(pVBInfo
->P3d4
, 0x57, 0x4A);
7078 xgifb_reg_set(pVBInfo
->P3d4
, 0x53, (unsigned char) (xgifb_reg_get(
7079 pVBInfo
->P3d4
, 0x53) | 0x02));
7081 SR31
= (unsigned char) xgifb_reg_get(pVBInfo
->P3c4
, 0x31);
7082 CR63
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x63);
7083 SR01
= (unsigned char) xgifb_reg_get(pVBInfo
->P3c4
, 0x01);
7085 xgifb_reg_set(pVBInfo
->P3c4
, 0x01, (unsigned char) (SR01
& 0xDF));
7086 xgifb_reg_set(pVBInfo
->P3d4
, 0x63, (unsigned char) (CR63
& 0xBF));
7088 CR17
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x17);
7089 xgifb_reg_set(pVBInfo
->P3d4
, 0x17, (unsigned char) (CR17
| 0x80));
7091 SR1F
= (unsigned char) xgifb_reg_get(pVBInfo
->P3c4
, 0x1F);
7092 xgifb_reg_set(pVBInfo
->P3c4
, 0x1F, (unsigned char) (SR1F
| 0x04));
7094 SR07
= (unsigned char) xgifb_reg_get(pVBInfo
->P3c4
, 0x07);
7095 xgifb_reg_set(pVBInfo
->P3c4
, 0x07, (unsigned char) (SR07
& 0xFB));
7096 SR06
= (unsigned char) xgifb_reg_get(pVBInfo
->P3c4
, 0x06);
7097 xgifb_reg_set(pVBInfo
->P3c4
, 0x06, (unsigned char) (SR06
& 0xC3));
7099 xgifb_reg_set(pVBInfo
->P3d4
, 0x11, 0x00);
7101 for (i
= 0; i
< 8; i
++)
7102 xgifb_reg_set(pVBInfo
->P3d4
, (unsigned short) i
, CRTCData
[i
]);
7104 for (i
= 8; i
< 11; i
++)
7105 xgifb_reg_set(pVBInfo
->P3d4
, (unsigned short) (i
+ 8),
7108 for (i
= 11; i
< 13; i
++)
7109 xgifb_reg_set(pVBInfo
->P3d4
, (unsigned short) (i
+ 4),
7112 for (i
= 13; i
< 16; i
++)
7113 xgifb_reg_set(pVBInfo
->P3c4
, (unsigned short) (i
- 3),
7116 xgifb_reg_set(pVBInfo
->P3c4
, 0x0E, (unsigned char) (CRTCData
[16]
7119 xgifb_reg_set(pVBInfo
->P3c4
, 0x31, 0x00);
7120 xgifb_reg_set(pVBInfo
->P3c4
, 0x2B, 0x1B);
7121 xgifb_reg_set(pVBInfo
->P3c4
, 0x2C, 0xE1);
7123 outb(0x00, pVBInfo
->P3c8
);
7125 for (i
= 0; i
< 256; i
++) {
7126 outb((unsigned char) DAC_TEST_PARMS
[0], (pVBInfo
->P3c8
+ 1));
7127 outb((unsigned char) DAC_TEST_PARMS
[1], (pVBInfo
->P3c8
+ 1));
7128 outb((unsigned char) DAC_TEST_PARMS
[2], (pVBInfo
->P3c8
+ 1));
7133 XGI_WaitDisply(pVBInfo
);
7134 temp
= inb(pVBInfo
->P3c2
);
7137 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x32, 0xDF, 0x20);
7139 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x32, 0xDF, 0x00);
7141 /* alan, avoid display something, set BLACK DAC if not restore DAC */
7142 outb(0x00, pVBInfo
->P3c8
);
7144 for (i
= 0; i
< 256; i
++) {
7145 outb(0, (pVBInfo
->P3c8
+ 1));
7146 outb(0, (pVBInfo
->P3c8
+ 1));
7147 outb(0, (pVBInfo
->P3c8
+ 1));
7150 xgifb_reg_set(pVBInfo
->P3c4
, 0x01, SR01
);
7151 xgifb_reg_set(pVBInfo
->P3d4
, 0x63, CR63
);
7152 xgifb_reg_set(pVBInfo
->P3c4
, 0x31, SR31
);
7154 /* [2004/05/11] Vicent */
7155 xgifb_reg_set(pVBInfo
->P3d4
, 0x53, (unsigned char) (xgifb_reg_get(
7156 pVBInfo
->P3d4
, 0x53) & 0xFD));
7157 xgifb_reg_set(pVBInfo
->P3c4
, 0x1F, (unsigned char) SR1F
);
7160 static void XGI_EnableBridge(struct xgifb_video_info
*xgifb_info
,
7161 struct xgi_hw_device_info
*HwDeviceExtension
,
7162 struct vb_device_info
*pVBInfo
)
7164 unsigned short tempah
;
7166 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
| VB_XGI301LV
7167 | VB_XGI302LV
| VB_XGI301C
)) {
7168 if (!(pVBInfo
->SetFlag
& DisableChA
)) {
7169 if (pVBInfo
->SetFlag
& EnableChA
) {
7171 xgifb_reg_set(pVBInfo
->Part1Port
, 0x1E, 0x20);
7173 if (pVBInfo
->VBInfo
& SetCRT2ToDualEdge
) {
7175 xgifb_reg_set(pVBInfo
->Part1Port
,
7181 if (!(pVBInfo
->SetFlag
& DisableChB
)) {
7182 if ((pVBInfo
->SetFlag
& EnableChB
) || (pVBInfo
->VBInfo
7183 & (SetCRT2ToLCD
| SetCRT2ToTV
7184 | SetCRT2ToRAMDAC
))) {
7185 tempah
= (unsigned char) xgifb_reg_get(
7186 pVBInfo
->P3c4
, 0x32);
7188 if (pVBInfo
->VBInfo
& SetInSlaveMode
) {
7189 if (!(pVBInfo
->VBInfo
&
7193 xgifb_reg_set(pVBInfo
->P3c4
, 0x32, tempah
);
7194 xgifb_reg_or(pVBInfo
->P3c4
, 0x1E, 0x20);
7196 tempah
= (unsigned char) xgifb_reg_get(
7197 pVBInfo
->Part1Port
, 0x2E);
7199 if (!(tempah
& 0x80))
7200 xgifb_reg_or(pVBInfo
->Part1Port
,
7202 xgifb_reg_and(pVBInfo
->Part1Port
, 0x00, 0x7F);
7206 if ((pVBInfo
->SetFlag
& (EnableChA
| EnableChB
))
7207 || (!(pVBInfo
->VBInfo
& DisableCRT2Display
))) {
7208 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x00, ~0xE0,
7209 0x20); /* shampoo 0129 */
7210 if (pVBInfo
->VBType
& (VB_XGI302LV
| VB_XGI301C
)) {
7211 if (!XGI_DisableChISLCD(pVBInfo
)) {
7212 if (XGI_EnableChISLCD(pVBInfo
) ||
7214 (SetCRT2ToLCD
| SetCRT2ToLCDA
)))
7215 /* LVDS PLL power on */
7221 /* LVDS Driver power on */
7222 xgifb_reg_and(pVBInfo
->Part4Port
, 0x30, 0x7F);
7228 if (!(pVBInfo
->VBInfo
& DisableCRT2Display
)) {
7231 if (!(pVBInfo
->VBInfo
& SetSimuScanMode
)) {
7232 if (pVBInfo
->VBInfo
& SetCRT2ToLCDA
) {
7233 if (pVBInfo
->VBInfo
&
7234 SetCRT2ToDualEdge
) {
7235 tempah
= tempah
& 0x40;
7236 if (pVBInfo
->VBInfo
&
7238 tempah
= tempah
^ 0xC0;
7240 if (pVBInfo
->SetFlag
&
7244 if (pVBInfo
->SetFlag
&
7248 if (pVBInfo
->SetFlag
&
7252 if (pVBInfo
->SetFlag
&
7260 /* EnablePart4_1F */
7261 xgifb_reg_or(pVBInfo
->Part4Port
, 0x1F, tempah
);
7263 if (!(pVBInfo
->SetFlag
& DisableChA
)) {
7264 if (!(pVBInfo
->SetFlag
& GatingCRT
)) {
7265 XGI_DisableGatingCRT(HwDeviceExtension
,
7267 XGI_DisplayOn(xgifb_info
, HwDeviceExtension
,
7273 if (pVBInfo
->VBInfo
& (SetCRT2ToTV
| SetCRT2ToLCD
7276 xgifb_reg_or(pVBInfo
->Part1Port
, 0x1E, 0x20);
7278 tempah
= (unsigned char) xgifb_reg_get(pVBInfo
->Part1Port
,
7280 if (!(tempah
& 0x80))
7281 xgifb_reg_or(pVBInfo
->Part1Port
, 0x2E, 0x80);
7283 xgifb_reg_and(pVBInfo
->Part1Port
, 0x00, 0x7F);
7284 XGI_DisplayOn(xgifb_info
, HwDeviceExtension
, pVBInfo
);
7288 static void XGI_SetCRT1Group(struct xgifb_video_info
*xgifb_info
,
7289 struct xgi_hw_device_info
*HwDeviceExtension
,
7290 unsigned short ModeNo
, unsigned short ModeIdIndex
,
7291 struct vb_device_info
*pVBInfo
)
7293 unsigned short StandTableIndex
, RefreshRateTableIndex
, b3CC
, temp
;
7295 unsigned short XGINew_P3cc
= pVBInfo
->P3cc
;
7297 StandTableIndex
= XGI_GetModePtr(ModeNo
, ModeIdIndex
, pVBInfo
);
7298 XGI_SetSeqRegs(ModeNo
, StandTableIndex
, ModeIdIndex
, pVBInfo
);
7299 outb(pVBInfo
->StandTable
[StandTableIndex
].MISC
, pVBInfo
->P3c2
);
7300 XGI_SetCRTCRegs(HwDeviceExtension
, StandTableIndex
, pVBInfo
);
7301 XGI_SetATTRegs(ModeNo
, StandTableIndex
, ModeIdIndex
, pVBInfo
);
7302 XGI_SetGRCRegs(StandTableIndex
, pVBInfo
);
7303 XGI_ClearExt1Regs(pVBInfo
);
7305 if (HwDeviceExtension
->jChipType
== XG27
) {
7306 if (pVBInfo
->IF_DEF_LVDS
== 0)
7307 XGI_SetDefaultVCLK(pVBInfo
);
7310 temp
= ~ProgrammingCRT2
;
7311 pVBInfo
->SetFlag
&= temp
;
7312 pVBInfo
->SelectCRT2Rate
= 0;
7314 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
| VB_XGI301LV
7315 | VB_XGI302LV
| VB_XGI301C
)) {
7316 if (pVBInfo
->VBInfo
& (SetSimuScanMode
| SetCRT2ToLCDA
7317 | SetInSlaveMode
)) {
7318 pVBInfo
->SetFlag
|= ProgrammingCRT2
;
7322 RefreshRateTableIndex
= XGI_GetRatePtrCRT2(HwDeviceExtension
, ModeNo
,
7323 ModeIdIndex
, pVBInfo
);
7324 if (RefreshRateTableIndex
!= 0xFFFF) {
7325 XGI_SetSync(RefreshRateTableIndex
, pVBInfo
);
7326 XGI_SetCRT1CRTC(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
7327 pVBInfo
, HwDeviceExtension
);
7328 XGI_SetCRT1DE(HwDeviceExtension
, ModeNo
, ModeIdIndex
,
7329 RefreshRateTableIndex
, pVBInfo
);
7330 XGI_SetCRT1Offset(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
7331 HwDeviceExtension
, pVBInfo
);
7332 XGI_SetCRT1VCLK(ModeNo
, ModeIdIndex
, HwDeviceExtension
,
7333 RefreshRateTableIndex
, pVBInfo
);
7336 if ((HwDeviceExtension
->jChipType
>= XG20
) &&
7337 (HwDeviceExtension
->jChipType
< XG27
)) { /* fix H/W DCLK/2 bug */
7338 if ((ModeNo
== 0x00) | (ModeNo
== 0x01)) {
7339 xgifb_reg_set(pVBInfo
->P3c4
, 0x2B, 0x4E);
7340 xgifb_reg_set(pVBInfo
->P3c4
, 0x2C, 0xE9);
7341 b3CC
= (unsigned char) inb(XGINew_P3cc
);
7342 outb((b3CC
|= 0x0C), XGINew_P3cc
);
7343 } else if ((ModeNo
== 0x04) | (ModeNo
== 0x05) | (ModeNo
7345 xgifb_reg_set(pVBInfo
->P3c4
, 0x2B, 0x1B);
7346 xgifb_reg_set(pVBInfo
->P3c4
, 0x2C, 0xE3);
7347 b3CC
= (unsigned char) inb(XGINew_P3cc
);
7348 outb((b3CC
|= 0x0C), XGINew_P3cc
);
7352 if (HwDeviceExtension
->jChipType
>= XG21
) {
7353 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x38);
7356 if (HwDeviceExtension
->jChipType
== XG27
)
7357 XGI_SetXG27CRTC(ModeNo
, ModeIdIndex
,
7358 RefreshRateTableIndex
, pVBInfo
);
7360 XGI_SetXG21CRTC(ModeNo
, ModeIdIndex
,
7361 RefreshRateTableIndex
, pVBInfo
);
7363 XGI_UpdateXG21CRTC(ModeNo
, pVBInfo
,
7364 RefreshRateTableIndex
);
7366 xgifb_set_lcd(HwDeviceExtension
->jChipType
,
7367 pVBInfo
, RefreshRateTableIndex
, ModeNo
);
7369 if (pVBInfo
->IF_DEF_LVDS
== 1)
7370 xgifb_set_lvds(xgifb_info
,
7371 HwDeviceExtension
->jChipType
,
7372 ModeNo
, ModeIdIndex
, pVBInfo
);
7376 pVBInfo
->SetFlag
&= (~ProgrammingCRT2
);
7377 XGI_SetCRT1FIFO(ModeNo
, HwDeviceExtension
, pVBInfo
);
7378 XGI_SetCRT1ModeRegs(HwDeviceExtension
, ModeNo
, ModeIdIndex
,
7379 RefreshRateTableIndex
, pVBInfo
);
7380 XGI_LoadDAC(ModeNo
, ModeIdIndex
, pVBInfo
);
7383 unsigned char XGISetModeNew(struct xgifb_video_info
*xgifb_info
,
7384 struct xgi_hw_device_info
*HwDeviceExtension
,
7385 unsigned short ModeNo
)
7387 unsigned short ModeIdIndex
;
7388 struct vb_device_info VBINF
;
7389 struct vb_device_info
*pVBInfo
= &VBINF
;
7390 pVBInfo
->BaseAddr
= (unsigned long) HwDeviceExtension
->pjIOAddress
;
7391 pVBInfo
->IF_DEF_LVDS
= 0;
7392 pVBInfo
->IF_DEF_LCDA
= 1;
7394 if (HwDeviceExtension
->jChipType
>= XG20
) { /* kuku 2004/06/25 */
7395 pVBInfo
->IF_DEF_YPbPr
= 0;
7396 pVBInfo
->IF_DEF_HiVision
= 0;
7397 pVBInfo
->IF_DEF_CRT2Monitor
= 0;
7398 pVBInfo
->VBType
= 0; /*set VBType default 0*/
7400 pVBInfo
->IF_DEF_YPbPr
= 1;
7401 pVBInfo
->IF_DEF_HiVision
= 1;
7402 pVBInfo
->IF_DEF_CRT2Monitor
= 1;
7405 pVBInfo
->P3c4
= pVBInfo
->BaseAddr
+ 0x14;
7406 pVBInfo
->P3d4
= pVBInfo
->BaseAddr
+ 0x24;
7407 pVBInfo
->P3c0
= pVBInfo
->BaseAddr
+ 0x10;
7408 pVBInfo
->P3ce
= pVBInfo
->BaseAddr
+ 0x1e;
7409 pVBInfo
->P3c2
= pVBInfo
->BaseAddr
+ 0x12;
7410 pVBInfo
->P3cc
= pVBInfo
->BaseAddr
+ 0x1C;
7411 pVBInfo
->P3ca
= pVBInfo
->BaseAddr
+ 0x1a;
7412 pVBInfo
->P3c6
= pVBInfo
->BaseAddr
+ 0x16;
7413 pVBInfo
->P3c7
= pVBInfo
->BaseAddr
+ 0x17;
7414 pVBInfo
->P3c8
= pVBInfo
->BaseAddr
+ 0x18;
7415 pVBInfo
->P3c9
= pVBInfo
->BaseAddr
+ 0x19;
7416 pVBInfo
->P3da
= pVBInfo
->BaseAddr
+ 0x2A;
7417 pVBInfo
->Part0Port
= pVBInfo
->BaseAddr
+ XGI_CRT2_PORT_00
;
7418 pVBInfo
->Part1Port
= pVBInfo
->BaseAddr
+ XGI_CRT2_PORT_04
;
7419 pVBInfo
->Part2Port
= pVBInfo
->BaseAddr
+ XGI_CRT2_PORT_10
;
7420 pVBInfo
->Part3Port
= pVBInfo
->BaseAddr
+ XGI_CRT2_PORT_12
;
7421 pVBInfo
->Part4Port
= pVBInfo
->BaseAddr
+ XGI_CRT2_PORT_14
;
7422 pVBInfo
->Part5Port
= pVBInfo
->BaseAddr
+ XGI_CRT2_PORT_14
+ 2;
7424 /* for x86 Linux, XG21 LVDS */
7425 if (HwDeviceExtension
->jChipType
== XG21
) {
7426 if ((xgifb_reg_get(pVBInfo
->P3d4
, 0x38) & 0xE0) == 0xC0)
7427 pVBInfo
->IF_DEF_LVDS
= 1;
7429 if (HwDeviceExtension
->jChipType
== XG27
) {
7430 if ((xgifb_reg_get(pVBInfo
->P3d4
, 0x38) & 0xE0) == 0xC0) {
7431 if (xgifb_reg_get(pVBInfo
->P3d4
, 0x30) & 0x20)
7432 pVBInfo
->IF_DEF_LVDS
= 1;
7436 if (HwDeviceExtension
->jChipType
< XG20
) /* kuku 2004/06/25 */
7437 XGI_GetVBType(pVBInfo
);
7439 InitTo330Pointer(HwDeviceExtension
->jChipType
, pVBInfo
);
7441 ModeNo
= ModeNo
& 0x7F;
7442 xgifb_reg_set(pVBInfo
->P3c4
, 0x05, 0x86);
7444 if (HwDeviceExtension
->jChipType
< XG20
) /* kuku 2004/06/25 1.Openkey */
7445 XGI_UnLockCRT2(HwDeviceExtension
, pVBInfo
);
7447 XGI_SearchModeID(ModeNo
, &ModeIdIndex
, pVBInfo
);
7449 if (HwDeviceExtension
->jChipType
< XG20
) { /* kuku 2004/06/25 */
7450 XGI_GetVBInfo(ModeNo
, ModeIdIndex
, HwDeviceExtension
, pVBInfo
);
7451 XGI_GetTVInfo(ModeNo
, ModeIdIndex
, pVBInfo
);
7452 XGI_GetLCDInfo(ModeNo
, ModeIdIndex
, pVBInfo
);
7453 XGI_DisableBridge(xgifb_info
, HwDeviceExtension
, pVBInfo
);
7455 if (pVBInfo
->VBInfo
& (SetSimuScanMode
| SetCRT2ToLCDA
)) {
7456 XGI_SetCRT1Group(xgifb_info
, HwDeviceExtension
, ModeNo
,
7457 ModeIdIndex
, pVBInfo
);
7459 if (pVBInfo
->VBInfo
& SetCRT2ToLCDA
) {
7460 XGI_SetLCDAGroup(ModeNo
, ModeIdIndex
,
7461 HwDeviceExtension
, pVBInfo
);
7464 if (!(pVBInfo
->VBInfo
& SwitchToCRT2
)) {
7465 XGI_SetCRT1Group(xgifb_info
,
7466 HwDeviceExtension
, ModeNo
,
7467 ModeIdIndex
, pVBInfo
);
7468 if (pVBInfo
->VBInfo
& SetCRT2ToLCDA
) {
7469 XGI_SetLCDAGroup(ModeNo
, ModeIdIndex
,
7476 if (pVBInfo
->VBInfo
& (SetSimuScanMode
| SwitchToCRT2
)) {
7477 switch (HwDeviceExtension
->ujVBChipID
) {
7479 XGI_SetCRT2Group301(ModeNo
, HwDeviceExtension
,
7480 pVBInfo
); /*add for CRT2 */
7484 XGI_SetCRT2Group301(ModeNo
, HwDeviceExtension
,
7485 pVBInfo
); /*add for CRT2 */
7493 XGI_SetCRT2ModeRegs(ModeNo
, HwDeviceExtension
, pVBInfo
);
7494 XGI_OEM310Setting(ModeNo
, ModeIdIndex
, pVBInfo
); /*0212*/
7495 XGI_CloseCRTC(HwDeviceExtension
, pVBInfo
);
7496 XGI_EnableBridge(xgifb_info
, HwDeviceExtension
, pVBInfo
);
7499 if (pVBInfo
->IF_DEF_LVDS
== 1)
7500 if (!XGI_XG21CheckLVDSMode(xgifb_info
, ModeNo
,
7505 if (ModeNo
<= 0x13) {
7506 pVBInfo
->ModeType
= pVBInfo
->SModeIDTable
[ModeIdIndex
].
7507 St_ModeFlag
& ModeInfoFlag
;
7509 pVBInfo
->ModeType
= pVBInfo
->EModeIDTable
[ModeIdIndex
].
7510 Ext_ModeFlag
& ModeInfoFlag
;
7513 pVBInfo
->SetFlag
= 0;
7514 pVBInfo
->VBInfo
= DisableCRT2Display
;
7516 XGI_DisplayOff(xgifb_info
, HwDeviceExtension
, pVBInfo
);
7518 XGI_SetCRT1Group(xgifb_info
, HwDeviceExtension
, ModeNo
,
7519 ModeIdIndex
, pVBInfo
);
7521 XGI_DisplayOn(xgifb_info
, HwDeviceExtension
, pVBInfo
);
7524 XGI_UpdateModeInfo(HwDeviceExtension
, pVBInfo
);
7526 if (HwDeviceExtension
->jChipType
< XG20
) { /* kuku 2004/06/25 */
7527 XGI_LockCRT2(HwDeviceExtension
, pVBInfo
);