3 #include <linux/delay.h>
4 #include <linux/types.h>
10 #include "vb_struct.h"
13 #include "vb_setmode.h"
16 #define IndexMask 0xff
17 #ifndef XGI_MASK_DUAL_CHIP
18 #define XGI_MASK_DUAL_CHIP 0x04 /* SR3A */
21 static unsigned short XGINew_MDA_DAC[] = {
22 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
24 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
25 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
26 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
28 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
29 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F};
31 static unsigned short XGINew_CGA_DAC[] = {
32 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
33 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
34 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
35 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
36 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
37 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
38 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
39 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F};
41 static unsigned short XGINew_EGA_DAC[] = {
42 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x05, 0x15,
43 0x20, 0x30, 0x24, 0x34, 0x21, 0x31, 0x25, 0x35,
44 0x08, 0x18, 0x0C, 0x1C, 0x09, 0x19, 0x0D, 0x1D,
45 0x28, 0x38, 0x2C, 0x3C, 0x29, 0x39, 0x2D, 0x3D,
46 0x02, 0x12, 0x06, 0x16, 0x03, 0x13, 0x07, 0x17,
47 0x22, 0x32, 0x26, 0x36, 0x23, 0x33, 0x27, 0x37,
48 0x0A, 0x1A, 0x0E, 0x1E, 0x0B, 0x1B, 0x0F, 0x1F,
49 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F};
51 static unsigned short XGINew_VGA_DAC[] = {
52 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
53 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
54 0x00, 0x05, 0x08, 0x0B, 0x0E, 0x11, 0x14, 0x18,
55 0x1C, 0x20, 0x24, 0x28, 0x2D, 0x32, 0x38, 0x3F,
56 0x00, 0x10, 0x1F, 0x2F, 0x3F, 0x1F, 0x27, 0x2F,
57 0x37, 0x3F, 0x2D, 0x31, 0x36, 0x3A, 0x3F, 0x00,
58 0x07, 0x0E, 0x15, 0x1C, 0x0E, 0x11, 0x15, 0x18,
59 0x1C, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x00, 0x04,
60 0x08, 0x0C, 0x10, 0x08, 0x0A, 0x0C, 0x0E, 0x10,
61 0x0B, 0x0C, 0x0D, 0x0F, 0x10};
63 void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo)
65 pVBInfo->SModeIDTable = (struct XGI_StStruct *) XGI330_SModeIDTable;
66 pVBInfo->StandTable = (struct XGI_StandTableStruct *) XGI330_StandTable;
67 pVBInfo->EModeIDTable = (struct XGI_ExtStruct *) XGI330_EModeIDTable;
68 pVBInfo->RefIndex = (struct XGI_Ext2Struct *) XGI330_RefIndex;
69 pVBInfo->XGINEWUB_CRT1Table
70 = (struct XGI_CRT1TableStruct *) XGI_CRT1Table;
72 /* add for new UNIVGABIOS */
73 /* XGINew_UBLCDDataTable =
74 * (struct XGI_LCDDataTablStruct *) XGI_LCDDataTable; */
75 /* XGINew_UBTVDataTable = (XGI_TVDataTablStruct *) XGI_TVDataTable; */
77 pVBInfo->MCLKData = (struct XGI_MCLKDataStruct *) XGI340New_MCLKData;
78 pVBInfo->ECLKData = (struct XGI_ECLKDataStruct *) XGI340_ECLKData;
79 pVBInfo->VCLKData = (struct XGI_VCLKDataStruct *) XGI_VCLKData;
80 pVBInfo->VBVCLKData = (struct XGI_VBVCLKDataStruct *) XGI_VBVCLKData;
81 pVBInfo->ScreenOffset = XGI330_ScreenOffset;
82 pVBInfo->StResInfo = (struct XGI_StResInfoStruct *) XGI330_StResInfo;
84 = (struct XGI_ModeResInfoStruct *) XGI330_ModeResInfo;
86 pVBInfo->pOutputSelect = &XGI330_OutputSelect;
87 pVBInfo->pSoftSetting = &XGI330_SoftSetting;
88 pVBInfo->pSR07 = &XGI330_SR07;
89 pVBInfo->LCDResInfo = 0;
90 pVBInfo->LCDTypeInfo = 0;
95 pVBInfo->SR15 = XGI340_SR13;
96 pVBInfo->CR40 = XGI340_cr41;
97 pVBInfo->SR25 = XGI330_sr25;
98 pVBInfo->pSR31 = &XGI330_sr31;
99 pVBInfo->pSR32 = &XGI330_sr32;
100 pVBInfo->CR6B = XGI340_CR6B;
101 pVBInfo->CR6E = XGI340_CR6E;
102 pVBInfo->CR6F = XGI340_CR6F;
103 pVBInfo->CR89 = XGI340_CR89;
104 pVBInfo->AGPReg = XGI340_AGPReg;
105 pVBInfo->SR16 = XGI340_SR16;
106 pVBInfo->pCRCF = &XG40_CRCF;
107 pVBInfo->pXGINew_DRAMTypeDefinition = &XG40_DRAMTypeDefinition;
109 pVBInfo->CR49 = XGI330_CR49;
110 pVBInfo->pSR1F = &XGI330_SR1F;
111 pVBInfo->pSR21 = &XGI330_SR21;
112 pVBInfo->pSR22 = &XGI330_SR22;
113 pVBInfo->pSR23 = &XGI330_SR23;
114 pVBInfo->pSR24 = &XGI330_SR24;
115 pVBInfo->pSR33 = &XGI330_SR33;
117 pVBInfo->pCRT2Data_1_2 = &XGI330_CRT2Data_1_2;
118 pVBInfo->pCRT2Data_4_D = &XGI330_CRT2Data_4_D;
119 pVBInfo->pCRT2Data_4_E = &XGI330_CRT2Data_4_E;
120 pVBInfo->pCRT2Data_4_10 = &XGI330_CRT2Data_4_10;
121 pVBInfo->pRGBSenseData = &XGI330_RGBSenseData;
122 pVBInfo->pVideoSenseData = &XGI330_VideoSenseData;
123 pVBInfo->pYCSenseData = &XGI330_YCSenseData;
124 pVBInfo->pRGBSenseData2 = &XGI330_RGBSenseData2;
125 pVBInfo->pVideoSenseData2 = &XGI330_VideoSenseData2;
126 pVBInfo->pYCSenseData2 = &XGI330_YCSenseData2;
128 pVBInfo->NTSCTiming = XGI330_NTSCTiming;
129 pVBInfo->PALTiming = XGI330_PALTiming;
130 pVBInfo->HiTVExtTiming = XGI330_HiTVExtTiming;
131 pVBInfo->HiTVSt1Timing = XGI330_HiTVSt1Timing;
132 pVBInfo->HiTVSt2Timing = XGI330_HiTVSt2Timing;
133 pVBInfo->HiTVTextTiming = XGI330_HiTVTextTiming;
134 pVBInfo->YPbPr750pTiming = XGI330_YPbPr750pTiming;
135 pVBInfo->YPbPr525pTiming = XGI330_YPbPr525pTiming;
136 pVBInfo->YPbPr525iTiming = XGI330_YPbPr525iTiming;
137 pVBInfo->HiTVGroup3Data = XGI330_HiTVGroup3Data;
138 pVBInfo->HiTVGroup3Simu = XGI330_HiTVGroup3Simu;
139 pVBInfo->HiTVGroup3Text = XGI330_HiTVGroup3Text;
140 pVBInfo->Ren525pGroup3 = XGI330_Ren525pGroup3;
141 pVBInfo->Ren750pGroup3 = XGI330_Ren750pGroup3;
143 pVBInfo->TimingH = (struct XGI_TimingHStruct *) XGI_TimingH;
144 pVBInfo->TimingV = (struct XGI_TimingVStruct *) XGI_TimingV;
145 pVBInfo->UpdateCRT1 = (struct XGI_XG21CRT1Struct *) XGI_UpdateCRT1Table;
147 pVBInfo->CHTVVCLKUNTSC = XGI330_CHTVVCLKUNTSC;
148 pVBInfo->CHTVVCLKONTSC = XGI330_CHTVVCLKONTSC;
149 pVBInfo->CHTVVCLKUPAL = XGI330_CHTVVCLKUPAL;
150 pVBInfo->CHTVVCLKOPAL = XGI330_CHTVVCLKOPAL;
152 /* 310 customization related */
153 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType & VB_XGI302LV))
154 pVBInfo->LCDCapList = XGI_LCDDLCapList;
156 pVBInfo->LCDCapList = XGI_LCDCapList;
158 if ((ChipType == XG21) || (ChipType == XG27))
159 pVBInfo->XG21_LVDSCapList = XGI21_LCDCapList;
161 pVBInfo->XGI_TVDelayList = XGI301TVDelayList;
162 pVBInfo->XGI_TVDelayList2 = XGI301TVDelayList2;
164 pVBInfo->pXGINew_I2CDefinition = &XG40_I2CDefinition;
166 if (ChipType >= XG20)
167 pVBInfo->pXGINew_CR97 = &XG20_CR97;
169 if (ChipType == XG27) {
171 = (struct XGI_MCLKDataStruct *) XGI27New_MCLKData;
172 pVBInfo->CR40 = XGI27_cr41;
173 pVBInfo->pXGINew_CR97 = &XG27_CR97;
174 pVBInfo->pSR36 = &XG27_SR36;
175 pVBInfo->pCR8F = &XG27_CR8F;
176 pVBInfo->pCRD0 = XG27_CRD0;
177 pVBInfo->pCRDE = XG27_CRDE;
178 pVBInfo->pSR40 = &XG27_SR40;
179 pVBInfo->pSR41 = &XG27_SR41;
183 if (ChipType >= XG20) {
184 pVBInfo->pDVOSetting = &XG21_DVOSetting;
185 pVBInfo->pCR2E = &XG21_CR2E;
186 pVBInfo->pCR2F = &XG21_CR2F;
187 pVBInfo->pCR46 = &XG21_CR46;
188 pVBInfo->pCR47 = &XG21_CR47;
193 static unsigned char XGI_GetModePtr(unsigned short ModeNo,
194 unsigned short ModeIdIndex,
195 struct vb_device_info *pVBInfo)
200 index = pVBInfo->SModeIDTable[ModeIdIndex].St_StTableIndex;
202 if (pVBInfo->ModeType <= 0x02)
203 index = 0x1B; /* 02 -> ModeEGA */
207 return index; /* Get pVBInfo->StandTable index */
211 unsigned char XGI_SetBIOSData(unsigned short ModeNo,
212 unsigned short ModeIdIndex) {
217 /* unsigned char XGI_ClearBankRegs(unsigned short ModeNo,
218 unsigned short ModeIdIndex) {
223 static void XGI_SetSeqRegs(unsigned short ModeNo,
224 unsigned short StandTableIndex,
225 unsigned short ModeIdIndex,
226 struct vb_device_info *pVBInfo)
228 unsigned char tempah, SRdata;
229 unsigned short i, modeflag;
232 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
234 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
236 xgifb_reg_set(pVBInfo->P3c4, 0x00, 0x03); /* Set SR0 */
237 tempah = pVBInfo->StandTable[StandTableIndex].SR[0];
240 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
243 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD)) {
244 if (pVBInfo->VBInfo & SetInSlaveMode)
249 tempah |= 0x20; /* screen off */
250 xgifb_reg_set(pVBInfo->P3c4, 0x01, tempah); /* Set SR1 */
252 for (i = 02; i <= 04; i++) {
253 /* Get SR2,3,4 from file */
254 SRdata = pVBInfo->StandTable[StandTableIndex].SR[i - 1];
255 xgifb_reg_set(pVBInfo->P3c4, i, SRdata); /* Set SR2 3 4 */
259 static void XGI_SetMiscRegs(unsigned short StandTableIndex,
260 struct vb_device_info *pVBInfo)
262 unsigned char Miscdata;
264 /* Get Misc from file */
265 Miscdata = pVBInfo->StandTable[StandTableIndex].MISC;
267 if (pVBInfo->VBType & (VB_XGI301B |
272 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
278 outb(Miscdata, pVBInfo->P3c2); /* Set Misc(3c2) */
281 static void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension,
282 unsigned short StandTableIndex,
283 struct vb_device_info *pVBInfo)
285 unsigned char CRTCdata;
288 CRTCdata = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
290 xgifb_reg_set(pVBInfo->P3d4, 0x11, CRTCdata); /* Unlock CRTC */
292 for (i = 0; i <= 0x18; i++) {
293 /* Get CRTC from file */
294 CRTCdata = pVBInfo->StandTable[StandTableIndex].CRTC[i];
295 xgifb_reg_set(pVBInfo->P3d4, i, CRTCdata); /* Set CRTC(3d4) */
298 if ((HwDeviceExtension->jChipType == XGI_630) &&
299 (HwDeviceExtension->jChipRevision == 0x30)) {
300 if (pVBInfo->VBInfo & SetInSlaveMode) {
301 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) {
302 xgifb_reg_set(pVBInfo->P3d4, 0x18, 0xFE);
309 static void XGI_SetATTRegs(unsigned short ModeNo,
310 unsigned short StandTableIndex,
311 unsigned short ModeIdIndex,
312 struct vb_device_info *pVBInfo)
314 unsigned char ARdata;
315 unsigned short i, modeflag;
318 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
320 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
322 for (i = 0; i <= 0x13; i++) {
323 ARdata = pVBInfo->StandTable[StandTableIndex].ATTR[i];
324 if (modeflag & Charx8Dot) { /* ifndef Dot9 */
326 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
329 if (pVBInfo->VBInfo & (SetCRT2ToTV
331 if (pVBInfo->VBInfo &
339 inb(pVBInfo->P3da); /* reset 3da */
340 outb(i, pVBInfo->P3c0); /* set index */
341 outb(ARdata, pVBInfo->P3c0); /* set data */
344 inb(pVBInfo->P3da); /* reset 3da */
345 outb(0x14, pVBInfo->P3c0); /* set index */
346 outb(0x00, pVBInfo->P3c0); /* set data */
347 inb(pVBInfo->P3da); /* Enable Attribute */
348 outb(0x20, pVBInfo->P3c0);
351 static void XGI_SetGRCRegs(unsigned short StandTableIndex,
352 struct vb_device_info *pVBInfo)
354 unsigned char GRdata;
357 for (i = 0; i <= 0x08; i++) {
358 /* Get GR from file */
359 GRdata = pVBInfo->StandTable[StandTableIndex].GRC[i];
360 xgifb_reg_set(pVBInfo->P3ce, i, GRdata); /* Set GR(3ce) */
363 if (pVBInfo->ModeType > ModeVGA) {
364 GRdata = (unsigned char) xgifb_reg_get(pVBInfo->P3ce, 0x05);
365 GRdata &= 0xBF; /* 256 color disable */
366 xgifb_reg_set(pVBInfo->P3ce, 0x05, GRdata);
370 static void XGI_ClearExt1Regs(struct vb_device_info *pVBInfo)
374 for (i = 0x0A; i <= 0x0E; i++)
375 xgifb_reg_set(pVBInfo->P3c4, i, 0x00); /* Clear SR0A-SR0E */
378 static unsigned char XGI_SetDefaultVCLK(struct vb_device_info *pVBInfo)
381 xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x20);
382 xgifb_reg_set(pVBInfo->P3c4, 0x2B, pVBInfo->VCLKData[0].SR2B);
383 xgifb_reg_set(pVBInfo->P3c4, 0x2C, pVBInfo->VCLKData[0].SR2C);
385 xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x10);
386 xgifb_reg_set(pVBInfo->P3c4, 0x2B, pVBInfo->VCLKData[1].SR2B);
387 xgifb_reg_set(pVBInfo->P3c4, 0x2C, pVBInfo->VCLKData[1].SR2C);
389 xgifb_reg_and(pVBInfo->P3c4, 0x31, ~0x30);
393 static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo,
394 unsigned short ModeIdIndex,
395 unsigned short RefreshRateTableIndex, unsigned short *i,
396 struct vb_device_info *pVBInfo)
398 unsigned short tempax, tempbx, resinfo, modeflag, infoflag;
402 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
404 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
406 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
407 tempbx = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID;
410 if (pVBInfo->IF_DEF_LVDS == 0) {
411 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
412 tempax |= SupportRAMDAC2;
414 if (pVBInfo->VBType & VB_XGI301C)
415 tempax |= SupportCRT2in301C;
419 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
420 tempax |= SupportLCD;
422 if (pVBInfo->LCDResInfo != Panel1280x1024) {
423 if (pVBInfo->LCDResInfo != Panel1280x960) {
424 if (pVBInfo->LCDInfo &
435 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { /* for HiTV */
436 if ((pVBInfo->VBType & VB_XGI301LV) &&
437 (pVBInfo->VBExtInfo == VB_YPbPr1080i)) {
438 tempax |= SupportYPbPr;
439 if (pVBInfo->VBInfo & SetInSlaveMode) {
450 tempax |= SupportHiVisionTV;
451 if (pVBInfo->VBInfo & SetInSlaveMode) {
466 if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO |
470 SetCRT2ToHiVisionTV)) {
473 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
474 | VB_XGI301LV | VB_XGI302LV
476 tempax |= SupportTV1024;
479 if (!(pVBInfo->VBInfo & SetPALTV)) {
480 if (modeflag & NoSupportSimuTV) {
481 if (pVBInfo->VBInfo &
483 if (!(pVBInfo->VBInfo &
492 } else { /* for LVDS */
493 if (pVBInfo->IF_DEF_CH7005 == 1) {
494 if (pVBInfo->VBInfo & SetCRT2ToTV)
495 tempax |= SupportCHTV;
498 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
499 tempax |= SupportLCD;
502 return 0; /* 1024x768 */
504 if (pVBInfo->LCDResInfo < Panel1024x768) {
506 return 0; /* 800x600 */
509 return 0; /* 512x384 */
514 for (; pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID ==
516 infoflag = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].
518 if (infoflag & tempax)
525 for ((*i) = 0;; (*i)++) {
526 infoflag = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].
528 if (pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID
533 if (infoflag & tempax)
539 static void XGI_SetSync(unsigned short RefreshRateTableIndex,
540 struct vb_device_info *pVBInfo)
542 unsigned short sync, temp;
545 sync = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag >> 8;
549 outb(temp, pVBInfo->P3c2); /* Set Misc(3c2) */
552 static void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo,
553 struct xgi_hw_device_info *HwDeviceExtension)
555 unsigned char data, data1, pushax;
558 /* xgifb_reg_set(pVBInfo->P3d4, 0x51, 0); */
559 /* xgifb_reg_set(pVBInfo->P3d4, 0x56, 0); */
560 /* xgifb_reg_and_or(pVBInfo->P3d4, 0x11, 0x7f, 0x00); */
563 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
565 xgifb_reg_set(pVBInfo->P3d4, 0x11, data);
567 data = pVBInfo->TimingH[0].data[0];
568 xgifb_reg_set(pVBInfo->P3d4, 0, data);
570 for (i = 0x01; i <= 0x04; i++) {
571 data = pVBInfo->TimingH[0].data[i];
572 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 1), data);
575 for (i = 0x05; i <= 0x06; i++) {
576 data = pVBInfo->TimingH[0].data[i];
577 xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i + 6), data);
580 j = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0e);
582 data = pVBInfo->TimingH[0].data[7];
585 xgifb_reg_set(pVBInfo->P3c4, 0x0e, data);
587 if (HwDeviceExtension->jChipType >= XG20) {
588 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x04);
590 xgifb_reg_set(pVBInfo->P3d4, 0x04, data);
591 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x05);
597 data = (unsigned char) xgifb_reg_get(pVBInfo->P3c4,
600 xgifb_reg_set(pVBInfo->P3c4, 0x0c, data);
605 xgifb_reg_set(pVBInfo->P3d4, 0x05, data);
606 data = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0e);
612 xgifb_reg_and_or(pVBInfo->P3c4, 0x0e, ~0xE0, data);
616 static void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex,
617 unsigned short ModeNo,
618 struct vb_device_info *pVBInfo)
623 /* xgifb_reg_set(pVBInfo->P3d4, 0x51, 0); */
624 /* xgifb_reg_set(pVBInfo->P3d4, 0x56, 0); */
625 /* xgifb_reg_and_or(pVBInfo->P3d4, 0x11, 0x7f, 0x00); */
627 for (i = 0x00; i <= 0x01; i++) {
628 data = pVBInfo->TimingV[0].data[i];
629 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 6), data);
632 for (i = 0x02; i <= 0x03; i++) {
633 data = pVBInfo->TimingV[0].data[i];
634 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x0e), data);
637 for (i = 0x04; i <= 0x05; i++) {
638 data = pVBInfo->TimingV[0].data[i];
639 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x11), data);
642 j = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0a);
644 data = pVBInfo->TimingV[0].data[6];
647 xgifb_reg_set(pVBInfo->P3c4, 0x0a, data);
649 data = pVBInfo->TimingV[0].data[6];
654 i = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
656 i = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
662 j = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x09);
665 xgifb_reg_set(pVBInfo->P3d4, 0x09, data);
668 static void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
669 unsigned short RefreshRateTableIndex,
670 struct vb_device_info *pVBInfo,
671 struct xgi_hw_device_info *HwDeviceExtension)
673 unsigned char index, data;
677 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
678 index = index & IndexMask;
680 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
682 xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */
684 for (i = 0; i < 8; i++)
685 pVBInfo->TimingH[0].data[i]
686 = pVBInfo->XGINEWUB_CRT1Table[index].CR[i];
688 for (i = 0; i < 7; i++)
689 pVBInfo->TimingV[0].data[i]
690 = pVBInfo->XGINEWUB_CRT1Table[index].CR[i + 8];
692 XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension);
694 XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo);
696 if (pVBInfo->ModeType > 0x03)
697 xgifb_reg_set(pVBInfo->P3d4, 0x14, 0x4F);
700 /* --------------------------------------------------------------------- */
701 /* Function : XGI_SetXG21CRTC */
702 /* Input : Stand or enhance CRTC table */
703 /* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */
704 /* Description : Set LCD timing */
705 /* --------------------------------------------------------------------- */
706 static void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
707 unsigned short RefreshRateTableIndex,
708 struct vb_device_info *pVBInfo)
710 unsigned char StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx;
711 unsigned short Temp1, Temp2, Temp3;
713 if (ModeNo <= 0x13) {
714 StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
716 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[4];
717 /* SR2E [7:0]->HRS */
718 xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax);
719 /* Tempbx: CR05 HRE */
720 Tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[5];
721 Tempbx &= 0x1F; /* Tempbx: HRE[4:0] */
723 Tempcx &= 0xE0; /* Tempcx: HRS[7:5] */
724 Tempdx = Tempcx | Tempbx; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
725 if (Tempbx < (Tempax & 0x1F)) /* IF HRE < HRS */
726 Tempdx |= 0x20; /* Tempdx: HRE = HRE + 0x20 */
727 Tempdx <<= 2; /* Tempdx << 2 */
728 /* SR2F [7:2]->HRE */
729 xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempdx);
730 xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00);
732 /* Tempax: CR16 VRS */
733 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[16];
734 Tempbx = Tempax; /* Tempbx=Tempax */
735 Tempax &= 0x01; /* Tempax: VRS[0] */
736 xgifb_reg_or(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS */
738 /* Tempax: CR7 VRS */
739 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[7];
740 Tempdx = Tempbx >> 1; /* Tempdx: VRS[7:1] */
741 Tempcx = Tempax & 0x04; /* Tempcx: CR7[2] */
742 Tempcx <<= 5; /* Tempcx[7]: VRS[8] */
743 Tempdx |= Tempcx; /* Tempdx: VRS[8:1] */
744 /* SR34[7:0]: VRS[8:1] */
745 xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempdx);
747 /* Temp1[8]: VRS[8] unsigned char -> unsigned short */
749 Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */
750 Tempax &= 0x80; /* Tempax[7]: CR7[7] */
751 Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */
752 Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */
755 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[17];
756 Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
757 Temp2 = Temp1 & 0x3F0; /* Temp2[9:4]: VRS[9:4] */
758 Temp2 |= Tempax; /* Temp2[9:0]: VRE[9:0] */
759 Temp3 = Temp1 & 0x0F; /* Temp3[3:0]: VRS[3:0] */
760 if (Tempax < Temp3) /* VRE[3:0]<VRS[3:0] */
761 Temp2 |= 0x10; /* Temp2: VRE + 0x10 */
762 Temp2 &= 0xFF; /* Temp2[7:0]: VRE[7:0] */
763 Tempax = (unsigned char) Temp2; /* Tempax[7:0]: VRE[7:0] */
764 Tempax <<= 2; /* Tempax << 2: VRE[5:0] */
765 Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */
766 Temp1 >>= 9; /* [10:9]->[1:0] */
767 Tempbx = (unsigned char) Temp1; /* Tempbx[1:0]: VRS[10:9] */
768 Tempax |= Tempbx; /* VRE[5:0]VRS[10:9] */
770 /* SR3F D[7:2]->VRE D[1:0]->VRS */
771 xgifb_reg_set(pVBInfo->P3c4, 0x3F, Tempax);
773 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
774 /* Tempax: CR4 HRS */
775 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3];
776 Tempcx = Tempax; /* Tempcx: HRS */
778 xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax);
780 Tempdx = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SRB */
781 Tempdx &= 0xC0; /* Tempdx[7:6]: SRB[7:6] */
782 Temp1 = Tempdx; /* Temp1[7:6]: HRS[9:8] */
783 Temp1 <<= 2; /* Temp1[9:8]: HRS[9:8] */
784 Temp1 |= Tempax; /* Temp1[9:0]: HRS[9:0] */
786 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */
787 Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */
789 Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[6]; /* SRC */
790 Tempbx &= 0x04; /* Tempbx[2]: HRE[5] */
791 Tempbx <<= 3; /* Tempbx[5]: HRE[5] */
792 Tempax |= Tempbx; /* Tempax[5:0]: HRE[5:0] */
794 Temp2 = Temp1 & 0x3C0; /* Temp2[9:6]: HRS[9:6] */
795 Temp2 |= Tempax; /* Temp2[9:0]: HRE[9:0] */
797 Tempcx &= 0x3F; /* Tempcx[5:0]: HRS[5:0] */
798 if (Tempax < Tempcx) /* HRE < HRS */
799 Temp2 |= 0x40; /* Temp2 + 0x40 */
802 Tempax = (unsigned char) Temp2; /* Tempax: HRE[7:0] */
803 Tempax <<= 2; /* Tempax[7:2]: HRE[5:0] */
804 Tempdx >>= 6; /* Tempdx[7:6]->[1:0] HRS[9:8] */
805 Tempax |= Tempdx; /* HRE[5:0]HRS[9:8] */
806 /* SR2F D[7:2]->HRE, D[1:0]->HRS */
807 xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax);
808 xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00);
811 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10];
812 Tempbx = Tempax; /* Tempbx: VRS */
813 Tempax &= 0x01; /* Tempax[0]: VRS[0] */
814 xgifb_reg_or(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS[0] */
816 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9];
817 Tempcx = Tempbx >> 1; /* Tempcx[6:0]: VRS[7:1] */
818 Tempdx = Tempax & 0x04; /* Tempdx[2]: CR7[2] */
819 Tempdx <<= 5; /* Tempdx[7]: VRS[8] */
820 Tempcx |= Tempdx; /* Tempcx[7:0]: VRS[8:1] */
821 xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempcx); /* SR34[8:1]->VRS */
823 Temp1 = Tempdx; /* Temp1[7]: Tempdx[7] */
824 Temp1 <<= 1; /* Temp1[8]: VRS[8] */
825 Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */
827 Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */
828 Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */
830 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14];
831 Tempax &= 0x08; /* Tempax[3]: VRS[3] */
833 Temp2 <<= 7; /* Temp2[10]: VRS[10] */
834 Temp1 |= Temp2; /* Temp1[10:0]: VRS[10:0] */
836 /* Tempax: CR11 VRE */
837 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11];
838 Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
840 Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14];
841 Tempbx &= 0x20; /* Tempbx[5]: VRE[5] */
842 Tempbx >>= 1; /* Tempbx[4]: VRE[4] */
843 Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */
844 Temp2 = Temp1 & 0x7E0; /* Temp2[10:5]: VRS[10:5] */
845 Temp2 |= Tempax; /* Temp2[10:5]: VRE[10:5] */
847 Temp3 = Temp1 & 0x1F; /* Temp3[4:0]: VRS[4:0] */
848 if (Tempax < Temp3) /* VRE < VRS */
849 Temp2 |= 0x20; /* VRE + 0x20 */
852 Tempax = (unsigned char) Temp2; /* Tempax: VRE[7:0] */
853 Tempax <<= 2; /* Tempax[7:0]; VRE[5:0]00 */
854 Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */
855 Temp1 >>= 9; /* Temp1[1:0]: VRS[10:9] */
856 Tempbx = (unsigned char) Temp1;
857 Tempax |= Tempbx; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */
859 /* SR3F D[7:2]->VRE D[1:0]->VRS */
860 xgifb_reg_set(pVBInfo->P3c4, 0x3F, Tempax);
864 static void XGI_SetXG27CRTC(unsigned short ModeNo,
865 unsigned short ModeIdIndex,
866 unsigned short RefreshRateTableIndex,
867 struct vb_device_info *pVBInfo)
869 unsigned short StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx;
871 if (ModeNo <= 0x13) {
872 StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
874 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[4];
875 /* SR2E [7:0]->HRS */
876 xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax);
877 /* Tempbx: CR05 HRE */
878 Tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[5];
879 Tempbx &= 0x1F; /* Tempbx: HRE[4:0] */
881 Tempcx &= 0xE0; /* Tempcx: HRS[7:5] */
882 Tempdx = Tempcx | Tempbx; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
883 if (Tempbx < (Tempax & 0x1F)) /* IF HRE < HRS */
884 Tempdx |= 0x20; /* Tempdx: HRE = HRE + 0x20 */
885 Tempdx <<= 2; /* Tempdx << 2 */
886 /* SR2F [7:2]->HRE */
887 xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempdx);
888 xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00);
890 /* Tempax: CR10 VRS */
891 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[16];
892 xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempax); /* SR34[7:0]->VRS */
893 Tempcx = Tempax; /* Tempcx=Tempax=VRS[7:0] */
894 /* Tempax[7][2]: CR7[7][2] VRS[9][8] */
895 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[7];
896 Tempbx = Tempax; /* Tempbx=CR07 */
897 Tempax &= 0x04; /* Tempax[2]: CR07[2] VRS[8] */
899 /* SR35 D[0]->VRS D[8] */
900 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x01, Tempax);
901 Tempcx |= (Tempax << 8); /* Tempcx[8] |= VRS[8] */
902 Tempcx |= (Tempbx & 0x80) << 2; /* Tempcx[9] |= VRS[9] */
905 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[17];
906 Tempax &= 0x0F; /* Tempax: VRE[3:0] */
907 Tempbx = Tempcx; /* Tempbx=Tempcx=VRS[9:0] */
908 Tempbx &= 0x3F0; /* Tempbx[9:4]: VRS[9:4] */
909 Tempbx |= Tempax; /* Tempbx[9:0]: VRE[9:0] */
910 if (Tempax <= (Tempcx & 0x0F)) /* VRE[3:0]<=VRS[3:0] */
911 Tempbx |= 0x10; /* Tempbx: VRE + 0x10 */
912 /* Tempax[7:0]: VRE[7:0] */
913 Tempax = (unsigned char) Tempbx & 0xFF;
914 Tempax <<= 2; /* Tempax << 2: VRE[5:0] */
915 Tempcx = (Tempcx & 0x600) >> 8; /* Tempcx VRS[10:9] */
916 /* SR3F D[7:2]->VRE D[5:0] */
917 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax);
918 /* SR35 D[2:1]->VRS[10:9] */
919 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x06, Tempcx);
921 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
922 /* Tempax: CR4 HRS */
923 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3];
924 Tempbx = Tempax; /* Tempbx: HRS[7:0] */
926 xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax);
929 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5];
930 Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
931 Tempbx |= (Tempax << 2); /* Tempbx: HRS[9:0] */
933 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */
934 Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */
935 Tempcx = Tempax; /* Tempcx: HRE[4:0] */
937 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[6]; /* SRC */
938 Tempax &= 0x04; /* Tempax[2]: HRE[5] */
939 Tempax <<= 3; /* Tempax[5]: HRE[5] */
940 Tempcx |= Tempax; /* Tempcx[5:0]: HRE[5:0] */
942 Tempbx = Tempbx & 0x3C0; /* Tempbx[9:6]: HRS[9:6] */
943 Tempbx |= Tempcx; /* Tempbx: HRS[9:6]HRE[5:0] */
945 /* Tempax: CR4 HRS */
946 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3];
947 Tempax &= 0x3F; /* Tempax: HRS[5:0] */
948 if (Tempcx <= Tempax) /* HRE[5:0] < HRS[5:0] */
949 Tempbx += 0x40; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/
951 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SR0B */
952 Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
953 Tempax >>= 6; /* Tempax[1:0]: HRS[9:8]*/
954 Tempax |= ((Tempbx << 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */
955 /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */
956 xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax);
957 xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00);
960 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10];
961 /* SR34[7:0]->VRS[7:0] */
962 xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempax);
964 Tempcx = Tempax; /* Tempcx <= VRS[7:0] */
965 /* CR7[7][2] VRS[9][8] */
966 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9];
967 Tempbx = Tempax; /* Tempbx <= CR07[7:0] */
968 Tempax = Tempax & 0x04; /* Tempax[2]: CR7[2]: VRS[8] */
969 Tempax >>= 2; /* Tempax[0]: VRS[8] */
970 /* SR35[0]: VRS[8] */
971 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x01, Tempax);
972 Tempcx |= (Tempax << 8); /* Tempcx <= VRS[8:0] */
973 Tempcx |= ((Tempbx & 0x80) << 2); /* Tempcx <= VRS[9:0] */
975 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14];
976 Tempax &= 0x08; /* SR0A[3] VRS[10] */
977 Tempcx |= (Tempax << 7); /* Tempcx <= VRS[10:0] */
979 /* Tempax: CR11 VRE */
980 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11];
981 Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
983 Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14];
984 Tempbx &= 0x20; /* Tempbx[5]: SR0A[5]: VRE[4] */
985 Tempbx >>= 1; /* Tempbx[4]: VRE[4] */
986 Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */
987 Tempbx = Tempcx; /* Tempbx: VRS[10:0] */
988 Tempbx &= 0x7E0; /* Tempbx[10:5]: VRS[10:5] */
989 Tempbx |= Tempax; /* Tempbx: VRS[10:5]VRE[4:0] */
991 if (Tempbx <= Tempcx) /* VRE <= VRS */
992 Tempbx |= 0x20; /* VRE + 0x20 */
994 /* Tempax: Tempax[7:0]; VRE[5:0]00 */
995 Tempax = (Tempbx << 2) & 0xFF;
996 /* SR3F[7:2]:VRE[5:0] */
997 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax);
998 Tempax = Tempcx >> 8;
999 /* SR35[2:0]:VRS[10:8] */
1000 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, Tempax);
1004 /* --------------------------------------------------------------------- */
1005 /* Function : XGI_SetXG21LCD */
1007 /* Output : FCLK duty cycle, FCLK delay compensation */
1008 /* Description : All values set zero */
1009 /* --------------------------------------------------------------------- */
1010 static void XGI_SetXG21LCD(struct vb_device_info *pVBInfo,
1011 unsigned short RefreshRateTableIndex, unsigned short ModeNo)
1013 unsigned short Data, Temp, b3CC;
1014 unsigned short XGI_P3cc;
1016 XGI_P3cc = pVBInfo->P3cc;
1018 xgifb_reg_set(pVBInfo->P3d4, 0x2E, 0x00);
1019 xgifb_reg_set(pVBInfo->P3d4, 0x2F, 0x00);
1020 xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x00);
1021 xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x00);
1022 if (((*pVBInfo->pDVOSetting) & 0xC0) == 0xC0) {
1023 xgifb_reg_set(pVBInfo->P3d4, 0x2E, *pVBInfo->pCR2E);
1024 xgifb_reg_set(pVBInfo->P3d4, 0x2F, *pVBInfo->pCR2F);
1025 xgifb_reg_set(pVBInfo->P3d4, 0x46, *pVBInfo->pCR46);
1026 xgifb_reg_set(pVBInfo->P3d4, 0x47, *pVBInfo->pCR47);
1029 Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
1032 xgifb_reg_or(pVBInfo->P3c4, 0x06, 0x40); /* 18 bits FP */
1033 xgifb_reg_or(pVBInfo->P3c4, 0x09, 0x40);
1036 xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */
1038 xgifb_reg_and(pVBInfo->P3c4, 0x30, ~0x20);
1039 xgifb_reg_and(pVBInfo->P3c4, 0x35, ~0x80);
1041 if (ModeNo <= 0x13) {
1042 b3CC = (unsigned char) inb(XGI_P3cc);
1044 /* Hsync polarity */
1045 xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20);
1047 /* Vsync polarity */
1048 xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80);
1050 Data = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1052 /* Hsync polarity */
1053 xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20);
1055 /* Vsync polarity */
1056 xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80);
1060 static void XGI_SetXG27LCD(struct vb_device_info *pVBInfo,
1061 unsigned short RefreshRateTableIndex,
1062 unsigned short ModeNo)
1064 unsigned short Data, Temp, b3CC;
1065 unsigned short XGI_P3cc;
1067 XGI_P3cc = pVBInfo->P3cc;
1069 xgifb_reg_set(pVBInfo->P3d4, 0x2E, 0x00);
1070 xgifb_reg_set(pVBInfo->P3d4, 0x2F, 0x00);
1071 xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x00);
1072 xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x00);
1074 Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
1075 if ((Temp & 0x03) == 0) { /* dual 12 */
1076 xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x13);
1077 xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x13);
1080 if (((*pVBInfo->pDVOSetting) & 0xC0) == 0xC0) {
1081 xgifb_reg_set(pVBInfo->P3d4, 0x2E, *pVBInfo->pCR2E);
1082 xgifb_reg_set(pVBInfo->P3d4, 0x2F, *pVBInfo->pCR2F);
1083 xgifb_reg_set(pVBInfo->P3d4, 0x46, *pVBInfo->pCR46);
1084 xgifb_reg_set(pVBInfo->P3d4, 0x47, *pVBInfo->pCR47);
1087 XGI_SetXG27FPBits(pVBInfo);
1089 xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */
1091 xgifb_reg_and(pVBInfo->P3c4, 0x30, ~0x20); /* Hsync polarity */
1092 xgifb_reg_and(pVBInfo->P3c4, 0x35, ~0x80); /* Vsync polarity */
1094 if (ModeNo <= 0x13) {
1095 b3CC = (unsigned char) inb(XGI_P3cc);
1097 /* Hsync polarity */
1098 xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20);
1100 /* Vsync polarity */
1101 xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80);
1103 Data = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1105 /* Hsync polarity */
1106 xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20);
1108 /* Vsync polarity */
1109 xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80);
1113 /* --------------------------------------------------------------------- */
1114 /* Function : XGI_UpdateXG21CRTC */
1116 /* Output : CRT1 CRTC */
1117 /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */
1118 /* --------------------------------------------------------------------- */
1119 static void XGI_UpdateXG21CRTC(unsigned short ModeNo,
1120 struct vb_device_info *pVBInfo,
1121 unsigned short RefreshRateTableIndex)
1125 xgifb_reg_and(pVBInfo->P3d4, 0x11, 0x7F); /* Unlock CR0~7 */
1126 if (ModeNo <= 0x13) {
1127 for (i = 0; i < 12; i++) {
1128 if (ModeNo == pVBInfo->UpdateCRT1[i].ModeID)
1132 if (ModeNo == 0x2E &&
1133 (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC ==
1136 else if (ModeNo == 0x2E &&
1137 (pVBInfo->RefIndex[RefreshRateTableIndex].
1138 Ext_CRT1CRTC == RES640x480x72))
1140 else if (ModeNo == 0x2F)
1142 else if (ModeNo == 0x50)
1144 else if (ModeNo == 0x59)
1149 xgifb_reg_set(pVBInfo->P3d4, 0x02,
1150 pVBInfo->UpdateCRT1[index].CR02);
1151 xgifb_reg_set(pVBInfo->P3d4, 0x03,
1152 pVBInfo->UpdateCRT1[index].CR03);
1153 xgifb_reg_set(pVBInfo->P3d4, 0x15,
1154 pVBInfo->UpdateCRT1[index].CR15);
1155 xgifb_reg_set(pVBInfo->P3d4, 0x16,
1156 pVBInfo->UpdateCRT1[index].CR16);
1160 static void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension,
1161 unsigned short ModeNo, unsigned short ModeIdIndex,
1162 unsigned short RefreshRateTableIndex,
1163 struct vb_device_info *pVBInfo)
1165 unsigned short resindex, tempax, tempbx, tempcx, temp, modeflag;
1169 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
1171 if (ModeNo <= 0x13) {
1172 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
1173 tempax = pVBInfo->StResInfo[resindex].HTotal;
1174 tempbx = pVBInfo->StResInfo[resindex].VTotal;
1176 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1177 tempax = pVBInfo->ModeResInfo[resindex].HTotal;
1178 tempbx = pVBInfo->ModeResInfo[resindex].VTotal;
1181 if (modeflag & HalfDCLK)
1182 tempax = tempax >> 1;
1184 if (ModeNo > 0x13) {
1185 if (modeflag & HalfDCLK)
1186 tempax = tempax << 1;
1188 temp = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1190 if (temp & InterlaceMode)
1191 tempbx = tempbx >> 1;
1193 if (modeflag & DoubleScanMode)
1194 tempbx = tempbx << 1;
1199 /* if (!(modeflag & Charx8Dot)) */
1206 temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
1207 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
1209 xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */
1210 xgifb_reg_set(pVBInfo->P3d4, 0x01, (unsigned short) (tempcx & 0xff));
1211 xgifb_reg_and_or(pVBInfo->P3d4, 0x0b, ~0x0c,
1212 (unsigned short) ((tempcx & 0x0ff00) >> 10));
1213 xgifb_reg_set(pVBInfo->P3d4, 0x12, (unsigned short) (tempbx & 0xff));
1215 tempbx = tempbx >> 8;
1223 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x42, tempax);
1224 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x07);
1231 xgifb_reg_and_or(pVBInfo->P3d4, 0x0a, ~0x02, tempax);
1232 xgifb_reg_set(pVBInfo->P3d4, 0x11, temp);
1235 unsigned short XGI_GetResInfo(unsigned short ModeNo,
1236 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
1238 unsigned short resindex;
1242 resindex = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
1244 /* si+Ext_ResInfo */
1245 resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
1249 static void XGI_SetCRT1Offset(unsigned short ModeNo,
1250 unsigned short ModeIdIndex,
1251 unsigned short RefreshRateTableIndex,
1252 struct xgi_hw_device_info *HwDeviceExtension,
1253 struct vb_device_info *pVBInfo)
1255 unsigned short temp, ah, al, temp2, i, DisplayUnit;
1258 temp = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo;
1260 temp = pVBInfo->ScreenOffset[temp];
1262 temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1263 temp2 &= InterlaceMode;
1268 temp2 = pVBInfo->ModeType - ModeEGA;
1293 if ((ModeNo >= 0x26) && (ModeNo <= 0x28))
1294 temp = temp * temp2 + temp2 / 2;
1301 temp = temp >> 8; /* ah */
1303 i = xgifb_reg_get(pVBInfo->P3c4, 0x0E);
1306 xgifb_reg_set(pVBInfo->P3c4, 0x0E, i);
1308 temp = (unsigned char) temp2;
1309 temp &= 0xFF; /* al */
1310 xgifb_reg_set(pVBInfo->P3d4, 0x13, temp);
1312 /* SetDisplayUnit */
1313 temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1314 temp2 &= InterlaceMode;
1318 DisplayUnit = DisplayUnit << 5;
1319 ah = (DisplayUnit & 0xff00) >> 8;
1320 al = DisplayUnit & 0x00ff;
1326 if (HwDeviceExtension->jChipType >= XG20)
1327 if ((ModeNo == 0x4A) | (ModeNo == 0x49))
1330 xgifb_reg_set(pVBInfo->P3c4, 0x10, ah);
1333 static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo,
1334 unsigned short ModeIdIndex,
1335 unsigned short RefreshRateTableIndex,
1336 struct xgi_hw_device_info *HwDeviceExtension,
1337 struct vb_device_info *pVBInfo)
1339 unsigned short tempbx;
1341 unsigned short LCDXlat1VCLK[4] = { VCLK65 + 2,
1345 unsigned short LCDXlat2VCLK[4] = { VCLK108_2 + 5,
1349 unsigned short LVDSXlat1VCLK[4] = { VCLK40, VCLK40, VCLK40, VCLK40 };
1350 unsigned short LVDSXlat2VCLK[4] = { VCLK65 + 2,
1354 unsigned short LVDSXlat3VCLK[4] = { VCLK65 + 2,
1359 unsigned short CRT2Index, VCLKIndex;
1360 unsigned short modeflag, resinfo;
1361 unsigned char *CHTVVCLKPtr = NULL;
1363 if (ModeNo <= 0x13) {
1365 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
1366 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
1367 CRT2Index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
1369 /* si+Ext_ResInfo */
1370 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1371 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
1372 CRT2Index = pVBInfo->RefIndex[RefreshRateTableIndex].
1376 if (pVBInfo->IF_DEF_LVDS == 0) {
1377 CRT2Index = CRT2Index >> 6; /* for LCD */
1378 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { /*301b*/
1379 if (pVBInfo->LCDResInfo != Panel1024x768)
1380 VCLKIndex = LCDXlat2VCLK[CRT2Index];
1382 VCLKIndex = LCDXlat1VCLK[CRT2Index];
1383 } else { /* for TV */
1384 if (pVBInfo->VBInfo & SetCRT2ToTV) {
1385 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
1386 if (pVBInfo->SetFlag & RPLLDIV2XO) {
1387 VCLKIndex = HiTVVCLKDIV2;
1390 VCLKIndex = HiTVVCLK;
1394 if (pVBInfo->SetFlag & TVSimuMode) {
1395 if (modeflag & Charx8Dot) {
1407 if (pVBInfo->VBType & VB_XGI301LV) {
1408 if (!(pVBInfo->VBExtInfo ==
1412 if (!(pVBInfo->VBExtInfo
1417 if (!(pVBInfo->VBExtInfo
1421 if (!(pVBInfo->SetFlag
1430 if (pVBInfo->VBInfo & SetCRT2ToTV) {
1431 if (pVBInfo->SetFlag &
1433 VCLKIndex = TVVCLKDIV2;
1441 } else { /* for CRT2 */
1443 VCLKIndex = (unsigned char) inb(
1444 (pVBInfo->P3ca + 0x02));
1445 VCLKIndex = ((VCLKIndex >> 2) & 0x03);
1446 if (ModeNo > 0x13) {
1447 /* di+Ext_CRTVCLK */
1450 RefreshRateTableIndex].
1452 VCLKIndex &= IndexMask;
1458 VCLKIndex = CRT2Index;
1460 VCLKIndex = CRT2Index;
1462 if (pVBInfo->IF_DEF_CH7005 == 1) {
1463 if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) {
1467 if (pVBInfo->VBInfo & SetPALTV)
1470 if (pVBInfo->VBInfo & SetCHTVOverScan)
1475 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC;
1478 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC;
1481 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL;
1484 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL;
1490 VCLKIndex = CHTVVCLKPtr[VCLKIndex];
1493 VCLKIndex = VCLKIndex >> 6;
1494 if ((pVBInfo->LCDResInfo == Panel800x600) ||
1495 (pVBInfo->LCDResInfo == Panel320x480))
1496 VCLKIndex = LVDSXlat1VCLK[VCLKIndex];
1497 else if ((pVBInfo->LCDResInfo == Panel1024x768) ||
1498 (pVBInfo->LCDResInfo == Panel1024x768x75))
1499 VCLKIndex = LVDSXlat2VCLK[VCLKIndex];
1501 VCLKIndex = LVDSXlat3VCLK[VCLKIndex];
1504 /* VCLKIndex = VCLKIndex&IndexMask; */
1509 static void XGI_SetCRT1VCLK(unsigned short ModeNo,
1510 unsigned short ModeIdIndex,
1511 struct xgi_hw_device_info *HwDeviceExtension,
1512 unsigned short RefreshRateTableIndex,
1513 struct vb_device_info *pVBInfo)
1515 unsigned char index, data;
1516 unsigned short vclkindex;
1518 if (pVBInfo->IF_DEF_LVDS == 1) {
1519 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1520 data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF;
1521 xgifb_reg_set(pVBInfo->P3c4, 0x31, data);
1522 xgifb_reg_set(pVBInfo->P3c4, 0x2B,
1523 pVBInfo->VCLKData[index].SR2B);
1524 xgifb_reg_set(pVBInfo->P3c4, 0x2C,
1525 pVBInfo->VCLKData[index].SR2C);
1526 xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01);
1527 } else if ((pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
1528 | VB_XGI302LV | VB_XGI301C)) && (pVBInfo->VBInfo
1530 vclkindex = XGI_GetVCLK2Ptr(ModeNo, ModeIdIndex,
1531 RefreshRateTableIndex, HwDeviceExtension,
1533 data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF;
1534 xgifb_reg_set(pVBInfo->P3c4, 0x31, data);
1535 data = pVBInfo->VBVCLKData[vclkindex].Part4_A;
1536 xgifb_reg_set(pVBInfo->P3c4, 0x2B, data);
1537 data = pVBInfo->VBVCLKData[vclkindex].Part4_B;
1538 xgifb_reg_set(pVBInfo->P3c4, 0x2C, data);
1539 xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01);
1541 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1542 data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF;
1543 xgifb_reg_set(pVBInfo->P3c4, 0x31, data);
1544 xgifb_reg_set(pVBInfo->P3c4, 0x2B,
1545 pVBInfo->VCLKData[index].SR2B);
1546 xgifb_reg_set(pVBInfo->P3c4, 0x2C,
1547 pVBInfo->VCLKData[index].SR2C);
1548 xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01);
1551 if (HwDeviceExtension->jChipType >= XG20) {
1552 if (pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag &
1554 data = xgifb_reg_get(pVBInfo->P3c4, 0x2B);
1555 xgifb_reg_set(pVBInfo->P3c4, 0x2B, data);
1556 data = xgifb_reg_get(pVBInfo->P3c4, 0x2C);
1563 xgifb_reg_set(pVBInfo->P3c4, 0x2C, data);
1568 static void XGI_SetCRT1FIFO(unsigned short ModeNo,
1569 struct xgi_hw_device_info *HwDeviceExtension,
1570 struct vb_device_info *pVBInfo)
1572 unsigned short data;
1574 data = xgifb_reg_get(pVBInfo->P3c4, 0x3D);
1576 xgifb_reg_set(pVBInfo->P3c4, 0x3D, data); /* diable auto-threshold */
1578 if (ModeNo > 0x13) {
1579 xgifb_reg_set(pVBInfo->P3c4, 0x08, 0x34);
1580 data = xgifb_reg_get(pVBInfo->P3c4, 0x09);
1582 xgifb_reg_set(pVBInfo->P3c4, 0x09, data | 0x30);
1583 data = xgifb_reg_get(pVBInfo->P3c4, 0x3D);
1585 xgifb_reg_set(pVBInfo->P3c4, 0x3D, data);
1587 if (HwDeviceExtension->jChipType == XG27) {
1588 xgifb_reg_set(pVBInfo->P3c4, 0x08, 0x0E);
1589 data = xgifb_reg_get(pVBInfo->P3c4, 0x09);
1591 xgifb_reg_set(pVBInfo->P3c4, 0x09, data | 0x20);
1593 xgifb_reg_set(pVBInfo->P3c4, 0x08, 0xAE);
1594 data = xgifb_reg_get(pVBInfo->P3c4, 0x09);
1596 xgifb_reg_set(pVBInfo->P3c4, 0x09, data);
1600 if (HwDeviceExtension->jChipType == XG21)
1601 XGI_SetXG21FPBits(pVBInfo); /* Fix SR9[7:6] can't read back */
1604 static void XGI_SetVCLKState(struct xgi_hw_device_info *HwDeviceExtension,
1605 unsigned short ModeNo, unsigned short RefreshRateTableIndex,
1606 struct vb_device_info *pVBInfo)
1608 unsigned short data, data2 = 0;
1611 unsigned char index;
1616 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1618 VCLK = pVBInfo->VCLKData[index].CLOCK;
1621 data = xgifb_reg_get(pVBInfo->P3c4, 0x32);
1624 data |= 0x0c; /* VCLK > 200 */
1626 if (HwDeviceExtension->jChipType >= XG20)
1627 data &= ~0x04; /* 2 pixel mode */
1629 xgifb_reg_set(pVBInfo->P3c4, 0x32, data);
1631 if (HwDeviceExtension->jChipType < XG20) {
1632 data = xgifb_reg_get(pVBInfo->P3c4, 0x1F);
1636 xgifb_reg_set(pVBInfo->P3c4, 0x1F, data);
1639 /* Jong for Adavantech LCD ripple issue
1640 if ((VCLK >= 0) && (VCLK < 135))
1642 else if ((VCLK >= 135) && (VCLK < 160))
1644 else if ((VCLK >= 160) && (VCLK < 260))
1646 else if (VCLK > 260)
1651 xgifb_reg_and_or(pVBInfo->P3c4, 0x07, 0xFC, data2);
1652 if (HwDeviceExtension->jChipType >= XG27)
1653 xgifb_reg_and_or(pVBInfo->P3c4, 0x40, 0xFC, data2 & 0x03);
1657 static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension,
1658 unsigned short ModeNo, unsigned short ModeIdIndex,
1659 unsigned short RefreshRateTableIndex,
1660 struct vb_device_info *pVBInfo)
1662 unsigned short data, data2, data3, infoflag = 0, modeflag, resindex,
1665 if (ModeNo > 0x13) {
1666 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1667 infoflag = pVBInfo->RefIndex[RefreshRateTableIndex].
1670 /* si+St_ModeFlag */
1671 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
1673 if (xgifb_reg_get(pVBInfo->P3d4, 0x31) & 0x01)
1674 xgifb_reg_and_or(pVBInfo->P3c4, 0x1F, 0x3F, 0x00);
1683 if (ModeNo > 0x13) {
1684 if (pVBInfo->ModeType > 0x02) {
1686 data3 = pVBInfo->ModeType - ModeVGA;
1692 data &= InterlaceMode;
1697 xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x3F, data2);
1698 /* xgifb_reg_set(pVBInfo->P3c4,0x06,data2); */
1699 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
1701 xres = pVBInfo->StResInfo[resindex].HTotal;
1703 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
1706 if (infoflag & InterlaceMode) {
1709 else if (xres == 1280)
1713 data2 = data & 0x00FF;
1714 xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFF, data2);
1715 data2 = (data & 0xFF00) >> 8;
1716 xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFC, data2);
1718 if (modeflag & HalfDCLK)
1719 xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xF7, 0x08);
1723 if (modeflag & LineCompareOff)
1726 if (ModeNo > 0x13) {
1727 if (pVBInfo->ModeType == ModeEGA)
1731 xgifb_reg_and_or(pVBInfo->P3c4, 0x0F, ~0x48, data2);
1733 if (pVBInfo->ModeType != ModeText) {
1735 if (pVBInfo->ModeType != ModeEGA)
1738 xgifb_reg_and_or(pVBInfo->P3c4, 0x21, 0x1F, data);
1740 XGI_SetVCLKState(HwDeviceExtension, ModeNo, RefreshRateTableIndex,
1743 /* if (modeflag&HalfDCLK) //030305 fix lowresolution bug */
1744 /* if (XGINew_IF_DEF_NEW_LOWRES) */
1745 /* XGI_VesaLowResolution(ModeNo, ModeIdIndex);
1746 * //030305 fix lowresolution bug */
1748 data = xgifb_reg_get(pVBInfo->P3d4, 0x31);
1750 if (HwDeviceExtension->jChipType == XG27) {
1755 xgifb_reg_set(pVBInfo->P3d4, 0x52, data);
1756 xgifb_reg_or(pVBInfo->P3d4, 0x51, 0x10);
1757 } else if (HwDeviceExtension->jChipType >= XG20) {
1762 xgifb_reg_set(pVBInfo->P3d4, 0x52, data);
1763 xgifb_reg_set(pVBInfo->P3d4, 0x51, 0x02);
1769 xgifb_reg_set(pVBInfo->P3d4, 0x52, data);
1775 void XGI_VesaLowResolution(unsigned short ModeNo,
1776 unsigned short ModeIdIndex,
1777 struct vb_device_info *pVBInfo)
1779 unsigned short modeflag;
1782 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1784 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
1786 if (ModeNo > 0x13) {
1787 if (modeflag & DoubleScanMode) {
1788 if (modeflag & HalfDCLK) {
1789 if (pVBInfo->VBType & VB_XGI301B |
1794 if (!(pVBInfo->VBInfo &
1796 if (pVBInfo->VBInfo &
1812 xgifb_reg_and_or(pVBInfo->P3c4,
1816 xgifb_reg_and_or(pVBInfo->P3c4,
1824 xgifb_reg_and_or(pVBInfo->P3c4, 0x0f, 0x7f, 0x00);
1828 static void XGI_WriteDAC(unsigned short dl,
1832 struct vb_device_info *pVBInfo)
1834 unsigned short temp, bh, bl;
1853 outb((unsigned short) dh, pVBInfo->P3c9);
1854 outb((unsigned short) bh, pVBInfo->P3c9);
1855 outb((unsigned short) bl, pVBInfo->P3c9);
1858 static void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex,
1859 struct vb_device_info *pVBInfo)
1861 unsigned short data, data2, time, i, j, k, m, n, o, si, di, bx, dl, al,
1862 ah, dh, *table = NULL;
1865 data = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
1867 data = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1869 data &= DACInfoFlag;
1873 table = XGINew_MDA_DAC;
1874 else if (data == 0x08)
1875 table = XGINew_CGA_DAC;
1876 else if (data == 0x10)
1877 table = XGINew_EGA_DAC;
1878 else if (data == 0x18) {
1880 table = XGINew_VGA_DAC;
1888 outb(0xFF, pVBInfo->P3c6);
1889 outb(0x00, pVBInfo->P3c8);
1891 for (i = 0; i < j; i++) {
1894 for (k = 0; k < 3; k++) {
1903 outb(data2, pVBInfo->P3c9);
1909 for (i = 16; i < 32; i++) {
1912 for (k = 0; k < 3; k++)
1913 outb(data, pVBInfo->P3c9);
1918 for (m = 0; m < 9; m++) {
1923 for (n = 0; n < 3; n++) {
1924 for (o = 0; o < 5; o++) {
1929 XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
1934 for (o = 0; o < 3; o++) {
1939 XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
1950 static void XGI_GetLVDSResInfo(unsigned short ModeNo,
1951 unsigned short ModeIdIndex,
1952 struct vb_device_info *pVBInfo)
1954 unsigned short resindex, xres, yres, modeflag;
1958 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
1960 /* si+Ext_ResInfo */
1961 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
1963 /* if (ModeNo > 0x13) */
1964 /* modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; */
1966 /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; */
1970 resindex = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
1972 /* si+Ext_ResInfo */
1973 resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
1975 /* resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); */
1977 if (ModeNo <= 0x13) {
1978 xres = pVBInfo->StResInfo[resindex].HTotal;
1979 yres = pVBInfo->StResInfo[resindex].VTotal;
1981 xres = pVBInfo->ModeResInfo[resindex].HTotal;
1982 yres = pVBInfo->ModeResInfo[resindex].VTotal;
1984 if (ModeNo > 0x13) {
1985 if (modeflag & HalfDCLK)
1988 if (modeflag & DoubleScanMode)
1991 /* if (modeflag & Charx8Dot) */
1998 pVBInfo->VGAHDE = xres;
1999 pVBInfo->HDE = xres;
2000 pVBInfo->VGAVDE = yres;
2001 pVBInfo->VDE = yres;
2004 static void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo,
2005 unsigned short ModeIdIndex,
2006 unsigned short RefreshRateTableIndex,
2007 struct vb_device_info *pVBInfo)
2009 unsigned short i, tempdx, tempcx, tempbx, tempal, modeflag, table;
2011 struct XGI330_LCDDataTablStruct *tempdi = NULL;
2015 if (ModeNo <= 0x13) {
2016 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
2017 tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
2019 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2020 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
2023 tempal = tempal & 0x0f;
2025 if (tempbx <= 1) { /* ExpLink */
2026 if (ModeNo <= 0x13) {
2027 /* find no Ext_CRT2CRTC2 */
2028 tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
2030 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].
2034 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
2036 tempal = pVBInfo->SModeIDTable[ModeIdIndex].
2039 tempal = pVBInfo->RefIndex[
2040 RefreshRateTableIndex].
2045 tempal = (tempal >> 4);
2047 tempal = (tempal & 0x0f);
2050 tempcx = LCDLenList[tempbx]; /* mov cl,byte ptr cs:LCDLenList[bx] */
2052 if (pVBInfo->LCDInfo & EnableScalingLCD) { /* ScaleLCD */
2053 if ((tempbx == 5) || (tempbx) == 7)
2054 tempcx = LCDDesDataLen2;
2055 else if ((tempbx == 3) || (tempbx == 8))
2056 tempcx = LVDSDesDataLen2;
2058 /* mov di, word ptr cs:LCDDataList[bx] */
2059 /* tempdi = pVideoMemory[LCDDataList + tempbx * 2] |
2060 (pVideoMemory[LCDDataList + tempbx * 2 + 1] << 8); */
2064 tempdi = XGI_EPLLCDCRT1Ptr_H;
2067 tempdi = XGI_EPLLCDCRT1Ptr_V;
2070 tempdi = XGI_EPLLCDDataPtr;
2073 tempdi = XGI_EPLLCDDesDataPtr;
2076 tempdi = XGI_LCDDataTable;
2079 tempdi = XGI_LCDDesDataTable;
2082 tempdi = XGI_EPLCHLCDRegPtr;
2093 if (tempdi == NULL) /* OEMUtil */
2099 while (tempdi[i].PANELID != 0xff) {
2100 tempdx = pVBInfo->LCDResInfo;
2101 if (tempbx & 0x0080) { /* OEMUtil */
2102 tempbx &= (~0x0080);
2103 tempdx = pVBInfo->LCDTypeInfo;
2106 if (pVBInfo->LCDInfo & EnableScalingLCD)
2107 tempdx &= (~PanelResInfo);
2109 if (tempdi[i].PANELID == tempdx) {
2110 tempbx = tempdi[i].MASK;
2111 tempdx = pVBInfo->LCDInfo;
2113 if (ModeNo <= 0x13) /* alan 09/10/2003 */
2114 tempdx |= SetLCDStdMode;
2116 if (modeflag & HalfDCLK)
2117 tempdx |= SetLCDLowResolution;
2120 if (tempbx == tempdi[i].CAP)
2127 switch (tempdi[i].DATAPTR) {
2129 return &XGI_LVDSCRT11024x768_1_H[tempal];
2132 return &XGI_LVDSCRT11024x768_2_H[tempal];
2135 return &XGI_LVDSCRT11280x1024_1_H[tempal];
2138 return &XGI_LVDSCRT11280x1024_2_H[tempal];
2141 return &XGI_LVDSCRT11400x1050_1_H[tempal];
2144 return &XGI_LVDSCRT11400x1050_2_H[tempal];
2147 return &XGI_LVDSCRT11600x1200_1_H[tempal];
2150 return &XGI_LVDSCRT11024x768_1_Hx75[tempal];
2153 return &XGI_LVDSCRT11024x768_2_Hx75[tempal];
2156 return &XGI_LVDSCRT11280x1024_1_Hx75[tempal];
2159 return &XGI_LVDSCRT11280x1024_2_Hx75[tempal];
2164 } else if (table == 1) {
2165 switch (tempdi[i].DATAPTR) {
2167 return &XGI_LVDSCRT11024x768_1_V[tempal];
2170 return &XGI_LVDSCRT11024x768_2_V[tempal];
2173 return &XGI_LVDSCRT11280x1024_1_V[tempal];
2176 return &XGI_LVDSCRT11280x1024_2_V[tempal];
2179 return &XGI_LVDSCRT11400x1050_1_V[tempal];
2182 return &XGI_LVDSCRT11400x1050_2_V[tempal];
2185 return &XGI_LVDSCRT11600x1200_1_V[tempal];
2188 return &XGI_LVDSCRT11024x768_1_Vx75[tempal];
2191 return &XGI_LVDSCRT11024x768_2_Vx75[tempal];
2194 return &XGI_LVDSCRT11280x1024_1_Vx75[tempal];
2197 return &XGI_LVDSCRT11280x1024_2_Vx75[tempal];
2202 } else if (table == 2) {
2203 switch (tempdi[i].DATAPTR) {
2205 return &XGI_LVDS1024x768Data_1[tempal];
2208 return &XGI_LVDS1024x768Data_2[tempal];
2211 return &XGI_LVDS1280x1024Data_1[tempal];
2214 return &XGI_LVDS1280x1024Data_2[tempal];
2217 return &XGI_LVDS1400x1050Data_1[tempal];
2220 return &XGI_LVDS1400x1050Data_2[tempal];
2223 return &XGI_LVDS1600x1200Data_1[tempal];
2226 return &XGI_LVDSNoScalingData[tempal];
2229 return &XGI_LVDS1024x768Data_1x75[tempal];
2232 return &XGI_LVDS1024x768Data_2x75[tempal];
2235 return &XGI_LVDS1280x1024Data_1x75[tempal];
2238 return &XGI_LVDS1280x1024Data_2x75[tempal];
2241 return &XGI_LVDSNoScalingDatax75[tempal];
2246 } else if (table == 3) {
2247 switch (tempdi[i].DATAPTR) {
2249 return &XGI_LVDS1024x768Des_1[tempal];
2252 return &XGI_LVDS1024x768Des_3[tempal];
2255 return &XGI_LVDS1024x768Des_2[tempal];
2258 return &XGI_LVDS1280x1024Des_1[tempal];
2261 return &XGI_LVDS1280x1024Des_2[tempal];
2264 return &XGI_LVDS1400x1050Des_1[tempal];
2267 return &XGI_LVDS1400x1050Des_2[tempal];
2270 return &XGI_LVDS1600x1200Des_1[tempal];
2273 return &XGI_LVDSNoScalingDesData[tempal];
2276 return &XGI_LVDS1024x768Des_1x75[tempal];
2279 return &XGI_LVDS1024x768Des_3x75[tempal];
2282 return &XGI_LVDS1024x768Des_2x75[tempal];
2285 return &XGI_LVDS1280x1024Des_1x75[tempal];
2288 return &XGI_LVDS1280x1024Des_2x75[tempal];
2291 return &XGI_LVDSNoScalingDesDatax75[tempal];
2296 } else if (table == 4) {
2297 switch (tempdi[i].DATAPTR) {
2299 return &XGI_ExtLCD1024x768Data[tempal];
2302 return &XGI_StLCD1024x768Data[tempal];
2305 return &XGI_CetLCD1024x768Data[tempal];
2308 return &XGI_ExtLCD1280x1024Data[tempal];
2311 return &XGI_StLCD1280x1024Data[tempal];
2314 return &XGI_CetLCD1280x1024Data[tempal];
2317 return &XGI_ExtLCD1400x1050Data[tempal];
2320 return &XGI_StLCD1400x1050Data[tempal];
2323 return &XGI_CetLCD1400x1050Data[tempal];
2326 return &XGI_ExtLCD1600x1200Data[tempal];
2329 return &XGI_StLCD1600x1200Data[tempal];
2332 return &XGI_NoScalingData[tempal];
2335 return &XGI_ExtLCD1024x768x75Data[tempal];
2338 return &XGI_ExtLCD1024x768x75Data[tempal];
2341 return &XGI_CetLCD1024x768x75Data[tempal];
2344 return &XGI_ExtLCD1280x1024x75Data[tempal];
2347 return &XGI_StLCD1280x1024x75Data[tempal];
2350 return &XGI_CetLCD1280x1024x75Data[tempal];
2353 return &XGI_NoScalingDatax75[tempal];
2358 } else if (table == 5) {
2359 switch (tempdi[i].DATAPTR) {
2361 return &XGI_ExtLCDDes1024x768Data[tempal];
2364 return &XGI_StLCDDes1024x768Data[tempal];
2367 return &XGI_CetLCDDes1024x768Data[tempal];
2370 if ((pVBInfo->VBType & VB_XGI301LV) ||
2371 (pVBInfo->VBType & VB_XGI302LV))
2372 return &XGI_ExtLCDDLDes1280x1024Data[tempal];
2374 return &XGI_ExtLCDDes1280x1024Data[tempal];
2377 if ((pVBInfo->VBType & VB_XGI301LV) ||
2378 (pVBInfo->VBType & VB_XGI302LV))
2379 return &XGI_StLCDDLDes1280x1024Data[tempal];
2381 return &XGI_StLCDDes1280x1024Data[tempal];
2384 if ((pVBInfo->VBType & VB_XGI301LV) ||
2385 (pVBInfo->VBType & VB_XGI302LV))
2386 return &XGI_CetLCDDLDes1280x1024Data[tempal];
2388 return &XGI_CetLCDDes1280x1024Data[tempal];
2391 if ((pVBInfo->VBType & VB_XGI301LV) ||
2392 (pVBInfo->VBType & VB_XGI302LV))
2393 return &XGI_ExtLCDDLDes1400x1050Data[tempal];
2395 return &XGI_ExtLCDDes1400x1050Data[tempal];
2398 if ((pVBInfo->VBType & VB_XGI301LV) ||
2399 (pVBInfo->VBType & VB_XGI302LV))
2400 return &XGI_StLCDDLDes1400x1050Data[tempal];
2402 return &XGI_StLCDDes1400x1050Data[tempal];
2405 return &XGI_CetLCDDes1400x1050Data[tempal];
2408 return &XGI_CetLCDDes1400x1050Data2[tempal];
2411 if ((pVBInfo->VBType & VB_XGI301LV) ||
2412 (pVBInfo->VBType & VB_XGI302LV))
2413 return &XGI_ExtLCDDLDes1600x1200Data[tempal];
2415 return &XGI_ExtLCDDes1600x1200Data[tempal];
2418 if ((pVBInfo->VBType & VB_XGI301LV) ||
2419 (pVBInfo->VBType & VB_XGI302LV))
2420 return &XGI_StLCDDLDes1600x1200Data[tempal];
2422 return &XGI_StLCDDes1600x1200Data[tempal];
2425 return &XGI_NoScalingDesData[tempal];
2428 return &XGI_ExtLCDDes1024x768x75Data[tempal];
2431 return &XGI_StLCDDes1024x768x75Data[tempal];
2434 return &XGI_CetLCDDes1024x768x75Data[tempal];
2437 if ((pVBInfo->VBType & VB_XGI301LV) ||
2438 (pVBInfo->VBType & VB_XGI302LV))
2439 return &XGI_ExtLCDDLDes1280x1024x75Data[tempal];
2441 return &XGI_ExtLCDDes1280x1024x75Data[tempal];
2444 if ((pVBInfo->VBType & VB_XGI301LV) ||
2445 (pVBInfo->VBType & VB_XGI302LV))
2446 return &XGI_StLCDDLDes1280x1024x75Data[tempal];
2448 return &XGI_StLCDDes1280x1024x75Data[tempal];
2451 if ((pVBInfo->VBType & VB_XGI301LV) ||
2452 (pVBInfo->VBType & VB_XGI302LV))
2453 return &XGI_CetLCDDLDes1280x1024x75Data[tempal];
2455 return &XGI_CetLCDDes1280x1024x75Data[tempal];
2458 return &XGI_NoScalingDesDatax75[tempal];
2463 } else if (table == 6) {
2464 switch (tempdi[i].DATAPTR) {
2466 return &XGI_CH7017LV1024x768[tempal];
2469 return &XGI_CH7017LV1400x1050[tempal];
2478 static void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo,
2479 unsigned short ModeIdIndex,
2480 unsigned short RefreshRateTableIndex,
2481 struct vb_device_info *pVBInfo)
2483 unsigned short i, tempdx, tempbx, tempal, modeflag, table;
2484 struct XGI330_TVDataTablStruct *tempdi = NULL;
2488 if (ModeNo <= 0x13) {
2489 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
2490 tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
2492 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2493 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
2496 tempal = tempal & 0x3f;
2501 tempdi = NULL; /*EPLCHTVCRT1Ptr_H;*/
2502 if (pVBInfo->IF_DEF_CH7007 == 1)
2503 tempdi = XGI_EPLCHTVCRT1Ptr;
2507 tempdi = NULL; /*EPLCHTVCRT1Ptr_V;*/
2508 if (pVBInfo->IF_DEF_CH7007 == 1)
2509 tempdi = XGI_EPLCHTVCRT1Ptr;
2513 tempdi = XGI_EPLCHTVDataPtr;
2519 tempdi = XGI_TVDataTable;
2525 tempdi = XGI_EPLCHTVRegPtr;
2531 if (tempdi == NULL) /* OEMUtil */
2534 tempdx = pVBInfo->TVInfo;
2536 if (pVBInfo->VBInfo & SetInSlaveMode)
2537 tempdx = tempdx | SetTVLockMode;
2539 if (modeflag & HalfDCLK)
2540 tempdx = tempdx | SetTVLowResolution;
2544 while (tempdi[i].MASK != 0xffff) {
2545 if ((tempdx & tempdi[i].MASK) == tempdi[i].CAP)
2551 if (table == 0x00) {
2552 } else if (table == 0x01) {
2553 } else if (table == 0x04) {
2554 switch (tempdi[i].DATAPTR) {
2556 return &XGI_ExtPALData[tempal];
2559 return &XGI_ExtNTSCData[tempal];
2562 return &XGI_StPALData[tempal];
2565 return &XGI_StNTSCData[tempal];
2568 return &XGI_ExtHiTVData[tempal];
2571 return &XGI_St2HiTVData[tempal];
2574 return &XGI_ExtYPbPr525iData[tempal];
2577 return &XGI_ExtYPbPr525pData[tempal];
2580 return &XGI_ExtYPbPr750pData[tempal];
2583 return &XGI_StYPbPr525iData[tempal];
2586 return &XGI_StYPbPr525pData[tempal];
2589 return &XGI_StYPbPr750pData[tempal];
2591 case 12: /* avoid system hang */
2592 return &XGI_ExtNTSCData[tempal];
2595 return &XGI_St1HiTVData[tempal];
2600 } else if (table == 0x02) {
2601 switch (tempdi[i].DATAPTR) {
2603 return &XGI_CHTVUNTSCData[tempal];
2606 return &XGI_CHTVONTSCData[tempal];
2609 return &XGI_CHTVUPALData[tempal];
2612 return &XGI_CHTVOPALData[tempal];
2617 } else if (table == 0x06) {
2622 static void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex,
2623 unsigned short RefreshRateTableIndex,
2624 struct vb_device_info *pVBInfo)
2626 unsigned short tempbx;
2627 struct XGI330_LVDSDataStruct *LCDPtr = NULL;
2628 struct XGI330_CHTVDataStruct *TVPtr = NULL;
2632 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
2633 LCDPtr = (struct XGI330_LVDSDataStruct *) XGI_GetLcdPtr(tempbx,
2634 ModeNo, ModeIdIndex, RefreshRateTableIndex,
2636 pVBInfo->VGAHT = LCDPtr->VGAHT;
2637 pVBInfo->VGAVT = LCDPtr->VGAVT;
2638 pVBInfo->HT = LCDPtr->LCDHT;
2639 pVBInfo->VT = LCDPtr->LCDVT;
2641 if (pVBInfo->IF_DEF_CH7017 == 1) {
2642 if (pVBInfo->VBInfo & SetCRT2ToTV) {
2643 TVPtr = (struct XGI330_CHTVDataStruct *) XGI_GetTVPtr(
2644 tempbx, ModeNo, ModeIdIndex,
2645 RefreshRateTableIndex, pVBInfo);
2646 pVBInfo->VGAHT = TVPtr->VGAHT;
2647 pVBInfo->VGAVT = TVPtr->VGAVT;
2648 pVBInfo->HT = TVPtr->LCDHT;
2649 pVBInfo->VT = TVPtr->LCDVT;
2653 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
2654 if (!(pVBInfo->LCDInfo & (SetLCDtoNonExpanding
2655 | EnableScalingLCD))) {
2656 if ((pVBInfo->LCDResInfo == Panel1024x768) ||
2657 (pVBInfo->LCDResInfo == Panel1024x768x75)) {
2658 pVBInfo->HDE = 1024;
2660 } else if ((pVBInfo->LCDResInfo == Panel1280x1024) ||
2661 (pVBInfo->LCDResInfo == Panel1280x1024x75)) {
2662 pVBInfo->HDE = 1280;
2663 pVBInfo->VDE = 1024;
2664 } else if (pVBInfo->LCDResInfo == Panel1400x1050) {
2665 pVBInfo->HDE = 1400;
2666 pVBInfo->VDE = 1050;
2668 pVBInfo->HDE = 1600;
2669 pVBInfo->VDE = 1200;
2675 static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex,
2676 unsigned short RefreshRateTableIndex,
2677 struct xgi_hw_device_info *HwDeviceExtension,
2678 struct vb_device_info *pVBInfo)
2680 unsigned char index;
2681 unsigned short tempbx, i;
2682 struct XGI_LVDSCRT1HDataStruct *LCDPtr = NULL;
2683 struct XGI_LVDSCRT1VDataStruct *LCDPtr1 = NULL;
2684 /* struct XGI330_CHTVDataStruct *TVPtr = NULL; */
2685 struct XGI_CH7007TV_TimingHStruct *CH7007TV_TimingHPtr = NULL;
2686 struct XGI_CH7007TV_TimingVStruct *CH7007TV_TimingVPtr = NULL;
2689 index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
2691 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
2693 index = index & IndexMask;
2695 if ((pVBInfo->IF_DEF_ScaleLCD == 0) ||
2696 ((pVBInfo->IF_DEF_ScaleLCD == 1) &&
2697 (!(pVBInfo->LCDInfo & EnableScalingLCD)))) {
2700 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
2701 LCDPtr = (struct XGI_LVDSCRT1HDataStruct *)
2702 XGI_GetLcdPtr(tempbx, ModeNo,
2704 RefreshRateTableIndex,
2707 for (i = 0; i < 8; i++)
2708 pVBInfo->TimingH[0].data[i] = LCDPtr[0].Reg[i];
2711 if (pVBInfo->IF_DEF_CH7007 == 1) {
2712 if (pVBInfo->VBInfo & SetCRT2ToTV) {
2713 CH7007TV_TimingHPtr =
2714 (struct XGI_CH7007TV_TimingHStruct *)
2719 RefreshRateTableIndex,
2722 for (i = 0; i < 8; i++)
2723 pVBInfo->TimingH[0].data[i] =
2724 CH7007TV_TimingHPtr[0].data[i];
2728 /* if (pVBInfo->IF_DEF_CH7017 == 1) {
2729 if (pVBInfo->VBInfo & SetCRT2ToTV)
2730 TVPtr = (struct XGI330_CHTVDataStruct *)
2735 RefreshRateTableIndex,
2740 XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension);
2742 if (pVBInfo->IF_DEF_CH7007 == 1) {
2743 xgifb_reg_set(pVBInfo->P3c4, 0x2E,
2744 CH7007TV_TimingHPtr[0].data[8]);
2745 xgifb_reg_set(pVBInfo->P3c4, 0x2F,
2746 CH7007TV_TimingHPtr[0].data[9]);
2751 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
2752 LCDPtr1 = (struct XGI_LVDSCRT1VDataStruct *)
2757 RefreshRateTableIndex,
2759 for (i = 0; i < 7; i++)
2760 pVBInfo->TimingV[0].data[i] = LCDPtr1[0].Reg[i];
2763 if (pVBInfo->IF_DEF_CH7007 == 1) {
2764 if (pVBInfo->VBInfo & SetCRT2ToTV) {
2765 CH7007TV_TimingVPtr =
2766 (struct XGI_CH7007TV_TimingVStruct *)
2771 RefreshRateTableIndex,
2774 for (i = 0; i < 7; i++)
2775 pVBInfo->TimingV[0].data[i] =
2776 CH7007TV_TimingVPtr[0].data[i];
2779 /* if (pVBInfo->IF_DEF_CH7017 == 1) {
2780 if (pVBInfo->VBInfo & SetCRT2ToTV)
2781 TVPtr = (struct XGI330_CHTVDataStruct *)
2782 XGI_GetTVPtr(tempbx,
2785 RefreshRateTableIndex,
2790 XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo);
2792 if (pVBInfo->IF_DEF_CH7007 == 1) {
2793 xgifb_reg_and_or(pVBInfo->P3c4, 0x33, ~0x01,
2794 CH7007TV_TimingVPtr[0].data[7] & 0x01);
2795 xgifb_reg_set(pVBInfo->P3c4, 0x34,
2796 CH7007TV_TimingVPtr[0].data[8]);
2797 xgifb_reg_set(pVBInfo->P3c4, 0x3F,
2798 CH7007TV_TimingVPtr[0].data[9]);
2804 static unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo)
2806 unsigned char tempal, tempah, tempbl, i;
2808 tempah = xgifb_reg_get(pVBInfo->P3d4, 0x36);
2809 tempal = tempah & 0x0F;
2810 tempah = tempah & 0xF0;
2812 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
2814 while (tempbl != 0xFF) {
2815 if (tempbl & 0x80) { /* OEMUtil */
2817 tempbl = tempbl & ~(0x80);
2820 if (tempal == tempbl)
2825 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
2831 static unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo)
2833 unsigned short tempah, tempal, tempbl, i;
2835 tempal = pVBInfo->LCDResInfo;
2836 tempah = pVBInfo->LCDTypeInfo;
2839 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
2841 while (tempbl != 0xFF) {
2842 if ((tempbl & 0x80) && (tempbl != 0x80)) {
2847 if (tempal == tempbl)
2851 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
2854 if (tempbl == 0xFF) {
2855 pVBInfo->LCDResInfo = Panel1024x768;
2856 pVBInfo->LCDTypeInfo = 0;
2863 static void XGI_GetLCDSync(unsigned short *HSyncWidth,
2864 unsigned short *VSyncWidth,
2865 struct vb_device_info *pVBInfo)
2867 unsigned short Index;
2869 Index = XGI_GetLCDCapPtr(pVBInfo);
2870 *HSyncWidth = pVBInfo->LCDCapList[Index].LCD_HSyncWidth;
2871 *VSyncWidth = pVBInfo->LCDCapList[Index].LCD_VSyncWidth;
2876 static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
2877 unsigned short RefreshRateTableIndex,
2878 struct vb_device_info *pVBInfo)
2880 unsigned short tempbx, tempax, tempcx, tempdx, push1, push2, modeflag;
2881 unsigned long temp, temp1, temp2, temp3, push3;
2882 struct XGI330_LCDDataDesStruct *LCDPtr = NULL;
2883 struct XGI330_LCDDataDesStruct2 *LCDPtr1 = NULL;
2886 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2888 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
2890 if (!(pVBInfo->SetFlag & Win9xDOSMode)) {
2891 if ((pVBInfo->IF_DEF_CH7017 == 0) || (pVBInfo->VBInfo
2892 & (SetCRT2ToLCD | SetCRT2ToLCDA))) {
2893 if (pVBInfo->IF_DEF_OEMUtil == 1) {
2895 LCDPtr = (struct XGI330_LCDDataDesStruct *)
2896 XGI_GetLcdPtr(tempbx,
2899 RefreshRateTableIndex,
2903 if ((pVBInfo->IF_DEF_OEMUtil == 0) ||
2906 if (pVBInfo->LCDInfo & EnableScalingLCD)
2908 (struct XGI330_LCDDataDesStruct2 *)
2913 RefreshRateTableIndex,
2917 (struct XGI330_LCDDataDesStruct *)
2922 RefreshRateTableIndex,
2926 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
2931 if ((pVBInfo->LCDResInfo == Panel1024x768) ||
2932 (pVBInfo->LCDResInfo == Panel1024x768x75)) {
2935 } else if ((pVBInfo->LCDResInfo == Panel1280x1024) ||
2936 (pVBInfo->LCDResInfo == Panel1280x1024x75)) {
2939 } else if (pVBInfo->LCDResInfo == Panel1400x1050) {
2947 if (pVBInfo->LCDInfo & SetLCDtoNonExpanding) {
2948 pVBInfo->HDE = tempax;
2949 pVBInfo->VDE = tempbx;
2950 pVBInfo->VGAHDE = tempax;
2951 pVBInfo->VGAVDE = tempbx;
2954 if ((pVBInfo->IF_DEF_ScaleLCD == 1) &&
2955 (pVBInfo->LCDInfo & EnableScalingLCD)) {
2956 tempax = pVBInfo->HDE;
2957 tempbx = pVBInfo->VDE;
2960 tempax = pVBInfo->HT;
2962 if (pVBInfo->LCDInfo & EnableScalingLCD)
2963 tempbx = LCDPtr1->LCDHDES;
2965 tempbx = LCDPtr->LCDHDES;
2967 tempcx = pVBInfo->HDE;
2968 tempbx = tempbx & 0x0fff;
2971 if (tempcx >= tempax)
2974 xgifb_reg_set(pVBInfo->Part1Port, 0x1A, tempbx & 0x07);
2976 tempcx = tempcx >> 3;
2977 tempbx = tempbx >> 3;
2979 xgifb_reg_set(pVBInfo->Part1Port, 0x16,
2980 (unsigned short) (tempbx & 0xff));
2981 xgifb_reg_set(pVBInfo->Part1Port, 0x17,
2982 (unsigned short) (tempcx & 0xff));
2984 tempax = pVBInfo->HT;
2986 if (pVBInfo->LCDInfo & EnableScalingLCD)
2987 tempbx = LCDPtr1->LCDHRS;
2989 tempbx = LCDPtr->LCDHRS;
2993 if (pVBInfo->LCDInfo & EnableScalingLCD)
2994 tempcx = LCDPtr1->LCDHSync;
2998 if (tempcx >= tempax)
3001 tempax = tempbx & 0x07;
3002 tempax = tempax >> 5;
3003 tempcx = tempcx >> 3;
3004 tempbx = tempbx >> 3;
3009 xgifb_reg_set(pVBInfo->Part1Port, 0x15, tempax);
3010 xgifb_reg_set(pVBInfo->Part1Port, 0x14,
3011 (unsigned short) (tempbx & 0xff));
3013 tempax = pVBInfo->VT;
3014 if (pVBInfo->LCDInfo & EnableScalingLCD)
3015 tempbx = LCDPtr1->LCDVDES;
3017 tempbx = LCDPtr->LCDVDES;
3018 tempcx = pVBInfo->VDE;
3020 tempbx = tempbx & 0x0fff;
3022 if (tempcx >= tempax)
3025 xgifb_reg_set(pVBInfo->Part1Port, 0x1b,
3026 (unsigned short) (tempbx & 0xff));
3027 xgifb_reg_set(pVBInfo->Part1Port, 0x1c,
3028 (unsigned short) (tempcx & 0xff));
3030 tempbx = (tempbx >> 8) & 0x07;
3031 tempcx = (tempcx >> 8) & 0x07;
3033 xgifb_reg_set(pVBInfo->Part1Port, 0x1d,
3034 (unsigned short) ((tempcx << 3)
3037 tempax = pVBInfo->VT;
3038 if (pVBInfo->LCDInfo & EnableScalingLCD)
3039 tempbx = LCDPtr1->LCDVRS;
3041 tempbx = LCDPtr->LCDVRS;
3043 /* tempbx = tempbx >> 4; */
3046 if (pVBInfo->LCDInfo & EnableScalingLCD)
3047 tempcx = LCDPtr1->LCDVSync;
3050 if (tempcx >= tempax)
3053 xgifb_reg_set(pVBInfo->Part1Port, 0x18,
3054 (unsigned short) (tempbx & 0xff));
3055 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, ~0x0f,
3056 (unsigned short) (tempcx & 0x0f));
3058 tempax = ((tempbx >> 8) & 0x07) << 3;
3060 tempbx = pVBInfo->VGAVDE;
3061 if (tempbx != pVBInfo->VDE)
3064 if (pVBInfo->LCDInfo & EnableLVDSDDA)
3067 xgifb_reg_and_or(pVBInfo->Part1Port, 0x1a, 0x07,
3070 tempcx = pVBInfo->VGAVT;
3071 tempbx = pVBInfo->VDE;
3072 tempax = pVBInfo->VGAVDE;
3075 temp = tempax; /* 0430 ylshieh */
3076 temp1 = (temp << 18) / tempbx;
3078 tempdx = (unsigned short) ((temp << 18) % tempbx);
3086 xgifb_reg_set(pVBInfo->Part1Port, 0x37,
3087 (unsigned short) (temp2 & 0xff));
3088 xgifb_reg_set(pVBInfo->Part1Port, 0x36,
3089 (unsigned short) ((temp2 >> 8) & 0xff));
3091 tempbx = (unsigned short) (temp2 >> 16);
3092 tempax = tempbx & 0x03;
3094 tempbx = pVBInfo->VGAVDE;
3095 if (tempbx == pVBInfo->VDE)
3098 xgifb_reg_set(pVBInfo->Part1Port, 0x35, tempax);
3100 if (pVBInfo->VBType & VB_XGI301C) {
3102 xgifb_reg_set(pVBInfo->Part4Port,
3104 (unsigned short) (temp2 & 0xff));
3105 xgifb_reg_set(pVBInfo->Part4Port,
3107 (unsigned short) ((temp2 >> 8) &
3109 tempbx = (unsigned short) (temp2 >> 16);
3110 xgifb_reg_and_or(pVBInfo->Part4Port, 0x3a,
3112 (unsigned short) ((tempbx &
3115 tempcx = pVBInfo->VGAVDE;
3116 if (tempcx == pVBInfo->VDE)
3117 xgifb_reg_and_or(pVBInfo->Part4Port,
3120 xgifb_reg_and_or(pVBInfo->Part4Port,
3124 tempcx = pVBInfo->VGAHDE;
3125 tempbx = pVBInfo->HDE;
3127 temp1 = tempcx << 16;
3129 tempax = (unsigned short) (temp1 / tempbx);
3131 if ((tempbx & 0xffff) == (tempcx & 0xffff))
3135 temp1 = pVBInfo->VGAHDE << 16;
3138 temp3 = temp3 << 16;
3141 temp3 = (temp3 & 0xffff0000) + (temp1 & 0xffff);
3143 tempax = (unsigned short) (temp3 & 0xff);
3144 xgifb_reg_set(pVBInfo->Part1Port, 0x1f, tempax);
3146 temp1 = pVBInfo->VGAVDE << 18;
3147 temp1 = temp1 / push3;
3148 tempbx = (unsigned short) (temp1 & 0xffff);
3150 if (pVBInfo->LCDResInfo == Panel1024x768)
3153 tempax = ((tempbx >> 8) & 0xff) << 3;
3154 tempax |= (unsigned short) ((temp3 >> 8) & 0x07);
3155 xgifb_reg_set(pVBInfo->Part1Port, 0x20,
3156 (unsigned short) (tempax & 0xff));
3157 xgifb_reg_set(pVBInfo->Part1Port, 0x21,
3158 (unsigned short) (tempbx & 0xff));
3160 temp3 = temp3 >> 16;
3162 if (modeflag & HalfDCLK)
3165 xgifb_reg_set(pVBInfo->Part1Port, 0x22,
3166 (unsigned short) ((temp3 >> 8) & 0xff));
3167 xgifb_reg_set(pVBInfo->Part1Port, 0x23,
3168 (unsigned short) (temp3 & 0xff));
3173 /* --------------------------------------------------------------------- */
3174 /* Function : XGI_GETLCDVCLKPtr */
3176 /* Output : al -> VCLK Index */
3178 /* --------------------------------------------------------------------- */
3179 static void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1,
3180 struct vb_device_info *pVBInfo)
3182 unsigned short index;
3184 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
3185 if (pVBInfo->IF_DEF_ScaleLCD == 1) {
3186 if (pVBInfo->LCDInfo & EnableScalingLCD)
3190 /* index = XGI_GetLCDCapPtr(pVBInfo); */
3191 index = XGI_GetLCDCapPtr1(pVBInfo);
3193 if (pVBInfo->VBInfo & SetCRT2ToLCD) { /* LCDB */
3194 *di_0 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData1;
3195 *di_1 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData2;
3197 *di_0 = pVBInfo->LCDCapList[index].LCDA_VCLKData1;
3198 *di_1 = pVBInfo->LCDCapList[index].LCDA_VCLKData2;
3204 static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex,
3205 unsigned short ModeNo, unsigned short ModeIdIndex,
3206 struct vb_device_info *pVBInfo)
3209 unsigned short index, modeflag;
3210 unsigned short tempbx;
3211 unsigned char tempal;
3212 unsigned char *CHTVVCLKPtr = NULL;
3216 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
3218 /* si+Ext_ResInfo */
3219 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3221 if ((pVBInfo->SetFlag & ProgrammingCRT2) &&
3222 (!(pVBInfo->LCDInfo & EnableScalingLCD))) { /* {LCDA/LCDB} */
3223 index = XGI_GetLCDCapPtr(pVBInfo);
3224 tempal = pVBInfo->LCDCapList[index].LCD_VCLK;
3226 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))
3230 if (pVBInfo->VBType &
3236 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
3237 tempal = HiTVVCLKDIV2;
3238 if (!(pVBInfo->TVInfo & RPLLDIV2XO))
3240 if (pVBInfo->TVInfo & TVSimuMode) {
3241 tempal = HiTVSimuVCLK;
3242 if (!(modeflag & Charx8Dot))
3243 tempal = HiTVTextVCLK;
3249 if (pVBInfo->TVInfo & SetYPbPrMode750p) {
3250 tempal = YPbPr750pVCLK;
3254 if (pVBInfo->TVInfo & SetYPbPrMode525p) {
3255 tempal = YPbPr525pVCLK;
3259 tempal = NTSC1024VCLK;
3261 if (!(pVBInfo->TVInfo & NTSC1024x768)) {
3262 tempal = TVVCLKDIV2;
3263 if (!(pVBInfo->TVInfo & RPLLDIV2XO))
3267 if (pVBInfo->VBInfo & SetCRT2ToTV)
3270 /* else if ((pVBInfo->IF_DEF_CH7017==1) &&
3271 (pVBInfo->VBType&VB_CH7017)) {
3273 *tempal = pVBInfo->SModeIDTable[ModeIdIndex].
3276 *tempal = pVBInfo->RefIndex[
3277 RefreshRateTableIndex].Ext_CRT2CRTC;
3278 *tempal = *tempal & 0x1F;
3280 if (pVBInfo->TVInfo & SetPALTV)
3281 tempbx = tempbx + 2;
3282 if (pVBInfo->TVInfo & SetCHTVOverScan)
3284 tempbx = tempbx << 1;
3288 if ((pVBInfo->IF_DEF_CH7007 == 1) &&
3289 (pVBInfo->VBType & VB_CH7007)) { /* [Billy] 07/05/08 CH7007 */
3290 /* VideoDebugPrint((
3292 "XGI_GetVCLKPtr: pVBInfo->IF_DEF_CH7007==1\n")); */
3293 if ((pVBInfo->VBInfo & SetCRT2ToTV)) {
3294 if (ModeNo <= 0x13) {
3295 tempal = pVBInfo->SModeIDTable[ModeIdIndex].
3298 tempal = pVBInfo->RefIndex[
3299 RefreshRateTableIndex].Ext_CRT2CRTC;
3302 tempal = tempal & 0x0F;
3305 if (pVBInfo->TVInfo & SetPALTV)
3306 tempbx = tempbx + 2;
3308 if (pVBInfo->TVInfo & SetCHTVOverScan)
3311 /** tempbx = tempbx << 1; CH7007 ? **/
3313 /* [Billy]07/05/29 CH7007 */
3314 if (pVBInfo->IF_DEF_CH7007 == 1) {
3317 CHTVVCLKPtr = XGI7007_CHTVVCLKUNTSC;
3320 CHTVVCLKPtr = XGI7007_CHTVVCLKONTSC;
3323 CHTVVCLKPtr = XGI7007_CHTVVCLKUPAL;
3326 CHTVVCLKPtr = XGI7007_CHTVVCLKOPAL;
3336 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC;
3339 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC;
3342 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL;
3345 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL;
3353 tempal = CHTVVCLKPtr[tempal];
3359 tempal = (unsigned char) inb((pVBInfo->P3ca + 0x02));
3360 tempal = tempal >> 2;
3363 /* for Dot8 Scaling LCD */
3364 if ((pVBInfo->LCDInfo & EnableScalingLCD) && (modeflag & Charx8Dot))
3365 tempal = tempal ^ tempal; /* ; set to VCLK25MHz always */
3370 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
3374 static void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0,
3375 unsigned char *di_1, struct vb_device_info *pVBInfo)
3377 if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 2007/05/16 */
3378 /* VideoDebugPrint((
3380 "XGI_GetVCLKLen: pVBInfo->IF_DEF_CH7007==1\n")); */
3381 *di_0 = (unsigned char) XGI_CH7007VCLKData[tempal].SR2B;
3382 *di_1 = (unsigned char) XGI_CH7007VCLKData[tempal].SR2C;
3383 } else if (pVBInfo->VBType & (VB_XGI301 | VB_XGI301B | VB_XGI302B
3384 | VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
3385 if ((!(pVBInfo->VBInfo & SetCRT2ToLCDA)) && (pVBInfo->SetFlag
3386 & ProgrammingCRT2)) {
3387 *di_0 = (unsigned char) XGI_VBVCLKData[tempal].SR2B;
3388 *di_1 = XGI_VBVCLKData[tempal].SR2C;
3391 *di_0 = XGI_VCLKData[tempal].SR2B;
3392 *di_1 = XGI_VCLKData[tempal].SR2C;
3396 static void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex,
3397 unsigned short RefreshRateTableIndex,
3398 struct vb_device_info *pVBInfo)
3400 unsigned char di_0, di_1, tempal;
3403 tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex,
3405 XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo);
3406 XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo);
3408 for (i = 0; i < 4; i++) {
3409 xgifb_reg_and_or(pVBInfo->P3d4, 0x31, ~0x30,
3410 (unsigned short) (0x10 * i));
3411 if (pVBInfo->IF_DEF_CH7007 == 1) {
3412 xgifb_reg_set(pVBInfo->P3c4, 0x2b, di_0);
3413 xgifb_reg_set(pVBInfo->P3c4, 0x2c, di_1);
3414 } else if ((!(pVBInfo->VBInfo & SetCRT2ToLCDA))
3415 && (!(pVBInfo->VBInfo & SetInSlaveMode))) {
3416 xgifb_reg_set(pVBInfo->P3c4, 0x2e, di_0);
3417 xgifb_reg_set(pVBInfo->P3c4, 0x2f, di_1);
3419 xgifb_reg_set(pVBInfo->P3c4, 0x2b, di_0);
3420 xgifb_reg_set(pVBInfo->P3c4, 0x2c, di_1);
3425 static void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension,
3426 struct vb_device_info *pVBInfo)
3428 unsigned short tempcl, tempch, temp, tempbl, tempax;
3430 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
3431 | VB_XGI302LV | VB_XGI301C)) {
3434 temp = xgifb_reg_get(pVBInfo->P3c4, 0x01);
3436 if (!(temp & 0x20)) {
3437 temp = xgifb_reg_get(pVBInfo->P3d4, 0x17);
3439 temp = xgifb_reg_get(pVBInfo->P3d4, 0x53);
3441 tempcl |= ActiveCRT1;
3445 temp = xgifb_reg_get(pVBInfo->Part1Port, 0x2e);
3448 if (!(temp == 0x08)) {
3449 /* Check ChannelA by Part1_13 [2003/10/03] */
3450 tempax = xgifb_reg_get(pVBInfo->Part1Port, 0x13);
3452 tempcl = tempcl | ActiveLCD;
3456 if (!(tempcl & ActiveLCD))
3458 tempcl |= ActiveCRT2;
3461 tempcl |= ActiveLCD;
3464 temp = xgifb_reg_get(pVBInfo->Part2Port, 0x00);
3467 tempch |= ActiveAVideo;
3470 tempch |= ActiveSVideo;
3473 tempch |= ActiveSCART;
3475 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
3477 tempch |= ActiveHiTV;
3480 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
3481 temp = xgifb_reg_get(
3486 tempch |= ActiveYPbPr;
3494 temp = xgifb_reg_get(pVBInfo->P3d4, 0x3d);
3495 if (tempcl & ActiveLCD) {
3496 if ((pVBInfo->SetFlag & ReserveTVOption)) {
3497 if (temp & ActiveTV)
3502 tempbl = ~ModeSwitchStatus;
3503 xgifb_reg_and_or(pVBInfo->P3d4, 0x3d, tempbl, temp);
3505 if (!(pVBInfo->SetFlag & ReserveTVOption))
3506 xgifb_reg_set(pVBInfo->P3d4, 0x3e, tempch);
3512 void XGI_GetVGAType(struct xgi_hw_device_info *HwDeviceExtension,
3513 struct vb_device_info *pVBInfo)
3516 if ( HwDeviceExtension->jChipType >= XG20 ) {
3517 pVBInfo->Set_VGAType = XG20;
3519 pVBInfo->Set_VGAType = VGA_XGI340;
3522 pVBInfo->Set_VGAType = HwDeviceExtension->jChipType;
3525 void XGI_GetVBType(struct vb_device_info *pVBInfo)
3527 unsigned short flag, tempbx, tempah;
3529 if (pVBInfo->IF_DEF_CH7007 == 1) {
3530 pVBInfo->VBType = VB_CH7007;
3533 if (pVBInfo->IF_DEF_LVDS == 0) {
3534 tempbx = VB_XGI302B;
3535 flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00);
3538 flag = xgifb_reg_get(pVBInfo->Part4Port, 0x01);
3540 tempbx = VB_XGI301B;
3542 tempbx = VB_XGI301C;
3544 tempbx = VB_XGI301LV;
3546 tempbx = VB_XGI302LV;
3547 tempah = xgifb_reg_get(
3557 if (tempbx & (VB_XGI301B | VB_XGI302B)) {
3558 flag = xgifb_reg_get(
3563 tempbx = tempbx | VB_NoLCD;
3567 pVBInfo->VBType = tempbx;
3570 else if (pVBInfo->IF_DEF_CH7017 == 1)
3571 pVBInfo->VBType = VB_CH7017;
3573 pVBInfo->VBType = VB_LVDS_NS;
3578 void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
3579 struct xgi_hw_device_info *HwDeviceExtension,
3580 struct vb_device_info *pVBInfo)
3582 unsigned short tempax, push, tempbx, temp, modeflag;
3585 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
3587 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3589 pVBInfo->SetFlag = 0;
3590 pVBInfo->ModeType = modeflag & ModeInfoFlag;
3593 if (pVBInfo->VBType & 0xFFFF) {
3594 /* Check Display Device */
3595 temp = xgifb_reg_get(pVBInfo->P3d4, 0x30);
3596 tempbx = tempbx | temp;
3597 temp = xgifb_reg_get(pVBInfo->P3d4, 0x31);
3601 tempbx = tempbx | tempax;
3602 temp = (SetCRT2ToDualEdge | SetCRT2ToYPbPr | SetCRT2ToLCDA
3603 | SetInSlaveMode | DisableCRT2Display);
3604 temp = 0xFFFF ^ temp;
3607 temp = xgifb_reg_get(pVBInfo->P3d4, 0x38);
3609 if (pVBInfo->IF_DEF_LCDA == 1) {
3611 if ((pVBInfo->Set_VGAType >= XG20)
3612 || (pVBInfo->Set_VGAType >= XG40)) {
3613 if (pVBInfo->IF_DEF_LVDS == 0) {
3614 /* if ((pVBInfo->VBType & VB_XGI302B)
3615 || (pVBInfo->VBType & VB_XGI301LV)
3616 || (pVBInfo->VBType & VB_XGI302LV)
3617 || (pVBInfo->VBType & VB_XGI301C))
3619 if (pVBInfo->VBType &
3624 if (temp & EnableDualEdge) {
3628 if (temp & SetToLCDA)
3633 } else if (pVBInfo->IF_DEF_CH7017 == 1) {
3634 if (pVBInfo->VBType & VB_CH7017) {
3635 if (temp & EnableDualEdge) {
3639 if (temp & SetToLCDA)
3648 if (pVBInfo->IF_DEF_YPbPr == 1) {
3649 /* [Billy] 07/05/04 */
3650 if (((pVBInfo->IF_DEF_LVDS == 0) &&
3651 ((pVBInfo->VBType & VB_XGI301LV) ||
3652 (pVBInfo->VBType & VB_XGI302LV) ||
3653 (pVBInfo->VBType & VB_XGI301C))) ||
3654 ((pVBInfo->IF_DEF_CH7017 == 1) &&
3655 (pVBInfo->VBType & VB_CH7017)) ||
3656 ((pVBInfo->IF_DEF_CH7007 == 1) &&
3657 (pVBInfo->VBType & VB_CH7007))) {
3658 if (temp & SetYPbPr) { /* temp = CR38 */
3659 if (pVBInfo->IF_DEF_HiVision == 1) {
3660 /* shampoo add for new
3662 temp = xgifb_reg_get(
3666 tempbx |= SetCRT2ToHiVisionTV;
3668 if (temp != YPbPrMode1080i) {
3670 (~SetCRT2ToHiVisionTV);
3676 /* tempbx |= SetCRT2ToYPbPr; */
3681 tempax = push; /* restore CR31 */
3683 if (pVBInfo->IF_DEF_LVDS == 0) {
3684 if (pVBInfo->IF_DEF_YPbPr == 1) {
3685 if (pVBInfo->IF_DEF_HiVision == 1)
3690 if (pVBInfo->IF_DEF_HiVision == 1)
3695 } else { /* 3nd party chip */
3696 if (pVBInfo->IF_DEF_CH7017 == 1)
3697 temp = (SetCRT2ToTV |
3700 /* [Billy] 07/05/03 */
3701 else if (pVBInfo->IF_DEF_CH7007 == 1)
3704 temp = SetCRT2ToLCD;
3707 if (!(tempbx & temp)) {
3708 tempax |= DisableCRT2Display;
3712 if (pVBInfo->IF_DEF_LCDA == 1) { /* Select Display Device */
3713 if (!(pVBInfo->VBType & VB_NoLCD)) {
3714 if (tempbx & SetCRT2ToLCDA) {
3715 if (tempbx & SetSimuScanMode)
3716 tempbx &= (~(SetCRT2ToLCD |
3720 tempbx &= (~(SetCRT2ToLCD |
3729 /* for driver abnormal */
3730 if (!(tempbx & (SwitchToCRT2 | SetSimuScanMode))) {
3731 if (pVBInfo->IF_DEF_CRT2Monitor == 1) {
3732 if (tempbx & SetCRT2ToRAMDAC) {
3737 tempbx &= (0x00FF | (~SetCRT2ToYPbPr));
3740 tempbx &= (~(SetCRT2ToRAMDAC |
3746 if (!(pVBInfo->VBType & VB_NoLCD)) {
3747 if (tempbx & SetCRT2ToLCD) {
3752 tempbx &= (0x00FF | (~SetCRT2ToYPbPr));
3756 if (tempbx & SetCRT2ToSCART) {
3761 tempbx &= (0x00FF | (~SetCRT2ToYPbPr));
3764 if (pVBInfo->IF_DEF_YPbPr == 1) {
3765 if (tempbx & SetCRT2ToYPbPr)
3771 if (pVBInfo->IF_DEF_HiVision == 1) {
3772 if (tempbx & SetCRT2ToHiVisionTV)
3774 SetCRT2ToHiVisionTV |
3779 if (tempax & DisableCRT2Display) { /* Set Display Device Info */
3780 if (!(tempbx & (SwitchToCRT2 | SetSimuScanMode)))
3781 tempbx = DisableCRT2Display;
3784 if (!(tempbx & DisableCRT2Display)) {
3785 if ((!(tempbx & DriverMode)) ||
3786 (!(modeflag & CRT2Mode))) {
3787 if (pVBInfo->IF_DEF_LCDA == 1) {
3788 if (!(tempbx & SetCRT2ToLCDA))
3789 tempbx |= (SetInSlaveMode |
3793 if (pVBInfo->IF_DEF_VideoCapture == 1) {
3794 if (((HwDeviceExtension->jChipType ==
3796 (pVBInfo->Set_VGAType == XG40)) ||
3797 ((HwDeviceExtension->jChipType ==
3799 (pVBInfo->Set_VGAType == XG41)) ||
3800 ((HwDeviceExtension->jChipType ==
3802 (pVBInfo->Set_VGAType == XG42)) ||
3803 ((HwDeviceExtension->jChipType ==
3805 (pVBInfo->Set_VGAType == XG45))) {
3822 /* LCD+TV can't support in slave mode
3823 * (Force LCDA+TV->LCDB) */
3824 if ((tempbx & SetInSlaveMode) &&
3825 (tempbx & SetCRT2ToLCDA)) {
3826 tempbx ^= (SetCRT2ToLCD |
3829 pVBInfo->SetFlag |= ReserveTVOption;
3834 pVBInfo->VBInfo = tempbx;
3837 void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
3838 struct vb_device_info *pVBInfo)
3840 unsigned short temp, tempbx = 0, resinfo = 0, modeflag, index1;
3845 if (pVBInfo->VBInfo & SetCRT2ToTV) {
3846 if (ModeNo <= 0x13) {
3847 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].
3848 St_ModeFlag; /* si+St_ModeFlag */
3849 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].
3850 St_ResInfo; /* si+St_ResInfo */
3852 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].
3854 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].
3855 Ext_RESINFO; /* si+Ext_ResInfo */
3858 if (pVBInfo->VBInfo & SetCRT2ToTV) {
3859 temp = xgifb_reg_get(pVBInfo->P3d4, 0x35);
3861 if (tempbx & SetPALTV) {
3862 tempbx &= (SetCHTVOverScan |
3866 if (tempbx & SetPALMTV)
3867 /* set to NTSC if PAL-M */
3868 tempbx &= ~SetPALTV;
3870 tempbx &= (SetCHTVOverScan |
3874 if (pVBInfo->IF_DEF_LVDS == 0) {
3876 index1 = xgifb_reg_get(pVBInfo->P3d4, 0x38);
3877 //00:PAL, 01:PAL-M, 10:PAL-N
3878 temp2 = (index1 & 0xC0) >> 5;
3880 if (temp2 & 0x02) //PAL-M
3881 tempbx &= (~SetPALTV);
3886 if (pVBInfo->IF_DEF_CH7017 == 1) {
3887 tempbx = xgifb_reg_get(pVBInfo->P3d4, 0x35);
3889 if (tempbx & TVOverScan)
3890 tempbx |= SetCHTVOverScan;
3893 if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/04 */
3894 tempbx = xgifb_reg_get(pVBInfo->P3d4, 0x35);
3896 if (tempbx & TVOverScan)
3897 tempbx |= SetCHTVOverScan;
3900 if (pVBInfo->IF_DEF_LVDS == 0) {
3901 if (pVBInfo->VBInfo & SetCRT2ToSCART)
3905 if (pVBInfo->IF_DEF_YPbPr == 1) {
3906 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
3907 index1 = xgifb_reg_get(pVBInfo->P3d4, 0x35);
3908 index1 &= YPbPrMode;
3910 if (index1 == YPbPrMode525i)
3911 tempbx |= SetYPbPrMode525i;
3913 if (index1 == YPbPrMode525p)
3914 tempbx = tempbx | SetYPbPrMode525p;
3915 if (index1 == YPbPrMode750p)
3916 tempbx = tempbx | SetYPbPrMode750p;
3920 if (pVBInfo->IF_DEF_HiVision == 1) {
3921 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
3922 tempbx = tempbx | SetYPbPrMode1080i | SetPALTV;
3925 if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */
3926 if ((pVBInfo->VBInfo & SetInSlaveMode) &&
3927 (!(pVBInfo->VBInfo & SetNotSimuMode)))
3928 tempbx |= TVSimuMode;
3930 if (!(tempbx & SetPALTV) &&
3932 (resinfo == 8)) /* NTSC 1024x768, */
3933 tempbx |= NTSC1024x768;
3935 tempbx |= RPLLDIV2XO;
3937 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
3938 if (pVBInfo->VBInfo & SetInSlaveMode)
3939 tempbx &= (~RPLLDIV2XO);
3942 (SetYPbPrMode525p | SetYPbPrMode750p))
3943 tempbx &= (~RPLLDIV2XO);
3944 else if (!(pVBInfo->VBType &
3950 if (tempbx & TVSimuMode)
3951 tempbx &= (~RPLLDIV2XO);
3956 pVBInfo->TVInfo = tempbx;
3959 unsigned char XGI_GetLCDInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
3960 struct vb_device_info *pVBInfo)
3962 unsigned short temp, tempax, tempbx, modeflag, resinfo = 0, LCDIdIndex;
3964 pVBInfo->LCDResInfo = 0;
3965 pVBInfo->LCDTypeInfo = 0;
3966 pVBInfo->LCDInfo = 0;
3968 if (ModeNo <= 0x13) {
3969 /* si+St_ModeFlag // */
3970 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
3972 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3973 /* si+Ext_ResInfo // */
3974 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
3977 temp = xgifb_reg_get(pVBInfo->P3d4, 0x36); /* Get LCD Res.Info */
3978 tempbx = temp & 0x0F;
3981 tempbx = Panel1024x768; /* default */
3983 /* LCD75 [2003/8/22] Vicent */
3984 if ((tempbx == Panel1024x768) || (tempbx == Panel1280x1024)) {
3985 if (pVBInfo->VBInfo & DriverMode) {
3986 tempax = xgifb_reg_get(pVBInfo->P3d4, 0x33);
3987 if (pVBInfo->VBInfo & SetCRT2ToLCDA)
3990 tempax = tempax >> 4;
3992 if ((resinfo == 6) || (resinfo == 9)) {
3994 tempbx |= PanelRef75Hz;
3995 } else if ((resinfo == 7) || (resinfo == 8)) {
3997 tempbx |= PanelRef75Hz;
4002 pVBInfo->LCDResInfo = tempbx;
4006 if (pVBInfo->IF_DEF_OEMUtil == 1)
4007 pVBInfo->LCDTypeInfo = (temp & 0xf0) >> 4;
4009 if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)))
4014 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
4016 temp &= (ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable);
4018 if ((pVBInfo->IF_DEF_ScaleLCD == 1) && (temp & LCDNonExpanding))
4019 temp &= ~EnableScalingLCD;
4023 LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo);
4025 tempax = pVBInfo->LCDCapList[LCDIdIndex].LCD_Capability;
4027 if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */
4028 if (((pVBInfo->VBType & VB_XGI302LV) || (pVBInfo->VBType
4029 & VB_XGI301C)) && (tempax & LCDDualLink)) {
4030 tempbx |= SetLCDDualLink;
4034 if (pVBInfo->IF_DEF_CH7017 == 1) {
4035 if (tempax & LCDDualLink)
4036 tempbx |= SetLCDDualLink;
4039 if (pVBInfo->IF_DEF_LVDS == 0) {
4040 if ((pVBInfo->LCDResInfo == Panel1400x1050) && (pVBInfo->VBInfo
4041 & SetCRT2ToLCD) && (ModeNo > 0x13) && (resinfo
4042 == 9) && (!(tempbx & EnableScalingLCD)))
4043 /* set to center in 1280x1024 LCDB for Panel1400x1050 */
4044 tempbx |= SetLCDtoNonExpanding;
4048 if (tempax & LCDBToA) {
4049 tempbx |= SetLCDBToA;
4053 if (pVBInfo->IF_DEF_ExpLink == 1) {
4054 if (modeflag & HalfDCLK) {
4055 /* if (!(pVBInfo->LCDInfo&LCDNonExpanding)) */
4056 if (!(tempbx & SetLCDtoNonExpanding)) {
4057 tempbx |= EnableLVDSDDA;
4059 if (ModeNo > 0x13) {
4060 if (pVBInfo->LCDResInfo
4062 if (resinfo == 4) {/* 512x384 */
4063 tempbx |= EnableLVDSDDA;
4071 if (pVBInfo->VBInfo & SetInSlaveMode) {
4072 if (pVBInfo->VBInfo & SetNotSimuMode)
4073 tempbx |= LCDVESATiming;
4075 tempbx |= LCDVESATiming;
4078 pVBInfo->LCDInfo = tempbx;
4080 if (pVBInfo->IF_DEF_PWD == 1) {
4081 if (pVBInfo->LCDInfo & SetPWDEnable) {
4082 if ((pVBInfo->VBType & VB_XGI302LV) ||
4083 (pVBInfo->VBType & VB_XGI301C)) {
4084 if (!(tempax & PWDEnable))
4085 pVBInfo->LCDInfo &= ~SetPWDEnable;
4090 if (pVBInfo->IF_DEF_LVDS == 0) {
4091 if (tempax & (LockLCDBToA | StLCDBToA)) {
4092 if (pVBInfo->VBInfo & SetInSlaveMode) {
4093 if (!(tempax & LockLCDBToA)) {
4094 if (ModeNo <= 0x13) {
4109 if (pVBInfo->IF_DEF_LVDS == 0) {
4110 if (tempax & (LockLCDBToA | StLCDBToA)) {
4111 if (pVBInfo->VBInfo & SetInSlaveMode) {
4112 if (!((!(tempax & LockLCDBToA)) &&
4130 unsigned char XGI_SearchModeID(unsigned short ModeNo,
4131 unsigned short *ModeIdIndex, struct vb_device_info *pVBInfo)
4135 if (ModeNo <= 0x13) {
4136 /* for (*ModeIdIndex=0;
4137 *ModeIdIndex < sizeof(pVBInfo->SModeIDTable)
4138 / sizeof(struct XGI_StStruct);
4139 (*ModeIdIndex)++) */
4140 for (*ModeIdIndex = 0;; (*ModeIdIndex)++) {
4141 if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID ==
4144 if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID ==
4150 (*ModeIdIndex)++; /* 400 lines */
4152 (*ModeIdIndex) += 2; /* 400 lines */
4153 /* else 350 lines */
4155 /* for (*ModeIdIndex=0;
4156 *ModeIdIndex < sizeof(pVBInfo->EModeIDTable)
4157 / sizeof(struct XGI_ExtStruct);
4158 (*ModeIdIndex)++) */
4159 for (*ModeIdIndex = 0;; (*ModeIdIndex)++) {
4160 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID ==
4163 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID ==
4172 /* win2000 MM adapter not support standard mode! */
4175 static unsigned char XGINew_CheckMemorySize(
4176 struct xgi_hw_device_info *HwDeviceExtension,
4177 unsigned short ModeNo,
4178 unsigned short ModeIdIndex,
4179 struct vb_device_info *pVBInfo)
4181 unsigned short memorysize, modeflag, temp, temp1, tmp;
4184 if ((HwDeviceExtension->jChipType == XGI_650) ||
4185 (HwDeviceExtension->jChipType == XGI_650M)) {
4191 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
4193 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4195 /* ModeType = modeflag&ModeInfoFlag; // Get mode type */
4197 memorysize = modeflag & MemoryInfoFlag;
4198 memorysize = memorysize > MemorySizeShift;
4199 memorysize++; /* Get memory size */
4201 temp = xgifb_reg_get(pVBInfo->P3c4, 0x14); /* Get DRAM Size */
4204 if (HwDeviceExtension->jChipType == XG40) {
4205 /* memory size per channel SR14[7:4] */
4206 temp = 1 << ((temp & 0x0F0) >> 4);
4207 if ((tmp & 0x0c) == 0x0C) { /* Qual channels */
4209 } else if ((tmp & 0x0c) == 0x08) { /* Dual channels */
4212 } else if (HwDeviceExtension->jChipType == XG42) {
4213 /* memory size per channel SR14[7:4] */
4214 temp = 1 << ((temp & 0x0F0) >> 4);
4215 if ((tmp & 0x04) == 0x04) { /* Dual channels */
4218 } else if (HwDeviceExtension->jChipType == XG45) {
4219 /* memory size per channel SR14[7:4] */
4220 temp = 1 << ((temp & 0x0F0) >> 4);
4221 if ((tmp & 0x0c) == 0x0C) { /* Qual channels */
4223 } else if ((tmp & 0x0c) == 0x08) { /* triple channels */
4227 } else if ((tmp & 0x0c) == 0x04) { /* Dual channels */
4231 if (temp < memorysize)
4239 void XGINew_IsLowResolution(unsigned short ModeNo,
4240 unsigned short ModeIdIndex,
4241 unsigned char XGINew_CheckMemorySize(
4242 struct xgi_hw_device_info *HwDeviceExtension,
4243 unsigned short ModeNo,
4244 unsigned short ModeIdIndex,
4245 struct vb_device_info *pVBInfo)
4247 unsigned short data ;
4248 unsigned short ModeFlag ;
4250 data = xgifb_reg_get(pVBInfo->P3c4, 0x0F);
4252 xgifb_reg_set(pVBInfo->P3c4, 0x0F, data);
4254 if (ModeNo > 0x13) {
4255 ModeFlag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4256 if ((ModeFlag & HalfDCLK) && (ModeFlag & DoubleScanMode)) {
4257 data = xgifb_reg_get(pVBInfo->P3c4, 0x0F);
4259 xgifb_reg_set(pVBInfo->P3c4, 0x0F, data);
4260 data = xgifb_reg_get(pVBInfo->P3c4, 0x01);
4262 xgifb_reg_set(pVBInfo->P3c4, 0x01, data);
4268 static unsigned char XG21GPIODataTransfer(unsigned char ujDate)
4270 unsigned char ujRet = 0;
4271 unsigned char i = 0;
4273 for (i = 0; i < 8; i++) {
4275 /* ujRet |= GETBITS(ujDate >> i, 0:0); */
4276 ujRet |= (ujDate >> i) & 1;
4282 /*----------------------------------------------------------------------------*/
4284 /* bl[5] : LVDS signal */
4285 /* bl[1] : LVDS backlight */
4286 /* bl[0] : LVDS VDD */
4287 /*----------------------------------------------------------------------------*/
4288 static unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo)
4290 unsigned char CR4A, temp;
4292 CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
4293 xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x23); /* enable GPIO write */
4295 temp = xgifb_reg_get(pVBInfo->P3d4, 0x48);
4297 temp = XG21GPIODataTransfer(temp);
4299 xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A);
4303 /*----------------------------------------------------------------------------*/
4305 /* bl[5] : LVDS signal */
4306 /* bl[1] : LVDS backlight */
4307 /* bl[0] : LVDS VDD */
4308 /*----------------------------------------------------------------------------*/
4309 static unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo)
4311 unsigned char CR4A, CRB4, temp;
4313 CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
4314 xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x0C); /* enable GPIO write */
4316 temp = xgifb_reg_get(pVBInfo->P3d4, 0x48);
4320 xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A);
4321 CRB4 = xgifb_reg_get(pVBInfo->P3d4, 0xB4);
4322 temp |= ((CRB4 & 0x04) << 3);
4326 void XGI_DisplayOn(struct xgi_hw_device_info *pXGIHWDE,
4327 struct vb_device_info *pVBInfo)
4330 xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x00);
4331 if (pXGIHWDE->jChipType == XG21) {
4332 if (pVBInfo->IF_DEF_LVDS == 1) {
4333 if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x1)) {
4335 XGI_XG21BLSignalVDD(0x01, 0x01, pVBInfo);
4336 XGI_XG21SetPanelDelay(2, pVBInfo);
4338 if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x20))
4339 /* LVDS signal on */
4340 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo);
4341 XGI_XG21SetPanelDelay(3, pVBInfo);
4342 /* LVDS backlight on */
4343 XGI_XG21BLSignalVDD(0x02, 0x02, pVBInfo);
4345 /* DVO/DVI signal on */
4346 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo);
4351 /* [Billy] 07/05/23 For CH7007 */
4352 if (pVBInfo->IF_DEF_CH7007 == 1) {
4355 if (pXGIHWDE->jChipType == XG27) {
4356 if (pVBInfo->IF_DEF_LVDS == 1) {
4357 if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x1)) {
4359 XGI_XG27BLSignalVDD(0x01, 0x01, pVBInfo);
4360 XGI_XG21SetPanelDelay(2, pVBInfo);
4362 if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x20))
4363 /* LVDS signal on */
4364 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo);
4365 XGI_XG21SetPanelDelay(3, pVBInfo);
4366 /* LVDS backlight on */
4367 XGI_XG27BLSignalVDD(0x02, 0x02, pVBInfo);
4369 /* DVO/DVI signal on */
4370 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo);
4376 void XGI_DisplayOff(struct xgi_hw_device_info *pXGIHWDE,
4377 struct vb_device_info *pVBInfo)
4380 if (pXGIHWDE->jChipType == XG21) {
4381 if (pVBInfo->IF_DEF_LVDS == 1) {
4382 /* LVDS backlight off */
4383 XGI_XG21BLSignalVDD(0x02, 0x00, pVBInfo);
4384 XGI_XG21SetPanelDelay(3, pVBInfo);
4386 /* DVO/DVI signal off */
4387 XGI_XG21BLSignalVDD(0x20, 0x00, pVBInfo);
4391 if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/23 For CH7007 */
4392 /* if (IsCH7007TVMode(pVBInfo) == 0) */
4397 if (pXGIHWDE->jChipType == XG27) {
4398 if ((XGI_XG27GetPSCValue(pVBInfo) & 0x2)) {
4399 /* LVDS backlight off */
4400 XGI_XG27BLSignalVDD(0x02, 0x00, pVBInfo);
4401 XGI_XG21SetPanelDelay(3, pVBInfo);
4404 if (pVBInfo->IF_DEF_LVDS == 0)
4405 /* DVO/DVI signal off */
4406 XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo);
4409 xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x20);
4412 static void XGI_WaitDisply(struct vb_device_info *pVBInfo)
4414 while ((inb(pVBInfo->P3da) & 0x01))
4417 while (!(inb(pVBInfo->P3da) & 0x01))
4422 static void XGI_WaitDisplay(struct vb_device_info *pVBInfo)
4424 while (!(inb(pVBInfo->P3da) & 0x01))
4426 while (inb(pVBInfo->P3da) & 0x01)
4431 static void XGI_AutoThreshold(struct vb_device_info *pVBInfo)
4433 if (!(pVBInfo->SetFlag & Win9xDOSMode))
4434 xgifb_reg_or(pVBInfo->Part1Port, 0x01, 0x40);
4437 static void XGI_SaveCRT2Info(unsigned short ModeNo,
4438 struct vb_device_info *pVBInfo)
4440 unsigned short temp1, temp2;
4442 /* reserve CR34 for CRT1 Mode No */
4443 xgifb_reg_set(pVBInfo->P3d4, 0x34, ModeNo);
4444 temp1 = (pVBInfo->VBInfo & SetInSlaveMode) >> 8;
4445 temp2 = ~(SetInSlaveMode >> 8);
4446 xgifb_reg_and_or(pVBInfo->P3d4, 0x31, temp2, temp1);
4449 static void XGI_GetCRT2ResInfo(unsigned short ModeNo,
4450 unsigned short ModeIdIndex,
4451 struct vb_device_info *pVBInfo)
4453 unsigned short xres, yres, modeflag, resindex;
4455 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
4456 if (ModeNo <= 0x13) {
4457 xres = pVBInfo->StResInfo[resindex].HTotal;
4458 yres = pVBInfo->StResInfo[resindex].VTotal;
4460 /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;*/
4462 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
4463 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
4464 /* si+St_ModeFlag */
4465 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4468 if (pVBInfo->IF_DEF_FSTN) {
4473 if (modeflag & HalfDCLK)
4476 if (modeflag & DoubleScanMode)
4481 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
4482 if (pVBInfo->IF_DEF_LVDS == 0) {
4483 if (pVBInfo->LCDResInfo == Panel1600x1200) {
4484 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
4490 if (pVBInfo->LCDResInfo == Panel1280x1024) {
4493 else if (yres == 350)
4496 if (pVBInfo->LCDInfo & LCDVESATiming) {
4502 if (pVBInfo->LCDResInfo == Panel1024x768) {
4503 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
4504 if (!(pVBInfo->LCDInfo
4505 & LCDNonExpanding)) {
4508 else if (yres == 400)
4510 else if (yres == 480)
4521 pVBInfo->VGAHDE = xres;
4522 pVBInfo->HDE = xres;
4523 pVBInfo->VGAVDE = yres;
4524 pVBInfo->VDE = yres;
4527 static unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo)
4530 if ((pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) &&
4531 (pVBInfo->LCDInfo & SetLCDDualLink)) /* shampoo0129 */
4537 static void XGI_GetRAMDAC2DATA(unsigned short ModeNo,
4538 unsigned short ModeIdIndex,
4539 unsigned short RefreshRateTableIndex,
4540 struct vb_device_info *pVBInfo)
4542 unsigned short tempax, tempbx, temp1, temp2, modeflag = 0, tempcx,
4543 StandTableIndex, CRT1Index;
4545 pVBInfo->RVBHCMAX = 1;
4546 pVBInfo->RVBHCFACT = 1;
4548 if (ModeNo <= 0x13) {
4549 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
4550 StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
4551 tempax = pVBInfo->StandTable[StandTableIndex].CRTC[0];
4552 tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[6];
4553 temp1 = pVBInfo->StandTable[StandTableIndex].CRTC[7];
4555 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4556 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].
4558 CRT1Index &= IndexMask;
4559 temp1 = (unsigned short) pVBInfo->
4560 XGINEWUB_CRT1Table[CRT1Index].CR[0];
4561 temp2 = (unsigned short) pVBInfo->
4562 XGINEWUB_CRT1Table[CRT1Index].CR[5];
4563 tempax = (temp1 & 0xFF) | ((temp2 & 0x03) << 8);
4564 tempbx = (unsigned short) pVBInfo->
4565 XGINEWUB_CRT1Table[CRT1Index].CR[8];
4566 tempcx = (unsigned short) pVBInfo->
4567 XGINEWUB_CRT1Table[CRT1Index].CR[14] << 8;
4569 tempcx = tempcx << 2;
4571 temp1 = (unsigned short) pVBInfo->
4572 XGINEWUB_CRT1Table[CRT1Index].CR[9];
4582 if (modeflag & Charx8Dot)
4587 pVBInfo->VGAHT = tempax;
4588 pVBInfo->HT = tempax;
4590 pVBInfo->VGAVT = tempbx;
4591 pVBInfo->VT = tempbx;
4594 static void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex,
4595 unsigned short RefreshRateTableIndex,
4596 struct vb_device_info *pVBInfo)
4598 unsigned short tempax = 0, tempbx, modeflag, resinfo;
4600 struct XGI_LCDDataStruct *LCDPtr = NULL;
4601 struct XGI_TVDataStruct *TVPtr = NULL;
4603 if (ModeNo <= 0x13) {
4605 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
4606 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
4608 /* si+Ext_ResInfo */
4609 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4610 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4613 pVBInfo->NewFlickerMode = 0;
4614 pVBInfo->RVBHRS = 50;
4616 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
4617 XGI_GetRAMDAC2DATA(ModeNo, ModeIdIndex, RefreshRateTableIndex,
4624 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
4625 LCDPtr = (struct XGI_LCDDataStruct *) XGI_GetLcdPtr(tempbx,
4626 ModeNo, ModeIdIndex, RefreshRateTableIndex,
4629 pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX;
4630 pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT;
4631 pVBInfo->VGAHT = LCDPtr->VGAHT;
4632 pVBInfo->VGAVT = LCDPtr->VGAVT;
4633 pVBInfo->HT = LCDPtr->LCDHT;
4634 pVBInfo->VT = LCDPtr->LCDVT;
4636 if (pVBInfo->LCDResInfo == Panel1024x768) {
4640 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
4641 if (pVBInfo->VGAVDE == 357)
4643 else if (pVBInfo->VGAVDE == 420)
4645 else if (pVBInfo->VGAVDE == 525)
4647 else if (pVBInfo->VGAVDE == 600)
4649 /* else if (pVBInfo->VGAVDE==350) tempbx=560; */
4650 /* else if (pVBInfo->VGAVDE==400) tempbx=640; */
4655 } else if (pVBInfo->LCDResInfo == Panel1024x768x75) {
4658 } else if (pVBInfo->LCDResInfo == Panel1280x1024) {
4660 if (pVBInfo->VGAVDE == 360)
4662 else if (pVBInfo->VGAVDE == 375)
4664 else if (pVBInfo->VGAVDE == 405)
4668 } else if (pVBInfo->LCDResInfo == Panel1280x1024x75) {
4671 } else if (pVBInfo->LCDResInfo == Panel1280x960) {
4673 if (pVBInfo->VGAVDE == 350)
4675 else if (pVBInfo->VGAVDE == 400)
4677 else if (pVBInfo->VGAVDE == 1024)
4681 } else if (pVBInfo->LCDResInfo == Panel1400x1050) {
4685 if (pVBInfo->VGAVDE == 1024) {
4689 } else if (pVBInfo->LCDResInfo == Panel1600x1200) {
4691 tempbx = 1200; /* alan 10/14/2003 */
4692 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
4693 if (pVBInfo->VGAVDE == 350)
4695 else if (pVBInfo->VGAVDE == 400)
4700 if (pVBInfo->LCDInfo & LCDNonExpanding) {
4701 tempax = pVBInfo->VGAHDE;
4702 tempbx = pVBInfo->VGAVDE;
4705 pVBInfo->HDE = tempax;
4706 pVBInfo->VDE = tempbx;
4710 if (pVBInfo->VBInfo & (SetCRT2ToTV)) {
4712 TVPtr = (struct XGI_TVDataStruct *) XGI_GetTVPtr(tempbx,
4713 ModeNo, ModeIdIndex, RefreshRateTableIndex,
4716 pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX;
4717 pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT;
4718 pVBInfo->VGAHT = TVPtr->VGAHT;
4719 pVBInfo->VGAVT = TVPtr->VGAVT;
4720 pVBInfo->HDE = TVPtr->TVHDE;
4721 pVBInfo->VDE = TVPtr->TVVDE;
4722 pVBInfo->RVBHRS = TVPtr->RVBHRS;
4723 pVBInfo->NewFlickerMode = TVPtr->FlickerMode;
4725 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4726 if (resinfo == 0x08)
4727 pVBInfo->NewFlickerMode = 0x40;
4728 else if (resinfo == 0x09)
4729 pVBInfo->NewFlickerMode = 0x40;
4730 else if (resinfo == 0x12)
4731 pVBInfo->NewFlickerMode = 0x40;
4733 if (pVBInfo->VGAVDE == 350)
4734 pVBInfo->TVInfo |= TVSimuMode;
4739 if (pVBInfo->VBInfo & SetInSlaveMode) {
4740 if (pVBInfo->TVInfo & TVSimuMode) {
4744 if (!(modeflag & Charx8Dot)) {
4745 tempax = StHiTextTVHT;
4746 tempbx = StHiTextTVVT;
4750 } else if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
4751 if (pVBInfo->TVInfo & SetYPbPrMode750p) {
4752 tempax = YPbPrTV750pHT; /* Ext750pTVHT */
4753 tempbx = YPbPrTV750pVT; /* Ext750pTVVT */
4756 if (pVBInfo->TVInfo & SetYPbPrMode525p) {
4757 tempax = YPbPrTV525pHT; /* Ext525pTVHT */
4758 tempbx = YPbPrTV525pVT; /* Ext525pTVVT */
4759 } else if (pVBInfo->TVInfo & SetYPbPrMode525i) {
4760 tempax = YPbPrTV525iHT; /* Ext525iTVHT */
4761 tempbx = YPbPrTV525iVT; /* Ext525iTVVT */
4762 if (pVBInfo->TVInfo & NTSC1024x768)
4763 tempax = NTSC1024x768HT;
4768 if (!(pVBInfo->TVInfo & SetPALTV)) {
4771 if (pVBInfo->TVInfo & NTSC1024x768)
4772 tempax = NTSC1024x768HT;
4776 pVBInfo->HT = tempax;
4777 pVBInfo->VT = tempbx;
4782 static void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex,
4783 unsigned short RefreshRateTableIndex,
4784 struct vb_device_info *pVBInfo)
4786 unsigned char di_0, di_1, tempal;
4788 tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex,
4790 XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo);
4791 XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo);
4793 if (pVBInfo->VBType & VB_XGI301) { /* shampoo 0129 */
4795 xgifb_reg_set(pVBInfo->Part4Port, 0x0A, 0x10);
4796 xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1);
4797 xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0);
4798 } else { /* 301b/302b/301lv/302lv */
4799 xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0);
4800 xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1);
4803 xgifb_reg_set(pVBInfo->Part4Port, 0x00, 0x12);
4805 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC)
4806 xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x28);
4808 xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x08);
4811 static unsigned short XGI_GetColorDepth(unsigned short ModeNo,
4812 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
4814 unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8 };
4816 unsigned short modeflag;
4819 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
4821 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4823 index = (modeflag & ModeInfoFlag) - ModeEGA;
4828 return ColorDepth[index];
4831 static unsigned short XGI_GetOffset(unsigned short ModeNo,
4832 unsigned short ModeIdIndex,
4833 unsigned short RefreshRateTableIndex,
4834 struct xgi_hw_device_info *HwDeviceExtension,
4835 struct vb_device_info *pVBInfo)
4837 unsigned short temp, colordepth, modeinfo, index, infoflag,
4838 ColorDepth[] = { 0x01, 0x02, 0x04 };
4840 modeinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo;
4844 infoflag = pVBInfo->
4845 RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
4847 index = (modeinfo >> 8) & 0xFF;
4849 temp = pVBInfo->ScreenOffset[index];
4851 if (infoflag & InterlaceMode)
4854 colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo);
4856 if ((ModeNo >= 0x7C) && (ModeNo <= 0x7E)) {
4857 temp = ModeNo - 0x7C;
4858 colordepth = ColorDepth[temp];
4860 if (infoflag & InterlaceMode)
4862 return temp * colordepth;
4864 return temp * colordepth;
4868 static void XGI_SetCRT2Offset(unsigned short ModeNo,
4869 unsigned short ModeIdIndex,
4870 unsigned short RefreshRateTableIndex,
4871 struct xgi_hw_device_info *HwDeviceExtension,
4872 struct vb_device_info *pVBInfo)
4874 unsigned short offset;
4877 if (pVBInfo->VBInfo & SetInSlaveMode)
4880 offset = XGI_GetOffset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
4881 HwDeviceExtension, pVBInfo);
4882 temp = (unsigned char) (offset & 0xFF);
4883 xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp);
4884 temp = (unsigned char) ((offset & 0xFF00) >> 8);
4885 xgifb_reg_set(pVBInfo->Part1Port, 0x09, temp);
4886 temp = (unsigned char) (((offset >> 3) & 0xFF) + 1);
4887 xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp);
4890 static void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo)
4892 /* threshold high ,disable auto threshold */
4893 xgifb_reg_set(pVBInfo->Part1Port, 0x01, 0x3B);
4894 /* threshold low default 04h */
4895 xgifb_reg_and_or(pVBInfo->Part1Port, 0x02, ~(0x3F), 0x04);
4898 static void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
4899 struct xgi_hw_device_info *HwDeviceExtension,
4900 unsigned short RefreshRateTableIndex,
4901 struct vb_device_info *pVBInfo)
4903 unsigned short tempcx = 0, CRT1Index = 0, resinfo = 0;
4905 if (ModeNo > 0x13) {
4906 CRT1Index = pVBInfo->
4907 RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4908 CRT1Index &= IndexMask;
4909 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4912 XGI_SetCRT2Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
4913 HwDeviceExtension, pVBInfo);
4914 XGI_SetCRT2FIFO(pVBInfo);
4915 /* XGI_SetCRT2Sync(ModeNo,RefreshRateTableIndex); */
4917 for (tempcx = 4; tempcx < 7; tempcx++)
4918 xgifb_reg_set(pVBInfo->Part1Port, tempcx, 0x0);
4920 xgifb_reg_set(pVBInfo->Part1Port, 0x50, 0x00);
4921 xgifb_reg_set(pVBInfo->Part1Port, 0x02, 0x44); /* temp 0206 */
4924 static void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
4925 struct xgi_hw_device_info *HwDeviceExtension,
4926 unsigned short RefreshRateTableIndex,
4927 struct vb_device_info *pVBInfo)
4929 unsigned short temp = 0, tempax = 0, tempbx = 0, tempcx = 0,
4930 pushbx = 0, CRT1Index = 0, modeflag, resinfo = 0;
4932 if (ModeNo > 0x13) {
4933 CRT1Index = pVBInfo->
4934 RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4935 CRT1Index &= IndexMask;
4936 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4940 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
4942 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4944 /* bainy change table name */
4945 if (modeflag & HalfDCLK) {
4946 /* BTVGA2HT 0x08,0x09 */
4947 temp = (pVBInfo->VGAHT / 2 - 1) & 0x0FF;
4948 xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp);
4949 temp = (((pVBInfo->VGAHT / 2 - 1) & 0xFF00) >> 8) << 4;
4950 xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp);
4951 /* BTVGA2HDEE 0x0A,0x0C */
4952 temp = (pVBInfo->VGAHDE / 2 + 16) & 0x0FF;
4953 xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp);
4954 tempcx = ((pVBInfo->VGAHT - pVBInfo->VGAHDE) / 2) >> 2;
4955 pushbx = pVBInfo->VGAHDE / 2 + 16;
4956 tempcx = tempcx >> 1;
4957 tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */
4960 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
4961 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4];
4962 tempbx |= ((pVBInfo->
4963 XGINEWUB_CRT1Table[CRT1Index].CR[14] &
4965 tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */
4966 tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5];
4968 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[15];
4969 temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */
4970 tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */
4976 if (tempcx > (pVBInfo->VGAHT / 2))
4977 tempcx = pVBInfo->VGAHT / 2;
4979 temp = tempbx & 0x00FF;
4981 xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp);
4983 temp = (pVBInfo->VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */
4984 xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp);
4985 temp = (((pVBInfo->VGAHT - 1) & 0xFF00) >> 8) << 4;
4986 xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp);
4987 /* BTVGA2HDEE 0x0A,0x0C */
4988 temp = (pVBInfo->VGAHDE + 16) & 0x0FF;
4989 xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp);
4990 tempcx = (pVBInfo->VGAHT - pVBInfo->VGAHDE) >> 2; /* cx */
4991 pushbx = pVBInfo->VGAHDE + 16;
4992 tempcx = tempcx >> 1;
4993 tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */
4996 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
4997 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[3];
4998 tempbx |= ((pVBInfo->
4999 XGINEWUB_CRT1Table[CRT1Index].CR[5] &
5001 tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */
5002 tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4];
5004 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[6];
5005 temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */
5006 tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */
5011 if (tempcx > pVBInfo->VGAHT)
5012 tempcx = pVBInfo->VGAHT;
5014 temp = tempbx & 0x00FF;
5015 xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp);
5018 tempax = (tempax & 0x00FF) | (tempbx & 0xFF00);
5020 tempbx = (tempbx & 0x00FF) | ((tempbx & 0xFF00) << 4);
5021 tempax |= (tempbx & 0xFF00);
5022 temp = (tempax & 0xFF00) >> 8;
5023 xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp);
5024 temp = tempcx & 0x00FF;
5025 xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp);
5026 tempcx = (pVBInfo->VGAVT - 1);
5027 temp = tempcx & 0x00FF;
5029 if (pVBInfo->IF_DEF_CH7005 == 1) {
5030 if (pVBInfo->VBInfo & 0x0C)
5034 xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp);
5035 tempbx = pVBInfo->VGAVDE - 1;
5036 temp = tempbx & 0x00FF;
5037 xgifb_reg_set(pVBInfo->Part1Port, 0x0F, temp);
5038 temp = ((tempbx & 0xFF00) << 3) >> 8;
5039 temp |= ((tempcx & 0xFF00) >> 8);
5040 xgifb_reg_set(pVBInfo->Part1Port, 0x12, temp);
5042 tempax = pVBInfo->VGAVDE;
5043 tempbx = pVBInfo->VGAVDE;
5044 tempcx = pVBInfo->VGAVT;
5045 /* BTVGA2VRS 0x10,0x11 */
5046 tempbx = (pVBInfo->VGAVT + pVBInfo->VGAVDE) >> 1;
5047 /* BTVGA2VRE 0x11 */
5048 tempcx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) >> 4) + tempbx + 1;
5050 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
5051 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[10];
5052 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9];
5060 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14];
5065 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[11];
5066 tempcx = (tempcx & 0xFF00) | (temp & 0x00FF);
5069 temp = tempbx & 0x00FF;
5070 xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp);
5071 temp = ((tempbx & 0xFF00) >> 8) << 4;
5072 temp = ((tempcx & 0x000F) | (temp));
5073 xgifb_reg_set(pVBInfo->Part1Port, 0x11, temp);
5076 if (modeflag & DoubleScanMode)
5079 if (modeflag & HalfDCLK)
5082 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2C, ~0x0C0, tempax);
5085 static unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo)
5087 unsigned long tempax, tempbx;
5089 tempbx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) * pVBInfo->RVBHCMAX)
5091 tempax = (pVBInfo->VT - pVBInfo->VDE) * pVBInfo->RVBHCFACT;
5092 tempax = (tempax * pVBInfo->HT) / tempbx;
5094 return (unsigned short) tempax;
5097 static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
5098 struct xgi_hw_device_info *HwDeviceExtension,
5099 unsigned short RefreshRateTableIndex,
5100 struct vb_device_info *pVBInfo)
5102 unsigned short push1, push2, tempax, tempbx = 0, tempcx, temp, resinfo,
5103 modeflag, CRT1Index;
5105 if (ModeNo <= 0x13) {
5107 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
5108 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
5110 /* si+Ext_ResInfo */
5111 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
5112 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
5113 CRT1Index = pVBInfo->
5114 RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
5115 CRT1Index &= IndexMask;
5118 if (!(pVBInfo->VBInfo & SetInSlaveMode))
5121 temp = 0xFF; /* set MAX HT */
5122 xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp);
5123 /* if (modeflag & Charx8Dot) */
5124 /* tempcx = 0x08; */
5128 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C))
5129 modeflag |= Charx8Dot;
5131 tempax = pVBInfo->VGAHDE; /* 0x04 Horizontal Display End */
5133 if (modeflag & HalfDCLK)
5134 tempax = tempax >> 1;
5136 tempax = (tempax / tempcx) - 1;
5137 tempbx |= ((tempax & 0x00FF) << 8);
5138 temp = tempax & 0x00FF;
5139 xgifb_reg_set(pVBInfo->Part1Port, 0x04, temp);
5141 temp = (tempbx & 0xFF00) >> 8;
5143 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5144 if (!(pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5145 | VB_XGI302LV | VB_XGI301C)))
5148 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5149 if (pVBInfo->VBType & VB_XGI301LV) {
5150 if (pVBInfo->VBExtInfo == VB_YPbPr1080i) {
5154 } else if (resinfo == 7) {
5160 /* 0x05 Horizontal Display Start */
5161 xgifb_reg_set(pVBInfo->Part1Port, 0x05, temp);
5162 /* 0x06 Horizontal Blank end */
5163 xgifb_reg_set(pVBInfo->Part1Port, 0x06, 0x03);
5165 if (!(pVBInfo->VBInfo & DisableCRT2Display)) { /* 030226 bainy */
5166 if (pVBInfo->VBInfo & SetCRT2ToTV)
5167 tempax = pVBInfo->VGAHT;
5169 tempax = XGI_GetVGAHT2(pVBInfo);
5172 if (tempax >= pVBInfo->VGAHT)
5173 tempax = pVBInfo->VGAHT;
5175 if (modeflag & HalfDCLK)
5176 tempax = tempax >> 1;
5178 tempax = (tempax / tempcx) - 5;
5179 tempcx = tempax; /* 20030401 0x07 horizontal Retrace Start */
5180 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5181 temp = (tempbx & 0x00FF) - 1;
5182 if (!(modeflag & HalfDCLK)) {
5184 if (pVBInfo->TVInfo & TVSimuMode) {
5191 /* tempcx = tempbx & 0x00FF ; */
5192 tempbx = (tempbx & 0xFF00) >> 8;
5193 tempcx = (tempcx + tempbx) >> 1;
5194 temp = (tempcx & 0x00FF) + 2;
5196 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5198 if (!(modeflag & HalfDCLK)) {
5199 if ((modeflag & Charx8Dot)) {
5201 if (pVBInfo->VGAHDE >= 800)
5206 if (!(modeflag & HalfDCLK)) {
5208 if (pVBInfo->LCDResInfo != Panel1280x960) {
5209 if (pVBInfo->VGAHDE >= 800) {
5211 if (pVBInfo->ModeType ==
5213 if (pVBInfo->VGAVDE ==
5216 if (pVBInfo->LCDResInfo != Panel1280x1024) {
5223 if (pVBInfo->VGAHDE >= 1280) {
5224 if (pVBInfo->LCDResInfo
5226 if (pVBInfo->LCDInfo
5227 & LCDNonExpanding) {
5239 /* 0x07 Horizontal Retrace Start */
5240 xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp);
5241 /* 0x08 Horizontal Retrace End */
5242 xgifb_reg_set(pVBInfo->Part1Port, 0x08, 0);
5244 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5245 if (pVBInfo->TVInfo & TVSimuMode) {
5246 if ((ModeNo == 0x06) || (ModeNo == 0x10) || (ModeNo
5247 == 0x11) || (ModeNo == 0x13) || (ModeNo
5249 xgifb_reg_set(pVBInfo->Part1Port, 0x07, 0x5b);
5250 xgifb_reg_set(pVBInfo->Part1Port, 0x08, 0x03);
5253 if ((ModeNo == 0x00) || (ModeNo == 0x01)) {
5254 if (pVBInfo->TVInfo & SetNTSCTV) {
5255 xgifb_reg_set(pVBInfo->Part1Port,
5257 xgifb_reg_set(pVBInfo->Part1Port,
5260 xgifb_reg_set(pVBInfo->Part1Port,
5262 xgifb_reg_set(pVBInfo->Part1Port,
5264 xgifb_reg_set(pVBInfo->Part1Port,
5269 if ((ModeNo == 0x02) || (ModeNo == 0x03) || (ModeNo
5271 if (pVBInfo->TVInfo & SetNTSCTV) {
5272 xgifb_reg_set(pVBInfo->Part1Port,
5274 xgifb_reg_set(pVBInfo->Part1Port,
5277 xgifb_reg_set(pVBInfo->Part1Port,
5279 xgifb_reg_set(pVBInfo->Part1Port,
5281 xgifb_reg_set(pVBInfo->Part1Port,
5286 if ((ModeNo == 0x04) || (ModeNo == 0x05) || (ModeNo
5287 == 0x0D) || (ModeNo == 0x50)) {
5288 if (pVBInfo->TVInfo & SetNTSCTV) {
5289 xgifb_reg_set(pVBInfo->Part1Port,
5291 xgifb_reg_set(pVBInfo->Part1Port,
5294 xgifb_reg_set(pVBInfo->Part1Port,
5296 xgifb_reg_set(pVBInfo->Part1Port,
5303 xgifb_reg_set(pVBInfo->Part1Port, 0x18, 0x03); /* 0x18 SR0B */
5304 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0xF0, 0x00);
5305 xgifb_reg_set(pVBInfo->Part1Port, 0x09, 0xFF); /* 0x09 Set Max VT */
5307 tempbx = pVBInfo->VGAVT;
5310 tempbx = pVBInfo->VGAVDE; /* 0x0E Virtical Display End */
5325 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
5326 if (pVBInfo->LCDResInfo == Panel1024x768) {
5327 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
5336 temp = tempbx & 0x00FF;
5338 temp = tempbx & 0x00FF;
5339 /* 0x10 vertical Blank Start */
5340 xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp);
5343 temp = tempbx & 0x00FF;
5344 xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp);
5346 if (tempbx & 0x0100)
5351 if (modeflag & DoubleScanMode)
5354 if (tempbx & 0x0200)
5357 temp = (tempax & 0xFF00) >> 8;
5358 xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp);
5360 if (tempbx & 0x0400)
5363 /* 0x11 Vertival Blank End */
5364 xgifb_reg_set(pVBInfo->Part1Port, 0x11, 0x00);
5367 tempax -= tempbx; /* 0x0C Vertical Retrace Start */
5368 tempax = tempax >> 2;
5369 push1 = tempax; /* push ax */
5371 if (resinfo != 0x09) {
5372 tempax = tempax << 1;
5376 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5377 if (pVBInfo->VBType & VB_XGI301LV) {
5378 if (pVBInfo->TVInfo & SetYPbPrMode1080i) {
5381 if (pVBInfo->TVInfo & TVSimuMode) {
5382 if (pVBInfo->TVInfo & SetPALTV) {
5383 if (pVBInfo->VBType &
5385 if (!(pVBInfo->TVInfo &
5388 SetYPbPrMode1080i)))
5400 if (pVBInfo->TVInfo & TVSimuMode) {
5401 if (pVBInfo->TVInfo & SetPALTV) {
5402 if (pVBInfo->VBType & VB_XGI301LV) {
5403 if (!(pVBInfo->TVInfo &
5406 SetYPbPrMode1080i)))
5415 tempax = tempax >> 2;
5418 push1 = tempax; /* push ax */
5420 if ((pVBInfo->TVInfo & SetPALTV)) {
5421 if (tempbx <= 513) {
5427 temp = tempbx & 0x00FF;
5428 xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp);
5430 temp = tempbx & 0x00FF;
5431 xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp);
5433 if (tempbx & 0x0100)
5436 if (tempbx & 0x0200)
5437 xgifb_reg_and_or(pVBInfo->Part1Port, 0x0B, 0x0FF, 0x20);
5441 if (tempbx & 0x0100)
5444 if (tempbx & 0x0200)
5447 if (tempbx & 0x0400)
5450 tempbx = push1; /* pop ax */
5451 temp = tempbx & 0x00FF;
5453 /* 0x0D vertical Retrace End */
5454 xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp);
5456 if (tempbx & 0x0010)
5459 temp = tempcx & 0x00FF;
5460 xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); /* 0x0A CR07 */
5461 temp = (tempcx & 0x0FF00) >> 8;
5462 xgifb_reg_set(pVBInfo->Part1Port, 0x17, temp); /* 0x17 SR0A */
5464 temp = (tempax & 0xFF00) >> 8;
5466 temp = (temp >> 1) & 0x09;
5468 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C))
5471 xgifb_reg_set(pVBInfo->Part1Port, 0x16, temp); /* 0x16 SR01 */
5472 xgifb_reg_set(pVBInfo->Part1Port, 0x0F, 0); /* 0x0F CR14 */
5473 xgifb_reg_set(pVBInfo->Part1Port, 0x12, 0); /* 0x12 CR17 */
5475 if (pVBInfo->LCDInfo & LCDRGB18Bit)
5480 xgifb_reg_set(pVBInfo->Part1Port, 0x1A, temp); /* 0x1A SR0E */
5485 static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex,
5486 unsigned short RefreshRateTableIndex,
5487 struct xgi_hw_device_info *HwDeviceExtension,
5488 struct vb_device_info *pVBInfo)
5490 unsigned short i, j, tempax, tempbx, tempcx, temp, push1, push2,
5491 modeflag, resinfo, crt2crtc;
5492 unsigned char *TimingPoint;
5494 unsigned long longtemp, tempeax, tempebx, temp2, tempecx;
5496 if (ModeNo <= 0x13) {
5498 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
5499 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
5500 crt2crtc = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
5502 /* si+Ext_ResInfo */
5503 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
5504 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
5505 crt2crtc = pVBInfo->RefIndex[RefreshRateTableIndex].
5511 if (!(pVBInfo->VBInfo & SetCRT2ToAVIDEO))
5514 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
5517 if (pVBInfo->VBInfo & SetCRT2ToSCART)
5520 if (!(pVBInfo->TVInfo & SetPALTV))
5523 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5526 if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))
5529 tempax = (tempax & 0xff00) >> 8;
5531 xgifb_reg_set(pVBInfo->Part2Port, 0x0, tempax);
5532 TimingPoint = pVBInfo->NTSCTiming;
5534 if (pVBInfo->TVInfo & SetPALTV)
5535 TimingPoint = pVBInfo->PALTiming;
5537 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5538 TimingPoint = pVBInfo->HiTVExtTiming;
5540 if (pVBInfo->VBInfo & SetInSlaveMode)
5541 TimingPoint = pVBInfo->HiTVSt2Timing;
5543 if (pVBInfo->SetFlag & TVSimuMode)
5544 TimingPoint = pVBInfo->HiTVSt1Timing;
5546 if (!(modeflag & Charx8Dot))
5547 TimingPoint = pVBInfo->HiTVTextTiming;
5550 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
5551 if (pVBInfo->TVInfo & SetYPbPrMode525i)
5552 TimingPoint = pVBInfo->YPbPr525iTiming;
5554 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5555 TimingPoint = pVBInfo->YPbPr525pTiming;
5557 if (pVBInfo->TVInfo & SetYPbPrMode750p)
5558 TimingPoint = pVBInfo->YPbPr750pTiming;
5561 for (i = 0x01, j = 0; i <= 0x2D; i++, j++)
5562 xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]);
5564 for (i = 0x39; i <= 0x45; i++, j++)
5566 xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]);
5568 if (pVBInfo->VBInfo & SetCRT2ToTV)
5569 xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, 0x00);
5571 temp = pVBInfo->NewFlickerMode;
5573 xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xFF, temp);
5575 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5578 if (pVBInfo->TVInfo & SetPALTV)
5583 if (pVBInfo->VDE <= tempax) {
5584 tempax -= pVBInfo->VDE;
5585 tempax = tempax >> 2;
5586 tempax = (tempax & 0x00FF) | ((tempax & 0x00FF) << 8);
5588 temp = (tempax & 0xFF00) >> 8;
5589 temp += (unsigned short) TimingPoint[0];
5591 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5592 | VB_XGI302LV | VB_XGI301C)) {
5593 if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO
5594 | SetCRT2ToSVIDEO | SetCRT2ToSCART
5595 | SetCRT2ToYPbPr)) {
5596 tempcx = pVBInfo->VGAHDE;
5597 if (tempcx >= 1024) {
5598 temp = 0x17; /* NTSC */
5599 if (pVBInfo->TVInfo & SetPALTV)
5600 temp = 0x19; /* PAL */
5605 xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp);
5607 temp = (tempax & 0xFF00) >> 8;
5608 temp += TimingPoint[1];
5610 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5611 | VB_XGI302LV | VB_XGI301C)) {
5612 if ((pVBInfo->VBInfo & (SetCRT2ToAVIDEO
5613 | SetCRT2ToSVIDEO | SetCRT2ToSCART
5614 | SetCRT2ToYPbPr))) {
5615 tempcx = pVBInfo->VGAHDE;
5616 if (tempcx >= 1024) {
5617 temp = 0x1D; /* NTSC */
5618 if (pVBInfo->TVInfo & SetPALTV)
5619 temp = 0x52; /* PAL */
5623 xgifb_reg_set(pVBInfo->Part2Port, 0x02, temp);
5627 tempcx = pVBInfo->HT;
5629 if (XGI_IsLCDDualLink(pVBInfo))
5630 tempcx = tempcx >> 1;
5633 temp = tempcx & 0x00FF;
5634 xgifb_reg_set(pVBInfo->Part2Port, 0x1B, temp);
5636 temp = (tempcx & 0xFF00) >> 8;
5637 xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F, temp);
5639 tempcx = pVBInfo->HT >> 1;
5640 push1 = tempcx; /* push cx */
5643 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5646 temp = tempcx & 0x00FF;
5648 xgifb_reg_and_or(pVBInfo->Part2Port, 0x22, 0x0F, temp);
5650 tempbx = TimingPoint[j] | ((TimingPoint[j + 1]) << 8);
5653 temp = tempbx & 0x00FF;
5654 xgifb_reg_set(pVBInfo->Part2Port, 0x24, temp);
5655 temp = (tempbx & 0xFF00) >> 8;
5657 xgifb_reg_and_or(pVBInfo->Part2Port, 0x25, 0x0F, temp);
5660 tempbx = tempbx + 8;
5661 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5662 tempbx = tempbx - 4;
5666 temp = (tempbx & 0x00FF) << 4;
5667 xgifb_reg_and_or(pVBInfo->Part2Port, 0x29, 0x0F, temp);
5670 tempcx += (TimingPoint[j] | ((TimingPoint[j + 1]) << 8));
5671 temp = tempcx & 0x00FF;
5672 xgifb_reg_set(pVBInfo->Part2Port, 0x27, temp);
5673 temp = ((tempcx & 0xFF00) >> 8) << 4;
5674 xgifb_reg_and_or(pVBInfo->Part2Port, 0x28, 0x0F, temp);
5677 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5680 temp = tempcx & 0xFF;
5682 xgifb_reg_and_or(pVBInfo->Part2Port, 0x2A, 0x0F, temp);
5684 tempcx = push1; /* pop cx */
5686 temp = TimingPoint[j] | ((TimingPoint[j + 1]) << 8);
5688 temp = tempcx & 0x00FF;
5690 xgifb_reg_and_or(pVBInfo->Part2Port, 0x2D, 0x0F, temp);
5694 if (!(pVBInfo->VBInfo & SetCRT2ToTV)) {
5695 tempax = XGI_GetVGAHT2(pVBInfo);
5696 tempcx = tempax - 1;
5698 temp = tempcx & 0x00FF;
5699 xgifb_reg_set(pVBInfo->Part2Port, 0x2E, temp);
5701 tempbx = pVBInfo->VDE;
5703 if (pVBInfo->VGAVDE == 360)
5705 if (pVBInfo->VGAVDE == 375)
5707 if (pVBInfo->VGAVDE == 405)
5710 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5711 if (pVBInfo->VBType &
5712 (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
5713 if (!(pVBInfo->TVInfo &
5714 (SetYPbPrMode525p | SetYPbPrMode750p)))
5715 tempbx = tempbx >> 1;
5717 tempbx = tempbx >> 1;
5721 temp = tempbx & 0x00FF;
5723 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5724 if (pVBInfo->VBType & VB_XGI301LV) {
5725 if (pVBInfo->TVInfo & SetYPbPrMode1080i) {
5726 if (pVBInfo->VBInfo & SetInSlaveMode) {
5732 if (pVBInfo->VBInfo & SetInSlaveMode) {
5739 xgifb_reg_set(pVBInfo->Part2Port, 0x2F, temp);
5741 temp = (tempcx & 0xFF00) >> 8;
5742 temp |= ((tempbx & 0xFF00) >> 8) << 6;
5744 if (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)) {
5745 if (pVBInfo->VBType & VB_XGI301LV) {
5746 if (pVBInfo->TVInfo & SetYPbPrMode1080i) {
5749 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
5754 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
5759 xgifb_reg_set(pVBInfo->Part2Port, 0x30, temp);
5761 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5762 | VB_XGI302LV | VB_XGI301C)) { /* TV gatingno */
5763 tempbx = pVBInfo->VDE;
5764 tempcx = tempbx - 2;
5766 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5767 if (!(pVBInfo->TVInfo & (SetYPbPrMode525p
5768 | SetYPbPrMode750p)))
5769 tempbx = tempbx >> 1;
5772 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
5774 if (tempcx & 0x0400)
5777 if (tempbx & 0x0400)
5780 xgifb_reg_set(pVBInfo->Part4Port, 0x10, temp);
5783 temp = (((tempbx - 3) & 0x0300) >> 8) << 5;
5784 xgifb_reg_set(pVBInfo->Part2Port, 0x46, temp);
5785 temp = (tempbx - 3) & 0x00FF;
5786 xgifb_reg_set(pVBInfo->Part2Port, 0x47, temp);
5789 tempbx = tempbx & 0x00FF;
5791 if (!(modeflag & HalfDCLK)) {
5792 tempcx = pVBInfo->VGAHDE;
5793 if (tempcx >= pVBInfo->HDE) {
5801 if (pVBInfo->VBInfo & SetCRT2ToTV) { /*301b*/
5802 if (pVBInfo->VGAHDE >= 1024) {
5804 if (pVBInfo->VGAHDE >= 1280) {
5806 tempbx = tempbx & 0xDFFF;
5811 if (!(tempbx & 0x2000)) {
5812 if (modeflag & HalfDCLK)
5813 tempcx = (tempcx & 0xFF00) | ((tempcx & 0x00FF) << 1);
5816 tempeax = pVBInfo->VGAHDE;
5817 tempebx = (tempcx & 0xFF00) >> 8;
5818 longtemp = tempeax * tempebx;
5819 tempecx = tempcx & 0x00FF;
5820 longtemp = longtemp / tempecx;
5825 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5826 | VB_XGI302LV | VB_XGI301C)) {
5827 tempecx = tempecx * 8;
5830 longtemp = longtemp * tempecx;
5831 tempecx = pVBInfo->HDE;
5832 temp2 = longtemp % tempecx;
5833 tempeax = longtemp / tempecx;
5837 tempax = (unsigned short) tempeax;
5840 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5841 | VB_XGI302LV | VB_XGI301C)) {
5842 tempcx = ((tempax & 0xFF00) >> 5) >> 8;
5847 tempbx = (unsigned short) (((tempeax & 0x0000FF00) & 0x1F00)
5848 | (tempbx & 0x00FF));
5849 tempax = (unsigned short) (((tempeax & 0x000000FF) << 8)
5850 | (tempax & 0x00FF));
5851 temp = (tempax & 0xFF00) >> 8;
5853 temp = (tempax & 0x00FF) >> 8;
5856 xgifb_reg_set(pVBInfo->Part2Port, 0x44, temp);
5857 temp = (tempbx & 0xFF00) >> 8;
5858 xgifb_reg_and_or(pVBInfo->Part2Port, 0x45, ~0x03F, temp);
5859 temp = tempcx & 0x00FF;
5861 if (tempbx & 0x2000)
5864 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
5867 xgifb_reg_and_or(pVBInfo->Part2Port, 0x46, ~0x1F, temp);
5868 if (pVBInfo->TVInfo & SetPALTV) {
5876 temp = tempbx & 0x00FF;
5877 xgifb_reg_set(pVBInfo->Part2Port, 0x4b, temp);
5878 temp = tempcx & 0x00FF;
5879 xgifb_reg_set(pVBInfo->Part2Port, 0x4c, temp);
5881 temp = ((tempcx & 0xFF00) >> 8) & 0x03;
5883 temp |= ((tempbx & 0xFF00) >> 8) & 0x03;
5885 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
5888 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5891 if (pVBInfo->TVInfo & SetYPbPrMode750p)
5895 xgifb_reg_set(pVBInfo->Part2Port, 0x4d, temp);
5896 temp = xgifb_reg_get(pVBInfo->Part2Port, 0x43); /* 301b change */
5897 xgifb_reg_set(pVBInfo->Part2Port, 0x43, (unsigned short) (temp - 3));
5899 if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))) {
5900 if (pVBInfo->TVInfo & NTSC1024x768) {
5901 TimingPoint = XGI_NTSC1024AdjTime;
5902 for (i = 0x1c, j = 0; i <= 0x30; i++, j++) {
5903 xgifb_reg_set(pVBInfo->Part2Port, i,
5906 xgifb_reg_set(pVBInfo->Part2Port, 0x43, 0x72);
5910 /* [ycchen] 01/14/03 Modify for 301C PALM Support */
5911 if (pVBInfo->VBType & VB_XGI301C) {
5912 if (pVBInfo->TVInfo & SetPALMTV)
5913 xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x08,
5914 0x08); /* PALM Mode */
5917 if (pVBInfo->TVInfo & SetPALMTV) {
5918 tempax = (unsigned char) xgifb_reg_get(pVBInfo->Part2Port,
5921 xgifb_reg_and(pVBInfo->Part2Port, 0x01, tempax);
5923 /* if ( !( pVBInfo->VBType & VB_XGI301C ) ) */
5924 xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xEF);
5927 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5928 if (!(pVBInfo->VBInfo & SetInSlaveMode))
5929 xgifb_reg_set(pVBInfo->Part2Port, 0x0B, 0x00);
5932 if (pVBInfo->VBInfo & SetCRT2ToTV)
5936 static void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
5937 struct xgi_hw_device_info *HwDeviceExtension,
5938 unsigned short RefreshRateTableIndex,
5939 struct vb_device_info *pVBInfo)
5941 unsigned short push1, push2, pushbx, tempax, tempbx, tempcx, temp,
5942 tempah, tempbh, tempch, resinfo, modeflag, CRT1Index;
5944 struct XGI_LCDDesStruct *LCDBDesPtr = NULL;
5946 if (ModeNo <= 0x13) {
5948 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
5949 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
5951 /* si+Ext_ResInfo */
5952 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
5953 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
5954 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].
5956 CRT1Index &= IndexMask;
5959 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
5962 tempbx = pVBInfo->HDE; /* RHACTE=HDE-1 */
5964 if (XGI_IsLCDDualLink(pVBInfo))
5965 tempbx = tempbx >> 1;
5968 temp = tempbx & 0x00FF;
5969 xgifb_reg_set(pVBInfo->Part2Port, 0x2C, temp);
5970 temp = (tempbx & 0xFF00) >> 8;
5972 xgifb_reg_and_or(pVBInfo->Part2Port, 0x2B, 0x0F, temp);
5975 if (pVBInfo->LCDResInfo == Panel1280x1024) {
5976 if (pVBInfo->ModeType == ModeEGA) {
5977 if (pVBInfo->VGAHDE >= 1024) {
5979 if (pVBInfo->LCDInfo & LCDVESATiming)
5985 xgifb_reg_set(pVBInfo->Part2Port, 0x0B, temp);
5986 tempbx = pVBInfo->VDE; /* RTVACTEO=(VDE-1)&0xFF */
5989 temp = tempbx & 0x00FF;
5990 xgifb_reg_set(pVBInfo->Part2Port, 0x03, temp);
5991 temp = ((tempbx & 0xFF00) >> 8) & 0x07;
5992 xgifb_reg_and_or(pVBInfo->Part2Port, 0x0C, ~0x07, temp);
5994 tempcx = pVBInfo->VT - 1;
5996 temp = tempcx & 0x00FF; /* RVTVT=VT-1 */
5997 xgifb_reg_set(pVBInfo->Part2Port, 0x19, temp);
5998 temp = (tempcx & 0xFF00) >> 8;
6000 xgifb_reg_set(pVBInfo->Part2Port, 0x1A, temp);
6001 xgifb_reg_and_or(pVBInfo->Part2Port, 0x09, 0xF0, 0x00);
6002 xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xF0, 0x00);
6003 xgifb_reg_and_or(pVBInfo->Part2Port, 0x17, 0xFB, 0x00);
6004 xgifb_reg_and_or(pVBInfo->Part2Port, 0x18, 0xDF, 0x00);
6006 /* Customized LCDB Des no add */
6008 LCDBDesPtr = (struct XGI_LCDDesStruct *) XGI_GetLcdPtr(tempbx, ModeNo,
6009 ModeIdIndex, RefreshRateTableIndex, pVBInfo);
6010 tempah = pVBInfo->LCDResInfo;
6011 tempah &= PanelResInfo;
6013 if ((tempah == Panel1024x768) || (tempah == Panel1024x768x75)) {
6016 } else if ((tempah == Panel1280x1024) ||
6017 (tempah == Panel1280x1024x75)) {
6020 } else if (tempah == Panel1400x1050) {
6028 if (pVBInfo->LCDInfo & EnableScalingLCD) {
6029 tempbx = pVBInfo->HDE;
6030 tempcx = pVBInfo->VDE;
6034 tempax = pVBInfo->VT;
6035 pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES;
6036 pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS;
6037 pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES;
6038 pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS;
6039 tempbx = pVBInfo->LCDVDES;
6042 if (tempcx >= tempax)
6043 tempcx -= tempax; /* lcdvdes */
6045 temp = tempbx & 0x00FF; /* RVEQ1EQ=lcdvdes */
6046 xgifb_reg_set(pVBInfo->Part2Port, 0x05, temp);
6047 temp = tempcx & 0x00FF;
6048 xgifb_reg_set(pVBInfo->Part2Port, 0x06, temp);
6049 tempch = ((tempcx & 0xFF00) >> 8) & 0x07;
6050 tempbh = ((tempbx & 0xFF00) >> 8) & 0x07;
6052 tempah = tempah << 3;
6054 xgifb_reg_set(pVBInfo->Part2Port, 0x02, tempah);
6057 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
6059 tempax = pVBInfo->VT;
6060 tempbx = pVBInfo->LCDVRS;
6062 /* if (SetLCD_Info & EnableScalingLCD) */
6064 if (tempcx >= tempax)
6067 temp = tempbx & 0x00FF; /* RTVACTEE=lcdvrs */
6068 xgifb_reg_set(pVBInfo->Part2Port, 0x04, temp);
6069 temp = (tempbx & 0xFF00) >> 8;
6071 temp |= (tempcx & 0x000F);
6072 xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp);
6074 tempax = pVBInfo->HT;
6075 tempbx = pVBInfo->LCDHDES;
6078 if (XGI_IsLCDDualLink(pVBInfo)) {
6079 tempax = tempax >> 1;
6080 tempbx = tempbx >> 1;
6081 tempcx = tempcx >> 1;
6084 if (pVBInfo->VBType & VB_XGI302LV)
6087 if (pVBInfo->VBType & VB_XGI301C) /* tap4 */
6092 if (tempcx >= tempax)
6095 temp = tempbx & 0x00FF;
6096 xgifb_reg_set(pVBInfo->Part2Port, 0x1F, temp); /* RHBLKE=lcdhdes */
6097 temp = ((tempbx & 0xFF00) >> 8) << 4;
6098 xgifb_reg_set(pVBInfo->Part2Port, 0x20, temp);
6099 temp = tempcx & 0x00FF;
6100 xgifb_reg_set(pVBInfo->Part2Port, 0x23, temp); /* RHEQPLE=lcdhdee */
6101 temp = (tempcx & 0xFF00) >> 8;
6102 xgifb_reg_set(pVBInfo->Part2Port, 0x25, temp);
6105 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
6107 tempax = pVBInfo->HT;
6108 tempbx = pVBInfo->LCDHRS;
6109 /* if ( SetLCD_Info & EnableScalingLCD) */
6110 if (XGI_IsLCDDualLink(pVBInfo)) {
6111 tempax = tempax >> 1;
6112 tempbx = tempbx >> 1;
6113 tempcx = tempcx >> 1;
6116 if (pVBInfo->VBType & VB_XGI302LV)
6121 if (tempcx >= tempax)
6124 temp = tempbx & 0x00FF; /* RHBURSTS=lcdhrs */
6125 xgifb_reg_set(pVBInfo->Part2Port, 0x1C, temp);
6127 temp = (tempbx & 0xFF00) >> 8;
6129 xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F0, temp);
6130 temp = tempcx & 0x00FF; /* RHSYEXP2S=lcdhre */
6131 xgifb_reg_set(pVBInfo->Part2Port, 0x21, temp);
6133 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
6134 if (pVBInfo->VGAVDE == 525) {
6135 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
6136 | VB_XGI301LV | VB_XGI302LV
6142 xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp);
6143 xgifb_reg_set(pVBInfo->Part2Port, 0x30, 0xB3);
6146 if (pVBInfo->VGAVDE == 420) {
6147 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
6148 | VB_XGI301LV | VB_XGI302LV
6153 xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp);
6158 /* --------------------------------------------------------------------- */
6159 /* Function : XGI_GetTap4Ptr */
6161 /* Output : di -> Tap4 Reg. Setting Pointer */
6163 /* --------------------------------------------------------------------- */
6164 static struct XGI301C_Tap4TimingStruct *XGI_GetTap4Ptr(unsigned short tempcx,
6165 struct vb_device_info *pVBInfo)
6167 unsigned short tempax, tempbx, i;
6169 struct XGI301C_Tap4TimingStruct *Tap4TimingPtr;
6172 tempax = pVBInfo->VGAHDE;
6173 tempbx = pVBInfo->HDE;
6175 tempax = pVBInfo->VGAVDE;
6176 tempbx = pVBInfo->VDE;
6179 if (tempax < tempbx)
6180 return &EnlargeTap4Timing[0];
6181 else if (tempax == tempbx)
6182 return &NoScaleTap4Timing[0]; /* 1:1 */
6184 Tap4TimingPtr = NTSCTap4Timing; /* NTSC */
6186 if (pVBInfo->TVInfo & SetPALTV)
6187 Tap4TimingPtr = PALTap4Timing;
6189 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
6190 if (pVBInfo->TVInfo & SetYPbPrMode525i)
6191 Tap4TimingPtr = YPbPr525iTap4Timing;
6192 if (pVBInfo->TVInfo & SetYPbPrMode525p)
6193 Tap4TimingPtr = YPbPr525pTap4Timing;
6194 if (pVBInfo->TVInfo & SetYPbPrMode750p)
6195 Tap4TimingPtr = YPbPr750pTap4Timing;
6198 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
6199 Tap4TimingPtr = HiTVTap4Timing;
6202 while (Tap4TimingPtr[i].DE != 0xFFFF) {
6203 if (Tap4TimingPtr[i].DE == tempax)
6207 return &Tap4TimingPtr[i];
6210 static void XGI_SetTap4Regs(struct vb_device_info *pVBInfo)
6212 unsigned short i, j;
6214 struct XGI301C_Tap4TimingStruct *Tap4TimingPtr;
6216 if (!(pVBInfo->VBType & VB_XGI301C))
6220 xgifb_reg_and(pVBInfo->Part2Port, 0x4E, 0xEB); /* Disable Tap4 */
6221 #else /* Tap4 Setting */
6223 Tap4TimingPtr = XGI_GetTap4Ptr(0, pVBInfo); /* Set Horizontal Scaling */
6224 for (i = 0x80, j = 0; i <= 0xBF; i++, j++)
6225 xgifb_reg_set(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]);
6227 if ((pVBInfo->VBInfo & SetCRT2ToTV) &&
6228 (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV))) {
6229 /* Set Vertical Scaling */
6230 Tap4TimingPtr = XGI_GetTap4Ptr(1, pVBInfo);
6231 for (i = 0xC0, j = 0; i < 0xFF; i++, j++)
6232 xgifb_reg_set(pVBInfo->Part2Port,
6234 Tap4TimingPtr->Reg[j]);
6237 if ((pVBInfo->VBInfo & SetCRT2ToTV) &&
6238 (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)))
6239 /* Enable V.Scaling */
6240 xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x04);
6242 /* Enable H.Scaling */
6243 xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x10);
6247 static void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex,
6248 struct vb_device_info *pVBInfo)
6251 unsigned char *tempdi;
6252 unsigned short modeflag;
6256 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
6258 /* si+Ext_ResInfo */
6259 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
6261 xgifb_reg_set(pVBInfo->Part3Port, 0x00, 0x00);
6262 if (pVBInfo->TVInfo & SetPALTV) {
6263 xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA);
6264 xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8);
6266 xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xF5);
6267 xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xB7);
6270 if (!(pVBInfo->VBInfo & SetCRT2ToTV))
6273 if (pVBInfo->TVInfo & SetPALMTV) {
6274 xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA);
6275 xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8);
6276 xgifb_reg_set(pVBInfo->Part3Port, 0x3D, 0xA8);
6279 if ((pVBInfo->VBInfo & SetCRT2ToHiVisionTV) || (pVBInfo->VBInfo
6280 & SetCRT2ToYPbPr)) {
6281 if (pVBInfo->TVInfo & SetYPbPrMode525i)
6284 tempdi = pVBInfo->HiTVGroup3Data;
6285 if (pVBInfo->SetFlag & TVSimuMode) {
6286 tempdi = pVBInfo->HiTVGroup3Simu;
6287 if (!(modeflag & Charx8Dot))
6288 tempdi = pVBInfo->HiTVGroup3Text;
6291 if (pVBInfo->TVInfo & SetYPbPrMode525p)
6292 tempdi = pVBInfo->Ren525pGroup3;
6294 if (pVBInfo->TVInfo & SetYPbPrMode750p)
6295 tempdi = pVBInfo->Ren750pGroup3;
6297 for (i = 0; i <= 0x3E; i++)
6298 xgifb_reg_set(pVBInfo->Part3Port, i, tempdi[i]);
6300 if (pVBInfo->VBType & VB_XGI301C) { /* Marcovision */
6301 if (pVBInfo->TVInfo & SetYPbPrMode525p)
6302 xgifb_reg_set(pVBInfo->Part3Port, 0x28, 0x3f);
6306 } /* {end of XGI_SetGroup3} */
6308 static void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex,
6309 unsigned short RefreshRateTableIndex,
6310 struct xgi_hw_device_info *HwDeviceExtension,
6311 struct vb_device_info *pVBInfo)
6313 unsigned short tempax, tempcx, tempbx, modeflag, temp, temp2;
6315 unsigned long tempebx, tempeax, templong;
6319 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
6321 /* si+Ext_ResInfo */
6322 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
6324 temp = pVBInfo->RVBHCFACT;
6325 xgifb_reg_set(pVBInfo->Part4Port, 0x13, temp);
6327 tempbx = pVBInfo->RVBHCMAX;
6328 temp = tempbx & 0x00FF;
6329 xgifb_reg_set(pVBInfo->Part4Port, 0x14, temp);
6330 temp2 = ((tempbx & 0xFF00) >> 8) << 7;
6331 tempcx = pVBInfo->VGAHT - 1;
6332 temp = tempcx & 0x00FF;
6333 xgifb_reg_set(pVBInfo->Part4Port, 0x16, temp);
6335 temp = ((tempcx & 0xFF00) >> 8) << 3;
6338 tempcx = pVBInfo->VGAVT - 1;
6339 if (!(pVBInfo->VBInfo & SetCRT2ToTV))
6342 temp = tempcx & 0x00FF;
6343 xgifb_reg_set(pVBInfo->Part4Port, 0x17, temp);
6344 temp = temp2 | ((tempcx & 0xFF00) >> 8);
6345 xgifb_reg_set(pVBInfo->Part4Port, 0x15, temp);
6346 xgifb_reg_or(pVBInfo->Part4Port, 0x0D, 0x08);
6347 tempcx = pVBInfo->VBInfo;
6348 tempbx = pVBInfo->VGAHDE;
6350 if (modeflag & HalfDCLK)
6351 tempbx = tempbx >> 1;
6353 if (XGI_IsLCDDualLink(pVBInfo))
6354 tempbx = tempbx >> 1;
6356 if (tempcx & SetCRT2ToHiVisionTV) {
6362 } else if (tempcx & SetCRT2ToTV) {
6368 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
6375 if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)) {
6377 if (pVBInfo->VGAHDE == 1280)
6379 if (pVBInfo->VGAHDE == 1024)
6382 xgifb_reg_and_or(pVBInfo->Part4Port, 0x0E, ~0xEF, temp);
6384 tempebx = pVBInfo->VDE;
6386 if (tempcx & SetCRT2ToHiVisionTV) {
6387 if (!(temp & 0xE000))
6388 tempbx = tempbx >> 1;
6391 tempcx = pVBInfo->RVBHRS;
6392 temp = tempcx & 0x00FF;
6393 xgifb_reg_set(pVBInfo->Part4Port, 0x18, temp);
6395 tempeax = pVBInfo->VGAVDE;
6398 if (tempeax <= tempebx) {
6399 tempcx = (tempcx & (~0x4000));
6400 tempeax = pVBInfo->VGAVDE;
6405 templong = (tempeax * 256 * 1024) % tempebx;
6406 tempeax = (tempeax * 256 * 1024) / tempebx;
6412 temp = (unsigned short) (tempebx & 0x000000FF);
6413 xgifb_reg_set(pVBInfo->Part4Port, 0x1B, temp);
6415 temp = (unsigned short) ((tempebx & 0x0000FF00) >> 8);
6416 xgifb_reg_set(pVBInfo->Part4Port, 0x1A, temp);
6417 tempbx = (unsigned short) (tempebx >> 16);
6418 temp = tempbx & 0x00FF;
6420 temp |= ((tempcx & 0xFF00) >> 8);
6421 xgifb_reg_set(pVBInfo->Part4Port, 0x19, temp);
6424 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
6425 | VB_XGI302LV | VB_XGI301C)) {
6427 xgifb_reg_set(pVBInfo->Part4Port, 0x1C, temp);
6428 tempax = pVBInfo->VGAHDE;
6429 if (modeflag & HalfDCLK)
6430 tempax = tempax >> 1;
6432 if (XGI_IsLCDDualLink(pVBInfo))
6433 tempax = tempax >> 1;
6435 /* if((pVBInfo->VBInfo&(SetCRT2ToLCD)) ||
6436 ((pVBInfo->TVInfo&SetYPbPrMode525p) ||
6437 (pVBInfo->TVInfo&SetYPbPrMode750p))) { */
6438 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
6442 if (pVBInfo->VGAHDE > 800) {
6443 if (pVBInfo->VGAHDE == 1024)
6444 tempax = (tempax * 25 / 32) - 1;
6446 tempax = (tempax * 20 / 32) - 1;
6452 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVisionTV)) {
6453 if (pVBInfo->VBType & VB_XGI301LV) {
6454 if (!(pVBInfo->TVInfo &
6457 SetYPbPrMode1080i))) {
6458 if (pVBInfo->VGAHDE > 800) {
6459 if (pVBInfo->VGAHDE == 1024)
6460 tempax =(tempax * 25 /
6463 tempax = (tempax * 20 /
6468 if (pVBInfo->VGAHDE > 800) {
6469 if (pVBInfo->VGAHDE == 1024)
6470 tempax = (tempax * 25 / 32) - 1;
6472 tempax = (tempax * 20 / 32) - 1;
6478 temp = (tempax & 0xFF00) >> 8;
6479 temp = ((temp & 0x0003) << 4);
6480 xgifb_reg_set(pVBInfo->Part4Port, 0x1E, temp);
6481 temp = (tempax & 0x00FF);
6482 xgifb_reg_set(pVBInfo->Part4Port, 0x1D, temp);
6484 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVisionTV)) {
6485 if (pVBInfo->VGAHDE > 800)
6486 xgifb_reg_or(pVBInfo->Part4Port, 0x1E, 0x08);
6491 if (pVBInfo->VBInfo & SetCRT2ToTV) {
6492 if (!(pVBInfo->TVInfo & (NTSC1024x768
6493 | SetYPbPrMode525p | SetYPbPrMode750p
6494 | SetYPbPrMode1080i))) {
6496 if ((pVBInfo->VBInfo & SetInSlaveMode)
6497 && (!(pVBInfo->TVInfo
6503 xgifb_reg_and_or(pVBInfo->Part4Port, 0x1F, 0x00C0, temp);
6504 tempbx = pVBInfo->HT;
6505 if (XGI_IsLCDDualLink(pVBInfo))
6506 tempbx = tempbx >> 1;
6507 tempbx = (tempbx >> 1) - 2;
6508 temp = ((tempbx & 0x0700) >> 8) << 3;
6509 xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, 0x00C0, temp);
6510 temp = tempbx & 0x00FF;
6511 xgifb_reg_set(pVBInfo->Part4Port, 0x22, temp);
6515 if (pVBInfo->ISXPDOS == 0)
6516 XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex,
6520 static void XGINew_EnableCRT2(struct vb_device_info *pVBInfo)
6522 xgifb_reg_and_or(pVBInfo->P3c4, 0x1E, 0xFF, 0x20);
6525 static void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex,
6526 struct vb_device_info *pVBInfo)
6528 unsigned short Pindex, Pdata;
6530 Pindex = pVBInfo->Part5Port;
6531 Pdata = pVBInfo->Part5Port + 1;
6532 if (pVBInfo->ModeType == ModeVGA) {
6533 if (!(pVBInfo->VBInfo & (SetInSlaveMode | LoadDACFlag
6534 | CRT2DisplayFlag))) {
6535 XGINew_EnableCRT2(pVBInfo);
6536 /* LoadDAC2(pVBInfo->Part5Port, ModeNo, ModeIdIndex); */
6542 static void XGI_EnableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension,
6543 struct vb_device_info *pVBInfo)
6545 xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x40);
6548 static void XGI_DisableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension,
6549 struct vb_device_info *pVBInfo)
6552 xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x00);
6555 /*----------------------------------------------------------------------------*/
6557 /* bl[5] : 1;LVDS signal on */
6558 /* bl[1] : 1;LVDS backlight on */
6559 /* bl[0] : 1:LVDS VDD on */
6560 /* bh: 100000b : clear bit 5, to set bit5 */
6561 /* 000010b : clear bit 1, to set bit1 */
6562 /* 000001b : clear bit 0, to set bit0 */
6563 /*----------------------------------------------------------------------------*/
6564 void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl,
6565 struct vb_device_info *pVBInfo)
6567 unsigned char CR4A, temp;
6569 CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
6572 xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */
6574 if (tempbh & 0x20) {
6575 temp = (tempbl >> 4) & 0x02;
6578 xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp);
6582 temp = xgifb_reg_get(pVBInfo->P3d4, 0x48);
6584 temp = XG21GPIODataTransfer(temp);
6587 xgifb_reg_set(pVBInfo->P3d4, 0x48, temp);
6590 void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl,
6591 struct vb_device_info *pVBInfo)
6593 unsigned char CR4A, temp;
6594 unsigned short tempbh0, tempbl0;
6603 if (tempbh & 0x20) {
6604 temp = (tempbl >> 4) & 0x02;
6607 xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp);
6610 xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~tempbh0, tempbl0);
6612 CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
6616 tempbl <<= 2; /* GPIOC,GPIOD */
6617 xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */
6618 xgifb_reg_and_or(pVBInfo->P3d4, 0x48, ~tempbh, tempbl);
6621 /* --------------------------------------------------------------------- */
6622 unsigned short XGI_GetLVDSOEMTableIndex(struct vb_device_info *pVBInfo)
6624 unsigned short index;
6626 index = xgifb_reg_get(pVBInfo->P3d4, 0x36);
6627 if (index < sizeof(XGI21_LCDCapList)
6628 / sizeof(struct XGI21_LVDSCapStruct))
6633 /* --------------------------------------------------------------------- */
6634 /* Function : XGI_XG21SetPanelDelay */
6638 /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
6639 /* : bl : 2 ; T2 : the duration signal on and Vdd on */
6640 /* : bl : 3 ; T3 : the duration between CPL off and signal off */
6641 /* : bl : 4 ; T4 : the duration signal off and Vdd off */
6642 /* --------------------------------------------------------------------- */
6643 void XGI_XG21SetPanelDelay(unsigned short tempbl,
6644 struct vb_device_info *pVBInfo)
6646 unsigned short index;
6648 index = XGI_GetLVDSOEMTableIndex(pVBInfo);
6650 mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S1);
6653 mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S2);
6656 mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S3);
6659 mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S4);
6662 unsigned char XGI_XG21CheckLVDSMode(unsigned short ModeNo,
6663 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
6665 unsigned short xres, yres, colordepth, modeflag, resindex,
6668 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
6669 if (ModeNo <= 0x13) {
6670 xres = pVBInfo->StResInfo[resindex].HTotal;
6671 yres = pVBInfo->StResInfo[resindex].VTotal;
6673 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
6675 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
6676 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
6677 /* si+St_ModeFlag */
6678 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
6681 if (!(modeflag & Charx8Dot)) {
6686 if (ModeNo > 0x13) {
6687 if ((ModeNo > 0x13) && (modeflag & HalfDCLK))
6690 if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
6695 lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo);
6696 if (xres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE))
6699 if (yres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE))
6702 if (ModeNo > 0x13) {
6703 if ((xres != (pVBInfo->XG21_LVDSCapList[lvdstableindex].
6705 (yres != (pVBInfo->XG21_LVDSCapList[lvdstableindex].
6707 colordepth = XGI_GetColorDepth(ModeNo,
6718 void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo)
6722 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); /* D[0] 1: 18bit */
6723 temp = (temp & 1) << 6;
6724 /* SR06[6] 18bit Dither */
6725 xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x40, temp);
6726 /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */
6727 xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80);
6731 void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo)
6735 /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */
6736 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
6737 temp = (temp & 3) << 6;
6738 /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */
6739 xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0xc0, temp & 0x80);
6740 /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */
6741 xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80);
6745 static void XGI_SetXG21LVDSPara(unsigned short ModeNo,
6746 unsigned short ModeIdIndex,
6747 struct vb_device_info *pVBInfo)
6749 unsigned char temp, Miscdata;
6750 unsigned short xres, yres, modeflag, resindex, lvdstableindex;
6751 unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE;
6752 unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE;
6753 unsigned short value;
6755 lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo);
6757 temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex].
6759 (LCDPolarity << 8)) >> 8);
6760 temp &= LCDPolarity;
6761 Miscdata = (unsigned char) inb(pVBInfo->P3cc);
6763 outb((Miscdata & 0x3F) | temp, pVBInfo->P3c2);
6765 temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex].
6766 LVDS_Capability & LCDPolarity);
6767 /* SR35[7] FP VSync polarity */
6768 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80);
6769 /* SR30[5] FP HSync polarity */
6770 xgifb_reg_and_or(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1);
6772 XGI_SetXG21FPBits(pVBInfo);
6773 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
6774 if (ModeNo <= 0x13) {
6775 xres = pVBInfo->StResInfo[resindex].HTotal;
6776 yres = pVBInfo->StResInfo[resindex].VTotal;
6778 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
6780 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
6781 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
6782 /* si+St_ModeFlag */
6783 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
6786 if (!(modeflag & Charx8Dot))
6787 xres = xres * 8 / 9;
6789 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
6791 LVDSHBS = xres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE
6793 if ((ModeNo <= 0x13) && (modeflag & HalfDCLK))
6794 LVDSHBS -= xres / 4;
6796 if (LVDSHBS > LVDSHT)
6799 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP;
6800 if (LVDSHRS > LVDSHT)
6803 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC;
6804 if (LVDSHRE > LVDSHT)
6807 LVDSHBE = LVDSHBS + LVDSHT
6808 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE;
6810 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
6812 LVDSVBS = yres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE
6814 if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
6815 LVDSVBS += yres / 2;
6817 if (LVDSVBS > LVDSVT)
6820 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP;
6821 if (LVDSVRS > LVDSVT)
6824 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC;
6825 if (LVDSVRE > LVDSVT)
6828 LVDSVBE = LVDSVBS + LVDSVT
6829 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE;
6831 temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
6832 xgifb_reg_set(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */
6834 if (!(modeflag & Charx8Dot))
6835 xgifb_reg_or(pVBInfo->P3c4, 0x1, 0x1);
6837 /* HT SR0B[1:0] CR00 */
6838 value = (LVDSHT >> 3) - 5;
6839 xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8);
6840 xgifb_reg_set(pVBInfo->P3d4, 0x0, (value & 0xFF));
6842 /* HBS SR0B[5:4] CR02 */
6843 value = (LVDSHBS >> 3) - 1;
6844 xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4);
6845 xgifb_reg_set(pVBInfo->P3d4, 0x2, (value & 0xFF));
6847 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
6848 value = (LVDSHBE >> 3) - 1;
6849 xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6);
6850 xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2);
6851 xgifb_reg_and_or(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F);
6853 /* HRS SR0B[7:6] CR04 */
6854 value = (LVDSHRS >> 3) + 2;
6855 xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2);
6856 xgifb_reg_set(pVBInfo->P3d4, 0x4, (value & 0xFF));
6858 /* Panel HRS SR2F[1:0] SR2E[7:0] */
6860 xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8);
6861 xgifb_reg_set(pVBInfo->P3c4, 0x2E, (value & 0xFF));
6863 /* HRE SR0C[2] CR05[4:0] */
6864 value = (LVDSHRE >> 3) + 2;
6865 xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3);
6866 xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F);
6868 /* Panel HRE SR2F[7:2] */
6870 xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2);
6872 /* VT SR0A[0] CR07[5][0] CR06 */
6874 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10);
6875 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4);
6876 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8);
6877 xgifb_reg_set(pVBInfo->P3d4, 0x06, (value & 0xFF));
6879 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
6880 value = LVDSVBS - 1;
6881 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8);
6882 xgifb_reg_and_or(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4);
6883 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5);
6884 xgifb_reg_set(pVBInfo->P3d4, 0x15, (value & 0xFF));
6886 /* VBE SR0A[4] CR16 */
6887 value = LVDSVBE - 1;
6888 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4);
6889 xgifb_reg_set(pVBInfo->P3d4, 0x16, (value & 0xFF));
6891 /* VRS SR0A[3] CR7[7][2] CR10 */
6892 value = LVDSVRS - 1;
6893 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7);
6894 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2);
6895 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6);
6896 xgifb_reg_set(pVBInfo->P3d4, 0x10, (value & 0xFF));
6898 /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */
6899 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0x03, (value & 0x600) >> 9);
6900 xgifb_reg_set(pVBInfo->P3c4, 0x34, (value >> 1) & 0xFF);
6901 xgifb_reg_and_or(pVBInfo->P3d4, 0x33, ~0x01, value & 0x01);
6903 /* VRE SR0A[5] CR11[3:0] */
6904 value = LVDSVRE - 1;
6905 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1);
6906 xgifb_reg_and_or(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F);
6908 /* Panel VRE SR3F[7:2] *//* SR3F[7] has to be 0, h/w bug */
6909 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, (value << 2) & 0x7C);
6911 for (temp = 0, value = 0; temp < 3; temp++) {
6913 xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, value);
6914 xgifb_reg_set(pVBInfo->P3c4,
6916 pVBInfo->XG21_LVDSCapList[lvdstableindex].
6918 xgifb_reg_set(pVBInfo->P3c4,
6920 pVBInfo->XG21_LVDSCapList[lvdstableindex].
6925 if (!(modeflag & Charx8Dot)) {
6926 inb(pVBInfo->P3da); /* reset 3da */
6927 outb(0x13, pVBInfo->P3c0); /* set index */
6928 /* set data, panning = 0, shift left 1 dot*/
6929 outb(0x00, pVBInfo->P3c0);
6931 inb(pVBInfo->P3da); /* Enable Attribute */
6932 outb(0x20, pVBInfo->P3c0);
6934 inb(pVBInfo->P3da); /* reset 3da */
6939 /* no shadow case */
6940 static void XGI_SetXG27LVDSPara(unsigned short ModeNo,
6941 unsigned short ModeIdIndex,
6942 struct vb_device_info *pVBInfo)
6944 unsigned char temp, Miscdata;
6945 unsigned short xres, yres, modeflag, resindex, lvdstableindex;
6946 unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE;
6947 unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE;
6948 unsigned short value;
6950 lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo);
6951 temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex].
6953 (LCDPolarity << 8)) >> 8);
6954 temp &= LCDPolarity;
6955 Miscdata = (unsigned char) inb(pVBInfo->P3cc);
6957 outb((Miscdata & 0x3F) | temp, pVBInfo->P3c2);
6959 temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex].
6960 LVDS_Capability & LCDPolarity);
6961 /* SR35[7] FP VSync polarity */
6962 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80);
6963 /* SR30[5] FP HSync polarity */
6964 xgifb_reg_and_or(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1);
6966 XGI_SetXG27FPBits(pVBInfo);
6967 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
6968 if (ModeNo <= 0x13) {
6969 xres = pVBInfo->StResInfo[resindex].HTotal;
6970 yres = pVBInfo->StResInfo[resindex].VTotal;
6972 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
6974 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
6975 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
6976 /* si+St_ModeFlag */
6977 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
6980 if (!(modeflag & Charx8Dot))
6981 xres = xres * 8 / 9;
6983 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
6985 LVDSHBS = xres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE
6987 if ((ModeNo <= 0x13) && (modeflag & HalfDCLK))
6988 LVDSHBS -= xres / 4;
6990 if (LVDSHBS > LVDSHT)
6993 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP;
6994 if (LVDSHRS > LVDSHT)
6997 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC;
6998 if (LVDSHRE > LVDSHT)
7001 LVDSHBE = LVDSHBS + LVDSHT
7002 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE;
7004 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
7006 LVDSVBS = yres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE
7008 if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
7009 LVDSVBS += yres / 2;
7011 if (LVDSVBS > LVDSVT)
7014 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP;
7015 if (LVDSVRS > LVDSVT)
7018 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].
7020 if (LVDSVRE > LVDSVT)
7023 LVDSVBE = LVDSVBS + LVDSVT
7024 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE;
7026 temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
7027 xgifb_reg_set(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */
7029 if (!(modeflag & Charx8Dot))
7030 xgifb_reg_or(pVBInfo->P3c4, 0x1, 0x1);
7032 /* HT SR0B[1:0] CR00 */
7033 value = (LVDSHT >> 3) - 5;
7034 xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8);
7035 xgifb_reg_set(pVBInfo->P3d4, 0x0, (value & 0xFF));
7037 /* HBS SR0B[5:4] CR02 */
7038 value = (LVDSHBS >> 3) - 1;
7039 xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4);
7040 xgifb_reg_set(pVBInfo->P3d4, 0x2, (value & 0xFF));
7042 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
7043 value = (LVDSHBE >> 3) - 1;
7044 xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6);
7045 xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2);
7046 xgifb_reg_and_or(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F);
7048 /* HRS SR0B[7:6] CR04 */
7049 value = (LVDSHRS >> 3) + 2;
7050 xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2);
7051 xgifb_reg_set(pVBInfo->P3d4, 0x4, (value & 0xFF));
7053 /* Panel HRS SR2F[1:0] SR2E[7:0] */
7055 xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8);
7056 xgifb_reg_set(pVBInfo->P3c4, 0x2E, (value & 0xFF));
7058 /* HRE SR0C[2] CR05[4:0] */
7059 value = (LVDSHRE >> 3) + 2;
7060 xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3);
7061 xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F);
7063 /* Panel HRE SR2F[7:2] */
7065 xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2);
7067 /* VT SR0A[0] CR07[5][0] CR06 */
7069 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10);
7070 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4);
7071 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8);
7072 xgifb_reg_set(pVBInfo->P3d4, 0x06, (value & 0xFF));
7074 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
7075 value = LVDSVBS - 1;
7076 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8);
7077 xgifb_reg_and_or(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4);
7078 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5);
7079 xgifb_reg_set(pVBInfo->P3d4, 0x15, (value & 0xFF));
7081 /* VBE SR0A[4] CR16 */
7082 value = LVDSVBE - 1;
7083 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4);
7084 xgifb_reg_set(pVBInfo->P3d4, 0x16, (value & 0xFF));
7086 /* VRS SR0A[3] CR7[7][2] CR10 */
7087 value = LVDSVRS - 1;
7088 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7);
7089 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2);
7090 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6);
7091 xgifb_reg_set(pVBInfo->P3d4, 0x10, (value & 0xFF));
7093 /* Panel VRS SR35[2:0] SR34[7:0] */
7094 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, (value & 0x700) >> 8);
7095 xgifb_reg_set(pVBInfo->P3c4, 0x34, value & 0xFF);
7097 /* VRE SR0A[5] CR11[3:0] */
7098 value = LVDSVRE - 1;
7099 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1);
7100 xgifb_reg_and_or(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F);
7102 /* Panel VRE SR3F[7:2] */
7103 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, (value << 2) & 0xFC);
7105 for (temp = 0, value = 0; temp < 3; temp++) {
7107 xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, value);
7108 xgifb_reg_set(pVBInfo->P3c4,
7110 pVBInfo->XG21_LVDSCapList[lvdstableindex].
7112 xgifb_reg_set(pVBInfo->P3c4,
7114 pVBInfo->XG21_LVDSCapList[lvdstableindex].
7119 if (!(modeflag & Charx8Dot)) {
7120 inb(pVBInfo->P3da); /* reset 3da */
7121 outb(0x13, pVBInfo->P3c0); /* set index */
7122 /* set data, panning = 0, shift left 1 dot*/
7123 outb(0x00, pVBInfo->P3c0);
7125 inb(pVBInfo->P3da); /* Enable Attribute */
7126 outb(0x20, pVBInfo->P3c0);
7128 inb(pVBInfo->P3da); /* reset 3da */
7133 /* --------------------------------------------------------------------- */
7134 /* Function : XGI_IsLCDON */
7136 /* Output : 0 : Skip PSC Control */
7137 /* 1: Disable PSC */
7139 /* --------------------------------------------------------------------- */
7140 static unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo)
7142 unsigned short tempax;
7144 tempax = pVBInfo->VBInfo;
7145 if (tempax & SetCRT2ToDualEdge)
7147 else if (tempax & (DisableCRT2Display | SwitchToCRT2 | SetSimuScanMode))
7153 /* --------------------------------------------------------------------- */
7154 /* Function : XGI_DisableChISLCD */
7156 /* Output : 0 -> Not LCD Mode */
7158 /* --------------------------------------------------------------------- */
7159 static unsigned char XGI_DisableChISLCD(struct vb_device_info *pVBInfo)
7161 unsigned short tempbx, tempah;
7163 tempbx = pVBInfo->SetFlag & (DisableChA | DisableChB);
7164 tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E));
7166 if (tempbx & (EnableChA | DisableChA)) {
7167 if (!(tempah & 0x08)) /* Chk LCDA Mode */
7171 if (!(tempbx & (EnableChB | DisableChB)))
7174 if (tempah & 0x01) /* Chk LCDB Mode */
7180 /* --------------------------------------------------------------------- */
7181 /* Function : XGI_EnableChISLCD */
7183 /* Output : 0 -> Not LCD mode */
7185 /* --------------------------------------------------------------------- */
7186 static unsigned char XGI_EnableChISLCD(struct vb_device_info *pVBInfo)
7188 unsigned short tempbx, tempah;
7190 tempbx = pVBInfo->SetFlag & (EnableChA | EnableChB);
7191 tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E));
7193 if (tempbx & (EnableChA | DisableChA)) {
7194 if (!(tempah & 0x08)) /* Chk LCDA Mode */
7198 if (!(tempbx & (EnableChB | DisableChB)))
7201 if (tempah & 0x01) /* Chk LCDB Mode */
7207 void XGI_DisableBridge(struct xgi_hw_device_info *HwDeviceExtension,
7208 struct vb_device_info *pVBInfo)
7210 unsigned short tempah = 0;
7212 if (pVBInfo->SetFlag == Win9xDOSMode)
7217 if (!(pVBInfo->VBInfo &
7218 (SetCRT2ToLCD | SetCRT2toLCDA)) ||
7219 (XGI_DisableChISLCD(pVBInfo))) {
7220 if (!XGI_IsLCDON(pVBInfo)) {
7222 tempbx = XGINew_GetCH7005(0x61);
7223 // first time we power up
7225 // and disable power sequence
7226 XGINew_SetCH7005(0x0066);
7228 // leave VDD on - disable power
7229 XGINew_SetCH7005(0x5f66);
7236 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7237 | VB_XGI302LV | VB_XGI301C)) {
7239 if (!(pVBInfo->VBInfo &
7240 (DisableCRT2Display | SetSimuScanMode))) {
7241 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
7242 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
7243 tempah = 0x7F; /* Disable Channel A */
7244 if (!(pVBInfo->VBInfo & SetCRT2ToLCDA))
7245 /* Disable Channel B */
7248 if (pVBInfo->SetFlag & DisableChB)
7249 /* force to disable Cahnnel */
7252 if (pVBInfo->SetFlag & DisableChA)
7253 /* Force to disable Channel B */
7259 /* disable part4_1f */
7260 xgifb_reg_and(pVBInfo->Part4Port, 0x1F, tempah);
7262 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
7263 if (((pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)))
7264 || (XGI_DisableChISLCD(pVBInfo))
7265 || (XGI_IsLCDON(pVBInfo)))
7266 /* LVDS Driver power down */
7267 xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x80);
7270 if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo
7271 & (DisableCRT2Display | SetCRT2ToLCDA
7272 | SetSimuScanMode))) {
7273 if (pVBInfo->SetFlag & GatingCRT)
7274 XGI_EnableGatingCRT(HwDeviceExtension, pVBInfo);
7275 XGI_DisplayOff(HwDeviceExtension, pVBInfo);
7278 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
7279 if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo
7282 xgifb_reg_and(pVBInfo->Part1Port, 0x1e, 0xdf);
7285 /* disable TV as primary VGA swap */
7286 xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xdf);
7288 if ((pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToDualEdge)))
7289 xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xdf);
7291 if ((pVBInfo->SetFlag & DisableChB) ||
7293 (DisableCRT2Display | SetSimuScanMode)) ||
7294 ((!(pVBInfo->VBInfo & SetCRT2ToLCDA)) &&
7296 (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV))))
7298 xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80);
7300 if ((pVBInfo->SetFlag & DisableChB) ||
7302 (DisableCRT2Display | SetSimuScanMode)) ||
7303 (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) ||
7305 (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV))) {
7306 /* save Part1 index 0 */
7307 tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00);
7308 /* BTDAC = 1, avoid VB reset */
7309 xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x10);
7311 xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF);
7312 /* restore Part1 index 0 */
7313 xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah);
7315 } else { /* {301} */
7316 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) {
7318 xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80);
7320 xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF);
7321 /* Disable TV asPrimary VGA swap */
7322 xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xDF);
7325 if (pVBInfo->VBInfo & (DisableCRT2Display | SetCRT2ToLCDA
7327 XGI_DisplayOff(HwDeviceExtension, pVBInfo);
7331 /* --------------------------------------------------------------------- */
7332 /* Function : XGI_GetTVPtrIndex */
7335 /* Description : bx 0 : ExtNTSC */
7347 /* --------------------------------------------------------------------- */
7348 static unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo)
7350 unsigned short tempbx = 0;
7352 if (pVBInfo->TVInfo & SetPALTV)
7354 if (pVBInfo->TVInfo & SetYPbPrMode1080i)
7356 if (pVBInfo->TVInfo & SetYPbPrMode525i)
7358 if (pVBInfo->TVInfo & SetYPbPrMode525p)
7360 if (pVBInfo->TVInfo & SetYPbPrMode750p)
7362 if (pVBInfo->TVInfo & TVSimuMode)
7368 /* --------------------------------------------------------------------- */
7369 /* Function : XGI_GetTVPtrIndex2 */
7371 /* Output : bx 0 : NTSC */
7375 /* 4 : NTSC1024x768 */
7376 /* 5 : PAL-M 1024x768 */
7378 /* cl 0 : YFilter1 */
7381 /* 1 : 301B/302B/301LV/302LV */
7383 /* --------------------------------------------------------------------- */
7384 static void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char *tempcl,
7385 unsigned char *tempch, struct vb_device_info *pVBInfo)
7391 if (pVBInfo->TVInfo & SetPALTV)
7394 if (pVBInfo->TVInfo & SetPALMTV)
7397 if (pVBInfo->TVInfo & SetPALNTV)
7400 if (pVBInfo->TVInfo & NTSC1024x768) {
7402 if (pVBInfo->TVInfo & SetPALMTV)
7406 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7407 | VB_XGI302LV | VB_XGI301C)) {
7408 if ((!(pVBInfo->VBInfo & SetInSlaveMode)) || (pVBInfo->TVInfo
7415 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7416 | VB_XGI302LV | VB_XGI301C))
7420 static void XGI_SetDelayComp(struct vb_device_info *pVBInfo)
7422 unsigned short index;
7424 unsigned char tempah, tempbl, tempbh;
7426 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7427 | VB_XGI302LV | VB_XGI301C)) {
7428 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA
7429 | SetCRT2ToTV | SetCRT2ToRAMDAC)) {
7433 index = XGI_GetTVPtrIndex(pVBInfo); /* Get TV Delay */
7434 tempbl = pVBInfo->XGI_TVDelayList[index];
7436 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
7437 | VB_XGI301LV | VB_XGI302LV
7439 tempbl = pVBInfo->XGI_TVDelayList2[index];
7441 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
7442 tempbl = tempbl >> 4;
7444 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC)
7445 tempbl = CRT2Delay1; // Get CRT2 Delay
7446 if (pVBInfo->VBType &
7452 tempbl = CRT2Delay2;
7454 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
7456 index = XGI_GetLCDCapPtr(pVBInfo);
7457 tempbh = pVBInfo->LCDCapList[index].
7458 LCD_DelayCompensation;
7460 if (!(pVBInfo->VBInfo & SetCRT2ToLCDA))
7466 tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x2D);
7468 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD
7469 | SetCRT2ToTV)) { /* Channel B */
7474 if (pVBInfo->VBInfo & SetCRT2ToLCDA) { /* Channel A */
7478 xgifb_reg_set(pVBInfo->Part1Port, 0x2D, tempah);
7480 } else if (pVBInfo->IF_DEF_LVDS == 1) {
7483 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
7484 /* / Get LCD Delay */
7485 tempah = pVBInfo->LCDCapList[
7486 XGI_GetLCDCapPtr(pVBInfo)].
7487 LCD_DelayCompensation;
7489 tempah = tempah << 4;
7490 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2D, 0x0f,
7496 static void XGI_SetLCDCap_A(unsigned short tempcx,
7497 struct vb_device_info *pVBInfo)
7499 unsigned short temp;
7501 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
7503 if (temp & LCDRGB18Bit) {
7504 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F,
7506 (unsigned short) (0x20 | (tempcx & 0x00C0)));
7507 xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80);
7509 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F,
7510 (unsigned short) (0x30 | (tempcx & 0x00C0)));
7511 xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00);
7515 if (tempcx & EnableLCD24bpp) { // 24bits
7516 xgifb_reg_and_or(pVBInfo->Part1Port,
7519 (unsigned short)(0x30 | (tempcx&0x00C0)));
7520 xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00);
7522 xgifb_reg_and_or(pVBInfo->Part1Port,
7526 (unsigned short)(0x20 | (tempcx&0x00C0)));
7527 xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80);
7532 /* --------------------------------------------------------------------- */
7533 /* Function : XGI_SetLCDCap_B */
7534 /* Input : cx -> LCD Capability */
7537 /* --------------------------------------------------------------------- */
7538 static void XGI_SetLCDCap_B(unsigned short tempcx,
7539 struct vb_device_info *pVBInfo)
7541 if (tempcx & EnableLCD24bpp) /* 24bits */
7542 xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0,
7543 (unsigned short) (((tempcx & 0x00ff) >> 6)
7546 xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0,
7547 (unsigned short) (((tempcx & 0x00ff) >> 6)
7548 | 0x18)); /* Enable Dither */
7551 static void SetSpectrum(struct vb_device_info *pVBInfo)
7553 unsigned short index;
7555 index = XGI_GetLCDCapPtr(pVBInfo);
7557 /* disable down spectrum D[4] */
7558 xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x8F);
7559 XGI_LongWait(pVBInfo);
7560 xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x20); /* reset spectrum */
7561 XGI_LongWait(pVBInfo);
7563 xgifb_reg_set(pVBInfo->Part4Port, 0x31,
7564 pVBInfo->LCDCapList[index].Spectrum_31);
7565 xgifb_reg_set(pVBInfo->Part4Port, 0x32,
7566 pVBInfo->LCDCapList[index].Spectrum_32);
7567 xgifb_reg_set(pVBInfo->Part4Port, 0x33,
7568 pVBInfo->LCDCapList[index].Spectrum_33);
7569 xgifb_reg_set(pVBInfo->Part4Port, 0x34,
7570 pVBInfo->LCDCapList[index].Spectrum_34);
7571 XGI_LongWait(pVBInfo);
7572 xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x40); /* enable spectrum */
7575 static void XGI_SetLCDCap(struct vb_device_info *pVBInfo)
7577 unsigned short tempcx;
7579 tempcx = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(pVBInfo)].LCD_Capability;
7581 if (pVBInfo->VBType &
7586 VB_XGI301C)) { /* 301LV/302LV only */
7587 if (pVBInfo->VBType &
7588 (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
7589 /* Set 301LV Capability */
7590 xgifb_reg_set(pVBInfo->Part4Port, 0x24,
7591 (unsigned char) (tempcx & 0x1F));
7594 xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D,
7595 ~((EnableVBCLKDRVLOW | EnablePLLSPLOW) >> 8),
7596 (unsigned short) ((tempcx & (EnableVBCLKDRVLOW
7597 | EnablePLLSPLOW)) >> 8));
7600 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7601 | VB_XGI302LV | VB_XGI301C)) {
7602 if (pVBInfo->VBInfo & SetCRT2ToLCD)
7603 XGI_SetLCDCap_B(tempcx, pVBInfo);
7604 else if (pVBInfo->VBInfo & SetCRT2ToLCDA)
7605 XGI_SetLCDCap_A(tempcx, pVBInfo);
7607 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
7608 if (tempcx & EnableSpectrum)
7609 SetSpectrum(pVBInfo);
7613 XGI_SetLCDCap_A(tempcx, pVBInfo);
7617 /* --------------------------------------------------------------------- */
7618 /* Function : XGI_SetAntiFlicker */
7621 /* Description : Set TV Customized Param. */
7622 /* --------------------------------------------------------------------- */
7623 static void XGI_SetAntiFlicker(unsigned short ModeNo,
7624 unsigned short ModeIdIndex,
7625 struct vb_device_info *pVBInfo)
7627 unsigned short tempbx, index;
7629 unsigned char tempah;
7631 if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))
7634 tempbx = XGI_GetTVPtrIndex(pVBInfo);
7638 index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVFlickerIndex;
7640 index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVFlickerIndex;
7643 tempah = TVAntiFlickList[tempbx];
7644 tempah = tempah << 4;
7646 xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0x8F, tempah);
7649 static void XGI_SetEdgeEnhance(unsigned short ModeNo,
7650 unsigned short ModeIdIndex,
7651 struct vb_device_info *pVBInfo)
7653 unsigned short tempbx, index;
7655 unsigned char tempah;
7657 tempbx = XGI_GetTVPtrIndex(pVBInfo);
7661 index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVEdgeIndex;
7663 index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVEdgeIndex;
7666 tempah = TVEdgeList[tempbx];
7667 tempah = tempah << 5;
7669 xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, tempah);
7672 static void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo)
7674 unsigned short tempbx;
7676 unsigned char tempcl, tempch;
7678 unsigned long tempData;
7680 XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */
7681 tempData = TVPhaseList[tempbx];
7683 xgifb_reg_set(pVBInfo->Part2Port, 0x31, (unsigned short) (tempData
7685 xgifb_reg_set(pVBInfo->Part2Port, 0x32, (unsigned short) ((tempData
7686 & 0x0000FF00) >> 8));
7687 xgifb_reg_set(pVBInfo->Part2Port, 0x33, (unsigned short) ((tempData
7688 & 0x00FF0000) >> 16));
7689 xgifb_reg_set(pVBInfo->Part2Port, 0x34, (unsigned short) ((tempData
7690 & 0xFF000000) >> 24));
7693 static void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex,
7694 struct vb_device_info *pVBInfo)
7696 unsigned short tempbx, index;
7698 unsigned char tempcl, tempch, tempal, *filterPtr;
7700 XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */
7705 filterPtr = NTSCYFilter1;
7709 filterPtr = PALYFilter1;
7715 filterPtr = PALMYFilter1;
7719 filterPtr = PALNYFilter1;
7724 filterPtr = NTSCYFilter2;
7728 filterPtr = PALMYFilter2;
7732 filterPtr = PALNYFilter2;
7736 filterPtr = PALYFilter2;
7744 tempal = pVBInfo->SModeIDTable[ModeIdIndex].
7745 VB_StTVYFilterIndex;
7747 tempal = pVBInfo->EModeIDTable[ModeIdIndex].
7748 VB_ExtTVYFilterIndex;
7755 if ((tempcl == 0) && (tempch == 1)) {
7756 xgifb_reg_set(pVBInfo->Part2Port, 0x35, 0);
7757 xgifb_reg_set(pVBInfo->Part2Port, 0x36, 0);
7758 xgifb_reg_set(pVBInfo->Part2Port, 0x37, 0);
7759 xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]);
7761 xgifb_reg_set(pVBInfo->Part2Port, 0x35, filterPtr[index++]);
7762 xgifb_reg_set(pVBInfo->Part2Port, 0x36, filterPtr[index++]);
7763 xgifb_reg_set(pVBInfo->Part2Port, 0x37, filterPtr[index++]);
7764 xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]);
7767 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7768 | VB_XGI302LV | VB_XGI301C)) {
7769 xgifb_reg_set(pVBInfo->Part2Port, 0x48, filterPtr[index++]);
7770 xgifb_reg_set(pVBInfo->Part2Port, 0x49, filterPtr[index++]);
7771 xgifb_reg_set(pVBInfo->Part2Port, 0x4A, filterPtr[index++]);
7775 /* --------------------------------------------------------------------- */
7776 /* Function : XGI_OEM310Setting */
7779 /* Description : Customized Param. for 301 */
7780 /* --------------------------------------------------------------------- */
7781 static void XGI_OEM310Setting(unsigned short ModeNo,
7782 unsigned short ModeIdIndex,
7783 struct vb_device_info *pVBInfo)
7785 if (pVBInfo->SetFlag & Win9xDOSMode)
7789 XGI_SetDelayComp(pVBInfo);
7791 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))
7792 XGI_SetLCDCap(pVBInfo);
7794 if (pVBInfo->VBInfo & SetCRT2ToTV) {
7796 XGI_SetPhaseIncr(pVBInfo);
7797 XGI_SetYFilter(ModeNo, ModeIdIndex, pVBInfo);
7798 XGI_SetAntiFlicker(ModeNo, ModeIdIndex, pVBInfo);
7800 if (pVBInfo->VBType & VB_XGI301)
7801 XGI_SetEdgeEnhance(ModeNo, ModeIdIndex, pVBInfo);
7805 /* --------------------------------------------------------------------- */
7806 /* Function : XGI_SetCRT2ModeRegs */
7809 /* Description : Origin code for crt2group */
7810 /* --------------------------------------------------------------------- */
7811 void XGI_SetCRT2ModeRegs(unsigned short ModeNo,
7812 struct xgi_hw_device_info *HwDeviceExtension,
7813 struct vb_device_info *pVBInfo)
7815 unsigned short tempbl;
7818 unsigned char tempah;
7820 /* // fix write part1 index 0 BTDRAM bit Bug
7821 * xgifb_reg_set(pVBInfo->Part1Port, 0x03, 0x00); */
7823 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
7824 tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00);
7825 tempah &= ~0x10; /* BTRAMDAC */
7826 tempah |= 0x40; /* BTRAM */
7828 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV
7830 tempah = 0x40; /* BTDRAM */
7831 if (ModeNo > 0x13) {
7832 tempcl = pVBInfo->ModeType;
7836 tempah = (0x008 >> tempcl);
7842 if (pVBInfo->VBInfo & SetInSlaveMode)
7843 tempah ^= 0x50; /* BTDAC */
7848 if (pVBInfo->VBInfo & DisableCRT2Display) {
7852 xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah);
7853 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD)) {
7854 tempcl = pVBInfo->ModeType;
7855 if (ModeNo > 0x13) {
7857 if ((tempcl > 0) || (tempcl == 0)) {
7858 tempah=(0x008>>tempcl) ;
7867 if (pVBInfo->VBInfo & SetInSlaveMode) {
7868 tempah = (tempah ^ 0x050);
7873 xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah);
7877 if (pVBInfo->VBInfo & DisableCRT2Display) {
7878 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl, tempah);
7883 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV
7884 | SetCRT2ToLCD | SetCRT2ToLCDA)) {
7885 if ((pVBInfo->VBInfo & SetCRT2ToLCDA) &&
7886 (!(pVBInfo->VBInfo & SetSimuScanMode))) {
7889 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e,
7892 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
7897 if (pVBInfo->VBInfo &
7904 if (!(pVBInfo->VBInfo & SetInSlaveMode))
7907 if (!(pVBInfo->VBInfo &
7909 tempah = tempah ^ 0x05;
7910 if (!(pVBInfo->VBInfo &
7912 tempah = tempah ^ 0x01;
7915 if (!(pVBInfo->VBInfo &
7918 xgifb_reg_and_or(pVBInfo->Part1Port,
7919 0x2e, tempbl, tempah);
7921 xgifb_reg_and_or(pVBInfo->Part1Port,
7922 0x2e, tempbl, tempah);
7926 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl,
7931 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD
7934 if ((pVBInfo->ModeType == ModeVGA) && (!(pVBInfo->VBInfo
7935 & SetInSlaveMode))) {
7940 if (pVBInfo->VBInfo & SetCRT2ToTV) {
7941 /* if (!(pVBInfo->TVInfo &
7942 (SetYPbPrMode525p | SetYPbPrMode750p))) { */
7944 if (ModeNo > 0x13) {
7945 if (pVBInfo->VBInfo & DriverMode)
7946 tempah = tempah ^ 0x20;
7951 xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D, ~0x0BF, tempah);
7954 if (pVBInfo->LCDInfo & SetLCDDualLink)
7957 if (pVBInfo->VBInfo & SetCRT2ToTV) {
7958 /* if ((!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)) &&
7959 (!(pVBInfo->TVInfo &
7960 (SetYPbPrMode525p | SetYPbPrMode750p)))) { */
7961 if (pVBInfo->TVInfo & RPLLDIV2XO)
7966 if ((pVBInfo->LCDResInfo == Panel1280x1024)
7967 || (pVBInfo->LCDResInfo == Panel1280x1024x75))
7970 if (pVBInfo->LCDResInfo == Panel1280x960)
7973 xgifb_reg_set(pVBInfo->Part4Port, 0x0C, tempah);
7976 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7977 | VB_XGI302LV | VB_XGI301C)) {
7981 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
7983 if (pVBInfo->VBInfo & SetCRT2ToLCDA)
7984 tempah |= 0x04; /* shampoo 0129 */
7987 xgifb_reg_and_or(pVBInfo->Part1Port, 0x13, tempbl, tempah);
7990 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
7991 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
7995 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2c, tempbl, tempah);
7999 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
8000 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
8003 xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, tempbl, tempah);
8008 if (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) {
8010 if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge))
8014 xgifb_reg_and_or(pVBInfo->Part4Port, 0x23, tempbl, tempah);
8016 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
8017 if (pVBInfo->LCDInfo & SetLCDDualLink) {
8018 xgifb_reg_or(pVBInfo->Part4Port, 0x27, 0x20);
8019 xgifb_reg_or(pVBInfo->Part4Port, 0x34, 0x10);
8024 static void XGI_CloseCRTC(struct xgi_hw_device_info *HwDeviceExtension,
8025 struct vb_device_info *pVBInfo)
8027 unsigned short tempbx;
8031 if (pVBInfo->VBInfo & SetCRT2ToLCDA)
8036 void XGI_OpenCRTC(struct xgi_hw_device_info *HwDeviceExtension,
8037 struct vb_device_info *pVBInfo)
8039 unsigned short tempbx;
8043 void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension,
8044 struct vb_device_info *pVBInfo)
8047 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2f, 0xFF, 0x01);
8051 void XGI_LockCRT2(struct xgi_hw_device_info *HwDeviceExtension,
8052 struct vb_device_info *pVBInfo)
8055 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2F, 0xFE, 0x00);
8059 unsigned char XGI_BridgeIsOn(struct vb_device_info *pVBInfo)
8061 unsigned short flag;
8063 if (pVBInfo->IF_DEF_LVDS == 1) {
8066 flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00);
8067 if ((flag == 1) || (flag == 2))
8068 return 1; /* 301b */
8074 void XGI_LongWait(struct vb_device_info *pVBInfo)
8078 i = xgifb_reg_get(pVBInfo->P3c4, 0x1F);
8081 for (i = 0; i < 0xFFFF; i++) {
8082 if (!(inb(pVBInfo->P3da) & 0x08))
8086 for (i = 0; i < 0xFFFF; i++) {
8087 if ((inb(pVBInfo->P3da) & 0x08))
8093 static void XGI_VBLongWait(struct vb_device_info *pVBInfo)
8095 unsigned short tempal, temp, i, j;
8097 if (!(pVBInfo->VBInfo & SetCRT2ToTV)) {
8099 for (i = 0; i < 3; i++) {
8100 for (j = 0; j < 100; j++) {
8101 tempal = inb(pVBInfo->P3da);
8102 if (temp & 0x01) { /* VBWaitMode2 */
8103 if ((tempal & 0x08))
8106 if (!(tempal & 0x08))
8109 } else { /* VBWaitMode1 */
8110 if (!(tempal & 0x08))
8113 if ((tempal & 0x08))
8120 XGI_LongWait(pVBInfo);
8125 unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE,
8126 unsigned short ModeNo, unsigned short ModeIdIndex,
8127 struct vb_device_info *pVBInfo)
8129 short LCDRefreshIndex[] = { 0x00, 0x00, 0x03, 0x01 },
8130 LCDARefreshIndex[] = { 0x00, 0x00, 0x03, 0x01, 0x01,
8133 unsigned short RefreshRateTableIndex, i, modeflag, index, temp;
8136 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
8138 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
8140 if (pVBInfo->IF_DEF_CH7005 == 1) {
8141 if (pVBInfo->VBInfo & SetCRT2ToTV) {
8142 if (modeflag & HalfDCLK)
8150 index = xgifb_reg_get(pVBInfo->P3d4, 0x33);
8151 index = index >> pVBInfo->SelectCRT2Rate;
8154 if (pVBInfo->LCDInfo & LCDNonExpanding)
8160 if (pVBInfo->SetFlag & ProgrammingCRT2) {
8161 if (pVBInfo->IF_DEF_CH7005 == 1) {
8162 if (pVBInfo->VBInfo & SetCRT2ToTV)
8166 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
8167 if (pVBInfo->IF_DEF_LVDS == 0) {
8168 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
8169 | VB_XGI301LV | VB_XGI302LV
8172 temp = LCDARefreshIndex[
8173 pVBInfo->LCDResInfo & 0x0F];
8175 temp = LCDRefreshIndex[
8176 pVBInfo->LCDResInfo & 0x0F];
8186 RefreshRateTableIndex = pVBInfo->EModeIDTable[ModeIdIndex].REFindex;
8187 ModeNo = pVBInfo->RefIndex[RefreshRateTableIndex].ModeID;
8188 if (pXGIHWDE->jChipType >= XG20) { /* for XG20, XG21, XG27 */
8190 if (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag &
8195 if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 800) &&
8196 (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 600)) {
8200 * do the similar adjustment like XGISearchCRT1Rate() */
8201 if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1024) &&
8202 (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 768)) {
8205 if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1280) &&
8206 (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 1024)) {
8213 if (pVBInfo->RefIndex[RefreshRateTableIndex + i].
8216 temp = pVBInfo->RefIndex[RefreshRateTableIndex + i].
8218 temp &= ModeInfoFlag;
8219 if (temp < pVBInfo->ModeType)
8224 } while (index != 0xFFFF);
8225 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) {
8226 if (pVBInfo->VBInfo & SetInSlaveMode) {
8227 temp = pVBInfo->RefIndex[RefreshRateTableIndex + i - 1].
8229 if (temp & InterlaceMode)
8234 if ((pVBInfo->SetFlag & ProgrammingCRT2)) {
8235 temp = XGI_AjustCRT2Rate(ModeNo, ModeIdIndex,
8236 RefreshRateTableIndex, &i, pVBInfo);
8238 return RefreshRateTableIndex + i; /* return (0x01 | (temp1<<1)); */
8241 static void XGI_SetLCDAGroup(unsigned short ModeNo, unsigned short ModeIdIndex,
8242 struct xgi_hw_device_info *HwDeviceExtension,
8243 struct vb_device_info *pVBInfo)
8245 unsigned short RefreshRateTableIndex;
8246 /* unsigned short temp ; */
8248 /* pVBInfo->SelectCRT2Rate = 0; */
8250 pVBInfo->SetFlag |= ProgrammingCRT2;
8251 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
8252 ModeIdIndex, pVBInfo);
8253 XGI_GetLVDSResInfo(ModeNo, ModeIdIndex, pVBInfo);
8254 XGI_GetLVDSData(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
8255 XGI_ModCRT1Regs(ModeNo, ModeIdIndex, RefreshRateTableIndex,
8256 HwDeviceExtension, pVBInfo);
8257 XGI_SetLVDSRegs(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
8258 XGI_SetCRT2ECLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
8261 unsigned char XGI_SetCRT2Group301(unsigned short ModeNo,
8262 struct xgi_hw_device_info *HwDeviceExtension,
8263 struct vb_device_info *pVBInfo)
8265 unsigned short tempbx, ModeIdIndex, RefreshRateTableIndex;
8267 tempbx = pVBInfo->VBInfo;
8268 pVBInfo->SetFlag |= ProgrammingCRT2;
8269 XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo);
8270 pVBInfo->SelectCRT2Rate = 4;
8271 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
8272 ModeIdIndex, pVBInfo);
8273 XGI_SaveCRT2Info(ModeNo, pVBInfo);
8274 XGI_GetCRT2ResInfo(ModeNo, ModeIdIndex, pVBInfo);
8275 XGI_GetCRT2Data(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
8276 XGI_PreSetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension,
8277 RefreshRateTableIndex, pVBInfo);
8278 XGI_SetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension,
8279 RefreshRateTableIndex, pVBInfo);
8280 XGI_SetLockRegs(ModeNo, ModeIdIndex, HwDeviceExtension,
8281 RefreshRateTableIndex, pVBInfo);
8282 XGI_SetGroup2(ModeNo, ModeIdIndex, RefreshRateTableIndex,
8283 HwDeviceExtension, pVBInfo);
8284 XGI_SetLCDRegs(ModeNo, ModeIdIndex, HwDeviceExtension,
8285 RefreshRateTableIndex, pVBInfo);
8286 XGI_SetTap4Regs(pVBInfo);
8287 XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo);
8288 XGI_SetGroup4(ModeNo, ModeIdIndex, RefreshRateTableIndex,
8289 HwDeviceExtension, pVBInfo);
8290 XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
8291 XGI_SetGroup5(ModeNo, ModeIdIndex, pVBInfo);
8292 XGI_AutoThreshold(pVBInfo);
8296 void XGI_SenseCRT1(struct vb_device_info *pVBInfo)
8298 unsigned char CRTCData[17] = { 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81,
8299 0x0B, 0x3E, 0xE9, 0x0B, 0xDF, 0xE7, 0x04, 0x00, 0x00,
8302 unsigned char SR01 = 0, SR1F = 0, SR07 = 0, SR06 = 0;
8304 unsigned char CR17, CR63, SR31;
8305 unsigned short temp;
8306 unsigned char DAC_TEST_PARMS[3] = { 0x0F, 0x0F, 0x0F };
8309 xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86);
8311 /* [2004/05/06] Vicent to fix XG42 single LCD sense to CRT+LCD */
8312 xgifb_reg_set(pVBInfo->P3d4, 0x57, 0x4A);
8313 xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get(
8314 pVBInfo->P3d4, 0x53) | 0x02));
8316 SR31 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x31);
8317 CR63 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x63);
8318 SR01 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x01);
8320 xgifb_reg_set(pVBInfo->P3c4, 0x01, (unsigned char) (SR01 & 0xDF));
8321 xgifb_reg_set(pVBInfo->P3d4, 0x63, (unsigned char) (CR63 & 0xBF));
8323 CR17 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x17);
8324 xgifb_reg_set(pVBInfo->P3d4, 0x17, (unsigned char) (CR17 | 0x80));
8326 SR1F = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x1F);
8327 xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) (SR1F | 0x04));
8329 SR07 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x07);
8330 xgifb_reg_set(pVBInfo->P3c4, 0x07, (unsigned char) (SR07 & 0xFB));
8331 SR06 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x06);
8332 xgifb_reg_set(pVBInfo->P3c4, 0x06, (unsigned char) (SR06 & 0xC3));
8334 xgifb_reg_set(pVBInfo->P3d4, 0x11, 0x00);
8336 for (i = 0; i < 8; i++)
8337 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) i, CRTCData[i]);
8339 for (i = 8; i < 11; i++)
8340 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 8),
8343 for (i = 11; i < 13; i++)
8344 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 4),
8347 for (i = 13; i < 16; i++)
8348 xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i - 3),
8351 xgifb_reg_set(pVBInfo->P3c4, 0x0E, (unsigned char) (CRTCData[16]
8354 xgifb_reg_set(pVBInfo->P3c4, 0x31, 0x00);
8355 xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x1B);
8356 xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE1);
8358 outb(0x00, pVBInfo->P3c8);
8360 for (i = 0; i < 256; i++) {
8361 outb((unsigned char) DAC_TEST_PARMS[0], (pVBInfo->P3c8 + 1));
8362 outb((unsigned char) DAC_TEST_PARMS[1], (pVBInfo->P3c8 + 1));
8363 outb((unsigned char) DAC_TEST_PARMS[2], (pVBInfo->P3c8 + 1));
8366 XGI_VBLongWait(pVBInfo);
8367 XGI_VBLongWait(pVBInfo);
8368 XGI_VBLongWait(pVBInfo);
8372 XGI_WaitDisply(pVBInfo);
8373 temp = inb(pVBInfo->P3c2);
8376 xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x20);
8378 xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x00);
8380 /* alan, avoid display something, set BLACK DAC if not restore DAC */
8381 outb(0x00, pVBInfo->P3c8);
8383 for (i = 0; i < 256; i++) {
8384 outb(0, (pVBInfo->P3c8 + 1));
8385 outb(0, (pVBInfo->P3c8 + 1));
8386 outb(0, (pVBInfo->P3c8 + 1));
8389 xgifb_reg_set(pVBInfo->P3c4, 0x01, SR01);
8390 xgifb_reg_set(pVBInfo->P3d4, 0x63, CR63);
8391 xgifb_reg_set(pVBInfo->P3c4, 0x31, SR31);
8393 /* [2004/05/11] Vicent */
8394 xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get(
8395 pVBInfo->P3d4, 0x53) & 0xFD));
8396 xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) SR1F);
8399 void XGI_EnableBridge(struct xgi_hw_device_info *HwDeviceExtension,
8400 struct vb_device_info *pVBInfo)
8402 unsigned short tempah;
8404 if (pVBInfo->SetFlag == Win9xDOSMode) {
8405 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8406 | VB_XGI302LV | VB_XGI301C)) {
8407 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
8410 /* LVDS or CH7017 */
8414 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8415 | VB_XGI302LV | VB_XGI301C)) {
8416 if (!(pVBInfo->SetFlag & DisableChA)) {
8417 if (pVBInfo->SetFlag & EnableChA) {
8419 xgifb_reg_set(pVBInfo->Part1Port, 0x1E, 0x20);
8421 /* SetCRT2ToLCDA ) */
8422 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
8424 xgifb_reg_set(pVBInfo->Part1Port,
8430 if (!(pVBInfo->SetFlag & DisableChB)) {
8431 if ((pVBInfo->SetFlag & EnableChB) || (pVBInfo->VBInfo
8432 & (SetCRT2ToLCD | SetCRT2ToTV
8433 | SetCRT2ToRAMDAC))) {
8434 tempah = (unsigned char) xgifb_reg_get(
8435 pVBInfo->P3c4, 0x32);
8437 if (pVBInfo->VBInfo & SetInSlaveMode) {
8438 if (!(pVBInfo->VBInfo &
8442 xgifb_reg_set(pVBInfo->P3c4, 0x32, tempah);
8443 xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x20);
8445 tempah = (unsigned char) xgifb_reg_get(
8446 pVBInfo->Part1Port, 0x2E);
8448 if (!(tempah & 0x80))
8449 /* BVBDOENABLE = 1 */
8450 xgifb_reg_or(pVBInfo->Part1Port,
8452 /* BScreenOFF = 0 */
8453 xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F);
8457 if ((pVBInfo->SetFlag & (EnableChA | EnableChB))
8458 || (!(pVBInfo->VBInfo & DisableCRT2Display))) {
8459 xgifb_reg_and_or(pVBInfo->Part2Port, 0x00, ~0xE0,
8460 0x20); /* shampoo 0129 */
8461 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
8462 if (!XGI_DisableChISLCD(pVBInfo)) {
8463 if (XGI_EnableChISLCD(pVBInfo) ||
8465 (SetCRT2ToLCD | SetCRT2ToLCDA)))
8466 /* LVDS PLL power on */
8472 /* LVDS Driver power on */
8473 xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x7F);
8479 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
8482 if (!(pVBInfo->VBInfo & SetSimuScanMode)) {
8483 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
8484 if (pVBInfo->VBInfo &
8485 SetCRT2ToDualEdge) {
8486 tempah = tempah & 0x40;
8487 if (pVBInfo->VBInfo &
8489 tempah = tempah ^ 0xC0;
8491 if (pVBInfo->SetFlag &
8495 if (pVBInfo->SetFlag &
8499 if (pVBInfo->SetFlag &
8503 if (pVBInfo->SetFlag &
8511 /* EnablePart4_1F */
8512 xgifb_reg_or(pVBInfo->Part4Port, 0x1F, tempah);
8514 if (pVBInfo->SetFlag & Win9xDOSMode) {
8515 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
8519 if (!(pVBInfo->SetFlag & DisableChA)) {
8520 XGI_VBLongWait(pVBInfo);
8521 if (!(pVBInfo->SetFlag & GatingCRT)) {
8522 XGI_DisableGatingCRT(HwDeviceExtension,
8524 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
8525 XGI_VBLongWait(pVBInfo);
8530 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD
8533 xgifb_reg_or(pVBInfo->Part1Port, 0x1E, 0x20);
8535 tempah = (unsigned char) xgifb_reg_get(pVBInfo->Part1Port,
8537 if (!(tempah & 0x80))
8538 /* BVBDOENABLE = 1 */
8539 xgifb_reg_or(pVBInfo->Part1Port, 0x2E, 0x80);
8541 xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F);
8542 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
8546 static void XGI_SetCRT1Group(struct xgi_hw_device_info *HwDeviceExtension,
8547 unsigned short ModeNo, unsigned short ModeIdIndex,
8548 struct vb_device_info *pVBInfo)
8550 unsigned short StandTableIndex, RefreshRateTableIndex, b3CC, temp;
8552 unsigned short XGINew_P3cc = pVBInfo->P3cc;
8554 /* XGINew_CRT1Mode = ModeNo; // SaveModeID */
8555 StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
8556 /* XGI_SetBIOSData(ModeNo, ModeIdIndex); */
8557 /* XGI_ClearBankRegs(ModeNo, ModeIdIndex); */
8558 XGI_SetSeqRegs(ModeNo, StandTableIndex, ModeIdIndex, pVBInfo);
8559 XGI_SetMiscRegs(StandTableIndex, pVBInfo);
8560 XGI_SetCRTCRegs(HwDeviceExtension, StandTableIndex, pVBInfo);
8561 XGI_SetATTRegs(ModeNo, StandTableIndex, ModeIdIndex, pVBInfo);
8562 XGI_SetGRCRegs(StandTableIndex, pVBInfo);
8563 XGI_ClearExt1Regs(pVBInfo);
8565 /* if (pVBInfo->IF_DEF_ExpLink) */
8566 if (HwDeviceExtension->jChipType == XG27) {
8567 if (pVBInfo->IF_DEF_LVDS == 0)
8568 XGI_SetDefaultVCLK(pVBInfo);
8571 temp = ~ProgrammingCRT2;
8572 pVBInfo->SetFlag &= temp;
8573 pVBInfo->SelectCRT2Rate = 0;
8575 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8576 | VB_XGI302LV | VB_XGI301C)) {
8577 if (pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToLCDA
8578 | SetInSlaveMode)) {
8579 pVBInfo->SetFlag |= ProgrammingCRT2;
8583 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
8584 ModeIdIndex, pVBInfo);
8585 if (RefreshRateTableIndex != 0xFFFF) {
8586 XGI_SetSync(RefreshRateTableIndex, pVBInfo);
8587 XGI_SetCRT1CRTC(ModeNo, ModeIdIndex, RefreshRateTableIndex,
8588 pVBInfo, HwDeviceExtension);
8589 XGI_SetCRT1DE(HwDeviceExtension, ModeNo, ModeIdIndex,
8590 RefreshRateTableIndex, pVBInfo);
8591 XGI_SetCRT1Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
8592 HwDeviceExtension, pVBInfo);
8593 XGI_SetCRT1VCLK(ModeNo, ModeIdIndex, HwDeviceExtension,
8594 RefreshRateTableIndex, pVBInfo);
8597 if ((HwDeviceExtension->jChipType >= XG20) &&
8598 (HwDeviceExtension->jChipType < XG27)) { /* fix H/W DCLK/2 bug */
8599 if ((ModeNo == 0x00) | (ModeNo == 0x01)) {
8600 xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x4E);
8601 xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE9);
8602 b3CC = (unsigned char) inb(XGINew_P3cc);
8603 outb((b3CC |= 0x0C), XGINew_P3cc);
8604 } else if ((ModeNo == 0x04) | (ModeNo == 0x05) | (ModeNo
8606 xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x1B);
8607 xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE3);
8608 b3CC = (unsigned char) inb(XGINew_P3cc);
8609 outb((b3CC |= 0x0C), XGINew_P3cc);
8613 if (HwDeviceExtension->jChipType >= XG21) {
8614 temp = xgifb_reg_get(pVBInfo->P3d4, 0x38);
8617 /* Enable write GPIOF */
8618 /* xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x20); */
8620 /* xgifb_reg_and(pVBInfo->P3d4, 0x48, ~0x20); */
8621 /* XG21 CRT1 Timing */
8622 if (HwDeviceExtension->jChipType == XG27)
8623 XGI_SetXG27CRTC(ModeNo, ModeIdIndex,
8624 RefreshRateTableIndex, pVBInfo);
8626 XGI_SetXG21CRTC(ModeNo, ModeIdIndex,
8627 RefreshRateTableIndex, pVBInfo);
8629 XGI_UpdateXG21CRTC(ModeNo, pVBInfo,
8630 RefreshRateTableIndex);
8632 if (HwDeviceExtension->jChipType == XG27)
8633 XGI_SetXG27LCD(pVBInfo, RefreshRateTableIndex,
8636 XGI_SetXG21LCD(pVBInfo, RefreshRateTableIndex,
8639 if (pVBInfo->IF_DEF_LVDS == 1) {
8640 if (HwDeviceExtension->jChipType == XG27)
8641 XGI_SetXG27LVDSPara(ModeNo,
8642 ModeIdIndex, pVBInfo);
8644 XGI_SetXG21LVDSPara(ModeNo,
8645 ModeIdIndex, pVBInfo);
8648 /* xgifb_reg_or(pVBInfo->P3d4, 0x48, 0x20); */
8652 pVBInfo->SetFlag &= (~ProgrammingCRT2);
8653 XGI_SetCRT1FIFO(ModeNo, HwDeviceExtension, pVBInfo);
8654 XGI_SetCRT1ModeRegs(HwDeviceExtension, ModeNo, ModeIdIndex,
8655 RefreshRateTableIndex, pVBInfo);
8657 /* XGI_LoadCharacter(); //dif ifdef TVFont */
8659 XGI_LoadDAC(ModeNo, ModeIdIndex, pVBInfo);
8660 /* XGI_ClearBuffer(HwDeviceExtension, ModeNo, pVBInfo); */
8663 unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension,
8664 unsigned short ModeNo)
8666 unsigned short ModeIdIndex;
8667 /* unsigned char *pVBInfo->FBAddr =
8668 HwDeviceExtension->pjVideoMemoryAddress; */
8669 struct vb_device_info VBINF;
8670 struct vb_device_info *pVBInfo = &VBINF;
8671 pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase;
8672 pVBInfo->BaseAddr = (unsigned long) HwDeviceExtension->pjIOAddress;
8673 pVBInfo->IF_DEF_LVDS = 0;
8674 pVBInfo->IF_DEF_CH7005 = 0;
8675 pVBInfo->IF_DEF_LCDA = 1;
8676 pVBInfo->IF_DEF_CH7017 = 0;
8677 pVBInfo->IF_DEF_CH7007 = 0; /* [Billy] 2007/05/14 */
8678 pVBInfo->IF_DEF_VideoCapture = 0;
8679 pVBInfo->IF_DEF_ScaleLCD = 0;
8680 pVBInfo->IF_DEF_OEMUtil = 0;
8681 pVBInfo->IF_DEF_PWD = 0;
8683 if (HwDeviceExtension->jChipType >= XG20) { /* kuku 2004/06/25 */
8684 pVBInfo->IF_DEF_YPbPr = 0;
8685 pVBInfo->IF_DEF_HiVision = 0;
8686 pVBInfo->IF_DEF_CRT2Monitor = 0;
8687 pVBInfo->VBType = 0; /*set VBType default 0*/
8689 pVBInfo->IF_DEF_YPbPr = 1;
8690 pVBInfo->IF_DEF_HiVision = 1;
8691 pVBInfo->IF_DEF_CRT2Monitor = 1;
8694 pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14;
8695 pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24;
8696 pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10;
8697 pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e;
8698 pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12;
8699 pVBInfo->P3cc = pVBInfo->BaseAddr + 0x1C;
8700 pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a;
8701 pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16;
8702 pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17;
8703 pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18;
8704 pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19;
8705 pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A;
8706 pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00;
8707 pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04;
8708 pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10;
8709 pVBInfo->Part3Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_12;
8710 pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14;
8711 pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2;
8713 /* for x86 Linux, XG21 LVDS */
8714 if (HwDeviceExtension->jChipType == XG21) {
8715 if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0)
8716 pVBInfo->IF_DEF_LVDS = 1;
8718 if (HwDeviceExtension->jChipType == XG27) {
8719 if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) {
8720 if (xgifb_reg_get(pVBInfo->P3d4, 0x30) & 0x20)
8721 pVBInfo->IF_DEF_LVDS = 1;
8725 if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 */
8726 XGI_GetVBType(pVBInfo);
8728 InitTo330Pointer(HwDeviceExtension->jChipType, pVBInfo);
8729 if (ModeNo & 0x80) {
8730 ModeNo = ModeNo & 0x7F;
8731 /* XGINew_flag_clearbuffer = 0; */
8734 XGINew_flag_clearbuffer = 1;
8737 xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86);
8739 if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 1.Openkey */
8740 XGI_UnLockCRT2(HwDeviceExtension, pVBInfo);
8742 XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo);
8744 XGI_GetVGAType(HwDeviceExtension, pVBInfo);
8746 if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */
8747 XGI_GetVBInfo(ModeNo, ModeIdIndex, HwDeviceExtension, pVBInfo);
8748 XGI_GetTVInfo(ModeNo, ModeIdIndex, pVBInfo);
8749 XGI_GetLCDInfo(ModeNo, ModeIdIndex, pVBInfo);
8750 XGI_DisableBridge(HwDeviceExtension, pVBInfo);
8751 /* XGI_OpenCRTC(HwDeviceExtension, pVBInfo); */
8753 if (pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToLCDA)) {
8754 XGI_SetCRT1Group(HwDeviceExtension, ModeNo,
8755 ModeIdIndex, pVBInfo);
8757 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
8758 XGI_SetLCDAGroup(ModeNo, ModeIdIndex,
8759 HwDeviceExtension, pVBInfo);
8762 if (!(pVBInfo->VBInfo & SwitchToCRT2)) {
8763 XGI_SetCRT1Group(HwDeviceExtension, ModeNo,
8764 ModeIdIndex, pVBInfo);
8765 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
8766 XGI_SetLCDAGroup(ModeNo, ModeIdIndex,
8773 if (pVBInfo->VBInfo & (SetSimuScanMode | SwitchToCRT2)) {
8774 switch (HwDeviceExtension->ujVBChipID) {
8776 XGI_SetCRT2Group301(ModeNo, HwDeviceExtension,
8777 pVBInfo); /*add for CRT2 */
8781 XGI_SetCRT2Group301(ModeNo, HwDeviceExtension,
8782 pVBInfo); /*add for CRT2 */
8790 XGI_SetCRT2ModeRegs(ModeNo, HwDeviceExtension, pVBInfo);
8791 XGI_OEM310Setting(ModeNo, ModeIdIndex, pVBInfo); /*0212*/
8792 XGI_CloseCRTC(HwDeviceExtension, pVBInfo);
8793 XGI_EnableBridge(HwDeviceExtension, pVBInfo);
8796 if (pVBInfo->IF_DEF_LVDS == 1)
8797 if (!XGI_XG21CheckLVDSMode(ModeNo,
8802 if (ModeNo <= 0x13) {
8803 pVBInfo->ModeType = pVBInfo->SModeIDTable[ModeIdIndex].
8804 St_ModeFlag & ModeInfoFlag;
8806 pVBInfo->ModeType = pVBInfo->EModeIDTable[ModeIdIndex].
8807 Ext_ModeFlag & ModeInfoFlag;
8810 pVBInfo->SetFlag = 0;
8811 if (pVBInfo->IF_DEF_CH7007 != 1)
8812 pVBInfo->VBInfo = DisableCRT2Display;
8814 XGI_DisplayOff(HwDeviceExtension, pVBInfo);
8816 XGI_SetCRT1Group(HwDeviceExtension, ModeNo, ModeIdIndex,
8819 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
8821 if (HwDeviceExtension->jChipType == XG21)
8822 xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0x80, 0x80);
8827 if (ModeNo <= 0x13) {
8828 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
8830 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
8832 pVBInfo->ModeType = modeflag&ModeInfoFlag;
8833 pVBInfo->SetFlag = 0x00;
8834 pVBInfo->VBInfo = DisableCRT2Display;
8835 temp = XGINew_CheckMemorySize(HwDeviceExtension,
8843 XGI_DisplayOff(HwDeviceExtension, pVBInfo) ;
8844 XGI_SetCRT1Group(HwDeviceExtension, ModeNo, ModeIdIndex, pVBInfo);
8845 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
8848 XGI_UpdateModeInfo(HwDeviceExtension, pVBInfo);
8850 if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */
8851 XGI_LockCRT2(HwDeviceExtension, pVBInfo);