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 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 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 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 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 /* add for new UNIVGABIOS */
71 /* XGINew_UBLCDDataTable =
72 * (struct XGI_LCDDataTablStruct *) XGI_LCDDataTable; */
73 /* XGINew_UBTVDataTable = (XGI_TVDataTablStruct *) XGI_TVDataTable; */
75 pVBInfo
->MCLKData
= (struct XGI_MCLKDataStruct
*) XGI340New_MCLKData
;
76 pVBInfo
->ECLKData
= (struct XGI_ECLKDataStruct
*) XGI340_ECLKData
;
77 pVBInfo
->VCLKData
= (struct XGI_VCLKDataStruct
*) XGI_VCLKData
;
78 pVBInfo
->VBVCLKData
= (struct XGI_VBVCLKDataStruct
*) XGI_VBVCLKData
;
79 pVBInfo
->ScreenOffset
= XGI330_ScreenOffset
;
80 pVBInfo
->StResInfo
= (struct XGI_StResInfoStruct
*) XGI330_StResInfo
;
82 = (struct XGI_ModeResInfoStruct
*) XGI330_ModeResInfo
;
84 pVBInfo
->pOutputSelect
= &XGI330_OutputSelect
;
85 pVBInfo
->pSoftSetting
= &XGI330_SoftSetting
;
86 pVBInfo
->pSR07
= &XGI330_SR07
;
87 pVBInfo
->LCDResInfo
= 0;
88 pVBInfo
->LCDTypeInfo
= 0;
93 pVBInfo
->SR15
= XGI340_SR13
;
94 pVBInfo
->CR40
= XGI340_cr41
;
95 pVBInfo
->SR25
= XGI330_sr25
;
96 pVBInfo
->pSR31
= &XGI330_sr31
;
97 pVBInfo
->pSR32
= &XGI330_sr32
;
98 pVBInfo
->CR6B
= XGI340_CR6B
;
99 pVBInfo
->CR6E
= XGI340_CR6E
;
100 pVBInfo
->CR6F
= XGI340_CR6F
;
101 pVBInfo
->CR89
= XGI340_CR89
;
102 pVBInfo
->AGPReg
= XGI340_AGPReg
;
103 pVBInfo
->SR16
= XGI340_SR16
;
104 pVBInfo
->pCRCF
= &XG40_CRCF
;
105 pVBInfo
->pXGINew_DRAMTypeDefinition
= &XG40_DRAMTypeDefinition
;
107 pVBInfo
->CR49
= XGI330_CR49
;
108 pVBInfo
->pSR1F
= &XGI330_SR1F
;
109 pVBInfo
->pSR21
= &XGI330_SR21
;
110 pVBInfo
->pSR22
= &XGI330_SR22
;
111 pVBInfo
->pSR23
= &XGI330_SR23
;
112 pVBInfo
->pSR24
= &XGI330_SR24
;
113 pVBInfo
->pSR33
= &XGI330_SR33
;
115 pVBInfo
->pCRT2Data_1_2
= &XGI330_CRT2Data_1_2
;
116 pVBInfo
->pCRT2Data_4_D
= &XGI330_CRT2Data_4_D
;
117 pVBInfo
->pCRT2Data_4_E
= &XGI330_CRT2Data_4_E
;
118 pVBInfo
->pCRT2Data_4_10
= &XGI330_CRT2Data_4_10
;
119 pVBInfo
->pRGBSenseData
= &XGI330_RGBSenseData
;
120 pVBInfo
->pVideoSenseData
= &XGI330_VideoSenseData
;
121 pVBInfo
->pYCSenseData
= &XGI330_YCSenseData
;
122 pVBInfo
->pRGBSenseData2
= &XGI330_RGBSenseData2
;
123 pVBInfo
->pVideoSenseData2
= &XGI330_VideoSenseData2
;
124 pVBInfo
->pYCSenseData2
= &XGI330_YCSenseData2
;
126 pVBInfo
->NTSCTiming
= XGI330_NTSCTiming
;
127 pVBInfo
->PALTiming
= XGI330_PALTiming
;
128 pVBInfo
->HiTVExtTiming
= XGI330_HiTVExtTiming
;
129 pVBInfo
->HiTVSt1Timing
= XGI330_HiTVSt1Timing
;
130 pVBInfo
->HiTVSt2Timing
= XGI330_HiTVSt2Timing
;
131 pVBInfo
->HiTVTextTiming
= XGI330_HiTVTextTiming
;
132 pVBInfo
->YPbPr750pTiming
= XGI330_YPbPr750pTiming
;
133 pVBInfo
->YPbPr525pTiming
= XGI330_YPbPr525pTiming
;
134 pVBInfo
->YPbPr525iTiming
= XGI330_YPbPr525iTiming
;
135 pVBInfo
->HiTVGroup3Data
= XGI330_HiTVGroup3Data
;
136 pVBInfo
->HiTVGroup3Simu
= XGI330_HiTVGroup3Simu
;
137 pVBInfo
->HiTVGroup3Text
= XGI330_HiTVGroup3Text
;
138 pVBInfo
->Ren525pGroup3
= XGI330_Ren525pGroup3
;
139 pVBInfo
->Ren750pGroup3
= XGI330_Ren750pGroup3
;
141 pVBInfo
->TimingH
= (struct XGI_TimingHStruct
*) XGI_TimingH
;
142 pVBInfo
->TimingV
= (struct XGI_TimingVStruct
*) XGI_TimingV
;
143 pVBInfo
->UpdateCRT1
= (struct XGI_XG21CRT1Struct
*) XGI_UpdateCRT1Table
;
145 /* 310 customization related */
146 if ((pVBInfo
->VBType
& VB_XGI301LV
) || (pVBInfo
->VBType
& VB_XGI302LV
))
147 pVBInfo
->LCDCapList
= XGI_LCDDLCapList
;
149 pVBInfo
->LCDCapList
= XGI_LCDCapList
;
151 if ((ChipType
== XG21
) || (ChipType
== XG27
))
152 pVBInfo
->XG21_LVDSCapList
= XGI21_LCDCapList
;
154 pVBInfo
->XGI_TVDelayList
= XGI301TVDelayList
;
155 pVBInfo
->XGI_TVDelayList2
= XGI301TVDelayList2
;
157 pVBInfo
->pXGINew_I2CDefinition
= &XG40_I2CDefinition
;
159 if (ChipType
>= XG20
)
160 pVBInfo
->pXGINew_CR97
= &XG20_CR97
;
162 if (ChipType
== XG27
) {
164 = (struct XGI_MCLKDataStruct
*) XGI27New_MCLKData
;
165 pVBInfo
->CR40
= XGI27_cr41
;
166 pVBInfo
->pXGINew_CR97
= &XG27_CR97
;
167 pVBInfo
->pSR36
= &XG27_SR36
;
168 pVBInfo
->pCR8F
= &XG27_CR8F
;
169 pVBInfo
->pCRD0
= XG27_CRD0
;
170 pVBInfo
->pCRDE
= XG27_CRDE
;
171 pVBInfo
->pSR40
= &XG27_SR40
;
172 pVBInfo
->pSR41
= &XG27_SR41
;
176 if (ChipType
>= XG20
) {
177 pVBInfo
->pDVOSetting
= &XG21_DVOSetting
;
178 pVBInfo
->pCR2E
= &XG21_CR2E
;
179 pVBInfo
->pCR2F
= &XG21_CR2F
;
180 pVBInfo
->pCR46
= &XG21_CR46
;
181 pVBInfo
->pCR47
= &XG21_CR47
;
186 static unsigned char XGI_GetModePtr(unsigned short ModeNo
,
187 unsigned short ModeIdIndex
,
188 struct vb_device_info
*pVBInfo
)
193 index
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_StTableIndex
;
195 if (pVBInfo
->ModeType
<= 0x02)
196 index
= 0x1B; /* 02 -> ModeEGA */
200 return index
; /* Get pVBInfo->StandTable index */
203 static void XGI_SetSeqRegs(unsigned short ModeNo
,
204 unsigned short StandTableIndex
,
205 unsigned short ModeIdIndex
,
206 struct vb_device_info
*pVBInfo
)
208 unsigned char tempah
, SRdata
;
209 unsigned short i
, modeflag
;
212 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
214 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
216 xgifb_reg_set(pVBInfo
->P3c4
, 0x00, 0x03); /* Set SR0 */
217 tempah
= pVBInfo
->StandTable
[StandTableIndex
].SR
[0];
220 if (pVBInfo
->VBInfo
& SetCRT2ToLCDA
) {
223 if (pVBInfo
->VBInfo
& (SetCRT2ToTV
| SetCRT2ToLCD
)) {
224 if (pVBInfo
->VBInfo
& SetInSlaveMode
)
229 tempah
|= 0x20; /* screen off */
230 xgifb_reg_set(pVBInfo
->P3c4
, 0x01, tempah
); /* Set SR1 */
232 for (i
= 02; i
<= 04; i
++) {
233 /* Get SR2,3,4 from file */
234 SRdata
= pVBInfo
->StandTable
[StandTableIndex
].SR
[i
- 1];
235 xgifb_reg_set(pVBInfo
->P3c4
, i
, SRdata
); /* Set SR2 3 4 */
239 static void XGI_SetMiscRegs(unsigned short StandTableIndex
,
240 struct vb_device_info
*pVBInfo
)
242 unsigned char Miscdata
;
244 /* Get Misc from file */
245 Miscdata
= pVBInfo
->StandTable
[StandTableIndex
].MISC
;
247 if (pVBInfo->VBType & (VB_XGI301B |
252 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
258 outb(Miscdata
, pVBInfo
->P3c2
); /* Set Misc(3c2) */
261 static void XGI_SetCRTCRegs(struct xgi_hw_device_info
*HwDeviceExtension
,
262 unsigned short StandTableIndex
,
263 struct vb_device_info
*pVBInfo
)
265 unsigned char CRTCdata
;
268 CRTCdata
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x11);
270 xgifb_reg_set(pVBInfo
->P3d4
, 0x11, CRTCdata
); /* Unlock CRTC */
272 for (i
= 0; i
<= 0x18; i
++) {
273 /* Get CRTC from file */
274 CRTCdata
= pVBInfo
->StandTable
[StandTableIndex
].CRTC
[i
];
275 xgifb_reg_set(pVBInfo
->P3d4
, i
, CRTCdata
); /* Set CRTC(3d4) */
278 if ((HwDeviceExtension->jChipType == XGI_630) &&
279 (HwDeviceExtension->jChipRevision == 0x30)) {
280 if (pVBInfo->VBInfo & SetInSlaveMode) {
281 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) {
282 xgifb_reg_set(pVBInfo->P3d4, 0x18, 0xFE);
289 static void XGI_SetATTRegs(unsigned short ModeNo
,
290 unsigned short StandTableIndex
,
291 unsigned short ModeIdIndex
,
292 struct vb_device_info
*pVBInfo
)
294 unsigned char ARdata
;
295 unsigned short i
, modeflag
;
298 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
300 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
302 for (i
= 0; i
<= 0x13; i
++) {
303 ARdata
= pVBInfo
->StandTable
[StandTableIndex
].ATTR
[i
];
304 if (modeflag
& Charx8Dot
) { /* ifndef Dot9 */
306 if (pVBInfo
->VBInfo
& SetCRT2ToLCDA
) {
309 if (pVBInfo
->VBInfo
& (SetCRT2ToTV
311 if (pVBInfo
->VBInfo
&
319 inb(pVBInfo
->P3da
); /* reset 3da */
320 outb(i
, pVBInfo
->P3c0
); /* set index */
321 outb(ARdata
, pVBInfo
->P3c0
); /* set data */
324 inb(pVBInfo
->P3da
); /* reset 3da */
325 outb(0x14, pVBInfo
->P3c0
); /* set index */
326 outb(0x00, pVBInfo
->P3c0
); /* set data */
327 inb(pVBInfo
->P3da
); /* Enable Attribute */
328 outb(0x20, pVBInfo
->P3c0
);
331 static void XGI_SetGRCRegs(unsigned short StandTableIndex
,
332 struct vb_device_info
*pVBInfo
)
334 unsigned char GRdata
;
337 for (i
= 0; i
<= 0x08; i
++) {
338 /* Get GR from file */
339 GRdata
= pVBInfo
->StandTable
[StandTableIndex
].GRC
[i
];
340 xgifb_reg_set(pVBInfo
->P3ce
, i
, GRdata
); /* Set GR(3ce) */
343 if (pVBInfo
->ModeType
> ModeVGA
) {
344 GRdata
= (unsigned char) xgifb_reg_get(pVBInfo
->P3ce
, 0x05);
345 GRdata
&= 0xBF; /* 256 color disable */
346 xgifb_reg_set(pVBInfo
->P3ce
, 0x05, GRdata
);
350 static void XGI_ClearExt1Regs(struct vb_device_info
*pVBInfo
)
354 for (i
= 0x0A; i
<= 0x0E; i
++)
355 xgifb_reg_set(pVBInfo
->P3c4
, i
, 0x00); /* Clear SR0A-SR0E */
358 static unsigned char XGI_SetDefaultVCLK(struct vb_device_info
*pVBInfo
)
361 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x31, ~0x30, 0x20);
362 xgifb_reg_set(pVBInfo
->P3c4
, 0x2B, pVBInfo
->VCLKData
[0].SR2B
);
363 xgifb_reg_set(pVBInfo
->P3c4
, 0x2C, pVBInfo
->VCLKData
[0].SR2C
);
365 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x31, ~0x30, 0x10);
366 xgifb_reg_set(pVBInfo
->P3c4
, 0x2B, pVBInfo
->VCLKData
[1].SR2B
);
367 xgifb_reg_set(pVBInfo
->P3c4
, 0x2C, pVBInfo
->VCLKData
[1].SR2C
);
369 xgifb_reg_and(pVBInfo
->P3c4
, 0x31, ~0x30);
373 static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo
,
374 unsigned short ModeIdIndex
,
375 unsigned short RefreshRateTableIndex
, unsigned short *i
,
376 struct vb_device_info
*pVBInfo
)
378 unsigned short tempax
, tempbx
, resinfo
, modeflag
, infoflag
;
382 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
384 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
386 resinfo
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
387 tempbx
= pVBInfo
->RefIndex
[RefreshRateTableIndex
+ (*i
)].ModeID
;
390 if (pVBInfo
->IF_DEF_LVDS
== 0) {
391 if (pVBInfo
->VBInfo
& SetCRT2ToRAMDAC
) {
392 tempax
|= SupportRAMDAC2
;
394 if (pVBInfo
->VBType
& VB_XGI301C
)
395 tempax
|= SupportCRT2in301C
;
399 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToLCDA
)) {
400 tempax
|= SupportLCD
;
402 if (pVBInfo
->LCDResInfo
!= Panel1280x1024
) {
403 if (pVBInfo
->LCDResInfo
!= Panel1280x960
) {
404 if (pVBInfo
->LCDInfo
&
415 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
) { /* for HiTV */
416 if ((pVBInfo
->VBType
& VB_XGI301LV
) &&
417 (pVBInfo
->VBExtInfo
== VB_YPbPr1080i
)) {
418 tempax
|= SupportYPbPr
;
419 if (pVBInfo
->VBInfo
& SetInSlaveMode
) {
430 tempax
|= SupportHiVisionTV
;
431 if (pVBInfo
->VBInfo
& SetInSlaveMode
) {
446 if (pVBInfo
->VBInfo
& (SetCRT2ToAVIDEO
|
450 SetCRT2ToHiVisionTV
)) {
453 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
454 | VB_XGI301LV
| VB_XGI302LV
456 tempax
|= SupportTV1024
;
459 if (!(pVBInfo
->VBInfo
& SetPALTV
)) {
460 if (modeflag
& NoSupportSimuTV
) {
461 if (pVBInfo
->VBInfo
&
463 if (!(pVBInfo
->VBInfo
&
472 } else { /* for LVDS */
473 if (pVBInfo
->VBInfo
& SetCRT2ToLCD
) {
474 tempax
|= SupportLCD
;
477 return 0; /* 1024x768 */
479 if (pVBInfo
->LCDResInfo
< Panel1024x768
) {
481 return 0; /* 800x600 */
484 return 0; /* 512x384 */
489 for (; pVBInfo
->RefIndex
[RefreshRateTableIndex
+ (*i
)].ModeID
==
491 infoflag
= pVBInfo
->RefIndex
[RefreshRateTableIndex
+ (*i
)].
493 if (infoflag
& tempax
)
500 for ((*i
) = 0;; (*i
)++) {
501 infoflag
= pVBInfo
->RefIndex
[RefreshRateTableIndex
+ (*i
)].
503 if (pVBInfo
->RefIndex
[RefreshRateTableIndex
+ (*i
)].ModeID
508 if (infoflag
& tempax
)
514 static void XGI_SetSync(unsigned short RefreshRateTableIndex
,
515 struct vb_device_info
*pVBInfo
)
517 unsigned short sync
, temp
;
520 sync
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_InfoFlag
>> 8;
524 outb(temp
, pVBInfo
->P3c2
); /* Set Misc(3c2) */
527 static void XGI_SetCRT1Timing_H(struct vb_device_info
*pVBInfo
,
528 struct xgi_hw_device_info
*HwDeviceExtension
)
530 unsigned char data
, data1
, pushax
;
533 /* xgifb_reg_set(pVBInfo->P3d4, 0x51, 0); */
534 /* xgifb_reg_set(pVBInfo->P3d4, 0x56, 0); */
535 /* xgifb_reg_and_or(pVBInfo->P3d4, 0x11, 0x7f, 0x00); */
538 data
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x11);
540 xgifb_reg_set(pVBInfo
->P3d4
, 0x11, data
);
542 data
= pVBInfo
->TimingH
[0].data
[0];
543 xgifb_reg_set(pVBInfo
->P3d4
, 0, data
);
545 for (i
= 0x01; i
<= 0x04; i
++) {
546 data
= pVBInfo
->TimingH
[0].data
[i
];
547 xgifb_reg_set(pVBInfo
->P3d4
, (unsigned short) (i
+ 1), data
);
550 for (i
= 0x05; i
<= 0x06; i
++) {
551 data
= pVBInfo
->TimingH
[0].data
[i
];
552 xgifb_reg_set(pVBInfo
->P3c4
, (unsigned short) (i
+ 6), data
);
555 j
= (unsigned char) xgifb_reg_get(pVBInfo
->P3c4
, 0x0e);
557 data
= pVBInfo
->TimingH
[0].data
[7];
560 xgifb_reg_set(pVBInfo
->P3c4
, 0x0e, data
);
562 if (HwDeviceExtension
->jChipType
>= XG20
) {
563 data
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x04);
565 xgifb_reg_set(pVBInfo
->P3d4
, 0x04, data
);
566 data
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x05);
572 data
= (unsigned char) xgifb_reg_get(pVBInfo
->P3c4
,
575 xgifb_reg_set(pVBInfo
->P3c4
, 0x0c, data
);
580 xgifb_reg_set(pVBInfo
->P3d4
, 0x05, data
);
581 data
= (unsigned char) xgifb_reg_get(pVBInfo
->P3c4
, 0x0e);
587 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0e, ~0xE0, data
);
591 static void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex
,
592 unsigned short ModeNo
,
593 struct vb_device_info
*pVBInfo
)
598 /* xgifb_reg_set(pVBInfo->P3d4, 0x51, 0); */
599 /* xgifb_reg_set(pVBInfo->P3d4, 0x56, 0); */
600 /* xgifb_reg_and_or(pVBInfo->P3d4, 0x11, 0x7f, 0x00); */
602 for (i
= 0x00; i
<= 0x01; i
++) {
603 data
= pVBInfo
->TimingV
[0].data
[i
];
604 xgifb_reg_set(pVBInfo
->P3d4
, (unsigned short) (i
+ 6), data
);
607 for (i
= 0x02; i
<= 0x03; i
++) {
608 data
= pVBInfo
->TimingV
[0].data
[i
];
609 xgifb_reg_set(pVBInfo
->P3d4
, (unsigned short) (i
+ 0x0e), data
);
612 for (i
= 0x04; i
<= 0x05; i
++) {
613 data
= pVBInfo
->TimingV
[0].data
[i
];
614 xgifb_reg_set(pVBInfo
->P3d4
, (unsigned short) (i
+ 0x11), data
);
617 j
= (unsigned char) xgifb_reg_get(pVBInfo
->P3c4
, 0x0a);
619 data
= pVBInfo
->TimingV
[0].data
[6];
622 xgifb_reg_set(pVBInfo
->P3c4
, 0x0a, data
);
624 data
= pVBInfo
->TimingV
[0].data
[6];
629 i
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
631 i
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
637 j
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x09);
640 xgifb_reg_set(pVBInfo
->P3d4
, 0x09, data
);
643 static void XGI_SetCRT1CRTC(unsigned short ModeNo
, unsigned short ModeIdIndex
,
644 unsigned short RefreshRateTableIndex
,
645 struct vb_device_info
*pVBInfo
,
646 struct xgi_hw_device_info
*HwDeviceExtension
)
648 unsigned char index
, data
;
652 index
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRT1CRTC
;
653 index
= index
& IndexMask
;
655 data
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x11);
657 xgifb_reg_set(pVBInfo
->P3d4
, 0x11, data
); /* Unlock CRTC */
659 for (i
= 0; i
< 8; i
++)
660 pVBInfo
->TimingH
[0].data
[i
]
661 = pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[i
];
663 for (i
= 0; i
< 7; i
++)
664 pVBInfo
->TimingV
[0].data
[i
]
665 = pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[i
+ 8];
667 XGI_SetCRT1Timing_H(pVBInfo
, HwDeviceExtension
);
669 XGI_SetCRT1Timing_V(ModeIdIndex
, ModeNo
, pVBInfo
);
671 if (pVBInfo
->ModeType
> 0x03)
672 xgifb_reg_set(pVBInfo
->P3d4
, 0x14, 0x4F);
675 /* --------------------------------------------------------------------- */
676 /* Function : XGI_SetXG21CRTC */
677 /* Input : Stand or enhance CRTC table */
678 /* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */
679 /* Description : Set LCD timing */
680 /* --------------------------------------------------------------------- */
681 static void XGI_SetXG21CRTC(unsigned short ModeNo
, unsigned short ModeIdIndex
,
682 unsigned short RefreshRateTableIndex
,
683 struct vb_device_info
*pVBInfo
)
685 unsigned char StandTableIndex
, index
, Tempax
, Tempbx
, Tempcx
, Tempdx
;
686 unsigned short Temp1
, Temp2
, Temp3
;
688 if (ModeNo
<= 0x13) {
689 StandTableIndex
= XGI_GetModePtr(ModeNo
, ModeIdIndex
, pVBInfo
);
691 Tempax
= pVBInfo
->StandTable
[StandTableIndex
].CRTC
[4];
692 /* SR2E [7:0]->HRS */
693 xgifb_reg_set(pVBInfo
->P3c4
, 0x2E, Tempax
);
694 /* Tempbx: CR05 HRE */
695 Tempbx
= pVBInfo
->StandTable
[StandTableIndex
].CRTC
[5];
696 Tempbx
&= 0x1F; /* Tempbx: HRE[4:0] */
698 Tempcx
&= 0xE0; /* Tempcx: HRS[7:5] */
699 Tempdx
= Tempcx
| Tempbx
; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
700 if (Tempbx
< (Tempax
& 0x1F)) /* IF HRE < HRS */
701 Tempdx
|= 0x20; /* Tempdx: HRE = HRE + 0x20 */
702 Tempdx
<<= 2; /* Tempdx << 2 */
703 /* SR2F [7:2]->HRE */
704 xgifb_reg_set(pVBInfo
->P3c4
, 0x2F, Tempdx
);
705 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x30, 0xE3, 00);
707 /* Tempax: CR16 VRS */
708 Tempax
= pVBInfo
->StandTable
[StandTableIndex
].CRTC
[16];
709 Tempbx
= Tempax
; /* Tempbx=Tempax */
710 Tempax
&= 0x01; /* Tempax: VRS[0] */
711 xgifb_reg_or(pVBInfo
->P3c4
, 0x33, Tempax
); /* SR33[0]->VRS */
713 /* Tempax: CR7 VRS */
714 Tempax
= pVBInfo
->StandTable
[StandTableIndex
].CRTC
[7];
715 Tempdx
= Tempbx
>> 1; /* Tempdx: VRS[7:1] */
716 Tempcx
= Tempax
& 0x04; /* Tempcx: CR7[2] */
717 Tempcx
<<= 5; /* Tempcx[7]: VRS[8] */
718 Tempdx
|= Tempcx
; /* Tempdx: VRS[8:1] */
719 /* SR34[7:0]: VRS[8:1] */
720 xgifb_reg_set(pVBInfo
->P3c4
, 0x34, Tempdx
);
722 /* Temp1[8]: VRS[8] unsigned char -> unsigned short */
724 Temp1
|= Tempbx
; /* Temp1[8:0]: VRS[8:0] */
725 Tempax
&= 0x80; /* Tempax[7]: CR7[7] */
726 Temp2
= Tempax
<< 2; /* Temp2[9]: VRS[9] */
727 Temp1
|= Temp2
; /* Temp1[9:0]: VRS[9:0] */
730 Tempax
= pVBInfo
->StandTable
[StandTableIndex
].CRTC
[17];
731 Tempax
&= 0x0F; /* Tempax[3:0]: VRE[3:0] */
732 Temp2
= Temp1
& 0x3F0; /* Temp2[9:4]: VRS[9:4] */
733 Temp2
|= Tempax
; /* Temp2[9:0]: VRE[9:0] */
734 Temp3
= Temp1
& 0x0F; /* Temp3[3:0]: VRS[3:0] */
735 if (Tempax
< Temp3
) /* VRE[3:0]<VRS[3:0] */
736 Temp2
|= 0x10; /* Temp2: VRE + 0x10 */
737 Temp2
&= 0xFF; /* Temp2[7:0]: VRE[7:0] */
738 Tempax
= (unsigned char) Temp2
; /* Tempax[7:0]: VRE[7:0] */
739 Tempax
<<= 2; /* Tempax << 2: VRE[5:0] */
740 Temp1
&= 0x600; /* Temp1[10:9]: VRS[10:9] */
741 Temp1
>>= 9; /* [10:9]->[1:0] */
742 Tempbx
= (unsigned char) Temp1
; /* Tempbx[1:0]: VRS[10:9] */
743 Tempax
|= Tempbx
; /* VRE[5:0]VRS[10:9] */
745 /* SR3F D[7:2]->VRE D[1:0]->VRS */
746 xgifb_reg_set(pVBInfo
->P3c4
, 0x3F, Tempax
);
748 index
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRT1CRTC
;
749 /* Tempax: CR4 HRS */
750 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[3];
751 Tempcx
= Tempax
; /* Tempcx: HRS */
753 xgifb_reg_set(pVBInfo
->P3c4
, 0x2E, Tempax
);
755 Tempdx
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[5]; /* SRB */
756 Tempdx
&= 0xC0; /* Tempdx[7:6]: SRB[7:6] */
757 Temp1
= Tempdx
; /* Temp1[7:6]: HRS[9:8] */
758 Temp1
<<= 2; /* Temp1[9:8]: HRS[9:8] */
759 Temp1
|= Tempax
; /* Temp1[9:0]: HRS[9:0] */
761 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[4]; /* CR5 HRE */
762 Tempax
&= 0x1F; /* Tempax[4:0]: HRE[4:0] */
764 Tempbx
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[6]; /* SRC */
765 Tempbx
&= 0x04; /* Tempbx[2]: HRE[5] */
766 Tempbx
<<= 3; /* Tempbx[5]: HRE[5] */
767 Tempax
|= Tempbx
; /* Tempax[5:0]: HRE[5:0] */
769 Temp2
= Temp1
& 0x3C0; /* Temp2[9:6]: HRS[9:6] */
770 Temp2
|= Tempax
; /* Temp2[9:0]: HRE[9:0] */
772 Tempcx
&= 0x3F; /* Tempcx[5:0]: HRS[5:0] */
773 if (Tempax
< Tempcx
) /* HRE < HRS */
774 Temp2
|= 0x40; /* Temp2 + 0x40 */
777 Tempax
= (unsigned char) Temp2
; /* Tempax: HRE[7:0] */
778 Tempax
<<= 2; /* Tempax[7:2]: HRE[5:0] */
779 Tempdx
>>= 6; /* Tempdx[7:6]->[1:0] HRS[9:8] */
780 Tempax
|= Tempdx
; /* HRE[5:0]HRS[9:8] */
781 /* SR2F D[7:2]->HRE, D[1:0]->HRS */
782 xgifb_reg_set(pVBInfo
->P3c4
, 0x2F, Tempax
);
783 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x30, 0xE3, 00);
786 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[10];
787 Tempbx
= Tempax
; /* Tempbx: VRS */
788 Tempax
&= 0x01; /* Tempax[0]: VRS[0] */
789 xgifb_reg_or(pVBInfo
->P3c4
, 0x33, Tempax
); /* SR33[0]->VRS[0] */
791 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[9];
792 Tempcx
= Tempbx
>> 1; /* Tempcx[6:0]: VRS[7:1] */
793 Tempdx
= Tempax
& 0x04; /* Tempdx[2]: CR7[2] */
794 Tempdx
<<= 5; /* Tempdx[7]: VRS[8] */
795 Tempcx
|= Tempdx
; /* Tempcx[7:0]: VRS[8:1] */
796 xgifb_reg_set(pVBInfo
->P3c4
, 0x34, Tempcx
); /* SR34[8:1]->VRS */
798 Temp1
= Tempdx
; /* Temp1[7]: Tempdx[7] */
799 Temp1
<<= 1; /* Temp1[8]: VRS[8] */
800 Temp1
|= Tempbx
; /* Temp1[8:0]: VRS[8:0] */
802 Temp2
= Tempax
<< 2; /* Temp2[9]: VRS[9] */
803 Temp1
|= Temp2
; /* Temp1[9:0]: VRS[9:0] */
805 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[14];
806 Tempax
&= 0x08; /* Tempax[3]: VRS[3] */
808 Temp2
<<= 7; /* Temp2[10]: VRS[10] */
809 Temp1
|= Temp2
; /* Temp1[10:0]: VRS[10:0] */
811 /* Tempax: CR11 VRE */
812 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[11];
813 Tempax
&= 0x0F; /* Tempax[3:0]: VRE[3:0] */
815 Tempbx
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[14];
816 Tempbx
&= 0x20; /* Tempbx[5]: VRE[5] */
817 Tempbx
>>= 1; /* Tempbx[4]: VRE[4] */
818 Tempax
|= Tempbx
; /* Tempax[4:0]: VRE[4:0] */
819 Temp2
= Temp1
& 0x7E0; /* Temp2[10:5]: VRS[10:5] */
820 Temp2
|= Tempax
; /* Temp2[10:5]: VRE[10:5] */
822 Temp3
= Temp1
& 0x1F; /* Temp3[4:0]: VRS[4:0] */
823 if (Tempax
< Temp3
) /* VRE < VRS */
824 Temp2
|= 0x20; /* VRE + 0x20 */
827 Tempax
= (unsigned char) Temp2
; /* Tempax: VRE[7:0] */
828 Tempax
<<= 2; /* Tempax[7:0]; VRE[5:0]00 */
829 Temp1
&= 0x600; /* Temp1[10:9]: VRS[10:9] */
830 Temp1
>>= 9; /* Temp1[1:0]: VRS[10:9] */
831 Tempbx
= (unsigned char) Temp1
;
832 Tempax
|= Tempbx
; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */
834 /* SR3F D[7:2]->VRE D[1:0]->VRS */
835 xgifb_reg_set(pVBInfo
->P3c4
, 0x3F, Tempax
);
839 static void XGI_SetXG27CRTC(unsigned short ModeNo
,
840 unsigned short ModeIdIndex
,
841 unsigned short RefreshRateTableIndex
,
842 struct vb_device_info
*pVBInfo
)
844 unsigned short StandTableIndex
, index
, Tempax
, Tempbx
, Tempcx
, Tempdx
;
846 if (ModeNo
<= 0x13) {
847 StandTableIndex
= XGI_GetModePtr(ModeNo
, ModeIdIndex
, pVBInfo
);
849 Tempax
= pVBInfo
->StandTable
[StandTableIndex
].CRTC
[4];
850 /* SR2E [7:0]->HRS */
851 xgifb_reg_set(pVBInfo
->P3c4
, 0x2E, Tempax
);
852 /* Tempbx: CR05 HRE */
853 Tempbx
= pVBInfo
->StandTable
[StandTableIndex
].CRTC
[5];
854 Tempbx
&= 0x1F; /* Tempbx: HRE[4:0] */
856 Tempcx
&= 0xE0; /* Tempcx: HRS[7:5] */
857 Tempdx
= Tempcx
| Tempbx
; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
858 if (Tempbx
< (Tempax
& 0x1F)) /* IF HRE < HRS */
859 Tempdx
|= 0x20; /* Tempdx: HRE = HRE + 0x20 */
860 Tempdx
<<= 2; /* Tempdx << 2 */
861 /* SR2F [7:2]->HRE */
862 xgifb_reg_set(pVBInfo
->P3c4
, 0x2F, Tempdx
);
863 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x30, 0xE3, 00);
865 /* Tempax: CR10 VRS */
866 Tempax
= pVBInfo
->StandTable
[StandTableIndex
].CRTC
[16];
867 xgifb_reg_set(pVBInfo
->P3c4
, 0x34, Tempax
); /* SR34[7:0]->VRS */
868 Tempcx
= Tempax
; /* Tempcx=Tempax=VRS[7:0] */
869 /* Tempax[7][2]: CR7[7][2] VRS[9][8] */
870 Tempax
= pVBInfo
->StandTable
[StandTableIndex
].CRTC
[7];
871 Tempbx
= Tempax
; /* Tempbx=CR07 */
872 Tempax
&= 0x04; /* Tempax[2]: CR07[2] VRS[8] */
874 /* SR35 D[0]->VRS D[8] */
875 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x35, ~0x01, Tempax
);
876 Tempcx
|= (Tempax
<< 8); /* Tempcx[8] |= VRS[8] */
877 Tempcx
|= (Tempbx
& 0x80) << 2; /* Tempcx[9] |= VRS[9] */
880 Tempax
= pVBInfo
->StandTable
[StandTableIndex
].CRTC
[17];
881 Tempax
&= 0x0F; /* Tempax: VRE[3:0] */
882 Tempbx
= Tempcx
; /* Tempbx=Tempcx=VRS[9:0] */
883 Tempbx
&= 0x3F0; /* Tempbx[9:4]: VRS[9:4] */
884 Tempbx
|= Tempax
; /* Tempbx[9:0]: VRE[9:0] */
885 if (Tempax
<= (Tempcx
& 0x0F)) /* VRE[3:0]<=VRS[3:0] */
886 Tempbx
|= 0x10; /* Tempbx: VRE + 0x10 */
887 /* Tempax[7:0]: VRE[7:0] */
888 Tempax
= (unsigned char) Tempbx
& 0xFF;
889 Tempax
<<= 2; /* Tempax << 2: VRE[5:0] */
890 Tempcx
= (Tempcx
& 0x600) >> 8; /* Tempcx VRS[10:9] */
891 /* SR3F D[7:2]->VRE D[5:0] */
892 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x3F, ~0xFC, Tempax
);
893 /* SR35 D[2:1]->VRS[10:9] */
894 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x35, ~0x06, Tempcx
);
896 index
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRT1CRTC
;
897 /* Tempax: CR4 HRS */
898 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[3];
899 Tempbx
= Tempax
; /* Tempbx: HRS[7:0] */
901 xgifb_reg_set(pVBInfo
->P3c4
, 0x2E, Tempax
);
904 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[5];
905 Tempax
&= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
906 Tempbx
|= (Tempax
<< 2); /* Tempbx: HRS[9:0] */
908 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[4]; /* CR5 HRE */
909 Tempax
&= 0x1F; /* Tempax[4:0]: HRE[4:0] */
910 Tempcx
= Tempax
; /* Tempcx: HRE[4:0] */
912 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[6]; /* SRC */
913 Tempax
&= 0x04; /* Tempax[2]: HRE[5] */
914 Tempax
<<= 3; /* Tempax[5]: HRE[5] */
915 Tempcx
|= Tempax
; /* Tempcx[5:0]: HRE[5:0] */
917 Tempbx
= Tempbx
& 0x3C0; /* Tempbx[9:6]: HRS[9:6] */
918 Tempbx
|= Tempcx
; /* Tempbx: HRS[9:6]HRE[5:0] */
920 /* Tempax: CR4 HRS */
921 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[3];
922 Tempax
&= 0x3F; /* Tempax: HRS[5:0] */
923 if (Tempcx
<= Tempax
) /* HRE[5:0] < HRS[5:0] */
924 Tempbx
+= 0x40; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/
926 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[5]; /* SR0B */
927 Tempax
&= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
928 Tempax
>>= 6; /* Tempax[1:0]: HRS[9:8]*/
929 Tempax
|= ((Tempbx
<< 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */
930 /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */
931 xgifb_reg_set(pVBInfo
->P3c4
, 0x2F, Tempax
);
932 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x30, 0xE3, 00);
935 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[10];
936 /* SR34[7:0]->VRS[7:0] */
937 xgifb_reg_set(pVBInfo
->P3c4
, 0x34, Tempax
);
939 Tempcx
= Tempax
; /* Tempcx <= VRS[7:0] */
940 /* CR7[7][2] VRS[9][8] */
941 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[9];
942 Tempbx
= Tempax
; /* Tempbx <= CR07[7:0] */
943 Tempax
= Tempax
& 0x04; /* Tempax[2]: CR7[2]: VRS[8] */
944 Tempax
>>= 2; /* Tempax[0]: VRS[8] */
945 /* SR35[0]: VRS[8] */
946 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x35, ~0x01, Tempax
);
947 Tempcx
|= (Tempax
<< 8); /* Tempcx <= VRS[8:0] */
948 Tempcx
|= ((Tempbx
& 0x80) << 2); /* Tempcx <= VRS[9:0] */
950 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[14];
951 Tempax
&= 0x08; /* SR0A[3] VRS[10] */
952 Tempcx
|= (Tempax
<< 7); /* Tempcx <= VRS[10:0] */
954 /* Tempax: CR11 VRE */
955 Tempax
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[11];
956 Tempax
&= 0x0F; /* Tempax[3:0]: VRE[3:0] */
958 Tempbx
= pVBInfo
->XGINEWUB_CRT1Table
[index
].CR
[14];
959 Tempbx
&= 0x20; /* Tempbx[5]: SR0A[5]: VRE[4] */
960 Tempbx
>>= 1; /* Tempbx[4]: VRE[4] */
961 Tempax
|= Tempbx
; /* Tempax[4:0]: VRE[4:0] */
962 Tempbx
= Tempcx
; /* Tempbx: VRS[10:0] */
963 Tempbx
&= 0x7E0; /* Tempbx[10:5]: VRS[10:5] */
964 Tempbx
|= Tempax
; /* Tempbx: VRS[10:5]VRE[4:0] */
966 if (Tempbx
<= Tempcx
) /* VRE <= VRS */
967 Tempbx
|= 0x20; /* VRE + 0x20 */
969 /* Tempax: Tempax[7:0]; VRE[5:0]00 */
970 Tempax
= (Tempbx
<< 2) & 0xFF;
971 /* SR3F[7:2]:VRE[5:0] */
972 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x3F, ~0xFC, Tempax
);
973 Tempax
= Tempcx
>> 8;
974 /* SR35[2:0]:VRS[10:8] */
975 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x35, ~0x07, Tempax
);
979 static void xgifb_set_lcd(int chip_id
,
980 struct vb_device_info
*pVBInfo
,
981 unsigned short RefreshRateTableIndex
,
982 unsigned short ModeNo
)
984 unsigned short Data
, Temp
, b3CC
;
985 unsigned short XGI_P3cc
;
987 XGI_P3cc
= pVBInfo
->P3cc
;
989 xgifb_reg_set(pVBInfo
->P3d4
, 0x2E, 0x00);
990 xgifb_reg_set(pVBInfo
->P3d4
, 0x2F, 0x00);
991 xgifb_reg_set(pVBInfo
->P3d4
, 0x46, 0x00);
992 xgifb_reg_set(pVBInfo
->P3d4
, 0x47, 0x00);
994 if (chip_id
== XG27
) {
995 Temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x37);
996 if ((Temp
& 0x03) == 0) { /* dual 12 */
997 xgifb_reg_set(pVBInfo
->P3d4
, 0x46, 0x13);
998 xgifb_reg_set(pVBInfo
->P3d4
, 0x47, 0x13);
1002 if (((*pVBInfo
->pDVOSetting
) & 0xC0) == 0xC0) {
1003 xgifb_reg_set(pVBInfo
->P3d4
, 0x2E, *pVBInfo
->pCR2E
);
1004 xgifb_reg_set(pVBInfo
->P3d4
, 0x2F, *pVBInfo
->pCR2F
);
1005 xgifb_reg_set(pVBInfo
->P3d4
, 0x46, *pVBInfo
->pCR46
);
1006 xgifb_reg_set(pVBInfo
->P3d4
, 0x47, *pVBInfo
->pCR47
);
1009 if (chip_id
== XG27
) {
1010 XGI_SetXG27FPBits(pVBInfo
);
1012 Temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x37);
1015 xgifb_reg_or(pVBInfo
->P3c4
, 0x06, 0x40);
1016 xgifb_reg_or(pVBInfo
->P3c4
, 0x09, 0x40);
1020 xgifb_reg_or(pVBInfo
->P3c4
, 0x1E, 0x01); /* Negative blank polarity */
1022 xgifb_reg_and(pVBInfo
->P3c4
, 0x30, ~0x20); /* Hsync polarity */
1023 xgifb_reg_and(pVBInfo
->P3c4
, 0x35, ~0x80); /* Vsync polarity */
1025 if (ModeNo
<= 0x13) {
1026 b3CC
= (unsigned char) inb(XGI_P3cc
);
1028 /* Hsync polarity */
1029 xgifb_reg_or(pVBInfo
->P3c4
, 0x30, 0x20);
1031 /* Vsync polarity */
1032 xgifb_reg_or(pVBInfo
->P3c4
, 0x35, 0x80);
1034 Data
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_InfoFlag
;
1036 /* Hsync polarity */
1037 xgifb_reg_or(pVBInfo
->P3c4
, 0x30, 0x20);
1039 /* Vsync polarity */
1040 xgifb_reg_or(pVBInfo
->P3c4
, 0x35, 0x80);
1044 /* --------------------------------------------------------------------- */
1045 /* Function : XGI_UpdateXG21CRTC */
1047 /* Output : CRT1 CRTC */
1048 /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */
1049 /* --------------------------------------------------------------------- */
1050 static void XGI_UpdateXG21CRTC(unsigned short ModeNo
,
1051 struct vb_device_info
*pVBInfo
,
1052 unsigned short RefreshRateTableIndex
)
1056 xgifb_reg_and(pVBInfo
->P3d4
, 0x11, 0x7F); /* Unlock CR0~7 */
1057 if (ModeNo
<= 0x13) {
1058 for (i
= 0; i
< 12; i
++) {
1059 if (ModeNo
== pVBInfo
->UpdateCRT1
[i
].ModeID
)
1063 if (ModeNo
== 0x2E &&
1064 (pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRT1CRTC
==
1067 else if (ModeNo
== 0x2E &&
1068 (pVBInfo
->RefIndex
[RefreshRateTableIndex
].
1069 Ext_CRT1CRTC
== RES640x480x72
))
1071 else if (ModeNo
== 0x2F)
1073 else if (ModeNo
== 0x50)
1075 else if (ModeNo
== 0x59)
1080 xgifb_reg_set(pVBInfo
->P3d4
, 0x02,
1081 pVBInfo
->UpdateCRT1
[index
].CR02
);
1082 xgifb_reg_set(pVBInfo
->P3d4
, 0x03,
1083 pVBInfo
->UpdateCRT1
[index
].CR03
);
1084 xgifb_reg_set(pVBInfo
->P3d4
, 0x15,
1085 pVBInfo
->UpdateCRT1
[index
].CR15
);
1086 xgifb_reg_set(pVBInfo
->P3d4
, 0x16,
1087 pVBInfo
->UpdateCRT1
[index
].CR16
);
1091 static void XGI_SetCRT1DE(struct xgi_hw_device_info
*HwDeviceExtension
,
1092 unsigned short ModeNo
, unsigned short ModeIdIndex
,
1093 unsigned short RefreshRateTableIndex
,
1094 struct vb_device_info
*pVBInfo
)
1096 unsigned short resindex
, tempax
, tempbx
, tempcx
, temp
, modeflag
;
1100 resindex
= XGI_GetResInfo(ModeNo
, ModeIdIndex
, pVBInfo
);
1102 if (ModeNo
<= 0x13) {
1103 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
1104 tempax
= pVBInfo
->StResInfo
[resindex
].HTotal
;
1105 tempbx
= pVBInfo
->StResInfo
[resindex
].VTotal
;
1107 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
1108 tempax
= pVBInfo
->ModeResInfo
[resindex
].HTotal
;
1109 tempbx
= pVBInfo
->ModeResInfo
[resindex
].VTotal
;
1112 if (modeflag
& HalfDCLK
)
1113 tempax
= tempax
>> 1;
1115 if (ModeNo
> 0x13) {
1116 if (modeflag
& HalfDCLK
)
1117 tempax
= tempax
<< 1;
1119 temp
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_InfoFlag
;
1121 if (temp
& InterlaceMode
)
1122 tempbx
= tempbx
>> 1;
1124 if (modeflag
& DoubleScanMode
)
1125 tempbx
= tempbx
<< 1;
1130 /* if (!(modeflag & Charx8Dot)) */
1137 temp
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x11);
1138 data
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x11);
1140 xgifb_reg_set(pVBInfo
->P3d4
, 0x11, data
); /* Unlock CRTC */
1141 xgifb_reg_set(pVBInfo
->P3d4
, 0x01, (unsigned short) (tempcx
& 0xff));
1142 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x0b, ~0x0c,
1143 (unsigned short) ((tempcx
& 0x0ff00) >> 10));
1144 xgifb_reg_set(pVBInfo
->P3d4
, 0x12, (unsigned short) (tempbx
& 0xff));
1146 tempbx
= tempbx
>> 8;
1154 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x07, ~0x42, tempax
);
1155 data
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x07);
1162 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x0a, ~0x02, tempax
);
1163 xgifb_reg_set(pVBInfo
->P3d4
, 0x11, temp
);
1166 unsigned short XGI_GetResInfo(unsigned short ModeNo
,
1167 unsigned short ModeIdIndex
, struct vb_device_info
*pVBInfo
)
1169 unsigned short resindex
;
1173 resindex
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ResInfo
;
1175 /* si+Ext_ResInfo */
1176 resindex
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
1180 static void XGI_SetCRT1Offset(unsigned short ModeNo
,
1181 unsigned short ModeIdIndex
,
1182 unsigned short RefreshRateTableIndex
,
1183 struct xgi_hw_device_info
*HwDeviceExtension
,
1184 struct vb_device_info
*pVBInfo
)
1186 unsigned short temp
, ah
, al
, temp2
, i
, DisplayUnit
;
1189 temp
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeInfo
;
1191 temp
= pVBInfo
->ScreenOffset
[temp
];
1193 temp2
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_InfoFlag
;
1194 temp2
&= InterlaceMode
;
1199 temp2
= pVBInfo
->ModeType
- ModeEGA
;
1224 if ((ModeNo
>= 0x26) && (ModeNo
<= 0x28))
1225 temp
= temp
* temp2
+ temp2
/ 2;
1232 temp
= temp
>> 8; /* ah */
1234 i
= xgifb_reg_get(pVBInfo
->P3c4
, 0x0E);
1237 xgifb_reg_set(pVBInfo
->P3c4
, 0x0E, i
);
1239 temp
= (unsigned char) temp2
;
1240 temp
&= 0xFF; /* al */
1241 xgifb_reg_set(pVBInfo
->P3d4
, 0x13, temp
);
1243 /* SetDisplayUnit */
1244 temp2
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_InfoFlag
;
1245 temp2
&= InterlaceMode
;
1249 DisplayUnit
= DisplayUnit
<< 5;
1250 ah
= (DisplayUnit
& 0xff00) >> 8;
1251 al
= DisplayUnit
& 0x00ff;
1257 if (HwDeviceExtension
->jChipType
>= XG20
)
1258 if ((ModeNo
== 0x4A) | (ModeNo
== 0x49))
1261 xgifb_reg_set(pVBInfo
->P3c4
, 0x10, ah
);
1264 static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo
,
1265 unsigned short ModeIdIndex
,
1266 unsigned short RefreshRateTableIndex
,
1267 struct xgi_hw_device_info
*HwDeviceExtension
,
1268 struct vb_device_info
*pVBInfo
)
1270 unsigned short LCDXlat1VCLK
[4] = { VCLK65
+ 2,
1274 unsigned short LCDXlat2VCLK
[4] = { VCLK108_2
+ 5,
1278 unsigned short LVDSXlat1VCLK
[4] = { VCLK40
, VCLK40
, VCLK40
, VCLK40
};
1279 unsigned short LVDSXlat2VCLK
[4] = { VCLK65
+ 2,
1283 unsigned short LVDSXlat3VCLK
[4] = { VCLK65
+ 2,
1288 unsigned short CRT2Index
, VCLKIndex
;
1289 unsigned short modeflag
, resinfo
;
1291 if (ModeNo
<= 0x13) {
1293 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
1294 resinfo
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ResInfo
;
1295 CRT2Index
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_CRT2CRTC
;
1297 /* si+Ext_ResInfo */
1298 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
1299 resinfo
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
1300 CRT2Index
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].
1304 if (pVBInfo
->IF_DEF_LVDS
== 0) {
1305 CRT2Index
= CRT2Index
>> 6; /* for LCD */
1306 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToLCDA
)) { /*301b*/
1307 if (pVBInfo
->LCDResInfo
!= Panel1024x768
)
1308 VCLKIndex
= LCDXlat2VCLK
[CRT2Index
];
1310 VCLKIndex
= LCDXlat1VCLK
[CRT2Index
];
1311 } else { /* for TV */
1312 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
1313 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
) {
1314 if (pVBInfo
->SetFlag
& RPLLDIV2XO
) {
1315 VCLKIndex
= HiTVVCLKDIV2
;
1318 VCLKIndex
= HiTVVCLK
;
1322 if (pVBInfo
->SetFlag
& TVSimuMode
) {
1323 if (modeflag
& Charx8Dot
) {
1335 if (pVBInfo
->VBType
& VB_XGI301LV
) {
1336 if (!(pVBInfo
->VBExtInfo
==
1340 if (!(pVBInfo
->VBExtInfo
1345 if (!(pVBInfo
->VBExtInfo
1349 if (!(pVBInfo
->SetFlag
1358 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
1359 if (pVBInfo
->SetFlag
&
1361 VCLKIndex
= TVVCLKDIV2
;
1369 } else { /* for CRT2 */
1371 VCLKIndex
= (unsigned char) inb(
1372 (pVBInfo
->P3ca
+ 0x02));
1373 VCLKIndex
= ((VCLKIndex
>> 2) & 0x03);
1374 if (ModeNo
> 0x13) {
1375 /* di+Ext_CRTVCLK */
1378 RefreshRateTableIndex
].
1380 VCLKIndex
&= IndexMask
;
1386 VCLKIndex
= CRT2Index
;
1388 VCLKIndex
= CRT2Index
;
1390 VCLKIndex
= VCLKIndex
>> 6;
1391 if ((pVBInfo
->LCDResInfo
== Panel800x600
) ||
1392 (pVBInfo
->LCDResInfo
== Panel320x480
))
1393 VCLKIndex
= LVDSXlat1VCLK
[VCLKIndex
];
1394 else if ((pVBInfo
->LCDResInfo
== Panel1024x768
) ||
1395 (pVBInfo
->LCDResInfo
== Panel1024x768x75
))
1396 VCLKIndex
= LVDSXlat2VCLK
[VCLKIndex
];
1398 VCLKIndex
= LVDSXlat3VCLK
[VCLKIndex
];
1400 /* VCLKIndex = VCLKIndex&IndexMask; */
1405 static void XGI_SetCRT1VCLK(unsigned short ModeNo
,
1406 unsigned short ModeIdIndex
,
1407 struct xgi_hw_device_info
*HwDeviceExtension
,
1408 unsigned short RefreshRateTableIndex
,
1409 struct vb_device_info
*pVBInfo
)
1411 unsigned char index
, data
;
1412 unsigned short vclkindex
;
1414 if (pVBInfo
->IF_DEF_LVDS
== 1) {
1415 index
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRTVCLK
;
1416 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x31) & 0xCF;
1417 xgifb_reg_set(pVBInfo
->P3c4
, 0x31, data
);
1418 xgifb_reg_set(pVBInfo
->P3c4
, 0x2B,
1419 pVBInfo
->VCLKData
[index
].SR2B
);
1420 xgifb_reg_set(pVBInfo
->P3c4
, 0x2C,
1421 pVBInfo
->VCLKData
[index
].SR2C
);
1422 xgifb_reg_set(pVBInfo
->P3c4
, 0x2D, 0x01);
1423 } else if ((pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
| VB_XGI301LV
1424 | VB_XGI302LV
| VB_XGI301C
)) && (pVBInfo
->VBInfo
1426 vclkindex
= XGI_GetVCLK2Ptr(ModeNo
, ModeIdIndex
,
1427 RefreshRateTableIndex
, HwDeviceExtension
,
1429 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x31) & 0xCF;
1430 xgifb_reg_set(pVBInfo
->P3c4
, 0x31, data
);
1431 data
= pVBInfo
->VBVCLKData
[vclkindex
].Part4_A
;
1432 xgifb_reg_set(pVBInfo
->P3c4
, 0x2B, data
);
1433 data
= pVBInfo
->VBVCLKData
[vclkindex
].Part4_B
;
1434 xgifb_reg_set(pVBInfo
->P3c4
, 0x2C, data
);
1435 xgifb_reg_set(pVBInfo
->P3c4
, 0x2D, 0x01);
1437 index
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRTVCLK
;
1438 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x31) & 0xCF;
1439 xgifb_reg_set(pVBInfo
->P3c4
, 0x31, data
);
1440 xgifb_reg_set(pVBInfo
->P3c4
, 0x2B,
1441 pVBInfo
->VCLKData
[index
].SR2B
);
1442 xgifb_reg_set(pVBInfo
->P3c4
, 0x2C,
1443 pVBInfo
->VCLKData
[index
].SR2C
);
1444 xgifb_reg_set(pVBInfo
->P3c4
, 0x2D, 0x01);
1447 if (HwDeviceExtension
->jChipType
>= XG20
) {
1448 if (pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
&
1450 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x2B);
1451 xgifb_reg_set(pVBInfo
->P3c4
, 0x2B, data
);
1452 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x2C);
1459 xgifb_reg_set(pVBInfo
->P3c4
, 0x2C, data
);
1464 static void XGI_SetCRT1FIFO(unsigned short ModeNo
,
1465 struct xgi_hw_device_info
*HwDeviceExtension
,
1466 struct vb_device_info
*pVBInfo
)
1468 unsigned short data
;
1470 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x3D);
1472 xgifb_reg_set(pVBInfo
->P3c4
, 0x3D, data
); /* diable auto-threshold */
1474 if (ModeNo
> 0x13) {
1475 xgifb_reg_set(pVBInfo
->P3c4
, 0x08, 0x34);
1476 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x09);
1478 xgifb_reg_set(pVBInfo
->P3c4
, 0x09, data
| 0x30);
1479 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x3D);
1481 xgifb_reg_set(pVBInfo
->P3c4
, 0x3D, data
);
1483 if (HwDeviceExtension
->jChipType
== XG27
) {
1484 xgifb_reg_set(pVBInfo
->P3c4
, 0x08, 0x0E);
1485 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x09);
1487 xgifb_reg_set(pVBInfo
->P3c4
, 0x09, data
| 0x20);
1489 xgifb_reg_set(pVBInfo
->P3c4
, 0x08, 0xAE);
1490 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x09);
1492 xgifb_reg_set(pVBInfo
->P3c4
, 0x09, data
);
1496 if (HwDeviceExtension
->jChipType
== XG21
)
1497 XGI_SetXG21FPBits(pVBInfo
); /* Fix SR9[7:6] can't read back */
1500 static void XGI_SetVCLKState(struct xgi_hw_device_info
*HwDeviceExtension
,
1501 unsigned short ModeNo
, unsigned short RefreshRateTableIndex
,
1502 struct vb_device_info
*pVBInfo
)
1504 unsigned short data
, data2
= 0;
1507 unsigned char index
;
1512 index
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRTVCLK
;
1514 VCLK
= pVBInfo
->VCLKData
[index
].CLOCK
;
1517 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x32);
1520 data
|= 0x0c; /* VCLK > 200 */
1522 if (HwDeviceExtension
->jChipType
>= XG20
)
1523 data
&= ~0x04; /* 2 pixel mode */
1525 xgifb_reg_set(pVBInfo
->P3c4
, 0x32, data
);
1527 if (HwDeviceExtension
->jChipType
< XG20
) {
1528 data
= xgifb_reg_get(pVBInfo
->P3c4
, 0x1F);
1532 xgifb_reg_set(pVBInfo
->P3c4
, 0x1F, data
);
1535 /* Jong for Adavantech LCD ripple issue
1536 if ((VCLK >= 0) && (VCLK < 135))
1538 else if ((VCLK >= 135) && (VCLK < 160))
1540 else if ((VCLK >= 160) && (VCLK < 260))
1542 else if (VCLK > 260)
1547 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x07, 0xFC, data2
);
1548 if (HwDeviceExtension
->jChipType
>= XG27
)
1549 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x40, 0xFC, data2
& 0x03);
1553 static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info
*HwDeviceExtension
,
1554 unsigned short ModeNo
, unsigned short ModeIdIndex
,
1555 unsigned short RefreshRateTableIndex
,
1556 struct vb_device_info
*pVBInfo
)
1558 unsigned short data
, data2
, data3
, infoflag
= 0, modeflag
, resindex
,
1561 if (ModeNo
> 0x13) {
1562 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
1563 infoflag
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].
1566 /* si+St_ModeFlag */
1567 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
1569 if (xgifb_reg_get(pVBInfo
->P3d4
, 0x31) & 0x01)
1570 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x1F, 0x3F, 0x00);
1579 if (ModeNo
> 0x13) {
1580 if (pVBInfo
->ModeType
> 0x02) {
1582 data3
= pVBInfo
->ModeType
- ModeVGA
;
1588 data
&= InterlaceMode
;
1593 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x06, ~0x3F, data2
);
1594 /* xgifb_reg_set(pVBInfo->P3c4,0x06,data2); */
1595 resindex
= XGI_GetResInfo(ModeNo
, ModeIdIndex
, pVBInfo
);
1597 xres
= pVBInfo
->StResInfo
[resindex
].HTotal
;
1599 xres
= pVBInfo
->ModeResInfo
[resindex
].HTotal
; /* xres->ax */
1602 if (infoflag
& InterlaceMode
) {
1605 else if (xres
== 1280)
1609 data2
= data
& 0x00FF;
1610 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x19, 0xFF, data2
);
1611 data2
= (data
& 0xFF00) >> 8;
1612 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x19, 0xFC, data2
);
1614 if (modeflag
& HalfDCLK
)
1615 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x01, 0xF7, 0x08);
1619 if (modeflag
& LineCompareOff
)
1622 if (ModeNo
> 0x13) {
1623 if (pVBInfo
->ModeType
== ModeEGA
)
1627 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0F, ~0x48, data2
);
1629 if (pVBInfo
->ModeType
!= ModeText
) {
1631 if (pVBInfo
->ModeType
!= ModeEGA
)
1634 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x21, 0x1F, data
);
1636 XGI_SetVCLKState(HwDeviceExtension
, ModeNo
, RefreshRateTableIndex
,
1639 /* if (modeflag&HalfDCLK) //030305 fix lowresolution bug */
1640 /* if (XGINew_IF_DEF_NEW_LOWRES) */
1641 /* XGI_VesaLowResolution(ModeNo, ModeIdIndex);
1642 * //030305 fix lowresolution bug */
1644 data
= xgifb_reg_get(pVBInfo
->P3d4
, 0x31);
1646 if (HwDeviceExtension
->jChipType
== XG27
) {
1651 xgifb_reg_set(pVBInfo
->P3d4
, 0x52, data
);
1652 xgifb_reg_or(pVBInfo
->P3d4
, 0x51, 0x10);
1653 } else if (HwDeviceExtension
->jChipType
>= XG20
) {
1658 xgifb_reg_set(pVBInfo
->P3d4
, 0x52, data
);
1659 xgifb_reg_set(pVBInfo
->P3d4
, 0x51, 0x02);
1665 xgifb_reg_set(pVBInfo
->P3d4
, 0x52, data
);
1670 static void XGI_WriteDAC(unsigned short dl
,
1674 struct vb_device_info
*pVBInfo
)
1676 unsigned short temp
, bh
, bl
;
1695 outb((unsigned short) dh
, pVBInfo
->P3c9
);
1696 outb((unsigned short) bh
, pVBInfo
->P3c9
);
1697 outb((unsigned short) bl
, pVBInfo
->P3c9
);
1700 static void XGI_LoadDAC(unsigned short ModeNo
, unsigned short ModeIdIndex
,
1701 struct vb_device_info
*pVBInfo
)
1703 unsigned short data
, data2
, time
, i
, j
, k
, m
, n
, o
, si
, di
, bx
, dl
, al
,
1704 ah
, dh
, *table
= NULL
;
1707 data
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
1709 data
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
1711 data
&= DACInfoFlag
;
1715 table
= XGINew_MDA_DAC
;
1716 else if (data
== 0x08)
1717 table
= XGINew_CGA_DAC
;
1718 else if (data
== 0x10)
1719 table
= XGINew_EGA_DAC
;
1720 else if (data
== 0x18) {
1722 table
= XGINew_VGA_DAC
;
1730 outb(0xFF, pVBInfo
->P3c6
);
1731 outb(0x00, pVBInfo
->P3c8
);
1733 for (i
= 0; i
< j
; i
++) {
1736 for (k
= 0; k
< 3; k
++) {
1745 outb(data2
, pVBInfo
->P3c9
);
1751 for (i
= 16; i
< 32; i
++) {
1754 for (k
= 0; k
< 3; k
++)
1755 outb(data
, pVBInfo
->P3c9
);
1760 for (m
= 0; m
< 9; m
++) {
1765 for (n
= 0; n
< 3; n
++) {
1766 for (o
= 0; o
< 5; o
++) {
1771 XGI_WriteDAC(dl
, ah
, al
, dh
, pVBInfo
);
1776 for (o
= 0; o
< 3; o
++) {
1781 XGI_WriteDAC(dl
, ah
, al
, dh
, pVBInfo
);
1792 static void XGI_GetLVDSResInfo(unsigned short ModeNo
,
1793 unsigned short ModeIdIndex
,
1794 struct vb_device_info
*pVBInfo
)
1796 unsigned short resindex
, xres
, yres
, modeflag
;
1800 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ResInfo
;
1802 /* si+Ext_ResInfo */
1803 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
1805 /* if (ModeNo > 0x13) */
1806 /* modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; */
1808 /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; */
1812 resindex
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ResInfo
;
1814 /* si+Ext_ResInfo */
1815 resindex
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
1817 /* resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); */
1819 if (ModeNo
<= 0x13) {
1820 xres
= pVBInfo
->StResInfo
[resindex
].HTotal
;
1821 yres
= pVBInfo
->StResInfo
[resindex
].VTotal
;
1823 xres
= pVBInfo
->ModeResInfo
[resindex
].HTotal
;
1824 yres
= pVBInfo
->ModeResInfo
[resindex
].VTotal
;
1826 if (ModeNo
> 0x13) {
1827 if (modeflag
& HalfDCLK
)
1830 if (modeflag
& DoubleScanMode
)
1833 /* if (modeflag & Charx8Dot) */
1840 pVBInfo
->VGAHDE
= xres
;
1841 pVBInfo
->HDE
= xres
;
1842 pVBInfo
->VGAVDE
= yres
;
1843 pVBInfo
->VDE
= yres
;
1846 static void *XGI_GetLcdPtr(unsigned short BX
, unsigned short ModeNo
,
1847 unsigned short ModeIdIndex
,
1848 unsigned short RefreshRateTableIndex
,
1849 struct vb_device_info
*pVBInfo
)
1851 unsigned short i
, tempdx
, tempcx
, tempbx
, tempal
, modeflag
, table
;
1853 struct XGI330_LCDDataTablStruct
*tempdi
= NULL
;
1857 if (ModeNo
<= 0x13) {
1858 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
1859 tempal
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_CRT2CRTC
;
1861 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
1862 tempal
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRT2CRTC
;
1865 tempal
= tempal
& 0x0f;
1867 if (tempbx
<= 1) { /* ExpLink */
1868 if (ModeNo
<= 0x13) {
1869 /* find no Ext_CRT2CRTC2 */
1870 tempal
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_CRT2CRTC
;
1872 tempal
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].
1876 if (pVBInfo
->VBInfo
& SetCRT2ToLCDA
) {
1878 tempal
= pVBInfo
->SModeIDTable
[ModeIdIndex
].
1881 tempal
= pVBInfo
->RefIndex
[
1882 RefreshRateTableIndex
].
1887 tempal
= (tempal
>> 4);
1889 tempal
= (tempal
& 0x0f);
1892 tempcx
= LCDLenList
[tempbx
]; /* mov cl,byte ptr cs:LCDLenList[bx] */
1894 if (pVBInfo
->LCDInfo
& EnableScalingLCD
) { /* ScaleLCD */
1895 if ((tempbx
== 5) || (tempbx
) == 7)
1896 tempcx
= LCDDesDataLen2
;
1897 else if ((tempbx
== 3) || (tempbx
== 8))
1898 tempcx
= LVDSDesDataLen2
;
1900 /* mov di, word ptr cs:LCDDataList[bx] */
1901 /* tempdi = pVideoMemory[LCDDataList + tempbx * 2] |
1902 (pVideoMemory[LCDDataList + tempbx * 2 + 1] << 8); */
1907 tempdi
= xgifb_epllcd_crt1
;
1910 tempdi
= XGI_EPLLCDDataPtr
;
1913 tempdi
= XGI_EPLLCDDesDataPtr
;
1916 tempdi
= XGI_LCDDataTable
;
1919 tempdi
= XGI_LCDDesDataTable
;
1922 tempdi
= XGI_EPLCHLCDRegPtr
;
1933 if (tempdi
== NULL
) /* OEMUtil */
1939 while (tempdi
[i
].PANELID
!= 0xff) {
1940 tempdx
= pVBInfo
->LCDResInfo
;
1941 if (tempbx
& 0x0080) { /* OEMUtil */
1942 tempbx
&= (~0x0080);
1943 tempdx
= pVBInfo
->LCDTypeInfo
;
1946 if (pVBInfo
->LCDInfo
& EnableScalingLCD
)
1947 tempdx
&= (~PanelResInfo
);
1949 if (tempdi
[i
].PANELID
== tempdx
) {
1950 tempbx
= tempdi
[i
].MASK
;
1951 tempdx
= pVBInfo
->LCDInfo
;
1953 if (ModeNo
<= 0x13) /* alan 09/10/2003 */
1954 tempdx
|= SetLCDStdMode
;
1956 if (modeflag
& HalfDCLK
)
1957 tempdx
|= SetLCDLowResolution
;
1960 if (tempbx
== tempdi
[i
].CAP
)
1967 switch (tempdi
[i
].DATAPTR
) {
1969 return &XGI_LVDSCRT11024x768_1_H
[tempal
];
1972 return &XGI_LVDSCRT11024x768_2_H
[tempal
];
1975 return &XGI_LVDSCRT11280x1024_1_H
[tempal
];
1978 return &XGI_LVDSCRT11280x1024_2_H
[tempal
];
1981 return &XGI_LVDSCRT11400x1050_1_H
[tempal
];
1984 return &XGI_LVDSCRT11400x1050_2_H
[tempal
];
1987 return &XGI_LVDSCRT11600x1200_1_H
[tempal
];
1990 return &XGI_LVDSCRT11024x768_1_Hx75
[tempal
];
1993 return &XGI_LVDSCRT11024x768_2_Hx75
[tempal
];
1996 return &XGI_LVDSCRT11280x1024_1_Hx75
[tempal
];
1999 return &XGI_LVDSCRT11280x1024_2_Hx75
[tempal
];
2004 } else if (table
== 1) {
2005 switch (tempdi
[i
].DATAPTR
) {
2007 return &XGI_LVDSCRT11024x768_1_V
[tempal
];
2010 return &XGI_LVDSCRT11024x768_2_V
[tempal
];
2013 return &XGI_LVDSCRT11280x1024_1_V
[tempal
];
2016 return &XGI_LVDSCRT11280x1024_2_V
[tempal
];
2019 return &XGI_LVDSCRT11400x1050_1_V
[tempal
];
2022 return &XGI_LVDSCRT11400x1050_2_V
[tempal
];
2025 return &XGI_LVDSCRT11600x1200_1_V
[tempal
];
2028 return &XGI_LVDSCRT11024x768_1_Vx75
[tempal
];
2031 return &XGI_LVDSCRT11024x768_2_Vx75
[tempal
];
2034 return &XGI_LVDSCRT11280x1024_1_Vx75
[tempal
];
2037 return &XGI_LVDSCRT11280x1024_2_Vx75
[tempal
];
2042 } else if (table
== 2) {
2043 switch (tempdi
[i
].DATAPTR
) {
2045 return &XGI_LVDS1024x768Data_1
[tempal
];
2048 return &XGI_LVDS1024x768Data_2
[tempal
];
2051 return &XGI_LVDS1280x1024Data_1
[tempal
];
2054 return &XGI_LVDS1280x1024Data_2
[tempal
];
2057 return &XGI_LVDS1400x1050Data_1
[tempal
];
2060 return &XGI_LVDS1400x1050Data_2
[tempal
];
2063 return &XGI_LVDS1600x1200Data_1
[tempal
];
2066 return &XGI_LVDSNoScalingData
[tempal
];
2069 return &XGI_LVDS1024x768Data_1x75
[tempal
];
2072 return &XGI_LVDS1024x768Data_2x75
[tempal
];
2075 return &XGI_LVDS1280x1024Data_1x75
[tempal
];
2078 return &XGI_LVDS1280x1024Data_2x75
[tempal
];
2081 return &XGI_LVDSNoScalingDatax75
[tempal
];
2086 } else if (table
== 3) {
2087 switch (tempdi
[i
].DATAPTR
) {
2089 return &XGI_LVDS1024x768Des_1
[tempal
];
2092 return &XGI_LVDS1024x768Des_3
[tempal
];
2095 return &XGI_LVDS1024x768Des_2
[tempal
];
2098 return &XGI_LVDS1280x1024Des_1
[tempal
];
2101 return &XGI_LVDS1280x1024Des_2
[tempal
];
2104 return &XGI_LVDS1400x1050Des_1
[tempal
];
2107 return &XGI_LVDS1400x1050Des_2
[tempal
];
2110 return &XGI_LVDS1600x1200Des_1
[tempal
];
2113 return &XGI_LVDSNoScalingDesData
[tempal
];
2116 return &XGI_LVDS1024x768Des_1x75
[tempal
];
2119 return &XGI_LVDS1024x768Des_3x75
[tempal
];
2122 return &XGI_LVDS1024x768Des_2x75
[tempal
];
2125 return &XGI_LVDS1280x1024Des_1x75
[tempal
];
2128 return &XGI_LVDS1280x1024Des_2x75
[tempal
];
2131 return &XGI_LVDSNoScalingDesDatax75
[tempal
];
2136 } else if (table
== 4) {
2137 switch (tempdi
[i
].DATAPTR
) {
2139 return &XGI_ExtLCD1024x768Data
[tempal
];
2142 return &XGI_StLCD1024x768Data
[tempal
];
2145 return &XGI_CetLCD1024x768Data
[tempal
];
2148 return &XGI_ExtLCD1280x1024Data
[tempal
];
2151 return &XGI_StLCD1280x1024Data
[tempal
];
2154 return &XGI_CetLCD1280x1024Data
[tempal
];
2158 return &xgifb_lcd_1400x1050
[tempal
];
2161 return &XGI_CetLCD1400x1050Data
[tempal
];
2164 return &XGI_ExtLCD1600x1200Data
[tempal
];
2167 return &XGI_StLCD1600x1200Data
[tempal
];
2170 return &XGI_NoScalingData
[tempal
];
2173 return &XGI_ExtLCD1024x768x75Data
[tempal
];
2176 return &XGI_ExtLCD1024x768x75Data
[tempal
];
2179 return &XGI_CetLCD1024x768x75Data
[tempal
];
2183 return &xgifb_lcd_1280x1024x75
[tempal
];
2186 return &XGI_CetLCD1280x1024x75Data
[tempal
];
2189 return &XGI_NoScalingDatax75
[tempal
];
2194 } else if (table
== 5) {
2195 switch (tempdi
[i
].DATAPTR
) {
2197 return &XGI_ExtLCDDes1024x768Data
[tempal
];
2200 return &XGI_StLCDDes1024x768Data
[tempal
];
2203 return &XGI_CetLCDDes1024x768Data
[tempal
];
2206 if ((pVBInfo
->VBType
& VB_XGI301LV
) ||
2207 (pVBInfo
->VBType
& VB_XGI302LV
))
2208 return &XGI_ExtLCDDLDes1280x1024Data
[tempal
];
2210 return &XGI_ExtLCDDes1280x1024Data
[tempal
];
2213 if ((pVBInfo
->VBType
& VB_XGI301LV
) ||
2214 (pVBInfo
->VBType
& VB_XGI302LV
))
2215 return &XGI_StLCDDLDes1280x1024Data
[tempal
];
2217 return &XGI_StLCDDes1280x1024Data
[tempal
];
2220 if ((pVBInfo
->VBType
& VB_XGI301LV
) ||
2221 (pVBInfo
->VBType
& VB_XGI302LV
))
2222 return &XGI_CetLCDDLDes1280x1024Data
[tempal
];
2224 return &XGI_CetLCDDes1280x1024Data
[tempal
];
2228 if ((pVBInfo
->VBType
& VB_XGI301LV
) ||
2229 (pVBInfo
->VBType
& VB_XGI302LV
))
2230 return &xgifb_lcddldes_1400x1050
[tempal
];
2232 return &xgifb_lcddes_1400x1050
[tempal
];
2235 return &XGI_CetLCDDes1400x1050Data
[tempal
];
2238 return &XGI_CetLCDDes1400x1050Data2
[tempal
];
2241 if ((pVBInfo
->VBType
& VB_XGI301LV
) ||
2242 (pVBInfo
->VBType
& VB_XGI302LV
))
2243 return &XGI_ExtLCDDLDes1600x1200Data
[tempal
];
2245 return &XGI_ExtLCDDes1600x1200Data
[tempal
];
2248 if ((pVBInfo
->VBType
& VB_XGI301LV
) ||
2249 (pVBInfo
->VBType
& VB_XGI302LV
))
2250 return &XGI_StLCDDLDes1600x1200Data
[tempal
];
2252 return &XGI_StLCDDes1600x1200Data
[tempal
];
2255 return &XGI_NoScalingDesData
[tempal
];
2259 return &xgifb_lcddes_1024x768x75
[tempal
];
2262 return &XGI_CetLCDDes1024x768x75Data
[tempal
];
2266 if ((pVBInfo
->VBType
& VB_XGI301LV
) ||
2267 (pVBInfo
->VBType
& VB_XGI302LV
))
2268 return &xgifb_lcddldes_1280x1024x75
[tempal
];
2270 return &xgifb_lcddes_1280x1024x75
[tempal
];
2273 if ((pVBInfo
->VBType
& VB_XGI301LV
) ||
2274 (pVBInfo
->VBType
& VB_XGI302LV
))
2275 return &XGI_CetLCDDLDes1280x1024x75Data
[tempal
];
2277 return &XGI_CetLCDDes1280x1024x75Data
[tempal
];
2280 return &XGI_NoScalingDesDatax75
[tempal
];
2285 } else if (table
== 6) {
2286 switch (tempdi
[i
].DATAPTR
) {
2288 return &XGI_CH7017LV1024x768
[tempal
];
2291 return &XGI_CH7017LV1400x1050
[tempal
];
2300 static void *XGI_GetTVPtr(unsigned short BX
, unsigned short ModeNo
,
2301 unsigned short ModeIdIndex
,
2302 unsigned short RefreshRateTableIndex
,
2303 struct vb_device_info
*pVBInfo
)
2305 unsigned short i
, tempdx
, tempbx
, tempal
, modeflag
, table
;
2306 struct XGI330_TVDataTablStruct
*tempdi
= NULL
;
2310 if (ModeNo
<= 0x13) {
2311 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
2312 tempal
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_CRT2CRTC
;
2314 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
2315 tempal
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRT2CRTC
;
2318 tempal
= tempal
& 0x3f;
2323 tempdi
= NULL
; /*EPLCHTVCRT1Ptr_H;*/
2326 tempdi
= NULL
; /*EPLCHTVCRT1Ptr_V;*/
2330 tempdi
= xgifb_chrontel_tv
;
2336 tempdi
= XGI_TVDataTable
;
2345 if (tempdi
== NULL
) /* OEMUtil */
2348 tempdx
= pVBInfo
->TVInfo
;
2350 if (pVBInfo
->VBInfo
& SetInSlaveMode
)
2351 tempdx
= tempdx
| SetTVLockMode
;
2353 if (modeflag
& HalfDCLK
)
2354 tempdx
= tempdx
| SetTVLowResolution
;
2358 while (tempdi
[i
].MASK
!= 0xffff) {
2359 if ((tempdx
& tempdi
[i
].MASK
) == tempdi
[i
].CAP
)
2365 if (table
== 0x00) {
2366 } else if (table
== 0x01) {
2367 } else if (table
== 0x04) {
2368 switch (tempdi
[i
].DATAPTR
) {
2370 return &XGI_ExtPALData
[tempal
];
2373 return &XGI_ExtNTSCData
[tempal
];
2376 return &XGI_StPALData
[tempal
];
2379 return &XGI_StNTSCData
[tempal
];
2382 return &XGI_ExtHiTVData
[tempal
];
2385 return &XGI_St2HiTVData
[tempal
];
2388 return &XGI_ExtYPbPr525iData
[tempal
];
2391 return &XGI_ExtYPbPr525pData
[tempal
];
2394 return &XGI_ExtYPbPr750pData
[tempal
];
2397 return &XGI_StYPbPr525iData
[tempal
];
2400 return &XGI_StYPbPr525pData
[tempal
];
2403 return &XGI_StYPbPr750pData
[tempal
];
2405 case 12: /* avoid system hang */
2406 return &XGI_ExtNTSCData
[tempal
];
2409 return &XGI_St1HiTVData
[tempal
];
2414 } else if (table
== 0x02) {
2415 switch (tempdi
[i
].DATAPTR
) {
2417 return &XGI_CHTVUNTSCData
[tempal
];
2420 return &XGI_CHTVONTSCData
[tempal
];
2423 return &XGI_CHTVUPALData
[tempal
];
2426 return &XGI_CHTVOPALData
[tempal
];
2431 } else if (table
== 0x06) {
2436 static void XGI_GetLVDSData(unsigned short ModeNo
, unsigned short ModeIdIndex
,
2437 unsigned short RefreshRateTableIndex
,
2438 struct vb_device_info
*pVBInfo
)
2440 unsigned short tempbx
;
2441 struct XGI330_LVDSDataStruct
*LCDPtr
= NULL
;
2445 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToLCDA
)) {
2446 LCDPtr
= (struct XGI330_LVDSDataStruct
*) XGI_GetLcdPtr(tempbx
,
2447 ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
2449 pVBInfo
->VGAHT
= LCDPtr
->VGAHT
;
2450 pVBInfo
->VGAVT
= LCDPtr
->VGAVT
;
2451 pVBInfo
->HT
= LCDPtr
->LCDHT
;
2452 pVBInfo
->VT
= LCDPtr
->LCDVT
;
2455 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToLCDA
)) {
2456 if (!(pVBInfo
->LCDInfo
& (SetLCDtoNonExpanding
2457 | EnableScalingLCD
))) {
2458 if ((pVBInfo
->LCDResInfo
== Panel1024x768
) ||
2459 (pVBInfo
->LCDResInfo
== Panel1024x768x75
)) {
2460 pVBInfo
->HDE
= 1024;
2462 } else if ((pVBInfo
->LCDResInfo
== Panel1280x1024
) ||
2463 (pVBInfo
->LCDResInfo
== Panel1280x1024x75
)) {
2464 pVBInfo
->HDE
= 1280;
2465 pVBInfo
->VDE
= 1024;
2466 } else if (pVBInfo
->LCDResInfo
== Panel1400x1050
) {
2467 pVBInfo
->HDE
= 1400;
2468 pVBInfo
->VDE
= 1050;
2470 pVBInfo
->HDE
= 1600;
2471 pVBInfo
->VDE
= 1200;
2477 static void XGI_ModCRT1Regs(unsigned short ModeNo
, unsigned short ModeIdIndex
,
2478 unsigned short RefreshRateTableIndex
,
2479 struct xgi_hw_device_info
*HwDeviceExtension
,
2480 struct vb_device_info
*pVBInfo
)
2482 unsigned char index
;
2483 unsigned short tempbx
, i
;
2484 struct XGI_LVDSCRT1HDataStruct
*LCDPtr
= NULL
;
2485 struct XGI_LVDSCRT1VDataStruct
*LCDPtr1
= NULL
;
2488 index
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_CRT2CRTC
;
2490 index
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRT2CRTC
;
2492 index
= index
& IndexMask
;
2496 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToLCDA
)) {
2497 LCDPtr
= (struct XGI_LVDSCRT1HDataStruct
*)
2498 XGI_GetLcdPtr(tempbx
, ModeNo
,
2500 RefreshRateTableIndex
,
2503 for (i
= 0; i
< 8; i
++)
2504 pVBInfo
->TimingH
[0].data
[i
] = LCDPtr
[0].Reg
[i
];
2507 XGI_SetCRT1Timing_H(pVBInfo
, HwDeviceExtension
);
2511 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToLCDA
)) {
2512 LCDPtr1
= (struct XGI_LVDSCRT1VDataStruct
*)
2517 RefreshRateTableIndex
,
2519 for (i
= 0; i
< 7; i
++)
2520 pVBInfo
->TimingV
[0].data
[i
] = LCDPtr1
[0].Reg
[i
];
2523 XGI_SetCRT1Timing_V(ModeIdIndex
, ModeNo
, pVBInfo
);
2526 static unsigned short XGI_GetLCDCapPtr(struct vb_device_info
*pVBInfo
)
2528 unsigned char tempal
, tempah
, tempbl
, i
;
2530 tempah
= xgifb_reg_get(pVBInfo
->P3d4
, 0x36);
2531 tempal
= tempah
& 0x0F;
2532 tempah
= tempah
& 0xF0;
2534 tempbl
= pVBInfo
->LCDCapList
[i
].LCD_ID
;
2536 while (tempbl
!= 0xFF) {
2537 if (tempbl
& 0x80) { /* OEMUtil */
2539 tempbl
= tempbl
& ~(0x80);
2542 if (tempal
== tempbl
)
2547 tempbl
= pVBInfo
->LCDCapList
[i
].LCD_ID
;
2553 static unsigned short XGI_GetLCDCapPtr1(struct vb_device_info
*pVBInfo
)
2555 unsigned short tempah
, tempal
, tempbl
, i
;
2557 tempal
= pVBInfo
->LCDResInfo
;
2558 tempah
= pVBInfo
->LCDTypeInfo
;
2561 tempbl
= pVBInfo
->LCDCapList
[i
].LCD_ID
;
2563 while (tempbl
!= 0xFF) {
2564 if ((tempbl
& 0x80) && (tempbl
!= 0x80)) {
2569 if (tempal
== tempbl
)
2573 tempbl
= pVBInfo
->LCDCapList
[i
].LCD_ID
;
2576 if (tempbl
== 0xFF) {
2577 pVBInfo
->LCDResInfo
= Panel1024x768
;
2578 pVBInfo
->LCDTypeInfo
= 0;
2585 static void XGI_GetLCDSync(unsigned short *HSyncWidth
,
2586 unsigned short *VSyncWidth
,
2587 struct vb_device_info
*pVBInfo
)
2589 unsigned short Index
;
2591 Index
= XGI_GetLCDCapPtr(pVBInfo
);
2592 *HSyncWidth
= pVBInfo
->LCDCapList
[Index
].LCD_HSyncWidth
;
2593 *VSyncWidth
= pVBInfo
->LCDCapList
[Index
].LCD_VSyncWidth
;
2598 static void XGI_SetLVDSRegs(unsigned short ModeNo
, unsigned short ModeIdIndex
,
2599 unsigned short RefreshRateTableIndex
,
2600 struct vb_device_info
*pVBInfo
)
2602 unsigned short tempbx
, tempax
, tempcx
, tempdx
, push1
, push2
, modeflag
;
2603 unsigned long temp
, temp1
, temp2
, temp3
, push3
;
2604 struct XGI330_LCDDataDesStruct
*LCDPtr
= NULL
;
2605 struct XGI330_LCDDataDesStruct2
*LCDPtr1
= NULL
;
2608 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
2610 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
2613 if (pVBInfo
->LCDInfo
& EnableScalingLCD
)
2615 (struct XGI330_LCDDataDesStruct2
*)
2620 RefreshRateTableIndex
,
2624 (struct XGI330_LCDDataDesStruct
*)
2629 RefreshRateTableIndex
,
2632 XGI_GetLCDSync(&tempax
, &tempbx
, pVBInfo
);
2637 if ((pVBInfo
->LCDResInfo
== Panel1024x768
) ||
2638 (pVBInfo
->LCDResInfo
== Panel1024x768x75
)) {
2641 } else if ((pVBInfo
->LCDResInfo
== Panel1280x1024
) ||
2642 (pVBInfo
->LCDResInfo
== Panel1280x1024x75
)) {
2645 } else if (pVBInfo
->LCDResInfo
== Panel1400x1050
) {
2653 if (pVBInfo
->LCDInfo
& SetLCDtoNonExpanding
) {
2654 pVBInfo
->HDE
= tempax
;
2655 pVBInfo
->VDE
= tempbx
;
2656 pVBInfo
->VGAHDE
= tempax
;
2657 pVBInfo
->VGAVDE
= tempbx
;
2660 tempax
= pVBInfo
->HT
;
2662 if (pVBInfo
->LCDInfo
& EnableScalingLCD
)
2663 tempbx
= LCDPtr1
->LCDHDES
;
2665 tempbx
= LCDPtr
->LCDHDES
;
2667 tempcx
= pVBInfo
->HDE
;
2668 tempbx
= tempbx
& 0x0fff;
2671 if (tempcx
>= tempax
)
2674 xgifb_reg_set(pVBInfo
->Part1Port
, 0x1A, tempbx
& 0x07);
2676 tempcx
= tempcx
>> 3;
2677 tempbx
= tempbx
>> 3;
2679 xgifb_reg_set(pVBInfo
->Part1Port
, 0x16,
2680 (unsigned short) (tempbx
& 0xff));
2681 xgifb_reg_set(pVBInfo
->Part1Port
, 0x17,
2682 (unsigned short) (tempcx
& 0xff));
2684 tempax
= pVBInfo
->HT
;
2686 if (pVBInfo
->LCDInfo
& EnableScalingLCD
)
2687 tempbx
= LCDPtr1
->LCDHRS
;
2689 tempbx
= LCDPtr
->LCDHRS
;
2693 if (pVBInfo
->LCDInfo
& EnableScalingLCD
)
2694 tempcx
= LCDPtr1
->LCDHSync
;
2698 if (tempcx
>= tempax
)
2701 tempax
= tempbx
& 0x07;
2702 tempax
= tempax
>> 5;
2703 tempcx
= tempcx
>> 3;
2704 tempbx
= tempbx
>> 3;
2709 xgifb_reg_set(pVBInfo
->Part1Port
, 0x15, tempax
);
2710 xgifb_reg_set(pVBInfo
->Part1Port
, 0x14,
2711 (unsigned short) (tempbx
& 0xff));
2713 tempax
= pVBInfo
->VT
;
2714 if (pVBInfo
->LCDInfo
& EnableScalingLCD
)
2715 tempbx
= LCDPtr1
->LCDVDES
;
2717 tempbx
= LCDPtr
->LCDVDES
;
2718 tempcx
= pVBInfo
->VDE
;
2720 tempbx
= tempbx
& 0x0fff;
2722 if (tempcx
>= tempax
)
2725 xgifb_reg_set(pVBInfo
->Part1Port
, 0x1b,
2726 (unsigned short) (tempbx
& 0xff));
2727 xgifb_reg_set(pVBInfo
->Part1Port
, 0x1c,
2728 (unsigned short) (tempcx
& 0xff));
2730 tempbx
= (tempbx
>> 8) & 0x07;
2731 tempcx
= (tempcx
>> 8) & 0x07;
2733 xgifb_reg_set(pVBInfo
->Part1Port
, 0x1d,
2734 (unsigned short) ((tempcx
<< 3)
2737 tempax
= pVBInfo
->VT
;
2738 if (pVBInfo
->LCDInfo
& EnableScalingLCD
)
2739 tempbx
= LCDPtr1
->LCDVRS
;
2741 tempbx
= LCDPtr
->LCDVRS
;
2743 /* tempbx = tempbx >> 4; */
2746 if (pVBInfo
->LCDInfo
& EnableScalingLCD
)
2747 tempcx
= LCDPtr1
->LCDVSync
;
2750 if (tempcx
>= tempax
)
2753 xgifb_reg_set(pVBInfo
->Part1Port
, 0x18,
2754 (unsigned short) (tempbx
& 0xff));
2755 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x19, ~0x0f,
2756 (unsigned short) (tempcx
& 0x0f));
2758 tempax
= ((tempbx
>> 8) & 0x07) << 3;
2760 tempbx
= pVBInfo
->VGAVDE
;
2761 if (tempbx
!= pVBInfo
->VDE
)
2764 if (pVBInfo
->LCDInfo
& EnableLVDSDDA
)
2767 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x1a, 0x07,
2770 tempcx
= pVBInfo
->VGAVT
;
2771 tempbx
= pVBInfo
->VDE
;
2772 tempax
= pVBInfo
->VGAVDE
;
2775 temp
= tempax
; /* 0430 ylshieh */
2776 temp1
= (temp
<< 18) / tempbx
;
2778 tempdx
= (unsigned short) ((temp
<< 18) % tempbx
);
2786 xgifb_reg_set(pVBInfo
->Part1Port
, 0x37,
2787 (unsigned short) (temp2
& 0xff));
2788 xgifb_reg_set(pVBInfo
->Part1Port
, 0x36,
2789 (unsigned short) ((temp2
>> 8) & 0xff));
2791 tempbx
= (unsigned short) (temp2
>> 16);
2792 tempax
= tempbx
& 0x03;
2794 tempbx
= pVBInfo
->VGAVDE
;
2795 if (tempbx
== pVBInfo
->VDE
)
2798 xgifb_reg_set(pVBInfo
->Part1Port
, 0x35, tempax
);
2800 if (pVBInfo
->VBType
& VB_XGI301C
) {
2802 xgifb_reg_set(pVBInfo
->Part4Port
,
2804 (unsigned short) (temp2
& 0xff));
2805 xgifb_reg_set(pVBInfo
->Part4Port
,
2807 (unsigned short) ((temp2
>> 8) &
2809 tempbx
= (unsigned short) (temp2
>> 16);
2810 xgifb_reg_and_or(pVBInfo
->Part4Port
, 0x3a,
2812 (unsigned short) ((tempbx
&
2815 tempcx
= pVBInfo
->VGAVDE
;
2816 if (tempcx
== pVBInfo
->VDE
)
2817 xgifb_reg_and_or(pVBInfo
->Part4Port
,
2820 xgifb_reg_and_or(pVBInfo
->Part4Port
,
2824 tempcx
= pVBInfo
->VGAHDE
;
2825 tempbx
= pVBInfo
->HDE
;
2827 temp1
= tempcx
<< 16;
2829 tempax
= (unsigned short) (temp1
/ tempbx
);
2831 if ((tempbx
& 0xffff) == (tempcx
& 0xffff))
2835 temp1
= pVBInfo
->VGAHDE
<< 16;
2838 temp3
= temp3
<< 16;
2841 temp3
= (temp3
& 0xffff0000) + (temp1
& 0xffff);
2843 tempax
= (unsigned short) (temp3
& 0xff);
2844 xgifb_reg_set(pVBInfo
->Part1Port
, 0x1f, tempax
);
2846 temp1
= pVBInfo
->VGAVDE
<< 18;
2847 temp1
= temp1
/ push3
;
2848 tempbx
= (unsigned short) (temp1
& 0xffff);
2850 if (pVBInfo
->LCDResInfo
== Panel1024x768
)
2853 tempax
= ((tempbx
>> 8) & 0xff) << 3;
2854 tempax
|= (unsigned short) ((temp3
>> 8) & 0x07);
2855 xgifb_reg_set(pVBInfo
->Part1Port
, 0x20,
2856 (unsigned short) (tempax
& 0xff));
2857 xgifb_reg_set(pVBInfo
->Part1Port
, 0x21,
2858 (unsigned short) (tempbx
& 0xff));
2860 temp3
= temp3
>> 16;
2862 if (modeflag
& HalfDCLK
)
2865 xgifb_reg_set(pVBInfo
->Part1Port
, 0x22,
2866 (unsigned short) ((temp3
>> 8) & 0xff));
2867 xgifb_reg_set(pVBInfo
->Part1Port
, 0x23,
2868 (unsigned short) (temp3
& 0xff));
2871 /* --------------------------------------------------------------------- */
2872 /* Function : XGI_GETLCDVCLKPtr */
2874 /* Output : al -> VCLK Index */
2876 /* --------------------------------------------------------------------- */
2877 static void XGI_GetLCDVCLKPtr(unsigned char *di_0
, unsigned char *di_1
,
2878 struct vb_device_info
*pVBInfo
)
2880 unsigned short index
;
2882 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToLCDA
)) {
2883 /* index = XGI_GetLCDCapPtr(pVBInfo); */
2884 index
= XGI_GetLCDCapPtr1(pVBInfo
);
2886 if (pVBInfo
->VBInfo
& SetCRT2ToLCD
) { /* LCDB */
2887 *di_0
= pVBInfo
->LCDCapList
[index
].LCUCHAR_VCLKData1
;
2888 *di_1
= pVBInfo
->LCDCapList
[index
].LCUCHAR_VCLKData2
;
2890 *di_0
= pVBInfo
->LCDCapList
[index
].LCDA_VCLKData1
;
2891 *di_1
= pVBInfo
->LCDCapList
[index
].LCDA_VCLKData2
;
2897 static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex
,
2898 unsigned short ModeNo
, unsigned short ModeIdIndex
,
2899 struct vb_device_info
*pVBInfo
)
2902 unsigned short index
, modeflag
;
2903 unsigned char tempal
;
2907 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
2909 /* si+Ext_ResInfo */
2910 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
2912 if ((pVBInfo
->SetFlag
& ProgrammingCRT2
) &&
2913 (!(pVBInfo
->LCDInfo
& EnableScalingLCD
))) { /* {LCDA/LCDB} */
2914 index
= XGI_GetLCDCapPtr(pVBInfo
);
2915 tempal
= pVBInfo
->LCDCapList
[index
].LCD_VCLK
;
2917 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToLCDA
))
2921 if (pVBInfo
->VBType
&
2927 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
) {
2928 tempal
= HiTVVCLKDIV2
;
2929 if (!(pVBInfo
->TVInfo
& RPLLDIV2XO
))
2931 if (pVBInfo
->TVInfo
& TVSimuMode
) {
2932 tempal
= HiTVSimuVCLK
;
2933 if (!(modeflag
& Charx8Dot
))
2934 tempal
= HiTVTextVCLK
;
2940 if (pVBInfo
->TVInfo
& SetYPbPrMode750p
) {
2941 tempal
= YPbPr750pVCLK
;
2945 if (pVBInfo
->TVInfo
& SetYPbPrMode525p
) {
2946 tempal
= YPbPr525pVCLK
;
2950 tempal
= NTSC1024VCLK
;
2952 if (!(pVBInfo
->TVInfo
& NTSC1024x768
)) {
2953 tempal
= TVVCLKDIV2
;
2954 if (!(pVBInfo
->TVInfo
& RPLLDIV2XO
))
2958 if (pVBInfo
->VBInfo
& SetCRT2ToTV
)
2963 tempal
= (unsigned char) inb((pVBInfo
->P3ca
+ 0x02));
2964 tempal
= tempal
>> 2;
2967 /* for Dot8 Scaling LCD */
2968 if ((pVBInfo
->LCDInfo
& EnableScalingLCD
) && (modeflag
& Charx8Dot
))
2969 tempal
= tempal
^ tempal
; /* ; set to VCLK25MHz always */
2974 tempal
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].Ext_CRTVCLK
;
2978 static void XGI_GetVCLKLen(unsigned char tempal
, unsigned char *di_0
,
2979 unsigned char *di_1
, struct vb_device_info
*pVBInfo
)
2981 if (pVBInfo
->VBType
& (VB_XGI301
| VB_XGI301B
| VB_XGI302B
2982 | VB_XGI301LV
| VB_XGI302LV
| VB_XGI301C
)) {
2983 if ((!(pVBInfo
->VBInfo
& SetCRT2ToLCDA
)) && (pVBInfo
->SetFlag
2984 & ProgrammingCRT2
)) {
2985 *di_0
= (unsigned char) XGI_VBVCLKData
[tempal
].SR2B
;
2986 *di_1
= XGI_VBVCLKData
[tempal
].SR2C
;
2989 *di_0
= XGI_VCLKData
[tempal
].SR2B
;
2990 *di_1
= XGI_VCLKData
[tempal
].SR2C
;
2994 static void XGI_SetCRT2ECLK(unsigned short ModeNo
, unsigned short ModeIdIndex
,
2995 unsigned short RefreshRateTableIndex
,
2996 struct vb_device_info
*pVBInfo
)
2998 unsigned char di_0
, di_1
, tempal
;
3001 tempal
= XGI_GetVCLKPtr(RefreshRateTableIndex
, ModeNo
, ModeIdIndex
,
3003 XGI_GetVCLKLen(tempal
, &di_0
, &di_1
, pVBInfo
);
3004 XGI_GetLCDVCLKPtr(&di_0
, &di_1
, pVBInfo
);
3006 for (i
= 0; i
< 4; i
++) {
3007 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x31, ~0x30,
3008 (unsigned short) (0x10 * i
));
3009 if ((!(pVBInfo
->VBInfo
& SetCRT2ToLCDA
))
3010 && (!(pVBInfo
->VBInfo
& SetInSlaveMode
))) {
3011 xgifb_reg_set(pVBInfo
->P3c4
, 0x2e, di_0
);
3012 xgifb_reg_set(pVBInfo
->P3c4
, 0x2f, di_1
);
3014 xgifb_reg_set(pVBInfo
->P3c4
, 0x2b, di_0
);
3015 xgifb_reg_set(pVBInfo
->P3c4
, 0x2c, di_1
);
3020 static void XGI_UpdateModeInfo(struct xgi_hw_device_info
*HwDeviceExtension
,
3021 struct vb_device_info
*pVBInfo
)
3023 unsigned short tempcl
, tempch
, temp
, tempbl
, tempax
;
3025 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
| VB_XGI301LV
3026 | VB_XGI302LV
| VB_XGI301C
)) {
3029 temp
= xgifb_reg_get(pVBInfo
->P3c4
, 0x01);
3031 if (!(temp
& 0x20)) {
3032 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x17);
3034 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x53);
3036 tempcl
|= ActiveCRT1
;
3040 temp
= xgifb_reg_get(pVBInfo
->Part1Port
, 0x2e);
3043 if (!(temp
== 0x08)) {
3044 /* Check ChannelA by Part1_13 [2003/10/03] */
3045 tempax
= xgifb_reg_get(pVBInfo
->Part1Port
, 0x13);
3047 tempcl
= tempcl
| ActiveLCD
;
3051 if (!(tempcl
& ActiveLCD
))
3053 tempcl
|= ActiveCRT2
;
3056 tempcl
|= ActiveLCD
;
3059 temp
= xgifb_reg_get(pVBInfo
->Part2Port
, 0x00);
3062 tempch
|= ActiveAVideo
;
3065 tempch
|= ActiveSVideo
;
3068 tempch
|= ActiveSCART
;
3070 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
) {
3072 tempch
|= ActiveHiTV
;
3075 if (pVBInfo
->VBInfo
& SetCRT2ToYPbPr
) {
3076 temp
= xgifb_reg_get(
3081 tempch
|= ActiveYPbPr
;
3089 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x3d);
3090 if (tempcl
& ActiveLCD
) {
3091 if ((pVBInfo
->SetFlag
& ReserveTVOption
)) {
3092 if (temp
& ActiveTV
)
3097 tempbl
= ~ModeSwitchStatus
;
3098 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x3d, tempbl
, temp
);
3100 if (!(pVBInfo
->SetFlag
& ReserveTVOption
))
3101 xgifb_reg_set(pVBInfo
->P3d4
, 0x3e, tempch
);
3107 void XGI_GetVGAType(struct xgi_hw_device_info
*HwDeviceExtension
,
3108 struct vb_device_info
*pVBInfo
)
3111 if ( HwDeviceExtension->jChipType >= XG20 ) {
3112 pVBInfo->Set_VGAType = XG20;
3114 pVBInfo->Set_VGAType = VGA_XGI340;
3117 pVBInfo
->Set_VGAType
= HwDeviceExtension
->jChipType
;
3120 void XGI_GetVBType(struct vb_device_info
*pVBInfo
)
3122 unsigned short flag
, tempbx
, tempah
;
3124 if (pVBInfo
->IF_DEF_LVDS
== 0) {
3125 tempbx
= VB_XGI302B
;
3126 flag
= xgifb_reg_get(pVBInfo
->Part4Port
, 0x00);
3129 flag
= xgifb_reg_get(pVBInfo
->Part4Port
, 0x01);
3131 tempbx
= VB_XGI301B
;
3133 tempbx
= VB_XGI301C
;
3135 tempbx
= VB_XGI301LV
;
3137 tempbx
= VB_XGI302LV
;
3138 tempah
= xgifb_reg_get(
3148 if (tempbx
& (VB_XGI301B
| VB_XGI302B
)) {
3149 flag
= xgifb_reg_get(
3154 tempbx
= tempbx
| VB_NoLCD
;
3158 pVBInfo
->VBType
= tempbx
;
3162 void XGI_GetVBInfo(unsigned short ModeNo
, unsigned short ModeIdIndex
,
3163 struct xgi_hw_device_info
*HwDeviceExtension
,
3164 struct vb_device_info
*pVBInfo
)
3166 unsigned short tempax
, push
, tempbx
, temp
, modeflag
;
3169 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
3171 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
3173 pVBInfo
->SetFlag
= 0;
3174 pVBInfo
->ModeType
= modeflag
& ModeInfoFlag
;
3177 if (pVBInfo
->VBType
& 0xFFFF) {
3178 /* Check Display Device */
3179 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x30);
3180 tempbx
= tempbx
| temp
;
3181 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x31);
3185 tempbx
= tempbx
| tempax
;
3186 temp
= (SetCRT2ToDualEdge
| SetCRT2ToYPbPr
| SetCRT2ToLCDA
3187 | SetInSlaveMode
| DisableCRT2Display
);
3188 temp
= 0xFFFF ^ temp
;
3191 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x38);
3193 if (pVBInfo
->IF_DEF_LCDA
== 1) {
3195 if ((pVBInfo
->Set_VGAType
>= XG20
)
3196 || (pVBInfo
->Set_VGAType
>= XG40
)) {
3197 if (pVBInfo
->IF_DEF_LVDS
== 0) {
3198 /* if ((pVBInfo->VBType & VB_XGI302B)
3199 || (pVBInfo->VBType & VB_XGI301LV)
3200 || (pVBInfo->VBType & VB_XGI302LV)
3201 || (pVBInfo->VBType & VB_XGI301C))
3203 if (pVBInfo
->VBType
&
3208 if (temp
& EnableDualEdge
) {
3212 if (temp
& SetToLCDA
)
3221 if (pVBInfo
->IF_DEF_YPbPr
== 1) {
3222 /* [Billy] 07/05/04 */
3223 if (((pVBInfo
->IF_DEF_LVDS
== 0) &&
3224 ((pVBInfo
->VBType
& VB_XGI301LV
) ||
3225 (pVBInfo
->VBType
& VB_XGI302LV
) ||
3226 (pVBInfo
->VBType
& VB_XGI301C
)))) {
3227 if (temp
& SetYPbPr
) { /* temp = CR38 */
3228 if (pVBInfo
->IF_DEF_HiVision
== 1) {
3229 /* shampoo add for new
3231 temp
= xgifb_reg_get(
3235 tempbx
|= SetCRT2ToHiVisionTV
;
3237 if (temp
!= YPbPrMode1080i
) {
3239 (~SetCRT2ToHiVisionTV
);
3245 /* tempbx |= SetCRT2ToYPbPr; */
3250 tempax
= push
; /* restore CR31 */
3252 if (pVBInfo
->IF_DEF_LVDS
== 0) {
3253 if (pVBInfo
->IF_DEF_YPbPr
== 1) {
3254 if (pVBInfo
->IF_DEF_HiVision
== 1)
3259 if (pVBInfo
->IF_DEF_HiVision
== 1)
3264 } else { /* 3nd party chip */
3265 temp
= SetCRT2ToLCD
;
3268 if (!(tempbx
& temp
)) {
3269 tempax
|= DisableCRT2Display
;
3273 if (pVBInfo
->IF_DEF_LCDA
== 1) { /* Select Display Device */
3274 if (!(pVBInfo
->VBType
& VB_NoLCD
)) {
3275 if (tempbx
& SetCRT2ToLCDA
) {
3276 if (tempbx
& SetSimuScanMode
)
3277 tempbx
&= (~(SetCRT2ToLCD
|
3281 tempbx
&= (~(SetCRT2ToLCD
|
3290 /* for driver abnormal */
3291 if (!(tempbx
& (SwitchToCRT2
| SetSimuScanMode
))) {
3292 if (pVBInfo
->IF_DEF_CRT2Monitor
== 1) {
3293 if (tempbx
& SetCRT2ToRAMDAC
) {
3298 tempbx
&= (0x00FF | (~SetCRT2ToYPbPr
));
3301 tempbx
&= (~(SetCRT2ToRAMDAC
|
3307 if (!(pVBInfo
->VBType
& VB_NoLCD
)) {
3308 if (tempbx
& SetCRT2ToLCD
) {
3313 tempbx
&= (0x00FF | (~SetCRT2ToYPbPr
));
3317 if (tempbx
& SetCRT2ToSCART
) {
3322 tempbx
&= (0x00FF | (~SetCRT2ToYPbPr
));
3325 if (pVBInfo
->IF_DEF_YPbPr
== 1) {
3326 if (tempbx
& SetCRT2ToYPbPr
)
3332 if (pVBInfo
->IF_DEF_HiVision
== 1) {
3333 if (tempbx
& SetCRT2ToHiVisionTV
)
3335 SetCRT2ToHiVisionTV
|
3340 if (tempax
& DisableCRT2Display
) { /* Set Display Device Info */
3341 if (!(tempbx
& (SwitchToCRT2
| SetSimuScanMode
)))
3342 tempbx
= DisableCRT2Display
;
3345 if (!(tempbx
& DisableCRT2Display
)) {
3346 if ((!(tempbx
& DriverMode
)) ||
3347 (!(modeflag
& CRT2Mode
))) {
3348 if (pVBInfo
->IF_DEF_LCDA
== 1) {
3349 if (!(tempbx
& SetCRT2ToLCDA
))
3350 tempbx
|= (SetInSlaveMode
|
3355 /* LCD+TV can't support in slave mode
3356 * (Force LCDA+TV->LCDB) */
3357 if ((tempbx
& SetInSlaveMode
) &&
3358 (tempbx
& SetCRT2ToLCDA
)) {
3359 tempbx
^= (SetCRT2ToLCD
|
3362 pVBInfo
->SetFlag
|= ReserveTVOption
;
3367 pVBInfo
->VBInfo
= tempbx
;
3370 void XGI_GetTVInfo(unsigned short ModeNo
, unsigned short ModeIdIndex
,
3371 struct vb_device_info
*pVBInfo
)
3373 unsigned short temp
, tempbx
= 0, resinfo
= 0, modeflag
, index1
;
3378 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
3379 if (ModeNo
<= 0x13) {
3380 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].
3381 St_ModeFlag
; /* si+St_ModeFlag */
3382 resinfo
= pVBInfo
->SModeIDTable
[ModeIdIndex
].
3383 St_ResInfo
; /* si+St_ResInfo */
3385 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].
3387 resinfo
= pVBInfo
->EModeIDTable
[ModeIdIndex
].
3388 Ext_RESINFO
; /* si+Ext_ResInfo */
3391 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
3392 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x35);
3394 if (tempbx
& SetPALTV
) {
3395 tempbx
&= (SetCHTVOverScan
|
3399 if (tempbx
& SetPALMTV
)
3400 /* set to NTSC if PAL-M */
3401 tempbx
&= ~SetPALTV
;
3403 tempbx
&= (SetCHTVOverScan
|
3407 if (pVBInfo->IF_DEF_LVDS == 0) {
3409 index1 = xgifb_reg_get(pVBInfo->P3d4, 0x38);
3410 //00:PAL, 01:PAL-M, 10:PAL-N
3411 temp2 = (index1 & 0xC0) >> 5;
3413 if (temp2 & 0x02) //PAL-M
3414 tempbx &= (~SetPALTV);
3419 if (pVBInfo
->IF_DEF_LVDS
== 0) {
3420 if (pVBInfo
->VBInfo
& SetCRT2ToSCART
)
3424 if (pVBInfo
->IF_DEF_YPbPr
== 1) {
3425 if (pVBInfo
->VBInfo
& SetCRT2ToYPbPr
) {
3426 index1
= xgifb_reg_get(pVBInfo
->P3d4
, 0x35);
3427 index1
&= YPbPrMode
;
3429 if (index1
== YPbPrMode525i
)
3430 tempbx
|= SetYPbPrMode525i
;
3432 if (index1
== YPbPrMode525p
)
3433 tempbx
= tempbx
| SetYPbPrMode525p
;
3434 if (index1
== YPbPrMode750p
)
3435 tempbx
= tempbx
| SetYPbPrMode750p
;
3439 if (pVBInfo
->IF_DEF_HiVision
== 1) {
3440 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
)
3441 tempbx
= tempbx
| SetYPbPrMode1080i
| SetPALTV
;
3444 if (pVBInfo
->IF_DEF_LVDS
== 0) { /* shampoo */
3445 if ((pVBInfo
->VBInfo
& SetInSlaveMode
) &&
3446 (!(pVBInfo
->VBInfo
& SetNotSimuMode
)))
3447 tempbx
|= TVSimuMode
;
3449 if (!(tempbx
& SetPALTV
) &&
3451 (resinfo
== 8)) /* NTSC 1024x768, */
3452 tempbx
|= NTSC1024x768
;
3454 tempbx
|= RPLLDIV2XO
;
3456 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
) {
3457 if (pVBInfo
->VBInfo
& SetInSlaveMode
)
3458 tempbx
&= (~RPLLDIV2XO
);
3461 (SetYPbPrMode525p
| SetYPbPrMode750p
))
3462 tempbx
&= (~RPLLDIV2XO
);
3463 else if (!(pVBInfo
->VBType
&
3469 if (tempbx
& TVSimuMode
)
3470 tempbx
&= (~RPLLDIV2XO
);
3475 pVBInfo
->TVInfo
= tempbx
;
3478 unsigned char XGI_GetLCDInfo(unsigned short ModeNo
, unsigned short ModeIdIndex
,
3479 struct vb_device_info
*pVBInfo
)
3481 unsigned short temp
, tempax
, tempbx
, modeflag
, resinfo
= 0, LCDIdIndex
;
3483 pVBInfo
->LCDResInfo
= 0;
3484 pVBInfo
->LCDTypeInfo
= 0;
3485 pVBInfo
->LCDInfo
= 0;
3487 if (ModeNo
<= 0x13) {
3488 /* si+St_ModeFlag // */
3489 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
3491 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
3492 /* si+Ext_ResInfo // */
3493 resinfo
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
3496 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x36); /* Get LCD Res.Info */
3497 tempbx
= temp
& 0x0F;
3500 tempbx
= Panel1024x768
; /* default */
3502 /* LCD75 [2003/8/22] Vicent */
3503 if ((tempbx
== Panel1024x768
) || (tempbx
== Panel1280x1024
)) {
3504 if (pVBInfo
->VBInfo
& DriverMode
) {
3505 tempax
= xgifb_reg_get(pVBInfo
->P3d4
, 0x33);
3506 if (pVBInfo
->VBInfo
& SetCRT2ToLCDA
)
3509 tempax
= tempax
>> 4;
3511 if ((resinfo
== 6) || (resinfo
== 9)) {
3513 tempbx
|= PanelRef75Hz
;
3514 } else if ((resinfo
== 7) || (resinfo
== 8)) {
3516 tempbx
|= PanelRef75Hz
;
3521 pVBInfo
->LCDResInfo
= tempbx
;
3525 if (!(pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToLCDA
)))
3530 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x37);
3532 temp
&= (ScalingLCD
| LCDNonExpanding
| LCDSyncBit
| SetPWDEnable
);
3536 LCDIdIndex
= XGI_GetLCDCapPtr1(pVBInfo
);
3538 tempax
= pVBInfo
->LCDCapList
[LCDIdIndex
].LCD_Capability
;
3540 if (pVBInfo
->IF_DEF_LVDS
== 0) { /* shampoo */
3541 if (((pVBInfo
->VBType
& VB_XGI302LV
) || (pVBInfo
->VBType
3542 & VB_XGI301C
)) && (tempax
& LCDDualLink
)) {
3543 tempbx
|= SetLCDDualLink
;
3547 if (pVBInfo
->IF_DEF_LVDS
== 0) {
3548 if ((pVBInfo
->LCDResInfo
== Panel1400x1050
) && (pVBInfo
->VBInfo
3549 & SetCRT2ToLCD
) && (ModeNo
> 0x13) && (resinfo
3550 == 9) && (!(tempbx
& EnableScalingLCD
)))
3551 /* set to center in 1280x1024 LCDB for Panel1400x1050 */
3552 tempbx
|= SetLCDtoNonExpanding
;
3556 if (tempax & LCDBToA) {
3557 tempbx |= SetLCDBToA;
3561 if (pVBInfo
->IF_DEF_ExpLink
== 1) {
3562 if (modeflag
& HalfDCLK
) {
3563 /* if (!(pVBInfo->LCDInfo&LCDNonExpanding)) */
3564 if (!(tempbx
& SetLCDtoNonExpanding
)) {
3565 tempbx
|= EnableLVDSDDA
;
3567 if (ModeNo
> 0x13) {
3568 if (pVBInfo
->LCDResInfo
3570 if (resinfo
== 4) {/* 512x384 */
3571 tempbx
|= EnableLVDSDDA
;
3579 if (pVBInfo
->VBInfo
& SetInSlaveMode
) {
3580 if (pVBInfo
->VBInfo
& SetNotSimuMode
)
3581 tempbx
|= LCDVESATiming
;
3583 tempbx
|= LCDVESATiming
;
3586 pVBInfo
->LCDInfo
= tempbx
;
3588 if (pVBInfo
->IF_DEF_LVDS
== 0) {
3589 if (tempax
& (LockLCDBToA
| StLCDBToA
)) {
3590 if (pVBInfo
->VBInfo
& SetInSlaveMode
) {
3591 if (!(tempax
& LockLCDBToA
)) {
3592 if (ModeNo
<= 0x13) {
3607 if (pVBInfo->IF_DEF_LVDS == 0) {
3608 if (tempax & (LockLCDBToA | StLCDBToA)) {
3609 if (pVBInfo->VBInfo & SetInSlaveMode) {
3610 if (!((!(tempax & LockLCDBToA)) &&
3628 unsigned char XGI_SearchModeID(unsigned short ModeNo
,
3629 unsigned short *ModeIdIndex
, struct vb_device_info
*pVBInfo
)
3633 if (ModeNo
<= 0x13) {
3634 /* for (*ModeIdIndex=0;
3635 *ModeIdIndex < sizeof(pVBInfo->SModeIDTable)
3636 / sizeof(struct XGI_StStruct);
3637 (*ModeIdIndex)++) */
3638 for (*ModeIdIndex
= 0;; (*ModeIdIndex
)++) {
3639 if (pVBInfo
->SModeIDTable
[*ModeIdIndex
].St_ModeID
==
3642 if (pVBInfo
->SModeIDTable
[*ModeIdIndex
].St_ModeID
==
3648 (*ModeIdIndex
)++; /* 400 lines */
3650 (*ModeIdIndex
) += 2; /* 400 lines */
3651 /* else 350 lines */
3653 /* for (*ModeIdIndex=0;
3654 *ModeIdIndex < sizeof(pVBInfo->EModeIDTable)
3655 / sizeof(struct XGI_ExtStruct);
3656 (*ModeIdIndex)++) */
3657 for (*ModeIdIndex
= 0;; (*ModeIdIndex
)++) {
3658 if (pVBInfo
->EModeIDTable
[*ModeIdIndex
].Ext_ModeID
==
3661 if (pVBInfo
->EModeIDTable
[*ModeIdIndex
].Ext_ModeID
==
3670 static unsigned char XG21GPIODataTransfer(unsigned char ujDate
)
3672 unsigned char ujRet
= 0;
3673 unsigned char i
= 0;
3675 for (i
= 0; i
< 8; i
++) {
3677 /* ujRet |= GETBITS(ujDate >> i, 0:0); */
3678 ujRet
|= (ujDate
>> i
) & 1;
3684 /*----------------------------------------------------------------------------*/
3686 /* bl[5] : LVDS signal */
3687 /* bl[1] : LVDS backlight */
3688 /* bl[0] : LVDS VDD */
3689 /*----------------------------------------------------------------------------*/
3690 static unsigned char XGI_XG21GetPSCValue(struct vb_device_info
*pVBInfo
)
3692 unsigned char CR4A
, temp
;
3694 CR4A
= xgifb_reg_get(pVBInfo
->P3d4
, 0x4A);
3695 xgifb_reg_and(pVBInfo
->P3d4
, 0x4A, ~0x23); /* enable GPIO write */
3697 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x48);
3699 temp
= XG21GPIODataTransfer(temp
);
3701 xgifb_reg_set(pVBInfo
->P3d4
, 0x4A, CR4A
);
3705 /*----------------------------------------------------------------------------*/
3707 /* bl[5] : LVDS signal */
3708 /* bl[1] : LVDS backlight */
3709 /* bl[0] : LVDS VDD */
3710 /*----------------------------------------------------------------------------*/
3711 static unsigned char XGI_XG27GetPSCValue(struct vb_device_info
*pVBInfo
)
3713 unsigned char CR4A
, CRB4
, temp
;
3715 CR4A
= xgifb_reg_get(pVBInfo
->P3d4
, 0x4A);
3716 xgifb_reg_and(pVBInfo
->P3d4
, 0x4A, ~0x0C); /* enable GPIO write */
3718 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x48);
3722 xgifb_reg_set(pVBInfo
->P3d4
, 0x4A, CR4A
);
3723 CRB4
= xgifb_reg_get(pVBInfo
->P3d4
, 0xB4);
3724 temp
|= ((CRB4
& 0x04) << 3);
3728 void XGI_DisplayOn(struct xgi_hw_device_info
*pXGIHWDE
,
3729 struct vb_device_info
*pVBInfo
)
3732 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x01, 0xDF, 0x00);
3733 if (pXGIHWDE
->jChipType
== XG21
) {
3734 if (pVBInfo
->IF_DEF_LVDS
== 1) {
3735 if (!(XGI_XG21GetPSCValue(pVBInfo
) & 0x1)) {
3737 XGI_XG21BLSignalVDD(0x01, 0x01, pVBInfo
);
3738 XGI_XG21SetPanelDelay(2, pVBInfo
);
3740 if (!(XGI_XG21GetPSCValue(pVBInfo
) & 0x20))
3741 /* LVDS signal on */
3742 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo
);
3743 XGI_XG21SetPanelDelay(3, pVBInfo
);
3744 /* LVDS backlight on */
3745 XGI_XG21BLSignalVDD(0x02, 0x02, pVBInfo
);
3747 /* DVO/DVI signal on */
3748 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo
);
3753 if (pXGIHWDE
->jChipType
== XG27
) {
3754 if (pVBInfo
->IF_DEF_LVDS
== 1) {
3755 if (!(XGI_XG27GetPSCValue(pVBInfo
) & 0x1)) {
3757 XGI_XG27BLSignalVDD(0x01, 0x01, pVBInfo
);
3758 XGI_XG21SetPanelDelay(2, pVBInfo
);
3760 if (!(XGI_XG27GetPSCValue(pVBInfo
) & 0x20))
3761 /* LVDS signal on */
3762 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo
);
3763 XGI_XG21SetPanelDelay(3, pVBInfo
);
3764 /* LVDS backlight on */
3765 XGI_XG27BLSignalVDD(0x02, 0x02, pVBInfo
);
3767 /* DVO/DVI signal on */
3768 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo
);
3774 void XGI_DisplayOff(struct xgi_hw_device_info
*pXGIHWDE
,
3775 struct vb_device_info
*pVBInfo
)
3778 if (pXGIHWDE
->jChipType
== XG21
) {
3779 if (pVBInfo
->IF_DEF_LVDS
== 1) {
3780 /* LVDS backlight off */
3781 XGI_XG21BLSignalVDD(0x02, 0x00, pVBInfo
);
3782 XGI_XG21SetPanelDelay(3, pVBInfo
);
3784 /* DVO/DVI signal off */
3785 XGI_XG21BLSignalVDD(0x20, 0x00, pVBInfo
);
3789 if (pXGIHWDE
->jChipType
== XG27
) {
3790 if ((XGI_XG27GetPSCValue(pVBInfo
) & 0x2)) {
3791 /* LVDS backlight off */
3792 XGI_XG27BLSignalVDD(0x02, 0x00, pVBInfo
);
3793 XGI_XG21SetPanelDelay(3, pVBInfo
);
3796 if (pVBInfo
->IF_DEF_LVDS
== 0)
3797 /* DVO/DVI signal off */
3798 XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo
);
3801 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x01, 0xDF, 0x20);
3804 static void XGI_WaitDisply(struct vb_device_info
*pVBInfo
)
3806 while ((inb(pVBInfo
->P3da
) & 0x01))
3809 while (!(inb(pVBInfo
->P3da
) & 0x01))
3813 static void XGI_AutoThreshold(struct vb_device_info
*pVBInfo
)
3815 xgifb_reg_or(pVBInfo
->Part1Port
, 0x01, 0x40);
3818 static void XGI_SaveCRT2Info(unsigned short ModeNo
,
3819 struct vb_device_info
*pVBInfo
)
3821 unsigned short temp1
, temp2
;
3823 /* reserve CR34 for CRT1 Mode No */
3824 xgifb_reg_set(pVBInfo
->P3d4
, 0x34, ModeNo
);
3825 temp1
= (pVBInfo
->VBInfo
& SetInSlaveMode
) >> 8;
3826 temp2
= ~(SetInSlaveMode
>> 8);
3827 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x31, temp2
, temp1
);
3830 static void XGI_GetCRT2ResInfo(unsigned short ModeNo
,
3831 unsigned short ModeIdIndex
,
3832 struct vb_device_info
*pVBInfo
)
3834 unsigned short xres
, yres
, modeflag
, resindex
;
3836 resindex
= XGI_GetResInfo(ModeNo
, ModeIdIndex
, pVBInfo
);
3837 if (ModeNo
<= 0x13) {
3838 xres
= pVBInfo
->StResInfo
[resindex
].HTotal
;
3839 yres
= pVBInfo
->StResInfo
[resindex
].VTotal
;
3841 /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;*/
3843 xres
= pVBInfo
->ModeResInfo
[resindex
].HTotal
; /* xres->ax */
3844 yres
= pVBInfo
->ModeResInfo
[resindex
].VTotal
; /* yres->bx */
3845 /* si+St_ModeFlag */
3846 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
3849 if (pVBInfo->IF_DEF_FSTN) {
3854 if (modeflag
& HalfDCLK
)
3857 if (modeflag
& DoubleScanMode
)
3862 if (pVBInfo
->VBInfo
& SetCRT2ToLCD
) {
3863 if (pVBInfo
->IF_DEF_LVDS
== 0) {
3864 if (pVBInfo
->LCDResInfo
== Panel1600x1200
) {
3865 if (!(pVBInfo
->LCDInfo
& LCDVESATiming
)) {
3871 if (pVBInfo
->LCDResInfo
== Panel1280x1024
) {
3874 else if (yres
== 350)
3877 if (pVBInfo
->LCDInfo
& LCDVESATiming
) {
3883 if (pVBInfo
->LCDResInfo
== Panel1024x768
) {
3884 if (!(pVBInfo
->LCDInfo
& LCDVESATiming
)) {
3885 if (!(pVBInfo
->LCDInfo
3886 & LCDNonExpanding
)) {
3889 else if (yres
== 400)
3891 else if (yres
== 480)
3902 pVBInfo
->VGAHDE
= xres
;
3903 pVBInfo
->HDE
= xres
;
3904 pVBInfo
->VGAVDE
= yres
;
3905 pVBInfo
->VDE
= yres
;
3908 static unsigned char XGI_IsLCDDualLink(struct vb_device_info
*pVBInfo
)
3911 if ((pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToLCDA
)) &&
3912 (pVBInfo
->LCDInfo
& SetLCDDualLink
)) /* shampoo0129 */
3918 static void XGI_GetRAMDAC2DATA(unsigned short ModeNo
,
3919 unsigned short ModeIdIndex
,
3920 unsigned short RefreshRateTableIndex
,
3921 struct vb_device_info
*pVBInfo
)
3923 unsigned short tempax
, tempbx
, temp1
, temp2
, modeflag
= 0, tempcx
,
3924 StandTableIndex
, CRT1Index
;
3926 pVBInfo
->RVBHCMAX
= 1;
3927 pVBInfo
->RVBHCFACT
= 1;
3929 if (ModeNo
<= 0x13) {
3930 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
3931 StandTableIndex
= XGI_GetModePtr(ModeNo
, ModeIdIndex
, pVBInfo
);
3932 tempax
= pVBInfo
->StandTable
[StandTableIndex
].CRTC
[0];
3933 tempbx
= pVBInfo
->StandTable
[StandTableIndex
].CRTC
[6];
3934 temp1
= pVBInfo
->StandTable
[StandTableIndex
].CRTC
[7];
3936 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
3937 CRT1Index
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].
3939 CRT1Index
&= IndexMask
;
3940 temp1
= (unsigned short) pVBInfo
->
3941 XGINEWUB_CRT1Table
[CRT1Index
].CR
[0];
3942 temp2
= (unsigned short) pVBInfo
->
3943 XGINEWUB_CRT1Table
[CRT1Index
].CR
[5];
3944 tempax
= (temp1
& 0xFF) | ((temp2
& 0x03) << 8);
3945 tempbx
= (unsigned short) pVBInfo
->
3946 XGINEWUB_CRT1Table
[CRT1Index
].CR
[8];
3947 tempcx
= (unsigned short) pVBInfo
->
3948 XGINEWUB_CRT1Table
[CRT1Index
].CR
[14] << 8;
3950 tempcx
= tempcx
<< 2;
3952 temp1
= (unsigned short) pVBInfo
->
3953 XGINEWUB_CRT1Table
[CRT1Index
].CR
[9];
3963 if (modeflag
& Charx8Dot
)
3968 pVBInfo
->VGAHT
= tempax
;
3969 pVBInfo
->HT
= tempax
;
3971 pVBInfo
->VGAVT
= tempbx
;
3972 pVBInfo
->VT
= tempbx
;
3975 static void XGI_GetCRT2Data(unsigned short ModeNo
, unsigned short ModeIdIndex
,
3976 unsigned short RefreshRateTableIndex
,
3977 struct vb_device_info
*pVBInfo
)
3979 unsigned short tempax
= 0, tempbx
, modeflag
, resinfo
;
3981 struct XGI_LCDDataStruct
*LCDPtr
= NULL
;
3982 struct XGI_TVDataStruct
*TVPtr
= NULL
;
3984 if (ModeNo
<= 0x13) {
3986 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
3987 resinfo
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ResInfo
;
3989 /* si+Ext_ResInfo */
3990 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
3991 resinfo
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
3994 pVBInfo
->NewFlickerMode
= 0;
3995 pVBInfo
->RVBHRS
= 50;
3997 if (pVBInfo
->VBInfo
& SetCRT2ToRAMDAC
) {
3998 XGI_GetRAMDAC2DATA(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
4005 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToLCDA
)) {
4006 LCDPtr
= (struct XGI_LCDDataStruct
*) XGI_GetLcdPtr(tempbx
,
4007 ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
4010 pVBInfo
->RVBHCMAX
= LCDPtr
->RVBHCMAX
;
4011 pVBInfo
->RVBHCFACT
= LCDPtr
->RVBHCFACT
;
4012 pVBInfo
->VGAHT
= LCDPtr
->VGAHT
;
4013 pVBInfo
->VGAVT
= LCDPtr
->VGAVT
;
4014 pVBInfo
->HT
= LCDPtr
->LCDHT
;
4015 pVBInfo
->VT
= LCDPtr
->LCDVT
;
4017 if (pVBInfo
->LCDResInfo
== Panel1024x768
) {
4021 if (!(pVBInfo
->LCDInfo
& LCDVESATiming
)) {
4022 if (pVBInfo
->VGAVDE
== 357)
4024 else if (pVBInfo
->VGAVDE
== 420)
4026 else if (pVBInfo
->VGAVDE
== 525)
4028 else if (pVBInfo
->VGAVDE
== 600)
4030 /* else if (pVBInfo->VGAVDE==350) tempbx=560; */
4031 /* else if (pVBInfo->VGAVDE==400) tempbx=640; */
4036 } else if (pVBInfo
->LCDResInfo
== Panel1024x768x75
) {
4039 } else if (pVBInfo
->LCDResInfo
== Panel1280x1024
) {
4041 if (pVBInfo
->VGAVDE
== 360)
4043 else if (pVBInfo
->VGAVDE
== 375)
4045 else if (pVBInfo
->VGAVDE
== 405)
4049 } else if (pVBInfo
->LCDResInfo
== Panel1280x1024x75
) {
4052 } else if (pVBInfo
->LCDResInfo
== Panel1280x960
) {
4054 if (pVBInfo
->VGAVDE
== 350)
4056 else if (pVBInfo
->VGAVDE
== 400)
4058 else if (pVBInfo
->VGAVDE
== 1024)
4062 } else if (pVBInfo
->LCDResInfo
== Panel1400x1050
) {
4066 if (pVBInfo
->VGAVDE
== 1024) {
4070 } else if (pVBInfo
->LCDResInfo
== Panel1600x1200
) {
4072 tempbx
= 1200; /* alan 10/14/2003 */
4073 if (!(pVBInfo
->LCDInfo
& LCDVESATiming
)) {
4074 if (pVBInfo
->VGAVDE
== 350)
4076 else if (pVBInfo
->VGAVDE
== 400)
4081 if (pVBInfo
->LCDInfo
& LCDNonExpanding
) {
4082 tempax
= pVBInfo
->VGAHDE
;
4083 tempbx
= pVBInfo
->VGAVDE
;
4086 pVBInfo
->HDE
= tempax
;
4087 pVBInfo
->VDE
= tempbx
;
4091 if (pVBInfo
->VBInfo
& (SetCRT2ToTV
)) {
4093 TVPtr
= (struct XGI_TVDataStruct
*) XGI_GetTVPtr(tempbx
,
4094 ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
4097 pVBInfo
->RVBHCMAX
= TVPtr
->RVBHCMAX
;
4098 pVBInfo
->RVBHCFACT
= TVPtr
->RVBHCFACT
;
4099 pVBInfo
->VGAHT
= TVPtr
->VGAHT
;
4100 pVBInfo
->VGAVT
= TVPtr
->VGAVT
;
4101 pVBInfo
->HDE
= TVPtr
->TVHDE
;
4102 pVBInfo
->VDE
= TVPtr
->TVVDE
;
4103 pVBInfo
->RVBHRS
= TVPtr
->RVBHRS
;
4104 pVBInfo
->NewFlickerMode
= TVPtr
->FlickerMode
;
4106 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
) {
4107 if (resinfo
== 0x08)
4108 pVBInfo
->NewFlickerMode
= 0x40;
4109 else if (resinfo
== 0x09)
4110 pVBInfo
->NewFlickerMode
= 0x40;
4111 else if (resinfo
== 0x12)
4112 pVBInfo
->NewFlickerMode
= 0x40;
4114 if (pVBInfo
->VGAVDE
== 350)
4115 pVBInfo
->TVInfo
|= TVSimuMode
;
4120 if (pVBInfo
->VBInfo
& SetInSlaveMode
) {
4121 if (pVBInfo
->TVInfo
& TVSimuMode
) {
4125 if (!(modeflag
& Charx8Dot
)) {
4126 tempax
= StHiTextTVHT
;
4127 tempbx
= StHiTextTVVT
;
4131 } else if (pVBInfo
->VBInfo
& SetCRT2ToYPbPr
) {
4132 if (pVBInfo
->TVInfo
& SetYPbPrMode750p
) {
4133 tempax
= YPbPrTV750pHT
; /* Ext750pTVHT */
4134 tempbx
= YPbPrTV750pVT
; /* Ext750pTVVT */
4137 if (pVBInfo
->TVInfo
& SetYPbPrMode525p
) {
4138 tempax
= YPbPrTV525pHT
; /* Ext525pTVHT */
4139 tempbx
= YPbPrTV525pVT
; /* Ext525pTVVT */
4140 } else if (pVBInfo
->TVInfo
& SetYPbPrMode525i
) {
4141 tempax
= YPbPrTV525iHT
; /* Ext525iTVHT */
4142 tempbx
= YPbPrTV525iVT
; /* Ext525iTVVT */
4143 if (pVBInfo
->TVInfo
& NTSC1024x768
)
4144 tempax
= NTSC1024x768HT
;
4149 if (!(pVBInfo
->TVInfo
& SetPALTV
)) {
4152 if (pVBInfo
->TVInfo
& NTSC1024x768
)
4153 tempax
= NTSC1024x768HT
;
4157 pVBInfo
->HT
= tempax
;
4158 pVBInfo
->VT
= tempbx
;
4163 static void XGI_SetCRT2VCLK(unsigned short ModeNo
, unsigned short ModeIdIndex
,
4164 unsigned short RefreshRateTableIndex
,
4165 struct vb_device_info
*pVBInfo
)
4167 unsigned char di_0
, di_1
, tempal
;
4169 tempal
= XGI_GetVCLKPtr(RefreshRateTableIndex
, ModeNo
, ModeIdIndex
,
4171 XGI_GetVCLKLen(tempal
, &di_0
, &di_1
, pVBInfo
);
4172 XGI_GetLCDVCLKPtr(&di_0
, &di_1
, pVBInfo
);
4174 if (pVBInfo
->VBType
& VB_XGI301
) { /* shampoo 0129 */
4176 xgifb_reg_set(pVBInfo
->Part4Port
, 0x0A, 0x10);
4177 xgifb_reg_set(pVBInfo
->Part4Port
, 0x0B, di_1
);
4178 xgifb_reg_set(pVBInfo
->Part4Port
, 0x0A, di_0
);
4179 } else { /* 301b/302b/301lv/302lv */
4180 xgifb_reg_set(pVBInfo
->Part4Port
, 0x0A, di_0
);
4181 xgifb_reg_set(pVBInfo
->Part4Port
, 0x0B, di_1
);
4184 xgifb_reg_set(pVBInfo
->Part4Port
, 0x00, 0x12);
4186 if (pVBInfo
->VBInfo
& SetCRT2ToRAMDAC
)
4187 xgifb_reg_or(pVBInfo
->Part4Port
, 0x12, 0x28);
4189 xgifb_reg_or(pVBInfo
->Part4Port
, 0x12, 0x08);
4192 static unsigned short XGI_GetColorDepth(unsigned short ModeNo
,
4193 unsigned short ModeIdIndex
, struct vb_device_info
*pVBInfo
)
4195 unsigned short ColorDepth
[6] = { 1, 2, 4, 4, 6, 8 };
4197 unsigned short modeflag
;
4200 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
4202 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
4204 index
= (modeflag
& ModeInfoFlag
) - ModeEGA
;
4209 return ColorDepth
[index
];
4212 static unsigned short XGI_GetOffset(unsigned short ModeNo
,
4213 unsigned short ModeIdIndex
,
4214 unsigned short RefreshRateTableIndex
,
4215 struct xgi_hw_device_info
*HwDeviceExtension
,
4216 struct vb_device_info
*pVBInfo
)
4218 unsigned short temp
, colordepth
, modeinfo
, index
, infoflag
,
4219 ColorDepth
[] = { 0x01, 0x02, 0x04 };
4221 modeinfo
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeInfo
;
4225 infoflag
= pVBInfo
->
4226 RefIndex
[RefreshRateTableIndex
].Ext_InfoFlag
;
4228 index
= (modeinfo
>> 8) & 0xFF;
4230 temp
= pVBInfo
->ScreenOffset
[index
];
4232 if (infoflag
& InterlaceMode
)
4235 colordepth
= XGI_GetColorDepth(ModeNo
, ModeIdIndex
, pVBInfo
);
4237 if ((ModeNo
>= 0x7C) && (ModeNo
<= 0x7E)) {
4238 temp
= ModeNo
- 0x7C;
4239 colordepth
= ColorDepth
[temp
];
4241 if (infoflag
& InterlaceMode
)
4243 return temp
* colordepth
;
4245 return temp
* colordepth
;
4249 static void XGI_SetCRT2Offset(unsigned short ModeNo
,
4250 unsigned short ModeIdIndex
,
4251 unsigned short RefreshRateTableIndex
,
4252 struct xgi_hw_device_info
*HwDeviceExtension
,
4253 struct vb_device_info
*pVBInfo
)
4255 unsigned short offset
;
4258 if (pVBInfo
->VBInfo
& SetInSlaveMode
)
4261 offset
= XGI_GetOffset(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
4262 HwDeviceExtension
, pVBInfo
);
4263 temp
= (unsigned char) (offset
& 0xFF);
4264 xgifb_reg_set(pVBInfo
->Part1Port
, 0x07, temp
);
4265 temp
= (unsigned char) ((offset
& 0xFF00) >> 8);
4266 xgifb_reg_set(pVBInfo
->Part1Port
, 0x09, temp
);
4267 temp
= (unsigned char) (((offset
>> 3) & 0xFF) + 1);
4268 xgifb_reg_set(pVBInfo
->Part1Port
, 0x03, temp
);
4271 static void XGI_SetCRT2FIFO(struct vb_device_info
*pVBInfo
)
4273 /* threshold high ,disable auto threshold */
4274 xgifb_reg_set(pVBInfo
->Part1Port
, 0x01, 0x3B);
4275 /* threshold low default 04h */
4276 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x02, ~(0x3F), 0x04);
4279 static void XGI_PreSetGroup1(unsigned short ModeNo
, unsigned short ModeIdIndex
,
4280 struct xgi_hw_device_info
*HwDeviceExtension
,
4281 unsigned short RefreshRateTableIndex
,
4282 struct vb_device_info
*pVBInfo
)
4284 unsigned short tempcx
= 0, CRT1Index
= 0, resinfo
= 0;
4286 if (ModeNo
> 0x13) {
4287 CRT1Index
= pVBInfo
->
4288 RefIndex
[RefreshRateTableIndex
].Ext_CRT1CRTC
;
4289 CRT1Index
&= IndexMask
;
4290 resinfo
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
4293 XGI_SetCRT2Offset(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
4294 HwDeviceExtension
, pVBInfo
);
4295 XGI_SetCRT2FIFO(pVBInfo
);
4296 /* XGI_SetCRT2Sync(ModeNo,RefreshRateTableIndex); */
4298 for (tempcx
= 4; tempcx
< 7; tempcx
++)
4299 xgifb_reg_set(pVBInfo
->Part1Port
, tempcx
, 0x0);
4301 xgifb_reg_set(pVBInfo
->Part1Port
, 0x50, 0x00);
4302 xgifb_reg_set(pVBInfo
->Part1Port
, 0x02, 0x44); /* temp 0206 */
4305 static void XGI_SetGroup1(unsigned short ModeNo
, unsigned short ModeIdIndex
,
4306 struct xgi_hw_device_info
*HwDeviceExtension
,
4307 unsigned short RefreshRateTableIndex
,
4308 struct vb_device_info
*pVBInfo
)
4310 unsigned short temp
= 0, tempax
= 0, tempbx
= 0, tempcx
= 0,
4311 pushbx
= 0, CRT1Index
= 0, modeflag
, resinfo
= 0;
4313 if (ModeNo
> 0x13) {
4314 CRT1Index
= pVBInfo
->
4315 RefIndex
[RefreshRateTableIndex
].Ext_CRT1CRTC
;
4316 CRT1Index
&= IndexMask
;
4317 resinfo
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
4321 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
4323 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
4325 /* bainy change table name */
4326 if (modeflag
& HalfDCLK
) {
4327 /* BTVGA2HT 0x08,0x09 */
4328 temp
= (pVBInfo
->VGAHT
/ 2 - 1) & 0x0FF;
4329 xgifb_reg_set(pVBInfo
->Part1Port
, 0x08, temp
);
4330 temp
= (((pVBInfo
->VGAHT
/ 2 - 1) & 0xFF00) >> 8) << 4;
4331 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x09, ~0x0F0, temp
);
4332 /* BTVGA2HDEE 0x0A,0x0C */
4333 temp
= (pVBInfo
->VGAHDE
/ 2 + 16) & 0x0FF;
4334 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0A, temp
);
4335 tempcx
= ((pVBInfo
->VGAHT
- pVBInfo
->VGAHDE
) / 2) >> 2;
4336 pushbx
= pVBInfo
->VGAHDE
/ 2 + 16;
4337 tempcx
= tempcx
>> 1;
4338 tempbx
= pushbx
+ tempcx
; /* bx BTVGA@HRS 0x0B,0x0C */
4341 if (pVBInfo
->VBInfo
& SetCRT2ToRAMDAC
) {
4342 tempbx
= pVBInfo
->XGINEWUB_CRT1Table
[CRT1Index
].CR
[4];
4343 tempbx
|= ((pVBInfo
->
4344 XGINEWUB_CRT1Table
[CRT1Index
].CR
[14] &
4346 tempbx
= (tempbx
- 3) << 3; /* (VGAHRS-3)*8 */
4347 tempcx
= pVBInfo
->XGINEWUB_CRT1Table
[CRT1Index
].CR
[5];
4349 temp
= pVBInfo
->XGINEWUB_CRT1Table
[CRT1Index
].CR
[15];
4350 temp
= (temp
& 0x04) << (5 - 2); /* VGAHRE D[5] */
4351 tempcx
= ((tempcx
| temp
) - 3) << 3; /* (VGAHRE-3)*8 */
4357 if (tempcx
> (pVBInfo
->VGAHT
/ 2))
4358 tempcx
= pVBInfo
->VGAHT
/ 2;
4360 temp
= tempbx
& 0x00FF;
4362 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0B, temp
);
4364 temp
= (pVBInfo
->VGAHT
- 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */
4365 xgifb_reg_set(pVBInfo
->Part1Port
, 0x08, temp
);
4366 temp
= (((pVBInfo
->VGAHT
- 1) & 0xFF00) >> 8) << 4;
4367 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x09, ~0x0F0, temp
);
4368 /* BTVGA2HDEE 0x0A,0x0C */
4369 temp
= (pVBInfo
->VGAHDE
+ 16) & 0x0FF;
4370 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0A, temp
);
4371 tempcx
= (pVBInfo
->VGAHT
- pVBInfo
->VGAHDE
) >> 2; /* cx */
4372 pushbx
= pVBInfo
->VGAHDE
+ 16;
4373 tempcx
= tempcx
>> 1;
4374 tempbx
= pushbx
+ tempcx
; /* bx BTVGA@HRS 0x0B,0x0C */
4377 if (pVBInfo
->VBInfo
& SetCRT2ToRAMDAC
) {
4378 tempbx
= pVBInfo
->XGINEWUB_CRT1Table
[CRT1Index
].CR
[3];
4379 tempbx
|= ((pVBInfo
->
4380 XGINEWUB_CRT1Table
[CRT1Index
].CR
[5] &
4382 tempbx
= (tempbx
- 3) << 3; /* (VGAHRS-3)*8 */
4383 tempcx
= pVBInfo
->XGINEWUB_CRT1Table
[CRT1Index
].CR
[4];
4385 temp
= pVBInfo
->XGINEWUB_CRT1Table
[CRT1Index
].CR
[6];
4386 temp
= (temp
& 0x04) << (5 - 2); /* VGAHRE D[5] */
4387 tempcx
= ((tempcx
| temp
) - 3) << 3; /* (VGAHRE-3)*8 */
4392 if (tempcx
> pVBInfo
->VGAHT
)
4393 tempcx
= pVBInfo
->VGAHT
;
4395 temp
= tempbx
& 0x00FF;
4396 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0B, temp
);
4399 tempax
= (tempax
& 0x00FF) | (tempbx
& 0xFF00);
4401 tempbx
= (tempbx
& 0x00FF) | ((tempbx
& 0xFF00) << 4);
4402 tempax
|= (tempbx
& 0xFF00);
4403 temp
= (tempax
& 0xFF00) >> 8;
4404 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0C, temp
);
4405 temp
= tempcx
& 0x00FF;
4406 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0D, temp
);
4407 tempcx
= (pVBInfo
->VGAVT
- 1);
4408 temp
= tempcx
& 0x00FF;
4410 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0E, temp
);
4411 tempbx
= pVBInfo
->VGAVDE
- 1;
4412 temp
= tempbx
& 0x00FF;
4413 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0F, temp
);
4414 temp
= ((tempbx
& 0xFF00) << 3) >> 8;
4415 temp
|= ((tempcx
& 0xFF00) >> 8);
4416 xgifb_reg_set(pVBInfo
->Part1Port
, 0x12, temp
);
4418 tempax
= pVBInfo
->VGAVDE
;
4419 tempbx
= pVBInfo
->VGAVDE
;
4420 tempcx
= pVBInfo
->VGAVT
;
4421 /* BTVGA2VRS 0x10,0x11 */
4422 tempbx
= (pVBInfo
->VGAVT
+ pVBInfo
->VGAVDE
) >> 1;
4423 /* BTVGA2VRE 0x11 */
4424 tempcx
= ((pVBInfo
->VGAVT
- pVBInfo
->VGAVDE
) >> 4) + tempbx
+ 1;
4426 if (pVBInfo
->VBInfo
& SetCRT2ToRAMDAC
) {
4427 tempbx
= pVBInfo
->XGINEWUB_CRT1Table
[CRT1Index
].CR
[10];
4428 temp
= pVBInfo
->XGINEWUB_CRT1Table
[CRT1Index
].CR
[9];
4436 temp
= pVBInfo
->XGINEWUB_CRT1Table
[CRT1Index
].CR
[14];
4441 temp
= pVBInfo
->XGINEWUB_CRT1Table
[CRT1Index
].CR
[11];
4442 tempcx
= (tempcx
& 0xFF00) | (temp
& 0x00FF);
4445 temp
= tempbx
& 0x00FF;
4446 xgifb_reg_set(pVBInfo
->Part1Port
, 0x10, temp
);
4447 temp
= ((tempbx
& 0xFF00) >> 8) << 4;
4448 temp
= ((tempcx
& 0x000F) | (temp
));
4449 xgifb_reg_set(pVBInfo
->Part1Port
, 0x11, temp
);
4452 if (modeflag
& DoubleScanMode
)
4455 if (modeflag
& HalfDCLK
)
4458 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x2C, ~0x0C0, tempax
);
4461 static unsigned short XGI_GetVGAHT2(struct vb_device_info
*pVBInfo
)
4463 unsigned long tempax
, tempbx
;
4465 tempbx
= ((pVBInfo
->VGAVT
- pVBInfo
->VGAVDE
) * pVBInfo
->RVBHCMAX
)
4467 tempax
= (pVBInfo
->VT
- pVBInfo
->VDE
) * pVBInfo
->RVBHCFACT
;
4468 tempax
= (tempax
* pVBInfo
->HT
) / tempbx
;
4470 return (unsigned short) tempax
;
4473 static void XGI_SetLockRegs(unsigned short ModeNo
, unsigned short ModeIdIndex
,
4474 struct xgi_hw_device_info
*HwDeviceExtension
,
4475 unsigned short RefreshRateTableIndex
,
4476 struct vb_device_info
*pVBInfo
)
4478 unsigned short push1
, push2
, tempax
, tempbx
= 0, tempcx
, temp
, resinfo
,
4479 modeflag
, CRT1Index
;
4481 if (ModeNo
<= 0x13) {
4483 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
4484 resinfo
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ResInfo
;
4486 /* si+Ext_ResInfo */
4487 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
4488 resinfo
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
4489 CRT1Index
= pVBInfo
->
4490 RefIndex
[RefreshRateTableIndex
].Ext_CRT1CRTC
;
4491 CRT1Index
&= IndexMask
;
4494 if (!(pVBInfo
->VBInfo
& SetInSlaveMode
))
4497 temp
= 0xFF; /* set MAX HT */
4498 xgifb_reg_set(pVBInfo
->Part1Port
, 0x03, temp
);
4499 /* if (modeflag & Charx8Dot) */
4500 /* tempcx = 0x08; */
4504 if (pVBInfo
->VBType
& (VB_XGI301LV
| VB_XGI302LV
| VB_XGI301C
))
4505 modeflag
|= Charx8Dot
;
4507 tempax
= pVBInfo
->VGAHDE
; /* 0x04 Horizontal Display End */
4509 if (modeflag
& HalfDCLK
)
4510 tempax
= tempax
>> 1;
4512 tempax
= (tempax
/ tempcx
) - 1;
4513 tempbx
|= ((tempax
& 0x00FF) << 8);
4514 temp
= tempax
& 0x00FF;
4515 xgifb_reg_set(pVBInfo
->Part1Port
, 0x04, temp
);
4517 temp
= (tempbx
& 0xFF00) >> 8;
4519 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
4520 if (!(pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
| VB_XGI301LV
4521 | VB_XGI302LV
| VB_XGI301C
)))
4524 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
) {
4525 if (pVBInfo
->VBType
& VB_XGI301LV
) {
4526 if (pVBInfo
->VBExtInfo
== VB_YPbPr1080i
) {
4530 } else if (resinfo
== 7) {
4536 /* 0x05 Horizontal Display Start */
4537 xgifb_reg_set(pVBInfo
->Part1Port
, 0x05, temp
);
4538 /* 0x06 Horizontal Blank end */
4539 xgifb_reg_set(pVBInfo
->Part1Port
, 0x06, 0x03);
4541 if (!(pVBInfo
->VBInfo
& DisableCRT2Display
)) { /* 030226 bainy */
4542 if (pVBInfo
->VBInfo
& SetCRT2ToTV
)
4543 tempax
= pVBInfo
->VGAHT
;
4545 tempax
= XGI_GetVGAHT2(pVBInfo
);
4548 if (tempax
>= pVBInfo
->VGAHT
)
4549 tempax
= pVBInfo
->VGAHT
;
4551 if (modeflag
& HalfDCLK
)
4552 tempax
= tempax
>> 1;
4554 tempax
= (tempax
/ tempcx
) - 5;
4555 tempcx
= tempax
; /* 20030401 0x07 horizontal Retrace Start */
4556 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
) {
4557 temp
= (tempbx
& 0x00FF) - 1;
4558 if (!(modeflag
& HalfDCLK
)) {
4560 if (pVBInfo
->TVInfo
& TVSimuMode
) {
4567 /* tempcx = tempbx & 0x00FF ; */
4568 tempbx
= (tempbx
& 0xFF00) >> 8;
4569 tempcx
= (tempcx
+ tempbx
) >> 1;
4570 temp
= (tempcx
& 0x00FF) + 2;
4572 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
4574 if (!(modeflag
& HalfDCLK
)) {
4575 if ((modeflag
& Charx8Dot
)) {
4577 if (pVBInfo
->VGAHDE
>= 800)
4582 if (!(modeflag
& HalfDCLK
)) {
4584 if (pVBInfo
->LCDResInfo
!= Panel1280x960
) {
4585 if (pVBInfo
->VGAHDE
>= 800) {
4587 if (pVBInfo
->ModeType
==
4589 if (pVBInfo
->VGAVDE
==
4592 if (pVBInfo
->LCDResInfo
!= Panel1280x1024
) {
4599 if (pVBInfo
->VGAHDE
>= 1280) {
4600 if (pVBInfo
->LCDResInfo
4602 if (pVBInfo
->LCDInfo
4603 & LCDNonExpanding
) {
4615 /* 0x07 Horizontal Retrace Start */
4616 xgifb_reg_set(pVBInfo
->Part1Port
, 0x07, temp
);
4617 /* 0x08 Horizontal Retrace End */
4618 xgifb_reg_set(pVBInfo
->Part1Port
, 0x08, 0);
4620 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
4621 if (pVBInfo
->TVInfo
& TVSimuMode
) {
4622 if ((ModeNo
== 0x06) || (ModeNo
== 0x10) || (ModeNo
4623 == 0x11) || (ModeNo
== 0x13) || (ModeNo
4625 xgifb_reg_set(pVBInfo
->Part1Port
, 0x07, 0x5b);
4626 xgifb_reg_set(pVBInfo
->Part1Port
, 0x08, 0x03);
4629 if ((ModeNo
== 0x00) || (ModeNo
== 0x01)) {
4630 if (pVBInfo
->TVInfo
& SetNTSCTV
) {
4631 xgifb_reg_set(pVBInfo
->Part1Port
,
4633 xgifb_reg_set(pVBInfo
->Part1Port
,
4636 xgifb_reg_set(pVBInfo
->Part1Port
,
4638 xgifb_reg_set(pVBInfo
->Part1Port
,
4640 xgifb_reg_set(pVBInfo
->Part1Port
,
4645 if ((ModeNo
== 0x02) || (ModeNo
== 0x03) || (ModeNo
4647 if (pVBInfo
->TVInfo
& SetNTSCTV
) {
4648 xgifb_reg_set(pVBInfo
->Part1Port
,
4650 xgifb_reg_set(pVBInfo
->Part1Port
,
4653 xgifb_reg_set(pVBInfo
->Part1Port
,
4655 xgifb_reg_set(pVBInfo
->Part1Port
,
4657 xgifb_reg_set(pVBInfo
->Part1Port
,
4662 if ((ModeNo
== 0x04) || (ModeNo
== 0x05) || (ModeNo
4663 == 0x0D) || (ModeNo
== 0x50)) {
4664 if (pVBInfo
->TVInfo
& SetNTSCTV
) {
4665 xgifb_reg_set(pVBInfo
->Part1Port
,
4667 xgifb_reg_set(pVBInfo
->Part1Port
,
4670 xgifb_reg_set(pVBInfo
->Part1Port
,
4672 xgifb_reg_set(pVBInfo
->Part1Port
,
4679 xgifb_reg_set(pVBInfo
->Part1Port
, 0x18, 0x03); /* 0x18 SR0B */
4680 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x19, 0xF0, 0x00);
4681 xgifb_reg_set(pVBInfo
->Part1Port
, 0x09, 0xFF); /* 0x09 Set Max VT */
4683 tempbx
= pVBInfo
->VGAVT
;
4686 tempbx
= pVBInfo
->VGAVDE
; /* 0x0E Virtical Display End */
4701 if (pVBInfo
->VBInfo
& SetCRT2ToLCD
) {
4702 if (pVBInfo
->LCDResInfo
== Panel1024x768
) {
4703 if (!(pVBInfo
->LCDInfo
& LCDVESATiming
)) {
4712 temp
= tempbx
& 0x00FF;
4714 temp
= tempbx
& 0x00FF;
4715 /* 0x10 vertical Blank Start */
4716 xgifb_reg_set(pVBInfo
->Part1Port
, 0x10, temp
);
4719 temp
= tempbx
& 0x00FF;
4720 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0E, temp
);
4722 if (tempbx
& 0x0100)
4727 if (modeflag
& DoubleScanMode
)
4730 if (tempbx
& 0x0200)
4733 temp
= (tempax
& 0xFF00) >> 8;
4734 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0B, temp
);
4736 if (tempbx
& 0x0400)
4739 /* 0x11 Vertival Blank End */
4740 xgifb_reg_set(pVBInfo
->Part1Port
, 0x11, 0x00);
4743 tempax
-= tempbx
; /* 0x0C Vertical Retrace Start */
4744 tempax
= tempax
>> 2;
4745 push1
= tempax
; /* push ax */
4747 if (resinfo
!= 0x09) {
4748 tempax
= tempax
<< 1;
4752 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
) {
4753 if (pVBInfo
->VBType
& VB_XGI301LV
) {
4754 if (pVBInfo
->TVInfo
& SetYPbPrMode1080i
) {
4757 if (pVBInfo
->TVInfo
& TVSimuMode
) {
4758 if (pVBInfo
->TVInfo
& SetPALTV
) {
4759 if (pVBInfo
->VBType
&
4761 if (!(pVBInfo
->TVInfo
&
4764 SetYPbPrMode1080i
)))
4776 if (pVBInfo
->TVInfo
& TVSimuMode
) {
4777 if (pVBInfo
->TVInfo
& SetPALTV
) {
4778 if (pVBInfo
->VBType
& VB_XGI301LV
) {
4779 if (!(pVBInfo
->TVInfo
&
4782 SetYPbPrMode1080i
)))
4791 tempax
= tempax
>> 2;
4794 push1
= tempax
; /* push ax */
4796 if ((pVBInfo
->TVInfo
& SetPALTV
)) {
4797 if (tempbx
<= 513) {
4803 temp
= tempbx
& 0x00FF;
4804 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0C, temp
);
4806 temp
= tempbx
& 0x00FF;
4807 xgifb_reg_set(pVBInfo
->Part1Port
, 0x10, temp
);
4809 if (tempbx
& 0x0100)
4812 if (tempbx
& 0x0200)
4813 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x0B, 0x0FF, 0x20);
4817 if (tempbx
& 0x0100)
4820 if (tempbx
& 0x0200)
4823 if (tempbx
& 0x0400)
4826 tempbx
= push1
; /* pop ax */
4827 temp
= tempbx
& 0x00FF;
4829 /* 0x0D vertical Retrace End */
4830 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0D, temp
);
4832 if (tempbx
& 0x0010)
4835 temp
= tempcx
& 0x00FF;
4836 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0A, temp
); /* 0x0A CR07 */
4837 temp
= (tempcx
& 0x0FF00) >> 8;
4838 xgifb_reg_set(pVBInfo
->Part1Port
, 0x17, temp
); /* 0x17 SR0A */
4840 temp
= (tempax
& 0xFF00) >> 8;
4842 temp
= (temp
>> 1) & 0x09;
4844 if (pVBInfo
->VBType
& (VB_XGI301LV
| VB_XGI302LV
| VB_XGI301C
))
4847 xgifb_reg_set(pVBInfo
->Part1Port
, 0x16, temp
); /* 0x16 SR01 */
4848 xgifb_reg_set(pVBInfo
->Part1Port
, 0x0F, 0); /* 0x0F CR14 */
4849 xgifb_reg_set(pVBInfo
->Part1Port
, 0x12, 0); /* 0x12 CR17 */
4851 if (pVBInfo
->LCDInfo
& LCDRGB18Bit
)
4856 xgifb_reg_set(pVBInfo
->Part1Port
, 0x1A, temp
); /* 0x1A SR0E */
4861 static void XGI_SetGroup2(unsigned short ModeNo
, unsigned short ModeIdIndex
,
4862 unsigned short RefreshRateTableIndex
,
4863 struct xgi_hw_device_info
*HwDeviceExtension
,
4864 struct vb_device_info
*pVBInfo
)
4866 unsigned short i
, j
, tempax
, tempbx
, tempcx
, temp
, push1
, push2
,
4867 modeflag
, resinfo
, crt2crtc
;
4868 unsigned char *TimingPoint
;
4870 unsigned long longtemp
, tempeax
, tempebx
, temp2
, tempecx
;
4872 if (ModeNo
<= 0x13) {
4874 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
4875 resinfo
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ResInfo
;
4876 crt2crtc
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_CRT2CRTC
;
4878 /* si+Ext_ResInfo */
4879 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
4880 resinfo
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
4881 crt2crtc
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].
4887 if (!(pVBInfo
->VBInfo
& SetCRT2ToAVIDEO
))
4890 if (!(pVBInfo
->VBInfo
& SetCRT2ToSVIDEO
))
4893 if (pVBInfo
->VBInfo
& SetCRT2ToSCART
)
4896 if (!(pVBInfo
->TVInfo
& SetPALTV
))
4899 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
)
4902 if (pVBInfo
->TVInfo
& (SetYPbPrMode525p
| SetYPbPrMode750p
))
4905 tempax
= (tempax
& 0xff00) >> 8;
4907 xgifb_reg_set(pVBInfo
->Part2Port
, 0x0, tempax
);
4908 TimingPoint
= pVBInfo
->NTSCTiming
;
4910 if (pVBInfo
->TVInfo
& SetPALTV
)
4911 TimingPoint
= pVBInfo
->PALTiming
;
4913 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
) {
4914 TimingPoint
= pVBInfo
->HiTVExtTiming
;
4916 if (pVBInfo
->VBInfo
& SetInSlaveMode
)
4917 TimingPoint
= pVBInfo
->HiTVSt2Timing
;
4919 if (pVBInfo
->SetFlag
& TVSimuMode
)
4920 TimingPoint
= pVBInfo
->HiTVSt1Timing
;
4922 if (!(modeflag
& Charx8Dot
))
4923 TimingPoint
= pVBInfo
->HiTVTextTiming
;
4926 if (pVBInfo
->VBInfo
& SetCRT2ToYPbPr
) {
4927 if (pVBInfo
->TVInfo
& SetYPbPrMode525i
)
4928 TimingPoint
= pVBInfo
->YPbPr525iTiming
;
4930 if (pVBInfo
->TVInfo
& SetYPbPrMode525p
)
4931 TimingPoint
= pVBInfo
->YPbPr525pTiming
;
4933 if (pVBInfo
->TVInfo
& SetYPbPrMode750p
)
4934 TimingPoint
= pVBInfo
->YPbPr750pTiming
;
4937 for (i
= 0x01, j
= 0; i
<= 0x2D; i
++, j
++)
4938 xgifb_reg_set(pVBInfo
->Part2Port
, i
, TimingPoint
[j
]);
4940 for (i
= 0x39; i
<= 0x45; i
++, j
++)
4942 xgifb_reg_set(pVBInfo
->Part2Port
, i
, TimingPoint
[j
]);
4944 if (pVBInfo
->VBInfo
& SetCRT2ToTV
)
4945 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x3A, 0x1F, 0x00);
4947 temp
= pVBInfo
->NewFlickerMode
;
4949 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x0A, 0xFF, temp
);
4951 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
)
4954 if (pVBInfo
->TVInfo
& SetPALTV
)
4959 if (pVBInfo
->VDE
<= tempax
) {
4960 tempax
-= pVBInfo
->VDE
;
4961 tempax
= tempax
>> 2;
4962 tempax
= (tempax
& 0x00FF) | ((tempax
& 0x00FF) << 8);
4964 temp
= (tempax
& 0xFF00) >> 8;
4965 temp
+= (unsigned short) TimingPoint
[0];
4967 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
| VB_XGI301LV
4968 | VB_XGI302LV
| VB_XGI301C
)) {
4969 if (pVBInfo
->VBInfo
& (SetCRT2ToAVIDEO
4970 | SetCRT2ToSVIDEO
| SetCRT2ToSCART
4971 | SetCRT2ToYPbPr
)) {
4972 tempcx
= pVBInfo
->VGAHDE
;
4973 if (tempcx
>= 1024) {
4974 temp
= 0x17; /* NTSC */
4975 if (pVBInfo
->TVInfo
& SetPALTV
)
4976 temp
= 0x19; /* PAL */
4981 xgifb_reg_set(pVBInfo
->Part2Port
, 0x01, temp
);
4983 temp
= (tempax
& 0xFF00) >> 8;
4984 temp
+= TimingPoint
[1];
4986 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
| VB_XGI301LV
4987 | VB_XGI302LV
| VB_XGI301C
)) {
4988 if ((pVBInfo
->VBInfo
& (SetCRT2ToAVIDEO
4989 | SetCRT2ToSVIDEO
| SetCRT2ToSCART
4990 | SetCRT2ToYPbPr
))) {
4991 tempcx
= pVBInfo
->VGAHDE
;
4992 if (tempcx
>= 1024) {
4993 temp
= 0x1D; /* NTSC */
4994 if (pVBInfo
->TVInfo
& SetPALTV
)
4995 temp
= 0x52; /* PAL */
4999 xgifb_reg_set(pVBInfo
->Part2Port
, 0x02, temp
);
5003 tempcx
= pVBInfo
->HT
;
5005 if (XGI_IsLCDDualLink(pVBInfo
))
5006 tempcx
= tempcx
>> 1;
5009 temp
= tempcx
& 0x00FF;
5010 xgifb_reg_set(pVBInfo
->Part2Port
, 0x1B, temp
);
5012 temp
= (tempcx
& 0xFF00) >> 8;
5013 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x1D, ~0x0F, temp
);
5015 tempcx
= pVBInfo
->HT
>> 1;
5016 push1
= tempcx
; /* push cx */
5019 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
)
5022 temp
= tempcx
& 0x00FF;
5024 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x22, 0x0F, temp
);
5026 tempbx
= TimingPoint
[j
] | ((TimingPoint
[j
+ 1]) << 8);
5029 temp
= tempbx
& 0x00FF;
5030 xgifb_reg_set(pVBInfo
->Part2Port
, 0x24, temp
);
5031 temp
= (tempbx
& 0xFF00) >> 8;
5033 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x25, 0x0F, temp
);
5036 tempbx
= tempbx
+ 8;
5037 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
) {
5038 tempbx
= tempbx
- 4;
5042 temp
= (tempbx
& 0x00FF) << 4;
5043 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x29, 0x0F, temp
);
5046 tempcx
+= (TimingPoint
[j
] | ((TimingPoint
[j
+ 1]) << 8));
5047 temp
= tempcx
& 0x00FF;
5048 xgifb_reg_set(pVBInfo
->Part2Port
, 0x27, temp
);
5049 temp
= ((tempcx
& 0xFF00) >> 8) << 4;
5050 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x28, 0x0F, temp
);
5053 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
)
5056 temp
= tempcx
& 0xFF;
5058 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x2A, 0x0F, temp
);
5060 tempcx
= push1
; /* pop cx */
5062 temp
= TimingPoint
[j
] | ((TimingPoint
[j
+ 1]) << 8);
5064 temp
= tempcx
& 0x00FF;
5066 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x2D, 0x0F, temp
);
5070 if (!(pVBInfo
->VBInfo
& SetCRT2ToTV
)) {
5071 tempax
= XGI_GetVGAHT2(pVBInfo
);
5072 tempcx
= tempax
- 1;
5074 temp
= tempcx
& 0x00FF;
5075 xgifb_reg_set(pVBInfo
->Part2Port
, 0x2E, temp
);
5077 tempbx
= pVBInfo
->VDE
;
5079 if (pVBInfo
->VGAVDE
== 360)
5081 if (pVBInfo
->VGAVDE
== 375)
5083 if (pVBInfo
->VGAVDE
== 405)
5086 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
5087 if (pVBInfo
->VBType
&
5088 (VB_XGI301LV
| VB_XGI302LV
| VB_XGI301C
)) {
5089 if (!(pVBInfo
->TVInfo
&
5090 (SetYPbPrMode525p
| SetYPbPrMode750p
)))
5091 tempbx
= tempbx
>> 1;
5093 tempbx
= tempbx
>> 1;
5097 temp
= tempbx
& 0x00FF;
5099 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
) {
5100 if (pVBInfo
->VBType
& VB_XGI301LV
) {
5101 if (pVBInfo
->TVInfo
& SetYPbPrMode1080i
) {
5102 if (pVBInfo
->VBInfo
& SetInSlaveMode
) {
5108 if (pVBInfo
->VBInfo
& SetInSlaveMode
) {
5115 xgifb_reg_set(pVBInfo
->Part2Port
, 0x2F, temp
);
5117 temp
= (tempcx
& 0xFF00) >> 8;
5118 temp
|= ((tempbx
& 0xFF00) >> 8) << 6;
5120 if (!(pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
)) {
5121 if (pVBInfo
->VBType
& VB_XGI301LV
) {
5122 if (pVBInfo
->TVInfo
& SetYPbPrMode1080i
) {
5125 if (!(pVBInfo
->VBInfo
& SetCRT2ToSVIDEO
))
5130 if (!(pVBInfo
->VBInfo
& SetCRT2ToSVIDEO
))
5135 xgifb_reg_set(pVBInfo
->Part2Port
, 0x30, temp
);
5137 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
| VB_XGI301LV
5138 | VB_XGI302LV
| VB_XGI301C
)) { /* TV gatingno */
5139 tempbx
= pVBInfo
->VDE
;
5140 tempcx
= tempbx
- 2;
5142 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
5143 if (!(pVBInfo
->TVInfo
& (SetYPbPrMode525p
5144 | SetYPbPrMode750p
)))
5145 tempbx
= tempbx
>> 1;
5148 if (pVBInfo
->VBType
& (VB_XGI302LV
| VB_XGI301C
)) {
5150 if (tempcx
& 0x0400)
5153 if (tempbx
& 0x0400)
5156 xgifb_reg_set(pVBInfo
->Part4Port
, 0x10, temp
);
5159 temp
= (((tempbx
- 3) & 0x0300) >> 8) << 5;
5160 xgifb_reg_set(pVBInfo
->Part2Port
, 0x46, temp
);
5161 temp
= (tempbx
- 3) & 0x00FF;
5162 xgifb_reg_set(pVBInfo
->Part2Port
, 0x47, temp
);
5165 tempbx
= tempbx
& 0x00FF;
5167 if (!(modeflag
& HalfDCLK
)) {
5168 tempcx
= pVBInfo
->VGAHDE
;
5169 if (tempcx
>= pVBInfo
->HDE
) {
5177 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) { /*301b*/
5178 if (pVBInfo
->VGAHDE
>= 1024) {
5180 if (pVBInfo
->VGAHDE
>= 1280) {
5182 tempbx
= tempbx
& 0xDFFF;
5187 if (!(tempbx
& 0x2000)) {
5188 if (modeflag
& HalfDCLK
)
5189 tempcx
= (tempcx
& 0xFF00) | ((tempcx
& 0x00FF) << 1);
5192 tempeax
= pVBInfo
->VGAHDE
;
5193 tempebx
= (tempcx
& 0xFF00) >> 8;
5194 longtemp
= tempeax
* tempebx
;
5195 tempecx
= tempcx
& 0x00FF;
5196 longtemp
= longtemp
/ tempecx
;
5201 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
| VB_XGI301LV
5202 | VB_XGI302LV
| VB_XGI301C
)) {
5203 tempecx
= tempecx
* 8;
5206 longtemp
= longtemp
* tempecx
;
5207 tempecx
= pVBInfo
->HDE
;
5208 temp2
= longtemp
% tempecx
;
5209 tempeax
= longtemp
/ tempecx
;
5213 tempax
= (unsigned short) tempeax
;
5216 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
| VB_XGI301LV
5217 | VB_XGI302LV
| VB_XGI301C
)) {
5218 tempcx
= ((tempax
& 0xFF00) >> 5) >> 8;
5223 tempbx
= (unsigned short) (((tempeax
& 0x0000FF00) & 0x1F00)
5224 | (tempbx
& 0x00FF));
5225 tempax
= (unsigned short) (((tempeax
& 0x000000FF) << 8)
5226 | (tempax
& 0x00FF));
5227 temp
= (tempax
& 0xFF00) >> 8;
5229 temp
= (tempax
& 0x00FF) >> 8;
5232 xgifb_reg_set(pVBInfo
->Part2Port
, 0x44, temp
);
5233 temp
= (tempbx
& 0xFF00) >> 8;
5234 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x45, ~0x03F, temp
);
5235 temp
= tempcx
& 0x00FF;
5237 if (tempbx
& 0x2000)
5240 if (!(pVBInfo
->VBInfo
& SetCRT2ToLCD
))
5243 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x46, ~0x1F, temp
);
5244 if (pVBInfo
->TVInfo
& SetPALTV
) {
5252 temp
= tempbx
& 0x00FF;
5253 xgifb_reg_set(pVBInfo
->Part2Port
, 0x4b, temp
);
5254 temp
= tempcx
& 0x00FF;
5255 xgifb_reg_set(pVBInfo
->Part2Port
, 0x4c, temp
);
5257 temp
= ((tempcx
& 0xFF00) >> 8) & 0x03;
5259 temp
|= ((tempbx
& 0xFF00) >> 8) & 0x03;
5261 if (pVBInfo
->VBInfo
& SetCRT2ToYPbPr
) {
5264 if (pVBInfo
->TVInfo
& SetYPbPrMode525p
)
5267 if (pVBInfo
->TVInfo
& SetYPbPrMode750p
)
5271 xgifb_reg_set(pVBInfo
->Part2Port
, 0x4d, temp
);
5272 temp
= xgifb_reg_get(pVBInfo
->Part2Port
, 0x43); /* 301b change */
5273 xgifb_reg_set(pVBInfo
->Part2Port
, 0x43, (unsigned short) (temp
- 3));
5275 if (!(pVBInfo
->TVInfo
& (SetYPbPrMode525p
| SetYPbPrMode750p
))) {
5276 if (pVBInfo
->TVInfo
& NTSC1024x768
) {
5277 TimingPoint
= XGI_NTSC1024AdjTime
;
5278 for (i
= 0x1c, j
= 0; i
<= 0x30; i
++, j
++) {
5279 xgifb_reg_set(pVBInfo
->Part2Port
, i
,
5282 xgifb_reg_set(pVBInfo
->Part2Port
, 0x43, 0x72);
5286 /* [ycchen] 01/14/03 Modify for 301C PALM Support */
5287 if (pVBInfo
->VBType
& VB_XGI301C
) {
5288 if (pVBInfo
->TVInfo
& SetPALMTV
)
5289 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x4E, ~0x08,
5290 0x08); /* PALM Mode */
5293 if (pVBInfo
->TVInfo
& SetPALMTV
) {
5294 tempax
= (unsigned char) xgifb_reg_get(pVBInfo
->Part2Port
,
5297 xgifb_reg_and(pVBInfo
->Part2Port
, 0x01, tempax
);
5299 /* if ( !( pVBInfo->VBType & VB_XGI301C ) ) */
5300 xgifb_reg_and(pVBInfo
->Part2Port
, 0x00, 0xEF);
5303 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
) {
5304 if (!(pVBInfo
->VBInfo
& SetInSlaveMode
))
5305 xgifb_reg_set(pVBInfo
->Part2Port
, 0x0B, 0x00);
5308 if (pVBInfo
->VBInfo
& SetCRT2ToTV
)
5312 static void XGI_SetLCDRegs(unsigned short ModeNo
, unsigned short ModeIdIndex
,
5313 struct xgi_hw_device_info
*HwDeviceExtension
,
5314 unsigned short RefreshRateTableIndex
,
5315 struct vb_device_info
*pVBInfo
)
5317 unsigned short push1
, push2
, pushbx
, tempax
, tempbx
, tempcx
, temp
,
5318 tempah
, tempbh
, tempch
, resinfo
, modeflag
, CRT1Index
;
5320 struct XGI_LCDDesStruct
*LCDBDesPtr
= NULL
;
5322 if (ModeNo
<= 0x13) {
5324 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
5325 resinfo
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ResInfo
;
5327 /* si+Ext_ResInfo */
5328 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
5329 resinfo
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_RESINFO
;
5330 CRT1Index
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].
5332 CRT1Index
&= IndexMask
;
5335 if (!(pVBInfo
->VBInfo
& SetCRT2ToLCD
))
5338 tempbx
= pVBInfo
->HDE
; /* RHACTE=HDE-1 */
5340 if (XGI_IsLCDDualLink(pVBInfo
))
5341 tempbx
= tempbx
>> 1;
5344 temp
= tempbx
& 0x00FF;
5345 xgifb_reg_set(pVBInfo
->Part2Port
, 0x2C, temp
);
5346 temp
= (tempbx
& 0xFF00) >> 8;
5348 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x2B, 0x0F, temp
);
5351 if (pVBInfo
->LCDResInfo
== Panel1280x1024
) {
5352 if (pVBInfo
->ModeType
== ModeEGA
) {
5353 if (pVBInfo
->VGAHDE
>= 1024) {
5355 if (pVBInfo
->LCDInfo
& LCDVESATiming
)
5361 xgifb_reg_set(pVBInfo
->Part2Port
, 0x0B, temp
);
5362 tempbx
= pVBInfo
->VDE
; /* RTVACTEO=(VDE-1)&0xFF */
5365 temp
= tempbx
& 0x00FF;
5366 xgifb_reg_set(pVBInfo
->Part2Port
, 0x03, temp
);
5367 temp
= ((tempbx
& 0xFF00) >> 8) & 0x07;
5368 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x0C, ~0x07, temp
);
5370 tempcx
= pVBInfo
->VT
- 1;
5372 temp
= tempcx
& 0x00FF; /* RVTVT=VT-1 */
5373 xgifb_reg_set(pVBInfo
->Part2Port
, 0x19, temp
);
5374 temp
= (tempcx
& 0xFF00) >> 8;
5376 xgifb_reg_set(pVBInfo
->Part2Port
, 0x1A, temp
);
5377 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x09, 0xF0, 0x00);
5378 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x0A, 0xF0, 0x00);
5379 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x17, 0xFB, 0x00);
5380 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x18, 0xDF, 0x00);
5382 /* Customized LCDB Des no add */
5384 LCDBDesPtr
= (struct XGI_LCDDesStruct
*) XGI_GetLcdPtr(tempbx
, ModeNo
,
5385 ModeIdIndex
, RefreshRateTableIndex
, pVBInfo
);
5386 tempah
= pVBInfo
->LCDResInfo
;
5387 tempah
&= PanelResInfo
;
5389 if ((tempah
== Panel1024x768
) || (tempah
== Panel1024x768x75
)) {
5392 } else if ((tempah
== Panel1280x1024
) ||
5393 (tempah
== Panel1280x1024x75
)) {
5396 } else if (tempah
== Panel1400x1050
) {
5404 if (pVBInfo
->LCDInfo
& EnableScalingLCD
) {
5405 tempbx
= pVBInfo
->HDE
;
5406 tempcx
= pVBInfo
->VDE
;
5410 tempax
= pVBInfo
->VT
;
5411 pVBInfo
->LCDHDES
= LCDBDesPtr
->LCDHDES
;
5412 pVBInfo
->LCDHRS
= LCDBDesPtr
->LCDHRS
;
5413 pVBInfo
->LCDVDES
= LCDBDesPtr
->LCDVDES
;
5414 pVBInfo
->LCDVRS
= LCDBDesPtr
->LCDVRS
;
5415 tempbx
= pVBInfo
->LCDVDES
;
5418 if (tempcx
>= tempax
)
5419 tempcx
-= tempax
; /* lcdvdes */
5421 temp
= tempbx
& 0x00FF; /* RVEQ1EQ=lcdvdes */
5422 xgifb_reg_set(pVBInfo
->Part2Port
, 0x05, temp
);
5423 temp
= tempcx
& 0x00FF;
5424 xgifb_reg_set(pVBInfo
->Part2Port
, 0x06, temp
);
5425 tempch
= ((tempcx
& 0xFF00) >> 8) & 0x07;
5426 tempbh
= ((tempbx
& 0xFF00) >> 8) & 0x07;
5428 tempah
= tempah
<< 3;
5430 xgifb_reg_set(pVBInfo
->Part2Port
, 0x02, tempah
);
5433 XGI_GetLCDSync(&tempax
, &tempbx
, pVBInfo
);
5435 tempax
= pVBInfo
->VT
;
5436 tempbx
= pVBInfo
->LCDVRS
;
5438 /* if (SetLCD_Info & EnableScalingLCD) */
5440 if (tempcx
>= tempax
)
5443 temp
= tempbx
& 0x00FF; /* RTVACTEE=lcdvrs */
5444 xgifb_reg_set(pVBInfo
->Part2Port
, 0x04, temp
);
5445 temp
= (tempbx
& 0xFF00) >> 8;
5447 temp
|= (tempcx
& 0x000F);
5448 xgifb_reg_set(pVBInfo
->Part2Port
, 0x01, temp
);
5450 tempax
= pVBInfo
->HT
;
5451 tempbx
= pVBInfo
->LCDHDES
;
5454 if (XGI_IsLCDDualLink(pVBInfo
)) {
5455 tempax
= tempax
>> 1;
5456 tempbx
= tempbx
>> 1;
5457 tempcx
= tempcx
>> 1;
5460 if (pVBInfo
->VBType
& VB_XGI302LV
)
5463 if (pVBInfo
->VBType
& VB_XGI301C
) /* tap4 */
5468 if (tempcx
>= tempax
)
5471 temp
= tempbx
& 0x00FF;
5472 xgifb_reg_set(pVBInfo
->Part2Port
, 0x1F, temp
); /* RHBLKE=lcdhdes */
5473 temp
= ((tempbx
& 0xFF00) >> 8) << 4;
5474 xgifb_reg_set(pVBInfo
->Part2Port
, 0x20, temp
);
5475 temp
= tempcx
& 0x00FF;
5476 xgifb_reg_set(pVBInfo
->Part2Port
, 0x23, temp
); /* RHEQPLE=lcdhdee */
5477 temp
= (tempcx
& 0xFF00) >> 8;
5478 xgifb_reg_set(pVBInfo
->Part2Port
, 0x25, temp
);
5481 XGI_GetLCDSync(&tempax
, &tempbx
, pVBInfo
);
5483 tempax
= pVBInfo
->HT
;
5484 tempbx
= pVBInfo
->LCDHRS
;
5485 /* if ( SetLCD_Info & EnableScalingLCD) */
5486 if (XGI_IsLCDDualLink(pVBInfo
)) {
5487 tempax
= tempax
>> 1;
5488 tempbx
= tempbx
>> 1;
5489 tempcx
= tempcx
>> 1;
5492 if (pVBInfo
->VBType
& VB_XGI302LV
)
5497 if (tempcx
>= tempax
)
5500 temp
= tempbx
& 0x00FF; /* RHBURSTS=lcdhrs */
5501 xgifb_reg_set(pVBInfo
->Part2Port
, 0x1C, temp
);
5503 temp
= (tempbx
& 0xFF00) >> 8;
5505 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x1D, ~0x0F0, temp
);
5506 temp
= tempcx
& 0x00FF; /* RHSYEXP2S=lcdhre */
5507 xgifb_reg_set(pVBInfo
->Part2Port
, 0x21, temp
);
5509 if (!(pVBInfo
->LCDInfo
& LCDVESATiming
)) {
5510 if (pVBInfo
->VGAVDE
== 525) {
5511 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
5512 | VB_XGI301LV
| VB_XGI302LV
5518 xgifb_reg_set(pVBInfo
->Part2Port
, 0x2f, temp
);
5519 xgifb_reg_set(pVBInfo
->Part2Port
, 0x30, 0xB3);
5522 if (pVBInfo
->VGAVDE
== 420) {
5523 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
5524 | VB_XGI301LV
| VB_XGI302LV
5529 xgifb_reg_set(pVBInfo
->Part2Port
, 0x2f, temp
);
5534 /* --------------------------------------------------------------------- */
5535 /* Function : XGI_GetTap4Ptr */
5537 /* Output : di -> Tap4 Reg. Setting Pointer */
5539 /* --------------------------------------------------------------------- */
5540 static struct XGI301C_Tap4TimingStruct
*XGI_GetTap4Ptr(unsigned short tempcx
,
5541 struct vb_device_info
*pVBInfo
)
5543 unsigned short tempax
, tempbx
, i
;
5545 struct XGI301C_Tap4TimingStruct
*Tap4TimingPtr
;
5548 tempax
= pVBInfo
->VGAHDE
;
5549 tempbx
= pVBInfo
->HDE
;
5551 tempax
= pVBInfo
->VGAVDE
;
5552 tempbx
= pVBInfo
->VDE
;
5555 if (tempax
<= tempbx
)
5556 return &xgifb_tap4_timing
[0];
5558 Tap4TimingPtr
= xgifb_ntsc_525_tap4_timing
; /* NTSC */
5560 if (pVBInfo
->TVInfo
& SetPALTV
)
5561 Tap4TimingPtr
= PALTap4Timing
;
5563 if (pVBInfo
->VBInfo
& SetCRT2ToYPbPr
) {
5564 if ((pVBInfo
->TVInfo
& SetYPbPrMode525i
) ||
5565 (pVBInfo
->TVInfo
& SetYPbPrMode525p
))
5566 Tap4TimingPtr
= xgifb_ntsc_525_tap4_timing
;
5567 if (pVBInfo
->TVInfo
& SetYPbPrMode750p
)
5568 Tap4TimingPtr
= YPbPr750pTap4Timing
;
5571 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
)
5572 Tap4TimingPtr
= xgifb_tap4_timing
;
5575 while (Tap4TimingPtr
[i
].DE
!= 0xFFFF) {
5576 if (Tap4TimingPtr
[i
].DE
== tempax
)
5580 return &Tap4TimingPtr
[i
];
5583 static void XGI_SetTap4Regs(struct vb_device_info
*pVBInfo
)
5585 unsigned short i
, j
;
5587 struct XGI301C_Tap4TimingStruct
*Tap4TimingPtr
;
5589 if (!(pVBInfo
->VBType
& VB_XGI301C
))
5592 Tap4TimingPtr
= XGI_GetTap4Ptr(0, pVBInfo
); /* Set Horizontal Scaling */
5593 for (i
= 0x80, j
= 0; i
<= 0xBF; i
++, j
++)
5594 xgifb_reg_set(pVBInfo
->Part2Port
, i
, Tap4TimingPtr
->Reg
[j
]);
5596 if ((pVBInfo
->VBInfo
& SetCRT2ToTV
) &&
5597 (!(pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
))) {
5598 /* Set Vertical Scaling */
5599 Tap4TimingPtr
= XGI_GetTap4Ptr(1, pVBInfo
);
5600 for (i
= 0xC0, j
= 0; i
< 0xFF; i
++, j
++)
5601 xgifb_reg_set(pVBInfo
->Part2Port
,
5603 Tap4TimingPtr
->Reg
[j
]);
5606 if ((pVBInfo
->VBInfo
& SetCRT2ToTV
) &&
5607 (!(pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
)))
5608 /* Enable V.Scaling */
5609 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x4E, ~0x14, 0x04);
5611 /* Enable H.Scaling */
5612 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x4E, ~0x14, 0x10);
5615 static void XGI_SetGroup3(unsigned short ModeNo
, unsigned short ModeIdIndex
,
5616 struct vb_device_info
*pVBInfo
)
5619 unsigned char *tempdi
;
5620 unsigned short modeflag
;
5624 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
5626 /* si+Ext_ResInfo */
5627 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
5629 xgifb_reg_set(pVBInfo
->Part3Port
, 0x00, 0x00);
5630 if (pVBInfo
->TVInfo
& SetPALTV
) {
5631 xgifb_reg_set(pVBInfo
->Part3Port
, 0x13, 0xFA);
5632 xgifb_reg_set(pVBInfo
->Part3Port
, 0x14, 0xC8);
5634 xgifb_reg_set(pVBInfo
->Part3Port
, 0x13, 0xF5);
5635 xgifb_reg_set(pVBInfo
->Part3Port
, 0x14, 0xB7);
5638 if (!(pVBInfo
->VBInfo
& SetCRT2ToTV
))
5641 if (pVBInfo
->TVInfo
& SetPALMTV
) {
5642 xgifb_reg_set(pVBInfo
->Part3Port
, 0x13, 0xFA);
5643 xgifb_reg_set(pVBInfo
->Part3Port
, 0x14, 0xC8);
5644 xgifb_reg_set(pVBInfo
->Part3Port
, 0x3D, 0xA8);
5647 if ((pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
) || (pVBInfo
->VBInfo
5648 & SetCRT2ToYPbPr
)) {
5649 if (pVBInfo
->TVInfo
& SetYPbPrMode525i
)
5652 tempdi
= pVBInfo
->HiTVGroup3Data
;
5653 if (pVBInfo
->SetFlag
& TVSimuMode
) {
5654 tempdi
= pVBInfo
->HiTVGroup3Simu
;
5655 if (!(modeflag
& Charx8Dot
))
5656 tempdi
= pVBInfo
->HiTVGroup3Text
;
5659 if (pVBInfo
->TVInfo
& SetYPbPrMode525p
)
5660 tempdi
= pVBInfo
->Ren525pGroup3
;
5662 if (pVBInfo
->TVInfo
& SetYPbPrMode750p
)
5663 tempdi
= pVBInfo
->Ren750pGroup3
;
5665 for (i
= 0; i
<= 0x3E; i
++)
5666 xgifb_reg_set(pVBInfo
->Part3Port
, i
, tempdi
[i
]);
5668 if (pVBInfo
->VBType
& VB_XGI301C
) { /* Marcovision */
5669 if (pVBInfo
->TVInfo
& SetYPbPrMode525p
)
5670 xgifb_reg_set(pVBInfo
->Part3Port
, 0x28, 0x3f);
5674 } /* {end of XGI_SetGroup3} */
5676 static void XGI_SetGroup4(unsigned short ModeNo
, unsigned short ModeIdIndex
,
5677 unsigned short RefreshRateTableIndex
,
5678 struct xgi_hw_device_info
*HwDeviceExtension
,
5679 struct vb_device_info
*pVBInfo
)
5681 unsigned short tempax
, tempcx
, tempbx
, modeflag
, temp
, temp2
;
5683 unsigned long tempebx
, tempeax
, templong
;
5687 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
5689 /* si+Ext_ResInfo */
5690 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
5692 temp
= pVBInfo
->RVBHCFACT
;
5693 xgifb_reg_set(pVBInfo
->Part4Port
, 0x13, temp
);
5695 tempbx
= pVBInfo
->RVBHCMAX
;
5696 temp
= tempbx
& 0x00FF;
5697 xgifb_reg_set(pVBInfo
->Part4Port
, 0x14, temp
);
5698 temp2
= ((tempbx
& 0xFF00) >> 8) << 7;
5699 tempcx
= pVBInfo
->VGAHT
- 1;
5700 temp
= tempcx
& 0x00FF;
5701 xgifb_reg_set(pVBInfo
->Part4Port
, 0x16, temp
);
5703 temp
= ((tempcx
& 0xFF00) >> 8) << 3;
5706 tempcx
= pVBInfo
->VGAVT
- 1;
5707 if (!(pVBInfo
->VBInfo
& SetCRT2ToTV
))
5710 temp
= tempcx
& 0x00FF;
5711 xgifb_reg_set(pVBInfo
->Part4Port
, 0x17, temp
);
5712 temp
= temp2
| ((tempcx
& 0xFF00) >> 8);
5713 xgifb_reg_set(pVBInfo
->Part4Port
, 0x15, temp
);
5714 xgifb_reg_or(pVBInfo
->Part4Port
, 0x0D, 0x08);
5715 tempcx
= pVBInfo
->VBInfo
;
5716 tempbx
= pVBInfo
->VGAHDE
;
5718 if (modeflag
& HalfDCLK
)
5719 tempbx
= tempbx
>> 1;
5721 if (XGI_IsLCDDualLink(pVBInfo
))
5722 tempbx
= tempbx
>> 1;
5724 if (tempcx
& SetCRT2ToHiVisionTV
) {
5730 } else if (tempcx
& SetCRT2ToTV
) {
5736 if (pVBInfo
->VBInfo
& SetCRT2ToLCD
) {
5743 if (pVBInfo
->TVInfo
& (SetYPbPrMode525p
| SetYPbPrMode750p
)) {
5745 if (pVBInfo
->VGAHDE
== 1280)
5747 if (pVBInfo
->VGAHDE
== 1024)
5750 xgifb_reg_and_or(pVBInfo
->Part4Port
, 0x0E, ~0xEF, temp
);
5752 tempebx
= pVBInfo
->VDE
;
5754 if (tempcx
& SetCRT2ToHiVisionTV
) {
5755 if (!(temp
& 0xE000))
5756 tempbx
= tempbx
>> 1;
5759 tempcx
= pVBInfo
->RVBHRS
;
5760 temp
= tempcx
& 0x00FF;
5761 xgifb_reg_set(pVBInfo
->Part4Port
, 0x18, temp
);
5763 tempeax
= pVBInfo
->VGAVDE
;
5766 if (tempeax
<= tempebx
) {
5767 tempcx
= (tempcx
& (~0x4000));
5768 tempeax
= pVBInfo
->VGAVDE
;
5773 templong
= (tempeax
* 256 * 1024) % tempebx
;
5774 tempeax
= (tempeax
* 256 * 1024) / tempebx
;
5780 temp
= (unsigned short) (tempebx
& 0x000000FF);
5781 xgifb_reg_set(pVBInfo
->Part4Port
, 0x1B, temp
);
5783 temp
= (unsigned short) ((tempebx
& 0x0000FF00) >> 8);
5784 xgifb_reg_set(pVBInfo
->Part4Port
, 0x1A, temp
);
5785 tempbx
= (unsigned short) (tempebx
>> 16);
5786 temp
= tempbx
& 0x00FF;
5788 temp
|= ((tempcx
& 0xFF00) >> 8);
5789 xgifb_reg_set(pVBInfo
->Part4Port
, 0x19, temp
);
5792 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
| VB_XGI301LV
5793 | VB_XGI302LV
| VB_XGI301C
)) {
5795 xgifb_reg_set(pVBInfo
->Part4Port
, 0x1C, temp
);
5796 tempax
= pVBInfo
->VGAHDE
;
5797 if (modeflag
& HalfDCLK
)
5798 tempax
= tempax
>> 1;
5800 if (XGI_IsLCDDualLink(pVBInfo
))
5801 tempax
= tempax
>> 1;
5803 /* if((pVBInfo->VBInfo&(SetCRT2ToLCD)) ||
5804 ((pVBInfo->TVInfo&SetYPbPrMode525p) ||
5805 (pVBInfo->TVInfo&SetYPbPrMode750p))) { */
5806 if (pVBInfo
->VBInfo
& SetCRT2ToLCD
) {
5810 if (pVBInfo
->VGAHDE
> 800) {
5811 if (pVBInfo
->VGAHDE
== 1024)
5812 tempax
= (tempax
* 25 / 32) - 1;
5814 tempax
= (tempax
* 20 / 32) - 1;
5820 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVisionTV)) {
5821 if (pVBInfo->VBType & VB_XGI301LV) {
5822 if (!(pVBInfo->TVInfo &
5825 SetYPbPrMode1080i))) {
5826 if (pVBInfo->VGAHDE > 800) {
5827 if (pVBInfo->VGAHDE == 1024)
5828 tempax =(tempax * 25 /
5831 tempax = (tempax * 20 /
5836 if (pVBInfo->VGAHDE > 800) {
5837 if (pVBInfo->VGAHDE == 1024)
5838 tempax = (tempax * 25 / 32) - 1;
5840 tempax = (tempax * 20 / 32) - 1;
5846 temp
= (tempax
& 0xFF00) >> 8;
5847 temp
= ((temp
& 0x0003) << 4);
5848 xgifb_reg_set(pVBInfo
->Part4Port
, 0x1E, temp
);
5849 temp
= (tempax
& 0x00FF);
5850 xgifb_reg_set(pVBInfo
->Part4Port
, 0x1D, temp
);
5852 if (pVBInfo
->VBInfo
& (SetCRT2ToTV
| SetCRT2ToHiVisionTV
)) {
5853 if (pVBInfo
->VGAHDE
> 800)
5854 xgifb_reg_or(pVBInfo
->Part4Port
, 0x1E, 0x08);
5859 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
5860 if (!(pVBInfo
->TVInfo
& (NTSC1024x768
5861 | SetYPbPrMode525p
| SetYPbPrMode750p
5862 | SetYPbPrMode1080i
))) {
5864 if ((pVBInfo
->VBInfo
& SetInSlaveMode
)
5865 && (!(pVBInfo
->TVInfo
5871 xgifb_reg_and_or(pVBInfo
->Part4Port
, 0x1F, 0x00C0, temp
);
5872 tempbx
= pVBInfo
->HT
;
5873 if (XGI_IsLCDDualLink(pVBInfo
))
5874 tempbx
= tempbx
>> 1;
5875 tempbx
= (tempbx
>> 1) - 2;
5876 temp
= ((tempbx
& 0x0700) >> 8) << 3;
5877 xgifb_reg_and_or(pVBInfo
->Part4Port
, 0x21, 0x00C0, temp
);
5878 temp
= tempbx
& 0x00FF;
5879 xgifb_reg_set(pVBInfo
->Part4Port
, 0x22, temp
);
5883 if (pVBInfo
->ISXPDOS
== 0)
5884 XGI_SetCRT2VCLK(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
5888 static void XGINew_EnableCRT2(struct vb_device_info
*pVBInfo
)
5890 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x1E, 0xFF, 0x20);
5893 static void XGI_SetGroup5(unsigned short ModeNo
, unsigned short ModeIdIndex
,
5894 struct vb_device_info
*pVBInfo
)
5896 unsigned short Pindex
, Pdata
;
5898 Pindex
= pVBInfo
->Part5Port
;
5899 Pdata
= pVBInfo
->Part5Port
+ 1;
5900 if (pVBInfo
->ModeType
== ModeVGA
) {
5901 if (!(pVBInfo
->VBInfo
& (SetInSlaveMode
| LoadDACFlag
5902 | CRT2DisplayFlag
))) {
5903 XGINew_EnableCRT2(pVBInfo
);
5904 /* LoadDAC2(pVBInfo->Part5Port, ModeNo, ModeIdIndex); */
5910 static void XGI_EnableGatingCRT(struct xgi_hw_device_info
*HwDeviceExtension
,
5911 struct vb_device_info
*pVBInfo
)
5913 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x63, 0xBF, 0x40);
5916 static void XGI_DisableGatingCRT(struct xgi_hw_device_info
*HwDeviceExtension
,
5917 struct vb_device_info
*pVBInfo
)
5920 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x63, 0xBF, 0x00);
5923 /*----------------------------------------------------------------------------*/
5925 /* bl[5] : 1;LVDS signal on */
5926 /* bl[1] : 1;LVDS backlight on */
5927 /* bl[0] : 1:LVDS VDD on */
5928 /* bh: 100000b : clear bit 5, to set bit5 */
5929 /* 000010b : clear bit 1, to set bit1 */
5930 /* 000001b : clear bit 0, to set bit0 */
5931 /*----------------------------------------------------------------------------*/
5932 void XGI_XG21BLSignalVDD(unsigned short tempbh
, unsigned short tempbl
,
5933 struct vb_device_info
*pVBInfo
)
5935 unsigned char CR4A
, temp
;
5937 CR4A
= xgifb_reg_get(pVBInfo
->P3d4
, 0x4A);
5940 xgifb_reg_and(pVBInfo
->P3d4
, 0x4A, ~tempbh
); /* enable GPIO write */
5942 if (tempbh
& 0x20) {
5943 temp
= (tempbl
>> 4) & 0x02;
5946 xgifb_reg_and_or(pVBInfo
->P3d4
, 0xB4, ~0x02, temp
);
5950 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x48);
5952 temp
= XG21GPIODataTransfer(temp
);
5955 xgifb_reg_set(pVBInfo
->P3d4
, 0x48, temp
);
5958 void XGI_XG27BLSignalVDD(unsigned short tempbh
, unsigned short tempbl
,
5959 struct vb_device_info
*pVBInfo
)
5961 unsigned char CR4A
, temp
;
5962 unsigned short tempbh0
, tempbl0
;
5971 if (tempbh
& 0x20) {
5972 temp
= (tempbl
>> 4) & 0x02;
5975 xgifb_reg_and_or(pVBInfo
->P3d4
, 0xB4, ~0x02, temp
);
5978 xgifb_reg_and_or(pVBInfo
->P3d4
, 0xB4, ~tempbh0
, tempbl0
);
5980 CR4A
= xgifb_reg_get(pVBInfo
->P3d4
, 0x4A);
5984 tempbl
<<= 2; /* GPIOC,GPIOD */
5985 xgifb_reg_and(pVBInfo
->P3d4
, 0x4A, ~tempbh
); /* enable GPIO write */
5986 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x48, ~tempbh
, tempbl
);
5989 /* --------------------------------------------------------------------- */
5990 unsigned short XGI_GetLVDSOEMTableIndex(struct vb_device_info
*pVBInfo
)
5992 unsigned short index
;
5994 index
= xgifb_reg_get(pVBInfo
->P3d4
, 0x36);
5995 if (index
< sizeof(XGI21_LCDCapList
)
5996 / sizeof(struct XGI21_LVDSCapStruct
))
6001 /* --------------------------------------------------------------------- */
6002 /* Function : XGI_XG21SetPanelDelay */
6006 /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
6007 /* : bl : 2 ; T2 : the duration signal on and Vdd on */
6008 /* : bl : 3 ; T3 : the duration between CPL off and signal off */
6009 /* : bl : 4 ; T4 : the duration signal off and Vdd off */
6010 /* --------------------------------------------------------------------- */
6011 void XGI_XG21SetPanelDelay(unsigned short tempbl
,
6012 struct vb_device_info
*pVBInfo
)
6014 unsigned short index
;
6016 index
= XGI_GetLVDSOEMTableIndex(pVBInfo
);
6018 mdelay(pVBInfo
->XG21_LVDSCapList
[index
].PSC_S1
);
6021 mdelay(pVBInfo
->XG21_LVDSCapList
[index
].PSC_S2
);
6024 mdelay(pVBInfo
->XG21_LVDSCapList
[index
].PSC_S3
);
6027 mdelay(pVBInfo
->XG21_LVDSCapList
[index
].PSC_S4
);
6030 unsigned char XGI_XG21CheckLVDSMode(unsigned short ModeNo
,
6031 unsigned short ModeIdIndex
, struct vb_device_info
*pVBInfo
)
6033 unsigned short xres
, yres
, colordepth
, modeflag
, resindex
,
6036 resindex
= XGI_GetResInfo(ModeNo
, ModeIdIndex
, pVBInfo
);
6037 if (ModeNo
<= 0x13) {
6038 xres
= pVBInfo
->StResInfo
[resindex
].HTotal
;
6039 yres
= pVBInfo
->StResInfo
[resindex
].VTotal
;
6041 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
6043 xres
= pVBInfo
->ModeResInfo
[resindex
].HTotal
; /* xres->ax */
6044 yres
= pVBInfo
->ModeResInfo
[resindex
].VTotal
; /* yres->bx */
6045 /* si+St_ModeFlag */
6046 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
6049 if (!(modeflag
& Charx8Dot
)) {
6054 if (ModeNo
> 0x13) {
6055 if ((ModeNo
> 0x13) && (modeflag
& HalfDCLK
))
6058 if ((ModeNo
> 0x13) && (modeflag
& DoubleScanMode
))
6063 lvdstableindex
= XGI_GetLVDSOEMTableIndex(pVBInfo
);
6064 if (xres
> (pVBInfo
->XG21_LVDSCapList
[lvdstableindex
].LVDSHDE
))
6067 if (yres
> (pVBInfo
->XG21_LVDSCapList
[lvdstableindex
].LVDSVDE
))
6070 if (ModeNo
> 0x13) {
6071 if ((xres
!= (pVBInfo
->XG21_LVDSCapList
[lvdstableindex
].
6073 (yres
!= (pVBInfo
->XG21_LVDSCapList
[lvdstableindex
].
6075 colordepth
= XGI_GetColorDepth(ModeNo
,
6086 void XGI_SetXG21FPBits(struct vb_device_info
*pVBInfo
)
6090 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x37); /* D[0] 1: 18bit */
6091 temp
= (temp
& 1) << 6;
6092 /* SR06[6] 18bit Dither */
6093 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x06, ~0x40, temp
);
6094 /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */
6095 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x09, ~0xc0, temp
| 0x80);
6099 void XGI_SetXG27FPBits(struct vb_device_info
*pVBInfo
)
6103 /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */
6104 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x37);
6105 temp
= (temp
& 3) << 6;
6106 /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */
6107 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x06, ~0xc0, temp
& 0x80);
6108 /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */
6109 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x09, ~0xc0, temp
| 0x80);
6113 static void xgifb_set_lvds(int chip_id
,
6114 unsigned short ModeNo
,
6115 unsigned short ModeIdIndex
,
6116 struct vb_device_info
*pVBInfo
)
6118 unsigned char temp
, Miscdata
;
6119 unsigned short xres
, yres
, modeflag
, resindex
, lvdstableindex
;
6120 unsigned short LVDSHT
, LVDSHBS
, LVDSHRS
, LVDSHRE
, LVDSHBE
;
6121 unsigned short LVDSVT
, LVDSVBS
, LVDSVRS
, LVDSVRE
, LVDSVBE
;
6122 unsigned short value
;
6124 lvdstableindex
= XGI_GetLVDSOEMTableIndex(pVBInfo
);
6125 temp
= (unsigned char) ((pVBInfo
->XG21_LVDSCapList
[lvdstableindex
].
6127 (LCDPolarity
<< 8)) >> 8);
6128 temp
&= LCDPolarity
;
6129 Miscdata
= (unsigned char) inb(pVBInfo
->P3cc
);
6131 outb((Miscdata
& 0x3F) | temp
, pVBInfo
->P3c2
);
6133 temp
= (unsigned char) (pVBInfo
->XG21_LVDSCapList
[lvdstableindex
].
6134 LVDS_Capability
& LCDPolarity
);
6135 /* SR35[7] FP VSync polarity */
6136 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x35, ~0x80, temp
& 0x80);
6137 /* SR30[5] FP HSync polarity */
6138 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x30, ~0x20, (temp
& 0x40) >> 1);
6140 if (chip_id
== XG27
)
6141 XGI_SetXG27FPBits(pVBInfo
);
6143 XGI_SetXG21FPBits(pVBInfo
);
6145 resindex
= XGI_GetResInfo(ModeNo
, ModeIdIndex
, pVBInfo
);
6146 if (ModeNo
<= 0x13) {
6147 xres
= pVBInfo
->StResInfo
[resindex
].HTotal
;
6148 yres
= pVBInfo
->StResInfo
[resindex
].VTotal
;
6150 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
6152 xres
= pVBInfo
->ModeResInfo
[resindex
].HTotal
; /* xres->ax */
6153 yres
= pVBInfo
->ModeResInfo
[resindex
].VTotal
; /* yres->bx */
6154 /* si+St_ModeFlag */
6155 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
6158 if (!(modeflag
& Charx8Dot
))
6159 xres
= xres
* 8 / 9;
6161 LVDSHT
= pVBInfo
->XG21_LVDSCapList
[lvdstableindex
].LVDSHT
;
6163 LVDSHBS
= xres
+ (pVBInfo
->XG21_LVDSCapList
[lvdstableindex
].LVDSHDE
6165 if ((ModeNo
<= 0x13) && (modeflag
& HalfDCLK
))
6166 LVDSHBS
-= xres
/ 4;
6168 if (LVDSHBS
> LVDSHT
)
6171 LVDSHRS
= LVDSHBS
+ pVBInfo
->XG21_LVDSCapList
[lvdstableindex
].LVDSHFP
;
6172 if (LVDSHRS
> LVDSHT
)
6175 LVDSHRE
= LVDSHRS
+ pVBInfo
->XG21_LVDSCapList
[lvdstableindex
].LVDSHSYNC
;
6176 if (LVDSHRE
> LVDSHT
)
6179 LVDSHBE
= LVDSHBS
+ LVDSHT
6180 - pVBInfo
->XG21_LVDSCapList
[lvdstableindex
].LVDSHDE
;
6182 LVDSVT
= pVBInfo
->XG21_LVDSCapList
[lvdstableindex
].LVDSVT
;
6184 LVDSVBS
= yres
+ (pVBInfo
->XG21_LVDSCapList
[lvdstableindex
].LVDSVDE
6186 if ((ModeNo
> 0x13) && (modeflag
& DoubleScanMode
))
6187 LVDSVBS
+= yres
/ 2;
6189 if (LVDSVBS
> LVDSVT
)
6192 LVDSVRS
= LVDSVBS
+ pVBInfo
->XG21_LVDSCapList
[lvdstableindex
].LVDSVFP
;
6193 if (LVDSVRS
> LVDSVT
)
6196 LVDSVRE
= LVDSVRS
+ pVBInfo
->XG21_LVDSCapList
[lvdstableindex
].
6198 if (LVDSVRE
> LVDSVT
)
6201 LVDSVBE
= LVDSVBS
+ LVDSVT
6202 - pVBInfo
->XG21_LVDSCapList
[lvdstableindex
].LVDSVDE
;
6204 temp
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x11);
6205 xgifb_reg_set(pVBInfo
->P3d4
, 0x11, temp
& 0x7f); /* Unlock CRTC */
6207 if (!(modeflag
& Charx8Dot
))
6208 xgifb_reg_or(pVBInfo
->P3c4
, 0x1, 0x1);
6210 /* HT SR0B[1:0] CR00 */
6211 value
= (LVDSHT
>> 3) - 5;
6212 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0B, ~0x03, (value
& 0x300) >> 8);
6213 xgifb_reg_set(pVBInfo
->P3d4
, 0x0, (value
& 0xFF));
6215 /* HBS SR0B[5:4] CR02 */
6216 value
= (LVDSHBS
>> 3) - 1;
6217 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0B, ~0x30, (value
& 0x300) >> 4);
6218 xgifb_reg_set(pVBInfo
->P3d4
, 0x2, (value
& 0xFF));
6220 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
6221 value
= (LVDSHBE
>> 3) - 1;
6222 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0C, ~0x03, (value
& 0xC0) >> 6);
6223 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x05, ~0x80, (value
& 0x20) << 2);
6224 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x03, ~0x1F, value
& 0x1F);
6226 /* HRS SR0B[7:6] CR04 */
6227 value
= (LVDSHRS
>> 3) + 2;
6228 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0B, ~0xC0, (value
& 0x300) >> 2);
6229 xgifb_reg_set(pVBInfo
->P3d4
, 0x4, (value
& 0xFF));
6231 /* Panel HRS SR2F[1:0] SR2E[7:0] */
6233 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x2F, ~0x03, (value
& 0x300) >> 8);
6234 xgifb_reg_set(pVBInfo
->P3c4
, 0x2E, (value
& 0xFF));
6236 /* HRE SR0C[2] CR05[4:0] */
6237 value
= (LVDSHRE
>> 3) + 2;
6238 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0C, ~0x04, (value
& 0x20) >> 3);
6239 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x05, ~0x1F, value
& 0x1F);
6241 /* Panel HRE SR2F[7:2] */
6243 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x2F, ~0xFC, value
<< 2);
6245 /* VT SR0A[0] CR07[5][0] CR06 */
6247 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0A, ~0x01, (value
& 0x400) >> 10);
6248 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x07, ~0x20, (value
& 0x200) >> 4);
6249 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x07, ~0x01, (value
& 0x100) >> 8);
6250 xgifb_reg_set(pVBInfo
->P3d4
, 0x06, (value
& 0xFF));
6252 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
6253 value
= LVDSVBS
- 1;
6254 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0A, ~0x04, (value
& 0x400) >> 8);
6255 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x09, ~0x20, (value
& 0x200) >> 4);
6256 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x07, ~0x08, (value
& 0x100) >> 5);
6257 xgifb_reg_set(pVBInfo
->P3d4
, 0x15, (value
& 0xFF));
6259 /* VBE SR0A[4] CR16 */
6260 value
= LVDSVBE
- 1;
6261 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0A, ~0x10, (value
& 0x100) >> 4);
6262 xgifb_reg_set(pVBInfo
->P3d4
, 0x16, (value
& 0xFF));
6264 /* VRS SR0A[3] CR7[7][2] CR10 */
6265 value
= LVDSVRS
- 1;
6266 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0A, ~0x08, (value
& 0x400) >> 7);
6267 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x07, ~0x80, (value
& 0x200) >> 2);
6268 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x07, ~0x04, (value
& 0x100) >> 6);
6269 xgifb_reg_set(pVBInfo
->P3d4
, 0x10, (value
& 0xFF));
6271 if (chip_id
== XG27
) {
6272 /* Panel VRS SR35[2:0] SR34[7:0] */
6273 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x35, ~0x07,
6274 (value
& 0x700) >> 8);
6275 xgifb_reg_set(pVBInfo
->P3c4
, 0x34, value
& 0xFF);
6277 /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */
6278 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x3F, ~0x03,
6279 (value
& 0x600) >> 9);
6280 xgifb_reg_set(pVBInfo
->P3c4
, 0x34, (value
>> 1) & 0xFF);
6281 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x33, ~0x01, value
& 0x01);
6284 /* VRE SR0A[5] CR11[3:0] */
6285 value
= LVDSVRE
- 1;
6286 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x0A, ~0x20, (value
& 0x10) << 1);
6287 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x11, ~0x0F, value
& 0x0F);
6289 /* Panel VRE SR3F[7:2] */
6290 if (chip_id
== XG27
)
6291 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x3F, ~0xFC,
6292 (value
<< 2) & 0xFC);
6294 /* SR3F[7] has to be 0, h/w bug */
6295 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x3F, ~0xFC,
6296 (value
<< 2) & 0x7C);
6298 for (temp
= 0, value
= 0; temp
< 3; temp
++) {
6300 xgifb_reg_and_or(pVBInfo
->P3c4
, 0x31, ~0x30, value
);
6301 xgifb_reg_set(pVBInfo
->P3c4
,
6303 pVBInfo
->XG21_LVDSCapList
[lvdstableindex
].
6305 xgifb_reg_set(pVBInfo
->P3c4
,
6307 pVBInfo
->XG21_LVDSCapList
[lvdstableindex
].
6312 if (!(modeflag
& Charx8Dot
)) {
6313 inb(pVBInfo
->P3da
); /* reset 3da */
6314 outb(0x13, pVBInfo
->P3c0
); /* set index */
6315 /* set data, panning = 0, shift left 1 dot*/
6316 outb(0x00, pVBInfo
->P3c0
);
6318 inb(pVBInfo
->P3da
); /* Enable Attribute */
6319 outb(0x20, pVBInfo
->P3c0
);
6321 inb(pVBInfo
->P3da
); /* reset 3da */
6326 /* --------------------------------------------------------------------- */
6327 /* Function : XGI_IsLCDON */
6329 /* Output : 0 : Skip PSC Control */
6330 /* 1: Disable PSC */
6332 /* --------------------------------------------------------------------- */
6333 static unsigned char XGI_IsLCDON(struct vb_device_info
*pVBInfo
)
6335 unsigned short tempax
;
6337 tempax
= pVBInfo
->VBInfo
;
6338 if (tempax
& SetCRT2ToDualEdge
)
6340 else if (tempax
& (DisableCRT2Display
| SwitchToCRT2
| SetSimuScanMode
))
6346 /* --------------------------------------------------------------------- */
6347 /* Function : XGI_DisableChISLCD */
6349 /* Output : 0 -> Not LCD Mode */
6351 /* --------------------------------------------------------------------- */
6352 static unsigned char XGI_DisableChISLCD(struct vb_device_info
*pVBInfo
)
6354 unsigned short tempbx
, tempah
;
6356 tempbx
= pVBInfo
->SetFlag
& (DisableChA
| DisableChB
);
6357 tempah
= ~((unsigned short) xgifb_reg_get(pVBInfo
->Part1Port
, 0x2E));
6359 if (tempbx
& (EnableChA
| DisableChA
)) {
6360 if (!(tempah
& 0x08)) /* Chk LCDA Mode */
6364 if (!(tempbx
& (EnableChB
| DisableChB
)))
6367 if (tempah
& 0x01) /* Chk LCDB Mode */
6373 /* --------------------------------------------------------------------- */
6374 /* Function : XGI_EnableChISLCD */
6376 /* Output : 0 -> Not LCD mode */
6378 /* --------------------------------------------------------------------- */
6379 static unsigned char XGI_EnableChISLCD(struct vb_device_info
*pVBInfo
)
6381 unsigned short tempbx
, tempah
;
6383 tempbx
= pVBInfo
->SetFlag
& (EnableChA
| EnableChB
);
6384 tempah
= ~((unsigned short) xgifb_reg_get(pVBInfo
->Part1Port
, 0x2E));
6386 if (tempbx
& (EnableChA
| DisableChA
)) {
6387 if (!(tempah
& 0x08)) /* Chk LCDA Mode */
6391 if (!(tempbx
& (EnableChB
| DisableChB
)))
6394 if (tempah
& 0x01) /* Chk LCDB Mode */
6400 void XGI_DisableBridge(struct xgi_hw_device_info
*HwDeviceExtension
,
6401 struct vb_device_info
*pVBInfo
)
6403 unsigned short tempah
= 0;
6405 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
| VB_XGI301LV
6406 | VB_XGI302LV
| VB_XGI301C
)) {
6408 if (!(pVBInfo
->VBInfo
&
6409 (DisableCRT2Display
| SetSimuScanMode
))) {
6410 if (pVBInfo
->VBInfo
& SetCRT2ToLCDA
) {
6411 if (pVBInfo
->VBInfo
& SetCRT2ToDualEdge
) {
6412 tempah
= 0x7F; /* Disable Channel A */
6413 if (!(pVBInfo
->VBInfo
& SetCRT2ToLCDA
))
6414 /* Disable Channel B */
6417 if (pVBInfo
->SetFlag
& DisableChB
)
6418 /* force to disable Cahnnel */
6421 if (pVBInfo
->SetFlag
& DisableChA
)
6422 /* Force to disable Channel B */
6428 /* disable part4_1f */
6429 xgifb_reg_and(pVBInfo
->Part4Port
, 0x1F, tempah
);
6431 if (pVBInfo
->VBType
& (VB_XGI302LV
| VB_XGI301C
)) {
6432 if (((pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToLCDA
)))
6433 || (XGI_DisableChISLCD(pVBInfo
))
6434 || (XGI_IsLCDON(pVBInfo
)))
6435 /* LVDS Driver power down */
6436 xgifb_reg_or(pVBInfo
->Part4Port
, 0x30, 0x80);
6439 if ((pVBInfo
->SetFlag
& DisableChA
) || (pVBInfo
->VBInfo
6440 & (DisableCRT2Display
| SetCRT2ToLCDA
6441 | SetSimuScanMode
))) {
6442 if (pVBInfo
->SetFlag
& GatingCRT
)
6443 XGI_EnableGatingCRT(HwDeviceExtension
, pVBInfo
);
6444 XGI_DisplayOff(HwDeviceExtension
, pVBInfo
);
6447 if (pVBInfo
->VBInfo
& SetCRT2ToLCDA
) {
6448 if ((pVBInfo
->SetFlag
& DisableChA
) || (pVBInfo
->VBInfo
6451 xgifb_reg_and(pVBInfo
->Part1Port
, 0x1e, 0xdf);
6454 /* disable TV as primary VGA swap */
6455 xgifb_reg_and(pVBInfo
->P3c4
, 0x32, 0xdf);
6457 if ((pVBInfo
->VBInfo
& (SetSimuScanMode
| SetCRT2ToDualEdge
)))
6458 xgifb_reg_and(pVBInfo
->Part2Port
, 0x00, 0xdf);
6460 if ((pVBInfo
->SetFlag
& DisableChB
) ||
6462 (DisableCRT2Display
| SetSimuScanMode
)) ||
6463 ((!(pVBInfo
->VBInfo
& SetCRT2ToLCDA
)) &&
6465 (SetCRT2ToRAMDAC
| SetCRT2ToLCD
| SetCRT2ToTV
))))
6467 xgifb_reg_or(pVBInfo
->Part1Port
, 0x00, 0x80);
6469 if ((pVBInfo
->SetFlag
& DisableChB
) ||
6471 (DisableCRT2Display
| SetSimuScanMode
)) ||
6472 (!(pVBInfo
->VBInfo
& SetCRT2ToLCDA
)) ||
6474 (SetCRT2ToRAMDAC
| SetCRT2ToLCD
| SetCRT2ToTV
))) {
6475 /* save Part1 index 0 */
6476 tempah
= xgifb_reg_get(pVBInfo
->Part1Port
, 0x00);
6477 /* BTDAC = 1, avoid VB reset */
6478 xgifb_reg_or(pVBInfo
->Part1Port
, 0x00, 0x10);
6480 xgifb_reg_and(pVBInfo
->Part1Port
, 0x1E, 0xDF);
6481 /* restore Part1 index 0 */
6482 xgifb_reg_set(pVBInfo
->Part1Port
, 0x00, tempah
);
6484 } else { /* {301} */
6485 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToTV
)) {
6487 xgifb_reg_or(pVBInfo
->Part1Port
, 0x00, 0x80);
6489 xgifb_reg_and(pVBInfo
->Part1Port
, 0x1E, 0xDF);
6490 /* Disable TV asPrimary VGA swap */
6491 xgifb_reg_and(pVBInfo
->P3c4
, 0x32, 0xDF);
6494 if (pVBInfo
->VBInfo
& (DisableCRT2Display
| SetCRT2ToLCDA
6496 XGI_DisplayOff(HwDeviceExtension
, pVBInfo
);
6500 /* --------------------------------------------------------------------- */
6501 /* Function : XGI_GetTVPtrIndex */
6504 /* Description : bx 0 : ExtNTSC */
6516 /* --------------------------------------------------------------------- */
6517 static unsigned short XGI_GetTVPtrIndex(struct vb_device_info
*pVBInfo
)
6519 unsigned short tempbx
= 0;
6521 if (pVBInfo
->TVInfo
& SetPALTV
)
6523 if (pVBInfo
->TVInfo
& SetYPbPrMode1080i
)
6525 if (pVBInfo
->TVInfo
& SetYPbPrMode525i
)
6527 if (pVBInfo
->TVInfo
& SetYPbPrMode525p
)
6529 if (pVBInfo
->TVInfo
& SetYPbPrMode750p
)
6531 if (pVBInfo
->TVInfo
& TVSimuMode
)
6537 /* --------------------------------------------------------------------- */
6538 /* Function : XGI_GetTVPtrIndex2 */
6540 /* Output : bx 0 : NTSC */
6544 /* 4 : NTSC1024x768 */
6545 /* 5 : PAL-M 1024x768 */
6547 /* cl 0 : YFilter1 */
6550 /* 1 : 301B/302B/301LV/302LV */
6552 /* --------------------------------------------------------------------- */
6553 static void XGI_GetTVPtrIndex2(unsigned short *tempbx
, unsigned char *tempcl
,
6554 unsigned char *tempch
, struct vb_device_info
*pVBInfo
)
6560 if (pVBInfo
->TVInfo
& SetPALTV
)
6563 if (pVBInfo
->TVInfo
& SetPALMTV
)
6566 if (pVBInfo
->TVInfo
& SetPALNTV
)
6569 if (pVBInfo
->TVInfo
& NTSC1024x768
) {
6571 if (pVBInfo
->TVInfo
& SetPALMTV
)
6575 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
| VB_XGI301LV
6576 | VB_XGI302LV
| VB_XGI301C
)) {
6577 if ((!(pVBInfo
->VBInfo
& SetInSlaveMode
)) || (pVBInfo
->TVInfo
6584 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
| VB_XGI301LV
6585 | VB_XGI302LV
| VB_XGI301C
))
6589 static void XGI_SetDelayComp(struct vb_device_info
*pVBInfo
)
6591 unsigned short index
;
6593 unsigned char tempah
, tempbl
, tempbh
;
6595 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
| VB_XGI301LV
6596 | VB_XGI302LV
| VB_XGI301C
)) {
6597 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToLCDA
6598 | SetCRT2ToTV
| SetCRT2ToRAMDAC
)) {
6602 index
= XGI_GetTVPtrIndex(pVBInfo
); /* Get TV Delay */
6603 tempbl
= pVBInfo
->XGI_TVDelayList
[index
];
6605 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
6606 | VB_XGI301LV
| VB_XGI302LV
6608 tempbl
= pVBInfo
->XGI_TVDelayList2
[index
];
6610 if (pVBInfo
->VBInfo
& SetCRT2ToDualEdge
)
6611 tempbl
= tempbl
>> 4;
6613 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC)
6614 tempbl = CRT2Delay1; // Get CRT2 Delay
6615 if (pVBInfo->VBType &
6621 tempbl = CRT2Delay2;
6623 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToLCDA
)) {
6625 index
= XGI_GetLCDCapPtr(pVBInfo
);
6626 tempbh
= pVBInfo
->LCDCapList
[index
].
6627 LCD_DelayCompensation
;
6629 if (!(pVBInfo
->VBInfo
& SetCRT2ToLCDA
))
6635 tempah
= xgifb_reg_get(pVBInfo
->Part1Port
, 0x2D);
6637 if (pVBInfo
->VBInfo
& (SetCRT2ToRAMDAC
| SetCRT2ToLCD
6638 | SetCRT2ToTV
)) { /* Channel B */
6643 if (pVBInfo
->VBInfo
& SetCRT2ToLCDA
) { /* Channel A */
6647 xgifb_reg_set(pVBInfo
->Part1Port
, 0x2D, tempah
);
6649 } else if (pVBInfo
->IF_DEF_LVDS
== 1) {
6652 if (pVBInfo
->VBInfo
& SetCRT2ToLCD
) {
6653 /* / Get LCD Delay */
6654 tempah
= pVBInfo
->LCDCapList
[
6655 XGI_GetLCDCapPtr(pVBInfo
)].
6656 LCD_DelayCompensation
;
6658 tempah
= tempah
<< 4;
6659 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x2D, 0x0f,
6665 static void XGI_SetLCDCap_A(unsigned short tempcx
,
6666 struct vb_device_info
*pVBInfo
)
6668 unsigned short temp
;
6670 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x37);
6672 if (temp
& LCDRGB18Bit
) {
6673 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x19, 0x0F,
6675 (unsigned short) (0x20 | (tempcx
& 0x00C0)));
6676 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x1A, 0x7F, 0x80);
6678 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x19, 0x0F,
6679 (unsigned short) (0x30 | (tempcx
& 0x00C0)));
6680 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x1A, 0x7F, 0x00);
6684 if (tempcx & EnableLCD24bpp) { // 24bits
6685 xgifb_reg_and_or(pVBInfo->Part1Port,
6688 (unsigned short)(0x30 | (tempcx&0x00C0)));
6689 xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00);
6691 xgifb_reg_and_or(pVBInfo->Part1Port,
6695 (unsigned short)(0x20 | (tempcx&0x00C0)));
6696 xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80);
6701 /* --------------------------------------------------------------------- */
6702 /* Function : XGI_SetLCDCap_B */
6703 /* Input : cx -> LCD Capability */
6706 /* --------------------------------------------------------------------- */
6707 static void XGI_SetLCDCap_B(unsigned short tempcx
,
6708 struct vb_device_info
*pVBInfo
)
6710 if (tempcx
& EnableLCD24bpp
) /* 24bits */
6711 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x1A, 0xE0,
6712 (unsigned short) (((tempcx
& 0x00ff) >> 6)
6715 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x1A, 0xE0,
6716 (unsigned short) (((tempcx
& 0x00ff) >> 6)
6717 | 0x18)); /* Enable Dither */
6720 static void SetSpectrum(struct vb_device_info
*pVBInfo
)
6722 unsigned short index
;
6724 index
= XGI_GetLCDCapPtr(pVBInfo
);
6726 /* disable down spectrum D[4] */
6727 xgifb_reg_and(pVBInfo
->Part4Port
, 0x30, 0x8F);
6728 XGI_LongWait(pVBInfo
);
6729 xgifb_reg_or(pVBInfo
->Part4Port
, 0x30, 0x20); /* reset spectrum */
6730 XGI_LongWait(pVBInfo
);
6732 xgifb_reg_set(pVBInfo
->Part4Port
, 0x31,
6733 pVBInfo
->LCDCapList
[index
].Spectrum_31
);
6734 xgifb_reg_set(pVBInfo
->Part4Port
, 0x32,
6735 pVBInfo
->LCDCapList
[index
].Spectrum_32
);
6736 xgifb_reg_set(pVBInfo
->Part4Port
, 0x33,
6737 pVBInfo
->LCDCapList
[index
].Spectrum_33
);
6738 xgifb_reg_set(pVBInfo
->Part4Port
, 0x34,
6739 pVBInfo
->LCDCapList
[index
].Spectrum_34
);
6740 XGI_LongWait(pVBInfo
);
6741 xgifb_reg_or(pVBInfo
->Part4Port
, 0x30, 0x40); /* enable spectrum */
6744 static void XGI_SetLCDCap(struct vb_device_info
*pVBInfo
)
6746 unsigned short tempcx
;
6748 tempcx
= pVBInfo
->LCDCapList
[XGI_GetLCDCapPtr(pVBInfo
)].LCD_Capability
;
6750 if (pVBInfo
->VBType
&
6755 VB_XGI301C
)) { /* 301LV/302LV only */
6756 if (pVBInfo
->VBType
&
6757 (VB_XGI301LV
| VB_XGI302LV
| VB_XGI301C
)) {
6758 /* Set 301LV Capability */
6759 xgifb_reg_set(pVBInfo
->Part4Port
, 0x24,
6760 (unsigned char) (tempcx
& 0x1F));
6763 xgifb_reg_and_or(pVBInfo
->Part4Port
, 0x0D,
6764 ~((EnableVBCLKDRVLOW
| EnablePLLSPLOW
) >> 8),
6765 (unsigned short) ((tempcx
& (EnableVBCLKDRVLOW
6766 | EnablePLLSPLOW
)) >> 8));
6769 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
| VB_XGI301LV
6770 | VB_XGI302LV
| VB_XGI301C
)) {
6771 if (pVBInfo
->VBInfo
& SetCRT2ToLCD
)
6772 XGI_SetLCDCap_B(tempcx
, pVBInfo
);
6773 else if (pVBInfo
->VBInfo
& SetCRT2ToLCDA
)
6774 XGI_SetLCDCap_A(tempcx
, pVBInfo
);
6776 if (pVBInfo
->VBType
& (VB_XGI302LV
| VB_XGI301C
)) {
6777 if (tempcx
& EnableSpectrum
)
6778 SetSpectrum(pVBInfo
);
6782 XGI_SetLCDCap_A(tempcx
, pVBInfo
);
6786 /* --------------------------------------------------------------------- */
6787 /* Function : XGI_SetAntiFlicker */
6790 /* Description : Set TV Customized Param. */
6791 /* --------------------------------------------------------------------- */
6792 static void XGI_SetAntiFlicker(unsigned short ModeNo
,
6793 unsigned short ModeIdIndex
,
6794 struct vb_device_info
*pVBInfo
)
6796 unsigned short tempbx
, index
;
6798 unsigned char tempah
;
6800 if (pVBInfo
->TVInfo
& (SetYPbPrMode525p
| SetYPbPrMode750p
))
6803 tempbx
= XGI_GetTVPtrIndex(pVBInfo
);
6807 index
= pVBInfo
->SModeIDTable
[ModeIdIndex
].VB_StTVFlickerIndex
;
6809 index
= pVBInfo
->EModeIDTable
[ModeIdIndex
].VB_ExtTVFlickerIndex
;
6812 tempah
= TVAntiFlickList
[tempbx
];
6813 tempah
= tempah
<< 4;
6815 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x0A, 0x8F, tempah
);
6818 static void XGI_SetEdgeEnhance(unsigned short ModeNo
,
6819 unsigned short ModeIdIndex
,
6820 struct vb_device_info
*pVBInfo
)
6822 unsigned short tempbx
, index
;
6824 unsigned char tempah
;
6826 tempbx
= XGI_GetTVPtrIndex(pVBInfo
);
6830 index
= pVBInfo
->SModeIDTable
[ModeIdIndex
].VB_StTVEdgeIndex
;
6832 index
= pVBInfo
->EModeIDTable
[ModeIdIndex
].VB_ExtTVEdgeIndex
;
6835 tempah
= TVEdgeList
[tempbx
];
6836 tempah
= tempah
<< 5;
6838 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x3A, 0x1F, tempah
);
6841 static void XGI_SetPhaseIncr(struct vb_device_info
*pVBInfo
)
6843 unsigned short tempbx
;
6845 unsigned char tempcl
, tempch
;
6847 unsigned long tempData
;
6849 XGI_GetTVPtrIndex2(&tempbx
, &tempcl
, &tempch
, pVBInfo
); /* bx, cl, ch */
6850 tempData
= TVPhaseList
[tempbx
];
6852 xgifb_reg_set(pVBInfo
->Part2Port
, 0x31, (unsigned short) (tempData
6854 xgifb_reg_set(pVBInfo
->Part2Port
, 0x32, (unsigned short) ((tempData
6855 & 0x0000FF00) >> 8));
6856 xgifb_reg_set(pVBInfo
->Part2Port
, 0x33, (unsigned short) ((tempData
6857 & 0x00FF0000) >> 16));
6858 xgifb_reg_set(pVBInfo
->Part2Port
, 0x34, (unsigned short) ((tempData
6859 & 0xFF000000) >> 24));
6862 static void XGI_SetYFilter(unsigned short ModeNo
, unsigned short ModeIdIndex
,
6863 struct vb_device_info
*pVBInfo
)
6865 unsigned short tempbx
, index
;
6867 unsigned char tempcl
, tempch
, tempal
, *filterPtr
;
6869 XGI_GetTVPtrIndex2(&tempbx
, &tempcl
, &tempch
, pVBInfo
); /* bx, cl, ch */
6874 filterPtr
= NTSCYFilter1
;
6878 filterPtr
= PALYFilter1
;
6885 filterPtr
= xgifb_palmn_yfilter1
;
6893 filterPtr
= xgifb_yfilter2
;
6901 tempal
= pVBInfo
->SModeIDTable
[ModeIdIndex
].
6902 VB_StTVYFilterIndex
;
6904 tempal
= pVBInfo
->EModeIDTable
[ModeIdIndex
].
6905 VB_ExtTVYFilterIndex
;
6912 if ((tempcl
== 0) && (tempch
== 1)) {
6913 xgifb_reg_set(pVBInfo
->Part2Port
, 0x35, 0);
6914 xgifb_reg_set(pVBInfo
->Part2Port
, 0x36, 0);
6915 xgifb_reg_set(pVBInfo
->Part2Port
, 0x37, 0);
6916 xgifb_reg_set(pVBInfo
->Part2Port
, 0x38, filterPtr
[index
++]);
6918 xgifb_reg_set(pVBInfo
->Part2Port
, 0x35, filterPtr
[index
++]);
6919 xgifb_reg_set(pVBInfo
->Part2Port
, 0x36, filterPtr
[index
++]);
6920 xgifb_reg_set(pVBInfo
->Part2Port
, 0x37, filterPtr
[index
++]);
6921 xgifb_reg_set(pVBInfo
->Part2Port
, 0x38, filterPtr
[index
++]);
6924 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
| VB_XGI301LV
6925 | VB_XGI302LV
| VB_XGI301C
)) {
6926 xgifb_reg_set(pVBInfo
->Part2Port
, 0x48, filterPtr
[index
++]);
6927 xgifb_reg_set(pVBInfo
->Part2Port
, 0x49, filterPtr
[index
++]);
6928 xgifb_reg_set(pVBInfo
->Part2Port
, 0x4A, filterPtr
[index
++]);
6932 /* --------------------------------------------------------------------- */
6933 /* Function : XGI_OEM310Setting */
6936 /* Description : Customized Param. for 301 */
6937 /* --------------------------------------------------------------------- */
6938 static void XGI_OEM310Setting(unsigned short ModeNo
,
6939 unsigned short ModeIdIndex
,
6940 struct vb_device_info
*pVBInfo
)
6943 XGI_SetDelayComp(pVBInfo
);
6945 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToLCDA
))
6946 XGI_SetLCDCap(pVBInfo
);
6948 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
6950 XGI_SetPhaseIncr(pVBInfo
);
6951 XGI_SetYFilter(ModeNo
, ModeIdIndex
, pVBInfo
);
6952 XGI_SetAntiFlicker(ModeNo
, ModeIdIndex
, pVBInfo
);
6954 if (pVBInfo
->VBType
& VB_XGI301
)
6955 XGI_SetEdgeEnhance(ModeNo
, ModeIdIndex
, pVBInfo
);
6959 /* --------------------------------------------------------------------- */
6960 /* Function : XGI_SetCRT2ModeRegs */
6963 /* Description : Origin code for crt2group */
6964 /* --------------------------------------------------------------------- */
6965 void XGI_SetCRT2ModeRegs(unsigned short ModeNo
,
6966 struct xgi_hw_device_info
*HwDeviceExtension
,
6967 struct vb_device_info
*pVBInfo
)
6969 unsigned short tempbl
;
6972 unsigned char tempah
;
6974 /* // fix write part1 index 0 BTDRAM bit Bug
6975 * xgifb_reg_set(pVBInfo->Part1Port, 0x03, 0x00); */
6977 if (!(pVBInfo
->VBInfo
& DisableCRT2Display
)) {
6978 tempah
= xgifb_reg_get(pVBInfo
->Part1Port
, 0x00);
6979 tempah
&= ~0x10; /* BTRAMDAC */
6980 tempah
|= 0x40; /* BTRAM */
6982 if (pVBInfo
->VBInfo
& (SetCRT2ToRAMDAC
| SetCRT2ToTV
6984 tempah
= 0x40; /* BTDRAM */
6985 if (ModeNo
> 0x13) {
6986 tempcl
= pVBInfo
->ModeType
;
6990 tempah
= (0x008 >> tempcl
);
6996 if (pVBInfo
->VBInfo
& SetInSlaveMode
)
6997 tempah
^= 0x50; /* BTDAC */
7002 if (pVBInfo->VBInfo & DisableCRT2Display) {
7006 xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah);
7007 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD)) {
7008 tempcl = pVBInfo->ModeType;
7009 if (ModeNo > 0x13) {
7011 if ((tempcl > 0) || (tempcl == 0)) {
7012 tempah=(0x008>>tempcl) ;
7021 if (pVBInfo->VBInfo & SetInSlaveMode) {
7022 tempah = (tempah ^ 0x050);
7027 xgifb_reg_set(pVBInfo
->Part1Port
, 0x00, tempah
);
7031 if (pVBInfo
->VBInfo
& DisableCRT2Display
) {
7032 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x2e, tempbl
, tempah
);
7037 if (pVBInfo
->VBInfo
& (SetCRT2ToRAMDAC
| SetCRT2ToTV
7038 | SetCRT2ToLCD
| SetCRT2ToLCDA
)) {
7039 if ((pVBInfo
->VBInfo
& SetCRT2ToLCDA
) &&
7040 (!(pVBInfo
->VBInfo
& SetSimuScanMode
))) {
7043 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x2e,
7046 if (pVBInfo
->VBInfo
& SetCRT2ToLCDA
) {
7051 if (pVBInfo
->VBInfo
&
7058 if (!(pVBInfo
->VBInfo
& SetInSlaveMode
))
7061 if (!(pVBInfo
->VBInfo
&
7063 tempah
= tempah
^ 0x05;
7064 if (!(pVBInfo
->VBInfo
&
7066 tempah
= tempah
^ 0x01;
7069 if (!(pVBInfo
->VBInfo
&
7072 xgifb_reg_and_or(pVBInfo
->Part1Port
,
7073 0x2e, tempbl
, tempah
);
7075 xgifb_reg_and_or(pVBInfo
->Part1Port
,
7076 0x2e, tempbl
, tempah
);
7080 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x2e, tempbl
,
7085 if (pVBInfo
->VBInfo
& (SetCRT2ToRAMDAC
| SetCRT2ToTV
| SetCRT2ToLCD
7088 if ((pVBInfo
->ModeType
== ModeVGA
) && (!(pVBInfo
->VBInfo
7089 & SetInSlaveMode
))) {
7094 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
7095 /* if (!(pVBInfo->TVInfo &
7096 (SetYPbPrMode525p | SetYPbPrMode750p))) { */
7098 if (ModeNo
> 0x13) {
7099 if (pVBInfo
->VBInfo
& DriverMode
)
7100 tempah
= tempah
^ 0x20;
7105 xgifb_reg_and_or(pVBInfo
->Part4Port
, 0x0D, ~0x0BF, tempah
);
7108 if (pVBInfo
->LCDInfo
& SetLCDDualLink
)
7111 if (pVBInfo
->VBInfo
& SetCRT2ToTV
) {
7112 /* if ((!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)) &&
7113 (!(pVBInfo->TVInfo &
7114 (SetYPbPrMode525p | SetYPbPrMode750p)))) { */
7115 if (pVBInfo
->TVInfo
& RPLLDIV2XO
)
7120 if ((pVBInfo
->LCDResInfo
== Panel1280x1024
)
7121 || (pVBInfo
->LCDResInfo
== Panel1280x1024x75
))
7124 if (pVBInfo
->LCDResInfo
== Panel1280x960
)
7127 xgifb_reg_set(pVBInfo
->Part4Port
, 0x0C, tempah
);
7130 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
| VB_XGI301LV
7131 | VB_XGI302LV
| VB_XGI301C
)) {
7135 if (pVBInfo
->VBInfo
& SetCRT2ToDualEdge
) {
7137 if (pVBInfo
->VBInfo
& SetCRT2ToLCDA
)
7138 tempah
|= 0x04; /* shampoo 0129 */
7141 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x13, tempbl
, tempah
);
7144 if (!(pVBInfo
->VBInfo
& DisableCRT2Display
)) {
7145 if (pVBInfo
->VBInfo
& SetCRT2ToDualEdge
)
7149 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x2c, tempbl
, tempah
);
7153 if (!(pVBInfo
->VBInfo
& DisableCRT2Display
)) {
7154 if (pVBInfo
->VBInfo
& SetCRT2ToDualEdge
)
7157 xgifb_reg_and_or(pVBInfo
->Part4Port
, 0x21, tempbl
, tempah
);
7162 if (!(pVBInfo
->VBInfo
& SetCRT2ToLCDA
)) {
7164 if (!(pVBInfo
->VBInfo
& SetCRT2ToDualEdge
))
7168 xgifb_reg_and_or(pVBInfo
->Part4Port
, 0x23, tempbl
, tempah
);
7170 if (pVBInfo
->VBType
& (VB_XGI302LV
| VB_XGI301C
)) {
7171 if (pVBInfo
->LCDInfo
& SetLCDDualLink
) {
7172 xgifb_reg_or(pVBInfo
->Part4Port
, 0x27, 0x20);
7173 xgifb_reg_or(pVBInfo
->Part4Port
, 0x34, 0x10);
7178 static void XGI_CloseCRTC(struct xgi_hw_device_info
*HwDeviceExtension
,
7179 struct vb_device_info
*pVBInfo
)
7181 unsigned short tempbx
;
7185 if (pVBInfo
->VBInfo
& SetCRT2ToLCDA
)
7190 void XGI_UnLockCRT2(struct xgi_hw_device_info
*HwDeviceExtension
,
7191 struct vb_device_info
*pVBInfo
)
7194 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x2f, 0xFF, 0x01);
7198 void XGI_LockCRT2(struct xgi_hw_device_info
*HwDeviceExtension
,
7199 struct vb_device_info
*pVBInfo
)
7202 xgifb_reg_and_or(pVBInfo
->Part1Port
, 0x2F, 0xFE, 0x00);
7206 unsigned char XGI_BridgeIsOn(struct vb_device_info
*pVBInfo
)
7208 unsigned short flag
;
7210 if (pVBInfo
->IF_DEF_LVDS
== 1) {
7213 flag
= xgifb_reg_get(pVBInfo
->Part4Port
, 0x00);
7214 if ((flag
== 1) || (flag
== 2))
7215 return 1; /* 301b */
7221 void XGI_LongWait(struct vb_device_info
*pVBInfo
)
7225 i
= xgifb_reg_get(pVBInfo
->P3c4
, 0x1F);
7228 for (i
= 0; i
< 0xFFFF; i
++) {
7229 if (!(inb(pVBInfo
->P3da
) & 0x08))
7233 for (i
= 0; i
< 0xFFFF; i
++) {
7234 if ((inb(pVBInfo
->P3da
) & 0x08))
7240 static void XGI_VBLongWait(struct vb_device_info
*pVBInfo
)
7242 unsigned short tempal
, temp
, i
, j
;
7244 if (!(pVBInfo
->VBInfo
& SetCRT2ToTV
)) {
7246 for (i
= 0; i
< 3; i
++) {
7247 for (j
= 0; j
< 100; j
++) {
7248 tempal
= inb(pVBInfo
->P3da
);
7249 if (temp
& 0x01) { /* VBWaitMode2 */
7250 if ((tempal
& 0x08))
7253 if (!(tempal
& 0x08))
7256 } else { /* VBWaitMode1 */
7257 if (!(tempal
& 0x08))
7260 if ((tempal
& 0x08))
7267 XGI_LongWait(pVBInfo
);
7272 unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info
*pXGIHWDE
,
7273 unsigned short ModeNo
, unsigned short ModeIdIndex
,
7274 struct vb_device_info
*pVBInfo
)
7276 short LCDRefreshIndex
[] = { 0x00, 0x00, 0x03, 0x01 },
7277 LCDARefreshIndex
[] = { 0x00, 0x00, 0x03, 0x01, 0x01,
7280 unsigned short RefreshRateTableIndex
, i
, modeflag
, index
, temp
;
7283 modeflag
= pVBInfo
->SModeIDTable
[ModeIdIndex
].St_ModeFlag
;
7285 modeflag
= pVBInfo
->EModeIDTable
[ModeIdIndex
].Ext_ModeFlag
;
7290 index
= xgifb_reg_get(pVBInfo
->P3d4
, 0x33);
7291 index
= index
>> pVBInfo
->SelectCRT2Rate
;
7294 if (pVBInfo
->LCDInfo
& LCDNonExpanding
)
7300 if (pVBInfo
->SetFlag
& ProgrammingCRT2
) {
7301 if (pVBInfo
->VBInfo
& (SetCRT2ToLCD
| SetCRT2ToLCDA
)) {
7302 if (pVBInfo
->IF_DEF_LVDS
== 0) {
7303 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
7304 | VB_XGI301LV
| VB_XGI302LV
7307 temp
= LCDARefreshIndex
[
7308 pVBInfo
->LCDResInfo
& 0x0F];
7310 temp
= LCDRefreshIndex
[
7311 pVBInfo
->LCDResInfo
& 0x0F];
7321 RefreshRateTableIndex
= pVBInfo
->EModeIDTable
[ModeIdIndex
].REFindex
;
7322 ModeNo
= pVBInfo
->RefIndex
[RefreshRateTableIndex
].ModeID
;
7323 if (pXGIHWDE
->jChipType
>= XG20
) { /* for XG20, XG21, XG27 */
7325 if (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag &
7330 if ((pVBInfo
->RefIndex
[RefreshRateTableIndex
].XRes
== 800) &&
7331 (pVBInfo
->RefIndex
[RefreshRateTableIndex
].YRes
== 600)) {
7335 * do the similar adjustment like XGISearchCRT1Rate() */
7336 if ((pVBInfo
->RefIndex
[RefreshRateTableIndex
].XRes
== 1024) &&
7337 (pVBInfo
->RefIndex
[RefreshRateTableIndex
].YRes
== 768)) {
7340 if ((pVBInfo
->RefIndex
[RefreshRateTableIndex
].XRes
== 1280) &&
7341 (pVBInfo
->RefIndex
[RefreshRateTableIndex
].YRes
== 1024)) {
7348 if (pVBInfo
->RefIndex
[RefreshRateTableIndex
+ i
].
7351 temp
= pVBInfo
->RefIndex
[RefreshRateTableIndex
+ i
].
7353 temp
&= ModeInfoFlag
;
7354 if (temp
< pVBInfo
->ModeType
)
7359 } while (index
!= 0xFFFF);
7360 if (!(pVBInfo
->VBInfo
& SetCRT2ToRAMDAC
)) {
7361 if (pVBInfo
->VBInfo
& SetInSlaveMode
) {
7362 temp
= pVBInfo
->RefIndex
[RefreshRateTableIndex
+ i
- 1].
7364 if (temp
& InterlaceMode
)
7369 if ((pVBInfo
->SetFlag
& ProgrammingCRT2
)) {
7370 temp
= XGI_AjustCRT2Rate(ModeNo
, ModeIdIndex
,
7371 RefreshRateTableIndex
, &i
, pVBInfo
);
7373 return RefreshRateTableIndex
+ i
; /* return (0x01 | (temp1<<1)); */
7376 static void XGI_SetLCDAGroup(unsigned short ModeNo
, unsigned short ModeIdIndex
,
7377 struct xgi_hw_device_info
*HwDeviceExtension
,
7378 struct vb_device_info
*pVBInfo
)
7380 unsigned short RefreshRateTableIndex
;
7381 /* unsigned short temp ; */
7383 /* pVBInfo->SelectCRT2Rate = 0; */
7385 pVBInfo
->SetFlag
|= ProgrammingCRT2
;
7386 RefreshRateTableIndex
= XGI_GetRatePtrCRT2(HwDeviceExtension
, ModeNo
,
7387 ModeIdIndex
, pVBInfo
);
7388 XGI_GetLVDSResInfo(ModeNo
, ModeIdIndex
, pVBInfo
);
7389 XGI_GetLVDSData(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
, pVBInfo
);
7390 XGI_ModCRT1Regs(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
7391 HwDeviceExtension
, pVBInfo
);
7392 XGI_SetLVDSRegs(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
, pVBInfo
);
7393 XGI_SetCRT2ECLK(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
, pVBInfo
);
7396 unsigned char XGI_SetCRT2Group301(unsigned short ModeNo
,
7397 struct xgi_hw_device_info
*HwDeviceExtension
,
7398 struct vb_device_info
*pVBInfo
)
7400 unsigned short tempbx
, ModeIdIndex
, RefreshRateTableIndex
;
7402 tempbx
= pVBInfo
->VBInfo
;
7403 pVBInfo
->SetFlag
|= ProgrammingCRT2
;
7404 XGI_SearchModeID(ModeNo
, &ModeIdIndex
, pVBInfo
);
7405 pVBInfo
->SelectCRT2Rate
= 4;
7406 RefreshRateTableIndex
= XGI_GetRatePtrCRT2(HwDeviceExtension
, ModeNo
,
7407 ModeIdIndex
, pVBInfo
);
7408 XGI_SaveCRT2Info(ModeNo
, pVBInfo
);
7409 XGI_GetCRT2ResInfo(ModeNo
, ModeIdIndex
, pVBInfo
);
7410 XGI_GetCRT2Data(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
, pVBInfo
);
7411 XGI_PreSetGroup1(ModeNo
, ModeIdIndex
, HwDeviceExtension
,
7412 RefreshRateTableIndex
, pVBInfo
);
7413 XGI_SetGroup1(ModeNo
, ModeIdIndex
, HwDeviceExtension
,
7414 RefreshRateTableIndex
, pVBInfo
);
7415 XGI_SetLockRegs(ModeNo
, ModeIdIndex
, HwDeviceExtension
,
7416 RefreshRateTableIndex
, pVBInfo
);
7417 XGI_SetGroup2(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
7418 HwDeviceExtension
, pVBInfo
);
7419 XGI_SetLCDRegs(ModeNo
, ModeIdIndex
, HwDeviceExtension
,
7420 RefreshRateTableIndex
, pVBInfo
);
7421 XGI_SetTap4Regs(pVBInfo
);
7422 XGI_SetGroup3(ModeNo
, ModeIdIndex
, pVBInfo
);
7423 XGI_SetGroup4(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
7424 HwDeviceExtension
, pVBInfo
);
7425 XGI_SetCRT2VCLK(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
, pVBInfo
);
7426 XGI_SetGroup5(ModeNo
, ModeIdIndex
, pVBInfo
);
7427 XGI_AutoThreshold(pVBInfo
);
7431 void XGI_SenseCRT1(struct vb_device_info
*pVBInfo
)
7433 unsigned char CRTCData
[17] = { 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81,
7434 0x0B, 0x3E, 0xE9, 0x0B, 0xDF, 0xE7, 0x04, 0x00, 0x00,
7437 unsigned char SR01
= 0, SR1F
= 0, SR07
= 0, SR06
= 0;
7439 unsigned char CR17
, CR63
, SR31
;
7440 unsigned short temp
;
7441 unsigned char DAC_TEST_PARMS
[3] = { 0x0F, 0x0F, 0x0F };
7444 xgifb_reg_set(pVBInfo
->P3c4
, 0x05, 0x86);
7446 /* [2004/05/06] Vicent to fix XG42 single LCD sense to CRT+LCD */
7447 xgifb_reg_set(pVBInfo
->P3d4
, 0x57, 0x4A);
7448 xgifb_reg_set(pVBInfo
->P3d4
, 0x53, (unsigned char) (xgifb_reg_get(
7449 pVBInfo
->P3d4
, 0x53) | 0x02));
7451 SR31
= (unsigned char) xgifb_reg_get(pVBInfo
->P3c4
, 0x31);
7452 CR63
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x63);
7453 SR01
= (unsigned char) xgifb_reg_get(pVBInfo
->P3c4
, 0x01);
7455 xgifb_reg_set(pVBInfo
->P3c4
, 0x01, (unsigned char) (SR01
& 0xDF));
7456 xgifb_reg_set(pVBInfo
->P3d4
, 0x63, (unsigned char) (CR63
& 0xBF));
7458 CR17
= (unsigned char) xgifb_reg_get(pVBInfo
->P3d4
, 0x17);
7459 xgifb_reg_set(pVBInfo
->P3d4
, 0x17, (unsigned char) (CR17
| 0x80));
7461 SR1F
= (unsigned char) xgifb_reg_get(pVBInfo
->P3c4
, 0x1F);
7462 xgifb_reg_set(pVBInfo
->P3c4
, 0x1F, (unsigned char) (SR1F
| 0x04));
7464 SR07
= (unsigned char) xgifb_reg_get(pVBInfo
->P3c4
, 0x07);
7465 xgifb_reg_set(pVBInfo
->P3c4
, 0x07, (unsigned char) (SR07
& 0xFB));
7466 SR06
= (unsigned char) xgifb_reg_get(pVBInfo
->P3c4
, 0x06);
7467 xgifb_reg_set(pVBInfo
->P3c4
, 0x06, (unsigned char) (SR06
& 0xC3));
7469 xgifb_reg_set(pVBInfo
->P3d4
, 0x11, 0x00);
7471 for (i
= 0; i
< 8; i
++)
7472 xgifb_reg_set(pVBInfo
->P3d4
, (unsigned short) i
, CRTCData
[i
]);
7474 for (i
= 8; i
< 11; i
++)
7475 xgifb_reg_set(pVBInfo
->P3d4
, (unsigned short) (i
+ 8),
7478 for (i
= 11; i
< 13; i
++)
7479 xgifb_reg_set(pVBInfo
->P3d4
, (unsigned short) (i
+ 4),
7482 for (i
= 13; i
< 16; i
++)
7483 xgifb_reg_set(pVBInfo
->P3c4
, (unsigned short) (i
- 3),
7486 xgifb_reg_set(pVBInfo
->P3c4
, 0x0E, (unsigned char) (CRTCData
[16]
7489 xgifb_reg_set(pVBInfo
->P3c4
, 0x31, 0x00);
7490 xgifb_reg_set(pVBInfo
->P3c4
, 0x2B, 0x1B);
7491 xgifb_reg_set(pVBInfo
->P3c4
, 0x2C, 0xE1);
7493 outb(0x00, pVBInfo
->P3c8
);
7495 for (i
= 0; i
< 256; i
++) {
7496 outb((unsigned char) DAC_TEST_PARMS
[0], (pVBInfo
->P3c8
+ 1));
7497 outb((unsigned char) DAC_TEST_PARMS
[1], (pVBInfo
->P3c8
+ 1));
7498 outb((unsigned char) DAC_TEST_PARMS
[2], (pVBInfo
->P3c8
+ 1));
7501 XGI_VBLongWait(pVBInfo
);
7502 XGI_VBLongWait(pVBInfo
);
7503 XGI_VBLongWait(pVBInfo
);
7507 XGI_WaitDisply(pVBInfo
);
7508 temp
= inb(pVBInfo
->P3c2
);
7511 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x32, 0xDF, 0x20);
7513 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x32, 0xDF, 0x00);
7515 /* alan, avoid display something, set BLACK DAC if not restore DAC */
7516 outb(0x00, pVBInfo
->P3c8
);
7518 for (i
= 0; i
< 256; i
++) {
7519 outb(0, (pVBInfo
->P3c8
+ 1));
7520 outb(0, (pVBInfo
->P3c8
+ 1));
7521 outb(0, (pVBInfo
->P3c8
+ 1));
7524 xgifb_reg_set(pVBInfo
->P3c4
, 0x01, SR01
);
7525 xgifb_reg_set(pVBInfo
->P3d4
, 0x63, CR63
);
7526 xgifb_reg_set(pVBInfo
->P3c4
, 0x31, SR31
);
7528 /* [2004/05/11] Vicent */
7529 xgifb_reg_set(pVBInfo
->P3d4
, 0x53, (unsigned char) (xgifb_reg_get(
7530 pVBInfo
->P3d4
, 0x53) & 0xFD));
7531 xgifb_reg_set(pVBInfo
->P3c4
, 0x1F, (unsigned char) SR1F
);
7534 void XGI_EnableBridge(struct xgi_hw_device_info
*HwDeviceExtension
,
7535 struct vb_device_info
*pVBInfo
)
7537 unsigned short tempah
;
7539 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
| VB_XGI301LV
7540 | VB_XGI302LV
| VB_XGI301C
)) {
7541 if (!(pVBInfo
->SetFlag
& DisableChA
)) {
7542 if (pVBInfo
->SetFlag
& EnableChA
) {
7544 xgifb_reg_set(pVBInfo
->Part1Port
, 0x1E, 0x20);
7546 /* SetCRT2ToLCDA ) */
7547 if (pVBInfo
->VBInfo
& SetCRT2ToDualEdge
) {
7549 xgifb_reg_set(pVBInfo
->Part1Port
,
7555 if (!(pVBInfo
->SetFlag
& DisableChB
)) {
7556 if ((pVBInfo
->SetFlag
& EnableChB
) || (pVBInfo
->VBInfo
7557 & (SetCRT2ToLCD
| SetCRT2ToTV
7558 | SetCRT2ToRAMDAC
))) {
7559 tempah
= (unsigned char) xgifb_reg_get(
7560 pVBInfo
->P3c4
, 0x32);
7562 if (pVBInfo
->VBInfo
& SetInSlaveMode
) {
7563 if (!(pVBInfo
->VBInfo
&
7567 xgifb_reg_set(pVBInfo
->P3c4
, 0x32, tempah
);
7568 xgifb_reg_or(pVBInfo
->P3c4
, 0x1E, 0x20);
7570 tempah
= (unsigned char) xgifb_reg_get(
7571 pVBInfo
->Part1Port
, 0x2E);
7573 if (!(tempah
& 0x80))
7574 /* BVBDOENABLE = 1 */
7575 xgifb_reg_or(pVBInfo
->Part1Port
,
7577 /* BScreenOFF = 0 */
7578 xgifb_reg_and(pVBInfo
->Part1Port
, 0x00, 0x7F);
7582 if ((pVBInfo
->SetFlag
& (EnableChA
| EnableChB
))
7583 || (!(pVBInfo
->VBInfo
& DisableCRT2Display
))) {
7584 xgifb_reg_and_or(pVBInfo
->Part2Port
, 0x00, ~0xE0,
7585 0x20); /* shampoo 0129 */
7586 if (pVBInfo
->VBType
& (VB_XGI302LV
| VB_XGI301C
)) {
7587 if (!XGI_DisableChISLCD(pVBInfo
)) {
7588 if (XGI_EnableChISLCD(pVBInfo
) ||
7590 (SetCRT2ToLCD
| SetCRT2ToLCDA
)))
7591 /* LVDS PLL power on */
7597 /* LVDS Driver power on */
7598 xgifb_reg_and(pVBInfo
->Part4Port
, 0x30, 0x7F);
7604 if (!(pVBInfo
->VBInfo
& DisableCRT2Display
)) {
7607 if (!(pVBInfo
->VBInfo
& SetSimuScanMode
)) {
7608 if (pVBInfo
->VBInfo
& SetCRT2ToLCDA
) {
7609 if (pVBInfo
->VBInfo
&
7610 SetCRT2ToDualEdge
) {
7611 tempah
= tempah
& 0x40;
7612 if (pVBInfo
->VBInfo
&
7614 tempah
= tempah
^ 0xC0;
7616 if (pVBInfo
->SetFlag
&
7620 if (pVBInfo
->SetFlag
&
7624 if (pVBInfo
->SetFlag
&
7628 if (pVBInfo
->SetFlag
&
7636 /* EnablePart4_1F */
7637 xgifb_reg_or(pVBInfo
->Part4Port
, 0x1F, tempah
);
7639 if (!(pVBInfo
->SetFlag
& DisableChA
)) {
7640 XGI_VBLongWait(pVBInfo
);
7641 if (!(pVBInfo
->SetFlag
& GatingCRT
)) {
7642 XGI_DisableGatingCRT(HwDeviceExtension
,
7644 XGI_DisplayOn(HwDeviceExtension
, pVBInfo
);
7645 XGI_VBLongWait(pVBInfo
);
7650 if (pVBInfo
->VBInfo
& (SetCRT2ToTV
| SetCRT2ToLCD
7653 xgifb_reg_or(pVBInfo
->Part1Port
, 0x1E, 0x20);
7655 tempah
= (unsigned char) xgifb_reg_get(pVBInfo
->Part1Port
,
7657 if (!(tempah
& 0x80))
7658 /* BVBDOENABLE = 1 */
7659 xgifb_reg_or(pVBInfo
->Part1Port
, 0x2E, 0x80);
7661 xgifb_reg_and(pVBInfo
->Part1Port
, 0x00, 0x7F);
7662 XGI_DisplayOn(HwDeviceExtension
, pVBInfo
);
7666 static void XGI_SetCRT1Group(struct xgi_hw_device_info
*HwDeviceExtension
,
7667 unsigned short ModeNo
, unsigned short ModeIdIndex
,
7668 struct vb_device_info
*pVBInfo
)
7670 unsigned short StandTableIndex
, RefreshRateTableIndex
, b3CC
, temp
;
7672 unsigned short XGINew_P3cc
= pVBInfo
->P3cc
;
7674 /* XGINew_CRT1Mode = ModeNo; // SaveModeID */
7675 StandTableIndex
= XGI_GetModePtr(ModeNo
, ModeIdIndex
, pVBInfo
);
7676 /* XGI_SetBIOSData(ModeNo, ModeIdIndex); */
7677 /* XGI_ClearBankRegs(ModeNo, ModeIdIndex); */
7678 XGI_SetSeqRegs(ModeNo
, StandTableIndex
, ModeIdIndex
, pVBInfo
);
7679 XGI_SetMiscRegs(StandTableIndex
, pVBInfo
);
7680 XGI_SetCRTCRegs(HwDeviceExtension
, StandTableIndex
, pVBInfo
);
7681 XGI_SetATTRegs(ModeNo
, StandTableIndex
, ModeIdIndex
, pVBInfo
);
7682 XGI_SetGRCRegs(StandTableIndex
, pVBInfo
);
7683 XGI_ClearExt1Regs(pVBInfo
);
7685 /* if (pVBInfo->IF_DEF_ExpLink) */
7686 if (HwDeviceExtension
->jChipType
== XG27
) {
7687 if (pVBInfo
->IF_DEF_LVDS
== 0)
7688 XGI_SetDefaultVCLK(pVBInfo
);
7691 temp
= ~ProgrammingCRT2
;
7692 pVBInfo
->SetFlag
&= temp
;
7693 pVBInfo
->SelectCRT2Rate
= 0;
7695 if (pVBInfo
->VBType
& (VB_XGI301B
| VB_XGI302B
| VB_XGI301LV
7696 | VB_XGI302LV
| VB_XGI301C
)) {
7697 if (pVBInfo
->VBInfo
& (SetSimuScanMode
| SetCRT2ToLCDA
7698 | SetInSlaveMode
)) {
7699 pVBInfo
->SetFlag
|= ProgrammingCRT2
;
7703 RefreshRateTableIndex
= XGI_GetRatePtrCRT2(HwDeviceExtension
, ModeNo
,
7704 ModeIdIndex
, pVBInfo
);
7705 if (RefreshRateTableIndex
!= 0xFFFF) {
7706 XGI_SetSync(RefreshRateTableIndex
, pVBInfo
);
7707 XGI_SetCRT1CRTC(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
7708 pVBInfo
, HwDeviceExtension
);
7709 XGI_SetCRT1DE(HwDeviceExtension
, ModeNo
, ModeIdIndex
,
7710 RefreshRateTableIndex
, pVBInfo
);
7711 XGI_SetCRT1Offset(ModeNo
, ModeIdIndex
, RefreshRateTableIndex
,
7712 HwDeviceExtension
, pVBInfo
);
7713 XGI_SetCRT1VCLK(ModeNo
, ModeIdIndex
, HwDeviceExtension
,
7714 RefreshRateTableIndex
, pVBInfo
);
7717 if ((HwDeviceExtension
->jChipType
>= XG20
) &&
7718 (HwDeviceExtension
->jChipType
< XG27
)) { /* fix H/W DCLK/2 bug */
7719 if ((ModeNo
== 0x00) | (ModeNo
== 0x01)) {
7720 xgifb_reg_set(pVBInfo
->P3c4
, 0x2B, 0x4E);
7721 xgifb_reg_set(pVBInfo
->P3c4
, 0x2C, 0xE9);
7722 b3CC
= (unsigned char) inb(XGINew_P3cc
);
7723 outb((b3CC
|= 0x0C), XGINew_P3cc
);
7724 } else if ((ModeNo
== 0x04) | (ModeNo
== 0x05) | (ModeNo
7726 xgifb_reg_set(pVBInfo
->P3c4
, 0x2B, 0x1B);
7727 xgifb_reg_set(pVBInfo
->P3c4
, 0x2C, 0xE3);
7728 b3CC
= (unsigned char) inb(XGINew_P3cc
);
7729 outb((b3CC
|= 0x0C), XGINew_P3cc
);
7733 if (HwDeviceExtension
->jChipType
>= XG21
) {
7734 temp
= xgifb_reg_get(pVBInfo
->P3d4
, 0x38);
7737 /* Enable write GPIOF */
7738 /* xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x20); */
7740 /* xgifb_reg_and(pVBInfo->P3d4, 0x48, ~0x20); */
7741 /* XG21 CRT1 Timing */
7742 if (HwDeviceExtension
->jChipType
== XG27
)
7743 XGI_SetXG27CRTC(ModeNo
, ModeIdIndex
,
7744 RefreshRateTableIndex
, pVBInfo
);
7746 XGI_SetXG21CRTC(ModeNo
, ModeIdIndex
,
7747 RefreshRateTableIndex
, pVBInfo
);
7749 XGI_UpdateXG21CRTC(ModeNo
, pVBInfo
,
7750 RefreshRateTableIndex
);
7752 xgifb_set_lcd(HwDeviceExtension
->jChipType
,
7753 pVBInfo
, RefreshRateTableIndex
, ModeNo
);
7755 if (pVBInfo
->IF_DEF_LVDS
== 1)
7756 xgifb_set_lvds(HwDeviceExtension
->jChipType
,
7757 ModeNo
, ModeIdIndex
, pVBInfo
);
7759 /* xgifb_reg_or(pVBInfo->P3d4, 0x48, 0x20); */
7763 pVBInfo
->SetFlag
&= (~ProgrammingCRT2
);
7764 XGI_SetCRT1FIFO(ModeNo
, HwDeviceExtension
, pVBInfo
);
7765 XGI_SetCRT1ModeRegs(HwDeviceExtension
, ModeNo
, ModeIdIndex
,
7766 RefreshRateTableIndex
, pVBInfo
);
7768 /* XGI_LoadCharacter(); //dif ifdef TVFont */
7770 XGI_LoadDAC(ModeNo
, ModeIdIndex
, pVBInfo
);
7771 /* XGI_ClearBuffer(HwDeviceExtension, ModeNo, pVBInfo); */
7774 unsigned char XGISetModeNew(struct xgi_hw_device_info
*HwDeviceExtension
,
7775 unsigned short ModeNo
)
7777 unsigned short ModeIdIndex
;
7778 /* unsigned char *pVBInfo->FBAddr =
7779 HwDeviceExtension->pjVideoMemoryAddress; */
7780 struct vb_device_info VBINF
;
7781 struct vb_device_info
*pVBInfo
= &VBINF
;
7782 pVBInfo
->ROMAddr
= HwDeviceExtension
->pjVirtualRomBase
;
7783 pVBInfo
->BaseAddr
= (unsigned long) HwDeviceExtension
->pjIOAddress
;
7784 pVBInfo
->IF_DEF_LVDS
= 0;
7785 pVBInfo
->IF_DEF_LCDA
= 1;
7787 if (HwDeviceExtension
->jChipType
>= XG20
) { /* kuku 2004/06/25 */
7788 pVBInfo
->IF_DEF_YPbPr
= 0;
7789 pVBInfo
->IF_DEF_HiVision
= 0;
7790 pVBInfo
->IF_DEF_CRT2Monitor
= 0;
7791 pVBInfo
->VBType
= 0; /*set VBType default 0*/
7793 pVBInfo
->IF_DEF_YPbPr
= 1;
7794 pVBInfo
->IF_DEF_HiVision
= 1;
7795 pVBInfo
->IF_DEF_CRT2Monitor
= 1;
7798 pVBInfo
->P3c4
= pVBInfo
->BaseAddr
+ 0x14;
7799 pVBInfo
->P3d4
= pVBInfo
->BaseAddr
+ 0x24;
7800 pVBInfo
->P3c0
= pVBInfo
->BaseAddr
+ 0x10;
7801 pVBInfo
->P3ce
= pVBInfo
->BaseAddr
+ 0x1e;
7802 pVBInfo
->P3c2
= pVBInfo
->BaseAddr
+ 0x12;
7803 pVBInfo
->P3cc
= pVBInfo
->BaseAddr
+ 0x1C;
7804 pVBInfo
->P3ca
= pVBInfo
->BaseAddr
+ 0x1a;
7805 pVBInfo
->P3c6
= pVBInfo
->BaseAddr
+ 0x16;
7806 pVBInfo
->P3c7
= pVBInfo
->BaseAddr
+ 0x17;
7807 pVBInfo
->P3c8
= pVBInfo
->BaseAddr
+ 0x18;
7808 pVBInfo
->P3c9
= pVBInfo
->BaseAddr
+ 0x19;
7809 pVBInfo
->P3da
= pVBInfo
->BaseAddr
+ 0x2A;
7810 pVBInfo
->Part0Port
= pVBInfo
->BaseAddr
+ XGI_CRT2_PORT_00
;
7811 pVBInfo
->Part1Port
= pVBInfo
->BaseAddr
+ XGI_CRT2_PORT_04
;
7812 pVBInfo
->Part2Port
= pVBInfo
->BaseAddr
+ XGI_CRT2_PORT_10
;
7813 pVBInfo
->Part3Port
= pVBInfo
->BaseAddr
+ XGI_CRT2_PORT_12
;
7814 pVBInfo
->Part4Port
= pVBInfo
->BaseAddr
+ XGI_CRT2_PORT_14
;
7815 pVBInfo
->Part5Port
= pVBInfo
->BaseAddr
+ XGI_CRT2_PORT_14
+ 2;
7817 /* for x86 Linux, XG21 LVDS */
7818 if (HwDeviceExtension
->jChipType
== XG21
) {
7819 if ((xgifb_reg_get(pVBInfo
->P3d4
, 0x38) & 0xE0) == 0xC0)
7820 pVBInfo
->IF_DEF_LVDS
= 1;
7822 if (HwDeviceExtension
->jChipType
== XG27
) {
7823 if ((xgifb_reg_get(pVBInfo
->P3d4
, 0x38) & 0xE0) == 0xC0) {
7824 if (xgifb_reg_get(pVBInfo
->P3d4
, 0x30) & 0x20)
7825 pVBInfo
->IF_DEF_LVDS
= 1;
7829 if (HwDeviceExtension
->jChipType
< XG20
) /* kuku 2004/06/25 */
7830 XGI_GetVBType(pVBInfo
);
7832 InitTo330Pointer(HwDeviceExtension
->jChipType
, pVBInfo
);
7833 if (ModeNo
& 0x80) {
7834 ModeNo
= ModeNo
& 0x7F;
7835 /* XGINew_flag_clearbuffer = 0; */
7838 XGINew_flag_clearbuffer = 1;
7841 xgifb_reg_set(pVBInfo
->P3c4
, 0x05, 0x86);
7843 if (HwDeviceExtension
->jChipType
< XG20
) /* kuku 2004/06/25 1.Openkey */
7844 XGI_UnLockCRT2(HwDeviceExtension
, pVBInfo
);
7846 XGI_SearchModeID(ModeNo
, &ModeIdIndex
, pVBInfo
);
7848 XGI_GetVGAType(HwDeviceExtension
, pVBInfo
);
7850 if (HwDeviceExtension
->jChipType
< XG20
) { /* kuku 2004/06/25 */
7851 XGI_GetVBInfo(ModeNo
, ModeIdIndex
, HwDeviceExtension
, pVBInfo
);
7852 XGI_GetTVInfo(ModeNo
, ModeIdIndex
, pVBInfo
);
7853 XGI_GetLCDInfo(ModeNo
, ModeIdIndex
, pVBInfo
);
7854 XGI_DisableBridge(HwDeviceExtension
, pVBInfo
);
7856 if (pVBInfo
->VBInfo
& (SetSimuScanMode
| SetCRT2ToLCDA
)) {
7857 XGI_SetCRT1Group(HwDeviceExtension
, ModeNo
,
7858 ModeIdIndex
, pVBInfo
);
7860 if (pVBInfo
->VBInfo
& SetCRT2ToLCDA
) {
7861 XGI_SetLCDAGroup(ModeNo
, ModeIdIndex
,
7862 HwDeviceExtension
, pVBInfo
);
7865 if (!(pVBInfo
->VBInfo
& SwitchToCRT2
)) {
7866 XGI_SetCRT1Group(HwDeviceExtension
, ModeNo
,
7867 ModeIdIndex
, pVBInfo
);
7868 if (pVBInfo
->VBInfo
& SetCRT2ToLCDA
) {
7869 XGI_SetLCDAGroup(ModeNo
, ModeIdIndex
,
7876 if (pVBInfo
->VBInfo
& (SetSimuScanMode
| SwitchToCRT2
)) {
7877 switch (HwDeviceExtension
->ujVBChipID
) {
7879 XGI_SetCRT2Group301(ModeNo
, HwDeviceExtension
,
7880 pVBInfo
); /*add for CRT2 */
7884 XGI_SetCRT2Group301(ModeNo
, HwDeviceExtension
,
7885 pVBInfo
); /*add for CRT2 */
7893 XGI_SetCRT2ModeRegs(ModeNo
, HwDeviceExtension
, pVBInfo
);
7894 XGI_OEM310Setting(ModeNo
, ModeIdIndex
, pVBInfo
); /*0212*/
7895 XGI_CloseCRTC(HwDeviceExtension
, pVBInfo
);
7896 XGI_EnableBridge(HwDeviceExtension
, pVBInfo
);
7899 if (pVBInfo
->IF_DEF_LVDS
== 1)
7900 if (!XGI_XG21CheckLVDSMode(ModeNo
,
7905 if (ModeNo
<= 0x13) {
7906 pVBInfo
->ModeType
= pVBInfo
->SModeIDTable
[ModeIdIndex
].
7907 St_ModeFlag
& ModeInfoFlag
;
7909 pVBInfo
->ModeType
= pVBInfo
->EModeIDTable
[ModeIdIndex
].
7910 Ext_ModeFlag
& ModeInfoFlag
;
7913 pVBInfo
->SetFlag
= 0;
7914 pVBInfo
->VBInfo
= DisableCRT2Display
;
7916 XGI_DisplayOff(HwDeviceExtension
, pVBInfo
);
7918 XGI_SetCRT1Group(HwDeviceExtension
, ModeNo
, ModeIdIndex
,
7921 XGI_DisplayOn(HwDeviceExtension
, pVBInfo
);
7923 if (HwDeviceExtension->jChipType == XG21)
7924 xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0x80, 0x80);
7929 if (ModeNo <= 0x13) {
7930 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
7932 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
7934 pVBInfo->ModeType = modeflag&ModeInfoFlag;
7935 pVBInfo->SetFlag = 0x00;
7936 pVBInfo->VBInfo = DisableCRT2Display;
7937 temp = XGINew_CheckMemorySize(HwDeviceExtension,
7945 XGI_DisplayOff(HwDeviceExtension, pVBInfo) ;
7946 XGI_SetCRT1Group(HwDeviceExtension, ModeNo, ModeIdIndex, pVBInfo);
7947 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
7950 XGI_UpdateModeInfo(HwDeviceExtension
, pVBInfo
);
7952 if (HwDeviceExtension
->jChipType
< XG20
) { /* kuku 2004/06/25 */
7953 XGI_LockCRT2(HwDeviceExtension
, pVBInfo
);