3 #include <linux/delay.h>
4 #include <linux/types.h>
10 #include "vb_struct.h"
14 #include "vb_setmode.h"
17 #define IndexMask 0xff
19 static const unsigned short XGINew_VGA_DAC[] = {
20 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
21 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
22 0x00, 0x05, 0x08, 0x0B, 0x0E, 0x11, 0x14, 0x18,
23 0x1C, 0x20, 0x24, 0x28, 0x2D, 0x32, 0x38, 0x3F,
24 0x00, 0x10, 0x1F, 0x2F, 0x3F, 0x1F, 0x27, 0x2F,
25 0x37, 0x3F, 0x2D, 0x31, 0x36, 0x3A, 0x3F, 0x00,
26 0x07, 0x0E, 0x15, 0x1C, 0x0E, 0x11, 0x15, 0x18,
27 0x1C, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x00, 0x04,
28 0x08, 0x0C, 0x10, 0x08, 0x0A, 0x0C, 0x0E, 0x10,
29 0x0B, 0x0C, 0x0D, 0x0F, 0x10};
31 void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo)
33 pVBInfo->StandTable = (struct SiS_StandTable_S *) &XGI330_StandTable;
34 pVBInfo->EModeIDTable = (struct XGI_ExtStruct *) XGI330_EModeIDTable;
35 pVBInfo->RefIndex = (struct XGI_Ext2Struct *) XGI330_RefIndex;
36 pVBInfo->XGINEWUB_CRT1Table
37 = (struct XGI_CRT1TableStruct *) XGI_CRT1Table;
39 pVBInfo->MCLKData = (struct SiS_MCLKData *) XGI340New_MCLKData;
40 pVBInfo->ECLKData = (struct XGI_ECLKDataStruct *) XGI340_ECLKData;
41 pVBInfo->VCLKData = (struct SiS_VCLKData *) XGI_VCLKData;
42 pVBInfo->VBVCLKData = (struct SiS_VBVCLKData *) XGI_VBVCLKData;
43 pVBInfo->ScreenOffset = XGI330_ScreenOffset;
44 pVBInfo->StResInfo = (struct SiS_StResInfo_S *) XGI330_StResInfo;
46 = (struct SiS_ModeResInfo_S *) XGI330_ModeResInfo;
48 pVBInfo->pOutputSelect = &XGI330_OutputSelect;
49 pVBInfo->pSoftSetting = &XGI330_SoftSetting;
50 pVBInfo->pSR07 = &XGI330_SR07;
51 pVBInfo->LCDResInfo = 0;
52 pVBInfo->LCDTypeInfo = 0;
57 pVBInfo->SR15 = XGI340_SR13;
58 pVBInfo->CR40 = XGI340_cr41;
59 pVBInfo->SR25 = XGI330_sr25;
60 pVBInfo->pSR31 = &XGI330_sr31;
61 pVBInfo->pSR32 = &XGI330_sr32;
62 pVBInfo->CR6B = XGI340_CR6B;
63 pVBInfo->CR6E = XGI340_CR6E;
64 pVBInfo->CR6F = XGI340_CR6F;
65 pVBInfo->CR89 = XGI340_CR89;
66 pVBInfo->AGPReg = XGI340_AGPReg;
67 pVBInfo->SR16 = XGI340_SR16;
68 pVBInfo->pCRCF = &XG40_CRCF;
69 pVBInfo->pXGINew_DRAMTypeDefinition = &XG40_DRAMTypeDefinition;
71 pVBInfo->CR49 = XGI330_CR49;
72 pVBInfo->pSR1F = &XGI330_SR1F;
73 pVBInfo->pSR21 = &XGI330_SR21;
74 pVBInfo->pSR22 = &XGI330_SR22;
75 pVBInfo->pSR23 = &XGI330_SR23;
76 pVBInfo->pSR24 = &XGI330_SR24;
77 pVBInfo->pSR33 = &XGI330_SR33;
79 pVBInfo->pCRT2Data_1_2 = &XGI330_CRT2Data_1_2;
80 pVBInfo->pCRT2Data_4_D = &XGI330_CRT2Data_4_D;
81 pVBInfo->pCRT2Data_4_E = &XGI330_CRT2Data_4_E;
82 pVBInfo->pCRT2Data_4_10 = &XGI330_CRT2Data_4_10;
83 pVBInfo->pRGBSenseData = &XGI330_RGBSenseData;
84 pVBInfo->pVideoSenseData = &XGI330_VideoSenseData;
85 pVBInfo->pYCSenseData = &XGI330_YCSenseData;
86 pVBInfo->pRGBSenseData2 = &XGI330_RGBSenseData2;
87 pVBInfo->pVideoSenseData2 = &XGI330_VideoSenseData2;
88 pVBInfo->pYCSenseData2 = &XGI330_YCSenseData2;
90 pVBInfo->NTSCTiming = XGI330_NTSCTiming;
91 pVBInfo->PALTiming = XGI330_PALTiming;
92 pVBInfo->HiTVExtTiming = XGI330_HiTVExtTiming;
93 pVBInfo->HiTVSt1Timing = XGI330_HiTVSt1Timing;
94 pVBInfo->HiTVSt2Timing = XGI330_HiTVSt2Timing;
95 pVBInfo->HiTVTextTiming = XGI330_HiTVTextTiming;
96 pVBInfo->YPbPr750pTiming = XGI330_YPbPr750pTiming;
97 pVBInfo->YPbPr525pTiming = XGI330_YPbPr525pTiming;
98 pVBInfo->YPbPr525iTiming = XGI330_YPbPr525iTiming;
99 pVBInfo->HiTVGroup3Data = XGI330_HiTVGroup3Data;
100 pVBInfo->HiTVGroup3Simu = XGI330_HiTVGroup3Simu;
101 pVBInfo->HiTVGroup3Text = XGI330_HiTVGroup3Text;
102 pVBInfo->Ren525pGroup3 = XGI330_Ren525pGroup3;
103 pVBInfo->Ren750pGroup3 = XGI330_Ren750pGroup3;
105 pVBInfo->TimingH = (struct XGI_TimingHStruct *) XGI_TimingH;
106 pVBInfo->TimingV = (struct XGI_TimingVStruct *) XGI_TimingV;
107 pVBInfo->UpdateCRT1 = (struct XGI_XG21CRT1Struct *) XGI_UpdateCRT1Table;
109 /* 310 customization related */
110 if ((pVBInfo->VBType & VB_SIS301LV) || (pVBInfo->VBType & VB_SIS302LV))
111 pVBInfo->LCDCapList = XGI_LCDDLCapList;
113 pVBInfo->LCDCapList = XGI_LCDCapList;
115 pVBInfo->XGI_TVDelayList = XGI301TVDelayList;
116 pVBInfo->XGI_TVDelayList2 = XGI301TVDelayList2;
118 pVBInfo->pXGINew_I2CDefinition = &XG40_I2CDefinition;
120 if (ChipType >= XG20)
121 pVBInfo->pXGINew_CR97 = &XG20_CR97;
123 if (ChipType == XG27) {
126 = (struct SiS_MCLKData *) XGI27New_MCLKData;
127 pVBInfo->CR40 = XGI27_cr41;
128 pVBInfo->pXGINew_CR97 = &XG27_CR97;
129 pVBInfo->pSR36 = &XG27_SR36;
130 pVBInfo->pCR8F = &XG27_CR8F;
131 pVBInfo->pCRD0 = XG27_CRD0;
132 pVBInfo->pCRDE = XG27_CRDE;
133 pVBInfo->pSR40 = &XG27_SR40;
134 pVBInfo->pSR41 = &XG27_SR41;
135 pVBInfo->SR15 = XG27_SR13;
138 temp = xgifb_reg_get(pVBInfo->P3c4, 0x3B);
139 /* SR3B[7][3]MAA15 MAA11 (Power on Trapping) */
140 if (((temp & 0x88) == 0x80) || ((temp & 0x88) == 0x08))
141 pVBInfo->pXGINew_CR97 = &Z11m_CR97;
144 if (ChipType >= XG20) {
145 pVBInfo->pDVOSetting = &XG21_DVOSetting;
146 pVBInfo->pCR2E = &XG21_CR2E;
147 pVBInfo->pCR2F = &XG21_CR2F;
148 pVBInfo->pCR46 = &XG21_CR46;
149 pVBInfo->pCR47 = &XG21_CR47;
154 static void XGI_SetSeqRegs(unsigned short ModeNo,
155 unsigned short ModeIdIndex,
156 struct vb_device_info *pVBInfo)
158 unsigned char tempah, SRdata;
159 unsigned short i, modeflag;
161 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
163 xgifb_reg_set(pVBInfo->P3c4, 0x00, 0x03); /* Set SR0 */
164 tempah = pVBInfo->StandTable->SR[0];
166 i = XGI_SetCRT2ToLCDA;
167 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
170 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD)) {
171 if (pVBInfo->VBInfo & SetInSlaveMode)
176 tempah |= 0x20; /* screen off */
177 xgifb_reg_set(pVBInfo->P3c4, 0x01, tempah); /* Set SR1 */
179 for (i = 02; i <= 04; i++) {
180 /* Get SR2,3,4 from file */
181 SRdata = pVBInfo->StandTable->SR[i - 1];
182 xgifb_reg_set(pVBInfo->P3c4, i, SRdata); /* Set SR2 3 4 */
186 static void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension,
187 struct vb_device_info *pVBInfo)
189 unsigned char CRTCdata;
192 CRTCdata = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
194 xgifb_reg_set(pVBInfo->P3d4, 0x11, CRTCdata); /* Unlock CRTC */
196 for (i = 0; i <= 0x18; i++) {
197 /* Get CRTC from file */
198 CRTCdata = pVBInfo->StandTable->CRTC[i];
199 xgifb_reg_set(pVBInfo->P3d4, i, CRTCdata); /* Set CRTC(3d4) */
203 static void XGI_SetATTRegs(unsigned short ModeNo,
204 unsigned short ModeIdIndex,
205 struct vb_device_info *pVBInfo)
207 unsigned char ARdata;
208 unsigned short i, modeflag;
210 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
212 for (i = 0; i <= 0x13; i++) {
213 ARdata = pVBInfo->StandTable->ATTR[i];
214 if (modeflag & Charx8Dot) { /* ifndef Dot9 */
216 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
219 if (pVBInfo->VBInfo & (SetCRT2ToTV
221 if (pVBInfo->VBInfo &
229 inb(pVBInfo->P3da); /* reset 3da */
230 outb(i, pVBInfo->P3c0); /* set index */
231 outb(ARdata, pVBInfo->P3c0); /* set data */
234 inb(pVBInfo->P3da); /* reset 3da */
235 outb(0x14, pVBInfo->P3c0); /* set index */
236 outb(0x00, pVBInfo->P3c0); /* set data */
237 inb(pVBInfo->P3da); /* Enable Attribute */
238 outb(0x20, pVBInfo->P3c0);
241 static void XGI_SetGRCRegs(struct vb_device_info *pVBInfo)
243 unsigned char GRdata;
246 for (i = 0; i <= 0x08; i++) {
247 /* Get GR from file */
248 GRdata = pVBInfo->StandTable->GRC[i];
249 xgifb_reg_set(pVBInfo->P3ce, i, GRdata); /* Set GR(3ce) */
252 if (pVBInfo->ModeType > ModeVGA) {
253 GRdata = (unsigned char) xgifb_reg_get(pVBInfo->P3ce, 0x05);
254 GRdata &= 0xBF; /* 256 color disable */
255 xgifb_reg_set(pVBInfo->P3ce, 0x05, GRdata);
259 static void XGI_ClearExt1Regs(struct vb_device_info *pVBInfo)
263 for (i = 0x0A; i <= 0x0E; i++)
264 xgifb_reg_set(pVBInfo->P3c4, i, 0x00); /* Clear SR0A-SR0E */
267 static unsigned char XGI_SetDefaultVCLK(struct vb_device_info *pVBInfo)
270 xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x20);
271 xgifb_reg_set(pVBInfo->P3c4, 0x2B, pVBInfo->VCLKData[0].SR2B);
272 xgifb_reg_set(pVBInfo->P3c4, 0x2C, pVBInfo->VCLKData[0].SR2C);
274 xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x10);
275 xgifb_reg_set(pVBInfo->P3c4, 0x2B, pVBInfo->VCLKData[1].SR2B);
276 xgifb_reg_set(pVBInfo->P3c4, 0x2C, pVBInfo->VCLKData[1].SR2C);
278 xgifb_reg_and(pVBInfo->P3c4, 0x31, ~0x30);
282 static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo,
283 unsigned short ModeIdIndex,
284 unsigned short RefreshRateTableIndex, unsigned short *i,
285 struct vb_device_info *pVBInfo)
287 unsigned short tempax, tempbx, resinfo, modeflag, infoflag;
289 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
290 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
291 tempbx = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID;
294 if (pVBInfo->IF_DEF_LVDS == 0) {
295 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
296 tempax |= SupportRAMDAC2;
298 if (pVBInfo->VBType & VB_XGI301C)
299 tempax |= SupportCRT2in301C;
303 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
304 tempax |= SupportLCD;
306 if (pVBInfo->LCDResInfo != Panel_1280x1024) {
307 if (pVBInfo->LCDResInfo != Panel_1280x960) {
308 if (pVBInfo->LCDInfo &
319 if (pVBInfo->VBInfo & SetCRT2ToHiVision) { /* for HiTV */
320 if ((pVBInfo->VBType & VB_SIS301LV) &&
321 (pVBInfo->VBExtInfo == VB_YPbPr1080i)) {
322 tempax |= SupportYPbPr750p;
323 if (pVBInfo->VBInfo & SetInSlaveMode) {
334 tempax |= SupportHiVision;
335 if (pVBInfo->VBInfo & SetInSlaveMode) {
350 if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO |
353 SetCRT2ToYPbPr525750 |
354 SetCRT2ToHiVision)) {
357 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B
358 | VB_SIS301LV | VB_SIS302LV
360 tempax |= SupportTV1024;
363 if (!(pVBInfo->VBInfo & TVSetPAL)) {
364 if (modeflag & NoSupportSimuTV) {
365 if (pVBInfo->VBInfo &
367 if (!(pVBInfo->VBInfo &
376 } else { /* for LVDS */
377 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
378 tempax |= SupportLCD;
381 return 0; /* 1024x768 */
383 if (pVBInfo->LCDResInfo < Panel_1024x768) {
385 return 0; /* 800x600 */
388 return 0; /* 512x384 */
393 for (; pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID ==
395 infoflag = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].
397 if (infoflag & tempax)
404 for ((*i) = 0;; (*i)++) {
405 infoflag = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].
407 if (pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID
412 if (infoflag & tempax)
418 static void XGI_SetSync(unsigned short RefreshRateTableIndex,
419 struct vb_device_info *pVBInfo)
421 unsigned short sync, temp;
424 sync = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag >> 8;
428 outb(temp, pVBInfo->P3c2); /* Set Misc(3c2) */
431 static void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo,
432 struct xgi_hw_device_info *HwDeviceExtension)
434 unsigned char data, data1, pushax;
438 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
440 xgifb_reg_set(pVBInfo->P3d4, 0x11, data);
442 data = pVBInfo->TimingH[0].data[0];
443 xgifb_reg_set(pVBInfo->P3d4, 0, data);
445 for (i = 0x01; i <= 0x04; i++) {
446 data = pVBInfo->TimingH[0].data[i];
447 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 1), data);
450 for (i = 0x05; i <= 0x06; i++) {
451 data = pVBInfo->TimingH[0].data[i];
452 xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i + 6), data);
455 j = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0e);
457 data = pVBInfo->TimingH[0].data[7];
460 xgifb_reg_set(pVBInfo->P3c4, 0x0e, data);
462 if (HwDeviceExtension->jChipType >= XG20) {
463 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x04);
465 xgifb_reg_set(pVBInfo->P3d4, 0x04, data);
466 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x05);
472 data = (unsigned char) xgifb_reg_get(pVBInfo->P3c4,
475 xgifb_reg_set(pVBInfo->P3c4, 0x0c, data);
480 xgifb_reg_set(pVBInfo->P3d4, 0x05, data);
481 data = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0e);
487 xgifb_reg_and_or(pVBInfo->P3c4, 0x0e, ~0xE0, data);
491 static void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex,
492 unsigned short ModeNo,
493 struct vb_device_info *pVBInfo)
498 for (i = 0x00; i <= 0x01; i++) {
499 data = pVBInfo->TimingV[0].data[i];
500 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 6), data);
503 for (i = 0x02; i <= 0x03; i++) {
504 data = pVBInfo->TimingV[0].data[i];
505 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x0e), data);
508 for (i = 0x04; i <= 0x05; i++) {
509 data = pVBInfo->TimingV[0].data[i];
510 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x11), data);
513 j = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0a);
515 data = pVBInfo->TimingV[0].data[6];
518 xgifb_reg_set(pVBInfo->P3c4, 0x0a, data);
520 data = pVBInfo->TimingV[0].data[6];
524 i = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
529 j = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x09);
532 xgifb_reg_set(pVBInfo->P3d4, 0x09, data);
535 static void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
536 unsigned short RefreshRateTableIndex,
537 struct vb_device_info *pVBInfo,
538 struct xgi_hw_device_info *HwDeviceExtension)
540 unsigned char index, data;
544 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
545 index = index & IndexMask;
547 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
549 xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */
551 for (i = 0; i < 8; i++)
552 pVBInfo->TimingH[0].data[i]
553 = pVBInfo->XGINEWUB_CRT1Table[index].CR[i];
555 for (i = 0; i < 7; i++)
556 pVBInfo->TimingV[0].data[i]
557 = pVBInfo->XGINEWUB_CRT1Table[index].CR[i + 8];
559 XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension);
561 XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo);
563 if (pVBInfo->ModeType > 0x03)
564 xgifb_reg_set(pVBInfo->P3d4, 0x14, 0x4F);
567 /* --------------------------------------------------------------------- */
568 /* Function : XGI_SetXG21CRTC */
569 /* Input : Stand or enhance CRTC table */
570 /* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */
571 /* Description : Set LCD timing */
572 /* --------------------------------------------------------------------- */
573 static void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
574 unsigned short RefreshRateTableIndex,
575 struct vb_device_info *pVBInfo)
577 unsigned char index, Tempax, Tempbx, Tempcx, Tempdx;
578 unsigned short Temp1, Temp2, Temp3;
580 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
581 /* Tempax: CR4 HRS */
582 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3];
583 Tempcx = Tempax; /* Tempcx: HRS */
585 xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax);
587 Tempdx = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SRB */
588 Tempdx &= 0xC0; /* Tempdx[7:6]: SRB[7:6] */
589 Temp1 = Tempdx; /* Temp1[7:6]: HRS[9:8] */
590 Temp1 <<= 2; /* Temp1[9:8]: HRS[9:8] */
591 Temp1 |= Tempax; /* Temp1[9:0]: HRS[9:0] */
593 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */
594 Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */
596 Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[6]; /* SRC */
597 Tempbx &= 0x04; /* Tempbx[2]: HRE[5] */
598 Tempbx <<= 3; /* Tempbx[5]: HRE[5] */
599 Tempax |= Tempbx; /* Tempax[5:0]: HRE[5:0] */
601 Temp2 = Temp1 & 0x3C0; /* Temp2[9:6]: HRS[9:6] */
602 Temp2 |= Tempax; /* Temp2[9:0]: HRE[9:0] */
604 Tempcx &= 0x3F; /* Tempcx[5:0]: HRS[5:0] */
605 if (Tempax < Tempcx) /* HRE < HRS */
606 Temp2 |= 0x40; /* Temp2 + 0x40 */
609 Tempax = (unsigned char) Temp2; /* Tempax: HRE[7:0] */
610 Tempax <<= 2; /* Tempax[7:2]: HRE[5:0] */
611 Tempdx >>= 6; /* Tempdx[7:6]->[1:0] HRS[9:8] */
612 Tempax |= Tempdx; /* HRE[5:0]HRS[9:8] */
613 /* SR2F D[7:2]->HRE, D[1:0]->HRS */
614 xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax);
615 xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00);
618 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10];
619 Tempbx = Tempax; /* Tempbx: VRS */
620 Tempax &= 0x01; /* Tempax[0]: VRS[0] */
621 xgifb_reg_or(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS[0] */
623 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9];
624 Tempcx = Tempbx >> 1; /* Tempcx[6:0]: VRS[7:1] */
625 Tempdx = Tempax & 0x04; /* Tempdx[2]: CR7[2] */
626 Tempdx <<= 5; /* Tempdx[7]: VRS[8] */
627 Tempcx |= Tempdx; /* Tempcx[7:0]: VRS[8:1] */
628 xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempcx); /* SR34[8:1]->VRS */
630 Temp1 = Tempdx; /* Temp1[7]: Tempdx[7] */
631 Temp1 <<= 1; /* Temp1[8]: VRS[8] */
632 Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */
634 Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */
635 Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */
637 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14];
638 Tempax &= 0x08; /* Tempax[3]: VRS[3] */
640 Temp2 <<= 7; /* Temp2[10]: VRS[10] */
641 Temp1 |= Temp2; /* Temp1[10:0]: VRS[10:0] */
643 /* Tempax: CR11 VRE */
644 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11];
645 Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
647 Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14];
648 Tempbx &= 0x20; /* Tempbx[5]: VRE[5] */
649 Tempbx >>= 1; /* Tempbx[4]: VRE[4] */
650 Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */
651 Temp2 = Temp1 & 0x7E0; /* Temp2[10:5]: VRS[10:5] */
652 Temp2 |= Tempax; /* Temp2[10:5]: VRE[10:5] */
654 Temp3 = Temp1 & 0x1F; /* Temp3[4:0]: VRS[4:0] */
655 if (Tempax < Temp3) /* VRE < VRS */
656 Temp2 |= 0x20; /* VRE + 0x20 */
659 Tempax = (unsigned char) Temp2; /* Tempax: VRE[7:0] */
660 Tempax <<= 2; /* Tempax[7:0]; VRE[5:0]00 */
661 Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */
662 Temp1 >>= 9; /* Temp1[1:0]: VRS[10:9] */
663 Tempbx = (unsigned char) Temp1;
664 Tempax |= Tempbx; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */
666 /* SR3F D[7:2]->VRE D[1:0]->VRS */
667 xgifb_reg_set(pVBInfo->P3c4, 0x3F, Tempax);
670 static void XGI_SetXG27CRTC(unsigned short ModeNo,
671 unsigned short ModeIdIndex,
672 unsigned short RefreshRateTableIndex,
673 struct vb_device_info *pVBInfo)
675 unsigned short index, Tempax, Tempbx, Tempcx;
677 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
678 /* Tempax: CR4 HRS */
679 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3];
680 Tempbx = Tempax; /* Tempbx: HRS[7:0] */
682 xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax);
685 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5];
686 Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
687 Tempbx |= (Tempax << 2); /* Tempbx: HRS[9:0] */
689 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */
690 Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */
691 Tempcx = Tempax; /* Tempcx: HRE[4:0] */
693 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[6]; /* SRC */
694 Tempax &= 0x04; /* Tempax[2]: HRE[5] */
695 Tempax <<= 3; /* Tempax[5]: HRE[5] */
696 Tempcx |= Tempax; /* Tempcx[5:0]: HRE[5:0] */
698 Tempbx = Tempbx & 0x3C0; /* Tempbx[9:6]: HRS[9:6] */
699 Tempbx |= Tempcx; /* Tempbx: HRS[9:6]HRE[5:0] */
701 /* Tempax: CR4 HRS */
702 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3];
703 Tempax &= 0x3F; /* Tempax: HRS[5:0] */
704 if (Tempcx <= Tempax) /* HRE[5:0] < HRS[5:0] */
705 Tempbx += 0x40; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/
707 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SR0B */
708 Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
709 Tempax >>= 6; /* Tempax[1:0]: HRS[9:8]*/
710 Tempax |= ((Tempbx << 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */
711 /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */
712 xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax);
713 xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00);
716 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10];
717 /* SR34[7:0]->VRS[7:0] */
718 xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempax);
720 Tempcx = Tempax; /* Tempcx <= VRS[7:0] */
721 /* CR7[7][2] VRS[9][8] */
722 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9];
723 Tempbx = Tempax; /* Tempbx <= CR07[7:0] */
724 Tempax = Tempax & 0x04; /* Tempax[2]: CR7[2]: VRS[8] */
725 Tempax >>= 2; /* Tempax[0]: VRS[8] */
726 /* SR35[0]: VRS[8] */
727 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x01, Tempax);
728 Tempcx |= (Tempax << 8); /* Tempcx <= VRS[8:0] */
729 Tempcx |= ((Tempbx & 0x80) << 2); /* Tempcx <= VRS[9:0] */
731 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14];
732 Tempax &= 0x08; /* SR0A[3] VRS[10] */
733 Tempcx |= (Tempax << 7); /* Tempcx <= VRS[10:0] */
735 /* Tempax: CR11 VRE */
736 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11];
737 Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
739 Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14];
740 Tempbx &= 0x20; /* Tempbx[5]: SR0A[5]: VRE[4] */
741 Tempbx >>= 1; /* Tempbx[4]: VRE[4] */
742 Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */
743 Tempbx = Tempcx; /* Tempbx: VRS[10:0] */
744 Tempbx &= 0x7E0; /* Tempbx[10:5]: VRS[10:5] */
745 Tempbx |= Tempax; /* Tempbx: VRS[10:5]VRE[4:0] */
747 if (Tempbx <= Tempcx) /* VRE <= VRS */
748 Tempbx |= 0x20; /* VRE + 0x20 */
750 /* Tempax: Tempax[7:0]; VRE[5:0]00 */
751 Tempax = (Tempbx << 2) & 0xFF;
752 /* SR3F[7:2]:VRE[5:0] */
753 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax);
754 Tempax = Tempcx >> 8;
755 /* SR35[2:0]:VRS[10:8] */
756 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, Tempax);
759 static void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo)
763 /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */
764 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
765 temp = (temp & 3) << 6;
766 /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */
767 xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0xc0, temp & 0x80);
768 /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */
769 xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80);
773 static void xgifb_set_lcd(int chip_id,
774 struct vb_device_info *pVBInfo,
775 unsigned short RefreshRateTableIndex,
776 unsigned short ModeNo)
778 unsigned short Data, Temp;
779 unsigned short XGI_P3cc;
781 XGI_P3cc = pVBInfo->P3cc;
783 xgifb_reg_set(pVBInfo->P3d4, 0x2E, 0x00);
784 xgifb_reg_set(pVBInfo->P3d4, 0x2F, 0x00);
785 xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x00);
786 xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x00);
788 if (chip_id == XG27) {
789 Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
790 if ((Temp & 0x03) == 0) { /* dual 12 */
791 xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x13);
792 xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x13);
796 if (((*pVBInfo->pDVOSetting) & 0xC0) == 0xC0) {
797 xgifb_reg_set(pVBInfo->P3d4, 0x2E, *pVBInfo->pCR2E);
798 xgifb_reg_set(pVBInfo->P3d4, 0x2F, *pVBInfo->pCR2F);
799 xgifb_reg_set(pVBInfo->P3d4, 0x46, *pVBInfo->pCR46);
800 xgifb_reg_set(pVBInfo->P3d4, 0x47, *pVBInfo->pCR47);
803 if (chip_id == XG27) {
804 XGI_SetXG27FPBits(pVBInfo);
806 Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
809 xgifb_reg_or(pVBInfo->P3c4, 0x06, 0x40);
810 xgifb_reg_or(pVBInfo->P3c4, 0x09, 0x40);
814 xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */
816 xgifb_reg_and(pVBInfo->P3c4, 0x30, ~0x20); /* Hsync polarity */
817 xgifb_reg_and(pVBInfo->P3c4, 0x35, ~0x80); /* Vsync polarity */
819 Data = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
822 xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20);
825 xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80);
828 /* --------------------------------------------------------------------- */
829 /* Function : XGI_UpdateXG21CRTC */
831 /* Output : CRT1 CRTC */
832 /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */
833 /* --------------------------------------------------------------------- */
834 static void XGI_UpdateXG21CRTC(unsigned short ModeNo,
835 struct vb_device_info *pVBInfo,
836 unsigned short RefreshRateTableIndex)
840 xgifb_reg_and(pVBInfo->P3d4, 0x11, 0x7F); /* Unlock CR0~7 */
841 if (ModeNo == 0x2E &&
842 (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC ==
845 else if (ModeNo == 0x2E && (pVBInfo->RefIndex[RefreshRateTableIndex].
846 Ext_CRT1CRTC == RES640x480x72))
848 else if (ModeNo == 0x2F)
850 else if (ModeNo == 0x50)
852 else if (ModeNo == 0x59)
856 xgifb_reg_set(pVBInfo->P3d4, 0x02,
857 pVBInfo->UpdateCRT1[index].CR02);
858 xgifb_reg_set(pVBInfo->P3d4, 0x03,
859 pVBInfo->UpdateCRT1[index].CR03);
860 xgifb_reg_set(pVBInfo->P3d4, 0x15,
861 pVBInfo->UpdateCRT1[index].CR15);
862 xgifb_reg_set(pVBInfo->P3d4, 0x16,
863 pVBInfo->UpdateCRT1[index].CR16);
867 static void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension,
868 unsigned short ModeNo, unsigned short ModeIdIndex,
869 unsigned short RefreshRateTableIndex,
870 struct vb_device_info *pVBInfo)
872 unsigned short resindex, tempax, tempbx, tempcx, temp, modeflag;
876 resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
878 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
879 tempax = pVBInfo->ModeResInfo[resindex].HTotal;
880 tempbx = pVBInfo->ModeResInfo[resindex].VTotal;
882 if (modeflag & HalfDCLK)
883 tempax = tempax >> 1;
885 if (modeflag & HalfDCLK)
886 tempax = tempax << 1;
888 temp = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
890 if (temp & InterlaceMode)
891 tempbx = tempbx >> 1;
893 if (modeflag & DoubleScanMode)
894 tempbx = tempbx << 1;
902 temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
903 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
905 xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */
906 xgifb_reg_set(pVBInfo->P3d4, 0x01, (unsigned short) (tempcx & 0xff));
907 xgifb_reg_and_or(pVBInfo->P3d4, 0x0b, ~0x0c,
908 (unsigned short) ((tempcx & 0x0ff00) >> 10));
909 xgifb_reg_set(pVBInfo->P3d4, 0x12, (unsigned short) (tempbx & 0xff));
911 tempbx = tempbx >> 8;
919 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x42, tempax);
920 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x07);
927 xgifb_reg_and_or(pVBInfo->P3d4, 0x0a, ~0x02, tempax);
928 xgifb_reg_set(pVBInfo->P3d4, 0x11, temp);
931 static void XGI_SetCRT1Offset(unsigned short ModeNo,
932 unsigned short ModeIdIndex,
933 unsigned short RefreshRateTableIndex,
934 struct xgi_hw_device_info *HwDeviceExtension,
935 struct vb_device_info *pVBInfo)
937 unsigned short temp, ah, al, temp2, i, DisplayUnit;
940 temp = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo;
942 temp = pVBInfo->ScreenOffset[temp];
944 temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
945 temp2 &= InterlaceMode;
950 temp2 = pVBInfo->ModeType - ModeEGA;
975 if ((ModeNo >= 0x26) && (ModeNo <= 0x28))
976 temp = temp * temp2 + temp2 / 2;
983 temp = temp >> 8; /* ah */
985 i = xgifb_reg_get(pVBInfo->P3c4, 0x0E);
988 xgifb_reg_set(pVBInfo->P3c4, 0x0E, i);
990 temp = (unsigned char) temp2;
991 temp &= 0xFF; /* al */
992 xgifb_reg_set(pVBInfo->P3d4, 0x13, temp);
995 temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
996 temp2 &= InterlaceMode;
1000 DisplayUnit = DisplayUnit << 5;
1001 ah = (DisplayUnit & 0xff00) >> 8;
1002 al = DisplayUnit & 0x00ff;
1008 if (HwDeviceExtension->jChipType >= XG20)
1009 if ((ModeNo == 0x4A) | (ModeNo == 0x49))
1012 xgifb_reg_set(pVBInfo->P3c4, 0x10, ah);
1015 static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo,
1016 unsigned short ModeIdIndex,
1017 unsigned short RefreshRateTableIndex,
1018 struct xgi_hw_device_info *HwDeviceExtension,
1019 struct vb_device_info *pVBInfo)
1021 unsigned short LCDXlat1VCLK[4] = { VCLK65_315 + 2,
1025 unsigned short LCDXlat2VCLK[4] = { VCLK108_2_315 + 5,
1028 VCLK108_2_315 + 5 };
1029 unsigned short LVDSXlat1VCLK[4] = { VCLK40, VCLK40, VCLK40, VCLK40 };
1030 unsigned short LVDSXlat2VCLK[4] = { VCLK65_315 + 2,
1034 unsigned short LVDSXlat3VCLK[4] = { VCLK65_315 + 2,
1039 unsigned short CRT2Index, VCLKIndex;
1040 unsigned short modeflag, resinfo;
1042 /* si+Ext_ResInfo */
1043 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1044 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
1045 CRT2Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
1047 if (pVBInfo->IF_DEF_LVDS == 0) {
1048 CRT2Index = CRT2Index >> 6; /* for LCD */
1049 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { /*301b*/
1050 if (pVBInfo->LCDResInfo != Panel_1024x768)
1051 VCLKIndex = LCDXlat2VCLK[CRT2Index];
1053 VCLKIndex = LCDXlat1VCLK[CRT2Index];
1054 } else if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
1055 if (pVBInfo->SetFlag & RPLLDIV2XO) {
1056 VCLKIndex = TVCLKBASE_315 + HiTVVCLKDIV2;
1059 VCLKIndex = TVCLKBASE_315 + HiTVVCLK;
1063 if (pVBInfo->SetFlag & TVSimuMode) {
1064 if (modeflag & Charx8Dot) {
1065 VCLKIndex = TVCLKBASE_315 + HiTVSimuVCLK;
1068 VCLKIndex = TVCLKBASE_315 + HiTVTextVCLK;
1074 if ((pVBInfo->VBType & VB_SIS301LV) &&
1075 !(pVBInfo->VBExtInfo == VB_YPbPr1080i)) {
1076 if (pVBInfo->VBExtInfo == YPbPr750p)
1077 VCLKIndex = XGI_YPbPr750pVCLK;
1078 else if (pVBInfo->VBExtInfo == YPbPr525p)
1079 VCLKIndex = YPbPr525pVCLK;
1080 else if (pVBInfo->SetFlag & RPLLDIV2XO)
1081 VCLKIndex = YPbPr525iVCLK_2;
1083 VCLKIndex = YPbPr525iVCLK;
1085 } else if (pVBInfo->VBInfo & SetCRT2ToTV) {
1086 if (pVBInfo->SetFlag & RPLLDIV2XO) {
1087 VCLKIndex = TVCLKBASE_315 + TVVCLKDIV2;
1090 VCLKIndex = TVCLKBASE_315 + TVVCLK;
1093 } else { /* for CRT2 */
1094 /* di+Ext_CRTVCLK */
1095 VCLKIndex = pVBInfo->RefIndex[RefreshRateTableIndex].
1097 VCLKIndex &= IndexMask;
1100 VCLKIndex = CRT2Index;
1101 VCLKIndex = VCLKIndex >> 6;
1102 if ((pVBInfo->LCDResInfo == Panel_800x600) ||
1103 (pVBInfo->LCDResInfo == Panel_320x480))
1104 VCLKIndex = LVDSXlat1VCLK[VCLKIndex];
1105 else if ((pVBInfo->LCDResInfo == Panel_1024x768) ||
1106 (pVBInfo->LCDResInfo == Panel_1024x768x75))
1107 VCLKIndex = LVDSXlat2VCLK[VCLKIndex];
1109 VCLKIndex = LVDSXlat3VCLK[VCLKIndex];
1115 static void XGI_SetCRT1VCLK(unsigned short ModeNo,
1116 unsigned short ModeIdIndex,
1117 struct xgi_hw_device_info *HwDeviceExtension,
1118 unsigned short RefreshRateTableIndex,
1119 struct vb_device_info *pVBInfo)
1121 unsigned char index, data;
1122 unsigned short vclkindex;
1124 if (pVBInfo->IF_DEF_LVDS == 1) {
1125 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1126 data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF;
1127 xgifb_reg_set(pVBInfo->P3c4, 0x31, data);
1128 xgifb_reg_set(pVBInfo->P3c4, 0x2B,
1129 pVBInfo->VCLKData[index].SR2B);
1130 xgifb_reg_set(pVBInfo->P3c4, 0x2C,
1131 pVBInfo->VCLKData[index].SR2C);
1132 xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01);
1133 } else if ((pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
1134 | VB_SIS302LV | VB_XGI301C)) && (pVBInfo->VBInfo
1135 & XGI_SetCRT2ToLCDA)) {
1136 vclkindex = XGI_GetVCLK2Ptr(ModeNo, ModeIdIndex,
1137 RefreshRateTableIndex, HwDeviceExtension,
1139 data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF;
1140 xgifb_reg_set(pVBInfo->P3c4, 0x31, data);
1141 data = pVBInfo->VBVCLKData[vclkindex].Part4_A;
1142 xgifb_reg_set(pVBInfo->P3c4, 0x2B, data);
1143 data = pVBInfo->VBVCLKData[vclkindex].Part4_B;
1144 xgifb_reg_set(pVBInfo->P3c4, 0x2C, data);
1145 xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01);
1147 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1148 data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF;
1149 xgifb_reg_set(pVBInfo->P3c4, 0x31, data);
1150 xgifb_reg_set(pVBInfo->P3c4, 0x2B,
1151 pVBInfo->VCLKData[index].SR2B);
1152 xgifb_reg_set(pVBInfo->P3c4, 0x2C,
1153 pVBInfo->VCLKData[index].SR2C);
1154 xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01);
1157 if (HwDeviceExtension->jChipType >= XG20) {
1158 if (pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag &
1160 data = xgifb_reg_get(pVBInfo->P3c4, 0x2B);
1161 xgifb_reg_set(pVBInfo->P3c4, 0x2B, data);
1162 data = xgifb_reg_get(pVBInfo->P3c4, 0x2C);
1169 xgifb_reg_set(pVBInfo->P3c4, 0x2C, data);
1174 static void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo)
1178 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); /* D[0] 1: 18bit */
1179 temp = (temp & 1) << 6;
1180 /* SR06[6] 18bit Dither */
1181 xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x40, temp);
1182 /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */
1183 xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80);
1187 static void XGI_SetCRT1FIFO(unsigned short ModeNo,
1188 struct xgi_hw_device_info *HwDeviceExtension,
1189 struct vb_device_info *pVBInfo)
1191 unsigned short data;
1193 data = xgifb_reg_get(pVBInfo->P3c4, 0x3D);
1195 xgifb_reg_set(pVBInfo->P3c4, 0x3D, data); /* diable auto-threshold */
1197 xgifb_reg_set(pVBInfo->P3c4, 0x08, 0x34);
1198 data = xgifb_reg_get(pVBInfo->P3c4, 0x09);
1200 xgifb_reg_set(pVBInfo->P3c4, 0x09, data | 0x30);
1201 data = xgifb_reg_get(pVBInfo->P3c4, 0x3D);
1203 xgifb_reg_set(pVBInfo->P3c4, 0x3D, data);
1205 if (HwDeviceExtension->jChipType == XG21)
1206 XGI_SetXG21FPBits(pVBInfo); /* Fix SR9[7:6] can't read back */
1209 static void XGI_SetVCLKState(struct xgi_hw_device_info *HwDeviceExtension,
1210 unsigned short ModeNo, unsigned short RefreshRateTableIndex,
1211 struct vb_device_info *pVBInfo)
1213 unsigned short data, data2 = 0;
1216 unsigned char index;
1218 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1220 VCLK = pVBInfo->VCLKData[index].CLOCK;
1222 data = xgifb_reg_get(pVBInfo->P3c4, 0x32);
1225 data |= 0x0c; /* VCLK > 200 */
1227 if (HwDeviceExtension->jChipType >= XG20)
1228 data &= ~0x04; /* 2 pixel mode */
1230 xgifb_reg_set(pVBInfo->P3c4, 0x32, data);
1232 if (HwDeviceExtension->jChipType < XG20) {
1233 data = xgifb_reg_get(pVBInfo->P3c4, 0x1F);
1237 xgifb_reg_set(pVBInfo->P3c4, 0x1F, data);
1242 xgifb_reg_and_or(pVBInfo->P3c4, 0x07, 0xFC, data2);
1243 if (HwDeviceExtension->jChipType >= XG27)
1244 xgifb_reg_and_or(pVBInfo->P3c4, 0x40, 0xFC, data2 & 0x03);
1248 static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension,
1249 unsigned short ModeNo, unsigned short ModeIdIndex,
1250 unsigned short RefreshRateTableIndex,
1251 struct vb_device_info *pVBInfo)
1253 unsigned short data, data2, data3, infoflag = 0, modeflag, resindex,
1256 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1257 infoflag = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1259 if (xgifb_reg_get(pVBInfo->P3d4, 0x31) & 0x01)
1260 xgifb_reg_and_or(pVBInfo->P3c4, 0x1F, 0x3F, 0x00);
1265 data3 = pVBInfo->ModeType - ModeVGA;
1268 data &= InterlaceMode;
1273 xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x3F, data2);
1274 resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
1275 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
1278 if (infoflag & InterlaceMode) {
1281 else if (xres == 1280)
1285 data2 = data & 0x00FF;
1286 xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFF, data2);
1287 data2 = (data & 0xFF00) >> 8;
1288 xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFC, data2);
1290 if (modeflag & HalfDCLK)
1291 xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xF7, 0x08);
1295 if (modeflag & LineCompareOff)
1298 xgifb_reg_and_or(pVBInfo->P3c4, 0x0F, ~0x48, data2);
1302 xgifb_reg_and_or(pVBInfo->P3c4, 0x21, 0x1F, data);
1304 XGI_SetVCLKState(HwDeviceExtension, ModeNo, RefreshRateTableIndex,
1307 data = xgifb_reg_get(pVBInfo->P3d4, 0x31);
1309 if (HwDeviceExtension->jChipType == XG27) {
1314 xgifb_reg_set(pVBInfo->P3d4, 0x52, data);
1315 xgifb_reg_or(pVBInfo->P3d4, 0x51, 0x10);
1316 } else if (HwDeviceExtension->jChipType >= XG20) {
1321 xgifb_reg_set(pVBInfo->P3d4, 0x52, data);
1322 xgifb_reg_set(pVBInfo->P3d4, 0x51, 0x02);
1328 xgifb_reg_set(pVBInfo->P3d4, 0x52, data);
1333 static void XGI_WriteDAC(unsigned short dl,
1337 struct vb_device_info *pVBInfo)
1339 unsigned short temp, bh, bl;
1358 outb((unsigned short) dh, pVBInfo->P3c9);
1359 outb((unsigned short) bh, pVBInfo->P3c9);
1360 outb((unsigned short) bl, pVBInfo->P3c9);
1363 static void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex,
1364 struct vb_device_info *pVBInfo)
1366 unsigned short data, data2, i, k, m, n, o, si, di, bx, dl, al, ah, dh;
1367 const unsigned short *table = XGINew_VGA_DAC;
1369 outb(0xFF, pVBInfo->P3c6);
1370 outb(0x00, pVBInfo->P3c8);
1372 for (i = 0; i < 16; i++) {
1375 for (k = 0; k < 3; k++) {
1384 outb(data2, pVBInfo->P3c9);
1389 for (i = 16; i < 32; i++) {
1392 for (k = 0; k < 3; k++)
1393 outb(data, pVBInfo->P3c9);
1398 for (m = 0; m < 9; m++) {
1403 for (n = 0; n < 3; n++) {
1404 for (o = 0; o < 5; o++) {
1409 XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
1414 for (o = 0; o < 3; o++) {
1419 XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
1429 static void XGI_GetLVDSResInfo(unsigned short ModeNo,
1430 unsigned short ModeIdIndex,
1431 struct vb_device_info *pVBInfo)
1433 unsigned short resindex, xres, yres, modeflag;
1435 /* si+Ext_ResInfo */
1436 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
1438 /* si+Ext_ResInfo */
1439 resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
1441 xres = pVBInfo->ModeResInfo[resindex].HTotal;
1442 yres = pVBInfo->ModeResInfo[resindex].VTotal;
1444 if (modeflag & HalfDCLK)
1447 if (modeflag & DoubleScanMode)
1453 pVBInfo->VGAHDE = xres;
1454 pVBInfo->HDE = xres;
1455 pVBInfo->VGAVDE = yres;
1456 pVBInfo->VDE = yres;
1459 static void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo,
1460 unsigned short ModeIdIndex,
1461 unsigned short RefreshRateTableIndex,
1462 struct vb_device_info *pVBInfo)
1464 unsigned short i, tempdx, tempcx, tempbx, tempal, modeflag, table;
1466 struct XGI330_LCDDataTablStruct *tempdi = NULL;
1470 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1471 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
1473 tempal = tempal & 0x0f;
1475 if (tempbx <= 1) { /* ExpLink */
1476 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
1478 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
1479 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].
1484 tempal = (tempal >> 4);
1486 tempal = (tempal & 0x0f);
1489 tempcx = LCDLenList[tempbx];
1491 if (pVBInfo->LCDInfo & EnableScalingLCD) { /* ScaleLCD */
1492 if ((tempbx == 5) || (tempbx) == 7)
1493 tempcx = LCDDesDataLen2;
1494 else if ((tempbx == 3) || (tempbx == 8))
1495 tempcx = LVDSDesDataLen2;
1501 tempdi = xgifb_epllcd_crt1;
1504 tempdi = XGI_EPLLCDDataPtr;
1507 tempdi = XGI_EPLLCDDesDataPtr;
1510 tempdi = XGI_LCDDataTable;
1513 tempdi = XGI_LCDDesDataTable;
1516 tempdi = XGI_EPLCHLCDRegPtr;
1527 if (tempdi == NULL) /* OEMUtil */
1533 while (tempdi[i].PANELID != 0xff) {
1534 tempdx = pVBInfo->LCDResInfo;
1535 if (tempbx & 0x0080) { /* OEMUtil */
1536 tempbx &= (~0x0080);
1537 tempdx = pVBInfo->LCDTypeInfo;
1540 if (pVBInfo->LCDInfo & EnableScalingLCD)
1541 tempdx &= (~PanelResInfo);
1543 if (tempdi[i].PANELID == tempdx) {
1544 tempbx = tempdi[i].MASK;
1545 tempdx = pVBInfo->LCDInfo;
1547 if (modeflag & HalfDCLK)
1548 tempdx |= SetLCDLowResolution;
1551 if (tempbx == tempdi[i].CAP)
1558 switch (tempdi[i].DATAPTR) {
1560 return &XGI_LVDSCRT11024x768_1_H[tempal];
1563 return &XGI_LVDSCRT11024x768_2_H[tempal];
1566 return &XGI_LVDSCRT11280x1024_1_H[tempal];
1569 return &XGI_LVDSCRT11280x1024_2_H[tempal];
1572 return &XGI_LVDSCRT11400x1050_1_H[tempal];
1575 return &XGI_LVDSCRT11400x1050_2_H[tempal];
1578 return &XGI_LVDSCRT11600x1200_1_H[tempal];
1581 return &XGI_LVDSCRT11024x768_1_Hx75[tempal];
1584 return &XGI_LVDSCRT11024x768_2_Hx75[tempal];
1587 return &XGI_LVDSCRT11280x1024_1_Hx75[tempal];
1590 return &XGI_LVDSCRT11280x1024_2_Hx75[tempal];
1595 } else if (table == 1) {
1596 switch (tempdi[i].DATAPTR) {
1598 return &XGI_LVDSCRT11024x768_1_V[tempal];
1601 return &XGI_LVDSCRT11024x768_2_V[tempal];
1604 return &XGI_LVDSCRT11280x1024_1_V[tempal];
1607 return &XGI_LVDSCRT11280x1024_2_V[tempal];
1610 return &XGI_LVDSCRT11400x1050_1_V[tempal];
1613 return &XGI_LVDSCRT11400x1050_2_V[tempal];
1616 return &XGI_LVDSCRT11600x1200_1_V[tempal];
1619 return &XGI_LVDSCRT11024x768_1_Vx75[tempal];
1622 return &XGI_LVDSCRT11024x768_2_Vx75[tempal];
1625 return &XGI_LVDSCRT11280x1024_1_Vx75[tempal];
1628 return &XGI_LVDSCRT11280x1024_2_Vx75[tempal];
1633 } else if (table == 2) {
1634 switch (tempdi[i].DATAPTR) {
1636 return &XGI_LVDS1024x768Data_1[tempal];
1639 return &XGI_LVDS1024x768Data_2[tempal];
1642 return &XGI_LVDS1280x1024Data_1[tempal];
1645 return &XGI_LVDS1280x1024Data_2[tempal];
1648 return &XGI_LVDS1400x1050Data_1[tempal];
1651 return &XGI_LVDS1400x1050Data_2[tempal];
1654 return &XGI_LVDS1600x1200Data_1[tempal];
1657 return &XGI_LVDSNoScalingData[tempal];
1660 return &XGI_LVDS1024x768Data_1x75[tempal];
1663 return &XGI_LVDS1024x768Data_2x75[tempal];
1666 return &XGI_LVDS1280x1024Data_1x75[tempal];
1669 return &XGI_LVDS1280x1024Data_2x75[tempal];
1672 return &XGI_LVDSNoScalingDatax75[tempal];
1677 } else if (table == 3) {
1678 switch (tempdi[i].DATAPTR) {
1680 return &XGI_LVDS1024x768Des_1[tempal];
1683 return &XGI_LVDS1024x768Des_3[tempal];
1686 return &XGI_LVDS1024x768Des_2[tempal];
1689 return &XGI_LVDS1280x1024Des_1[tempal];
1692 return &XGI_LVDS1280x1024Des_2[tempal];
1695 return &XGI_LVDS1400x1050Des_1[tempal];
1698 return &XGI_LVDS1400x1050Des_2[tempal];
1701 return &XGI_LVDS1600x1200Des_1[tempal];
1704 return &XGI_LVDSNoScalingDesData[tempal];
1707 return &XGI_LVDS1024x768Des_1x75[tempal];
1710 return &XGI_LVDS1024x768Des_3x75[tempal];
1713 return &XGI_LVDS1024x768Des_2x75[tempal];
1716 return &XGI_LVDS1280x1024Des_1x75[tempal];
1719 return &XGI_LVDS1280x1024Des_2x75[tempal];
1722 return &XGI_LVDSNoScalingDesDatax75[tempal];
1727 } else if (table == 4) {
1728 switch (tempdi[i].DATAPTR) {
1730 return &XGI_ExtLCD1024x768Data[tempal];
1733 return &XGI_StLCD1024x768Data[tempal];
1736 return &XGI_CetLCD1024x768Data[tempal];
1739 return &XGI_ExtLCD1280x1024Data[tempal];
1742 return &XGI_StLCD1280x1024Data[tempal];
1745 return &XGI_CetLCD1280x1024Data[tempal];
1749 return &xgifb_lcd_1400x1050[tempal];
1752 return &XGI_CetLCD1400x1050Data[tempal];
1755 return &XGI_ExtLCD1600x1200Data[tempal];
1758 return &XGI_StLCD1600x1200Data[tempal];
1761 return &XGI_NoScalingData[tempal];
1764 return &XGI_ExtLCD1024x768x75Data[tempal];
1767 return &XGI_ExtLCD1024x768x75Data[tempal];
1770 return &XGI_CetLCD1024x768x75Data[tempal];
1774 return &xgifb_lcd_1280x1024x75[tempal];
1777 return &XGI_CetLCD1280x1024x75Data[tempal];
1780 return &XGI_NoScalingDatax75[tempal];
1785 } else if (table == 5) {
1786 switch (tempdi[i].DATAPTR) {
1788 return &XGI_ExtLCDDes1024x768Data[tempal];
1791 return &XGI_StLCDDes1024x768Data[tempal];
1794 return &XGI_CetLCDDes1024x768Data[tempal];
1797 if ((pVBInfo->VBType & VB_SIS301LV) ||
1798 (pVBInfo->VBType & VB_SIS302LV))
1799 return &XGI_ExtLCDDLDes1280x1024Data[tempal];
1801 return &XGI_ExtLCDDes1280x1024Data[tempal];
1804 if ((pVBInfo->VBType & VB_SIS301LV) ||
1805 (pVBInfo->VBType & VB_SIS302LV))
1806 return &XGI_StLCDDLDes1280x1024Data[tempal];
1808 return &XGI_StLCDDes1280x1024Data[tempal];
1811 if ((pVBInfo->VBType & VB_SIS301LV) ||
1812 (pVBInfo->VBType & VB_SIS302LV))
1813 return &XGI_CetLCDDLDes1280x1024Data[tempal];
1815 return &XGI_CetLCDDes1280x1024Data[tempal];
1819 if ((pVBInfo->VBType & VB_SIS301LV) ||
1820 (pVBInfo->VBType & VB_SIS302LV))
1821 return &xgifb_lcddldes_1400x1050[tempal];
1823 return &xgifb_lcddes_1400x1050[tempal];
1826 return &XGI_CetLCDDes1400x1050Data[tempal];
1829 return &XGI_CetLCDDes1400x1050Data2[tempal];
1832 if ((pVBInfo->VBType & VB_SIS301LV) ||
1833 (pVBInfo->VBType & VB_SIS302LV))
1834 return &XGI_ExtLCDDLDes1600x1200Data[tempal];
1836 return &XGI_ExtLCDDes1600x1200Data[tempal];
1839 if ((pVBInfo->VBType & VB_SIS301LV) ||
1840 (pVBInfo->VBType & VB_SIS302LV))
1841 return &XGI_StLCDDLDes1600x1200Data[tempal];
1843 return &XGI_StLCDDes1600x1200Data[tempal];
1846 return &XGI_NoScalingDesData[tempal];
1850 return &xgifb_lcddes_1024x768x75[tempal];
1853 return &XGI_CetLCDDes1024x768x75Data[tempal];
1857 if ((pVBInfo->VBType & VB_SIS301LV) ||
1858 (pVBInfo->VBType & VB_SIS302LV))
1859 return &xgifb_lcddldes_1280x1024x75[tempal];
1861 return &xgifb_lcddes_1280x1024x75[tempal];
1864 if ((pVBInfo->VBType & VB_SIS301LV) ||
1865 (pVBInfo->VBType & VB_SIS302LV))
1866 return &XGI_CetLCDDLDes1280x1024x75Data[tempal];
1868 return &XGI_CetLCDDes1280x1024x75Data[tempal];
1871 return &XGI_NoScalingDesDatax75[tempal];
1876 } else if (table == 6) {
1877 switch (tempdi[i].DATAPTR) {
1879 return &XGI_CH7017LV1024x768[tempal];
1882 return &XGI_CH7017LV1400x1050[tempal];
1891 static void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo,
1892 unsigned short ModeIdIndex,
1893 unsigned short RefreshRateTableIndex,
1894 struct vb_device_info *pVBInfo)
1896 unsigned short i, tempdx, tempbx, tempal, modeflag, table;
1897 struct XGI330_TVDataTablStruct *tempdi = NULL;
1900 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1901 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
1902 tempal = tempal & 0x3f;
1914 tempdi = xgifb_chrontel_tv;
1920 tempdi = XGI_TVDataTable;
1929 if (tempdi == NULL) /* OEMUtil */
1932 tempdx = pVBInfo->TVInfo;
1934 if (pVBInfo->VBInfo & SetInSlaveMode)
1935 tempdx = tempdx | SetTVLockMode;
1937 if (modeflag & HalfDCLK)
1938 tempdx = tempdx | SetTVLowResolution;
1942 while (tempdi[i].MASK != 0xffff) {
1943 if ((tempdx & tempdi[i].MASK) == tempdi[i].CAP)
1949 if (table == 0x04) {
1950 switch (tempdi[i].DATAPTR) {
1952 return &XGI_ExtPALData[tempal];
1955 return &XGI_ExtNTSCData[tempal];
1958 return &XGI_StPALData[tempal];
1961 return &XGI_StNTSCData[tempal];
1964 return &XGI_ExtHiTVData[tempal];
1967 return &XGI_St2HiTVData[tempal];
1970 return &XGI_ExtYPbPr525iData[tempal];
1973 return &XGI_ExtYPbPr525pData[tempal];
1976 return &XGI_ExtYPbPr750pData[tempal];
1979 return &XGI_StYPbPr525iData[tempal];
1982 return &XGI_StYPbPr525pData[tempal];
1985 return &XGI_StYPbPr750pData[tempal];
1987 case 12: /* avoid system hang */
1988 return &XGI_ExtNTSCData[tempal];
1991 return &XGI_St1HiTVData[tempal];
1996 } else if (table == 0x02) {
1997 switch (tempdi[i].DATAPTR) {
1999 return &XGI_CHTVUNTSCData[tempal];
2002 return &XGI_CHTVONTSCData[tempal];
2005 return &XGI_CHTVUPALData[tempal];
2008 return &XGI_CHTVOPALData[tempal];
2017 static void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex,
2018 unsigned short RefreshRateTableIndex,
2019 struct vb_device_info *pVBInfo)
2021 unsigned short tempbx;
2022 struct XGI330_LVDSDataStruct *LCDPtr = NULL;
2026 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
2027 LCDPtr = (struct XGI330_LVDSDataStruct *) XGI_GetLcdPtr(tempbx,
2028 ModeNo, ModeIdIndex, RefreshRateTableIndex,
2030 pVBInfo->VGAHT = LCDPtr->VGAHT;
2031 pVBInfo->VGAVT = LCDPtr->VGAVT;
2032 pVBInfo->HT = LCDPtr->LCDHT;
2033 pVBInfo->VT = LCDPtr->LCDVT;
2036 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
2037 if (!(pVBInfo->LCDInfo & (SetLCDtoNonExpanding
2038 | EnableScalingLCD))) {
2039 if ((pVBInfo->LCDResInfo == Panel_1024x768) ||
2040 (pVBInfo->LCDResInfo == Panel_1024x768x75)) {
2041 pVBInfo->HDE = 1024;
2043 } else if ((pVBInfo->LCDResInfo == Panel_1280x1024) ||
2044 (pVBInfo->LCDResInfo == Panel_1280x1024x75)) {
2045 pVBInfo->HDE = 1280;
2046 pVBInfo->VDE = 1024;
2047 } else if (pVBInfo->LCDResInfo == Panel_1400x1050) {
2048 pVBInfo->HDE = 1400;
2049 pVBInfo->VDE = 1050;
2051 pVBInfo->HDE = 1600;
2052 pVBInfo->VDE = 1200;
2058 static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex,
2059 unsigned short RefreshRateTableIndex,
2060 struct xgi_hw_device_info *HwDeviceExtension,
2061 struct vb_device_info *pVBInfo)
2063 unsigned char index;
2064 unsigned short tempbx, i;
2065 struct XGI_LVDSCRT1HDataStruct *LCDPtr = NULL;
2066 struct XGI_LVDSCRT1VDataStruct *LCDPtr1 = NULL;
2068 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
2069 index = index & IndexMask;
2073 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
2074 LCDPtr = (struct XGI_LVDSCRT1HDataStruct *)
2075 XGI_GetLcdPtr(tempbx, ModeNo,
2077 RefreshRateTableIndex,
2080 for (i = 0; i < 8; i++)
2081 pVBInfo->TimingH[0].data[i] = LCDPtr[0].Reg[i];
2084 XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension);
2088 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
2089 LCDPtr1 = (struct XGI_LVDSCRT1VDataStruct *)
2094 RefreshRateTableIndex,
2096 for (i = 0; i < 7; i++)
2097 pVBInfo->TimingV[0].data[i] = LCDPtr1[0].Reg[i];
2100 XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo);
2103 static unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo)
2105 unsigned char tempal, tempah, tempbl, i;
2107 tempah = xgifb_reg_get(pVBInfo->P3d4, 0x36);
2108 tempal = tempah & 0x0F;
2109 tempah = tempah & 0xF0;
2111 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
2113 while (tempbl != 0xFF) {
2114 if (tempbl & 0x80) { /* OEMUtil */
2116 tempbl = tempbl & ~(0x80);
2119 if (tempal == tempbl)
2124 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
2130 static unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo)
2132 unsigned short tempah, tempal, tempbl, i;
2134 tempal = pVBInfo->LCDResInfo;
2135 tempah = pVBInfo->LCDTypeInfo;
2138 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
2140 while (tempbl != 0xFF) {
2141 if ((tempbl & 0x80) && (tempbl != 0x80)) {
2146 if (tempal == tempbl)
2150 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
2153 if (tempbl == 0xFF) {
2154 pVBInfo->LCDResInfo = Panel_1024x768;
2155 pVBInfo->LCDTypeInfo = 0;
2162 static void XGI_GetLCDSync(unsigned short *HSyncWidth,
2163 unsigned short *VSyncWidth,
2164 struct vb_device_info *pVBInfo)
2166 unsigned short Index;
2168 Index = XGI_GetLCDCapPtr(pVBInfo);
2169 *HSyncWidth = pVBInfo->LCDCapList[Index].LCD_HSyncWidth;
2170 *VSyncWidth = pVBInfo->LCDCapList[Index].LCD_VSyncWidth;
2175 static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
2176 unsigned short RefreshRateTableIndex,
2177 struct vb_device_info *pVBInfo)
2179 unsigned short tempbx, tempax, tempcx, tempdx, push1, push2, modeflag;
2180 unsigned long temp, temp1, temp2, temp3, push3;
2181 struct XGI_LCDDesStruct *LCDPtr = NULL;
2182 struct XGI330_LCDDataDesStruct2 *LCDPtr1 = NULL;
2184 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2186 if (pVBInfo->LCDInfo & EnableScalingLCD)
2188 (struct XGI330_LCDDataDesStruct2 *)
2193 RefreshRateTableIndex,
2197 (struct XGI_LCDDesStruct *)
2202 RefreshRateTableIndex,
2205 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
2210 if ((pVBInfo->LCDResInfo == Panel_1024x768) ||
2211 (pVBInfo->LCDResInfo == Panel_1024x768x75)) {
2214 } else if ((pVBInfo->LCDResInfo == Panel_1280x1024) ||
2215 (pVBInfo->LCDResInfo == Panel_1280x1024x75)) {
2218 } else if (pVBInfo->LCDResInfo == Panel_1400x1050) {
2226 if (pVBInfo->LCDInfo & SetLCDtoNonExpanding) {
2227 pVBInfo->HDE = tempax;
2228 pVBInfo->VDE = tempbx;
2229 pVBInfo->VGAHDE = tempax;
2230 pVBInfo->VGAVDE = tempbx;
2233 tempax = pVBInfo->HT;
2235 if (pVBInfo->LCDInfo & EnableScalingLCD)
2236 tempbx = LCDPtr1->LCDHDES;
2238 tempbx = LCDPtr->LCDHDES;
2240 tempcx = pVBInfo->HDE;
2241 tempbx = tempbx & 0x0fff;
2244 if (tempcx >= tempax)
2247 xgifb_reg_set(pVBInfo->Part1Port, 0x1A, tempbx & 0x07);
2249 tempcx = tempcx >> 3;
2250 tempbx = tempbx >> 3;
2252 xgifb_reg_set(pVBInfo->Part1Port, 0x16,
2253 (unsigned short) (tempbx & 0xff));
2254 xgifb_reg_set(pVBInfo->Part1Port, 0x17,
2255 (unsigned short) (tempcx & 0xff));
2257 tempax = pVBInfo->HT;
2259 if (pVBInfo->LCDInfo & EnableScalingLCD)
2260 tempbx = LCDPtr1->LCDHRS;
2262 tempbx = LCDPtr->LCDHRS;
2266 if (pVBInfo->LCDInfo & EnableScalingLCD)
2267 tempcx = LCDPtr1->LCDHSync;
2271 if (tempcx >= tempax)
2274 tempax = tempbx & 0x07;
2275 tempax = tempax >> 5;
2276 tempcx = tempcx >> 3;
2277 tempbx = tempbx >> 3;
2282 xgifb_reg_set(pVBInfo->Part1Port, 0x15, tempax);
2283 xgifb_reg_set(pVBInfo->Part1Port, 0x14,
2284 (unsigned short) (tempbx & 0xff));
2286 tempax = pVBInfo->VT;
2287 if (pVBInfo->LCDInfo & EnableScalingLCD)
2288 tempbx = LCDPtr1->LCDVDES;
2290 tempbx = LCDPtr->LCDVDES;
2291 tempcx = pVBInfo->VDE;
2293 tempbx = tempbx & 0x0fff;
2295 if (tempcx >= tempax)
2298 xgifb_reg_set(pVBInfo->Part1Port, 0x1b,
2299 (unsigned short) (tempbx & 0xff));
2300 xgifb_reg_set(pVBInfo->Part1Port, 0x1c,
2301 (unsigned short) (tempcx & 0xff));
2303 tempbx = (tempbx >> 8) & 0x07;
2304 tempcx = (tempcx >> 8) & 0x07;
2306 xgifb_reg_set(pVBInfo->Part1Port, 0x1d,
2307 (unsigned short) ((tempcx << 3)
2310 tempax = pVBInfo->VT;
2311 if (pVBInfo->LCDInfo & EnableScalingLCD)
2312 tempbx = LCDPtr1->LCDVRS;
2314 tempbx = LCDPtr->LCDVRS;
2318 if (pVBInfo->LCDInfo & EnableScalingLCD)
2319 tempcx = LCDPtr1->LCDVSync;
2322 if (tempcx >= tempax)
2325 xgifb_reg_set(pVBInfo->Part1Port, 0x18,
2326 (unsigned short) (tempbx & 0xff));
2327 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, ~0x0f,
2328 (unsigned short) (tempcx & 0x0f));
2330 tempax = ((tempbx >> 8) & 0x07) << 3;
2332 tempbx = pVBInfo->VGAVDE;
2333 if (tempbx != pVBInfo->VDE)
2336 if (pVBInfo->LCDInfo & XGI_EnableLVDSDDA)
2339 xgifb_reg_and_or(pVBInfo->Part1Port, 0x1a, 0x07,
2342 tempcx = pVBInfo->VGAVT;
2343 tempbx = pVBInfo->VDE;
2344 tempax = pVBInfo->VGAVDE;
2347 temp = tempax; /* 0430 ylshieh */
2348 temp1 = (temp << 18) / tempbx;
2350 tempdx = (unsigned short) ((temp << 18) % tempbx);
2358 xgifb_reg_set(pVBInfo->Part1Port, 0x37,
2359 (unsigned short) (temp2 & 0xff));
2360 xgifb_reg_set(pVBInfo->Part1Port, 0x36,
2361 (unsigned short) ((temp2 >> 8) & 0xff));
2363 tempbx = (unsigned short) (temp2 >> 16);
2364 tempax = tempbx & 0x03;
2366 tempbx = pVBInfo->VGAVDE;
2367 if (tempbx == pVBInfo->VDE)
2370 xgifb_reg_set(pVBInfo->Part1Port, 0x35, tempax);
2372 if (pVBInfo->VBType & VB_XGI301C) {
2374 xgifb_reg_set(pVBInfo->Part4Port,
2376 (unsigned short) (temp2 & 0xff));
2377 xgifb_reg_set(pVBInfo->Part4Port,
2379 (unsigned short) ((temp2 >> 8) &
2381 tempbx = (unsigned short) (temp2 >> 16);
2382 xgifb_reg_and_or(pVBInfo->Part4Port, 0x3a,
2384 (unsigned short) ((tempbx &
2387 tempcx = pVBInfo->VGAVDE;
2388 if (tempcx == pVBInfo->VDE)
2389 xgifb_reg_and_or(pVBInfo->Part4Port,
2392 xgifb_reg_and_or(pVBInfo->Part4Port,
2396 tempcx = pVBInfo->VGAHDE;
2397 tempbx = pVBInfo->HDE;
2399 temp1 = tempcx << 16;
2401 tempax = (unsigned short) (temp1 / tempbx);
2403 if ((tempbx & 0xffff) == (tempcx & 0xffff))
2407 temp1 = pVBInfo->VGAHDE << 16;
2410 temp3 = temp3 << 16;
2413 temp3 = (temp3 & 0xffff0000) + (temp1 & 0xffff);
2415 tempax = (unsigned short) (temp3 & 0xff);
2416 xgifb_reg_set(pVBInfo->Part1Port, 0x1f, tempax);
2418 temp1 = pVBInfo->VGAVDE << 18;
2419 temp1 = temp1 / push3;
2420 tempbx = (unsigned short) (temp1 & 0xffff);
2422 if (pVBInfo->LCDResInfo == Panel_1024x768)
2425 tempax = ((tempbx >> 8) & 0xff) << 3;
2426 tempax |= (unsigned short) ((temp3 >> 8) & 0x07);
2427 xgifb_reg_set(pVBInfo->Part1Port, 0x20,
2428 (unsigned short) (tempax & 0xff));
2429 xgifb_reg_set(pVBInfo->Part1Port, 0x21,
2430 (unsigned short) (tempbx & 0xff));
2432 temp3 = temp3 >> 16;
2434 if (modeflag & HalfDCLK)
2437 xgifb_reg_set(pVBInfo->Part1Port, 0x22,
2438 (unsigned short) ((temp3 >> 8) & 0xff));
2439 xgifb_reg_set(pVBInfo->Part1Port, 0x23,
2440 (unsigned short) (temp3 & 0xff));
2443 /* --------------------------------------------------------------------- */
2444 /* Function : XGI_GETLCDVCLKPtr */
2446 /* Output : al -> VCLK Index */
2448 /* --------------------------------------------------------------------- */
2449 static void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1,
2450 struct vb_device_info *pVBInfo)
2452 unsigned short index;
2454 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
2455 index = XGI_GetLCDCapPtr1(pVBInfo);
2457 if (pVBInfo->VBInfo & SetCRT2ToLCD) { /* LCDB */
2458 *di_0 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData1;
2459 *di_1 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData2;
2461 *di_0 = pVBInfo->LCDCapList[index].LCDA_VCLKData1;
2462 *di_1 = pVBInfo->LCDCapList[index].LCDA_VCLKData2;
2468 static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex,
2469 unsigned short ModeNo, unsigned short ModeIdIndex,
2470 struct vb_device_info *pVBInfo)
2473 unsigned short index, modeflag;
2474 unsigned char tempal;
2476 /* si+Ext_ResInfo */
2477 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2479 if ((pVBInfo->SetFlag & ProgrammingCRT2) &&
2480 (!(pVBInfo->LCDInfo & EnableScalingLCD))) { /* {LCDA/LCDB} */
2481 index = XGI_GetLCDCapPtr(pVBInfo);
2482 tempal = pVBInfo->LCDCapList[index].LCD_VCLK;
2484 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))
2488 if (pVBInfo->VBType &
2494 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
2495 tempal = TVCLKBASE_315 + HiTVVCLKDIV2;
2496 if (!(pVBInfo->TVInfo & RPLLDIV2XO))
2497 tempal = TVCLKBASE_315 + HiTVVCLK;
2498 if (pVBInfo->TVInfo & TVSimuMode) {
2499 tempal = TVCLKBASE_315 + HiTVSimuVCLK;
2500 if (!(modeflag & Charx8Dot))
2501 tempal = TVCLKBASE_315 + HiTVTextVCLK;
2507 if (pVBInfo->TVInfo & TVSetYPbPr750p) {
2508 tempal = XGI_YPbPr750pVCLK;
2512 if (pVBInfo->TVInfo & TVSetYPbPr525p) {
2513 tempal = YPbPr525pVCLK;
2517 tempal = NTSC1024VCLK;
2519 if (!(pVBInfo->TVInfo & NTSC1024x768)) {
2520 tempal = TVCLKBASE_315 + TVVCLKDIV2;
2521 if (!(pVBInfo->TVInfo & RPLLDIV2XO))
2522 tempal = TVCLKBASE_315 + TVVCLK;
2525 if (pVBInfo->VBInfo & SetCRT2ToTV)
2530 tempal = (unsigned char) inb((pVBInfo->P3ca + 0x02));
2531 tempal = tempal >> 2;
2534 /* for Dot8 Scaling LCD */
2535 if ((pVBInfo->LCDInfo & EnableScalingLCD) && (modeflag & Charx8Dot))
2536 tempal = tempal ^ tempal; /* ; set to VCLK25MHz always */
2538 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
2542 static void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0,
2543 unsigned char *di_1, struct vb_device_info *pVBInfo)
2545 if (pVBInfo->VBType & (VB_SIS301 | VB_SIS301B | VB_SIS302B
2546 | VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) {
2547 if ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) && (pVBInfo->SetFlag
2548 & ProgrammingCRT2)) {
2549 *di_0 = (unsigned char) XGI_VBVCLKData[tempal].SR2B;
2550 *di_1 = XGI_VBVCLKData[tempal].SR2C;
2553 *di_0 = XGI_VCLKData[tempal].SR2B;
2554 *di_1 = XGI_VCLKData[tempal].SR2C;
2558 static void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex,
2559 unsigned short RefreshRateTableIndex,
2560 struct vb_device_info *pVBInfo)
2562 unsigned char di_0, di_1, tempal;
2565 tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex,
2567 XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo);
2568 XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo);
2570 for (i = 0; i < 4; i++) {
2571 xgifb_reg_and_or(pVBInfo->P3d4, 0x31, ~0x30,
2572 (unsigned short) (0x10 * i));
2573 if ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA))
2574 && (!(pVBInfo->VBInfo & SetInSlaveMode))) {
2575 xgifb_reg_set(pVBInfo->P3c4, 0x2e, di_0);
2576 xgifb_reg_set(pVBInfo->P3c4, 0x2f, di_1);
2578 xgifb_reg_set(pVBInfo->P3c4, 0x2b, di_0);
2579 xgifb_reg_set(pVBInfo->P3c4, 0x2c, di_1);
2584 static void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension,
2585 struct vb_device_info *pVBInfo)
2587 unsigned short tempcl, tempch, temp, tempbl, tempax;
2589 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
2590 | VB_SIS302LV | VB_XGI301C)) {
2593 temp = xgifb_reg_get(pVBInfo->P3c4, 0x01);
2595 if (!(temp & 0x20)) {
2596 temp = xgifb_reg_get(pVBInfo->P3d4, 0x17);
2598 temp = xgifb_reg_get(pVBInfo->P3d4, 0x53);
2600 tempcl |= ActiveCRT1;
2604 temp = xgifb_reg_get(pVBInfo->Part1Port, 0x2e);
2607 if (!(temp == 0x08)) {
2608 /* Check ChannelA by Part1_13 [2003/10/03] */
2609 tempax = xgifb_reg_get(pVBInfo->Part1Port, 0x13);
2611 tempcl = tempcl | ActiveLCD;
2615 if (!(tempcl & ActiveLCD))
2617 tempcl |= ActiveCRT2;
2620 tempcl |= ActiveLCD;
2623 temp = xgifb_reg_get(pVBInfo->Part2Port, 0x00);
2626 tempch |= ActiveAVideo;
2629 tempch |= ActiveSVideo;
2632 tempch |= ActiveSCART;
2634 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
2636 tempch |= ActiveHiTV;
2639 if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
2640 temp = xgifb_reg_get(
2645 tempch |= ActiveYPbPr;
2653 temp = xgifb_reg_get(pVBInfo->P3d4, 0x3d);
2654 if (tempcl & ActiveLCD) {
2655 if ((pVBInfo->SetFlag & ReserveTVOption)) {
2656 if (temp & ActiveTV)
2661 tempbl = ~XGI_ModeSwitchStatus;
2662 xgifb_reg_and_or(pVBInfo->P3d4, 0x3d, tempbl, temp);
2664 if (!(pVBInfo->SetFlag & ReserveTVOption))
2665 xgifb_reg_set(pVBInfo->P3d4, 0x3e, tempch);
2671 void XGI_GetVBType(struct vb_device_info *pVBInfo)
2673 unsigned short flag, tempbx, tempah;
2675 if (pVBInfo->IF_DEF_LVDS == 0) {
2676 tempbx = VB_SIS302B;
2677 flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00);
2680 flag = xgifb_reg_get(pVBInfo->Part4Port, 0x01);
2682 tempbx = VB_SIS301B;
2684 tempbx = VB_XGI301C;
2686 tempbx = VB_SIS301LV;
2688 tempbx = VB_SIS302LV;
2689 tempah = xgifb_reg_get(
2699 if (tempbx & (VB_SIS301B | VB_SIS302B)) {
2700 flag = xgifb_reg_get(
2705 tempbx = tempbx | VB_NoLCD;
2709 pVBInfo->VBType = tempbx;
2713 static void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
2714 struct xgi_hw_device_info *HwDeviceExtension,
2715 struct vb_device_info *pVBInfo)
2717 unsigned short tempax, push, tempbx, temp, modeflag;
2719 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2720 pVBInfo->SetFlag = 0;
2721 pVBInfo->ModeType = modeflag & ModeTypeMask;
2724 if (pVBInfo->VBType & 0xFFFF) {
2725 /* Check Display Device */
2726 temp = xgifb_reg_get(pVBInfo->P3d4, 0x30);
2727 tempbx = tempbx | temp;
2728 temp = xgifb_reg_get(pVBInfo->P3d4, 0x31);
2732 tempbx = tempbx | tempax;
2733 temp = (SetCRT2ToDualEdge | SetCRT2ToYPbPr525750 | XGI_SetCRT2ToLCDA
2734 | SetInSlaveMode | DisableCRT2Display);
2735 temp = 0xFFFF ^ temp;
2738 temp = xgifb_reg_get(pVBInfo->P3d4, 0x38);
2740 if (pVBInfo->IF_DEF_LCDA == 1) {
2742 if ((HwDeviceExtension->jChipType >= XG20) ||
2743 (HwDeviceExtension->jChipType >= XG40)) {
2744 if (pVBInfo->IF_DEF_LVDS == 0) {
2745 if (pVBInfo->VBType &
2750 if (temp & EnableDualEdge) {
2754 if (temp & SetToLCDA)
2763 if (pVBInfo->IF_DEF_YPbPr == 1) {
2764 /* [Billy] 07/05/04 */
2765 if (((pVBInfo->IF_DEF_LVDS == 0) &&
2766 ((pVBInfo->VBType & VB_SIS301LV) ||
2767 (pVBInfo->VBType & VB_SIS302LV) ||
2768 (pVBInfo->VBType & VB_XGI301C)))) {
2769 if (temp & SetYPbPr) {
2770 if (pVBInfo->IF_DEF_HiVision == 1) {
2771 /* shampoo add for new
2773 temp = xgifb_reg_get(
2777 tempbx |= SetCRT2ToHiVision;
2779 if (temp != YPbPrMode1080i) {
2781 (~SetCRT2ToHiVision);
2783 SetCRT2ToYPbPr525750;
2790 tempax = push; /* restore CR31 */
2792 if (pVBInfo->IF_DEF_LVDS == 0) {
2793 if (pVBInfo->IF_DEF_YPbPr == 1) {
2794 if (pVBInfo->IF_DEF_HiVision == 1)
2799 if (pVBInfo->IF_DEF_HiVision == 1)
2804 } else { /* 3nd party chip */
2805 temp = SetCRT2ToLCD;
2808 if (!(tempbx & temp)) {
2809 tempax |= DisableCRT2Display;
2813 if (pVBInfo->IF_DEF_LCDA == 1) { /* Select Display Device */
2814 if (!(pVBInfo->VBType & VB_NoLCD)) {
2815 if (tempbx & XGI_SetCRT2ToLCDA) {
2816 if (tempbx & SetSimuScanMode)
2817 tempbx &= (~(SetCRT2ToLCD |
2821 tempbx &= (~(SetCRT2ToLCD |
2830 /* for driver abnormal */
2831 if (!(tempbx & (SwitchCRT2 | SetSimuScanMode))) {
2832 if (pVBInfo->IF_DEF_CRT2Monitor == 1) {
2833 if (tempbx & SetCRT2ToRAMDAC) {
2838 tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750));
2841 tempbx &= (~(SetCRT2ToRAMDAC |
2847 if (!(pVBInfo->VBType & VB_NoLCD)) {
2848 if (tempbx & SetCRT2ToLCD) {
2853 tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750));
2857 if (tempbx & SetCRT2ToSCART) {
2862 tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750));
2865 if (pVBInfo->IF_DEF_YPbPr == 1) {
2866 if (tempbx & SetCRT2ToYPbPr525750)
2872 if (pVBInfo->IF_DEF_HiVision == 1) {
2873 if (tempbx & SetCRT2ToHiVision)
2880 if (tempax & DisableCRT2Display) { /* Set Display Device Info */
2881 if (!(tempbx & (SwitchCRT2 | SetSimuScanMode)))
2882 tempbx = DisableCRT2Display;
2885 if (!(tempbx & DisableCRT2Display)) {
2886 if ((!(tempbx & DriverMode)) ||
2887 (!(modeflag & CRT2Mode))) {
2888 if (pVBInfo->IF_DEF_LCDA == 1) {
2889 if (!(tempbx & XGI_SetCRT2ToLCDA))
2890 tempbx |= (SetInSlaveMode |
2895 /* LCD+TV can't support in slave mode
2896 * (Force LCDA+TV->LCDB) */
2897 if ((tempbx & SetInSlaveMode) &&
2898 (tempbx & XGI_SetCRT2ToLCDA)) {
2899 tempbx ^= (SetCRT2ToLCD |
2902 pVBInfo->SetFlag |= ReserveTVOption;
2907 pVBInfo->VBInfo = tempbx;
2910 static void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
2911 struct vb_device_info *pVBInfo)
2913 unsigned short temp, tempbx = 0, resinfo = 0, modeflag, index1;
2918 if (pVBInfo->VBInfo & SetCRT2ToTV) {
2919 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2920 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
2922 if (pVBInfo->VBInfo & SetCRT2ToTV) {
2923 temp = xgifb_reg_get(pVBInfo->P3d4, 0x35);
2925 if (tempbx & TVSetPAL) {
2926 tempbx &= (SetCHTVOverScan |
2930 if (tempbx & TVSetPALM)
2931 /* set to NTSC if PAL-M */
2932 tempbx &= ~TVSetPAL;
2934 tempbx &= (SetCHTVOverScan |
2939 if (pVBInfo->IF_DEF_LVDS == 0) {
2940 if (pVBInfo->VBInfo & SetCRT2ToSCART)
2944 if (pVBInfo->IF_DEF_YPbPr == 1) {
2945 if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
2946 index1 = xgifb_reg_get(pVBInfo->P3d4, 0x35);
2947 index1 &= YPbPrMode;
2949 if (index1 == YPbPrMode525i)
2950 tempbx |= TVSetYPbPr525i;
2952 if (index1 == YPbPrMode525p)
2953 tempbx = tempbx | TVSetYPbPr525p;
2954 if (index1 == YPbPrMode750p)
2955 tempbx = tempbx | TVSetYPbPr750p;
2959 if (pVBInfo->IF_DEF_HiVision == 1) {
2960 if (pVBInfo->VBInfo & SetCRT2ToHiVision)
2961 tempbx = tempbx | TVSetHiVision | TVSetPAL;
2964 if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */
2965 if ((pVBInfo->VBInfo & SetInSlaveMode) &&
2966 (!(pVBInfo->VBInfo & SetNotSimuMode)))
2967 tempbx |= TVSimuMode;
2969 if (!(tempbx & TVSetPAL) &&
2971 (resinfo == 8)) /* NTSC 1024x768, */
2972 tempbx |= NTSC1024x768;
2974 tempbx |= RPLLDIV2XO;
2976 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
2977 if (pVBInfo->VBInfo & SetInSlaveMode)
2978 tempbx &= (~RPLLDIV2XO);
2981 (TVSetYPbPr525p | TVSetYPbPr750p))
2982 tempbx &= (~RPLLDIV2XO);
2983 else if (!(pVBInfo->VBType &
2989 if (tempbx & TVSimuMode)
2990 tempbx &= (~RPLLDIV2XO);
2995 pVBInfo->TVInfo = tempbx;
2998 static unsigned char XGI_GetLCDInfo(unsigned short ModeNo,
2999 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
3001 unsigned short temp, tempax, tempbx, modeflag, resinfo = 0, LCDIdIndex;
3003 pVBInfo->LCDResInfo = 0;
3004 pVBInfo->LCDTypeInfo = 0;
3005 pVBInfo->LCDInfo = 0;
3007 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3008 /* si+Ext_ResInfo // */
3009 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
3010 temp = xgifb_reg_get(pVBInfo->P3d4, 0x36); /* Get LCD Res.Info */
3011 tempbx = temp & 0x0F;
3014 tempbx = Panel_1024x768; /* default */
3016 /* LCD75 [2003/8/22] Vicent */
3017 if ((tempbx == Panel_1024x768) || (tempbx == Panel_1280x1024)) {
3018 if (pVBInfo->VBInfo & DriverMode) {
3019 tempax = xgifb_reg_get(pVBInfo->P3d4, 0x33);
3020 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)
3023 tempax = tempax >> 4;
3025 if ((resinfo == 6) || (resinfo == 9)) {
3027 tempbx |= PanelRef75Hz;
3028 } else if ((resinfo == 7) || (resinfo == 8)) {
3030 tempbx |= PanelRef75Hz;
3035 pVBInfo->LCDResInfo = tempbx;
3039 if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)))
3044 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
3046 temp &= (ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable);
3050 LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo);
3052 tempax = pVBInfo->LCDCapList[LCDIdIndex].LCD_Capability;
3054 if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */
3055 if (((pVBInfo->VBType & VB_SIS302LV) || (pVBInfo->VBType
3056 & VB_XGI301C)) && (tempax & XGI_LCDDualLink)) {
3057 tempbx |= SetLCDDualLink;
3061 if (pVBInfo->IF_DEF_LVDS == 0) {
3062 if ((pVBInfo->LCDResInfo == Panel_1400x1050) && (pVBInfo->VBInfo
3063 & SetCRT2ToLCD) && (resinfo == 9) &&
3064 (!(tempbx & EnableScalingLCD)))
3065 /* set to center in 1280x1024 LCDB for Panel_1400x1050 */
3066 tempbx |= SetLCDtoNonExpanding;
3069 if (pVBInfo->IF_DEF_ExpLink == 1) {
3070 if (modeflag & HalfDCLK) {
3071 if (!(tempbx & SetLCDtoNonExpanding)) {
3072 tempbx |= XGI_EnableLVDSDDA;
3074 if (pVBInfo->LCDResInfo == Panel_1024x768) {
3075 if (resinfo == 4) {/* 512x384 */
3076 tempbx |= XGI_EnableLVDSDDA;
3083 if (pVBInfo->VBInfo & SetInSlaveMode) {
3084 if (pVBInfo->VBInfo & SetNotSimuMode)
3085 tempbx |= XGI_LCDVESATiming;
3087 tempbx |= XGI_LCDVESATiming;
3090 pVBInfo->LCDInfo = tempbx;
3095 unsigned char XGI_SearchModeID(unsigned short ModeNo,
3096 unsigned short *ModeIdIndex, struct vb_device_info *pVBInfo)
3098 for (*ModeIdIndex = 0;; (*ModeIdIndex)++) {
3099 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == ModeNo)
3101 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == 0xFF)
3108 static unsigned char XG21GPIODataTransfer(unsigned char ujDate)
3110 unsigned char ujRet = 0;
3111 unsigned char i = 0;
3113 for (i = 0; i < 8; i++) {
3115 ujRet |= (ujDate >> i) & 1;
3121 /*----------------------------------------------------------------------------*/
3123 /* bl[5] : LVDS signal */
3124 /* bl[1] : LVDS backlight */
3125 /* bl[0] : LVDS VDD */
3126 /*----------------------------------------------------------------------------*/
3127 static unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo)
3129 unsigned char CR4A, temp;
3131 CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
3132 xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x23); /* enable GPIO write */
3134 temp = xgifb_reg_get(pVBInfo->P3d4, 0x48);
3136 temp = XG21GPIODataTransfer(temp);
3138 xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A);
3142 /*----------------------------------------------------------------------------*/
3144 /* bl[5] : LVDS signal */
3145 /* bl[1] : LVDS backlight */
3146 /* bl[0] : LVDS VDD */
3147 /*----------------------------------------------------------------------------*/
3148 static unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo)
3150 unsigned char CR4A, CRB4, temp;
3152 CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
3153 xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x0C); /* enable GPIO write */
3155 temp = xgifb_reg_get(pVBInfo->P3d4, 0x48);
3159 xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A);
3160 CRB4 = xgifb_reg_get(pVBInfo->P3d4, 0xB4);
3161 temp |= ((CRB4 & 0x04) << 3);
3165 /*----------------------------------------------------------------------------*/
3167 /* bl[5] : 1;LVDS signal on */
3168 /* bl[1] : 1;LVDS backlight on */
3169 /* bl[0] : 1:LVDS VDD on */
3170 /* bh: 100000b : clear bit 5, to set bit5 */
3171 /* 000010b : clear bit 1, to set bit1 */
3172 /* 000001b : clear bit 0, to set bit0 */
3173 /*----------------------------------------------------------------------------*/
3174 static void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl,
3175 struct vb_device_info *pVBInfo)
3177 unsigned char CR4A, temp;
3179 CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
3182 xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */
3184 if (tempbh & 0x20) {
3185 temp = (tempbl >> 4) & 0x02;
3188 xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp);
3192 temp = xgifb_reg_get(pVBInfo->P3d4, 0x48);
3194 temp = XG21GPIODataTransfer(temp);
3197 xgifb_reg_set(pVBInfo->P3d4, 0x48, temp);
3200 static void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl,
3201 struct vb_device_info *pVBInfo)
3203 unsigned char CR4A, temp;
3204 unsigned short tempbh0, tempbl0;
3213 if (tempbh & 0x20) {
3214 temp = (tempbl >> 4) & 0x02;
3217 xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp);
3220 xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~tempbh0, tempbl0);
3222 CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
3226 tempbl <<= 2; /* GPIOC,GPIOD */
3227 xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */
3228 xgifb_reg_and_or(pVBInfo->P3d4, 0x48, ~tempbh, tempbl);
3231 /* --------------------------------------------------------------------- */
3232 /* Function : XGI_XG21SetPanelDelay */
3236 /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
3237 /* : bl : 2 ; T2 : the duration signal on and Vdd on */
3238 /* : bl : 3 ; T3 : the duration between CPL off and signal off */
3239 /* : bl : 4 ; T4 : the duration signal off and Vdd off */
3240 /* --------------------------------------------------------------------- */
3241 static void XGI_XG21SetPanelDelay(struct xgifb_video_info *xgifb_info,
3242 unsigned short tempbl,
3243 struct vb_device_info *pVBInfo)
3246 mdelay(xgifb_info->lvds_data.PSC_S1);
3249 mdelay(xgifb_info->lvds_data.PSC_S2);
3252 mdelay(xgifb_info->lvds_data.PSC_S3);
3255 mdelay(xgifb_info->lvds_data.PSC_S4);
3258 static void XGI_DisplayOn(struct xgifb_video_info *xgifb_info,
3259 struct xgi_hw_device_info *pXGIHWDE,
3260 struct vb_device_info *pVBInfo)
3263 xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x00);
3264 if (pXGIHWDE->jChipType == XG21) {
3265 if (pVBInfo->IF_DEF_LVDS == 1) {
3266 if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x1)) {
3268 XGI_XG21BLSignalVDD(0x01, 0x01, pVBInfo);
3269 XGI_XG21SetPanelDelay(xgifb_info, 2, pVBInfo);
3271 if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x20))
3272 /* LVDS signal on */
3273 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo);
3274 XGI_XG21SetPanelDelay(xgifb_info, 3, pVBInfo);
3275 /* LVDS backlight on */
3276 XGI_XG21BLSignalVDD(0x02, 0x02, pVBInfo);
3278 /* DVO/DVI signal on */
3279 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo);
3284 if (pXGIHWDE->jChipType == XG27) {
3285 if (pVBInfo->IF_DEF_LVDS == 1) {
3286 if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x1)) {
3288 XGI_XG27BLSignalVDD(0x01, 0x01, pVBInfo);
3289 XGI_XG21SetPanelDelay(xgifb_info, 2, pVBInfo);
3291 if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x20))
3292 /* LVDS signal on */
3293 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo);
3294 XGI_XG21SetPanelDelay(xgifb_info, 3, pVBInfo);
3295 /* LVDS backlight on */
3296 XGI_XG27BLSignalVDD(0x02, 0x02, pVBInfo);
3298 /* DVO/DVI signal on */
3299 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo);
3305 void XGI_DisplayOff(struct xgifb_video_info *xgifb_info,
3306 struct xgi_hw_device_info *pXGIHWDE,
3307 struct vb_device_info *pVBInfo)
3310 if (pXGIHWDE->jChipType == XG21) {
3311 if (pVBInfo->IF_DEF_LVDS == 1) {
3312 /* LVDS backlight off */
3313 XGI_XG21BLSignalVDD(0x02, 0x00, pVBInfo);
3314 XGI_XG21SetPanelDelay(xgifb_info, 3, pVBInfo);
3316 /* DVO/DVI signal off */
3317 XGI_XG21BLSignalVDD(0x20, 0x00, pVBInfo);
3321 if (pXGIHWDE->jChipType == XG27) {
3322 if ((XGI_XG27GetPSCValue(pVBInfo) & 0x2)) {
3323 /* LVDS backlight off */
3324 XGI_XG27BLSignalVDD(0x02, 0x00, pVBInfo);
3325 XGI_XG21SetPanelDelay(xgifb_info, 3, pVBInfo);
3328 if (pVBInfo->IF_DEF_LVDS == 0)
3329 /* DVO/DVI signal off */
3330 XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo);
3333 xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x20);
3336 static void XGI_WaitDisply(struct vb_device_info *pVBInfo)
3338 while ((inb(pVBInfo->P3da) & 0x01))
3341 while (!(inb(pVBInfo->P3da) & 0x01))
3345 static void XGI_AutoThreshold(struct vb_device_info *pVBInfo)
3347 xgifb_reg_or(pVBInfo->Part1Port, 0x01, 0x40);
3350 static void XGI_SaveCRT2Info(unsigned short ModeNo,
3351 struct vb_device_info *pVBInfo)
3353 unsigned short temp1, temp2;
3355 /* reserve CR34 for CRT1 Mode No */
3356 xgifb_reg_set(pVBInfo->P3d4, 0x34, ModeNo);
3357 temp1 = (pVBInfo->VBInfo & SetInSlaveMode) >> 8;
3358 temp2 = ~(SetInSlaveMode >> 8);
3359 xgifb_reg_and_or(pVBInfo->P3d4, 0x31, temp2, temp1);
3362 static void XGI_GetCRT2ResInfo(unsigned short ModeNo,
3363 unsigned short ModeIdIndex,
3364 struct vb_device_info *pVBInfo)
3366 unsigned short xres, yres, modeflag, resindex;
3368 resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
3369 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
3370 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
3371 /* si+St_ModeFlag */
3372 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3374 if (modeflag & HalfDCLK)
3377 if (modeflag & DoubleScanMode)
3380 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
3381 if (pVBInfo->IF_DEF_LVDS == 0) {
3382 if (pVBInfo->LCDResInfo == Panel_1600x1200) {
3383 if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
3389 if (pVBInfo->LCDResInfo == Panel_1280x1024) {
3392 else if (yres == 350)
3395 if (pVBInfo->LCDInfo & XGI_LCDVESATiming) {
3401 if (pVBInfo->LCDResInfo == Panel_1024x768) {
3402 if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
3403 if (!(pVBInfo->LCDInfo
3404 & LCDNonExpanding)) {
3407 else if (yres == 400)
3409 else if (yres == 480)
3420 pVBInfo->VGAHDE = xres;
3421 pVBInfo->HDE = xres;
3422 pVBInfo->VGAVDE = yres;
3423 pVBInfo->VDE = yres;
3426 static unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo)
3429 if ((pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) &&
3430 (pVBInfo->LCDInfo & SetLCDDualLink)) /* shampoo0129 */
3436 static void XGI_GetRAMDAC2DATA(unsigned short ModeNo,
3437 unsigned short ModeIdIndex,
3438 unsigned short RefreshRateTableIndex,
3439 struct vb_device_info *pVBInfo)
3441 unsigned short tempax, tempbx, temp1, temp2, modeflag = 0, tempcx,
3444 pVBInfo->RVBHCMAX = 1;
3445 pVBInfo->RVBHCFACT = 1;
3446 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3447 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
3448 CRT1Index &= IndexMask;
3449 temp1 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[0];
3450 temp2 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5];
3451 tempax = (temp1 & 0xFF) | ((temp2 & 0x03) << 8);
3452 tempbx = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[8];
3453 tempcx = (unsigned short)
3454 pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14] << 8;
3456 tempcx = tempcx << 2;
3458 temp1 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9];
3467 if (modeflag & Charx8Dot)
3472 pVBInfo->VGAHT = tempax;
3473 pVBInfo->HT = tempax;
3475 pVBInfo->VGAVT = tempbx;
3476 pVBInfo->VT = tempbx;
3479 static void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex,
3480 unsigned short RefreshRateTableIndex,
3481 struct vb_device_info *pVBInfo)
3483 unsigned short tempax = 0, tempbx, modeflag, resinfo;
3485 struct SiS_LCDData *LCDPtr = NULL;
3486 struct SiS_TVData *TVPtr = NULL;
3488 /* si+Ext_ResInfo */
3489 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3490 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
3491 pVBInfo->NewFlickerMode = 0;
3492 pVBInfo->RVBHRS = 50;
3494 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
3495 XGI_GetRAMDAC2DATA(ModeNo, ModeIdIndex, RefreshRateTableIndex,
3502 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
3503 LCDPtr = (struct SiS_LCDData *) XGI_GetLcdPtr(tempbx,
3504 ModeNo, ModeIdIndex, RefreshRateTableIndex,
3507 pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX;
3508 pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT;
3509 pVBInfo->VGAHT = LCDPtr->VGAHT;
3510 pVBInfo->VGAVT = LCDPtr->VGAVT;
3511 pVBInfo->HT = LCDPtr->LCDHT;
3512 pVBInfo->VT = LCDPtr->LCDVT;
3514 if (pVBInfo->LCDResInfo == Panel_1024x768) {
3518 if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
3519 if (pVBInfo->VGAVDE == 357)
3521 else if (pVBInfo->VGAVDE == 420)
3523 else if (pVBInfo->VGAVDE == 525)
3525 else if (pVBInfo->VGAVDE == 600)
3531 } else if (pVBInfo->LCDResInfo == Panel_1024x768x75) {
3534 } else if (pVBInfo->LCDResInfo == Panel_1280x1024) {
3536 if (pVBInfo->VGAVDE == 360)
3538 else if (pVBInfo->VGAVDE == 375)
3540 else if (pVBInfo->VGAVDE == 405)
3544 } else if (pVBInfo->LCDResInfo == Panel_1280x1024x75) {
3547 } else if (pVBInfo->LCDResInfo == Panel_1280x960) {
3549 if (pVBInfo->VGAVDE == 350)
3551 else if (pVBInfo->VGAVDE == 400)
3553 else if (pVBInfo->VGAVDE == 1024)
3557 } else if (pVBInfo->LCDResInfo == Panel_1400x1050) {
3561 if (pVBInfo->VGAVDE == 1024) {
3565 } else if (pVBInfo->LCDResInfo == Panel_1600x1200) {
3567 tempbx = 1200; /* alan 10/14/2003 */
3568 if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
3569 if (pVBInfo->VGAVDE == 350)
3571 else if (pVBInfo->VGAVDE == 400)
3576 if (pVBInfo->LCDInfo & LCDNonExpanding) {
3577 tempax = pVBInfo->VGAHDE;
3578 tempbx = pVBInfo->VGAVDE;
3581 pVBInfo->HDE = tempax;
3582 pVBInfo->VDE = tempbx;
3586 if (pVBInfo->VBInfo & (SetCRT2ToTV)) {
3588 TVPtr = (struct SiS_TVData *) XGI_GetTVPtr(tempbx,
3589 ModeNo, ModeIdIndex, RefreshRateTableIndex,
3592 pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX;
3593 pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT;
3594 pVBInfo->VGAHT = TVPtr->VGAHT;
3595 pVBInfo->VGAVT = TVPtr->VGAVT;
3596 pVBInfo->HDE = TVPtr->TVHDE;
3597 pVBInfo->VDE = TVPtr->TVVDE;
3598 pVBInfo->RVBHRS = TVPtr->RVBHRS;
3599 pVBInfo->NewFlickerMode = TVPtr->FlickerMode;
3601 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
3602 if (resinfo == 0x08)
3603 pVBInfo->NewFlickerMode = 0x40;
3604 else if (resinfo == 0x09)
3605 pVBInfo->NewFlickerMode = 0x40;
3606 else if (resinfo == 0x12)
3607 pVBInfo->NewFlickerMode = 0x40;
3609 if (pVBInfo->VGAVDE == 350)
3610 pVBInfo->TVInfo |= TVSimuMode;
3615 if (pVBInfo->VBInfo & SetInSlaveMode) {
3616 if (pVBInfo->TVInfo & TVSimuMode) {
3620 if (!(modeflag & Charx8Dot)) {
3621 tempax = StHiTextTVHT;
3622 tempbx = StHiTextTVVT;
3626 } else if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
3627 if (pVBInfo->TVInfo & TVSetYPbPr750p) {
3628 tempax = YPbPrTV750pHT; /* Ext750pTVHT */
3629 tempbx = YPbPrTV750pVT; /* Ext750pTVVT */
3632 if (pVBInfo->TVInfo & TVSetYPbPr525p) {
3633 tempax = YPbPrTV525pHT; /* Ext525pTVHT */
3634 tempbx = YPbPrTV525pVT; /* Ext525pTVVT */
3635 } else if (pVBInfo->TVInfo & TVSetYPbPr525i) {
3636 tempax = YPbPrTV525iHT; /* Ext525iTVHT */
3637 tempbx = YPbPrTV525iVT; /* Ext525iTVVT */
3638 if (pVBInfo->TVInfo & NTSC1024x768)
3639 tempax = NTSC1024x768HT;
3644 if (!(pVBInfo->TVInfo & TVSetPAL)) {
3647 if (pVBInfo->TVInfo & NTSC1024x768)
3648 tempax = NTSC1024x768HT;
3652 pVBInfo->HT = tempax;
3653 pVBInfo->VT = tempbx;
3658 static void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex,
3659 unsigned short RefreshRateTableIndex,
3660 struct vb_device_info *pVBInfo)
3662 unsigned char di_0, di_1, tempal;
3664 tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex,
3666 XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo);
3667 XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo);
3669 if (pVBInfo->VBType & VB_SIS301) { /* shampoo 0129 */
3671 xgifb_reg_set(pVBInfo->Part4Port, 0x0A, 0x10);
3672 xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1);
3673 xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0);
3674 } else { /* 301b/302b/301lv/302lv */
3675 xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0);
3676 xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1);
3679 xgifb_reg_set(pVBInfo->Part4Port, 0x00, 0x12);
3681 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC)
3682 xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x28);
3684 xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x08);
3687 static unsigned short XGI_GetColorDepth(unsigned short ModeNo,
3688 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
3690 unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8 };
3692 unsigned short modeflag;
3694 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3695 index = (modeflag & ModeTypeMask) - ModeEGA;
3700 return ColorDepth[index];
3703 static unsigned short XGI_GetOffset(unsigned short ModeNo,
3704 unsigned short ModeIdIndex,
3705 unsigned short RefreshRateTableIndex,
3706 struct xgi_hw_device_info *HwDeviceExtension,
3707 struct vb_device_info *pVBInfo)
3709 unsigned short temp, colordepth, modeinfo, index, infoflag,
3710 ColorDepth[] = { 0x01, 0x02, 0x04 };
3712 modeinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo;
3713 infoflag = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
3715 index = (modeinfo >> 8) & 0xFF;
3717 temp = pVBInfo->ScreenOffset[index];
3719 if (infoflag & InterlaceMode)
3722 colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo);
3724 if ((ModeNo >= 0x7C) && (ModeNo <= 0x7E)) {
3725 temp = ModeNo - 0x7C;
3726 colordepth = ColorDepth[temp];
3728 if (infoflag & InterlaceMode)
3730 return temp * colordepth;
3732 return temp * colordepth;
3736 static void XGI_SetCRT2Offset(unsigned short ModeNo,
3737 unsigned short ModeIdIndex,
3738 unsigned short RefreshRateTableIndex,
3739 struct xgi_hw_device_info *HwDeviceExtension,
3740 struct vb_device_info *pVBInfo)
3742 unsigned short offset;
3745 if (pVBInfo->VBInfo & SetInSlaveMode)
3748 offset = XGI_GetOffset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
3749 HwDeviceExtension, pVBInfo);
3750 temp = (unsigned char) (offset & 0xFF);
3751 xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp);
3752 temp = (unsigned char) ((offset & 0xFF00) >> 8);
3753 xgifb_reg_set(pVBInfo->Part1Port, 0x09, temp);
3754 temp = (unsigned char) (((offset >> 3) & 0xFF) + 1);
3755 xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp);
3758 static void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo)
3760 /* threshold high ,disable auto threshold */
3761 xgifb_reg_set(pVBInfo->Part1Port, 0x01, 0x3B);
3762 /* threshold low default 04h */
3763 xgifb_reg_and_or(pVBInfo->Part1Port, 0x02, ~(0x3F), 0x04);
3766 static void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
3767 struct xgi_hw_device_info *HwDeviceExtension,
3768 unsigned short RefreshRateTableIndex,
3769 struct vb_device_info *pVBInfo)
3771 unsigned short tempcx = 0, CRT1Index = 0, resinfo = 0;
3773 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
3774 CRT1Index &= IndexMask;
3775 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
3777 XGI_SetCRT2Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
3778 HwDeviceExtension, pVBInfo);
3779 XGI_SetCRT2FIFO(pVBInfo);
3781 for (tempcx = 4; tempcx < 7; tempcx++)
3782 xgifb_reg_set(pVBInfo->Part1Port, tempcx, 0x0);
3784 xgifb_reg_set(pVBInfo->Part1Port, 0x50, 0x00);
3785 xgifb_reg_set(pVBInfo->Part1Port, 0x02, 0x44); /* temp 0206 */
3788 static void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
3789 struct xgi_hw_device_info *HwDeviceExtension,
3790 unsigned short RefreshRateTableIndex,
3791 struct vb_device_info *pVBInfo)
3793 unsigned short temp = 0, tempax = 0, tempbx = 0, tempcx = 0,
3794 pushbx = 0, CRT1Index = 0, modeflag, resinfo = 0;
3796 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
3797 CRT1Index &= IndexMask;
3798 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
3799 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3801 /* bainy change table name */
3802 if (modeflag & HalfDCLK) {
3803 /* BTVGA2HT 0x08,0x09 */
3804 temp = (pVBInfo->VGAHT / 2 - 1) & 0x0FF;
3805 xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp);
3806 temp = (((pVBInfo->VGAHT / 2 - 1) & 0xFF00) >> 8) << 4;
3807 xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp);
3808 /* BTVGA2HDEE 0x0A,0x0C */
3809 temp = (pVBInfo->VGAHDE / 2 + 16) & 0x0FF;
3810 xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp);
3811 tempcx = ((pVBInfo->VGAHT - pVBInfo->VGAHDE) / 2) >> 2;
3812 pushbx = pVBInfo->VGAHDE / 2 + 16;
3813 tempcx = tempcx >> 1;
3814 tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */
3817 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
3818 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4];
3819 tempbx |= ((pVBInfo->
3820 XGINEWUB_CRT1Table[CRT1Index].CR[14] &
3822 tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */
3823 tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5];
3825 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[15];
3826 temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */
3827 tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */
3833 if (tempcx > (pVBInfo->VGAHT / 2))
3834 tempcx = pVBInfo->VGAHT / 2;
3836 temp = tempbx & 0x00FF;
3838 xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp);
3840 temp = (pVBInfo->VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */
3841 xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp);
3842 temp = (((pVBInfo->VGAHT - 1) & 0xFF00) >> 8) << 4;
3843 xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp);
3844 /* BTVGA2HDEE 0x0A,0x0C */
3845 temp = (pVBInfo->VGAHDE + 16) & 0x0FF;
3846 xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp);
3847 tempcx = (pVBInfo->VGAHT - pVBInfo->VGAHDE) >> 2; /* cx */
3848 pushbx = pVBInfo->VGAHDE + 16;
3849 tempcx = tempcx >> 1;
3850 tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */
3853 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
3854 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[3];
3855 tempbx |= ((pVBInfo->
3856 XGINEWUB_CRT1Table[CRT1Index].CR[5] &
3858 tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */
3859 tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4];
3861 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[6];
3862 temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */
3863 tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */
3868 if (tempcx > pVBInfo->VGAHT)
3869 tempcx = pVBInfo->VGAHT;
3871 temp = tempbx & 0x00FF;
3872 xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp);
3875 tempax = (tempax & 0x00FF) | (tempbx & 0xFF00);
3877 tempbx = (tempbx & 0x00FF) | ((tempbx & 0xFF00) << 4);
3878 tempax |= (tempbx & 0xFF00);
3879 temp = (tempax & 0xFF00) >> 8;
3880 xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp);
3881 temp = tempcx & 0x00FF;
3882 xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp);
3883 tempcx = (pVBInfo->VGAVT - 1);
3884 temp = tempcx & 0x00FF;
3886 xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp);
3887 tempbx = pVBInfo->VGAVDE - 1;
3888 temp = tempbx & 0x00FF;
3889 xgifb_reg_set(pVBInfo->Part1Port, 0x0F, temp);
3890 temp = ((tempbx & 0xFF00) << 3) >> 8;
3891 temp |= ((tempcx & 0xFF00) >> 8);
3892 xgifb_reg_set(pVBInfo->Part1Port, 0x12, temp);
3894 tempax = pVBInfo->VGAVDE;
3895 tempbx = pVBInfo->VGAVDE;
3896 tempcx = pVBInfo->VGAVT;
3897 /* BTVGA2VRS 0x10,0x11 */
3898 tempbx = (pVBInfo->VGAVT + pVBInfo->VGAVDE) >> 1;
3899 /* BTVGA2VRE 0x11 */
3900 tempcx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) >> 4) + tempbx + 1;
3902 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
3903 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[10];
3904 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9];
3912 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14];
3917 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[11];
3918 tempcx = (tempcx & 0xFF00) | (temp & 0x00FF);
3921 temp = tempbx & 0x00FF;
3922 xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp);
3923 temp = ((tempbx & 0xFF00) >> 8) << 4;
3924 temp = ((tempcx & 0x000F) | (temp));
3925 xgifb_reg_set(pVBInfo->Part1Port, 0x11, temp);
3928 if (modeflag & DoubleScanMode)
3931 if (modeflag & HalfDCLK)
3934 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2C, ~0x0C0, tempax);
3937 static unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo)
3939 unsigned long tempax, tempbx;
3941 tempbx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) * pVBInfo->RVBHCMAX)
3943 tempax = (pVBInfo->VT - pVBInfo->VDE) * pVBInfo->RVBHCFACT;
3944 tempax = (tempax * pVBInfo->HT) / tempbx;
3946 return (unsigned short) tempax;
3949 static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
3950 struct xgi_hw_device_info *HwDeviceExtension,
3951 unsigned short RefreshRateTableIndex,
3952 struct vb_device_info *pVBInfo)
3954 unsigned short push1, push2, tempax, tempbx = 0, tempcx, temp, resinfo,
3955 modeflag, CRT1Index;
3957 /* si+Ext_ResInfo */
3958 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3959 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
3960 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
3961 CRT1Index &= IndexMask;
3963 if (!(pVBInfo->VBInfo & SetInSlaveMode))
3966 temp = 0xFF; /* set MAX HT */
3967 xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp);
3970 if (pVBInfo->VBType & (VB_SIS301LV | VB_SIS302LV | VB_XGI301C))
3971 modeflag |= Charx8Dot;
3973 tempax = pVBInfo->VGAHDE; /* 0x04 Horizontal Display End */
3975 if (modeflag & HalfDCLK)
3976 tempax = tempax >> 1;
3978 tempax = (tempax / tempcx) - 1;
3979 tempbx |= ((tempax & 0x00FF) << 8);
3980 temp = tempax & 0x00FF;
3981 xgifb_reg_set(pVBInfo->Part1Port, 0x04, temp);
3983 temp = (tempbx & 0xFF00) >> 8;
3985 if (pVBInfo->VBInfo & SetCRT2ToTV) {
3986 if (!(pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
3987 | VB_SIS302LV | VB_XGI301C)))
3990 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
3991 if (pVBInfo->VBType & VB_SIS301LV) {
3992 if (pVBInfo->VBExtInfo == VB_YPbPr1080i) {
3996 } else if (resinfo == 7) {
4002 /* 0x05 Horizontal Display Start */
4003 xgifb_reg_set(pVBInfo->Part1Port, 0x05, temp);
4004 /* 0x06 Horizontal Blank end */
4005 xgifb_reg_set(pVBInfo->Part1Port, 0x06, 0x03);
4007 if (!(pVBInfo->VBInfo & DisableCRT2Display)) { /* 030226 bainy */
4008 if (pVBInfo->VBInfo & SetCRT2ToTV)
4009 tempax = pVBInfo->VGAHT;
4011 tempax = XGI_GetVGAHT2(pVBInfo);
4014 if (tempax >= pVBInfo->VGAHT)
4015 tempax = pVBInfo->VGAHT;
4017 if (modeflag & HalfDCLK)
4018 tempax = tempax >> 1;
4020 tempax = (tempax / tempcx) - 5;
4021 tempcx = tempax; /* 20030401 0x07 horizontal Retrace Start */
4022 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
4023 temp = (tempbx & 0x00FF) - 1;
4024 if (!(modeflag & HalfDCLK)) {
4026 if (pVBInfo->TVInfo & TVSimuMode) {
4032 tempbx = (tempbx & 0xFF00) >> 8;
4033 tempcx = (tempcx + tempbx) >> 1;
4034 temp = (tempcx & 0x00FF) + 2;
4036 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4038 if (!(modeflag & HalfDCLK)) {
4039 if ((modeflag & Charx8Dot)) {
4041 if (pVBInfo->VGAHDE >= 800)
4045 } else if (!(modeflag & HalfDCLK)) {
4047 if (pVBInfo->LCDResInfo != Panel_1280x960 &&
4048 pVBInfo->VGAHDE >= 800) {
4050 if (pVBInfo->VGAHDE >= 1280 &&
4051 pVBInfo->LCDResInfo != Panel_1280x960 &&
4052 (pVBInfo->LCDInfo & LCDNonExpanding))
4058 /* 0x07 Horizontal Retrace Start */
4059 xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp);
4060 /* 0x08 Horizontal Retrace End */
4061 xgifb_reg_set(pVBInfo->Part1Port, 0x08, 0);
4063 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4064 if (pVBInfo->TVInfo & TVSimuMode) {
4065 if (ModeNo == 0x50) {
4066 if (pVBInfo->TVInfo & SetNTSCTV) {
4067 xgifb_reg_set(pVBInfo->Part1Port,
4069 xgifb_reg_set(pVBInfo->Part1Port,
4072 xgifb_reg_set(pVBInfo->Part1Port,
4074 xgifb_reg_set(pVBInfo->Part1Port,
4081 xgifb_reg_set(pVBInfo->Part1Port, 0x18, 0x03); /* 0x18 SR0B */
4082 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0xF0, 0x00);
4083 xgifb_reg_set(pVBInfo->Part1Port, 0x09, 0xFF); /* 0x09 Set Max VT */
4085 tempbx = pVBInfo->VGAVT;
4088 tempbx = pVBInfo->VGAVDE; /* 0x0E Virtical Display End */
4103 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
4104 if (pVBInfo->LCDResInfo == Panel_1024x768) {
4105 if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
4114 temp = tempbx & 0x00FF;
4116 temp = tempbx & 0x00FF;
4117 /* 0x10 vertical Blank Start */
4118 xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp);
4121 temp = tempbx & 0x00FF;
4122 xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp);
4124 if (tempbx & 0x0100)
4129 if (modeflag & DoubleScanMode)
4132 if (tempbx & 0x0200)
4135 temp = (tempax & 0xFF00) >> 8;
4136 xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp);
4138 if (tempbx & 0x0400)
4141 /* 0x11 Vertival Blank End */
4142 xgifb_reg_set(pVBInfo->Part1Port, 0x11, 0x00);
4145 tempax -= tempbx; /* 0x0C Vertical Retrace Start */
4146 tempax = tempax >> 2;
4147 push1 = tempax; /* push ax */
4149 if (resinfo != 0x09) {
4150 tempax = tempax << 1;
4154 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
4155 if (pVBInfo->VBType & VB_SIS301LV) {
4156 if (pVBInfo->TVInfo & TVSetHiVision) {
4159 if (pVBInfo->TVInfo & TVSimuMode) {
4160 if (pVBInfo->TVInfo & TVSetPAL) {
4161 if (pVBInfo->VBType &
4163 if (!(pVBInfo->TVInfo &
4178 if (pVBInfo->TVInfo & TVSimuMode) {
4179 if (pVBInfo->TVInfo & TVSetPAL) {
4180 if (pVBInfo->VBType & VB_SIS301LV) {
4181 if (!(pVBInfo->TVInfo &
4193 tempax = tempax >> 2;
4196 push1 = tempax; /* push ax */
4198 if ((pVBInfo->TVInfo & TVSetPAL)) {
4199 if (tempbx <= 513) {
4205 temp = tempbx & 0x00FF;
4206 xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp);
4208 temp = tempbx & 0x00FF;
4209 xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp);
4211 if (tempbx & 0x0100)
4214 if (tempbx & 0x0200)
4215 xgifb_reg_and_or(pVBInfo->Part1Port, 0x0B, 0x0FF, 0x20);
4219 if (tempbx & 0x0100)
4222 if (tempbx & 0x0200)
4225 if (tempbx & 0x0400)
4228 tempbx = push1; /* pop ax */
4229 temp = tempbx & 0x00FF;
4231 /* 0x0D vertical Retrace End */
4232 xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp);
4234 if (tempbx & 0x0010)
4237 temp = tempcx & 0x00FF;
4238 xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); /* 0x0A CR07 */
4239 temp = (tempcx & 0x0FF00) >> 8;
4240 xgifb_reg_set(pVBInfo->Part1Port, 0x17, temp); /* 0x17 SR0A */
4242 temp = (tempax & 0xFF00) >> 8;
4244 temp = (temp >> 1) & 0x09;
4246 if (pVBInfo->VBType & (VB_SIS301LV | VB_SIS302LV | VB_XGI301C))
4249 xgifb_reg_set(pVBInfo->Part1Port, 0x16, temp); /* 0x16 SR01 */
4250 xgifb_reg_set(pVBInfo->Part1Port, 0x0F, 0); /* 0x0F CR14 */
4251 xgifb_reg_set(pVBInfo->Part1Port, 0x12, 0); /* 0x12 CR17 */
4253 if (pVBInfo->LCDInfo & LCDRGB18Bit)
4258 xgifb_reg_set(pVBInfo->Part1Port, 0x1A, temp); /* 0x1A SR0E */
4263 static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex,
4264 unsigned short RefreshRateTableIndex,
4265 struct xgi_hw_device_info *HwDeviceExtension,
4266 struct vb_device_info *pVBInfo)
4268 unsigned short i, j, tempax, tempbx, tempcx, temp, push1, push2,
4269 modeflag, resinfo, crt2crtc;
4270 unsigned char *TimingPoint;
4272 unsigned long longtemp, tempeax, tempebx, temp2, tempecx;
4274 /* si+Ext_ResInfo */
4275 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4276 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4277 crt2crtc = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
4281 if (!(pVBInfo->VBInfo & SetCRT2ToAVIDEO))
4284 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
4287 if (pVBInfo->VBInfo & SetCRT2ToSCART)
4290 if (!(pVBInfo->TVInfo & TVSetPAL))
4293 if (pVBInfo->VBInfo & SetCRT2ToHiVision)
4296 if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p))
4299 tempax = (tempax & 0xff00) >> 8;
4301 xgifb_reg_set(pVBInfo->Part2Port, 0x0, tempax);
4302 TimingPoint = pVBInfo->NTSCTiming;
4304 if (pVBInfo->TVInfo & TVSetPAL)
4305 TimingPoint = pVBInfo->PALTiming;
4307 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
4308 TimingPoint = pVBInfo->HiTVExtTiming;
4310 if (pVBInfo->VBInfo & SetInSlaveMode)
4311 TimingPoint = pVBInfo->HiTVSt2Timing;
4313 if (pVBInfo->SetFlag & TVSimuMode)
4314 TimingPoint = pVBInfo->HiTVSt1Timing;
4316 if (!(modeflag & Charx8Dot))
4317 TimingPoint = pVBInfo->HiTVTextTiming;
4320 if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
4321 if (pVBInfo->TVInfo & TVSetYPbPr525i)
4322 TimingPoint = pVBInfo->YPbPr525iTiming;
4324 if (pVBInfo->TVInfo & TVSetYPbPr525p)
4325 TimingPoint = pVBInfo->YPbPr525pTiming;
4327 if (pVBInfo->TVInfo & TVSetYPbPr750p)
4328 TimingPoint = pVBInfo->YPbPr750pTiming;
4331 for (i = 0x01, j = 0; i <= 0x2D; i++, j++)
4332 xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]);
4334 for (i = 0x39; i <= 0x45; i++, j++)
4336 xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]);
4338 if (pVBInfo->VBInfo & SetCRT2ToTV)
4339 xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, 0x00);
4341 temp = pVBInfo->NewFlickerMode;
4343 xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xFF, temp);
4345 if (pVBInfo->VBInfo & SetCRT2ToHiVision)
4348 if (pVBInfo->TVInfo & TVSetPAL)
4353 if (pVBInfo->VDE <= tempax) {
4354 tempax -= pVBInfo->VDE;
4355 tempax = tempax >> 2;
4356 tempax = (tempax & 0x00FF) | ((tempax & 0x00FF) << 8);
4358 temp = (tempax & 0xFF00) >> 8;
4359 temp += (unsigned short) TimingPoint[0];
4361 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
4362 | VB_SIS302LV | VB_XGI301C)) {
4363 if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO
4364 | SetCRT2ToSVIDEO | SetCRT2ToSCART
4365 | SetCRT2ToYPbPr525750)) {
4366 tempcx = pVBInfo->VGAHDE;
4367 if (tempcx >= 1024) {
4368 temp = 0x17; /* NTSC */
4369 if (pVBInfo->TVInfo & TVSetPAL)
4370 temp = 0x19; /* PAL */
4375 xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp);
4377 temp = (tempax & 0xFF00) >> 8;
4378 temp += TimingPoint[1];
4380 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
4381 | VB_SIS302LV | VB_XGI301C)) {
4382 if ((pVBInfo->VBInfo & (SetCRT2ToAVIDEO
4383 | SetCRT2ToSVIDEO | SetCRT2ToSCART
4384 | SetCRT2ToYPbPr525750))) {
4385 tempcx = pVBInfo->VGAHDE;
4386 if (tempcx >= 1024) {
4387 temp = 0x1D; /* NTSC */
4388 if (pVBInfo->TVInfo & TVSetPAL)
4389 temp = 0x52; /* PAL */
4393 xgifb_reg_set(pVBInfo->Part2Port, 0x02, temp);
4397 tempcx = pVBInfo->HT;
4399 if (XGI_IsLCDDualLink(pVBInfo))
4400 tempcx = tempcx >> 1;
4403 temp = tempcx & 0x00FF;
4404 xgifb_reg_set(pVBInfo->Part2Port, 0x1B, temp);
4406 temp = (tempcx & 0xFF00) >> 8;
4407 xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F, temp);
4409 tempcx = pVBInfo->HT >> 1;
4410 push1 = tempcx; /* push cx */
4413 if (pVBInfo->VBInfo & SetCRT2ToHiVision)
4416 temp = tempcx & 0x00FF;
4418 xgifb_reg_and_or(pVBInfo->Part2Port, 0x22, 0x0F, temp);
4420 tempbx = TimingPoint[j] | ((TimingPoint[j + 1]) << 8);
4423 temp = tempbx & 0x00FF;
4424 xgifb_reg_set(pVBInfo->Part2Port, 0x24, temp);
4425 temp = (tempbx & 0xFF00) >> 8;
4427 xgifb_reg_and_or(pVBInfo->Part2Port, 0x25, 0x0F, temp);
4430 tempbx = tempbx + 8;
4431 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
4432 tempbx = tempbx - 4;
4436 temp = (tempbx & 0x00FF) << 4;
4437 xgifb_reg_and_or(pVBInfo->Part2Port, 0x29, 0x0F, temp);
4440 tempcx += (TimingPoint[j] | ((TimingPoint[j + 1]) << 8));
4441 temp = tempcx & 0x00FF;
4442 xgifb_reg_set(pVBInfo->Part2Port, 0x27, temp);
4443 temp = ((tempcx & 0xFF00) >> 8) << 4;
4444 xgifb_reg_and_or(pVBInfo->Part2Port, 0x28, 0x0F, temp);
4447 if (pVBInfo->VBInfo & SetCRT2ToHiVision)
4450 temp = tempcx & 0xFF;
4452 xgifb_reg_and_or(pVBInfo->Part2Port, 0x2A, 0x0F, temp);
4454 tempcx = push1; /* pop cx */
4456 temp = TimingPoint[j] | ((TimingPoint[j + 1]) << 8);
4458 temp = tempcx & 0x00FF;
4460 xgifb_reg_and_or(pVBInfo->Part2Port, 0x2D, 0x0F, temp);
4464 if (!(pVBInfo->VBInfo & SetCRT2ToTV)) {
4465 tempax = XGI_GetVGAHT2(pVBInfo);
4466 tempcx = tempax - 1;
4468 temp = tempcx & 0x00FF;
4469 xgifb_reg_set(pVBInfo->Part2Port, 0x2E, temp);
4471 tempbx = pVBInfo->VDE;
4473 if (pVBInfo->VGAVDE == 360)
4475 if (pVBInfo->VGAVDE == 375)
4477 if (pVBInfo->VGAVDE == 405)
4480 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4481 if (pVBInfo->VBType &
4482 (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) {
4483 if (!(pVBInfo->TVInfo &
4484 (TVSetYPbPr525p | TVSetYPbPr750p)))
4485 tempbx = tempbx >> 1;
4487 tempbx = tempbx >> 1;
4491 temp = tempbx & 0x00FF;
4493 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
4494 if (pVBInfo->VBType & VB_SIS301LV) {
4495 if (pVBInfo->TVInfo & TVSetHiVision) {
4496 if (pVBInfo->VBInfo & SetInSlaveMode) {
4502 if (pVBInfo->VBInfo & SetInSlaveMode) {
4509 xgifb_reg_set(pVBInfo->Part2Port, 0x2F, temp);
4511 temp = (tempcx & 0xFF00) >> 8;
4512 temp |= ((tempbx & 0xFF00) >> 8) << 6;
4514 if (!(pVBInfo->VBInfo & SetCRT2ToHiVision)) {
4515 if (pVBInfo->VBType & VB_SIS301LV) {
4516 if (pVBInfo->TVInfo & TVSetHiVision) {
4519 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
4524 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
4529 xgifb_reg_set(pVBInfo->Part2Port, 0x30, temp);
4531 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
4532 | VB_SIS302LV | VB_XGI301C)) { /* TV gatingno */
4533 tempbx = pVBInfo->VDE;
4534 tempcx = tempbx - 2;
4536 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4537 if (!(pVBInfo->TVInfo & (TVSetYPbPr525p
4539 tempbx = tempbx >> 1;
4542 if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) {
4544 if (tempcx & 0x0400)
4547 if (tempbx & 0x0400)
4550 xgifb_reg_set(pVBInfo->Part4Port, 0x10, temp);
4553 temp = (((tempbx - 3) & 0x0300) >> 8) << 5;
4554 xgifb_reg_set(pVBInfo->Part2Port, 0x46, temp);
4555 temp = (tempbx - 3) & 0x00FF;
4556 xgifb_reg_set(pVBInfo->Part2Port, 0x47, temp);
4559 tempbx = tempbx & 0x00FF;
4561 if (!(modeflag & HalfDCLK)) {
4562 tempcx = pVBInfo->VGAHDE;
4563 if (tempcx >= pVBInfo->HDE) {
4571 if (pVBInfo->VBInfo & SetCRT2ToTV) { /*301b*/
4572 if (pVBInfo->VGAHDE >= 1024) {
4574 if (pVBInfo->VGAHDE >= 1280) {
4576 tempbx = tempbx & 0xDFFF;
4581 if (!(tempbx & 0x2000)) {
4582 if (modeflag & HalfDCLK)
4583 tempcx = (tempcx & 0xFF00) | ((tempcx & 0x00FF) << 1);
4586 tempeax = pVBInfo->VGAHDE;
4587 tempebx = (tempcx & 0xFF00) >> 8;
4588 longtemp = tempeax * tempebx;
4589 tempecx = tempcx & 0x00FF;
4590 longtemp = longtemp / tempecx;
4595 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
4596 | VB_SIS302LV | VB_XGI301C)) {
4597 tempecx = tempecx * 8;
4600 longtemp = longtemp * tempecx;
4601 tempecx = pVBInfo->HDE;
4602 temp2 = longtemp % tempecx;
4603 tempeax = longtemp / tempecx;
4607 tempax = (unsigned short) tempeax;
4610 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
4611 | VB_SIS302LV | VB_XGI301C)) {
4612 tempcx = ((tempax & 0xFF00) >> 5) >> 8;
4617 tempbx = (unsigned short) (((tempeax & 0x0000FF00) & 0x1F00)
4618 | (tempbx & 0x00FF));
4619 tempax = (unsigned short) (((tempeax & 0x000000FF) << 8)
4620 | (tempax & 0x00FF));
4621 temp = (tempax & 0xFF00) >> 8;
4623 temp = (tempax & 0x00FF) >> 8;
4626 xgifb_reg_set(pVBInfo->Part2Port, 0x44, temp);
4627 temp = (tempbx & 0xFF00) >> 8;
4628 xgifb_reg_and_or(pVBInfo->Part2Port, 0x45, ~0x03F, temp);
4629 temp = tempcx & 0x00FF;
4631 if (tempbx & 0x2000)
4634 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
4637 xgifb_reg_and_or(pVBInfo->Part2Port, 0x46, ~0x1F, temp);
4638 if (pVBInfo->TVInfo & TVSetPAL) {
4646 temp = tempbx & 0x00FF;
4647 xgifb_reg_set(pVBInfo->Part2Port, 0x4b, temp);
4648 temp = tempcx & 0x00FF;
4649 xgifb_reg_set(pVBInfo->Part2Port, 0x4c, temp);
4651 temp = ((tempcx & 0xFF00) >> 8) & 0x03;
4653 temp |= ((tempbx & 0xFF00) >> 8) & 0x03;
4655 if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
4658 if (pVBInfo->TVInfo & TVSetYPbPr525p)
4661 if (pVBInfo->TVInfo & TVSetYPbPr750p)
4665 xgifb_reg_set(pVBInfo->Part2Port, 0x4d, temp);
4666 temp = xgifb_reg_get(pVBInfo->Part2Port, 0x43); /* 301b change */
4667 xgifb_reg_set(pVBInfo->Part2Port, 0x43, (unsigned short) (temp - 3));
4669 if (!(pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p))) {
4670 if (pVBInfo->TVInfo & NTSC1024x768) {
4671 TimingPoint = XGI_NTSC1024AdjTime;
4672 for (i = 0x1c, j = 0; i <= 0x30; i++, j++) {
4673 xgifb_reg_set(pVBInfo->Part2Port, i,
4676 xgifb_reg_set(pVBInfo->Part2Port, 0x43, 0x72);
4680 /* [ycchen] 01/14/03 Modify for 301C PALM Support */
4681 if (pVBInfo->VBType & VB_XGI301C) {
4682 if (pVBInfo->TVInfo & TVSetPALM)
4683 xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x08,
4684 0x08); /* PALM Mode */
4687 if (pVBInfo->TVInfo & TVSetPALM) {
4688 tempax = (unsigned char) xgifb_reg_get(pVBInfo->Part2Port,
4691 xgifb_reg_and(pVBInfo->Part2Port, 0x01, tempax);
4693 xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xEF);
4696 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
4697 if (!(pVBInfo->VBInfo & SetInSlaveMode))
4698 xgifb_reg_set(pVBInfo->Part2Port, 0x0B, 0x00);
4701 if (pVBInfo->VBInfo & SetCRT2ToTV)
4705 static void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
4706 struct xgi_hw_device_info *HwDeviceExtension,
4707 unsigned short RefreshRateTableIndex,
4708 struct vb_device_info *pVBInfo)
4710 unsigned short push1, push2, pushbx, tempax, tempbx, tempcx, temp,
4711 tempah, tempbh, tempch, resinfo, modeflag, CRT1Index;
4713 struct XGI_LCDDesStruct *LCDBDesPtr = NULL;
4715 /* si+Ext_ResInfo */
4716 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4717 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4718 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4719 CRT1Index &= IndexMask;
4721 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
4724 tempbx = pVBInfo->HDE; /* RHACTE=HDE-1 */
4726 if (XGI_IsLCDDualLink(pVBInfo))
4727 tempbx = tempbx >> 1;
4730 temp = tempbx & 0x00FF;
4731 xgifb_reg_set(pVBInfo->Part2Port, 0x2C, temp);
4732 temp = (tempbx & 0xFF00) >> 8;
4734 xgifb_reg_and_or(pVBInfo->Part2Port, 0x2B, 0x0F, temp);
4737 xgifb_reg_set(pVBInfo->Part2Port, 0x0B, temp);
4738 tempbx = pVBInfo->VDE; /* RTVACTEO=(VDE-1)&0xFF */
4741 temp = tempbx & 0x00FF;
4742 xgifb_reg_set(pVBInfo->Part2Port, 0x03, temp);
4743 temp = ((tempbx & 0xFF00) >> 8) & 0x07;
4744 xgifb_reg_and_or(pVBInfo->Part2Port, 0x0C, ~0x07, temp);
4746 tempcx = pVBInfo->VT - 1;
4748 temp = tempcx & 0x00FF; /* RVTVT=VT-1 */
4749 xgifb_reg_set(pVBInfo->Part2Port, 0x19, temp);
4750 temp = (tempcx & 0xFF00) >> 8;
4752 xgifb_reg_set(pVBInfo->Part2Port, 0x1A, temp);
4753 xgifb_reg_and_or(pVBInfo->Part2Port, 0x09, 0xF0, 0x00);
4754 xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xF0, 0x00);
4755 xgifb_reg_and_or(pVBInfo->Part2Port, 0x17, 0xFB, 0x00);
4756 xgifb_reg_and_or(pVBInfo->Part2Port, 0x18, 0xDF, 0x00);
4758 /* Customized LCDB Des no add */
4760 LCDBDesPtr = (struct XGI_LCDDesStruct *) XGI_GetLcdPtr(tempbx, ModeNo,
4761 ModeIdIndex, RefreshRateTableIndex, pVBInfo);
4762 tempah = pVBInfo->LCDResInfo;
4763 tempah &= PanelResInfo;
4765 if ((tempah == Panel_1024x768) || (tempah == Panel_1024x768x75)) {
4768 } else if ((tempah == Panel_1280x1024) ||
4769 (tempah == Panel_1280x1024x75)) {
4772 } else if (tempah == Panel_1400x1050) {
4780 if (pVBInfo->LCDInfo & EnableScalingLCD) {
4781 tempbx = pVBInfo->HDE;
4782 tempcx = pVBInfo->VDE;
4786 tempax = pVBInfo->VT;
4787 pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES;
4788 pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS;
4789 pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES;
4790 pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS;
4791 tempbx = pVBInfo->LCDVDES;
4794 if (tempcx >= tempax)
4795 tempcx -= tempax; /* lcdvdes */
4797 temp = tempbx & 0x00FF; /* RVEQ1EQ=lcdvdes */
4798 xgifb_reg_set(pVBInfo->Part2Port, 0x05, temp);
4799 temp = tempcx & 0x00FF;
4800 xgifb_reg_set(pVBInfo->Part2Port, 0x06, temp);
4801 tempch = ((tempcx & 0xFF00) >> 8) & 0x07;
4802 tempbh = ((tempbx & 0xFF00) >> 8) & 0x07;
4804 tempah = tempah << 3;
4806 xgifb_reg_set(pVBInfo->Part2Port, 0x02, tempah);
4809 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
4811 tempax = pVBInfo->VT;
4812 tempbx = pVBInfo->LCDVRS;
4815 if (tempcx >= tempax)
4818 temp = tempbx & 0x00FF; /* RTVACTEE=lcdvrs */
4819 xgifb_reg_set(pVBInfo->Part2Port, 0x04, temp);
4820 temp = (tempbx & 0xFF00) >> 8;
4822 temp |= (tempcx & 0x000F);
4823 xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp);
4825 tempax = pVBInfo->HT;
4826 tempbx = pVBInfo->LCDHDES;
4829 if (XGI_IsLCDDualLink(pVBInfo)) {
4830 tempax = tempax >> 1;
4831 tempbx = tempbx >> 1;
4832 tempcx = tempcx >> 1;
4835 if (pVBInfo->VBType & VB_SIS302LV)
4838 if (pVBInfo->VBType & VB_XGI301C) /* tap4 */
4843 if (tempcx >= tempax)
4846 temp = tempbx & 0x00FF;
4847 xgifb_reg_set(pVBInfo->Part2Port, 0x1F, temp); /* RHBLKE=lcdhdes */
4848 temp = ((tempbx & 0xFF00) >> 8) << 4;
4849 xgifb_reg_set(pVBInfo->Part2Port, 0x20, temp);
4850 temp = tempcx & 0x00FF;
4851 xgifb_reg_set(pVBInfo->Part2Port, 0x23, temp); /* RHEQPLE=lcdhdee */
4852 temp = (tempcx & 0xFF00) >> 8;
4853 xgifb_reg_set(pVBInfo->Part2Port, 0x25, temp);
4855 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
4857 tempax = pVBInfo->HT;
4858 tempbx = pVBInfo->LCDHRS;
4859 if (XGI_IsLCDDualLink(pVBInfo)) {
4860 tempax = tempax >> 1;
4861 tempbx = tempbx >> 1;
4862 tempcx = tempcx >> 1;
4865 if (pVBInfo->VBType & VB_SIS302LV)
4870 if (tempcx >= tempax)
4873 temp = tempbx & 0x00FF; /* RHBURSTS=lcdhrs */
4874 xgifb_reg_set(pVBInfo->Part2Port, 0x1C, temp);
4876 temp = (tempbx & 0xFF00) >> 8;
4878 xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F0, temp);
4879 temp = tempcx & 0x00FF; /* RHSYEXP2S=lcdhre */
4880 xgifb_reg_set(pVBInfo->Part2Port, 0x21, temp);
4882 if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
4883 if (pVBInfo->VGAVDE == 525) {
4884 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B
4885 | VB_SIS301LV | VB_SIS302LV
4891 xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp);
4892 xgifb_reg_set(pVBInfo->Part2Port, 0x30, 0xB3);
4895 if (pVBInfo->VGAVDE == 420) {
4896 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B
4897 | VB_SIS301LV | VB_SIS302LV
4902 xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp);
4907 /* --------------------------------------------------------------------- */
4908 /* Function : XGI_GetTap4Ptr */
4910 /* Output : di -> Tap4 Reg. Setting Pointer */
4912 /* --------------------------------------------------------------------- */
4913 static struct XGI301C_Tap4TimingStruct *XGI_GetTap4Ptr(unsigned short tempcx,
4914 struct vb_device_info *pVBInfo)
4916 unsigned short tempax, tempbx, i;
4918 struct XGI301C_Tap4TimingStruct *Tap4TimingPtr;
4921 tempax = pVBInfo->VGAHDE;
4922 tempbx = pVBInfo->HDE;
4924 tempax = pVBInfo->VGAVDE;
4925 tempbx = pVBInfo->VDE;
4928 if (tempax <= tempbx)
4929 return &xgifb_tap4_timing[0];
4931 Tap4TimingPtr = xgifb_ntsc_525_tap4_timing; /* NTSC */
4933 if (pVBInfo->TVInfo & TVSetPAL)
4934 Tap4TimingPtr = PALTap4Timing;
4936 if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
4937 if ((pVBInfo->TVInfo & TVSetYPbPr525i) ||
4938 (pVBInfo->TVInfo & TVSetYPbPr525p))
4939 Tap4TimingPtr = xgifb_ntsc_525_tap4_timing;
4940 if (pVBInfo->TVInfo & TVSetYPbPr750p)
4941 Tap4TimingPtr = YPbPr750pTap4Timing;
4944 if (pVBInfo->VBInfo & SetCRT2ToHiVision)
4945 Tap4TimingPtr = xgifb_tap4_timing;
4948 while (Tap4TimingPtr[i].DE != 0xFFFF) {
4949 if (Tap4TimingPtr[i].DE == tempax)
4953 return &Tap4TimingPtr[i];
4956 static void XGI_SetTap4Regs(struct vb_device_info *pVBInfo)
4958 unsigned short i, j;
4960 struct XGI301C_Tap4TimingStruct *Tap4TimingPtr;
4962 if (!(pVBInfo->VBType & VB_XGI301C))
4965 Tap4TimingPtr = XGI_GetTap4Ptr(0, pVBInfo); /* Set Horizontal Scaling */
4966 for (i = 0x80, j = 0; i <= 0xBF; i++, j++)
4967 xgifb_reg_set(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]);
4969 if ((pVBInfo->VBInfo & SetCRT2ToTV) &&
4970 (!(pVBInfo->VBInfo & SetCRT2ToHiVision))) {
4971 /* Set Vertical Scaling */
4972 Tap4TimingPtr = XGI_GetTap4Ptr(1, pVBInfo);
4973 for (i = 0xC0, j = 0; i < 0xFF; i++, j++)
4974 xgifb_reg_set(pVBInfo->Part2Port,
4976 Tap4TimingPtr->Reg[j]);
4979 if ((pVBInfo->VBInfo & SetCRT2ToTV) &&
4980 (!(pVBInfo->VBInfo & SetCRT2ToHiVision)))
4981 /* Enable V.Scaling */
4982 xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x04);
4984 /* Enable H.Scaling */
4985 xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x10);
4988 static void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex,
4989 struct vb_device_info *pVBInfo)
4992 unsigned char *tempdi;
4993 unsigned short modeflag;
4995 /* si+Ext_ResInfo */
4996 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4998 xgifb_reg_set(pVBInfo->Part3Port, 0x00, 0x00);
4999 if (pVBInfo->TVInfo & TVSetPAL) {
5000 xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA);
5001 xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8);
5003 xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xF5);
5004 xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xB7);
5007 if (!(pVBInfo->VBInfo & SetCRT2ToTV))
5010 if (pVBInfo->TVInfo & TVSetPALM) {
5011 xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA);
5012 xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8);
5013 xgifb_reg_set(pVBInfo->Part3Port, 0x3D, 0xA8);
5016 if ((pVBInfo->VBInfo & SetCRT2ToHiVision) || (pVBInfo->VBInfo
5017 & SetCRT2ToYPbPr525750)) {
5018 if (pVBInfo->TVInfo & TVSetYPbPr525i)
5021 tempdi = pVBInfo->HiTVGroup3Data;
5022 if (pVBInfo->SetFlag & TVSimuMode) {
5023 tempdi = pVBInfo->HiTVGroup3Simu;
5024 if (!(modeflag & Charx8Dot))
5025 tempdi = pVBInfo->HiTVGroup3Text;
5028 if (pVBInfo->TVInfo & TVSetYPbPr525p)
5029 tempdi = pVBInfo->Ren525pGroup3;
5031 if (pVBInfo->TVInfo & TVSetYPbPr750p)
5032 tempdi = pVBInfo->Ren750pGroup3;
5034 for (i = 0; i <= 0x3E; i++)
5035 xgifb_reg_set(pVBInfo->Part3Port, i, tempdi[i]);
5037 if (pVBInfo->VBType & VB_XGI301C) { /* Marcovision */
5038 if (pVBInfo->TVInfo & TVSetYPbPr525p)
5039 xgifb_reg_set(pVBInfo->Part3Port, 0x28, 0x3f);
5043 } /* {end of XGI_SetGroup3} */
5045 static void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex,
5046 unsigned short RefreshRateTableIndex,
5047 struct xgi_hw_device_info *HwDeviceExtension,
5048 struct vb_device_info *pVBInfo)
5050 unsigned short tempax, tempcx, tempbx, modeflag, temp, temp2;
5052 unsigned long tempebx, tempeax, templong;
5054 /* si+Ext_ResInfo */
5055 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
5056 temp = pVBInfo->RVBHCFACT;
5057 xgifb_reg_set(pVBInfo->Part4Port, 0x13, temp);
5059 tempbx = pVBInfo->RVBHCMAX;
5060 temp = tempbx & 0x00FF;
5061 xgifb_reg_set(pVBInfo->Part4Port, 0x14, temp);
5062 temp2 = ((tempbx & 0xFF00) >> 8) << 7;
5063 tempcx = pVBInfo->VGAHT - 1;
5064 temp = tempcx & 0x00FF;
5065 xgifb_reg_set(pVBInfo->Part4Port, 0x16, temp);
5067 temp = ((tempcx & 0xFF00) >> 8) << 3;
5070 tempcx = pVBInfo->VGAVT - 1;
5071 if (!(pVBInfo->VBInfo & SetCRT2ToTV))
5074 temp = tempcx & 0x00FF;
5075 xgifb_reg_set(pVBInfo->Part4Port, 0x17, temp);
5076 temp = temp2 | ((tempcx & 0xFF00) >> 8);
5077 xgifb_reg_set(pVBInfo->Part4Port, 0x15, temp);
5078 xgifb_reg_or(pVBInfo->Part4Port, 0x0D, 0x08);
5079 tempcx = pVBInfo->VBInfo;
5080 tempbx = pVBInfo->VGAHDE;
5082 if (modeflag & HalfDCLK)
5083 tempbx = tempbx >> 1;
5085 if (XGI_IsLCDDualLink(pVBInfo))
5086 tempbx = tempbx >> 1;
5088 if (tempcx & SetCRT2ToHiVision) {
5094 } else if (tempcx & SetCRT2ToTV) {
5100 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
5107 if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p)) {
5109 if (pVBInfo->VGAHDE == 1280)
5111 if (pVBInfo->VGAHDE == 1024)
5114 xgifb_reg_and_or(pVBInfo->Part4Port, 0x0E, ~0xEF, temp);
5116 tempebx = pVBInfo->VDE;
5118 if (tempcx & SetCRT2ToHiVision) {
5119 if (!(temp & 0xE000))
5120 tempbx = tempbx >> 1;
5123 tempcx = pVBInfo->RVBHRS;
5124 temp = tempcx & 0x00FF;
5125 xgifb_reg_set(pVBInfo->Part4Port, 0x18, temp);
5127 tempeax = pVBInfo->VGAVDE;
5130 if (tempeax <= tempebx) {
5131 tempcx = (tempcx & (~0x4000));
5132 tempeax = pVBInfo->VGAVDE;
5137 templong = (tempeax * 256 * 1024) % tempebx;
5138 tempeax = (tempeax * 256 * 1024) / tempebx;
5144 temp = (unsigned short) (tempebx & 0x000000FF);
5145 xgifb_reg_set(pVBInfo->Part4Port, 0x1B, temp);
5147 temp = (unsigned short) ((tempebx & 0x0000FF00) >> 8);
5148 xgifb_reg_set(pVBInfo->Part4Port, 0x1A, temp);
5149 tempbx = (unsigned short) (tempebx >> 16);
5150 temp = tempbx & 0x00FF;
5152 temp |= ((tempcx & 0xFF00) >> 8);
5153 xgifb_reg_set(pVBInfo->Part4Port, 0x19, temp);
5156 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
5157 | VB_SIS302LV | VB_XGI301C)) {
5159 xgifb_reg_set(pVBInfo->Part4Port, 0x1C, temp);
5160 tempax = pVBInfo->VGAHDE;
5161 if (modeflag & HalfDCLK)
5162 tempax = tempax >> 1;
5164 if (XGI_IsLCDDualLink(pVBInfo))
5165 tempax = tempax >> 1;
5167 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
5171 if (pVBInfo->VGAHDE > 800) {
5172 if (pVBInfo->VGAHDE == 1024)
5173 tempax = (tempax * 25 / 32) - 1;
5175 tempax = (tempax * 20 / 32) - 1;
5180 temp = (tempax & 0xFF00) >> 8;
5181 temp = ((temp & 0x0003) << 4);
5182 xgifb_reg_set(pVBInfo->Part4Port, 0x1E, temp);
5183 temp = (tempax & 0x00FF);
5184 xgifb_reg_set(pVBInfo->Part4Port, 0x1D, temp);
5186 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVision)) {
5187 if (pVBInfo->VGAHDE > 800)
5188 xgifb_reg_or(pVBInfo->Part4Port, 0x1E, 0x08);
5193 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5194 if (!(pVBInfo->TVInfo & (NTSC1024x768
5195 | TVSetYPbPr525p | TVSetYPbPr750p
5196 | TVSetHiVision))) {
5198 if ((pVBInfo->VBInfo & SetInSlaveMode)
5199 && (!(pVBInfo->TVInfo
5205 xgifb_reg_and_or(pVBInfo->Part4Port, 0x1F, 0x00C0, temp);
5206 tempbx = pVBInfo->HT;
5207 if (XGI_IsLCDDualLink(pVBInfo))
5208 tempbx = tempbx >> 1;
5209 tempbx = (tempbx >> 1) - 2;
5210 temp = ((tempbx & 0x0700) >> 8) << 3;
5211 xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, 0x00C0, temp);
5212 temp = tempbx & 0x00FF;
5213 xgifb_reg_set(pVBInfo->Part4Port, 0x22, temp);
5217 if (pVBInfo->ISXPDOS == 0)
5218 XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex,
5222 static void XGINew_EnableCRT2(struct vb_device_info *pVBInfo)
5224 xgifb_reg_and_or(pVBInfo->P3c4, 0x1E, 0xFF, 0x20);
5227 static void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex,
5228 struct vb_device_info *pVBInfo)
5230 unsigned short Pindex, Pdata;
5232 Pindex = pVBInfo->Part5Port;
5233 Pdata = pVBInfo->Part5Port + 1;
5234 if (pVBInfo->ModeType == ModeVGA) {
5235 if (!(pVBInfo->VBInfo & (SetInSlaveMode | LoadDACFlag
5236 | DisableCRT2Display))) {
5237 XGINew_EnableCRT2(pVBInfo);
5243 static void XGI_EnableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension,
5244 struct vb_device_info *pVBInfo)
5246 xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x40);
5249 static void XGI_DisableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension,
5250 struct vb_device_info *pVBInfo)
5253 xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x00);
5256 static unsigned char XGI_XG21CheckLVDSMode(struct xgifb_video_info *xgifb_info,
5257 unsigned short ModeNo, unsigned short ModeIdIndex,
5258 struct vb_device_info *pVBInfo)
5260 unsigned short xres, yres, colordepth, modeflag, resindex;
5262 resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
5263 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
5264 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
5265 /* si+St_ModeFlag */
5266 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
5268 if (!(modeflag & Charx8Dot)) {
5273 if ((ModeNo > 0x13) && (modeflag & HalfDCLK))
5276 if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
5279 if (xres > xgifb_info->lvds_data.LVDSHDE)
5282 if (yres > xgifb_info->lvds_data.LVDSVDE)
5285 if (xres != xgifb_info->lvds_data.LVDSHDE ||
5286 yres != xgifb_info->lvds_data.LVDSVDE) {
5287 colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo);
5294 static void xgifb_set_lvds(struct xgifb_video_info *xgifb_info,
5296 unsigned short ModeNo,
5297 unsigned short ModeIdIndex,
5298 struct vb_device_info *pVBInfo)
5300 unsigned char temp, Miscdata;
5301 unsigned short xres, yres, modeflag, resindex;
5302 unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE;
5303 unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE;
5304 unsigned short value;
5306 temp = (unsigned char) ((xgifb_info->lvds_data.LVDS_Capability &
5307 (LCDPolarity << 8)) >> 8);
5308 temp &= LCDPolarity;
5309 Miscdata = (unsigned char) inb(pVBInfo->P3cc);
5311 outb((Miscdata & 0x3F) | temp, pVBInfo->P3c2);
5313 temp = xgifb_info->lvds_data.LVDS_Capability & LCDPolarity;
5314 /* SR35[7] FP VSync polarity */
5315 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80);
5316 /* SR30[5] FP HSync polarity */
5317 xgifb_reg_and_or(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1);
5319 if (chip_id == XG27)
5320 XGI_SetXG27FPBits(pVBInfo);
5322 XGI_SetXG21FPBits(pVBInfo);
5324 resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
5325 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
5326 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
5327 /* si+St_ModeFlag */
5328 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
5330 if (!(modeflag & Charx8Dot))
5331 xres = xres * 8 / 9;
5333 LVDSHT = xgifb_info->lvds_data.LVDSHT;
5335 LVDSHBS = xres + (xgifb_info->lvds_data.LVDSHDE - xres) / 2;
5337 if (LVDSHBS > LVDSHT)
5340 LVDSHRS = LVDSHBS + xgifb_info->lvds_data.LVDSHFP;
5341 if (LVDSHRS > LVDSHT)
5344 LVDSHRE = LVDSHRS + xgifb_info->lvds_data.LVDSHSYNC;
5345 if (LVDSHRE > LVDSHT)
5348 LVDSHBE = LVDSHBS + LVDSHT - xgifb_info->lvds_data.LVDSHDE;
5350 LVDSVT = xgifb_info->lvds_data.LVDSVT;
5352 LVDSVBS = yres + (xgifb_info->lvds_data.LVDSVDE - yres) / 2;
5353 if (modeflag & DoubleScanMode)
5354 LVDSVBS += yres / 2;
5356 if (LVDSVBS > LVDSVT)
5359 LVDSVRS = LVDSVBS + xgifb_info->lvds_data.LVDSVFP;
5360 if (LVDSVRS > LVDSVT)
5363 LVDSVRE = LVDSVRS + xgifb_info->lvds_data.LVDSVSYNC;
5364 if (LVDSVRE > LVDSVT)
5367 LVDSVBE = LVDSVBS + LVDSVT - xgifb_info->lvds_data.LVDSVDE;
5369 temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
5370 xgifb_reg_set(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */
5372 if (!(modeflag & Charx8Dot))
5373 xgifb_reg_or(pVBInfo->P3c4, 0x1, 0x1);
5375 /* HT SR0B[1:0] CR00 */
5376 value = (LVDSHT >> 3) - 5;
5377 xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8);
5378 xgifb_reg_set(pVBInfo->P3d4, 0x0, (value & 0xFF));
5380 /* HBS SR0B[5:4] CR02 */
5381 value = (LVDSHBS >> 3) - 1;
5382 xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4);
5383 xgifb_reg_set(pVBInfo->P3d4, 0x2, (value & 0xFF));
5385 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
5386 value = (LVDSHBE >> 3) - 1;
5387 xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6);
5388 xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2);
5389 xgifb_reg_and_or(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F);
5391 /* HRS SR0B[7:6] CR04 */
5392 value = (LVDSHRS >> 3) + 2;
5393 xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2);
5394 xgifb_reg_set(pVBInfo->P3d4, 0x4, (value & 0xFF));
5396 /* Panel HRS SR2F[1:0] SR2E[7:0] */
5398 xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8);
5399 xgifb_reg_set(pVBInfo->P3c4, 0x2E, (value & 0xFF));
5401 /* HRE SR0C[2] CR05[4:0] */
5402 value = (LVDSHRE >> 3) + 2;
5403 xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3);
5404 xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F);
5406 /* Panel HRE SR2F[7:2] */
5408 xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2);
5410 /* VT SR0A[0] CR07[5][0] CR06 */
5412 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10);
5413 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4);
5414 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8);
5415 xgifb_reg_set(pVBInfo->P3d4, 0x06, (value & 0xFF));
5417 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
5418 value = LVDSVBS - 1;
5419 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8);
5420 xgifb_reg_and_or(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4);
5421 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5);
5422 xgifb_reg_set(pVBInfo->P3d4, 0x15, (value & 0xFF));
5424 /* VBE SR0A[4] CR16 */
5425 value = LVDSVBE - 1;
5426 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4);
5427 xgifb_reg_set(pVBInfo->P3d4, 0x16, (value & 0xFF));
5429 /* VRS SR0A[3] CR7[7][2] CR10 */
5430 value = LVDSVRS - 1;
5431 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7);
5432 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2);
5433 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6);
5434 xgifb_reg_set(pVBInfo->P3d4, 0x10, (value & 0xFF));
5436 if (chip_id == XG27) {
5437 /* Panel VRS SR35[2:0] SR34[7:0] */
5438 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07,
5439 (value & 0x700) >> 8);
5440 xgifb_reg_set(pVBInfo->P3c4, 0x34, value & 0xFF);
5442 /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */
5443 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0x03,
5444 (value & 0x600) >> 9);
5445 xgifb_reg_set(pVBInfo->P3c4, 0x34, (value >> 1) & 0xFF);
5446 xgifb_reg_and_or(pVBInfo->P3d4, 0x33, ~0x01, value & 0x01);
5449 /* VRE SR0A[5] CR11[3:0] */
5450 value = LVDSVRE - 1;
5451 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1);
5452 xgifb_reg_and_or(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F);
5454 /* Panel VRE SR3F[7:2] */
5455 if (chip_id == XG27)
5456 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC,
5457 (value << 2) & 0xFC);
5459 /* SR3F[7] has to be 0, h/w bug */
5460 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC,
5461 (value << 2) & 0x7C);
5463 for (temp = 0, value = 0; temp < 3; temp++) {
5465 xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, value);
5466 xgifb_reg_set(pVBInfo->P3c4,
5467 0x2B, xgifb_info->lvds_data.VCLKData1);
5468 xgifb_reg_set(pVBInfo->P3c4,
5469 0x2C, xgifb_info->lvds_data.VCLKData2);
5473 if (!(modeflag & Charx8Dot)) {
5474 inb(pVBInfo->P3da); /* reset 3da */
5475 outb(0x13, pVBInfo->P3c0); /* set index */
5476 /* set data, panning = 0, shift left 1 dot*/
5477 outb(0x00, pVBInfo->P3c0);
5479 inb(pVBInfo->P3da); /* Enable Attribute */
5480 outb(0x20, pVBInfo->P3c0);
5482 inb(pVBInfo->P3da); /* reset 3da */
5487 /* --------------------------------------------------------------------- */
5488 /* Function : XGI_IsLCDON */
5490 /* Output : 0 : Skip PSC Control */
5491 /* 1: Disable PSC */
5493 /* --------------------------------------------------------------------- */
5494 static unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo)
5496 unsigned short tempax;
5498 tempax = pVBInfo->VBInfo;
5499 if (tempax & SetCRT2ToDualEdge)
5501 else if (tempax & (DisableCRT2Display | SwitchCRT2 | SetSimuScanMode))
5507 /* --------------------------------------------------------------------- */
5508 /* Function : XGI_DisableChISLCD */
5510 /* Output : 0 -> Not LCD Mode */
5512 /* --------------------------------------------------------------------- */
5513 static unsigned char XGI_DisableChISLCD(struct vb_device_info *pVBInfo)
5515 unsigned short tempbx, tempah;
5517 tempbx = pVBInfo->SetFlag & (DisableChA | DisableChB);
5518 tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E));
5520 if (tempbx & (EnableChA | DisableChA)) {
5521 if (!(tempah & 0x08)) /* Chk LCDA Mode */
5525 if (!(tempbx & (EnableChB | DisableChB)))
5528 if (tempah & 0x01) /* Chk LCDB Mode */
5534 /* --------------------------------------------------------------------- */
5535 /* Function : XGI_EnableChISLCD */
5537 /* Output : 0 -> Not LCD mode */
5539 /* --------------------------------------------------------------------- */
5540 static unsigned char XGI_EnableChISLCD(struct vb_device_info *pVBInfo)
5542 unsigned short tempbx, tempah;
5544 tempbx = pVBInfo->SetFlag & (EnableChA | EnableChB);
5545 tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E));
5547 if (tempbx & (EnableChA | DisableChA)) {
5548 if (!(tempah & 0x08)) /* Chk LCDA Mode */
5552 if (!(tempbx & (EnableChB | DisableChB)))
5555 if (tempah & 0x01) /* Chk LCDB Mode */
5561 static void XGI_DisableBridge(struct xgifb_video_info *xgifb_info,
5562 struct xgi_hw_device_info *HwDeviceExtension,
5563 struct vb_device_info *pVBInfo)
5565 unsigned short tempah = 0;
5567 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
5568 | VB_SIS302LV | VB_XGI301C)) {
5570 if (!(pVBInfo->VBInfo &
5571 (DisableCRT2Display | SetSimuScanMode))) {
5572 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
5573 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
5574 tempah = 0x7F; /* Disable Channel A */
5575 if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA))
5576 /* Disable Channel B */
5579 if (pVBInfo->SetFlag & DisableChB)
5580 /* force to disable Cahnnel */
5583 if (pVBInfo->SetFlag & DisableChA)
5584 /* Force to disable Channel B */
5590 /* disable part4_1f */
5591 xgifb_reg_and(pVBInfo->Part4Port, 0x1F, tempah);
5593 if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) {
5594 if (((pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)))
5595 || (XGI_DisableChISLCD(pVBInfo))
5596 || (XGI_IsLCDON(pVBInfo)))
5597 /* LVDS Driver power down */
5598 xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x80);
5601 if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo
5602 & (DisableCRT2Display | XGI_SetCRT2ToLCDA
5603 | SetSimuScanMode))) {
5604 if (pVBInfo->SetFlag & GatingCRT)
5605 XGI_EnableGatingCRT(HwDeviceExtension, pVBInfo);
5606 XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo);
5609 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
5610 if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo
5611 & XGI_SetCRT2ToLCDA))
5613 xgifb_reg_and(pVBInfo->Part1Port, 0x1e, 0xdf);
5616 /* disable TV as primary VGA swap */
5617 xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xdf);
5619 if ((pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToDualEdge)))
5620 xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xdf);
5622 if ((pVBInfo->SetFlag & DisableChB) ||
5624 (DisableCRT2Display | SetSimuScanMode)) ||
5625 ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) &&
5627 (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV))))
5628 xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80);
5630 if ((pVBInfo->SetFlag & DisableChB) ||
5632 (DisableCRT2Display | SetSimuScanMode)) ||
5633 (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) ||
5635 (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV))) {
5636 /* save Part1 index 0 */
5637 tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00);
5638 /* BTDAC = 1, avoid VB reset */
5639 xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x10);
5641 xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF);
5642 /* restore Part1 index 0 */
5643 xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah);
5645 } else { /* {301} */
5646 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) {
5647 xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80);
5649 xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF);
5650 /* Disable TV asPrimary VGA swap */
5651 xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xDF);
5654 if (pVBInfo->VBInfo & (DisableCRT2Display | XGI_SetCRT2ToLCDA
5656 XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo);
5660 /* --------------------------------------------------------------------- */
5661 /* Function : XGI_GetTVPtrIndex */
5664 /* Description : bx 0 : ExtNTSC */
5676 /* --------------------------------------------------------------------- */
5677 static unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo)
5679 unsigned short tempbx = 0;
5681 if (pVBInfo->TVInfo & TVSetPAL)
5683 if (pVBInfo->TVInfo & TVSetHiVision)
5685 if (pVBInfo->TVInfo & TVSetYPbPr525i)
5687 if (pVBInfo->TVInfo & TVSetYPbPr525p)
5689 if (pVBInfo->TVInfo & TVSetYPbPr750p)
5691 if (pVBInfo->TVInfo & TVSimuMode)
5697 /* --------------------------------------------------------------------- */
5698 /* Function : XGI_GetTVPtrIndex2 */
5700 /* Output : bx 0 : NTSC */
5704 /* 4 : NTSC1024x768 */
5705 /* 5 : PAL-M 1024x768 */
5707 /* cl 0 : YFilter1 */
5710 /* 1 : 301B/302B/301LV/302LV */
5712 /* --------------------------------------------------------------------- */
5713 static void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char *tempcl,
5714 unsigned char *tempch, struct vb_device_info *pVBInfo)
5720 if (pVBInfo->TVInfo & TVSetPAL)
5723 if (pVBInfo->TVInfo & TVSetPALM)
5726 if (pVBInfo->TVInfo & TVSetPALN)
5729 if (pVBInfo->TVInfo & NTSC1024x768) {
5731 if (pVBInfo->TVInfo & TVSetPALM)
5735 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
5736 | VB_SIS302LV | VB_XGI301C)) {
5737 if ((!(pVBInfo->VBInfo & SetInSlaveMode)) || (pVBInfo->TVInfo
5744 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
5745 | VB_SIS302LV | VB_XGI301C))
5749 static void XGI_SetDelayComp(struct vb_device_info *pVBInfo)
5751 unsigned short index;
5753 unsigned char tempah, tempbl, tempbh;
5755 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
5756 | VB_SIS302LV | VB_XGI301C)) {
5757 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA
5758 | SetCRT2ToTV | SetCRT2ToRAMDAC)) {
5762 index = XGI_GetTVPtrIndex(pVBInfo); /* Get TV Delay */
5763 tempbl = pVBInfo->XGI_TVDelayList[index];
5765 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B
5766 | VB_SIS301LV | VB_SIS302LV
5768 tempbl = pVBInfo->XGI_TVDelayList2[index];
5770 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
5771 tempbl = tempbl >> 4;
5772 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
5774 index = XGI_GetLCDCapPtr(pVBInfo);
5775 tempbh = pVBInfo->LCDCapList[index].
5776 LCD_DelayCompensation;
5778 if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA))
5784 tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x2D);
5786 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD
5787 | SetCRT2ToTV)) { /* Channel B */
5792 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { /* Channel A */
5796 xgifb_reg_set(pVBInfo->Part1Port, 0x2D, tempah);
5798 } else if (pVBInfo->IF_DEF_LVDS == 1) {
5801 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
5802 /* / Get LCD Delay */
5803 tempah = pVBInfo->LCDCapList[
5804 XGI_GetLCDCapPtr(pVBInfo)].
5805 LCD_DelayCompensation;
5807 tempah = tempah << 4;
5808 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2D, 0x0f,
5814 static void XGI_SetLCDCap_A(unsigned short tempcx,
5815 struct vb_device_info *pVBInfo)
5817 unsigned short temp;
5819 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
5821 if (temp & LCDRGB18Bit) {
5822 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F,
5824 (unsigned short) (0x20 | (tempcx & 0x00C0)));
5825 xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80);
5827 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F,
5828 (unsigned short) (0x30 | (tempcx & 0x00C0)));
5829 xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00);
5833 /* --------------------------------------------------------------------- */
5834 /* Function : XGI_SetLCDCap_B */
5835 /* Input : cx -> LCD Capability */
5838 /* --------------------------------------------------------------------- */
5839 static void XGI_SetLCDCap_B(unsigned short tempcx,
5840 struct vb_device_info *pVBInfo)
5842 if (tempcx & EnableLCD24bpp) /* 24bits */
5843 xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0,
5844 (unsigned short) (((tempcx & 0x00ff) >> 6)
5847 xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0,
5848 (unsigned short) (((tempcx & 0x00ff) >> 6)
5849 | 0x18)); /* Enable Dither */
5852 static void XGI_LongWait(struct vb_device_info *pVBInfo)
5856 i = xgifb_reg_get(pVBInfo->P3c4, 0x1F);
5859 for (i = 0; i < 0xFFFF; i++) {
5860 if (!(inb(pVBInfo->P3da) & 0x08))
5864 for (i = 0; i < 0xFFFF; i++) {
5865 if ((inb(pVBInfo->P3da) & 0x08))
5871 static void SetSpectrum(struct vb_device_info *pVBInfo)
5873 unsigned short index;
5875 index = XGI_GetLCDCapPtr(pVBInfo);
5877 /* disable down spectrum D[4] */
5878 xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x8F);
5879 XGI_LongWait(pVBInfo);
5880 xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x20); /* reset spectrum */
5881 XGI_LongWait(pVBInfo);
5883 xgifb_reg_set(pVBInfo->Part4Port, 0x31,
5884 pVBInfo->LCDCapList[index].Spectrum_31);
5885 xgifb_reg_set(pVBInfo->Part4Port, 0x32,
5886 pVBInfo->LCDCapList[index].Spectrum_32);
5887 xgifb_reg_set(pVBInfo->Part4Port, 0x33,
5888 pVBInfo->LCDCapList[index].Spectrum_33);
5889 xgifb_reg_set(pVBInfo->Part4Port, 0x34,
5890 pVBInfo->LCDCapList[index].Spectrum_34);
5891 XGI_LongWait(pVBInfo);
5892 xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x40); /* enable spectrum */
5895 static void XGI_SetLCDCap(struct vb_device_info *pVBInfo)
5897 unsigned short tempcx;
5899 tempcx = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(pVBInfo)].LCD_Capability;
5901 if (pVBInfo->VBType &
5906 VB_XGI301C)) { /* 301LV/302LV only */
5907 if (pVBInfo->VBType &
5908 (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) {
5909 /* Set 301LV Capability */
5910 xgifb_reg_set(pVBInfo->Part4Port, 0x24,
5911 (unsigned char) (tempcx & 0x1F));
5914 xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D,
5915 ~((EnableVBCLKDRVLOW | EnablePLLSPLOW) >> 8),
5916 (unsigned short) ((tempcx & (EnableVBCLKDRVLOW
5917 | EnablePLLSPLOW)) >> 8));
5920 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
5921 | VB_SIS302LV | VB_XGI301C)) {
5922 if (pVBInfo->VBInfo & SetCRT2ToLCD)
5923 XGI_SetLCDCap_B(tempcx, pVBInfo);
5924 else if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)
5925 XGI_SetLCDCap_A(tempcx, pVBInfo);
5927 if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) {
5928 if (tempcx & EnableSpectrum)
5929 SetSpectrum(pVBInfo);
5933 XGI_SetLCDCap_A(tempcx, pVBInfo);
5937 /* --------------------------------------------------------------------- */
5938 /* Function : XGI_SetAntiFlicker */
5941 /* Description : Set TV Customized Param. */
5942 /* --------------------------------------------------------------------- */
5943 static void XGI_SetAntiFlicker(unsigned short ModeNo,
5944 unsigned short ModeIdIndex,
5945 struct vb_device_info *pVBInfo)
5947 unsigned short tempbx;
5949 unsigned char tempah;
5951 if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p))
5954 tempbx = XGI_GetTVPtrIndex(pVBInfo);
5956 tempah = TVAntiFlickList[tempbx];
5957 tempah = tempah << 4;
5959 xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0x8F, tempah);
5962 static void XGI_SetEdgeEnhance(unsigned short ModeNo,
5963 unsigned short ModeIdIndex,
5964 struct vb_device_info *pVBInfo)
5966 unsigned short tempbx;
5968 unsigned char tempah;
5970 tempbx = XGI_GetTVPtrIndex(pVBInfo);
5972 tempah = TVEdgeList[tempbx];
5973 tempah = tempah << 5;
5975 xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, tempah);
5978 static void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo)
5980 unsigned short tempbx;
5982 unsigned char tempcl, tempch;
5984 unsigned long tempData;
5986 XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */
5987 tempData = TVPhaseList[tempbx];
5989 xgifb_reg_set(pVBInfo->Part2Port, 0x31, (unsigned short) (tempData
5991 xgifb_reg_set(pVBInfo->Part2Port, 0x32, (unsigned short) ((tempData
5992 & 0x0000FF00) >> 8));
5993 xgifb_reg_set(pVBInfo->Part2Port, 0x33, (unsigned short) ((tempData
5994 & 0x00FF0000) >> 16));
5995 xgifb_reg_set(pVBInfo->Part2Port, 0x34, (unsigned short) ((tempData
5996 & 0xFF000000) >> 24));
5999 static void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex,
6000 struct vb_device_info *pVBInfo)
6002 unsigned short tempbx, index;
6004 unsigned char tempcl, tempch, tempal, *filterPtr;
6006 XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */
6011 filterPtr = NTSCYFilter1;
6015 filterPtr = PALYFilter1;
6022 filterPtr = xgifb_palmn_yfilter1;
6030 filterPtr = xgifb_yfilter2;
6037 tempal = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVYFilterIndex;
6043 if ((tempcl == 0) && (tempch == 1)) {
6044 xgifb_reg_set(pVBInfo->Part2Port, 0x35, 0);
6045 xgifb_reg_set(pVBInfo->Part2Port, 0x36, 0);
6046 xgifb_reg_set(pVBInfo->Part2Port, 0x37, 0);
6047 xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]);
6049 xgifb_reg_set(pVBInfo->Part2Port, 0x35, filterPtr[index++]);
6050 xgifb_reg_set(pVBInfo->Part2Port, 0x36, filterPtr[index++]);
6051 xgifb_reg_set(pVBInfo->Part2Port, 0x37, filterPtr[index++]);
6052 xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]);
6055 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
6056 | VB_SIS302LV | VB_XGI301C)) {
6057 xgifb_reg_set(pVBInfo->Part2Port, 0x48, filterPtr[index++]);
6058 xgifb_reg_set(pVBInfo->Part2Port, 0x49, filterPtr[index++]);
6059 xgifb_reg_set(pVBInfo->Part2Port, 0x4A, filterPtr[index++]);
6063 /* --------------------------------------------------------------------- */
6064 /* Function : XGI_OEM310Setting */
6067 /* Description : Customized Param. for 301 */
6068 /* --------------------------------------------------------------------- */
6069 static void XGI_OEM310Setting(unsigned short ModeNo,
6070 unsigned short ModeIdIndex,
6071 struct vb_device_info *pVBInfo)
6073 XGI_SetDelayComp(pVBInfo);
6075 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))
6076 XGI_SetLCDCap(pVBInfo);
6078 if (pVBInfo->VBInfo & SetCRT2ToTV) {
6079 XGI_SetPhaseIncr(pVBInfo);
6080 XGI_SetYFilter(ModeNo, ModeIdIndex, pVBInfo);
6081 XGI_SetAntiFlicker(ModeNo, ModeIdIndex, pVBInfo);
6083 if (pVBInfo->VBType & VB_SIS301)
6084 XGI_SetEdgeEnhance(ModeNo, ModeIdIndex, pVBInfo);
6088 /* --------------------------------------------------------------------- */
6089 /* Function : XGI_SetCRT2ModeRegs */
6092 /* Description : Origin code for crt2group */
6093 /* --------------------------------------------------------------------- */
6094 static void XGI_SetCRT2ModeRegs(unsigned short ModeNo,
6095 struct xgi_hw_device_info *HwDeviceExtension,
6096 struct vb_device_info *pVBInfo)
6098 unsigned short tempbl;
6101 unsigned char tempah;
6104 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
6105 tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00);
6106 tempah &= ~0x10; /* BTRAMDAC */
6107 tempah |= 0x40; /* BTRAM */
6109 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV
6111 tempah = 0x40; /* BTDRAM */
6112 tempcl = pVBInfo->ModeType;
6116 tempah = (0x008 >> tempcl);
6121 if (pVBInfo->VBInfo & SetInSlaveMode)
6122 tempah ^= 0x50; /* BTDAC */
6126 xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah);
6130 if (pVBInfo->VBInfo & DisableCRT2Display) {
6131 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl, tempah);
6136 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV
6137 | SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
6138 if ((pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) &&
6139 (!(pVBInfo->VBInfo & SetSimuScanMode))) {
6142 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e,
6145 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
6150 if (pVBInfo->VBInfo &
6157 if (!(pVBInfo->VBInfo & SetInSlaveMode))
6160 if (!(pVBInfo->VBInfo &
6162 tempah = tempah ^ 0x05;
6163 if (!(pVBInfo->VBInfo &
6165 tempah = tempah ^ 0x01;
6168 if (!(pVBInfo->VBInfo &
6171 xgifb_reg_and_or(pVBInfo->Part1Port,
6172 0x2e, tempbl, tempah);
6174 xgifb_reg_and_or(pVBInfo->Part1Port,
6175 0x2e, tempbl, tempah);
6179 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl,
6184 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD
6185 | XGI_SetCRT2ToLCDA)) {
6187 if ((pVBInfo->ModeType == ModeVGA) && (!(pVBInfo->VBInfo
6188 & SetInSlaveMode))) {
6193 if (pVBInfo->VBInfo & SetCRT2ToTV) {
6195 if (pVBInfo->VBInfo & DriverMode)
6196 tempah = tempah ^ 0x20;
6199 xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D, ~0x0BF, tempah);
6202 if (pVBInfo->LCDInfo & SetLCDDualLink)
6205 if (pVBInfo->VBInfo & SetCRT2ToTV) {
6206 if (pVBInfo->TVInfo & RPLLDIV2XO)
6210 if ((pVBInfo->LCDResInfo == Panel_1280x1024)
6211 || (pVBInfo->LCDResInfo == Panel_1280x1024x75))
6214 if (pVBInfo->LCDResInfo == Panel_1280x960)
6217 xgifb_reg_set(pVBInfo->Part4Port, 0x0C, tempah);
6220 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
6221 | VB_SIS302LV | VB_XGI301C)) {
6225 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
6227 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)
6228 tempah |= 0x04; /* shampoo 0129 */
6231 xgifb_reg_and_or(pVBInfo->Part1Port, 0x13, tempbl, tempah);
6234 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
6235 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
6239 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2c, tempbl, tempah);
6243 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
6244 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
6247 xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, tempbl, tempah);
6252 if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) {
6254 if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge))
6258 xgifb_reg_and_or(pVBInfo->Part4Port, 0x23, tempbl, tempah);
6260 if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) {
6261 if (pVBInfo->LCDInfo & SetLCDDualLink) {
6262 xgifb_reg_or(pVBInfo->Part4Port, 0x27, 0x20);
6263 xgifb_reg_or(pVBInfo->Part4Port, 0x34, 0x10);
6268 static void XGI_CloseCRTC(struct xgi_hw_device_info *HwDeviceExtension,
6269 struct vb_device_info *pVBInfo)
6271 unsigned short tempbx;
6275 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)
6280 void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension,
6281 struct vb_device_info *pVBInfo)
6284 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2f, 0xFF, 0x01);
6288 void XGI_LockCRT2(struct xgi_hw_device_info *HwDeviceExtension,
6289 struct vb_device_info *pVBInfo)
6292 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2F, 0xFE, 0x00);
6296 unsigned char XGI_BridgeIsOn(struct vb_device_info *pVBInfo)
6298 unsigned short flag;
6300 if (pVBInfo->IF_DEF_LVDS == 1) {
6303 flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00);
6304 if ((flag == 1) || (flag == 2))
6305 return 1; /* 301b */
6311 unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE,
6312 unsigned short ModeNo, unsigned short ModeIdIndex,
6313 struct vb_device_info *pVBInfo)
6315 short LCDRefreshIndex[] = { 0x00, 0x00, 0x03, 0x01 },
6316 LCDARefreshIndex[] = { 0x00, 0x00, 0x03, 0x01, 0x01,
6319 unsigned short RefreshRateTableIndex, i, modeflag, index, temp;
6321 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
6323 index = xgifb_reg_get(pVBInfo->P3d4, 0x33);
6324 index = index >> pVBInfo->SelectCRT2Rate;
6327 if (pVBInfo->LCDInfo & LCDNonExpanding)
6333 if (pVBInfo->SetFlag & ProgrammingCRT2) {
6334 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
6335 if (pVBInfo->IF_DEF_LVDS == 0) {
6336 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B
6337 | VB_SIS301LV | VB_SIS302LV
6340 temp = LCDARefreshIndex[
6341 pVBInfo->LCDResInfo & 0x0F];
6343 temp = LCDRefreshIndex[
6344 pVBInfo->LCDResInfo & 0x0F];
6354 RefreshRateTableIndex = pVBInfo->EModeIDTable[ModeIdIndex].REFindex;
6355 ModeNo = pVBInfo->RefIndex[RefreshRateTableIndex].ModeID;
6356 if (pXGIHWDE->jChipType >= XG20) { /* for XG20, XG21, XG27 */
6357 if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 800) &&
6358 (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 600)) {
6362 * do the similar adjustment like XGISearchCRT1Rate() */
6363 if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1024) &&
6364 (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 768)) {
6367 if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1280) &&
6368 (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 1024)) {
6375 if (pVBInfo->RefIndex[RefreshRateTableIndex + i].
6378 temp = pVBInfo->RefIndex[RefreshRateTableIndex + i].
6380 temp &= ModeTypeMask;
6381 if (temp < pVBInfo->ModeType)
6386 } while (index != 0xFFFF);
6387 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) {
6388 if (pVBInfo->VBInfo & SetInSlaveMode) {
6389 temp = pVBInfo->RefIndex[RefreshRateTableIndex + i - 1].
6391 if (temp & InterlaceMode)
6396 if ((pVBInfo->SetFlag & ProgrammingCRT2)) {
6397 temp = XGI_AjustCRT2Rate(ModeNo, ModeIdIndex,
6398 RefreshRateTableIndex, &i, pVBInfo);
6400 return RefreshRateTableIndex + i;
6403 static void XGI_SetLCDAGroup(unsigned short ModeNo, unsigned short ModeIdIndex,
6404 struct xgi_hw_device_info *HwDeviceExtension,
6405 struct vb_device_info *pVBInfo)
6407 unsigned short RefreshRateTableIndex;
6409 pVBInfo->SetFlag |= ProgrammingCRT2;
6410 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
6411 ModeIdIndex, pVBInfo);
6412 XGI_GetLVDSResInfo(ModeNo, ModeIdIndex, pVBInfo);
6413 XGI_GetLVDSData(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
6414 XGI_ModCRT1Regs(ModeNo, ModeIdIndex, RefreshRateTableIndex,
6415 HwDeviceExtension, pVBInfo);
6416 XGI_SetLVDSRegs(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
6417 XGI_SetCRT2ECLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
6420 static unsigned char XGI_SetCRT2Group301(unsigned short ModeNo,
6421 struct xgi_hw_device_info *HwDeviceExtension,
6422 struct vb_device_info *pVBInfo)
6424 unsigned short tempbx, ModeIdIndex, RefreshRateTableIndex;
6426 tempbx = pVBInfo->VBInfo;
6427 pVBInfo->SetFlag |= ProgrammingCRT2;
6428 XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo);
6429 pVBInfo->SelectCRT2Rate = 4;
6430 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
6431 ModeIdIndex, pVBInfo);
6432 XGI_SaveCRT2Info(ModeNo, pVBInfo);
6433 XGI_GetCRT2ResInfo(ModeNo, ModeIdIndex, pVBInfo);
6434 XGI_GetCRT2Data(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
6435 XGI_PreSetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension,
6436 RefreshRateTableIndex, pVBInfo);
6437 XGI_SetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension,
6438 RefreshRateTableIndex, pVBInfo);
6439 XGI_SetLockRegs(ModeNo, ModeIdIndex, HwDeviceExtension,
6440 RefreshRateTableIndex, pVBInfo);
6441 XGI_SetGroup2(ModeNo, ModeIdIndex, RefreshRateTableIndex,
6442 HwDeviceExtension, pVBInfo);
6443 XGI_SetLCDRegs(ModeNo, ModeIdIndex, HwDeviceExtension,
6444 RefreshRateTableIndex, pVBInfo);
6445 XGI_SetTap4Regs(pVBInfo);
6446 XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo);
6447 XGI_SetGroup4(ModeNo, ModeIdIndex, RefreshRateTableIndex,
6448 HwDeviceExtension, pVBInfo);
6449 XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
6450 XGI_SetGroup5(ModeNo, ModeIdIndex, pVBInfo);
6451 XGI_AutoThreshold(pVBInfo);
6455 void XGI_SenseCRT1(struct vb_device_info *pVBInfo)
6457 unsigned char CRTCData[17] = { 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81,
6458 0x0B, 0x3E, 0xE9, 0x0B, 0xDF, 0xE7, 0x04, 0x00, 0x00,
6461 unsigned char SR01 = 0, SR1F = 0, SR07 = 0, SR06 = 0;
6463 unsigned char CR17, CR63, SR31;
6464 unsigned short temp;
6465 unsigned char DAC_TEST_PARMS[3] = { 0x0F, 0x0F, 0x0F };
6468 xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86);
6470 /* [2004/05/06] Vicent to fix XG42 single LCD sense to CRT+LCD */
6471 xgifb_reg_set(pVBInfo->P3d4, 0x57, 0x4A);
6472 xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get(
6473 pVBInfo->P3d4, 0x53) | 0x02));
6475 SR31 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x31);
6476 CR63 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x63);
6477 SR01 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x01);
6479 xgifb_reg_set(pVBInfo->P3c4, 0x01, (unsigned char) (SR01 & 0xDF));
6480 xgifb_reg_set(pVBInfo->P3d4, 0x63, (unsigned char) (CR63 & 0xBF));
6482 CR17 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x17);
6483 xgifb_reg_set(pVBInfo->P3d4, 0x17, (unsigned char) (CR17 | 0x80));
6485 SR1F = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x1F);
6486 xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) (SR1F | 0x04));
6488 SR07 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x07);
6489 xgifb_reg_set(pVBInfo->P3c4, 0x07, (unsigned char) (SR07 & 0xFB));
6490 SR06 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x06);
6491 xgifb_reg_set(pVBInfo->P3c4, 0x06, (unsigned char) (SR06 & 0xC3));
6493 xgifb_reg_set(pVBInfo->P3d4, 0x11, 0x00);
6495 for (i = 0; i < 8; i++)
6496 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) i, CRTCData[i]);
6498 for (i = 8; i < 11; i++)
6499 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 8),
6502 for (i = 11; i < 13; i++)
6503 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 4),
6506 for (i = 13; i < 16; i++)
6507 xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i - 3),
6510 xgifb_reg_set(pVBInfo->P3c4, 0x0E, (unsigned char) (CRTCData[16]
6513 xgifb_reg_set(pVBInfo->P3c4, 0x31, 0x00);
6514 xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x1B);
6515 xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE1);
6517 outb(0x00, pVBInfo->P3c8);
6519 for (i = 0; i < 256; i++) {
6520 outb((unsigned char) DAC_TEST_PARMS[0], (pVBInfo->P3c8 + 1));
6521 outb((unsigned char) DAC_TEST_PARMS[1], (pVBInfo->P3c8 + 1));
6522 outb((unsigned char) DAC_TEST_PARMS[2], (pVBInfo->P3c8 + 1));
6527 XGI_WaitDisply(pVBInfo);
6528 temp = inb(pVBInfo->P3c2);
6531 xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x20);
6533 xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x00);
6535 /* alan, avoid display something, set BLACK DAC if not restore DAC */
6536 outb(0x00, pVBInfo->P3c8);
6538 for (i = 0; i < 256; i++) {
6539 outb(0, (pVBInfo->P3c8 + 1));
6540 outb(0, (pVBInfo->P3c8 + 1));
6541 outb(0, (pVBInfo->P3c8 + 1));
6544 xgifb_reg_set(pVBInfo->P3c4, 0x01, SR01);
6545 xgifb_reg_set(pVBInfo->P3d4, 0x63, CR63);
6546 xgifb_reg_set(pVBInfo->P3c4, 0x31, SR31);
6548 /* [2004/05/11] Vicent */
6549 xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get(
6550 pVBInfo->P3d4, 0x53) & 0xFD));
6551 xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) SR1F);
6554 static void XGI_EnableBridge(struct xgifb_video_info *xgifb_info,
6555 struct xgi_hw_device_info *HwDeviceExtension,
6556 struct vb_device_info *pVBInfo)
6558 unsigned short tempah;
6560 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
6561 | VB_SIS302LV | VB_XGI301C)) {
6562 if (!(pVBInfo->SetFlag & DisableChA)) {
6563 if (pVBInfo->SetFlag & EnableChA) {
6565 xgifb_reg_set(pVBInfo->Part1Port, 0x1E, 0x20);
6567 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
6569 xgifb_reg_set(pVBInfo->Part1Port,
6575 if (!(pVBInfo->SetFlag & DisableChB)) {
6576 if ((pVBInfo->SetFlag & EnableChB) || (pVBInfo->VBInfo
6577 & (SetCRT2ToLCD | SetCRT2ToTV
6578 | SetCRT2ToRAMDAC))) {
6579 tempah = (unsigned char) xgifb_reg_get(
6580 pVBInfo->P3c4, 0x32);
6582 if (pVBInfo->VBInfo & SetInSlaveMode) {
6583 if (!(pVBInfo->VBInfo &
6587 xgifb_reg_set(pVBInfo->P3c4, 0x32, tempah);
6588 xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x20);
6590 tempah = (unsigned char) xgifb_reg_get(
6591 pVBInfo->Part1Port, 0x2E);
6593 if (!(tempah & 0x80))
6594 xgifb_reg_or(pVBInfo->Part1Port,
6596 xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F);
6600 if ((pVBInfo->SetFlag & (EnableChA | EnableChB))
6601 || (!(pVBInfo->VBInfo & DisableCRT2Display))) {
6602 xgifb_reg_and_or(pVBInfo->Part2Port, 0x00, ~0xE0,
6603 0x20); /* shampoo 0129 */
6604 if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) {
6605 if (!XGI_DisableChISLCD(pVBInfo)) {
6606 if (XGI_EnableChISLCD(pVBInfo) ||
6608 (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)))
6609 /* LVDS PLL power on */
6615 /* LVDS Driver power on */
6616 xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x7F);
6622 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
6625 if (!(pVBInfo->VBInfo & SetSimuScanMode)) {
6626 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
6627 if (pVBInfo->VBInfo &
6628 SetCRT2ToDualEdge) {
6629 tempah = tempah & 0x40;
6630 if (pVBInfo->VBInfo &
6632 tempah = tempah ^ 0xC0;
6634 if (pVBInfo->SetFlag &
6638 if (pVBInfo->SetFlag &
6642 if (pVBInfo->SetFlag &
6646 if (pVBInfo->SetFlag &
6654 /* EnablePart4_1F */
6655 xgifb_reg_or(pVBInfo->Part4Port, 0x1F, tempah);
6657 if (!(pVBInfo->SetFlag & DisableChA)) {
6658 if (!(pVBInfo->SetFlag & GatingCRT)) {
6659 XGI_DisableGatingCRT(HwDeviceExtension,
6661 XGI_DisplayOn(xgifb_info, HwDeviceExtension,
6667 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD
6668 | XGI_SetCRT2ToLCDA))
6670 xgifb_reg_or(pVBInfo->Part1Port, 0x1E, 0x20);
6672 tempah = (unsigned char) xgifb_reg_get(pVBInfo->Part1Port,
6674 if (!(tempah & 0x80))
6675 xgifb_reg_or(pVBInfo->Part1Port, 0x2E, 0x80);
6677 xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F);
6678 XGI_DisplayOn(xgifb_info, HwDeviceExtension, pVBInfo);
6682 static void XGI_SetCRT1Group(struct xgifb_video_info *xgifb_info,
6683 struct xgi_hw_device_info *HwDeviceExtension,
6684 unsigned short ModeNo, unsigned short ModeIdIndex,
6685 struct vb_device_info *pVBInfo)
6687 unsigned short RefreshRateTableIndex, temp;
6689 XGI_SetSeqRegs(ModeNo, ModeIdIndex, pVBInfo);
6690 outb(pVBInfo->StandTable->MISC, pVBInfo->P3c2);
6691 XGI_SetCRTCRegs(HwDeviceExtension, pVBInfo);
6692 XGI_SetATTRegs(ModeNo, ModeIdIndex, pVBInfo);
6693 XGI_SetGRCRegs(pVBInfo);
6694 XGI_ClearExt1Regs(pVBInfo);
6696 if (HwDeviceExtension->jChipType == XG27) {
6697 if (pVBInfo->IF_DEF_LVDS == 0)
6698 XGI_SetDefaultVCLK(pVBInfo);
6701 temp = ~ProgrammingCRT2;
6702 pVBInfo->SetFlag &= temp;
6703 pVBInfo->SelectCRT2Rate = 0;
6705 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
6706 | VB_SIS302LV | VB_XGI301C)) {
6707 if (pVBInfo->VBInfo & (SetSimuScanMode | XGI_SetCRT2ToLCDA
6708 | SetInSlaveMode)) {
6709 pVBInfo->SetFlag |= ProgrammingCRT2;
6713 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
6714 ModeIdIndex, pVBInfo);
6715 if (RefreshRateTableIndex != 0xFFFF) {
6716 XGI_SetSync(RefreshRateTableIndex, pVBInfo);
6717 XGI_SetCRT1CRTC(ModeNo, ModeIdIndex, RefreshRateTableIndex,
6718 pVBInfo, HwDeviceExtension);
6719 XGI_SetCRT1DE(HwDeviceExtension, ModeNo, ModeIdIndex,
6720 RefreshRateTableIndex, pVBInfo);
6721 XGI_SetCRT1Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
6722 HwDeviceExtension, pVBInfo);
6723 XGI_SetCRT1VCLK(ModeNo, ModeIdIndex, HwDeviceExtension,
6724 RefreshRateTableIndex, pVBInfo);
6727 if (HwDeviceExtension->jChipType >= XG21) {
6728 temp = xgifb_reg_get(pVBInfo->P3d4, 0x38);
6731 if (HwDeviceExtension->jChipType == XG27)
6732 XGI_SetXG27CRTC(ModeNo, ModeIdIndex,
6733 RefreshRateTableIndex, pVBInfo);
6735 XGI_SetXG21CRTC(ModeNo, ModeIdIndex,
6736 RefreshRateTableIndex, pVBInfo);
6738 XGI_UpdateXG21CRTC(ModeNo, pVBInfo,
6739 RefreshRateTableIndex);
6741 xgifb_set_lcd(HwDeviceExtension->jChipType,
6742 pVBInfo, RefreshRateTableIndex, ModeNo);
6744 if (pVBInfo->IF_DEF_LVDS == 1)
6745 xgifb_set_lvds(xgifb_info,
6746 HwDeviceExtension->jChipType,
6747 ModeNo, ModeIdIndex, pVBInfo);
6751 pVBInfo->SetFlag &= (~ProgrammingCRT2);
6752 XGI_SetCRT1FIFO(ModeNo, HwDeviceExtension, pVBInfo);
6753 XGI_SetCRT1ModeRegs(HwDeviceExtension, ModeNo, ModeIdIndex,
6754 RefreshRateTableIndex, pVBInfo);
6755 XGI_LoadDAC(ModeNo, ModeIdIndex, pVBInfo);
6758 unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info,
6759 struct xgi_hw_device_info *HwDeviceExtension,
6760 unsigned short ModeNo)
6762 unsigned short ModeIdIndex;
6763 struct vb_device_info VBINF;
6764 struct vb_device_info *pVBInfo = &VBINF;
6765 pVBInfo->BaseAddr = xgifb_info->vga_base;
6766 pVBInfo->IF_DEF_LVDS = 0;
6767 pVBInfo->IF_DEF_LCDA = 1;
6769 if (HwDeviceExtension->jChipType >= XG20) { /* kuku 2004/06/25 */
6770 pVBInfo->IF_DEF_YPbPr = 0;
6771 pVBInfo->IF_DEF_HiVision = 0;
6772 pVBInfo->IF_DEF_CRT2Monitor = 0;
6773 pVBInfo->VBType = 0; /*set VBType default 0*/
6775 pVBInfo->IF_DEF_YPbPr = 1;
6776 pVBInfo->IF_DEF_HiVision = 1;
6777 pVBInfo->IF_DEF_CRT2Monitor = 1;
6780 pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14;
6781 pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24;
6782 pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10;
6783 pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e;
6784 pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12;
6785 pVBInfo->P3cc = pVBInfo->BaseAddr + 0x1C;
6786 pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a;
6787 pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16;
6788 pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17;
6789 pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18;
6790 pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19;
6791 pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A;
6792 pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00;
6793 pVBInfo->Part1Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_04;
6794 pVBInfo->Part2Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_10;
6795 pVBInfo->Part3Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_12;
6796 pVBInfo->Part4Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_14;
6797 pVBInfo->Part5Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_14 + 2;
6799 /* for x86 Linux, XG21 LVDS */
6800 if (HwDeviceExtension->jChipType == XG21) {
6801 if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0)
6802 pVBInfo->IF_DEF_LVDS = 1;
6804 if (HwDeviceExtension->jChipType == XG27) {
6805 if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) {
6806 if (xgifb_reg_get(pVBInfo->P3d4, 0x30) & 0x20)
6807 pVBInfo->IF_DEF_LVDS = 1;
6811 if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 */
6812 XGI_GetVBType(pVBInfo);
6814 InitTo330Pointer(HwDeviceExtension->jChipType, pVBInfo);
6816 ModeNo = ModeNo & 0x7F;
6817 xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86);
6819 if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 1.Openkey */
6820 XGI_UnLockCRT2(HwDeviceExtension, pVBInfo);
6822 XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo);
6824 if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */
6825 XGI_GetVBInfo(ModeNo, ModeIdIndex, HwDeviceExtension, pVBInfo);
6826 XGI_GetTVInfo(ModeNo, ModeIdIndex, pVBInfo);
6827 XGI_GetLCDInfo(ModeNo, ModeIdIndex, pVBInfo);
6828 XGI_DisableBridge(xgifb_info, HwDeviceExtension, pVBInfo);
6830 if (pVBInfo->VBInfo & (SetSimuScanMode | XGI_SetCRT2ToLCDA)) {
6831 XGI_SetCRT1Group(xgifb_info, HwDeviceExtension, ModeNo,
6832 ModeIdIndex, pVBInfo);
6834 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
6835 XGI_SetLCDAGroup(ModeNo, ModeIdIndex,
6836 HwDeviceExtension, pVBInfo);
6839 if (!(pVBInfo->VBInfo & SwitchCRT2)) {
6840 XGI_SetCRT1Group(xgifb_info,
6841 HwDeviceExtension, ModeNo,
6842 ModeIdIndex, pVBInfo);
6843 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
6844 XGI_SetLCDAGroup(ModeNo, ModeIdIndex,
6851 if (pVBInfo->VBInfo & (SetSimuScanMode | SwitchCRT2)) {
6852 switch (HwDeviceExtension->ujVBChipID) {
6854 XGI_SetCRT2Group301(ModeNo, HwDeviceExtension,
6855 pVBInfo); /*add for CRT2 */
6859 XGI_SetCRT2Group301(ModeNo, HwDeviceExtension,
6860 pVBInfo); /*add for CRT2 */
6868 XGI_SetCRT2ModeRegs(ModeNo, HwDeviceExtension, pVBInfo);
6869 XGI_OEM310Setting(ModeNo, ModeIdIndex, pVBInfo); /*0212*/
6870 XGI_CloseCRTC(HwDeviceExtension, pVBInfo);
6871 XGI_EnableBridge(xgifb_info, HwDeviceExtension, pVBInfo);
6874 if (pVBInfo->IF_DEF_LVDS == 1)
6875 if (!XGI_XG21CheckLVDSMode(xgifb_info, ModeNo,
6880 pVBInfo->ModeType = pVBInfo->EModeIDTable[ModeIdIndex].
6881 Ext_ModeFlag & ModeTypeMask;
6883 pVBInfo->SetFlag = 0;
6884 pVBInfo->VBInfo = DisableCRT2Display;
6886 XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo);
6888 XGI_SetCRT1Group(xgifb_info, HwDeviceExtension, ModeNo,
6889 ModeIdIndex, pVBInfo);
6891 XGI_DisplayOn(xgifb_info, HwDeviceExtension, pVBInfo);
6894 XGI_UpdateModeInfo(HwDeviceExtension, pVBInfo);
6896 if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */
6897 XGI_LockCRT2(HwDeviceExtension, pVBInfo);