Merge tag 'sound-3.11' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound
[linux-2.6.git] / drivers / staging / xgifb / vb_setmode.c
blobfcefe5b36cddb99c01eaae5d85772016db7e6f6b
1 #include <linux/delay.h>
2 #include "XGIfb.h"
4 #include "vb_def.h"
5 #include "vb_init.h"
6 #include "vb_util.h"
7 #include "vb_table.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;
31 pVBInfo->LCDInfo = 0;
32 pVBInfo->VBInfo = 0;
33 pVBInfo->TVInfo = 0;
35 pVBInfo->SR18 = XGI340_SR18;
36 pVBInfo->CR40 = XGI340_cr41;
38 if (ChipType < XG20)
39 XGI_GetVBType(pVBInfo);
41 /* 310 customization related */
42 if ((pVBInfo->VBType & VB_SIS301LV) || (pVBInfo->VBType & VB_SIS302LV))
43 pVBInfo->LCDCapList = XGI_LCDDLCapList;
44 else
45 pVBInfo->LCDCapList = XGI_LCDCapList;
47 if (ChipType >= XG20)
48 pVBInfo->XGINew_CR97 = 0x10;
50 if (ChipType == XG27) {
51 unsigned char temp;
52 pVBInfo->MCLKData = XGI27New_MCLKData;
53 pVBInfo->CR40 = XGI27_cr41;
54 pVBInfo->XGINew_CR97 = 0xc1;
55 pVBInfo->SR18 = XG27_SR18;
57 /*Z11m DDR*/
58 temp = xgifb_reg_get(pVBInfo->P3c4, 0x3B);
59 /* SR3B[7][3]MAA15 MAA11 (Power on Trapping) */
60 if (((temp & 0x88) == 0x80) || ((temp & 0x88) == 0x08))
61 pVBInfo->XGINew_CR97 = 0x80;
66 static void XGI_SetSeqRegs(unsigned short ModeNo,
67 unsigned short ModeIdIndex,
68 struct vb_device_info *pVBInfo)
70 unsigned char SRdata, i;
72 xgifb_reg_set(pVBInfo->P3c4, 0x00, 0x03); /* Set SR0 */
74 for (i = 0; i < 4; i++) {
75 /* Get SR1,2,3,4 from file */
76 /* SR1 is with screen off 0x20 */
77 SRdata = XGI330_StandTable.SR[i];
78 xgifb_reg_set(pVBInfo->P3c4, i+1, SRdata); /* Set SR 1 2 3 4 */
82 static void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension,
83 struct vb_device_info *pVBInfo)
85 unsigned char CRTCdata;
86 unsigned short i;
88 CRTCdata = xgifb_reg_get(pVBInfo->P3d4, 0x11);
89 CRTCdata &= 0x7f;
90 xgifb_reg_set(pVBInfo->P3d4, 0x11, CRTCdata); /* Unlock CRTC */
92 for (i = 0; i <= 0x18; i++) {
93 /* Get CRTC from file */
94 CRTCdata = XGI330_StandTable.CRTC[i];
95 xgifb_reg_set(pVBInfo->P3d4, i, CRTCdata); /* Set CRTC(3d4) */
99 static void XGI_SetATTRegs(unsigned short ModeNo,
100 unsigned short ModeIdIndex,
101 struct vb_device_info *pVBInfo)
103 unsigned char ARdata;
104 unsigned short i, modeflag;
106 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
108 for (i = 0; i <= 0x13; i++) {
109 ARdata = XGI330_StandTable.ATTR[i];
111 if ((modeflag & Charx8Dot) && i == 0x13) { /* ifndef Dot9 */
112 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
113 ARdata = 0;
114 } else if ((pVBInfo->VBInfo &
115 (SetCRT2ToTV | SetCRT2ToLCD)) &&
116 (pVBInfo->VBInfo & SetInSlaveMode)) {
117 ARdata = 0;
121 inb(pVBInfo->P3da); /* reset 3da */
122 outb(i, pVBInfo->P3c0); /* set index */
123 outb(ARdata, pVBInfo->P3c0); /* set data */
126 inb(pVBInfo->P3da); /* reset 3da */
127 outb(0x14, pVBInfo->P3c0); /* set index */
128 outb(0x00, pVBInfo->P3c0); /* set data */
129 inb(pVBInfo->P3da); /* Enable Attribute */
130 outb(0x20, pVBInfo->P3c0);
133 static void XGI_SetGRCRegs(struct vb_device_info *pVBInfo)
135 unsigned char GRdata;
136 unsigned short i;
138 for (i = 0; i <= 0x08; i++) {
139 /* Get GR from file */
140 GRdata = XGI330_StandTable.GRC[i];
141 xgifb_reg_set(pVBInfo->P3ce, i, GRdata); /* Set GR(3ce) */
144 if (pVBInfo->ModeType > ModeVGA) {
145 GRdata = xgifb_reg_get(pVBInfo->P3ce, 0x05);
146 GRdata &= 0xBF; /* 256 color disable */
147 xgifb_reg_set(pVBInfo->P3ce, 0x05, GRdata);
151 static void XGI_ClearExt1Regs(struct vb_device_info *pVBInfo)
153 unsigned short i;
155 for (i = 0x0A; i <= 0x0E; i++)
156 xgifb_reg_set(pVBInfo->P3c4, i, 0x00); /* Clear SR0A-SR0E */
159 static unsigned char XGI_SetDefaultVCLK(struct vb_device_info *pVBInfo)
162 xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x20);
163 xgifb_reg_set(pVBInfo->P3c4, 0x2B, XGI_VCLKData[0].SR2B);
164 xgifb_reg_set(pVBInfo->P3c4, 0x2C, XGI_VCLKData[0].SR2C);
166 xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x10);
167 xgifb_reg_set(pVBInfo->P3c4, 0x2B, XGI_VCLKData[1].SR2B);
168 xgifb_reg_set(pVBInfo->P3c4, 0x2C, XGI_VCLKData[1].SR2C);
170 xgifb_reg_and(pVBInfo->P3c4, 0x31, ~0x30);
171 return 0;
174 static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo,
175 unsigned short ModeIdIndex,
176 unsigned short RefreshRateTableIndex, unsigned short *i,
177 struct vb_device_info *pVBInfo)
179 unsigned short tempax, tempbx, resinfo, modeflag, infoflag;
181 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
182 resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO;
183 tempbx = XGI330_RefIndex[RefreshRateTableIndex + (*i)].ModeID;
184 tempax = 0;
186 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
187 tempax |= SupportRAMDAC2;
189 if (pVBInfo->VBType & VB_XGI301C)
190 tempax |= SupportCRT2in301C;
193 /* 301b */
194 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
195 tempax |= SupportLCD;
197 if (pVBInfo->LCDResInfo != Panel_1280x1024 &&
198 pVBInfo->LCDResInfo != Panel_1280x960 &&
199 (pVBInfo->LCDInfo & LCDNonExpanding) &&
200 resinfo >= 9)
201 return 0;
204 if (pVBInfo->VBInfo & SetCRT2ToHiVision) { /* for HiTV */
205 tempax |= SupportHiVision;
206 if ((pVBInfo->VBInfo & SetInSlaveMode) &&
207 ((resinfo == 4) ||
208 (resinfo == 3 && (pVBInfo->SetFlag & TVSimuMode)) ||
209 (resinfo > 7)))
210 return 0;
211 } else if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO | SetCRT2ToSVIDEO |
212 SetCRT2ToSCART | SetCRT2ToYPbPr525750 |
213 SetCRT2ToHiVision)) {
214 tempax |= SupportTV;
216 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
217 VB_SIS302LV | VB_XGI301C))
218 tempax |= SupportTV1024;
220 if (!(pVBInfo->VBInfo & TVSetPAL) &&
221 (modeflag & NoSupportSimuTV) &&
222 (pVBInfo->VBInfo & SetInSlaveMode) &&
223 (!(pVBInfo->VBInfo & SetNotSimuMode)))
224 return 0;
227 for (; XGI330_RefIndex[RefreshRateTableIndex + (*i)].ModeID ==
228 tempbx; (*i)--) {
229 infoflag = XGI330_RefIndex[RefreshRateTableIndex + (*i)].
230 Ext_InfoFlag;
231 if (infoflag & tempax)
232 return 1;
234 if ((*i) == 0)
235 break;
238 for ((*i) = 0;; (*i)++) {
239 infoflag = XGI330_RefIndex[RefreshRateTableIndex + (*i)].
240 Ext_InfoFlag;
241 if (XGI330_RefIndex[RefreshRateTableIndex + (*i)].ModeID
242 != tempbx) {
243 return 0;
246 if (infoflag & tempax)
247 return 1;
249 return 1;
252 static void XGI_SetSync(unsigned short RefreshRateTableIndex,
253 struct vb_device_info *pVBInfo)
255 unsigned short sync, temp;
257 /* di+0x00 */
258 sync = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag >> 8;
259 sync &= 0xC0;
260 temp = 0x2F;
261 temp |= sync;
262 outb(temp, pVBInfo->P3c2); /* Set Misc(3c2) */
265 static void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo,
266 struct xgi_hw_device_info *HwDeviceExtension)
268 unsigned char data, data1, pushax;
269 unsigned short i, j;
271 /* unlock cr0-7 */
272 data = xgifb_reg_get(pVBInfo->P3d4, 0x11);
273 data &= 0x7F;
274 xgifb_reg_set(pVBInfo->P3d4, 0x11, data);
276 data = pVBInfo->TimingH.data[0];
277 xgifb_reg_set(pVBInfo->P3d4, 0, data);
279 for (i = 0x01; i <= 0x04; i++) {
280 data = pVBInfo->TimingH.data[i];
281 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 1), data);
284 for (i = 0x05; i <= 0x06; i++) {
285 data = pVBInfo->TimingH.data[i];
286 xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i + 6), data);
289 j = xgifb_reg_get(pVBInfo->P3c4, 0x0e);
290 j &= 0x1F;
291 data = pVBInfo->TimingH.data[7];
292 data &= 0xE0;
293 data |= j;
294 xgifb_reg_set(pVBInfo->P3c4, 0x0e, data);
296 if (HwDeviceExtension->jChipType >= XG20) {
297 data = xgifb_reg_get(pVBInfo->P3d4, 0x04);
298 data = data - 1;
299 xgifb_reg_set(pVBInfo->P3d4, 0x04, data);
300 data = xgifb_reg_get(pVBInfo->P3d4, 0x05);
301 data1 = data;
302 data1 &= 0xE0;
303 data &= 0x1F;
304 if (data == 0) {
305 pushax = data;
306 data = xgifb_reg_get(pVBInfo->P3c4, 0x0c);
307 data &= 0xFB;
308 xgifb_reg_set(pVBInfo->P3c4, 0x0c, data);
309 data = pushax;
311 data = data - 1;
312 data |= data1;
313 xgifb_reg_set(pVBInfo->P3d4, 0x05, data);
314 data = xgifb_reg_get(pVBInfo->P3c4, 0x0e);
315 data = data >> 5;
316 data = data + 3;
317 if (data > 7)
318 data = data - 7;
319 data = data << 5;
320 xgifb_reg_and_or(pVBInfo->P3c4, 0x0e, ~0xE0, data);
324 static void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex,
325 unsigned short ModeNo,
326 struct vb_device_info *pVBInfo)
328 unsigned char data;
329 unsigned short i, j;
331 for (i = 0x00; i <= 0x01; i++) {
332 data = pVBInfo->TimingV.data[i];
333 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 6), data);
336 for (i = 0x02; i <= 0x03; i++) {
337 data = pVBInfo->TimingV.data[i];
338 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x0e), data);
341 for (i = 0x04; i <= 0x05; i++) {
342 data = pVBInfo->TimingV.data[i];
343 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x11), data);
346 j = xgifb_reg_get(pVBInfo->P3c4, 0x0a);
347 j &= 0xC0;
348 data = pVBInfo->TimingV.data[6];
349 data &= 0x3F;
350 data |= j;
351 xgifb_reg_set(pVBInfo->P3c4, 0x0a, data);
353 data = pVBInfo->TimingV.data[6];
354 data &= 0x80;
355 data = data >> 2;
357 i = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
358 i &= DoubleScanMode;
359 if (i)
360 data |= 0x80;
362 j = xgifb_reg_get(pVBInfo->P3d4, 0x09);
363 j &= 0x5F;
364 data |= j;
365 xgifb_reg_set(pVBInfo->P3d4, 0x09, data);
368 static void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
369 unsigned short RefreshRateTableIndex,
370 struct vb_device_info *pVBInfo,
371 struct xgi_hw_device_info *HwDeviceExtension)
373 unsigned char index, data;
374 unsigned short i;
376 /* Get index */
377 index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
378 index = index & IndexMask;
380 data = xgifb_reg_get(pVBInfo->P3d4, 0x11);
381 data &= 0x7F;
382 xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */
384 for (i = 0; i < 8; i++)
385 pVBInfo->TimingH.data[i]
386 = XGI_CRT1Table[index].CR[i];
388 for (i = 0; i < 7; i++)
389 pVBInfo->TimingV.data[i]
390 = XGI_CRT1Table[index].CR[i + 8];
392 XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension);
394 XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo);
396 if (pVBInfo->ModeType > 0x03)
397 xgifb_reg_set(pVBInfo->P3d4, 0x14, 0x4F);
400 /* --------------------------------------------------------------------- */
401 /* Function : XGI_SetXG21CRTC */
402 /* Input : Stand or enhance CRTC table */
403 /* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */
404 /* Description : Set LCD timing */
405 /* --------------------------------------------------------------------- */
406 static void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
407 unsigned short RefreshRateTableIndex,
408 struct vb_device_info *pVBInfo)
410 unsigned char index, Tempax, Tempbx, Tempcx, Tempdx;
411 unsigned short Temp1, Temp2, Temp3;
413 index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
414 /* Tempax: CR4 HRS */
415 Tempax = XGI_CRT1Table[index].CR[3];
416 Tempcx = Tempax; /* Tempcx: HRS */
417 /* SR2E[7:0]->HRS */
418 xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax);
420 Tempdx = XGI_CRT1Table[index].CR[5]; /* SRB */
421 Tempdx &= 0xC0; /* Tempdx[7:6]: SRB[7:6] */
422 Temp1 = Tempdx; /* Temp1[7:6]: HRS[9:8] */
423 Temp1 <<= 2; /* Temp1[9:8]: HRS[9:8] */
424 Temp1 |= Tempax; /* Temp1[9:0]: HRS[9:0] */
426 Tempax = XGI_CRT1Table[index].CR[4]; /* CR5 HRE */
427 Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */
429 Tempbx = XGI_CRT1Table[index].CR[6]; /* SRC */
430 Tempbx &= 0x04; /* Tempbx[2]: HRE[5] */
431 Tempbx <<= 3; /* Tempbx[5]: HRE[5] */
432 Tempax |= Tempbx; /* Tempax[5:0]: HRE[5:0] */
434 Temp2 = Temp1 & 0x3C0; /* Temp2[9:6]: HRS[9:6] */
435 Temp2 |= Tempax; /* Temp2[9:0]: HRE[9:0] */
437 Tempcx &= 0x3F; /* Tempcx[5:0]: HRS[5:0] */
438 if (Tempax < Tempcx) /* HRE < HRS */
439 Temp2 |= 0x40; /* Temp2 + 0x40 */
441 Temp2 &= 0xFF;
442 Tempax = (unsigned char) Temp2; /* Tempax: HRE[7:0] */
443 Tempax <<= 2; /* Tempax[7:2]: HRE[5:0] */
444 Tempdx >>= 6; /* Tempdx[7:6]->[1:0] HRS[9:8] */
445 Tempax |= Tempdx; /* HRE[5:0]HRS[9:8] */
446 /* SR2F D[7:2]->HRE, D[1:0]->HRS */
447 xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax);
448 xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00);
450 /* CR10 VRS */
451 Tempax = XGI_CRT1Table[index].CR[10];
452 Tempbx = Tempax; /* Tempbx: VRS */
453 Tempax &= 0x01; /* Tempax[0]: VRS[0] */
454 xgifb_reg_or(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS[0] */
455 /* CR7[2][7] VRE */
456 Tempax = XGI_CRT1Table[index].CR[9];
457 Tempcx = Tempbx >> 1; /* Tempcx[6:0]: VRS[7:1] */
458 Tempdx = Tempax & 0x04; /* Tempdx[2]: CR7[2] */
459 Tempdx <<= 5; /* Tempdx[7]: VRS[8] */
460 Tempcx |= Tempdx; /* Tempcx[7:0]: VRS[8:1] */
461 xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempcx); /* SR34[8:1]->VRS */
463 Temp1 = Tempdx; /* Temp1[7]: Tempdx[7] */
464 Temp1 <<= 1; /* Temp1[8]: VRS[8] */
465 Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */
466 Tempax &= 0x80;
467 Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */
468 Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */
469 /* Tempax: SRA */
470 Tempax = XGI_CRT1Table[index].CR[14];
471 Tempax &= 0x08; /* Tempax[3]: VRS[3] */
472 Temp2 = Tempax;
473 Temp2 <<= 7; /* Temp2[10]: VRS[10] */
474 Temp1 |= Temp2; /* Temp1[10:0]: VRS[10:0] */
476 /* Tempax: CR11 VRE */
477 Tempax = XGI_CRT1Table[index].CR[11];
478 Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
479 /* Tempbx: SRA */
480 Tempbx = XGI_CRT1Table[index].CR[14];
481 Tempbx &= 0x20; /* Tempbx[5]: VRE[5] */
482 Tempbx >>= 1; /* Tempbx[4]: VRE[4] */
483 Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */
484 Temp2 = Temp1 & 0x7E0; /* Temp2[10:5]: VRS[10:5] */
485 Temp2 |= Tempax; /* Temp2[10:5]: VRE[10:5] */
487 Temp3 = Temp1 & 0x1F; /* Temp3[4:0]: VRS[4:0] */
488 if (Tempax < Temp3) /* VRE < VRS */
489 Temp2 |= 0x20; /* VRE + 0x20 */
491 Temp2 &= 0xFF;
492 Tempax = (unsigned char) Temp2; /* Tempax: VRE[7:0] */
493 Tempax <<= 2; /* Tempax[7:0]; VRE[5:0]00 */
494 Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */
495 Temp1 >>= 9; /* Temp1[1:0]: VRS[10:9] */
496 Tempbx = (unsigned char) Temp1;
497 Tempax |= Tempbx; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */
498 Tempax &= 0x7F;
499 /* SR3F D[7:2]->VRE D[1:0]->VRS */
500 xgifb_reg_set(pVBInfo->P3c4, 0x3F, Tempax);
503 static void XGI_SetXG27CRTC(unsigned short ModeNo,
504 unsigned short ModeIdIndex,
505 unsigned short RefreshRateTableIndex,
506 struct vb_device_info *pVBInfo)
508 unsigned short index, Tempax, Tempbx, Tempcx;
510 index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
511 /* Tempax: CR4 HRS */
512 Tempax = XGI_CRT1Table[index].CR[3];
513 Tempbx = Tempax; /* Tempbx: HRS[7:0] */
514 /* SR2E[7:0]->HRS */
515 xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax);
517 /* SR0B */
518 Tempax = XGI_CRT1Table[index].CR[5];
519 Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
520 Tempbx |= (Tempax << 2); /* Tempbx: HRS[9:0] */
522 Tempax = XGI_CRT1Table[index].CR[4]; /* CR5 HRE */
523 Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */
524 Tempcx = Tempax; /* Tempcx: HRE[4:0] */
526 Tempax = XGI_CRT1Table[index].CR[6]; /* SRC */
527 Tempax &= 0x04; /* Tempax[2]: HRE[5] */
528 Tempax <<= 3; /* Tempax[5]: HRE[5] */
529 Tempcx |= Tempax; /* Tempcx[5:0]: HRE[5:0] */
531 Tempbx = Tempbx & 0x3C0; /* Tempbx[9:6]: HRS[9:6] */
532 Tempbx |= Tempcx; /* Tempbx: HRS[9:6]HRE[5:0] */
534 /* Tempax: CR4 HRS */
535 Tempax = XGI_CRT1Table[index].CR[3];
536 Tempax &= 0x3F; /* Tempax: HRS[5:0] */
537 if (Tempcx <= Tempax) /* HRE[5:0] < HRS[5:0] */
538 Tempbx += 0x40; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/
540 Tempax = XGI_CRT1Table[index].CR[5]; /* SR0B */
541 Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
542 Tempax >>= 6; /* Tempax[1:0]: HRS[9:8]*/
543 Tempax |= ((Tempbx << 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */
544 /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */
545 xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax);
546 xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00);
548 /* CR10 VRS */
549 Tempax = XGI_CRT1Table[index].CR[10];
550 /* SR34[7:0]->VRS[7:0] */
551 xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempax);
553 Tempcx = Tempax; /* Tempcx <= VRS[7:0] */
554 /* CR7[7][2] VRS[9][8] */
555 Tempax = XGI_CRT1Table[index].CR[9];
556 Tempbx = Tempax; /* Tempbx <= CR07[7:0] */
557 Tempax = Tempax & 0x04; /* Tempax[2]: CR7[2]: VRS[8] */
558 Tempax >>= 2; /* Tempax[0]: VRS[8] */
559 /* SR35[0]: VRS[8] */
560 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x01, Tempax);
561 Tempcx |= (Tempax << 8); /* Tempcx <= VRS[8:0] */
562 Tempcx |= ((Tempbx & 0x80) << 2); /* Tempcx <= VRS[9:0] */
563 /* Tempax: SR0A */
564 Tempax = XGI_CRT1Table[index].CR[14];
565 Tempax &= 0x08; /* SR0A[3] VRS[10] */
566 Tempcx |= (Tempax << 7); /* Tempcx <= VRS[10:0] */
568 /* Tempax: CR11 VRE */
569 Tempax = XGI_CRT1Table[index].CR[11];
570 Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
571 /* Tempbx: SR0A */
572 Tempbx = XGI_CRT1Table[index].CR[14];
573 Tempbx &= 0x20; /* Tempbx[5]: SR0A[5]: VRE[4] */
574 Tempbx >>= 1; /* Tempbx[4]: VRE[4] */
575 Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */
576 Tempbx = Tempcx; /* Tempbx: VRS[10:0] */
577 Tempbx &= 0x7E0; /* Tempbx[10:5]: VRS[10:5] */
578 Tempbx |= Tempax; /* Tempbx: VRS[10:5]VRE[4:0] */
580 if (Tempbx <= Tempcx) /* VRE <= VRS */
581 Tempbx |= 0x20; /* VRE + 0x20 */
583 /* Tempax: Tempax[7:0]; VRE[5:0]00 */
584 Tempax = (Tempbx << 2) & 0xFF;
585 /* SR3F[7:2]:VRE[5:0] */
586 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax);
587 Tempax = Tempcx >> 8;
588 /* SR35[2:0]:VRS[10:8] */
589 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, Tempax);
592 static void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo)
594 unsigned char temp;
596 /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */
597 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
598 temp = (temp & 3) << 6;
599 /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */
600 xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0xc0, temp & 0x80);
601 /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */
602 xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80);
606 static void xgifb_set_lcd(int chip_id,
607 struct vb_device_info *pVBInfo,
608 unsigned short RefreshRateTableIndex,
609 unsigned short ModeNo)
611 unsigned short temp;
613 xgifb_reg_set(pVBInfo->P3d4, 0x2E, 0x00);
614 xgifb_reg_set(pVBInfo->P3d4, 0x2F, 0x00);
615 xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x00);
616 xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x00);
618 if (chip_id == XG27) {
619 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
620 if ((temp & 0x03) == 0) { /* dual 12 */
621 xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x13);
622 xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x13);
626 if (chip_id == XG27) {
627 XGI_SetXG27FPBits(pVBInfo);
628 } else {
629 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
630 if (temp & 0x01) {
631 /* 18 bits FP */
632 xgifb_reg_or(pVBInfo->P3c4, 0x06, 0x40);
633 xgifb_reg_or(pVBInfo->P3c4, 0x09, 0x40);
637 xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */
639 xgifb_reg_and(pVBInfo->P3c4, 0x30, ~0x20); /* Hsync polarity */
640 xgifb_reg_and(pVBInfo->P3c4, 0x35, ~0x80); /* Vsync polarity */
642 temp = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
643 if (temp & 0x4000)
644 /* Hsync polarity */
645 xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20);
646 if (temp & 0x8000)
647 /* Vsync polarity */
648 xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80);
651 /* --------------------------------------------------------------------- */
652 /* Function : XGI_UpdateXG21CRTC */
653 /* Input : */
654 /* Output : CRT1 CRTC */
655 /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */
656 /* --------------------------------------------------------------------- */
657 static void XGI_UpdateXG21CRTC(unsigned short ModeNo,
658 struct vb_device_info *pVBInfo,
659 unsigned short RefreshRateTableIndex)
661 int index = -1;
663 xgifb_reg_and(pVBInfo->P3d4, 0x11, 0x7F); /* Unlock CR0~7 */
664 if (ModeNo == 0x2E &&
665 (XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC ==
666 RES640x480x60))
667 index = 12;
668 else if (ModeNo == 0x2E && (XGI330_RefIndex[RefreshRateTableIndex].
669 Ext_CRT1CRTC == RES640x480x72))
670 index = 13;
671 else if (ModeNo == 0x2F)
672 index = 14;
673 else if (ModeNo == 0x50)
674 index = 15;
675 else if (ModeNo == 0x59)
676 index = 16;
678 if (index != -1) {
679 xgifb_reg_set(pVBInfo->P3d4, 0x02,
680 XGI_UpdateCRT1Table[index].CR02);
681 xgifb_reg_set(pVBInfo->P3d4, 0x03,
682 XGI_UpdateCRT1Table[index].CR03);
683 xgifb_reg_set(pVBInfo->P3d4, 0x15,
684 XGI_UpdateCRT1Table[index].CR15);
685 xgifb_reg_set(pVBInfo->P3d4, 0x16,
686 XGI_UpdateCRT1Table[index].CR16);
690 static void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension,
691 unsigned short ModeNo, unsigned short ModeIdIndex,
692 unsigned short RefreshRateTableIndex,
693 struct vb_device_info *pVBInfo)
695 unsigned short resindex, tempax, tempbx, tempcx, temp, modeflag;
697 unsigned char data;
699 resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO;
701 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
702 tempax = XGI330_ModeResInfo[resindex].HTotal;
703 tempbx = XGI330_ModeResInfo[resindex].VTotal;
705 if (modeflag & HalfDCLK)
706 tempax = tempax >> 1;
708 if (modeflag & HalfDCLK)
709 tempax = tempax << 1;
711 temp = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
713 if (temp & InterlaceMode)
714 tempbx = tempbx >> 1;
716 if (modeflag & DoubleScanMode)
717 tempbx = tempbx << 1;
719 tempcx = 8;
721 tempax /= tempcx;
722 tempax -= 1;
723 tempbx -= 1;
724 tempcx = tempax;
725 temp = xgifb_reg_get(pVBInfo->P3d4, 0x11);
726 data = xgifb_reg_get(pVBInfo->P3d4, 0x11);
727 data &= 0x7F;
728 xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */
729 xgifb_reg_set(pVBInfo->P3d4, 0x01, (unsigned short) (tempcx & 0xff));
730 xgifb_reg_and_or(pVBInfo->P3d4, 0x0b, ~0x0c,
731 (unsigned short) ((tempcx & 0x0ff00) >> 10));
732 xgifb_reg_set(pVBInfo->P3d4, 0x12, (unsigned short) (tempbx & 0xff));
733 tempax = 0;
734 tempbx = tempbx >> 8;
736 if (tempbx & 0x01)
737 tempax |= 0x02;
739 if (tempbx & 0x02)
740 tempax |= 0x40;
742 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x42, tempax);
743 data = xgifb_reg_get(pVBInfo->P3d4, 0x07);
744 tempax = 0;
746 if (tempbx & 0x04)
747 tempax |= 0x02;
749 xgifb_reg_and_or(pVBInfo->P3d4, 0x0a, ~0x02, tempax);
750 xgifb_reg_set(pVBInfo->P3d4, 0x11, temp);
753 static void XGI_SetCRT1Offset(unsigned short ModeNo,
754 unsigned short ModeIdIndex,
755 unsigned short RefreshRateTableIndex,
756 struct xgi_hw_device_info *HwDeviceExtension,
757 struct vb_device_info *pVBInfo)
759 unsigned short temp, ah, al, temp2, i, DisplayUnit;
761 /* GetOffset */
762 temp = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeInfo;
763 temp = temp >> 8;
764 temp = XGI330_ScreenOffset[temp];
766 temp2 = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
767 temp2 &= InterlaceMode;
769 if (temp2)
770 temp = temp << 1;
772 temp2 = pVBInfo->ModeType - ModeEGA;
774 switch (temp2) {
775 case 0:
776 temp2 = 1;
777 break;
778 case 1:
779 temp2 = 2;
780 break;
781 case 2:
782 temp2 = 4;
783 break;
784 case 3:
785 temp2 = 4;
786 break;
787 case 4:
788 temp2 = 6;
789 break;
790 case 5:
791 temp2 = 8;
792 break;
793 default:
794 break;
797 if ((ModeNo >= 0x26) && (ModeNo <= 0x28))
798 temp = temp * temp2 + temp2 / 2;
799 else
800 temp *= temp2;
802 /* SetOffset */
803 DisplayUnit = temp;
804 temp2 = temp;
805 temp = temp >> 8; /* ah */
806 temp &= 0x0F;
807 i = xgifb_reg_get(pVBInfo->P3c4, 0x0E);
808 i &= 0xF0;
809 i |= temp;
810 xgifb_reg_set(pVBInfo->P3c4, 0x0E, i);
812 temp = (unsigned char) temp2;
813 temp &= 0xFF; /* al */
814 xgifb_reg_set(pVBInfo->P3d4, 0x13, temp);
816 /* SetDisplayUnit */
817 temp2 = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
818 temp2 &= InterlaceMode;
819 if (temp2)
820 DisplayUnit >>= 1;
822 DisplayUnit = DisplayUnit << 5;
823 ah = (DisplayUnit & 0xff00) >> 8;
824 al = DisplayUnit & 0x00ff;
825 if (al == 0)
826 ah += 1;
827 else
828 ah += 2;
830 if (HwDeviceExtension->jChipType >= XG20)
831 if ((ModeNo == 0x4A) | (ModeNo == 0x49))
832 ah -= 1;
834 xgifb_reg_set(pVBInfo->P3c4, 0x10, ah);
837 static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo,
838 unsigned short ModeIdIndex,
839 unsigned short RefreshRateTableIndex,
840 struct xgi_hw_device_info *HwDeviceExtension,
841 struct vb_device_info *pVBInfo)
843 unsigned short VCLKIndex, modeflag;
845 /* si+Ext_ResInfo */
846 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
848 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { /*301b*/
849 if (pVBInfo->LCDResInfo != Panel_1024x768)
850 /* LCDXlat2VCLK */
851 VCLKIndex = VCLK108_2_315 + 5;
852 else
853 VCLKIndex = VCLK65_315 + 2; /* LCDXlat1VCLK */
854 } else if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
855 if (pVBInfo->SetFlag & RPLLDIV2XO)
856 VCLKIndex = TVCLKBASE_315_25 + HiTVVCLKDIV2;
857 else
858 VCLKIndex = TVCLKBASE_315_25 + HiTVVCLK;
860 if (pVBInfo->SetFlag & TVSimuMode) {
861 if (modeflag & Charx8Dot) {
862 VCLKIndex = TVCLKBASE_315_25 + HiTVSimuVCLK;
863 } else {
864 VCLKIndex = TVCLKBASE_315_25 + HiTVTextVCLK;
868 /* 301lv */
869 if (pVBInfo->VBType & VB_SIS301LV) {
870 if (pVBInfo->SetFlag & RPLLDIV2XO)
871 VCLKIndex = YPbPr525iVCLK_2;
872 else
873 VCLKIndex = YPbPr525iVCLK;
875 } else if (pVBInfo->VBInfo & SetCRT2ToTV) {
876 if (pVBInfo->SetFlag & RPLLDIV2XO)
877 VCLKIndex = TVCLKBASE_315_25 + TVVCLKDIV2;
878 else
879 VCLKIndex = TVCLKBASE_315_25 + TVVCLK;
880 } else { /* for CRT2 */
881 /* di+Ext_CRTVCLK */
882 VCLKIndex = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
883 VCLKIndex &= IndexMask;
886 return VCLKIndex;
889 static void XGI_SetCRT1VCLK(unsigned short ModeNo,
890 unsigned short ModeIdIndex,
891 struct xgi_hw_device_info *HwDeviceExtension,
892 unsigned short RefreshRateTableIndex,
893 struct vb_device_info *pVBInfo)
895 unsigned char index, data;
896 unsigned short vclkindex;
898 if ((pVBInfo->IF_DEF_LVDS == 0) &&
899 (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
900 VB_SIS302LV | VB_XGI301C)) &&
901 (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) {
902 vclkindex = XGI_GetVCLK2Ptr(ModeNo, ModeIdIndex,
903 RefreshRateTableIndex, HwDeviceExtension,
904 pVBInfo);
905 data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF;
906 xgifb_reg_set(pVBInfo->P3c4, 0x31, data);
907 data = XGI_VBVCLKData[vclkindex].Part4_A;
908 xgifb_reg_set(pVBInfo->P3c4, 0x2B, data);
909 data = XGI_VBVCLKData[vclkindex].Part4_B;
910 xgifb_reg_set(pVBInfo->P3c4, 0x2C, data);
911 xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01);
912 } else {
913 index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
914 data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF;
915 xgifb_reg_set(pVBInfo->P3c4, 0x31, data);
916 xgifb_reg_set(pVBInfo->P3c4, 0x2B, XGI_VCLKData[index].SR2B);
917 xgifb_reg_set(pVBInfo->P3c4, 0x2C, XGI_VCLKData[index].SR2C);
918 xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01);
921 if (HwDeviceExtension->jChipType >= XG20) {
922 if (XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag &
923 HalfDCLK) {
924 data = xgifb_reg_get(pVBInfo->P3c4, 0x2B);
925 xgifb_reg_set(pVBInfo->P3c4, 0x2B, data);
926 data = xgifb_reg_get(pVBInfo->P3c4, 0x2C);
927 index = data;
928 index &= 0xE0;
929 data &= 0x1F;
930 data = data << 1;
931 data += 1;
932 data |= index;
933 xgifb_reg_set(pVBInfo->P3c4, 0x2C, data);
938 static void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo)
940 unsigned char temp;
942 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); /* D[0] 1: 18bit */
943 temp = (temp & 1) << 6;
944 /* SR06[6] 18bit Dither */
945 xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x40, temp);
946 /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */
947 xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80);
951 static void XGI_SetCRT1FIFO(unsigned short ModeNo,
952 struct xgi_hw_device_info *HwDeviceExtension,
953 struct vb_device_info *pVBInfo)
955 unsigned short data;
957 data = xgifb_reg_get(pVBInfo->P3c4, 0x3D);
958 data &= 0xfe;
959 xgifb_reg_set(pVBInfo->P3c4, 0x3D, data); /* diable auto-threshold */
961 xgifb_reg_set(pVBInfo->P3c4, 0x08, 0x34);
962 data = xgifb_reg_get(pVBInfo->P3c4, 0x09);
963 data &= 0xC0;
964 xgifb_reg_set(pVBInfo->P3c4, 0x09, data | 0x30);
965 data = xgifb_reg_get(pVBInfo->P3c4, 0x3D);
966 data |= 0x01;
967 xgifb_reg_set(pVBInfo->P3c4, 0x3D, data);
969 if (HwDeviceExtension->jChipType == XG21)
970 XGI_SetXG21FPBits(pVBInfo); /* Fix SR9[7:6] can't read back */
973 static void XGI_SetVCLKState(struct xgi_hw_device_info *HwDeviceExtension,
974 unsigned short ModeNo, unsigned short RefreshRateTableIndex,
975 struct vb_device_info *pVBInfo)
977 unsigned short data, data2 = 0;
978 short VCLK;
980 unsigned char index;
982 index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
983 index &= IndexMask;
984 VCLK = XGI_VCLKData[index].CLOCK;
986 data = xgifb_reg_get(pVBInfo->P3c4, 0x32);
987 data &= 0xf3;
988 if (VCLK >= 200)
989 data |= 0x0c; /* VCLK > 200 */
991 if (HwDeviceExtension->jChipType >= XG20)
992 data &= ~0x04; /* 2 pixel mode */
994 xgifb_reg_set(pVBInfo->P3c4, 0x32, data);
996 if (HwDeviceExtension->jChipType < XG20) {
997 data = xgifb_reg_get(pVBInfo->P3c4, 0x1F);
998 data &= 0xE7;
999 if (VCLK < 200)
1000 data |= 0x10;
1001 xgifb_reg_set(pVBInfo->P3c4, 0x1F, data);
1004 data2 = 0x00;
1006 xgifb_reg_and_or(pVBInfo->P3c4, 0x07, 0xFC, data2);
1007 if (HwDeviceExtension->jChipType >= XG27)
1008 xgifb_reg_and_or(pVBInfo->P3c4, 0x40, 0xFC, data2 & 0x03);
1012 static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension,
1013 unsigned short ModeNo, unsigned short ModeIdIndex,
1014 unsigned short RefreshRateTableIndex,
1015 struct vb_device_info *pVBInfo)
1017 unsigned short data, data2, data3, infoflag = 0, modeflag, resindex,
1018 xres;
1020 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1021 infoflag = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1023 if (xgifb_reg_get(pVBInfo->P3d4, 0x31) & 0x01)
1024 xgifb_reg_and_or(pVBInfo->P3c4, 0x1F, 0x3F, 0x00);
1026 data = infoflag;
1027 data2 = 0;
1028 data2 |= 0x02;
1029 data3 = pVBInfo->ModeType - ModeVGA;
1030 data3 = data3 << 2;
1031 data2 |= data3;
1032 data &= InterlaceMode;
1034 if (data)
1035 data2 |= 0x20;
1037 xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x3F, data2);
1038 resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO;
1039 xres = XGI330_ModeResInfo[resindex].HTotal; /* xres->ax */
1041 data = 0x0000;
1042 if (infoflag & InterlaceMode) {
1043 if (xres == 1024)
1044 data = 0x0035;
1045 else if (xres == 1280)
1046 data = 0x0048;
1049 xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFF, data);
1050 xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFC, 0);
1052 if (modeflag & HalfDCLK)
1053 xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xF7, 0x08);
1055 data2 = 0;
1057 if (modeflag & LineCompareOff)
1058 data2 |= 0x08;
1060 xgifb_reg_and_or(pVBInfo->P3c4, 0x0F, ~0x48, data2);
1061 data = 0x60;
1062 data = data ^ 0x60;
1063 data = data ^ 0xA0;
1064 xgifb_reg_and_or(pVBInfo->P3c4, 0x21, 0x1F, data);
1066 XGI_SetVCLKState(HwDeviceExtension, ModeNo, RefreshRateTableIndex,
1067 pVBInfo);
1069 data = xgifb_reg_get(pVBInfo->P3d4, 0x31);
1071 if (HwDeviceExtension->jChipType == XG27) {
1072 if (data & 0x40)
1073 data = 0x2c;
1074 else
1075 data = 0x6c;
1076 xgifb_reg_set(pVBInfo->P3d4, 0x52, data);
1077 xgifb_reg_or(pVBInfo->P3d4, 0x51, 0x10);
1078 } else if (HwDeviceExtension->jChipType >= XG20) {
1079 if (data & 0x40)
1080 data = 0x33;
1081 else
1082 data = 0x73;
1083 xgifb_reg_set(pVBInfo->P3d4, 0x52, data);
1084 xgifb_reg_set(pVBInfo->P3d4, 0x51, 0x02);
1085 } else {
1086 if (data & 0x40)
1087 data = 0x2c;
1088 else
1089 data = 0x6c;
1090 xgifb_reg_set(pVBInfo->P3d4, 0x52, data);
1095 static void XGI_WriteDAC(unsigned short dl,
1096 unsigned short ah,
1097 unsigned short al,
1098 unsigned short dh,
1099 struct vb_device_info *pVBInfo)
1101 unsigned short temp, bh, bl;
1103 bh = ah;
1104 bl = al;
1106 if (dl != 0) {
1107 temp = bh;
1108 bh = dh;
1109 dh = temp;
1110 if (dl == 1) {
1111 temp = bl;
1112 bl = dh;
1113 dh = temp;
1114 } else {
1115 temp = bl;
1116 bl = bh;
1117 bh = temp;
1120 outb((unsigned short) dh, pVBInfo->P3c9);
1121 outb((unsigned short) bh, pVBInfo->P3c9);
1122 outb((unsigned short) bl, pVBInfo->P3c9);
1125 static void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex,
1126 struct vb_device_info *pVBInfo)
1128 unsigned short data, data2, i, k, m, n, o, si, di, bx, dl, al, ah, dh;
1129 const unsigned short *table = XGINew_VGA_DAC;
1131 outb(0xFF, pVBInfo->P3c6);
1132 outb(0x00, pVBInfo->P3c8);
1134 for (i = 0; i < 16; i++) {
1135 data = table[i];
1137 for (k = 0; k < 3; k++) {
1138 data2 = 0;
1140 if (data & 0x01)
1141 data2 = 0x2A;
1143 if (data & 0x02)
1144 data2 += 0x15;
1146 outb(data2, pVBInfo->P3c9);
1147 data = data >> 2;
1151 for (i = 16; i < 32; i++) {
1152 data = table[i];
1154 for (k = 0; k < 3; k++)
1155 outb(data, pVBInfo->P3c9);
1158 si = 32;
1160 for (m = 0; m < 9; m++) {
1161 di = si;
1162 bx = si + 0x04;
1163 dl = 0;
1165 for (n = 0; n < 3; n++) {
1166 for (o = 0; o < 5; o++) {
1167 dh = table[si];
1168 ah = table[di];
1169 al = table[bx];
1170 si++;
1171 XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
1174 si -= 2;
1176 for (o = 0; o < 3; o++) {
1177 dh = table[bx];
1178 ah = table[di];
1179 al = table[si];
1180 si--;
1181 XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
1184 dl++;
1187 si += 5;
1191 static void XGI_GetLVDSResInfo(unsigned short ModeNo,
1192 unsigned short ModeIdIndex,
1193 struct vb_device_info *pVBInfo)
1195 unsigned short resindex, xres, yres, modeflag;
1197 /* si+Ext_ResInfo */
1198 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO;
1200 /* si+Ext_ResInfo */
1201 resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO;
1203 xres = XGI330_ModeResInfo[resindex].HTotal;
1204 yres = XGI330_ModeResInfo[resindex].VTotal;
1206 if (modeflag & HalfDCLK)
1207 xres = xres << 1;
1209 if (modeflag & DoubleScanMode)
1210 yres = yres << 1;
1212 if (xres == 720)
1213 xres = 640;
1215 pVBInfo->VGAHDE = xres;
1216 pVBInfo->HDE = xres;
1217 pVBInfo->VGAVDE = yres;
1218 pVBInfo->VDE = yres;
1221 static void const *XGI_GetLcdPtr(struct XGI330_LCDDataTablStruct const *table,
1222 unsigned short ModeNo,
1223 unsigned short ModeIdIndex,
1224 unsigned short RefreshRateTableIndex,
1225 struct vb_device_info *pVBInfo)
1227 unsigned short i, tempdx, tempbx, modeflag;
1229 tempbx = 0;
1231 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1233 i = 0;
1235 while (table[i].PANELID != 0xff) {
1236 tempdx = pVBInfo->LCDResInfo;
1237 if (tempbx & 0x0080) { /* OEMUtil */
1238 tempbx &= (~0x0080);
1239 tempdx = pVBInfo->LCDTypeInfo;
1242 if (pVBInfo->LCDInfo & EnableScalingLCD)
1243 tempdx &= (~PanelResInfo);
1245 if (table[i].PANELID == tempdx) {
1246 tempbx = table[i].MASK;
1247 tempdx = pVBInfo->LCDInfo;
1249 if (modeflag & HalfDCLK)
1250 tempdx |= SetLCDLowResolution;
1252 tempbx &= tempdx;
1253 if (tempbx == table[i].CAP)
1254 break;
1256 i++;
1259 return table[i].DATAPTR;
1262 static struct SiS_TVData const *XGI_GetTVPtr(unsigned short ModeNo,
1263 unsigned short ModeIdIndex,
1264 unsigned short RefreshRateTableIndex,
1265 struct vb_device_info *pVBInfo)
1267 unsigned short i, tempdx, tempal, modeflag;
1269 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1270 tempal = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
1271 tempal = tempal & 0x3f;
1272 tempdx = pVBInfo->TVInfo;
1274 if (pVBInfo->VBInfo & SetInSlaveMode)
1275 tempdx = tempdx | SetTVLockMode;
1277 if (modeflag & HalfDCLK)
1278 tempdx = tempdx | SetTVLowResolution;
1280 i = 0;
1282 while (XGI_TVDataTable[i].MASK != 0xffff) {
1283 if ((tempdx & XGI_TVDataTable[i].MASK) ==
1284 XGI_TVDataTable[i].CAP)
1285 break;
1286 i++;
1289 return &XGI_TVDataTable[i].DATAPTR[tempal];
1292 static void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex,
1293 unsigned short RefreshRateTableIndex,
1294 struct vb_device_info *pVBInfo)
1296 struct SiS_LVDSData const *LCDPtr;
1298 if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)))
1299 return;
1301 LCDPtr = XGI_GetLcdPtr(XGI_EPLLCDDataPtr, ModeNo, ModeIdIndex,
1302 RefreshRateTableIndex, pVBInfo);
1303 pVBInfo->VGAHT = LCDPtr->VGAHT;
1304 pVBInfo->VGAVT = LCDPtr->VGAVT;
1305 pVBInfo->HT = LCDPtr->LCDHT;
1306 pVBInfo->VT = LCDPtr->LCDVT;
1308 if (pVBInfo->LCDInfo & (SetLCDtoNonExpanding | EnableScalingLCD))
1309 return;
1311 if ((pVBInfo->LCDResInfo == Panel_1024x768) ||
1312 (pVBInfo->LCDResInfo == Panel_1024x768x75)) {
1313 pVBInfo->HDE = 1024;
1314 pVBInfo->VDE = 768;
1315 } else if ((pVBInfo->LCDResInfo == Panel_1280x1024) ||
1316 (pVBInfo->LCDResInfo == Panel_1280x1024x75)) {
1317 pVBInfo->HDE = 1280;
1318 pVBInfo->VDE = 1024;
1319 } else if (pVBInfo->LCDResInfo == Panel_1400x1050) {
1320 pVBInfo->HDE = 1400;
1321 pVBInfo->VDE = 1050;
1322 } else {
1323 pVBInfo->HDE = 1600;
1324 pVBInfo->VDE = 1200;
1328 static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex,
1329 unsigned short RefreshRateTableIndex,
1330 struct xgi_hw_device_info *HwDeviceExtension,
1331 struct vb_device_info *pVBInfo)
1333 unsigned short i;
1334 struct XGI_LVDSCRT1HDataStruct const *LCDPtr = NULL;
1335 struct XGI_LVDSCRT1VDataStruct const *LCDPtr1 = NULL;
1337 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
1338 LCDPtr = XGI_GetLcdPtr(xgifb_epllcd_crt1_h, ModeNo, ModeIdIndex,
1339 RefreshRateTableIndex, pVBInfo);
1341 for (i = 0; i < 8; i++)
1342 pVBInfo->TimingH.data[i] = LCDPtr[0].Reg[i];
1345 XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension);
1347 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
1348 LCDPtr1 = XGI_GetLcdPtr(xgifb_epllcd_crt1_v, ModeNo,
1349 ModeIdIndex, RefreshRateTableIndex,
1350 pVBInfo);
1351 for (i = 0; i < 7; i++)
1352 pVBInfo->TimingV.data[i] = LCDPtr1[0].Reg[i];
1355 XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo);
1358 static unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo)
1360 unsigned char tempal, tempah, tempbl, i;
1362 tempah = xgifb_reg_get(pVBInfo->P3d4, 0x36);
1363 tempal = tempah & 0x0F;
1364 tempah = tempah & 0xF0;
1365 i = 0;
1366 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
1368 while (tempbl != 0xFF) {
1369 if (tempbl & 0x80) { /* OEMUtil */
1370 tempal = tempah;
1371 tempbl = tempbl & ~(0x80);
1374 if (tempal == tempbl)
1375 break;
1377 i++;
1379 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
1382 return i;
1385 static unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo)
1387 unsigned short tempah, tempal, tempbl, i;
1389 tempal = pVBInfo->LCDResInfo;
1390 tempah = pVBInfo->LCDTypeInfo;
1392 i = 0;
1393 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
1395 while (tempbl != 0xFF) {
1396 if ((tempbl & 0x80) && (tempbl != 0x80)) {
1397 tempal = tempah;
1398 tempbl &= ~0x80;
1401 if (tempal == tempbl)
1402 break;
1404 i++;
1405 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
1408 if (tempbl == 0xFF) {
1409 pVBInfo->LCDResInfo = Panel_1024x768;
1410 pVBInfo->LCDTypeInfo = 0;
1411 i = 0;
1414 return i;
1417 static void XGI_GetLCDSync(unsigned short *HSyncWidth,
1418 unsigned short *VSyncWidth,
1419 struct vb_device_info *pVBInfo)
1421 unsigned short Index;
1423 Index = XGI_GetLCDCapPtr(pVBInfo);
1424 *HSyncWidth = pVBInfo->LCDCapList[Index].LCD_HSyncWidth;
1425 *VSyncWidth = pVBInfo->LCDCapList[Index].LCD_VSyncWidth;
1428 static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
1429 unsigned short RefreshRateTableIndex,
1430 struct vb_device_info *pVBInfo)
1432 unsigned short tempbx, tempax, tempcx, tempdx, push1, push2, modeflag;
1433 unsigned long temp, temp1, temp2, temp3, push3;
1434 struct XGI330_LCDDataDesStruct2 const *LCDPtr1 = NULL;
1436 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1437 LCDPtr1 = XGI_GetLcdPtr(XGI_EPLLCDDesDataPtr, ModeNo, ModeIdIndex,
1438 RefreshRateTableIndex, pVBInfo);
1440 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
1441 push1 = tempbx;
1442 push2 = tempax;
1444 /* GetLCDResInfo */
1445 if ((pVBInfo->LCDResInfo == Panel_1024x768) ||
1446 (pVBInfo->LCDResInfo == Panel_1024x768x75)) {
1447 tempax = 1024;
1448 tempbx = 768;
1449 } else if ((pVBInfo->LCDResInfo == Panel_1280x1024) ||
1450 (pVBInfo->LCDResInfo == Panel_1280x1024x75)) {
1451 tempax = 1280;
1452 tempbx = 1024;
1453 } else if (pVBInfo->LCDResInfo == Panel_1400x1050) {
1454 tempax = 1400;
1455 tempbx = 1050;
1456 } else {
1457 tempax = 1600;
1458 tempbx = 1200;
1461 if (pVBInfo->LCDInfo & SetLCDtoNonExpanding) {
1462 pVBInfo->HDE = tempax;
1463 pVBInfo->VDE = tempbx;
1464 pVBInfo->VGAHDE = tempax;
1465 pVBInfo->VGAVDE = tempbx;
1468 tempax = pVBInfo->HT;
1470 tempbx = LCDPtr1->LCDHDES;
1472 tempcx = pVBInfo->HDE;
1473 tempbx = tempbx & 0x0fff;
1474 tempcx += tempbx;
1476 if (tempcx >= tempax)
1477 tempcx -= tempax;
1479 xgifb_reg_set(pVBInfo->Part1Port, 0x1A, tempbx & 0x07);
1481 tempcx = tempcx >> 3;
1482 tempbx = tempbx >> 3;
1484 xgifb_reg_set(pVBInfo->Part1Port, 0x16,
1485 (unsigned short) (tempbx & 0xff));
1486 xgifb_reg_set(pVBInfo->Part1Port, 0x17,
1487 (unsigned short) (tempcx & 0xff));
1489 tempax = pVBInfo->HT;
1491 tempbx = LCDPtr1->LCDHRS;
1493 tempcx = push2;
1495 if (pVBInfo->LCDInfo & EnableScalingLCD)
1496 tempcx = LCDPtr1->LCDHSync;
1498 tempcx += tempbx;
1500 if (tempcx >= tempax)
1501 tempcx -= tempax;
1503 tempax = tempbx & 0x07;
1504 tempax = tempax >> 5;
1505 tempcx = tempcx >> 3;
1506 tempbx = tempbx >> 3;
1508 tempcx &= 0x1f;
1509 tempax |= tempcx;
1511 xgifb_reg_set(pVBInfo->Part1Port, 0x15, tempax);
1512 xgifb_reg_set(pVBInfo->Part1Port, 0x14,
1513 (unsigned short) (tempbx & 0xff));
1515 tempax = pVBInfo->VT;
1516 tempbx = LCDPtr1->LCDVDES;
1517 tempcx = pVBInfo->VDE;
1519 tempbx = tempbx & 0x0fff;
1520 tempcx += tempbx;
1521 if (tempcx >= tempax)
1522 tempcx -= tempax;
1524 xgifb_reg_set(pVBInfo->Part1Port, 0x1b,
1525 (unsigned short) (tempbx & 0xff));
1526 xgifb_reg_set(pVBInfo->Part1Port, 0x1c,
1527 (unsigned short) (tempcx & 0xff));
1529 tempbx = (tempbx >> 8) & 0x07;
1530 tempcx = (tempcx >> 8) & 0x07;
1532 xgifb_reg_set(pVBInfo->Part1Port, 0x1d,
1533 (unsigned short) ((tempcx << 3)
1534 | tempbx));
1536 tempax = pVBInfo->VT;
1537 tempbx = LCDPtr1->LCDVRS;
1539 tempcx = push1;
1541 if (pVBInfo->LCDInfo & EnableScalingLCD)
1542 tempcx = LCDPtr1->LCDVSync;
1544 tempcx += tempbx;
1545 if (tempcx >= tempax)
1546 tempcx -= tempax;
1548 xgifb_reg_set(pVBInfo->Part1Port, 0x18,
1549 (unsigned short) (tempbx & 0xff));
1550 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, ~0x0f,
1551 (unsigned short) (tempcx & 0x0f));
1553 tempax = ((tempbx >> 8) & 0x07) << 3;
1555 tempbx = pVBInfo->VGAVDE;
1556 if (tempbx != pVBInfo->VDE)
1557 tempax |= 0x40;
1559 if (pVBInfo->LCDInfo & XGI_EnableLVDSDDA)
1560 tempax |= 0x40;
1562 xgifb_reg_and_or(pVBInfo->Part1Port, 0x1a, 0x07,
1563 tempax);
1565 tempbx = pVBInfo->VDE;
1566 tempax = pVBInfo->VGAVDE;
1568 temp = tempax; /* 0430 ylshieh */
1569 temp1 = (temp << 18) / tempbx;
1571 tempdx = (unsigned short) ((temp << 18) % tempbx);
1573 if (tempdx != 0)
1574 temp1 += 1;
1576 temp2 = temp1;
1577 push3 = temp2;
1579 xgifb_reg_set(pVBInfo->Part1Port, 0x37,
1580 (unsigned short) (temp2 & 0xff));
1581 xgifb_reg_set(pVBInfo->Part1Port, 0x36,
1582 (unsigned short) ((temp2 >> 8) & 0xff));
1584 tempbx = (unsigned short) (temp2 >> 16);
1585 tempax = tempbx & 0x03;
1587 tempbx = pVBInfo->VGAVDE;
1588 if (tempbx == pVBInfo->VDE)
1589 tempax |= 0x04;
1591 xgifb_reg_set(pVBInfo->Part1Port, 0x35, tempax);
1593 if (pVBInfo->VBType & VB_XGI301C) {
1594 temp2 = push3;
1595 xgifb_reg_set(pVBInfo->Part4Port,
1596 0x3c,
1597 (unsigned short) (temp2 & 0xff));
1598 xgifb_reg_set(pVBInfo->Part4Port,
1599 0x3b,
1600 (unsigned short) ((temp2 >> 8) &
1601 0xff));
1602 tempbx = (unsigned short) (temp2 >> 16);
1603 xgifb_reg_and_or(pVBInfo->Part4Port, 0x3a,
1604 ~0xc0,
1605 (unsigned short) ((tempbx &
1606 0xff) << 6));
1608 tempcx = pVBInfo->VGAVDE;
1609 if (tempcx == pVBInfo->VDE)
1610 xgifb_reg_and_or(pVBInfo->Part4Port,
1611 0x30, ~0x0c, 0x00);
1612 else
1613 xgifb_reg_and_or(pVBInfo->Part4Port,
1614 0x30, ~0x0c, 0x08);
1617 tempcx = pVBInfo->VGAHDE;
1618 tempbx = pVBInfo->HDE;
1620 temp1 = tempcx << 16;
1622 tempax = (unsigned short) (temp1 / tempbx);
1624 if ((tempbx & 0xffff) == (tempcx & 0xffff))
1625 tempax = 65535;
1627 temp3 = tempax;
1628 temp1 = pVBInfo->VGAHDE << 16;
1630 temp1 /= temp3;
1631 temp3 = temp3 << 16;
1632 temp1 -= 1;
1634 temp3 = (temp3 & 0xffff0000) + (temp1 & 0xffff);
1636 tempax = (unsigned short) (temp3 & 0xff);
1637 xgifb_reg_set(pVBInfo->Part1Port, 0x1f, tempax);
1639 temp1 = pVBInfo->VGAVDE << 18;
1640 temp1 = temp1 / push3;
1641 tempbx = (unsigned short) (temp1 & 0xffff);
1643 if (pVBInfo->LCDResInfo == Panel_1024x768)
1644 tempbx -= 1;
1646 tempax = ((tempbx >> 8) & 0xff) << 3;
1647 tempax |= (unsigned short) ((temp3 >> 8) & 0x07);
1648 xgifb_reg_set(pVBInfo->Part1Port, 0x20,
1649 (unsigned short) (tempax & 0xff));
1650 xgifb_reg_set(pVBInfo->Part1Port, 0x21,
1651 (unsigned short) (tempbx & 0xff));
1653 temp3 = temp3 >> 16;
1655 if (modeflag & HalfDCLK)
1656 temp3 = temp3 >> 1;
1658 xgifb_reg_set(pVBInfo->Part1Port, 0x22,
1659 (unsigned short) ((temp3 >> 8) & 0xff));
1660 xgifb_reg_set(pVBInfo->Part1Port, 0x23,
1661 (unsigned short) (temp3 & 0xff));
1664 /* --------------------------------------------------------------------- */
1665 /* Function : XGI_GETLCDVCLKPtr */
1666 /* Input : */
1667 /* Output : al -> VCLK Index */
1668 /* Description : */
1669 /* --------------------------------------------------------------------- */
1670 static void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1,
1671 struct vb_device_info *pVBInfo)
1673 unsigned short index;
1675 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
1676 index = XGI_GetLCDCapPtr1(pVBInfo);
1678 if (pVBInfo->VBInfo & SetCRT2ToLCD) { /* LCDB */
1679 *di_0 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData1;
1680 *di_1 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData2;
1681 } else { /* LCDA */
1682 *di_0 = pVBInfo->LCDCapList[index].LCDA_VCLKData1;
1683 *di_1 = pVBInfo->LCDCapList[index].LCDA_VCLKData2;
1688 static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex,
1689 unsigned short ModeNo, unsigned short ModeIdIndex,
1690 struct vb_device_info *pVBInfo)
1693 unsigned short index, modeflag;
1694 unsigned char tempal;
1696 /* si+Ext_ResInfo */
1697 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1699 if ((pVBInfo->SetFlag & ProgrammingCRT2) &&
1700 (!(pVBInfo->LCDInfo & EnableScalingLCD))) { /* {LCDA/LCDB} */
1701 index = XGI_GetLCDCapPtr(pVBInfo);
1702 tempal = pVBInfo->LCDCapList[index].LCD_VCLK;
1704 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))
1705 return tempal;
1707 /* {TV} */
1708 if (pVBInfo->VBType &
1709 (VB_SIS301B |
1710 VB_SIS302B |
1711 VB_SIS301LV |
1712 VB_SIS302LV |
1713 VB_XGI301C)) {
1714 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
1715 tempal = TVCLKBASE_315 + HiTVVCLKDIV2;
1716 if (!(pVBInfo->TVInfo & RPLLDIV2XO))
1717 tempal = TVCLKBASE_315 + HiTVVCLK;
1718 if (pVBInfo->TVInfo & TVSimuMode) {
1719 tempal = TVCLKBASE_315 + HiTVSimuVCLK;
1720 if (!(modeflag & Charx8Dot))
1721 tempal = TVCLKBASE_315 +
1722 HiTVTextVCLK;
1725 return tempal;
1728 if (pVBInfo->TVInfo & TVSetYPbPr750p) {
1729 tempal = XGI_YPbPr750pVCLK;
1730 return tempal;
1733 if (pVBInfo->TVInfo & TVSetYPbPr525p) {
1734 tempal = YPbPr525pVCLK;
1735 return tempal;
1738 tempal = NTSC1024VCLK;
1740 if (!(pVBInfo->TVInfo & NTSC1024x768)) {
1741 tempal = TVCLKBASE_315 + TVVCLKDIV2;
1742 if (!(pVBInfo->TVInfo & RPLLDIV2XO))
1743 tempal = TVCLKBASE_315 + TVVCLK;
1746 if (pVBInfo->VBInfo & SetCRT2ToTV)
1747 return tempal;
1749 } /* {End of VB} */
1751 inb((pVBInfo->P3ca + 0x02));
1752 tempal = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1753 return tempal;
1756 static void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0,
1757 unsigned char *di_1, struct vb_device_info *pVBInfo)
1759 if (pVBInfo->VBType & (VB_SIS301 | VB_SIS301B | VB_SIS302B
1760 | VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) {
1761 if ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) &&
1762 (pVBInfo->SetFlag & ProgrammingCRT2)) {
1763 *di_0 = XGI_VBVCLKData[tempal].Part4_A;
1764 *di_1 = XGI_VBVCLKData[tempal].Part4_B;
1766 } else {
1767 *di_0 = XGI_VCLKData[tempal].SR2B;
1768 *di_1 = XGI_VCLKData[tempal].SR2C;
1772 static void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex,
1773 unsigned short RefreshRateTableIndex,
1774 struct vb_device_info *pVBInfo)
1776 unsigned char di_0, di_1, tempal;
1777 int i;
1779 tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex,
1780 pVBInfo);
1781 XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo);
1782 XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo);
1784 for (i = 0; i < 4; i++) {
1785 xgifb_reg_and_or(pVBInfo->P3d4, 0x31, ~0x30,
1786 (unsigned short) (0x10 * i));
1787 if ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA))
1788 && (!(pVBInfo->VBInfo & SetInSlaveMode))) {
1789 xgifb_reg_set(pVBInfo->P3c4, 0x2e, di_0);
1790 xgifb_reg_set(pVBInfo->P3c4, 0x2f, di_1);
1791 } else {
1792 xgifb_reg_set(pVBInfo->P3c4, 0x2b, di_0);
1793 xgifb_reg_set(pVBInfo->P3c4, 0x2c, di_1);
1798 static void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension,
1799 struct vb_device_info *pVBInfo)
1801 unsigned short tempcl, tempch, temp, tempbl, tempax;
1803 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
1804 | VB_SIS302LV | VB_XGI301C)) {
1805 tempcl = 0;
1806 tempch = 0;
1807 temp = xgifb_reg_get(pVBInfo->P3c4, 0x01);
1809 if (!(temp & 0x20)) {
1810 temp = xgifb_reg_get(pVBInfo->P3d4, 0x17);
1811 if (temp & 0x80) {
1812 temp = xgifb_reg_get(pVBInfo->P3d4, 0x53);
1813 if (!(temp & 0x40))
1814 tempcl |= ActiveCRT1;
1818 temp = xgifb_reg_get(pVBInfo->Part1Port, 0x2e);
1819 temp &= 0x0f;
1821 if (!(temp == 0x08)) {
1822 /* Check ChannelA */
1823 tempax = xgifb_reg_get(pVBInfo->Part1Port, 0x13);
1824 if (tempax & 0x04)
1825 tempcl = tempcl | ActiveLCD;
1827 temp &= 0x05;
1829 if (!(tempcl & ActiveLCD))
1830 if (temp == 0x01)
1831 tempcl |= ActiveCRT2;
1833 if (temp == 0x04)
1834 tempcl |= ActiveLCD;
1836 if (temp == 0x05) {
1837 temp = xgifb_reg_get(pVBInfo->Part2Port, 0x00);
1839 if (!(temp & 0x08))
1840 tempch |= ActiveAVideo;
1842 if (!(temp & 0x04))
1843 tempch |= ActiveSVideo;
1845 if (temp & 0x02)
1846 tempch |= ActiveSCART;
1848 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
1849 if (temp & 0x01)
1850 tempch |= ActiveHiTV;
1853 if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
1854 temp = xgifb_reg_get(
1855 pVBInfo->Part2Port,
1856 0x4d);
1858 if (temp & 0x10)
1859 tempch |= ActiveYPbPr;
1862 if (tempch != 0)
1863 tempcl |= ActiveTV;
1867 temp = xgifb_reg_get(pVBInfo->P3d4, 0x3d);
1868 if (tempcl & ActiveLCD) {
1869 if ((pVBInfo->SetFlag & ReserveTVOption)) {
1870 if (temp & ActiveTV)
1871 tempcl |= ActiveTV;
1874 temp = tempcl;
1875 tempbl = ~XGI_ModeSwitchStatus;
1876 xgifb_reg_and_or(pVBInfo->P3d4, 0x3d, tempbl, temp);
1878 if (!(pVBInfo->SetFlag & ReserveTVOption))
1879 xgifb_reg_set(pVBInfo->P3d4, 0x3e, tempch);
1883 void XGI_GetVBType(struct vb_device_info *pVBInfo)
1885 unsigned short flag, tempbx, tempah;
1887 tempbx = VB_SIS302B;
1888 flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00);
1889 if (flag == 0x02)
1890 goto finish;
1892 tempbx = VB_SIS301;
1893 flag = xgifb_reg_get(pVBInfo->Part4Port, 0x01);
1894 if (flag < 0xB0)
1895 goto finish;
1897 tempbx = VB_SIS301B;
1898 if (flag < 0xC0)
1899 goto bigger_than_0xB0;
1901 tempbx = VB_XGI301C;
1902 if (flag < 0xD0)
1903 goto bigger_than_0xB0;
1905 tempbx = VB_SIS301LV;
1906 if (flag < 0xE0)
1907 goto bigger_than_0xB0;
1909 tempbx = VB_SIS302LV;
1910 tempah = xgifb_reg_get(pVBInfo->Part4Port, 0x39);
1911 if (tempah != 0xFF)
1912 tempbx = VB_XGI301C;
1914 bigger_than_0xB0:
1915 if (tempbx & (VB_SIS301B | VB_SIS302B)) {
1916 flag = xgifb_reg_get(pVBInfo->Part4Port, 0x23);
1917 if (!(flag & 0x02))
1918 tempbx = tempbx | VB_NoLCD;
1921 finish:
1922 pVBInfo->VBType = tempbx;
1925 static void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
1926 struct xgi_hw_device_info *HwDeviceExtension,
1927 struct vb_device_info *pVBInfo)
1929 unsigned short tempax, push, tempbx, temp, modeflag;
1931 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1932 pVBInfo->SetFlag = 0;
1933 pVBInfo->ModeType = modeflag & ModeTypeMask;
1934 tempbx = 0;
1936 if (!(pVBInfo->VBType & 0xFFFF))
1937 return;
1939 /* Check Display Device */
1940 temp = xgifb_reg_get(pVBInfo->P3d4, 0x30);
1941 tempbx = tempbx | temp;
1942 temp = xgifb_reg_get(pVBInfo->P3d4, 0x31);
1943 push = temp;
1944 push = push << 8;
1945 tempax = temp << 8;
1946 tempbx = tempbx | tempax;
1947 temp = (SetCRT2ToDualEdge | SetCRT2ToYPbPr525750 | XGI_SetCRT2ToLCDA
1948 | SetInSlaveMode | DisableCRT2Display);
1949 temp = 0xFFFF ^ temp;
1950 tempbx &= temp;
1952 temp = xgifb_reg_get(pVBInfo->P3d4, 0x38);
1954 if (pVBInfo->VBType & (VB_SIS302B | VB_SIS301LV | VB_SIS302LV |
1955 VB_XGI301C)) {
1956 if (temp & EnableDualEdge) {
1957 tempbx |= SetCRT2ToDualEdge;
1958 if (temp & SetToLCDA)
1959 tempbx |= XGI_SetCRT2ToLCDA;
1963 if (pVBInfo->VBType & (VB_SIS301LV|VB_SIS302LV|VB_XGI301C)) {
1964 if (temp & SetYPbPr) {
1965 /* shampoo add for new scratch */
1966 temp = xgifb_reg_get(pVBInfo->P3d4, 0x35);
1967 temp &= YPbPrMode;
1968 tempbx |= SetCRT2ToHiVision;
1970 if (temp != YPbPrMode1080i) {
1971 tempbx &= (~SetCRT2ToHiVision);
1972 tempbx |= SetCRT2ToYPbPr525750;
1977 tempax = push; /* restore CR31 */
1979 temp = 0x09FC;
1981 if (!(tempbx & temp)) {
1982 tempax |= DisableCRT2Display;
1983 tempbx = 0;
1986 if (!(pVBInfo->VBType & VB_NoLCD)) {
1987 if (tempbx & XGI_SetCRT2ToLCDA) {
1988 if (tempbx & SetSimuScanMode)
1989 tempbx &= (~(SetCRT2ToLCD | SetCRT2ToRAMDAC |
1990 SwitchCRT2));
1991 else
1992 tempbx &= (~(SetCRT2ToLCD | SetCRT2ToRAMDAC |
1993 SetCRT2ToTV | SwitchCRT2));
1997 /* shampoo add */
1998 /* for driver abnormal */
1999 if (!(tempbx & (SwitchCRT2 | SetSimuScanMode))) {
2000 if (tempbx & SetCRT2ToRAMDAC) {
2001 tempbx &= (0xFF00 | SetCRT2ToRAMDAC |
2002 SwitchCRT2 | SetSimuScanMode);
2003 tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750));
2007 if (!(pVBInfo->VBType & VB_NoLCD)) {
2008 if (tempbx & SetCRT2ToLCD) {
2009 tempbx &= (0xFF00 | SetCRT2ToLCD | SwitchCRT2 |
2010 SetSimuScanMode);
2011 tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750));
2015 if (tempbx & SetCRT2ToSCART) {
2016 tempbx &= (0xFF00 | SetCRT2ToSCART | SwitchCRT2 |
2017 SetSimuScanMode);
2018 tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750));
2021 if (tempbx & SetCRT2ToYPbPr525750)
2022 tempbx &= (0xFF00 | SwitchCRT2 | SetSimuScanMode);
2024 if (tempbx & SetCRT2ToHiVision)
2025 tempbx &= (0xFF00 | SetCRT2ToHiVision | SwitchCRT2 |
2026 SetSimuScanMode);
2028 if (tempax & DisableCRT2Display) { /* Set Display Device Info */
2029 if (!(tempbx & (SwitchCRT2 | SetSimuScanMode)))
2030 tempbx = DisableCRT2Display;
2033 if (!(tempbx & DisableCRT2Display)) {
2034 if ((!(tempbx & DriverMode)) || (!(modeflag & CRT2Mode))) {
2035 if (!(tempbx & XGI_SetCRT2ToLCDA))
2036 tempbx |= (SetInSlaveMode | SetSimuScanMode);
2039 /* LCD+TV can't support in slave mode
2040 * (Force LCDA+TV->LCDB) */
2041 if ((tempbx & SetInSlaveMode) && (tempbx & XGI_SetCRT2ToLCDA)) {
2042 tempbx ^= (SetCRT2ToLCD | XGI_SetCRT2ToLCDA |
2043 SetCRT2ToDualEdge);
2044 pVBInfo->SetFlag |= ReserveTVOption;
2048 pVBInfo->VBInfo = tempbx;
2051 static void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
2052 struct vb_device_info *pVBInfo)
2054 unsigned short tempbx = 0, resinfo = 0, modeflag, index1;
2056 if (pVBInfo->VBInfo & SetCRT2ToTV) {
2057 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2058 resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO;
2060 tempbx = xgifb_reg_get(pVBInfo->P3d4, 0x35);
2061 if (tempbx & TVSetPAL) {
2062 tempbx &= (SetCHTVOverScan |
2063 TVSetPALM |
2064 TVSetPALN |
2065 TVSetPAL);
2066 if (tempbx & TVSetPALM)
2067 /* set to NTSC if PAL-M */
2068 tempbx &= ~TVSetPAL;
2069 } else
2070 tempbx &= (SetCHTVOverScan |
2071 TVSetNTSCJ |
2072 TVSetPAL);
2074 if (pVBInfo->VBInfo & SetCRT2ToSCART)
2075 tempbx |= TVSetPAL;
2077 if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
2078 index1 = xgifb_reg_get(pVBInfo->P3d4, 0x35);
2079 index1 &= YPbPrMode;
2081 if (index1 == YPbPrMode525i)
2082 tempbx |= TVSetYPbPr525i;
2084 if (index1 == YPbPrMode525p)
2085 tempbx = tempbx | TVSetYPbPr525p;
2086 if (index1 == YPbPrMode750p)
2087 tempbx = tempbx | TVSetYPbPr750p;
2090 if (pVBInfo->VBInfo & SetCRT2ToHiVision)
2091 tempbx = tempbx | TVSetHiVision | TVSetPAL;
2093 if ((pVBInfo->VBInfo & SetInSlaveMode) &&
2094 (!(pVBInfo->VBInfo & SetNotSimuMode)))
2095 tempbx |= TVSimuMode;
2097 if (!(tempbx & TVSetPAL) && (modeflag > 13) && (resinfo == 8))
2098 /* NTSC 1024x768, */
2099 tempbx |= NTSC1024x768;
2101 tempbx |= RPLLDIV2XO;
2103 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
2104 if (pVBInfo->VBInfo & SetInSlaveMode)
2105 tempbx &= (~RPLLDIV2XO);
2106 } else if (tempbx & (TVSetYPbPr525p | TVSetYPbPr750p)) {
2107 tempbx &= (~RPLLDIV2XO);
2108 } else if (!(pVBInfo->VBType & (VB_SIS301B | VB_SIS302B |
2109 VB_SIS301LV | VB_SIS302LV |
2110 VB_XGI301C))) {
2111 if (tempbx & TVSimuMode)
2112 tempbx &= (~RPLLDIV2XO);
2115 pVBInfo->TVInfo = tempbx;
2118 static unsigned char XGI_GetLCDInfo(unsigned short ModeNo,
2119 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
2121 unsigned short temp, tempax, tempbx, resinfo = 0, LCDIdIndex;
2123 pVBInfo->LCDResInfo = 0;
2124 pVBInfo->LCDTypeInfo = 0;
2125 pVBInfo->LCDInfo = 0;
2127 /* si+Ext_ResInfo // */
2128 resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO;
2129 temp = xgifb_reg_get(pVBInfo->P3d4, 0x36); /* Get LCD Res.Info */
2130 tempbx = temp & 0x0F;
2132 if (tempbx == 0)
2133 tempbx = Panel_1024x768; /* default */
2135 /* LCD75 */
2136 if ((tempbx == Panel_1024x768) || (tempbx == Panel_1280x1024)) {
2137 if (pVBInfo->VBInfo & DriverMode) {
2138 tempax = xgifb_reg_get(pVBInfo->P3d4, 0x33);
2139 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)
2140 tempax &= 0x0F;
2141 else
2142 tempax = tempax >> 4;
2144 if ((resinfo == 6) || (resinfo == 9)) {
2145 if (tempax >= 3)
2146 tempbx |= PanelRef75Hz;
2147 } else if ((resinfo == 7) || (resinfo == 8)) {
2148 if (tempax >= 4)
2149 tempbx |= PanelRef75Hz;
2154 pVBInfo->LCDResInfo = tempbx;
2156 /* End of LCD75 */
2158 if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)))
2159 return 0;
2161 tempbx = 0;
2163 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
2165 temp &= (ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable);
2167 tempbx |= temp;
2169 LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo);
2171 tempax = pVBInfo->LCDCapList[LCDIdIndex].LCD_Capability;
2173 if (((pVBInfo->VBType & VB_SIS302LV) ||
2174 (pVBInfo->VBType & VB_XGI301C)) && (tempax & XGI_LCDDualLink))
2175 tempbx |= SetLCDDualLink;
2177 if ((pVBInfo->LCDResInfo == Panel_1400x1050) &&
2178 (pVBInfo->VBInfo & SetCRT2ToLCD) && (resinfo == 9) &&
2179 (!(tempbx & EnableScalingLCD)))
2181 * set to center in 1280x1024 LCDB
2182 * for Panel_1400x1050
2184 tempbx |= SetLCDtoNonExpanding;
2186 if (pVBInfo->VBInfo & SetInSlaveMode) {
2187 if (pVBInfo->VBInfo & SetNotSimuMode)
2188 tempbx |= XGI_LCDVESATiming;
2189 } else {
2190 tempbx |= XGI_LCDVESATiming;
2193 pVBInfo->LCDInfo = tempbx;
2195 return 1;
2198 unsigned char XGI_SearchModeID(unsigned short ModeNo,
2199 unsigned short *ModeIdIndex, struct vb_device_info *pVBInfo)
2201 for (*ModeIdIndex = 0;; (*ModeIdIndex)++) {
2202 if (XGI330_EModeIDTable[*ModeIdIndex].Ext_ModeID == ModeNo)
2203 break;
2204 if (XGI330_EModeIDTable[*ModeIdIndex].Ext_ModeID == 0xFF)
2205 return 0;
2208 return 1;
2211 static unsigned char XG21GPIODataTransfer(unsigned char ujDate)
2213 unsigned char ujRet = 0;
2214 unsigned char i = 0;
2216 for (i = 0; i < 8; i++) {
2217 ujRet = ujRet << 1;
2218 ujRet |= (ujDate >> i) & 1;
2221 return ujRet;
2224 /*----------------------------------------------------------------------------*/
2225 /* output */
2226 /* bl[5] : LVDS signal */
2227 /* bl[1] : LVDS backlight */
2228 /* bl[0] : LVDS VDD */
2229 /*----------------------------------------------------------------------------*/
2230 static unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo)
2232 unsigned char CR4A, temp;
2234 CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
2235 xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x23); /* enable GPIO write */
2237 temp = xgifb_reg_get(pVBInfo->P3d4, 0x48);
2239 temp = XG21GPIODataTransfer(temp);
2240 temp &= 0x23;
2241 xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A);
2242 return temp;
2245 /*----------------------------------------------------------------------------*/
2246 /* output */
2247 /* bl[5] : LVDS signal */
2248 /* bl[1] : LVDS backlight */
2249 /* bl[0] : LVDS VDD */
2250 /*----------------------------------------------------------------------------*/
2251 static unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo)
2253 unsigned char CR4A, CRB4, temp;
2255 CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
2256 xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x0C); /* enable GPIO write */
2258 temp = xgifb_reg_get(pVBInfo->P3d4, 0x48);
2260 temp &= 0x0C;
2261 temp >>= 2;
2262 xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A);
2263 CRB4 = xgifb_reg_get(pVBInfo->P3d4, 0xB4);
2264 temp |= ((CRB4 & 0x04) << 3);
2265 return temp;
2268 /*----------------------------------------------------------------------------*/
2269 /* input */
2270 /* bl[5] : 1;LVDS signal on */
2271 /* bl[1] : 1;LVDS backlight on */
2272 /* bl[0] : 1:LVDS VDD on */
2273 /* bh: 100000b : clear bit 5, to set bit5 */
2274 /* 000010b : clear bit 1, to set bit1 */
2275 /* 000001b : clear bit 0, to set bit0 */
2276 /*----------------------------------------------------------------------------*/
2277 static void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl,
2278 struct vb_device_info *pVBInfo)
2280 unsigned char CR4A, temp;
2282 CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
2283 tempbh &= 0x23;
2284 tempbl &= 0x23;
2285 xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */
2287 if (tempbh & 0x20) {
2288 temp = (tempbl >> 4) & 0x02;
2290 /* CR B4[1] */
2291 xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp);
2295 temp = xgifb_reg_get(pVBInfo->P3d4, 0x48);
2297 temp = XG21GPIODataTransfer(temp);
2298 temp &= ~tempbh;
2299 temp |= tempbl;
2300 xgifb_reg_set(pVBInfo->P3d4, 0x48, temp);
2303 static void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl,
2304 struct vb_device_info *pVBInfo)
2306 unsigned char CR4A, temp;
2307 unsigned short tempbh0, tempbl0;
2309 tempbh0 = tempbh;
2310 tempbl0 = tempbl;
2311 tempbh0 &= 0x20;
2312 tempbl0 &= 0x20;
2313 tempbh0 >>= 3;
2314 tempbl0 >>= 3;
2316 if (tempbh & 0x20) {
2317 temp = (tempbl >> 4) & 0x02;
2319 /* CR B4[1] */
2320 xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp);
2323 xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~tempbh0, tempbl0);
2325 CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
2326 tempbh &= 0x03;
2327 tempbl &= 0x03;
2328 tempbh <<= 2;
2329 tempbl <<= 2; /* GPIOC,GPIOD */
2330 xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */
2331 xgifb_reg_and_or(pVBInfo->P3d4, 0x48, ~tempbh, tempbl);
2334 static void XGI_DisplayOn(struct xgifb_video_info *xgifb_info,
2335 struct xgi_hw_device_info *pXGIHWDE,
2336 struct vb_device_info *pVBInfo)
2339 xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x00);
2340 if (pXGIHWDE->jChipType == XG21) {
2341 if (pVBInfo->IF_DEF_LVDS == 1) {
2342 if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x1)) {
2343 /* LVDS VDD on */
2344 XGI_XG21BLSignalVDD(0x01, 0x01, pVBInfo);
2345 mdelay(xgifb_info->lvds_data.PSC_S2);
2347 if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x20))
2348 /* LVDS signal on */
2349 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo);
2350 mdelay(xgifb_info->lvds_data.PSC_S3);
2351 /* LVDS backlight on */
2352 XGI_XG21BLSignalVDD(0x02, 0x02, pVBInfo);
2353 } else {
2354 /* DVO/DVI signal on */
2355 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo);
2360 if (pXGIHWDE->jChipType == XG27) {
2361 if (pVBInfo->IF_DEF_LVDS == 1) {
2362 if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x1)) {
2363 /* LVDS VDD on */
2364 XGI_XG27BLSignalVDD(0x01, 0x01, pVBInfo);
2365 mdelay(xgifb_info->lvds_data.PSC_S2);
2367 if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x20))
2368 /* LVDS signal on */
2369 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo);
2370 mdelay(xgifb_info->lvds_data.PSC_S3);
2371 /* LVDS backlight on */
2372 XGI_XG27BLSignalVDD(0x02, 0x02, pVBInfo);
2373 } else {
2374 /* DVO/DVI signal on */
2375 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo);
2381 void XGI_DisplayOff(struct xgifb_video_info *xgifb_info,
2382 struct xgi_hw_device_info *pXGIHWDE,
2383 struct vb_device_info *pVBInfo)
2386 if (pXGIHWDE->jChipType == XG21) {
2387 if (pVBInfo->IF_DEF_LVDS == 1) {
2388 /* LVDS backlight off */
2389 XGI_XG21BLSignalVDD(0x02, 0x00, pVBInfo);
2390 mdelay(xgifb_info->lvds_data.PSC_S3);
2391 } else {
2392 /* DVO/DVI signal off */
2393 XGI_XG21BLSignalVDD(0x20, 0x00, pVBInfo);
2397 if (pXGIHWDE->jChipType == XG27) {
2398 if ((XGI_XG27GetPSCValue(pVBInfo) & 0x2)) {
2399 /* LVDS backlight off */
2400 XGI_XG27BLSignalVDD(0x02, 0x00, pVBInfo);
2401 mdelay(xgifb_info->lvds_data.PSC_S3);
2404 if (pVBInfo->IF_DEF_LVDS == 0)
2405 /* DVO/DVI signal off */
2406 XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo);
2409 xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x20);
2412 static void XGI_WaitDisply(struct vb_device_info *pVBInfo)
2414 while ((inb(pVBInfo->P3da) & 0x01))
2415 break;
2417 while (!(inb(pVBInfo->P3da) & 0x01))
2418 break;
2421 static void XGI_AutoThreshold(struct vb_device_info *pVBInfo)
2423 xgifb_reg_or(pVBInfo->Part1Port, 0x01, 0x40);
2426 static void XGI_SaveCRT2Info(unsigned short ModeNo,
2427 struct vb_device_info *pVBInfo)
2429 unsigned short temp1, temp2;
2431 /* reserve CR34 for CRT1 Mode No */
2432 xgifb_reg_set(pVBInfo->P3d4, 0x34, ModeNo);
2433 temp1 = (pVBInfo->VBInfo & SetInSlaveMode) >> 8;
2434 temp2 = ~(SetInSlaveMode >> 8);
2435 xgifb_reg_and_or(pVBInfo->P3d4, 0x31, temp2, temp1);
2438 static void XGI_GetCRT2ResInfo(unsigned short ModeNo,
2439 unsigned short ModeIdIndex,
2440 struct vb_device_info *pVBInfo)
2442 unsigned short xres, yres, modeflag, resindex;
2444 resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO;
2445 xres = XGI330_ModeResInfo[resindex].HTotal; /* xres->ax */
2446 yres = XGI330_ModeResInfo[resindex].VTotal; /* yres->bx */
2447 /* si+St_ModeFlag */
2448 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2450 if (modeflag & HalfDCLK)
2451 xres *= 2;
2453 if (modeflag & DoubleScanMode)
2454 yres *= 2;
2456 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
2457 goto exit;
2459 if (pVBInfo->LCDResInfo == Panel_1600x1200) {
2460 if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
2461 if (yres == 1024)
2462 yres = 1056;
2466 if (pVBInfo->LCDResInfo == Panel_1280x1024) {
2467 if (yres == 400)
2468 yres = 405;
2469 else if (yres == 350)
2470 yres = 360;
2472 if (pVBInfo->LCDInfo & XGI_LCDVESATiming) {
2473 if (yres == 360)
2474 yres = 375;
2478 if (pVBInfo->LCDResInfo == Panel_1024x768) {
2479 if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
2480 if (!(pVBInfo->LCDInfo & LCDNonExpanding)) {
2481 if (yres == 350)
2482 yres = 357;
2483 else if (yres == 400)
2484 yres = 420;
2485 else if (yres == 480)
2486 yres = 525;
2491 if (xres == 720)
2492 xres = 640;
2494 exit:
2495 pVBInfo->VGAHDE = xres;
2496 pVBInfo->HDE = xres;
2497 pVBInfo->VGAVDE = yres;
2498 pVBInfo->VDE = yres;
2501 static unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo)
2504 if ((pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) &&
2505 (pVBInfo->LCDInfo & SetLCDDualLink)) /* shampoo0129 */
2506 return 1;
2508 return 0;
2511 static void XGI_GetRAMDAC2DATA(unsigned short ModeNo,
2512 unsigned short ModeIdIndex,
2513 unsigned short RefreshRateTableIndex,
2514 struct vb_device_info *pVBInfo)
2516 unsigned short tempax, tempbx, temp1, temp2, modeflag = 0, tempcx,
2517 CRT1Index;
2519 pVBInfo->RVBHCMAX = 1;
2520 pVBInfo->RVBHCFACT = 1;
2521 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2522 CRT1Index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
2523 CRT1Index &= IndexMask;
2524 temp1 = (unsigned short) XGI_CRT1Table[CRT1Index].CR[0];
2525 temp2 = (unsigned short) XGI_CRT1Table[CRT1Index].CR[5];
2526 tempax = (temp1 & 0xFF) | ((temp2 & 0x03) << 8);
2527 tempbx = (unsigned short) XGI_CRT1Table[CRT1Index].CR[8];
2528 tempcx = (unsigned short)
2529 XGI_CRT1Table[CRT1Index].CR[14] << 8;
2530 tempcx &= 0x0100;
2531 tempcx = tempcx << 2;
2532 tempbx |= tempcx;
2533 temp1 = (unsigned short) XGI_CRT1Table[CRT1Index].CR[9];
2535 if (temp1 & 0x01)
2536 tempbx |= 0x0100;
2538 if (temp1 & 0x20)
2539 tempbx |= 0x0200;
2540 tempax += 5;
2542 if (modeflag & Charx8Dot)
2543 tempax *= 8;
2544 else
2545 tempax *= 9;
2547 pVBInfo->VGAHT = tempax;
2548 pVBInfo->HT = tempax;
2549 tempbx++;
2550 pVBInfo->VGAVT = tempbx;
2551 pVBInfo->VT = tempbx;
2554 static void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex,
2555 unsigned short RefreshRateTableIndex,
2556 struct vb_device_info *pVBInfo)
2558 unsigned short tempax = 0, tempbx = 0, modeflag, resinfo;
2560 struct SiS_LCDData const *LCDPtr = NULL;
2562 /* si+Ext_ResInfo */
2563 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2564 resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO;
2565 pVBInfo->NewFlickerMode = 0;
2566 pVBInfo->RVBHRS = 50;
2568 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
2569 XGI_GetRAMDAC2DATA(ModeNo, ModeIdIndex, RefreshRateTableIndex,
2570 pVBInfo);
2571 return;
2574 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
2575 LCDPtr = XGI_GetLcdPtr(XGI_LCDDataTable, ModeNo, ModeIdIndex,
2576 RefreshRateTableIndex, pVBInfo);
2578 pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX;
2579 pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT;
2580 pVBInfo->VGAHT = LCDPtr->VGAHT;
2581 pVBInfo->VGAVT = LCDPtr->VGAVT;
2582 pVBInfo->HT = LCDPtr->LCDHT;
2583 pVBInfo->VT = LCDPtr->LCDVT;
2585 if (pVBInfo->LCDResInfo == Panel_1024x768) {
2586 tempax = 1024;
2587 tempbx = 768;
2589 if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
2590 if (pVBInfo->VGAVDE == 357)
2591 tempbx = 527;
2592 else if (pVBInfo->VGAVDE == 420)
2593 tempbx = 620;
2594 else if (pVBInfo->VGAVDE == 525)
2595 tempbx = 775;
2596 else if (pVBInfo->VGAVDE == 600)
2597 tempbx = 775;
2599 } else if (pVBInfo->LCDResInfo == Panel_1024x768x75) {
2600 tempax = 1024;
2601 tempbx = 768;
2602 } else if (pVBInfo->LCDResInfo == Panel_1280x1024) {
2603 tempax = 1280;
2604 if (pVBInfo->VGAVDE == 360)
2605 tempbx = 768;
2606 else if (pVBInfo->VGAVDE == 375)
2607 tempbx = 800;
2608 else if (pVBInfo->VGAVDE == 405)
2609 tempbx = 864;
2610 else
2611 tempbx = 1024;
2612 } else if (pVBInfo->LCDResInfo == Panel_1280x1024x75) {
2613 tempax = 1280;
2614 tempbx = 1024;
2615 } else if (pVBInfo->LCDResInfo == Panel_1280x960) {
2616 tempax = 1280;
2617 if (pVBInfo->VGAVDE == 350)
2618 tempbx = 700;
2619 else if (pVBInfo->VGAVDE == 400)
2620 tempbx = 800;
2621 else if (pVBInfo->VGAVDE == 1024)
2622 tempbx = 960;
2623 else
2624 tempbx = 960;
2625 } else if (pVBInfo->LCDResInfo == Panel_1400x1050) {
2626 tempax = 1400;
2627 tempbx = 1050;
2629 if (pVBInfo->VGAVDE == 1024) {
2630 tempax = 1280;
2631 tempbx = 1024;
2633 } else if (pVBInfo->LCDResInfo == Panel_1600x1200) {
2634 tempax = 1600;
2635 tempbx = 1200; /* alan 10/14/2003 */
2636 if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
2637 if (pVBInfo->VGAVDE == 350)
2638 tempbx = 875;
2639 else if (pVBInfo->VGAVDE == 400)
2640 tempbx = 1000;
2644 if (pVBInfo->LCDInfo & LCDNonExpanding) {
2645 tempax = pVBInfo->VGAHDE;
2646 tempbx = pVBInfo->VGAVDE;
2649 pVBInfo->HDE = tempax;
2650 pVBInfo->VDE = tempbx;
2651 return;
2654 if (pVBInfo->VBInfo & (SetCRT2ToTV)) {
2655 struct SiS_TVData const *TVPtr;
2657 TVPtr = XGI_GetTVPtr(ModeNo, ModeIdIndex, RefreshRateTableIndex,
2658 pVBInfo);
2660 pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX;
2661 pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT;
2662 pVBInfo->VGAHT = TVPtr->VGAHT;
2663 pVBInfo->VGAVT = TVPtr->VGAVT;
2664 pVBInfo->HDE = TVPtr->TVHDE;
2665 pVBInfo->VDE = TVPtr->TVVDE;
2666 pVBInfo->RVBHRS = TVPtr->RVBHRS;
2667 pVBInfo->NewFlickerMode = TVPtr->FlickerMode;
2669 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
2670 if (resinfo == 0x08)
2671 pVBInfo->NewFlickerMode = 0x40;
2672 else if (resinfo == 0x09)
2673 pVBInfo->NewFlickerMode = 0x40;
2674 else if (resinfo == 0x12)
2675 pVBInfo->NewFlickerMode = 0x40;
2677 if (pVBInfo->VGAVDE == 350)
2678 pVBInfo->TVInfo |= TVSimuMode;
2680 tempax = ExtHiTVHT;
2681 tempbx = ExtHiTVVT;
2683 if (pVBInfo->VBInfo & SetInSlaveMode) {
2684 if (pVBInfo->TVInfo & TVSimuMode) {
2685 tempax = StHiTVHT;
2686 tempbx = StHiTVVT;
2688 if (!(modeflag & Charx8Dot)) {
2689 tempax = StHiTextTVHT;
2690 tempbx = StHiTextTVVT;
2694 } else if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
2695 if (pVBInfo->TVInfo & TVSetYPbPr750p) {
2696 tempax = YPbPrTV750pHT; /* Ext750pTVHT */
2697 tempbx = YPbPrTV750pVT; /* Ext750pTVVT */
2700 if (pVBInfo->TVInfo & TVSetYPbPr525p) {
2701 tempax = YPbPrTV525pHT; /* Ext525pTVHT */
2702 tempbx = YPbPrTV525pVT; /* Ext525pTVVT */
2703 } else if (pVBInfo->TVInfo & TVSetYPbPr525i) {
2704 tempax = YPbPrTV525iHT; /* Ext525iTVHT */
2705 tempbx = YPbPrTV525iVT; /* Ext525iTVVT */
2706 if (pVBInfo->TVInfo & NTSC1024x768)
2707 tempax = NTSC1024x768HT;
2709 } else {
2710 tempax = PALHT;
2711 tempbx = PALVT;
2712 if (!(pVBInfo->TVInfo & TVSetPAL)) {
2713 tempax = NTSCHT;
2714 tempbx = NTSCVT;
2715 if (pVBInfo->TVInfo & NTSC1024x768)
2716 tempax = NTSC1024x768HT;
2720 pVBInfo->HT = tempax;
2721 pVBInfo->VT = tempbx;
2725 static void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex,
2726 unsigned short RefreshRateTableIndex,
2727 struct vb_device_info *pVBInfo)
2729 unsigned char di_0, di_1, tempal;
2731 tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex,
2732 pVBInfo);
2733 XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo);
2734 XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo);
2736 if (pVBInfo->VBType & VB_SIS301) { /* shampoo 0129 */
2737 /* 301 */
2738 xgifb_reg_set(pVBInfo->Part4Port, 0x0A, 0x10);
2739 xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1);
2740 xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0);
2741 } else { /* 301b/302b/301lv/302lv */
2742 xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0);
2743 xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1);
2746 xgifb_reg_set(pVBInfo->Part4Port, 0x00, 0x12);
2748 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC)
2749 xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x28);
2750 else
2751 xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x08);
2754 static unsigned short XGI_GetColorDepth(unsigned short ModeNo,
2755 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
2757 unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8 };
2758 short index;
2759 unsigned short modeflag;
2761 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2762 index = (modeflag & ModeTypeMask) - ModeEGA;
2764 if (index < 0)
2765 index = 0;
2767 return ColorDepth[index];
2770 static unsigned short XGI_GetOffset(unsigned short ModeNo,
2771 unsigned short ModeIdIndex,
2772 unsigned short RefreshRateTableIndex,
2773 struct xgi_hw_device_info *HwDeviceExtension,
2774 struct vb_device_info *pVBInfo)
2776 unsigned short temp, colordepth, modeinfo, index, infoflag,
2777 ColorDepth[] = { 0x01, 0x02, 0x04 };
2779 modeinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeInfo;
2780 infoflag = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
2782 index = (modeinfo >> 8) & 0xFF;
2784 temp = XGI330_ScreenOffset[index];
2786 if (infoflag & InterlaceMode)
2787 temp = temp << 1;
2789 colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo);
2791 if ((ModeNo >= 0x7C) && (ModeNo <= 0x7E)) {
2792 temp = ModeNo - 0x7C;
2793 colordepth = ColorDepth[temp];
2794 temp = 0x6B;
2795 if (infoflag & InterlaceMode)
2796 temp = temp << 1;
2798 return temp * colordepth;
2801 static void XGI_SetCRT2Offset(unsigned short ModeNo,
2802 unsigned short ModeIdIndex,
2803 unsigned short RefreshRateTableIndex,
2804 struct xgi_hw_device_info *HwDeviceExtension,
2805 struct vb_device_info *pVBInfo)
2807 unsigned short offset;
2808 unsigned char temp;
2810 if (pVBInfo->VBInfo & SetInSlaveMode)
2811 return;
2813 offset = XGI_GetOffset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
2814 HwDeviceExtension, pVBInfo);
2815 temp = (unsigned char) (offset & 0xFF);
2816 xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp);
2817 temp = (unsigned char) ((offset & 0xFF00) >> 8);
2818 xgifb_reg_set(pVBInfo->Part1Port, 0x09, temp);
2819 temp = (unsigned char) (((offset >> 3) & 0xFF) + 1);
2820 xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp);
2823 static void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo)
2825 /* threshold high ,disable auto threshold */
2826 xgifb_reg_set(pVBInfo->Part1Port, 0x01, 0x3B);
2827 /* threshold low default 04h */
2828 xgifb_reg_and_or(pVBInfo->Part1Port, 0x02, ~(0x3F), 0x04);
2831 static void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
2832 struct xgi_hw_device_info *HwDeviceExtension,
2833 unsigned short RefreshRateTableIndex,
2834 struct vb_device_info *pVBInfo)
2836 u8 tempcx;
2838 XGI_SetCRT2Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
2839 HwDeviceExtension, pVBInfo);
2840 XGI_SetCRT2FIFO(pVBInfo);
2842 for (tempcx = 4; tempcx < 7; tempcx++)
2843 xgifb_reg_set(pVBInfo->Part1Port, tempcx, 0x0);
2845 xgifb_reg_set(pVBInfo->Part1Port, 0x50, 0x00);
2846 xgifb_reg_set(pVBInfo->Part1Port, 0x02, 0x44); /* temp 0206 */
2849 static void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
2850 struct xgi_hw_device_info *HwDeviceExtension,
2851 unsigned short RefreshRateTableIndex,
2852 struct vb_device_info *pVBInfo)
2854 unsigned short temp = 0, tempax = 0, tempbx = 0, tempcx = 0,
2855 pushbx = 0, CRT1Index, modeflag;
2857 CRT1Index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
2858 CRT1Index &= IndexMask;
2859 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2861 /* bainy change table name */
2862 if (modeflag & HalfDCLK) {
2863 /* BTVGA2HT 0x08,0x09 */
2864 temp = (pVBInfo->VGAHT / 2 - 1) & 0x0FF;
2865 xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp);
2866 temp = (((pVBInfo->VGAHT / 2 - 1) & 0xFF00) >> 8) << 4;
2867 xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp);
2868 /* BTVGA2HDEE 0x0A,0x0C */
2869 temp = (pVBInfo->VGAHDE / 2 + 16) & 0x0FF;
2870 xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp);
2871 tempcx = ((pVBInfo->VGAHT - pVBInfo->VGAHDE) / 2) >> 2;
2872 pushbx = pVBInfo->VGAHDE / 2 + 16;
2873 tempcx = tempcx >> 1;
2874 tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */
2875 tempcx += tempbx;
2877 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
2878 tempbx = XGI_CRT1Table[CRT1Index].CR[4];
2879 tempbx |= ((XGI_CRT1Table[CRT1Index].CR[14] &
2880 0xC0) << 2);
2881 tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */
2882 tempcx = XGI_CRT1Table[CRT1Index].CR[5];
2883 tempcx &= 0x1F;
2884 temp = XGI_CRT1Table[CRT1Index].CR[15];
2885 temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */
2886 tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */
2889 tempbx += 4;
2890 tempcx += 4;
2892 if (tempcx > (pVBInfo->VGAHT / 2))
2893 tempcx = pVBInfo->VGAHT / 2;
2895 temp = tempbx & 0x00FF;
2897 xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp);
2898 } else {
2899 temp = (pVBInfo->VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */
2900 xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp);
2901 temp = (((pVBInfo->VGAHT - 1) & 0xFF00) >> 8) << 4;
2902 xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp);
2903 /* BTVGA2HDEE 0x0A,0x0C */
2904 temp = (pVBInfo->VGAHDE + 16) & 0x0FF;
2905 xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp);
2906 tempcx = (pVBInfo->VGAHT - pVBInfo->VGAHDE) >> 2; /* cx */
2907 pushbx = pVBInfo->VGAHDE + 16;
2908 tempcx = tempcx >> 1;
2909 tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */
2910 tempcx += tempbx;
2912 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
2913 tempbx = XGI_CRT1Table[CRT1Index].CR[3];
2914 tempbx |= ((XGI_CRT1Table[CRT1Index].CR[5] &
2915 0xC0) << 2);
2916 tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */
2917 tempcx = XGI_CRT1Table[CRT1Index].CR[4];
2918 tempcx &= 0x1F;
2919 temp = XGI_CRT1Table[CRT1Index].CR[6];
2920 temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */
2921 tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */
2922 tempbx += 16;
2923 tempcx += 16;
2926 if (tempcx > pVBInfo->VGAHT)
2927 tempcx = pVBInfo->VGAHT;
2929 temp = tempbx & 0x00FF;
2930 xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp);
2933 tempax = (tempax & 0x00FF) | (tempbx & 0xFF00);
2934 tempbx = pushbx;
2935 tempbx = (tempbx & 0x00FF) | ((tempbx & 0xFF00) << 4);
2936 tempax |= (tempbx & 0xFF00);
2937 temp = (tempax & 0xFF00) >> 8;
2938 xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp);
2939 temp = tempcx & 0x00FF;
2940 xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp);
2941 tempcx = (pVBInfo->VGAVT - 1);
2942 temp = tempcx & 0x00FF;
2944 xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp);
2945 tempbx = pVBInfo->VGAVDE - 1;
2946 temp = tempbx & 0x00FF;
2947 xgifb_reg_set(pVBInfo->Part1Port, 0x0F, temp);
2948 temp = ((tempbx & 0xFF00) << 3) >> 8;
2949 temp |= ((tempcx & 0xFF00) >> 8);
2950 xgifb_reg_set(pVBInfo->Part1Port, 0x12, temp);
2952 /* BTVGA2VRS 0x10,0x11 */
2953 tempbx = (pVBInfo->VGAVT + pVBInfo->VGAVDE) >> 1;
2954 /* BTVGA2VRE 0x11 */
2955 tempcx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) >> 4) + tempbx + 1;
2957 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
2958 tempbx = XGI_CRT1Table[CRT1Index].CR[10];
2959 temp = XGI_CRT1Table[CRT1Index].CR[9];
2961 if (temp & 0x04)
2962 tempbx |= 0x0100;
2964 if (temp & 0x080)
2965 tempbx |= 0x0200;
2967 temp = XGI_CRT1Table[CRT1Index].CR[14];
2969 if (temp & 0x08)
2970 tempbx |= 0x0400;
2972 temp = XGI_CRT1Table[CRT1Index].CR[11];
2973 tempcx = (tempcx & 0xFF00) | (temp & 0x00FF);
2976 temp = tempbx & 0x00FF;
2977 xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp);
2978 temp = ((tempbx & 0xFF00) >> 8) << 4;
2979 temp = ((tempcx & 0x000F) | (temp));
2980 xgifb_reg_set(pVBInfo->Part1Port, 0x11, temp);
2981 tempax = 0;
2983 if (modeflag & DoubleScanMode)
2984 tempax |= 0x80;
2986 if (modeflag & HalfDCLK)
2987 tempax |= 0x40;
2989 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2C, ~0x0C0, tempax);
2992 static unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo)
2994 unsigned long tempax, tempbx;
2996 tempbx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) * pVBInfo->RVBHCMAX)
2997 & 0xFFFF;
2998 tempax = (pVBInfo->VT - pVBInfo->VDE) * pVBInfo->RVBHCFACT;
2999 tempax = (tempax * pVBInfo->HT) / tempbx;
3001 return (unsigned short) tempax;
3004 static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
3005 struct xgi_hw_device_info *HwDeviceExtension,
3006 unsigned short RefreshRateTableIndex,
3007 struct vb_device_info *pVBInfo)
3009 unsigned short push1, push2, tempax, tempbx = 0, tempcx, temp, resinfo,
3010 modeflag;
3012 /* si+Ext_ResInfo */
3013 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3014 resinfo = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO;
3016 if (!(pVBInfo->VBInfo & SetInSlaveMode))
3017 return;
3019 temp = 0xFF; /* set MAX HT */
3020 xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp);
3021 tempcx = 0x08;
3023 if (pVBInfo->VBType & (VB_SIS301LV | VB_SIS302LV | VB_XGI301C))
3024 modeflag |= Charx8Dot;
3026 tempax = pVBInfo->VGAHDE; /* 0x04 Horizontal Display End */
3028 if (modeflag & HalfDCLK)
3029 tempax = tempax >> 1;
3031 tempax = (tempax / tempcx) - 1;
3032 tempbx |= ((tempax & 0x00FF) << 8);
3033 temp = tempax & 0x00FF;
3034 xgifb_reg_set(pVBInfo->Part1Port, 0x04, temp);
3036 temp = (tempbx & 0xFF00) >> 8;
3038 if (pVBInfo->VBInfo & SetCRT2ToTV) {
3039 if (!(pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
3040 | VB_SIS302LV | VB_XGI301C)))
3041 temp += 2;
3043 if ((pVBInfo->VBInfo & SetCRT2ToHiVision) &&
3044 !(pVBInfo->VBType & VB_SIS301LV) && (resinfo == 7))
3045 temp -= 2;
3048 /* 0x05 Horizontal Display Start */
3049 xgifb_reg_set(pVBInfo->Part1Port, 0x05, temp);
3050 /* 0x06 Horizontal Blank end */
3051 xgifb_reg_set(pVBInfo->Part1Port, 0x06, 0x03);
3053 if (!(pVBInfo->VBInfo & DisableCRT2Display)) { /* 030226 bainy */
3054 if (pVBInfo->VBInfo & SetCRT2ToTV)
3055 tempax = pVBInfo->VGAHT;
3056 else
3057 tempax = XGI_GetVGAHT2(pVBInfo);
3060 if (tempax >= pVBInfo->VGAHT)
3061 tempax = pVBInfo->VGAHT;
3063 if (modeflag & HalfDCLK)
3064 tempax = tempax >> 1;
3066 tempax = (tempax / tempcx) - 5;
3067 tempcx = tempax; /* 20030401 0x07 horizontal Retrace Start */
3068 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
3069 temp = (tempbx & 0x00FF) - 1;
3070 if (!(modeflag & HalfDCLK)) {
3071 temp -= 6;
3072 if (pVBInfo->TVInfo & TVSimuMode) {
3073 temp -= 4;
3074 temp -= 10;
3077 } else {
3078 tempbx = (tempbx & 0xFF00) >> 8;
3079 tempcx = (tempcx + tempbx) >> 1;
3080 temp = (tempcx & 0x00FF) + 2;
3082 if (pVBInfo->VBInfo & SetCRT2ToTV) {
3083 temp -= 1;
3084 if (!(modeflag & HalfDCLK)) {
3085 if ((modeflag & Charx8Dot)) {
3086 temp += 4;
3087 if (pVBInfo->VGAHDE >= 800)
3088 temp -= 6;
3091 } else if (!(modeflag & HalfDCLK)) {
3092 temp -= 4;
3093 if (pVBInfo->LCDResInfo != Panel_1280x960 &&
3094 pVBInfo->VGAHDE >= 800) {
3095 temp -= 7;
3096 if (pVBInfo->VGAHDE >= 1280 &&
3097 pVBInfo->LCDResInfo != Panel_1280x960 &&
3098 (pVBInfo->LCDInfo & LCDNonExpanding))
3099 temp += 28;
3104 /* 0x07 Horizontal Retrace Start */
3105 xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp);
3106 /* 0x08 Horizontal Retrace End */
3107 xgifb_reg_set(pVBInfo->Part1Port, 0x08, 0);
3109 if (pVBInfo->VBInfo & SetCRT2ToTV) {
3110 if (pVBInfo->TVInfo & TVSimuMode) {
3111 if (ModeNo == 0x50) {
3112 if (pVBInfo->TVInfo == SetNTSCTV) {
3113 xgifb_reg_set(pVBInfo->Part1Port,
3114 0x07, 0x30);
3115 xgifb_reg_set(pVBInfo->Part1Port,
3116 0x08, 0x03);
3117 } else {
3118 xgifb_reg_set(pVBInfo->Part1Port,
3119 0x07, 0x2f);
3120 xgifb_reg_set(pVBInfo->Part1Port,
3121 0x08, 0x02);
3127 xgifb_reg_set(pVBInfo->Part1Port, 0x18, 0x03); /* 0x18 SR0B */
3128 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0xF0, 0x00);
3129 xgifb_reg_set(pVBInfo->Part1Port, 0x09, 0xFF); /* 0x09 Set Max VT */
3131 tempbx = pVBInfo->VGAVT;
3132 push1 = tempbx;
3133 tempcx = 0x121;
3134 tempbx = pVBInfo->VGAVDE; /* 0x0E Virtical Display End */
3136 if (tempbx == 357)
3137 tempbx = 350;
3138 if (tempbx == 360)
3139 tempbx = 350;
3140 if (tempbx == 375)
3141 tempbx = 350;
3142 if (tempbx == 405)
3143 tempbx = 400;
3144 if (tempbx == 525)
3145 tempbx = 480;
3147 push2 = tempbx;
3149 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
3150 if (pVBInfo->LCDResInfo == Panel_1024x768) {
3151 if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
3152 if (tempbx == 350)
3153 tempbx += 5;
3154 if (tempbx == 480)
3155 tempbx += 5;
3159 tempbx--;
3160 tempbx--;
3161 temp = tempbx & 0x00FF;
3162 /* 0x10 vertical Blank Start */
3163 xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp);
3164 tempbx = push2;
3165 tempbx--;
3166 temp = tempbx & 0x00FF;
3167 xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp);
3169 if (tempbx & 0x0100)
3170 tempcx |= 0x0002;
3172 tempax = 0x000B;
3174 if (modeflag & DoubleScanMode)
3175 tempax |= 0x08000;
3177 if (tempbx & 0x0200)
3178 tempcx |= 0x0040;
3180 temp = (tempax & 0xFF00) >> 8;
3181 xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp);
3183 if (tempbx & 0x0400)
3184 tempcx |= 0x0600;
3186 /* 0x11 Vertival Blank End */
3187 xgifb_reg_set(pVBInfo->Part1Port, 0x11, 0x00);
3189 tempax = push1;
3190 tempax -= tempbx; /* 0x0C Vertical Retrace Start */
3191 tempax = tempax >> 2;
3192 push1 = tempax; /* push ax */
3194 if (resinfo != 0x09) {
3195 tempax = tempax << 1;
3196 tempbx += tempax;
3199 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
3200 if ((pVBInfo->VBType & VB_SIS301LV) &&
3201 !(pVBInfo->TVInfo & TVSetHiVision)) {
3202 if ((pVBInfo->TVInfo & TVSimuMode) &&
3203 (pVBInfo->TVInfo & TVSetPAL)) {
3204 if (!(pVBInfo->VBType & VB_SIS301LV) ||
3205 !(pVBInfo->TVInfo &
3206 (TVSetYPbPr525p |
3207 TVSetYPbPr750p |
3208 TVSetHiVision)))
3209 tempbx += 40;
3211 } else {
3212 tempbx -= 10;
3214 } else if (pVBInfo->TVInfo & TVSimuMode) {
3215 if (pVBInfo->TVInfo & TVSetPAL) {
3216 if (pVBInfo->VBType & VB_SIS301LV) {
3217 if (!(pVBInfo->TVInfo &
3218 (TVSetYPbPr525p |
3219 TVSetYPbPr750p |
3220 TVSetHiVision)))
3221 tempbx += 40;
3222 } else {
3223 tempbx += 40;
3227 tempax = push1;
3228 tempax = tempax >> 2;
3229 tempax++;
3230 tempax += tempbx;
3231 push1 = tempax; /* push ax */
3233 if ((pVBInfo->TVInfo & TVSetPAL)) {
3234 if (tempbx <= 513) {
3235 if (tempax >= 513)
3236 tempbx = 513;
3240 temp = tempbx & 0x00FF;
3241 xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp);
3242 tempbx--;
3243 temp = tempbx & 0x00FF;
3244 xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp);
3246 if (tempbx & 0x0100)
3247 tempcx |= 0x0008;
3249 if (tempbx & 0x0200)
3250 xgifb_reg_and_or(pVBInfo->Part1Port, 0x0B, 0x0FF, 0x20);
3252 tempbx++;
3254 if (tempbx & 0x0100)
3255 tempcx |= 0x0004;
3257 if (tempbx & 0x0200)
3258 tempcx |= 0x0080;
3260 if (tempbx & 0x0400)
3261 tempcx |= 0x0C00;
3263 tempbx = push1; /* pop ax */
3264 temp = tempbx & 0x00FF;
3265 temp &= 0x0F;
3266 /* 0x0D vertical Retrace End */
3267 xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp);
3269 if (tempbx & 0x0010)
3270 tempcx |= 0x2000;
3272 temp = tempcx & 0x00FF;
3273 xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); /* 0x0A CR07 */
3274 temp = (tempcx & 0x0FF00) >> 8;
3275 xgifb_reg_set(pVBInfo->Part1Port, 0x17, temp); /* 0x17 SR0A */
3276 tempax = modeflag;
3277 temp = (tempax & 0xFF00) >> 8;
3279 temp = (temp >> 1) & 0x09;
3281 if (pVBInfo->VBType & (VB_SIS301LV | VB_SIS302LV | VB_XGI301C))
3282 temp |= 0x01;
3284 xgifb_reg_set(pVBInfo->Part1Port, 0x16, temp); /* 0x16 SR01 */
3285 xgifb_reg_set(pVBInfo->Part1Port, 0x0F, 0); /* 0x0F CR14 */
3286 xgifb_reg_set(pVBInfo->Part1Port, 0x12, 0); /* 0x12 CR17 */
3288 if (pVBInfo->LCDInfo & LCDRGB18Bit)
3289 temp = 0x80;
3290 else
3291 temp = 0x00;
3293 xgifb_reg_set(pVBInfo->Part1Port, 0x1A, temp); /* 0x1A SR0E */
3296 static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex,
3297 unsigned short RefreshRateTableIndex,
3298 struct xgi_hw_device_info *HwDeviceExtension,
3299 struct vb_device_info *pVBInfo)
3301 unsigned short i, j, tempax, tempbx, tempcx, temp, push1, push2,
3302 modeflag;
3303 unsigned char const *TimingPoint;
3305 unsigned long longtemp, tempeax, tempebx, temp2, tempecx;
3307 /* si+Ext_ResInfo */
3308 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3310 tempax = 0;
3312 if (!(pVBInfo->VBInfo & SetCRT2ToAVIDEO))
3313 tempax |= 0x0800;
3315 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
3316 tempax |= 0x0400;
3318 if (pVBInfo->VBInfo & SetCRT2ToSCART)
3319 tempax |= 0x0200;
3321 if (!(pVBInfo->TVInfo & TVSetPAL))
3322 tempax |= 0x1000;
3324 if (pVBInfo->VBInfo & SetCRT2ToHiVision)
3325 tempax |= 0x0100;
3327 if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p))
3328 tempax &= 0xfe00;
3330 tempax = (tempax & 0xff00) >> 8;
3332 xgifb_reg_set(pVBInfo->Part2Port, 0x0, tempax);
3333 TimingPoint = XGI330_NTSCTiming;
3335 if (pVBInfo->TVInfo & TVSetPAL)
3336 TimingPoint = XGI330_PALTiming;
3338 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
3339 TimingPoint = XGI330_HiTVExtTiming;
3341 if (pVBInfo->VBInfo & SetInSlaveMode)
3342 TimingPoint = XGI330_HiTVSt2Timing;
3344 if (pVBInfo->SetFlag & TVSimuMode)
3345 TimingPoint = XGI330_HiTVSt1Timing;
3347 if (!(modeflag & Charx8Dot))
3348 TimingPoint = XGI330_HiTVTextTiming;
3351 if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
3352 if (pVBInfo->TVInfo & TVSetYPbPr525i)
3353 TimingPoint = XGI330_YPbPr525iTiming;
3355 if (pVBInfo->TVInfo & TVSetYPbPr525p)
3356 TimingPoint = XGI330_YPbPr525pTiming;
3358 if (pVBInfo->TVInfo & TVSetYPbPr750p)
3359 TimingPoint = XGI330_YPbPr750pTiming;
3362 for (i = 0x01, j = 0; i <= 0x2D; i++, j++)
3363 xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]);
3365 for (i = 0x39; i <= 0x45; i++, j++)
3366 /* di->temp2[j] */
3367 xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]);
3369 if (pVBInfo->VBInfo & SetCRT2ToTV)
3370 xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, 0x00);
3372 temp = pVBInfo->NewFlickerMode;
3373 temp &= 0x80;
3374 xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xFF, temp);
3376 if (pVBInfo->TVInfo & TVSetPAL)
3377 tempax = 520;
3378 else
3379 tempax = 440;
3381 if (pVBInfo->VDE <= tempax) {
3382 tempax -= pVBInfo->VDE;
3383 tempax = tempax >> 2;
3384 tempax = (tempax & 0x00FF) | ((tempax & 0x00FF) << 8);
3385 push1 = tempax;
3386 temp = (tempax & 0xFF00) >> 8;
3387 temp += (unsigned short) TimingPoint[0];
3389 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
3390 | VB_SIS302LV | VB_XGI301C)) {
3391 if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO
3392 | SetCRT2ToSVIDEO | SetCRT2ToSCART
3393 | SetCRT2ToYPbPr525750)) {
3394 tempcx = pVBInfo->VGAHDE;
3395 if (tempcx >= 1024) {
3396 temp = 0x17; /* NTSC */
3397 if (pVBInfo->TVInfo & TVSetPAL)
3398 temp = 0x19; /* PAL */
3403 xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp);
3404 tempax = push1;
3405 temp = (tempax & 0xFF00) >> 8;
3406 temp += TimingPoint[1];
3408 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
3409 | VB_SIS302LV | VB_XGI301C)) {
3410 if ((pVBInfo->VBInfo & (SetCRT2ToAVIDEO
3411 | SetCRT2ToSVIDEO | SetCRT2ToSCART
3412 | SetCRT2ToYPbPr525750))) {
3413 tempcx = pVBInfo->VGAHDE;
3414 if (tempcx >= 1024) {
3415 temp = 0x1D; /* NTSC */
3416 if (pVBInfo->TVInfo & TVSetPAL)
3417 temp = 0x52; /* PAL */
3421 xgifb_reg_set(pVBInfo->Part2Port, 0x02, temp);
3424 /* 301b */
3425 tempcx = pVBInfo->HT;
3427 if (XGI_IsLCDDualLink(pVBInfo))
3428 tempcx = tempcx >> 1;
3430 tempcx -= 2;
3431 temp = tempcx & 0x00FF;
3432 xgifb_reg_set(pVBInfo->Part2Port, 0x1B, temp);
3434 temp = (tempcx & 0xFF00) >> 8;
3435 xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F, temp);
3437 tempcx = pVBInfo->HT >> 1;
3438 push1 = tempcx; /* push cx */
3439 tempcx += 7;
3441 if (pVBInfo->VBInfo & SetCRT2ToHiVision)
3442 tempcx -= 4;
3444 temp = tempcx & 0x00FF;
3445 temp = temp << 4;
3446 xgifb_reg_and_or(pVBInfo->Part2Port, 0x22, 0x0F, temp);
3448 tempbx = TimingPoint[j] | ((TimingPoint[j + 1]) << 8);
3449 tempbx += tempcx;
3450 push2 = tempbx;
3451 temp = tempbx & 0x00FF;
3452 xgifb_reg_set(pVBInfo->Part2Port, 0x24, temp);
3453 temp = (tempbx & 0xFF00) >> 8;
3454 temp = temp << 4;
3455 xgifb_reg_and_or(pVBInfo->Part2Port, 0x25, 0x0F, temp);
3457 tempbx = push2;
3458 tempbx = tempbx + 8;
3459 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
3460 tempbx = tempbx - 4;
3461 tempcx = tempbx;
3464 temp = (tempbx & 0x00FF) << 4;
3465 xgifb_reg_and_or(pVBInfo->Part2Port, 0x29, 0x0F, temp);
3467 j += 2;
3468 tempcx += (TimingPoint[j] | ((TimingPoint[j + 1]) << 8));
3469 temp = tempcx & 0x00FF;
3470 xgifb_reg_set(pVBInfo->Part2Port, 0x27, temp);
3471 temp = ((tempcx & 0xFF00) >> 8) << 4;
3472 xgifb_reg_and_or(pVBInfo->Part2Port, 0x28, 0x0F, temp);
3474 tempcx += 8;
3475 if (pVBInfo->VBInfo & SetCRT2ToHiVision)
3476 tempcx -= 4;
3478 temp = tempcx & 0xFF;
3479 temp = temp << 4;
3480 xgifb_reg_and_or(pVBInfo->Part2Port, 0x2A, 0x0F, temp);
3482 tempcx = push1; /* pop cx */
3483 j += 2;
3484 temp = TimingPoint[j] | ((TimingPoint[j + 1]) << 8);
3485 tempcx -= temp;
3486 temp = tempcx & 0x00FF;
3487 temp = temp << 4;
3488 xgifb_reg_and_or(pVBInfo->Part2Port, 0x2D, 0x0F, temp);
3490 tempcx -= 11;
3492 if (!(pVBInfo->VBInfo & SetCRT2ToTV)) {
3493 tempax = XGI_GetVGAHT2(pVBInfo);
3494 tempcx = tempax - 1;
3496 temp = tempcx & 0x00FF;
3497 xgifb_reg_set(pVBInfo->Part2Port, 0x2E, temp);
3499 tempbx = pVBInfo->VDE;
3501 if (pVBInfo->VGAVDE == 360)
3502 tempbx = 746;
3503 if (pVBInfo->VGAVDE == 375)
3504 tempbx = 746;
3505 if (pVBInfo->VGAVDE == 405)
3506 tempbx = 853;
3508 if (pVBInfo->VBInfo & SetCRT2ToTV) {
3509 if (pVBInfo->VBType &
3510 (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) {
3511 if (!(pVBInfo->TVInfo &
3512 (TVSetYPbPr525p | TVSetYPbPr750p)))
3513 tempbx = tempbx >> 1;
3514 } else
3515 tempbx = tempbx >> 1;
3518 tempbx -= 2;
3519 temp = tempbx & 0x00FF;
3521 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
3522 if (pVBInfo->VBType & VB_SIS301LV) {
3523 if (pVBInfo->TVInfo & TVSetHiVision) {
3524 if (pVBInfo->VBInfo & SetInSlaveMode) {
3525 if (ModeNo == 0x2f)
3526 temp += 1;
3529 } else if (pVBInfo->VBInfo & SetInSlaveMode) {
3530 if (ModeNo == 0x2f)
3531 temp += 1;
3535 xgifb_reg_set(pVBInfo->Part2Port, 0x2F, temp);
3537 temp = (tempcx & 0xFF00) >> 8;
3538 temp |= ((tempbx & 0xFF00) >> 8) << 6;
3540 if (!(pVBInfo->VBInfo & SetCRT2ToHiVision)) {
3541 if (pVBInfo->VBType & VB_SIS301LV) {
3542 if (pVBInfo->TVInfo & TVSetHiVision) {
3543 temp |= 0x10;
3545 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
3546 temp |= 0x20;
3548 } else {
3549 temp |= 0x10;
3550 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
3551 temp |= 0x20;
3555 xgifb_reg_set(pVBInfo->Part2Port, 0x30, temp);
3557 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
3558 | VB_SIS302LV | VB_XGI301C)) { /* TV gatingno */
3559 tempbx = pVBInfo->VDE;
3560 tempcx = tempbx - 2;
3562 if (pVBInfo->VBInfo & SetCRT2ToTV) {
3563 if (!(pVBInfo->TVInfo & (TVSetYPbPr525p
3564 | TVSetYPbPr750p)))
3565 tempbx = tempbx >> 1;
3568 if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) {
3569 temp = 0;
3570 if (tempcx & 0x0400)
3571 temp |= 0x20;
3573 if (tempbx & 0x0400)
3574 temp |= 0x40;
3576 xgifb_reg_set(pVBInfo->Part4Port, 0x10, temp);
3579 temp = (((tempbx - 3) & 0x0300) >> 8) << 5;
3580 xgifb_reg_set(pVBInfo->Part2Port, 0x46, temp);
3581 temp = (tempbx - 3) & 0x00FF;
3582 xgifb_reg_set(pVBInfo->Part2Port, 0x47, temp);
3585 tempbx = tempbx & 0x00FF;
3587 if (!(modeflag & HalfDCLK)) {
3588 tempcx = pVBInfo->VGAHDE;
3589 if (tempcx >= pVBInfo->HDE) {
3590 tempbx |= 0x2000;
3591 tempax &= 0x00FF;
3595 tempcx = 0x0101;
3597 if (pVBInfo->VBInfo & SetCRT2ToTV) { /*301b*/
3598 if (pVBInfo->VGAHDE >= 1024) {
3599 tempcx = 0x1920;
3600 if (pVBInfo->VGAHDE >= 1280) {
3601 tempcx = 0x1420;
3602 tempbx = tempbx & 0xDFFF;
3607 if (!(tempbx & 0x2000)) {
3608 if (modeflag & HalfDCLK)
3609 tempcx = (tempcx & 0xFF00) | ((tempcx & 0x00FF) << 1);
3611 push1 = tempbx;
3612 tempeax = pVBInfo->VGAHDE;
3613 tempebx = (tempcx & 0xFF00) >> 8;
3614 longtemp = tempeax * tempebx;
3615 tempecx = tempcx & 0x00FF;
3616 longtemp = longtemp / tempecx;
3618 /* 301b */
3619 tempecx = 8 * 1024;
3621 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
3622 | VB_SIS302LV | VB_XGI301C)) {
3623 tempecx = tempecx * 8;
3626 longtemp = longtemp * tempecx;
3627 tempecx = pVBInfo->HDE;
3628 temp2 = longtemp % tempecx;
3629 tempeax = longtemp / tempecx;
3630 if (temp2 != 0)
3631 tempeax += 1;
3633 tempax = (unsigned short) tempeax;
3635 /* 301b */
3636 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
3637 | VB_SIS302LV | VB_XGI301C)) {
3638 tempcx = ((tempax & 0xFF00) >> 5) >> 8;
3640 /* end 301b */
3642 tempbx = push1;
3643 tempbx = (unsigned short) (((tempeax & 0x0000FF00) & 0x1F00)
3644 | (tempbx & 0x00FF));
3645 tempax = (unsigned short) (((tempeax & 0x000000FF) << 8)
3646 | (tempax & 0x00FF));
3647 temp = (tempax & 0xFF00) >> 8;
3648 } else {
3649 temp = (tempax & 0x00FF) >> 8;
3652 xgifb_reg_set(pVBInfo->Part2Port, 0x44, temp);
3653 temp = (tempbx & 0xFF00) >> 8;
3654 xgifb_reg_and_or(pVBInfo->Part2Port, 0x45, ~0x03F, temp);
3655 temp = tempcx & 0x00FF;
3657 if (tempbx & 0x2000)
3658 temp = 0;
3660 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
3661 temp |= 0x18;
3663 xgifb_reg_and_or(pVBInfo->Part2Port, 0x46, ~0x1F, temp);
3664 if (pVBInfo->TVInfo & TVSetPAL) {
3665 tempbx = 0x0382;
3666 tempcx = 0x007e;
3667 } else {
3668 tempbx = 0x0369;
3669 tempcx = 0x0061;
3672 temp = tempbx & 0x00FF;
3673 xgifb_reg_set(pVBInfo->Part2Port, 0x4b, temp);
3674 temp = tempcx & 0x00FF;
3675 xgifb_reg_set(pVBInfo->Part2Port, 0x4c, temp);
3677 temp = ((tempcx & 0xFF00) >> 8) & 0x03;
3678 temp = temp << 2;
3679 temp |= ((tempbx & 0xFF00) >> 8) & 0x03;
3681 if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
3682 temp |= 0x10;
3684 if (pVBInfo->TVInfo & TVSetYPbPr525p)
3685 temp |= 0x20;
3687 if (pVBInfo->TVInfo & TVSetYPbPr750p)
3688 temp |= 0x60;
3691 xgifb_reg_set(pVBInfo->Part2Port, 0x4d, temp);
3692 temp = xgifb_reg_get(pVBInfo->Part2Port, 0x43); /* 301b change */
3693 xgifb_reg_set(pVBInfo->Part2Port, 0x43, (unsigned short) (temp - 3));
3695 if (!(pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p))) {
3696 if (pVBInfo->TVInfo & NTSC1024x768) {
3697 TimingPoint = XGI_NTSC1024AdjTime;
3698 for (i = 0x1c, j = 0; i <= 0x30; i++, j++) {
3699 xgifb_reg_set(pVBInfo->Part2Port, i,
3700 TimingPoint[j]);
3702 xgifb_reg_set(pVBInfo->Part2Port, 0x43, 0x72);
3706 /* Modify for 301C PALM Support */
3707 if (pVBInfo->VBType & VB_XGI301C) {
3708 if (pVBInfo->TVInfo & TVSetPALM)
3709 xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x08,
3710 0x08); /* PALM Mode */
3713 if (pVBInfo->TVInfo & TVSetPALM) {
3714 tempax = xgifb_reg_get(pVBInfo->Part2Port, 0x01);
3715 tempax--;
3716 xgifb_reg_and(pVBInfo->Part2Port, 0x01, tempax);
3718 xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xEF);
3721 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
3722 if (!(pVBInfo->VBInfo & SetInSlaveMode))
3723 xgifb_reg_set(pVBInfo->Part2Port, 0x0B, 0x00);
3727 static void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
3728 struct xgi_hw_device_info *HwDeviceExtension,
3729 unsigned short RefreshRateTableIndex,
3730 struct vb_device_info *pVBInfo)
3732 unsigned short pushbx, tempax, tempbx, tempcx, temp, tempah,
3733 tempbh, tempch;
3735 struct XGI_LCDDesStruct const *LCDBDesPtr = NULL;
3737 /* si+Ext_ResInfo */
3738 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
3739 return;
3741 tempbx = pVBInfo->HDE; /* RHACTE=HDE-1 */
3743 if (XGI_IsLCDDualLink(pVBInfo))
3744 tempbx = tempbx >> 1;
3746 tempbx -= 1;
3747 temp = tempbx & 0x00FF;
3748 xgifb_reg_set(pVBInfo->Part2Port, 0x2C, temp);
3749 temp = (tempbx & 0xFF00) >> 8;
3750 temp = temp << 4;
3751 xgifb_reg_and_or(pVBInfo->Part2Port, 0x2B, 0x0F, temp);
3752 temp = 0x01;
3754 xgifb_reg_set(pVBInfo->Part2Port, 0x0B, temp);
3755 tempbx = pVBInfo->VDE; /* RTVACTEO=(VDE-1)&0xFF */
3756 tempbx--;
3757 temp = tempbx & 0x00FF;
3758 xgifb_reg_set(pVBInfo->Part2Port, 0x03, temp);
3759 temp = ((tempbx & 0xFF00) >> 8) & 0x07;
3760 xgifb_reg_and_or(pVBInfo->Part2Port, 0x0C, ~0x07, temp);
3762 tempcx = pVBInfo->VT - 1;
3763 temp = tempcx & 0x00FF; /* RVTVT=VT-1 */
3764 xgifb_reg_set(pVBInfo->Part2Port, 0x19, temp);
3765 temp = (tempcx & 0xFF00) >> 8;
3766 temp = temp << 5;
3767 xgifb_reg_set(pVBInfo->Part2Port, 0x1A, temp);
3768 xgifb_reg_and_or(pVBInfo->Part2Port, 0x09, 0xF0, 0x00);
3769 xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xF0, 0x00);
3770 xgifb_reg_and_or(pVBInfo->Part2Port, 0x17, 0xFB, 0x00);
3771 xgifb_reg_and_or(pVBInfo->Part2Port, 0x18, 0xDF, 0x00);
3773 /* Customized LCDB Does not add */
3774 if ((pVBInfo->VBType & VB_SIS301LV) || (pVBInfo->VBType & VB_SIS302LV))
3775 LCDBDesPtr = XGI_GetLcdPtr(xgifb_lcddldes, ModeNo, ModeIdIndex,
3776 RefreshRateTableIndex, pVBInfo);
3777 else
3778 LCDBDesPtr = XGI_GetLcdPtr(XGI_LCDDesDataTable, ModeNo,
3779 ModeIdIndex, RefreshRateTableIndex,
3780 pVBInfo);
3782 tempah = pVBInfo->LCDResInfo;
3783 tempah &= PanelResInfo;
3785 if ((tempah == Panel_1024x768) || (tempah == Panel_1024x768x75)) {
3786 tempbx = 1024;
3787 tempcx = 768;
3788 } else if ((tempah == Panel_1280x1024) ||
3789 (tempah == Panel_1280x1024x75)) {
3790 tempbx = 1280;
3791 tempcx = 1024;
3792 } else if (tempah == Panel_1400x1050) {
3793 tempbx = 1400;
3794 tempcx = 1050;
3795 } else {
3796 tempbx = 1600;
3797 tempcx = 1200;
3800 if (pVBInfo->LCDInfo & EnableScalingLCD) {
3801 tempbx = pVBInfo->HDE;
3802 tempcx = pVBInfo->VDE;
3805 pushbx = tempbx;
3806 tempax = pVBInfo->VT;
3807 pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES;
3808 pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS;
3809 pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES;
3810 pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS;
3811 tempbx = pVBInfo->LCDVDES;
3812 tempcx += tempbx;
3814 if (tempcx >= tempax)
3815 tempcx -= tempax; /* lcdvdes */
3817 temp = tempbx & 0x00FF; /* RVEQ1EQ=lcdvdes */
3818 xgifb_reg_set(pVBInfo->Part2Port, 0x05, temp);
3819 temp = tempcx & 0x00FF;
3820 xgifb_reg_set(pVBInfo->Part2Port, 0x06, temp);
3821 tempch = ((tempcx & 0xFF00) >> 8) & 0x07;
3822 tempbh = ((tempbx & 0xFF00) >> 8) & 0x07;
3823 tempah = tempch;
3824 tempah = tempah << 3;
3825 tempah |= tempbh;
3826 xgifb_reg_set(pVBInfo->Part2Port, 0x02, tempah);
3828 /* getlcdsync() */
3829 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
3830 tempcx = tempbx;
3831 tempax = pVBInfo->VT;
3832 tempbx = pVBInfo->LCDVRS;
3834 tempcx += tempbx;
3835 if (tempcx >= tempax)
3836 tempcx -= tempax;
3838 temp = tempbx & 0x00FF; /* RTVACTEE=lcdvrs */
3839 xgifb_reg_set(pVBInfo->Part2Port, 0x04, temp);
3840 temp = (tempbx & 0xFF00) >> 8;
3841 temp = temp << 4;
3842 temp |= (tempcx & 0x000F);
3843 xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp);
3844 tempcx = pushbx;
3845 tempax = pVBInfo->HT;
3846 tempbx = pVBInfo->LCDHDES;
3847 tempbx &= 0x0FFF;
3849 if (XGI_IsLCDDualLink(pVBInfo)) {
3850 tempax = tempax >> 1;
3851 tempbx = tempbx >> 1;
3852 tempcx = tempcx >> 1;
3855 if (pVBInfo->VBType & VB_SIS302LV)
3856 tempbx += 1;
3858 if (pVBInfo->VBType & VB_XGI301C) /* tap4 */
3859 tempbx += 1;
3861 tempcx += tempbx;
3863 if (tempcx >= tempax)
3864 tempcx -= tempax;
3866 temp = tempbx & 0x00FF;
3867 xgifb_reg_set(pVBInfo->Part2Port, 0x1F, temp); /* RHBLKE=lcdhdes */
3868 temp = ((tempbx & 0xFF00) >> 8) << 4;
3869 xgifb_reg_set(pVBInfo->Part2Port, 0x20, temp);
3870 temp = tempcx & 0x00FF;
3871 xgifb_reg_set(pVBInfo->Part2Port, 0x23, temp); /* RHEQPLE=lcdhdee */
3872 temp = (tempcx & 0xFF00) >> 8;
3873 xgifb_reg_set(pVBInfo->Part2Port, 0x25, temp);
3875 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
3876 tempcx = tempax;
3877 tempax = pVBInfo->HT;
3878 tempbx = pVBInfo->LCDHRS;
3879 if (XGI_IsLCDDualLink(pVBInfo)) {
3880 tempax = tempax >> 1;
3881 tempbx = tempbx >> 1;
3882 tempcx = tempcx >> 1;
3885 if (pVBInfo->VBType & VB_SIS302LV)
3886 tempbx += 1;
3888 tempcx += tempbx;
3890 if (tempcx >= tempax)
3891 tempcx -= tempax;
3893 temp = tempbx & 0x00FF; /* RHBURSTS=lcdhrs */
3894 xgifb_reg_set(pVBInfo->Part2Port, 0x1C, temp);
3896 temp = (tempbx & 0xFF00) >> 8;
3897 temp = temp << 4;
3898 xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F0, temp);
3899 temp = tempcx & 0x00FF; /* RHSYEXP2S=lcdhre */
3900 xgifb_reg_set(pVBInfo->Part2Port, 0x21, temp);
3902 if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
3903 if (pVBInfo->VGAVDE == 525) {
3904 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B
3905 | VB_SIS301LV | VB_SIS302LV
3906 | VB_XGI301C)) {
3907 temp = 0xC6;
3908 } else
3909 temp = 0xC4;
3911 xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp);
3912 xgifb_reg_set(pVBInfo->Part2Port, 0x30, 0xB3);
3915 if (pVBInfo->VGAVDE == 420) {
3916 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B
3917 | VB_SIS301LV | VB_SIS302LV
3918 | VB_XGI301C)) {
3919 temp = 0x4F;
3920 } else
3921 temp = 0x4E;
3922 xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp);
3927 /* --------------------------------------------------------------------- */
3928 /* Function : XGI_GetTap4Ptr */
3929 /* Input : */
3930 /* Output : di -> Tap4 Reg. Setting Pointer */
3931 /* Description : */
3932 /* --------------------------------------------------------------------- */
3933 static struct XGI301C_Tap4TimingStruct const
3934 *XGI_GetTap4Ptr(unsigned short tempcx, struct vb_device_info *pVBInfo)
3936 unsigned short tempax, tempbx, i;
3937 struct XGI301C_Tap4TimingStruct const *Tap4TimingPtr;
3939 if (tempcx == 0) {
3940 tempax = pVBInfo->VGAHDE;
3941 tempbx = pVBInfo->HDE;
3942 } else {
3943 tempax = pVBInfo->VGAVDE;
3944 tempbx = pVBInfo->VDE;
3947 if (tempax <= tempbx)
3948 return &xgifb_tap4_timing[0];
3949 else
3950 Tap4TimingPtr = xgifb_ntsc_525_tap4_timing; /* NTSC */
3952 if (pVBInfo->TVInfo & TVSetPAL)
3953 Tap4TimingPtr = PALTap4Timing;
3955 if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
3956 if ((pVBInfo->TVInfo & TVSetYPbPr525i) ||
3957 (pVBInfo->TVInfo & TVSetYPbPr525p))
3958 Tap4TimingPtr = xgifb_ntsc_525_tap4_timing;
3959 if (pVBInfo->TVInfo & TVSetYPbPr750p)
3960 Tap4TimingPtr = YPbPr750pTap4Timing;
3963 if (pVBInfo->VBInfo & SetCRT2ToHiVision)
3964 Tap4TimingPtr = xgifb_tap4_timing;
3966 i = 0;
3967 while (Tap4TimingPtr[i].DE != 0xFFFF) {
3968 if (Tap4TimingPtr[i].DE == tempax)
3969 break;
3970 i++;
3972 return &Tap4TimingPtr[i];
3975 static void XGI_SetTap4Regs(struct vb_device_info *pVBInfo)
3977 unsigned short i, j;
3978 struct XGI301C_Tap4TimingStruct const *Tap4TimingPtr;
3980 if (!(pVBInfo->VBType & VB_XGI301C))
3981 return;
3983 Tap4TimingPtr = XGI_GetTap4Ptr(0, pVBInfo); /* Set Horizontal Scaling */
3984 for (i = 0x80, j = 0; i <= 0xBF; i++, j++)
3985 xgifb_reg_set(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]);
3987 if ((pVBInfo->VBInfo & SetCRT2ToTV) &&
3988 (!(pVBInfo->VBInfo & SetCRT2ToHiVision))) {
3989 /* Set Vertical Scaling */
3990 Tap4TimingPtr = XGI_GetTap4Ptr(1, pVBInfo);
3991 for (i = 0xC0, j = 0; i < 0xFF; i++, j++)
3992 xgifb_reg_set(pVBInfo->Part2Port,
3994 Tap4TimingPtr->Reg[j]);
3997 if ((pVBInfo->VBInfo & SetCRT2ToTV) &&
3998 (!(pVBInfo->VBInfo & SetCRT2ToHiVision)))
3999 /* Enable V.Scaling */
4000 xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x04);
4001 else
4002 /* Enable H.Scaling */
4003 xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x10);
4006 static void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex,
4007 struct vb_device_info *pVBInfo)
4009 unsigned short i;
4010 unsigned char const *tempdi;
4011 unsigned short modeflag;
4013 /* si+Ext_ResInfo */
4014 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4016 xgifb_reg_set(pVBInfo->Part3Port, 0x00, 0x00);
4017 if (pVBInfo->TVInfo & TVSetPAL) {
4018 xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA);
4019 xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8);
4020 } else {
4021 xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xF5);
4022 xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xB7);
4025 if (!(pVBInfo->VBInfo & SetCRT2ToTV))
4026 return;
4028 if (pVBInfo->TVInfo & TVSetPALM) {
4029 xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA);
4030 xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8);
4031 xgifb_reg_set(pVBInfo->Part3Port, 0x3D, 0xA8);
4034 if ((pVBInfo->VBInfo & SetCRT2ToHiVision) || (pVBInfo->VBInfo
4035 & SetCRT2ToYPbPr525750)) {
4036 if (pVBInfo->TVInfo & TVSetYPbPr525i)
4037 return;
4039 tempdi = XGI330_HiTVGroup3Data;
4040 if (pVBInfo->SetFlag & TVSimuMode) {
4041 tempdi = XGI330_HiTVGroup3Simu;
4042 if (!(modeflag & Charx8Dot))
4043 tempdi = XGI330_HiTVGroup3Text;
4046 if (pVBInfo->TVInfo & TVSetYPbPr525p)
4047 tempdi = XGI330_Ren525pGroup3;
4049 if (pVBInfo->TVInfo & TVSetYPbPr750p)
4050 tempdi = XGI330_Ren750pGroup3;
4052 for (i = 0; i <= 0x3E; i++)
4053 xgifb_reg_set(pVBInfo->Part3Port, i, tempdi[i]);
4055 if (pVBInfo->VBType & VB_XGI301C) { /* Marcovision */
4056 if (pVBInfo->TVInfo & TVSetYPbPr525p)
4057 xgifb_reg_set(pVBInfo->Part3Port, 0x28, 0x3f);
4062 static void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex,
4063 unsigned short RefreshRateTableIndex,
4064 struct xgi_hw_device_info *HwDeviceExtension,
4065 struct vb_device_info *pVBInfo)
4067 unsigned short tempax, tempcx, tempbx, modeflag, temp, temp2;
4069 unsigned long tempebx, tempeax, templong;
4071 /* si+Ext_ResInfo */
4072 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4073 temp = pVBInfo->RVBHCFACT;
4074 xgifb_reg_set(pVBInfo->Part4Port, 0x13, temp);
4076 tempbx = pVBInfo->RVBHCMAX;
4077 temp = tempbx & 0x00FF;
4078 xgifb_reg_set(pVBInfo->Part4Port, 0x14, temp);
4079 temp2 = ((tempbx & 0xFF00) >> 8) << 7;
4080 tempcx = pVBInfo->VGAHT - 1;
4081 temp = tempcx & 0x00FF;
4082 xgifb_reg_set(pVBInfo->Part4Port, 0x16, temp);
4084 temp = ((tempcx & 0xFF00) >> 8) << 3;
4085 temp2 |= temp;
4087 tempcx = pVBInfo->VGAVT - 1;
4088 if (!(pVBInfo->VBInfo & SetCRT2ToTV))
4089 tempcx -= 5;
4091 temp = tempcx & 0x00FF;
4092 xgifb_reg_set(pVBInfo->Part4Port, 0x17, temp);
4093 temp = temp2 | ((tempcx & 0xFF00) >> 8);
4094 xgifb_reg_set(pVBInfo->Part4Port, 0x15, temp);
4095 xgifb_reg_or(pVBInfo->Part4Port, 0x0D, 0x08);
4096 tempcx = pVBInfo->VBInfo;
4097 tempbx = pVBInfo->VGAHDE;
4099 if (modeflag & HalfDCLK)
4100 tempbx = tempbx >> 1;
4102 if (XGI_IsLCDDualLink(pVBInfo))
4103 tempbx = tempbx >> 1;
4105 if (tempcx & SetCRT2ToHiVision) {
4106 temp = 0;
4107 if (tempbx <= 1024)
4108 temp = 0xA0;
4109 if (tempbx == 1280)
4110 temp = 0xC0;
4111 } else if (tempcx & SetCRT2ToTV) {
4112 temp = 0xA0;
4113 if (tempbx <= 800)
4114 temp = 0x80;
4115 } else {
4116 temp = 0x80;
4117 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
4118 temp = 0;
4119 if (tempbx > 800)
4120 temp = 0x60;
4124 if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p)) {
4125 temp = 0x00;
4126 if (pVBInfo->VGAHDE == 1280)
4127 temp = 0x40;
4128 if (pVBInfo->VGAHDE == 1024)
4129 temp = 0x20;
4131 xgifb_reg_and_or(pVBInfo->Part4Port, 0x0E, ~0xEF, temp);
4133 tempebx = pVBInfo->VDE;
4135 tempcx = pVBInfo->RVBHRS;
4136 temp = tempcx & 0x00FF;
4137 xgifb_reg_set(pVBInfo->Part4Port, 0x18, temp);
4139 tempeax = pVBInfo->VGAVDE;
4140 tempcx |= 0x04000;
4142 if (tempeax <= tempebx) {
4143 tempcx = (tempcx & (~0x4000));
4144 tempeax = pVBInfo->VGAVDE;
4145 } else {
4146 tempeax -= tempebx;
4149 templong = (tempeax * 256 * 1024) % tempebx;
4150 tempeax = (tempeax * 256 * 1024) / tempebx;
4151 tempebx = tempeax;
4153 if (templong != 0)
4154 tempebx++;
4156 temp = (unsigned short) (tempebx & 0x000000FF);
4157 xgifb_reg_set(pVBInfo->Part4Port, 0x1B, temp);
4159 temp = (unsigned short) ((tempebx & 0x0000FF00) >> 8);
4160 xgifb_reg_set(pVBInfo->Part4Port, 0x1A, temp);
4161 tempbx = (unsigned short) (tempebx >> 16);
4162 temp = tempbx & 0x00FF;
4163 temp = temp << 4;
4164 temp |= ((tempcx & 0xFF00) >> 8);
4165 xgifb_reg_set(pVBInfo->Part4Port, 0x19, temp);
4167 /* 301b */
4168 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
4169 | VB_SIS302LV | VB_XGI301C)) {
4170 temp = 0x0028;
4171 xgifb_reg_set(pVBInfo->Part4Port, 0x1C, temp);
4172 tempax = pVBInfo->VGAHDE;
4173 if (modeflag & HalfDCLK)
4174 tempax = tempax >> 1;
4176 if (XGI_IsLCDDualLink(pVBInfo))
4177 tempax = tempax >> 1;
4179 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
4180 if (tempax > 800)
4181 tempax -= 800;
4182 } else if (pVBInfo->VGAHDE > 800) {
4183 if (pVBInfo->VGAHDE == 1024)
4184 tempax = (tempax * 25 / 32) - 1;
4185 else
4186 tempax = (tempax * 20 / 32) - 1;
4188 tempax -= 1;
4190 temp = (tempax & 0xFF00) >> 8;
4191 temp = ((temp & 0x0003) << 4);
4192 xgifb_reg_set(pVBInfo->Part4Port, 0x1E, temp);
4193 temp = (tempax & 0x00FF);
4194 xgifb_reg_set(pVBInfo->Part4Port, 0x1D, temp);
4196 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVision)) {
4197 if (pVBInfo->VGAHDE > 800)
4198 xgifb_reg_or(pVBInfo->Part4Port, 0x1E, 0x08);
4201 temp = 0x0036;
4203 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4204 if (!(pVBInfo->TVInfo & (NTSC1024x768
4205 | TVSetYPbPr525p | TVSetYPbPr750p
4206 | TVSetHiVision))) {
4207 temp |= 0x0001;
4208 if ((pVBInfo->VBInfo & SetInSlaveMode)
4209 && (!(pVBInfo->TVInfo
4210 & TVSimuMode)))
4211 temp &= (~0x0001);
4215 xgifb_reg_and_or(pVBInfo->Part4Port, 0x1F, 0x00C0, temp);
4216 tempbx = pVBInfo->HT;
4217 if (XGI_IsLCDDualLink(pVBInfo))
4218 tempbx = tempbx >> 1;
4219 tempbx = (tempbx >> 1) - 2;
4220 temp = ((tempbx & 0x0700) >> 8) << 3;
4221 xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, 0x00C0, temp);
4222 temp = tempbx & 0x00FF;
4223 xgifb_reg_set(pVBInfo->Part4Port, 0x22, temp);
4225 /* end 301b */
4227 XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
4230 static void XGINew_EnableCRT2(struct vb_device_info *pVBInfo)
4232 xgifb_reg_and_or(pVBInfo->P3c4, 0x1E, 0xFF, 0x20);
4235 static void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex,
4236 struct vb_device_info *pVBInfo)
4238 if (pVBInfo->ModeType == ModeVGA) {
4239 if (!(pVBInfo->VBInfo & (SetInSlaveMode | LoadDACFlag
4240 | DisableCRT2Display))) {
4241 XGINew_EnableCRT2(pVBInfo);
4246 static void XGI_DisableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension,
4247 struct vb_device_info *pVBInfo)
4250 xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x00);
4253 static unsigned char XGI_XG21CheckLVDSMode(struct xgifb_video_info *xgifb_info,
4254 unsigned short ModeNo, unsigned short ModeIdIndex,
4255 struct vb_device_info *pVBInfo)
4257 unsigned short xres, yres, colordepth, modeflag, resindex;
4259 resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO;
4260 xres = XGI330_ModeResInfo[resindex].HTotal; /* xres->ax */
4261 yres = XGI330_ModeResInfo[resindex].VTotal; /* yres->bx */
4262 /* si+St_ModeFlag */
4263 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4265 if (!(modeflag & Charx8Dot)) {
4266 xres /= 9;
4267 xres *= 8;
4270 if ((ModeNo > 0x13) && (modeflag & HalfDCLK))
4271 xres *= 2;
4273 if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
4274 yres *= 2;
4276 if (xres > xgifb_info->lvds_data.LVDSHDE)
4277 return 0;
4279 if (yres > xgifb_info->lvds_data.LVDSVDE)
4280 return 0;
4282 if (xres != xgifb_info->lvds_data.LVDSHDE ||
4283 yres != xgifb_info->lvds_data.LVDSVDE) {
4284 colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo);
4285 if (colordepth > 2)
4286 return 0;
4288 return 1;
4291 static void xgifb_set_lvds(struct xgifb_video_info *xgifb_info,
4292 int chip_id,
4293 unsigned short ModeNo,
4294 unsigned short ModeIdIndex,
4295 struct vb_device_info *pVBInfo)
4297 unsigned char temp, Miscdata;
4298 unsigned short xres, yres, modeflag, resindex;
4299 unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE;
4300 unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE;
4301 unsigned short value;
4303 temp = (unsigned char) ((xgifb_info->lvds_data.LVDS_Capability &
4304 (LCDPolarity << 8)) >> 8);
4305 temp &= LCDPolarity;
4306 Miscdata = inb(pVBInfo->P3cc);
4308 outb((Miscdata & 0x3F) | temp, pVBInfo->P3c2);
4310 temp = xgifb_info->lvds_data.LVDS_Capability & LCDPolarity;
4311 /* SR35[7] FP VSync polarity */
4312 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80);
4313 /* SR30[5] FP HSync polarity */
4314 xgifb_reg_and_or(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1);
4316 if (chip_id == XG27)
4317 XGI_SetXG27FPBits(pVBInfo);
4318 else
4319 XGI_SetXG21FPBits(pVBInfo);
4321 resindex = XGI330_EModeIDTable[ModeIdIndex].Ext_RESINFO;
4322 xres = XGI330_ModeResInfo[resindex].HTotal; /* xres->ax */
4323 yres = XGI330_ModeResInfo[resindex].VTotal; /* yres->bx */
4324 /* si+St_ModeFlag */
4325 modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4327 if (!(modeflag & Charx8Dot))
4328 xres = xres * 8 / 9;
4330 LVDSHT = xgifb_info->lvds_data.LVDSHT;
4332 LVDSHBS = xres + (xgifb_info->lvds_data.LVDSHDE - xres) / 2;
4334 if (LVDSHBS > LVDSHT)
4335 LVDSHBS -= LVDSHT;
4337 LVDSHRS = LVDSHBS + xgifb_info->lvds_data.LVDSHFP;
4338 if (LVDSHRS > LVDSHT)
4339 LVDSHRS -= LVDSHT;
4341 LVDSHRE = LVDSHRS + xgifb_info->lvds_data.LVDSHSYNC;
4342 if (LVDSHRE > LVDSHT)
4343 LVDSHRE -= LVDSHT;
4345 LVDSHBE = LVDSHBS + LVDSHT - xgifb_info->lvds_data.LVDSHDE;
4347 LVDSVT = xgifb_info->lvds_data.LVDSVT;
4349 LVDSVBS = yres + (xgifb_info->lvds_data.LVDSVDE - yres) / 2;
4350 if (modeflag & DoubleScanMode)
4351 LVDSVBS += yres / 2;
4353 if (LVDSVBS > LVDSVT)
4354 LVDSVBS -= LVDSVT;
4356 LVDSVRS = LVDSVBS + xgifb_info->lvds_data.LVDSVFP;
4357 if (LVDSVRS > LVDSVT)
4358 LVDSVRS -= LVDSVT;
4360 LVDSVRE = LVDSVRS + xgifb_info->lvds_data.LVDSVSYNC;
4361 if (LVDSVRE > LVDSVT)
4362 LVDSVRE -= LVDSVT;
4364 LVDSVBE = LVDSVBS + LVDSVT - xgifb_info->lvds_data.LVDSVDE;
4366 temp = xgifb_reg_get(pVBInfo->P3d4, 0x11);
4367 xgifb_reg_set(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */
4369 if (!(modeflag & Charx8Dot))
4370 xgifb_reg_or(pVBInfo->P3c4, 0x1, 0x1);
4372 /* HT SR0B[1:0] CR00 */
4373 value = (LVDSHT >> 3) - 5;
4374 xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8);
4375 xgifb_reg_set(pVBInfo->P3d4, 0x0, (value & 0xFF));
4377 /* HBS SR0B[5:4] CR02 */
4378 value = (LVDSHBS >> 3) - 1;
4379 xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4);
4380 xgifb_reg_set(pVBInfo->P3d4, 0x2, (value & 0xFF));
4382 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
4383 value = (LVDSHBE >> 3) - 1;
4384 xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6);
4385 xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2);
4386 xgifb_reg_and_or(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F);
4388 /* HRS SR0B[7:6] CR04 */
4389 value = (LVDSHRS >> 3) + 2;
4390 xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2);
4391 xgifb_reg_set(pVBInfo->P3d4, 0x4, (value & 0xFF));
4393 /* Panel HRS SR2F[1:0] SR2E[7:0] */
4394 value--;
4395 xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8);
4396 xgifb_reg_set(pVBInfo->P3c4, 0x2E, (value & 0xFF));
4398 /* HRE SR0C[2] CR05[4:0] */
4399 value = (LVDSHRE >> 3) + 2;
4400 xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3);
4401 xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F);
4403 /* Panel HRE SR2F[7:2] */
4404 value--;
4405 xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2);
4407 /* VT SR0A[0] CR07[5][0] CR06 */
4408 value = LVDSVT - 2;
4409 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10);
4410 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4);
4411 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8);
4412 xgifb_reg_set(pVBInfo->P3d4, 0x06, (value & 0xFF));
4414 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
4415 value = LVDSVBS - 1;
4416 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8);
4417 xgifb_reg_and_or(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4);
4418 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5);
4419 xgifb_reg_set(pVBInfo->P3d4, 0x15, (value & 0xFF));
4421 /* VBE SR0A[4] CR16 */
4422 value = LVDSVBE - 1;
4423 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4);
4424 xgifb_reg_set(pVBInfo->P3d4, 0x16, (value & 0xFF));
4426 /* VRS SR0A[3] CR7[7][2] CR10 */
4427 value = LVDSVRS - 1;
4428 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7);
4429 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2);
4430 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6);
4431 xgifb_reg_set(pVBInfo->P3d4, 0x10, (value & 0xFF));
4433 if (chip_id == XG27) {
4434 /* Panel VRS SR35[2:0] SR34[7:0] */
4435 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07,
4436 (value & 0x700) >> 8);
4437 xgifb_reg_set(pVBInfo->P3c4, 0x34, value & 0xFF);
4438 } else {
4439 /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */
4440 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0x03,
4441 (value & 0x600) >> 9);
4442 xgifb_reg_set(pVBInfo->P3c4, 0x34, (value >> 1) & 0xFF);
4443 xgifb_reg_and_or(pVBInfo->P3d4, 0x33, ~0x01, value & 0x01);
4446 /* VRE SR0A[5] CR11[3:0] */
4447 value = LVDSVRE - 1;
4448 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1);
4449 xgifb_reg_and_or(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F);
4451 /* Panel VRE SR3F[7:2] */
4452 if (chip_id == XG27)
4453 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC,
4454 (value << 2) & 0xFC);
4455 else
4456 /* SR3F[7] has to be 0, h/w bug */
4457 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC,
4458 (value << 2) & 0x7C);
4460 for (temp = 0, value = 0; temp < 3; temp++) {
4462 xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, value);
4463 xgifb_reg_set(pVBInfo->P3c4,
4464 0x2B, xgifb_info->lvds_data.VCLKData1);
4465 xgifb_reg_set(pVBInfo->P3c4,
4466 0x2C, xgifb_info->lvds_data.VCLKData2);
4467 value += 0x10;
4470 if (!(modeflag & Charx8Dot)) {
4471 inb(pVBInfo->P3da); /* reset 3da */
4472 outb(0x13, pVBInfo->P3c0); /* set index */
4473 /* set data, panning = 0, shift left 1 dot*/
4474 outb(0x00, pVBInfo->P3c0);
4476 inb(pVBInfo->P3da); /* Enable Attribute */
4477 outb(0x20, pVBInfo->P3c0);
4479 inb(pVBInfo->P3da); /* reset 3da */
4484 /* --------------------------------------------------------------------- */
4485 /* Function : XGI_IsLCDON */
4486 /* Input : */
4487 /* Output : 0 : Skip PSC Control */
4488 /* 1: Disable PSC */
4489 /* Description : */
4490 /* --------------------------------------------------------------------- */
4491 static unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo)
4493 unsigned short tempax;
4495 tempax = pVBInfo->VBInfo;
4496 if (tempax & SetCRT2ToDualEdge)
4497 return 0;
4498 else if (tempax & (DisableCRT2Display | SwitchCRT2 | SetSimuScanMode))
4499 return 1;
4501 return 0;
4504 static void XGI_DisableBridge(struct xgifb_video_info *xgifb_info,
4505 struct xgi_hw_device_info *HwDeviceExtension,
4506 struct vb_device_info *pVBInfo)
4508 unsigned short tempah = 0;
4510 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
4511 | VB_SIS302LV | VB_XGI301C)) {
4512 tempah = 0x3F;
4513 if (!(pVBInfo->VBInfo &
4514 (DisableCRT2Display | SetSimuScanMode))) {
4515 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
4516 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
4517 tempah = 0x7F; /* Disable Channel A */
4521 /* disable part4_1f */
4522 xgifb_reg_and(pVBInfo->Part4Port, 0x1F, tempah);
4524 if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) {
4525 if (((pVBInfo->VBInfo &
4526 (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) ||
4527 (XGI_IsLCDON(pVBInfo)))
4528 /* LVDS Driver power down */
4529 xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x80);
4532 if (pVBInfo->VBInfo & (DisableCRT2Display | XGI_SetCRT2ToLCDA |
4533 SetSimuScanMode))
4534 XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo);
4536 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)
4537 /* Power down */
4538 xgifb_reg_and(pVBInfo->Part1Port, 0x1e, 0xdf);
4540 /* disable TV as primary VGA swap */
4541 xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xdf);
4543 if ((pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToDualEdge)))
4544 xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xdf);
4546 if ((pVBInfo->VBInfo &
4547 (DisableCRT2Display | SetSimuScanMode)) ||
4548 ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) &&
4549 (pVBInfo->VBInfo &
4550 (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV))))
4551 xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80);
4553 if ((pVBInfo->VBInfo &
4554 (DisableCRT2Display | SetSimuScanMode)) ||
4555 (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) ||
4556 (pVBInfo->VBInfo &
4557 (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV))) {
4558 /* save Part1 index 0 */
4559 tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00);
4560 /* BTDAC = 1, avoid VB reset */
4561 xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x10);
4562 /* disable CRT2 */
4563 xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF);
4564 /* restore Part1 index 0 */
4565 xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah);
4567 } else { /* {301} */
4568 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) {
4569 xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80);
4570 /* Disable CRT2 */
4571 xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF);
4572 /* Disable TV asPrimary VGA swap */
4573 xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xDF);
4576 if (pVBInfo->VBInfo & (DisableCRT2Display | XGI_SetCRT2ToLCDA
4577 | SetSimuScanMode))
4578 XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo);
4582 /* --------------------------------------------------------------------- */
4583 /* Function : XGI_GetTVPtrIndex */
4584 /* Input : */
4585 /* Output : */
4586 /* Description : bx 0 : ExtNTSC */
4587 /* 1 : StNTSC */
4588 /* 2 : ExtPAL */
4589 /* 3 : StPAL */
4590 /* 4 : ExtHiTV */
4591 /* 5 : StHiTV */
4592 /* 6 : Ext525i */
4593 /* 7 : St525i */
4594 /* 8 : Ext525p */
4595 /* 9 : St525p */
4596 /* A : Ext750p */
4597 /* B : St750p */
4598 /* --------------------------------------------------------------------- */
4599 static unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo)
4601 unsigned short tempbx = 0;
4603 if (pVBInfo->TVInfo & TVSetPAL)
4604 tempbx = 2;
4605 if (pVBInfo->TVInfo & TVSetHiVision)
4606 tempbx = 4;
4607 if (pVBInfo->TVInfo & TVSetYPbPr525i)
4608 tempbx = 6;
4609 if (pVBInfo->TVInfo & TVSetYPbPr525p)
4610 tempbx = 8;
4611 if (pVBInfo->TVInfo & TVSetYPbPr750p)
4612 tempbx = 10;
4613 if (pVBInfo->TVInfo & TVSimuMode)
4614 tempbx++;
4616 return tempbx;
4619 /* --------------------------------------------------------------------- */
4620 /* Function : XGI_GetTVPtrIndex2 */
4621 /* Input : */
4622 /* Output : bx 0 : NTSC */
4623 /* 1 : PAL */
4624 /* 2 : PALM */
4625 /* 3 : PALN */
4626 /* 4 : NTSC1024x768 */
4627 /* 5 : PAL-M 1024x768 */
4628 /* 6-7: reserved */
4629 /* cl 0 : YFilter1 */
4630 /* 1 : YFilter2 */
4631 /* ch 0 : 301A */
4632 /* 1 : 301B/302B/301LV/302LV */
4633 /* Description : */
4634 /* --------------------------------------------------------------------- */
4635 static void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char *tempcl,
4636 unsigned char *tempch, struct vb_device_info *pVBInfo)
4638 *tempbx = 0;
4639 *tempcl = 0;
4640 *tempch = 0;
4642 if (pVBInfo->TVInfo & TVSetPAL)
4643 *tempbx = 1;
4645 if (pVBInfo->TVInfo & TVSetPALM)
4646 *tempbx = 2;
4648 if (pVBInfo->TVInfo & TVSetPALN)
4649 *tempbx = 3;
4651 if (pVBInfo->TVInfo & NTSC1024x768) {
4652 *tempbx = 4;
4653 if (pVBInfo->TVInfo & TVSetPALM)
4654 *tempbx = 5;
4657 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
4658 | VB_SIS302LV | VB_XGI301C)) {
4659 if ((!(pVBInfo->VBInfo & SetInSlaveMode)) || (pVBInfo->TVInfo
4660 & TVSimuMode)) {
4661 *tempbx += 8;
4662 *tempcl += 1;
4666 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
4667 | VB_SIS302LV | VB_XGI301C))
4668 (*tempch)++;
4671 static void XGI_SetDelayComp(struct vb_device_info *pVBInfo)
4673 unsigned char tempah, tempbl, tempbh;
4675 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
4676 | VB_SIS302LV | VB_XGI301C)) {
4677 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA
4678 | SetCRT2ToTV | SetCRT2ToRAMDAC)) {
4679 tempbh = 0;
4680 tempbl = XGI301TVDelay;
4682 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
4683 tempbl = tempbl >> 4;
4684 if (pVBInfo->VBInfo &
4685 (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
4686 tempbh = XGI301LCDDelay;
4688 if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA))
4689 tempbl = tempbh;
4692 tempbl &= 0x0F;
4693 tempbh &= 0xF0;
4694 tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x2D);
4696 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD
4697 | SetCRT2ToTV)) { /* Channel B */
4698 tempah &= 0xF0;
4699 tempah |= tempbl;
4702 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
4703 /* Channel A */
4704 tempah &= 0x0F;
4705 tempah |= tempbh;
4707 xgifb_reg_set(pVBInfo->Part1Port, 0x2D, tempah);
4712 static void XGI_SetLCDCap_A(unsigned short tempcx,
4713 struct vb_device_info *pVBInfo)
4715 unsigned short temp;
4717 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
4719 if (temp & LCDRGB18Bit) {
4720 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F,
4721 /* Enable Dither */
4722 (unsigned short) (0x20 | (tempcx & 0x00C0)));
4723 xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80);
4724 } else {
4725 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F,
4726 (unsigned short) (0x30 | (tempcx & 0x00C0)));
4727 xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00);
4731 /* --------------------------------------------------------------------- */
4732 /* Function : XGI_SetLCDCap_B */
4733 /* Input : cx -> LCD Capability */
4734 /* Output : */
4735 /* Description : */
4736 /* --------------------------------------------------------------------- */
4737 static void XGI_SetLCDCap_B(unsigned short tempcx,
4738 struct vb_device_info *pVBInfo)
4740 if (tempcx & EnableLCD24bpp) /* 24bits */
4741 xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0,
4742 (unsigned short) (((tempcx & 0x00ff) >> 6)
4743 | 0x0c));
4744 else
4745 xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0,
4746 (unsigned short) (((tempcx & 0x00ff) >> 6)
4747 | 0x18)); /* Enable Dither */
4750 static void XGI_LongWait(struct vb_device_info *pVBInfo)
4752 unsigned short i;
4754 i = xgifb_reg_get(pVBInfo->P3c4, 0x1F);
4756 if (!(i & 0xC0)) {
4757 for (i = 0; i < 0xFFFF; i++) {
4758 if (!(inb(pVBInfo->P3da) & 0x08))
4759 break;
4762 for (i = 0; i < 0xFFFF; i++) {
4763 if ((inb(pVBInfo->P3da) & 0x08))
4764 break;
4769 static void SetSpectrum(struct vb_device_info *pVBInfo)
4771 unsigned short index;
4773 index = XGI_GetLCDCapPtr(pVBInfo);
4775 /* disable down spectrum D[4] */
4776 xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x8F);
4777 XGI_LongWait(pVBInfo);
4778 xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x20); /* reset spectrum */
4779 XGI_LongWait(pVBInfo);
4781 xgifb_reg_set(pVBInfo->Part4Port, 0x31,
4782 pVBInfo->LCDCapList[index].Spectrum_31);
4783 xgifb_reg_set(pVBInfo->Part4Port, 0x32,
4784 pVBInfo->LCDCapList[index].Spectrum_32);
4785 xgifb_reg_set(pVBInfo->Part4Port, 0x33,
4786 pVBInfo->LCDCapList[index].Spectrum_33);
4787 xgifb_reg_set(pVBInfo->Part4Port, 0x34,
4788 pVBInfo->LCDCapList[index].Spectrum_34);
4789 XGI_LongWait(pVBInfo);
4790 xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x40); /* enable spectrum */
4793 static void XGI_SetLCDCap(struct vb_device_info *pVBInfo)
4795 unsigned short tempcx;
4797 tempcx = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(pVBInfo)].LCD_Capability;
4799 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV |
4800 VB_SIS302LV | VB_XGI301C)) {
4801 if (pVBInfo->VBType &
4802 (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) {
4803 /* Set 301LV Capability */
4804 xgifb_reg_set(pVBInfo->Part4Port, 0x24,
4805 (unsigned char) (tempcx & 0x1F));
4807 /* VB Driving */
4808 xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D,
4809 ~((EnableVBCLKDRVLOW | EnablePLLSPLOW) >> 8),
4810 (unsigned short) ((tempcx & (EnableVBCLKDRVLOW
4811 | EnablePLLSPLOW)) >> 8));
4813 if (pVBInfo->VBInfo & SetCRT2ToLCD)
4814 XGI_SetLCDCap_B(tempcx, pVBInfo);
4815 else if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)
4816 XGI_SetLCDCap_A(tempcx, pVBInfo);
4818 if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) {
4819 if (tempcx & EnableSpectrum)
4820 SetSpectrum(pVBInfo);
4822 } else {
4823 /* LVDS,CH7017 */
4824 XGI_SetLCDCap_A(tempcx, pVBInfo);
4828 /* --------------------------------------------------------------------- */
4829 /* Function : XGI_SetAntiFlicker */
4830 /* Input : */
4831 /* Output : */
4832 /* Description : Set TV Customized Param. */
4833 /* --------------------------------------------------------------------- */
4834 static void XGI_SetAntiFlicker(unsigned short ModeNo,
4835 unsigned short ModeIdIndex,
4836 struct vb_device_info *pVBInfo)
4838 unsigned short tempbx;
4840 unsigned char tempah;
4842 if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p))
4843 return;
4845 tempbx = XGI_GetTVPtrIndex(pVBInfo);
4846 tempbx &= 0xFE;
4847 tempah = TVAntiFlickList[tempbx];
4848 tempah = tempah << 4;
4850 xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0x8F, tempah);
4853 static void XGI_SetEdgeEnhance(unsigned short ModeNo,
4854 unsigned short ModeIdIndex,
4855 struct vb_device_info *pVBInfo)
4857 unsigned short tempbx;
4859 unsigned char tempah;
4861 tempbx = XGI_GetTVPtrIndex(pVBInfo);
4862 tempbx &= 0xFE;
4863 tempah = TVEdgeList[tempbx];
4864 tempah = tempah << 5;
4866 xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, tempah);
4869 static void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo)
4871 unsigned short tempbx;
4873 unsigned char tempcl, tempch;
4875 unsigned long tempData;
4877 XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */
4878 tempData = TVPhaseList[tempbx];
4880 xgifb_reg_set(pVBInfo->Part2Port, 0x31, (unsigned short) (tempData
4881 & 0x000000FF));
4882 xgifb_reg_set(pVBInfo->Part2Port, 0x32, (unsigned short) ((tempData
4883 & 0x0000FF00) >> 8));
4884 xgifb_reg_set(pVBInfo->Part2Port, 0x33, (unsigned short) ((tempData
4885 & 0x00FF0000) >> 16));
4886 xgifb_reg_set(pVBInfo->Part2Port, 0x34, (unsigned short) ((tempData
4887 & 0xFF000000) >> 24));
4890 static void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex,
4891 struct vb_device_info *pVBInfo)
4893 unsigned short tempbx, index;
4894 unsigned char const *filterPtr;
4895 unsigned char tempcl, tempch, tempal;
4897 XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */
4899 switch (tempbx) {
4900 case 0x00:
4901 case 0x04:
4902 filterPtr = NTSCYFilter1;
4903 break;
4905 case 0x01:
4906 filterPtr = PALYFilter1;
4907 break;
4909 case 0x02:
4910 case 0x05:
4911 case 0x0D:
4912 case 0x03:
4913 filterPtr = xgifb_palmn_yfilter1;
4914 break;
4916 case 0x08:
4917 case 0x0C:
4918 case 0x0A:
4919 case 0x0B:
4920 case 0x09:
4921 filterPtr = xgifb_yfilter2;
4922 break;
4924 default:
4925 return;
4928 tempal = XGI330_EModeIDTable[ModeIdIndex].VB_ExtTVYFilterIndex;
4929 if (tempcl == 0)
4930 index = tempal * 4;
4931 else
4932 index = tempal * 7;
4934 if ((tempcl == 0) && (tempch == 1)) {
4935 xgifb_reg_set(pVBInfo->Part2Port, 0x35, 0);
4936 xgifb_reg_set(pVBInfo->Part2Port, 0x36, 0);
4937 xgifb_reg_set(pVBInfo->Part2Port, 0x37, 0);
4938 xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]);
4939 } else {
4940 xgifb_reg_set(pVBInfo->Part2Port, 0x35, filterPtr[index++]);
4941 xgifb_reg_set(pVBInfo->Part2Port, 0x36, filterPtr[index++]);
4942 xgifb_reg_set(pVBInfo->Part2Port, 0x37, filterPtr[index++]);
4943 xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]);
4946 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
4947 | VB_SIS302LV | VB_XGI301C)) {
4948 xgifb_reg_set(pVBInfo->Part2Port, 0x48, filterPtr[index++]);
4949 xgifb_reg_set(pVBInfo->Part2Port, 0x49, filterPtr[index++]);
4950 xgifb_reg_set(pVBInfo->Part2Port, 0x4A, filterPtr[index++]);
4954 /* --------------------------------------------------------------------- */
4955 /* Function : XGI_OEM310Setting */
4956 /* Input : */
4957 /* Output : */
4958 /* Description : Customized Param. for 301 */
4959 /* --------------------------------------------------------------------- */
4960 static void XGI_OEM310Setting(unsigned short ModeNo,
4961 unsigned short ModeIdIndex,
4962 struct vb_device_info *pVBInfo)
4964 XGI_SetDelayComp(pVBInfo);
4966 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))
4967 XGI_SetLCDCap(pVBInfo);
4969 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4970 XGI_SetPhaseIncr(pVBInfo);
4971 XGI_SetYFilter(ModeNo, ModeIdIndex, pVBInfo);
4972 XGI_SetAntiFlicker(ModeNo, ModeIdIndex, pVBInfo);
4974 if (pVBInfo->VBType & VB_SIS301)
4975 XGI_SetEdgeEnhance(ModeNo, ModeIdIndex, pVBInfo);
4979 /* --------------------------------------------------------------------- */
4980 /* Function : XGI_SetCRT2ModeRegs */
4981 /* Input : */
4982 /* Output : */
4983 /* Description : Origin code for crt2group */
4984 /* --------------------------------------------------------------------- */
4985 static void XGI_SetCRT2ModeRegs(unsigned short ModeNo,
4986 struct xgi_hw_device_info *HwDeviceExtension,
4987 struct vb_device_info *pVBInfo)
4989 unsigned short tempbl;
4990 short tempcl;
4992 unsigned char tempah;
4994 tempah = 0;
4995 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
4996 tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00);
4997 tempah &= ~0x10; /* BTRAMDAC */
4998 tempah |= 0x40; /* BTRAM */
5000 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV
5001 | SetCRT2ToLCD)) {
5002 tempah = 0x40; /* BTDRAM */
5003 tempcl = pVBInfo->ModeType;
5004 tempcl -= ModeVGA;
5005 if (tempcl >= 0) {
5006 /* BT Color */
5007 tempah = (0x008 >> tempcl);
5008 if (tempah == 0)
5009 tempah = 1;
5010 tempah |= 0x040;
5012 if (pVBInfo->VBInfo & SetInSlaveMode)
5013 tempah ^= 0x50; /* BTDAC */
5017 xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah);
5018 tempah = 0x08;
5019 tempbl = 0xf0;
5021 if (pVBInfo->VBInfo & DisableCRT2Display)
5022 goto reg_and_or;
5024 tempah = 0x00;
5025 tempbl = 0xff;
5027 if (!(pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV |
5028 SetCRT2ToLCD | XGI_SetCRT2ToLCDA)))
5029 goto reg_and_or;
5031 if ((pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) &&
5032 (!(pVBInfo->VBInfo & SetSimuScanMode))) {
5033 tempbl &= 0xf7;
5034 tempah |= 0x01;
5035 goto reg_and_or;
5038 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
5039 tempbl &= 0xf7;
5040 tempah |= 0x01;
5043 if (!(pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD)))
5044 goto reg_and_or;
5046 tempbl &= 0xf8;
5047 tempah = 0x01;
5049 if (!(pVBInfo->VBInfo & SetInSlaveMode))
5050 tempah |= 0x02;
5052 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) {
5053 tempah = tempah ^ 0x05;
5054 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
5055 tempah = tempah ^ 0x01;
5058 if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge))
5059 tempah |= 0x08;
5061 reg_and_or:
5062 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl, tempah);
5064 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD
5065 | XGI_SetCRT2ToLCDA)) {
5066 tempah &= (~0x08);
5067 if ((pVBInfo->ModeType == ModeVGA) && (!(pVBInfo->VBInfo
5068 & SetInSlaveMode))) {
5069 tempah |= 0x010;
5071 tempah |= 0x080;
5073 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5074 tempah |= 0x020;
5075 if (pVBInfo->VBInfo & DriverMode)
5076 tempah = tempah ^ 0x20;
5079 xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D, ~0x0BF, tempah);
5080 tempah = 0;
5082 if (pVBInfo->LCDInfo & SetLCDDualLink)
5083 tempah |= 0x40;
5085 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5086 if (pVBInfo->TVInfo & RPLLDIV2XO)
5087 tempah |= 0x40;
5090 if ((pVBInfo->LCDResInfo == Panel_1280x1024)
5091 || (pVBInfo->LCDResInfo == Panel_1280x1024x75))
5092 tempah |= 0x80;
5094 if (pVBInfo->LCDResInfo == Panel_1280x960)
5095 tempah |= 0x80;
5097 xgifb_reg_set(pVBInfo->Part4Port, 0x0C, tempah);
5100 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
5101 | VB_SIS302LV | VB_XGI301C)) {
5102 tempah = 0;
5103 tempbl = 0xfb;
5105 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
5106 tempbl = 0xff;
5107 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)
5108 tempah |= 0x04; /* shampoo 0129 */
5111 xgifb_reg_and_or(pVBInfo->Part1Port, 0x13, tempbl, tempah);
5112 tempah = 0x00;
5113 tempbl = 0xcf;
5114 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
5115 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
5116 tempah |= 0x30;
5119 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2c, tempbl, tempah);
5120 tempah = 0;
5121 tempbl = 0x3f;
5123 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
5124 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
5125 tempah |= 0xc0;
5127 xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, tempbl, tempah);
5130 tempah = 0;
5131 tempbl = 0x7f;
5132 if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) {
5133 tempbl = 0xff;
5134 if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge))
5135 tempah |= 0x80;
5138 xgifb_reg_and_or(pVBInfo->Part4Port, 0x23, tempbl, tempah);
5140 if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) {
5141 if (pVBInfo->LCDInfo & SetLCDDualLink) {
5142 xgifb_reg_or(pVBInfo->Part4Port, 0x27, 0x20);
5143 xgifb_reg_or(pVBInfo->Part4Port, 0x34, 0x10);
5149 void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension,
5150 struct vb_device_info *pVBInfo)
5153 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2f, 0xFF, 0x01);
5157 void XGI_LockCRT2(struct xgi_hw_device_info *HwDeviceExtension,
5158 struct vb_device_info *pVBInfo)
5161 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2F, 0xFE, 0x00);
5165 unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE,
5166 unsigned short ModeNo, unsigned short ModeIdIndex,
5167 struct vb_device_info *pVBInfo)
5169 const u8 LCDARefreshIndex[] = {
5170 0x00, 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x00 };
5172 unsigned short RefreshRateTableIndex, i, index, temp;
5174 index = xgifb_reg_get(pVBInfo->P3d4, 0x33);
5175 index = index >> pVBInfo->SelectCRT2Rate;
5176 index &= 0x0F;
5178 if (pVBInfo->LCDInfo & LCDNonExpanding)
5179 index = 0;
5181 if (index > 0)
5182 index--;
5184 if (pVBInfo->SetFlag & ProgrammingCRT2) {
5185 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
5186 temp = LCDARefreshIndex[pVBInfo->LCDResInfo & 0x07];
5188 if (index > temp)
5189 index = temp;
5193 RefreshRateTableIndex = XGI330_EModeIDTable[ModeIdIndex].REFindex;
5194 ModeNo = XGI330_RefIndex[RefreshRateTableIndex].ModeID;
5195 if (pXGIHWDE->jChipType >= XG20) { /* for XG20, XG21, XG27 */
5196 if ((XGI330_RefIndex[RefreshRateTableIndex].XRes == 800) &&
5197 (XGI330_RefIndex[RefreshRateTableIndex].YRes == 600)) {
5198 index++;
5200 /* do the similar adjustment like XGISearchCRT1Rate() */
5201 if ((XGI330_RefIndex[RefreshRateTableIndex].XRes == 1024) &&
5202 (XGI330_RefIndex[RefreshRateTableIndex].YRes == 768)) {
5203 index++;
5205 if ((XGI330_RefIndex[RefreshRateTableIndex].XRes == 1280) &&
5206 (XGI330_RefIndex[RefreshRateTableIndex].YRes == 1024)) {
5207 index++;
5211 i = 0;
5212 do {
5213 if (XGI330_RefIndex[RefreshRateTableIndex + i].
5214 ModeID != ModeNo)
5215 break;
5216 temp = XGI330_RefIndex[RefreshRateTableIndex + i].Ext_InfoFlag;
5217 temp &= ModeTypeMask;
5218 if (temp < pVBInfo->ModeType)
5219 break;
5220 i++;
5221 index--;
5223 } while (index != 0xFFFF);
5224 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) {
5225 if (pVBInfo->VBInfo & SetInSlaveMode) {
5226 temp = XGI330_RefIndex[RefreshRateTableIndex + i - 1].
5227 Ext_InfoFlag;
5228 if (temp & InterlaceMode)
5229 i++;
5232 i--;
5233 if ((pVBInfo->SetFlag & ProgrammingCRT2)) {
5234 temp = XGI_AjustCRT2Rate(ModeNo, ModeIdIndex,
5235 RefreshRateTableIndex, &i, pVBInfo);
5237 return RefreshRateTableIndex + i;
5240 static void XGI_SetLCDAGroup(unsigned short ModeNo, unsigned short ModeIdIndex,
5241 struct xgi_hw_device_info *HwDeviceExtension,
5242 struct vb_device_info *pVBInfo)
5244 unsigned short RefreshRateTableIndex;
5246 pVBInfo->SetFlag |= ProgrammingCRT2;
5247 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
5248 ModeIdIndex, pVBInfo);
5249 XGI_GetLVDSResInfo(ModeNo, ModeIdIndex, pVBInfo);
5250 XGI_GetLVDSData(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
5251 XGI_ModCRT1Regs(ModeNo, ModeIdIndex, RefreshRateTableIndex,
5252 HwDeviceExtension, pVBInfo);
5253 XGI_SetLVDSRegs(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
5254 XGI_SetCRT2ECLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
5257 static unsigned char XGI_SetCRT2Group301(unsigned short ModeNo,
5258 struct xgi_hw_device_info *HwDeviceExtension,
5259 struct vb_device_info *pVBInfo)
5261 unsigned short ModeIdIndex, RefreshRateTableIndex;
5263 pVBInfo->SetFlag |= ProgrammingCRT2;
5264 XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo);
5265 pVBInfo->SelectCRT2Rate = 4;
5266 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
5267 ModeIdIndex, pVBInfo);
5268 XGI_SaveCRT2Info(ModeNo, pVBInfo);
5269 XGI_GetCRT2ResInfo(ModeNo, ModeIdIndex, pVBInfo);
5270 XGI_GetCRT2Data(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
5271 XGI_PreSetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension,
5272 RefreshRateTableIndex, pVBInfo);
5273 XGI_SetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension,
5274 RefreshRateTableIndex, pVBInfo);
5275 XGI_SetLockRegs(ModeNo, ModeIdIndex, HwDeviceExtension,
5276 RefreshRateTableIndex, pVBInfo);
5277 XGI_SetGroup2(ModeNo, ModeIdIndex, RefreshRateTableIndex,
5278 HwDeviceExtension, pVBInfo);
5279 XGI_SetLCDRegs(ModeNo, ModeIdIndex, HwDeviceExtension,
5280 RefreshRateTableIndex, pVBInfo);
5281 XGI_SetTap4Regs(pVBInfo);
5282 XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo);
5283 XGI_SetGroup4(ModeNo, ModeIdIndex, RefreshRateTableIndex,
5284 HwDeviceExtension, pVBInfo);
5285 XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
5286 XGI_SetGroup5(ModeNo, ModeIdIndex, pVBInfo);
5287 XGI_AutoThreshold(pVBInfo);
5288 return 1;
5291 void XGI_SenseCRT1(struct vb_device_info *pVBInfo)
5293 unsigned char CRTCData[17] = { 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81,
5294 0x0B, 0x3E, 0xE9, 0x0B, 0xDF, 0xE7, 0x04, 0x00, 0x00,
5295 0x05, 0x00 };
5297 unsigned char SR01 = 0, SR1F = 0, SR07 = 0, SR06 = 0;
5299 unsigned char CR17, CR63, SR31;
5300 unsigned short temp;
5302 int i;
5303 xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86);
5305 /* to fix XG42 single LCD sense to CRT+LCD */
5306 xgifb_reg_set(pVBInfo->P3d4, 0x57, 0x4A);
5307 xgifb_reg_set(pVBInfo->P3d4, 0x53, (xgifb_reg_get(
5308 pVBInfo->P3d4, 0x53) | 0x02));
5310 SR31 = xgifb_reg_get(pVBInfo->P3c4, 0x31);
5311 CR63 = xgifb_reg_get(pVBInfo->P3d4, 0x63);
5312 SR01 = xgifb_reg_get(pVBInfo->P3c4, 0x01);
5314 xgifb_reg_set(pVBInfo->P3c4, 0x01, (unsigned char) (SR01 & 0xDF));
5315 xgifb_reg_set(pVBInfo->P3d4, 0x63, (unsigned char) (CR63 & 0xBF));
5317 CR17 = xgifb_reg_get(pVBInfo->P3d4, 0x17);
5318 xgifb_reg_set(pVBInfo->P3d4, 0x17, (unsigned char) (CR17 | 0x80));
5320 SR1F = xgifb_reg_get(pVBInfo->P3c4, 0x1F);
5321 xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) (SR1F | 0x04));
5323 SR07 = xgifb_reg_get(pVBInfo->P3c4, 0x07);
5324 xgifb_reg_set(pVBInfo->P3c4, 0x07, (unsigned char) (SR07 & 0xFB));
5325 SR06 = xgifb_reg_get(pVBInfo->P3c4, 0x06);
5326 xgifb_reg_set(pVBInfo->P3c4, 0x06, (unsigned char) (SR06 & 0xC3));
5328 xgifb_reg_set(pVBInfo->P3d4, 0x11, 0x00);
5330 for (i = 0; i < 8; i++)
5331 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) i, CRTCData[i]);
5333 for (i = 8; i < 11; i++)
5334 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 8),
5335 CRTCData[i]);
5337 for (i = 11; i < 13; i++)
5338 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 4),
5339 CRTCData[i]);
5341 for (i = 13; i < 16; i++)
5342 xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i - 3),
5343 CRTCData[i]);
5345 xgifb_reg_set(pVBInfo->P3c4, 0x0E, (unsigned char) (CRTCData[16]
5346 & 0xE0));
5348 xgifb_reg_set(pVBInfo->P3c4, 0x31, 0x00);
5349 xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x1B);
5350 xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE1);
5352 outb(0x00, pVBInfo->P3c8);
5354 for (i = 0; i < 256 * 3; i++) {
5355 outb(0x0F, (pVBInfo->P3c8 + 1)); /* DAC_TEST_PARMS */
5358 mdelay(1);
5360 XGI_WaitDisply(pVBInfo);
5361 temp = inb(pVBInfo->P3c2);
5363 if (temp & 0x10)
5364 xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x20);
5365 else
5366 xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x00);
5368 /* avoid display something, set BLACK DAC if not restore DAC */
5369 outb(0x00, pVBInfo->P3c8);
5371 for (i = 0; i < 256 * 3; i++) {
5372 outb(0, (pVBInfo->P3c8 + 1));
5375 xgifb_reg_set(pVBInfo->P3c4, 0x01, SR01);
5376 xgifb_reg_set(pVBInfo->P3d4, 0x63, CR63);
5377 xgifb_reg_set(pVBInfo->P3c4, 0x31, SR31);
5379 xgifb_reg_set(pVBInfo->P3d4, 0x53, (xgifb_reg_get(
5380 pVBInfo->P3d4, 0x53) & 0xFD));
5381 xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) SR1F);
5384 static void XGI_EnableBridge(struct xgifb_video_info *xgifb_info,
5385 struct xgi_hw_device_info *HwDeviceExtension,
5386 struct vb_device_info *pVBInfo)
5388 unsigned short tempah;
5390 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
5391 | VB_SIS302LV | VB_XGI301C)) {
5392 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
5393 /* Power on */
5394 xgifb_reg_set(pVBInfo->Part1Port, 0x1E, 0x20);
5396 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV |
5397 SetCRT2ToRAMDAC)) {
5398 tempah = xgifb_reg_get(pVBInfo->P3c4, 0x32);
5399 tempah &= 0xDF;
5400 if (pVBInfo->VBInfo & SetInSlaveMode) {
5401 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC))
5402 tempah |= 0x20;
5404 xgifb_reg_set(pVBInfo->P3c4, 0x32, tempah);
5405 xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x20);
5407 tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x2E);
5409 if (!(tempah & 0x80))
5410 xgifb_reg_or(pVBInfo->Part1Port, 0x2E, 0x80);
5411 xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F);
5414 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
5415 xgifb_reg_and_or(pVBInfo->Part2Port, 0x00, ~0xE0,
5416 0x20); /* shampoo 0129 */
5417 if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) {
5418 if (pVBInfo->VBInfo &
5419 (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))
5420 /* LVDS PLL power on */
5421 xgifb_reg_and(pVBInfo->Part4Port, 0x2A,
5422 0x7F);
5423 /* LVDS Driver power on */
5424 xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x7F);
5428 tempah = 0x00;
5430 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
5431 tempah = 0xc0;
5433 if (!(pVBInfo->VBInfo & SetSimuScanMode) &&
5434 (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) &&
5435 (pVBInfo->VBInfo & SetCRT2ToDualEdge)) {
5436 tempah = tempah & 0x40;
5437 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)
5438 tempah = tempah ^ 0xC0;
5442 /* EnablePart4_1F */
5443 xgifb_reg_or(pVBInfo->Part4Port, 0x1F, tempah);
5445 XGI_DisableGatingCRT(HwDeviceExtension, pVBInfo);
5446 XGI_DisplayOn(xgifb_info, HwDeviceExtension, pVBInfo);
5447 } /* 301 */
5448 else { /* LVDS */
5449 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD
5450 | XGI_SetCRT2ToLCDA))
5451 /* enable CRT2 */
5452 xgifb_reg_or(pVBInfo->Part1Port, 0x1E, 0x20);
5454 tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x2E);
5455 if (!(tempah & 0x80))
5456 xgifb_reg_or(pVBInfo->Part1Port, 0x2E, 0x80);
5458 xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F);
5459 XGI_DisplayOn(xgifb_info, HwDeviceExtension, pVBInfo);
5460 } /* End of VB */
5463 static void XGI_SetCRT1Group(struct xgifb_video_info *xgifb_info,
5464 struct xgi_hw_device_info *HwDeviceExtension,
5465 unsigned short ModeNo, unsigned short ModeIdIndex,
5466 struct vb_device_info *pVBInfo)
5468 unsigned short RefreshRateTableIndex, temp;
5470 XGI_SetSeqRegs(ModeNo, ModeIdIndex, pVBInfo);
5471 outb(XGI330_StandTable.MISC, pVBInfo->P3c2);
5472 XGI_SetCRTCRegs(HwDeviceExtension, pVBInfo);
5473 XGI_SetATTRegs(ModeNo, ModeIdIndex, pVBInfo);
5474 XGI_SetGRCRegs(pVBInfo);
5475 XGI_ClearExt1Regs(pVBInfo);
5477 if (HwDeviceExtension->jChipType == XG27) {
5478 if (pVBInfo->IF_DEF_LVDS == 0)
5479 XGI_SetDefaultVCLK(pVBInfo);
5482 temp = ~ProgrammingCRT2;
5483 pVBInfo->SetFlag &= temp;
5484 pVBInfo->SelectCRT2Rate = 0;
5486 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
5487 | VB_SIS302LV | VB_XGI301C)) {
5488 if (pVBInfo->VBInfo & (SetSimuScanMode | XGI_SetCRT2ToLCDA
5489 | SetInSlaveMode)) {
5490 pVBInfo->SetFlag |= ProgrammingCRT2;
5494 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
5495 ModeIdIndex, pVBInfo);
5496 if (RefreshRateTableIndex != 0xFFFF) {
5497 XGI_SetSync(RefreshRateTableIndex, pVBInfo);
5498 XGI_SetCRT1CRTC(ModeNo, ModeIdIndex, RefreshRateTableIndex,
5499 pVBInfo, HwDeviceExtension);
5500 XGI_SetCRT1DE(HwDeviceExtension, ModeNo, ModeIdIndex,
5501 RefreshRateTableIndex, pVBInfo);
5502 XGI_SetCRT1Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
5503 HwDeviceExtension, pVBInfo);
5504 XGI_SetCRT1VCLK(ModeNo, ModeIdIndex, HwDeviceExtension,
5505 RefreshRateTableIndex, pVBInfo);
5508 if (HwDeviceExtension->jChipType >= XG21) {
5509 temp = xgifb_reg_get(pVBInfo->P3d4, 0x38);
5510 if (temp & 0xA0) {
5512 if (HwDeviceExtension->jChipType == XG27)
5513 XGI_SetXG27CRTC(ModeNo, ModeIdIndex,
5514 RefreshRateTableIndex, pVBInfo);
5515 else
5516 XGI_SetXG21CRTC(ModeNo, ModeIdIndex,
5517 RefreshRateTableIndex, pVBInfo);
5519 XGI_UpdateXG21CRTC(ModeNo, pVBInfo,
5520 RefreshRateTableIndex);
5522 xgifb_set_lcd(HwDeviceExtension->jChipType,
5523 pVBInfo, RefreshRateTableIndex, ModeNo);
5525 if (pVBInfo->IF_DEF_LVDS == 1)
5526 xgifb_set_lvds(xgifb_info,
5527 HwDeviceExtension->jChipType,
5528 ModeNo, ModeIdIndex, pVBInfo);
5532 pVBInfo->SetFlag &= (~ProgrammingCRT2);
5533 XGI_SetCRT1FIFO(ModeNo, HwDeviceExtension, pVBInfo);
5534 XGI_SetCRT1ModeRegs(HwDeviceExtension, ModeNo, ModeIdIndex,
5535 RefreshRateTableIndex, pVBInfo);
5536 XGI_LoadDAC(ModeNo, ModeIdIndex, pVBInfo);
5539 unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info,
5540 struct xgi_hw_device_info *HwDeviceExtension,
5541 unsigned short ModeNo)
5543 unsigned short ModeIdIndex;
5544 struct vb_device_info VBINF;
5545 struct vb_device_info *pVBInfo = &VBINF;
5546 pVBInfo->IF_DEF_LVDS = 0;
5548 if (HwDeviceExtension->jChipType >= XG20)
5549 pVBInfo->VBType = 0; /*set VBType default 0*/
5551 XGIRegInit(pVBInfo, xgifb_info->vga_base);
5553 /* for x86 Linux, XG21 LVDS */
5554 if (HwDeviceExtension->jChipType == XG21) {
5555 if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0)
5556 pVBInfo->IF_DEF_LVDS = 1;
5558 if (HwDeviceExtension->jChipType == XG27) {
5559 if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) {
5560 if (xgifb_reg_get(pVBInfo->P3d4, 0x30) & 0x20)
5561 pVBInfo->IF_DEF_LVDS = 1;
5565 InitTo330Pointer(HwDeviceExtension->jChipType, pVBInfo);
5566 if (ModeNo & 0x80)
5567 ModeNo = ModeNo & 0x7F;
5568 xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86);
5570 if (HwDeviceExtension->jChipType < XG20)
5571 XGI_UnLockCRT2(HwDeviceExtension, pVBInfo);
5573 XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo);
5575 if (HwDeviceExtension->jChipType < XG20) {
5576 XGI_GetVBInfo(ModeNo, ModeIdIndex, HwDeviceExtension, pVBInfo);
5577 XGI_GetTVInfo(ModeNo, ModeIdIndex, pVBInfo);
5578 XGI_GetLCDInfo(ModeNo, ModeIdIndex, pVBInfo);
5579 XGI_DisableBridge(xgifb_info, HwDeviceExtension, pVBInfo);
5581 if (pVBInfo->VBInfo & (SetSimuScanMode | XGI_SetCRT2ToLCDA) ||
5582 (!(pVBInfo->VBInfo & SwitchCRT2))) {
5583 XGI_SetCRT1Group(xgifb_info, HwDeviceExtension, ModeNo,
5584 ModeIdIndex, pVBInfo);
5586 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
5587 XGI_SetLCDAGroup(ModeNo, ModeIdIndex,
5588 HwDeviceExtension, pVBInfo);
5592 if (pVBInfo->VBInfo & (SetSimuScanMode | SwitchCRT2)) {
5593 switch (HwDeviceExtension->ujVBChipID) {
5594 case VB_CHIP_301: /* fall through */
5595 case VB_CHIP_302:
5596 XGI_SetCRT2Group301(ModeNo, HwDeviceExtension,
5597 pVBInfo); /*add for CRT2 */
5598 break;
5600 default:
5601 break;
5605 XGI_SetCRT2ModeRegs(ModeNo, HwDeviceExtension, pVBInfo);
5606 XGI_OEM310Setting(ModeNo, ModeIdIndex, pVBInfo); /*0212*/
5607 XGI_EnableBridge(xgifb_info, HwDeviceExtension, pVBInfo);
5608 } /* !XG20 */
5609 else {
5610 if (pVBInfo->IF_DEF_LVDS == 1)
5611 if (!XGI_XG21CheckLVDSMode(xgifb_info, ModeNo,
5612 ModeIdIndex,
5613 pVBInfo))
5614 return 0;
5616 pVBInfo->ModeType = XGI330_EModeIDTable[ModeIdIndex].
5617 Ext_ModeFlag & ModeTypeMask;
5619 pVBInfo->SetFlag = 0;
5620 pVBInfo->VBInfo = DisableCRT2Display;
5622 XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo);
5624 XGI_SetCRT1Group(xgifb_info, HwDeviceExtension, ModeNo,
5625 ModeIdIndex, pVBInfo);
5627 XGI_DisplayOn(xgifb_info, HwDeviceExtension, pVBInfo);
5630 XGI_UpdateModeInfo(HwDeviceExtension, pVBInfo);
5632 if (HwDeviceExtension->jChipType < XG20)
5633 XGI_LockCRT2(HwDeviceExtension, pVBInfo);
5635 return 1;