3 #include <linux/delay.h>
4 #include <linux/types.h>
10 #include "vb_struct.h"
13 #include "vb_setmode.h"
16 #define IndexMask 0xff
18 static unsigned short XGINew_MDA_DAC[] = {
19 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
21 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
22 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
23 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
25 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
26 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F};
28 static unsigned short XGINew_CGA_DAC[] = {
29 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
30 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
31 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
32 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
33 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
34 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
35 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
36 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F};
38 static unsigned short XGINew_EGA_DAC[] = {
39 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x05, 0x15,
40 0x20, 0x30, 0x24, 0x34, 0x21, 0x31, 0x25, 0x35,
41 0x08, 0x18, 0x0C, 0x1C, 0x09, 0x19, 0x0D, 0x1D,
42 0x28, 0x38, 0x2C, 0x3C, 0x29, 0x39, 0x2D, 0x3D,
43 0x02, 0x12, 0x06, 0x16, 0x03, 0x13, 0x07, 0x17,
44 0x22, 0x32, 0x26, 0x36, 0x23, 0x33, 0x27, 0x37,
45 0x0A, 0x1A, 0x0E, 0x1E, 0x0B, 0x1B, 0x0F, 0x1F,
46 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F};
48 static unsigned short XGINew_VGA_DAC[] = {
49 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
50 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
51 0x00, 0x05, 0x08, 0x0B, 0x0E, 0x11, 0x14, 0x18,
52 0x1C, 0x20, 0x24, 0x28, 0x2D, 0x32, 0x38, 0x3F,
53 0x00, 0x10, 0x1F, 0x2F, 0x3F, 0x1F, 0x27, 0x2F,
54 0x37, 0x3F, 0x2D, 0x31, 0x36, 0x3A, 0x3F, 0x00,
55 0x07, 0x0E, 0x15, 0x1C, 0x0E, 0x11, 0x15, 0x18,
56 0x1C, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x00, 0x04,
57 0x08, 0x0C, 0x10, 0x08, 0x0A, 0x0C, 0x0E, 0x10,
58 0x0B, 0x0C, 0x0D, 0x0F, 0x10};
60 void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo)
62 pVBInfo->SModeIDTable = (struct XGI_StStruct *) XGI330_SModeIDTable;
63 pVBInfo->StandTable = (struct XGI_StandTableStruct *) XGI330_StandTable;
64 pVBInfo->EModeIDTable = (struct XGI_ExtStruct *) XGI330_EModeIDTable;
65 pVBInfo->RefIndex = (struct XGI_Ext2Struct *) XGI330_RefIndex;
66 pVBInfo->XGINEWUB_CRT1Table
67 = (struct XGI_CRT1TableStruct *) XGI_CRT1Table;
69 /* add for new UNIVGABIOS */
70 /* XGINew_UBLCDDataTable =
71 * (struct XGI_LCDDataTablStruct *) XGI_LCDDataTable; */
72 /* XGINew_UBTVDataTable = (XGI_TVDataTablStruct *) XGI_TVDataTable; */
74 pVBInfo->MCLKData = (struct XGI_MCLKDataStruct *) XGI340New_MCLKData;
75 pVBInfo->ECLKData = (struct XGI_ECLKDataStruct *) XGI340_ECLKData;
76 pVBInfo->VCLKData = (struct XGI_VCLKDataStruct *) XGI_VCLKData;
77 pVBInfo->VBVCLKData = (struct XGI_VBVCLKDataStruct *) XGI_VBVCLKData;
78 pVBInfo->ScreenOffset = XGI330_ScreenOffset;
79 pVBInfo->StResInfo = (struct XGI_StResInfoStruct *) XGI330_StResInfo;
81 = (struct XGI_ModeResInfoStruct *) XGI330_ModeResInfo;
83 pVBInfo->pOutputSelect = &XGI330_OutputSelect;
84 pVBInfo->pSoftSetting = &XGI330_SoftSetting;
85 pVBInfo->pSR07 = &XGI330_SR07;
86 pVBInfo->LCDResInfo = 0;
87 pVBInfo->LCDTypeInfo = 0;
92 pVBInfo->SR15 = XGI340_SR13;
93 pVBInfo->CR40 = XGI340_cr41;
94 pVBInfo->SR25 = XGI330_sr25;
95 pVBInfo->pSR31 = &XGI330_sr31;
96 pVBInfo->pSR32 = &XGI330_sr32;
97 pVBInfo->CR6B = XGI340_CR6B;
98 pVBInfo->CR6E = XGI340_CR6E;
99 pVBInfo->CR6F = XGI340_CR6F;
100 pVBInfo->CR89 = XGI340_CR89;
101 pVBInfo->AGPReg = XGI340_AGPReg;
102 pVBInfo->SR16 = XGI340_SR16;
103 pVBInfo->pCRCF = &XG40_CRCF;
104 pVBInfo->pXGINew_DRAMTypeDefinition = &XG40_DRAMTypeDefinition;
106 pVBInfo->CR49 = XGI330_CR49;
107 pVBInfo->pSR1F = &XGI330_SR1F;
108 pVBInfo->pSR21 = &XGI330_SR21;
109 pVBInfo->pSR22 = &XGI330_SR22;
110 pVBInfo->pSR23 = &XGI330_SR23;
111 pVBInfo->pSR24 = &XGI330_SR24;
112 pVBInfo->pSR33 = &XGI330_SR33;
114 pVBInfo->pCRT2Data_1_2 = &XGI330_CRT2Data_1_2;
115 pVBInfo->pCRT2Data_4_D = &XGI330_CRT2Data_4_D;
116 pVBInfo->pCRT2Data_4_E = &XGI330_CRT2Data_4_E;
117 pVBInfo->pCRT2Data_4_10 = &XGI330_CRT2Data_4_10;
118 pVBInfo->pRGBSenseData = &XGI330_RGBSenseData;
119 pVBInfo->pVideoSenseData = &XGI330_VideoSenseData;
120 pVBInfo->pYCSenseData = &XGI330_YCSenseData;
121 pVBInfo->pRGBSenseData2 = &XGI330_RGBSenseData2;
122 pVBInfo->pVideoSenseData2 = &XGI330_VideoSenseData2;
123 pVBInfo->pYCSenseData2 = &XGI330_YCSenseData2;
125 pVBInfo->NTSCTiming = XGI330_NTSCTiming;
126 pVBInfo->PALTiming = XGI330_PALTiming;
127 pVBInfo->HiTVExtTiming = XGI330_HiTVExtTiming;
128 pVBInfo->HiTVSt1Timing = XGI330_HiTVSt1Timing;
129 pVBInfo->HiTVSt2Timing = XGI330_HiTVSt2Timing;
130 pVBInfo->HiTVTextTiming = XGI330_HiTVTextTiming;
131 pVBInfo->YPbPr750pTiming = XGI330_YPbPr750pTiming;
132 pVBInfo->YPbPr525pTiming = XGI330_YPbPr525pTiming;
133 pVBInfo->YPbPr525iTiming = XGI330_YPbPr525iTiming;
134 pVBInfo->HiTVGroup3Data = XGI330_HiTVGroup3Data;
135 pVBInfo->HiTVGroup3Simu = XGI330_HiTVGroup3Simu;
136 pVBInfo->HiTVGroup3Text = XGI330_HiTVGroup3Text;
137 pVBInfo->Ren525pGroup3 = XGI330_Ren525pGroup3;
138 pVBInfo->Ren750pGroup3 = XGI330_Ren750pGroup3;
140 pVBInfo->TimingH = (struct XGI_TimingHStruct *) XGI_TimingH;
141 pVBInfo->TimingV = (struct XGI_TimingVStruct *) XGI_TimingV;
142 pVBInfo->UpdateCRT1 = (struct XGI_XG21CRT1Struct *) XGI_UpdateCRT1Table;
144 /* 310 customization related */
145 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType & VB_XGI302LV))
146 pVBInfo->LCDCapList = XGI_LCDDLCapList;
148 pVBInfo->LCDCapList = XGI_LCDCapList;
150 if ((ChipType == XG21) || (ChipType == XG27))
151 pVBInfo->XG21_LVDSCapList = XGI21_LCDCapList;
153 pVBInfo->XGI_TVDelayList = XGI301TVDelayList;
154 pVBInfo->XGI_TVDelayList2 = XGI301TVDelayList2;
156 pVBInfo->pXGINew_I2CDefinition = &XG40_I2CDefinition;
158 if (ChipType >= XG20)
159 pVBInfo->pXGINew_CR97 = &XG20_CR97;
161 if (ChipType == XG27) {
163 = (struct XGI_MCLKDataStruct *) XGI27New_MCLKData;
164 pVBInfo->CR40 = XGI27_cr41;
165 pVBInfo->pXGINew_CR97 = &XG27_CR97;
166 pVBInfo->pSR36 = &XG27_SR36;
167 pVBInfo->pCR8F = &XG27_CR8F;
168 pVBInfo->pCRD0 = XG27_CRD0;
169 pVBInfo->pCRDE = XG27_CRDE;
170 pVBInfo->pSR40 = &XG27_SR40;
171 pVBInfo->pSR41 = &XG27_SR41;
175 if (ChipType >= XG20) {
176 pVBInfo->pDVOSetting = &XG21_DVOSetting;
177 pVBInfo->pCR2E = &XG21_CR2E;
178 pVBInfo->pCR2F = &XG21_CR2F;
179 pVBInfo->pCR46 = &XG21_CR46;
180 pVBInfo->pCR47 = &XG21_CR47;
185 static unsigned char XGI_GetModePtr(unsigned short ModeNo,
186 unsigned short ModeIdIndex,
187 struct vb_device_info *pVBInfo)
192 index = pVBInfo->SModeIDTable[ModeIdIndex].St_StTableIndex;
194 if (pVBInfo->ModeType <= 0x02)
195 index = 0x1B; /* 02 -> ModeEGA */
199 return index; /* Get pVBInfo->StandTable index */
203 unsigned char XGI_SetBIOSData(unsigned short ModeNo,
204 unsigned short ModeIdIndex) {
209 /* unsigned char XGI_ClearBankRegs(unsigned short ModeNo,
210 unsigned short ModeIdIndex) {
215 static void XGI_SetSeqRegs(unsigned short ModeNo,
216 unsigned short StandTableIndex,
217 unsigned short ModeIdIndex,
218 struct vb_device_info *pVBInfo)
220 unsigned char tempah, SRdata;
221 unsigned short i, modeflag;
224 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
226 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
228 xgifb_reg_set(pVBInfo->P3c4, 0x00, 0x03); /* Set SR0 */
229 tempah = pVBInfo->StandTable[StandTableIndex].SR[0];
232 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
235 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD)) {
236 if (pVBInfo->VBInfo & SetInSlaveMode)
241 tempah |= 0x20; /* screen off */
242 xgifb_reg_set(pVBInfo->P3c4, 0x01, tempah); /* Set SR1 */
244 for (i = 02; i <= 04; i++) {
245 /* Get SR2,3,4 from file */
246 SRdata = pVBInfo->StandTable[StandTableIndex].SR[i - 1];
247 xgifb_reg_set(pVBInfo->P3c4, i, SRdata); /* Set SR2 3 4 */
251 static void XGI_SetMiscRegs(unsigned short StandTableIndex,
252 struct vb_device_info *pVBInfo)
254 unsigned char Miscdata;
256 /* Get Misc from file */
257 Miscdata = pVBInfo->StandTable[StandTableIndex].MISC;
259 if (pVBInfo->VBType & (VB_XGI301B |
264 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
270 outb(Miscdata, pVBInfo->P3c2); /* Set Misc(3c2) */
273 static void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension,
274 unsigned short StandTableIndex,
275 struct vb_device_info *pVBInfo)
277 unsigned char CRTCdata;
280 CRTCdata = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
282 xgifb_reg_set(pVBInfo->P3d4, 0x11, CRTCdata); /* Unlock CRTC */
284 for (i = 0; i <= 0x18; i++) {
285 /* Get CRTC from file */
286 CRTCdata = pVBInfo->StandTable[StandTableIndex].CRTC[i];
287 xgifb_reg_set(pVBInfo->P3d4, i, CRTCdata); /* Set CRTC(3d4) */
290 if ((HwDeviceExtension->jChipType == XGI_630) &&
291 (HwDeviceExtension->jChipRevision == 0x30)) {
292 if (pVBInfo->VBInfo & SetInSlaveMode) {
293 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) {
294 xgifb_reg_set(pVBInfo->P3d4, 0x18, 0xFE);
301 static void XGI_SetATTRegs(unsigned short ModeNo,
302 unsigned short StandTableIndex,
303 unsigned short ModeIdIndex,
304 struct vb_device_info *pVBInfo)
306 unsigned char ARdata;
307 unsigned short i, modeflag;
310 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
312 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
314 for (i = 0; i <= 0x13; i++) {
315 ARdata = pVBInfo->StandTable[StandTableIndex].ATTR[i];
316 if (modeflag & Charx8Dot) { /* ifndef Dot9 */
318 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
321 if (pVBInfo->VBInfo & (SetCRT2ToTV
323 if (pVBInfo->VBInfo &
331 inb(pVBInfo->P3da); /* reset 3da */
332 outb(i, pVBInfo->P3c0); /* set index */
333 outb(ARdata, pVBInfo->P3c0); /* set data */
336 inb(pVBInfo->P3da); /* reset 3da */
337 outb(0x14, pVBInfo->P3c0); /* set index */
338 outb(0x00, pVBInfo->P3c0); /* set data */
339 inb(pVBInfo->P3da); /* Enable Attribute */
340 outb(0x20, pVBInfo->P3c0);
343 static void XGI_SetGRCRegs(unsigned short StandTableIndex,
344 struct vb_device_info *pVBInfo)
346 unsigned char GRdata;
349 for (i = 0; i <= 0x08; i++) {
350 /* Get GR from file */
351 GRdata = pVBInfo->StandTable[StandTableIndex].GRC[i];
352 xgifb_reg_set(pVBInfo->P3ce, i, GRdata); /* Set GR(3ce) */
355 if (pVBInfo->ModeType > ModeVGA) {
356 GRdata = (unsigned char) xgifb_reg_get(pVBInfo->P3ce, 0x05);
357 GRdata &= 0xBF; /* 256 color disable */
358 xgifb_reg_set(pVBInfo->P3ce, 0x05, GRdata);
362 static void XGI_ClearExt1Regs(struct vb_device_info *pVBInfo)
366 for (i = 0x0A; i <= 0x0E; i++)
367 xgifb_reg_set(pVBInfo->P3c4, i, 0x00); /* Clear SR0A-SR0E */
370 static unsigned char XGI_SetDefaultVCLK(struct vb_device_info *pVBInfo)
373 xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x20);
374 xgifb_reg_set(pVBInfo->P3c4, 0x2B, pVBInfo->VCLKData[0].SR2B);
375 xgifb_reg_set(pVBInfo->P3c4, 0x2C, pVBInfo->VCLKData[0].SR2C);
377 xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x10);
378 xgifb_reg_set(pVBInfo->P3c4, 0x2B, pVBInfo->VCLKData[1].SR2B);
379 xgifb_reg_set(pVBInfo->P3c4, 0x2C, pVBInfo->VCLKData[1].SR2C);
381 xgifb_reg_and(pVBInfo->P3c4, 0x31, ~0x30);
385 static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo,
386 unsigned short ModeIdIndex,
387 unsigned short RefreshRateTableIndex, unsigned short *i,
388 struct vb_device_info *pVBInfo)
390 unsigned short tempax, tempbx, resinfo, modeflag, infoflag;
394 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
396 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
398 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
399 tempbx = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID;
402 if (pVBInfo->IF_DEF_LVDS == 0) {
403 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
404 tempax |= SupportRAMDAC2;
406 if (pVBInfo->VBType & VB_XGI301C)
407 tempax |= SupportCRT2in301C;
411 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
412 tempax |= SupportLCD;
414 if (pVBInfo->LCDResInfo != Panel1280x1024) {
415 if (pVBInfo->LCDResInfo != Panel1280x960) {
416 if (pVBInfo->LCDInfo &
427 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { /* for HiTV */
428 if ((pVBInfo->VBType & VB_XGI301LV) &&
429 (pVBInfo->VBExtInfo == VB_YPbPr1080i)) {
430 tempax |= SupportYPbPr;
431 if (pVBInfo->VBInfo & SetInSlaveMode) {
442 tempax |= SupportHiVisionTV;
443 if (pVBInfo->VBInfo & SetInSlaveMode) {
458 if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO |
462 SetCRT2ToHiVisionTV)) {
465 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
466 | VB_XGI301LV | VB_XGI302LV
468 tempax |= SupportTV1024;
471 if (!(pVBInfo->VBInfo & SetPALTV)) {
472 if (modeflag & NoSupportSimuTV) {
473 if (pVBInfo->VBInfo &
475 if (!(pVBInfo->VBInfo &
484 } else { /* for LVDS */
485 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
486 tempax |= SupportLCD;
489 return 0; /* 1024x768 */
491 if (pVBInfo->LCDResInfo < Panel1024x768) {
493 return 0; /* 800x600 */
496 return 0; /* 512x384 */
501 for (; pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID ==
503 infoflag = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].
505 if (infoflag & tempax)
512 for ((*i) = 0;; (*i)++) {
513 infoflag = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].
515 if (pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID
520 if (infoflag & tempax)
526 static void XGI_SetSync(unsigned short RefreshRateTableIndex,
527 struct vb_device_info *pVBInfo)
529 unsigned short sync, temp;
532 sync = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag >> 8;
536 outb(temp, pVBInfo->P3c2); /* Set Misc(3c2) */
539 static void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo,
540 struct xgi_hw_device_info *HwDeviceExtension)
542 unsigned char data, data1, pushax;
545 /* xgifb_reg_set(pVBInfo->P3d4, 0x51, 0); */
546 /* xgifb_reg_set(pVBInfo->P3d4, 0x56, 0); */
547 /* xgifb_reg_and_or(pVBInfo->P3d4, 0x11, 0x7f, 0x00); */
550 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
552 xgifb_reg_set(pVBInfo->P3d4, 0x11, data);
554 data = pVBInfo->TimingH[0].data[0];
555 xgifb_reg_set(pVBInfo->P3d4, 0, data);
557 for (i = 0x01; i <= 0x04; i++) {
558 data = pVBInfo->TimingH[0].data[i];
559 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 1), data);
562 for (i = 0x05; i <= 0x06; i++) {
563 data = pVBInfo->TimingH[0].data[i];
564 xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i + 6), data);
567 j = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0e);
569 data = pVBInfo->TimingH[0].data[7];
572 xgifb_reg_set(pVBInfo->P3c4, 0x0e, data);
574 if (HwDeviceExtension->jChipType >= XG20) {
575 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x04);
577 xgifb_reg_set(pVBInfo->P3d4, 0x04, data);
578 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x05);
584 data = (unsigned char) xgifb_reg_get(pVBInfo->P3c4,
587 xgifb_reg_set(pVBInfo->P3c4, 0x0c, data);
592 xgifb_reg_set(pVBInfo->P3d4, 0x05, data);
593 data = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0e);
599 xgifb_reg_and_or(pVBInfo->P3c4, 0x0e, ~0xE0, data);
603 static void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex,
604 unsigned short ModeNo,
605 struct vb_device_info *pVBInfo)
610 /* xgifb_reg_set(pVBInfo->P3d4, 0x51, 0); */
611 /* xgifb_reg_set(pVBInfo->P3d4, 0x56, 0); */
612 /* xgifb_reg_and_or(pVBInfo->P3d4, 0x11, 0x7f, 0x00); */
614 for (i = 0x00; i <= 0x01; i++) {
615 data = pVBInfo->TimingV[0].data[i];
616 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 6), data);
619 for (i = 0x02; i <= 0x03; i++) {
620 data = pVBInfo->TimingV[0].data[i];
621 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x0e), data);
624 for (i = 0x04; i <= 0x05; i++) {
625 data = pVBInfo->TimingV[0].data[i];
626 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x11), data);
629 j = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0a);
631 data = pVBInfo->TimingV[0].data[6];
634 xgifb_reg_set(pVBInfo->P3c4, 0x0a, data);
636 data = pVBInfo->TimingV[0].data[6];
641 i = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
643 i = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
649 j = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x09);
652 xgifb_reg_set(pVBInfo->P3d4, 0x09, data);
655 static void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
656 unsigned short RefreshRateTableIndex,
657 struct vb_device_info *pVBInfo,
658 struct xgi_hw_device_info *HwDeviceExtension)
660 unsigned char index, data;
664 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
665 index = index & IndexMask;
667 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
669 xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */
671 for (i = 0; i < 8; i++)
672 pVBInfo->TimingH[0].data[i]
673 = pVBInfo->XGINEWUB_CRT1Table[index].CR[i];
675 for (i = 0; i < 7; i++)
676 pVBInfo->TimingV[0].data[i]
677 = pVBInfo->XGINEWUB_CRT1Table[index].CR[i + 8];
679 XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension);
681 XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo);
683 if (pVBInfo->ModeType > 0x03)
684 xgifb_reg_set(pVBInfo->P3d4, 0x14, 0x4F);
687 /* --------------------------------------------------------------------- */
688 /* Function : XGI_SetXG21CRTC */
689 /* Input : Stand or enhance CRTC table */
690 /* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */
691 /* Description : Set LCD timing */
692 /* --------------------------------------------------------------------- */
693 static void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
694 unsigned short RefreshRateTableIndex,
695 struct vb_device_info *pVBInfo)
697 unsigned char StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx;
698 unsigned short Temp1, Temp2, Temp3;
700 if (ModeNo <= 0x13) {
701 StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
703 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[4];
704 /* SR2E [7:0]->HRS */
705 xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax);
706 /* Tempbx: CR05 HRE */
707 Tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[5];
708 Tempbx &= 0x1F; /* Tempbx: HRE[4:0] */
710 Tempcx &= 0xE0; /* Tempcx: HRS[7:5] */
711 Tempdx = Tempcx | Tempbx; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
712 if (Tempbx < (Tempax & 0x1F)) /* IF HRE < HRS */
713 Tempdx |= 0x20; /* Tempdx: HRE = HRE + 0x20 */
714 Tempdx <<= 2; /* Tempdx << 2 */
715 /* SR2F [7:2]->HRE */
716 xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempdx);
717 xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00);
719 /* Tempax: CR16 VRS */
720 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[16];
721 Tempbx = Tempax; /* Tempbx=Tempax */
722 Tempax &= 0x01; /* Tempax: VRS[0] */
723 xgifb_reg_or(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS */
725 /* Tempax: CR7 VRS */
726 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[7];
727 Tempdx = Tempbx >> 1; /* Tempdx: VRS[7:1] */
728 Tempcx = Tempax & 0x04; /* Tempcx: CR7[2] */
729 Tempcx <<= 5; /* Tempcx[7]: VRS[8] */
730 Tempdx |= Tempcx; /* Tempdx: VRS[8:1] */
731 /* SR34[7:0]: VRS[8:1] */
732 xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempdx);
734 /* Temp1[8]: VRS[8] unsigned char -> unsigned short */
736 Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */
737 Tempax &= 0x80; /* Tempax[7]: CR7[7] */
738 Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */
739 Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */
742 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[17];
743 Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
744 Temp2 = Temp1 & 0x3F0; /* Temp2[9:4]: VRS[9:4] */
745 Temp2 |= Tempax; /* Temp2[9:0]: VRE[9:0] */
746 Temp3 = Temp1 & 0x0F; /* Temp3[3:0]: VRS[3:0] */
747 if (Tempax < Temp3) /* VRE[3:0]<VRS[3:0] */
748 Temp2 |= 0x10; /* Temp2: VRE + 0x10 */
749 Temp2 &= 0xFF; /* Temp2[7:0]: VRE[7:0] */
750 Tempax = (unsigned char) Temp2; /* Tempax[7:0]: VRE[7:0] */
751 Tempax <<= 2; /* Tempax << 2: VRE[5:0] */
752 Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */
753 Temp1 >>= 9; /* [10:9]->[1:0] */
754 Tempbx = (unsigned char) Temp1; /* Tempbx[1:0]: VRS[10:9] */
755 Tempax |= Tempbx; /* VRE[5:0]VRS[10:9] */
757 /* SR3F D[7:2]->VRE D[1:0]->VRS */
758 xgifb_reg_set(pVBInfo->P3c4, 0x3F, Tempax);
760 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
761 /* Tempax: CR4 HRS */
762 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3];
763 Tempcx = Tempax; /* Tempcx: HRS */
765 xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax);
767 Tempdx = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SRB */
768 Tempdx &= 0xC0; /* Tempdx[7:6]: SRB[7:6] */
769 Temp1 = Tempdx; /* Temp1[7:6]: HRS[9:8] */
770 Temp1 <<= 2; /* Temp1[9:8]: HRS[9:8] */
771 Temp1 |= Tempax; /* Temp1[9:0]: HRS[9:0] */
773 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */
774 Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */
776 Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[6]; /* SRC */
777 Tempbx &= 0x04; /* Tempbx[2]: HRE[5] */
778 Tempbx <<= 3; /* Tempbx[5]: HRE[5] */
779 Tempax |= Tempbx; /* Tempax[5:0]: HRE[5:0] */
781 Temp2 = Temp1 & 0x3C0; /* Temp2[9:6]: HRS[9:6] */
782 Temp2 |= Tempax; /* Temp2[9:0]: HRE[9:0] */
784 Tempcx &= 0x3F; /* Tempcx[5:0]: HRS[5:0] */
785 if (Tempax < Tempcx) /* HRE < HRS */
786 Temp2 |= 0x40; /* Temp2 + 0x40 */
789 Tempax = (unsigned char) Temp2; /* Tempax: HRE[7:0] */
790 Tempax <<= 2; /* Tempax[7:2]: HRE[5:0] */
791 Tempdx >>= 6; /* Tempdx[7:6]->[1:0] HRS[9:8] */
792 Tempax |= Tempdx; /* HRE[5:0]HRS[9:8] */
793 /* SR2F D[7:2]->HRE, D[1:0]->HRS */
794 xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax);
795 xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00);
798 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10];
799 Tempbx = Tempax; /* Tempbx: VRS */
800 Tempax &= 0x01; /* Tempax[0]: VRS[0] */
801 xgifb_reg_or(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS[0] */
803 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9];
804 Tempcx = Tempbx >> 1; /* Tempcx[6:0]: VRS[7:1] */
805 Tempdx = Tempax & 0x04; /* Tempdx[2]: CR7[2] */
806 Tempdx <<= 5; /* Tempdx[7]: VRS[8] */
807 Tempcx |= Tempdx; /* Tempcx[7:0]: VRS[8:1] */
808 xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempcx); /* SR34[8:1]->VRS */
810 Temp1 = Tempdx; /* Temp1[7]: Tempdx[7] */
811 Temp1 <<= 1; /* Temp1[8]: VRS[8] */
812 Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */
814 Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */
815 Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */
817 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14];
818 Tempax &= 0x08; /* Tempax[3]: VRS[3] */
820 Temp2 <<= 7; /* Temp2[10]: VRS[10] */
821 Temp1 |= Temp2; /* Temp1[10:0]: VRS[10:0] */
823 /* Tempax: CR11 VRE */
824 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11];
825 Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
827 Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14];
828 Tempbx &= 0x20; /* Tempbx[5]: VRE[5] */
829 Tempbx >>= 1; /* Tempbx[4]: VRE[4] */
830 Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */
831 Temp2 = Temp1 & 0x7E0; /* Temp2[10:5]: VRS[10:5] */
832 Temp2 |= Tempax; /* Temp2[10:5]: VRE[10:5] */
834 Temp3 = Temp1 & 0x1F; /* Temp3[4:0]: VRS[4:0] */
835 if (Tempax < Temp3) /* VRE < VRS */
836 Temp2 |= 0x20; /* VRE + 0x20 */
839 Tempax = (unsigned char) Temp2; /* Tempax: VRE[7:0] */
840 Tempax <<= 2; /* Tempax[7:0]; VRE[5:0]00 */
841 Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */
842 Temp1 >>= 9; /* Temp1[1:0]: VRS[10:9] */
843 Tempbx = (unsigned char) Temp1;
844 Tempax |= Tempbx; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */
846 /* SR3F D[7:2]->VRE D[1:0]->VRS */
847 xgifb_reg_set(pVBInfo->P3c4, 0x3F, Tempax);
851 static void XGI_SetXG27CRTC(unsigned short ModeNo,
852 unsigned short ModeIdIndex,
853 unsigned short RefreshRateTableIndex,
854 struct vb_device_info *pVBInfo)
856 unsigned short StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx;
858 if (ModeNo <= 0x13) {
859 StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
861 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[4];
862 /* SR2E [7:0]->HRS */
863 xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax);
864 /* Tempbx: CR05 HRE */
865 Tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[5];
866 Tempbx &= 0x1F; /* Tempbx: HRE[4:0] */
868 Tempcx &= 0xE0; /* Tempcx: HRS[7:5] */
869 Tempdx = Tempcx | Tempbx; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
870 if (Tempbx < (Tempax & 0x1F)) /* IF HRE < HRS */
871 Tempdx |= 0x20; /* Tempdx: HRE = HRE + 0x20 */
872 Tempdx <<= 2; /* Tempdx << 2 */
873 /* SR2F [7:2]->HRE */
874 xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempdx);
875 xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00);
877 /* Tempax: CR10 VRS */
878 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[16];
879 xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempax); /* SR34[7:0]->VRS */
880 Tempcx = Tempax; /* Tempcx=Tempax=VRS[7:0] */
881 /* Tempax[7][2]: CR7[7][2] VRS[9][8] */
882 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[7];
883 Tempbx = Tempax; /* Tempbx=CR07 */
884 Tempax &= 0x04; /* Tempax[2]: CR07[2] VRS[8] */
886 /* SR35 D[0]->VRS D[8] */
887 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x01, Tempax);
888 Tempcx |= (Tempax << 8); /* Tempcx[8] |= VRS[8] */
889 Tempcx |= (Tempbx & 0x80) << 2; /* Tempcx[9] |= VRS[9] */
892 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[17];
893 Tempax &= 0x0F; /* Tempax: VRE[3:0] */
894 Tempbx = Tempcx; /* Tempbx=Tempcx=VRS[9:0] */
895 Tempbx &= 0x3F0; /* Tempbx[9:4]: VRS[9:4] */
896 Tempbx |= Tempax; /* Tempbx[9:0]: VRE[9:0] */
897 if (Tempax <= (Tempcx & 0x0F)) /* VRE[3:0]<=VRS[3:0] */
898 Tempbx |= 0x10; /* Tempbx: VRE + 0x10 */
899 /* Tempax[7:0]: VRE[7:0] */
900 Tempax = (unsigned char) Tempbx & 0xFF;
901 Tempax <<= 2; /* Tempax << 2: VRE[5:0] */
902 Tempcx = (Tempcx & 0x600) >> 8; /* Tempcx VRS[10:9] */
903 /* SR3F D[7:2]->VRE D[5:0] */
904 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax);
905 /* SR35 D[2:1]->VRS[10:9] */
906 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x06, Tempcx);
908 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
909 /* Tempax: CR4 HRS */
910 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3];
911 Tempbx = Tempax; /* Tempbx: HRS[7:0] */
913 xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax);
916 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5];
917 Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
918 Tempbx |= (Tempax << 2); /* Tempbx: HRS[9:0] */
920 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */
921 Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */
922 Tempcx = Tempax; /* Tempcx: HRE[4:0] */
924 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[6]; /* SRC */
925 Tempax &= 0x04; /* Tempax[2]: HRE[5] */
926 Tempax <<= 3; /* Tempax[5]: HRE[5] */
927 Tempcx |= Tempax; /* Tempcx[5:0]: HRE[5:0] */
929 Tempbx = Tempbx & 0x3C0; /* Tempbx[9:6]: HRS[9:6] */
930 Tempbx |= Tempcx; /* Tempbx: HRS[9:6]HRE[5:0] */
932 /* Tempax: CR4 HRS */
933 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3];
934 Tempax &= 0x3F; /* Tempax: HRS[5:0] */
935 if (Tempcx <= Tempax) /* HRE[5:0] < HRS[5:0] */
936 Tempbx += 0x40; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/
938 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SR0B */
939 Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
940 Tempax >>= 6; /* Tempax[1:0]: HRS[9:8]*/
941 Tempax |= ((Tempbx << 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */
942 /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */
943 xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax);
944 xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00);
947 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10];
948 /* SR34[7:0]->VRS[7:0] */
949 xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempax);
951 Tempcx = Tempax; /* Tempcx <= VRS[7:0] */
952 /* CR7[7][2] VRS[9][8] */
953 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9];
954 Tempbx = Tempax; /* Tempbx <= CR07[7:0] */
955 Tempax = Tempax & 0x04; /* Tempax[2]: CR7[2]: VRS[8] */
956 Tempax >>= 2; /* Tempax[0]: VRS[8] */
957 /* SR35[0]: VRS[8] */
958 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x01, Tempax);
959 Tempcx |= (Tempax << 8); /* Tempcx <= VRS[8:0] */
960 Tempcx |= ((Tempbx & 0x80) << 2); /* Tempcx <= VRS[9:0] */
962 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14];
963 Tempax &= 0x08; /* SR0A[3] VRS[10] */
964 Tempcx |= (Tempax << 7); /* Tempcx <= VRS[10:0] */
966 /* Tempax: CR11 VRE */
967 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11];
968 Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
970 Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14];
971 Tempbx &= 0x20; /* Tempbx[5]: SR0A[5]: VRE[4] */
972 Tempbx >>= 1; /* Tempbx[4]: VRE[4] */
973 Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */
974 Tempbx = Tempcx; /* Tempbx: VRS[10:0] */
975 Tempbx &= 0x7E0; /* Tempbx[10:5]: VRS[10:5] */
976 Tempbx |= Tempax; /* Tempbx: VRS[10:5]VRE[4:0] */
978 if (Tempbx <= Tempcx) /* VRE <= VRS */
979 Tempbx |= 0x20; /* VRE + 0x20 */
981 /* Tempax: Tempax[7:0]; VRE[5:0]00 */
982 Tempax = (Tempbx << 2) & 0xFF;
983 /* SR3F[7:2]:VRE[5:0] */
984 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax);
985 Tempax = Tempcx >> 8;
986 /* SR35[2:0]:VRS[10:8] */
987 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, Tempax);
991 static void xgifb_set_lcd(int chip_id,
992 struct vb_device_info *pVBInfo,
993 unsigned short RefreshRateTableIndex,
994 unsigned short ModeNo)
996 unsigned short Data, Temp, b3CC;
997 unsigned short XGI_P3cc;
999 XGI_P3cc = pVBInfo->P3cc;
1001 xgifb_reg_set(pVBInfo->P3d4, 0x2E, 0x00);
1002 xgifb_reg_set(pVBInfo->P3d4, 0x2F, 0x00);
1003 xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x00);
1004 xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x00);
1006 if (chip_id == XG27) {
1007 Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
1008 if ((Temp & 0x03) == 0) { /* dual 12 */
1009 xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x13);
1010 xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x13);
1014 if (((*pVBInfo->pDVOSetting) & 0xC0) == 0xC0) {
1015 xgifb_reg_set(pVBInfo->P3d4, 0x2E, *pVBInfo->pCR2E);
1016 xgifb_reg_set(pVBInfo->P3d4, 0x2F, *pVBInfo->pCR2F);
1017 xgifb_reg_set(pVBInfo->P3d4, 0x46, *pVBInfo->pCR46);
1018 xgifb_reg_set(pVBInfo->P3d4, 0x47, *pVBInfo->pCR47);
1021 if (chip_id == XG27) {
1022 XGI_SetXG27FPBits(pVBInfo);
1024 Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
1027 xgifb_reg_or(pVBInfo->P3c4, 0x06, 0x40);
1028 xgifb_reg_or(pVBInfo->P3c4, 0x09, 0x40);
1032 xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */
1034 xgifb_reg_and(pVBInfo->P3c4, 0x30, ~0x20); /* Hsync polarity */
1035 xgifb_reg_and(pVBInfo->P3c4, 0x35, ~0x80); /* Vsync polarity */
1037 if (ModeNo <= 0x13) {
1038 b3CC = (unsigned char) inb(XGI_P3cc);
1040 /* Hsync polarity */
1041 xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20);
1043 /* Vsync polarity */
1044 xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80);
1046 Data = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1048 /* Hsync polarity */
1049 xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20);
1051 /* Vsync polarity */
1052 xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80);
1056 /* --------------------------------------------------------------------- */
1057 /* Function : XGI_UpdateXG21CRTC */
1059 /* Output : CRT1 CRTC */
1060 /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */
1061 /* --------------------------------------------------------------------- */
1062 static void XGI_UpdateXG21CRTC(unsigned short ModeNo,
1063 struct vb_device_info *pVBInfo,
1064 unsigned short RefreshRateTableIndex)
1068 xgifb_reg_and(pVBInfo->P3d4, 0x11, 0x7F); /* Unlock CR0~7 */
1069 if (ModeNo <= 0x13) {
1070 for (i = 0; i < 12; i++) {
1071 if (ModeNo == pVBInfo->UpdateCRT1[i].ModeID)
1075 if (ModeNo == 0x2E &&
1076 (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC ==
1079 else if (ModeNo == 0x2E &&
1080 (pVBInfo->RefIndex[RefreshRateTableIndex].
1081 Ext_CRT1CRTC == RES640x480x72))
1083 else if (ModeNo == 0x2F)
1085 else if (ModeNo == 0x50)
1087 else if (ModeNo == 0x59)
1092 xgifb_reg_set(pVBInfo->P3d4, 0x02,
1093 pVBInfo->UpdateCRT1[index].CR02);
1094 xgifb_reg_set(pVBInfo->P3d4, 0x03,
1095 pVBInfo->UpdateCRT1[index].CR03);
1096 xgifb_reg_set(pVBInfo->P3d4, 0x15,
1097 pVBInfo->UpdateCRT1[index].CR15);
1098 xgifb_reg_set(pVBInfo->P3d4, 0x16,
1099 pVBInfo->UpdateCRT1[index].CR16);
1103 static void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension,
1104 unsigned short ModeNo, unsigned short ModeIdIndex,
1105 unsigned short RefreshRateTableIndex,
1106 struct vb_device_info *pVBInfo)
1108 unsigned short resindex, tempax, tempbx, tempcx, temp, modeflag;
1112 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
1114 if (ModeNo <= 0x13) {
1115 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
1116 tempax = pVBInfo->StResInfo[resindex].HTotal;
1117 tempbx = pVBInfo->StResInfo[resindex].VTotal;
1119 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1120 tempax = pVBInfo->ModeResInfo[resindex].HTotal;
1121 tempbx = pVBInfo->ModeResInfo[resindex].VTotal;
1124 if (modeflag & HalfDCLK)
1125 tempax = tempax >> 1;
1127 if (ModeNo > 0x13) {
1128 if (modeflag & HalfDCLK)
1129 tempax = tempax << 1;
1131 temp = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1133 if (temp & InterlaceMode)
1134 tempbx = tempbx >> 1;
1136 if (modeflag & DoubleScanMode)
1137 tempbx = tempbx << 1;
1142 /* if (!(modeflag & Charx8Dot)) */
1149 temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
1150 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
1152 xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */
1153 xgifb_reg_set(pVBInfo->P3d4, 0x01, (unsigned short) (tempcx & 0xff));
1154 xgifb_reg_and_or(pVBInfo->P3d4, 0x0b, ~0x0c,
1155 (unsigned short) ((tempcx & 0x0ff00) >> 10));
1156 xgifb_reg_set(pVBInfo->P3d4, 0x12, (unsigned short) (tempbx & 0xff));
1158 tempbx = tempbx >> 8;
1166 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x42, tempax);
1167 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x07);
1174 xgifb_reg_and_or(pVBInfo->P3d4, 0x0a, ~0x02, tempax);
1175 xgifb_reg_set(pVBInfo->P3d4, 0x11, temp);
1178 unsigned short XGI_GetResInfo(unsigned short ModeNo,
1179 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
1181 unsigned short resindex;
1185 resindex = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
1187 /* si+Ext_ResInfo */
1188 resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
1192 static void XGI_SetCRT1Offset(unsigned short ModeNo,
1193 unsigned short ModeIdIndex,
1194 unsigned short RefreshRateTableIndex,
1195 struct xgi_hw_device_info *HwDeviceExtension,
1196 struct vb_device_info *pVBInfo)
1198 unsigned short temp, ah, al, temp2, i, DisplayUnit;
1201 temp = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo;
1203 temp = pVBInfo->ScreenOffset[temp];
1205 temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1206 temp2 &= InterlaceMode;
1211 temp2 = pVBInfo->ModeType - ModeEGA;
1236 if ((ModeNo >= 0x26) && (ModeNo <= 0x28))
1237 temp = temp * temp2 + temp2 / 2;
1244 temp = temp >> 8; /* ah */
1246 i = xgifb_reg_get(pVBInfo->P3c4, 0x0E);
1249 xgifb_reg_set(pVBInfo->P3c4, 0x0E, i);
1251 temp = (unsigned char) temp2;
1252 temp &= 0xFF; /* al */
1253 xgifb_reg_set(pVBInfo->P3d4, 0x13, temp);
1255 /* SetDisplayUnit */
1256 temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1257 temp2 &= InterlaceMode;
1261 DisplayUnit = DisplayUnit << 5;
1262 ah = (DisplayUnit & 0xff00) >> 8;
1263 al = DisplayUnit & 0x00ff;
1269 if (HwDeviceExtension->jChipType >= XG20)
1270 if ((ModeNo == 0x4A) | (ModeNo == 0x49))
1273 xgifb_reg_set(pVBInfo->P3c4, 0x10, ah);
1276 static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo,
1277 unsigned short ModeIdIndex,
1278 unsigned short RefreshRateTableIndex,
1279 struct xgi_hw_device_info *HwDeviceExtension,
1280 struct vb_device_info *pVBInfo)
1282 unsigned short LCDXlat1VCLK[4] = { VCLK65 + 2,
1286 unsigned short LCDXlat2VCLK[4] = { VCLK108_2 + 5,
1290 unsigned short LVDSXlat1VCLK[4] = { VCLK40, VCLK40, VCLK40, VCLK40 };
1291 unsigned short LVDSXlat2VCLK[4] = { VCLK65 + 2,
1295 unsigned short LVDSXlat3VCLK[4] = { VCLK65 + 2,
1300 unsigned short CRT2Index, VCLKIndex;
1301 unsigned short modeflag, resinfo;
1303 if (ModeNo <= 0x13) {
1305 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
1306 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
1307 CRT2Index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
1309 /* si+Ext_ResInfo */
1310 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1311 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
1312 CRT2Index = pVBInfo->RefIndex[RefreshRateTableIndex].
1316 if (pVBInfo->IF_DEF_LVDS == 0) {
1317 CRT2Index = CRT2Index >> 6; /* for LCD */
1318 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { /*301b*/
1319 if (pVBInfo->LCDResInfo != Panel1024x768)
1320 VCLKIndex = LCDXlat2VCLK[CRT2Index];
1322 VCLKIndex = LCDXlat1VCLK[CRT2Index];
1323 } else { /* for TV */
1324 if (pVBInfo->VBInfo & SetCRT2ToTV) {
1325 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
1326 if (pVBInfo->SetFlag & RPLLDIV2XO) {
1327 VCLKIndex = HiTVVCLKDIV2;
1330 VCLKIndex = HiTVVCLK;
1334 if (pVBInfo->SetFlag & TVSimuMode) {
1335 if (modeflag & Charx8Dot) {
1347 if (pVBInfo->VBType & VB_XGI301LV) {
1348 if (!(pVBInfo->VBExtInfo ==
1352 if (!(pVBInfo->VBExtInfo
1357 if (!(pVBInfo->VBExtInfo
1361 if (!(pVBInfo->SetFlag
1370 if (pVBInfo->VBInfo & SetCRT2ToTV) {
1371 if (pVBInfo->SetFlag &
1373 VCLKIndex = TVVCLKDIV2;
1381 } else { /* for CRT2 */
1383 VCLKIndex = (unsigned char) inb(
1384 (pVBInfo->P3ca + 0x02));
1385 VCLKIndex = ((VCLKIndex >> 2) & 0x03);
1386 if (ModeNo > 0x13) {
1387 /* di+Ext_CRTVCLK */
1390 RefreshRateTableIndex].
1392 VCLKIndex &= IndexMask;
1398 VCLKIndex = CRT2Index;
1400 VCLKIndex = CRT2Index;
1402 VCLKIndex = VCLKIndex >> 6;
1403 if ((pVBInfo->LCDResInfo == Panel800x600) ||
1404 (pVBInfo->LCDResInfo == Panel320x480))
1405 VCLKIndex = LVDSXlat1VCLK[VCLKIndex];
1406 else if ((pVBInfo->LCDResInfo == Panel1024x768) ||
1407 (pVBInfo->LCDResInfo == Panel1024x768x75))
1408 VCLKIndex = LVDSXlat2VCLK[VCLKIndex];
1410 VCLKIndex = LVDSXlat3VCLK[VCLKIndex];
1412 /* VCLKIndex = VCLKIndex&IndexMask; */
1417 static void XGI_SetCRT1VCLK(unsigned short ModeNo,
1418 unsigned short ModeIdIndex,
1419 struct xgi_hw_device_info *HwDeviceExtension,
1420 unsigned short RefreshRateTableIndex,
1421 struct vb_device_info *pVBInfo)
1423 unsigned char index, data;
1424 unsigned short vclkindex;
1426 if (pVBInfo->IF_DEF_LVDS == 1) {
1427 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1428 data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF;
1429 xgifb_reg_set(pVBInfo->P3c4, 0x31, data);
1430 xgifb_reg_set(pVBInfo->P3c4, 0x2B,
1431 pVBInfo->VCLKData[index].SR2B);
1432 xgifb_reg_set(pVBInfo->P3c4, 0x2C,
1433 pVBInfo->VCLKData[index].SR2C);
1434 xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01);
1435 } else if ((pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
1436 | VB_XGI302LV | VB_XGI301C)) && (pVBInfo->VBInfo
1438 vclkindex = XGI_GetVCLK2Ptr(ModeNo, ModeIdIndex,
1439 RefreshRateTableIndex, HwDeviceExtension,
1441 data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF;
1442 xgifb_reg_set(pVBInfo->P3c4, 0x31, data);
1443 data = pVBInfo->VBVCLKData[vclkindex].Part4_A;
1444 xgifb_reg_set(pVBInfo->P3c4, 0x2B, data);
1445 data = pVBInfo->VBVCLKData[vclkindex].Part4_B;
1446 xgifb_reg_set(pVBInfo->P3c4, 0x2C, data);
1447 xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01);
1449 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1450 data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF;
1451 xgifb_reg_set(pVBInfo->P3c4, 0x31, data);
1452 xgifb_reg_set(pVBInfo->P3c4, 0x2B,
1453 pVBInfo->VCLKData[index].SR2B);
1454 xgifb_reg_set(pVBInfo->P3c4, 0x2C,
1455 pVBInfo->VCLKData[index].SR2C);
1456 xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01);
1459 if (HwDeviceExtension->jChipType >= XG20) {
1460 if (pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag &
1462 data = xgifb_reg_get(pVBInfo->P3c4, 0x2B);
1463 xgifb_reg_set(pVBInfo->P3c4, 0x2B, data);
1464 data = xgifb_reg_get(pVBInfo->P3c4, 0x2C);
1471 xgifb_reg_set(pVBInfo->P3c4, 0x2C, data);
1476 static void XGI_SetCRT1FIFO(unsigned short ModeNo,
1477 struct xgi_hw_device_info *HwDeviceExtension,
1478 struct vb_device_info *pVBInfo)
1480 unsigned short data;
1482 data = xgifb_reg_get(pVBInfo->P3c4, 0x3D);
1484 xgifb_reg_set(pVBInfo->P3c4, 0x3D, data); /* diable auto-threshold */
1486 if (ModeNo > 0x13) {
1487 xgifb_reg_set(pVBInfo->P3c4, 0x08, 0x34);
1488 data = xgifb_reg_get(pVBInfo->P3c4, 0x09);
1490 xgifb_reg_set(pVBInfo->P3c4, 0x09, data | 0x30);
1491 data = xgifb_reg_get(pVBInfo->P3c4, 0x3D);
1493 xgifb_reg_set(pVBInfo->P3c4, 0x3D, data);
1495 if (HwDeviceExtension->jChipType == XG27) {
1496 xgifb_reg_set(pVBInfo->P3c4, 0x08, 0x0E);
1497 data = xgifb_reg_get(pVBInfo->P3c4, 0x09);
1499 xgifb_reg_set(pVBInfo->P3c4, 0x09, data | 0x20);
1501 xgifb_reg_set(pVBInfo->P3c4, 0x08, 0xAE);
1502 data = xgifb_reg_get(pVBInfo->P3c4, 0x09);
1504 xgifb_reg_set(pVBInfo->P3c4, 0x09, data);
1508 if (HwDeviceExtension->jChipType == XG21)
1509 XGI_SetXG21FPBits(pVBInfo); /* Fix SR9[7:6] can't read back */
1512 static void XGI_SetVCLKState(struct xgi_hw_device_info *HwDeviceExtension,
1513 unsigned short ModeNo, unsigned short RefreshRateTableIndex,
1514 struct vb_device_info *pVBInfo)
1516 unsigned short data, data2 = 0;
1519 unsigned char index;
1524 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1526 VCLK = pVBInfo->VCLKData[index].CLOCK;
1529 data = xgifb_reg_get(pVBInfo->P3c4, 0x32);
1532 data |= 0x0c; /* VCLK > 200 */
1534 if (HwDeviceExtension->jChipType >= XG20)
1535 data &= ~0x04; /* 2 pixel mode */
1537 xgifb_reg_set(pVBInfo->P3c4, 0x32, data);
1539 if (HwDeviceExtension->jChipType < XG20) {
1540 data = xgifb_reg_get(pVBInfo->P3c4, 0x1F);
1544 xgifb_reg_set(pVBInfo->P3c4, 0x1F, data);
1547 /* Jong for Adavantech LCD ripple issue
1548 if ((VCLK >= 0) && (VCLK < 135))
1550 else if ((VCLK >= 135) && (VCLK < 160))
1552 else if ((VCLK >= 160) && (VCLK < 260))
1554 else if (VCLK > 260)
1559 xgifb_reg_and_or(pVBInfo->P3c4, 0x07, 0xFC, data2);
1560 if (HwDeviceExtension->jChipType >= XG27)
1561 xgifb_reg_and_or(pVBInfo->P3c4, 0x40, 0xFC, data2 & 0x03);
1565 static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension,
1566 unsigned short ModeNo, unsigned short ModeIdIndex,
1567 unsigned short RefreshRateTableIndex,
1568 struct vb_device_info *pVBInfo)
1570 unsigned short data, data2, data3, infoflag = 0, modeflag, resindex,
1573 if (ModeNo > 0x13) {
1574 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1575 infoflag = pVBInfo->RefIndex[RefreshRateTableIndex].
1578 /* si+St_ModeFlag */
1579 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
1581 if (xgifb_reg_get(pVBInfo->P3d4, 0x31) & 0x01)
1582 xgifb_reg_and_or(pVBInfo->P3c4, 0x1F, 0x3F, 0x00);
1591 if (ModeNo > 0x13) {
1592 if (pVBInfo->ModeType > 0x02) {
1594 data3 = pVBInfo->ModeType - ModeVGA;
1600 data &= InterlaceMode;
1605 xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x3F, data2);
1606 /* xgifb_reg_set(pVBInfo->P3c4,0x06,data2); */
1607 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
1609 xres = pVBInfo->StResInfo[resindex].HTotal;
1611 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
1614 if (infoflag & InterlaceMode) {
1617 else if (xres == 1280)
1621 data2 = data & 0x00FF;
1622 xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFF, data2);
1623 data2 = (data & 0xFF00) >> 8;
1624 xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFC, data2);
1626 if (modeflag & HalfDCLK)
1627 xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xF7, 0x08);
1631 if (modeflag & LineCompareOff)
1634 if (ModeNo > 0x13) {
1635 if (pVBInfo->ModeType == ModeEGA)
1639 xgifb_reg_and_or(pVBInfo->P3c4, 0x0F, ~0x48, data2);
1641 if (pVBInfo->ModeType != ModeText) {
1643 if (pVBInfo->ModeType != ModeEGA)
1646 xgifb_reg_and_or(pVBInfo->P3c4, 0x21, 0x1F, data);
1648 XGI_SetVCLKState(HwDeviceExtension, ModeNo, RefreshRateTableIndex,
1651 /* if (modeflag&HalfDCLK) //030305 fix lowresolution bug */
1652 /* if (XGINew_IF_DEF_NEW_LOWRES) */
1653 /* XGI_VesaLowResolution(ModeNo, ModeIdIndex);
1654 * //030305 fix lowresolution bug */
1656 data = xgifb_reg_get(pVBInfo->P3d4, 0x31);
1658 if (HwDeviceExtension->jChipType == XG27) {
1663 xgifb_reg_set(pVBInfo->P3d4, 0x52, data);
1664 xgifb_reg_or(pVBInfo->P3d4, 0x51, 0x10);
1665 } else if (HwDeviceExtension->jChipType >= XG20) {
1670 xgifb_reg_set(pVBInfo->P3d4, 0x52, data);
1671 xgifb_reg_set(pVBInfo->P3d4, 0x51, 0x02);
1677 xgifb_reg_set(pVBInfo->P3d4, 0x52, data);
1683 void XGI_VesaLowResolution(unsigned short ModeNo,
1684 unsigned short ModeIdIndex,
1685 struct vb_device_info *pVBInfo)
1687 unsigned short modeflag;
1690 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1692 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
1694 if (ModeNo > 0x13) {
1695 if (modeflag & DoubleScanMode) {
1696 if (modeflag & HalfDCLK) {
1697 if (pVBInfo->VBType & VB_XGI301B |
1702 if (!(pVBInfo->VBInfo &
1704 if (pVBInfo->VBInfo &
1720 xgifb_reg_and_or(pVBInfo->P3c4,
1724 xgifb_reg_and_or(pVBInfo->P3c4,
1732 xgifb_reg_and_or(pVBInfo->P3c4, 0x0f, 0x7f, 0x00);
1736 static void XGI_WriteDAC(unsigned short dl,
1740 struct vb_device_info *pVBInfo)
1742 unsigned short temp, bh, bl;
1761 outb((unsigned short) dh, pVBInfo->P3c9);
1762 outb((unsigned short) bh, pVBInfo->P3c9);
1763 outb((unsigned short) bl, pVBInfo->P3c9);
1766 static void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex,
1767 struct vb_device_info *pVBInfo)
1769 unsigned short data, data2, time, i, j, k, m, n, o, si, di, bx, dl, al,
1770 ah, dh, *table = NULL;
1773 data = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
1775 data = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1777 data &= DACInfoFlag;
1781 table = XGINew_MDA_DAC;
1782 else if (data == 0x08)
1783 table = XGINew_CGA_DAC;
1784 else if (data == 0x10)
1785 table = XGINew_EGA_DAC;
1786 else if (data == 0x18) {
1788 table = XGINew_VGA_DAC;
1796 outb(0xFF, pVBInfo->P3c6);
1797 outb(0x00, pVBInfo->P3c8);
1799 for (i = 0; i < j; i++) {
1802 for (k = 0; k < 3; k++) {
1811 outb(data2, pVBInfo->P3c9);
1817 for (i = 16; i < 32; i++) {
1820 for (k = 0; k < 3; k++)
1821 outb(data, pVBInfo->P3c9);
1826 for (m = 0; m < 9; m++) {
1831 for (n = 0; n < 3; n++) {
1832 for (o = 0; o < 5; o++) {
1837 XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
1842 for (o = 0; o < 3; o++) {
1847 XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
1858 static void XGI_GetLVDSResInfo(unsigned short ModeNo,
1859 unsigned short ModeIdIndex,
1860 struct vb_device_info *pVBInfo)
1862 unsigned short resindex, xres, yres, modeflag;
1866 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
1868 /* si+Ext_ResInfo */
1869 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
1871 /* if (ModeNo > 0x13) */
1872 /* modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; */
1874 /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; */
1878 resindex = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
1880 /* si+Ext_ResInfo */
1881 resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
1883 /* resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); */
1885 if (ModeNo <= 0x13) {
1886 xres = pVBInfo->StResInfo[resindex].HTotal;
1887 yres = pVBInfo->StResInfo[resindex].VTotal;
1889 xres = pVBInfo->ModeResInfo[resindex].HTotal;
1890 yres = pVBInfo->ModeResInfo[resindex].VTotal;
1892 if (ModeNo > 0x13) {
1893 if (modeflag & HalfDCLK)
1896 if (modeflag & DoubleScanMode)
1899 /* if (modeflag & Charx8Dot) */
1906 pVBInfo->VGAHDE = xres;
1907 pVBInfo->HDE = xres;
1908 pVBInfo->VGAVDE = yres;
1909 pVBInfo->VDE = yres;
1912 static void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo,
1913 unsigned short ModeIdIndex,
1914 unsigned short RefreshRateTableIndex,
1915 struct vb_device_info *pVBInfo)
1917 unsigned short i, tempdx, tempcx, tempbx, tempal, modeflag, table;
1919 struct XGI330_LCDDataTablStruct *tempdi = NULL;
1923 if (ModeNo <= 0x13) {
1924 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
1925 tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
1927 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1928 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
1931 tempal = tempal & 0x0f;
1933 if (tempbx <= 1) { /* ExpLink */
1934 if (ModeNo <= 0x13) {
1935 /* find no Ext_CRT2CRTC2 */
1936 tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
1938 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].
1942 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
1944 tempal = pVBInfo->SModeIDTable[ModeIdIndex].
1947 tempal = pVBInfo->RefIndex[
1948 RefreshRateTableIndex].
1953 tempal = (tempal >> 4);
1955 tempal = (tempal & 0x0f);
1958 tempcx = LCDLenList[tempbx]; /* mov cl,byte ptr cs:LCDLenList[bx] */
1960 if (pVBInfo->LCDInfo & EnableScalingLCD) { /* ScaleLCD */
1961 if ((tempbx == 5) || (tempbx) == 7)
1962 tempcx = LCDDesDataLen2;
1963 else if ((tempbx == 3) || (tempbx == 8))
1964 tempcx = LVDSDesDataLen2;
1966 /* mov di, word ptr cs:LCDDataList[bx] */
1967 /* tempdi = pVideoMemory[LCDDataList + tempbx * 2] |
1968 (pVideoMemory[LCDDataList + tempbx * 2 + 1] << 8); */
1972 tempdi = XGI_EPLLCDCRT1Ptr_H;
1975 tempdi = XGI_EPLLCDCRT1Ptr_V;
1978 tempdi = XGI_EPLLCDDataPtr;
1981 tempdi = XGI_EPLLCDDesDataPtr;
1984 tempdi = XGI_LCDDataTable;
1987 tempdi = XGI_LCDDesDataTable;
1990 tempdi = XGI_EPLCHLCDRegPtr;
2001 if (tempdi == NULL) /* OEMUtil */
2007 while (tempdi[i].PANELID != 0xff) {
2008 tempdx = pVBInfo->LCDResInfo;
2009 if (tempbx & 0x0080) { /* OEMUtil */
2010 tempbx &= (~0x0080);
2011 tempdx = pVBInfo->LCDTypeInfo;
2014 if (pVBInfo->LCDInfo & EnableScalingLCD)
2015 tempdx &= (~PanelResInfo);
2017 if (tempdi[i].PANELID == tempdx) {
2018 tempbx = tempdi[i].MASK;
2019 tempdx = pVBInfo->LCDInfo;
2021 if (ModeNo <= 0x13) /* alan 09/10/2003 */
2022 tempdx |= SetLCDStdMode;
2024 if (modeflag & HalfDCLK)
2025 tempdx |= SetLCDLowResolution;
2028 if (tempbx == tempdi[i].CAP)
2035 switch (tempdi[i].DATAPTR) {
2037 return &XGI_LVDSCRT11024x768_1_H[tempal];
2040 return &XGI_LVDSCRT11024x768_2_H[tempal];
2043 return &XGI_LVDSCRT11280x1024_1_H[tempal];
2046 return &XGI_LVDSCRT11280x1024_2_H[tempal];
2049 return &XGI_LVDSCRT11400x1050_1_H[tempal];
2052 return &XGI_LVDSCRT11400x1050_2_H[tempal];
2055 return &XGI_LVDSCRT11600x1200_1_H[tempal];
2058 return &XGI_LVDSCRT11024x768_1_Hx75[tempal];
2061 return &XGI_LVDSCRT11024x768_2_Hx75[tempal];
2064 return &XGI_LVDSCRT11280x1024_1_Hx75[tempal];
2067 return &XGI_LVDSCRT11280x1024_2_Hx75[tempal];
2072 } else if (table == 1) {
2073 switch (tempdi[i].DATAPTR) {
2075 return &XGI_LVDSCRT11024x768_1_V[tempal];
2078 return &XGI_LVDSCRT11024x768_2_V[tempal];
2081 return &XGI_LVDSCRT11280x1024_1_V[tempal];
2084 return &XGI_LVDSCRT11280x1024_2_V[tempal];
2087 return &XGI_LVDSCRT11400x1050_1_V[tempal];
2090 return &XGI_LVDSCRT11400x1050_2_V[tempal];
2093 return &XGI_LVDSCRT11600x1200_1_V[tempal];
2096 return &XGI_LVDSCRT11024x768_1_Vx75[tempal];
2099 return &XGI_LVDSCRT11024x768_2_Vx75[tempal];
2102 return &XGI_LVDSCRT11280x1024_1_Vx75[tempal];
2105 return &XGI_LVDSCRT11280x1024_2_Vx75[tempal];
2110 } else if (table == 2) {
2111 switch (tempdi[i].DATAPTR) {
2113 return &XGI_LVDS1024x768Data_1[tempal];
2116 return &XGI_LVDS1024x768Data_2[tempal];
2119 return &XGI_LVDS1280x1024Data_1[tempal];
2122 return &XGI_LVDS1280x1024Data_2[tempal];
2125 return &XGI_LVDS1400x1050Data_1[tempal];
2128 return &XGI_LVDS1400x1050Data_2[tempal];
2131 return &XGI_LVDS1600x1200Data_1[tempal];
2134 return &XGI_LVDSNoScalingData[tempal];
2137 return &XGI_LVDS1024x768Data_1x75[tempal];
2140 return &XGI_LVDS1024x768Data_2x75[tempal];
2143 return &XGI_LVDS1280x1024Data_1x75[tempal];
2146 return &XGI_LVDS1280x1024Data_2x75[tempal];
2149 return &XGI_LVDSNoScalingDatax75[tempal];
2154 } else if (table == 3) {
2155 switch (tempdi[i].DATAPTR) {
2157 return &XGI_LVDS1024x768Des_1[tempal];
2160 return &XGI_LVDS1024x768Des_3[tempal];
2163 return &XGI_LVDS1024x768Des_2[tempal];
2166 return &XGI_LVDS1280x1024Des_1[tempal];
2169 return &XGI_LVDS1280x1024Des_2[tempal];
2172 return &XGI_LVDS1400x1050Des_1[tempal];
2175 return &XGI_LVDS1400x1050Des_2[tempal];
2178 return &XGI_LVDS1600x1200Des_1[tempal];
2181 return &XGI_LVDSNoScalingDesData[tempal];
2184 return &XGI_LVDS1024x768Des_1x75[tempal];
2187 return &XGI_LVDS1024x768Des_3x75[tempal];
2190 return &XGI_LVDS1024x768Des_2x75[tempal];
2193 return &XGI_LVDS1280x1024Des_1x75[tempal];
2196 return &XGI_LVDS1280x1024Des_2x75[tempal];
2199 return &XGI_LVDSNoScalingDesDatax75[tempal];
2204 } else if (table == 4) {
2205 switch (tempdi[i].DATAPTR) {
2207 return &XGI_ExtLCD1024x768Data[tempal];
2210 return &XGI_StLCD1024x768Data[tempal];
2213 return &XGI_CetLCD1024x768Data[tempal];
2216 return &XGI_ExtLCD1280x1024Data[tempal];
2219 return &XGI_StLCD1280x1024Data[tempal];
2222 return &XGI_CetLCD1280x1024Data[tempal];
2225 return &XGI_ExtLCD1400x1050Data[tempal];
2228 return &XGI_StLCD1400x1050Data[tempal];
2231 return &XGI_CetLCD1400x1050Data[tempal];
2234 return &XGI_ExtLCD1600x1200Data[tempal];
2237 return &XGI_StLCD1600x1200Data[tempal];
2240 return &XGI_NoScalingData[tempal];
2243 return &XGI_ExtLCD1024x768x75Data[tempal];
2246 return &XGI_ExtLCD1024x768x75Data[tempal];
2249 return &XGI_CetLCD1024x768x75Data[tempal];
2252 return &XGI_ExtLCD1280x1024x75Data[tempal];
2255 return &XGI_StLCD1280x1024x75Data[tempal];
2258 return &XGI_CetLCD1280x1024x75Data[tempal];
2261 return &XGI_NoScalingDatax75[tempal];
2266 } else if (table == 5) {
2267 switch (tempdi[i].DATAPTR) {
2269 return &XGI_ExtLCDDes1024x768Data[tempal];
2272 return &XGI_StLCDDes1024x768Data[tempal];
2275 return &XGI_CetLCDDes1024x768Data[tempal];
2278 if ((pVBInfo->VBType & VB_XGI301LV) ||
2279 (pVBInfo->VBType & VB_XGI302LV))
2280 return &XGI_ExtLCDDLDes1280x1024Data[tempal];
2282 return &XGI_ExtLCDDes1280x1024Data[tempal];
2285 if ((pVBInfo->VBType & VB_XGI301LV) ||
2286 (pVBInfo->VBType & VB_XGI302LV))
2287 return &XGI_StLCDDLDes1280x1024Data[tempal];
2289 return &XGI_StLCDDes1280x1024Data[tempal];
2292 if ((pVBInfo->VBType & VB_XGI301LV) ||
2293 (pVBInfo->VBType & VB_XGI302LV))
2294 return &XGI_CetLCDDLDes1280x1024Data[tempal];
2296 return &XGI_CetLCDDes1280x1024Data[tempal];
2299 if ((pVBInfo->VBType & VB_XGI301LV) ||
2300 (pVBInfo->VBType & VB_XGI302LV))
2301 return &XGI_ExtLCDDLDes1400x1050Data[tempal];
2303 return &XGI_ExtLCDDes1400x1050Data[tempal];
2306 if ((pVBInfo->VBType & VB_XGI301LV) ||
2307 (pVBInfo->VBType & VB_XGI302LV))
2308 return &XGI_StLCDDLDes1400x1050Data[tempal];
2310 return &XGI_StLCDDes1400x1050Data[tempal];
2313 return &XGI_CetLCDDes1400x1050Data[tempal];
2316 return &XGI_CetLCDDes1400x1050Data2[tempal];
2319 if ((pVBInfo->VBType & VB_XGI301LV) ||
2320 (pVBInfo->VBType & VB_XGI302LV))
2321 return &XGI_ExtLCDDLDes1600x1200Data[tempal];
2323 return &XGI_ExtLCDDes1600x1200Data[tempal];
2326 if ((pVBInfo->VBType & VB_XGI301LV) ||
2327 (pVBInfo->VBType & VB_XGI302LV))
2328 return &XGI_StLCDDLDes1600x1200Data[tempal];
2330 return &XGI_StLCDDes1600x1200Data[tempal];
2333 return &XGI_NoScalingDesData[tempal];
2336 return &XGI_ExtLCDDes1024x768x75Data[tempal];
2339 return &XGI_StLCDDes1024x768x75Data[tempal];
2342 return &XGI_CetLCDDes1024x768x75Data[tempal];
2345 if ((pVBInfo->VBType & VB_XGI301LV) ||
2346 (pVBInfo->VBType & VB_XGI302LV))
2347 return &XGI_ExtLCDDLDes1280x1024x75Data[tempal];
2349 return &XGI_ExtLCDDes1280x1024x75Data[tempal];
2352 if ((pVBInfo->VBType & VB_XGI301LV) ||
2353 (pVBInfo->VBType & VB_XGI302LV))
2354 return &XGI_StLCDDLDes1280x1024x75Data[tempal];
2356 return &XGI_StLCDDes1280x1024x75Data[tempal];
2359 if ((pVBInfo->VBType & VB_XGI301LV) ||
2360 (pVBInfo->VBType & VB_XGI302LV))
2361 return &XGI_CetLCDDLDes1280x1024x75Data[tempal];
2363 return &XGI_CetLCDDes1280x1024x75Data[tempal];
2366 return &XGI_NoScalingDesDatax75[tempal];
2371 } else if (table == 6) {
2372 switch (tempdi[i].DATAPTR) {
2374 return &XGI_CH7017LV1024x768[tempal];
2377 return &XGI_CH7017LV1400x1050[tempal];
2386 static void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo,
2387 unsigned short ModeIdIndex,
2388 unsigned short RefreshRateTableIndex,
2389 struct vb_device_info *pVBInfo)
2391 unsigned short i, tempdx, tempbx, tempal, modeflag, table;
2392 struct XGI330_TVDataTablStruct *tempdi = NULL;
2396 if (ModeNo <= 0x13) {
2397 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
2398 tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
2400 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2401 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
2404 tempal = tempal & 0x3f;
2409 tempdi = NULL; /*EPLCHTVCRT1Ptr_H;*/
2412 tempdi = NULL; /*EPLCHTVCRT1Ptr_V;*/
2415 tempdi = XGI_EPLCHTVDataPtr;
2421 tempdi = XGI_TVDataTable;
2427 tempdi = XGI_EPLCHTVRegPtr;
2433 if (tempdi == NULL) /* OEMUtil */
2436 tempdx = pVBInfo->TVInfo;
2438 if (pVBInfo->VBInfo & SetInSlaveMode)
2439 tempdx = tempdx | SetTVLockMode;
2441 if (modeflag & HalfDCLK)
2442 tempdx = tempdx | SetTVLowResolution;
2446 while (tempdi[i].MASK != 0xffff) {
2447 if ((tempdx & tempdi[i].MASK) == tempdi[i].CAP)
2453 if (table == 0x00) {
2454 } else if (table == 0x01) {
2455 } else if (table == 0x04) {
2456 switch (tempdi[i].DATAPTR) {
2458 return &XGI_ExtPALData[tempal];
2461 return &XGI_ExtNTSCData[tempal];
2464 return &XGI_StPALData[tempal];
2467 return &XGI_StNTSCData[tempal];
2470 return &XGI_ExtHiTVData[tempal];
2473 return &XGI_St2HiTVData[tempal];
2476 return &XGI_ExtYPbPr525iData[tempal];
2479 return &XGI_ExtYPbPr525pData[tempal];
2482 return &XGI_ExtYPbPr750pData[tempal];
2485 return &XGI_StYPbPr525iData[tempal];
2488 return &XGI_StYPbPr525pData[tempal];
2491 return &XGI_StYPbPr750pData[tempal];
2493 case 12: /* avoid system hang */
2494 return &XGI_ExtNTSCData[tempal];
2497 return &XGI_St1HiTVData[tempal];
2502 } else if (table == 0x02) {
2503 switch (tempdi[i].DATAPTR) {
2505 return &XGI_CHTVUNTSCData[tempal];
2508 return &XGI_CHTVONTSCData[tempal];
2511 return &XGI_CHTVUPALData[tempal];
2514 return &XGI_CHTVOPALData[tempal];
2519 } else if (table == 0x06) {
2524 static void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex,
2525 unsigned short RefreshRateTableIndex,
2526 struct vb_device_info *pVBInfo)
2528 unsigned short tempbx;
2529 struct XGI330_LVDSDataStruct *LCDPtr = NULL;
2533 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
2534 LCDPtr = (struct XGI330_LVDSDataStruct *) XGI_GetLcdPtr(tempbx,
2535 ModeNo, ModeIdIndex, RefreshRateTableIndex,
2537 pVBInfo->VGAHT = LCDPtr->VGAHT;
2538 pVBInfo->VGAVT = LCDPtr->VGAVT;
2539 pVBInfo->HT = LCDPtr->LCDHT;
2540 pVBInfo->VT = LCDPtr->LCDVT;
2543 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
2544 if (!(pVBInfo->LCDInfo & (SetLCDtoNonExpanding
2545 | EnableScalingLCD))) {
2546 if ((pVBInfo->LCDResInfo == Panel1024x768) ||
2547 (pVBInfo->LCDResInfo == Panel1024x768x75)) {
2548 pVBInfo->HDE = 1024;
2550 } else if ((pVBInfo->LCDResInfo == Panel1280x1024) ||
2551 (pVBInfo->LCDResInfo == Panel1280x1024x75)) {
2552 pVBInfo->HDE = 1280;
2553 pVBInfo->VDE = 1024;
2554 } else if (pVBInfo->LCDResInfo == Panel1400x1050) {
2555 pVBInfo->HDE = 1400;
2556 pVBInfo->VDE = 1050;
2558 pVBInfo->HDE = 1600;
2559 pVBInfo->VDE = 1200;
2565 static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex,
2566 unsigned short RefreshRateTableIndex,
2567 struct xgi_hw_device_info *HwDeviceExtension,
2568 struct vb_device_info *pVBInfo)
2570 unsigned char index;
2571 unsigned short tempbx, i;
2572 struct XGI_LVDSCRT1HDataStruct *LCDPtr = NULL;
2573 struct XGI_LVDSCRT1VDataStruct *LCDPtr1 = NULL;
2576 index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
2578 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
2580 index = index & IndexMask;
2582 if ((pVBInfo->IF_DEF_ScaleLCD == 0) ||
2583 ((pVBInfo->IF_DEF_ScaleLCD == 1) &&
2584 (!(pVBInfo->LCDInfo & EnableScalingLCD)))) {
2587 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
2588 LCDPtr = (struct XGI_LVDSCRT1HDataStruct *)
2589 XGI_GetLcdPtr(tempbx, ModeNo,
2591 RefreshRateTableIndex,
2594 for (i = 0; i < 8; i++)
2595 pVBInfo->TimingH[0].data[i] = LCDPtr[0].Reg[i];
2598 XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension);
2602 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
2603 LCDPtr1 = (struct XGI_LVDSCRT1VDataStruct *)
2608 RefreshRateTableIndex,
2610 for (i = 0; i < 7; i++)
2611 pVBInfo->TimingV[0].data[i] = LCDPtr1[0].Reg[i];
2614 XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo);
2618 static unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo)
2620 unsigned char tempal, tempah, tempbl, i;
2622 tempah = xgifb_reg_get(pVBInfo->P3d4, 0x36);
2623 tempal = tempah & 0x0F;
2624 tempah = tempah & 0xF0;
2626 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
2628 while (tempbl != 0xFF) {
2629 if (tempbl & 0x80) { /* OEMUtil */
2631 tempbl = tempbl & ~(0x80);
2634 if (tempal == tempbl)
2639 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
2645 static unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo)
2647 unsigned short tempah, tempal, tempbl, i;
2649 tempal = pVBInfo->LCDResInfo;
2650 tempah = pVBInfo->LCDTypeInfo;
2653 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
2655 while (tempbl != 0xFF) {
2656 if ((tempbl & 0x80) && (tempbl != 0x80)) {
2661 if (tempal == tempbl)
2665 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
2668 if (tempbl == 0xFF) {
2669 pVBInfo->LCDResInfo = Panel1024x768;
2670 pVBInfo->LCDTypeInfo = 0;
2677 static void XGI_GetLCDSync(unsigned short *HSyncWidth,
2678 unsigned short *VSyncWidth,
2679 struct vb_device_info *pVBInfo)
2681 unsigned short Index;
2683 Index = XGI_GetLCDCapPtr(pVBInfo);
2684 *HSyncWidth = pVBInfo->LCDCapList[Index].LCD_HSyncWidth;
2685 *VSyncWidth = pVBInfo->LCDCapList[Index].LCD_VSyncWidth;
2690 static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
2691 unsigned short RefreshRateTableIndex,
2692 struct vb_device_info *pVBInfo)
2694 unsigned short tempbx, tempax, tempcx, tempdx, push1, push2, modeflag;
2695 unsigned long temp, temp1, temp2, temp3, push3;
2696 struct XGI330_LCDDataDesStruct *LCDPtr = NULL;
2697 struct XGI330_LCDDataDesStruct2 *LCDPtr1 = NULL;
2700 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2702 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
2704 if (!(pVBInfo->SetFlag & Win9xDOSMode)) {
2705 if (pVBInfo->IF_DEF_OEMUtil == 1) {
2707 LCDPtr = (struct XGI330_LCDDataDesStruct *)
2708 XGI_GetLcdPtr(tempbx,
2711 RefreshRateTableIndex,
2715 if ((pVBInfo->IF_DEF_OEMUtil == 0) ||
2718 if (pVBInfo->LCDInfo & EnableScalingLCD)
2720 (struct XGI330_LCDDataDesStruct2 *)
2725 RefreshRateTableIndex,
2729 (struct XGI330_LCDDataDesStruct *)
2734 RefreshRateTableIndex,
2738 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
2743 if ((pVBInfo->LCDResInfo == Panel1024x768) ||
2744 (pVBInfo->LCDResInfo == Panel1024x768x75)) {
2747 } else if ((pVBInfo->LCDResInfo == Panel1280x1024) ||
2748 (pVBInfo->LCDResInfo == Panel1280x1024x75)) {
2751 } else if (pVBInfo->LCDResInfo == Panel1400x1050) {
2759 if (pVBInfo->LCDInfo & SetLCDtoNonExpanding) {
2760 pVBInfo->HDE = tempax;
2761 pVBInfo->VDE = tempbx;
2762 pVBInfo->VGAHDE = tempax;
2763 pVBInfo->VGAVDE = tempbx;
2766 if ((pVBInfo->IF_DEF_ScaleLCD == 1) &&
2767 (pVBInfo->LCDInfo & EnableScalingLCD)) {
2768 tempax = pVBInfo->HDE;
2769 tempbx = pVBInfo->VDE;
2772 tempax = pVBInfo->HT;
2774 if (pVBInfo->LCDInfo & EnableScalingLCD)
2775 tempbx = LCDPtr1->LCDHDES;
2777 tempbx = LCDPtr->LCDHDES;
2779 tempcx = pVBInfo->HDE;
2780 tempbx = tempbx & 0x0fff;
2783 if (tempcx >= tempax)
2786 xgifb_reg_set(pVBInfo->Part1Port, 0x1A, tempbx & 0x07);
2788 tempcx = tempcx >> 3;
2789 tempbx = tempbx >> 3;
2791 xgifb_reg_set(pVBInfo->Part1Port, 0x16,
2792 (unsigned short) (tempbx & 0xff));
2793 xgifb_reg_set(pVBInfo->Part1Port, 0x17,
2794 (unsigned short) (tempcx & 0xff));
2796 tempax = pVBInfo->HT;
2798 if (pVBInfo->LCDInfo & EnableScalingLCD)
2799 tempbx = LCDPtr1->LCDHRS;
2801 tempbx = LCDPtr->LCDHRS;
2805 if (pVBInfo->LCDInfo & EnableScalingLCD)
2806 tempcx = LCDPtr1->LCDHSync;
2810 if (tempcx >= tempax)
2813 tempax = tempbx & 0x07;
2814 tempax = tempax >> 5;
2815 tempcx = tempcx >> 3;
2816 tempbx = tempbx >> 3;
2821 xgifb_reg_set(pVBInfo->Part1Port, 0x15, tempax);
2822 xgifb_reg_set(pVBInfo->Part1Port, 0x14,
2823 (unsigned short) (tempbx & 0xff));
2825 tempax = pVBInfo->VT;
2826 if (pVBInfo->LCDInfo & EnableScalingLCD)
2827 tempbx = LCDPtr1->LCDVDES;
2829 tempbx = LCDPtr->LCDVDES;
2830 tempcx = pVBInfo->VDE;
2832 tempbx = tempbx & 0x0fff;
2834 if (tempcx >= tempax)
2837 xgifb_reg_set(pVBInfo->Part1Port, 0x1b,
2838 (unsigned short) (tempbx & 0xff));
2839 xgifb_reg_set(pVBInfo->Part1Port, 0x1c,
2840 (unsigned short) (tempcx & 0xff));
2842 tempbx = (tempbx >> 8) & 0x07;
2843 tempcx = (tempcx >> 8) & 0x07;
2845 xgifb_reg_set(pVBInfo->Part1Port, 0x1d,
2846 (unsigned short) ((tempcx << 3)
2849 tempax = pVBInfo->VT;
2850 if (pVBInfo->LCDInfo & EnableScalingLCD)
2851 tempbx = LCDPtr1->LCDVRS;
2853 tempbx = LCDPtr->LCDVRS;
2855 /* tempbx = tempbx >> 4; */
2858 if (pVBInfo->LCDInfo & EnableScalingLCD)
2859 tempcx = LCDPtr1->LCDVSync;
2862 if (tempcx >= tempax)
2865 xgifb_reg_set(pVBInfo->Part1Port, 0x18,
2866 (unsigned short) (tempbx & 0xff));
2867 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, ~0x0f,
2868 (unsigned short) (tempcx & 0x0f));
2870 tempax = ((tempbx >> 8) & 0x07) << 3;
2872 tempbx = pVBInfo->VGAVDE;
2873 if (tempbx != pVBInfo->VDE)
2876 if (pVBInfo->LCDInfo & EnableLVDSDDA)
2879 xgifb_reg_and_or(pVBInfo->Part1Port, 0x1a, 0x07,
2882 tempcx = pVBInfo->VGAVT;
2883 tempbx = pVBInfo->VDE;
2884 tempax = pVBInfo->VGAVDE;
2887 temp = tempax; /* 0430 ylshieh */
2888 temp1 = (temp << 18) / tempbx;
2890 tempdx = (unsigned short) ((temp << 18) % tempbx);
2898 xgifb_reg_set(pVBInfo->Part1Port, 0x37,
2899 (unsigned short) (temp2 & 0xff));
2900 xgifb_reg_set(pVBInfo->Part1Port, 0x36,
2901 (unsigned short) ((temp2 >> 8) & 0xff));
2903 tempbx = (unsigned short) (temp2 >> 16);
2904 tempax = tempbx & 0x03;
2906 tempbx = pVBInfo->VGAVDE;
2907 if (tempbx == pVBInfo->VDE)
2910 xgifb_reg_set(pVBInfo->Part1Port, 0x35, tempax);
2912 if (pVBInfo->VBType & VB_XGI301C) {
2914 xgifb_reg_set(pVBInfo->Part4Port,
2916 (unsigned short) (temp2 & 0xff));
2917 xgifb_reg_set(pVBInfo->Part4Port,
2919 (unsigned short) ((temp2 >> 8) &
2921 tempbx = (unsigned short) (temp2 >> 16);
2922 xgifb_reg_and_or(pVBInfo->Part4Port, 0x3a,
2924 (unsigned short) ((tempbx &
2927 tempcx = pVBInfo->VGAVDE;
2928 if (tempcx == pVBInfo->VDE)
2929 xgifb_reg_and_or(pVBInfo->Part4Port,
2932 xgifb_reg_and_or(pVBInfo->Part4Port,
2936 tempcx = pVBInfo->VGAHDE;
2937 tempbx = pVBInfo->HDE;
2939 temp1 = tempcx << 16;
2941 tempax = (unsigned short) (temp1 / tempbx);
2943 if ((tempbx & 0xffff) == (tempcx & 0xffff))
2947 temp1 = pVBInfo->VGAHDE << 16;
2950 temp3 = temp3 << 16;
2953 temp3 = (temp3 & 0xffff0000) + (temp1 & 0xffff);
2955 tempax = (unsigned short) (temp3 & 0xff);
2956 xgifb_reg_set(pVBInfo->Part1Port, 0x1f, tempax);
2958 temp1 = pVBInfo->VGAVDE << 18;
2959 temp1 = temp1 / push3;
2960 tempbx = (unsigned short) (temp1 & 0xffff);
2962 if (pVBInfo->LCDResInfo == Panel1024x768)
2965 tempax = ((tempbx >> 8) & 0xff) << 3;
2966 tempax |= (unsigned short) ((temp3 >> 8) & 0x07);
2967 xgifb_reg_set(pVBInfo->Part1Port, 0x20,
2968 (unsigned short) (tempax & 0xff));
2969 xgifb_reg_set(pVBInfo->Part1Port, 0x21,
2970 (unsigned short) (tempbx & 0xff));
2972 temp3 = temp3 >> 16;
2974 if (modeflag & HalfDCLK)
2977 xgifb_reg_set(pVBInfo->Part1Port, 0x22,
2978 (unsigned short) ((temp3 >> 8) & 0xff));
2979 xgifb_reg_set(pVBInfo->Part1Port, 0x23,
2980 (unsigned short) (temp3 & 0xff));
2984 /* --------------------------------------------------------------------- */
2985 /* Function : XGI_GETLCDVCLKPtr */
2987 /* Output : al -> VCLK Index */
2989 /* --------------------------------------------------------------------- */
2990 static void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1,
2991 struct vb_device_info *pVBInfo)
2993 unsigned short index;
2995 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
2996 if (pVBInfo->IF_DEF_ScaleLCD == 1) {
2997 if (pVBInfo->LCDInfo & EnableScalingLCD)
3001 /* index = XGI_GetLCDCapPtr(pVBInfo); */
3002 index = XGI_GetLCDCapPtr1(pVBInfo);
3004 if (pVBInfo->VBInfo & SetCRT2ToLCD) { /* LCDB */
3005 *di_0 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData1;
3006 *di_1 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData2;
3008 *di_0 = pVBInfo->LCDCapList[index].LCDA_VCLKData1;
3009 *di_1 = pVBInfo->LCDCapList[index].LCDA_VCLKData2;
3015 static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex,
3016 unsigned short ModeNo, unsigned short ModeIdIndex,
3017 struct vb_device_info *pVBInfo)
3020 unsigned short index, modeflag;
3021 unsigned char tempal;
3025 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
3027 /* si+Ext_ResInfo */
3028 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3030 if ((pVBInfo->SetFlag & ProgrammingCRT2) &&
3031 (!(pVBInfo->LCDInfo & EnableScalingLCD))) { /* {LCDA/LCDB} */
3032 index = XGI_GetLCDCapPtr(pVBInfo);
3033 tempal = pVBInfo->LCDCapList[index].LCD_VCLK;
3035 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))
3039 if (pVBInfo->VBType &
3045 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
3046 tempal = HiTVVCLKDIV2;
3047 if (!(pVBInfo->TVInfo & RPLLDIV2XO))
3049 if (pVBInfo->TVInfo & TVSimuMode) {
3050 tempal = HiTVSimuVCLK;
3051 if (!(modeflag & Charx8Dot))
3052 tempal = HiTVTextVCLK;
3058 if (pVBInfo->TVInfo & SetYPbPrMode750p) {
3059 tempal = YPbPr750pVCLK;
3063 if (pVBInfo->TVInfo & SetYPbPrMode525p) {
3064 tempal = YPbPr525pVCLK;
3068 tempal = NTSC1024VCLK;
3070 if (!(pVBInfo->TVInfo & NTSC1024x768)) {
3071 tempal = TVVCLKDIV2;
3072 if (!(pVBInfo->TVInfo & RPLLDIV2XO))
3076 if (pVBInfo->VBInfo & SetCRT2ToTV)
3081 tempal = (unsigned char) inb((pVBInfo->P3ca + 0x02));
3082 tempal = tempal >> 2;
3085 /* for Dot8 Scaling LCD */
3086 if ((pVBInfo->LCDInfo & EnableScalingLCD) && (modeflag & Charx8Dot))
3087 tempal = tempal ^ tempal; /* ; set to VCLK25MHz always */
3092 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
3096 static void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0,
3097 unsigned char *di_1, struct vb_device_info *pVBInfo)
3099 if (pVBInfo->VBType & (VB_XGI301 | VB_XGI301B | VB_XGI302B
3100 | VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
3101 if ((!(pVBInfo->VBInfo & SetCRT2ToLCDA)) && (pVBInfo->SetFlag
3102 & ProgrammingCRT2)) {
3103 *di_0 = (unsigned char) XGI_VBVCLKData[tempal].SR2B;
3104 *di_1 = XGI_VBVCLKData[tempal].SR2C;
3107 *di_0 = XGI_VCLKData[tempal].SR2B;
3108 *di_1 = XGI_VCLKData[tempal].SR2C;
3112 static void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex,
3113 unsigned short RefreshRateTableIndex,
3114 struct vb_device_info *pVBInfo)
3116 unsigned char di_0, di_1, tempal;
3119 tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex,
3121 XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo);
3122 XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo);
3124 for (i = 0; i < 4; i++) {
3125 xgifb_reg_and_or(pVBInfo->P3d4, 0x31, ~0x30,
3126 (unsigned short) (0x10 * i));
3127 if ((!(pVBInfo->VBInfo & SetCRT2ToLCDA))
3128 && (!(pVBInfo->VBInfo & SetInSlaveMode))) {
3129 xgifb_reg_set(pVBInfo->P3c4, 0x2e, di_0);
3130 xgifb_reg_set(pVBInfo->P3c4, 0x2f, di_1);
3132 xgifb_reg_set(pVBInfo->P3c4, 0x2b, di_0);
3133 xgifb_reg_set(pVBInfo->P3c4, 0x2c, di_1);
3138 static void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension,
3139 struct vb_device_info *pVBInfo)
3141 unsigned short tempcl, tempch, temp, tempbl, tempax;
3143 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
3144 | VB_XGI302LV | VB_XGI301C)) {
3147 temp = xgifb_reg_get(pVBInfo->P3c4, 0x01);
3149 if (!(temp & 0x20)) {
3150 temp = xgifb_reg_get(pVBInfo->P3d4, 0x17);
3152 temp = xgifb_reg_get(pVBInfo->P3d4, 0x53);
3154 tempcl |= ActiveCRT1;
3158 temp = xgifb_reg_get(pVBInfo->Part1Port, 0x2e);
3161 if (!(temp == 0x08)) {
3162 /* Check ChannelA by Part1_13 [2003/10/03] */
3163 tempax = xgifb_reg_get(pVBInfo->Part1Port, 0x13);
3165 tempcl = tempcl | ActiveLCD;
3169 if (!(tempcl & ActiveLCD))
3171 tempcl |= ActiveCRT2;
3174 tempcl |= ActiveLCD;
3177 temp = xgifb_reg_get(pVBInfo->Part2Port, 0x00);
3180 tempch |= ActiveAVideo;
3183 tempch |= ActiveSVideo;
3186 tempch |= ActiveSCART;
3188 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
3190 tempch |= ActiveHiTV;
3193 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
3194 temp = xgifb_reg_get(
3199 tempch |= ActiveYPbPr;
3207 temp = xgifb_reg_get(pVBInfo->P3d4, 0x3d);
3208 if (tempcl & ActiveLCD) {
3209 if ((pVBInfo->SetFlag & ReserveTVOption)) {
3210 if (temp & ActiveTV)
3215 tempbl = ~ModeSwitchStatus;
3216 xgifb_reg_and_or(pVBInfo->P3d4, 0x3d, tempbl, temp);
3218 if (!(pVBInfo->SetFlag & ReserveTVOption))
3219 xgifb_reg_set(pVBInfo->P3d4, 0x3e, tempch);
3225 void XGI_GetVGAType(struct xgi_hw_device_info *HwDeviceExtension,
3226 struct vb_device_info *pVBInfo)
3229 if ( HwDeviceExtension->jChipType >= XG20 ) {
3230 pVBInfo->Set_VGAType = XG20;
3232 pVBInfo->Set_VGAType = VGA_XGI340;
3235 pVBInfo->Set_VGAType = HwDeviceExtension->jChipType;
3238 void XGI_GetVBType(struct vb_device_info *pVBInfo)
3240 unsigned short flag, tempbx, tempah;
3242 if (pVBInfo->IF_DEF_LVDS == 0) {
3243 tempbx = VB_XGI302B;
3244 flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00);
3247 flag = xgifb_reg_get(pVBInfo->Part4Port, 0x01);
3249 tempbx = VB_XGI301B;
3251 tempbx = VB_XGI301C;
3253 tempbx = VB_XGI301LV;
3255 tempbx = VB_XGI302LV;
3256 tempah = xgifb_reg_get(
3266 if (tempbx & (VB_XGI301B | VB_XGI302B)) {
3267 flag = xgifb_reg_get(
3272 tempbx = tempbx | VB_NoLCD;
3276 pVBInfo->VBType = tempbx;
3280 void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
3281 struct xgi_hw_device_info *HwDeviceExtension,
3282 struct vb_device_info *pVBInfo)
3284 unsigned short tempax, push, tempbx, temp, modeflag;
3287 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
3289 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3291 pVBInfo->SetFlag = 0;
3292 pVBInfo->ModeType = modeflag & ModeInfoFlag;
3295 if (pVBInfo->VBType & 0xFFFF) {
3296 /* Check Display Device */
3297 temp = xgifb_reg_get(pVBInfo->P3d4, 0x30);
3298 tempbx = tempbx | temp;
3299 temp = xgifb_reg_get(pVBInfo->P3d4, 0x31);
3303 tempbx = tempbx | tempax;
3304 temp = (SetCRT2ToDualEdge | SetCRT2ToYPbPr | SetCRT2ToLCDA
3305 | SetInSlaveMode | DisableCRT2Display);
3306 temp = 0xFFFF ^ temp;
3309 temp = xgifb_reg_get(pVBInfo->P3d4, 0x38);
3311 if (pVBInfo->IF_DEF_LCDA == 1) {
3313 if ((pVBInfo->Set_VGAType >= XG20)
3314 || (pVBInfo->Set_VGAType >= XG40)) {
3315 if (pVBInfo->IF_DEF_LVDS == 0) {
3316 /* if ((pVBInfo->VBType & VB_XGI302B)
3317 || (pVBInfo->VBType & VB_XGI301LV)
3318 || (pVBInfo->VBType & VB_XGI302LV)
3319 || (pVBInfo->VBType & VB_XGI301C))
3321 if (pVBInfo->VBType &
3326 if (temp & EnableDualEdge) {
3330 if (temp & SetToLCDA)
3339 if (pVBInfo->IF_DEF_YPbPr == 1) {
3340 /* [Billy] 07/05/04 */
3341 if (((pVBInfo->IF_DEF_LVDS == 0) &&
3342 ((pVBInfo->VBType & VB_XGI301LV) ||
3343 (pVBInfo->VBType & VB_XGI302LV) ||
3344 (pVBInfo->VBType & VB_XGI301C)))) {
3345 if (temp & SetYPbPr) { /* temp = CR38 */
3346 if (pVBInfo->IF_DEF_HiVision == 1) {
3347 /* shampoo add for new
3349 temp = xgifb_reg_get(
3353 tempbx |= SetCRT2ToHiVisionTV;
3355 if (temp != YPbPrMode1080i) {
3357 (~SetCRT2ToHiVisionTV);
3363 /* tempbx |= SetCRT2ToYPbPr; */
3368 tempax = push; /* restore CR31 */
3370 if (pVBInfo->IF_DEF_LVDS == 0) {
3371 if (pVBInfo->IF_DEF_YPbPr == 1) {
3372 if (pVBInfo->IF_DEF_HiVision == 1)
3377 if (pVBInfo->IF_DEF_HiVision == 1)
3382 } else { /* 3nd party chip */
3383 temp = SetCRT2ToLCD;
3386 if (!(tempbx & temp)) {
3387 tempax |= DisableCRT2Display;
3391 if (pVBInfo->IF_DEF_LCDA == 1) { /* Select Display Device */
3392 if (!(pVBInfo->VBType & VB_NoLCD)) {
3393 if (tempbx & SetCRT2ToLCDA) {
3394 if (tempbx & SetSimuScanMode)
3395 tempbx &= (~(SetCRT2ToLCD |
3399 tempbx &= (~(SetCRT2ToLCD |
3408 /* for driver abnormal */
3409 if (!(tempbx & (SwitchToCRT2 | SetSimuScanMode))) {
3410 if (pVBInfo->IF_DEF_CRT2Monitor == 1) {
3411 if (tempbx & SetCRT2ToRAMDAC) {
3416 tempbx &= (0x00FF | (~SetCRT2ToYPbPr));
3419 tempbx &= (~(SetCRT2ToRAMDAC |
3425 if (!(pVBInfo->VBType & VB_NoLCD)) {
3426 if (tempbx & SetCRT2ToLCD) {
3431 tempbx &= (0x00FF | (~SetCRT2ToYPbPr));
3435 if (tempbx & SetCRT2ToSCART) {
3440 tempbx &= (0x00FF | (~SetCRT2ToYPbPr));
3443 if (pVBInfo->IF_DEF_YPbPr == 1) {
3444 if (tempbx & SetCRT2ToYPbPr)
3450 if (pVBInfo->IF_DEF_HiVision == 1) {
3451 if (tempbx & SetCRT2ToHiVisionTV)
3453 SetCRT2ToHiVisionTV |
3458 if (tempax & DisableCRT2Display) { /* Set Display Device Info */
3459 if (!(tempbx & (SwitchToCRT2 | SetSimuScanMode)))
3460 tempbx = DisableCRT2Display;
3463 if (!(tempbx & DisableCRT2Display)) {
3464 if ((!(tempbx & DriverMode)) ||
3465 (!(modeflag & CRT2Mode))) {
3466 if (pVBInfo->IF_DEF_LCDA == 1) {
3467 if (!(tempbx & SetCRT2ToLCDA))
3468 tempbx |= (SetInSlaveMode |
3472 if (pVBInfo->IF_DEF_VideoCapture == 1) {
3473 if (((HwDeviceExtension->jChipType ==
3475 (pVBInfo->Set_VGAType == XG40)) ||
3476 ((HwDeviceExtension->jChipType ==
3478 (pVBInfo->Set_VGAType == XG41)) ||
3479 ((HwDeviceExtension->jChipType ==
3481 (pVBInfo->Set_VGAType == XG42)) ||
3482 ((HwDeviceExtension->jChipType ==
3484 (pVBInfo->Set_VGAType == XG45))) {
3501 /* LCD+TV can't support in slave mode
3502 * (Force LCDA+TV->LCDB) */
3503 if ((tempbx & SetInSlaveMode) &&
3504 (tempbx & SetCRT2ToLCDA)) {
3505 tempbx ^= (SetCRT2ToLCD |
3508 pVBInfo->SetFlag |= ReserveTVOption;
3513 pVBInfo->VBInfo = tempbx;
3516 void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
3517 struct vb_device_info *pVBInfo)
3519 unsigned short temp, tempbx = 0, resinfo = 0, modeflag, index1;
3524 if (pVBInfo->VBInfo & SetCRT2ToTV) {
3525 if (ModeNo <= 0x13) {
3526 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].
3527 St_ModeFlag; /* si+St_ModeFlag */
3528 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].
3529 St_ResInfo; /* si+St_ResInfo */
3531 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].
3533 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].
3534 Ext_RESINFO; /* si+Ext_ResInfo */
3537 if (pVBInfo->VBInfo & SetCRT2ToTV) {
3538 temp = xgifb_reg_get(pVBInfo->P3d4, 0x35);
3540 if (tempbx & SetPALTV) {
3541 tempbx &= (SetCHTVOverScan |
3545 if (tempbx & SetPALMTV)
3546 /* set to NTSC if PAL-M */
3547 tempbx &= ~SetPALTV;
3549 tempbx &= (SetCHTVOverScan |
3553 if (pVBInfo->IF_DEF_LVDS == 0) {
3555 index1 = xgifb_reg_get(pVBInfo->P3d4, 0x38);
3556 //00:PAL, 01:PAL-M, 10:PAL-N
3557 temp2 = (index1 & 0xC0) >> 5;
3559 if (temp2 & 0x02) //PAL-M
3560 tempbx &= (~SetPALTV);
3565 if (pVBInfo->IF_DEF_LVDS == 0) {
3566 if (pVBInfo->VBInfo & SetCRT2ToSCART)
3570 if (pVBInfo->IF_DEF_YPbPr == 1) {
3571 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
3572 index1 = xgifb_reg_get(pVBInfo->P3d4, 0x35);
3573 index1 &= YPbPrMode;
3575 if (index1 == YPbPrMode525i)
3576 tempbx |= SetYPbPrMode525i;
3578 if (index1 == YPbPrMode525p)
3579 tempbx = tempbx | SetYPbPrMode525p;
3580 if (index1 == YPbPrMode750p)
3581 tempbx = tempbx | SetYPbPrMode750p;
3585 if (pVBInfo->IF_DEF_HiVision == 1) {
3586 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
3587 tempbx = tempbx | SetYPbPrMode1080i | SetPALTV;
3590 if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */
3591 if ((pVBInfo->VBInfo & SetInSlaveMode) &&
3592 (!(pVBInfo->VBInfo & SetNotSimuMode)))
3593 tempbx |= TVSimuMode;
3595 if (!(tempbx & SetPALTV) &&
3597 (resinfo == 8)) /* NTSC 1024x768, */
3598 tempbx |= NTSC1024x768;
3600 tempbx |= RPLLDIV2XO;
3602 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
3603 if (pVBInfo->VBInfo & SetInSlaveMode)
3604 tempbx &= (~RPLLDIV2XO);
3607 (SetYPbPrMode525p | SetYPbPrMode750p))
3608 tempbx &= (~RPLLDIV2XO);
3609 else if (!(pVBInfo->VBType &
3615 if (tempbx & TVSimuMode)
3616 tempbx &= (~RPLLDIV2XO);
3621 pVBInfo->TVInfo = tempbx;
3624 unsigned char XGI_GetLCDInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
3625 struct vb_device_info *pVBInfo)
3627 unsigned short temp, tempax, tempbx, modeflag, resinfo = 0, LCDIdIndex;
3629 pVBInfo->LCDResInfo = 0;
3630 pVBInfo->LCDTypeInfo = 0;
3631 pVBInfo->LCDInfo = 0;
3633 if (ModeNo <= 0x13) {
3634 /* si+St_ModeFlag // */
3635 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
3637 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3638 /* si+Ext_ResInfo // */
3639 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
3642 temp = xgifb_reg_get(pVBInfo->P3d4, 0x36); /* Get LCD Res.Info */
3643 tempbx = temp & 0x0F;
3646 tempbx = Panel1024x768; /* default */
3648 /* LCD75 [2003/8/22] Vicent */
3649 if ((tempbx == Panel1024x768) || (tempbx == Panel1280x1024)) {
3650 if (pVBInfo->VBInfo & DriverMode) {
3651 tempax = xgifb_reg_get(pVBInfo->P3d4, 0x33);
3652 if (pVBInfo->VBInfo & SetCRT2ToLCDA)
3655 tempax = tempax >> 4;
3657 if ((resinfo == 6) || (resinfo == 9)) {
3659 tempbx |= PanelRef75Hz;
3660 } else if ((resinfo == 7) || (resinfo == 8)) {
3662 tempbx |= PanelRef75Hz;
3667 pVBInfo->LCDResInfo = tempbx;
3671 if (pVBInfo->IF_DEF_OEMUtil == 1)
3672 pVBInfo->LCDTypeInfo = (temp & 0xf0) >> 4;
3674 if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)))
3679 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
3681 temp &= (ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable);
3683 if ((pVBInfo->IF_DEF_ScaleLCD == 1) && (temp & LCDNonExpanding))
3684 temp &= ~EnableScalingLCD;
3688 LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo);
3690 tempax = pVBInfo->LCDCapList[LCDIdIndex].LCD_Capability;
3692 if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */
3693 if (((pVBInfo->VBType & VB_XGI302LV) || (pVBInfo->VBType
3694 & VB_XGI301C)) && (tempax & LCDDualLink)) {
3695 tempbx |= SetLCDDualLink;
3699 if (pVBInfo->IF_DEF_LVDS == 0) {
3700 if ((pVBInfo->LCDResInfo == Panel1400x1050) && (pVBInfo->VBInfo
3701 & SetCRT2ToLCD) && (ModeNo > 0x13) && (resinfo
3702 == 9) && (!(tempbx & EnableScalingLCD)))
3703 /* set to center in 1280x1024 LCDB for Panel1400x1050 */
3704 tempbx |= SetLCDtoNonExpanding;
3708 if (tempax & LCDBToA) {
3709 tempbx |= SetLCDBToA;
3713 if (pVBInfo->IF_DEF_ExpLink == 1) {
3714 if (modeflag & HalfDCLK) {
3715 /* if (!(pVBInfo->LCDInfo&LCDNonExpanding)) */
3716 if (!(tempbx & SetLCDtoNonExpanding)) {
3717 tempbx |= EnableLVDSDDA;
3719 if (ModeNo > 0x13) {
3720 if (pVBInfo->LCDResInfo
3722 if (resinfo == 4) {/* 512x384 */
3723 tempbx |= EnableLVDSDDA;
3731 if (pVBInfo->VBInfo & SetInSlaveMode) {
3732 if (pVBInfo->VBInfo & SetNotSimuMode)
3733 tempbx |= LCDVESATiming;
3735 tempbx |= LCDVESATiming;
3738 pVBInfo->LCDInfo = tempbx;
3740 if (pVBInfo->IF_DEF_PWD == 1) {
3741 if (pVBInfo->LCDInfo & SetPWDEnable) {
3742 if ((pVBInfo->VBType & VB_XGI302LV) ||
3743 (pVBInfo->VBType & VB_XGI301C)) {
3744 if (!(tempax & PWDEnable))
3745 pVBInfo->LCDInfo &= ~SetPWDEnable;
3750 if (pVBInfo->IF_DEF_LVDS == 0) {
3751 if (tempax & (LockLCDBToA | StLCDBToA)) {
3752 if (pVBInfo->VBInfo & SetInSlaveMode) {
3753 if (!(tempax & LockLCDBToA)) {
3754 if (ModeNo <= 0x13) {
3769 if (pVBInfo->IF_DEF_LVDS == 0) {
3770 if (tempax & (LockLCDBToA | StLCDBToA)) {
3771 if (pVBInfo->VBInfo & SetInSlaveMode) {
3772 if (!((!(tempax & LockLCDBToA)) &&
3790 unsigned char XGI_SearchModeID(unsigned short ModeNo,
3791 unsigned short *ModeIdIndex, struct vb_device_info *pVBInfo)
3795 if (ModeNo <= 0x13) {
3796 /* for (*ModeIdIndex=0;
3797 *ModeIdIndex < sizeof(pVBInfo->SModeIDTable)
3798 / sizeof(struct XGI_StStruct);
3799 (*ModeIdIndex)++) */
3800 for (*ModeIdIndex = 0;; (*ModeIdIndex)++) {
3801 if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID ==
3804 if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID ==
3810 (*ModeIdIndex)++; /* 400 lines */
3812 (*ModeIdIndex) += 2; /* 400 lines */
3813 /* else 350 lines */
3815 /* for (*ModeIdIndex=0;
3816 *ModeIdIndex < sizeof(pVBInfo->EModeIDTable)
3817 / sizeof(struct XGI_ExtStruct);
3818 (*ModeIdIndex)++) */
3819 for (*ModeIdIndex = 0;; (*ModeIdIndex)++) {
3820 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID ==
3823 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID ==
3832 /* win2000 MM adapter not support standard mode! */
3835 static unsigned char XGINew_CheckMemorySize(
3836 struct xgi_hw_device_info *HwDeviceExtension,
3837 unsigned short ModeNo,
3838 unsigned short ModeIdIndex,
3839 struct vb_device_info *pVBInfo)
3841 unsigned short memorysize, modeflag, temp, temp1, tmp;
3844 if ((HwDeviceExtension->jChipType == XGI_650) ||
3845 (HwDeviceExtension->jChipType == XGI_650M)) {
3851 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
3853 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3855 /* ModeType = modeflag&ModeInfoFlag; // Get mode type */
3857 memorysize = modeflag & MemoryInfoFlag;
3858 memorysize = memorysize > MemorySizeShift;
3859 memorysize++; /* Get memory size */
3861 temp = xgifb_reg_get(pVBInfo->P3c4, 0x14); /* Get DRAM Size */
3864 if (HwDeviceExtension->jChipType == XG40) {
3865 /* memory size per channel SR14[7:4] */
3866 temp = 1 << ((temp & 0x0F0) >> 4);
3867 if ((tmp & 0x0c) == 0x0C) { /* Qual channels */
3869 } else if ((tmp & 0x0c) == 0x08) { /* Dual channels */
3872 } else if (HwDeviceExtension->jChipType == XG42) {
3873 /* memory size per channel SR14[7:4] */
3874 temp = 1 << ((temp & 0x0F0) >> 4);
3875 if ((tmp & 0x04) == 0x04) { /* Dual channels */
3878 } else if (HwDeviceExtension->jChipType == XG45) {
3879 /* memory size per channel SR14[7:4] */
3880 temp = 1 << ((temp & 0x0F0) >> 4);
3881 if ((tmp & 0x0c) == 0x0C) { /* Qual channels */
3883 } else if ((tmp & 0x0c) == 0x08) { /* triple channels */
3887 } else if ((tmp & 0x0c) == 0x04) { /* Dual channels */
3891 if (temp < memorysize)
3899 void XGINew_IsLowResolution(unsigned short ModeNo,
3900 unsigned short ModeIdIndex,
3901 unsigned char XGINew_CheckMemorySize(
3902 struct xgi_hw_device_info *HwDeviceExtension,
3903 unsigned short ModeNo,
3904 unsigned short ModeIdIndex,
3905 struct vb_device_info *pVBInfo)
3907 unsigned short data ;
3908 unsigned short ModeFlag ;
3910 data = xgifb_reg_get(pVBInfo->P3c4, 0x0F);
3912 xgifb_reg_set(pVBInfo->P3c4, 0x0F, data);
3914 if (ModeNo > 0x13) {
3915 ModeFlag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3916 if ((ModeFlag & HalfDCLK) && (ModeFlag & DoubleScanMode)) {
3917 data = xgifb_reg_get(pVBInfo->P3c4, 0x0F);
3919 xgifb_reg_set(pVBInfo->P3c4, 0x0F, data);
3920 data = xgifb_reg_get(pVBInfo->P3c4, 0x01);
3922 xgifb_reg_set(pVBInfo->P3c4, 0x01, data);
3928 static unsigned char XG21GPIODataTransfer(unsigned char ujDate)
3930 unsigned char ujRet = 0;
3931 unsigned char i = 0;
3933 for (i = 0; i < 8; i++) {
3935 /* ujRet |= GETBITS(ujDate >> i, 0:0); */
3936 ujRet |= (ujDate >> i) & 1;
3942 /*----------------------------------------------------------------------------*/
3944 /* bl[5] : LVDS signal */
3945 /* bl[1] : LVDS backlight */
3946 /* bl[0] : LVDS VDD */
3947 /*----------------------------------------------------------------------------*/
3948 static unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo)
3950 unsigned char CR4A, temp;
3952 CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
3953 xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x23); /* enable GPIO write */
3955 temp = xgifb_reg_get(pVBInfo->P3d4, 0x48);
3957 temp = XG21GPIODataTransfer(temp);
3959 xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A);
3963 /*----------------------------------------------------------------------------*/
3965 /* bl[5] : LVDS signal */
3966 /* bl[1] : LVDS backlight */
3967 /* bl[0] : LVDS VDD */
3968 /*----------------------------------------------------------------------------*/
3969 static unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo)
3971 unsigned char CR4A, CRB4, temp;
3973 CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
3974 xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x0C); /* enable GPIO write */
3976 temp = xgifb_reg_get(pVBInfo->P3d4, 0x48);
3980 xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A);
3981 CRB4 = xgifb_reg_get(pVBInfo->P3d4, 0xB4);
3982 temp |= ((CRB4 & 0x04) << 3);
3986 void XGI_DisplayOn(struct xgi_hw_device_info *pXGIHWDE,
3987 struct vb_device_info *pVBInfo)
3990 xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x00);
3991 if (pXGIHWDE->jChipType == XG21) {
3992 if (pVBInfo->IF_DEF_LVDS == 1) {
3993 if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x1)) {
3995 XGI_XG21BLSignalVDD(0x01, 0x01, pVBInfo);
3996 XGI_XG21SetPanelDelay(2, pVBInfo);
3998 if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x20))
3999 /* LVDS signal on */
4000 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo);
4001 XGI_XG21SetPanelDelay(3, pVBInfo);
4002 /* LVDS backlight on */
4003 XGI_XG21BLSignalVDD(0x02, 0x02, pVBInfo);
4005 /* DVO/DVI signal on */
4006 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo);
4011 if (pXGIHWDE->jChipType == XG27) {
4012 if (pVBInfo->IF_DEF_LVDS == 1) {
4013 if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x1)) {
4015 XGI_XG27BLSignalVDD(0x01, 0x01, pVBInfo);
4016 XGI_XG21SetPanelDelay(2, pVBInfo);
4018 if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x20))
4019 /* LVDS signal on */
4020 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo);
4021 XGI_XG21SetPanelDelay(3, pVBInfo);
4022 /* LVDS backlight on */
4023 XGI_XG27BLSignalVDD(0x02, 0x02, pVBInfo);
4025 /* DVO/DVI signal on */
4026 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo);
4032 void XGI_DisplayOff(struct xgi_hw_device_info *pXGIHWDE,
4033 struct vb_device_info *pVBInfo)
4036 if (pXGIHWDE->jChipType == XG21) {
4037 if (pVBInfo->IF_DEF_LVDS == 1) {
4038 /* LVDS backlight off */
4039 XGI_XG21BLSignalVDD(0x02, 0x00, pVBInfo);
4040 XGI_XG21SetPanelDelay(3, pVBInfo);
4042 /* DVO/DVI signal off */
4043 XGI_XG21BLSignalVDD(0x20, 0x00, pVBInfo);
4047 if (pXGIHWDE->jChipType == XG27) {
4048 if ((XGI_XG27GetPSCValue(pVBInfo) & 0x2)) {
4049 /* LVDS backlight off */
4050 XGI_XG27BLSignalVDD(0x02, 0x00, pVBInfo);
4051 XGI_XG21SetPanelDelay(3, pVBInfo);
4054 if (pVBInfo->IF_DEF_LVDS == 0)
4055 /* DVO/DVI signal off */
4056 XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo);
4059 xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x20);
4062 static void XGI_WaitDisply(struct vb_device_info *pVBInfo)
4064 while ((inb(pVBInfo->P3da) & 0x01))
4067 while (!(inb(pVBInfo->P3da) & 0x01))
4072 static void XGI_WaitDisplay(struct vb_device_info *pVBInfo)
4074 while (!(inb(pVBInfo->P3da) & 0x01))
4076 while (inb(pVBInfo->P3da) & 0x01)
4081 static void XGI_AutoThreshold(struct vb_device_info *pVBInfo)
4083 if (!(pVBInfo->SetFlag & Win9xDOSMode))
4084 xgifb_reg_or(pVBInfo->Part1Port, 0x01, 0x40);
4087 static void XGI_SaveCRT2Info(unsigned short ModeNo,
4088 struct vb_device_info *pVBInfo)
4090 unsigned short temp1, temp2;
4092 /* reserve CR34 for CRT1 Mode No */
4093 xgifb_reg_set(pVBInfo->P3d4, 0x34, ModeNo);
4094 temp1 = (pVBInfo->VBInfo & SetInSlaveMode) >> 8;
4095 temp2 = ~(SetInSlaveMode >> 8);
4096 xgifb_reg_and_or(pVBInfo->P3d4, 0x31, temp2, temp1);
4099 static void XGI_GetCRT2ResInfo(unsigned short ModeNo,
4100 unsigned short ModeIdIndex,
4101 struct vb_device_info *pVBInfo)
4103 unsigned short xres, yres, modeflag, resindex;
4105 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
4106 if (ModeNo <= 0x13) {
4107 xres = pVBInfo->StResInfo[resindex].HTotal;
4108 yres = pVBInfo->StResInfo[resindex].VTotal;
4110 /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;*/
4112 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
4113 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
4114 /* si+St_ModeFlag */
4115 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4118 if (pVBInfo->IF_DEF_FSTN) {
4123 if (modeflag & HalfDCLK)
4126 if (modeflag & DoubleScanMode)
4131 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
4132 if (pVBInfo->IF_DEF_LVDS == 0) {
4133 if (pVBInfo->LCDResInfo == Panel1600x1200) {
4134 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
4140 if (pVBInfo->LCDResInfo == Panel1280x1024) {
4143 else if (yres == 350)
4146 if (pVBInfo->LCDInfo & LCDVESATiming) {
4152 if (pVBInfo->LCDResInfo == Panel1024x768) {
4153 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
4154 if (!(pVBInfo->LCDInfo
4155 & LCDNonExpanding)) {
4158 else if (yres == 400)
4160 else if (yres == 480)
4171 pVBInfo->VGAHDE = xres;
4172 pVBInfo->HDE = xres;
4173 pVBInfo->VGAVDE = yres;
4174 pVBInfo->VDE = yres;
4177 static unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo)
4180 if ((pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) &&
4181 (pVBInfo->LCDInfo & SetLCDDualLink)) /* shampoo0129 */
4187 static void XGI_GetRAMDAC2DATA(unsigned short ModeNo,
4188 unsigned short ModeIdIndex,
4189 unsigned short RefreshRateTableIndex,
4190 struct vb_device_info *pVBInfo)
4192 unsigned short tempax, tempbx, temp1, temp2, modeflag = 0, tempcx,
4193 StandTableIndex, CRT1Index;
4195 pVBInfo->RVBHCMAX = 1;
4196 pVBInfo->RVBHCFACT = 1;
4198 if (ModeNo <= 0x13) {
4199 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
4200 StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
4201 tempax = pVBInfo->StandTable[StandTableIndex].CRTC[0];
4202 tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[6];
4203 temp1 = pVBInfo->StandTable[StandTableIndex].CRTC[7];
4205 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4206 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].
4208 CRT1Index &= IndexMask;
4209 temp1 = (unsigned short) pVBInfo->
4210 XGINEWUB_CRT1Table[CRT1Index].CR[0];
4211 temp2 = (unsigned short) pVBInfo->
4212 XGINEWUB_CRT1Table[CRT1Index].CR[5];
4213 tempax = (temp1 & 0xFF) | ((temp2 & 0x03) << 8);
4214 tempbx = (unsigned short) pVBInfo->
4215 XGINEWUB_CRT1Table[CRT1Index].CR[8];
4216 tempcx = (unsigned short) pVBInfo->
4217 XGINEWUB_CRT1Table[CRT1Index].CR[14] << 8;
4219 tempcx = tempcx << 2;
4221 temp1 = (unsigned short) pVBInfo->
4222 XGINEWUB_CRT1Table[CRT1Index].CR[9];
4232 if (modeflag & Charx8Dot)
4237 pVBInfo->VGAHT = tempax;
4238 pVBInfo->HT = tempax;
4240 pVBInfo->VGAVT = tempbx;
4241 pVBInfo->VT = tempbx;
4244 static void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex,
4245 unsigned short RefreshRateTableIndex,
4246 struct vb_device_info *pVBInfo)
4248 unsigned short tempax = 0, tempbx, modeflag, resinfo;
4250 struct XGI_LCDDataStruct *LCDPtr = NULL;
4251 struct XGI_TVDataStruct *TVPtr = NULL;
4253 if (ModeNo <= 0x13) {
4255 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
4256 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
4258 /* si+Ext_ResInfo */
4259 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4260 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4263 pVBInfo->NewFlickerMode = 0;
4264 pVBInfo->RVBHRS = 50;
4266 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
4267 XGI_GetRAMDAC2DATA(ModeNo, ModeIdIndex, RefreshRateTableIndex,
4274 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
4275 LCDPtr = (struct XGI_LCDDataStruct *) XGI_GetLcdPtr(tempbx,
4276 ModeNo, ModeIdIndex, RefreshRateTableIndex,
4279 pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX;
4280 pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT;
4281 pVBInfo->VGAHT = LCDPtr->VGAHT;
4282 pVBInfo->VGAVT = LCDPtr->VGAVT;
4283 pVBInfo->HT = LCDPtr->LCDHT;
4284 pVBInfo->VT = LCDPtr->LCDVT;
4286 if (pVBInfo->LCDResInfo == Panel1024x768) {
4290 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
4291 if (pVBInfo->VGAVDE == 357)
4293 else if (pVBInfo->VGAVDE == 420)
4295 else if (pVBInfo->VGAVDE == 525)
4297 else if (pVBInfo->VGAVDE == 600)
4299 /* else if (pVBInfo->VGAVDE==350) tempbx=560; */
4300 /* else if (pVBInfo->VGAVDE==400) tempbx=640; */
4305 } else if (pVBInfo->LCDResInfo == Panel1024x768x75) {
4308 } else if (pVBInfo->LCDResInfo == Panel1280x1024) {
4310 if (pVBInfo->VGAVDE == 360)
4312 else if (pVBInfo->VGAVDE == 375)
4314 else if (pVBInfo->VGAVDE == 405)
4318 } else if (pVBInfo->LCDResInfo == Panel1280x1024x75) {
4321 } else if (pVBInfo->LCDResInfo == Panel1280x960) {
4323 if (pVBInfo->VGAVDE == 350)
4325 else if (pVBInfo->VGAVDE == 400)
4327 else if (pVBInfo->VGAVDE == 1024)
4331 } else if (pVBInfo->LCDResInfo == Panel1400x1050) {
4335 if (pVBInfo->VGAVDE == 1024) {
4339 } else if (pVBInfo->LCDResInfo == Panel1600x1200) {
4341 tempbx = 1200; /* alan 10/14/2003 */
4342 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
4343 if (pVBInfo->VGAVDE == 350)
4345 else if (pVBInfo->VGAVDE == 400)
4350 if (pVBInfo->LCDInfo & LCDNonExpanding) {
4351 tempax = pVBInfo->VGAHDE;
4352 tempbx = pVBInfo->VGAVDE;
4355 pVBInfo->HDE = tempax;
4356 pVBInfo->VDE = tempbx;
4360 if (pVBInfo->VBInfo & (SetCRT2ToTV)) {
4362 TVPtr = (struct XGI_TVDataStruct *) XGI_GetTVPtr(tempbx,
4363 ModeNo, ModeIdIndex, RefreshRateTableIndex,
4366 pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX;
4367 pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT;
4368 pVBInfo->VGAHT = TVPtr->VGAHT;
4369 pVBInfo->VGAVT = TVPtr->VGAVT;
4370 pVBInfo->HDE = TVPtr->TVHDE;
4371 pVBInfo->VDE = TVPtr->TVVDE;
4372 pVBInfo->RVBHRS = TVPtr->RVBHRS;
4373 pVBInfo->NewFlickerMode = TVPtr->FlickerMode;
4375 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4376 if (resinfo == 0x08)
4377 pVBInfo->NewFlickerMode = 0x40;
4378 else if (resinfo == 0x09)
4379 pVBInfo->NewFlickerMode = 0x40;
4380 else if (resinfo == 0x12)
4381 pVBInfo->NewFlickerMode = 0x40;
4383 if (pVBInfo->VGAVDE == 350)
4384 pVBInfo->TVInfo |= TVSimuMode;
4389 if (pVBInfo->VBInfo & SetInSlaveMode) {
4390 if (pVBInfo->TVInfo & TVSimuMode) {
4394 if (!(modeflag & Charx8Dot)) {
4395 tempax = StHiTextTVHT;
4396 tempbx = StHiTextTVVT;
4400 } else if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
4401 if (pVBInfo->TVInfo & SetYPbPrMode750p) {
4402 tempax = YPbPrTV750pHT; /* Ext750pTVHT */
4403 tempbx = YPbPrTV750pVT; /* Ext750pTVVT */
4406 if (pVBInfo->TVInfo & SetYPbPrMode525p) {
4407 tempax = YPbPrTV525pHT; /* Ext525pTVHT */
4408 tempbx = YPbPrTV525pVT; /* Ext525pTVVT */
4409 } else if (pVBInfo->TVInfo & SetYPbPrMode525i) {
4410 tempax = YPbPrTV525iHT; /* Ext525iTVHT */
4411 tempbx = YPbPrTV525iVT; /* Ext525iTVVT */
4412 if (pVBInfo->TVInfo & NTSC1024x768)
4413 tempax = NTSC1024x768HT;
4418 if (!(pVBInfo->TVInfo & SetPALTV)) {
4421 if (pVBInfo->TVInfo & NTSC1024x768)
4422 tempax = NTSC1024x768HT;
4426 pVBInfo->HT = tempax;
4427 pVBInfo->VT = tempbx;
4432 static void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex,
4433 unsigned short RefreshRateTableIndex,
4434 struct vb_device_info *pVBInfo)
4436 unsigned char di_0, di_1, tempal;
4438 tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex,
4440 XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo);
4441 XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo);
4443 if (pVBInfo->VBType & VB_XGI301) { /* shampoo 0129 */
4445 xgifb_reg_set(pVBInfo->Part4Port, 0x0A, 0x10);
4446 xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1);
4447 xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0);
4448 } else { /* 301b/302b/301lv/302lv */
4449 xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0);
4450 xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1);
4453 xgifb_reg_set(pVBInfo->Part4Port, 0x00, 0x12);
4455 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC)
4456 xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x28);
4458 xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x08);
4461 static unsigned short XGI_GetColorDepth(unsigned short ModeNo,
4462 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
4464 unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8 };
4466 unsigned short modeflag;
4469 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
4471 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4473 index = (modeflag & ModeInfoFlag) - ModeEGA;
4478 return ColorDepth[index];
4481 static unsigned short XGI_GetOffset(unsigned short ModeNo,
4482 unsigned short ModeIdIndex,
4483 unsigned short RefreshRateTableIndex,
4484 struct xgi_hw_device_info *HwDeviceExtension,
4485 struct vb_device_info *pVBInfo)
4487 unsigned short temp, colordepth, modeinfo, index, infoflag,
4488 ColorDepth[] = { 0x01, 0x02, 0x04 };
4490 modeinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo;
4494 infoflag = pVBInfo->
4495 RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
4497 index = (modeinfo >> 8) & 0xFF;
4499 temp = pVBInfo->ScreenOffset[index];
4501 if (infoflag & InterlaceMode)
4504 colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo);
4506 if ((ModeNo >= 0x7C) && (ModeNo <= 0x7E)) {
4507 temp = ModeNo - 0x7C;
4508 colordepth = ColorDepth[temp];
4510 if (infoflag & InterlaceMode)
4512 return temp * colordepth;
4514 return temp * colordepth;
4518 static void XGI_SetCRT2Offset(unsigned short ModeNo,
4519 unsigned short ModeIdIndex,
4520 unsigned short RefreshRateTableIndex,
4521 struct xgi_hw_device_info *HwDeviceExtension,
4522 struct vb_device_info *pVBInfo)
4524 unsigned short offset;
4527 if (pVBInfo->VBInfo & SetInSlaveMode)
4530 offset = XGI_GetOffset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
4531 HwDeviceExtension, pVBInfo);
4532 temp = (unsigned char) (offset & 0xFF);
4533 xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp);
4534 temp = (unsigned char) ((offset & 0xFF00) >> 8);
4535 xgifb_reg_set(pVBInfo->Part1Port, 0x09, temp);
4536 temp = (unsigned char) (((offset >> 3) & 0xFF) + 1);
4537 xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp);
4540 static void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo)
4542 /* threshold high ,disable auto threshold */
4543 xgifb_reg_set(pVBInfo->Part1Port, 0x01, 0x3B);
4544 /* threshold low default 04h */
4545 xgifb_reg_and_or(pVBInfo->Part1Port, 0x02, ~(0x3F), 0x04);
4548 static void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
4549 struct xgi_hw_device_info *HwDeviceExtension,
4550 unsigned short RefreshRateTableIndex,
4551 struct vb_device_info *pVBInfo)
4553 unsigned short tempcx = 0, CRT1Index = 0, resinfo = 0;
4555 if (ModeNo > 0x13) {
4556 CRT1Index = pVBInfo->
4557 RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4558 CRT1Index &= IndexMask;
4559 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4562 XGI_SetCRT2Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
4563 HwDeviceExtension, pVBInfo);
4564 XGI_SetCRT2FIFO(pVBInfo);
4565 /* XGI_SetCRT2Sync(ModeNo,RefreshRateTableIndex); */
4567 for (tempcx = 4; tempcx < 7; tempcx++)
4568 xgifb_reg_set(pVBInfo->Part1Port, tempcx, 0x0);
4570 xgifb_reg_set(pVBInfo->Part1Port, 0x50, 0x00);
4571 xgifb_reg_set(pVBInfo->Part1Port, 0x02, 0x44); /* temp 0206 */
4574 static void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
4575 struct xgi_hw_device_info *HwDeviceExtension,
4576 unsigned short RefreshRateTableIndex,
4577 struct vb_device_info *pVBInfo)
4579 unsigned short temp = 0, tempax = 0, tempbx = 0, tempcx = 0,
4580 pushbx = 0, CRT1Index = 0, modeflag, resinfo = 0;
4582 if (ModeNo > 0x13) {
4583 CRT1Index = pVBInfo->
4584 RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4585 CRT1Index &= IndexMask;
4586 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4590 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
4592 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4594 /* bainy change table name */
4595 if (modeflag & HalfDCLK) {
4596 /* BTVGA2HT 0x08,0x09 */
4597 temp = (pVBInfo->VGAHT / 2 - 1) & 0x0FF;
4598 xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp);
4599 temp = (((pVBInfo->VGAHT / 2 - 1) & 0xFF00) >> 8) << 4;
4600 xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp);
4601 /* BTVGA2HDEE 0x0A,0x0C */
4602 temp = (pVBInfo->VGAHDE / 2 + 16) & 0x0FF;
4603 xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp);
4604 tempcx = ((pVBInfo->VGAHT - pVBInfo->VGAHDE) / 2) >> 2;
4605 pushbx = pVBInfo->VGAHDE / 2 + 16;
4606 tempcx = tempcx >> 1;
4607 tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */
4610 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
4611 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4];
4612 tempbx |= ((pVBInfo->
4613 XGINEWUB_CRT1Table[CRT1Index].CR[14] &
4615 tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */
4616 tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5];
4618 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[15];
4619 temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */
4620 tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */
4626 if (tempcx > (pVBInfo->VGAHT / 2))
4627 tempcx = pVBInfo->VGAHT / 2;
4629 temp = tempbx & 0x00FF;
4631 xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp);
4633 temp = (pVBInfo->VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */
4634 xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp);
4635 temp = (((pVBInfo->VGAHT - 1) & 0xFF00) >> 8) << 4;
4636 xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp);
4637 /* BTVGA2HDEE 0x0A,0x0C */
4638 temp = (pVBInfo->VGAHDE + 16) & 0x0FF;
4639 xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp);
4640 tempcx = (pVBInfo->VGAHT - pVBInfo->VGAHDE) >> 2; /* cx */
4641 pushbx = pVBInfo->VGAHDE + 16;
4642 tempcx = tempcx >> 1;
4643 tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */
4646 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
4647 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[3];
4648 tempbx |= ((pVBInfo->
4649 XGINEWUB_CRT1Table[CRT1Index].CR[5] &
4651 tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */
4652 tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4];
4654 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[6];
4655 temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */
4656 tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */
4661 if (tempcx > pVBInfo->VGAHT)
4662 tempcx = pVBInfo->VGAHT;
4664 temp = tempbx & 0x00FF;
4665 xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp);
4668 tempax = (tempax & 0x00FF) | (tempbx & 0xFF00);
4670 tempbx = (tempbx & 0x00FF) | ((tempbx & 0xFF00) << 4);
4671 tempax |= (tempbx & 0xFF00);
4672 temp = (tempax & 0xFF00) >> 8;
4673 xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp);
4674 temp = tempcx & 0x00FF;
4675 xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp);
4676 tempcx = (pVBInfo->VGAVT - 1);
4677 temp = tempcx & 0x00FF;
4679 xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp);
4680 tempbx = pVBInfo->VGAVDE - 1;
4681 temp = tempbx & 0x00FF;
4682 xgifb_reg_set(pVBInfo->Part1Port, 0x0F, temp);
4683 temp = ((tempbx & 0xFF00) << 3) >> 8;
4684 temp |= ((tempcx & 0xFF00) >> 8);
4685 xgifb_reg_set(pVBInfo->Part1Port, 0x12, temp);
4687 tempax = pVBInfo->VGAVDE;
4688 tempbx = pVBInfo->VGAVDE;
4689 tempcx = pVBInfo->VGAVT;
4690 /* BTVGA2VRS 0x10,0x11 */
4691 tempbx = (pVBInfo->VGAVT + pVBInfo->VGAVDE) >> 1;
4692 /* BTVGA2VRE 0x11 */
4693 tempcx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) >> 4) + tempbx + 1;
4695 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
4696 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[10];
4697 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9];
4705 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14];
4710 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[11];
4711 tempcx = (tempcx & 0xFF00) | (temp & 0x00FF);
4714 temp = tempbx & 0x00FF;
4715 xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp);
4716 temp = ((tempbx & 0xFF00) >> 8) << 4;
4717 temp = ((tempcx & 0x000F) | (temp));
4718 xgifb_reg_set(pVBInfo->Part1Port, 0x11, temp);
4721 if (modeflag & DoubleScanMode)
4724 if (modeflag & HalfDCLK)
4727 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2C, ~0x0C0, tempax);
4730 static unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo)
4732 unsigned long tempax, tempbx;
4734 tempbx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) * pVBInfo->RVBHCMAX)
4736 tempax = (pVBInfo->VT - pVBInfo->VDE) * pVBInfo->RVBHCFACT;
4737 tempax = (tempax * pVBInfo->HT) / tempbx;
4739 return (unsigned short) tempax;
4742 static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
4743 struct xgi_hw_device_info *HwDeviceExtension,
4744 unsigned short RefreshRateTableIndex,
4745 struct vb_device_info *pVBInfo)
4747 unsigned short push1, push2, tempax, tempbx = 0, tempcx, temp, resinfo,
4748 modeflag, CRT1Index;
4750 if (ModeNo <= 0x13) {
4752 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
4753 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
4755 /* si+Ext_ResInfo */
4756 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4757 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4758 CRT1Index = pVBInfo->
4759 RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4760 CRT1Index &= IndexMask;
4763 if (!(pVBInfo->VBInfo & SetInSlaveMode))
4766 temp = 0xFF; /* set MAX HT */
4767 xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp);
4768 /* if (modeflag & Charx8Dot) */
4769 /* tempcx = 0x08; */
4773 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C))
4774 modeflag |= Charx8Dot;
4776 tempax = pVBInfo->VGAHDE; /* 0x04 Horizontal Display End */
4778 if (modeflag & HalfDCLK)
4779 tempax = tempax >> 1;
4781 tempax = (tempax / tempcx) - 1;
4782 tempbx |= ((tempax & 0x00FF) << 8);
4783 temp = tempax & 0x00FF;
4784 xgifb_reg_set(pVBInfo->Part1Port, 0x04, temp);
4786 temp = (tempbx & 0xFF00) >> 8;
4788 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4789 if (!(pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
4790 | VB_XGI302LV | VB_XGI301C)))
4793 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4794 if (pVBInfo->VBType & VB_XGI301LV) {
4795 if (pVBInfo->VBExtInfo == VB_YPbPr1080i) {
4799 } else if (resinfo == 7) {
4805 /* 0x05 Horizontal Display Start */
4806 xgifb_reg_set(pVBInfo->Part1Port, 0x05, temp);
4807 /* 0x06 Horizontal Blank end */
4808 xgifb_reg_set(pVBInfo->Part1Port, 0x06, 0x03);
4810 if (!(pVBInfo->VBInfo & DisableCRT2Display)) { /* 030226 bainy */
4811 if (pVBInfo->VBInfo & SetCRT2ToTV)
4812 tempax = pVBInfo->VGAHT;
4814 tempax = XGI_GetVGAHT2(pVBInfo);
4817 if (tempax >= pVBInfo->VGAHT)
4818 tempax = pVBInfo->VGAHT;
4820 if (modeflag & HalfDCLK)
4821 tempax = tempax >> 1;
4823 tempax = (tempax / tempcx) - 5;
4824 tempcx = tempax; /* 20030401 0x07 horizontal Retrace Start */
4825 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4826 temp = (tempbx & 0x00FF) - 1;
4827 if (!(modeflag & HalfDCLK)) {
4829 if (pVBInfo->TVInfo & TVSimuMode) {
4836 /* tempcx = tempbx & 0x00FF ; */
4837 tempbx = (tempbx & 0xFF00) >> 8;
4838 tempcx = (tempcx + tempbx) >> 1;
4839 temp = (tempcx & 0x00FF) + 2;
4841 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4843 if (!(modeflag & HalfDCLK)) {
4844 if ((modeflag & Charx8Dot)) {
4846 if (pVBInfo->VGAHDE >= 800)
4851 if (!(modeflag & HalfDCLK)) {
4853 if (pVBInfo->LCDResInfo != Panel1280x960) {
4854 if (pVBInfo->VGAHDE >= 800) {
4856 if (pVBInfo->ModeType ==
4858 if (pVBInfo->VGAVDE ==
4861 if (pVBInfo->LCDResInfo != Panel1280x1024) {
4868 if (pVBInfo->VGAHDE >= 1280) {
4869 if (pVBInfo->LCDResInfo
4871 if (pVBInfo->LCDInfo
4872 & LCDNonExpanding) {
4884 /* 0x07 Horizontal Retrace Start */
4885 xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp);
4886 /* 0x08 Horizontal Retrace End */
4887 xgifb_reg_set(pVBInfo->Part1Port, 0x08, 0);
4889 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4890 if (pVBInfo->TVInfo & TVSimuMode) {
4891 if ((ModeNo == 0x06) || (ModeNo == 0x10) || (ModeNo
4892 == 0x11) || (ModeNo == 0x13) || (ModeNo
4894 xgifb_reg_set(pVBInfo->Part1Port, 0x07, 0x5b);
4895 xgifb_reg_set(pVBInfo->Part1Port, 0x08, 0x03);
4898 if ((ModeNo == 0x00) || (ModeNo == 0x01)) {
4899 if (pVBInfo->TVInfo & SetNTSCTV) {
4900 xgifb_reg_set(pVBInfo->Part1Port,
4902 xgifb_reg_set(pVBInfo->Part1Port,
4905 xgifb_reg_set(pVBInfo->Part1Port,
4907 xgifb_reg_set(pVBInfo->Part1Port,
4909 xgifb_reg_set(pVBInfo->Part1Port,
4914 if ((ModeNo == 0x02) || (ModeNo == 0x03) || (ModeNo
4916 if (pVBInfo->TVInfo & SetNTSCTV) {
4917 xgifb_reg_set(pVBInfo->Part1Port,
4919 xgifb_reg_set(pVBInfo->Part1Port,
4922 xgifb_reg_set(pVBInfo->Part1Port,
4924 xgifb_reg_set(pVBInfo->Part1Port,
4926 xgifb_reg_set(pVBInfo->Part1Port,
4931 if ((ModeNo == 0x04) || (ModeNo == 0x05) || (ModeNo
4932 == 0x0D) || (ModeNo == 0x50)) {
4933 if (pVBInfo->TVInfo & SetNTSCTV) {
4934 xgifb_reg_set(pVBInfo->Part1Port,
4936 xgifb_reg_set(pVBInfo->Part1Port,
4939 xgifb_reg_set(pVBInfo->Part1Port,
4941 xgifb_reg_set(pVBInfo->Part1Port,
4948 xgifb_reg_set(pVBInfo->Part1Port, 0x18, 0x03); /* 0x18 SR0B */
4949 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0xF0, 0x00);
4950 xgifb_reg_set(pVBInfo->Part1Port, 0x09, 0xFF); /* 0x09 Set Max VT */
4952 tempbx = pVBInfo->VGAVT;
4955 tempbx = pVBInfo->VGAVDE; /* 0x0E Virtical Display End */
4970 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
4971 if (pVBInfo->LCDResInfo == Panel1024x768) {
4972 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
4981 temp = tempbx & 0x00FF;
4983 temp = tempbx & 0x00FF;
4984 /* 0x10 vertical Blank Start */
4985 xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp);
4988 temp = tempbx & 0x00FF;
4989 xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp);
4991 if (tempbx & 0x0100)
4996 if (modeflag & DoubleScanMode)
4999 if (tempbx & 0x0200)
5002 temp = (tempax & 0xFF00) >> 8;
5003 xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp);
5005 if (tempbx & 0x0400)
5008 /* 0x11 Vertival Blank End */
5009 xgifb_reg_set(pVBInfo->Part1Port, 0x11, 0x00);
5012 tempax -= tempbx; /* 0x0C Vertical Retrace Start */
5013 tempax = tempax >> 2;
5014 push1 = tempax; /* push ax */
5016 if (resinfo != 0x09) {
5017 tempax = tempax << 1;
5021 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5022 if (pVBInfo->VBType & VB_XGI301LV) {
5023 if (pVBInfo->TVInfo & SetYPbPrMode1080i) {
5026 if (pVBInfo->TVInfo & TVSimuMode) {
5027 if (pVBInfo->TVInfo & SetPALTV) {
5028 if (pVBInfo->VBType &
5030 if (!(pVBInfo->TVInfo &
5033 SetYPbPrMode1080i)))
5045 if (pVBInfo->TVInfo & TVSimuMode) {
5046 if (pVBInfo->TVInfo & SetPALTV) {
5047 if (pVBInfo->VBType & VB_XGI301LV) {
5048 if (!(pVBInfo->TVInfo &
5051 SetYPbPrMode1080i)))
5060 tempax = tempax >> 2;
5063 push1 = tempax; /* push ax */
5065 if ((pVBInfo->TVInfo & SetPALTV)) {
5066 if (tempbx <= 513) {
5072 temp = tempbx & 0x00FF;
5073 xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp);
5075 temp = tempbx & 0x00FF;
5076 xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp);
5078 if (tempbx & 0x0100)
5081 if (tempbx & 0x0200)
5082 xgifb_reg_and_or(pVBInfo->Part1Port, 0x0B, 0x0FF, 0x20);
5086 if (tempbx & 0x0100)
5089 if (tempbx & 0x0200)
5092 if (tempbx & 0x0400)
5095 tempbx = push1; /* pop ax */
5096 temp = tempbx & 0x00FF;
5098 /* 0x0D vertical Retrace End */
5099 xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp);
5101 if (tempbx & 0x0010)
5104 temp = tempcx & 0x00FF;
5105 xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); /* 0x0A CR07 */
5106 temp = (tempcx & 0x0FF00) >> 8;
5107 xgifb_reg_set(pVBInfo->Part1Port, 0x17, temp); /* 0x17 SR0A */
5109 temp = (tempax & 0xFF00) >> 8;
5111 temp = (temp >> 1) & 0x09;
5113 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C))
5116 xgifb_reg_set(pVBInfo->Part1Port, 0x16, temp); /* 0x16 SR01 */
5117 xgifb_reg_set(pVBInfo->Part1Port, 0x0F, 0); /* 0x0F CR14 */
5118 xgifb_reg_set(pVBInfo->Part1Port, 0x12, 0); /* 0x12 CR17 */
5120 if (pVBInfo->LCDInfo & LCDRGB18Bit)
5125 xgifb_reg_set(pVBInfo->Part1Port, 0x1A, temp); /* 0x1A SR0E */
5130 static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex,
5131 unsigned short RefreshRateTableIndex,
5132 struct xgi_hw_device_info *HwDeviceExtension,
5133 struct vb_device_info *pVBInfo)
5135 unsigned short i, j, tempax, tempbx, tempcx, temp, push1, push2,
5136 modeflag, resinfo, crt2crtc;
5137 unsigned char *TimingPoint;
5139 unsigned long longtemp, tempeax, tempebx, temp2, tempecx;
5141 if (ModeNo <= 0x13) {
5143 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
5144 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
5145 crt2crtc = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
5147 /* si+Ext_ResInfo */
5148 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
5149 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
5150 crt2crtc = pVBInfo->RefIndex[RefreshRateTableIndex].
5156 if (!(pVBInfo->VBInfo & SetCRT2ToAVIDEO))
5159 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
5162 if (pVBInfo->VBInfo & SetCRT2ToSCART)
5165 if (!(pVBInfo->TVInfo & SetPALTV))
5168 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5171 if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))
5174 tempax = (tempax & 0xff00) >> 8;
5176 xgifb_reg_set(pVBInfo->Part2Port, 0x0, tempax);
5177 TimingPoint = pVBInfo->NTSCTiming;
5179 if (pVBInfo->TVInfo & SetPALTV)
5180 TimingPoint = pVBInfo->PALTiming;
5182 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5183 TimingPoint = pVBInfo->HiTVExtTiming;
5185 if (pVBInfo->VBInfo & SetInSlaveMode)
5186 TimingPoint = pVBInfo->HiTVSt2Timing;
5188 if (pVBInfo->SetFlag & TVSimuMode)
5189 TimingPoint = pVBInfo->HiTVSt1Timing;
5191 if (!(modeflag & Charx8Dot))
5192 TimingPoint = pVBInfo->HiTVTextTiming;
5195 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
5196 if (pVBInfo->TVInfo & SetYPbPrMode525i)
5197 TimingPoint = pVBInfo->YPbPr525iTiming;
5199 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5200 TimingPoint = pVBInfo->YPbPr525pTiming;
5202 if (pVBInfo->TVInfo & SetYPbPrMode750p)
5203 TimingPoint = pVBInfo->YPbPr750pTiming;
5206 for (i = 0x01, j = 0; i <= 0x2D; i++, j++)
5207 xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]);
5209 for (i = 0x39; i <= 0x45; i++, j++)
5211 xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]);
5213 if (pVBInfo->VBInfo & SetCRT2ToTV)
5214 xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, 0x00);
5216 temp = pVBInfo->NewFlickerMode;
5218 xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xFF, temp);
5220 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5223 if (pVBInfo->TVInfo & SetPALTV)
5228 if (pVBInfo->VDE <= tempax) {
5229 tempax -= pVBInfo->VDE;
5230 tempax = tempax >> 2;
5231 tempax = (tempax & 0x00FF) | ((tempax & 0x00FF) << 8);
5233 temp = (tempax & 0xFF00) >> 8;
5234 temp += (unsigned short) TimingPoint[0];
5236 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5237 | VB_XGI302LV | VB_XGI301C)) {
5238 if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO
5239 | SetCRT2ToSVIDEO | SetCRT2ToSCART
5240 | SetCRT2ToYPbPr)) {
5241 tempcx = pVBInfo->VGAHDE;
5242 if (tempcx >= 1024) {
5243 temp = 0x17; /* NTSC */
5244 if (pVBInfo->TVInfo & SetPALTV)
5245 temp = 0x19; /* PAL */
5250 xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp);
5252 temp = (tempax & 0xFF00) >> 8;
5253 temp += TimingPoint[1];
5255 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5256 | VB_XGI302LV | VB_XGI301C)) {
5257 if ((pVBInfo->VBInfo & (SetCRT2ToAVIDEO
5258 | SetCRT2ToSVIDEO | SetCRT2ToSCART
5259 | SetCRT2ToYPbPr))) {
5260 tempcx = pVBInfo->VGAHDE;
5261 if (tempcx >= 1024) {
5262 temp = 0x1D; /* NTSC */
5263 if (pVBInfo->TVInfo & SetPALTV)
5264 temp = 0x52; /* PAL */
5268 xgifb_reg_set(pVBInfo->Part2Port, 0x02, temp);
5272 tempcx = pVBInfo->HT;
5274 if (XGI_IsLCDDualLink(pVBInfo))
5275 tempcx = tempcx >> 1;
5278 temp = tempcx & 0x00FF;
5279 xgifb_reg_set(pVBInfo->Part2Port, 0x1B, temp);
5281 temp = (tempcx & 0xFF00) >> 8;
5282 xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F, temp);
5284 tempcx = pVBInfo->HT >> 1;
5285 push1 = tempcx; /* push cx */
5288 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5291 temp = tempcx & 0x00FF;
5293 xgifb_reg_and_or(pVBInfo->Part2Port, 0x22, 0x0F, temp);
5295 tempbx = TimingPoint[j] | ((TimingPoint[j + 1]) << 8);
5298 temp = tempbx & 0x00FF;
5299 xgifb_reg_set(pVBInfo->Part2Port, 0x24, temp);
5300 temp = (tempbx & 0xFF00) >> 8;
5302 xgifb_reg_and_or(pVBInfo->Part2Port, 0x25, 0x0F, temp);
5305 tempbx = tempbx + 8;
5306 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5307 tempbx = tempbx - 4;
5311 temp = (tempbx & 0x00FF) << 4;
5312 xgifb_reg_and_or(pVBInfo->Part2Port, 0x29, 0x0F, temp);
5315 tempcx += (TimingPoint[j] | ((TimingPoint[j + 1]) << 8));
5316 temp = tempcx & 0x00FF;
5317 xgifb_reg_set(pVBInfo->Part2Port, 0x27, temp);
5318 temp = ((tempcx & 0xFF00) >> 8) << 4;
5319 xgifb_reg_and_or(pVBInfo->Part2Port, 0x28, 0x0F, temp);
5322 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5325 temp = tempcx & 0xFF;
5327 xgifb_reg_and_or(pVBInfo->Part2Port, 0x2A, 0x0F, temp);
5329 tempcx = push1; /* pop cx */
5331 temp = TimingPoint[j] | ((TimingPoint[j + 1]) << 8);
5333 temp = tempcx & 0x00FF;
5335 xgifb_reg_and_or(pVBInfo->Part2Port, 0x2D, 0x0F, temp);
5339 if (!(pVBInfo->VBInfo & SetCRT2ToTV)) {
5340 tempax = XGI_GetVGAHT2(pVBInfo);
5341 tempcx = tempax - 1;
5343 temp = tempcx & 0x00FF;
5344 xgifb_reg_set(pVBInfo->Part2Port, 0x2E, temp);
5346 tempbx = pVBInfo->VDE;
5348 if (pVBInfo->VGAVDE == 360)
5350 if (pVBInfo->VGAVDE == 375)
5352 if (pVBInfo->VGAVDE == 405)
5355 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5356 if (pVBInfo->VBType &
5357 (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
5358 if (!(pVBInfo->TVInfo &
5359 (SetYPbPrMode525p | SetYPbPrMode750p)))
5360 tempbx = tempbx >> 1;
5362 tempbx = tempbx >> 1;
5366 temp = tempbx & 0x00FF;
5368 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5369 if (pVBInfo->VBType & VB_XGI301LV) {
5370 if (pVBInfo->TVInfo & SetYPbPrMode1080i) {
5371 if (pVBInfo->VBInfo & SetInSlaveMode) {
5377 if (pVBInfo->VBInfo & SetInSlaveMode) {
5384 xgifb_reg_set(pVBInfo->Part2Port, 0x2F, temp);
5386 temp = (tempcx & 0xFF00) >> 8;
5387 temp |= ((tempbx & 0xFF00) >> 8) << 6;
5389 if (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)) {
5390 if (pVBInfo->VBType & VB_XGI301LV) {
5391 if (pVBInfo->TVInfo & SetYPbPrMode1080i) {
5394 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
5399 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
5404 xgifb_reg_set(pVBInfo->Part2Port, 0x30, temp);
5406 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5407 | VB_XGI302LV | VB_XGI301C)) { /* TV gatingno */
5408 tempbx = pVBInfo->VDE;
5409 tempcx = tempbx - 2;
5411 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5412 if (!(pVBInfo->TVInfo & (SetYPbPrMode525p
5413 | SetYPbPrMode750p)))
5414 tempbx = tempbx >> 1;
5417 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
5419 if (tempcx & 0x0400)
5422 if (tempbx & 0x0400)
5425 xgifb_reg_set(pVBInfo->Part4Port, 0x10, temp);
5428 temp = (((tempbx - 3) & 0x0300) >> 8) << 5;
5429 xgifb_reg_set(pVBInfo->Part2Port, 0x46, temp);
5430 temp = (tempbx - 3) & 0x00FF;
5431 xgifb_reg_set(pVBInfo->Part2Port, 0x47, temp);
5434 tempbx = tempbx & 0x00FF;
5436 if (!(modeflag & HalfDCLK)) {
5437 tempcx = pVBInfo->VGAHDE;
5438 if (tempcx >= pVBInfo->HDE) {
5446 if (pVBInfo->VBInfo & SetCRT2ToTV) { /*301b*/
5447 if (pVBInfo->VGAHDE >= 1024) {
5449 if (pVBInfo->VGAHDE >= 1280) {
5451 tempbx = tempbx & 0xDFFF;
5456 if (!(tempbx & 0x2000)) {
5457 if (modeflag & HalfDCLK)
5458 tempcx = (tempcx & 0xFF00) | ((tempcx & 0x00FF) << 1);
5461 tempeax = pVBInfo->VGAHDE;
5462 tempebx = (tempcx & 0xFF00) >> 8;
5463 longtemp = tempeax * tempebx;
5464 tempecx = tempcx & 0x00FF;
5465 longtemp = longtemp / tempecx;
5470 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5471 | VB_XGI302LV | VB_XGI301C)) {
5472 tempecx = tempecx * 8;
5475 longtemp = longtemp * tempecx;
5476 tempecx = pVBInfo->HDE;
5477 temp2 = longtemp % tempecx;
5478 tempeax = longtemp / tempecx;
5482 tempax = (unsigned short) tempeax;
5485 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5486 | VB_XGI302LV | VB_XGI301C)) {
5487 tempcx = ((tempax & 0xFF00) >> 5) >> 8;
5492 tempbx = (unsigned short) (((tempeax & 0x0000FF00) & 0x1F00)
5493 | (tempbx & 0x00FF));
5494 tempax = (unsigned short) (((tempeax & 0x000000FF) << 8)
5495 | (tempax & 0x00FF));
5496 temp = (tempax & 0xFF00) >> 8;
5498 temp = (tempax & 0x00FF) >> 8;
5501 xgifb_reg_set(pVBInfo->Part2Port, 0x44, temp);
5502 temp = (tempbx & 0xFF00) >> 8;
5503 xgifb_reg_and_or(pVBInfo->Part2Port, 0x45, ~0x03F, temp);
5504 temp = tempcx & 0x00FF;
5506 if (tempbx & 0x2000)
5509 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
5512 xgifb_reg_and_or(pVBInfo->Part2Port, 0x46, ~0x1F, temp);
5513 if (pVBInfo->TVInfo & SetPALTV) {
5521 temp = tempbx & 0x00FF;
5522 xgifb_reg_set(pVBInfo->Part2Port, 0x4b, temp);
5523 temp = tempcx & 0x00FF;
5524 xgifb_reg_set(pVBInfo->Part2Port, 0x4c, temp);
5526 temp = ((tempcx & 0xFF00) >> 8) & 0x03;
5528 temp |= ((tempbx & 0xFF00) >> 8) & 0x03;
5530 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
5533 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5536 if (pVBInfo->TVInfo & SetYPbPrMode750p)
5540 xgifb_reg_set(pVBInfo->Part2Port, 0x4d, temp);
5541 temp = xgifb_reg_get(pVBInfo->Part2Port, 0x43); /* 301b change */
5542 xgifb_reg_set(pVBInfo->Part2Port, 0x43, (unsigned short) (temp - 3));
5544 if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))) {
5545 if (pVBInfo->TVInfo & NTSC1024x768) {
5546 TimingPoint = XGI_NTSC1024AdjTime;
5547 for (i = 0x1c, j = 0; i <= 0x30; i++, j++) {
5548 xgifb_reg_set(pVBInfo->Part2Port, i,
5551 xgifb_reg_set(pVBInfo->Part2Port, 0x43, 0x72);
5555 /* [ycchen] 01/14/03 Modify for 301C PALM Support */
5556 if (pVBInfo->VBType & VB_XGI301C) {
5557 if (pVBInfo->TVInfo & SetPALMTV)
5558 xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x08,
5559 0x08); /* PALM Mode */
5562 if (pVBInfo->TVInfo & SetPALMTV) {
5563 tempax = (unsigned char) xgifb_reg_get(pVBInfo->Part2Port,
5566 xgifb_reg_and(pVBInfo->Part2Port, 0x01, tempax);
5568 /* if ( !( pVBInfo->VBType & VB_XGI301C ) ) */
5569 xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xEF);
5572 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5573 if (!(pVBInfo->VBInfo & SetInSlaveMode))
5574 xgifb_reg_set(pVBInfo->Part2Port, 0x0B, 0x00);
5577 if (pVBInfo->VBInfo & SetCRT2ToTV)
5581 static void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
5582 struct xgi_hw_device_info *HwDeviceExtension,
5583 unsigned short RefreshRateTableIndex,
5584 struct vb_device_info *pVBInfo)
5586 unsigned short push1, push2, pushbx, tempax, tempbx, tempcx, temp,
5587 tempah, tempbh, tempch, resinfo, modeflag, CRT1Index;
5589 struct XGI_LCDDesStruct *LCDBDesPtr = NULL;
5591 if (ModeNo <= 0x13) {
5593 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
5594 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
5596 /* si+Ext_ResInfo */
5597 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
5598 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
5599 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].
5601 CRT1Index &= IndexMask;
5604 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
5607 tempbx = pVBInfo->HDE; /* RHACTE=HDE-1 */
5609 if (XGI_IsLCDDualLink(pVBInfo))
5610 tempbx = tempbx >> 1;
5613 temp = tempbx & 0x00FF;
5614 xgifb_reg_set(pVBInfo->Part2Port, 0x2C, temp);
5615 temp = (tempbx & 0xFF00) >> 8;
5617 xgifb_reg_and_or(pVBInfo->Part2Port, 0x2B, 0x0F, temp);
5620 if (pVBInfo->LCDResInfo == Panel1280x1024) {
5621 if (pVBInfo->ModeType == ModeEGA) {
5622 if (pVBInfo->VGAHDE >= 1024) {
5624 if (pVBInfo->LCDInfo & LCDVESATiming)
5630 xgifb_reg_set(pVBInfo->Part2Port, 0x0B, temp);
5631 tempbx = pVBInfo->VDE; /* RTVACTEO=(VDE-1)&0xFF */
5634 temp = tempbx & 0x00FF;
5635 xgifb_reg_set(pVBInfo->Part2Port, 0x03, temp);
5636 temp = ((tempbx & 0xFF00) >> 8) & 0x07;
5637 xgifb_reg_and_or(pVBInfo->Part2Port, 0x0C, ~0x07, temp);
5639 tempcx = pVBInfo->VT - 1;
5641 temp = tempcx & 0x00FF; /* RVTVT=VT-1 */
5642 xgifb_reg_set(pVBInfo->Part2Port, 0x19, temp);
5643 temp = (tempcx & 0xFF00) >> 8;
5645 xgifb_reg_set(pVBInfo->Part2Port, 0x1A, temp);
5646 xgifb_reg_and_or(pVBInfo->Part2Port, 0x09, 0xF0, 0x00);
5647 xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xF0, 0x00);
5648 xgifb_reg_and_or(pVBInfo->Part2Port, 0x17, 0xFB, 0x00);
5649 xgifb_reg_and_or(pVBInfo->Part2Port, 0x18, 0xDF, 0x00);
5651 /* Customized LCDB Des no add */
5653 LCDBDesPtr = (struct XGI_LCDDesStruct *) XGI_GetLcdPtr(tempbx, ModeNo,
5654 ModeIdIndex, RefreshRateTableIndex, pVBInfo);
5655 tempah = pVBInfo->LCDResInfo;
5656 tempah &= PanelResInfo;
5658 if ((tempah == Panel1024x768) || (tempah == Panel1024x768x75)) {
5661 } else if ((tempah == Panel1280x1024) ||
5662 (tempah == Panel1280x1024x75)) {
5665 } else if (tempah == Panel1400x1050) {
5673 if (pVBInfo->LCDInfo & EnableScalingLCD) {
5674 tempbx = pVBInfo->HDE;
5675 tempcx = pVBInfo->VDE;
5679 tempax = pVBInfo->VT;
5680 pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES;
5681 pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS;
5682 pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES;
5683 pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS;
5684 tempbx = pVBInfo->LCDVDES;
5687 if (tempcx >= tempax)
5688 tempcx -= tempax; /* lcdvdes */
5690 temp = tempbx & 0x00FF; /* RVEQ1EQ=lcdvdes */
5691 xgifb_reg_set(pVBInfo->Part2Port, 0x05, temp);
5692 temp = tempcx & 0x00FF;
5693 xgifb_reg_set(pVBInfo->Part2Port, 0x06, temp);
5694 tempch = ((tempcx & 0xFF00) >> 8) & 0x07;
5695 tempbh = ((tempbx & 0xFF00) >> 8) & 0x07;
5697 tempah = tempah << 3;
5699 xgifb_reg_set(pVBInfo->Part2Port, 0x02, tempah);
5702 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
5704 tempax = pVBInfo->VT;
5705 tempbx = pVBInfo->LCDVRS;
5707 /* if (SetLCD_Info & EnableScalingLCD) */
5709 if (tempcx >= tempax)
5712 temp = tempbx & 0x00FF; /* RTVACTEE=lcdvrs */
5713 xgifb_reg_set(pVBInfo->Part2Port, 0x04, temp);
5714 temp = (tempbx & 0xFF00) >> 8;
5716 temp |= (tempcx & 0x000F);
5717 xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp);
5719 tempax = pVBInfo->HT;
5720 tempbx = pVBInfo->LCDHDES;
5723 if (XGI_IsLCDDualLink(pVBInfo)) {
5724 tempax = tempax >> 1;
5725 tempbx = tempbx >> 1;
5726 tempcx = tempcx >> 1;
5729 if (pVBInfo->VBType & VB_XGI302LV)
5732 if (pVBInfo->VBType & VB_XGI301C) /* tap4 */
5737 if (tempcx >= tempax)
5740 temp = tempbx & 0x00FF;
5741 xgifb_reg_set(pVBInfo->Part2Port, 0x1F, temp); /* RHBLKE=lcdhdes */
5742 temp = ((tempbx & 0xFF00) >> 8) << 4;
5743 xgifb_reg_set(pVBInfo->Part2Port, 0x20, temp);
5744 temp = tempcx & 0x00FF;
5745 xgifb_reg_set(pVBInfo->Part2Port, 0x23, temp); /* RHEQPLE=lcdhdee */
5746 temp = (tempcx & 0xFF00) >> 8;
5747 xgifb_reg_set(pVBInfo->Part2Port, 0x25, temp);
5750 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
5752 tempax = pVBInfo->HT;
5753 tempbx = pVBInfo->LCDHRS;
5754 /* if ( SetLCD_Info & EnableScalingLCD) */
5755 if (XGI_IsLCDDualLink(pVBInfo)) {
5756 tempax = tempax >> 1;
5757 tempbx = tempbx >> 1;
5758 tempcx = tempcx >> 1;
5761 if (pVBInfo->VBType & VB_XGI302LV)
5766 if (tempcx >= tempax)
5769 temp = tempbx & 0x00FF; /* RHBURSTS=lcdhrs */
5770 xgifb_reg_set(pVBInfo->Part2Port, 0x1C, temp);
5772 temp = (tempbx & 0xFF00) >> 8;
5774 xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F0, temp);
5775 temp = tempcx & 0x00FF; /* RHSYEXP2S=lcdhre */
5776 xgifb_reg_set(pVBInfo->Part2Port, 0x21, temp);
5778 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
5779 if (pVBInfo->VGAVDE == 525) {
5780 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
5781 | VB_XGI301LV | VB_XGI302LV
5787 xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp);
5788 xgifb_reg_set(pVBInfo->Part2Port, 0x30, 0xB3);
5791 if (pVBInfo->VGAVDE == 420) {
5792 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
5793 | VB_XGI301LV | VB_XGI302LV
5798 xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp);
5803 /* --------------------------------------------------------------------- */
5804 /* Function : XGI_GetTap4Ptr */
5806 /* Output : di -> Tap4 Reg. Setting Pointer */
5808 /* --------------------------------------------------------------------- */
5809 static struct XGI301C_Tap4TimingStruct *XGI_GetTap4Ptr(unsigned short tempcx,
5810 struct vb_device_info *pVBInfo)
5812 unsigned short tempax, tempbx, i;
5814 struct XGI301C_Tap4TimingStruct *Tap4TimingPtr;
5817 tempax = pVBInfo->VGAHDE;
5818 tempbx = pVBInfo->HDE;
5820 tempax = pVBInfo->VGAVDE;
5821 tempbx = pVBInfo->VDE;
5824 if (tempax < tempbx)
5825 return &EnlargeTap4Timing[0];
5826 else if (tempax == tempbx)
5827 return &NoScaleTap4Timing[0]; /* 1:1 */
5829 Tap4TimingPtr = NTSCTap4Timing; /* NTSC */
5831 if (pVBInfo->TVInfo & SetPALTV)
5832 Tap4TimingPtr = PALTap4Timing;
5834 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
5835 if (pVBInfo->TVInfo & SetYPbPrMode525i)
5836 Tap4TimingPtr = YPbPr525iTap4Timing;
5837 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5838 Tap4TimingPtr = YPbPr525pTap4Timing;
5839 if (pVBInfo->TVInfo & SetYPbPrMode750p)
5840 Tap4TimingPtr = YPbPr750pTap4Timing;
5843 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5844 Tap4TimingPtr = HiTVTap4Timing;
5847 while (Tap4TimingPtr[i].DE != 0xFFFF) {
5848 if (Tap4TimingPtr[i].DE == tempax)
5852 return &Tap4TimingPtr[i];
5855 static void XGI_SetTap4Regs(struct vb_device_info *pVBInfo)
5857 unsigned short i, j;
5859 struct XGI301C_Tap4TimingStruct *Tap4TimingPtr;
5861 if (!(pVBInfo->VBType & VB_XGI301C))
5865 xgifb_reg_and(pVBInfo->Part2Port, 0x4E, 0xEB); /* Disable Tap4 */
5866 #else /* Tap4 Setting */
5868 Tap4TimingPtr = XGI_GetTap4Ptr(0, pVBInfo); /* Set Horizontal Scaling */
5869 for (i = 0x80, j = 0; i <= 0xBF; i++, j++)
5870 xgifb_reg_set(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]);
5872 if ((pVBInfo->VBInfo & SetCRT2ToTV) &&
5873 (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV))) {
5874 /* Set Vertical Scaling */
5875 Tap4TimingPtr = XGI_GetTap4Ptr(1, pVBInfo);
5876 for (i = 0xC0, j = 0; i < 0xFF; i++, j++)
5877 xgifb_reg_set(pVBInfo->Part2Port,
5879 Tap4TimingPtr->Reg[j]);
5882 if ((pVBInfo->VBInfo & SetCRT2ToTV) &&
5883 (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)))
5884 /* Enable V.Scaling */
5885 xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x04);
5887 /* Enable H.Scaling */
5888 xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x10);
5892 static void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex,
5893 struct vb_device_info *pVBInfo)
5896 unsigned char *tempdi;
5897 unsigned short modeflag;
5901 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
5903 /* si+Ext_ResInfo */
5904 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
5906 xgifb_reg_set(pVBInfo->Part3Port, 0x00, 0x00);
5907 if (pVBInfo->TVInfo & SetPALTV) {
5908 xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA);
5909 xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8);
5911 xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xF5);
5912 xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xB7);
5915 if (!(pVBInfo->VBInfo & SetCRT2ToTV))
5918 if (pVBInfo->TVInfo & SetPALMTV) {
5919 xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA);
5920 xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8);
5921 xgifb_reg_set(pVBInfo->Part3Port, 0x3D, 0xA8);
5924 if ((pVBInfo->VBInfo & SetCRT2ToHiVisionTV) || (pVBInfo->VBInfo
5925 & SetCRT2ToYPbPr)) {
5926 if (pVBInfo->TVInfo & SetYPbPrMode525i)
5929 tempdi = pVBInfo->HiTVGroup3Data;
5930 if (pVBInfo->SetFlag & TVSimuMode) {
5931 tempdi = pVBInfo->HiTVGroup3Simu;
5932 if (!(modeflag & Charx8Dot))
5933 tempdi = pVBInfo->HiTVGroup3Text;
5936 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5937 tempdi = pVBInfo->Ren525pGroup3;
5939 if (pVBInfo->TVInfo & SetYPbPrMode750p)
5940 tempdi = pVBInfo->Ren750pGroup3;
5942 for (i = 0; i <= 0x3E; i++)
5943 xgifb_reg_set(pVBInfo->Part3Port, i, tempdi[i]);
5945 if (pVBInfo->VBType & VB_XGI301C) { /* Marcovision */
5946 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5947 xgifb_reg_set(pVBInfo->Part3Port, 0x28, 0x3f);
5951 } /* {end of XGI_SetGroup3} */
5953 static void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex,
5954 unsigned short RefreshRateTableIndex,
5955 struct xgi_hw_device_info *HwDeviceExtension,
5956 struct vb_device_info *pVBInfo)
5958 unsigned short tempax, tempcx, tempbx, modeflag, temp, temp2;
5960 unsigned long tempebx, tempeax, templong;
5964 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
5966 /* si+Ext_ResInfo */
5967 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
5969 temp = pVBInfo->RVBHCFACT;
5970 xgifb_reg_set(pVBInfo->Part4Port, 0x13, temp);
5972 tempbx = pVBInfo->RVBHCMAX;
5973 temp = tempbx & 0x00FF;
5974 xgifb_reg_set(pVBInfo->Part4Port, 0x14, temp);
5975 temp2 = ((tempbx & 0xFF00) >> 8) << 7;
5976 tempcx = pVBInfo->VGAHT - 1;
5977 temp = tempcx & 0x00FF;
5978 xgifb_reg_set(pVBInfo->Part4Port, 0x16, temp);
5980 temp = ((tempcx & 0xFF00) >> 8) << 3;
5983 tempcx = pVBInfo->VGAVT - 1;
5984 if (!(pVBInfo->VBInfo & SetCRT2ToTV))
5987 temp = tempcx & 0x00FF;
5988 xgifb_reg_set(pVBInfo->Part4Port, 0x17, temp);
5989 temp = temp2 | ((tempcx & 0xFF00) >> 8);
5990 xgifb_reg_set(pVBInfo->Part4Port, 0x15, temp);
5991 xgifb_reg_or(pVBInfo->Part4Port, 0x0D, 0x08);
5992 tempcx = pVBInfo->VBInfo;
5993 tempbx = pVBInfo->VGAHDE;
5995 if (modeflag & HalfDCLK)
5996 tempbx = tempbx >> 1;
5998 if (XGI_IsLCDDualLink(pVBInfo))
5999 tempbx = tempbx >> 1;
6001 if (tempcx & SetCRT2ToHiVisionTV) {
6007 } else if (tempcx & SetCRT2ToTV) {
6013 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
6020 if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)) {
6022 if (pVBInfo->VGAHDE == 1280)
6024 if (pVBInfo->VGAHDE == 1024)
6027 xgifb_reg_and_or(pVBInfo->Part4Port, 0x0E, ~0xEF, temp);
6029 tempebx = pVBInfo->VDE;
6031 if (tempcx & SetCRT2ToHiVisionTV) {
6032 if (!(temp & 0xE000))
6033 tempbx = tempbx >> 1;
6036 tempcx = pVBInfo->RVBHRS;
6037 temp = tempcx & 0x00FF;
6038 xgifb_reg_set(pVBInfo->Part4Port, 0x18, temp);
6040 tempeax = pVBInfo->VGAVDE;
6043 if (tempeax <= tempebx) {
6044 tempcx = (tempcx & (~0x4000));
6045 tempeax = pVBInfo->VGAVDE;
6050 templong = (tempeax * 256 * 1024) % tempebx;
6051 tempeax = (tempeax * 256 * 1024) / tempebx;
6057 temp = (unsigned short) (tempebx & 0x000000FF);
6058 xgifb_reg_set(pVBInfo->Part4Port, 0x1B, temp);
6060 temp = (unsigned short) ((tempebx & 0x0000FF00) >> 8);
6061 xgifb_reg_set(pVBInfo->Part4Port, 0x1A, temp);
6062 tempbx = (unsigned short) (tempebx >> 16);
6063 temp = tempbx & 0x00FF;
6065 temp |= ((tempcx & 0xFF00) >> 8);
6066 xgifb_reg_set(pVBInfo->Part4Port, 0x19, temp);
6069 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
6070 | VB_XGI302LV | VB_XGI301C)) {
6072 xgifb_reg_set(pVBInfo->Part4Port, 0x1C, temp);
6073 tempax = pVBInfo->VGAHDE;
6074 if (modeflag & HalfDCLK)
6075 tempax = tempax >> 1;
6077 if (XGI_IsLCDDualLink(pVBInfo))
6078 tempax = tempax >> 1;
6080 /* if((pVBInfo->VBInfo&(SetCRT2ToLCD)) ||
6081 ((pVBInfo->TVInfo&SetYPbPrMode525p) ||
6082 (pVBInfo->TVInfo&SetYPbPrMode750p))) { */
6083 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
6087 if (pVBInfo->VGAHDE > 800) {
6088 if (pVBInfo->VGAHDE == 1024)
6089 tempax = (tempax * 25 / 32) - 1;
6091 tempax = (tempax * 20 / 32) - 1;
6097 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVisionTV)) {
6098 if (pVBInfo->VBType & VB_XGI301LV) {
6099 if (!(pVBInfo->TVInfo &
6102 SetYPbPrMode1080i))) {
6103 if (pVBInfo->VGAHDE > 800) {
6104 if (pVBInfo->VGAHDE == 1024)
6105 tempax =(tempax * 25 /
6108 tempax = (tempax * 20 /
6113 if (pVBInfo->VGAHDE > 800) {
6114 if (pVBInfo->VGAHDE == 1024)
6115 tempax = (tempax * 25 / 32) - 1;
6117 tempax = (tempax * 20 / 32) - 1;
6123 temp = (tempax & 0xFF00) >> 8;
6124 temp = ((temp & 0x0003) << 4);
6125 xgifb_reg_set(pVBInfo->Part4Port, 0x1E, temp);
6126 temp = (tempax & 0x00FF);
6127 xgifb_reg_set(pVBInfo->Part4Port, 0x1D, temp);
6129 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVisionTV)) {
6130 if (pVBInfo->VGAHDE > 800)
6131 xgifb_reg_or(pVBInfo->Part4Port, 0x1E, 0x08);
6136 if (pVBInfo->VBInfo & SetCRT2ToTV) {
6137 if (!(pVBInfo->TVInfo & (NTSC1024x768
6138 | SetYPbPrMode525p | SetYPbPrMode750p
6139 | SetYPbPrMode1080i))) {
6141 if ((pVBInfo->VBInfo & SetInSlaveMode)
6142 && (!(pVBInfo->TVInfo
6148 xgifb_reg_and_or(pVBInfo->Part4Port, 0x1F, 0x00C0, temp);
6149 tempbx = pVBInfo->HT;
6150 if (XGI_IsLCDDualLink(pVBInfo))
6151 tempbx = tempbx >> 1;
6152 tempbx = (tempbx >> 1) - 2;
6153 temp = ((tempbx & 0x0700) >> 8) << 3;
6154 xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, 0x00C0, temp);
6155 temp = tempbx & 0x00FF;
6156 xgifb_reg_set(pVBInfo->Part4Port, 0x22, temp);
6160 if (pVBInfo->ISXPDOS == 0)
6161 XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex,
6165 static void XGINew_EnableCRT2(struct vb_device_info *pVBInfo)
6167 xgifb_reg_and_or(pVBInfo->P3c4, 0x1E, 0xFF, 0x20);
6170 static void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex,
6171 struct vb_device_info *pVBInfo)
6173 unsigned short Pindex, Pdata;
6175 Pindex = pVBInfo->Part5Port;
6176 Pdata = pVBInfo->Part5Port + 1;
6177 if (pVBInfo->ModeType == ModeVGA) {
6178 if (!(pVBInfo->VBInfo & (SetInSlaveMode | LoadDACFlag
6179 | CRT2DisplayFlag))) {
6180 XGINew_EnableCRT2(pVBInfo);
6181 /* LoadDAC2(pVBInfo->Part5Port, ModeNo, ModeIdIndex); */
6187 static void XGI_EnableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension,
6188 struct vb_device_info *pVBInfo)
6190 xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x40);
6193 static void XGI_DisableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension,
6194 struct vb_device_info *pVBInfo)
6197 xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x00);
6200 /*----------------------------------------------------------------------------*/
6202 /* bl[5] : 1;LVDS signal on */
6203 /* bl[1] : 1;LVDS backlight on */
6204 /* bl[0] : 1:LVDS VDD on */
6205 /* bh: 100000b : clear bit 5, to set bit5 */
6206 /* 000010b : clear bit 1, to set bit1 */
6207 /* 000001b : clear bit 0, to set bit0 */
6208 /*----------------------------------------------------------------------------*/
6209 void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl,
6210 struct vb_device_info *pVBInfo)
6212 unsigned char CR4A, temp;
6214 CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
6217 xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */
6219 if (tempbh & 0x20) {
6220 temp = (tempbl >> 4) & 0x02;
6223 xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp);
6227 temp = xgifb_reg_get(pVBInfo->P3d4, 0x48);
6229 temp = XG21GPIODataTransfer(temp);
6232 xgifb_reg_set(pVBInfo->P3d4, 0x48, temp);
6235 void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl,
6236 struct vb_device_info *pVBInfo)
6238 unsigned char CR4A, temp;
6239 unsigned short tempbh0, tempbl0;
6248 if (tempbh & 0x20) {
6249 temp = (tempbl >> 4) & 0x02;
6252 xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp);
6255 xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~tempbh0, tempbl0);
6257 CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
6261 tempbl <<= 2; /* GPIOC,GPIOD */
6262 xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */
6263 xgifb_reg_and_or(pVBInfo->P3d4, 0x48, ~tempbh, tempbl);
6266 /* --------------------------------------------------------------------- */
6267 unsigned short XGI_GetLVDSOEMTableIndex(struct vb_device_info *pVBInfo)
6269 unsigned short index;
6271 index = xgifb_reg_get(pVBInfo->P3d4, 0x36);
6272 if (index < sizeof(XGI21_LCDCapList)
6273 / sizeof(struct XGI21_LVDSCapStruct))
6278 /* --------------------------------------------------------------------- */
6279 /* Function : XGI_XG21SetPanelDelay */
6283 /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
6284 /* : bl : 2 ; T2 : the duration signal on and Vdd on */
6285 /* : bl : 3 ; T3 : the duration between CPL off and signal off */
6286 /* : bl : 4 ; T4 : the duration signal off and Vdd off */
6287 /* --------------------------------------------------------------------- */
6288 void XGI_XG21SetPanelDelay(unsigned short tempbl,
6289 struct vb_device_info *pVBInfo)
6291 unsigned short index;
6293 index = XGI_GetLVDSOEMTableIndex(pVBInfo);
6295 mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S1);
6298 mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S2);
6301 mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S3);
6304 mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S4);
6307 unsigned char XGI_XG21CheckLVDSMode(unsigned short ModeNo,
6308 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
6310 unsigned short xres, yres, colordepth, modeflag, resindex,
6313 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
6314 if (ModeNo <= 0x13) {
6315 xres = pVBInfo->StResInfo[resindex].HTotal;
6316 yres = pVBInfo->StResInfo[resindex].VTotal;
6318 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
6320 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
6321 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
6322 /* si+St_ModeFlag */
6323 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
6326 if (!(modeflag & Charx8Dot)) {
6331 if (ModeNo > 0x13) {
6332 if ((ModeNo > 0x13) && (modeflag & HalfDCLK))
6335 if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
6340 lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo);
6341 if (xres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE))
6344 if (yres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE))
6347 if (ModeNo > 0x13) {
6348 if ((xres != (pVBInfo->XG21_LVDSCapList[lvdstableindex].
6350 (yres != (pVBInfo->XG21_LVDSCapList[lvdstableindex].
6352 colordepth = XGI_GetColorDepth(ModeNo,
6363 void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo)
6367 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); /* D[0] 1: 18bit */
6368 temp = (temp & 1) << 6;
6369 /* SR06[6] 18bit Dither */
6370 xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x40, temp);
6371 /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */
6372 xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80);
6376 void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo)
6380 /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */
6381 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
6382 temp = (temp & 3) << 6;
6383 /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */
6384 xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0xc0, temp & 0x80);
6385 /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */
6386 xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80);
6390 static void xgifb_set_lvds(int chip_id,
6391 unsigned short ModeNo,
6392 unsigned short ModeIdIndex,
6393 struct vb_device_info *pVBInfo)
6395 unsigned char temp, Miscdata;
6396 unsigned short xres, yres, modeflag, resindex, lvdstableindex;
6397 unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE;
6398 unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE;
6399 unsigned short value;
6401 lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo);
6402 temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex].
6404 (LCDPolarity << 8)) >> 8);
6405 temp &= LCDPolarity;
6406 Miscdata = (unsigned char) inb(pVBInfo->P3cc);
6408 outb((Miscdata & 0x3F) | temp, pVBInfo->P3c2);
6410 temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex].
6411 LVDS_Capability & LCDPolarity);
6412 /* SR35[7] FP VSync polarity */
6413 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80);
6414 /* SR30[5] FP HSync polarity */
6415 xgifb_reg_and_or(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1);
6417 if (chip_id == XG27)
6418 XGI_SetXG27FPBits(pVBInfo);
6420 XGI_SetXG21FPBits(pVBInfo);
6422 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
6423 if (ModeNo <= 0x13) {
6424 xres = pVBInfo->StResInfo[resindex].HTotal;
6425 yres = pVBInfo->StResInfo[resindex].VTotal;
6427 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
6429 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
6430 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
6431 /* si+St_ModeFlag */
6432 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
6435 if (!(modeflag & Charx8Dot))
6436 xres = xres * 8 / 9;
6438 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
6440 LVDSHBS = xres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE
6442 if ((ModeNo <= 0x13) && (modeflag & HalfDCLK))
6443 LVDSHBS -= xres / 4;
6445 if (LVDSHBS > LVDSHT)
6448 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP;
6449 if (LVDSHRS > LVDSHT)
6452 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC;
6453 if (LVDSHRE > LVDSHT)
6456 LVDSHBE = LVDSHBS + LVDSHT
6457 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE;
6459 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
6461 LVDSVBS = yres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE
6463 if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
6464 LVDSVBS += yres / 2;
6466 if (LVDSVBS > LVDSVT)
6469 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP;
6470 if (LVDSVRS > LVDSVT)
6473 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].
6475 if (LVDSVRE > LVDSVT)
6478 LVDSVBE = LVDSVBS + LVDSVT
6479 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE;
6481 temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
6482 xgifb_reg_set(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */
6484 if (!(modeflag & Charx8Dot))
6485 xgifb_reg_or(pVBInfo->P3c4, 0x1, 0x1);
6487 /* HT SR0B[1:0] CR00 */
6488 value = (LVDSHT >> 3) - 5;
6489 xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8);
6490 xgifb_reg_set(pVBInfo->P3d4, 0x0, (value & 0xFF));
6492 /* HBS SR0B[5:4] CR02 */
6493 value = (LVDSHBS >> 3) - 1;
6494 xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4);
6495 xgifb_reg_set(pVBInfo->P3d4, 0x2, (value & 0xFF));
6497 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
6498 value = (LVDSHBE >> 3) - 1;
6499 xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6);
6500 xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2);
6501 xgifb_reg_and_or(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F);
6503 /* HRS SR0B[7:6] CR04 */
6504 value = (LVDSHRS >> 3) + 2;
6505 xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2);
6506 xgifb_reg_set(pVBInfo->P3d4, 0x4, (value & 0xFF));
6508 /* Panel HRS SR2F[1:0] SR2E[7:0] */
6510 xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8);
6511 xgifb_reg_set(pVBInfo->P3c4, 0x2E, (value & 0xFF));
6513 /* HRE SR0C[2] CR05[4:0] */
6514 value = (LVDSHRE >> 3) + 2;
6515 xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3);
6516 xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F);
6518 /* Panel HRE SR2F[7:2] */
6520 xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2);
6522 /* VT SR0A[0] CR07[5][0] CR06 */
6524 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10);
6525 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4);
6526 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8);
6527 xgifb_reg_set(pVBInfo->P3d4, 0x06, (value & 0xFF));
6529 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
6530 value = LVDSVBS - 1;
6531 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8);
6532 xgifb_reg_and_or(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4);
6533 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5);
6534 xgifb_reg_set(pVBInfo->P3d4, 0x15, (value & 0xFF));
6536 /* VBE SR0A[4] CR16 */
6537 value = LVDSVBE - 1;
6538 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4);
6539 xgifb_reg_set(pVBInfo->P3d4, 0x16, (value & 0xFF));
6541 /* VRS SR0A[3] CR7[7][2] CR10 */
6542 value = LVDSVRS - 1;
6543 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7);
6544 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2);
6545 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6);
6546 xgifb_reg_set(pVBInfo->P3d4, 0x10, (value & 0xFF));
6548 if (chip_id == XG27) {
6549 /* Panel VRS SR35[2:0] SR34[7:0] */
6550 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07,
6551 (value & 0x700) >> 8);
6552 xgifb_reg_set(pVBInfo->P3c4, 0x34, value & 0xFF);
6554 /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */
6555 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0x03,
6556 (value & 0x600) >> 9);
6557 xgifb_reg_set(pVBInfo->P3c4, 0x34, (value >> 1) & 0xFF);
6558 xgifb_reg_and_or(pVBInfo->P3d4, 0x33, ~0x01, value & 0x01);
6561 /* VRE SR0A[5] CR11[3:0] */
6562 value = LVDSVRE - 1;
6563 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1);
6564 xgifb_reg_and_or(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F);
6566 /* Panel VRE SR3F[7:2] */
6567 if (chip_id == XG27)
6568 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC,
6569 (value << 2) & 0xFC);
6571 /* SR3F[7] has to be 0, h/w bug */
6572 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC,
6573 (value << 2) & 0x7C);
6575 for (temp = 0, value = 0; temp < 3; temp++) {
6577 xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, value);
6578 xgifb_reg_set(pVBInfo->P3c4,
6580 pVBInfo->XG21_LVDSCapList[lvdstableindex].
6582 xgifb_reg_set(pVBInfo->P3c4,
6584 pVBInfo->XG21_LVDSCapList[lvdstableindex].
6589 if (!(modeflag & Charx8Dot)) {
6590 inb(pVBInfo->P3da); /* reset 3da */
6591 outb(0x13, pVBInfo->P3c0); /* set index */
6592 /* set data, panning = 0, shift left 1 dot*/
6593 outb(0x00, pVBInfo->P3c0);
6595 inb(pVBInfo->P3da); /* Enable Attribute */
6596 outb(0x20, pVBInfo->P3c0);
6598 inb(pVBInfo->P3da); /* reset 3da */
6603 /* --------------------------------------------------------------------- */
6604 /* Function : XGI_IsLCDON */
6606 /* Output : 0 : Skip PSC Control */
6607 /* 1: Disable PSC */
6609 /* --------------------------------------------------------------------- */
6610 static unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo)
6612 unsigned short tempax;
6614 tempax = pVBInfo->VBInfo;
6615 if (tempax & SetCRT2ToDualEdge)
6617 else if (tempax & (DisableCRT2Display | SwitchToCRT2 | SetSimuScanMode))
6623 /* --------------------------------------------------------------------- */
6624 /* Function : XGI_DisableChISLCD */
6626 /* Output : 0 -> Not LCD Mode */
6628 /* --------------------------------------------------------------------- */
6629 static unsigned char XGI_DisableChISLCD(struct vb_device_info *pVBInfo)
6631 unsigned short tempbx, tempah;
6633 tempbx = pVBInfo->SetFlag & (DisableChA | DisableChB);
6634 tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E));
6636 if (tempbx & (EnableChA | DisableChA)) {
6637 if (!(tempah & 0x08)) /* Chk LCDA Mode */
6641 if (!(tempbx & (EnableChB | DisableChB)))
6644 if (tempah & 0x01) /* Chk LCDB Mode */
6650 /* --------------------------------------------------------------------- */
6651 /* Function : XGI_EnableChISLCD */
6653 /* Output : 0 -> Not LCD mode */
6655 /* --------------------------------------------------------------------- */
6656 static unsigned char XGI_EnableChISLCD(struct vb_device_info *pVBInfo)
6658 unsigned short tempbx, tempah;
6660 tempbx = pVBInfo->SetFlag & (EnableChA | EnableChB);
6661 tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E));
6663 if (tempbx & (EnableChA | DisableChA)) {
6664 if (!(tempah & 0x08)) /* Chk LCDA Mode */
6668 if (!(tempbx & (EnableChB | DisableChB)))
6671 if (tempah & 0x01) /* Chk LCDB Mode */
6677 void XGI_DisableBridge(struct xgi_hw_device_info *HwDeviceExtension,
6678 struct vb_device_info *pVBInfo)
6680 unsigned short tempah = 0;
6682 if (pVBInfo->SetFlag == Win9xDOSMode)
6685 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
6686 | VB_XGI302LV | VB_XGI301C)) {
6688 if (!(pVBInfo->VBInfo &
6689 (DisableCRT2Display | SetSimuScanMode))) {
6690 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
6691 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
6692 tempah = 0x7F; /* Disable Channel A */
6693 if (!(pVBInfo->VBInfo & SetCRT2ToLCDA))
6694 /* Disable Channel B */
6697 if (pVBInfo->SetFlag & DisableChB)
6698 /* force to disable Cahnnel */
6701 if (pVBInfo->SetFlag & DisableChA)
6702 /* Force to disable Channel B */
6708 /* disable part4_1f */
6709 xgifb_reg_and(pVBInfo->Part4Port, 0x1F, tempah);
6711 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
6712 if (((pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)))
6713 || (XGI_DisableChISLCD(pVBInfo))
6714 || (XGI_IsLCDON(pVBInfo)))
6715 /* LVDS Driver power down */
6716 xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x80);
6719 if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo
6720 & (DisableCRT2Display | SetCRT2ToLCDA
6721 | SetSimuScanMode))) {
6722 if (pVBInfo->SetFlag & GatingCRT)
6723 XGI_EnableGatingCRT(HwDeviceExtension, pVBInfo);
6724 XGI_DisplayOff(HwDeviceExtension, pVBInfo);
6727 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
6728 if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo
6731 xgifb_reg_and(pVBInfo->Part1Port, 0x1e, 0xdf);
6734 /* disable TV as primary VGA swap */
6735 xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xdf);
6737 if ((pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToDualEdge)))
6738 xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xdf);
6740 if ((pVBInfo->SetFlag & DisableChB) ||
6742 (DisableCRT2Display | SetSimuScanMode)) ||
6743 ((!(pVBInfo->VBInfo & SetCRT2ToLCDA)) &&
6745 (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV))))
6747 xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80);
6749 if ((pVBInfo->SetFlag & DisableChB) ||
6751 (DisableCRT2Display | SetSimuScanMode)) ||
6752 (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) ||
6754 (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV))) {
6755 /* save Part1 index 0 */
6756 tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00);
6757 /* BTDAC = 1, avoid VB reset */
6758 xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x10);
6760 xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF);
6761 /* restore Part1 index 0 */
6762 xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah);
6764 } else { /* {301} */
6765 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) {
6767 xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80);
6769 xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF);
6770 /* Disable TV asPrimary VGA swap */
6771 xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xDF);
6774 if (pVBInfo->VBInfo & (DisableCRT2Display | SetCRT2ToLCDA
6776 XGI_DisplayOff(HwDeviceExtension, pVBInfo);
6780 /* --------------------------------------------------------------------- */
6781 /* Function : XGI_GetTVPtrIndex */
6784 /* Description : bx 0 : ExtNTSC */
6796 /* --------------------------------------------------------------------- */
6797 static unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo)
6799 unsigned short tempbx = 0;
6801 if (pVBInfo->TVInfo & SetPALTV)
6803 if (pVBInfo->TVInfo & SetYPbPrMode1080i)
6805 if (pVBInfo->TVInfo & SetYPbPrMode525i)
6807 if (pVBInfo->TVInfo & SetYPbPrMode525p)
6809 if (pVBInfo->TVInfo & SetYPbPrMode750p)
6811 if (pVBInfo->TVInfo & TVSimuMode)
6817 /* --------------------------------------------------------------------- */
6818 /* Function : XGI_GetTVPtrIndex2 */
6820 /* Output : bx 0 : NTSC */
6824 /* 4 : NTSC1024x768 */
6825 /* 5 : PAL-M 1024x768 */
6827 /* cl 0 : YFilter1 */
6830 /* 1 : 301B/302B/301LV/302LV */
6832 /* --------------------------------------------------------------------- */
6833 static void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char *tempcl,
6834 unsigned char *tempch, struct vb_device_info *pVBInfo)
6840 if (pVBInfo->TVInfo & SetPALTV)
6843 if (pVBInfo->TVInfo & SetPALMTV)
6846 if (pVBInfo->TVInfo & SetPALNTV)
6849 if (pVBInfo->TVInfo & NTSC1024x768) {
6851 if (pVBInfo->TVInfo & SetPALMTV)
6855 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
6856 | VB_XGI302LV | VB_XGI301C)) {
6857 if ((!(pVBInfo->VBInfo & SetInSlaveMode)) || (pVBInfo->TVInfo
6864 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
6865 | VB_XGI302LV | VB_XGI301C))
6869 static void XGI_SetDelayComp(struct vb_device_info *pVBInfo)
6871 unsigned short index;
6873 unsigned char tempah, tempbl, tempbh;
6875 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
6876 | VB_XGI302LV | VB_XGI301C)) {
6877 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA
6878 | SetCRT2ToTV | SetCRT2ToRAMDAC)) {
6882 index = XGI_GetTVPtrIndex(pVBInfo); /* Get TV Delay */
6883 tempbl = pVBInfo->XGI_TVDelayList[index];
6885 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
6886 | VB_XGI301LV | VB_XGI302LV
6888 tempbl = pVBInfo->XGI_TVDelayList2[index];
6890 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
6891 tempbl = tempbl >> 4;
6893 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC)
6894 tempbl = CRT2Delay1; // Get CRT2 Delay
6895 if (pVBInfo->VBType &
6901 tempbl = CRT2Delay2;
6903 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
6905 index = XGI_GetLCDCapPtr(pVBInfo);
6906 tempbh = pVBInfo->LCDCapList[index].
6907 LCD_DelayCompensation;
6909 if (!(pVBInfo->VBInfo & SetCRT2ToLCDA))
6915 tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x2D);
6917 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD
6918 | SetCRT2ToTV)) { /* Channel B */
6923 if (pVBInfo->VBInfo & SetCRT2ToLCDA) { /* Channel A */
6927 xgifb_reg_set(pVBInfo->Part1Port, 0x2D, tempah);
6929 } else if (pVBInfo->IF_DEF_LVDS == 1) {
6932 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
6933 /* / Get LCD Delay */
6934 tempah = pVBInfo->LCDCapList[
6935 XGI_GetLCDCapPtr(pVBInfo)].
6936 LCD_DelayCompensation;
6938 tempah = tempah << 4;
6939 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2D, 0x0f,
6945 static void XGI_SetLCDCap_A(unsigned short tempcx,
6946 struct vb_device_info *pVBInfo)
6948 unsigned short temp;
6950 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
6952 if (temp & LCDRGB18Bit) {
6953 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F,
6955 (unsigned short) (0x20 | (tempcx & 0x00C0)));
6956 xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80);
6958 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F,
6959 (unsigned short) (0x30 | (tempcx & 0x00C0)));
6960 xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00);
6964 if (tempcx & EnableLCD24bpp) { // 24bits
6965 xgifb_reg_and_or(pVBInfo->Part1Port,
6968 (unsigned short)(0x30 | (tempcx&0x00C0)));
6969 xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00);
6971 xgifb_reg_and_or(pVBInfo->Part1Port,
6975 (unsigned short)(0x20 | (tempcx&0x00C0)));
6976 xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80);
6981 /* --------------------------------------------------------------------- */
6982 /* Function : XGI_SetLCDCap_B */
6983 /* Input : cx -> LCD Capability */
6986 /* --------------------------------------------------------------------- */
6987 static void XGI_SetLCDCap_B(unsigned short tempcx,
6988 struct vb_device_info *pVBInfo)
6990 if (tempcx & EnableLCD24bpp) /* 24bits */
6991 xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0,
6992 (unsigned short) (((tempcx & 0x00ff) >> 6)
6995 xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0,
6996 (unsigned short) (((tempcx & 0x00ff) >> 6)
6997 | 0x18)); /* Enable Dither */
7000 static void SetSpectrum(struct vb_device_info *pVBInfo)
7002 unsigned short index;
7004 index = XGI_GetLCDCapPtr(pVBInfo);
7006 /* disable down spectrum D[4] */
7007 xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x8F);
7008 XGI_LongWait(pVBInfo);
7009 xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x20); /* reset spectrum */
7010 XGI_LongWait(pVBInfo);
7012 xgifb_reg_set(pVBInfo->Part4Port, 0x31,
7013 pVBInfo->LCDCapList[index].Spectrum_31);
7014 xgifb_reg_set(pVBInfo->Part4Port, 0x32,
7015 pVBInfo->LCDCapList[index].Spectrum_32);
7016 xgifb_reg_set(pVBInfo->Part4Port, 0x33,
7017 pVBInfo->LCDCapList[index].Spectrum_33);
7018 xgifb_reg_set(pVBInfo->Part4Port, 0x34,
7019 pVBInfo->LCDCapList[index].Spectrum_34);
7020 XGI_LongWait(pVBInfo);
7021 xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x40); /* enable spectrum */
7024 static void XGI_SetLCDCap(struct vb_device_info *pVBInfo)
7026 unsigned short tempcx;
7028 tempcx = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(pVBInfo)].LCD_Capability;
7030 if (pVBInfo->VBType &
7035 VB_XGI301C)) { /* 301LV/302LV only */
7036 if (pVBInfo->VBType &
7037 (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
7038 /* Set 301LV Capability */
7039 xgifb_reg_set(pVBInfo->Part4Port, 0x24,
7040 (unsigned char) (tempcx & 0x1F));
7043 xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D,
7044 ~((EnableVBCLKDRVLOW | EnablePLLSPLOW) >> 8),
7045 (unsigned short) ((tempcx & (EnableVBCLKDRVLOW
7046 | EnablePLLSPLOW)) >> 8));
7049 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7050 | VB_XGI302LV | VB_XGI301C)) {
7051 if (pVBInfo->VBInfo & SetCRT2ToLCD)
7052 XGI_SetLCDCap_B(tempcx, pVBInfo);
7053 else if (pVBInfo->VBInfo & SetCRT2ToLCDA)
7054 XGI_SetLCDCap_A(tempcx, pVBInfo);
7056 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
7057 if (tempcx & EnableSpectrum)
7058 SetSpectrum(pVBInfo);
7062 XGI_SetLCDCap_A(tempcx, pVBInfo);
7066 /* --------------------------------------------------------------------- */
7067 /* Function : XGI_SetAntiFlicker */
7070 /* Description : Set TV Customized Param. */
7071 /* --------------------------------------------------------------------- */
7072 static void XGI_SetAntiFlicker(unsigned short ModeNo,
7073 unsigned short ModeIdIndex,
7074 struct vb_device_info *pVBInfo)
7076 unsigned short tempbx, index;
7078 unsigned char tempah;
7080 if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))
7083 tempbx = XGI_GetTVPtrIndex(pVBInfo);
7087 index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVFlickerIndex;
7089 index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVFlickerIndex;
7092 tempah = TVAntiFlickList[tempbx];
7093 tempah = tempah << 4;
7095 xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0x8F, tempah);
7098 static void XGI_SetEdgeEnhance(unsigned short ModeNo,
7099 unsigned short ModeIdIndex,
7100 struct vb_device_info *pVBInfo)
7102 unsigned short tempbx, index;
7104 unsigned char tempah;
7106 tempbx = XGI_GetTVPtrIndex(pVBInfo);
7110 index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVEdgeIndex;
7112 index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVEdgeIndex;
7115 tempah = TVEdgeList[tempbx];
7116 tempah = tempah << 5;
7118 xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, tempah);
7121 static void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo)
7123 unsigned short tempbx;
7125 unsigned char tempcl, tempch;
7127 unsigned long tempData;
7129 XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */
7130 tempData = TVPhaseList[tempbx];
7132 xgifb_reg_set(pVBInfo->Part2Port, 0x31, (unsigned short) (tempData
7134 xgifb_reg_set(pVBInfo->Part2Port, 0x32, (unsigned short) ((tempData
7135 & 0x0000FF00) >> 8));
7136 xgifb_reg_set(pVBInfo->Part2Port, 0x33, (unsigned short) ((tempData
7137 & 0x00FF0000) >> 16));
7138 xgifb_reg_set(pVBInfo->Part2Port, 0x34, (unsigned short) ((tempData
7139 & 0xFF000000) >> 24));
7142 static void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex,
7143 struct vb_device_info *pVBInfo)
7145 unsigned short tempbx, index;
7147 unsigned char tempcl, tempch, tempal, *filterPtr;
7149 XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */
7154 filterPtr = NTSCYFilter1;
7158 filterPtr = PALYFilter1;
7164 filterPtr = PALMYFilter1;
7168 filterPtr = PALNYFilter1;
7173 filterPtr = NTSCYFilter2;
7177 filterPtr = PALMYFilter2;
7181 filterPtr = PALNYFilter2;
7185 filterPtr = PALYFilter2;
7193 tempal = pVBInfo->SModeIDTable[ModeIdIndex].
7194 VB_StTVYFilterIndex;
7196 tempal = pVBInfo->EModeIDTable[ModeIdIndex].
7197 VB_ExtTVYFilterIndex;
7204 if ((tempcl == 0) && (tempch == 1)) {
7205 xgifb_reg_set(pVBInfo->Part2Port, 0x35, 0);
7206 xgifb_reg_set(pVBInfo->Part2Port, 0x36, 0);
7207 xgifb_reg_set(pVBInfo->Part2Port, 0x37, 0);
7208 xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]);
7210 xgifb_reg_set(pVBInfo->Part2Port, 0x35, filterPtr[index++]);
7211 xgifb_reg_set(pVBInfo->Part2Port, 0x36, filterPtr[index++]);
7212 xgifb_reg_set(pVBInfo->Part2Port, 0x37, filterPtr[index++]);
7213 xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]);
7216 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7217 | VB_XGI302LV | VB_XGI301C)) {
7218 xgifb_reg_set(pVBInfo->Part2Port, 0x48, filterPtr[index++]);
7219 xgifb_reg_set(pVBInfo->Part2Port, 0x49, filterPtr[index++]);
7220 xgifb_reg_set(pVBInfo->Part2Port, 0x4A, filterPtr[index++]);
7224 /* --------------------------------------------------------------------- */
7225 /* Function : XGI_OEM310Setting */
7228 /* Description : Customized Param. for 301 */
7229 /* --------------------------------------------------------------------- */
7230 static void XGI_OEM310Setting(unsigned short ModeNo,
7231 unsigned short ModeIdIndex,
7232 struct vb_device_info *pVBInfo)
7234 if (pVBInfo->SetFlag & Win9xDOSMode)
7238 XGI_SetDelayComp(pVBInfo);
7240 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))
7241 XGI_SetLCDCap(pVBInfo);
7243 if (pVBInfo->VBInfo & SetCRT2ToTV) {
7245 XGI_SetPhaseIncr(pVBInfo);
7246 XGI_SetYFilter(ModeNo, ModeIdIndex, pVBInfo);
7247 XGI_SetAntiFlicker(ModeNo, ModeIdIndex, pVBInfo);
7249 if (pVBInfo->VBType & VB_XGI301)
7250 XGI_SetEdgeEnhance(ModeNo, ModeIdIndex, pVBInfo);
7254 /* --------------------------------------------------------------------- */
7255 /* Function : XGI_SetCRT2ModeRegs */
7258 /* Description : Origin code for crt2group */
7259 /* --------------------------------------------------------------------- */
7260 void XGI_SetCRT2ModeRegs(unsigned short ModeNo,
7261 struct xgi_hw_device_info *HwDeviceExtension,
7262 struct vb_device_info *pVBInfo)
7264 unsigned short tempbl;
7267 unsigned char tempah;
7269 /* // fix write part1 index 0 BTDRAM bit Bug
7270 * xgifb_reg_set(pVBInfo->Part1Port, 0x03, 0x00); */
7272 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
7273 tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00);
7274 tempah &= ~0x10; /* BTRAMDAC */
7275 tempah |= 0x40; /* BTRAM */
7277 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV
7279 tempah = 0x40; /* BTDRAM */
7280 if (ModeNo > 0x13) {
7281 tempcl = pVBInfo->ModeType;
7285 tempah = (0x008 >> tempcl);
7291 if (pVBInfo->VBInfo & SetInSlaveMode)
7292 tempah ^= 0x50; /* BTDAC */
7297 if (pVBInfo->VBInfo & DisableCRT2Display) {
7301 xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah);
7302 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD)) {
7303 tempcl = pVBInfo->ModeType;
7304 if (ModeNo > 0x13) {
7306 if ((tempcl > 0) || (tempcl == 0)) {
7307 tempah=(0x008>>tempcl) ;
7316 if (pVBInfo->VBInfo & SetInSlaveMode) {
7317 tempah = (tempah ^ 0x050);
7322 xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah);
7326 if (pVBInfo->VBInfo & DisableCRT2Display) {
7327 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl, tempah);
7332 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV
7333 | SetCRT2ToLCD | SetCRT2ToLCDA)) {
7334 if ((pVBInfo->VBInfo & SetCRT2ToLCDA) &&
7335 (!(pVBInfo->VBInfo & SetSimuScanMode))) {
7338 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e,
7341 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
7346 if (pVBInfo->VBInfo &
7353 if (!(pVBInfo->VBInfo & SetInSlaveMode))
7356 if (!(pVBInfo->VBInfo &
7358 tempah = tempah ^ 0x05;
7359 if (!(pVBInfo->VBInfo &
7361 tempah = tempah ^ 0x01;
7364 if (!(pVBInfo->VBInfo &
7367 xgifb_reg_and_or(pVBInfo->Part1Port,
7368 0x2e, tempbl, tempah);
7370 xgifb_reg_and_or(pVBInfo->Part1Port,
7371 0x2e, tempbl, tempah);
7375 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl,
7380 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD
7383 if ((pVBInfo->ModeType == ModeVGA) && (!(pVBInfo->VBInfo
7384 & SetInSlaveMode))) {
7389 if (pVBInfo->VBInfo & SetCRT2ToTV) {
7390 /* if (!(pVBInfo->TVInfo &
7391 (SetYPbPrMode525p | SetYPbPrMode750p))) { */
7393 if (ModeNo > 0x13) {
7394 if (pVBInfo->VBInfo & DriverMode)
7395 tempah = tempah ^ 0x20;
7400 xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D, ~0x0BF, tempah);
7403 if (pVBInfo->LCDInfo & SetLCDDualLink)
7406 if (pVBInfo->VBInfo & SetCRT2ToTV) {
7407 /* if ((!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)) &&
7408 (!(pVBInfo->TVInfo &
7409 (SetYPbPrMode525p | SetYPbPrMode750p)))) { */
7410 if (pVBInfo->TVInfo & RPLLDIV2XO)
7415 if ((pVBInfo->LCDResInfo == Panel1280x1024)
7416 || (pVBInfo->LCDResInfo == Panel1280x1024x75))
7419 if (pVBInfo->LCDResInfo == Panel1280x960)
7422 xgifb_reg_set(pVBInfo->Part4Port, 0x0C, tempah);
7425 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7426 | VB_XGI302LV | VB_XGI301C)) {
7430 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
7432 if (pVBInfo->VBInfo & SetCRT2ToLCDA)
7433 tempah |= 0x04; /* shampoo 0129 */
7436 xgifb_reg_and_or(pVBInfo->Part1Port, 0x13, tempbl, tempah);
7439 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
7440 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
7444 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2c, tempbl, tempah);
7448 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
7449 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
7452 xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, tempbl, tempah);
7457 if (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) {
7459 if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge))
7463 xgifb_reg_and_or(pVBInfo->Part4Port, 0x23, tempbl, tempah);
7465 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
7466 if (pVBInfo->LCDInfo & SetLCDDualLink) {
7467 xgifb_reg_or(pVBInfo->Part4Port, 0x27, 0x20);
7468 xgifb_reg_or(pVBInfo->Part4Port, 0x34, 0x10);
7473 static void XGI_CloseCRTC(struct xgi_hw_device_info *HwDeviceExtension,
7474 struct vb_device_info *pVBInfo)
7476 unsigned short tempbx;
7480 if (pVBInfo->VBInfo & SetCRT2ToLCDA)
7485 void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension,
7486 struct vb_device_info *pVBInfo)
7489 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2f, 0xFF, 0x01);
7493 void XGI_LockCRT2(struct xgi_hw_device_info *HwDeviceExtension,
7494 struct vb_device_info *pVBInfo)
7497 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2F, 0xFE, 0x00);
7501 unsigned char XGI_BridgeIsOn(struct vb_device_info *pVBInfo)
7503 unsigned short flag;
7505 if (pVBInfo->IF_DEF_LVDS == 1) {
7508 flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00);
7509 if ((flag == 1) || (flag == 2))
7510 return 1; /* 301b */
7516 void XGI_LongWait(struct vb_device_info *pVBInfo)
7520 i = xgifb_reg_get(pVBInfo->P3c4, 0x1F);
7523 for (i = 0; i < 0xFFFF; i++) {
7524 if (!(inb(pVBInfo->P3da) & 0x08))
7528 for (i = 0; i < 0xFFFF; i++) {
7529 if ((inb(pVBInfo->P3da) & 0x08))
7535 static void XGI_VBLongWait(struct vb_device_info *pVBInfo)
7537 unsigned short tempal, temp, i, j;
7539 if (!(pVBInfo->VBInfo & SetCRT2ToTV)) {
7541 for (i = 0; i < 3; i++) {
7542 for (j = 0; j < 100; j++) {
7543 tempal = inb(pVBInfo->P3da);
7544 if (temp & 0x01) { /* VBWaitMode2 */
7545 if ((tempal & 0x08))
7548 if (!(tempal & 0x08))
7551 } else { /* VBWaitMode1 */
7552 if (!(tempal & 0x08))
7555 if ((tempal & 0x08))
7562 XGI_LongWait(pVBInfo);
7567 unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE,
7568 unsigned short ModeNo, unsigned short ModeIdIndex,
7569 struct vb_device_info *pVBInfo)
7571 short LCDRefreshIndex[] = { 0x00, 0x00, 0x03, 0x01 },
7572 LCDARefreshIndex[] = { 0x00, 0x00, 0x03, 0x01, 0x01,
7575 unsigned short RefreshRateTableIndex, i, modeflag, index, temp;
7578 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
7580 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
7585 index = xgifb_reg_get(pVBInfo->P3d4, 0x33);
7586 index = index >> pVBInfo->SelectCRT2Rate;
7589 if (pVBInfo->LCDInfo & LCDNonExpanding)
7595 if (pVBInfo->SetFlag & ProgrammingCRT2) {
7596 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
7597 if (pVBInfo->IF_DEF_LVDS == 0) {
7598 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
7599 | VB_XGI301LV | VB_XGI302LV
7602 temp = LCDARefreshIndex[
7603 pVBInfo->LCDResInfo & 0x0F];
7605 temp = LCDRefreshIndex[
7606 pVBInfo->LCDResInfo & 0x0F];
7616 RefreshRateTableIndex = pVBInfo->EModeIDTable[ModeIdIndex].REFindex;
7617 ModeNo = pVBInfo->RefIndex[RefreshRateTableIndex].ModeID;
7618 if (pXGIHWDE->jChipType >= XG20) { /* for XG20, XG21, XG27 */
7620 if (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag &
7625 if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 800) &&
7626 (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 600)) {
7630 * do the similar adjustment like XGISearchCRT1Rate() */
7631 if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1024) &&
7632 (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 768)) {
7635 if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1280) &&
7636 (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 1024)) {
7643 if (pVBInfo->RefIndex[RefreshRateTableIndex + i].
7646 temp = pVBInfo->RefIndex[RefreshRateTableIndex + i].
7648 temp &= ModeInfoFlag;
7649 if (temp < pVBInfo->ModeType)
7654 } while (index != 0xFFFF);
7655 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) {
7656 if (pVBInfo->VBInfo & SetInSlaveMode) {
7657 temp = pVBInfo->RefIndex[RefreshRateTableIndex + i - 1].
7659 if (temp & InterlaceMode)
7664 if ((pVBInfo->SetFlag & ProgrammingCRT2)) {
7665 temp = XGI_AjustCRT2Rate(ModeNo, ModeIdIndex,
7666 RefreshRateTableIndex, &i, pVBInfo);
7668 return RefreshRateTableIndex + i; /* return (0x01 | (temp1<<1)); */
7671 static void XGI_SetLCDAGroup(unsigned short ModeNo, unsigned short ModeIdIndex,
7672 struct xgi_hw_device_info *HwDeviceExtension,
7673 struct vb_device_info *pVBInfo)
7675 unsigned short RefreshRateTableIndex;
7676 /* unsigned short temp ; */
7678 /* pVBInfo->SelectCRT2Rate = 0; */
7680 pVBInfo->SetFlag |= ProgrammingCRT2;
7681 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
7682 ModeIdIndex, pVBInfo);
7683 XGI_GetLVDSResInfo(ModeNo, ModeIdIndex, pVBInfo);
7684 XGI_GetLVDSData(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
7685 XGI_ModCRT1Regs(ModeNo, ModeIdIndex, RefreshRateTableIndex,
7686 HwDeviceExtension, pVBInfo);
7687 XGI_SetLVDSRegs(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
7688 XGI_SetCRT2ECLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
7691 unsigned char XGI_SetCRT2Group301(unsigned short ModeNo,
7692 struct xgi_hw_device_info *HwDeviceExtension,
7693 struct vb_device_info *pVBInfo)
7695 unsigned short tempbx, ModeIdIndex, RefreshRateTableIndex;
7697 tempbx = pVBInfo->VBInfo;
7698 pVBInfo->SetFlag |= ProgrammingCRT2;
7699 XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo);
7700 pVBInfo->SelectCRT2Rate = 4;
7701 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
7702 ModeIdIndex, pVBInfo);
7703 XGI_SaveCRT2Info(ModeNo, pVBInfo);
7704 XGI_GetCRT2ResInfo(ModeNo, ModeIdIndex, pVBInfo);
7705 XGI_GetCRT2Data(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
7706 XGI_PreSetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension,
7707 RefreshRateTableIndex, pVBInfo);
7708 XGI_SetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension,
7709 RefreshRateTableIndex, pVBInfo);
7710 XGI_SetLockRegs(ModeNo, ModeIdIndex, HwDeviceExtension,
7711 RefreshRateTableIndex, pVBInfo);
7712 XGI_SetGroup2(ModeNo, ModeIdIndex, RefreshRateTableIndex,
7713 HwDeviceExtension, pVBInfo);
7714 XGI_SetLCDRegs(ModeNo, ModeIdIndex, HwDeviceExtension,
7715 RefreshRateTableIndex, pVBInfo);
7716 XGI_SetTap4Regs(pVBInfo);
7717 XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo);
7718 XGI_SetGroup4(ModeNo, ModeIdIndex, RefreshRateTableIndex,
7719 HwDeviceExtension, pVBInfo);
7720 XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
7721 XGI_SetGroup5(ModeNo, ModeIdIndex, pVBInfo);
7722 XGI_AutoThreshold(pVBInfo);
7726 void XGI_SenseCRT1(struct vb_device_info *pVBInfo)
7728 unsigned char CRTCData[17] = { 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81,
7729 0x0B, 0x3E, 0xE9, 0x0B, 0xDF, 0xE7, 0x04, 0x00, 0x00,
7732 unsigned char SR01 = 0, SR1F = 0, SR07 = 0, SR06 = 0;
7734 unsigned char CR17, CR63, SR31;
7735 unsigned short temp;
7736 unsigned char DAC_TEST_PARMS[3] = { 0x0F, 0x0F, 0x0F };
7739 xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86);
7741 /* [2004/05/06] Vicent to fix XG42 single LCD sense to CRT+LCD */
7742 xgifb_reg_set(pVBInfo->P3d4, 0x57, 0x4A);
7743 xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get(
7744 pVBInfo->P3d4, 0x53) | 0x02));
7746 SR31 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x31);
7747 CR63 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x63);
7748 SR01 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x01);
7750 xgifb_reg_set(pVBInfo->P3c4, 0x01, (unsigned char) (SR01 & 0xDF));
7751 xgifb_reg_set(pVBInfo->P3d4, 0x63, (unsigned char) (CR63 & 0xBF));
7753 CR17 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x17);
7754 xgifb_reg_set(pVBInfo->P3d4, 0x17, (unsigned char) (CR17 | 0x80));
7756 SR1F = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x1F);
7757 xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) (SR1F | 0x04));
7759 SR07 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x07);
7760 xgifb_reg_set(pVBInfo->P3c4, 0x07, (unsigned char) (SR07 & 0xFB));
7761 SR06 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x06);
7762 xgifb_reg_set(pVBInfo->P3c4, 0x06, (unsigned char) (SR06 & 0xC3));
7764 xgifb_reg_set(pVBInfo->P3d4, 0x11, 0x00);
7766 for (i = 0; i < 8; i++)
7767 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) i, CRTCData[i]);
7769 for (i = 8; i < 11; i++)
7770 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 8),
7773 for (i = 11; i < 13; i++)
7774 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 4),
7777 for (i = 13; i < 16; i++)
7778 xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i - 3),
7781 xgifb_reg_set(pVBInfo->P3c4, 0x0E, (unsigned char) (CRTCData[16]
7784 xgifb_reg_set(pVBInfo->P3c4, 0x31, 0x00);
7785 xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x1B);
7786 xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE1);
7788 outb(0x00, pVBInfo->P3c8);
7790 for (i = 0; i < 256; i++) {
7791 outb((unsigned char) DAC_TEST_PARMS[0], (pVBInfo->P3c8 + 1));
7792 outb((unsigned char) DAC_TEST_PARMS[1], (pVBInfo->P3c8 + 1));
7793 outb((unsigned char) DAC_TEST_PARMS[2], (pVBInfo->P3c8 + 1));
7796 XGI_VBLongWait(pVBInfo);
7797 XGI_VBLongWait(pVBInfo);
7798 XGI_VBLongWait(pVBInfo);
7802 XGI_WaitDisply(pVBInfo);
7803 temp = inb(pVBInfo->P3c2);
7806 xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x20);
7808 xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x00);
7810 /* alan, avoid display something, set BLACK DAC if not restore DAC */
7811 outb(0x00, pVBInfo->P3c8);
7813 for (i = 0; i < 256; i++) {
7814 outb(0, (pVBInfo->P3c8 + 1));
7815 outb(0, (pVBInfo->P3c8 + 1));
7816 outb(0, (pVBInfo->P3c8 + 1));
7819 xgifb_reg_set(pVBInfo->P3c4, 0x01, SR01);
7820 xgifb_reg_set(pVBInfo->P3d4, 0x63, CR63);
7821 xgifb_reg_set(pVBInfo->P3c4, 0x31, SR31);
7823 /* [2004/05/11] Vicent */
7824 xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get(
7825 pVBInfo->P3d4, 0x53) & 0xFD));
7826 xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) SR1F);
7829 void XGI_EnableBridge(struct xgi_hw_device_info *HwDeviceExtension,
7830 struct vb_device_info *pVBInfo)
7832 unsigned short tempah;
7834 if (pVBInfo->SetFlag == Win9xDOSMode) {
7835 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7836 | VB_XGI302LV | VB_XGI301C)) {
7837 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
7840 /* LVDS or CH7017 */
7844 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7845 | VB_XGI302LV | VB_XGI301C)) {
7846 if (!(pVBInfo->SetFlag & DisableChA)) {
7847 if (pVBInfo->SetFlag & EnableChA) {
7849 xgifb_reg_set(pVBInfo->Part1Port, 0x1E, 0x20);
7851 /* SetCRT2ToLCDA ) */
7852 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
7854 xgifb_reg_set(pVBInfo->Part1Port,
7860 if (!(pVBInfo->SetFlag & DisableChB)) {
7861 if ((pVBInfo->SetFlag & EnableChB) || (pVBInfo->VBInfo
7862 & (SetCRT2ToLCD | SetCRT2ToTV
7863 | SetCRT2ToRAMDAC))) {
7864 tempah = (unsigned char) xgifb_reg_get(
7865 pVBInfo->P3c4, 0x32);
7867 if (pVBInfo->VBInfo & SetInSlaveMode) {
7868 if (!(pVBInfo->VBInfo &
7872 xgifb_reg_set(pVBInfo->P3c4, 0x32, tempah);
7873 xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x20);
7875 tempah = (unsigned char) xgifb_reg_get(
7876 pVBInfo->Part1Port, 0x2E);
7878 if (!(tempah & 0x80))
7879 /* BVBDOENABLE = 1 */
7880 xgifb_reg_or(pVBInfo->Part1Port,
7882 /* BScreenOFF = 0 */
7883 xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F);
7887 if ((pVBInfo->SetFlag & (EnableChA | EnableChB))
7888 || (!(pVBInfo->VBInfo & DisableCRT2Display))) {
7889 xgifb_reg_and_or(pVBInfo->Part2Port, 0x00, ~0xE0,
7890 0x20); /* shampoo 0129 */
7891 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
7892 if (!XGI_DisableChISLCD(pVBInfo)) {
7893 if (XGI_EnableChISLCD(pVBInfo) ||
7895 (SetCRT2ToLCD | SetCRT2ToLCDA)))
7896 /* LVDS PLL power on */
7902 /* LVDS Driver power on */
7903 xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x7F);
7909 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
7912 if (!(pVBInfo->VBInfo & SetSimuScanMode)) {
7913 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
7914 if (pVBInfo->VBInfo &
7915 SetCRT2ToDualEdge) {
7916 tempah = tempah & 0x40;
7917 if (pVBInfo->VBInfo &
7919 tempah = tempah ^ 0xC0;
7921 if (pVBInfo->SetFlag &
7925 if (pVBInfo->SetFlag &
7929 if (pVBInfo->SetFlag &
7933 if (pVBInfo->SetFlag &
7941 /* EnablePart4_1F */
7942 xgifb_reg_or(pVBInfo->Part4Port, 0x1F, tempah);
7944 if (pVBInfo->SetFlag & Win9xDOSMode) {
7945 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
7949 if (!(pVBInfo->SetFlag & DisableChA)) {
7950 XGI_VBLongWait(pVBInfo);
7951 if (!(pVBInfo->SetFlag & GatingCRT)) {
7952 XGI_DisableGatingCRT(HwDeviceExtension,
7954 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
7955 XGI_VBLongWait(pVBInfo);
7960 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD
7963 xgifb_reg_or(pVBInfo->Part1Port, 0x1E, 0x20);
7965 tempah = (unsigned char) xgifb_reg_get(pVBInfo->Part1Port,
7967 if (!(tempah & 0x80))
7968 /* BVBDOENABLE = 1 */
7969 xgifb_reg_or(pVBInfo->Part1Port, 0x2E, 0x80);
7971 xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F);
7972 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
7976 static void XGI_SetCRT1Group(struct xgi_hw_device_info *HwDeviceExtension,
7977 unsigned short ModeNo, unsigned short ModeIdIndex,
7978 struct vb_device_info *pVBInfo)
7980 unsigned short StandTableIndex, RefreshRateTableIndex, b3CC, temp;
7982 unsigned short XGINew_P3cc = pVBInfo->P3cc;
7984 /* XGINew_CRT1Mode = ModeNo; // SaveModeID */
7985 StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
7986 /* XGI_SetBIOSData(ModeNo, ModeIdIndex); */
7987 /* XGI_ClearBankRegs(ModeNo, ModeIdIndex); */
7988 XGI_SetSeqRegs(ModeNo, StandTableIndex, ModeIdIndex, pVBInfo);
7989 XGI_SetMiscRegs(StandTableIndex, pVBInfo);
7990 XGI_SetCRTCRegs(HwDeviceExtension, StandTableIndex, pVBInfo);
7991 XGI_SetATTRegs(ModeNo, StandTableIndex, ModeIdIndex, pVBInfo);
7992 XGI_SetGRCRegs(StandTableIndex, pVBInfo);
7993 XGI_ClearExt1Regs(pVBInfo);
7995 /* if (pVBInfo->IF_DEF_ExpLink) */
7996 if (HwDeviceExtension->jChipType == XG27) {
7997 if (pVBInfo->IF_DEF_LVDS == 0)
7998 XGI_SetDefaultVCLK(pVBInfo);
8001 temp = ~ProgrammingCRT2;
8002 pVBInfo->SetFlag &= temp;
8003 pVBInfo->SelectCRT2Rate = 0;
8005 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8006 | VB_XGI302LV | VB_XGI301C)) {
8007 if (pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToLCDA
8008 | SetInSlaveMode)) {
8009 pVBInfo->SetFlag |= ProgrammingCRT2;
8013 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
8014 ModeIdIndex, pVBInfo);
8015 if (RefreshRateTableIndex != 0xFFFF) {
8016 XGI_SetSync(RefreshRateTableIndex, pVBInfo);
8017 XGI_SetCRT1CRTC(ModeNo, ModeIdIndex, RefreshRateTableIndex,
8018 pVBInfo, HwDeviceExtension);
8019 XGI_SetCRT1DE(HwDeviceExtension, ModeNo, ModeIdIndex,
8020 RefreshRateTableIndex, pVBInfo);
8021 XGI_SetCRT1Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
8022 HwDeviceExtension, pVBInfo);
8023 XGI_SetCRT1VCLK(ModeNo, ModeIdIndex, HwDeviceExtension,
8024 RefreshRateTableIndex, pVBInfo);
8027 if ((HwDeviceExtension->jChipType >= XG20) &&
8028 (HwDeviceExtension->jChipType < XG27)) { /* fix H/W DCLK/2 bug */
8029 if ((ModeNo == 0x00) | (ModeNo == 0x01)) {
8030 xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x4E);
8031 xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE9);
8032 b3CC = (unsigned char) inb(XGINew_P3cc);
8033 outb((b3CC |= 0x0C), XGINew_P3cc);
8034 } else if ((ModeNo == 0x04) | (ModeNo == 0x05) | (ModeNo
8036 xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x1B);
8037 xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE3);
8038 b3CC = (unsigned char) inb(XGINew_P3cc);
8039 outb((b3CC |= 0x0C), XGINew_P3cc);
8043 if (HwDeviceExtension->jChipType >= XG21) {
8044 temp = xgifb_reg_get(pVBInfo->P3d4, 0x38);
8047 /* Enable write GPIOF */
8048 /* xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x20); */
8050 /* xgifb_reg_and(pVBInfo->P3d4, 0x48, ~0x20); */
8051 /* XG21 CRT1 Timing */
8052 if (HwDeviceExtension->jChipType == XG27)
8053 XGI_SetXG27CRTC(ModeNo, ModeIdIndex,
8054 RefreshRateTableIndex, pVBInfo);
8056 XGI_SetXG21CRTC(ModeNo, ModeIdIndex,
8057 RefreshRateTableIndex, pVBInfo);
8059 XGI_UpdateXG21CRTC(ModeNo, pVBInfo,
8060 RefreshRateTableIndex);
8062 xgifb_set_lcd(HwDeviceExtension->jChipType,
8063 pVBInfo, RefreshRateTableIndex, ModeNo);
8065 if (pVBInfo->IF_DEF_LVDS == 1)
8066 xgifb_set_lvds(HwDeviceExtension->jChipType,
8067 ModeNo, ModeIdIndex, pVBInfo);
8069 /* xgifb_reg_or(pVBInfo->P3d4, 0x48, 0x20); */
8073 pVBInfo->SetFlag &= (~ProgrammingCRT2);
8074 XGI_SetCRT1FIFO(ModeNo, HwDeviceExtension, pVBInfo);
8075 XGI_SetCRT1ModeRegs(HwDeviceExtension, ModeNo, ModeIdIndex,
8076 RefreshRateTableIndex, pVBInfo);
8078 /* XGI_LoadCharacter(); //dif ifdef TVFont */
8080 XGI_LoadDAC(ModeNo, ModeIdIndex, pVBInfo);
8081 /* XGI_ClearBuffer(HwDeviceExtension, ModeNo, pVBInfo); */
8084 unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension,
8085 unsigned short ModeNo)
8087 unsigned short ModeIdIndex;
8088 /* unsigned char *pVBInfo->FBAddr =
8089 HwDeviceExtension->pjVideoMemoryAddress; */
8090 struct vb_device_info VBINF;
8091 struct vb_device_info *pVBInfo = &VBINF;
8092 pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase;
8093 pVBInfo->BaseAddr = (unsigned long) HwDeviceExtension->pjIOAddress;
8094 pVBInfo->IF_DEF_LVDS = 0;
8095 pVBInfo->IF_DEF_LCDA = 1;
8096 pVBInfo->IF_DEF_VideoCapture = 0;
8097 pVBInfo->IF_DEF_ScaleLCD = 0;
8098 pVBInfo->IF_DEF_OEMUtil = 0;
8099 pVBInfo->IF_DEF_PWD = 0;
8101 if (HwDeviceExtension->jChipType >= XG20) { /* kuku 2004/06/25 */
8102 pVBInfo->IF_DEF_YPbPr = 0;
8103 pVBInfo->IF_DEF_HiVision = 0;
8104 pVBInfo->IF_DEF_CRT2Monitor = 0;
8105 pVBInfo->VBType = 0; /*set VBType default 0*/
8107 pVBInfo->IF_DEF_YPbPr = 1;
8108 pVBInfo->IF_DEF_HiVision = 1;
8109 pVBInfo->IF_DEF_CRT2Monitor = 1;
8112 pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14;
8113 pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24;
8114 pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10;
8115 pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e;
8116 pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12;
8117 pVBInfo->P3cc = pVBInfo->BaseAddr + 0x1C;
8118 pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a;
8119 pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16;
8120 pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17;
8121 pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18;
8122 pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19;
8123 pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A;
8124 pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00;
8125 pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04;
8126 pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10;
8127 pVBInfo->Part3Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_12;
8128 pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14;
8129 pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2;
8131 /* for x86 Linux, XG21 LVDS */
8132 if (HwDeviceExtension->jChipType == XG21) {
8133 if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0)
8134 pVBInfo->IF_DEF_LVDS = 1;
8136 if (HwDeviceExtension->jChipType == XG27) {
8137 if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) {
8138 if (xgifb_reg_get(pVBInfo->P3d4, 0x30) & 0x20)
8139 pVBInfo->IF_DEF_LVDS = 1;
8143 if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 */
8144 XGI_GetVBType(pVBInfo);
8146 InitTo330Pointer(HwDeviceExtension->jChipType, pVBInfo);
8147 if (ModeNo & 0x80) {
8148 ModeNo = ModeNo & 0x7F;
8149 /* XGINew_flag_clearbuffer = 0; */
8152 XGINew_flag_clearbuffer = 1;
8155 xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86);
8157 if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 1.Openkey */
8158 XGI_UnLockCRT2(HwDeviceExtension, pVBInfo);
8160 XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo);
8162 XGI_GetVGAType(HwDeviceExtension, pVBInfo);
8164 if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */
8165 XGI_GetVBInfo(ModeNo, ModeIdIndex, HwDeviceExtension, pVBInfo);
8166 XGI_GetTVInfo(ModeNo, ModeIdIndex, pVBInfo);
8167 XGI_GetLCDInfo(ModeNo, ModeIdIndex, pVBInfo);
8168 XGI_DisableBridge(HwDeviceExtension, pVBInfo);
8170 if (pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToLCDA)) {
8171 XGI_SetCRT1Group(HwDeviceExtension, ModeNo,
8172 ModeIdIndex, pVBInfo);
8174 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
8175 XGI_SetLCDAGroup(ModeNo, ModeIdIndex,
8176 HwDeviceExtension, pVBInfo);
8179 if (!(pVBInfo->VBInfo & SwitchToCRT2)) {
8180 XGI_SetCRT1Group(HwDeviceExtension, ModeNo,
8181 ModeIdIndex, pVBInfo);
8182 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
8183 XGI_SetLCDAGroup(ModeNo, ModeIdIndex,
8190 if (pVBInfo->VBInfo & (SetSimuScanMode | SwitchToCRT2)) {
8191 switch (HwDeviceExtension->ujVBChipID) {
8193 XGI_SetCRT2Group301(ModeNo, HwDeviceExtension,
8194 pVBInfo); /*add for CRT2 */
8198 XGI_SetCRT2Group301(ModeNo, HwDeviceExtension,
8199 pVBInfo); /*add for CRT2 */
8207 XGI_SetCRT2ModeRegs(ModeNo, HwDeviceExtension, pVBInfo);
8208 XGI_OEM310Setting(ModeNo, ModeIdIndex, pVBInfo); /*0212*/
8209 XGI_CloseCRTC(HwDeviceExtension, pVBInfo);
8210 XGI_EnableBridge(HwDeviceExtension, pVBInfo);
8213 if (pVBInfo->IF_DEF_LVDS == 1)
8214 if (!XGI_XG21CheckLVDSMode(ModeNo,
8219 if (ModeNo <= 0x13) {
8220 pVBInfo->ModeType = pVBInfo->SModeIDTable[ModeIdIndex].
8221 St_ModeFlag & ModeInfoFlag;
8223 pVBInfo->ModeType = pVBInfo->EModeIDTable[ModeIdIndex].
8224 Ext_ModeFlag & ModeInfoFlag;
8227 pVBInfo->SetFlag = 0;
8228 pVBInfo->VBInfo = DisableCRT2Display;
8230 XGI_DisplayOff(HwDeviceExtension, pVBInfo);
8232 XGI_SetCRT1Group(HwDeviceExtension, ModeNo, ModeIdIndex,
8235 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
8237 if (HwDeviceExtension->jChipType == XG21)
8238 xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0x80, 0x80);
8243 if (ModeNo <= 0x13) {
8244 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
8246 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
8248 pVBInfo->ModeType = modeflag&ModeInfoFlag;
8249 pVBInfo->SetFlag = 0x00;
8250 pVBInfo->VBInfo = DisableCRT2Display;
8251 temp = XGINew_CheckMemorySize(HwDeviceExtension,
8259 XGI_DisplayOff(HwDeviceExtension, pVBInfo) ;
8260 XGI_SetCRT1Group(HwDeviceExtension, ModeNo, ModeIdIndex, pVBInfo);
8261 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
8264 XGI_UpdateModeInfo(HwDeviceExtension, pVBInfo);
8266 if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */
8267 XGI_LockCRT2(HwDeviceExtension, pVBInfo);