3 #include <linux/delay.h>
4 #include <linux/types.h>
5 #include <linux/version.h>
11 #include "vb_struct.h"
14 #include "vb_setmode.h"
17 #define IndexMask 0xff
18 #ifndef XGI_MASK_DUAL_CHIP
19 #define XGI_MASK_DUAL_CHIP 0x04 /* SR3A */
22 static unsigned short XGINew_MDA_DAC[] = {
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,
27 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
29 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
30 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F};
32 static unsigned short XGINew_CGA_DAC[] = {
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,
37 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
38 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
39 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
40 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F};
42 static unsigned short XGINew_EGA_DAC[] = {
43 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x05, 0x15,
44 0x20, 0x30, 0x24, 0x34, 0x21, 0x31, 0x25, 0x35,
45 0x08, 0x18, 0x0C, 0x1C, 0x09, 0x19, 0x0D, 0x1D,
46 0x28, 0x38, 0x2C, 0x3C, 0x29, 0x39, 0x2D, 0x3D,
47 0x02, 0x12, 0x06, 0x16, 0x03, 0x13, 0x07, 0x17,
48 0x22, 0x32, 0x26, 0x36, 0x23, 0x33, 0x27, 0x37,
49 0x0A, 0x1A, 0x0E, 0x1E, 0x0B, 0x1B, 0x0F, 0x1F,
50 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F};
52 static unsigned short XGINew_VGA_DAC[] = {
53 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
54 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
55 0x00, 0x05, 0x08, 0x0B, 0x0E, 0x11, 0x14, 0x18,
56 0x1C, 0x20, 0x24, 0x28, 0x2D, 0x32, 0x38, 0x3F,
57 0x00, 0x10, 0x1F, 0x2F, 0x3F, 0x1F, 0x27, 0x2F,
58 0x37, 0x3F, 0x2D, 0x31, 0x36, 0x3A, 0x3F, 0x00,
59 0x07, 0x0E, 0x15, 0x1C, 0x0E, 0x11, 0x15, 0x18,
60 0x1C, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x00, 0x04,
61 0x08, 0x0C, 0x10, 0x08, 0x0A, 0x0C, 0x0E, 0x10,
62 0x0B, 0x0C, 0x0D, 0x0F, 0x10};
64 void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo)
66 pVBInfo->SModeIDTable = (struct XGI_StStruct *) XGI330_SModeIDTable;
67 pVBInfo->StandTable = (struct XGI_StandTableStruct *) XGI330_StandTable;
68 pVBInfo->EModeIDTable = (struct XGI_ExtStruct *) XGI330_EModeIDTable;
69 pVBInfo->RefIndex = (struct XGI_Ext2Struct *) XGI330_RefIndex;
70 pVBInfo->XGINEWUB_CRT1Table
71 = (struct XGI_CRT1TableStruct *) XGI_CRT1Table;
73 /* add for new UNIVGABIOS */
74 /* XGINew_UBLCDDataTable = (struct XGI_LCDDataTablStruct *) XGI_LCDDataTable; */
75 /* XGINew_UBTVDataTable = (XGI_TVDataTablStruct *) XGI_TVDataTable; */
77 pVBInfo->MCLKData = (struct XGI_MCLKDataStruct *) XGI340New_MCLKData;
78 pVBInfo->ECLKData = (struct XGI_ECLKDataStruct *) XGI340_ECLKData;
79 pVBInfo->VCLKData = (struct XGI_VCLKDataStruct *) XGI_VCLKData;
80 pVBInfo->VBVCLKData = (struct XGI_VBVCLKDataStruct *) XGI_VBVCLKData;
81 pVBInfo->ScreenOffset = XGI330_ScreenOffset;
82 pVBInfo->StResInfo = (struct XGI_StResInfoStruct *) XGI330_StResInfo;
84 = (struct XGI_ModeResInfoStruct *) XGI330_ModeResInfo;
86 pVBInfo->pOutputSelect = &XGI330_OutputSelect;
87 pVBInfo->pSoftSetting = &XGI330_SoftSetting;
88 pVBInfo->pSR07 = &XGI330_SR07;
89 pVBInfo->LCDResInfo = 0;
90 pVBInfo->LCDTypeInfo = 0;
95 pVBInfo->SR15 = XGI340_SR13;
96 pVBInfo->CR40 = XGI340_cr41;
97 pVBInfo->SR25 = XGI330_sr25;
98 pVBInfo->pSR31 = &XGI330_sr31;
99 pVBInfo->pSR32 = &XGI330_sr32;
100 pVBInfo->CR6B = XGI340_CR6B;
101 pVBInfo->CR6E = XGI340_CR6E;
102 pVBInfo->CR6F = XGI340_CR6F;
103 pVBInfo->CR89 = XGI340_CR89;
104 pVBInfo->AGPReg = XGI340_AGPReg;
105 pVBInfo->SR16 = XGI340_SR16;
106 pVBInfo->pCRCF = &XG40_CRCF;
107 pVBInfo->pXGINew_DRAMTypeDefinition = &XG40_DRAMTypeDefinition;
109 pVBInfo->CR49 = XGI330_CR49;
110 pVBInfo->pSR1F = &XGI330_SR1F;
111 pVBInfo->pSR21 = &XGI330_SR21;
112 pVBInfo->pSR22 = &XGI330_SR22;
113 pVBInfo->pSR23 = &XGI330_SR23;
114 pVBInfo->pSR24 = &XGI330_SR24;
115 pVBInfo->pSR33 = &XGI330_SR33;
117 pVBInfo->pCRT2Data_1_2 = &XGI330_CRT2Data_1_2;
118 pVBInfo->pCRT2Data_4_D = &XGI330_CRT2Data_4_D;
119 pVBInfo->pCRT2Data_4_E = &XGI330_CRT2Data_4_E;
120 pVBInfo->pCRT2Data_4_10 = &XGI330_CRT2Data_4_10;
121 pVBInfo->pRGBSenseData = &XGI330_RGBSenseData;
122 pVBInfo->pVideoSenseData = &XGI330_VideoSenseData;
123 pVBInfo->pYCSenseData = &XGI330_YCSenseData;
124 pVBInfo->pRGBSenseData2 = &XGI330_RGBSenseData2;
125 pVBInfo->pVideoSenseData2 = &XGI330_VideoSenseData2;
126 pVBInfo->pYCSenseData2 = &XGI330_YCSenseData2;
128 pVBInfo->NTSCTiming = XGI330_NTSCTiming;
129 pVBInfo->PALTiming = XGI330_PALTiming;
130 pVBInfo->HiTVExtTiming = XGI330_HiTVExtTiming;
131 pVBInfo->HiTVSt1Timing = XGI330_HiTVSt1Timing;
132 pVBInfo->HiTVSt2Timing = XGI330_HiTVSt2Timing;
133 pVBInfo->HiTVTextTiming = XGI330_HiTVTextTiming;
134 pVBInfo->YPbPr750pTiming = XGI330_YPbPr750pTiming;
135 pVBInfo->YPbPr525pTiming = XGI330_YPbPr525pTiming;
136 pVBInfo->YPbPr525iTiming = XGI330_YPbPr525iTiming;
137 pVBInfo->HiTVGroup3Data = XGI330_HiTVGroup3Data;
138 pVBInfo->HiTVGroup3Simu = XGI330_HiTVGroup3Simu;
139 pVBInfo->HiTVGroup3Text = XGI330_HiTVGroup3Text;
140 pVBInfo->Ren525pGroup3 = XGI330_Ren525pGroup3;
141 pVBInfo->Ren750pGroup3 = XGI330_Ren750pGroup3;
143 pVBInfo->TimingH = (struct XGI_TimingHStruct *) XGI_TimingH;
144 pVBInfo->TimingV = (struct XGI_TimingVStruct *) XGI_TimingV;
145 pVBInfo->UpdateCRT1 = (struct XGI_XG21CRT1Struct *) XGI_UpdateCRT1Table;
147 pVBInfo->CHTVVCLKUNTSC = XGI330_CHTVVCLKUNTSC;
148 pVBInfo->CHTVVCLKONTSC = XGI330_CHTVVCLKONTSC;
149 pVBInfo->CHTVVCLKUPAL = XGI330_CHTVVCLKUPAL;
150 pVBInfo->CHTVVCLKOPAL = XGI330_CHTVVCLKOPAL;
152 /* 310 customization related */
153 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType & VB_XGI302LV))
154 pVBInfo->LCDCapList = XGI_LCDDLCapList;
156 pVBInfo->LCDCapList = XGI_LCDCapList;
158 if ((ChipType == XG21) || (ChipType == XG27))
159 pVBInfo->XG21_LVDSCapList = XGI21_LCDCapList;
161 pVBInfo->XGI_TVDelayList = XGI301TVDelayList;
162 pVBInfo->XGI_TVDelayList2 = XGI301TVDelayList2;
164 pVBInfo->pXGINew_I2CDefinition = &XG40_I2CDefinition;
166 if (ChipType >= XG20)
167 pVBInfo->pXGINew_CR97 = &XG20_CR97;
169 if (ChipType == XG27) {
171 = (struct XGI_MCLKDataStruct *) XGI27New_MCLKData;
172 pVBInfo->CR40 = XGI27_cr41;
173 pVBInfo->pXGINew_CR97 = &XG27_CR97;
174 pVBInfo->pSR36 = &XG27_SR36;
175 pVBInfo->pCR8F = &XG27_CR8F;
176 pVBInfo->pCRD0 = XG27_CRD0;
177 pVBInfo->pCRDE = XG27_CRDE;
178 pVBInfo->pSR40 = &XG27_SR40;
179 pVBInfo->pSR41 = &XG27_SR41;
183 if (ChipType >= XG20) {
184 pVBInfo->pDVOSetting = &XG21_DVOSetting;
185 pVBInfo->pCR2E = &XG21_CR2E;
186 pVBInfo->pCR2F = &XG21_CR2F;
187 pVBInfo->pCR46 = &XG21_CR46;
188 pVBInfo->pCR47 = &XG21_CR47;
193 static unsigned char XGI_GetModePtr(unsigned short ModeNo, unsigned short ModeIdIndex,
194 struct vb_device_info *pVBInfo)
199 index = pVBInfo->SModeIDTable[ModeIdIndex].St_StTableIndex;
201 if (pVBInfo->ModeType <= 0x02)
202 index = 0x1B; /* 02 -> ModeEGA */
206 return index; /* Get pVBInfo->StandTable index */
210 unsigned char XGI_SetBIOSData(unsigned short ModeNo, unsigned short ModeIdIndex) {
215 /* unsigned char XGI_ClearBankRegs(unsigned short ModeNo, unsigned short ModeIdIndex) {
220 static void XGI_SetSeqRegs(unsigned short ModeNo, unsigned short StandTableIndex,
221 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
223 unsigned char tempah, SRdata;
225 unsigned short i, modeflag;
228 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
230 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
232 XGINew_SetReg1(pVBInfo->P3c4, 0x00, 0x03); /* Set SR0 */
233 tempah = pVBInfo->StandTable[StandTableIndex].SR[0];
236 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
239 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD)) {
240 if (pVBInfo->VBInfo & SetInSlaveMode)
245 tempah |= 0x20; /* screen off */
246 XGINew_SetReg1(pVBInfo->P3c4, 0x01, tempah); /* Set SR1 */
248 for (i = 02; i <= 04; i++) {
249 SRdata = pVBInfo->StandTable[StandTableIndex].SR[i - 1]; /* Get SR2,3,4 from file */
250 XGINew_SetReg1(pVBInfo->P3c4, i, SRdata); /* Set SR2 3 4 */
254 static void XGI_SetMiscRegs(unsigned short StandTableIndex,
255 struct vb_device_info *pVBInfo)
257 unsigned char Miscdata;
259 Miscdata = pVBInfo->StandTable[StandTableIndex].MISC; /* Get Misc from file */
261 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
262 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
268 outb(Miscdata, pVBInfo->P3c2); /* Set Misc(3c2) */
271 static void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension,
272 unsigned short StandTableIndex, struct vb_device_info *pVBInfo)
274 unsigned char CRTCdata;
277 CRTCdata = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11);
279 XGINew_SetReg1(pVBInfo->P3d4, 0x11, CRTCdata); /* Unlock CRTC */
281 for (i = 0; i <= 0x18; i++) {
282 CRTCdata = pVBInfo->StandTable[StandTableIndex].CRTC[i]; /* Get CRTC from file */
283 XGINew_SetReg1(pVBInfo->P3d4, i, CRTCdata); /* Set CRTC(3d4) */
286 if ((HwDeviceExtension->jChipType == XGI_630) && (HwDeviceExtension->jChipRevision == 0x30)) {
287 if (pVBInfo->VBInfo & SetInSlaveMode) {
288 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) {
289 XGINew_SetReg1(pVBInfo->P3d4, 0x18, 0xFE);
296 static void XGI_SetATTRegs(unsigned short ModeNo, unsigned short StandTableIndex,
297 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
299 unsigned char ARdata;
300 unsigned short i, modeflag;
303 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
305 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
307 for (i = 0; i <= 0x13; i++) {
308 ARdata = pVBInfo->StandTable[StandTableIndex].ATTR[i];
309 if (modeflag & Charx8Dot) { /* ifndef Dot9 */
311 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
314 if (pVBInfo->VBInfo & (SetCRT2ToTV
324 inb(pVBInfo->P3da); /* reset 3da */
325 outb(i, pVBInfo->P3c0); /* set index */
326 outb(ARdata, pVBInfo->P3c0); /* set data */
329 inb(pVBInfo->P3da); /* reset 3da */
330 outb(0x14, pVBInfo->P3c0); /* set index */
331 outb(0x00, pVBInfo->P3c0); /* set data */
332 inb(pVBInfo->P3da); /* Enable Attribute */
333 outb(0x20, pVBInfo->P3c0);
336 static void XGI_SetGRCRegs(unsigned short StandTableIndex,
337 struct vb_device_info *pVBInfo)
339 unsigned char GRdata;
342 for (i = 0; i <= 0x08; i++) {
343 GRdata = pVBInfo->StandTable[StandTableIndex].GRC[i]; /* Get GR from file */
344 XGINew_SetReg1(pVBInfo->P3ce, i, GRdata); /* Set GR(3ce) */
347 if (pVBInfo->ModeType > ModeVGA) {
348 GRdata = (unsigned char) XGINew_GetReg1(pVBInfo->P3ce, 0x05);
349 GRdata &= 0xBF; /* 256 color disable */
350 XGINew_SetReg1(pVBInfo->P3ce, 0x05, GRdata);
354 static void XGI_ClearExt1Regs(struct vb_device_info *pVBInfo)
358 for (i = 0x0A; i <= 0x0E; i++)
359 XGINew_SetReg1(pVBInfo->P3c4, i, 0x00); /* Clear SR0A-SR0E */
362 static unsigned char XGI_SetDefaultVCLK(struct vb_device_info *pVBInfo)
365 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x31, ~0x30, 0x20);
366 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, pVBInfo->VCLKData[0].SR2B);
367 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, pVBInfo->VCLKData[0].SR2C);
369 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x31, ~0x30, 0x10);
370 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, pVBInfo->VCLKData[1].SR2B);
371 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, pVBInfo->VCLKData[1].SR2C);
373 XGINew_SetRegAND(pVBInfo->P3c4, 0x31, ~0x30);
377 static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo,
378 unsigned short ModeIdIndex,
379 unsigned short RefreshRateTableIndex, unsigned short *i,
380 struct vb_device_info *pVBInfo)
382 unsigned short tempax, tempbx, resinfo, modeflag, infoflag;
385 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ModeFlag */
387 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
389 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
390 tempbx = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID;
393 if (pVBInfo->IF_DEF_LVDS == 0) {
394 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
395 tempax |= SupportRAMDAC2;
397 if (pVBInfo->VBType & VB_XGI301C)
398 tempax |= SupportCRT2in301C;
401 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { /* 301b */
402 tempax |= SupportLCD;
404 if (pVBInfo->LCDResInfo != Panel1280x1024) {
405 if (pVBInfo->LCDResInfo != Panel1280x960) {
406 if (pVBInfo->LCDInfo & LCDNonExpanding) {
416 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { /* for HiTV */
417 if ((pVBInfo->VBType & VB_XGI301LV)
418 && (pVBInfo->VBExtInfo == VB_YPbPr1080i)) {
419 tempax |= SupportYPbPr;
420 if (pVBInfo->VBInfo & SetInSlaveMode) {
431 tempax |= SupportHiVisionTV;
432 if (pVBInfo->VBInfo & SetInSlaveMode) {
447 if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO
448 | SetCRT2ToSVIDEO | SetCRT2ToSCART
449 | SetCRT2ToYPbPr | SetCRT2ToHiVisionTV)) {
452 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
453 | VB_XGI301LV | VB_XGI302LV
455 tempax |= SupportTV1024;
458 if (!(pVBInfo->VBInfo & SetPALTV)) {
459 if (modeflag & NoSupportSimuTV) {
462 if (!(pVBInfo->VBInfo
471 } else { /* for LVDS */
472 if (pVBInfo->IF_DEF_CH7005 == 1) {
473 if (pVBInfo->VBInfo & SetCRT2ToTV)
474 tempax |= SupportCHTV;
477 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
478 tempax |= SupportLCD;
481 return 0; /* 1024x768 */
483 if (pVBInfo->LCDResInfo < Panel1024x768) {
485 return 0; /* 800x600 */
488 return 0; /* 512x384 */
493 for (; pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID == tempbx; (*i)--) {
495 = pVBInfo->RefIndex[RefreshRateTableIndex
496 + (*i)].Ext_InfoFlag;
497 if (infoflag & tempax)
504 for ((*i) = 0;; (*i)++) {
506 = pVBInfo->RefIndex[RefreshRateTableIndex
507 + (*i)].Ext_InfoFlag;
508 if (pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID
513 if (infoflag & tempax)
519 static void XGI_SetSync(unsigned short RefreshRateTableIndex,
520 struct vb_device_info *pVBInfo)
522 unsigned short sync, temp;
524 sync = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag >> 8; /* di+0x00 */
528 outb(temp, pVBInfo->P3c2); /* Set Misc(3c2) */
531 static void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo,
532 struct xgi_hw_device_info *HwDeviceExtension)
534 unsigned char data, data1, pushax;
537 /* XGINew_SetReg1(pVBInfo->P3d4, 0x51, 0); */
538 /* XGINew_SetReg1(pVBInfo->P3d4, 0x56, 0); */
539 /* XGINew_SetRegANDOR(pVBInfo->P3d4, 0x11, 0x7f, 0x00); */
541 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11); /* unlock cr0-7 */
543 XGINew_SetReg1(pVBInfo->P3d4, 0x11, data);
545 data = pVBInfo->TimingH[0].data[0];
546 XGINew_SetReg1(pVBInfo->P3d4, 0, data);
548 for (i = 0x01; i <= 0x04; i++) {
549 data = pVBInfo->TimingH[0].data[i];
550 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 1), data);
553 for (i = 0x05; i <= 0x06; i++) {
554 data = pVBInfo->TimingH[0].data[i];
555 XGINew_SetReg1(pVBInfo->P3c4, (unsigned short) (i + 6), data);
558 j = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x0e);
560 data = pVBInfo->TimingH[0].data[7];
563 XGINew_SetReg1(pVBInfo->P3c4, 0x0e, data);
565 if (HwDeviceExtension->jChipType >= XG20) {
566 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x04);
568 XGINew_SetReg1(pVBInfo->P3d4, 0x04, data);
569 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x05);
575 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4,
578 XGINew_SetReg1(pVBInfo->P3c4, 0x0c, data);
583 XGINew_SetReg1(pVBInfo->P3d4, 0x05, data);
584 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x0e);
590 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0e, ~0xE0, data);
594 static void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex, unsigned short ModeNo,
595 struct vb_device_info *pVBInfo)
600 /* XGINew_SetReg1(pVBInfo->P3d4, 0x51, 0); */
601 /* XGINew_SetReg1(pVBInfo->P3d4, 0x56, 0); */
602 /* XGINew_SetRegANDOR(pVBInfo->P3d4, 0x11, 0x7f, 0x00); */
604 for (i = 0x00; i <= 0x01; i++) {
605 data = pVBInfo->TimingV[0].data[i];
606 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 6), data);
609 for (i = 0x02; i <= 0x03; i++) {
610 data = pVBInfo->TimingV[0].data[i];
611 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 0x0e), data);
614 for (i = 0x04; i <= 0x05; i++) {
615 data = pVBInfo->TimingV[0].data[i];
616 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 0x11), data);
619 j = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x0a);
621 data = pVBInfo->TimingV[0].data[6];
624 XGINew_SetReg1(pVBInfo->P3c4, 0x0a, data);
626 data = pVBInfo->TimingV[0].data[6];
631 i = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
633 i = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
639 j = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x09);
642 XGINew_SetReg1(pVBInfo->P3d4, 0x09, data);
645 static void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
646 unsigned short RefreshRateTableIndex,
647 struct vb_device_info *pVBInfo,
648 struct xgi_hw_device_info *HwDeviceExtension)
650 unsigned char index, data;
653 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; /* Get index */
654 index = index & IndexMask;
656 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11);
658 XGINew_SetReg1(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */
660 for (i = 0; i < 8; i++)
661 pVBInfo->TimingH[0].data[i]
662 = pVBInfo->XGINEWUB_CRT1Table[index].CR[i];
664 for (i = 0; i < 7; i++)
665 pVBInfo->TimingV[0].data[i]
666 = pVBInfo->XGINEWUB_CRT1Table[index].CR[i + 8];
668 XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension);
670 XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo);
672 if (pVBInfo->ModeType > 0x03)
673 XGINew_SetReg1(pVBInfo->P3d4, 0x14, 0x4F);
676 /* --------------------------------------------------------------------- */
677 /* Function : XGI_SetXG21CRTC */
678 /* Input : Stand or enhance CRTC table */
679 /* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */
680 /* Description : Set LCD timing */
681 /* --------------------------------------------------------------------- */
682 static void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
683 unsigned short RefreshRateTableIndex,
684 struct vb_device_info *pVBInfo)
686 unsigned char StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx;
687 unsigned short Temp1, Temp2, Temp3;
689 if (ModeNo <= 0x13) {
690 StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
691 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[4]; /* CR04 HRS */
692 XGINew_SetReg1(pVBInfo->P3c4, 0x2E, Tempax); /* SR2E [7:0]->HRS */
693 Tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[5]; /* Tempbx: CR05 HRE */
694 Tempbx &= 0x1F; /* Tempbx: HRE[4:0] */
696 Tempcx &= 0xE0; /* Tempcx: HRS[7:5] */
697 Tempdx = Tempcx | Tempbx; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
698 if (Tempbx < (Tempax & 0x1F)) /* IF HRE < HRS */
699 Tempdx |= 0x20; /* Tempdx: HRE = HRE + 0x20 */
700 Tempdx <<= 2; /* Tempdx << 2 */
701 XGINew_SetReg1(pVBInfo->P3c4, 0x2F, Tempdx); /* SR2F [7:2]->HRE */
702 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x30, 0xE3, 00);
704 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[16]; /* Tempax: CR16 VRS */
705 Tempbx = Tempax; /* Tempbx=Tempax */
706 Tempax &= 0x01; /* Tempax: VRS[0] */
707 XGINew_SetRegOR(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS */
708 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[7]; /* Tempax: CR7 VRS */
709 Tempdx = Tempbx >> 1; /* Tempdx: VRS[7:1] */
710 Tempcx = Tempax & 0x04; /* Tempcx: CR7[2] */
711 Tempcx <<= 5; /* Tempcx[7]: VRS[8] */
712 Tempdx |= Tempcx; /* Tempdx: VRS[8:1] */
713 XGINew_SetReg1(pVBInfo->P3c4, 0x34, Tempdx); /* SR34[7:0]: VRS[8:1] */
715 Temp1 = Tempcx << 1; /* Temp1[8]: VRS[8] unsigned char -> unsigned short */
716 Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */
717 Tempax &= 0x80; /* Tempax[7]: CR7[7] */
718 Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */
719 Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */
721 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[17]; /* CR16 VRE */
722 Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
723 Temp2 = Temp1 & 0x3F0; /* Temp2[9:4]: VRS[9:4] */
724 Temp2 |= Tempax; /* Temp2[9:0]: VRE[9:0] */
725 Temp3 = Temp1 & 0x0F; /* Temp3[3:0]: VRS[3:0] */
726 if (Tempax < Temp3) /* VRE[3:0]<VRS[3:0] */
727 Temp2 |= 0x10; /* Temp2: VRE + 0x10 */
728 Temp2 &= 0xFF; /* Temp2[7:0]: VRE[7:0] */
729 Tempax = (unsigned char) Temp2; /* Tempax[7:0]: VRE[7:0] */
730 Tempax <<= 2; /* Tempax << 2: VRE[5:0] */
731 Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */
732 Temp1 >>= 9; /* [10:9]->[1:0] */
733 Tempbx = (unsigned char) Temp1; /* Tempbx[1:0]: VRS[10:9] */
734 Tempax |= Tempbx; /* VRE[5:0]VRS[10:9] */
736 XGINew_SetReg1(pVBInfo->P3c4, 0x3F, Tempax); /* SR3F D[7:2]->VRE D[1:0]->VRS */
738 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
739 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3]; /* Tempax: CR4 HRS */
740 Tempcx = Tempax; /* Tempcx: HRS */
741 XGINew_SetReg1(pVBInfo->P3c4, 0x2E, Tempax); /* SR2E[7:0]->HRS */
743 Tempdx = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SRB */
744 Tempdx &= 0xC0; /* Tempdx[7:6]: SRB[7:6] */
745 Temp1 = Tempdx; /* Temp1[7:6]: HRS[9:8] */
746 Temp1 <<= 2; /* Temp1[9:8]: HRS[9:8] */
747 Temp1 |= Tempax; /* Temp1[9:0]: HRS[9:0] */
749 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */
750 Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */
752 Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[6]; /* SRC */
753 Tempbx &= 0x04; /* Tempbx[2]: HRE[5] */
754 Tempbx <<= 3; /* Tempbx[5]: HRE[5] */
755 Tempax |= Tempbx; /* Tempax[5:0]: HRE[5:0] */
757 Temp2 = Temp1 & 0x3C0; /* Temp2[9:6]: HRS[9:6] */
758 Temp2 |= Tempax; /* Temp2[9:0]: HRE[9:0] */
760 Tempcx &= 0x3F; /* Tempcx[5:0]: HRS[5:0] */
761 if (Tempax < Tempcx) /* HRE < HRS */
762 Temp2 |= 0x40; /* Temp2 + 0x40 */
765 Tempax = (unsigned char) Temp2; /* Tempax: HRE[7:0] */
766 Tempax <<= 2; /* Tempax[7:2]: HRE[5:0] */
767 Tempdx >>= 6; /* Tempdx[7:6]->[1:0] HRS[9:8] */
768 Tempax |= Tempdx; /* HRE[5:0]HRS[9:8] */
769 XGINew_SetReg1(pVBInfo->P3c4, 0x2F, Tempax); /* SR2F D[7:2]->HRE, D[1:0]->HRS */
770 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x30, 0xE3, 00);
772 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10]; /* CR10 VRS */
773 Tempbx = Tempax; /* Tempbx: VRS */
774 Tempax &= 0x01; /* Tempax[0]: VRS[0] */
775 XGINew_SetRegOR(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS[0] */
776 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9]; /* CR7[2][7] VRE */
777 Tempcx = Tempbx >> 1; /* Tempcx[6:0]: VRS[7:1] */
778 Tempdx = Tempax & 0x04; /* Tempdx[2]: CR7[2] */
779 Tempdx <<= 5; /* Tempdx[7]: VRS[8] */
780 Tempcx |= Tempdx; /* Tempcx[7:0]: VRS[8:1] */
781 XGINew_SetReg1(pVBInfo->P3c4, 0x34, Tempcx); /* SR34[8:1]->VRS */
783 Temp1 = Tempdx; /* Temp1[7]: Tempdx[7] */
784 Temp1 <<= 1; /* Temp1[8]: VRS[8] */
785 Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */
787 Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */
788 Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */
789 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; /* Tempax: SRA */
790 Tempax &= 0x08; /* Tempax[3]: VRS[3] */
792 Temp2 <<= 7; /* Temp2[10]: VRS[10] */
793 Temp1 |= Temp2; /* Temp1[10:0]: VRS[10:0] */
795 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11]; /* Tempax: CR11 VRE */
796 Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
797 Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; /* Tempbx: SRA */
798 Tempbx &= 0x20; /* Tempbx[5]: VRE[5] */
799 Tempbx >>= 1; /* Tempbx[4]: VRE[4] */
800 Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */
801 Temp2 = Temp1 & 0x7E0; /* Temp2[10:5]: VRS[10:5] */
802 Temp2 |= Tempax; /* Temp2[10:5]: VRE[10:5] */
804 Temp3 = Temp1 & 0x1F; /* Temp3[4:0]: VRS[4:0] */
805 if (Tempax < Temp3) /* VRE < VRS */
806 Temp2 |= 0x20; /* VRE + 0x20 */
809 Tempax = (unsigned char) Temp2; /* Tempax: VRE[7:0] */
810 Tempax <<= 2; /* Tempax[7:0]; VRE[5:0]00 */
811 Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */
812 Temp1 >>= 9; /* Temp1[1:0]: VRS[10:9] */
813 Tempbx = (unsigned char) Temp1;
814 Tempax |= Tempbx; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */
816 XGINew_SetReg1(pVBInfo->P3c4, 0x3F, Tempax); /* SR3F D[7:2]->VRE D[1:0]->VRS */
820 static void XGI_SetXG27CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
821 unsigned short RefreshRateTableIndex,
822 struct vb_device_info *pVBInfo)
824 unsigned short StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx;
826 if (ModeNo <= 0x13) {
827 StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
828 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[4]; /* CR04 HRS */
829 XGINew_SetReg1(pVBInfo->P3c4, 0x2E, Tempax); /* SR2E [7:0]->HRS */
830 Tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[5]; /* Tempbx: CR05 HRE */
831 Tempbx &= 0x1F; /* Tempbx: HRE[4:0] */
833 Tempcx &= 0xE0; /* Tempcx: HRS[7:5] */
834 Tempdx = Tempcx | Tempbx; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
835 if (Tempbx < (Tempax & 0x1F)) /* IF HRE < HRS */
836 Tempdx |= 0x20; /* Tempdx: HRE = HRE + 0x20 */
837 Tempdx <<= 2; /* Tempdx << 2 */
838 XGINew_SetReg1(pVBInfo->P3c4, 0x2F, Tempdx); /* SR2F [7:2]->HRE */
839 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x30, 0xE3, 00);
841 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[16]; /* Tempax: CR10 VRS */
842 XGINew_SetReg1(pVBInfo->P3c4, 0x34, Tempax); /* SR34[7:0]->VRS */
843 Tempcx = Tempax; /* Tempcx=Tempax=VRS[7:0] */
844 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[7]; /* Tempax[7][2]: CR7[7][2] VRS[9][8] */
845 Tempbx = Tempax; /* Tempbx=CR07 */
846 Tempax &= 0x04; /* Tempax[2]: CR07[2] VRS[8] */
848 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x01, Tempax); /* SR35 D[0]->VRS D[8] */
849 Tempcx |= (Tempax << 8); /* Tempcx[8] |= VRS[8] */
850 Tempcx |= (Tempbx & 0x80) << 2; /* Tempcx[9] |= VRS[9] */
852 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[17]; /* CR11 VRE */
853 Tempax &= 0x0F; /* Tempax: VRE[3:0] */
854 Tempbx = Tempcx; /* Tempbx=Tempcx=VRS[9:0] */
855 Tempbx &= 0x3F0; /* Tempbx[9:4]: VRS[9:4] */
856 Tempbx |= Tempax; /* Tempbx[9:0]: VRE[9:0] */
857 if (Tempax <= (Tempcx & 0x0F)) /* VRE[3:0]<=VRS[3:0] */
858 Tempbx |= 0x10; /* Tempbx: VRE + 0x10 */
859 Tempax = (unsigned char) Tempbx & 0xFF; /* Tempax[7:0]: VRE[7:0] */
860 Tempax <<= 2; /* Tempax << 2: VRE[5:0] */
861 Tempcx = (Tempcx & 0x600) >> 8; /* Tempcx VRS[10:9] */
862 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax); /* SR3F D[7:2]->VRE D[5:0] */
863 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x06, Tempcx); /* SR35 D[2:1]->VRS[10:9] */
865 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
866 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3]; /* Tempax: CR4 HRS */
867 Tempbx = Tempax; /* Tempbx: HRS[7:0] */
868 XGINew_SetReg1(pVBInfo->P3c4, 0x2E, Tempax); /* SR2E[7:0]->HRS */
870 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SR0B */
871 Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
872 Tempbx |= (Tempax << 2); /* Tempbx: HRS[9:0] */
874 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */
875 Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */
876 Tempcx = Tempax; /* Tempcx: HRE[4:0] */
878 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[6]; /* SRC */
879 Tempax &= 0x04; /* Tempax[2]: HRE[5] */
880 Tempax <<= 3; /* Tempax[5]: HRE[5] */
881 Tempcx |= Tempax; /* Tempcx[5:0]: HRE[5:0] */
883 Tempbx = Tempbx & 0x3C0; /* Tempbx[9:6]: HRS[9:6] */
884 Tempbx |= Tempcx; /* Tempbx: HRS[9:6]HRE[5:0] */
886 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3]; /* Tempax: CR4 HRS */
887 Tempax &= 0x3F; /* Tempax: HRS[5:0] */
888 if (Tempcx <= Tempax) /* HRE[5:0] < HRS[5:0] */
889 Tempbx += 0x40; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/
891 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SR0B */
892 Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
893 Tempax >>= 6; /* Tempax[1:0]: HRS[9:8]*/
894 Tempax |= ((Tempbx << 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */
895 XGINew_SetReg1(pVBInfo->P3c4, 0x2F, Tempax); /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */
896 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x30, 0xE3, 00);
898 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10]; /* CR10 VRS */
899 XGINew_SetReg1(pVBInfo->P3c4, 0x34, Tempax); /* SR34[7:0]->VRS[7:0] */
901 Tempcx = Tempax; /* Tempcx <= VRS[7:0] */
902 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9]; /* CR7[7][2] VRS[9][8] */
903 Tempbx = Tempax; /* Tempbx <= CR07[7:0] */
904 Tempax = Tempax & 0x04; /* Tempax[2]: CR7[2]: VRS[8] */
905 Tempax >>= 2; /* Tempax[0]: VRS[8] */
906 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x01, Tempax); /* SR35[0]: VRS[8] */
907 Tempcx |= (Tempax << 8); /* Tempcx <= VRS[8:0] */
908 Tempcx |= ((Tempbx & 0x80) << 2); /* Tempcx <= VRS[9:0] */
909 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; /* Tempax: SR0A */
910 Tempax &= 0x08; /* SR0A[3] VRS[10] */
911 Tempcx |= (Tempax << 7); /* Tempcx <= VRS[10:0] */
913 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11]; /* Tempax: CR11 VRE */
914 Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
915 Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; /* Tempbx: SR0A */
916 Tempbx &= 0x20; /* Tempbx[5]: SR0A[5]: VRE[4] */
917 Tempbx >>= 1; /* Tempbx[4]: VRE[4] */
918 Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */
919 Tempbx = Tempcx; /* Tempbx: VRS[10:0] */
920 Tempbx &= 0x7E0; /* Tempbx[10:5]: VRS[10:5] */
921 Tempbx |= Tempax; /* Tempbx: VRS[10:5]VRE[4:0] */
923 if (Tempbx <= Tempcx) /* VRE <= VRS */
924 Tempbx |= 0x20; /* VRE + 0x20 */
926 Tempax = (Tempbx << 2) & 0xFF; /* Tempax: Tempax[7:0]; VRE[5:0]00 */
927 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax); /* SR3F[7:2]:VRE[5:0] */
928 Tempax = Tempcx >> 8;
929 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x07, Tempax); /* SR35[2:0]:VRS[10:8] */
933 /* --------------------------------------------------------------------- */
934 /* Function : XGI_SetXG21LCD */
936 /* Output : FCLK duty cycle, FCLK delay compensation */
937 /* Description : All values set zero */
938 /* --------------------------------------------------------------------- */
939 static void XGI_SetXG21LCD(struct vb_device_info *pVBInfo,
940 unsigned short RefreshRateTableIndex, unsigned short ModeNo)
942 unsigned short Data, Temp, b3CC;
943 unsigned short XGI_P3cc;
945 XGI_P3cc = pVBInfo->P3cc;
947 XGINew_SetReg1(pVBInfo->P3d4, 0x2E, 0x00);
948 XGINew_SetReg1(pVBInfo->P3d4, 0x2F, 0x00);
949 XGINew_SetReg1(pVBInfo->P3d4, 0x46, 0x00);
950 XGINew_SetReg1(pVBInfo->P3d4, 0x47, 0x00);
951 if (((*pVBInfo->pDVOSetting) & 0xC0) == 0xC0) {
952 XGINew_SetReg1(pVBInfo->P3d4, 0x2E, *pVBInfo->pCR2E);
953 XGINew_SetReg1(pVBInfo->P3d4, 0x2F, *pVBInfo->pCR2F);
954 XGINew_SetReg1(pVBInfo->P3d4, 0x46, *pVBInfo->pCR46);
955 XGINew_SetReg1(pVBInfo->P3d4, 0x47, *pVBInfo->pCR47);
958 Temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37);
961 XGINew_SetRegOR(pVBInfo->P3c4, 0x06, 0x40); /* 18 bits FP */
962 XGINew_SetRegOR(pVBInfo->P3c4, 0x09, 0x40);
965 XGINew_SetRegOR(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */
967 XGINew_SetRegAND(pVBInfo->P3c4, 0x30, ~0x20);
968 XGINew_SetRegAND(pVBInfo->P3c4, 0x35, ~0x80);
970 if (ModeNo <= 0x13) {
971 b3CC = (unsigned char) inb(XGI_P3cc);
973 XGINew_SetRegOR(pVBInfo->P3c4, 0x30, 0x20); /* Hsync polarity */
975 XGINew_SetRegOR(pVBInfo->P3c4, 0x35, 0x80); /* Vsync polarity */
977 Data = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
979 XGINew_SetRegOR(pVBInfo->P3c4, 0x30, 0x20); /* Hsync polarity */
981 XGINew_SetRegOR(pVBInfo->P3c4, 0x35, 0x80); /* Vsync polarity */
985 static void XGI_SetXG27LCD(struct vb_device_info *pVBInfo,
986 unsigned short RefreshRateTableIndex, unsigned short ModeNo)
988 unsigned short Data, Temp, b3CC;
989 unsigned short XGI_P3cc;
991 XGI_P3cc = pVBInfo->P3cc;
993 XGINew_SetReg1(pVBInfo->P3d4, 0x2E, 0x00);
994 XGINew_SetReg1(pVBInfo->P3d4, 0x2F, 0x00);
995 XGINew_SetReg1(pVBInfo->P3d4, 0x46, 0x00);
996 XGINew_SetReg1(pVBInfo->P3d4, 0x47, 0x00);
998 Temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37);
999 if ((Temp & 0x03) == 0) { /* dual 12 */
1000 XGINew_SetReg1(pVBInfo->P3d4, 0x46, 0x13);
1001 XGINew_SetReg1(pVBInfo->P3d4, 0x47, 0x13);
1004 if (((*pVBInfo->pDVOSetting) & 0xC0) == 0xC0) {
1005 XGINew_SetReg1(pVBInfo->P3d4, 0x2E, *pVBInfo->pCR2E);
1006 XGINew_SetReg1(pVBInfo->P3d4, 0x2F, *pVBInfo->pCR2F);
1007 XGINew_SetReg1(pVBInfo->P3d4, 0x46, *pVBInfo->pCR46);
1008 XGINew_SetReg1(pVBInfo->P3d4, 0x47, *pVBInfo->pCR47);
1011 XGI_SetXG27FPBits(pVBInfo);
1013 XGINew_SetRegOR(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */
1015 XGINew_SetRegAND(pVBInfo->P3c4, 0x30, ~0x20); /* Hsync polarity */
1016 XGINew_SetRegAND(pVBInfo->P3c4, 0x35, ~0x80); /* Vsync polarity */
1018 if (ModeNo <= 0x13) {
1019 b3CC = (unsigned char) inb(XGI_P3cc);
1021 XGINew_SetRegOR(pVBInfo->P3c4, 0x30, 0x20); /* Hsync polarity */
1023 XGINew_SetRegOR(pVBInfo->P3c4, 0x35, 0x80); /* Vsync polarity */
1025 Data = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1027 XGINew_SetRegOR(pVBInfo->P3c4, 0x30, 0x20); /* Hsync polarity */
1029 XGINew_SetRegOR(pVBInfo->P3c4, 0x35, 0x80); /* Vsync polarity */
1033 /* --------------------------------------------------------------------- */
1034 /* Function : XGI_UpdateXG21CRTC */
1036 /* Output : CRT1 CRTC */
1037 /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */
1038 /* --------------------------------------------------------------------- */
1039 static void XGI_UpdateXG21CRTC(unsigned short ModeNo, struct vb_device_info *pVBInfo,
1040 unsigned short RefreshRateTableIndex)
1044 XGINew_SetRegAND(pVBInfo->P3d4, 0x11, 0x7F); /* Unlock CR0~7 */
1045 if (ModeNo <= 0x13) {
1046 for (i = 0; i < 12; i++) {
1047 if (ModeNo == pVBInfo->UpdateCRT1[i].ModeID)
1052 && (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC
1055 else if (ModeNo == 0x2E
1056 && (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC
1059 else if (ModeNo == 0x2F)
1061 else if (ModeNo == 0x50)
1063 else if (ModeNo == 0x59)
1068 XGINew_SetReg1(pVBInfo->P3d4, 0x02,
1069 pVBInfo->UpdateCRT1[index].CR02);
1070 XGINew_SetReg1(pVBInfo->P3d4, 0x03,
1071 pVBInfo->UpdateCRT1[index].CR03);
1072 XGINew_SetReg1(pVBInfo->P3d4, 0x15,
1073 pVBInfo->UpdateCRT1[index].CR15);
1074 XGINew_SetReg1(pVBInfo->P3d4, 0x16,
1075 pVBInfo->UpdateCRT1[index].CR16);
1079 static void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension,
1080 unsigned short ModeNo, unsigned short ModeIdIndex,
1081 unsigned short RefreshRateTableIndex,
1082 struct vb_device_info *pVBInfo)
1084 unsigned short resindex, tempax, tempbx, tempcx, temp, modeflag;
1088 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
1090 if (ModeNo <= 0x13) {
1091 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
1092 tempax = pVBInfo->StResInfo[resindex].HTotal;
1093 tempbx = pVBInfo->StResInfo[resindex].VTotal;
1095 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1096 tempax = pVBInfo->ModeResInfo[resindex].HTotal;
1097 tempbx = pVBInfo->ModeResInfo[resindex].VTotal;
1100 if (modeflag & HalfDCLK)
1101 tempax = tempax >> 1;
1103 if (ModeNo > 0x13) {
1104 if (modeflag & HalfDCLK)
1105 tempax = tempax << 1;
1107 temp = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1109 if (temp & InterlaceMode)
1110 tempbx = tempbx >> 1;
1112 if (modeflag & DoubleScanMode)
1113 tempbx = tempbx << 1;
1118 /* if (!(modeflag & Charx8Dot)) */
1125 temp = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11);
1126 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11);
1128 XGINew_SetReg1(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */
1129 XGINew_SetReg1(pVBInfo->P3d4, 0x01, (unsigned short) (tempcx & 0xff));
1130 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x0b, ~0x0c,
1131 (unsigned short) ((tempcx & 0x0ff00) >> 10));
1132 XGINew_SetReg1(pVBInfo->P3d4, 0x12, (unsigned short) (tempbx & 0xff));
1134 tempbx = tempbx >> 8;
1142 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x42, tempax);
1143 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x07);
1150 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x0a, ~0x02, tempax);
1151 XGINew_SetReg1(pVBInfo->P3d4, 0x11, temp);
1154 unsigned short XGI_GetResInfo(unsigned short ModeNo,
1155 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
1157 unsigned short resindex;
1160 resindex = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; /* si+St_ResInfo */
1162 resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; /* si+Ext_ResInfo */
1166 static void XGI_SetCRT1Offset(unsigned short ModeNo, unsigned short ModeIdIndex,
1167 unsigned short RefreshRateTableIndex,
1168 struct xgi_hw_device_info *HwDeviceExtension,
1169 struct vb_device_info *pVBInfo)
1171 unsigned short temp, ah, al, temp2, i, DisplayUnit;
1174 temp = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo;
1176 temp = pVBInfo->ScreenOffset[temp];
1178 temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1179 temp2 &= InterlaceMode;
1184 temp2 = pVBInfo->ModeType - ModeEGA;
1209 if ((ModeNo >= 0x26) && (ModeNo <= 0x28))
1210 temp = temp * temp2 + temp2 / 2;
1217 temp = temp >> 8; /* ah */
1219 i = XGINew_GetReg1(pVBInfo->P3c4, 0x0E);
1222 XGINew_SetReg1(pVBInfo->P3c4, 0x0E, i);
1224 temp = (unsigned char) temp2;
1225 temp &= 0xFF; /* al */
1226 XGINew_SetReg1(pVBInfo->P3d4, 0x13, temp);
1228 /* SetDisplayUnit */
1229 temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1230 temp2 &= InterlaceMode;
1234 DisplayUnit = DisplayUnit << 5;
1235 ah = (DisplayUnit & 0xff00) >> 8;
1236 al = DisplayUnit & 0x00ff;
1242 if (HwDeviceExtension->jChipType >= XG20)
1243 if ((ModeNo == 0x4A) | (ModeNo == 0x49))
1246 XGINew_SetReg1(pVBInfo->P3c4, 0x10, ah);
1249 static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo,
1250 unsigned short ModeIdIndex,
1251 unsigned short RefreshRateTableIndex,
1252 struct xgi_hw_device_info *HwDeviceExtension,
1253 struct vb_device_info *pVBInfo)
1255 unsigned short tempbx;
1257 unsigned short LCDXlat1VCLK[4] = { VCLK65 + 2, VCLK65 + 2, VCLK65 + 2,
1259 unsigned short LCDXlat2VCLK[4] = { VCLK108_2 + 5, VCLK108_2 + 5,
1260 VCLK108_2 + 5, VCLK108_2 + 5 };
1261 unsigned short LVDSXlat1VCLK[4] = { VCLK40, VCLK40, VCLK40, VCLK40 };
1262 unsigned short LVDSXlat2VCLK[4] = { VCLK65 + 2, VCLK65 + 2, VCLK65 + 2,
1264 unsigned short LVDSXlat3VCLK[4] = { VCLK65 + 2, VCLK65 + 2, VCLK65 + 2,
1267 unsigned short CRT2Index, VCLKIndex;
1268 unsigned short modeflag, resinfo;
1269 unsigned char *CHTVVCLKPtr = NULL;
1271 if (ModeNo <= 0x13) {
1272 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
1273 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
1274 CRT2Index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
1276 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
1277 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
1279 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
1282 if (pVBInfo->IF_DEF_LVDS == 0) {
1283 CRT2Index = CRT2Index >> 6; /* for LCD */
1284 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { /*301b*/
1285 if (pVBInfo->LCDResInfo != Panel1024x768)
1286 VCLKIndex = LCDXlat2VCLK[CRT2Index];
1288 VCLKIndex = LCDXlat1VCLK[CRT2Index];
1289 } else { /* for TV */
1290 if (pVBInfo->VBInfo & SetCRT2ToTV) {
1291 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
1292 if (pVBInfo->SetFlag & RPLLDIV2XO) {
1293 VCLKIndex = HiTVVCLKDIV2;
1298 VCLKIndex = HiTVVCLK;
1304 if (pVBInfo->SetFlag & TVSimuMode) {
1305 if (modeflag & Charx8Dot) {
1320 if (pVBInfo->VBType & VB_XGI301LV) { /* 301lv */
1321 if (!(pVBInfo->VBExtInfo
1322 == VB_YPbPr1080i)) {
1325 if (!(pVBInfo->VBExtInfo
1329 if (!(pVBInfo->VBExtInfo
1333 if (!(pVBInfo->SetFlag
1342 if (pVBInfo->VBInfo & SetCRT2ToTV) {
1343 if (pVBInfo->SetFlag
1345 VCLKIndex = TVVCLKDIV2;
1357 } else { /* for CRT2 */
1358 VCLKIndex = (unsigned char) inb(
1359 (pVBInfo->P3ca + 0x02)); /* Port 3cch */
1360 VCLKIndex = ((VCLKIndex >> 2) & 0x03);
1361 if (ModeNo > 0x13) {
1363 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; /* di+Ext_CRTVCLK */
1364 VCLKIndex &= IndexMask;
1370 VCLKIndex = CRT2Index;
1372 VCLKIndex = CRT2Index;
1374 if (pVBInfo->IF_DEF_CH7005 == 1) {
1375 if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) {
1379 if (pVBInfo->VBInfo & SetPALTV)
1382 if (pVBInfo->VBInfo & SetCHTVOverScan)
1387 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC;
1390 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC;
1393 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL;
1396 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL;
1402 VCLKIndex = CHTVVCLKPtr[VCLKIndex];
1405 VCLKIndex = VCLKIndex >> 6;
1406 if ((pVBInfo->LCDResInfo == Panel800x600)
1407 || (pVBInfo->LCDResInfo == Panel320x480))
1408 VCLKIndex = LVDSXlat1VCLK[VCLKIndex];
1409 else if ((pVBInfo->LCDResInfo == Panel1024x768)
1410 || (pVBInfo->LCDResInfo
1411 == Panel1024x768x75))
1412 VCLKIndex = LVDSXlat2VCLK[VCLKIndex];
1414 VCLKIndex = LVDSXlat3VCLK[VCLKIndex];
1417 /* VCLKIndex = VCLKIndex&IndexMask; */
1422 static void XGI_SetCRT1VCLK(unsigned short ModeNo, unsigned short ModeIdIndex,
1423 struct xgi_hw_device_info *HwDeviceExtension,
1424 unsigned short RefreshRateTableIndex,
1425 struct vb_device_info *pVBInfo)
1427 unsigned char index, data;
1428 unsigned short vclkindex;
1430 if (pVBInfo->IF_DEF_LVDS == 1) {
1431 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1432 data = XGINew_GetReg1(pVBInfo->P3c4, 0x31) & 0xCF;
1433 XGINew_SetReg1(pVBInfo->P3c4, 0x31, data);
1434 XGINew_SetReg1(pVBInfo->P3c4, 0x2B,
1435 pVBInfo->VCLKData[index].SR2B);
1436 XGINew_SetReg1(pVBInfo->P3c4, 0x2C,
1437 pVBInfo->VCLKData[index].SR2C);
1438 XGINew_SetReg1(pVBInfo->P3c4, 0x2D, 0x01);
1439 } else if ((pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
1440 | VB_XGI302LV | VB_XGI301C)) && (pVBInfo->VBInfo
1442 vclkindex = XGI_GetVCLK2Ptr(ModeNo, ModeIdIndex,
1443 RefreshRateTableIndex, HwDeviceExtension,
1445 data = XGINew_GetReg1(pVBInfo->P3c4, 0x31) & 0xCF;
1446 XGINew_SetReg1(pVBInfo->P3c4, 0x31, data);
1447 data = pVBInfo->VBVCLKData[vclkindex].Part4_A;
1448 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, data);
1449 data = pVBInfo->VBVCLKData[vclkindex].Part4_B;
1450 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, data);
1451 XGINew_SetReg1(pVBInfo->P3c4, 0x2D, 0x01);
1453 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1454 data = XGINew_GetReg1(pVBInfo->P3c4, 0x31) & 0xCF;
1455 XGINew_SetReg1(pVBInfo->P3c4, 0x31, data);
1456 XGINew_SetReg1(pVBInfo->P3c4, 0x2B,
1457 pVBInfo->VCLKData[index].SR2B);
1458 XGINew_SetReg1(pVBInfo->P3c4, 0x2C,
1459 pVBInfo->VCLKData[index].SR2C);
1460 XGINew_SetReg1(pVBInfo->P3c4, 0x2D, 0x01);
1463 if (HwDeviceExtension->jChipType >= XG20) {
1464 if (pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag & HalfDCLK) {
1465 data = XGINew_GetReg1(pVBInfo->P3c4, 0x2B);
1466 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, data);
1467 data = XGINew_GetReg1(pVBInfo->P3c4, 0x2C);
1474 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, data);
1479 static void XGI_SetCRT1FIFO(unsigned short ModeNo,
1480 struct xgi_hw_device_info *HwDeviceExtension,
1481 struct vb_device_info *pVBInfo)
1483 unsigned short data;
1485 data = XGINew_GetReg1(pVBInfo->P3c4, 0x3D);
1487 XGINew_SetReg1(pVBInfo->P3c4, 0x3D, data); /* diable auto-threshold */
1489 if (ModeNo > 0x13) {
1490 XGINew_SetReg1(pVBInfo->P3c4, 0x08, 0x34);
1491 data = XGINew_GetReg1(pVBInfo->P3c4, 0x09);
1493 XGINew_SetReg1(pVBInfo->P3c4, 0x09, data | 0x30);
1494 data = XGINew_GetReg1(pVBInfo->P3c4, 0x3D);
1496 XGINew_SetReg1(pVBInfo->P3c4, 0x3D, data);
1498 if (HwDeviceExtension->jChipType == XG27) {
1499 XGINew_SetReg1(pVBInfo->P3c4, 0x08, 0x0E);
1500 data = XGINew_GetReg1(pVBInfo->P3c4, 0x09);
1502 XGINew_SetReg1(pVBInfo->P3c4, 0x09, data | 0x20);
1504 XGINew_SetReg1(pVBInfo->P3c4, 0x08, 0xAE);
1505 data = XGINew_GetReg1(pVBInfo->P3c4, 0x09);
1507 XGINew_SetReg1(pVBInfo->P3c4, 0x09, data);
1511 if (HwDeviceExtension->jChipType == XG21)
1512 XGI_SetXG21FPBits(pVBInfo); /* Fix SR9[7:6] can't read back */
1515 static void XGI_SetVCLKState(struct xgi_hw_device_info *HwDeviceExtension,
1516 unsigned short ModeNo, unsigned short RefreshRateTableIndex,
1517 struct vb_device_info *pVBInfo)
1519 unsigned short data, data2 = 0;
1522 unsigned char index;
1527 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1529 VCLK = pVBInfo->VCLKData[index].CLOCK;
1532 data = XGINew_GetReg1(pVBInfo->P3c4, 0x32);
1535 data |= 0x0c; /* VCLK > 200 */
1537 if (HwDeviceExtension->jChipType >= XG20)
1538 data &= ~0x04; /* 2 pixel mode */
1540 XGINew_SetReg1(pVBInfo->P3c4, 0x32, data);
1542 if (HwDeviceExtension->jChipType < XG20) {
1543 data = XGINew_GetReg1(pVBInfo->P3c4, 0x1F);
1547 XGINew_SetReg1(pVBInfo->P3c4, 0x1F, data);
1550 /* Jong for Adavantech LCD ripple issue
1551 if ((VCLK >= 0) && (VCLK < 135))
1553 else if ((VCLK >= 135) && (VCLK < 160))
1555 else if ((VCLK >= 160) && (VCLK < 260))
1557 else if (VCLK > 260)
1562 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x07, 0xFC, data2);
1563 if (HwDeviceExtension->jChipType >= XG27)
1564 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x40, 0xFC, data2 & 0x03);
1568 static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension,
1569 unsigned short ModeNo, unsigned short ModeIdIndex,
1570 unsigned short RefreshRateTableIndex,
1571 struct vb_device_info *pVBInfo)
1573 unsigned short data, data2, data3, infoflag = 0, modeflag, resindex,
1576 if (ModeNo > 0x13) {
1577 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1579 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1581 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ModeFlag */
1583 if (XGINew_GetReg1(pVBInfo->P3d4, 0x31) & 0x01)
1584 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x1F, 0x3F, 0x00);
1593 if (ModeNo > 0x13) {
1594 if (pVBInfo->ModeType > 0x02) {
1596 data3 = pVBInfo->ModeType - ModeVGA;
1602 data &= InterlaceMode;
1607 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x06, ~0x3F, data2);
1608 /* XGINew_SetReg1(pVBInfo->P3c4,0x06,data2); */
1609 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
1611 xres = pVBInfo->StResInfo[resindex].HTotal;
1613 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
1616 if (infoflag & InterlaceMode) {
1619 else if (xres == 1280)
1623 data2 = data & 0x00FF;
1624 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x19, 0xFF, data2);
1625 data2 = (data & 0xFF00) >> 8;
1626 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x19, 0xFC, data2);
1628 if (modeflag & HalfDCLK)
1629 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x01, 0xF7, 0x08);
1633 if (modeflag & LineCompareOff)
1636 if (ModeNo > 0x13) {
1637 if (pVBInfo->ModeType == ModeEGA)
1641 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0F, ~0x48, data2);
1643 if (pVBInfo->ModeType != ModeText) {
1645 if (pVBInfo->ModeType != ModeEGA)
1648 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x21, 0x1F, data);
1650 XGI_SetVCLKState(HwDeviceExtension, ModeNo, RefreshRateTableIndex,
1653 /* if (modeflag&HalfDCLK) //030305 fix lowresolution bug */
1654 /* if (XGINew_IF_DEF_NEW_LOWRES) */
1655 /* XGI_VesaLowResolution(ModeNo, ModeIdIndex); //030305 fix lowresolution bug */
1657 data = XGINew_GetReg1(pVBInfo->P3d4, 0x31);
1659 if (HwDeviceExtension->jChipType == XG27) {
1664 XGINew_SetReg1(pVBInfo->P3d4, 0x52, data);
1665 XGINew_SetRegOR(pVBInfo->P3d4, 0x51, 0x10);
1666 } else if (HwDeviceExtension->jChipType >= XG20) {
1671 XGINew_SetReg1(pVBInfo->P3d4, 0x52, data);
1672 XGINew_SetReg1(pVBInfo->P3d4, 0x51, 0x02);
1678 XGINew_SetReg1(pVBInfo->P3d4, 0x52, data);
1684 void XGI_VesaLowResolution(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
1686 unsigned short modeflag;
1689 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1691 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
1693 if (ModeNo > 0x13) {
1694 if (modeflag & DoubleScanMode) {
1695 if (modeflag & HalfDCLK) {
1696 if (pVBInfo->VBType & VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
1697 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) {
1698 if (pVBInfo->VBInfo & SetInSlaveMode) {
1699 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x01, 0xf7, 0x00);
1700 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0f, 0x7f, 0x00);
1705 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0f, 0xff, 0x80);
1706 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x01, 0xf7, 0x00);
1711 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0f, 0x7f, 0x00);
1715 static void XGI_WriteDAC(unsigned short dl, unsigned short ah, unsigned short al,
1716 unsigned short dh, struct vb_device_info *pVBInfo)
1718 unsigned short temp, bh, bl;
1737 outb((unsigned short) dh, pVBInfo->P3c9);
1738 outb((unsigned short) bh, pVBInfo->P3c9);
1739 outb((unsigned short) bl, pVBInfo->P3c9);
1742 static void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex,
1743 struct vb_device_info *pVBInfo)
1745 unsigned short data, data2, time, i, j, k, m, n, o, si, di, bx, dl, al,
1746 ah, dh, *table = NULL;
1749 data = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
1751 data = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1753 data &= DACInfoFlag;
1757 table = XGINew_MDA_DAC;
1758 else if (data == 0x08)
1759 table = XGINew_CGA_DAC;
1760 else if (data == 0x10)
1761 table = XGINew_EGA_DAC;
1762 else if (data == 0x18) {
1764 table = XGINew_VGA_DAC;
1772 outb(0xFF, pVBInfo->P3c6);
1773 outb(0x00, pVBInfo->P3c8);
1775 for (i = 0; i < j; i++) {
1778 for (k = 0; k < 3; k++) {
1787 outb(data2, pVBInfo->P3c9);
1793 for (i = 16; i < 32; i++) {
1796 for (k = 0; k < 3; k++)
1797 outb(data, pVBInfo->P3c9);
1802 for (m = 0; m < 9; m++) {
1807 for (n = 0; n < 3; n++) {
1808 for (o = 0; o < 5; o++) {
1813 XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
1818 for (o = 0; o < 3; o++) {
1823 XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
1834 static void XGI_GetLVDSResInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
1835 struct vb_device_info *pVBInfo)
1837 unsigned short resindex, xres, yres, modeflag;
1840 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; /* si+St_ResInfo */
1842 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; /* si+Ext_ResInfo */
1844 /* if (ModeNo > 0x13) */
1845 /* modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; */
1847 /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; */
1850 resindex = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; /* si+St_ResInfo */
1852 resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; /* si+Ext_ResInfo */
1854 /* resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); */
1856 if (ModeNo <= 0x13) {
1857 xres = pVBInfo->StResInfo[resindex].HTotal;
1858 yres = pVBInfo->StResInfo[resindex].VTotal;
1860 xres = pVBInfo->ModeResInfo[resindex].HTotal;
1861 yres = pVBInfo->ModeResInfo[resindex].VTotal;
1863 if (ModeNo > 0x13) {
1864 if (modeflag & HalfDCLK)
1867 if (modeflag & DoubleScanMode)
1870 /* if (modeflag & Charx8Dot) */
1877 pVBInfo->VGAHDE = xres;
1878 pVBInfo->HDE = xres;
1879 pVBInfo->VGAVDE = yres;
1880 pVBInfo->VDE = yres;
1883 static void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo,
1884 unsigned short ModeIdIndex,
1885 unsigned short RefreshRateTableIndex,
1886 struct vb_device_info *pVBInfo)
1888 unsigned short i, tempdx, tempcx, tempbx, tempal, modeflag, table;
1890 struct XGI330_LCDDataTablStruct *tempdi = NULL;
1894 if (ModeNo <= 0x13) {
1895 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
1896 tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
1898 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1899 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
1902 tempal = tempal & 0x0f;
1904 if (tempbx <= 1) { /* ExpLink */
1905 if (ModeNo <= 0x13) {
1906 tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; /* find no Ext_CRT2CRTC2 */
1909 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
1912 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
1915 = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC2;
1918 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC2;
1922 tempal = (tempal >> 4);
1924 tempal = (tempal & 0x0f);
1927 tempcx = LCDLenList[tempbx]; /* mov cl,byte ptr cs:LCDLenList[bx] */
1929 if (pVBInfo->LCDInfo & EnableScalingLCD) { /* ScaleLCD */
1930 if ((tempbx == 5) || (tempbx) == 7)
1931 tempcx = LCDDesDataLen2;
1932 else if ((tempbx == 3) || (tempbx == 8))
1933 tempcx = LVDSDesDataLen2;
1935 /* mov di, word ptr cs:LCDDataList[bx] */
1936 /* tempdi = pVideoMemory[LCDDataList + tempbx * 2] | (pVideoMemory[LCDDataList + tempbx * 2 + 1] << 8); */
1940 tempdi = XGI_EPLLCDCRT1Ptr_H;
1943 tempdi = XGI_EPLLCDCRT1Ptr_V;
1946 tempdi = XGI_EPLLCDDataPtr;
1949 tempdi = XGI_EPLLCDDesDataPtr;
1952 tempdi = XGI_LCDDataTable;
1955 tempdi = XGI_LCDDesDataTable;
1958 tempdi = XGI_EPLCHLCDRegPtr;
1969 if (tempdi == NULL) /* OEMUtil */
1975 while (tempdi[i].PANELID != 0xff) {
1976 tempdx = pVBInfo->LCDResInfo;
1977 if (tempbx & 0x0080) { /* OEMUtil */
1978 tempbx &= (~0x0080);
1979 tempdx = pVBInfo->LCDTypeInfo;
1982 if (pVBInfo->LCDInfo & EnableScalingLCD)
1983 tempdx &= (~PanelResInfo);
1985 if (tempdi[i].PANELID == tempdx) {
1986 tempbx = tempdi[i].MASK;
1987 tempdx = pVBInfo->LCDInfo;
1989 if (ModeNo <= 0x13) /* alan 09/10/2003 */
1990 tempdx |= SetLCDStdMode;
1992 if (modeflag & HalfDCLK)
1993 tempdx |= SetLCDLowResolution;
1996 if (tempbx == tempdi[i].CAP)
2003 switch (tempdi[i].DATAPTR) {
2005 return &XGI_LVDSCRT11024x768_1_H[tempal];
2008 return &XGI_LVDSCRT11024x768_2_H[tempal];
2011 return &XGI_LVDSCRT11280x1024_1_H[tempal];
2014 return &XGI_LVDSCRT11280x1024_2_H[tempal];
2017 return &XGI_LVDSCRT11400x1050_1_H[tempal];
2020 return &XGI_LVDSCRT11400x1050_2_H[tempal];
2023 return &XGI_LVDSCRT11600x1200_1_H[tempal];
2026 return &XGI_LVDSCRT11024x768_1_Hx75[tempal];
2029 return &XGI_LVDSCRT11024x768_2_Hx75[tempal];
2032 return &XGI_LVDSCRT11280x1024_1_Hx75[tempal];
2035 return &XGI_LVDSCRT11280x1024_2_Hx75[tempal];
2040 } else if (table == 1) {
2041 switch (tempdi[i].DATAPTR) {
2043 return &XGI_LVDSCRT11024x768_1_V[tempal];
2046 return &XGI_LVDSCRT11024x768_2_V[tempal];
2049 return &XGI_LVDSCRT11280x1024_1_V[tempal];
2052 return &XGI_LVDSCRT11280x1024_2_V[tempal];
2055 return &XGI_LVDSCRT11400x1050_1_V[tempal];
2058 return &XGI_LVDSCRT11400x1050_2_V[tempal];
2061 return &XGI_LVDSCRT11600x1200_1_V[tempal];
2064 return &XGI_LVDSCRT11024x768_1_Vx75[tempal];
2067 return &XGI_LVDSCRT11024x768_2_Vx75[tempal];
2070 return &XGI_LVDSCRT11280x1024_1_Vx75[tempal];
2073 return &XGI_LVDSCRT11280x1024_2_Vx75[tempal];
2078 } else if (table == 2) {
2079 switch (tempdi[i].DATAPTR) {
2081 return &XGI_LVDS1024x768Data_1[tempal];
2084 return &XGI_LVDS1024x768Data_2[tempal];
2087 return &XGI_LVDS1280x1024Data_1[tempal];
2090 return &XGI_LVDS1280x1024Data_2[tempal];
2093 return &XGI_LVDS1400x1050Data_1[tempal];
2096 return &XGI_LVDS1400x1050Data_2[tempal];
2099 return &XGI_LVDS1600x1200Data_1[tempal];
2102 return &XGI_LVDSNoScalingData[tempal];
2105 return &XGI_LVDS1024x768Data_1x75[tempal];
2108 return &XGI_LVDS1024x768Data_2x75[tempal];
2111 return &XGI_LVDS1280x1024Data_1x75[tempal];
2114 return &XGI_LVDS1280x1024Data_2x75[tempal];
2117 return &XGI_LVDSNoScalingDatax75[tempal];
2122 } else if (table == 3) {
2123 switch (tempdi[i].DATAPTR) {
2125 return &XGI_LVDS1024x768Des_1[tempal];
2128 return &XGI_LVDS1024x768Des_3[tempal];
2131 return &XGI_LVDS1024x768Des_2[tempal];
2134 return &XGI_LVDS1280x1024Des_1[tempal];
2137 return &XGI_LVDS1280x1024Des_2[tempal];
2140 return &XGI_LVDS1400x1050Des_1[tempal];
2143 return &XGI_LVDS1400x1050Des_2[tempal];
2146 return &XGI_LVDS1600x1200Des_1[tempal];
2149 return &XGI_LVDSNoScalingDesData[tempal];
2152 return &XGI_LVDS1024x768Des_1x75[tempal];
2155 return &XGI_LVDS1024x768Des_3x75[tempal];
2158 return &XGI_LVDS1024x768Des_2x75[tempal];
2161 return &XGI_LVDS1280x1024Des_1x75[tempal];
2164 return &XGI_LVDS1280x1024Des_2x75[tempal];
2167 return &XGI_LVDSNoScalingDesDatax75[tempal];
2172 } else if (table == 4) {
2173 switch (tempdi[i].DATAPTR) {
2175 return &XGI_ExtLCD1024x768Data[tempal];
2178 return &XGI_StLCD1024x768Data[tempal];
2181 return &XGI_CetLCD1024x768Data[tempal];
2184 return &XGI_ExtLCD1280x1024Data[tempal];
2187 return &XGI_StLCD1280x1024Data[tempal];
2190 return &XGI_CetLCD1280x1024Data[tempal];
2193 return &XGI_ExtLCD1400x1050Data[tempal];
2196 return &XGI_StLCD1400x1050Data[tempal];
2199 return &XGI_CetLCD1400x1050Data[tempal];
2202 return &XGI_ExtLCD1600x1200Data[tempal];
2205 return &XGI_StLCD1600x1200Data[tempal];
2208 return &XGI_NoScalingData[tempal];
2211 return &XGI_ExtLCD1024x768x75Data[tempal];
2214 return &XGI_ExtLCD1024x768x75Data[tempal];
2217 return &XGI_CetLCD1024x768x75Data[tempal];
2220 return &XGI_ExtLCD1280x1024x75Data[tempal];
2223 return &XGI_StLCD1280x1024x75Data[tempal];
2226 return &XGI_CetLCD1280x1024x75Data[tempal];
2229 return &XGI_NoScalingDatax75[tempal];
2234 } else if (table == 5) {
2235 switch (tempdi[i].DATAPTR) {
2237 return &XGI_ExtLCDDes1024x768Data[tempal];
2240 return &XGI_StLCDDes1024x768Data[tempal];
2243 return &XGI_CetLCDDes1024x768Data[tempal];
2246 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
2248 return &XGI_ExtLCDDLDes1280x1024Data[tempal];
2250 return &XGI_ExtLCDDes1280x1024Data[tempal];
2253 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
2255 return &XGI_StLCDDLDes1280x1024Data[tempal];
2257 return &XGI_StLCDDes1280x1024Data[tempal];
2260 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
2262 return &XGI_CetLCDDLDes1280x1024Data[tempal];
2264 return &XGI_CetLCDDes1280x1024Data[tempal];
2267 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
2269 return &XGI_ExtLCDDLDes1400x1050Data[tempal];
2271 return &XGI_ExtLCDDes1400x1050Data[tempal];
2274 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
2276 return &XGI_StLCDDLDes1400x1050Data[tempal];
2278 return &XGI_StLCDDes1400x1050Data[tempal];
2281 return &XGI_CetLCDDes1400x1050Data[tempal];
2284 return &XGI_CetLCDDes1400x1050Data2[tempal];
2287 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
2289 return &XGI_ExtLCDDLDes1600x1200Data[tempal];
2291 return &XGI_ExtLCDDes1600x1200Data[tempal];
2294 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
2296 return &XGI_StLCDDLDes1600x1200Data[tempal];
2298 return &XGI_StLCDDes1600x1200Data[tempal];
2301 return &XGI_NoScalingDesData[tempal];
2304 return &XGI_ExtLCDDes1024x768x75Data[tempal];
2307 return &XGI_StLCDDes1024x768x75Data[tempal];
2310 return &XGI_CetLCDDes1024x768x75Data[tempal];
2313 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
2315 return &XGI_ExtLCDDLDes1280x1024x75Data[tempal];
2317 return &XGI_ExtLCDDes1280x1024x75Data[tempal];
2320 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
2322 return &XGI_StLCDDLDes1280x1024x75Data[tempal];
2324 return &XGI_StLCDDes1280x1024x75Data[tempal];
2327 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
2329 return &XGI_CetLCDDLDes1280x1024x75Data[tempal];
2331 return &XGI_CetLCDDes1280x1024x75Data[tempal];
2334 return &XGI_NoScalingDesDatax75[tempal];
2339 } else if (table == 6) {
2340 switch (tempdi[i].DATAPTR) {
2342 return &XGI_CH7017LV1024x768[tempal];
2345 return &XGI_CH7017LV1400x1050[tempal];
2354 static void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo,
2355 unsigned short ModeIdIndex,
2356 unsigned short RefreshRateTableIndex,
2357 struct vb_device_info *pVBInfo)
2359 unsigned short i, tempdx, tempbx, tempal, modeflag, table;
2360 struct XGI330_TVDataTablStruct *tempdi = NULL;
2364 if (ModeNo <= 0x13) {
2365 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
2366 tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
2368 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2369 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
2372 tempal = tempal & 0x3f;
2377 tempdi = NULL; /*EPLCHTVCRT1Ptr_H;*/
2378 if (pVBInfo->IF_DEF_CH7007 == 1)
2379 tempdi = XGI_EPLCHTVCRT1Ptr;
2383 tempdi = NULL; /*EPLCHTVCRT1Ptr_V;*/
2384 if (pVBInfo->IF_DEF_CH7007 == 1)
2385 tempdi = XGI_EPLCHTVCRT1Ptr;
2389 tempdi = XGI_EPLCHTVDataPtr;
2395 tempdi = XGI_TVDataTable;
2401 tempdi = XGI_EPLCHTVRegPtr;
2407 if (tempdi == NULL) /* OEMUtil */
2410 tempdx = pVBInfo->TVInfo;
2412 if (pVBInfo->VBInfo & SetInSlaveMode)
2413 tempdx = tempdx | SetTVLockMode;
2415 if (modeflag & HalfDCLK)
2416 tempdx = tempdx | SetTVLowResolution;
2420 while (tempdi[i].MASK != 0xffff) {
2421 if ((tempdx & tempdi[i].MASK) == tempdi[i].CAP)
2426 if (table == 0x00) { /* 07/05/22 */
2427 } else if (table == 0x01) {
2428 } else if (table == 0x04) {
2429 switch (tempdi[i].DATAPTR) {
2431 return &XGI_ExtPALData[tempal];
2434 return &XGI_ExtNTSCData[tempal];
2437 return &XGI_StPALData[tempal];
2440 return &XGI_StNTSCData[tempal];
2443 return &XGI_ExtHiTVData[tempal];
2446 return &XGI_St2HiTVData[tempal];
2449 return &XGI_ExtYPbPr525iData[tempal];
2452 return &XGI_ExtYPbPr525pData[tempal];
2455 return &XGI_ExtYPbPr750pData[tempal];
2458 return &XGI_StYPbPr525iData[tempal];
2461 return &XGI_StYPbPr525pData[tempal];
2464 return &XGI_StYPbPr750pData[tempal];
2466 case 12: /* avoid system hang */
2467 return &XGI_ExtNTSCData[tempal];
2470 return &XGI_St1HiTVData[tempal];
2475 } else if (table == 0x02) {
2476 switch (tempdi[i].DATAPTR) {
2478 return &XGI_CHTVUNTSCData[tempal];
2481 return &XGI_CHTVONTSCData[tempal];
2484 return &XGI_CHTVUPALData[tempal];
2487 return &XGI_CHTVOPALData[tempal];
2492 } else if (table == 0x06) {
2497 static void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex,
2498 unsigned short RefreshRateTableIndex,
2499 struct vb_device_info *pVBInfo)
2501 unsigned short tempbx;
2502 struct XGI330_LVDSDataStruct *LCDPtr = NULL;
2503 struct XGI330_CHTVDataStruct *TVPtr = NULL;
2507 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
2508 LCDPtr = (struct XGI330_LVDSDataStruct *) XGI_GetLcdPtr(tempbx,
2509 ModeNo, ModeIdIndex, RefreshRateTableIndex,
2511 pVBInfo->VGAHT = LCDPtr->VGAHT;
2512 pVBInfo->VGAVT = LCDPtr->VGAVT;
2513 pVBInfo->HT = LCDPtr->LCDHT;
2514 pVBInfo->VT = LCDPtr->LCDVT;
2516 if (pVBInfo->IF_DEF_CH7017 == 1) {
2517 if (pVBInfo->VBInfo & SetCRT2ToTV) {
2518 TVPtr = (struct XGI330_CHTVDataStruct *) XGI_GetTVPtr(
2519 tempbx, ModeNo, ModeIdIndex,
2520 RefreshRateTableIndex, pVBInfo);
2521 pVBInfo->VGAHT = TVPtr->VGAHT;
2522 pVBInfo->VGAVT = TVPtr->VGAVT;
2523 pVBInfo->HT = TVPtr->LCDHT;
2524 pVBInfo->VT = TVPtr->LCDVT;
2528 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
2529 if (!(pVBInfo->LCDInfo & (SetLCDtoNonExpanding
2530 | EnableScalingLCD))) {
2531 if ((pVBInfo->LCDResInfo == Panel1024x768)
2532 || (pVBInfo->LCDResInfo
2533 == Panel1024x768x75)) {
2534 pVBInfo->HDE = 1024;
2536 } else if ((pVBInfo->LCDResInfo == Panel1280x1024)
2537 || (pVBInfo->LCDResInfo
2538 == Panel1280x1024x75)) {
2539 pVBInfo->HDE = 1280;
2540 pVBInfo->VDE = 1024;
2541 } else if (pVBInfo->LCDResInfo == Panel1400x1050) {
2542 pVBInfo->HDE = 1400;
2543 pVBInfo->VDE = 1050;
2545 pVBInfo->HDE = 1600;
2546 pVBInfo->VDE = 1200;
2552 static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex,
2553 unsigned short RefreshRateTableIndex,
2554 struct xgi_hw_device_info *HwDeviceExtension,
2555 struct vb_device_info *pVBInfo)
2557 unsigned char index;
2558 unsigned short tempbx, i;
2559 struct XGI_LVDSCRT1HDataStruct *LCDPtr = NULL;
2560 struct XGI_LVDSCRT1VDataStruct *LCDPtr1 = NULL;
2561 /* struct XGI330_CHTVDataStruct *TVPtr = NULL; */
2562 struct XGI_CH7007TV_TimingHStruct *CH7007TV_TimingHPtr = NULL;
2563 struct XGI_CH7007TV_TimingVStruct *CH7007TV_TimingVPtr = NULL;
2566 index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
2568 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
2570 index = index & IndexMask;
2572 if ((pVBInfo->IF_DEF_ScaleLCD == 0) || ((pVBInfo->IF_DEF_ScaleLCD == 1)
2573 && (!(pVBInfo->LCDInfo & EnableScalingLCD)))) {
2576 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
2578 = (struct XGI_LVDSCRT1HDataStruct *) XGI_GetLcdPtr(
2581 RefreshRateTableIndex,
2584 for (i = 0; i < 8; i++)
2585 pVBInfo->TimingH[0].data[i] = LCDPtr[0].Reg[i];
2588 if (pVBInfo->IF_DEF_CH7007 == 1) {
2589 if (pVBInfo->VBInfo & SetCRT2ToTV) {
2591 = (struct XGI_CH7007TV_TimingHStruct *) XGI_GetTVPtr(
2595 RefreshRateTableIndex,
2598 for (i = 0; i < 8; i++)
2599 pVBInfo->TimingH[0].data[i]
2600 = CH7007TV_TimingHPtr[0].data[i];
2604 /* if (pVBInfo->IF_DEF_CH7017 == 1) {
2605 if (pVBInfo->VBInfo & SetCRT2ToTV)
2606 TVPtr = (struct XGI330_CHTVDataStruct *)XGI_GetTVPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2610 XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension);
2612 if (pVBInfo->IF_DEF_CH7007 == 1) {
2613 XGINew_SetReg1(pVBInfo->P3c4, 0x2E,
2614 CH7007TV_TimingHPtr[0].data[8]);
2615 XGINew_SetReg1(pVBInfo->P3c4, 0x2F,
2616 CH7007TV_TimingHPtr[0].data[9]);
2621 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
2623 = (struct XGI_LVDSCRT1VDataStruct *) XGI_GetLcdPtr(
2626 RefreshRateTableIndex,
2628 for (i = 0; i < 7; i++)
2629 pVBInfo->TimingV[0].data[i] = LCDPtr1[0].Reg[i];
2632 if (pVBInfo->IF_DEF_CH7007 == 1) {
2633 if (pVBInfo->VBInfo & SetCRT2ToTV) {
2635 = (struct XGI_CH7007TV_TimingVStruct *) XGI_GetTVPtr(
2639 RefreshRateTableIndex,
2642 for (i = 0; i < 7; i++)
2643 pVBInfo->TimingV[0].data[i]
2644 = CH7007TV_TimingVPtr[0].data[i];
2647 /* if (pVBInfo->IF_DEF_CH7017 == 1) {
2648 if (pVBInfo->VBInfo & SetCRT2ToTV)
2649 TVPtr = (struct XGI330_CHTVDataStruct *)XGI_GetTVPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2653 XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo);
2655 if (pVBInfo->IF_DEF_CH7007 == 1) {
2656 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x33, ~0x01,
2657 CH7007TV_TimingVPtr[0].data[7] & 0x01);
2658 XGINew_SetReg1(pVBInfo->P3c4, 0x34,
2659 CH7007TV_TimingVPtr[0].data[8]);
2660 XGINew_SetReg1(pVBInfo->P3c4, 0x3F,
2661 CH7007TV_TimingVPtr[0].data[9]);
2667 static unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo)
2669 unsigned char tempal, tempah, tempbl, i;
2671 tempah = XGINew_GetReg1(pVBInfo->P3d4, 0x36);
2672 tempal = tempah & 0x0F;
2673 tempah = tempah & 0xF0;
2675 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
2677 while (tempbl != 0xFF) {
2678 if (tempbl & 0x80) { /* OEMUtil */
2680 tempbl = tempbl & ~(0x80);
2683 if (tempal == tempbl)
2688 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
2694 static unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo)
2696 unsigned short tempah, tempal, tempbl, i;
2698 tempal = pVBInfo->LCDResInfo;
2699 tempah = pVBInfo->LCDTypeInfo;
2702 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
2704 while (tempbl != 0xFF) {
2705 if ((tempbl & 0x80) && (tempbl != 0x80)) {
2710 if (tempal == tempbl)
2714 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
2717 if (tempbl == 0xFF) {
2718 pVBInfo->LCDResInfo = Panel1024x768;
2719 pVBInfo->LCDTypeInfo = 0;
2726 static void XGI_GetLCDSync(unsigned short *HSyncWidth, unsigned short *VSyncWidth,
2727 struct vb_device_info *pVBInfo)
2729 unsigned short Index;
2731 Index = XGI_GetLCDCapPtr(pVBInfo);
2732 *HSyncWidth = pVBInfo->LCDCapList[Index].LCD_HSyncWidth;
2733 *VSyncWidth = pVBInfo->LCDCapList[Index].LCD_VSyncWidth;
2738 static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
2739 unsigned short RefreshRateTableIndex,
2740 struct vb_device_info *pVBInfo)
2742 unsigned short tempbx, tempax, tempcx, tempdx, push1, push2, modeflag;
2743 unsigned long temp, temp1, temp2, temp3, push3;
2744 struct XGI330_LCDDataDesStruct *LCDPtr = NULL;
2745 struct XGI330_LCDDataDesStruct2 *LCDPtr1 = NULL;
2748 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2750 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
2752 if (!(pVBInfo->SetFlag & Win9xDOSMode)) {
2753 if ((pVBInfo->IF_DEF_CH7017 == 0) || (pVBInfo->VBInfo
2754 & (SetCRT2ToLCD | SetCRT2ToLCDA))) {
2755 if (pVBInfo->IF_DEF_OEMUtil == 1) {
2758 = (struct XGI330_LCDDataDesStruct *) XGI_GetLcdPtr(
2762 RefreshRateTableIndex,
2766 if ((pVBInfo->IF_DEF_OEMUtil == 0) || (LCDPtr == NULL)) {
2768 if (pVBInfo->LCDInfo & EnableScalingLCD)
2770 = (struct XGI330_LCDDataDesStruct2 *) XGI_GetLcdPtr(
2774 RefreshRateTableIndex,
2778 = (struct XGI330_LCDDataDesStruct *) XGI_GetLcdPtr(
2782 RefreshRateTableIndex,
2786 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
2791 if ((pVBInfo->LCDResInfo == Panel1024x768)
2792 || (pVBInfo->LCDResInfo
2793 == Panel1024x768x75)) {
2796 } else if ((pVBInfo->LCDResInfo == Panel1280x1024)
2797 || (pVBInfo->LCDResInfo
2798 == Panel1280x1024x75)) {
2801 } else if (pVBInfo->LCDResInfo == Panel1400x1050) {
2809 if (pVBInfo->LCDInfo & SetLCDtoNonExpanding) {
2810 pVBInfo->HDE = tempax;
2811 pVBInfo->VDE = tempbx;
2812 pVBInfo->VGAHDE = tempax;
2813 pVBInfo->VGAVDE = tempbx;
2816 if ((pVBInfo->IF_DEF_ScaleLCD == 1)
2817 && (pVBInfo->LCDInfo & EnableScalingLCD)) {
2818 tempax = pVBInfo->HDE;
2819 tempbx = pVBInfo->VDE;
2822 tempax = pVBInfo->HT;
2824 if (pVBInfo->LCDInfo & EnableScalingLCD)
2825 tempbx = LCDPtr1->LCDHDES;
2827 tempbx = LCDPtr->LCDHDES;
2829 tempcx = pVBInfo->HDE;
2830 tempbx = tempbx & 0x0fff;
2833 if (tempcx >= tempax)
2836 XGINew_SetReg1(pVBInfo->Part1Port, 0x1A, tempbx & 0x07);
2838 tempcx = tempcx >> 3;
2839 tempbx = tempbx >> 3;
2841 XGINew_SetReg1(pVBInfo->Part1Port, 0x16,
2842 (unsigned short) (tempbx & 0xff));
2843 XGINew_SetReg1(pVBInfo->Part1Port, 0x17,
2844 (unsigned short) (tempcx & 0xff));
2846 tempax = pVBInfo->HT;
2848 if (pVBInfo->LCDInfo & EnableScalingLCD)
2849 tempbx = LCDPtr1->LCDHRS;
2851 tempbx = LCDPtr->LCDHRS;
2855 if (pVBInfo->LCDInfo & EnableScalingLCD)
2856 tempcx = LCDPtr1->LCDHSync;
2860 if (tempcx >= tempax)
2863 tempax = tempbx & 0x07;
2864 tempax = tempax >> 5;
2865 tempcx = tempcx >> 3;
2866 tempbx = tempbx >> 3;
2871 XGINew_SetReg1(pVBInfo->Part1Port, 0x15, tempax);
2872 XGINew_SetReg1(pVBInfo->Part1Port, 0x14,
2873 (unsigned short) (tempbx & 0xff));
2875 tempax = pVBInfo->VT;
2876 if (pVBInfo->LCDInfo & EnableScalingLCD)
2877 tempbx = LCDPtr1->LCDVDES;
2879 tempbx = LCDPtr->LCDVDES;
2880 tempcx = pVBInfo->VDE;
2882 tempbx = tempbx & 0x0fff;
2884 if (tempcx >= tempax)
2887 XGINew_SetReg1(pVBInfo->Part1Port, 0x1b,
2888 (unsigned short) (tempbx & 0xff));
2889 XGINew_SetReg1(pVBInfo->Part1Port, 0x1c,
2890 (unsigned short) (tempcx & 0xff));
2892 tempbx = (tempbx >> 8) & 0x07;
2893 tempcx = (tempcx >> 8) & 0x07;
2895 XGINew_SetReg1(pVBInfo->Part1Port, 0x1d,
2896 (unsigned short) ((tempcx << 3)
2899 tempax = pVBInfo->VT;
2900 if (pVBInfo->LCDInfo & EnableScalingLCD)
2901 tempbx = LCDPtr1->LCDVRS;
2903 tempbx = LCDPtr->LCDVRS;
2905 /* tempbx = tempbx >> 4; */
2908 if (pVBInfo->LCDInfo & EnableScalingLCD)
2909 tempcx = LCDPtr1->LCDVSync;
2912 if (tempcx >= tempax)
2915 XGINew_SetReg1(pVBInfo->Part1Port, 0x18,
2916 (unsigned short) (tempbx & 0xff));
2917 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, ~0x0f,
2918 (unsigned short) (tempcx & 0x0f));
2920 tempax = ((tempbx >> 8) & 0x07) << 3;
2922 tempbx = pVBInfo->VGAVDE;
2923 if (tempbx != pVBInfo->VDE)
2926 if (pVBInfo->LCDInfo & EnableLVDSDDA)
2929 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1a, 0x07,
2932 tempcx = pVBInfo->VGAVT;
2933 tempbx = pVBInfo->VDE;
2934 tempax = pVBInfo->VGAVDE;
2937 temp = tempax; /* 0430 ylshieh */
2938 temp1 = (temp << 18) / tempbx;
2940 tempdx = (unsigned short) ((temp << 18) % tempbx);
2948 XGINew_SetReg1(pVBInfo->Part1Port, 0x37,
2949 (unsigned short) (temp2 & 0xff));
2950 XGINew_SetReg1(pVBInfo->Part1Port, 0x36,
2951 (unsigned short) ((temp2 >> 8) & 0xff));
2953 tempbx = (unsigned short) (temp2 >> 16);
2954 tempax = tempbx & 0x03;
2956 tempbx = pVBInfo->VGAVDE;
2957 if (tempbx == pVBInfo->VDE)
2960 XGINew_SetReg1(pVBInfo->Part1Port, 0x35, tempax);
2962 if (pVBInfo->VBType & VB_XGI301C) {
2964 XGINew_SetReg1(pVBInfo->Part4Port, 0x3c,
2965 (unsigned short) (temp2 & 0xff));
2966 XGINew_SetReg1(pVBInfo->Part4Port, 0x3b,
2967 (unsigned short) ((temp2 >> 8)
2969 tempbx = (unsigned short) (temp2 >> 16);
2970 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x3a,
2972 (unsigned short) ((tempbx
2975 tempcx = pVBInfo->VGAVDE;
2976 if (tempcx == pVBInfo->VDE)
2977 XGINew_SetRegANDOR(pVBInfo->Part4Port,
2980 XGINew_SetRegANDOR(pVBInfo->Part4Port,
2984 tempcx = pVBInfo->VGAHDE;
2985 tempbx = pVBInfo->HDE;
2987 temp1 = tempcx << 16;
2989 tempax = (unsigned short) (temp1 / tempbx);
2991 if ((tempbx & 0xffff) == (tempcx & 0xffff))
2995 temp1 = pVBInfo->VGAHDE << 16;
2998 temp3 = temp3 << 16;
3001 temp3 = (temp3 & 0xffff0000) + (temp1 & 0xffff);
3003 tempax = (unsigned short) (temp3 & 0xff);
3004 XGINew_SetReg1(pVBInfo->Part1Port, 0x1f, tempax);
3006 temp1 = pVBInfo->VGAVDE << 18;
3007 temp1 = temp1 / push3;
3008 tempbx = (unsigned short) (temp1 & 0xffff);
3010 if (pVBInfo->LCDResInfo == Panel1024x768)
3013 tempax = ((tempbx >> 8) & 0xff) << 3;
3014 tempax |= (unsigned short) ((temp3 >> 8) & 0x07);
3015 XGINew_SetReg1(pVBInfo->Part1Port, 0x20,
3016 (unsigned short) (tempax & 0xff));
3017 XGINew_SetReg1(pVBInfo->Part1Port, 0x21,
3018 (unsigned short) (tempbx & 0xff));
3020 temp3 = temp3 >> 16;
3022 if (modeflag & HalfDCLK)
3025 XGINew_SetReg1(pVBInfo->Part1Port, 0x22,
3026 (unsigned short) ((temp3 >> 8) & 0xff));
3027 XGINew_SetReg1(pVBInfo->Part1Port, 0x23,
3028 (unsigned short) (temp3 & 0xff));
3033 /* --------------------------------------------------------------------- */
3034 /* Function : XGI_GETLCDVCLKPtr */
3036 /* Output : al -> VCLK Index */
3038 /* --------------------------------------------------------------------- */
3039 static void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1,
3040 struct vb_device_info *pVBInfo)
3042 unsigned short index;
3044 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
3045 if (pVBInfo->IF_DEF_ScaleLCD == 1) {
3046 if (pVBInfo->LCDInfo & EnableScalingLCD)
3050 /* index = XGI_GetLCDCapPtr(pVBInfo); */
3051 index = XGI_GetLCDCapPtr1(pVBInfo);
3053 if (pVBInfo->VBInfo & SetCRT2ToLCD) { /* LCDB */
3054 *di_0 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData1;
3055 *di_1 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData2;
3057 *di_0 = pVBInfo->LCDCapList[index].LCDA_VCLKData1;
3058 *di_1 = pVBInfo->LCDCapList[index].LCDA_VCLKData2;
3064 static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex,
3065 unsigned short ModeNo, unsigned short ModeIdIndex,
3066 struct vb_device_info *pVBInfo)
3069 unsigned short index, modeflag;
3070 unsigned short tempbx;
3071 unsigned char tempal;
3072 unsigned char *CHTVVCLKPtr = NULL;
3075 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
3077 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
3079 if ((pVBInfo->SetFlag & ProgrammingCRT2) && (!(pVBInfo->LCDInfo
3080 & EnableScalingLCD))) { /* {LCDA/LCDB} */
3081 index = XGI_GetLCDCapPtr(pVBInfo);
3082 tempal = pVBInfo->LCDCapList[index].LCD_VCLK;
3084 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))
3088 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
3089 | VB_XGI302LV | VB_XGI301C)) {
3090 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
3091 tempal = HiTVVCLKDIV2;
3092 if (!(pVBInfo->TVInfo & RPLLDIV2XO))
3094 if (pVBInfo->TVInfo & TVSimuMode) {
3095 tempal = HiTVSimuVCLK;
3096 if (!(modeflag & Charx8Dot))
3097 tempal = HiTVTextVCLK;
3103 if (pVBInfo->TVInfo & SetYPbPrMode750p) {
3104 tempal = YPbPr750pVCLK;
3108 if (pVBInfo->TVInfo & SetYPbPrMode525p) {
3109 tempal = YPbPr525pVCLK;
3113 tempal = NTSC1024VCLK;
3115 if (!(pVBInfo->TVInfo & NTSC1024x768)) {
3116 tempal = TVVCLKDIV2;
3117 if (!(pVBInfo->TVInfo & RPLLDIV2XO))
3121 if (pVBInfo->VBInfo & SetCRT2ToTV)
3124 /* else if ((pVBInfo->IF_DEF_CH7017==1)&&(pVBInfo->VBType&VB_CH7017)) {
3126 *tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
3128 *tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
3129 *tempal = *tempal & 0x1F;
3131 if (pVBInfo->TVInfo & SetPALTV)
3132 tempbx = tempbx + 2;
3133 if (pVBInfo->TVInfo & SetCHTVOverScan)
3135 tempbx = tempbx << 1;
3139 if ((pVBInfo->IF_DEF_CH7007 == 1) && (pVBInfo->VBType & VB_CH7007)) { /* [Billy] 07/05/08 CH7007 */
3140 /* VideoDebugPrint((0, "XGI_GetVCLKPtr: pVBInfo->IF_DEF_CH7007==1\n")); */
3141 if ((pVBInfo->VBInfo & SetCRT2ToTV)) {
3142 if (ModeNo <= 0x13) {
3144 = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
3147 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
3150 tempal = tempal & 0x0F;
3153 if (pVBInfo->TVInfo & SetPALTV)
3154 tempbx = tempbx + 2;
3156 if (pVBInfo->TVInfo & SetCHTVOverScan)
3159 /** tempbx = tempbx << 1; CH7007 ? **/
3161 /* [Billy]07/05/29 CH7007 */
3162 if (pVBInfo->IF_DEF_CH7007 == 1) {
3165 CHTVVCLKPtr = XGI7007_CHTVVCLKUNTSC;
3168 CHTVVCLKPtr = XGI7007_CHTVVCLKONTSC;
3171 CHTVVCLKPtr = XGI7007_CHTVVCLKUPAL;
3174 CHTVVCLKPtr = XGI7007_CHTVVCLKOPAL;
3184 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC;
3187 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC;
3190 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL;
3193 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL;
3201 tempal = CHTVVCLKPtr[tempal];
3207 tempal = (unsigned char) inb((pVBInfo->P3ca + 0x02));
3208 tempal = tempal >> 2;
3211 if ((pVBInfo->LCDInfo & EnableScalingLCD) && (modeflag & Charx8Dot)) /* for Dot8 Scaling LCD */
3212 tempal = tempal ^ tempal; /* ; set to VCLK25MHz always */
3217 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
3221 static void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0,
3222 unsigned char *di_1, struct vb_device_info *pVBInfo)
3224 if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 2007/05/16 */
3225 /* VideoDebugPrint((0, "XGI_GetVCLKLen: pVBInfo->IF_DEF_CH7007==1\n")); */
3226 *di_0 = (unsigned char) XGI_CH7007VCLKData[tempal].SR2B;
3227 *di_1 = (unsigned char) XGI_CH7007VCLKData[tempal].SR2C;
3228 } else if (pVBInfo->VBType & (VB_XGI301 | VB_XGI301B | VB_XGI302B
3229 | VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
3230 if ((!(pVBInfo->VBInfo & SetCRT2ToLCDA)) && (pVBInfo->SetFlag
3231 & ProgrammingCRT2)) {
3232 *di_0 = (unsigned char) XGI_VBVCLKData[tempal].SR2B;
3233 *di_1 = XGI_VBVCLKData[tempal].SR2C;
3236 *di_0 = XGI_VCLKData[tempal].SR2B;
3237 *di_1 = XGI_VCLKData[tempal].SR2C;
3241 static void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex,
3242 unsigned short RefreshRateTableIndex,
3243 struct vb_device_info *pVBInfo)
3245 unsigned char di_0, di_1, tempal;
3248 tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex,
3250 XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo);
3251 XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo);
3253 for (i = 0; i < 4; i++) {
3254 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x31, ~0x30,
3255 (unsigned short) (0x10 * i));
3256 if (pVBInfo->IF_DEF_CH7007 == 1) {
3257 XGINew_SetReg1(pVBInfo->P3c4, 0x2b, di_0);
3258 XGINew_SetReg1(pVBInfo->P3c4, 0x2c, di_1);
3259 } else if ((!(pVBInfo->VBInfo & SetCRT2ToLCDA))
3260 && (!(pVBInfo->VBInfo & SetInSlaveMode))) {
3261 XGINew_SetReg1(pVBInfo->P3c4, 0x2e, di_0);
3262 XGINew_SetReg1(pVBInfo->P3c4, 0x2f, di_1);
3264 XGINew_SetReg1(pVBInfo->P3c4, 0x2b, di_0);
3265 XGINew_SetReg1(pVBInfo->P3c4, 0x2c, di_1);
3270 static void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension,
3271 struct vb_device_info *pVBInfo)
3273 unsigned short tempcl, tempch, temp, tempbl, tempax;
3275 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
3276 | VB_XGI302LV | VB_XGI301C)) {
3279 temp = XGINew_GetReg1(pVBInfo->P3c4, 0x01);
3281 if (!(temp & 0x20)) {
3282 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x17);
3284 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x53);
3286 tempcl |= ActiveCRT1;
3290 temp = XGINew_GetReg1(pVBInfo->Part1Port, 0x2e);
3293 if (!(temp == 0x08)) {
3294 tempax = XGINew_GetReg1(pVBInfo->Part1Port, 0x13); /* Check ChannelA by Part1_13 [2003/10/03] */
3296 tempcl = tempcl | ActiveLCD;
3300 if (!(tempcl & ActiveLCD))
3302 tempcl |= ActiveCRT2;
3305 tempcl |= ActiveLCD;
3308 temp = XGINew_GetReg1(pVBInfo->Part2Port, 0x00);
3311 tempch |= ActiveAVideo;
3314 tempch |= ActiveSVideo;
3317 tempch |= ActiveSCART;
3319 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
3321 tempch |= ActiveHiTV;
3324 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
3325 temp = XGINew_GetReg1(
3330 tempch |= ActiveYPbPr;
3338 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x3d);
3339 if (tempcl & ActiveLCD) {
3340 if ((pVBInfo->SetFlag & ReserveTVOption)) {
3341 if (temp & ActiveTV)
3346 tempbl = ~ModeSwitchStatus;
3347 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x3d, tempbl, temp);
3349 if (!(pVBInfo->SetFlag & ReserveTVOption))
3350 XGINew_SetReg1(pVBInfo->P3d4, 0x3e, tempch);
3356 void XGI_GetVGAType(struct xgi_hw_device_info *HwDeviceExtension,
3357 struct vb_device_info *pVBInfo)
3360 if ( HwDeviceExtension->jChipType >= XG20 ) {
3361 pVBInfo->Set_VGAType = XG20;
3363 pVBInfo->Set_VGAType = VGA_XGI340;
3366 pVBInfo->Set_VGAType = HwDeviceExtension->jChipType;
3369 void XGI_GetVBType(struct vb_device_info *pVBInfo)
3371 unsigned short flag, tempbx, tempah;
3373 if (pVBInfo->IF_DEF_CH7007 == 1) {
3374 pVBInfo->VBType = VB_CH7007;
3377 if (pVBInfo->IF_DEF_LVDS == 0) {
3378 tempbx = VB_XGI302B;
3379 flag = XGINew_GetReg1(pVBInfo->Part4Port, 0x00);
3382 flag = XGINew_GetReg1(pVBInfo->Part4Port, 0x01);
3384 tempbx = VB_XGI301B;
3386 tempbx = VB_XGI301C;
3388 tempbx = VB_XGI301LV;
3390 tempbx = VB_XGI302LV;
3402 if (tempbx & (VB_XGI301B | VB_XGI302B)) {
3403 flag = XGINew_GetReg1(
3408 tempbx = tempbx | VB_NoLCD;
3412 pVBInfo->VBType = tempbx;
3415 else if (pVBInfo->IF_DEF_CH7017 == 1)
3416 pVBInfo->VBType = VB_CH7017;
3418 pVBInfo->VBType = VB_LVDS_NS;
3423 void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
3424 struct xgi_hw_device_info *HwDeviceExtension,
3425 struct vb_device_info *pVBInfo)
3427 unsigned short tempax, push, tempbx, temp, modeflag;
3430 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
3432 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3434 pVBInfo->SetFlag = 0;
3435 pVBInfo->ModeType = modeflag & ModeInfoFlag;
3438 if (pVBInfo->VBType & 0xFFFF) {
3439 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x30); /* Check Display Device */
3440 tempbx = tempbx | temp;
3441 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x31);
3445 tempbx = tempbx | tempax;
3446 temp = (SetCRT2ToDualEdge | SetCRT2ToYPbPr | SetCRT2ToLCDA
3447 | SetInSlaveMode | DisableCRT2Display);
3448 temp = 0xFFFF ^ temp;
3451 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x38);
3453 if (pVBInfo->IF_DEF_LCDA == 1) {
3455 if ((pVBInfo->Set_VGAType >= XG20)
3456 || (pVBInfo->Set_VGAType >= XG40)) {
3457 if (pVBInfo->IF_DEF_LVDS == 0) {
3458 /* if ((pVBInfo->VBType & VB_XGI302B) || (pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType & VB_XGI302LV) || (pVBInfo->VBType & VB_XGI301C)) */
3459 if (pVBInfo->VBType & (VB_XGI302B
3463 if (temp & EnableDualEdge) {
3465 |= SetCRT2ToDualEdge;
3467 if (temp & SetToLCDA)
3472 } else if (pVBInfo->IF_DEF_CH7017 == 1) {
3473 if (pVBInfo->VBType & VB_CH7017) {
3474 if (temp & EnableDualEdge) {
3476 |= SetCRT2ToDualEdge;
3478 if (temp & SetToLCDA)
3487 if (pVBInfo->IF_DEF_YPbPr == 1) {
3488 if (((pVBInfo->IF_DEF_LVDS == 0) && ((pVBInfo->VBType
3489 & VB_XGI301LV) || (pVBInfo->VBType
3490 & VB_XGI302LV) || (pVBInfo->VBType
3492 || ((pVBInfo->IF_DEF_CH7017 == 1)
3495 || ((pVBInfo->IF_DEF_CH7007 == 1)
3497 & VB_CH7007))) { /* [Billy] 07/05/04 */
3498 if (temp & SetYPbPr) { /* temp = CR38 */
3499 if (pVBInfo->IF_DEF_HiVision == 1) {
3500 temp = XGINew_GetReg1(
3502 0x35); /* shampoo add for new scratch */
3504 tempbx |= SetCRT2ToHiVisionTV;
3506 if (temp != YPbPrMode1080i) {
3508 &= (~SetCRT2ToHiVisionTV);
3514 /* tempbx |= SetCRT2ToYPbPr; */
3519 tempax = push; /* restore CR31 */
3521 if (pVBInfo->IF_DEF_LVDS == 0) {
3522 if (pVBInfo->IF_DEF_YPbPr == 1) {
3523 if (pVBInfo->IF_DEF_HiVision == 1)
3528 if (pVBInfo->IF_DEF_HiVision == 1)
3533 } else { /* 3nd party chip */
3534 if (pVBInfo->IF_DEF_CH7017 == 1)
3535 temp = (SetCRT2ToTV | SetCRT2ToLCD
3537 else if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/03 */
3540 temp = SetCRT2ToLCD;
3543 if (!(tempbx & temp)) {
3544 tempax |= DisableCRT2Display;
3548 if (pVBInfo->IF_DEF_LCDA == 1) { /* Select Display Device */
3549 if (!(pVBInfo->VBType & VB_NoLCD)) {
3550 if (tempbx & SetCRT2ToLCDA) {
3551 if (tempbx & SetSimuScanMode)
3567 if (!(tempbx & (SwitchToCRT2 | SetSimuScanMode))) { /* for driver abnormal */
3568 if (pVBInfo->IF_DEF_CRT2Monitor == 1) {
3569 if (tempbx & SetCRT2ToRAMDAC) {
3570 tempbx &= (0xFF00 | SetCRT2ToRAMDAC
3573 tempbx &= (0x00FF | (~SetCRT2ToYPbPr));
3576 tempbx &= (~(SetCRT2ToRAMDAC | SetCRT2ToLCD
3581 if (!(pVBInfo->VBType & VB_NoLCD)) {
3582 if (tempbx & SetCRT2ToLCD) {
3583 tempbx &= (0xFF00 | SetCRT2ToLCD | SwitchToCRT2
3585 tempbx &= (0x00FF | (~SetCRT2ToYPbPr));
3589 if (tempbx & SetCRT2ToSCART) {
3590 tempbx &= (0xFF00 | SetCRT2ToSCART | SwitchToCRT2
3592 tempbx &= (0x00FF | (~SetCRT2ToYPbPr));
3595 if (pVBInfo->IF_DEF_YPbPr == 1) {
3596 if (tempbx & SetCRT2ToYPbPr)
3597 tempbx &= (0xFF00 | SwitchToCRT2
3601 if (pVBInfo->IF_DEF_HiVision == 1) {
3602 if (tempbx & SetCRT2ToHiVisionTV)
3603 tempbx &= (0xFF00 | SetCRT2ToHiVisionTV
3608 if (tempax & DisableCRT2Display) { /* Set Display Device Info */
3609 if (!(tempbx & (SwitchToCRT2 | SetSimuScanMode)))
3610 tempbx = DisableCRT2Display;
3613 if (!(tempbx & DisableCRT2Display)) {
3614 if ((!(tempbx & DriverMode))
3615 || (!(modeflag & CRT2Mode))) {
3616 if (pVBInfo->IF_DEF_LCDA == 1) {
3617 if (!(tempbx & SetCRT2ToLCDA))
3623 if (pVBInfo->IF_DEF_VideoCapture == 1) {
3624 if (((HwDeviceExtension->jChipType
3626 && (pVBInfo->Set_VGAType
3628 || ((HwDeviceExtension->jChipType
3630 && (pVBInfo->Set_VGAType
3632 || ((HwDeviceExtension->jChipType
3634 && (pVBInfo->Set_VGAType
3636 || ((HwDeviceExtension->jChipType
3638 && (pVBInfo->Set_VGAType
3642 & SetCRT2ToRAMDAC)) { /*CRT2 not need to support*/
3645 | (~SetInSlaveMode));
3654 /* LCD+TV can't support in slave mode (Force LCDA+TV->LCDB) */
3655 if ((tempbx & SetInSlaveMode) && (tempbx
3657 tempbx ^= (SetCRT2ToLCD | SetCRT2ToLCDA
3658 | SetCRT2ToDualEdge);
3659 pVBInfo->SetFlag |= ReserveTVOption;
3664 pVBInfo->VBInfo = tempbx;
3667 void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
3668 struct vb_device_info *pVBInfo)
3670 unsigned short temp, tempbx = 0, resinfo = 0, modeflag, index1;
3675 if (pVBInfo->VBInfo & SetCRT2ToTV) {
3676 if (ModeNo <= 0x13) {
3678 = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ModeFlag */
3679 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; /* si+St_ResInfo */
3682 = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3684 = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; /* si+Ext_ResInfo */
3687 if (pVBInfo->VBInfo & SetCRT2ToTV) {
3688 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x35);
3690 if (tempbx & SetPALTV) {
3691 tempbx &= (SetCHTVOverScan | SetPALMTV
3692 | SetPALNTV | SetPALTV);
3693 if (tempbx & SetPALMTV)
3694 tempbx &= ~SetPALTV; /* set to NTSC if PAL-M */
3696 tempbx &= (SetCHTVOverScan | SetNTSCJ
3699 if (pVBInfo->IF_DEF_LVDS == 0) {
3700 index1 = XGINew_GetReg1(pVBInfo->P3d4, 0x38); //PAL-M/PAL-N Info
3701 temp2 = (index1 & 0xC0) >> 5; //00:PAL, 01:PAL-M, 10:PAL-N
3703 if (temp2 & 0x02) //PAL-M
3704 tempbx &= (~SetPALTV);
3709 if (pVBInfo->IF_DEF_CH7017 == 1) {
3710 tempbx = XGINew_GetReg1(pVBInfo->P3d4, 0x35);
3712 if (tempbx & TVOverScan)
3713 tempbx |= SetCHTVOverScan;
3716 if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/04 */
3717 tempbx = XGINew_GetReg1(pVBInfo->P3d4, 0x35);
3719 if (tempbx & TVOverScan)
3720 tempbx |= SetCHTVOverScan;
3723 if (pVBInfo->IF_DEF_LVDS == 0) {
3724 if (pVBInfo->VBInfo & SetCRT2ToSCART)
3728 if (pVBInfo->IF_DEF_YPbPr == 1) {
3729 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
3730 index1 = XGINew_GetReg1(pVBInfo->P3d4, 0x35);
3731 index1 &= YPbPrMode;
3733 if (index1 == YPbPrMode525i)
3734 tempbx |= SetYPbPrMode525i;
3736 if (index1 == YPbPrMode525p)
3737 tempbx = tempbx | SetYPbPrMode525p;
3738 if (index1 == YPbPrMode750p)
3739 tempbx = tempbx | SetYPbPrMode750p;
3743 if (pVBInfo->IF_DEF_HiVision == 1) {
3744 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
3745 tempbx = tempbx | SetYPbPrMode1080i | SetPALTV;
3748 if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */
3749 if ((pVBInfo->VBInfo & SetInSlaveMode)
3750 && (!(pVBInfo->VBInfo & SetNotSimuMode)))
3751 tempbx |= TVSimuMode;
3753 if (!(tempbx & SetPALTV) && (modeflag > 13) && (resinfo
3754 == 8)) /* NTSC 1024x768, */
3755 tempbx |= NTSC1024x768;
3757 tempbx |= RPLLDIV2XO;
3759 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
3760 if (pVBInfo->VBInfo & SetInSlaveMode)
3761 tempbx &= (~RPLLDIV2XO);
3763 if (tempbx & (SetYPbPrMode525p
3764 | SetYPbPrMode750p))
3765 tempbx &= (~RPLLDIV2XO);
3766 else if (!(pVBInfo->VBType & (VB_XGI301B
3767 | VB_XGI302B | VB_XGI301LV
3768 | VB_XGI302LV | VB_XGI301C))) {
3769 if (tempbx & TVSimuMode)
3770 tempbx &= (~RPLLDIV2XO);
3775 pVBInfo->TVInfo = tempbx;
3778 unsigned char XGI_GetLCDInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
3779 struct vb_device_info *pVBInfo)
3781 unsigned short temp, tempax, tempbx, modeflag, resinfo = 0, LCDIdIndex;
3783 pVBInfo->LCDResInfo = 0;
3784 pVBInfo->LCDTypeInfo = 0;
3785 pVBInfo->LCDInfo = 0;
3787 if (ModeNo <= 0x13) {
3788 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ModeFlag // */
3790 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3791 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; /* si+Ext_ResInfo // */
3794 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x36); /* Get LCD Res.Info */
3795 tempbx = temp & 0x0F;
3798 tempbx = Panel1024x768; /* default */
3800 /* LCD75 [2003/8/22] Vicent */
3801 if ((tempbx == Panel1024x768) || (tempbx == Panel1280x1024)) {
3802 if (pVBInfo->VBInfo & DriverMode) {
3803 tempax = XGINew_GetReg1(pVBInfo->P3d4, 0x33);
3804 if (pVBInfo->VBInfo & SetCRT2ToLCDA)
3807 tempax = tempax >> 4;
3809 if ((resinfo == 6) || (resinfo == 9)) {
3811 tempbx |= PanelRef75Hz;
3812 } else if ((resinfo == 7) || (resinfo == 8)) {
3814 tempbx |= PanelRef75Hz;
3819 pVBInfo->LCDResInfo = tempbx;
3823 if (pVBInfo->IF_DEF_OEMUtil == 1)
3824 pVBInfo->LCDTypeInfo = (temp & 0xf0) >> 4;
3826 if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)))
3831 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37);
3833 temp &= (ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable);
3835 if ((pVBInfo->IF_DEF_ScaleLCD == 1) && (temp & LCDNonExpanding))
3836 temp &= ~EnableScalingLCD;
3840 LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo);
3842 tempax = pVBInfo->LCDCapList[LCDIdIndex].LCD_Capability;
3844 if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */
3845 if (((pVBInfo->VBType & VB_XGI302LV) || (pVBInfo->VBType
3846 & VB_XGI301C)) && (tempax & LCDDualLink)) {
3847 tempbx |= SetLCDDualLink;
3851 if (pVBInfo->IF_DEF_CH7017 == 1) {
3852 if (tempax & LCDDualLink)
3853 tempbx |= SetLCDDualLink;
3856 if (pVBInfo->IF_DEF_LVDS == 0) {
3857 if ((pVBInfo->LCDResInfo == Panel1400x1050) && (pVBInfo->VBInfo
3858 & SetCRT2ToLCD) && (ModeNo > 0x13) && (resinfo
3859 == 9) && (!(tempbx & EnableScalingLCD)))
3860 tempbx |= SetLCDtoNonExpanding; /* set to center in 1280x1024 LCDB for Panel1400x1050 */
3864 if (tempax & LCDBToA) {
3865 tempbx |= SetLCDBToA;
3869 if (pVBInfo->IF_DEF_ExpLink == 1) {
3870 if (modeflag & HalfDCLK) {
3871 /* if (!(pVBInfo->LCDInfo&LCDNonExpanding)) */
3872 if (!(tempbx & SetLCDtoNonExpanding)) {
3873 tempbx |= EnableLVDSDDA;
3875 if (ModeNo > 0x13) {
3876 if (pVBInfo->LCDResInfo
3878 if (resinfo == 4) { /* 512x384 */
3879 tempbx |= EnableLVDSDDA;
3887 if (pVBInfo->VBInfo & SetInSlaveMode) {
3888 if (pVBInfo->VBInfo & SetNotSimuMode)
3889 tempbx |= LCDVESATiming;
3891 tempbx |= LCDVESATiming;
3894 pVBInfo->LCDInfo = tempbx;
3896 if (pVBInfo->IF_DEF_PWD == 1) {
3897 if (pVBInfo->LCDInfo & SetPWDEnable) {
3898 if ((pVBInfo->VBType & VB_XGI302LV) || (pVBInfo->VBType
3900 if (!(tempax & PWDEnable))
3901 pVBInfo->LCDInfo &= ~SetPWDEnable;
3906 if (pVBInfo->IF_DEF_LVDS == 0) {
3907 if (tempax & (LockLCDBToA | StLCDBToA)) {
3908 if (pVBInfo->VBInfo & SetInSlaveMode) {
3909 if (!(tempax & LockLCDBToA)) {
3910 if (ModeNo <= 0x13) {
3912 &= ~(SetSimuScanMode
3917 | SetCRT2ToDualEdge;
3925 if (pVBInfo->IF_DEF_LVDS == 0) {
3926 if (tempax & (LockLCDBToA | StLCDBToA)) {
3927 if (pVBInfo->VBInfo & SetInSlaveMode) {
3928 if (!((!(tempax & LockLCDBToA)) && (ModeNo > 0x13))) {
3929 pVBInfo->VBInfo&=~(SetSimuScanMode|SetInSlaveMode|SetCRT2ToLCD);
3930 pVBInfo->VBInfo|=SetCRT2ToLCDA|SetCRT2ToDualEdge;
3940 unsigned char XGI_SearchModeID(unsigned short ModeNo,
3941 unsigned short *ModeIdIndex, struct vb_device_info *pVBInfo)
3945 if (ModeNo <= 0x13) {
3946 /* for (*ModeIdIndex=0; *ModeIdIndex < sizeof(pVBInfo->SModeIDTable) / sizeof(struct XGI_StStruct); (*ModeIdIndex)++) */
3947 for (*ModeIdIndex = 0;; (*ModeIdIndex)++) {
3948 if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == ModeNo)
3950 if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == 0xFF)
3955 (*ModeIdIndex)++; /* 400 lines */
3957 (*ModeIdIndex) += 2; /* 400 lines */
3958 /* else 350 lines */
3960 /* for (*ModeIdIndex=0; *ModeIdIndex < sizeof(pVBInfo->EModeIDTable) / sizeof(struct XGI_ExtStruct); (*ModeIdIndex)++) */
3961 for (*ModeIdIndex = 0;; (*ModeIdIndex)++) {
3962 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == ModeNo)
3964 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == 0xFF)
3972 /* win2000 MM adapter not support standard mode! */
3975 static unsigned char XGINew_CheckMemorySize(
3976 struct xgi_hw_device_info *HwDeviceExtension,
3977 unsigned short ModeNo,
3978 unsigned short ModeIdIndex,
3979 struct vb_device_info *pVBInfo)
3981 unsigned short memorysize, modeflag, temp, temp1, tmp;
3984 if ((HwDeviceExtension->jChipType == XGI_650) ||
3985 (HwDeviceExtension->jChipType == XGI_650M)) {
3991 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
3993 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3995 /* ModeType = modeflag&ModeInfoFlag; // Get mode type */
3997 memorysize = modeflag & MemoryInfoFlag;
3998 memorysize = memorysize > MemorySizeShift;
3999 memorysize++; /* Get memory size */
4001 temp = XGINew_GetReg1(pVBInfo->P3c4, 0x14); /* Get DRAM Size */
4004 if (HwDeviceExtension->jChipType == XG40) {
4005 temp = 1 << ((temp & 0x0F0) >> 4); /* memory size per channel SR14[7:4] */
4006 if ((tmp & 0x0c) == 0x0C) { /* Qual channels */
4008 } else if ((tmp & 0x0c) == 0x08) { /* Dual channels */
4011 } else if (HwDeviceExtension->jChipType == XG42) {
4012 temp = 1 << ((temp & 0x0F0) >> 4); /* memory size per channel SR14[7:4] */
4013 if ((tmp & 0x04) == 0x04) { /* Dual channels */
4016 } else if (HwDeviceExtension->jChipType == XG45) {
4017 temp = 1 << ((temp & 0x0F0) >> 4); /* memory size per channel SR14[7:4] */
4018 if ((tmp & 0x0c) == 0x0C) { /* Qual channels */
4020 } else if ((tmp & 0x0c) == 0x08) { /* triple channels */
4024 } else if ((tmp & 0x0c) == 0x04) { /* Dual channels */
4028 if (temp < memorysize)
4036 void XGINew_IsLowResolution(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned char XGINew_CheckMemorySize(struct xgi_hw_device_info *HwDeviceExtension, unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
4038 unsigned short data ;
4039 unsigned short ModeFlag ;
4041 data = XGINew_GetReg1(pVBInfo->P3c4, 0x0F);
4043 XGINew_SetReg1(pVBInfo->P3c4, 0x0F, data);
4045 if (ModeNo > 0x13) {
4046 ModeFlag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4047 if ((ModeFlag & HalfDCLK) && (ModeFlag & DoubleScanMode)) {
4048 data = XGINew_GetReg1(pVBInfo->P3c4, 0x0F);
4050 XGINew_SetReg1(pVBInfo->P3c4, 0x0F, data);
4051 data = XGINew_GetReg1(pVBInfo->P3c4, 0x01);
4053 XGINew_SetReg1(pVBInfo->P3c4, 0x01, data);
4059 static unsigned char XG21GPIODataTransfer(unsigned char ujDate)
4061 unsigned char ujRet = 0;
4062 unsigned char i = 0;
4064 for (i = 0; i < 8; i++) {
4066 /* ujRet |= GETBITS(ujDate >> i, 0:0); */
4067 ujRet |= (ujDate >> i) & 1;
4073 /*----------------------------------------------------------------------------*/
4075 /* bl[5] : LVDS signal */
4076 /* bl[1] : LVDS backlight */
4077 /* bl[0] : LVDS VDD */
4078 /*----------------------------------------------------------------------------*/
4079 static unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo)
4081 unsigned char CR4A, temp;
4083 CR4A = XGINew_GetReg1(pVBInfo->P3d4, 0x4A);
4084 XGINew_SetRegAND(pVBInfo->P3d4, 0x4A, ~0x23); /* enable GPIO write */
4086 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x48);
4088 temp = XG21GPIODataTransfer(temp);
4090 XGINew_SetReg1(pVBInfo->P3d4, 0x4A, CR4A);
4094 /*----------------------------------------------------------------------------*/
4096 /* bl[5] : LVDS signal */
4097 /* bl[1] : LVDS backlight */
4098 /* bl[0] : LVDS VDD */
4099 /*----------------------------------------------------------------------------*/
4100 static unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo)
4102 unsigned char CR4A, CRB4, temp;
4104 CR4A = XGINew_GetReg1(pVBInfo->P3d4, 0x4A);
4105 XGINew_SetRegAND(pVBInfo->P3d4, 0x4A, ~0x0C); /* enable GPIO write */
4107 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x48);
4111 XGINew_SetReg1(pVBInfo->P3d4, 0x4A, CR4A);
4112 CRB4 = XGINew_GetReg1(pVBInfo->P3d4, 0xB4);
4113 temp |= ((CRB4 & 0x04) << 3);
4117 void XGI_DisplayOn(struct xgi_hw_device_info *pXGIHWDE,
4118 struct vb_device_info *pVBInfo)
4121 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x01, 0xDF, 0x00);
4122 if (pXGIHWDE->jChipType == XG21) {
4123 if (pVBInfo->IF_DEF_LVDS == 1) {
4124 if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x1)) {
4125 XGI_XG21BLSignalVDD(0x01, 0x01, pVBInfo); /* LVDS VDD on */
4126 XGI_XG21SetPanelDelay(2, pVBInfo);
4128 if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x20))
4129 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); /* LVDS signal on */
4130 XGI_XG21SetPanelDelay(3, pVBInfo);
4131 XGI_XG21BLSignalVDD(0x02, 0x02, pVBInfo); /* LVDS backlight on */
4133 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); /* DVO/DVI signal on */
4138 if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/23 For CH7007 */
4142 if (pXGIHWDE->jChipType == XG27) {
4143 if (pVBInfo->IF_DEF_LVDS == 1) {
4144 if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x1)) {
4145 XGI_XG27BLSignalVDD(0x01, 0x01, pVBInfo); /* LVDS VDD on */
4146 XGI_XG21SetPanelDelay(2, pVBInfo);
4148 if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x20))
4149 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); /* LVDS signal on */
4150 XGI_XG21SetPanelDelay(3, pVBInfo);
4151 XGI_XG27BLSignalVDD(0x02, 0x02, pVBInfo); /* LVDS backlight on */
4153 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); /* DVO/DVI signal on */
4159 void XGI_DisplayOff(struct xgi_hw_device_info *pXGIHWDE,
4160 struct vb_device_info *pVBInfo)
4163 if (pXGIHWDE->jChipType == XG21) {
4164 if (pVBInfo->IF_DEF_LVDS == 1) {
4165 XGI_XG21BLSignalVDD(0x02, 0x00, pVBInfo); /* LVDS backlight off */
4166 XGI_XG21SetPanelDelay(3, pVBInfo);
4168 XGI_XG21BLSignalVDD(0x20, 0x00, pVBInfo); /* DVO/DVI signal off */
4172 if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/23 For CH7007 */
4173 /* if (IsCH7007TVMode(pVBInfo) == 0) */
4178 if (pXGIHWDE->jChipType == XG27) {
4179 if ((XGI_XG27GetPSCValue(pVBInfo) & 0x2)) {
4180 XGI_XG27BLSignalVDD(0x02, 0x00, pVBInfo); /* LVDS backlight off */
4181 XGI_XG21SetPanelDelay(3, pVBInfo);
4184 if (pVBInfo->IF_DEF_LVDS == 0)
4185 XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo); /* DVO/DVI signal off */
4188 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x01, 0xDF, 0x20);
4191 static void XGI_WaitDisply(struct vb_device_info *pVBInfo)
4193 while ((inb(pVBInfo->P3da) & 0x01))
4196 while (!(inb(pVBInfo->P3da) & 0x01))
4201 static void XGI_WaitDisplay(struct vb_device_info *pVBInfo)
4203 while (!(inb(pVBInfo->P3da) & 0x01));
4204 while (inb(pVBInfo->P3da) & 0x01);
4208 static void XGI_AutoThreshold(struct vb_device_info *pVBInfo)
4210 if (!(pVBInfo->SetFlag & Win9xDOSMode))
4211 XGINew_SetRegOR(pVBInfo->Part1Port, 0x01, 0x40);
4214 static void XGI_SaveCRT2Info(unsigned short ModeNo, struct vb_device_info *pVBInfo)
4216 unsigned short temp1, temp2;
4218 XGINew_SetReg1(pVBInfo->P3d4, 0x34, ModeNo); /* reserve CR34 for CRT1 Mode No */
4219 temp1 = (pVBInfo->VBInfo & SetInSlaveMode) >> 8;
4220 temp2 = ~(SetInSlaveMode >> 8);
4221 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x31, temp2, temp1);
4224 static void XGI_GetCRT2ResInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
4225 struct vb_device_info *pVBInfo)
4227 unsigned short xres, yres, modeflag, resindex;
4229 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
4230 if (ModeNo <= 0x13) {
4231 xres = pVBInfo->StResInfo[resindex].HTotal;
4232 yres = pVBInfo->StResInfo[resindex].VTotal;
4233 /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; si+St_ResInfo */
4235 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
4236 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
4237 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */
4240 if (pVBInfo->IF_DEF_FSTN) {
4245 if (modeflag & HalfDCLK)
4248 if (modeflag & DoubleScanMode)
4253 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
4254 if (pVBInfo->IF_DEF_LVDS == 0) {
4255 if (pVBInfo->LCDResInfo == Panel1600x1200) {
4256 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
4262 if (pVBInfo->LCDResInfo == Panel1280x1024) {
4265 else if (yres == 350)
4268 if (pVBInfo->LCDInfo & LCDVESATiming) {
4274 if (pVBInfo->LCDResInfo == Panel1024x768) {
4275 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
4276 if (!(pVBInfo->LCDInfo
4277 & LCDNonExpanding)) {
4280 else if (yres == 400)
4282 else if (yres == 480)
4293 pVBInfo->VGAHDE = xres;
4294 pVBInfo->HDE = xres;
4295 pVBInfo->VGAVDE = yres;
4296 pVBInfo->VDE = yres;
4299 static unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo)
4302 if ((pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) &&
4303 (pVBInfo->LCDInfo & SetLCDDualLink)) /* shampoo0129 */
4309 static void XGI_GetRAMDAC2DATA(unsigned short ModeNo, unsigned short ModeIdIndex,
4310 unsigned short RefreshRateTableIndex,
4311 struct vb_device_info *pVBInfo)
4313 unsigned short tempax, tempbx, temp1, temp2, modeflag = 0, tempcx,
4314 StandTableIndex, CRT1Index;
4316 pVBInfo->RVBHCMAX = 1;
4317 pVBInfo->RVBHCFACT = 1;
4319 if (ModeNo <= 0x13) {
4320 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
4321 StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
4322 tempax = pVBInfo->StandTable[StandTableIndex].CRTC[0];
4323 tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[6];
4324 temp1 = pVBInfo->StandTable[StandTableIndex].CRTC[7];
4326 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4328 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4329 CRT1Index &= IndexMask;
4331 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[0];
4333 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5];
4334 tempax = (temp1 & 0xFF) | ((temp2 & 0x03) << 8);
4336 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[8];
4338 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14]
4341 tempcx = tempcx << 2;
4344 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9];
4354 if (modeflag & Charx8Dot)
4359 pVBInfo->VGAHT = tempax;
4360 pVBInfo->HT = tempax;
4362 pVBInfo->VGAVT = tempbx;
4363 pVBInfo->VT = tempbx;
4366 static void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex,
4367 unsigned short RefreshRateTableIndex,
4368 struct vb_device_info *pVBInfo)
4370 unsigned short tempax = 0, tempbx, modeflag, resinfo;
4372 struct XGI_LCDDataStruct *LCDPtr = NULL;
4373 struct XGI_TVDataStruct *TVPtr = NULL;
4375 if (ModeNo <= 0x13) {
4376 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
4377 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
4379 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
4380 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4383 pVBInfo->NewFlickerMode = 0;
4384 pVBInfo->RVBHRS = 50;
4386 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
4387 XGI_GetRAMDAC2DATA(ModeNo, ModeIdIndex, RefreshRateTableIndex,
4394 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
4395 LCDPtr = (struct XGI_LCDDataStruct *) XGI_GetLcdPtr(tempbx,
4396 ModeNo, ModeIdIndex, RefreshRateTableIndex,
4399 pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX;
4400 pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT;
4401 pVBInfo->VGAHT = LCDPtr->VGAHT;
4402 pVBInfo->VGAVT = LCDPtr->VGAVT;
4403 pVBInfo->HT = LCDPtr->LCDHT;
4404 pVBInfo->VT = LCDPtr->LCDVT;
4406 if (pVBInfo->LCDResInfo == Panel1024x768) {
4410 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
4411 if (pVBInfo->VGAVDE == 357)
4413 else if (pVBInfo->VGAVDE == 420)
4415 else if (pVBInfo->VGAVDE == 525)
4417 else if (pVBInfo->VGAVDE == 600)
4419 /* else if (pVBInfo->VGAVDE==350) tempbx=560; */
4420 /* else if (pVBInfo->VGAVDE==400) tempbx=640; */
4425 } else if (pVBInfo->LCDResInfo == Panel1024x768x75) {
4428 } else if (pVBInfo->LCDResInfo == Panel1280x1024) {
4430 if (pVBInfo->VGAVDE == 360)
4432 else if (pVBInfo->VGAVDE == 375)
4434 else if (pVBInfo->VGAVDE == 405)
4438 } else if (pVBInfo->LCDResInfo == Panel1280x1024x75) {
4441 } else if (pVBInfo->LCDResInfo == Panel1280x960) {
4443 if (pVBInfo->VGAVDE == 350)
4445 else if (pVBInfo->VGAVDE == 400)
4447 else if (pVBInfo->VGAVDE == 1024)
4451 } else if (pVBInfo->LCDResInfo == Panel1400x1050) {
4455 if (pVBInfo->VGAVDE == 1024) {
4459 } else if (pVBInfo->LCDResInfo == Panel1600x1200) {
4461 tempbx = 1200; /* alan 10/14/2003 */
4462 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
4463 if (pVBInfo->VGAVDE == 350)
4465 else if (pVBInfo->VGAVDE == 400)
4470 if (pVBInfo->LCDInfo & LCDNonExpanding) {
4471 tempax = pVBInfo->VGAHDE;
4472 tempbx = pVBInfo->VGAVDE;
4475 pVBInfo->HDE = tempax;
4476 pVBInfo->VDE = tempbx;
4480 if (pVBInfo->VBInfo & (SetCRT2ToTV)) {
4482 TVPtr = (struct XGI_TVDataStruct *) XGI_GetTVPtr(tempbx,
4483 ModeNo, ModeIdIndex, RefreshRateTableIndex,
4486 pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX;
4487 pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT;
4488 pVBInfo->VGAHT = TVPtr->VGAHT;
4489 pVBInfo->VGAVT = TVPtr->VGAVT;
4490 pVBInfo->HDE = TVPtr->TVHDE;
4491 pVBInfo->VDE = TVPtr->TVVDE;
4492 pVBInfo->RVBHRS = TVPtr->RVBHRS;
4493 pVBInfo->NewFlickerMode = TVPtr->FlickerMode;
4495 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4496 if (resinfo == 0x08)
4497 pVBInfo->NewFlickerMode = 0x40;
4498 else if (resinfo == 0x09)
4499 pVBInfo->NewFlickerMode = 0x40;
4500 else if (resinfo == 0x12)
4501 pVBInfo->NewFlickerMode = 0x40;
4503 if (pVBInfo->VGAVDE == 350)
4504 pVBInfo->TVInfo |= TVSimuMode;
4509 if (pVBInfo->VBInfo & SetInSlaveMode) {
4510 if (pVBInfo->TVInfo & TVSimuMode) {
4514 if (!(modeflag & Charx8Dot)) {
4515 tempax = StHiTextTVHT;
4516 tempbx = StHiTextTVVT;
4520 } else if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
4521 if (pVBInfo->TVInfo & SetYPbPrMode750p) {
4522 tempax = YPbPrTV750pHT; /* Ext750pTVHT */
4523 tempbx = YPbPrTV750pVT; /* Ext750pTVVT */
4526 if (pVBInfo->TVInfo & SetYPbPrMode525p) {
4527 tempax = YPbPrTV525pHT; /* Ext525pTVHT */
4528 tempbx = YPbPrTV525pVT; /* Ext525pTVVT */
4529 } else if (pVBInfo->TVInfo & SetYPbPrMode525i) {
4530 tempax = YPbPrTV525iHT; /* Ext525iTVHT */
4531 tempbx = YPbPrTV525iVT; /* Ext525iTVVT */
4532 if (pVBInfo->TVInfo & NTSC1024x768)
4533 tempax = NTSC1024x768HT;
4538 if (!(pVBInfo->TVInfo & SetPALTV)) {
4541 if (pVBInfo->TVInfo & NTSC1024x768)
4542 tempax = NTSC1024x768HT;
4546 pVBInfo->HT = tempax;
4547 pVBInfo->VT = tempbx;
4552 static void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex,
4553 unsigned short RefreshRateTableIndex,
4554 struct vb_device_info *pVBInfo)
4556 unsigned char di_0, di_1, tempal;
4558 tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex,
4560 XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo);
4561 XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo);
4563 if (pVBInfo->VBType & VB_XGI301) { /* shampoo 0129 */
4565 XGINew_SetReg1(pVBInfo->Part4Port, 0x0A, 0x10);
4566 XGINew_SetReg1(pVBInfo->Part4Port, 0x0B, di_1);
4567 XGINew_SetReg1(pVBInfo->Part4Port, 0x0A, di_0);
4568 } else { /* 301b/302b/301lv/302lv */
4569 XGINew_SetReg1(pVBInfo->Part4Port, 0x0A, di_0);
4570 XGINew_SetReg1(pVBInfo->Part4Port, 0x0B, di_1);
4573 XGINew_SetReg1(pVBInfo->Part4Port, 0x00, 0x12);
4575 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC)
4576 XGINew_SetRegOR(pVBInfo->Part4Port, 0x12, 0x28);
4578 XGINew_SetRegOR(pVBInfo->Part4Port, 0x12, 0x08);
4581 static unsigned short XGI_GetColorDepth(unsigned short ModeNo,
4582 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
4584 unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8 };
4586 unsigned short modeflag;
4589 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
4591 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4593 index = (modeflag & ModeInfoFlag) - ModeEGA;
4598 return ColorDepth[index];
4601 static unsigned short XGI_GetOffset(unsigned short ModeNo, unsigned short ModeIdIndex,
4602 unsigned short RefreshRateTableIndex,
4603 struct xgi_hw_device_info *HwDeviceExtension,
4604 struct vb_device_info *pVBInfo)
4606 unsigned short temp, colordepth, modeinfo, index, infoflag,
4607 ColorDepth[] = { 0x01, 0x02, 0x04 };
4609 modeinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo;
4613 infoflag = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
4615 index = (modeinfo >> 8) & 0xFF;
4617 temp = pVBInfo->ScreenOffset[index];
4619 if (infoflag & InterlaceMode)
4622 colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo);
4624 if ((ModeNo >= 0x7C) && (ModeNo <= 0x7E)) {
4625 temp = ModeNo - 0x7C;
4626 colordepth = ColorDepth[temp];
4628 if (infoflag & InterlaceMode)
4630 return temp * colordepth;
4632 return temp * colordepth;
4636 static void XGI_SetCRT2Offset(unsigned short ModeNo,
4637 unsigned short ModeIdIndex,
4638 unsigned short RefreshRateTableIndex,
4639 struct xgi_hw_device_info *HwDeviceExtension,
4640 struct vb_device_info *pVBInfo)
4642 unsigned short offset;
4645 if (pVBInfo->VBInfo & SetInSlaveMode)
4648 offset = XGI_GetOffset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
4649 HwDeviceExtension, pVBInfo);
4650 temp = (unsigned char) (offset & 0xFF);
4651 XGINew_SetReg1(pVBInfo->Part1Port, 0x07, temp);
4652 temp = (unsigned char) ((offset & 0xFF00) >> 8);
4653 XGINew_SetReg1(pVBInfo->Part1Port, 0x09, temp);
4654 temp = (unsigned char) (((offset >> 3) & 0xFF) + 1);
4655 XGINew_SetReg1(pVBInfo->Part1Port, 0x03, temp);
4658 static void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo)
4660 XGINew_SetReg1(pVBInfo->Part1Port, 0x01, 0x3B); /* threshold high ,disable auto threshold */
4661 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x02, ~(0x3F), 0x04); /* threshold low default 04h */
4664 static void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
4665 struct xgi_hw_device_info *HwDeviceExtension,
4666 unsigned short RefreshRateTableIndex,
4667 struct vb_device_info *pVBInfo)
4669 unsigned short tempcx = 0, CRT1Index = 0, resinfo = 0;
4671 if (ModeNo > 0x13) {
4672 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4673 CRT1Index &= IndexMask;
4674 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4677 XGI_SetCRT2Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
4678 HwDeviceExtension, pVBInfo);
4679 XGI_SetCRT2FIFO(pVBInfo);
4680 /* XGI_SetCRT2Sync(ModeNo,RefreshRateTableIndex); */
4682 for (tempcx = 4; tempcx < 7; tempcx++)
4683 XGINew_SetReg1(pVBInfo->Part1Port, tempcx, 0x0);
4685 XGINew_SetReg1(pVBInfo->Part1Port, 0x50, 0x00);
4686 XGINew_SetReg1(pVBInfo->Part1Port, 0x02, 0x44); /* temp 0206 */
4689 static void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
4690 struct xgi_hw_device_info *HwDeviceExtension,
4691 unsigned short RefreshRateTableIndex,
4692 struct vb_device_info *pVBInfo)
4694 unsigned short temp = 0, tempax = 0, tempbx = 0, tempcx = 0,
4695 pushbx = 0, CRT1Index = 0, modeflag, resinfo = 0;
4697 if (ModeNo > 0x13) {
4698 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4699 CRT1Index &= IndexMask;
4700 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4704 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
4706 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4708 /* bainy change table name */
4709 if (modeflag & HalfDCLK) {
4710 temp = (pVBInfo->VGAHT / 2 - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */
4711 XGINew_SetReg1(pVBInfo->Part1Port, 0x08, temp);
4712 temp = (((pVBInfo->VGAHT / 2 - 1) & 0xFF00) >> 8) << 4;
4713 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x09, ~0x0F0, temp);
4714 temp = (pVBInfo->VGAHDE / 2 + 16) & 0x0FF; /* BTVGA2HDEE 0x0A,0x0C */
4715 XGINew_SetReg1(pVBInfo->Part1Port, 0x0A, temp);
4716 tempcx = ((pVBInfo->VGAHT - pVBInfo->VGAHDE) / 2) >> 2;
4717 pushbx = pVBInfo->VGAHDE / 2 + 16;
4718 tempcx = tempcx >> 1;
4719 tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */
4722 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
4723 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4];
4724 tempbx |= ((pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14]
4726 tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */
4727 tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5];
4729 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[15];
4730 temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */
4731 tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */
4737 if (tempcx > (pVBInfo->VGAHT / 2))
4738 tempcx = pVBInfo->VGAHT / 2;
4740 temp = tempbx & 0x00FF;
4742 XGINew_SetReg1(pVBInfo->Part1Port, 0x0B, temp);
4744 temp = (pVBInfo->VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */
4745 XGINew_SetReg1(pVBInfo->Part1Port, 0x08, temp);
4746 temp = (((pVBInfo->VGAHT - 1) & 0xFF00) >> 8) << 4;
4747 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x09, ~0x0F0, temp);
4748 temp = (pVBInfo->VGAHDE + 16) & 0x0FF; /* BTVGA2HDEE 0x0A,0x0C */
4749 XGINew_SetReg1(pVBInfo->Part1Port, 0x0A, temp);
4750 tempcx = (pVBInfo->VGAHT - pVBInfo->VGAHDE) >> 2; /* cx */
4751 pushbx = pVBInfo->VGAHDE + 16;
4752 tempcx = tempcx >> 1;
4753 tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */
4756 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
4757 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[3];
4758 tempbx |= ((pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5]
4760 tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */
4761 tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4];
4763 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[6];
4764 temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */
4765 tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */
4770 if (tempcx > pVBInfo->VGAHT)
4771 tempcx = pVBInfo->VGAHT;
4773 temp = tempbx & 0x00FF;
4774 XGINew_SetReg1(pVBInfo->Part1Port, 0x0B, temp);
4777 tempax = (tempax & 0x00FF) | (tempbx & 0xFF00);
4779 tempbx = (tempbx & 0x00FF) | ((tempbx & 0xFF00) << 4);
4780 tempax |= (tempbx & 0xFF00);
4781 temp = (tempax & 0xFF00) >> 8;
4782 XGINew_SetReg1(pVBInfo->Part1Port, 0x0C, temp);
4783 temp = tempcx & 0x00FF;
4784 XGINew_SetReg1(pVBInfo->Part1Port, 0x0D, temp);
4785 tempcx = (pVBInfo->VGAVT - 1);
4786 temp = tempcx & 0x00FF;
4788 if (pVBInfo->IF_DEF_CH7005 == 1) {
4789 if (pVBInfo->VBInfo & 0x0C)
4793 XGINew_SetReg1(pVBInfo->Part1Port, 0x0E, temp);
4794 tempbx = pVBInfo->VGAVDE - 1;
4795 temp = tempbx & 0x00FF;
4796 XGINew_SetReg1(pVBInfo->Part1Port, 0x0F, temp);
4797 temp = ((tempbx & 0xFF00) << 3) >> 8;
4798 temp |= ((tempcx & 0xFF00) >> 8);
4799 XGINew_SetReg1(pVBInfo->Part1Port, 0x12, temp);
4801 tempax = pVBInfo->VGAVDE;
4802 tempbx = pVBInfo->VGAVDE;
4803 tempcx = pVBInfo->VGAVT;
4804 tempbx = (pVBInfo->VGAVT + pVBInfo->VGAVDE) >> 1; /* BTVGA2VRS 0x10,0x11 */
4805 tempcx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) >> 4) + tempbx + 1; /* BTVGA2VRE 0x11 */
4807 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
4808 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[10];
4809 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9];
4817 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14];
4822 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[11];
4823 tempcx = (tempcx & 0xFF00) | (temp & 0x00FF);
4826 temp = tempbx & 0x00FF;
4827 XGINew_SetReg1(pVBInfo->Part1Port, 0x10, temp);
4828 temp = ((tempbx & 0xFF00) >> 8) << 4;
4829 temp = ((tempcx & 0x000F) | (temp));
4830 XGINew_SetReg1(pVBInfo->Part1Port, 0x11, temp);
4833 if (modeflag & DoubleScanMode)
4836 if (modeflag & HalfDCLK)
4839 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2C, ~0x0C0, tempax);
4842 static unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo)
4844 unsigned long tempax, tempbx;
4846 tempbx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) * pVBInfo->RVBHCMAX)
4848 tempax = (pVBInfo->VT - pVBInfo->VDE) * pVBInfo->RVBHCFACT;
4849 tempax = (tempax * pVBInfo->HT) / tempbx;
4851 return (unsigned short) tempax;
4854 static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
4855 struct xgi_hw_device_info *HwDeviceExtension,
4856 unsigned short RefreshRateTableIndex,
4857 struct vb_device_info *pVBInfo)
4859 unsigned short push1, push2, tempax, tempbx = 0, tempcx, temp, resinfo,
4860 modeflag, CRT1Index;
4862 if (ModeNo <= 0x13) {
4863 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
4864 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
4866 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
4867 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4868 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4869 CRT1Index &= IndexMask;
4872 if (!(pVBInfo->VBInfo & SetInSlaveMode))
4875 temp = 0xFF; /* set MAX HT */
4876 XGINew_SetReg1(pVBInfo->Part1Port, 0x03, temp);
4877 /* if (modeflag & Charx8Dot) */
4878 /* tempcx = 0x08; */
4882 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C))
4883 modeflag |= Charx8Dot;
4885 tempax = pVBInfo->VGAHDE; /* 0x04 Horizontal Display End */
4887 if (modeflag & HalfDCLK)
4888 tempax = tempax >> 1;
4890 tempax = (tempax / tempcx) - 1;
4891 tempbx |= ((tempax & 0x00FF) << 8);
4892 temp = tempax & 0x00FF;
4893 XGINew_SetReg1(pVBInfo->Part1Port, 0x04, temp);
4895 temp = (tempbx & 0xFF00) >> 8;
4897 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4898 if (!(pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
4899 | VB_XGI302LV | VB_XGI301C)))
4902 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4903 if (pVBInfo->VBType & VB_XGI301LV) {
4904 if (pVBInfo->VBExtInfo == VB_YPbPr1080i) {
4908 } else if (resinfo == 7) {
4914 XGINew_SetReg1(pVBInfo->Part1Port, 0x05, temp); /* 0x05 Horizontal Display Start */
4915 XGINew_SetReg1(pVBInfo->Part1Port, 0x06, 0x03); /* 0x06 Horizontal Blank end */
4917 if (!(pVBInfo->VBInfo & DisableCRT2Display)) { /* 030226 bainy */
4918 if (pVBInfo->VBInfo & SetCRT2ToTV)
4919 tempax = pVBInfo->VGAHT;
4921 tempax = XGI_GetVGAHT2(pVBInfo);
4924 if (tempax >= pVBInfo->VGAHT)
4925 tempax = pVBInfo->VGAHT;
4927 if (modeflag & HalfDCLK)
4928 tempax = tempax >> 1;
4930 tempax = (tempax / tempcx) - 5;
4931 tempcx = tempax; /* 20030401 0x07 horizontal Retrace Start */
4932 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4933 temp = (tempbx & 0x00FF) - 1;
4934 if (!(modeflag & HalfDCLK)) {
4936 if (pVBInfo->TVInfo & TVSimuMode) {
4943 /* tempcx = tempbx & 0x00FF ; */
4944 tempbx = (tempbx & 0xFF00) >> 8;
4945 tempcx = (tempcx + tempbx) >> 1;
4946 temp = (tempcx & 0x00FF) + 2;
4948 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4950 if (!(modeflag & HalfDCLK)) {
4951 if ((modeflag & Charx8Dot)) {
4953 if (pVBInfo->VGAHDE >= 800)
4958 if (!(modeflag & HalfDCLK)) {
4960 if (pVBInfo->LCDResInfo != Panel1280x960) {
4961 if (pVBInfo->VGAHDE >= 800) {
4963 if (pVBInfo->ModeType
4968 if (pVBInfo->LCDResInfo
4969 != Panel1280x1024) {
4976 if (pVBInfo->VGAHDE >= 1280) {
4977 if (pVBInfo->LCDResInfo
4979 if (pVBInfo->LCDInfo
4980 & LCDNonExpanding) {
4992 XGINew_SetReg1(pVBInfo->Part1Port, 0x07, temp); /* 0x07 Horizontal Retrace Start */
4993 XGINew_SetReg1(pVBInfo->Part1Port, 0x08, 0); /* 0x08 Horizontal Retrace End */
4995 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4996 if (pVBInfo->TVInfo & TVSimuMode) {
4997 if ((ModeNo == 0x06) || (ModeNo == 0x10) || (ModeNo
4998 == 0x11) || (ModeNo == 0x13) || (ModeNo
5000 XGINew_SetReg1(pVBInfo->Part1Port, 0x07, 0x5b);
5001 XGINew_SetReg1(pVBInfo->Part1Port, 0x08, 0x03);
5004 if ((ModeNo == 0x00) || (ModeNo == 0x01)) {
5005 if (pVBInfo->TVInfo & SetNTSCTV) {
5006 XGINew_SetReg1(pVBInfo->Part1Port,
5008 XGINew_SetReg1(pVBInfo->Part1Port,
5011 XGINew_SetReg1(pVBInfo->Part1Port,
5013 XGINew_SetReg1(pVBInfo->Part1Port,
5015 XGINew_SetReg1(pVBInfo->Part1Port,
5020 if ((ModeNo == 0x02) || (ModeNo == 0x03) || (ModeNo
5022 if (pVBInfo->TVInfo & SetNTSCTV) {
5023 XGINew_SetReg1(pVBInfo->Part1Port,
5025 XGINew_SetReg1(pVBInfo->Part1Port,
5028 XGINew_SetReg1(pVBInfo->Part1Port,
5030 XGINew_SetReg1(pVBInfo->Part1Port,
5032 XGINew_SetReg1(pVBInfo->Part1Port,
5037 if ((ModeNo == 0x04) || (ModeNo == 0x05) || (ModeNo
5038 == 0x0D) || (ModeNo == 0x50)) {
5039 if (pVBInfo->TVInfo & SetNTSCTV) {
5040 XGINew_SetReg1(pVBInfo->Part1Port,
5042 XGINew_SetReg1(pVBInfo->Part1Port,
5045 XGINew_SetReg1(pVBInfo->Part1Port,
5047 XGINew_SetReg1(pVBInfo->Part1Port,
5054 XGINew_SetReg1(pVBInfo->Part1Port, 0x18, 0x03); /* 0x18 SR0B */
5055 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0xF0, 0x00);
5056 XGINew_SetReg1(pVBInfo->Part1Port, 0x09, 0xFF); /* 0x09 Set Max VT */
5058 tempbx = pVBInfo->VGAVT;
5061 tempbx = pVBInfo->VGAVDE; /* 0x0E Virtical Display End */
5076 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
5077 if (pVBInfo->LCDResInfo == Panel1024x768) {
5078 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
5087 temp = tempbx & 0x00FF;
5089 temp = tempbx & 0x00FF;
5090 XGINew_SetReg1(pVBInfo->Part1Port, 0x10, temp); /* 0x10 vertical Blank Start */
5093 temp = tempbx & 0x00FF;
5094 XGINew_SetReg1(pVBInfo->Part1Port, 0x0E, temp);
5096 if (tempbx & 0x0100)
5101 if (modeflag & DoubleScanMode)
5104 if (tempbx & 0x0200)
5107 temp = (tempax & 0xFF00) >> 8;
5108 XGINew_SetReg1(pVBInfo->Part1Port, 0x0B, temp);
5110 if (tempbx & 0x0400)
5113 XGINew_SetReg1(pVBInfo->Part1Port, 0x11, 0x00); /* 0x11 Vertival Blank End */
5116 tempax -= tempbx; /* 0x0C Vertical Retrace Start */
5117 tempax = tempax >> 2;
5118 push1 = tempax; /* push ax */
5120 if (resinfo != 0x09) {
5121 tempax = tempax << 1;
5125 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5126 if (pVBInfo->VBType & VB_XGI301LV) {
5127 if (pVBInfo->TVInfo & SetYPbPrMode1080i) {
5130 if (pVBInfo->TVInfo & TVSimuMode) {
5131 if (pVBInfo->TVInfo & SetPALTV) {
5134 if (!(pVBInfo->TVInfo
5137 | SetYPbPrMode1080i)))
5149 if (pVBInfo->TVInfo & TVSimuMode) {
5150 if (pVBInfo->TVInfo & SetPALTV) {
5151 if (pVBInfo->VBType & VB_XGI301LV) {
5152 if (!(pVBInfo->TVInfo
5155 | SetYPbPrMode1080i)))
5164 tempax = tempax >> 2;
5167 push1 = tempax; /* push ax */
5169 if ((pVBInfo->TVInfo & SetPALTV)) {
5170 if (tempbx <= 513) {
5176 temp = tempbx & 0x00FF;
5177 XGINew_SetReg1(pVBInfo->Part1Port, 0x0C, temp);
5179 temp = tempbx & 0x00FF;
5180 XGINew_SetReg1(pVBInfo->Part1Port, 0x10, temp);
5182 if (tempbx & 0x0100)
5185 if (tempbx & 0x0200)
5186 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x0B, 0x0FF, 0x20);
5190 if (tempbx & 0x0100)
5193 if (tempbx & 0x0200)
5196 if (tempbx & 0x0400)
5199 tempbx = push1; /* pop ax */
5200 temp = tempbx & 0x00FF;
5202 XGINew_SetReg1(pVBInfo->Part1Port, 0x0D, temp); /* 0x0D vertical Retrace End */
5204 if (tempbx & 0x0010)
5207 temp = tempcx & 0x00FF;
5208 XGINew_SetReg1(pVBInfo->Part1Port, 0x0A, temp); /* 0x0A CR07 */
5209 temp = (tempcx & 0x0FF00) >> 8;
5210 XGINew_SetReg1(pVBInfo->Part1Port, 0x17, temp); /* 0x17 SR0A */
5212 temp = (tempax & 0xFF00) >> 8;
5214 temp = (temp >> 1) & 0x09;
5216 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C))
5219 XGINew_SetReg1(pVBInfo->Part1Port, 0x16, temp); /* 0x16 SR01 */
5220 XGINew_SetReg1(pVBInfo->Part1Port, 0x0F, 0); /* 0x0F CR14 */
5221 XGINew_SetReg1(pVBInfo->Part1Port, 0x12, 0); /* 0x12 CR17 */
5223 if (pVBInfo->LCDInfo & LCDRGB18Bit)
5228 XGINew_SetReg1(pVBInfo->Part1Port, 0x1A, temp); /* 0x1A SR0E */
5233 static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex,
5234 unsigned short RefreshRateTableIndex,
5235 struct xgi_hw_device_info *HwDeviceExtension,
5236 struct vb_device_info *pVBInfo)
5238 unsigned short i, j, tempax, tempbx, tempcx, temp, push1, push2,
5239 modeflag, resinfo, crt2crtc;
5240 unsigned char *TimingPoint;
5242 unsigned long longtemp, tempeax, tempebx, temp2, tempecx;
5244 if (ModeNo <= 0x13) {
5245 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
5246 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
5247 crt2crtc = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
5249 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
5250 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
5252 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
5257 if (!(pVBInfo->VBInfo & SetCRT2ToAVIDEO))
5260 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
5263 if (pVBInfo->VBInfo & SetCRT2ToSCART)
5266 if (!(pVBInfo->TVInfo & SetPALTV))
5269 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5272 if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))
5275 tempax = (tempax & 0xff00) >> 8;
5277 XGINew_SetReg1(pVBInfo->Part2Port, 0x0, tempax);
5278 TimingPoint = pVBInfo->NTSCTiming;
5280 if (pVBInfo->TVInfo & SetPALTV)
5281 TimingPoint = pVBInfo->PALTiming;
5283 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5284 TimingPoint = pVBInfo->HiTVExtTiming;
5286 if (pVBInfo->VBInfo & SetInSlaveMode)
5287 TimingPoint = pVBInfo->HiTVSt2Timing;
5289 if (pVBInfo->SetFlag & TVSimuMode)
5290 TimingPoint = pVBInfo->HiTVSt1Timing;
5292 if (!(modeflag & Charx8Dot))
5293 TimingPoint = pVBInfo->HiTVTextTiming;
5296 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
5297 if (pVBInfo->TVInfo & SetYPbPrMode525i)
5298 TimingPoint = pVBInfo->YPbPr525iTiming;
5300 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5301 TimingPoint = pVBInfo->YPbPr525pTiming;
5303 if (pVBInfo->TVInfo & SetYPbPrMode750p)
5304 TimingPoint = pVBInfo->YPbPr750pTiming;
5307 for (i = 0x01, j = 0; i <= 0x2D; i++, j++)
5308 XGINew_SetReg1(pVBInfo->Part2Port, i, TimingPoint[j]);
5310 for (i = 0x39; i <= 0x45; i++, j++)
5311 XGINew_SetReg1(pVBInfo->Part2Port, i, TimingPoint[j]); /* di->temp2[j] */
5313 if (pVBInfo->VBInfo & SetCRT2ToTV)
5314 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x3A, 0x1F, 0x00);
5316 temp = pVBInfo->NewFlickerMode;
5318 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x0A, 0xFF, temp);
5320 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5323 if (pVBInfo->TVInfo & SetPALTV)
5328 if (pVBInfo->VDE <= tempax) {
5329 tempax -= pVBInfo->VDE;
5330 tempax = tempax >> 2;
5331 tempax = (tempax & 0x00FF) | ((tempax & 0x00FF) << 8);
5333 temp = (tempax & 0xFF00) >> 8;
5334 temp += (unsigned short) TimingPoint[0];
5336 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5337 | VB_XGI302LV | VB_XGI301C)) {
5338 if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO
5339 | SetCRT2ToSVIDEO | SetCRT2ToSCART
5340 | SetCRT2ToYPbPr)) {
5341 tempcx = pVBInfo->VGAHDE;
5342 if (tempcx >= 1024) {
5343 temp = 0x17; /* NTSC */
5344 if (pVBInfo->TVInfo & SetPALTV)
5345 temp = 0x19; /* PAL */
5350 XGINew_SetReg1(pVBInfo->Part2Port, 0x01, temp);
5352 temp = (tempax & 0xFF00) >> 8;
5353 temp += TimingPoint[1];
5355 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5356 | VB_XGI302LV | VB_XGI301C)) {
5357 if ((pVBInfo->VBInfo & (SetCRT2ToAVIDEO
5358 | SetCRT2ToSVIDEO | SetCRT2ToSCART
5359 | SetCRT2ToYPbPr))) {
5360 tempcx = pVBInfo->VGAHDE;
5361 if (tempcx >= 1024) {
5362 temp = 0x1D; /* NTSC */
5363 if (pVBInfo->TVInfo & SetPALTV)
5364 temp = 0x52; /* PAL */
5368 XGINew_SetReg1(pVBInfo->Part2Port, 0x02, temp);
5372 tempcx = pVBInfo->HT;
5374 if (XGI_IsLCDDualLink(pVBInfo))
5375 tempcx = tempcx >> 1;
5378 temp = tempcx & 0x00FF;
5379 XGINew_SetReg1(pVBInfo->Part2Port, 0x1B, temp);
5381 temp = (tempcx & 0xFF00) >> 8;
5382 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1D, ~0x0F, temp);
5384 tempcx = pVBInfo->HT >> 1;
5385 push1 = tempcx; /* push cx */
5388 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5391 temp = tempcx & 0x00FF;
5393 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x22, 0x0F, temp);
5395 tempbx = TimingPoint[j] | ((TimingPoint[j + 1]) << 8);
5398 temp = tempbx & 0x00FF;
5399 XGINew_SetReg1(pVBInfo->Part2Port, 0x24, temp);
5400 temp = (tempbx & 0xFF00) >> 8;
5402 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x25, 0x0F, temp);
5405 tempbx = tempbx + 8;
5406 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5407 tempbx = tempbx - 4;
5411 temp = (tempbx & 0x00FF) << 4;
5412 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x29, 0x0F, temp);
5415 tempcx += (TimingPoint[j] | ((TimingPoint[j + 1]) << 8));
5416 temp = tempcx & 0x00FF;
5417 XGINew_SetReg1(pVBInfo->Part2Port, 0x27, temp);
5418 temp = ((tempcx & 0xFF00) >> 8) << 4;
5419 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x28, 0x0F, temp);
5422 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5425 temp = tempcx & 0xFF;
5427 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x2A, 0x0F, temp);
5429 tempcx = push1; /* pop cx */
5431 temp = TimingPoint[j] | ((TimingPoint[j + 1]) << 8);
5433 temp = tempcx & 0x00FF;
5435 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x2D, 0x0F, temp);
5439 if (!(pVBInfo->VBInfo & SetCRT2ToTV)) {
5440 tempax = XGI_GetVGAHT2(pVBInfo);
5441 tempcx = tempax - 1;
5443 temp = tempcx & 0x00FF;
5444 XGINew_SetReg1(pVBInfo->Part2Port, 0x2E, temp);
5446 tempbx = pVBInfo->VDE;
5448 if (pVBInfo->VGAVDE == 360)
5450 if (pVBInfo->VGAVDE == 375)
5452 if (pVBInfo->VGAVDE == 405)
5455 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5456 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
5457 if (!(pVBInfo->TVInfo & (SetYPbPrMode525p
5458 | SetYPbPrMode750p)))
5459 tempbx = tempbx >> 1;
5461 tempbx = tempbx >> 1;
5465 temp = tempbx & 0x00FF;
5467 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5468 if (pVBInfo->VBType & VB_XGI301LV) {
5469 if (pVBInfo->TVInfo & SetYPbPrMode1080i) {
5470 if (pVBInfo->VBInfo & SetInSlaveMode) {
5476 if (pVBInfo->VBInfo & SetInSlaveMode) {
5483 XGINew_SetReg1(pVBInfo->Part2Port, 0x2F, temp);
5485 temp = (tempcx & 0xFF00) >> 8;
5486 temp |= ((tempbx & 0xFF00) >> 8) << 6;
5488 if (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)) {
5489 if (pVBInfo->VBType & VB_XGI301LV) {
5490 if (pVBInfo->TVInfo & SetYPbPrMode1080i) {
5493 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
5498 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
5503 XGINew_SetReg1(pVBInfo->Part2Port, 0x30, temp);
5505 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5506 | VB_XGI302LV | VB_XGI301C)) { /* TV gatingno */
5507 tempbx = pVBInfo->VDE;
5508 tempcx = tempbx - 2;
5510 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5511 if (!(pVBInfo->TVInfo & (SetYPbPrMode525p
5512 | SetYPbPrMode750p)))
5513 tempbx = tempbx >> 1;
5516 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
5518 if (tempcx & 0x0400)
5521 if (tempbx & 0x0400)
5524 XGINew_SetReg1(pVBInfo->Part4Port, 0x10, temp);
5527 temp = (((tempbx - 3) & 0x0300) >> 8) << 5;
5528 XGINew_SetReg1(pVBInfo->Part2Port, 0x46, temp);
5529 temp = (tempbx - 3) & 0x00FF;
5530 XGINew_SetReg1(pVBInfo->Part2Port, 0x47, temp);
5533 tempbx = tempbx & 0x00FF;
5535 if (!(modeflag & HalfDCLK)) {
5536 tempcx = pVBInfo->VGAHDE;
5537 if (tempcx >= pVBInfo->HDE) {
5545 if (pVBInfo->VBInfo & SetCRT2ToTV) { /*301b*/
5546 if (pVBInfo->VGAHDE >= 1024) {
5548 if (pVBInfo->VGAHDE >= 1280) {
5550 tempbx = tempbx & 0xDFFF;
5555 if (!(tempbx & 0x2000)) {
5556 if (modeflag & HalfDCLK)
5557 tempcx = (tempcx & 0xFF00) | ((tempcx & 0x00FF) << 1);
5560 tempeax = pVBInfo->VGAHDE;
5561 tempebx = (tempcx & 0xFF00) >> 8;
5562 longtemp = tempeax * tempebx;
5563 tempecx = tempcx & 0x00FF;
5564 longtemp = longtemp / tempecx;
5569 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5570 | VB_XGI302LV | VB_XGI301C)) {
5571 tempecx = tempecx * 8;
5574 longtemp = longtemp * tempecx;
5575 tempecx = pVBInfo->HDE;
5576 temp2 = longtemp % tempecx;
5577 tempeax = longtemp / tempecx;
5581 tempax = (unsigned short) tempeax;
5584 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5585 | VB_XGI302LV | VB_XGI301C)) {
5586 tempcx = ((tempax & 0xFF00) >> 5) >> 8;
5591 tempbx = (unsigned short) (((tempeax & 0x0000FF00) & 0x1F00)
5592 | (tempbx & 0x00FF));
5593 tempax = (unsigned short) (((tempeax & 0x000000FF) << 8)
5594 | (tempax & 0x00FF));
5595 temp = (tempax & 0xFF00) >> 8;
5597 temp = (tempax & 0x00FF) >> 8;
5600 XGINew_SetReg1(pVBInfo->Part2Port, 0x44, temp);
5601 temp = (tempbx & 0xFF00) >> 8;
5602 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x45, ~0x03F, temp);
5603 temp = tempcx & 0x00FF;
5605 if (tempbx & 0x2000)
5608 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
5611 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x46, ~0x1F, temp);
5612 if (pVBInfo->TVInfo & SetPALTV) {
5620 temp = tempbx & 0x00FF;
5621 XGINew_SetReg1(pVBInfo->Part2Port, 0x4b, temp);
5622 temp = tempcx & 0x00FF;
5623 XGINew_SetReg1(pVBInfo->Part2Port, 0x4c, temp);
5625 temp = ((tempcx & 0xFF00) >> 8) & 0x03;
5627 temp |= ((tempbx & 0xFF00) >> 8) & 0x03;
5629 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
5632 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5635 if (pVBInfo->TVInfo & SetYPbPrMode750p)
5639 XGINew_SetReg1(pVBInfo->Part2Port, 0x4d, temp);
5640 temp = XGINew_GetReg1(pVBInfo->Part2Port, 0x43); /* 301b change */
5641 XGINew_SetReg1(pVBInfo->Part2Port, 0x43, (unsigned short) (temp - 3));
5643 if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))) {
5644 if (pVBInfo->TVInfo & NTSC1024x768) {
5645 TimingPoint = XGI_NTSC1024AdjTime;
5646 for (i = 0x1c, j = 0; i <= 0x30; i++, j++) {
5647 XGINew_SetReg1(pVBInfo->Part2Port, i,
5650 XGINew_SetReg1(pVBInfo->Part2Port, 0x43, 0x72);
5654 /* [ycchen] 01/14/03 Modify for 301C PALM Support */
5655 if (pVBInfo->VBType & VB_XGI301C) {
5656 if (pVBInfo->TVInfo & SetPALMTV)
5657 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x4E, ~0x08,
5658 0x08); /* PALM Mode */
5661 if (pVBInfo->TVInfo & SetPALMTV) {
5662 tempax = (unsigned char) XGINew_GetReg1(pVBInfo->Part2Port,
5665 XGINew_SetRegAND(pVBInfo->Part2Port, 0x01, tempax);
5667 /* if ( !( pVBInfo->VBType & VB_XGI301C ) ) */
5668 XGINew_SetRegAND(pVBInfo->Part2Port, 0x00, 0xEF);
5671 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5672 if (!(pVBInfo->VBInfo & SetInSlaveMode))
5673 XGINew_SetReg1(pVBInfo->Part2Port, 0x0B, 0x00);
5676 if (pVBInfo->VBInfo & SetCRT2ToTV)
5680 static void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
5681 struct xgi_hw_device_info *HwDeviceExtension,
5682 unsigned short RefreshRateTableIndex,
5683 struct vb_device_info *pVBInfo)
5685 unsigned short push1, push2, pushbx, tempax, tempbx, tempcx, temp,
5686 tempah, tempbh, tempch, resinfo, modeflag, CRT1Index;
5688 struct XGI_LCDDesStruct *LCDBDesPtr = NULL;
5690 if (ModeNo <= 0x13) {
5691 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
5692 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
5694 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
5695 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
5697 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
5698 CRT1Index &= IndexMask;
5701 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
5704 tempbx = pVBInfo->HDE; /* RHACTE=HDE-1 */
5706 if (XGI_IsLCDDualLink(pVBInfo))
5707 tempbx = tempbx >> 1;
5710 temp = tempbx & 0x00FF;
5711 XGINew_SetReg1(pVBInfo->Part2Port, 0x2C, temp);
5712 temp = (tempbx & 0xFF00) >> 8;
5714 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x2B, 0x0F, temp);
5717 if (pVBInfo->LCDResInfo == Panel1280x1024) {
5718 if (pVBInfo->ModeType == ModeEGA) {
5719 if (pVBInfo->VGAHDE >= 1024) {
5721 if (pVBInfo->LCDInfo & LCDVESATiming)
5727 XGINew_SetReg1(pVBInfo->Part2Port, 0x0B, temp);
5728 tempbx = pVBInfo->VDE; /* RTVACTEO=(VDE-1)&0xFF */
5731 temp = tempbx & 0x00FF;
5732 XGINew_SetReg1(pVBInfo->Part2Port, 0x03, temp);
5733 temp = ((tempbx & 0xFF00) >> 8) & 0x07;
5734 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x0C, ~0x07, temp);
5736 tempcx = pVBInfo->VT - 1;
5738 temp = tempcx & 0x00FF; /* RVTVT=VT-1 */
5739 XGINew_SetReg1(pVBInfo->Part2Port, 0x19, temp);
5740 temp = (tempcx & 0xFF00) >> 8;
5742 XGINew_SetReg1(pVBInfo->Part2Port, 0x1A, temp);
5743 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x09, 0xF0, 0x00);
5744 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x0A, 0xF0, 0x00);
5745 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x17, 0xFB, 0x00);
5746 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x18, 0xDF, 0x00);
5748 /* Customized LCDB Des no add */
5750 LCDBDesPtr = (struct XGI_LCDDesStruct *) XGI_GetLcdPtr(tempbx, ModeNo,
5751 ModeIdIndex, RefreshRateTableIndex, pVBInfo);
5752 tempah = pVBInfo->LCDResInfo;
5753 tempah &= PanelResInfo;
5755 if ((tempah == Panel1024x768) || (tempah == Panel1024x768x75)) {
5758 } else if ((tempah == Panel1280x1024) || (tempah == Panel1280x1024x75)) {
5761 } else if (tempah == Panel1400x1050) {
5769 if (pVBInfo->LCDInfo & EnableScalingLCD) {
5770 tempbx = pVBInfo->HDE;
5771 tempcx = pVBInfo->VDE;
5775 tempax = pVBInfo->VT;
5776 pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES;
5777 pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS;
5778 pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES;
5779 pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS;
5780 tempbx = pVBInfo->LCDVDES;
5783 if (tempcx >= tempax)
5784 tempcx -= tempax; /* lcdvdes */
5786 temp = tempbx & 0x00FF; /* RVEQ1EQ=lcdvdes */
5787 XGINew_SetReg1(pVBInfo->Part2Port, 0x05, temp);
5788 temp = tempcx & 0x00FF;
5789 XGINew_SetReg1(pVBInfo->Part2Port, 0x06, temp);
5790 tempch = ((tempcx & 0xFF00) >> 8) & 0x07;
5791 tempbh = ((tempbx & 0xFF00) >> 8) & 0x07;
5793 tempah = tempah << 3;
5795 XGINew_SetReg1(pVBInfo->Part2Port, 0x02, tempah);
5798 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
5800 tempax = pVBInfo->VT;
5801 tempbx = pVBInfo->LCDVRS;
5803 /* if (SetLCD_Info & EnableScalingLCD) */
5805 if (tempcx >= tempax)
5808 temp = tempbx & 0x00FF; /* RTVACTEE=lcdvrs */
5809 XGINew_SetReg1(pVBInfo->Part2Port, 0x04, temp);
5810 temp = (tempbx & 0xFF00) >> 8;
5812 temp |= (tempcx & 0x000F);
5813 XGINew_SetReg1(pVBInfo->Part2Port, 0x01, temp);
5815 tempax = pVBInfo->HT;
5816 tempbx = pVBInfo->LCDHDES;
5819 if (XGI_IsLCDDualLink(pVBInfo)) {
5820 tempax = tempax >> 1;
5821 tempbx = tempbx >> 1;
5822 tempcx = tempcx >> 1;
5825 if (pVBInfo->VBType & VB_XGI302LV)
5828 if (pVBInfo->VBType & VB_XGI301C) /* tap4 */
5833 if (tempcx >= tempax)
5836 temp = tempbx & 0x00FF;
5837 XGINew_SetReg1(pVBInfo->Part2Port, 0x1F, temp); /* RHBLKE=lcdhdes */
5838 temp = ((tempbx & 0xFF00) >> 8) << 4;
5839 XGINew_SetReg1(pVBInfo->Part2Port, 0x20, temp);
5840 temp = tempcx & 0x00FF;
5841 XGINew_SetReg1(pVBInfo->Part2Port, 0x23, temp); /* RHEQPLE=lcdhdee */
5842 temp = (tempcx & 0xFF00) >> 8;
5843 XGINew_SetReg1(pVBInfo->Part2Port, 0x25, temp);
5846 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
5848 tempax = pVBInfo->HT;
5849 tempbx = pVBInfo->LCDHRS;
5850 /* if ( SetLCD_Info & EnableScalingLCD) */
5851 if (XGI_IsLCDDualLink(pVBInfo)) {
5852 tempax = tempax >> 1;
5853 tempbx = tempbx >> 1;
5854 tempcx = tempcx >> 1;
5857 if (pVBInfo->VBType & VB_XGI302LV)
5862 if (tempcx >= tempax)
5865 temp = tempbx & 0x00FF; /* RHBURSTS=lcdhrs */
5866 XGINew_SetReg1(pVBInfo->Part2Port, 0x1C, temp);
5868 temp = (tempbx & 0xFF00) >> 8;
5870 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1D, ~0x0F0, temp);
5871 temp = tempcx & 0x00FF; /* RHSYEXP2S=lcdhre */
5872 XGINew_SetReg1(pVBInfo->Part2Port, 0x21, temp);
5874 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
5875 if (pVBInfo->VGAVDE == 525) {
5876 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
5877 | VB_XGI301LV | VB_XGI302LV
5883 XGINew_SetReg1(pVBInfo->Part2Port, 0x2f, temp);
5884 XGINew_SetReg1(pVBInfo->Part2Port, 0x30, 0xB3);
5887 if (pVBInfo->VGAVDE == 420) {
5888 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
5889 | VB_XGI301LV | VB_XGI302LV
5894 XGINew_SetReg1(pVBInfo->Part2Port, 0x2f, temp);
5899 /* --------------------------------------------------------------------- */
5900 /* Function : XGI_GetTap4Ptr */
5902 /* Output : di -> Tap4 Reg. Setting Pointer */
5904 /* --------------------------------------------------------------------- */
5905 static struct XGI301C_Tap4TimingStruct *XGI_GetTap4Ptr(unsigned short tempcx,
5906 struct vb_device_info *pVBInfo)
5908 unsigned short tempax, tempbx, i;
5910 struct XGI301C_Tap4TimingStruct *Tap4TimingPtr;
5913 tempax = pVBInfo->VGAHDE;
5914 tempbx = pVBInfo->HDE;
5916 tempax = pVBInfo->VGAVDE;
5917 tempbx = pVBInfo->VDE;
5920 if (tempax < tempbx)
5921 return &EnlargeTap4Timing[0];
5922 else if (tempax == tempbx)
5923 return &NoScaleTap4Timing[0]; /* 1:1 */
5925 Tap4TimingPtr = NTSCTap4Timing; /* NTSC */
5927 if (pVBInfo->TVInfo & SetPALTV)
5928 Tap4TimingPtr = PALTap4Timing;
5930 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
5931 if (pVBInfo->TVInfo & SetYPbPrMode525i)
5932 Tap4TimingPtr = YPbPr525iTap4Timing;
5933 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5934 Tap4TimingPtr = YPbPr525pTap4Timing;
5935 if (pVBInfo->TVInfo & SetYPbPrMode750p)
5936 Tap4TimingPtr = YPbPr750pTap4Timing;
5939 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5940 Tap4TimingPtr = HiTVTap4Timing;
5943 while (Tap4TimingPtr[i].DE != 0xFFFF) {
5944 if (Tap4TimingPtr[i].DE == tempax)
5948 return &Tap4TimingPtr[i];
5951 static void XGI_SetTap4Regs(struct vb_device_info *pVBInfo)
5953 unsigned short i, j;
5955 struct XGI301C_Tap4TimingStruct *Tap4TimingPtr;
5957 if (!(pVBInfo->VBType & VB_XGI301C))
5961 XGINew_SetRegAND(pVBInfo->Part2Port, 0x4E, 0xEB); /* Disable Tap4 */
5962 #else /* Tap4 Setting */
5964 Tap4TimingPtr = XGI_GetTap4Ptr(0, pVBInfo); /* Set Horizontal Scaling */
5965 for (i = 0x80, j = 0; i <= 0xBF; i++, j++)
5966 XGINew_SetReg1(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]);
5968 if ((pVBInfo->VBInfo & SetCRT2ToTV) && (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV))) {
5969 Tap4TimingPtr = XGI_GetTap4Ptr(1, pVBInfo); /* Set Vertical Scaling */
5970 for (i = 0xC0, j = 0; i < 0xFF; i++, j++)
5971 XGINew_SetReg1(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]);
5974 if ((pVBInfo->VBInfo & SetCRT2ToTV) && (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)))
5975 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x4E, ~0x14, 0x04); /* Enable V.Scaling */
5977 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x4E, ~0x14, 0x10); /* Enable H.Scaling */
5981 static void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex,
5982 struct vb_device_info *pVBInfo)
5985 unsigned char *tempdi;
5986 unsigned short modeflag;
5989 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
5991 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
5993 XGINew_SetReg1(pVBInfo->Part3Port, 0x00, 0x00);
5994 if (pVBInfo->TVInfo & SetPALTV) {
5995 XGINew_SetReg1(pVBInfo->Part3Port, 0x13, 0xFA);
5996 XGINew_SetReg1(pVBInfo->Part3Port, 0x14, 0xC8);
5998 XGINew_SetReg1(pVBInfo->Part3Port, 0x13, 0xF5);
5999 XGINew_SetReg1(pVBInfo->Part3Port, 0x14, 0xB7);
6002 if (!(pVBInfo->VBInfo & SetCRT2ToTV))
6005 if (pVBInfo->TVInfo & SetPALMTV) {
6006 XGINew_SetReg1(pVBInfo->Part3Port, 0x13, 0xFA);
6007 XGINew_SetReg1(pVBInfo->Part3Port, 0x14, 0xC8);
6008 XGINew_SetReg1(pVBInfo->Part3Port, 0x3D, 0xA8);
6011 if ((pVBInfo->VBInfo & SetCRT2ToHiVisionTV) || (pVBInfo->VBInfo
6012 & SetCRT2ToYPbPr)) {
6013 if (pVBInfo->TVInfo & SetYPbPrMode525i)
6016 tempdi = pVBInfo->HiTVGroup3Data;
6017 if (pVBInfo->SetFlag & TVSimuMode) {
6018 tempdi = pVBInfo->HiTVGroup3Simu;
6019 if (!(modeflag & Charx8Dot))
6020 tempdi = pVBInfo->HiTVGroup3Text;
6023 if (pVBInfo->TVInfo & SetYPbPrMode525p)
6024 tempdi = pVBInfo->Ren525pGroup3;
6026 if (pVBInfo->TVInfo & SetYPbPrMode750p)
6027 tempdi = pVBInfo->Ren750pGroup3;
6029 for (i = 0; i <= 0x3E; i++)
6030 XGINew_SetReg1(pVBInfo->Part3Port, i, tempdi[i]);
6032 if (pVBInfo->VBType & VB_XGI301C) { /* Marcovision */
6033 if (pVBInfo->TVInfo & SetYPbPrMode525p)
6034 XGINew_SetReg1(pVBInfo->Part3Port, 0x28, 0x3f);
6038 } /* {end of XGI_SetGroup3} */
6040 static void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex,
6041 unsigned short RefreshRateTableIndex,
6042 struct xgi_hw_device_info *HwDeviceExtension,
6043 struct vb_device_info *pVBInfo)
6045 unsigned short tempax, tempcx, tempbx, modeflag, temp, temp2;
6047 unsigned long tempebx, tempeax, templong;
6050 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
6052 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
6054 temp = pVBInfo->RVBHCFACT;
6055 XGINew_SetReg1(pVBInfo->Part4Port, 0x13, temp);
6057 tempbx = pVBInfo->RVBHCMAX;
6058 temp = tempbx & 0x00FF;
6059 XGINew_SetReg1(pVBInfo->Part4Port, 0x14, temp);
6060 temp2 = ((tempbx & 0xFF00) >> 8) << 7;
6061 tempcx = pVBInfo->VGAHT - 1;
6062 temp = tempcx & 0x00FF;
6063 XGINew_SetReg1(pVBInfo->Part4Port, 0x16, temp);
6065 temp = ((tempcx & 0xFF00) >> 8) << 3;
6068 tempcx = pVBInfo->VGAVT - 1;
6069 if (!(pVBInfo->VBInfo & SetCRT2ToTV))
6072 temp = tempcx & 0x00FF;
6073 XGINew_SetReg1(pVBInfo->Part4Port, 0x17, temp);
6074 temp = temp2 | ((tempcx & 0xFF00) >> 8);
6075 XGINew_SetReg1(pVBInfo->Part4Port, 0x15, temp);
6076 XGINew_SetRegOR(pVBInfo->Part4Port, 0x0D, 0x08);
6077 tempcx = pVBInfo->VBInfo;
6078 tempbx = pVBInfo->VGAHDE;
6080 if (modeflag & HalfDCLK)
6081 tempbx = tempbx >> 1;
6083 if (XGI_IsLCDDualLink(pVBInfo))
6084 tempbx = tempbx >> 1;
6086 if (tempcx & SetCRT2ToHiVisionTV) {
6092 } else if (tempcx & SetCRT2ToTV) {
6098 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
6105 if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)) {
6107 if (pVBInfo->VGAHDE == 1280)
6109 if (pVBInfo->VGAHDE == 1024)
6112 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x0E, ~0xEF, temp);
6114 tempebx = pVBInfo->VDE;
6116 if (tempcx & SetCRT2ToHiVisionTV) {
6117 if (!(temp & 0xE000))
6118 tempbx = tempbx >> 1;
6121 tempcx = pVBInfo->RVBHRS;
6122 temp = tempcx & 0x00FF;
6123 XGINew_SetReg1(pVBInfo->Part4Port, 0x18, temp);
6125 tempeax = pVBInfo->VGAVDE;
6128 if (tempeax <= tempebx) {
6129 tempcx = (tempcx & (~0x4000));
6130 tempeax = pVBInfo->VGAVDE;
6135 templong = (tempeax * 256 * 1024) % tempebx;
6136 tempeax = (tempeax * 256 * 1024) / tempebx;
6142 temp = (unsigned short) (tempebx & 0x000000FF);
6143 XGINew_SetReg1(pVBInfo->Part4Port, 0x1B, temp);
6145 temp = (unsigned short) ((tempebx & 0x0000FF00) >> 8);
6146 XGINew_SetReg1(pVBInfo->Part4Port, 0x1A, temp);
6147 tempbx = (unsigned short) (tempebx >> 16);
6148 temp = tempbx & 0x00FF;
6150 temp |= ((tempcx & 0xFF00) >> 8);
6151 XGINew_SetReg1(pVBInfo->Part4Port, 0x19, temp);
6154 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
6155 | VB_XGI302LV | VB_XGI301C)) {
6157 XGINew_SetReg1(pVBInfo->Part4Port, 0x1C, temp);
6158 tempax = pVBInfo->VGAHDE;
6159 if (modeflag & HalfDCLK)
6160 tempax = tempax >> 1;
6162 if (XGI_IsLCDDualLink(pVBInfo))
6163 tempax = tempax >> 1;
6165 /* if((pVBInfo->VBInfo&(SetCRT2ToLCD))||((pVBInfo->TVInfo&SetYPbPrMode525p)||(pVBInfo->TVInfo&SetYPbPrMode750p))) { */
6166 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
6170 if (pVBInfo->VGAHDE > 800) {
6171 if (pVBInfo->VGAHDE == 1024)
6172 tempax = (tempax * 25 / 32) - 1;
6174 tempax = (tempax * 20 / 32) - 1;
6180 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVisionTV)) {
6181 if (pVBInfo->VBType & VB_XGI301LV) {
6182 if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i))) {
6183 if (pVBInfo->VGAHDE > 800) {
6184 if (pVBInfo->VGAHDE == 1024)
6185 tempax = (tempax * 25 / 32) - 1;
6187 tempax = (tempax * 20 / 32) - 1;
6191 if (pVBInfo->VGAHDE > 800) {
6192 if (pVBInfo->VGAHDE == 1024)
6193 tempax = (tempax * 25 / 32) - 1;
6195 tempax = (tempax * 20 / 32) - 1;
6201 temp = (tempax & 0xFF00) >> 8;
6202 temp = ((temp & 0x0003) << 4);
6203 XGINew_SetReg1(pVBInfo->Part4Port, 0x1E, temp);
6204 temp = (tempax & 0x00FF);
6205 XGINew_SetReg1(pVBInfo->Part4Port, 0x1D, temp);
6207 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVisionTV)) {
6208 if (pVBInfo->VGAHDE > 800)
6209 XGINew_SetRegOR(pVBInfo->Part4Port, 0x1E, 0x08);
6214 if (pVBInfo->VBInfo & SetCRT2ToTV) {
6215 if (!(pVBInfo->TVInfo & (NTSC1024x768
6216 | SetYPbPrMode525p | SetYPbPrMode750p
6217 | SetYPbPrMode1080i))) {
6219 if ((pVBInfo->VBInfo & SetInSlaveMode)
6220 && (!(pVBInfo->TVInfo
6226 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x1F, 0x00C0, temp);
6227 tempbx = pVBInfo->HT;
6228 if (XGI_IsLCDDualLink(pVBInfo))
6229 tempbx = tempbx >> 1;
6230 tempbx = (tempbx >> 1) - 2;
6231 temp = ((tempbx & 0x0700) >> 8) << 3;
6232 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x21, 0x00C0, temp);
6233 temp = tempbx & 0x00FF;
6234 XGINew_SetReg1(pVBInfo->Part4Port, 0x22, temp);
6238 if (pVBInfo->ISXPDOS == 0)
6239 XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex,
6243 static void XGINew_EnableCRT2(struct vb_device_info *pVBInfo)
6245 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x1E, 0xFF, 0x20);
6248 static void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex,
6249 struct vb_device_info *pVBInfo)
6251 unsigned short Pindex, Pdata;
6253 Pindex = pVBInfo->Part5Port;
6254 Pdata = pVBInfo->Part5Port + 1;
6255 if (pVBInfo->ModeType == ModeVGA) {
6256 if (!(pVBInfo->VBInfo & (SetInSlaveMode | LoadDACFlag
6257 | CRT2DisplayFlag))) {
6258 XGINew_EnableCRT2(pVBInfo);
6259 /* LoadDAC2(pVBInfo->Part5Port, ModeNo, ModeIdIndex); */
6265 static void XGI_EnableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension,
6266 struct vb_device_info *pVBInfo)
6268 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x63, 0xBF, 0x40);
6271 static void XGI_DisableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension,
6272 struct vb_device_info *pVBInfo)
6275 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x63, 0xBF, 0x00);
6278 /*----------------------------------------------------------------------------*/
6280 /* bl[5] : 1;LVDS signal on */
6281 /* bl[1] : 1;LVDS backlight on */
6282 /* bl[0] : 1:LVDS VDD on */
6283 /* bh: 100000b : clear bit 5, to set bit5 */
6284 /* 000010b : clear bit 1, to set bit1 */
6285 /* 000001b : clear bit 0, to set bit0 */
6286 /*----------------------------------------------------------------------------*/
6287 void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl,
6288 struct vb_device_info *pVBInfo)
6290 unsigned char CR4A, temp;
6292 CR4A = XGINew_GetReg1(pVBInfo->P3d4, 0x4A);
6295 XGINew_SetRegAND(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */
6297 if (tempbh & 0x20) {
6298 temp = (tempbl >> 4) & 0x02;
6300 XGINew_SetRegANDOR(pVBInfo->P3d4, 0xB4, ~0x02, temp); /* CR B4[1] */
6304 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x48);
6306 temp = XG21GPIODataTransfer(temp);
6309 XGINew_SetReg1(pVBInfo->P3d4, 0x48, temp);
6312 void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl,
6313 struct vb_device_info *pVBInfo)
6315 unsigned char CR4A, temp;
6316 unsigned short tempbh0, tempbl0;
6325 if (tempbh & 0x20) {
6326 temp = (tempbl >> 4) & 0x02;
6328 XGINew_SetRegANDOR(pVBInfo->P3d4, 0xB4, ~0x02, temp); /* CR B4[1] */
6331 XGINew_SetRegANDOR(pVBInfo->P3d4, 0xB4, ~tempbh0, tempbl0);
6333 CR4A = XGINew_GetReg1(pVBInfo->P3d4, 0x4A);
6337 tempbl <<= 2; /* GPIOC,GPIOD */
6338 XGINew_SetRegAND(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */
6339 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x48, ~tempbh, tempbl);
6342 /* --------------------------------------------------------------------- */
6343 unsigned short XGI_GetLVDSOEMTableIndex(struct vb_device_info *pVBInfo)
6345 unsigned short index;
6347 index = XGINew_GetReg1(pVBInfo->P3d4, 0x36);
6348 if (index < sizeof(XGI21_LCDCapList)
6349 / sizeof(struct XGI21_LVDSCapStruct))
6354 /* --------------------------------------------------------------------- */
6355 /* Function : XGI_XG21SetPanelDelay */
6359 /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
6360 /* : bl : 2 ; T2 : the duration signal on and Vdd on */
6361 /* : bl : 3 ; T3 : the duration between CPL off and signal off */
6362 /* : bl : 4 ; T4 : the duration signal off and Vdd off */
6363 /* --------------------------------------------------------------------- */
6364 void XGI_XG21SetPanelDelay(unsigned short tempbl,
6365 struct vb_device_info *pVBInfo)
6367 unsigned short index;
6369 index = XGI_GetLVDSOEMTableIndex(pVBInfo);
6371 mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S1);
6374 mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S2);
6377 mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S3);
6380 mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S4);
6383 unsigned char XGI_XG21CheckLVDSMode(unsigned short ModeNo,
6384 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
6386 unsigned short xres, yres, colordepth, modeflag, resindex,
6389 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
6390 if (ModeNo <= 0x13) {
6391 xres = pVBInfo->StResInfo[resindex].HTotal;
6392 yres = pVBInfo->StResInfo[resindex].VTotal;
6393 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
6395 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
6396 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
6397 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */
6400 if (!(modeflag & Charx8Dot)) {
6405 if (ModeNo > 0x13) {
6406 if ((ModeNo > 0x13) && (modeflag & HalfDCLK))
6409 if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
6414 lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo);
6415 if (xres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE))
6418 if (yres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE))
6421 if (ModeNo > 0x13) {
6423 != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE))
6425 != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE))) {
6426 colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex,
6436 void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo)
6440 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37); /* D[0] 1: 18bit */
6441 temp = (temp & 1) << 6;
6442 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x06, ~0x40, temp); /* SR06[6] 18bit Dither */
6443 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */
6447 void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo)
6451 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37); /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */
6452 temp = (temp & 3) << 6;
6453 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x06, ~0xc0, temp & 0x80); /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */
6454 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */
6458 static void XGI_SetXG21LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex,
6459 struct vb_device_info *pVBInfo)
6461 unsigned char temp, Miscdata;
6462 unsigned short xres, yres, modeflag, resindex, lvdstableindex;
6463 unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE;
6464 unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE;
6465 unsigned short value;
6467 lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo);
6469 temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability
6470 & (LCDPolarity << 8)) >> 8);
6471 temp &= LCDPolarity;
6472 Miscdata = (unsigned char) inb(pVBInfo->P3cc);
6474 outb((Miscdata & 0x3F) | temp, pVBInfo->P3c2);
6476 temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability
6478 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80); /* SR35[7] FP VSync polarity */
6479 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); /* SR30[5] FP HSync polarity */
6481 XGI_SetXG21FPBits(pVBInfo);
6482 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
6483 if (ModeNo <= 0x13) {
6484 xres = pVBInfo->StResInfo[resindex].HTotal;
6485 yres = pVBInfo->StResInfo[resindex].VTotal;
6486 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
6488 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
6489 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
6490 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */
6493 if (!(modeflag & Charx8Dot))
6494 xres = xres * 8 / 9;
6496 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
6498 LVDSHBS = xres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE
6500 if ((ModeNo <= 0x13) && (modeflag & HalfDCLK))
6501 LVDSHBS -= xres / 4;
6503 if (LVDSHBS > LVDSHT)
6506 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP;
6507 if (LVDSHRS > LVDSHT)
6510 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC;
6511 if (LVDSHRE > LVDSHT)
6514 LVDSHBE = LVDSHBS + LVDSHT
6515 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE;
6517 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
6519 LVDSVBS = yres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE
6521 if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
6522 LVDSVBS += yres / 2;
6524 if (LVDSVBS > LVDSVT)
6527 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP;
6528 if (LVDSVRS > LVDSVT)
6531 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC;
6532 if (LVDSVRE > LVDSVT)
6535 LVDSVBE = LVDSVBS + LVDSVT
6536 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE;
6538 temp = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11);
6539 XGINew_SetReg1(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */
6541 if (!(modeflag & Charx8Dot))
6542 XGINew_SetRegOR(pVBInfo->P3c4, 0x1, 0x1);
6544 /* HT SR0B[1:0] CR00 */
6545 value = (LVDSHT >> 3) - 5;
6546 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8);
6547 XGINew_SetReg1(pVBInfo->P3d4, 0x0, (value & 0xFF));
6549 /* HBS SR0B[5:4] CR02 */
6550 value = (LVDSHBS >> 3) - 1;
6551 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4);
6552 XGINew_SetReg1(pVBInfo->P3d4, 0x2, (value & 0xFF));
6554 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
6555 value = (LVDSHBE >> 3) - 1;
6556 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6);
6557 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2);
6558 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F);
6560 /* HRS SR0B[7:6] CR04 */
6561 value = (LVDSHRS >> 3) + 2;
6562 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2);
6563 XGINew_SetReg1(pVBInfo->P3d4, 0x4, (value & 0xFF));
6565 /* Panel HRS SR2F[1:0] SR2E[7:0] */
6567 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8);
6568 XGINew_SetReg1(pVBInfo->P3c4, 0x2E, (value & 0xFF));
6570 /* HRE SR0C[2] CR05[4:0] */
6571 value = (LVDSHRE >> 3) + 2;
6572 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3);
6573 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F);
6575 /* Panel HRE SR2F[7:2] */
6577 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2);
6579 /* VT SR0A[0] CR07[5][0] CR06 */
6581 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10);
6582 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4);
6583 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8);
6584 XGINew_SetReg1(pVBInfo->P3d4, 0x06, (value & 0xFF));
6586 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
6587 value = LVDSVBS - 1;
6588 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8);
6589 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4);
6590 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5);
6591 XGINew_SetReg1(pVBInfo->P3d4, 0x15, (value & 0xFF));
6593 /* VBE SR0A[4] CR16 */
6594 value = LVDSVBE - 1;
6595 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4);
6596 XGINew_SetReg1(pVBInfo->P3d4, 0x16, (value & 0xFF));
6598 /* VRS SR0A[3] CR7[7][2] CR10 */
6599 value = LVDSVRS - 1;
6600 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7);
6601 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2);
6602 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6);
6603 XGINew_SetReg1(pVBInfo->P3d4, 0x10, (value & 0xFF));
6605 /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */
6606 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x3F, ~0x03, (value & 0x600) >> 9);
6607 XGINew_SetReg1(pVBInfo->P3c4, 0x34, (value >> 1) & 0xFF);
6608 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x33, ~0x01, value & 0x01);
6610 /* VRE SR0A[5] CR11[3:0] */
6611 value = LVDSVRE - 1;
6612 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1);
6613 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F);
6615 /* Panel VRE SR3F[7:2] *//* SR3F[7] has to be 0, h/w bug */
6616 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x3F, ~0xFC, (value << 2) & 0x7C);
6618 for (temp = 0, value = 0; temp < 3; temp++) {
6620 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x31, ~0x30, value);
6621 XGINew_SetReg1(pVBInfo->P3c4,
6623 pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1);
6624 XGINew_SetReg1(pVBInfo->P3c4,
6626 pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2);
6630 if (!(modeflag & Charx8Dot)) {
6631 inb(pVBInfo->P3da); /* reset 3da */
6632 outb(0x13, pVBInfo->P3c0); /* set index */
6633 outb(0x00, pVBInfo->P3c0); /* set data, panning = 0, shift left 1 dot*/
6635 inb(pVBInfo->P3da); /* Enable Attribute */
6636 outb(0x20, pVBInfo->P3c0);
6638 inb(pVBInfo->P3da); /* reset 3da */
6643 /* no shadow case */
6644 static void XGI_SetXG27LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex,
6645 struct vb_device_info *pVBInfo)
6647 unsigned char temp, Miscdata;
6648 unsigned short xres, yres, modeflag, resindex, lvdstableindex;
6649 unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE;
6650 unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE;
6651 unsigned short value;
6653 lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo);
6654 temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability
6655 & (LCDPolarity << 8)) >> 8);
6656 temp &= LCDPolarity;
6657 Miscdata = (unsigned char) inb(pVBInfo->P3cc);
6659 outb((Miscdata & 0x3F) | temp, pVBInfo->P3c2);
6661 temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability
6663 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80); /* SR35[7] FP VSync polarity */
6664 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); /* SR30[5] FP HSync polarity */
6666 XGI_SetXG27FPBits(pVBInfo);
6667 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
6668 if (ModeNo <= 0x13) {
6669 xres = pVBInfo->StResInfo[resindex].HTotal;
6670 yres = pVBInfo->StResInfo[resindex].VTotal;
6671 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
6673 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
6674 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
6675 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */
6678 if (!(modeflag & Charx8Dot))
6679 xres = xres * 8 / 9;
6681 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
6683 LVDSHBS = xres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE
6685 if ((ModeNo <= 0x13) && (modeflag & HalfDCLK))
6686 LVDSHBS -= xres / 4;
6688 if (LVDSHBS > LVDSHT)
6691 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP;
6692 if (LVDSHRS > LVDSHT)
6695 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC;
6696 if (LVDSHRE > LVDSHT)
6699 LVDSHBE = LVDSHBS + LVDSHT
6700 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE;
6702 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
6704 LVDSVBS = yres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE
6706 if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
6707 LVDSVBS += yres / 2;
6709 if (LVDSVBS > LVDSVT)
6712 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP;
6713 if (LVDSVRS > LVDSVT)
6716 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC;
6717 if (LVDSVRE > LVDSVT)
6720 LVDSVBE = LVDSVBS + LVDSVT
6721 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE;
6723 temp = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11);
6724 XGINew_SetReg1(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */
6726 if (!(modeflag & Charx8Dot))
6727 XGINew_SetRegOR(pVBInfo->P3c4, 0x1, 0x1);
6729 /* HT SR0B[1:0] CR00 */
6730 value = (LVDSHT >> 3) - 5;
6731 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8);
6732 XGINew_SetReg1(pVBInfo->P3d4, 0x0, (value & 0xFF));
6734 /* HBS SR0B[5:4] CR02 */
6735 value = (LVDSHBS >> 3) - 1;
6736 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4);
6737 XGINew_SetReg1(pVBInfo->P3d4, 0x2, (value & 0xFF));
6739 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
6740 value = (LVDSHBE >> 3) - 1;
6741 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6);
6742 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2);
6743 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F);
6745 /* HRS SR0B[7:6] CR04 */
6746 value = (LVDSHRS >> 3) + 2;
6747 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2);
6748 XGINew_SetReg1(pVBInfo->P3d4, 0x4, (value & 0xFF));
6750 /* Panel HRS SR2F[1:0] SR2E[7:0] */
6752 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8);
6753 XGINew_SetReg1(pVBInfo->P3c4, 0x2E, (value & 0xFF));
6755 /* HRE SR0C[2] CR05[4:0] */
6756 value = (LVDSHRE >> 3) + 2;
6757 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3);
6758 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F);
6760 /* Panel HRE SR2F[7:2] */
6762 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2);
6764 /* VT SR0A[0] CR07[5][0] CR06 */
6766 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10);
6767 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4);
6768 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8);
6769 XGINew_SetReg1(pVBInfo->P3d4, 0x06, (value & 0xFF));
6771 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
6772 value = LVDSVBS - 1;
6773 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8);
6774 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4);
6775 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5);
6776 XGINew_SetReg1(pVBInfo->P3d4, 0x15, (value & 0xFF));
6778 /* VBE SR0A[4] CR16 */
6779 value = LVDSVBE - 1;
6780 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4);
6781 XGINew_SetReg1(pVBInfo->P3d4, 0x16, (value & 0xFF));
6783 /* VRS SR0A[3] CR7[7][2] CR10 */
6784 value = LVDSVRS - 1;
6785 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7);
6786 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2);
6787 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6);
6788 XGINew_SetReg1(pVBInfo->P3d4, 0x10, (value & 0xFF));
6790 /* Panel VRS SR35[2:0] SR34[7:0] */
6791 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x07, (value & 0x700) >> 8);
6792 XGINew_SetReg1(pVBInfo->P3c4, 0x34, value & 0xFF);
6794 /* VRE SR0A[5] CR11[3:0] */
6795 value = LVDSVRE - 1;
6796 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1);
6797 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F);
6799 /* Panel VRE SR3F[7:2] */
6800 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x3F, ~0xFC, (value << 2) & 0xFC);
6802 for (temp = 0, value = 0; temp < 3; temp++) {
6804 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x31, ~0x30, value);
6805 XGINew_SetReg1(pVBInfo->P3c4,
6807 pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1);
6808 XGINew_SetReg1(pVBInfo->P3c4,
6810 pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2);
6814 if (!(modeflag & Charx8Dot)) {
6815 inb(pVBInfo->P3da); /* reset 3da */
6816 outb(0x13, pVBInfo->P3c0); /* set index */
6817 outb(0x00, pVBInfo->P3c0); /* set data, panning = 0, shift left 1 dot*/
6819 inb(pVBInfo->P3da); /* Enable Attribute */
6820 outb(0x20, pVBInfo->P3c0);
6822 inb(pVBInfo->P3da); /* reset 3da */
6827 /* --------------------------------------------------------------------- */
6828 /* Function : XGI_IsLCDON */
6830 /* Output : 0 : Skip PSC Control */
6831 /* 1: Disable PSC */
6833 /* --------------------------------------------------------------------- */
6834 static unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo)
6836 unsigned short tempax;
6838 tempax = pVBInfo->VBInfo;
6839 if (tempax & SetCRT2ToDualEdge)
6841 else if (tempax & (DisableCRT2Display | SwitchToCRT2 | SetSimuScanMode))
6847 /* --------------------------------------------------------------------- */
6848 /* Function : XGI_DisableChISLCD */
6850 /* Output : 0 -> Not LCD Mode */
6852 /* --------------------------------------------------------------------- */
6853 static unsigned char XGI_DisableChISLCD(struct vb_device_info *pVBInfo)
6855 unsigned short tempbx, tempah;
6857 tempbx = pVBInfo->SetFlag & (DisableChA | DisableChB);
6858 tempah = ~((unsigned short) XGINew_GetReg1(pVBInfo->Part1Port, 0x2E));
6860 if (tempbx & (EnableChA | DisableChA)) {
6861 if (!(tempah & 0x08)) /* Chk LCDA Mode */
6865 if (!(tempbx & (EnableChB | DisableChB)))
6868 if (tempah & 0x01) /* Chk LCDB Mode */
6874 /* --------------------------------------------------------------------- */
6875 /* Function : XGI_EnableChISLCD */
6877 /* Output : 0 -> Not LCD mode */
6879 /* --------------------------------------------------------------------- */
6880 static unsigned char XGI_EnableChISLCD(struct vb_device_info *pVBInfo)
6882 unsigned short tempbx, tempah;
6884 tempbx = pVBInfo->SetFlag & (EnableChA | EnableChB);
6885 tempah = ~((unsigned short) XGINew_GetReg1(pVBInfo->Part1Port, 0x2E));
6887 if (tempbx & (EnableChA | DisableChA)) {
6888 if (!(tempah & 0x08)) /* Chk LCDA Mode */
6892 if (!(tempbx & (EnableChB | DisableChB)))
6895 if (tempah & 0x01) /* Chk LCDB Mode */
6901 void XGI_DisableBridge(struct xgi_hw_device_info *HwDeviceExtension,
6902 struct vb_device_info *pVBInfo)
6904 unsigned short tempah = 0;
6906 if (pVBInfo->SetFlag == Win9xDOSMode)
6911 if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2toLCDA)) || (XGI_DisableChISLCD(pVBInfo))) {
6912 if (!XGI_IsLCDON(pVBInfo)) {
6914 tempbx = XGINew_GetCH7005(0x61);
6915 if (tempbx < 0x01) // first time we power up
6916 XGINew_SetCH7005(0x0066); // and disable power sequence
6918 XGINew_SetCH7005(0x5f66); // leave VDD on - disable power
6925 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
6926 | VB_XGI302LV | VB_XGI301C)) {
6928 if (!(pVBInfo->VBInfo & (DisableCRT2Display | SetSimuScanMode))) {
6929 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
6930 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
6931 tempah = 0x7F; /* Disable Channel A */
6932 if (!(pVBInfo->VBInfo & SetCRT2ToLCDA))
6933 tempah = 0xBF; /* Disable Channel B */
6935 if (pVBInfo->SetFlag & DisableChB)
6936 tempah &= 0xBF; /* force to disable Cahnnel */
6938 if (pVBInfo->SetFlag & DisableChA)
6939 tempah &= 0x7F; /* Force to disable Channel B */
6944 XGINew_SetRegAND(pVBInfo->Part4Port, 0x1F, tempah); /* disable part4_1f */
6946 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
6947 if (((pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)))
6948 || (XGI_DisableChISLCD(pVBInfo))
6949 || (XGI_IsLCDON(pVBInfo)))
6950 XGINew_SetRegOR(pVBInfo->Part4Port, 0x30, 0x80); /* LVDS Driver power down */
6953 if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo
6954 & (DisableCRT2Display | SetCRT2ToLCDA
6955 | SetSimuScanMode))) {
6956 if (pVBInfo->SetFlag & GatingCRT)
6957 XGI_EnableGatingCRT(HwDeviceExtension, pVBInfo);
6958 XGI_DisplayOff(HwDeviceExtension, pVBInfo);
6961 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
6962 if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo
6964 XGINew_SetRegAND(pVBInfo->Part1Port, 0x1e, 0xdf); /* Power down */
6967 XGINew_SetRegAND(pVBInfo->P3c4, 0x32, 0xdf); /* disable TV as primary VGA swap */
6969 if ((pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToDualEdge)))
6970 XGINew_SetRegAND(pVBInfo->Part2Port, 0x00, 0xdf);
6972 if ((pVBInfo->SetFlag & DisableChB) || (pVBInfo->VBInfo
6973 & (DisableCRT2Display | SetSimuScanMode))
6974 || ((!(pVBInfo->VBInfo & SetCRT2ToLCDA))
6979 XGINew_SetRegOR(pVBInfo->Part1Port, 0x00, 0x80); /* BScreenOff=1 */
6981 if ((pVBInfo->SetFlag & DisableChB) || (pVBInfo->VBInfo
6982 & (DisableCRT2Display | SetSimuScanMode))
6983 || (!(pVBInfo->VBInfo & SetCRT2ToLCDA))
6984 || (pVBInfo->VBInfo & (SetCRT2ToRAMDAC
6985 | SetCRT2ToLCD | SetCRT2ToTV))) {
6986 tempah = XGINew_GetReg1(pVBInfo->Part1Port, 0x00); /* save Part1 index 0 */
6987 XGINew_SetRegOR(pVBInfo->Part1Port, 0x00, 0x10); /* BTDAC = 1, avoid VB reset */
6988 XGINew_SetRegAND(pVBInfo->Part1Port, 0x1E, 0xDF); /* disable CRT2 */
6989 XGINew_SetReg1(pVBInfo->Part1Port, 0x00, tempah); /* restore Part1 index 0 */
6991 } else { /* {301} */
6992 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) {
6993 XGINew_SetRegOR(pVBInfo->Part1Port, 0x00, 0x80); /* BScreenOff=1 */
6994 XGINew_SetRegAND(pVBInfo->Part1Port, 0x1E, 0xDF); /* Disable CRT2 */
6995 XGINew_SetRegAND(pVBInfo->P3c4, 0x32, 0xDF); /* Disable TV asPrimary VGA swap */
6998 if (pVBInfo->VBInfo & (DisableCRT2Display | SetCRT2ToLCDA
7000 XGI_DisplayOff(HwDeviceExtension, pVBInfo);
7004 /* --------------------------------------------------------------------- */
7005 /* Function : XGI_GetTVPtrIndex */
7008 /* Description : bx 0 : ExtNTSC */
7020 /* --------------------------------------------------------------------- */
7021 static unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo)
7023 unsigned short tempbx = 0;
7025 if (pVBInfo->TVInfo & SetPALTV)
7027 if (pVBInfo->TVInfo & SetYPbPrMode1080i)
7029 if (pVBInfo->TVInfo & SetYPbPrMode525i)
7031 if (pVBInfo->TVInfo & SetYPbPrMode525p)
7033 if (pVBInfo->TVInfo & SetYPbPrMode750p)
7035 if (pVBInfo->TVInfo & TVSimuMode)
7041 /* --------------------------------------------------------------------- */
7042 /* Function : XGI_GetTVPtrIndex2 */
7044 /* Output : bx 0 : NTSC */
7048 /* 4 : NTSC1024x768 */
7049 /* 5 : PAL-M 1024x768 */
7051 /* cl 0 : YFilter1 */
7054 /* 1 : 301B/302B/301LV/302LV */
7056 /* --------------------------------------------------------------------- */
7057 static void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char *tempcl,
7058 unsigned char *tempch, struct vb_device_info *pVBInfo)
7064 if (pVBInfo->TVInfo & SetPALTV)
7067 if (pVBInfo->TVInfo & SetPALMTV)
7070 if (pVBInfo->TVInfo & SetPALNTV)
7073 if (pVBInfo->TVInfo & NTSC1024x768) {
7075 if (pVBInfo->TVInfo & SetPALMTV)
7079 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7080 | VB_XGI302LV | VB_XGI301C)) {
7081 if ((!(pVBInfo->VBInfo & SetInSlaveMode)) || (pVBInfo->TVInfo
7088 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7089 | VB_XGI302LV | VB_XGI301C))
7093 static void XGI_SetDelayComp(struct vb_device_info *pVBInfo)
7095 unsigned short index;
7097 unsigned char tempah, tempbl, tempbh;
7099 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7100 | VB_XGI302LV | VB_XGI301C)) {
7101 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA
7102 | SetCRT2ToTV | SetCRT2ToRAMDAC)) {
7106 index = XGI_GetTVPtrIndex(pVBInfo); /* Get TV Delay */
7107 tempbl = pVBInfo->XGI_TVDelayList[index];
7109 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
7110 | VB_XGI301LV | VB_XGI302LV
7112 tempbl = pVBInfo->XGI_TVDelayList2[index];
7114 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
7115 tempbl = tempbl >> 4;
7117 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC)
7118 tempbl = CRT2Delay1; // Get CRT2 Delay
7119 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C))
7120 tempbl = CRT2Delay2;
7122 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
7123 index = XGI_GetLCDCapPtr(pVBInfo); /* Get LCD Delay */
7124 tempbh = pVBInfo->LCDCapList[index].LCD_DelayCompensation;
7126 if (!(pVBInfo->VBInfo & SetCRT2ToLCDA))
7132 tempah = XGINew_GetReg1(pVBInfo->Part1Port, 0x2D);
7134 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD
7135 | SetCRT2ToTV)) { /* Channel B */
7140 if (pVBInfo->VBInfo & SetCRT2ToLCDA) { /* Channel A */
7144 XGINew_SetReg1(pVBInfo->Part1Port, 0x2D, tempah);
7146 } else if (pVBInfo->IF_DEF_LVDS == 1) {
7149 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
7151 = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(
7152 pVBInfo)].LCD_DelayCompensation; /* / Get LCD Delay */
7154 tempah = tempah << 4;
7155 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2D, 0x0f,
7161 static void XGI_SetLCDCap_A(unsigned short tempcx, struct vb_device_info *pVBInfo)
7163 unsigned short temp;
7165 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37);
7167 if (temp & LCDRGB18Bit) {
7168 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F,
7169 (unsigned short) (0x20 | (tempcx & 0x00C0))); /* Enable Dither */
7170 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80);
7172 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F,
7173 (unsigned short) (0x30 | (tempcx & 0x00C0)));
7174 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00);
7178 if (tempcx & EnableLCD24bpp) { // 24bits
7179 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F, (unsigned short)(0x30 | (tempcx&0x00C0)));
7180 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00);
7182 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F, (unsigned short)(0x20 | (tempcx&0x00C0))); // Enable Dither
7183 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80);
7188 /* --------------------------------------------------------------------- */
7189 /* Function : XGI_SetLCDCap_B */
7190 /* Input : cx -> LCD Capability */
7193 /* --------------------------------------------------------------------- */
7194 static void XGI_SetLCDCap_B(unsigned short tempcx, struct vb_device_info *pVBInfo)
7196 if (tempcx & EnableLCD24bpp) /* 24bits */
7197 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1A, 0xE0,
7198 (unsigned short) (((tempcx & 0x00ff) >> 6)
7201 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1A, 0xE0,
7202 (unsigned short) (((tempcx & 0x00ff) >> 6)
7203 | 0x18)); /* Enable Dither */
7206 static void SetSpectrum(struct vb_device_info *pVBInfo)
7208 unsigned short index;
7210 index = XGI_GetLCDCapPtr(pVBInfo);
7212 XGINew_SetRegAND(pVBInfo->Part4Port, 0x30, 0x8F); /* disable down spectrum D[4] */
7213 XGI_LongWait(pVBInfo);
7214 XGINew_SetRegOR(pVBInfo->Part4Port, 0x30, 0x20); /* reset spectrum */
7215 XGI_LongWait(pVBInfo);
7217 XGINew_SetReg1(pVBInfo->Part4Port, 0x31,
7218 pVBInfo->LCDCapList[index].Spectrum_31);
7219 XGINew_SetReg1(pVBInfo->Part4Port, 0x32,
7220 pVBInfo->LCDCapList[index].Spectrum_32);
7221 XGINew_SetReg1(pVBInfo->Part4Port, 0x33,
7222 pVBInfo->LCDCapList[index].Spectrum_33);
7223 XGINew_SetReg1(pVBInfo->Part4Port, 0x34,
7224 pVBInfo->LCDCapList[index].Spectrum_34);
7225 XGI_LongWait(pVBInfo);
7226 XGINew_SetRegOR(pVBInfo->Part4Port, 0x30, 0x40); /* enable spectrum */
7229 static void XGI_SetLCDCap(struct vb_device_info *pVBInfo)
7231 unsigned short tempcx;
7233 tempcx = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(pVBInfo)].LCD_Capability;
7235 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7236 | VB_XGI302LV | VB_XGI301C)) {
7237 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) { /* 301LV/302LV only */
7238 /* Set 301LV Capability */
7239 XGINew_SetReg1(pVBInfo->Part4Port, 0x24,
7240 (unsigned char) (tempcx & 0x1F));
7243 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x0D,
7244 ~((EnableVBCLKDRVLOW | EnablePLLSPLOW) >> 8),
7245 (unsigned short) ((tempcx & (EnableVBCLKDRVLOW
7246 | EnablePLLSPLOW)) >> 8));
7249 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7250 | VB_XGI302LV | VB_XGI301C)) {
7251 if (pVBInfo->VBInfo & SetCRT2ToLCD)
7252 XGI_SetLCDCap_B(tempcx, pVBInfo);
7253 else if (pVBInfo->VBInfo & SetCRT2ToLCDA)
7254 XGI_SetLCDCap_A(tempcx, pVBInfo);
7256 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
7257 if (tempcx & EnableSpectrum)
7258 SetSpectrum(pVBInfo);
7262 XGI_SetLCDCap_A(tempcx, pVBInfo);
7266 /* --------------------------------------------------------------------- */
7267 /* Function : XGI_SetAntiFlicker */
7270 /* Description : Set TV Customized Param. */
7271 /* --------------------------------------------------------------------- */
7272 static void XGI_SetAntiFlicker(unsigned short ModeNo, unsigned short ModeIdIndex,
7273 struct vb_device_info *pVBInfo)
7275 unsigned short tempbx, index;
7277 unsigned char tempah;
7279 if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))
7282 tempbx = XGI_GetTVPtrIndex(pVBInfo);
7286 index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVFlickerIndex;
7288 index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVFlickerIndex;
7291 tempah = TVAntiFlickList[tempbx];
7292 tempah = tempah << 4;
7294 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x0A, 0x8F, tempah);
7297 static void XGI_SetEdgeEnhance(unsigned short ModeNo, unsigned short ModeIdIndex,
7298 struct vb_device_info *pVBInfo)
7300 unsigned short tempbx, index;
7302 unsigned char tempah;
7304 tempbx = XGI_GetTVPtrIndex(pVBInfo);
7308 index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVEdgeIndex;
7310 index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVEdgeIndex;
7313 tempah = TVEdgeList[tempbx];
7314 tempah = tempah << 5;
7316 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x3A, 0x1F, tempah);
7319 static void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo)
7321 unsigned short tempbx;
7323 unsigned char tempcl, tempch;
7325 unsigned long tempData;
7327 XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */
7328 tempData = TVPhaseList[tempbx];
7330 XGINew_SetReg1(pVBInfo->Part2Port, 0x31, (unsigned short) (tempData
7332 XGINew_SetReg1(pVBInfo->Part2Port, 0x32, (unsigned short) ((tempData
7333 & 0x0000FF00) >> 8));
7334 XGINew_SetReg1(pVBInfo->Part2Port, 0x33, (unsigned short) ((tempData
7335 & 0x00FF0000) >> 16));
7336 XGINew_SetReg1(pVBInfo->Part2Port, 0x34, (unsigned short) ((tempData
7337 & 0xFF000000) >> 24));
7340 static void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex,
7341 struct vb_device_info *pVBInfo)
7343 unsigned short tempbx, index;
7345 unsigned char tempcl, tempch, tempal, *filterPtr;
7347 XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */
7352 filterPtr = NTSCYFilter1;
7356 filterPtr = PALYFilter1;
7362 filterPtr = PALMYFilter1;
7366 filterPtr = PALNYFilter1;
7371 filterPtr = NTSCYFilter2;
7375 filterPtr = PALMYFilter2;
7379 filterPtr = PALNYFilter2;
7383 filterPtr = PALYFilter2;
7391 tempal = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVYFilterIndex;
7394 = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVYFilterIndex;
7401 if ((tempcl == 0) && (tempch == 1)) {
7402 XGINew_SetReg1(pVBInfo->Part2Port, 0x35, 0);
7403 XGINew_SetReg1(pVBInfo->Part2Port, 0x36, 0);
7404 XGINew_SetReg1(pVBInfo->Part2Port, 0x37, 0);
7405 XGINew_SetReg1(pVBInfo->Part2Port, 0x38, filterPtr[index++]);
7407 XGINew_SetReg1(pVBInfo->Part2Port, 0x35, filterPtr[index++]);
7408 XGINew_SetReg1(pVBInfo->Part2Port, 0x36, filterPtr[index++]);
7409 XGINew_SetReg1(pVBInfo->Part2Port, 0x37, filterPtr[index++]);
7410 XGINew_SetReg1(pVBInfo->Part2Port, 0x38, filterPtr[index++]);
7413 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7414 | VB_XGI302LV | VB_XGI301C)) {
7415 XGINew_SetReg1(pVBInfo->Part2Port, 0x48, filterPtr[index++]);
7416 XGINew_SetReg1(pVBInfo->Part2Port, 0x49, filterPtr[index++]);
7417 XGINew_SetReg1(pVBInfo->Part2Port, 0x4A, filterPtr[index++]);
7421 /* --------------------------------------------------------------------- */
7422 /* Function : XGI_OEM310Setting */
7425 /* Description : Customized Param. for 301 */
7426 /* --------------------------------------------------------------------- */
7427 static void XGI_OEM310Setting(unsigned short ModeNo, unsigned short ModeIdIndex,
7428 struct vb_device_info *pVBInfo)
7430 if (pVBInfo->SetFlag & Win9xDOSMode)
7434 XGI_SetDelayComp(pVBInfo);
7436 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))
7437 XGI_SetLCDCap(pVBInfo);
7439 if (pVBInfo->VBInfo & SetCRT2ToTV) {
7441 XGI_SetPhaseIncr(pVBInfo);
7442 XGI_SetYFilter(ModeNo, ModeIdIndex, pVBInfo);
7443 XGI_SetAntiFlicker(ModeNo, ModeIdIndex, pVBInfo);
7445 if (pVBInfo->VBType & VB_XGI301)
7446 XGI_SetEdgeEnhance(ModeNo, ModeIdIndex, pVBInfo);
7450 /* --------------------------------------------------------------------- */
7451 /* Function : XGI_SetCRT2ModeRegs */
7454 /* Description : Origin code for crt2group */
7455 /* --------------------------------------------------------------------- */
7456 void XGI_SetCRT2ModeRegs(unsigned short ModeNo,
7457 struct xgi_hw_device_info *HwDeviceExtension,
7458 struct vb_device_info *pVBInfo)
7460 unsigned short tempbl;
7463 unsigned char tempah;
7465 /* XGINew_SetReg1(pVBInfo->Part1Port, 0x03, 0x00); // fix write part1 index 0 BTDRAM bit Bug */
7467 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
7468 tempah = XGINew_GetReg1(pVBInfo->Part1Port, 0x00);
7469 tempah &= ~0x10; /* BTRAMDAC */
7470 tempah |= 0x40; /* BTRAM */
7472 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV
7474 tempah = 0x40; /* BTDRAM */
7475 if (ModeNo > 0x13) {
7476 tempcl = pVBInfo->ModeType;
7479 tempah = (0x008 >> tempcl); /* BT Color */
7485 if (pVBInfo->VBInfo & SetInSlaveMode)
7486 tempah ^= 0x50; /* BTDAC */
7491 if (pVBInfo->VBInfo & DisableCRT2Display) {
7495 XGINew_SetReg1(pVBInfo->Part1Port, 0x00, tempah);
7496 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD)) {
7497 tempcl = pVBInfo->ModeType;
7498 if (ModeNo > 0x13) {
7500 if ((tempcl > 0) || (tempcl == 0)) {
7501 tempah=(0x008>>tempcl) ;
7510 if (pVBInfo->VBInfo & SetInSlaveMode) {
7511 tempah = (tempah ^ 0x050);
7516 XGINew_SetReg1(pVBInfo->Part1Port, 0x00, tempah);
7520 if (pVBInfo->VBInfo & DisableCRT2Display) {
7521 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2e, tempbl, tempah);
7526 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV
7527 | SetCRT2ToLCD | SetCRT2ToLCDA)) {
7528 if ((pVBInfo->VBInfo & SetCRT2ToLCDA)
7529 && (!(pVBInfo->VBInfo & SetSimuScanMode))) {
7532 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2e,
7535 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
7540 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC
7541 | SetCRT2ToTV | SetCRT2ToLCD)) {
7545 if (!(pVBInfo->VBInfo & SetInSlaveMode))
7548 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) {
7549 tempah = tempah ^ 0x05;
7550 if (!(pVBInfo->VBInfo
7552 tempah = tempah ^ 0x01;
7555 if (!(pVBInfo->VBInfo
7556 & SetCRT2ToDualEdge))
7558 XGINew_SetRegANDOR(pVBInfo->Part1Port,
7559 0x2e, tempbl, tempah);
7561 XGINew_SetRegANDOR(pVBInfo->Part1Port,
7562 0x2e, tempbl, tempah);
7566 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2e, tempbl,
7571 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD
7574 if ((pVBInfo->ModeType == ModeVGA) && (!(pVBInfo->VBInfo
7575 & SetInSlaveMode))) {
7580 if (pVBInfo->VBInfo & SetCRT2ToTV) {
7581 /* if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))) { */
7583 if (ModeNo > 0x13) {
7584 if (pVBInfo->VBInfo & DriverMode)
7585 tempah = tempah ^ 0x20;
7590 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x0D, ~0x0BF, tempah);
7593 if (pVBInfo->LCDInfo & SetLCDDualLink)
7596 if (pVBInfo->VBInfo & SetCRT2ToTV) {
7597 /* if ((!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)) && (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)))) { */
7598 if (pVBInfo->TVInfo & RPLLDIV2XO)
7603 if ((pVBInfo->LCDResInfo == Panel1280x1024)
7604 || (pVBInfo->LCDResInfo == Panel1280x1024x75))
7607 if (pVBInfo->LCDResInfo == Panel1280x960)
7610 XGINew_SetReg1(pVBInfo->Part4Port, 0x0C, tempah);
7613 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7614 | VB_XGI302LV | VB_XGI301C)) {
7618 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
7620 if (pVBInfo->VBInfo & SetCRT2ToLCDA)
7621 tempah |= 0x04; /* shampoo 0129 */
7624 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x13, tempbl, tempah);
7627 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
7628 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
7632 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2c, tempbl, tempah);
7636 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
7637 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
7640 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x21, tempbl, tempah);
7645 if (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) {
7647 if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge))
7651 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x23, tempbl, tempah);
7653 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
7654 if (pVBInfo->LCDInfo & SetLCDDualLink) {
7655 XGINew_SetRegOR(pVBInfo->Part4Port, 0x27, 0x20);
7656 XGINew_SetRegOR(pVBInfo->Part4Port, 0x34, 0x10);
7661 static void XGI_CloseCRTC(struct xgi_hw_device_info *HwDeviceExtension,
7662 struct vb_device_info *pVBInfo)
7664 unsigned short tempbx;
7668 if (pVBInfo->VBInfo & SetCRT2ToLCDA)
7673 void XGI_OpenCRTC(struct xgi_hw_device_info *HwDeviceExtension,
7674 struct vb_device_info *pVBInfo)
7676 unsigned short tempbx;
7680 void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension,
7681 struct vb_device_info *pVBInfo)
7684 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2f, 0xFF, 0x01);
7688 void XGI_LockCRT2(struct xgi_hw_device_info *HwDeviceExtension,
7689 struct vb_device_info *pVBInfo)
7692 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2F, 0xFE, 0x00);
7696 unsigned char XGI_BridgeIsOn(struct vb_device_info *pVBInfo)
7698 unsigned short flag;
7700 if (pVBInfo->IF_DEF_LVDS == 1) {
7703 flag = XGINew_GetReg1(pVBInfo->Part4Port, 0x00);
7704 if ((flag == 1) || (flag == 2))
7705 return 1; /* 301b */
7711 void XGI_LongWait(struct vb_device_info *pVBInfo)
7715 i = XGINew_GetReg1(pVBInfo->P3c4, 0x1F);
7718 for (i = 0; i < 0xFFFF; i++) {
7719 if (!(inb(pVBInfo->P3da) & 0x08))
7723 for (i = 0; i < 0xFFFF; i++) {
7724 if ((inb(pVBInfo->P3da) & 0x08))
7730 static void XGI_VBLongWait(struct vb_device_info *pVBInfo)
7732 unsigned short tempal, temp, i, j;
7734 if (!(pVBInfo->VBInfo & SetCRT2ToTV)) {
7736 for (i = 0; i < 3; i++) {
7737 for (j = 0; j < 100; j++) {
7738 tempal = inb(pVBInfo->P3da);
7739 if (temp & 0x01) { /* VBWaitMode2 */
7740 if ((tempal & 0x08))
7743 if (!(tempal & 0x08))
7746 } else { /* VBWaitMode1 */
7747 if (!(tempal & 0x08))
7750 if ((tempal & 0x08))
7757 XGI_LongWait(pVBInfo);
7762 unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE,
7763 unsigned short ModeNo, unsigned short ModeIdIndex,
7764 struct vb_device_info *pVBInfo)
7766 short LCDRefreshIndex[] = { 0x00, 0x00, 0x03, 0x01 },
7767 LCDARefreshIndex[] = { 0x00, 0x00, 0x03, 0x01, 0x01,
7770 unsigned short RefreshRateTableIndex, i, modeflag, index, temp;
7773 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
7775 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
7777 if (pVBInfo->IF_DEF_CH7005 == 1) {
7778 if (pVBInfo->VBInfo & SetCRT2ToTV) {
7779 if (modeflag & HalfDCLK)
7787 index = XGINew_GetReg1(pVBInfo->P3d4, 0x33);
7788 index = index >> pVBInfo->SelectCRT2Rate;
7791 if (pVBInfo->LCDInfo & LCDNonExpanding)
7797 if (pVBInfo->SetFlag & ProgrammingCRT2) {
7798 if (pVBInfo->IF_DEF_CH7005 == 1) {
7799 if (pVBInfo->VBInfo & SetCRT2ToTV)
7803 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
7804 if (pVBInfo->IF_DEF_LVDS == 0) {
7805 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
7806 | VB_XGI301LV | VB_XGI302LV
7809 = LCDARefreshIndex[pVBInfo->LCDResInfo
7813 = LCDRefreshIndex[pVBInfo->LCDResInfo
7824 RefreshRateTableIndex = pVBInfo->EModeIDTable[ModeIdIndex].REFindex;
7825 ModeNo = pVBInfo->RefIndex[RefreshRateTableIndex].ModeID;
7826 if (pXGIHWDE->jChipType >= XG20) { /* for XG20, XG21, XG27 */
7828 if (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag & XG2xNotSupport) {
7832 if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 800)
7833 && (pVBInfo->RefIndex[RefreshRateTableIndex].YRes
7837 /* Alan 10/19/2007; do the similiar adjustment like XGISearchCRT1Rate() */
7838 if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1024)
7839 && (pVBInfo->RefIndex[RefreshRateTableIndex].YRes
7843 if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1280)
7844 && (pVBInfo->RefIndex[RefreshRateTableIndex].YRes
7852 if (pVBInfo->RefIndex[RefreshRateTableIndex + i].ModeID
7856 = pVBInfo->RefIndex[RefreshRateTableIndex + i].Ext_InfoFlag;
7857 temp &= ModeInfoFlag;
7858 if (temp < pVBInfo->ModeType)
7863 } while (index != 0xFFFF);
7864 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) {
7865 if (pVBInfo->VBInfo & SetInSlaveMode) {
7867 = pVBInfo->RefIndex[RefreshRateTableIndex
7868 + i - 1].Ext_InfoFlag;
7869 if (temp & InterlaceMode)
7874 if ((pVBInfo->SetFlag & ProgrammingCRT2)) {
7875 temp = XGI_AjustCRT2Rate(ModeNo, ModeIdIndex,
7876 RefreshRateTableIndex, &i, pVBInfo);
7878 return RefreshRateTableIndex + i; /* return (0x01 | (temp1<<1)); */
7881 static void XGI_SetLCDAGroup(unsigned short ModeNo, unsigned short ModeIdIndex,
7882 struct xgi_hw_device_info *HwDeviceExtension,
7883 struct vb_device_info *pVBInfo)
7885 unsigned short RefreshRateTableIndex;
7886 /* unsigned short temp ; */
7888 /* pVBInfo->SelectCRT2Rate = 0; */
7890 pVBInfo->SetFlag |= ProgrammingCRT2;
7891 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
7892 ModeIdIndex, pVBInfo);
7893 XGI_GetLVDSResInfo(ModeNo, ModeIdIndex, pVBInfo);
7894 XGI_GetLVDSData(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
7895 XGI_ModCRT1Regs(ModeNo, ModeIdIndex, RefreshRateTableIndex,
7896 HwDeviceExtension, pVBInfo);
7897 XGI_SetLVDSRegs(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
7898 XGI_SetCRT2ECLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
7901 unsigned char XGI_SetCRT2Group301(unsigned short ModeNo,
7902 struct xgi_hw_device_info *HwDeviceExtension,
7903 struct vb_device_info *pVBInfo)
7905 unsigned short tempbx, ModeIdIndex, RefreshRateTableIndex;
7907 tempbx = pVBInfo->VBInfo;
7908 pVBInfo->SetFlag |= ProgrammingCRT2;
7909 XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo);
7910 pVBInfo->SelectCRT2Rate = 4;
7911 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
7912 ModeIdIndex, pVBInfo);
7913 XGI_SaveCRT2Info(ModeNo, pVBInfo);
7914 XGI_GetCRT2ResInfo(ModeNo, ModeIdIndex, pVBInfo);
7915 XGI_GetCRT2Data(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
7916 XGI_PreSetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension,
7917 RefreshRateTableIndex, pVBInfo);
7918 XGI_SetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension,
7919 RefreshRateTableIndex, pVBInfo);
7920 XGI_SetLockRegs(ModeNo, ModeIdIndex, HwDeviceExtension,
7921 RefreshRateTableIndex, pVBInfo);
7922 XGI_SetGroup2(ModeNo, ModeIdIndex, RefreshRateTableIndex,
7923 HwDeviceExtension, pVBInfo);
7924 XGI_SetLCDRegs(ModeNo, ModeIdIndex, HwDeviceExtension,
7925 RefreshRateTableIndex, pVBInfo);
7926 XGI_SetTap4Regs(pVBInfo);
7927 XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo);
7928 XGI_SetGroup4(ModeNo, ModeIdIndex, RefreshRateTableIndex,
7929 HwDeviceExtension, pVBInfo);
7930 XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
7931 XGI_SetGroup5(ModeNo, ModeIdIndex, pVBInfo);
7932 XGI_AutoThreshold(pVBInfo);
7936 void XGI_SenseCRT1(struct vb_device_info *pVBInfo)
7938 unsigned char CRTCData[17] = { 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81,
7939 0x0B, 0x3E, 0xE9, 0x0B, 0xDF, 0xE7, 0x04, 0x00, 0x00,
7942 unsigned char SR01 = 0, SR1F = 0, SR07 = 0, SR06 = 0;
7944 unsigned char CR17, CR63, SR31;
7945 unsigned short temp;
7946 unsigned char DAC_TEST_PARMS[3] = { 0x0F, 0x0F, 0x0F };
7949 XGINew_SetReg1(pVBInfo->P3c4, 0x05, 0x86);
7951 /* [2004/05/06] Vicent to fix XG42 single LCD sense to CRT+LCD */
7952 XGINew_SetReg1(pVBInfo->P3d4, 0x57, 0x4A);
7953 XGINew_SetReg1(pVBInfo->P3d4, 0x53, (unsigned char) (XGINew_GetReg1(
7954 pVBInfo->P3d4, 0x53) | 0x02));
7956 SR31 = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x31);
7957 CR63 = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x63);
7958 SR01 = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x01);
7960 XGINew_SetReg1(pVBInfo->P3c4, 0x01, (unsigned char) (SR01 & 0xDF));
7961 XGINew_SetReg1(pVBInfo->P3d4, 0x63, (unsigned char) (CR63 & 0xBF));
7963 CR17 = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x17);
7964 XGINew_SetReg1(pVBInfo->P3d4, 0x17, (unsigned char) (CR17 | 0x80));
7966 SR1F = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x1F);
7967 XGINew_SetReg1(pVBInfo->P3c4, 0x1F, (unsigned char) (SR1F | 0x04));
7969 SR07 = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x07);
7970 XGINew_SetReg1(pVBInfo->P3c4, 0x07, (unsigned char) (SR07 & 0xFB));
7971 SR06 = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x06);
7972 XGINew_SetReg1(pVBInfo->P3c4, 0x06, (unsigned char) (SR06 & 0xC3));
7974 XGINew_SetReg1(pVBInfo->P3d4, 0x11, 0x00);
7976 for (i = 0; i < 8; i++)
7977 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) i, CRTCData[i]);
7979 for (i = 8; i < 11; i++)
7980 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 8),
7983 for (i = 11; i < 13; i++)
7984 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 4),
7987 for (i = 13; i < 16; i++)
7988 XGINew_SetReg1(pVBInfo->P3c4, (unsigned short) (i - 3),
7991 XGINew_SetReg1(pVBInfo->P3c4, 0x0E, (unsigned char) (CRTCData[16]
7994 XGINew_SetReg1(pVBInfo->P3c4, 0x31, 0x00);
7995 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, 0x1B);
7996 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, 0xE1);
7998 outb(0x00, pVBInfo->P3c8);
8000 for (i = 0; i < 256; i++) {
8001 outb((unsigned char) DAC_TEST_PARMS[0], (pVBInfo->P3c8 + 1));
8002 outb((unsigned char) DAC_TEST_PARMS[1], (pVBInfo->P3c8 + 1));
8003 outb((unsigned char) DAC_TEST_PARMS[2], (pVBInfo->P3c8 + 1));
8006 XGI_VBLongWait(pVBInfo);
8007 XGI_VBLongWait(pVBInfo);
8008 XGI_VBLongWait(pVBInfo);
8012 XGI_WaitDisply(pVBInfo);
8013 temp = inb(pVBInfo->P3c2);
8016 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x32, 0xDF, 0x20);
8018 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x32, 0xDF, 0x00);
8020 /* alan, avoid display something, set BLACK DAC if not restore DAC */
8021 outb(0x00, pVBInfo->P3c8);
8023 for (i = 0; i < 256; i++) {
8024 outb(0, (pVBInfo->P3c8 + 1));
8025 outb(0, (pVBInfo->P3c8 + 1));
8026 outb(0, (pVBInfo->P3c8 + 1));
8029 XGINew_SetReg1(pVBInfo->P3c4, 0x01, SR01);
8030 XGINew_SetReg1(pVBInfo->P3d4, 0x63, CR63);
8031 XGINew_SetReg1(pVBInfo->P3c4, 0x31, SR31);
8033 /* [2004/05/11] Vicent */
8034 XGINew_SetReg1(pVBInfo->P3d4, 0x53, (unsigned char) (XGINew_GetReg1(
8035 pVBInfo->P3d4, 0x53) & 0xFD));
8036 XGINew_SetReg1(pVBInfo->P3c4, 0x1F, (unsigned char) SR1F);
8039 void XGI_EnableBridge(struct xgi_hw_device_info *HwDeviceExtension,
8040 struct vb_device_info *pVBInfo)
8042 unsigned short tempah;
8044 if (pVBInfo->SetFlag == Win9xDOSMode) {
8045 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8046 | VB_XGI302LV | VB_XGI301C)) {
8047 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
8050 /* LVDS or CH7017 */
8054 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8055 | VB_XGI302LV | VB_XGI301C)) {
8056 if (!(pVBInfo->SetFlag & DisableChA)) {
8057 if (pVBInfo->SetFlag & EnableChA) {
8058 XGINew_SetReg1(pVBInfo->Part1Port, 0x1E, 0x20); /* Power on */
8060 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { /* SetCRT2ToLCDA ) */
8061 XGINew_SetReg1(pVBInfo->Part1Port,
8062 0x1E, 0x20); /* Power on */
8067 if (!(pVBInfo->SetFlag & DisableChB)) {
8068 if ((pVBInfo->SetFlag & EnableChB) || (pVBInfo->VBInfo
8069 & (SetCRT2ToLCD | SetCRT2ToTV
8070 | SetCRT2ToRAMDAC))) {
8071 tempah = (unsigned char) XGINew_GetReg1(
8072 pVBInfo->P3c4, 0x32);
8074 if (pVBInfo->VBInfo & SetInSlaveMode) {
8075 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC))
8078 XGINew_SetReg1(pVBInfo->P3c4, 0x32, tempah);
8079 XGINew_SetRegOR(pVBInfo->P3c4, 0x1E, 0x20);
8081 tempah = (unsigned char) XGINew_GetReg1(
8082 pVBInfo->Part1Port, 0x2E);
8084 if (!(tempah & 0x80))
8085 XGINew_SetRegOR(pVBInfo->Part1Port,
8086 0x2E, 0x80); /* BVBDOENABLE = 1 */
8088 XGINew_SetRegAND(pVBInfo->Part1Port, 0x00, 0x7F); /* BScreenOFF = 0 */
8092 if ((pVBInfo->SetFlag & (EnableChA | EnableChB))
8093 || (!(pVBInfo->VBInfo & DisableCRT2Display))) {
8094 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x00, ~0xE0,
8095 0x20); /* shampoo 0129 */
8096 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
8097 if (!XGI_DisableChISLCD(pVBInfo)) {
8098 if (XGI_EnableChISLCD(pVBInfo)
8104 0x2A, 0x7F); /* LVDS PLL power on */
8106 XGINew_SetRegAND(pVBInfo->Part4Port, 0x30, 0x7F); /* LVDS Driver power on */
8112 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
8115 if (!(pVBInfo->VBInfo & SetSimuScanMode)) {
8116 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
8117 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
8118 tempah = tempah & 0x40;
8121 tempah = tempah ^ 0xC0;
8123 if (pVBInfo->SetFlag
8127 if (pVBInfo->SetFlag
8131 if (pVBInfo->SetFlag
8135 if (pVBInfo->SetFlag
8143 XGINew_SetRegOR(pVBInfo->Part4Port, 0x1F, tempah); /* EnablePart4_1F */
8145 if (pVBInfo->SetFlag & Win9xDOSMode) {
8146 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
8150 if (!(pVBInfo->SetFlag & DisableChA)) {
8151 XGI_VBLongWait(pVBInfo);
8152 if (!(pVBInfo->SetFlag & GatingCRT)) {
8153 XGI_DisableGatingCRT(HwDeviceExtension, pVBInfo);
8154 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
8155 XGI_VBLongWait(pVBInfo);
8160 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD
8162 XGINew_SetRegOR(pVBInfo->Part1Port, 0x1E, 0x20); /* enable CRT2 */
8164 tempah = (unsigned char) XGINew_GetReg1(pVBInfo->Part1Port,
8166 if (!(tempah & 0x80))
8167 XGINew_SetRegOR(pVBInfo->Part1Port, 0x2E, 0x80); /* BVBDOENABLE = 1 */
8169 XGINew_SetRegAND(pVBInfo->Part1Port, 0x00, 0x7F);
8170 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
8174 static void XGI_SetCRT1Group(struct xgi_hw_device_info *HwDeviceExtension,
8175 unsigned short ModeNo, unsigned short ModeIdIndex,
8176 struct vb_device_info *pVBInfo)
8178 unsigned short StandTableIndex, RefreshRateTableIndex, b3CC, temp;
8180 unsigned short XGINew_P3cc = pVBInfo->P3cc;
8182 /* XGINew_CRT1Mode = ModeNo; // SaveModeID */
8183 StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
8184 /* XGI_SetBIOSData(ModeNo, ModeIdIndex); */
8185 /* XGI_ClearBankRegs(ModeNo, ModeIdIndex); */
8186 XGI_SetSeqRegs(ModeNo, StandTableIndex, ModeIdIndex, pVBInfo);
8187 XGI_SetMiscRegs(StandTableIndex, pVBInfo);
8188 XGI_SetCRTCRegs(HwDeviceExtension, StandTableIndex, pVBInfo);
8189 XGI_SetATTRegs(ModeNo, StandTableIndex, ModeIdIndex, pVBInfo);
8190 XGI_SetGRCRegs(StandTableIndex, pVBInfo);
8191 XGI_ClearExt1Regs(pVBInfo);
8193 /* if (pVBInfo->IF_DEF_ExpLink) */
8194 if (HwDeviceExtension->jChipType == XG27) {
8195 if (pVBInfo->IF_DEF_LVDS == 0)
8196 XGI_SetDefaultVCLK(pVBInfo);
8199 temp = ~ProgrammingCRT2;
8200 pVBInfo->SetFlag &= temp;
8201 pVBInfo->SelectCRT2Rate = 0;
8203 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8204 | VB_XGI302LV | VB_XGI301C)) {
8205 if (pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToLCDA
8206 | SetInSlaveMode)) {
8207 pVBInfo->SetFlag |= ProgrammingCRT2;
8211 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
8212 ModeIdIndex, pVBInfo);
8213 if (RefreshRateTableIndex != 0xFFFF) {
8214 XGI_SetSync(RefreshRateTableIndex, pVBInfo);
8215 XGI_SetCRT1CRTC(ModeNo, ModeIdIndex, RefreshRateTableIndex,
8216 pVBInfo, HwDeviceExtension);
8217 XGI_SetCRT1DE(HwDeviceExtension, ModeNo, ModeIdIndex,
8218 RefreshRateTableIndex, pVBInfo);
8219 XGI_SetCRT1Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
8220 HwDeviceExtension, pVBInfo);
8221 XGI_SetCRT1VCLK(ModeNo, ModeIdIndex, HwDeviceExtension,
8222 RefreshRateTableIndex, pVBInfo);
8225 if ((HwDeviceExtension->jChipType >= XG20)
8226 && (HwDeviceExtension->jChipType < XG27)) { /* fix H/W DCLK/2 bug */
8227 if ((ModeNo == 0x00) | (ModeNo == 0x01)) {
8228 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, 0x4E);
8229 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, 0xE9);
8230 b3CC = (unsigned char) inb(XGINew_P3cc);
8231 outb((b3CC |= 0x0C), XGINew_P3cc);
8232 } else if ((ModeNo == 0x04) | (ModeNo == 0x05) | (ModeNo
8234 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, 0x1B);
8235 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, 0xE3);
8236 b3CC = (unsigned char) inb(XGINew_P3cc);
8237 outb((b3CC |= 0x0C), XGINew_P3cc);
8241 if (HwDeviceExtension->jChipType >= XG21) {
8242 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x38);
8245 /* XGINew_SetRegAND(pVBInfo->P3d4, 0x4A, ~0x20); *//* Enable write GPIOF */
8246 /* XGINew_SetRegAND(pVBInfo->P3d4, 0x48, ~0x20); *//* P. DWN */
8247 /* XG21 CRT1 Timing */
8248 if (HwDeviceExtension->jChipType == XG27)
8249 XGI_SetXG27CRTC(ModeNo, ModeIdIndex,
8250 RefreshRateTableIndex, pVBInfo);
8252 XGI_SetXG21CRTC(ModeNo, ModeIdIndex,
8253 RefreshRateTableIndex, pVBInfo);
8255 XGI_UpdateXG21CRTC(ModeNo, pVBInfo,
8256 RefreshRateTableIndex);
8258 if (HwDeviceExtension->jChipType == XG27)
8259 XGI_SetXG27LCD(pVBInfo, RefreshRateTableIndex,
8262 XGI_SetXG21LCD(pVBInfo, RefreshRateTableIndex,
8265 if (pVBInfo->IF_DEF_LVDS == 1) {
8266 if (HwDeviceExtension->jChipType == XG27)
8267 XGI_SetXG27LVDSPara(ModeNo,
8268 ModeIdIndex, pVBInfo);
8270 XGI_SetXG21LVDSPara(ModeNo,
8271 ModeIdIndex, pVBInfo);
8273 /* XGINew_SetRegOR(pVBInfo->P3d4, 0x48, 0x20); *//* P. ON */
8277 pVBInfo->SetFlag &= (~ProgrammingCRT2);
8278 XGI_SetCRT1FIFO(ModeNo, HwDeviceExtension, pVBInfo);
8279 XGI_SetCRT1ModeRegs(HwDeviceExtension, ModeNo, ModeIdIndex,
8280 RefreshRateTableIndex, pVBInfo);
8282 /* XGI_LoadCharacter(); //dif ifdef TVFont */
8284 XGI_LoadDAC(ModeNo, ModeIdIndex, pVBInfo);
8285 /* XGI_ClearBuffer(HwDeviceExtension, ModeNo, pVBInfo); */
8288 unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension,
8289 unsigned short ModeNo)
8291 unsigned short ModeIdIndex;
8292 /* unsigned char *pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress; */
8293 struct vb_device_info VBINF;
8294 struct vb_device_info *pVBInfo = &VBINF;
8295 pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase;
8296 pVBInfo->BaseAddr = (unsigned long) HwDeviceExtension->pjIOAddress;
8297 pVBInfo->IF_DEF_LVDS = 0;
8298 pVBInfo->IF_DEF_CH7005 = 0;
8299 pVBInfo->IF_DEF_LCDA = 1;
8300 pVBInfo->IF_DEF_CH7017 = 0;
8301 pVBInfo->IF_DEF_CH7007 = 0; /* [Billy] 2007/05/14 */
8302 pVBInfo->IF_DEF_VideoCapture = 0;
8303 pVBInfo->IF_DEF_ScaleLCD = 0;
8304 pVBInfo->IF_DEF_OEMUtil = 0;
8305 pVBInfo->IF_DEF_PWD = 0;
8307 if (HwDeviceExtension->jChipType >= XG20) { /* kuku 2004/06/25 */
8308 pVBInfo->IF_DEF_YPbPr = 0;
8309 pVBInfo->IF_DEF_HiVision = 0;
8310 pVBInfo->IF_DEF_CRT2Monitor = 0;
8311 pVBInfo->VBType = 0; /*set VBType default 0*/
8313 pVBInfo->IF_DEF_YPbPr = 1;
8314 pVBInfo->IF_DEF_HiVision = 1;
8315 pVBInfo->IF_DEF_CRT2Monitor = 1;
8318 pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14;
8319 pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24;
8320 pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10;
8321 pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e;
8322 pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12;
8323 pVBInfo->P3cc = pVBInfo->BaseAddr + 0x1C;
8324 pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a;
8325 pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16;
8326 pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17;
8327 pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18;
8328 pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19;
8329 pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A;
8330 pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00;
8331 pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04;
8332 pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10;
8333 pVBInfo->Part3Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_12;
8334 pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14;
8335 pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2;
8337 if (HwDeviceExtension->jChipType == XG21) { /* for x86 Linux, XG21 LVDS */
8338 if ((XGINew_GetReg1(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0)
8339 pVBInfo->IF_DEF_LVDS = 1;
8341 if (HwDeviceExtension->jChipType == XG27) {
8342 if ((XGINew_GetReg1(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) {
8343 if (XGINew_GetReg1(pVBInfo->P3d4, 0x30) & 0x20)
8344 pVBInfo->IF_DEF_LVDS = 1;
8348 if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 */
8349 XGI_GetVBType(pVBInfo);
8351 InitTo330Pointer(HwDeviceExtension->jChipType, pVBInfo);
8352 if (ModeNo & 0x80) {
8353 ModeNo = ModeNo & 0x7F;
8354 /* XGINew_flag_clearbuffer = 0; */
8357 XGINew_flag_clearbuffer = 1;
8360 XGINew_SetReg1(pVBInfo->P3c4, 0x05, 0x86);
8362 if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 1.Openkey */
8363 XGI_UnLockCRT2(HwDeviceExtension, pVBInfo);
8365 XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo);
8367 XGI_GetVGAType(HwDeviceExtension, pVBInfo);
8369 if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */
8370 XGI_GetVBInfo(ModeNo, ModeIdIndex, HwDeviceExtension, pVBInfo);
8371 XGI_GetTVInfo(ModeNo, ModeIdIndex, pVBInfo);
8372 XGI_GetLCDInfo(ModeNo, ModeIdIndex, pVBInfo);
8373 XGI_DisableBridge(HwDeviceExtension, pVBInfo);
8374 /* XGI_OpenCRTC(HwDeviceExtension, pVBInfo); */
8376 if (pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToLCDA)) {
8377 XGI_SetCRT1Group(HwDeviceExtension, ModeNo,
8378 ModeIdIndex, pVBInfo);
8380 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
8381 XGI_SetLCDAGroup(ModeNo, ModeIdIndex,
8382 HwDeviceExtension, pVBInfo);
8385 if (!(pVBInfo->VBInfo & SwitchToCRT2)) {
8386 XGI_SetCRT1Group(HwDeviceExtension, ModeNo,
8387 ModeIdIndex, pVBInfo);
8388 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
8389 XGI_SetLCDAGroup(ModeNo, ModeIdIndex,
8396 if (pVBInfo->VBInfo & (SetSimuScanMode | SwitchToCRT2)) {
8397 switch (HwDeviceExtension->ujVBChipID) {
8399 XGI_SetCRT2Group301(ModeNo, HwDeviceExtension,
8400 pVBInfo); /*add for CRT2 */
8404 XGI_SetCRT2Group301(ModeNo, HwDeviceExtension,
8405 pVBInfo); /*add for CRT2 */
8413 XGI_SetCRT2ModeRegs(ModeNo, HwDeviceExtension, pVBInfo);
8414 XGI_OEM310Setting(ModeNo, ModeIdIndex, pVBInfo); /*0212*/
8415 XGI_CloseCRTC(HwDeviceExtension, pVBInfo);
8416 XGI_EnableBridge(HwDeviceExtension, pVBInfo);
8419 if (pVBInfo->IF_DEF_LVDS == 1)
8420 if (!XGI_XG21CheckLVDSMode(ModeNo, ModeIdIndex, pVBInfo))
8423 if (ModeNo <= 0x13) {
8425 = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag
8429 = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag
8433 pVBInfo->SetFlag = 0;
8434 if (pVBInfo->IF_DEF_CH7007 != 1)
8435 pVBInfo->VBInfo = DisableCRT2Display;
8437 XGI_DisplayOff(HwDeviceExtension, pVBInfo);
8439 XGI_SetCRT1Group(HwDeviceExtension, ModeNo, ModeIdIndex,
8442 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
8444 if (HwDeviceExtension->jChipType == XG21)
8445 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x09, ~0x80, 0x80);
8450 if (ModeNo <= 0x13) {
8451 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
8453 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
8455 pVBInfo->ModeType = modeflag&ModeInfoFlag;
8456 pVBInfo->SetFlag = 0x00;
8457 pVBInfo->VBInfo = DisableCRT2Display;
8458 temp = XGINew_CheckMemorySize(HwDeviceExtension, ModeNo, ModeIdIndex, pVBInfo);
8463 XGI_DisplayOff(HwDeviceExtension, pVBInfo) ;
8464 XGI_SetCRT1Group(HwDeviceExtension, ModeNo, ModeIdIndex, pVBInfo);
8465 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
8468 XGI_UpdateModeInfo(HwDeviceExtension, pVBInfo);
8470 if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */
8471 XGI_LockCRT2(HwDeviceExtension, pVBInfo);