1 #include <linux/delay.h>
8 #include "vb_setmode.h"
10 #define IndexMask 0xff
11 #define TVCLKBASE_315_25 (TVCLKBASE_315 + 25)
13 static const unsigned short XGINew_VGA_DAC[] = {
14 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
15 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
16 0x00, 0x05, 0x08, 0x0B, 0x0E, 0x11, 0x14, 0x18,
17 0x1C, 0x20, 0x24, 0x28, 0x2D, 0x32, 0x38, 0x3F,
18 0x00, 0x10, 0x1F, 0x2F, 0x3F, 0x1F, 0x27, 0x2F,
19 0x37, 0x3F, 0x2D, 0x31, 0x36, 0x3A, 0x3F, 0x00,
20 0x07, 0x0E, 0x15, 0x1C, 0x0E, 0x11, 0x15, 0x18,
21 0x1C, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x00, 0x04,
22 0x08, 0x0C, 0x10, 0x08, 0x0A, 0x0C, 0x0E, 0x10,
23 0x0B, 0x0C, 0x0D, 0x0F, 0x10};
25 void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo)
27 pVBInfo->MCLKData = XGI340New_MCLKData;
29 pVBInfo->LCDResInfo = 0;
30 pVBInfo->LCDTypeInfo = 0;
35 pVBInfo->SR18 = XGI340_SR18;
36 pVBInfo->CR40 = XGI340_cr41;
38 /* 310 customization related */
39 if ((pVBInfo->VBType & VB_SIS301LV) || (pVBInfo->VBType & VB_SIS302LV))
40 pVBInfo->LCDCapList = XGI_LCDDLCapList;
42 pVBInfo->LCDCapList = XGI_LCDCapList;
45 pVBInfo->XGINew_CR97 = 0x10;
47 if (ChipType == XG27) {
49 pVBInfo->MCLKData = XGI27New_MCLKData;
50 pVBInfo->CR40 = XGI27_cr41;
51 pVBInfo->XGINew_CR97 = 0xc1;
52 pVBInfo->SR18 = XG27_SR18;
55 temp = xgifb_reg_get(pVBInfo->P3c4, 0x3B);
56 /* SR3B[7][3]MAA15 MAA11 (Power on Trapping) */
57 if (((temp & 0x88) == 0x80) || ((temp & 0x88) == 0x08))
58 pVBInfo->XGINew_CR97 = 0x80;
63 static void XGI_SetSeqRegs(unsigned short ModeNo,
64 unsigned short ModeIdIndex,
65 struct vb_device_info *pVBInfo)
67 unsigned char SRdata, i;
69 xgifb_reg_set(pVBInfo->P3c4, 0x00, 0x03); /* Set SR0 */
71 for (i = 0; i < 4; i++) {
72 /* Get SR1,2,3,4 from file */
73 /* SR1 is with screen off 0x20 */
74 SRdata = XGI330_StandTable.SR[i];
75 xgifb_reg_set(pVBInfo->P3c4, i+1, SRdata); /* Set SR 1 2 3 4 */
79 static void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension,
80 struct vb_device_info *pVBInfo)
82 unsigned char CRTCdata;
85 CRTCdata = xgifb_reg_get(pVBInfo->P3d4, 0x11);
87 xgifb_reg_set(pVBInfo->P3d4, 0x11, CRTCdata); /* Unlock CRTC */
89 for (i = 0; i <= 0x18; i++) {
90 /* Get CRTC from file */
91 CRTCdata = XGI330_StandTable.CRTC[i];
92 xgifb_reg_set(pVBInfo->P3d4, i, CRTCdata); /* Set CRTC(3d4) */
96 static void XGI_SetATTRegs(unsigned short ModeNo,
97 unsigned short ModeIdIndex,
98 struct vb_device_info *pVBInfo)
100 unsigned char ARdata;
101 unsigned short i, modeflag;
103 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
105 for (i = 0; i <= 0x13; i++) {
106 ARdata = XGI330_StandTable.ATTR[i];
108 if ((modeflag & Charx8Dot) && i == 0x13) { /* ifndef Dot9 */
109 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
111 } else if ((pVBInfo->VBInfo &
112 (SetCRT2ToTV | SetCRT2ToLCD)) &&
113 (pVBInfo->VBInfo & SetInSlaveMode)) {
118 inb(pVBInfo->P3da); /* reset 3da */
119 outb(i, pVBInfo->P3c0); /* set index */
120 outb(ARdata, pVBInfo->P3c0); /* set data */
123 inb(pVBInfo->P3da); /* reset 3da */
124 outb(0x14, pVBInfo->P3c0); /* set index */
125 outb(0x00, pVBInfo->P3c0); /* set data */
126 inb(pVBInfo->P3da); /* Enable Attribute */
127 outb(0x20, pVBInfo->P3c0);
130 static void XGI_SetGRCRegs(struct vb_device_info *pVBInfo)
132 unsigned char GRdata;
135 for (i = 0; i <= 0x08; i++) {
136 /* Get GR from file */
137 GRdata = XGI330_StandTable.GRC[i];
138 xgifb_reg_set(pVBInfo->P3ce, i, GRdata); /* Set GR(3ce) */
141 if (pVBInfo->ModeType > ModeVGA) {
142 GRdata = xgifb_reg_get(pVBInfo->P3ce, 0x05);
143 GRdata &= 0xBF; /* 256 color disable */
144 xgifb_reg_set(pVBInfo->P3ce, 0x05, GRdata);
148 static void XGI_ClearExt1Regs(struct vb_device_info *pVBInfo)
152 for (i = 0x0A; i <= 0x0E; i++)
153 xgifb_reg_set(pVBInfo->P3c4, i, 0x00); /* Clear SR0A-SR0E */
156 static unsigned char XGI_SetDefaultVCLK(struct vb_device_info *pVBInfo)
159 xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x20);
160 xgifb_reg_set(pVBInfo->P3c4, 0x2B, XGI_VCLKData[0].SR2B);
161 xgifb_reg_set(pVBInfo->P3c4, 0x2C, XGI_VCLKData[0].SR2C);
163 xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x10);
164 xgifb_reg_set(pVBInfo->P3c4, 0x2B, XGI_VCLKData[1].SR2B);
165 xgifb_reg_set(pVBInfo->P3c4, 0x2C, XGI_VCLKData[1].SR2C);
167 xgifb_reg_and(pVBInfo->P3c4, 0x31, ~0x30);
171 static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo,
172 unsigned short ModeIdIndex,
173 unsigned short RefreshRateTableIndex, unsigned short *i,
174 struct vb_device_info *pVBInfo)
176 unsigned short tempax, tempbx, resinfo, modeflag, infoflag;
178 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
179 resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO;
180 tempbx = XGI330_RefIndex[RefreshRateTableIndex + (*i)].ModeID;
183 if (pVBInfo->IF_DEF_LVDS == 0) {
184 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
185 tempax |= SupportRAMDAC2;
187 if (pVBInfo->VBType & VB_XGI301C)
188 tempax |= SupportCRT2in301C;
192 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
193 tempax |= SupportLCD;
195 if (pVBInfo->LCDResInfo != Panel_1280x1024 &&
196 pVBInfo->LCDResInfo != Panel_1280x960 &&
197 (pVBInfo->LCDInfo & LCDNonExpanding) &&
202 if (pVBInfo->VBInfo & SetCRT2ToHiVision) { /* for HiTV */
203 tempax |= SupportHiVision;
204 if ((pVBInfo->VBInfo & SetInSlaveMode) &&
207 (pVBInfo->SetFlag & TVSimuMode)) ||
210 } else if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO |
213 SetCRT2ToYPbPr525750 |
214 SetCRT2ToHiVision)) {
217 if (pVBInfo->VBType & (VB_SIS301B |
222 tempax |= SupportTV1024;
224 if (!(pVBInfo->VBInfo & TVSetPAL) &&
225 (modeflag & NoSupportSimuTV) &&
226 (pVBInfo->VBInfo & SetInSlaveMode) &&
227 (!(pVBInfo->VBInfo & SetNotSimuMode)))
230 } else if (pVBInfo->VBInfo & SetCRT2ToLCD) { /* for LVDS */
231 tempax |= SupportLCD;
234 return 0; /* 1024x768 */
236 if (pVBInfo->LCDResInfo < Panel_1024x768) {
238 return 0; /* 800x600 */
241 return 0; /* 512x384 */
245 for (; XGI330_RefIndex[RefreshRateTableIndex + (*i)].ModeID ==
247 infoflag = XGI330_RefIndex[RefreshRateTableIndex + (*i)].
249 if (infoflag & tempax)
256 for ((*i) = 0;; (*i)++) {
257 infoflag = XGI330_RefIndex[RefreshRateTableIndex + (*i)].
259 if (XGI330_RefIndex[RefreshRateTableIndex + (*i)].ModeID
264 if (infoflag & tempax)
270 static void XGI_SetSync(unsigned short RefreshRateTableIndex,
271 struct vb_device_info *pVBInfo)
273 unsigned short sync, temp;
276 sync = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag >> 8;
280 outb(temp, pVBInfo->P3c2); /* Set Misc(3c2) */
283 static void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo,
284 struct xgi_hw_device_info *HwDeviceExtension)
286 unsigned char data, data1, pushax;
290 data = xgifb_reg_get(pVBInfo->P3d4, 0x11);
292 xgifb_reg_set(pVBInfo->P3d4, 0x11, data);
294 data = pVBInfo->TimingH.data[0];
295 xgifb_reg_set(pVBInfo->P3d4, 0, data);
297 for (i = 0x01; i <= 0x04; i++) {
298 data = pVBInfo->TimingH.data[i];
299 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 1), data);
302 for (i = 0x05; i <= 0x06; i++) {
303 data = pVBInfo->TimingH.data[i];
304 xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i + 6), data);
307 j = xgifb_reg_get(pVBInfo->P3c4, 0x0e);
309 data = pVBInfo->TimingH.data[7];
312 xgifb_reg_set(pVBInfo->P3c4, 0x0e, data);
314 if (HwDeviceExtension->jChipType >= XG20) {
315 data = xgifb_reg_get(pVBInfo->P3d4, 0x04);
317 xgifb_reg_set(pVBInfo->P3d4, 0x04, data);
318 data = xgifb_reg_get(pVBInfo->P3d4, 0x05);
324 data = xgifb_reg_get(pVBInfo->P3c4, 0x0c);
326 xgifb_reg_set(pVBInfo->P3c4, 0x0c, data);
331 xgifb_reg_set(pVBInfo->P3d4, 0x05, data);
332 data = xgifb_reg_get(pVBInfo->P3c4, 0x0e);
338 xgifb_reg_and_or(pVBInfo->P3c4, 0x0e, ~0xE0, data);
342 static void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex,
343 unsigned short ModeNo,
344 struct vb_device_info *pVBInfo)
349 for (i = 0x00; i <= 0x01; i++) {
350 data = pVBInfo->TimingV.data[i];
351 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 6), data);
354 for (i = 0x02; i <= 0x03; i++) {
355 data = pVBInfo->TimingV.data[i];
356 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x0e), data);
359 for (i = 0x04; i <= 0x05; i++) {
360 data = pVBInfo->TimingV.data[i];
361 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x11), data);
364 j = xgifb_reg_get(pVBInfo->P3c4, 0x0a);
366 data = pVBInfo->TimingV.data[6];
369 xgifb_reg_set(pVBInfo->P3c4, 0x0a, data);
371 data = pVBInfo->TimingV.data[6];
375 i = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
380 j = xgifb_reg_get(pVBInfo->P3d4, 0x09);
383 xgifb_reg_set(pVBInfo->P3d4, 0x09, data);
386 static void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
387 unsigned short RefreshRateTableIndex,
388 struct vb_device_info *pVBInfo,
389 struct xgi_hw_device_info *HwDeviceExtension)
391 unsigned char index, data;
395 index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
396 index = index & IndexMask;
398 data = xgifb_reg_get(pVBInfo->P3d4, 0x11);
400 xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */
402 for (i = 0; i < 8; i++)
403 pVBInfo->TimingH.data[i]
404 = XGI_CRT1Table[index].CR[i];
406 for (i = 0; i < 7; i++)
407 pVBInfo->TimingV.data[i]
408 = XGI_CRT1Table[index].CR[i + 8];
410 XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension);
412 XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo);
414 if (pVBInfo->ModeType > 0x03)
415 xgifb_reg_set(pVBInfo->P3d4, 0x14, 0x4F);
418 /* --------------------------------------------------------------------- */
419 /* Function : XGI_SetXG21CRTC */
420 /* Input : Stand or enhance CRTC table */
421 /* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */
422 /* Description : Set LCD timing */
423 /* --------------------------------------------------------------------- */
424 static void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
425 unsigned short RefreshRateTableIndex,
426 struct vb_device_info *pVBInfo)
428 unsigned char index, Tempax, Tempbx, Tempcx, Tempdx;
429 unsigned short Temp1, Temp2, Temp3;
431 index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
432 /* Tempax: CR4 HRS */
433 Tempax = XGI_CRT1Table[index].CR[3];
434 Tempcx = Tempax; /* Tempcx: HRS */
436 xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax);
438 Tempdx = XGI_CRT1Table[index].CR[5]; /* SRB */
439 Tempdx &= 0xC0; /* Tempdx[7:6]: SRB[7:6] */
440 Temp1 = Tempdx; /* Temp1[7:6]: HRS[9:8] */
441 Temp1 <<= 2; /* Temp1[9:8]: HRS[9:8] */
442 Temp1 |= Tempax; /* Temp1[9:0]: HRS[9:0] */
444 Tempax = XGI_CRT1Table[index].CR[4]; /* CR5 HRE */
445 Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */
447 Tempbx = XGI_CRT1Table[index].CR[6]; /* SRC */
448 Tempbx &= 0x04; /* Tempbx[2]: HRE[5] */
449 Tempbx <<= 3; /* Tempbx[5]: HRE[5] */
450 Tempax |= Tempbx; /* Tempax[5:0]: HRE[5:0] */
452 Temp2 = Temp1 & 0x3C0; /* Temp2[9:6]: HRS[9:6] */
453 Temp2 |= Tempax; /* Temp2[9:0]: HRE[9:0] */
455 Tempcx &= 0x3F; /* Tempcx[5:0]: HRS[5:0] */
456 if (Tempax < Tempcx) /* HRE < HRS */
457 Temp2 |= 0x40; /* Temp2 + 0x40 */
460 Tempax = (unsigned char) Temp2; /* Tempax: HRE[7:0] */
461 Tempax <<= 2; /* Tempax[7:2]: HRE[5:0] */
462 Tempdx >>= 6; /* Tempdx[7:6]->[1:0] HRS[9:8] */
463 Tempax |= Tempdx; /* HRE[5:0]HRS[9:8] */
464 /* SR2F D[7:2]->HRE, D[1:0]->HRS */
465 xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax);
466 xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00);
469 Tempax = XGI_CRT1Table[index].CR[10];
470 Tempbx = Tempax; /* Tempbx: VRS */
471 Tempax &= 0x01; /* Tempax[0]: VRS[0] */
472 xgifb_reg_or(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS[0] */
474 Tempax = XGI_CRT1Table[index].CR[9];
475 Tempcx = Tempbx >> 1; /* Tempcx[6:0]: VRS[7:1] */
476 Tempdx = Tempax & 0x04; /* Tempdx[2]: CR7[2] */
477 Tempdx <<= 5; /* Tempdx[7]: VRS[8] */
478 Tempcx |= Tempdx; /* Tempcx[7:0]: VRS[8:1] */
479 xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempcx); /* SR34[8:1]->VRS */
481 Temp1 = Tempdx; /* Temp1[7]: Tempdx[7] */
482 Temp1 <<= 1; /* Temp1[8]: VRS[8] */
483 Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */
485 Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */
486 Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */
488 Tempax = XGI_CRT1Table[index].CR[14];
489 Tempax &= 0x08; /* Tempax[3]: VRS[3] */
491 Temp2 <<= 7; /* Temp2[10]: VRS[10] */
492 Temp1 |= Temp2; /* Temp1[10:0]: VRS[10:0] */
494 /* Tempax: CR11 VRE */
495 Tempax = XGI_CRT1Table[index].CR[11];
496 Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
498 Tempbx = XGI_CRT1Table[index].CR[14];
499 Tempbx &= 0x20; /* Tempbx[5]: VRE[5] */
500 Tempbx >>= 1; /* Tempbx[4]: VRE[4] */
501 Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */
502 Temp2 = Temp1 & 0x7E0; /* Temp2[10:5]: VRS[10:5] */
503 Temp2 |= Tempax; /* Temp2[10:5]: VRE[10:5] */
505 Temp3 = Temp1 & 0x1F; /* Temp3[4:0]: VRS[4:0] */
506 if (Tempax < Temp3) /* VRE < VRS */
507 Temp2 |= 0x20; /* VRE + 0x20 */
510 Tempax = (unsigned char) Temp2; /* Tempax: VRE[7:0] */
511 Tempax <<= 2; /* Tempax[7:0]; VRE[5:0]00 */
512 Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */
513 Temp1 >>= 9; /* Temp1[1:0]: VRS[10:9] */
514 Tempbx = (unsigned char) Temp1;
515 Tempax |= Tempbx; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */
517 /* SR3F D[7:2]->VRE D[1:0]->VRS */
518 xgifb_reg_set(pVBInfo->P3c4, 0x3F, Tempax);
521 static void XGI_SetXG27CRTC(unsigned short ModeNo,
522 unsigned short ModeIdIndex,
523 unsigned short RefreshRateTableIndex,
524 struct vb_device_info *pVBInfo)
526 unsigned short index, Tempax, Tempbx, Tempcx;
528 index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
529 /* Tempax: CR4 HRS */
530 Tempax = XGI_CRT1Table[index].CR[3];
531 Tempbx = Tempax; /* Tempbx: HRS[7:0] */
533 xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax);
536 Tempax = XGI_CRT1Table[index].CR[5];
537 Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
538 Tempbx |= (Tempax << 2); /* Tempbx: HRS[9:0] */
540 Tempax = XGI_CRT1Table[index].CR[4]; /* CR5 HRE */
541 Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */
542 Tempcx = Tempax; /* Tempcx: HRE[4:0] */
544 Tempax = XGI_CRT1Table[index].CR[6]; /* SRC */
545 Tempax &= 0x04; /* Tempax[2]: HRE[5] */
546 Tempax <<= 3; /* Tempax[5]: HRE[5] */
547 Tempcx |= Tempax; /* Tempcx[5:0]: HRE[5:0] */
549 Tempbx = Tempbx & 0x3C0; /* Tempbx[9:6]: HRS[9:6] */
550 Tempbx |= Tempcx; /* Tempbx: HRS[9:6]HRE[5:0] */
552 /* Tempax: CR4 HRS */
553 Tempax = XGI_CRT1Table[index].CR[3];
554 Tempax &= 0x3F; /* Tempax: HRS[5:0] */
555 if (Tempcx <= Tempax) /* HRE[5:0] < HRS[5:0] */
556 Tempbx += 0x40; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/
558 Tempax = XGI_CRT1Table[index].CR[5]; /* SR0B */
559 Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
560 Tempax >>= 6; /* Tempax[1:0]: HRS[9:8]*/
561 Tempax |= ((Tempbx << 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */
562 /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */
563 xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax);
564 xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00);
567 Tempax = XGI_CRT1Table[index].CR[10];
568 /* SR34[7:0]->VRS[7:0] */
569 xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempax);
571 Tempcx = Tempax; /* Tempcx <= VRS[7:0] */
572 /* CR7[7][2] VRS[9][8] */
573 Tempax = XGI_CRT1Table[index].CR[9];
574 Tempbx = Tempax; /* Tempbx <= CR07[7:0] */
575 Tempax = Tempax & 0x04; /* Tempax[2]: CR7[2]: VRS[8] */
576 Tempax >>= 2; /* Tempax[0]: VRS[8] */
577 /* SR35[0]: VRS[8] */
578 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x01, Tempax);
579 Tempcx |= (Tempax << 8); /* Tempcx <= VRS[8:0] */
580 Tempcx |= ((Tempbx & 0x80) << 2); /* Tempcx <= VRS[9:0] */
582 Tempax = XGI_CRT1Table[index].CR[14];
583 Tempax &= 0x08; /* SR0A[3] VRS[10] */
584 Tempcx |= (Tempax << 7); /* Tempcx <= VRS[10:0] */
586 /* Tempax: CR11 VRE */
587 Tempax = XGI_CRT1Table[index].CR[11];
588 Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
590 Tempbx = XGI_CRT1Table[index].CR[14];
591 Tempbx &= 0x20; /* Tempbx[5]: SR0A[5]: VRE[4] */
592 Tempbx >>= 1; /* Tempbx[4]: VRE[4] */
593 Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */
594 Tempbx = Tempcx; /* Tempbx: VRS[10:0] */
595 Tempbx &= 0x7E0; /* Tempbx[10:5]: VRS[10:5] */
596 Tempbx |= Tempax; /* Tempbx: VRS[10:5]VRE[4:0] */
598 if (Tempbx <= Tempcx) /* VRE <= VRS */
599 Tempbx |= 0x20; /* VRE + 0x20 */
601 /* Tempax: Tempax[7:0]; VRE[5:0]00 */
602 Tempax = (Tempbx << 2) & 0xFF;
603 /* SR3F[7:2]:VRE[5:0] */
604 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax);
605 Tempax = Tempcx >> 8;
606 /* SR35[2:0]:VRS[10:8] */
607 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, Tempax);
610 static void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo)
614 /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */
615 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
616 temp = (temp & 3) << 6;
617 /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */
618 xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0xc0, temp & 0x80);
619 /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */
620 xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80);
624 static void xgifb_set_lcd(int chip_id,
625 struct vb_device_info *pVBInfo,
626 unsigned short RefreshRateTableIndex,
627 unsigned short ModeNo)
631 xgifb_reg_set(pVBInfo->P3d4, 0x2E, 0x00);
632 xgifb_reg_set(pVBInfo->P3d4, 0x2F, 0x00);
633 xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x00);
634 xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x00);
636 if (chip_id == XG27) {
637 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
638 if ((temp & 0x03) == 0) { /* dual 12 */
639 xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x13);
640 xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x13);
644 if (chip_id == XG27) {
645 XGI_SetXG27FPBits(pVBInfo);
647 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
650 xgifb_reg_or(pVBInfo->P3c4, 0x06, 0x40);
651 xgifb_reg_or(pVBInfo->P3c4, 0x09, 0x40);
655 xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */
657 xgifb_reg_and(pVBInfo->P3c4, 0x30, ~0x20); /* Hsync polarity */
658 xgifb_reg_and(pVBInfo->P3c4, 0x35, ~0x80); /* Vsync polarity */
660 temp = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
663 xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20);
666 xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80);
669 /* --------------------------------------------------------------------- */
670 /* Function : XGI_UpdateXG21CRTC */
672 /* Output : CRT1 CRTC */
673 /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */
674 /* --------------------------------------------------------------------- */
675 static void XGI_UpdateXG21CRTC(unsigned short ModeNo,
676 struct vb_device_info *pVBInfo,
677 unsigned short RefreshRateTableIndex)
681 xgifb_reg_and(pVBInfo->P3d4, 0x11, 0x7F); /* Unlock CR0~7 */
682 if (ModeNo == 0x2E &&
683 (XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC ==
686 else if (ModeNo == 0x2E && (XGI330_RefIndex[RefreshRateTableIndex].
687 Ext_CRT1CRTC == RES640x480x72))
689 else if (ModeNo == 0x2F)
691 else if (ModeNo == 0x50)
693 else if (ModeNo == 0x59)
697 xgifb_reg_set(pVBInfo->P3d4, 0x02,
698 XGI_UpdateCRT1Table[index].CR02);
699 xgifb_reg_set(pVBInfo->P3d4, 0x03,
700 XGI_UpdateCRT1Table[index].CR03);
701 xgifb_reg_set(pVBInfo->P3d4, 0x15,
702 XGI_UpdateCRT1Table[index].CR15);
703 xgifb_reg_set(pVBInfo->P3d4, 0x16,
704 XGI_UpdateCRT1Table[index].CR16);
708 static void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension,
709 unsigned short ModeNo, unsigned short ModeIdIndex,
710 unsigned short RefreshRateTableIndex,
711 struct vb_device_info *pVBInfo)
713 unsigned short resindex, tempax, tempbx, tempcx, temp, modeflag;
717 resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO;
719 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
720 tempax = XGI330_ModeResInfo[resindex].HTotal;
721 tempbx = XGI330_ModeResInfo[resindex].VTotal;
723 if (modeflag & HalfDCLK)
724 tempax = tempax >> 1;
726 if (modeflag & HalfDCLK)
727 tempax = tempax << 1;
729 temp = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
731 if (temp & InterlaceMode)
732 tempbx = tempbx >> 1;
734 if (modeflag & DoubleScanMode)
735 tempbx = tempbx << 1;
743 temp = xgifb_reg_get(pVBInfo->P3d4, 0x11);
744 data = xgifb_reg_get(pVBInfo->P3d4, 0x11);
746 xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */
747 xgifb_reg_set(pVBInfo->P3d4, 0x01, (unsigned short) (tempcx & 0xff));
748 xgifb_reg_and_or(pVBInfo->P3d4, 0x0b, ~0x0c,
749 (unsigned short) ((tempcx & 0x0ff00) >> 10));
750 xgifb_reg_set(pVBInfo->P3d4, 0x12, (unsigned short) (tempbx & 0xff));
752 tempbx = tempbx >> 8;
760 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x42, tempax);
761 data = xgifb_reg_get(pVBInfo->P3d4, 0x07);
768 xgifb_reg_and_or(pVBInfo->P3d4, 0x0a, ~0x02, tempax);
769 xgifb_reg_set(pVBInfo->P3d4, 0x11, temp);
772 static void XGI_SetCRT1Offset(unsigned short ModeNo,
773 unsigned short ModeIdIndex,
774 unsigned short RefreshRateTableIndex,
775 struct xgi_hw_device_info *HwDeviceExtension,
776 struct vb_device_info *pVBInfo)
778 unsigned short temp, ah, al, temp2, i, DisplayUnit;
781 temp = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeInfo;
783 temp = XGI330_ScreenOffset[temp];
785 temp2 = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
786 temp2 &= InterlaceMode;
791 temp2 = pVBInfo->ModeType - ModeEGA;
816 if ((ModeNo >= 0x26) && (ModeNo <= 0x28))
817 temp = temp * temp2 + temp2 / 2;
824 temp = temp >> 8; /* ah */
826 i = xgifb_reg_get(pVBInfo->P3c4, 0x0E);
829 xgifb_reg_set(pVBInfo->P3c4, 0x0E, i);
831 temp = (unsigned char) temp2;
832 temp &= 0xFF; /* al */
833 xgifb_reg_set(pVBInfo->P3d4, 0x13, temp);
836 temp2 = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
837 temp2 &= InterlaceMode;
841 DisplayUnit = DisplayUnit << 5;
842 ah = (DisplayUnit & 0xff00) >> 8;
843 al = DisplayUnit & 0x00ff;
849 if (HwDeviceExtension->jChipType >= XG20)
850 if ((ModeNo == 0x4A) | (ModeNo == 0x49))
853 xgifb_reg_set(pVBInfo->P3c4, 0x10, ah);
856 static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo,
857 unsigned short ModeIdIndex,
858 unsigned short RefreshRateTableIndex,
859 struct xgi_hw_device_info *HwDeviceExtension,
860 struct vb_device_info *pVBInfo)
862 unsigned short VCLKIndex, modeflag;
865 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
867 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { /*301b*/
868 if (pVBInfo->LCDResInfo != Panel_1024x768)
870 VCLKIndex = VCLK108_2_315 + 5;
872 VCLKIndex = VCLK65_315 + 2; /* LCDXlat1VCLK */
873 } else if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
874 if (pVBInfo->SetFlag & RPLLDIV2XO)
875 VCLKIndex = TVCLKBASE_315_25 + HiTVVCLKDIV2;
877 VCLKIndex = TVCLKBASE_315_25 + HiTVVCLK;
879 if (pVBInfo->SetFlag & TVSimuMode) {
880 if (modeflag & Charx8Dot) {
881 VCLKIndex = TVCLKBASE_315_25 + HiTVSimuVCLK;
883 VCLKIndex = TVCLKBASE_315_25 + HiTVTextVCLK;
888 if (pVBInfo->VBType & VB_SIS301LV) {
889 if (pVBInfo->SetFlag & RPLLDIV2XO)
890 VCLKIndex = YPbPr525iVCLK_2;
892 VCLKIndex = YPbPr525iVCLK;
894 } else if (pVBInfo->VBInfo & SetCRT2ToTV) {
895 if (pVBInfo->SetFlag & RPLLDIV2XO)
896 VCLKIndex = TVCLKBASE_315_25 + TVVCLKDIV2;
898 VCLKIndex = TVCLKBASE_315_25 + TVVCLK;
899 } else { /* for CRT2 */
901 VCLKIndex = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
902 VCLKIndex &= IndexMask;
908 static void XGI_SetCRT1VCLK(unsigned short ModeNo,
909 unsigned short ModeIdIndex,
910 struct xgi_hw_device_info *HwDeviceExtension,
911 unsigned short RefreshRateTableIndex,
912 struct vb_device_info *pVBInfo)
914 unsigned char index, data;
915 unsigned short vclkindex;
917 if (pVBInfo->IF_DEF_LVDS == 1) {
918 index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
919 data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF;
920 xgifb_reg_set(pVBInfo->P3c4, 0x31, data);
921 xgifb_reg_set(pVBInfo->P3c4, 0x2B, XGI_VCLKData[index].SR2B);
922 xgifb_reg_set(pVBInfo->P3c4, 0x2C, XGI_VCLKData[index].SR2C);
923 xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01);
924 } else if ((pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
925 | VB_SIS302LV | VB_XGI301C)) && (pVBInfo->VBInfo
926 & XGI_SetCRT2ToLCDA)) {
927 vclkindex = XGI_GetVCLK2Ptr(ModeNo, ModeIdIndex,
928 RefreshRateTableIndex, HwDeviceExtension,
930 data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF;
931 xgifb_reg_set(pVBInfo->P3c4, 0x31, data);
932 data = XGI_VBVCLKData[vclkindex].Part4_A;
933 xgifb_reg_set(pVBInfo->P3c4, 0x2B, data);
934 data = XGI_VBVCLKData[vclkindex].Part4_B;
935 xgifb_reg_set(pVBInfo->P3c4, 0x2C, data);
936 xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01);
938 index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
939 data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF;
940 xgifb_reg_set(pVBInfo->P3c4, 0x31, data);
941 xgifb_reg_set(pVBInfo->P3c4, 0x2B, XGI_VCLKData[index].SR2B);
942 xgifb_reg_set(pVBInfo->P3c4, 0x2C, XGI_VCLKData[index].SR2C);
943 xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01);
946 if (HwDeviceExtension->jChipType >= XG20) {
947 if (XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag &
949 data = xgifb_reg_get(pVBInfo->P3c4, 0x2B);
950 xgifb_reg_set(pVBInfo->P3c4, 0x2B, data);
951 data = xgifb_reg_get(pVBInfo->P3c4, 0x2C);
958 xgifb_reg_set(pVBInfo->P3c4, 0x2C, data);
963 static void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo)
967 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); /* D[0] 1: 18bit */
968 temp = (temp & 1) << 6;
969 /* SR06[6] 18bit Dither */
970 xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x40, temp);
971 /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */
972 xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80);
976 static void XGI_SetCRT1FIFO(unsigned short ModeNo,
977 struct xgi_hw_device_info *HwDeviceExtension,
978 struct vb_device_info *pVBInfo)
982 data = xgifb_reg_get(pVBInfo->P3c4, 0x3D);
984 xgifb_reg_set(pVBInfo->P3c4, 0x3D, data); /* diable auto-threshold */
986 xgifb_reg_set(pVBInfo->P3c4, 0x08, 0x34);
987 data = xgifb_reg_get(pVBInfo->P3c4, 0x09);
989 xgifb_reg_set(pVBInfo->P3c4, 0x09, data | 0x30);
990 data = xgifb_reg_get(pVBInfo->P3c4, 0x3D);
992 xgifb_reg_set(pVBInfo->P3c4, 0x3D, data);
994 if (HwDeviceExtension->jChipType == XG21)
995 XGI_SetXG21FPBits(pVBInfo); /* Fix SR9[7:6] can't read back */
998 static void XGI_SetVCLKState(struct xgi_hw_device_info *HwDeviceExtension,
999 unsigned short ModeNo, unsigned short RefreshRateTableIndex,
1000 struct vb_device_info *pVBInfo)
1002 unsigned short data, data2 = 0;
1005 unsigned char index;
1007 index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1009 VCLK = XGI_VCLKData[index].CLOCK;
1011 data = xgifb_reg_get(pVBInfo->P3c4, 0x32);
1014 data |= 0x0c; /* VCLK > 200 */
1016 if (HwDeviceExtension->jChipType >= XG20)
1017 data &= ~0x04; /* 2 pixel mode */
1019 xgifb_reg_set(pVBInfo->P3c4, 0x32, data);
1021 if (HwDeviceExtension->jChipType < XG20) {
1022 data = xgifb_reg_get(pVBInfo->P3c4, 0x1F);
1026 xgifb_reg_set(pVBInfo->P3c4, 0x1F, data);
1031 xgifb_reg_and_or(pVBInfo->P3c4, 0x07, 0xFC, data2);
1032 if (HwDeviceExtension->jChipType >= XG27)
1033 xgifb_reg_and_or(pVBInfo->P3c4, 0x40, 0xFC, data2 & 0x03);
1037 static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension,
1038 unsigned short ModeNo, unsigned short ModeIdIndex,
1039 unsigned short RefreshRateTableIndex,
1040 struct vb_device_info *pVBInfo)
1042 unsigned short data, data2, data3, infoflag = 0, modeflag, resindex,
1045 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1046 infoflag = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1048 if (xgifb_reg_get(pVBInfo->P3d4, 0x31) & 0x01)
1049 xgifb_reg_and_or(pVBInfo->P3c4, 0x1F, 0x3F, 0x00);
1054 data3 = pVBInfo->ModeType - ModeVGA;
1057 data &= InterlaceMode;
1062 xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x3F, data2);
1063 resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO;
1064 xres = XGI330_ModeResInfo[resindex].HTotal; /* xres->ax */
1067 if (infoflag & InterlaceMode) {
1070 else if (xres == 1280)
1074 xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFF, data);
1075 xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFC, 0);
1077 if (modeflag & HalfDCLK)
1078 xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xF7, 0x08);
1082 if (modeflag & LineCompareOff)
1085 xgifb_reg_and_or(pVBInfo->P3c4, 0x0F, ~0x48, data2);
1089 xgifb_reg_and_or(pVBInfo->P3c4, 0x21, 0x1F, data);
1091 XGI_SetVCLKState(HwDeviceExtension, ModeNo, RefreshRateTableIndex,
1094 data = xgifb_reg_get(pVBInfo->P3d4, 0x31);
1096 if (HwDeviceExtension->jChipType == XG27) {
1101 xgifb_reg_set(pVBInfo->P3d4, 0x52, data);
1102 xgifb_reg_or(pVBInfo->P3d4, 0x51, 0x10);
1103 } else if (HwDeviceExtension->jChipType >= XG20) {
1108 xgifb_reg_set(pVBInfo->P3d4, 0x52, data);
1109 xgifb_reg_set(pVBInfo->P3d4, 0x51, 0x02);
1115 xgifb_reg_set(pVBInfo->P3d4, 0x52, data);
1120 static void XGI_WriteDAC(unsigned short dl,
1124 struct vb_device_info *pVBInfo)
1126 unsigned short temp, bh, bl;
1145 outb((unsigned short) dh, pVBInfo->P3c9);
1146 outb((unsigned short) bh, pVBInfo->P3c9);
1147 outb((unsigned short) bl, pVBInfo->P3c9);
1150 static void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex,
1151 struct vb_device_info *pVBInfo)
1153 unsigned short data, data2, i, k, m, n, o, si, di, bx, dl, al, ah, dh;
1154 const unsigned short *table = XGINew_VGA_DAC;
1156 outb(0xFF, pVBInfo->P3c6);
1157 outb(0x00, pVBInfo->P3c8);
1159 for (i = 0; i < 16; i++) {
1162 for (k = 0; k < 3; k++) {
1171 outb(data2, pVBInfo->P3c9);
1176 for (i = 16; i < 32; i++) {
1179 for (k = 0; k < 3; k++)
1180 outb(data, pVBInfo->P3c9);
1185 for (m = 0; m < 9; m++) {
1190 for (n = 0; n < 3; n++) {
1191 for (o = 0; o < 5; o++) {
1196 XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
1201 for (o = 0; o < 3; o++) {
1206 XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
1216 static void XGI_GetLVDSResInfo(unsigned short ModeNo,
1217 unsigned short ModeIdIndex,
1218 struct vb_device_info *pVBInfo)
1220 unsigned short resindex, xres, yres, modeflag;
1222 /* si+Ext_ResInfo */
1223 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO;
1225 /* si+Ext_ResInfo */
1226 resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO;
1228 xres = XGI330_ModeResInfo[resindex].HTotal;
1229 yres = XGI330_ModeResInfo[resindex].VTotal;
1231 if (modeflag & HalfDCLK)
1234 if (modeflag & DoubleScanMode)
1240 pVBInfo->VGAHDE = xres;
1241 pVBInfo->HDE = xres;
1242 pVBInfo->VGAVDE = yres;
1243 pVBInfo->VDE = yres;
1246 static void const *XGI_GetLcdPtr(struct XGI330_LCDDataTablStruct const *table,
1247 unsigned short ModeNo,
1248 unsigned short ModeIdIndex,
1249 unsigned short RefreshRateTableIndex,
1250 struct vb_device_info *pVBInfo)
1252 unsigned short i, tempdx, tempbx, modeflag;
1256 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1260 while (table[i].PANELID != 0xff) {
1261 tempdx = pVBInfo->LCDResInfo;
1262 if (tempbx & 0x0080) { /* OEMUtil */
1263 tempbx &= (~0x0080);
1264 tempdx = pVBInfo->LCDTypeInfo;
1267 if (pVBInfo->LCDInfo & EnableScalingLCD)
1268 tempdx &= (~PanelResInfo);
1270 if (table[i].PANELID == tempdx) {
1271 tempbx = table[i].MASK;
1272 tempdx = pVBInfo->LCDInfo;
1274 if (modeflag & HalfDCLK)
1275 tempdx |= SetLCDLowResolution;
1278 if (tempbx == table[i].CAP)
1284 return table[i].DATAPTR;
1287 static struct SiS_TVData const *XGI_GetTVPtr(unsigned short ModeNo,
1288 unsigned short ModeIdIndex,
1289 unsigned short RefreshRateTableIndex,
1290 struct vb_device_info *pVBInfo)
1292 unsigned short i, tempdx, tempal, modeflag;
1294 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1295 tempal = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
1296 tempal = tempal & 0x3f;
1297 tempdx = pVBInfo->TVInfo;
1299 if (pVBInfo->VBInfo & SetInSlaveMode)
1300 tempdx = tempdx | SetTVLockMode;
1302 if (modeflag & HalfDCLK)
1303 tempdx = tempdx | SetTVLowResolution;
1307 while (XGI_TVDataTable[i].MASK != 0xffff) {
1308 if ((tempdx & XGI_TVDataTable[i].MASK) ==
1309 XGI_TVDataTable[i].CAP)
1314 return &XGI_TVDataTable[i].DATAPTR[tempal];
1317 static void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex,
1318 unsigned short RefreshRateTableIndex,
1319 struct vb_device_info *pVBInfo)
1321 struct SiS_LVDSData const *LCDPtr;
1323 if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)))
1326 LCDPtr = XGI_GetLcdPtr(XGI_EPLLCDDataPtr, ModeNo, ModeIdIndex,
1327 RefreshRateTableIndex, pVBInfo);
1328 pVBInfo->VGAHT = LCDPtr->VGAHT;
1329 pVBInfo->VGAVT = LCDPtr->VGAVT;
1330 pVBInfo->HT = LCDPtr->LCDHT;
1331 pVBInfo->VT = LCDPtr->LCDVT;
1333 if (pVBInfo->LCDInfo & (SetLCDtoNonExpanding | EnableScalingLCD))
1336 if ((pVBInfo->LCDResInfo == Panel_1024x768) ||
1337 (pVBInfo->LCDResInfo == Panel_1024x768x75)) {
1338 pVBInfo->HDE = 1024;
1340 } else if ((pVBInfo->LCDResInfo == Panel_1280x1024) ||
1341 (pVBInfo->LCDResInfo == Panel_1280x1024x75)) {
1342 pVBInfo->HDE = 1280;
1343 pVBInfo->VDE = 1024;
1344 } else if (pVBInfo->LCDResInfo == Panel_1400x1050) {
1345 pVBInfo->HDE = 1400;
1346 pVBInfo->VDE = 1050;
1348 pVBInfo->HDE = 1600;
1349 pVBInfo->VDE = 1200;
1353 static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex,
1354 unsigned short RefreshRateTableIndex,
1355 struct xgi_hw_device_info *HwDeviceExtension,
1356 struct vb_device_info *pVBInfo)
1359 struct XGI_LVDSCRT1HDataStruct const *LCDPtr = NULL;
1360 struct XGI_LVDSCRT1VDataStruct const *LCDPtr1 = NULL;
1362 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
1363 LCDPtr = XGI_GetLcdPtr(xgifb_epllcd_crt1_h, ModeNo, ModeIdIndex,
1364 RefreshRateTableIndex, pVBInfo);
1366 for (i = 0; i < 8; i++)
1367 pVBInfo->TimingH.data[i] = LCDPtr[0].Reg[i];
1370 XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension);
1372 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
1373 LCDPtr1 = XGI_GetLcdPtr(xgifb_epllcd_crt1_v, ModeNo,
1374 ModeIdIndex, RefreshRateTableIndex,
1376 for (i = 0; i < 7; i++)
1377 pVBInfo->TimingV.data[i] = LCDPtr1[0].Reg[i];
1380 XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo);
1383 static unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo)
1385 unsigned char tempal, tempah, tempbl, i;
1387 tempah = xgifb_reg_get(pVBInfo->P3d4, 0x36);
1388 tempal = tempah & 0x0F;
1389 tempah = tempah & 0xF0;
1391 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
1393 while (tempbl != 0xFF) {
1394 if (tempbl & 0x80) { /* OEMUtil */
1396 tempbl = tempbl & ~(0x80);
1399 if (tempal == tempbl)
1404 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
1410 static unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo)
1412 unsigned short tempah, tempal, tempbl, i;
1414 tempal = pVBInfo->LCDResInfo;
1415 tempah = pVBInfo->LCDTypeInfo;
1418 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
1420 while (tempbl != 0xFF) {
1421 if ((tempbl & 0x80) && (tempbl != 0x80)) {
1426 if (tempal == tempbl)
1430 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
1433 if (tempbl == 0xFF) {
1434 pVBInfo->LCDResInfo = Panel_1024x768;
1435 pVBInfo->LCDTypeInfo = 0;
1442 static void XGI_GetLCDSync(unsigned short *HSyncWidth,
1443 unsigned short *VSyncWidth,
1444 struct vb_device_info *pVBInfo)
1446 unsigned short Index;
1448 Index = XGI_GetLCDCapPtr(pVBInfo);
1449 *HSyncWidth = pVBInfo->LCDCapList[Index].LCD_HSyncWidth;
1450 *VSyncWidth = pVBInfo->LCDCapList[Index].LCD_VSyncWidth;
1455 static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
1456 unsigned short RefreshRateTableIndex,
1457 struct vb_device_info *pVBInfo)
1459 unsigned short tempbx, tempax, tempcx, tempdx, push1, push2, modeflag;
1460 unsigned long temp, temp1, temp2, temp3, push3;
1461 struct XGI330_LCDDataDesStruct2 const *LCDPtr1 = NULL;
1463 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1464 LCDPtr1 = XGI_GetLcdPtr(XGI_EPLLCDDesDataPtr, ModeNo, ModeIdIndex,
1465 RefreshRateTableIndex, pVBInfo);
1467 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
1472 if ((pVBInfo->LCDResInfo == Panel_1024x768) ||
1473 (pVBInfo->LCDResInfo == Panel_1024x768x75)) {
1476 } else if ((pVBInfo->LCDResInfo == Panel_1280x1024) ||
1477 (pVBInfo->LCDResInfo == Panel_1280x1024x75)) {
1480 } else if (pVBInfo->LCDResInfo == Panel_1400x1050) {
1488 if (pVBInfo->LCDInfo & SetLCDtoNonExpanding) {
1489 pVBInfo->HDE = tempax;
1490 pVBInfo->VDE = tempbx;
1491 pVBInfo->VGAHDE = tempax;
1492 pVBInfo->VGAVDE = tempbx;
1495 tempax = pVBInfo->HT;
1497 tempbx = LCDPtr1->LCDHDES;
1499 tempcx = pVBInfo->HDE;
1500 tempbx = tempbx & 0x0fff;
1503 if (tempcx >= tempax)
1506 xgifb_reg_set(pVBInfo->Part1Port, 0x1A, tempbx & 0x07);
1508 tempcx = tempcx >> 3;
1509 tempbx = tempbx >> 3;
1511 xgifb_reg_set(pVBInfo->Part1Port, 0x16,
1512 (unsigned short) (tempbx & 0xff));
1513 xgifb_reg_set(pVBInfo->Part1Port, 0x17,
1514 (unsigned short) (tempcx & 0xff));
1516 tempax = pVBInfo->HT;
1518 tempbx = LCDPtr1->LCDHRS;
1522 if (pVBInfo->LCDInfo & EnableScalingLCD)
1523 tempcx = LCDPtr1->LCDHSync;
1527 if (tempcx >= tempax)
1530 tempax = tempbx & 0x07;
1531 tempax = tempax >> 5;
1532 tempcx = tempcx >> 3;
1533 tempbx = tempbx >> 3;
1538 xgifb_reg_set(pVBInfo->Part1Port, 0x15, tempax);
1539 xgifb_reg_set(pVBInfo->Part1Port, 0x14,
1540 (unsigned short) (tempbx & 0xff));
1542 tempax = pVBInfo->VT;
1543 tempbx = LCDPtr1->LCDVDES;
1544 tempcx = pVBInfo->VDE;
1546 tempbx = tempbx & 0x0fff;
1548 if (tempcx >= tempax)
1551 xgifb_reg_set(pVBInfo->Part1Port, 0x1b,
1552 (unsigned short) (tempbx & 0xff));
1553 xgifb_reg_set(pVBInfo->Part1Port, 0x1c,
1554 (unsigned short) (tempcx & 0xff));
1556 tempbx = (tempbx >> 8) & 0x07;
1557 tempcx = (tempcx >> 8) & 0x07;
1559 xgifb_reg_set(pVBInfo->Part1Port, 0x1d,
1560 (unsigned short) ((tempcx << 3)
1563 tempax = pVBInfo->VT;
1564 tempbx = LCDPtr1->LCDVRS;
1568 if (pVBInfo->LCDInfo & EnableScalingLCD)
1569 tempcx = LCDPtr1->LCDVSync;
1572 if (tempcx >= tempax)
1575 xgifb_reg_set(pVBInfo->Part1Port, 0x18,
1576 (unsigned short) (tempbx & 0xff));
1577 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, ~0x0f,
1578 (unsigned short) (tempcx & 0x0f));
1580 tempax = ((tempbx >> 8) & 0x07) << 3;
1582 tempbx = pVBInfo->VGAVDE;
1583 if (tempbx != pVBInfo->VDE)
1586 if (pVBInfo->LCDInfo & XGI_EnableLVDSDDA)
1589 xgifb_reg_and_or(pVBInfo->Part1Port, 0x1a, 0x07,
1592 tempcx = pVBInfo->VGAVT;
1593 tempbx = pVBInfo->VDE;
1594 tempax = pVBInfo->VGAVDE;
1597 temp = tempax; /* 0430 ylshieh */
1598 temp1 = (temp << 18) / tempbx;
1600 tempdx = (unsigned short) ((temp << 18) % tempbx);
1608 xgifb_reg_set(pVBInfo->Part1Port, 0x37,
1609 (unsigned short) (temp2 & 0xff));
1610 xgifb_reg_set(pVBInfo->Part1Port, 0x36,
1611 (unsigned short) ((temp2 >> 8) & 0xff));
1613 tempbx = (unsigned short) (temp2 >> 16);
1614 tempax = tempbx & 0x03;
1616 tempbx = pVBInfo->VGAVDE;
1617 if (tempbx == pVBInfo->VDE)
1620 xgifb_reg_set(pVBInfo->Part1Port, 0x35, tempax);
1622 if (pVBInfo->VBType & VB_XGI301C) {
1624 xgifb_reg_set(pVBInfo->Part4Port,
1626 (unsigned short) (temp2 & 0xff));
1627 xgifb_reg_set(pVBInfo->Part4Port,
1629 (unsigned short) ((temp2 >> 8) &
1631 tempbx = (unsigned short) (temp2 >> 16);
1632 xgifb_reg_and_or(pVBInfo->Part4Port, 0x3a,
1634 (unsigned short) ((tempbx &
1637 tempcx = pVBInfo->VGAVDE;
1638 if (tempcx == pVBInfo->VDE)
1639 xgifb_reg_and_or(pVBInfo->Part4Port,
1642 xgifb_reg_and_or(pVBInfo->Part4Port,
1646 tempcx = pVBInfo->VGAHDE;
1647 tempbx = pVBInfo->HDE;
1649 temp1 = tempcx << 16;
1651 tempax = (unsigned short) (temp1 / tempbx);
1653 if ((tempbx & 0xffff) == (tempcx & 0xffff))
1657 temp1 = pVBInfo->VGAHDE << 16;
1660 temp3 = temp3 << 16;
1663 temp3 = (temp3 & 0xffff0000) + (temp1 & 0xffff);
1665 tempax = (unsigned short) (temp3 & 0xff);
1666 xgifb_reg_set(pVBInfo->Part1Port, 0x1f, tempax);
1668 temp1 = pVBInfo->VGAVDE << 18;
1669 temp1 = temp1 / push3;
1670 tempbx = (unsigned short) (temp1 & 0xffff);
1672 if (pVBInfo->LCDResInfo == Panel_1024x768)
1675 tempax = ((tempbx >> 8) & 0xff) << 3;
1676 tempax |= (unsigned short) ((temp3 >> 8) & 0x07);
1677 xgifb_reg_set(pVBInfo->Part1Port, 0x20,
1678 (unsigned short) (tempax & 0xff));
1679 xgifb_reg_set(pVBInfo->Part1Port, 0x21,
1680 (unsigned short) (tempbx & 0xff));
1682 temp3 = temp3 >> 16;
1684 if (modeflag & HalfDCLK)
1687 xgifb_reg_set(pVBInfo->Part1Port, 0x22,
1688 (unsigned short) ((temp3 >> 8) & 0xff));
1689 xgifb_reg_set(pVBInfo->Part1Port, 0x23,
1690 (unsigned short) (temp3 & 0xff));
1693 /* --------------------------------------------------------------------- */
1694 /* Function : XGI_GETLCDVCLKPtr */
1696 /* Output : al -> VCLK Index */
1698 /* --------------------------------------------------------------------- */
1699 static void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1,
1700 struct vb_device_info *pVBInfo)
1702 unsigned short index;
1704 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
1705 index = XGI_GetLCDCapPtr1(pVBInfo);
1707 if (pVBInfo->VBInfo & SetCRT2ToLCD) { /* LCDB */
1708 *di_0 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData1;
1709 *di_1 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData2;
1711 *di_0 = pVBInfo->LCDCapList[index].LCDA_VCLKData1;
1712 *di_1 = pVBInfo->LCDCapList[index].LCDA_VCLKData2;
1718 static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex,
1719 unsigned short ModeNo, unsigned short ModeIdIndex,
1720 struct vb_device_info *pVBInfo)
1723 unsigned short index, modeflag;
1724 unsigned char tempal;
1726 /* si+Ext_ResInfo */
1727 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1729 if ((pVBInfo->SetFlag & ProgrammingCRT2) &&
1730 (!(pVBInfo->LCDInfo & EnableScalingLCD))) { /* {LCDA/LCDB} */
1731 index = XGI_GetLCDCapPtr(pVBInfo);
1732 tempal = pVBInfo->LCDCapList[index].LCD_VCLK;
1734 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))
1738 if (pVBInfo->VBType &
1744 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
1745 tempal = TVCLKBASE_315 + HiTVVCLKDIV2;
1746 if (!(pVBInfo->TVInfo & RPLLDIV2XO))
1747 tempal = TVCLKBASE_315 + HiTVVCLK;
1748 if (pVBInfo->TVInfo & TVSimuMode) {
1749 tempal = TVCLKBASE_315 + HiTVSimuVCLK;
1750 if (!(modeflag & Charx8Dot))
1751 tempal = TVCLKBASE_315 +
1758 if (pVBInfo->TVInfo & TVSetYPbPr750p) {
1759 tempal = XGI_YPbPr750pVCLK;
1763 if (pVBInfo->TVInfo & TVSetYPbPr525p) {
1764 tempal = YPbPr525pVCLK;
1768 tempal = NTSC1024VCLK;
1770 if (!(pVBInfo->TVInfo & NTSC1024x768)) {
1771 tempal = TVCLKBASE_315 + TVVCLKDIV2;
1772 if (!(pVBInfo->TVInfo & RPLLDIV2XO))
1773 tempal = TVCLKBASE_315 + TVVCLK;
1776 if (pVBInfo->VBInfo & SetCRT2ToTV)
1781 inb((pVBInfo->P3ca + 0x02));
1782 tempal = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1786 static void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0,
1787 unsigned char *di_1, struct vb_device_info *pVBInfo)
1789 if (pVBInfo->VBType & (VB_SIS301 | VB_SIS301B | VB_SIS302B
1790 | VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) {
1791 if ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) &&
1792 (pVBInfo->SetFlag & ProgrammingCRT2)) {
1793 *di_0 = XGI_VBVCLKData[tempal].Part4_A;
1794 *di_1 = XGI_VBVCLKData[tempal].Part4_B;
1797 *di_0 = XGI_VCLKData[tempal].SR2B;
1798 *di_1 = XGI_VCLKData[tempal].SR2C;
1802 static void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex,
1803 unsigned short RefreshRateTableIndex,
1804 struct vb_device_info *pVBInfo)
1806 unsigned char di_0, di_1, tempal;
1809 tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex,
1811 XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo);
1812 XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo);
1814 for (i = 0; i < 4; i++) {
1815 xgifb_reg_and_or(pVBInfo->P3d4, 0x31, ~0x30,
1816 (unsigned short) (0x10 * i));
1817 if ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA))
1818 && (!(pVBInfo->VBInfo & SetInSlaveMode))) {
1819 xgifb_reg_set(pVBInfo->P3c4, 0x2e, di_0);
1820 xgifb_reg_set(pVBInfo->P3c4, 0x2f, di_1);
1822 xgifb_reg_set(pVBInfo->P3c4, 0x2b, di_0);
1823 xgifb_reg_set(pVBInfo->P3c4, 0x2c, di_1);
1828 static void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension,
1829 struct vb_device_info *pVBInfo)
1831 unsigned short tempcl, tempch, temp, tempbl, tempax;
1833 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
1834 | VB_SIS302LV | VB_XGI301C)) {
1837 temp = xgifb_reg_get(pVBInfo->P3c4, 0x01);
1839 if (!(temp & 0x20)) {
1840 temp = xgifb_reg_get(pVBInfo->P3d4, 0x17);
1842 temp = xgifb_reg_get(pVBInfo->P3d4, 0x53);
1844 tempcl |= ActiveCRT1;
1848 temp = xgifb_reg_get(pVBInfo->Part1Port, 0x2e);
1851 if (!(temp == 0x08)) {
1852 /* Check ChannelA */
1853 tempax = xgifb_reg_get(pVBInfo->Part1Port, 0x13);
1855 tempcl = tempcl | ActiveLCD;
1859 if (!(tempcl & ActiveLCD))
1861 tempcl |= ActiveCRT2;
1864 tempcl |= ActiveLCD;
1867 temp = xgifb_reg_get(pVBInfo->Part2Port, 0x00);
1870 tempch |= ActiveAVideo;
1873 tempch |= ActiveSVideo;
1876 tempch |= ActiveSCART;
1878 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
1880 tempch |= ActiveHiTV;
1883 if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
1884 temp = xgifb_reg_get(
1889 tempch |= ActiveYPbPr;
1897 temp = xgifb_reg_get(pVBInfo->P3d4, 0x3d);
1898 if (tempcl & ActiveLCD) {
1899 if ((pVBInfo->SetFlag & ReserveTVOption)) {
1900 if (temp & ActiveTV)
1905 tempbl = ~XGI_ModeSwitchStatus;
1906 xgifb_reg_and_or(pVBInfo->P3d4, 0x3d, tempbl, temp);
1908 if (!(pVBInfo->SetFlag & ReserveTVOption))
1909 xgifb_reg_set(pVBInfo->P3d4, 0x3e, tempch);
1915 void XGI_GetVBType(struct vb_device_info *pVBInfo)
1917 unsigned short flag, tempbx, tempah;
1919 if (pVBInfo->IF_DEF_LVDS != 0)
1922 tempbx = VB_SIS302B;
1923 flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00);
1928 flag = xgifb_reg_get(pVBInfo->Part4Port, 0x01);
1932 tempbx = VB_SIS301B;
1934 goto bigger_than_0xB0;
1936 tempbx = VB_XGI301C;
1938 goto bigger_than_0xB0;
1940 tempbx = VB_SIS301LV;
1942 goto bigger_than_0xB0;
1944 tempbx = VB_SIS302LV;
1945 tempah = xgifb_reg_get(pVBInfo->Part4Port, 0x39);
1947 tempbx = VB_XGI301C;
1950 if (tempbx & (VB_SIS301B | VB_SIS302B)) {
1951 flag = xgifb_reg_get(pVBInfo->Part4Port, 0x23);
1953 tempbx = tempbx | VB_NoLCD;
1957 pVBInfo->VBType = tempbx;
1960 static void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
1961 struct xgi_hw_device_info *HwDeviceExtension,
1962 struct vb_device_info *pVBInfo)
1964 unsigned short tempax, push, tempbx, temp, modeflag;
1966 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1967 pVBInfo->SetFlag = 0;
1968 pVBInfo->ModeType = modeflag & ModeTypeMask;
1971 if (!(pVBInfo->VBType & 0xFFFF))
1974 /* Check Display Device */
1975 temp = xgifb_reg_get(pVBInfo->P3d4, 0x30);
1976 tempbx = tempbx | temp;
1977 temp = xgifb_reg_get(pVBInfo->P3d4, 0x31);
1981 tempbx = tempbx | tempax;
1982 temp = (SetCRT2ToDualEdge | SetCRT2ToYPbPr525750 | XGI_SetCRT2ToLCDA
1983 | SetInSlaveMode | DisableCRT2Display);
1984 temp = 0xFFFF ^ temp;
1987 temp = xgifb_reg_get(pVBInfo->P3d4, 0x38);
1989 if (pVBInfo->VBType & (VB_SIS302B | VB_SIS301LV | VB_SIS302LV |
1991 if (temp & EnableDualEdge) {
1992 tempbx |= SetCRT2ToDualEdge;
1993 if (temp & SetToLCDA)
1994 tempbx |= XGI_SetCRT2ToLCDA;
1998 if (pVBInfo->IF_DEF_YPbPr == 1) {
1999 if (pVBInfo->VBType & (VB_SIS301LV|VB_SIS302LV|VB_XGI301C)) {
2000 if (temp & SetYPbPr) {
2001 if (pVBInfo->IF_DEF_HiVision == 1) {
2002 /* shampoo add for new scratch */
2003 temp = xgifb_reg_get(pVBInfo->P3d4,
2006 tempbx |= SetCRT2ToHiVision;
2008 if (temp != YPbPrMode1080i) {
2009 tempbx &= (~SetCRT2ToHiVision);
2010 tempbx |= SetCRT2ToYPbPr525750;
2017 tempax = push; /* restore CR31 */
2019 if (pVBInfo->IF_DEF_YPbPr == 1) {
2020 if (pVBInfo->IF_DEF_HiVision == 1)
2024 } else if (pVBInfo->IF_DEF_HiVision == 1) {
2030 if (!(tempbx & temp)) {
2031 tempax |= DisableCRT2Display;
2035 if (!(pVBInfo->VBType & VB_NoLCD)) {
2036 if (tempbx & XGI_SetCRT2ToLCDA) {
2037 if (tempbx & SetSimuScanMode)
2038 tempbx &= (~(SetCRT2ToLCD | SetCRT2ToRAMDAC |
2041 tempbx &= (~(SetCRT2ToLCD | SetCRT2ToRAMDAC |
2042 SetCRT2ToTV | SwitchCRT2));
2047 /* for driver abnormal */
2048 if (!(tempbx & (SwitchCRT2 | SetSimuScanMode))) {
2049 if (pVBInfo->IF_DEF_CRT2Monitor == 1) {
2050 if (tempbx & SetCRT2ToRAMDAC) {
2051 tempbx &= (0xFF00 | SetCRT2ToRAMDAC |
2052 SwitchCRT2 | SetSimuScanMode);
2053 tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750));
2056 tempbx &= (~(SetCRT2ToRAMDAC | SetCRT2ToLCD |
2061 if (!(pVBInfo->VBType & VB_NoLCD)) {
2062 if (tempbx & SetCRT2ToLCD) {
2063 tempbx &= (0xFF00 | SetCRT2ToLCD | SwitchCRT2 |
2065 tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750));
2069 if (tempbx & SetCRT2ToSCART) {
2070 tempbx &= (0xFF00 | SetCRT2ToSCART | SwitchCRT2 |
2072 tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750));
2075 if (pVBInfo->IF_DEF_YPbPr == 1) {
2076 if (tempbx & SetCRT2ToYPbPr525750)
2077 tempbx &= (0xFF00 | SwitchCRT2 | SetSimuScanMode);
2080 if (pVBInfo->IF_DEF_HiVision == 1) {
2081 if (tempbx & SetCRT2ToHiVision)
2082 tempbx &= (0xFF00 | SetCRT2ToHiVision | SwitchCRT2 |
2086 if (tempax & DisableCRT2Display) { /* Set Display Device Info */
2087 if (!(tempbx & (SwitchCRT2 | SetSimuScanMode)))
2088 tempbx = DisableCRT2Display;
2091 if (!(tempbx & DisableCRT2Display)) {
2092 if ((!(tempbx & DriverMode)) || (!(modeflag & CRT2Mode))) {
2093 if (!(tempbx & XGI_SetCRT2ToLCDA))
2094 tempbx |= (SetInSlaveMode | SetSimuScanMode);
2097 /* LCD+TV can't support in slave mode
2098 * (Force LCDA+TV->LCDB) */
2099 if ((tempbx & SetInSlaveMode) && (tempbx & XGI_SetCRT2ToLCDA)) {
2100 tempbx ^= (SetCRT2ToLCD | XGI_SetCRT2ToLCDA |
2102 pVBInfo->SetFlag |= ReserveTVOption;
2106 pVBInfo->VBInfo = tempbx;
2109 static void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
2110 struct vb_device_info *pVBInfo)
2112 unsigned short tempbx = 0, resinfo = 0, modeflag, index1;
2114 if (pVBInfo->VBInfo & SetCRT2ToTV) {
2115 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2116 resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO;
2118 tempbx = xgifb_reg_get(pVBInfo->P3d4, 0x35);
2119 if (tempbx & TVSetPAL) {
2120 tempbx &= (SetCHTVOverScan |
2124 if (tempbx & TVSetPALM)
2125 /* set to NTSC if PAL-M */
2126 tempbx &= ~TVSetPAL;
2128 tempbx &= (SetCHTVOverScan |
2132 if (pVBInfo->VBInfo & SetCRT2ToSCART)
2135 if (pVBInfo->IF_DEF_YPbPr == 1) {
2136 if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
2137 index1 = xgifb_reg_get(pVBInfo->P3d4, 0x35);
2138 index1 &= YPbPrMode;
2140 if (index1 == YPbPrMode525i)
2141 tempbx |= TVSetYPbPr525i;
2143 if (index1 == YPbPrMode525p)
2144 tempbx = tempbx | TVSetYPbPr525p;
2145 if (index1 == YPbPrMode750p)
2146 tempbx = tempbx | TVSetYPbPr750p;
2150 if (pVBInfo->IF_DEF_HiVision == 1) {
2151 if (pVBInfo->VBInfo & SetCRT2ToHiVision)
2152 tempbx = tempbx | TVSetHiVision | TVSetPAL;
2155 if ((pVBInfo->VBInfo & SetInSlaveMode) &&
2156 (!(pVBInfo->VBInfo & SetNotSimuMode)))
2157 tempbx |= TVSimuMode;
2159 if (!(tempbx & TVSetPAL) && (modeflag > 13) && (resinfo == 8))
2160 /* NTSC 1024x768, */
2161 tempbx |= NTSC1024x768;
2163 tempbx |= RPLLDIV2XO;
2165 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
2166 if (pVBInfo->VBInfo & SetInSlaveMode)
2167 tempbx &= (~RPLLDIV2XO);
2168 } else if (tempbx & (TVSetYPbPr525p | TVSetYPbPr750p)) {
2169 tempbx &= (~RPLLDIV2XO);
2170 } else if (!(pVBInfo->VBType & (VB_SIS301B | VB_SIS302B |
2171 VB_SIS301LV | VB_SIS302LV |
2173 if (tempbx & TVSimuMode)
2174 tempbx &= (~RPLLDIV2XO);
2177 pVBInfo->TVInfo = tempbx;
2180 static unsigned char XGI_GetLCDInfo(unsigned short ModeNo,
2181 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
2183 unsigned short temp, tempax, tempbx, resinfo = 0, LCDIdIndex;
2185 pVBInfo->LCDResInfo = 0;
2186 pVBInfo->LCDTypeInfo = 0;
2187 pVBInfo->LCDInfo = 0;
2189 /* si+Ext_ResInfo // */
2190 resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO;
2191 temp = xgifb_reg_get(pVBInfo->P3d4, 0x36); /* Get LCD Res.Info */
2192 tempbx = temp & 0x0F;
2195 tempbx = Panel_1024x768; /* default */
2198 if ((tempbx == Panel_1024x768) || (tempbx == Panel_1280x1024)) {
2199 if (pVBInfo->VBInfo & DriverMode) {
2200 tempax = xgifb_reg_get(pVBInfo->P3d4, 0x33);
2201 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)
2204 tempax = tempax >> 4;
2206 if ((resinfo == 6) || (resinfo == 9)) {
2208 tempbx |= PanelRef75Hz;
2209 } else if ((resinfo == 7) || (resinfo == 8)) {
2211 tempbx |= PanelRef75Hz;
2216 pVBInfo->LCDResInfo = tempbx;
2220 if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)))
2225 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
2227 temp &= (ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable);
2231 LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo);
2233 tempax = pVBInfo->LCDCapList[LCDIdIndex].LCD_Capability;
2235 if (((pVBInfo->VBType & VB_SIS302LV) ||
2236 (pVBInfo->VBType & VB_XGI301C)) && (tempax & XGI_LCDDualLink))
2237 tempbx |= SetLCDDualLink;
2239 if ((pVBInfo->LCDResInfo == Panel_1400x1050) &&
2240 (pVBInfo->VBInfo & SetCRT2ToLCD) && (resinfo == 9) &&
2241 (!(tempbx & EnableScalingLCD)))
2243 * set to center in 1280x1024 LCDB
2244 * for Panel_1400x1050
2246 tempbx |= SetLCDtoNonExpanding;
2248 if (pVBInfo->VBInfo & SetInSlaveMode) {
2249 if (pVBInfo->VBInfo & SetNotSimuMode)
2250 tempbx |= XGI_LCDVESATiming;
2252 tempbx |= XGI_LCDVESATiming;
2255 pVBInfo->LCDInfo = tempbx;
2260 unsigned char XGI_SearchModeID(unsigned short ModeNo,
2261 unsigned short *ModeIdIndex, struct vb_device_info *pVBInfo)
2263 for (*ModeIdIndex = 0;; (*ModeIdIndex)++) {
2264 if (XGI330_EModeIDTable[*ModeIdIndex].Ext_ModeID == ModeNo)
2266 if (XGI330_EModeIDTable[*ModeIdIndex].Ext_ModeID == 0xFF)
2273 static unsigned char XG21GPIODataTransfer(unsigned char ujDate)
2275 unsigned char ujRet = 0;
2276 unsigned char i = 0;
2278 for (i = 0; i < 8; i++) {
2280 ujRet |= (ujDate >> i) & 1;
2286 /*----------------------------------------------------------------------------*/
2288 /* bl[5] : LVDS signal */
2289 /* bl[1] : LVDS backlight */
2290 /* bl[0] : LVDS VDD */
2291 /*----------------------------------------------------------------------------*/
2292 static unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo)
2294 unsigned char CR4A, temp;
2296 CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
2297 xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x23); /* enable GPIO write */
2299 temp = xgifb_reg_get(pVBInfo->P3d4, 0x48);
2301 temp = XG21GPIODataTransfer(temp);
2303 xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A);
2307 /*----------------------------------------------------------------------------*/
2309 /* bl[5] : LVDS signal */
2310 /* bl[1] : LVDS backlight */
2311 /* bl[0] : LVDS VDD */
2312 /*----------------------------------------------------------------------------*/
2313 static unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo)
2315 unsigned char CR4A, CRB4, temp;
2317 CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
2318 xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x0C); /* enable GPIO write */
2320 temp = xgifb_reg_get(pVBInfo->P3d4, 0x48);
2324 xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A);
2325 CRB4 = xgifb_reg_get(pVBInfo->P3d4, 0xB4);
2326 temp |= ((CRB4 & 0x04) << 3);
2330 /*----------------------------------------------------------------------------*/
2332 /* bl[5] : 1;LVDS signal on */
2333 /* bl[1] : 1;LVDS backlight on */
2334 /* bl[0] : 1:LVDS VDD on */
2335 /* bh: 100000b : clear bit 5, to set bit5 */
2336 /* 000010b : clear bit 1, to set bit1 */
2337 /* 000001b : clear bit 0, to set bit0 */
2338 /*----------------------------------------------------------------------------*/
2339 static void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl,
2340 struct vb_device_info *pVBInfo)
2342 unsigned char CR4A, temp;
2344 CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
2347 xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */
2349 if (tempbh & 0x20) {
2350 temp = (tempbl >> 4) & 0x02;
2353 xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp);
2357 temp = xgifb_reg_get(pVBInfo->P3d4, 0x48);
2359 temp = XG21GPIODataTransfer(temp);
2362 xgifb_reg_set(pVBInfo->P3d4, 0x48, temp);
2365 static void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl,
2366 struct vb_device_info *pVBInfo)
2368 unsigned char CR4A, temp;
2369 unsigned short tempbh0, tempbl0;
2378 if (tempbh & 0x20) {
2379 temp = (tempbl >> 4) & 0x02;
2382 xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp);
2385 xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~tempbh0, tempbl0);
2387 CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
2391 tempbl <<= 2; /* GPIOC,GPIOD */
2392 xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */
2393 xgifb_reg_and_or(pVBInfo->P3d4, 0x48, ~tempbh, tempbl);
2396 static void XGI_DisplayOn(struct xgifb_video_info *xgifb_info,
2397 struct xgi_hw_device_info *pXGIHWDE,
2398 struct vb_device_info *pVBInfo)
2401 xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x00);
2402 if (pXGIHWDE->jChipType == XG21) {
2403 if (pVBInfo->IF_DEF_LVDS == 1) {
2404 if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x1)) {
2406 XGI_XG21BLSignalVDD(0x01, 0x01, pVBInfo);
2407 mdelay(xgifb_info->lvds_data.PSC_S2);
2409 if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x20))
2410 /* LVDS signal on */
2411 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo);
2412 mdelay(xgifb_info->lvds_data.PSC_S3);
2413 /* LVDS backlight on */
2414 XGI_XG21BLSignalVDD(0x02, 0x02, pVBInfo);
2416 /* DVO/DVI signal on */
2417 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo);
2422 if (pXGIHWDE->jChipType == XG27) {
2423 if (pVBInfo->IF_DEF_LVDS == 1) {
2424 if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x1)) {
2426 XGI_XG27BLSignalVDD(0x01, 0x01, pVBInfo);
2427 mdelay(xgifb_info->lvds_data.PSC_S2);
2429 if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x20))
2430 /* LVDS signal on */
2431 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo);
2432 mdelay(xgifb_info->lvds_data.PSC_S3);
2433 /* LVDS backlight on */
2434 XGI_XG27BLSignalVDD(0x02, 0x02, pVBInfo);
2436 /* DVO/DVI signal on */
2437 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo);
2443 void XGI_DisplayOff(struct xgifb_video_info *xgifb_info,
2444 struct xgi_hw_device_info *pXGIHWDE,
2445 struct vb_device_info *pVBInfo)
2448 if (pXGIHWDE->jChipType == XG21) {
2449 if (pVBInfo->IF_DEF_LVDS == 1) {
2450 /* LVDS backlight off */
2451 XGI_XG21BLSignalVDD(0x02, 0x00, pVBInfo);
2452 mdelay(xgifb_info->lvds_data.PSC_S3);
2454 /* DVO/DVI signal off */
2455 XGI_XG21BLSignalVDD(0x20, 0x00, pVBInfo);
2459 if (pXGIHWDE->jChipType == XG27) {
2460 if ((XGI_XG27GetPSCValue(pVBInfo) & 0x2)) {
2461 /* LVDS backlight off */
2462 XGI_XG27BLSignalVDD(0x02, 0x00, pVBInfo);
2463 mdelay(xgifb_info->lvds_data.PSC_S3);
2466 if (pVBInfo->IF_DEF_LVDS == 0)
2467 /* DVO/DVI signal off */
2468 XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo);
2471 xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x20);
2474 static void XGI_WaitDisply(struct vb_device_info *pVBInfo)
2476 while ((inb(pVBInfo->P3da) & 0x01))
2479 while (!(inb(pVBInfo->P3da) & 0x01))
2483 static void XGI_AutoThreshold(struct vb_device_info *pVBInfo)
2485 xgifb_reg_or(pVBInfo->Part1Port, 0x01, 0x40);
2488 static void XGI_SaveCRT2Info(unsigned short ModeNo,
2489 struct vb_device_info *pVBInfo)
2491 unsigned short temp1, temp2;
2493 /* reserve CR34 for CRT1 Mode No */
2494 xgifb_reg_set(pVBInfo->P3d4, 0x34, ModeNo);
2495 temp1 = (pVBInfo->VBInfo & SetInSlaveMode) >> 8;
2496 temp2 = ~(SetInSlaveMode >> 8);
2497 xgifb_reg_and_or(pVBInfo->P3d4, 0x31, temp2, temp1);
2500 static void XGI_GetCRT2ResInfo(unsigned short ModeNo,
2501 unsigned short ModeIdIndex,
2502 struct vb_device_info *pVBInfo)
2504 unsigned short xres, yres, modeflag, resindex;
2506 resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO;
2507 xres = XGI330_ModeResInfo[resindex].HTotal; /* xres->ax */
2508 yres = XGI330_ModeResInfo[resindex].VTotal; /* yres->bx */
2509 /* si+St_ModeFlag */
2510 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2512 if (modeflag & HalfDCLK)
2515 if (modeflag & DoubleScanMode)
2518 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
2521 if (pVBInfo->LCDResInfo == Panel_1600x1200) {
2522 if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
2528 if (pVBInfo->LCDResInfo == Panel_1280x1024) {
2531 else if (yres == 350)
2534 if (pVBInfo->LCDInfo & XGI_LCDVESATiming) {
2540 if (pVBInfo->LCDResInfo == Panel_1024x768) {
2541 if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
2542 if (!(pVBInfo->LCDInfo & LCDNonExpanding)) {
2545 else if (yres == 400)
2547 else if (yres == 480)
2557 pVBInfo->VGAHDE = xres;
2558 pVBInfo->HDE = xres;
2559 pVBInfo->VGAVDE = yres;
2560 pVBInfo->VDE = yres;
2563 static unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo)
2566 if ((pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) &&
2567 (pVBInfo->LCDInfo & SetLCDDualLink)) /* shampoo0129 */
2573 static void XGI_GetRAMDAC2DATA(unsigned short ModeNo,
2574 unsigned short ModeIdIndex,
2575 unsigned short RefreshRateTableIndex,
2576 struct vb_device_info *pVBInfo)
2578 unsigned short tempax, tempbx, temp1, temp2, modeflag = 0, tempcx,
2581 pVBInfo->RVBHCMAX = 1;
2582 pVBInfo->RVBHCFACT = 1;
2583 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2584 CRT1Index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
2585 CRT1Index &= IndexMask;
2586 temp1 = (unsigned short) XGI_CRT1Table[CRT1Index].CR[0];
2587 temp2 = (unsigned short) XGI_CRT1Table[CRT1Index].CR[5];
2588 tempax = (temp1 & 0xFF) | ((temp2 & 0x03) << 8);
2589 tempbx = (unsigned short) XGI_CRT1Table[CRT1Index].CR[8];
2590 tempcx = (unsigned short)
2591 XGI_CRT1Table[CRT1Index].CR[14] << 8;
2593 tempcx = tempcx << 2;
2595 temp1 = (unsigned short) XGI_CRT1Table[CRT1Index].CR[9];
2604 if (modeflag & Charx8Dot)
2609 pVBInfo->VGAHT = tempax;
2610 pVBInfo->HT = tempax;
2612 pVBInfo->VGAVT = tempbx;
2613 pVBInfo->VT = tempbx;
2616 static void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex,
2617 unsigned short RefreshRateTableIndex,
2618 struct vb_device_info *pVBInfo)
2620 unsigned short tempax = 0, tempbx = 0, modeflag, resinfo;
2622 struct SiS_LCDData const *LCDPtr = NULL;
2624 /* si+Ext_ResInfo */
2625 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2626 resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO;
2627 pVBInfo->NewFlickerMode = 0;
2628 pVBInfo->RVBHRS = 50;
2630 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
2631 XGI_GetRAMDAC2DATA(ModeNo, ModeIdIndex, RefreshRateTableIndex,
2636 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
2637 LCDPtr = XGI_GetLcdPtr(XGI_LCDDataTable, ModeNo, ModeIdIndex,
2638 RefreshRateTableIndex, pVBInfo);
2640 pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX;
2641 pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT;
2642 pVBInfo->VGAHT = LCDPtr->VGAHT;
2643 pVBInfo->VGAVT = LCDPtr->VGAVT;
2644 pVBInfo->HT = LCDPtr->LCDHT;
2645 pVBInfo->VT = LCDPtr->LCDVT;
2647 if (pVBInfo->LCDResInfo == Panel_1024x768) {
2651 if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
2652 if (pVBInfo->VGAVDE == 357)
2654 else if (pVBInfo->VGAVDE == 420)
2656 else if (pVBInfo->VGAVDE == 525)
2658 else if (pVBInfo->VGAVDE == 600)
2664 } else if (pVBInfo->LCDResInfo == Panel_1024x768x75) {
2667 } else if (pVBInfo->LCDResInfo == Panel_1280x1024) {
2669 if (pVBInfo->VGAVDE == 360)
2671 else if (pVBInfo->VGAVDE == 375)
2673 else if (pVBInfo->VGAVDE == 405)
2677 } else if (pVBInfo->LCDResInfo == Panel_1280x1024x75) {
2680 } else if (pVBInfo->LCDResInfo == Panel_1280x960) {
2682 if (pVBInfo->VGAVDE == 350)
2684 else if (pVBInfo->VGAVDE == 400)
2686 else if (pVBInfo->VGAVDE == 1024)
2690 } else if (pVBInfo->LCDResInfo == Panel_1400x1050) {
2694 if (pVBInfo->VGAVDE == 1024) {
2698 } else if (pVBInfo->LCDResInfo == Panel_1600x1200) {
2700 tempbx = 1200; /* alan 10/14/2003 */
2701 if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
2702 if (pVBInfo->VGAVDE == 350)
2704 else if (pVBInfo->VGAVDE == 400)
2709 if (pVBInfo->LCDInfo & LCDNonExpanding) {
2710 tempax = pVBInfo->VGAHDE;
2711 tempbx = pVBInfo->VGAVDE;
2714 pVBInfo->HDE = tempax;
2715 pVBInfo->VDE = tempbx;
2719 if (pVBInfo->VBInfo & (SetCRT2ToTV)) {
2720 struct SiS_TVData const *TVPtr;
2722 TVPtr = XGI_GetTVPtr(ModeNo, ModeIdIndex, RefreshRateTableIndex,
2725 pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX;
2726 pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT;
2727 pVBInfo->VGAHT = TVPtr->VGAHT;
2728 pVBInfo->VGAVT = TVPtr->VGAVT;
2729 pVBInfo->HDE = TVPtr->TVHDE;
2730 pVBInfo->VDE = TVPtr->TVVDE;
2731 pVBInfo->RVBHRS = TVPtr->RVBHRS;
2732 pVBInfo->NewFlickerMode = TVPtr->FlickerMode;
2734 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
2735 if (resinfo == 0x08)
2736 pVBInfo->NewFlickerMode = 0x40;
2737 else if (resinfo == 0x09)
2738 pVBInfo->NewFlickerMode = 0x40;
2739 else if (resinfo == 0x12)
2740 pVBInfo->NewFlickerMode = 0x40;
2742 if (pVBInfo->VGAVDE == 350)
2743 pVBInfo->TVInfo |= TVSimuMode;
2748 if (pVBInfo->VBInfo & SetInSlaveMode) {
2749 if (pVBInfo->TVInfo & TVSimuMode) {
2753 if (!(modeflag & Charx8Dot)) {
2754 tempax = StHiTextTVHT;
2755 tempbx = StHiTextTVVT;
2759 } else if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
2760 if (pVBInfo->TVInfo & TVSetYPbPr750p) {
2761 tempax = YPbPrTV750pHT; /* Ext750pTVHT */
2762 tempbx = YPbPrTV750pVT; /* Ext750pTVVT */
2765 if (pVBInfo->TVInfo & TVSetYPbPr525p) {
2766 tempax = YPbPrTV525pHT; /* Ext525pTVHT */
2767 tempbx = YPbPrTV525pVT; /* Ext525pTVVT */
2768 } else if (pVBInfo->TVInfo & TVSetYPbPr525i) {
2769 tempax = YPbPrTV525iHT; /* Ext525iTVHT */
2770 tempbx = YPbPrTV525iVT; /* Ext525iTVVT */
2771 if (pVBInfo->TVInfo & NTSC1024x768)
2772 tempax = NTSC1024x768HT;
2777 if (!(pVBInfo->TVInfo & TVSetPAL)) {
2780 if (pVBInfo->TVInfo & NTSC1024x768)
2781 tempax = NTSC1024x768HT;
2785 pVBInfo->HT = tempax;
2786 pVBInfo->VT = tempbx;
2791 static void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex,
2792 unsigned short RefreshRateTableIndex,
2793 struct vb_device_info *pVBInfo)
2795 unsigned char di_0, di_1, tempal;
2797 tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex,
2799 XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo);
2800 XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo);
2802 if (pVBInfo->VBType & VB_SIS301) { /* shampoo 0129 */
2804 xgifb_reg_set(pVBInfo->Part4Port, 0x0A, 0x10);
2805 xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1);
2806 xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0);
2807 } else { /* 301b/302b/301lv/302lv */
2808 xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0);
2809 xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1);
2812 xgifb_reg_set(pVBInfo->Part4Port, 0x00, 0x12);
2814 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC)
2815 xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x28);
2817 xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x08);
2820 static unsigned short XGI_GetColorDepth(unsigned short ModeNo,
2821 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
2823 unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8 };
2825 unsigned short modeflag;
2827 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2828 index = (modeflag & ModeTypeMask) - ModeEGA;
2833 return ColorDepth[index];
2836 static unsigned short XGI_GetOffset(unsigned short ModeNo,
2837 unsigned short ModeIdIndex,
2838 unsigned short RefreshRateTableIndex,
2839 struct xgi_hw_device_info *HwDeviceExtension,
2840 struct vb_device_info *pVBInfo)
2842 unsigned short temp, colordepth, modeinfo, index, infoflag,
2843 ColorDepth[] = { 0x01, 0x02, 0x04 };
2845 modeinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeInfo;
2846 infoflag = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
2848 index = (modeinfo >> 8) & 0xFF;
2850 temp = XGI330_ScreenOffset[index];
2852 if (infoflag & InterlaceMode)
2855 colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo);
2857 if ((ModeNo >= 0x7C) && (ModeNo <= 0x7E)) {
2858 temp = ModeNo - 0x7C;
2859 colordepth = ColorDepth[temp];
2861 if (infoflag & InterlaceMode)
2864 return temp * colordepth;
2867 static void XGI_SetCRT2Offset(unsigned short ModeNo,
2868 unsigned short ModeIdIndex,
2869 unsigned short RefreshRateTableIndex,
2870 struct xgi_hw_device_info *HwDeviceExtension,
2871 struct vb_device_info *pVBInfo)
2873 unsigned short offset;
2876 if (pVBInfo->VBInfo & SetInSlaveMode)
2879 offset = XGI_GetOffset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
2880 HwDeviceExtension, pVBInfo);
2881 temp = (unsigned char) (offset & 0xFF);
2882 xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp);
2883 temp = (unsigned char) ((offset & 0xFF00) >> 8);
2884 xgifb_reg_set(pVBInfo->Part1Port, 0x09, temp);
2885 temp = (unsigned char) (((offset >> 3) & 0xFF) + 1);
2886 xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp);
2889 static void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo)
2891 /* threshold high ,disable auto threshold */
2892 xgifb_reg_set(pVBInfo->Part1Port, 0x01, 0x3B);
2893 /* threshold low default 04h */
2894 xgifb_reg_and_or(pVBInfo->Part1Port, 0x02, ~(0x3F), 0x04);
2897 static void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
2898 struct xgi_hw_device_info *HwDeviceExtension,
2899 unsigned short RefreshRateTableIndex,
2900 struct vb_device_info *pVBInfo)
2904 XGI_SetCRT2Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
2905 HwDeviceExtension, pVBInfo);
2906 XGI_SetCRT2FIFO(pVBInfo);
2908 for (tempcx = 4; tempcx < 7; tempcx++)
2909 xgifb_reg_set(pVBInfo->Part1Port, tempcx, 0x0);
2911 xgifb_reg_set(pVBInfo->Part1Port, 0x50, 0x00);
2912 xgifb_reg_set(pVBInfo->Part1Port, 0x02, 0x44); /* temp 0206 */
2915 static void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
2916 struct xgi_hw_device_info *HwDeviceExtension,
2917 unsigned short RefreshRateTableIndex,
2918 struct vb_device_info *pVBInfo)
2920 unsigned short temp = 0, tempax = 0, tempbx = 0, tempcx = 0,
2921 pushbx = 0, CRT1Index, modeflag;
2923 CRT1Index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
2924 CRT1Index &= IndexMask;
2925 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2927 /* bainy change table name */
2928 if (modeflag & HalfDCLK) {
2929 /* BTVGA2HT 0x08,0x09 */
2930 temp = (pVBInfo->VGAHT / 2 - 1) & 0x0FF;
2931 xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp);
2932 temp = (((pVBInfo->VGAHT / 2 - 1) & 0xFF00) >> 8) << 4;
2933 xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp);
2934 /* BTVGA2HDEE 0x0A,0x0C */
2935 temp = (pVBInfo->VGAHDE / 2 + 16) & 0x0FF;
2936 xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp);
2937 tempcx = ((pVBInfo->VGAHT - pVBInfo->VGAHDE) / 2) >> 2;
2938 pushbx = pVBInfo->VGAHDE / 2 + 16;
2939 tempcx = tempcx >> 1;
2940 tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */
2943 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
2944 tempbx = XGI_CRT1Table[CRT1Index].CR[4];
2945 tempbx |= ((XGI_CRT1Table[CRT1Index].CR[14] &
2947 tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */
2948 tempcx = XGI_CRT1Table[CRT1Index].CR[5];
2950 temp = XGI_CRT1Table[CRT1Index].CR[15];
2951 temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */
2952 tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */
2958 if (tempcx > (pVBInfo->VGAHT / 2))
2959 tempcx = pVBInfo->VGAHT / 2;
2961 temp = tempbx & 0x00FF;
2963 xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp);
2965 temp = (pVBInfo->VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */
2966 xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp);
2967 temp = (((pVBInfo->VGAHT - 1) & 0xFF00) >> 8) << 4;
2968 xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp);
2969 /* BTVGA2HDEE 0x0A,0x0C */
2970 temp = (pVBInfo->VGAHDE + 16) & 0x0FF;
2971 xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp);
2972 tempcx = (pVBInfo->VGAHT - pVBInfo->VGAHDE) >> 2; /* cx */
2973 pushbx = pVBInfo->VGAHDE + 16;
2974 tempcx = tempcx >> 1;
2975 tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */
2978 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
2979 tempbx = XGI_CRT1Table[CRT1Index].CR[3];
2980 tempbx |= ((XGI_CRT1Table[CRT1Index].CR[5] &
2982 tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */
2983 tempcx = XGI_CRT1Table[CRT1Index].CR[4];
2985 temp = XGI_CRT1Table[CRT1Index].CR[6];
2986 temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */
2987 tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */
2992 if (tempcx > pVBInfo->VGAHT)
2993 tempcx = pVBInfo->VGAHT;
2995 temp = tempbx & 0x00FF;
2996 xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp);
2999 tempax = (tempax & 0x00FF) | (tempbx & 0xFF00);
3001 tempbx = (tempbx & 0x00FF) | ((tempbx & 0xFF00) << 4);
3002 tempax |= (tempbx & 0xFF00);
3003 temp = (tempax & 0xFF00) >> 8;
3004 xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp);
3005 temp = tempcx & 0x00FF;
3006 xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp);
3007 tempcx = (pVBInfo->VGAVT - 1);
3008 temp = tempcx & 0x00FF;
3010 xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp);
3011 tempbx = pVBInfo->VGAVDE - 1;
3012 temp = tempbx & 0x00FF;
3013 xgifb_reg_set(pVBInfo->Part1Port, 0x0F, temp);
3014 temp = ((tempbx & 0xFF00) << 3) >> 8;
3015 temp |= ((tempcx & 0xFF00) >> 8);
3016 xgifb_reg_set(pVBInfo->Part1Port, 0x12, temp);
3018 tempax = pVBInfo->VGAVDE;
3019 tempbx = pVBInfo->VGAVDE;
3020 tempcx = pVBInfo->VGAVT;
3021 /* BTVGA2VRS 0x10,0x11 */
3022 tempbx = (pVBInfo->VGAVT + pVBInfo->VGAVDE) >> 1;
3023 /* BTVGA2VRE 0x11 */
3024 tempcx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) >> 4) + tempbx + 1;
3026 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
3027 tempbx = XGI_CRT1Table[CRT1Index].CR[10];
3028 temp = XGI_CRT1Table[CRT1Index].CR[9];
3036 temp = XGI_CRT1Table[CRT1Index].CR[14];
3041 temp = XGI_CRT1Table[CRT1Index].CR[11];
3042 tempcx = (tempcx & 0xFF00) | (temp & 0x00FF);
3045 temp = tempbx & 0x00FF;
3046 xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp);
3047 temp = ((tempbx & 0xFF00) >> 8) << 4;
3048 temp = ((tempcx & 0x000F) | (temp));
3049 xgifb_reg_set(pVBInfo->Part1Port, 0x11, temp);
3052 if (modeflag & DoubleScanMode)
3055 if (modeflag & HalfDCLK)
3058 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2C, ~0x0C0, tempax);
3061 static unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo)
3063 unsigned long tempax, tempbx;
3065 tempbx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) * pVBInfo->RVBHCMAX)
3067 tempax = (pVBInfo->VT - pVBInfo->VDE) * pVBInfo->RVBHCFACT;
3068 tempax = (tempax * pVBInfo->HT) / tempbx;
3070 return (unsigned short) tempax;
3073 static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
3074 struct xgi_hw_device_info *HwDeviceExtension,
3075 unsigned short RefreshRateTableIndex,
3076 struct vb_device_info *pVBInfo)
3078 unsigned short push1, push2, tempax, tempbx = 0, tempcx, temp, resinfo,
3081 /* si+Ext_ResInfo */
3082 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3083 resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO;
3085 if (!(pVBInfo->VBInfo & SetInSlaveMode))
3088 temp = 0xFF; /* set MAX HT */
3089 xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp);
3092 if (pVBInfo->VBType & (VB_SIS301LV | VB_SIS302LV | VB_XGI301C))
3093 modeflag |= Charx8Dot;
3095 tempax = pVBInfo->VGAHDE; /* 0x04 Horizontal Display End */
3097 if (modeflag & HalfDCLK)
3098 tempax = tempax >> 1;
3100 tempax = (tempax / tempcx) - 1;
3101 tempbx |= ((tempax & 0x00FF) << 8);
3102 temp = tempax & 0x00FF;
3103 xgifb_reg_set(pVBInfo->Part1Port, 0x04, temp);
3105 temp = (tempbx & 0xFF00) >> 8;
3107 if (pVBInfo->VBInfo & SetCRT2ToTV) {
3108 if (!(pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
3109 | VB_SIS302LV | VB_XGI301C)))
3112 if ((pVBInfo->VBInfo & SetCRT2ToHiVision) &&
3113 !(pVBInfo->VBType & VB_SIS301LV) && (resinfo == 7))
3117 /* 0x05 Horizontal Display Start */
3118 xgifb_reg_set(pVBInfo->Part1Port, 0x05, temp);
3119 /* 0x06 Horizontal Blank end */
3120 xgifb_reg_set(pVBInfo->Part1Port, 0x06, 0x03);
3122 if (!(pVBInfo->VBInfo & DisableCRT2Display)) { /* 030226 bainy */
3123 if (pVBInfo->VBInfo & SetCRT2ToTV)
3124 tempax = pVBInfo->VGAHT;
3126 tempax = XGI_GetVGAHT2(pVBInfo);
3129 if (tempax >= pVBInfo->VGAHT)
3130 tempax = pVBInfo->VGAHT;
3132 if (modeflag & HalfDCLK)
3133 tempax = tempax >> 1;
3135 tempax = (tempax / tempcx) - 5;
3136 tempcx = tempax; /* 20030401 0x07 horizontal Retrace Start */
3137 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
3138 temp = (tempbx & 0x00FF) - 1;
3139 if (!(modeflag & HalfDCLK)) {
3141 if (pVBInfo->TVInfo & TVSimuMode) {
3147 tempbx = (tempbx & 0xFF00) >> 8;
3148 tempcx = (tempcx + tempbx) >> 1;
3149 temp = (tempcx & 0x00FF) + 2;
3151 if (pVBInfo->VBInfo & SetCRT2ToTV) {
3153 if (!(modeflag & HalfDCLK)) {
3154 if ((modeflag & Charx8Dot)) {
3156 if (pVBInfo->VGAHDE >= 800)
3160 } else if (!(modeflag & HalfDCLK)) {
3162 if (pVBInfo->LCDResInfo != Panel_1280x960 &&
3163 pVBInfo->VGAHDE >= 800) {
3165 if (pVBInfo->VGAHDE >= 1280 &&
3166 pVBInfo->LCDResInfo != Panel_1280x960 &&
3167 (pVBInfo->LCDInfo & LCDNonExpanding))
3173 /* 0x07 Horizontal Retrace Start */
3174 xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp);
3175 /* 0x08 Horizontal Retrace End */
3176 xgifb_reg_set(pVBInfo->Part1Port, 0x08, 0);
3178 if (pVBInfo->VBInfo & SetCRT2ToTV) {
3179 if (pVBInfo->TVInfo & TVSimuMode) {
3180 if (ModeNo == 0x50) {
3181 if (pVBInfo->TVInfo & SetNTSCTV) {
3182 xgifb_reg_set(pVBInfo->Part1Port,
3184 xgifb_reg_set(pVBInfo->Part1Port,
3187 xgifb_reg_set(pVBInfo->Part1Port,
3189 xgifb_reg_set(pVBInfo->Part1Port,
3196 xgifb_reg_set(pVBInfo->Part1Port, 0x18, 0x03); /* 0x18 SR0B */
3197 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0xF0, 0x00);
3198 xgifb_reg_set(pVBInfo->Part1Port, 0x09, 0xFF); /* 0x09 Set Max VT */
3200 tempbx = pVBInfo->VGAVT;
3203 tempbx = pVBInfo->VGAVDE; /* 0x0E Virtical Display End */
3218 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
3219 if (pVBInfo->LCDResInfo == Panel_1024x768) {
3220 if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
3229 temp = tempbx & 0x00FF;
3231 temp = tempbx & 0x00FF;
3232 /* 0x10 vertical Blank Start */
3233 xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp);
3236 temp = tempbx & 0x00FF;
3237 xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp);
3239 if (tempbx & 0x0100)
3244 if (modeflag & DoubleScanMode)
3247 if (tempbx & 0x0200)
3250 temp = (tempax & 0xFF00) >> 8;
3251 xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp);
3253 if (tempbx & 0x0400)
3256 /* 0x11 Vertival Blank End */
3257 xgifb_reg_set(pVBInfo->Part1Port, 0x11, 0x00);
3260 tempax -= tempbx; /* 0x0C Vertical Retrace Start */
3261 tempax = tempax >> 2;
3262 push1 = tempax; /* push ax */
3264 if (resinfo != 0x09) {
3265 tempax = tempax << 1;
3269 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
3270 if ((pVBInfo->VBType & VB_SIS301LV) &&
3271 !(pVBInfo->TVInfo & TVSetHiVision)) {
3272 if ((pVBInfo->TVInfo & TVSimuMode) &&
3273 (pVBInfo->TVInfo & TVSetPAL)) {
3274 if (!(pVBInfo->VBType & VB_SIS301LV) ||
3284 } else if (pVBInfo->TVInfo & TVSimuMode) {
3285 if (pVBInfo->TVInfo & TVSetPAL) {
3286 if (pVBInfo->VBType & VB_SIS301LV) {
3287 if (!(pVBInfo->TVInfo &
3298 tempax = tempax >> 2;
3301 push1 = tempax; /* push ax */
3303 if ((pVBInfo->TVInfo & TVSetPAL)) {
3304 if (tempbx <= 513) {
3310 temp = tempbx & 0x00FF;
3311 xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp);
3313 temp = tempbx & 0x00FF;
3314 xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp);
3316 if (tempbx & 0x0100)
3319 if (tempbx & 0x0200)
3320 xgifb_reg_and_or(pVBInfo->Part1Port, 0x0B, 0x0FF, 0x20);
3324 if (tempbx & 0x0100)
3327 if (tempbx & 0x0200)
3330 if (tempbx & 0x0400)
3333 tempbx = push1; /* pop ax */
3334 temp = tempbx & 0x00FF;
3336 /* 0x0D vertical Retrace End */
3337 xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp);
3339 if (tempbx & 0x0010)
3342 temp = tempcx & 0x00FF;
3343 xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); /* 0x0A CR07 */
3344 temp = (tempcx & 0x0FF00) >> 8;
3345 xgifb_reg_set(pVBInfo->Part1Port, 0x17, temp); /* 0x17 SR0A */
3347 temp = (tempax & 0xFF00) >> 8;
3349 temp = (temp >> 1) & 0x09;
3351 if (pVBInfo->VBType & (VB_SIS301LV | VB_SIS302LV | VB_XGI301C))
3354 xgifb_reg_set(pVBInfo->Part1Port, 0x16, temp); /* 0x16 SR01 */
3355 xgifb_reg_set(pVBInfo->Part1Port, 0x0F, 0); /* 0x0F CR14 */
3356 xgifb_reg_set(pVBInfo->Part1Port, 0x12, 0); /* 0x12 CR17 */
3358 if (pVBInfo->LCDInfo & LCDRGB18Bit)
3363 xgifb_reg_set(pVBInfo->Part1Port, 0x1A, temp); /* 0x1A SR0E */
3368 static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex,
3369 unsigned short RefreshRateTableIndex,
3370 struct xgi_hw_device_info *HwDeviceExtension,
3371 struct vb_device_info *pVBInfo)
3373 unsigned short i, j, tempax, tempbx, tempcx, temp, push1, push2,
3375 unsigned char const *TimingPoint;
3377 unsigned long longtemp, tempeax, tempebx, temp2, tempecx;
3379 /* si+Ext_ResInfo */
3380 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3384 if (!(pVBInfo->VBInfo & SetCRT2ToAVIDEO))
3387 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
3390 if (pVBInfo->VBInfo & SetCRT2ToSCART)
3393 if (!(pVBInfo->TVInfo & TVSetPAL))
3396 if (pVBInfo->VBInfo & SetCRT2ToHiVision)
3399 if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p))
3402 tempax = (tempax & 0xff00) >> 8;
3404 xgifb_reg_set(pVBInfo->Part2Port, 0x0, tempax);
3405 TimingPoint = XGI330_NTSCTiming;
3407 if (pVBInfo->TVInfo & TVSetPAL)
3408 TimingPoint = XGI330_PALTiming;
3410 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
3411 TimingPoint = XGI330_HiTVExtTiming;
3413 if (pVBInfo->VBInfo & SetInSlaveMode)
3414 TimingPoint = XGI330_HiTVSt2Timing;
3416 if (pVBInfo->SetFlag & TVSimuMode)
3417 TimingPoint = XGI330_HiTVSt1Timing;
3419 if (!(modeflag & Charx8Dot))
3420 TimingPoint = XGI330_HiTVTextTiming;
3423 if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
3424 if (pVBInfo->TVInfo & TVSetYPbPr525i)
3425 TimingPoint = XGI330_YPbPr525iTiming;
3427 if (pVBInfo->TVInfo & TVSetYPbPr525p)
3428 TimingPoint = XGI330_YPbPr525pTiming;
3430 if (pVBInfo->TVInfo & TVSetYPbPr750p)
3431 TimingPoint = XGI330_YPbPr750pTiming;
3434 for (i = 0x01, j = 0; i <= 0x2D; i++, j++)
3435 xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]);
3437 for (i = 0x39; i <= 0x45; i++, j++)
3439 xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]);
3441 if (pVBInfo->VBInfo & SetCRT2ToTV)
3442 xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, 0x00);
3444 temp = pVBInfo->NewFlickerMode;
3446 xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xFF, temp);
3448 if (pVBInfo->VBInfo & SetCRT2ToHiVision)
3451 if (pVBInfo->TVInfo & TVSetPAL)
3456 if (pVBInfo->VDE <= tempax) {
3457 tempax -= pVBInfo->VDE;
3458 tempax = tempax >> 2;
3459 tempax = (tempax & 0x00FF) | ((tempax & 0x00FF) << 8);
3461 temp = (tempax & 0xFF00) >> 8;
3462 temp += (unsigned short) TimingPoint[0];
3464 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
3465 | VB_SIS302LV | VB_XGI301C)) {
3466 if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO
3467 | SetCRT2ToSVIDEO | SetCRT2ToSCART
3468 | SetCRT2ToYPbPr525750)) {
3469 tempcx = pVBInfo->VGAHDE;
3470 if (tempcx >= 1024) {
3471 temp = 0x17; /* NTSC */
3472 if (pVBInfo->TVInfo & TVSetPAL)
3473 temp = 0x19; /* PAL */
3478 xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp);
3480 temp = (tempax & 0xFF00) >> 8;
3481 temp += TimingPoint[1];
3483 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
3484 | VB_SIS302LV | VB_XGI301C)) {
3485 if ((pVBInfo->VBInfo & (SetCRT2ToAVIDEO
3486 | SetCRT2ToSVIDEO | SetCRT2ToSCART
3487 | SetCRT2ToYPbPr525750))) {
3488 tempcx = pVBInfo->VGAHDE;
3489 if (tempcx >= 1024) {
3490 temp = 0x1D; /* NTSC */
3491 if (pVBInfo->TVInfo & TVSetPAL)
3492 temp = 0x52; /* PAL */
3496 xgifb_reg_set(pVBInfo->Part2Port, 0x02, temp);
3500 tempcx = pVBInfo->HT;
3502 if (XGI_IsLCDDualLink(pVBInfo))
3503 tempcx = tempcx >> 1;
3506 temp = tempcx & 0x00FF;
3507 xgifb_reg_set(pVBInfo->Part2Port, 0x1B, temp);
3509 temp = (tempcx & 0xFF00) >> 8;
3510 xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F, temp);
3512 tempcx = pVBInfo->HT >> 1;
3513 push1 = tempcx; /* push cx */
3516 if (pVBInfo->VBInfo & SetCRT2ToHiVision)
3519 temp = tempcx & 0x00FF;
3521 xgifb_reg_and_or(pVBInfo->Part2Port, 0x22, 0x0F, temp);
3523 tempbx = TimingPoint[j] | ((TimingPoint[j + 1]) << 8);
3526 temp = tempbx & 0x00FF;
3527 xgifb_reg_set(pVBInfo->Part2Port, 0x24, temp);
3528 temp = (tempbx & 0xFF00) >> 8;
3530 xgifb_reg_and_or(pVBInfo->Part2Port, 0x25, 0x0F, temp);
3533 tempbx = tempbx + 8;
3534 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
3535 tempbx = tempbx - 4;
3539 temp = (tempbx & 0x00FF) << 4;
3540 xgifb_reg_and_or(pVBInfo->Part2Port, 0x29, 0x0F, temp);
3543 tempcx += (TimingPoint[j] | ((TimingPoint[j + 1]) << 8));
3544 temp = tempcx & 0x00FF;
3545 xgifb_reg_set(pVBInfo->Part2Port, 0x27, temp);
3546 temp = ((tempcx & 0xFF00) >> 8) << 4;
3547 xgifb_reg_and_or(pVBInfo->Part2Port, 0x28, 0x0F, temp);
3550 if (pVBInfo->VBInfo & SetCRT2ToHiVision)
3553 temp = tempcx & 0xFF;
3555 xgifb_reg_and_or(pVBInfo->Part2Port, 0x2A, 0x0F, temp);
3557 tempcx = push1; /* pop cx */
3559 temp = TimingPoint[j] | ((TimingPoint[j + 1]) << 8);
3561 temp = tempcx & 0x00FF;
3563 xgifb_reg_and_or(pVBInfo->Part2Port, 0x2D, 0x0F, temp);
3567 if (!(pVBInfo->VBInfo & SetCRT2ToTV)) {
3568 tempax = XGI_GetVGAHT2(pVBInfo);
3569 tempcx = tempax - 1;
3571 temp = tempcx & 0x00FF;
3572 xgifb_reg_set(pVBInfo->Part2Port, 0x2E, temp);
3574 tempbx = pVBInfo->VDE;
3576 if (pVBInfo->VGAVDE == 360)
3578 if (pVBInfo->VGAVDE == 375)
3580 if (pVBInfo->VGAVDE == 405)
3583 if (pVBInfo->VBInfo & SetCRT2ToTV) {
3584 if (pVBInfo->VBType &
3585 (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) {
3586 if (!(pVBInfo->TVInfo &
3587 (TVSetYPbPr525p | TVSetYPbPr750p)))
3588 tempbx = tempbx >> 1;
3590 tempbx = tempbx >> 1;
3594 temp = tempbx & 0x00FF;
3596 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
3597 if (pVBInfo->VBType & VB_SIS301LV) {
3598 if (pVBInfo->TVInfo & TVSetHiVision) {
3599 if (pVBInfo->VBInfo & SetInSlaveMode) {
3604 } else if (pVBInfo->VBInfo & SetInSlaveMode) {
3610 xgifb_reg_set(pVBInfo->Part2Port, 0x2F, temp);
3612 temp = (tempcx & 0xFF00) >> 8;
3613 temp |= ((tempbx & 0xFF00) >> 8) << 6;
3615 if (!(pVBInfo->VBInfo & SetCRT2ToHiVision)) {
3616 if (pVBInfo->VBType & VB_SIS301LV) {
3617 if (pVBInfo->TVInfo & TVSetHiVision) {
3620 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
3625 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
3630 xgifb_reg_set(pVBInfo->Part2Port, 0x30, temp);
3632 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
3633 | VB_SIS302LV | VB_XGI301C)) { /* TV gatingno */
3634 tempbx = pVBInfo->VDE;
3635 tempcx = tempbx - 2;
3637 if (pVBInfo->VBInfo & SetCRT2ToTV) {
3638 if (!(pVBInfo->TVInfo & (TVSetYPbPr525p
3640 tempbx = tempbx >> 1;
3643 if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) {
3645 if (tempcx & 0x0400)
3648 if (tempbx & 0x0400)
3651 xgifb_reg_set(pVBInfo->Part4Port, 0x10, temp);
3654 temp = (((tempbx - 3) & 0x0300) >> 8) << 5;
3655 xgifb_reg_set(pVBInfo->Part2Port, 0x46, temp);
3656 temp = (tempbx - 3) & 0x00FF;
3657 xgifb_reg_set(pVBInfo->Part2Port, 0x47, temp);
3660 tempbx = tempbx & 0x00FF;
3662 if (!(modeflag & HalfDCLK)) {
3663 tempcx = pVBInfo->VGAHDE;
3664 if (tempcx >= pVBInfo->HDE) {
3672 if (pVBInfo->VBInfo & SetCRT2ToTV) { /*301b*/
3673 if (pVBInfo->VGAHDE >= 1024) {
3675 if (pVBInfo->VGAHDE >= 1280) {
3677 tempbx = tempbx & 0xDFFF;
3682 if (!(tempbx & 0x2000)) {
3683 if (modeflag & HalfDCLK)
3684 tempcx = (tempcx & 0xFF00) | ((tempcx & 0x00FF) << 1);
3687 tempeax = pVBInfo->VGAHDE;
3688 tempebx = (tempcx & 0xFF00) >> 8;
3689 longtemp = tempeax * tempebx;
3690 tempecx = tempcx & 0x00FF;
3691 longtemp = longtemp / tempecx;
3696 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
3697 | VB_SIS302LV | VB_XGI301C)) {
3698 tempecx = tempecx * 8;
3701 longtemp = longtemp * tempecx;
3702 tempecx = pVBInfo->HDE;
3703 temp2 = longtemp % tempecx;
3704 tempeax = longtemp / tempecx;
3708 tempax = (unsigned short) tempeax;
3711 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
3712 | VB_SIS302LV | VB_XGI301C)) {
3713 tempcx = ((tempax & 0xFF00) >> 5) >> 8;
3718 tempbx = (unsigned short) (((tempeax & 0x0000FF00) & 0x1F00)
3719 | (tempbx & 0x00FF));
3720 tempax = (unsigned short) (((tempeax & 0x000000FF) << 8)
3721 | (tempax & 0x00FF));
3722 temp = (tempax & 0xFF00) >> 8;
3724 temp = (tempax & 0x00FF) >> 8;
3727 xgifb_reg_set(pVBInfo->Part2Port, 0x44, temp);
3728 temp = (tempbx & 0xFF00) >> 8;
3729 xgifb_reg_and_or(pVBInfo->Part2Port, 0x45, ~0x03F, temp);
3730 temp = tempcx & 0x00FF;
3732 if (tempbx & 0x2000)
3735 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
3738 xgifb_reg_and_or(pVBInfo->Part2Port, 0x46, ~0x1F, temp);
3739 if (pVBInfo->TVInfo & TVSetPAL) {
3747 temp = tempbx & 0x00FF;
3748 xgifb_reg_set(pVBInfo->Part2Port, 0x4b, temp);
3749 temp = tempcx & 0x00FF;
3750 xgifb_reg_set(pVBInfo->Part2Port, 0x4c, temp);
3752 temp = ((tempcx & 0xFF00) >> 8) & 0x03;
3754 temp |= ((tempbx & 0xFF00) >> 8) & 0x03;
3756 if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
3759 if (pVBInfo->TVInfo & TVSetYPbPr525p)
3762 if (pVBInfo->TVInfo & TVSetYPbPr750p)
3766 xgifb_reg_set(pVBInfo->Part2Port, 0x4d, temp);
3767 temp = xgifb_reg_get(pVBInfo->Part2Port, 0x43); /* 301b change */
3768 xgifb_reg_set(pVBInfo->Part2Port, 0x43, (unsigned short) (temp - 3));
3770 if (!(pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p))) {
3771 if (pVBInfo->TVInfo & NTSC1024x768) {
3772 TimingPoint = XGI_NTSC1024AdjTime;
3773 for (i = 0x1c, j = 0; i <= 0x30; i++, j++) {
3774 xgifb_reg_set(pVBInfo->Part2Port, i,
3777 xgifb_reg_set(pVBInfo->Part2Port, 0x43, 0x72);
3781 /* Modify for 301C PALM Support */
3782 if (pVBInfo->VBType & VB_XGI301C) {
3783 if (pVBInfo->TVInfo & TVSetPALM)
3784 xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x08,
3785 0x08); /* PALM Mode */
3788 if (pVBInfo->TVInfo & TVSetPALM) {
3789 tempax = xgifb_reg_get(pVBInfo->Part2Port, 0x01);
3791 xgifb_reg_and(pVBInfo->Part2Port, 0x01, tempax);
3793 xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xEF);
3796 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
3797 if (!(pVBInfo->VBInfo & SetInSlaveMode))
3798 xgifb_reg_set(pVBInfo->Part2Port, 0x0B, 0x00);
3801 if (pVBInfo->VBInfo & SetCRT2ToTV)
3805 static void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
3806 struct xgi_hw_device_info *HwDeviceExtension,
3807 unsigned short RefreshRateTableIndex,
3808 struct vb_device_info *pVBInfo)
3810 unsigned short pushbx, tempax, tempbx, tempcx, temp, tempah,
3813 struct XGI_LCDDesStruct const *LCDBDesPtr = NULL;
3815 /* si+Ext_ResInfo */
3816 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
3819 tempbx = pVBInfo->HDE; /* RHACTE=HDE-1 */
3821 if (XGI_IsLCDDualLink(pVBInfo))
3822 tempbx = tempbx >> 1;
3825 temp = tempbx & 0x00FF;
3826 xgifb_reg_set(pVBInfo->Part2Port, 0x2C, temp);
3827 temp = (tempbx & 0xFF00) >> 8;
3829 xgifb_reg_and_or(pVBInfo->Part2Port, 0x2B, 0x0F, temp);
3832 xgifb_reg_set(pVBInfo->Part2Port, 0x0B, temp);
3833 tempbx = pVBInfo->VDE; /* RTVACTEO=(VDE-1)&0xFF */
3835 temp = tempbx & 0x00FF;
3836 xgifb_reg_set(pVBInfo->Part2Port, 0x03, temp);
3837 temp = ((tempbx & 0xFF00) >> 8) & 0x07;
3838 xgifb_reg_and_or(pVBInfo->Part2Port, 0x0C, ~0x07, temp);
3840 tempcx = pVBInfo->VT - 1;
3841 temp = tempcx & 0x00FF; /* RVTVT=VT-1 */
3842 xgifb_reg_set(pVBInfo->Part2Port, 0x19, temp);
3843 temp = (tempcx & 0xFF00) >> 8;
3845 xgifb_reg_set(pVBInfo->Part2Port, 0x1A, temp);
3846 xgifb_reg_and_or(pVBInfo->Part2Port, 0x09, 0xF0, 0x00);
3847 xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xF0, 0x00);
3848 xgifb_reg_and_or(pVBInfo->Part2Port, 0x17, 0xFB, 0x00);
3849 xgifb_reg_and_or(pVBInfo->Part2Port, 0x18, 0xDF, 0x00);
3851 /* Customized LCDB Does not add */
3852 if ((pVBInfo->VBType & VB_SIS301LV) || (pVBInfo->VBType & VB_SIS302LV))
3853 LCDBDesPtr = XGI_GetLcdPtr(xgifb_lcddldes, ModeNo, ModeIdIndex,
3854 RefreshRateTableIndex, pVBInfo);
3856 LCDBDesPtr = XGI_GetLcdPtr(XGI_LCDDesDataTable, ModeNo,
3857 ModeIdIndex, RefreshRateTableIndex,
3860 tempah = pVBInfo->LCDResInfo;
3861 tempah &= PanelResInfo;
3863 if ((tempah == Panel_1024x768) || (tempah == Panel_1024x768x75)) {
3866 } else if ((tempah == Panel_1280x1024) ||
3867 (tempah == Panel_1280x1024x75)) {
3870 } else if (tempah == Panel_1400x1050) {
3878 if (pVBInfo->LCDInfo & EnableScalingLCD) {
3879 tempbx = pVBInfo->HDE;
3880 tempcx = pVBInfo->VDE;
3884 tempax = pVBInfo->VT;
3885 pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES;
3886 pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS;
3887 pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES;
3888 pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS;
3889 tempbx = pVBInfo->LCDVDES;
3892 if (tempcx >= tempax)
3893 tempcx -= tempax; /* lcdvdes */
3895 temp = tempbx & 0x00FF; /* RVEQ1EQ=lcdvdes */
3896 xgifb_reg_set(pVBInfo->Part2Port, 0x05, temp);
3897 temp = tempcx & 0x00FF;
3898 xgifb_reg_set(pVBInfo->Part2Port, 0x06, temp);
3899 tempch = ((tempcx & 0xFF00) >> 8) & 0x07;
3900 tempbh = ((tempbx & 0xFF00) >> 8) & 0x07;
3902 tempah = tempah << 3;
3904 xgifb_reg_set(pVBInfo->Part2Port, 0x02, tempah);
3907 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
3909 tempax = pVBInfo->VT;
3910 tempbx = pVBInfo->LCDVRS;
3913 if (tempcx >= tempax)
3916 temp = tempbx & 0x00FF; /* RTVACTEE=lcdvrs */
3917 xgifb_reg_set(pVBInfo->Part2Port, 0x04, temp);
3918 temp = (tempbx & 0xFF00) >> 8;
3920 temp |= (tempcx & 0x000F);
3921 xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp);
3923 tempax = pVBInfo->HT;
3924 tempbx = pVBInfo->LCDHDES;
3927 if (XGI_IsLCDDualLink(pVBInfo)) {
3928 tempax = tempax >> 1;
3929 tempbx = tempbx >> 1;
3930 tempcx = tempcx >> 1;
3933 if (pVBInfo->VBType & VB_SIS302LV)
3936 if (pVBInfo->VBType & VB_XGI301C) /* tap4 */
3941 if (tempcx >= tempax)
3944 temp = tempbx & 0x00FF;
3945 xgifb_reg_set(pVBInfo->Part2Port, 0x1F, temp); /* RHBLKE=lcdhdes */
3946 temp = ((tempbx & 0xFF00) >> 8) << 4;
3947 xgifb_reg_set(pVBInfo->Part2Port, 0x20, temp);
3948 temp = tempcx & 0x00FF;
3949 xgifb_reg_set(pVBInfo->Part2Port, 0x23, temp); /* RHEQPLE=lcdhdee */
3950 temp = (tempcx & 0xFF00) >> 8;
3951 xgifb_reg_set(pVBInfo->Part2Port, 0x25, temp);
3953 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
3955 tempax = pVBInfo->HT;
3956 tempbx = pVBInfo->LCDHRS;
3957 if (XGI_IsLCDDualLink(pVBInfo)) {
3958 tempax = tempax >> 1;
3959 tempbx = tempbx >> 1;
3960 tempcx = tempcx >> 1;
3963 if (pVBInfo->VBType & VB_SIS302LV)
3968 if (tempcx >= tempax)
3971 temp = tempbx & 0x00FF; /* RHBURSTS=lcdhrs */
3972 xgifb_reg_set(pVBInfo->Part2Port, 0x1C, temp);
3974 temp = (tempbx & 0xFF00) >> 8;
3976 xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F0, temp);
3977 temp = tempcx & 0x00FF; /* RHSYEXP2S=lcdhre */
3978 xgifb_reg_set(pVBInfo->Part2Port, 0x21, temp);
3980 if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
3981 if (pVBInfo->VGAVDE == 525) {
3982 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B
3983 | VB_SIS301LV | VB_SIS302LV
3989 xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp);
3990 xgifb_reg_set(pVBInfo->Part2Port, 0x30, 0xB3);
3993 if (pVBInfo->VGAVDE == 420) {
3994 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B
3995 | VB_SIS301LV | VB_SIS302LV
4000 xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp);
4005 /* --------------------------------------------------------------------- */
4006 /* Function : XGI_GetTap4Ptr */
4008 /* Output : di -> Tap4 Reg. Setting Pointer */
4010 /* --------------------------------------------------------------------- */
4011 static struct XGI301C_Tap4TimingStruct const
4012 *XGI_GetTap4Ptr(unsigned short tempcx, struct vb_device_info *pVBInfo)
4014 unsigned short tempax, tempbx, i;
4015 struct XGI301C_Tap4TimingStruct const *Tap4TimingPtr;
4018 tempax = pVBInfo->VGAHDE;
4019 tempbx = pVBInfo->HDE;
4021 tempax = pVBInfo->VGAVDE;
4022 tempbx = pVBInfo->VDE;
4025 if (tempax <= tempbx)
4026 return &xgifb_tap4_timing[0];
4028 Tap4TimingPtr = xgifb_ntsc_525_tap4_timing; /* NTSC */
4030 if (pVBInfo->TVInfo & TVSetPAL)
4031 Tap4TimingPtr = PALTap4Timing;
4033 if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
4034 if ((pVBInfo->TVInfo & TVSetYPbPr525i) ||
4035 (pVBInfo->TVInfo & TVSetYPbPr525p))
4036 Tap4TimingPtr = xgifb_ntsc_525_tap4_timing;
4037 if (pVBInfo->TVInfo & TVSetYPbPr750p)
4038 Tap4TimingPtr = YPbPr750pTap4Timing;
4041 if (pVBInfo->VBInfo & SetCRT2ToHiVision)
4042 Tap4TimingPtr = xgifb_tap4_timing;
4045 while (Tap4TimingPtr[i].DE != 0xFFFF) {
4046 if (Tap4TimingPtr[i].DE == tempax)
4050 return &Tap4TimingPtr[i];
4053 static void XGI_SetTap4Regs(struct vb_device_info *pVBInfo)
4055 unsigned short i, j;
4056 struct XGI301C_Tap4TimingStruct const *Tap4TimingPtr;
4058 if (!(pVBInfo->VBType & VB_XGI301C))
4061 Tap4TimingPtr = XGI_GetTap4Ptr(0, pVBInfo); /* Set Horizontal Scaling */
4062 for (i = 0x80, j = 0; i <= 0xBF; i++, j++)
4063 xgifb_reg_set(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]);
4065 if ((pVBInfo->VBInfo & SetCRT2ToTV) &&
4066 (!(pVBInfo->VBInfo & SetCRT2ToHiVision))) {
4067 /* Set Vertical Scaling */
4068 Tap4TimingPtr = XGI_GetTap4Ptr(1, pVBInfo);
4069 for (i = 0xC0, j = 0; i < 0xFF; i++, j++)
4070 xgifb_reg_set(pVBInfo->Part2Port,
4072 Tap4TimingPtr->Reg[j]);
4075 if ((pVBInfo->VBInfo & SetCRT2ToTV) &&
4076 (!(pVBInfo->VBInfo & SetCRT2ToHiVision)))
4077 /* Enable V.Scaling */
4078 xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x04);
4080 /* Enable H.Scaling */
4081 xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x10);
4084 static void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex,
4085 struct vb_device_info *pVBInfo)
4088 unsigned char const *tempdi;
4089 unsigned short modeflag;
4091 /* si+Ext_ResInfo */
4092 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4094 xgifb_reg_set(pVBInfo->Part3Port, 0x00, 0x00);
4095 if (pVBInfo->TVInfo & TVSetPAL) {
4096 xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA);
4097 xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8);
4099 xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xF5);
4100 xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xB7);
4103 if (!(pVBInfo->VBInfo & SetCRT2ToTV))
4106 if (pVBInfo->TVInfo & TVSetPALM) {
4107 xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA);
4108 xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8);
4109 xgifb_reg_set(pVBInfo->Part3Port, 0x3D, 0xA8);
4112 if ((pVBInfo->VBInfo & SetCRT2ToHiVision) || (pVBInfo->VBInfo
4113 & SetCRT2ToYPbPr525750)) {
4114 if (pVBInfo->TVInfo & TVSetYPbPr525i)
4117 tempdi = XGI330_HiTVGroup3Data;
4118 if (pVBInfo->SetFlag & TVSimuMode) {
4119 tempdi = XGI330_HiTVGroup3Simu;
4120 if (!(modeflag & Charx8Dot))
4121 tempdi = XGI330_HiTVGroup3Text;
4124 if (pVBInfo->TVInfo & TVSetYPbPr525p)
4125 tempdi = XGI330_Ren525pGroup3;
4127 if (pVBInfo->TVInfo & TVSetYPbPr750p)
4128 tempdi = XGI330_Ren750pGroup3;
4130 for (i = 0; i <= 0x3E; i++)
4131 xgifb_reg_set(pVBInfo->Part3Port, i, tempdi[i]);
4133 if (pVBInfo->VBType & VB_XGI301C) { /* Marcovision */
4134 if (pVBInfo->TVInfo & TVSetYPbPr525p)
4135 xgifb_reg_set(pVBInfo->Part3Port, 0x28, 0x3f);
4139 } /* {end of XGI_SetGroup3} */
4141 static void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex,
4142 unsigned short RefreshRateTableIndex,
4143 struct xgi_hw_device_info *HwDeviceExtension,
4144 struct vb_device_info *pVBInfo)
4146 unsigned short tempax, tempcx, tempbx, modeflag, temp, temp2;
4148 unsigned long tempebx, tempeax, templong;
4150 /* si+Ext_ResInfo */
4151 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4152 temp = pVBInfo->RVBHCFACT;
4153 xgifb_reg_set(pVBInfo->Part4Port, 0x13, temp);
4155 tempbx = pVBInfo->RVBHCMAX;
4156 temp = tempbx & 0x00FF;
4157 xgifb_reg_set(pVBInfo->Part4Port, 0x14, temp);
4158 temp2 = ((tempbx & 0xFF00) >> 8) << 7;
4159 tempcx = pVBInfo->VGAHT - 1;
4160 temp = tempcx & 0x00FF;
4161 xgifb_reg_set(pVBInfo->Part4Port, 0x16, temp);
4163 temp = ((tempcx & 0xFF00) >> 8) << 3;
4166 tempcx = pVBInfo->VGAVT - 1;
4167 if (!(pVBInfo->VBInfo & SetCRT2ToTV))
4170 temp = tempcx & 0x00FF;
4171 xgifb_reg_set(pVBInfo->Part4Port, 0x17, temp);
4172 temp = temp2 | ((tempcx & 0xFF00) >> 8);
4173 xgifb_reg_set(pVBInfo->Part4Port, 0x15, temp);
4174 xgifb_reg_or(pVBInfo->Part4Port, 0x0D, 0x08);
4175 tempcx = pVBInfo->VBInfo;
4176 tempbx = pVBInfo->VGAHDE;
4178 if (modeflag & HalfDCLK)
4179 tempbx = tempbx >> 1;
4181 if (XGI_IsLCDDualLink(pVBInfo))
4182 tempbx = tempbx >> 1;
4184 if (tempcx & SetCRT2ToHiVision) {
4190 } else if (tempcx & SetCRT2ToTV) {
4196 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
4203 if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p)) {
4205 if (pVBInfo->VGAHDE == 1280)
4207 if (pVBInfo->VGAHDE == 1024)
4210 xgifb_reg_and_or(pVBInfo->Part4Port, 0x0E, ~0xEF, temp);
4212 tempebx = pVBInfo->VDE;
4214 if (tempcx & SetCRT2ToHiVision) {
4215 if (!(temp & 0xE000))
4216 tempbx = tempbx >> 1;
4219 tempcx = pVBInfo->RVBHRS;
4220 temp = tempcx & 0x00FF;
4221 xgifb_reg_set(pVBInfo->Part4Port, 0x18, temp);
4223 tempeax = pVBInfo->VGAVDE;
4226 if (tempeax <= tempebx) {
4227 tempcx = (tempcx & (~0x4000));
4228 tempeax = pVBInfo->VGAVDE;
4233 templong = (tempeax * 256 * 1024) % tempebx;
4234 tempeax = (tempeax * 256 * 1024) / tempebx;
4240 temp = (unsigned short) (tempebx & 0x000000FF);
4241 xgifb_reg_set(pVBInfo->Part4Port, 0x1B, temp);
4243 temp = (unsigned short) ((tempebx & 0x0000FF00) >> 8);
4244 xgifb_reg_set(pVBInfo->Part4Port, 0x1A, temp);
4245 tempbx = (unsigned short) (tempebx >> 16);
4246 temp = tempbx & 0x00FF;
4248 temp |= ((tempcx & 0xFF00) >> 8);
4249 xgifb_reg_set(pVBInfo->Part4Port, 0x19, temp);
4252 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
4253 | VB_SIS302LV | VB_XGI301C)) {
4255 xgifb_reg_set(pVBInfo->Part4Port, 0x1C, temp);
4256 tempax = pVBInfo->VGAHDE;
4257 if (modeflag & HalfDCLK)
4258 tempax = tempax >> 1;
4260 if (XGI_IsLCDDualLink(pVBInfo))
4261 tempax = tempax >> 1;
4263 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
4266 } else if (pVBInfo->VGAHDE > 800) {
4267 if (pVBInfo->VGAHDE == 1024)
4268 tempax = (tempax * 25 / 32) - 1;
4270 tempax = (tempax * 20 / 32) - 1;
4274 temp = (tempax & 0xFF00) >> 8;
4275 temp = ((temp & 0x0003) << 4);
4276 xgifb_reg_set(pVBInfo->Part4Port, 0x1E, temp);
4277 temp = (tempax & 0x00FF);
4278 xgifb_reg_set(pVBInfo->Part4Port, 0x1D, temp);
4280 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVision)) {
4281 if (pVBInfo->VGAHDE > 800)
4282 xgifb_reg_or(pVBInfo->Part4Port, 0x1E, 0x08);
4287 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4288 if (!(pVBInfo->TVInfo & (NTSC1024x768
4289 | TVSetYPbPr525p | TVSetYPbPr750p
4290 | TVSetHiVision))) {
4292 if ((pVBInfo->VBInfo & SetInSlaveMode)
4293 && (!(pVBInfo->TVInfo
4299 xgifb_reg_and_or(pVBInfo->Part4Port, 0x1F, 0x00C0, temp);
4300 tempbx = pVBInfo->HT;
4301 if (XGI_IsLCDDualLink(pVBInfo))
4302 tempbx = tempbx >> 1;
4303 tempbx = (tempbx >> 1) - 2;
4304 temp = ((tempbx & 0x0700) >> 8) << 3;
4305 xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, 0x00C0, temp);
4306 temp = tempbx & 0x00FF;
4307 xgifb_reg_set(pVBInfo->Part4Port, 0x22, temp);
4311 XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
4314 static void XGINew_EnableCRT2(struct vb_device_info *pVBInfo)
4316 xgifb_reg_and_or(pVBInfo->P3c4, 0x1E, 0xFF, 0x20);
4319 static void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex,
4320 struct vb_device_info *pVBInfo)
4322 if (pVBInfo->ModeType == ModeVGA) {
4323 if (!(pVBInfo->VBInfo & (SetInSlaveMode | LoadDACFlag
4324 | DisableCRT2Display))) {
4325 XGINew_EnableCRT2(pVBInfo);
4331 static void XGI_EnableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension,
4332 struct vb_device_info *pVBInfo)
4334 xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x40);
4337 static void XGI_DisableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension,
4338 struct vb_device_info *pVBInfo)
4341 xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x00);
4344 static unsigned char XGI_XG21CheckLVDSMode(struct xgifb_video_info *xgifb_info,
4345 unsigned short ModeNo, unsigned short ModeIdIndex,
4346 struct vb_device_info *pVBInfo)
4348 unsigned short xres, yres, colordepth, modeflag, resindex;
4350 resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO;
4351 xres = XGI330_ModeResInfo[resindex].HTotal; /* xres->ax */
4352 yres = XGI330_ModeResInfo[resindex].VTotal; /* yres->bx */
4353 /* si+St_ModeFlag */
4354 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4356 if (!(modeflag & Charx8Dot)) {
4361 if ((ModeNo > 0x13) && (modeflag & HalfDCLK))
4364 if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
4367 if (xres > xgifb_info->lvds_data.LVDSHDE)
4370 if (yres > xgifb_info->lvds_data.LVDSVDE)
4373 if (xres != xgifb_info->lvds_data.LVDSHDE ||
4374 yres != xgifb_info->lvds_data.LVDSVDE) {
4375 colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo);
4382 static void xgifb_set_lvds(struct xgifb_video_info *xgifb_info,
4384 unsigned short ModeNo,
4385 unsigned short ModeIdIndex,
4386 struct vb_device_info *pVBInfo)
4388 unsigned char temp, Miscdata;
4389 unsigned short xres, yres, modeflag, resindex;
4390 unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE;
4391 unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE;
4392 unsigned short value;
4394 temp = (unsigned char) ((xgifb_info->lvds_data.LVDS_Capability &
4395 (LCDPolarity << 8)) >> 8);
4396 temp &= LCDPolarity;
4397 Miscdata = inb(pVBInfo->P3cc);
4399 outb((Miscdata & 0x3F) | temp, pVBInfo->P3c2);
4401 temp = xgifb_info->lvds_data.LVDS_Capability & LCDPolarity;
4402 /* SR35[7] FP VSync polarity */
4403 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80);
4404 /* SR30[5] FP HSync polarity */
4405 xgifb_reg_and_or(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1);
4407 if (chip_id == XG27)
4408 XGI_SetXG27FPBits(pVBInfo);
4410 XGI_SetXG21FPBits(pVBInfo);
4412 resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO;
4413 xres = XGI330_ModeResInfo[resindex].HTotal; /* xres->ax */
4414 yres = XGI330_ModeResInfo[resindex].VTotal; /* yres->bx */
4415 /* si+St_ModeFlag */
4416 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4418 if (!(modeflag & Charx8Dot))
4419 xres = xres * 8 / 9;
4421 LVDSHT = xgifb_info->lvds_data.LVDSHT;
4423 LVDSHBS = xres + (xgifb_info->lvds_data.LVDSHDE - xres) / 2;
4425 if (LVDSHBS > LVDSHT)
4428 LVDSHRS = LVDSHBS + xgifb_info->lvds_data.LVDSHFP;
4429 if (LVDSHRS > LVDSHT)
4432 LVDSHRE = LVDSHRS + xgifb_info->lvds_data.LVDSHSYNC;
4433 if (LVDSHRE > LVDSHT)
4436 LVDSHBE = LVDSHBS + LVDSHT - xgifb_info->lvds_data.LVDSHDE;
4438 LVDSVT = xgifb_info->lvds_data.LVDSVT;
4440 LVDSVBS = yres + (xgifb_info->lvds_data.LVDSVDE - yres) / 2;
4441 if (modeflag & DoubleScanMode)
4442 LVDSVBS += yres / 2;
4444 if (LVDSVBS > LVDSVT)
4447 LVDSVRS = LVDSVBS + xgifb_info->lvds_data.LVDSVFP;
4448 if (LVDSVRS > LVDSVT)
4451 LVDSVRE = LVDSVRS + xgifb_info->lvds_data.LVDSVSYNC;
4452 if (LVDSVRE > LVDSVT)
4455 LVDSVBE = LVDSVBS + LVDSVT - xgifb_info->lvds_data.LVDSVDE;
4457 temp = xgifb_reg_get(pVBInfo->P3d4, 0x11);
4458 xgifb_reg_set(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */
4460 if (!(modeflag & Charx8Dot))
4461 xgifb_reg_or(pVBInfo->P3c4, 0x1, 0x1);
4463 /* HT SR0B[1:0] CR00 */
4464 value = (LVDSHT >> 3) - 5;
4465 xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8);
4466 xgifb_reg_set(pVBInfo->P3d4, 0x0, (value & 0xFF));
4468 /* HBS SR0B[5:4] CR02 */
4469 value = (LVDSHBS >> 3) - 1;
4470 xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4);
4471 xgifb_reg_set(pVBInfo->P3d4, 0x2, (value & 0xFF));
4473 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
4474 value = (LVDSHBE >> 3) - 1;
4475 xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6);
4476 xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2);
4477 xgifb_reg_and_or(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F);
4479 /* HRS SR0B[7:6] CR04 */
4480 value = (LVDSHRS >> 3) + 2;
4481 xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2);
4482 xgifb_reg_set(pVBInfo->P3d4, 0x4, (value & 0xFF));
4484 /* Panel HRS SR2F[1:0] SR2E[7:0] */
4486 xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8);
4487 xgifb_reg_set(pVBInfo->P3c4, 0x2E, (value & 0xFF));
4489 /* HRE SR0C[2] CR05[4:0] */
4490 value = (LVDSHRE >> 3) + 2;
4491 xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3);
4492 xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F);
4494 /* Panel HRE SR2F[7:2] */
4496 xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2);
4498 /* VT SR0A[0] CR07[5][0] CR06 */
4500 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10);
4501 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4);
4502 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8);
4503 xgifb_reg_set(pVBInfo->P3d4, 0x06, (value & 0xFF));
4505 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
4506 value = LVDSVBS - 1;
4507 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8);
4508 xgifb_reg_and_or(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4);
4509 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5);
4510 xgifb_reg_set(pVBInfo->P3d4, 0x15, (value & 0xFF));
4512 /* VBE SR0A[4] CR16 */
4513 value = LVDSVBE - 1;
4514 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4);
4515 xgifb_reg_set(pVBInfo->P3d4, 0x16, (value & 0xFF));
4517 /* VRS SR0A[3] CR7[7][2] CR10 */
4518 value = LVDSVRS - 1;
4519 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7);
4520 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2);
4521 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6);
4522 xgifb_reg_set(pVBInfo->P3d4, 0x10, (value & 0xFF));
4524 if (chip_id == XG27) {
4525 /* Panel VRS SR35[2:0] SR34[7:0] */
4526 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07,
4527 (value & 0x700) >> 8);
4528 xgifb_reg_set(pVBInfo->P3c4, 0x34, value & 0xFF);
4530 /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */
4531 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0x03,
4532 (value & 0x600) >> 9);
4533 xgifb_reg_set(pVBInfo->P3c4, 0x34, (value >> 1) & 0xFF);
4534 xgifb_reg_and_or(pVBInfo->P3d4, 0x33, ~0x01, value & 0x01);
4537 /* VRE SR0A[5] CR11[3:0] */
4538 value = LVDSVRE - 1;
4539 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1);
4540 xgifb_reg_and_or(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F);
4542 /* Panel VRE SR3F[7:2] */
4543 if (chip_id == XG27)
4544 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC,
4545 (value << 2) & 0xFC);
4547 /* SR3F[7] has to be 0, h/w bug */
4548 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC,
4549 (value << 2) & 0x7C);
4551 for (temp = 0, value = 0; temp < 3; temp++) {
4553 xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, value);
4554 xgifb_reg_set(pVBInfo->P3c4,
4555 0x2B, xgifb_info->lvds_data.VCLKData1);
4556 xgifb_reg_set(pVBInfo->P3c4,
4557 0x2C, xgifb_info->lvds_data.VCLKData2);
4561 if (!(modeflag & Charx8Dot)) {
4562 inb(pVBInfo->P3da); /* reset 3da */
4563 outb(0x13, pVBInfo->P3c0); /* set index */
4564 /* set data, panning = 0, shift left 1 dot*/
4565 outb(0x00, pVBInfo->P3c0);
4567 inb(pVBInfo->P3da); /* Enable Attribute */
4568 outb(0x20, pVBInfo->P3c0);
4570 inb(pVBInfo->P3da); /* reset 3da */
4575 /* --------------------------------------------------------------------- */
4576 /* Function : XGI_IsLCDON */
4578 /* Output : 0 : Skip PSC Control */
4579 /* 1: Disable PSC */
4581 /* --------------------------------------------------------------------- */
4582 static unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo)
4584 unsigned short tempax;
4586 tempax = pVBInfo->VBInfo;
4587 if (tempax & SetCRT2ToDualEdge)
4589 else if (tempax & (DisableCRT2Display | SwitchCRT2 | SetSimuScanMode))
4595 /* --------------------------------------------------------------------- */
4596 /* Function : XGI_EnableChISLCD */
4598 /* Output : 0 -> Not LCD mode */
4599 /* Description : if bool enable = true -> enable, else disable */
4600 /* --------------------------------------------------------------------- */
4601 static unsigned char XGI_EnableChISLCD(struct vb_device_info *pVBInfo,
4604 unsigned short tempbx, tempah;
4607 tempbx = pVBInfo->SetFlag & (EnableChA | EnableChB);
4609 tempbx = pVBInfo->SetFlag & (DisableChA | DisableChB);
4611 tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E));
4613 if (tempbx & (EnableChA | DisableChA)) {
4614 if (!(tempah & 0x08)) /* Chk LCDA Mode */
4618 if (!(tempbx & (EnableChB | DisableChB)))
4621 if (tempah & 0x01) /* Chk LCDB Mode */
4627 static void XGI_DisableBridge(struct xgifb_video_info *xgifb_info,
4628 struct xgi_hw_device_info *HwDeviceExtension,
4629 struct vb_device_info *pVBInfo)
4631 unsigned short tempah = 0;
4633 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
4634 | VB_SIS302LV | VB_XGI301C)) {
4636 if (!(pVBInfo->VBInfo &
4637 (DisableCRT2Display | SetSimuScanMode))) {
4638 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
4639 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
4640 tempah = 0x7F; /* Disable Channel A */
4641 if (!(pVBInfo->VBInfo &
4643 /* Disable Channel B */
4646 if (pVBInfo->SetFlag & DisableChB)
4647 /* force to disable Cahnnel */
4650 if (pVBInfo->SetFlag & DisableChA)
4651 /* Force to disable Channel B */
4657 /* disable part4_1f */
4658 xgifb_reg_and(pVBInfo->Part4Port, 0x1F, tempah);
4660 if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) {
4661 if (((pVBInfo->VBInfo &
4662 (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) ||
4663 (XGI_EnableChISLCD(pVBInfo, false)) ||
4664 (XGI_IsLCDON(pVBInfo)))
4665 /* LVDS Driver power down */
4666 xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x80);
4669 if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo
4670 & (DisableCRT2Display | XGI_SetCRT2ToLCDA
4671 | SetSimuScanMode))) {
4672 if (pVBInfo->SetFlag & GatingCRT)
4673 XGI_EnableGatingCRT(HwDeviceExtension, pVBInfo);
4674 XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo);
4677 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
4678 if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo
4679 & XGI_SetCRT2ToLCDA))
4681 xgifb_reg_and(pVBInfo->Part1Port, 0x1e, 0xdf);
4684 /* disable TV as primary VGA swap */
4685 xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xdf);
4687 if ((pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToDualEdge)))
4688 xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xdf);
4690 if ((pVBInfo->SetFlag & DisableChB) ||
4692 (DisableCRT2Display | SetSimuScanMode)) ||
4693 ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) &&
4695 (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV))))
4696 xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80);
4698 if ((pVBInfo->SetFlag & DisableChB) ||
4700 (DisableCRT2Display | SetSimuScanMode)) ||
4701 (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) ||
4703 (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV))) {
4704 /* save Part1 index 0 */
4705 tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00);
4706 /* BTDAC = 1, avoid VB reset */
4707 xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x10);
4709 xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF);
4710 /* restore Part1 index 0 */
4711 xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah);
4713 } else { /* {301} */
4714 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) {
4715 xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80);
4717 xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF);
4718 /* Disable TV asPrimary VGA swap */
4719 xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xDF);
4722 if (pVBInfo->VBInfo & (DisableCRT2Display | XGI_SetCRT2ToLCDA
4724 XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo);
4728 /* --------------------------------------------------------------------- */
4729 /* Function : XGI_GetTVPtrIndex */
4732 /* Description : bx 0 : ExtNTSC */
4744 /* --------------------------------------------------------------------- */
4745 static unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo)
4747 unsigned short tempbx = 0;
4749 if (pVBInfo->TVInfo & TVSetPAL)
4751 if (pVBInfo->TVInfo & TVSetHiVision)
4753 if (pVBInfo->TVInfo & TVSetYPbPr525i)
4755 if (pVBInfo->TVInfo & TVSetYPbPr525p)
4757 if (pVBInfo->TVInfo & TVSetYPbPr750p)
4759 if (pVBInfo->TVInfo & TVSimuMode)
4765 /* --------------------------------------------------------------------- */
4766 /* Function : XGI_GetTVPtrIndex2 */
4768 /* Output : bx 0 : NTSC */
4772 /* 4 : NTSC1024x768 */
4773 /* 5 : PAL-M 1024x768 */
4775 /* cl 0 : YFilter1 */
4778 /* 1 : 301B/302B/301LV/302LV */
4780 /* --------------------------------------------------------------------- */
4781 static void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char *tempcl,
4782 unsigned char *tempch, struct vb_device_info *pVBInfo)
4788 if (pVBInfo->TVInfo & TVSetPAL)
4791 if (pVBInfo->TVInfo & TVSetPALM)
4794 if (pVBInfo->TVInfo & TVSetPALN)
4797 if (pVBInfo->TVInfo & NTSC1024x768) {
4799 if (pVBInfo->TVInfo & TVSetPALM)
4803 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
4804 | VB_SIS302LV | VB_XGI301C)) {
4805 if ((!(pVBInfo->VBInfo & SetInSlaveMode)) || (pVBInfo->TVInfo
4812 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
4813 | VB_SIS302LV | VB_XGI301C))
4817 static void XGI_SetDelayComp(struct vb_device_info *pVBInfo)
4819 unsigned char tempah, tempbl, tempbh;
4821 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
4822 | VB_SIS302LV | VB_XGI301C)) {
4823 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA
4824 | SetCRT2ToTV | SetCRT2ToRAMDAC)) {
4826 tempbl = XGI301TVDelay;
4828 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
4829 tempbl = tempbl >> 4;
4830 if (pVBInfo->VBInfo &
4831 (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
4832 tempbh = XGI301LCDDelay;
4834 if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA))
4840 tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x2D);
4842 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD
4843 | SetCRT2ToTV)) { /* Channel B */
4848 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
4853 xgifb_reg_set(pVBInfo->Part1Port, 0x2D, tempah);
4858 static void XGI_SetLCDCap_A(unsigned short tempcx,
4859 struct vb_device_info *pVBInfo)
4861 unsigned short temp;
4863 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
4865 if (temp & LCDRGB18Bit) {
4866 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F,
4868 (unsigned short) (0x20 | (tempcx & 0x00C0)));
4869 xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80);
4871 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F,
4872 (unsigned short) (0x30 | (tempcx & 0x00C0)));
4873 xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00);
4877 /* --------------------------------------------------------------------- */
4878 /* Function : XGI_SetLCDCap_B */
4879 /* Input : cx -> LCD Capability */
4882 /* --------------------------------------------------------------------- */
4883 static void XGI_SetLCDCap_B(unsigned short tempcx,
4884 struct vb_device_info *pVBInfo)
4886 if (tempcx & EnableLCD24bpp) /* 24bits */
4887 xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0,
4888 (unsigned short) (((tempcx & 0x00ff) >> 6)
4891 xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0,
4892 (unsigned short) (((tempcx & 0x00ff) >> 6)
4893 | 0x18)); /* Enable Dither */
4896 static void XGI_LongWait(struct vb_device_info *pVBInfo)
4900 i = xgifb_reg_get(pVBInfo->P3c4, 0x1F);
4903 for (i = 0; i < 0xFFFF; i++) {
4904 if (!(inb(pVBInfo->P3da) & 0x08))
4908 for (i = 0; i < 0xFFFF; i++) {
4909 if ((inb(pVBInfo->P3da) & 0x08))
4915 static void SetSpectrum(struct vb_device_info *pVBInfo)
4917 unsigned short index;
4919 index = XGI_GetLCDCapPtr(pVBInfo);
4921 /* disable down spectrum D[4] */
4922 xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x8F);
4923 XGI_LongWait(pVBInfo);
4924 xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x20); /* reset spectrum */
4925 XGI_LongWait(pVBInfo);
4927 xgifb_reg_set(pVBInfo->Part4Port, 0x31,
4928 pVBInfo->LCDCapList[index].Spectrum_31);
4929 xgifb_reg_set(pVBInfo->Part4Port, 0x32,
4930 pVBInfo->LCDCapList[index].Spectrum_32);
4931 xgifb_reg_set(pVBInfo->Part4Port, 0x33,
4932 pVBInfo->LCDCapList[index].Spectrum_33);
4933 xgifb_reg_set(pVBInfo->Part4Port, 0x34,
4934 pVBInfo->LCDCapList[index].Spectrum_34);
4935 XGI_LongWait(pVBInfo);
4936 xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x40); /* enable spectrum */
4939 static void XGI_SetLCDCap(struct vb_device_info *pVBInfo)
4941 unsigned short tempcx;
4943 tempcx = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(pVBInfo)].LCD_Capability;
4945 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
4946 VB_SIS302LV | VB_XGI301C)) {
4947 if (pVBInfo->VBType &
4948 (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) {
4949 /* Set 301LV Capability */
4950 xgifb_reg_set(pVBInfo->Part4Port, 0x24,
4951 (unsigned char) (tempcx & 0x1F));
4954 xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D,
4955 ~((EnableVBCLKDRVLOW | EnablePLLSPLOW) >> 8),
4956 (unsigned short) ((tempcx & (EnableVBCLKDRVLOW
4957 | EnablePLLSPLOW)) >> 8));
4959 if (pVBInfo->VBInfo & SetCRT2ToLCD)
4960 XGI_SetLCDCap_B(tempcx, pVBInfo);
4961 else if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)
4962 XGI_SetLCDCap_A(tempcx, pVBInfo);
4964 if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) {
4965 if (tempcx & EnableSpectrum)
4966 SetSpectrum(pVBInfo);
4970 XGI_SetLCDCap_A(tempcx, pVBInfo);
4974 /* --------------------------------------------------------------------- */
4975 /* Function : XGI_SetAntiFlicker */
4978 /* Description : Set TV Customized Param. */
4979 /* --------------------------------------------------------------------- */
4980 static void XGI_SetAntiFlicker(unsigned short ModeNo,
4981 unsigned short ModeIdIndex,
4982 struct vb_device_info *pVBInfo)
4984 unsigned short tempbx;
4986 unsigned char tempah;
4988 if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p))
4991 tempbx = XGI_GetTVPtrIndex(pVBInfo);
4993 tempah = TVAntiFlickList[tempbx];
4994 tempah = tempah << 4;
4996 xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0x8F, tempah);
4999 static void XGI_SetEdgeEnhance(unsigned short ModeNo,
5000 unsigned short ModeIdIndex,
5001 struct vb_device_info *pVBInfo)
5003 unsigned short tempbx;
5005 unsigned char tempah;
5007 tempbx = XGI_GetTVPtrIndex(pVBInfo);
5009 tempah = TVEdgeList[tempbx];
5010 tempah = tempah << 5;
5012 xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, tempah);
5015 static void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo)
5017 unsigned short tempbx;
5019 unsigned char tempcl, tempch;
5021 unsigned long tempData;
5023 XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */
5024 tempData = TVPhaseList[tempbx];
5026 xgifb_reg_set(pVBInfo->Part2Port, 0x31, (unsigned short) (tempData
5028 xgifb_reg_set(pVBInfo->Part2Port, 0x32, (unsigned short) ((tempData
5029 & 0x0000FF00) >> 8));
5030 xgifb_reg_set(pVBInfo->Part2Port, 0x33, (unsigned short) ((tempData
5031 & 0x00FF0000) >> 16));
5032 xgifb_reg_set(pVBInfo->Part2Port, 0x34, (unsigned short) ((tempData
5033 & 0xFF000000) >> 24));
5036 static void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex,
5037 struct vb_device_info *pVBInfo)
5039 unsigned short tempbx, index;
5040 unsigned char const *filterPtr;
5041 unsigned char tempcl, tempch, tempal;
5043 XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */
5048 filterPtr = NTSCYFilter1;
5052 filterPtr = PALYFilter1;
5059 filterPtr = xgifb_palmn_yfilter1;
5067 filterPtr = xgifb_yfilter2;
5074 tempal = XGI330_EModeIDTable[ModeIdIndex].VB_ExtTVYFilterIndex;
5080 if ((tempcl == 0) && (tempch == 1)) {
5081 xgifb_reg_set(pVBInfo->Part2Port, 0x35, 0);
5082 xgifb_reg_set(pVBInfo->Part2Port, 0x36, 0);
5083 xgifb_reg_set(pVBInfo->Part2Port, 0x37, 0);
5084 xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]);
5086 xgifb_reg_set(pVBInfo->Part2Port, 0x35, filterPtr[index++]);
5087 xgifb_reg_set(pVBInfo->Part2Port, 0x36, filterPtr[index++]);
5088 xgifb_reg_set(pVBInfo->Part2Port, 0x37, filterPtr[index++]);
5089 xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]);
5092 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
5093 | VB_SIS302LV | VB_XGI301C)) {
5094 xgifb_reg_set(pVBInfo->Part2Port, 0x48, filterPtr[index++]);
5095 xgifb_reg_set(pVBInfo->Part2Port, 0x49, filterPtr[index++]);
5096 xgifb_reg_set(pVBInfo->Part2Port, 0x4A, filterPtr[index++]);
5100 /* --------------------------------------------------------------------- */
5101 /* Function : XGI_OEM310Setting */
5104 /* Description : Customized Param. for 301 */
5105 /* --------------------------------------------------------------------- */
5106 static void XGI_OEM310Setting(unsigned short ModeNo,
5107 unsigned short ModeIdIndex,
5108 struct vb_device_info *pVBInfo)
5110 XGI_SetDelayComp(pVBInfo);
5112 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))
5113 XGI_SetLCDCap(pVBInfo);
5115 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5116 XGI_SetPhaseIncr(pVBInfo);
5117 XGI_SetYFilter(ModeNo, ModeIdIndex, pVBInfo);
5118 XGI_SetAntiFlicker(ModeNo, ModeIdIndex, pVBInfo);
5120 if (pVBInfo->VBType & VB_SIS301)
5121 XGI_SetEdgeEnhance(ModeNo, ModeIdIndex, pVBInfo);
5125 /* --------------------------------------------------------------------- */
5126 /* Function : XGI_SetCRT2ModeRegs */
5129 /* Description : Origin code for crt2group */
5130 /* --------------------------------------------------------------------- */
5131 static void XGI_SetCRT2ModeRegs(unsigned short ModeNo,
5132 struct xgi_hw_device_info *HwDeviceExtension,
5133 struct vb_device_info *pVBInfo)
5135 unsigned short tempbl;
5138 unsigned char tempah;
5141 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
5142 tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00);
5143 tempah &= ~0x10; /* BTRAMDAC */
5144 tempah |= 0x40; /* BTRAM */
5146 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV
5148 tempah = 0x40; /* BTDRAM */
5149 tempcl = pVBInfo->ModeType;
5153 tempah = (0x008 >> tempcl);
5158 if (pVBInfo->VBInfo & SetInSlaveMode)
5159 tempah ^= 0x50; /* BTDAC */
5163 xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah);
5167 if (pVBInfo->VBInfo & DisableCRT2Display)
5173 if (!(pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV |
5174 SetCRT2ToLCD | XGI_SetCRT2ToLCDA)))
5177 if ((pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) &&
5178 (!(pVBInfo->VBInfo & SetSimuScanMode))) {
5184 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
5189 if (!(pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD)))
5195 if (!(pVBInfo->VBInfo & SetInSlaveMode))
5198 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) {
5199 tempah = tempah ^ 0x05;
5200 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
5201 tempah = tempah ^ 0x01;
5204 if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge))
5208 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl, tempah);
5210 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD
5211 | XGI_SetCRT2ToLCDA)) {
5213 if ((pVBInfo->ModeType == ModeVGA) && (!(pVBInfo->VBInfo
5214 & SetInSlaveMode))) {
5219 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5221 if (pVBInfo->VBInfo & DriverMode)
5222 tempah = tempah ^ 0x20;
5225 xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D, ~0x0BF, tempah);
5228 if (pVBInfo->LCDInfo & SetLCDDualLink)
5231 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5232 if (pVBInfo->TVInfo & RPLLDIV2XO)
5236 if ((pVBInfo->LCDResInfo == Panel_1280x1024)
5237 || (pVBInfo->LCDResInfo == Panel_1280x1024x75))
5240 if (pVBInfo->LCDResInfo == Panel_1280x960)
5243 xgifb_reg_set(pVBInfo->Part4Port, 0x0C, tempah);
5246 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
5247 | VB_SIS302LV | VB_XGI301C)) {
5251 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
5253 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)
5254 tempah |= 0x04; /* shampoo 0129 */
5257 xgifb_reg_and_or(pVBInfo->Part1Port, 0x13, tempbl, tempah);
5260 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
5261 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
5265 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2c, tempbl, tempah);
5269 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
5270 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
5273 xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, tempbl, tempah);
5278 if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) {
5280 if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge))
5284 xgifb_reg_and_or(pVBInfo->Part4Port, 0x23, tempbl, tempah);
5286 if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) {
5287 if (pVBInfo->LCDInfo & SetLCDDualLink) {
5288 xgifb_reg_or(pVBInfo->Part4Port, 0x27, 0x20);
5289 xgifb_reg_or(pVBInfo->Part4Port, 0x34, 0x10);
5295 void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension,
5296 struct vb_device_info *pVBInfo)
5299 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2f, 0xFF, 0x01);
5303 void XGI_LockCRT2(struct xgi_hw_device_info *HwDeviceExtension,
5304 struct vb_device_info *pVBInfo)
5307 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2F, 0xFE, 0x00);
5311 unsigned char XGI_BridgeIsOn(struct vb_device_info *pVBInfo)
5313 unsigned short flag;
5315 if (pVBInfo->IF_DEF_LVDS == 1) {
5318 flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00);
5319 if ((flag == 1) || (flag == 2))
5320 return 1; /* 301b */
5326 unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE,
5327 unsigned short ModeNo, unsigned short ModeIdIndex,
5328 struct vb_device_info *pVBInfo)
5330 const u8 LCDARefreshIndex[] = {
5331 0x00, 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x00 };
5333 unsigned short RefreshRateTableIndex, i, index, temp;
5335 index = xgifb_reg_get(pVBInfo->P3d4, 0x33);
5336 index = index >> pVBInfo->SelectCRT2Rate;
5339 if (pVBInfo->LCDInfo & LCDNonExpanding)
5345 if (pVBInfo->SetFlag & ProgrammingCRT2) {
5346 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
5347 if (pVBInfo->IF_DEF_LVDS == 0) {
5348 temp = LCDARefreshIndex[
5349 pVBInfo->LCDResInfo & 0x07];
5359 RefreshRateTableIndex = XGI330_EModeIDTable[ModeIdIndex].REFindex;
5360 ModeNo = XGI330_RefIndex[RefreshRateTableIndex].ModeID;
5361 if (pXGIHWDE->jChipType >= XG20) { /* for XG20, XG21, XG27 */
5362 if ((XGI330_RefIndex[RefreshRateTableIndex].XRes == 800) &&
5363 (XGI330_RefIndex[RefreshRateTableIndex].YRes == 600)) {
5366 /* do the similar adjustment like XGISearchCRT1Rate() */
5367 if ((XGI330_RefIndex[RefreshRateTableIndex].XRes == 1024) &&
5368 (XGI330_RefIndex[RefreshRateTableIndex].YRes == 768)) {
5371 if ((XGI330_RefIndex[RefreshRateTableIndex].XRes == 1280) &&
5372 (XGI330_RefIndex[RefreshRateTableIndex].YRes == 1024)) {
5379 if (XGI330_RefIndex[RefreshRateTableIndex + i].
5382 temp = XGI330_RefIndex[RefreshRateTableIndex + i].Ext_InfoFlag;
5383 temp &= ModeTypeMask;
5384 if (temp < pVBInfo->ModeType)
5389 } while (index != 0xFFFF);
5390 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) {
5391 if (pVBInfo->VBInfo & SetInSlaveMode) {
5392 temp = XGI330_RefIndex[RefreshRateTableIndex + i - 1].
5394 if (temp & InterlaceMode)
5399 if ((pVBInfo->SetFlag & ProgrammingCRT2)) {
5400 temp = XGI_AjustCRT2Rate(ModeNo, ModeIdIndex,
5401 RefreshRateTableIndex, &i, pVBInfo);
5403 return RefreshRateTableIndex + i;
5406 static void XGI_SetLCDAGroup(unsigned short ModeNo, unsigned short ModeIdIndex,
5407 struct xgi_hw_device_info *HwDeviceExtension,
5408 struct vb_device_info *pVBInfo)
5410 unsigned short RefreshRateTableIndex;
5412 pVBInfo->SetFlag |= ProgrammingCRT2;
5413 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
5414 ModeIdIndex, pVBInfo);
5415 XGI_GetLVDSResInfo(ModeNo, ModeIdIndex, pVBInfo);
5416 XGI_GetLVDSData(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
5417 XGI_ModCRT1Regs(ModeNo, ModeIdIndex, RefreshRateTableIndex,
5418 HwDeviceExtension, pVBInfo);
5419 XGI_SetLVDSRegs(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
5420 XGI_SetCRT2ECLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
5423 static unsigned char XGI_SetCRT2Group301(unsigned short ModeNo,
5424 struct xgi_hw_device_info *HwDeviceExtension,
5425 struct vb_device_info *pVBInfo)
5427 unsigned short ModeIdIndex, RefreshRateTableIndex;
5429 pVBInfo->SetFlag |= ProgrammingCRT2;
5430 XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo);
5431 pVBInfo->SelectCRT2Rate = 4;
5432 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
5433 ModeIdIndex, pVBInfo);
5434 XGI_SaveCRT2Info(ModeNo, pVBInfo);
5435 XGI_GetCRT2ResInfo(ModeNo, ModeIdIndex, pVBInfo);
5436 XGI_GetCRT2Data(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
5437 XGI_PreSetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension,
5438 RefreshRateTableIndex, pVBInfo);
5439 XGI_SetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension,
5440 RefreshRateTableIndex, pVBInfo);
5441 XGI_SetLockRegs(ModeNo, ModeIdIndex, HwDeviceExtension,
5442 RefreshRateTableIndex, pVBInfo);
5443 XGI_SetGroup2(ModeNo, ModeIdIndex, RefreshRateTableIndex,
5444 HwDeviceExtension, pVBInfo);
5445 XGI_SetLCDRegs(ModeNo, ModeIdIndex, HwDeviceExtension,
5446 RefreshRateTableIndex, pVBInfo);
5447 XGI_SetTap4Regs(pVBInfo);
5448 XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo);
5449 XGI_SetGroup4(ModeNo, ModeIdIndex, RefreshRateTableIndex,
5450 HwDeviceExtension, pVBInfo);
5451 XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
5452 XGI_SetGroup5(ModeNo, ModeIdIndex, pVBInfo);
5453 XGI_AutoThreshold(pVBInfo);
5457 void XGI_SenseCRT1(struct vb_device_info *pVBInfo)
5459 unsigned char CRTCData[17] = { 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81,
5460 0x0B, 0x3E, 0xE9, 0x0B, 0xDF, 0xE7, 0x04, 0x00, 0x00,
5463 unsigned char SR01 = 0, SR1F = 0, SR07 = 0, SR06 = 0;
5465 unsigned char CR17, CR63, SR31;
5466 unsigned short temp;
5469 xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86);
5471 /* to fix XG42 single LCD sense to CRT+LCD */
5472 xgifb_reg_set(pVBInfo->P3d4, 0x57, 0x4A);
5473 xgifb_reg_set(pVBInfo->P3d4, 0x53, (xgifb_reg_get(
5474 pVBInfo->P3d4, 0x53) | 0x02));
5476 SR31 = xgifb_reg_get(pVBInfo->P3c4, 0x31);
5477 CR63 = xgifb_reg_get(pVBInfo->P3d4, 0x63);
5478 SR01 = xgifb_reg_get(pVBInfo->P3c4, 0x01);
5480 xgifb_reg_set(pVBInfo->P3c4, 0x01, (unsigned char) (SR01 & 0xDF));
5481 xgifb_reg_set(pVBInfo->P3d4, 0x63, (unsigned char) (CR63 & 0xBF));
5483 CR17 = xgifb_reg_get(pVBInfo->P3d4, 0x17);
5484 xgifb_reg_set(pVBInfo->P3d4, 0x17, (unsigned char) (CR17 | 0x80));
5486 SR1F = xgifb_reg_get(pVBInfo->P3c4, 0x1F);
5487 xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) (SR1F | 0x04));
5489 SR07 = xgifb_reg_get(pVBInfo->P3c4, 0x07);
5490 xgifb_reg_set(pVBInfo->P3c4, 0x07, (unsigned char) (SR07 & 0xFB));
5491 SR06 = xgifb_reg_get(pVBInfo->P3c4, 0x06);
5492 xgifb_reg_set(pVBInfo->P3c4, 0x06, (unsigned char) (SR06 & 0xC3));
5494 xgifb_reg_set(pVBInfo->P3d4, 0x11, 0x00);
5496 for (i = 0; i < 8; i++)
5497 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) i, CRTCData[i]);
5499 for (i = 8; i < 11; i++)
5500 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 8),
5503 for (i = 11; i < 13; i++)
5504 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 4),
5507 for (i = 13; i < 16; i++)
5508 xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i - 3),
5511 xgifb_reg_set(pVBInfo->P3c4, 0x0E, (unsigned char) (CRTCData[16]
5514 xgifb_reg_set(pVBInfo->P3c4, 0x31, 0x00);
5515 xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x1B);
5516 xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE1);
5518 outb(0x00, pVBInfo->P3c8);
5520 for (i = 0; i < 256 * 3; i++) {
5521 outb(0x0F, (pVBInfo->P3c8 + 1)); /* DAC_TEST_PARMS */
5526 XGI_WaitDisply(pVBInfo);
5527 temp = inb(pVBInfo->P3c2);
5530 xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x20);
5532 xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x00);
5534 /* avoid display something, set BLACK DAC if not restore DAC */
5535 outb(0x00, pVBInfo->P3c8);
5537 for (i = 0; i < 256 * 3; i++) {
5538 outb(0, (pVBInfo->P3c8 + 1));
5541 xgifb_reg_set(pVBInfo->P3c4, 0x01, SR01);
5542 xgifb_reg_set(pVBInfo->P3d4, 0x63, CR63);
5543 xgifb_reg_set(pVBInfo->P3c4, 0x31, SR31);
5545 xgifb_reg_set(pVBInfo->P3d4, 0x53, (xgifb_reg_get(
5546 pVBInfo->P3d4, 0x53) & 0xFD));
5547 xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) SR1F);
5550 static void XGI_EnableBridge(struct xgifb_video_info *xgifb_info,
5551 struct xgi_hw_device_info *HwDeviceExtension,
5552 struct vb_device_info *pVBInfo)
5554 unsigned short tempah;
5556 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
5557 | VB_SIS302LV | VB_XGI301C)) {
5558 if (!(pVBInfo->SetFlag & DisableChA)) {
5559 if ((pVBInfo->SetFlag & EnableChA) ||
5560 (pVBInfo->VBInfo & SetCRT2ToDualEdge)) {
5562 xgifb_reg_set(pVBInfo->Part1Port, 0x1E, 0x20);
5566 if (!(pVBInfo->SetFlag & DisableChB)) {
5567 if ((pVBInfo->SetFlag & EnableChB) || (pVBInfo->VBInfo
5568 & (SetCRT2ToLCD | SetCRT2ToTV
5569 | SetCRT2ToRAMDAC))) {
5570 tempah = xgifb_reg_get(pVBInfo->P3c4, 0x32);
5572 if (pVBInfo->VBInfo & SetInSlaveMode) {
5573 if (!(pVBInfo->VBInfo &
5577 xgifb_reg_set(pVBInfo->P3c4, 0x32, tempah);
5578 xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x20);
5580 tempah = xgifb_reg_get(pVBInfo->Part1Port,
5583 if (!(tempah & 0x80))
5584 xgifb_reg_or(pVBInfo->Part1Port,
5586 xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F);
5590 if ((pVBInfo->SetFlag & (EnableChA | EnableChB))
5591 || (!(pVBInfo->VBInfo & DisableCRT2Display))) {
5592 xgifb_reg_and_or(pVBInfo->Part2Port, 0x00, ~0xE0,
5593 0x20); /* shampoo 0129 */
5594 if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) {
5595 if (!XGI_EnableChISLCD(pVBInfo, false)) {
5596 if (XGI_EnableChISLCD(pVBInfo, true) ||
5598 (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)))
5599 /* LVDS PLL power on */
5605 /* LVDS Driver power on */
5606 xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x7F);
5612 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
5615 if (!(pVBInfo->VBInfo & SetSimuScanMode) &&
5616 (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) &&
5617 (pVBInfo->VBInfo & SetCRT2ToDualEdge)) {
5618 tempah = tempah & 0x40;
5619 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)
5620 tempah = tempah ^ 0xC0;
5622 if (pVBInfo->SetFlag & DisableChB)
5625 if (pVBInfo->SetFlag & DisableChA)
5628 if (pVBInfo->SetFlag & EnableChB)
5631 if (pVBInfo->SetFlag & EnableChA)
5636 /* EnablePart4_1F */
5637 xgifb_reg_or(pVBInfo->Part4Port, 0x1F, tempah);
5639 if (!(pVBInfo->SetFlag & DisableChA)) {
5640 if (!(pVBInfo->SetFlag & GatingCRT)) {
5641 XGI_DisableGatingCRT(HwDeviceExtension,
5643 XGI_DisplayOn(xgifb_info, HwDeviceExtension,
5649 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD
5650 | XGI_SetCRT2ToLCDA))
5652 xgifb_reg_or(pVBInfo->Part1Port, 0x1E, 0x20);
5654 tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x2E);
5655 if (!(tempah & 0x80))
5656 xgifb_reg_or(pVBInfo->Part1Port, 0x2E, 0x80);
5658 xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F);
5659 XGI_DisplayOn(xgifb_info, HwDeviceExtension, pVBInfo);
5663 static void XGI_SetCRT1Group(struct xgifb_video_info *xgifb_info,
5664 struct xgi_hw_device_info *HwDeviceExtension,
5665 unsigned short ModeNo, unsigned short ModeIdIndex,
5666 struct vb_device_info *pVBInfo)
5668 unsigned short RefreshRateTableIndex, temp;
5670 XGI_SetSeqRegs(ModeNo, ModeIdIndex, pVBInfo);
5671 outb(XGI330_StandTable.MISC, pVBInfo->P3c2);
5672 XGI_SetCRTCRegs(HwDeviceExtension, pVBInfo);
5673 XGI_SetATTRegs(ModeNo, ModeIdIndex, pVBInfo);
5674 XGI_SetGRCRegs(pVBInfo);
5675 XGI_ClearExt1Regs(pVBInfo);
5677 if (HwDeviceExtension->jChipType == XG27) {
5678 if (pVBInfo->IF_DEF_LVDS == 0)
5679 XGI_SetDefaultVCLK(pVBInfo);
5682 temp = ~ProgrammingCRT2;
5683 pVBInfo->SetFlag &= temp;
5684 pVBInfo->SelectCRT2Rate = 0;
5686 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
5687 | VB_SIS302LV | VB_XGI301C)) {
5688 if (pVBInfo->VBInfo & (SetSimuScanMode | XGI_SetCRT2ToLCDA
5689 | SetInSlaveMode)) {
5690 pVBInfo->SetFlag |= ProgrammingCRT2;
5694 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
5695 ModeIdIndex, pVBInfo);
5696 if (RefreshRateTableIndex != 0xFFFF) {
5697 XGI_SetSync(RefreshRateTableIndex, pVBInfo);
5698 XGI_SetCRT1CRTC(ModeNo, ModeIdIndex, RefreshRateTableIndex,
5699 pVBInfo, HwDeviceExtension);
5700 XGI_SetCRT1DE(HwDeviceExtension, ModeNo, ModeIdIndex,
5701 RefreshRateTableIndex, pVBInfo);
5702 XGI_SetCRT1Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
5703 HwDeviceExtension, pVBInfo);
5704 XGI_SetCRT1VCLK(ModeNo, ModeIdIndex, HwDeviceExtension,
5705 RefreshRateTableIndex, pVBInfo);
5708 if (HwDeviceExtension->jChipType >= XG21) {
5709 temp = xgifb_reg_get(pVBInfo->P3d4, 0x38);
5712 if (HwDeviceExtension->jChipType == XG27)
5713 XGI_SetXG27CRTC(ModeNo, ModeIdIndex,
5714 RefreshRateTableIndex, pVBInfo);
5716 XGI_SetXG21CRTC(ModeNo, ModeIdIndex,
5717 RefreshRateTableIndex, pVBInfo);
5719 XGI_UpdateXG21CRTC(ModeNo, pVBInfo,
5720 RefreshRateTableIndex);
5722 xgifb_set_lcd(HwDeviceExtension->jChipType,
5723 pVBInfo, RefreshRateTableIndex, ModeNo);
5725 if (pVBInfo->IF_DEF_LVDS == 1)
5726 xgifb_set_lvds(xgifb_info,
5727 HwDeviceExtension->jChipType,
5728 ModeNo, ModeIdIndex, pVBInfo);
5732 pVBInfo->SetFlag &= (~ProgrammingCRT2);
5733 XGI_SetCRT1FIFO(ModeNo, HwDeviceExtension, pVBInfo);
5734 XGI_SetCRT1ModeRegs(HwDeviceExtension, ModeNo, ModeIdIndex,
5735 RefreshRateTableIndex, pVBInfo);
5736 XGI_LoadDAC(ModeNo, ModeIdIndex, pVBInfo);
5739 unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info,
5740 struct xgi_hw_device_info *HwDeviceExtension,
5741 unsigned short ModeNo)
5743 unsigned short ModeIdIndex;
5744 struct vb_device_info VBINF;
5745 struct vb_device_info *pVBInfo = &VBINF;
5746 pVBInfo->IF_DEF_LVDS = 0;
5748 if (HwDeviceExtension->jChipType >= XG20) {
5749 pVBInfo->IF_DEF_YPbPr = 0;
5750 pVBInfo->IF_DEF_HiVision = 0;
5751 pVBInfo->IF_DEF_CRT2Monitor = 0;
5752 pVBInfo->VBType = 0; /*set VBType default 0*/
5754 pVBInfo->IF_DEF_YPbPr = 1;
5755 pVBInfo->IF_DEF_HiVision = 1;
5756 pVBInfo->IF_DEF_CRT2Monitor = 1;
5759 XGIRegInit(pVBInfo, xgifb_info->vga_base);
5761 /* for x86 Linux, XG21 LVDS */
5762 if (HwDeviceExtension->jChipType == XG21) {
5763 if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0)
5764 pVBInfo->IF_DEF_LVDS = 1;
5766 if (HwDeviceExtension->jChipType == XG27) {
5767 if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) {
5768 if (xgifb_reg_get(pVBInfo->P3d4, 0x30) & 0x20)
5769 pVBInfo->IF_DEF_LVDS = 1;
5773 if (HwDeviceExtension->jChipType < XG20)
5774 XGI_GetVBType(pVBInfo);
5776 InitTo330Pointer(HwDeviceExtension->jChipType, pVBInfo);
5778 ModeNo = ModeNo & 0x7F;
5779 xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86);
5781 if (HwDeviceExtension->jChipType < XG20)
5782 XGI_UnLockCRT2(HwDeviceExtension, pVBInfo);
5784 XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo);
5786 if (HwDeviceExtension->jChipType < XG20) {
5787 XGI_GetVBInfo(ModeNo, ModeIdIndex, HwDeviceExtension, pVBInfo);
5788 XGI_GetTVInfo(ModeNo, ModeIdIndex, pVBInfo);
5789 XGI_GetLCDInfo(ModeNo, ModeIdIndex, pVBInfo);
5790 XGI_DisableBridge(xgifb_info, HwDeviceExtension, pVBInfo);
5792 if (pVBInfo->VBInfo & (SetSimuScanMode | XGI_SetCRT2ToLCDA) ||
5793 (!(pVBInfo->VBInfo & SwitchCRT2))) {
5794 XGI_SetCRT1Group(xgifb_info, HwDeviceExtension, ModeNo,
5795 ModeIdIndex, pVBInfo);
5797 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
5798 XGI_SetLCDAGroup(ModeNo, ModeIdIndex,
5799 HwDeviceExtension, pVBInfo);
5803 if (pVBInfo->VBInfo & (SetSimuScanMode | SwitchCRT2)) {
5804 switch (HwDeviceExtension->ujVBChipID) {
5805 case VB_CHIP_301: /* fall through */
5807 XGI_SetCRT2Group301(ModeNo, HwDeviceExtension,
5808 pVBInfo); /*add for CRT2 */
5816 XGI_SetCRT2ModeRegs(ModeNo, HwDeviceExtension, pVBInfo);
5817 XGI_OEM310Setting(ModeNo, ModeIdIndex, pVBInfo); /*0212*/
5818 XGI_EnableBridge(xgifb_info, HwDeviceExtension, pVBInfo);
5821 if (pVBInfo->IF_DEF_LVDS == 1)
5822 if (!XGI_XG21CheckLVDSMode(xgifb_info, ModeNo,
5827 pVBInfo->ModeType = XGI330_EModeIDTable[ModeIdIndex].
5828 Ext_ModeFlag & ModeTypeMask;
5830 pVBInfo->SetFlag = 0;
5831 pVBInfo->VBInfo = DisableCRT2Display;
5833 XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo);
5835 XGI_SetCRT1Group(xgifb_info, HwDeviceExtension, ModeNo,
5836 ModeIdIndex, pVBInfo);
5838 XGI_DisplayOn(xgifb_info, HwDeviceExtension, pVBInfo);
5841 XGI_UpdateModeInfo(HwDeviceExtension, pVBInfo);
5843 if (HwDeviceExtension->jChipType < XG20)
5844 XGI_LockCRT2(HwDeviceExtension, pVBInfo);