1
2 #include <asm/io.h>
3 #include <linux/delay.h>
4 #include <linux/types.h>
5 #include <linux/version.h>
6 #include "XGIfb.h"
7
8
9 #include "vb_def.h"
10 #include "vgatypes.h"
11 #include "vb_struct.h"
12 #include "vb_util.h"
13 #include "vb_table.h"
14 #include "vb_setmode.h"
15
16
17 #define IndexMask 0xff
18 #ifndef XGI_MASK_DUAL_CHIP
19 #define XGI_MASK_DUAL_CHIP 0x04 /* SR3A */
20 #endif
21
22 static unsigned short XGINew_MDA_DAC[] = {
23 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
25 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
26 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
27 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
29 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
30 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F};
31
32 static unsigned short XGINew_CGA_DAC[] = {
33 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
34 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
35 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
36 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
37 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
38 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
39 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
40 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F};
41
42 static unsigned short XGINew_EGA_DAC[] = {
43 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x05, 0x15,
44 0x20, 0x30, 0x24, 0x34, 0x21, 0x31, 0x25, 0x35,
45 0x08, 0x18, 0x0C, 0x1C, 0x09, 0x19, 0x0D, 0x1D,
46 0x28, 0x38, 0x2C, 0x3C, 0x29, 0x39, 0x2D, 0x3D,
47 0x02, 0x12, 0x06, 0x16, 0x03, 0x13, 0x07, 0x17,
48 0x22, 0x32, 0x26, 0x36, 0x23, 0x33, 0x27, 0x37,
49 0x0A, 0x1A, 0x0E, 0x1E, 0x0B, 0x1B, 0x0F, 0x1F,
50 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F};
51
52 static unsigned short XGINew_VGA_DAC[] = {
53 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
54 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
55 0x00, 0x05, 0x08, 0x0B, 0x0E, 0x11, 0x14, 0x18,
56 0x1C, 0x20, 0x24, 0x28, 0x2D, 0x32, 0x38, 0x3F,
57 0x00, 0x10, 0x1F, 0x2F, 0x3F, 0x1F, 0x27, 0x2F,
58 0x37, 0x3F, 0x2D, 0x31, 0x36, 0x3A, 0x3F, 0x00,
59 0x07, 0x0E, 0x15, 0x1C, 0x0E, 0x11, 0x15, 0x18,
60 0x1C, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x00, 0x04,
61 0x08, 0x0C, 0x10, 0x08, 0x0A, 0x0C, 0x0E, 0x10,
62 0x0B, 0x0C, 0x0D, 0x0F, 0x10};
63
InitTo330Pointer(unsigned char ChipType,struct vb_device_info * pVBInfo)64 void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo)
65 {
66 pVBInfo->SModeIDTable = (struct XGI_StStruct *) XGI330_SModeIDTable;
67 pVBInfo->StandTable = (struct XGI_StandTableStruct *) XGI330_StandTable;
68 pVBInfo->EModeIDTable = (struct XGI_ExtStruct *) XGI330_EModeIDTable;
69 pVBInfo->RefIndex = (struct XGI_Ext2Struct *) XGI330_RefIndex;
70 pVBInfo->XGINEWUB_CRT1Table
71 = (struct XGI_CRT1TableStruct *) XGI_CRT1Table;
72
73 /* add for new UNIVGABIOS */
74 /* XGINew_UBLCDDataTable = (struct XGI_LCDDataTablStruct *) XGI_LCDDataTable; */
75 /* XGINew_UBTVDataTable = (XGI_TVDataTablStruct *) XGI_TVDataTable; */
76
77 pVBInfo->MCLKData = (struct XGI_MCLKDataStruct *) XGI340New_MCLKData;
78 pVBInfo->ECLKData = (struct XGI_ECLKDataStruct *) XGI340_ECLKData;
79 pVBInfo->VCLKData = (struct XGI_VCLKDataStruct *) XGI_VCLKData;
80 pVBInfo->VBVCLKData = (struct XGI_VBVCLKDataStruct *) XGI_VBVCLKData;
81 pVBInfo->ScreenOffset = XGI330_ScreenOffset;
82 pVBInfo->StResInfo = (struct XGI_StResInfoStruct *) XGI330_StResInfo;
83 pVBInfo->ModeResInfo
84 = (struct XGI_ModeResInfoStruct *) XGI330_ModeResInfo;
85
86 pVBInfo->pOutputSelect = &XGI330_OutputSelect;
87 pVBInfo->pSoftSetting = &XGI330_SoftSetting;
88 pVBInfo->pSR07 = &XGI330_SR07;
89 pVBInfo->LCDResInfo = 0;
90 pVBInfo->LCDTypeInfo = 0;
91 pVBInfo->LCDInfo = 0;
92 pVBInfo->VBInfo = 0;
93 pVBInfo->TVInfo = 0;
94
95 pVBInfo->SR15 = XGI340_SR13;
96 pVBInfo->CR40 = XGI340_cr41;
97 pVBInfo->SR25 = XGI330_sr25;
98 pVBInfo->pSR31 = &XGI330_sr31;
99 pVBInfo->pSR32 = &XGI330_sr32;
100 pVBInfo->CR6B = XGI340_CR6B;
101 pVBInfo->CR6E = XGI340_CR6E;
102 pVBInfo->CR6F = XGI340_CR6F;
103 pVBInfo->CR89 = XGI340_CR89;
104 pVBInfo->AGPReg = XGI340_AGPReg;
105 pVBInfo->SR16 = XGI340_SR16;
106 pVBInfo->pCRCF = &XG40_CRCF;
107 pVBInfo->pXGINew_DRAMTypeDefinition = &XG40_DRAMTypeDefinition;
108
109 pVBInfo->CR49 = XGI330_CR49;
110 pVBInfo->pSR1F = &XGI330_SR1F;
111 pVBInfo->pSR21 = &XGI330_SR21;
112 pVBInfo->pSR22 = &XGI330_SR22;
113 pVBInfo->pSR23 = &XGI330_SR23;
114 pVBInfo->pSR24 = &XGI330_SR24;
115 pVBInfo->pSR33 = &XGI330_SR33;
116
117 pVBInfo->pCRT2Data_1_2 = &XGI330_CRT2Data_1_2;
118 pVBInfo->pCRT2Data_4_D = &XGI330_CRT2Data_4_D;
119 pVBInfo->pCRT2Data_4_E = &XGI330_CRT2Data_4_E;
120 pVBInfo->pCRT2Data_4_10 = &XGI330_CRT2Data_4_10;
121 pVBInfo->pRGBSenseData = &XGI330_RGBSenseData;
122 pVBInfo->pVideoSenseData = &XGI330_VideoSenseData;
123 pVBInfo->pYCSenseData = &XGI330_YCSenseData;
124 pVBInfo->pRGBSenseData2 = &XGI330_RGBSenseData2;
125 pVBInfo->pVideoSenseData2 = &XGI330_VideoSenseData2;
126 pVBInfo->pYCSenseData2 = &XGI330_YCSenseData2;
127
128 pVBInfo->NTSCTiming = XGI330_NTSCTiming;
129 pVBInfo->PALTiming = XGI330_PALTiming;
130 pVBInfo->HiTVExtTiming = XGI330_HiTVExtTiming;
131 pVBInfo->HiTVSt1Timing = XGI330_HiTVSt1Timing;
132 pVBInfo->HiTVSt2Timing = XGI330_HiTVSt2Timing;
133 pVBInfo->HiTVTextTiming = XGI330_HiTVTextTiming;
134 pVBInfo->YPbPr750pTiming = XGI330_YPbPr750pTiming;
135 pVBInfo->YPbPr525pTiming = XGI330_YPbPr525pTiming;
136 pVBInfo->YPbPr525iTiming = XGI330_YPbPr525iTiming;
137 pVBInfo->HiTVGroup3Data = XGI330_HiTVGroup3Data;
138 pVBInfo->HiTVGroup3Simu = XGI330_HiTVGroup3Simu;
139 pVBInfo->HiTVGroup3Text = XGI330_HiTVGroup3Text;
140 pVBInfo->Ren525pGroup3 = XGI330_Ren525pGroup3;
141 pVBInfo->Ren750pGroup3 = XGI330_Ren750pGroup3;
142
143 pVBInfo->TimingH = (struct XGI_TimingHStruct *) XGI_TimingH;
144 pVBInfo->TimingV = (struct XGI_TimingVStruct *) XGI_TimingV;
145 pVBInfo->UpdateCRT1 = (struct XGI_XG21CRT1Struct *) XGI_UpdateCRT1Table;
146
147 pVBInfo->CHTVVCLKUNTSC = XGI330_CHTVVCLKUNTSC;
148 pVBInfo->CHTVVCLKONTSC = XGI330_CHTVVCLKONTSC;
149 pVBInfo->CHTVVCLKUPAL = XGI330_CHTVVCLKUPAL;
150 pVBInfo->CHTVVCLKOPAL = XGI330_CHTVVCLKOPAL;
151
152 /* 310 customization related */
153 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType & VB_XGI302LV))
154 pVBInfo->LCDCapList = XGI_LCDDLCapList;
155 else
156 pVBInfo->LCDCapList = XGI_LCDCapList;
157
158 if ((ChipType == XG21) || (ChipType == XG27))
159 pVBInfo->XG21_LVDSCapList = XGI21_LCDCapList;
160
161 pVBInfo->XGI_TVDelayList = XGI301TVDelayList;
162 pVBInfo->XGI_TVDelayList2 = XGI301TVDelayList2;
163
164 pVBInfo->pXGINew_I2CDefinition = &XG40_I2CDefinition;
165
166 if (ChipType >= XG20)
167 pVBInfo->pXGINew_CR97 = &XG20_CR97;
168
169 if (ChipType == XG27) {
170 pVBInfo->MCLKData
171 = (struct XGI_MCLKDataStruct *) XGI27New_MCLKData;
172 pVBInfo->CR40 = XGI27_cr41;
173 pVBInfo->pXGINew_CR97 = &XG27_CR97;
174 pVBInfo->pSR36 = &XG27_SR36;
175 pVBInfo->pCR8F = &XG27_CR8F;
176 pVBInfo->pCRD0 = XG27_CRD0;
177 pVBInfo->pCRDE = XG27_CRDE;
178 pVBInfo->pSR40 = &XG27_SR40;
179 pVBInfo->pSR41 = &XG27_SR41;
180
181 }
182
183 if (ChipType >= XG20) {
184 pVBInfo->pDVOSetting = &XG21_DVOSetting;
185 pVBInfo->pCR2E = &XG21_CR2E;
186 pVBInfo->pCR2F = &XG21_CR2F;
187 pVBInfo->pCR46 = &XG21_CR46;
188 pVBInfo->pCR47 = &XG21_CR47;
189 }
190
191 }
192
XGI_GetModePtr(unsigned short ModeNo,unsigned short ModeIdIndex,struct vb_device_info * pVBInfo)193 static unsigned char XGI_GetModePtr(unsigned short ModeNo, unsigned short ModeIdIndex,
194 struct vb_device_info *pVBInfo)
195 {
196 unsigned char index;
197
198 if (ModeNo <= 0x13)
199 index = pVBInfo->SModeIDTable[ModeIdIndex].St_StTableIndex;
200 else {
201 if (pVBInfo->ModeType <= 0x02)
202 index = 0x1B; /* 02 -> ModeEGA */
203 else
204 index = 0x0F;
205 }
206 return index; /* Get pVBInfo->StandTable index */
207 }
208
209 /*
210 unsigned char XGI_SetBIOSData(unsigned short ModeNo, unsigned short ModeIdIndex) {
211 return (0);
212 }
213 */
214
215 /* unsigned char XGI_ClearBankRegs(unsigned short ModeNo, unsigned short ModeIdIndex) {
216 return( 0 ) ;
217 }
218 */
219
XGI_SetSeqRegs(unsigned short ModeNo,unsigned short StandTableIndex,unsigned short ModeIdIndex,struct vb_device_info * pVBInfo)220 static void XGI_SetSeqRegs(unsigned short ModeNo, unsigned short StandTableIndex,
221 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
222 {
223 unsigned char tempah, SRdata;
224
225 unsigned short i, modeflag;
226
227 if (ModeNo <= 0x13)
228 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
229 else
230 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
231
232 xgifb_reg_set(pVBInfo->P3c4, 0x00, 0x03); /* Set SR0 */
233 tempah = pVBInfo->StandTable[StandTableIndex].SR[0];
234
235 i = SetCRT2ToLCDA;
236 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
237 tempah |= 0x01;
238 } else {
239 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD)) {
240 if (pVBInfo->VBInfo & SetInSlaveMode)
241 tempah |= 0x01;
242 }
243 }
244
245 tempah |= 0x20; /* screen off */
246 xgifb_reg_set(pVBInfo->P3c4, 0x01, tempah); /* Set SR1 */
247
248 for (i = 02; i <= 04; i++) {
249 SRdata = pVBInfo->StandTable[StandTableIndex].SR[i - 1]; /* Get SR2,3,4 from file */
250 xgifb_reg_set(pVBInfo->P3c4, i, SRdata); /* Set SR2 3 4 */
251 }
252 }
253
XGI_SetMiscRegs(unsigned short StandTableIndex,struct vb_device_info * pVBInfo)254 static void XGI_SetMiscRegs(unsigned short StandTableIndex,
255 struct vb_device_info *pVBInfo)
256 {
257 unsigned char Miscdata;
258
259 Miscdata = pVBInfo->StandTable[StandTableIndex].MISC; /* Get Misc from file */
260 /*
261 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
262 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
263 Miscdata |= 0x0C;
264 }
265 }
266 */
267
268 outb(Miscdata, pVBInfo->P3c2); /* Set Misc(3c2) */
269 }
270
XGI_SetCRTCRegs(struct xgi_hw_device_info * HwDeviceExtension,unsigned short StandTableIndex,struct vb_device_info * pVBInfo)271 static void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension,
272 unsigned short StandTableIndex, struct vb_device_info *pVBInfo)
273 {
274 unsigned char CRTCdata;
275 unsigned short i;
276
277 CRTCdata = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
278 CRTCdata &= 0x7f;
279 xgifb_reg_set(pVBInfo->P3d4, 0x11, CRTCdata); /* Unlock CRTC */
280
281 for (i = 0; i <= 0x18; i++) {
282 CRTCdata = pVBInfo->StandTable[StandTableIndex].CRTC[i]; /* Get CRTC from file */
283 xgifb_reg_set(pVBInfo->P3d4, i, CRTCdata); /* Set CRTC(3d4) */
284 }
285 /*
286 if ((HwDeviceExtension->jChipType == XGI_630) && (HwDeviceExtension->jChipRevision == 0x30)) {
287 if (pVBInfo->VBInfo & SetInSlaveMode) {
288 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) {
289 xgifb_reg_set(pVBInfo->P3d4, 0x18, 0xFE);
290 }
291 }
292 }
293 */
294 }
295
XGI_SetATTRegs(unsigned short ModeNo,unsigned short StandTableIndex,unsigned short ModeIdIndex,struct vb_device_info * pVBInfo)296 static void XGI_SetATTRegs(unsigned short ModeNo, unsigned short StandTableIndex,
297 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
298 {
299 unsigned char ARdata;
300 unsigned short i, modeflag;
301
302 if (ModeNo <= 0x13)
303 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
304 else
305 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
306
307 for (i = 0; i <= 0x13; i++) {
308 ARdata = pVBInfo->StandTable[StandTableIndex].ATTR[i];
309 if (modeflag & Charx8Dot) { /* ifndef Dot9 */
310 if (i == 0x13) {
311 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
312 ARdata = 0;
313 } else {
314 if (pVBInfo->VBInfo & (SetCRT2ToTV
315 | SetCRT2ToLCD)) {
316 if (pVBInfo->VBInfo
317 & SetInSlaveMode)
318 ARdata = 0;
319 }
320 }
321 }
322 }
323
324 inb(pVBInfo->P3da); /* reset 3da */
325 outb(i, pVBInfo->P3c0); /* set index */
326 outb(ARdata, pVBInfo->P3c0); /* set data */
327 }
328
329 inb(pVBInfo->P3da); /* reset 3da */
330 outb(0x14, pVBInfo->P3c0); /* set index */
331 outb(0x00, pVBInfo->P3c0); /* set data */
332 inb(pVBInfo->P3da); /* Enable Attribute */
333 outb(0x20, pVBInfo->P3c0);
334 }
335
XGI_SetGRCRegs(unsigned short StandTableIndex,struct vb_device_info * pVBInfo)336 static void XGI_SetGRCRegs(unsigned short StandTableIndex,
337 struct vb_device_info *pVBInfo)
338 {
339 unsigned char GRdata;
340 unsigned short i;
341
342 for (i = 0; i <= 0x08; i++) {
343 GRdata = pVBInfo->StandTable[StandTableIndex].GRC[i]; /* Get GR from file */
344 xgifb_reg_set(pVBInfo->P3ce, i, GRdata); /* Set GR(3ce) */
345 }
346
347 if (pVBInfo->ModeType > ModeVGA) {
348 GRdata = (unsigned char) xgifb_reg_get(pVBInfo->P3ce, 0x05);
349 GRdata &= 0xBF; /* 256 color disable */
350 xgifb_reg_set(pVBInfo->P3ce, 0x05, GRdata);
351 }
352 }
353
XGI_ClearExt1Regs(struct vb_device_info * pVBInfo)354 static void XGI_ClearExt1Regs(struct vb_device_info *pVBInfo)
355 {
356 unsigned short i;
357
358 for (i = 0x0A; i <= 0x0E; i++)
359 xgifb_reg_set(pVBInfo->P3c4, i, 0x00); /* Clear SR0A-SR0E */
360 }
361
XGI_SetDefaultVCLK(struct vb_device_info * pVBInfo)362 static unsigned char XGI_SetDefaultVCLK(struct vb_device_info *pVBInfo)
363 {
364
365 xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x20);
366 xgifb_reg_set(pVBInfo->P3c4, 0x2B, pVBInfo->VCLKData[0].SR2B);
367 xgifb_reg_set(pVBInfo->P3c4, 0x2C, pVBInfo->VCLKData[0].SR2C);
368
369 xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x10);
370 xgifb_reg_set(pVBInfo->P3c4, 0x2B, pVBInfo->VCLKData[1].SR2B);
371 xgifb_reg_set(pVBInfo->P3c4, 0x2C, pVBInfo->VCLKData[1].SR2C);
372
373 xgifb_reg_and(pVBInfo->P3c4, 0x31, ~0x30);
374 return 0;
375 }
376
XGI_AjustCRT2Rate(unsigned short ModeNo,unsigned short ModeIdIndex,unsigned short RefreshRateTableIndex,unsigned short * i,struct vb_device_info * pVBInfo)377 static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo,
378 unsigned short ModeIdIndex,
379 unsigned short RefreshRateTableIndex, unsigned short *i,
380 struct vb_device_info *pVBInfo)
381 {
382 unsigned short tempax, tempbx, resinfo, modeflag, infoflag;
383
384 if (ModeNo <= 0x13)
385 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ModeFlag */
386 else
387 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
388
389 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
390 tempbx = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID;
391 tempax = 0;
392
393 if (pVBInfo->IF_DEF_LVDS == 0) {
394 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
395 tempax |= SupportRAMDAC2;
396
397 if (pVBInfo->VBType & VB_XGI301C)
398 tempax |= SupportCRT2in301C;
399 }
400
401 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { /* 301b */
402 tempax |= SupportLCD;
403
404 if (pVBInfo->LCDResInfo != Panel1280x1024) {
405 if (pVBInfo->LCDResInfo != Panel1280x960) {
406 if (pVBInfo->LCDInfo & LCDNonExpanding) {
407 if (resinfo >= 9) {
408 tempax = 0;
409 return 0;
410 }
411 }
412 }
413 }
414 }
415
416 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { /* for HiTV */
417 if ((pVBInfo->VBType & VB_XGI301LV)
418 && (pVBInfo->VBExtInfo == VB_YPbPr1080i)) {
419 tempax |= SupportYPbPr;
420 if (pVBInfo->VBInfo & SetInSlaveMode) {
421 if (resinfo == 4)
422 return 0;
423
424 if (resinfo == 3)
425 return 0;
426
427 if (resinfo > 7)
428 return 0;
429 }
430 } else {
431 tempax |= SupportHiVisionTV;
432 if (pVBInfo->VBInfo & SetInSlaveMode) {
433 if (resinfo == 4)
434 return 0;
435
436 if (resinfo == 3) {
437 if (pVBInfo->SetFlag
438 & TVSimuMode)
439 return 0;
440 }
441
442 if (resinfo > 7)
443 return 0;
444 }
445 }
446 } else {
447 if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO
448 | SetCRT2ToSVIDEO | SetCRT2ToSCART
449 | SetCRT2ToYPbPr | SetCRT2ToHiVisionTV)) {
450 tempax |= SupportTV;
451
452 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
453 | VB_XGI301LV | VB_XGI302LV
454 | VB_XGI301C)) {
455 tempax |= SupportTV1024;
456 }
457
458 if (!(pVBInfo->VBInfo & SetPALTV)) {
459 if (modeflag & NoSupportSimuTV) {
460 if (pVBInfo->VBInfo
461 & SetInSlaveMode) {
462 if (!(pVBInfo->VBInfo
463 & SetNotSimuMode)) {
464 return 0;
465 }
466 }
467 }
468 }
469 }
470 }
471 } else { /* for LVDS */
472 if (pVBInfo->IF_DEF_CH7005 == 1) {
473 if (pVBInfo->VBInfo & SetCRT2ToTV)
474 tempax |= SupportCHTV;
475 }
476
477 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
478 tempax |= SupportLCD;
479
480 if (resinfo > 0x08)
481 return 0; /* 1024x768 */
482
483 if (pVBInfo->LCDResInfo < Panel1024x768) {
484 if (resinfo > 0x07)
485 return 0; /* 800x600 */
486
487 if (resinfo == 0x04)
488 return 0; /* 512x384 */
489 }
490 }
491 }
492
493 for (; pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID == tempbx; (*i)--) {
494 infoflag
495 = pVBInfo->RefIndex[RefreshRateTableIndex
496 + (*i)].Ext_InfoFlag;
497 if (infoflag & tempax)
498 return 1;
499
500 if ((*i) == 0)
501 break;
502 }
503
504 for ((*i) = 0;; (*i)++) {
505 infoflag
506 = pVBInfo->RefIndex[RefreshRateTableIndex
507 + (*i)].Ext_InfoFlag;
508 if (pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID
509 != tempbx) {
510 return 0;
511 }
512
513 if (infoflag & tempax)
514 return 1;
515 }
516 return 1;
517 }
518
XGI_SetSync(unsigned short RefreshRateTableIndex,struct vb_device_info * pVBInfo)519 static void XGI_SetSync(unsigned short RefreshRateTableIndex,
520 struct vb_device_info *pVBInfo)
521 {
522 unsigned short sync, temp;
523
524 sync = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag >> 8; /* di+0x00 */
525 sync &= 0xC0;
526 temp = 0x2F;
527 temp |= sync;
528 outb(temp, pVBInfo->P3c2); /* Set Misc(3c2) */
529 }
530
XGI_SetCRT1Timing_H(struct vb_device_info * pVBInfo,struct xgi_hw_device_info * HwDeviceExtension)531 static void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo,
532 struct xgi_hw_device_info *HwDeviceExtension)
533 {
534 unsigned char data, data1, pushax;
535 unsigned short i, j;
536
537 /* xgifb_reg_set(pVBInfo->P3d4, 0x51, 0); */
538 /* xgifb_reg_set(pVBInfo->P3d4, 0x56, 0); */
539 /* xgifb_reg_and_or(pVBInfo->P3d4, 0x11, 0x7f, 0x00); */
540
541 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); /* unlock cr0-7 */
542 data &= 0x7F;
543 xgifb_reg_set(pVBInfo->P3d4, 0x11, data);
544
545 data = pVBInfo->TimingH[0].data[0];
546 xgifb_reg_set(pVBInfo->P3d4, 0, data);
547
548 for (i = 0x01; i <= 0x04; i++) {
549 data = pVBInfo->TimingH[0].data[i];
550 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 1), data);
551 }
552
553 for (i = 0x05; i <= 0x06; i++) {
554 data = pVBInfo->TimingH[0].data[i];
555 xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i + 6), data);
556 }
557
558 j = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0e);
559 j &= 0x1F;
560 data = pVBInfo->TimingH[0].data[7];
561 data &= 0xE0;
562 data |= j;
563 xgifb_reg_set(pVBInfo->P3c4, 0x0e, data);
564
565 if (HwDeviceExtension->jChipType >= XG20) {
566 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x04);
567 data = data - 1;
568 xgifb_reg_set(pVBInfo->P3d4, 0x04, data);
569 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x05);
570 data1 = data;
571 data1 &= 0xE0;
572 data &= 0x1F;
573 if (data == 0) {
574 pushax = data;
575 data = (unsigned char) xgifb_reg_get(pVBInfo->P3c4,
576 0x0c);
577 data &= 0xFB;
578 xgifb_reg_set(pVBInfo->P3c4, 0x0c, data);
579 data = pushax;
580 }
581 data = data - 1;
582 data |= data1;
583 xgifb_reg_set(pVBInfo->P3d4, 0x05, data);
584 data = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0e);
585 data = data >> 5;
586 data = data + 3;
587 if (data > 7)
588 data = data - 7;
589 data = data << 5;
590 xgifb_reg_and_or(pVBInfo->P3c4, 0x0e, ~0xE0, data);
591 }
592 }
593
XGI_SetCRT1Timing_V(unsigned short ModeIdIndex,unsigned short ModeNo,struct vb_device_info * pVBInfo)594 static void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex, unsigned short ModeNo,
595 struct vb_device_info *pVBInfo)
596 {
597 unsigned char data;
598 unsigned short i, j;
599
600 /* xgifb_reg_set(pVBInfo->P3d4, 0x51, 0); */
601 /* xgifb_reg_set(pVBInfo->P3d4, 0x56, 0); */
602 /* xgifb_reg_and_or(pVBInfo->P3d4, 0x11, 0x7f, 0x00); */
603
604 for (i = 0x00; i <= 0x01; i++) {
605 data = pVBInfo->TimingV[0].data[i];
606 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 6), data);
607 }
608
609 for (i = 0x02; i <= 0x03; i++) {
610 data = pVBInfo->TimingV[0].data[i];
611 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x0e), data);
612 }
613
614 for (i = 0x04; i <= 0x05; i++) {
615 data = pVBInfo->TimingV[0].data[i];
616 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x11), data);
617 }
618
619 j = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0a);
620 j &= 0xC0;
621 data = pVBInfo->TimingV[0].data[6];
622 data &= 0x3F;
623 data |= j;
624 xgifb_reg_set(pVBInfo->P3c4, 0x0a, data);
625
626 data = pVBInfo->TimingV[0].data[6];
627 data &= 0x80;
628 data = data >> 2;
629
630 if (ModeNo <= 0x13)
631 i = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
632 else
633 i = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
634
635 i &= DoubleScanMode;
636 if (i)
637 data |= 0x80;
638
639 j = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x09);
640 j &= 0x5F;
641 data |= j;
642 xgifb_reg_set(pVBInfo->P3d4, 0x09, data);
643 }
644
XGI_SetCRT1CRTC(unsigned short ModeNo,unsigned short ModeIdIndex,unsigned short RefreshRateTableIndex,struct vb_device_info * pVBInfo,struct xgi_hw_device_info * HwDeviceExtension)645 static void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
646 unsigned short RefreshRateTableIndex,
647 struct vb_device_info *pVBInfo,
648 struct xgi_hw_device_info *HwDeviceExtension)
649 {
650 unsigned char index, data;
651 unsigned short i;
652
653 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; /* Get index */
654 index = index & IndexMask;
655
656 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
657 data &= 0x7F;
658 xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */
659
660 for (i = 0; i < 8; i++)
661 pVBInfo->TimingH[0].data[i]
662 = pVBInfo->XGINEWUB_CRT1Table[index].CR[i];
663
664 for (i = 0; i < 7; i++)
665 pVBInfo->TimingV[0].data[i]
666 = pVBInfo->XGINEWUB_CRT1Table[index].CR[i + 8];
667
668 XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension);
669
670 XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo);
671
672 if (pVBInfo->ModeType > 0x03)
673 xgifb_reg_set(pVBInfo->P3d4, 0x14, 0x4F);
674 }
675
676 /* --------------------------------------------------------------------- */
677 /* Function : XGI_SetXG21CRTC */
678 /* Input : Stand or enhance CRTC table */
679 /* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */
680 /* Description : Set LCD timing */
681 /* --------------------------------------------------------------------- */
XGI_SetXG21CRTC(unsigned short ModeNo,unsigned short ModeIdIndex,unsigned short RefreshRateTableIndex,struct vb_device_info * pVBInfo)682 static void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
683 unsigned short RefreshRateTableIndex,
684 struct vb_device_info *pVBInfo)
685 {
686 unsigned char StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx;
687 unsigned short Temp1, Temp2, Temp3;
688
689 if (ModeNo <= 0x13) {
690 StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
691 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[4]; /* CR04 HRS */
692 xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); /* SR2E [7:0]->HRS */
693 Tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[5]; /* Tempbx: CR05 HRE */
694 Tempbx &= 0x1F; /* Tempbx: HRE[4:0] */
695 Tempcx = Tempax;
696 Tempcx &= 0xE0; /* Tempcx: HRS[7:5] */
697 Tempdx = Tempcx | Tempbx; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
698 if (Tempbx < (Tempax & 0x1F)) /* IF HRE < HRS */
699 Tempdx |= 0x20; /* Tempdx: HRE = HRE + 0x20 */
700 Tempdx <<= 2; /* Tempdx << 2 */
701 xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempdx); /* SR2F [7:2]->HRE */
702 xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00);
703
704 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[16]; /* Tempax: CR16 VRS */
705 Tempbx = Tempax; /* Tempbx=Tempax */
706 Tempax &= 0x01; /* Tempax: VRS[0] */
707 xgifb_reg_or(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS */
708 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[7]; /* Tempax: CR7 VRS */
709 Tempdx = Tempbx >> 1; /* Tempdx: VRS[7:1] */
710 Tempcx = Tempax & 0x04; /* Tempcx: CR7[2] */
711 Tempcx <<= 5; /* Tempcx[7]: VRS[8] */
712 Tempdx |= Tempcx; /* Tempdx: VRS[8:1] */
713 xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempdx); /* SR34[7:0]: VRS[8:1] */
714
715 Temp1 = Tempcx << 1; /* Temp1[8]: VRS[8] unsigned char -> unsigned short */
716 Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */
717 Tempax &= 0x80; /* Tempax[7]: CR7[7] */
718 Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */
719 Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */
720
721 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[17]; /* CR16 VRE */
722 Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
723 Temp2 = Temp1 & 0x3F0; /* Temp2[9:4]: VRS[9:4] */
724 Temp2 |= Tempax; /* Temp2[9:0]: VRE[9:0] */
725 Temp3 = Temp1 & 0x0F; /* Temp3[3:0]: VRS[3:0] */
726 if (Tempax < Temp3) /* VRE[3:0]<VRS[3:0] */
727 Temp2 |= 0x10; /* Temp2: VRE + 0x10 */
728 Temp2 &= 0xFF; /* Temp2[7:0]: VRE[7:0] */
729 Tempax = (unsigned char) Temp2; /* Tempax[7:0]: VRE[7:0] */
730 Tempax <<= 2; /* Tempax << 2: VRE[5:0] */
731 Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */
732 Temp1 >>= 9; /* [10:9]->[1:0] */
733 Tempbx = (unsigned char) Temp1; /* Tempbx[1:0]: VRS[10:9] */
734 Tempax |= Tempbx; /* VRE[5:0]VRS[10:9] */
735 Tempax &= 0x7F;
736 xgifb_reg_set(pVBInfo->P3c4, 0x3F, Tempax); /* SR3F D[7:2]->VRE D[1:0]->VRS */
737 } else {
738 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
739 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3]; /* Tempax: CR4 HRS */
740 Tempcx = Tempax; /* Tempcx: HRS */
741 xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); /* SR2E[7:0]->HRS */
742
743 Tempdx = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SRB */
744 Tempdx &= 0xC0; /* Tempdx[7:6]: SRB[7:6] */
745 Temp1 = Tempdx; /* Temp1[7:6]: HRS[9:8] */
746 Temp1 <<= 2; /* Temp1[9:8]: HRS[9:8] */
747 Temp1 |= Tempax; /* Temp1[9:0]: HRS[9:0] */
748
749 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */
750 Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */
751
752 Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[6]; /* SRC */
753 Tempbx &= 0x04; /* Tempbx[2]: HRE[5] */
754 Tempbx <<= 3; /* Tempbx[5]: HRE[5] */
755 Tempax |= Tempbx; /* Tempax[5:0]: HRE[5:0] */
756
757 Temp2 = Temp1 & 0x3C0; /* Temp2[9:6]: HRS[9:6] */
758 Temp2 |= Tempax; /* Temp2[9:0]: HRE[9:0] */
759
760 Tempcx &= 0x3F; /* Tempcx[5:0]: HRS[5:0] */
761 if (Tempax < Tempcx) /* HRE < HRS */
762 Temp2 |= 0x40; /* Temp2 + 0x40 */
763
764 Temp2 &= 0xFF;
765 Tempax = (unsigned char) Temp2; /* Tempax: HRE[7:0] */
766 Tempax <<= 2; /* Tempax[7:2]: HRE[5:0] */
767 Tempdx >>= 6; /* Tempdx[7:6]->[1:0] HRS[9:8] */
768 Tempax |= Tempdx; /* HRE[5:0]HRS[9:8] */
769 xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax); /* SR2F D[7:2]->HRE, D[1:0]->HRS */
770 xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00);
771
772 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10]; /* CR10 VRS */
773 Tempbx = Tempax; /* Tempbx: VRS */
774 Tempax &= 0x01; /* Tempax[0]: VRS[0] */
775 xgifb_reg_or(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS[0] */
776 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9]; /* CR7[2][7] VRE */
777 Tempcx = Tempbx >> 1; /* Tempcx[6:0]: VRS[7:1] */
778 Tempdx = Tempax & 0x04; /* Tempdx[2]: CR7[2] */
779 Tempdx <<= 5; /* Tempdx[7]: VRS[8] */
780 Tempcx |= Tempdx; /* Tempcx[7:0]: VRS[8:1] */
781 xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempcx); /* SR34[8:1]->VRS */
782
783 Temp1 = Tempdx; /* Temp1[7]: Tempdx[7] */
784 Temp1 <<= 1; /* Temp1[8]: VRS[8] */
785 Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */
786 Tempax &= 0x80;
787 Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */
788 Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */
789 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; /* Tempax: SRA */
790 Tempax &= 0x08; /* Tempax[3]: VRS[3] */
791 Temp2 = Tempax;
792 Temp2 <<= 7; /* Temp2[10]: VRS[10] */
793 Temp1 |= Temp2; /* Temp1[10:0]: VRS[10:0] */
794
795 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11]; /* Tempax: CR11 VRE */
796 Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
797 Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; /* Tempbx: SRA */
798 Tempbx &= 0x20; /* Tempbx[5]: VRE[5] */
799 Tempbx >>= 1; /* Tempbx[4]: VRE[4] */
800 Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */
801 Temp2 = Temp1 & 0x7E0; /* Temp2[10:5]: VRS[10:5] */
802 Temp2 |= Tempax; /* Temp2[10:5]: VRE[10:5] */
803
804 Temp3 = Temp1 & 0x1F; /* Temp3[4:0]: VRS[4:0] */
805 if (Tempax < Temp3) /* VRE < VRS */
806 Temp2 |= 0x20; /* VRE + 0x20 */
807
808 Temp2 &= 0xFF;
809 Tempax = (unsigned char) Temp2; /* Tempax: VRE[7:0] */
810 Tempax <<= 2; /* Tempax[7:0]; VRE[5:0]00 */
811 Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */
812 Temp1 >>= 9; /* Temp1[1:0]: VRS[10:9] */
813 Tempbx = (unsigned char) Temp1;
814 Tempax |= Tempbx; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */
815 Tempax &= 0x7F;
816 xgifb_reg_set(pVBInfo->P3c4, 0x3F, Tempax); /* SR3F D[7:2]->VRE D[1:0]->VRS */
817 }
818 }
819
XGI_SetXG27CRTC(unsigned short ModeNo,unsigned short ModeIdIndex,unsigned short RefreshRateTableIndex,struct vb_device_info * pVBInfo)820 static void XGI_SetXG27CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
821 unsigned short RefreshRateTableIndex,
822 struct vb_device_info *pVBInfo)
823 {
824 unsigned short StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx;
825
826 if (ModeNo <= 0x13) {
827 StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
828 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[4]; /* CR04 HRS */
829 xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); /* SR2E [7:0]->HRS */
830 Tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[5]; /* Tempbx: CR05 HRE */
831 Tempbx &= 0x1F; /* Tempbx: HRE[4:0] */
832 Tempcx = Tempax;
833 Tempcx &= 0xE0; /* Tempcx: HRS[7:5] */
834 Tempdx = Tempcx | Tempbx; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
835 if (Tempbx < (Tempax & 0x1F)) /* IF HRE < HRS */
836 Tempdx |= 0x20; /* Tempdx: HRE = HRE + 0x20 */
837 Tempdx <<= 2; /* Tempdx << 2 */
838 xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempdx); /* SR2F [7:2]->HRE */
839 xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00);
840
841 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[16]; /* Tempax: CR10 VRS */
842 xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempax); /* SR34[7:0]->VRS */
843 Tempcx = Tempax; /* Tempcx=Tempax=VRS[7:0] */
844 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[7]; /* Tempax[7][2]: CR7[7][2] VRS[9][8] */
845 Tempbx = Tempax; /* Tempbx=CR07 */
846 Tempax &= 0x04; /* Tempax[2]: CR07[2] VRS[8] */
847 Tempax >>= 2;
848 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x01, Tempax); /* SR35 D[0]->VRS D[8] */
849 Tempcx |= (Tempax << 8); /* Tempcx[8] |= VRS[8] */
850 Tempcx |= (Tempbx & 0x80) << 2; /* Tempcx[9] |= VRS[9] */
851
852 Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[17]; /* CR11 VRE */
853 Tempax &= 0x0F; /* Tempax: VRE[3:0] */
854 Tempbx = Tempcx; /* Tempbx=Tempcx=VRS[9:0] */
855 Tempbx &= 0x3F0; /* Tempbx[9:4]: VRS[9:4] */
856 Tempbx |= Tempax; /* Tempbx[9:0]: VRE[9:0] */
857 if (Tempax <= (Tempcx & 0x0F)) /* VRE[3:0]<=VRS[3:0] */
858 Tempbx |= 0x10; /* Tempbx: VRE + 0x10 */
859 Tempax = (unsigned char) Tempbx & 0xFF; /* Tempax[7:0]: VRE[7:0] */
860 Tempax <<= 2; /* Tempax << 2: VRE[5:0] */
861 Tempcx = (Tempcx & 0x600) >> 8; /* Tempcx VRS[10:9] */
862 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax); /* SR3F D[7:2]->VRE D[5:0] */
863 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x06, Tempcx); /* SR35 D[2:1]->VRS[10:9] */
864 } else {
865 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
866 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3]; /* Tempax: CR4 HRS */
867 Tempbx = Tempax; /* Tempbx: HRS[7:0] */
868 xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); /* SR2E[7:0]->HRS */
869
870 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SR0B */
871 Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
872 Tempbx |= (Tempax << 2); /* Tempbx: HRS[9:0] */
873
874 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */
875 Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */
876 Tempcx = Tempax; /* Tempcx: HRE[4:0] */
877
878 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[6]; /* SRC */
879 Tempax &= 0x04; /* Tempax[2]: HRE[5] */
880 Tempax <<= 3; /* Tempax[5]: HRE[5] */
881 Tempcx |= Tempax; /* Tempcx[5:0]: HRE[5:0] */
882
883 Tempbx = Tempbx & 0x3C0; /* Tempbx[9:6]: HRS[9:6] */
884 Tempbx |= Tempcx; /* Tempbx: HRS[9:6]HRE[5:0] */
885
886 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3]; /* Tempax: CR4 HRS */
887 Tempax &= 0x3F; /* Tempax: HRS[5:0] */
888 if (Tempcx <= Tempax) /* HRE[5:0] < HRS[5:0] */
889 Tempbx += 0x40; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/
890
891 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SR0B */
892 Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
893 Tempax >>= 6; /* Tempax[1:0]: HRS[9:8]*/
894 Tempax |= ((Tempbx << 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */
895 xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax); /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */
896 xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00);
897
898 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10]; /* CR10 VRS */
899 xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempax); /* SR34[7:0]->VRS[7:0] */
900
901 Tempcx = Tempax; /* Tempcx <= VRS[7:0] */
902 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9]; /* CR7[7][2] VRS[9][8] */
903 Tempbx = Tempax; /* Tempbx <= CR07[7:0] */
904 Tempax = Tempax & 0x04; /* Tempax[2]: CR7[2]: VRS[8] */
905 Tempax >>= 2; /* Tempax[0]: VRS[8] */
906 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x01, Tempax); /* SR35[0]: VRS[8] */
907 Tempcx |= (Tempax << 8); /* Tempcx <= VRS[8:0] */
908 Tempcx |= ((Tempbx & 0x80) << 2); /* Tempcx <= VRS[9:0] */
909 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; /* Tempax: SR0A */
910 Tempax &= 0x08; /* SR0A[3] VRS[10] */
911 Tempcx |= (Tempax << 7); /* Tempcx <= VRS[10:0] */
912
913 Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11]; /* Tempax: CR11 VRE */
914 Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
915 Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; /* Tempbx: SR0A */
916 Tempbx &= 0x20; /* Tempbx[5]: SR0A[5]: VRE[4] */
917 Tempbx >>= 1; /* Tempbx[4]: VRE[4] */
918 Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */
919 Tempbx = Tempcx; /* Tempbx: VRS[10:0] */
920 Tempbx &= 0x7E0; /* Tempbx[10:5]: VRS[10:5] */
921 Tempbx |= Tempax; /* Tempbx: VRS[10:5]VRE[4:0] */
922
923 if (Tempbx <= Tempcx) /* VRE <= VRS */
924 Tempbx |= 0x20; /* VRE + 0x20 */
925
926 Tempax = (Tempbx << 2) & 0xFF; /* Tempax: Tempax[7:0]; VRE[5:0]00 */
927 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax); /* SR3F[7:2]:VRE[5:0] */
928 Tempax = Tempcx >> 8;
929 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, Tempax); /* SR35[2:0]:VRS[10:8] */
930 }
931 }
932
933 /* --------------------------------------------------------------------- */
934 /* Function : XGI_SetXG21LCD */
935 /* Input : */
936 /* Output : FCLK duty cycle, FCLK delay compensation */
937 /* Description : All values set zero */
938 /* --------------------------------------------------------------------- */
XGI_SetXG21LCD(struct vb_device_info * pVBInfo,unsigned short RefreshRateTableIndex,unsigned short ModeNo)939 static void XGI_SetXG21LCD(struct vb_device_info *pVBInfo,
940 unsigned short RefreshRateTableIndex, unsigned short ModeNo)
941 {
942 unsigned short Data, Temp, b3CC;
943 unsigned short XGI_P3cc;
944
945 XGI_P3cc = pVBInfo->P3cc;
946
947 xgifb_reg_set(pVBInfo->P3d4, 0x2E, 0x00);
948 xgifb_reg_set(pVBInfo->P3d4, 0x2F, 0x00);
949 xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x00);
950 xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x00);
951 if (((*pVBInfo->pDVOSetting) & 0xC0) == 0xC0) {
952 xgifb_reg_set(pVBInfo->P3d4, 0x2E, *pVBInfo->pCR2E);
953 xgifb_reg_set(pVBInfo->P3d4, 0x2F, *pVBInfo->pCR2F);
954 xgifb_reg_set(pVBInfo->P3d4, 0x46, *pVBInfo->pCR46);
955 xgifb_reg_set(pVBInfo->P3d4, 0x47, *pVBInfo->pCR47);
956 }
957
958 Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
959
960 if (Temp & 0x01) {
961 xgifb_reg_or(pVBInfo->P3c4, 0x06, 0x40); /* 18 bits FP */
962 xgifb_reg_or(pVBInfo->P3c4, 0x09, 0x40);
963 }
964
965 xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */
966
967 xgifb_reg_and(pVBInfo->P3c4, 0x30, ~0x20);
968 xgifb_reg_and(pVBInfo->P3c4, 0x35, ~0x80);
969
970 if (ModeNo <= 0x13) {
971 b3CC = (unsigned char) inb(XGI_P3cc);
972 if (b3CC & 0x40)
973 xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20); /* Hsync polarity */
974 if (b3CC & 0x80)
975 xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80); /* Vsync polarity */
976 } else {
977 Data = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
978 if (Data & 0x4000)
979 xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20); /* Hsync polarity */
980 if (Data & 0x8000)
981 xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80); /* Vsync polarity */
982 }
983 }
984
XGI_SetXG27LCD(struct vb_device_info * pVBInfo,unsigned short RefreshRateTableIndex,unsigned short ModeNo)985 static void XGI_SetXG27LCD(struct vb_device_info *pVBInfo,
986 unsigned short RefreshRateTableIndex, unsigned short ModeNo)
987 {
988 unsigned short Data, Temp, b3CC;
989 unsigned short XGI_P3cc;
990
991 XGI_P3cc = pVBInfo->P3cc;
992
993 xgifb_reg_set(pVBInfo->P3d4, 0x2E, 0x00);
994 xgifb_reg_set(pVBInfo->P3d4, 0x2F, 0x00);
995 xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x00);
996 xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x00);
997
998 Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
999 if ((Temp & 0x03) == 0) { /* dual 12 */
1000 xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x13);
1001 xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x13);
1002 }
1003
1004 if (((*pVBInfo->pDVOSetting) & 0xC0) == 0xC0) {
1005 xgifb_reg_set(pVBInfo->P3d4, 0x2E, *pVBInfo->pCR2E);
1006 xgifb_reg_set(pVBInfo->P3d4, 0x2F, *pVBInfo->pCR2F);
1007 xgifb_reg_set(pVBInfo->P3d4, 0x46, *pVBInfo->pCR46);
1008 xgifb_reg_set(pVBInfo->P3d4, 0x47, *pVBInfo->pCR47);
1009 }
1010
1011 XGI_SetXG27FPBits(pVBInfo);
1012
1013 xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */
1014
1015 xgifb_reg_and(pVBInfo->P3c4, 0x30, ~0x20); /* Hsync polarity */
1016 xgifb_reg_and(pVBInfo->P3c4, 0x35, ~0x80); /* Vsync polarity */
1017
1018 if (ModeNo <= 0x13) {
1019 b3CC = (unsigned char) inb(XGI_P3cc);
1020 if (b3CC & 0x40)
1021 xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20); /* Hsync polarity */
1022 if (b3CC & 0x80)
1023 xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80); /* Vsync polarity */
1024 } else {
1025 Data = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1026 if (Data & 0x4000)
1027 xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20); /* Hsync polarity */
1028 if (Data & 0x8000)
1029 xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80); /* Vsync polarity */
1030 }
1031 }
1032
1033 /* --------------------------------------------------------------------- */
1034 /* Function : XGI_UpdateXG21CRTC */
1035 /* Input : */
1036 /* Output : CRT1 CRTC */
1037 /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */
1038 /* --------------------------------------------------------------------- */
XGI_UpdateXG21CRTC(unsigned short ModeNo,struct vb_device_info * pVBInfo,unsigned short RefreshRateTableIndex)1039 static void XGI_UpdateXG21CRTC(unsigned short ModeNo, struct vb_device_info *pVBInfo,
1040 unsigned short RefreshRateTableIndex)
1041 {
1042 int i, index = -1;
1043
1044 xgifb_reg_and(pVBInfo->P3d4, 0x11, 0x7F); /* Unlock CR0~7 */
1045 if (ModeNo <= 0x13) {
1046 for (i = 0; i < 12; i++) {
1047 if (ModeNo == pVBInfo->UpdateCRT1[i].ModeID)
1048 index = i;
1049 }
1050 } else {
1051 if (ModeNo == 0x2E
1052 && (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC
1053 == RES640x480x60))
1054 index = 12;
1055 else if (ModeNo == 0x2E
1056 && (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC
1057 == RES640x480x72))
1058 index = 13;
1059 else if (ModeNo == 0x2F)
1060 index = 14;
1061 else if (ModeNo == 0x50)
1062 index = 15;
1063 else if (ModeNo == 0x59)
1064 index = 16;
1065 }
1066
1067 if (index != -1) {
1068 xgifb_reg_set(pVBInfo->P3d4, 0x02,
1069 pVBInfo->UpdateCRT1[index].CR02);
1070 xgifb_reg_set(pVBInfo->P3d4, 0x03,
1071 pVBInfo->UpdateCRT1[index].CR03);
1072 xgifb_reg_set(pVBInfo->P3d4, 0x15,
1073 pVBInfo->UpdateCRT1[index].CR15);
1074 xgifb_reg_set(pVBInfo->P3d4, 0x16,
1075 pVBInfo->UpdateCRT1[index].CR16);
1076 }
1077 }
1078
XGI_SetCRT1DE(struct xgi_hw_device_info * HwDeviceExtension,unsigned short ModeNo,unsigned short ModeIdIndex,unsigned short RefreshRateTableIndex,struct vb_device_info * pVBInfo)1079 static void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension,
1080 unsigned short ModeNo, unsigned short ModeIdIndex,
1081 unsigned short RefreshRateTableIndex,
1082 struct vb_device_info *pVBInfo)
1083 {
1084 unsigned short resindex, tempax, tempbx, tempcx, temp, modeflag;
1085
1086 unsigned char data;
1087
1088 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
1089
1090 if (ModeNo <= 0x13) {
1091 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
1092 tempax = pVBInfo->StResInfo[resindex].HTotal;
1093 tempbx = pVBInfo->StResInfo[resindex].VTotal;
1094 } else {
1095 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1096 tempax = pVBInfo->ModeResInfo[resindex].HTotal;
1097 tempbx = pVBInfo->ModeResInfo[resindex].VTotal;
1098 }
1099
1100 if (modeflag & HalfDCLK)
1101 tempax = tempax >> 1;
1102
1103 if (ModeNo > 0x13) {
1104 if (modeflag & HalfDCLK)
1105 tempax = tempax << 1;
1106
1107 temp = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1108
1109 if (temp & InterlaceMode)
1110 tempbx = tempbx >> 1;
1111
1112 if (modeflag & DoubleScanMode)
1113 tempbx = tempbx << 1;
1114 }
1115
1116 tempcx = 8;
1117
1118 /* if (!(modeflag & Charx8Dot)) */
1119 /* tempcx = 9; */
1120
1121 tempax /= tempcx;
1122 tempax -= 1;
1123 tempbx -= 1;
1124 tempcx = tempax;
1125 temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
1126 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
1127 data &= 0x7F;
1128 xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */
1129 xgifb_reg_set(pVBInfo->P3d4, 0x01, (unsigned short) (tempcx & 0xff));
1130 xgifb_reg_and_or(pVBInfo->P3d4, 0x0b, ~0x0c,
1131 (unsigned short) ((tempcx & 0x0ff00) >> 10));
1132 xgifb_reg_set(pVBInfo->P3d4, 0x12, (unsigned short) (tempbx & 0xff));
1133 tempax = 0;
1134 tempbx = tempbx >> 8;
1135
1136 if (tempbx & 0x01)
1137 tempax |= 0x02;
1138
1139 if (tempbx & 0x02)
1140 tempax |= 0x40;
1141
1142 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x42, tempax);
1143 data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x07);
1144 data &= 0xFF;
1145 tempax = 0;
1146
1147 if (tempbx & 0x04)
1148 tempax |= 0x02;
1149
1150 xgifb_reg_and_or(pVBInfo->P3d4, 0x0a, ~0x02, tempax);
1151 xgifb_reg_set(pVBInfo->P3d4, 0x11, temp);
1152 }
1153
XGI_GetResInfo(unsigned short ModeNo,unsigned short ModeIdIndex,struct vb_device_info * pVBInfo)1154 unsigned short XGI_GetResInfo(unsigned short ModeNo,
1155 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
1156 {
1157 unsigned short resindex;
1158
1159 if (ModeNo <= 0x13)
1160 resindex = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; /* si+St_ResInfo */
1161 else
1162 resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; /* si+Ext_ResInfo */
1163 return resindex;
1164 }
1165
XGI_SetCRT1Offset(unsigned short ModeNo,unsigned short ModeIdIndex,unsigned short RefreshRateTableIndex,struct xgi_hw_device_info * HwDeviceExtension,struct vb_device_info * pVBInfo)1166 static void XGI_SetCRT1Offset(unsigned short ModeNo, unsigned short ModeIdIndex,
1167 unsigned short RefreshRateTableIndex,
1168 struct xgi_hw_device_info *HwDeviceExtension,
1169 struct vb_device_info *pVBInfo)
1170 {
1171 unsigned short temp, ah, al, temp2, i, DisplayUnit;
1172
1173 /* GetOffset */
1174 temp = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo;
1175 temp = temp >> 8;
1176 temp = pVBInfo->ScreenOffset[temp];
1177
1178 temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1179 temp2 &= InterlaceMode;
1180
1181 if (temp2)
1182 temp = temp << 1;
1183
1184 temp2 = pVBInfo->ModeType - ModeEGA;
1185
1186 switch (temp2) {
1187 case 0:
1188 temp2 = 1;
1189 break;
1190 case 1:
1191 temp2 = 2;
1192 break;
1193 case 2:
1194 temp2 = 4;
1195 break;
1196 case 3:
1197 temp2 = 4;
1198 break;
1199 case 4:
1200 temp2 = 6;
1201 break;
1202 case 5:
1203 temp2 = 8;
1204 break;
1205 default:
1206 break;
1207 }
1208
1209 if ((ModeNo >= 0x26) && (ModeNo <= 0x28))
1210 temp = temp * temp2 + temp2 / 2;
1211 else
1212 temp *= temp2;
1213
1214 /* SetOffset */
1215 DisplayUnit = temp;
1216 temp2 = temp;
1217 temp = temp >> 8; /* ah */
1218 temp &= 0x0F;
1219 i = xgifb_reg_get(pVBInfo->P3c4, 0x0E);
1220 i &= 0xF0;
1221 i |= temp;
1222 xgifb_reg_set(pVBInfo->P3c4, 0x0E, i);
1223
1224 temp = (unsigned char) temp2;
1225 temp &= 0xFF; /* al */
1226 xgifb_reg_set(pVBInfo->P3d4, 0x13, temp);
1227
1228 /* SetDisplayUnit */
1229 temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1230 temp2 &= InterlaceMode;
1231 if (temp2)
1232 DisplayUnit >>= 1;
1233
1234 DisplayUnit = DisplayUnit << 5;
1235 ah = (DisplayUnit & 0xff00) >> 8;
1236 al = DisplayUnit & 0x00ff;
1237 if (al == 0)
1238 ah += 1;
1239 else
1240 ah += 2;
1241
1242 if (HwDeviceExtension->jChipType >= XG20)
1243 if ((ModeNo == 0x4A) | (ModeNo == 0x49))
1244 ah -= 1;
1245
1246 xgifb_reg_set(pVBInfo->P3c4, 0x10, ah);
1247 }
1248
XGI_GetVCLK2Ptr(unsigned short ModeNo,unsigned short ModeIdIndex,unsigned short RefreshRateTableIndex,struct xgi_hw_device_info * HwDeviceExtension,struct vb_device_info * pVBInfo)1249 static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo,
1250 unsigned short ModeIdIndex,
1251 unsigned short RefreshRateTableIndex,
1252 struct xgi_hw_device_info *HwDeviceExtension,
1253 struct vb_device_info *pVBInfo)
1254 {
1255 unsigned short tempbx;
1256
1257 unsigned short LCDXlat1VCLK[4] = { VCLK65 + 2, VCLK65 + 2, VCLK65 + 2,
1258 VCLK65 + 2 };
1259 unsigned short LCDXlat2VCLK[4] = { VCLK108_2 + 5, VCLK108_2 + 5,
1260 VCLK108_2 + 5, VCLK108_2 + 5 };
1261 unsigned short LVDSXlat1VCLK[4] = { VCLK40, VCLK40, VCLK40, VCLK40 };
1262 unsigned short LVDSXlat2VCLK[4] = { VCLK65 + 2, VCLK65 + 2, VCLK65 + 2,
1263 VCLK65 + 2 };
1264 unsigned short LVDSXlat3VCLK[4] = { VCLK65 + 2, VCLK65 + 2, VCLK65 + 2,
1265 VCLK65 + 2 };
1266
1267 unsigned short CRT2Index, VCLKIndex;
1268 unsigned short modeflag, resinfo;
1269 unsigned char *CHTVVCLKPtr = NULL;
1270
1271 if (ModeNo <= 0x13) {
1272 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
1273 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
1274 CRT2Index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
1275 } else {
1276 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
1277 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
1278 CRT2Index
1279 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
1280 }
1281
1282 if (pVBInfo->IF_DEF_LVDS == 0) {
1283 CRT2Index = CRT2Index >> 6; /* for LCD */
1284 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { /*301b*/
1285 if (pVBInfo->LCDResInfo != Panel1024x768)
1286 VCLKIndex = LCDXlat2VCLK[CRT2Index];
1287 else
1288 VCLKIndex = LCDXlat1VCLK[CRT2Index];
1289 } else { /* for TV */
1290 if (pVBInfo->VBInfo & SetCRT2ToTV) {
1291 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
1292 if (pVBInfo->SetFlag & RPLLDIV2XO) {
1293 VCLKIndex = HiTVVCLKDIV2;
1294
1295 VCLKIndex += 25;
1296
1297 } else {
1298 VCLKIndex = HiTVVCLK;
1299
1300 VCLKIndex += 25;
1301
1302 }
1303
1304 if (pVBInfo->SetFlag & TVSimuMode) {
1305 if (modeflag & Charx8Dot) {
1306 VCLKIndex
1307 = HiTVSimuVCLK;
1308
1309 VCLKIndex += 25;
1310
1311 } else {
1312 VCLKIndex
1313 = HiTVTextVCLK;
1314
1315 VCLKIndex += 25;
1316
1317 }
1318 }
1319
1320 if (pVBInfo->VBType & VB_XGI301LV) { /* 301lv */
1321 if (!(pVBInfo->VBExtInfo
1322 == VB_YPbPr1080i)) {
1323 VCLKIndex
1324 = YPbPr750pVCLK;
1325 if (!(pVBInfo->VBExtInfo
1326 == VB_YPbPr750p)) {
1327 VCLKIndex
1328 = YPbPr525pVCLK;
1329 if (!(pVBInfo->VBExtInfo
1330 == VB_YPbPr525p)) {
1331 VCLKIndex
1332 = YPbPr525iVCLK_2;
1333 if (!(pVBInfo->SetFlag
1334 & RPLLDIV2XO))
1335 VCLKIndex
1336 = YPbPr525iVCLK;
1337 }
1338 }
1339 }
1340 }
1341 } else {
1342 if (pVBInfo->VBInfo & SetCRT2ToTV) {
1343 if (pVBInfo->SetFlag
1344 & RPLLDIV2XO) {
1345 VCLKIndex = TVVCLKDIV2;
1346
1347 VCLKIndex += 25;
1348
1349 } else {
1350 VCLKIndex = TVVCLK;
1351
1352 VCLKIndex += 25;
1353
1354 }
1355 }
1356 }
1357 } else { /* for CRT2 */
1358 VCLKIndex = (unsigned char) inb(
1359 (pVBInfo->P3ca + 0x02)); /* Port 3cch */
1360 VCLKIndex = ((VCLKIndex >> 2) & 0x03);
1361 if (ModeNo > 0x13) {
1362 VCLKIndex
1363 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; /* di+Ext_CRTVCLK */
1364 VCLKIndex &= IndexMask;
1365 }
1366 }
1367 }
1368 } else { /* LVDS */
1369 if (ModeNo <= 0x13)
1370 VCLKIndex = CRT2Index;
1371 else
1372 VCLKIndex = CRT2Index;
1373
1374 if (pVBInfo->IF_DEF_CH7005 == 1) {
1375 if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) {
1376 VCLKIndex &= 0x1f;
1377 tempbx = 0;
1378
1379 if (pVBInfo->VBInfo & SetPALTV)
1380 tempbx += 2;
1381
1382 if (pVBInfo->VBInfo & SetCHTVOverScan)
1383 tempbx += 1;
1384
1385 switch (tempbx) {
1386 case 0:
1387 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC;
1388 break;
1389 case 1:
1390 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC;
1391 break;
1392 case 2:
1393 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL;
1394 break;
1395 case 3:
1396 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL;
1397 break;
1398 default:
1399 break;
1400 }
1401
1402 VCLKIndex = CHTVVCLKPtr[VCLKIndex];
1403 }
1404 } else {
1405 VCLKIndex = VCLKIndex >> 6;
1406 if ((pVBInfo->LCDResInfo == Panel800x600)
1407 || (pVBInfo->LCDResInfo == Panel320x480))
1408 VCLKIndex = LVDSXlat1VCLK[VCLKIndex];
1409 else if ((pVBInfo->LCDResInfo == Panel1024x768)
1410 || (pVBInfo->LCDResInfo
1411 == Panel1024x768x75))
1412 VCLKIndex = LVDSXlat2VCLK[VCLKIndex];
1413 else
1414 VCLKIndex = LVDSXlat3VCLK[VCLKIndex];
1415 }
1416 }
1417 /* VCLKIndex = VCLKIndex&IndexMask; */
1418
1419 return VCLKIndex;
1420 }
1421
XGI_SetCRT1VCLK(unsigned short ModeNo,unsigned short ModeIdIndex,struct xgi_hw_device_info * HwDeviceExtension,unsigned short RefreshRateTableIndex,struct vb_device_info * pVBInfo)1422 static void XGI_SetCRT1VCLK(unsigned short ModeNo, unsigned short ModeIdIndex,
1423 struct xgi_hw_device_info *HwDeviceExtension,
1424 unsigned short RefreshRateTableIndex,
1425 struct vb_device_info *pVBInfo)
1426 {
1427 unsigned char index, data;
1428 unsigned short vclkindex;
1429
1430 if (pVBInfo->IF_DEF_LVDS == 1) {
1431 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1432 data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF;
1433 xgifb_reg_set(pVBInfo->P3c4, 0x31, data);
1434 xgifb_reg_set(pVBInfo->P3c4, 0x2B,
1435 pVBInfo->VCLKData[index].SR2B);
1436 xgifb_reg_set(pVBInfo->P3c4, 0x2C,
1437 pVBInfo->VCLKData[index].SR2C);
1438 xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01);
1439 } else if ((pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
1440 | VB_XGI302LV | VB_XGI301C)) && (pVBInfo->VBInfo
1441 & SetCRT2ToLCDA)) {
1442 vclkindex = XGI_GetVCLK2Ptr(ModeNo, ModeIdIndex,
1443 RefreshRateTableIndex, HwDeviceExtension,
1444 pVBInfo);
1445 data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF;
1446 xgifb_reg_set(pVBInfo->P3c4, 0x31, data);
1447 data = pVBInfo->VBVCLKData[vclkindex].Part4_A;
1448 xgifb_reg_set(pVBInfo->P3c4, 0x2B, data);
1449 data = pVBInfo->VBVCLKData[vclkindex].Part4_B;
1450 xgifb_reg_set(pVBInfo->P3c4, 0x2C, data);
1451 xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01);
1452 } else {
1453 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1454 data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF;
1455 xgifb_reg_set(pVBInfo->P3c4, 0x31, data);
1456 xgifb_reg_set(pVBInfo->P3c4, 0x2B,
1457 pVBInfo->VCLKData[index].SR2B);
1458 xgifb_reg_set(pVBInfo->P3c4, 0x2C,
1459 pVBInfo->VCLKData[index].SR2C);
1460 xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01);
1461 }
1462
1463 if (HwDeviceExtension->jChipType >= XG20) {
1464 if (pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag & HalfDCLK) {
1465 data = xgifb_reg_get(pVBInfo->P3c4, 0x2B);
1466 xgifb_reg_set(pVBInfo->P3c4, 0x2B, data);
1467 data = xgifb_reg_get(pVBInfo->P3c4, 0x2C);
1468 index = data;
1469 index &= 0xE0;
1470 data &= 0x1F;
1471 data = data << 1;
1472 data += 1;
1473 data |= index;
1474 xgifb_reg_set(pVBInfo->P3c4, 0x2C, data);
1475 }
1476 }
1477 }
1478
XGI_SetCRT1FIFO(unsigned short ModeNo,struct xgi_hw_device_info * HwDeviceExtension,struct vb_device_info * pVBInfo)1479 static void XGI_SetCRT1FIFO(unsigned short ModeNo,
1480 struct xgi_hw_device_info *HwDeviceExtension,
1481 struct vb_device_info *pVBInfo)
1482 {
1483 unsigned short data;
1484
1485 data = xgifb_reg_get(pVBInfo->P3c4, 0x3D);
1486 data &= 0xfe;
1487 xgifb_reg_set(pVBInfo->P3c4, 0x3D, data); /* diable auto-threshold */
1488
1489 if (ModeNo > 0x13) {
1490 xgifb_reg_set(pVBInfo->P3c4, 0x08, 0x34);
1491 data = xgifb_reg_get(pVBInfo->P3c4, 0x09);
1492 data &= 0xC0;
1493 xgifb_reg_set(pVBInfo->P3c4, 0x09, data | 0x30);
1494 data = xgifb_reg_get(pVBInfo->P3c4, 0x3D);
1495 data |= 0x01;
1496 xgifb_reg_set(pVBInfo->P3c4, 0x3D, data);
1497 } else {
1498 if (HwDeviceExtension->jChipType == XG27) {
1499 xgifb_reg_set(pVBInfo->P3c4, 0x08, 0x0E);
1500 data = xgifb_reg_get(pVBInfo->P3c4, 0x09);
1501 data &= 0xC0;
1502 xgifb_reg_set(pVBInfo->P3c4, 0x09, data | 0x20);
1503 } else {
1504 xgifb_reg_set(pVBInfo->P3c4, 0x08, 0xAE);
1505 data = xgifb_reg_get(pVBInfo->P3c4, 0x09);
1506 data &= 0xF0;
1507 xgifb_reg_set(pVBInfo->P3c4, 0x09, data);
1508 }
1509 }
1510
1511 if (HwDeviceExtension->jChipType == XG21)
1512 XGI_SetXG21FPBits(pVBInfo); /* Fix SR9[7:6] can't read back */
1513 }
1514
XGI_SetVCLKState(struct xgi_hw_device_info * HwDeviceExtension,unsigned short ModeNo,unsigned short RefreshRateTableIndex,struct vb_device_info * pVBInfo)1515 static void XGI_SetVCLKState(struct xgi_hw_device_info *HwDeviceExtension,
1516 unsigned short ModeNo, unsigned short RefreshRateTableIndex,
1517 struct vb_device_info *pVBInfo)
1518 {
1519 unsigned short data, data2 = 0;
1520 short VCLK;
1521
1522 unsigned char index;
1523
1524 if (ModeNo <= 0x13)
1525 VCLK = 0;
1526 else {
1527 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
1528 index &= IndexMask;
1529 VCLK = pVBInfo->VCLKData[index].CLOCK;
1530 }
1531
1532 data = xgifb_reg_get(pVBInfo->P3c4, 0x32);
1533 data &= 0xf3;
1534 if (VCLK >= 200)
1535 data |= 0x0c; /* VCLK > 200 */
1536
1537 if (HwDeviceExtension->jChipType >= XG20)
1538 data &= ~0x04; /* 2 pixel mode */
1539
1540 xgifb_reg_set(pVBInfo->P3c4, 0x32, data);
1541
1542 if (HwDeviceExtension->jChipType < XG20) {
1543 data = xgifb_reg_get(pVBInfo->P3c4, 0x1F);
1544 data &= 0xE7;
1545 if (VCLK < 200)
1546 data |= 0x10;
1547 xgifb_reg_set(pVBInfo->P3c4, 0x1F, data);
1548 }
1549
1550 /* Jong for Adavantech LCD ripple issue
1551 if ((VCLK >= 0) && (VCLK < 135))
1552 data2 = 0x03;
1553 else if ((VCLK >= 135) && (VCLK < 160))
1554 data2 = 0x02;
1555 else if ((VCLK >= 160) && (VCLK < 260))
1556 data2 = 0x01;
1557 else if (VCLK > 260)
1558 data2 = 0x00;
1559 */
1560 data2 = 0x00;
1561
1562 xgifb_reg_and_or(pVBInfo->P3c4, 0x07, 0xFC, data2);
1563 if (HwDeviceExtension->jChipType >= XG27)
1564 xgifb_reg_and_or(pVBInfo->P3c4, 0x40, 0xFC, data2 & 0x03);
1565
1566 }
1567
XGI_SetCRT1ModeRegs(struct xgi_hw_device_info * HwDeviceExtension,unsigned short ModeNo,unsigned short ModeIdIndex,unsigned short RefreshRateTableIndex,struct vb_device_info * pVBInfo)1568 static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension,
1569 unsigned short ModeNo, unsigned short ModeIdIndex,
1570 unsigned short RefreshRateTableIndex,
1571 struct vb_device_info *pVBInfo)
1572 {
1573 unsigned short data, data2, data3, infoflag = 0, modeflag, resindex,
1574 xres;
1575
1576 if (ModeNo > 0x13) {
1577 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1578 infoflag
1579 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
1580 } else
1581 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ModeFlag */
1582
1583 if (xgifb_reg_get(pVBInfo->P3d4, 0x31) & 0x01)
1584 xgifb_reg_and_or(pVBInfo->P3c4, 0x1F, 0x3F, 0x00);
1585
1586 if (ModeNo > 0x13)
1587 data = infoflag;
1588 else
1589 data = 0;
1590
1591 data2 = 0;
1592
1593 if (ModeNo > 0x13) {
1594 if (pVBInfo->ModeType > 0x02) {
1595 data2 |= 0x02;
1596 data3 = pVBInfo->ModeType - ModeVGA;
1597 data3 = data3 << 2;
1598 data2 |= data3;
1599 }
1600 }
1601
1602 data &= InterlaceMode;
1603
1604 if (data)
1605 data2 |= 0x20;
1606
1607 xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x3F, data2);
1608 /* xgifb_reg_set(pVBInfo->P3c4,0x06,data2); */
1609 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
1610 if (ModeNo <= 0x13)
1611 xres = pVBInfo->StResInfo[resindex].HTotal;
1612 else
1613 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
1614
1615 data = 0x0000;
1616 if (infoflag & InterlaceMode) {
1617 if (xres == 1024)
1618 data = 0x0035;
1619 else if (xres == 1280)
1620 data = 0x0048;
1621 }
1622
1623 data2 = data & 0x00FF;
1624 xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFF, data2);
1625 data2 = (data & 0xFF00) >> 8;
1626 xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFC, data2);
1627
1628 if (modeflag & HalfDCLK)
1629 xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xF7, 0x08);
1630
1631 data2 = 0;
1632
1633 if (modeflag & LineCompareOff)
1634 data2 |= 0x08;
1635
1636 if (ModeNo > 0x13) {
1637 if (pVBInfo->ModeType == ModeEGA)
1638 data2 |= 0x40;
1639 }
1640
1641 xgifb_reg_and_or(pVBInfo->P3c4, 0x0F, ~0x48, data2);
1642 data = 0x60;
1643 if (pVBInfo->ModeType != ModeText) {
1644 data = data ^ 0x60;
1645 if (pVBInfo->ModeType != ModeEGA)
1646 data = data ^ 0xA0;
1647 }
1648 xgifb_reg_and_or(pVBInfo->P3c4, 0x21, 0x1F, data);
1649
1650 XGI_SetVCLKState(HwDeviceExtension, ModeNo, RefreshRateTableIndex,
1651 pVBInfo);
1652
1653 /* if (modeflag&HalfDCLK) //030305 fix lowresolution bug */
1654 /* if (XGINew_IF_DEF_NEW_LOWRES) */
1655 /* XGI_VesaLowResolution(ModeNo, ModeIdIndex); //030305 fix lowresolution bug */
1656
1657 data = xgifb_reg_get(pVBInfo->P3d4, 0x31);
1658
1659 if (HwDeviceExtension->jChipType == XG27) {
1660 if (data & 0x40)
1661 data = 0x2c;
1662 else
1663 data = 0x6c;
1664 xgifb_reg_set(pVBInfo->P3d4, 0x52, data);
1665 xgifb_reg_or(pVBInfo->P3d4, 0x51, 0x10);
1666 } else if (HwDeviceExtension->jChipType >= XG20) {
1667 if (data & 0x40)
1668 data = 0x33;
1669 else
1670 data = 0x73;
1671 xgifb_reg_set(pVBInfo->P3d4, 0x52, data);
1672 xgifb_reg_set(pVBInfo->P3d4, 0x51, 0x02);
1673 } else {
1674 if (data & 0x40)
1675 data = 0x2c;
1676 else
1677 data = 0x6c;
1678 xgifb_reg_set(pVBInfo->P3d4, 0x52, data);
1679 }
1680
1681 }
1682
1683 /*
1684 void XGI_VesaLowResolution(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
1685 {
1686 unsigned short modeflag;
1687
1688 if (ModeNo > 0x13)
1689 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1690 else
1691 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
1692
1693 if (ModeNo > 0x13) {
1694 if (modeflag & DoubleScanMode) {
1695 if (modeflag & HalfDCLK) {
1696 if (pVBInfo->VBType & VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
1697 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) {
1698 if (pVBInfo->VBInfo & SetInSlaveMode) {
1699 xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xf7, 0x00);
1700 xgifb_reg_and_or(pVBInfo->P3c4, 0x0f, 0x7f, 0x00);
1701 return;
1702 }
1703 }
1704 }
1705 xgifb_reg_and_or(pVBInfo->P3c4, 0x0f, 0xff, 0x80);
1706 xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xf7, 0x00);
1707 return;
1708 }
1709 }
1710 }
1711 xgifb_reg_and_or(pVBInfo->P3c4, 0x0f, 0x7f, 0x00);
1712 }
1713 */
1714
XGI_WriteDAC(unsigned short dl,unsigned short ah,unsigned short al,unsigned short dh,struct vb_device_info * pVBInfo)1715 static void XGI_WriteDAC(unsigned short dl, unsigned short ah, unsigned short al,
1716 unsigned short dh, struct vb_device_info *pVBInfo)
1717 {
1718 unsigned short temp, bh, bl;
1719
1720 bh = ah;
1721 bl = al;
1722
1723 if (dl != 0) {
1724 temp = bh;
1725 bh = dh;
1726 dh = temp;
1727 if (dl == 1) {
1728 temp = bl;
1729 bl = dh;
1730 dh = temp;
1731 } else {
1732 temp = bl;
1733 bl = bh;
1734 bh = temp;
1735 }
1736 }
1737 outb((unsigned short) dh, pVBInfo->P3c9);
1738 outb((unsigned short) bh, pVBInfo->P3c9);
1739 outb((unsigned short) bl, pVBInfo->P3c9);
1740 }
1741
XGI_LoadDAC(unsigned short ModeNo,unsigned short ModeIdIndex,struct vb_device_info * pVBInfo)1742 static void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex,
1743 struct vb_device_info *pVBInfo)
1744 {
1745 unsigned short data, data2, time, i, j, k, m, n, o, si, di, bx, dl, al,
1746 ah, dh, *table = NULL;
1747
1748 if (ModeNo <= 0x13)
1749 data = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
1750 else
1751 data = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1752
1753 data &= DACInfoFlag;
1754 time = 64;
1755
1756 if (data == 0x00)
1757 table = XGINew_MDA_DAC;
1758 else if (data == 0x08)
1759 table = XGINew_CGA_DAC;
1760 else if (data == 0x10)
1761 table = XGINew_EGA_DAC;
1762 else if (data == 0x18) {
1763 time = 256;
1764 table = XGINew_VGA_DAC;
1765 }
1766
1767 if (time == 256)
1768 j = 16;
1769 else
1770 j = time;
1771
1772 outb(0xFF, pVBInfo->P3c6);
1773 outb(0x00, pVBInfo->P3c8);
1774
1775 for (i = 0; i < j; i++) {
1776 data = table[i];
1777
1778 for (k = 0; k < 3; k++) {
1779 data2 = 0;
1780
1781 if (data & 0x01)
1782 data2 = 0x2A;
1783
1784 if (data & 0x02)
1785 data2 += 0x15;
1786
1787 outb(data2, pVBInfo->P3c9);
1788 data = data >> 2;
1789 }
1790 }
1791
1792 if (time == 256) {
1793 for (i = 16; i < 32; i++) {
1794 data = table[i];
1795
1796 for (k = 0; k < 3; k++)
1797 outb(data, pVBInfo->P3c9);
1798 }
1799
1800 si = 32;
1801
1802 for (m = 0; m < 9; m++) {
1803 di = si;
1804 bx = si + 0x04;
1805 dl = 0;
1806
1807 for (n = 0; n < 3; n++) {
1808 for (o = 0; o < 5; o++) {
1809 dh = table[si];
1810 ah = table[di];
1811 al = table[bx];
1812 si++;
1813 XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
1814 }
1815
1816 si -= 2;
1817
1818 for (o = 0; o < 3; o++) {
1819 dh = table[bx];
1820 ah = table[di];
1821 al = table[si];
1822 si--;
1823 XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
1824 }
1825
1826 dl++;
1827 }
1828
1829 si += 5;
1830 }
1831 }
1832 }
1833
XGI_GetLVDSResInfo(unsigned short ModeNo,unsigned short ModeIdIndex,struct vb_device_info * pVBInfo)1834 static void XGI_GetLVDSResInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
1835 struct vb_device_info *pVBInfo)
1836 {
1837 unsigned short resindex, xres, yres, modeflag;
1838
1839 if (ModeNo <= 0x13)
1840 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; /* si+St_ResInfo */
1841 else
1842 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; /* si+Ext_ResInfo */
1843
1844 /* if (ModeNo > 0x13) */
1845 /* modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; */
1846 /* else */
1847 /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; */
1848
1849 if (ModeNo <= 0x13)
1850 resindex = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; /* si+St_ResInfo */
1851 else
1852 resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; /* si+Ext_ResInfo */
1853
1854 /* resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); */
1855
1856 if (ModeNo <= 0x13) {
1857 xres = pVBInfo->StResInfo[resindex].HTotal;
1858 yres = pVBInfo->StResInfo[resindex].VTotal;
1859 } else {
1860 xres = pVBInfo->ModeResInfo[resindex].HTotal;
1861 yres = pVBInfo->ModeResInfo[resindex].VTotal;
1862 }
1863 if (ModeNo > 0x13) {
1864 if (modeflag & HalfDCLK)
1865 xres = xres << 1;
1866
1867 if (modeflag & DoubleScanMode)
1868 yres = yres << 1;
1869 }
1870 /* if (modeflag & Charx8Dot) */
1871 /* { */
1872
1873 if (xres == 720)
1874 xres = 640;
1875
1876 /* } */
1877 pVBInfo->VGAHDE = xres;
1878 pVBInfo->HDE = xres;
1879 pVBInfo->VGAVDE = yres;
1880 pVBInfo->VDE = yres;
1881 }
1882
XGI_GetLcdPtr(unsigned short BX,unsigned short ModeNo,unsigned short ModeIdIndex,unsigned short RefreshRateTableIndex,struct vb_device_info * pVBInfo)1883 static void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo,
1884 unsigned short ModeIdIndex,
1885 unsigned short RefreshRateTableIndex,
1886 struct vb_device_info *pVBInfo)
1887 {
1888 unsigned short i, tempdx, tempcx, tempbx, tempal, modeflag, table;
1889
1890 struct XGI330_LCDDataTablStruct *tempdi = NULL;
1891
1892 tempbx = BX;
1893
1894 if (ModeNo <= 0x13) {
1895 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
1896 tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
1897 } else {
1898 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
1899 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
1900 }
1901
1902 tempal = tempal & 0x0f;
1903
1904 if (tempbx <= 1) { /* ExpLink */
1905 if (ModeNo <= 0x13) {
1906 tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; /* find no Ext_CRT2CRTC2 */
1907 } else {
1908 tempal
1909 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
1910 }
1911
1912 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
1913 if (ModeNo <= 0x13)
1914 tempal
1915 = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC2;
1916 else
1917 tempal
1918 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC2;
1919 }
1920
1921 if (tempbx & 0x01)
1922 tempal = (tempal >> 4);
1923
1924 tempal = (tempal & 0x0f);
1925 }
1926
1927 tempcx = LCDLenList[tempbx]; /* mov cl,byte ptr cs:LCDLenList[bx] */
1928
1929 if (pVBInfo->LCDInfo & EnableScalingLCD) { /* ScaleLCD */
1930 if ((tempbx == 5) || (tempbx) == 7)
1931 tempcx = LCDDesDataLen2;
1932 else if ((tempbx == 3) || (tempbx == 8))
1933 tempcx = LVDSDesDataLen2;
1934 }
1935 /* mov di, word ptr cs:LCDDataList[bx] */
1936 /* tempdi = pVideoMemory[LCDDataList + tempbx * 2] | (pVideoMemory[LCDDataList + tempbx * 2 + 1] << 8); */
1937
1938 switch (tempbx) {
1939 case 0:
1940 tempdi = XGI_EPLLCDCRT1Ptr_H;
1941 break;
1942 case 1:
1943 tempdi = XGI_EPLLCDCRT1Ptr_V;
1944 break;
1945 case 2:
1946 tempdi = XGI_EPLLCDDataPtr;
1947 break;
1948 case 3:
1949 tempdi = XGI_EPLLCDDesDataPtr;
1950 break;
1951 case 4:
1952 tempdi = XGI_LCDDataTable;
1953 break;
1954 case 5:
1955 tempdi = XGI_LCDDesDataTable;
1956 break;
1957 case 6:
1958 tempdi = XGI_EPLCHLCDRegPtr;
1959 break;
1960 case 7:
1961 case 8:
1962 case 9:
1963 tempdi = NULL;
1964 break;
1965 default:
1966 break;
1967 }
1968
1969 if (tempdi == NULL) /* OEMUtil */
1970 return NULL;
1971
1972 table = tempbx;
1973 i = 0;
1974
1975 while (tempdi[i].PANELID != 0xff) {
1976 tempdx = pVBInfo->LCDResInfo;
1977 if (tempbx & 0x0080) { /* OEMUtil */
1978 tempbx &= (~0x0080);
1979 tempdx = pVBInfo->LCDTypeInfo;
1980 }
1981
1982 if (pVBInfo->LCDInfo & EnableScalingLCD)
1983 tempdx &= (~PanelResInfo);
1984
1985 if (tempdi[i].PANELID == tempdx) {
1986 tempbx = tempdi[i].MASK;
1987 tempdx = pVBInfo->LCDInfo;
1988
1989 if (ModeNo <= 0x13) /* alan 09/10/2003 */
1990 tempdx |= SetLCDStdMode;
1991
1992 if (modeflag & HalfDCLK)
1993 tempdx |= SetLCDLowResolution;
1994
1995 tempbx &= tempdx;
1996 if (tempbx == tempdi[i].CAP)
1997 break;
1998 }
1999 i++;
2000 }
2001
2002 if (table == 0) {
2003 switch (tempdi[i].DATAPTR) {
2004 case 0:
2005 return &XGI_LVDSCRT11024x768_1_H[tempal];
2006 break;
2007 case 1:
2008 return &XGI_LVDSCRT11024x768_2_H[tempal];
2009 break;
2010 case 2:
2011 return &XGI_LVDSCRT11280x1024_1_H[tempal];
2012 break;
2013 case 3:
2014 return &XGI_LVDSCRT11280x1024_2_H[tempal];
2015 break;
2016 case 4:
2017 return &XGI_LVDSCRT11400x1050_1_H[tempal];
2018 break;
2019 case 5:
2020 return &XGI_LVDSCRT11400x1050_2_H[tempal];
2021 break;
2022 case 6:
2023 return &XGI_LVDSCRT11600x1200_1_H[tempal];
2024 break;
2025 case 7:
2026 return &XGI_LVDSCRT11024x768_1_Hx75[tempal];
2027 break;
2028 case 8:
2029 return &XGI_LVDSCRT11024x768_2_Hx75[tempal];
2030 break;
2031 case 9:
2032 return &XGI_LVDSCRT11280x1024_1_Hx75[tempal];
2033 break;
2034 case 10:
2035 return &XGI_LVDSCRT11280x1024_2_Hx75[tempal];
2036 break;
2037 default:
2038 break;
2039 }
2040 } else if (table == 1) {
2041 switch (tempdi[i].DATAPTR) {
2042 case 0:
2043 return &XGI_LVDSCRT11024x768_1_V[tempal];
2044 break;
2045 case 1:
2046 return &XGI_LVDSCRT11024x768_2_V[tempal];
2047 break;
2048 case 2:
2049 return &XGI_LVDSCRT11280x1024_1_V[tempal];
2050 break;
2051 case 3:
2052 return &XGI_LVDSCRT11280x1024_2_V[tempal];
2053 break;
2054 case 4:
2055 return &XGI_LVDSCRT11400x1050_1_V[tempal];
2056 break;
2057 case 5:
2058 return &XGI_LVDSCRT11400x1050_2_V[tempal];
2059 break;
2060 case 6:
2061 return &XGI_LVDSCRT11600x1200_1_V[tempal];
2062 break;
2063 case 7:
2064 return &XGI_LVDSCRT11024x768_1_Vx75[tempal];
2065 break;
2066 case 8:
2067 return &XGI_LVDSCRT11024x768_2_Vx75[tempal];
2068 break;
2069 case 9:
2070 return &XGI_LVDSCRT11280x1024_1_Vx75[tempal];
2071 break;
2072 case 10:
2073 return &XGI_LVDSCRT11280x1024_2_Vx75[tempal];
2074 break;
2075 default:
2076 break;
2077 }
2078 } else if (table == 2) {
2079 switch (tempdi[i].DATAPTR) {
2080 case 0:
2081 return &XGI_LVDS1024x768Data_1[tempal];
2082 break;
2083 case 1:
2084 return &XGI_LVDS1024x768Data_2[tempal];
2085 break;
2086 case 2:
2087 return &XGI_LVDS1280x1024Data_1[tempal];
2088 break;
2089 case 3:
2090 return &XGI_LVDS1280x1024Data_2[tempal];
2091 break;
2092 case 4:
2093 return &XGI_LVDS1400x1050Data_1[tempal];
2094 break;
2095 case 5:
2096 return &XGI_LVDS1400x1050Data_2[tempal];
2097 break;
2098 case 6:
2099 return &XGI_LVDS1600x1200Data_1[tempal];
2100 break;
2101 case 7:
2102 return &XGI_LVDSNoScalingData[tempal];
2103 break;
2104 case 8:
2105 return &XGI_LVDS1024x768Data_1x75[tempal];
2106 break;
2107 case 9:
2108 return &XGI_LVDS1024x768Data_2x75[tempal];
2109 break;
2110 case 10:
2111 return &XGI_LVDS1280x1024Data_1x75[tempal];
2112 break;
2113 case 11:
2114 return &XGI_LVDS1280x1024Data_2x75[tempal];
2115 break;
2116 case 12:
2117 return &XGI_LVDSNoScalingDatax75[tempal];
2118 break;
2119 default:
2120 break;
2121 }
2122 } else if (table == 3) {
2123 switch (tempdi[i].DATAPTR) {
2124 case 0:
2125 return &XGI_LVDS1024x768Des_1[tempal];
2126 break;
2127 case 1:
2128 return &XGI_LVDS1024x768Des_3[tempal];
2129 break;
2130 case 2:
2131 return &XGI_LVDS1024x768Des_2[tempal];
2132 break;
2133 case 3:
2134 return &XGI_LVDS1280x1024Des_1[tempal];
2135 break;
2136 case 4:
2137 return &XGI_LVDS1280x1024Des_2[tempal];
2138 break;
2139 case 5:
2140 return &XGI_LVDS1400x1050Des_1[tempal];
2141 break;
2142 case 6:
2143 return &XGI_LVDS1400x1050Des_2[tempal];
2144 break;
2145 case 7:
2146 return &XGI_LVDS1600x1200Des_1[tempal];
2147 break;
2148 case 8:
2149 return &XGI_LVDSNoScalingDesData[tempal];
2150 break;
2151 case 9:
2152 return &XGI_LVDS1024x768Des_1x75[tempal];
2153 break;
2154 case 10:
2155 return &XGI_LVDS1024x768Des_3x75[tempal];
2156 break;
2157 case 11:
2158 return &XGI_LVDS1024x768Des_2x75[tempal];
2159 break;
2160 case 12:
2161 return &XGI_LVDS1280x1024Des_1x75[tempal];
2162 break;
2163 case 13:
2164 return &XGI_LVDS1280x1024Des_2x75[tempal];
2165 break;
2166 case 14:
2167 return &XGI_LVDSNoScalingDesDatax75[tempal];
2168 break;
2169 default:
2170 break;
2171 }
2172 } else if (table == 4) {
2173 switch (tempdi[i].DATAPTR) {
2174 case 0:
2175 return &XGI_ExtLCD1024x768Data[tempal];
2176 break;
2177 case 1:
2178 return &XGI_StLCD1024x768Data[tempal];
2179 break;
2180 case 2:
2181 return &XGI_CetLCD1024x768Data[tempal];
2182 break;
2183 case 3:
2184 return &XGI_ExtLCD1280x1024Data[tempal];
2185 break;
2186 case 4:
2187 return &XGI_StLCD1280x1024Data[tempal];
2188 break;
2189 case 5:
2190 return &XGI_CetLCD1280x1024Data[tempal];
2191 break;
2192 case 6:
2193 return &XGI_ExtLCD1400x1050Data[tempal];
2194 break;
2195 case 7:
2196 return &XGI_StLCD1400x1050Data[tempal];
2197 break;
2198 case 8:
2199 return &XGI_CetLCD1400x1050Data[tempal];
2200 break;
2201 case 9:
2202 return &XGI_ExtLCD1600x1200Data[tempal];
2203 break;
2204 case 10:
2205 return &XGI_StLCD1600x1200Data[tempal];
2206 break;
2207 case 11:
2208 return &XGI_NoScalingData[tempal];
2209 break;
2210 case 12:
2211 return &XGI_ExtLCD1024x768x75Data[tempal];
2212 break;
2213 case 13:
2214 return &XGI_ExtLCD1024x768x75Data[tempal];
2215 break;
2216 case 14:
2217 return &XGI_CetLCD1024x768x75Data[tempal];
2218 break;
2219 case 15:
2220 return &XGI_ExtLCD1280x1024x75Data[tempal];
2221 break;
2222 case 16:
2223 return &XGI_StLCD1280x1024x75Data[tempal];
2224 break;
2225 case 17:
2226 return &XGI_CetLCD1280x1024x75Data[tempal];
2227 break;
2228 case 18:
2229 return &XGI_NoScalingDatax75[tempal];
2230 break;
2231 default:
2232 break;
2233 }
2234 } else if (table == 5) {
2235 switch (tempdi[i].DATAPTR) {
2236 case 0:
2237 return &XGI_ExtLCDDes1024x768Data[tempal];
2238 break;
2239 case 1:
2240 return &XGI_StLCDDes1024x768Data[tempal];
2241 break;
2242 case 2:
2243 return &XGI_CetLCDDes1024x768Data[tempal];
2244 break;
2245 case 3:
2246 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
2247 & VB_XGI302LV))
2248 return &XGI_ExtLCDDLDes1280x1024Data[tempal];
2249 else
2250 return &XGI_ExtLCDDes1280x1024Data[tempal];
2251 break;
2252 case 4:
2253 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
2254 & VB_XGI302LV))
2255 return &XGI_StLCDDLDes1280x1024Data[tempal];
2256 else
2257 return &XGI_StLCDDes1280x1024Data[tempal];
2258 break;
2259 case 5:
2260 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
2261 & VB_XGI302LV))
2262 return &XGI_CetLCDDLDes1280x1024Data[tempal];
2263 else
2264 return &XGI_CetLCDDes1280x1024Data[tempal];
2265 break;
2266 case 6:
2267 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
2268 & VB_XGI302LV))
2269 return &XGI_ExtLCDDLDes1400x1050Data[tempal];
2270 else
2271 return &XGI_ExtLCDDes1400x1050Data[tempal];
2272 break;
2273 case 7:
2274 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
2275 & VB_XGI302LV))
2276 return &XGI_StLCDDLDes1400x1050Data[tempal];
2277 else
2278 return &XGI_StLCDDes1400x1050Data[tempal];
2279 break;
2280 case 8:
2281 return &XGI_CetLCDDes1400x1050Data[tempal];
2282 break;
2283 case 9:
2284 return &XGI_CetLCDDes1400x1050Data2[tempal];
2285 break;
2286 case 10:
2287 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
2288 & VB_XGI302LV))
2289 return &XGI_ExtLCDDLDes1600x1200Data[tempal];
2290 else
2291 return &XGI_ExtLCDDes1600x1200Data[tempal];
2292 break;
2293 case 11:
2294 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
2295 & VB_XGI302LV))
2296 return &XGI_StLCDDLDes1600x1200Data[tempal];
2297 else
2298 return &XGI_StLCDDes1600x1200Data[tempal];
2299 break;
2300 case 12:
2301 return &XGI_NoScalingDesData[tempal];
2302 break;
2303 case 13:
2304 return &XGI_ExtLCDDes1024x768x75Data[tempal];
2305 break;
2306 case 14:
2307 return &XGI_StLCDDes1024x768x75Data[tempal];
2308 break;
2309 case 15:
2310 return &XGI_CetLCDDes1024x768x75Data[tempal];
2311 break;
2312 case 16:
2313 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
2314 & VB_XGI302LV))
2315 return &XGI_ExtLCDDLDes1280x1024x75Data[tempal];
2316 else
2317 return &XGI_ExtLCDDes1280x1024x75Data[tempal];
2318 break;
2319 case 17:
2320 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
2321 & VB_XGI302LV))
2322 return &XGI_StLCDDLDes1280x1024x75Data[tempal];
2323 else
2324 return &XGI_StLCDDes1280x1024x75Data[tempal];
2325 break;
2326 case 18:
2327 if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType
2328 & VB_XGI302LV))
2329 return &XGI_CetLCDDLDes1280x1024x75Data[tempal];
2330 else
2331 return &XGI_CetLCDDes1280x1024x75Data[tempal];
2332 break;
2333 case 19:
2334 return &XGI_NoScalingDesDatax75[tempal];
2335 break;
2336 default:
2337 break;
2338 }
2339 } else if (table == 6) {
2340 switch (tempdi[i].DATAPTR) {
2341 case 0:
2342 return &XGI_CH7017LV1024x768[tempal];
2343 break;
2344 case 1:
2345 return &XGI_CH7017LV1400x1050[tempal];
2346 break;
2347 default:
2348 break;
2349 }
2350 }
2351 return NULL;
2352 }
2353
XGI_GetTVPtr(unsigned short BX,unsigned short ModeNo,unsigned short ModeIdIndex,unsigned short RefreshRateTableIndex,struct vb_device_info * pVBInfo)2354 static void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo,
2355 unsigned short ModeIdIndex,
2356 unsigned short RefreshRateTableIndex,
2357 struct vb_device_info *pVBInfo)
2358 {
2359 unsigned short i, tempdx, tempbx, tempal, modeflag, table;
2360 struct XGI330_TVDataTablStruct *tempdi = NULL;
2361
2362 tempbx = BX;
2363
2364 if (ModeNo <= 0x13) {
2365 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
2366 tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
2367 } else {
2368 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2369 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
2370 }
2371
2372 tempal = tempal & 0x3f;
2373 table = tempbx;
2374
2375 switch (tempbx) {
2376 case 0:
2377 tempdi = NULL; /*EPLCHTVCRT1Ptr_H;*/
2378 if (pVBInfo->IF_DEF_CH7007 == 1)
2379 tempdi = XGI_EPLCHTVCRT1Ptr;
2380
2381 break;
2382 case 1:
2383 tempdi = NULL; /*EPLCHTVCRT1Ptr_V;*/
2384 if (pVBInfo->IF_DEF_CH7007 == 1)
2385 tempdi = XGI_EPLCHTVCRT1Ptr;
2386
2387 break;
2388 case 2:
2389 tempdi = XGI_EPLCHTVDataPtr;
2390 break;
2391 case 3:
2392 tempdi = NULL;
2393 break;
2394 case 4:
2395 tempdi = XGI_TVDataTable;
2396 break;
2397 case 5:
2398 tempdi = NULL;
2399 break;
2400 case 6:
2401 tempdi = XGI_EPLCHTVRegPtr;
2402 break;
2403 default:
2404 break;
2405 }
2406
2407 if (tempdi == NULL) /* OEMUtil */
2408 return NULL;
2409
2410 tempdx = pVBInfo->TVInfo;
2411
2412 if (pVBInfo->VBInfo & SetInSlaveMode)
2413 tempdx = tempdx | SetTVLockMode;
2414
2415 if (modeflag & HalfDCLK)
2416 tempdx = tempdx | SetTVLowResolution;
2417
2418 i = 0;
2419
2420 while (tempdi[i].MASK != 0xffff) {
2421 if ((tempdx & tempdi[i].MASK) == tempdi[i].CAP)
2422 break;
2423 i++;
2424 }
2425
2426 if (table == 0x00) { /* 07/05/22 */
2427 } else if (table == 0x01) {
2428 } else if (table == 0x04) {
2429 switch (tempdi[i].DATAPTR) {
2430 case 0:
2431 return &XGI_ExtPALData[tempal];
2432 break;
2433 case 1:
2434 return &XGI_ExtNTSCData[tempal];
2435 break;
2436 case 2:
2437 return &XGI_StPALData[tempal];
2438 break;
2439 case 3:
2440 return &XGI_StNTSCData[tempal];
2441 break;
2442 case 4:
2443 return &XGI_ExtHiTVData[tempal];
2444 break;
2445 case 5:
2446 return &XGI_St2HiTVData[tempal];
2447 break;
2448 case 6:
2449 return &XGI_ExtYPbPr525iData[tempal];
2450 break;
2451 case 7:
2452 return &XGI_ExtYPbPr525pData[tempal];
2453 break;
2454 case 8:
2455 return &XGI_ExtYPbPr750pData[tempal];
2456 break;
2457 case 9:
2458 return &XGI_StYPbPr525iData[tempal];
2459 break;
2460 case 10:
2461 return &XGI_StYPbPr525pData[tempal];
2462 break;
2463 case 11:
2464 return &XGI_StYPbPr750pData[tempal];
2465 break;
2466 case 12: /* avoid system hang */
2467 return &XGI_ExtNTSCData[tempal];
2468 break;
2469 case 13:
2470 return &XGI_St1HiTVData[tempal];
2471 break;
2472 default:
2473 break;
2474 }
2475 } else if (table == 0x02) {
2476 switch (tempdi[i].DATAPTR) {
2477 case 0:
2478 return &XGI_CHTVUNTSCData[tempal];
2479 break;
2480 case 1:
2481 return &XGI_CHTVONTSCData[tempal];
2482 break;
2483 case 2:
2484 return &XGI_CHTVUPALData[tempal];
2485 break;
2486 case 3:
2487 return &XGI_CHTVOPALData[tempal];
2488 break;
2489 default:
2490 break;
2491 }
2492 } else if (table == 0x06) {
2493 }
2494 return NULL;
2495 }
2496
XGI_GetLVDSData(unsigned short ModeNo,unsigned short ModeIdIndex,unsigned short RefreshRateTableIndex,struct vb_device_info * pVBInfo)2497 static void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex,
2498 unsigned short RefreshRateTableIndex,
2499 struct vb_device_info *pVBInfo)
2500 {
2501 unsigned short tempbx;
2502 struct XGI330_LVDSDataStruct *LCDPtr = NULL;
2503 struct XGI330_CHTVDataStruct *TVPtr = NULL;
2504
2505 tempbx = 2;
2506
2507 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
2508 LCDPtr = (struct XGI330_LVDSDataStruct *) XGI_GetLcdPtr(tempbx,
2509 ModeNo, ModeIdIndex, RefreshRateTableIndex,
2510 pVBInfo);
2511 pVBInfo->VGAHT = LCDPtr->VGAHT;
2512 pVBInfo->VGAVT = LCDPtr->VGAVT;
2513 pVBInfo->HT = LCDPtr->LCDHT;
2514 pVBInfo->VT = LCDPtr->LCDVT;
2515 }
2516 if (pVBInfo->IF_DEF_CH7017 == 1) {
2517 if (pVBInfo->VBInfo & SetCRT2ToTV) {
2518 TVPtr = (struct XGI330_CHTVDataStruct *) XGI_GetTVPtr(
2519 tempbx, ModeNo, ModeIdIndex,
2520 RefreshRateTableIndex, pVBInfo);
2521 pVBInfo->VGAHT = TVPtr->VGAHT;
2522 pVBInfo->VGAVT = TVPtr->VGAVT;
2523 pVBInfo->HT = TVPtr->LCDHT;
2524 pVBInfo->VT = TVPtr->LCDVT;
2525 }
2526 }
2527
2528 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
2529 if (!(pVBInfo->LCDInfo & (SetLCDtoNonExpanding
2530 | EnableScalingLCD))) {
2531 if ((pVBInfo->LCDResInfo == Panel1024x768)
2532 || (pVBInfo->LCDResInfo
2533 == Panel1024x768x75)) {
2534 pVBInfo->HDE = 1024;
2535 pVBInfo->VDE = 768;
2536 } else if ((pVBInfo->LCDResInfo == Panel1280x1024)
2537 || (pVBInfo->LCDResInfo
2538 == Panel1280x1024x75)) {
2539 pVBInfo->HDE = 1280;
2540 pVBInfo->VDE = 1024;
2541 } else if (pVBInfo->LCDResInfo == Panel1400x1050) {
2542 pVBInfo->HDE = 1400;
2543 pVBInfo->VDE = 1050;
2544 } else {
2545 pVBInfo->HDE = 1600;
2546 pVBInfo->VDE = 1200;
2547 }
2548 }
2549 }
2550 }
2551
XGI_ModCRT1Regs(unsigned short ModeNo,unsigned short ModeIdIndex,unsigned short RefreshRateTableIndex,struct xgi_hw_device_info * HwDeviceExtension,struct vb_device_info * pVBInfo)2552 static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex,
2553 unsigned short RefreshRateTableIndex,
2554 struct xgi_hw_device_info *HwDeviceExtension,
2555 struct vb_device_info *pVBInfo)
2556 {
2557 unsigned char index;
2558 unsigned short tempbx, i;
2559 struct XGI_LVDSCRT1HDataStruct *LCDPtr = NULL;
2560 struct XGI_LVDSCRT1VDataStruct *LCDPtr1 = NULL;
2561 /* struct XGI330_CHTVDataStruct *TVPtr = NULL; */
2562 struct XGI_CH7007TV_TimingHStruct *CH7007TV_TimingHPtr = NULL;
2563 struct XGI_CH7007TV_TimingVStruct *CH7007TV_TimingVPtr = NULL;
2564
2565 if (ModeNo <= 0x13)
2566 index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
2567 else
2568 index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
2569
2570 index = index & IndexMask;
2571
2572 if ((pVBInfo->IF_DEF_ScaleLCD == 0) || ((pVBInfo->IF_DEF_ScaleLCD == 1)
2573 && (!(pVBInfo->LCDInfo & EnableScalingLCD)))) {
2574 tempbx = 0;
2575
2576 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
2577 LCDPtr
2578 = (struct XGI_LVDSCRT1HDataStruct *) XGI_GetLcdPtr(
2579 tempbx, ModeNo,
2580 ModeIdIndex,
2581 RefreshRateTableIndex,
2582 pVBInfo);
2583
2584 for (i = 0; i < 8; i++)
2585 pVBInfo->TimingH[0].data[i] = LCDPtr[0].Reg[i];
2586 }
2587
2588 if (pVBInfo->IF_DEF_CH7007 == 1) {
2589 if (pVBInfo->VBInfo & SetCRT2ToTV) {
2590 CH7007TV_TimingHPtr
2591 = (struct XGI_CH7007TV_TimingHStruct *) XGI_GetTVPtr(
2592 tempbx,
2593 ModeNo,
2594 ModeIdIndex,
2595 RefreshRateTableIndex,
2596 pVBInfo);
2597
2598 for (i = 0; i < 8; i++)
2599 pVBInfo->TimingH[0].data[i]
2600 = CH7007TV_TimingHPtr[0].data[i];
2601 }
2602 }
2603
2604 /* if (pVBInfo->IF_DEF_CH7017 == 1) {
2605 if (pVBInfo->VBInfo & SetCRT2ToTV)
2606 TVPtr = (struct XGI330_CHTVDataStruct *)XGI_GetTVPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2607 }
2608 */
2609
2610 XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension);
2611
2612 if (pVBInfo->IF_DEF_CH7007 == 1) {
2613 xgifb_reg_set(pVBInfo->P3c4, 0x2E,
2614 CH7007TV_TimingHPtr[0].data[8]);
2615 xgifb_reg_set(pVBInfo->P3c4, 0x2F,
2616 CH7007TV_TimingHPtr[0].data[9]);
2617 }
2618
2619 tempbx = 1;
2620
2621 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
2622 LCDPtr1
2623 = (struct XGI_LVDSCRT1VDataStruct *) XGI_GetLcdPtr(
2624 tempbx, ModeNo,
2625 ModeIdIndex,
2626 RefreshRateTableIndex,
2627 pVBInfo);
2628 for (i = 0; i < 7; i++)
2629 pVBInfo->TimingV[0].data[i] = LCDPtr1[0].Reg[i];
2630 }
2631
2632 if (pVBInfo->IF_DEF_CH7007 == 1) {
2633 if (pVBInfo->VBInfo & SetCRT2ToTV) {
2634 CH7007TV_TimingVPtr
2635 = (struct XGI_CH7007TV_TimingVStruct *) XGI_GetTVPtr(
2636 tempbx,
2637 ModeNo,
2638 ModeIdIndex,
2639 RefreshRateTableIndex,
2640 pVBInfo);
2641
2642 for (i = 0; i < 7; i++)
2643 pVBInfo->TimingV[0].data[i]
2644 = CH7007TV_TimingVPtr[0].data[i];
2645 }
2646 }
2647 /* if (pVBInfo->IF_DEF_CH7017 == 1) {
2648 if (pVBInfo->VBInfo & SetCRT2ToTV)
2649 TVPtr = (struct XGI330_CHTVDataStruct *)XGI_GetTVPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
2650 }
2651 */
2652
2653 XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo);
2654
2655 if (pVBInfo->IF_DEF_CH7007 == 1) {
2656 xgifb_reg_and_or(pVBInfo->P3c4, 0x33, ~0x01,
2657 CH7007TV_TimingVPtr[0].data[7] & 0x01);
2658 xgifb_reg_set(pVBInfo->P3c4, 0x34,
2659 CH7007TV_TimingVPtr[0].data[8]);
2660 xgifb_reg_set(pVBInfo->P3c4, 0x3F,
2661 CH7007TV_TimingVPtr[0].data[9]);
2662
2663 }
2664 }
2665 }
2666
XGI_GetLCDCapPtr(struct vb_device_info * pVBInfo)2667 static unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo)
2668 {
2669 unsigned char tempal, tempah, tempbl, i;
2670
2671 tempah = xgifb_reg_get(pVBInfo->P3d4, 0x36);
2672 tempal = tempah & 0x0F;
2673 tempah = tempah & 0xF0;
2674 i = 0;
2675 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
2676
2677 while (tempbl != 0xFF) {
2678 if (tempbl & 0x80) { /* OEMUtil */
2679 tempal = tempah;
2680 tempbl = tempbl & ~(0x80);
2681 }
2682
2683 if (tempal == tempbl)
2684 break;
2685
2686 i++;
2687
2688 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
2689 }
2690
2691 return i;
2692 }
2693
XGI_GetLCDCapPtr1(struct vb_device_info * pVBInfo)2694 static unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo)
2695 {
2696 unsigned short tempah, tempal, tempbl, i;
2697
2698 tempal = pVBInfo->LCDResInfo;
2699 tempah = pVBInfo->LCDTypeInfo;
2700
2701 i = 0;
2702 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
2703
2704 while (tempbl != 0xFF) {
2705 if ((tempbl & 0x80) && (tempbl != 0x80)) {
2706 tempal = tempah;
2707 tempbl &= ~0x80;
2708 }
2709
2710 if (tempal == tempbl)
2711 break;
2712
2713 i++;
2714 tempbl = pVBInfo->LCDCapList[i].LCD_ID;
2715 }
2716
2717 if (tempbl == 0xFF) {
2718 pVBInfo->LCDResInfo = Panel1024x768;
2719 pVBInfo->LCDTypeInfo = 0;
2720 i = 0;
2721 }
2722
2723 return i;
2724 }
2725
XGI_GetLCDSync(unsigned short * HSyncWidth,unsigned short * VSyncWidth,struct vb_device_info * pVBInfo)2726 static void XGI_GetLCDSync(unsigned short *HSyncWidth, unsigned short *VSyncWidth,
2727 struct vb_device_info *pVBInfo)
2728 {
2729 unsigned short Index;
2730
2731 Index = XGI_GetLCDCapPtr(pVBInfo);
2732 *HSyncWidth = pVBInfo->LCDCapList[Index].LCD_HSyncWidth;
2733 *VSyncWidth = pVBInfo->LCDCapList[Index].LCD_VSyncWidth;
2734
2735 return;
2736 }
2737
XGI_SetLVDSRegs(unsigned short ModeNo,unsigned short ModeIdIndex,unsigned short RefreshRateTableIndex,struct vb_device_info * pVBInfo)2738 static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
2739 unsigned short RefreshRateTableIndex,
2740 struct vb_device_info *pVBInfo)
2741 {
2742 unsigned short tempbx, tempax, tempcx, tempdx, push1, push2, modeflag;
2743 unsigned long temp, temp1, temp2, temp3, push3;
2744 struct XGI330_LCDDataDesStruct *LCDPtr = NULL;
2745 struct XGI330_LCDDataDesStruct2 *LCDPtr1 = NULL;
2746
2747 if (ModeNo > 0x13)
2748 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
2749 else
2750 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
2751
2752 if (!(pVBInfo->SetFlag & Win9xDOSMode)) {
2753 if ((pVBInfo->IF_DEF_CH7017 == 0) || (pVBInfo->VBInfo
2754 & (SetCRT2ToLCD | SetCRT2ToLCDA))) {
2755 if (pVBInfo->IF_DEF_OEMUtil == 1) {
2756 tempbx = 8;
2757 LCDPtr
2758 = (struct XGI330_LCDDataDesStruct *) XGI_GetLcdPtr(
2759 tempbx,
2760 ModeNo,
2761 ModeIdIndex,
2762 RefreshRateTableIndex,
2763 pVBInfo);
2764 }
2765
2766 if ((pVBInfo->IF_DEF_OEMUtil == 0) || (LCDPtr == NULL)) {
2767 tempbx = 3;
2768 if (pVBInfo->LCDInfo & EnableScalingLCD)
2769 LCDPtr1
2770 = (struct XGI330_LCDDataDesStruct2 *) XGI_GetLcdPtr(
2771 tempbx,
2772 ModeNo,
2773 ModeIdIndex,
2774 RefreshRateTableIndex,
2775 pVBInfo);
2776 else
2777 LCDPtr
2778 = (struct XGI330_LCDDataDesStruct *) XGI_GetLcdPtr(
2779 tempbx,
2780 ModeNo,
2781 ModeIdIndex,
2782 RefreshRateTableIndex,
2783 pVBInfo);
2784 }
2785
2786 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
2787 push1 = tempbx;
2788 push2 = tempax;
2789
2790 /* GetLCDResInfo */
2791 if ((pVBInfo->LCDResInfo == Panel1024x768)
2792 || (pVBInfo->LCDResInfo
2793 == Panel1024x768x75)) {
2794 tempax = 1024;
2795 tempbx = 768;
2796 } else if ((pVBInfo->LCDResInfo == Panel1280x1024)
2797 || (pVBInfo->LCDResInfo
2798 == Panel1280x1024x75)) {
2799 tempax = 1280;
2800 tempbx = 1024;
2801 } else if (pVBInfo->LCDResInfo == Panel1400x1050) {
2802 tempax = 1400;
2803 tempbx = 1050;
2804 } else {
2805 tempax = 1600;
2806 tempbx = 1200;
2807 }
2808
2809 if (pVBInfo->LCDInfo & SetLCDtoNonExpanding) {
2810 pVBInfo->HDE = tempax;
2811 pVBInfo->VDE = tempbx;
2812 pVBInfo->VGAHDE = tempax;
2813 pVBInfo->VGAVDE = tempbx;
2814 }
2815
2816 if ((pVBInfo->IF_DEF_ScaleLCD == 1)
2817 && (pVBInfo->LCDInfo & EnableScalingLCD)) {
2818 tempax = pVBInfo->HDE;
2819 tempbx = pVBInfo->VDE;
2820 }
2821
2822 tempax = pVBInfo->HT;
2823
2824 if (pVBInfo->LCDInfo & EnableScalingLCD)
2825 tempbx = LCDPtr1->LCDHDES;
2826 else
2827 tempbx = LCDPtr->LCDHDES;
2828
2829 tempcx = pVBInfo->HDE;
2830 tempbx = tempbx & 0x0fff;
2831 tempcx += tempbx;
2832
2833 if (tempcx >= tempax)
2834 tempcx -= tempax;
2835
2836 xgifb_reg_set(pVBInfo->Part1Port, 0x1A, tempbx & 0x07);
2837
2838 tempcx = tempcx >> 3;
2839 tempbx = tempbx >> 3;
2840
2841 xgifb_reg_set(pVBInfo->Part1Port, 0x16,
2842 (unsigned short) (tempbx & 0xff));
2843 xgifb_reg_set(pVBInfo->Part1Port, 0x17,
2844 (unsigned short) (tempcx & 0xff));
2845
2846 tempax = pVBInfo->HT;
2847
2848 if (pVBInfo->LCDInfo & EnableScalingLCD)
2849 tempbx = LCDPtr1->LCDHRS;
2850 else
2851 tempbx = LCDPtr->LCDHRS;
2852
2853 tempcx = push2;
2854
2855 if (pVBInfo->LCDInfo & EnableScalingLCD)
2856 tempcx = LCDPtr1->LCDHSync;
2857
2858 tempcx += tempbx;
2859
2860 if (tempcx >= tempax)
2861 tempcx -= tempax;
2862
2863 tempax = tempbx & 0x07;
2864 tempax = tempax >> 5;
2865 tempcx = tempcx >> 3;
2866 tempbx = tempbx >> 3;
2867
2868 tempcx &= 0x1f;
2869 tempax |= tempcx;
2870
2871 xgifb_reg_set(pVBInfo->Part1Port, 0x15, tempax);
2872 xgifb_reg_set(pVBInfo->Part1Port, 0x14,
2873 (unsigned short) (tempbx & 0xff));
2874
2875 tempax = pVBInfo->VT;
2876 if (pVBInfo->LCDInfo & EnableScalingLCD)
2877 tempbx = LCDPtr1->LCDVDES;
2878 else
2879 tempbx = LCDPtr->LCDVDES;
2880 tempcx = pVBInfo->VDE;
2881
2882 tempbx = tempbx & 0x0fff;
2883 tempcx += tempbx;
2884 if (tempcx >= tempax)
2885 tempcx -= tempax;
2886
2887 xgifb_reg_set(pVBInfo->Part1Port, 0x1b,
2888 (unsigned short) (tempbx & 0xff));
2889 xgifb_reg_set(pVBInfo->Part1Port, 0x1c,
2890 (unsigned short) (tempcx & 0xff));
2891
2892 tempbx = (tempbx >> 8) & 0x07;
2893 tempcx = (tempcx >> 8) & 0x07;
2894
2895 xgifb_reg_set(pVBInfo->Part1Port, 0x1d,
2896 (unsigned short) ((tempcx << 3)
2897 | tempbx));
2898
2899 tempax = pVBInfo->VT;
2900 if (pVBInfo->LCDInfo & EnableScalingLCD)
2901 tempbx = LCDPtr1->LCDVRS;
2902 else
2903 tempbx = LCDPtr->LCDVRS;
2904
2905 /* tempbx = tempbx >> 4; */
2906 tempcx = push1;
2907
2908 if (pVBInfo->LCDInfo & EnableScalingLCD)
2909 tempcx = LCDPtr1->LCDVSync;
2910
2911 tempcx += tempbx;
2912 if (tempcx >= tempax)
2913 tempcx -= tempax;
2914
2915 xgifb_reg_set(pVBInfo->Part1Port, 0x18,
2916 (unsigned short) (tempbx & 0xff));
2917 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, ~0x0f,
2918 (unsigned short) (tempcx & 0x0f));
2919
2920 tempax = ((tempbx >> 8) & 0x07) << 3;
2921
2922 tempbx = pVBInfo->VGAVDE;
2923 if (tempbx != pVBInfo->VDE)
2924 tempax |= 0x40;
2925
2926 if (pVBInfo->LCDInfo & EnableLVDSDDA)
2927 tempax |= 0x40;
2928
2929 xgifb_reg_and_or(pVBInfo->Part1Port, 0x1a, 0x07,
2930 tempax);
2931
2932 tempcx = pVBInfo->VGAVT;
2933 tempbx = pVBInfo->VDE;
2934 tempax = pVBInfo->VGAVDE;
2935 tempcx -= tempax;
2936
2937 temp = tempax; /* 0430 ylshieh */
2938 temp1 = (temp << 18) / tempbx;
2939
2940 tempdx = (unsigned short) ((temp << 18) % tempbx);
2941
2942 if (tempdx != 0)
2943 temp1 += 1;
2944
2945 temp2 = temp1;
2946 push3 = temp2;
2947
2948 xgifb_reg_set(pVBInfo->Part1Port, 0x37,
2949 (unsigned short) (temp2 & 0xff));
2950 xgifb_reg_set(pVBInfo->Part1Port, 0x36,
2951 (unsigned short) ((temp2 >> 8) & 0xff));
2952
2953 tempbx = (unsigned short) (temp2 >> 16);
2954 tempax = tempbx & 0x03;
2955
2956 tempbx = pVBInfo->VGAVDE;
2957 if (tempbx == pVBInfo->VDE)
2958 tempax |= 0x04;
2959
2960 xgifb_reg_set(pVBInfo->Part1Port, 0x35, tempax);
2961
2962 if (pVBInfo->VBType & VB_XGI301C) {
2963 temp2 = push3;
2964 xgifb_reg_set(pVBInfo->Part4Port, 0x3c,
2965 (unsigned short) (temp2 & 0xff));
2966 xgifb_reg_set(pVBInfo->Part4Port, 0x3b,
2967 (unsigned short) ((temp2 >> 8)
2968 & 0xff));
2969 tempbx = (unsigned short) (temp2 >> 16);
2970 xgifb_reg_and_or(pVBInfo->Part4Port, 0x3a,
2971 ~0xc0,
2972 (unsigned short) ((tempbx
2973 & 0xff) << 6));
2974
2975 tempcx = pVBInfo->VGAVDE;
2976 if (tempcx == pVBInfo->VDE)
2977 xgifb_reg_and_or(pVBInfo->Part4Port,
2978 0x30, ~0x0c, 0x00);
2979 else
2980 xgifb_reg_and_or(pVBInfo->Part4Port,
2981 0x30, ~0x0c, 0x08);
2982 }
2983
2984 tempcx = pVBInfo->VGAHDE;
2985 tempbx = pVBInfo->HDE;
2986
2987 temp1 = tempcx << 16;
2988
2989 tempax = (unsigned short) (temp1 / tempbx);
2990
2991 if ((tempbx & 0xffff) == (tempcx & 0xffff))
2992 tempax = 65535;
2993
2994 temp3 = tempax;
2995 temp1 = pVBInfo->VGAHDE << 16;
2996
2997 temp1 /= temp3;
2998 temp3 = temp3 << 16;
2999 temp1 -= 1;
3000
3001 temp3 = (temp3 & 0xffff0000) + (temp1 & 0xffff);
3002
3003 tempax = (unsigned short) (temp3 & 0xff);
3004 xgifb_reg_set(pVBInfo->Part1Port, 0x1f, tempax);
3005
3006 temp1 = pVBInfo->VGAVDE << 18;
3007 temp1 = temp1 / push3;
3008 tempbx = (unsigned short) (temp1 & 0xffff);
3009
3010 if (pVBInfo->LCDResInfo == Panel1024x768)
3011 tempbx -= 1;
3012
3013 tempax = ((tempbx >> 8) & 0xff) << 3;
3014 tempax |= (unsigned short) ((temp3 >> 8) & 0x07);
3015 xgifb_reg_set(pVBInfo->Part1Port, 0x20,
3016 (unsigned short) (tempax & 0xff));
3017 xgifb_reg_set(pVBInfo->Part1Port, 0x21,
3018 (unsigned short) (tempbx & 0xff));
3019
3020 temp3 = temp3 >> 16;
3021
3022 if (modeflag & HalfDCLK)
3023 temp3 = temp3 >> 1;
3024
3025 xgifb_reg_set(pVBInfo->Part1Port, 0x22,
3026 (unsigned short) ((temp3 >> 8) & 0xff));
3027 xgifb_reg_set(pVBInfo->Part1Port, 0x23,
3028 (unsigned short) (temp3 & 0xff));
3029 }
3030 }
3031 }
3032
3033 /* --------------------------------------------------------------------- */
3034 /* Function : XGI_GETLCDVCLKPtr */
3035 /* Input : */
3036 /* Output : al -> VCLK Index */
3037 /* Description : */
3038 /* --------------------------------------------------------------------- */
XGI_GetLCDVCLKPtr(unsigned char * di_0,unsigned char * di_1,struct vb_device_info * pVBInfo)3039 static void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1,
3040 struct vb_device_info *pVBInfo)
3041 {
3042 unsigned short index;
3043
3044 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
3045 if (pVBInfo->IF_DEF_ScaleLCD == 1) {
3046 if (pVBInfo->LCDInfo & EnableScalingLCD)
3047 return;
3048 }
3049
3050 /* index = XGI_GetLCDCapPtr(pVBInfo); */
3051 index = XGI_GetLCDCapPtr1(pVBInfo);
3052
3053 if (pVBInfo->VBInfo & SetCRT2ToLCD) { /* LCDB */
3054 *di_0 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData1;
3055 *di_1 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData2;
3056 } else { /* LCDA */
3057 *di_0 = pVBInfo->LCDCapList[index].LCDA_VCLKData1;
3058 *di_1 = pVBInfo->LCDCapList[index].LCDA_VCLKData2;
3059 }
3060 }
3061 return;
3062 }
3063
XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex,unsigned short ModeNo,unsigned short ModeIdIndex,struct vb_device_info * pVBInfo)3064 static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex,
3065 unsigned short ModeNo, unsigned short ModeIdIndex,
3066 struct vb_device_info *pVBInfo)
3067 {
3068
3069 unsigned short index, modeflag;
3070 unsigned short tempbx;
3071 unsigned char tempal;
3072 unsigned char *CHTVVCLKPtr = NULL;
3073
3074 if (ModeNo <= 0x13)
3075 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
3076 else
3077 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
3078
3079 if ((pVBInfo->SetFlag & ProgrammingCRT2) && (!(pVBInfo->LCDInfo
3080 & EnableScalingLCD))) { /* {LCDA/LCDB} */
3081 index = XGI_GetLCDCapPtr(pVBInfo);
3082 tempal = pVBInfo->LCDCapList[index].LCD_VCLK;
3083
3084 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))
3085 return tempal;
3086
3087 /* {TV} */
3088 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
3089 | VB_XGI302LV | VB_XGI301C)) {
3090 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
3091 tempal = HiTVVCLKDIV2;
3092 if (!(pVBInfo->TVInfo & RPLLDIV2XO))
3093 tempal = HiTVVCLK;
3094 if (pVBInfo->TVInfo & TVSimuMode) {
3095 tempal = HiTVSimuVCLK;
3096 if (!(modeflag & Charx8Dot))
3097 tempal = HiTVTextVCLK;
3098
3099 }
3100 return tempal;
3101 }
3102
3103 if (pVBInfo->TVInfo & SetYPbPrMode750p) {
3104 tempal = YPbPr750pVCLK;
3105 return tempal;
3106 }
3107
3108 if (pVBInfo->TVInfo & SetYPbPrMode525p) {
3109 tempal = YPbPr525pVCLK;
3110 return tempal;
3111 }
3112
3113 tempal = NTSC1024VCLK;
3114
3115 if (!(pVBInfo->TVInfo & NTSC1024x768)) {
3116 tempal = TVVCLKDIV2;
3117 if (!(pVBInfo->TVInfo & RPLLDIV2XO))
3118 tempal = TVVCLK;
3119 }
3120
3121 if (pVBInfo->VBInfo & SetCRT2ToTV)
3122 return tempal;
3123 }
3124 /* else if ((pVBInfo->IF_DEF_CH7017==1)&&(pVBInfo->VBType&VB_CH7017)) {
3125 if (ModeNo<=0x13)
3126 *tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
3127 else
3128 *tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
3129 *tempal = *tempal & 0x1F;
3130 tempbx = 0;
3131 if (pVBInfo->TVInfo & SetPALTV)
3132 tempbx = tempbx + 2;
3133 if (pVBInfo->TVInfo & SetCHTVOverScan)
3134 tempbx++;
3135 tempbx = tempbx << 1;
3136 } */
3137 } /* {End of VB} */
3138
3139 if ((pVBInfo->IF_DEF_CH7007 == 1) && (pVBInfo->VBType & VB_CH7007)) { /* [Billy] 07/05/08 CH7007 */
3140 /* VideoDebugPrint((0, "XGI_GetVCLKPtr: pVBInfo->IF_DEF_CH7007==1\n")); */
3141 if ((pVBInfo->VBInfo & SetCRT2ToTV)) {
3142 if (ModeNo <= 0x13) {
3143 tempal
3144 = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
3145 } else {
3146 tempal
3147 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
3148 }
3149
3150 tempal = tempal & 0x0F;
3151 tempbx = 0;
3152
3153 if (pVBInfo->TVInfo & SetPALTV)
3154 tempbx = tempbx + 2;
3155
3156 if (pVBInfo->TVInfo & SetCHTVOverScan)
3157 tempbx++;
3158
3159 /** tempbx = tempbx << 1; CH7007 ? **/
3160
3161 /* [Billy]07/05/29 CH7007 */
3162 if (pVBInfo->IF_DEF_CH7007 == 1) {
3163 switch (tempbx) {
3164 case 0:
3165 CHTVVCLKPtr = XGI7007_CHTVVCLKUNTSC;
3166 break;
3167 case 1:
3168 CHTVVCLKPtr = XGI7007_CHTVVCLKONTSC;
3169 break;
3170 case 2:
3171 CHTVVCLKPtr = XGI7007_CHTVVCLKUPAL;
3172 break;
3173 case 3:
3174 CHTVVCLKPtr = XGI7007_CHTVVCLKOPAL;
3175 break;
3176 default:
3177 break;
3178
3179 }
3180 }
3181 /* else {
3182 switch(tempbx) {
3183 case 0:
3184 CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC;
3185 break;
3186 case 1:
3187 CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC;
3188 break;
3189 case 2:
3190 CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL;
3191 break;
3192 case 3:
3193 CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL;
3194 break;
3195 default:
3196 break;
3197 }
3198 }
3199 */
3200
3201 tempal = CHTVVCLKPtr[tempal];
3202 return tempal;
3203 }
3204
3205 }
3206
3207 tempal = (unsigned char) inb((pVBInfo->P3ca + 0x02));
3208 tempal = tempal >> 2;
3209 tempal &= 0x03;
3210
3211 if ((pVBInfo->LCDInfo & EnableScalingLCD) && (modeflag & Charx8Dot)) /* for Dot8 Scaling LCD */
3212 tempal = tempal ^ tempal; /* ; set to VCLK25MHz always */
3213
3214 if (ModeNo <= 0x13)
3215 return tempal;
3216
3217 tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
3218 return tempal;
3219 }
3220
XGI_GetVCLKLen(unsigned char tempal,unsigned char * di_0,unsigned char * di_1,struct vb_device_info * pVBInfo)3221 static void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0,
3222 unsigned char *di_1, struct vb_device_info *pVBInfo)
3223 {
3224 if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 2007/05/16 */
3225 /* VideoDebugPrint((0, "XGI_GetVCLKLen: pVBInfo->IF_DEF_CH7007==1\n")); */
3226 *di_0 = (unsigned char) XGI_CH7007VCLKData[tempal].SR2B;
3227 *di_1 = (unsigned char) XGI_CH7007VCLKData[tempal].SR2C;
3228 } else if (pVBInfo->VBType & (VB_XGI301 | VB_XGI301B | VB_XGI302B
3229 | VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
3230 if ((!(pVBInfo->VBInfo & SetCRT2ToLCDA)) && (pVBInfo->SetFlag
3231 & ProgrammingCRT2)) {
3232 *di_0 = (unsigned char) XGI_VBVCLKData[tempal].SR2B;
3233 *di_1 = XGI_VBVCLKData[tempal].SR2C;
3234 }
3235 } else {
3236 *di_0 = XGI_VCLKData[tempal].SR2B;
3237 *di_1 = XGI_VCLKData[tempal].SR2C;
3238 }
3239 }
3240
XGI_SetCRT2ECLK(unsigned short ModeNo,unsigned short ModeIdIndex,unsigned short RefreshRateTableIndex,struct vb_device_info * pVBInfo)3241 static void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex,
3242 unsigned short RefreshRateTableIndex,
3243 struct vb_device_info *pVBInfo)
3244 {
3245 unsigned char di_0, di_1, tempal;
3246 int i;
3247
3248 tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex,
3249 pVBInfo);
3250 XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo);
3251 XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo);
3252
3253 for (i = 0; i < 4; i++) {
3254 xgifb_reg_and_or(pVBInfo->P3d4, 0x31, ~0x30,
3255 (unsigned short) (0x10 * i));
3256 if (pVBInfo->IF_DEF_CH7007 == 1) {
3257 xgifb_reg_set(pVBInfo->P3c4, 0x2b, di_0);
3258 xgifb_reg_set(pVBInfo->P3c4, 0x2c, di_1);
3259 } else if ((!(pVBInfo->VBInfo & SetCRT2ToLCDA))
3260 && (!(pVBInfo->VBInfo & SetInSlaveMode))) {
3261 xgifb_reg_set(pVBInfo->P3c4, 0x2e, di_0);
3262 xgifb_reg_set(pVBInfo->P3c4, 0x2f, di_1);
3263 } else {
3264 xgifb_reg_set(pVBInfo->P3c4, 0x2b, di_0);
3265 xgifb_reg_set(pVBInfo->P3c4, 0x2c, di_1);
3266 }
3267 }
3268 }
3269
XGI_UpdateModeInfo(struct xgi_hw_device_info * HwDeviceExtension,struct vb_device_info * pVBInfo)3270 static void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension,
3271 struct vb_device_info *pVBInfo)
3272 {
3273 unsigned short tempcl, tempch, temp, tempbl, tempax;
3274
3275 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
3276 | VB_XGI302LV | VB_XGI301C)) {
3277 tempcl = 0;
3278 tempch = 0;
3279 temp = xgifb_reg_get(pVBInfo->P3c4, 0x01);
3280
3281 if (!(temp & 0x20)) {
3282 temp = xgifb_reg_get(pVBInfo->P3d4, 0x17);
3283 if (temp & 0x80) {
3284 temp = xgifb_reg_get(pVBInfo->P3d4, 0x53);
3285 if (!(temp & 0x40))
3286 tempcl |= ActiveCRT1;
3287 }
3288 }
3289
3290 temp = xgifb_reg_get(pVBInfo->Part1Port, 0x2e);
3291 temp &= 0x0f;
3292
3293 if (!(temp == 0x08)) {
3294 tempax = xgifb_reg_get(pVBInfo->Part1Port, 0x13); /* Check ChannelA by Part1_13 [2003/10/03] */
3295 if (tempax & 0x04)
3296 tempcl = tempcl | ActiveLCD;
3297
3298 temp &= 0x05;
3299
3300 if (!(tempcl & ActiveLCD))
3301 if (temp == 0x01)
3302 tempcl |= ActiveCRT2;
3303
3304 if (temp == 0x04)
3305 tempcl |= ActiveLCD;
3306
3307 if (temp == 0x05) {
3308 temp = xgifb_reg_get(pVBInfo->Part2Port, 0x00);
3309
3310 if (!(temp & 0x08))
3311 tempch |= ActiveAVideo;
3312
3313 if (!(temp & 0x04))
3314 tempch |= ActiveSVideo;
3315
3316 if (temp & 0x02)
3317 tempch |= ActiveSCART;
3318
3319 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
3320 if (temp & 0x01)
3321 tempch |= ActiveHiTV;
3322 }
3323
3324 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
3325 temp = xgifb_reg_get(
3326 pVBInfo->Part2Port,
3327 0x4d);
3328
3329 if (temp & 0x10)
3330 tempch |= ActiveYPbPr;
3331 }
3332
3333 if (tempch != 0)
3334 tempcl |= ActiveTV;
3335 }
3336 }
3337
3338 temp = xgifb_reg_get(pVBInfo->P3d4, 0x3d);
3339 if (tempcl & ActiveLCD) {
3340 if ((pVBInfo->SetFlag & ReserveTVOption)) {
3341 if (temp & ActiveTV)
3342 tempcl |= ActiveTV;
3343 }
3344 }
3345 temp = tempcl;
3346 tempbl = ~ModeSwitchStatus;
3347 xgifb_reg_and_or(pVBInfo->P3d4, 0x3d, tempbl, temp);
3348
3349 if (!(pVBInfo->SetFlag & ReserveTVOption))
3350 xgifb_reg_set(pVBInfo->P3d4, 0x3e, tempch);
3351 } else {
3352 return;
3353 }
3354 }
3355
XGI_GetVGAType(struct xgi_hw_device_info * HwDeviceExtension,struct vb_device_info * pVBInfo)3356 void XGI_GetVGAType(struct xgi_hw_device_info *HwDeviceExtension,
3357 struct vb_device_info *pVBInfo)
3358 {
3359 /*
3360 if ( HwDeviceExtension->jChipType >= XG20 ) {
3361 pVBInfo->Set_VGAType = XG20;
3362 } else {
3363 pVBInfo->Set_VGAType = VGA_XGI340;
3364 }
3365 */
3366 pVBInfo->Set_VGAType = HwDeviceExtension->jChipType;
3367 }
3368
XGI_GetVBType(struct vb_device_info * pVBInfo)3369 void XGI_GetVBType(struct vb_device_info *pVBInfo)
3370 {
3371 unsigned short flag, tempbx, tempah;
3372
3373 if (pVBInfo->IF_DEF_CH7007 == 1) {
3374 pVBInfo->VBType = VB_CH7007;
3375 return;
3376 }
3377 if (pVBInfo->IF_DEF_LVDS == 0) {
3378 tempbx = VB_XGI302B;
3379 flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00);
3380 if (flag != 0x02) {
3381 tempbx = VB_XGI301;
3382 flag = xgifb_reg_get(pVBInfo->Part4Port, 0x01);
3383 if (flag >= 0xB0) {
3384 tempbx = VB_XGI301B;
3385 if (flag >= 0xC0) {
3386 tempbx = VB_XGI301C;
3387 if (flag >= 0xD0) {
3388 tempbx = VB_XGI301LV;
3389 if (flag >= 0xE0) {
3390 tempbx = VB_XGI302LV;
3391 tempah
3392 = xgifb_reg_get(
3393 pVBInfo->Part4Port,
3394 0x39);
3395 if (tempah != 0xFF)
3396 tempbx
3397 = VB_XGI301C;
3398 }
3399 }
3400 }
3401
3402 if (tempbx & (VB_XGI301B | VB_XGI302B)) {
3403 flag = xgifb_reg_get(
3404 pVBInfo->Part4Port,
3405 0x23);
3406
3407 if (!(flag & 0x02))
3408 tempbx = tempbx | VB_NoLCD;
3409 }
3410 }
3411 }
3412 pVBInfo->VBType = tempbx;
3413 }
3414 /*
3415 else if (pVBInfo->IF_DEF_CH7017 == 1)
3416 pVBInfo->VBType = VB_CH7017;
3417 else //LVDS
3418 pVBInfo->VBType = VB_LVDS_NS;
3419 */
3420
3421 }
3422
XGI_GetVBInfo(unsigned short ModeNo,unsigned short ModeIdIndex,struct xgi_hw_device_info * HwDeviceExtension,struct vb_device_info * pVBInfo)3423 void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
3424 struct xgi_hw_device_info *HwDeviceExtension,
3425 struct vb_device_info *pVBInfo)
3426 {
3427 unsigned short tempax, push, tempbx, temp, modeflag;
3428
3429 if (ModeNo <= 0x13)
3430 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
3431 else
3432 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3433
3434 pVBInfo->SetFlag = 0;
3435 pVBInfo->ModeType = modeflag & ModeInfoFlag;
3436 tempbx = 0;
3437
3438 if (pVBInfo->VBType & 0xFFFF) {
3439 temp = xgifb_reg_get(pVBInfo->P3d4, 0x30); /* Check Display Device */
3440 tempbx = tempbx | temp;
3441 temp = xgifb_reg_get(pVBInfo->P3d4, 0x31);
3442 push = temp;
3443 push = push << 8;
3444 tempax = temp << 8;
3445 tempbx = tempbx | tempax;
3446 temp = (SetCRT2ToDualEdge | SetCRT2ToYPbPr | SetCRT2ToLCDA
3447 | SetInSlaveMode | DisableCRT2Display);
3448 temp = 0xFFFF ^ temp;
3449 tempbx &= temp;
3450
3451 temp = xgifb_reg_get(pVBInfo->P3d4, 0x38);
3452
3453 if (pVBInfo->IF_DEF_LCDA == 1) {
3454
3455 if ((pVBInfo->Set_VGAType >= XG20)
3456 || (pVBInfo->Set_VGAType >= XG40)) {
3457 if (pVBInfo->IF_DEF_LVDS == 0) {
3458 /* if ((pVBInfo->VBType & VB_XGI302B) || (pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType & VB_XGI302LV) || (pVBInfo->VBType & VB_XGI301C)) */
3459 if (pVBInfo->VBType & (VB_XGI302B
3460 | VB_XGI301LV
3461 | VB_XGI302LV
3462 | VB_XGI301C)) {
3463 if (temp & EnableDualEdge) {
3464 tempbx
3465 |= SetCRT2ToDualEdge;
3466
3467 if (temp & SetToLCDA)
3468 tempbx
3469 |= SetCRT2ToLCDA;
3470 }
3471 }
3472 } else if (pVBInfo->IF_DEF_CH7017 == 1) {
3473 if (pVBInfo->VBType & VB_CH7017) {
3474 if (temp & EnableDualEdge) {
3475 tempbx
3476 |= SetCRT2ToDualEdge;
3477
3478 if (temp & SetToLCDA)
3479 tempbx
3480 |= SetCRT2ToLCDA;
3481 }
3482 }
3483 }
3484 }
3485 }
3486
3487 if (pVBInfo->IF_DEF_YPbPr == 1) {
3488 if (((pVBInfo->IF_DEF_LVDS == 0) && ((pVBInfo->VBType
3489 & VB_XGI301LV) || (pVBInfo->VBType
3490 & VB_XGI302LV) || (pVBInfo->VBType
3491 & VB_XGI301C)))
3492 || ((pVBInfo->IF_DEF_CH7017 == 1)
3493 && (pVBInfo->VBType
3494 & VB_CH7017))
3495 || ((pVBInfo->IF_DEF_CH7007 == 1)
3496 && (pVBInfo->VBType
3497 & VB_CH7007))) { /* [Billy] 07/05/04 */
3498 if (temp & SetYPbPr) { /* temp = CR38 */
3499 if (pVBInfo->IF_DEF_HiVision == 1) {
3500 temp = xgifb_reg_get(
3501 pVBInfo->P3d4,
3502 0x35); /* shampoo add for new scratch */
3503 temp &= YPbPrMode;
3504 tempbx |= SetCRT2ToHiVisionTV;
3505
3506 if (temp != YPbPrMode1080i) {
3507 tempbx
3508 &= (~SetCRT2ToHiVisionTV);
3509 tempbx
3510 |= SetCRT2ToYPbPr;
3511 }
3512 }
3513
3514 /* tempbx |= SetCRT2ToYPbPr; */
3515 }
3516 }
3517 }
3518
3519 tempax = push; /* restore CR31 */
3520
3521 if (pVBInfo->IF_DEF_LVDS == 0) {
3522 if (pVBInfo->IF_DEF_YPbPr == 1) {
3523 if (pVBInfo->IF_DEF_HiVision == 1)
3524 temp = 0x09FC;
3525 else
3526 temp = 0x097C;
3527 } else {
3528 if (pVBInfo->IF_DEF_HiVision == 1)
3529 temp = 0x01FC;
3530 else
3531 temp = 0x017C;
3532 }
3533 } else { /* 3nd party chip */
3534 if (pVBInfo->IF_DEF_CH7017 == 1)
3535 temp = (SetCRT2ToTV | SetCRT2ToLCD
3536 | SetCRT2ToLCDA);
3537 else if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/03 */
3538 temp = SetCRT2ToTV;
3539 } else
3540 temp = SetCRT2ToLCD;
3541 }
3542
3543 if (!(tempbx & temp)) {
3544 tempax |= DisableCRT2Display;
3545 tempbx = 0;
3546 }
3547
3548 if (pVBInfo->IF_DEF_LCDA == 1) { /* Select Display Device */
3549 if (!(pVBInfo->VBType & VB_NoLCD)) {
3550 if (tempbx & SetCRT2ToLCDA) {
3551 if (tempbx & SetSimuScanMode)
3552 tempbx
3553 &= (~(SetCRT2ToLCD
3554 | SetCRT2ToRAMDAC
3555 | SwitchToCRT2));
3556 else
3557 tempbx
3558 &= (~(SetCRT2ToLCD
3559 | SetCRT2ToRAMDAC
3560 | SetCRT2ToTV
3561 | SwitchToCRT2));
3562 }
3563 }
3564 }
3565
3566 /* shampoo add */
3567 if (!(tempbx & (SwitchToCRT2 | SetSimuScanMode))) { /* for driver abnormal */
3568 if (pVBInfo->IF_DEF_CRT2Monitor == 1) {
3569 if (tempbx & SetCRT2ToRAMDAC) {
3570 tempbx &= (0xFF00 | SetCRT2ToRAMDAC
3571 | SwitchToCRT2
3572 | SetSimuScanMode);
3573 tempbx &= (0x00FF | (~SetCRT2ToYPbPr));
3574 }
3575 } else {
3576 tempbx &= (~(SetCRT2ToRAMDAC | SetCRT2ToLCD
3577 | SetCRT2ToTV));
3578 }
3579 }
3580
3581 if (!(pVBInfo->VBType & VB_NoLCD)) {
3582 if (tempbx & SetCRT2ToLCD) {
3583 tempbx &= (0xFF00 | SetCRT2ToLCD | SwitchToCRT2
3584 | SetSimuScanMode);
3585 tempbx &= (0x00FF | (~SetCRT2ToYPbPr));
3586 }
3587 }
3588
3589 if (tempbx & SetCRT2ToSCART) {
3590 tempbx &= (0xFF00 | SetCRT2ToSCART | SwitchToCRT2
3591 | SetSimuScanMode);
3592 tempbx &= (0x00FF | (~SetCRT2ToYPbPr));
3593 }
3594
3595 if (pVBInfo->IF_DEF_YPbPr == 1) {
3596 if (tempbx & SetCRT2ToYPbPr)
3597 tempbx &= (0xFF00 | SwitchToCRT2
3598 | SetSimuScanMode);
3599 }
3600
3601 if (pVBInfo->IF_DEF_HiVision == 1) {
3602 if (tempbx & SetCRT2ToHiVisionTV)
3603 tempbx &= (0xFF00 | SetCRT2ToHiVisionTV
3604 | SwitchToCRT2
3605 | SetSimuScanMode);
3606 }
3607
3608 if (tempax & DisableCRT2Display) { /* Set Display Device Info */
3609 if (!(tempbx & (SwitchToCRT2 | SetSimuScanMode)))
3610 tempbx = DisableCRT2Display;
3611 }
3612
3613 if (!(tempbx & DisableCRT2Display)) {
3614 if ((!(tempbx & DriverMode))
3615 || (!(modeflag & CRT2Mode))) {
3616 if (pVBInfo->IF_DEF_LCDA == 1) {
3617 if (!(tempbx & SetCRT2ToLCDA))
3618 tempbx
3619 |= (SetInSlaveMode
3620 | SetSimuScanMode);
3621 }
3622
3623 if (pVBInfo->IF_DEF_VideoCapture == 1) {
3624 if (((HwDeviceExtension->jChipType
3625 == XG40)
3626 && (pVBInfo->Set_VGAType
3627 == XG40))
3628 || ((HwDeviceExtension->jChipType
3629 == XG41)
3630 && (pVBInfo->Set_VGAType
3631 == XG41))
3632 || ((HwDeviceExtension->jChipType
3633 == XG42)
3634 && (pVBInfo->Set_VGAType
3635 == XG42))
3636 || ((HwDeviceExtension->jChipType
3637 == XG45)
3638 && (pVBInfo->Set_VGAType
3639 == XG45))) {
3640 if (ModeNo <= 13) {
3641 if (!(tempbx
3642 & SetCRT2ToRAMDAC)) { /*CRT2 not need to support*/
3643 tempbx
3644 &= (0x00FF
3645 | (~SetInSlaveMode));
3646 pVBInfo->SetFlag
3647 |= EnableVCMode;
3648 }
3649 }
3650 }
3651 }
3652 }
3653
3654 /* LCD+TV can't support in slave mode (Force LCDA+TV->LCDB) */
3655 if ((tempbx & SetInSlaveMode) && (tempbx
3656 & SetCRT2ToLCDA)) {
3657 tempbx ^= (SetCRT2ToLCD | SetCRT2ToLCDA
3658 | SetCRT2ToDualEdge);
3659 pVBInfo->SetFlag |= ReserveTVOption;
3660 }
3661 }
3662 }
3663
3664 pVBInfo->VBInfo = tempbx;
3665 }
3666
XGI_GetTVInfo(unsigned short ModeNo,unsigned short ModeIdIndex,struct vb_device_info * pVBInfo)3667 void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
3668 struct vb_device_info *pVBInfo)
3669 {
3670 unsigned short temp, tempbx = 0, resinfo = 0, modeflag, index1;
3671
3672 tempbx = 0;
3673 resinfo = 0;
3674
3675 if (pVBInfo->VBInfo & SetCRT2ToTV) {
3676 if (ModeNo <= 0x13) {
3677 modeflag
3678 = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ModeFlag */
3679 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; /* si+St_ResInfo */
3680 } else {
3681 modeflag
3682 = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3683 resinfo
3684 = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; /* si+Ext_ResInfo */
3685 }
3686
3687 if (pVBInfo->VBInfo & SetCRT2ToTV) {
3688 temp = xgifb_reg_get(pVBInfo->P3d4, 0x35);
3689 tempbx = temp;
3690 if (tempbx & SetPALTV) {
3691 tempbx &= (SetCHTVOverScan | SetPALMTV
3692 | SetPALNTV | SetPALTV);
3693 if (tempbx & SetPALMTV)
3694 tempbx &= ~SetPALTV; /* set to NTSC if PAL-M */
3695 } else
3696 tempbx &= (SetCHTVOverScan | SetNTSCJ
3697 | SetPALTV);
3698 /*
3699 if (pVBInfo->IF_DEF_LVDS == 0) {
3700 index1 = xgifb_reg_get(pVBInfo->P3d4, 0x38); //PAL-M/PAL-N Info
3701 temp2 = (index1 & 0xC0) >> 5; //00:PAL, 01:PAL-M, 10:PAL-N
3702 tempbx |= temp2;
3703 if (temp2 & 0x02) //PAL-M
3704 tempbx &= (~SetPALTV);
3705 }
3706 */
3707 }
3708
3709 if (pVBInfo->IF_DEF_CH7017 == 1) {
3710 tempbx = xgifb_reg_get(pVBInfo->P3d4, 0x35);
3711
3712 if (tempbx & TVOverScan)
3713 tempbx |= SetCHTVOverScan;
3714 }
3715
3716 if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/04 */
3717 tempbx = xgifb_reg_get(pVBInfo->P3d4, 0x35);
3718
3719 if (tempbx & TVOverScan)
3720 tempbx |= SetCHTVOverScan;
3721 }
3722
3723 if (pVBInfo->IF_DEF_LVDS == 0) {
3724 if (pVBInfo->VBInfo & SetCRT2ToSCART)
3725 tempbx |= SetPALTV;
3726 }
3727
3728 if (pVBInfo->IF_DEF_YPbPr == 1) {
3729 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
3730 index1 = xgifb_reg_get(pVBInfo->P3d4, 0x35);
3731 index1 &= YPbPrMode;
3732
3733 if (index1 == YPbPrMode525i)
3734 tempbx |= SetYPbPrMode525i;
3735
3736 if (index1 == YPbPrMode525p)
3737 tempbx = tempbx | SetYPbPrMode525p;
3738 if (index1 == YPbPrMode750p)
3739 tempbx = tempbx | SetYPbPrMode750p;
3740 }
3741 }
3742
3743 if (pVBInfo->IF_DEF_HiVision == 1) {
3744 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
3745 tempbx = tempbx | SetYPbPrMode1080i | SetPALTV;
3746 }
3747
3748 if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */
3749 if ((pVBInfo->VBInfo & SetInSlaveMode)
3750 && (!(pVBInfo->VBInfo & SetNotSimuMode)))
3751 tempbx |= TVSimuMode;
3752
3753 if (!(tempbx & SetPALTV) && (modeflag > 13) && (resinfo
3754 == 8)) /* NTSC 1024x768, */
3755 tempbx |= NTSC1024x768;
3756
3757 tempbx |= RPLLDIV2XO;
3758
3759 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
3760 if (pVBInfo->VBInfo & SetInSlaveMode)
3761 tempbx &= (~RPLLDIV2XO);
3762 } else {
3763 if (tempbx & (SetYPbPrMode525p
3764 | SetYPbPrMode750p))
3765 tempbx &= (~RPLLDIV2XO);
3766 else if (!(pVBInfo->VBType & (VB_XGI301B
3767 | VB_XGI302B | VB_XGI301LV
3768 | VB_XGI302LV | VB_XGI301C))) {
3769 if (tempbx & TVSimuMode)
3770 tempbx &= (~RPLLDIV2XO);
3771 }
3772 }
3773 }
3774 }
3775 pVBInfo->TVInfo = tempbx;
3776 }
3777
XGI_GetLCDInfo(unsigned short ModeNo,unsigned short ModeIdIndex,struct vb_device_info * pVBInfo)3778 unsigned char XGI_GetLCDInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
3779 struct vb_device_info *pVBInfo)
3780 {
3781 unsigned short temp, tempax, tempbx, modeflag, resinfo = 0, LCDIdIndex;
3782
3783 pVBInfo->LCDResInfo = 0;
3784 pVBInfo->LCDTypeInfo = 0;
3785 pVBInfo->LCDInfo = 0;
3786
3787 if (ModeNo <= 0x13) {
3788 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ModeFlag // */
3789 } else {
3790 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3791 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; /* si+Ext_ResInfo // */
3792 }
3793
3794 temp = xgifb_reg_get(pVBInfo->P3d4, 0x36); /* Get LCD Res.Info */
3795 tempbx = temp & 0x0F;
3796
3797 if (tempbx == 0)
3798 tempbx = Panel1024x768; /* default */
3799
3800 /* LCD75 [2003/8/22] Vicent */
3801 if ((tempbx == Panel1024x768) || (tempbx == Panel1280x1024)) {
3802 if (pVBInfo->VBInfo & DriverMode) {
3803 tempax = xgifb_reg_get(pVBInfo->P3d4, 0x33);
3804 if (pVBInfo->VBInfo & SetCRT2ToLCDA)
3805 tempax &= 0x0F;
3806 else
3807 tempax = tempax >> 4;
3808
3809 if ((resinfo == 6) || (resinfo == 9)) {
3810 if (tempax >= 3)
3811 tempbx |= PanelRef75Hz;
3812 } else if ((resinfo == 7) || (resinfo == 8)) {
3813 if (tempax >= 4)
3814 tempbx |= PanelRef75Hz;
3815 }
3816 }
3817 }
3818
3819 pVBInfo->LCDResInfo = tempbx;
3820
3821 /* End of LCD75 */
3822
3823 if (pVBInfo->IF_DEF_OEMUtil == 1)
3824 pVBInfo->LCDTypeInfo = (temp & 0xf0) >> 4;
3825
3826 if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)))
3827 return 0;
3828
3829 tempbx = 0;
3830
3831 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
3832
3833 temp &= (ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable);
3834
3835 if ((pVBInfo->IF_DEF_ScaleLCD == 1) && (temp & LCDNonExpanding))
3836 temp &= ~EnableScalingLCD;
3837
3838 tempbx |= temp;
3839
3840 LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo);
3841
3842 tempax = pVBInfo->LCDCapList[LCDIdIndex].LCD_Capability;
3843
3844 if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */
3845 if (((pVBInfo->VBType & VB_XGI302LV) || (pVBInfo->VBType
3846 & VB_XGI301C)) && (tempax & LCDDualLink)) {
3847 tempbx |= SetLCDDualLink;
3848 }
3849 }
3850
3851 if (pVBInfo->IF_DEF_CH7017 == 1) {
3852 if (tempax & LCDDualLink)
3853 tempbx |= SetLCDDualLink;
3854 }
3855
3856 if (pVBInfo->IF_DEF_LVDS == 0) {
3857 if ((pVBInfo->LCDResInfo == Panel1400x1050) && (pVBInfo->VBInfo
3858 & SetCRT2ToLCD) && (ModeNo > 0x13) && (resinfo
3859 == 9) && (!(tempbx & EnableScalingLCD)))
3860 tempbx |= SetLCDtoNonExpanding; /* set to center in 1280x1024 LCDB for Panel1400x1050 */
3861 }
3862
3863 /*
3864 if (tempax & LCDBToA) {
3865 tempbx |= SetLCDBToA;
3866 }
3867 */
3868
3869 if (pVBInfo->IF_DEF_ExpLink == 1) {
3870 if (modeflag & HalfDCLK) {
3871 /* if (!(pVBInfo->LCDInfo&LCDNonExpanding)) */
3872 if (!(tempbx & SetLCDtoNonExpanding)) {
3873 tempbx |= EnableLVDSDDA;
3874 } else {
3875 if (ModeNo > 0x13) {
3876 if (pVBInfo->LCDResInfo
3877 == Panel1024x768) {
3878 if (resinfo == 4) { /* 512x384 */
3879 tempbx |= EnableLVDSDDA;
3880 }
3881 }
3882 }
3883 }
3884 }
3885 }
3886
3887 if (pVBInfo->VBInfo & SetInSlaveMode) {
3888 if (pVBInfo->VBInfo & SetNotSimuMode)
3889 tempbx |= LCDVESATiming;
3890 } else {
3891 tempbx |= LCDVESATiming;
3892 }
3893
3894 pVBInfo->LCDInfo = tempbx;
3895
3896 if (pVBInfo->IF_DEF_PWD == 1) {
3897 if (pVBInfo->LCDInfo & SetPWDEnable) {
3898 if ((pVBInfo->VBType & VB_XGI302LV) || (pVBInfo->VBType
3899 & VB_XGI301C)) {
3900 if (!(tempax & PWDEnable))
3901 pVBInfo->LCDInfo &= ~SetPWDEnable;
3902 }
3903 }
3904 }
3905
3906 if (pVBInfo->IF_DEF_LVDS == 0) {
3907 if (tempax & (LockLCDBToA | StLCDBToA)) {
3908 if (pVBInfo->VBInfo & SetInSlaveMode) {
3909 if (!(tempax & LockLCDBToA)) {
3910 if (ModeNo <= 0x13) {
3911 pVBInfo->VBInfo
3912 &= ~(SetSimuScanMode
3913 | SetInSlaveMode
3914 | SetCRT2ToLCD);
3915 pVBInfo->VBInfo
3916 |= SetCRT2ToLCDA
3917 | SetCRT2ToDualEdge;
3918 }
3919 }
3920 }
3921 }
3922 }
3923
3924 /*
3925 if (pVBInfo->IF_DEF_LVDS == 0) {
3926 if (tempax & (LockLCDBToA | StLCDBToA)) {
3927 if (pVBInfo->VBInfo & SetInSlaveMode) {
3928 if (!((!(tempax & LockLCDBToA)) && (ModeNo > 0x13))) {
3929 pVBInfo->VBInfo&=~(SetSimuScanMode|SetInSlaveMode|SetCRT2ToLCD);
3930 pVBInfo->VBInfo|=SetCRT2ToLCDA|SetCRT2ToDualEdge;
3931 }
3932 }
3933 }
3934 }
3935 */
3936
3937 return 1;
3938 }
3939
XGI_SearchModeID(unsigned short ModeNo,unsigned short * ModeIdIndex,struct vb_device_info * pVBInfo)3940 unsigned char XGI_SearchModeID(unsigned short ModeNo,
3941 unsigned short *ModeIdIndex, struct vb_device_info *pVBInfo)
3942 {
3943 if (ModeNo <= 5)
3944 ModeNo |= 1;
3945 if (ModeNo <= 0x13) {
3946 /* for (*ModeIdIndex=0; *ModeIdIndex < sizeof(pVBInfo->SModeIDTable) / sizeof(struct XGI_StStruct); (*ModeIdIndex)++) */
3947 for (*ModeIdIndex = 0;; (*ModeIdIndex)++) {
3948 if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == ModeNo)
3949 break;
3950 if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == 0xFF)
3951 return 0;
3952 }
3953
3954 if (ModeNo == 0x07)
3955 (*ModeIdIndex)++; /* 400 lines */
3956 if (ModeNo <= 3)
3957 (*ModeIdIndex) += 2; /* 400 lines */
3958 /* else 350 lines */
3959 } else {
3960 /* for (*ModeIdIndex=0; *ModeIdIndex < sizeof(pVBInfo->EModeIDTable) / sizeof(struct XGI_ExtStruct); (*ModeIdIndex)++) */
3961 for (*ModeIdIndex = 0;; (*ModeIdIndex)++) {
3962 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == ModeNo)
3963 break;
3964 if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == 0xFF)
3965 return 0;
3966 }
3967 }
3968
3969 return 1;
3970 }
3971
3972 /* win2000 MM adapter not support standard mode! */
3973
3974 #if 0
3975 static unsigned char XGINew_CheckMemorySize(
3976 struct xgi_hw_device_info *HwDeviceExtension,
3977 unsigned short ModeNo,
3978 unsigned short ModeIdIndex,
3979 struct vb_device_info *pVBInfo)
3980 {
3981 unsigned short memorysize, modeflag, temp, temp1, tmp;
3982
3983 /*
3984 if ((HwDeviceExtension->jChipType == XGI_650) ||
3985 (HwDeviceExtension->jChipType == XGI_650M)) {
3986 return 1;
3987 }
3988 */
3989
3990 if (ModeNo <= 0x13)
3991 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
3992 else
3993 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
3994
3995 /* ModeType = modeflag&ModeInfoFlag; // Get mode type */
3996
3997 memorysize = modeflag & MemoryInfoFlag;
3998 memorysize = memorysize > MemorySizeShift;
3999 memorysize++; /* Get memory size */
4000
4001 temp = xgifb_reg_get(pVBInfo->P3c4, 0x14); /* Get DRAM Size */
4002 tmp = temp;
4003
4004 if (HwDeviceExtension->jChipType == XG40) {
4005 temp = 1 << ((temp & 0x0F0) >> 4); /* memory size per channel SR14[7:4] */
4006 if ((tmp & 0x0c) == 0x0C) { /* Qual channels */
4007 temp <<= 2;
4008 } else if ((tmp & 0x0c) == 0x08) { /* Dual channels */
4009 temp <<= 1;
4010 }
4011 } else if (HwDeviceExtension->jChipType == XG42) {
4012 temp = 1 << ((temp & 0x0F0) >> 4); /* memory size per channel SR14[7:4] */
4013 if ((tmp & 0x04) == 0x04) { /* Dual channels */
4014 temp <<= 1;
4015 }
4016 } else if (HwDeviceExtension->jChipType == XG45) {
4017 temp = 1 << ((temp & 0x0F0) >> 4); /* memory size per channel SR14[7:4] */
4018 if ((tmp & 0x0c) == 0x0C) { /* Qual channels */
4019 temp <<= 2;
4020 } else if ((tmp & 0x0c) == 0x08) { /* triple channels */
4021 temp1 = temp;
4022 temp <<= 1;
4023 temp += temp1;
4024 } else if ((tmp & 0x0c) == 0x04) { /* Dual channels */
4025 temp <<= 1;
4026 }
4027 }
4028 if (temp < memorysize)
4029 return 0;
4030 else
4031 return 1;
4032 }
4033 #endif
4034
4035 /*
4036 void XGINew_IsLowResolution(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned char XGINew_CheckMemorySize(struct xgi_hw_device_info *HwDeviceExtension, unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
4037 {
4038 unsigned short data ;
4039 unsigned short ModeFlag ;
4040
4041 data = xgifb_reg_get(pVBInfo->P3c4, 0x0F);
4042 data &= 0x7F;
4043 xgifb_reg_set(pVBInfo->P3c4, 0x0F, data);
4044
4045 if (ModeNo > 0x13) {
4046 ModeFlag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4047 if ((ModeFlag & HalfDCLK) && (ModeFlag & DoubleScanMode)) {
4048 data = xgifb_reg_get(pVBInfo->P3c4, 0x0F);
4049 data |= 0x80;
4050 xgifb_reg_set(pVBInfo->P3c4, 0x0F, data);
4051 data = xgifb_reg_get(pVBInfo->P3c4, 0x01);
4052 data &= 0xF7;
4053 xgifb_reg_set(pVBInfo->P3c4, 0x01, data);
4054 }
4055 }
4056 }
4057 */
4058
XG21GPIODataTransfer(unsigned char ujDate)4059 static unsigned char XG21GPIODataTransfer(unsigned char ujDate)
4060 {
4061 unsigned char ujRet = 0;
4062 unsigned char i = 0;
4063
4064 for (i = 0; i < 8; i++) {
4065 ujRet = ujRet << 1;
4066 /* ujRet |= GETBITS(ujDate >> i, 0:0); */
4067 ujRet |= (ujDate >> i) & 1;
4068 }
4069
4070 return ujRet;
4071 }
4072
4073 /*----------------------------------------------------------------------------*/
4074 /* output */
4075 /* bl[5] : LVDS signal */
4076 /* bl[1] : LVDS backlight */
4077 /* bl[0] : LVDS VDD */
4078 /*----------------------------------------------------------------------------*/
XGI_XG21GetPSCValue(struct vb_device_info * pVBInfo)4079 static unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo)
4080 {
4081 unsigned char CR4A, temp;
4082
4083 CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
4084 xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x23); /* enable GPIO write */
4085
4086 temp = xgifb_reg_get(pVBInfo->P3d4, 0x48);
4087
4088 temp = XG21GPIODataTransfer(temp);
4089 temp &= 0x23;
4090 xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A);
4091 return temp;
4092 }
4093
4094 /*----------------------------------------------------------------------------*/
4095 /* output */
4096 /* bl[5] : LVDS signal */
4097 /* bl[1] : LVDS backlight */
4098 /* bl[0] : LVDS VDD */
4099 /*----------------------------------------------------------------------------*/
XGI_XG27GetPSCValue(struct vb_device_info * pVBInfo)4100 static unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo)
4101 {
4102 unsigned char CR4A, CRB4, temp;
4103
4104 CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
4105 xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x0C); /* enable GPIO write */
4106
4107 temp = xgifb_reg_get(pVBInfo->P3d4, 0x48);
4108
4109 temp &= 0x0C;
4110 temp >>= 2;
4111 xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A);
4112 CRB4 = xgifb_reg_get(pVBInfo->P3d4, 0xB4);
4113 temp |= ((CRB4 & 0x04) << 3);
4114 return temp;
4115 }
4116
XGI_DisplayOn(struct xgi_hw_device_info * pXGIHWDE,struct vb_device_info * pVBInfo)4117 void XGI_DisplayOn(struct xgi_hw_device_info *pXGIHWDE,
4118 struct vb_device_info *pVBInfo)
4119 {
4120
4121 xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x00);
4122 if (pXGIHWDE->jChipType == XG21) {
4123 if (pVBInfo->IF_DEF_LVDS == 1) {
4124 if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x1)) {
4125 XGI_XG21BLSignalVDD(0x01, 0x01, pVBInfo); /* LVDS VDD on */
4126 XGI_XG21SetPanelDelay(2, pVBInfo);
4127 }
4128 if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x20))
4129 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); /* LVDS signal on */
4130 XGI_XG21SetPanelDelay(3, pVBInfo);
4131 XGI_XG21BLSignalVDD(0x02, 0x02, pVBInfo); /* LVDS backlight on */
4132 } else {
4133 XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); /* DVO/DVI signal on */
4134 }
4135
4136 }
4137
4138 if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/23 For CH7007 */
4139
4140 }
4141
4142 if (pXGIHWDE->jChipType == XG27) {
4143 if (pVBInfo->IF_DEF_LVDS == 1) {
4144 if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x1)) {
4145 XGI_XG27BLSignalVDD(0x01, 0x01, pVBInfo); /* LVDS VDD on */
4146 XGI_XG21SetPanelDelay(2, pVBInfo);
4147 }
4148 if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x20))
4149 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); /* LVDS signal on */
4150 XGI_XG21SetPanelDelay(3, pVBInfo);
4151 XGI_XG27BLSignalVDD(0x02, 0x02, pVBInfo); /* LVDS backlight on */
4152 } else {
4153 XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); /* DVO/DVI signal on */
4154 }
4155
4156 }
4157 }
4158
XGI_DisplayOff(struct xgi_hw_device_info * pXGIHWDE,struct vb_device_info * pVBInfo)4159 void XGI_DisplayOff(struct xgi_hw_device_info *pXGIHWDE,
4160 struct vb_device_info *pVBInfo)
4161 {
4162
4163 if (pXGIHWDE->jChipType == XG21) {
4164 if (pVBInfo->IF_DEF_LVDS == 1) {
4165 XGI_XG21BLSignalVDD(0x02, 0x00, pVBInfo); /* LVDS backlight off */
4166 XGI_XG21SetPanelDelay(3, pVBInfo);
4167 } else {
4168 XGI_XG21BLSignalVDD(0x20, 0x00, pVBInfo); /* DVO/DVI signal off */
4169 }
4170 }
4171
4172 if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/23 For CH7007 */
4173 /* if (IsCH7007TVMode(pVBInfo) == 0) */
4174 {
4175 }
4176 }
4177
4178 if (pXGIHWDE->jChipType == XG27) {
4179 if ((XGI_XG27GetPSCValue(pVBInfo) & 0x2)) {
4180 XGI_XG27BLSignalVDD(0x02, 0x00, pVBInfo); /* LVDS backlight off */
4181 XGI_XG21SetPanelDelay(3, pVBInfo);
4182 }
4183
4184 if (pVBInfo->IF_DEF_LVDS == 0)
4185 XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo); /* DVO/DVI signal off */
4186 }
4187
4188 xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x20);
4189 }
4190
XGI_WaitDisply(struct vb_device_info * pVBInfo)4191 static void XGI_WaitDisply(struct vb_device_info *pVBInfo)
4192 {
4193 while ((inb(pVBInfo->P3da) & 0x01))
4194 break;
4195
4196 while (!(inb(pVBInfo->P3da) & 0x01))
4197 break;
4198 }
4199
4200 #if 0
4201 static void XGI_WaitDisplay(struct vb_device_info *pVBInfo)
4202 {
4203 while (!(inb(pVBInfo->P3da) & 0x01));
4204 while (inb(pVBInfo->P3da) & 0x01);
4205 }
4206 #endif
4207
XGI_AutoThreshold(struct vb_device_info * pVBInfo)4208 static void XGI_AutoThreshold(struct vb_device_info *pVBInfo)
4209 {
4210 if (!(pVBInfo->SetFlag & Win9xDOSMode))
4211 xgifb_reg_or(pVBInfo->Part1Port, 0x01, 0x40);
4212 }
4213
XGI_SaveCRT2Info(unsigned short ModeNo,struct vb_device_info * pVBInfo)4214 static void XGI_SaveCRT2Info(unsigned short ModeNo, struct vb_device_info *pVBInfo)
4215 {
4216 unsigned short temp1, temp2;
4217
4218 xgifb_reg_set(pVBInfo->P3d4, 0x34, ModeNo); /* reserve CR34 for CRT1 Mode No */
4219 temp1 = (pVBInfo->VBInfo & SetInSlaveMode) >> 8;
4220 temp2 = ~(SetInSlaveMode >> 8);
4221 xgifb_reg_and_or(pVBInfo->P3d4, 0x31, temp2, temp1);
4222 }
4223
XGI_GetCRT2ResInfo(unsigned short ModeNo,unsigned short ModeIdIndex,struct vb_device_info * pVBInfo)4224 static void XGI_GetCRT2ResInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
4225 struct vb_device_info *pVBInfo)
4226 {
4227 unsigned short xres, yres, modeflag, resindex;
4228
4229 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
4230 if (ModeNo <= 0x13) {
4231 xres = pVBInfo->StResInfo[resindex].HTotal;
4232 yres = pVBInfo->StResInfo[resindex].VTotal;
4233 /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; si+St_ResInfo */
4234 } else {
4235 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
4236 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
4237 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */
4238
4239 /*
4240 if (pVBInfo->IF_DEF_FSTN) {
4241 xres *= 2;
4242 yres *= 2;
4243 } else {
4244 */
4245 if (modeflag & HalfDCLK)
4246 xres *= 2;
4247
4248 if (modeflag & DoubleScanMode)
4249 yres *= 2;
4250 /* } */
4251 }
4252
4253 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
4254 if (pVBInfo->IF_DEF_LVDS == 0) {
4255 if (pVBInfo->LCDResInfo == Panel1600x1200) {
4256 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
4257 if (yres == 1024)
4258 yres = 1056;
4259 }
4260 }
4261
4262 if (pVBInfo->LCDResInfo == Panel1280x1024) {
4263 if (yres == 400)
4264 yres = 405;
4265 else if (yres == 350)
4266 yres = 360;
4267
4268 if (pVBInfo->LCDInfo & LCDVESATiming) {
4269 if (yres == 360)
4270 yres = 375;
4271 }
4272 }
4273
4274 if (pVBInfo->LCDResInfo == Panel1024x768) {
4275 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
4276 if (!(pVBInfo->LCDInfo
4277 & LCDNonExpanding)) {
4278 if (yres == 350)
4279 yres = 357;
4280 else if (yres == 400)
4281 yres = 420;
4282 else if (yres == 480)
4283 yres = 525;
4284 }
4285 }
4286 }
4287 }
4288
4289 if (xres == 720)
4290 xres = 640;
4291 }
4292
4293 pVBInfo->VGAHDE = xres;
4294 pVBInfo->HDE = xres;
4295 pVBInfo->VGAVDE = yres;
4296 pVBInfo->VDE = yres;
4297 }
4298
XGI_IsLCDDualLink(struct vb_device_info * pVBInfo)4299 static unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo)
4300 {
4301
4302 if ((pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) &&
4303 (pVBInfo->LCDInfo & SetLCDDualLink)) /* shampoo0129 */
4304 return 1;
4305
4306 return 0;
4307 }
4308
XGI_GetRAMDAC2DATA(unsigned short ModeNo,unsigned short ModeIdIndex,unsigned short RefreshRateTableIndex,struct vb_device_info * pVBInfo)4309 static void XGI_GetRAMDAC2DATA(unsigned short ModeNo, unsigned short ModeIdIndex,
4310 unsigned short RefreshRateTableIndex,
4311 struct vb_device_info *pVBInfo)
4312 {
4313 unsigned short tempax, tempbx, temp1, temp2, modeflag = 0, tempcx,
4314 StandTableIndex, CRT1Index;
4315
4316 pVBInfo->RVBHCMAX = 1;
4317 pVBInfo->RVBHCFACT = 1;
4318
4319 if (ModeNo <= 0x13) {
4320 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
4321 StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
4322 tempax = pVBInfo->StandTable[StandTableIndex].CRTC[0];
4323 tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[6];
4324 temp1 = pVBInfo->StandTable[StandTableIndex].CRTC[7];
4325 } else {
4326 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4327 CRT1Index
4328 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4329 CRT1Index &= IndexMask;
4330 temp1
4331 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[0];
4332 temp2
4333 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5];
4334 tempax = (temp1 & 0xFF) | ((temp2 & 0x03) << 8);
4335 tempbx
4336 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[8];
4337 tempcx
4338 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14]
4339 << 8;
4340 tempcx &= 0x0100;
4341 tempcx = tempcx << 2;
4342 tempbx |= tempcx;
4343 temp1
4344 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9];
4345 }
4346
4347 if (temp1 & 0x01)
4348 tempbx |= 0x0100;
4349
4350 if (temp1 & 0x20)
4351 tempbx |= 0x0200;
4352 tempax += 5;
4353
4354 if (modeflag & Charx8Dot)
4355 tempax *= 8;
4356 else
4357 tempax *= 9;
4358
4359 pVBInfo->VGAHT = tempax;
4360 pVBInfo->HT = tempax;
4361 tempbx++;
4362 pVBInfo->VGAVT = tempbx;
4363 pVBInfo->VT = tempbx;
4364 }
4365
XGI_GetCRT2Data(unsigned short ModeNo,unsigned short ModeIdIndex,unsigned short RefreshRateTableIndex,struct vb_device_info * pVBInfo)4366 static void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex,
4367 unsigned short RefreshRateTableIndex,
4368 struct vb_device_info *pVBInfo)
4369 {
4370 unsigned short tempax = 0, tempbx, modeflag, resinfo;
4371
4372 struct XGI_LCDDataStruct *LCDPtr = NULL;
4373 struct XGI_TVDataStruct *TVPtr = NULL;
4374
4375 if (ModeNo <= 0x13) {
4376 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
4377 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
4378 } else {
4379 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
4380 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4381 }
4382
4383 pVBInfo->NewFlickerMode = 0;
4384 pVBInfo->RVBHRS = 50;
4385
4386 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
4387 XGI_GetRAMDAC2DATA(ModeNo, ModeIdIndex, RefreshRateTableIndex,
4388 pVBInfo);
4389 return;
4390 }
4391
4392 tempbx = 4;
4393
4394 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
4395 LCDPtr = (struct XGI_LCDDataStruct *) XGI_GetLcdPtr(tempbx,
4396 ModeNo, ModeIdIndex, RefreshRateTableIndex,
4397 pVBInfo);
4398
4399 pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX;
4400 pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT;
4401 pVBInfo->VGAHT = LCDPtr->VGAHT;
4402 pVBInfo->VGAVT = LCDPtr->VGAVT;
4403 pVBInfo->HT = LCDPtr->LCDHT;
4404 pVBInfo->VT = LCDPtr->LCDVT;
4405
4406 if (pVBInfo->LCDResInfo == Panel1024x768) {
4407 tempax = 1024;
4408 tempbx = 768;
4409
4410 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
4411 if (pVBInfo->VGAVDE == 357)
4412 tempbx = 527;
4413 else if (pVBInfo->VGAVDE == 420)
4414 tempbx = 620;
4415 else if (pVBInfo->VGAVDE == 525)
4416 tempbx = 775;
4417 else if (pVBInfo->VGAVDE == 600)
4418 tempbx = 775;
4419 /* else if (pVBInfo->VGAVDE==350) tempbx=560; */
4420 /* else if (pVBInfo->VGAVDE==400) tempbx=640; */
4421 else
4422 tempbx = 768;
4423 } else
4424 tempbx = 768;
4425 } else if (pVBInfo->LCDResInfo == Panel1024x768x75) {
4426 tempax = 1024;
4427 tempbx = 768;
4428 } else if (pVBInfo->LCDResInfo == Panel1280x1024) {
4429 tempax = 1280;
4430 if (pVBInfo->VGAVDE == 360)
4431 tempbx = 768;
4432 else if (pVBInfo->VGAVDE == 375)
4433 tempbx = 800;
4434 else if (pVBInfo->VGAVDE == 405)
4435 tempbx = 864;
4436 else
4437 tempbx = 1024;
4438 } else if (pVBInfo->LCDResInfo == Panel1280x1024x75) {
4439 tempax = 1280;
4440 tempbx = 1024;
4441 } else if (pVBInfo->LCDResInfo == Panel1280x960) {
4442 tempax = 1280;
4443 if (pVBInfo->VGAVDE == 350)
4444 tempbx = 700;
4445 else if (pVBInfo->VGAVDE == 400)
4446 tempbx = 800;
4447 else if (pVBInfo->VGAVDE == 1024)
4448 tempbx = 960;
4449 else
4450 tempbx = 960;
4451 } else if (pVBInfo->LCDResInfo == Panel1400x1050) {
4452 tempax = 1400;
4453 tempbx = 1050;
4454
4455 if (pVBInfo->VGAVDE == 1024) {
4456 tempax = 1280;
4457 tempbx = 1024;
4458 }
4459 } else if (pVBInfo->LCDResInfo == Panel1600x1200) {
4460 tempax = 1600;
4461 tempbx = 1200; /* alan 10/14/2003 */
4462 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
4463 if (pVBInfo->VGAVDE == 350)
4464 tempbx = 875;
4465 else if (pVBInfo->VGAVDE == 400)
4466 tempbx = 1000;
4467 }
4468 }
4469
4470 if (pVBInfo->LCDInfo & LCDNonExpanding) {
4471 tempax = pVBInfo->VGAHDE;
4472 tempbx = pVBInfo->VGAVDE;
4473 }
4474
4475 pVBInfo->HDE = tempax;
4476 pVBInfo->VDE = tempbx;
4477 return;
4478 }
4479
4480 if (pVBInfo->VBInfo & (SetCRT2ToTV)) {
4481 tempbx = 4;
4482 TVPtr = (struct XGI_TVDataStruct *) XGI_GetTVPtr(tempbx,
4483 ModeNo, ModeIdIndex, RefreshRateTableIndex,
4484 pVBInfo);
4485
4486 pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX;
4487 pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT;
4488 pVBInfo->VGAHT = TVPtr->VGAHT;
4489 pVBInfo->VGAVT = TVPtr->VGAVT;
4490 pVBInfo->HDE = TVPtr->TVHDE;
4491 pVBInfo->VDE = TVPtr->TVVDE;
4492 pVBInfo->RVBHRS = TVPtr->RVBHRS;
4493 pVBInfo->NewFlickerMode = TVPtr->FlickerMode;
4494
4495 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4496 if (resinfo == 0x08)
4497 pVBInfo->NewFlickerMode = 0x40;
4498 else if (resinfo == 0x09)
4499 pVBInfo->NewFlickerMode = 0x40;
4500 else if (resinfo == 0x12)
4501 pVBInfo->NewFlickerMode = 0x40;
4502
4503 if (pVBInfo->VGAVDE == 350)
4504 pVBInfo->TVInfo |= TVSimuMode;
4505
4506 tempax = ExtHiTVHT;
4507 tempbx = ExtHiTVVT;
4508
4509 if (pVBInfo->VBInfo & SetInSlaveMode) {
4510 if (pVBInfo->TVInfo & TVSimuMode) {
4511 tempax = StHiTVHT;
4512 tempbx = StHiTVVT;
4513
4514 if (!(modeflag & Charx8Dot)) {
4515 tempax = StHiTextTVHT;
4516 tempbx = StHiTextTVVT;
4517 }
4518 }
4519 }
4520 } else if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
4521 if (pVBInfo->TVInfo & SetYPbPrMode750p) {
4522 tempax = YPbPrTV750pHT; /* Ext750pTVHT */
4523 tempbx = YPbPrTV750pVT; /* Ext750pTVVT */
4524 }
4525
4526 if (pVBInfo->TVInfo & SetYPbPrMode525p) {
4527 tempax = YPbPrTV525pHT; /* Ext525pTVHT */
4528 tempbx = YPbPrTV525pVT; /* Ext525pTVVT */
4529 } else if (pVBInfo->TVInfo & SetYPbPrMode525i) {
4530 tempax = YPbPrTV525iHT; /* Ext525iTVHT */
4531 tempbx = YPbPrTV525iVT; /* Ext525iTVVT */
4532 if (pVBInfo->TVInfo & NTSC1024x768)
4533 tempax = NTSC1024x768HT;
4534 }
4535 } else {
4536 tempax = PALHT;
4537 tempbx = PALVT;
4538 if (!(pVBInfo->TVInfo & SetPALTV)) {
4539 tempax = NTSCHT;
4540 tempbx = NTSCVT;
4541 if (pVBInfo->TVInfo & NTSC1024x768)
4542 tempax = NTSC1024x768HT;
4543 }
4544 }
4545
4546 pVBInfo->HT = tempax;
4547 pVBInfo->VT = tempbx;
4548 return;
4549 }
4550 }
4551
XGI_SetCRT2VCLK(unsigned short ModeNo,unsigned short ModeIdIndex,unsigned short RefreshRateTableIndex,struct vb_device_info * pVBInfo)4552 static void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex,
4553 unsigned short RefreshRateTableIndex,
4554 struct vb_device_info *pVBInfo)
4555 {
4556 unsigned char di_0, di_1, tempal;
4557
4558 tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex,
4559 pVBInfo);
4560 XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo);
4561 XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo);
4562
4563 if (pVBInfo->VBType & VB_XGI301) { /* shampoo 0129 */
4564 /* 301 */
4565 xgifb_reg_set(pVBInfo->Part4Port, 0x0A, 0x10);
4566 xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1);
4567 xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0);
4568 } else { /* 301b/302b/301lv/302lv */
4569 xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0);
4570 xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1);
4571 }
4572
4573 xgifb_reg_set(pVBInfo->Part4Port, 0x00, 0x12);
4574
4575 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC)
4576 xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x28);
4577 else
4578 xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x08);
4579 }
4580
XGI_GetColorDepth(unsigned short ModeNo,unsigned short ModeIdIndex,struct vb_device_info * pVBInfo)4581 static unsigned short XGI_GetColorDepth(unsigned short ModeNo,
4582 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
4583 {
4584 unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8 };
4585 short index;
4586 unsigned short modeflag;
4587
4588 if (ModeNo <= 0x13)
4589 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
4590 else
4591 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4592
4593 index = (modeflag & ModeInfoFlag) - ModeEGA;
4594
4595 if (index < 0)
4596 index = 0;
4597
4598 return ColorDepth[index];
4599 }
4600
XGI_GetOffset(unsigned short ModeNo,unsigned short ModeIdIndex,unsigned short RefreshRateTableIndex,struct xgi_hw_device_info * HwDeviceExtension,struct vb_device_info * pVBInfo)4601 static unsigned short XGI_GetOffset(unsigned short ModeNo, unsigned short ModeIdIndex,
4602 unsigned short RefreshRateTableIndex,
4603 struct xgi_hw_device_info *HwDeviceExtension,
4604 struct vb_device_info *pVBInfo)
4605 {
4606 unsigned short temp, colordepth, modeinfo, index, infoflag,
4607 ColorDepth[] = { 0x01, 0x02, 0x04 };
4608
4609 modeinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo;
4610 if (ModeNo <= 0x14)
4611 infoflag = 0;
4612 else
4613 infoflag = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
4614
4615 index = (modeinfo >> 8) & 0xFF;
4616
4617 temp = pVBInfo->ScreenOffset[index];
4618
4619 if (infoflag & InterlaceMode)
4620 temp = temp << 1;
4621
4622 colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo);
4623
4624 if ((ModeNo >= 0x7C) && (ModeNo <= 0x7E)) {
4625 temp = ModeNo - 0x7C;
4626 colordepth = ColorDepth[temp];
4627 temp = 0x6B;
4628 if (infoflag & InterlaceMode)
4629 temp = temp << 1;
4630 return temp * colordepth;
4631 } else {
4632 return temp * colordepth;
4633 }
4634 }
4635
XGI_SetCRT2Offset(unsigned short ModeNo,unsigned short ModeIdIndex,unsigned short RefreshRateTableIndex,struct xgi_hw_device_info * HwDeviceExtension,struct vb_device_info * pVBInfo)4636 static void XGI_SetCRT2Offset(unsigned short ModeNo,
4637 unsigned short ModeIdIndex,
4638 unsigned short RefreshRateTableIndex,
4639 struct xgi_hw_device_info *HwDeviceExtension,
4640 struct vb_device_info *pVBInfo)
4641 {
4642 unsigned short offset;
4643 unsigned char temp;
4644
4645 if (pVBInfo->VBInfo & SetInSlaveMode)
4646 return;
4647
4648 offset = XGI_GetOffset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
4649 HwDeviceExtension, pVBInfo);
4650 temp = (unsigned char) (offset & 0xFF);
4651 xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp);
4652 temp = (unsigned char) ((offset & 0xFF00) >> 8);
4653 xgifb_reg_set(pVBInfo->Part1Port, 0x09, temp);
4654 temp = (unsigned char) (((offset >> 3) & 0xFF) + 1);
4655 xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp);
4656 }
4657
XGI_SetCRT2FIFO(struct vb_device_info * pVBInfo)4658 static void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo)
4659 {
4660 xgifb_reg_set(pVBInfo->Part1Port, 0x01, 0x3B); /* threshold high ,disable auto threshold */
4661 xgifb_reg_and_or(pVBInfo->Part1Port, 0x02, ~(0x3F), 0x04); /* threshold low default 04h */
4662 }
4663
XGI_PreSetGroup1(unsigned short ModeNo,unsigned short ModeIdIndex,struct xgi_hw_device_info * HwDeviceExtension,unsigned short RefreshRateTableIndex,struct vb_device_info * pVBInfo)4664 static void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
4665 struct xgi_hw_device_info *HwDeviceExtension,
4666 unsigned short RefreshRateTableIndex,
4667 struct vb_device_info *pVBInfo)
4668 {
4669 unsigned short tempcx = 0, CRT1Index = 0, resinfo = 0;
4670
4671 if (ModeNo > 0x13) {
4672 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4673 CRT1Index &= IndexMask;
4674 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4675 }
4676
4677 XGI_SetCRT2Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
4678 HwDeviceExtension, pVBInfo);
4679 XGI_SetCRT2FIFO(pVBInfo);
4680 /* XGI_SetCRT2Sync(ModeNo,RefreshRateTableIndex); */
4681
4682 for (tempcx = 4; tempcx < 7; tempcx++)
4683 xgifb_reg_set(pVBInfo->Part1Port, tempcx, 0x0);
4684
4685 xgifb_reg_set(pVBInfo->Part1Port, 0x50, 0x00);
4686 xgifb_reg_set(pVBInfo->Part1Port, 0x02, 0x44); /* temp 0206 */
4687 }
4688
XGI_SetGroup1(unsigned short ModeNo,unsigned short ModeIdIndex,struct xgi_hw_device_info * HwDeviceExtension,unsigned short RefreshRateTableIndex,struct vb_device_info * pVBInfo)4689 static void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
4690 struct xgi_hw_device_info *HwDeviceExtension,
4691 unsigned short RefreshRateTableIndex,
4692 struct vb_device_info *pVBInfo)
4693 {
4694 unsigned short temp = 0, tempax = 0, tempbx = 0, tempcx = 0,
4695 pushbx = 0, CRT1Index = 0, modeflag, resinfo = 0;
4696
4697 if (ModeNo > 0x13) {
4698 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4699 CRT1Index &= IndexMask;
4700 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4701 }
4702
4703 if (ModeNo <= 0x13)
4704 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
4705 else
4706 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
4707
4708 /* bainy change table name */
4709 if (modeflag & HalfDCLK) {
4710 temp = (pVBInfo->VGAHT / 2 - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */
4711 xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp);
4712 temp = (((pVBInfo->VGAHT / 2 - 1) & 0xFF00) >> 8) << 4;
4713 xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp);
4714 temp = (pVBInfo->VGAHDE / 2 + 16) & 0x0FF; /* BTVGA2HDEE 0x0A,0x0C */
4715 xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp);
4716 tempcx = ((pVBInfo->VGAHT - pVBInfo->VGAHDE) / 2) >> 2;
4717 pushbx = pVBInfo->VGAHDE / 2 + 16;
4718 tempcx = tempcx >> 1;
4719 tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */
4720 tempcx += tempbx;
4721
4722 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
4723 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4];
4724 tempbx |= ((pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14]
4725 & 0xC0) << 2);
4726 tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */
4727 tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5];
4728 tempcx &= 0x1F;
4729 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[15];
4730 temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */
4731 tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */
4732 }
4733
4734 tempbx += 4;
4735 tempcx += 4;
4736
4737 if (tempcx > (pVBInfo->VGAHT / 2))
4738 tempcx = pVBInfo->VGAHT / 2;
4739
4740 temp = tempbx & 0x00FF;
4741
4742 xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp);
4743 } else {
4744 temp = (pVBInfo->VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */
4745 xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp);
4746 temp = (((pVBInfo->VGAHT - 1) & 0xFF00) >> 8) << 4;
4747 xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp);
4748 temp = (pVBInfo->VGAHDE + 16) & 0x0FF; /* BTVGA2HDEE 0x0A,0x0C */
4749 xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp);
4750 tempcx = (pVBInfo->VGAHT - pVBInfo->VGAHDE) >> 2; /* cx */
4751 pushbx = pVBInfo->VGAHDE + 16;
4752 tempcx = tempcx >> 1;
4753 tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */
4754 tempcx += tempbx;
4755
4756 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
4757 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[3];
4758 tempbx |= ((pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5]
4759 & 0xC0) << 2);
4760 tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */
4761 tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4];
4762 tempcx &= 0x1F;
4763 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[6];
4764 temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */
4765 tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */
4766 tempbx += 16;
4767 tempcx += 16;
4768 }
4769
4770 if (tempcx > pVBInfo->VGAHT)
4771 tempcx = pVBInfo->VGAHT;
4772
4773 temp = tempbx & 0x00FF;
4774 xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp);
4775 }
4776
4777 tempax = (tempax & 0x00FF) | (tempbx & 0xFF00);
4778 tempbx = pushbx;
4779 tempbx = (tempbx & 0x00FF) | ((tempbx & 0xFF00) << 4);
4780 tempax |= (tempbx & 0xFF00);
4781 temp = (tempax & 0xFF00) >> 8;
4782 xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp);
4783 temp = tempcx & 0x00FF;
4784 xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp);
4785 tempcx = (pVBInfo->VGAVT - 1);
4786 temp = tempcx & 0x00FF;
4787
4788 if (pVBInfo->IF_DEF_CH7005 == 1) {
4789 if (pVBInfo->VBInfo & 0x0C)
4790 temp--;
4791 }
4792
4793 xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp);
4794 tempbx = pVBInfo->VGAVDE - 1;
4795 temp = tempbx & 0x00FF;
4796 xgifb_reg_set(pVBInfo->Part1Port, 0x0F, temp);
4797 temp = ((tempbx & 0xFF00) << 3) >> 8;
4798 temp |= ((tempcx & 0xFF00) >> 8);
4799 xgifb_reg_set(pVBInfo->Part1Port, 0x12, temp);
4800
4801 tempax = pVBInfo->VGAVDE;
4802 tempbx = pVBInfo->VGAVDE;
4803 tempcx = pVBInfo->VGAVT;
4804 tempbx = (pVBInfo->VGAVT + pVBInfo->VGAVDE) >> 1; /* BTVGA2VRS 0x10,0x11 */
4805 tempcx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) >> 4) + tempbx + 1; /* BTVGA2VRE 0x11 */
4806
4807 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) {
4808 tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[10];
4809 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9];
4810
4811 if (temp & 0x04)
4812 tempbx |= 0x0100;
4813
4814 if (temp & 0x080)
4815 tempbx |= 0x0200;
4816
4817 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14];
4818
4819 if (temp & 0x08)
4820 tempbx |= 0x0400;
4821
4822 temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[11];
4823 tempcx = (tempcx & 0xFF00) | (temp & 0x00FF);
4824 }
4825
4826 temp = tempbx & 0x00FF;
4827 xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp);
4828 temp = ((tempbx & 0xFF00) >> 8) << 4;
4829 temp = ((tempcx & 0x000F) | (temp));
4830 xgifb_reg_set(pVBInfo->Part1Port, 0x11, temp);
4831 tempax = 0;
4832
4833 if (modeflag & DoubleScanMode)
4834 tempax |= 0x80;
4835
4836 if (modeflag & HalfDCLK)
4837 tempax |= 0x40;
4838
4839 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2C, ~0x0C0, tempax);
4840 }
4841
XGI_GetVGAHT2(struct vb_device_info * pVBInfo)4842 static unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo)
4843 {
4844 unsigned long tempax, tempbx;
4845
4846 tempbx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) * pVBInfo->RVBHCMAX)
4847 & 0xFFFF;
4848 tempax = (pVBInfo->VT - pVBInfo->VDE) * pVBInfo->RVBHCFACT;
4849 tempax = (tempax * pVBInfo->HT) / tempbx;
4850
4851 return (unsigned short) tempax;
4852 }
4853
XGI_SetLockRegs(unsigned short ModeNo,unsigned short ModeIdIndex,struct xgi_hw_device_info * HwDeviceExtension,unsigned short RefreshRateTableIndex,struct vb_device_info * pVBInfo)4854 static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
4855 struct xgi_hw_device_info *HwDeviceExtension,
4856 unsigned short RefreshRateTableIndex,
4857 struct vb_device_info *pVBInfo)
4858 {
4859 unsigned short push1, push2, tempax, tempbx = 0, tempcx, temp, resinfo,
4860 modeflag, CRT1Index;
4861
4862 if (ModeNo <= 0x13) {
4863 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
4864 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
4865 } else {
4866 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
4867 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
4868 CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
4869 CRT1Index &= IndexMask;
4870 }
4871
4872 if (!(pVBInfo->VBInfo & SetInSlaveMode))
4873 return;
4874
4875 temp = 0xFF; /* set MAX HT */
4876 xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp);
4877 /* if (modeflag & Charx8Dot) */
4878 /* tempcx = 0x08; */
4879 /* else */
4880 tempcx = 0x08;
4881
4882 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C))
4883 modeflag |= Charx8Dot;
4884
4885 tempax = pVBInfo->VGAHDE; /* 0x04 Horizontal Display End */
4886
4887 if (modeflag & HalfDCLK)
4888 tempax = tempax >> 1;
4889
4890 tempax = (tempax / tempcx) - 1;
4891 tempbx |= ((tempax & 0x00FF) << 8);
4892 temp = tempax & 0x00FF;
4893 xgifb_reg_set(pVBInfo->Part1Port, 0x04, temp);
4894
4895 temp = (tempbx & 0xFF00) >> 8;
4896
4897 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4898 if (!(pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
4899 | VB_XGI302LV | VB_XGI301C)))
4900 temp += 2;
4901
4902 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4903 if (pVBInfo->VBType & VB_XGI301LV) {
4904 if (pVBInfo->VBExtInfo == VB_YPbPr1080i) {
4905 if (resinfo == 7)
4906 temp -= 2;
4907 }
4908 } else if (resinfo == 7) {
4909 temp -= 2;
4910 }
4911 }
4912 }
4913
4914 xgifb_reg_set(pVBInfo->Part1Port, 0x05, temp); /* 0x05 Horizontal Display Start */
4915 xgifb_reg_set(pVBInfo->Part1Port, 0x06, 0x03); /* 0x06 Horizontal Blank end */
4916
4917 if (!(pVBInfo->VBInfo & DisableCRT2Display)) { /* 030226 bainy */
4918 if (pVBInfo->VBInfo & SetCRT2ToTV)
4919 tempax = pVBInfo->VGAHT;
4920 else
4921 tempax = XGI_GetVGAHT2(pVBInfo);
4922 }
4923
4924 if (tempax >= pVBInfo->VGAHT)
4925 tempax = pVBInfo->VGAHT;
4926
4927 if (modeflag & HalfDCLK)
4928 tempax = tempax >> 1;
4929
4930 tempax = (tempax / tempcx) - 5;
4931 tempcx = tempax; /* 20030401 0x07 horizontal Retrace Start */
4932 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
4933 temp = (tempbx & 0x00FF) - 1;
4934 if (!(modeflag & HalfDCLK)) {
4935 temp -= 6;
4936 if (pVBInfo->TVInfo & TVSimuMode) {
4937 temp -= 4;
4938 if (ModeNo > 0x13)
4939 temp -= 10;
4940 }
4941 }
4942 } else {
4943 /* tempcx = tempbx & 0x00FF ; */
4944 tempbx = (tempbx & 0xFF00) >> 8;
4945 tempcx = (tempcx + tempbx) >> 1;
4946 temp = (tempcx & 0x00FF) + 2;
4947
4948 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4949 temp -= 1;
4950 if (!(modeflag & HalfDCLK)) {
4951 if ((modeflag & Charx8Dot)) {
4952 temp += 4;
4953 if (pVBInfo->VGAHDE >= 800)
4954 temp -= 6;
4955 }
4956 }
4957 } else {
4958 if (!(modeflag & HalfDCLK)) {
4959 temp -= 4;
4960 if (pVBInfo->LCDResInfo != Panel1280x960) {
4961 if (pVBInfo->VGAHDE >= 800) {
4962 temp -= 7;
4963 if (pVBInfo->ModeType
4964 == ModeEGA) {
4965 if (pVBInfo->VGAVDE
4966 == 1024) {
4967 temp += 15;
4968 if (pVBInfo->LCDResInfo
4969 != Panel1280x1024) {
4970 temp
4971 += 7;
4972 }
4973 }
4974 }
4975
4976 if (pVBInfo->VGAHDE >= 1280) {
4977 if (pVBInfo->LCDResInfo
4978 != Panel1280x960) {
4979 if (pVBInfo->LCDInfo
4980 & LCDNonExpanding) {
4981 temp
4982 += 28;
4983 }
4984 }
4985 }
4986 }
4987 }
4988 }
4989 }
4990 }
4991
4992 xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp); /* 0x07 Horizontal Retrace Start */
4993 xgifb_reg_set(pVBInfo->Part1Port, 0x08, 0); /* 0x08 Horizontal Retrace End */
4994
4995 if (pVBInfo->VBInfo & SetCRT2ToTV) {
4996 if (pVBInfo->TVInfo & TVSimuMode) {
4997 if ((ModeNo == 0x06) || (ModeNo == 0x10) || (ModeNo
4998 == 0x11) || (ModeNo == 0x13) || (ModeNo
4999 == 0x0F)) {
5000 xgifb_reg_set(pVBInfo->Part1Port, 0x07, 0x5b);
5001 xgifb_reg_set(pVBInfo->Part1Port, 0x08, 0x03);
5002 }
5003
5004 if ((ModeNo == 0x00) || (ModeNo == 0x01)) {
5005 if (pVBInfo->TVInfo & SetNTSCTV) {
5006 xgifb_reg_set(pVBInfo->Part1Port,
5007 0x07, 0x2A);
5008 xgifb_reg_set(pVBInfo->Part1Port,
5009 0x08, 0x61);
5010 } else {
5011 xgifb_reg_set(pVBInfo->Part1Port,
5012 0x07, 0x2A);
5013 xgifb_reg_set(pVBInfo->Part1Port,
5014 0x08, 0x41);
5015 xgifb_reg_set(pVBInfo->Part1Port,
5016 0x0C, 0xF0);
5017 }
5018 }
5019
5020 if ((ModeNo == 0x02) || (ModeNo == 0x03) || (ModeNo
5021 == 0x07)) {
5022 if (pVBInfo->TVInfo & SetNTSCTV) {
5023 xgifb_reg_set(pVBInfo->Part1Port,
5024 0x07, 0x54);
5025 xgifb_reg_set(pVBInfo->Part1Port,
5026 0x08, 0x00);
5027 } else {
5028 xgifb_reg_set(pVBInfo->Part1Port,
5029 0x07, 0x55);
5030 xgifb_reg_set(pVBInfo->Part1Port,
5031 0x08, 0x00);
5032 xgifb_reg_set(pVBInfo->Part1Port,
5033 0x0C, 0xF0);
5034 }
5035 }
5036
5037 if ((ModeNo == 0x04) || (ModeNo == 0x05) || (ModeNo
5038 == 0x0D) || (ModeNo == 0x50)) {
5039 if (pVBInfo->TVInfo & SetNTSCTV) {
5040 xgifb_reg_set(pVBInfo->Part1Port,
5041 0x07, 0x30);
5042 xgifb_reg_set(pVBInfo->Part1Port,
5043 0x08, 0x03);
5044 } else {
5045 xgifb_reg_set(pVBInfo->Part1Port,
5046 0x07, 0x2f);
5047 xgifb_reg_set(pVBInfo->Part1Port,
5048 0x08, 0x02);
5049 }
5050 }
5051 }
5052 }
5053
5054 xgifb_reg_set(pVBInfo->Part1Port, 0x18, 0x03); /* 0x18 SR0B */
5055 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0xF0, 0x00);
5056 xgifb_reg_set(pVBInfo->Part1Port, 0x09, 0xFF); /* 0x09 Set Max VT */
5057
5058 tempbx = pVBInfo->VGAVT;
5059 push1 = tempbx;
5060 tempcx = 0x121;
5061 tempbx = pVBInfo->VGAVDE; /* 0x0E Virtical Display End */
5062
5063 if (tempbx == 357)
5064 tempbx = 350;
5065 if (tempbx == 360)
5066 tempbx = 350;
5067 if (tempbx == 375)
5068 tempbx = 350;
5069 if (tempbx == 405)
5070 tempbx = 400;
5071 if (tempbx == 525)
5072 tempbx = 480;
5073
5074 push2 = tempbx;
5075
5076 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
5077 if (pVBInfo->LCDResInfo == Panel1024x768) {
5078 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
5079 if (tempbx == 350)
5080 tempbx += 5;
5081 if (tempbx == 480)
5082 tempbx += 5;
5083 }
5084 }
5085 }
5086 tempbx--;
5087 temp = tempbx & 0x00FF;
5088 tempbx--;
5089 temp = tempbx & 0x00FF;
5090 xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); /* 0x10 vertical Blank Start */
5091 tempbx = push2;
5092 tempbx--;
5093 temp = tempbx & 0x00FF;
5094 xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp);
5095
5096 if (tempbx & 0x0100)
5097 tempcx |= 0x0002;
5098
5099 tempax = 0x000B;
5100
5101 if (modeflag & DoubleScanMode)
5102 tempax |= 0x08000;
5103
5104 if (tempbx & 0x0200)
5105 tempcx |= 0x0040;
5106
5107 temp = (tempax & 0xFF00) >> 8;
5108 xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp);
5109
5110 if (tempbx & 0x0400)
5111 tempcx |= 0x0600;
5112
5113 xgifb_reg_set(pVBInfo->Part1Port, 0x11, 0x00); /* 0x11 Vertival Blank End */
5114
5115 tempax = push1;
5116 tempax -= tempbx; /* 0x0C Vertical Retrace Start */
5117 tempax = tempax >> 2;
5118 push1 = tempax; /* push ax */
5119
5120 if (resinfo != 0x09) {
5121 tempax = tempax << 1;
5122 tempbx += tempax;
5123 }
5124
5125 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5126 if (pVBInfo->VBType & VB_XGI301LV) {
5127 if (pVBInfo->TVInfo & SetYPbPrMode1080i) {
5128 tempbx -= 10;
5129 } else {
5130 if (pVBInfo->TVInfo & TVSimuMode) {
5131 if (pVBInfo->TVInfo & SetPALTV) {
5132 if (pVBInfo->VBType
5133 & VB_XGI301LV) {
5134 if (!(pVBInfo->TVInfo
5135 & (SetYPbPrMode525p
5136 | SetYPbPrMode750p
5137 | SetYPbPrMode1080i)))
5138 tempbx += 40;
5139 } else {
5140 tempbx += 40;
5141 }
5142 }
5143 }
5144 }
5145 } else {
5146 tempbx -= 10;
5147 }
5148 } else {
5149 if (pVBInfo->TVInfo & TVSimuMode) {
5150 if (pVBInfo->TVInfo & SetPALTV) {
5151 if (pVBInfo->VBType & VB_XGI301LV) {
5152 if (!(pVBInfo->TVInfo
5153 & (SetYPbPrMode525p
5154 | SetYPbPrMode750p
5155 | SetYPbPrMode1080i)))
5156 tempbx += 40;
5157 } else {
5158 tempbx += 40;
5159 }
5160 }
5161 }
5162 }
5163 tempax = push1;
5164 tempax = tempax >> 2;
5165 tempax++;
5166 tempax += tempbx;
5167 push1 = tempax; /* push ax */
5168
5169 if ((pVBInfo->TVInfo & SetPALTV)) {
5170 if (tempbx <= 513) {
5171 if (tempax >= 513)
5172 tempbx = 513;
5173 }
5174 }
5175
5176 temp = tempbx & 0x00FF;
5177 xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp);
5178 tempbx--;
5179 temp = tempbx & 0x00FF;
5180 xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp);
5181
5182 if (tempbx & 0x0100)
5183 tempcx |= 0x0008;
5184
5185 if (tempbx & 0x0200)
5186 xgifb_reg_and_or(pVBInfo->Part1Port, 0x0B, 0x0FF, 0x20);
5187
5188 tempbx++;
5189
5190 if (tempbx & 0x0100)
5191 tempcx |= 0x0004;
5192
5193 if (tempbx & 0x0200)
5194 tempcx |= 0x0080;
5195
5196 if (tempbx & 0x0400)
5197 tempcx |= 0x0C00;
5198
5199 tempbx = push1; /* pop ax */
5200 temp = tempbx & 0x00FF;
5201 temp &= 0x0F;
5202 xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp); /* 0x0D vertical Retrace End */
5203
5204 if (tempbx & 0x0010)
5205 tempcx |= 0x2000;
5206
5207 temp = tempcx & 0x00FF;
5208 xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); /* 0x0A CR07 */
5209 temp = (tempcx & 0x0FF00) >> 8;
5210 xgifb_reg_set(pVBInfo->Part1Port, 0x17, temp); /* 0x17 SR0A */
5211 tempax = modeflag;
5212 temp = (tempax & 0xFF00) >> 8;
5213
5214 temp = (temp >> 1) & 0x09;
5215
5216 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C))
5217 temp |= 0x01;
5218
5219 xgifb_reg_set(pVBInfo->Part1Port, 0x16, temp); /* 0x16 SR01 */
5220 xgifb_reg_set(pVBInfo->Part1Port, 0x0F, 0); /* 0x0F CR14 */
5221 xgifb_reg_set(pVBInfo->Part1Port, 0x12, 0); /* 0x12 CR17 */
5222
5223 if (pVBInfo->LCDInfo & LCDRGB18Bit)
5224 temp = 0x80;
5225 else
5226 temp = 0x00;
5227
5228 xgifb_reg_set(pVBInfo->Part1Port, 0x1A, temp); /* 0x1A SR0E */
5229
5230 return;
5231 }
5232
XGI_SetGroup2(unsigned short ModeNo,unsigned short ModeIdIndex,unsigned short RefreshRateTableIndex,struct xgi_hw_device_info * HwDeviceExtension,struct vb_device_info * pVBInfo)5233 static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex,
5234 unsigned short RefreshRateTableIndex,
5235 struct xgi_hw_device_info *HwDeviceExtension,
5236 struct vb_device_info *pVBInfo)
5237 {
5238 unsigned short i, j, tempax, tempbx, tempcx, temp, push1, push2,
5239 modeflag, resinfo, crt2crtc;
5240 unsigned char *TimingPoint;
5241
5242 unsigned long longtemp, tempeax, tempebx, temp2, tempecx;
5243
5244 if (ModeNo <= 0x13) {
5245 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
5246 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
5247 crt2crtc = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
5248 } else {
5249 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
5250 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
5251 crt2crtc
5252 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
5253 }
5254
5255 tempax = 0;
5256
5257 if (!(pVBInfo->VBInfo & SetCRT2ToAVIDEO))
5258 tempax |= 0x0800;
5259
5260 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
5261 tempax |= 0x0400;
5262
5263 if (pVBInfo->VBInfo & SetCRT2ToSCART)
5264 tempax |= 0x0200;
5265
5266 if (!(pVBInfo->TVInfo & SetPALTV))
5267 tempax |= 0x1000;
5268
5269 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5270 tempax |= 0x0100;
5271
5272 if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))
5273 tempax &= 0xfe00;
5274
5275 tempax = (tempax & 0xff00) >> 8;
5276
5277 xgifb_reg_set(pVBInfo->Part2Port, 0x0, tempax);
5278 TimingPoint = pVBInfo->NTSCTiming;
5279
5280 if (pVBInfo->TVInfo & SetPALTV)
5281 TimingPoint = pVBInfo->PALTiming;
5282
5283 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5284 TimingPoint = pVBInfo->HiTVExtTiming;
5285
5286 if (pVBInfo->VBInfo & SetInSlaveMode)
5287 TimingPoint = pVBInfo->HiTVSt2Timing;
5288
5289 if (pVBInfo->SetFlag & TVSimuMode)
5290 TimingPoint = pVBInfo->HiTVSt1Timing;
5291
5292 if (!(modeflag & Charx8Dot))
5293 TimingPoint = pVBInfo->HiTVTextTiming;
5294 }
5295
5296 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
5297 if (pVBInfo->TVInfo & SetYPbPrMode525i)
5298 TimingPoint = pVBInfo->YPbPr525iTiming;
5299
5300 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5301 TimingPoint = pVBInfo->YPbPr525pTiming;
5302
5303 if (pVBInfo->TVInfo & SetYPbPrMode750p)
5304 TimingPoint = pVBInfo->YPbPr750pTiming;
5305 }
5306
5307 for (i = 0x01, j = 0; i <= 0x2D; i++, j++)
5308 xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]);
5309
5310 for (i = 0x39; i <= 0x45; i++, j++)
5311 xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]); /* di->temp2[j] */
5312
5313 if (pVBInfo->VBInfo & SetCRT2ToTV)
5314 xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, 0x00);
5315
5316 temp = pVBInfo->NewFlickerMode;
5317 temp &= 0x80;
5318 xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xFF, temp);
5319
5320 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5321 tempax = 950;
5322
5323 if (pVBInfo->TVInfo & SetPALTV)
5324 tempax = 520;
5325 else
5326 tempax = 440;
5327
5328 if (pVBInfo->VDE <= tempax) {
5329 tempax -= pVBInfo->VDE;
5330 tempax = tempax >> 2;
5331 tempax = (tempax & 0x00FF) | ((tempax & 0x00FF) << 8);
5332 push1 = tempax;
5333 temp = (tempax & 0xFF00) >> 8;
5334 temp += (unsigned short) TimingPoint[0];
5335
5336 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5337 | VB_XGI302LV | VB_XGI301C)) {
5338 if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO
5339 | SetCRT2ToSVIDEO | SetCRT2ToSCART
5340 | SetCRT2ToYPbPr)) {
5341 tempcx = pVBInfo->VGAHDE;
5342 if (tempcx >= 1024) {
5343 temp = 0x17; /* NTSC */
5344 if (pVBInfo->TVInfo & SetPALTV)
5345 temp = 0x19; /* PAL */
5346 }
5347 }
5348 }
5349
5350 xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp);
5351 tempax = push1;
5352 temp = (tempax & 0xFF00) >> 8;
5353 temp += TimingPoint[1];
5354
5355 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5356 | VB_XGI302LV | VB_XGI301C)) {
5357 if ((pVBInfo->VBInfo & (SetCRT2ToAVIDEO
5358 | SetCRT2ToSVIDEO | SetCRT2ToSCART
5359 | SetCRT2ToYPbPr))) {
5360 tempcx = pVBInfo->VGAHDE;
5361 if (tempcx >= 1024) {
5362 temp = 0x1D; /* NTSC */
5363 if (pVBInfo->TVInfo & SetPALTV)
5364 temp = 0x52; /* PAL */
5365 }
5366 }
5367 }
5368 xgifb_reg_set(pVBInfo->Part2Port, 0x02, temp);
5369 }
5370
5371 /* 301b */
5372 tempcx = pVBInfo->HT;
5373
5374 if (XGI_IsLCDDualLink(pVBInfo))
5375 tempcx = tempcx >> 1;
5376
5377 tempcx -= 2;
5378 temp = tempcx & 0x00FF;
5379 xgifb_reg_set(pVBInfo->Part2Port, 0x1B, temp);
5380
5381 temp = (tempcx & 0xFF00) >> 8;
5382 xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F, temp);
5383
5384 tempcx = pVBInfo->HT >> 1;
5385 push1 = tempcx; /* push cx */
5386 tempcx += 7;
5387
5388 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5389 tempcx -= 4;
5390
5391 temp = tempcx & 0x00FF;
5392 temp = temp << 4;
5393 xgifb_reg_and_or(pVBInfo->Part2Port, 0x22, 0x0F, temp);
5394
5395 tempbx = TimingPoint[j] | ((TimingPoint[j + 1]) << 8);
5396 tempbx += tempcx;
5397 push2 = tempbx;
5398 temp = tempbx & 0x00FF;
5399 xgifb_reg_set(pVBInfo->Part2Port, 0x24, temp);
5400 temp = (tempbx & 0xFF00) >> 8;
5401 temp = temp << 4;
5402 xgifb_reg_and_or(pVBInfo->Part2Port, 0x25, 0x0F, temp);
5403
5404 tempbx = push2;
5405 tempbx = tempbx + 8;
5406 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5407 tempbx = tempbx - 4;
5408 tempcx = tempbx;
5409 }
5410
5411 temp = (tempbx & 0x00FF) << 4;
5412 xgifb_reg_and_or(pVBInfo->Part2Port, 0x29, 0x0F, temp);
5413
5414 j += 2;
5415 tempcx += (TimingPoint[j] | ((TimingPoint[j + 1]) << 8));
5416 temp = tempcx & 0x00FF;
5417 xgifb_reg_set(pVBInfo->Part2Port, 0x27, temp);
5418 temp = ((tempcx & 0xFF00) >> 8) << 4;
5419 xgifb_reg_and_or(pVBInfo->Part2Port, 0x28, 0x0F, temp);
5420
5421 tempcx += 8;
5422 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5423 tempcx -= 4;
5424
5425 temp = tempcx & 0xFF;
5426 temp = temp << 4;
5427 xgifb_reg_and_or(pVBInfo->Part2Port, 0x2A, 0x0F, temp);
5428
5429 tempcx = push1; /* pop cx */
5430 j += 2;
5431 temp = TimingPoint[j] | ((TimingPoint[j + 1]) << 8);
5432 tempcx -= temp;
5433 temp = tempcx & 0x00FF;
5434 temp = temp << 4;
5435 xgifb_reg_and_or(pVBInfo->Part2Port, 0x2D, 0x0F, temp);
5436
5437 tempcx -= 11;
5438
5439 if (!(pVBInfo->VBInfo & SetCRT2ToTV)) {
5440 tempax = XGI_GetVGAHT2(pVBInfo);
5441 tempcx = tempax - 1;
5442 }
5443 temp = tempcx & 0x00FF;
5444 xgifb_reg_set(pVBInfo->Part2Port, 0x2E, temp);
5445
5446 tempbx = pVBInfo->VDE;
5447
5448 if (pVBInfo->VGAVDE == 360)
5449 tempbx = 746;
5450 if (pVBInfo->VGAVDE == 375)
5451 tempbx = 746;
5452 if (pVBInfo->VGAVDE == 405)
5453 tempbx = 853;
5454
5455 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5456 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) {
5457 if (!(pVBInfo->TVInfo & (SetYPbPrMode525p
5458 | SetYPbPrMode750p)))
5459 tempbx = tempbx >> 1;
5460 } else
5461 tempbx = tempbx >> 1;
5462 }
5463
5464 tempbx -= 2;
5465 temp = tempbx & 0x00FF;
5466
5467 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5468 if (pVBInfo->VBType & VB_XGI301LV) {
5469 if (pVBInfo->TVInfo & SetYPbPrMode1080i) {
5470 if (pVBInfo->VBInfo & SetInSlaveMode) {
5471 if (ModeNo == 0x2f)
5472 temp += 1;
5473 }
5474 }
5475 } else {
5476 if (pVBInfo->VBInfo & SetInSlaveMode) {
5477 if (ModeNo == 0x2f)
5478 temp += 1;
5479 }
5480 }
5481 }
5482
5483 xgifb_reg_set(pVBInfo->Part2Port, 0x2F, temp);
5484
5485 temp = (tempcx & 0xFF00) >> 8;
5486 temp |= ((tempbx & 0xFF00) >> 8) << 6;
5487
5488 if (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)) {
5489 if (pVBInfo->VBType & VB_XGI301LV) {
5490 if (pVBInfo->TVInfo & SetYPbPrMode1080i) {
5491 temp |= 0x10;
5492
5493 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
5494 temp |= 0x20;
5495 }
5496 } else {
5497 temp |= 0x10;
5498 if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO))
5499 temp |= 0x20;
5500 }
5501 }
5502
5503 xgifb_reg_set(pVBInfo->Part2Port, 0x30, temp);
5504
5505 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5506 | VB_XGI302LV | VB_XGI301C)) { /* TV gatingno */
5507 tempbx = pVBInfo->VDE;
5508 tempcx = tempbx - 2;
5509
5510 if (pVBInfo->VBInfo & SetCRT2ToTV) {
5511 if (!(pVBInfo->TVInfo & (SetYPbPrMode525p
5512 | SetYPbPrMode750p)))
5513 tempbx = tempbx >> 1;
5514 }
5515
5516 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
5517 temp = 0;
5518 if (tempcx & 0x0400)
5519 temp |= 0x20;
5520
5521 if (tempbx & 0x0400)
5522 temp |= 0x40;
5523
5524 xgifb_reg_set(pVBInfo->Part4Port, 0x10, temp);
5525 }
5526
5527 temp = (((tempbx - 3) & 0x0300) >> 8) << 5;
5528 xgifb_reg_set(pVBInfo->Part2Port, 0x46, temp);
5529 temp = (tempbx - 3) & 0x00FF;
5530 xgifb_reg_set(pVBInfo->Part2Port, 0x47, temp);
5531 }
5532
5533 tempbx = tempbx & 0x00FF;
5534
5535 if (!(modeflag & HalfDCLK)) {
5536 tempcx = pVBInfo->VGAHDE;
5537 if (tempcx >= pVBInfo->HDE) {
5538 tempbx |= 0x2000;
5539 tempax &= 0x00FF;
5540 }
5541 }
5542
5543 tempcx = 0x0101;
5544
5545 if (pVBInfo->VBInfo & SetCRT2ToTV) { /*301b*/
5546 if (pVBInfo->VGAHDE >= 1024) {
5547 tempcx = 0x1920;
5548 if (pVBInfo->VGAHDE >= 1280) {
5549 tempcx = 0x1420;
5550 tempbx = tempbx & 0xDFFF;
5551 }
5552 }
5553 }
5554
5555 if (!(tempbx & 0x2000)) {
5556 if (modeflag & HalfDCLK)
5557 tempcx = (tempcx & 0xFF00) | ((tempcx & 0x00FF) << 1);
5558
5559 push1 = tempbx;
5560 tempeax = pVBInfo->VGAHDE;
5561 tempebx = (tempcx & 0xFF00) >> 8;
5562 longtemp = tempeax * tempebx;
5563 tempecx = tempcx & 0x00FF;
5564 longtemp = longtemp / tempecx;
5565
5566 /* 301b */
5567 tempecx = 8 * 1024;
5568
5569 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5570 | VB_XGI302LV | VB_XGI301C)) {
5571 tempecx = tempecx * 8;
5572 }
5573
5574 longtemp = longtemp * tempecx;
5575 tempecx = pVBInfo->HDE;
5576 temp2 = longtemp % tempecx;
5577 tempeax = longtemp / tempecx;
5578 if (temp2 != 0)
5579 tempeax += 1;
5580
5581 tempax = (unsigned short) tempeax;
5582
5583 /* 301b */
5584 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
5585 | VB_XGI302LV | VB_XGI301C)) {
5586 tempcx = ((tempax & 0xFF00) >> 5) >> 8;
5587 }
5588 /* end 301b */
5589
5590 tempbx = push1;
5591 tempbx = (unsigned short) (((tempeax & 0x0000FF00) & 0x1F00)
5592 | (tempbx & 0x00FF));
5593 tempax = (unsigned short) (((tempeax & 0x000000FF) << 8)
5594 | (tempax & 0x00FF));
5595 temp = (tempax & 0xFF00) >> 8;
5596 } else {
5597 temp = (tempax & 0x00FF) >> 8;
5598 }
5599
5600 xgifb_reg_set(pVBInfo->Part2Port, 0x44, temp);
5601 temp = (tempbx & 0xFF00) >> 8;
5602 xgifb_reg_and_or(pVBInfo->Part2Port, 0x45, ~0x03F, temp);
5603 temp = tempcx & 0x00FF;
5604
5605 if (tempbx & 0x2000)
5606 temp = 0;
5607
5608 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
5609 temp |= 0x18;
5610
5611 xgifb_reg_and_or(pVBInfo->Part2Port, 0x46, ~0x1F, temp);
5612 if (pVBInfo->TVInfo & SetPALTV) {
5613 tempbx = 0x0382;
5614 tempcx = 0x007e;
5615 } else {
5616 tempbx = 0x0369;
5617 tempcx = 0x0061;
5618 }
5619
5620 temp = tempbx & 0x00FF;
5621 xgifb_reg_set(pVBInfo->Part2Port, 0x4b, temp);
5622 temp = tempcx & 0x00FF;
5623 xgifb_reg_set(pVBInfo->Part2Port, 0x4c, temp);
5624
5625 temp = ((tempcx & 0xFF00) >> 8) & 0x03;
5626 temp = temp << 2;
5627 temp |= ((tempbx & 0xFF00) >> 8) & 0x03;
5628
5629 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
5630 temp |= 0x10;
5631
5632 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5633 temp |= 0x20;
5634
5635 if (pVBInfo->TVInfo & SetYPbPrMode750p)
5636 temp |= 0x60;
5637 }
5638
5639 xgifb_reg_set(pVBInfo->Part2Port, 0x4d, temp);
5640 temp = xgifb_reg_get(pVBInfo->Part2Port, 0x43); /* 301b change */
5641 xgifb_reg_set(pVBInfo->Part2Port, 0x43, (unsigned short) (temp - 3));
5642
5643 if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))) {
5644 if (pVBInfo->TVInfo & NTSC1024x768) {
5645 TimingPoint = XGI_NTSC1024AdjTime;
5646 for (i = 0x1c, j = 0; i <= 0x30; i++, j++) {
5647 xgifb_reg_set(pVBInfo->Part2Port, i,
5648 TimingPoint[j]);
5649 }
5650 xgifb_reg_set(pVBInfo->Part2Port, 0x43, 0x72);
5651 }
5652 }
5653
5654 /* [ycchen] 01/14/03 Modify for 301C PALM Support */
5655 if (pVBInfo->VBType & VB_XGI301C) {
5656 if (pVBInfo->TVInfo & SetPALMTV)
5657 xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x08,
5658 0x08); /* PALM Mode */
5659 }
5660
5661 if (pVBInfo->TVInfo & SetPALMTV) {
5662 tempax = (unsigned char) xgifb_reg_get(pVBInfo->Part2Port,
5663 0x01);
5664 tempax--;
5665 xgifb_reg_and(pVBInfo->Part2Port, 0x01, tempax);
5666
5667 /* if ( !( pVBInfo->VBType & VB_XGI301C ) ) */
5668 xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xEF);
5669 }
5670
5671 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) {
5672 if (!(pVBInfo->VBInfo & SetInSlaveMode))
5673 xgifb_reg_set(pVBInfo->Part2Port, 0x0B, 0x00);
5674 }
5675
5676 if (pVBInfo->VBInfo & SetCRT2ToTV)
5677 return;
5678 }
5679
XGI_SetLCDRegs(unsigned short ModeNo,unsigned short ModeIdIndex,struct xgi_hw_device_info * HwDeviceExtension,unsigned short RefreshRateTableIndex,struct vb_device_info * pVBInfo)5680 static void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
5681 struct xgi_hw_device_info *HwDeviceExtension,
5682 unsigned short RefreshRateTableIndex,
5683 struct vb_device_info *pVBInfo)
5684 {
5685 unsigned short push1, push2, pushbx, tempax, tempbx, tempcx, temp,
5686 tempah, tempbh, tempch, resinfo, modeflag, CRT1Index;
5687
5688 struct XGI_LCDDesStruct *LCDBDesPtr = NULL;
5689
5690 if (ModeNo <= 0x13) {
5691 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
5692 resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
5693 } else {
5694 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
5695 resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
5696 CRT1Index
5697 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
5698 CRT1Index &= IndexMask;
5699 }
5700
5701 if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
5702 return;
5703
5704 tempbx = pVBInfo->HDE; /* RHACTE=HDE-1 */
5705
5706 if (XGI_IsLCDDualLink(pVBInfo))
5707 tempbx = tempbx >> 1;
5708
5709 tempbx -= 1;
5710 temp = tempbx & 0x00FF;
5711 xgifb_reg_set(pVBInfo->Part2Port, 0x2C, temp);
5712 temp = (tempbx & 0xFF00) >> 8;
5713 temp = temp << 4;
5714 xgifb_reg_and_or(pVBInfo->Part2Port, 0x2B, 0x0F, temp);
5715 temp = 0x01;
5716
5717 if (pVBInfo->LCDResInfo == Panel1280x1024) {
5718 if (pVBInfo->ModeType == ModeEGA) {
5719 if (pVBInfo->VGAHDE >= 1024) {
5720 temp = 0x02;
5721 if (pVBInfo->LCDInfo & LCDVESATiming)
5722 temp = 0x01;
5723 }
5724 }
5725 }
5726
5727 xgifb_reg_set(pVBInfo->Part2Port, 0x0B, temp);
5728 tempbx = pVBInfo->VDE; /* RTVACTEO=(VDE-1)&0xFF */
5729 push1 = tempbx;
5730 tempbx--;
5731 temp = tempbx & 0x00FF;
5732 xgifb_reg_set(pVBInfo->Part2Port, 0x03, temp);
5733 temp = ((tempbx & 0xFF00) >> 8) & 0x07;
5734 xgifb_reg_and_or(pVBInfo->Part2Port, 0x0C, ~0x07, temp);
5735
5736 tempcx = pVBInfo->VT - 1;
5737 push2 = tempcx + 1;
5738 temp = tempcx & 0x00FF; /* RVTVT=VT-1 */
5739 xgifb_reg_set(pVBInfo->Part2Port, 0x19, temp);
5740 temp = (tempcx & 0xFF00) >> 8;
5741 temp = temp << 5;
5742 xgifb_reg_set(pVBInfo->Part2Port, 0x1A, temp);
5743 xgifb_reg_and_or(pVBInfo->Part2Port, 0x09, 0xF0, 0x00);
5744 xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xF0, 0x00);
5745 xgifb_reg_and_or(pVBInfo->Part2Port, 0x17, 0xFB, 0x00);
5746 xgifb_reg_and_or(pVBInfo->Part2Port, 0x18, 0xDF, 0x00);
5747
5748 /* Customized LCDB Des no add */
5749 tempbx = 5;
5750 LCDBDesPtr = (struct XGI_LCDDesStruct *) XGI_GetLcdPtr(tempbx, ModeNo,
5751 ModeIdIndex, RefreshRateTableIndex, pVBInfo);
5752 tempah = pVBInfo->LCDResInfo;
5753 tempah &= PanelResInfo;
5754
5755 if ((tempah == Panel1024x768) || (tempah == Panel1024x768x75)) {
5756 tempbx = 1024;
5757 tempcx = 768;
5758 } else if ((tempah == Panel1280x1024) || (tempah == Panel1280x1024x75)) {
5759 tempbx = 1280;
5760 tempcx = 1024;
5761 } else if (tempah == Panel1400x1050) {
5762 tempbx = 1400;
5763 tempcx = 1050;
5764 } else {
5765 tempbx = 1600;
5766 tempcx = 1200;
5767 }
5768
5769 if (pVBInfo->LCDInfo & EnableScalingLCD) {
5770 tempbx = pVBInfo->HDE;
5771 tempcx = pVBInfo->VDE;
5772 }
5773
5774 pushbx = tempbx;
5775 tempax = pVBInfo->VT;
5776 pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES;
5777 pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS;
5778 pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES;
5779 pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS;
5780 tempbx = pVBInfo->LCDVDES;
5781 tempcx += tempbx;
5782
5783 if (tempcx >= tempax)
5784 tempcx -= tempax; /* lcdvdes */
5785
5786 temp = tempbx & 0x00FF; /* RVEQ1EQ=lcdvdes */
5787 xgifb_reg_set(pVBInfo->Part2Port, 0x05, temp);
5788 temp = tempcx & 0x00FF;
5789 xgifb_reg_set(pVBInfo->Part2Port, 0x06, temp);
5790 tempch = ((tempcx & 0xFF00) >> 8) & 0x07;
5791 tempbh = ((tempbx & 0xFF00) >> 8) & 0x07;
5792 tempah = tempch;
5793 tempah = tempah << 3;
5794 tempah |= tempbh;
5795 xgifb_reg_set(pVBInfo->Part2Port, 0x02, tempah);
5796
5797 /* getlcdsync() */
5798 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
5799 tempcx = tempbx;
5800 tempax = pVBInfo->VT;
5801 tempbx = pVBInfo->LCDVRS;
5802
5803 /* if (SetLCD_Info & EnableScalingLCD) */
5804 tempcx += tempbx;
5805 if (tempcx >= tempax)
5806 tempcx -= tempax;
5807
5808 temp = tempbx & 0x00FF; /* RTVACTEE=lcdvrs */
5809 xgifb_reg_set(pVBInfo->Part2Port, 0x04, temp);
5810 temp = (tempbx & 0xFF00) >> 8;
5811 temp = temp << 4;
5812 temp |= (tempcx & 0x000F);
5813 xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp);
5814 tempcx = pushbx;
5815 tempax = pVBInfo->HT;
5816 tempbx = pVBInfo->LCDHDES;
5817 tempbx &= 0x0FFF;
5818
5819 if (XGI_IsLCDDualLink(pVBInfo)) {
5820 tempax = tempax >> 1;
5821 tempbx = tempbx >> 1;
5822 tempcx = tempcx >> 1;
5823 }
5824
5825 if (pVBInfo->VBType & VB_XGI302LV)
5826 tempbx += 1;
5827
5828 if (pVBInfo->VBType & VB_XGI301C) /* tap4 */
5829 tempbx += 1;
5830
5831 tempcx += tempbx;
5832
5833 if (tempcx >= tempax)
5834 tempcx -= tempax;
5835
5836 temp = tempbx & 0x00FF;
5837 xgifb_reg_set(pVBInfo->Part2Port, 0x1F, temp); /* RHBLKE=lcdhdes */
5838 temp = ((tempbx & 0xFF00) >> 8) << 4;
5839 xgifb_reg_set(pVBInfo->Part2Port, 0x20, temp);
5840 temp = tempcx & 0x00FF;
5841 xgifb_reg_set(pVBInfo->Part2Port, 0x23, temp); /* RHEQPLE=lcdhdee */
5842 temp = (tempcx & 0xFF00) >> 8;
5843 xgifb_reg_set(pVBInfo->Part2Port, 0x25, temp);
5844
5845 /* getlcdsync() */
5846 XGI_GetLCDSync(&tempax, &tempbx, pVBInfo);
5847 tempcx = tempax;
5848 tempax = pVBInfo->HT;
5849 tempbx = pVBInfo->LCDHRS;
5850 /* if ( SetLCD_Info & EnableScalingLCD) */
5851 if (XGI_IsLCDDualLink(pVBInfo)) {
5852 tempax = tempax >> 1;
5853 tempbx = tempbx >> 1;
5854 tempcx = tempcx >> 1;
5855 }
5856
5857 if (pVBInfo->VBType & VB_XGI302LV)
5858 tempbx += 1;
5859
5860 tempcx += tempbx;
5861
5862 if (tempcx >= tempax)
5863 tempcx -= tempax;
5864
5865 temp = tempbx & 0x00FF; /* RHBURSTS=lcdhrs */
5866 xgifb_reg_set(pVBInfo->Part2Port, 0x1C, temp);
5867
5868 temp = (tempbx & 0xFF00) >> 8;
5869 temp = temp << 4;
5870 xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F0, temp);
5871 temp = tempcx & 0x00FF; /* RHSYEXP2S=lcdhre */
5872 xgifb_reg_set(pVBInfo->Part2Port, 0x21, temp);
5873
5874 if (!(pVBInfo->LCDInfo & LCDVESATiming)) {
5875 if (pVBInfo->VGAVDE == 525) {
5876 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
5877 | VB_XGI301LV | VB_XGI302LV
5878 | VB_XGI301C)) {
5879 temp = 0xC6;
5880 } else
5881 temp = 0xC4;
5882
5883 xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp);
5884 xgifb_reg_set(pVBInfo->Part2Port, 0x30, 0xB3);
5885 }
5886
5887 if (pVBInfo->VGAVDE == 420) {
5888 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
5889 | VB_XGI301LV | VB_XGI302LV
5890 | VB_XGI301C)) {
5891 temp = 0x4F;
5892 } else
5893 temp = 0x4E;
5894 xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp);
5895 }
5896 }
5897 }
5898
5899 /* --------------------------------------------------------------------- */
5900 /* Function : XGI_GetTap4Ptr */
5901 /* Input : */
5902 /* Output : di -> Tap4 Reg. Setting Pointer */
5903 /* Description : */
5904 /* --------------------------------------------------------------------- */
XGI_GetTap4Ptr(unsigned short tempcx,struct vb_device_info * pVBInfo)5905 static struct XGI301C_Tap4TimingStruct *XGI_GetTap4Ptr(unsigned short tempcx,
5906 struct vb_device_info *pVBInfo)
5907 {
5908 unsigned short tempax, tempbx, i;
5909
5910 struct XGI301C_Tap4TimingStruct *Tap4TimingPtr;
5911
5912 if (tempcx == 0) {
5913 tempax = pVBInfo->VGAHDE;
5914 tempbx = pVBInfo->HDE;
5915 } else {
5916 tempax = pVBInfo->VGAVDE;
5917 tempbx = pVBInfo->VDE;
5918 }
5919
5920 if (tempax < tempbx)
5921 return &EnlargeTap4Timing[0];
5922 else if (tempax == tempbx)
5923 return &NoScaleTap4Timing[0]; /* 1:1 */
5924 else
5925 Tap4TimingPtr = NTSCTap4Timing; /* NTSC */
5926
5927 if (pVBInfo->TVInfo & SetPALTV)
5928 Tap4TimingPtr = PALTap4Timing;
5929
5930 if (pVBInfo->VBInfo & SetCRT2ToYPbPr) {
5931 if (pVBInfo->TVInfo & SetYPbPrMode525i)
5932 Tap4TimingPtr = YPbPr525iTap4Timing;
5933 if (pVBInfo->TVInfo & SetYPbPrMode525p)
5934 Tap4TimingPtr = YPbPr525pTap4Timing;
5935 if (pVBInfo->TVInfo & SetYPbPrMode750p)
5936 Tap4TimingPtr = YPbPr750pTap4Timing;
5937 }
5938
5939 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV)
5940 Tap4TimingPtr = HiTVTap4Timing;
5941
5942 i = 0;
5943 while (Tap4TimingPtr[i].DE != 0xFFFF) {
5944 if (Tap4TimingPtr[i].DE == tempax)
5945 break;
5946 i++;
5947 }
5948 return &Tap4TimingPtr[i];
5949 }
5950
XGI_SetTap4Regs(struct vb_device_info * pVBInfo)5951 static void XGI_SetTap4Regs(struct vb_device_info *pVBInfo)
5952 {
5953 unsigned short i, j;
5954
5955 struct XGI301C_Tap4TimingStruct *Tap4TimingPtr;
5956
5957 if (!(pVBInfo->VBType & VB_XGI301C))
5958 return;
5959
5960 #ifndef Tap4
5961 xgifb_reg_and(pVBInfo->Part2Port, 0x4E, 0xEB); /* Disable Tap4 */
5962 #else /* Tap4 Setting */
5963
5964 Tap4TimingPtr = XGI_GetTap4Ptr(0, pVBInfo); /* Set Horizontal Scaling */
5965 for (i = 0x80, j = 0; i <= 0xBF; i++, j++)
5966 xgifb_reg_set(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]);
5967
5968 if ((pVBInfo->VBInfo & SetCRT2ToTV) && (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV))) {
5969 Tap4TimingPtr = XGI_GetTap4Ptr(1, pVBInfo); /* Set Vertical Scaling */
5970 for (i = 0xC0, j = 0; i < 0xFF; i++, j++)
5971 xgifb_reg_set(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]);
5972 }
5973
5974 if ((pVBInfo->VBInfo & SetCRT2ToTV) && (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)))
5975 xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x04); /* Enable V.Scaling */
5976 else
5977 xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x10); /* Enable H.Scaling */
5978 #endif
5979 }
5980
XGI_SetGroup3(unsigned short ModeNo,unsigned short ModeIdIndex,struct vb_device_info * pVBInfo)5981 static void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex,
5982 struct vb_device_info *pVBInfo)
5983 {
5984 unsigned short i;
5985 unsigned char *tempdi;
5986 unsigned short modeflag;
5987
5988 if (ModeNo <= 0x13)
5989 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
5990 else
5991 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
5992
5993 xgifb_reg_set(pVBInfo->Part3Port, 0x00, 0x00);
5994 if (pVBInfo->TVInfo & SetPALTV) {
5995 xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA);
5996 xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8);
5997 } else {
5998 xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xF5);
5999 xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xB7);
6000 }
6001
6002 if (!(pVBInfo->VBInfo & SetCRT2ToTV))
6003 return;
6004
6005 if (pVBInfo->TVInfo & SetPALMTV) {
6006 xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA);
6007 xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8);
6008 xgifb_reg_set(pVBInfo->Part3Port, 0x3D, 0xA8);
6009 }
6010
6011 if ((pVBInfo->VBInfo & SetCRT2ToHiVisionTV) || (pVBInfo->VBInfo
6012 & SetCRT2ToYPbPr)) {
6013 if (pVBInfo->TVInfo & SetYPbPrMode525i)
6014 return;
6015
6016 tempdi = pVBInfo->HiTVGroup3Data;
6017 if (pVBInfo->SetFlag & TVSimuMode) {
6018 tempdi = pVBInfo->HiTVGroup3Simu;
6019 if (!(modeflag & Charx8Dot))
6020 tempdi = pVBInfo->HiTVGroup3Text;
6021 }
6022
6023 if (pVBInfo->TVInfo & SetYPbPrMode525p)
6024 tempdi = pVBInfo->Ren525pGroup3;
6025
6026 if (pVBInfo->TVInfo & SetYPbPrMode750p)
6027 tempdi = pVBInfo->Ren750pGroup3;
6028
6029 for (i = 0; i <= 0x3E; i++)
6030 xgifb_reg_set(pVBInfo->Part3Port, i, tempdi[i]);
6031
6032 if (pVBInfo->VBType & VB_XGI301C) { /* Marcovision */
6033 if (pVBInfo->TVInfo & SetYPbPrMode525p)
6034 xgifb_reg_set(pVBInfo->Part3Port, 0x28, 0x3f);
6035 }
6036 }
6037 return;
6038 } /* {end of XGI_SetGroup3} */
6039
XGI_SetGroup4(unsigned short ModeNo,unsigned short ModeIdIndex,unsigned short RefreshRateTableIndex,struct xgi_hw_device_info * HwDeviceExtension,struct vb_device_info * pVBInfo)6040 static void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex,
6041 unsigned short RefreshRateTableIndex,
6042 struct xgi_hw_device_info *HwDeviceExtension,
6043 struct vb_device_info *pVBInfo)
6044 {
6045 unsigned short tempax, tempcx, tempbx, modeflag, temp, temp2;
6046
6047 unsigned long tempebx, tempeax, templong;
6048
6049 if (ModeNo <= 0x13)
6050 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
6051 else
6052 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+Ext_ResInfo */
6053
6054 temp = pVBInfo->RVBHCFACT;
6055 xgifb_reg_set(pVBInfo->Part4Port, 0x13, temp);
6056
6057 tempbx = pVBInfo->RVBHCMAX;
6058 temp = tempbx & 0x00FF;
6059 xgifb_reg_set(pVBInfo->Part4Port, 0x14, temp);
6060 temp2 = ((tempbx & 0xFF00) >> 8) << 7;
6061 tempcx = pVBInfo->VGAHT - 1;
6062 temp = tempcx & 0x00FF;
6063 xgifb_reg_set(pVBInfo->Part4Port, 0x16, temp);
6064
6065 temp = ((tempcx & 0xFF00) >> 8) << 3;
6066 temp2 |= temp;
6067
6068 tempcx = pVBInfo->VGAVT - 1;
6069 if (!(pVBInfo->VBInfo & SetCRT2ToTV))
6070 tempcx -= 5;
6071
6072 temp = tempcx & 0x00FF;
6073 xgifb_reg_set(pVBInfo->Part4Port, 0x17, temp);
6074 temp = temp2 | ((tempcx & 0xFF00) >> 8);
6075 xgifb_reg_set(pVBInfo->Part4Port, 0x15, temp);
6076 xgifb_reg_or(pVBInfo->Part4Port, 0x0D, 0x08);
6077 tempcx = pVBInfo->VBInfo;
6078 tempbx = pVBInfo->VGAHDE;
6079
6080 if (modeflag & HalfDCLK)
6081 tempbx = tempbx >> 1;
6082
6083 if (XGI_IsLCDDualLink(pVBInfo))
6084 tempbx = tempbx >> 1;
6085
6086 if (tempcx & SetCRT2ToHiVisionTV) {
6087 temp = 0;
6088 if (tempbx <= 1024)
6089 temp = 0xA0;
6090 if (tempbx == 1280)
6091 temp = 0xC0;
6092 } else if (tempcx & SetCRT2ToTV) {
6093 temp = 0xA0;
6094 if (tempbx <= 800)
6095 temp = 0x80;
6096 } else {
6097 temp = 0x80;
6098 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
6099 temp = 0;
6100 if (tempbx > 800)
6101 temp = 0x60;
6102 }
6103 }
6104
6105 if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)) {
6106 temp = 0x00;
6107 if (pVBInfo->VGAHDE == 1280)
6108 temp = 0x40;
6109 if (pVBInfo->VGAHDE == 1024)
6110 temp = 0x20;
6111 }
6112 xgifb_reg_and_or(pVBInfo->Part4Port, 0x0E, ~0xEF, temp);
6113
6114 tempebx = pVBInfo->VDE;
6115
6116 if (tempcx & SetCRT2ToHiVisionTV) {
6117 if (!(temp & 0xE000))
6118 tempbx = tempbx >> 1;
6119 }
6120
6121 tempcx = pVBInfo->RVBHRS;
6122 temp = tempcx & 0x00FF;
6123 xgifb_reg_set(pVBInfo->Part4Port, 0x18, temp);
6124
6125 tempeax = pVBInfo->VGAVDE;
6126 tempcx |= 0x04000;
6127
6128 if (tempeax <= tempebx) {
6129 tempcx = (tempcx & (~0x4000));
6130 tempeax = pVBInfo->VGAVDE;
6131 } else {
6132 tempeax -= tempebx;
6133 }
6134
6135 templong = (tempeax * 256 * 1024) % tempebx;
6136 tempeax = (tempeax * 256 * 1024) / tempebx;
6137 tempebx = tempeax;
6138
6139 if (templong != 0)
6140 tempebx++;
6141
6142 temp = (unsigned short) (tempebx & 0x000000FF);
6143 xgifb_reg_set(pVBInfo->Part4Port, 0x1B, temp);
6144
6145 temp = (unsigned short) ((tempebx & 0x0000FF00) >> 8);
6146 xgifb_reg_set(pVBInfo->Part4Port, 0x1A, temp);
6147 tempbx = (unsigned short) (tempebx >> 16);
6148 temp = tempbx & 0x00FF;
6149 temp = temp << 4;
6150 temp |= ((tempcx & 0xFF00) >> 8);
6151 xgifb_reg_set(pVBInfo->Part4Port, 0x19, temp);
6152
6153 /* 301b */
6154 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
6155 | VB_XGI302LV | VB_XGI301C)) {
6156 temp = 0x0028;
6157 xgifb_reg_set(pVBInfo->Part4Port, 0x1C, temp);
6158 tempax = pVBInfo->VGAHDE;
6159 if (modeflag & HalfDCLK)
6160 tempax = tempax >> 1;
6161
6162 if (XGI_IsLCDDualLink(pVBInfo))
6163 tempax = tempax >> 1;
6164
6165 /* if((pVBInfo->VBInfo&(SetCRT2ToLCD))||((pVBInfo->TVInfo&SetYPbPrMode525p)||(pVBInfo->TVInfo&SetYPbPrMode750p))) { */
6166 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
6167 if (tempax > 800)
6168 tempax -= 800;
6169 } else {
6170 if (pVBInfo->VGAHDE > 800) {
6171 if (pVBInfo->VGAHDE == 1024)
6172 tempax = (tempax * 25 / 32) - 1;
6173 else
6174 tempax = (tempax * 20 / 32) - 1;
6175 }
6176 }
6177 tempax -= 1;
6178
6179 /*
6180 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVisionTV)) {
6181 if (pVBInfo->VBType & VB_XGI301LV) {
6182 if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p | SetYPbPrMode1080i))) {
6183 if (pVBInfo->VGAHDE > 800) {
6184 if (pVBInfo->VGAHDE == 1024)
6185 tempax = (tempax * 25 / 32) - 1;
6186 else
6187 tempax = (tempax * 20 / 32) - 1;
6188 }
6189 }
6190 } else {
6191 if (pVBInfo->VGAHDE > 800) {
6192 if (pVBInfo->VGAHDE == 1024)
6193 tempax = (tempax * 25 / 32) - 1;
6194 else
6195 tempax = (tempax * 20 / 32) - 1;
6196 }
6197 }
6198 }
6199 */
6200
6201 temp = (tempax & 0xFF00) >> 8;
6202 temp = ((temp & 0x0003) << 4);
6203 xgifb_reg_set(pVBInfo->Part4Port, 0x1E, temp);
6204 temp = (tempax & 0x00FF);
6205 xgifb_reg_set(pVBInfo->Part4Port, 0x1D, temp);
6206
6207 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVisionTV)) {
6208 if (pVBInfo->VGAHDE > 800)
6209 xgifb_reg_or(pVBInfo->Part4Port, 0x1E, 0x08);
6210
6211 }
6212 temp = 0x0036;
6213
6214 if (pVBInfo->VBInfo & SetCRT2ToTV) {
6215 if (!(pVBInfo->TVInfo & (NTSC1024x768
6216 | SetYPbPrMode525p | SetYPbPrMode750p
6217 | SetYPbPrMode1080i))) {
6218 temp |= 0x0001;
6219 if ((pVBInfo->VBInfo & SetInSlaveMode)
6220 && (!(pVBInfo->TVInfo
6221 & TVSimuMode)))
6222 temp &= (~0x0001);
6223 }
6224 }
6225
6226 xgifb_reg_and_or(pVBInfo->Part4Port, 0x1F, 0x00C0, temp);
6227 tempbx = pVBInfo->HT;
6228 if (XGI_IsLCDDualLink(pVBInfo))
6229 tempbx = tempbx >> 1;
6230 tempbx = (tempbx >> 1) - 2;
6231 temp = ((tempbx & 0x0700) >> 8) << 3;
6232 xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, 0x00C0, temp);
6233 temp = tempbx & 0x00FF;
6234 xgifb_reg_set(pVBInfo->Part4Port, 0x22, temp);
6235 }
6236 /* end 301b */
6237
6238 if (pVBInfo->ISXPDOS == 0)
6239 XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex,
6240 pVBInfo);
6241 }
6242
XGINew_EnableCRT2(struct vb_device_info * pVBInfo)6243 static void XGINew_EnableCRT2(struct vb_device_info *pVBInfo)
6244 {
6245 xgifb_reg_and_or(pVBInfo->P3c4, 0x1E, 0xFF, 0x20);
6246 }
6247
XGI_SetGroup5(unsigned short ModeNo,unsigned short ModeIdIndex,struct vb_device_info * pVBInfo)6248 static void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex,
6249 struct vb_device_info *pVBInfo)
6250 {
6251 unsigned short Pindex, Pdata;
6252
6253 Pindex = pVBInfo->Part5Port;
6254 Pdata = pVBInfo->Part5Port + 1;
6255 if (pVBInfo->ModeType == ModeVGA) {
6256 if (!(pVBInfo->VBInfo & (SetInSlaveMode | LoadDACFlag
6257 | CRT2DisplayFlag))) {
6258 XGINew_EnableCRT2(pVBInfo);
6259 /* LoadDAC2(pVBInfo->Part5Port, ModeNo, ModeIdIndex); */
6260 }
6261 }
6262 return;
6263 }
6264
XGI_EnableGatingCRT(struct xgi_hw_device_info * HwDeviceExtension,struct vb_device_info * pVBInfo)6265 static void XGI_EnableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension,
6266 struct vb_device_info *pVBInfo)
6267 {
6268 xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x40);
6269 }
6270
XGI_DisableGatingCRT(struct xgi_hw_device_info * HwDeviceExtension,struct vb_device_info * pVBInfo)6271 static void XGI_DisableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension,
6272 struct vb_device_info *pVBInfo)
6273 {
6274
6275 xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x00);
6276 }
6277
6278 /*----------------------------------------------------------------------------*/
6279 /* input */
6280 /* bl[5] : 1;LVDS signal on */
6281 /* bl[1] : 1;LVDS backlight on */
6282 /* bl[0] : 1:LVDS VDD on */
6283 /* bh: 100000b : clear bit 5, to set bit5 */
6284 /* 000010b : clear bit 1, to set bit1 */
6285 /* 000001b : clear bit 0, to set bit0 */
6286 /*----------------------------------------------------------------------------*/
XGI_XG21BLSignalVDD(unsigned short tempbh,unsigned short tempbl,struct vb_device_info * pVBInfo)6287 void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl,
6288 struct vb_device_info *pVBInfo)
6289 {
6290 unsigned char CR4A, temp;
6291
6292 CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
6293 tempbh &= 0x23;
6294 tempbl &= 0x23;
6295 xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */
6296
6297 if (tempbh & 0x20) {
6298 temp = (tempbl >> 4) & 0x02;
6299
6300 xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp); /* CR B4[1] */
6301
6302 }
6303
6304 temp = xgifb_reg_get(pVBInfo->P3d4, 0x48);
6305
6306 temp = XG21GPIODataTransfer(temp);
6307 temp &= ~tempbh;
6308 temp |= tempbl;
6309 xgifb_reg_set(pVBInfo->P3d4, 0x48, temp);
6310 }
6311
XGI_XG27BLSignalVDD(unsigned short tempbh,unsigned short tempbl,struct vb_device_info * pVBInfo)6312 void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl,
6313 struct vb_device_info *pVBInfo)
6314 {
6315 unsigned char CR4A, temp;
6316 unsigned short tempbh0, tempbl0;
6317
6318 tempbh0 = tempbh;
6319 tempbl0 = tempbl;
6320 tempbh0 &= 0x20;
6321 tempbl0 &= 0x20;
6322 tempbh0 >>= 3;
6323 tempbl0 >>= 3;
6324
6325 if (tempbh & 0x20) {
6326 temp = (tempbl >> 4) & 0x02;
6327
6328 xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp); /* CR B4[1] */
6329
6330 }
6331 xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~tempbh0, tempbl0);
6332
6333 CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A);
6334 tempbh &= 0x03;
6335 tempbl &= 0x03;
6336 tempbh <<= 2;
6337 tempbl <<= 2; /* GPIOC,GPIOD */
6338 xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */
6339 xgifb_reg_and_or(pVBInfo->P3d4, 0x48, ~tempbh, tempbl);
6340 }
6341
6342 /* --------------------------------------------------------------------- */
XGI_GetLVDSOEMTableIndex(struct vb_device_info * pVBInfo)6343 unsigned short XGI_GetLVDSOEMTableIndex(struct vb_device_info *pVBInfo)
6344 {
6345 unsigned short index;
6346
6347 index = xgifb_reg_get(pVBInfo->P3d4, 0x36);
6348 if (index < sizeof(XGI21_LCDCapList)
6349 / sizeof(struct XGI21_LVDSCapStruct))
6350 return index;
6351 return 0;
6352 }
6353
6354 /* --------------------------------------------------------------------- */
6355 /* Function : XGI_XG21SetPanelDelay */
6356 /* Input : */
6357 /* Output : */
6358 /* Description : */
6359 /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */
6360 /* : bl : 2 ; T2 : the duration signal on and Vdd on */
6361 /* : bl : 3 ; T3 : the duration between CPL off and signal off */
6362 /* : bl : 4 ; T4 : the duration signal off and Vdd off */
6363 /* --------------------------------------------------------------------- */
XGI_XG21SetPanelDelay(unsigned short tempbl,struct vb_device_info * pVBInfo)6364 void XGI_XG21SetPanelDelay(unsigned short tempbl,
6365 struct vb_device_info *pVBInfo)
6366 {
6367 unsigned short index;
6368
6369 index = XGI_GetLVDSOEMTableIndex(pVBInfo);
6370 if (tempbl == 1)
6371 mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S1);
6372
6373 if (tempbl == 2)
6374 mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S2);
6375
6376 if (tempbl == 3)
6377 mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S3);
6378
6379 if (tempbl == 4)
6380 mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S4);
6381 }
6382
XGI_XG21CheckLVDSMode(unsigned short ModeNo,unsigned short ModeIdIndex,struct vb_device_info * pVBInfo)6383 unsigned char XGI_XG21CheckLVDSMode(unsigned short ModeNo,
6384 unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
6385 {
6386 unsigned short xres, yres, colordepth, modeflag, resindex,
6387 lvdstableindex;
6388
6389 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
6390 if (ModeNo <= 0x13) {
6391 xres = pVBInfo->StResInfo[resindex].HTotal;
6392 yres = pVBInfo->StResInfo[resindex].VTotal;
6393 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
6394 } else {
6395 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
6396 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
6397 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */
6398 }
6399
6400 if (!(modeflag & Charx8Dot)) {
6401 xres /= 9;
6402 xres *= 8;
6403 }
6404
6405 if (ModeNo > 0x13) {
6406 if ((ModeNo > 0x13) && (modeflag & HalfDCLK))
6407 xres *= 2;
6408
6409 if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
6410 yres *= 2;
6411
6412 }
6413
6414 lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo);
6415 if (xres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE))
6416 return 0;
6417
6418 if (yres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE))
6419 return 0;
6420
6421 if (ModeNo > 0x13) {
6422 if ((xres
6423 != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE))
6424 || (yres
6425 != (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE))) {
6426 colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex,
6427 pVBInfo);
6428 if (colordepth > 2)
6429 return 0;
6430
6431 }
6432 }
6433 return 1;
6434 }
6435
XGI_SetXG21FPBits(struct vb_device_info * pVBInfo)6436 void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo)
6437 {
6438 unsigned char temp;
6439
6440 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); /* D[0] 1: 18bit */
6441 temp = (temp & 1) << 6;
6442 xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x40, temp); /* SR06[6] 18bit Dither */
6443 xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */
6444
6445 }
6446
XGI_SetXG27FPBits(struct vb_device_info * pVBInfo)6447 void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo)
6448 {
6449 unsigned char temp;
6450
6451 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */
6452 temp = (temp & 3) << 6;
6453 xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0xc0, temp & 0x80); /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */
6454 xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */
6455
6456 }
6457
XGI_SetXG21LVDSPara(unsigned short ModeNo,unsigned short ModeIdIndex,struct vb_device_info * pVBInfo)6458 static void XGI_SetXG21LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex,
6459 struct vb_device_info *pVBInfo)
6460 {
6461 unsigned char temp, Miscdata;
6462 unsigned short xres, yres, modeflag, resindex, lvdstableindex;
6463 unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE;
6464 unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE;
6465 unsigned short value;
6466
6467 lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo);
6468
6469 temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability
6470 & (LCDPolarity << 8)) >> 8);
6471 temp &= LCDPolarity;
6472 Miscdata = (unsigned char) inb(pVBInfo->P3cc);
6473
6474 outb((Miscdata & 0x3F) | temp, pVBInfo->P3c2);
6475
6476 temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability
6477 & LCDPolarity);
6478 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80); /* SR35[7] FP VSync polarity */
6479 xgifb_reg_and_or(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); /* SR30[5] FP HSync polarity */
6480
6481 XGI_SetXG21FPBits(pVBInfo);
6482 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
6483 if (ModeNo <= 0x13) {
6484 xres = pVBInfo->StResInfo[resindex].HTotal;
6485 yres = pVBInfo->StResInfo[resindex].VTotal;
6486 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
6487 } else {
6488 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
6489 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
6490 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */
6491 }
6492
6493 if (!(modeflag & Charx8Dot))
6494 xres = xres * 8 / 9;
6495
6496 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
6497
6498 LVDSHBS = xres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE
6499 - xres) / 2;
6500 if ((ModeNo <= 0x13) && (modeflag & HalfDCLK))
6501 LVDSHBS -= xres / 4;
6502
6503 if (LVDSHBS > LVDSHT)
6504 LVDSHBS -= LVDSHT;
6505
6506 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP;
6507 if (LVDSHRS > LVDSHT)
6508 LVDSHRS -= LVDSHT;
6509
6510 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC;
6511 if (LVDSHRE > LVDSHT)
6512 LVDSHRE -= LVDSHT;
6513
6514 LVDSHBE = LVDSHBS + LVDSHT
6515 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE;
6516
6517 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
6518
6519 LVDSVBS = yres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE
6520 - yres) / 2;
6521 if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
6522 LVDSVBS += yres / 2;
6523
6524 if (LVDSVBS > LVDSVT)
6525 LVDSVBS -= LVDSVT;
6526
6527 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP;
6528 if (LVDSVRS > LVDSVT)
6529 LVDSVRS -= LVDSVT;
6530
6531 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC;
6532 if (LVDSVRE > LVDSVT)
6533 LVDSVRE -= LVDSVT;
6534
6535 LVDSVBE = LVDSVBS + LVDSVT
6536 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE;
6537
6538 temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
6539 xgifb_reg_set(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */
6540
6541 if (!(modeflag & Charx8Dot))
6542 xgifb_reg_or(pVBInfo->P3c4, 0x1, 0x1);
6543
6544 /* HT SR0B[1:0] CR00 */
6545 value = (LVDSHT >> 3) - 5;
6546 xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8);
6547 xgifb_reg_set(pVBInfo->P3d4, 0x0, (value & 0xFF));
6548
6549 /* HBS SR0B[5:4] CR02 */
6550 value = (LVDSHBS >> 3) - 1;
6551 xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4);
6552 xgifb_reg_set(pVBInfo->P3d4, 0x2, (value & 0xFF));
6553
6554 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
6555 value = (LVDSHBE >> 3) - 1;
6556 xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6);
6557 xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2);
6558 xgifb_reg_and_or(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F);
6559
6560 /* HRS SR0B[7:6] CR04 */
6561 value = (LVDSHRS >> 3) + 2;
6562 xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2);
6563 xgifb_reg_set(pVBInfo->P3d4, 0x4, (value & 0xFF));
6564
6565 /* Panel HRS SR2F[1:0] SR2E[7:0] */
6566 value--;
6567 xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8);
6568 xgifb_reg_set(pVBInfo->P3c4, 0x2E, (value & 0xFF));
6569
6570 /* HRE SR0C[2] CR05[4:0] */
6571 value = (LVDSHRE >> 3) + 2;
6572 xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3);
6573 xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F);
6574
6575 /* Panel HRE SR2F[7:2] */
6576 value--;
6577 xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2);
6578
6579 /* VT SR0A[0] CR07[5][0] CR06 */
6580 value = LVDSVT - 2;
6581 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10);
6582 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4);
6583 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8);
6584 xgifb_reg_set(pVBInfo->P3d4, 0x06, (value & 0xFF));
6585
6586 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
6587 value = LVDSVBS - 1;
6588 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8);
6589 xgifb_reg_and_or(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4);
6590 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5);
6591 xgifb_reg_set(pVBInfo->P3d4, 0x15, (value & 0xFF));
6592
6593 /* VBE SR0A[4] CR16 */
6594 value = LVDSVBE - 1;
6595 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4);
6596 xgifb_reg_set(pVBInfo->P3d4, 0x16, (value & 0xFF));
6597
6598 /* VRS SR0A[3] CR7[7][2] CR10 */
6599 value = LVDSVRS - 1;
6600 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7);
6601 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2);
6602 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6);
6603 xgifb_reg_set(pVBInfo->P3d4, 0x10, (value & 0xFF));
6604
6605 /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */
6606 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0x03, (value & 0x600) >> 9);
6607 xgifb_reg_set(pVBInfo->P3c4, 0x34, (value >> 1) & 0xFF);
6608 xgifb_reg_and_or(pVBInfo->P3d4, 0x33, ~0x01, value & 0x01);
6609
6610 /* VRE SR0A[5] CR11[3:0] */
6611 value = LVDSVRE - 1;
6612 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1);
6613 xgifb_reg_and_or(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F);
6614
6615 /* Panel VRE SR3F[7:2] *//* SR3F[7] has to be 0, h/w bug */
6616 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, (value << 2) & 0x7C);
6617
6618 for (temp = 0, value = 0; temp < 3; temp++) {
6619
6620 xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, value);
6621 xgifb_reg_set(pVBInfo->P3c4,
6622 0x2B,
6623 pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1);
6624 xgifb_reg_set(pVBInfo->P3c4,
6625 0x2C,
6626 pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2);
6627 value += 0x10;
6628 }
6629
6630 if (!(modeflag & Charx8Dot)) {
6631 inb(pVBInfo->P3da); /* reset 3da */
6632 outb(0x13, pVBInfo->P3c0); /* set index */
6633 outb(0x00, pVBInfo->P3c0); /* set data, panning = 0, shift left 1 dot*/
6634
6635 inb(pVBInfo->P3da); /* Enable Attribute */
6636 outb(0x20, pVBInfo->P3c0);
6637
6638 inb(pVBInfo->P3da); /* reset 3da */
6639 }
6640
6641 }
6642
6643 /* no shadow case */
XGI_SetXG27LVDSPara(unsigned short ModeNo,unsigned short ModeIdIndex,struct vb_device_info * pVBInfo)6644 static void XGI_SetXG27LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex,
6645 struct vb_device_info *pVBInfo)
6646 {
6647 unsigned char temp, Miscdata;
6648 unsigned short xres, yres, modeflag, resindex, lvdstableindex;
6649 unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE;
6650 unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE;
6651 unsigned short value;
6652
6653 lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo);
6654 temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability
6655 & (LCDPolarity << 8)) >> 8);
6656 temp &= LCDPolarity;
6657 Miscdata = (unsigned char) inb(pVBInfo->P3cc);
6658
6659 outb((Miscdata & 0x3F) | temp, pVBInfo->P3c2);
6660
6661 temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability
6662 & LCDPolarity);
6663 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80); /* SR35[7] FP VSync polarity */
6664 xgifb_reg_and_or(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); /* SR30[5] FP HSync polarity */
6665
6666 XGI_SetXG27FPBits(pVBInfo);
6667 resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
6668 if (ModeNo <= 0x13) {
6669 xres = pVBInfo->StResInfo[resindex].HTotal;
6670 yres = pVBInfo->StResInfo[resindex].VTotal;
6671 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */
6672 } else {
6673 xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
6674 yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
6675 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; /* si+St_ModeFlag */
6676 }
6677
6678 if (!(modeflag & Charx8Dot))
6679 xres = xres * 8 / 9;
6680
6681 LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
6682
6683 LVDSHBS = xres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE
6684 - xres) / 2;
6685 if ((ModeNo <= 0x13) && (modeflag & HalfDCLK))
6686 LVDSHBS -= xres / 4;
6687
6688 if (LVDSHBS > LVDSHT)
6689 LVDSHBS -= LVDSHT;
6690
6691 LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP;
6692 if (LVDSHRS > LVDSHT)
6693 LVDSHRS -= LVDSHT;
6694
6695 LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC;
6696 if (LVDSHRE > LVDSHT)
6697 LVDSHRE -= LVDSHT;
6698
6699 LVDSHBE = LVDSHBS + LVDSHT
6700 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE;
6701
6702 LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
6703
6704 LVDSVBS = yres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE
6705 - yres) / 2;
6706 if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
6707 LVDSVBS += yres / 2;
6708
6709 if (LVDSVBS > LVDSVT)
6710 LVDSVBS -= LVDSVT;
6711
6712 LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP;
6713 if (LVDSVRS > LVDSVT)
6714 LVDSVRS -= LVDSVT;
6715
6716 LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC;
6717 if (LVDSVRE > LVDSVT)
6718 LVDSVRE -= LVDSVT;
6719
6720 LVDSVBE = LVDSVBS + LVDSVT
6721 - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE;
6722
6723 temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11);
6724 xgifb_reg_set(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */
6725
6726 if (!(modeflag & Charx8Dot))
6727 xgifb_reg_or(pVBInfo->P3c4, 0x1, 0x1);
6728
6729 /* HT SR0B[1:0] CR00 */
6730 value = (LVDSHT >> 3) - 5;
6731 xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8);
6732 xgifb_reg_set(pVBInfo->P3d4, 0x0, (value & 0xFF));
6733
6734 /* HBS SR0B[5:4] CR02 */
6735 value = (LVDSHBS >> 3) - 1;
6736 xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4);
6737 xgifb_reg_set(pVBInfo->P3d4, 0x2, (value & 0xFF));
6738
6739 /* HBE SR0C[1:0] CR05[7] CR03[4:0] */
6740 value = (LVDSHBE >> 3) - 1;
6741 xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6);
6742 xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2);
6743 xgifb_reg_and_or(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F);
6744
6745 /* HRS SR0B[7:6] CR04 */
6746 value = (LVDSHRS >> 3) + 2;
6747 xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2);
6748 xgifb_reg_set(pVBInfo->P3d4, 0x4, (value & 0xFF));
6749
6750 /* Panel HRS SR2F[1:0] SR2E[7:0] */
6751 value--;
6752 xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8);
6753 xgifb_reg_set(pVBInfo->P3c4, 0x2E, (value & 0xFF));
6754
6755 /* HRE SR0C[2] CR05[4:0] */
6756 value = (LVDSHRE >> 3) + 2;
6757 xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3);
6758 xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F);
6759
6760 /* Panel HRE SR2F[7:2] */
6761 value--;
6762 xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2);
6763
6764 /* VT SR0A[0] CR07[5][0] CR06 */
6765 value = LVDSVT - 2;
6766 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10);
6767 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4);
6768 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8);
6769 xgifb_reg_set(pVBInfo->P3d4, 0x06, (value & 0xFF));
6770
6771 /* VBS SR0A[2] CR09[5] CR07[3] CR15 */
6772 value = LVDSVBS - 1;
6773 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8);
6774 xgifb_reg_and_or(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4);
6775 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5);
6776 xgifb_reg_set(pVBInfo->P3d4, 0x15, (value & 0xFF));
6777
6778 /* VBE SR0A[4] CR16 */
6779 value = LVDSVBE - 1;
6780 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4);
6781 xgifb_reg_set(pVBInfo->P3d4, 0x16, (value & 0xFF));
6782
6783 /* VRS SR0A[3] CR7[7][2] CR10 */
6784 value = LVDSVRS - 1;
6785 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7);
6786 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2);
6787 xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6);
6788 xgifb_reg_set(pVBInfo->P3d4, 0x10, (value & 0xFF));
6789
6790 /* Panel VRS SR35[2:0] SR34[7:0] */
6791 xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, (value & 0x700) >> 8);
6792 xgifb_reg_set(pVBInfo->P3c4, 0x34, value & 0xFF);
6793
6794 /* VRE SR0A[5] CR11[3:0] */
6795 value = LVDSVRE - 1;
6796 xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1);
6797 xgifb_reg_and_or(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F);
6798
6799 /* Panel VRE SR3F[7:2] */
6800 xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, (value << 2) & 0xFC);
6801
6802 for (temp = 0, value = 0; temp < 3; temp++) {
6803
6804 xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, value);
6805 xgifb_reg_set(pVBInfo->P3c4,
6806 0x2B,
6807 pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1);
6808 xgifb_reg_set(pVBInfo->P3c4,
6809 0x2C,
6810 pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2);
6811 value += 0x10;
6812 }
6813
6814 if (!(modeflag & Charx8Dot)) {
6815 inb(pVBInfo->P3da); /* reset 3da */
6816 outb(0x13, pVBInfo->P3c0); /* set index */
6817 outb(0x00, pVBInfo->P3c0); /* set data, panning = 0, shift left 1 dot*/
6818
6819 inb(pVBInfo->P3da); /* Enable Attribute */
6820 outb(0x20, pVBInfo->P3c0);
6821
6822 inb(pVBInfo->P3da); /* reset 3da */
6823 }
6824
6825 }
6826
6827 /* --------------------------------------------------------------------- */
6828 /* Function : XGI_IsLCDON */
6829 /* Input : */
6830 /* Output : 0 : Skip PSC Control */
6831 /* 1: Disable PSC */
6832 /* Description : */
6833 /* --------------------------------------------------------------------- */
XGI_IsLCDON(struct vb_device_info * pVBInfo)6834 static unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo)
6835 {
6836 unsigned short tempax;
6837
6838 tempax = pVBInfo->VBInfo;
6839 if (tempax & SetCRT2ToDualEdge)
6840 return 0;
6841 else if (tempax & (DisableCRT2Display | SwitchToCRT2 | SetSimuScanMode))
6842 return 1;
6843
6844 return 0;
6845 }
6846
6847 /* --------------------------------------------------------------------- */
6848 /* Function : XGI_DisableChISLCD */
6849 /* Input : */
6850 /* Output : 0 -> Not LCD Mode */
6851 /* Description : */
6852 /* --------------------------------------------------------------------- */
XGI_DisableChISLCD(struct vb_device_info * pVBInfo)6853 static unsigned char XGI_DisableChISLCD(struct vb_device_info *pVBInfo)
6854 {
6855 unsigned short tempbx, tempah;
6856
6857 tempbx = pVBInfo->SetFlag & (DisableChA | DisableChB);
6858 tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E));
6859
6860 if (tempbx & (EnableChA | DisableChA)) {
6861 if (!(tempah & 0x08)) /* Chk LCDA Mode */
6862 return 0;
6863 }
6864
6865 if (!(tempbx & (EnableChB | DisableChB)))
6866 return 0;
6867
6868 if (tempah & 0x01) /* Chk LCDB Mode */
6869 return 1;
6870
6871 return 0;
6872 }
6873
6874 /* --------------------------------------------------------------------- */
6875 /* Function : XGI_EnableChISLCD */
6876 /* Input : */
6877 /* Output : 0 -> Not LCD mode */
6878 /* Description : */
6879 /* --------------------------------------------------------------------- */
XGI_EnableChISLCD(struct vb_device_info * pVBInfo)6880 static unsigned char XGI_EnableChISLCD(struct vb_device_info *pVBInfo)
6881 {
6882 unsigned short tempbx, tempah;
6883
6884 tempbx = pVBInfo->SetFlag & (EnableChA | EnableChB);
6885 tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E));
6886
6887 if (tempbx & (EnableChA | DisableChA)) {
6888 if (!(tempah & 0x08)) /* Chk LCDA Mode */
6889 return 0;
6890 }
6891
6892 if (!(tempbx & (EnableChB | DisableChB)))
6893 return 0;
6894
6895 if (tempah & 0x01) /* Chk LCDB Mode */
6896 return 1;
6897
6898 return 0;
6899 }
6900
XGI_DisableBridge(struct xgi_hw_device_info * HwDeviceExtension,struct vb_device_info * pVBInfo)6901 void XGI_DisableBridge(struct xgi_hw_device_info *HwDeviceExtension,
6902 struct vb_device_info *pVBInfo)
6903 {
6904 unsigned short tempah = 0;
6905
6906 if (pVBInfo->SetFlag == Win9xDOSMode)
6907 return;
6908
6909 /*
6910 if (CH7017) {
6911 if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2toLCDA)) || (XGI_DisableChISLCD(pVBInfo))) {
6912 if (!XGI_IsLCDON(pVBInfo)) {
6913 if (DISCHARGE) {
6914 tempbx = XGINew_GetCH7005(0x61);
6915 if (tempbx < 0x01) // first time we power up
6916 XGINew_SetCH7005(0x0066); // and disable power sequence
6917 else
6918 XGINew_SetCH7005(0x5f66); // leave VDD on - disable power
6919 }
6920 }
6921 }
6922 }
6923 */
6924
6925 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
6926 | VB_XGI302LV | VB_XGI301C)) {
6927 tempah = 0x3F;
6928 if (!(pVBInfo->VBInfo & (DisableCRT2Display | SetSimuScanMode))) {
6929 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
6930 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
6931 tempah = 0x7F; /* Disable Channel A */
6932 if (!(pVBInfo->VBInfo & SetCRT2ToLCDA))
6933 tempah = 0xBF; /* Disable Channel B */
6934
6935 if (pVBInfo->SetFlag & DisableChB)
6936 tempah &= 0xBF; /* force to disable Cahnnel */
6937
6938 if (pVBInfo->SetFlag & DisableChA)
6939 tempah &= 0x7F; /* Force to disable Channel B */
6940 }
6941 }
6942 }
6943
6944 xgifb_reg_and(pVBInfo->Part4Port, 0x1F, tempah); /* disable part4_1f */
6945
6946 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
6947 if (((pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)))
6948 || (XGI_DisableChISLCD(pVBInfo))
6949 || (XGI_IsLCDON(pVBInfo)))
6950 xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x80); /* LVDS Driver power down */
6951 }
6952
6953 if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo
6954 & (DisableCRT2Display | SetCRT2ToLCDA
6955 | SetSimuScanMode))) {
6956 if (pVBInfo->SetFlag & GatingCRT)
6957 XGI_EnableGatingCRT(HwDeviceExtension, pVBInfo);
6958 XGI_DisplayOff(HwDeviceExtension, pVBInfo);
6959 }
6960
6961 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
6962 if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo
6963 & SetCRT2ToLCDA))
6964 xgifb_reg_and(pVBInfo->Part1Port, 0x1e, 0xdf); /* Power down */
6965 }
6966
6967 xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xdf); /* disable TV as primary VGA swap */
6968
6969 if ((pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToDualEdge)))
6970 xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xdf);
6971
6972 if ((pVBInfo->SetFlag & DisableChB) || (pVBInfo->VBInfo
6973 & (DisableCRT2Display | SetSimuScanMode))
6974 || ((!(pVBInfo->VBInfo & SetCRT2ToLCDA))
6975 && (pVBInfo->VBInfo
6976 & (SetCRT2ToRAMDAC
6977 | SetCRT2ToLCD
6978 | SetCRT2ToTV))))
6979 xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80); /* BScreenOff=1 */
6980
6981 if ((pVBInfo->SetFlag & DisableChB) || (pVBInfo->VBInfo
6982 & (DisableCRT2Display | SetSimuScanMode))
6983 || (!(pVBInfo->VBInfo & SetCRT2ToLCDA))
6984 || (pVBInfo->VBInfo & (SetCRT2ToRAMDAC
6985 | SetCRT2ToLCD | SetCRT2ToTV))) {
6986 tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00); /* save Part1 index 0 */
6987 xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x10); /* BTDAC = 1, avoid VB reset */
6988 xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF); /* disable CRT2 */
6989 xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah); /* restore Part1 index 0 */
6990 }
6991 } else { /* {301} */
6992 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) {
6993 xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80); /* BScreenOff=1 */
6994 xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF); /* Disable CRT2 */
6995 xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xDF); /* Disable TV asPrimary VGA swap */
6996 }
6997
6998 if (pVBInfo->VBInfo & (DisableCRT2Display | SetCRT2ToLCDA
6999 | SetSimuScanMode))
7000 XGI_DisplayOff(HwDeviceExtension, pVBInfo);
7001 }
7002 }
7003
7004 /* --------------------------------------------------------------------- */
7005 /* Function : XGI_GetTVPtrIndex */
7006 /* Input : */
7007 /* Output : */
7008 /* Description : bx 0 : ExtNTSC */
7009 /* 1 : StNTSC */
7010 /* 2 : ExtPAL */
7011 /* 3 : StPAL */
7012 /* 4 : ExtHiTV */
7013 /* 5 : StHiTV */
7014 /* 6 : Ext525i */
7015 /* 7 : St525i */
7016 /* 8 : Ext525p */
7017 /* 9 : St525p */
7018 /* A : Ext750p */
7019 /* B : St750p */
7020 /* --------------------------------------------------------------------- */
XGI_GetTVPtrIndex(struct vb_device_info * pVBInfo)7021 static unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo)
7022 {
7023 unsigned short tempbx = 0;
7024
7025 if (pVBInfo->TVInfo & SetPALTV)
7026 tempbx = 2;
7027 if (pVBInfo->TVInfo & SetYPbPrMode1080i)
7028 tempbx = 4;
7029 if (pVBInfo->TVInfo & SetYPbPrMode525i)
7030 tempbx = 6;
7031 if (pVBInfo->TVInfo & SetYPbPrMode525p)
7032 tempbx = 8;
7033 if (pVBInfo->TVInfo & SetYPbPrMode750p)
7034 tempbx = 10;
7035 if (pVBInfo->TVInfo & TVSimuMode)
7036 tempbx++;
7037
7038 return tempbx;
7039 }
7040
7041 /* --------------------------------------------------------------------- */
7042 /* Function : XGI_GetTVPtrIndex2 */
7043 /* Input : */
7044 /* Output : bx 0 : NTSC */
7045 /* 1 : PAL */
7046 /* 2 : PALM */
7047 /* 3 : PALN */
7048 /* 4 : NTSC1024x768 */
7049 /* 5 : PAL-M 1024x768 */
7050 /* 6-7: reserved */
7051 /* cl 0 : YFilter1 */
7052 /* 1 : YFilter2 */
7053 /* ch 0 : 301A */
7054 /* 1 : 301B/302B/301LV/302LV */
7055 /* Description : */
7056 /* --------------------------------------------------------------------- */
XGI_GetTVPtrIndex2(unsigned short * tempbx,unsigned char * tempcl,unsigned char * tempch,struct vb_device_info * pVBInfo)7057 static void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char *tempcl,
7058 unsigned char *tempch, struct vb_device_info *pVBInfo)
7059 {
7060 *tempbx = 0;
7061 *tempcl = 0;
7062 *tempch = 0;
7063
7064 if (pVBInfo->TVInfo & SetPALTV)
7065 *tempbx = 1;
7066
7067 if (pVBInfo->TVInfo & SetPALMTV)
7068 *tempbx = 2;
7069
7070 if (pVBInfo->TVInfo & SetPALNTV)
7071 *tempbx = 3;
7072
7073 if (pVBInfo->TVInfo & NTSC1024x768) {
7074 *tempbx = 4;
7075 if (pVBInfo->TVInfo & SetPALMTV)
7076 *tempbx = 5;
7077 }
7078
7079 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7080 | VB_XGI302LV | VB_XGI301C)) {
7081 if ((!(pVBInfo->VBInfo & SetInSlaveMode)) || (pVBInfo->TVInfo
7082 & TVSimuMode)) {
7083 *tempbx += 8;
7084 *tempcl += 1;
7085 }
7086 }
7087
7088 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7089 | VB_XGI302LV | VB_XGI301C))
7090 (*tempch)++;
7091 }
7092
XGI_SetDelayComp(struct vb_device_info * pVBInfo)7093 static void XGI_SetDelayComp(struct vb_device_info *pVBInfo)
7094 {
7095 unsigned short index;
7096
7097 unsigned char tempah, tempbl, tempbh;
7098
7099 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7100 | VB_XGI302LV | VB_XGI301C)) {
7101 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA
7102 | SetCRT2ToTV | SetCRT2ToRAMDAC)) {
7103 tempbl = 0;
7104 tempbh = 0;
7105
7106 index = XGI_GetTVPtrIndex(pVBInfo); /* Get TV Delay */
7107 tempbl = pVBInfo->XGI_TVDelayList[index];
7108
7109 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
7110 | VB_XGI301LV | VB_XGI302LV
7111 | VB_XGI301C))
7112 tempbl = pVBInfo->XGI_TVDelayList2[index];
7113
7114 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
7115 tempbl = tempbl >> 4;
7116 /*
7117 if (pVBInfo->VBInfo & SetCRT2ToRAMDAC)
7118 tempbl = CRT2Delay1; // Get CRT2 Delay
7119 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV | VB_XGI301C))
7120 tempbl = CRT2Delay2;
7121 */
7122 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
7123 index = XGI_GetLCDCapPtr(pVBInfo); /* Get LCD Delay */
7124 tempbh = pVBInfo->LCDCapList[index].LCD_DelayCompensation;
7125
7126 if (!(pVBInfo->VBInfo & SetCRT2ToLCDA))
7127 tempbl = tempbh;
7128 }
7129
7130 tempbl &= 0x0F;
7131 tempbh &= 0xF0;
7132 tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x2D);
7133
7134 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD
7135 | SetCRT2ToTV)) { /* Channel B */
7136 tempah &= 0xF0;
7137 tempah |= tempbl;
7138 }
7139
7140 if (pVBInfo->VBInfo & SetCRT2ToLCDA) { /* Channel A */
7141 tempah &= 0x0F;
7142 tempah |= tempbh;
7143 }
7144 xgifb_reg_set(pVBInfo->Part1Port, 0x2D, tempah);
7145 }
7146 } else if (pVBInfo->IF_DEF_LVDS == 1) {
7147 tempbl = 0;
7148 tempbh = 0;
7149 if (pVBInfo->VBInfo & SetCRT2ToLCD) {
7150 tempah
7151 = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(
7152 pVBInfo)].LCD_DelayCompensation; /* / Get LCD Delay */
7153 tempah &= 0x0f;
7154 tempah = tempah << 4;
7155 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2D, 0x0f,
7156 tempah);
7157 }
7158 }
7159 }
7160
XGI_SetLCDCap_A(unsigned short tempcx,struct vb_device_info * pVBInfo)7161 static void XGI_SetLCDCap_A(unsigned short tempcx, struct vb_device_info *pVBInfo)
7162 {
7163 unsigned short temp;
7164
7165 temp = xgifb_reg_get(pVBInfo->P3d4, 0x37);
7166
7167 if (temp & LCDRGB18Bit) {
7168 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F,
7169 (unsigned short) (0x20 | (tempcx & 0x00C0))); /* Enable Dither */
7170 xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80);
7171 } else {
7172 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F,
7173 (unsigned short) (0x30 | (tempcx & 0x00C0)));
7174 xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00);
7175 }
7176
7177 /*
7178 if (tempcx & EnableLCD24bpp) { // 24bits
7179 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F, (unsigned short)(0x30 | (tempcx&0x00C0)));
7180 xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00);
7181 } else {
7182 xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F, (unsigned short)(0x20 | (tempcx&0x00C0))); // Enable Dither
7183 xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80);
7184 }
7185 */
7186 }
7187
7188 /* --------------------------------------------------------------------- */
7189 /* Function : XGI_SetLCDCap_B */
7190 /* Input : cx -> LCD Capability */
7191 /* Output : */
7192 /* Description : */
7193 /* --------------------------------------------------------------------- */
XGI_SetLCDCap_B(unsigned short tempcx,struct vb_device_info * pVBInfo)7194 static void XGI_SetLCDCap_B(unsigned short tempcx, struct vb_device_info *pVBInfo)
7195 {
7196 if (tempcx & EnableLCD24bpp) /* 24bits */
7197 xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0,
7198 (unsigned short) (((tempcx & 0x00ff) >> 6)
7199 | 0x0c));
7200 else
7201 xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0,
7202 (unsigned short) (((tempcx & 0x00ff) >> 6)
7203 | 0x18)); /* Enable Dither */
7204 }
7205
SetSpectrum(struct vb_device_info * pVBInfo)7206 static void SetSpectrum(struct vb_device_info *pVBInfo)
7207 {
7208 unsigned short index;
7209
7210 index = XGI_GetLCDCapPtr(pVBInfo);
7211
7212 xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x8F); /* disable down spectrum D[4] */
7213 XGI_LongWait(pVBInfo);
7214 xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x20); /* reset spectrum */
7215 XGI_LongWait(pVBInfo);
7216
7217 xgifb_reg_set(pVBInfo->Part4Port, 0x31,
7218 pVBInfo->LCDCapList[index].Spectrum_31);
7219 xgifb_reg_set(pVBInfo->Part4Port, 0x32,
7220 pVBInfo->LCDCapList[index].Spectrum_32);
7221 xgifb_reg_set(pVBInfo->Part4Port, 0x33,
7222 pVBInfo->LCDCapList[index].Spectrum_33);
7223 xgifb_reg_set(pVBInfo->Part4Port, 0x34,
7224 pVBInfo->LCDCapList[index].Spectrum_34);
7225 XGI_LongWait(pVBInfo);
7226 xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x40); /* enable spectrum */
7227 }
7228
XGI_SetLCDCap(struct vb_device_info * pVBInfo)7229 static void XGI_SetLCDCap(struct vb_device_info *pVBInfo)
7230 {
7231 unsigned short tempcx;
7232
7233 tempcx = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(pVBInfo)].LCD_Capability;
7234
7235 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7236 | VB_XGI302LV | VB_XGI301C)) {
7237 if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) { /* 301LV/302LV only */
7238 /* Set 301LV Capability */
7239 xgifb_reg_set(pVBInfo->Part4Port, 0x24,
7240 (unsigned char) (tempcx & 0x1F));
7241 }
7242 /* VB Driving */
7243 xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D,
7244 ~((EnableVBCLKDRVLOW | EnablePLLSPLOW) >> 8),
7245 (unsigned short) ((tempcx & (EnableVBCLKDRVLOW
7246 | EnablePLLSPLOW)) >> 8));
7247 }
7248
7249 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7250 | VB_XGI302LV | VB_XGI301C)) {
7251 if (pVBInfo->VBInfo & SetCRT2ToLCD)
7252 XGI_SetLCDCap_B(tempcx, pVBInfo);
7253 else if (pVBInfo->VBInfo & SetCRT2ToLCDA)
7254 XGI_SetLCDCap_A(tempcx, pVBInfo);
7255
7256 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
7257 if (tempcx & EnableSpectrum)
7258 SetSpectrum(pVBInfo);
7259 }
7260 } else {
7261 /* LVDS,CH7017 */
7262 XGI_SetLCDCap_A(tempcx, pVBInfo);
7263 }
7264 }
7265
7266 /* --------------------------------------------------------------------- */
7267 /* Function : XGI_SetAntiFlicker */
7268 /* Input : */
7269 /* Output : */
7270 /* Description : Set TV Customized Param. */
7271 /* --------------------------------------------------------------------- */
XGI_SetAntiFlicker(unsigned short ModeNo,unsigned short ModeIdIndex,struct vb_device_info * pVBInfo)7272 static void XGI_SetAntiFlicker(unsigned short ModeNo, unsigned short ModeIdIndex,
7273 struct vb_device_info *pVBInfo)
7274 {
7275 unsigned short tempbx, index;
7276
7277 unsigned char tempah;
7278
7279 if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))
7280 return;
7281
7282 tempbx = XGI_GetTVPtrIndex(pVBInfo);
7283 tempbx &= 0xFE;
7284
7285 if (ModeNo <= 0x13)
7286 index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVFlickerIndex;
7287 else
7288 index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVFlickerIndex;
7289
7290 tempbx += index;
7291 tempah = TVAntiFlickList[tempbx];
7292 tempah = tempah << 4;
7293
7294 xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0x8F, tempah);
7295 }
7296
XGI_SetEdgeEnhance(unsigned short ModeNo,unsigned short ModeIdIndex,struct vb_device_info * pVBInfo)7297 static void XGI_SetEdgeEnhance(unsigned short ModeNo, unsigned short ModeIdIndex,
7298 struct vb_device_info *pVBInfo)
7299 {
7300 unsigned short tempbx, index;
7301
7302 unsigned char tempah;
7303
7304 tempbx = XGI_GetTVPtrIndex(pVBInfo);
7305 tempbx &= 0xFE;
7306
7307 if (ModeNo <= 0x13)
7308 index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVEdgeIndex;
7309 else
7310 index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVEdgeIndex;
7311
7312 tempbx += index;
7313 tempah = TVEdgeList[tempbx];
7314 tempah = tempah << 5;
7315
7316 xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, tempah);
7317 }
7318
XGI_SetPhaseIncr(struct vb_device_info * pVBInfo)7319 static void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo)
7320 {
7321 unsigned short tempbx;
7322
7323 unsigned char tempcl, tempch;
7324
7325 unsigned long tempData;
7326
7327 XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */
7328 tempData = TVPhaseList[tempbx];
7329
7330 xgifb_reg_set(pVBInfo->Part2Port, 0x31, (unsigned short) (tempData
7331 & 0x000000FF));
7332 xgifb_reg_set(pVBInfo->Part2Port, 0x32, (unsigned short) ((tempData
7333 & 0x0000FF00) >> 8));
7334 xgifb_reg_set(pVBInfo->Part2Port, 0x33, (unsigned short) ((tempData
7335 & 0x00FF0000) >> 16));
7336 xgifb_reg_set(pVBInfo->Part2Port, 0x34, (unsigned short) ((tempData
7337 & 0xFF000000) >> 24));
7338 }
7339
XGI_SetYFilter(unsigned short ModeNo,unsigned short ModeIdIndex,struct vb_device_info * pVBInfo)7340 static void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex,
7341 struct vb_device_info *pVBInfo)
7342 {
7343 unsigned short tempbx, index;
7344
7345 unsigned char tempcl, tempch, tempal, *filterPtr;
7346
7347 XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */
7348
7349 switch (tempbx) {
7350 case 0x00:
7351 case 0x04:
7352 filterPtr = NTSCYFilter1;
7353 break;
7354
7355 case 0x01:
7356 filterPtr = PALYFilter1;
7357 break;
7358
7359 case 0x02:
7360 case 0x05:
7361 case 0x0D:
7362 filterPtr = PALMYFilter1;
7363 break;
7364
7365 case 0x03:
7366 filterPtr = PALNYFilter1;
7367 break;
7368
7369 case 0x08:
7370 case 0x0C:
7371 filterPtr = NTSCYFilter2;
7372 break;
7373
7374 case 0x0A:
7375 filterPtr = PALMYFilter2;
7376 break;
7377
7378 case 0x0B:
7379 filterPtr = PALNYFilter2;
7380 break;
7381
7382 case 0x09:
7383 filterPtr = PALYFilter2;
7384 break;
7385
7386 default:
7387 return;
7388 }
7389
7390 if (ModeNo <= 0x13)
7391 tempal = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVYFilterIndex;
7392 else
7393 tempal
7394 = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVYFilterIndex;
7395
7396 if (tempcl == 0)
7397 index = tempal * 4;
7398 else
7399 index = tempal * 7;
7400
7401 if ((tempcl == 0) && (tempch == 1)) {
7402 xgifb_reg_set(pVBInfo->Part2Port, 0x35, 0);
7403 xgifb_reg_set(pVBInfo->Part2Port, 0x36, 0);
7404 xgifb_reg_set(pVBInfo->Part2Port, 0x37, 0);
7405 xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]);
7406 } else {
7407 xgifb_reg_set(pVBInfo->Part2Port, 0x35, filterPtr[index++]);
7408 xgifb_reg_set(pVBInfo->Part2Port, 0x36, filterPtr[index++]);
7409 xgifb_reg_set(pVBInfo->Part2Port, 0x37, filterPtr[index++]);
7410 xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]);
7411 }
7412
7413 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7414 | VB_XGI302LV | VB_XGI301C)) {
7415 xgifb_reg_set(pVBInfo->Part2Port, 0x48, filterPtr[index++]);
7416 xgifb_reg_set(pVBInfo->Part2Port, 0x49, filterPtr[index++]);
7417 xgifb_reg_set(pVBInfo->Part2Port, 0x4A, filterPtr[index++]);
7418 }
7419 }
7420
7421 /* --------------------------------------------------------------------- */
7422 /* Function : XGI_OEM310Setting */
7423 /* Input : */
7424 /* Output : */
7425 /* Description : Customized Param. for 301 */
7426 /* --------------------------------------------------------------------- */
XGI_OEM310Setting(unsigned short ModeNo,unsigned short ModeIdIndex,struct vb_device_info * pVBInfo)7427 static void XGI_OEM310Setting(unsigned short ModeNo, unsigned short ModeIdIndex,
7428 struct vb_device_info *pVBInfo)
7429 {
7430 if (pVBInfo->SetFlag & Win9xDOSMode)
7431 return;
7432
7433 /* GetPart1IO(); */
7434 XGI_SetDelayComp(pVBInfo);
7435
7436 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))
7437 XGI_SetLCDCap(pVBInfo);
7438
7439 if (pVBInfo->VBInfo & SetCRT2ToTV) {
7440 /* GetPart2IO() */
7441 XGI_SetPhaseIncr(pVBInfo);
7442 XGI_SetYFilter(ModeNo, ModeIdIndex, pVBInfo);
7443 XGI_SetAntiFlicker(ModeNo, ModeIdIndex, pVBInfo);
7444
7445 if (pVBInfo->VBType & VB_XGI301)
7446 XGI_SetEdgeEnhance(ModeNo, ModeIdIndex, pVBInfo);
7447 }
7448 }
7449
7450 /* --------------------------------------------------------------------- */
7451 /* Function : XGI_SetCRT2ModeRegs */
7452 /* Input : */
7453 /* Output : */
7454 /* Description : Origin code for crt2group */
7455 /* --------------------------------------------------------------------- */
XGI_SetCRT2ModeRegs(unsigned short ModeNo,struct xgi_hw_device_info * HwDeviceExtension,struct vb_device_info * pVBInfo)7456 void XGI_SetCRT2ModeRegs(unsigned short ModeNo,
7457 struct xgi_hw_device_info *HwDeviceExtension,
7458 struct vb_device_info *pVBInfo)
7459 {
7460 unsigned short tempbl;
7461 short tempcl;
7462
7463 unsigned char tempah;
7464
7465 /* xgifb_reg_set(pVBInfo->Part1Port, 0x03, 0x00); // fix write part1 index 0 BTDRAM bit Bug */
7466 tempah = 0;
7467 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
7468 tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00);
7469 tempah &= ~0x10; /* BTRAMDAC */
7470 tempah |= 0x40; /* BTRAM */
7471
7472 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV
7473 | SetCRT2ToLCD)) {
7474 tempah = 0x40; /* BTDRAM */
7475 if (ModeNo > 0x13) {
7476 tempcl = pVBInfo->ModeType;
7477 tempcl -= ModeVGA;
7478 if (tempcl >= 0) {
7479 tempah = (0x008 >> tempcl); /* BT Color */
7480 if (tempah == 0)
7481 tempah = 1;
7482 tempah |= 0x040;
7483 }
7484 }
7485 if (pVBInfo->VBInfo & SetInSlaveMode)
7486 tempah ^= 0x50; /* BTDAC */
7487 }
7488 }
7489
7490 /* 0210 shampoo
7491 if (pVBInfo->VBInfo & DisableCRT2Display) {
7492 tempah = 0;
7493 }
7494
7495 xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah);
7496 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD)) {
7497 tempcl = pVBInfo->ModeType;
7498 if (ModeNo > 0x13) {
7499 tempcl -= ModeVGA;
7500 if ((tempcl > 0) || (tempcl == 0)) {
7501 tempah=(0x008>>tempcl) ;
7502 if (tempah == 0)
7503 tempah = 1;
7504 tempah |= 0x040;
7505 }
7506 } else {
7507 tempah = 0x040;
7508 }
7509
7510 if (pVBInfo->VBInfo & SetInSlaveMode) {
7511 tempah = (tempah ^ 0x050);
7512 }
7513 }
7514 */
7515
7516 xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah);
7517 tempah = 0x08;
7518 tempbl = 0xf0;
7519
7520 if (pVBInfo->VBInfo & DisableCRT2Display) {
7521 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl, tempah);
7522 } else {
7523 tempah = 0x00;
7524 tempbl = 0xff;
7525
7526 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV
7527 | SetCRT2ToLCD | SetCRT2ToLCDA)) {
7528 if ((pVBInfo->VBInfo & SetCRT2ToLCDA)
7529 && (!(pVBInfo->VBInfo & SetSimuScanMode))) {
7530 tempbl &= 0xf7;
7531 tempah |= 0x01;
7532 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e,
7533 tempbl, tempah);
7534 } else {
7535 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
7536 tempbl &= 0xf7;
7537 tempah |= 0x01;
7538 }
7539
7540 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC
7541 | SetCRT2ToTV | SetCRT2ToLCD)) {
7542 tempbl &= 0xf8;
7543 tempah = 0x01;
7544
7545 if (!(pVBInfo->VBInfo & SetInSlaveMode))
7546 tempah |= 0x02;
7547
7548 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) {
7549 tempah = tempah ^ 0x05;
7550 if (!(pVBInfo->VBInfo
7551 & SetCRT2ToLCD))
7552 tempah = tempah ^ 0x01;
7553 }
7554
7555 if (!(pVBInfo->VBInfo
7556 & SetCRT2ToDualEdge))
7557 tempah |= 0x08;
7558 xgifb_reg_and_or(pVBInfo->Part1Port,
7559 0x2e, tempbl, tempah);
7560 } else {
7561 xgifb_reg_and_or(pVBInfo->Part1Port,
7562 0x2e, tempbl, tempah);
7563 }
7564 }
7565 } else {
7566 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl,
7567 tempah);
7568 }
7569 }
7570
7571 if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD
7572 | SetCRT2ToLCDA)) {
7573 tempah &= (~0x08);
7574 if ((pVBInfo->ModeType == ModeVGA) && (!(pVBInfo->VBInfo
7575 & SetInSlaveMode))) {
7576 tempah |= 0x010;
7577 }
7578 tempah |= 0x080;
7579
7580 if (pVBInfo->VBInfo & SetCRT2ToTV) {
7581 /* if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))) { */
7582 tempah |= 0x020;
7583 if (ModeNo > 0x13) {
7584 if (pVBInfo->VBInfo & DriverMode)
7585 tempah = tempah ^ 0x20;
7586 }
7587 /* } */
7588 }
7589
7590 xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D, ~0x0BF, tempah);
7591 tempah = 0;
7592
7593 if (pVBInfo->LCDInfo & SetLCDDualLink)
7594 tempah |= 0x40;
7595
7596 if (pVBInfo->VBInfo & SetCRT2ToTV) {
7597 /* if ((!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)) && (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)))) { */
7598 if (pVBInfo->TVInfo & RPLLDIV2XO)
7599 tempah |= 0x40;
7600 /* } */
7601 }
7602
7603 if ((pVBInfo->LCDResInfo == Panel1280x1024)
7604 || (pVBInfo->LCDResInfo == Panel1280x1024x75))
7605 tempah |= 0x80;
7606
7607 if (pVBInfo->LCDResInfo == Panel1280x960)
7608 tempah |= 0x80;
7609
7610 xgifb_reg_set(pVBInfo->Part4Port, 0x0C, tempah);
7611 }
7612
7613 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
7614 | VB_XGI302LV | VB_XGI301C)) {
7615 tempah = 0;
7616 tempbl = 0xfb;
7617
7618 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
7619 tempbl = 0xff;
7620 if (pVBInfo->VBInfo & SetCRT2ToLCDA)
7621 tempah |= 0x04; /* shampoo 0129 */
7622 }
7623
7624 xgifb_reg_and_or(pVBInfo->Part1Port, 0x13, tempbl, tempah);
7625 tempah = 0x00;
7626 tempbl = 0xcf;
7627 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
7628 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
7629 tempah |= 0x30;
7630 }
7631
7632 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2c, tempbl, tempah);
7633 tempah = 0;
7634 tempbl = 0x3f;
7635
7636 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
7637 if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
7638 tempah |= 0xc0;
7639 }
7640 xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, tempbl, tempah);
7641 }
7642
7643 tempah = 0;
7644 tempbl = 0x7f;
7645 if (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) {
7646 tempbl = 0xff;
7647 if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge))
7648 tempah |= 0x80;
7649 }
7650
7651 xgifb_reg_and_or(pVBInfo->Part4Port, 0x23, tempbl, tempah);
7652
7653 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
7654 if (pVBInfo->LCDInfo & SetLCDDualLink) {
7655 xgifb_reg_or(pVBInfo->Part4Port, 0x27, 0x20);
7656 xgifb_reg_or(pVBInfo->Part4Port, 0x34, 0x10);
7657 }
7658 }
7659 }
7660
XGI_CloseCRTC(struct xgi_hw_device_info * HwDeviceExtension,struct vb_device_info * pVBInfo)7661 static void XGI_CloseCRTC(struct xgi_hw_device_info *HwDeviceExtension,
7662 struct vb_device_info *pVBInfo)
7663 {
7664 unsigned short tempbx;
7665
7666 tempbx = 0;
7667
7668 if (pVBInfo->VBInfo & SetCRT2ToLCDA)
7669 tempbx = 0x08A0;
7670
7671 }
7672
XGI_OpenCRTC(struct xgi_hw_device_info * HwDeviceExtension,struct vb_device_info * pVBInfo)7673 void XGI_OpenCRTC(struct xgi_hw_device_info *HwDeviceExtension,
7674 struct vb_device_info *pVBInfo)
7675 {
7676 unsigned short tempbx;
7677 tempbx = 0;
7678 }
7679
XGI_UnLockCRT2(struct xgi_hw_device_info * HwDeviceExtension,struct vb_device_info * pVBInfo)7680 void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension,
7681 struct vb_device_info *pVBInfo)
7682 {
7683
7684 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2f, 0xFF, 0x01);
7685
7686 }
7687
XGI_LockCRT2(struct xgi_hw_device_info * HwDeviceExtension,struct vb_device_info * pVBInfo)7688 void XGI_LockCRT2(struct xgi_hw_device_info *HwDeviceExtension,
7689 struct vb_device_info *pVBInfo)
7690 {
7691
7692 xgifb_reg_and_or(pVBInfo->Part1Port, 0x2F, 0xFE, 0x00);
7693
7694 }
7695
XGI_BridgeIsOn(struct vb_device_info * pVBInfo)7696 unsigned char XGI_BridgeIsOn(struct vb_device_info *pVBInfo)
7697 {
7698 unsigned short flag;
7699
7700 if (pVBInfo->IF_DEF_LVDS == 1) {
7701 return 1;
7702 } else {
7703 flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00);
7704 if ((flag == 1) || (flag == 2))
7705 return 1; /* 301b */
7706 else
7707 return 0;
7708 }
7709 }
7710
XGI_LongWait(struct vb_device_info * pVBInfo)7711 void XGI_LongWait(struct vb_device_info *pVBInfo)
7712 {
7713 unsigned short i;
7714
7715 i = xgifb_reg_get(pVBInfo->P3c4, 0x1F);
7716
7717 if (!(i & 0xC0)) {
7718 for (i = 0; i < 0xFFFF; i++) {
7719 if (!(inb(pVBInfo->P3da) & 0x08))
7720 break;
7721 }
7722
7723 for (i = 0; i < 0xFFFF; i++) {
7724 if ((inb(pVBInfo->P3da) & 0x08))
7725 break;
7726 }
7727 }
7728 }
7729
XGI_VBLongWait(struct vb_device_info * pVBInfo)7730 static void XGI_VBLongWait(struct vb_device_info *pVBInfo)
7731 {
7732 unsigned short tempal, temp, i, j;
7733 return;
7734 if (!(pVBInfo->VBInfo & SetCRT2ToTV)) {
7735 temp = 0;
7736 for (i = 0; i < 3; i++) {
7737 for (j = 0; j < 100; j++) {
7738 tempal = inb(pVBInfo->P3da);
7739 if (temp & 0x01) { /* VBWaitMode2 */
7740 if ((tempal & 0x08))
7741 continue;
7742
7743 if (!(tempal & 0x08))
7744 break;
7745
7746 } else { /* VBWaitMode1 */
7747 if (!(tempal & 0x08))
7748 continue;
7749
7750 if ((tempal & 0x08))
7751 break;
7752 }
7753 }
7754 temp = temp ^ 0x01;
7755 }
7756 } else {
7757 XGI_LongWait(pVBInfo);
7758 }
7759 return;
7760 }
7761
XGI_GetRatePtrCRT2(struct xgi_hw_device_info * pXGIHWDE,unsigned short ModeNo,unsigned short ModeIdIndex,struct vb_device_info * pVBInfo)7762 unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE,
7763 unsigned short ModeNo, unsigned short ModeIdIndex,
7764 struct vb_device_info *pVBInfo)
7765 {
7766 short LCDRefreshIndex[] = { 0x00, 0x00, 0x03, 0x01 },
7767 LCDARefreshIndex[] = { 0x00, 0x00, 0x03, 0x01, 0x01,
7768 0x01, 0x01 };
7769
7770 unsigned short RefreshRateTableIndex, i, modeflag, index, temp;
7771
7772 if (ModeNo <= 0x13)
7773 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
7774 else
7775 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
7776
7777 if (pVBInfo->IF_DEF_CH7005 == 1) {
7778 if (pVBInfo->VBInfo & SetCRT2ToTV) {
7779 if (modeflag & HalfDCLK)
7780 return 0;
7781 }
7782 }
7783
7784 if (ModeNo < 0x14)
7785 return 0xFFFF;
7786
7787 index = xgifb_reg_get(pVBInfo->P3d4, 0x33);
7788 index = index >> pVBInfo->SelectCRT2Rate;
7789 index &= 0x0F;
7790
7791 if (pVBInfo->LCDInfo & LCDNonExpanding)
7792 index = 0;
7793
7794 if (index > 0)
7795 index--;
7796
7797 if (pVBInfo->SetFlag & ProgrammingCRT2) {
7798 if (pVBInfo->IF_DEF_CH7005 == 1) {
7799 if (pVBInfo->VBInfo & SetCRT2ToTV)
7800 index = 0;
7801 }
7802
7803 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) {
7804 if (pVBInfo->IF_DEF_LVDS == 0) {
7805 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B
7806 | VB_XGI301LV | VB_XGI302LV
7807 | VB_XGI301C))
7808 temp
7809 = LCDARefreshIndex[pVBInfo->LCDResInfo
7810 & 0x0F]; /* 301b */
7811 else
7812 temp
7813 = LCDRefreshIndex[pVBInfo->LCDResInfo
7814 & 0x0F];
7815
7816 if (index > temp)
7817 index = temp;
7818 } else {
7819 index = 0;
7820 }
7821 }
7822 }
7823
7824 RefreshRateTableIndex = pVBInfo->EModeIDTable[ModeIdIndex].REFindex;
7825 ModeNo = pVBInfo->RefIndex[RefreshRateTableIndex].ModeID;
7826 if (pXGIHWDE->jChipType >= XG20) { /* for XG20, XG21, XG27 */
7827 /*
7828 if (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag & XG2xNotSupport) {
7829 index++;
7830 }
7831 */
7832 if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 800)
7833 && (pVBInfo->RefIndex[RefreshRateTableIndex].YRes
7834 == 600)) {
7835 index++;
7836 }
7837 /* Alan 10/19/2007; do the similar adjustment like XGISearchCRT1Rate() */
7838 if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1024)
7839 && (pVBInfo->RefIndex[RefreshRateTableIndex].YRes
7840 == 768)) {
7841 index++;
7842 }
7843 if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1280)
7844 && (pVBInfo->RefIndex[RefreshRateTableIndex].YRes
7845 == 1024)) {
7846 index++;
7847 }
7848 }
7849
7850 i = 0;
7851 do {
7852 if (pVBInfo->RefIndex[RefreshRateTableIndex + i].ModeID
7853 != ModeNo)
7854 break;
7855 temp
7856 = pVBInfo->RefIndex[RefreshRateTableIndex + i].Ext_InfoFlag;
7857 temp &= ModeInfoFlag;
7858 if (temp < pVBInfo->ModeType)
7859 break;
7860 i++;
7861 index--;
7862
7863 } while (index != 0xFFFF);
7864 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) {
7865 if (pVBInfo->VBInfo & SetInSlaveMode) {
7866 temp
7867 = pVBInfo->RefIndex[RefreshRateTableIndex
7868 + i - 1].Ext_InfoFlag;
7869 if (temp & InterlaceMode)
7870 i++;
7871 }
7872 }
7873 i--;
7874 if ((pVBInfo->SetFlag & ProgrammingCRT2)) {
7875 temp = XGI_AjustCRT2Rate(ModeNo, ModeIdIndex,
7876 RefreshRateTableIndex, &i, pVBInfo);
7877 }
7878 return RefreshRateTableIndex + i; /* return (0x01 | (temp1<<1)); */
7879 }
7880
XGI_SetLCDAGroup(unsigned short ModeNo,unsigned short ModeIdIndex,struct xgi_hw_device_info * HwDeviceExtension,struct vb_device_info * pVBInfo)7881 static void XGI_SetLCDAGroup(unsigned short ModeNo, unsigned short ModeIdIndex,
7882 struct xgi_hw_device_info *HwDeviceExtension,
7883 struct vb_device_info *pVBInfo)
7884 {
7885 unsigned short RefreshRateTableIndex;
7886 /* unsigned short temp ; */
7887
7888 /* pVBInfo->SelectCRT2Rate = 0; */
7889
7890 pVBInfo->SetFlag |= ProgrammingCRT2;
7891 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
7892 ModeIdIndex, pVBInfo);
7893 XGI_GetLVDSResInfo(ModeNo, ModeIdIndex, pVBInfo);
7894 XGI_GetLVDSData(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
7895 XGI_ModCRT1Regs(ModeNo, ModeIdIndex, RefreshRateTableIndex,
7896 HwDeviceExtension, pVBInfo);
7897 XGI_SetLVDSRegs(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
7898 XGI_SetCRT2ECLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
7899 }
7900
XGI_SetCRT2Group301(unsigned short ModeNo,struct xgi_hw_device_info * HwDeviceExtension,struct vb_device_info * pVBInfo)7901 unsigned char XGI_SetCRT2Group301(unsigned short ModeNo,
7902 struct xgi_hw_device_info *HwDeviceExtension,
7903 struct vb_device_info *pVBInfo)
7904 {
7905 unsigned short tempbx, ModeIdIndex, RefreshRateTableIndex;
7906
7907 tempbx = pVBInfo->VBInfo;
7908 pVBInfo->SetFlag |= ProgrammingCRT2;
7909 XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo);
7910 pVBInfo->SelectCRT2Rate = 4;
7911 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
7912 ModeIdIndex, pVBInfo);
7913 XGI_SaveCRT2Info(ModeNo, pVBInfo);
7914 XGI_GetCRT2ResInfo(ModeNo, ModeIdIndex, pVBInfo);
7915 XGI_GetCRT2Data(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
7916 XGI_PreSetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension,
7917 RefreshRateTableIndex, pVBInfo);
7918 XGI_SetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension,
7919 RefreshRateTableIndex, pVBInfo);
7920 XGI_SetLockRegs(ModeNo, ModeIdIndex, HwDeviceExtension,
7921 RefreshRateTableIndex, pVBInfo);
7922 XGI_SetGroup2(ModeNo, ModeIdIndex, RefreshRateTableIndex,
7923 HwDeviceExtension, pVBInfo);
7924 XGI_SetLCDRegs(ModeNo, ModeIdIndex, HwDeviceExtension,
7925 RefreshRateTableIndex, pVBInfo);
7926 XGI_SetTap4Regs(pVBInfo);
7927 XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo);
7928 XGI_SetGroup4(ModeNo, ModeIdIndex, RefreshRateTableIndex,
7929 HwDeviceExtension, pVBInfo);
7930 XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
7931 XGI_SetGroup5(ModeNo, ModeIdIndex, pVBInfo);
7932 XGI_AutoThreshold(pVBInfo);
7933 return 1;
7934 }
7935
XGI_SenseCRT1(struct vb_device_info * pVBInfo)7936 void XGI_SenseCRT1(struct vb_device_info *pVBInfo)
7937 {
7938 unsigned char CRTCData[17] = { 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81,
7939 0x0B, 0x3E, 0xE9, 0x0B, 0xDF, 0xE7, 0x04, 0x00, 0x00,
7940 0x05, 0x00 };
7941
7942 unsigned char SR01 = 0, SR1F = 0, SR07 = 0, SR06 = 0;
7943
7944 unsigned char CR17, CR63, SR31;
7945 unsigned short temp;
7946 unsigned char DAC_TEST_PARMS[3] = { 0x0F, 0x0F, 0x0F };
7947
7948 int i;
7949 xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86);
7950
7951 /* [2004/05/06] Vicent to fix XG42 single LCD sense to CRT+LCD */
7952 xgifb_reg_set(pVBInfo->P3d4, 0x57, 0x4A);
7953 xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get(
7954 pVBInfo->P3d4, 0x53) | 0x02));
7955
7956 SR31 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x31);
7957 CR63 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x63);
7958 SR01 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x01);
7959
7960 xgifb_reg_set(pVBInfo->P3c4, 0x01, (unsigned char) (SR01 & 0xDF));
7961 xgifb_reg_set(pVBInfo->P3d4, 0x63, (unsigned char) (CR63 & 0xBF));
7962
7963 CR17 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x17);
7964 xgifb_reg_set(pVBInfo->P3d4, 0x17, (unsigned char) (CR17 | 0x80));
7965
7966 SR1F = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x1F);
7967 xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) (SR1F | 0x04));
7968
7969 SR07 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x07);
7970 xgifb_reg_set(pVBInfo->P3c4, 0x07, (unsigned char) (SR07 & 0xFB));
7971 SR06 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x06);
7972 xgifb_reg_set(pVBInfo->P3c4, 0x06, (unsigned char) (SR06 & 0xC3));
7973
7974 xgifb_reg_set(pVBInfo->P3d4, 0x11, 0x00);
7975
7976 for (i = 0; i < 8; i++)
7977 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) i, CRTCData[i]);
7978
7979 for (i = 8; i < 11; i++)
7980 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 8),
7981 CRTCData[i]);
7982
7983 for (i = 11; i < 13; i++)
7984 xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 4),
7985 CRTCData[i]);
7986
7987 for (i = 13; i < 16; i++)
7988 xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i - 3),
7989 CRTCData[i]);
7990
7991 xgifb_reg_set(pVBInfo->P3c4, 0x0E, (unsigned char) (CRTCData[16]
7992 & 0xE0));
7993
7994 xgifb_reg_set(pVBInfo->P3c4, 0x31, 0x00);
7995 xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x1B);
7996 xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE1);
7997
7998 outb(0x00, pVBInfo->P3c8);
7999
8000 for (i = 0; i < 256; i++) {
8001 outb((unsigned char) DAC_TEST_PARMS[0], (pVBInfo->P3c8 + 1));
8002 outb((unsigned char) DAC_TEST_PARMS[1], (pVBInfo->P3c8 + 1));
8003 outb((unsigned char) DAC_TEST_PARMS[2], (pVBInfo->P3c8 + 1));
8004 }
8005
8006 XGI_VBLongWait(pVBInfo);
8007 XGI_VBLongWait(pVBInfo);
8008 XGI_VBLongWait(pVBInfo);
8009
8010 mdelay(1);
8011
8012 XGI_WaitDisply(pVBInfo);
8013 temp = inb(pVBInfo->P3c2);
8014
8015 if (temp & 0x10)
8016 xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x20);
8017 else
8018 xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x00);
8019
8020 /* alan, avoid display something, set BLACK DAC if not restore DAC */
8021 outb(0x00, pVBInfo->P3c8);
8022
8023 for (i = 0; i < 256; i++) {
8024 outb(0, (pVBInfo->P3c8 + 1));
8025 outb(0, (pVBInfo->P3c8 + 1));
8026 outb(0, (pVBInfo->P3c8 + 1));
8027 }
8028
8029 xgifb_reg_set(pVBInfo->P3c4, 0x01, SR01);
8030 xgifb_reg_set(pVBInfo->P3d4, 0x63, CR63);
8031 xgifb_reg_set(pVBInfo->P3c4, 0x31, SR31);
8032
8033 /* [2004/05/11] Vicent */
8034 xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get(
8035 pVBInfo->P3d4, 0x53) & 0xFD));
8036 xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) SR1F);
8037 }
8038
XGI_EnableBridge(struct xgi_hw_device_info * HwDeviceExtension,struct vb_device_info * pVBInfo)8039 void XGI_EnableBridge(struct xgi_hw_device_info *HwDeviceExtension,
8040 struct vb_device_info *pVBInfo)
8041 {
8042 unsigned short tempah;
8043
8044 if (pVBInfo->SetFlag == Win9xDOSMode) {
8045 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8046 | VB_XGI302LV | VB_XGI301C)) {
8047 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
8048 return;
8049 } else
8050 /* LVDS or CH7017 */
8051 return;
8052 }
8053
8054 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8055 | VB_XGI302LV | VB_XGI301C)) {
8056 if (!(pVBInfo->SetFlag & DisableChA)) {
8057 if (pVBInfo->SetFlag & EnableChA) {
8058 xgifb_reg_set(pVBInfo->Part1Port, 0x1E, 0x20); /* Power on */
8059 } else {
8060 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { /* SetCRT2ToLCDA ) */
8061 xgifb_reg_set(pVBInfo->Part1Port,
8062 0x1E, 0x20); /* Power on */
8063 }
8064 }
8065 }
8066
8067 if (!(pVBInfo->SetFlag & DisableChB)) {
8068 if ((pVBInfo->SetFlag & EnableChB) || (pVBInfo->VBInfo
8069 & (SetCRT2ToLCD | SetCRT2ToTV
8070 | SetCRT2ToRAMDAC))) {
8071 tempah = (unsigned char) xgifb_reg_get(
8072 pVBInfo->P3c4, 0x32);
8073 tempah &= 0xDF;
8074 if (pVBInfo->VBInfo & SetInSlaveMode) {
8075 if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC))
8076 tempah |= 0x20;
8077 }
8078 xgifb_reg_set(pVBInfo->P3c4, 0x32, tempah);
8079 xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x20);
8080
8081 tempah = (unsigned char) xgifb_reg_get(
8082 pVBInfo->Part1Port, 0x2E);
8083
8084 if (!(tempah & 0x80))
8085 xgifb_reg_or(pVBInfo->Part1Port,
8086 0x2E, 0x80); /* BVBDOENABLE = 1 */
8087
8088 xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F); /* BScreenOFF = 0 */
8089 }
8090 }
8091
8092 if ((pVBInfo->SetFlag & (EnableChA | EnableChB))
8093 || (!(pVBInfo->VBInfo & DisableCRT2Display))) {
8094 xgifb_reg_and_or(pVBInfo->Part2Port, 0x00, ~0xE0,
8095 0x20); /* shampoo 0129 */
8096 if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) {
8097 if (!XGI_DisableChISLCD(pVBInfo)) {
8098 if (XGI_EnableChISLCD(pVBInfo)
8099 || (pVBInfo->VBInfo
8100 & (SetCRT2ToLCD
8101 | SetCRT2ToLCDA)))
8102 xgifb_reg_and(
8103 pVBInfo->Part4Port,
8104 0x2A, 0x7F); /* LVDS PLL power on */
8105 }
8106 xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x7F); /* LVDS Driver power on */
8107 }
8108 }
8109
8110 tempah = 0x00;
8111
8112 if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
8113 tempah = 0xc0;
8114
8115 if (!(pVBInfo->VBInfo & SetSimuScanMode)) {
8116 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
8117 if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
8118 tempah = tempah & 0x40;
8119 if (pVBInfo->VBInfo
8120 & SetCRT2ToLCDA)
8121 tempah = tempah ^ 0xC0;
8122
8123 if (pVBInfo->SetFlag
8124 & DisableChB)
8125 tempah &= 0xBF;
8126
8127 if (pVBInfo->SetFlag
8128 & DisableChA)
8129 tempah &= 0x7F;
8130
8131 if (pVBInfo->SetFlag
8132 & EnableChB)
8133 tempah |= 0x40;
8134
8135 if (pVBInfo->SetFlag
8136 & EnableChA)
8137 tempah |= 0x80;
8138 }
8139 }
8140 }
8141 }
8142
8143 xgifb_reg_or(pVBInfo->Part4Port, 0x1F, tempah); /* EnablePart4_1F */
8144
8145 if (pVBInfo->SetFlag & Win9xDOSMode) {
8146 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
8147 return;
8148 }
8149
8150 if (!(pVBInfo->SetFlag & DisableChA)) {
8151 XGI_VBLongWait(pVBInfo);
8152 if (!(pVBInfo->SetFlag & GatingCRT)) {
8153 XGI_DisableGatingCRT(HwDeviceExtension, pVBInfo);
8154 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
8155 XGI_VBLongWait(pVBInfo);
8156 }
8157 }
8158 } /* 301 */
8159 else { /* LVDS */
8160 if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD
8161 | SetCRT2ToLCDA))
8162 xgifb_reg_or(pVBInfo->Part1Port, 0x1E, 0x20); /* enable CRT2 */
8163
8164 tempah = (unsigned char) xgifb_reg_get(pVBInfo->Part1Port,
8165 0x2E);
8166 if (!(tempah & 0x80))
8167 xgifb_reg_or(pVBInfo->Part1Port, 0x2E, 0x80); /* BVBDOENABLE = 1 */
8168
8169 xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F);
8170 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
8171 } /* End of VB */
8172 }
8173
XGI_SetCRT1Group(struct xgi_hw_device_info * HwDeviceExtension,unsigned short ModeNo,unsigned short ModeIdIndex,struct vb_device_info * pVBInfo)8174 static void XGI_SetCRT1Group(struct xgi_hw_device_info *HwDeviceExtension,
8175 unsigned short ModeNo, unsigned short ModeIdIndex,
8176 struct vb_device_info *pVBInfo)
8177 {
8178 unsigned short StandTableIndex, RefreshRateTableIndex, b3CC, temp;
8179
8180 unsigned short XGINew_P3cc = pVBInfo->P3cc;
8181
8182 /* XGINew_CRT1Mode = ModeNo; // SaveModeID */
8183 StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
8184 /* XGI_SetBIOSData(ModeNo, ModeIdIndex); */
8185 /* XGI_ClearBankRegs(ModeNo, ModeIdIndex); */
8186 XGI_SetSeqRegs(ModeNo, StandTableIndex, ModeIdIndex, pVBInfo);
8187 XGI_SetMiscRegs(StandTableIndex, pVBInfo);
8188 XGI_SetCRTCRegs(HwDeviceExtension, StandTableIndex, pVBInfo);
8189 XGI_SetATTRegs(ModeNo, StandTableIndex, ModeIdIndex, pVBInfo);
8190 XGI_SetGRCRegs(StandTableIndex, pVBInfo);
8191 XGI_ClearExt1Regs(pVBInfo);
8192
8193 /* if (pVBInfo->IF_DEF_ExpLink) */
8194 if (HwDeviceExtension->jChipType == XG27) {
8195 if (pVBInfo->IF_DEF_LVDS == 0)
8196 XGI_SetDefaultVCLK(pVBInfo);
8197 }
8198
8199 temp = ~ProgrammingCRT2;
8200 pVBInfo->SetFlag &= temp;
8201 pVBInfo->SelectCRT2Rate = 0;
8202
8203 if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV
8204 | VB_XGI302LV | VB_XGI301C)) {
8205 if (pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToLCDA
8206 | SetInSlaveMode)) {
8207 pVBInfo->SetFlag |= ProgrammingCRT2;
8208 }
8209 }
8210
8211 RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
8212 ModeIdIndex, pVBInfo);
8213 if (RefreshRateTableIndex != 0xFFFF) {
8214 XGI_SetSync(RefreshRateTableIndex, pVBInfo);
8215 XGI_SetCRT1CRTC(ModeNo, ModeIdIndex, RefreshRateTableIndex,
8216 pVBInfo, HwDeviceExtension);
8217 XGI_SetCRT1DE(HwDeviceExtension, ModeNo, ModeIdIndex,
8218 RefreshRateTableIndex, pVBInfo);
8219 XGI_SetCRT1Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
8220 HwDeviceExtension, pVBInfo);
8221 XGI_SetCRT1VCLK(ModeNo, ModeIdIndex, HwDeviceExtension,
8222 RefreshRateTableIndex, pVBInfo);
8223 }
8224
8225 if ((HwDeviceExtension->jChipType >= XG20)
8226 && (HwDeviceExtension->jChipType < XG27)) { /* fix H/W DCLK/2 bug */
8227 if ((ModeNo == 0x00) | (ModeNo == 0x01)) {
8228 xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x4E);
8229 xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE9);
8230 b3CC = (unsigned char) inb(XGINew_P3cc);
8231 outb((b3CC |= 0x0C), XGINew_P3cc);
8232 } else if ((ModeNo == 0x04) | (ModeNo == 0x05) | (ModeNo
8233 == 0x0D)) {
8234 xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x1B);
8235 xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE3);
8236 b3CC = (unsigned char) inb(XGINew_P3cc);
8237 outb((b3CC |= 0x0C), XGINew_P3cc);
8238 }
8239 }
8240
8241 if (HwDeviceExtension->jChipType >= XG21) {
8242 temp = xgifb_reg_get(pVBInfo->P3d4, 0x38);
8243 if (temp & 0xA0) {
8244
8245 /* xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x20); *//* Enable write GPIOF */
8246 /* xgifb_reg_and(pVBInfo->P3d4, 0x48, ~0x20); *//* P. DWN */
8247 /* XG21 CRT1 Timing */
8248 if (HwDeviceExtension->jChipType == XG27)
8249 XGI_SetXG27CRTC(ModeNo, ModeIdIndex,
8250 RefreshRateTableIndex, pVBInfo);
8251 else
8252 XGI_SetXG21CRTC(ModeNo, ModeIdIndex,
8253 RefreshRateTableIndex, pVBInfo);
8254
8255 XGI_UpdateXG21CRTC(ModeNo, pVBInfo,
8256 RefreshRateTableIndex);
8257
8258 if (HwDeviceExtension->jChipType == XG27)
8259 XGI_SetXG27LCD(pVBInfo, RefreshRateTableIndex,
8260 ModeNo);
8261 else
8262 XGI_SetXG21LCD(pVBInfo, RefreshRateTableIndex,
8263 ModeNo);
8264
8265 if (pVBInfo->IF_DEF_LVDS == 1) {
8266 if (HwDeviceExtension->jChipType == XG27)
8267 XGI_SetXG27LVDSPara(ModeNo,
8268 ModeIdIndex, pVBInfo);
8269 else
8270 XGI_SetXG21LVDSPara(ModeNo,
8271 ModeIdIndex, pVBInfo);
8272 }
8273 /* xgifb_reg_or(pVBInfo->P3d4, 0x48, 0x20); *//* P. ON */
8274 }
8275 }
8276
8277 pVBInfo->SetFlag &= (~ProgrammingCRT2);
8278 XGI_SetCRT1FIFO(ModeNo, HwDeviceExtension, pVBInfo);
8279 XGI_SetCRT1ModeRegs(HwDeviceExtension, ModeNo, ModeIdIndex,
8280 RefreshRateTableIndex, pVBInfo);
8281
8282 /* XGI_LoadCharacter(); //dif ifdef TVFont */
8283
8284 XGI_LoadDAC(ModeNo, ModeIdIndex, pVBInfo);
8285 /* XGI_ClearBuffer(HwDeviceExtension, ModeNo, pVBInfo); */
8286 }
8287
XGISetModeNew(struct xgi_hw_device_info * HwDeviceExtension,unsigned short ModeNo)8288 unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension,
8289 unsigned short ModeNo)
8290 {
8291 unsigned short ModeIdIndex;
8292 /* unsigned char *pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress; */
8293 struct vb_device_info VBINF;
8294 struct vb_device_info *pVBInfo = &VBINF;
8295 pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase;
8296 pVBInfo->BaseAddr = (unsigned long) HwDeviceExtension->pjIOAddress;
8297 pVBInfo->IF_DEF_LVDS = 0;
8298 pVBInfo->IF_DEF_CH7005 = 0;
8299 pVBInfo->IF_DEF_LCDA = 1;
8300 pVBInfo->IF_DEF_CH7017 = 0;
8301 pVBInfo->IF_DEF_CH7007 = 0; /* [Billy] 2007/05/14 */
8302 pVBInfo->IF_DEF_VideoCapture = 0;
8303 pVBInfo->IF_DEF_ScaleLCD = 0;
8304 pVBInfo->IF_DEF_OEMUtil = 0;
8305 pVBInfo->IF_DEF_PWD = 0;
8306
8307 if (HwDeviceExtension->jChipType >= XG20) { /* kuku 2004/06/25 */
8308 pVBInfo->IF_DEF_YPbPr = 0;
8309 pVBInfo->IF_DEF_HiVision = 0;
8310 pVBInfo->IF_DEF_CRT2Monitor = 0;
8311 pVBInfo->VBType = 0; /*set VBType default 0*/
8312 } else {
8313 pVBInfo->IF_DEF_YPbPr = 1;
8314 pVBInfo->IF_DEF_HiVision = 1;
8315 pVBInfo->IF_DEF_CRT2Monitor = 1;
8316 }
8317
8318 pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14;
8319 pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24;
8320 pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10;
8321 pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e;
8322 pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12;
8323 pVBInfo->P3cc = pVBInfo->BaseAddr + 0x1C;
8324 pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a;
8325 pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16;
8326 pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17;
8327 pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18;
8328 pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19;
8329 pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A;
8330 pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00;
8331 pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04;
8332 pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10;
8333 pVBInfo->Part3Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_12;
8334 pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14;
8335 pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2;
8336
8337 if (HwDeviceExtension->jChipType == XG21) { /* for x86 Linux, XG21 LVDS */
8338 if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0)
8339 pVBInfo->IF_DEF_LVDS = 1;
8340 }
8341 if (HwDeviceExtension->jChipType == XG27) {
8342 if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) {
8343 if (xgifb_reg_get(pVBInfo->P3d4, 0x30) & 0x20)
8344 pVBInfo->IF_DEF_LVDS = 1;
8345 }
8346 }
8347
8348 if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 */
8349 XGI_GetVBType(pVBInfo);
8350
8351 InitTo330Pointer(HwDeviceExtension->jChipType, pVBInfo);
8352 if (ModeNo & 0x80) {
8353 ModeNo = ModeNo & 0x7F;
8354 /* XGINew_flag_clearbuffer = 0; */
8355 }
8356 /* else {
8357 XGINew_flag_clearbuffer = 1;
8358 }
8359 */
8360 xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86);
8361
8362 if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 1.Openkey */
8363 XGI_UnLockCRT2(HwDeviceExtension, pVBInfo);
8364
8365 XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo);
8366
8367 XGI_GetVGAType(HwDeviceExtension, pVBInfo);
8368
8369 if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */
8370 XGI_GetVBInfo(ModeNo, ModeIdIndex, HwDeviceExtension, pVBInfo);
8371 XGI_GetTVInfo(ModeNo, ModeIdIndex, pVBInfo);
8372 XGI_GetLCDInfo(ModeNo, ModeIdIndex, pVBInfo);
8373 XGI_DisableBridge(HwDeviceExtension, pVBInfo);
8374 /* XGI_OpenCRTC(HwDeviceExtension, pVBInfo); */
8375
8376 if (pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToLCDA)) {
8377 XGI_SetCRT1Group(HwDeviceExtension, ModeNo,
8378 ModeIdIndex, pVBInfo);
8379
8380 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
8381 XGI_SetLCDAGroup(ModeNo, ModeIdIndex,
8382 HwDeviceExtension, pVBInfo);
8383 }
8384 } else {
8385 if (!(pVBInfo->VBInfo & SwitchToCRT2)) {
8386 XGI_SetCRT1Group(HwDeviceExtension, ModeNo,
8387 ModeIdIndex, pVBInfo);
8388 if (pVBInfo->VBInfo & SetCRT2ToLCDA) {
8389 XGI_SetLCDAGroup(ModeNo, ModeIdIndex,
8390 HwDeviceExtension,
8391 pVBInfo);
8392 }
8393 }
8394 }
8395
8396 if (pVBInfo->VBInfo & (SetSimuScanMode | SwitchToCRT2)) {
8397 switch (HwDeviceExtension->ujVBChipID) {
8398 case VB_CHIP_301:
8399 XGI_SetCRT2Group301(ModeNo, HwDeviceExtension,
8400 pVBInfo); /*add for CRT2 */
8401 break;
8402
8403 case VB_CHIP_302:
8404 XGI_SetCRT2Group301(ModeNo, HwDeviceExtension,
8405 pVBInfo); /*add for CRT2 */
8406 break;
8407
8408 default:
8409 break;
8410 }
8411 }
8412
8413 XGI_SetCRT2ModeRegs(ModeNo, HwDeviceExtension, pVBInfo);
8414 XGI_OEM310Setting(ModeNo, ModeIdIndex, pVBInfo); /*0212*/
8415 XGI_CloseCRTC(HwDeviceExtension, pVBInfo);
8416 XGI_EnableBridge(HwDeviceExtension, pVBInfo);
8417 } /* !XG20 */
8418 else {
8419 if (pVBInfo->IF_DEF_LVDS == 1)
8420 if (!XGI_XG21CheckLVDSMode(ModeNo, ModeIdIndex, pVBInfo))
8421 return 0;
8422
8423 if (ModeNo <= 0x13) {
8424 pVBInfo->ModeType
8425 = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag
8426 & ModeInfoFlag;
8427 } else {
8428 pVBInfo->ModeType
8429 = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag
8430 & ModeInfoFlag;
8431 }
8432
8433 pVBInfo->SetFlag = 0;
8434 if (pVBInfo->IF_DEF_CH7007 != 1)
8435 pVBInfo->VBInfo = DisableCRT2Display;
8436
8437 XGI_DisplayOff(HwDeviceExtension, pVBInfo);
8438
8439 XGI_SetCRT1Group(HwDeviceExtension, ModeNo, ModeIdIndex,
8440 pVBInfo);
8441
8442 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
8443 /*
8444 if (HwDeviceExtension->jChipType == XG21)
8445 xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0x80, 0x80);
8446 */
8447 }
8448
8449 /*
8450 if (ModeNo <= 0x13) {
8451 modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
8452 } else {
8453 modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
8454 }
8455 pVBInfo->ModeType = modeflag&ModeInfoFlag;
8456 pVBInfo->SetFlag = 0x00;
8457 pVBInfo->VBInfo = DisableCRT2Display;
8458 temp = XGINew_CheckMemorySize(HwDeviceExtension, ModeNo, ModeIdIndex, pVBInfo);
8459
8460 if (temp == 0)
8461 return (0);
8462
8463 XGI_DisplayOff(HwDeviceExtension, pVBInfo) ;
8464 XGI_SetCRT1Group(HwDeviceExtension, ModeNo, ModeIdIndex, pVBInfo);
8465 XGI_DisplayOn(HwDeviceExtension, pVBInfo);
8466 */
8467
8468 XGI_UpdateModeInfo(HwDeviceExtension, pVBInfo);
8469
8470 if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */
8471 XGI_LockCRT2(HwDeviceExtension, pVBInfo);
8472 }
8473
8474 return 1;
8475 }
8476