1 #include <linux/delay.h>
7 #include "vb_setmode.h"
10 #define TVCLKBASE_315_25 (TVCLKBASE_315 + 25)
12 static const unsigned short XGINew_VGA_DAC[] = {
13 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
14 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
15 0x00, 0x05, 0x08, 0x0B, 0x0E, 0x11, 0x14, 0x18,
16 0x1C, 0x20, 0x24, 0x28, 0x2D, 0x32, 0x38, 0x3F,
17 0x00, 0x10, 0x1F, 0x2F, 0x3F, 0x1F, 0x27, 0x2F,
18 0x37, 0x3F, 0x2D, 0x31, 0x36, 0x3A, 0x3F, 0x00,
19 0x07, 0x0E, 0x15, 0x1C, 0x0E, 0x11, 0x15, 0x18,
20 0x1C, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x00, 0x04,
21 0x08, 0x0C, 0x10, 0x08, 0x0A, 0x0C, 0x0E, 0x10,
22 0x0B, 0x0C, 0x0D, 0x0F, 0x10};
24 void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo)
26 pVBInfo->StandTable = (struct SiS_StandTable_S *) &XGI330_StandTable;
27 pVBInfo->EModeIDTable = (struct XGI_ExtStruct *) XGI330_EModeIDTable;
28 pVBInfo->RefIndex = (struct XGI_Ext2Struct *) XGI330_RefIndex;
29 pVBInfo->XGINEWUB_CRT1Table
30 = (struct XGI_CRT1TableStruct *) XGI_CRT1Table;
32 pVBInfo->MCLKData = (struct SiS_MCLKData *) XGI340New_MCLKData;
33 pVBInfo->ECLKData = (struct XGI_ECLKDataStruct *) XGI340_ECLKData;
34 pVBInfo->VCLKData = (struct SiS_VCLKData *) XGI_VCLKData;
35 pVBInfo->VBVCLKData = (struct SiS_VBVCLKData *) XGI_VBVCLKData;
36 pVBInfo->ScreenOffset = XGI330_ScreenOffset;
37 pVBInfo->StResInfo = (struct SiS_StResInfo_S *) XGI330_StResInfo;
39 = (struct SiS_ModeResInfo_S *) XGI330_ModeResInfo;
41 pVBInfo->LCDResInfo = 0;
42 pVBInfo->LCDTypeInfo = 0;
47 pVBInfo->SR15 = XGI340_SR13;
48 pVBInfo->CR40 = XGI340_cr41;
49 pVBInfo->CR6B = XGI340_CR6B;
50 pVBInfo->CR6E = XGI340_CR6E;
51 pVBInfo->CR6F = XGI340_CR6F;
52 pVBInfo->CR89 = XGI340_CR89;
53 pVBInfo->AGPReg = XGI340_AGPReg;
54 pVBInfo->SR16 = XGI340_SR16;
59 pVBInfo->NTSCTiming = XGI330_NTSCTiming;
60 pVBInfo->PALTiming = XGI330_PALTiming;
61 pVBInfo->HiTVExtTiming = XGI330_HiTVExtTiming;
62 pVBInfo->HiTVSt1Timing = XGI330_HiTVSt1Timing;
63 pVBInfo->HiTVSt2Timing = XGI330_HiTVSt2Timing;
64 pVBInfo->HiTVTextTiming = XGI330_HiTVTextTiming;
65 pVBInfo->YPbPr750pTiming = XGI330_YPbPr750pTiming;
66 pVBInfo->YPbPr525pTiming = XGI330_YPbPr525pTiming;
67 pVBInfo->YPbPr525iTiming = XGI330_YPbPr525iTiming;
68 pVBInfo->HiTVGroup3Data = XGI330_HiTVGroup3Data;
69 pVBInfo->HiTVGroup3Simu = XGI330_HiTVGroup3Simu;
70 pVBInfo->HiTVGroup3Text = XGI330_HiTVGroup3Text;
71 pVBInfo->Ren525pGroup3 = XGI330_Ren525pGroup3;
72 pVBInfo->Ren750pGroup3 = XGI330_Ren750pGroup3;
74 pVBInfo->TimingH = (struct XGI_TimingHStruct *) XGI_TimingH;
75 pVBInfo->TimingV = (struct XGI_TimingVStruct *) XGI_TimingV;
76 pVBInfo->UpdateCRT1 = (struct XGI_XG21CRT1Struct *) XGI_UpdateCRT1Table;
78 /* 310 customization related */
79 if ((pVBInfo->VBType & VB_SIS301LV) || (pVBInfo->VBType & VB_SIS302LV))
80 pVBInfo->LCDCapList = XGI_LCDDLCapList;
82 pVBInfo->LCDCapList = XGI_LCDCapList;
85 pVBInfo->XGINew_CR97 = 0x10;
87 if (ChipType == XG27) {
90 = (struct SiS_MCLKData *) XGI27New_MCLKData;
91 pVBInfo->CR40 = XGI27_cr41;
92 pVBInfo->XGINew_CR97 = 0xc1;
93 pVBInfo->SR15 = XG27_SR13;
96 temp = xgifb_reg_get(pVBInfo->P3c4, 0x3B);
97 /* SR3B[7][3]MAA15 MAA11 (Power on Trapping) */
98 if (((temp & 0x88) == 0x80) || ((temp & 0x88) == 0x08))
99 pVBInfo->XGINew_CR97 = 0x80;
104 static void XGI_SetSeqRegs(unsigned short ModeNo,
105 unsigned short ModeIdIndex,
106 struct vb_device_info *pVBInfo)
108 unsigned char tempah, SRdata;
109 unsigned short i, modeflag;
111 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
113 xgifb_reg_set(pVBInfo->P3c4, 0x00, 0x03); /* Set SR0 */
114 tempah = pVBInfo->StandTable->SR[0];
116 i = XGI_SetCRT2ToLCDA;
117 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
120 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD)) {
121 if (pVBInfo->VBInfo & SetInSlaveMode)
126 tempah |= 0x20; /* screen off */
127 xgifb_reg_set(pVBInfo->P3c4, 0x01, tempah); /* Set SR1 */
129 for (i = 02; i <= 04; i++) {
130 /* Get SR2,3,4 from file */
131 SRdata = pVBInfo->StandTable->SR[i - 1];
132 xgifb_reg_set(pVBInfo->P3c4, i, SRdata); /* Set SR2 3 4 */
136 static void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension,
137 struct vb_device_info *pVBInfo)
139 unsigned char CRTCdata;
142 CRTCdata = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
144 xgifb_reg_set(pVBInfo->P3d4, 0x11, CRTCdata); /* Unlock CRTC */
146 for (i = 0; i <= 0x18; i++) {
147 /* Get CRTC from file */
148 CRTCdata = pVBInfo->StandTable->CRTC[i];
149 xgifb_reg_set(pVBInfo->P3d4, i, CRTCdata); /* Set CRTC(3d4) */
153 static void XGI_SetATTRegs(unsigned short ModeNo,
154 unsigned short ModeIdIndex,
155 struct vb_device_info *pVBInfo)
157 unsigned char ARdata;
158 unsigned short i, modeflag;
160 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
162 for (i = 0; i <= 0x13; i++) {
163 ARdata = pVBInfo->StandTable->ATTR[i];
165 if ((modeflag & Charx8Dot) && i == 0x13) { /* ifndef Dot9 */
166 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
169 if ((pVBInfo->VBInfo &
170 (SetCRT2ToTV | SetCRT2ToLCD)) &&
171 (pVBInfo->VBInfo & SetInSlaveMode))
176 inb(pVBInfo->P3da); /* reset 3da */
177 outb(i, pVBInfo->P3c0); /* set index */
178 outb(ARdata, pVBInfo->P3c0); /* set data */
181 inb(pVBInfo->P3da); /* reset 3da */
182 outb(0x14, pVBInfo->P3c0); /* set index */
183 outb(0x00, pVBInfo->P3c0); /* set data */
184 inb(pVBInfo->P3da); /* Enable Attribute */
185 outb(0x20, pVBInfo->P3c0);
188 static void XGI_SetGRCRegs(struct vb_device_info *pVBInfo)
190 unsigned char GRdata;
193 for (i = 0; i <= 0x08; i++) {
194 /* Get GR from file */
195 GRdata = pVBInfo->StandTable->GRC[i];
196 xgifb_reg_set(pVBInfo->P3ce, i, GRdata); /* Set GR(3ce) */
199 if (pVBInfo->ModeType > ModeVGA) {
200 GRdata = (unsigned char) xgifb_reg_get(pVBInfo->P3ce, 0x05);
201 GRdata &= 0xBF; /* 256 color disable */
202 xgifb_reg_set(pVBInfo->P3ce, 0x05, GRdata);
206 static void XGI_ClearExt1Regs(struct vb_device_info *pVBInfo)
210 for (i = 0x0A; i <= 0x0E; i++)
211 xgifb_reg_set(pVBInfo->P3c4, i, 0x00); /* Clear SR0A-SR0E */
214 static unsigned char XGI_SetDefaultVCLK(struct vb_device_info *pVBInfo)
217 xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x20);
218 xgifb_reg_set(pVBInfo->P3c4, 0x2B, pVBInfo->VCLKData[0].SR2B);
219 xgifb_reg_set(pVBInfo->P3c4, 0x2C, pVBInfo->VCLKData[0].SR2C);
221 xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x10);
222 xgifb_reg_set(pVBInfo->P3c4, 0x2B, pVBInfo->VCLKData[1].SR2B);
223 xgifb_reg_set(pVBInfo->P3c4, 0x2C, pVBInfo->VCLKData[1].SR2C);
225 xgifb_reg_and(pVBInfo->P3c4, 0x31, ~0x30);
229 static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo,
230 unsigned short ModeIdIndex,
231 unsigned short RefreshRateTableIndex, unsigned short *i,
232 struct vb_device_info *pVBInfo)
234 unsigned short tempax, tempbx, resinfo, modeflag, infoflag;
236 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
237 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
238 tempbx = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID;
241 if (pVBInfo->IF_DEF_LVDS == 0) {
242 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
243 tempax |= SupportRAMDAC2;
245 if (pVBInfo->VBType & VB_XGI301C)
246 tempax |= SupportCRT2in301C;
250 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
251 tempax |= SupportLCD;
253 if (pVBInfo->LCDResInfo != Panel_1280x1024 &&
254 pVBInfo->LCDResInfo != Panel_1280x960 &&
255 (pVBInfo->LCDInfo & LCDNonExpanding) &&
260 if (pVBInfo->VBInfo & SetCRT2ToHiVision) { /* for HiTV */
261 if ((pVBInfo->VBType & VB_SIS301LV) &&
262 (pVBInfo->VBExtInfo == VB_YPbPr1080i)) {
263 tempax |= SupportYPbPr750p;
264 if ((pVBInfo->VBInfo & SetInSlaveMode) &&
270 tempax |= SupportHiVision;
271 if ((pVBInfo->VBInfo & SetInSlaveMode) &&
274 (pVBInfo->SetFlag & TVSimuMode)) ||
279 if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO |
282 SetCRT2ToYPbPr525750 |
283 SetCRT2ToHiVision)) {
286 if (pVBInfo->VBType & (VB_SIS301B |
291 tempax |= SupportTV1024;
293 if (!(pVBInfo->VBInfo & TVSetPAL) &&
294 (modeflag & NoSupportSimuTV) &&
295 (pVBInfo->VBInfo & SetInSlaveMode) &&
296 (!(pVBInfo->VBInfo & SetNotSimuMode)))
300 } else { /* for LVDS */
301 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
302 tempax |= SupportLCD;
305 return 0; /* 1024x768 */
307 if (pVBInfo->LCDResInfo < Panel_1024x768) {
309 return 0; /* 800x600 */
312 return 0; /* 512x384 */
317 for (; pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID ==
319 infoflag = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].
321 if (infoflag & tempax)
328 for ((*i) = 0;; (*i)++) {
329 infoflag = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].
331 if (pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID
336 if (infoflag & tempax)
342 static void XGI_SetSync(unsigned short RefreshRateTableIndex,
343 struct vb_device_info *pVBInfo)
345 unsigned short sync, temp;
348 sync = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag >> 8;
352 outb(temp, pVBInfo->P3c2); /* Set Misc(3c2) */
355 static void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo,
356 struct xgi_hw_device_info *HwDeviceExtension)
358 unsigned char data, data1, pushax;
362 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
364 xgifb_reg_set(pVBInfo->P3d4, 0x11, data);
366 data = pVBInfo->TimingH[0].data[0];
367 xgifb_reg_set(pVBInfo->P3d4, 0, data);
369 for (i = 0x01; i <= 0x04; i++) {
370 data = pVBInfo->TimingH[0].data[i];
371 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 1), data);
374 for (i = 0x05; i <= 0x06; i++) {
375 data = pVBInfo->TimingH[0].data[i];
376 xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i + 6), data);
379 j = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0e);
381 data = pVBInfo->TimingH[0].data[7];
384 xgifb_reg_set(pVBInfo->P3c4, 0x0e, data);
386 if (HwDeviceExtension->jChipType >= XG20) {
387 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x04);
389 xgifb_reg_set(pVBInfo->P3d4, 0x04, data);
390 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x05);
396 data = (unsigned char) xgifb_reg_get(pVBInfo->P3c4,
399 xgifb_reg_set(pVBInfo->P3c4, 0x0c, data);
404 xgifb_reg_set(pVBInfo->P3d4, 0x05, data);
405 data = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0e);
411 xgifb_reg_and_or(pVBInfo->P3c4, 0x0e, ~0xE0, data);
415 static void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex,
416 unsigned short ModeNo,
417 struct vb_device_info *pVBInfo)
422 for (i = 0x00; i <= 0x01; i++) {
423 data = pVBInfo->TimingV[0].data[i];
424 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 6), data);
427 for (i = 0x02; i <= 0x03; i++) {
428 data = pVBInfo->TimingV[0].data[i];
429 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x0e), data);
432 for (i = 0x04; i <= 0x05; i++) {
433 data = pVBInfo->TimingV[0].data[i];
434 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x11), data);
437 j = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0a);
439 data = pVBInfo->TimingV[0].data[6];
442 xgifb_reg_set(pVBInfo->P3c4, 0x0a, data);
444 data = pVBInfo->TimingV[0].data[6];
448 i = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
453 j = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x09);
456 xgifb_reg_set(pVBInfo->P3d4, 0x09, data);
459 static void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
460 unsigned short RefreshRateTableIndex,
461 struct vb_device_info *pVBInfo,
462 struct xgi_hw_device_info *HwDeviceExtension)
464 unsigned char index, data;
468 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
469 index = index & IndexMask;
471 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
473 xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */
475 for (i = 0; i < 8; i++)
476 pVBInfo->TimingH[0].data[i]
477 = pVBInfo->XGINEWUB_CRT1Table[index].CR[i];
479 for (i = 0; i < 7; i++)
480 pVBInfo->TimingV[0].data[i]
481 = pVBInfo->XGINEWUB_CRT1Table[index].CR[i + 8];
483 XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension);
485 XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo);
487 if (pVBInfo->ModeType > 0x03)
488 xgifb_reg_set(pVBInfo->P3d4, 0x14, 0x4F);
491 /* --------------------------------------------------------------------- */
492 /* Function : XGI_SetXG21CRTC */
493 /* Input : Stand or enhance CRTC table */
494 /* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */
495 /* Description : Set LCD timing */
496 /* --------------------------------------------------------------------- */
497 static void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
498 unsigned short RefreshRateTableIndex,
499 struct vb_device_info *pVBInfo)
501 unsigned char index, Tempax, Tempbx, Tempcx, Tempdx;
502 unsigned short Temp1, Temp2, Temp3;
504 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
505 /* Tempax: CR4 HRS */
506 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3];
507 Tempcx = Tempax; /* Tempcx: HRS */
509 xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax);
511 Tempdx = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SRB */
512 Tempdx &= 0xC0; /* Tempdx[7:6]: SRB[7:6] */
513 Temp1 = Tempdx; /* Temp1[7:6]: HRS[9:8] */
514 Temp1 <<= 2; /* Temp1[9:8]: HRS[9:8] */
515 Temp1 |= Tempax; /* Temp1[9:0]: HRS[9:0] */
517 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */
518 Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */
520 Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[6]; /* SRC */
521 Tempbx &= 0x04; /* Tempbx[2]: HRE[5] */
522 Tempbx <<= 3; /* Tempbx[5]: HRE[5] */
523 Tempax |= Tempbx; /* Tempax[5:0]: HRE[5:0] */
525 Temp2 = Temp1 & 0x3C0; /* Temp2[9:6]: HRS[9:6] */
526 Temp2 |= Tempax; /* Temp2[9:0]: HRE[9:0] */
528 Tempcx &= 0x3F; /* Tempcx[5:0]: HRS[5:0] */
529 if (Tempax < Tempcx) /* HRE < HRS */
530 Temp2 |= 0x40; /* Temp2 + 0x40 */
533 Tempax = (unsigned char) Temp2; /* Tempax: HRE[7:0] */
534 Tempax <<= 2; /* Tempax[7:2]: HRE[5:0] */
535 Tempdx >>= 6; /* Tempdx[7:6]->[1:0] HRS[9:8] */
536 Tempax |= Tempdx; /* HRE[5:0]HRS[9:8] */
537 /* SR2F D[7:2]->HRE, D[1:0]->HRS */
538 xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax);
539 xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00);
542 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10];
543 Tempbx = Tempax; /* Tempbx: VRS */
544 Tempax &= 0x01; /* Tempax[0]: VRS[0] */
545 xgifb_reg_or(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS[0] */
547 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9];
548 Tempcx = Tempbx >> 1; /* Tempcx[6:0]: VRS[7:1] */
549 Tempdx = Tempax & 0x04; /* Tempdx[2]: CR7[2] */
550 Tempdx <<= 5; /* Tempdx[7]: VRS[8] */
551 Tempcx |= Tempdx; /* Tempcx[7:0]: VRS[8:1] */
552 xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempcx); /* SR34[8:1]->VRS */
554 Temp1 = Tempdx; /* Temp1[7]: Tempdx[7] */
555 Temp1 <<= 1; /* Temp1[8]: VRS[8] */
556 Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */
558 Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */
559 Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */
561 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14];
562 Tempax &= 0x08; /* Tempax[3]: VRS[3] */
564 Temp2 <<= 7; /* Temp2[10]: VRS[10] */
565 Temp1 |= Temp2; /* Temp1[10:0]: VRS[10:0] */
567 /* Tempax: CR11 VRE */
568 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11];
569 Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
571 Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14];
572 Tempbx &= 0x20; /* Tempbx[5]: VRE[5] */
573 Tempbx >>= 1; /* Tempbx[4]: VRE[4] */
574 Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */
575 Temp2 = Temp1 & 0x7E0; /* Temp2[10:5]: VRS[10:5] */
576 Temp2 |= Tempax; /* Temp2[10:5]: VRE[10:5] */
578 Temp3 = Temp1 & 0x1F; /* Temp3[4:0]: VRS[4:0] */
579 if (Tempax < Temp3) /* VRE < VRS */
580 Temp2 |= 0x20; /* VRE + 0x20 */
583 Tempax = (unsigned char) Temp2; /* Tempax: VRE[7:0] */
584 Tempax <<= 2; /* Tempax[7:0]; VRE[5:0]00 */
585 Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */
586 Temp1 >>= 9; /* Temp1[1:0]: VRS[10:9] */
587 Tempbx = (unsigned char) Temp1;
588 Tempax |= Tempbx; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */
590 /* SR3F D[7:2]->VRE D[1:0]->VRS */
591 xgifb_reg_set(pVBInfo->P3c4, 0x3F, Tempax);
594 static void XGI_SetXG27CRTC(unsigned short ModeNo,
595 unsigned short ModeIdIndex,
596 unsigned short RefreshRateTableIndex,
597 struct vb_device_info *pVBInfo)
599 unsigned short index, Tempax, Tempbx, Tempcx;
601 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
602 /* Tempax: CR4 HRS */
603 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3];
604 Tempbx = Tempax; /* Tempbx: HRS[7:0] */
606 xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax);
609 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5];
610 Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
611 Tempbx |= (Tempax << 2); /* Tempbx: HRS[9:0] */
613 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */
614 Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */
615 Tempcx = Tempax; /* Tempcx: HRE[4:0] */
617 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[6]; /* SRC */
618 Tempax &= 0x04; /* Tempax[2]: HRE[5] */
619 Tempax <<= 3; /* Tempax[5]: HRE[5] */
620 Tempcx |= Tempax; /* Tempcx[5:0]: HRE[5:0] */
622 Tempbx = Tempbx & 0x3C0; /* Tempbx[9:6]: HRS[9:6] */
623 Tempbx |= Tempcx; /* Tempbx: HRS[9:6]HRE[5:0] */
625 /* Tempax: CR4 HRS */
626 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3];
627 Tempax &= 0x3F; /* Tempax: HRS[5:0] */
628 if (Tempcx <= Tempax) /* HRE[5:0] < HRS[5:0] */
629 Tempbx += 0x40; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/
631 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SR0B */
632 Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
633 Tempax >>= 6; /* Tempax[1:0]: HRS[9:8]*/
634 Tempax |= ((Tempbx << 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */
635 /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */
636 xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax);
637 xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00);
640 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10];
641 /* SR34[7:0]->VRS[7:0] */
642 xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempax);
644 Tempcx = Tempax; /* Tempcx <= VRS[7:0] */
645 /* CR7[7][2] VRS[9][8] */
646 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9];
647 Tempbx = Tempax; /* Tempbx <= CR07[7:0] */
648 Tempax = Tempax & 0x04; /* Tempax[2]: CR7[2]: VRS[8] */
649 Tempax >>= 2; /* Tempax[0]: VRS[8] */
650 /* SR35[0]: VRS[8] */
651 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x01, Tempax);
652 Tempcx |= (Tempax << 8); /* Tempcx <= VRS[8:0] */
653 Tempcx |= ((Tempbx & 0x80) << 2); /* Tempcx <= VRS[9:0] */
655 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14];
656 Tempax &= 0x08; /* SR0A[3] VRS[10] */
657 Tempcx |= (Tempax << 7); /* Tempcx <= VRS[10:0] */
659 /* Tempax: CR11 VRE */
660 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11];
661 Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
663 Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14];
664 Tempbx &= 0x20; /* Tempbx[5]: SR0A[5]: VRE[4] */
665 Tempbx >>= 1; /* Tempbx[4]: VRE[4] */
666 Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */
667 Tempbx = Tempcx; /* Tempbx: VRS[10:0] */
668 Tempbx &= 0x7E0; /* Tempbx[10:5]: VRS[10:5] */
669 Tempbx |= Tempax; /* Tempbx: VRS[10:5]VRE[4:0] */
671 if (Tempbx <= Tempcx) /* VRE <= VRS */
672 Tempbx |= 0x20; /* VRE + 0x20 */
674 /* Tempax: Tempax[7:0]; VRE[5:0]00 */
675 Tempax = (Tempbx << 2) & 0xFF;
676 /* SR3F[7:2]:VRE[5:0] */
677 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax);
678 Tempax = Tempcx >> 8;
679 /* SR35[2:0]:VRS[10:8] */
680 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, Tempax);
683 static void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo)
687 /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */
688 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
689 temp = (temp & 3) << 6;
690 /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */
691 xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0xc0, temp & 0x80);
692 /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */
693 xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80);
697 static void xgifb_set_lcd(int chip_id,
698 struct vb_device_info *pVBInfo,
699 unsigned short RefreshRateTableIndex,
700 unsigned short ModeNo)
702 unsigned short Data, Temp;
703 unsigned short XGI_P3cc;
705 XGI_P3cc = pVBInfo->P3cc;
707 xgifb_reg_set(pVBInfo->P3d4, 0x2E, 0x00);
708 xgifb_reg_set(pVBInfo->P3d4, 0x2F, 0x00);
709 xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x00);
710 xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x00);
712 if (chip_id == XG27) {
713 Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
714 if ((Temp & 0x03) == 0) { /* dual 12 */
715 xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x13);
716 xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x13);
720 if (chip_id == XG27) {
721 XGI_SetXG27FPBits(pVBInfo);
723 Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
726 xgifb_reg_or(pVBInfo->P3c4, 0x06, 0x40);
727 xgifb_reg_or(pVBInfo->P3c4, 0x09, 0x40);
731 xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */
733 xgifb_reg_and(pVBInfo->P3c4, 0x30, ~0x20); /* Hsync polarity */
734 xgifb_reg_and(pVBInfo->P3c4, 0x35, ~0x80); /* Vsync polarity */
736 Data = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
739 xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20);
742 xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80);
745 /* --------------------------------------------------------------------- */
746 /* Function : XGI_UpdateXG21CRTC */
748 /* Output : CRT1 CRTC */
749 /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */
750 /* --------------------------------------------------------------------- */
751 static void XGI_UpdateXG21CRTC(unsigned short ModeNo,
752 struct vb_device_info *pVBInfo,
753 unsigned short RefreshRateTableIndex)
757 xgifb_reg_and(pVBInfo->P3d4, 0x11, 0x7F); /* Unlock CR0~7 */
758 if (ModeNo == 0x2E &&
759 (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC ==
762 else if (ModeNo == 0x2E && (pVBInfo->RefIndex[RefreshRateTableIndex].
763 Ext_CRT1CRTC == RES640x480x72))
765 else if (ModeNo == 0x2F)
767 else if (ModeNo == 0x50)
769 else if (ModeNo == 0x59)
773 xgifb_reg_set(pVBInfo->P3d4, 0x02,
774 pVBInfo->UpdateCRT1[index].CR02);
775 xgifb_reg_set(pVBInfo->P3d4, 0x03,
776 pVBInfo->UpdateCRT1[index].CR03);
777 xgifb_reg_set(pVBInfo->P3d4, 0x15,
778 pVBInfo->UpdateCRT1[index].CR15);
779 xgifb_reg_set(pVBInfo->P3d4, 0x16,
780 pVBInfo->UpdateCRT1[index].CR16);
784 static void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension,
785 unsigned short ModeNo, unsigned short ModeIdIndex,
786 unsigned short RefreshRateTableIndex,
787 struct vb_device_info *pVBInfo)
789 unsigned short resindex, tempax, tempbx, tempcx, temp, modeflag;
793 resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
795 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
796 tempax = pVBInfo->ModeResInfo[resindex].HTotal;
797 tempbx = pVBInfo->ModeResInfo[resindex].VTotal;
799 if (modeflag & HalfDCLK)
800 tempax = tempax >> 1;
802 if (modeflag & HalfDCLK)
803 tempax = tempax << 1;
805 temp = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
807 if (temp & InterlaceMode)
808 tempbx = tempbx >> 1;
810 if (modeflag & DoubleScanMode)
811 tempbx = tempbx << 1;
819 temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
820 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
822 xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */
823 xgifb_reg_set(pVBInfo->P3d4, 0x01, (unsigned short) (tempcx & 0xff));
824 xgifb_reg_and_or(pVBInfo->P3d4, 0x0b, ~0x0c,
825 (unsigned short) ((tempcx & 0x0ff00) >> 10));
826 xgifb_reg_set(pVBInfo->P3d4, 0x12, (unsigned short) (tempbx & 0xff));
828 tempbx = tempbx >> 8;
836 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x42, tempax);
837 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x07);
844 xgifb_reg_and_or(pVBInfo->P3d4, 0x0a, ~0x02, tempax);
845 xgifb_reg_set(pVBInfo->P3d4, 0x11, temp);
848 static void XGI_SetCRT1Offset(unsigned short ModeNo,
849 unsigned short ModeIdIndex,
850 unsigned short RefreshRateTableIndex,
851 struct xgi_hw_device_info *HwDeviceExtension,
852 struct vb_device_info *pVBInfo)
854 unsigned short temp, ah, al, temp2, i, DisplayUnit;
857 temp = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo;
859 temp = pVBInfo->ScreenOffset[temp];
861 temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
862 temp2 &= InterlaceMode;
867 temp2 = pVBInfo->ModeType - ModeEGA;
892 if ((ModeNo >= 0x26) && (ModeNo <= 0x28))
893 temp = temp * temp2 + temp2 / 2;
900 temp = temp >> 8; /* ah */
902 i = xgifb_reg_get(pVBInfo->P3c4, 0x0E);
905 xgifb_reg_set(pVBInfo->P3c4, 0x0E, i);
907 temp = (unsigned char) temp2;
908 temp &= 0xFF; /* al */
909 xgifb_reg_set(pVBInfo->P3d4, 0x13, temp);
912 temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
913 temp2 &= InterlaceMode;
917 DisplayUnit = DisplayUnit << 5;
918 ah = (DisplayUnit & 0xff00) >> 8;
919 al = DisplayUnit & 0x00ff;
925 if (HwDeviceExtension->jChipType >= XG20)
926 if ((ModeNo == 0x4A) | (ModeNo == 0x49))
929 xgifb_reg_set(pVBInfo->P3c4, 0x10, ah);
932 static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo,
933 unsigned short ModeIdIndex,
934 unsigned short RefreshRateTableIndex,
935 struct xgi_hw_device_info *HwDeviceExtension,
936 struct vb_device_info *pVBInfo)
938 unsigned short CRT2Index, VCLKIndex;
939 unsigned short modeflag, resinfo;
942 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
943 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
944 CRT2Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
946 if (pVBInfo->IF_DEF_LVDS == 0) {
947 CRT2Index = CRT2Index >> 6; /* for LCD */
948 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { /*301b*/
949 if (pVBInfo->LCDResInfo != Panel_1024x768)
950 VCLKIndex = VCLK108_2_315 + 5; /* LCDXlat2VCLK */
952 VCLKIndex = VCLK65_315 + 2; /* LCDXlat1VCLK */
953 } else if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
954 if (pVBInfo->SetFlag & RPLLDIV2XO) {
955 VCLKIndex = TVCLKBASE_315_25 + HiTVVCLKDIV2;
957 VCLKIndex = TVCLKBASE_315_25 + HiTVVCLK;
960 if (pVBInfo->SetFlag & TVSimuMode) {
961 if (modeflag & Charx8Dot) {
962 VCLKIndex = TVCLKBASE_315_25 + HiTVSimuVCLK;
964 VCLKIndex = TVCLKBASE_315_25 + HiTVTextVCLK;
969 if ((pVBInfo->VBType & VB_SIS301LV) &&
970 !(pVBInfo->VBExtInfo == VB_YPbPr1080i)) {
971 if (pVBInfo->VBExtInfo == YPbPr750p)
972 VCLKIndex = XGI_YPbPr750pVCLK;
973 else if (pVBInfo->VBExtInfo == YPbPr525p)
974 VCLKIndex = YPbPr525pVCLK;
975 else if (pVBInfo->SetFlag & RPLLDIV2XO)
976 VCLKIndex = YPbPr525iVCLK_2;
978 VCLKIndex = YPbPr525iVCLK;
980 } else if (pVBInfo->VBInfo & SetCRT2ToTV) {
981 if (pVBInfo->SetFlag & RPLLDIV2XO) {
982 VCLKIndex = TVCLKBASE_315_25 + TVVCLKDIV2;
984 VCLKIndex = TVCLKBASE_315_25 + TVVCLK;
986 } else { /* for CRT2 */
988 VCLKIndex = pVBInfo->RefIndex[RefreshRateTableIndex].
990 VCLKIndex &= IndexMask;
993 if ((pVBInfo->LCDResInfo == Panel_800x600) ||
994 (pVBInfo->LCDResInfo == Panel_320x480))
995 VCLKIndex = VCLK40; /* LVDSXlat1VCLK */
997 VCLKIndex = VCLK65_315 + 2; /* LVDSXlat2VCLK, LVDSXlat3VCLK */
1003 static void XGI_SetCRT1VCLK(unsigned short ModeNo,
1004 unsigned short ModeIdIndex,
1005 struct xgi_hw_device_info *HwDeviceExtension,
1006 unsigned short RefreshRateTableIndex,
1007 struct vb_device_info *pVBInfo)
1009 unsigned char index, data;
1010 unsigned short vclkindex;
1012 if (pVBInfo->IF_DEF_LVDS == 1) {
1013 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1014 data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF;
1015 xgifb_reg_set(pVBInfo->P3c4, 0x31, data);
1016 xgifb_reg_set(pVBInfo->P3c4, 0x2B,
1017 pVBInfo->VCLKData[index].SR2B);
1018 xgifb_reg_set(pVBInfo->P3c4, 0x2C,
1019 pVBInfo->VCLKData[index].SR2C);
1020 xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01);
1021 } else if ((pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
1022 | VB_SIS302LV | VB_XGI301C)) && (pVBInfo->VBInfo
1023 & XGI_SetCRT2ToLCDA)) {
1024 vclkindex = XGI_GetVCLK2Ptr(ModeNo, ModeIdIndex,
1025 RefreshRateTableIndex, HwDeviceExtension,
1027 data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF;
1028 xgifb_reg_set(pVBInfo->P3c4, 0x31, data);
1029 data = pVBInfo->VBVCLKData[vclkindex].Part4_A;
1030 xgifb_reg_set(pVBInfo->P3c4, 0x2B, data);
1031 data = pVBInfo->VBVCLKData[vclkindex].Part4_B;
1032 xgifb_reg_set(pVBInfo->P3c4, 0x2C, data);
1033 xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01);
1035 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1036 data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF;
1037 xgifb_reg_set(pVBInfo->P3c4, 0x31, data);
1038 xgifb_reg_set(pVBInfo->P3c4, 0x2B,
1039 pVBInfo->VCLKData[index].SR2B);
1040 xgifb_reg_set(pVBInfo->P3c4, 0x2C,
1041 pVBInfo->VCLKData[index].SR2C);
1042 xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01);
1045 if (HwDeviceExtension->jChipType >= XG20) {
1046 if (pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag &
1048 data = xgifb_reg_get(pVBInfo->P3c4, 0x2B);
1049 xgifb_reg_set(pVBInfo->P3c4, 0x2B, data);
1050 data = xgifb_reg_get(pVBInfo->P3c4, 0x2C);
1057 xgifb_reg_set(pVBInfo->P3c4, 0x2C, data);
1062 static void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo)
1066 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); /* D[0] 1: 18bit */
1067 temp = (temp & 1) << 6;
1068 /* SR06[6] 18bit Dither */
1069 xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x40, temp);
1070 /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */
1071 xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80);
1075 static void XGI_SetCRT1FIFO(unsigned short ModeNo,
1076 struct xgi_hw_device_info *HwDeviceExtension,
1077 struct vb_device_info *pVBInfo)
1079 unsigned short data;
1081 data = xgifb_reg_get(pVBInfo->P3c4, 0x3D);
1083 xgifb_reg_set(pVBInfo->P3c4, 0x3D, data); /* diable auto-threshold */
1085 xgifb_reg_set(pVBInfo->P3c4, 0x08, 0x34);
1086 data = xgifb_reg_get(pVBInfo->P3c4, 0x09);
1088 xgifb_reg_set(pVBInfo->P3c4, 0x09, data | 0x30);
1089 data = xgifb_reg_get(pVBInfo->P3c4, 0x3D);
1091 xgifb_reg_set(pVBInfo->P3c4, 0x3D, data);
1093 if (HwDeviceExtension->jChipType == XG21)
1094 XGI_SetXG21FPBits(pVBInfo); /* Fix SR9[7:6] can't read back */
1097 static void XGI_SetVCLKState(struct xgi_hw_device_info *HwDeviceExtension,
1098 unsigned short ModeNo, unsigned short RefreshRateTableIndex,
1099 struct vb_device_info *pVBInfo)
1101 unsigned short data, data2 = 0;
1104 unsigned char index;
1106 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1108 VCLK = pVBInfo->VCLKData[index].CLOCK;
1110 data = xgifb_reg_get(pVBInfo->P3c4, 0x32);
1113 data |= 0x0c; /* VCLK > 200 */
1115 if (HwDeviceExtension->jChipType >= XG20)
1116 data &= ~0x04; /* 2 pixel mode */
1118 xgifb_reg_set(pVBInfo->P3c4, 0x32, data);
1120 if (HwDeviceExtension->jChipType < XG20) {
1121 data = xgifb_reg_get(pVBInfo->P3c4, 0x1F);
1125 xgifb_reg_set(pVBInfo->P3c4, 0x1F, data);
1130 xgifb_reg_and_or(pVBInfo->P3c4, 0x07, 0xFC, data2);
1131 if (HwDeviceExtension->jChipType >= XG27)
1132 xgifb_reg_and_or(pVBInfo->P3c4, 0x40, 0xFC, data2 & 0x03);
1136 static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension,
1137 unsigned short ModeNo, unsigned short ModeIdIndex,
1138 unsigned short RefreshRateTableIndex,
1139 struct vb_device_info *pVBInfo)
1141 unsigned short data, data2, data3, infoflag = 0, modeflag, resindex,
1144 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1145 infoflag = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1147 if (xgifb_reg_get(pVBInfo->P3d4, 0x31) & 0x01)
1148 xgifb_reg_and_or(pVBInfo->P3c4, 0x1F, 0x3F, 0x00);
1153 data3 = pVBInfo->ModeType - ModeVGA;
1156 data &= InterlaceMode;
1161 xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x3F, data2);
1162 resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
1163 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
1166 if (infoflag & InterlaceMode) {
1169 else if (xres == 1280)
1173 data2 = data & 0x00FF;
1174 xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFF, data2);
1175 data2 = (data & 0xFF00) >> 8;
1176 xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFC, data2);
1178 if (modeflag & HalfDCLK)
1179 xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xF7, 0x08);
1183 if (modeflag & LineCompareOff)
1186 xgifb_reg_and_or(pVBInfo->P3c4, 0x0F, ~0x48, data2);
1190 xgifb_reg_and_or(pVBInfo->P3c4, 0x21, 0x1F, data);
1192 XGI_SetVCLKState(HwDeviceExtension, ModeNo, RefreshRateTableIndex,
1195 data = xgifb_reg_get(pVBInfo->P3d4, 0x31);
1197 if (HwDeviceExtension->jChipType == XG27) {
1202 xgifb_reg_set(pVBInfo->P3d4, 0x52, data);
1203 xgifb_reg_or(pVBInfo->P3d4, 0x51, 0x10);
1204 } else if (HwDeviceExtension->jChipType >= XG20) {
1209 xgifb_reg_set(pVBInfo->P3d4, 0x52, data);
1210 xgifb_reg_set(pVBInfo->P3d4, 0x51, 0x02);
1216 xgifb_reg_set(pVBInfo->P3d4, 0x52, data);
1221 static void XGI_WriteDAC(unsigned short dl,
1225 struct vb_device_info *pVBInfo)
1227 unsigned short temp, bh, bl;
1246 outb((unsigned short) dh, pVBInfo->P3c9);
1247 outb((unsigned short) bh, pVBInfo->P3c9);
1248 outb((unsigned short) bl, pVBInfo->P3c9);
1251 static void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex,
1252 struct vb_device_info *pVBInfo)
1254 unsigned short data, data2, i, k, m, n, o, si, di, bx, dl, al, ah, dh;
1255 const unsigned short *table = XGINew_VGA_DAC;
1257 outb(0xFF, pVBInfo->P3c6);
1258 outb(0x00, pVBInfo->P3c8);
1260 for (i = 0; i < 16; i++) {
1263 for (k = 0; k < 3; k++) {
1272 outb(data2, pVBInfo->P3c9);
1277 for (i = 16; i < 32; i++) {
1280 for (k = 0; k < 3; k++)
1281 outb(data, pVBInfo->P3c9);
1286 for (m = 0; m < 9; m++) {
1291 for (n = 0; n < 3; n++) {
1292 for (o = 0; o < 5; o++) {
1297 XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
1302 for (o = 0; o < 3; o++) {
1307 XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
1317 static void XGI_GetLVDSResInfo(unsigned short ModeNo,
1318 unsigned short ModeIdIndex,
1319 struct vb_device_info *pVBInfo)
1321 unsigned short resindex, xres, yres, modeflag;
1323 /* si+Ext_ResInfo */
1324 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
1326 /* si+Ext_ResInfo */
1327 resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
1329 xres = pVBInfo->ModeResInfo[resindex].HTotal;
1330 yres = pVBInfo->ModeResInfo[resindex].VTotal;
1332 if (modeflag & HalfDCLK)
1335 if (modeflag & DoubleScanMode)
1341 pVBInfo->VGAHDE = xres;
1342 pVBInfo->HDE = xres;
1343 pVBInfo->VGAVDE = yres;
1344 pVBInfo->VDE = yres;
1347 static void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo,
1348 unsigned short ModeIdIndex,
1349 unsigned short RefreshRateTableIndex,
1350 struct vb_device_info *pVBInfo)
1352 unsigned short i, tempdx, tempcx, tempbx, tempal, modeflag, table;
1354 struct XGI330_LCDDataTablStruct *tempdi = NULL;
1358 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1359 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
1361 tempal = tempal & 0x0f;
1363 if (tempbx <= 1) { /* ExpLink */
1364 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
1366 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
1367 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].
1372 tempal = (tempal >> 4);
1374 tempal = (tempal & 0x0f);
1377 tempcx = LCDLenList[tempbx];
1379 if (pVBInfo->LCDInfo & EnableScalingLCD) { /* ScaleLCD */
1380 if ((tempbx == 5) || (tempbx) == 7)
1381 tempcx = LCDDesDataLen2;
1382 else if ((tempbx == 3) || (tempbx == 8))
1383 tempcx = LVDSDesDataLen2;
1389 tempdi = xgifb_epllcd_crt1;
1392 tempdi = XGI_EPLLCDDataPtr;
1395 tempdi = XGI_EPLLCDDesDataPtr;
1398 tempdi = XGI_LCDDataTable;
1401 tempdi = XGI_LCDDesDataTable;
1404 tempdi = XGI_EPLCHLCDRegPtr;
1415 if (tempdi == NULL) /* OEMUtil */
1421 while (tempdi[i].PANELID != 0xff) {
1422 tempdx = pVBInfo->LCDResInfo;
1423 if (tempbx & 0x0080) { /* OEMUtil */
1424 tempbx &= (~0x0080);
1425 tempdx = pVBInfo->LCDTypeInfo;
1428 if (pVBInfo->LCDInfo & EnableScalingLCD)
1429 tempdx &= (~PanelResInfo);
1431 if (tempdi[i].PANELID == tempdx) {
1432 tempbx = tempdi[i].MASK;
1433 tempdx = pVBInfo->LCDInfo;
1435 if (modeflag & HalfDCLK)
1436 tempdx |= SetLCDLowResolution;
1439 if (tempbx == tempdi[i].CAP)
1446 switch (tempdi[i].DATAPTR) {
1448 return &XGI_LVDSCRT11024x768_1_H[tempal];
1451 return &XGI_LVDSCRT11024x768_2_H[tempal];
1454 return &XGI_LVDSCRT11280x1024_1_H[tempal];
1457 return &XGI_LVDSCRT11280x1024_2_H[tempal];
1460 return &XGI_LVDSCRT11400x1050_1_H[tempal];
1463 return &XGI_LVDSCRT11400x1050_2_H[tempal];
1466 return &XGI_LVDSCRT11600x1200_1_H[tempal];
1469 return &XGI_LVDSCRT11024x768_1_Hx75[tempal];
1472 return &XGI_LVDSCRT11024x768_2_Hx75[tempal];
1475 return &XGI_LVDSCRT11280x1024_1_Hx75[tempal];
1478 return &XGI_LVDSCRT11280x1024_2_Hx75[tempal];
1483 } else if (table == 1) {
1484 switch (tempdi[i].DATAPTR) {
1486 return &XGI_LVDSCRT11024x768_1_V[tempal];
1489 return &XGI_LVDSCRT11024x768_2_V[tempal];
1492 return &XGI_LVDSCRT11280x1024_1_V[tempal];
1495 return &XGI_LVDSCRT11280x1024_2_V[tempal];
1498 return &XGI_LVDSCRT11400x1050_1_V[tempal];
1501 return &XGI_LVDSCRT11400x1050_2_V[tempal];
1504 return &XGI_LVDSCRT11600x1200_1_V[tempal];
1507 return &XGI_LVDSCRT11024x768_1_Vx75[tempal];
1510 return &XGI_LVDSCRT11024x768_2_Vx75[tempal];
1513 return &XGI_LVDSCRT11280x1024_1_Vx75[tempal];
1516 return &XGI_LVDSCRT11280x1024_2_Vx75[tempal];
1521 } else if (table == 2) {
1522 switch (tempdi[i].DATAPTR) {
1524 return &XGI_LVDS1024x768Data_1[tempal];
1527 return &XGI_LVDS1024x768Data_2[tempal];
1530 return &XGI_LVDS1280x1024Data_1[tempal];
1533 return &XGI_LVDS1280x1024Data_2[tempal];
1536 return &XGI_LVDS1400x1050Data_1[tempal];
1539 return &XGI_LVDS1400x1050Data_2[tempal];
1542 return &XGI_LVDS1600x1200Data_1[tempal];
1545 return &XGI_LVDSNoScalingData[tempal];
1548 return &XGI_LVDS1024x768Data_1x75[tempal];
1551 return &XGI_LVDS1024x768Data_2x75[tempal];
1554 return &XGI_LVDS1280x1024Data_1x75[tempal];
1557 return &XGI_LVDS1280x1024Data_2x75[tempal];
1560 return &XGI_LVDSNoScalingDatax75[tempal];
1565 } else if (table == 3) {
1566 switch (tempdi[i].DATAPTR) {
1568 return &XGI_LVDS1024x768Des_1[tempal];
1571 return &XGI_LVDS1024x768Des_3[tempal];
1574 return &XGI_LVDS1024x768Des_2[tempal];
1577 return &XGI_LVDS1280x1024Des_1[tempal];
1580 return &XGI_LVDS1280x1024Des_2[tempal];
1583 return &XGI_LVDS1400x1050Des_1[tempal];
1586 return &XGI_LVDS1400x1050Des_2[tempal];
1589 return &XGI_LVDS1600x1200Des_1[tempal];
1592 return &XGI_LVDSNoScalingDesData[tempal];
1595 return &XGI_LVDS1024x768Des_1x75[tempal];
1598 return &XGI_LVDS1024x768Des_3x75[tempal];
1601 return &XGI_LVDS1024x768Des_2x75[tempal];
1604 return &XGI_LVDS1280x1024Des_1x75[tempal];
1607 return &XGI_LVDS1280x1024Des_2x75[tempal];
1610 return &XGI_LVDSNoScalingDesDatax75[tempal];
1615 } else if (table == 4) {
1616 switch (tempdi[i].DATAPTR) {
1618 return &XGI_ExtLCD1024x768Data[tempal];
1621 return &XGI_StLCD1024x768Data[tempal];
1624 return &XGI_CetLCD1024x768Data[tempal];
1627 return &XGI_ExtLCD1280x1024Data[tempal];
1630 return &XGI_StLCD1280x1024Data[tempal];
1633 return &XGI_CetLCD1280x1024Data[tempal];
1637 return &xgifb_lcd_1400x1050[tempal];
1640 return &XGI_CetLCD1400x1050Data[tempal];
1643 return &XGI_ExtLCD1600x1200Data[tempal];
1646 return &XGI_StLCD1600x1200Data[tempal];
1649 return &XGI_NoScalingData[tempal];
1652 return &XGI_ExtLCD1024x768x75Data[tempal];
1655 return &XGI_ExtLCD1024x768x75Data[tempal];
1658 return &XGI_CetLCD1024x768x75Data[tempal];
1662 return &xgifb_lcd_1280x1024x75[tempal];
1665 return &XGI_CetLCD1280x1024x75Data[tempal];
1668 return &XGI_NoScalingDatax75[tempal];
1673 } else if (table == 5) {
1674 switch (tempdi[i].DATAPTR) {
1676 return &XGI_ExtLCDDes1024x768Data[tempal];
1679 return &XGI_StLCDDes1024x768Data[tempal];
1682 return &XGI_CetLCDDes1024x768Data[tempal];
1685 if ((pVBInfo->VBType & VB_SIS301LV) ||
1686 (pVBInfo->VBType & VB_SIS302LV))
1687 return &XGI_ExtLCDDLDes1280x1024Data[tempal];
1689 return &XGI_ExtLCDDes1280x1024Data[tempal];
1692 if ((pVBInfo->VBType & VB_SIS301LV) ||
1693 (pVBInfo->VBType & VB_SIS302LV))
1694 return &XGI_StLCDDLDes1280x1024Data[tempal];
1696 return &XGI_StLCDDes1280x1024Data[tempal];
1699 if ((pVBInfo->VBType & VB_SIS301LV) ||
1700 (pVBInfo->VBType & VB_SIS302LV))
1701 return &XGI_CetLCDDLDes1280x1024Data[tempal];
1703 return &XGI_CetLCDDes1280x1024Data[tempal];
1707 if ((pVBInfo->VBType & VB_SIS301LV) ||
1708 (pVBInfo->VBType & VB_SIS302LV))
1709 return &xgifb_lcddldes_1400x1050[tempal];
1711 return &xgifb_lcddes_1400x1050[tempal];
1714 return &XGI_CetLCDDes1400x1050Data[tempal];
1717 return &XGI_CetLCDDes1400x1050Data2[tempal];
1720 if ((pVBInfo->VBType & VB_SIS301LV) ||
1721 (pVBInfo->VBType & VB_SIS302LV))
1722 return &XGI_ExtLCDDLDes1600x1200Data[tempal];
1724 return &XGI_ExtLCDDes1600x1200Data[tempal];
1727 if ((pVBInfo->VBType & VB_SIS301LV) ||
1728 (pVBInfo->VBType & VB_SIS302LV))
1729 return &XGI_StLCDDLDes1600x1200Data[tempal];
1731 return &XGI_StLCDDes1600x1200Data[tempal];
1734 return &XGI_NoScalingDesData[tempal];
1738 return &xgifb_lcddes_1024x768x75[tempal];
1741 return &XGI_CetLCDDes1024x768x75Data[tempal];
1745 if ((pVBInfo->VBType & VB_SIS301LV) ||
1746 (pVBInfo->VBType & VB_SIS302LV))
1747 return &xgifb_lcddldes_1280x1024x75[tempal];
1749 return &xgifb_lcddes_1280x1024x75[tempal];
1752 if ((pVBInfo->VBType & VB_SIS301LV) ||
1753 (pVBInfo->VBType & VB_SIS302LV))
1754 return &XGI_CetLCDDLDes1280x1024x75Data[tempal];
1756 return &XGI_CetLCDDes1280x1024x75Data[tempal];
1759 return &XGI_NoScalingDesDatax75[tempal];
1764 } else if (table == 6) {
1765 switch (tempdi[i].DATAPTR) {
1767 return &XGI_CH7017LV1024x768[tempal];
1770 return &XGI_CH7017LV1400x1050[tempal];
1779 static void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo,
1780 unsigned short ModeIdIndex,
1781 unsigned short RefreshRateTableIndex,
1782 struct vb_device_info *pVBInfo)
1784 unsigned short i, tempdx, tempbx, tempal, modeflag, table;
1785 struct XGI330_TVDataTablStruct *tempdi = NULL;
1788 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1789 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
1790 tempal = tempal & 0x3f;
1802 tempdi = xgifb_chrontel_tv;
1808 tempdi = XGI_TVDataTable;
1817 if (tempdi == NULL) /* OEMUtil */
1820 tempdx = pVBInfo->TVInfo;
1822 if (pVBInfo->VBInfo & SetInSlaveMode)
1823 tempdx = tempdx | SetTVLockMode;
1825 if (modeflag & HalfDCLK)
1826 tempdx = tempdx | SetTVLowResolution;
1830 while (tempdi[i].MASK != 0xffff) {
1831 if ((tempdx & tempdi[i].MASK) == tempdi[i].CAP)
1836 if (table == 0x04) {
1837 switch (tempdi[i].DATAPTR) {
1839 return &XGI_ExtPALData[tempal];
1842 return &XGI_ExtNTSCData[tempal];
1845 return &XGI_StPALData[tempal];
1848 return &XGI_StNTSCData[tempal];
1851 return &XGI_ExtHiTVData[tempal];
1854 return &XGI_St2HiTVData[tempal];
1857 return &XGI_ExtYPbPr525iData[tempal];
1860 return &XGI_ExtYPbPr525pData[tempal];
1863 return &XGI_ExtYPbPr750pData[tempal];
1866 return &XGI_StYPbPr525iData[tempal];
1869 return &XGI_StYPbPr525pData[tempal];
1872 return &XGI_StYPbPr750pData[tempal];
1874 case 12: /* avoid system hang */
1875 return &XGI_ExtNTSCData[tempal];
1878 return &XGI_St1HiTVData[tempal];
1883 } else if (table == 0x02) {
1884 switch (tempdi[i].DATAPTR) {
1886 return &XGI_CHTVUNTSCData[tempal];
1889 return &XGI_CHTVONTSCData[tempal];
1892 return &XGI_CHTVUPALData[tempal];
1895 return &XGI_CHTVOPALData[tempal];
1904 static void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex,
1905 unsigned short RefreshRateTableIndex,
1906 struct vb_device_info *pVBInfo)
1908 unsigned short tempbx;
1909 struct SiS_LVDSData *LCDPtr = NULL;
1913 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
1914 LCDPtr = (struct SiS_LVDSData *)XGI_GetLcdPtr(tempbx,
1915 ModeNo, ModeIdIndex, RefreshRateTableIndex,
1917 pVBInfo->VGAHT = LCDPtr->VGAHT;
1918 pVBInfo->VGAVT = LCDPtr->VGAVT;
1919 pVBInfo->HT = LCDPtr->LCDHT;
1920 pVBInfo->VT = LCDPtr->LCDVT;
1923 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
1924 if (!(pVBInfo->LCDInfo & (SetLCDtoNonExpanding
1925 | EnableScalingLCD))) {
1926 if ((pVBInfo->LCDResInfo == Panel_1024x768) ||
1927 (pVBInfo->LCDResInfo == Panel_1024x768x75)) {
1928 pVBInfo->HDE = 1024;
1930 } else if ((pVBInfo->LCDResInfo == Panel_1280x1024) ||
1931 (pVBInfo->LCDResInfo == Panel_1280x1024x75)) {
1932 pVBInfo->HDE = 1280;
1933 pVBInfo->VDE = 1024;
1934 } else if (pVBInfo->LCDResInfo == Panel_1400x1050) {
1935 pVBInfo->HDE = 1400;
1936 pVBInfo->VDE = 1050;
1938 pVBInfo->HDE = 1600;
1939 pVBInfo->VDE = 1200;
1945 static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex,
1946 unsigned short RefreshRateTableIndex,
1947 struct xgi_hw_device_info *HwDeviceExtension,
1948 struct vb_device_info *pVBInfo)
1950 unsigned char index;
1951 unsigned short tempbx, i;
1952 struct XGI_LVDSCRT1HDataStruct *LCDPtr = NULL;
1953 struct XGI_LVDSCRT1VDataStruct *LCDPtr1 = NULL;
1955 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
1956 index = index & IndexMask;
1960 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
1961 LCDPtr = (struct XGI_LVDSCRT1HDataStruct *)
1962 XGI_GetLcdPtr(tempbx, ModeNo,
1964 RefreshRateTableIndex,
1967 for (i = 0; i < 8; i++)
1968 pVBInfo->TimingH[0].data[i] = LCDPtr[0].Reg[i];
1971 XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension);
1975 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
1976 LCDPtr1 = (struct XGI_LVDSCRT1VDataStruct *)
1981 RefreshRateTableIndex,
1983 for (i = 0; i < 7; i++)
1984 pVBInfo->TimingV[0].data[i] = LCDPtr1[0].Reg[i];
1987 XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo);
1990 static unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo)
1992 unsigned char tempal, tempah, tempbl, i;
1994 tempah = xgifb_reg_get(pVBInfo->P3d4, 0x36);
1995 tempal = tempah & 0x0F;
1996 tempah = tempah & 0xF0;
1998 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
2000 while (tempbl != 0xFF) {
2001 if (tempbl & 0x80) { /* OEMUtil */
2003 tempbl = tempbl & ~(0x80);
2006 if (tempal == tempbl)
2011 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
2017 static unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo)
2019 unsigned short tempah, tempal, tempbl, i;
2021 tempal = pVBInfo->LCDResInfo;
2022 tempah = pVBInfo->LCDTypeInfo;
2025 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
2027 while (tempbl != 0xFF) {
2028 if ((tempbl & 0x80) && (tempbl != 0x80)) {
2033 if (tempal == tempbl)
2037 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
2040 if (tempbl == 0xFF) {
2041 pVBInfo->LCDResInfo = Panel_1024x768;
2042 pVBInfo->LCDTypeInfo = 0;
2049 static void XGI_GetLCDSync(unsigned short *HSyncWidth,
2050 unsigned short *VSyncWidth,
2051 struct vb_device_info *pVBInfo)
2053 unsigned short Index;
2055 Index = XGI_GetLCDCapPtr(pVBInfo);
2056 *HSyncWidth = pVBInfo->LCDCapList[Index].LCD_HSyncWidth;
2057 *VSyncWidth = pVBInfo->LCDCapList[Index].LCD_VSyncWidth;
2062 static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
2063 unsigned short RefreshRateTableIndex,
2064 struct vb_device_info *pVBInfo)
2066 unsigned short tempbx, tempax, tempcx, tempdx, push1, push2, modeflag;
2067 unsigned long temp, temp1, temp2, temp3, push3;
2068 struct XGI_LCDDesStruct *LCDPtr = NULL;
2069 struct XGI330_LCDDataDesStruct2 *LCDPtr1 = NULL;
2071 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2073 if (pVBInfo->LCDInfo & EnableScalingLCD)
2075 (struct XGI330_LCDDataDesStruct2 *)
2080 RefreshRateTableIndex,
2084 (struct XGI_LCDDesStruct *)
2089 RefreshRateTableIndex,
2092 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
2097 if ((pVBInfo->LCDResInfo == Panel_1024x768) ||
2098 (pVBInfo->LCDResInfo == Panel_1024x768x75)) {
2101 } else if ((pVBInfo->LCDResInfo == Panel_1280x1024) ||
2102 (pVBInfo->LCDResInfo == Panel_1280x1024x75)) {
2105 } else if (pVBInfo->LCDResInfo == Panel_1400x1050) {
2113 if (pVBInfo->LCDInfo & SetLCDtoNonExpanding) {
2114 pVBInfo->HDE = tempax;
2115 pVBInfo->VDE = tempbx;
2116 pVBInfo->VGAHDE = tempax;
2117 pVBInfo->VGAVDE = tempbx;
2120 tempax = pVBInfo->HT;
2122 if (pVBInfo->LCDInfo & EnableScalingLCD)
2123 tempbx = LCDPtr1->LCDHDES;
2125 tempbx = LCDPtr->LCDHDES;
2127 tempcx = pVBInfo->HDE;
2128 tempbx = tempbx & 0x0fff;
2131 if (tempcx >= tempax)
2134 xgifb_reg_set(pVBInfo->Part1Port, 0x1A, tempbx & 0x07);
2136 tempcx = tempcx >> 3;
2137 tempbx = tempbx >> 3;
2139 xgifb_reg_set(pVBInfo->Part1Port, 0x16,
2140 (unsigned short) (tempbx & 0xff));
2141 xgifb_reg_set(pVBInfo->Part1Port, 0x17,
2142 (unsigned short) (tempcx & 0xff));
2144 tempax = pVBInfo->HT;
2146 if (pVBInfo->LCDInfo & EnableScalingLCD)
2147 tempbx = LCDPtr1->LCDHRS;
2149 tempbx = LCDPtr->LCDHRS;
2153 if (pVBInfo->LCDInfo & EnableScalingLCD)
2154 tempcx = LCDPtr1->LCDHSync;
2158 if (tempcx >= tempax)
2161 tempax = tempbx & 0x07;
2162 tempax = tempax >> 5;
2163 tempcx = tempcx >> 3;
2164 tempbx = tempbx >> 3;
2169 xgifb_reg_set(pVBInfo->Part1Port, 0x15, tempax);
2170 xgifb_reg_set(pVBInfo->Part1Port, 0x14,
2171 (unsigned short) (tempbx & 0xff));
2173 tempax = pVBInfo->VT;
2174 if (pVBInfo->LCDInfo & EnableScalingLCD)
2175 tempbx = LCDPtr1->LCDVDES;
2177 tempbx = LCDPtr->LCDVDES;
2178 tempcx = pVBInfo->VDE;
2180 tempbx = tempbx & 0x0fff;
2182 if (tempcx >= tempax)
2185 xgifb_reg_set(pVBInfo->Part1Port, 0x1b,
2186 (unsigned short) (tempbx & 0xff));
2187 xgifb_reg_set(pVBInfo->Part1Port, 0x1c,
2188 (unsigned short) (tempcx & 0xff));
2190 tempbx = (tempbx >> 8) & 0x07;
2191 tempcx = (tempcx >> 8) & 0x07;
2193 xgifb_reg_set(pVBInfo->Part1Port, 0x1d,
2194 (unsigned short) ((tempcx << 3)
2197 tempax = pVBInfo->VT;
2198 if (pVBInfo->LCDInfo & EnableScalingLCD)
2199 tempbx = LCDPtr1->LCDVRS;
2201 tempbx = LCDPtr->LCDVRS;
2205 if (pVBInfo->LCDInfo & EnableScalingLCD)
2206 tempcx = LCDPtr1->LCDVSync;
2209 if (tempcx >= tempax)
2212 xgifb_reg_set(pVBInfo->Part1Port, 0x18,
2213 (unsigned short) (tempbx & 0xff));
2214 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, ~0x0f,
2215 (unsigned short) (tempcx & 0x0f));
2217 tempax = ((tempbx >> 8) & 0x07) << 3;
2219 tempbx = pVBInfo->VGAVDE;
2220 if (tempbx != pVBInfo->VDE)
2223 if (pVBInfo->LCDInfo & XGI_EnableLVDSDDA)
2226 xgifb_reg_and_or(pVBInfo->Part1Port, 0x1a, 0x07,
2229 tempcx = pVBInfo->VGAVT;
2230 tempbx = pVBInfo->VDE;
2231 tempax = pVBInfo->VGAVDE;
2234 temp = tempax; /* 0430 ylshieh */
2235 temp1 = (temp << 18) / tempbx;
2237 tempdx = (unsigned short) ((temp << 18) % tempbx);
2245 xgifb_reg_set(pVBInfo->Part1Port, 0x37,
2246 (unsigned short) (temp2 & 0xff));
2247 xgifb_reg_set(pVBInfo->Part1Port, 0x36,
2248 (unsigned short) ((temp2 >> 8) & 0xff));
2250 tempbx = (unsigned short) (temp2 >> 16);
2251 tempax = tempbx & 0x03;
2253 tempbx = pVBInfo->VGAVDE;
2254 if (tempbx == pVBInfo->VDE)
2257 xgifb_reg_set(pVBInfo->Part1Port, 0x35, tempax);
2259 if (pVBInfo->VBType & VB_XGI301C) {
2261 xgifb_reg_set(pVBInfo->Part4Port,
2263 (unsigned short) (temp2 & 0xff));
2264 xgifb_reg_set(pVBInfo->Part4Port,
2266 (unsigned short) ((temp2 >> 8) &
2268 tempbx = (unsigned short) (temp2 >> 16);
2269 xgifb_reg_and_or(pVBInfo->Part4Port, 0x3a,
2271 (unsigned short) ((tempbx &
2274 tempcx = pVBInfo->VGAVDE;
2275 if (tempcx == pVBInfo->VDE)
2276 xgifb_reg_and_or(pVBInfo->Part4Port,
2279 xgifb_reg_and_or(pVBInfo->Part4Port,
2283 tempcx = pVBInfo->VGAHDE;
2284 tempbx = pVBInfo->HDE;
2286 temp1 = tempcx << 16;
2288 tempax = (unsigned short) (temp1 / tempbx);
2290 if ((tempbx & 0xffff) == (tempcx & 0xffff))
2294 temp1 = pVBInfo->VGAHDE << 16;
2297 temp3 = temp3 << 16;
2300 temp3 = (temp3 & 0xffff0000) + (temp1 & 0xffff);
2302 tempax = (unsigned short) (temp3 & 0xff);
2303 xgifb_reg_set(pVBInfo->Part1Port, 0x1f, tempax);
2305 temp1 = pVBInfo->VGAVDE << 18;
2306 temp1 = temp1 / push3;
2307 tempbx = (unsigned short) (temp1 & 0xffff);
2309 if (pVBInfo->LCDResInfo == Panel_1024x768)
2312 tempax = ((tempbx >> 8) & 0xff) << 3;
2313 tempax |= (unsigned short) ((temp3 >> 8) & 0x07);
2314 xgifb_reg_set(pVBInfo->Part1Port, 0x20,
2315 (unsigned short) (tempax & 0xff));
2316 xgifb_reg_set(pVBInfo->Part1Port, 0x21,
2317 (unsigned short) (tempbx & 0xff));
2319 temp3 = temp3 >> 16;
2321 if (modeflag & HalfDCLK)
2324 xgifb_reg_set(pVBInfo->Part1Port, 0x22,
2325 (unsigned short) ((temp3 >> 8) & 0xff));
2326 xgifb_reg_set(pVBInfo->Part1Port, 0x23,
2327 (unsigned short) (temp3 & 0xff));
2330 /* --------------------------------------------------------------------- */
2331 /* Function : XGI_GETLCDVCLKPtr */
2333 /* Output : al -> VCLK Index */
2335 /* --------------------------------------------------------------------- */
2336 static void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1,
2337 struct vb_device_info *pVBInfo)
2339 unsigned short index;
2341 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
2342 index = XGI_GetLCDCapPtr1(pVBInfo);
2344 if (pVBInfo->VBInfo & SetCRT2ToLCD) { /* LCDB */
2345 *di_0 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData1;
2346 *di_1 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData2;
2348 *di_0 = pVBInfo->LCDCapList[index].LCDA_VCLKData1;
2349 *di_1 = pVBInfo->LCDCapList[index].LCDA_VCLKData2;
2355 static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex,
2356 unsigned short ModeNo, unsigned short ModeIdIndex,
2357 struct vb_device_info *pVBInfo)
2360 unsigned short index, modeflag;
2361 unsigned char tempal;
2363 /* si+Ext_ResInfo */
2364 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2366 if ((pVBInfo->SetFlag & ProgrammingCRT2) &&
2367 (!(pVBInfo->LCDInfo & EnableScalingLCD))) { /* {LCDA/LCDB} */
2368 index = XGI_GetLCDCapPtr(pVBInfo);
2369 tempal = pVBInfo->LCDCapList[index].LCD_VCLK;
2371 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))
2375 if (pVBInfo->VBType &
2381 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
2382 tempal = TVCLKBASE_315 + HiTVVCLKDIV2;
2383 if (!(pVBInfo->TVInfo & RPLLDIV2XO))
2384 tempal = TVCLKBASE_315 + HiTVVCLK;
2385 if (pVBInfo->TVInfo & TVSimuMode) {
2386 tempal = TVCLKBASE_315 + HiTVSimuVCLK;
2387 if (!(modeflag & Charx8Dot))
2388 tempal = TVCLKBASE_315 + HiTVTextVCLK;
2394 if (pVBInfo->TVInfo & TVSetYPbPr750p) {
2395 tempal = XGI_YPbPr750pVCLK;
2399 if (pVBInfo->TVInfo & TVSetYPbPr525p) {
2400 tempal = YPbPr525pVCLK;
2404 tempal = NTSC1024VCLK;
2406 if (!(pVBInfo->TVInfo & NTSC1024x768)) {
2407 tempal = TVCLKBASE_315 + TVVCLKDIV2;
2408 if (!(pVBInfo->TVInfo & RPLLDIV2XO))
2409 tempal = TVCLKBASE_315 + TVVCLK;
2412 if (pVBInfo->VBInfo & SetCRT2ToTV)
2417 tempal = (unsigned char) inb((pVBInfo->P3ca + 0x02));
2418 tempal = tempal >> 2;
2421 /* for Dot8 Scaling LCD */
2422 if ((pVBInfo->LCDInfo & EnableScalingLCD) && (modeflag & Charx8Dot))
2423 tempal = tempal ^ tempal; /* ; set to VCLK25MHz always */
2425 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
2429 static void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0,
2430 unsigned char *di_1, struct vb_device_info *pVBInfo)
2432 if (pVBInfo->VBType & (VB_SIS301 | VB_SIS301B | VB_SIS302B
2433 | VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) {
2434 if ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) && (pVBInfo->SetFlag
2435 & ProgrammingCRT2)) {
2436 *di_0 = (unsigned char) XGI_VBVCLKData[tempal].SR2B;
2437 *di_1 = XGI_VBVCLKData[tempal].SR2C;
2440 *di_0 = XGI_VCLKData[tempal].SR2B;
2441 *di_1 = XGI_VCLKData[tempal].SR2C;
2445 static void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex,
2446 unsigned short RefreshRateTableIndex,
2447 struct vb_device_info *pVBInfo)
2449 unsigned char di_0, di_1, tempal;
2452 tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex,
2454 XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo);
2455 XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo);
2457 for (i = 0; i < 4; i++) {
2458 xgifb_reg_and_or(pVBInfo->P3d4, 0x31, ~0x30,
2459 (unsigned short) (0x10 * i));
2460 if ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA))
2461 && (!(pVBInfo->VBInfo & SetInSlaveMode))) {
2462 xgifb_reg_set(pVBInfo->P3c4, 0x2e, di_0);
2463 xgifb_reg_set(pVBInfo->P3c4, 0x2f, di_1);
2465 xgifb_reg_set(pVBInfo->P3c4, 0x2b, di_0);
2466 xgifb_reg_set(pVBInfo->P3c4, 0x2c, di_1);
2471 static void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension,
2472 struct vb_device_info *pVBInfo)
2474 unsigned short tempcl, tempch, temp, tempbl, tempax;
2476 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
2477 | VB_SIS302LV | VB_XGI301C)) {
2480 temp = xgifb_reg_get(pVBInfo->P3c4, 0x01);
2482 if (!(temp & 0x20)) {
2483 temp = xgifb_reg_get(pVBInfo->P3d4, 0x17);
2485 temp = xgifb_reg_get(pVBInfo->P3d4, 0x53);
2487 tempcl |= ActiveCRT1;
2491 temp = xgifb_reg_get(pVBInfo->Part1Port, 0x2e);
2494 if (!(temp == 0x08)) {
2495 /* Check ChannelA */
2496 tempax = xgifb_reg_get(pVBInfo->Part1Port, 0x13);
2498 tempcl = tempcl | ActiveLCD;
2502 if (!(tempcl & ActiveLCD))
2504 tempcl |= ActiveCRT2;
2507 tempcl |= ActiveLCD;
2510 temp = xgifb_reg_get(pVBInfo->Part2Port, 0x00);
2513 tempch |= ActiveAVideo;
2516 tempch |= ActiveSVideo;
2519 tempch |= ActiveSCART;
2521 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
2523 tempch |= ActiveHiTV;
2526 if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
2527 temp = xgifb_reg_get(
2532 tempch |= ActiveYPbPr;
2540 temp = xgifb_reg_get(pVBInfo->P3d4, 0x3d);
2541 if (tempcl & ActiveLCD) {
2542 if ((pVBInfo->SetFlag & ReserveTVOption)) {
2543 if (temp & ActiveTV)
2548 tempbl = ~XGI_ModeSwitchStatus;
2549 xgifb_reg_and_or(pVBInfo->P3d4, 0x3d, tempbl, temp);
2551 if (!(pVBInfo->SetFlag & ReserveTVOption))
2552 xgifb_reg_set(pVBInfo->P3d4, 0x3e, tempch);
2558 void XGI_GetVBType(struct vb_device_info *pVBInfo)
2560 unsigned short flag, tempbx, tempah;
2562 if (pVBInfo->IF_DEF_LVDS != 0)
2565 tempbx = VB_SIS302B;
2566 flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00);
2571 flag = xgifb_reg_get(pVBInfo->Part4Port, 0x01);
2575 tempbx = VB_SIS301B;
2577 goto bigger_than_0xB0;
2579 tempbx = VB_XGI301C;
2581 goto bigger_than_0xB0;
2583 tempbx = VB_SIS301LV;
2585 goto bigger_than_0xB0;
2587 tempbx = VB_SIS302LV;
2588 tempah = xgifb_reg_get(pVBInfo->Part4Port, 0x39);
2590 tempbx = VB_XGI301C;
2593 if (tempbx & (VB_SIS301B | VB_SIS302B)) {
2594 flag = xgifb_reg_get(pVBInfo->Part4Port, 0x23);
2596 tempbx = tempbx | VB_NoLCD;
2600 pVBInfo->VBType = tempbx;
2603 static void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
2604 struct xgi_hw_device_info *HwDeviceExtension,
2605 struct vb_device_info *pVBInfo)
2607 unsigned short tempax, push, tempbx, temp, modeflag;
2609 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2610 pVBInfo->SetFlag = 0;
2611 pVBInfo->ModeType = modeflag & ModeTypeMask;
2614 if (!(pVBInfo->VBType & 0xFFFF))
2617 /* Check Display Device */
2618 temp = xgifb_reg_get(pVBInfo->P3d4, 0x30);
2619 tempbx = tempbx | temp;
2620 temp = xgifb_reg_get(pVBInfo->P3d4, 0x31);
2624 tempbx = tempbx | tempax;
2625 temp = (SetCRT2ToDualEdge | SetCRT2ToYPbPr525750 | XGI_SetCRT2ToLCDA
2626 | SetInSlaveMode | DisableCRT2Display);
2627 temp = 0xFFFF ^ temp;
2630 temp = xgifb_reg_get(pVBInfo->P3d4, 0x38);
2632 if (pVBInfo->IF_DEF_LCDA == 1) {
2634 if (((HwDeviceExtension->jChipType >= XG20) ||
2635 (HwDeviceExtension->jChipType >= XG40)) &&
2636 (pVBInfo->IF_DEF_LVDS == 0)) {
2637 if (pVBInfo->VBType &
2642 if (temp & EnableDualEdge) {
2643 tempbx |= SetCRT2ToDualEdge;
2644 if (temp & SetToLCDA)
2645 tempbx |= XGI_SetCRT2ToLCDA;
2651 if (pVBInfo->IF_DEF_YPbPr == 1) {
2652 if (((pVBInfo->IF_DEF_LVDS == 0) &&
2653 ((pVBInfo->VBType & VB_SIS301LV) ||
2654 (pVBInfo->VBType & VB_SIS302LV) ||
2655 (pVBInfo->VBType & VB_XGI301C)))) {
2656 if (temp & SetYPbPr) {
2657 if (pVBInfo->IF_DEF_HiVision == 1) {
2658 /* shampoo add for new
2660 temp = xgifb_reg_get(
2664 tempbx |= SetCRT2ToHiVision;
2666 if (temp != YPbPrMode1080i) {
2668 (~SetCRT2ToHiVision);
2670 SetCRT2ToYPbPr525750;
2677 tempax = push; /* restore CR31 */
2679 if (pVBInfo->IF_DEF_LVDS == 0) {
2680 if (pVBInfo->IF_DEF_YPbPr == 1) {
2681 if (pVBInfo->IF_DEF_HiVision == 1)
2686 if (pVBInfo->IF_DEF_HiVision == 1)
2691 } else { /* 3nd party chip */
2692 temp = SetCRT2ToLCD;
2695 if (!(tempbx & temp)) {
2696 tempax |= DisableCRT2Display;
2700 if (pVBInfo->IF_DEF_LCDA == 1) { /* Select Display Device */
2701 if (!(pVBInfo->VBType & VB_NoLCD)) {
2702 if (tempbx & XGI_SetCRT2ToLCDA) {
2703 if (tempbx & SetSimuScanMode)
2704 tempbx &= (~(SetCRT2ToLCD |
2708 tempbx &= (~(SetCRT2ToLCD |
2717 /* for driver abnormal */
2718 if (!(tempbx & (SwitchCRT2 | SetSimuScanMode))) {
2719 if (pVBInfo->IF_DEF_CRT2Monitor == 1) {
2720 if (tempbx & SetCRT2ToRAMDAC) {
2725 tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750));
2728 tempbx &= (~(SetCRT2ToRAMDAC |
2734 if (!(pVBInfo->VBType & VB_NoLCD)) {
2735 if (tempbx & SetCRT2ToLCD) {
2740 tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750));
2744 if (tempbx & SetCRT2ToSCART) {
2749 tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750));
2752 if (pVBInfo->IF_DEF_YPbPr == 1) {
2753 if (tempbx & SetCRT2ToYPbPr525750)
2759 if (pVBInfo->IF_DEF_HiVision == 1) {
2760 if (tempbx & SetCRT2ToHiVision)
2767 if (tempax & DisableCRT2Display) { /* Set Display Device Info */
2768 if (!(tempbx & (SwitchCRT2 | SetSimuScanMode)))
2769 tempbx = DisableCRT2Display;
2772 if (!(tempbx & DisableCRT2Display)) {
2773 if ((!(tempbx & DriverMode)) ||
2774 (!(modeflag & CRT2Mode))) {
2775 if (pVBInfo->IF_DEF_LCDA == 1) {
2776 if (!(tempbx & XGI_SetCRT2ToLCDA))
2777 tempbx |= (SetInSlaveMode |
2782 /* LCD+TV can't support in slave mode
2783 * (Force LCDA+TV->LCDB) */
2784 if ((tempbx & SetInSlaveMode) &&
2785 (tempbx & XGI_SetCRT2ToLCDA)) {
2786 tempbx ^= (SetCRT2ToLCD |
2789 pVBInfo->SetFlag |= ReserveTVOption;
2793 pVBInfo->VBInfo = tempbx;
2796 static void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
2797 struct vb_device_info *pVBInfo)
2799 unsigned short temp, tempbx = 0, resinfo = 0, modeflag, index1;
2804 if (pVBInfo->VBInfo & SetCRT2ToTV) {
2805 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2806 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
2808 if (pVBInfo->VBInfo & SetCRT2ToTV) {
2809 temp = xgifb_reg_get(pVBInfo->P3d4, 0x35);
2811 if (tempbx & TVSetPAL) {
2812 tempbx &= (SetCHTVOverScan |
2816 if (tempbx & TVSetPALM)
2817 /* set to NTSC if PAL-M */
2818 tempbx &= ~TVSetPAL;
2820 tempbx &= (SetCHTVOverScan |
2825 if (pVBInfo->IF_DEF_LVDS == 0) {
2826 if (pVBInfo->VBInfo & SetCRT2ToSCART)
2830 if (pVBInfo->IF_DEF_YPbPr == 1) {
2831 if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
2832 index1 = xgifb_reg_get(pVBInfo->P3d4, 0x35);
2833 index1 &= YPbPrMode;
2835 if (index1 == YPbPrMode525i)
2836 tempbx |= TVSetYPbPr525i;
2838 if (index1 == YPbPrMode525p)
2839 tempbx = tempbx | TVSetYPbPr525p;
2840 if (index1 == YPbPrMode750p)
2841 tempbx = tempbx | TVSetYPbPr750p;
2845 if (pVBInfo->IF_DEF_HiVision == 1) {
2846 if (pVBInfo->VBInfo & SetCRT2ToHiVision)
2847 tempbx = tempbx | TVSetHiVision | TVSetPAL;
2850 if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */
2851 if ((pVBInfo->VBInfo & SetInSlaveMode) &&
2852 (!(pVBInfo->VBInfo & SetNotSimuMode)))
2853 tempbx |= TVSimuMode;
2855 if (!(tempbx & TVSetPAL) &&
2857 (resinfo == 8)) /* NTSC 1024x768, */
2858 tempbx |= NTSC1024x768;
2860 tempbx |= RPLLDIV2XO;
2862 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
2863 if (pVBInfo->VBInfo & SetInSlaveMode)
2864 tempbx &= (~RPLLDIV2XO);
2867 (TVSetYPbPr525p | TVSetYPbPr750p))
2868 tempbx &= (~RPLLDIV2XO);
2869 else if (!(pVBInfo->VBType &
2875 if (tempbx & TVSimuMode)
2876 tempbx &= (~RPLLDIV2XO);
2881 pVBInfo->TVInfo = tempbx;
2884 static unsigned char XGI_GetLCDInfo(unsigned short ModeNo,
2885 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
2887 unsigned short temp, tempax, tempbx, modeflag, resinfo = 0, LCDIdIndex;
2889 pVBInfo->LCDResInfo = 0;
2890 pVBInfo->LCDTypeInfo = 0;
2891 pVBInfo->LCDInfo = 0;
2893 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2894 /* si+Ext_ResInfo // */
2895 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
2896 temp = xgifb_reg_get(pVBInfo->P3d4, 0x36); /* Get LCD Res.Info */
2897 tempbx = temp & 0x0F;
2900 tempbx = Panel_1024x768; /* default */
2903 if ((tempbx == Panel_1024x768) || (tempbx == Panel_1280x1024)) {
2904 if (pVBInfo->VBInfo & DriverMode) {
2905 tempax = xgifb_reg_get(pVBInfo->P3d4, 0x33);
2906 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)
2909 tempax = tempax >> 4;
2911 if ((resinfo == 6) || (resinfo == 9)) {
2913 tempbx |= PanelRef75Hz;
2914 } else if ((resinfo == 7) || (resinfo == 8)) {
2916 tempbx |= PanelRef75Hz;
2921 pVBInfo->LCDResInfo = tempbx;
2925 if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)))
2930 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
2932 temp &= (ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable);
2936 LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo);
2938 tempax = pVBInfo->LCDCapList[LCDIdIndex].LCD_Capability;
2940 if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */
2941 if (((pVBInfo->VBType & VB_SIS302LV) || (pVBInfo->VBType
2942 & VB_XGI301C)) && (tempax & XGI_LCDDualLink)) {
2943 tempbx |= SetLCDDualLink;
2947 if (pVBInfo->IF_DEF_LVDS == 0) {
2948 if ((pVBInfo->LCDResInfo == Panel_1400x1050) && (pVBInfo->VBInfo
2949 & SetCRT2ToLCD) && (resinfo == 9) &&
2950 (!(tempbx & EnableScalingLCD)))
2951 /* set to center in 1280x1024 LCDB for Panel_1400x1050 */
2952 tempbx |= SetLCDtoNonExpanding;
2955 if (pVBInfo->IF_DEF_ExpLink == 1) {
2956 if (modeflag & HalfDCLK) {
2957 if (!(tempbx & SetLCDtoNonExpanding)) {
2958 tempbx |= XGI_EnableLVDSDDA;
2960 if (pVBInfo->LCDResInfo == Panel_1024x768) {
2961 if (resinfo == 4) {/* 512x384 */
2962 tempbx |= XGI_EnableLVDSDDA;
2969 if (pVBInfo->VBInfo & SetInSlaveMode) {
2970 if (pVBInfo->VBInfo & SetNotSimuMode)
2971 tempbx |= XGI_LCDVESATiming;
2973 tempbx |= XGI_LCDVESATiming;
2976 pVBInfo->LCDInfo = tempbx;
2981 unsigned char XGI_SearchModeID(unsigned short ModeNo,
2982 unsigned short *ModeIdIndex, struct vb_device_info *pVBInfo)
2984 for (*ModeIdIndex = 0;; (*ModeIdIndex)++) {
2985 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == ModeNo)
2987 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == 0xFF)
2994 static unsigned char XG21GPIODataTransfer(unsigned char ujDate)
2996 unsigned char ujRet = 0;
2997 unsigned char i = 0;
2999 for (i = 0; i < 8; i++) {
3001 ujRet |= (ujDate >> i) & 1;
3007 /*----------------------------------------------------------------------------*/
3009 /* bl[5] : LVDS signal */
3010 /* bl[1] : LVDS backlight */
3011 /* bl[0] : LVDS VDD */
3012 /*----------------------------------------------------------------------------*/
3013 static unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo)
3015 unsigned char CR4A, temp;
3017 CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
3018 xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x23); /* enable GPIO write */
3020 temp = xgifb_reg_get(pVBInfo->P3d4, 0x48);
3022 temp = XG21GPIODataTransfer(temp);
3024 xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A);
3028 /*----------------------------------------------------------------------------*/
3030 /* bl[5] : LVDS signal */
3031 /* bl[1] : LVDS backlight */
3032 /* bl[0] : LVDS VDD */
3033 /*----------------------------------------------------------------------------*/
3034 static unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo)
3036 unsigned char CR4A, CRB4, temp;
3038 CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
3039 xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x0C); /* enable GPIO write */
3041 temp = xgifb_reg_get(pVBInfo->P3d4, 0x48);
3045 xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A);
3046 CRB4 = xgifb_reg_get(pVBInfo->P3d4, 0xB4);
3047 temp |= ((CRB4 & 0x04) << 3);
3051 /*----------------------------------------------------------------------------*/
3053 /* bl[5] : 1;LVDS signal on */
3054 /* bl[1] : 1;LVDS backlight on */
3055 /* bl[0] : 1:LVDS VDD on */
3056 /* bh: 100000b : clear bit 5, to set bit5 */
3057 /* 000010b : clear bit 1, to set bit1 */
3058 /* 000001b : clear bit 0, to set bit0 */
3059 /*----------------------------------------------------------------------------*/
3060 static void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl,
3061 struct vb_device_info *pVBInfo)
3063 unsigned char CR4A, temp;
3065 CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
3068 xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */
3070 if (tempbh & 0x20) {
3071 temp = (tempbl >> 4) & 0x02;
3074 xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp);
3078 temp = xgifb_reg_get(pVBInfo->P3d4, 0x48);
3080 temp = XG21GPIODataTransfer(temp);
3083 xgifb_reg_set(pVBInfo->P3d4, 0x48, temp);
3086 static void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl,
3087 struct vb_device_info *pVBInfo)
3089 unsigned char CR4A, temp;
3090 unsigned short tempbh0, tempbl0;
3099 if (tempbh & 0x20) {
3100 temp = (tempbl >> 4) & 0x02;
3103 xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp);
3106 xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~tempbh0, tempbl0);
3108 CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
3112 tempbl <<= 2; /* GPIOC,GPIOD */
3113 xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */
3114 xgifb_reg_and_or(pVBInfo->P3d4, 0x48, ~tempbh, tempbl);
3117 /* --------------------------------------------------------------------- */
3118 /* Function : XGI_XG21SetPanelDelay */
3122 /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
3123 /* : bl : 2 ; T2 : the duration signal on and Vdd on */
3124 /* : bl : 3 ; T3 : the duration between CPL off and signal off */
3125 /* : bl : 4 ; T4 : the duration signal off and Vdd off */
3126 /* --------------------------------------------------------------------- */
3127 static void XGI_XG21SetPanelDelay(struct xgifb_video_info *xgifb_info,
3128 unsigned short tempbl,
3129 struct vb_device_info *pVBInfo)
3132 mdelay(xgifb_info->lvds_data.PSC_S1);
3135 mdelay(xgifb_info->lvds_data.PSC_S2);
3138 mdelay(xgifb_info->lvds_data.PSC_S3);
3141 mdelay(xgifb_info->lvds_data.PSC_S4);
3144 static void XGI_DisplayOn(struct xgifb_video_info *xgifb_info,
3145 struct xgi_hw_device_info *pXGIHWDE,
3146 struct vb_device_info *pVBInfo)
3149 xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x00);
3150 if (pXGIHWDE->jChipType == XG21) {
3151 if (pVBInfo->IF_DEF_LVDS == 1) {
3152 if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x1)) {
3154 XGI_XG21BLSignalVDD(0x01, 0x01, pVBInfo);
3155 XGI_XG21SetPanelDelay(xgifb_info, 2, pVBInfo);
3157 if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x20))
3158 /* LVDS signal on */
3159 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo);
3160 XGI_XG21SetPanelDelay(xgifb_info, 3, pVBInfo);
3161 /* LVDS backlight on */
3162 XGI_XG21BLSignalVDD(0x02, 0x02, pVBInfo);
3164 /* DVO/DVI signal on */
3165 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo);
3170 if (pXGIHWDE->jChipType == XG27) {
3171 if (pVBInfo->IF_DEF_LVDS == 1) {
3172 if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x1)) {
3174 XGI_XG27BLSignalVDD(0x01, 0x01, pVBInfo);
3175 XGI_XG21SetPanelDelay(xgifb_info, 2, pVBInfo);
3177 if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x20))
3178 /* LVDS signal on */
3179 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo);
3180 XGI_XG21SetPanelDelay(xgifb_info, 3, pVBInfo);
3181 /* LVDS backlight on */
3182 XGI_XG27BLSignalVDD(0x02, 0x02, pVBInfo);
3184 /* DVO/DVI signal on */
3185 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo);
3191 void XGI_DisplayOff(struct xgifb_video_info *xgifb_info,
3192 struct xgi_hw_device_info *pXGIHWDE,
3193 struct vb_device_info *pVBInfo)
3196 if (pXGIHWDE->jChipType == XG21) {
3197 if (pVBInfo->IF_DEF_LVDS == 1) {
3198 /* LVDS backlight off */
3199 XGI_XG21BLSignalVDD(0x02, 0x00, pVBInfo);
3200 XGI_XG21SetPanelDelay(xgifb_info, 3, pVBInfo);
3202 /* DVO/DVI signal off */
3203 XGI_XG21BLSignalVDD(0x20, 0x00, pVBInfo);
3207 if (pXGIHWDE->jChipType == XG27) {
3208 if ((XGI_XG27GetPSCValue(pVBInfo) & 0x2)) {
3209 /* LVDS backlight off */
3210 XGI_XG27BLSignalVDD(0x02, 0x00, pVBInfo);
3211 XGI_XG21SetPanelDelay(xgifb_info, 3, pVBInfo);
3214 if (pVBInfo->IF_DEF_LVDS == 0)
3215 /* DVO/DVI signal off */
3216 XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo);
3219 xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x20);
3222 static void XGI_WaitDisply(struct vb_device_info *pVBInfo)
3224 while ((inb(pVBInfo->P3da) & 0x01))
3227 while (!(inb(pVBInfo->P3da) & 0x01))
3231 static void XGI_AutoThreshold(struct vb_device_info *pVBInfo)
3233 xgifb_reg_or(pVBInfo->Part1Port, 0x01, 0x40);
3236 static void XGI_SaveCRT2Info(unsigned short ModeNo,
3237 struct vb_device_info *pVBInfo)
3239 unsigned short temp1, temp2;
3241 /* reserve CR34 for CRT1 Mode No */
3242 xgifb_reg_set(pVBInfo->P3d4, 0x34, ModeNo);
3243 temp1 = (pVBInfo->VBInfo & SetInSlaveMode) >> 8;
3244 temp2 = ~(SetInSlaveMode >> 8);
3245 xgifb_reg_and_or(pVBInfo->P3d4, 0x31, temp2, temp1);
3248 static void XGI_GetCRT2ResInfo(unsigned short ModeNo,
3249 unsigned short ModeIdIndex,
3250 struct vb_device_info *pVBInfo)
3252 unsigned short xres, yres, modeflag, resindex;
3254 resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
3255 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
3256 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
3257 /* si+St_ModeFlag */
3258 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3260 if (modeflag & HalfDCLK)
3263 if (modeflag & DoubleScanMode)
3266 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
3269 if (pVBInfo->IF_DEF_LVDS == 0) {
3270 if (pVBInfo->LCDResInfo == Panel_1600x1200) {
3271 if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
3277 if (pVBInfo->LCDResInfo == Panel_1280x1024) {
3280 else if (yres == 350)
3283 if (pVBInfo->LCDInfo & XGI_LCDVESATiming) {
3289 if (pVBInfo->LCDResInfo == Panel_1024x768) {
3290 if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
3291 if (!(pVBInfo->LCDInfo & LCDNonExpanding)) {
3294 else if (yres == 400)
3296 else if (yres == 480)
3307 pVBInfo->VGAHDE = xres;
3308 pVBInfo->HDE = xres;
3309 pVBInfo->VGAVDE = yres;
3310 pVBInfo->VDE = yres;
3313 static unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo)
3316 if ((pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) &&
3317 (pVBInfo->LCDInfo & SetLCDDualLink)) /* shampoo0129 */
3323 static void XGI_GetRAMDAC2DATA(unsigned short ModeNo,
3324 unsigned short ModeIdIndex,
3325 unsigned short RefreshRateTableIndex,
3326 struct vb_device_info *pVBInfo)
3328 unsigned short tempax, tempbx, temp1, temp2, modeflag = 0, tempcx,
3331 pVBInfo->RVBHCMAX = 1;
3332 pVBInfo->RVBHCFACT = 1;
3333 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3334 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
3335 CRT1Index &= IndexMask;
3336 temp1 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[0];
3337 temp2 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5];
3338 tempax = (temp1 & 0xFF) | ((temp2 & 0x03) << 8);
3339 tempbx = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[8];
3340 tempcx = (unsigned short)
3341 pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14] << 8;
3343 tempcx = tempcx << 2;
3345 temp1 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9];
3354 if (modeflag & Charx8Dot)
3359 pVBInfo->VGAHT = tempax;
3360 pVBInfo->HT = tempax;
3362 pVBInfo->VGAVT = tempbx;
3363 pVBInfo->VT = tempbx;
3366 static void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex,
3367 unsigned short RefreshRateTableIndex,
3368 struct vb_device_info *pVBInfo)
3370 unsigned short tempax = 0, tempbx, modeflag, resinfo;
3372 struct SiS_LCDData *LCDPtr = NULL;
3373 struct SiS_TVData *TVPtr = NULL;
3375 /* si+Ext_ResInfo */
3376 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3377 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
3378 pVBInfo->NewFlickerMode = 0;
3379 pVBInfo->RVBHRS = 50;
3381 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
3382 XGI_GetRAMDAC2DATA(ModeNo, ModeIdIndex, RefreshRateTableIndex,
3389 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
3390 LCDPtr = (struct SiS_LCDData *) XGI_GetLcdPtr(tempbx,
3391 ModeNo, ModeIdIndex, RefreshRateTableIndex,
3394 pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX;
3395 pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT;
3396 pVBInfo->VGAHT = LCDPtr->VGAHT;
3397 pVBInfo->VGAVT = LCDPtr->VGAVT;
3398 pVBInfo->HT = LCDPtr->LCDHT;
3399 pVBInfo->VT = LCDPtr->LCDVT;
3401 if (pVBInfo->LCDResInfo == Panel_1024x768) {
3405 if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
3406 if (pVBInfo->VGAVDE == 357)
3408 else if (pVBInfo->VGAVDE == 420)
3410 else if (pVBInfo->VGAVDE == 525)
3412 else if (pVBInfo->VGAVDE == 600)
3418 } else if (pVBInfo->LCDResInfo == Panel_1024x768x75) {
3421 } else if (pVBInfo->LCDResInfo == Panel_1280x1024) {
3423 if (pVBInfo->VGAVDE == 360)
3425 else if (pVBInfo->VGAVDE == 375)
3427 else if (pVBInfo->VGAVDE == 405)
3431 } else if (pVBInfo->LCDResInfo == Panel_1280x1024x75) {
3434 } else if (pVBInfo->LCDResInfo == Panel_1280x960) {
3436 if (pVBInfo->VGAVDE == 350)
3438 else if (pVBInfo->VGAVDE == 400)
3440 else if (pVBInfo->VGAVDE == 1024)
3444 } else if (pVBInfo->LCDResInfo == Panel_1400x1050) {
3448 if (pVBInfo->VGAVDE == 1024) {
3452 } else if (pVBInfo->LCDResInfo == Panel_1600x1200) {
3454 tempbx = 1200; /* alan 10/14/2003 */
3455 if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
3456 if (pVBInfo->VGAVDE == 350)
3458 else if (pVBInfo->VGAVDE == 400)
3463 if (pVBInfo->LCDInfo & LCDNonExpanding) {
3464 tempax = pVBInfo->VGAHDE;
3465 tempbx = pVBInfo->VGAVDE;
3468 pVBInfo->HDE = tempax;
3469 pVBInfo->VDE = tempbx;
3473 if (pVBInfo->VBInfo & (SetCRT2ToTV)) {
3475 TVPtr = (struct SiS_TVData *) XGI_GetTVPtr(tempbx,
3476 ModeNo, ModeIdIndex, RefreshRateTableIndex,
3479 pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX;
3480 pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT;
3481 pVBInfo->VGAHT = TVPtr->VGAHT;
3482 pVBInfo->VGAVT = TVPtr->VGAVT;
3483 pVBInfo->HDE = TVPtr->TVHDE;
3484 pVBInfo->VDE = TVPtr->TVVDE;
3485 pVBInfo->RVBHRS = TVPtr->RVBHRS;
3486 pVBInfo->NewFlickerMode = TVPtr->FlickerMode;
3488 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
3489 if (resinfo == 0x08)
3490 pVBInfo->NewFlickerMode = 0x40;
3491 else if (resinfo == 0x09)
3492 pVBInfo->NewFlickerMode = 0x40;
3493 else if (resinfo == 0x12)
3494 pVBInfo->NewFlickerMode = 0x40;
3496 if (pVBInfo->VGAVDE == 350)
3497 pVBInfo->TVInfo |= TVSimuMode;
3502 if (pVBInfo->VBInfo & SetInSlaveMode) {
3503 if (pVBInfo->TVInfo & TVSimuMode) {
3507 if (!(modeflag & Charx8Dot)) {
3508 tempax = StHiTextTVHT;
3509 tempbx = StHiTextTVVT;
3513 } else if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
3514 if (pVBInfo->TVInfo & TVSetYPbPr750p) {
3515 tempax = YPbPrTV750pHT; /* Ext750pTVHT */
3516 tempbx = YPbPrTV750pVT; /* Ext750pTVVT */
3519 if (pVBInfo->TVInfo & TVSetYPbPr525p) {
3520 tempax = YPbPrTV525pHT; /* Ext525pTVHT */
3521 tempbx = YPbPrTV525pVT; /* Ext525pTVVT */
3522 } else if (pVBInfo->TVInfo & TVSetYPbPr525i) {
3523 tempax = YPbPrTV525iHT; /* Ext525iTVHT */
3524 tempbx = YPbPrTV525iVT; /* Ext525iTVVT */
3525 if (pVBInfo->TVInfo & NTSC1024x768)
3526 tempax = NTSC1024x768HT;
3531 if (!(pVBInfo->TVInfo & TVSetPAL)) {
3534 if (pVBInfo->TVInfo & NTSC1024x768)
3535 tempax = NTSC1024x768HT;
3539 pVBInfo->HT = tempax;
3540 pVBInfo->VT = tempbx;
3545 static void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex,
3546 unsigned short RefreshRateTableIndex,
3547 struct vb_device_info *pVBInfo)
3549 unsigned char di_0, di_1, tempal;
3551 tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex,
3553 XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo);
3554 XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo);
3556 if (pVBInfo->VBType & VB_SIS301) { /* shampoo 0129 */
3558 xgifb_reg_set(pVBInfo->Part4Port, 0x0A, 0x10);
3559 xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1);
3560 xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0);
3561 } else { /* 301b/302b/301lv/302lv */
3562 xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0);
3563 xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1);
3566 xgifb_reg_set(pVBInfo->Part4Port, 0x00, 0x12);
3568 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC)
3569 xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x28);
3571 xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x08);
3574 static unsigned short XGI_GetColorDepth(unsigned short ModeNo,
3575 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
3577 unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8 };
3579 unsigned short modeflag;
3581 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3582 index = (modeflag & ModeTypeMask) - ModeEGA;
3587 return ColorDepth[index];
3590 static unsigned short XGI_GetOffset(unsigned short ModeNo,
3591 unsigned short ModeIdIndex,
3592 unsigned short RefreshRateTableIndex,
3593 struct xgi_hw_device_info *HwDeviceExtension,
3594 struct vb_device_info *pVBInfo)
3596 unsigned short temp, colordepth, modeinfo, index, infoflag,
3597 ColorDepth[] = { 0x01, 0x02, 0x04 };
3599 modeinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo;
3600 infoflag = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
3602 index = (modeinfo >> 8) & 0xFF;
3604 temp = pVBInfo->ScreenOffset[index];
3606 if (infoflag & InterlaceMode)
3609 colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo);
3611 if ((ModeNo >= 0x7C) && (ModeNo <= 0x7E)) {
3612 temp = ModeNo - 0x7C;
3613 colordepth = ColorDepth[temp];
3615 if (infoflag & InterlaceMode)
3617 return temp * colordepth;
3619 return temp * colordepth;
3623 static void XGI_SetCRT2Offset(unsigned short ModeNo,
3624 unsigned short ModeIdIndex,
3625 unsigned short RefreshRateTableIndex,
3626 struct xgi_hw_device_info *HwDeviceExtension,
3627 struct vb_device_info *pVBInfo)
3629 unsigned short offset;
3632 if (pVBInfo->VBInfo & SetInSlaveMode)
3635 offset = XGI_GetOffset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
3636 HwDeviceExtension, pVBInfo);
3637 temp = (unsigned char) (offset & 0xFF);
3638 xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp);
3639 temp = (unsigned char) ((offset & 0xFF00) >> 8);
3640 xgifb_reg_set(pVBInfo->Part1Port, 0x09, temp);
3641 temp = (unsigned char) (((offset >> 3) & 0xFF) + 1);
3642 xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp);
3645 static void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo)
3647 /* threshold high ,disable auto threshold */
3648 xgifb_reg_set(pVBInfo->Part1Port, 0x01, 0x3B);
3649 /* threshold low default 04h */
3650 xgifb_reg_and_or(pVBInfo->Part1Port, 0x02, ~(0x3F), 0x04);
3653 static void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
3654 struct xgi_hw_device_info *HwDeviceExtension,
3655 unsigned short RefreshRateTableIndex,
3656 struct vb_device_info *pVBInfo)
3658 unsigned short tempcx = 0, CRT1Index = 0, resinfo = 0;
3660 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
3661 CRT1Index &= IndexMask;
3662 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
3664 XGI_SetCRT2Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
3665 HwDeviceExtension, pVBInfo);
3666 XGI_SetCRT2FIFO(pVBInfo);
3668 for (tempcx = 4; tempcx < 7; tempcx++)
3669 xgifb_reg_set(pVBInfo->Part1Port, tempcx, 0x0);
3671 xgifb_reg_set(pVBInfo->Part1Port, 0x50, 0x00);
3672 xgifb_reg_set(pVBInfo->Part1Port, 0x02, 0x44); /* temp 0206 */
3675 static void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
3676 struct xgi_hw_device_info *HwDeviceExtension,
3677 unsigned short RefreshRateTableIndex,
3678 struct vb_device_info *pVBInfo)
3680 unsigned short temp = 0, tempax = 0, tempbx = 0, tempcx = 0,
3681 pushbx = 0, CRT1Index = 0, modeflag, resinfo = 0;
3683 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
3684 CRT1Index &= IndexMask;
3685 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
3686 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3688 /* bainy change table name */
3689 if (modeflag & HalfDCLK) {
3690 /* BTVGA2HT 0x08,0x09 */
3691 temp = (pVBInfo->VGAHT / 2 - 1) & 0x0FF;
3692 xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp);
3693 temp = (((pVBInfo->VGAHT / 2 - 1) & 0xFF00) >> 8) << 4;
3694 xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp);
3695 /* BTVGA2HDEE 0x0A,0x0C */
3696 temp = (pVBInfo->VGAHDE / 2 + 16) & 0x0FF;
3697 xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp);
3698 tempcx = ((pVBInfo->VGAHT - pVBInfo->VGAHDE) / 2) >> 2;
3699 pushbx = pVBInfo->VGAHDE / 2 + 16;
3700 tempcx = tempcx >> 1;
3701 tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */
3704 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
3705 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4];
3706 tempbx |= ((pVBInfo->
3707 XGINEWUB_CRT1Table[CRT1Index].CR[14] &
3709 tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */
3710 tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5];
3712 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[15];
3713 temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */
3714 tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */
3720 if (tempcx > (pVBInfo->VGAHT / 2))
3721 tempcx = pVBInfo->VGAHT / 2;
3723 temp = tempbx & 0x00FF;
3725 xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp);
3727 temp = (pVBInfo->VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */
3728 xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp);
3729 temp = (((pVBInfo->VGAHT - 1) & 0xFF00) >> 8) << 4;
3730 xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp);
3731 /* BTVGA2HDEE 0x0A,0x0C */
3732 temp = (pVBInfo->VGAHDE + 16) & 0x0FF;
3733 xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp);
3734 tempcx = (pVBInfo->VGAHT - pVBInfo->VGAHDE) >> 2; /* cx */
3735 pushbx = pVBInfo->VGAHDE + 16;
3736 tempcx = tempcx >> 1;
3737 tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */
3740 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
3741 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[3];
3742 tempbx |= ((pVBInfo->
3743 XGINEWUB_CRT1Table[CRT1Index].CR[5] &
3745 tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */
3746 tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4];
3748 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[6];
3749 temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */
3750 tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */
3755 if (tempcx > pVBInfo->VGAHT)
3756 tempcx = pVBInfo->VGAHT;
3758 temp = tempbx & 0x00FF;
3759 xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp);
3762 tempax = (tempax & 0x00FF) | (tempbx & 0xFF00);
3764 tempbx = (tempbx & 0x00FF) | ((tempbx & 0xFF00) << 4);
3765 tempax |= (tempbx & 0xFF00);
3766 temp = (tempax & 0xFF00) >> 8;
3767 xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp);
3768 temp = tempcx & 0x00FF;
3769 xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp);
3770 tempcx = (pVBInfo->VGAVT - 1);
3771 temp = tempcx & 0x00FF;
3773 xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp);
3774 tempbx = pVBInfo->VGAVDE - 1;
3775 temp = tempbx & 0x00FF;
3776 xgifb_reg_set(pVBInfo->Part1Port, 0x0F, temp);
3777 temp = ((tempbx & 0xFF00) << 3) >> 8;
3778 temp |= ((tempcx & 0xFF00) >> 8);
3779 xgifb_reg_set(pVBInfo->Part1Port, 0x12, temp);
3781 tempax = pVBInfo->VGAVDE;
3782 tempbx = pVBInfo->VGAVDE;
3783 tempcx = pVBInfo->VGAVT;
3784 /* BTVGA2VRS 0x10,0x11 */
3785 tempbx = (pVBInfo->VGAVT + pVBInfo->VGAVDE) >> 1;
3786 /* BTVGA2VRE 0x11 */
3787 tempcx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) >> 4) + tempbx + 1;
3789 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
3790 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[10];
3791 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9];
3799 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14];
3804 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[11];
3805 tempcx = (tempcx & 0xFF00) | (temp & 0x00FF);
3808 temp = tempbx & 0x00FF;
3809 xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp);
3810 temp = ((tempbx & 0xFF00) >> 8) << 4;
3811 temp = ((tempcx & 0x000F) | (temp));
3812 xgifb_reg_set(pVBInfo->Part1Port, 0x11, temp);
3815 if (modeflag & DoubleScanMode)
3818 if (modeflag & HalfDCLK)
3821 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2C, ~0x0C0, tempax);
3824 static unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo)
3826 unsigned long tempax, tempbx;
3828 tempbx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) * pVBInfo->RVBHCMAX)
3830 tempax = (pVBInfo->VT - pVBInfo->VDE) * pVBInfo->RVBHCFACT;
3831 tempax = (tempax * pVBInfo->HT) / tempbx;
3833 return (unsigned short) tempax;
3836 static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
3837 struct xgi_hw_device_info *HwDeviceExtension,
3838 unsigned short RefreshRateTableIndex,
3839 struct vb_device_info *pVBInfo)
3841 unsigned short push1, push2, tempax, tempbx = 0, tempcx, temp, resinfo,
3842 modeflag, CRT1Index;
3844 /* si+Ext_ResInfo */
3845 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3846 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
3847 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
3848 CRT1Index &= IndexMask;
3850 if (!(pVBInfo->VBInfo & SetInSlaveMode))
3853 temp = 0xFF; /* set MAX HT */
3854 xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp);
3857 if (pVBInfo->VBType & (VB_SIS301LV | VB_SIS302LV | VB_XGI301C))
3858 modeflag |= Charx8Dot;
3860 tempax = pVBInfo->VGAHDE; /* 0x04 Horizontal Display End */
3862 if (modeflag & HalfDCLK)
3863 tempax = tempax >> 1;
3865 tempax = (tempax / tempcx) - 1;
3866 tempbx |= ((tempax & 0x00FF) << 8);
3867 temp = tempax & 0x00FF;
3868 xgifb_reg_set(pVBInfo->Part1Port, 0x04, temp);
3870 temp = (tempbx & 0xFF00) >> 8;
3872 if (pVBInfo->VBInfo & SetCRT2ToTV) {
3873 if (!(pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
3874 | VB_SIS302LV | VB_XGI301C)))
3877 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
3878 if (pVBInfo->VBType & VB_SIS301LV) {
3879 if (pVBInfo->VBExtInfo == VB_YPbPr1080i) {
3883 } else if (resinfo == 7) {
3889 /* 0x05 Horizontal Display Start */
3890 xgifb_reg_set(pVBInfo->Part1Port, 0x05, temp);
3891 /* 0x06 Horizontal Blank end */
3892 xgifb_reg_set(pVBInfo->Part1Port, 0x06, 0x03);
3894 if (!(pVBInfo->VBInfo & DisableCRT2Display)) { /* 030226 bainy */
3895 if (pVBInfo->VBInfo & SetCRT2ToTV)
3896 tempax = pVBInfo->VGAHT;
3898 tempax = XGI_GetVGAHT2(pVBInfo);
3901 if (tempax >= pVBInfo->VGAHT)
3902 tempax = pVBInfo->VGAHT;
3904 if (modeflag & HalfDCLK)
3905 tempax = tempax >> 1;
3907 tempax = (tempax / tempcx) - 5;
3908 tempcx = tempax; /* 20030401 0x07 horizontal Retrace Start */
3909 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
3910 temp = (tempbx & 0x00FF) - 1;
3911 if (!(modeflag & HalfDCLK)) {
3913 if (pVBInfo->TVInfo & TVSimuMode) {
3919 tempbx = (tempbx & 0xFF00) >> 8;
3920 tempcx = (tempcx + tempbx) >> 1;
3921 temp = (tempcx & 0x00FF) + 2;
3923 if (pVBInfo->VBInfo & SetCRT2ToTV) {
3925 if (!(modeflag & HalfDCLK)) {
3926 if ((modeflag & Charx8Dot)) {
3928 if (pVBInfo->VGAHDE >= 800)
3932 } else if (!(modeflag & HalfDCLK)) {
3934 if (pVBInfo->LCDResInfo != Panel_1280x960 &&
3935 pVBInfo->VGAHDE >= 800) {
3937 if (pVBInfo->VGAHDE >= 1280 &&
3938 pVBInfo->LCDResInfo != Panel_1280x960 &&
3939 (pVBInfo->LCDInfo & LCDNonExpanding))
3945 /* 0x07 Horizontal Retrace Start */
3946 xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp);
3947 /* 0x08 Horizontal Retrace End */
3948 xgifb_reg_set(pVBInfo->Part1Port, 0x08, 0);
3950 if (pVBInfo->VBInfo & SetCRT2ToTV) {
3951 if (pVBInfo->TVInfo & TVSimuMode) {
3952 if (ModeNo == 0x50) {
3953 if (pVBInfo->TVInfo & SetNTSCTV) {
3954 xgifb_reg_set(pVBInfo->Part1Port,
3956 xgifb_reg_set(pVBInfo->Part1Port,
3959 xgifb_reg_set(pVBInfo->Part1Port,
3961 xgifb_reg_set(pVBInfo->Part1Port,
3968 xgifb_reg_set(pVBInfo->Part1Port, 0x18, 0x03); /* 0x18 SR0B */
3969 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0xF0, 0x00);
3970 xgifb_reg_set(pVBInfo->Part1Port, 0x09, 0xFF); /* 0x09 Set Max VT */
3972 tempbx = pVBInfo->VGAVT;
3975 tempbx = pVBInfo->VGAVDE; /* 0x0E Virtical Display End */
3990 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
3991 if (pVBInfo->LCDResInfo == Panel_1024x768) {
3992 if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
4001 temp = tempbx & 0x00FF;
4003 temp = tempbx & 0x00FF;
4004 /* 0x10 vertical Blank Start */
4005 xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp);
4008 temp = tempbx & 0x00FF;
4009 xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp);
4011 if (tempbx & 0x0100)
4016 if (modeflag & DoubleScanMode)
4019 if (tempbx & 0x0200)
4022 temp = (tempax & 0xFF00) >> 8;
4023 xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp);
4025 if (tempbx & 0x0400)
4028 /* 0x11 Vertival Blank End */
4029 xgifb_reg_set(pVBInfo->Part1Port, 0x11, 0x00);
4032 tempax -= tempbx; /* 0x0C Vertical Retrace Start */
4033 tempax = tempax >> 2;
4034 push1 = tempax; /* push ax */
4036 if (resinfo != 0x09) {
4037 tempax = tempax << 1;
4041 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
4042 if ((pVBInfo->VBType & VB_SIS301LV) &&
4043 !(pVBInfo->TVInfo & TVSetHiVision)) {
4044 if ((pVBInfo->TVInfo & TVSimuMode) &&
4045 (pVBInfo->TVInfo & TVSetPAL)) {
4046 if (!(pVBInfo->VBType & VB_SIS301LV) ||
4057 if (pVBInfo->TVInfo & TVSimuMode) {
4058 if (pVBInfo->TVInfo & TVSetPAL) {
4059 if (pVBInfo->VBType & VB_SIS301LV) {
4060 if (!(pVBInfo->TVInfo &
4072 tempax = tempax >> 2;
4075 push1 = tempax; /* push ax */
4077 if ((pVBInfo->TVInfo & TVSetPAL)) {
4078 if (tempbx <= 513) {
4084 temp = tempbx & 0x00FF;
4085 xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp);
4087 temp = tempbx & 0x00FF;
4088 xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp);
4090 if (tempbx & 0x0100)
4093 if (tempbx & 0x0200)
4094 xgifb_reg_and_or(pVBInfo->Part1Port, 0x0B, 0x0FF, 0x20);
4098 if (tempbx & 0x0100)
4101 if (tempbx & 0x0200)
4104 if (tempbx & 0x0400)
4107 tempbx = push1; /* pop ax */
4108 temp = tempbx & 0x00FF;
4110 /* 0x0D vertical Retrace End */
4111 xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp);
4113 if (tempbx & 0x0010)
4116 temp = tempcx & 0x00FF;
4117 xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); /* 0x0A CR07 */
4118 temp = (tempcx & 0x0FF00) >> 8;
4119 xgifb_reg_set(pVBInfo->Part1Port, 0x17, temp); /* 0x17 SR0A */
4121 temp = (tempax & 0xFF00) >> 8;
4123 temp = (temp >> 1) & 0x09;
4125 if (pVBInfo->VBType & (VB_SIS301LV | VB_SIS302LV | VB_XGI301C))
4128 xgifb_reg_set(pVBInfo->Part1Port, 0x16, temp); /* 0x16 SR01 */
4129 xgifb_reg_set(pVBInfo->Part1Port, 0x0F, 0); /* 0x0F CR14 */
4130 xgifb_reg_set(pVBInfo->Part1Port, 0x12, 0); /* 0x12 CR17 */
4132 if (pVBInfo->LCDInfo & LCDRGB18Bit)
4137 xgifb_reg_set(pVBInfo->Part1Port, 0x1A, temp); /* 0x1A SR0E */
4142 static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex,
4143 unsigned short RefreshRateTableIndex,
4144 struct xgi_hw_device_info *HwDeviceExtension,
4145 struct vb_device_info *pVBInfo)
4147 unsigned short i, j, tempax, tempbx, tempcx, temp, push1, push2,
4148 modeflag, resinfo, crt2crtc;
4149 unsigned char *TimingPoint;
4151 unsigned long longtemp, tempeax, tempebx, temp2, tempecx;
4153 /* si+Ext_ResInfo */
4154 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4155 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4156 crt2crtc = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
4160 if (!(pVBInfo->VBInfo & SetCRT2ToAVIDEO))
4163 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
4166 if (pVBInfo->VBInfo & SetCRT2ToSCART)
4169 if (!(pVBInfo->TVInfo & TVSetPAL))
4172 if (pVBInfo->VBInfo & SetCRT2ToHiVision)
4175 if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p))
4178 tempax = (tempax & 0xff00) >> 8;
4180 xgifb_reg_set(pVBInfo->Part2Port, 0x0, tempax);
4181 TimingPoint = pVBInfo->NTSCTiming;
4183 if (pVBInfo->TVInfo & TVSetPAL)
4184 TimingPoint = pVBInfo->PALTiming;
4186 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
4187 TimingPoint = pVBInfo->HiTVExtTiming;
4189 if (pVBInfo->VBInfo & SetInSlaveMode)
4190 TimingPoint = pVBInfo->HiTVSt2Timing;
4192 if (pVBInfo->SetFlag & TVSimuMode)
4193 TimingPoint = pVBInfo->HiTVSt1Timing;
4195 if (!(modeflag & Charx8Dot))
4196 TimingPoint = pVBInfo->HiTVTextTiming;
4199 if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
4200 if (pVBInfo->TVInfo & TVSetYPbPr525i)
4201 TimingPoint = pVBInfo->YPbPr525iTiming;
4203 if (pVBInfo->TVInfo & TVSetYPbPr525p)
4204 TimingPoint = pVBInfo->YPbPr525pTiming;
4206 if (pVBInfo->TVInfo & TVSetYPbPr750p)
4207 TimingPoint = pVBInfo->YPbPr750pTiming;
4210 for (i = 0x01, j = 0; i <= 0x2D; i++, j++)
4211 xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]);
4213 for (i = 0x39; i <= 0x45; i++, j++)
4215 xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]);
4217 if (pVBInfo->VBInfo & SetCRT2ToTV)
4218 xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, 0x00);
4220 temp = pVBInfo->NewFlickerMode;
4222 xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xFF, temp);
4224 if (pVBInfo->VBInfo & SetCRT2ToHiVision)
4227 if (pVBInfo->TVInfo & TVSetPAL)
4232 if (pVBInfo->VDE <= tempax) {
4233 tempax -= pVBInfo->VDE;
4234 tempax = tempax >> 2;
4235 tempax = (tempax & 0x00FF) | ((tempax & 0x00FF) << 8);
4237 temp = (tempax & 0xFF00) >> 8;
4238 temp += (unsigned short) TimingPoint[0];
4240 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
4241 | VB_SIS302LV | VB_XGI301C)) {
4242 if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO
4243 | SetCRT2ToSVIDEO | SetCRT2ToSCART
4244 | SetCRT2ToYPbPr525750)) {
4245 tempcx = pVBInfo->VGAHDE;
4246 if (tempcx >= 1024) {
4247 temp = 0x17; /* NTSC */
4248 if (pVBInfo->TVInfo & TVSetPAL)
4249 temp = 0x19; /* PAL */
4254 xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp);
4256 temp = (tempax & 0xFF00) >> 8;
4257 temp += TimingPoint[1];
4259 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
4260 | VB_SIS302LV | VB_XGI301C)) {
4261 if ((pVBInfo->VBInfo & (SetCRT2ToAVIDEO
4262 | SetCRT2ToSVIDEO | SetCRT2ToSCART
4263 | SetCRT2ToYPbPr525750))) {
4264 tempcx = pVBInfo->VGAHDE;
4265 if (tempcx >= 1024) {
4266 temp = 0x1D; /* NTSC */
4267 if (pVBInfo->TVInfo & TVSetPAL)
4268 temp = 0x52; /* PAL */
4272 xgifb_reg_set(pVBInfo->Part2Port, 0x02, temp);
4276 tempcx = pVBInfo->HT;
4278 if (XGI_IsLCDDualLink(pVBInfo))
4279 tempcx = tempcx >> 1;
4282 temp = tempcx & 0x00FF;
4283 xgifb_reg_set(pVBInfo->Part2Port, 0x1B, temp);
4285 temp = (tempcx & 0xFF00) >> 8;
4286 xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F, temp);
4288 tempcx = pVBInfo->HT >> 1;
4289 push1 = tempcx; /* push cx */
4292 if (pVBInfo->VBInfo & SetCRT2ToHiVision)
4295 temp = tempcx & 0x00FF;
4297 xgifb_reg_and_or(pVBInfo->Part2Port, 0x22, 0x0F, temp);
4299 tempbx = TimingPoint[j] | ((TimingPoint[j + 1]) << 8);
4302 temp = tempbx & 0x00FF;
4303 xgifb_reg_set(pVBInfo->Part2Port, 0x24, temp);
4304 temp = (tempbx & 0xFF00) >> 8;
4306 xgifb_reg_and_or(pVBInfo->Part2Port, 0x25, 0x0F, temp);
4309 tempbx = tempbx + 8;
4310 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
4311 tempbx = tempbx - 4;
4315 temp = (tempbx & 0x00FF) << 4;
4316 xgifb_reg_and_or(pVBInfo->Part2Port, 0x29, 0x0F, temp);
4319 tempcx += (TimingPoint[j] | ((TimingPoint[j + 1]) << 8));
4320 temp = tempcx & 0x00FF;
4321 xgifb_reg_set(pVBInfo->Part2Port, 0x27, temp);
4322 temp = ((tempcx & 0xFF00) >> 8) << 4;
4323 xgifb_reg_and_or(pVBInfo->Part2Port, 0x28, 0x0F, temp);
4326 if (pVBInfo->VBInfo & SetCRT2ToHiVision)
4329 temp = tempcx & 0xFF;
4331 xgifb_reg_and_or(pVBInfo->Part2Port, 0x2A, 0x0F, temp);
4333 tempcx = push1; /* pop cx */
4335 temp = TimingPoint[j] | ((TimingPoint[j + 1]) << 8);
4337 temp = tempcx & 0x00FF;
4339 xgifb_reg_and_or(pVBInfo->Part2Port, 0x2D, 0x0F, temp);
4343 if (!(pVBInfo->VBInfo & SetCRT2ToTV)) {
4344 tempax = XGI_GetVGAHT2(pVBInfo);
4345 tempcx = tempax - 1;
4347 temp = tempcx & 0x00FF;
4348 xgifb_reg_set(pVBInfo->Part2Port, 0x2E, temp);
4350 tempbx = pVBInfo->VDE;
4352 if (pVBInfo->VGAVDE == 360)
4354 if (pVBInfo->VGAVDE == 375)
4356 if (pVBInfo->VGAVDE == 405)
4359 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4360 if (pVBInfo->VBType &
4361 (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) {
4362 if (!(pVBInfo->TVInfo &
4363 (TVSetYPbPr525p | TVSetYPbPr750p)))
4364 tempbx = tempbx >> 1;
4366 tempbx = tempbx >> 1;
4370 temp = tempbx & 0x00FF;
4372 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
4373 if (pVBInfo->VBType & VB_SIS301LV) {
4374 if (pVBInfo->TVInfo & TVSetHiVision) {
4375 if (pVBInfo->VBInfo & SetInSlaveMode) {
4381 if (pVBInfo->VBInfo & SetInSlaveMode) {
4388 xgifb_reg_set(pVBInfo->Part2Port, 0x2F, temp);
4390 temp = (tempcx & 0xFF00) >> 8;
4391 temp |= ((tempbx & 0xFF00) >> 8) << 6;
4393 if (!(pVBInfo->VBInfo & SetCRT2ToHiVision)) {
4394 if (pVBInfo->VBType & VB_SIS301LV) {
4395 if (pVBInfo->TVInfo & TVSetHiVision) {
4398 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
4403 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
4408 xgifb_reg_set(pVBInfo->Part2Port, 0x30, temp);
4410 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
4411 | VB_SIS302LV | VB_XGI301C)) { /* TV gatingno */
4412 tempbx = pVBInfo->VDE;
4413 tempcx = tempbx - 2;
4415 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4416 if (!(pVBInfo->TVInfo & (TVSetYPbPr525p
4418 tempbx = tempbx >> 1;
4421 if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) {
4423 if (tempcx & 0x0400)
4426 if (tempbx & 0x0400)
4429 xgifb_reg_set(pVBInfo->Part4Port, 0x10, temp);
4432 temp = (((tempbx - 3) & 0x0300) >> 8) << 5;
4433 xgifb_reg_set(pVBInfo->Part2Port, 0x46, temp);
4434 temp = (tempbx - 3) & 0x00FF;
4435 xgifb_reg_set(pVBInfo->Part2Port, 0x47, temp);
4438 tempbx = tempbx & 0x00FF;
4440 if (!(modeflag & HalfDCLK)) {
4441 tempcx = pVBInfo->VGAHDE;
4442 if (tempcx >= pVBInfo->HDE) {
4450 if (pVBInfo->VBInfo & SetCRT2ToTV) { /*301b*/
4451 if (pVBInfo->VGAHDE >= 1024) {
4453 if (pVBInfo->VGAHDE >= 1280) {
4455 tempbx = tempbx & 0xDFFF;
4460 if (!(tempbx & 0x2000)) {
4461 if (modeflag & HalfDCLK)
4462 tempcx = (tempcx & 0xFF00) | ((tempcx & 0x00FF) << 1);
4465 tempeax = pVBInfo->VGAHDE;
4466 tempebx = (tempcx & 0xFF00) >> 8;
4467 longtemp = tempeax * tempebx;
4468 tempecx = tempcx & 0x00FF;
4469 longtemp = longtemp / tempecx;
4474 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
4475 | VB_SIS302LV | VB_XGI301C)) {
4476 tempecx = tempecx * 8;
4479 longtemp = longtemp * tempecx;
4480 tempecx = pVBInfo->HDE;
4481 temp2 = longtemp % tempecx;
4482 tempeax = longtemp / tempecx;
4486 tempax = (unsigned short) tempeax;
4489 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
4490 | VB_SIS302LV | VB_XGI301C)) {
4491 tempcx = ((tempax & 0xFF00) >> 5) >> 8;
4496 tempbx = (unsigned short) (((tempeax & 0x0000FF00) & 0x1F00)
4497 | (tempbx & 0x00FF));
4498 tempax = (unsigned short) (((tempeax & 0x000000FF) << 8)
4499 | (tempax & 0x00FF));
4500 temp = (tempax & 0xFF00) >> 8;
4502 temp = (tempax & 0x00FF) >> 8;
4505 xgifb_reg_set(pVBInfo->Part2Port, 0x44, temp);
4506 temp = (tempbx & 0xFF00) >> 8;
4507 xgifb_reg_and_or(pVBInfo->Part2Port, 0x45, ~0x03F, temp);
4508 temp = tempcx & 0x00FF;
4510 if (tempbx & 0x2000)
4513 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
4516 xgifb_reg_and_or(pVBInfo->Part2Port, 0x46, ~0x1F, temp);
4517 if (pVBInfo->TVInfo & TVSetPAL) {
4525 temp = tempbx & 0x00FF;
4526 xgifb_reg_set(pVBInfo->Part2Port, 0x4b, temp);
4527 temp = tempcx & 0x00FF;
4528 xgifb_reg_set(pVBInfo->Part2Port, 0x4c, temp);
4530 temp = ((tempcx & 0xFF00) >> 8) & 0x03;
4532 temp |= ((tempbx & 0xFF00) >> 8) & 0x03;
4534 if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
4537 if (pVBInfo->TVInfo & TVSetYPbPr525p)
4540 if (pVBInfo->TVInfo & TVSetYPbPr750p)
4544 xgifb_reg_set(pVBInfo->Part2Port, 0x4d, temp);
4545 temp = xgifb_reg_get(pVBInfo->Part2Port, 0x43); /* 301b change */
4546 xgifb_reg_set(pVBInfo->Part2Port, 0x43, (unsigned short) (temp - 3));
4548 if (!(pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p))) {
4549 if (pVBInfo->TVInfo & NTSC1024x768) {
4550 TimingPoint = XGI_NTSC1024AdjTime;
4551 for (i = 0x1c, j = 0; i <= 0x30; i++, j++) {
4552 xgifb_reg_set(pVBInfo->Part2Port, i,
4555 xgifb_reg_set(pVBInfo->Part2Port, 0x43, 0x72);
4559 /* Modify for 301C PALM Support */
4560 if (pVBInfo->VBType & VB_XGI301C) {
4561 if (pVBInfo->TVInfo & TVSetPALM)
4562 xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x08,
4563 0x08); /* PALM Mode */
4566 if (pVBInfo->TVInfo & TVSetPALM) {
4567 tempax = (unsigned char) xgifb_reg_get(pVBInfo->Part2Port,
4570 xgifb_reg_and(pVBInfo->Part2Port, 0x01, tempax);
4572 xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xEF);
4575 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
4576 if (!(pVBInfo->VBInfo & SetInSlaveMode))
4577 xgifb_reg_set(pVBInfo->Part2Port, 0x0B, 0x00);
4580 if (pVBInfo->VBInfo & SetCRT2ToTV)
4584 static void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
4585 struct xgi_hw_device_info *HwDeviceExtension,
4586 unsigned short RefreshRateTableIndex,
4587 struct vb_device_info *pVBInfo)
4589 unsigned short push1, push2, pushbx, tempax, tempbx, tempcx, temp,
4590 tempah, tempbh, tempch, resinfo, modeflag, CRT1Index;
4592 struct XGI_LCDDesStruct *LCDBDesPtr = NULL;
4594 /* si+Ext_ResInfo */
4595 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4596 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4597 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4598 CRT1Index &= IndexMask;
4600 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
4603 tempbx = pVBInfo->HDE; /* RHACTE=HDE-1 */
4605 if (XGI_IsLCDDualLink(pVBInfo))
4606 tempbx = tempbx >> 1;
4609 temp = tempbx & 0x00FF;
4610 xgifb_reg_set(pVBInfo->Part2Port, 0x2C, temp);
4611 temp = (tempbx & 0xFF00) >> 8;
4613 xgifb_reg_and_or(pVBInfo->Part2Port, 0x2B, 0x0F, temp);
4616 xgifb_reg_set(pVBInfo->Part2Port, 0x0B, temp);
4617 tempbx = pVBInfo->VDE; /* RTVACTEO=(VDE-1)&0xFF */
4620 temp = tempbx & 0x00FF;
4621 xgifb_reg_set(pVBInfo->Part2Port, 0x03, temp);
4622 temp = ((tempbx & 0xFF00) >> 8) & 0x07;
4623 xgifb_reg_and_or(pVBInfo->Part2Port, 0x0C, ~0x07, temp);
4625 tempcx = pVBInfo->VT - 1;
4627 temp = tempcx & 0x00FF; /* RVTVT=VT-1 */
4628 xgifb_reg_set(pVBInfo->Part2Port, 0x19, temp);
4629 temp = (tempcx & 0xFF00) >> 8;
4631 xgifb_reg_set(pVBInfo->Part2Port, 0x1A, temp);
4632 xgifb_reg_and_or(pVBInfo->Part2Port, 0x09, 0xF0, 0x00);
4633 xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xF0, 0x00);
4634 xgifb_reg_and_or(pVBInfo->Part2Port, 0x17, 0xFB, 0x00);
4635 xgifb_reg_and_or(pVBInfo->Part2Port, 0x18, 0xDF, 0x00);
4637 /* Customized LCDB Des no add */
4639 LCDBDesPtr = (struct XGI_LCDDesStruct *) XGI_GetLcdPtr(tempbx, ModeNo,
4640 ModeIdIndex, RefreshRateTableIndex, pVBInfo);
4641 tempah = pVBInfo->LCDResInfo;
4642 tempah &= PanelResInfo;
4644 if ((tempah == Panel_1024x768) || (tempah == Panel_1024x768x75)) {
4647 } else if ((tempah == Panel_1280x1024) ||
4648 (tempah == Panel_1280x1024x75)) {
4651 } else if (tempah == Panel_1400x1050) {
4659 if (pVBInfo->LCDInfo & EnableScalingLCD) {
4660 tempbx = pVBInfo->HDE;
4661 tempcx = pVBInfo->VDE;
4665 tempax = pVBInfo->VT;
4666 pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES;
4667 pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS;
4668 pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES;
4669 pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS;
4670 tempbx = pVBInfo->LCDVDES;
4673 if (tempcx >= tempax)
4674 tempcx -= tempax; /* lcdvdes */
4676 temp = tempbx & 0x00FF; /* RVEQ1EQ=lcdvdes */
4677 xgifb_reg_set(pVBInfo->Part2Port, 0x05, temp);
4678 temp = tempcx & 0x00FF;
4679 xgifb_reg_set(pVBInfo->Part2Port, 0x06, temp);
4680 tempch = ((tempcx & 0xFF00) >> 8) & 0x07;
4681 tempbh = ((tempbx & 0xFF00) >> 8) & 0x07;
4683 tempah = tempah << 3;
4685 xgifb_reg_set(pVBInfo->Part2Port, 0x02, tempah);
4688 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
4690 tempax = pVBInfo->VT;
4691 tempbx = pVBInfo->LCDVRS;
4694 if (tempcx >= tempax)
4697 temp = tempbx & 0x00FF; /* RTVACTEE=lcdvrs */
4698 xgifb_reg_set(pVBInfo->Part2Port, 0x04, temp);
4699 temp = (tempbx & 0xFF00) >> 8;
4701 temp |= (tempcx & 0x000F);
4702 xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp);
4704 tempax = pVBInfo->HT;
4705 tempbx = pVBInfo->LCDHDES;
4708 if (XGI_IsLCDDualLink(pVBInfo)) {
4709 tempax = tempax >> 1;
4710 tempbx = tempbx >> 1;
4711 tempcx = tempcx >> 1;
4714 if (pVBInfo->VBType & VB_SIS302LV)
4717 if (pVBInfo->VBType & VB_XGI301C) /* tap4 */
4722 if (tempcx >= tempax)
4725 temp = tempbx & 0x00FF;
4726 xgifb_reg_set(pVBInfo->Part2Port, 0x1F, temp); /* RHBLKE=lcdhdes */
4727 temp = ((tempbx & 0xFF00) >> 8) << 4;
4728 xgifb_reg_set(pVBInfo->Part2Port, 0x20, temp);
4729 temp = tempcx & 0x00FF;
4730 xgifb_reg_set(pVBInfo->Part2Port, 0x23, temp); /* RHEQPLE=lcdhdee */
4731 temp = (tempcx & 0xFF00) >> 8;
4732 xgifb_reg_set(pVBInfo->Part2Port, 0x25, temp);
4734 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
4736 tempax = pVBInfo->HT;
4737 tempbx = pVBInfo->LCDHRS;
4738 if (XGI_IsLCDDualLink(pVBInfo)) {
4739 tempax = tempax >> 1;
4740 tempbx = tempbx >> 1;
4741 tempcx = tempcx >> 1;
4744 if (pVBInfo->VBType & VB_SIS302LV)
4749 if (tempcx >= tempax)
4752 temp = tempbx & 0x00FF; /* RHBURSTS=lcdhrs */
4753 xgifb_reg_set(pVBInfo->Part2Port, 0x1C, temp);
4755 temp = (tempbx & 0xFF00) >> 8;
4757 xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F0, temp);
4758 temp = tempcx & 0x00FF; /* RHSYEXP2S=lcdhre */
4759 xgifb_reg_set(pVBInfo->Part2Port, 0x21, temp);
4761 if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
4762 if (pVBInfo->VGAVDE == 525) {
4763 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B
4764 | VB_SIS301LV | VB_SIS302LV
4770 xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp);
4771 xgifb_reg_set(pVBInfo->Part2Port, 0x30, 0xB3);
4774 if (pVBInfo->VGAVDE == 420) {
4775 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B
4776 | VB_SIS301LV | VB_SIS302LV
4781 xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp);
4786 /* --------------------------------------------------------------------- */
4787 /* Function : XGI_GetTap4Ptr */
4789 /* Output : di -> Tap4 Reg. Setting Pointer */
4791 /* --------------------------------------------------------------------- */
4792 static struct XGI301C_Tap4TimingStruct *XGI_GetTap4Ptr(unsigned short tempcx,
4793 struct vb_device_info *pVBInfo)
4795 unsigned short tempax, tempbx, i;
4797 struct XGI301C_Tap4TimingStruct *Tap4TimingPtr;
4800 tempax = pVBInfo->VGAHDE;
4801 tempbx = pVBInfo->HDE;
4803 tempax = pVBInfo->VGAVDE;
4804 tempbx = pVBInfo->VDE;
4807 if (tempax <= tempbx)
4808 return &xgifb_tap4_timing[0];
4810 Tap4TimingPtr = xgifb_ntsc_525_tap4_timing; /* NTSC */
4812 if (pVBInfo->TVInfo & TVSetPAL)
4813 Tap4TimingPtr = PALTap4Timing;
4815 if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
4816 if ((pVBInfo->TVInfo & TVSetYPbPr525i) ||
4817 (pVBInfo->TVInfo & TVSetYPbPr525p))
4818 Tap4TimingPtr = xgifb_ntsc_525_tap4_timing;
4819 if (pVBInfo->TVInfo & TVSetYPbPr750p)
4820 Tap4TimingPtr = YPbPr750pTap4Timing;
4823 if (pVBInfo->VBInfo & SetCRT2ToHiVision)
4824 Tap4TimingPtr = xgifb_tap4_timing;
4827 while (Tap4TimingPtr[i].DE != 0xFFFF) {
4828 if (Tap4TimingPtr[i].DE == tempax)
4832 return &Tap4TimingPtr[i];
4835 static void XGI_SetTap4Regs(struct vb_device_info *pVBInfo)
4837 unsigned short i, j;
4839 struct XGI301C_Tap4TimingStruct *Tap4TimingPtr;
4841 if (!(pVBInfo->VBType & VB_XGI301C))
4844 Tap4TimingPtr = XGI_GetTap4Ptr(0, pVBInfo); /* Set Horizontal Scaling */
4845 for (i = 0x80, j = 0; i <= 0xBF; i++, j++)
4846 xgifb_reg_set(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]);
4848 if ((pVBInfo->VBInfo & SetCRT2ToTV) &&
4849 (!(pVBInfo->VBInfo & SetCRT2ToHiVision))) {
4850 /* Set Vertical Scaling */
4851 Tap4TimingPtr = XGI_GetTap4Ptr(1, pVBInfo);
4852 for (i = 0xC0, j = 0; i < 0xFF; i++, j++)
4853 xgifb_reg_set(pVBInfo->Part2Port,
4855 Tap4TimingPtr->Reg[j]);
4858 if ((pVBInfo->VBInfo & SetCRT2ToTV) &&
4859 (!(pVBInfo->VBInfo & SetCRT2ToHiVision)))
4860 /* Enable V.Scaling */
4861 xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x04);
4863 /* Enable H.Scaling */
4864 xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x10);
4867 static void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex,
4868 struct vb_device_info *pVBInfo)
4871 unsigned char *tempdi;
4872 unsigned short modeflag;
4874 /* si+Ext_ResInfo */
4875 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4877 xgifb_reg_set(pVBInfo->Part3Port, 0x00, 0x00);
4878 if (pVBInfo->TVInfo & TVSetPAL) {
4879 xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA);
4880 xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8);
4882 xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xF5);
4883 xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xB7);
4886 if (!(pVBInfo->VBInfo & SetCRT2ToTV))
4889 if (pVBInfo->TVInfo & TVSetPALM) {
4890 xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA);
4891 xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8);
4892 xgifb_reg_set(pVBInfo->Part3Port, 0x3D, 0xA8);
4895 if ((pVBInfo->VBInfo & SetCRT2ToHiVision) || (pVBInfo->VBInfo
4896 & SetCRT2ToYPbPr525750)) {
4897 if (pVBInfo->TVInfo & TVSetYPbPr525i)
4900 tempdi = pVBInfo->HiTVGroup3Data;
4901 if (pVBInfo->SetFlag & TVSimuMode) {
4902 tempdi = pVBInfo->HiTVGroup3Simu;
4903 if (!(modeflag & Charx8Dot))
4904 tempdi = pVBInfo->HiTVGroup3Text;
4907 if (pVBInfo->TVInfo & TVSetYPbPr525p)
4908 tempdi = pVBInfo->Ren525pGroup3;
4910 if (pVBInfo->TVInfo & TVSetYPbPr750p)
4911 tempdi = pVBInfo->Ren750pGroup3;
4913 for (i = 0; i <= 0x3E; i++)
4914 xgifb_reg_set(pVBInfo->Part3Port, i, tempdi[i]);
4916 if (pVBInfo->VBType & VB_XGI301C) { /* Marcovision */
4917 if (pVBInfo->TVInfo & TVSetYPbPr525p)
4918 xgifb_reg_set(pVBInfo->Part3Port, 0x28, 0x3f);
4922 } /* {end of XGI_SetGroup3} */
4924 static void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex,
4925 unsigned short RefreshRateTableIndex,
4926 struct xgi_hw_device_info *HwDeviceExtension,
4927 struct vb_device_info *pVBInfo)
4929 unsigned short tempax, tempcx, tempbx, modeflag, temp, temp2;
4931 unsigned long tempebx, tempeax, templong;
4933 /* si+Ext_ResInfo */
4934 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4935 temp = pVBInfo->RVBHCFACT;
4936 xgifb_reg_set(pVBInfo->Part4Port, 0x13, temp);
4938 tempbx = pVBInfo->RVBHCMAX;
4939 temp = tempbx & 0x00FF;
4940 xgifb_reg_set(pVBInfo->Part4Port, 0x14, temp);
4941 temp2 = ((tempbx & 0xFF00) >> 8) << 7;
4942 tempcx = pVBInfo->VGAHT - 1;
4943 temp = tempcx & 0x00FF;
4944 xgifb_reg_set(pVBInfo->Part4Port, 0x16, temp);
4946 temp = ((tempcx & 0xFF00) >> 8) << 3;
4949 tempcx = pVBInfo->VGAVT - 1;
4950 if (!(pVBInfo->VBInfo & SetCRT2ToTV))
4953 temp = tempcx & 0x00FF;
4954 xgifb_reg_set(pVBInfo->Part4Port, 0x17, temp);
4955 temp = temp2 | ((tempcx & 0xFF00) >> 8);
4956 xgifb_reg_set(pVBInfo->Part4Port, 0x15, temp);
4957 xgifb_reg_or(pVBInfo->Part4Port, 0x0D, 0x08);
4958 tempcx = pVBInfo->VBInfo;
4959 tempbx = pVBInfo->VGAHDE;
4961 if (modeflag & HalfDCLK)
4962 tempbx = tempbx >> 1;
4964 if (XGI_IsLCDDualLink(pVBInfo))
4965 tempbx = tempbx >> 1;
4967 if (tempcx & SetCRT2ToHiVision) {
4973 } else if (tempcx & SetCRT2ToTV) {
4979 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
4986 if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p)) {
4988 if (pVBInfo->VGAHDE == 1280)
4990 if (pVBInfo->VGAHDE == 1024)
4993 xgifb_reg_and_or(pVBInfo->Part4Port, 0x0E, ~0xEF, temp);
4995 tempebx = pVBInfo->VDE;
4997 if (tempcx & SetCRT2ToHiVision) {
4998 if (!(temp & 0xE000))
4999 tempbx = tempbx >> 1;
5002 tempcx = pVBInfo->RVBHRS;
5003 temp = tempcx & 0x00FF;
5004 xgifb_reg_set(pVBInfo->Part4Port, 0x18, temp);
5006 tempeax = pVBInfo->VGAVDE;
5009 if (tempeax <= tempebx) {
5010 tempcx = (tempcx & (~0x4000));
5011 tempeax = pVBInfo->VGAVDE;
5016 templong = (tempeax * 256 * 1024) % tempebx;
5017 tempeax = (tempeax * 256 * 1024) / tempebx;
5023 temp = (unsigned short) (tempebx & 0x000000FF);
5024 xgifb_reg_set(pVBInfo->Part4Port, 0x1B, temp);
5026 temp = (unsigned short) ((tempebx & 0x0000FF00) >> 8);
5027 xgifb_reg_set(pVBInfo->Part4Port, 0x1A, temp);
5028 tempbx = (unsigned short) (tempebx >> 16);
5029 temp = tempbx & 0x00FF;
5031 temp |= ((tempcx & 0xFF00) >> 8);
5032 xgifb_reg_set(pVBInfo->Part4Port, 0x19, temp);
5035 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
5036 | VB_SIS302LV | VB_XGI301C)) {
5038 xgifb_reg_set(pVBInfo->Part4Port, 0x1C, temp);
5039 tempax = pVBInfo->VGAHDE;
5040 if (modeflag & HalfDCLK)
5041 tempax = tempax >> 1;
5043 if (XGI_IsLCDDualLink(pVBInfo))
5044 tempax = tempax >> 1;
5046 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
5050 if (pVBInfo->VGAHDE > 800) {
5051 if (pVBInfo->VGAHDE == 1024)
5052 tempax = (tempax * 25 / 32) - 1;
5054 tempax = (tempax * 20 / 32) - 1;
5059 temp = (tempax & 0xFF00) >> 8;
5060 temp = ((temp & 0x0003) << 4);
5061 xgifb_reg_set(pVBInfo->Part4Port, 0x1E, temp);
5062 temp = (tempax & 0x00FF);
5063 xgifb_reg_set(pVBInfo->Part4Port, 0x1D, temp);
5065 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVision)) {
5066 if (pVBInfo->VGAHDE > 800)
5067 xgifb_reg_or(pVBInfo->Part4Port, 0x1E, 0x08);
5072 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5073 if (!(pVBInfo->TVInfo & (NTSC1024x768
5074 | TVSetYPbPr525p | TVSetYPbPr750p
5075 | TVSetHiVision))) {
5077 if ((pVBInfo->VBInfo & SetInSlaveMode)
5078 && (!(pVBInfo->TVInfo
5084 xgifb_reg_and_or(pVBInfo->Part4Port, 0x1F, 0x00C0, temp);
5085 tempbx = pVBInfo->HT;
5086 if (XGI_IsLCDDualLink(pVBInfo))
5087 tempbx = tempbx >> 1;
5088 tempbx = (tempbx >> 1) - 2;
5089 temp = ((tempbx & 0x0700) >> 8) << 3;
5090 xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, 0x00C0, temp);
5091 temp = tempbx & 0x00FF;
5092 xgifb_reg_set(pVBInfo->Part4Port, 0x22, temp);
5096 if (pVBInfo->ISXPDOS == 0)
5097 XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex,
5101 static void XGINew_EnableCRT2(struct vb_device_info *pVBInfo)
5103 xgifb_reg_and_or(pVBInfo->P3c4, 0x1E, 0xFF, 0x20);
5106 static void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex,
5107 struct vb_device_info *pVBInfo)
5109 unsigned short Pindex, Pdata;
5111 Pindex = pVBInfo->Part5Port;
5112 Pdata = pVBInfo->Part5Port + 1;
5113 if (pVBInfo->ModeType == ModeVGA) {
5114 if (!(pVBInfo->VBInfo & (SetInSlaveMode | LoadDACFlag
5115 | DisableCRT2Display))) {
5116 XGINew_EnableCRT2(pVBInfo);
5122 static void XGI_EnableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension,
5123 struct vb_device_info *pVBInfo)
5125 xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x40);
5128 static void XGI_DisableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension,
5129 struct vb_device_info *pVBInfo)
5132 xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x00);
5135 static unsigned char XGI_XG21CheckLVDSMode(struct xgifb_video_info *xgifb_info,
5136 unsigned short ModeNo, unsigned short ModeIdIndex,
5137 struct vb_device_info *pVBInfo)
5139 unsigned short xres, yres, colordepth, modeflag, resindex;
5141 resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
5142 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
5143 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
5144 /* si+St_ModeFlag */
5145 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
5147 if (!(modeflag & Charx8Dot)) {
5152 if ((ModeNo > 0x13) && (modeflag & HalfDCLK))
5155 if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
5158 if (xres > xgifb_info->lvds_data.LVDSHDE)
5161 if (yres > xgifb_info->lvds_data.LVDSVDE)
5164 if (xres != xgifb_info->lvds_data.LVDSHDE ||
5165 yres != xgifb_info->lvds_data.LVDSVDE) {
5166 colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo);
5173 static void xgifb_set_lvds(struct xgifb_video_info *xgifb_info,
5175 unsigned short ModeNo,
5176 unsigned short ModeIdIndex,
5177 struct vb_device_info *pVBInfo)
5179 unsigned char temp, Miscdata;
5180 unsigned short xres, yres, modeflag, resindex;
5181 unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE;
5182 unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE;
5183 unsigned short value;
5185 temp = (unsigned char) ((xgifb_info->lvds_data.LVDS_Capability &
5186 (LCDPolarity << 8)) >> 8);
5187 temp &= LCDPolarity;
5188 Miscdata = (unsigned char) inb(pVBInfo->P3cc);
5190 outb((Miscdata & 0x3F) | temp, pVBInfo->P3c2);
5192 temp = xgifb_info->lvds_data.LVDS_Capability & LCDPolarity;
5193 /* SR35[7] FP VSync polarity */
5194 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80);
5195 /* SR30[5] FP HSync polarity */
5196 xgifb_reg_and_or(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1);
5198 if (chip_id == XG27)
5199 XGI_SetXG27FPBits(pVBInfo);
5201 XGI_SetXG21FPBits(pVBInfo);
5203 resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
5204 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
5205 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
5206 /* si+St_ModeFlag */
5207 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
5209 if (!(modeflag & Charx8Dot))
5210 xres = xres * 8 / 9;
5212 LVDSHT = xgifb_info->lvds_data.LVDSHT;
5214 LVDSHBS = xres + (xgifb_info->lvds_data.LVDSHDE - xres) / 2;
5216 if (LVDSHBS > LVDSHT)
5219 LVDSHRS = LVDSHBS + xgifb_info->lvds_data.LVDSHFP;
5220 if (LVDSHRS > LVDSHT)
5223 LVDSHRE = LVDSHRS + xgifb_info->lvds_data.LVDSHSYNC;
5224 if (LVDSHRE > LVDSHT)
5227 LVDSHBE = LVDSHBS + LVDSHT - xgifb_info->lvds_data.LVDSHDE;
5229 LVDSVT = xgifb_info->lvds_data.LVDSVT;
5231 LVDSVBS = yres + (xgifb_info->lvds_data.LVDSVDE - yres) / 2;
5232 if (modeflag & DoubleScanMode)
5233 LVDSVBS += yres / 2;
5235 if (LVDSVBS > LVDSVT)
5238 LVDSVRS = LVDSVBS + xgifb_info->lvds_data.LVDSVFP;
5239 if (LVDSVRS > LVDSVT)
5242 LVDSVRE = LVDSVRS + xgifb_info->lvds_data.LVDSVSYNC;
5243 if (LVDSVRE > LVDSVT)
5246 LVDSVBE = LVDSVBS + LVDSVT - xgifb_info->lvds_data.LVDSVDE;
5248 temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
5249 xgifb_reg_set(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */
5251 if (!(modeflag & Charx8Dot))
5252 xgifb_reg_or(pVBInfo->P3c4, 0x1, 0x1);
5254 /* HT SR0B[1:0] CR00 */
5255 value = (LVDSHT >> 3) - 5;
5256 xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8);
5257 xgifb_reg_set(pVBInfo->P3d4, 0x0, (value & 0xFF));
5259 /* HBS SR0B[5:4] CR02 */
5260 value = (LVDSHBS >> 3) - 1;
5261 xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4);
5262 xgifb_reg_set(pVBInfo->P3d4, 0x2, (value & 0xFF));
5264 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
5265 value = (LVDSHBE >> 3) - 1;
5266 xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6);
5267 xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2);
5268 xgifb_reg_and_or(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F);
5270 /* HRS SR0B[7:6] CR04 */
5271 value = (LVDSHRS >> 3) + 2;
5272 xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2);
5273 xgifb_reg_set(pVBInfo->P3d4, 0x4, (value & 0xFF));
5275 /* Panel HRS SR2F[1:0] SR2E[7:0] */
5277 xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8);
5278 xgifb_reg_set(pVBInfo->P3c4, 0x2E, (value & 0xFF));
5280 /* HRE SR0C[2] CR05[4:0] */
5281 value = (LVDSHRE >> 3) + 2;
5282 xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3);
5283 xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F);
5285 /* Panel HRE SR2F[7:2] */
5287 xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2);
5289 /* VT SR0A[0] CR07[5][0] CR06 */
5291 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10);
5292 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4);
5293 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8);
5294 xgifb_reg_set(pVBInfo->P3d4, 0x06, (value & 0xFF));
5296 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
5297 value = LVDSVBS - 1;
5298 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8);
5299 xgifb_reg_and_or(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4);
5300 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5);
5301 xgifb_reg_set(pVBInfo->P3d4, 0x15, (value & 0xFF));
5303 /* VBE SR0A[4] CR16 */
5304 value = LVDSVBE - 1;
5305 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4);
5306 xgifb_reg_set(pVBInfo->P3d4, 0x16, (value & 0xFF));
5308 /* VRS SR0A[3] CR7[7][2] CR10 */
5309 value = LVDSVRS - 1;
5310 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7);
5311 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2);
5312 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6);
5313 xgifb_reg_set(pVBInfo->P3d4, 0x10, (value & 0xFF));
5315 if (chip_id == XG27) {
5316 /* Panel VRS SR35[2:0] SR34[7:0] */
5317 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07,
5318 (value & 0x700) >> 8);
5319 xgifb_reg_set(pVBInfo->P3c4, 0x34, value & 0xFF);
5321 /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */
5322 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0x03,
5323 (value & 0x600) >> 9);
5324 xgifb_reg_set(pVBInfo->P3c4, 0x34, (value >> 1) & 0xFF);
5325 xgifb_reg_and_or(pVBInfo->P3d4, 0x33, ~0x01, value & 0x01);
5328 /* VRE SR0A[5] CR11[3:0] */
5329 value = LVDSVRE - 1;
5330 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1);
5331 xgifb_reg_and_or(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F);
5333 /* Panel VRE SR3F[7:2] */
5334 if (chip_id == XG27)
5335 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC,
5336 (value << 2) & 0xFC);
5338 /* SR3F[7] has to be 0, h/w bug */
5339 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC,
5340 (value << 2) & 0x7C);
5342 for (temp = 0, value = 0; temp < 3; temp++) {
5344 xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, value);
5345 xgifb_reg_set(pVBInfo->P3c4,
5346 0x2B, xgifb_info->lvds_data.VCLKData1);
5347 xgifb_reg_set(pVBInfo->P3c4,
5348 0x2C, xgifb_info->lvds_data.VCLKData2);
5352 if (!(modeflag & Charx8Dot)) {
5353 inb(pVBInfo->P3da); /* reset 3da */
5354 outb(0x13, pVBInfo->P3c0); /* set index */
5355 /* set data, panning = 0, shift left 1 dot*/
5356 outb(0x00, pVBInfo->P3c0);
5358 inb(pVBInfo->P3da); /* Enable Attribute */
5359 outb(0x20, pVBInfo->P3c0);
5361 inb(pVBInfo->P3da); /* reset 3da */
5366 /* --------------------------------------------------------------------- */
5367 /* Function : XGI_IsLCDON */
5369 /* Output : 0 : Skip PSC Control */
5370 /* 1: Disable PSC */
5372 /* --------------------------------------------------------------------- */
5373 static unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo)
5375 unsigned short tempax;
5377 tempax = pVBInfo->VBInfo;
5378 if (tempax & SetCRT2ToDualEdge)
5380 else if (tempax & (DisableCRT2Display | SwitchCRT2 | SetSimuScanMode))
5386 /* --------------------------------------------------------------------- */
5387 /* Function : XGI_DisableChISLCD */
5389 /* Output : 0 -> Not LCD Mode */
5391 /* --------------------------------------------------------------------- */
5392 static unsigned char XGI_DisableChISLCD(struct vb_device_info *pVBInfo)
5394 unsigned short tempbx, tempah;
5396 tempbx = pVBInfo->SetFlag & (DisableChA | DisableChB);
5397 tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E));
5399 if (tempbx & (EnableChA | DisableChA)) {
5400 if (!(tempah & 0x08)) /* Chk LCDA Mode */
5404 if (!(tempbx & (EnableChB | DisableChB)))
5407 if (tempah & 0x01) /* Chk LCDB Mode */
5413 /* --------------------------------------------------------------------- */
5414 /* Function : XGI_EnableChISLCD */
5416 /* Output : 0 -> Not LCD mode */
5418 /* --------------------------------------------------------------------- */
5419 static unsigned char XGI_EnableChISLCD(struct vb_device_info *pVBInfo)
5421 unsigned short tempbx, tempah;
5423 tempbx = pVBInfo->SetFlag & (EnableChA | EnableChB);
5424 tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E));
5426 if (tempbx & (EnableChA | DisableChA)) {
5427 if (!(tempah & 0x08)) /* Chk LCDA Mode */
5431 if (!(tempbx & (EnableChB | DisableChB)))
5434 if (tempah & 0x01) /* Chk LCDB Mode */
5440 static void XGI_DisableBridge(struct xgifb_video_info *xgifb_info,
5441 struct xgi_hw_device_info *HwDeviceExtension,
5442 struct vb_device_info *pVBInfo)
5444 unsigned short tempah = 0;
5446 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
5447 | VB_SIS302LV | VB_XGI301C)) {
5449 if (!(pVBInfo->VBInfo &
5450 (DisableCRT2Display | SetSimuScanMode))) {
5451 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
5452 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
5453 tempah = 0x7F; /* Disable Channel A */
5454 if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA))
5455 /* Disable Channel B */
5458 if (pVBInfo->SetFlag & DisableChB)
5459 /* force to disable Cahnnel */
5462 if (pVBInfo->SetFlag & DisableChA)
5463 /* Force to disable Channel B */
5469 /* disable part4_1f */
5470 xgifb_reg_and(pVBInfo->Part4Port, 0x1F, tempah);
5472 if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) {
5473 if (((pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)))
5474 || (XGI_DisableChISLCD(pVBInfo))
5475 || (XGI_IsLCDON(pVBInfo)))
5476 /* LVDS Driver power down */
5477 xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x80);
5480 if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo
5481 & (DisableCRT2Display | XGI_SetCRT2ToLCDA
5482 | SetSimuScanMode))) {
5483 if (pVBInfo->SetFlag & GatingCRT)
5484 XGI_EnableGatingCRT(HwDeviceExtension, pVBInfo);
5485 XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo);
5488 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
5489 if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo
5490 & XGI_SetCRT2ToLCDA))
5492 xgifb_reg_and(pVBInfo->Part1Port, 0x1e, 0xdf);
5495 /* disable TV as primary VGA swap */
5496 xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xdf);
5498 if ((pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToDualEdge)))
5499 xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xdf);
5501 if ((pVBInfo->SetFlag & DisableChB) ||
5503 (DisableCRT2Display | SetSimuScanMode)) ||
5504 ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) &&
5506 (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV))))
5507 xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80);
5509 if ((pVBInfo->SetFlag & DisableChB) ||
5511 (DisableCRT2Display | SetSimuScanMode)) ||
5512 (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) ||
5514 (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV))) {
5515 /* save Part1 index 0 */
5516 tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00);
5517 /* BTDAC = 1, avoid VB reset */
5518 xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x10);
5520 xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF);
5521 /* restore Part1 index 0 */
5522 xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah);
5524 } else { /* {301} */
5525 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) {
5526 xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80);
5528 xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF);
5529 /* Disable TV asPrimary VGA swap */
5530 xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xDF);
5533 if (pVBInfo->VBInfo & (DisableCRT2Display | XGI_SetCRT2ToLCDA
5535 XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo);
5539 /* --------------------------------------------------------------------- */
5540 /* Function : XGI_GetTVPtrIndex */
5543 /* Description : bx 0 : ExtNTSC */
5555 /* --------------------------------------------------------------------- */
5556 static unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo)
5558 unsigned short tempbx = 0;
5560 if (pVBInfo->TVInfo & TVSetPAL)
5562 if (pVBInfo->TVInfo & TVSetHiVision)
5564 if (pVBInfo->TVInfo & TVSetYPbPr525i)
5566 if (pVBInfo->TVInfo & TVSetYPbPr525p)
5568 if (pVBInfo->TVInfo & TVSetYPbPr750p)
5570 if (pVBInfo->TVInfo & TVSimuMode)
5576 /* --------------------------------------------------------------------- */
5577 /* Function : XGI_GetTVPtrIndex2 */
5579 /* Output : bx 0 : NTSC */
5583 /* 4 : NTSC1024x768 */
5584 /* 5 : PAL-M 1024x768 */
5586 /* cl 0 : YFilter1 */
5589 /* 1 : 301B/302B/301LV/302LV */
5591 /* --------------------------------------------------------------------- */
5592 static void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char *tempcl,
5593 unsigned char *tempch, struct vb_device_info *pVBInfo)
5599 if (pVBInfo->TVInfo & TVSetPAL)
5602 if (pVBInfo->TVInfo & TVSetPALM)
5605 if (pVBInfo->TVInfo & TVSetPALN)
5608 if (pVBInfo->TVInfo & NTSC1024x768) {
5610 if (pVBInfo->TVInfo & TVSetPALM)
5614 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
5615 | VB_SIS302LV | VB_XGI301C)) {
5616 if ((!(pVBInfo->VBInfo & SetInSlaveMode)) || (pVBInfo->TVInfo
5623 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
5624 | VB_SIS302LV | VB_XGI301C))
5628 static void XGI_SetDelayComp(struct vb_device_info *pVBInfo)
5630 unsigned char tempah, tempbl, tempbh;
5632 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
5633 | VB_SIS302LV | VB_XGI301C)) {
5634 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA
5635 | SetCRT2ToTV | SetCRT2ToRAMDAC)) {
5637 tempbl = XGI301TVDelay;
5639 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
5640 tempbl = tempbl >> 4;
5641 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
5642 tempbh = XGI301LCDDelay;
5644 if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA))
5650 tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x2D);
5652 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD
5653 | SetCRT2ToTV)) { /* Channel B */
5658 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { /* Channel A */
5662 xgifb_reg_set(pVBInfo->Part1Port, 0x2D, tempah);
5664 } else if (pVBInfo->IF_DEF_LVDS == 1) {
5667 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
5668 tempah = XGI301LCDDelay;
5670 tempah = tempah << 4;
5671 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2D, 0x0f,
5677 static void XGI_SetLCDCap_A(unsigned short tempcx,
5678 struct vb_device_info *pVBInfo)
5680 unsigned short temp;
5682 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
5684 if (temp & LCDRGB18Bit) {
5685 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F,
5687 (unsigned short) (0x20 | (tempcx & 0x00C0)));
5688 xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80);
5690 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F,
5691 (unsigned short) (0x30 | (tempcx & 0x00C0)));
5692 xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00);
5696 /* --------------------------------------------------------------------- */
5697 /* Function : XGI_SetLCDCap_B */
5698 /* Input : cx -> LCD Capability */
5701 /* --------------------------------------------------------------------- */
5702 static void XGI_SetLCDCap_B(unsigned short tempcx,
5703 struct vb_device_info *pVBInfo)
5705 if (tempcx & EnableLCD24bpp) /* 24bits */
5706 xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0,
5707 (unsigned short) (((tempcx & 0x00ff) >> 6)
5710 xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0,
5711 (unsigned short) (((tempcx & 0x00ff) >> 6)
5712 | 0x18)); /* Enable Dither */
5715 static void XGI_LongWait(struct vb_device_info *pVBInfo)
5719 i = xgifb_reg_get(pVBInfo->P3c4, 0x1F);
5722 for (i = 0; i < 0xFFFF; i++) {
5723 if (!(inb(pVBInfo->P3da) & 0x08))
5727 for (i = 0; i < 0xFFFF; i++) {
5728 if ((inb(pVBInfo->P3da) & 0x08))
5734 static void SetSpectrum(struct vb_device_info *pVBInfo)
5736 unsigned short index;
5738 index = XGI_GetLCDCapPtr(pVBInfo);
5740 /* disable down spectrum D[4] */
5741 xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x8F);
5742 XGI_LongWait(pVBInfo);
5743 xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x20); /* reset spectrum */
5744 XGI_LongWait(pVBInfo);
5746 xgifb_reg_set(pVBInfo->Part4Port, 0x31,
5747 pVBInfo->LCDCapList[index].Spectrum_31);
5748 xgifb_reg_set(pVBInfo->Part4Port, 0x32,
5749 pVBInfo->LCDCapList[index].Spectrum_32);
5750 xgifb_reg_set(pVBInfo->Part4Port, 0x33,
5751 pVBInfo->LCDCapList[index].Spectrum_33);
5752 xgifb_reg_set(pVBInfo->Part4Port, 0x34,
5753 pVBInfo->LCDCapList[index].Spectrum_34);
5754 XGI_LongWait(pVBInfo);
5755 xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x40); /* enable spectrum */
5758 static void XGI_SetLCDCap(struct vb_device_info *pVBInfo)
5760 unsigned short tempcx;
5762 tempcx = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(pVBInfo)].LCD_Capability;
5764 if (pVBInfo->VBType &
5769 VB_XGI301C)) { /* 301LV/302LV only */
5770 if (pVBInfo->VBType &
5771 (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) {
5772 /* Set 301LV Capability */
5773 xgifb_reg_set(pVBInfo->Part4Port, 0x24,
5774 (unsigned char) (tempcx & 0x1F));
5777 xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D,
5778 ~((EnableVBCLKDRVLOW | EnablePLLSPLOW) >> 8),
5779 (unsigned short) ((tempcx & (EnableVBCLKDRVLOW
5780 | EnablePLLSPLOW)) >> 8));
5783 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
5784 | VB_SIS302LV | VB_XGI301C)) {
5785 if (pVBInfo->VBInfo & SetCRT2ToLCD)
5786 XGI_SetLCDCap_B(tempcx, pVBInfo);
5787 else if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)
5788 XGI_SetLCDCap_A(tempcx, pVBInfo);
5790 if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) {
5791 if (tempcx & EnableSpectrum)
5792 SetSpectrum(pVBInfo);
5796 XGI_SetLCDCap_A(tempcx, pVBInfo);
5800 /* --------------------------------------------------------------------- */
5801 /* Function : XGI_SetAntiFlicker */
5804 /* Description : Set TV Customized Param. */
5805 /* --------------------------------------------------------------------- */
5806 static void XGI_SetAntiFlicker(unsigned short ModeNo,
5807 unsigned short ModeIdIndex,
5808 struct vb_device_info *pVBInfo)
5810 unsigned short tempbx;
5812 unsigned char tempah;
5814 if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p))
5817 tempbx = XGI_GetTVPtrIndex(pVBInfo);
5819 tempah = TVAntiFlickList[tempbx];
5820 tempah = tempah << 4;
5822 xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0x8F, tempah);
5825 static void XGI_SetEdgeEnhance(unsigned short ModeNo,
5826 unsigned short ModeIdIndex,
5827 struct vb_device_info *pVBInfo)
5829 unsigned short tempbx;
5831 unsigned char tempah;
5833 tempbx = XGI_GetTVPtrIndex(pVBInfo);
5835 tempah = TVEdgeList[tempbx];
5836 tempah = tempah << 5;
5838 xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, tempah);
5841 static void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo)
5843 unsigned short tempbx;
5845 unsigned char tempcl, tempch;
5847 unsigned long tempData;
5849 XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */
5850 tempData = TVPhaseList[tempbx];
5852 xgifb_reg_set(pVBInfo->Part2Port, 0x31, (unsigned short) (tempData
5854 xgifb_reg_set(pVBInfo->Part2Port, 0x32, (unsigned short) ((tempData
5855 & 0x0000FF00) >> 8));
5856 xgifb_reg_set(pVBInfo->Part2Port, 0x33, (unsigned short) ((tempData
5857 & 0x00FF0000) >> 16));
5858 xgifb_reg_set(pVBInfo->Part2Port, 0x34, (unsigned short) ((tempData
5859 & 0xFF000000) >> 24));
5862 static void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex,
5863 struct vb_device_info *pVBInfo)
5865 unsigned short tempbx, index;
5867 unsigned char tempcl, tempch, tempal, *filterPtr;
5869 XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */
5874 filterPtr = NTSCYFilter1;
5878 filterPtr = PALYFilter1;
5885 filterPtr = xgifb_palmn_yfilter1;
5893 filterPtr = xgifb_yfilter2;
5900 tempal = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVYFilterIndex;
5906 if ((tempcl == 0) && (tempch == 1)) {
5907 xgifb_reg_set(pVBInfo->Part2Port, 0x35, 0);
5908 xgifb_reg_set(pVBInfo->Part2Port, 0x36, 0);
5909 xgifb_reg_set(pVBInfo->Part2Port, 0x37, 0);
5910 xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]);
5912 xgifb_reg_set(pVBInfo->Part2Port, 0x35, filterPtr[index++]);
5913 xgifb_reg_set(pVBInfo->Part2Port, 0x36, filterPtr[index++]);
5914 xgifb_reg_set(pVBInfo->Part2Port, 0x37, filterPtr[index++]);
5915 xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]);
5918 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
5919 | VB_SIS302LV | VB_XGI301C)) {
5920 xgifb_reg_set(pVBInfo->Part2Port, 0x48, filterPtr[index++]);
5921 xgifb_reg_set(pVBInfo->Part2Port, 0x49, filterPtr[index++]);
5922 xgifb_reg_set(pVBInfo->Part2Port, 0x4A, filterPtr[index++]);
5926 /* --------------------------------------------------------------------- */
5927 /* Function : XGI_OEM310Setting */
5930 /* Description : Customized Param. for 301 */
5931 /* --------------------------------------------------------------------- */
5932 static void XGI_OEM310Setting(unsigned short ModeNo,
5933 unsigned short ModeIdIndex,
5934 struct vb_device_info *pVBInfo)
5936 XGI_SetDelayComp(pVBInfo);
5938 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))
5939 XGI_SetLCDCap(pVBInfo);
5941 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5942 XGI_SetPhaseIncr(pVBInfo);
5943 XGI_SetYFilter(ModeNo, ModeIdIndex, pVBInfo);
5944 XGI_SetAntiFlicker(ModeNo, ModeIdIndex, pVBInfo);
5946 if (pVBInfo->VBType & VB_SIS301)
5947 XGI_SetEdgeEnhance(ModeNo, ModeIdIndex, pVBInfo);
5951 /* --------------------------------------------------------------------- */
5952 /* Function : XGI_SetCRT2ModeRegs */
5955 /* Description : Origin code for crt2group */
5956 /* --------------------------------------------------------------------- */
5957 static void XGI_SetCRT2ModeRegs(unsigned short ModeNo,
5958 struct xgi_hw_device_info *HwDeviceExtension,
5959 struct vb_device_info *pVBInfo)
5961 unsigned short tempbl;
5964 unsigned char tempah;
5967 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
5968 tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00);
5969 tempah &= ~0x10; /* BTRAMDAC */
5970 tempah |= 0x40; /* BTRAM */
5972 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV
5974 tempah = 0x40; /* BTDRAM */
5975 tempcl = pVBInfo->ModeType;
5979 tempah = (0x008 >> tempcl);
5984 if (pVBInfo->VBInfo & SetInSlaveMode)
5985 tempah ^= 0x50; /* BTDAC */
5989 xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah);
5993 if (pVBInfo->VBInfo & DisableCRT2Display) {
5994 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl, tempah);
5999 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV
6000 | SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
6001 if ((pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) &&
6002 (!(pVBInfo->VBInfo & SetSimuScanMode))) {
6005 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e,
6008 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
6013 if (pVBInfo->VBInfo &
6020 if (!(pVBInfo->VBInfo & SetInSlaveMode))
6023 if (!(pVBInfo->VBInfo &
6025 tempah = tempah ^ 0x05;
6026 if (!(pVBInfo->VBInfo &
6028 tempah = tempah ^ 0x01;
6031 if (!(pVBInfo->VBInfo &
6034 xgifb_reg_and_or(pVBInfo->Part1Port,
6035 0x2e, tempbl, tempah);
6037 xgifb_reg_and_or(pVBInfo->Part1Port,
6038 0x2e, tempbl, tempah);
6042 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl,
6047 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD
6048 | XGI_SetCRT2ToLCDA)) {
6050 if ((pVBInfo->ModeType == ModeVGA) && (!(pVBInfo->VBInfo
6051 & SetInSlaveMode))) {
6056 if (pVBInfo->VBInfo & SetCRT2ToTV) {
6058 if (pVBInfo->VBInfo & DriverMode)
6059 tempah = tempah ^ 0x20;
6062 xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D, ~0x0BF, tempah);
6065 if (pVBInfo->LCDInfo & SetLCDDualLink)
6068 if (pVBInfo->VBInfo & SetCRT2ToTV) {
6069 if (pVBInfo->TVInfo & RPLLDIV2XO)
6073 if ((pVBInfo->LCDResInfo == Panel_1280x1024)
6074 || (pVBInfo->LCDResInfo == Panel_1280x1024x75))
6077 if (pVBInfo->LCDResInfo == Panel_1280x960)
6080 xgifb_reg_set(pVBInfo->Part4Port, 0x0C, tempah);
6083 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
6084 | VB_SIS302LV | VB_XGI301C)) {
6088 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
6090 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)
6091 tempah |= 0x04; /* shampoo 0129 */
6094 xgifb_reg_and_or(pVBInfo->Part1Port, 0x13, tempbl, tempah);
6097 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
6098 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
6102 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2c, tempbl, tempah);
6106 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
6107 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
6110 xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, tempbl, tempah);
6115 if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) {
6117 if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge))
6121 xgifb_reg_and_or(pVBInfo->Part4Port, 0x23, tempbl, tempah);
6123 if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) {
6124 if (pVBInfo->LCDInfo & SetLCDDualLink) {
6125 xgifb_reg_or(pVBInfo->Part4Port, 0x27, 0x20);
6126 xgifb_reg_or(pVBInfo->Part4Port, 0x34, 0x10);
6132 void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension,
6133 struct vb_device_info *pVBInfo)
6136 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2f, 0xFF, 0x01);
6140 void XGI_LockCRT2(struct xgi_hw_device_info *HwDeviceExtension,
6141 struct vb_device_info *pVBInfo)
6144 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2F, 0xFE, 0x00);
6148 unsigned char XGI_BridgeIsOn(struct vb_device_info *pVBInfo)
6150 unsigned short flag;
6152 if (pVBInfo->IF_DEF_LVDS == 1) {
6155 flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00);
6156 if ((flag == 1) || (flag == 2))
6157 return 1; /* 301b */
6163 unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE,
6164 unsigned short ModeNo, unsigned short ModeIdIndex,
6165 struct vb_device_info *pVBInfo)
6167 short LCDRefreshIndex[] = { 0x00, 0x00, 0x03, 0x01 },
6168 LCDARefreshIndex[] = { 0x00, 0x00, 0x03, 0x01, 0x01,
6171 unsigned short RefreshRateTableIndex, i, modeflag, index, temp;
6173 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
6175 index = xgifb_reg_get(pVBInfo->P3d4, 0x33);
6176 index = index >> pVBInfo->SelectCRT2Rate;
6179 if (pVBInfo->LCDInfo & LCDNonExpanding)
6185 if (pVBInfo->SetFlag & ProgrammingCRT2) {
6186 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
6187 if (pVBInfo->IF_DEF_LVDS == 0) {
6188 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B
6189 | VB_SIS301LV | VB_SIS302LV
6192 temp = LCDARefreshIndex[
6193 pVBInfo->LCDResInfo & 0x0F];
6195 temp = LCDRefreshIndex[
6196 pVBInfo->LCDResInfo & 0x0F];
6206 RefreshRateTableIndex = pVBInfo->EModeIDTable[ModeIdIndex].REFindex;
6207 ModeNo = pVBInfo->RefIndex[RefreshRateTableIndex].ModeID;
6208 if (pXGIHWDE->jChipType >= XG20) { /* for XG20, XG21, XG27 */
6209 if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 800) &&
6210 (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 600)) {
6213 /* do the similar adjustment like XGISearchCRT1Rate() */
6214 if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1024) &&
6215 (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 768)) {
6218 if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1280) &&
6219 (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 1024)) {
6226 if (pVBInfo->RefIndex[RefreshRateTableIndex + i].
6229 temp = pVBInfo->RefIndex[RefreshRateTableIndex + i].
6231 temp &= ModeTypeMask;
6232 if (temp < pVBInfo->ModeType)
6237 } while (index != 0xFFFF);
6238 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) {
6239 if (pVBInfo->VBInfo & SetInSlaveMode) {
6240 temp = pVBInfo->RefIndex[RefreshRateTableIndex + i - 1].
6242 if (temp & InterlaceMode)
6247 if ((pVBInfo->SetFlag & ProgrammingCRT2)) {
6248 temp = XGI_AjustCRT2Rate(ModeNo, ModeIdIndex,
6249 RefreshRateTableIndex, &i, pVBInfo);
6251 return RefreshRateTableIndex + i;
6254 static void XGI_SetLCDAGroup(unsigned short ModeNo, unsigned short ModeIdIndex,
6255 struct xgi_hw_device_info *HwDeviceExtension,
6256 struct vb_device_info *pVBInfo)
6258 unsigned short RefreshRateTableIndex;
6260 pVBInfo->SetFlag |= ProgrammingCRT2;
6261 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
6262 ModeIdIndex, pVBInfo);
6263 XGI_GetLVDSResInfo(ModeNo, ModeIdIndex, pVBInfo);
6264 XGI_GetLVDSData(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
6265 XGI_ModCRT1Regs(ModeNo, ModeIdIndex, RefreshRateTableIndex,
6266 HwDeviceExtension, pVBInfo);
6267 XGI_SetLVDSRegs(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
6268 XGI_SetCRT2ECLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
6271 static unsigned char XGI_SetCRT2Group301(unsigned short ModeNo,
6272 struct xgi_hw_device_info *HwDeviceExtension,
6273 struct vb_device_info *pVBInfo)
6275 unsigned short tempbx, ModeIdIndex, RefreshRateTableIndex;
6277 tempbx = pVBInfo->VBInfo;
6278 pVBInfo->SetFlag |= ProgrammingCRT2;
6279 XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo);
6280 pVBInfo->SelectCRT2Rate = 4;
6281 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
6282 ModeIdIndex, pVBInfo);
6283 XGI_SaveCRT2Info(ModeNo, pVBInfo);
6284 XGI_GetCRT2ResInfo(ModeNo, ModeIdIndex, pVBInfo);
6285 XGI_GetCRT2Data(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
6286 XGI_PreSetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension,
6287 RefreshRateTableIndex, pVBInfo);
6288 XGI_SetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension,
6289 RefreshRateTableIndex, pVBInfo);
6290 XGI_SetLockRegs(ModeNo, ModeIdIndex, HwDeviceExtension,
6291 RefreshRateTableIndex, pVBInfo);
6292 XGI_SetGroup2(ModeNo, ModeIdIndex, RefreshRateTableIndex,
6293 HwDeviceExtension, pVBInfo);
6294 XGI_SetLCDRegs(ModeNo, ModeIdIndex, HwDeviceExtension,
6295 RefreshRateTableIndex, pVBInfo);
6296 XGI_SetTap4Regs(pVBInfo);
6297 XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo);
6298 XGI_SetGroup4(ModeNo, ModeIdIndex, RefreshRateTableIndex,
6299 HwDeviceExtension, pVBInfo);
6300 XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
6301 XGI_SetGroup5(ModeNo, ModeIdIndex, pVBInfo);
6302 XGI_AutoThreshold(pVBInfo);
6306 void XGI_SenseCRT1(struct vb_device_info *pVBInfo)
6308 unsigned char CRTCData[17] = { 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81,
6309 0x0B, 0x3E, 0xE9, 0x0B, 0xDF, 0xE7, 0x04, 0x00, 0x00,
6312 unsigned char SR01 = 0, SR1F = 0, SR07 = 0, SR06 = 0;
6314 unsigned char CR17, CR63, SR31;
6315 unsigned short temp;
6316 unsigned char DAC_TEST_PARMS[3] = { 0x0F, 0x0F, 0x0F };
6319 xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86);
6321 /* to fix XG42 single LCD sense to CRT+LCD */
6322 xgifb_reg_set(pVBInfo->P3d4, 0x57, 0x4A);
6323 xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get(
6324 pVBInfo->P3d4, 0x53) | 0x02));
6326 SR31 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x31);
6327 CR63 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x63);
6328 SR01 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x01);
6330 xgifb_reg_set(pVBInfo->P3c4, 0x01, (unsigned char) (SR01 & 0xDF));
6331 xgifb_reg_set(pVBInfo->P3d4, 0x63, (unsigned char) (CR63 & 0xBF));
6333 CR17 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x17);
6334 xgifb_reg_set(pVBInfo->P3d4, 0x17, (unsigned char) (CR17 | 0x80));
6336 SR1F = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x1F);
6337 xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) (SR1F | 0x04));
6339 SR07 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x07);
6340 xgifb_reg_set(pVBInfo->P3c4, 0x07, (unsigned char) (SR07 & 0xFB));
6341 SR06 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x06);
6342 xgifb_reg_set(pVBInfo->P3c4, 0x06, (unsigned char) (SR06 & 0xC3));
6344 xgifb_reg_set(pVBInfo->P3d4, 0x11, 0x00);
6346 for (i = 0; i < 8; i++)
6347 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) i, CRTCData[i]);
6349 for (i = 8; i < 11; i++)
6350 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 8),
6353 for (i = 11; i < 13; i++)
6354 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 4),
6357 for (i = 13; i < 16; i++)
6358 xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i - 3),
6361 xgifb_reg_set(pVBInfo->P3c4, 0x0E, (unsigned char) (CRTCData[16]
6364 xgifb_reg_set(pVBInfo->P3c4, 0x31, 0x00);
6365 xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x1B);
6366 xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE1);
6368 outb(0x00, pVBInfo->P3c8);
6370 for (i = 0; i < 256; i++) {
6371 outb((unsigned char) DAC_TEST_PARMS[0], (pVBInfo->P3c8 + 1));
6372 outb((unsigned char) DAC_TEST_PARMS[1], (pVBInfo->P3c8 + 1));
6373 outb((unsigned char) DAC_TEST_PARMS[2], (pVBInfo->P3c8 + 1));
6378 XGI_WaitDisply(pVBInfo);
6379 temp = inb(pVBInfo->P3c2);
6382 xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x20);
6384 xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x00);
6386 /* avoid display something, set BLACK DAC if not restore DAC */
6387 outb(0x00, pVBInfo->P3c8);
6389 for (i = 0; i < 256; i++) {
6390 outb(0, (pVBInfo->P3c8 + 1));
6391 outb(0, (pVBInfo->P3c8 + 1));
6392 outb(0, (pVBInfo->P3c8 + 1));
6395 xgifb_reg_set(pVBInfo->P3c4, 0x01, SR01);
6396 xgifb_reg_set(pVBInfo->P3d4, 0x63, CR63);
6397 xgifb_reg_set(pVBInfo->P3c4, 0x31, SR31);
6399 xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get(
6400 pVBInfo->P3d4, 0x53) & 0xFD));
6401 xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) SR1F);
6404 static void XGI_EnableBridge(struct xgifb_video_info *xgifb_info,
6405 struct xgi_hw_device_info *HwDeviceExtension,
6406 struct vb_device_info *pVBInfo)
6408 unsigned short tempah;
6410 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
6411 | VB_SIS302LV | VB_XGI301C)) {
6412 if (!(pVBInfo->SetFlag & DisableChA)) {
6413 if (pVBInfo->SetFlag & EnableChA) {
6415 xgifb_reg_set(pVBInfo->Part1Port, 0x1E, 0x20);
6417 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
6419 xgifb_reg_set(pVBInfo->Part1Port,
6425 if (!(pVBInfo->SetFlag & DisableChB)) {
6426 if ((pVBInfo->SetFlag & EnableChB) || (pVBInfo->VBInfo
6427 & (SetCRT2ToLCD | SetCRT2ToTV
6428 | SetCRT2ToRAMDAC))) {
6429 tempah = (unsigned char) xgifb_reg_get(
6430 pVBInfo->P3c4, 0x32);
6432 if (pVBInfo->VBInfo & SetInSlaveMode) {
6433 if (!(pVBInfo->VBInfo &
6437 xgifb_reg_set(pVBInfo->P3c4, 0x32, tempah);
6438 xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x20);
6440 tempah = (unsigned char) xgifb_reg_get(
6441 pVBInfo->Part1Port, 0x2E);
6443 if (!(tempah & 0x80))
6444 xgifb_reg_or(pVBInfo->Part1Port,
6446 xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F);
6450 if ((pVBInfo->SetFlag & (EnableChA | EnableChB))
6451 || (!(pVBInfo->VBInfo & DisableCRT2Display))) {
6452 xgifb_reg_and_or(pVBInfo->Part2Port, 0x00, ~0xE0,
6453 0x20); /* shampoo 0129 */
6454 if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) {
6455 if (!XGI_DisableChISLCD(pVBInfo)) {
6456 if (XGI_EnableChISLCD(pVBInfo) ||
6458 (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)))
6459 /* LVDS PLL power on */
6465 /* LVDS Driver power on */
6466 xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x7F);
6472 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
6475 if (!(pVBInfo->VBInfo & SetSimuScanMode) &&
6476 (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) &&
6477 (pVBInfo->VBInfo & SetCRT2ToDualEdge)) {
6478 tempah = tempah & 0x40;
6479 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)
6480 tempah = tempah ^ 0xC0;
6482 if (pVBInfo->SetFlag & DisableChB)
6485 if (pVBInfo->SetFlag & DisableChA)
6488 if (pVBInfo->SetFlag & EnableChB)
6491 if (pVBInfo->SetFlag & EnableChA)
6496 /* EnablePart4_1F */
6497 xgifb_reg_or(pVBInfo->Part4Port, 0x1F, tempah);
6499 if (!(pVBInfo->SetFlag & DisableChA)) {
6500 if (!(pVBInfo->SetFlag & GatingCRT)) {
6501 XGI_DisableGatingCRT(HwDeviceExtension,
6503 XGI_DisplayOn(xgifb_info, HwDeviceExtension,
6509 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD
6510 | XGI_SetCRT2ToLCDA))
6512 xgifb_reg_or(pVBInfo->Part1Port, 0x1E, 0x20);
6514 tempah = (unsigned char) xgifb_reg_get(pVBInfo->Part1Port,
6516 if (!(tempah & 0x80))
6517 xgifb_reg_or(pVBInfo->Part1Port, 0x2E, 0x80);
6519 xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F);
6520 XGI_DisplayOn(xgifb_info, HwDeviceExtension, pVBInfo);
6524 static void XGI_SetCRT1Group(struct xgifb_video_info *xgifb_info,
6525 struct xgi_hw_device_info *HwDeviceExtension,
6526 unsigned short ModeNo, unsigned short ModeIdIndex,
6527 struct vb_device_info *pVBInfo)
6529 unsigned short RefreshRateTableIndex, temp;
6531 XGI_SetSeqRegs(ModeNo, ModeIdIndex, pVBInfo);
6532 outb(pVBInfo->StandTable->MISC, pVBInfo->P3c2);
6533 XGI_SetCRTCRegs(HwDeviceExtension, pVBInfo);
6534 XGI_SetATTRegs(ModeNo, ModeIdIndex, pVBInfo);
6535 XGI_SetGRCRegs(pVBInfo);
6536 XGI_ClearExt1Regs(pVBInfo);
6538 if (HwDeviceExtension->jChipType == XG27) {
6539 if (pVBInfo->IF_DEF_LVDS == 0)
6540 XGI_SetDefaultVCLK(pVBInfo);
6543 temp = ~ProgrammingCRT2;
6544 pVBInfo->SetFlag &= temp;
6545 pVBInfo->SelectCRT2Rate = 0;
6547 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
6548 | VB_SIS302LV | VB_XGI301C)) {
6549 if (pVBInfo->VBInfo & (SetSimuScanMode | XGI_SetCRT2ToLCDA
6550 | SetInSlaveMode)) {
6551 pVBInfo->SetFlag |= ProgrammingCRT2;
6555 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
6556 ModeIdIndex, pVBInfo);
6557 if (RefreshRateTableIndex != 0xFFFF) {
6558 XGI_SetSync(RefreshRateTableIndex, pVBInfo);
6559 XGI_SetCRT1CRTC(ModeNo, ModeIdIndex, RefreshRateTableIndex,
6560 pVBInfo, HwDeviceExtension);
6561 XGI_SetCRT1DE(HwDeviceExtension, ModeNo, ModeIdIndex,
6562 RefreshRateTableIndex, pVBInfo);
6563 XGI_SetCRT1Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
6564 HwDeviceExtension, pVBInfo);
6565 XGI_SetCRT1VCLK(ModeNo, ModeIdIndex, HwDeviceExtension,
6566 RefreshRateTableIndex, pVBInfo);
6569 if (HwDeviceExtension->jChipType >= XG21) {
6570 temp = xgifb_reg_get(pVBInfo->P3d4, 0x38);
6573 if (HwDeviceExtension->jChipType == XG27)
6574 XGI_SetXG27CRTC(ModeNo, ModeIdIndex,
6575 RefreshRateTableIndex, pVBInfo);
6577 XGI_SetXG21CRTC(ModeNo, ModeIdIndex,
6578 RefreshRateTableIndex, pVBInfo);
6580 XGI_UpdateXG21CRTC(ModeNo, pVBInfo,
6581 RefreshRateTableIndex);
6583 xgifb_set_lcd(HwDeviceExtension->jChipType,
6584 pVBInfo, RefreshRateTableIndex, ModeNo);
6586 if (pVBInfo->IF_DEF_LVDS == 1)
6587 xgifb_set_lvds(xgifb_info,
6588 HwDeviceExtension->jChipType,
6589 ModeNo, ModeIdIndex, pVBInfo);
6593 pVBInfo->SetFlag &= (~ProgrammingCRT2);
6594 XGI_SetCRT1FIFO(ModeNo, HwDeviceExtension, pVBInfo);
6595 XGI_SetCRT1ModeRegs(HwDeviceExtension, ModeNo, ModeIdIndex,
6596 RefreshRateTableIndex, pVBInfo);
6597 XGI_LoadDAC(ModeNo, ModeIdIndex, pVBInfo);
6600 unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info,
6601 struct xgi_hw_device_info *HwDeviceExtension,
6602 unsigned short ModeNo)
6604 unsigned short ModeIdIndex;
6605 struct vb_device_info VBINF;
6606 struct vb_device_info *pVBInfo = &VBINF;
6607 pVBInfo->BaseAddr = xgifb_info->vga_base;
6608 pVBInfo->IF_DEF_LVDS = 0;
6609 pVBInfo->IF_DEF_LCDA = 1;
6611 if (HwDeviceExtension->jChipType >= XG20) {
6612 pVBInfo->IF_DEF_YPbPr = 0;
6613 pVBInfo->IF_DEF_HiVision = 0;
6614 pVBInfo->IF_DEF_CRT2Monitor = 0;
6615 pVBInfo->VBType = 0; /*set VBType default 0*/
6617 pVBInfo->IF_DEF_YPbPr = 1;
6618 pVBInfo->IF_DEF_HiVision = 1;
6619 pVBInfo->IF_DEF_CRT2Monitor = 1;
6622 pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14;
6623 pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24;
6624 pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10;
6625 pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e;
6626 pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12;
6627 pVBInfo->P3cc = pVBInfo->BaseAddr + 0x1C;
6628 pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a;
6629 pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16;
6630 pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17;
6631 pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18;
6632 pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19;
6633 pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A;
6634 pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00;
6635 pVBInfo->Part1Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_04;
6636 pVBInfo->Part2Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_10;
6637 pVBInfo->Part3Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_12;
6638 pVBInfo->Part4Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_14;
6639 pVBInfo->Part5Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_14 + 2;
6641 /* for x86 Linux, XG21 LVDS */
6642 if (HwDeviceExtension->jChipType == XG21) {
6643 if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0)
6644 pVBInfo->IF_DEF_LVDS = 1;
6646 if (HwDeviceExtension->jChipType == XG27) {
6647 if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) {
6648 if (xgifb_reg_get(pVBInfo->P3d4, 0x30) & 0x20)
6649 pVBInfo->IF_DEF_LVDS = 1;
6653 if (HwDeviceExtension->jChipType < XG20)
6654 XGI_GetVBType(pVBInfo);
6656 InitTo330Pointer(HwDeviceExtension->jChipType, pVBInfo);
6658 ModeNo = ModeNo & 0x7F;
6659 xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86);
6661 if (HwDeviceExtension->jChipType < XG20)
6662 XGI_UnLockCRT2(HwDeviceExtension, pVBInfo);
6664 XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo);
6666 if (HwDeviceExtension->jChipType < XG20) {
6667 XGI_GetVBInfo(ModeNo, ModeIdIndex, HwDeviceExtension, pVBInfo);
6668 XGI_GetTVInfo(ModeNo, ModeIdIndex, pVBInfo);
6669 XGI_GetLCDInfo(ModeNo, ModeIdIndex, pVBInfo);
6670 XGI_DisableBridge(xgifb_info, HwDeviceExtension, pVBInfo);
6672 if (pVBInfo->VBInfo & (SetSimuScanMode | XGI_SetCRT2ToLCDA)) {
6673 XGI_SetCRT1Group(xgifb_info, HwDeviceExtension, ModeNo,
6674 ModeIdIndex, pVBInfo);
6676 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
6677 XGI_SetLCDAGroup(ModeNo, ModeIdIndex,
6678 HwDeviceExtension, pVBInfo);
6681 if (!(pVBInfo->VBInfo & SwitchCRT2)) {
6682 XGI_SetCRT1Group(xgifb_info,
6683 HwDeviceExtension, ModeNo,
6684 ModeIdIndex, pVBInfo);
6685 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
6686 XGI_SetLCDAGroup(ModeNo, ModeIdIndex,
6693 if (pVBInfo->VBInfo & (SetSimuScanMode | SwitchCRT2)) {
6694 switch (HwDeviceExtension->ujVBChipID) {
6696 XGI_SetCRT2Group301(ModeNo, HwDeviceExtension,
6697 pVBInfo); /*add for CRT2 */
6701 XGI_SetCRT2Group301(ModeNo, HwDeviceExtension,
6702 pVBInfo); /*add for CRT2 */
6710 XGI_SetCRT2ModeRegs(ModeNo, HwDeviceExtension, pVBInfo);
6711 XGI_OEM310Setting(ModeNo, ModeIdIndex, pVBInfo); /*0212*/
6712 XGI_EnableBridge(xgifb_info, HwDeviceExtension, pVBInfo);
6715 if (pVBInfo->IF_DEF_LVDS == 1)
6716 if (!XGI_XG21CheckLVDSMode(xgifb_info, ModeNo,
6721 pVBInfo->ModeType = pVBInfo->EModeIDTable[ModeIdIndex].
6722 Ext_ModeFlag & ModeTypeMask;
6724 pVBInfo->SetFlag = 0;
6725 pVBInfo->VBInfo = DisableCRT2Display;
6727 XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo);
6729 XGI_SetCRT1Group(xgifb_info, HwDeviceExtension, ModeNo,
6730 ModeIdIndex, pVBInfo);
6732 XGI_DisplayOn(xgifb_info, HwDeviceExtension, pVBInfo);
6735 XGI_UpdateModeInfo(HwDeviceExtension, pVBInfo);
6737 if (HwDeviceExtension->jChipType < XG20) {
6738 XGI_LockCRT2(HwDeviceExtension, pVBInfo);