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 if (ChipType >= XG40) {
79 = (struct XGI_MCLKDataStruct *) XGI340New_MCLKData;
81 = (struct XGI_ECLKDataStruct *) XGI340_ECLKData;
84 = (struct XGI_MCLKDataStruct *) XGI330New_MCLKData;
86 = (struct XGI_ECLKDataStruct *) XGI330_ECLKData;
89 pVBInfo->VCLKData = (struct XGI_VCLKDataStruct *) XGI_VCLKData;
90 pVBInfo->VBVCLKData = (struct XGI_VBVCLKDataStruct *) XGI_VBVCLKData;
91 pVBInfo->ScreenOffset = XGI330_ScreenOffset;
92 pVBInfo->StResInfo = (struct XGI_StResInfoStruct *) XGI330_StResInfo;
94 = (struct XGI_ModeResInfoStruct *) XGI330_ModeResInfo;
96 pVBInfo->pOutputSelect = &XGI330_OutputSelect;
97 pVBInfo->pSoftSetting = &XGI330_SoftSetting;
98 pVBInfo->pSR07 = &XGI330_SR07;
99 pVBInfo->LCDResInfo = 0;
100 pVBInfo->LCDTypeInfo = 0;
101 pVBInfo->LCDInfo = 0;
105 pVBInfo->SR15 = XGI340_SR13;
106 pVBInfo->CR40 = XGI340_cr41;
107 pVBInfo->SR25 = XGI330_sr25;
108 pVBInfo->pSR31 = &XGI330_sr31;
109 pVBInfo->pSR32 = &XGI330_sr32;
110 pVBInfo->CR6B = XGI340_CR6B;
111 pVBInfo->CR6E = XGI340_CR6E;
112 pVBInfo->CR6F = XGI340_CR6F;
113 pVBInfo->CR89 = XGI340_CR89;
114 pVBInfo->AGPReg = XGI340_AGPReg;
115 pVBInfo->SR16 = XGI340_SR16;
116 pVBInfo->pCRCF = &XG40_CRCF;
117 pVBInfo->pXGINew_DRAMTypeDefinition = &XG40_DRAMTypeDefinition;
119 pVBInfo->CR49 = XGI330_CR49;
120 pVBInfo->pSR1F = &XGI330_SR1F;
121 pVBInfo->pSR21 = &XGI330_SR21;
122 pVBInfo->pSR22 = &XGI330_SR22;
123 pVBInfo->pSR23 = &XGI330_SR23;
124 pVBInfo->pSR24 = &XGI330_SR24;
125 pVBInfo->pSR33 = &XGI330_SR33;
127 pVBInfo->pCRT2Data_1_2 = &XGI330_CRT2Data_1_2;
128 pVBInfo->pCRT2Data_4_D = &XGI330_CRT2Data_4_D;
129 pVBInfo->pCRT2Data_4_E = &XGI330_CRT2Data_4_E;
130 pVBInfo->pCRT2Data_4_10 = &XGI330_CRT2Data_4_10;
131 pVBInfo->pRGBSenseData = &XGI330_RGBSenseData;
132 pVBInfo->pVideoSenseData = &XGI330_VideoSenseData;
133 pVBInfo->pYCSenseData = &XGI330_YCSenseData;
134 pVBInfo->pRGBSenseData2 = &XGI330_RGBSenseData2;
135 pVBInfo->pVideoSenseData2 = &XGI330_VideoSenseData2;
136 pVBInfo->pYCSenseData2 = &XGI330_YCSenseData2;
138 pVBInfo->NTSCTiming = XGI330_NTSCTiming;
139 pVBInfo->PALTiming = XGI330_PALTiming;
140 pVBInfo->HiTVExtTiming = XGI330_HiTVExtTiming;
141 pVBInfo->HiTVSt1Timing = XGI330_HiTVSt1Timing;
142 pVBInfo->HiTVSt2Timing = XGI330_HiTVSt2Timing;
143 pVBInfo->HiTVTextTiming = XGI330_HiTVTextTiming;
144 pVBInfo->YPbPr750pTiming = XGI330_YPbPr750pTiming;
145 pVBInfo->YPbPr525pTiming = XGI330_YPbPr525pTiming;
146 pVBInfo->YPbPr525iTiming = XGI330_YPbPr525iTiming;
147 pVBInfo->HiTVGroup3Data = XGI330_HiTVGroup3Data;
148 pVBInfo->HiTVGroup3Simu = XGI330_HiTVGroup3Simu;
149 pVBInfo->HiTVGroup3Text = XGI330_HiTVGroup3Text;
150 pVBInfo->Ren525pGroup3 = XGI330_Ren525pGroup3;
151 pVBInfo->Ren750pGroup3 = XGI330_Ren750pGroup3;
153 pVBInfo->TimingH = (struct XGI_TimingHStruct *) XGI_TimingH;
154 pVBInfo->TimingV = (struct XGI_TimingVStruct *) XGI_TimingV;
155 pVBInfo->UpdateCRT1 = (struct XGI_XG21CRT1Struct *) XGI_UpdateCRT1Table;
157 pVBInfo->CHTVVCLKUNTSC = XGI330_CHTVVCLKUNTSC;
158 pVBInfo->CHTVVCLKONTSC = XGI330_CHTVVCLKONTSC;
159 pVBInfo->CHTVVCLKUPAL = XGI330_CHTVVCLKUPAL;
160 pVBInfo->CHTVVCLKOPAL = XGI330_CHTVVCLKOPAL;
162 /* 310 customization related */
163 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType & VB_XGI302LV))
164 pVBInfo->LCDCapList = XGI_LCDDLCapList;
166 pVBInfo->LCDCapList = XGI_LCDCapList;
168 if ((ChipType == XG21) || (ChipType == XG27))
169 pVBInfo->XG21_LVDSCapList = XGI21_LCDCapList;
171 pVBInfo->XGI_TVDelayList = XGI301TVDelayList;
172 pVBInfo->XGI_TVDelayList2 = XGI301TVDelayList2;
174 pVBInfo->pXGINew_I2CDefinition = &XG40_I2CDefinition;
176 if (ChipType >= XG20)
177 pVBInfo->pXGINew_CR97 = &XG20_CR97;
179 if (ChipType == XG27) {
181 = (struct XGI_MCLKDataStruct *) XGI27New_MCLKData;
182 pVBInfo->CR40 = XGI27_cr41;
183 pVBInfo->pXGINew_CR97 = &XG27_CR97;
184 pVBInfo->pSR36 = &XG27_SR36;
185 pVBInfo->pCR8F = &XG27_CR8F;
186 pVBInfo->pCRD0 = XG27_CRD0;
187 pVBInfo->pCRDE = XG27_CRDE;
188 pVBInfo->pSR40 = &XG27_SR40;
189 pVBInfo->pSR41 = &XG27_SR41;
193 if (ChipType >= XG20) {
194 pVBInfo->pDVOSetting = &XG21_DVOSetting;
195 pVBInfo->pCR2E = &XG21_CR2E;
196 pVBInfo->pCR2F = &XG21_CR2F;
197 pVBInfo->pCR46 = &XG21_CR46;
198 pVBInfo->pCR47 = &XG21_CR47;
203 static unsigned char XGI_GetModePtr(unsigned short ModeNo, unsigned short ModeIdIndex,
204 struct vb_device_info *pVBInfo)
209 index = pVBInfo->SModeIDTable[ModeIdIndex].St_StTableIndex;
211 if (pVBInfo->ModeType <= 0x02)
212 index = 0x1B; /* 02 -> ModeEGA */
216 return index; /* Get pVBInfo->StandTable index */
220 unsigned char XGI_SetBIOSData(unsigned short ModeNo, unsigned short ModeIdIndex) {
225 /* unsigned char XGI_ClearBankRegs(unsigned short ModeNo, unsigned short ModeIdIndex) {
230 static void XGI_SetSeqRegs(unsigned short ModeNo, unsigned short StandTableIndex,
231 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
233 unsigned char tempah, SRdata;
235 unsigned short i, modeflag;
238 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
240 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
242 XGINew_SetReg1(pVBInfo->P3c4, 0x00, 0x03); /* Set SR0 */
243 tempah = pVBInfo->StandTable[StandTableIndex].SR[0];
246 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
249 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD)) {
250 if (pVBInfo->VBInfo & SetInSlaveMode)
255 tempah |= 0x20; /* screen off */
256 XGINew_SetReg1(pVBInfo->P3c4, 0x01, tempah); /* Set SR1 */
258 for (i = 02; i <= 04; i++) {
259 SRdata = pVBInfo->StandTable[StandTableIndex].SR[i - 1]; /* Get SR2,3,4 from file */
260 XGINew_SetReg1(pVBInfo->P3c4, i, SRdata); /* Set SR2 3 4 */
264 static void XGI_SetMiscRegs(unsigned short StandTableIndex,
265 struct vb_device_info *pVBInfo)
267 unsigned char Miscdata;
269 Miscdata = pVBInfo->StandTable[StandTableIndex].MISC; /* Get Misc from file */
271 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
272 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
278 XGINew_SetReg3(pVBInfo->P3c2, Miscdata); /* Set Misc(3c2) */
281 static void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension,
282 unsigned short StandTableIndex, struct vb_device_info *pVBInfo)
284 unsigned char CRTCdata;
287 CRTCdata = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11);
289 XGINew_SetReg1(pVBInfo->P3d4, 0x11, CRTCdata); /* Unlock CRTC */
291 for (i = 0; i <= 0x18; i++) {
292 CRTCdata = pVBInfo->StandTable[StandTableIndex].CRTC[i]; /* Get CRTC from file */
293 XGINew_SetReg1(pVBInfo->P3d4, i, CRTCdata); /* Set CRTC(3d4) */
296 if ((HwDeviceExtension->jChipType == XGI_630) && (HwDeviceExtension->jChipRevision == 0x30)) {
297 if (pVBInfo->VBInfo & SetInSlaveMode) {
298 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) {
299 XGINew_SetReg1(pVBInfo->P3d4, 0x18, 0xFE);
306 static void XGI_SetATTRegs(unsigned short ModeNo, unsigned short StandTableIndex,
307 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
309 unsigned char ARdata;
310 unsigned short i, modeflag;
313 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
315 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
317 for (i = 0; i <= 0x13; i++) {
318 ARdata = pVBInfo->StandTable[StandTableIndex].ATTR[i];
319 if (modeflag & Charx8Dot) { /* ifndef Dot9 */
321 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
324 if (pVBInfo->VBInfo & (SetCRT2ToTV
334 XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */
335 XGINew_SetReg3(pVBInfo->P3c0, i); /* set index */
336 XGINew_SetReg3(pVBInfo->P3c0, ARdata); /* set data */
339 XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */
340 XGINew_SetReg3(pVBInfo->P3c0, 0x14); /* set index */
341 XGINew_SetReg3(pVBInfo->P3c0, 0x00); /* set data */
342 XGINew_GetReg2(pVBInfo->P3da); /* Enable Attribute */
343 XGINew_SetReg3(pVBInfo->P3c0, 0x20);
346 static void XGI_SetGRCRegs(unsigned short StandTableIndex,
347 struct vb_device_info *pVBInfo)
349 unsigned char GRdata;
352 for (i = 0; i <= 0x08; i++) {
353 GRdata = pVBInfo->StandTable[StandTableIndex].GRC[i]; /* Get GR from file */
354 XGINew_SetReg1(pVBInfo->P3ce, i, GRdata); /* Set GR(3ce) */
357 if (pVBInfo->ModeType > ModeVGA) {
358 GRdata = (unsigned char) XGINew_GetReg1(pVBInfo->P3ce, 0x05);
359 GRdata &= 0xBF; /* 256 color disable */
360 XGINew_SetReg1(pVBInfo->P3ce, 0x05, GRdata);
364 static void XGI_ClearExt1Regs(struct vb_device_info *pVBInfo)
368 for (i = 0x0A; i <= 0x0E; i++)
369 XGINew_SetReg1(pVBInfo->P3c4, i, 0x00); /* Clear SR0A-SR0E */
372 static unsigned char XGI_SetDefaultVCLK(struct vb_device_info *pVBInfo)
375 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x31, ~0x30, 0x20);
376 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, pVBInfo->VCLKData[0].SR2B);
377 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, pVBInfo->VCLKData[0].SR2C);
379 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x31, ~0x30, 0x10);
380 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, pVBInfo->VCLKData[1].SR2B);
381 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, pVBInfo->VCLKData[1].SR2C);
383 XGINew_SetRegAND(pVBInfo->P3c4, 0x31, ~0x30);
387 static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo,
388 unsigned short ModeIdIndex,
389 unsigned short RefreshRateTableIndex, unsigned short *i,
390 struct vb_device_info *pVBInfo)
392 unsigned short tempax, tempbx, resinfo, modeflag, infoflag;
395 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ModeFlag */
397 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
399 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
400 tempbx = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID;
403 if (pVBInfo->IF_DEF_LVDS == 0) {
404 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
405 tempax |= SupportRAMDAC2;
407 if (pVBInfo->VBType & VB_XGI301C)
408 tempax |= SupportCRT2in301C;
411 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { /* 301b */
412 tempax |= SupportLCD;
414 if (pVBInfo->LCDResInfo != Panel1280x1024) {
415 if (pVBInfo->LCDResInfo != Panel1280x960) {
416 if (pVBInfo->LCDInfo & LCDNonExpanding) {
426 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { /* for HiTV */
427 if ((pVBInfo->VBType & VB_XGI301LV)
428 && (pVBInfo->VBExtInfo == VB_YPbPr1080i)) {
429 tempax |= SupportYPbPr;
430 if (pVBInfo->VBInfo & SetInSlaveMode) {
441 tempax |= SupportHiVisionTV;
442 if (pVBInfo->VBInfo & SetInSlaveMode) {
457 if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO
458 | SetCRT2ToSVIDEO | SetCRT2ToSCART
459 | SetCRT2ToYPbPr | SetCRT2ToHiVisionTV)) {
462 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
463 | VB_XGI301LV | VB_XGI302LV
465 tempax |= SupportTV1024;
468 if (!(pVBInfo->VBInfo & SetPALTV)) {
469 if (modeflag & NoSupportSimuTV) {
472 if (!(pVBInfo->VBInfo
481 } else { /* for LVDS */
482 if (pVBInfo->IF_DEF_CH7005 == 1) {
483 if (pVBInfo->VBInfo & SetCRT2ToTV)
484 tempax |= SupportCHTV;
487 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
488 tempax |= SupportLCD;
491 return 0; /* 1024x768 */
493 if (pVBInfo->LCDResInfo < Panel1024x768) {
495 return 0; /* 800x600 */
498 return 0; /* 512x384 */
503 for (; pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID == tempbx; (*i)--) {
505 = pVBInfo->RefIndex[RefreshRateTableIndex
506 + (*i)].Ext_InfoFlag;
507 if (infoflag & tempax)
514 for ((*i) = 0;; (*i)++) {
516 = pVBInfo->RefIndex[RefreshRateTableIndex
517 + (*i)].Ext_InfoFlag;
518 if (pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID
523 if (infoflag & tempax)
529 static void XGI_SetSync(unsigned short RefreshRateTableIndex,
530 struct vb_device_info *pVBInfo)
532 unsigned short sync, temp;
534 sync = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag >> 8; /* di+0x00 */
538 XGINew_SetReg3(pVBInfo->P3c2, temp); /* Set Misc(3c2) */
541 static void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo,
542 struct xgi_hw_device_info *HwDeviceExtension)
544 unsigned char data, data1, pushax;
547 /* XGINew_SetReg1(pVBInfo->P3d4, 0x51, 0); */
548 /* XGINew_SetReg1(pVBInfo->P3d4, 0x56, 0); */
549 /* XGINew_SetRegANDOR(pVBInfo->P3d4, 0x11, 0x7f, 0x00); */
551 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11); /* unlock cr0-7 */
553 XGINew_SetReg1(pVBInfo->P3d4, 0x11, data);
555 data = pVBInfo->TimingH[0].data[0];
556 XGINew_SetReg1(pVBInfo->P3d4, 0, data);
558 for (i = 0x01; i <= 0x04; i++) {
559 data = pVBInfo->TimingH[0].data[i];
560 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 1), data);
563 for (i = 0x05; i <= 0x06; i++) {
564 data = pVBInfo->TimingH[0].data[i];
565 XGINew_SetReg1(pVBInfo->P3c4, (unsigned short) (i + 6), data);
568 j = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x0e);
570 data = pVBInfo->TimingH[0].data[7];
573 XGINew_SetReg1(pVBInfo->P3c4, 0x0e, data);
575 if (HwDeviceExtension->jChipType >= XG20) {
576 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x04);
578 XGINew_SetReg1(pVBInfo->P3d4, 0x04, data);
579 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x05);
585 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4,
588 XGINew_SetReg1(pVBInfo->P3c4, 0x0c, data);
593 XGINew_SetReg1(pVBInfo->P3d4, 0x05, data);
594 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x0e);
600 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0e, ~0xE0, data);
604 static void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex, unsigned short ModeNo,
605 struct vb_device_info *pVBInfo)
610 /* XGINew_SetReg1(pVBInfo->P3d4, 0x51, 0); */
611 /* XGINew_SetReg1(pVBInfo->P3d4, 0x56, 0); */
612 /* XGINew_SetRegANDOR(pVBInfo->P3d4, 0x11, 0x7f, 0x00); */
614 for (i = 0x00; i <= 0x01; i++) {
615 data = pVBInfo->TimingV[0].data[i];
616 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 6), data);
619 for (i = 0x02; i <= 0x03; i++) {
620 data = pVBInfo->TimingV[0].data[i];
621 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 0x0e), data);
624 for (i = 0x04; i <= 0x05; i++) {
625 data = pVBInfo->TimingV[0].data[i];
626 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 0x11), data);
629 j = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x0a);
631 data = pVBInfo->TimingV[0].data[6];
634 XGINew_SetReg1(pVBInfo->P3c4, 0x0a, data);
636 data = pVBInfo->TimingV[0].data[6];
641 i = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
643 i = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
649 j = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x09);
652 XGINew_SetReg1(pVBInfo->P3d4, 0x09, data);
655 static void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
656 unsigned short RefreshRateTableIndex,
657 struct vb_device_info *pVBInfo,
658 struct xgi_hw_device_info *HwDeviceExtension)
660 unsigned char index, data;
663 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; /* Get index */
664 index = index & IndexMask;
666 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11);
668 XGINew_SetReg1(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */
670 for (i = 0; i < 8; i++)
671 pVBInfo->TimingH[0].data[i]
672 = pVBInfo->XGINEWUB_CRT1Table[index].CR[i];
674 for (i = 0; i < 7; i++)
675 pVBInfo->TimingV[0].data[i]
676 = pVBInfo->XGINEWUB_CRT1Table[index].CR[i + 8];
678 XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension);
680 XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo);
682 if (pVBInfo->ModeType > 0x03)
683 XGINew_SetReg1(pVBInfo->P3d4, 0x14, 0x4F);
686 /* --------------------------------------------------------------------- */
687 /* Function : XGI_SetXG21CRTC */
688 /* Input : Stand or enhance CRTC table */
689 /* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */
690 /* Description : Set LCD timing */
691 /* --------------------------------------------------------------------- */
692 static void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
693 unsigned short RefreshRateTableIndex,
694 struct vb_device_info *pVBInfo)
696 unsigned char StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx;
697 unsigned short Temp1, Temp2, Temp3;
699 if (ModeNo <= 0x13) {
700 StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
701 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[4]; /* CR04 HRS */
702 XGINew_SetReg1(pVBInfo->P3c4, 0x2E, Tempax); /* SR2E [7:0]->HRS */
703 Tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[5]; /* Tempbx: CR05 HRE */
704 Tempbx &= 0x1F; /* Tempbx: HRE[4:0] */
706 Tempcx &= 0xE0; /* Tempcx: HRS[7:5] */
707 Tempdx = Tempcx | Tempbx; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
708 if (Tempbx < (Tempax & 0x1F)) /* IF HRE < HRS */
709 Tempdx |= 0x20; /* Tempdx: HRE = HRE + 0x20 */
710 Tempdx <<= 2; /* Tempdx << 2 */
711 XGINew_SetReg1(pVBInfo->P3c4, 0x2F, Tempdx); /* SR2F [7:2]->HRE */
712 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x30, 0xE3, 00);
714 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[16]; /* Tempax: CR16 VRS */
715 Tempbx = Tempax; /* Tempbx=Tempax */
716 Tempax &= 0x01; /* Tempax: VRS[0] */
717 XGINew_SetRegOR(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS */
718 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[7]; /* Tempax: CR7 VRS */
719 Tempdx = Tempbx >> 1; /* Tempdx: VRS[7:1] */
720 Tempcx = Tempax & 0x04; /* Tempcx: CR7[2] */
721 Tempcx <<= 5; /* Tempcx[7]: VRS[8] */
722 Tempdx |= Tempcx; /* Tempdx: VRS[8:1] */
723 XGINew_SetReg1(pVBInfo->P3c4, 0x34, Tempdx); /* SR34[7:0]: VRS[8:1] */
725 Temp1 = Tempcx << 1; /* Temp1[8]: VRS[8] unsigned char -> unsigned short */
726 Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */
727 Tempax &= 0x80; /* Tempax[7]: CR7[7] */
728 Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */
729 Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */
731 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[17]; /* CR16 VRE */
732 Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
733 Temp2 = Temp1 & 0x3F0; /* Temp2[9:4]: VRS[9:4] */
734 Temp2 |= Tempax; /* Temp2[9:0]: VRE[9:0] */
735 Temp3 = Temp1 & 0x0F; /* Temp3[3:0]: VRS[3:0] */
736 if (Tempax < Temp3) /* VRE[3:0]<VRS[3:0] */
737 Temp2 |= 0x10; /* Temp2: VRE + 0x10 */
738 Temp2 &= 0xFF; /* Temp2[7:0]: VRE[7:0] */
739 Tempax = (unsigned char) Temp2; /* Tempax[7:0]: VRE[7:0] */
740 Tempax <<= 2; /* Tempax << 2: VRE[5:0] */
741 Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */
742 Temp1 >>= 9; /* [10:9]->[1:0] */
743 Tempbx = (unsigned char) Temp1; /* Tempbx[1:0]: VRS[10:9] */
744 Tempax |= Tempbx; /* VRE[5:0]VRS[10:9] */
746 XGINew_SetReg1(pVBInfo->P3c4, 0x3F, Tempax); /* SR3F D[7:2]->VRE D[1:0]->VRS */
748 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
749 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3]; /* Tempax: CR4 HRS */
750 Tempcx = Tempax; /* Tempcx: HRS */
751 XGINew_SetReg1(pVBInfo->P3c4, 0x2E, Tempax); /* SR2E[7:0]->HRS */
753 Tempdx = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SRB */
754 Tempdx &= 0xC0; /* Tempdx[7:6]: SRB[7:6] */
755 Temp1 = Tempdx; /* Temp1[7:6]: HRS[9:8] */
756 Temp1 <<= 2; /* Temp1[9:8]: HRS[9:8] */
757 Temp1 |= Tempax; /* Temp1[9:0]: HRS[9:0] */
759 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */
760 Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */
762 Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[6]; /* SRC */
763 Tempbx &= 0x04; /* Tempbx[2]: HRE[5] */
764 Tempbx <<= 3; /* Tempbx[5]: HRE[5] */
765 Tempax |= Tempbx; /* Tempax[5:0]: HRE[5:0] */
767 Temp2 = Temp1 & 0x3C0; /* Temp2[9:6]: HRS[9:6] */
768 Temp2 |= Tempax; /* Temp2[9:0]: HRE[9:0] */
770 Tempcx &= 0x3F; /* Tempcx[5:0]: HRS[5:0] */
771 if (Tempax < Tempcx) /* HRE < HRS */
772 Temp2 |= 0x40; /* Temp2 + 0x40 */
775 Tempax = (unsigned char) Temp2; /* Tempax: HRE[7:0] */
776 Tempax <<= 2; /* Tempax[7:2]: HRE[5:0] */
777 Tempdx >>= 6; /* Tempdx[7:6]->[1:0] HRS[9:8] */
778 Tempax |= Tempdx; /* HRE[5:0]HRS[9:8] */
779 XGINew_SetReg1(pVBInfo->P3c4, 0x2F, Tempax); /* SR2F D[7:2]->HRE, D[1:0]->HRS */
780 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x30, 0xE3, 00);
782 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10]; /* CR10 VRS */
783 Tempbx = Tempax; /* Tempbx: VRS */
784 Tempax &= 0x01; /* Tempax[0]: VRS[0] */
785 XGINew_SetRegOR(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS[0] */
786 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9]; /* CR7[2][7] VRE */
787 Tempcx = Tempbx >> 1; /* Tempcx[6:0]: VRS[7:1] */
788 Tempdx = Tempax & 0x04; /* Tempdx[2]: CR7[2] */
789 Tempdx <<= 5; /* Tempdx[7]: VRS[8] */
790 Tempcx |= Tempdx; /* Tempcx[7:0]: VRS[8:1] */
791 XGINew_SetReg1(pVBInfo->P3c4, 0x34, Tempcx); /* SR34[8:1]->VRS */
793 Temp1 = Tempdx; /* Temp1[7]: Tempdx[7] */
794 Temp1 <<= 1; /* Temp1[8]: VRS[8] */
795 Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */
797 Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */
798 Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */
799 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; /* Tempax: SRA */
800 Tempax &= 0x08; /* Tempax[3]: VRS[3] */
802 Temp2 <<= 7; /* Temp2[10]: VRS[10] */
803 Temp1 |= Temp2; /* Temp1[10:0]: VRS[10:0] */
805 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11]; /* Tempax: CR11 VRE */
806 Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
807 Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; /* Tempbx: SRA */
808 Tempbx &= 0x20; /* Tempbx[5]: VRE[5] */
809 Tempbx >>= 1; /* Tempbx[4]: VRE[4] */
810 Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */
811 Temp2 = Temp1 & 0x7E0; /* Temp2[10:5]: VRS[10:5] */
812 Temp2 |= Tempax; /* Temp2[10:5]: VRE[10:5] */
814 Temp3 = Temp1 & 0x1F; /* Temp3[4:0]: VRS[4:0] */
815 if (Tempax < Temp3) /* VRE < VRS */
816 Temp2 |= 0x20; /* VRE + 0x20 */
819 Tempax = (unsigned char) Temp2; /* Tempax: VRE[7:0] */
820 Tempax <<= 2; /* Tempax[7:0]; VRE[5:0]00 */
821 Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */
822 Temp1 >>= 9; /* Temp1[1:0]: VRS[10:9] */
823 Tempbx = (unsigned char) Temp1;
824 Tempax |= Tempbx; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */
826 XGINew_SetReg1(pVBInfo->P3c4, 0x3F, Tempax); /* SR3F D[7:2]->VRE D[1:0]->VRS */
830 static void XGI_SetXG27CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
831 unsigned short RefreshRateTableIndex,
832 struct vb_device_info *pVBInfo)
834 unsigned short StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx;
836 if (ModeNo <= 0x13) {
837 StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
838 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[4]; /* CR04 HRS */
839 XGINew_SetReg1(pVBInfo->P3c4, 0x2E, Tempax); /* SR2E [7:0]->HRS */
840 Tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[5]; /* Tempbx: CR05 HRE */
841 Tempbx &= 0x1F; /* Tempbx: HRE[4:0] */
843 Tempcx &= 0xE0; /* Tempcx: HRS[7:5] */
844 Tempdx = Tempcx | Tempbx; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
845 if (Tempbx < (Tempax & 0x1F)) /* IF HRE < HRS */
846 Tempdx |= 0x20; /* Tempdx: HRE = HRE + 0x20 */
847 Tempdx <<= 2; /* Tempdx << 2 */
848 XGINew_SetReg1(pVBInfo->P3c4, 0x2F, Tempdx); /* SR2F [7:2]->HRE */
849 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x30, 0xE3, 00);
851 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[16]; /* Tempax: CR10 VRS */
852 XGINew_SetReg1(pVBInfo->P3c4, 0x34, Tempax); /* SR34[7:0]->VRS */
853 Tempcx = Tempax; /* Tempcx=Tempax=VRS[7:0] */
854 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[7]; /* Tempax[7][2]: CR7[7][2] VRS[9][8] */
855 Tempbx = Tempax; /* Tempbx=CR07 */
856 Tempax &= 0x04; /* Tempax[2]: CR07[2] VRS[8] */
858 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x01, Tempax); /* SR35 D[0]->VRS D[8] */
859 Tempcx |= (Tempax << 8); /* Tempcx[8] |= VRS[8] */
860 Tempcx |= (Tempbx & 0x80) << 2; /* Tempcx[9] |= VRS[9] */
862 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[17]; /* CR11 VRE */
863 Tempax &= 0x0F; /* Tempax: VRE[3:0] */
864 Tempbx = Tempcx; /* Tempbx=Tempcx=VRS[9:0] */
865 Tempbx &= 0x3F0; /* Tempbx[9:4]: VRS[9:4] */
866 Tempbx |= Tempax; /* Tempbx[9:0]: VRE[9:0] */
867 if (Tempax <= (Tempcx & 0x0F)) /* VRE[3:0]<=VRS[3:0] */
868 Tempbx |= 0x10; /* Tempbx: VRE + 0x10 */
869 Tempax = (unsigned char) Tempbx & 0xFF; /* Tempax[7:0]: VRE[7:0] */
870 Tempax <<= 2; /* Tempax << 2: VRE[5:0] */
871 Tempcx = (Tempcx & 0x600) >> 8; /* Tempcx VRS[10:9] */
872 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax); /* SR3F D[7:2]->VRE D[5:0] */
873 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x06, Tempcx); /* SR35 D[2:1]->VRS[10:9] */
875 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
876 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3]; /* Tempax: CR4 HRS */
877 Tempbx = Tempax; /* Tempbx: HRS[7:0] */
878 XGINew_SetReg1(pVBInfo->P3c4, 0x2E, Tempax); /* SR2E[7:0]->HRS */
880 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SR0B */
881 Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
882 Tempbx |= (Tempax << 2); /* Tempbx: HRS[9:0] */
884 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */
885 Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */
886 Tempcx = Tempax; /* Tempcx: HRE[4:0] */
888 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[6]; /* SRC */
889 Tempax &= 0x04; /* Tempax[2]: HRE[5] */
890 Tempax <<= 3; /* Tempax[5]: HRE[5] */
891 Tempcx |= Tempax; /* Tempcx[5:0]: HRE[5:0] */
893 Tempbx = Tempbx & 0x3C0; /* Tempbx[9:6]: HRS[9:6] */
894 Tempbx |= Tempcx; /* Tempbx: HRS[9:6]HRE[5:0] */
896 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3]; /* Tempax: CR4 HRS */
897 Tempax &= 0x3F; /* Tempax: HRS[5:0] */
898 if (Tempcx <= Tempax) /* HRE[5:0] < HRS[5:0] */
899 Tempbx += 0x40; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/
901 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SR0B */
902 Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
903 Tempax >>= 6; /* Tempax[1:0]: HRS[9:8]*/
904 Tempax |= ((Tempbx << 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */
905 XGINew_SetReg1(pVBInfo->P3c4, 0x2F, Tempax); /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */
906 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x30, 0xE3, 00);
908 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10]; /* CR10 VRS */
909 XGINew_SetReg1(pVBInfo->P3c4, 0x34, Tempax); /* SR34[7:0]->VRS[7:0] */
911 Tempcx = Tempax; /* Tempcx <= VRS[7:0] */
912 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9]; /* CR7[7][2] VRS[9][8] */
913 Tempbx = Tempax; /* Tempbx <= CR07[7:0] */
914 Tempax = Tempax & 0x04; /* Tempax[2]: CR7[2]: VRS[8] */
915 Tempax >>= 2; /* Tempax[0]: VRS[8] */
916 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x01, Tempax); /* SR35[0]: VRS[8] */
917 Tempcx |= (Tempax << 8); /* Tempcx <= VRS[8:0] */
918 Tempcx |= ((Tempbx & 0x80) << 2); /* Tempcx <= VRS[9:0] */
919 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; /* Tempax: SR0A */
920 Tempax &= 0x08; /* SR0A[3] VRS[10] */
921 Tempcx |= (Tempax << 7); /* Tempcx <= VRS[10:0] */
923 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11]; /* Tempax: CR11 VRE */
924 Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
925 Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; /* Tempbx: SR0A */
926 Tempbx &= 0x20; /* Tempbx[5]: SR0A[5]: VRE[4] */
927 Tempbx >>= 1; /* Tempbx[4]: VRE[4] */
928 Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */
929 Tempbx = Tempcx; /* Tempbx: VRS[10:0] */
930 Tempbx &= 0x7E0; /* Tempbx[10:5]: VRS[10:5] */
931 Tempbx |= Tempax; /* Tempbx: VRS[10:5]VRE[4:0] */
933 if (Tempbx <= Tempcx) /* VRE <= VRS */
934 Tempbx |= 0x20; /* VRE + 0x20 */
936 Tempax = (Tempbx << 2) & 0xFF; /* Tempax: Tempax[7:0]; VRE[5:0]00 */
937 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax); /* SR3F[7:2]:VRE[5:0] */
938 Tempax = Tempcx >> 8;
939 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x07, Tempax); /* SR35[2:0]:VRS[10:8] */
943 /* --------------------------------------------------------------------- */
944 /* Function : XGI_SetXG21LCD */
946 /* Output : FCLK duty cycle, FCLK delay compensation */
947 /* Description : All values set zero */
948 /* --------------------------------------------------------------------- */
949 static void XGI_SetXG21LCD(struct vb_device_info *pVBInfo,
950 unsigned short RefreshRateTableIndex, unsigned short ModeNo)
952 unsigned short Data, Temp, b3CC;
953 unsigned short XGI_P3cc;
955 XGI_P3cc = pVBInfo->P3cc;
957 XGINew_SetReg1(pVBInfo->P3d4, 0x2E, 0x00);
958 XGINew_SetReg1(pVBInfo->P3d4, 0x2F, 0x00);
959 XGINew_SetReg1(pVBInfo->P3d4, 0x46, 0x00);
960 XGINew_SetReg1(pVBInfo->P3d4, 0x47, 0x00);
961 if (((*pVBInfo->pDVOSetting) & 0xC0) == 0xC0) {
962 XGINew_SetReg1(pVBInfo->P3d4, 0x2E, *pVBInfo->pCR2E);
963 XGINew_SetReg1(pVBInfo->P3d4, 0x2F, *pVBInfo->pCR2F);
964 XGINew_SetReg1(pVBInfo->P3d4, 0x46, *pVBInfo->pCR46);
965 XGINew_SetReg1(pVBInfo->P3d4, 0x47, *pVBInfo->pCR47);
968 Temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37);
971 XGINew_SetRegOR(pVBInfo->P3c4, 0x06, 0x40); /* 18 bits FP */
972 XGINew_SetRegOR(pVBInfo->P3c4, 0x09, 0x40);
975 XGINew_SetRegOR(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */
977 XGINew_SetRegAND(pVBInfo->P3c4, 0x30, ~0x20);
978 XGINew_SetRegAND(pVBInfo->P3c4, 0x35, ~0x80);
980 if (ModeNo <= 0x13) {
981 b3CC = (unsigned char) XGINew_GetReg2(XGI_P3cc);
983 XGINew_SetRegOR(pVBInfo->P3c4, 0x30, 0x20); /* Hsync polarity */
985 XGINew_SetRegOR(pVBInfo->P3c4, 0x35, 0x80); /* Vsync polarity */
987 Data = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
989 XGINew_SetRegOR(pVBInfo->P3c4, 0x30, 0x20); /* Hsync polarity */
991 XGINew_SetRegOR(pVBInfo->P3c4, 0x35, 0x80); /* Vsync polarity */
995 static void XGI_SetXG27LCD(struct vb_device_info *pVBInfo,
996 unsigned short RefreshRateTableIndex, unsigned short ModeNo)
998 unsigned short Data, Temp, b3CC;
999 unsigned short XGI_P3cc;
1001 XGI_P3cc = pVBInfo->P3cc;
1003 XGINew_SetReg1(pVBInfo->P3d4, 0x2E, 0x00);
1004 XGINew_SetReg1(pVBInfo->P3d4, 0x2F, 0x00);
1005 XGINew_SetReg1(pVBInfo->P3d4, 0x46, 0x00);
1006 XGINew_SetReg1(pVBInfo->P3d4, 0x47, 0x00);
1008 Temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37);
1009 if ((Temp & 0x03) == 0) { /* dual 12 */
1010 XGINew_SetReg1(pVBInfo->P3d4, 0x46, 0x13);
1011 XGINew_SetReg1(pVBInfo->P3d4, 0x47, 0x13);
1014 if (((*pVBInfo->pDVOSetting) & 0xC0) == 0xC0) {
1015 XGINew_SetReg1(pVBInfo->P3d4, 0x2E, *pVBInfo->pCR2E);
1016 XGINew_SetReg1(pVBInfo->P3d4, 0x2F, *pVBInfo->pCR2F);
1017 XGINew_SetReg1(pVBInfo->P3d4, 0x46, *pVBInfo->pCR46);
1018 XGINew_SetReg1(pVBInfo->P3d4, 0x47, *pVBInfo->pCR47);
1021 XGI_SetXG27FPBits(pVBInfo);
1023 XGINew_SetRegOR(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */
1025 XGINew_SetRegAND(pVBInfo->P3c4, 0x30, ~0x20); /* Hsync polarity */
1026 XGINew_SetRegAND(pVBInfo->P3c4, 0x35, ~0x80); /* Vsync polarity */
1028 if (ModeNo <= 0x13) {
1029 b3CC = (unsigned char) XGINew_GetReg2(XGI_P3cc);
1031 XGINew_SetRegOR(pVBInfo->P3c4, 0x30, 0x20); /* Hsync polarity */
1033 XGINew_SetRegOR(pVBInfo->P3c4, 0x35, 0x80); /* Vsync polarity */
1035 Data = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1037 XGINew_SetRegOR(pVBInfo->P3c4, 0x30, 0x20); /* Hsync polarity */
1039 XGINew_SetRegOR(pVBInfo->P3c4, 0x35, 0x80); /* Vsync polarity */
1043 /* --------------------------------------------------------------------- */
1044 /* Function : XGI_UpdateXG21CRTC */
1046 /* Output : CRT1 CRTC */
1047 /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */
1048 /* --------------------------------------------------------------------- */
1049 static void XGI_UpdateXG21CRTC(unsigned short ModeNo, struct vb_device_info *pVBInfo,
1050 unsigned short RefreshRateTableIndex)
1054 XGINew_SetRegAND(pVBInfo->P3d4, 0x11, 0x7F); /* Unlock CR0~7 */
1055 if (ModeNo <= 0x13) {
1056 for (i = 0; i < 12; i++) {
1057 if (ModeNo == pVBInfo->UpdateCRT1[i].ModeID)
1062 && (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC
1065 else if (ModeNo == 0x2E
1066 && (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC
1069 else if (ModeNo == 0x2F)
1071 else if (ModeNo == 0x50)
1073 else if (ModeNo == 0x59)
1078 XGINew_SetReg1(pVBInfo->P3d4, 0x02,
1079 pVBInfo->UpdateCRT1[index].CR02);
1080 XGINew_SetReg1(pVBInfo->P3d4, 0x03,
1081 pVBInfo->UpdateCRT1[index].CR03);
1082 XGINew_SetReg1(pVBInfo->P3d4, 0x15,
1083 pVBInfo->UpdateCRT1[index].CR15);
1084 XGINew_SetReg1(pVBInfo->P3d4, 0x16,
1085 pVBInfo->UpdateCRT1[index].CR16);
1089 static void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension,
1090 unsigned short ModeNo, unsigned short ModeIdIndex,
1091 unsigned short RefreshRateTableIndex,
1092 struct vb_device_info *pVBInfo)
1094 unsigned short resindex, tempax, tempbx, tempcx, temp, modeflag;
1098 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
1100 if (ModeNo <= 0x13) {
1101 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
1102 tempax = pVBInfo->StResInfo[resindex].HTotal;
1103 tempbx = pVBInfo->StResInfo[resindex].VTotal;
1105 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1106 tempax = pVBInfo->ModeResInfo[resindex].HTotal;
1107 tempbx = pVBInfo->ModeResInfo[resindex].VTotal;
1110 if (modeflag & HalfDCLK)
1111 tempax = tempax >> 1;
1113 if (ModeNo > 0x13) {
1114 if (modeflag & HalfDCLK)
1115 tempax = tempax << 1;
1117 temp = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1119 if (temp & InterlaceMode)
1120 tempbx = tempbx >> 1;
1122 if (modeflag & DoubleScanMode)
1123 tempbx = tempbx << 1;
1128 /* if (!(modeflag & Charx8Dot)) */
1135 temp = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11);
1136 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11);
1138 XGINew_SetReg1(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */
1139 XGINew_SetReg1(pVBInfo->P3d4, 0x01, (unsigned short) (tempcx & 0xff));
1140 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x0b, ~0x0c,
1141 (unsigned short) ((tempcx & 0x0ff00) >> 10));
1142 XGINew_SetReg1(pVBInfo->P3d4, 0x12, (unsigned short) (tempbx & 0xff));
1144 tempbx = tempbx >> 8;
1152 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x42, tempax);
1153 data = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x07);
1160 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x0a, ~0x02, tempax);
1161 XGINew_SetReg1(pVBInfo->P3d4, 0x11, temp);
1164 unsigned short XGI_GetResInfo(unsigned short ModeNo,
1165 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
1167 unsigned short resindex;
1170 resindex = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; /* si+St_ResInfo */
1172 resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; /* si+Ext_ResInfo */
1176 static void XGI_SetCRT1Offset(unsigned short ModeNo, unsigned short ModeIdIndex,
1177 unsigned short RefreshRateTableIndex,
1178 struct xgi_hw_device_info *HwDeviceExtension,
1179 struct vb_device_info *pVBInfo)
1181 unsigned short temp, ah, al, temp2, i, DisplayUnit;
1184 temp = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo;
1186 temp = pVBInfo->ScreenOffset[temp];
1188 temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1189 temp2 &= InterlaceMode;
1194 temp2 = pVBInfo->ModeType - ModeEGA;
1219 if ((ModeNo >= 0x26) && (ModeNo <= 0x28))
1220 temp = temp * temp2 + temp2 / 2;
1227 temp = temp >> 8; /* ah */
1229 i = XGINew_GetReg1(pVBInfo->P3c4, 0x0E);
1232 XGINew_SetReg1(pVBInfo->P3c4, 0x0E, i);
1234 temp = (unsigned char) temp2;
1235 temp &= 0xFF; /* al */
1236 XGINew_SetReg1(pVBInfo->P3d4, 0x13, temp);
1238 /* SetDisplayUnit */
1239 temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1240 temp2 &= InterlaceMode;
1244 DisplayUnit = DisplayUnit << 5;
1245 ah = (DisplayUnit & 0xff00) >> 8;
1246 al = DisplayUnit & 0x00ff;
1252 if (HwDeviceExtension->jChipType >= XG20)
1253 if ((ModeNo == 0x4A) | (ModeNo == 0x49))
1256 XGINew_SetReg1(pVBInfo->P3c4, 0x10, ah);
1259 static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo,
1260 unsigned short ModeIdIndex,
1261 unsigned short RefreshRateTableIndex,
1262 struct xgi_hw_device_info *HwDeviceExtension,
1263 struct vb_device_info *pVBInfo)
1265 unsigned short tempbx;
1267 unsigned short LCDXlat1VCLK[4] = { VCLK65 + 2, VCLK65 + 2, VCLK65 + 2,
1269 unsigned short LCDXlat2VCLK[4] = { VCLK108_2 + 5, VCLK108_2 + 5,
1270 VCLK108_2 + 5, VCLK108_2 + 5 };
1271 unsigned short LVDSXlat1VCLK[4] = { VCLK40, VCLK40, VCLK40, VCLK40 };
1272 unsigned short LVDSXlat2VCLK[4] = { VCLK65 + 2, VCLK65 + 2, VCLK65 + 2,
1274 unsigned short LVDSXlat3VCLK[4] = { VCLK65 + 2, VCLK65 + 2, VCLK65 + 2,
1277 unsigned short CRT2Index, VCLKIndex;
1278 unsigned short modeflag, resinfo;
1279 unsigned char *CHTVVCLKPtr = NULL;
1281 if (ModeNo <= 0x13) {
1282 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
1283 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
1284 CRT2Index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
1286 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
1287 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
1289 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
1292 if (pVBInfo->IF_DEF_LVDS == 0) {
1293 CRT2Index = CRT2Index >> 6; /* for LCD */
1294 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { /*301b*/
1295 if (pVBInfo->LCDResInfo != Panel1024x768)
1296 VCLKIndex = LCDXlat2VCLK[CRT2Index];
1298 VCLKIndex = LCDXlat1VCLK[CRT2Index];
1299 } else { /* for TV */
1300 if (pVBInfo->VBInfo & SetCRT2ToTV) {
1301 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
1302 if (pVBInfo->SetFlag & RPLLDIV2XO) {
1303 VCLKIndex = HiTVVCLKDIV2;
1308 VCLKIndex = HiTVVCLK;
1314 if (pVBInfo->SetFlag & TVSimuMode) {
1315 if (modeflag & Charx8Dot) {
1330 if (pVBInfo->VBType & VB_XGI301LV) { /* 301lv */
1331 if (!(pVBInfo->VBExtInfo
1332 == VB_YPbPr1080i)) {
1335 if (!(pVBInfo->VBExtInfo
1339 if (!(pVBInfo->VBExtInfo
1343 if (!(pVBInfo->SetFlag
1352 if (pVBInfo->VBInfo & SetCRT2ToTV) {
1353 if (pVBInfo->SetFlag
1355 VCLKIndex = TVVCLKDIV2;
1367 } else { /* for CRT2 */
1368 VCLKIndex = (unsigned char) XGINew_GetReg2(
1369 (pVBInfo->P3ca + 0x02)); /* Port 3cch */
1370 VCLKIndex = ((VCLKIndex >> 2) & 0x03);
1371 if (ModeNo > 0x13) {
1373 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; /* di+Ext_CRTVCLK */
1374 VCLKIndex &= IndexMask;
1380 VCLKIndex = CRT2Index;
1382 VCLKIndex = CRT2Index;
1384 if (pVBInfo->IF_DEF_CH7005 == 1) {
1385 if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) {
1389 if (pVBInfo->VBInfo & SetPALTV)
1392 if (pVBInfo->VBInfo & SetCHTVOverScan)
1397 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC;
1400 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC;
1403 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL;
1406 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL;
1412 VCLKIndex = CHTVVCLKPtr[VCLKIndex];
1415 VCLKIndex = VCLKIndex >> 6;
1416 if ((pVBInfo->LCDResInfo == Panel800x600)
1417 || (pVBInfo->LCDResInfo == Panel320x480))
1418 VCLKIndex = LVDSXlat1VCLK[VCLKIndex];
1419 else if ((pVBInfo->LCDResInfo == Panel1024x768)
1420 || (pVBInfo->LCDResInfo
1421 == Panel1024x768x75))
1422 VCLKIndex = LVDSXlat2VCLK[VCLKIndex];
1424 VCLKIndex = LVDSXlat3VCLK[VCLKIndex];
1427 /* VCLKIndex = VCLKIndex&IndexMask; */
1432 static void XGI_SetCRT1VCLK(unsigned short ModeNo, unsigned short ModeIdIndex,
1433 struct xgi_hw_device_info *HwDeviceExtension,
1434 unsigned short RefreshRateTableIndex,
1435 struct vb_device_info *pVBInfo)
1437 unsigned char index, data;
1438 unsigned short vclkindex;
1440 if (pVBInfo->IF_DEF_LVDS == 1) {
1441 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1442 data = XGINew_GetReg1(pVBInfo->P3c4, 0x31) & 0xCF;
1443 XGINew_SetReg1(pVBInfo->P3c4, 0x31, data);
1444 XGINew_SetReg1(pVBInfo->P3c4, 0x2B,
1445 pVBInfo->VCLKData[index].SR2B);
1446 XGINew_SetReg1(pVBInfo->P3c4, 0x2C,
1447 pVBInfo->VCLKData[index].SR2C);
1448 XGINew_SetReg1(pVBInfo->P3c4, 0x2D, 0x01);
1449 } else if ((pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
1450 | VB_XGI302LV | VB_XGI301C)) && (pVBInfo->VBInfo
1452 vclkindex = XGI_GetVCLK2Ptr(ModeNo, ModeIdIndex,
1453 RefreshRateTableIndex, HwDeviceExtension,
1455 data = XGINew_GetReg1(pVBInfo->P3c4, 0x31) & 0xCF;
1456 XGINew_SetReg1(pVBInfo->P3c4, 0x31, data);
1457 data = pVBInfo->VBVCLKData[vclkindex].Part4_A;
1458 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, data);
1459 data = pVBInfo->VBVCLKData[vclkindex].Part4_B;
1460 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, data);
1461 XGINew_SetReg1(pVBInfo->P3c4, 0x2D, 0x01);
1463 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1464 data = XGINew_GetReg1(pVBInfo->P3c4, 0x31) & 0xCF;
1465 XGINew_SetReg1(pVBInfo->P3c4, 0x31, data);
1466 XGINew_SetReg1(pVBInfo->P3c4, 0x2B,
1467 pVBInfo->VCLKData[index].SR2B);
1468 XGINew_SetReg1(pVBInfo->P3c4, 0x2C,
1469 pVBInfo->VCLKData[index].SR2C);
1470 XGINew_SetReg1(pVBInfo->P3c4, 0x2D, 0x01);
1473 if (HwDeviceExtension->jChipType >= XG20) {
1474 if (pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag & HalfDCLK) {
1475 data = XGINew_GetReg1(pVBInfo->P3c4, 0x2B);
1476 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, data);
1477 data = XGINew_GetReg1(pVBInfo->P3c4, 0x2C);
1484 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, data);
1489 static void XGI_SetCRT1FIFO(unsigned short ModeNo,
1490 struct xgi_hw_device_info *HwDeviceExtension,
1491 struct vb_device_info *pVBInfo)
1493 unsigned short data;
1495 data = XGINew_GetReg1(pVBInfo->P3c4, 0x3D);
1497 XGINew_SetReg1(pVBInfo->P3c4, 0x3D, data); /* diable auto-threshold */
1499 if (ModeNo > 0x13) {
1500 XGINew_SetReg1(pVBInfo->P3c4, 0x08, 0x34);
1501 data = XGINew_GetReg1(pVBInfo->P3c4, 0x09);
1503 XGINew_SetReg1(pVBInfo->P3c4, 0x09, data | 0x30);
1504 data = XGINew_GetReg1(pVBInfo->P3c4, 0x3D);
1506 XGINew_SetReg1(pVBInfo->P3c4, 0x3D, data);
1508 if (HwDeviceExtension->jChipType == XG27) {
1509 XGINew_SetReg1(pVBInfo->P3c4, 0x08, 0x0E);
1510 data = XGINew_GetReg1(pVBInfo->P3c4, 0x09);
1512 XGINew_SetReg1(pVBInfo->P3c4, 0x09, data | 0x20);
1514 XGINew_SetReg1(pVBInfo->P3c4, 0x08, 0xAE);
1515 data = XGINew_GetReg1(pVBInfo->P3c4, 0x09);
1517 XGINew_SetReg1(pVBInfo->P3c4, 0x09, data);
1521 if (HwDeviceExtension->jChipType == XG21)
1522 XGI_SetXG21FPBits(pVBInfo); /* Fix SR9[7:6] can't read back */
1525 static void XGI_SetVCLKState(struct xgi_hw_device_info *HwDeviceExtension,
1526 unsigned short ModeNo, unsigned short RefreshRateTableIndex,
1527 struct vb_device_info *pVBInfo)
1529 unsigned short data, data2 = 0;
1532 unsigned char index;
1537 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1539 VCLK = pVBInfo->VCLKData[index].CLOCK;
1542 data = XGINew_GetReg1(pVBInfo->P3c4, 0x32);
1545 data |= 0x0c; /* VCLK > 200 */
1547 if (HwDeviceExtension->jChipType >= XG20)
1548 data &= ~0x04; /* 2 pixel mode */
1550 XGINew_SetReg1(pVBInfo->P3c4, 0x32, data);
1552 if (HwDeviceExtension->jChipType < XG20) {
1553 data = XGINew_GetReg1(pVBInfo->P3c4, 0x1F);
1557 XGINew_SetReg1(pVBInfo->P3c4, 0x1F, data);
1560 /* Jong for Adavantech LCD ripple issue
1561 if ((VCLK >= 0) && (VCLK < 135))
1563 else if ((VCLK >= 135) && (VCLK < 160))
1565 else if ((VCLK >= 160) && (VCLK < 260))
1567 else if (VCLK > 260)
1572 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x07, 0xFC, data2);
1573 if (HwDeviceExtension->jChipType >= XG27)
1574 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x40, 0xFC, data2 & 0x03);
1578 static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension,
1579 unsigned short ModeNo, unsigned short ModeIdIndex,
1580 unsigned short RefreshRateTableIndex,
1581 struct vb_device_info *pVBInfo)
1583 unsigned short data, data2, data3, infoflag = 0, modeflag, resindex,
1586 if (ModeNo > 0x13) {
1587 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1589 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1591 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ModeFlag */
1593 if (XGINew_GetReg1(pVBInfo->P3d4, 0x31) & 0x01)
1594 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x1F, 0x3F, 0x00);
1603 if (ModeNo > 0x13) {
1604 if (pVBInfo->ModeType > 0x02) {
1606 data3 = pVBInfo->ModeType - ModeVGA;
1612 data &= InterlaceMode;
1617 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x06, ~0x3F, data2);
1618 /* XGINew_SetReg1(pVBInfo->P3c4,0x06,data2); */
1619 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
1621 xres = pVBInfo->StResInfo[resindex].HTotal;
1623 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
1626 if (infoflag & InterlaceMode) {
1629 else if (xres == 1280)
1633 data2 = data & 0x00FF;
1634 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x19, 0xFF, data2);
1635 data2 = (data & 0xFF00) >> 8;
1636 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x19, 0xFC, data2);
1638 if (modeflag & HalfDCLK)
1639 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x01, 0xF7, 0x08);
1643 if (modeflag & LineCompareOff)
1646 if (ModeNo > 0x13) {
1647 if (pVBInfo->ModeType == ModeEGA)
1651 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0F, ~0x48, data2);
1653 if (pVBInfo->ModeType != ModeText) {
1655 if (pVBInfo->ModeType != ModeEGA)
1658 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x21, 0x1F, data);
1660 XGI_SetVCLKState(HwDeviceExtension, ModeNo, RefreshRateTableIndex,
1663 /* if (modeflag&HalfDCLK) //030305 fix lowresolution bug */
1664 /* if (XGINew_IF_DEF_NEW_LOWRES) */
1665 /* XGI_VesaLowResolution(ModeNo, ModeIdIndex); //030305 fix lowresolution bug */
1667 data = XGINew_GetReg1(pVBInfo->P3d4, 0x31);
1669 if (HwDeviceExtension->jChipType == XG27) {
1674 XGINew_SetReg1(pVBInfo->P3d4, 0x52, data);
1675 XGINew_SetRegOR(pVBInfo->P3d4, 0x51, 0x10);
1676 } else if (HwDeviceExtension->jChipType >= XG20) {
1681 XGINew_SetReg1(pVBInfo->P3d4, 0x52, data);
1682 XGINew_SetReg1(pVBInfo->P3d4, 0x51, 0x02);
1688 XGINew_SetReg1(pVBInfo->P3d4, 0x52, data);
1694 void XGI_VesaLowResolution(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
1696 unsigned short modeflag;
1699 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1701 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
1703 if (ModeNo > 0x13) {
1704 if (modeflag & DoubleScanMode) {
1705 if (modeflag & HalfDCLK) {
1706 if (pVBInfo->VBType & VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
1707 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) {
1708 if (pVBInfo->VBInfo & SetInSlaveMode) {
1709 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x01, 0xf7, 0x00);
1710 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0f, 0x7f, 0x00);
1715 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0f, 0xff, 0x80);
1716 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x01, 0xf7, 0x00);
1721 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0f, 0x7f, 0x00);
1725 static void XGI_WriteDAC(unsigned short dl, unsigned short ah, unsigned short al,
1726 unsigned short dh, struct vb_device_info *pVBInfo)
1728 unsigned short temp, bh, bl;
1747 XGINew_SetReg3(pVBInfo->P3c9, (unsigned short) dh);
1748 XGINew_SetReg3(pVBInfo->P3c9, (unsigned short) bh);
1749 XGINew_SetReg3(pVBInfo->P3c9, (unsigned short) bl);
1752 static void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex,
1753 struct vb_device_info *pVBInfo)
1755 unsigned short data, data2, time, i, j, k, m, n, o, si, di, bx, dl, al,
1756 ah, dh, *table = NULL;
1759 data = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
1761 data = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1763 data &= DACInfoFlag;
1767 table = XGINew_MDA_DAC;
1768 else if (data == 0x08)
1769 table = XGINew_CGA_DAC;
1770 else if (data == 0x10)
1771 table = XGINew_EGA_DAC;
1772 else if (data == 0x18) {
1774 table = XGINew_VGA_DAC;
1782 XGINew_SetReg3(pVBInfo->P3c6, 0xFF);
1783 XGINew_SetReg3(pVBInfo->P3c8, 0x00);
1785 for (i = 0; i < j; i++) {
1788 for (k = 0; k < 3; k++) {
1797 XGINew_SetReg3(pVBInfo->P3c9, data2);
1803 for (i = 16; i < 32; i++) {
1806 for (k = 0; k < 3; k++)
1807 XGINew_SetReg3(pVBInfo->P3c9, data);
1812 for (m = 0; m < 9; m++) {
1817 for (n = 0; n < 3; n++) {
1818 for (o = 0; o < 5; o++) {
1823 XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
1828 for (o = 0; o < 3; o++) {
1833 XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
1844 static void XGI_GetLVDSResInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
1845 struct vb_device_info *pVBInfo)
1847 unsigned short resindex, xres, yres, modeflag;
1850 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; /* si+St_ResInfo */
1852 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; /* si+Ext_ResInfo */
1854 /* if (ModeNo > 0x13) */
1855 /* modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; */
1857 /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; */
1860 resindex = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; /* si+St_ResInfo */
1862 resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; /* si+Ext_ResInfo */
1864 /* resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); */
1866 if (ModeNo <= 0x13) {
1867 xres = pVBInfo->StResInfo[resindex].HTotal;
1868 yres = pVBInfo->StResInfo[resindex].VTotal;
1870 xres = pVBInfo->ModeResInfo[resindex].HTotal;
1871 yres = pVBInfo->ModeResInfo[resindex].VTotal;
1873 if (ModeNo > 0x13) {
1874 if (modeflag & HalfDCLK)
1877 if (modeflag & DoubleScanMode)
1880 /* if (modeflag & Charx8Dot) */
1887 pVBInfo->VGAHDE = xres;
1888 pVBInfo->HDE = xres;
1889 pVBInfo->VGAVDE = yres;
1890 pVBInfo->VDE = yres;
1893 static void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo,
1894 unsigned short ModeIdIndex,
1895 unsigned short RefreshRateTableIndex,
1896 struct vb_device_info *pVBInfo)
1898 unsigned short i, tempdx, tempcx, tempbx, tempal, modeflag, table;
1900 struct XGI330_LCDDataTablStruct *tempdi = NULL;
1904 if (ModeNo <= 0x13) {
1905 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
1906 tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
1908 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1909 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
1912 tempal = tempal & 0x0f;
1914 if (tempbx <= 1) { /* ExpLink */
1915 if (ModeNo <= 0x13) {
1916 tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; /* find no Ext_CRT2CRTC2 */
1919 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
1922 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
1925 = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC2;
1928 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC2;
1932 tempal = (tempal >> 4);
1934 tempal = (tempal & 0x0f);
1937 tempcx = LCDLenList[tempbx]; /* mov cl,byte ptr cs:LCDLenList[bx] */
1939 if (pVBInfo->LCDInfo & EnableScalingLCD) { /* ScaleLCD */
1940 if ((tempbx == 5) || (tempbx) == 7)
1941 tempcx = LCDDesDataLen2;
1942 else if ((tempbx == 3) || (tempbx == 8))
1943 tempcx = LVDSDesDataLen2;
1945 /* mov di, word ptr cs:LCDDataList[bx] */
1946 /* tempdi = pVideoMemory[LCDDataList + tempbx * 2] | (pVideoMemory[LCDDataList + tempbx * 2 + 1] << 8); */
1950 tempdi = XGI_EPLLCDCRT1Ptr_H;
1953 tempdi = XGI_EPLLCDCRT1Ptr_V;
1956 tempdi = XGI_EPLLCDDataPtr;
1959 tempdi = XGI_EPLLCDDesDataPtr;
1962 tempdi = XGI_LCDDataTable;
1965 tempdi = XGI_LCDDesDataTable;
1968 tempdi = XGI_EPLCHLCDRegPtr;
1979 if (tempdi == NULL) /* OEMUtil */
1985 while (tempdi[i].PANELID != 0xff) {
1986 tempdx = pVBInfo->LCDResInfo;
1987 if (tempbx & 0x0080) { /* OEMUtil */
1988 tempbx &= (~0x0080);
1989 tempdx = pVBInfo->LCDTypeInfo;
1992 if (pVBInfo->LCDInfo & EnableScalingLCD)
1993 tempdx &= (~PanelResInfo);
1995 if (tempdi[i].PANELID == tempdx) {
1996 tempbx = tempdi[i].MASK;
1997 tempdx = pVBInfo->LCDInfo;
1999 if (ModeNo <= 0x13) /* alan 09/10/2003 */
2000 tempdx |= SetLCDStdMode;
2002 if (modeflag & HalfDCLK)
2003 tempdx |= SetLCDLowResolution;
2006 if (tempbx == tempdi[i].CAP)
2013 switch (tempdi[i].DATAPTR) {
2015 return &XGI_LVDSCRT11024x768_1_H[tempal];
2018 return &XGI_LVDSCRT11024x768_2_H[tempal];
2021 return &XGI_LVDSCRT11280x1024_1_H[tempal];
2024 return &XGI_LVDSCRT11280x1024_2_H[tempal];
2027 return &XGI_LVDSCRT11400x1050_1_H[tempal];
2030 return &XGI_LVDSCRT11400x1050_2_H[tempal];
2033 return &XGI_LVDSCRT11600x1200_1_H[tempal];
2036 return &XGI_LVDSCRT11024x768_1_Hx75[tempal];
2039 return &XGI_LVDSCRT11024x768_2_Hx75[tempal];
2042 return &XGI_LVDSCRT11280x1024_1_Hx75[tempal];
2045 return &XGI_LVDSCRT11280x1024_2_Hx75[tempal];
2050 } else if (table == 1) {
2051 switch (tempdi[i].DATAPTR) {
2053 return &XGI_LVDSCRT11024x768_1_V[tempal];
2056 return &XGI_LVDSCRT11024x768_2_V[tempal];
2059 return &XGI_LVDSCRT11280x1024_1_V[tempal];
2062 return &XGI_LVDSCRT11280x1024_2_V[tempal];
2065 return &XGI_LVDSCRT11400x1050_1_V[tempal];
2068 return &XGI_LVDSCRT11400x1050_2_V[tempal];
2071 return &XGI_LVDSCRT11600x1200_1_V[tempal];
2074 return &XGI_LVDSCRT11024x768_1_Vx75[tempal];
2077 return &XGI_LVDSCRT11024x768_2_Vx75[tempal];
2080 return &XGI_LVDSCRT11280x1024_1_Vx75[tempal];
2083 return &XGI_LVDSCRT11280x1024_2_Vx75[tempal];
2088 } else if (table == 2) {
2089 switch (tempdi[i].DATAPTR) {
2091 return &XGI_LVDS1024x768Data_1[tempal];
2094 return &XGI_LVDS1024x768Data_2[tempal];
2097 return &XGI_LVDS1280x1024Data_1[tempal];
2100 return &XGI_LVDS1280x1024Data_2[tempal];
2103 return &XGI_LVDS1400x1050Data_1[tempal];
2106 return &XGI_LVDS1400x1050Data_2[tempal];
2109 return &XGI_LVDS1600x1200Data_1[tempal];
2112 return &XGI_LVDSNoScalingData[tempal];
2115 return &XGI_LVDS1024x768Data_1x75[tempal];
2118 return &XGI_LVDS1024x768Data_2x75[tempal];
2121 return &XGI_LVDS1280x1024Data_1x75[tempal];
2124 return &XGI_LVDS1280x1024Data_2x75[tempal];
2127 return &XGI_LVDSNoScalingDatax75[tempal];
2132 } else if (table == 3) {
2133 switch (tempdi[i].DATAPTR) {
2135 return &XGI_LVDS1024x768Des_1[tempal];
2138 return &XGI_LVDS1024x768Des_3[tempal];
2141 return &XGI_LVDS1024x768Des_2[tempal];
2144 return &XGI_LVDS1280x1024Des_1[tempal];
2147 return &XGI_LVDS1280x1024Des_2[tempal];
2150 return &XGI_LVDS1400x1050Des_1[tempal];
2153 return &XGI_LVDS1400x1050Des_2[tempal];
2156 return &XGI_LVDS1600x1200Des_1[tempal];
2159 return &XGI_LVDSNoScalingDesData[tempal];
2162 return &XGI_LVDS1024x768Des_1x75[tempal];
2165 return &XGI_LVDS1024x768Des_3x75[tempal];
2168 return &XGI_LVDS1024x768Des_2x75[tempal];
2171 return &XGI_LVDS1280x1024Des_1x75[tempal];
2174 return &XGI_LVDS1280x1024Des_2x75[tempal];
2177 return &XGI_LVDSNoScalingDesDatax75[tempal];
2182 } else if (table == 4) {
2183 switch (tempdi[i].DATAPTR) {
2185 return &XGI_ExtLCD1024x768Data[tempal];
2188 return &XGI_StLCD1024x768Data[tempal];
2191 return &XGI_CetLCD1024x768Data[tempal];
2194 return &XGI_ExtLCD1280x1024Data[tempal];
2197 return &XGI_StLCD1280x1024Data[tempal];
2200 return &XGI_CetLCD1280x1024Data[tempal];
2203 return &XGI_ExtLCD1400x1050Data[tempal];
2206 return &XGI_StLCD1400x1050Data[tempal];
2209 return &XGI_CetLCD1400x1050Data[tempal];
2212 return &XGI_ExtLCD1600x1200Data[tempal];
2215 return &XGI_StLCD1600x1200Data[tempal];
2218 return &XGI_NoScalingData[tempal];
2221 return &XGI_ExtLCD1024x768x75Data[tempal];
2224 return &XGI_ExtLCD1024x768x75Data[tempal];
2227 return &XGI_CetLCD1024x768x75Data[tempal];
2230 return &XGI_ExtLCD1280x1024x75Data[tempal];
2233 return &XGI_StLCD1280x1024x75Data[tempal];
2236 return &XGI_CetLCD1280x1024x75Data[tempal];
2239 return &XGI_NoScalingDatax75[tempal];
2244 } else if (table == 5) {
2245 switch (tempdi[i].DATAPTR) {
2247 return &XGI_ExtLCDDes1024x768Data[tempal];
2250 return &XGI_StLCDDes1024x768Data[tempal];
2253 return &XGI_CetLCDDes1024x768Data[tempal];
2256 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
2258 return &XGI_ExtLCDDLDes1280x1024Data[tempal];
2260 return &XGI_ExtLCDDes1280x1024Data[tempal];
2263 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
2265 return &XGI_StLCDDLDes1280x1024Data[tempal];
2267 return &XGI_StLCDDes1280x1024Data[tempal];
2270 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
2272 return &XGI_CetLCDDLDes1280x1024Data[tempal];
2274 return &XGI_CetLCDDes1280x1024Data[tempal];
2277 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
2279 return &XGI_ExtLCDDLDes1400x1050Data[tempal];
2281 return &XGI_ExtLCDDes1400x1050Data[tempal];
2284 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
2286 return &XGI_StLCDDLDes1400x1050Data[tempal];
2288 return &XGI_StLCDDes1400x1050Data[tempal];
2291 return &XGI_CetLCDDes1400x1050Data[tempal];
2294 return &XGI_CetLCDDes1400x1050Data2[tempal];
2297 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
2299 return &XGI_ExtLCDDLDes1600x1200Data[tempal];
2301 return &XGI_ExtLCDDes1600x1200Data[tempal];
2304 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
2306 return &XGI_StLCDDLDes1600x1200Data[tempal];
2308 return &XGI_StLCDDes1600x1200Data[tempal];
2311 return &XGI_NoScalingDesData[tempal];
2314 return &XGI_ExtLCDDes1024x768x75Data[tempal];
2317 return &XGI_StLCDDes1024x768x75Data[tempal];
2320 return &XGI_CetLCDDes1024x768x75Data[tempal];
2323 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
2325 return &XGI_ExtLCDDLDes1280x1024x75Data[tempal];
2327 return &XGI_ExtLCDDes1280x1024x75Data[tempal];
2330 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
2332 return &XGI_StLCDDLDes1280x1024x75Data[tempal];
2334 return &XGI_StLCDDes1280x1024x75Data[tempal];
2337 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
2339 return &XGI_CetLCDDLDes1280x1024x75Data[tempal];
2341 return &XGI_CetLCDDes1280x1024x75Data[tempal];
2344 return &XGI_NoScalingDesDatax75[tempal];
2349 } else if (table == 6) {
2350 switch (tempdi[i].DATAPTR) {
2352 return &XGI_CH7017LV1024x768[tempal];
2355 return &XGI_CH7017LV1400x1050[tempal];
2364 static void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo,
2365 unsigned short ModeIdIndex,
2366 unsigned short RefreshRateTableIndex,
2367 struct vb_device_info *pVBInfo)
2369 unsigned short i, tempdx, tempbx, tempal, modeflag, table;
2370 struct XGI330_TVDataTablStruct *tempdi = NULL;
2374 if (ModeNo <= 0x13) {
2375 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
2376 tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
2378 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2379 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
2382 tempal = tempal & 0x3f;
2387 tempdi = NULL; /*EPLCHTVCRT1Ptr_H;*/
2388 if (pVBInfo->IF_DEF_CH7007 == 1)
2389 tempdi = XGI_EPLCHTVCRT1Ptr;
2393 tempdi = NULL; /*EPLCHTVCRT1Ptr_V;*/
2394 if (pVBInfo->IF_DEF_CH7007 == 1)
2395 tempdi = XGI_EPLCHTVCRT1Ptr;
2399 tempdi = XGI_EPLCHTVDataPtr;
2405 tempdi = XGI_TVDataTable;
2411 tempdi = XGI_EPLCHTVRegPtr;
2417 if (tempdi == NULL) /* OEMUtil */
2420 tempdx = pVBInfo->TVInfo;
2422 if (pVBInfo->VBInfo & SetInSlaveMode)
2423 tempdx = tempdx | SetTVLockMode;
2425 if (modeflag & HalfDCLK)
2426 tempdx = tempdx | SetTVLowResolution;
2430 while (tempdi[i].MASK != 0xffff) {
2431 if ((tempdx & tempdi[i].MASK) == tempdi[i].CAP)
2436 if (table == 0x00) { /* 07/05/22 */
2437 } else if (table == 0x01) {
2438 } else if (table == 0x04) {
2439 switch (tempdi[i].DATAPTR) {
2441 return &XGI_ExtPALData[tempal];
2444 return &XGI_ExtNTSCData[tempal];
2447 return &XGI_StPALData[tempal];
2450 return &XGI_StNTSCData[tempal];
2453 return &XGI_ExtHiTVData[tempal];
2456 return &XGI_St2HiTVData[tempal];
2459 return &XGI_ExtYPbPr525iData[tempal];
2462 return &XGI_ExtYPbPr525pData[tempal];
2465 return &XGI_ExtYPbPr750pData[tempal];
2468 return &XGI_StYPbPr525iData[tempal];
2471 return &XGI_StYPbPr525pData[tempal];
2474 return &XGI_StYPbPr750pData[tempal];
2476 case 12: /* avoid system hang */
2477 return &XGI_ExtNTSCData[tempal];
2480 return &XGI_St1HiTVData[tempal];
2485 } else if (table == 0x02) {
2486 switch (tempdi[i].DATAPTR) {
2488 return &XGI_CHTVUNTSCData[tempal];
2491 return &XGI_CHTVONTSCData[tempal];
2494 return &XGI_CHTVUPALData[tempal];
2497 return &XGI_CHTVOPALData[tempal];
2502 } else if (table == 0x06) {
2507 static void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex,
2508 unsigned short RefreshRateTableIndex,
2509 struct vb_device_info *pVBInfo)
2511 unsigned short tempbx;
2512 struct XGI330_LVDSDataStruct *LCDPtr = NULL;
2513 struct XGI330_CHTVDataStruct *TVPtr = NULL;
2517 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
2518 LCDPtr = (struct XGI330_LVDSDataStruct *) XGI_GetLcdPtr(tempbx,
2519 ModeNo, ModeIdIndex, RefreshRateTableIndex,
2521 pVBInfo->VGAHT = LCDPtr->VGAHT;
2522 pVBInfo->VGAVT = LCDPtr->VGAVT;
2523 pVBInfo->HT = LCDPtr->LCDHT;
2524 pVBInfo->VT = LCDPtr->LCDVT;
2526 if (pVBInfo->IF_DEF_CH7017 == 1) {
2527 if (pVBInfo->VBInfo & SetCRT2ToTV) {
2528 TVPtr = (struct XGI330_CHTVDataStruct *) XGI_GetTVPtr(
2529 tempbx, ModeNo, ModeIdIndex,
2530 RefreshRateTableIndex, pVBInfo);
2531 pVBInfo->VGAHT = TVPtr->VGAHT;
2532 pVBInfo->VGAVT = TVPtr->VGAVT;
2533 pVBInfo->HT = TVPtr->LCDHT;
2534 pVBInfo->VT = TVPtr->LCDVT;
2538 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
2539 if (!(pVBInfo->LCDInfo & (SetLCDtoNonExpanding
2540 | EnableScalingLCD))) {
2541 if ((pVBInfo->LCDResInfo == Panel1024x768)
2542 || (pVBInfo->LCDResInfo
2543 == Panel1024x768x75)) {
2544 pVBInfo->HDE = 1024;
2546 } else if ((pVBInfo->LCDResInfo == Panel1280x1024)
2547 || (pVBInfo->LCDResInfo
2548 == Panel1280x1024x75)) {
2549 pVBInfo->HDE = 1280;
2550 pVBInfo->VDE = 1024;
2551 } else if (pVBInfo->LCDResInfo == Panel1400x1050) {
2552 pVBInfo->HDE = 1400;
2553 pVBInfo->VDE = 1050;
2555 pVBInfo->HDE = 1600;
2556 pVBInfo->VDE = 1200;
2562 static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex,
2563 unsigned short RefreshRateTableIndex,
2564 struct xgi_hw_device_info *HwDeviceExtension,
2565 struct vb_device_info *pVBInfo)
2567 unsigned char index;
2568 unsigned short tempbx, i;
2569 struct XGI_LVDSCRT1HDataStruct *LCDPtr = NULL;
2570 struct XGI_LVDSCRT1VDataStruct *LCDPtr1 = NULL;
2571 /* struct XGI330_CHTVDataStruct *TVPtr = NULL; */
2572 struct XGI_CH7007TV_TimingHStruct *CH7007TV_TimingHPtr = NULL;
2573 struct XGI_CH7007TV_TimingVStruct *CH7007TV_TimingVPtr = NULL;
2576 index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
2578 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
2580 index = index & IndexMask;
2582 if ((pVBInfo->IF_DEF_ScaleLCD == 0) || ((pVBInfo->IF_DEF_ScaleLCD == 1)
2583 && (!(pVBInfo->LCDInfo & EnableScalingLCD)))) {
2586 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
2588 = (struct XGI_LVDSCRT1HDataStruct *) XGI_GetLcdPtr(
2591 RefreshRateTableIndex,
2594 for (i = 0; i < 8; i++)
2595 pVBInfo->TimingH[0].data[i] = LCDPtr[0].Reg[i];
2598 if (pVBInfo->IF_DEF_CH7007 == 1) {
2599 if (pVBInfo->VBInfo & SetCRT2ToTV) {
2601 = (struct XGI_CH7007TV_TimingHStruct *) XGI_GetTVPtr(
2605 RefreshRateTableIndex,
2608 for (i = 0; i < 8; i++)
2609 pVBInfo->TimingH[0].data[i]
2610 = CH7007TV_TimingHPtr[0].data[i];
2614 /* if (pVBInfo->IF_DEF_CH7017 == 1) {
2615 if (pVBInfo->VBInfo & SetCRT2ToTV)
2616 TVPtr = (struct XGI330_CHTVDataStruct *)XGI_GetTVPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2620 XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension);
2622 if (pVBInfo->IF_DEF_CH7007 == 1) {
2623 XGINew_SetReg1(pVBInfo->P3c4, 0x2E,
2624 CH7007TV_TimingHPtr[0].data[8]);
2625 XGINew_SetReg1(pVBInfo->P3c4, 0x2F,
2626 CH7007TV_TimingHPtr[0].data[9]);
2631 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
2633 = (struct XGI_LVDSCRT1VDataStruct *) XGI_GetLcdPtr(
2636 RefreshRateTableIndex,
2638 for (i = 0; i < 7; i++)
2639 pVBInfo->TimingV[0].data[i] = LCDPtr1[0].Reg[i];
2642 if (pVBInfo->IF_DEF_CH7007 == 1) {
2643 if (pVBInfo->VBInfo & SetCRT2ToTV) {
2645 = (struct XGI_CH7007TV_TimingVStruct *) XGI_GetTVPtr(
2649 RefreshRateTableIndex,
2652 for (i = 0; i < 7; i++)
2653 pVBInfo->TimingV[0].data[i]
2654 = CH7007TV_TimingVPtr[0].data[i];
2657 /* if (pVBInfo->IF_DEF_CH7017 == 1) {
2658 if (pVBInfo->VBInfo & SetCRT2ToTV)
2659 TVPtr = (struct XGI330_CHTVDataStruct *)XGI_GetTVPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2663 XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo);
2665 if (pVBInfo->IF_DEF_CH7007 == 1) {
2666 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x33, ~0x01,
2667 CH7007TV_TimingVPtr[0].data[7] & 0x01);
2668 XGINew_SetReg1(pVBInfo->P3c4, 0x34,
2669 CH7007TV_TimingVPtr[0].data[8]);
2670 XGINew_SetReg1(pVBInfo->P3c4, 0x3F,
2671 CH7007TV_TimingVPtr[0].data[9]);
2677 static unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo)
2679 unsigned char tempal, tempah, tempbl, i;
2681 tempah = XGINew_GetReg1(pVBInfo->P3d4, 0x36);
2682 tempal = tempah & 0x0F;
2683 tempah = tempah & 0xF0;
2685 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
2687 while (tempbl != 0xFF) {
2688 if (tempbl & 0x80) { /* OEMUtil */
2690 tempbl = tempbl & ~(0x80);
2693 if (tempal == tempbl)
2698 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
2704 static unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo)
2706 unsigned short tempah, tempal, tempbl, i;
2708 tempal = pVBInfo->LCDResInfo;
2709 tempah = pVBInfo->LCDTypeInfo;
2712 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
2714 while (tempbl != 0xFF) {
2715 if ((tempbl & 0x80) && (tempbl != 0x80)) {
2720 if (tempal == tempbl)
2724 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
2727 if (tempbl == 0xFF) {
2728 pVBInfo->LCDResInfo = Panel1024x768;
2729 pVBInfo->LCDTypeInfo = 0;
2736 static void XGI_GetLCDSync(unsigned short *HSyncWidth, unsigned short *VSyncWidth,
2737 struct vb_device_info *pVBInfo)
2739 unsigned short Index;
2741 Index = XGI_GetLCDCapPtr(pVBInfo);
2742 *HSyncWidth = pVBInfo->LCDCapList[Index].LCD_HSyncWidth;
2743 *VSyncWidth = pVBInfo->LCDCapList[Index].LCD_VSyncWidth;
2748 static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
2749 unsigned short RefreshRateTableIndex,
2750 struct vb_device_info *pVBInfo)
2752 unsigned short tempbx, tempax, tempcx, tempdx, push1, push2, modeflag;
2753 unsigned long temp, temp1, temp2, temp3, push3;
2754 struct XGI330_LCDDataDesStruct *LCDPtr = NULL;
2755 struct XGI330_LCDDataDesStruct2 *LCDPtr1 = NULL;
2758 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2760 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
2762 if (!(pVBInfo->SetFlag & Win9xDOSMode)) {
2763 if ((pVBInfo->IF_DEF_CH7017 == 0) || (pVBInfo->VBInfo
2764 & (SetCRT2ToLCD | SetCRT2ToLCDA))) {
2765 if (pVBInfo->IF_DEF_OEMUtil == 1) {
2768 = (struct XGI330_LCDDataDesStruct *) XGI_GetLcdPtr(
2772 RefreshRateTableIndex,
2776 if ((pVBInfo->IF_DEF_OEMUtil == 0) || (LCDPtr == NULL)) {
2778 if (pVBInfo->LCDInfo & EnableScalingLCD)
2780 = (struct XGI330_LCDDataDesStruct2 *) XGI_GetLcdPtr(
2784 RefreshRateTableIndex,
2788 = (struct XGI330_LCDDataDesStruct *) XGI_GetLcdPtr(
2792 RefreshRateTableIndex,
2796 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
2801 if ((pVBInfo->LCDResInfo == Panel1024x768)
2802 || (pVBInfo->LCDResInfo
2803 == Panel1024x768x75)) {
2806 } else if ((pVBInfo->LCDResInfo == Panel1280x1024)
2807 || (pVBInfo->LCDResInfo
2808 == Panel1280x1024x75)) {
2811 } else if (pVBInfo->LCDResInfo == Panel1400x1050) {
2819 if (pVBInfo->LCDInfo & SetLCDtoNonExpanding) {
2820 pVBInfo->HDE = tempax;
2821 pVBInfo->VDE = tempbx;
2822 pVBInfo->VGAHDE = tempax;
2823 pVBInfo->VGAVDE = tempbx;
2826 if ((pVBInfo->IF_DEF_ScaleLCD == 1)
2827 && (pVBInfo->LCDInfo & EnableScalingLCD)) {
2828 tempax = pVBInfo->HDE;
2829 tempbx = pVBInfo->VDE;
2832 tempax = pVBInfo->HT;
2834 if (pVBInfo->LCDInfo & EnableScalingLCD)
2835 tempbx = LCDPtr1->LCDHDES;
2837 tempbx = LCDPtr->LCDHDES;
2839 tempcx = pVBInfo->HDE;
2840 tempbx = tempbx & 0x0fff;
2843 if (tempcx >= tempax)
2846 XGINew_SetReg1(pVBInfo->Part1Port, 0x1A, tempbx & 0x07);
2848 tempcx = tempcx >> 3;
2849 tempbx = tempbx >> 3;
2851 XGINew_SetReg1(pVBInfo->Part1Port, 0x16,
2852 (unsigned short) (tempbx & 0xff));
2853 XGINew_SetReg1(pVBInfo->Part1Port, 0x17,
2854 (unsigned short) (tempcx & 0xff));
2856 tempax = pVBInfo->HT;
2858 if (pVBInfo->LCDInfo & EnableScalingLCD)
2859 tempbx = LCDPtr1->LCDHRS;
2861 tempbx = LCDPtr->LCDHRS;
2865 if (pVBInfo->LCDInfo & EnableScalingLCD)
2866 tempcx = LCDPtr1->LCDHSync;
2870 if (tempcx >= tempax)
2873 tempax = tempbx & 0x07;
2874 tempax = tempax >> 5;
2875 tempcx = tempcx >> 3;
2876 tempbx = tempbx >> 3;
2881 XGINew_SetReg1(pVBInfo->Part1Port, 0x15, tempax);
2882 XGINew_SetReg1(pVBInfo->Part1Port, 0x14,
2883 (unsigned short) (tempbx & 0xff));
2885 tempax = pVBInfo->VT;
2886 if (pVBInfo->LCDInfo & EnableScalingLCD)
2887 tempbx = LCDPtr1->LCDVDES;
2889 tempbx = LCDPtr->LCDVDES;
2890 tempcx = pVBInfo->VDE;
2892 tempbx = tempbx & 0x0fff;
2894 if (tempcx >= tempax)
2897 XGINew_SetReg1(pVBInfo->Part1Port, 0x1b,
2898 (unsigned short) (tempbx & 0xff));
2899 XGINew_SetReg1(pVBInfo->Part1Port, 0x1c,
2900 (unsigned short) (tempcx & 0xff));
2902 tempbx = (tempbx >> 8) & 0x07;
2903 tempcx = (tempcx >> 8) & 0x07;
2905 XGINew_SetReg1(pVBInfo->Part1Port, 0x1d,
2906 (unsigned short) ((tempcx << 3)
2909 tempax = pVBInfo->VT;
2910 if (pVBInfo->LCDInfo & EnableScalingLCD)
2911 tempbx = LCDPtr1->LCDVRS;
2913 tempbx = LCDPtr->LCDVRS;
2915 /* tempbx = tempbx >> 4; */
2918 if (pVBInfo->LCDInfo & EnableScalingLCD)
2919 tempcx = LCDPtr1->LCDVSync;
2922 if (tempcx >= tempax)
2925 XGINew_SetReg1(pVBInfo->Part1Port, 0x18,
2926 (unsigned short) (tempbx & 0xff));
2927 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, ~0x0f,
2928 (unsigned short) (tempcx & 0x0f));
2930 tempax = ((tempbx >> 8) & 0x07) << 3;
2932 tempbx = pVBInfo->VGAVDE;
2933 if (tempbx != pVBInfo->VDE)
2936 if (pVBInfo->LCDInfo & EnableLVDSDDA)
2939 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1a, 0x07,
2942 tempcx = pVBInfo->VGAVT;
2943 tempbx = pVBInfo->VDE;
2944 tempax = pVBInfo->VGAVDE;
2947 temp = tempax; /* 0430 ylshieh */
2948 temp1 = (temp << 18) / tempbx;
2950 tempdx = (unsigned short) ((temp << 18) % tempbx);
2958 XGINew_SetReg1(pVBInfo->Part1Port, 0x37,
2959 (unsigned short) (temp2 & 0xff));
2960 XGINew_SetReg1(pVBInfo->Part1Port, 0x36,
2961 (unsigned short) ((temp2 >> 8) & 0xff));
2963 tempbx = (unsigned short) (temp2 >> 16);
2964 tempax = tempbx & 0x03;
2966 tempbx = pVBInfo->VGAVDE;
2967 if (tempbx == pVBInfo->VDE)
2970 XGINew_SetReg1(pVBInfo->Part1Port, 0x35, tempax);
2972 if (pVBInfo->VBType & VB_XGI301C) {
2974 XGINew_SetReg1(pVBInfo->Part4Port, 0x3c,
2975 (unsigned short) (temp2 & 0xff));
2976 XGINew_SetReg1(pVBInfo->Part4Port, 0x3b,
2977 (unsigned short) ((temp2 >> 8)
2979 tempbx = (unsigned short) (temp2 >> 16);
2980 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x3a,
2982 (unsigned short) ((tempbx
2985 tempcx = pVBInfo->VGAVDE;
2986 if (tempcx == pVBInfo->VDE)
2987 XGINew_SetRegANDOR(pVBInfo->Part4Port,
2990 XGINew_SetRegANDOR(pVBInfo->Part4Port,
2994 tempcx = pVBInfo->VGAHDE;
2995 tempbx = pVBInfo->HDE;
2997 temp1 = tempcx << 16;
2999 tempax = (unsigned short) (temp1 / tempbx);
3001 if ((tempbx & 0xffff) == (tempcx & 0xffff))
3005 temp1 = pVBInfo->VGAHDE << 16;
3008 temp3 = temp3 << 16;
3011 temp3 = (temp3 & 0xffff0000) + (temp1 & 0xffff);
3013 tempax = (unsigned short) (temp3 & 0xff);
3014 XGINew_SetReg1(pVBInfo->Part1Port, 0x1f, tempax);
3016 temp1 = pVBInfo->VGAVDE << 18;
3017 temp1 = temp1 / push3;
3018 tempbx = (unsigned short) (temp1 & 0xffff);
3020 if (pVBInfo->LCDResInfo == Panel1024x768)
3023 tempax = ((tempbx >> 8) & 0xff) << 3;
3024 tempax |= (unsigned short) ((temp3 >> 8) & 0x07);
3025 XGINew_SetReg1(pVBInfo->Part1Port, 0x20,
3026 (unsigned short) (tempax & 0xff));
3027 XGINew_SetReg1(pVBInfo->Part1Port, 0x21,
3028 (unsigned short) (tempbx & 0xff));
3030 temp3 = temp3 >> 16;
3032 if (modeflag & HalfDCLK)
3035 XGINew_SetReg1(pVBInfo->Part1Port, 0x22,
3036 (unsigned short) ((temp3 >> 8) & 0xff));
3037 XGINew_SetReg1(pVBInfo->Part1Port, 0x23,
3038 (unsigned short) (temp3 & 0xff));
3043 /* --------------------------------------------------------------------- */
3044 /* Function : XGI_GETLCDVCLKPtr */
3046 /* Output : al -> VCLK Index */
3048 /* --------------------------------------------------------------------- */
3049 static void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1,
3050 struct vb_device_info *pVBInfo)
3052 unsigned short index;
3054 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
3055 if (pVBInfo->IF_DEF_ScaleLCD == 1) {
3056 if (pVBInfo->LCDInfo & EnableScalingLCD)
3060 /* index = XGI_GetLCDCapPtr(pVBInfo); */
3061 index = XGI_GetLCDCapPtr1(pVBInfo);
3063 if (pVBInfo->VBInfo & SetCRT2ToLCD) { /* LCDB */
3064 *di_0 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData1;
3065 *di_1 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData2;
3067 *di_0 = pVBInfo->LCDCapList[index].LCDA_VCLKData1;
3068 *di_1 = pVBInfo->LCDCapList[index].LCDA_VCLKData2;
3074 static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex,
3075 unsigned short ModeNo, unsigned short ModeIdIndex,
3076 struct vb_device_info *pVBInfo)
3079 unsigned short index, modeflag;
3080 unsigned short tempbx;
3081 unsigned char tempal;
3082 unsigned char *CHTVVCLKPtr = NULL;
3085 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
3087 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
3089 if ((pVBInfo->SetFlag & ProgrammingCRT2) && (!(pVBInfo->LCDInfo
3090 & EnableScalingLCD))) { /* {LCDA/LCDB} */
3091 index = XGI_GetLCDCapPtr(pVBInfo);
3092 tempal = pVBInfo->LCDCapList[index].LCD_VCLK;
3094 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))
3098 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
3099 | VB_XGI302LV | VB_XGI301C)) {
3100 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
3101 tempal = HiTVVCLKDIV2;
3102 if (!(pVBInfo->TVInfo & RPLLDIV2XO))
3104 if (pVBInfo->TVInfo & TVSimuMode) {
3105 tempal = HiTVSimuVCLK;
3106 if (!(modeflag & Charx8Dot))
3107 tempal = HiTVTextVCLK;
3113 if (pVBInfo->TVInfo & SetYPbPrMode750p) {
3114 tempal = YPbPr750pVCLK;
3118 if (pVBInfo->TVInfo & SetYPbPrMode525p) {
3119 tempal = YPbPr525pVCLK;
3123 tempal = NTSC1024VCLK;
3125 if (!(pVBInfo->TVInfo & NTSC1024x768)) {
3126 tempal = TVVCLKDIV2;
3127 if (!(pVBInfo->TVInfo & RPLLDIV2XO))
3131 if (pVBInfo->VBInfo & SetCRT2ToTV)
3134 /* else if ((pVBInfo->IF_DEF_CH7017==1)&&(pVBInfo->VBType&VB_CH7017)) {
3136 *tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
3138 *tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
3139 *tempal = *tempal & 0x1F;
3141 if (pVBInfo->TVInfo & SetPALTV)
3142 tempbx = tempbx + 2;
3143 if (pVBInfo->TVInfo & SetCHTVOverScan)
3145 tempbx = tempbx << 1;
3149 if ((pVBInfo->IF_DEF_CH7007 == 1) && (pVBInfo->VBType & VB_CH7007)) { /* [Billy] 07/05/08 CH7007 */
3150 /* VideoDebugPrint((0, "XGI_GetVCLKPtr: pVBInfo->IF_DEF_CH7007==1\n")); */
3151 if ((pVBInfo->VBInfo & SetCRT2ToTV)) {
3152 if (ModeNo <= 0x13) {
3154 = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
3157 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
3160 tempal = tempal & 0x0F;
3163 if (pVBInfo->TVInfo & SetPALTV)
3164 tempbx = tempbx + 2;
3166 if (pVBInfo->TVInfo & SetCHTVOverScan)
3169 /** tempbx = tempbx << 1; CH7007 ? **/
3171 /* [Billy]07/05/29 CH7007 */
3172 if (pVBInfo->IF_DEF_CH7007 == 1) {
3175 CHTVVCLKPtr = XGI7007_CHTVVCLKUNTSC;
3178 CHTVVCLKPtr = XGI7007_CHTVVCLKONTSC;
3181 CHTVVCLKPtr = XGI7007_CHTVVCLKUPAL;
3184 CHTVVCLKPtr = XGI7007_CHTVVCLKOPAL;
3194 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC;
3197 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC;
3200 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL;
3203 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL;
3211 tempal = CHTVVCLKPtr[tempal];
3217 tempal = (unsigned char) XGINew_GetReg2((pVBInfo->P3ca + 0x02));
3218 tempal = tempal >> 2;
3221 if ((pVBInfo->LCDInfo & EnableScalingLCD) && (modeflag & Charx8Dot)) /* for Dot8 Scaling LCD */
3222 tempal = tempal ^ tempal; /* ; set to VCLK25MHz always */
3227 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
3231 static void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0,
3232 unsigned char *di_1, struct vb_device_info *pVBInfo)
3234 if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 2007/05/16 */
3235 /* VideoDebugPrint((0, "XGI_GetVCLKLen: pVBInfo->IF_DEF_CH7007==1\n")); */
3236 *di_0 = (unsigned char) XGI_CH7007VCLKData[tempal].SR2B;
3237 *di_1 = (unsigned char) XGI_CH7007VCLKData[tempal].SR2C;
3238 } else if (pVBInfo->VBType & (VB_XGI301 | VB_XGI301B | VB_XGI302B
3239 | VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
3240 if ((!(pVBInfo->VBInfo & SetCRT2ToLCDA)) && (pVBInfo->SetFlag
3241 & ProgrammingCRT2)) {
3242 *di_0 = (unsigned char) XGI_VBVCLKData[tempal].SR2B;
3243 *di_1 = XGI_VBVCLKData[tempal].SR2C;
3246 *di_0 = XGI_VCLKData[tempal].SR2B;
3247 *di_1 = XGI_VCLKData[tempal].SR2C;
3251 static void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex,
3252 unsigned short RefreshRateTableIndex,
3253 struct vb_device_info *pVBInfo)
3255 unsigned char di_0, di_1, tempal;
3258 tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex,
3260 XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo);
3261 XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo);
3263 for (i = 0; i < 4; i++) {
3264 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x31, ~0x30,
3265 (unsigned short) (0x10 * i));
3266 if (pVBInfo->IF_DEF_CH7007 == 1) {
3267 XGINew_SetReg1(pVBInfo->P3c4, 0x2b, di_0);
3268 XGINew_SetReg1(pVBInfo->P3c4, 0x2c, di_1);
3269 } else if ((!(pVBInfo->VBInfo & SetCRT2ToLCDA))
3270 && (!(pVBInfo->VBInfo & SetInSlaveMode))) {
3271 XGINew_SetReg1(pVBInfo->P3c4, 0x2e, di_0);
3272 XGINew_SetReg1(pVBInfo->P3c4, 0x2f, di_1);
3274 XGINew_SetReg1(pVBInfo->P3c4, 0x2b, di_0);
3275 XGINew_SetReg1(pVBInfo->P3c4, 0x2c, di_1);
3280 static void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension,
3281 struct vb_device_info *pVBInfo)
3283 unsigned short tempcl, tempch, temp, tempbl, tempax;
3285 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
3286 | VB_XGI302LV | VB_XGI301C)) {
3289 temp = XGINew_GetReg1(pVBInfo->P3c4, 0x01);
3291 if (!(temp & 0x20)) {
3292 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x17);
3294 if ((HwDeviceExtension->jChipType >= XG20)
3295 || (HwDeviceExtension->jChipType
3297 temp = XGINew_GetReg1(pVBInfo->P3d4,
3300 temp = XGINew_GetReg1(pVBInfo->P3d4,
3304 tempcl |= ActiveCRT1;
3308 temp = XGINew_GetReg1(pVBInfo->Part1Port, 0x2e);
3311 if (!(temp == 0x08)) {
3312 tempax = XGINew_GetReg1(pVBInfo->Part1Port, 0x13); /* Check ChannelA by Part1_13 [2003/10/03] */
3314 tempcl = tempcl | ActiveLCD;
3318 if (!(tempcl & ActiveLCD))
3320 tempcl |= ActiveCRT2;
3323 tempcl |= ActiveLCD;
3326 temp = XGINew_GetReg1(pVBInfo->Part2Port, 0x00);
3329 tempch |= ActiveAVideo;
3332 tempch |= ActiveSVideo;
3335 tempch |= ActiveSCART;
3337 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
3339 tempch |= ActiveHiTV;
3342 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
3343 temp = XGINew_GetReg1(
3348 tempch |= ActiveYPbPr;
3356 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x3d);
3357 if (tempcl & ActiveLCD) {
3358 if ((pVBInfo->SetFlag & ReserveTVOption)) {
3359 if (temp & ActiveTV)
3364 tempbl = ~ModeSwitchStatus;
3365 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x3d, tempbl, temp);
3367 if (!(pVBInfo->SetFlag & ReserveTVOption))
3368 XGINew_SetReg1(pVBInfo->P3d4, 0x3e, tempch);
3374 void XGI_GetVGAType(struct xgi_hw_device_info *HwDeviceExtension,
3375 struct vb_device_info *pVBInfo)
3378 if ( HwDeviceExtension->jChipType >= XG20 ) {
3379 pVBInfo->Set_VGAType = XG20;
3380 } else if (HwDeviceExtension->jChipType >= XG40) {
3381 pVBInfo->Set_VGAType = VGA_XGI340;
3384 pVBInfo->Set_VGAType = HwDeviceExtension->jChipType;
3387 void XGI_GetVBType(struct vb_device_info *pVBInfo)
3389 unsigned short flag, tempbx, tempah;
3391 if (pVBInfo->IF_DEF_CH7007 == 1) {
3392 pVBInfo->VBType = VB_CH7007;
3395 if (pVBInfo->IF_DEF_LVDS == 0) {
3396 tempbx = VB_XGI302B;
3397 flag = XGINew_GetReg1(pVBInfo->Part4Port, 0x00);
3400 flag = XGINew_GetReg1(pVBInfo->Part4Port, 0x01);
3402 tempbx = VB_XGI301B;
3404 tempbx = VB_XGI301C;
3406 tempbx = VB_XGI301LV;
3408 tempbx = VB_XGI302LV;
3420 if (tempbx & (VB_XGI301B | VB_XGI302B)) {
3421 flag = XGINew_GetReg1(
3426 tempbx = tempbx | VB_NoLCD;
3430 pVBInfo->VBType = tempbx;
3433 else if (pVBInfo->IF_DEF_CH7017 == 1)
3434 pVBInfo->VBType = VB_CH7017;
3436 pVBInfo->VBType = VB_LVDS_NS;
3441 void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
3442 struct xgi_hw_device_info *HwDeviceExtension,
3443 struct vb_device_info *pVBInfo)
3445 unsigned short tempax, push, tempbx, temp, modeflag;
3448 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
3450 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3452 pVBInfo->SetFlag = 0;
3453 pVBInfo->ModeType = modeflag & ModeInfoFlag;
3456 if (pVBInfo->VBType & 0xFFFF) {
3457 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x30); /* Check Display Device */
3458 tempbx = tempbx | temp;
3459 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x31);
3463 tempbx = tempbx | tempax;
3464 temp = (SetCRT2ToDualEdge | SetCRT2ToYPbPr | SetCRT2ToLCDA
3465 | SetInSlaveMode | DisableCRT2Display);
3466 temp = 0xFFFF ^ temp;
3469 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x38);
3471 if (pVBInfo->IF_DEF_LCDA == 1) {
3473 if ((pVBInfo->Set_VGAType >= XG20)
3474 || (pVBInfo->Set_VGAType >= XG40)) {
3475 if (pVBInfo->IF_DEF_LVDS == 0) {
3476 /* if ((pVBInfo->VBType & VB_XGI302B) || (pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType & VB_XGI302LV) || (pVBInfo->VBType & VB_XGI301C)) */
3477 if (pVBInfo->VBType & (VB_XGI302B
3481 if (temp & EnableDualEdge) {
3483 |= SetCRT2ToDualEdge;
3485 if (temp & SetToLCDA)
3490 } else if (pVBInfo->IF_DEF_CH7017 == 1) {
3491 if (pVBInfo->VBType & VB_CH7017) {
3492 if (temp & EnableDualEdge) {
3494 |= SetCRT2ToDualEdge;
3496 if (temp & SetToLCDA)
3505 if (pVBInfo->IF_DEF_YPbPr == 1) {
3506 if (((pVBInfo->IF_DEF_LVDS == 0) && ((pVBInfo->VBType
3507 & VB_XGI301LV) || (pVBInfo->VBType
3508 & VB_XGI302LV) || (pVBInfo->VBType
3510 || ((pVBInfo->IF_DEF_CH7017 == 1)
3513 || ((pVBInfo->IF_DEF_CH7007 == 1)
3515 & VB_CH7007))) { /* [Billy] 07/05/04 */
3516 if (temp & SetYPbPr) { /* temp = CR38 */
3517 if (pVBInfo->IF_DEF_HiVision == 1) {
3518 temp = XGINew_GetReg1(
3520 0x35); /* shampoo add for new scratch */
3522 tempbx |= SetCRT2ToHiVisionTV;
3524 if (temp != YPbPrMode1080i) {
3526 &= (~SetCRT2ToHiVisionTV);
3532 /* tempbx |= SetCRT2ToYPbPr; */
3537 tempax = push; /* restore CR31 */
3539 if (pVBInfo->IF_DEF_LVDS == 0) {
3540 if (pVBInfo->IF_DEF_YPbPr == 1) {
3541 if (pVBInfo->IF_DEF_HiVision == 1)
3546 if (pVBInfo->IF_DEF_HiVision == 1)
3551 } else { /* 3nd party chip */
3552 if (pVBInfo->IF_DEF_CH7017 == 1)
3553 temp = (SetCRT2ToTV | SetCRT2ToLCD
3555 else if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/03 */
3558 temp = SetCRT2ToLCD;
3561 if (!(tempbx & temp)) {
3562 tempax |= DisableCRT2Display;
3566 if (pVBInfo->IF_DEF_LCDA == 1) { /* Select Display Device */
3567 if (!(pVBInfo->VBType & VB_NoLCD)) {
3568 if (tempbx & SetCRT2ToLCDA) {
3569 if (tempbx & SetSimuScanMode)
3585 if (!(tempbx & (SwitchToCRT2 | SetSimuScanMode))) { /* for driver abnormal */
3586 if (pVBInfo->IF_DEF_CRT2Monitor == 1) {
3587 if (tempbx & SetCRT2ToRAMDAC) {
3588 tempbx &= (0xFF00 | SetCRT2ToRAMDAC
3591 tempbx &= (0x00FF | (~SetCRT2ToYPbPr));
3594 tempbx &= (~(SetCRT2ToRAMDAC | SetCRT2ToLCD
3599 if (!(pVBInfo->VBType & VB_NoLCD)) {
3600 if (tempbx & SetCRT2ToLCD) {
3601 tempbx &= (0xFF00 | SetCRT2ToLCD | SwitchToCRT2
3603 tempbx &= (0x00FF | (~SetCRT2ToYPbPr));
3607 if (tempbx & SetCRT2ToSCART) {
3608 tempbx &= (0xFF00 | SetCRT2ToSCART | SwitchToCRT2
3610 tempbx &= (0x00FF | (~SetCRT2ToYPbPr));
3613 if (pVBInfo->IF_DEF_YPbPr == 1) {
3614 if (tempbx & SetCRT2ToYPbPr)
3615 tempbx &= (0xFF00 | SwitchToCRT2
3619 if (pVBInfo->IF_DEF_HiVision == 1) {
3620 if (tempbx & SetCRT2ToHiVisionTV)
3621 tempbx &= (0xFF00 | SetCRT2ToHiVisionTV
3626 if (tempax & DisableCRT2Display) { /* Set Display Device Info */
3627 if (!(tempbx & (SwitchToCRT2 | SetSimuScanMode)))
3628 tempbx = DisableCRT2Display;
3631 if (!(tempbx & DisableCRT2Display)) {
3632 if ((!(tempbx & DriverMode))
3633 || (!(modeflag & CRT2Mode))) {
3634 if (pVBInfo->IF_DEF_LCDA == 1) {
3635 if (!(tempbx & SetCRT2ToLCDA))
3641 if (pVBInfo->IF_DEF_VideoCapture == 1) {
3642 if (((HwDeviceExtension->jChipType
3644 && (pVBInfo->Set_VGAType
3646 || ((HwDeviceExtension->jChipType
3648 && (pVBInfo->Set_VGAType
3650 || ((HwDeviceExtension->jChipType
3652 && (pVBInfo->Set_VGAType
3654 || ((HwDeviceExtension->jChipType
3656 && (pVBInfo->Set_VGAType
3660 & SetCRT2ToRAMDAC)) { /*CRT2 not need to support*/
3663 | (~SetInSlaveMode));
3672 /* LCD+TV can't support in slave mode (Force LCDA+TV->LCDB) */
3673 if ((tempbx & SetInSlaveMode) && (tempbx
3675 tempbx ^= (SetCRT2ToLCD | SetCRT2ToLCDA
3676 | SetCRT2ToDualEdge);
3677 pVBInfo->SetFlag |= ReserveTVOption;
3682 pVBInfo->VBInfo = tempbx;
3685 void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
3686 struct vb_device_info *pVBInfo)
3688 unsigned short temp, tempbx = 0, resinfo = 0, modeflag, index1;
3693 if (pVBInfo->VBInfo & SetCRT2ToTV) {
3694 if (ModeNo <= 0x13) {
3696 = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ModeFlag */
3697 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; /* si+St_ResInfo */
3700 = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3702 = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; /* si+Ext_ResInfo */
3705 if (pVBInfo->VBInfo & SetCRT2ToTV) {
3706 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x35);
3708 if (tempbx & SetPALTV) {
3709 tempbx &= (SetCHTVOverScan | SetPALMTV
3710 | SetPALNTV | SetPALTV);
3711 if (tempbx & SetPALMTV)
3712 tempbx &= ~SetPALTV; /* set to NTSC if PAL-M */
3714 tempbx &= (SetCHTVOverScan | SetNTSCJ
3717 if (pVBInfo->IF_DEF_LVDS == 0) {
3718 index1 = XGINew_GetReg1(pVBInfo->P3d4, 0x38); //PAL-M/PAL-N Info
3719 temp2 = (index1 & 0xC0) >> 5; //00:PAL, 01:PAL-M, 10:PAL-N
3721 if (temp2 & 0x02) //PAL-M
3722 tempbx &= (~SetPALTV);
3727 if (pVBInfo->IF_DEF_CH7017 == 1) {
3728 tempbx = XGINew_GetReg1(pVBInfo->P3d4, 0x35);
3730 if (tempbx & TVOverScan)
3731 tempbx |= SetCHTVOverScan;
3734 if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/04 */
3735 tempbx = XGINew_GetReg1(pVBInfo->P3d4, 0x35);
3737 if (tempbx & TVOverScan)
3738 tempbx |= SetCHTVOverScan;
3741 if (pVBInfo->IF_DEF_LVDS == 0) {
3742 if (pVBInfo->VBInfo & SetCRT2ToSCART)
3746 if (pVBInfo->IF_DEF_YPbPr == 1) {
3747 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
3748 index1 = XGINew_GetReg1(pVBInfo->P3d4, 0x35);
3749 index1 &= YPbPrMode;
3751 if (index1 == YPbPrMode525i)
3752 tempbx |= SetYPbPrMode525i;
3754 if (index1 == YPbPrMode525p)
3755 tempbx = tempbx | SetYPbPrMode525p;
3756 if (index1 == YPbPrMode750p)
3757 tempbx = tempbx | SetYPbPrMode750p;
3761 if (pVBInfo->IF_DEF_HiVision == 1) {
3762 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
3763 tempbx = tempbx | SetYPbPrMode1080i | SetPALTV;
3766 if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */
3767 if ((pVBInfo->VBInfo & SetInSlaveMode)
3768 && (!(pVBInfo->VBInfo & SetNotSimuMode)))
3769 tempbx |= TVSimuMode;
3771 if (!(tempbx & SetPALTV) && (modeflag > 13) && (resinfo
3772 == 8)) /* NTSC 1024x768, */
3773 tempbx |= NTSC1024x768;
3775 tempbx |= RPLLDIV2XO;
3777 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
3778 if (pVBInfo->VBInfo & SetInSlaveMode)
3779 tempbx &= (~RPLLDIV2XO);
3781 if (tempbx & (SetYPbPrMode525p
3782 | SetYPbPrMode750p))
3783 tempbx &= (~RPLLDIV2XO);
3784 else if (!(pVBInfo->VBType & (VB_XGI301B
3785 | VB_XGI302B | VB_XGI301LV
3786 | VB_XGI302LV | VB_XGI301C))) {
3787 if (tempbx & TVSimuMode)
3788 tempbx &= (~RPLLDIV2XO);
3793 pVBInfo->TVInfo = tempbx;
3796 unsigned char XGI_GetLCDInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
3797 struct vb_device_info *pVBInfo)
3799 unsigned short temp, tempax, tempbx, modeflag, resinfo = 0, LCDIdIndex;
3801 pVBInfo->LCDResInfo = 0;
3802 pVBInfo->LCDTypeInfo = 0;
3803 pVBInfo->LCDInfo = 0;
3805 if (ModeNo <= 0x13) {
3806 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ModeFlag // */
3808 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3809 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; /* si+Ext_ResInfo // */
3812 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x36); /* Get LCD Res.Info */
3813 tempbx = temp & 0x0F;
3816 tempbx = Panel1024x768; /* default */
3818 /* LCD75 [2003/8/22] Vicent */
3819 if ((tempbx == Panel1024x768) || (tempbx == Panel1280x1024)) {
3820 if (pVBInfo->VBInfo & DriverMode) {
3821 tempax = XGINew_GetReg1(pVBInfo->P3d4, 0x33);
3822 if (pVBInfo->VBInfo & SetCRT2ToLCDA)
3825 tempax = tempax >> 4;
3827 if ((resinfo == 6) || (resinfo == 9)) {
3829 tempbx |= PanelRef75Hz;
3830 } else if ((resinfo == 7) || (resinfo == 8)) {
3832 tempbx |= PanelRef75Hz;
3837 pVBInfo->LCDResInfo = tempbx;
3841 if (pVBInfo->IF_DEF_OEMUtil == 1)
3842 pVBInfo->LCDTypeInfo = (temp & 0xf0) >> 4;
3844 if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)))
3849 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37);
3851 temp &= (ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable);
3853 if ((pVBInfo->IF_DEF_ScaleLCD == 1) && (temp & LCDNonExpanding))
3854 temp &= ~EnableScalingLCD;
3858 LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo);
3860 tempax = pVBInfo->LCDCapList[LCDIdIndex].LCD_Capability;
3862 if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */
3863 if (((pVBInfo->VBType & VB_XGI302LV) || (pVBInfo->VBType
3864 & VB_XGI301C)) && (tempax & LCDDualLink)) {
3865 tempbx |= SetLCDDualLink;
3869 if (pVBInfo->IF_DEF_CH7017 == 1) {
3870 if (tempax & LCDDualLink)
3871 tempbx |= SetLCDDualLink;
3874 if (pVBInfo->IF_DEF_LVDS == 0) {
3875 if ((pVBInfo->LCDResInfo == Panel1400x1050) && (pVBInfo->VBInfo
3876 & SetCRT2ToLCD) && (ModeNo > 0x13) && (resinfo
3877 == 9) && (!(tempbx & EnableScalingLCD)))
3878 tempbx |= SetLCDtoNonExpanding; /* set to center in 1280x1024 LCDB for Panel1400x1050 */
3882 if (tempax & LCDBToA) {
3883 tempbx |= SetLCDBToA;
3887 if (pVBInfo->IF_DEF_ExpLink == 1) {
3888 if (modeflag & HalfDCLK) {
3889 /* if (!(pVBInfo->LCDInfo&LCDNonExpanding)) */
3890 if (!(tempbx & SetLCDtoNonExpanding)) {
3891 tempbx |= EnableLVDSDDA;
3893 if (ModeNo > 0x13) {
3894 if (pVBInfo->LCDResInfo
3896 if (resinfo == 4) { /* 512x384 */
3897 tempbx |= EnableLVDSDDA;
3905 if (pVBInfo->VBInfo & SetInSlaveMode) {
3906 if (pVBInfo->VBInfo & SetNotSimuMode)
3907 tempbx |= LCDVESATiming;
3909 tempbx |= LCDVESATiming;
3912 pVBInfo->LCDInfo = tempbx;
3914 if (pVBInfo->IF_DEF_PWD == 1) {
3915 if (pVBInfo->LCDInfo & SetPWDEnable) {
3916 if ((pVBInfo->VBType & VB_XGI302LV) || (pVBInfo->VBType
3918 if (!(tempax & PWDEnable))
3919 pVBInfo->LCDInfo &= ~SetPWDEnable;
3924 if (pVBInfo->IF_DEF_LVDS == 0) {
3925 if (tempax & (LockLCDBToA | StLCDBToA)) {
3926 if (pVBInfo->VBInfo & SetInSlaveMode) {
3927 if (!(tempax & LockLCDBToA)) {
3928 if (ModeNo <= 0x13) {
3930 &= ~(SetSimuScanMode
3935 | SetCRT2ToDualEdge;
3943 if (pVBInfo->IF_DEF_LVDS == 0) {
3944 if (tempax & (LockLCDBToA | StLCDBToA)) {
3945 if (pVBInfo->VBInfo & SetInSlaveMode) {
3946 if (!((!(tempax & LockLCDBToA)) && (ModeNo > 0x13))) {
3947 pVBInfo->VBInfo&=~(SetSimuScanMode|SetInSlaveMode|SetCRT2ToLCD);
3948 pVBInfo->VBInfo|=SetCRT2ToLCDA|SetCRT2ToDualEdge;
3958 unsigned char XGI_SearchModeID(unsigned short ModeNo,
3959 unsigned short *ModeIdIndex, struct vb_device_info *pVBInfo)
3963 if (ModeNo <= 0x13) {
3964 /* for (*ModeIdIndex=0; *ModeIdIndex < sizeof(pVBInfo->SModeIDTable) / sizeof(struct XGI_StStruct); (*ModeIdIndex)++) */
3965 for (*ModeIdIndex = 0;; (*ModeIdIndex)++) {
3966 if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == ModeNo)
3968 if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == 0xFF)
3973 (*ModeIdIndex)++; /* 400 lines */
3975 (*ModeIdIndex) += 2; /* 400 lines */
3976 /* else 350 lines */
3978 /* for (*ModeIdIndex=0; *ModeIdIndex < sizeof(pVBInfo->EModeIDTable) / sizeof(struct XGI_ExtStruct); (*ModeIdIndex)++) */
3979 for (*ModeIdIndex = 0;; (*ModeIdIndex)++) {
3980 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == ModeNo)
3982 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == 0xFF)
3990 /* win2000 MM adapter not support standard mode! */
3993 static unsigned char XGINew_CheckMemorySize(
3994 struct xgi_hw_device_info *HwDeviceExtension,
3995 unsigned short ModeNo,
3996 unsigned short ModeIdIndex,
3997 struct vb_device_info *pVBInfo)
3999 unsigned short memorysize, modeflag, temp, temp1, tmp;
4002 if ((HwDeviceExtension->jChipType == XGI_650) ||
4003 (HwDeviceExtension->jChipType == XGI_650M)) {
4009 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
4011 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4013 /* ModeType = modeflag&ModeInfoFlag; // Get mode type */
4015 memorysize = modeflag & MemoryInfoFlag;
4016 memorysize = memorysize > MemorySizeShift;
4017 memorysize++; /* Get memory size */
4019 temp = XGINew_GetReg1(pVBInfo->P3c4, 0x14); /* Get DRAM Size */
4022 if (HwDeviceExtension->jChipType == XG40) {
4023 temp = 1 << ((temp & 0x0F0) >> 4); /* memory size per channel SR14[7:4] */
4024 if ((tmp & 0x0c) == 0x0C) { /* Qual channels */
4026 } else if ((tmp & 0x0c) == 0x08) { /* Dual channels */
4029 } else if (HwDeviceExtension->jChipType == XG42) {
4030 temp = 1 << ((temp & 0x0F0) >> 4); /* memory size per channel SR14[7:4] */
4031 if ((tmp & 0x04) == 0x04) { /* Dual channels */
4034 } else if (HwDeviceExtension->jChipType == XG45) {
4035 temp = 1 << ((temp & 0x0F0) >> 4); /* memory size per channel SR14[7:4] */
4036 if ((tmp & 0x0c) == 0x0C) { /* Qual channels */
4038 } else if ((tmp & 0x0c) == 0x08) { /* triple channels */
4042 } else if ((tmp & 0x0c) == 0x04) { /* Dual channels */
4046 if (temp < memorysize)
4054 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)
4056 unsigned short data ;
4057 unsigned short ModeFlag ;
4059 data = XGINew_GetReg1(pVBInfo->P3c4, 0x0F);
4061 XGINew_SetReg1(pVBInfo->P3c4, 0x0F, data);
4063 if (ModeNo > 0x13) {
4064 ModeFlag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4065 if ((ModeFlag & HalfDCLK) && (ModeFlag & DoubleScanMode)) {
4066 data = XGINew_GetReg1(pVBInfo->P3c4, 0x0F);
4068 XGINew_SetReg1(pVBInfo->P3c4, 0x0F, data);
4069 data = XGINew_GetReg1(pVBInfo->P3c4, 0x01);
4071 XGINew_SetReg1(pVBInfo->P3c4, 0x01, data);
4077 static unsigned char XG21GPIODataTransfer(unsigned char ujDate)
4079 unsigned char ujRet = 0;
4080 unsigned char i = 0;
4082 for (i = 0; i < 8; i++) {
4084 /* ujRet |= GETBITS(ujDate >> i, 0:0); */
4085 ujRet |= (ujDate >> i) & 1;
4091 /*----------------------------------------------------------------------------*/
4093 /* bl[5] : LVDS signal */
4094 /* bl[1] : LVDS backlight */
4095 /* bl[0] : LVDS VDD */
4096 /*----------------------------------------------------------------------------*/
4097 static unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo)
4099 unsigned char CR4A, temp;
4101 CR4A = XGINew_GetReg1(pVBInfo->P3d4, 0x4A);
4102 XGINew_SetRegAND(pVBInfo->P3d4, 0x4A, ~0x23); /* enable GPIO write */
4104 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x48);
4106 temp = XG21GPIODataTransfer(temp);
4108 XGINew_SetReg1(pVBInfo->P3d4, 0x4A, CR4A);
4112 /*----------------------------------------------------------------------------*/
4114 /* bl[5] : LVDS signal */
4115 /* bl[1] : LVDS backlight */
4116 /* bl[0] : LVDS VDD */
4117 /*----------------------------------------------------------------------------*/
4118 static unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo)
4120 unsigned char CR4A, CRB4, temp;
4122 CR4A = XGINew_GetReg1(pVBInfo->P3d4, 0x4A);
4123 XGINew_SetRegAND(pVBInfo->P3d4, 0x4A, ~0x0C); /* enable GPIO write */
4125 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x48);
4129 XGINew_SetReg1(pVBInfo->P3d4, 0x4A, CR4A);
4130 CRB4 = XGINew_GetReg1(pVBInfo->P3d4, 0xB4);
4131 temp |= ((CRB4 & 0x04) << 3);
4135 void XGI_DisplayOn(struct xgi_hw_device_info *pXGIHWDE,
4136 struct vb_device_info *pVBInfo)
4139 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x01, 0xDF, 0x00);
4140 if (pXGIHWDE->jChipType == XG21) {
4141 if (pVBInfo->IF_DEF_LVDS == 1) {
4142 if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x1)) {
4143 XGI_XG21BLSignalVDD(0x01, 0x01, pVBInfo); /* LVDS VDD on */
4144 XGI_XG21SetPanelDelay(2, pVBInfo);
4146 if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x20))
4147 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); /* LVDS signal on */
4148 XGI_XG21SetPanelDelay(3, pVBInfo);
4149 XGI_XG21BLSignalVDD(0x02, 0x02, pVBInfo); /* LVDS backlight on */
4151 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); /* DVO/DVI signal on */
4156 if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/23 For CH7007 */
4160 if (pXGIHWDE->jChipType == XG27) {
4161 if (pVBInfo->IF_DEF_LVDS == 1) {
4162 if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x1)) {
4163 XGI_XG27BLSignalVDD(0x01, 0x01, pVBInfo); /* LVDS VDD on */
4164 XGI_XG21SetPanelDelay(2, pVBInfo);
4166 if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x20))
4167 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); /* LVDS signal on */
4168 XGI_XG21SetPanelDelay(3, pVBInfo);
4169 XGI_XG27BLSignalVDD(0x02, 0x02, pVBInfo); /* LVDS backlight on */
4171 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); /* DVO/DVI signal on */
4177 void XGI_DisplayOff(struct xgi_hw_device_info *pXGIHWDE,
4178 struct vb_device_info *pVBInfo)
4181 if (pXGIHWDE->jChipType == XG21) {
4182 if (pVBInfo->IF_DEF_LVDS == 1) {
4183 XGI_XG21BLSignalVDD(0x02, 0x00, pVBInfo); /* LVDS backlight off */
4184 XGI_XG21SetPanelDelay(3, pVBInfo);
4186 XGI_XG21BLSignalVDD(0x20, 0x00, pVBInfo); /* DVO/DVI signal off */
4190 if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/23 For CH7007 */
4191 /* if (IsCH7007TVMode(pVBInfo) == 0) */
4196 if (pXGIHWDE->jChipType == XG27) {
4197 if ((XGI_XG27GetPSCValue(pVBInfo) & 0x2)) {
4198 XGI_XG27BLSignalVDD(0x02, 0x00, pVBInfo); /* LVDS backlight off */
4199 XGI_XG21SetPanelDelay(3, pVBInfo);
4202 if (pVBInfo->IF_DEF_LVDS == 0)
4203 XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo); /* DVO/DVI signal off */
4206 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x01, 0xDF, 0x20);
4209 static void XGI_WaitDisply(struct vb_device_info *pVBInfo)
4211 while ((XGINew_GetReg2(pVBInfo->P3da) & 0x01))
4214 while (!(XGINew_GetReg2(pVBInfo->P3da) & 0x01))
4219 static void XGI_WaitDisplay(struct vb_device_info *pVBInfo)
4221 while (!(XGINew_GetReg2(pVBInfo->P3da) & 0x01));
4222 while (XGINew_GetReg2(pVBInfo->P3da) & 0x01);
4226 static void XGI_AutoThreshold(struct vb_device_info *pVBInfo)
4228 if (!(pVBInfo->SetFlag & Win9xDOSMode))
4229 XGINew_SetRegOR(pVBInfo->Part1Port, 0x01, 0x40);
4232 static void XGI_SaveCRT2Info(unsigned short ModeNo, struct vb_device_info *pVBInfo)
4234 unsigned short temp1, temp2;
4236 XGINew_SetReg1(pVBInfo->P3d4, 0x34, ModeNo); /* reserve CR34 for CRT1 Mode No */
4237 temp1 = (pVBInfo->VBInfo & SetInSlaveMode) >> 8;
4238 temp2 = ~(SetInSlaveMode >> 8);
4239 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x31, temp2, temp1);
4242 static void XGI_GetCRT2ResInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
4243 struct vb_device_info *pVBInfo)
4245 unsigned short xres, yres, modeflag, resindex;
4247 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
4248 if (ModeNo <= 0x13) {
4249 xres = pVBInfo->StResInfo[resindex].HTotal;
4250 yres = pVBInfo->StResInfo[resindex].VTotal;
4251 /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; si+St_ResInfo */
4253 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
4254 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
4255 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */
4258 if (pVBInfo->IF_DEF_FSTN) {
4263 if (modeflag & HalfDCLK)
4266 if (modeflag & DoubleScanMode)
4271 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
4272 if (pVBInfo->IF_DEF_LVDS == 0) {
4273 if (pVBInfo->LCDResInfo == Panel1600x1200) {
4274 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
4280 if (pVBInfo->LCDResInfo == Panel1280x1024) {
4283 else if (yres == 350)
4286 if (pVBInfo->LCDInfo & LCDVESATiming) {
4292 if (pVBInfo->LCDResInfo == Panel1024x768) {
4293 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
4294 if (!(pVBInfo->LCDInfo
4295 & LCDNonExpanding)) {
4298 else if (yres == 400)
4300 else if (yres == 480)
4311 pVBInfo->VGAHDE = xres;
4312 pVBInfo->HDE = xres;
4313 pVBInfo->VGAVDE = yres;
4314 pVBInfo->VDE = yres;
4317 static unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo)
4320 if ((pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) &&
4321 (pVBInfo->LCDInfo & SetLCDDualLink)) /* shampoo0129 */
4327 static void XGI_GetRAMDAC2DATA(unsigned short ModeNo, unsigned short ModeIdIndex,
4328 unsigned short RefreshRateTableIndex,
4329 struct vb_device_info *pVBInfo)
4331 unsigned short tempax, tempbx, temp1, temp2, modeflag = 0, tempcx,
4332 StandTableIndex, CRT1Index;
4334 pVBInfo->RVBHCMAX = 1;
4335 pVBInfo->RVBHCFACT = 1;
4337 if (ModeNo <= 0x13) {
4338 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
4339 StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
4340 tempax = pVBInfo->StandTable[StandTableIndex].CRTC[0];
4341 tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[6];
4342 temp1 = pVBInfo->StandTable[StandTableIndex].CRTC[7];
4344 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4346 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4347 CRT1Index &= IndexMask;
4349 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[0];
4351 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5];
4352 tempax = (temp1 & 0xFF) | ((temp2 & 0x03) << 8);
4354 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[8];
4356 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14]
4359 tempcx = tempcx << 2;
4362 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9];
4372 if (modeflag & Charx8Dot)
4377 pVBInfo->VGAHT = tempax;
4378 pVBInfo->HT = tempax;
4380 pVBInfo->VGAVT = tempbx;
4381 pVBInfo->VT = tempbx;
4384 static void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex,
4385 unsigned short RefreshRateTableIndex,
4386 struct vb_device_info *pVBInfo)
4388 unsigned short tempax = 0, tempbx, modeflag, resinfo;
4390 struct XGI_LCDDataStruct *LCDPtr = NULL;
4391 struct XGI_TVDataStruct *TVPtr = NULL;
4393 if (ModeNo <= 0x13) {
4394 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
4395 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
4397 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
4398 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4401 pVBInfo->NewFlickerMode = 0;
4402 pVBInfo->RVBHRS = 50;
4404 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
4405 XGI_GetRAMDAC2DATA(ModeNo, ModeIdIndex, RefreshRateTableIndex,
4412 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
4413 LCDPtr = (struct XGI_LCDDataStruct *) XGI_GetLcdPtr(tempbx,
4414 ModeNo, ModeIdIndex, RefreshRateTableIndex,
4417 pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX;
4418 pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT;
4419 pVBInfo->VGAHT = LCDPtr->VGAHT;
4420 pVBInfo->VGAVT = LCDPtr->VGAVT;
4421 pVBInfo->HT = LCDPtr->LCDHT;
4422 pVBInfo->VT = LCDPtr->LCDVT;
4424 if (pVBInfo->LCDResInfo == Panel1024x768) {
4428 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
4429 if (pVBInfo->VGAVDE == 357)
4431 else if (pVBInfo->VGAVDE == 420)
4433 else if (pVBInfo->VGAVDE == 525)
4435 else if (pVBInfo->VGAVDE == 600)
4437 /* else if (pVBInfo->VGAVDE==350) tempbx=560; */
4438 /* else if (pVBInfo->VGAVDE==400) tempbx=640; */
4443 } else if (pVBInfo->LCDResInfo == Panel1024x768x75) {
4446 } else if (pVBInfo->LCDResInfo == Panel1280x1024) {
4448 if (pVBInfo->VGAVDE == 360)
4450 else if (pVBInfo->VGAVDE == 375)
4452 else if (pVBInfo->VGAVDE == 405)
4456 } else if (pVBInfo->LCDResInfo == Panel1280x1024x75) {
4459 } else if (pVBInfo->LCDResInfo == Panel1280x960) {
4461 if (pVBInfo->VGAVDE == 350)
4463 else if (pVBInfo->VGAVDE == 400)
4465 else if (pVBInfo->VGAVDE == 1024)
4469 } else if (pVBInfo->LCDResInfo == Panel1400x1050) {
4473 if (pVBInfo->VGAVDE == 1024) {
4477 } else if (pVBInfo->LCDResInfo == Panel1600x1200) {
4479 tempbx = 1200; /* alan 10/14/2003 */
4480 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
4481 if (pVBInfo->VGAVDE == 350)
4483 else if (pVBInfo->VGAVDE == 400)
4488 if (pVBInfo->LCDInfo & LCDNonExpanding) {
4489 tempax = pVBInfo->VGAHDE;
4490 tempbx = pVBInfo->VGAVDE;
4493 pVBInfo->HDE = tempax;
4494 pVBInfo->VDE = tempbx;
4498 if (pVBInfo->VBInfo & (SetCRT2ToTV)) {
4500 TVPtr = (struct XGI_TVDataStruct *) XGI_GetTVPtr(tempbx,
4501 ModeNo, ModeIdIndex, RefreshRateTableIndex,
4504 pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX;
4505 pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT;
4506 pVBInfo->VGAHT = TVPtr->VGAHT;
4507 pVBInfo->VGAVT = TVPtr->VGAVT;
4508 pVBInfo->HDE = TVPtr->TVHDE;
4509 pVBInfo->VDE = TVPtr->TVVDE;
4510 pVBInfo->RVBHRS = TVPtr->RVBHRS;
4511 pVBInfo->NewFlickerMode = TVPtr->FlickerMode;
4513 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4514 if (resinfo == 0x08)
4515 pVBInfo->NewFlickerMode = 0x40;
4516 else if (resinfo == 0x09)
4517 pVBInfo->NewFlickerMode = 0x40;
4518 else if (resinfo == 0x12)
4519 pVBInfo->NewFlickerMode = 0x40;
4521 if (pVBInfo->VGAVDE == 350)
4522 pVBInfo->TVInfo |= TVSimuMode;
4527 if (pVBInfo->VBInfo & SetInSlaveMode) {
4528 if (pVBInfo->TVInfo & TVSimuMode) {
4532 if (!(modeflag & Charx8Dot)) {
4533 tempax = StHiTextTVHT;
4534 tempbx = StHiTextTVVT;
4538 } else if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
4539 if (pVBInfo->TVInfo & SetYPbPrMode750p) {
4540 tempax = YPbPrTV750pHT; /* Ext750pTVHT */
4541 tempbx = YPbPrTV750pVT; /* Ext750pTVVT */
4544 if (pVBInfo->TVInfo & SetYPbPrMode525p) {
4545 tempax = YPbPrTV525pHT; /* Ext525pTVHT */
4546 tempbx = YPbPrTV525pVT; /* Ext525pTVVT */
4547 } else if (pVBInfo->TVInfo & SetYPbPrMode525i) {
4548 tempax = YPbPrTV525iHT; /* Ext525iTVHT */
4549 tempbx = YPbPrTV525iVT; /* Ext525iTVVT */
4550 if (pVBInfo->TVInfo & NTSC1024x768)
4551 tempax = NTSC1024x768HT;
4556 if (!(pVBInfo->TVInfo & SetPALTV)) {
4559 if (pVBInfo->TVInfo & NTSC1024x768)
4560 tempax = NTSC1024x768HT;
4564 pVBInfo->HT = tempax;
4565 pVBInfo->VT = tempbx;
4570 static void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex,
4571 unsigned short RefreshRateTableIndex,
4572 struct vb_device_info *pVBInfo)
4574 unsigned char di_0, di_1, tempal;
4576 tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex,
4578 XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo);
4579 XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo);
4581 if (pVBInfo->VBType & VB_XGI301) { /* shampoo 0129 */
4583 XGINew_SetReg1(pVBInfo->Part4Port, 0x0A, 0x10);
4584 XGINew_SetReg1(pVBInfo->Part4Port, 0x0B, di_1);
4585 XGINew_SetReg1(pVBInfo->Part4Port, 0x0A, di_0);
4586 } else { /* 301b/302b/301lv/302lv */
4587 XGINew_SetReg1(pVBInfo->Part4Port, 0x0A, di_0);
4588 XGINew_SetReg1(pVBInfo->Part4Port, 0x0B, di_1);
4591 XGINew_SetReg1(pVBInfo->Part4Port, 0x00, 0x12);
4593 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC)
4594 XGINew_SetRegOR(pVBInfo->Part4Port, 0x12, 0x28);
4596 XGINew_SetRegOR(pVBInfo->Part4Port, 0x12, 0x08);
4599 static unsigned short XGI_GetColorDepth(unsigned short ModeNo,
4600 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
4602 unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8 };
4604 unsigned short modeflag;
4607 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
4609 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4611 index = (modeflag & ModeInfoFlag) - ModeEGA;
4616 return ColorDepth[index];
4619 static unsigned short XGI_GetOffset(unsigned short ModeNo, unsigned short ModeIdIndex,
4620 unsigned short RefreshRateTableIndex,
4621 struct xgi_hw_device_info *HwDeviceExtension,
4622 struct vb_device_info *pVBInfo)
4624 unsigned short temp, colordepth, modeinfo, index, infoflag,
4625 ColorDepth[] = { 0x01, 0x02, 0x04 };
4627 modeinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo;
4631 infoflag = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
4633 index = (modeinfo >> 8) & 0xFF;
4635 temp = pVBInfo->ScreenOffset[index];
4637 if (infoflag & InterlaceMode)
4640 colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo);
4642 if ((ModeNo >= 0x7C) && (ModeNo <= 0x7E)) {
4643 temp = ModeNo - 0x7C;
4644 colordepth = ColorDepth[temp];
4646 if (infoflag & InterlaceMode)
4648 return temp * colordepth;
4650 return temp * colordepth;
4654 static void XGI_SetCRT2Offset(unsigned short ModeNo,
4655 unsigned short ModeIdIndex,
4656 unsigned short RefreshRateTableIndex,
4657 struct xgi_hw_device_info *HwDeviceExtension,
4658 struct vb_device_info *pVBInfo)
4660 unsigned short offset;
4663 if (pVBInfo->VBInfo & SetInSlaveMode)
4666 offset = XGI_GetOffset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
4667 HwDeviceExtension, pVBInfo);
4668 temp = (unsigned char) (offset & 0xFF);
4669 XGINew_SetReg1(pVBInfo->Part1Port, 0x07, temp);
4670 temp = (unsigned char) ((offset & 0xFF00) >> 8);
4671 XGINew_SetReg1(pVBInfo->Part1Port, 0x09, temp);
4672 temp = (unsigned char) (((offset >> 3) & 0xFF) + 1);
4673 XGINew_SetReg1(pVBInfo->Part1Port, 0x03, temp);
4676 static void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo)
4678 XGINew_SetReg1(pVBInfo->Part1Port, 0x01, 0x3B); /* threshold high ,disable auto threshold */
4679 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x02, ~(0x3F), 0x04); /* threshold low default 04h */
4682 static void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
4683 struct xgi_hw_device_info *HwDeviceExtension,
4684 unsigned short RefreshRateTableIndex,
4685 struct vb_device_info *pVBInfo)
4687 unsigned short tempcx = 0, CRT1Index = 0, resinfo = 0;
4689 if (ModeNo > 0x13) {
4690 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4691 CRT1Index &= IndexMask;
4692 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4695 XGI_SetCRT2Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
4696 HwDeviceExtension, pVBInfo);
4697 XGI_SetCRT2FIFO(pVBInfo);
4698 /* XGI_SetCRT2Sync(ModeNo,RefreshRateTableIndex); */
4700 for (tempcx = 4; tempcx < 7; tempcx++)
4701 XGINew_SetReg1(pVBInfo->Part1Port, tempcx, 0x0);
4703 XGINew_SetReg1(pVBInfo->Part1Port, 0x50, 0x00);
4704 XGINew_SetReg1(pVBInfo->Part1Port, 0x02, 0x44); /* temp 0206 */
4707 static void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
4708 struct xgi_hw_device_info *HwDeviceExtension,
4709 unsigned short RefreshRateTableIndex,
4710 struct vb_device_info *pVBInfo)
4712 unsigned short temp = 0, tempax = 0, tempbx = 0, tempcx = 0,
4713 pushbx = 0, CRT1Index = 0, modeflag, resinfo = 0;
4715 if (ModeNo > 0x13) {
4716 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4717 CRT1Index &= IndexMask;
4718 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4722 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
4724 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4726 /* bainy change table name */
4727 if (modeflag & HalfDCLK) {
4728 temp = (pVBInfo->VGAHT / 2 - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */
4729 XGINew_SetReg1(pVBInfo->Part1Port, 0x08, temp);
4730 temp = (((pVBInfo->VGAHT / 2 - 1) & 0xFF00) >> 8) << 4;
4731 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x09, ~0x0F0, temp);
4732 temp = (pVBInfo->VGAHDE / 2 + 16) & 0x0FF; /* BTVGA2HDEE 0x0A,0x0C */
4733 XGINew_SetReg1(pVBInfo->Part1Port, 0x0A, temp);
4734 tempcx = ((pVBInfo->VGAHT - pVBInfo->VGAHDE) / 2) >> 2;
4735 pushbx = pVBInfo->VGAHDE / 2 + 16;
4736 tempcx = tempcx >> 1;
4737 tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */
4740 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
4741 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4];
4742 tempbx |= ((pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14]
4744 tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */
4745 tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5];
4747 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[15];
4748 temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */
4749 tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */
4755 if (tempcx > (pVBInfo->VGAHT / 2))
4756 tempcx = pVBInfo->VGAHT / 2;
4758 temp = tempbx & 0x00FF;
4760 XGINew_SetReg1(pVBInfo->Part1Port, 0x0B, temp);
4762 temp = (pVBInfo->VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */
4763 XGINew_SetReg1(pVBInfo->Part1Port, 0x08, temp);
4764 temp = (((pVBInfo->VGAHT - 1) & 0xFF00) >> 8) << 4;
4765 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x09, ~0x0F0, temp);
4766 temp = (pVBInfo->VGAHDE + 16) & 0x0FF; /* BTVGA2HDEE 0x0A,0x0C */
4767 XGINew_SetReg1(pVBInfo->Part1Port, 0x0A, temp);
4768 tempcx = (pVBInfo->VGAHT - pVBInfo->VGAHDE) >> 2; /* cx */
4769 pushbx = pVBInfo->VGAHDE + 16;
4770 tempcx = tempcx >> 1;
4771 tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */
4774 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
4775 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[3];
4776 tempbx |= ((pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5]
4778 tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */
4779 tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4];
4781 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[6];
4782 temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */
4783 tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */
4788 if (tempcx > pVBInfo->VGAHT)
4789 tempcx = pVBInfo->VGAHT;
4791 temp = tempbx & 0x00FF;
4792 XGINew_SetReg1(pVBInfo->Part1Port, 0x0B, temp);
4795 tempax = (tempax & 0x00FF) | (tempbx & 0xFF00);
4797 tempbx = (tempbx & 0x00FF) | ((tempbx & 0xFF00) << 4);
4798 tempax |= (tempbx & 0xFF00);
4799 temp = (tempax & 0xFF00) >> 8;
4800 XGINew_SetReg1(pVBInfo->Part1Port, 0x0C, temp);
4801 temp = tempcx & 0x00FF;
4802 XGINew_SetReg1(pVBInfo->Part1Port, 0x0D, temp);
4803 tempcx = (pVBInfo->VGAVT - 1);
4804 temp = tempcx & 0x00FF;
4806 if (pVBInfo->IF_DEF_CH7005 == 1) {
4807 if (pVBInfo->VBInfo & 0x0C)
4811 XGINew_SetReg1(pVBInfo->Part1Port, 0x0E, temp);
4812 tempbx = pVBInfo->VGAVDE - 1;
4813 temp = tempbx & 0x00FF;
4814 XGINew_SetReg1(pVBInfo->Part1Port, 0x0F, temp);
4815 temp = ((tempbx & 0xFF00) << 3) >> 8;
4816 temp |= ((tempcx & 0xFF00) >> 8);
4817 XGINew_SetReg1(pVBInfo->Part1Port, 0x12, temp);
4819 tempax = pVBInfo->VGAVDE;
4820 tempbx = pVBInfo->VGAVDE;
4821 tempcx = pVBInfo->VGAVT;
4822 tempbx = (pVBInfo->VGAVT + pVBInfo->VGAVDE) >> 1; /* BTVGA2VRS 0x10,0x11 */
4823 tempcx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) >> 4) + tempbx + 1; /* BTVGA2VRE 0x11 */
4825 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
4826 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[10];
4827 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9];
4835 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14];
4840 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[11];
4841 tempcx = (tempcx & 0xFF00) | (temp & 0x00FF);
4844 temp = tempbx & 0x00FF;
4845 XGINew_SetReg1(pVBInfo->Part1Port, 0x10, temp);
4846 temp = ((tempbx & 0xFF00) >> 8) << 4;
4847 temp = ((tempcx & 0x000F) | (temp));
4848 XGINew_SetReg1(pVBInfo->Part1Port, 0x11, temp);
4851 if (modeflag & DoubleScanMode)
4854 if (modeflag & HalfDCLK)
4857 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2C, ~0x0C0, tempax);
4860 static unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo)
4862 unsigned long tempax, tempbx;
4864 tempbx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) * pVBInfo->RVBHCMAX)
4866 tempax = (pVBInfo->VT - pVBInfo->VDE) * pVBInfo->RVBHCFACT;
4867 tempax = (tempax * pVBInfo->HT) / tempbx;
4869 return (unsigned short) tempax;
4872 static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
4873 struct xgi_hw_device_info *HwDeviceExtension,
4874 unsigned short RefreshRateTableIndex,
4875 struct vb_device_info *pVBInfo)
4877 unsigned short push1, push2, tempax, tempbx = 0, tempcx, temp, resinfo,
4878 modeflag, CRT1Index;
4880 if (ModeNo <= 0x13) {
4881 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
4882 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
4884 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
4885 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4886 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4887 CRT1Index &= IndexMask;
4890 if (!(pVBInfo->VBInfo & SetInSlaveMode))
4893 temp = 0xFF; /* set MAX HT */
4894 XGINew_SetReg1(pVBInfo->Part1Port, 0x03, temp);
4895 /* if (modeflag & Charx8Dot) */
4896 /* tempcx = 0x08; */
4900 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C))
4901 modeflag |= Charx8Dot;
4903 tempax = pVBInfo->VGAHDE; /* 0x04 Horizontal Display End */
4905 if (modeflag & HalfDCLK)
4906 tempax = tempax >> 1;
4908 tempax = (tempax / tempcx) - 1;
4909 tempbx |= ((tempax & 0x00FF) << 8);
4910 temp = tempax & 0x00FF;
4911 XGINew_SetReg1(pVBInfo->Part1Port, 0x04, temp);
4913 temp = (tempbx & 0xFF00) >> 8;
4915 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4916 if (!(pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
4917 | VB_XGI302LV | VB_XGI301C)))
4920 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4921 if (pVBInfo->VBType & VB_XGI301LV) {
4922 if (pVBInfo->VBExtInfo == VB_YPbPr1080i) {
4926 } else if (resinfo == 7) {
4932 XGINew_SetReg1(pVBInfo->Part1Port, 0x05, temp); /* 0x05 Horizontal Display Start */
4933 XGINew_SetReg1(pVBInfo->Part1Port, 0x06, 0x03); /* 0x06 Horizontal Blank end */
4935 if (!(pVBInfo->VBInfo & DisableCRT2Display)) { /* 030226 bainy */
4936 if (pVBInfo->VBInfo & SetCRT2ToTV)
4937 tempax = pVBInfo->VGAHT;
4939 tempax = XGI_GetVGAHT2(pVBInfo);
4942 if (tempax >= pVBInfo->VGAHT)
4943 tempax = pVBInfo->VGAHT;
4945 if (modeflag & HalfDCLK)
4946 tempax = tempax >> 1;
4948 tempax = (tempax / tempcx) - 5;
4949 tempcx = tempax; /* 20030401 0x07 horizontal Retrace Start */
4950 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4951 temp = (tempbx & 0x00FF) - 1;
4952 if (!(modeflag & HalfDCLK)) {
4954 if (pVBInfo->TVInfo & TVSimuMode) {
4961 /* tempcx = tempbx & 0x00FF ; */
4962 tempbx = (tempbx & 0xFF00) >> 8;
4963 tempcx = (tempcx + tempbx) >> 1;
4964 temp = (tempcx & 0x00FF) + 2;
4966 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4968 if (!(modeflag & HalfDCLK)) {
4969 if ((modeflag & Charx8Dot)) {
4971 if (pVBInfo->VGAHDE >= 800)
4976 if (!(modeflag & HalfDCLK)) {
4978 if (pVBInfo->LCDResInfo != Panel1280x960) {
4979 if (pVBInfo->VGAHDE >= 800) {
4981 if (pVBInfo->ModeType
4986 if (pVBInfo->LCDResInfo
4987 != Panel1280x1024) {
4994 if (pVBInfo->VGAHDE >= 1280) {
4995 if (pVBInfo->LCDResInfo
4997 if (pVBInfo->LCDInfo
4998 & LCDNonExpanding) {
5010 XGINew_SetReg1(pVBInfo->Part1Port, 0x07, temp); /* 0x07 Horizontal Retrace Start */
5011 XGINew_SetReg1(pVBInfo->Part1Port, 0x08, 0); /* 0x08 Horizontal Retrace End */
5013 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5014 if (pVBInfo->TVInfo & TVSimuMode) {
5015 if ((ModeNo == 0x06) || (ModeNo == 0x10) || (ModeNo
5016 == 0x11) || (ModeNo == 0x13) || (ModeNo
5018 XGINew_SetReg1(pVBInfo->Part1Port, 0x07, 0x5b);
5019 XGINew_SetReg1(pVBInfo->Part1Port, 0x08, 0x03);
5022 if ((ModeNo == 0x00) || (ModeNo == 0x01)) {
5023 if (pVBInfo->TVInfo & SetNTSCTV) {
5024 XGINew_SetReg1(pVBInfo->Part1Port,
5026 XGINew_SetReg1(pVBInfo->Part1Port,
5029 XGINew_SetReg1(pVBInfo->Part1Port,
5031 XGINew_SetReg1(pVBInfo->Part1Port,
5033 XGINew_SetReg1(pVBInfo->Part1Port,
5038 if ((ModeNo == 0x02) || (ModeNo == 0x03) || (ModeNo
5040 if (pVBInfo->TVInfo & SetNTSCTV) {
5041 XGINew_SetReg1(pVBInfo->Part1Port,
5043 XGINew_SetReg1(pVBInfo->Part1Port,
5046 XGINew_SetReg1(pVBInfo->Part1Port,
5048 XGINew_SetReg1(pVBInfo->Part1Port,
5050 XGINew_SetReg1(pVBInfo->Part1Port,
5055 if ((ModeNo == 0x04) || (ModeNo == 0x05) || (ModeNo
5056 == 0x0D) || (ModeNo == 0x50)) {
5057 if (pVBInfo->TVInfo & SetNTSCTV) {
5058 XGINew_SetReg1(pVBInfo->Part1Port,
5060 XGINew_SetReg1(pVBInfo->Part1Port,
5063 XGINew_SetReg1(pVBInfo->Part1Port,
5065 XGINew_SetReg1(pVBInfo->Part1Port,
5072 XGINew_SetReg1(pVBInfo->Part1Port, 0x18, 0x03); /* 0x18 SR0B */
5073 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0xF0, 0x00);
5074 XGINew_SetReg1(pVBInfo->Part1Port, 0x09, 0xFF); /* 0x09 Set Max VT */
5076 tempbx = pVBInfo->VGAVT;
5079 tempbx = pVBInfo->VGAVDE; /* 0x0E Virtical Display End */
5094 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
5095 if (pVBInfo->LCDResInfo == Panel1024x768) {
5096 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
5105 temp = tempbx & 0x00FF;
5107 temp = tempbx & 0x00FF;
5108 XGINew_SetReg1(pVBInfo->Part1Port, 0x10, temp); /* 0x10 vertical Blank Start */
5111 temp = tempbx & 0x00FF;
5112 XGINew_SetReg1(pVBInfo->Part1Port, 0x0E, temp);
5114 if (tempbx & 0x0100)
5119 if (modeflag & DoubleScanMode)
5122 if (tempbx & 0x0200)
5125 temp = (tempax & 0xFF00) >> 8;
5126 XGINew_SetReg1(pVBInfo->Part1Port, 0x0B, temp);
5128 if (tempbx & 0x0400)
5131 XGINew_SetReg1(pVBInfo->Part1Port, 0x11, 0x00); /* 0x11 Vertival Blank End */
5134 tempax -= tempbx; /* 0x0C Vertical Retrace Start */
5135 tempax = tempax >> 2;
5136 push1 = tempax; /* push ax */
5138 if (resinfo != 0x09) {
5139 tempax = tempax << 1;
5143 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5144 if (pVBInfo->VBType & VB_XGI301LV) {
5145 if (pVBInfo->TVInfo & SetYPbPrMode1080i) {
5148 if (pVBInfo->TVInfo & TVSimuMode) {
5149 if (pVBInfo->TVInfo & SetPALTV) {
5152 if (!(pVBInfo->TVInfo
5155 | SetYPbPrMode1080i)))
5167 if (pVBInfo->TVInfo & TVSimuMode) {
5168 if (pVBInfo->TVInfo & SetPALTV) {
5169 if (pVBInfo->VBType & VB_XGI301LV) {
5170 if (!(pVBInfo->TVInfo
5173 | SetYPbPrMode1080i)))
5182 tempax = tempax >> 2;
5185 push1 = tempax; /* push ax */
5187 if ((pVBInfo->TVInfo & SetPALTV)) {
5188 if (tempbx <= 513) {
5194 temp = tempbx & 0x00FF;
5195 XGINew_SetReg1(pVBInfo->Part1Port, 0x0C, temp);
5197 temp = tempbx & 0x00FF;
5198 XGINew_SetReg1(pVBInfo->Part1Port, 0x10, temp);
5200 if (tempbx & 0x0100)
5203 if (tempbx & 0x0200)
5204 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x0B, 0x0FF, 0x20);
5208 if (tempbx & 0x0100)
5211 if (tempbx & 0x0200)
5214 if (tempbx & 0x0400)
5217 tempbx = push1; /* pop ax */
5218 temp = tempbx & 0x00FF;
5220 XGINew_SetReg1(pVBInfo->Part1Port, 0x0D, temp); /* 0x0D vertical Retrace End */
5222 if (tempbx & 0x0010)
5225 temp = tempcx & 0x00FF;
5226 XGINew_SetReg1(pVBInfo->Part1Port, 0x0A, temp); /* 0x0A CR07 */
5227 temp = (tempcx & 0x0FF00) >> 8;
5228 XGINew_SetReg1(pVBInfo->Part1Port, 0x17, temp); /* 0x17 SR0A */
5230 temp = (tempax & 0xFF00) >> 8;
5232 temp = (temp >> 1) & 0x09;
5234 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C))
5237 XGINew_SetReg1(pVBInfo->Part1Port, 0x16, temp); /* 0x16 SR01 */
5238 XGINew_SetReg1(pVBInfo->Part1Port, 0x0F, 0); /* 0x0F CR14 */
5239 XGINew_SetReg1(pVBInfo->Part1Port, 0x12, 0); /* 0x12 CR17 */
5241 if (pVBInfo->LCDInfo & LCDRGB18Bit)
5246 XGINew_SetReg1(pVBInfo->Part1Port, 0x1A, temp); /* 0x1A SR0E */
5251 static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex,
5252 unsigned short RefreshRateTableIndex,
5253 struct xgi_hw_device_info *HwDeviceExtension,
5254 struct vb_device_info *pVBInfo)
5256 unsigned short i, j, tempax, tempbx, tempcx, temp, push1, push2,
5257 modeflag, resinfo, crt2crtc;
5258 unsigned char *TimingPoint;
5260 unsigned long longtemp, tempeax, tempebx, temp2, tempecx;
5262 if (ModeNo <= 0x13) {
5263 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
5264 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
5265 crt2crtc = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
5267 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
5268 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
5270 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
5275 if (!(pVBInfo->VBInfo & SetCRT2ToAVIDEO))
5278 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
5281 if (pVBInfo->VBInfo & SetCRT2ToSCART)
5284 if (!(pVBInfo->TVInfo & SetPALTV))
5287 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5290 if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))
5293 tempax = (tempax & 0xff00) >> 8;
5295 XGINew_SetReg1(pVBInfo->Part2Port, 0x0, tempax);
5296 TimingPoint = pVBInfo->NTSCTiming;
5298 if (pVBInfo->TVInfo & SetPALTV)
5299 TimingPoint = pVBInfo->PALTiming;
5301 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5302 TimingPoint = pVBInfo->HiTVExtTiming;
5304 if (pVBInfo->VBInfo & SetInSlaveMode)
5305 TimingPoint = pVBInfo->HiTVSt2Timing;
5307 if (pVBInfo->SetFlag & TVSimuMode)
5308 TimingPoint = pVBInfo->HiTVSt1Timing;
5310 if (!(modeflag & Charx8Dot))
5311 TimingPoint = pVBInfo->HiTVTextTiming;
5314 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
5315 if (pVBInfo->TVInfo & SetYPbPrMode525i)
5316 TimingPoint = pVBInfo->YPbPr525iTiming;
5318 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5319 TimingPoint = pVBInfo->YPbPr525pTiming;
5321 if (pVBInfo->TVInfo & SetYPbPrMode750p)
5322 TimingPoint = pVBInfo->YPbPr750pTiming;
5325 for (i = 0x01, j = 0; i <= 0x2D; i++, j++)
5326 XGINew_SetReg1(pVBInfo->Part2Port, i, TimingPoint[j]);
5328 for (i = 0x39; i <= 0x45; i++, j++)
5329 XGINew_SetReg1(pVBInfo->Part2Port, i, TimingPoint[j]); /* di->temp2[j] */
5331 if (pVBInfo->VBInfo & SetCRT2ToTV)
5332 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x3A, 0x1F, 0x00);
5334 temp = pVBInfo->NewFlickerMode;
5336 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x0A, 0xFF, temp);
5338 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5341 if (pVBInfo->TVInfo & SetPALTV)
5346 if (pVBInfo->VDE <= tempax) {
5347 tempax -= pVBInfo->VDE;
5348 tempax = tempax >> 2;
5349 tempax = (tempax & 0x00FF) | ((tempax & 0x00FF) << 8);
5351 temp = (tempax & 0xFF00) >> 8;
5352 temp += (unsigned short) TimingPoint[0];
5354 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5355 | VB_XGI302LV | VB_XGI301C)) {
5356 if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO
5357 | SetCRT2ToSVIDEO | SetCRT2ToSCART
5358 | SetCRT2ToYPbPr)) {
5359 tempcx = pVBInfo->VGAHDE;
5360 if (tempcx >= 1024) {
5361 temp = 0x17; /* NTSC */
5362 if (pVBInfo->TVInfo & SetPALTV)
5363 temp = 0x19; /* PAL */
5368 XGINew_SetReg1(pVBInfo->Part2Port, 0x01, temp);
5370 temp = (tempax & 0xFF00) >> 8;
5371 temp += TimingPoint[1];
5373 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5374 | VB_XGI302LV | VB_XGI301C)) {
5375 if ((pVBInfo->VBInfo & (SetCRT2ToAVIDEO
5376 | SetCRT2ToSVIDEO | SetCRT2ToSCART
5377 | SetCRT2ToYPbPr))) {
5378 tempcx = pVBInfo->VGAHDE;
5379 if (tempcx >= 1024) {
5380 temp = 0x1D; /* NTSC */
5381 if (pVBInfo->TVInfo & SetPALTV)
5382 temp = 0x52; /* PAL */
5386 XGINew_SetReg1(pVBInfo->Part2Port, 0x02, temp);
5390 tempcx = pVBInfo->HT;
5392 if (XGI_IsLCDDualLink(pVBInfo))
5393 tempcx = tempcx >> 1;
5396 temp = tempcx & 0x00FF;
5397 XGINew_SetReg1(pVBInfo->Part2Port, 0x1B, temp);
5399 temp = (tempcx & 0xFF00) >> 8;
5400 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1D, ~0x0F, temp);
5402 tempcx = pVBInfo->HT >> 1;
5403 push1 = tempcx; /* push cx */
5406 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5409 temp = tempcx & 0x00FF;
5411 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x22, 0x0F, temp);
5413 tempbx = TimingPoint[j] | ((TimingPoint[j + 1]) << 8);
5416 temp = tempbx & 0x00FF;
5417 XGINew_SetReg1(pVBInfo->Part2Port, 0x24, temp);
5418 temp = (tempbx & 0xFF00) >> 8;
5420 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x25, 0x0F, temp);
5423 tempbx = tempbx + 8;
5424 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5425 tempbx = tempbx - 4;
5429 temp = (tempbx & 0x00FF) << 4;
5430 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x29, 0x0F, temp);
5433 tempcx += (TimingPoint[j] | ((TimingPoint[j + 1]) << 8));
5434 temp = tempcx & 0x00FF;
5435 XGINew_SetReg1(pVBInfo->Part2Port, 0x27, temp);
5436 temp = ((tempcx & 0xFF00) >> 8) << 4;
5437 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x28, 0x0F, temp);
5440 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5443 temp = tempcx & 0xFF;
5445 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x2A, 0x0F, temp);
5447 tempcx = push1; /* pop cx */
5449 temp = TimingPoint[j] | ((TimingPoint[j + 1]) << 8);
5451 temp = tempcx & 0x00FF;
5453 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x2D, 0x0F, temp);
5457 if (!(pVBInfo->VBInfo & SetCRT2ToTV)) {
5458 tempax = XGI_GetVGAHT2(pVBInfo);
5459 tempcx = tempax - 1;
5461 temp = tempcx & 0x00FF;
5462 XGINew_SetReg1(pVBInfo->Part2Port, 0x2E, temp);
5464 tempbx = pVBInfo->VDE;
5466 if (pVBInfo->VGAVDE == 360)
5468 if (pVBInfo->VGAVDE == 375)
5470 if (pVBInfo->VGAVDE == 405)
5473 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5474 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
5475 if (!(pVBInfo->TVInfo & (SetYPbPrMode525p
5476 | SetYPbPrMode750p)))
5477 tempbx = tempbx >> 1;
5479 tempbx = tempbx >> 1;
5483 temp = tempbx & 0x00FF;
5485 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5486 if (pVBInfo->VBType & VB_XGI301LV) {
5487 if (pVBInfo->TVInfo & SetYPbPrMode1080i) {
5488 if (pVBInfo->VBInfo & SetInSlaveMode) {
5494 if (pVBInfo->VBInfo & SetInSlaveMode) {
5501 XGINew_SetReg1(pVBInfo->Part2Port, 0x2F, temp);
5503 temp = (tempcx & 0xFF00) >> 8;
5504 temp |= ((tempbx & 0xFF00) >> 8) << 6;
5506 if (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)) {
5507 if (pVBInfo->VBType & VB_XGI301LV) {
5508 if (pVBInfo->TVInfo & SetYPbPrMode1080i) {
5511 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
5516 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
5521 XGINew_SetReg1(pVBInfo->Part2Port, 0x30, temp);
5523 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5524 | VB_XGI302LV | VB_XGI301C)) { /* TV gatingno */
5525 tempbx = pVBInfo->VDE;
5526 tempcx = tempbx - 2;
5528 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5529 if (!(pVBInfo->TVInfo & (SetYPbPrMode525p
5530 | SetYPbPrMode750p)))
5531 tempbx = tempbx >> 1;
5534 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
5536 if (tempcx & 0x0400)
5539 if (tempbx & 0x0400)
5542 XGINew_SetReg1(pVBInfo->Part4Port, 0x10, temp);
5545 temp = (((tempbx - 3) & 0x0300) >> 8) << 5;
5546 XGINew_SetReg1(pVBInfo->Part2Port, 0x46, temp);
5547 temp = (tempbx - 3) & 0x00FF;
5548 XGINew_SetReg1(pVBInfo->Part2Port, 0x47, temp);
5551 tempbx = tempbx & 0x00FF;
5553 if (!(modeflag & HalfDCLK)) {
5554 tempcx = pVBInfo->VGAHDE;
5555 if (tempcx >= pVBInfo->HDE) {
5563 if (pVBInfo->VBInfo & SetCRT2ToTV) { /*301b*/
5564 if (pVBInfo->VGAHDE >= 1024) {
5566 if (pVBInfo->VGAHDE >= 1280) {
5568 tempbx = tempbx & 0xDFFF;
5573 if (!(tempbx & 0x2000)) {
5574 if (modeflag & HalfDCLK)
5575 tempcx = (tempcx & 0xFF00) | ((tempcx & 0x00FF) << 1);
5578 tempeax = pVBInfo->VGAHDE;
5579 tempebx = (tempcx & 0xFF00) >> 8;
5580 longtemp = tempeax * tempebx;
5581 tempecx = tempcx & 0x00FF;
5582 longtemp = longtemp / tempecx;
5587 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5588 | VB_XGI302LV | VB_XGI301C)) {
5589 tempecx = tempecx * 8;
5592 longtemp = longtemp * tempecx;
5593 tempecx = pVBInfo->HDE;
5594 temp2 = longtemp % tempecx;
5595 tempeax = longtemp / tempecx;
5599 tempax = (unsigned short) tempeax;
5602 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5603 | VB_XGI302LV | VB_XGI301C)) {
5604 tempcx = ((tempax & 0xFF00) >> 5) >> 8;
5609 tempbx = (unsigned short) (((tempeax & 0x0000FF00) & 0x1F00)
5610 | (tempbx & 0x00FF));
5611 tempax = (unsigned short) (((tempeax & 0x000000FF) << 8)
5612 | (tempax & 0x00FF));
5613 temp = (tempax & 0xFF00) >> 8;
5615 temp = (tempax & 0x00FF) >> 8;
5618 XGINew_SetReg1(pVBInfo->Part2Port, 0x44, temp);
5619 temp = (tempbx & 0xFF00) >> 8;
5620 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x45, ~0x03F, temp);
5621 temp = tempcx & 0x00FF;
5623 if (tempbx & 0x2000)
5626 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
5629 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x46, ~0x1F, temp);
5630 if (pVBInfo->TVInfo & SetPALTV) {
5638 temp = tempbx & 0x00FF;
5639 XGINew_SetReg1(pVBInfo->Part2Port, 0x4b, temp);
5640 temp = tempcx & 0x00FF;
5641 XGINew_SetReg1(pVBInfo->Part2Port, 0x4c, temp);
5643 temp = ((tempcx & 0xFF00) >> 8) & 0x03;
5645 temp |= ((tempbx & 0xFF00) >> 8) & 0x03;
5647 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
5650 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5653 if (pVBInfo->TVInfo & SetYPbPrMode750p)
5657 XGINew_SetReg1(pVBInfo->Part2Port, 0x4d, temp);
5658 temp = XGINew_GetReg1(pVBInfo->Part2Port, 0x43); /* 301b change */
5659 XGINew_SetReg1(pVBInfo->Part2Port, 0x43, (unsigned short) (temp - 3));
5661 if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))) {
5662 if (pVBInfo->TVInfo & NTSC1024x768) {
5663 TimingPoint = XGI_NTSC1024AdjTime;
5664 for (i = 0x1c, j = 0; i <= 0x30; i++, j++) {
5665 XGINew_SetReg1(pVBInfo->Part2Port, i,
5668 XGINew_SetReg1(pVBInfo->Part2Port, 0x43, 0x72);
5672 /* [ycchen] 01/14/03 Modify for 301C PALM Support */
5673 if (pVBInfo->VBType & VB_XGI301C) {
5674 if (pVBInfo->TVInfo & SetPALMTV)
5675 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x4E, ~0x08,
5676 0x08); /* PALM Mode */
5679 if (pVBInfo->TVInfo & SetPALMTV) {
5680 tempax = (unsigned char) XGINew_GetReg1(pVBInfo->Part2Port,
5683 XGINew_SetRegAND(pVBInfo->Part2Port, 0x01, tempax);
5685 /* if ( !( pVBInfo->VBType & VB_XGI301C ) ) */
5686 XGINew_SetRegAND(pVBInfo->Part2Port, 0x00, 0xEF);
5689 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5690 if (!(pVBInfo->VBInfo & SetInSlaveMode))
5691 XGINew_SetReg1(pVBInfo->Part2Port, 0x0B, 0x00);
5694 if (pVBInfo->VBInfo & SetCRT2ToTV)
5698 static void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
5699 struct xgi_hw_device_info *HwDeviceExtension,
5700 unsigned short RefreshRateTableIndex,
5701 struct vb_device_info *pVBInfo)
5703 unsigned short push1, push2, pushbx, tempax, tempbx, tempcx, temp,
5704 tempah, tempbh, tempch, resinfo, modeflag, CRT1Index;
5706 struct XGI_LCDDesStruct *LCDBDesPtr = NULL;
5708 if (ModeNo <= 0x13) {
5709 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
5710 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
5712 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
5713 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
5715 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
5716 CRT1Index &= IndexMask;
5719 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
5722 tempbx = pVBInfo->HDE; /* RHACTE=HDE-1 */
5724 if (XGI_IsLCDDualLink(pVBInfo))
5725 tempbx = tempbx >> 1;
5728 temp = tempbx & 0x00FF;
5729 XGINew_SetReg1(pVBInfo->Part2Port, 0x2C, temp);
5730 temp = (tempbx & 0xFF00) >> 8;
5732 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x2B, 0x0F, temp);
5735 if (pVBInfo->LCDResInfo == Panel1280x1024) {
5736 if (pVBInfo->ModeType == ModeEGA) {
5737 if (pVBInfo->VGAHDE >= 1024) {
5739 if (pVBInfo->LCDInfo & LCDVESATiming)
5745 XGINew_SetReg1(pVBInfo->Part2Port, 0x0B, temp);
5746 tempbx = pVBInfo->VDE; /* RTVACTEO=(VDE-1)&0xFF */
5749 temp = tempbx & 0x00FF;
5750 XGINew_SetReg1(pVBInfo->Part2Port, 0x03, temp);
5751 temp = ((tempbx & 0xFF00) >> 8) & 0x07;
5752 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x0C, ~0x07, temp);
5754 tempcx = pVBInfo->VT - 1;
5756 temp = tempcx & 0x00FF; /* RVTVT=VT-1 */
5757 XGINew_SetReg1(pVBInfo->Part2Port, 0x19, temp);
5758 temp = (tempcx & 0xFF00) >> 8;
5760 XGINew_SetReg1(pVBInfo->Part2Port, 0x1A, temp);
5761 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x09, 0xF0, 0x00);
5762 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x0A, 0xF0, 0x00);
5763 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x17, 0xFB, 0x00);
5764 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x18, 0xDF, 0x00);
5766 /* Customized LCDB Des no add */
5768 LCDBDesPtr = (struct XGI_LCDDesStruct *) XGI_GetLcdPtr(tempbx, ModeNo,
5769 ModeIdIndex, RefreshRateTableIndex, pVBInfo);
5770 tempah = pVBInfo->LCDResInfo;
5771 tempah &= PanelResInfo;
5773 if ((tempah == Panel1024x768) || (tempah == Panel1024x768x75)) {
5776 } else if ((tempah == Panel1280x1024) || (tempah == Panel1280x1024x75)) {
5779 } else if (tempah == Panel1400x1050) {
5787 if (pVBInfo->LCDInfo & EnableScalingLCD) {
5788 tempbx = pVBInfo->HDE;
5789 tempcx = pVBInfo->VDE;
5793 tempax = pVBInfo->VT;
5794 pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES;
5795 pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS;
5796 pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES;
5797 pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS;
5798 tempbx = pVBInfo->LCDVDES;
5801 if (tempcx >= tempax)
5802 tempcx -= tempax; /* lcdvdes */
5804 temp = tempbx & 0x00FF; /* RVEQ1EQ=lcdvdes */
5805 XGINew_SetReg1(pVBInfo->Part2Port, 0x05, temp);
5806 temp = tempcx & 0x00FF;
5807 XGINew_SetReg1(pVBInfo->Part2Port, 0x06, temp);
5808 tempch = ((tempcx & 0xFF00) >> 8) & 0x07;
5809 tempbh = ((tempbx & 0xFF00) >> 8) & 0x07;
5811 tempah = tempah << 3;
5813 XGINew_SetReg1(pVBInfo->Part2Port, 0x02, tempah);
5816 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
5818 tempax = pVBInfo->VT;
5819 tempbx = pVBInfo->LCDVRS;
5821 /* if (SetLCD_Info & EnableScalingLCD) */
5823 if (tempcx >= tempax)
5826 temp = tempbx & 0x00FF; /* RTVACTEE=lcdvrs */
5827 XGINew_SetReg1(pVBInfo->Part2Port, 0x04, temp);
5828 temp = (tempbx & 0xFF00) >> 8;
5830 temp |= (tempcx & 0x000F);
5831 XGINew_SetReg1(pVBInfo->Part2Port, 0x01, temp);
5833 tempax = pVBInfo->HT;
5834 tempbx = pVBInfo->LCDHDES;
5837 if (XGI_IsLCDDualLink(pVBInfo)) {
5838 tempax = tempax >> 1;
5839 tempbx = tempbx >> 1;
5840 tempcx = tempcx >> 1;
5843 if (pVBInfo->VBType & VB_XGI302LV)
5846 if (pVBInfo->VBType & VB_XGI301C) /* tap4 */
5851 if (tempcx >= tempax)
5854 temp = tempbx & 0x00FF;
5855 XGINew_SetReg1(pVBInfo->Part2Port, 0x1F, temp); /* RHBLKE=lcdhdes */
5856 temp = ((tempbx & 0xFF00) >> 8) << 4;
5857 XGINew_SetReg1(pVBInfo->Part2Port, 0x20, temp);
5858 temp = tempcx & 0x00FF;
5859 XGINew_SetReg1(pVBInfo->Part2Port, 0x23, temp); /* RHEQPLE=lcdhdee */
5860 temp = (tempcx & 0xFF00) >> 8;
5861 XGINew_SetReg1(pVBInfo->Part2Port, 0x25, temp);
5864 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
5866 tempax = pVBInfo->HT;
5867 tempbx = pVBInfo->LCDHRS;
5868 /* if ( SetLCD_Info & EnableScalingLCD) */
5869 if (XGI_IsLCDDualLink(pVBInfo)) {
5870 tempax = tempax >> 1;
5871 tempbx = tempbx >> 1;
5872 tempcx = tempcx >> 1;
5875 if (pVBInfo->VBType & VB_XGI302LV)
5880 if (tempcx >= tempax)
5883 temp = tempbx & 0x00FF; /* RHBURSTS=lcdhrs */
5884 XGINew_SetReg1(pVBInfo->Part2Port, 0x1C, temp);
5886 temp = (tempbx & 0xFF00) >> 8;
5888 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1D, ~0x0F0, temp);
5889 temp = tempcx & 0x00FF; /* RHSYEXP2S=lcdhre */
5890 XGINew_SetReg1(pVBInfo->Part2Port, 0x21, temp);
5892 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
5893 if (pVBInfo->VGAVDE == 525) {
5894 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
5895 | VB_XGI301LV | VB_XGI302LV
5901 XGINew_SetReg1(pVBInfo->Part2Port, 0x2f, temp);
5902 XGINew_SetReg1(pVBInfo->Part2Port, 0x30, 0xB3);
5905 if (pVBInfo->VGAVDE == 420) {
5906 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
5907 | VB_XGI301LV | VB_XGI302LV
5912 XGINew_SetReg1(pVBInfo->Part2Port, 0x2f, temp);
5917 /* --------------------------------------------------------------------- */
5918 /* Function : XGI_GetTap4Ptr */
5920 /* Output : di -> Tap4 Reg. Setting Pointer */
5922 /* --------------------------------------------------------------------- */
5923 static struct XGI301C_Tap4TimingStruct *XGI_GetTap4Ptr(unsigned short tempcx,
5924 struct vb_device_info *pVBInfo)
5926 unsigned short tempax, tempbx, i;
5928 struct XGI301C_Tap4TimingStruct *Tap4TimingPtr;
5931 tempax = pVBInfo->VGAHDE;
5932 tempbx = pVBInfo->HDE;
5934 tempax = pVBInfo->VGAVDE;
5935 tempbx = pVBInfo->VDE;
5938 if (tempax < tempbx)
5939 return &EnlargeTap4Timing[0];
5940 else if (tempax == tempbx)
5941 return &NoScaleTap4Timing[0]; /* 1:1 */
5943 Tap4TimingPtr = NTSCTap4Timing; /* NTSC */
5945 if (pVBInfo->TVInfo & SetPALTV)
5946 Tap4TimingPtr = PALTap4Timing;
5948 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
5949 if (pVBInfo->TVInfo & SetYPbPrMode525i)
5950 Tap4TimingPtr = YPbPr525iTap4Timing;
5951 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5952 Tap4TimingPtr = YPbPr525pTap4Timing;
5953 if (pVBInfo->TVInfo & SetYPbPrMode750p)
5954 Tap4TimingPtr = YPbPr750pTap4Timing;
5957 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5958 Tap4TimingPtr = HiTVTap4Timing;
5961 while (Tap4TimingPtr[i].DE != 0xFFFF) {
5962 if (Tap4TimingPtr[i].DE == tempax)
5966 return &Tap4TimingPtr[i];
5969 static void XGI_SetTap4Regs(struct vb_device_info *pVBInfo)
5971 unsigned short i, j;
5973 struct XGI301C_Tap4TimingStruct *Tap4TimingPtr;
5975 if (!(pVBInfo->VBType & VB_XGI301C))
5979 XGINew_SetRegAND(pVBInfo->Part2Port, 0x4E, 0xEB); /* Disable Tap4 */
5980 #else /* Tap4 Setting */
5982 Tap4TimingPtr = XGI_GetTap4Ptr(0, pVBInfo); /* Set Horizontal Scaling */
5983 for (i = 0x80, j = 0; i <= 0xBF; i++, j++)
5984 XGINew_SetReg1(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]);
5986 if ((pVBInfo->VBInfo & SetCRT2ToTV) && (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV))) {
5987 Tap4TimingPtr = XGI_GetTap4Ptr(1, pVBInfo); /* Set Vertical Scaling */
5988 for (i = 0xC0, j = 0; i < 0xFF; i++, j++)
5989 XGINew_SetReg1(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]);
5992 if ((pVBInfo->VBInfo & SetCRT2ToTV) && (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)))
5993 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x4E, ~0x14, 0x04); /* Enable V.Scaling */
5995 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x4E, ~0x14, 0x10); /* Enable H.Scaling */
5999 static void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex,
6000 struct vb_device_info *pVBInfo)
6003 unsigned char *tempdi;
6004 unsigned short modeflag;
6007 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
6009 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
6011 XGINew_SetReg1(pVBInfo->Part3Port, 0x00, 0x00);
6012 if (pVBInfo->TVInfo & SetPALTV) {
6013 XGINew_SetReg1(pVBInfo->Part3Port, 0x13, 0xFA);
6014 XGINew_SetReg1(pVBInfo->Part3Port, 0x14, 0xC8);
6016 XGINew_SetReg1(pVBInfo->Part3Port, 0x13, 0xF5);
6017 XGINew_SetReg1(pVBInfo->Part3Port, 0x14, 0xB7);
6020 if (!(pVBInfo->VBInfo & SetCRT2ToTV))
6023 if (pVBInfo->TVInfo & SetPALMTV) {
6024 XGINew_SetReg1(pVBInfo->Part3Port, 0x13, 0xFA);
6025 XGINew_SetReg1(pVBInfo->Part3Port, 0x14, 0xC8);
6026 XGINew_SetReg1(pVBInfo->Part3Port, 0x3D, 0xA8);
6029 if ((pVBInfo->VBInfo & SetCRT2ToHiVisionTV) || (pVBInfo->VBInfo
6030 & SetCRT2ToYPbPr)) {
6031 if (pVBInfo->TVInfo & SetYPbPrMode525i)
6034 tempdi = pVBInfo->HiTVGroup3Data;
6035 if (pVBInfo->SetFlag & TVSimuMode) {
6036 tempdi = pVBInfo->HiTVGroup3Simu;
6037 if (!(modeflag & Charx8Dot))
6038 tempdi = pVBInfo->HiTVGroup3Text;
6041 if (pVBInfo->TVInfo & SetYPbPrMode525p)
6042 tempdi = pVBInfo->Ren525pGroup3;
6044 if (pVBInfo->TVInfo & SetYPbPrMode750p)
6045 tempdi = pVBInfo->Ren750pGroup3;
6047 for (i = 0; i <= 0x3E; i++)
6048 XGINew_SetReg1(pVBInfo->Part3Port, i, tempdi[i]);
6050 if (pVBInfo->VBType & VB_XGI301C) { /* Marcovision */
6051 if (pVBInfo->TVInfo & SetYPbPrMode525p)
6052 XGINew_SetReg1(pVBInfo->Part3Port, 0x28, 0x3f);
6056 } /* {end of XGI_SetGroup3} */
6058 static void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex,
6059 unsigned short RefreshRateTableIndex,
6060 struct xgi_hw_device_info *HwDeviceExtension,
6061 struct vb_device_info *pVBInfo)
6063 unsigned short tempax, tempcx, tempbx, modeflag, temp, temp2;
6065 unsigned long tempebx, tempeax, templong;
6068 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
6070 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
6072 temp = pVBInfo->RVBHCFACT;
6073 XGINew_SetReg1(pVBInfo->Part4Port, 0x13, temp);
6075 tempbx = pVBInfo->RVBHCMAX;
6076 temp = tempbx & 0x00FF;
6077 XGINew_SetReg1(pVBInfo->Part4Port, 0x14, temp);
6078 temp2 = ((tempbx & 0xFF00) >> 8) << 7;
6079 tempcx = pVBInfo->VGAHT - 1;
6080 temp = tempcx & 0x00FF;
6081 XGINew_SetReg1(pVBInfo->Part4Port, 0x16, temp);
6083 temp = ((tempcx & 0xFF00) >> 8) << 3;
6086 tempcx = pVBInfo->VGAVT - 1;
6087 if (!(pVBInfo->VBInfo & SetCRT2ToTV))
6090 temp = tempcx & 0x00FF;
6091 XGINew_SetReg1(pVBInfo->Part4Port, 0x17, temp);
6092 temp = temp2 | ((tempcx & 0xFF00) >> 8);
6093 XGINew_SetReg1(pVBInfo->Part4Port, 0x15, temp);
6094 XGINew_SetRegOR(pVBInfo->Part4Port, 0x0D, 0x08);
6095 tempcx = pVBInfo->VBInfo;
6096 tempbx = pVBInfo->VGAHDE;
6098 if (modeflag & HalfDCLK)
6099 tempbx = tempbx >> 1;
6101 if (XGI_IsLCDDualLink(pVBInfo))
6102 tempbx = tempbx >> 1;
6104 if (tempcx & SetCRT2ToHiVisionTV) {
6110 } else if (tempcx & SetCRT2ToTV) {
6116 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
6123 if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)) {
6125 if (pVBInfo->VGAHDE == 1280)
6127 if (pVBInfo->VGAHDE == 1024)
6130 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x0E, ~0xEF, temp);
6132 tempebx = pVBInfo->VDE;
6134 if (tempcx & SetCRT2ToHiVisionTV) {
6135 if (!(temp & 0xE000))
6136 tempbx = tempbx >> 1;
6139 tempcx = pVBInfo->RVBHRS;
6140 temp = tempcx & 0x00FF;
6141 XGINew_SetReg1(pVBInfo->Part4Port, 0x18, temp);
6143 tempeax = pVBInfo->VGAVDE;
6146 if (tempeax <= tempebx) {
6147 tempcx = (tempcx & (~0x4000));
6148 tempeax = pVBInfo->VGAVDE;
6153 templong = (tempeax * 256 * 1024) % tempebx;
6154 tempeax = (tempeax * 256 * 1024) / tempebx;
6160 temp = (unsigned short) (tempebx & 0x000000FF);
6161 XGINew_SetReg1(pVBInfo->Part4Port, 0x1B, temp);
6163 temp = (unsigned short) ((tempebx & 0x0000FF00) >> 8);
6164 XGINew_SetReg1(pVBInfo->Part4Port, 0x1A, temp);
6165 tempbx = (unsigned short) (tempebx >> 16);
6166 temp = tempbx & 0x00FF;
6168 temp |= ((tempcx & 0xFF00) >> 8);
6169 XGINew_SetReg1(pVBInfo->Part4Port, 0x19, temp);
6172 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
6173 | VB_XGI302LV | VB_XGI301C)) {
6175 XGINew_SetReg1(pVBInfo->Part4Port, 0x1C, temp);
6176 tempax = pVBInfo->VGAHDE;
6177 if (modeflag & HalfDCLK)
6178 tempax = tempax >> 1;
6180 if (XGI_IsLCDDualLink(pVBInfo))
6181 tempax = tempax >> 1;
6183 /* if((pVBInfo->VBInfo&(SetCRT2ToLCD))||((pVBInfo->TVInfo&SetYPbPrMode525p)||(pVBInfo->TVInfo&SetYPbPrMode750p))) { */
6184 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
6188 if (pVBInfo->VGAHDE > 800) {
6189 if (pVBInfo->VGAHDE == 1024)
6190 tempax = (tempax * 25 / 32) - 1;
6192 tempax = (tempax * 20 / 32) - 1;
6198 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVisionTV)) {
6199 if (pVBInfo->VBType & VB_XGI301LV) {
6200 if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i))) {
6201 if (pVBInfo->VGAHDE > 800) {
6202 if (pVBInfo->VGAHDE == 1024)
6203 tempax = (tempax * 25 / 32) - 1;
6205 tempax = (tempax * 20 / 32) - 1;
6209 if (pVBInfo->VGAHDE > 800) {
6210 if (pVBInfo->VGAHDE == 1024)
6211 tempax = (tempax * 25 / 32) - 1;
6213 tempax = (tempax * 20 / 32) - 1;
6219 temp = (tempax & 0xFF00) >> 8;
6220 temp = ((temp & 0x0003) << 4);
6221 XGINew_SetReg1(pVBInfo->Part4Port, 0x1E, temp);
6222 temp = (tempax & 0x00FF);
6223 XGINew_SetReg1(pVBInfo->Part4Port, 0x1D, temp);
6225 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVisionTV)) {
6226 if (pVBInfo->VGAHDE > 800)
6227 XGINew_SetRegOR(pVBInfo->Part4Port, 0x1E, 0x08);
6232 if (pVBInfo->VBInfo & SetCRT2ToTV) {
6233 if (!(pVBInfo->TVInfo & (NTSC1024x768
6234 | SetYPbPrMode525p | SetYPbPrMode750p
6235 | SetYPbPrMode1080i))) {
6237 if ((pVBInfo->VBInfo & SetInSlaveMode)
6238 && (!(pVBInfo->TVInfo
6244 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x1F, 0x00C0, temp);
6245 tempbx = pVBInfo->HT;
6246 if (XGI_IsLCDDualLink(pVBInfo))
6247 tempbx = tempbx >> 1;
6248 tempbx = (tempbx >> 1) - 2;
6249 temp = ((tempbx & 0x0700) >> 8) << 3;
6250 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x21, 0x00C0, temp);
6251 temp = tempbx & 0x00FF;
6252 XGINew_SetReg1(pVBInfo->Part4Port, 0x22, temp);
6256 if (pVBInfo->ISXPDOS == 0)
6257 XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex,
6261 static void XGINew_EnableCRT2(struct vb_device_info *pVBInfo)
6263 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x1E, 0xFF, 0x20);
6266 static void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex,
6267 struct vb_device_info *pVBInfo)
6269 unsigned short Pindex, Pdata;
6271 Pindex = pVBInfo->Part5Port;
6272 Pdata = pVBInfo->Part5Port + 1;
6273 if (pVBInfo->ModeType == ModeVGA) {
6274 if (!(pVBInfo->VBInfo & (SetInSlaveMode | LoadDACFlag
6275 | CRT2DisplayFlag))) {
6276 XGINew_EnableCRT2(pVBInfo);
6277 /* LoadDAC2(pVBInfo->Part5Port, ModeNo, ModeIdIndex); */
6283 /* --------------------------------------------------------------------- */
6284 /* Function : XGI_BacklightByDrv */
6286 /* Output : 1 -> Skip backlight control */
6288 /* --------------------------------------------------------------------- */
6289 static unsigned char XGI_BacklightByDrv(struct vb_device_info *pVBInfo)
6291 unsigned char tempah;
6293 tempah = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x3A);
6294 if (tempah & BacklightControlBit)
6300 /* --------------------------------------------------------------------- */
6301 /* Function : XGI_FirePWDDisable */
6304 /* Description : Turn off VDD & Backlight : Fire disable procedure */
6305 /* --------------------------------------------------------------------- */
6307 void XGI_FirePWDDisable(struct vb_device_info *pVBInfo)
6309 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x26, 0x00, 0xFC);
6313 /* --------------------------------------------------------------------- */
6314 /* Function : XGI_FirePWDEnable */
6317 /* Description : Turn on VDD & Backlight : Fire enable procedure */
6318 /* --------------------------------------------------------------------- */
6319 static void XGI_FirePWDEnable(struct vb_device_info *pVBInfo)
6321 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x26, 0x03, 0xFC);
6324 static void XGI_EnableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension,
6325 struct vb_device_info *pVBInfo)
6327 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x63, 0xBF, 0x40);
6330 static void XGI_DisableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension,
6331 struct vb_device_info *pVBInfo)
6334 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x63, 0xBF, 0x00);
6337 /* --------------------------------------------------------------------- */
6338 /* Function : XGI_SetPanelDelay */
6342 /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
6343 /* : bl : 2 ; T2 : the duration signal on and Vdd on */
6344 /* : bl : 3 ; T3 : the duration between CPL off and signal off */
6345 /* : bl : 4 ; T4 : the duration signal off and Vdd off */
6346 /* --------------------------------------------------------------------- */
6347 static void XGI_SetPanelDelay(unsigned short tempbl, struct vb_device_info *pVBInfo)
6349 unsigned short index;
6351 index = XGI_GetLCDCapPtr(pVBInfo);
6354 mdelay(pVBInfo->LCDCapList[index].PSC_S1);
6357 mdelay(pVBInfo->LCDCapList[index].PSC_S2);
6360 mdelay(pVBInfo->LCDCapList[index].PSC_S3);
6363 mdelay(pVBInfo->LCDCapList[index].PSC_S4);
6366 /* --------------------------------------------------------------------- */
6367 /* Function : XGI_SetPanelPower */
6371 /* I/O : ah = 0011b = 03h ; Backlight on, Power on */
6372 /* = 0111b = 07h ; Backlight on, Power off */
6373 /* = 1011b = 0Bh ; Backlight off, Power on */
6374 /* = 1111b = 0Fh ; Backlight off, Power off */
6375 /* --------------------------------------------------------------------- */
6376 static void XGI_SetPanelPower(unsigned short tempah, unsigned short tempbl,
6377 struct vb_device_info *pVBInfo)
6379 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C))
6380 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x26, tempbl, tempah);
6382 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x11, tempbl, tempah);
6385 /*----------------------------------------------------------------------------*/
6387 /* bl[5] : 1;LVDS signal on */
6388 /* bl[1] : 1;LVDS backlight on */
6389 /* bl[0] : 1:LVDS VDD on */
6390 /* bh: 100000b : clear bit 5, to set bit5 */
6391 /* 000010b : clear bit 1, to set bit1 */
6392 /* 000001b : clear bit 0, to set bit0 */
6393 /*----------------------------------------------------------------------------*/
6394 void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl,
6395 struct vb_device_info *pVBInfo)
6397 unsigned char CR4A, temp;
6399 CR4A = XGINew_GetReg1(pVBInfo->P3d4, 0x4A);
6402 XGINew_SetRegAND(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */
6404 if (tempbh & 0x20) {
6405 temp = (tempbl >> 4) & 0x02;
6407 XGINew_SetRegANDOR(pVBInfo->P3d4, 0xB4, ~0x02, temp); /* CR B4[1] */
6411 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x48);
6413 temp = XG21GPIODataTransfer(temp);
6416 XGINew_SetReg1(pVBInfo->P3d4, 0x48, temp);
6419 void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl,
6420 struct vb_device_info *pVBInfo)
6422 unsigned char CR4A, temp;
6423 unsigned short tempbh0, tempbl0;
6432 if (tempbh & 0x20) {
6433 temp = (tempbl >> 4) & 0x02;
6435 XGINew_SetRegANDOR(pVBInfo->P3d4, 0xB4, ~0x02, temp); /* CR B4[1] */
6438 XGINew_SetRegANDOR(pVBInfo->P3d4, 0xB4, ~tempbh0, tempbl0);
6440 CR4A = XGINew_GetReg1(pVBInfo->P3d4, 0x4A);
6444 tempbl <<= 2; /* GPIOC,GPIOD */
6445 XGINew_SetRegAND(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */
6446 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x48, ~tempbh, tempbl);
6449 /* --------------------------------------------------------------------- */
6450 unsigned short XGI_GetLVDSOEMTableIndex(struct vb_device_info *pVBInfo)
6452 unsigned short index;
6454 index = XGINew_GetReg1(pVBInfo->P3d4, 0x36);
6455 if (index < sizeof(XGI21_LCDCapList)
6456 / sizeof(struct XGI21_LVDSCapStruct))
6461 /* --------------------------------------------------------------------- */
6462 /* Function : XGI_XG21SetPanelDelay */
6466 /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
6467 /* : bl : 2 ; T2 : the duration signal on and Vdd on */
6468 /* : bl : 3 ; T3 : the duration between CPL off and signal off */
6469 /* : bl : 4 ; T4 : the duration signal off and Vdd off */
6470 /* --------------------------------------------------------------------- */
6471 void XGI_XG21SetPanelDelay(unsigned short tempbl,
6472 struct vb_device_info *pVBInfo)
6474 unsigned short index;
6476 index = XGI_GetLVDSOEMTableIndex(pVBInfo);
6478 mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S1);
6481 mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S2);
6484 mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S3);
6487 mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S4);
6490 unsigned char XGI_XG21CheckLVDSMode(unsigned short ModeNo,
6491 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
6493 unsigned short xres, yres, colordepth, modeflag, resindex,
6496 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
6497 if (ModeNo <= 0x13) {
6498 xres = pVBInfo->StResInfo[resindex].HTotal;
6499 yres = pVBInfo->StResInfo[resindex].VTotal;
6500 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
6502 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
6503 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
6504 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */
6507 if (!(modeflag & Charx8Dot)) {
6512 if (ModeNo > 0x13) {
6513 if ((ModeNo > 0x13) && (modeflag & HalfDCLK))
6516 if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
6521 lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo);
6522 if (xres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE))
6525 if (yres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE))
6528 if (ModeNo > 0x13) {
6530 != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE))
6532 != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE))) {
6533 colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex,
6543 void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo)
6547 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37); /* D[0] 1: 18bit */
6548 temp = (temp & 1) << 6;
6549 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x06, ~0x40, temp); /* SR06[6] 18bit Dither */
6550 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */
6554 void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo)
6558 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37); /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */
6559 temp = (temp & 3) << 6;
6560 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x06, ~0xc0, temp & 0x80); /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */
6561 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */
6565 static void XGI_SetXG21LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex,
6566 struct vb_device_info *pVBInfo)
6568 unsigned char temp, Miscdata;
6569 unsigned short xres, yres, modeflag, resindex, lvdstableindex;
6570 unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE;
6571 unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE;
6572 unsigned short value;
6574 lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo);
6576 temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability
6577 & (LCDPolarity << 8)) >> 8);
6578 temp &= LCDPolarity;
6579 Miscdata = (unsigned char) XGINew_GetReg2(pVBInfo->P3cc);
6581 XGINew_SetReg3(pVBInfo->P3c2, (Miscdata & 0x3F) | temp);
6583 temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability
6585 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80); /* SR35[7] FP VSync polarity */
6586 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); /* SR30[5] FP HSync polarity */
6588 XGI_SetXG21FPBits(pVBInfo);
6589 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
6590 if (ModeNo <= 0x13) {
6591 xres = pVBInfo->StResInfo[resindex].HTotal;
6592 yres = pVBInfo->StResInfo[resindex].VTotal;
6593 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
6595 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
6596 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
6597 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */
6600 if (!(modeflag & Charx8Dot))
6601 xres = xres * 8 / 9;
6603 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
6605 LVDSHBS = xres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE
6607 if ((ModeNo <= 0x13) && (modeflag & HalfDCLK))
6608 LVDSHBS -= xres / 4;
6610 if (LVDSHBS > LVDSHT)
6613 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP;
6614 if (LVDSHRS > LVDSHT)
6617 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC;
6618 if (LVDSHRE > LVDSHT)
6621 LVDSHBE = LVDSHBS + LVDSHT
6622 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE;
6624 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
6626 LVDSVBS = yres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE
6628 if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
6629 LVDSVBS += yres / 2;
6631 if (LVDSVBS > LVDSVT)
6634 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP;
6635 if (LVDSVRS > LVDSVT)
6638 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC;
6639 if (LVDSVRE > LVDSVT)
6642 LVDSVBE = LVDSVBS + LVDSVT
6643 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE;
6645 temp = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11);
6646 XGINew_SetReg1(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */
6648 if (!(modeflag & Charx8Dot))
6649 XGINew_SetRegOR(pVBInfo->P3c4, 0x1, 0x1);
6651 /* HT SR0B[1:0] CR00 */
6652 value = (LVDSHT >> 3) - 5;
6653 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8);
6654 XGINew_SetReg1(pVBInfo->P3d4, 0x0, (value & 0xFF));
6656 /* HBS SR0B[5:4] CR02 */
6657 value = (LVDSHBS >> 3) - 1;
6658 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4);
6659 XGINew_SetReg1(pVBInfo->P3d4, 0x2, (value & 0xFF));
6661 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
6662 value = (LVDSHBE >> 3) - 1;
6663 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6);
6664 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2);
6665 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F);
6667 /* HRS SR0B[7:6] CR04 */
6668 value = (LVDSHRS >> 3) + 2;
6669 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2);
6670 XGINew_SetReg1(pVBInfo->P3d4, 0x4, (value & 0xFF));
6672 /* Panel HRS SR2F[1:0] SR2E[7:0] */
6674 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8);
6675 XGINew_SetReg1(pVBInfo->P3c4, 0x2E, (value & 0xFF));
6677 /* HRE SR0C[2] CR05[4:0] */
6678 value = (LVDSHRE >> 3) + 2;
6679 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3);
6680 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F);
6682 /* Panel HRE SR2F[7:2] */
6684 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2);
6686 /* VT SR0A[0] CR07[5][0] CR06 */
6688 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10);
6689 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4);
6690 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8);
6691 XGINew_SetReg1(pVBInfo->P3d4, 0x06, (value & 0xFF));
6693 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
6694 value = LVDSVBS - 1;
6695 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8);
6696 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4);
6697 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5);
6698 XGINew_SetReg1(pVBInfo->P3d4, 0x15, (value & 0xFF));
6700 /* VBE SR0A[4] CR16 */
6701 value = LVDSVBE - 1;
6702 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4);
6703 XGINew_SetReg1(pVBInfo->P3d4, 0x16, (value & 0xFF));
6705 /* VRS SR0A[3] CR7[7][2] CR10 */
6706 value = LVDSVRS - 1;
6707 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7);
6708 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2);
6709 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6);
6710 XGINew_SetReg1(pVBInfo->P3d4, 0x10, (value & 0xFF));
6712 /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */
6713 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x3F, ~0x03, (value & 0x600) >> 9);
6714 XGINew_SetReg1(pVBInfo->P3c4, 0x34, (value >> 1) & 0xFF);
6715 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x33, ~0x01, value & 0x01);
6717 /* VRE SR0A[5] CR11[3:0] */
6718 value = LVDSVRE - 1;
6719 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1);
6720 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F);
6722 /* Panel VRE SR3F[7:2] *//* SR3F[7] has to be 0, h/w bug */
6723 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x3F, ~0xFC, (value << 2) & 0x7C);
6725 for (temp = 0, value = 0; temp < 3; temp++) {
6727 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x31, ~0x30, value);
6728 XGINew_SetReg1(pVBInfo->P3c4,
6730 pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1);
6731 XGINew_SetReg1(pVBInfo->P3c4,
6733 pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2);
6737 if (!(modeflag & Charx8Dot)) {
6738 XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */
6739 XGINew_SetReg3(pVBInfo->P3c0, 0x13); /* set index */
6740 XGINew_SetReg3(pVBInfo->P3c0, 0x00); /* set data, panning = 0, shift left 1 dot*/
6742 XGINew_GetReg2(pVBInfo->P3da); /* Enable Attribute */
6743 XGINew_SetReg3(pVBInfo->P3c0, 0x20);
6745 XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */
6750 /* no shadow case */
6751 static void XGI_SetXG27LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex,
6752 struct vb_device_info *pVBInfo)
6754 unsigned char temp, Miscdata;
6755 unsigned short xres, yres, modeflag, resindex, lvdstableindex;
6756 unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE;
6757 unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE;
6758 unsigned short value;
6760 lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo);
6761 temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability
6762 & (LCDPolarity << 8)) >> 8);
6763 temp &= LCDPolarity;
6764 Miscdata = (unsigned char) XGINew_GetReg2(pVBInfo->P3cc);
6766 XGINew_SetReg3(pVBInfo->P3c2, (Miscdata & 0x3F) | temp);
6768 temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability
6770 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80); /* SR35[7] FP VSync polarity */
6771 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); /* SR30[5] FP HSync polarity */
6773 XGI_SetXG27FPBits(pVBInfo);
6774 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
6775 if (ModeNo <= 0x13) {
6776 xres = pVBInfo->StResInfo[resindex].HTotal;
6777 yres = pVBInfo->StResInfo[resindex].VTotal;
6778 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
6780 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
6781 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
6782 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */
6785 if (!(modeflag & Charx8Dot))
6786 xres = xres * 8 / 9;
6788 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
6790 LVDSHBS = xres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE
6792 if ((ModeNo <= 0x13) && (modeflag & HalfDCLK))
6793 LVDSHBS -= xres / 4;
6795 if (LVDSHBS > LVDSHT)
6798 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP;
6799 if (LVDSHRS > LVDSHT)
6802 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC;
6803 if (LVDSHRE > LVDSHT)
6806 LVDSHBE = LVDSHBS + LVDSHT
6807 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE;
6809 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
6811 LVDSVBS = yres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE
6813 if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
6814 LVDSVBS += yres / 2;
6816 if (LVDSVBS > LVDSVT)
6819 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP;
6820 if (LVDSVRS > LVDSVT)
6823 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC;
6824 if (LVDSVRE > LVDSVT)
6827 LVDSVBE = LVDSVBS + LVDSVT
6828 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE;
6830 temp = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x11);
6831 XGINew_SetReg1(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */
6833 if (!(modeflag & Charx8Dot))
6834 XGINew_SetRegOR(pVBInfo->P3c4, 0x1, 0x1);
6836 /* HT SR0B[1:0] CR00 */
6837 value = (LVDSHT >> 3) - 5;
6838 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8);
6839 XGINew_SetReg1(pVBInfo->P3d4, 0x0, (value & 0xFF));
6841 /* HBS SR0B[5:4] CR02 */
6842 value = (LVDSHBS >> 3) - 1;
6843 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4);
6844 XGINew_SetReg1(pVBInfo->P3d4, 0x2, (value & 0xFF));
6846 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
6847 value = (LVDSHBE >> 3) - 1;
6848 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6);
6849 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2);
6850 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F);
6852 /* HRS SR0B[7:6] CR04 */
6853 value = (LVDSHRS >> 3) + 2;
6854 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2);
6855 XGINew_SetReg1(pVBInfo->P3d4, 0x4, (value & 0xFF));
6857 /* Panel HRS SR2F[1:0] SR2E[7:0] */
6859 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8);
6860 XGINew_SetReg1(pVBInfo->P3c4, 0x2E, (value & 0xFF));
6862 /* HRE SR0C[2] CR05[4:0] */
6863 value = (LVDSHRE >> 3) + 2;
6864 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3);
6865 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F);
6867 /* Panel HRE SR2F[7:2] */
6869 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2);
6871 /* VT SR0A[0] CR07[5][0] CR06 */
6873 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10);
6874 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4);
6875 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8);
6876 XGINew_SetReg1(pVBInfo->P3d4, 0x06, (value & 0xFF));
6878 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
6879 value = LVDSVBS - 1;
6880 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8);
6881 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4);
6882 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5);
6883 XGINew_SetReg1(pVBInfo->P3d4, 0x15, (value & 0xFF));
6885 /* VBE SR0A[4] CR16 */
6886 value = LVDSVBE - 1;
6887 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4);
6888 XGINew_SetReg1(pVBInfo->P3d4, 0x16, (value & 0xFF));
6890 /* VRS SR0A[3] CR7[7][2] CR10 */
6891 value = LVDSVRS - 1;
6892 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7);
6893 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2);
6894 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6);
6895 XGINew_SetReg1(pVBInfo->P3d4, 0x10, (value & 0xFF));
6897 /* Panel VRS SR35[2:0] SR34[7:0] */
6898 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x35, ~0x07, (value & 0x700) >> 8);
6899 XGINew_SetReg1(pVBInfo->P3c4, 0x34, value & 0xFF);
6901 /* VRE SR0A[5] CR11[3:0] */
6902 value = LVDSVRE - 1;
6903 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1);
6904 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F);
6906 /* Panel VRE SR3F[7:2] */
6907 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x3F, ~0xFC, (value << 2) & 0xFC);
6909 for (temp = 0, value = 0; temp < 3; temp++) {
6911 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x31, ~0x30, value);
6912 XGINew_SetReg1(pVBInfo->P3c4,
6914 pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1);
6915 XGINew_SetReg1(pVBInfo->P3c4,
6917 pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2);
6921 if (!(modeflag & Charx8Dot)) {
6922 XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */
6923 XGINew_SetReg3(pVBInfo->P3c0, 0x13); /* set index */
6924 XGINew_SetReg3(pVBInfo->P3c0, 0x00); /* set data, panning = 0, shift left 1 dot*/
6926 XGINew_GetReg2(pVBInfo->P3da); /* Enable Attribute */
6927 XGINew_SetReg3(pVBInfo->P3c0, 0x20);
6929 XGINew_GetReg2(pVBInfo->P3da); /* reset 3da */
6934 /* --------------------------------------------------------------------- */
6935 /* Function : XGI_IsLCDON */
6937 /* Output : 0 : Skip PSC Control */
6938 /* 1: Disable PSC */
6940 /* --------------------------------------------------------------------- */
6941 static unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo)
6943 unsigned short tempax;
6945 tempax = pVBInfo->VBInfo;
6946 if (tempax & SetCRT2ToDualEdge)
6948 else if (tempax & (DisableCRT2Display | SwitchToCRT2 | SetSimuScanMode))
6954 static void XGI_EnablePWD(struct vb_device_info *pVBInfo)
6956 unsigned short index, temp;
6958 index = XGI_GetLCDCapPtr(pVBInfo);
6959 temp = pVBInfo->LCDCapList[index].PWD_2B;
6960 XGINew_SetReg1(pVBInfo->Part4Port, 0x2B, temp);
6961 XGINew_SetReg1(pVBInfo->Part4Port, 0x2C,
6962 pVBInfo->LCDCapList[index].PWD_2C);
6963 XGINew_SetReg1(pVBInfo->Part4Port, 0x2D,
6964 pVBInfo->LCDCapList[index].PWD_2D);
6965 XGINew_SetReg1(pVBInfo->Part4Port, 0x2E,
6966 pVBInfo->LCDCapList[index].PWD_2E);
6967 XGINew_SetReg1(pVBInfo->Part4Port, 0x2F,
6968 pVBInfo->LCDCapList[index].PWD_2F);
6969 XGINew_SetRegOR(pVBInfo->Part4Port, 0x27, 0x80); /* enable PWD */
6972 static void XGI_DisablePWD(struct vb_device_info *pVBInfo)
6974 XGINew_SetRegAND(pVBInfo->Part4Port, 0x27, 0x7F); /* disable PWD */
6977 /* --------------------------------------------------------------------- */
6978 /* Function : XGI_DisableChISLCD */
6980 /* Output : 0 -> Not LCD Mode */
6982 /* --------------------------------------------------------------------- */
6983 static unsigned char XGI_DisableChISLCD(struct vb_device_info *pVBInfo)
6985 unsigned short tempbx, tempah;
6987 tempbx = pVBInfo->SetFlag & (DisableChA | DisableChB);
6988 tempah = ~((unsigned short) XGINew_GetReg1(pVBInfo->Part1Port, 0x2E));
6990 if (tempbx & (EnableChA | DisableChA)) {
6991 if (!(tempah & 0x08)) /* Chk LCDA Mode */
6995 if (!(tempbx & (EnableChB | DisableChB)))
6998 if (tempah & 0x01) /* Chk LCDB Mode */
7004 /* --------------------------------------------------------------------- */
7005 /* Function : XGI_EnableChISLCD */
7007 /* Output : 0 -> Not LCD mode */
7009 /* --------------------------------------------------------------------- */
7010 static unsigned char XGI_EnableChISLCD(struct vb_device_info *pVBInfo)
7012 unsigned short tempbx, tempah;
7014 tempbx = pVBInfo->SetFlag & (EnableChA | EnableChB);
7015 tempah = ~((unsigned short) XGINew_GetReg1(pVBInfo->Part1Port, 0x2E));
7017 if (tempbx & (EnableChA | DisableChA)) {
7018 if (!(tempah & 0x08)) /* Chk LCDA Mode */
7022 if (!(tempbx & (EnableChB | DisableChB)))
7025 if (tempah & 0x01) /* Chk LCDB Mode */
7031 void XGI_DisableBridge(struct xgi_hw_device_info *HwDeviceExtension,
7032 struct vb_device_info *pVBInfo)
7034 unsigned short tempax, tempbx, tempah = 0, tempbl = 0;
7036 if (pVBInfo->SetFlag == Win9xDOSMode)
7039 if (HwDeviceExtension->jChipType < XG40) {
7040 if ((!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)))
7041 || (XGI_DisableChISLCD(pVBInfo))) {
7042 if (!XGI_IsLCDON(pVBInfo)) {
7043 if (pVBInfo->LCDInfo & SetPWDEnable)
7044 XGI_EnablePWD(pVBInfo);
7046 pVBInfo->LCDInfo &= ~SetPWDEnable;
7047 XGI_DisablePWD(pVBInfo);
7048 if (pVBInfo->VBType & (VB_XGI301LV
7051 tempbx = 0xFE; /* not 01h */
7054 tempbx = 0xF7; /* not 08h */
7057 XGI_SetPanelPower(tempax, tempbx,
7059 XGI_SetPanelDelay(3, pVBInfo);
7061 } /* end if (!XGI_IsLCDON(pVBInfo)) */
7067 if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2toLCDA)) || (XGI_DisableChISLCD(pVBInfo))) {
7068 if (!XGI_IsLCDON(pVBInfo)) {
7070 tempbx = XGINew_GetCH7005(0x61);
7071 if (tempbx < 0x01) // first time we power up
7072 XGINew_SetCH7005(0x0066); // and disable power sequence
7074 XGINew_SetCH7005(0x5f66); // leave VDD on - disable power
7081 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7082 | VB_XGI302LV | VB_XGI301C)) {
7084 if (!(pVBInfo->VBInfo & (DisableCRT2Display | SetSimuScanMode))) {
7085 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
7086 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
7087 tempah = 0x7F; /* Disable Channel A */
7088 if (!(pVBInfo->VBInfo & SetCRT2ToLCDA))
7089 tempah = 0xBF; /* Disable Channel B */
7091 if (pVBInfo->SetFlag & DisableChB)
7092 tempah &= 0xBF; /* force to disable Cahnnel */
7094 if (pVBInfo->SetFlag & DisableChA)
7095 tempah &= 0x7F; /* Force to disable Channel B */
7100 XGINew_SetRegAND(pVBInfo->Part4Port, 0x1F, tempah); /* disable part4_1f */
7102 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
7103 if (((pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)))
7104 || (XGI_DisableChISLCD(pVBInfo))
7105 || (XGI_IsLCDON(pVBInfo)))
7106 XGINew_SetRegOR(pVBInfo->Part4Port, 0x30, 0x80); /* LVDS Driver power down */
7109 if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo
7110 & (DisableCRT2Display | SetCRT2ToLCDA
7111 | SetSimuScanMode))) {
7112 if (pVBInfo->SetFlag & GatingCRT)
7113 XGI_EnableGatingCRT(HwDeviceExtension, pVBInfo);
7114 XGI_DisplayOff(HwDeviceExtension, pVBInfo);
7117 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
7118 if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo
7120 XGINew_SetRegAND(pVBInfo->Part1Port, 0x1e, 0xdf); /* Power down */
7123 XGINew_SetRegAND(pVBInfo->P3c4, 0x32, 0xdf); /* disable TV as primary VGA swap */
7125 if ((pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToDualEdge)))
7126 XGINew_SetRegAND(pVBInfo->Part2Port, 0x00, 0xdf);
7128 if ((pVBInfo->SetFlag & DisableChB) || (pVBInfo->VBInfo
7129 & (DisableCRT2Display | SetSimuScanMode))
7130 || ((!(pVBInfo->VBInfo & SetCRT2ToLCDA))
7135 XGINew_SetRegOR(pVBInfo->Part1Port, 0x00, 0x80); /* BScreenOff=1 */
7137 if ((pVBInfo->SetFlag & DisableChB) || (pVBInfo->VBInfo
7138 & (DisableCRT2Display | SetSimuScanMode))
7139 || (!(pVBInfo->VBInfo & SetCRT2ToLCDA))
7140 || (pVBInfo->VBInfo & (SetCRT2ToRAMDAC
7141 | SetCRT2ToLCD | SetCRT2ToTV))) {
7142 tempah = XGINew_GetReg1(pVBInfo->Part1Port, 0x00); /* save Part1 index 0 */
7143 XGINew_SetRegOR(pVBInfo->Part1Port, 0x00, 0x10); /* BTDAC = 1, avoid VB reset */
7144 XGINew_SetRegAND(pVBInfo->Part1Port, 0x1E, 0xDF); /* disable CRT2 */
7145 XGINew_SetReg1(pVBInfo->Part1Port, 0x00, tempah); /* restore Part1 index 0 */
7147 } else { /* {301} */
7148 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) {
7149 XGINew_SetRegOR(pVBInfo->Part1Port, 0x00, 0x80); /* BScreenOff=1 */
7150 XGINew_SetRegAND(pVBInfo->Part1Port, 0x1E, 0xDF); /* Disable CRT2 */
7151 XGINew_SetRegAND(pVBInfo->P3c4, 0x32, 0xDF); /* Disable TV asPrimary VGA swap */
7154 if (pVBInfo->VBInfo & (DisableCRT2Display | SetCRT2ToLCDA
7156 XGI_DisplayOff(HwDeviceExtension, pVBInfo);
7159 if (HwDeviceExtension->jChipType < XG40) {
7160 if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))
7161 || (XGI_DisableChISLCD(pVBInfo))
7162 || (XGI_IsLCDON(pVBInfo))) {
7163 if (pVBInfo->LCDInfo & SetPWDEnable) {
7164 if (pVBInfo->LCDInfo & SetPWDEnable)
7165 XGI_BacklightByDrv(pVBInfo);
7167 XGI_SetPanelDelay(4, pVBInfo);
7168 if (pVBInfo->VBType & VB_XGI301LV) {
7177 XGI_SetPanelPower(tempah, tempbl, pVBInfo);
7182 /* --------------------------------------------------------------------- */
7183 /* Function : XGI_GetTVPtrIndex */
7186 /* Description : bx 0 : ExtNTSC */
7198 /* --------------------------------------------------------------------- */
7199 static unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo)
7201 unsigned short tempbx = 0;
7203 if (pVBInfo->TVInfo & SetPALTV)
7205 if (pVBInfo->TVInfo & SetYPbPrMode1080i)
7207 if (pVBInfo->TVInfo & SetYPbPrMode525i)
7209 if (pVBInfo->TVInfo & SetYPbPrMode525p)
7211 if (pVBInfo->TVInfo & SetYPbPrMode750p)
7213 if (pVBInfo->TVInfo & TVSimuMode)
7219 /* --------------------------------------------------------------------- */
7220 /* Function : XGI_GetTVPtrIndex2 */
7222 /* Output : bx 0 : NTSC */
7226 /* 4 : NTSC1024x768 */
7227 /* 5 : PAL-M 1024x768 */
7229 /* cl 0 : YFilter1 */
7232 /* 1 : 301B/302B/301LV/302LV */
7234 /* --------------------------------------------------------------------- */
7235 static void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char *tempcl,
7236 unsigned char *tempch, struct vb_device_info *pVBInfo)
7242 if (pVBInfo->TVInfo & SetPALTV)
7245 if (pVBInfo->TVInfo & SetPALMTV)
7248 if (pVBInfo->TVInfo & SetPALNTV)
7251 if (pVBInfo->TVInfo & NTSC1024x768) {
7253 if (pVBInfo->TVInfo & SetPALMTV)
7257 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7258 | VB_XGI302LV | VB_XGI301C)) {
7259 if ((!(pVBInfo->VBInfo & SetInSlaveMode)) || (pVBInfo->TVInfo
7266 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7267 | VB_XGI302LV | VB_XGI301C))
7271 static void XGI_SetDelayComp(struct vb_device_info *pVBInfo)
7273 unsigned short index;
7275 unsigned char tempah, tempbl, tempbh;
7277 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7278 | VB_XGI302LV | VB_XGI301C)) {
7279 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA
7280 | SetCRT2ToTV | SetCRT2ToRAMDAC)) {
7284 index = XGI_GetTVPtrIndex(pVBInfo); /* Get TV Delay */
7285 tempbl = pVBInfo->XGI_TVDelayList[index];
7287 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
7288 | VB_XGI301LV | VB_XGI302LV
7290 tempbl = pVBInfo->XGI_TVDelayList2[index];
7292 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
7293 tempbl = tempbl >> 4;
7295 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC)
7296 tempbl = CRT2Delay1; // Get CRT2 Delay
7297 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C))
7298 tempbl = CRT2Delay2;
7300 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
7301 index = XGI_GetLCDCapPtr(pVBInfo); /* Get LCD Delay */
7302 tempbh = pVBInfo->LCDCapList[index].LCD_DelayCompensation;
7304 if (!(pVBInfo->VBInfo & SetCRT2ToLCDA))
7310 tempah = XGINew_GetReg1(pVBInfo->Part1Port, 0x2D);
7312 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD
7313 | SetCRT2ToTV)) { /* Channel B */
7318 if (pVBInfo->VBInfo & SetCRT2ToLCDA) { /* Channel A */
7322 XGINew_SetReg1(pVBInfo->Part1Port, 0x2D, tempah);
7324 } else if (pVBInfo->IF_DEF_LVDS == 1) {
7327 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
7329 = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(
7330 pVBInfo)].LCD_DelayCompensation; /* / Get LCD Delay */
7332 tempah = tempah << 4;
7333 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2D, 0x0f,
7339 static void XGI_SetLCDCap_A(unsigned short tempcx, struct vb_device_info *pVBInfo)
7341 unsigned short temp;
7343 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x37);
7345 if (temp & LCDRGB18Bit) {
7346 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F,
7347 (unsigned short) (0x20 | (tempcx & 0x00C0))); /* Enable Dither */
7348 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80);
7350 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F,
7351 (unsigned short) (0x30 | (tempcx & 0x00C0)));
7352 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00);
7356 if (tempcx & EnableLCD24bpp) { // 24bits
7357 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F, (unsigned short)(0x30 | (tempcx&0x00C0)));
7358 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00);
7360 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x19, 0x0F, (unsigned short)(0x20 | (tempcx&0x00C0))); // Enable Dither
7361 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80);
7366 /* --------------------------------------------------------------------- */
7367 /* Function : XGI_SetLCDCap_B */
7368 /* Input : cx -> LCD Capability */
7371 /* --------------------------------------------------------------------- */
7372 static void XGI_SetLCDCap_B(unsigned short tempcx, struct vb_device_info *pVBInfo)
7374 if (tempcx & EnableLCD24bpp) /* 24bits */
7375 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1A, 0xE0,
7376 (unsigned short) (((tempcx & 0x00ff) >> 6)
7379 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x1A, 0xE0,
7380 (unsigned short) (((tempcx & 0x00ff) >> 6)
7381 | 0x18)); /* Enable Dither */
7384 static void SetSpectrum(struct vb_device_info *pVBInfo)
7386 unsigned short index;
7388 index = XGI_GetLCDCapPtr(pVBInfo);
7390 XGINew_SetRegAND(pVBInfo->Part4Port, 0x30, 0x8F); /* disable down spectrum D[4] */
7391 XGI_LongWait(pVBInfo);
7392 XGINew_SetRegOR(pVBInfo->Part4Port, 0x30, 0x20); /* reset spectrum */
7393 XGI_LongWait(pVBInfo);
7395 XGINew_SetReg1(pVBInfo->Part4Port, 0x31,
7396 pVBInfo->LCDCapList[index].Spectrum_31);
7397 XGINew_SetReg1(pVBInfo->Part4Port, 0x32,
7398 pVBInfo->LCDCapList[index].Spectrum_32);
7399 XGINew_SetReg1(pVBInfo->Part4Port, 0x33,
7400 pVBInfo->LCDCapList[index].Spectrum_33);
7401 XGINew_SetReg1(pVBInfo->Part4Port, 0x34,
7402 pVBInfo->LCDCapList[index].Spectrum_34);
7403 XGI_LongWait(pVBInfo);
7404 XGINew_SetRegOR(pVBInfo->Part4Port, 0x30, 0x40); /* enable spectrum */
7407 static void XGI_SetLCDCap(struct vb_device_info *pVBInfo)
7409 unsigned short tempcx;
7411 tempcx = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(pVBInfo)].LCD_Capability;
7413 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7414 | VB_XGI302LV | VB_XGI301C)) {
7415 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) { /* 301LV/302LV only */
7416 /* Set 301LV Capability */
7417 XGINew_SetReg1(pVBInfo->Part4Port, 0x24,
7418 (unsigned char) (tempcx & 0x1F));
7421 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x0D,
7422 ~((EnableVBCLKDRVLOW | EnablePLLSPLOW) >> 8),
7423 (unsigned short) ((tempcx & (EnableVBCLKDRVLOW
7424 | EnablePLLSPLOW)) >> 8));
7427 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7428 | VB_XGI302LV | VB_XGI301C)) {
7429 if (pVBInfo->VBInfo & SetCRT2ToLCD)
7430 XGI_SetLCDCap_B(tempcx, pVBInfo);
7431 else if (pVBInfo->VBInfo & SetCRT2ToLCDA)
7432 XGI_SetLCDCap_A(tempcx, pVBInfo);
7434 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
7435 if (tempcx & EnableSpectrum)
7436 SetSpectrum(pVBInfo);
7440 XGI_SetLCDCap_A(tempcx, pVBInfo);
7444 /* --------------------------------------------------------------------- */
7445 /* Function : XGI_SetAntiFlicker */
7448 /* Description : Set TV Customized Param. */
7449 /* --------------------------------------------------------------------- */
7450 static void XGI_SetAntiFlicker(unsigned short ModeNo, unsigned short ModeIdIndex,
7451 struct vb_device_info *pVBInfo)
7453 unsigned short tempbx, index;
7455 unsigned char tempah;
7457 if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))
7460 tempbx = XGI_GetTVPtrIndex(pVBInfo);
7464 index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVFlickerIndex;
7466 index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVFlickerIndex;
7469 tempah = TVAntiFlickList[tempbx];
7470 tempah = tempah << 4;
7472 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x0A, 0x8F, tempah);
7475 static void XGI_SetEdgeEnhance(unsigned short ModeNo, unsigned short ModeIdIndex,
7476 struct vb_device_info *pVBInfo)
7478 unsigned short tempbx, index;
7480 unsigned char tempah;
7482 tempbx = XGI_GetTVPtrIndex(pVBInfo);
7486 index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVEdgeIndex;
7488 index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVEdgeIndex;
7491 tempah = TVEdgeList[tempbx];
7492 tempah = tempah << 5;
7494 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x3A, 0x1F, tempah);
7497 static void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo)
7499 unsigned short tempbx;
7501 unsigned char tempcl, tempch;
7503 unsigned long tempData;
7505 XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */
7506 tempData = TVPhaseList[tempbx];
7508 XGINew_SetReg1(pVBInfo->Part2Port, 0x31, (unsigned short) (tempData
7510 XGINew_SetReg1(pVBInfo->Part2Port, 0x32, (unsigned short) ((tempData
7511 & 0x0000FF00) >> 8));
7512 XGINew_SetReg1(pVBInfo->Part2Port, 0x33, (unsigned short) ((tempData
7513 & 0x00FF0000) >> 16));
7514 XGINew_SetReg1(pVBInfo->Part2Port, 0x34, (unsigned short) ((tempData
7515 & 0xFF000000) >> 24));
7518 static void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex,
7519 struct vb_device_info *pVBInfo)
7521 unsigned short tempbx, index;
7523 unsigned char tempcl, tempch, tempal, *filterPtr;
7525 XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */
7530 filterPtr = NTSCYFilter1;
7534 filterPtr = PALYFilter1;
7540 filterPtr = PALMYFilter1;
7544 filterPtr = PALNYFilter1;
7549 filterPtr = NTSCYFilter2;
7553 filterPtr = PALMYFilter2;
7557 filterPtr = PALNYFilter2;
7561 filterPtr = PALYFilter2;
7569 tempal = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVYFilterIndex;
7572 = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVYFilterIndex;
7579 if ((tempcl == 0) && (tempch == 1)) {
7580 XGINew_SetReg1(pVBInfo->Part2Port, 0x35, 0);
7581 XGINew_SetReg1(pVBInfo->Part2Port, 0x36, 0);
7582 XGINew_SetReg1(pVBInfo->Part2Port, 0x37, 0);
7583 XGINew_SetReg1(pVBInfo->Part2Port, 0x38, filterPtr[index++]);
7585 XGINew_SetReg1(pVBInfo->Part2Port, 0x35, filterPtr[index++]);
7586 XGINew_SetReg1(pVBInfo->Part2Port, 0x36, filterPtr[index++]);
7587 XGINew_SetReg1(pVBInfo->Part2Port, 0x37, filterPtr[index++]);
7588 XGINew_SetReg1(pVBInfo->Part2Port, 0x38, filterPtr[index++]);
7591 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7592 | VB_XGI302LV | VB_XGI301C)) {
7593 XGINew_SetReg1(pVBInfo->Part2Port, 0x48, filterPtr[index++]);
7594 XGINew_SetReg1(pVBInfo->Part2Port, 0x49, filterPtr[index++]);
7595 XGINew_SetReg1(pVBInfo->Part2Port, 0x4A, filterPtr[index++]);
7599 /* --------------------------------------------------------------------- */
7600 /* Function : XGI_OEM310Setting */
7603 /* Description : Customized Param. for 301 */
7604 /* --------------------------------------------------------------------- */
7605 static void XGI_OEM310Setting(unsigned short ModeNo, unsigned short ModeIdIndex,
7606 struct vb_device_info *pVBInfo)
7608 if (pVBInfo->SetFlag & Win9xDOSMode)
7612 XGI_SetDelayComp(pVBInfo);
7614 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))
7615 XGI_SetLCDCap(pVBInfo);
7617 if (pVBInfo->VBInfo & SetCRT2ToTV) {
7619 XGI_SetPhaseIncr(pVBInfo);
7620 XGI_SetYFilter(ModeNo, ModeIdIndex, pVBInfo);
7621 XGI_SetAntiFlicker(ModeNo, ModeIdIndex, pVBInfo);
7623 if (pVBInfo->VBType & VB_XGI301)
7624 XGI_SetEdgeEnhance(ModeNo, ModeIdIndex, pVBInfo);
7628 /* --------------------------------------------------------------------- */
7629 /* Function : XGI_SetCRT2ModeRegs */
7632 /* Description : Origin code for crt2group */
7633 /* --------------------------------------------------------------------- */
7634 void XGI_SetCRT2ModeRegs(unsigned short ModeNo,
7635 struct xgi_hw_device_info *HwDeviceExtension,
7636 struct vb_device_info *pVBInfo)
7638 unsigned short tempbl;
7641 unsigned char tempah;
7643 /* XGINew_SetReg1(pVBInfo->Part1Port, 0x03, 0x00); // fix write part1 index 0 BTDRAM bit Bug */
7645 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
7646 tempah = XGINew_GetReg1(pVBInfo->Part1Port, 0x00);
7647 tempah &= ~0x10; /* BTRAMDAC */
7648 tempah |= 0x40; /* BTRAM */
7650 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV
7652 tempah = 0x40; /* BTDRAM */
7653 if (ModeNo > 0x13) {
7654 tempcl = pVBInfo->ModeType;
7657 tempah = (0x008 >> tempcl); /* BT Color */
7663 if (pVBInfo->VBInfo & SetInSlaveMode)
7664 tempah ^= 0x50; /* BTDAC */
7669 if (pVBInfo->VBInfo & DisableCRT2Display) {
7673 XGINew_SetReg1(pVBInfo->Part1Port, 0x00, tempah);
7674 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD)) {
7675 tempcl = pVBInfo->ModeType;
7676 if (ModeNo > 0x13) {
7678 if ((tempcl > 0) || (tempcl == 0)) {
7679 tempah=(0x008>>tempcl) ;
7688 if (pVBInfo->VBInfo & SetInSlaveMode) {
7689 tempah = (tempah ^ 0x050);
7694 XGINew_SetReg1(pVBInfo->Part1Port, 0x00, tempah);
7698 if (pVBInfo->VBInfo & DisableCRT2Display) {
7699 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2e, tempbl, tempah);
7704 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV
7705 | SetCRT2ToLCD | SetCRT2ToLCDA)) {
7706 if ((pVBInfo->VBInfo & SetCRT2ToLCDA)
7707 && (!(pVBInfo->VBInfo & SetSimuScanMode))) {
7710 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2e,
7713 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
7718 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC
7719 | SetCRT2ToTV | SetCRT2ToLCD)) {
7723 if (!(pVBInfo->VBInfo & SetInSlaveMode))
7726 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) {
7727 tempah = tempah ^ 0x05;
7728 if (!(pVBInfo->VBInfo
7730 tempah = tempah ^ 0x01;
7733 if (!(pVBInfo->VBInfo
7734 & SetCRT2ToDualEdge))
7736 XGINew_SetRegANDOR(pVBInfo->Part1Port,
7737 0x2e, tempbl, tempah);
7739 XGINew_SetRegANDOR(pVBInfo->Part1Port,
7740 0x2e, tempbl, tempah);
7744 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2e, tempbl,
7749 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD
7752 if ((pVBInfo->ModeType == ModeVGA) && (!(pVBInfo->VBInfo
7753 & SetInSlaveMode))) {
7758 if (pVBInfo->VBInfo & SetCRT2ToTV) {
7759 /* if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))) { */
7761 if (ModeNo > 0x13) {
7762 if (pVBInfo->VBInfo & DriverMode)
7763 tempah = tempah ^ 0x20;
7768 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x0D, ~0x0BF, tempah);
7771 if (pVBInfo->LCDInfo & SetLCDDualLink)
7774 if (pVBInfo->VBInfo & SetCRT2ToTV) {
7775 /* if ((!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)) && (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)))) { */
7776 if (pVBInfo->TVInfo & RPLLDIV2XO)
7781 if ((pVBInfo->LCDResInfo == Panel1280x1024)
7782 || (pVBInfo->LCDResInfo == Panel1280x1024x75))
7785 if (pVBInfo->LCDResInfo == Panel1280x960)
7788 XGINew_SetReg1(pVBInfo->Part4Port, 0x0C, tempah);
7791 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7792 | VB_XGI302LV | VB_XGI301C)) {
7796 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
7798 if (pVBInfo->VBInfo & SetCRT2ToLCDA)
7799 tempah |= 0x04; /* shampoo 0129 */
7802 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x13, tempbl, tempah);
7805 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
7806 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
7810 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2c, tempbl, tempah);
7814 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
7815 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
7818 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x21, tempbl, tempah);
7823 if (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) {
7825 if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge))
7829 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x23, tempbl, tempah);
7831 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
7832 if (pVBInfo->LCDInfo & SetLCDDualLink) {
7833 XGINew_SetRegOR(pVBInfo->Part4Port, 0x27, 0x20);
7834 XGINew_SetRegOR(pVBInfo->Part4Port, 0x34, 0x10);
7839 static void XGI_CloseCRTC(struct xgi_hw_device_info *HwDeviceExtension,
7840 struct vb_device_info *pVBInfo)
7842 unsigned short tempbx;
7846 if (pVBInfo->VBInfo & SetCRT2ToLCDA)
7851 void XGI_OpenCRTC(struct xgi_hw_device_info *HwDeviceExtension,
7852 struct vb_device_info *pVBInfo)
7854 unsigned short tempbx;
7858 void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension,
7859 struct vb_device_info *pVBInfo)
7862 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2f, 0xFF, 0x01);
7866 void XGI_LockCRT2(struct xgi_hw_device_info *HwDeviceExtension,
7867 struct vb_device_info *pVBInfo)
7870 XGINew_SetRegANDOR(pVBInfo->Part1Port, 0x2F, 0xFE, 0x00);
7874 unsigned char XGI_BridgeIsOn(struct vb_device_info *pVBInfo)
7876 unsigned short flag;
7878 if (pVBInfo->IF_DEF_LVDS == 1) {
7881 flag = XGINew_GetReg1(pVBInfo->Part4Port, 0x00);
7882 if ((flag == 1) || (flag == 2))
7883 return 1; /* 301b */
7889 void XGI_LongWait(struct vb_device_info *pVBInfo)
7893 i = XGINew_GetReg1(pVBInfo->P3c4, 0x1F);
7896 for (i = 0; i < 0xFFFF; i++) {
7897 if (!(XGINew_GetReg2(pVBInfo->P3da) & 0x08))
7901 for (i = 0; i < 0xFFFF; i++) {
7902 if ((XGINew_GetReg2(pVBInfo->P3da) & 0x08))
7908 static void XGI_VBLongWait(struct vb_device_info *pVBInfo)
7910 unsigned short tempal, temp, i, j;
7912 if (!(pVBInfo->VBInfo & SetCRT2ToTV)) {
7914 for (i = 0; i < 3; i++) {
7915 for (j = 0; j < 100; j++) {
7916 tempal = XGINew_GetReg2(pVBInfo->P3da);
7917 if (temp & 0x01) { /* VBWaitMode2 */
7918 if ((tempal & 0x08))
7921 if (!(tempal & 0x08))
7924 } else { /* VBWaitMode1 */
7925 if (!(tempal & 0x08))
7928 if ((tempal & 0x08))
7935 XGI_LongWait(pVBInfo);
7940 unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE,
7941 unsigned short ModeNo, unsigned short ModeIdIndex,
7942 struct vb_device_info *pVBInfo)
7944 short LCDRefreshIndex[] = { 0x00, 0x00, 0x03, 0x01 },
7945 LCDARefreshIndex[] = { 0x00, 0x00, 0x03, 0x01, 0x01,
7948 unsigned short RefreshRateTableIndex, i, modeflag, index, temp;
7951 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
7953 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
7955 if (pVBInfo->IF_DEF_CH7005 == 1) {
7956 if (pVBInfo->VBInfo & SetCRT2ToTV) {
7957 if (modeflag & HalfDCLK)
7965 index = XGINew_GetReg1(pVBInfo->P3d4, 0x33);
7966 index = index >> pVBInfo->SelectCRT2Rate;
7969 if (pVBInfo->LCDInfo & LCDNonExpanding)
7975 if (pVBInfo->SetFlag & ProgrammingCRT2) {
7976 if (pVBInfo->IF_DEF_CH7005 == 1) {
7977 if (pVBInfo->VBInfo & SetCRT2ToTV)
7981 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
7982 if (pVBInfo->IF_DEF_LVDS == 0) {
7983 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
7984 | VB_XGI301LV | VB_XGI302LV
7987 = LCDARefreshIndex[pVBInfo->LCDResInfo
7991 = LCDRefreshIndex[pVBInfo->LCDResInfo
8002 RefreshRateTableIndex = pVBInfo->EModeIDTable[ModeIdIndex].REFindex;
8003 ModeNo = pVBInfo->RefIndex[RefreshRateTableIndex].ModeID;
8004 if (pXGIHWDE->jChipType >= XG20) { /* for XG20, XG21, XG27 */
8006 if (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag & XG2xNotSupport) {
8010 if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 800)
8011 && (pVBInfo->RefIndex[RefreshRateTableIndex].YRes
8015 /* Alan 10/19/2007; do the similiar adjustment like XGISearchCRT1Rate() */
8016 if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1024)
8017 && (pVBInfo->RefIndex[RefreshRateTableIndex].YRes
8021 if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1280)
8022 && (pVBInfo->RefIndex[RefreshRateTableIndex].YRes
8030 if (pVBInfo->RefIndex[RefreshRateTableIndex + i].ModeID
8034 = pVBInfo->RefIndex[RefreshRateTableIndex + i].Ext_InfoFlag;
8035 temp &= ModeInfoFlag;
8036 if (temp < pVBInfo->ModeType)
8041 } while (index != 0xFFFF);
8042 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) {
8043 if (pVBInfo->VBInfo & SetInSlaveMode) {
8045 = pVBInfo->RefIndex[RefreshRateTableIndex
8046 + i - 1].Ext_InfoFlag;
8047 if (temp & InterlaceMode)
8052 if ((pVBInfo->SetFlag & ProgrammingCRT2)) {
8053 temp = XGI_AjustCRT2Rate(ModeNo, ModeIdIndex,
8054 RefreshRateTableIndex, &i, pVBInfo);
8056 return RefreshRateTableIndex + i; /* return (0x01 | (temp1<<1)); */
8059 static void XGI_SetLCDAGroup(unsigned short ModeNo, unsigned short ModeIdIndex,
8060 struct xgi_hw_device_info *HwDeviceExtension,
8061 struct vb_device_info *pVBInfo)
8063 unsigned short RefreshRateTableIndex;
8064 /* unsigned short temp ; */
8066 /* pVBInfo->SelectCRT2Rate = 0; */
8068 pVBInfo->SetFlag |= ProgrammingCRT2;
8069 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
8070 ModeIdIndex, pVBInfo);
8071 XGI_GetLVDSResInfo(ModeNo, ModeIdIndex, pVBInfo);
8072 XGI_GetLVDSData(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
8073 XGI_ModCRT1Regs(ModeNo, ModeIdIndex, RefreshRateTableIndex,
8074 HwDeviceExtension, pVBInfo);
8075 XGI_SetLVDSRegs(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
8076 XGI_SetCRT2ECLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
8079 unsigned char XGI_SetCRT2Group301(unsigned short ModeNo,
8080 struct xgi_hw_device_info *HwDeviceExtension,
8081 struct vb_device_info *pVBInfo)
8083 unsigned short tempbx, ModeIdIndex, RefreshRateTableIndex;
8085 tempbx = pVBInfo->VBInfo;
8086 pVBInfo->SetFlag |= ProgrammingCRT2;
8087 XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo);
8088 pVBInfo->SelectCRT2Rate = 4;
8089 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
8090 ModeIdIndex, pVBInfo);
8091 XGI_SaveCRT2Info(ModeNo, pVBInfo);
8092 XGI_GetCRT2ResInfo(ModeNo, ModeIdIndex, pVBInfo);
8093 XGI_GetCRT2Data(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
8094 XGI_PreSetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension,
8095 RefreshRateTableIndex, pVBInfo);
8096 XGI_SetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension,
8097 RefreshRateTableIndex, pVBInfo);
8098 XGI_SetLockRegs(ModeNo, ModeIdIndex, HwDeviceExtension,
8099 RefreshRateTableIndex, pVBInfo);
8100 XGI_SetGroup2(ModeNo, ModeIdIndex, RefreshRateTableIndex,
8101 HwDeviceExtension, pVBInfo);
8102 XGI_SetLCDRegs(ModeNo, ModeIdIndex, HwDeviceExtension,
8103 RefreshRateTableIndex, pVBInfo);
8104 XGI_SetTap4Regs(pVBInfo);
8105 XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo);
8106 XGI_SetGroup4(ModeNo, ModeIdIndex, RefreshRateTableIndex,
8107 HwDeviceExtension, pVBInfo);
8108 XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
8109 XGI_SetGroup5(ModeNo, ModeIdIndex, pVBInfo);
8110 XGI_AutoThreshold(pVBInfo);
8114 void XGI_SenseCRT1(struct vb_device_info *pVBInfo)
8116 unsigned char CRTCData[17] = { 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81,
8117 0x0B, 0x3E, 0xE9, 0x0B, 0xDF, 0xE7, 0x04, 0x00, 0x00,
8120 unsigned char SR01 = 0, SR1F = 0, SR07 = 0, SR06 = 0;
8122 unsigned char CR17, CR63, SR31;
8123 unsigned short temp;
8124 unsigned char DAC_TEST_PARMS[3] = { 0x0F, 0x0F, 0x0F };
8127 XGINew_SetReg1(pVBInfo->P3c4, 0x05, 0x86);
8129 /* [2004/05/06] Vicent to fix XG42 single LCD sense to CRT+LCD */
8130 XGINew_SetReg1(pVBInfo->P3d4, 0x57, 0x4A);
8131 XGINew_SetReg1(pVBInfo->P3d4, 0x53, (unsigned char) (XGINew_GetReg1(
8132 pVBInfo->P3d4, 0x53) | 0x02));
8134 SR31 = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x31);
8135 CR63 = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x63);
8136 SR01 = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x01);
8138 XGINew_SetReg1(pVBInfo->P3c4, 0x01, (unsigned char) (SR01 & 0xDF));
8139 XGINew_SetReg1(pVBInfo->P3d4, 0x63, (unsigned char) (CR63 & 0xBF));
8141 CR17 = (unsigned char) XGINew_GetReg1(pVBInfo->P3d4, 0x17);
8142 XGINew_SetReg1(pVBInfo->P3d4, 0x17, (unsigned char) (CR17 | 0x80));
8144 SR1F = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x1F);
8145 XGINew_SetReg1(pVBInfo->P3c4, 0x1F, (unsigned char) (SR1F | 0x04));
8147 SR07 = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x07);
8148 XGINew_SetReg1(pVBInfo->P3c4, 0x07, (unsigned char) (SR07 & 0xFB));
8149 SR06 = (unsigned char) XGINew_GetReg1(pVBInfo->P3c4, 0x06);
8150 XGINew_SetReg1(pVBInfo->P3c4, 0x06, (unsigned char) (SR06 & 0xC3));
8152 XGINew_SetReg1(pVBInfo->P3d4, 0x11, 0x00);
8154 for (i = 0; i < 8; i++)
8155 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) i, CRTCData[i]);
8157 for (i = 8; i < 11; i++)
8158 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 8),
8161 for (i = 11; i < 13; i++)
8162 XGINew_SetReg1(pVBInfo->P3d4, (unsigned short) (i + 4),
8165 for (i = 13; i < 16; i++)
8166 XGINew_SetReg1(pVBInfo->P3c4, (unsigned short) (i - 3),
8169 XGINew_SetReg1(pVBInfo->P3c4, 0x0E, (unsigned char) (CRTCData[16]
8172 XGINew_SetReg1(pVBInfo->P3c4, 0x31, 0x00);
8173 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, 0x1B);
8174 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, 0xE1);
8176 XGINew_SetReg3(pVBInfo->P3c8, 0x00);
8178 for (i = 0; i < 256; i++) {
8179 XGINew_SetReg3((pVBInfo->P3c8 + 1),
8180 (unsigned char) DAC_TEST_PARMS[0]);
8181 XGINew_SetReg3((pVBInfo->P3c8 + 1),
8182 (unsigned char) DAC_TEST_PARMS[1]);
8183 XGINew_SetReg3((pVBInfo->P3c8 + 1),
8184 (unsigned char) DAC_TEST_PARMS[2]);
8187 XGI_VBLongWait(pVBInfo);
8188 XGI_VBLongWait(pVBInfo);
8189 XGI_VBLongWait(pVBInfo);
8193 XGI_WaitDisply(pVBInfo);
8194 temp = XGINew_GetReg2(pVBInfo->P3c2);
8197 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x32, 0xDF, 0x20);
8199 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x32, 0xDF, 0x00);
8201 /* alan, avoid display something, set BLACK DAC if not restore DAC */
8202 XGINew_SetReg3(pVBInfo->P3c8, 0x00);
8204 for (i = 0; i < 256; i++) {
8205 XGINew_SetReg3((pVBInfo->P3c8 + 1), 0);
8206 XGINew_SetReg3((pVBInfo->P3c8 + 1), 0);
8207 XGINew_SetReg3((pVBInfo->P3c8 + 1), 0);
8210 XGINew_SetReg1(pVBInfo->P3c4, 0x01, SR01);
8211 XGINew_SetReg1(pVBInfo->P3d4, 0x63, CR63);
8212 XGINew_SetReg1(pVBInfo->P3c4, 0x31, SR31);
8214 /* [2004/05/11] Vicent */
8215 XGINew_SetReg1(pVBInfo->P3d4, 0x53, (unsigned char) (XGINew_GetReg1(
8216 pVBInfo->P3d4, 0x53) & 0xFD));
8217 XGINew_SetReg1(pVBInfo->P3c4, 0x1F, (unsigned char) SR1F);
8220 void XGI_EnableBridge(struct xgi_hw_device_info *HwDeviceExtension,
8221 struct vb_device_info *pVBInfo)
8223 unsigned short tempbl, tempah;
8225 if (pVBInfo->SetFlag == Win9xDOSMode) {
8226 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8227 | VB_XGI302LV | VB_XGI301C)) {
8228 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
8231 /* LVDS or CH7017 */
8235 if (HwDeviceExtension->jChipType < XG40) {
8236 if (!XGI_DisableChISLCD(pVBInfo)) {
8237 if ((XGI_EnableChISLCD(pVBInfo)) || (pVBInfo->VBInfo
8238 & (SetCRT2ToLCD | SetCRT2ToLCDA))) {
8239 if (pVBInfo->LCDInfo & SetPWDEnable) {
8240 XGI_EnablePWD(pVBInfo);
8242 pVBInfo->LCDInfo &= (~SetPWDEnable);
8243 if (pVBInfo->VBType & (VB_XGI301LV
8253 XGI_SetPanelPower(tempah, tempbl,
8255 XGI_SetPanelDelay(1, pVBInfo);
8261 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8262 | VB_XGI302LV | VB_XGI301C)) {
8263 if (!(pVBInfo->SetFlag & DisableChA)) {
8264 if (pVBInfo->SetFlag & EnableChA) {
8265 XGINew_SetReg1(pVBInfo->Part1Port, 0x1E, 0x20); /* Power on */
8267 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { /* SetCRT2ToLCDA ) */
8268 XGINew_SetReg1(pVBInfo->Part1Port,
8269 0x1E, 0x20); /* Power on */
8274 if (!(pVBInfo->SetFlag & DisableChB)) {
8275 if ((pVBInfo->SetFlag & EnableChB) || (pVBInfo->VBInfo
8276 & (SetCRT2ToLCD | SetCRT2ToTV
8277 | SetCRT2ToRAMDAC))) {
8278 tempah = (unsigned char) XGINew_GetReg1(
8279 pVBInfo->P3c4, 0x32);
8281 if (pVBInfo->VBInfo & SetInSlaveMode) {
8282 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC))
8285 XGINew_SetReg1(pVBInfo->P3c4, 0x32, tempah);
8286 XGINew_SetRegOR(pVBInfo->P3c4, 0x1E, 0x20);
8288 tempah = (unsigned char) XGINew_GetReg1(
8289 pVBInfo->Part1Port, 0x2E);
8291 if (!(tempah & 0x80))
8292 XGINew_SetRegOR(pVBInfo->Part1Port,
8293 0x2E, 0x80); /* BVBDOENABLE = 1 */
8295 XGINew_SetRegAND(pVBInfo->Part1Port, 0x00, 0x7F); /* BScreenOFF = 0 */
8299 if ((pVBInfo->SetFlag & (EnableChA | EnableChB))
8300 || (!(pVBInfo->VBInfo & DisableCRT2Display))) {
8301 XGINew_SetRegANDOR(pVBInfo->Part2Port, 0x00, ~0xE0,
8302 0x20); /* shampoo 0129 */
8303 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
8304 if (!XGI_DisableChISLCD(pVBInfo)) {
8305 if (XGI_EnableChISLCD(pVBInfo)
8311 0x2A, 0x7F); /* LVDS PLL power on */
8313 XGINew_SetRegAND(pVBInfo->Part4Port, 0x30, 0x7F); /* LVDS Driver power on */
8319 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
8322 if (!(pVBInfo->VBInfo & SetSimuScanMode)) {
8323 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
8324 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
8325 tempah = tempah & 0x40;
8328 tempah = tempah ^ 0xC0;
8330 if (pVBInfo->SetFlag
8334 if (pVBInfo->SetFlag
8338 if (pVBInfo->SetFlag
8342 if (pVBInfo->SetFlag
8350 XGINew_SetRegOR(pVBInfo->Part4Port, 0x1F, tempah); /* EnablePart4_1F */
8352 if (pVBInfo->SetFlag & Win9xDOSMode) {
8353 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
8357 if (!(pVBInfo->SetFlag & DisableChA)) {
8358 XGI_VBLongWait(pVBInfo);
8359 if (!(pVBInfo->SetFlag & GatingCRT)) {
8360 XGI_DisableGatingCRT(HwDeviceExtension, pVBInfo);
8361 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
8362 XGI_VBLongWait(pVBInfo);
8367 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD
8369 XGINew_SetRegOR(pVBInfo->Part1Port, 0x1E, 0x20); /* enable CRT2 */
8371 tempah = (unsigned char) XGINew_GetReg1(pVBInfo->Part1Port,
8373 if (!(tempah & 0x80))
8374 XGINew_SetRegOR(pVBInfo->Part1Port, 0x2E, 0x80); /* BVBDOENABLE = 1 */
8376 XGINew_SetRegAND(pVBInfo->Part1Port, 0x00, 0x7F);
8377 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
8380 if (HwDeviceExtension->jChipType < XG40) {
8381 if (!XGI_EnableChISLCD(pVBInfo)) {
8382 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
8383 if (XGI_BacklightByDrv(pVBInfo))
8389 if (pVBInfo->LCDInfo & SetPWDEnable) {
8390 XGI_FirePWDEnable(pVBInfo);
8394 XGI_SetPanelDelay(2, pVBInfo);
8396 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
8398 tempbl = 0xFE; /* turn on backlght */
8403 XGI_SetPanelPower(tempah, tempbl, pVBInfo);
8407 static void XGI_SetCRT1Group(struct xgi_hw_device_info *HwDeviceExtension,
8408 unsigned short ModeNo, unsigned short ModeIdIndex,
8409 struct vb_device_info *pVBInfo)
8411 unsigned short StandTableIndex, RefreshRateTableIndex, b3CC, temp;
8413 unsigned short XGINew_P3cc = pVBInfo->P3cc;
8415 /* XGINew_CRT1Mode = ModeNo; // SaveModeID */
8416 StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
8417 /* XGI_SetBIOSData(ModeNo, ModeIdIndex); */
8418 /* XGI_ClearBankRegs(ModeNo, ModeIdIndex); */
8419 XGI_SetSeqRegs(ModeNo, StandTableIndex, ModeIdIndex, pVBInfo);
8420 XGI_SetMiscRegs(StandTableIndex, pVBInfo);
8421 XGI_SetCRTCRegs(HwDeviceExtension, StandTableIndex, pVBInfo);
8422 XGI_SetATTRegs(ModeNo, StandTableIndex, ModeIdIndex, pVBInfo);
8423 XGI_SetGRCRegs(StandTableIndex, pVBInfo);
8424 XGI_ClearExt1Regs(pVBInfo);
8426 /* if (pVBInfo->IF_DEF_ExpLink) */
8427 if (HwDeviceExtension->jChipType == XG27) {
8428 if (pVBInfo->IF_DEF_LVDS == 0)
8429 XGI_SetDefaultVCLK(pVBInfo);
8432 temp = ~ProgrammingCRT2;
8433 pVBInfo->SetFlag &= temp;
8434 pVBInfo->SelectCRT2Rate = 0;
8436 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8437 | VB_XGI302LV | VB_XGI301C)) {
8438 if (pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToLCDA
8439 | SetInSlaveMode)) {
8440 pVBInfo->SetFlag |= ProgrammingCRT2;
8444 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
8445 ModeIdIndex, pVBInfo);
8446 if (RefreshRateTableIndex != 0xFFFF) {
8447 XGI_SetSync(RefreshRateTableIndex, pVBInfo);
8448 XGI_SetCRT1CRTC(ModeNo, ModeIdIndex, RefreshRateTableIndex,
8449 pVBInfo, HwDeviceExtension);
8450 XGI_SetCRT1DE(HwDeviceExtension, ModeNo, ModeIdIndex,
8451 RefreshRateTableIndex, pVBInfo);
8452 XGI_SetCRT1Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
8453 HwDeviceExtension, pVBInfo);
8454 XGI_SetCRT1VCLK(ModeNo, ModeIdIndex, HwDeviceExtension,
8455 RefreshRateTableIndex, pVBInfo);
8458 if ((HwDeviceExtension->jChipType >= XG20)
8459 && (HwDeviceExtension->jChipType < XG27)) { /* fix H/W DCLK/2 bug */
8460 if ((ModeNo == 0x00) | (ModeNo == 0x01)) {
8461 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, 0x4E);
8462 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, 0xE9);
8463 b3CC = (unsigned char) XGINew_GetReg2(XGINew_P3cc);
8464 XGINew_SetReg3(XGINew_P3cc, (b3CC |= 0x0C));
8465 } else if ((ModeNo == 0x04) | (ModeNo == 0x05) | (ModeNo
8467 XGINew_SetReg1(pVBInfo->P3c4, 0x2B, 0x1B);
8468 XGINew_SetReg1(pVBInfo->P3c4, 0x2C, 0xE3);
8469 b3CC = (unsigned char) XGINew_GetReg2(XGINew_P3cc);
8470 XGINew_SetReg3(XGINew_P3cc, (b3CC |= 0x0C));
8474 if (HwDeviceExtension->jChipType >= XG21) {
8475 temp = XGINew_GetReg1(pVBInfo->P3d4, 0x38);
8478 /* XGINew_SetRegAND(pVBInfo->P3d4, 0x4A, ~0x20); *//* Enable write GPIOF */
8479 /* XGINew_SetRegAND(pVBInfo->P3d4, 0x48, ~0x20); *//* P. DWN */
8480 /* XG21 CRT1 Timing */
8481 if (HwDeviceExtension->jChipType == XG27)
8482 XGI_SetXG27CRTC(ModeNo, ModeIdIndex,
8483 RefreshRateTableIndex, pVBInfo);
8485 XGI_SetXG21CRTC(ModeNo, ModeIdIndex,
8486 RefreshRateTableIndex, pVBInfo);
8488 XGI_UpdateXG21CRTC(ModeNo, pVBInfo,
8489 RefreshRateTableIndex);
8491 if (HwDeviceExtension->jChipType == XG27)
8492 XGI_SetXG27LCD(pVBInfo, RefreshRateTableIndex,
8495 XGI_SetXG21LCD(pVBInfo, RefreshRateTableIndex,
8498 if (pVBInfo->IF_DEF_LVDS == 1) {
8499 if (HwDeviceExtension->jChipType == XG27)
8500 XGI_SetXG27LVDSPara(ModeNo,
8501 ModeIdIndex, pVBInfo);
8503 XGI_SetXG21LVDSPara(ModeNo,
8504 ModeIdIndex, pVBInfo);
8506 /* XGINew_SetRegOR(pVBInfo->P3d4, 0x48, 0x20); *//* P. ON */
8510 pVBInfo->SetFlag &= (~ProgrammingCRT2);
8511 XGI_SetCRT1FIFO(ModeNo, HwDeviceExtension, pVBInfo);
8512 XGI_SetCRT1ModeRegs(HwDeviceExtension, ModeNo, ModeIdIndex,
8513 RefreshRateTableIndex, pVBInfo);
8515 /* XGI_LoadCharacter(); //dif ifdef TVFont */
8517 XGI_LoadDAC(ModeNo, ModeIdIndex, pVBInfo);
8518 /* XGI_ClearBuffer(HwDeviceExtension, ModeNo, pVBInfo); */
8521 unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension,
8522 unsigned short ModeNo)
8524 unsigned short ModeIdIndex;
8525 /* unsigned char *pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress; */
8526 struct vb_device_info VBINF;
8527 struct vb_device_info *pVBInfo = &VBINF;
8528 pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase;
8529 pVBInfo->BaseAddr = (unsigned long) HwDeviceExtension->pjIOAddress;
8530 pVBInfo->IF_DEF_LVDS = 0;
8531 pVBInfo->IF_DEF_CH7005 = 0;
8532 pVBInfo->IF_DEF_LCDA = 1;
8533 pVBInfo->IF_DEF_CH7017 = 0;
8534 pVBInfo->IF_DEF_CH7007 = 0; /* [Billy] 2007/05/14 */
8535 pVBInfo->IF_DEF_VideoCapture = 0;
8536 pVBInfo->IF_DEF_ScaleLCD = 0;
8537 pVBInfo->IF_DEF_OEMUtil = 0;
8538 pVBInfo->IF_DEF_PWD = 0;
8540 if (HwDeviceExtension->jChipType >= XG20) { /* kuku 2004/06/25 */
8541 pVBInfo->IF_DEF_YPbPr = 0;
8542 pVBInfo->IF_DEF_HiVision = 0;
8543 pVBInfo->IF_DEF_CRT2Monitor = 0;
8544 pVBInfo->VBType = 0; /*set VBType default 0*/
8545 } else if (HwDeviceExtension->jChipType >= XG40) {
8546 pVBInfo->IF_DEF_YPbPr = 1;
8547 pVBInfo->IF_DEF_HiVision = 1;
8548 pVBInfo->IF_DEF_CRT2Monitor = 1;
8550 pVBInfo->IF_DEF_YPbPr = 1;
8551 pVBInfo->IF_DEF_HiVision = 1;
8552 pVBInfo->IF_DEF_CRT2Monitor = 0;
8555 pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14;
8556 pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24;
8557 pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10;
8558 pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e;
8559 pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12;
8560 pVBInfo->P3cc = pVBInfo->BaseAddr + 0x1C;
8561 pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a;
8562 pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16;
8563 pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17;
8564 pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18;
8565 pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19;
8566 pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A;
8567 pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00;
8568 pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04;
8569 pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10;
8570 pVBInfo->Part3Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_12;
8571 pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14;
8572 pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2;
8574 if (HwDeviceExtension->jChipType == XG21) { /* for x86 Linux, XG21 LVDS */
8575 if ((XGINew_GetReg1(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0)
8576 pVBInfo->IF_DEF_LVDS = 1;
8578 if (HwDeviceExtension->jChipType == XG27) {
8579 if ((XGINew_GetReg1(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) {
8580 if (XGINew_GetReg1(pVBInfo->P3d4, 0x30) & 0x20)
8581 pVBInfo->IF_DEF_LVDS = 1;
8585 if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 */
8586 XGI_GetVBType(pVBInfo);
8588 InitTo330Pointer(HwDeviceExtension->jChipType, pVBInfo);
8589 if (ModeNo & 0x80) {
8590 ModeNo = ModeNo & 0x7F;
8591 /* XGINew_flag_clearbuffer = 0; */
8594 XGINew_flag_clearbuffer = 1;
8597 XGINew_SetReg1(pVBInfo->P3c4, 0x05, 0x86);
8599 if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 1.Openkey */
8600 XGI_UnLockCRT2(HwDeviceExtension, pVBInfo);
8602 XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo);
8604 XGI_GetVGAType(HwDeviceExtension, pVBInfo);
8606 if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */
8607 XGI_GetVBInfo(ModeNo, ModeIdIndex, HwDeviceExtension, pVBInfo);
8608 XGI_GetTVInfo(ModeNo, ModeIdIndex, pVBInfo);
8609 XGI_GetLCDInfo(ModeNo, ModeIdIndex, pVBInfo);
8610 XGI_DisableBridge(HwDeviceExtension, pVBInfo);
8611 /* XGI_OpenCRTC(HwDeviceExtension, pVBInfo); */
8613 if (pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToLCDA)) {
8614 XGI_SetCRT1Group(HwDeviceExtension, ModeNo,
8615 ModeIdIndex, pVBInfo);
8617 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
8618 XGI_SetLCDAGroup(ModeNo, ModeIdIndex,
8619 HwDeviceExtension, pVBInfo);
8622 if (!(pVBInfo->VBInfo & SwitchToCRT2)) {
8623 XGI_SetCRT1Group(HwDeviceExtension, ModeNo,
8624 ModeIdIndex, pVBInfo);
8625 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
8626 XGI_SetLCDAGroup(ModeNo, ModeIdIndex,
8633 if (pVBInfo->VBInfo & (SetSimuScanMode | SwitchToCRT2)) {
8634 switch (HwDeviceExtension->ujVBChipID) {
8636 XGI_SetCRT2Group301(ModeNo, HwDeviceExtension,
8637 pVBInfo); /*add for CRT2 */
8641 XGI_SetCRT2Group301(ModeNo, HwDeviceExtension,
8642 pVBInfo); /*add for CRT2 */
8650 XGI_SetCRT2ModeRegs(ModeNo, HwDeviceExtension, pVBInfo);
8651 XGI_OEM310Setting(ModeNo, ModeIdIndex, pVBInfo); /*0212*/
8652 XGI_CloseCRTC(HwDeviceExtension, pVBInfo);
8653 XGI_EnableBridge(HwDeviceExtension, pVBInfo);
8656 if (pVBInfo->IF_DEF_LVDS == 1)
8657 if (!XGI_XG21CheckLVDSMode(ModeNo, ModeIdIndex, pVBInfo))
8660 if (ModeNo <= 0x13) {
8662 = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag
8666 = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag
8670 pVBInfo->SetFlag = 0;
8671 if (pVBInfo->IF_DEF_CH7007 != 1)
8672 pVBInfo->VBInfo = DisableCRT2Display;
8674 XGI_DisplayOff(HwDeviceExtension, pVBInfo);
8676 XGI_SetCRT1Group(HwDeviceExtension, ModeNo, ModeIdIndex,
8679 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
8681 if (HwDeviceExtension->jChipType == XG21)
8682 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x09, ~0x80, 0x80);
8687 if (ModeNo <= 0x13) {
8688 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
8690 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
8692 pVBInfo->ModeType = modeflag&ModeInfoFlag;
8693 pVBInfo->SetFlag = 0x00;
8694 pVBInfo->VBInfo = DisableCRT2Display;
8695 temp = XGINew_CheckMemorySize(HwDeviceExtension, ModeNo, ModeIdIndex, pVBInfo);
8700 XGI_DisplayOff(HwDeviceExtension, pVBInfo) ;
8701 XGI_SetCRT1Group(HwDeviceExtension, ModeNo, ModeIdIndex, pVBInfo);
8702 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
8705 XGI_UpdateModeInfo(HwDeviceExtension, pVBInfo);
8707 if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */
8708 XGI_LockCRT2(HwDeviceExtension, pVBInfo);