1 #include <linux/delay.h>
8 #include "vb_setmode.h"
10 #define IndexMask 0xff
11 #define TVCLKBASE_315_25 (TVCLKBASE_315 + 25)
13 static const unsigned short XGINew_VGA_DAC[] = {
14 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
15 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
16 0x00, 0x05, 0x08, 0x0B, 0x0E, 0x11, 0x14, 0x18,
17 0x1C, 0x20, 0x24, 0x28, 0x2D, 0x32, 0x38, 0x3F,
18 0x00, 0x10, 0x1F, 0x2F, 0x3F, 0x1F, 0x27, 0x2F,
19 0x37, 0x3F, 0x2D, 0x31, 0x36, 0x3A, 0x3F, 0x00,
20 0x07, 0x0E, 0x15, 0x1C, 0x0E, 0x11, 0x15, 0x18,
21 0x1C, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x00, 0x04,
22 0x08, 0x0C, 0x10, 0x08, 0x0A, 0x0C, 0x0E, 0x10,
23 0x0B, 0x0C, 0x0D, 0x0F, 0x10};
25 void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo)
27 pVBInfo->MCLKData = XGI340New_MCLKData;
29 pVBInfo->LCDResInfo = 0;
30 pVBInfo->LCDTypeInfo = 0;
35 pVBInfo->SR15 = XGI340_SR13;
36 pVBInfo->CR40 = XGI340_cr41;
38 /* 310 customization related */
39 if ((pVBInfo->VBType & VB_SIS301LV) || (pVBInfo->VBType & VB_SIS302LV))
40 pVBInfo->LCDCapList = XGI_LCDDLCapList;
42 pVBInfo->LCDCapList = XGI_LCDCapList;
45 pVBInfo->XGINew_CR97 = 0x10;
47 if (ChipType == XG27) {
49 pVBInfo->MCLKData = XGI27New_MCLKData;
50 pVBInfo->CR40 = XGI27_cr41;
51 pVBInfo->XGINew_CR97 = 0xc1;
52 pVBInfo->SR15 = XG27_SR13;
55 temp = xgifb_reg_get(pVBInfo->P3c4, 0x3B);
56 /* SR3B[7][3]MAA15 MAA11 (Power on Trapping) */
57 if (((temp & 0x88) == 0x80) || ((temp & 0x88) == 0x08))
58 pVBInfo->XGINew_CR97 = 0x80;
63 static void XGI_SetSeqRegs(unsigned short ModeNo,
64 unsigned short ModeIdIndex,
65 struct vb_device_info *pVBInfo)
67 unsigned char SRdata, i;
69 xgifb_reg_set(pVBInfo->P3c4, 0x00, 0x03); /* Set SR0 */
71 for (i = 0; i < 4; i++) {
72 /* Get SR1,2,3,4 from file */
73 /* SR1 is with screen off 0x20 */
74 SRdata = XGI330_StandTable.SR[i];
75 xgifb_reg_set(pVBInfo->P3c4, i+1, SRdata); /* Set SR 1 2 3 4 */
79 static void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension,
80 struct vb_device_info *pVBInfo)
82 unsigned char CRTCdata;
85 CRTCdata = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
87 xgifb_reg_set(pVBInfo->P3d4, 0x11, CRTCdata); /* Unlock CRTC */
89 for (i = 0; i <= 0x18; i++) {
90 /* Get CRTC from file */
91 CRTCdata = XGI330_StandTable.CRTC[i];
92 xgifb_reg_set(pVBInfo->P3d4, i, CRTCdata); /* Set CRTC(3d4) */
96 static void XGI_SetATTRegs(unsigned short ModeNo,
97 unsigned short ModeIdIndex,
98 struct vb_device_info *pVBInfo)
100 unsigned char ARdata;
101 unsigned short i, modeflag;
103 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
105 for (i = 0; i <= 0x13; i++) {
106 ARdata = XGI330_StandTable.ATTR[i];
108 if ((modeflag & Charx8Dot) && i == 0x13) { /* ifndef Dot9 */
109 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
111 } else if ((pVBInfo->VBInfo &
112 (SetCRT2ToTV | SetCRT2ToLCD)) &&
113 (pVBInfo->VBInfo & SetInSlaveMode)) {
118 inb(pVBInfo->P3da); /* reset 3da */
119 outb(i, pVBInfo->P3c0); /* set index */
120 outb(ARdata, pVBInfo->P3c0); /* set data */
123 inb(pVBInfo->P3da); /* reset 3da */
124 outb(0x14, pVBInfo->P3c0); /* set index */
125 outb(0x00, pVBInfo->P3c0); /* set data */
126 inb(pVBInfo->P3da); /* Enable Attribute */
127 outb(0x20, pVBInfo->P3c0);
130 static void XGI_SetGRCRegs(struct vb_device_info *pVBInfo)
132 unsigned char GRdata;
135 for (i = 0; i <= 0x08; i++) {
136 /* Get GR from file */
137 GRdata = XGI330_StandTable.GRC[i];
138 xgifb_reg_set(pVBInfo->P3ce, i, GRdata); /* Set GR(3ce) */
141 if (pVBInfo->ModeType > ModeVGA) {
142 GRdata = (unsigned char) xgifb_reg_get(pVBInfo->P3ce, 0x05);
143 GRdata &= 0xBF; /* 256 color disable */
144 xgifb_reg_set(pVBInfo->P3ce, 0x05, GRdata);
148 static void XGI_ClearExt1Regs(struct vb_device_info *pVBInfo)
152 for (i = 0x0A; i <= 0x0E; i++)
153 xgifb_reg_set(pVBInfo->P3c4, i, 0x00); /* Clear SR0A-SR0E */
156 static unsigned char XGI_SetDefaultVCLK(struct vb_device_info *pVBInfo)
159 xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x20);
160 xgifb_reg_set(pVBInfo->P3c4, 0x2B, XGI_VCLKData[0].SR2B);
161 xgifb_reg_set(pVBInfo->P3c4, 0x2C, XGI_VCLKData[0].SR2C);
163 xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x10);
164 xgifb_reg_set(pVBInfo->P3c4, 0x2B, XGI_VCLKData[1].SR2B);
165 xgifb_reg_set(pVBInfo->P3c4, 0x2C, XGI_VCLKData[1].SR2C);
167 xgifb_reg_and(pVBInfo->P3c4, 0x31, ~0x30);
171 static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo,
172 unsigned short ModeIdIndex,
173 unsigned short RefreshRateTableIndex, unsigned short *i,
174 struct vb_device_info *pVBInfo)
176 unsigned short tempax, tempbx, resinfo, modeflag, infoflag;
178 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
179 resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO;
180 tempbx = XGI330_RefIndex[RefreshRateTableIndex + (*i)].ModeID;
183 if (pVBInfo->IF_DEF_LVDS == 0) {
184 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
185 tempax |= SupportRAMDAC2;
187 if (pVBInfo->VBType & VB_XGI301C)
188 tempax |= SupportCRT2in301C;
192 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
193 tempax |= SupportLCD;
195 if (pVBInfo->LCDResInfo != Panel_1280x1024 &&
196 pVBInfo->LCDResInfo != Panel_1280x960 &&
197 (pVBInfo->LCDInfo & LCDNonExpanding) &&
202 if (pVBInfo->VBInfo & SetCRT2ToHiVision) { /* for HiTV */
203 tempax |= SupportHiVision;
204 if ((pVBInfo->VBInfo & SetInSlaveMode) &&
207 (pVBInfo->SetFlag & TVSimuMode)) ||
210 } else if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO |
213 SetCRT2ToYPbPr525750 |
214 SetCRT2ToHiVision)) {
217 if (pVBInfo->VBType & (VB_SIS301B |
222 tempax |= SupportTV1024;
224 if (!(pVBInfo->VBInfo & TVSetPAL) &&
225 (modeflag & NoSupportSimuTV) &&
226 (pVBInfo->VBInfo & SetInSlaveMode) &&
227 (!(pVBInfo->VBInfo & SetNotSimuMode)))
230 } else if (pVBInfo->VBInfo & SetCRT2ToLCD) { /* for LVDS */
231 tempax |= SupportLCD;
234 return 0; /* 1024x768 */
236 if (pVBInfo->LCDResInfo < Panel_1024x768) {
238 return 0; /* 800x600 */
241 return 0; /* 512x384 */
245 for (; XGI330_RefIndex[RefreshRateTableIndex + (*i)].ModeID ==
247 infoflag = XGI330_RefIndex[RefreshRateTableIndex + (*i)].
249 if (infoflag & tempax)
256 for ((*i) = 0;; (*i)++) {
257 infoflag = XGI330_RefIndex[RefreshRateTableIndex + (*i)].
259 if (XGI330_RefIndex[RefreshRateTableIndex + (*i)].ModeID
264 if (infoflag & tempax)
270 static void XGI_SetSync(unsigned short RefreshRateTableIndex,
271 struct vb_device_info *pVBInfo)
273 unsigned short sync, temp;
276 sync = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag >> 8;
280 outb(temp, pVBInfo->P3c2); /* Set Misc(3c2) */
283 static void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo,
284 struct xgi_hw_device_info *HwDeviceExtension)
286 unsigned char data, data1, pushax;
290 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
292 xgifb_reg_set(pVBInfo->P3d4, 0x11, data);
294 data = pVBInfo->TimingH.data[0];
295 xgifb_reg_set(pVBInfo->P3d4, 0, data);
297 for (i = 0x01; i <= 0x04; i++) {
298 data = pVBInfo->TimingH.data[i];
299 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 1), data);
302 for (i = 0x05; i <= 0x06; i++) {
303 data = pVBInfo->TimingH.data[i];
304 xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i + 6), data);
307 j = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0e);
309 data = pVBInfo->TimingH.data[7];
312 xgifb_reg_set(pVBInfo->P3c4, 0x0e, data);
314 if (HwDeviceExtension->jChipType >= XG20) {
315 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x04);
317 xgifb_reg_set(pVBInfo->P3d4, 0x04, data);
318 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x05);
324 data = (unsigned char) xgifb_reg_get(pVBInfo->P3c4,
327 xgifb_reg_set(pVBInfo->P3c4, 0x0c, data);
332 xgifb_reg_set(pVBInfo->P3d4, 0x05, data);
333 data = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0e);
339 xgifb_reg_and_or(pVBInfo->P3c4, 0x0e, ~0xE0, data);
343 static void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex,
344 unsigned short ModeNo,
345 struct vb_device_info *pVBInfo)
350 for (i = 0x00; i <= 0x01; i++) {
351 data = pVBInfo->TimingV.data[i];
352 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 6), data);
355 for (i = 0x02; i <= 0x03; i++) {
356 data = pVBInfo->TimingV.data[i];
357 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x0e), data);
360 for (i = 0x04; i <= 0x05; i++) {
361 data = pVBInfo->TimingV.data[i];
362 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x11), data);
365 j = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0a);
367 data = pVBInfo->TimingV.data[6];
370 xgifb_reg_set(pVBInfo->P3c4, 0x0a, data);
372 data = pVBInfo->TimingV.data[6];
376 i = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
381 j = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x09);
384 xgifb_reg_set(pVBInfo->P3d4, 0x09, data);
387 static void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
388 unsigned short RefreshRateTableIndex,
389 struct vb_device_info *pVBInfo,
390 struct xgi_hw_device_info *HwDeviceExtension)
392 unsigned char index, data;
396 index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
397 index = index & IndexMask;
399 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
401 xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */
403 for (i = 0; i < 8; i++)
404 pVBInfo->TimingH.data[i]
405 = XGI_CRT1Table[index].CR[i];
407 for (i = 0; i < 7; i++)
408 pVBInfo->TimingV.data[i]
409 = XGI_CRT1Table[index].CR[i + 8];
411 XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension);
413 XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo);
415 if (pVBInfo->ModeType > 0x03)
416 xgifb_reg_set(pVBInfo->P3d4, 0x14, 0x4F);
419 /* --------------------------------------------------------------------- */
420 /* Function : XGI_SetXG21CRTC */
421 /* Input : Stand or enhance CRTC table */
422 /* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */
423 /* Description : Set LCD timing */
424 /* --------------------------------------------------------------------- */
425 static void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
426 unsigned short RefreshRateTableIndex,
427 struct vb_device_info *pVBInfo)
429 unsigned char index, Tempax, Tempbx, Tempcx, Tempdx;
430 unsigned short Temp1, Temp2, Temp3;
432 index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
433 /* Tempax: CR4 HRS */
434 Tempax = XGI_CRT1Table[index].CR[3];
435 Tempcx = Tempax; /* Tempcx: HRS */
437 xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax);
439 Tempdx = XGI_CRT1Table[index].CR[5]; /* SRB */
440 Tempdx &= 0xC0; /* Tempdx[7:6]: SRB[7:6] */
441 Temp1 = Tempdx; /* Temp1[7:6]: HRS[9:8] */
442 Temp1 <<= 2; /* Temp1[9:8]: HRS[9:8] */
443 Temp1 |= Tempax; /* Temp1[9:0]: HRS[9:0] */
445 Tempax = XGI_CRT1Table[index].CR[4]; /* CR5 HRE */
446 Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */
448 Tempbx = XGI_CRT1Table[index].CR[6]; /* SRC */
449 Tempbx &= 0x04; /* Tempbx[2]: HRE[5] */
450 Tempbx <<= 3; /* Tempbx[5]: HRE[5] */
451 Tempax |= Tempbx; /* Tempax[5:0]: HRE[5:0] */
453 Temp2 = Temp1 & 0x3C0; /* Temp2[9:6]: HRS[9:6] */
454 Temp2 |= Tempax; /* Temp2[9:0]: HRE[9:0] */
456 Tempcx &= 0x3F; /* Tempcx[5:0]: HRS[5:0] */
457 if (Tempax < Tempcx) /* HRE < HRS */
458 Temp2 |= 0x40; /* Temp2 + 0x40 */
461 Tempax = (unsigned char) Temp2; /* Tempax: HRE[7:0] */
462 Tempax <<= 2; /* Tempax[7:2]: HRE[5:0] */
463 Tempdx >>= 6; /* Tempdx[7:6]->[1:0] HRS[9:8] */
464 Tempax |= Tempdx; /* HRE[5:0]HRS[9:8] */
465 /* SR2F D[7:2]->HRE, D[1:0]->HRS */
466 xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax);
467 xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00);
470 Tempax = XGI_CRT1Table[index].CR[10];
471 Tempbx = Tempax; /* Tempbx: VRS */
472 Tempax &= 0x01; /* Tempax[0]: VRS[0] */
473 xgifb_reg_or(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS[0] */
475 Tempax = XGI_CRT1Table[index].CR[9];
476 Tempcx = Tempbx >> 1; /* Tempcx[6:0]: VRS[7:1] */
477 Tempdx = Tempax & 0x04; /* Tempdx[2]: CR7[2] */
478 Tempdx <<= 5; /* Tempdx[7]: VRS[8] */
479 Tempcx |= Tempdx; /* Tempcx[7:0]: VRS[8:1] */
480 xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempcx); /* SR34[8:1]->VRS */
482 Temp1 = Tempdx; /* Temp1[7]: Tempdx[7] */
483 Temp1 <<= 1; /* Temp1[8]: VRS[8] */
484 Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */
486 Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */
487 Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */
489 Tempax = XGI_CRT1Table[index].CR[14];
490 Tempax &= 0x08; /* Tempax[3]: VRS[3] */
492 Temp2 <<= 7; /* Temp2[10]: VRS[10] */
493 Temp1 |= Temp2; /* Temp1[10:0]: VRS[10:0] */
495 /* Tempax: CR11 VRE */
496 Tempax = XGI_CRT1Table[index].CR[11];
497 Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
499 Tempbx = XGI_CRT1Table[index].CR[14];
500 Tempbx &= 0x20; /* Tempbx[5]: VRE[5] */
501 Tempbx >>= 1; /* Tempbx[4]: VRE[4] */
502 Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */
503 Temp2 = Temp1 & 0x7E0; /* Temp2[10:5]: VRS[10:5] */
504 Temp2 |= Tempax; /* Temp2[10:5]: VRE[10:5] */
506 Temp3 = Temp1 & 0x1F; /* Temp3[4:0]: VRS[4:0] */
507 if (Tempax < Temp3) /* VRE < VRS */
508 Temp2 |= 0x20; /* VRE + 0x20 */
511 Tempax = (unsigned char) Temp2; /* Tempax: VRE[7:0] */
512 Tempax <<= 2; /* Tempax[7:0]; VRE[5:0]00 */
513 Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */
514 Temp1 >>= 9; /* Temp1[1:0]: VRS[10:9] */
515 Tempbx = (unsigned char) Temp1;
516 Tempax |= Tempbx; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */
518 /* SR3F D[7:2]->VRE D[1:0]->VRS */
519 xgifb_reg_set(pVBInfo->P3c4, 0x3F, Tempax);
522 static void XGI_SetXG27CRTC(unsigned short ModeNo,
523 unsigned short ModeIdIndex,
524 unsigned short RefreshRateTableIndex,
525 struct vb_device_info *pVBInfo)
527 unsigned short index, Tempax, Tempbx, Tempcx;
529 index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
530 /* Tempax: CR4 HRS */
531 Tempax = XGI_CRT1Table[index].CR[3];
532 Tempbx = Tempax; /* Tempbx: HRS[7:0] */
534 xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax);
537 Tempax = XGI_CRT1Table[index].CR[5];
538 Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
539 Tempbx |= (Tempax << 2); /* Tempbx: HRS[9:0] */
541 Tempax = XGI_CRT1Table[index].CR[4]; /* CR5 HRE */
542 Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */
543 Tempcx = Tempax; /* Tempcx: HRE[4:0] */
545 Tempax = XGI_CRT1Table[index].CR[6]; /* SRC */
546 Tempax &= 0x04; /* Tempax[2]: HRE[5] */
547 Tempax <<= 3; /* Tempax[5]: HRE[5] */
548 Tempcx |= Tempax; /* Tempcx[5:0]: HRE[5:0] */
550 Tempbx = Tempbx & 0x3C0; /* Tempbx[9:6]: HRS[9:6] */
551 Tempbx |= Tempcx; /* Tempbx: HRS[9:6]HRE[5:0] */
553 /* Tempax: CR4 HRS */
554 Tempax = XGI_CRT1Table[index].CR[3];
555 Tempax &= 0x3F; /* Tempax: HRS[5:0] */
556 if (Tempcx <= Tempax) /* HRE[5:0] < HRS[5:0] */
557 Tempbx += 0x40; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/
559 Tempax = XGI_CRT1Table[index].CR[5]; /* SR0B */
560 Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
561 Tempax >>= 6; /* Tempax[1:0]: HRS[9:8]*/
562 Tempax |= ((Tempbx << 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */
563 /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */
564 xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax);
565 xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00);
568 Tempax = XGI_CRT1Table[index].CR[10];
569 /* SR34[7:0]->VRS[7:0] */
570 xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempax);
572 Tempcx = Tempax; /* Tempcx <= VRS[7:0] */
573 /* CR7[7][2] VRS[9][8] */
574 Tempax = XGI_CRT1Table[index].CR[9];
575 Tempbx = Tempax; /* Tempbx <= CR07[7:0] */
576 Tempax = Tempax & 0x04; /* Tempax[2]: CR7[2]: VRS[8] */
577 Tempax >>= 2; /* Tempax[0]: VRS[8] */
578 /* SR35[0]: VRS[8] */
579 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x01, Tempax);
580 Tempcx |= (Tempax << 8); /* Tempcx <= VRS[8:0] */
581 Tempcx |= ((Tempbx & 0x80) << 2); /* Tempcx <= VRS[9:0] */
583 Tempax = XGI_CRT1Table[index].CR[14];
584 Tempax &= 0x08; /* SR0A[3] VRS[10] */
585 Tempcx |= (Tempax << 7); /* Tempcx <= VRS[10:0] */
587 /* Tempax: CR11 VRE */
588 Tempax = XGI_CRT1Table[index].CR[11];
589 Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
591 Tempbx = XGI_CRT1Table[index].CR[14];
592 Tempbx &= 0x20; /* Tempbx[5]: SR0A[5]: VRE[4] */
593 Tempbx >>= 1; /* Tempbx[4]: VRE[4] */
594 Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */
595 Tempbx = Tempcx; /* Tempbx: VRS[10:0] */
596 Tempbx &= 0x7E0; /* Tempbx[10:5]: VRS[10:5] */
597 Tempbx |= Tempax; /* Tempbx: VRS[10:5]VRE[4:0] */
599 if (Tempbx <= Tempcx) /* VRE <= VRS */
600 Tempbx |= 0x20; /* VRE + 0x20 */
602 /* Tempax: Tempax[7:0]; VRE[5:0]00 */
603 Tempax = (Tempbx << 2) & 0xFF;
604 /* SR3F[7:2]:VRE[5:0] */
605 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax);
606 Tempax = Tempcx >> 8;
607 /* SR35[2:0]:VRS[10:8] */
608 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, Tempax);
611 static void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo)
615 /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */
616 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
617 temp = (temp & 3) << 6;
618 /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */
619 xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0xc0, temp & 0x80);
620 /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */
621 xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80);
625 static void xgifb_set_lcd(int chip_id,
626 struct vb_device_info *pVBInfo,
627 unsigned short RefreshRateTableIndex,
628 unsigned short ModeNo)
632 xgifb_reg_set(pVBInfo->P3d4, 0x2E, 0x00);
633 xgifb_reg_set(pVBInfo->P3d4, 0x2F, 0x00);
634 xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x00);
635 xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x00);
637 if (chip_id == XG27) {
638 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
639 if ((temp & 0x03) == 0) { /* dual 12 */
640 xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x13);
641 xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x13);
645 if (chip_id == XG27) {
646 XGI_SetXG27FPBits(pVBInfo);
648 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
651 xgifb_reg_or(pVBInfo->P3c4, 0x06, 0x40);
652 xgifb_reg_or(pVBInfo->P3c4, 0x09, 0x40);
656 xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */
658 xgifb_reg_and(pVBInfo->P3c4, 0x30, ~0x20); /* Hsync polarity */
659 xgifb_reg_and(pVBInfo->P3c4, 0x35, ~0x80); /* Vsync polarity */
661 temp = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
664 xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20);
667 xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80);
670 /* --------------------------------------------------------------------- */
671 /* Function : XGI_UpdateXG21CRTC */
673 /* Output : CRT1 CRTC */
674 /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */
675 /* --------------------------------------------------------------------- */
676 static void XGI_UpdateXG21CRTC(unsigned short ModeNo,
677 struct vb_device_info *pVBInfo,
678 unsigned short RefreshRateTableIndex)
682 xgifb_reg_and(pVBInfo->P3d4, 0x11, 0x7F); /* Unlock CR0~7 */
683 if (ModeNo == 0x2E &&
684 (XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC ==
687 else if (ModeNo == 0x2E && (XGI330_RefIndex[RefreshRateTableIndex].
688 Ext_CRT1CRTC == RES640x480x72))
690 else if (ModeNo == 0x2F)
692 else if (ModeNo == 0x50)
694 else if (ModeNo == 0x59)
698 xgifb_reg_set(pVBInfo->P3d4, 0x02,
699 XGI_UpdateCRT1Table[index].CR02);
700 xgifb_reg_set(pVBInfo->P3d4, 0x03,
701 XGI_UpdateCRT1Table[index].CR03);
702 xgifb_reg_set(pVBInfo->P3d4, 0x15,
703 XGI_UpdateCRT1Table[index].CR15);
704 xgifb_reg_set(pVBInfo->P3d4, 0x16,
705 XGI_UpdateCRT1Table[index].CR16);
709 static void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension,
710 unsigned short ModeNo, unsigned short ModeIdIndex,
711 unsigned short RefreshRateTableIndex,
712 struct vb_device_info *pVBInfo)
714 unsigned short resindex, tempax, tempbx, tempcx, temp, modeflag;
718 resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO;
720 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
721 tempax = XGI330_ModeResInfo[resindex].HTotal;
722 tempbx = XGI330_ModeResInfo[resindex].VTotal;
724 if (modeflag & HalfDCLK)
725 tempax = tempax >> 1;
727 if (modeflag & HalfDCLK)
728 tempax = tempax << 1;
730 temp = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
732 if (temp & InterlaceMode)
733 tempbx = tempbx >> 1;
735 if (modeflag & DoubleScanMode)
736 tempbx = tempbx << 1;
744 temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
745 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
747 xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */
748 xgifb_reg_set(pVBInfo->P3d4, 0x01, (unsigned short) (tempcx & 0xff));
749 xgifb_reg_and_or(pVBInfo->P3d4, 0x0b, ~0x0c,
750 (unsigned short) ((tempcx & 0x0ff00) >> 10));
751 xgifb_reg_set(pVBInfo->P3d4, 0x12, (unsigned short) (tempbx & 0xff));
753 tempbx = tempbx >> 8;
761 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x42, tempax);
762 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x07);
769 xgifb_reg_and_or(pVBInfo->P3d4, 0x0a, ~0x02, tempax);
770 xgifb_reg_set(pVBInfo->P3d4, 0x11, temp);
773 static void XGI_SetCRT1Offset(unsigned short ModeNo,
774 unsigned short ModeIdIndex,
775 unsigned short RefreshRateTableIndex,
776 struct xgi_hw_device_info *HwDeviceExtension,
777 struct vb_device_info *pVBInfo)
779 unsigned short temp, ah, al, temp2, i, DisplayUnit;
782 temp = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeInfo;
784 temp = XGI330_ScreenOffset[temp];
786 temp2 = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
787 temp2 &= InterlaceMode;
792 temp2 = pVBInfo->ModeType - ModeEGA;
817 if ((ModeNo >= 0x26) && (ModeNo <= 0x28))
818 temp = temp * temp2 + temp2 / 2;
825 temp = temp >> 8; /* ah */
827 i = xgifb_reg_get(pVBInfo->P3c4, 0x0E);
830 xgifb_reg_set(pVBInfo->P3c4, 0x0E, i);
832 temp = (unsigned char) temp2;
833 temp &= 0xFF; /* al */
834 xgifb_reg_set(pVBInfo->P3d4, 0x13, temp);
837 temp2 = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
838 temp2 &= InterlaceMode;
842 DisplayUnit = DisplayUnit << 5;
843 ah = (DisplayUnit & 0xff00) >> 8;
844 al = DisplayUnit & 0x00ff;
850 if (HwDeviceExtension->jChipType >= XG20)
851 if ((ModeNo == 0x4A) | (ModeNo == 0x49))
854 xgifb_reg_set(pVBInfo->P3c4, 0x10, ah);
857 static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo,
858 unsigned short ModeIdIndex,
859 unsigned short RefreshRateTableIndex,
860 struct xgi_hw_device_info *HwDeviceExtension,
861 struct vb_device_info *pVBInfo)
863 unsigned short VCLKIndex, modeflag;
866 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
868 if (pVBInfo->IF_DEF_LVDS == 0) {
869 if (pVBInfo->VBInfo &
870 (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { /*301b*/
871 if (pVBInfo->LCDResInfo != Panel_1024x768)
873 VCLKIndex = VCLK108_2_315 + 5;
875 VCLKIndex = VCLK65_315 + 2; /* LCDXlat1VCLK */
876 } else if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
877 if (pVBInfo->SetFlag & RPLLDIV2XO)
878 VCLKIndex = TVCLKBASE_315_25 + HiTVVCLKDIV2;
880 VCLKIndex = TVCLKBASE_315_25 + HiTVVCLK;
882 if (pVBInfo->SetFlag & TVSimuMode) {
883 if (modeflag & Charx8Dot) {
884 VCLKIndex = TVCLKBASE_315_25 +
887 VCLKIndex = TVCLKBASE_315_25 +
893 if (pVBInfo->VBType & VB_SIS301LV) {
894 if (pVBInfo->SetFlag & RPLLDIV2XO)
895 VCLKIndex = YPbPr525iVCLK_2;
897 VCLKIndex = YPbPr525iVCLK;
899 } else if (pVBInfo->VBInfo & SetCRT2ToTV) {
900 if (pVBInfo->SetFlag & RPLLDIV2XO)
901 VCLKIndex = TVCLKBASE_315_25 + TVVCLKDIV2;
903 VCLKIndex = TVCLKBASE_315_25 + TVVCLK;
904 } else { /* for CRT2 */
906 VCLKIndex = XGI330_RefIndex[RefreshRateTableIndex].
908 VCLKIndex &= IndexMask;
910 } else if ((pVBInfo->LCDResInfo == Panel_800x600) ||
911 (pVBInfo->LCDResInfo == Panel_320x480)) { /* LVDS */
912 VCLKIndex = VCLK40; /* LVDSXlat1VCLK */
914 VCLKIndex = VCLK65_315 + 2; /* LVDSXlat2VCLK, LVDSXlat3VCLK */
920 static void XGI_SetCRT1VCLK(unsigned short ModeNo,
921 unsigned short ModeIdIndex,
922 struct xgi_hw_device_info *HwDeviceExtension,
923 unsigned short RefreshRateTableIndex,
924 struct vb_device_info *pVBInfo)
926 unsigned char index, data;
927 unsigned short vclkindex;
929 if (pVBInfo->IF_DEF_LVDS == 1) {
930 index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
931 data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF;
932 xgifb_reg_set(pVBInfo->P3c4, 0x31, data);
933 xgifb_reg_set(pVBInfo->P3c4, 0x2B, XGI_VCLKData[index].SR2B);
934 xgifb_reg_set(pVBInfo->P3c4, 0x2C, XGI_VCLKData[index].SR2C);
935 xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01);
936 } else if ((pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
937 | VB_SIS302LV | VB_XGI301C)) && (pVBInfo->VBInfo
938 & XGI_SetCRT2ToLCDA)) {
939 vclkindex = XGI_GetVCLK2Ptr(ModeNo, ModeIdIndex,
940 RefreshRateTableIndex, HwDeviceExtension,
942 data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF;
943 xgifb_reg_set(pVBInfo->P3c4, 0x31, data);
944 data = XGI_VBVCLKData[vclkindex].Part4_A;
945 xgifb_reg_set(pVBInfo->P3c4, 0x2B, data);
946 data = XGI_VBVCLKData[vclkindex].Part4_B;
947 xgifb_reg_set(pVBInfo->P3c4, 0x2C, data);
948 xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01);
950 index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
951 data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF;
952 xgifb_reg_set(pVBInfo->P3c4, 0x31, data);
953 xgifb_reg_set(pVBInfo->P3c4, 0x2B, XGI_VCLKData[index].SR2B);
954 xgifb_reg_set(pVBInfo->P3c4, 0x2C, XGI_VCLKData[index].SR2C);
955 xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01);
958 if (HwDeviceExtension->jChipType >= XG20) {
959 if (XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag &
961 data = xgifb_reg_get(pVBInfo->P3c4, 0x2B);
962 xgifb_reg_set(pVBInfo->P3c4, 0x2B, data);
963 data = xgifb_reg_get(pVBInfo->P3c4, 0x2C);
970 xgifb_reg_set(pVBInfo->P3c4, 0x2C, data);
975 static void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo)
979 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); /* D[0] 1: 18bit */
980 temp = (temp & 1) << 6;
981 /* SR06[6] 18bit Dither */
982 xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x40, temp);
983 /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */
984 xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80);
988 static void XGI_SetCRT1FIFO(unsigned short ModeNo,
989 struct xgi_hw_device_info *HwDeviceExtension,
990 struct vb_device_info *pVBInfo)
994 data = xgifb_reg_get(pVBInfo->P3c4, 0x3D);
996 xgifb_reg_set(pVBInfo->P3c4, 0x3D, data); /* diable auto-threshold */
998 xgifb_reg_set(pVBInfo->P3c4, 0x08, 0x34);
999 data = xgifb_reg_get(pVBInfo->P3c4, 0x09);
1001 xgifb_reg_set(pVBInfo->P3c4, 0x09, data | 0x30);
1002 data = xgifb_reg_get(pVBInfo->P3c4, 0x3D);
1004 xgifb_reg_set(pVBInfo->P3c4, 0x3D, data);
1006 if (HwDeviceExtension->jChipType == XG21)
1007 XGI_SetXG21FPBits(pVBInfo); /* Fix SR9[7:6] can't read back */
1010 static void XGI_SetVCLKState(struct xgi_hw_device_info *HwDeviceExtension,
1011 unsigned short ModeNo, unsigned short RefreshRateTableIndex,
1012 struct vb_device_info *pVBInfo)
1014 unsigned short data, data2 = 0;
1017 unsigned char index;
1019 index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1021 VCLK = XGI_VCLKData[index].CLOCK;
1023 data = xgifb_reg_get(pVBInfo->P3c4, 0x32);
1026 data |= 0x0c; /* VCLK > 200 */
1028 if (HwDeviceExtension->jChipType >= XG20)
1029 data &= ~0x04; /* 2 pixel mode */
1031 xgifb_reg_set(pVBInfo->P3c4, 0x32, data);
1033 if (HwDeviceExtension->jChipType < XG20) {
1034 data = xgifb_reg_get(pVBInfo->P3c4, 0x1F);
1038 xgifb_reg_set(pVBInfo->P3c4, 0x1F, data);
1043 xgifb_reg_and_or(pVBInfo->P3c4, 0x07, 0xFC, data2);
1044 if (HwDeviceExtension->jChipType >= XG27)
1045 xgifb_reg_and_or(pVBInfo->P3c4, 0x40, 0xFC, data2 & 0x03);
1049 static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension,
1050 unsigned short ModeNo, unsigned short ModeIdIndex,
1051 unsigned short RefreshRateTableIndex,
1052 struct vb_device_info *pVBInfo)
1054 unsigned short data, data2, data3, infoflag = 0, modeflag, resindex,
1057 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1058 infoflag = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1060 if (xgifb_reg_get(pVBInfo->P3d4, 0x31) & 0x01)
1061 xgifb_reg_and_or(pVBInfo->P3c4, 0x1F, 0x3F, 0x00);
1066 data3 = pVBInfo->ModeType - ModeVGA;
1069 data &= InterlaceMode;
1074 xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x3F, data2);
1075 resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO;
1076 xres = XGI330_ModeResInfo[resindex].HTotal; /* xres->ax */
1079 if (infoflag & InterlaceMode) {
1082 else if (xres == 1280)
1086 xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFF, data);
1087 xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFC, 0);
1089 if (modeflag & HalfDCLK)
1090 xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xF7, 0x08);
1094 if (modeflag & LineCompareOff)
1097 xgifb_reg_and_or(pVBInfo->P3c4, 0x0F, ~0x48, data2);
1101 xgifb_reg_and_or(pVBInfo->P3c4, 0x21, 0x1F, data);
1103 XGI_SetVCLKState(HwDeviceExtension, ModeNo, RefreshRateTableIndex,
1106 data = xgifb_reg_get(pVBInfo->P3d4, 0x31);
1108 if (HwDeviceExtension->jChipType == XG27) {
1113 xgifb_reg_set(pVBInfo->P3d4, 0x52, data);
1114 xgifb_reg_or(pVBInfo->P3d4, 0x51, 0x10);
1115 } else if (HwDeviceExtension->jChipType >= XG20) {
1120 xgifb_reg_set(pVBInfo->P3d4, 0x52, data);
1121 xgifb_reg_set(pVBInfo->P3d4, 0x51, 0x02);
1127 xgifb_reg_set(pVBInfo->P3d4, 0x52, data);
1132 static void XGI_WriteDAC(unsigned short dl,
1136 struct vb_device_info *pVBInfo)
1138 unsigned short temp, bh, bl;
1157 outb((unsigned short) dh, pVBInfo->P3c9);
1158 outb((unsigned short) bh, pVBInfo->P3c9);
1159 outb((unsigned short) bl, pVBInfo->P3c9);
1162 static void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex,
1163 struct vb_device_info *pVBInfo)
1165 unsigned short data, data2, i, k, m, n, o, si, di, bx, dl, al, ah, dh;
1166 const unsigned short *table = XGINew_VGA_DAC;
1168 outb(0xFF, pVBInfo->P3c6);
1169 outb(0x00, pVBInfo->P3c8);
1171 for (i = 0; i < 16; i++) {
1174 for (k = 0; k < 3; k++) {
1183 outb(data2, pVBInfo->P3c9);
1188 for (i = 16; i < 32; i++) {
1191 for (k = 0; k < 3; k++)
1192 outb(data, pVBInfo->P3c9);
1197 for (m = 0; m < 9; m++) {
1202 for (n = 0; n < 3; n++) {
1203 for (o = 0; o < 5; o++) {
1208 XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
1213 for (o = 0; o < 3; o++) {
1218 XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
1228 static void XGI_GetLVDSResInfo(unsigned short ModeNo,
1229 unsigned short ModeIdIndex,
1230 struct vb_device_info *pVBInfo)
1232 unsigned short resindex, xres, yres, modeflag;
1234 /* si+Ext_ResInfo */
1235 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO;
1237 /* si+Ext_ResInfo */
1238 resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO;
1240 xres = XGI330_ModeResInfo[resindex].HTotal;
1241 yres = XGI330_ModeResInfo[resindex].VTotal;
1243 if (modeflag & HalfDCLK)
1246 if (modeflag & DoubleScanMode)
1252 pVBInfo->VGAHDE = xres;
1253 pVBInfo->HDE = xres;
1254 pVBInfo->VGAVDE = yres;
1255 pVBInfo->VDE = yres;
1258 static void const *XGI_GetLcdPtr(struct XGI330_LCDDataTablStruct const *table,
1259 unsigned short ModeNo,
1260 unsigned short ModeIdIndex,
1261 unsigned short RefreshRateTableIndex,
1262 struct vb_device_info *pVBInfo)
1264 unsigned short i, tempdx, tempbx, modeflag;
1268 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1272 while (table[i].PANELID != 0xff) {
1273 tempdx = pVBInfo->LCDResInfo;
1274 if (tempbx & 0x0080) { /* OEMUtil */
1275 tempbx &= (~0x0080);
1276 tempdx = pVBInfo->LCDTypeInfo;
1279 if (pVBInfo->LCDInfo & EnableScalingLCD)
1280 tempdx &= (~PanelResInfo);
1282 if (table[i].PANELID == tempdx) {
1283 tempbx = table[i].MASK;
1284 tempdx = pVBInfo->LCDInfo;
1286 if (modeflag & HalfDCLK)
1287 tempdx |= SetLCDLowResolution;
1290 if (tempbx == table[i].CAP)
1296 return table[i].DATAPTR;
1299 static struct SiS_TVData const *XGI_GetTVPtr(unsigned short ModeNo,
1300 unsigned short ModeIdIndex,
1301 unsigned short RefreshRateTableIndex,
1302 struct vb_device_info *pVBInfo)
1304 unsigned short i, tempdx, tempal, modeflag;
1306 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1307 tempal = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
1308 tempal = tempal & 0x3f;
1309 tempdx = pVBInfo->TVInfo;
1311 if (pVBInfo->VBInfo & SetInSlaveMode)
1312 tempdx = tempdx | SetTVLockMode;
1314 if (modeflag & HalfDCLK)
1315 tempdx = tempdx | SetTVLowResolution;
1319 while (XGI_TVDataTable[i].MASK != 0xffff) {
1320 if ((tempdx & XGI_TVDataTable[i].MASK) ==
1321 XGI_TVDataTable[i].CAP)
1326 return &XGI_TVDataTable[i].DATAPTR[tempal];
1329 static void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex,
1330 unsigned short RefreshRateTableIndex,
1331 struct vb_device_info *pVBInfo)
1333 struct SiS_LVDSData const *LCDPtr;
1335 if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)))
1338 LCDPtr = XGI_GetLcdPtr(XGI_EPLLCDDataPtr, ModeNo, ModeIdIndex,
1339 RefreshRateTableIndex, pVBInfo);
1340 pVBInfo->VGAHT = LCDPtr->VGAHT;
1341 pVBInfo->VGAVT = LCDPtr->VGAVT;
1342 pVBInfo->HT = LCDPtr->LCDHT;
1343 pVBInfo->VT = LCDPtr->LCDVT;
1345 if (pVBInfo->LCDInfo & (SetLCDtoNonExpanding | EnableScalingLCD))
1348 if ((pVBInfo->LCDResInfo == Panel_1024x768) ||
1349 (pVBInfo->LCDResInfo == Panel_1024x768x75)) {
1350 pVBInfo->HDE = 1024;
1352 } else if ((pVBInfo->LCDResInfo == Panel_1280x1024) ||
1353 (pVBInfo->LCDResInfo == Panel_1280x1024x75)) {
1354 pVBInfo->HDE = 1280;
1355 pVBInfo->VDE = 1024;
1356 } else if (pVBInfo->LCDResInfo == Panel_1400x1050) {
1357 pVBInfo->HDE = 1400;
1358 pVBInfo->VDE = 1050;
1360 pVBInfo->HDE = 1600;
1361 pVBInfo->VDE = 1200;
1365 static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex,
1366 unsigned short RefreshRateTableIndex,
1367 struct xgi_hw_device_info *HwDeviceExtension,
1368 struct vb_device_info *pVBInfo)
1371 struct XGI_LVDSCRT1HDataStruct const *LCDPtr = NULL;
1372 struct XGI_LVDSCRT1VDataStruct const *LCDPtr1 = NULL;
1374 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
1375 LCDPtr = XGI_GetLcdPtr(xgifb_epllcd_crt1_h, ModeNo, ModeIdIndex,
1376 RefreshRateTableIndex, pVBInfo);
1378 for (i = 0; i < 8; i++)
1379 pVBInfo->TimingH.data[i] = LCDPtr[0].Reg[i];
1382 XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension);
1384 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
1385 LCDPtr1 = XGI_GetLcdPtr(xgifb_epllcd_crt1_v, ModeNo,
1386 ModeIdIndex, RefreshRateTableIndex,
1388 for (i = 0; i < 7; i++)
1389 pVBInfo->TimingV.data[i] = LCDPtr1[0].Reg[i];
1392 XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo);
1395 static unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo)
1397 unsigned char tempal, tempah, tempbl, i;
1399 tempah = xgifb_reg_get(pVBInfo->P3d4, 0x36);
1400 tempal = tempah & 0x0F;
1401 tempah = tempah & 0xF0;
1403 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
1405 while (tempbl != 0xFF) {
1406 if (tempbl & 0x80) { /* OEMUtil */
1408 tempbl = tempbl & ~(0x80);
1411 if (tempal == tempbl)
1416 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
1422 static unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo)
1424 unsigned short tempah, tempal, tempbl, i;
1426 tempal = pVBInfo->LCDResInfo;
1427 tempah = pVBInfo->LCDTypeInfo;
1430 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
1432 while (tempbl != 0xFF) {
1433 if ((tempbl & 0x80) && (tempbl != 0x80)) {
1438 if (tempal == tempbl)
1442 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
1445 if (tempbl == 0xFF) {
1446 pVBInfo->LCDResInfo = Panel_1024x768;
1447 pVBInfo->LCDTypeInfo = 0;
1454 static void XGI_GetLCDSync(unsigned short *HSyncWidth,
1455 unsigned short *VSyncWidth,
1456 struct vb_device_info *pVBInfo)
1458 unsigned short Index;
1460 Index = XGI_GetLCDCapPtr(pVBInfo);
1461 *HSyncWidth = pVBInfo->LCDCapList[Index].LCD_HSyncWidth;
1462 *VSyncWidth = pVBInfo->LCDCapList[Index].LCD_VSyncWidth;
1467 static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
1468 unsigned short RefreshRateTableIndex,
1469 struct vb_device_info *pVBInfo)
1471 unsigned short tempbx, tempax, tempcx, tempdx, push1, push2, modeflag;
1472 unsigned long temp, temp1, temp2, temp3, push3;
1473 struct XGI_LCDDesStruct const *LCDPtr = NULL;
1474 struct XGI330_LCDDataDesStruct2 const *LCDPtr1 = NULL;
1476 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1477 if (pVBInfo->LCDInfo & EnableScalingLCD)
1478 LCDPtr1 = XGI_GetLcdPtr(XGI_EPLLCDDesDataPtr, ModeNo,
1479 ModeIdIndex, RefreshRateTableIndex,
1482 LCDPtr = XGI_GetLcdPtr(XGI_EPLLCDDesDataPtr, ModeNo,
1483 ModeIdIndex, RefreshRateTableIndex,
1486 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
1491 if ((pVBInfo->LCDResInfo == Panel_1024x768) ||
1492 (pVBInfo->LCDResInfo == Panel_1024x768x75)) {
1495 } else if ((pVBInfo->LCDResInfo == Panel_1280x1024) ||
1496 (pVBInfo->LCDResInfo == Panel_1280x1024x75)) {
1499 } else if (pVBInfo->LCDResInfo == Panel_1400x1050) {
1507 if (pVBInfo->LCDInfo & SetLCDtoNonExpanding) {
1508 pVBInfo->HDE = tempax;
1509 pVBInfo->VDE = tempbx;
1510 pVBInfo->VGAHDE = tempax;
1511 pVBInfo->VGAVDE = tempbx;
1514 tempax = pVBInfo->HT;
1516 if (pVBInfo->LCDInfo & EnableScalingLCD)
1517 tempbx = LCDPtr1->LCDHDES;
1519 tempbx = LCDPtr->LCDHDES;
1521 tempcx = pVBInfo->HDE;
1522 tempbx = tempbx & 0x0fff;
1525 if (tempcx >= tempax)
1528 xgifb_reg_set(pVBInfo->Part1Port, 0x1A, tempbx & 0x07);
1530 tempcx = tempcx >> 3;
1531 tempbx = tempbx >> 3;
1533 xgifb_reg_set(pVBInfo->Part1Port, 0x16,
1534 (unsigned short) (tempbx & 0xff));
1535 xgifb_reg_set(pVBInfo->Part1Port, 0x17,
1536 (unsigned short) (tempcx & 0xff));
1538 tempax = pVBInfo->HT;
1540 if (pVBInfo->LCDInfo & EnableScalingLCD)
1541 tempbx = LCDPtr1->LCDHRS;
1543 tempbx = LCDPtr->LCDHRS;
1547 if (pVBInfo->LCDInfo & EnableScalingLCD)
1548 tempcx = LCDPtr1->LCDHSync;
1552 if (tempcx >= tempax)
1555 tempax = tempbx & 0x07;
1556 tempax = tempax >> 5;
1557 tempcx = tempcx >> 3;
1558 tempbx = tempbx >> 3;
1563 xgifb_reg_set(pVBInfo->Part1Port, 0x15, tempax);
1564 xgifb_reg_set(pVBInfo->Part1Port, 0x14,
1565 (unsigned short) (tempbx & 0xff));
1567 tempax = pVBInfo->VT;
1568 if (pVBInfo->LCDInfo & EnableScalingLCD)
1569 tempbx = LCDPtr1->LCDVDES;
1571 tempbx = LCDPtr->LCDVDES;
1572 tempcx = pVBInfo->VDE;
1574 tempbx = tempbx & 0x0fff;
1576 if (tempcx >= tempax)
1579 xgifb_reg_set(pVBInfo->Part1Port, 0x1b,
1580 (unsigned short) (tempbx & 0xff));
1581 xgifb_reg_set(pVBInfo->Part1Port, 0x1c,
1582 (unsigned short) (tempcx & 0xff));
1584 tempbx = (tempbx >> 8) & 0x07;
1585 tempcx = (tempcx >> 8) & 0x07;
1587 xgifb_reg_set(pVBInfo->Part1Port, 0x1d,
1588 (unsigned short) ((tempcx << 3)
1591 tempax = pVBInfo->VT;
1592 if (pVBInfo->LCDInfo & EnableScalingLCD)
1593 tempbx = LCDPtr1->LCDVRS;
1595 tempbx = LCDPtr->LCDVRS;
1599 if (pVBInfo->LCDInfo & EnableScalingLCD)
1600 tempcx = LCDPtr1->LCDVSync;
1603 if (tempcx >= tempax)
1606 xgifb_reg_set(pVBInfo->Part1Port, 0x18,
1607 (unsigned short) (tempbx & 0xff));
1608 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, ~0x0f,
1609 (unsigned short) (tempcx & 0x0f));
1611 tempax = ((tempbx >> 8) & 0x07) << 3;
1613 tempbx = pVBInfo->VGAVDE;
1614 if (tempbx != pVBInfo->VDE)
1617 if (pVBInfo->LCDInfo & XGI_EnableLVDSDDA)
1620 xgifb_reg_and_or(pVBInfo->Part1Port, 0x1a, 0x07,
1623 tempcx = pVBInfo->VGAVT;
1624 tempbx = pVBInfo->VDE;
1625 tempax = pVBInfo->VGAVDE;
1628 temp = tempax; /* 0430 ylshieh */
1629 temp1 = (temp << 18) / tempbx;
1631 tempdx = (unsigned short) ((temp << 18) % tempbx);
1639 xgifb_reg_set(pVBInfo->Part1Port, 0x37,
1640 (unsigned short) (temp2 & 0xff));
1641 xgifb_reg_set(pVBInfo->Part1Port, 0x36,
1642 (unsigned short) ((temp2 >> 8) & 0xff));
1644 tempbx = (unsigned short) (temp2 >> 16);
1645 tempax = tempbx & 0x03;
1647 tempbx = pVBInfo->VGAVDE;
1648 if (tempbx == pVBInfo->VDE)
1651 xgifb_reg_set(pVBInfo->Part1Port, 0x35, tempax);
1653 if (pVBInfo->VBType & VB_XGI301C) {
1655 xgifb_reg_set(pVBInfo->Part4Port,
1657 (unsigned short) (temp2 & 0xff));
1658 xgifb_reg_set(pVBInfo->Part4Port,
1660 (unsigned short) ((temp2 >> 8) &
1662 tempbx = (unsigned short) (temp2 >> 16);
1663 xgifb_reg_and_or(pVBInfo->Part4Port, 0x3a,
1665 (unsigned short) ((tempbx &
1668 tempcx = pVBInfo->VGAVDE;
1669 if (tempcx == pVBInfo->VDE)
1670 xgifb_reg_and_or(pVBInfo->Part4Port,
1673 xgifb_reg_and_or(pVBInfo->Part4Port,
1677 tempcx = pVBInfo->VGAHDE;
1678 tempbx = pVBInfo->HDE;
1680 temp1 = tempcx << 16;
1682 tempax = (unsigned short) (temp1 / tempbx);
1684 if ((tempbx & 0xffff) == (tempcx & 0xffff))
1688 temp1 = pVBInfo->VGAHDE << 16;
1691 temp3 = temp3 << 16;
1694 temp3 = (temp3 & 0xffff0000) + (temp1 & 0xffff);
1696 tempax = (unsigned short) (temp3 & 0xff);
1697 xgifb_reg_set(pVBInfo->Part1Port, 0x1f, tempax);
1699 temp1 = pVBInfo->VGAVDE << 18;
1700 temp1 = temp1 / push3;
1701 tempbx = (unsigned short) (temp1 & 0xffff);
1703 if (pVBInfo->LCDResInfo == Panel_1024x768)
1706 tempax = ((tempbx >> 8) & 0xff) << 3;
1707 tempax |= (unsigned short) ((temp3 >> 8) & 0x07);
1708 xgifb_reg_set(pVBInfo->Part1Port, 0x20,
1709 (unsigned short) (tempax & 0xff));
1710 xgifb_reg_set(pVBInfo->Part1Port, 0x21,
1711 (unsigned short) (tempbx & 0xff));
1713 temp3 = temp3 >> 16;
1715 if (modeflag & HalfDCLK)
1718 xgifb_reg_set(pVBInfo->Part1Port, 0x22,
1719 (unsigned short) ((temp3 >> 8) & 0xff));
1720 xgifb_reg_set(pVBInfo->Part1Port, 0x23,
1721 (unsigned short) (temp3 & 0xff));
1724 /* --------------------------------------------------------------------- */
1725 /* Function : XGI_GETLCDVCLKPtr */
1727 /* Output : al -> VCLK Index */
1729 /* --------------------------------------------------------------------- */
1730 static void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1,
1731 struct vb_device_info *pVBInfo)
1733 unsigned short index;
1735 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
1736 index = XGI_GetLCDCapPtr1(pVBInfo);
1738 if (pVBInfo->VBInfo & SetCRT2ToLCD) { /* LCDB */
1739 *di_0 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData1;
1740 *di_1 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData2;
1742 *di_0 = pVBInfo->LCDCapList[index].LCDA_VCLKData1;
1743 *di_1 = pVBInfo->LCDCapList[index].LCDA_VCLKData2;
1749 static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex,
1750 unsigned short ModeNo, unsigned short ModeIdIndex,
1751 struct vb_device_info *pVBInfo)
1754 unsigned short index, modeflag;
1755 unsigned char tempal;
1757 /* si+Ext_ResInfo */
1758 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1760 if ((pVBInfo->SetFlag & ProgrammingCRT2) &&
1761 (!(pVBInfo->LCDInfo & EnableScalingLCD))) { /* {LCDA/LCDB} */
1762 index = XGI_GetLCDCapPtr(pVBInfo);
1763 tempal = pVBInfo->LCDCapList[index].LCD_VCLK;
1765 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))
1769 if (pVBInfo->VBType &
1775 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
1776 tempal = TVCLKBASE_315 + HiTVVCLKDIV2;
1777 if (!(pVBInfo->TVInfo & RPLLDIV2XO))
1778 tempal = TVCLKBASE_315 + HiTVVCLK;
1779 if (pVBInfo->TVInfo & TVSimuMode) {
1780 tempal = TVCLKBASE_315 + HiTVSimuVCLK;
1781 if (!(modeflag & Charx8Dot))
1782 tempal = TVCLKBASE_315 +
1789 if (pVBInfo->TVInfo & TVSetYPbPr750p) {
1790 tempal = XGI_YPbPr750pVCLK;
1794 if (pVBInfo->TVInfo & TVSetYPbPr525p) {
1795 tempal = YPbPr525pVCLK;
1799 tempal = NTSC1024VCLK;
1801 if (!(pVBInfo->TVInfo & NTSC1024x768)) {
1802 tempal = TVCLKBASE_315 + TVVCLKDIV2;
1803 if (!(pVBInfo->TVInfo & RPLLDIV2XO))
1804 tempal = TVCLKBASE_315 + TVVCLK;
1807 if (pVBInfo->VBInfo & SetCRT2ToTV)
1812 tempal = (unsigned char) inb((pVBInfo->P3ca + 0x02));
1813 tempal = tempal >> 2;
1816 /* for Dot8 Scaling LCD */
1817 if ((pVBInfo->LCDInfo & EnableScalingLCD) && (modeflag & Charx8Dot))
1818 tempal = tempal ^ tempal; /* ; set to VCLK25MHz always */
1820 tempal = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1824 static void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0,
1825 unsigned char *di_1, struct vb_device_info *pVBInfo)
1827 if (pVBInfo->VBType & (VB_SIS301 | VB_SIS301B | VB_SIS302B
1828 | VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) {
1829 if ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) &&
1830 (pVBInfo->SetFlag & ProgrammingCRT2)) {
1831 *di_0 = XGI_VBVCLKData[tempal].Part4_A;
1832 *di_1 = XGI_VBVCLKData[tempal].Part4_B;
1835 *di_0 = XGI_VCLKData[tempal].SR2B;
1836 *di_1 = XGI_VCLKData[tempal].SR2C;
1840 static void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex,
1841 unsigned short RefreshRateTableIndex,
1842 struct vb_device_info *pVBInfo)
1844 unsigned char di_0, di_1, tempal;
1847 tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex,
1849 XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo);
1850 XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo);
1852 for (i = 0; i < 4; i++) {
1853 xgifb_reg_and_or(pVBInfo->P3d4, 0x31, ~0x30,
1854 (unsigned short) (0x10 * i));
1855 if ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA))
1856 && (!(pVBInfo->VBInfo & SetInSlaveMode))) {
1857 xgifb_reg_set(pVBInfo->P3c4, 0x2e, di_0);
1858 xgifb_reg_set(pVBInfo->P3c4, 0x2f, di_1);
1860 xgifb_reg_set(pVBInfo->P3c4, 0x2b, di_0);
1861 xgifb_reg_set(pVBInfo->P3c4, 0x2c, di_1);
1866 static void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension,
1867 struct vb_device_info *pVBInfo)
1869 unsigned short tempcl, tempch, temp, tempbl, tempax;
1871 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
1872 | VB_SIS302LV | VB_XGI301C)) {
1875 temp = xgifb_reg_get(pVBInfo->P3c4, 0x01);
1877 if (!(temp & 0x20)) {
1878 temp = xgifb_reg_get(pVBInfo->P3d4, 0x17);
1880 temp = xgifb_reg_get(pVBInfo->P3d4, 0x53);
1882 tempcl |= ActiveCRT1;
1886 temp = xgifb_reg_get(pVBInfo->Part1Port, 0x2e);
1889 if (!(temp == 0x08)) {
1890 /* Check ChannelA */
1891 tempax = xgifb_reg_get(pVBInfo->Part1Port, 0x13);
1893 tempcl = tempcl | ActiveLCD;
1897 if (!(tempcl & ActiveLCD))
1899 tempcl |= ActiveCRT2;
1902 tempcl |= ActiveLCD;
1905 temp = xgifb_reg_get(pVBInfo->Part2Port, 0x00);
1908 tempch |= ActiveAVideo;
1911 tempch |= ActiveSVideo;
1914 tempch |= ActiveSCART;
1916 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
1918 tempch |= ActiveHiTV;
1921 if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
1922 temp = xgifb_reg_get(
1927 tempch |= ActiveYPbPr;
1935 temp = xgifb_reg_get(pVBInfo->P3d4, 0x3d);
1936 if (tempcl & ActiveLCD) {
1937 if ((pVBInfo->SetFlag & ReserveTVOption)) {
1938 if (temp & ActiveTV)
1943 tempbl = ~XGI_ModeSwitchStatus;
1944 xgifb_reg_and_or(pVBInfo->P3d4, 0x3d, tempbl, temp);
1946 if (!(pVBInfo->SetFlag & ReserveTVOption))
1947 xgifb_reg_set(pVBInfo->P3d4, 0x3e, tempch);
1953 void XGI_GetVBType(struct vb_device_info *pVBInfo)
1955 unsigned short flag, tempbx, tempah;
1957 if (pVBInfo->IF_DEF_LVDS != 0)
1960 tempbx = VB_SIS302B;
1961 flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00);
1966 flag = xgifb_reg_get(pVBInfo->Part4Port, 0x01);
1970 tempbx = VB_SIS301B;
1972 goto bigger_than_0xB0;
1974 tempbx = VB_XGI301C;
1976 goto bigger_than_0xB0;
1978 tempbx = VB_SIS301LV;
1980 goto bigger_than_0xB0;
1982 tempbx = VB_SIS302LV;
1983 tempah = xgifb_reg_get(pVBInfo->Part4Port, 0x39);
1985 tempbx = VB_XGI301C;
1988 if (tempbx & (VB_SIS301B | VB_SIS302B)) {
1989 flag = xgifb_reg_get(pVBInfo->Part4Port, 0x23);
1991 tempbx = tempbx | VB_NoLCD;
1995 pVBInfo->VBType = tempbx;
1998 static void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
1999 struct xgi_hw_device_info *HwDeviceExtension,
2000 struct vb_device_info *pVBInfo)
2002 unsigned short tempax, push, tempbx, temp, modeflag;
2004 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2005 pVBInfo->SetFlag = 0;
2006 pVBInfo->ModeType = modeflag & ModeTypeMask;
2009 if (!(pVBInfo->VBType & 0xFFFF))
2012 /* Check Display Device */
2013 temp = xgifb_reg_get(pVBInfo->P3d4, 0x30);
2014 tempbx = tempbx | temp;
2015 temp = xgifb_reg_get(pVBInfo->P3d4, 0x31);
2019 tempbx = tempbx | tempax;
2020 temp = (SetCRT2ToDualEdge | SetCRT2ToYPbPr525750 | XGI_SetCRT2ToLCDA
2021 | SetInSlaveMode | DisableCRT2Display);
2022 temp = 0xFFFF ^ temp;
2025 temp = xgifb_reg_get(pVBInfo->P3d4, 0x38);
2027 if (pVBInfo->IF_DEF_LVDS == 0) {
2028 if (pVBInfo->VBType &
2033 if (temp & EnableDualEdge) {
2034 tempbx |= SetCRT2ToDualEdge;
2035 if (temp & SetToLCDA)
2036 tempbx |= XGI_SetCRT2ToLCDA;
2041 if (pVBInfo->IF_DEF_YPbPr == 1) {
2042 if (((pVBInfo->IF_DEF_LVDS == 0) &&
2043 ((pVBInfo->VBType & VB_SIS301LV) ||
2044 (pVBInfo->VBType & VB_SIS302LV) ||
2045 (pVBInfo->VBType & VB_XGI301C)))) {
2046 if (temp & SetYPbPr) {
2047 if (pVBInfo->IF_DEF_HiVision == 1) {
2048 /* shampoo add for new
2050 temp = xgifb_reg_get(
2054 tempbx |= SetCRT2ToHiVision;
2056 if (temp != YPbPrMode1080i) {
2058 (~SetCRT2ToHiVision);
2060 SetCRT2ToYPbPr525750;
2067 tempax = push; /* restore CR31 */
2069 if (pVBInfo->IF_DEF_LVDS == 0) {
2070 if (pVBInfo->IF_DEF_YPbPr == 1) {
2071 if (pVBInfo->IF_DEF_HiVision == 1)
2075 } else if (pVBInfo->IF_DEF_HiVision == 1) {
2080 } else { /* 3rd party chip */
2081 temp = SetCRT2ToLCD;
2084 if (!(tempbx & temp)) {
2085 tempax |= DisableCRT2Display;
2089 if (!(pVBInfo->VBType & VB_NoLCD)) {
2090 if (tempbx & XGI_SetCRT2ToLCDA) {
2091 if (tempbx & SetSimuScanMode)
2092 tempbx &= (~(SetCRT2ToLCD |
2096 tempbx &= (~(SetCRT2ToLCD |
2104 /* for driver abnormal */
2105 if (!(tempbx & (SwitchCRT2 | SetSimuScanMode))) {
2106 if (pVBInfo->IF_DEF_CRT2Monitor == 1) {
2107 if (tempbx & SetCRT2ToRAMDAC) {
2112 tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750));
2115 tempbx &= (~(SetCRT2ToRAMDAC |
2121 if (!(pVBInfo->VBType & VB_NoLCD)) {
2122 if (tempbx & SetCRT2ToLCD) {
2127 tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750));
2131 if (tempbx & SetCRT2ToSCART) {
2136 tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750));
2139 if (pVBInfo->IF_DEF_YPbPr == 1) {
2140 if (tempbx & SetCRT2ToYPbPr525750)
2146 if (pVBInfo->IF_DEF_HiVision == 1) {
2147 if (tempbx & SetCRT2ToHiVision)
2154 if (tempax & DisableCRT2Display) { /* Set Display Device Info */
2155 if (!(tempbx & (SwitchCRT2 | SetSimuScanMode)))
2156 tempbx = DisableCRT2Display;
2159 if (!(tempbx & DisableCRT2Display)) {
2160 if ((!(tempbx & DriverMode)) ||
2161 (!(modeflag & CRT2Mode))) {
2162 if (!(tempbx & XGI_SetCRT2ToLCDA))
2163 tempbx |= (SetInSlaveMode |
2167 /* LCD+TV can't support in slave mode
2168 * (Force LCDA+TV->LCDB) */
2169 if ((tempbx & SetInSlaveMode) &&
2170 (tempbx & XGI_SetCRT2ToLCDA)) {
2171 tempbx ^= (SetCRT2ToLCD |
2174 pVBInfo->SetFlag |= ReserveTVOption;
2178 pVBInfo->VBInfo = tempbx;
2181 static void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
2182 struct vb_device_info *pVBInfo)
2184 unsigned short tempbx = 0, resinfo = 0, modeflag, index1;
2186 if (pVBInfo->VBInfo & SetCRT2ToTV) {
2187 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2188 resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO;
2190 tempbx = xgifb_reg_get(pVBInfo->P3d4, 0x35);
2191 if (tempbx & TVSetPAL) {
2192 tempbx &= (SetCHTVOverScan |
2196 if (tempbx & TVSetPALM)
2197 /* set to NTSC if PAL-M */
2198 tempbx &= ~TVSetPAL;
2200 tempbx &= (SetCHTVOverScan |
2204 if (pVBInfo->IF_DEF_LVDS == 0) {
2205 if (pVBInfo->VBInfo & SetCRT2ToSCART)
2209 if (pVBInfo->IF_DEF_YPbPr == 1) {
2210 if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
2211 index1 = xgifb_reg_get(pVBInfo->P3d4, 0x35);
2212 index1 &= YPbPrMode;
2214 if (index1 == YPbPrMode525i)
2215 tempbx |= TVSetYPbPr525i;
2217 if (index1 == YPbPrMode525p)
2218 tempbx = tempbx | TVSetYPbPr525p;
2219 if (index1 == YPbPrMode750p)
2220 tempbx = tempbx | TVSetYPbPr750p;
2224 if (pVBInfo->IF_DEF_HiVision == 1) {
2225 if (pVBInfo->VBInfo & SetCRT2ToHiVision)
2226 tempbx = tempbx | TVSetHiVision | TVSetPAL;
2229 if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */
2230 if ((pVBInfo->VBInfo & SetInSlaveMode) &&
2231 (!(pVBInfo->VBInfo & SetNotSimuMode)))
2232 tempbx |= TVSimuMode;
2234 if (!(tempbx & TVSetPAL) &&
2236 (resinfo == 8)) /* NTSC 1024x768, */
2237 tempbx |= NTSC1024x768;
2239 tempbx |= RPLLDIV2XO;
2241 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
2242 if (pVBInfo->VBInfo & SetInSlaveMode)
2243 tempbx &= (~RPLLDIV2XO);
2245 (TVSetYPbPr525p | TVSetYPbPr750p)) {
2246 tempbx &= (~RPLLDIV2XO);
2247 } else if (!(pVBInfo->VBType &
2253 if (tempbx & TVSimuMode)
2254 tempbx &= (~RPLLDIV2XO);
2258 pVBInfo->TVInfo = tempbx;
2261 static unsigned char XGI_GetLCDInfo(unsigned short ModeNo,
2262 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
2264 unsigned short temp, tempax, tempbx, resinfo = 0, LCDIdIndex;
2266 pVBInfo->LCDResInfo = 0;
2267 pVBInfo->LCDTypeInfo = 0;
2268 pVBInfo->LCDInfo = 0;
2270 /* si+Ext_ResInfo // */
2271 resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO;
2272 temp = xgifb_reg_get(pVBInfo->P3d4, 0x36); /* Get LCD Res.Info */
2273 tempbx = temp & 0x0F;
2276 tempbx = Panel_1024x768; /* default */
2279 if ((tempbx == Panel_1024x768) || (tempbx == Panel_1280x1024)) {
2280 if (pVBInfo->VBInfo & DriverMode) {
2281 tempax = xgifb_reg_get(pVBInfo->P3d4, 0x33);
2282 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)
2285 tempax = tempax >> 4;
2287 if ((resinfo == 6) || (resinfo == 9)) {
2289 tempbx |= PanelRef75Hz;
2290 } else if ((resinfo == 7) || (resinfo == 8)) {
2292 tempbx |= PanelRef75Hz;
2297 pVBInfo->LCDResInfo = tempbx;
2301 if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)))
2306 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
2308 temp &= (ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable);
2312 LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo);
2314 tempax = pVBInfo->LCDCapList[LCDIdIndex].LCD_Capability;
2316 if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */
2317 if (((pVBInfo->VBType & VB_SIS302LV) || (pVBInfo->VBType
2318 & VB_XGI301C)) && (tempax & XGI_LCDDualLink)) {
2319 tempbx |= SetLCDDualLink;
2323 if (pVBInfo->IF_DEF_LVDS == 0) {
2324 if ((pVBInfo->LCDResInfo == Panel_1400x1050) && (pVBInfo->VBInfo
2325 & SetCRT2ToLCD) && (resinfo == 9) &&
2326 (!(tempbx & EnableScalingLCD)))
2328 * set to center in 1280x1024 LCDB
2329 * for Panel_1400x1050
2331 tempbx |= SetLCDtoNonExpanding;
2334 if (pVBInfo->VBInfo & SetInSlaveMode) {
2335 if (pVBInfo->VBInfo & SetNotSimuMode)
2336 tempbx |= XGI_LCDVESATiming;
2338 tempbx |= XGI_LCDVESATiming;
2341 pVBInfo->LCDInfo = tempbx;
2346 unsigned char XGI_SearchModeID(unsigned short ModeNo,
2347 unsigned short *ModeIdIndex, struct vb_device_info *pVBInfo)
2349 for (*ModeIdIndex = 0;; (*ModeIdIndex)++) {
2350 if (XGI330_EModeIDTable[*ModeIdIndex].Ext_ModeID == ModeNo)
2352 if (XGI330_EModeIDTable[*ModeIdIndex].Ext_ModeID == 0xFF)
2359 static unsigned char XG21GPIODataTransfer(unsigned char ujDate)
2361 unsigned char ujRet = 0;
2362 unsigned char i = 0;
2364 for (i = 0; i < 8; i++) {
2366 ujRet |= (ujDate >> i) & 1;
2372 /*----------------------------------------------------------------------------*/
2374 /* bl[5] : LVDS signal */
2375 /* bl[1] : LVDS backlight */
2376 /* bl[0] : LVDS VDD */
2377 /*----------------------------------------------------------------------------*/
2378 static unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo)
2380 unsigned char CR4A, temp;
2382 CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
2383 xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x23); /* enable GPIO write */
2385 temp = xgifb_reg_get(pVBInfo->P3d4, 0x48);
2387 temp = XG21GPIODataTransfer(temp);
2389 xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A);
2393 /*----------------------------------------------------------------------------*/
2395 /* bl[5] : LVDS signal */
2396 /* bl[1] : LVDS backlight */
2397 /* bl[0] : LVDS VDD */
2398 /*----------------------------------------------------------------------------*/
2399 static unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo)
2401 unsigned char CR4A, CRB4, temp;
2403 CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
2404 xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x0C); /* enable GPIO write */
2406 temp = xgifb_reg_get(pVBInfo->P3d4, 0x48);
2410 xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A);
2411 CRB4 = xgifb_reg_get(pVBInfo->P3d4, 0xB4);
2412 temp |= ((CRB4 & 0x04) << 3);
2416 /*----------------------------------------------------------------------------*/
2418 /* bl[5] : 1;LVDS signal on */
2419 /* bl[1] : 1;LVDS backlight on */
2420 /* bl[0] : 1:LVDS VDD on */
2421 /* bh: 100000b : clear bit 5, to set bit5 */
2422 /* 000010b : clear bit 1, to set bit1 */
2423 /* 000001b : clear bit 0, to set bit0 */
2424 /*----------------------------------------------------------------------------*/
2425 static void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl,
2426 struct vb_device_info *pVBInfo)
2428 unsigned char CR4A, temp;
2430 CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
2433 xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */
2435 if (tempbh & 0x20) {
2436 temp = (tempbl >> 4) & 0x02;
2439 xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp);
2443 temp = xgifb_reg_get(pVBInfo->P3d4, 0x48);
2445 temp = XG21GPIODataTransfer(temp);
2448 xgifb_reg_set(pVBInfo->P3d4, 0x48, temp);
2451 static void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl,
2452 struct vb_device_info *pVBInfo)
2454 unsigned char CR4A, temp;
2455 unsigned short tempbh0, tempbl0;
2464 if (tempbh & 0x20) {
2465 temp = (tempbl >> 4) & 0x02;
2468 xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp);
2471 xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~tempbh0, tempbl0);
2473 CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
2477 tempbl <<= 2; /* GPIOC,GPIOD */
2478 xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */
2479 xgifb_reg_and_or(pVBInfo->P3d4, 0x48, ~tempbh, tempbl);
2482 static void XGI_DisplayOn(struct xgifb_video_info *xgifb_info,
2483 struct xgi_hw_device_info *pXGIHWDE,
2484 struct vb_device_info *pVBInfo)
2487 xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x00);
2488 if (pXGIHWDE->jChipType == XG21) {
2489 if (pVBInfo->IF_DEF_LVDS == 1) {
2490 if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x1)) {
2492 XGI_XG21BLSignalVDD(0x01, 0x01, pVBInfo);
2493 mdelay(xgifb_info->lvds_data.PSC_S2);
2495 if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x20))
2496 /* LVDS signal on */
2497 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo);
2498 mdelay(xgifb_info->lvds_data.PSC_S3);
2499 /* LVDS backlight on */
2500 XGI_XG21BLSignalVDD(0x02, 0x02, pVBInfo);
2502 /* DVO/DVI signal on */
2503 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo);
2508 if (pXGIHWDE->jChipType == XG27) {
2509 if (pVBInfo->IF_DEF_LVDS == 1) {
2510 if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x1)) {
2512 XGI_XG27BLSignalVDD(0x01, 0x01, pVBInfo);
2513 mdelay(xgifb_info->lvds_data.PSC_S2);
2515 if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x20))
2516 /* LVDS signal on */
2517 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo);
2518 mdelay(xgifb_info->lvds_data.PSC_S3);
2519 /* LVDS backlight on */
2520 XGI_XG27BLSignalVDD(0x02, 0x02, pVBInfo);
2522 /* DVO/DVI signal on */
2523 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo);
2529 void XGI_DisplayOff(struct xgifb_video_info *xgifb_info,
2530 struct xgi_hw_device_info *pXGIHWDE,
2531 struct vb_device_info *pVBInfo)
2534 if (pXGIHWDE->jChipType == XG21) {
2535 if (pVBInfo->IF_DEF_LVDS == 1) {
2536 /* LVDS backlight off */
2537 XGI_XG21BLSignalVDD(0x02, 0x00, pVBInfo);
2538 mdelay(xgifb_info->lvds_data.PSC_S3);
2540 /* DVO/DVI signal off */
2541 XGI_XG21BLSignalVDD(0x20, 0x00, pVBInfo);
2545 if (pXGIHWDE->jChipType == XG27) {
2546 if ((XGI_XG27GetPSCValue(pVBInfo) & 0x2)) {
2547 /* LVDS backlight off */
2548 XGI_XG27BLSignalVDD(0x02, 0x00, pVBInfo);
2549 mdelay(xgifb_info->lvds_data.PSC_S3);
2552 if (pVBInfo->IF_DEF_LVDS == 0)
2553 /* DVO/DVI signal off */
2554 XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo);
2557 xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x20);
2560 static void XGI_WaitDisply(struct vb_device_info *pVBInfo)
2562 while ((inb(pVBInfo->P3da) & 0x01))
2565 while (!(inb(pVBInfo->P3da) & 0x01))
2569 static void XGI_AutoThreshold(struct vb_device_info *pVBInfo)
2571 xgifb_reg_or(pVBInfo->Part1Port, 0x01, 0x40);
2574 static void XGI_SaveCRT2Info(unsigned short ModeNo,
2575 struct vb_device_info *pVBInfo)
2577 unsigned short temp1, temp2;
2579 /* reserve CR34 for CRT1 Mode No */
2580 xgifb_reg_set(pVBInfo->P3d4, 0x34, ModeNo);
2581 temp1 = (pVBInfo->VBInfo & SetInSlaveMode) >> 8;
2582 temp2 = ~(SetInSlaveMode >> 8);
2583 xgifb_reg_and_or(pVBInfo->P3d4, 0x31, temp2, temp1);
2586 static void XGI_GetCRT2ResInfo(unsigned short ModeNo,
2587 unsigned short ModeIdIndex,
2588 struct vb_device_info *pVBInfo)
2590 unsigned short xres, yres, modeflag, resindex;
2592 resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO;
2593 xres = XGI330_ModeResInfo[resindex].HTotal; /* xres->ax */
2594 yres = XGI330_ModeResInfo[resindex].VTotal; /* yres->bx */
2595 /* si+St_ModeFlag */
2596 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2598 if (modeflag & HalfDCLK)
2601 if (modeflag & DoubleScanMode)
2604 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
2607 if (pVBInfo->IF_DEF_LVDS == 0) {
2608 if (pVBInfo->LCDResInfo == Panel_1600x1200) {
2609 if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
2615 if (pVBInfo->LCDResInfo == Panel_1280x1024) {
2618 else if (yres == 350)
2621 if (pVBInfo->LCDInfo & XGI_LCDVESATiming) {
2627 if (pVBInfo->LCDResInfo == Panel_1024x768) {
2628 if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
2629 if (!(pVBInfo->LCDInfo & LCDNonExpanding)) {
2632 else if (yres == 400)
2634 else if (yres == 480)
2645 pVBInfo->VGAHDE = xres;
2646 pVBInfo->HDE = xres;
2647 pVBInfo->VGAVDE = yres;
2648 pVBInfo->VDE = yres;
2651 static unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo)
2654 if ((pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) &&
2655 (pVBInfo->LCDInfo & SetLCDDualLink)) /* shampoo0129 */
2661 static void XGI_GetRAMDAC2DATA(unsigned short ModeNo,
2662 unsigned short ModeIdIndex,
2663 unsigned short RefreshRateTableIndex,
2664 struct vb_device_info *pVBInfo)
2666 unsigned short tempax, tempbx, temp1, temp2, modeflag = 0, tempcx,
2669 pVBInfo->RVBHCMAX = 1;
2670 pVBInfo->RVBHCFACT = 1;
2671 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2672 CRT1Index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
2673 CRT1Index &= IndexMask;
2674 temp1 = (unsigned short) XGI_CRT1Table[CRT1Index].CR[0];
2675 temp2 = (unsigned short) XGI_CRT1Table[CRT1Index].CR[5];
2676 tempax = (temp1 & 0xFF) | ((temp2 & 0x03) << 8);
2677 tempbx = (unsigned short) XGI_CRT1Table[CRT1Index].CR[8];
2678 tempcx = (unsigned short)
2679 XGI_CRT1Table[CRT1Index].CR[14] << 8;
2681 tempcx = tempcx << 2;
2683 temp1 = (unsigned short) XGI_CRT1Table[CRT1Index].CR[9];
2692 if (modeflag & Charx8Dot)
2697 pVBInfo->VGAHT = tempax;
2698 pVBInfo->HT = tempax;
2700 pVBInfo->VGAVT = tempbx;
2701 pVBInfo->VT = tempbx;
2704 static void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex,
2705 unsigned short RefreshRateTableIndex,
2706 struct vb_device_info *pVBInfo)
2708 unsigned short tempax = 0, tempbx = 0, modeflag, resinfo;
2710 struct SiS_LCDData const *LCDPtr = NULL;
2712 /* si+Ext_ResInfo */
2713 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2714 resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO;
2715 pVBInfo->NewFlickerMode = 0;
2716 pVBInfo->RVBHRS = 50;
2718 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
2719 XGI_GetRAMDAC2DATA(ModeNo, ModeIdIndex, RefreshRateTableIndex,
2724 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
2725 LCDPtr = XGI_GetLcdPtr(XGI_LCDDataTable, ModeNo, ModeIdIndex,
2726 RefreshRateTableIndex, pVBInfo);
2728 pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX;
2729 pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT;
2730 pVBInfo->VGAHT = LCDPtr->VGAHT;
2731 pVBInfo->VGAVT = LCDPtr->VGAVT;
2732 pVBInfo->HT = LCDPtr->LCDHT;
2733 pVBInfo->VT = LCDPtr->LCDVT;
2735 if (pVBInfo->LCDResInfo == Panel_1024x768) {
2739 if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
2740 if (pVBInfo->VGAVDE == 357)
2742 else if (pVBInfo->VGAVDE == 420)
2744 else if (pVBInfo->VGAVDE == 525)
2746 else if (pVBInfo->VGAVDE == 600)
2752 } else if (pVBInfo->LCDResInfo == Panel_1024x768x75) {
2755 } else if (pVBInfo->LCDResInfo == Panel_1280x1024) {
2757 if (pVBInfo->VGAVDE == 360)
2759 else if (pVBInfo->VGAVDE == 375)
2761 else if (pVBInfo->VGAVDE == 405)
2765 } else if (pVBInfo->LCDResInfo == Panel_1280x1024x75) {
2768 } else if (pVBInfo->LCDResInfo == Panel_1280x960) {
2770 if (pVBInfo->VGAVDE == 350)
2772 else if (pVBInfo->VGAVDE == 400)
2774 else if (pVBInfo->VGAVDE == 1024)
2778 } else if (pVBInfo->LCDResInfo == Panel_1400x1050) {
2782 if (pVBInfo->VGAVDE == 1024) {
2786 } else if (pVBInfo->LCDResInfo == Panel_1600x1200) {
2788 tempbx = 1200; /* alan 10/14/2003 */
2789 if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
2790 if (pVBInfo->VGAVDE == 350)
2792 else if (pVBInfo->VGAVDE == 400)
2797 if (pVBInfo->LCDInfo & LCDNonExpanding) {
2798 tempax = pVBInfo->VGAHDE;
2799 tempbx = pVBInfo->VGAVDE;
2802 pVBInfo->HDE = tempax;
2803 pVBInfo->VDE = tempbx;
2807 if (pVBInfo->VBInfo & (SetCRT2ToTV)) {
2808 struct SiS_TVData const *TVPtr;
2810 TVPtr = XGI_GetTVPtr(ModeNo, ModeIdIndex, RefreshRateTableIndex,
2813 pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX;
2814 pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT;
2815 pVBInfo->VGAHT = TVPtr->VGAHT;
2816 pVBInfo->VGAVT = TVPtr->VGAVT;
2817 pVBInfo->HDE = TVPtr->TVHDE;
2818 pVBInfo->VDE = TVPtr->TVVDE;
2819 pVBInfo->RVBHRS = TVPtr->RVBHRS;
2820 pVBInfo->NewFlickerMode = TVPtr->FlickerMode;
2822 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
2823 if (resinfo == 0x08)
2824 pVBInfo->NewFlickerMode = 0x40;
2825 else if (resinfo == 0x09)
2826 pVBInfo->NewFlickerMode = 0x40;
2827 else if (resinfo == 0x12)
2828 pVBInfo->NewFlickerMode = 0x40;
2830 if (pVBInfo->VGAVDE == 350)
2831 pVBInfo->TVInfo |= TVSimuMode;
2836 if (pVBInfo->VBInfo & SetInSlaveMode) {
2837 if (pVBInfo->TVInfo & TVSimuMode) {
2841 if (!(modeflag & Charx8Dot)) {
2842 tempax = StHiTextTVHT;
2843 tempbx = StHiTextTVVT;
2847 } else if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
2848 if (pVBInfo->TVInfo & TVSetYPbPr750p) {
2849 tempax = YPbPrTV750pHT; /* Ext750pTVHT */
2850 tempbx = YPbPrTV750pVT; /* Ext750pTVVT */
2853 if (pVBInfo->TVInfo & TVSetYPbPr525p) {
2854 tempax = YPbPrTV525pHT; /* Ext525pTVHT */
2855 tempbx = YPbPrTV525pVT; /* Ext525pTVVT */
2856 } else if (pVBInfo->TVInfo & TVSetYPbPr525i) {
2857 tempax = YPbPrTV525iHT; /* Ext525iTVHT */
2858 tempbx = YPbPrTV525iVT; /* Ext525iTVVT */
2859 if (pVBInfo->TVInfo & NTSC1024x768)
2860 tempax = NTSC1024x768HT;
2865 if (!(pVBInfo->TVInfo & TVSetPAL)) {
2868 if (pVBInfo->TVInfo & NTSC1024x768)
2869 tempax = NTSC1024x768HT;
2873 pVBInfo->HT = tempax;
2874 pVBInfo->VT = tempbx;
2879 static void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex,
2880 unsigned short RefreshRateTableIndex,
2881 struct vb_device_info *pVBInfo)
2883 unsigned char di_0, di_1, tempal;
2885 tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex,
2887 XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo);
2888 XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo);
2890 if (pVBInfo->VBType & VB_SIS301) { /* shampoo 0129 */
2892 xgifb_reg_set(pVBInfo->Part4Port, 0x0A, 0x10);
2893 xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1);
2894 xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0);
2895 } else { /* 301b/302b/301lv/302lv */
2896 xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0);
2897 xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1);
2900 xgifb_reg_set(pVBInfo->Part4Port, 0x00, 0x12);
2902 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC)
2903 xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x28);
2905 xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x08);
2908 static unsigned short XGI_GetColorDepth(unsigned short ModeNo,
2909 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
2911 unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8 };
2913 unsigned short modeflag;
2915 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2916 index = (modeflag & ModeTypeMask) - ModeEGA;
2921 return ColorDepth[index];
2924 static unsigned short XGI_GetOffset(unsigned short ModeNo,
2925 unsigned short ModeIdIndex,
2926 unsigned short RefreshRateTableIndex,
2927 struct xgi_hw_device_info *HwDeviceExtension,
2928 struct vb_device_info *pVBInfo)
2930 unsigned short temp, colordepth, modeinfo, index, infoflag,
2931 ColorDepth[] = { 0x01, 0x02, 0x04 };
2933 modeinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeInfo;
2934 infoflag = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
2936 index = (modeinfo >> 8) & 0xFF;
2938 temp = XGI330_ScreenOffset[index];
2940 if (infoflag & InterlaceMode)
2943 colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo);
2945 if ((ModeNo >= 0x7C) && (ModeNo <= 0x7E)) {
2946 temp = ModeNo - 0x7C;
2947 colordepth = ColorDepth[temp];
2949 if (infoflag & InterlaceMode)
2951 return temp * colordepth;
2953 return temp * colordepth;
2957 static void XGI_SetCRT2Offset(unsigned short ModeNo,
2958 unsigned short ModeIdIndex,
2959 unsigned short RefreshRateTableIndex,
2960 struct xgi_hw_device_info *HwDeviceExtension,
2961 struct vb_device_info *pVBInfo)
2963 unsigned short offset;
2966 if (pVBInfo->VBInfo & SetInSlaveMode)
2969 offset = XGI_GetOffset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
2970 HwDeviceExtension, pVBInfo);
2971 temp = (unsigned char) (offset & 0xFF);
2972 xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp);
2973 temp = (unsigned char) ((offset & 0xFF00) >> 8);
2974 xgifb_reg_set(pVBInfo->Part1Port, 0x09, temp);
2975 temp = (unsigned char) (((offset >> 3) & 0xFF) + 1);
2976 xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp);
2979 static void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo)
2981 /* threshold high ,disable auto threshold */
2982 xgifb_reg_set(pVBInfo->Part1Port, 0x01, 0x3B);
2983 /* threshold low default 04h */
2984 xgifb_reg_and_or(pVBInfo->Part1Port, 0x02, ~(0x3F), 0x04);
2987 static void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
2988 struct xgi_hw_device_info *HwDeviceExtension,
2989 unsigned short RefreshRateTableIndex,
2990 struct vb_device_info *pVBInfo)
2994 XGI_SetCRT2Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
2995 HwDeviceExtension, pVBInfo);
2996 XGI_SetCRT2FIFO(pVBInfo);
2998 for (tempcx = 4; tempcx < 7; tempcx++)
2999 xgifb_reg_set(pVBInfo->Part1Port, tempcx, 0x0);
3001 xgifb_reg_set(pVBInfo->Part1Port, 0x50, 0x00);
3002 xgifb_reg_set(pVBInfo->Part1Port, 0x02, 0x44); /* temp 0206 */
3005 static void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
3006 struct xgi_hw_device_info *HwDeviceExtension,
3007 unsigned short RefreshRateTableIndex,
3008 struct vb_device_info *pVBInfo)
3010 unsigned short temp = 0, tempax = 0, tempbx = 0, tempcx = 0,
3011 pushbx = 0, CRT1Index, modeflag;
3013 CRT1Index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
3014 CRT1Index &= IndexMask;
3015 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3017 /* bainy change table name */
3018 if (modeflag & HalfDCLK) {
3019 /* BTVGA2HT 0x08,0x09 */
3020 temp = (pVBInfo->VGAHT / 2 - 1) & 0x0FF;
3021 xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp);
3022 temp = (((pVBInfo->VGAHT / 2 - 1) & 0xFF00) >> 8) << 4;
3023 xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp);
3024 /* BTVGA2HDEE 0x0A,0x0C */
3025 temp = (pVBInfo->VGAHDE / 2 + 16) & 0x0FF;
3026 xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp);
3027 tempcx = ((pVBInfo->VGAHT - pVBInfo->VGAHDE) / 2) >> 2;
3028 pushbx = pVBInfo->VGAHDE / 2 + 16;
3029 tempcx = tempcx >> 1;
3030 tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */
3033 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
3034 tempbx = XGI_CRT1Table[CRT1Index].CR[4];
3035 tempbx |= ((XGI_CRT1Table[CRT1Index].CR[14] &
3037 tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */
3038 tempcx = XGI_CRT1Table[CRT1Index].CR[5];
3040 temp = XGI_CRT1Table[CRT1Index].CR[15];
3041 temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */
3042 tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */
3048 if (tempcx > (pVBInfo->VGAHT / 2))
3049 tempcx = pVBInfo->VGAHT / 2;
3051 temp = tempbx & 0x00FF;
3053 xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp);
3055 temp = (pVBInfo->VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */
3056 xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp);
3057 temp = (((pVBInfo->VGAHT - 1) & 0xFF00) >> 8) << 4;
3058 xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp);
3059 /* BTVGA2HDEE 0x0A,0x0C */
3060 temp = (pVBInfo->VGAHDE + 16) & 0x0FF;
3061 xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp);
3062 tempcx = (pVBInfo->VGAHT - pVBInfo->VGAHDE) >> 2; /* cx */
3063 pushbx = pVBInfo->VGAHDE + 16;
3064 tempcx = tempcx >> 1;
3065 tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */
3068 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
3069 tempbx = XGI_CRT1Table[CRT1Index].CR[3];
3070 tempbx |= ((XGI_CRT1Table[CRT1Index].CR[5] &
3072 tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */
3073 tempcx = XGI_CRT1Table[CRT1Index].CR[4];
3075 temp = XGI_CRT1Table[CRT1Index].CR[6];
3076 temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */
3077 tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */
3082 if (tempcx > pVBInfo->VGAHT)
3083 tempcx = pVBInfo->VGAHT;
3085 temp = tempbx & 0x00FF;
3086 xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp);
3089 tempax = (tempax & 0x00FF) | (tempbx & 0xFF00);
3091 tempbx = (tempbx & 0x00FF) | ((tempbx & 0xFF00) << 4);
3092 tempax |= (tempbx & 0xFF00);
3093 temp = (tempax & 0xFF00) >> 8;
3094 xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp);
3095 temp = tempcx & 0x00FF;
3096 xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp);
3097 tempcx = (pVBInfo->VGAVT - 1);
3098 temp = tempcx & 0x00FF;
3100 xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp);
3101 tempbx = pVBInfo->VGAVDE - 1;
3102 temp = tempbx & 0x00FF;
3103 xgifb_reg_set(pVBInfo->Part1Port, 0x0F, temp);
3104 temp = ((tempbx & 0xFF00) << 3) >> 8;
3105 temp |= ((tempcx & 0xFF00) >> 8);
3106 xgifb_reg_set(pVBInfo->Part1Port, 0x12, temp);
3108 tempax = pVBInfo->VGAVDE;
3109 tempbx = pVBInfo->VGAVDE;
3110 tempcx = pVBInfo->VGAVT;
3111 /* BTVGA2VRS 0x10,0x11 */
3112 tempbx = (pVBInfo->VGAVT + pVBInfo->VGAVDE) >> 1;
3113 /* BTVGA2VRE 0x11 */
3114 tempcx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) >> 4) + tempbx + 1;
3116 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
3117 tempbx = XGI_CRT1Table[CRT1Index].CR[10];
3118 temp = XGI_CRT1Table[CRT1Index].CR[9];
3126 temp = XGI_CRT1Table[CRT1Index].CR[14];
3131 temp = XGI_CRT1Table[CRT1Index].CR[11];
3132 tempcx = (tempcx & 0xFF00) | (temp & 0x00FF);
3135 temp = tempbx & 0x00FF;
3136 xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp);
3137 temp = ((tempbx & 0xFF00) >> 8) << 4;
3138 temp = ((tempcx & 0x000F) | (temp));
3139 xgifb_reg_set(pVBInfo->Part1Port, 0x11, temp);
3142 if (modeflag & DoubleScanMode)
3145 if (modeflag & HalfDCLK)
3148 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2C, ~0x0C0, tempax);
3151 static unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo)
3153 unsigned long tempax, tempbx;
3155 tempbx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) * pVBInfo->RVBHCMAX)
3157 tempax = (pVBInfo->VT - pVBInfo->VDE) * pVBInfo->RVBHCFACT;
3158 tempax = (tempax * pVBInfo->HT) / tempbx;
3160 return (unsigned short) tempax;
3163 static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
3164 struct xgi_hw_device_info *HwDeviceExtension,
3165 unsigned short RefreshRateTableIndex,
3166 struct vb_device_info *pVBInfo)
3168 unsigned short push1, push2, tempax, tempbx = 0, tempcx, temp, resinfo,
3171 /* si+Ext_ResInfo */
3172 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3173 resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO;
3175 if (!(pVBInfo->VBInfo & SetInSlaveMode))
3178 temp = 0xFF; /* set MAX HT */
3179 xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp);
3182 if (pVBInfo->VBType & (VB_SIS301LV | VB_SIS302LV | VB_XGI301C))
3183 modeflag |= Charx8Dot;
3185 tempax = pVBInfo->VGAHDE; /* 0x04 Horizontal Display End */
3187 if (modeflag & HalfDCLK)
3188 tempax = tempax >> 1;
3190 tempax = (tempax / tempcx) - 1;
3191 tempbx |= ((tempax & 0x00FF) << 8);
3192 temp = tempax & 0x00FF;
3193 xgifb_reg_set(pVBInfo->Part1Port, 0x04, temp);
3195 temp = (tempbx & 0xFF00) >> 8;
3197 if (pVBInfo->VBInfo & SetCRT2ToTV) {
3198 if (!(pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
3199 | VB_SIS302LV | VB_XGI301C)))
3202 if ((pVBInfo->VBInfo & SetCRT2ToHiVision) &&
3203 !(pVBInfo->VBType & VB_SIS301LV) && (resinfo == 7))
3207 /* 0x05 Horizontal Display Start */
3208 xgifb_reg_set(pVBInfo->Part1Port, 0x05, temp);
3209 /* 0x06 Horizontal Blank end */
3210 xgifb_reg_set(pVBInfo->Part1Port, 0x06, 0x03);
3212 if (!(pVBInfo->VBInfo & DisableCRT2Display)) { /* 030226 bainy */
3213 if (pVBInfo->VBInfo & SetCRT2ToTV)
3214 tempax = pVBInfo->VGAHT;
3216 tempax = XGI_GetVGAHT2(pVBInfo);
3219 if (tempax >= pVBInfo->VGAHT)
3220 tempax = pVBInfo->VGAHT;
3222 if (modeflag & HalfDCLK)
3223 tempax = tempax >> 1;
3225 tempax = (tempax / tempcx) - 5;
3226 tempcx = tempax; /* 20030401 0x07 horizontal Retrace Start */
3227 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
3228 temp = (tempbx & 0x00FF) - 1;
3229 if (!(modeflag & HalfDCLK)) {
3231 if (pVBInfo->TVInfo & TVSimuMode) {
3237 tempbx = (tempbx & 0xFF00) >> 8;
3238 tempcx = (tempcx + tempbx) >> 1;
3239 temp = (tempcx & 0x00FF) + 2;
3241 if (pVBInfo->VBInfo & SetCRT2ToTV) {
3243 if (!(modeflag & HalfDCLK)) {
3244 if ((modeflag & Charx8Dot)) {
3246 if (pVBInfo->VGAHDE >= 800)
3250 } else if (!(modeflag & HalfDCLK)) {
3252 if (pVBInfo->LCDResInfo != Panel_1280x960 &&
3253 pVBInfo->VGAHDE >= 800) {
3255 if (pVBInfo->VGAHDE >= 1280 &&
3256 pVBInfo->LCDResInfo != Panel_1280x960 &&
3257 (pVBInfo->LCDInfo & LCDNonExpanding))
3263 /* 0x07 Horizontal Retrace Start */
3264 xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp);
3265 /* 0x08 Horizontal Retrace End */
3266 xgifb_reg_set(pVBInfo->Part1Port, 0x08, 0);
3268 if (pVBInfo->VBInfo & SetCRT2ToTV) {
3269 if (pVBInfo->TVInfo & TVSimuMode) {
3270 if (ModeNo == 0x50) {
3271 if (pVBInfo->TVInfo & SetNTSCTV) {
3272 xgifb_reg_set(pVBInfo->Part1Port,
3274 xgifb_reg_set(pVBInfo->Part1Port,
3277 xgifb_reg_set(pVBInfo->Part1Port,
3279 xgifb_reg_set(pVBInfo->Part1Port,
3286 xgifb_reg_set(pVBInfo->Part1Port, 0x18, 0x03); /* 0x18 SR0B */
3287 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0xF0, 0x00);
3288 xgifb_reg_set(pVBInfo->Part1Port, 0x09, 0xFF); /* 0x09 Set Max VT */
3290 tempbx = pVBInfo->VGAVT;
3293 tempbx = pVBInfo->VGAVDE; /* 0x0E Virtical Display End */
3308 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
3309 if (pVBInfo->LCDResInfo == Panel_1024x768) {
3310 if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
3319 temp = tempbx & 0x00FF;
3321 temp = tempbx & 0x00FF;
3322 /* 0x10 vertical Blank Start */
3323 xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp);
3326 temp = tempbx & 0x00FF;
3327 xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp);
3329 if (tempbx & 0x0100)
3334 if (modeflag & DoubleScanMode)
3337 if (tempbx & 0x0200)
3340 temp = (tempax & 0xFF00) >> 8;
3341 xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp);
3343 if (tempbx & 0x0400)
3346 /* 0x11 Vertival Blank End */
3347 xgifb_reg_set(pVBInfo->Part1Port, 0x11, 0x00);
3350 tempax -= tempbx; /* 0x0C Vertical Retrace Start */
3351 tempax = tempax >> 2;
3352 push1 = tempax; /* push ax */
3354 if (resinfo != 0x09) {
3355 tempax = tempax << 1;
3359 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
3360 if ((pVBInfo->VBType & VB_SIS301LV) &&
3361 !(pVBInfo->TVInfo & TVSetHiVision)) {
3362 if ((pVBInfo->TVInfo & TVSimuMode) &&
3363 (pVBInfo->TVInfo & TVSetPAL)) {
3364 if (!(pVBInfo->VBType & VB_SIS301LV) ||
3374 } else if (pVBInfo->TVInfo & TVSimuMode) {
3375 if (pVBInfo->TVInfo & TVSetPAL) {
3376 if (pVBInfo->VBType & VB_SIS301LV) {
3377 if (!(pVBInfo->TVInfo &
3388 tempax = tempax >> 2;
3391 push1 = tempax; /* push ax */
3393 if ((pVBInfo->TVInfo & TVSetPAL)) {
3394 if (tempbx <= 513) {
3400 temp = tempbx & 0x00FF;
3401 xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp);
3403 temp = tempbx & 0x00FF;
3404 xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp);
3406 if (tempbx & 0x0100)
3409 if (tempbx & 0x0200)
3410 xgifb_reg_and_or(pVBInfo->Part1Port, 0x0B, 0x0FF, 0x20);
3414 if (tempbx & 0x0100)
3417 if (tempbx & 0x0200)
3420 if (tempbx & 0x0400)
3423 tempbx = push1; /* pop ax */
3424 temp = tempbx & 0x00FF;
3426 /* 0x0D vertical Retrace End */
3427 xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp);
3429 if (tempbx & 0x0010)
3432 temp = tempcx & 0x00FF;
3433 xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); /* 0x0A CR07 */
3434 temp = (tempcx & 0x0FF00) >> 8;
3435 xgifb_reg_set(pVBInfo->Part1Port, 0x17, temp); /* 0x17 SR0A */
3437 temp = (tempax & 0xFF00) >> 8;
3439 temp = (temp >> 1) & 0x09;
3441 if (pVBInfo->VBType & (VB_SIS301LV | VB_SIS302LV | VB_XGI301C))
3444 xgifb_reg_set(pVBInfo->Part1Port, 0x16, temp); /* 0x16 SR01 */
3445 xgifb_reg_set(pVBInfo->Part1Port, 0x0F, 0); /* 0x0F CR14 */
3446 xgifb_reg_set(pVBInfo->Part1Port, 0x12, 0); /* 0x12 CR17 */
3448 if (pVBInfo->LCDInfo & LCDRGB18Bit)
3453 xgifb_reg_set(pVBInfo->Part1Port, 0x1A, temp); /* 0x1A SR0E */
3458 static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex,
3459 unsigned short RefreshRateTableIndex,
3460 struct xgi_hw_device_info *HwDeviceExtension,
3461 struct vb_device_info *pVBInfo)
3463 unsigned short i, j, tempax, tempbx, tempcx, temp, push1, push2,
3465 unsigned char const *TimingPoint;
3467 unsigned long longtemp, tempeax, tempebx, temp2, tempecx;
3469 /* si+Ext_ResInfo */
3470 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3474 if (!(pVBInfo->VBInfo & SetCRT2ToAVIDEO))
3477 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
3480 if (pVBInfo->VBInfo & SetCRT2ToSCART)
3483 if (!(pVBInfo->TVInfo & TVSetPAL))
3486 if (pVBInfo->VBInfo & SetCRT2ToHiVision)
3489 if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p))
3492 tempax = (tempax & 0xff00) >> 8;
3494 xgifb_reg_set(pVBInfo->Part2Port, 0x0, tempax);
3495 TimingPoint = XGI330_NTSCTiming;
3497 if (pVBInfo->TVInfo & TVSetPAL)
3498 TimingPoint = XGI330_PALTiming;
3500 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
3501 TimingPoint = XGI330_HiTVExtTiming;
3503 if (pVBInfo->VBInfo & SetInSlaveMode)
3504 TimingPoint = XGI330_HiTVSt2Timing;
3506 if (pVBInfo->SetFlag & TVSimuMode)
3507 TimingPoint = XGI330_HiTVSt1Timing;
3509 if (!(modeflag & Charx8Dot))
3510 TimingPoint = XGI330_HiTVTextTiming;
3513 if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
3514 if (pVBInfo->TVInfo & TVSetYPbPr525i)
3515 TimingPoint = XGI330_YPbPr525iTiming;
3517 if (pVBInfo->TVInfo & TVSetYPbPr525p)
3518 TimingPoint = XGI330_YPbPr525pTiming;
3520 if (pVBInfo->TVInfo & TVSetYPbPr750p)
3521 TimingPoint = XGI330_YPbPr750pTiming;
3524 for (i = 0x01, j = 0; i <= 0x2D; i++, j++)
3525 xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]);
3527 for (i = 0x39; i <= 0x45; i++, j++)
3529 xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]);
3531 if (pVBInfo->VBInfo & SetCRT2ToTV)
3532 xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, 0x00);
3534 temp = pVBInfo->NewFlickerMode;
3536 xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xFF, temp);
3538 if (pVBInfo->VBInfo & SetCRT2ToHiVision)
3541 if (pVBInfo->TVInfo & TVSetPAL)
3546 if (pVBInfo->VDE <= tempax) {
3547 tempax -= pVBInfo->VDE;
3548 tempax = tempax >> 2;
3549 tempax = (tempax & 0x00FF) | ((tempax & 0x00FF) << 8);
3551 temp = (tempax & 0xFF00) >> 8;
3552 temp += (unsigned short) TimingPoint[0];
3554 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
3555 | VB_SIS302LV | VB_XGI301C)) {
3556 if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO
3557 | SetCRT2ToSVIDEO | SetCRT2ToSCART
3558 | SetCRT2ToYPbPr525750)) {
3559 tempcx = pVBInfo->VGAHDE;
3560 if (tempcx >= 1024) {
3561 temp = 0x17; /* NTSC */
3562 if (pVBInfo->TVInfo & TVSetPAL)
3563 temp = 0x19; /* PAL */
3568 xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp);
3570 temp = (tempax & 0xFF00) >> 8;
3571 temp += TimingPoint[1];
3573 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
3574 | VB_SIS302LV | VB_XGI301C)) {
3575 if ((pVBInfo->VBInfo & (SetCRT2ToAVIDEO
3576 | SetCRT2ToSVIDEO | SetCRT2ToSCART
3577 | SetCRT2ToYPbPr525750))) {
3578 tempcx = pVBInfo->VGAHDE;
3579 if (tempcx >= 1024) {
3580 temp = 0x1D; /* NTSC */
3581 if (pVBInfo->TVInfo & TVSetPAL)
3582 temp = 0x52; /* PAL */
3586 xgifb_reg_set(pVBInfo->Part2Port, 0x02, temp);
3590 tempcx = pVBInfo->HT;
3592 if (XGI_IsLCDDualLink(pVBInfo))
3593 tempcx = tempcx >> 1;
3596 temp = tempcx & 0x00FF;
3597 xgifb_reg_set(pVBInfo->Part2Port, 0x1B, temp);
3599 temp = (tempcx & 0xFF00) >> 8;
3600 xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F, temp);
3602 tempcx = pVBInfo->HT >> 1;
3603 push1 = tempcx; /* push cx */
3606 if (pVBInfo->VBInfo & SetCRT2ToHiVision)
3609 temp = tempcx & 0x00FF;
3611 xgifb_reg_and_or(pVBInfo->Part2Port, 0x22, 0x0F, temp);
3613 tempbx = TimingPoint[j] | ((TimingPoint[j + 1]) << 8);
3616 temp = tempbx & 0x00FF;
3617 xgifb_reg_set(pVBInfo->Part2Port, 0x24, temp);
3618 temp = (tempbx & 0xFF00) >> 8;
3620 xgifb_reg_and_or(pVBInfo->Part2Port, 0x25, 0x0F, temp);
3623 tempbx = tempbx + 8;
3624 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
3625 tempbx = tempbx - 4;
3629 temp = (tempbx & 0x00FF) << 4;
3630 xgifb_reg_and_or(pVBInfo->Part2Port, 0x29, 0x0F, temp);
3633 tempcx += (TimingPoint[j] | ((TimingPoint[j + 1]) << 8));
3634 temp = tempcx & 0x00FF;
3635 xgifb_reg_set(pVBInfo->Part2Port, 0x27, temp);
3636 temp = ((tempcx & 0xFF00) >> 8) << 4;
3637 xgifb_reg_and_or(pVBInfo->Part2Port, 0x28, 0x0F, temp);
3640 if (pVBInfo->VBInfo & SetCRT2ToHiVision)
3643 temp = tempcx & 0xFF;
3645 xgifb_reg_and_or(pVBInfo->Part2Port, 0x2A, 0x0F, temp);
3647 tempcx = push1; /* pop cx */
3649 temp = TimingPoint[j] | ((TimingPoint[j + 1]) << 8);
3651 temp = tempcx & 0x00FF;
3653 xgifb_reg_and_or(pVBInfo->Part2Port, 0x2D, 0x0F, temp);
3657 if (!(pVBInfo->VBInfo & SetCRT2ToTV)) {
3658 tempax = XGI_GetVGAHT2(pVBInfo);
3659 tempcx = tempax - 1;
3661 temp = tempcx & 0x00FF;
3662 xgifb_reg_set(pVBInfo->Part2Port, 0x2E, temp);
3664 tempbx = pVBInfo->VDE;
3666 if (pVBInfo->VGAVDE == 360)
3668 if (pVBInfo->VGAVDE == 375)
3670 if (pVBInfo->VGAVDE == 405)
3673 if (pVBInfo->VBInfo & SetCRT2ToTV) {
3674 if (pVBInfo->VBType &
3675 (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) {
3676 if (!(pVBInfo->TVInfo &
3677 (TVSetYPbPr525p | TVSetYPbPr750p)))
3678 tempbx = tempbx >> 1;
3680 tempbx = tempbx >> 1;
3684 temp = tempbx & 0x00FF;
3686 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
3687 if (pVBInfo->VBType & VB_SIS301LV) {
3688 if (pVBInfo->TVInfo & TVSetHiVision) {
3689 if (pVBInfo->VBInfo & SetInSlaveMode) {
3694 } else if (pVBInfo->VBInfo & SetInSlaveMode) {
3700 xgifb_reg_set(pVBInfo->Part2Port, 0x2F, temp);
3702 temp = (tempcx & 0xFF00) >> 8;
3703 temp |= ((tempbx & 0xFF00) >> 8) << 6;
3705 if (!(pVBInfo->VBInfo & SetCRT2ToHiVision)) {
3706 if (pVBInfo->VBType & VB_SIS301LV) {
3707 if (pVBInfo->TVInfo & TVSetHiVision) {
3710 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
3715 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
3720 xgifb_reg_set(pVBInfo->Part2Port, 0x30, temp);
3722 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
3723 | VB_SIS302LV | VB_XGI301C)) { /* TV gatingno */
3724 tempbx = pVBInfo->VDE;
3725 tempcx = tempbx - 2;
3727 if (pVBInfo->VBInfo & SetCRT2ToTV) {
3728 if (!(pVBInfo->TVInfo & (TVSetYPbPr525p
3730 tempbx = tempbx >> 1;
3733 if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) {
3735 if (tempcx & 0x0400)
3738 if (tempbx & 0x0400)
3741 xgifb_reg_set(pVBInfo->Part4Port, 0x10, temp);
3744 temp = (((tempbx - 3) & 0x0300) >> 8) << 5;
3745 xgifb_reg_set(pVBInfo->Part2Port, 0x46, temp);
3746 temp = (tempbx - 3) & 0x00FF;
3747 xgifb_reg_set(pVBInfo->Part2Port, 0x47, temp);
3750 tempbx = tempbx & 0x00FF;
3752 if (!(modeflag & HalfDCLK)) {
3753 tempcx = pVBInfo->VGAHDE;
3754 if (tempcx >= pVBInfo->HDE) {
3762 if (pVBInfo->VBInfo & SetCRT2ToTV) { /*301b*/
3763 if (pVBInfo->VGAHDE >= 1024) {
3765 if (pVBInfo->VGAHDE >= 1280) {
3767 tempbx = tempbx & 0xDFFF;
3772 if (!(tempbx & 0x2000)) {
3773 if (modeflag & HalfDCLK)
3774 tempcx = (tempcx & 0xFF00) | ((tempcx & 0x00FF) << 1);
3777 tempeax = pVBInfo->VGAHDE;
3778 tempebx = (tempcx & 0xFF00) >> 8;
3779 longtemp = tempeax * tempebx;
3780 tempecx = tempcx & 0x00FF;
3781 longtemp = longtemp / tempecx;
3786 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
3787 | VB_SIS302LV | VB_XGI301C)) {
3788 tempecx = tempecx * 8;
3791 longtemp = longtemp * tempecx;
3792 tempecx = pVBInfo->HDE;
3793 temp2 = longtemp % tempecx;
3794 tempeax = longtemp / tempecx;
3798 tempax = (unsigned short) tempeax;
3801 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
3802 | VB_SIS302LV | VB_XGI301C)) {
3803 tempcx = ((tempax & 0xFF00) >> 5) >> 8;
3808 tempbx = (unsigned short) (((tempeax & 0x0000FF00) & 0x1F00)
3809 | (tempbx & 0x00FF));
3810 tempax = (unsigned short) (((tempeax & 0x000000FF) << 8)
3811 | (tempax & 0x00FF));
3812 temp = (tempax & 0xFF00) >> 8;
3814 temp = (tempax & 0x00FF) >> 8;
3817 xgifb_reg_set(pVBInfo->Part2Port, 0x44, temp);
3818 temp = (tempbx & 0xFF00) >> 8;
3819 xgifb_reg_and_or(pVBInfo->Part2Port, 0x45, ~0x03F, temp);
3820 temp = tempcx & 0x00FF;
3822 if (tempbx & 0x2000)
3825 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
3828 xgifb_reg_and_or(pVBInfo->Part2Port, 0x46, ~0x1F, temp);
3829 if (pVBInfo->TVInfo & TVSetPAL) {
3837 temp = tempbx & 0x00FF;
3838 xgifb_reg_set(pVBInfo->Part2Port, 0x4b, temp);
3839 temp = tempcx & 0x00FF;
3840 xgifb_reg_set(pVBInfo->Part2Port, 0x4c, temp);
3842 temp = ((tempcx & 0xFF00) >> 8) & 0x03;
3844 temp |= ((tempbx & 0xFF00) >> 8) & 0x03;
3846 if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
3849 if (pVBInfo->TVInfo & TVSetYPbPr525p)
3852 if (pVBInfo->TVInfo & TVSetYPbPr750p)
3856 xgifb_reg_set(pVBInfo->Part2Port, 0x4d, temp);
3857 temp = xgifb_reg_get(pVBInfo->Part2Port, 0x43); /* 301b change */
3858 xgifb_reg_set(pVBInfo->Part2Port, 0x43, (unsigned short) (temp - 3));
3860 if (!(pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p))) {
3861 if (pVBInfo->TVInfo & NTSC1024x768) {
3862 TimingPoint = XGI_NTSC1024AdjTime;
3863 for (i = 0x1c, j = 0; i <= 0x30; i++, j++) {
3864 xgifb_reg_set(pVBInfo->Part2Port, i,
3867 xgifb_reg_set(pVBInfo->Part2Port, 0x43, 0x72);
3871 /* Modify for 301C PALM Support */
3872 if (pVBInfo->VBType & VB_XGI301C) {
3873 if (pVBInfo->TVInfo & TVSetPALM)
3874 xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x08,
3875 0x08); /* PALM Mode */
3878 if (pVBInfo->TVInfo & TVSetPALM) {
3879 tempax = (unsigned char) xgifb_reg_get(pVBInfo->Part2Port,
3882 xgifb_reg_and(pVBInfo->Part2Port, 0x01, tempax);
3884 xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xEF);
3887 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
3888 if (!(pVBInfo->VBInfo & SetInSlaveMode))
3889 xgifb_reg_set(pVBInfo->Part2Port, 0x0B, 0x00);
3892 if (pVBInfo->VBInfo & SetCRT2ToTV)
3896 static void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
3897 struct xgi_hw_device_info *HwDeviceExtension,
3898 unsigned short RefreshRateTableIndex,
3899 struct vb_device_info *pVBInfo)
3901 unsigned short pushbx, tempax, tempbx, tempcx, temp, tempah,
3904 struct XGI_LCDDesStruct const *LCDBDesPtr = NULL;
3906 /* si+Ext_ResInfo */
3907 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
3910 tempbx = pVBInfo->HDE; /* RHACTE=HDE-1 */
3912 if (XGI_IsLCDDualLink(pVBInfo))
3913 tempbx = tempbx >> 1;
3916 temp = tempbx & 0x00FF;
3917 xgifb_reg_set(pVBInfo->Part2Port, 0x2C, temp);
3918 temp = (tempbx & 0xFF00) >> 8;
3920 xgifb_reg_and_or(pVBInfo->Part2Port, 0x2B, 0x0F, temp);
3923 xgifb_reg_set(pVBInfo->Part2Port, 0x0B, temp);
3924 tempbx = pVBInfo->VDE; /* RTVACTEO=(VDE-1)&0xFF */
3926 temp = tempbx & 0x00FF;
3927 xgifb_reg_set(pVBInfo->Part2Port, 0x03, temp);
3928 temp = ((tempbx & 0xFF00) >> 8) & 0x07;
3929 xgifb_reg_and_or(pVBInfo->Part2Port, 0x0C, ~0x07, temp);
3931 tempcx = pVBInfo->VT - 1;
3932 temp = tempcx & 0x00FF; /* RVTVT=VT-1 */
3933 xgifb_reg_set(pVBInfo->Part2Port, 0x19, temp);
3934 temp = (tempcx & 0xFF00) >> 8;
3936 xgifb_reg_set(pVBInfo->Part2Port, 0x1A, temp);
3937 xgifb_reg_and_or(pVBInfo->Part2Port, 0x09, 0xF0, 0x00);
3938 xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xF0, 0x00);
3939 xgifb_reg_and_or(pVBInfo->Part2Port, 0x17, 0xFB, 0x00);
3940 xgifb_reg_and_or(pVBInfo->Part2Port, 0x18, 0xDF, 0x00);
3942 /* Customized LCDB Does not add */
3943 if ((pVBInfo->VBType & VB_SIS301LV) || (pVBInfo->VBType & VB_SIS302LV))
3944 LCDBDesPtr = XGI_GetLcdPtr(xgifb_lcddldes, ModeNo, ModeIdIndex,
3945 RefreshRateTableIndex, pVBInfo);
3947 LCDBDesPtr = XGI_GetLcdPtr(XGI_LCDDesDataTable, ModeNo,
3948 ModeIdIndex, RefreshRateTableIndex,
3951 tempah = pVBInfo->LCDResInfo;
3952 tempah &= PanelResInfo;
3954 if ((tempah == Panel_1024x768) || (tempah == Panel_1024x768x75)) {
3957 } else if ((tempah == Panel_1280x1024) ||
3958 (tempah == Panel_1280x1024x75)) {
3961 } else if (tempah == Panel_1400x1050) {
3969 if (pVBInfo->LCDInfo & EnableScalingLCD) {
3970 tempbx = pVBInfo->HDE;
3971 tempcx = pVBInfo->VDE;
3975 tempax = pVBInfo->VT;
3976 pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES;
3977 pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS;
3978 pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES;
3979 pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS;
3980 tempbx = pVBInfo->LCDVDES;
3983 if (tempcx >= tempax)
3984 tempcx -= tempax; /* lcdvdes */
3986 temp = tempbx & 0x00FF; /* RVEQ1EQ=lcdvdes */
3987 xgifb_reg_set(pVBInfo->Part2Port, 0x05, temp);
3988 temp = tempcx & 0x00FF;
3989 xgifb_reg_set(pVBInfo->Part2Port, 0x06, temp);
3990 tempch = ((tempcx & 0xFF00) >> 8) & 0x07;
3991 tempbh = ((tempbx & 0xFF00) >> 8) & 0x07;
3993 tempah = tempah << 3;
3995 xgifb_reg_set(pVBInfo->Part2Port, 0x02, tempah);
3998 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
4000 tempax = pVBInfo->VT;
4001 tempbx = pVBInfo->LCDVRS;
4004 if (tempcx >= tempax)
4007 temp = tempbx & 0x00FF; /* RTVACTEE=lcdvrs */
4008 xgifb_reg_set(pVBInfo->Part2Port, 0x04, temp);
4009 temp = (tempbx & 0xFF00) >> 8;
4011 temp |= (tempcx & 0x000F);
4012 xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp);
4014 tempax = pVBInfo->HT;
4015 tempbx = pVBInfo->LCDHDES;
4018 if (XGI_IsLCDDualLink(pVBInfo)) {
4019 tempax = tempax >> 1;
4020 tempbx = tempbx >> 1;
4021 tempcx = tempcx >> 1;
4024 if (pVBInfo->VBType & VB_SIS302LV)
4027 if (pVBInfo->VBType & VB_XGI301C) /* tap4 */
4032 if (tempcx >= tempax)
4035 temp = tempbx & 0x00FF;
4036 xgifb_reg_set(pVBInfo->Part2Port, 0x1F, temp); /* RHBLKE=lcdhdes */
4037 temp = ((tempbx & 0xFF00) >> 8) << 4;
4038 xgifb_reg_set(pVBInfo->Part2Port, 0x20, temp);
4039 temp = tempcx & 0x00FF;
4040 xgifb_reg_set(pVBInfo->Part2Port, 0x23, temp); /* RHEQPLE=lcdhdee */
4041 temp = (tempcx & 0xFF00) >> 8;
4042 xgifb_reg_set(pVBInfo->Part2Port, 0x25, temp);
4044 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
4046 tempax = pVBInfo->HT;
4047 tempbx = pVBInfo->LCDHRS;
4048 if (XGI_IsLCDDualLink(pVBInfo)) {
4049 tempax = tempax >> 1;
4050 tempbx = tempbx >> 1;
4051 tempcx = tempcx >> 1;
4054 if (pVBInfo->VBType & VB_SIS302LV)
4059 if (tempcx >= tempax)
4062 temp = tempbx & 0x00FF; /* RHBURSTS=lcdhrs */
4063 xgifb_reg_set(pVBInfo->Part2Port, 0x1C, temp);
4065 temp = (tempbx & 0xFF00) >> 8;
4067 xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F0, temp);
4068 temp = tempcx & 0x00FF; /* RHSYEXP2S=lcdhre */
4069 xgifb_reg_set(pVBInfo->Part2Port, 0x21, temp);
4071 if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
4072 if (pVBInfo->VGAVDE == 525) {
4073 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B
4074 | VB_SIS301LV | VB_SIS302LV
4080 xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp);
4081 xgifb_reg_set(pVBInfo->Part2Port, 0x30, 0xB3);
4084 if (pVBInfo->VGAVDE == 420) {
4085 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B
4086 | VB_SIS301LV | VB_SIS302LV
4091 xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp);
4096 /* --------------------------------------------------------------------- */
4097 /* Function : XGI_GetTap4Ptr */
4099 /* Output : di -> Tap4 Reg. Setting Pointer */
4101 /* --------------------------------------------------------------------- */
4102 static struct XGI301C_Tap4TimingStruct const
4103 *XGI_GetTap4Ptr(unsigned short tempcx, struct vb_device_info *pVBInfo)
4105 unsigned short tempax, tempbx, i;
4106 struct XGI301C_Tap4TimingStruct const *Tap4TimingPtr;
4109 tempax = pVBInfo->VGAHDE;
4110 tempbx = pVBInfo->HDE;
4112 tempax = pVBInfo->VGAVDE;
4113 tempbx = pVBInfo->VDE;
4116 if (tempax <= tempbx)
4117 return &xgifb_tap4_timing[0];
4119 Tap4TimingPtr = xgifb_ntsc_525_tap4_timing; /* NTSC */
4121 if (pVBInfo->TVInfo & TVSetPAL)
4122 Tap4TimingPtr = PALTap4Timing;
4124 if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
4125 if ((pVBInfo->TVInfo & TVSetYPbPr525i) ||
4126 (pVBInfo->TVInfo & TVSetYPbPr525p))
4127 Tap4TimingPtr = xgifb_ntsc_525_tap4_timing;
4128 if (pVBInfo->TVInfo & TVSetYPbPr750p)
4129 Tap4TimingPtr = YPbPr750pTap4Timing;
4132 if (pVBInfo->VBInfo & SetCRT2ToHiVision)
4133 Tap4TimingPtr = xgifb_tap4_timing;
4136 while (Tap4TimingPtr[i].DE != 0xFFFF) {
4137 if (Tap4TimingPtr[i].DE == tempax)
4141 return &Tap4TimingPtr[i];
4144 static void XGI_SetTap4Regs(struct vb_device_info *pVBInfo)
4146 unsigned short i, j;
4147 struct XGI301C_Tap4TimingStruct const *Tap4TimingPtr;
4149 if (!(pVBInfo->VBType & VB_XGI301C))
4152 Tap4TimingPtr = XGI_GetTap4Ptr(0, pVBInfo); /* Set Horizontal Scaling */
4153 for (i = 0x80, j = 0; i <= 0xBF; i++, j++)
4154 xgifb_reg_set(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]);
4156 if ((pVBInfo->VBInfo & SetCRT2ToTV) &&
4157 (!(pVBInfo->VBInfo & SetCRT2ToHiVision))) {
4158 /* Set Vertical Scaling */
4159 Tap4TimingPtr = XGI_GetTap4Ptr(1, pVBInfo);
4160 for (i = 0xC0, j = 0; i < 0xFF; i++, j++)
4161 xgifb_reg_set(pVBInfo->Part2Port,
4163 Tap4TimingPtr->Reg[j]);
4166 if ((pVBInfo->VBInfo & SetCRT2ToTV) &&
4167 (!(pVBInfo->VBInfo & SetCRT2ToHiVision)))
4168 /* Enable V.Scaling */
4169 xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x04);
4171 /* Enable H.Scaling */
4172 xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x10);
4175 static void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex,
4176 struct vb_device_info *pVBInfo)
4179 unsigned char const *tempdi;
4180 unsigned short modeflag;
4182 /* si+Ext_ResInfo */
4183 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4185 xgifb_reg_set(pVBInfo->Part3Port, 0x00, 0x00);
4186 if (pVBInfo->TVInfo & TVSetPAL) {
4187 xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA);
4188 xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8);
4190 xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xF5);
4191 xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xB7);
4194 if (!(pVBInfo->VBInfo & SetCRT2ToTV))
4197 if (pVBInfo->TVInfo & TVSetPALM) {
4198 xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA);
4199 xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8);
4200 xgifb_reg_set(pVBInfo->Part3Port, 0x3D, 0xA8);
4203 if ((pVBInfo->VBInfo & SetCRT2ToHiVision) || (pVBInfo->VBInfo
4204 & SetCRT2ToYPbPr525750)) {
4205 if (pVBInfo->TVInfo & TVSetYPbPr525i)
4208 tempdi = XGI330_HiTVGroup3Data;
4209 if (pVBInfo->SetFlag & TVSimuMode) {
4210 tempdi = XGI330_HiTVGroup3Simu;
4211 if (!(modeflag & Charx8Dot))
4212 tempdi = XGI330_HiTVGroup3Text;
4215 if (pVBInfo->TVInfo & TVSetYPbPr525p)
4216 tempdi = XGI330_Ren525pGroup3;
4218 if (pVBInfo->TVInfo & TVSetYPbPr750p)
4219 tempdi = XGI330_Ren750pGroup3;
4221 for (i = 0; i <= 0x3E; i++)
4222 xgifb_reg_set(pVBInfo->Part3Port, i, tempdi[i]);
4224 if (pVBInfo->VBType & VB_XGI301C) { /* Marcovision */
4225 if (pVBInfo->TVInfo & TVSetYPbPr525p)
4226 xgifb_reg_set(pVBInfo->Part3Port, 0x28, 0x3f);
4230 } /* {end of XGI_SetGroup3} */
4232 static void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex,
4233 unsigned short RefreshRateTableIndex,
4234 struct xgi_hw_device_info *HwDeviceExtension,
4235 struct vb_device_info *pVBInfo)
4237 unsigned short tempax, tempcx, tempbx, modeflag, temp, temp2;
4239 unsigned long tempebx, tempeax, templong;
4241 /* si+Ext_ResInfo */
4242 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4243 temp = pVBInfo->RVBHCFACT;
4244 xgifb_reg_set(pVBInfo->Part4Port, 0x13, temp);
4246 tempbx = pVBInfo->RVBHCMAX;
4247 temp = tempbx & 0x00FF;
4248 xgifb_reg_set(pVBInfo->Part4Port, 0x14, temp);
4249 temp2 = ((tempbx & 0xFF00) >> 8) << 7;
4250 tempcx = pVBInfo->VGAHT - 1;
4251 temp = tempcx & 0x00FF;
4252 xgifb_reg_set(pVBInfo->Part4Port, 0x16, temp);
4254 temp = ((tempcx & 0xFF00) >> 8) << 3;
4257 tempcx = pVBInfo->VGAVT - 1;
4258 if (!(pVBInfo->VBInfo & SetCRT2ToTV))
4261 temp = tempcx & 0x00FF;
4262 xgifb_reg_set(pVBInfo->Part4Port, 0x17, temp);
4263 temp = temp2 | ((tempcx & 0xFF00) >> 8);
4264 xgifb_reg_set(pVBInfo->Part4Port, 0x15, temp);
4265 xgifb_reg_or(pVBInfo->Part4Port, 0x0D, 0x08);
4266 tempcx = pVBInfo->VBInfo;
4267 tempbx = pVBInfo->VGAHDE;
4269 if (modeflag & HalfDCLK)
4270 tempbx = tempbx >> 1;
4272 if (XGI_IsLCDDualLink(pVBInfo))
4273 tempbx = tempbx >> 1;
4275 if (tempcx & SetCRT2ToHiVision) {
4281 } else if (tempcx & SetCRT2ToTV) {
4287 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
4294 if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p)) {
4296 if (pVBInfo->VGAHDE == 1280)
4298 if (pVBInfo->VGAHDE == 1024)
4301 xgifb_reg_and_or(pVBInfo->Part4Port, 0x0E, ~0xEF, temp);
4303 tempebx = pVBInfo->VDE;
4305 if (tempcx & SetCRT2ToHiVision) {
4306 if (!(temp & 0xE000))
4307 tempbx = tempbx >> 1;
4310 tempcx = pVBInfo->RVBHRS;
4311 temp = tempcx & 0x00FF;
4312 xgifb_reg_set(pVBInfo->Part4Port, 0x18, temp);
4314 tempeax = pVBInfo->VGAVDE;
4317 if (tempeax <= tempebx) {
4318 tempcx = (tempcx & (~0x4000));
4319 tempeax = pVBInfo->VGAVDE;
4324 templong = (tempeax * 256 * 1024) % tempebx;
4325 tempeax = (tempeax * 256 * 1024) / tempebx;
4331 temp = (unsigned short) (tempebx & 0x000000FF);
4332 xgifb_reg_set(pVBInfo->Part4Port, 0x1B, temp);
4334 temp = (unsigned short) ((tempebx & 0x0000FF00) >> 8);
4335 xgifb_reg_set(pVBInfo->Part4Port, 0x1A, temp);
4336 tempbx = (unsigned short) (tempebx >> 16);
4337 temp = tempbx & 0x00FF;
4339 temp |= ((tempcx & 0xFF00) >> 8);
4340 xgifb_reg_set(pVBInfo->Part4Port, 0x19, temp);
4343 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
4344 | VB_SIS302LV | VB_XGI301C)) {
4346 xgifb_reg_set(pVBInfo->Part4Port, 0x1C, temp);
4347 tempax = pVBInfo->VGAHDE;
4348 if (modeflag & HalfDCLK)
4349 tempax = tempax >> 1;
4351 if (XGI_IsLCDDualLink(pVBInfo))
4352 tempax = tempax >> 1;
4354 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
4357 } else if (pVBInfo->VGAHDE > 800) {
4358 if (pVBInfo->VGAHDE == 1024)
4359 tempax = (tempax * 25 / 32) - 1;
4361 tempax = (tempax * 20 / 32) - 1;
4365 temp = (tempax & 0xFF00) >> 8;
4366 temp = ((temp & 0x0003) << 4);
4367 xgifb_reg_set(pVBInfo->Part4Port, 0x1E, temp);
4368 temp = (tempax & 0x00FF);
4369 xgifb_reg_set(pVBInfo->Part4Port, 0x1D, temp);
4371 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVision)) {
4372 if (pVBInfo->VGAHDE > 800)
4373 xgifb_reg_or(pVBInfo->Part4Port, 0x1E, 0x08);
4378 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4379 if (!(pVBInfo->TVInfo & (NTSC1024x768
4380 | TVSetYPbPr525p | TVSetYPbPr750p
4381 | TVSetHiVision))) {
4383 if ((pVBInfo->VBInfo & SetInSlaveMode)
4384 && (!(pVBInfo->TVInfo
4390 xgifb_reg_and_or(pVBInfo->Part4Port, 0x1F, 0x00C0, temp);
4391 tempbx = pVBInfo->HT;
4392 if (XGI_IsLCDDualLink(pVBInfo))
4393 tempbx = tempbx >> 1;
4394 tempbx = (tempbx >> 1) - 2;
4395 temp = ((tempbx & 0x0700) >> 8) << 3;
4396 xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, 0x00C0, temp);
4397 temp = tempbx & 0x00FF;
4398 xgifb_reg_set(pVBInfo->Part4Port, 0x22, temp);
4402 XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
4405 static void XGINew_EnableCRT2(struct vb_device_info *pVBInfo)
4407 xgifb_reg_and_or(pVBInfo->P3c4, 0x1E, 0xFF, 0x20);
4410 static void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex,
4411 struct vb_device_info *pVBInfo)
4413 if (pVBInfo->ModeType == ModeVGA) {
4414 if (!(pVBInfo->VBInfo & (SetInSlaveMode | LoadDACFlag
4415 | DisableCRT2Display))) {
4416 XGINew_EnableCRT2(pVBInfo);
4422 static void XGI_EnableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension,
4423 struct vb_device_info *pVBInfo)
4425 xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x40);
4428 static void XGI_DisableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension,
4429 struct vb_device_info *pVBInfo)
4432 xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x00);
4435 static unsigned char XGI_XG21CheckLVDSMode(struct xgifb_video_info *xgifb_info,
4436 unsigned short ModeNo, unsigned short ModeIdIndex,
4437 struct vb_device_info *pVBInfo)
4439 unsigned short xres, yres, colordepth, modeflag, resindex;
4441 resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO;
4442 xres = XGI330_ModeResInfo[resindex].HTotal; /* xres->ax */
4443 yres = XGI330_ModeResInfo[resindex].VTotal; /* yres->bx */
4444 /* si+St_ModeFlag */
4445 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4447 if (!(modeflag & Charx8Dot)) {
4452 if ((ModeNo > 0x13) && (modeflag & HalfDCLK))
4455 if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
4458 if (xres > xgifb_info->lvds_data.LVDSHDE)
4461 if (yres > xgifb_info->lvds_data.LVDSVDE)
4464 if (xres != xgifb_info->lvds_data.LVDSHDE ||
4465 yres != xgifb_info->lvds_data.LVDSVDE) {
4466 colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo);
4473 static void xgifb_set_lvds(struct xgifb_video_info *xgifb_info,
4475 unsigned short ModeNo,
4476 unsigned short ModeIdIndex,
4477 struct vb_device_info *pVBInfo)
4479 unsigned char temp, Miscdata;
4480 unsigned short xres, yres, modeflag, resindex;
4481 unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE;
4482 unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE;
4483 unsigned short value;
4485 temp = (unsigned char) ((xgifb_info->lvds_data.LVDS_Capability &
4486 (LCDPolarity << 8)) >> 8);
4487 temp &= LCDPolarity;
4488 Miscdata = (unsigned char) inb(pVBInfo->P3cc);
4490 outb((Miscdata & 0x3F) | temp, pVBInfo->P3c2);
4492 temp = xgifb_info->lvds_data.LVDS_Capability & LCDPolarity;
4493 /* SR35[7] FP VSync polarity */
4494 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80);
4495 /* SR30[5] FP HSync polarity */
4496 xgifb_reg_and_or(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1);
4498 if (chip_id == XG27)
4499 XGI_SetXG27FPBits(pVBInfo);
4501 XGI_SetXG21FPBits(pVBInfo);
4503 resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO;
4504 xres = XGI330_ModeResInfo[resindex].HTotal; /* xres->ax */
4505 yres = XGI330_ModeResInfo[resindex].VTotal; /* yres->bx */
4506 /* si+St_ModeFlag */
4507 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4509 if (!(modeflag & Charx8Dot))
4510 xres = xres * 8 / 9;
4512 LVDSHT = xgifb_info->lvds_data.LVDSHT;
4514 LVDSHBS = xres + (xgifb_info->lvds_data.LVDSHDE - xres) / 2;
4516 if (LVDSHBS > LVDSHT)
4519 LVDSHRS = LVDSHBS + xgifb_info->lvds_data.LVDSHFP;
4520 if (LVDSHRS > LVDSHT)
4523 LVDSHRE = LVDSHRS + xgifb_info->lvds_data.LVDSHSYNC;
4524 if (LVDSHRE > LVDSHT)
4527 LVDSHBE = LVDSHBS + LVDSHT - xgifb_info->lvds_data.LVDSHDE;
4529 LVDSVT = xgifb_info->lvds_data.LVDSVT;
4531 LVDSVBS = yres + (xgifb_info->lvds_data.LVDSVDE - yres) / 2;
4532 if (modeflag & DoubleScanMode)
4533 LVDSVBS += yres / 2;
4535 if (LVDSVBS > LVDSVT)
4538 LVDSVRS = LVDSVBS + xgifb_info->lvds_data.LVDSVFP;
4539 if (LVDSVRS > LVDSVT)
4542 LVDSVRE = LVDSVRS + xgifb_info->lvds_data.LVDSVSYNC;
4543 if (LVDSVRE > LVDSVT)
4546 LVDSVBE = LVDSVBS + LVDSVT - xgifb_info->lvds_data.LVDSVDE;
4548 temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
4549 xgifb_reg_set(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */
4551 if (!(modeflag & Charx8Dot))
4552 xgifb_reg_or(pVBInfo->P3c4, 0x1, 0x1);
4554 /* HT SR0B[1:0] CR00 */
4555 value = (LVDSHT >> 3) - 5;
4556 xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8);
4557 xgifb_reg_set(pVBInfo->P3d4, 0x0, (value & 0xFF));
4559 /* HBS SR0B[5:4] CR02 */
4560 value = (LVDSHBS >> 3) - 1;
4561 xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4);
4562 xgifb_reg_set(pVBInfo->P3d4, 0x2, (value & 0xFF));
4564 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
4565 value = (LVDSHBE >> 3) - 1;
4566 xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6);
4567 xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2);
4568 xgifb_reg_and_or(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F);
4570 /* HRS SR0B[7:6] CR04 */
4571 value = (LVDSHRS >> 3) + 2;
4572 xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2);
4573 xgifb_reg_set(pVBInfo->P3d4, 0x4, (value & 0xFF));
4575 /* Panel HRS SR2F[1:0] SR2E[7:0] */
4577 xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8);
4578 xgifb_reg_set(pVBInfo->P3c4, 0x2E, (value & 0xFF));
4580 /* HRE SR0C[2] CR05[4:0] */
4581 value = (LVDSHRE >> 3) + 2;
4582 xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3);
4583 xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F);
4585 /* Panel HRE SR2F[7:2] */
4587 xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2);
4589 /* VT SR0A[0] CR07[5][0] CR06 */
4591 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10);
4592 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4);
4593 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8);
4594 xgifb_reg_set(pVBInfo->P3d4, 0x06, (value & 0xFF));
4596 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
4597 value = LVDSVBS - 1;
4598 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8);
4599 xgifb_reg_and_or(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4);
4600 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5);
4601 xgifb_reg_set(pVBInfo->P3d4, 0x15, (value & 0xFF));
4603 /* VBE SR0A[4] CR16 */
4604 value = LVDSVBE - 1;
4605 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4);
4606 xgifb_reg_set(pVBInfo->P3d4, 0x16, (value & 0xFF));
4608 /* VRS SR0A[3] CR7[7][2] CR10 */
4609 value = LVDSVRS - 1;
4610 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7);
4611 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2);
4612 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6);
4613 xgifb_reg_set(pVBInfo->P3d4, 0x10, (value & 0xFF));
4615 if (chip_id == XG27) {
4616 /* Panel VRS SR35[2:0] SR34[7:0] */
4617 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07,
4618 (value & 0x700) >> 8);
4619 xgifb_reg_set(pVBInfo->P3c4, 0x34, value & 0xFF);
4621 /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */
4622 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0x03,
4623 (value & 0x600) >> 9);
4624 xgifb_reg_set(pVBInfo->P3c4, 0x34, (value >> 1) & 0xFF);
4625 xgifb_reg_and_or(pVBInfo->P3d4, 0x33, ~0x01, value & 0x01);
4628 /* VRE SR0A[5] CR11[3:0] */
4629 value = LVDSVRE - 1;
4630 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1);
4631 xgifb_reg_and_or(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F);
4633 /* Panel VRE SR3F[7:2] */
4634 if (chip_id == XG27)
4635 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC,
4636 (value << 2) & 0xFC);
4638 /* SR3F[7] has to be 0, h/w bug */
4639 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC,
4640 (value << 2) & 0x7C);
4642 for (temp = 0, value = 0; temp < 3; temp++) {
4644 xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, value);
4645 xgifb_reg_set(pVBInfo->P3c4,
4646 0x2B, xgifb_info->lvds_data.VCLKData1);
4647 xgifb_reg_set(pVBInfo->P3c4,
4648 0x2C, xgifb_info->lvds_data.VCLKData2);
4652 if (!(modeflag & Charx8Dot)) {
4653 inb(pVBInfo->P3da); /* reset 3da */
4654 outb(0x13, pVBInfo->P3c0); /* set index */
4655 /* set data, panning = 0, shift left 1 dot*/
4656 outb(0x00, pVBInfo->P3c0);
4658 inb(pVBInfo->P3da); /* Enable Attribute */
4659 outb(0x20, pVBInfo->P3c0);
4661 inb(pVBInfo->P3da); /* reset 3da */
4666 /* --------------------------------------------------------------------- */
4667 /* Function : XGI_IsLCDON */
4669 /* Output : 0 : Skip PSC Control */
4670 /* 1: Disable PSC */
4672 /* --------------------------------------------------------------------- */
4673 static unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo)
4675 unsigned short tempax;
4677 tempax = pVBInfo->VBInfo;
4678 if (tempax & SetCRT2ToDualEdge)
4680 else if (tempax & (DisableCRT2Display | SwitchCRT2 | SetSimuScanMode))
4686 /* --------------------------------------------------------------------- */
4687 /* Function : XGI_DisableChISLCD */
4689 /* Output : 0 -> Not LCD Mode */
4691 /* --------------------------------------------------------------------- */
4692 static unsigned char XGI_DisableChISLCD(struct vb_device_info *pVBInfo)
4694 unsigned short tempbx, tempah;
4696 tempbx = pVBInfo->SetFlag & (DisableChA | DisableChB);
4697 tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E));
4699 if (tempbx & (EnableChA | DisableChA)) {
4700 if (!(tempah & 0x08)) /* Chk LCDA Mode */
4704 if (!(tempbx & (EnableChB | DisableChB)))
4707 if (tempah & 0x01) /* Chk LCDB Mode */
4713 /* --------------------------------------------------------------------- */
4714 /* Function : XGI_EnableChISLCD */
4716 /* Output : 0 -> Not LCD mode */
4718 /* --------------------------------------------------------------------- */
4719 static unsigned char XGI_EnableChISLCD(struct vb_device_info *pVBInfo)
4721 unsigned short tempbx, tempah;
4723 tempbx = pVBInfo->SetFlag & (EnableChA | EnableChB);
4724 tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E));
4726 if (tempbx & (EnableChA | DisableChA)) {
4727 if (!(tempah & 0x08)) /* Chk LCDA Mode */
4731 if (!(tempbx & (EnableChB | DisableChB)))
4734 if (tempah & 0x01) /* Chk LCDB Mode */
4740 static void XGI_DisableBridge(struct xgifb_video_info *xgifb_info,
4741 struct xgi_hw_device_info *HwDeviceExtension,
4742 struct vb_device_info *pVBInfo)
4744 unsigned short tempah = 0;
4746 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
4747 | VB_SIS302LV | VB_XGI301C)) {
4749 if (!(pVBInfo->VBInfo &
4750 (DisableCRT2Display | SetSimuScanMode))) {
4751 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
4752 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
4753 tempah = 0x7F; /* Disable Channel A */
4754 if (!(pVBInfo->VBInfo &
4756 /* Disable Channel B */
4759 if (pVBInfo->SetFlag & DisableChB)
4760 /* force to disable Cahnnel */
4763 if (pVBInfo->SetFlag & DisableChA)
4764 /* Force to disable Channel B */
4770 /* disable part4_1f */
4771 xgifb_reg_and(pVBInfo->Part4Port, 0x1F, tempah);
4773 if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) {
4774 if (((pVBInfo->VBInfo &
4775 (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)))
4776 || (XGI_DisableChISLCD(pVBInfo))
4777 || (XGI_IsLCDON(pVBInfo)))
4778 /* LVDS Driver power down */
4779 xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x80);
4782 if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo
4783 & (DisableCRT2Display | XGI_SetCRT2ToLCDA
4784 | SetSimuScanMode))) {
4785 if (pVBInfo->SetFlag & GatingCRT)
4786 XGI_EnableGatingCRT(HwDeviceExtension, pVBInfo);
4787 XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo);
4790 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
4791 if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo
4792 & XGI_SetCRT2ToLCDA))
4794 xgifb_reg_and(pVBInfo->Part1Port, 0x1e, 0xdf);
4797 /* disable TV as primary VGA swap */
4798 xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xdf);
4800 if ((pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToDualEdge)))
4801 xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xdf);
4803 if ((pVBInfo->SetFlag & DisableChB) ||
4805 (DisableCRT2Display | SetSimuScanMode)) ||
4806 ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) &&
4808 (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV))))
4809 xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80);
4811 if ((pVBInfo->SetFlag & DisableChB) ||
4813 (DisableCRT2Display | SetSimuScanMode)) ||
4814 (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) ||
4816 (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV))) {
4817 /* save Part1 index 0 */
4818 tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00);
4819 /* BTDAC = 1, avoid VB reset */
4820 xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x10);
4822 xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF);
4823 /* restore Part1 index 0 */
4824 xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah);
4826 } else { /* {301} */
4827 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) {
4828 xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80);
4830 xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF);
4831 /* Disable TV asPrimary VGA swap */
4832 xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xDF);
4835 if (pVBInfo->VBInfo & (DisableCRT2Display | XGI_SetCRT2ToLCDA
4837 XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo);
4841 /* --------------------------------------------------------------------- */
4842 /* Function : XGI_GetTVPtrIndex */
4845 /* Description : bx 0 : ExtNTSC */
4857 /* --------------------------------------------------------------------- */
4858 static unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo)
4860 unsigned short tempbx = 0;
4862 if (pVBInfo->TVInfo & TVSetPAL)
4864 if (pVBInfo->TVInfo & TVSetHiVision)
4866 if (pVBInfo->TVInfo & TVSetYPbPr525i)
4868 if (pVBInfo->TVInfo & TVSetYPbPr525p)
4870 if (pVBInfo->TVInfo & TVSetYPbPr750p)
4872 if (pVBInfo->TVInfo & TVSimuMode)
4878 /* --------------------------------------------------------------------- */
4879 /* Function : XGI_GetTVPtrIndex2 */
4881 /* Output : bx 0 : NTSC */
4885 /* 4 : NTSC1024x768 */
4886 /* 5 : PAL-M 1024x768 */
4888 /* cl 0 : YFilter1 */
4891 /* 1 : 301B/302B/301LV/302LV */
4893 /* --------------------------------------------------------------------- */
4894 static void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char *tempcl,
4895 unsigned char *tempch, struct vb_device_info *pVBInfo)
4901 if (pVBInfo->TVInfo & TVSetPAL)
4904 if (pVBInfo->TVInfo & TVSetPALM)
4907 if (pVBInfo->TVInfo & TVSetPALN)
4910 if (pVBInfo->TVInfo & NTSC1024x768) {
4912 if (pVBInfo->TVInfo & TVSetPALM)
4916 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
4917 | VB_SIS302LV | VB_XGI301C)) {
4918 if ((!(pVBInfo->VBInfo & SetInSlaveMode)) || (pVBInfo->TVInfo
4925 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
4926 | VB_SIS302LV | VB_XGI301C))
4930 static void XGI_SetDelayComp(struct vb_device_info *pVBInfo)
4932 unsigned char tempah, tempbl, tempbh;
4934 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
4935 | VB_SIS302LV | VB_XGI301C)) {
4936 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA
4937 | SetCRT2ToTV | SetCRT2ToRAMDAC)) {
4939 tempbl = XGI301TVDelay;
4941 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
4942 tempbl = tempbl >> 4;
4943 if (pVBInfo->VBInfo &
4944 (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
4945 tempbh = XGI301LCDDelay;
4947 if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA))
4953 tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x2D);
4955 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD
4956 | SetCRT2ToTV)) { /* Channel B */
4961 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
4966 xgifb_reg_set(pVBInfo->Part1Port, 0x2D, tempah);
4968 } else if (pVBInfo->IF_DEF_LVDS == 1) {
4971 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
4972 tempah = XGI301LCDDelay;
4974 tempah = tempah << 4;
4975 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2D, 0x0f,
4981 static void XGI_SetLCDCap_A(unsigned short tempcx,
4982 struct vb_device_info *pVBInfo)
4984 unsigned short temp;
4986 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
4988 if (temp & LCDRGB18Bit) {
4989 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F,
4991 (unsigned short) (0x20 | (tempcx & 0x00C0)));
4992 xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80);
4994 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F,
4995 (unsigned short) (0x30 | (tempcx & 0x00C0)));
4996 xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00);
5000 /* --------------------------------------------------------------------- */
5001 /* Function : XGI_SetLCDCap_B */
5002 /* Input : cx -> LCD Capability */
5005 /* --------------------------------------------------------------------- */
5006 static void XGI_SetLCDCap_B(unsigned short tempcx,
5007 struct vb_device_info *pVBInfo)
5009 if (tempcx & EnableLCD24bpp) /* 24bits */
5010 xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0,
5011 (unsigned short) (((tempcx & 0x00ff) >> 6)
5014 xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0,
5015 (unsigned short) (((tempcx & 0x00ff) >> 6)
5016 | 0x18)); /* Enable Dither */
5019 static void XGI_LongWait(struct vb_device_info *pVBInfo)
5023 i = xgifb_reg_get(pVBInfo->P3c4, 0x1F);
5026 for (i = 0; i < 0xFFFF; i++) {
5027 if (!(inb(pVBInfo->P3da) & 0x08))
5031 for (i = 0; i < 0xFFFF; i++) {
5032 if ((inb(pVBInfo->P3da) & 0x08))
5038 static void SetSpectrum(struct vb_device_info *pVBInfo)
5040 unsigned short index;
5042 index = XGI_GetLCDCapPtr(pVBInfo);
5044 /* disable down spectrum D[4] */
5045 xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x8F);
5046 XGI_LongWait(pVBInfo);
5047 xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x20); /* reset spectrum */
5048 XGI_LongWait(pVBInfo);
5050 xgifb_reg_set(pVBInfo->Part4Port, 0x31,
5051 pVBInfo->LCDCapList[index].Spectrum_31);
5052 xgifb_reg_set(pVBInfo->Part4Port, 0x32,
5053 pVBInfo->LCDCapList[index].Spectrum_32);
5054 xgifb_reg_set(pVBInfo->Part4Port, 0x33,
5055 pVBInfo->LCDCapList[index].Spectrum_33);
5056 xgifb_reg_set(pVBInfo->Part4Port, 0x34,
5057 pVBInfo->LCDCapList[index].Spectrum_34);
5058 XGI_LongWait(pVBInfo);
5059 xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x40); /* enable spectrum */
5062 static void XGI_SetLCDCap(struct vb_device_info *pVBInfo)
5064 unsigned short tempcx;
5066 tempcx = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(pVBInfo)].LCD_Capability;
5068 if (pVBInfo->VBType &
5073 VB_XGI301C)) { /* 301LV/302LV only */
5074 if (pVBInfo->VBType &
5075 (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) {
5076 /* Set 301LV Capability */
5077 xgifb_reg_set(pVBInfo->Part4Port, 0x24,
5078 (unsigned char) (tempcx & 0x1F));
5081 xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D,
5082 ~((EnableVBCLKDRVLOW | EnablePLLSPLOW) >> 8),
5083 (unsigned short) ((tempcx & (EnableVBCLKDRVLOW
5084 | EnablePLLSPLOW)) >> 8));
5087 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
5088 | VB_SIS302LV | VB_XGI301C)) {
5089 if (pVBInfo->VBInfo & SetCRT2ToLCD)
5090 XGI_SetLCDCap_B(tempcx, pVBInfo);
5091 else if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)
5092 XGI_SetLCDCap_A(tempcx, pVBInfo);
5094 if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) {
5095 if (tempcx & EnableSpectrum)
5096 SetSpectrum(pVBInfo);
5100 XGI_SetLCDCap_A(tempcx, pVBInfo);
5104 /* --------------------------------------------------------------------- */
5105 /* Function : XGI_SetAntiFlicker */
5108 /* Description : Set TV Customized Param. */
5109 /* --------------------------------------------------------------------- */
5110 static void XGI_SetAntiFlicker(unsigned short ModeNo,
5111 unsigned short ModeIdIndex,
5112 struct vb_device_info *pVBInfo)
5114 unsigned short tempbx;
5116 unsigned char tempah;
5118 if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p))
5121 tempbx = XGI_GetTVPtrIndex(pVBInfo);
5123 tempah = TVAntiFlickList[tempbx];
5124 tempah = tempah << 4;
5126 xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0x8F, tempah);
5129 static void XGI_SetEdgeEnhance(unsigned short ModeNo,
5130 unsigned short ModeIdIndex,
5131 struct vb_device_info *pVBInfo)
5133 unsigned short tempbx;
5135 unsigned char tempah;
5137 tempbx = XGI_GetTVPtrIndex(pVBInfo);
5139 tempah = TVEdgeList[tempbx];
5140 tempah = tempah << 5;
5142 xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, tempah);
5145 static void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo)
5147 unsigned short tempbx;
5149 unsigned char tempcl, tempch;
5151 unsigned long tempData;
5153 XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */
5154 tempData = TVPhaseList[tempbx];
5156 xgifb_reg_set(pVBInfo->Part2Port, 0x31, (unsigned short) (tempData
5158 xgifb_reg_set(pVBInfo->Part2Port, 0x32, (unsigned short) ((tempData
5159 & 0x0000FF00) >> 8));
5160 xgifb_reg_set(pVBInfo->Part2Port, 0x33, (unsigned short) ((tempData
5161 & 0x00FF0000) >> 16));
5162 xgifb_reg_set(pVBInfo->Part2Port, 0x34, (unsigned short) ((tempData
5163 & 0xFF000000) >> 24));
5166 static void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex,
5167 struct vb_device_info *pVBInfo)
5169 unsigned short tempbx, index;
5170 unsigned char const *filterPtr;
5171 unsigned char tempcl, tempch, tempal;
5173 XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */
5178 filterPtr = NTSCYFilter1;
5182 filterPtr = PALYFilter1;
5189 filterPtr = xgifb_palmn_yfilter1;
5197 filterPtr = xgifb_yfilter2;
5204 tempal = XGI330_EModeIDTable[ModeIdIndex].VB_ExtTVYFilterIndex;
5210 if ((tempcl == 0) && (tempch == 1)) {
5211 xgifb_reg_set(pVBInfo->Part2Port, 0x35, 0);
5212 xgifb_reg_set(pVBInfo->Part2Port, 0x36, 0);
5213 xgifb_reg_set(pVBInfo->Part2Port, 0x37, 0);
5214 xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]);
5216 xgifb_reg_set(pVBInfo->Part2Port, 0x35, filterPtr[index++]);
5217 xgifb_reg_set(pVBInfo->Part2Port, 0x36, filterPtr[index++]);
5218 xgifb_reg_set(pVBInfo->Part2Port, 0x37, filterPtr[index++]);
5219 xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]);
5222 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
5223 | VB_SIS302LV | VB_XGI301C)) {
5224 xgifb_reg_set(pVBInfo->Part2Port, 0x48, filterPtr[index++]);
5225 xgifb_reg_set(pVBInfo->Part2Port, 0x49, filterPtr[index++]);
5226 xgifb_reg_set(pVBInfo->Part2Port, 0x4A, filterPtr[index++]);
5230 /* --------------------------------------------------------------------- */
5231 /* Function : XGI_OEM310Setting */
5234 /* Description : Customized Param. for 301 */
5235 /* --------------------------------------------------------------------- */
5236 static void XGI_OEM310Setting(unsigned short ModeNo,
5237 unsigned short ModeIdIndex,
5238 struct vb_device_info *pVBInfo)
5240 XGI_SetDelayComp(pVBInfo);
5242 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))
5243 XGI_SetLCDCap(pVBInfo);
5245 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5246 XGI_SetPhaseIncr(pVBInfo);
5247 XGI_SetYFilter(ModeNo, ModeIdIndex, pVBInfo);
5248 XGI_SetAntiFlicker(ModeNo, ModeIdIndex, pVBInfo);
5250 if (pVBInfo->VBType & VB_SIS301)
5251 XGI_SetEdgeEnhance(ModeNo, ModeIdIndex, pVBInfo);
5255 /* --------------------------------------------------------------------- */
5256 /* Function : XGI_SetCRT2ModeRegs */
5259 /* Description : Origin code for crt2group */
5260 /* --------------------------------------------------------------------- */
5261 static void XGI_SetCRT2ModeRegs(unsigned short ModeNo,
5262 struct xgi_hw_device_info *HwDeviceExtension,
5263 struct vb_device_info *pVBInfo)
5265 unsigned short tempbl;
5268 unsigned char tempah;
5271 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
5272 tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00);
5273 tempah &= ~0x10; /* BTRAMDAC */
5274 tempah |= 0x40; /* BTRAM */
5276 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV
5278 tempah = 0x40; /* BTDRAM */
5279 tempcl = pVBInfo->ModeType;
5283 tempah = (0x008 >> tempcl);
5288 if (pVBInfo->VBInfo & SetInSlaveMode)
5289 tempah ^= 0x50; /* BTDAC */
5293 xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah);
5297 if (pVBInfo->VBInfo & DisableCRT2Display)
5303 if (!(pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV |
5304 SetCRT2ToLCD | XGI_SetCRT2ToLCDA)))
5307 if ((pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) &&
5308 (!(pVBInfo->VBInfo & SetSimuScanMode))) {
5314 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
5319 if (!(pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD)))
5325 if (!(pVBInfo->VBInfo & SetInSlaveMode))
5328 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) {
5329 tempah = tempah ^ 0x05;
5330 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
5331 tempah = tempah ^ 0x01;
5334 if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge))
5338 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl, tempah);
5340 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD
5341 | XGI_SetCRT2ToLCDA)) {
5343 if ((pVBInfo->ModeType == ModeVGA) && (!(pVBInfo->VBInfo
5344 & SetInSlaveMode))) {
5349 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5351 if (pVBInfo->VBInfo & DriverMode)
5352 tempah = tempah ^ 0x20;
5355 xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D, ~0x0BF, tempah);
5358 if (pVBInfo->LCDInfo & SetLCDDualLink)
5361 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5362 if (pVBInfo->TVInfo & RPLLDIV2XO)
5366 if ((pVBInfo->LCDResInfo == Panel_1280x1024)
5367 || (pVBInfo->LCDResInfo == Panel_1280x1024x75))
5370 if (pVBInfo->LCDResInfo == Panel_1280x960)
5373 xgifb_reg_set(pVBInfo->Part4Port, 0x0C, tempah);
5376 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
5377 | VB_SIS302LV | VB_XGI301C)) {
5381 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
5383 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)
5384 tempah |= 0x04; /* shampoo 0129 */
5387 xgifb_reg_and_or(pVBInfo->Part1Port, 0x13, tempbl, tempah);
5390 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
5391 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
5395 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2c, tempbl, tempah);
5399 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
5400 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
5403 xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, tempbl, tempah);
5408 if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) {
5410 if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge))
5414 xgifb_reg_and_or(pVBInfo->Part4Port, 0x23, tempbl, tempah);
5416 if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) {
5417 if (pVBInfo->LCDInfo & SetLCDDualLink) {
5418 xgifb_reg_or(pVBInfo->Part4Port, 0x27, 0x20);
5419 xgifb_reg_or(pVBInfo->Part4Port, 0x34, 0x10);
5425 void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension,
5426 struct vb_device_info *pVBInfo)
5429 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2f, 0xFF, 0x01);
5433 void XGI_LockCRT2(struct xgi_hw_device_info *HwDeviceExtension,
5434 struct vb_device_info *pVBInfo)
5437 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2F, 0xFE, 0x00);
5441 unsigned char XGI_BridgeIsOn(struct vb_device_info *pVBInfo)
5443 unsigned short flag;
5445 if (pVBInfo->IF_DEF_LVDS == 1) {
5448 flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00);
5449 if ((flag == 1) || (flag == 2))
5450 return 1; /* 301b */
5456 unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE,
5457 unsigned short ModeNo, unsigned short ModeIdIndex,
5458 struct vb_device_info *pVBInfo)
5460 const u8 LCDARefreshIndex[] = {
5461 0x00, 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x00 };
5463 unsigned short RefreshRateTableIndex, i, index, temp;
5465 index = xgifb_reg_get(pVBInfo->P3d4, 0x33);
5466 index = index >> pVBInfo->SelectCRT2Rate;
5469 if (pVBInfo->LCDInfo & LCDNonExpanding)
5475 if (pVBInfo->SetFlag & ProgrammingCRT2) {
5476 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
5477 if (pVBInfo->IF_DEF_LVDS == 0) {
5478 temp = LCDARefreshIndex[
5479 pVBInfo->LCDResInfo & 0x07];
5489 RefreshRateTableIndex = XGI330_EModeIDTable[ModeIdIndex].REFindex;
5490 ModeNo = XGI330_RefIndex[RefreshRateTableIndex].ModeID;
5491 if (pXGIHWDE->jChipType >= XG20) { /* for XG20, XG21, XG27 */
5492 if ((XGI330_RefIndex[RefreshRateTableIndex].XRes == 800) &&
5493 (XGI330_RefIndex[RefreshRateTableIndex].YRes == 600)) {
5496 /* do the similar adjustment like XGISearchCRT1Rate() */
5497 if ((XGI330_RefIndex[RefreshRateTableIndex].XRes == 1024) &&
5498 (XGI330_RefIndex[RefreshRateTableIndex].YRes == 768)) {
5501 if ((XGI330_RefIndex[RefreshRateTableIndex].XRes == 1280) &&
5502 (XGI330_RefIndex[RefreshRateTableIndex].YRes == 1024)) {
5509 if (XGI330_RefIndex[RefreshRateTableIndex + i].
5512 temp = XGI330_RefIndex[RefreshRateTableIndex + i].Ext_InfoFlag;
5513 temp &= ModeTypeMask;
5514 if (temp < pVBInfo->ModeType)
5519 } while (index != 0xFFFF);
5520 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) {
5521 if (pVBInfo->VBInfo & SetInSlaveMode) {
5522 temp = XGI330_RefIndex[RefreshRateTableIndex + i - 1].
5524 if (temp & InterlaceMode)
5529 if ((pVBInfo->SetFlag & ProgrammingCRT2)) {
5530 temp = XGI_AjustCRT2Rate(ModeNo, ModeIdIndex,
5531 RefreshRateTableIndex, &i, pVBInfo);
5533 return RefreshRateTableIndex + i;
5536 static void XGI_SetLCDAGroup(unsigned short ModeNo, unsigned short ModeIdIndex,
5537 struct xgi_hw_device_info *HwDeviceExtension,
5538 struct vb_device_info *pVBInfo)
5540 unsigned short RefreshRateTableIndex;
5542 pVBInfo->SetFlag |= ProgrammingCRT2;
5543 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
5544 ModeIdIndex, pVBInfo);
5545 XGI_GetLVDSResInfo(ModeNo, ModeIdIndex, pVBInfo);
5546 XGI_GetLVDSData(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
5547 XGI_ModCRT1Regs(ModeNo, ModeIdIndex, RefreshRateTableIndex,
5548 HwDeviceExtension, pVBInfo);
5549 XGI_SetLVDSRegs(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
5550 XGI_SetCRT2ECLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
5553 static unsigned char XGI_SetCRT2Group301(unsigned short ModeNo,
5554 struct xgi_hw_device_info *HwDeviceExtension,
5555 struct vb_device_info *pVBInfo)
5557 unsigned short ModeIdIndex, RefreshRateTableIndex;
5559 pVBInfo->SetFlag |= ProgrammingCRT2;
5560 XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo);
5561 pVBInfo->SelectCRT2Rate = 4;
5562 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
5563 ModeIdIndex, pVBInfo);
5564 XGI_SaveCRT2Info(ModeNo, pVBInfo);
5565 XGI_GetCRT2ResInfo(ModeNo, ModeIdIndex, pVBInfo);
5566 XGI_GetCRT2Data(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
5567 XGI_PreSetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension,
5568 RefreshRateTableIndex, pVBInfo);
5569 XGI_SetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension,
5570 RefreshRateTableIndex, pVBInfo);
5571 XGI_SetLockRegs(ModeNo, ModeIdIndex, HwDeviceExtension,
5572 RefreshRateTableIndex, pVBInfo);
5573 XGI_SetGroup2(ModeNo, ModeIdIndex, RefreshRateTableIndex,
5574 HwDeviceExtension, pVBInfo);
5575 XGI_SetLCDRegs(ModeNo, ModeIdIndex, HwDeviceExtension,
5576 RefreshRateTableIndex, pVBInfo);
5577 XGI_SetTap4Regs(pVBInfo);
5578 XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo);
5579 XGI_SetGroup4(ModeNo, ModeIdIndex, RefreshRateTableIndex,
5580 HwDeviceExtension, pVBInfo);
5581 XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
5582 XGI_SetGroup5(ModeNo, ModeIdIndex, pVBInfo);
5583 XGI_AutoThreshold(pVBInfo);
5587 void XGI_SenseCRT1(struct vb_device_info *pVBInfo)
5589 unsigned char CRTCData[17] = { 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81,
5590 0x0B, 0x3E, 0xE9, 0x0B, 0xDF, 0xE7, 0x04, 0x00, 0x00,
5593 unsigned char SR01 = 0, SR1F = 0, SR07 = 0, SR06 = 0;
5595 unsigned char CR17, CR63, SR31;
5596 unsigned short temp;
5597 unsigned char DAC_TEST_PARMS[3] = { 0x0F, 0x0F, 0x0F };
5600 xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86);
5602 /* to fix XG42 single LCD sense to CRT+LCD */
5603 xgifb_reg_set(pVBInfo->P3d4, 0x57, 0x4A);
5604 xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get(
5605 pVBInfo->P3d4, 0x53) | 0x02));
5607 SR31 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x31);
5608 CR63 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x63);
5609 SR01 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x01);
5611 xgifb_reg_set(pVBInfo->P3c4, 0x01, (unsigned char) (SR01 & 0xDF));
5612 xgifb_reg_set(pVBInfo->P3d4, 0x63, (unsigned char) (CR63 & 0xBF));
5614 CR17 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x17);
5615 xgifb_reg_set(pVBInfo->P3d4, 0x17, (unsigned char) (CR17 | 0x80));
5617 SR1F = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x1F);
5618 xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) (SR1F | 0x04));
5620 SR07 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x07);
5621 xgifb_reg_set(pVBInfo->P3c4, 0x07, (unsigned char) (SR07 & 0xFB));
5622 SR06 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x06);
5623 xgifb_reg_set(pVBInfo->P3c4, 0x06, (unsigned char) (SR06 & 0xC3));
5625 xgifb_reg_set(pVBInfo->P3d4, 0x11, 0x00);
5627 for (i = 0; i < 8; i++)
5628 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) i, CRTCData[i]);
5630 for (i = 8; i < 11; i++)
5631 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 8),
5634 for (i = 11; i < 13; i++)
5635 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 4),
5638 for (i = 13; i < 16; i++)
5639 xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i - 3),
5642 xgifb_reg_set(pVBInfo->P3c4, 0x0E, (unsigned char) (CRTCData[16]
5645 xgifb_reg_set(pVBInfo->P3c4, 0x31, 0x00);
5646 xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x1B);
5647 xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE1);
5649 outb(0x00, pVBInfo->P3c8);
5651 for (i = 0; i < 256; i++) {
5652 outb((unsigned char) DAC_TEST_PARMS[0], (pVBInfo->P3c8 + 1));
5653 outb((unsigned char) DAC_TEST_PARMS[1], (pVBInfo->P3c8 + 1));
5654 outb((unsigned char) DAC_TEST_PARMS[2], (pVBInfo->P3c8 + 1));
5659 XGI_WaitDisply(pVBInfo);
5660 temp = inb(pVBInfo->P3c2);
5663 xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x20);
5665 xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x00);
5667 /* avoid display something, set BLACK DAC if not restore DAC */
5668 outb(0x00, pVBInfo->P3c8);
5670 for (i = 0; i < 256; i++) {
5671 outb(0, (pVBInfo->P3c8 + 1));
5672 outb(0, (pVBInfo->P3c8 + 1));
5673 outb(0, (pVBInfo->P3c8 + 1));
5676 xgifb_reg_set(pVBInfo->P3c4, 0x01, SR01);
5677 xgifb_reg_set(pVBInfo->P3d4, 0x63, CR63);
5678 xgifb_reg_set(pVBInfo->P3c4, 0x31, SR31);
5680 xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get(
5681 pVBInfo->P3d4, 0x53) & 0xFD));
5682 xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) SR1F);
5685 static void XGI_EnableBridge(struct xgifb_video_info *xgifb_info,
5686 struct xgi_hw_device_info *HwDeviceExtension,
5687 struct vb_device_info *pVBInfo)
5689 unsigned short tempah;
5691 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
5692 | VB_SIS302LV | VB_XGI301C)) {
5693 if (!(pVBInfo->SetFlag & DisableChA)) {
5694 if (pVBInfo->SetFlag & EnableChA) {
5696 xgifb_reg_set(pVBInfo->Part1Port, 0x1E, 0x20);
5697 } else if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
5699 xgifb_reg_set(pVBInfo->Part1Port,
5704 if (!(pVBInfo->SetFlag & DisableChB)) {
5705 if ((pVBInfo->SetFlag & EnableChB) || (pVBInfo->VBInfo
5706 & (SetCRT2ToLCD | SetCRT2ToTV
5707 | SetCRT2ToRAMDAC))) {
5708 tempah = (unsigned char) xgifb_reg_get(
5709 pVBInfo->P3c4, 0x32);
5711 if (pVBInfo->VBInfo & SetInSlaveMode) {
5712 if (!(pVBInfo->VBInfo &
5716 xgifb_reg_set(pVBInfo->P3c4, 0x32, tempah);
5717 xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x20);
5719 tempah = (unsigned char) xgifb_reg_get(
5720 pVBInfo->Part1Port, 0x2E);
5722 if (!(tempah & 0x80))
5723 xgifb_reg_or(pVBInfo->Part1Port,
5725 xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F);
5729 if ((pVBInfo->SetFlag & (EnableChA | EnableChB))
5730 || (!(pVBInfo->VBInfo & DisableCRT2Display))) {
5731 xgifb_reg_and_or(pVBInfo->Part2Port, 0x00, ~0xE0,
5732 0x20); /* shampoo 0129 */
5733 if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) {
5734 if (!XGI_DisableChISLCD(pVBInfo)) {
5735 if (XGI_EnableChISLCD(pVBInfo) ||
5737 (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)))
5738 /* LVDS PLL power on */
5744 /* LVDS Driver power on */
5745 xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x7F);
5751 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
5754 if (!(pVBInfo->VBInfo & SetSimuScanMode) &&
5755 (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) &&
5756 (pVBInfo->VBInfo & SetCRT2ToDualEdge)) {
5757 tempah = tempah & 0x40;
5758 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)
5759 tempah = tempah ^ 0xC0;
5761 if (pVBInfo->SetFlag & DisableChB)
5764 if (pVBInfo->SetFlag & DisableChA)
5767 if (pVBInfo->SetFlag & EnableChB)
5770 if (pVBInfo->SetFlag & EnableChA)
5775 /* EnablePart4_1F */
5776 xgifb_reg_or(pVBInfo->Part4Port, 0x1F, tempah);
5778 if (!(pVBInfo->SetFlag & DisableChA)) {
5779 if (!(pVBInfo->SetFlag & GatingCRT)) {
5780 XGI_DisableGatingCRT(HwDeviceExtension,
5782 XGI_DisplayOn(xgifb_info, HwDeviceExtension,
5788 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD
5789 | XGI_SetCRT2ToLCDA))
5791 xgifb_reg_or(pVBInfo->Part1Port, 0x1E, 0x20);
5793 tempah = (unsigned char) xgifb_reg_get(pVBInfo->Part1Port,
5795 if (!(tempah & 0x80))
5796 xgifb_reg_or(pVBInfo->Part1Port, 0x2E, 0x80);
5798 xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F);
5799 XGI_DisplayOn(xgifb_info, HwDeviceExtension, pVBInfo);
5803 static void XGI_SetCRT1Group(struct xgifb_video_info *xgifb_info,
5804 struct xgi_hw_device_info *HwDeviceExtension,
5805 unsigned short ModeNo, unsigned short ModeIdIndex,
5806 struct vb_device_info *pVBInfo)
5808 unsigned short RefreshRateTableIndex, temp;
5810 XGI_SetSeqRegs(ModeNo, ModeIdIndex, pVBInfo);
5811 outb(XGI330_StandTable.MISC, pVBInfo->P3c2);
5812 XGI_SetCRTCRegs(HwDeviceExtension, pVBInfo);
5813 XGI_SetATTRegs(ModeNo, ModeIdIndex, pVBInfo);
5814 XGI_SetGRCRegs(pVBInfo);
5815 XGI_ClearExt1Regs(pVBInfo);
5817 if (HwDeviceExtension->jChipType == XG27) {
5818 if (pVBInfo->IF_DEF_LVDS == 0)
5819 XGI_SetDefaultVCLK(pVBInfo);
5822 temp = ~ProgrammingCRT2;
5823 pVBInfo->SetFlag &= temp;
5824 pVBInfo->SelectCRT2Rate = 0;
5826 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
5827 | VB_SIS302LV | VB_XGI301C)) {
5828 if (pVBInfo->VBInfo & (SetSimuScanMode | XGI_SetCRT2ToLCDA
5829 | SetInSlaveMode)) {
5830 pVBInfo->SetFlag |= ProgrammingCRT2;
5834 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
5835 ModeIdIndex, pVBInfo);
5836 if (RefreshRateTableIndex != 0xFFFF) {
5837 XGI_SetSync(RefreshRateTableIndex, pVBInfo);
5838 XGI_SetCRT1CRTC(ModeNo, ModeIdIndex, RefreshRateTableIndex,
5839 pVBInfo, HwDeviceExtension);
5840 XGI_SetCRT1DE(HwDeviceExtension, ModeNo, ModeIdIndex,
5841 RefreshRateTableIndex, pVBInfo);
5842 XGI_SetCRT1Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
5843 HwDeviceExtension, pVBInfo);
5844 XGI_SetCRT1VCLK(ModeNo, ModeIdIndex, HwDeviceExtension,
5845 RefreshRateTableIndex, pVBInfo);
5848 if (HwDeviceExtension->jChipType >= XG21) {
5849 temp = xgifb_reg_get(pVBInfo->P3d4, 0x38);
5852 if (HwDeviceExtension->jChipType == XG27)
5853 XGI_SetXG27CRTC(ModeNo, ModeIdIndex,
5854 RefreshRateTableIndex, pVBInfo);
5856 XGI_SetXG21CRTC(ModeNo, ModeIdIndex,
5857 RefreshRateTableIndex, pVBInfo);
5859 XGI_UpdateXG21CRTC(ModeNo, pVBInfo,
5860 RefreshRateTableIndex);
5862 xgifb_set_lcd(HwDeviceExtension->jChipType,
5863 pVBInfo, RefreshRateTableIndex, ModeNo);
5865 if (pVBInfo->IF_DEF_LVDS == 1)
5866 xgifb_set_lvds(xgifb_info,
5867 HwDeviceExtension->jChipType,
5868 ModeNo, ModeIdIndex, pVBInfo);
5872 pVBInfo->SetFlag &= (~ProgrammingCRT2);
5873 XGI_SetCRT1FIFO(ModeNo, HwDeviceExtension, pVBInfo);
5874 XGI_SetCRT1ModeRegs(HwDeviceExtension, ModeNo, ModeIdIndex,
5875 RefreshRateTableIndex, pVBInfo);
5876 XGI_LoadDAC(ModeNo, ModeIdIndex, pVBInfo);
5879 unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info,
5880 struct xgi_hw_device_info *HwDeviceExtension,
5881 unsigned short ModeNo)
5883 unsigned short ModeIdIndex;
5884 struct vb_device_info VBINF;
5885 struct vb_device_info *pVBInfo = &VBINF;
5886 pVBInfo->IF_DEF_LVDS = 0;
5888 if (HwDeviceExtension->jChipType >= XG20) {
5889 pVBInfo->IF_DEF_YPbPr = 0;
5890 pVBInfo->IF_DEF_HiVision = 0;
5891 pVBInfo->IF_DEF_CRT2Monitor = 0;
5892 pVBInfo->VBType = 0; /*set VBType default 0*/
5894 pVBInfo->IF_DEF_YPbPr = 1;
5895 pVBInfo->IF_DEF_HiVision = 1;
5896 pVBInfo->IF_DEF_CRT2Monitor = 1;
5899 XGIRegInit(pVBInfo, xgifb_info->vga_base);
5901 /* for x86 Linux, XG21 LVDS */
5902 if (HwDeviceExtension->jChipType == XG21) {
5903 if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0)
5904 pVBInfo->IF_DEF_LVDS = 1;
5906 if (HwDeviceExtension->jChipType == XG27) {
5907 if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) {
5908 if (xgifb_reg_get(pVBInfo->P3d4, 0x30) & 0x20)
5909 pVBInfo->IF_DEF_LVDS = 1;
5913 if (HwDeviceExtension->jChipType < XG20)
5914 XGI_GetVBType(pVBInfo);
5916 InitTo330Pointer(HwDeviceExtension->jChipType, pVBInfo);
5918 ModeNo = ModeNo & 0x7F;
5919 xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86);
5921 if (HwDeviceExtension->jChipType < XG20)
5922 XGI_UnLockCRT2(HwDeviceExtension, pVBInfo);
5924 XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo);
5926 if (HwDeviceExtension->jChipType < XG20) {
5927 XGI_GetVBInfo(ModeNo, ModeIdIndex, HwDeviceExtension, pVBInfo);
5928 XGI_GetTVInfo(ModeNo, ModeIdIndex, pVBInfo);
5929 XGI_GetLCDInfo(ModeNo, ModeIdIndex, pVBInfo);
5930 XGI_DisableBridge(xgifb_info, HwDeviceExtension, pVBInfo);
5932 if (pVBInfo->VBInfo & (SetSimuScanMode | XGI_SetCRT2ToLCDA)) {
5933 XGI_SetCRT1Group(xgifb_info, HwDeviceExtension, ModeNo,
5934 ModeIdIndex, pVBInfo);
5936 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
5937 XGI_SetLCDAGroup(ModeNo, ModeIdIndex,
5938 HwDeviceExtension, pVBInfo);
5940 } else if (!(pVBInfo->VBInfo & SwitchCRT2)) {
5941 XGI_SetCRT1Group(xgifb_info,
5942 HwDeviceExtension, ModeNo,
5943 ModeIdIndex, pVBInfo);
5944 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
5945 XGI_SetLCDAGroup(ModeNo, ModeIdIndex,
5951 if (pVBInfo->VBInfo & (SetSimuScanMode | SwitchCRT2)) {
5952 switch (HwDeviceExtension->ujVBChipID) {
5954 XGI_SetCRT2Group301(ModeNo, HwDeviceExtension,
5955 pVBInfo); /*add for CRT2 */
5959 XGI_SetCRT2Group301(ModeNo, HwDeviceExtension,
5960 pVBInfo); /*add for CRT2 */
5968 XGI_SetCRT2ModeRegs(ModeNo, HwDeviceExtension, pVBInfo);
5969 XGI_OEM310Setting(ModeNo, ModeIdIndex, pVBInfo); /*0212*/
5970 XGI_EnableBridge(xgifb_info, HwDeviceExtension, pVBInfo);
5973 if (pVBInfo->IF_DEF_LVDS == 1)
5974 if (!XGI_XG21CheckLVDSMode(xgifb_info, ModeNo,
5979 pVBInfo->ModeType = XGI330_EModeIDTable[ModeIdIndex].
5980 Ext_ModeFlag & ModeTypeMask;
5982 pVBInfo->SetFlag = 0;
5983 pVBInfo->VBInfo = DisableCRT2Display;
5985 XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo);
5987 XGI_SetCRT1Group(xgifb_info, HwDeviceExtension, ModeNo,
5988 ModeIdIndex, pVBInfo);
5990 XGI_DisplayOn(xgifb_info, HwDeviceExtension, pVBInfo);
5993 XGI_UpdateModeInfo(HwDeviceExtension, pVBInfo);
5995 if (HwDeviceExtension->jChipType < XG20)
5996 XGI_LockCRT2(HwDeviceExtension, pVBInfo);