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_MDA_DAC[] = {
20 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
22 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
23 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
24 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
26 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
27 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F};
29 static const unsigned short XGINew_CGA_DAC[] = {
30 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
31 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
32 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
33 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
34 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
35 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
36 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
37 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F};
39 static const unsigned short XGINew_EGA_DAC[] = {
40 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x05, 0x15,
41 0x20, 0x30, 0x24, 0x34, 0x21, 0x31, 0x25, 0x35,
42 0x08, 0x18, 0x0C, 0x1C, 0x09, 0x19, 0x0D, 0x1D,
43 0x28, 0x38, 0x2C, 0x3C, 0x29, 0x39, 0x2D, 0x3D,
44 0x02, 0x12, 0x06, 0x16, 0x03, 0x13, 0x07, 0x17,
45 0x22, 0x32, 0x26, 0x36, 0x23, 0x33, 0x27, 0x37,
46 0x0A, 0x1A, 0x0E, 0x1E, 0x0B, 0x1B, 0x0F, 0x1F,
47 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F};
49 static const unsigned short XGINew_VGA_DAC[] = {
50 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
51 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
52 0x00, 0x05, 0x08, 0x0B, 0x0E, 0x11, 0x14, 0x18,
53 0x1C, 0x20, 0x24, 0x28, 0x2D, 0x32, 0x38, 0x3F,
54 0x00, 0x10, 0x1F, 0x2F, 0x3F, 0x1F, 0x27, 0x2F,
55 0x37, 0x3F, 0x2D, 0x31, 0x36, 0x3A, 0x3F, 0x00,
56 0x07, 0x0E, 0x15, 0x1C, 0x0E, 0x11, 0x15, 0x18,
57 0x1C, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x00, 0x04,
58 0x08, 0x0C, 0x10, 0x08, 0x0A, 0x0C, 0x0E, 0x10,
59 0x0B, 0x0C, 0x0D, 0x0F, 0x10};
61 void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo)
63 pVBInfo->StandTable = (struct SiS_StandTable_S *) &XGI330_StandTable;
64 pVBInfo->EModeIDTable = (struct XGI_ExtStruct *) XGI330_EModeIDTable;
65 pVBInfo->RefIndex = (struct XGI_Ext2Struct *) XGI330_RefIndex;
66 pVBInfo->XGINEWUB_CRT1Table
67 = (struct XGI_CRT1TableStruct *) XGI_CRT1Table;
69 pVBInfo->MCLKData = (struct SiS_MCLKData *) XGI340New_MCLKData;
70 pVBInfo->ECLKData = (struct XGI_ECLKDataStruct *) XGI340_ECLKData;
71 pVBInfo->VCLKData = (struct SiS_VCLKData *) XGI_VCLKData;
72 pVBInfo->VBVCLKData = (struct SiS_VBVCLKData *) XGI_VBVCLKData;
73 pVBInfo->ScreenOffset = XGI330_ScreenOffset;
74 pVBInfo->StResInfo = (struct SiS_StResInfo_S *) XGI330_StResInfo;
76 = (struct SiS_ModeResInfo_S *) XGI330_ModeResInfo;
78 pVBInfo->pOutputSelect = &XGI330_OutputSelect;
79 pVBInfo->pSoftSetting = &XGI330_SoftSetting;
80 pVBInfo->pSR07 = &XGI330_SR07;
81 pVBInfo->LCDResInfo = 0;
82 pVBInfo->LCDTypeInfo = 0;
87 pVBInfo->SR15 = XGI340_SR13;
88 pVBInfo->CR40 = XGI340_cr41;
89 pVBInfo->SR25 = XGI330_sr25;
90 pVBInfo->pSR31 = &XGI330_sr31;
91 pVBInfo->pSR32 = &XGI330_sr32;
92 pVBInfo->CR6B = XGI340_CR6B;
93 pVBInfo->CR6E = XGI340_CR6E;
94 pVBInfo->CR6F = XGI340_CR6F;
95 pVBInfo->CR89 = XGI340_CR89;
96 pVBInfo->AGPReg = XGI340_AGPReg;
97 pVBInfo->SR16 = XGI340_SR16;
98 pVBInfo->pCRCF = &XG40_CRCF;
99 pVBInfo->pXGINew_DRAMTypeDefinition = &XG40_DRAMTypeDefinition;
101 pVBInfo->CR49 = XGI330_CR49;
102 pVBInfo->pSR1F = &XGI330_SR1F;
103 pVBInfo->pSR21 = &XGI330_SR21;
104 pVBInfo->pSR22 = &XGI330_SR22;
105 pVBInfo->pSR23 = &XGI330_SR23;
106 pVBInfo->pSR24 = &XGI330_SR24;
107 pVBInfo->pSR33 = &XGI330_SR33;
109 pVBInfo->pCRT2Data_1_2 = &XGI330_CRT2Data_1_2;
110 pVBInfo->pCRT2Data_4_D = &XGI330_CRT2Data_4_D;
111 pVBInfo->pCRT2Data_4_E = &XGI330_CRT2Data_4_E;
112 pVBInfo->pCRT2Data_4_10 = &XGI330_CRT2Data_4_10;
113 pVBInfo->pRGBSenseData = &XGI330_RGBSenseData;
114 pVBInfo->pVideoSenseData = &XGI330_VideoSenseData;
115 pVBInfo->pYCSenseData = &XGI330_YCSenseData;
116 pVBInfo->pRGBSenseData2 = &XGI330_RGBSenseData2;
117 pVBInfo->pVideoSenseData2 = &XGI330_VideoSenseData2;
118 pVBInfo->pYCSenseData2 = &XGI330_YCSenseData2;
120 pVBInfo->NTSCTiming = XGI330_NTSCTiming;
121 pVBInfo->PALTiming = XGI330_PALTiming;
122 pVBInfo->HiTVExtTiming = XGI330_HiTVExtTiming;
123 pVBInfo->HiTVSt1Timing = XGI330_HiTVSt1Timing;
124 pVBInfo->HiTVSt2Timing = XGI330_HiTVSt2Timing;
125 pVBInfo->HiTVTextTiming = XGI330_HiTVTextTiming;
126 pVBInfo->YPbPr750pTiming = XGI330_YPbPr750pTiming;
127 pVBInfo->YPbPr525pTiming = XGI330_YPbPr525pTiming;
128 pVBInfo->YPbPr525iTiming = XGI330_YPbPr525iTiming;
129 pVBInfo->HiTVGroup3Data = XGI330_HiTVGroup3Data;
130 pVBInfo->HiTVGroup3Simu = XGI330_HiTVGroup3Simu;
131 pVBInfo->HiTVGroup3Text = XGI330_HiTVGroup3Text;
132 pVBInfo->Ren525pGroup3 = XGI330_Ren525pGroup3;
133 pVBInfo->Ren750pGroup3 = XGI330_Ren750pGroup3;
135 pVBInfo->TimingH = (struct XGI_TimingHStruct *) XGI_TimingH;
136 pVBInfo->TimingV = (struct XGI_TimingVStruct *) XGI_TimingV;
137 pVBInfo->UpdateCRT1 = (struct XGI_XG21CRT1Struct *) XGI_UpdateCRT1Table;
139 /* 310 customization related */
140 if ((pVBInfo->VBType & VB_SIS301LV) || (pVBInfo->VBType & VB_SIS302LV))
141 pVBInfo->LCDCapList = XGI_LCDDLCapList;
143 pVBInfo->LCDCapList = XGI_LCDCapList;
145 pVBInfo->XGI_TVDelayList = XGI301TVDelayList;
146 pVBInfo->XGI_TVDelayList2 = XGI301TVDelayList2;
148 pVBInfo->pXGINew_I2CDefinition = &XG40_I2CDefinition;
150 if (ChipType >= XG20)
151 pVBInfo->pXGINew_CR97 = &XG20_CR97;
153 if (ChipType == XG27) {
155 = (struct SiS_MCLKData *) XGI27New_MCLKData;
156 pVBInfo->CR40 = XGI27_cr41;
157 pVBInfo->pXGINew_CR97 = &XG27_CR97;
158 pVBInfo->pSR36 = &XG27_SR36;
159 pVBInfo->pCR8F = &XG27_CR8F;
160 pVBInfo->pCRD0 = XG27_CRD0;
161 pVBInfo->pCRDE = XG27_CRDE;
162 pVBInfo->pSR40 = &XG27_SR40;
163 pVBInfo->pSR41 = &XG27_SR41;
167 if (ChipType >= XG20) {
168 pVBInfo->pDVOSetting = &XG21_DVOSetting;
169 pVBInfo->pCR2E = &XG21_CR2E;
170 pVBInfo->pCR2F = &XG21_CR2F;
171 pVBInfo->pCR46 = &XG21_CR46;
172 pVBInfo->pCR47 = &XG21_CR47;
177 static void XGI_SetSeqRegs(unsigned short ModeNo,
178 unsigned short ModeIdIndex,
179 struct vb_device_info *pVBInfo)
181 unsigned char tempah, SRdata;
182 unsigned short i, modeflag;
184 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
186 xgifb_reg_set(pVBInfo->P3c4, 0x00, 0x03); /* Set SR0 */
187 tempah = pVBInfo->StandTable->SR[0];
189 i = XGI_SetCRT2ToLCDA;
190 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
193 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD)) {
194 if (pVBInfo->VBInfo & SetInSlaveMode)
199 tempah |= 0x20; /* screen off */
200 xgifb_reg_set(pVBInfo->P3c4, 0x01, tempah); /* Set SR1 */
202 for (i = 02; i <= 04; i++) {
203 /* Get SR2,3,4 from file */
204 SRdata = pVBInfo->StandTable->SR[i - 1];
205 xgifb_reg_set(pVBInfo->P3c4, i, SRdata); /* Set SR2 3 4 */
209 static void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension,
210 struct vb_device_info *pVBInfo)
212 unsigned char CRTCdata;
215 CRTCdata = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
217 xgifb_reg_set(pVBInfo->P3d4, 0x11, CRTCdata); /* Unlock CRTC */
219 for (i = 0; i <= 0x18; i++) {
220 /* Get CRTC from file */
221 CRTCdata = pVBInfo->StandTable->CRTC[i];
222 xgifb_reg_set(pVBInfo->P3d4, i, CRTCdata); /* Set CRTC(3d4) */
226 static void XGI_SetATTRegs(unsigned short ModeNo,
227 unsigned short ModeIdIndex,
228 struct vb_device_info *pVBInfo)
230 unsigned char ARdata;
231 unsigned short i, modeflag;
233 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
235 for (i = 0; i <= 0x13; i++) {
236 ARdata = pVBInfo->StandTable->ATTR[i];
237 if (modeflag & Charx8Dot) { /* ifndef Dot9 */
239 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
242 if (pVBInfo->VBInfo & (SetCRT2ToTV
244 if (pVBInfo->VBInfo &
252 inb(pVBInfo->P3da); /* reset 3da */
253 outb(i, pVBInfo->P3c0); /* set index */
254 outb(ARdata, pVBInfo->P3c0); /* set data */
257 inb(pVBInfo->P3da); /* reset 3da */
258 outb(0x14, pVBInfo->P3c0); /* set index */
259 outb(0x00, pVBInfo->P3c0); /* set data */
260 inb(pVBInfo->P3da); /* Enable Attribute */
261 outb(0x20, pVBInfo->P3c0);
264 static void XGI_SetGRCRegs(struct vb_device_info *pVBInfo)
266 unsigned char GRdata;
269 for (i = 0; i <= 0x08; i++) {
270 /* Get GR from file */
271 GRdata = pVBInfo->StandTable->GRC[i];
272 xgifb_reg_set(pVBInfo->P3ce, i, GRdata); /* Set GR(3ce) */
275 if (pVBInfo->ModeType > ModeVGA) {
276 GRdata = (unsigned char) xgifb_reg_get(pVBInfo->P3ce, 0x05);
277 GRdata &= 0xBF; /* 256 color disable */
278 xgifb_reg_set(pVBInfo->P3ce, 0x05, GRdata);
282 static void XGI_ClearExt1Regs(struct vb_device_info *pVBInfo)
286 for (i = 0x0A; i <= 0x0E; i++)
287 xgifb_reg_set(pVBInfo->P3c4, i, 0x00); /* Clear SR0A-SR0E */
290 static unsigned char XGI_SetDefaultVCLK(struct vb_device_info *pVBInfo)
293 xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x20);
294 xgifb_reg_set(pVBInfo->P3c4, 0x2B, pVBInfo->VCLKData[0].SR2B);
295 xgifb_reg_set(pVBInfo->P3c4, 0x2C, pVBInfo->VCLKData[0].SR2C);
297 xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x10);
298 xgifb_reg_set(pVBInfo->P3c4, 0x2B, pVBInfo->VCLKData[1].SR2B);
299 xgifb_reg_set(pVBInfo->P3c4, 0x2C, pVBInfo->VCLKData[1].SR2C);
301 xgifb_reg_and(pVBInfo->P3c4, 0x31, ~0x30);
305 static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo,
306 unsigned short ModeIdIndex,
307 unsigned short RefreshRateTableIndex, unsigned short *i,
308 struct vb_device_info *pVBInfo)
310 unsigned short tempax, tempbx, resinfo, modeflag, infoflag;
312 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
313 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
314 tempbx = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID;
317 if (pVBInfo->IF_DEF_LVDS == 0) {
318 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
319 tempax |= SupportRAMDAC2;
321 if (pVBInfo->VBType & VB_XGI301C)
322 tempax |= SupportCRT2in301C;
326 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
327 tempax |= SupportLCD;
329 if (pVBInfo->LCDResInfo != Panel_1280x1024) {
330 if (pVBInfo->LCDResInfo != Panel_1280x960) {
331 if (pVBInfo->LCDInfo &
342 if (pVBInfo->VBInfo & SetCRT2ToHiVision) { /* for HiTV */
343 if ((pVBInfo->VBType & VB_SIS301LV) &&
344 (pVBInfo->VBExtInfo == VB_YPbPr1080i)) {
345 tempax |= SupportYPbPr750p;
346 if (pVBInfo->VBInfo & SetInSlaveMode) {
357 tempax |= SupportHiVision;
358 if (pVBInfo->VBInfo & SetInSlaveMode) {
373 if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO |
376 SetCRT2ToYPbPr525750 |
377 SetCRT2ToHiVision)) {
380 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B
381 | VB_SIS301LV | VB_SIS302LV
383 tempax |= SupportTV1024;
386 if (!(pVBInfo->VBInfo & TVSetPAL)) {
387 if (modeflag & NoSupportSimuTV) {
388 if (pVBInfo->VBInfo &
390 if (!(pVBInfo->VBInfo &
399 } else { /* for LVDS */
400 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
401 tempax |= SupportLCD;
404 return 0; /* 1024x768 */
406 if (pVBInfo->LCDResInfo < Panel_1024x768) {
408 return 0; /* 800x600 */
411 return 0; /* 512x384 */
416 for (; pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID ==
418 infoflag = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].
420 if (infoflag & tempax)
427 for ((*i) = 0;; (*i)++) {
428 infoflag = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].
430 if (pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID
435 if (infoflag & tempax)
441 static void XGI_SetSync(unsigned short RefreshRateTableIndex,
442 struct vb_device_info *pVBInfo)
444 unsigned short sync, temp;
447 sync = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag >> 8;
451 outb(temp, pVBInfo->P3c2); /* Set Misc(3c2) */
454 static void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo,
455 struct xgi_hw_device_info *HwDeviceExtension)
457 unsigned char data, data1, pushax;
461 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
463 xgifb_reg_set(pVBInfo->P3d4, 0x11, data);
465 data = pVBInfo->TimingH[0].data[0];
466 xgifb_reg_set(pVBInfo->P3d4, 0, data);
468 for (i = 0x01; i <= 0x04; i++) {
469 data = pVBInfo->TimingH[0].data[i];
470 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 1), data);
473 for (i = 0x05; i <= 0x06; i++) {
474 data = pVBInfo->TimingH[0].data[i];
475 xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i + 6), data);
478 j = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0e);
480 data = pVBInfo->TimingH[0].data[7];
483 xgifb_reg_set(pVBInfo->P3c4, 0x0e, data);
485 if (HwDeviceExtension->jChipType >= XG20) {
486 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x04);
488 xgifb_reg_set(pVBInfo->P3d4, 0x04, data);
489 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x05);
495 data = (unsigned char) xgifb_reg_get(pVBInfo->P3c4,
498 xgifb_reg_set(pVBInfo->P3c4, 0x0c, data);
503 xgifb_reg_set(pVBInfo->P3d4, 0x05, data);
504 data = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0e);
510 xgifb_reg_and_or(pVBInfo->P3c4, 0x0e, ~0xE0, data);
514 static void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex,
515 unsigned short ModeNo,
516 struct vb_device_info *pVBInfo)
521 for (i = 0x00; i <= 0x01; i++) {
522 data = pVBInfo->TimingV[0].data[i];
523 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 6), data);
526 for (i = 0x02; i <= 0x03; i++) {
527 data = pVBInfo->TimingV[0].data[i];
528 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x0e), data);
531 for (i = 0x04; i <= 0x05; i++) {
532 data = pVBInfo->TimingV[0].data[i];
533 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x11), data);
536 j = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0a);
538 data = pVBInfo->TimingV[0].data[6];
541 xgifb_reg_set(pVBInfo->P3c4, 0x0a, data);
543 data = pVBInfo->TimingV[0].data[6];
547 i = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
552 j = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x09);
555 xgifb_reg_set(pVBInfo->P3d4, 0x09, data);
558 static void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
559 unsigned short RefreshRateTableIndex,
560 struct vb_device_info *pVBInfo,
561 struct xgi_hw_device_info *HwDeviceExtension)
563 unsigned char index, data;
567 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
568 index = index & IndexMask;
570 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
572 xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */
574 for (i = 0; i < 8; i++)
575 pVBInfo->TimingH[0].data[i]
576 = pVBInfo->XGINEWUB_CRT1Table[index].CR[i];
578 for (i = 0; i < 7; i++)
579 pVBInfo->TimingV[0].data[i]
580 = pVBInfo->XGINEWUB_CRT1Table[index].CR[i + 8];
582 XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension);
584 XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo);
586 if (pVBInfo->ModeType > 0x03)
587 xgifb_reg_set(pVBInfo->P3d4, 0x14, 0x4F);
590 /* --------------------------------------------------------------------- */
591 /* Function : XGI_SetXG21CRTC */
592 /* Input : Stand or enhance CRTC table */
593 /* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */
594 /* Description : Set LCD timing */
595 /* --------------------------------------------------------------------- */
596 static void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
597 unsigned short RefreshRateTableIndex,
598 struct vb_device_info *pVBInfo)
600 unsigned char index, Tempax, Tempbx, Tempcx, Tempdx;
601 unsigned short Temp1, Temp2, Temp3;
603 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
604 /* Tempax: CR4 HRS */
605 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3];
606 Tempcx = Tempax; /* Tempcx: HRS */
608 xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax);
610 Tempdx = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SRB */
611 Tempdx &= 0xC0; /* Tempdx[7:6]: SRB[7:6] */
612 Temp1 = Tempdx; /* Temp1[7:6]: HRS[9:8] */
613 Temp1 <<= 2; /* Temp1[9:8]: HRS[9:8] */
614 Temp1 |= Tempax; /* Temp1[9:0]: HRS[9:0] */
616 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */
617 Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */
619 Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[6]; /* SRC */
620 Tempbx &= 0x04; /* Tempbx[2]: HRE[5] */
621 Tempbx <<= 3; /* Tempbx[5]: HRE[5] */
622 Tempax |= Tempbx; /* Tempax[5:0]: HRE[5:0] */
624 Temp2 = Temp1 & 0x3C0; /* Temp2[9:6]: HRS[9:6] */
625 Temp2 |= Tempax; /* Temp2[9:0]: HRE[9:0] */
627 Tempcx &= 0x3F; /* Tempcx[5:0]: HRS[5:0] */
628 if (Tempax < Tempcx) /* HRE < HRS */
629 Temp2 |= 0x40; /* Temp2 + 0x40 */
632 Tempax = (unsigned char) Temp2; /* Tempax: HRE[7:0] */
633 Tempax <<= 2; /* Tempax[7:2]: HRE[5:0] */
634 Tempdx >>= 6; /* Tempdx[7:6]->[1:0] HRS[9:8] */
635 Tempax |= Tempdx; /* HRE[5:0]HRS[9:8] */
636 /* SR2F D[7:2]->HRE, D[1:0]->HRS */
637 xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax);
638 xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00);
641 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10];
642 Tempbx = Tempax; /* Tempbx: VRS */
643 Tempax &= 0x01; /* Tempax[0]: VRS[0] */
644 xgifb_reg_or(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS[0] */
646 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9];
647 Tempcx = Tempbx >> 1; /* Tempcx[6:0]: VRS[7:1] */
648 Tempdx = Tempax & 0x04; /* Tempdx[2]: CR7[2] */
649 Tempdx <<= 5; /* Tempdx[7]: VRS[8] */
650 Tempcx |= Tempdx; /* Tempcx[7:0]: VRS[8:1] */
651 xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempcx); /* SR34[8:1]->VRS */
653 Temp1 = Tempdx; /* Temp1[7]: Tempdx[7] */
654 Temp1 <<= 1; /* Temp1[8]: VRS[8] */
655 Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */
657 Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */
658 Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */
660 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14];
661 Tempax &= 0x08; /* Tempax[3]: VRS[3] */
663 Temp2 <<= 7; /* Temp2[10]: VRS[10] */
664 Temp1 |= Temp2; /* Temp1[10:0]: VRS[10:0] */
666 /* Tempax: CR11 VRE */
667 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11];
668 Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
670 Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14];
671 Tempbx &= 0x20; /* Tempbx[5]: VRE[5] */
672 Tempbx >>= 1; /* Tempbx[4]: VRE[4] */
673 Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */
674 Temp2 = Temp1 & 0x7E0; /* Temp2[10:5]: VRS[10:5] */
675 Temp2 |= Tempax; /* Temp2[10:5]: VRE[10:5] */
677 Temp3 = Temp1 & 0x1F; /* Temp3[4:0]: VRS[4:0] */
678 if (Tempax < Temp3) /* VRE < VRS */
679 Temp2 |= 0x20; /* VRE + 0x20 */
682 Tempax = (unsigned char) Temp2; /* Tempax: VRE[7:0] */
683 Tempax <<= 2; /* Tempax[7:0]; VRE[5:0]00 */
684 Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */
685 Temp1 >>= 9; /* Temp1[1:0]: VRS[10:9] */
686 Tempbx = (unsigned char) Temp1;
687 Tempax |= Tempbx; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */
689 /* SR3F D[7:2]->VRE D[1:0]->VRS */
690 xgifb_reg_set(pVBInfo->P3c4, 0x3F, Tempax);
693 static void XGI_SetXG27CRTC(unsigned short ModeNo,
694 unsigned short ModeIdIndex,
695 unsigned short RefreshRateTableIndex,
696 struct vb_device_info *pVBInfo)
698 unsigned short index, Tempax, Tempbx, Tempcx;
700 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
701 /* Tempax: CR4 HRS */
702 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3];
703 Tempbx = Tempax; /* Tempbx: HRS[7:0] */
705 xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax);
708 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5];
709 Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
710 Tempbx |= (Tempax << 2); /* Tempbx: HRS[9:0] */
712 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */
713 Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */
714 Tempcx = Tempax; /* Tempcx: HRE[4:0] */
716 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[6]; /* SRC */
717 Tempax &= 0x04; /* Tempax[2]: HRE[5] */
718 Tempax <<= 3; /* Tempax[5]: HRE[5] */
719 Tempcx |= Tempax; /* Tempcx[5:0]: HRE[5:0] */
721 Tempbx = Tempbx & 0x3C0; /* Tempbx[9:6]: HRS[9:6] */
722 Tempbx |= Tempcx; /* Tempbx: HRS[9:6]HRE[5:0] */
724 /* Tempax: CR4 HRS */
725 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3];
726 Tempax &= 0x3F; /* Tempax: HRS[5:0] */
727 if (Tempcx <= Tempax) /* HRE[5:0] < HRS[5:0] */
728 Tempbx += 0x40; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/
730 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SR0B */
731 Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
732 Tempax >>= 6; /* Tempax[1:0]: HRS[9:8]*/
733 Tempax |= ((Tempbx << 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */
734 /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */
735 xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax);
736 xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00);
739 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10];
740 /* SR34[7:0]->VRS[7:0] */
741 xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempax);
743 Tempcx = Tempax; /* Tempcx <= VRS[7:0] */
744 /* CR7[7][2] VRS[9][8] */
745 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9];
746 Tempbx = Tempax; /* Tempbx <= CR07[7:0] */
747 Tempax = Tempax & 0x04; /* Tempax[2]: CR7[2]: VRS[8] */
748 Tempax >>= 2; /* Tempax[0]: VRS[8] */
749 /* SR35[0]: VRS[8] */
750 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x01, Tempax);
751 Tempcx |= (Tempax << 8); /* Tempcx <= VRS[8:0] */
752 Tempcx |= ((Tempbx & 0x80) << 2); /* Tempcx <= VRS[9:0] */
754 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14];
755 Tempax &= 0x08; /* SR0A[3] VRS[10] */
756 Tempcx |= (Tempax << 7); /* Tempcx <= VRS[10:0] */
758 /* Tempax: CR11 VRE */
759 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11];
760 Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
762 Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14];
763 Tempbx &= 0x20; /* Tempbx[5]: SR0A[5]: VRE[4] */
764 Tempbx >>= 1; /* Tempbx[4]: VRE[4] */
765 Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */
766 Tempbx = Tempcx; /* Tempbx: VRS[10:0] */
767 Tempbx &= 0x7E0; /* Tempbx[10:5]: VRS[10:5] */
768 Tempbx |= Tempax; /* Tempbx: VRS[10:5]VRE[4:0] */
770 if (Tempbx <= Tempcx) /* VRE <= VRS */
771 Tempbx |= 0x20; /* VRE + 0x20 */
773 /* Tempax: Tempax[7:0]; VRE[5:0]00 */
774 Tempax = (Tempbx << 2) & 0xFF;
775 /* SR3F[7:2]:VRE[5:0] */
776 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax);
777 Tempax = Tempcx >> 8;
778 /* SR35[2:0]:VRS[10:8] */
779 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, Tempax);
782 static void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo)
786 /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */
787 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
788 temp = (temp & 3) << 6;
789 /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */
790 xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0xc0, temp & 0x80);
791 /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */
792 xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80);
796 static void xgifb_set_lcd(int chip_id,
797 struct vb_device_info *pVBInfo,
798 unsigned short RefreshRateTableIndex,
799 unsigned short ModeNo)
801 unsigned short Data, Temp;
802 unsigned short XGI_P3cc;
804 XGI_P3cc = pVBInfo->P3cc;
806 xgifb_reg_set(pVBInfo->P3d4, 0x2E, 0x00);
807 xgifb_reg_set(pVBInfo->P3d4, 0x2F, 0x00);
808 xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x00);
809 xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x00);
811 if (chip_id == XG27) {
812 Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
813 if ((Temp & 0x03) == 0) { /* dual 12 */
814 xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x13);
815 xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x13);
819 if (((*pVBInfo->pDVOSetting) & 0xC0) == 0xC0) {
820 xgifb_reg_set(pVBInfo->P3d4, 0x2E, *pVBInfo->pCR2E);
821 xgifb_reg_set(pVBInfo->P3d4, 0x2F, *pVBInfo->pCR2F);
822 xgifb_reg_set(pVBInfo->P3d4, 0x46, *pVBInfo->pCR46);
823 xgifb_reg_set(pVBInfo->P3d4, 0x47, *pVBInfo->pCR47);
826 if (chip_id == XG27) {
827 XGI_SetXG27FPBits(pVBInfo);
829 Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
832 xgifb_reg_or(pVBInfo->P3c4, 0x06, 0x40);
833 xgifb_reg_or(pVBInfo->P3c4, 0x09, 0x40);
837 xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */
839 xgifb_reg_and(pVBInfo->P3c4, 0x30, ~0x20); /* Hsync polarity */
840 xgifb_reg_and(pVBInfo->P3c4, 0x35, ~0x80); /* Vsync polarity */
842 Data = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
845 xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20);
848 xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80);
851 /* --------------------------------------------------------------------- */
852 /* Function : XGI_UpdateXG21CRTC */
854 /* Output : CRT1 CRTC */
855 /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */
856 /* --------------------------------------------------------------------- */
857 static void XGI_UpdateXG21CRTC(unsigned short ModeNo,
858 struct vb_device_info *pVBInfo,
859 unsigned short RefreshRateTableIndex)
863 xgifb_reg_and(pVBInfo->P3d4, 0x11, 0x7F); /* Unlock CR0~7 */
864 if (ModeNo == 0x2E &&
865 (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC ==
868 else if (ModeNo == 0x2E && (pVBInfo->RefIndex[RefreshRateTableIndex].
869 Ext_CRT1CRTC == RES640x480x72))
871 else if (ModeNo == 0x2F)
873 else if (ModeNo == 0x50)
875 else if (ModeNo == 0x59)
879 xgifb_reg_set(pVBInfo->P3d4, 0x02,
880 pVBInfo->UpdateCRT1[index].CR02);
881 xgifb_reg_set(pVBInfo->P3d4, 0x03,
882 pVBInfo->UpdateCRT1[index].CR03);
883 xgifb_reg_set(pVBInfo->P3d4, 0x15,
884 pVBInfo->UpdateCRT1[index].CR15);
885 xgifb_reg_set(pVBInfo->P3d4, 0x16,
886 pVBInfo->UpdateCRT1[index].CR16);
890 static unsigned short XGI_GetResInfo(unsigned short ModeNo,
891 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
894 return pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
897 static void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension,
898 unsigned short ModeNo, unsigned short ModeIdIndex,
899 unsigned short RefreshRateTableIndex,
900 struct vb_device_info *pVBInfo)
902 unsigned short resindex, tempax, tempbx, tempcx, temp, modeflag;
906 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
908 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
909 tempax = pVBInfo->ModeResInfo[resindex].HTotal;
910 tempbx = pVBInfo->ModeResInfo[resindex].VTotal;
912 if (modeflag & HalfDCLK)
913 tempax = tempax >> 1;
915 if (modeflag & HalfDCLK)
916 tempax = tempax << 1;
918 temp = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
920 if (temp & InterlaceMode)
921 tempbx = tempbx >> 1;
923 if (modeflag & DoubleScanMode)
924 tempbx = tempbx << 1;
932 temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
933 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
935 xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */
936 xgifb_reg_set(pVBInfo->P3d4, 0x01, (unsigned short) (tempcx & 0xff));
937 xgifb_reg_and_or(pVBInfo->P3d4, 0x0b, ~0x0c,
938 (unsigned short) ((tempcx & 0x0ff00) >> 10));
939 xgifb_reg_set(pVBInfo->P3d4, 0x12, (unsigned short) (tempbx & 0xff));
941 tempbx = tempbx >> 8;
949 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x42, tempax);
950 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x07);
957 xgifb_reg_and_or(pVBInfo->P3d4, 0x0a, ~0x02, tempax);
958 xgifb_reg_set(pVBInfo->P3d4, 0x11, temp);
961 static void XGI_SetCRT1Offset(unsigned short ModeNo,
962 unsigned short ModeIdIndex,
963 unsigned short RefreshRateTableIndex,
964 struct xgi_hw_device_info *HwDeviceExtension,
965 struct vb_device_info *pVBInfo)
967 unsigned short temp, ah, al, temp2, i, DisplayUnit;
970 temp = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo;
972 temp = pVBInfo->ScreenOffset[temp];
974 temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
975 temp2 &= InterlaceMode;
980 temp2 = pVBInfo->ModeType - ModeEGA;
1005 if ((ModeNo >= 0x26) && (ModeNo <= 0x28))
1006 temp = temp * temp2 + temp2 / 2;
1013 temp = temp >> 8; /* ah */
1015 i = xgifb_reg_get(pVBInfo->P3c4, 0x0E);
1018 xgifb_reg_set(pVBInfo->P3c4, 0x0E, i);
1020 temp = (unsigned char) temp2;
1021 temp &= 0xFF; /* al */
1022 xgifb_reg_set(pVBInfo->P3d4, 0x13, temp);
1024 /* SetDisplayUnit */
1025 temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1026 temp2 &= InterlaceMode;
1030 DisplayUnit = DisplayUnit << 5;
1031 ah = (DisplayUnit & 0xff00) >> 8;
1032 al = DisplayUnit & 0x00ff;
1038 if (HwDeviceExtension->jChipType >= XG20)
1039 if ((ModeNo == 0x4A) | (ModeNo == 0x49))
1042 xgifb_reg_set(pVBInfo->P3c4, 0x10, ah);
1045 static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo,
1046 unsigned short ModeIdIndex,
1047 unsigned short RefreshRateTableIndex,
1048 struct xgi_hw_device_info *HwDeviceExtension,
1049 struct vb_device_info *pVBInfo)
1051 unsigned short LCDXlat1VCLK[4] = { VCLK65_315 + 2,
1055 unsigned short LCDXlat2VCLK[4] = { VCLK108_2_315 + 5,
1058 VCLK108_2_315 + 5 };
1059 unsigned short LVDSXlat1VCLK[4] = { VCLK40, VCLK40, VCLK40, VCLK40 };
1060 unsigned short LVDSXlat2VCLK[4] = { VCLK65_315 + 2,
1064 unsigned short LVDSXlat3VCLK[4] = { VCLK65_315 + 2,
1069 unsigned short CRT2Index, VCLKIndex;
1070 unsigned short modeflag, resinfo;
1072 /* si+Ext_ResInfo */
1073 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1074 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
1075 CRT2Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
1077 if (pVBInfo->IF_DEF_LVDS == 0) {
1078 CRT2Index = CRT2Index >> 6; /* for LCD */
1079 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { /*301b*/
1080 if (pVBInfo->LCDResInfo != Panel_1024x768)
1081 VCLKIndex = LCDXlat2VCLK[CRT2Index];
1083 VCLKIndex = LCDXlat1VCLK[CRT2Index];
1084 } else if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
1085 if (pVBInfo->SetFlag & RPLLDIV2XO) {
1086 VCLKIndex = TVCLKBASE_315 + HiTVVCLKDIV2;
1089 VCLKIndex = TVCLKBASE_315 + HiTVVCLK;
1093 if (pVBInfo->SetFlag & TVSimuMode) {
1094 if (modeflag & Charx8Dot) {
1095 VCLKIndex = TVCLKBASE_315 + HiTVSimuVCLK;
1098 VCLKIndex = TVCLKBASE_315 + HiTVTextVCLK;
1104 if ((pVBInfo->VBType & VB_SIS301LV) &&
1105 !(pVBInfo->VBExtInfo == VB_YPbPr1080i)) {
1106 if (pVBInfo->VBExtInfo == YPbPr750p)
1107 VCLKIndex = XGI_YPbPr750pVCLK;
1108 else if (pVBInfo->VBExtInfo == YPbPr525p)
1109 VCLKIndex = YPbPr525pVCLK;
1110 else if (pVBInfo->SetFlag & RPLLDIV2XO)
1111 VCLKIndex = YPbPr525iVCLK_2;
1113 VCLKIndex = YPbPr525iVCLK;
1115 } else if (pVBInfo->VBInfo & SetCRT2ToTV) {
1116 if (pVBInfo->SetFlag & RPLLDIV2XO) {
1117 VCLKIndex = TVCLKBASE_315 + TVVCLKDIV2;
1120 VCLKIndex = TVCLKBASE_315 + TVVCLK;
1123 } else { /* for CRT2 */
1124 /* di+Ext_CRTVCLK */
1125 VCLKIndex = pVBInfo->RefIndex[RefreshRateTableIndex].
1127 VCLKIndex &= IndexMask;
1130 VCLKIndex = CRT2Index;
1131 VCLKIndex = VCLKIndex >> 6;
1132 if ((pVBInfo->LCDResInfo == Panel_800x600) ||
1133 (pVBInfo->LCDResInfo == Panel_320x480))
1134 VCLKIndex = LVDSXlat1VCLK[VCLKIndex];
1135 else if ((pVBInfo->LCDResInfo == Panel_1024x768) ||
1136 (pVBInfo->LCDResInfo == Panel_1024x768x75))
1137 VCLKIndex = LVDSXlat2VCLK[VCLKIndex];
1139 VCLKIndex = LVDSXlat3VCLK[VCLKIndex];
1145 static void XGI_SetCRT1VCLK(unsigned short ModeNo,
1146 unsigned short ModeIdIndex,
1147 struct xgi_hw_device_info *HwDeviceExtension,
1148 unsigned short RefreshRateTableIndex,
1149 struct vb_device_info *pVBInfo)
1151 unsigned char index, data;
1152 unsigned short vclkindex;
1154 if (pVBInfo->IF_DEF_LVDS == 1) {
1155 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1156 data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF;
1157 xgifb_reg_set(pVBInfo->P3c4, 0x31, data);
1158 xgifb_reg_set(pVBInfo->P3c4, 0x2B,
1159 pVBInfo->VCLKData[index].SR2B);
1160 xgifb_reg_set(pVBInfo->P3c4, 0x2C,
1161 pVBInfo->VCLKData[index].SR2C);
1162 xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01);
1163 } else if ((pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
1164 | VB_SIS302LV | VB_XGI301C)) && (pVBInfo->VBInfo
1165 & XGI_SetCRT2ToLCDA)) {
1166 vclkindex = XGI_GetVCLK2Ptr(ModeNo, ModeIdIndex,
1167 RefreshRateTableIndex, HwDeviceExtension,
1169 data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF;
1170 xgifb_reg_set(pVBInfo->P3c4, 0x31, data);
1171 data = pVBInfo->VBVCLKData[vclkindex].Part4_A;
1172 xgifb_reg_set(pVBInfo->P3c4, 0x2B, data);
1173 data = pVBInfo->VBVCLKData[vclkindex].Part4_B;
1174 xgifb_reg_set(pVBInfo->P3c4, 0x2C, data);
1175 xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01);
1177 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1178 data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF;
1179 xgifb_reg_set(pVBInfo->P3c4, 0x31, data);
1180 xgifb_reg_set(pVBInfo->P3c4, 0x2B,
1181 pVBInfo->VCLKData[index].SR2B);
1182 xgifb_reg_set(pVBInfo->P3c4, 0x2C,
1183 pVBInfo->VCLKData[index].SR2C);
1184 xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01);
1187 if (HwDeviceExtension->jChipType >= XG20) {
1188 if (pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag &
1190 data = xgifb_reg_get(pVBInfo->P3c4, 0x2B);
1191 xgifb_reg_set(pVBInfo->P3c4, 0x2B, data);
1192 data = xgifb_reg_get(pVBInfo->P3c4, 0x2C);
1199 xgifb_reg_set(pVBInfo->P3c4, 0x2C, data);
1204 static void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo)
1208 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); /* D[0] 1: 18bit */
1209 temp = (temp & 1) << 6;
1210 /* SR06[6] 18bit Dither */
1211 xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x40, temp);
1212 /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */
1213 xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80);
1217 static void XGI_SetCRT1FIFO(unsigned short ModeNo,
1218 struct xgi_hw_device_info *HwDeviceExtension,
1219 struct vb_device_info *pVBInfo)
1221 unsigned short data;
1223 data = xgifb_reg_get(pVBInfo->P3c4, 0x3D);
1225 xgifb_reg_set(pVBInfo->P3c4, 0x3D, data); /* diable auto-threshold */
1227 xgifb_reg_set(pVBInfo->P3c4, 0x08, 0x34);
1228 data = xgifb_reg_get(pVBInfo->P3c4, 0x09);
1230 xgifb_reg_set(pVBInfo->P3c4, 0x09, data | 0x30);
1231 data = xgifb_reg_get(pVBInfo->P3c4, 0x3D);
1233 xgifb_reg_set(pVBInfo->P3c4, 0x3D, data);
1235 if (HwDeviceExtension->jChipType == XG21)
1236 XGI_SetXG21FPBits(pVBInfo); /* Fix SR9[7:6] can't read back */
1239 static void XGI_SetVCLKState(struct xgi_hw_device_info *HwDeviceExtension,
1240 unsigned short ModeNo, unsigned short RefreshRateTableIndex,
1241 struct vb_device_info *pVBInfo)
1243 unsigned short data, data2 = 0;
1246 unsigned char index;
1248 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1250 VCLK = pVBInfo->VCLKData[index].CLOCK;
1252 data = xgifb_reg_get(pVBInfo->P3c4, 0x32);
1255 data |= 0x0c; /* VCLK > 200 */
1257 if (HwDeviceExtension->jChipType >= XG20)
1258 data &= ~0x04; /* 2 pixel mode */
1260 xgifb_reg_set(pVBInfo->P3c4, 0x32, data);
1262 if (HwDeviceExtension->jChipType < XG20) {
1263 data = xgifb_reg_get(pVBInfo->P3c4, 0x1F);
1267 xgifb_reg_set(pVBInfo->P3c4, 0x1F, data);
1272 xgifb_reg_and_or(pVBInfo->P3c4, 0x07, 0xFC, data2);
1273 if (HwDeviceExtension->jChipType >= XG27)
1274 xgifb_reg_and_or(pVBInfo->P3c4, 0x40, 0xFC, data2 & 0x03);
1278 static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension,
1279 unsigned short ModeNo, unsigned short ModeIdIndex,
1280 unsigned short RefreshRateTableIndex,
1281 struct vb_device_info *pVBInfo)
1283 unsigned short data, data2, data3, infoflag = 0, modeflag, resindex,
1286 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1287 infoflag = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1289 if (xgifb_reg_get(pVBInfo->P3d4, 0x31) & 0x01)
1290 xgifb_reg_and_or(pVBInfo->P3c4, 0x1F, 0x3F, 0x00);
1295 data3 = pVBInfo->ModeType - ModeVGA;
1298 data &= InterlaceMode;
1303 xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x3F, data2);
1304 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
1305 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
1308 if (infoflag & InterlaceMode) {
1311 else if (xres == 1280)
1315 data2 = data & 0x00FF;
1316 xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFF, data2);
1317 data2 = (data & 0xFF00) >> 8;
1318 xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFC, data2);
1320 if (modeflag & HalfDCLK)
1321 xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xF7, 0x08);
1325 if (modeflag & LineCompareOff)
1328 xgifb_reg_and_or(pVBInfo->P3c4, 0x0F, ~0x48, data2);
1332 xgifb_reg_and_or(pVBInfo->P3c4, 0x21, 0x1F, data);
1334 XGI_SetVCLKState(HwDeviceExtension, ModeNo, RefreshRateTableIndex,
1337 data = xgifb_reg_get(pVBInfo->P3d4, 0x31);
1339 if (HwDeviceExtension->jChipType == XG27) {
1344 xgifb_reg_set(pVBInfo->P3d4, 0x52, data);
1345 xgifb_reg_or(pVBInfo->P3d4, 0x51, 0x10);
1346 } else if (HwDeviceExtension->jChipType >= XG20) {
1351 xgifb_reg_set(pVBInfo->P3d4, 0x52, data);
1352 xgifb_reg_set(pVBInfo->P3d4, 0x51, 0x02);
1358 xgifb_reg_set(pVBInfo->P3d4, 0x52, data);
1363 static void XGI_WriteDAC(unsigned short dl,
1367 struct vb_device_info *pVBInfo)
1369 unsigned short temp, bh, bl;
1388 outb((unsigned short) dh, pVBInfo->P3c9);
1389 outb((unsigned short) bh, pVBInfo->P3c9);
1390 outb((unsigned short) bl, pVBInfo->P3c9);
1393 static void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex,
1394 struct vb_device_info *pVBInfo)
1396 unsigned short data, data2, time, i, j, k, m, n, o, si, di, bx, dl, al,
1398 const unsigned short *table = NULL;
1400 data = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1401 data &= DACInfoFlag;
1405 table = XGINew_MDA_DAC;
1406 else if (data == 0x08)
1407 table = XGINew_CGA_DAC;
1408 else if (data == 0x10)
1409 table = XGINew_EGA_DAC;
1410 else if (data == 0x18) {
1412 table = XGINew_VGA_DAC;
1420 outb(0xFF, pVBInfo->P3c6);
1421 outb(0x00, pVBInfo->P3c8);
1423 for (i = 0; i < j; i++) {
1426 for (k = 0; k < 3; k++) {
1435 outb(data2, pVBInfo->P3c9);
1441 for (i = 16; i < 32; i++) {
1444 for (k = 0; k < 3; k++)
1445 outb(data, pVBInfo->P3c9);
1450 for (m = 0; m < 9; m++) {
1455 for (n = 0; n < 3; n++) {
1456 for (o = 0; o < 5; o++) {
1461 XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
1466 for (o = 0; o < 3; o++) {
1471 XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
1482 static void XGI_GetLVDSResInfo(unsigned short ModeNo,
1483 unsigned short ModeIdIndex,
1484 struct vb_device_info *pVBInfo)
1486 unsigned short resindex, xres, yres, modeflag;
1488 /* si+Ext_ResInfo */
1489 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
1491 /* si+Ext_ResInfo */
1492 resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
1494 xres = pVBInfo->ModeResInfo[resindex].HTotal;
1495 yres = pVBInfo->ModeResInfo[resindex].VTotal;
1497 if (modeflag & HalfDCLK)
1500 if (modeflag & DoubleScanMode)
1506 pVBInfo->VGAHDE = xres;
1507 pVBInfo->HDE = xres;
1508 pVBInfo->VGAVDE = yres;
1509 pVBInfo->VDE = yres;
1512 static void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo,
1513 unsigned short ModeIdIndex,
1514 unsigned short RefreshRateTableIndex,
1515 struct vb_device_info *pVBInfo)
1517 unsigned short i, tempdx, tempcx, tempbx, tempal, modeflag, table;
1519 struct XGI330_LCDDataTablStruct *tempdi = NULL;
1523 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1524 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
1526 tempal = tempal & 0x0f;
1528 if (tempbx <= 1) { /* ExpLink */
1529 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
1531 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
1532 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].
1537 tempal = (tempal >> 4);
1539 tempal = (tempal & 0x0f);
1542 tempcx = LCDLenList[tempbx];
1544 if (pVBInfo->LCDInfo & EnableScalingLCD) { /* ScaleLCD */
1545 if ((tempbx == 5) || (tempbx) == 7)
1546 tempcx = LCDDesDataLen2;
1547 else if ((tempbx == 3) || (tempbx == 8))
1548 tempcx = LVDSDesDataLen2;
1554 tempdi = xgifb_epllcd_crt1;
1557 tempdi = XGI_EPLLCDDataPtr;
1560 tempdi = XGI_EPLLCDDesDataPtr;
1563 tempdi = XGI_LCDDataTable;
1566 tempdi = XGI_LCDDesDataTable;
1569 tempdi = XGI_EPLCHLCDRegPtr;
1580 if (tempdi == NULL) /* OEMUtil */
1586 while (tempdi[i].PANELID != 0xff) {
1587 tempdx = pVBInfo->LCDResInfo;
1588 if (tempbx & 0x0080) { /* OEMUtil */
1589 tempbx &= (~0x0080);
1590 tempdx = pVBInfo->LCDTypeInfo;
1593 if (pVBInfo->LCDInfo & EnableScalingLCD)
1594 tempdx &= (~PanelResInfo);
1596 if (tempdi[i].PANELID == tempdx) {
1597 tempbx = tempdi[i].MASK;
1598 tempdx = pVBInfo->LCDInfo;
1600 if (modeflag & HalfDCLK)
1601 tempdx |= SetLCDLowResolution;
1604 if (tempbx == tempdi[i].CAP)
1611 switch (tempdi[i].DATAPTR) {
1613 return &XGI_LVDSCRT11024x768_1_H[tempal];
1616 return &XGI_LVDSCRT11024x768_2_H[tempal];
1619 return &XGI_LVDSCRT11280x1024_1_H[tempal];
1622 return &XGI_LVDSCRT11280x1024_2_H[tempal];
1625 return &XGI_LVDSCRT11400x1050_1_H[tempal];
1628 return &XGI_LVDSCRT11400x1050_2_H[tempal];
1631 return &XGI_LVDSCRT11600x1200_1_H[tempal];
1634 return &XGI_LVDSCRT11024x768_1_Hx75[tempal];
1637 return &XGI_LVDSCRT11024x768_2_Hx75[tempal];
1640 return &XGI_LVDSCRT11280x1024_1_Hx75[tempal];
1643 return &XGI_LVDSCRT11280x1024_2_Hx75[tempal];
1648 } else if (table == 1) {
1649 switch (tempdi[i].DATAPTR) {
1651 return &XGI_LVDSCRT11024x768_1_V[tempal];
1654 return &XGI_LVDSCRT11024x768_2_V[tempal];
1657 return &XGI_LVDSCRT11280x1024_1_V[tempal];
1660 return &XGI_LVDSCRT11280x1024_2_V[tempal];
1663 return &XGI_LVDSCRT11400x1050_1_V[tempal];
1666 return &XGI_LVDSCRT11400x1050_2_V[tempal];
1669 return &XGI_LVDSCRT11600x1200_1_V[tempal];
1672 return &XGI_LVDSCRT11024x768_1_Vx75[tempal];
1675 return &XGI_LVDSCRT11024x768_2_Vx75[tempal];
1678 return &XGI_LVDSCRT11280x1024_1_Vx75[tempal];
1681 return &XGI_LVDSCRT11280x1024_2_Vx75[tempal];
1686 } else if (table == 2) {
1687 switch (tempdi[i].DATAPTR) {
1689 return &XGI_LVDS1024x768Data_1[tempal];
1692 return &XGI_LVDS1024x768Data_2[tempal];
1695 return &XGI_LVDS1280x1024Data_1[tempal];
1698 return &XGI_LVDS1280x1024Data_2[tempal];
1701 return &XGI_LVDS1400x1050Data_1[tempal];
1704 return &XGI_LVDS1400x1050Data_2[tempal];
1707 return &XGI_LVDS1600x1200Data_1[tempal];
1710 return &XGI_LVDSNoScalingData[tempal];
1713 return &XGI_LVDS1024x768Data_1x75[tempal];
1716 return &XGI_LVDS1024x768Data_2x75[tempal];
1719 return &XGI_LVDS1280x1024Data_1x75[tempal];
1722 return &XGI_LVDS1280x1024Data_2x75[tempal];
1725 return &XGI_LVDSNoScalingDatax75[tempal];
1730 } else if (table == 3) {
1731 switch (tempdi[i].DATAPTR) {
1733 return &XGI_LVDS1024x768Des_1[tempal];
1736 return &XGI_LVDS1024x768Des_3[tempal];
1739 return &XGI_LVDS1024x768Des_2[tempal];
1742 return &XGI_LVDS1280x1024Des_1[tempal];
1745 return &XGI_LVDS1280x1024Des_2[tempal];
1748 return &XGI_LVDS1400x1050Des_1[tempal];
1751 return &XGI_LVDS1400x1050Des_2[tempal];
1754 return &XGI_LVDS1600x1200Des_1[tempal];
1757 return &XGI_LVDSNoScalingDesData[tempal];
1760 return &XGI_LVDS1024x768Des_1x75[tempal];
1763 return &XGI_LVDS1024x768Des_3x75[tempal];
1766 return &XGI_LVDS1024x768Des_2x75[tempal];
1769 return &XGI_LVDS1280x1024Des_1x75[tempal];
1772 return &XGI_LVDS1280x1024Des_2x75[tempal];
1775 return &XGI_LVDSNoScalingDesDatax75[tempal];
1780 } else if (table == 4) {
1781 switch (tempdi[i].DATAPTR) {
1783 return &XGI_ExtLCD1024x768Data[tempal];
1786 return &XGI_StLCD1024x768Data[tempal];
1789 return &XGI_CetLCD1024x768Data[tempal];
1792 return &XGI_ExtLCD1280x1024Data[tempal];
1795 return &XGI_StLCD1280x1024Data[tempal];
1798 return &XGI_CetLCD1280x1024Data[tempal];
1802 return &xgifb_lcd_1400x1050[tempal];
1805 return &XGI_CetLCD1400x1050Data[tempal];
1808 return &XGI_ExtLCD1600x1200Data[tempal];
1811 return &XGI_StLCD1600x1200Data[tempal];
1814 return &XGI_NoScalingData[tempal];
1817 return &XGI_ExtLCD1024x768x75Data[tempal];
1820 return &XGI_ExtLCD1024x768x75Data[tempal];
1823 return &XGI_CetLCD1024x768x75Data[tempal];
1827 return &xgifb_lcd_1280x1024x75[tempal];
1830 return &XGI_CetLCD1280x1024x75Data[tempal];
1833 return &XGI_NoScalingDatax75[tempal];
1838 } else if (table == 5) {
1839 switch (tempdi[i].DATAPTR) {
1841 return &XGI_ExtLCDDes1024x768Data[tempal];
1844 return &XGI_StLCDDes1024x768Data[tempal];
1847 return &XGI_CetLCDDes1024x768Data[tempal];
1850 if ((pVBInfo->VBType & VB_SIS301LV) ||
1851 (pVBInfo->VBType & VB_SIS302LV))
1852 return &XGI_ExtLCDDLDes1280x1024Data[tempal];
1854 return &XGI_ExtLCDDes1280x1024Data[tempal];
1857 if ((pVBInfo->VBType & VB_SIS301LV) ||
1858 (pVBInfo->VBType & VB_SIS302LV))
1859 return &XGI_StLCDDLDes1280x1024Data[tempal];
1861 return &XGI_StLCDDes1280x1024Data[tempal];
1864 if ((pVBInfo->VBType & VB_SIS301LV) ||
1865 (pVBInfo->VBType & VB_SIS302LV))
1866 return &XGI_CetLCDDLDes1280x1024Data[tempal];
1868 return &XGI_CetLCDDes1280x1024Data[tempal];
1872 if ((pVBInfo->VBType & VB_SIS301LV) ||
1873 (pVBInfo->VBType & VB_SIS302LV))
1874 return &xgifb_lcddldes_1400x1050[tempal];
1876 return &xgifb_lcddes_1400x1050[tempal];
1879 return &XGI_CetLCDDes1400x1050Data[tempal];
1882 return &XGI_CetLCDDes1400x1050Data2[tempal];
1885 if ((pVBInfo->VBType & VB_SIS301LV) ||
1886 (pVBInfo->VBType & VB_SIS302LV))
1887 return &XGI_ExtLCDDLDes1600x1200Data[tempal];
1889 return &XGI_ExtLCDDes1600x1200Data[tempal];
1892 if ((pVBInfo->VBType & VB_SIS301LV) ||
1893 (pVBInfo->VBType & VB_SIS302LV))
1894 return &XGI_StLCDDLDes1600x1200Data[tempal];
1896 return &XGI_StLCDDes1600x1200Data[tempal];
1899 return &XGI_NoScalingDesData[tempal];
1903 return &xgifb_lcddes_1024x768x75[tempal];
1906 return &XGI_CetLCDDes1024x768x75Data[tempal];
1910 if ((pVBInfo->VBType & VB_SIS301LV) ||
1911 (pVBInfo->VBType & VB_SIS302LV))
1912 return &xgifb_lcddldes_1280x1024x75[tempal];
1914 return &xgifb_lcddes_1280x1024x75[tempal];
1917 if ((pVBInfo->VBType & VB_SIS301LV) ||
1918 (pVBInfo->VBType & VB_SIS302LV))
1919 return &XGI_CetLCDDLDes1280x1024x75Data[tempal];
1921 return &XGI_CetLCDDes1280x1024x75Data[tempal];
1924 return &XGI_NoScalingDesDatax75[tempal];
1929 } else if (table == 6) {
1930 switch (tempdi[i].DATAPTR) {
1932 return &XGI_CH7017LV1024x768[tempal];
1935 return &XGI_CH7017LV1400x1050[tempal];
1944 static void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo,
1945 unsigned short ModeIdIndex,
1946 unsigned short RefreshRateTableIndex,
1947 struct vb_device_info *pVBInfo)
1949 unsigned short i, tempdx, tempbx, tempal, modeflag, table;
1950 struct XGI330_TVDataTablStruct *tempdi = NULL;
1953 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1954 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
1955 tempal = tempal & 0x3f;
1967 tempdi = xgifb_chrontel_tv;
1973 tempdi = XGI_TVDataTable;
1982 if (tempdi == NULL) /* OEMUtil */
1985 tempdx = pVBInfo->TVInfo;
1987 if (pVBInfo->VBInfo & SetInSlaveMode)
1988 tempdx = tempdx | SetTVLockMode;
1990 if (modeflag & HalfDCLK)
1991 tempdx = tempdx | SetTVLowResolution;
1995 while (tempdi[i].MASK != 0xffff) {
1996 if ((tempdx & tempdi[i].MASK) == tempdi[i].CAP)
2002 if (table == 0x04) {
2003 switch (tempdi[i].DATAPTR) {
2005 return &XGI_ExtPALData[tempal];
2008 return &XGI_ExtNTSCData[tempal];
2011 return &XGI_StPALData[tempal];
2014 return &XGI_StNTSCData[tempal];
2017 return &XGI_ExtHiTVData[tempal];
2020 return &XGI_St2HiTVData[tempal];
2023 return &XGI_ExtYPbPr525iData[tempal];
2026 return &XGI_ExtYPbPr525pData[tempal];
2029 return &XGI_ExtYPbPr750pData[tempal];
2032 return &XGI_StYPbPr525iData[tempal];
2035 return &XGI_StYPbPr525pData[tempal];
2038 return &XGI_StYPbPr750pData[tempal];
2040 case 12: /* avoid system hang */
2041 return &XGI_ExtNTSCData[tempal];
2044 return &XGI_St1HiTVData[tempal];
2049 } else if (table == 0x02) {
2050 switch (tempdi[i].DATAPTR) {
2052 return &XGI_CHTVUNTSCData[tempal];
2055 return &XGI_CHTVONTSCData[tempal];
2058 return &XGI_CHTVUPALData[tempal];
2061 return &XGI_CHTVOPALData[tempal];
2070 static void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex,
2071 unsigned short RefreshRateTableIndex,
2072 struct vb_device_info *pVBInfo)
2074 unsigned short tempbx;
2075 struct XGI330_LVDSDataStruct *LCDPtr = NULL;
2079 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
2080 LCDPtr = (struct XGI330_LVDSDataStruct *) XGI_GetLcdPtr(tempbx,
2081 ModeNo, ModeIdIndex, RefreshRateTableIndex,
2083 pVBInfo->VGAHT = LCDPtr->VGAHT;
2084 pVBInfo->VGAVT = LCDPtr->VGAVT;
2085 pVBInfo->HT = LCDPtr->LCDHT;
2086 pVBInfo->VT = LCDPtr->LCDVT;
2089 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
2090 if (!(pVBInfo->LCDInfo & (SetLCDtoNonExpanding
2091 | EnableScalingLCD))) {
2092 if ((pVBInfo->LCDResInfo == Panel_1024x768) ||
2093 (pVBInfo->LCDResInfo == Panel_1024x768x75)) {
2094 pVBInfo->HDE = 1024;
2096 } else if ((pVBInfo->LCDResInfo == Panel_1280x1024) ||
2097 (pVBInfo->LCDResInfo == Panel_1280x1024x75)) {
2098 pVBInfo->HDE = 1280;
2099 pVBInfo->VDE = 1024;
2100 } else if (pVBInfo->LCDResInfo == Panel_1400x1050) {
2101 pVBInfo->HDE = 1400;
2102 pVBInfo->VDE = 1050;
2104 pVBInfo->HDE = 1600;
2105 pVBInfo->VDE = 1200;
2111 static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex,
2112 unsigned short RefreshRateTableIndex,
2113 struct xgi_hw_device_info *HwDeviceExtension,
2114 struct vb_device_info *pVBInfo)
2116 unsigned char index;
2117 unsigned short tempbx, i;
2118 struct XGI_LVDSCRT1HDataStruct *LCDPtr = NULL;
2119 struct XGI_LVDSCRT1VDataStruct *LCDPtr1 = NULL;
2121 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
2122 index = index & IndexMask;
2126 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
2127 LCDPtr = (struct XGI_LVDSCRT1HDataStruct *)
2128 XGI_GetLcdPtr(tempbx, ModeNo,
2130 RefreshRateTableIndex,
2133 for (i = 0; i < 8; i++)
2134 pVBInfo->TimingH[0].data[i] = LCDPtr[0].Reg[i];
2137 XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension);
2141 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
2142 LCDPtr1 = (struct XGI_LVDSCRT1VDataStruct *)
2147 RefreshRateTableIndex,
2149 for (i = 0; i < 7; i++)
2150 pVBInfo->TimingV[0].data[i] = LCDPtr1[0].Reg[i];
2153 XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo);
2156 static unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo)
2158 unsigned char tempal, tempah, tempbl, i;
2160 tempah = xgifb_reg_get(pVBInfo->P3d4, 0x36);
2161 tempal = tempah & 0x0F;
2162 tempah = tempah & 0xF0;
2164 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
2166 while (tempbl != 0xFF) {
2167 if (tempbl & 0x80) { /* OEMUtil */
2169 tempbl = tempbl & ~(0x80);
2172 if (tempal == tempbl)
2177 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
2183 static unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo)
2185 unsigned short tempah, tempal, tempbl, i;
2187 tempal = pVBInfo->LCDResInfo;
2188 tempah = pVBInfo->LCDTypeInfo;
2191 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
2193 while (tempbl != 0xFF) {
2194 if ((tempbl & 0x80) && (tempbl != 0x80)) {
2199 if (tempal == tempbl)
2203 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
2206 if (tempbl == 0xFF) {
2207 pVBInfo->LCDResInfo = Panel_1024x768;
2208 pVBInfo->LCDTypeInfo = 0;
2215 static void XGI_GetLCDSync(unsigned short *HSyncWidth,
2216 unsigned short *VSyncWidth,
2217 struct vb_device_info *pVBInfo)
2219 unsigned short Index;
2221 Index = XGI_GetLCDCapPtr(pVBInfo);
2222 *HSyncWidth = pVBInfo->LCDCapList[Index].LCD_HSyncWidth;
2223 *VSyncWidth = pVBInfo->LCDCapList[Index].LCD_VSyncWidth;
2228 static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
2229 unsigned short RefreshRateTableIndex,
2230 struct vb_device_info *pVBInfo)
2232 unsigned short tempbx, tempax, tempcx, tempdx, push1, push2, modeflag;
2233 unsigned long temp, temp1, temp2, temp3, push3;
2234 struct XGI330_LCDDataDesStruct *LCDPtr = NULL;
2235 struct XGI330_LCDDataDesStruct2 *LCDPtr1 = NULL;
2237 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2239 if (pVBInfo->LCDInfo & EnableScalingLCD)
2241 (struct XGI330_LCDDataDesStruct2 *)
2246 RefreshRateTableIndex,
2250 (struct XGI330_LCDDataDesStruct *)
2255 RefreshRateTableIndex,
2258 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
2263 if ((pVBInfo->LCDResInfo == Panel_1024x768) ||
2264 (pVBInfo->LCDResInfo == Panel_1024x768x75)) {
2267 } else if ((pVBInfo->LCDResInfo == Panel_1280x1024) ||
2268 (pVBInfo->LCDResInfo == Panel_1280x1024x75)) {
2271 } else if (pVBInfo->LCDResInfo == Panel_1400x1050) {
2279 if (pVBInfo->LCDInfo & SetLCDtoNonExpanding) {
2280 pVBInfo->HDE = tempax;
2281 pVBInfo->VDE = tempbx;
2282 pVBInfo->VGAHDE = tempax;
2283 pVBInfo->VGAVDE = tempbx;
2286 tempax = pVBInfo->HT;
2288 if (pVBInfo->LCDInfo & EnableScalingLCD)
2289 tempbx = LCDPtr1->LCDHDES;
2291 tempbx = LCDPtr->LCDHDES;
2293 tempcx = pVBInfo->HDE;
2294 tempbx = tempbx & 0x0fff;
2297 if (tempcx >= tempax)
2300 xgifb_reg_set(pVBInfo->Part1Port, 0x1A, tempbx & 0x07);
2302 tempcx = tempcx >> 3;
2303 tempbx = tempbx >> 3;
2305 xgifb_reg_set(pVBInfo->Part1Port, 0x16,
2306 (unsigned short) (tempbx & 0xff));
2307 xgifb_reg_set(pVBInfo->Part1Port, 0x17,
2308 (unsigned short) (tempcx & 0xff));
2310 tempax = pVBInfo->HT;
2312 if (pVBInfo->LCDInfo & EnableScalingLCD)
2313 tempbx = LCDPtr1->LCDHRS;
2315 tempbx = LCDPtr->LCDHRS;
2319 if (pVBInfo->LCDInfo & EnableScalingLCD)
2320 tempcx = LCDPtr1->LCDHSync;
2324 if (tempcx >= tempax)
2327 tempax = tempbx & 0x07;
2328 tempax = tempax >> 5;
2329 tempcx = tempcx >> 3;
2330 tempbx = tempbx >> 3;
2335 xgifb_reg_set(pVBInfo->Part1Port, 0x15, tempax);
2336 xgifb_reg_set(pVBInfo->Part1Port, 0x14,
2337 (unsigned short) (tempbx & 0xff));
2339 tempax = pVBInfo->VT;
2340 if (pVBInfo->LCDInfo & EnableScalingLCD)
2341 tempbx = LCDPtr1->LCDVDES;
2343 tempbx = LCDPtr->LCDVDES;
2344 tempcx = pVBInfo->VDE;
2346 tempbx = tempbx & 0x0fff;
2348 if (tempcx >= tempax)
2351 xgifb_reg_set(pVBInfo->Part1Port, 0x1b,
2352 (unsigned short) (tempbx & 0xff));
2353 xgifb_reg_set(pVBInfo->Part1Port, 0x1c,
2354 (unsigned short) (tempcx & 0xff));
2356 tempbx = (tempbx >> 8) & 0x07;
2357 tempcx = (tempcx >> 8) & 0x07;
2359 xgifb_reg_set(pVBInfo->Part1Port, 0x1d,
2360 (unsigned short) ((tempcx << 3)
2363 tempax = pVBInfo->VT;
2364 if (pVBInfo->LCDInfo & EnableScalingLCD)
2365 tempbx = LCDPtr1->LCDVRS;
2367 tempbx = LCDPtr->LCDVRS;
2371 if (pVBInfo->LCDInfo & EnableScalingLCD)
2372 tempcx = LCDPtr1->LCDVSync;
2375 if (tempcx >= tempax)
2378 xgifb_reg_set(pVBInfo->Part1Port, 0x18,
2379 (unsigned short) (tempbx & 0xff));
2380 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, ~0x0f,
2381 (unsigned short) (tempcx & 0x0f));
2383 tempax = ((tempbx >> 8) & 0x07) << 3;
2385 tempbx = pVBInfo->VGAVDE;
2386 if (tempbx != pVBInfo->VDE)
2389 if (pVBInfo->LCDInfo & XGI_EnableLVDSDDA)
2392 xgifb_reg_and_or(pVBInfo->Part1Port, 0x1a, 0x07,
2395 tempcx = pVBInfo->VGAVT;
2396 tempbx = pVBInfo->VDE;
2397 tempax = pVBInfo->VGAVDE;
2400 temp = tempax; /* 0430 ylshieh */
2401 temp1 = (temp << 18) / tempbx;
2403 tempdx = (unsigned short) ((temp << 18) % tempbx);
2411 xgifb_reg_set(pVBInfo->Part1Port, 0x37,
2412 (unsigned short) (temp2 & 0xff));
2413 xgifb_reg_set(pVBInfo->Part1Port, 0x36,
2414 (unsigned short) ((temp2 >> 8) & 0xff));
2416 tempbx = (unsigned short) (temp2 >> 16);
2417 tempax = tempbx & 0x03;
2419 tempbx = pVBInfo->VGAVDE;
2420 if (tempbx == pVBInfo->VDE)
2423 xgifb_reg_set(pVBInfo->Part1Port, 0x35, tempax);
2425 if (pVBInfo->VBType & VB_XGI301C) {
2427 xgifb_reg_set(pVBInfo->Part4Port,
2429 (unsigned short) (temp2 & 0xff));
2430 xgifb_reg_set(pVBInfo->Part4Port,
2432 (unsigned short) ((temp2 >> 8) &
2434 tempbx = (unsigned short) (temp2 >> 16);
2435 xgifb_reg_and_or(pVBInfo->Part4Port, 0x3a,
2437 (unsigned short) ((tempbx &
2440 tempcx = pVBInfo->VGAVDE;
2441 if (tempcx == pVBInfo->VDE)
2442 xgifb_reg_and_or(pVBInfo->Part4Port,
2445 xgifb_reg_and_or(pVBInfo->Part4Port,
2449 tempcx = pVBInfo->VGAHDE;
2450 tempbx = pVBInfo->HDE;
2452 temp1 = tempcx << 16;
2454 tempax = (unsigned short) (temp1 / tempbx);
2456 if ((tempbx & 0xffff) == (tempcx & 0xffff))
2460 temp1 = pVBInfo->VGAHDE << 16;
2463 temp3 = temp3 << 16;
2466 temp3 = (temp3 & 0xffff0000) + (temp1 & 0xffff);
2468 tempax = (unsigned short) (temp3 & 0xff);
2469 xgifb_reg_set(pVBInfo->Part1Port, 0x1f, tempax);
2471 temp1 = pVBInfo->VGAVDE << 18;
2472 temp1 = temp1 / push3;
2473 tempbx = (unsigned short) (temp1 & 0xffff);
2475 if (pVBInfo->LCDResInfo == Panel_1024x768)
2478 tempax = ((tempbx >> 8) & 0xff) << 3;
2479 tempax |= (unsigned short) ((temp3 >> 8) & 0x07);
2480 xgifb_reg_set(pVBInfo->Part1Port, 0x20,
2481 (unsigned short) (tempax & 0xff));
2482 xgifb_reg_set(pVBInfo->Part1Port, 0x21,
2483 (unsigned short) (tempbx & 0xff));
2485 temp3 = temp3 >> 16;
2487 if (modeflag & HalfDCLK)
2490 xgifb_reg_set(pVBInfo->Part1Port, 0x22,
2491 (unsigned short) ((temp3 >> 8) & 0xff));
2492 xgifb_reg_set(pVBInfo->Part1Port, 0x23,
2493 (unsigned short) (temp3 & 0xff));
2496 /* --------------------------------------------------------------------- */
2497 /* Function : XGI_GETLCDVCLKPtr */
2499 /* Output : al -> VCLK Index */
2501 /* --------------------------------------------------------------------- */
2502 static void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1,
2503 struct vb_device_info *pVBInfo)
2505 unsigned short index;
2507 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
2508 index = XGI_GetLCDCapPtr1(pVBInfo);
2510 if (pVBInfo->VBInfo & SetCRT2ToLCD) { /* LCDB */
2511 *di_0 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData1;
2512 *di_1 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData2;
2514 *di_0 = pVBInfo->LCDCapList[index].LCDA_VCLKData1;
2515 *di_1 = pVBInfo->LCDCapList[index].LCDA_VCLKData2;
2521 static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex,
2522 unsigned short ModeNo, unsigned short ModeIdIndex,
2523 struct vb_device_info *pVBInfo)
2526 unsigned short index, modeflag;
2527 unsigned char tempal;
2529 /* si+Ext_ResInfo */
2530 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2532 if ((pVBInfo->SetFlag & ProgrammingCRT2) &&
2533 (!(pVBInfo->LCDInfo & EnableScalingLCD))) { /* {LCDA/LCDB} */
2534 index = XGI_GetLCDCapPtr(pVBInfo);
2535 tempal = pVBInfo->LCDCapList[index].LCD_VCLK;
2537 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))
2541 if (pVBInfo->VBType &
2547 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
2548 tempal = TVCLKBASE_315 + HiTVVCLKDIV2;
2549 if (!(pVBInfo->TVInfo & RPLLDIV2XO))
2550 tempal = TVCLKBASE_315 + HiTVVCLK;
2551 if (pVBInfo->TVInfo & TVSimuMode) {
2552 tempal = TVCLKBASE_315 + HiTVSimuVCLK;
2553 if (!(modeflag & Charx8Dot))
2554 tempal = TVCLKBASE_315 + HiTVTextVCLK;
2560 if (pVBInfo->TVInfo & TVSetYPbPr750p) {
2561 tempal = XGI_YPbPr750pVCLK;
2565 if (pVBInfo->TVInfo & TVSetYPbPr525p) {
2566 tempal = YPbPr525pVCLK;
2570 tempal = NTSC1024VCLK;
2572 if (!(pVBInfo->TVInfo & NTSC1024x768)) {
2573 tempal = TVCLKBASE_315 + TVVCLKDIV2;
2574 if (!(pVBInfo->TVInfo & RPLLDIV2XO))
2575 tempal = TVCLKBASE_315 + TVVCLK;
2578 if (pVBInfo->VBInfo & SetCRT2ToTV)
2583 tempal = (unsigned char) inb((pVBInfo->P3ca + 0x02));
2584 tempal = tempal >> 2;
2587 /* for Dot8 Scaling LCD */
2588 if ((pVBInfo->LCDInfo & EnableScalingLCD) && (modeflag & Charx8Dot))
2589 tempal = tempal ^ tempal; /* ; set to VCLK25MHz always */
2591 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
2595 static void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0,
2596 unsigned char *di_1, struct vb_device_info *pVBInfo)
2598 if (pVBInfo->VBType & (VB_SIS301 | VB_SIS301B | VB_SIS302B
2599 | VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) {
2600 if ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) && (pVBInfo->SetFlag
2601 & ProgrammingCRT2)) {
2602 *di_0 = (unsigned char) XGI_VBVCLKData[tempal].SR2B;
2603 *di_1 = XGI_VBVCLKData[tempal].SR2C;
2606 *di_0 = XGI_VCLKData[tempal].SR2B;
2607 *di_1 = XGI_VCLKData[tempal].SR2C;
2611 static void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex,
2612 unsigned short RefreshRateTableIndex,
2613 struct vb_device_info *pVBInfo)
2615 unsigned char di_0, di_1, tempal;
2618 tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex,
2620 XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo);
2621 XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo);
2623 for (i = 0; i < 4; i++) {
2624 xgifb_reg_and_or(pVBInfo->P3d4, 0x31, ~0x30,
2625 (unsigned short) (0x10 * i));
2626 if ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA))
2627 && (!(pVBInfo->VBInfo & SetInSlaveMode))) {
2628 xgifb_reg_set(pVBInfo->P3c4, 0x2e, di_0);
2629 xgifb_reg_set(pVBInfo->P3c4, 0x2f, di_1);
2631 xgifb_reg_set(pVBInfo->P3c4, 0x2b, di_0);
2632 xgifb_reg_set(pVBInfo->P3c4, 0x2c, di_1);
2637 static void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension,
2638 struct vb_device_info *pVBInfo)
2640 unsigned short tempcl, tempch, temp, tempbl, tempax;
2642 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
2643 | VB_SIS302LV | VB_XGI301C)) {
2646 temp = xgifb_reg_get(pVBInfo->P3c4, 0x01);
2648 if (!(temp & 0x20)) {
2649 temp = xgifb_reg_get(pVBInfo->P3d4, 0x17);
2651 temp = xgifb_reg_get(pVBInfo->P3d4, 0x53);
2653 tempcl |= ActiveCRT1;
2657 temp = xgifb_reg_get(pVBInfo->Part1Port, 0x2e);
2660 if (!(temp == 0x08)) {
2661 /* Check ChannelA by Part1_13 [2003/10/03] */
2662 tempax = xgifb_reg_get(pVBInfo->Part1Port, 0x13);
2664 tempcl = tempcl | ActiveLCD;
2668 if (!(tempcl & ActiveLCD))
2670 tempcl |= ActiveCRT2;
2673 tempcl |= ActiveLCD;
2676 temp = xgifb_reg_get(pVBInfo->Part2Port, 0x00);
2679 tempch |= ActiveAVideo;
2682 tempch |= ActiveSVideo;
2685 tempch |= ActiveSCART;
2687 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
2689 tempch |= ActiveHiTV;
2692 if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
2693 temp = xgifb_reg_get(
2698 tempch |= ActiveYPbPr;
2706 temp = xgifb_reg_get(pVBInfo->P3d4, 0x3d);
2707 if (tempcl & ActiveLCD) {
2708 if ((pVBInfo->SetFlag & ReserveTVOption)) {
2709 if (temp & ActiveTV)
2714 tempbl = ~XGI_ModeSwitchStatus;
2715 xgifb_reg_and_or(pVBInfo->P3d4, 0x3d, tempbl, temp);
2717 if (!(pVBInfo->SetFlag & ReserveTVOption))
2718 xgifb_reg_set(pVBInfo->P3d4, 0x3e, tempch);
2724 void XGI_GetVBType(struct vb_device_info *pVBInfo)
2726 unsigned short flag, tempbx, tempah;
2728 if (pVBInfo->IF_DEF_LVDS == 0) {
2729 tempbx = VB_SIS302B;
2730 flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00);
2733 flag = xgifb_reg_get(pVBInfo->Part4Port, 0x01);
2735 tempbx = VB_SIS301B;
2737 tempbx = VB_XGI301C;
2739 tempbx = VB_SIS301LV;
2741 tempbx = VB_SIS302LV;
2742 tempah = xgifb_reg_get(
2752 if (tempbx & (VB_SIS301B | VB_SIS302B)) {
2753 flag = xgifb_reg_get(
2758 tempbx = tempbx | VB_NoLCD;
2762 pVBInfo->VBType = tempbx;
2766 static void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
2767 struct xgi_hw_device_info *HwDeviceExtension,
2768 struct vb_device_info *pVBInfo)
2770 unsigned short tempax, push, tempbx, temp, modeflag;
2772 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2773 pVBInfo->SetFlag = 0;
2774 pVBInfo->ModeType = modeflag & ModeTypeMask;
2777 if (pVBInfo->VBType & 0xFFFF) {
2778 /* Check Display Device */
2779 temp = xgifb_reg_get(pVBInfo->P3d4, 0x30);
2780 tempbx = tempbx | temp;
2781 temp = xgifb_reg_get(pVBInfo->P3d4, 0x31);
2785 tempbx = tempbx | tempax;
2786 temp = (SetCRT2ToDualEdge | SetCRT2ToYPbPr525750 | XGI_SetCRT2ToLCDA
2787 | SetInSlaveMode | DisableCRT2Display);
2788 temp = 0xFFFF ^ temp;
2791 temp = xgifb_reg_get(pVBInfo->P3d4, 0x38);
2793 if (pVBInfo->IF_DEF_LCDA == 1) {
2795 if ((HwDeviceExtension->jChipType >= XG20) ||
2796 (HwDeviceExtension->jChipType >= XG40)) {
2797 if (pVBInfo->IF_DEF_LVDS == 0) {
2798 if (pVBInfo->VBType &
2803 if (temp & EnableDualEdge) {
2807 if (temp & SetToLCDA)
2816 if (pVBInfo->IF_DEF_YPbPr == 1) {
2817 /* [Billy] 07/05/04 */
2818 if (((pVBInfo->IF_DEF_LVDS == 0) &&
2819 ((pVBInfo->VBType & VB_SIS301LV) ||
2820 (pVBInfo->VBType & VB_SIS302LV) ||
2821 (pVBInfo->VBType & VB_XGI301C)))) {
2822 if (temp & SetYPbPr) {
2823 if (pVBInfo->IF_DEF_HiVision == 1) {
2824 /* shampoo add for new
2826 temp = xgifb_reg_get(
2830 tempbx |= SetCRT2ToHiVision;
2832 if (temp != YPbPrMode1080i) {
2834 (~SetCRT2ToHiVision);
2836 SetCRT2ToYPbPr525750;
2843 tempax = push; /* restore CR31 */
2845 if (pVBInfo->IF_DEF_LVDS == 0) {
2846 if (pVBInfo->IF_DEF_YPbPr == 1) {
2847 if (pVBInfo->IF_DEF_HiVision == 1)
2852 if (pVBInfo->IF_DEF_HiVision == 1)
2857 } else { /* 3nd party chip */
2858 temp = SetCRT2ToLCD;
2861 if (!(tempbx & temp)) {
2862 tempax |= DisableCRT2Display;
2866 if (pVBInfo->IF_DEF_LCDA == 1) { /* Select Display Device */
2867 if (!(pVBInfo->VBType & VB_NoLCD)) {
2868 if (tempbx & XGI_SetCRT2ToLCDA) {
2869 if (tempbx & SetSimuScanMode)
2870 tempbx &= (~(SetCRT2ToLCD |
2874 tempbx &= (~(SetCRT2ToLCD |
2883 /* for driver abnormal */
2884 if (!(tempbx & (SwitchCRT2 | SetSimuScanMode))) {
2885 if (pVBInfo->IF_DEF_CRT2Monitor == 1) {
2886 if (tempbx & SetCRT2ToRAMDAC) {
2891 tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750));
2894 tempbx &= (~(SetCRT2ToRAMDAC |
2900 if (!(pVBInfo->VBType & VB_NoLCD)) {
2901 if (tempbx & SetCRT2ToLCD) {
2906 tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750));
2910 if (tempbx & SetCRT2ToSCART) {
2915 tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750));
2918 if (pVBInfo->IF_DEF_YPbPr == 1) {
2919 if (tempbx & SetCRT2ToYPbPr525750)
2925 if (pVBInfo->IF_DEF_HiVision == 1) {
2926 if (tempbx & SetCRT2ToHiVision)
2933 if (tempax & DisableCRT2Display) { /* Set Display Device Info */
2934 if (!(tempbx & (SwitchCRT2 | SetSimuScanMode)))
2935 tempbx = DisableCRT2Display;
2938 if (!(tempbx & DisableCRT2Display)) {
2939 if ((!(tempbx & DriverMode)) ||
2940 (!(modeflag & CRT2Mode))) {
2941 if (pVBInfo->IF_DEF_LCDA == 1) {
2942 if (!(tempbx & XGI_SetCRT2ToLCDA))
2943 tempbx |= (SetInSlaveMode |
2948 /* LCD+TV can't support in slave mode
2949 * (Force LCDA+TV->LCDB) */
2950 if ((tempbx & SetInSlaveMode) &&
2951 (tempbx & XGI_SetCRT2ToLCDA)) {
2952 tempbx ^= (SetCRT2ToLCD |
2955 pVBInfo->SetFlag |= ReserveTVOption;
2960 pVBInfo->VBInfo = tempbx;
2963 static void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
2964 struct vb_device_info *pVBInfo)
2966 unsigned short temp, tempbx = 0, resinfo = 0, modeflag, index1;
2971 if (pVBInfo->VBInfo & SetCRT2ToTV) {
2972 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2973 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
2975 if (pVBInfo->VBInfo & SetCRT2ToTV) {
2976 temp = xgifb_reg_get(pVBInfo->P3d4, 0x35);
2978 if (tempbx & TVSetPAL) {
2979 tempbx &= (SetCHTVOverScan |
2983 if (tempbx & TVSetPALM)
2984 /* set to NTSC if PAL-M */
2985 tempbx &= ~TVSetPAL;
2987 tempbx &= (SetCHTVOverScan |
2992 if (pVBInfo->IF_DEF_LVDS == 0) {
2993 if (pVBInfo->VBInfo & SetCRT2ToSCART)
2997 if (pVBInfo->IF_DEF_YPbPr == 1) {
2998 if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
2999 index1 = xgifb_reg_get(pVBInfo->P3d4, 0x35);
3000 index1 &= YPbPrMode;
3002 if (index1 == YPbPrMode525i)
3003 tempbx |= TVSetYPbPr525i;
3005 if (index1 == YPbPrMode525p)
3006 tempbx = tempbx | TVSetYPbPr525p;
3007 if (index1 == YPbPrMode750p)
3008 tempbx = tempbx | TVSetYPbPr750p;
3012 if (pVBInfo->IF_DEF_HiVision == 1) {
3013 if (pVBInfo->VBInfo & SetCRT2ToHiVision)
3014 tempbx = tempbx | TVSetHiVision | TVSetPAL;
3017 if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */
3018 if ((pVBInfo->VBInfo & SetInSlaveMode) &&
3019 (!(pVBInfo->VBInfo & SetNotSimuMode)))
3020 tempbx |= TVSimuMode;
3022 if (!(tempbx & TVSetPAL) &&
3024 (resinfo == 8)) /* NTSC 1024x768, */
3025 tempbx |= NTSC1024x768;
3027 tempbx |= RPLLDIV2XO;
3029 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
3030 if (pVBInfo->VBInfo & SetInSlaveMode)
3031 tempbx &= (~RPLLDIV2XO);
3034 (TVSetYPbPr525p | TVSetYPbPr750p))
3035 tempbx &= (~RPLLDIV2XO);
3036 else if (!(pVBInfo->VBType &
3042 if (tempbx & TVSimuMode)
3043 tempbx &= (~RPLLDIV2XO);
3048 pVBInfo->TVInfo = tempbx;
3051 static unsigned char XGI_GetLCDInfo(unsigned short ModeNo,
3052 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
3054 unsigned short temp, tempax, tempbx, modeflag, resinfo = 0, LCDIdIndex;
3056 pVBInfo->LCDResInfo = 0;
3057 pVBInfo->LCDTypeInfo = 0;
3058 pVBInfo->LCDInfo = 0;
3060 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3061 /* si+Ext_ResInfo // */
3062 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
3063 temp = xgifb_reg_get(pVBInfo->P3d4, 0x36); /* Get LCD Res.Info */
3064 tempbx = temp & 0x0F;
3067 tempbx = Panel_1024x768; /* default */
3069 /* LCD75 [2003/8/22] Vicent */
3070 if ((tempbx == Panel_1024x768) || (tempbx == Panel_1280x1024)) {
3071 if (pVBInfo->VBInfo & DriverMode) {
3072 tempax = xgifb_reg_get(pVBInfo->P3d4, 0x33);
3073 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)
3076 tempax = tempax >> 4;
3078 if ((resinfo == 6) || (resinfo == 9)) {
3080 tempbx |= PanelRef75Hz;
3081 } else if ((resinfo == 7) || (resinfo == 8)) {
3083 tempbx |= PanelRef75Hz;
3088 pVBInfo->LCDResInfo = tempbx;
3092 if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)))
3097 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
3099 temp &= (ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable);
3103 LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo);
3105 tempax = pVBInfo->LCDCapList[LCDIdIndex].LCD_Capability;
3107 if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */
3108 if (((pVBInfo->VBType & VB_SIS302LV) || (pVBInfo->VBType
3109 & VB_XGI301C)) && (tempax & XGI_LCDDualLink)) {
3110 tempbx |= SetLCDDualLink;
3114 if (pVBInfo->IF_DEF_LVDS == 0) {
3115 if ((pVBInfo->LCDResInfo == Panel_1400x1050) && (pVBInfo->VBInfo
3116 & SetCRT2ToLCD) && (resinfo == 9) &&
3117 (!(tempbx & EnableScalingLCD)))
3118 /* set to center in 1280x1024 LCDB for Panel_1400x1050 */
3119 tempbx |= SetLCDtoNonExpanding;
3122 if (pVBInfo->IF_DEF_ExpLink == 1) {
3123 if (modeflag & HalfDCLK) {
3124 if (!(tempbx & SetLCDtoNonExpanding)) {
3125 tempbx |= XGI_EnableLVDSDDA;
3127 if (pVBInfo->LCDResInfo == Panel_1024x768) {
3128 if (resinfo == 4) {/* 512x384 */
3129 tempbx |= XGI_EnableLVDSDDA;
3136 if (pVBInfo->VBInfo & SetInSlaveMode) {
3137 if (pVBInfo->VBInfo & SetNotSimuMode)
3138 tempbx |= XGI_LCDVESATiming;
3140 tempbx |= XGI_LCDVESATiming;
3143 pVBInfo->LCDInfo = tempbx;
3148 unsigned char XGI_SearchModeID(unsigned short ModeNo,
3149 unsigned short *ModeIdIndex, struct vb_device_info *pVBInfo)
3151 for (*ModeIdIndex = 0;; (*ModeIdIndex)++) {
3152 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == ModeNo)
3154 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == 0xFF)
3161 static unsigned char XG21GPIODataTransfer(unsigned char ujDate)
3163 unsigned char ujRet = 0;
3164 unsigned char i = 0;
3166 for (i = 0; i < 8; i++) {
3168 ujRet |= (ujDate >> i) & 1;
3174 /*----------------------------------------------------------------------------*/
3176 /* bl[5] : LVDS signal */
3177 /* bl[1] : LVDS backlight */
3178 /* bl[0] : LVDS VDD */
3179 /*----------------------------------------------------------------------------*/
3180 static unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo)
3182 unsigned char CR4A, temp;
3184 CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
3185 xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x23); /* enable GPIO write */
3187 temp = xgifb_reg_get(pVBInfo->P3d4, 0x48);
3189 temp = XG21GPIODataTransfer(temp);
3191 xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A);
3195 /*----------------------------------------------------------------------------*/
3197 /* bl[5] : LVDS signal */
3198 /* bl[1] : LVDS backlight */
3199 /* bl[0] : LVDS VDD */
3200 /*----------------------------------------------------------------------------*/
3201 static unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo)
3203 unsigned char CR4A, CRB4, temp;
3205 CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
3206 xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x0C); /* enable GPIO write */
3208 temp = xgifb_reg_get(pVBInfo->P3d4, 0x48);
3212 xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A);
3213 CRB4 = xgifb_reg_get(pVBInfo->P3d4, 0xB4);
3214 temp |= ((CRB4 & 0x04) << 3);
3218 /*----------------------------------------------------------------------------*/
3220 /* bl[5] : 1;LVDS signal on */
3221 /* bl[1] : 1;LVDS backlight on */
3222 /* bl[0] : 1:LVDS VDD on */
3223 /* bh: 100000b : clear bit 5, to set bit5 */
3224 /* 000010b : clear bit 1, to set bit1 */
3225 /* 000001b : clear bit 0, to set bit0 */
3226 /*----------------------------------------------------------------------------*/
3227 static void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl,
3228 struct vb_device_info *pVBInfo)
3230 unsigned char CR4A, temp;
3232 CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
3235 xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */
3237 if (tempbh & 0x20) {
3238 temp = (tempbl >> 4) & 0x02;
3241 xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp);
3245 temp = xgifb_reg_get(pVBInfo->P3d4, 0x48);
3247 temp = XG21GPIODataTransfer(temp);
3250 xgifb_reg_set(pVBInfo->P3d4, 0x48, temp);
3253 static void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl,
3254 struct vb_device_info *pVBInfo)
3256 unsigned char CR4A, temp;
3257 unsigned short tempbh0, tempbl0;
3266 if (tempbh & 0x20) {
3267 temp = (tempbl >> 4) & 0x02;
3270 xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp);
3273 xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~tempbh0, tempbl0);
3275 CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
3279 tempbl <<= 2; /* GPIOC,GPIOD */
3280 xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */
3281 xgifb_reg_and_or(pVBInfo->P3d4, 0x48, ~tempbh, tempbl);
3284 /* --------------------------------------------------------------------- */
3285 /* Function : XGI_XG21SetPanelDelay */
3289 /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
3290 /* : bl : 2 ; T2 : the duration signal on and Vdd on */
3291 /* : bl : 3 ; T3 : the duration between CPL off and signal off */
3292 /* : bl : 4 ; T4 : the duration signal off and Vdd off */
3293 /* --------------------------------------------------------------------- */
3294 static void XGI_XG21SetPanelDelay(struct xgifb_video_info *xgifb_info,
3295 unsigned short tempbl,
3296 struct vb_device_info *pVBInfo)
3299 mdelay(xgifb_info->lvds_data.PSC_S1);
3302 mdelay(xgifb_info->lvds_data.PSC_S2);
3305 mdelay(xgifb_info->lvds_data.PSC_S3);
3308 mdelay(xgifb_info->lvds_data.PSC_S4);
3311 static void XGI_DisplayOn(struct xgifb_video_info *xgifb_info,
3312 struct xgi_hw_device_info *pXGIHWDE,
3313 struct vb_device_info *pVBInfo)
3316 xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x00);
3317 if (pXGIHWDE->jChipType == XG21) {
3318 if (pVBInfo->IF_DEF_LVDS == 1) {
3319 if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x1)) {
3321 XGI_XG21BLSignalVDD(0x01, 0x01, pVBInfo);
3322 XGI_XG21SetPanelDelay(xgifb_info, 2, pVBInfo);
3324 if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x20))
3325 /* LVDS signal on */
3326 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo);
3327 XGI_XG21SetPanelDelay(xgifb_info, 3, pVBInfo);
3328 /* LVDS backlight on */
3329 XGI_XG21BLSignalVDD(0x02, 0x02, pVBInfo);
3331 /* DVO/DVI signal on */
3332 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo);
3337 if (pXGIHWDE->jChipType == XG27) {
3338 if (pVBInfo->IF_DEF_LVDS == 1) {
3339 if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x1)) {
3341 XGI_XG27BLSignalVDD(0x01, 0x01, pVBInfo);
3342 XGI_XG21SetPanelDelay(xgifb_info, 2, pVBInfo);
3344 if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x20))
3345 /* LVDS signal on */
3346 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo);
3347 XGI_XG21SetPanelDelay(xgifb_info, 3, pVBInfo);
3348 /* LVDS backlight on */
3349 XGI_XG27BLSignalVDD(0x02, 0x02, pVBInfo);
3351 /* DVO/DVI signal on */
3352 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo);
3358 void XGI_DisplayOff(struct xgifb_video_info *xgifb_info,
3359 struct xgi_hw_device_info *pXGIHWDE,
3360 struct vb_device_info *pVBInfo)
3363 if (pXGIHWDE->jChipType == XG21) {
3364 if (pVBInfo->IF_DEF_LVDS == 1) {
3365 /* LVDS backlight off */
3366 XGI_XG21BLSignalVDD(0x02, 0x00, pVBInfo);
3367 XGI_XG21SetPanelDelay(xgifb_info, 3, pVBInfo);
3369 /* DVO/DVI signal off */
3370 XGI_XG21BLSignalVDD(0x20, 0x00, pVBInfo);
3374 if (pXGIHWDE->jChipType == XG27) {
3375 if ((XGI_XG27GetPSCValue(pVBInfo) & 0x2)) {
3376 /* LVDS backlight off */
3377 XGI_XG27BLSignalVDD(0x02, 0x00, pVBInfo);
3378 XGI_XG21SetPanelDelay(xgifb_info, 3, pVBInfo);
3381 if (pVBInfo->IF_DEF_LVDS == 0)
3382 /* DVO/DVI signal off */
3383 XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo);
3386 xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x20);
3389 static void XGI_WaitDisply(struct vb_device_info *pVBInfo)
3391 while ((inb(pVBInfo->P3da) & 0x01))
3394 while (!(inb(pVBInfo->P3da) & 0x01))
3398 static void XGI_AutoThreshold(struct vb_device_info *pVBInfo)
3400 xgifb_reg_or(pVBInfo->Part1Port, 0x01, 0x40);
3403 static void XGI_SaveCRT2Info(unsigned short ModeNo,
3404 struct vb_device_info *pVBInfo)
3406 unsigned short temp1, temp2;
3408 /* reserve CR34 for CRT1 Mode No */
3409 xgifb_reg_set(pVBInfo->P3d4, 0x34, ModeNo);
3410 temp1 = (pVBInfo->VBInfo & SetInSlaveMode) >> 8;
3411 temp2 = ~(SetInSlaveMode >> 8);
3412 xgifb_reg_and_or(pVBInfo->P3d4, 0x31, temp2, temp1);
3415 static void XGI_GetCRT2ResInfo(unsigned short ModeNo,
3416 unsigned short ModeIdIndex,
3417 struct vb_device_info *pVBInfo)
3419 unsigned short xres, yres, modeflag, resindex;
3421 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
3422 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
3423 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
3424 /* si+St_ModeFlag */
3425 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3427 if (modeflag & HalfDCLK)
3430 if (modeflag & DoubleScanMode)
3433 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
3434 if (pVBInfo->IF_DEF_LVDS == 0) {
3435 if (pVBInfo->LCDResInfo == Panel_1600x1200) {
3436 if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
3442 if (pVBInfo->LCDResInfo == Panel_1280x1024) {
3445 else if (yres == 350)
3448 if (pVBInfo->LCDInfo & XGI_LCDVESATiming) {
3454 if (pVBInfo->LCDResInfo == Panel_1024x768) {
3455 if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
3456 if (!(pVBInfo->LCDInfo
3457 & LCDNonExpanding)) {
3460 else if (yres == 400)
3462 else if (yres == 480)
3473 pVBInfo->VGAHDE = xres;
3474 pVBInfo->HDE = xres;
3475 pVBInfo->VGAVDE = yres;
3476 pVBInfo->VDE = yres;
3479 static unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo)
3482 if ((pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) &&
3483 (pVBInfo->LCDInfo & SetLCDDualLink)) /* shampoo0129 */
3489 static void XGI_GetRAMDAC2DATA(unsigned short ModeNo,
3490 unsigned short ModeIdIndex,
3491 unsigned short RefreshRateTableIndex,
3492 struct vb_device_info *pVBInfo)
3494 unsigned short tempax, tempbx, temp1, temp2, modeflag = 0, tempcx,
3497 pVBInfo->RVBHCMAX = 1;
3498 pVBInfo->RVBHCFACT = 1;
3499 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3500 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
3501 CRT1Index &= IndexMask;
3502 temp1 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[0];
3503 temp2 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5];
3504 tempax = (temp1 & 0xFF) | ((temp2 & 0x03) << 8);
3505 tempbx = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[8];
3506 tempcx = (unsigned short)
3507 pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14] << 8;
3509 tempcx = tempcx << 2;
3511 temp1 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9];
3520 if (modeflag & Charx8Dot)
3525 pVBInfo->VGAHT = tempax;
3526 pVBInfo->HT = tempax;
3528 pVBInfo->VGAVT = tempbx;
3529 pVBInfo->VT = tempbx;
3532 static void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex,
3533 unsigned short RefreshRateTableIndex,
3534 struct vb_device_info *pVBInfo)
3536 unsigned short tempax = 0, tempbx, modeflag, resinfo;
3538 struct SiS_LCDData *LCDPtr = NULL;
3539 struct SiS_TVData *TVPtr = NULL;
3541 /* si+Ext_ResInfo */
3542 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3543 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
3544 pVBInfo->NewFlickerMode = 0;
3545 pVBInfo->RVBHRS = 50;
3547 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
3548 XGI_GetRAMDAC2DATA(ModeNo, ModeIdIndex, RefreshRateTableIndex,
3555 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
3556 LCDPtr = (struct SiS_LCDData *) XGI_GetLcdPtr(tempbx,
3557 ModeNo, ModeIdIndex, RefreshRateTableIndex,
3560 pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX;
3561 pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT;
3562 pVBInfo->VGAHT = LCDPtr->VGAHT;
3563 pVBInfo->VGAVT = LCDPtr->VGAVT;
3564 pVBInfo->HT = LCDPtr->LCDHT;
3565 pVBInfo->VT = LCDPtr->LCDVT;
3567 if (pVBInfo->LCDResInfo == Panel_1024x768) {
3571 if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
3572 if (pVBInfo->VGAVDE == 357)
3574 else if (pVBInfo->VGAVDE == 420)
3576 else if (pVBInfo->VGAVDE == 525)
3578 else if (pVBInfo->VGAVDE == 600)
3584 } else if (pVBInfo->LCDResInfo == Panel_1024x768x75) {
3587 } else if (pVBInfo->LCDResInfo == Panel_1280x1024) {
3589 if (pVBInfo->VGAVDE == 360)
3591 else if (pVBInfo->VGAVDE == 375)
3593 else if (pVBInfo->VGAVDE == 405)
3597 } else if (pVBInfo->LCDResInfo == Panel_1280x1024x75) {
3600 } else if (pVBInfo->LCDResInfo == Panel_1280x960) {
3602 if (pVBInfo->VGAVDE == 350)
3604 else if (pVBInfo->VGAVDE == 400)
3606 else if (pVBInfo->VGAVDE == 1024)
3610 } else if (pVBInfo->LCDResInfo == Panel_1400x1050) {
3614 if (pVBInfo->VGAVDE == 1024) {
3618 } else if (pVBInfo->LCDResInfo == Panel_1600x1200) {
3620 tempbx = 1200; /* alan 10/14/2003 */
3621 if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
3622 if (pVBInfo->VGAVDE == 350)
3624 else if (pVBInfo->VGAVDE == 400)
3629 if (pVBInfo->LCDInfo & LCDNonExpanding) {
3630 tempax = pVBInfo->VGAHDE;
3631 tempbx = pVBInfo->VGAVDE;
3634 pVBInfo->HDE = tempax;
3635 pVBInfo->VDE = tempbx;
3639 if (pVBInfo->VBInfo & (SetCRT2ToTV)) {
3641 TVPtr = (struct SiS_TVData *) XGI_GetTVPtr(tempbx,
3642 ModeNo, ModeIdIndex, RefreshRateTableIndex,
3645 pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX;
3646 pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT;
3647 pVBInfo->VGAHT = TVPtr->VGAHT;
3648 pVBInfo->VGAVT = TVPtr->VGAVT;
3649 pVBInfo->HDE = TVPtr->TVHDE;
3650 pVBInfo->VDE = TVPtr->TVVDE;
3651 pVBInfo->RVBHRS = TVPtr->RVBHRS;
3652 pVBInfo->NewFlickerMode = TVPtr->FlickerMode;
3654 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
3655 if (resinfo == 0x08)
3656 pVBInfo->NewFlickerMode = 0x40;
3657 else if (resinfo == 0x09)
3658 pVBInfo->NewFlickerMode = 0x40;
3659 else if (resinfo == 0x12)
3660 pVBInfo->NewFlickerMode = 0x40;
3662 if (pVBInfo->VGAVDE == 350)
3663 pVBInfo->TVInfo |= TVSimuMode;
3668 if (pVBInfo->VBInfo & SetInSlaveMode) {
3669 if (pVBInfo->TVInfo & TVSimuMode) {
3673 if (!(modeflag & Charx8Dot)) {
3674 tempax = StHiTextTVHT;
3675 tempbx = StHiTextTVVT;
3679 } else if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
3680 if (pVBInfo->TVInfo & TVSetYPbPr750p) {
3681 tempax = YPbPrTV750pHT; /* Ext750pTVHT */
3682 tempbx = YPbPrTV750pVT; /* Ext750pTVVT */
3685 if (pVBInfo->TVInfo & TVSetYPbPr525p) {
3686 tempax = YPbPrTV525pHT; /* Ext525pTVHT */
3687 tempbx = YPbPrTV525pVT; /* Ext525pTVVT */
3688 } else if (pVBInfo->TVInfo & TVSetYPbPr525i) {
3689 tempax = YPbPrTV525iHT; /* Ext525iTVHT */
3690 tempbx = YPbPrTV525iVT; /* Ext525iTVVT */
3691 if (pVBInfo->TVInfo & NTSC1024x768)
3692 tempax = NTSC1024x768HT;
3697 if (!(pVBInfo->TVInfo & TVSetPAL)) {
3700 if (pVBInfo->TVInfo & NTSC1024x768)
3701 tempax = NTSC1024x768HT;
3705 pVBInfo->HT = tempax;
3706 pVBInfo->VT = tempbx;
3711 static void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex,
3712 unsigned short RefreshRateTableIndex,
3713 struct vb_device_info *pVBInfo)
3715 unsigned char di_0, di_1, tempal;
3717 tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex,
3719 XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo);
3720 XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo);
3722 if (pVBInfo->VBType & VB_SIS301) { /* shampoo 0129 */
3724 xgifb_reg_set(pVBInfo->Part4Port, 0x0A, 0x10);
3725 xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1);
3726 xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0);
3727 } else { /* 301b/302b/301lv/302lv */
3728 xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0);
3729 xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1);
3732 xgifb_reg_set(pVBInfo->Part4Port, 0x00, 0x12);
3734 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC)
3735 xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x28);
3737 xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x08);
3740 static unsigned short XGI_GetColorDepth(unsigned short ModeNo,
3741 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
3743 unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8 };
3745 unsigned short modeflag;
3747 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3748 index = (modeflag & ModeTypeMask) - ModeEGA;
3753 return ColorDepth[index];
3756 static unsigned short XGI_GetOffset(unsigned short ModeNo,
3757 unsigned short ModeIdIndex,
3758 unsigned short RefreshRateTableIndex,
3759 struct xgi_hw_device_info *HwDeviceExtension,
3760 struct vb_device_info *pVBInfo)
3762 unsigned short temp, colordepth, modeinfo, index, infoflag,
3763 ColorDepth[] = { 0x01, 0x02, 0x04 };
3765 modeinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo;
3766 infoflag = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
3768 index = (modeinfo >> 8) & 0xFF;
3770 temp = pVBInfo->ScreenOffset[index];
3772 if (infoflag & InterlaceMode)
3775 colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo);
3777 if ((ModeNo >= 0x7C) && (ModeNo <= 0x7E)) {
3778 temp = ModeNo - 0x7C;
3779 colordepth = ColorDepth[temp];
3781 if (infoflag & InterlaceMode)
3783 return temp * colordepth;
3785 return temp * colordepth;
3789 static void XGI_SetCRT2Offset(unsigned short ModeNo,
3790 unsigned short ModeIdIndex,
3791 unsigned short RefreshRateTableIndex,
3792 struct xgi_hw_device_info *HwDeviceExtension,
3793 struct vb_device_info *pVBInfo)
3795 unsigned short offset;
3798 if (pVBInfo->VBInfo & SetInSlaveMode)
3801 offset = XGI_GetOffset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
3802 HwDeviceExtension, pVBInfo);
3803 temp = (unsigned char) (offset & 0xFF);
3804 xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp);
3805 temp = (unsigned char) ((offset & 0xFF00) >> 8);
3806 xgifb_reg_set(pVBInfo->Part1Port, 0x09, temp);
3807 temp = (unsigned char) (((offset >> 3) & 0xFF) + 1);
3808 xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp);
3811 static void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo)
3813 /* threshold high ,disable auto threshold */
3814 xgifb_reg_set(pVBInfo->Part1Port, 0x01, 0x3B);
3815 /* threshold low default 04h */
3816 xgifb_reg_and_or(pVBInfo->Part1Port, 0x02, ~(0x3F), 0x04);
3819 static void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
3820 struct xgi_hw_device_info *HwDeviceExtension,
3821 unsigned short RefreshRateTableIndex,
3822 struct vb_device_info *pVBInfo)
3824 unsigned short tempcx = 0, CRT1Index = 0, resinfo = 0;
3826 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
3827 CRT1Index &= IndexMask;
3828 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
3830 XGI_SetCRT2Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
3831 HwDeviceExtension, pVBInfo);
3832 XGI_SetCRT2FIFO(pVBInfo);
3834 for (tempcx = 4; tempcx < 7; tempcx++)
3835 xgifb_reg_set(pVBInfo->Part1Port, tempcx, 0x0);
3837 xgifb_reg_set(pVBInfo->Part1Port, 0x50, 0x00);
3838 xgifb_reg_set(pVBInfo->Part1Port, 0x02, 0x44); /* temp 0206 */
3841 static void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
3842 struct xgi_hw_device_info *HwDeviceExtension,
3843 unsigned short RefreshRateTableIndex,
3844 struct vb_device_info *pVBInfo)
3846 unsigned short temp = 0, tempax = 0, tempbx = 0, tempcx = 0,
3847 pushbx = 0, CRT1Index = 0, modeflag, resinfo = 0;
3849 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
3850 CRT1Index &= IndexMask;
3851 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
3852 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3854 /* bainy change table name */
3855 if (modeflag & HalfDCLK) {
3856 /* BTVGA2HT 0x08,0x09 */
3857 temp = (pVBInfo->VGAHT / 2 - 1) & 0x0FF;
3858 xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp);
3859 temp = (((pVBInfo->VGAHT / 2 - 1) & 0xFF00) >> 8) << 4;
3860 xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp);
3861 /* BTVGA2HDEE 0x0A,0x0C */
3862 temp = (pVBInfo->VGAHDE / 2 + 16) & 0x0FF;
3863 xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp);
3864 tempcx = ((pVBInfo->VGAHT - pVBInfo->VGAHDE) / 2) >> 2;
3865 pushbx = pVBInfo->VGAHDE / 2 + 16;
3866 tempcx = tempcx >> 1;
3867 tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */
3870 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
3871 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4];
3872 tempbx |= ((pVBInfo->
3873 XGINEWUB_CRT1Table[CRT1Index].CR[14] &
3875 tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */
3876 tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5];
3878 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[15];
3879 temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */
3880 tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */
3886 if (tempcx > (pVBInfo->VGAHT / 2))
3887 tempcx = pVBInfo->VGAHT / 2;
3889 temp = tempbx & 0x00FF;
3891 xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp);
3893 temp = (pVBInfo->VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */
3894 xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp);
3895 temp = (((pVBInfo->VGAHT - 1) & 0xFF00) >> 8) << 4;
3896 xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp);
3897 /* BTVGA2HDEE 0x0A,0x0C */
3898 temp = (pVBInfo->VGAHDE + 16) & 0x0FF;
3899 xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp);
3900 tempcx = (pVBInfo->VGAHT - pVBInfo->VGAHDE) >> 2; /* cx */
3901 pushbx = pVBInfo->VGAHDE + 16;
3902 tempcx = tempcx >> 1;
3903 tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */
3906 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
3907 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[3];
3908 tempbx |= ((pVBInfo->
3909 XGINEWUB_CRT1Table[CRT1Index].CR[5] &
3911 tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */
3912 tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4];
3914 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[6];
3915 temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */
3916 tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */
3921 if (tempcx > pVBInfo->VGAHT)
3922 tempcx = pVBInfo->VGAHT;
3924 temp = tempbx & 0x00FF;
3925 xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp);
3928 tempax = (tempax & 0x00FF) | (tempbx & 0xFF00);
3930 tempbx = (tempbx & 0x00FF) | ((tempbx & 0xFF00) << 4);
3931 tempax |= (tempbx & 0xFF00);
3932 temp = (tempax & 0xFF00) >> 8;
3933 xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp);
3934 temp = tempcx & 0x00FF;
3935 xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp);
3936 tempcx = (pVBInfo->VGAVT - 1);
3937 temp = tempcx & 0x00FF;
3939 xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp);
3940 tempbx = pVBInfo->VGAVDE - 1;
3941 temp = tempbx & 0x00FF;
3942 xgifb_reg_set(pVBInfo->Part1Port, 0x0F, temp);
3943 temp = ((tempbx & 0xFF00) << 3) >> 8;
3944 temp |= ((tempcx & 0xFF00) >> 8);
3945 xgifb_reg_set(pVBInfo->Part1Port, 0x12, temp);
3947 tempax = pVBInfo->VGAVDE;
3948 tempbx = pVBInfo->VGAVDE;
3949 tempcx = pVBInfo->VGAVT;
3950 /* BTVGA2VRS 0x10,0x11 */
3951 tempbx = (pVBInfo->VGAVT + pVBInfo->VGAVDE) >> 1;
3952 /* BTVGA2VRE 0x11 */
3953 tempcx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) >> 4) + tempbx + 1;
3955 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
3956 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[10];
3957 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9];
3965 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14];
3970 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[11];
3971 tempcx = (tempcx & 0xFF00) | (temp & 0x00FF);
3974 temp = tempbx & 0x00FF;
3975 xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp);
3976 temp = ((tempbx & 0xFF00) >> 8) << 4;
3977 temp = ((tempcx & 0x000F) | (temp));
3978 xgifb_reg_set(pVBInfo->Part1Port, 0x11, temp);
3981 if (modeflag & DoubleScanMode)
3984 if (modeflag & HalfDCLK)
3987 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2C, ~0x0C0, tempax);
3990 static unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo)
3992 unsigned long tempax, tempbx;
3994 tempbx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) * pVBInfo->RVBHCMAX)
3996 tempax = (pVBInfo->VT - pVBInfo->VDE) * pVBInfo->RVBHCFACT;
3997 tempax = (tempax * pVBInfo->HT) / tempbx;
3999 return (unsigned short) tempax;
4002 static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
4003 struct xgi_hw_device_info *HwDeviceExtension,
4004 unsigned short RefreshRateTableIndex,
4005 struct vb_device_info *pVBInfo)
4007 unsigned short push1, push2, tempax, tempbx = 0, tempcx, temp, resinfo,
4008 modeflag, CRT1Index;
4010 /* si+Ext_ResInfo */
4011 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4012 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4013 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4014 CRT1Index &= IndexMask;
4016 if (!(pVBInfo->VBInfo & SetInSlaveMode))
4019 temp = 0xFF; /* set MAX HT */
4020 xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp);
4023 if (pVBInfo->VBType & (VB_SIS301LV | VB_SIS302LV | VB_XGI301C))
4024 modeflag |= Charx8Dot;
4026 tempax = pVBInfo->VGAHDE; /* 0x04 Horizontal Display End */
4028 if (modeflag & HalfDCLK)
4029 tempax = tempax >> 1;
4031 tempax = (tempax / tempcx) - 1;
4032 tempbx |= ((tempax & 0x00FF) << 8);
4033 temp = tempax & 0x00FF;
4034 xgifb_reg_set(pVBInfo->Part1Port, 0x04, temp);
4036 temp = (tempbx & 0xFF00) >> 8;
4038 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4039 if (!(pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
4040 | VB_SIS302LV | VB_XGI301C)))
4043 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
4044 if (pVBInfo->VBType & VB_SIS301LV) {
4045 if (pVBInfo->VBExtInfo == VB_YPbPr1080i) {
4049 } else if (resinfo == 7) {
4055 /* 0x05 Horizontal Display Start */
4056 xgifb_reg_set(pVBInfo->Part1Port, 0x05, temp);
4057 /* 0x06 Horizontal Blank end */
4058 xgifb_reg_set(pVBInfo->Part1Port, 0x06, 0x03);
4060 if (!(pVBInfo->VBInfo & DisableCRT2Display)) { /* 030226 bainy */
4061 if (pVBInfo->VBInfo & SetCRT2ToTV)
4062 tempax = pVBInfo->VGAHT;
4064 tempax = XGI_GetVGAHT2(pVBInfo);
4067 if (tempax >= pVBInfo->VGAHT)
4068 tempax = pVBInfo->VGAHT;
4070 if (modeflag & HalfDCLK)
4071 tempax = tempax >> 1;
4073 tempax = (tempax / tempcx) - 5;
4074 tempcx = tempax; /* 20030401 0x07 horizontal Retrace Start */
4075 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
4076 temp = (tempbx & 0x00FF) - 1;
4077 if (!(modeflag & HalfDCLK)) {
4079 if (pVBInfo->TVInfo & TVSimuMode) {
4085 tempbx = (tempbx & 0xFF00) >> 8;
4086 tempcx = (tempcx + tempbx) >> 1;
4087 temp = (tempcx & 0x00FF) + 2;
4089 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4091 if (!(modeflag & HalfDCLK)) {
4092 if ((modeflag & Charx8Dot)) {
4094 if (pVBInfo->VGAHDE >= 800)
4098 } else if (!(modeflag & HalfDCLK)) {
4100 if (pVBInfo->LCDResInfo != Panel_1280x960 &&
4101 pVBInfo->VGAHDE >= 800) {
4103 if (pVBInfo->VGAHDE >= 1280 &&
4104 pVBInfo->LCDResInfo != Panel_1280x960 &&
4105 (pVBInfo->LCDInfo & LCDNonExpanding))
4111 /* 0x07 Horizontal Retrace Start */
4112 xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp);
4113 /* 0x08 Horizontal Retrace End */
4114 xgifb_reg_set(pVBInfo->Part1Port, 0x08, 0);
4116 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4117 if (pVBInfo->TVInfo & TVSimuMode) {
4118 if (ModeNo == 0x50) {
4119 if (pVBInfo->TVInfo & SetNTSCTV) {
4120 xgifb_reg_set(pVBInfo->Part1Port,
4122 xgifb_reg_set(pVBInfo->Part1Port,
4125 xgifb_reg_set(pVBInfo->Part1Port,
4127 xgifb_reg_set(pVBInfo->Part1Port,
4134 xgifb_reg_set(pVBInfo->Part1Port, 0x18, 0x03); /* 0x18 SR0B */
4135 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0xF0, 0x00);
4136 xgifb_reg_set(pVBInfo->Part1Port, 0x09, 0xFF); /* 0x09 Set Max VT */
4138 tempbx = pVBInfo->VGAVT;
4141 tempbx = pVBInfo->VGAVDE; /* 0x0E Virtical Display End */
4156 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
4157 if (pVBInfo->LCDResInfo == Panel_1024x768) {
4158 if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
4167 temp = tempbx & 0x00FF;
4169 temp = tempbx & 0x00FF;
4170 /* 0x10 vertical Blank Start */
4171 xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp);
4174 temp = tempbx & 0x00FF;
4175 xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp);
4177 if (tempbx & 0x0100)
4182 if (modeflag & DoubleScanMode)
4185 if (tempbx & 0x0200)
4188 temp = (tempax & 0xFF00) >> 8;
4189 xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp);
4191 if (tempbx & 0x0400)
4194 /* 0x11 Vertival Blank End */
4195 xgifb_reg_set(pVBInfo->Part1Port, 0x11, 0x00);
4198 tempax -= tempbx; /* 0x0C Vertical Retrace Start */
4199 tempax = tempax >> 2;
4200 push1 = tempax; /* push ax */
4202 if (resinfo != 0x09) {
4203 tempax = tempax << 1;
4207 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
4208 if (pVBInfo->VBType & VB_SIS301LV) {
4209 if (pVBInfo->TVInfo & TVSetHiVision) {
4212 if (pVBInfo->TVInfo & TVSimuMode) {
4213 if (pVBInfo->TVInfo & TVSetPAL) {
4214 if (pVBInfo->VBType &
4216 if (!(pVBInfo->TVInfo &
4231 if (pVBInfo->TVInfo & TVSimuMode) {
4232 if (pVBInfo->TVInfo & TVSetPAL) {
4233 if (pVBInfo->VBType & VB_SIS301LV) {
4234 if (!(pVBInfo->TVInfo &
4246 tempax = tempax >> 2;
4249 push1 = tempax; /* push ax */
4251 if ((pVBInfo->TVInfo & TVSetPAL)) {
4252 if (tempbx <= 513) {
4258 temp = tempbx & 0x00FF;
4259 xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp);
4261 temp = tempbx & 0x00FF;
4262 xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp);
4264 if (tempbx & 0x0100)
4267 if (tempbx & 0x0200)
4268 xgifb_reg_and_or(pVBInfo->Part1Port, 0x0B, 0x0FF, 0x20);
4272 if (tempbx & 0x0100)
4275 if (tempbx & 0x0200)
4278 if (tempbx & 0x0400)
4281 tempbx = push1; /* pop ax */
4282 temp = tempbx & 0x00FF;
4284 /* 0x0D vertical Retrace End */
4285 xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp);
4287 if (tempbx & 0x0010)
4290 temp = tempcx & 0x00FF;
4291 xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); /* 0x0A CR07 */
4292 temp = (tempcx & 0x0FF00) >> 8;
4293 xgifb_reg_set(pVBInfo->Part1Port, 0x17, temp); /* 0x17 SR0A */
4295 temp = (tempax & 0xFF00) >> 8;
4297 temp = (temp >> 1) & 0x09;
4299 if (pVBInfo->VBType & (VB_SIS301LV | VB_SIS302LV | VB_XGI301C))
4302 xgifb_reg_set(pVBInfo->Part1Port, 0x16, temp); /* 0x16 SR01 */
4303 xgifb_reg_set(pVBInfo->Part1Port, 0x0F, 0); /* 0x0F CR14 */
4304 xgifb_reg_set(pVBInfo->Part1Port, 0x12, 0); /* 0x12 CR17 */
4306 if (pVBInfo->LCDInfo & LCDRGB18Bit)
4311 xgifb_reg_set(pVBInfo->Part1Port, 0x1A, temp); /* 0x1A SR0E */
4316 static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex,
4317 unsigned short RefreshRateTableIndex,
4318 struct xgi_hw_device_info *HwDeviceExtension,
4319 struct vb_device_info *pVBInfo)
4321 unsigned short i, j, tempax, tempbx, tempcx, temp, push1, push2,
4322 modeflag, resinfo, crt2crtc;
4323 unsigned char *TimingPoint;
4325 unsigned long longtemp, tempeax, tempebx, temp2, tempecx;
4327 /* si+Ext_ResInfo */
4328 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4329 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4330 crt2crtc = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
4334 if (!(pVBInfo->VBInfo & SetCRT2ToAVIDEO))
4337 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
4340 if (pVBInfo->VBInfo & SetCRT2ToSCART)
4343 if (!(pVBInfo->TVInfo & TVSetPAL))
4346 if (pVBInfo->VBInfo & SetCRT2ToHiVision)
4349 if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p))
4352 tempax = (tempax & 0xff00) >> 8;
4354 xgifb_reg_set(pVBInfo->Part2Port, 0x0, tempax);
4355 TimingPoint = pVBInfo->NTSCTiming;
4357 if (pVBInfo->TVInfo & TVSetPAL)
4358 TimingPoint = pVBInfo->PALTiming;
4360 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
4361 TimingPoint = pVBInfo->HiTVExtTiming;
4363 if (pVBInfo->VBInfo & SetInSlaveMode)
4364 TimingPoint = pVBInfo->HiTVSt2Timing;
4366 if (pVBInfo->SetFlag & TVSimuMode)
4367 TimingPoint = pVBInfo->HiTVSt1Timing;
4369 if (!(modeflag & Charx8Dot))
4370 TimingPoint = pVBInfo->HiTVTextTiming;
4373 if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
4374 if (pVBInfo->TVInfo & TVSetYPbPr525i)
4375 TimingPoint = pVBInfo->YPbPr525iTiming;
4377 if (pVBInfo->TVInfo & TVSetYPbPr525p)
4378 TimingPoint = pVBInfo->YPbPr525pTiming;
4380 if (pVBInfo->TVInfo & TVSetYPbPr750p)
4381 TimingPoint = pVBInfo->YPbPr750pTiming;
4384 for (i = 0x01, j = 0; i <= 0x2D; i++, j++)
4385 xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]);
4387 for (i = 0x39; i <= 0x45; i++, j++)
4389 xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]);
4391 if (pVBInfo->VBInfo & SetCRT2ToTV)
4392 xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, 0x00);
4394 temp = pVBInfo->NewFlickerMode;
4396 xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xFF, temp);
4398 if (pVBInfo->VBInfo & SetCRT2ToHiVision)
4401 if (pVBInfo->TVInfo & TVSetPAL)
4406 if (pVBInfo->VDE <= tempax) {
4407 tempax -= pVBInfo->VDE;
4408 tempax = tempax >> 2;
4409 tempax = (tempax & 0x00FF) | ((tempax & 0x00FF) << 8);
4411 temp = (tempax & 0xFF00) >> 8;
4412 temp += (unsigned short) TimingPoint[0];
4414 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
4415 | VB_SIS302LV | VB_XGI301C)) {
4416 if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO
4417 | SetCRT2ToSVIDEO | SetCRT2ToSCART
4418 | SetCRT2ToYPbPr525750)) {
4419 tempcx = pVBInfo->VGAHDE;
4420 if (tempcx >= 1024) {
4421 temp = 0x17; /* NTSC */
4422 if (pVBInfo->TVInfo & TVSetPAL)
4423 temp = 0x19; /* PAL */
4428 xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp);
4430 temp = (tempax & 0xFF00) >> 8;
4431 temp += TimingPoint[1];
4433 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
4434 | VB_SIS302LV | VB_XGI301C)) {
4435 if ((pVBInfo->VBInfo & (SetCRT2ToAVIDEO
4436 | SetCRT2ToSVIDEO | SetCRT2ToSCART
4437 | SetCRT2ToYPbPr525750))) {
4438 tempcx = pVBInfo->VGAHDE;
4439 if (tempcx >= 1024) {
4440 temp = 0x1D; /* NTSC */
4441 if (pVBInfo->TVInfo & TVSetPAL)
4442 temp = 0x52; /* PAL */
4446 xgifb_reg_set(pVBInfo->Part2Port, 0x02, temp);
4450 tempcx = pVBInfo->HT;
4452 if (XGI_IsLCDDualLink(pVBInfo))
4453 tempcx = tempcx >> 1;
4456 temp = tempcx & 0x00FF;
4457 xgifb_reg_set(pVBInfo->Part2Port, 0x1B, temp);
4459 temp = (tempcx & 0xFF00) >> 8;
4460 xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F, temp);
4462 tempcx = pVBInfo->HT >> 1;
4463 push1 = tempcx; /* push cx */
4466 if (pVBInfo->VBInfo & SetCRT2ToHiVision)
4469 temp = tempcx & 0x00FF;
4471 xgifb_reg_and_or(pVBInfo->Part2Port, 0x22, 0x0F, temp);
4473 tempbx = TimingPoint[j] | ((TimingPoint[j + 1]) << 8);
4476 temp = tempbx & 0x00FF;
4477 xgifb_reg_set(pVBInfo->Part2Port, 0x24, temp);
4478 temp = (tempbx & 0xFF00) >> 8;
4480 xgifb_reg_and_or(pVBInfo->Part2Port, 0x25, 0x0F, temp);
4483 tempbx = tempbx + 8;
4484 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
4485 tempbx = tempbx - 4;
4489 temp = (tempbx & 0x00FF) << 4;
4490 xgifb_reg_and_or(pVBInfo->Part2Port, 0x29, 0x0F, temp);
4493 tempcx += (TimingPoint[j] | ((TimingPoint[j + 1]) << 8));
4494 temp = tempcx & 0x00FF;
4495 xgifb_reg_set(pVBInfo->Part2Port, 0x27, temp);
4496 temp = ((tempcx & 0xFF00) >> 8) << 4;
4497 xgifb_reg_and_or(pVBInfo->Part2Port, 0x28, 0x0F, temp);
4500 if (pVBInfo->VBInfo & SetCRT2ToHiVision)
4503 temp = tempcx & 0xFF;
4505 xgifb_reg_and_or(pVBInfo->Part2Port, 0x2A, 0x0F, temp);
4507 tempcx = push1; /* pop cx */
4509 temp = TimingPoint[j] | ((TimingPoint[j + 1]) << 8);
4511 temp = tempcx & 0x00FF;
4513 xgifb_reg_and_or(pVBInfo->Part2Port, 0x2D, 0x0F, temp);
4517 if (!(pVBInfo->VBInfo & SetCRT2ToTV)) {
4518 tempax = XGI_GetVGAHT2(pVBInfo);
4519 tempcx = tempax - 1;
4521 temp = tempcx & 0x00FF;
4522 xgifb_reg_set(pVBInfo->Part2Port, 0x2E, temp);
4524 tempbx = pVBInfo->VDE;
4526 if (pVBInfo->VGAVDE == 360)
4528 if (pVBInfo->VGAVDE == 375)
4530 if (pVBInfo->VGAVDE == 405)
4533 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4534 if (pVBInfo->VBType &
4535 (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) {
4536 if (!(pVBInfo->TVInfo &
4537 (TVSetYPbPr525p | TVSetYPbPr750p)))
4538 tempbx = tempbx >> 1;
4540 tempbx = tempbx >> 1;
4544 temp = tempbx & 0x00FF;
4546 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
4547 if (pVBInfo->VBType & VB_SIS301LV) {
4548 if (pVBInfo->TVInfo & TVSetHiVision) {
4549 if (pVBInfo->VBInfo & SetInSlaveMode) {
4555 if (pVBInfo->VBInfo & SetInSlaveMode) {
4562 xgifb_reg_set(pVBInfo->Part2Port, 0x2F, temp);
4564 temp = (tempcx & 0xFF00) >> 8;
4565 temp |= ((tempbx & 0xFF00) >> 8) << 6;
4567 if (!(pVBInfo->VBInfo & SetCRT2ToHiVision)) {
4568 if (pVBInfo->VBType & VB_SIS301LV) {
4569 if (pVBInfo->TVInfo & TVSetHiVision) {
4572 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
4577 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
4582 xgifb_reg_set(pVBInfo->Part2Port, 0x30, temp);
4584 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
4585 | VB_SIS302LV | VB_XGI301C)) { /* TV gatingno */
4586 tempbx = pVBInfo->VDE;
4587 tempcx = tempbx - 2;
4589 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4590 if (!(pVBInfo->TVInfo & (TVSetYPbPr525p
4592 tempbx = tempbx >> 1;
4595 if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) {
4597 if (tempcx & 0x0400)
4600 if (tempbx & 0x0400)
4603 xgifb_reg_set(pVBInfo->Part4Port, 0x10, temp);
4606 temp = (((tempbx - 3) & 0x0300) >> 8) << 5;
4607 xgifb_reg_set(pVBInfo->Part2Port, 0x46, temp);
4608 temp = (tempbx - 3) & 0x00FF;
4609 xgifb_reg_set(pVBInfo->Part2Port, 0x47, temp);
4612 tempbx = tempbx & 0x00FF;
4614 if (!(modeflag & HalfDCLK)) {
4615 tempcx = pVBInfo->VGAHDE;
4616 if (tempcx >= pVBInfo->HDE) {
4624 if (pVBInfo->VBInfo & SetCRT2ToTV) { /*301b*/
4625 if (pVBInfo->VGAHDE >= 1024) {
4627 if (pVBInfo->VGAHDE >= 1280) {
4629 tempbx = tempbx & 0xDFFF;
4634 if (!(tempbx & 0x2000)) {
4635 if (modeflag & HalfDCLK)
4636 tempcx = (tempcx & 0xFF00) | ((tempcx & 0x00FF) << 1);
4639 tempeax = pVBInfo->VGAHDE;
4640 tempebx = (tempcx & 0xFF00) >> 8;
4641 longtemp = tempeax * tempebx;
4642 tempecx = tempcx & 0x00FF;
4643 longtemp = longtemp / tempecx;
4648 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
4649 | VB_SIS302LV | VB_XGI301C)) {
4650 tempecx = tempecx * 8;
4653 longtemp = longtemp * tempecx;
4654 tempecx = pVBInfo->HDE;
4655 temp2 = longtemp % tempecx;
4656 tempeax = longtemp / tempecx;
4660 tempax = (unsigned short) tempeax;
4663 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
4664 | VB_SIS302LV | VB_XGI301C)) {
4665 tempcx = ((tempax & 0xFF00) >> 5) >> 8;
4670 tempbx = (unsigned short) (((tempeax & 0x0000FF00) & 0x1F00)
4671 | (tempbx & 0x00FF));
4672 tempax = (unsigned short) (((tempeax & 0x000000FF) << 8)
4673 | (tempax & 0x00FF));
4674 temp = (tempax & 0xFF00) >> 8;
4676 temp = (tempax & 0x00FF) >> 8;
4679 xgifb_reg_set(pVBInfo->Part2Port, 0x44, temp);
4680 temp = (tempbx & 0xFF00) >> 8;
4681 xgifb_reg_and_or(pVBInfo->Part2Port, 0x45, ~0x03F, temp);
4682 temp = tempcx & 0x00FF;
4684 if (tempbx & 0x2000)
4687 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
4690 xgifb_reg_and_or(pVBInfo->Part2Port, 0x46, ~0x1F, temp);
4691 if (pVBInfo->TVInfo & TVSetPAL) {
4699 temp = tempbx & 0x00FF;
4700 xgifb_reg_set(pVBInfo->Part2Port, 0x4b, temp);
4701 temp = tempcx & 0x00FF;
4702 xgifb_reg_set(pVBInfo->Part2Port, 0x4c, temp);
4704 temp = ((tempcx & 0xFF00) >> 8) & 0x03;
4706 temp |= ((tempbx & 0xFF00) >> 8) & 0x03;
4708 if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
4711 if (pVBInfo->TVInfo & TVSetYPbPr525p)
4714 if (pVBInfo->TVInfo & TVSetYPbPr750p)
4718 xgifb_reg_set(pVBInfo->Part2Port, 0x4d, temp);
4719 temp = xgifb_reg_get(pVBInfo->Part2Port, 0x43); /* 301b change */
4720 xgifb_reg_set(pVBInfo->Part2Port, 0x43, (unsigned short) (temp - 3));
4722 if (!(pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p))) {
4723 if (pVBInfo->TVInfo & NTSC1024x768) {
4724 TimingPoint = XGI_NTSC1024AdjTime;
4725 for (i = 0x1c, j = 0; i <= 0x30; i++, j++) {
4726 xgifb_reg_set(pVBInfo->Part2Port, i,
4729 xgifb_reg_set(pVBInfo->Part2Port, 0x43, 0x72);
4733 /* [ycchen] 01/14/03 Modify for 301C PALM Support */
4734 if (pVBInfo->VBType & VB_XGI301C) {
4735 if (pVBInfo->TVInfo & TVSetPALM)
4736 xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x08,
4737 0x08); /* PALM Mode */
4740 if (pVBInfo->TVInfo & TVSetPALM) {
4741 tempax = (unsigned char) xgifb_reg_get(pVBInfo->Part2Port,
4744 xgifb_reg_and(pVBInfo->Part2Port, 0x01, tempax);
4746 xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xEF);
4749 if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
4750 if (!(pVBInfo->VBInfo & SetInSlaveMode))
4751 xgifb_reg_set(pVBInfo->Part2Port, 0x0B, 0x00);
4754 if (pVBInfo->VBInfo & SetCRT2ToTV)
4758 static void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
4759 struct xgi_hw_device_info *HwDeviceExtension,
4760 unsigned short RefreshRateTableIndex,
4761 struct vb_device_info *pVBInfo)
4763 unsigned short push1, push2, pushbx, tempax, tempbx, tempcx, temp,
4764 tempah, tempbh, tempch, resinfo, modeflag, CRT1Index;
4766 struct XGI_LCDDesStruct *LCDBDesPtr = NULL;
4768 /* si+Ext_ResInfo */
4769 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4770 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4771 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4772 CRT1Index &= IndexMask;
4774 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
4777 tempbx = pVBInfo->HDE; /* RHACTE=HDE-1 */
4779 if (XGI_IsLCDDualLink(pVBInfo))
4780 tempbx = tempbx >> 1;
4783 temp = tempbx & 0x00FF;
4784 xgifb_reg_set(pVBInfo->Part2Port, 0x2C, temp);
4785 temp = (tempbx & 0xFF00) >> 8;
4787 xgifb_reg_and_or(pVBInfo->Part2Port, 0x2B, 0x0F, temp);
4790 xgifb_reg_set(pVBInfo->Part2Port, 0x0B, temp);
4791 tempbx = pVBInfo->VDE; /* RTVACTEO=(VDE-1)&0xFF */
4794 temp = tempbx & 0x00FF;
4795 xgifb_reg_set(pVBInfo->Part2Port, 0x03, temp);
4796 temp = ((tempbx & 0xFF00) >> 8) & 0x07;
4797 xgifb_reg_and_or(pVBInfo->Part2Port, 0x0C, ~0x07, temp);
4799 tempcx = pVBInfo->VT - 1;
4801 temp = tempcx & 0x00FF; /* RVTVT=VT-1 */
4802 xgifb_reg_set(pVBInfo->Part2Port, 0x19, temp);
4803 temp = (tempcx & 0xFF00) >> 8;
4805 xgifb_reg_set(pVBInfo->Part2Port, 0x1A, temp);
4806 xgifb_reg_and_or(pVBInfo->Part2Port, 0x09, 0xF0, 0x00);
4807 xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xF0, 0x00);
4808 xgifb_reg_and_or(pVBInfo->Part2Port, 0x17, 0xFB, 0x00);
4809 xgifb_reg_and_or(pVBInfo->Part2Port, 0x18, 0xDF, 0x00);
4811 /* Customized LCDB Des no add */
4813 LCDBDesPtr = (struct XGI_LCDDesStruct *) XGI_GetLcdPtr(tempbx, ModeNo,
4814 ModeIdIndex, RefreshRateTableIndex, pVBInfo);
4815 tempah = pVBInfo->LCDResInfo;
4816 tempah &= PanelResInfo;
4818 if ((tempah == Panel_1024x768) || (tempah == Panel_1024x768x75)) {
4821 } else if ((tempah == Panel_1280x1024) ||
4822 (tempah == Panel_1280x1024x75)) {
4825 } else if (tempah == Panel_1400x1050) {
4833 if (pVBInfo->LCDInfo & EnableScalingLCD) {
4834 tempbx = pVBInfo->HDE;
4835 tempcx = pVBInfo->VDE;
4839 tempax = pVBInfo->VT;
4840 pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES;
4841 pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS;
4842 pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES;
4843 pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS;
4844 tempbx = pVBInfo->LCDVDES;
4847 if (tempcx >= tempax)
4848 tempcx -= tempax; /* lcdvdes */
4850 temp = tempbx & 0x00FF; /* RVEQ1EQ=lcdvdes */
4851 xgifb_reg_set(pVBInfo->Part2Port, 0x05, temp);
4852 temp = tempcx & 0x00FF;
4853 xgifb_reg_set(pVBInfo->Part2Port, 0x06, temp);
4854 tempch = ((tempcx & 0xFF00) >> 8) & 0x07;
4855 tempbh = ((tempbx & 0xFF00) >> 8) & 0x07;
4857 tempah = tempah << 3;
4859 xgifb_reg_set(pVBInfo->Part2Port, 0x02, tempah);
4862 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
4864 tempax = pVBInfo->VT;
4865 tempbx = pVBInfo->LCDVRS;
4868 if (tempcx >= tempax)
4871 temp = tempbx & 0x00FF; /* RTVACTEE=lcdvrs */
4872 xgifb_reg_set(pVBInfo->Part2Port, 0x04, temp);
4873 temp = (tempbx & 0xFF00) >> 8;
4875 temp |= (tempcx & 0x000F);
4876 xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp);
4878 tempax = pVBInfo->HT;
4879 tempbx = pVBInfo->LCDHDES;
4882 if (XGI_IsLCDDualLink(pVBInfo)) {
4883 tempax = tempax >> 1;
4884 tempbx = tempbx >> 1;
4885 tempcx = tempcx >> 1;
4888 if (pVBInfo->VBType & VB_SIS302LV)
4891 if (pVBInfo->VBType & VB_XGI301C) /* tap4 */
4896 if (tempcx >= tempax)
4899 temp = tempbx & 0x00FF;
4900 xgifb_reg_set(pVBInfo->Part2Port, 0x1F, temp); /* RHBLKE=lcdhdes */
4901 temp = ((tempbx & 0xFF00) >> 8) << 4;
4902 xgifb_reg_set(pVBInfo->Part2Port, 0x20, temp);
4903 temp = tempcx & 0x00FF;
4904 xgifb_reg_set(pVBInfo->Part2Port, 0x23, temp); /* RHEQPLE=lcdhdee */
4905 temp = (tempcx & 0xFF00) >> 8;
4906 xgifb_reg_set(pVBInfo->Part2Port, 0x25, temp);
4908 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
4910 tempax = pVBInfo->HT;
4911 tempbx = pVBInfo->LCDHRS;
4912 if (XGI_IsLCDDualLink(pVBInfo)) {
4913 tempax = tempax >> 1;
4914 tempbx = tempbx >> 1;
4915 tempcx = tempcx >> 1;
4918 if (pVBInfo->VBType & VB_SIS302LV)
4923 if (tempcx >= tempax)
4926 temp = tempbx & 0x00FF; /* RHBURSTS=lcdhrs */
4927 xgifb_reg_set(pVBInfo->Part2Port, 0x1C, temp);
4929 temp = (tempbx & 0xFF00) >> 8;
4931 xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F0, temp);
4932 temp = tempcx & 0x00FF; /* RHSYEXP2S=lcdhre */
4933 xgifb_reg_set(pVBInfo->Part2Port, 0x21, temp);
4935 if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
4936 if (pVBInfo->VGAVDE == 525) {
4937 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B
4938 | VB_SIS301LV | VB_SIS302LV
4944 xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp);
4945 xgifb_reg_set(pVBInfo->Part2Port, 0x30, 0xB3);
4948 if (pVBInfo->VGAVDE == 420) {
4949 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B
4950 | VB_SIS301LV | VB_SIS302LV
4955 xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp);
4960 /* --------------------------------------------------------------------- */
4961 /* Function : XGI_GetTap4Ptr */
4963 /* Output : di -> Tap4 Reg. Setting Pointer */
4965 /* --------------------------------------------------------------------- */
4966 static struct XGI301C_Tap4TimingStruct *XGI_GetTap4Ptr(unsigned short tempcx,
4967 struct vb_device_info *pVBInfo)
4969 unsigned short tempax, tempbx, i;
4971 struct XGI301C_Tap4TimingStruct *Tap4TimingPtr;
4974 tempax = pVBInfo->VGAHDE;
4975 tempbx = pVBInfo->HDE;
4977 tempax = pVBInfo->VGAVDE;
4978 tempbx = pVBInfo->VDE;
4981 if (tempax <= tempbx)
4982 return &xgifb_tap4_timing[0];
4984 Tap4TimingPtr = xgifb_ntsc_525_tap4_timing; /* NTSC */
4986 if (pVBInfo->TVInfo & TVSetPAL)
4987 Tap4TimingPtr = PALTap4Timing;
4989 if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
4990 if ((pVBInfo->TVInfo & TVSetYPbPr525i) ||
4991 (pVBInfo->TVInfo & TVSetYPbPr525p))
4992 Tap4TimingPtr = xgifb_ntsc_525_tap4_timing;
4993 if (pVBInfo->TVInfo & TVSetYPbPr750p)
4994 Tap4TimingPtr = YPbPr750pTap4Timing;
4997 if (pVBInfo->VBInfo & SetCRT2ToHiVision)
4998 Tap4TimingPtr = xgifb_tap4_timing;
5001 while (Tap4TimingPtr[i].DE != 0xFFFF) {
5002 if (Tap4TimingPtr[i].DE == tempax)
5006 return &Tap4TimingPtr[i];
5009 static void XGI_SetTap4Regs(struct vb_device_info *pVBInfo)
5011 unsigned short i, j;
5013 struct XGI301C_Tap4TimingStruct *Tap4TimingPtr;
5015 if (!(pVBInfo->VBType & VB_XGI301C))
5018 Tap4TimingPtr = XGI_GetTap4Ptr(0, pVBInfo); /* Set Horizontal Scaling */
5019 for (i = 0x80, j = 0; i <= 0xBF; i++, j++)
5020 xgifb_reg_set(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]);
5022 if ((pVBInfo->VBInfo & SetCRT2ToTV) &&
5023 (!(pVBInfo->VBInfo & SetCRT2ToHiVision))) {
5024 /* Set Vertical Scaling */
5025 Tap4TimingPtr = XGI_GetTap4Ptr(1, pVBInfo);
5026 for (i = 0xC0, j = 0; i < 0xFF; i++, j++)
5027 xgifb_reg_set(pVBInfo->Part2Port,
5029 Tap4TimingPtr->Reg[j]);
5032 if ((pVBInfo->VBInfo & SetCRT2ToTV) &&
5033 (!(pVBInfo->VBInfo & SetCRT2ToHiVision)))
5034 /* Enable V.Scaling */
5035 xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x04);
5037 /* Enable H.Scaling */
5038 xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x10);
5041 static void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex,
5042 struct vb_device_info *pVBInfo)
5045 unsigned char *tempdi;
5046 unsigned short modeflag;
5048 /* si+Ext_ResInfo */
5049 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
5051 xgifb_reg_set(pVBInfo->Part3Port, 0x00, 0x00);
5052 if (pVBInfo->TVInfo & TVSetPAL) {
5053 xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA);
5054 xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8);
5056 xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xF5);
5057 xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xB7);
5060 if (!(pVBInfo->VBInfo & SetCRT2ToTV))
5063 if (pVBInfo->TVInfo & TVSetPALM) {
5064 xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA);
5065 xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8);
5066 xgifb_reg_set(pVBInfo->Part3Port, 0x3D, 0xA8);
5069 if ((pVBInfo->VBInfo & SetCRT2ToHiVision) || (pVBInfo->VBInfo
5070 & SetCRT2ToYPbPr525750)) {
5071 if (pVBInfo->TVInfo & TVSetYPbPr525i)
5074 tempdi = pVBInfo->HiTVGroup3Data;
5075 if (pVBInfo->SetFlag & TVSimuMode) {
5076 tempdi = pVBInfo->HiTVGroup3Simu;
5077 if (!(modeflag & Charx8Dot))
5078 tempdi = pVBInfo->HiTVGroup3Text;
5081 if (pVBInfo->TVInfo & TVSetYPbPr525p)
5082 tempdi = pVBInfo->Ren525pGroup3;
5084 if (pVBInfo->TVInfo & TVSetYPbPr750p)
5085 tempdi = pVBInfo->Ren750pGroup3;
5087 for (i = 0; i <= 0x3E; i++)
5088 xgifb_reg_set(pVBInfo->Part3Port, i, tempdi[i]);
5090 if (pVBInfo->VBType & VB_XGI301C) { /* Marcovision */
5091 if (pVBInfo->TVInfo & TVSetYPbPr525p)
5092 xgifb_reg_set(pVBInfo->Part3Port, 0x28, 0x3f);
5096 } /* {end of XGI_SetGroup3} */
5098 static void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex,
5099 unsigned short RefreshRateTableIndex,
5100 struct xgi_hw_device_info *HwDeviceExtension,
5101 struct vb_device_info *pVBInfo)
5103 unsigned short tempax, tempcx, tempbx, modeflag, temp, temp2;
5105 unsigned long tempebx, tempeax, templong;
5107 /* si+Ext_ResInfo */
5108 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
5109 temp = pVBInfo->RVBHCFACT;
5110 xgifb_reg_set(pVBInfo->Part4Port, 0x13, temp);
5112 tempbx = pVBInfo->RVBHCMAX;
5113 temp = tempbx & 0x00FF;
5114 xgifb_reg_set(pVBInfo->Part4Port, 0x14, temp);
5115 temp2 = ((tempbx & 0xFF00) >> 8) << 7;
5116 tempcx = pVBInfo->VGAHT - 1;
5117 temp = tempcx & 0x00FF;
5118 xgifb_reg_set(pVBInfo->Part4Port, 0x16, temp);
5120 temp = ((tempcx & 0xFF00) >> 8) << 3;
5123 tempcx = pVBInfo->VGAVT - 1;
5124 if (!(pVBInfo->VBInfo & SetCRT2ToTV))
5127 temp = tempcx & 0x00FF;
5128 xgifb_reg_set(pVBInfo->Part4Port, 0x17, temp);
5129 temp = temp2 | ((tempcx & 0xFF00) >> 8);
5130 xgifb_reg_set(pVBInfo->Part4Port, 0x15, temp);
5131 xgifb_reg_or(pVBInfo->Part4Port, 0x0D, 0x08);
5132 tempcx = pVBInfo->VBInfo;
5133 tempbx = pVBInfo->VGAHDE;
5135 if (modeflag & HalfDCLK)
5136 tempbx = tempbx >> 1;
5138 if (XGI_IsLCDDualLink(pVBInfo))
5139 tempbx = tempbx >> 1;
5141 if (tempcx & SetCRT2ToHiVision) {
5147 } else if (tempcx & SetCRT2ToTV) {
5153 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
5160 if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p)) {
5162 if (pVBInfo->VGAHDE == 1280)
5164 if (pVBInfo->VGAHDE == 1024)
5167 xgifb_reg_and_or(pVBInfo->Part4Port, 0x0E, ~0xEF, temp);
5169 tempebx = pVBInfo->VDE;
5171 if (tempcx & SetCRT2ToHiVision) {
5172 if (!(temp & 0xE000))
5173 tempbx = tempbx >> 1;
5176 tempcx = pVBInfo->RVBHRS;
5177 temp = tempcx & 0x00FF;
5178 xgifb_reg_set(pVBInfo->Part4Port, 0x18, temp);
5180 tempeax = pVBInfo->VGAVDE;
5183 if (tempeax <= tempebx) {
5184 tempcx = (tempcx & (~0x4000));
5185 tempeax = pVBInfo->VGAVDE;
5190 templong = (tempeax * 256 * 1024) % tempebx;
5191 tempeax = (tempeax * 256 * 1024) / tempebx;
5197 temp = (unsigned short) (tempebx & 0x000000FF);
5198 xgifb_reg_set(pVBInfo->Part4Port, 0x1B, temp);
5200 temp = (unsigned short) ((tempebx & 0x0000FF00) >> 8);
5201 xgifb_reg_set(pVBInfo->Part4Port, 0x1A, temp);
5202 tempbx = (unsigned short) (tempebx >> 16);
5203 temp = tempbx & 0x00FF;
5205 temp |= ((tempcx & 0xFF00) >> 8);
5206 xgifb_reg_set(pVBInfo->Part4Port, 0x19, temp);
5209 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
5210 | VB_SIS302LV | VB_XGI301C)) {
5212 xgifb_reg_set(pVBInfo->Part4Port, 0x1C, temp);
5213 tempax = pVBInfo->VGAHDE;
5214 if (modeflag & HalfDCLK)
5215 tempax = tempax >> 1;
5217 if (XGI_IsLCDDualLink(pVBInfo))
5218 tempax = tempax >> 1;
5220 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
5224 if (pVBInfo->VGAHDE > 800) {
5225 if (pVBInfo->VGAHDE == 1024)
5226 tempax = (tempax * 25 / 32) - 1;
5228 tempax = (tempax * 20 / 32) - 1;
5233 temp = (tempax & 0xFF00) >> 8;
5234 temp = ((temp & 0x0003) << 4);
5235 xgifb_reg_set(pVBInfo->Part4Port, 0x1E, temp);
5236 temp = (tempax & 0x00FF);
5237 xgifb_reg_set(pVBInfo->Part4Port, 0x1D, temp);
5239 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVision)) {
5240 if (pVBInfo->VGAHDE > 800)
5241 xgifb_reg_or(pVBInfo->Part4Port, 0x1E, 0x08);
5246 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5247 if (!(pVBInfo->TVInfo & (NTSC1024x768
5248 | TVSetYPbPr525p | TVSetYPbPr750p
5249 | TVSetHiVision))) {
5251 if ((pVBInfo->VBInfo & SetInSlaveMode)
5252 && (!(pVBInfo->TVInfo
5258 xgifb_reg_and_or(pVBInfo->Part4Port, 0x1F, 0x00C0, temp);
5259 tempbx = pVBInfo->HT;
5260 if (XGI_IsLCDDualLink(pVBInfo))
5261 tempbx = tempbx >> 1;
5262 tempbx = (tempbx >> 1) - 2;
5263 temp = ((tempbx & 0x0700) >> 8) << 3;
5264 xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, 0x00C0, temp);
5265 temp = tempbx & 0x00FF;
5266 xgifb_reg_set(pVBInfo->Part4Port, 0x22, temp);
5270 if (pVBInfo->ISXPDOS == 0)
5271 XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex,
5275 static void XGINew_EnableCRT2(struct vb_device_info *pVBInfo)
5277 xgifb_reg_and_or(pVBInfo->P3c4, 0x1E, 0xFF, 0x20);
5280 static void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex,
5281 struct vb_device_info *pVBInfo)
5283 unsigned short Pindex, Pdata;
5285 Pindex = pVBInfo->Part5Port;
5286 Pdata = pVBInfo->Part5Port + 1;
5287 if (pVBInfo->ModeType == ModeVGA) {
5288 if (!(pVBInfo->VBInfo & (SetInSlaveMode | LoadDACFlag
5289 | DisableCRT2Display))) {
5290 XGINew_EnableCRT2(pVBInfo);
5296 static void XGI_EnableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension,
5297 struct vb_device_info *pVBInfo)
5299 xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x40);
5302 static void XGI_DisableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension,
5303 struct vb_device_info *pVBInfo)
5306 xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x00);
5309 static unsigned char XGI_XG21CheckLVDSMode(struct xgifb_video_info *xgifb_info,
5310 unsigned short ModeNo, unsigned short ModeIdIndex,
5311 struct vb_device_info *pVBInfo)
5313 unsigned short xres, yres, colordepth, modeflag, resindex;
5315 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
5316 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
5317 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
5318 /* si+St_ModeFlag */
5319 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
5321 if (!(modeflag & Charx8Dot)) {
5326 if ((ModeNo > 0x13) && (modeflag & HalfDCLK))
5329 if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
5332 if (xres > xgifb_info->lvds_data.LVDSHDE)
5335 if (yres > xgifb_info->lvds_data.LVDSVDE)
5338 if (xres != xgifb_info->lvds_data.LVDSHDE ||
5339 yres != xgifb_info->lvds_data.LVDSVDE) {
5340 colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo);
5347 static void xgifb_set_lvds(struct xgifb_video_info *xgifb_info,
5349 unsigned short ModeNo,
5350 unsigned short ModeIdIndex,
5351 struct vb_device_info *pVBInfo)
5353 unsigned char temp, Miscdata;
5354 unsigned short xres, yres, modeflag, resindex;
5355 unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE;
5356 unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE;
5357 unsigned short value;
5359 temp = (unsigned char) ((xgifb_info->lvds_data.LVDS_Capability &
5360 (LCDPolarity << 8)) >> 8);
5361 temp &= LCDPolarity;
5362 Miscdata = (unsigned char) inb(pVBInfo->P3cc);
5364 outb((Miscdata & 0x3F) | temp, pVBInfo->P3c2);
5366 temp = xgifb_info->lvds_data.LVDS_Capability & LCDPolarity;
5367 /* SR35[7] FP VSync polarity */
5368 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80);
5369 /* SR30[5] FP HSync polarity */
5370 xgifb_reg_and_or(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1);
5372 if (chip_id == XG27)
5373 XGI_SetXG27FPBits(pVBInfo);
5375 XGI_SetXG21FPBits(pVBInfo);
5377 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
5378 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
5379 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
5380 /* si+St_ModeFlag */
5381 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
5383 if (!(modeflag & Charx8Dot))
5384 xres = xres * 8 / 9;
5386 LVDSHT = xgifb_info->lvds_data.LVDSHT;
5388 LVDSHBS = xres + (xgifb_info->lvds_data.LVDSHDE - xres) / 2;
5390 if (LVDSHBS > LVDSHT)
5393 LVDSHRS = LVDSHBS + xgifb_info->lvds_data.LVDSHFP;
5394 if (LVDSHRS > LVDSHT)
5397 LVDSHRE = LVDSHRS + xgifb_info->lvds_data.LVDSHSYNC;
5398 if (LVDSHRE > LVDSHT)
5401 LVDSHBE = LVDSHBS + LVDSHT - xgifb_info->lvds_data.LVDSHDE;
5403 LVDSVT = xgifb_info->lvds_data.LVDSVT;
5405 LVDSVBS = yres + (xgifb_info->lvds_data.LVDSVDE - yres) / 2;
5406 if (modeflag & DoubleScanMode)
5407 LVDSVBS += yres / 2;
5409 if (LVDSVBS > LVDSVT)
5412 LVDSVRS = LVDSVBS + xgifb_info->lvds_data.LVDSVFP;
5413 if (LVDSVRS > LVDSVT)
5416 LVDSVRE = LVDSVRS + xgifb_info->lvds_data.LVDSVSYNC;
5417 if (LVDSVRE > LVDSVT)
5420 LVDSVBE = LVDSVBS + LVDSVT - xgifb_info->lvds_data.LVDSVDE;
5422 temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
5423 xgifb_reg_set(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */
5425 if (!(modeflag & Charx8Dot))
5426 xgifb_reg_or(pVBInfo->P3c4, 0x1, 0x1);
5428 /* HT SR0B[1:0] CR00 */
5429 value = (LVDSHT >> 3) - 5;
5430 xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8);
5431 xgifb_reg_set(pVBInfo->P3d4, 0x0, (value & 0xFF));
5433 /* HBS SR0B[5:4] CR02 */
5434 value = (LVDSHBS >> 3) - 1;
5435 xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4);
5436 xgifb_reg_set(pVBInfo->P3d4, 0x2, (value & 0xFF));
5438 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
5439 value = (LVDSHBE >> 3) - 1;
5440 xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6);
5441 xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2);
5442 xgifb_reg_and_or(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F);
5444 /* HRS SR0B[7:6] CR04 */
5445 value = (LVDSHRS >> 3) + 2;
5446 xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2);
5447 xgifb_reg_set(pVBInfo->P3d4, 0x4, (value & 0xFF));
5449 /* Panel HRS SR2F[1:0] SR2E[7:0] */
5451 xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8);
5452 xgifb_reg_set(pVBInfo->P3c4, 0x2E, (value & 0xFF));
5454 /* HRE SR0C[2] CR05[4:0] */
5455 value = (LVDSHRE >> 3) + 2;
5456 xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3);
5457 xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F);
5459 /* Panel HRE SR2F[7:2] */
5461 xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2);
5463 /* VT SR0A[0] CR07[5][0] CR06 */
5465 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10);
5466 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4);
5467 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8);
5468 xgifb_reg_set(pVBInfo->P3d4, 0x06, (value & 0xFF));
5470 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
5471 value = LVDSVBS - 1;
5472 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8);
5473 xgifb_reg_and_or(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4);
5474 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5);
5475 xgifb_reg_set(pVBInfo->P3d4, 0x15, (value & 0xFF));
5477 /* VBE SR0A[4] CR16 */
5478 value = LVDSVBE - 1;
5479 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4);
5480 xgifb_reg_set(pVBInfo->P3d4, 0x16, (value & 0xFF));
5482 /* VRS SR0A[3] CR7[7][2] CR10 */
5483 value = LVDSVRS - 1;
5484 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7);
5485 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2);
5486 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6);
5487 xgifb_reg_set(pVBInfo->P3d4, 0x10, (value & 0xFF));
5489 if (chip_id == XG27) {
5490 /* Panel VRS SR35[2:0] SR34[7:0] */
5491 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07,
5492 (value & 0x700) >> 8);
5493 xgifb_reg_set(pVBInfo->P3c4, 0x34, value & 0xFF);
5495 /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */
5496 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0x03,
5497 (value & 0x600) >> 9);
5498 xgifb_reg_set(pVBInfo->P3c4, 0x34, (value >> 1) & 0xFF);
5499 xgifb_reg_and_or(pVBInfo->P3d4, 0x33, ~0x01, value & 0x01);
5502 /* VRE SR0A[5] CR11[3:0] */
5503 value = LVDSVRE - 1;
5504 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1);
5505 xgifb_reg_and_or(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F);
5507 /* Panel VRE SR3F[7:2] */
5508 if (chip_id == XG27)
5509 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC,
5510 (value << 2) & 0xFC);
5512 /* SR3F[7] has to be 0, h/w bug */
5513 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC,
5514 (value << 2) & 0x7C);
5516 for (temp = 0, value = 0; temp < 3; temp++) {
5518 xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, value);
5519 xgifb_reg_set(pVBInfo->P3c4,
5520 0x2B, xgifb_info->lvds_data.VCLKData1);
5521 xgifb_reg_set(pVBInfo->P3c4,
5522 0x2C, xgifb_info->lvds_data.VCLKData2);
5526 if (!(modeflag & Charx8Dot)) {
5527 inb(pVBInfo->P3da); /* reset 3da */
5528 outb(0x13, pVBInfo->P3c0); /* set index */
5529 /* set data, panning = 0, shift left 1 dot*/
5530 outb(0x00, pVBInfo->P3c0);
5532 inb(pVBInfo->P3da); /* Enable Attribute */
5533 outb(0x20, pVBInfo->P3c0);
5535 inb(pVBInfo->P3da); /* reset 3da */
5540 /* --------------------------------------------------------------------- */
5541 /* Function : XGI_IsLCDON */
5543 /* Output : 0 : Skip PSC Control */
5544 /* 1: Disable PSC */
5546 /* --------------------------------------------------------------------- */
5547 static unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo)
5549 unsigned short tempax;
5551 tempax = pVBInfo->VBInfo;
5552 if (tempax & SetCRT2ToDualEdge)
5554 else if (tempax & (DisableCRT2Display | SwitchCRT2 | SetSimuScanMode))
5560 /* --------------------------------------------------------------------- */
5561 /* Function : XGI_DisableChISLCD */
5563 /* Output : 0 -> Not LCD Mode */
5565 /* --------------------------------------------------------------------- */
5566 static unsigned char XGI_DisableChISLCD(struct vb_device_info *pVBInfo)
5568 unsigned short tempbx, tempah;
5570 tempbx = pVBInfo->SetFlag & (DisableChA | DisableChB);
5571 tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E));
5573 if (tempbx & (EnableChA | DisableChA)) {
5574 if (!(tempah & 0x08)) /* Chk LCDA Mode */
5578 if (!(tempbx & (EnableChB | DisableChB)))
5581 if (tempah & 0x01) /* Chk LCDB Mode */
5587 /* --------------------------------------------------------------------- */
5588 /* Function : XGI_EnableChISLCD */
5590 /* Output : 0 -> Not LCD mode */
5592 /* --------------------------------------------------------------------- */
5593 static unsigned char XGI_EnableChISLCD(struct vb_device_info *pVBInfo)
5595 unsigned short tempbx, tempah;
5597 tempbx = pVBInfo->SetFlag & (EnableChA | EnableChB);
5598 tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E));
5600 if (tempbx & (EnableChA | DisableChA)) {
5601 if (!(tempah & 0x08)) /* Chk LCDA Mode */
5605 if (!(tempbx & (EnableChB | DisableChB)))
5608 if (tempah & 0x01) /* Chk LCDB Mode */
5614 static void XGI_DisableBridge(struct xgifb_video_info *xgifb_info,
5615 struct xgi_hw_device_info *HwDeviceExtension,
5616 struct vb_device_info *pVBInfo)
5618 unsigned short tempah = 0;
5620 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
5621 | VB_SIS302LV | VB_XGI301C)) {
5623 if (!(pVBInfo->VBInfo &
5624 (DisableCRT2Display | SetSimuScanMode))) {
5625 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
5626 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
5627 tempah = 0x7F; /* Disable Channel A */
5628 if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA))
5629 /* Disable Channel B */
5632 if (pVBInfo->SetFlag & DisableChB)
5633 /* force to disable Cahnnel */
5636 if (pVBInfo->SetFlag & DisableChA)
5637 /* Force to disable Channel B */
5643 /* disable part4_1f */
5644 xgifb_reg_and(pVBInfo->Part4Port, 0x1F, tempah);
5646 if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) {
5647 if (((pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)))
5648 || (XGI_DisableChISLCD(pVBInfo))
5649 || (XGI_IsLCDON(pVBInfo)))
5650 /* LVDS Driver power down */
5651 xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x80);
5654 if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo
5655 & (DisableCRT2Display | XGI_SetCRT2ToLCDA
5656 | SetSimuScanMode))) {
5657 if (pVBInfo->SetFlag & GatingCRT)
5658 XGI_EnableGatingCRT(HwDeviceExtension, pVBInfo);
5659 XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo);
5662 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
5663 if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo
5664 & XGI_SetCRT2ToLCDA))
5666 xgifb_reg_and(pVBInfo->Part1Port, 0x1e, 0xdf);
5669 /* disable TV as primary VGA swap */
5670 xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xdf);
5672 if ((pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToDualEdge)))
5673 xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xdf);
5675 if ((pVBInfo->SetFlag & DisableChB) ||
5677 (DisableCRT2Display | SetSimuScanMode)) ||
5678 ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) &&
5680 (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV))))
5681 xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80);
5683 if ((pVBInfo->SetFlag & DisableChB) ||
5685 (DisableCRT2Display | SetSimuScanMode)) ||
5686 (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) ||
5688 (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV))) {
5689 /* save Part1 index 0 */
5690 tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00);
5691 /* BTDAC = 1, avoid VB reset */
5692 xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x10);
5694 xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF);
5695 /* restore Part1 index 0 */
5696 xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah);
5698 } else { /* {301} */
5699 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) {
5700 xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80);
5702 xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF);
5703 /* Disable TV asPrimary VGA swap */
5704 xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xDF);
5707 if (pVBInfo->VBInfo & (DisableCRT2Display | XGI_SetCRT2ToLCDA
5709 XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo);
5713 /* --------------------------------------------------------------------- */
5714 /* Function : XGI_GetTVPtrIndex */
5717 /* Description : bx 0 : ExtNTSC */
5729 /* --------------------------------------------------------------------- */
5730 static unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo)
5732 unsigned short tempbx = 0;
5734 if (pVBInfo->TVInfo & TVSetPAL)
5736 if (pVBInfo->TVInfo & TVSetHiVision)
5738 if (pVBInfo->TVInfo & TVSetYPbPr525i)
5740 if (pVBInfo->TVInfo & TVSetYPbPr525p)
5742 if (pVBInfo->TVInfo & TVSetYPbPr750p)
5744 if (pVBInfo->TVInfo & TVSimuMode)
5750 /* --------------------------------------------------------------------- */
5751 /* Function : XGI_GetTVPtrIndex2 */
5753 /* Output : bx 0 : NTSC */
5757 /* 4 : NTSC1024x768 */
5758 /* 5 : PAL-M 1024x768 */
5760 /* cl 0 : YFilter1 */
5763 /* 1 : 301B/302B/301LV/302LV */
5765 /* --------------------------------------------------------------------- */
5766 static void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char *tempcl,
5767 unsigned char *tempch, struct vb_device_info *pVBInfo)
5773 if (pVBInfo->TVInfo & TVSetPAL)
5776 if (pVBInfo->TVInfo & TVSetPALM)
5779 if (pVBInfo->TVInfo & TVSetPALN)
5782 if (pVBInfo->TVInfo & NTSC1024x768) {
5784 if (pVBInfo->TVInfo & TVSetPALM)
5788 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
5789 | VB_SIS302LV | VB_XGI301C)) {
5790 if ((!(pVBInfo->VBInfo & SetInSlaveMode)) || (pVBInfo->TVInfo
5797 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
5798 | VB_SIS302LV | VB_XGI301C))
5802 static void XGI_SetDelayComp(struct vb_device_info *pVBInfo)
5804 unsigned short index;
5806 unsigned char tempah, tempbl, tempbh;
5808 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
5809 | VB_SIS302LV | VB_XGI301C)) {
5810 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA
5811 | SetCRT2ToTV | SetCRT2ToRAMDAC)) {
5815 index = XGI_GetTVPtrIndex(pVBInfo); /* Get TV Delay */
5816 tempbl = pVBInfo->XGI_TVDelayList[index];
5818 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B
5819 | VB_SIS301LV | VB_SIS302LV
5821 tempbl = pVBInfo->XGI_TVDelayList2[index];
5823 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
5824 tempbl = tempbl >> 4;
5825 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
5827 index = XGI_GetLCDCapPtr(pVBInfo);
5828 tempbh = pVBInfo->LCDCapList[index].
5829 LCD_DelayCompensation;
5831 if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA))
5837 tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x2D);
5839 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD
5840 | SetCRT2ToTV)) { /* Channel B */
5845 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { /* Channel A */
5849 xgifb_reg_set(pVBInfo->Part1Port, 0x2D, tempah);
5851 } else if (pVBInfo->IF_DEF_LVDS == 1) {
5854 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
5855 /* / Get LCD Delay */
5856 tempah = pVBInfo->LCDCapList[
5857 XGI_GetLCDCapPtr(pVBInfo)].
5858 LCD_DelayCompensation;
5860 tempah = tempah << 4;
5861 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2D, 0x0f,
5867 static void XGI_SetLCDCap_A(unsigned short tempcx,
5868 struct vb_device_info *pVBInfo)
5870 unsigned short temp;
5872 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
5874 if (temp & LCDRGB18Bit) {
5875 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F,
5877 (unsigned short) (0x20 | (tempcx & 0x00C0)));
5878 xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80);
5880 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F,
5881 (unsigned short) (0x30 | (tempcx & 0x00C0)));
5882 xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00);
5886 /* --------------------------------------------------------------------- */
5887 /* Function : XGI_SetLCDCap_B */
5888 /* Input : cx -> LCD Capability */
5891 /* --------------------------------------------------------------------- */
5892 static void XGI_SetLCDCap_B(unsigned short tempcx,
5893 struct vb_device_info *pVBInfo)
5895 if (tempcx & EnableLCD24bpp) /* 24bits */
5896 xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0,
5897 (unsigned short) (((tempcx & 0x00ff) >> 6)
5900 xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0,
5901 (unsigned short) (((tempcx & 0x00ff) >> 6)
5902 | 0x18)); /* Enable Dither */
5905 static void XGI_LongWait(struct vb_device_info *pVBInfo)
5909 i = xgifb_reg_get(pVBInfo->P3c4, 0x1F);
5912 for (i = 0; i < 0xFFFF; i++) {
5913 if (!(inb(pVBInfo->P3da) & 0x08))
5917 for (i = 0; i < 0xFFFF; i++) {
5918 if ((inb(pVBInfo->P3da) & 0x08))
5924 static void SetSpectrum(struct vb_device_info *pVBInfo)
5926 unsigned short index;
5928 index = XGI_GetLCDCapPtr(pVBInfo);
5930 /* disable down spectrum D[4] */
5931 xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x8F);
5932 XGI_LongWait(pVBInfo);
5933 xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x20); /* reset spectrum */
5934 XGI_LongWait(pVBInfo);
5936 xgifb_reg_set(pVBInfo->Part4Port, 0x31,
5937 pVBInfo->LCDCapList[index].Spectrum_31);
5938 xgifb_reg_set(pVBInfo->Part4Port, 0x32,
5939 pVBInfo->LCDCapList[index].Spectrum_32);
5940 xgifb_reg_set(pVBInfo->Part4Port, 0x33,
5941 pVBInfo->LCDCapList[index].Spectrum_33);
5942 xgifb_reg_set(pVBInfo->Part4Port, 0x34,
5943 pVBInfo->LCDCapList[index].Spectrum_34);
5944 XGI_LongWait(pVBInfo);
5945 xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x40); /* enable spectrum */
5948 static void XGI_SetLCDCap(struct vb_device_info *pVBInfo)
5950 unsigned short tempcx;
5952 tempcx = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(pVBInfo)].LCD_Capability;
5954 if (pVBInfo->VBType &
5959 VB_XGI301C)) { /* 301LV/302LV only */
5960 if (pVBInfo->VBType &
5961 (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) {
5962 /* Set 301LV Capability */
5963 xgifb_reg_set(pVBInfo->Part4Port, 0x24,
5964 (unsigned char) (tempcx & 0x1F));
5967 xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D,
5968 ~((EnableVBCLKDRVLOW | EnablePLLSPLOW) >> 8),
5969 (unsigned short) ((tempcx & (EnableVBCLKDRVLOW
5970 | EnablePLLSPLOW)) >> 8));
5973 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
5974 | VB_SIS302LV | VB_XGI301C)) {
5975 if (pVBInfo->VBInfo & SetCRT2ToLCD)
5976 XGI_SetLCDCap_B(tempcx, pVBInfo);
5977 else if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)
5978 XGI_SetLCDCap_A(tempcx, pVBInfo);
5980 if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) {
5981 if (tempcx & EnableSpectrum)
5982 SetSpectrum(pVBInfo);
5986 XGI_SetLCDCap_A(tempcx, pVBInfo);
5990 /* --------------------------------------------------------------------- */
5991 /* Function : XGI_SetAntiFlicker */
5994 /* Description : Set TV Customized Param. */
5995 /* --------------------------------------------------------------------- */
5996 static void XGI_SetAntiFlicker(unsigned short ModeNo,
5997 unsigned short ModeIdIndex,
5998 struct vb_device_info *pVBInfo)
6000 unsigned short tempbx, index;
6002 unsigned char tempah;
6004 if (pVBInfo->TVInfo & (TVSetYPbPr525p | TVSetYPbPr750p))
6007 tempbx = XGI_GetTVPtrIndex(pVBInfo);
6009 index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVFlickerIndex;
6011 tempah = TVAntiFlickList[tempbx];
6012 tempah = tempah << 4;
6014 xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0x8F, tempah);
6017 static void XGI_SetEdgeEnhance(unsigned short ModeNo,
6018 unsigned short ModeIdIndex,
6019 struct vb_device_info *pVBInfo)
6021 unsigned short tempbx, index;
6023 unsigned char tempah;
6025 tempbx = XGI_GetTVPtrIndex(pVBInfo);
6027 index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVEdgeIndex;
6029 tempah = TVEdgeList[tempbx];
6030 tempah = tempah << 5;
6032 xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, tempah);
6035 static void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo)
6037 unsigned short tempbx;
6039 unsigned char tempcl, tempch;
6041 unsigned long tempData;
6043 XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */
6044 tempData = TVPhaseList[tempbx];
6046 xgifb_reg_set(pVBInfo->Part2Port, 0x31, (unsigned short) (tempData
6048 xgifb_reg_set(pVBInfo->Part2Port, 0x32, (unsigned short) ((tempData
6049 & 0x0000FF00) >> 8));
6050 xgifb_reg_set(pVBInfo->Part2Port, 0x33, (unsigned short) ((tempData
6051 & 0x00FF0000) >> 16));
6052 xgifb_reg_set(pVBInfo->Part2Port, 0x34, (unsigned short) ((tempData
6053 & 0xFF000000) >> 24));
6056 static void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex,
6057 struct vb_device_info *pVBInfo)
6059 unsigned short tempbx, index;
6061 unsigned char tempcl, tempch, tempal, *filterPtr;
6063 XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */
6068 filterPtr = NTSCYFilter1;
6072 filterPtr = PALYFilter1;
6079 filterPtr = xgifb_palmn_yfilter1;
6087 filterPtr = xgifb_yfilter2;
6094 tempal = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVYFilterIndex;
6100 if ((tempcl == 0) && (tempch == 1)) {
6101 xgifb_reg_set(pVBInfo->Part2Port, 0x35, 0);
6102 xgifb_reg_set(pVBInfo->Part2Port, 0x36, 0);
6103 xgifb_reg_set(pVBInfo->Part2Port, 0x37, 0);
6104 xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]);
6106 xgifb_reg_set(pVBInfo->Part2Port, 0x35, filterPtr[index++]);
6107 xgifb_reg_set(pVBInfo->Part2Port, 0x36, filterPtr[index++]);
6108 xgifb_reg_set(pVBInfo->Part2Port, 0x37, filterPtr[index++]);
6109 xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]);
6112 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
6113 | VB_SIS302LV | VB_XGI301C)) {
6114 xgifb_reg_set(pVBInfo->Part2Port, 0x48, filterPtr[index++]);
6115 xgifb_reg_set(pVBInfo->Part2Port, 0x49, filterPtr[index++]);
6116 xgifb_reg_set(pVBInfo->Part2Port, 0x4A, filterPtr[index++]);
6120 /* --------------------------------------------------------------------- */
6121 /* Function : XGI_OEM310Setting */
6124 /* Description : Customized Param. for 301 */
6125 /* --------------------------------------------------------------------- */
6126 static void XGI_OEM310Setting(unsigned short ModeNo,
6127 unsigned short ModeIdIndex,
6128 struct vb_device_info *pVBInfo)
6130 XGI_SetDelayComp(pVBInfo);
6132 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))
6133 XGI_SetLCDCap(pVBInfo);
6135 if (pVBInfo->VBInfo & SetCRT2ToTV) {
6136 XGI_SetPhaseIncr(pVBInfo);
6137 XGI_SetYFilter(ModeNo, ModeIdIndex, pVBInfo);
6138 XGI_SetAntiFlicker(ModeNo, ModeIdIndex, pVBInfo);
6140 if (pVBInfo->VBType & VB_SIS301)
6141 XGI_SetEdgeEnhance(ModeNo, ModeIdIndex, pVBInfo);
6145 /* --------------------------------------------------------------------- */
6146 /* Function : XGI_SetCRT2ModeRegs */
6149 /* Description : Origin code for crt2group */
6150 /* --------------------------------------------------------------------- */
6151 static void XGI_SetCRT2ModeRegs(unsigned short ModeNo,
6152 struct xgi_hw_device_info *HwDeviceExtension,
6153 struct vb_device_info *pVBInfo)
6155 unsigned short tempbl;
6158 unsigned char tempah;
6161 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
6162 tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00);
6163 tempah &= ~0x10; /* BTRAMDAC */
6164 tempah |= 0x40; /* BTRAM */
6166 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV
6168 tempah = 0x40; /* BTDRAM */
6169 tempcl = pVBInfo->ModeType;
6173 tempah = (0x008 >> tempcl);
6178 if (pVBInfo->VBInfo & SetInSlaveMode)
6179 tempah ^= 0x50; /* BTDAC */
6183 xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah);
6187 if (pVBInfo->VBInfo & DisableCRT2Display) {
6188 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl, tempah);
6193 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV
6194 | SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
6195 if ((pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) &&
6196 (!(pVBInfo->VBInfo & SetSimuScanMode))) {
6199 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e,
6202 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
6207 if (pVBInfo->VBInfo &
6214 if (!(pVBInfo->VBInfo & SetInSlaveMode))
6217 if (!(pVBInfo->VBInfo &
6219 tempah = tempah ^ 0x05;
6220 if (!(pVBInfo->VBInfo &
6222 tempah = tempah ^ 0x01;
6225 if (!(pVBInfo->VBInfo &
6228 xgifb_reg_and_or(pVBInfo->Part1Port,
6229 0x2e, tempbl, tempah);
6231 xgifb_reg_and_or(pVBInfo->Part1Port,
6232 0x2e, tempbl, tempah);
6236 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl,
6241 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD
6242 | XGI_SetCRT2ToLCDA)) {
6244 if ((pVBInfo->ModeType == ModeVGA) && (!(pVBInfo->VBInfo
6245 & SetInSlaveMode))) {
6250 if (pVBInfo->VBInfo & SetCRT2ToTV) {
6252 if (pVBInfo->VBInfo & DriverMode)
6253 tempah = tempah ^ 0x20;
6256 xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D, ~0x0BF, tempah);
6259 if (pVBInfo->LCDInfo & SetLCDDualLink)
6262 if (pVBInfo->VBInfo & SetCRT2ToTV) {
6263 if (pVBInfo->TVInfo & RPLLDIV2XO)
6267 if ((pVBInfo->LCDResInfo == Panel_1280x1024)
6268 || (pVBInfo->LCDResInfo == Panel_1280x1024x75))
6271 if (pVBInfo->LCDResInfo == Panel_1280x960)
6274 xgifb_reg_set(pVBInfo->Part4Port, 0x0C, tempah);
6277 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
6278 | VB_SIS302LV | VB_XGI301C)) {
6282 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
6284 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)
6285 tempah |= 0x04; /* shampoo 0129 */
6288 xgifb_reg_and_or(pVBInfo->Part1Port, 0x13, tempbl, tempah);
6291 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
6292 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
6296 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2c, tempbl, tempah);
6300 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
6301 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
6304 xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, tempbl, tempah);
6309 if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) {
6311 if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge))
6315 xgifb_reg_and_or(pVBInfo->Part4Port, 0x23, tempbl, tempah);
6317 if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) {
6318 if (pVBInfo->LCDInfo & SetLCDDualLink) {
6319 xgifb_reg_or(pVBInfo->Part4Port, 0x27, 0x20);
6320 xgifb_reg_or(pVBInfo->Part4Port, 0x34, 0x10);
6325 static void XGI_CloseCRTC(struct xgi_hw_device_info *HwDeviceExtension,
6326 struct vb_device_info *pVBInfo)
6328 unsigned short tempbx;
6332 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)
6337 void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension,
6338 struct vb_device_info *pVBInfo)
6341 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2f, 0xFF, 0x01);
6345 void XGI_LockCRT2(struct xgi_hw_device_info *HwDeviceExtension,
6346 struct vb_device_info *pVBInfo)
6349 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2F, 0xFE, 0x00);
6353 unsigned char XGI_BridgeIsOn(struct vb_device_info *pVBInfo)
6355 unsigned short flag;
6357 if (pVBInfo->IF_DEF_LVDS == 1) {
6360 flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00);
6361 if ((flag == 1) || (flag == 2))
6362 return 1; /* 301b */
6368 unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE,
6369 unsigned short ModeNo, unsigned short ModeIdIndex,
6370 struct vb_device_info *pVBInfo)
6372 short LCDRefreshIndex[] = { 0x00, 0x00, 0x03, 0x01 },
6373 LCDARefreshIndex[] = { 0x00, 0x00, 0x03, 0x01, 0x01,
6376 unsigned short RefreshRateTableIndex, i, modeflag, index, temp;
6378 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
6380 index = xgifb_reg_get(pVBInfo->P3d4, 0x33);
6381 index = index >> pVBInfo->SelectCRT2Rate;
6384 if (pVBInfo->LCDInfo & LCDNonExpanding)
6390 if (pVBInfo->SetFlag & ProgrammingCRT2) {
6391 if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
6392 if (pVBInfo->IF_DEF_LVDS == 0) {
6393 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B
6394 | VB_SIS301LV | VB_SIS302LV
6397 temp = LCDARefreshIndex[
6398 pVBInfo->LCDResInfo & 0x0F];
6400 temp = LCDRefreshIndex[
6401 pVBInfo->LCDResInfo & 0x0F];
6411 RefreshRateTableIndex = pVBInfo->EModeIDTable[ModeIdIndex].REFindex;
6412 ModeNo = pVBInfo->RefIndex[RefreshRateTableIndex].ModeID;
6413 if (pXGIHWDE->jChipType >= XG20) { /* for XG20, XG21, XG27 */
6414 if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 800) &&
6415 (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 600)) {
6419 * do the similar adjustment like XGISearchCRT1Rate() */
6420 if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1024) &&
6421 (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 768)) {
6424 if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1280) &&
6425 (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 1024)) {
6432 if (pVBInfo->RefIndex[RefreshRateTableIndex + i].
6435 temp = pVBInfo->RefIndex[RefreshRateTableIndex + i].
6437 temp &= ModeTypeMask;
6438 if (temp < pVBInfo->ModeType)
6443 } while (index != 0xFFFF);
6444 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) {
6445 if (pVBInfo->VBInfo & SetInSlaveMode) {
6446 temp = pVBInfo->RefIndex[RefreshRateTableIndex + i - 1].
6448 if (temp & InterlaceMode)
6453 if ((pVBInfo->SetFlag & ProgrammingCRT2)) {
6454 temp = XGI_AjustCRT2Rate(ModeNo, ModeIdIndex,
6455 RefreshRateTableIndex, &i, pVBInfo);
6457 return RefreshRateTableIndex + i;
6460 static void XGI_SetLCDAGroup(unsigned short ModeNo, unsigned short ModeIdIndex,
6461 struct xgi_hw_device_info *HwDeviceExtension,
6462 struct vb_device_info *pVBInfo)
6464 unsigned short RefreshRateTableIndex;
6466 pVBInfo->SetFlag |= ProgrammingCRT2;
6467 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
6468 ModeIdIndex, pVBInfo);
6469 XGI_GetLVDSResInfo(ModeNo, ModeIdIndex, pVBInfo);
6470 XGI_GetLVDSData(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
6471 XGI_ModCRT1Regs(ModeNo, ModeIdIndex, RefreshRateTableIndex,
6472 HwDeviceExtension, pVBInfo);
6473 XGI_SetLVDSRegs(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
6474 XGI_SetCRT2ECLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
6477 static unsigned char XGI_SetCRT2Group301(unsigned short ModeNo,
6478 struct xgi_hw_device_info *HwDeviceExtension,
6479 struct vb_device_info *pVBInfo)
6481 unsigned short tempbx, ModeIdIndex, RefreshRateTableIndex;
6483 tempbx = pVBInfo->VBInfo;
6484 pVBInfo->SetFlag |= ProgrammingCRT2;
6485 XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo);
6486 pVBInfo->SelectCRT2Rate = 4;
6487 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
6488 ModeIdIndex, pVBInfo);
6489 XGI_SaveCRT2Info(ModeNo, pVBInfo);
6490 XGI_GetCRT2ResInfo(ModeNo, ModeIdIndex, pVBInfo);
6491 XGI_GetCRT2Data(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
6492 XGI_PreSetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension,
6493 RefreshRateTableIndex, pVBInfo);
6494 XGI_SetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension,
6495 RefreshRateTableIndex, pVBInfo);
6496 XGI_SetLockRegs(ModeNo, ModeIdIndex, HwDeviceExtension,
6497 RefreshRateTableIndex, pVBInfo);
6498 XGI_SetGroup2(ModeNo, ModeIdIndex, RefreshRateTableIndex,
6499 HwDeviceExtension, pVBInfo);
6500 XGI_SetLCDRegs(ModeNo, ModeIdIndex, HwDeviceExtension,
6501 RefreshRateTableIndex, pVBInfo);
6502 XGI_SetTap4Regs(pVBInfo);
6503 XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo);
6504 XGI_SetGroup4(ModeNo, ModeIdIndex, RefreshRateTableIndex,
6505 HwDeviceExtension, pVBInfo);
6506 XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
6507 XGI_SetGroup5(ModeNo, ModeIdIndex, pVBInfo);
6508 XGI_AutoThreshold(pVBInfo);
6512 void XGI_SenseCRT1(struct vb_device_info *pVBInfo)
6514 unsigned char CRTCData[17] = { 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81,
6515 0x0B, 0x3E, 0xE9, 0x0B, 0xDF, 0xE7, 0x04, 0x00, 0x00,
6518 unsigned char SR01 = 0, SR1F = 0, SR07 = 0, SR06 = 0;
6520 unsigned char CR17, CR63, SR31;
6521 unsigned short temp;
6522 unsigned char DAC_TEST_PARMS[3] = { 0x0F, 0x0F, 0x0F };
6525 xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86);
6527 /* [2004/05/06] Vicent to fix XG42 single LCD sense to CRT+LCD */
6528 xgifb_reg_set(pVBInfo->P3d4, 0x57, 0x4A);
6529 xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get(
6530 pVBInfo->P3d4, 0x53) | 0x02));
6532 SR31 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x31);
6533 CR63 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x63);
6534 SR01 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x01);
6536 xgifb_reg_set(pVBInfo->P3c4, 0x01, (unsigned char) (SR01 & 0xDF));
6537 xgifb_reg_set(pVBInfo->P3d4, 0x63, (unsigned char) (CR63 & 0xBF));
6539 CR17 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x17);
6540 xgifb_reg_set(pVBInfo->P3d4, 0x17, (unsigned char) (CR17 | 0x80));
6542 SR1F = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x1F);
6543 xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) (SR1F | 0x04));
6545 SR07 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x07);
6546 xgifb_reg_set(pVBInfo->P3c4, 0x07, (unsigned char) (SR07 & 0xFB));
6547 SR06 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x06);
6548 xgifb_reg_set(pVBInfo->P3c4, 0x06, (unsigned char) (SR06 & 0xC3));
6550 xgifb_reg_set(pVBInfo->P3d4, 0x11, 0x00);
6552 for (i = 0; i < 8; i++)
6553 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) i, CRTCData[i]);
6555 for (i = 8; i < 11; i++)
6556 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 8),
6559 for (i = 11; i < 13; i++)
6560 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 4),
6563 for (i = 13; i < 16; i++)
6564 xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i - 3),
6567 xgifb_reg_set(pVBInfo->P3c4, 0x0E, (unsigned char) (CRTCData[16]
6570 xgifb_reg_set(pVBInfo->P3c4, 0x31, 0x00);
6571 xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x1B);
6572 xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE1);
6574 outb(0x00, pVBInfo->P3c8);
6576 for (i = 0; i < 256; i++) {
6577 outb((unsigned char) DAC_TEST_PARMS[0], (pVBInfo->P3c8 + 1));
6578 outb((unsigned char) DAC_TEST_PARMS[1], (pVBInfo->P3c8 + 1));
6579 outb((unsigned char) DAC_TEST_PARMS[2], (pVBInfo->P3c8 + 1));
6584 XGI_WaitDisply(pVBInfo);
6585 temp = inb(pVBInfo->P3c2);
6588 xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x20);
6590 xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x00);
6592 /* alan, avoid display something, set BLACK DAC if not restore DAC */
6593 outb(0x00, pVBInfo->P3c8);
6595 for (i = 0; i < 256; i++) {
6596 outb(0, (pVBInfo->P3c8 + 1));
6597 outb(0, (pVBInfo->P3c8 + 1));
6598 outb(0, (pVBInfo->P3c8 + 1));
6601 xgifb_reg_set(pVBInfo->P3c4, 0x01, SR01);
6602 xgifb_reg_set(pVBInfo->P3d4, 0x63, CR63);
6603 xgifb_reg_set(pVBInfo->P3c4, 0x31, SR31);
6605 /* [2004/05/11] Vicent */
6606 xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get(
6607 pVBInfo->P3d4, 0x53) & 0xFD));
6608 xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) SR1F);
6611 static void XGI_EnableBridge(struct xgifb_video_info *xgifb_info,
6612 struct xgi_hw_device_info *HwDeviceExtension,
6613 struct vb_device_info *pVBInfo)
6615 unsigned short tempah;
6617 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
6618 | VB_SIS302LV | VB_XGI301C)) {
6619 if (!(pVBInfo->SetFlag & DisableChA)) {
6620 if (pVBInfo->SetFlag & EnableChA) {
6622 xgifb_reg_set(pVBInfo->Part1Port, 0x1E, 0x20);
6624 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
6626 xgifb_reg_set(pVBInfo->Part1Port,
6632 if (!(pVBInfo->SetFlag & DisableChB)) {
6633 if ((pVBInfo->SetFlag & EnableChB) || (pVBInfo->VBInfo
6634 & (SetCRT2ToLCD | SetCRT2ToTV
6635 | SetCRT2ToRAMDAC))) {
6636 tempah = (unsigned char) xgifb_reg_get(
6637 pVBInfo->P3c4, 0x32);
6639 if (pVBInfo->VBInfo & SetInSlaveMode) {
6640 if (!(pVBInfo->VBInfo &
6644 xgifb_reg_set(pVBInfo->P3c4, 0x32, tempah);
6645 xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x20);
6647 tempah = (unsigned char) xgifb_reg_get(
6648 pVBInfo->Part1Port, 0x2E);
6650 if (!(tempah & 0x80))
6651 xgifb_reg_or(pVBInfo->Part1Port,
6653 xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F);
6657 if ((pVBInfo->SetFlag & (EnableChA | EnableChB))
6658 || (!(pVBInfo->VBInfo & DisableCRT2Display))) {
6659 xgifb_reg_and_or(pVBInfo->Part2Port, 0x00, ~0xE0,
6660 0x20); /* shampoo 0129 */
6661 if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) {
6662 if (!XGI_DisableChISLCD(pVBInfo)) {
6663 if (XGI_EnableChISLCD(pVBInfo) ||
6665 (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)))
6666 /* LVDS PLL power on */
6672 /* LVDS Driver power on */
6673 xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x7F);
6679 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
6682 if (!(pVBInfo->VBInfo & SetSimuScanMode)) {
6683 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
6684 if (pVBInfo->VBInfo &
6685 SetCRT2ToDualEdge) {
6686 tempah = tempah & 0x40;
6687 if (pVBInfo->VBInfo &
6689 tempah = tempah ^ 0xC0;
6691 if (pVBInfo->SetFlag &
6695 if (pVBInfo->SetFlag &
6699 if (pVBInfo->SetFlag &
6703 if (pVBInfo->SetFlag &
6711 /* EnablePart4_1F */
6712 xgifb_reg_or(pVBInfo->Part4Port, 0x1F, tempah);
6714 if (!(pVBInfo->SetFlag & DisableChA)) {
6715 if (!(pVBInfo->SetFlag & GatingCRT)) {
6716 XGI_DisableGatingCRT(HwDeviceExtension,
6718 XGI_DisplayOn(xgifb_info, HwDeviceExtension,
6724 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD
6725 | XGI_SetCRT2ToLCDA))
6727 xgifb_reg_or(pVBInfo->Part1Port, 0x1E, 0x20);
6729 tempah = (unsigned char) xgifb_reg_get(pVBInfo->Part1Port,
6731 if (!(tempah & 0x80))
6732 xgifb_reg_or(pVBInfo->Part1Port, 0x2E, 0x80);
6734 xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F);
6735 XGI_DisplayOn(xgifb_info, HwDeviceExtension, pVBInfo);
6739 static void XGI_SetCRT1Group(struct xgifb_video_info *xgifb_info,
6740 struct xgi_hw_device_info *HwDeviceExtension,
6741 unsigned short ModeNo, unsigned short ModeIdIndex,
6742 struct vb_device_info *pVBInfo)
6744 unsigned short RefreshRateTableIndex, temp;
6746 XGI_SetSeqRegs(ModeNo, ModeIdIndex, pVBInfo);
6747 outb(pVBInfo->StandTable->MISC, pVBInfo->P3c2);
6748 XGI_SetCRTCRegs(HwDeviceExtension, pVBInfo);
6749 XGI_SetATTRegs(ModeNo, ModeIdIndex, pVBInfo);
6750 XGI_SetGRCRegs(pVBInfo);
6751 XGI_ClearExt1Regs(pVBInfo);
6753 if (HwDeviceExtension->jChipType == XG27) {
6754 if (pVBInfo->IF_DEF_LVDS == 0)
6755 XGI_SetDefaultVCLK(pVBInfo);
6758 temp = ~ProgrammingCRT2;
6759 pVBInfo->SetFlag &= temp;
6760 pVBInfo->SelectCRT2Rate = 0;
6762 if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
6763 | VB_SIS302LV | VB_XGI301C)) {
6764 if (pVBInfo->VBInfo & (SetSimuScanMode | XGI_SetCRT2ToLCDA
6765 | SetInSlaveMode)) {
6766 pVBInfo->SetFlag |= ProgrammingCRT2;
6770 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
6771 ModeIdIndex, pVBInfo);
6772 if (RefreshRateTableIndex != 0xFFFF) {
6773 XGI_SetSync(RefreshRateTableIndex, pVBInfo);
6774 XGI_SetCRT1CRTC(ModeNo, ModeIdIndex, RefreshRateTableIndex,
6775 pVBInfo, HwDeviceExtension);
6776 XGI_SetCRT1DE(HwDeviceExtension, ModeNo, ModeIdIndex,
6777 RefreshRateTableIndex, pVBInfo);
6778 XGI_SetCRT1Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
6779 HwDeviceExtension, pVBInfo);
6780 XGI_SetCRT1VCLK(ModeNo, ModeIdIndex, HwDeviceExtension,
6781 RefreshRateTableIndex, pVBInfo);
6784 if (HwDeviceExtension->jChipType >= XG21) {
6785 temp = xgifb_reg_get(pVBInfo->P3d4, 0x38);
6788 if (HwDeviceExtension->jChipType == XG27)
6789 XGI_SetXG27CRTC(ModeNo, ModeIdIndex,
6790 RefreshRateTableIndex, pVBInfo);
6792 XGI_SetXG21CRTC(ModeNo, ModeIdIndex,
6793 RefreshRateTableIndex, pVBInfo);
6795 XGI_UpdateXG21CRTC(ModeNo, pVBInfo,
6796 RefreshRateTableIndex);
6798 xgifb_set_lcd(HwDeviceExtension->jChipType,
6799 pVBInfo, RefreshRateTableIndex, ModeNo);
6801 if (pVBInfo->IF_DEF_LVDS == 1)
6802 xgifb_set_lvds(xgifb_info,
6803 HwDeviceExtension->jChipType,
6804 ModeNo, ModeIdIndex, pVBInfo);
6808 pVBInfo->SetFlag &= (~ProgrammingCRT2);
6809 XGI_SetCRT1FIFO(ModeNo, HwDeviceExtension, pVBInfo);
6810 XGI_SetCRT1ModeRegs(HwDeviceExtension, ModeNo, ModeIdIndex,
6811 RefreshRateTableIndex, pVBInfo);
6812 XGI_LoadDAC(ModeNo, ModeIdIndex, pVBInfo);
6815 unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info,
6816 struct xgi_hw_device_info *HwDeviceExtension,
6817 unsigned short ModeNo)
6819 unsigned short ModeIdIndex;
6820 struct vb_device_info VBINF;
6821 struct vb_device_info *pVBInfo = &VBINF;
6822 pVBInfo->BaseAddr = xgifb_info->vga_base;
6823 pVBInfo->IF_DEF_LVDS = 0;
6824 pVBInfo->IF_DEF_LCDA = 1;
6826 if (HwDeviceExtension->jChipType >= XG20) { /* kuku 2004/06/25 */
6827 pVBInfo->IF_DEF_YPbPr = 0;
6828 pVBInfo->IF_DEF_HiVision = 0;
6829 pVBInfo->IF_DEF_CRT2Monitor = 0;
6830 pVBInfo->VBType = 0; /*set VBType default 0*/
6832 pVBInfo->IF_DEF_YPbPr = 1;
6833 pVBInfo->IF_DEF_HiVision = 1;
6834 pVBInfo->IF_DEF_CRT2Monitor = 1;
6837 pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14;
6838 pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24;
6839 pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10;
6840 pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e;
6841 pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12;
6842 pVBInfo->P3cc = pVBInfo->BaseAddr + 0x1C;
6843 pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a;
6844 pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16;
6845 pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17;
6846 pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18;
6847 pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19;
6848 pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A;
6849 pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00;
6850 pVBInfo->Part1Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_04;
6851 pVBInfo->Part2Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_10;
6852 pVBInfo->Part3Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_12;
6853 pVBInfo->Part4Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_14;
6854 pVBInfo->Part5Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_14 + 2;
6856 /* for x86 Linux, XG21 LVDS */
6857 if (HwDeviceExtension->jChipType == XG21) {
6858 if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0)
6859 pVBInfo->IF_DEF_LVDS = 1;
6861 if (HwDeviceExtension->jChipType == XG27) {
6862 if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) {
6863 if (xgifb_reg_get(pVBInfo->P3d4, 0x30) & 0x20)
6864 pVBInfo->IF_DEF_LVDS = 1;
6868 if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 */
6869 XGI_GetVBType(pVBInfo);
6871 InitTo330Pointer(HwDeviceExtension->jChipType, pVBInfo);
6873 ModeNo = ModeNo & 0x7F;
6874 xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86);
6876 if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 1.Openkey */
6877 XGI_UnLockCRT2(HwDeviceExtension, pVBInfo);
6879 XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo);
6881 if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */
6882 XGI_GetVBInfo(ModeNo, ModeIdIndex, HwDeviceExtension, pVBInfo);
6883 XGI_GetTVInfo(ModeNo, ModeIdIndex, pVBInfo);
6884 XGI_GetLCDInfo(ModeNo, ModeIdIndex, pVBInfo);
6885 XGI_DisableBridge(xgifb_info, HwDeviceExtension, pVBInfo);
6887 if (pVBInfo->VBInfo & (SetSimuScanMode | XGI_SetCRT2ToLCDA)) {
6888 XGI_SetCRT1Group(xgifb_info, HwDeviceExtension, ModeNo,
6889 ModeIdIndex, pVBInfo);
6891 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
6892 XGI_SetLCDAGroup(ModeNo, ModeIdIndex,
6893 HwDeviceExtension, pVBInfo);
6896 if (!(pVBInfo->VBInfo & SwitchCRT2)) {
6897 XGI_SetCRT1Group(xgifb_info,
6898 HwDeviceExtension, ModeNo,
6899 ModeIdIndex, pVBInfo);
6900 if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
6901 XGI_SetLCDAGroup(ModeNo, ModeIdIndex,
6908 if (pVBInfo->VBInfo & (SetSimuScanMode | SwitchCRT2)) {
6909 switch (HwDeviceExtension->ujVBChipID) {
6911 XGI_SetCRT2Group301(ModeNo, HwDeviceExtension,
6912 pVBInfo); /*add for CRT2 */
6916 XGI_SetCRT2Group301(ModeNo, HwDeviceExtension,
6917 pVBInfo); /*add for CRT2 */
6925 XGI_SetCRT2ModeRegs(ModeNo, HwDeviceExtension, pVBInfo);
6926 XGI_OEM310Setting(ModeNo, ModeIdIndex, pVBInfo); /*0212*/
6927 XGI_CloseCRTC(HwDeviceExtension, pVBInfo);
6928 XGI_EnableBridge(xgifb_info, HwDeviceExtension, pVBInfo);
6931 if (pVBInfo->IF_DEF_LVDS == 1)
6932 if (!XGI_XG21CheckLVDSMode(xgifb_info, ModeNo,
6937 pVBInfo->ModeType = pVBInfo->EModeIDTable[ModeIdIndex].
6938 Ext_ModeFlag & ModeTypeMask;
6940 pVBInfo->SetFlag = 0;
6941 pVBInfo->VBInfo = DisableCRT2Display;
6943 XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo);
6945 XGI_SetCRT1Group(xgifb_info, HwDeviceExtension, ModeNo,
6946 ModeIdIndex, pVBInfo);
6948 XGI_DisplayOn(xgifb_info, HwDeviceExtension, pVBInfo);
6951 XGI_UpdateModeInfo(HwDeviceExtension, pVBInfo);
6953 if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */
6954 XGI_LockCRT2(HwDeviceExtension, pVBInfo);