]>
Commit | Line | Data |
---|---|---|
d7636e0b | 1 | |
d7636e0b | 2 | #include <asm/io.h> |
d80aaa01 | 3 | #include <linux/delay.h> |
d7636e0b | 4 | #include <linux/types.h> |
5 | #include <linux/version.h> | |
6 | #include "XGIfb.h" | |
d7636e0b | 7 | |
d7636e0b | 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" | |
5e60b97c | 14 | #include "vb_setmode.h" |
d7636e0b | 15 | |
16 | ||
17 | #define IndexMask 0xff | |
18 | #ifndef XGI_MASK_DUAL_CHIP | |
19 | #define XGI_MASK_DUAL_CHIP 0x04 /* SR3A */ | |
20 | #endif | |
21 | ||
8922967e | 22 | static unsigned short XGINew_MDA_DAC[] = { |
82d6eb5b BP |
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 | ||
8922967e | 32 | static unsigned short XGINew_CGA_DAC[] = { |
82d6eb5b BP |
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 | ||
8922967e | 42 | static unsigned short XGINew_EGA_DAC[] = { |
82d6eb5b BP |
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 | ||
8922967e | 52 | static unsigned short XGINew_VGA_DAC[] = { |
82d6eb5b BP |
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}; | |
d7636e0b | 63 | |
80adad85 | 64 | void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo) |
d7636e0b | 65 | { |
21df8fc8 PS |
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 | ||
06587335 AK |
77 | pVBInfo->MCLKData = (struct XGI_MCLKDataStruct *) XGI340New_MCLKData; |
78 | pVBInfo->ECLKData = (struct XGI_ECLKDataStruct *) XGI340_ECLKData; | |
21df8fc8 PS |
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; | |
d7636e0b | 157 | |
21df8fc8 PS |
158 | if ((ChipType == XG21) || (ChipType == XG27)) |
159 | pVBInfo->XG21_LVDSCapList = XGI21_LCDCapList; | |
d7636e0b | 160 | |
21df8fc8 PS |
161 | pVBInfo->XGI_TVDelayList = XGI301TVDelayList; |
162 | pVBInfo->XGI_TVDelayList2 = XGI301TVDelayList2; | |
d7636e0b | 163 | |
21df8fc8 | 164 | pVBInfo->pXGINew_I2CDefinition = &XG40_I2CDefinition; |
d7636e0b | 165 | |
21df8fc8 PS |
166 | if (ChipType >= XG20) |
167 | pVBInfo->pXGINew_CR97 = &XG20_CR97; | |
d7636e0b | 168 | |
21df8fc8 PS |
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 | } | |
d7636e0b | 192 | |
cc1e2398 AK |
193 | static unsigned char XGI_GetModePtr(unsigned short ModeNo, unsigned short ModeIdIndex, |
194 | struct vb_device_info *pVBInfo) | |
21df8fc8 | 195 | { |
cc1e2398 | 196 | unsigned char index; |
21df8fc8 | 197 | |
cc1e2398 AK |
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; | |
21df8fc8 | 205 | } |
cc1e2398 AK |
206 | return index; /* Get pVBInfo->StandTable index */ |
207 | } | |
d7636e0b | 208 | |
cc1e2398 AK |
209 | /* |
210 | unsigned char XGI_SetBIOSData(unsigned short ModeNo, unsigned short ModeIdIndex) { | |
211 | return (0); | |
212 | } | |
213 | */ | |
21df8fc8 | 214 | |
cc1e2398 AK |
215 | /* unsigned char XGI_ClearBankRegs(unsigned short ModeNo, unsigned short ModeIdIndex) { |
216 | return( 0 ) ; | |
217 | } | |
218 | */ | |
219 | ||
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 | ||
8104e329 | 232 | xgifb_reg_set(pVBInfo->P3c4, 0x00, 0x03); /* Set SR0 */ |
cc1e2398 AK |
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; | |
21df8fc8 PS |
242 | } |
243 | } | |
d7636e0b | 244 | |
cc1e2398 | 245 | tempah |= 0x20; /* screen off */ |
8104e329 | 246 | xgifb_reg_set(pVBInfo->P3c4, 0x01, tempah); /* Set SR1 */ |
d7636e0b | 247 | |
cc1e2398 AK |
248 | for (i = 02; i <= 04; i++) { |
249 | SRdata = pVBInfo->StandTable[StandTableIndex].SR[i - 1]; /* Get SR2,3,4 from file */ | |
8104e329 | 250 | xgifb_reg_set(pVBInfo->P3c4, i, SRdata); /* Set SR2 3 4 */ |
21df8fc8 | 251 | } |
cc1e2398 AK |
252 | } |
253 | ||
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 | } | |
21df8fc8 PS |
265 | } |
266 | */ | |
21df8fc8 | 267 | |
efdf4ee7 | 268 | outb(Miscdata, pVBInfo->P3c2); /* Set Misc(3c2) */ |
cc1e2398 | 269 | } |
21df8fc8 | 270 | |
cc1e2398 AK |
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; | |
21df8fc8 | 276 | |
58839b01 | 277 | CRTCdata = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
cc1e2398 | 278 | CRTCdata &= 0x7f; |
8104e329 | 279 | xgifb_reg_set(pVBInfo->P3d4, 0x11, CRTCdata); /* Unlock CRTC */ |
21df8fc8 | 280 | |
cc1e2398 AK |
281 | for (i = 0; i <= 0x18; i++) { |
282 | CRTCdata = pVBInfo->StandTable[StandTableIndex].CRTC[i]; /* Get CRTC from file */ | |
8104e329 | 283 | xgifb_reg_set(pVBInfo->P3d4, i, CRTCdata); /* Set CRTC(3d4) */ |
cc1e2398 AK |
284 | } |
285 | /* | |
286 | if ((HwDeviceExtension->jChipType == XGI_630) && (HwDeviceExtension->jChipRevision == 0x30)) { | |
287 | if (pVBInfo->VBInfo & SetInSlaveMode) { | |
288 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) { | |
8104e329 | 289 | xgifb_reg_set(pVBInfo->P3d4, 0x18, 0xFE); |
cc1e2398 AK |
290 | } |
291 | } | |
292 | } | |
293 | */ | |
294 | } | |
21df8fc8 | 295 | |
cc1e2398 AK |
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; | |
21df8fc8 | 301 | |
cc1e2398 AK |
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) { | |
21df8fc8 | 311 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { |
cc1e2398 AK |
312 | ARdata = 0; |
313 | } else { | |
314 | if (pVBInfo->VBInfo & (SetCRT2ToTV | |
315 | | SetCRT2ToLCD)) { | |
316 | if (pVBInfo->VBInfo | |
317 | & SetInSlaveMode) | |
318 | ARdata = 0; | |
319 | } | |
21df8fc8 PS |
320 | } |
321 | } | |
322 | } | |
323 | ||
d8ad0a6d | 324 | inb(pVBInfo->P3da); /* reset 3da */ |
efdf4ee7 AK |
325 | outb(i, pVBInfo->P3c0); /* set index */ |
326 | outb(ARdata, pVBInfo->P3c0); /* set data */ | |
cc1e2398 | 327 | } |
21df8fc8 | 328 | |
d8ad0a6d | 329 | inb(pVBInfo->P3da); /* reset 3da */ |
efdf4ee7 AK |
330 | outb(0x14, pVBInfo->P3c0); /* set index */ |
331 | outb(0x00, pVBInfo->P3c0); /* set data */ | |
d8ad0a6d | 332 | inb(pVBInfo->P3da); /* Enable Attribute */ |
efdf4ee7 | 333 | outb(0x20, pVBInfo->P3c0); |
cc1e2398 | 334 | } |
21df8fc8 | 335 | |
cc1e2398 AK |
336 | static void XGI_SetGRCRegs(unsigned short StandTableIndex, |
337 | struct vb_device_info *pVBInfo) | |
338 | { | |
339 | unsigned char GRdata; | |
340 | unsigned short i; | |
21df8fc8 | 341 | |
cc1e2398 AK |
342 | for (i = 0; i <= 0x08; i++) { |
343 | GRdata = pVBInfo->StandTable[StandTableIndex].GRC[i]; /* Get GR from file */ | |
8104e329 | 344 | xgifb_reg_set(pVBInfo->P3ce, i, GRdata); /* Set GR(3ce) */ |
cc1e2398 | 345 | } |
21df8fc8 | 346 | |
cc1e2398 | 347 | if (pVBInfo->ModeType > ModeVGA) { |
58839b01 | 348 | GRdata = (unsigned char) xgifb_reg_get(pVBInfo->P3ce, 0x05); |
cc1e2398 | 349 | GRdata &= 0xBF; /* 256 color disable */ |
8104e329 | 350 | xgifb_reg_set(pVBInfo->P3ce, 0x05, GRdata); |
21df8fc8 | 351 | } |
cc1e2398 | 352 | } |
d7636e0b | 353 | |
cc1e2398 AK |
354 | static void XGI_ClearExt1Regs(struct vb_device_info *pVBInfo) |
355 | { | |
356 | unsigned short i; | |
d7636e0b | 357 | |
cc1e2398 | 358 | for (i = 0x0A; i <= 0x0E; i++) |
8104e329 | 359 | xgifb_reg_set(pVBInfo->P3c4, i, 0x00); /* Clear SR0A-SR0E */ |
cc1e2398 | 360 | } |
d7636e0b | 361 | |
cc1e2398 AK |
362 | static unsigned char XGI_SetDefaultVCLK(struct vb_device_info *pVBInfo) |
363 | { | |
d7636e0b | 364 | |
ec9e5d3e | 365 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x20); |
8104e329 AK |
366 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, pVBInfo->VCLKData[0].SR2B); |
367 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, pVBInfo->VCLKData[0].SR2C); | |
21df8fc8 | 368 | |
ec9e5d3e | 369 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x10); |
8104e329 AK |
370 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, pVBInfo->VCLKData[1].SR2B); |
371 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, pVBInfo->VCLKData[1].SR2C); | |
21df8fc8 | 372 | |
dc50556b | 373 | xgifb_reg_and(pVBInfo->P3c4, 0x31, ~0x30); |
cc1e2398 | 374 | return 0; |
d7636e0b | 375 | } |
376 | ||
cc1e2398 AK |
377 | static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo, |
378 | unsigned short ModeIdIndex, | |
379 | unsigned short RefreshRateTableIndex, unsigned short *i, | |
21df8fc8 PS |
380 | struct vb_device_info *pVBInfo) |
381 | { | |
cc1e2398 | 382 | unsigned short tempax, tempbx, resinfo, modeflag, infoflag; |
21df8fc8 | 383 | |
cc1e2398 AK |
384 | if (ModeNo <= 0x13) |
385 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ModeFlag */ | |
386 | else | |
387 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
21df8fc8 | 388 | |
cc1e2398 AK |
389 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
390 | tempbx = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID; | |
391 | tempax = 0; | |
21df8fc8 | 392 | |
cc1e2398 AK |
393 | if (pVBInfo->IF_DEF_LVDS == 0) { |
394 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { | |
395 | tempax |= SupportRAMDAC2; | |
21df8fc8 | 396 | |
cc1e2398 AK |
397 | if (pVBInfo->VBType & VB_XGI301C) |
398 | tempax |= SupportCRT2in301C; | |
21df8fc8 | 399 | } |
21df8fc8 | 400 | |
cc1e2398 AK |
401 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { /* 301b */ |
402 | tempax |= SupportLCD; | |
21df8fc8 | 403 | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 414 | } |
21df8fc8 | 415 | |
cc1e2398 AK |
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; | |
21df8fc8 | 423 | |
cc1e2398 AK |
424 | if (resinfo == 3) |
425 | return 0; | |
21df8fc8 | 426 | |
cc1e2398 AK |
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; | |
21df8fc8 | 435 | |
cc1e2398 AK |
436 | if (resinfo == 3) { |
437 | if (pVBInfo->SetFlag | |
438 | & TVSimuMode) | |
439 | return 0; | |
440 | } | |
21df8fc8 | 441 | |
cc1e2398 AK |
442 | if (resinfo > 7) |
443 | return 0; | |
444 | } | |
21df8fc8 | 445 | } |
cc1e2398 AK |
446 | } else { |
447 | if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO | |
448 | | SetCRT2ToSVIDEO | SetCRT2ToSCART | |
449 | | SetCRT2ToYPbPr | SetCRT2ToHiVisionTV)) { | |
450 | tempax |= SupportTV; | |
21df8fc8 | 451 | |
cc1e2398 AK |
452 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B |
453 | | VB_XGI301LV | VB_XGI302LV | |
454 | | VB_XGI301C)) { | |
455 | tempax |= SupportTV1024; | |
456 | } | |
21df8fc8 | 457 | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 476 | |
cc1e2398 AK |
477 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
478 | tempax |= SupportLCD; | |
d7636e0b | 479 | |
cc1e2398 AK |
480 | if (resinfo > 0x08) |
481 | return 0; /* 1024x768 */ | |
d7636e0b | 482 | |
cc1e2398 AK |
483 | if (pVBInfo->LCDResInfo < Panel1024x768) { |
484 | if (resinfo > 0x07) | |
485 | return 0; /* 800x600 */ | |
d7636e0b | 486 | |
cc1e2398 AK |
487 | if (resinfo == 0x04) |
488 | return 0; /* 512x384 */ | |
489 | } | |
490 | } | |
491 | } | |
21df8fc8 | 492 | |
cc1e2398 AK |
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; | |
21df8fc8 | 499 | |
cc1e2398 AK |
500 | if ((*i) == 0) |
501 | break; | |
21df8fc8 | 502 | } |
d7636e0b | 503 | |
cc1e2398 AK |
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 | } | |
d7636e0b | 512 | |
cc1e2398 AK |
513 | if (infoflag & tempax) |
514 | return 1; | |
21df8fc8 | 515 | } |
cc1e2398 | 516 | return 1; |
d7636e0b | 517 | } |
518 | ||
cc1e2398 | 519 | static void XGI_SetSync(unsigned short RefreshRateTableIndex, |
21df8fc8 | 520 | struct vb_device_info *pVBInfo) |
d7636e0b | 521 | { |
cc1e2398 | 522 | unsigned short sync, temp; |
d7636e0b | 523 | |
cc1e2398 AK |
524 | sync = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag >> 8; /* di+0x00 */ |
525 | sync &= 0xC0; | |
526 | temp = 0x2F; | |
527 | temp |= sync; | |
efdf4ee7 | 528 | outb(temp, pVBInfo->P3c2); /* Set Misc(3c2) */ |
d7636e0b | 529 | } |
530 | ||
cc1e2398 AK |
531 | static void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo, |
532 | struct xgi_hw_device_info *HwDeviceExtension) | |
d7636e0b | 533 | { |
cc1e2398 AK |
534 | unsigned char data, data1, pushax; |
535 | unsigned short i, j; | |
d7636e0b | 536 | |
8104e329 AK |
537 | /* xgifb_reg_set(pVBInfo->P3d4, 0x51, 0); */ |
538 | /* xgifb_reg_set(pVBInfo->P3d4, 0x56, 0); */ | |
ec9e5d3e | 539 | /* xgifb_reg_and_or(pVBInfo->P3d4, 0x11, 0x7f, 0x00); */ |
d7636e0b | 540 | |
58839b01 | 541 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); /* unlock cr0-7 */ |
cc1e2398 | 542 | data &= 0x7F; |
8104e329 | 543 | xgifb_reg_set(pVBInfo->P3d4, 0x11, data); |
cc1e2398 AK |
544 | |
545 | data = pVBInfo->TimingH[0].data[0]; | |
8104e329 | 546 | xgifb_reg_set(pVBInfo->P3d4, 0, data); |
cc1e2398 AK |
547 | |
548 | for (i = 0x01; i <= 0x04; i++) { | |
549 | data = pVBInfo->TimingH[0].data[i]; | |
8104e329 | 550 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 1), data); |
21df8fc8 | 551 | } |
d7636e0b | 552 | |
cc1e2398 AK |
553 | for (i = 0x05; i <= 0x06; i++) { |
554 | data = pVBInfo->TimingH[0].data[i]; | |
8104e329 | 555 | xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i + 6), data); |
cc1e2398 | 556 | } |
d7636e0b | 557 | |
58839b01 | 558 | j = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0e); |
cc1e2398 AK |
559 | j &= 0x1F; |
560 | data = pVBInfo->TimingH[0].data[7]; | |
561 | data &= 0xE0; | |
562 | data |= j; | |
8104e329 | 563 | xgifb_reg_set(pVBInfo->P3c4, 0x0e, data); |
21df8fc8 | 564 | |
cc1e2398 | 565 | if (HwDeviceExtension->jChipType >= XG20) { |
58839b01 | 566 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x04); |
cc1e2398 | 567 | data = data - 1; |
8104e329 | 568 | xgifb_reg_set(pVBInfo->P3d4, 0x04, data); |
58839b01 | 569 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x05); |
cc1e2398 AK |
570 | data1 = data; |
571 | data1 &= 0xE0; | |
572 | data &= 0x1F; | |
573 | if (data == 0) { | |
574 | pushax = data; | |
58839b01 | 575 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, |
cc1e2398 AK |
576 | 0x0c); |
577 | data &= 0xFB; | |
8104e329 | 578 | xgifb_reg_set(pVBInfo->P3c4, 0x0c, data); |
cc1e2398 | 579 | data = pushax; |
21df8fc8 | 580 | } |
cc1e2398 AK |
581 | data = data - 1; |
582 | data |= data1; | |
8104e329 | 583 | xgifb_reg_set(pVBInfo->P3d4, 0x05, data); |
58839b01 | 584 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0e); |
cc1e2398 AK |
585 | data = data >> 5; |
586 | data = data + 3; | |
587 | if (data > 7) | |
588 | data = data - 7; | |
589 | data = data << 5; | |
ec9e5d3e | 590 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0e, ~0xE0, data); |
21df8fc8 | 591 | } |
21df8fc8 PS |
592 | } |
593 | ||
cc1e2398 | 594 | static void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex, unsigned short ModeNo, |
21df8fc8 | 595 | struct vb_device_info *pVBInfo) |
d7636e0b | 596 | { |
cc1e2398 AK |
597 | unsigned char data; |
598 | unsigned short i, j; | |
d7636e0b | 599 | |
8104e329 AK |
600 | /* xgifb_reg_set(pVBInfo->P3d4, 0x51, 0); */ |
601 | /* xgifb_reg_set(pVBInfo->P3d4, 0x56, 0); */ | |
ec9e5d3e | 602 | /* xgifb_reg_and_or(pVBInfo->P3d4, 0x11, 0x7f, 0x00); */ |
cc1e2398 AK |
603 | |
604 | for (i = 0x00; i <= 0x01; i++) { | |
605 | data = pVBInfo->TimingV[0].data[i]; | |
8104e329 | 606 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 6), data); |
21df8fc8 | 607 | } |
d7636e0b | 608 | |
cc1e2398 AK |
609 | for (i = 0x02; i <= 0x03; i++) { |
610 | data = pVBInfo->TimingV[0].data[i]; | |
8104e329 | 611 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x0e), data); |
21df8fc8 | 612 | } |
d7636e0b | 613 | |
cc1e2398 AK |
614 | for (i = 0x04; i <= 0x05; i++) { |
615 | data = pVBInfo->TimingV[0].data[i]; | |
8104e329 | 616 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x11), data); |
cc1e2398 | 617 | } |
d7636e0b | 618 | |
58839b01 | 619 | j = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0a); |
cc1e2398 AK |
620 | j &= 0xC0; |
621 | data = pVBInfo->TimingV[0].data[6]; | |
622 | data &= 0x3F; | |
623 | data |= j; | |
8104e329 | 624 | xgifb_reg_set(pVBInfo->P3c4, 0x0a, data); |
d7636e0b | 625 | |
cc1e2398 AK |
626 | data = pVBInfo->TimingV[0].data[6]; |
627 | data &= 0x80; | |
628 | data = data >> 2; | |
d7636e0b | 629 | |
cc1e2398 AK |
630 | if (ModeNo <= 0x13) |
631 | i = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
632 | else | |
633 | i = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
d7636e0b | 634 | |
cc1e2398 AK |
635 | i &= DoubleScanMode; |
636 | if (i) | |
637 | data |= 0x80; | |
d7636e0b | 638 | |
58839b01 | 639 | j = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x09); |
cc1e2398 AK |
640 | j &= 0x5F; |
641 | data |= j; | |
8104e329 | 642 | xgifb_reg_set(pVBInfo->P3d4, 0x09, data); |
d7636e0b | 643 | } |
644 | ||
cc1e2398 AK |
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) | |
21df8fc8 | 649 | { |
cc1e2398 AK |
650 | unsigned char index, data; |
651 | unsigned short i; | |
21df8fc8 | 652 | |
cc1e2398 AK |
653 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; /* Get index */ |
654 | index = index & IndexMask; | |
21df8fc8 | 655 | |
58839b01 | 656 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
cc1e2398 | 657 | data &= 0x7F; |
8104e329 | 658 | xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */ |
21df8fc8 | 659 | |
cc1e2398 AK |
660 | for (i = 0; i < 8; i++) |
661 | pVBInfo->TimingH[0].data[i] | |
662 | = pVBInfo->XGINEWUB_CRT1Table[index].CR[i]; | |
21df8fc8 | 663 | |
cc1e2398 AK |
664 | for (i = 0; i < 7; i++) |
665 | pVBInfo->TimingV[0].data[i] | |
666 | = pVBInfo->XGINEWUB_CRT1Table[index].CR[i + 8]; | |
21df8fc8 | 667 | |
cc1e2398 | 668 | XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension); |
21df8fc8 | 669 | |
cc1e2398 | 670 | XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo); |
21df8fc8 | 671 | |
cc1e2398 | 672 | if (pVBInfo->ModeType > 0x03) |
8104e329 | 673 | xgifb_reg_set(pVBInfo->P3d4, 0x14, 0x4F); |
21df8fc8 PS |
674 | } |
675 | ||
cc1e2398 AK |
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 | /* --------------------------------------------------------------------- */ | |
682 | static void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, | |
683 | unsigned short RefreshRateTableIndex, | |
21df8fc8 | 684 | struct vb_device_info *pVBInfo) |
d7636e0b | 685 | { |
cc1e2398 AK |
686 | unsigned char StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx; |
687 | unsigned short Temp1, Temp2, Temp3; | |
21df8fc8 | 688 | |
cc1e2398 AK |
689 | if (ModeNo <= 0x13) { |
690 | StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo); | |
691 | Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[4]; /* CR04 HRS */ | |
8104e329 | 692 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); /* SR2E [7:0]->HRS */ |
cc1e2398 AK |
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 */ | |
8104e329 | 701 | xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempdx); /* SR2F [7:2]->HRE */ |
ec9e5d3e | 702 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00); |
21df8fc8 | 703 | |
cc1e2398 AK |
704 | Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[16]; /* Tempax: CR16 VRS */ |
705 | Tempbx = Tempax; /* Tempbx=Tempax */ | |
706 | Tempax &= 0x01; /* Tempax: VRS[0] */ | |
b9bf6e4e | 707 | xgifb_reg_or(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS */ |
cc1e2398 AK |
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] */ | |
8104e329 | 713 | xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempdx); /* SR34[7:0]: VRS[8:1] */ |
21df8fc8 | 714 | |
cc1e2398 AK |
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] */ | |
21df8fc8 | 720 | |
cc1e2398 AK |
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; | |
8104e329 | 736 | xgifb_reg_set(pVBInfo->P3c4, 0x3F, Tempax); /* SR3F D[7:2]->VRE D[1:0]->VRS */ |
cc1e2398 AK |
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 */ | |
8104e329 | 741 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); /* SR2E[7:0]->HRS */ |
21df8fc8 | 742 | |
cc1e2398 AK |
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] */ | |
21df8fc8 | 748 | |
cc1e2398 AK |
749 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */ |
750 | Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */ | |
21df8fc8 | 751 | |
cc1e2398 AK |
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] */ | |
21df8fc8 | 756 | |
cc1e2398 AK |
757 | Temp2 = Temp1 & 0x3C0; /* Temp2[9:6]: HRS[9:6] */ |
758 | Temp2 |= Tempax; /* Temp2[9:0]: HRE[9:0] */ | |
21df8fc8 | 759 | |
cc1e2398 AK |
760 | Tempcx &= 0x3F; /* Tempcx[5:0]: HRS[5:0] */ |
761 | if (Tempax < Tempcx) /* HRE < HRS */ | |
762 | Temp2 |= 0x40; /* Temp2 + 0x40 */ | |
21df8fc8 | 763 | |
cc1e2398 AK |
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] */ | |
8104e329 | 769 | xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax); /* SR2F D[7:2]->HRE, D[1:0]->HRS */ |
ec9e5d3e | 770 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00); |
21df8fc8 | 771 | |
cc1e2398 AK |
772 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10]; /* CR10 VRS */ |
773 | Tempbx = Tempax; /* Tempbx: VRS */ | |
774 | Tempax &= 0x01; /* Tempax[0]: VRS[0] */ | |
b9bf6e4e | 775 | xgifb_reg_or(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS[0] */ |
cc1e2398 AK |
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] */ | |
8104e329 | 781 | xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempcx); /* SR34[8:1]->VRS */ |
21df8fc8 | 782 | |
cc1e2398 AK |
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] */ | |
21df8fc8 | 794 | |
cc1e2398 AK |
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] */ | |
21df8fc8 | 803 | |
cc1e2398 AK |
804 | Temp3 = Temp1 & 0x1F; /* Temp3[4:0]: VRS[4:0] */ |
805 | if (Tempax < Temp3) /* VRE < VRS */ | |
806 | Temp2 |= 0x20; /* VRE + 0x20 */ | |
d7636e0b | 807 | |
cc1e2398 AK |
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; | |
8104e329 | 816 | xgifb_reg_set(pVBInfo->P3c4, 0x3F, Tempax); /* SR3F D[7:2]->VRE D[1:0]->VRS */ |
21df8fc8 | 817 | } |
d7636e0b | 818 | } |
819 | ||
cc1e2398 AK |
820 | static void XGI_SetXG27CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, |
821 | unsigned short RefreshRateTableIndex, | |
21df8fc8 PS |
822 | struct vb_device_info *pVBInfo) |
823 | { | |
cc1e2398 | 824 | unsigned short StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx; |
21df8fc8 | 825 | |
cc1e2398 AK |
826 | if (ModeNo <= 0x13) { |
827 | StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo); | |
828 | Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[4]; /* CR04 HRS */ | |
8104e329 | 829 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); /* SR2E [7:0]->HRS */ |
cc1e2398 AK |
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 */ | |
8104e329 | 838 | xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempdx); /* SR2F [7:2]->HRE */ |
ec9e5d3e | 839 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00); |
d7636e0b | 840 | |
cc1e2398 | 841 | Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[16]; /* Tempax: CR10 VRS */ |
8104e329 | 842 | xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempax); /* SR34[7:0]->VRS */ |
cc1e2398 AK |
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; | |
ec9e5d3e | 848 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x01, Tempax); /* SR35 D[0]->VRS D[8] */ |
cc1e2398 AK |
849 | Tempcx |= (Tempax << 8); /* Tempcx[8] |= VRS[8] */ |
850 | Tempcx |= (Tempbx & 0x80) << 2; /* Tempcx[9] |= VRS[9] */ | |
d7636e0b | 851 | |
cc1e2398 AK |
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] */ | |
ec9e5d3e AK |
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] */ | |
cc1e2398 AK |
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] */ | |
8104e329 | 868 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); /* SR2E[7:0]->HRS */ |
d7636e0b | 869 | |
cc1e2398 AK |
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] */ | |
d7636e0b | 873 | |
cc1e2398 AK |
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] */ | |
d7636e0b | 877 | |
cc1e2398 AK |
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] */ | |
d7636e0b | 882 | |
cc1e2398 AK |
883 | Tempbx = Tempbx & 0x3C0; /* Tempbx[9:6]: HRS[9:6] */ |
884 | Tempbx |= Tempcx; /* Tempbx: HRS[9:6]HRE[5:0] */ | |
d7636e0b | 885 | |
cc1e2398 AK |
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]*/ | |
d7636e0b | 890 | |
cc1e2398 AK |
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] */ | |
8104e329 | 895 | xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax); /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */ |
ec9e5d3e | 896 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00); |
d7636e0b | 897 | |
cc1e2398 | 898 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10]; /* CR10 VRS */ |
8104e329 | 899 | xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempax); /* SR34[7:0]->VRS[7:0] */ |
d7636e0b | 900 | |
cc1e2398 AK |
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] */ | |
ec9e5d3e | 906 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x01, Tempax); /* SR35[0]: VRS[8] */ |
cc1e2398 AK |
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] */ | |
d7636e0b | 912 | |
cc1e2398 AK |
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] */ | |
d7636e0b | 922 | |
cc1e2398 AK |
923 | if (Tempbx <= Tempcx) /* VRE <= VRS */ |
924 | Tempbx |= 0x20; /* VRE + 0x20 */ | |
d7636e0b | 925 | |
cc1e2398 | 926 | Tempax = (Tempbx << 2) & 0xFF; /* Tempax: Tempax[7:0]; VRE[5:0]00 */ |
ec9e5d3e | 927 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax); /* SR3F[7:2]:VRE[5:0] */ |
cc1e2398 | 928 | Tempax = Tempcx >> 8; |
ec9e5d3e | 929 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, Tempax); /* SR35[2:0]:VRS[10:8] */ |
21df8fc8 | 930 | } |
cc1e2398 | 931 | } |
d7636e0b | 932 | |
cc1e2398 AK |
933 | /* --------------------------------------------------------------------- */ |
934 | /* Function : XGI_SetXG21LCD */ | |
935 | /* Input : */ | |
936 | /* Output : FCLK duty cycle, FCLK delay compensation */ | |
937 | /* Description : All values set zero */ | |
938 | /* --------------------------------------------------------------------- */ | |
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 | ||
8104e329 AK |
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); | |
cc1e2398 | 951 | if (((*pVBInfo->pDVOSetting) & 0xC0) == 0xC0) { |
8104e329 AK |
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); | |
21df8fc8 | 956 | } |
d7636e0b | 957 | |
58839b01 | 958 | Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
21df8fc8 | 959 | |
cc1e2398 | 960 | if (Temp & 0x01) { |
b9bf6e4e AK |
961 | xgifb_reg_or(pVBInfo->P3c4, 0x06, 0x40); /* 18 bits FP */ |
962 | xgifb_reg_or(pVBInfo->P3c4, 0x09, 0x40); | |
cc1e2398 AK |
963 | } |
964 | ||
b9bf6e4e | 965 | xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */ |
cc1e2398 | 966 | |
dc50556b AK |
967 | xgifb_reg_and(pVBInfo->P3c4, 0x30, ~0x20); |
968 | xgifb_reg_and(pVBInfo->P3c4, 0x35, ~0x80); | |
cc1e2398 AK |
969 | |
970 | if (ModeNo <= 0x13) { | |
d8ad0a6d | 971 | b3CC = (unsigned char) inb(XGI_P3cc); |
cc1e2398 | 972 | if (b3CC & 0x40) |
b9bf6e4e | 973 | xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20); /* Hsync polarity */ |
cc1e2398 | 974 | if (b3CC & 0x80) |
b9bf6e4e | 975 | xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80); /* Vsync polarity */ |
cc1e2398 AK |
976 | } else { |
977 | Data = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; | |
978 | if (Data & 0x4000) | |
b9bf6e4e | 979 | xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20); /* Hsync polarity */ |
cc1e2398 | 980 | if (Data & 0x8000) |
b9bf6e4e | 981 | xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80); /* Vsync polarity */ |
21df8fc8 | 982 | } |
d7636e0b | 983 | } |
984 | ||
cc1e2398 AK |
985 | static void XGI_SetXG27LCD(struct vb_device_info *pVBInfo, |
986 | unsigned short RefreshRateTableIndex, unsigned short ModeNo) | |
21df8fc8 | 987 | { |
cc1e2398 AK |
988 | unsigned short Data, Temp, b3CC; |
989 | unsigned short XGI_P3cc; | |
21df8fc8 | 990 | |
cc1e2398 | 991 | XGI_P3cc = pVBInfo->P3cc; |
21df8fc8 | 992 | |
8104e329 AK |
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); | |
21df8fc8 | 997 | |
58839b01 | 998 | Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
cc1e2398 | 999 | if ((Temp & 0x03) == 0) { /* dual 12 */ |
8104e329 AK |
1000 | xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x13); |
1001 | xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x13); | |
21df8fc8 PS |
1002 | } |
1003 | ||
cc1e2398 | 1004 | if (((*pVBInfo->pDVOSetting) & 0xC0) == 0xC0) { |
8104e329 AK |
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); | |
21df8fc8 PS |
1009 | } |
1010 | ||
cc1e2398 | 1011 | XGI_SetXG27FPBits(pVBInfo); |
21df8fc8 | 1012 | |
b9bf6e4e | 1013 | xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */ |
21df8fc8 | 1014 | |
dc50556b AK |
1015 | xgifb_reg_and(pVBInfo->P3c4, 0x30, ~0x20); /* Hsync polarity */ |
1016 | xgifb_reg_and(pVBInfo->P3c4, 0x35, ~0x80); /* Vsync polarity */ | |
21df8fc8 | 1017 | |
cc1e2398 | 1018 | if (ModeNo <= 0x13) { |
d8ad0a6d | 1019 | b3CC = (unsigned char) inb(XGI_P3cc); |
cc1e2398 | 1020 | if (b3CC & 0x40) |
b9bf6e4e | 1021 | xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20); /* Hsync polarity */ |
cc1e2398 | 1022 | if (b3CC & 0x80) |
b9bf6e4e | 1023 | xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80); /* Vsync polarity */ |
cc1e2398 AK |
1024 | } else { |
1025 | Data = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; | |
1026 | if (Data & 0x4000) | |
b9bf6e4e | 1027 | xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20); /* Hsync polarity */ |
cc1e2398 | 1028 | if (Data & 0x8000) |
b9bf6e4e | 1029 | xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80); /* Vsync polarity */ |
cc1e2398 | 1030 | } |
21df8fc8 | 1031 | } |
d7636e0b | 1032 | |
1033 | /* --------------------------------------------------------------------- */ | |
cc1e2398 AK |
1034 | /* Function : XGI_UpdateXG21CRTC */ |
1035 | /* Input : */ | |
1036 | /* Output : CRT1 CRTC */ | |
1037 | /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */ | |
d7636e0b | 1038 | /* --------------------------------------------------------------------- */ |
cc1e2398 AK |
1039 | static void XGI_UpdateXG21CRTC(unsigned short ModeNo, struct vb_device_info *pVBInfo, |
1040 | unsigned short RefreshRateTableIndex) | |
1041 | { | |
1042 | int i, index = -1; | |
1043 | ||
dc50556b | 1044 | xgifb_reg_and(pVBInfo->P3d4, 0x11, 0x7F); /* Unlock CR0~7 */ |
cc1e2398 AK |
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) { | |
8104e329 | 1068 | xgifb_reg_set(pVBInfo->P3d4, 0x02, |
cc1e2398 | 1069 | pVBInfo->UpdateCRT1[index].CR02); |
8104e329 | 1070 | xgifb_reg_set(pVBInfo->P3d4, 0x03, |
cc1e2398 | 1071 | pVBInfo->UpdateCRT1[index].CR03); |
8104e329 | 1072 | xgifb_reg_set(pVBInfo->P3d4, 0x15, |
cc1e2398 | 1073 | pVBInfo->UpdateCRT1[index].CR15); |
8104e329 | 1074 | xgifb_reg_set(pVBInfo->P3d4, 0x16, |
cc1e2398 AK |
1075 | pVBInfo->UpdateCRT1[index].CR16); |
1076 | } | |
1077 | } | |
1078 | ||
1079 | static void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension, | |
1080 | unsigned short ModeNo, unsigned short ModeIdIndex, | |
21df8fc8 PS |
1081 | unsigned short RefreshRateTableIndex, |
1082 | struct vb_device_info *pVBInfo) | |
1083 | { | |
cc1e2398 AK |
1084 | unsigned short resindex, tempax, tempbx, tempcx, temp, modeflag; |
1085 | ||
1086 | unsigned char data; | |
1087 | ||
1088 | resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); | |
21df8fc8 PS |
1089 | |
1090 | if (ModeNo <= 0x13) { | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 1099 | |
cc1e2398 AK |
1100 | if (modeflag & HalfDCLK) |
1101 | tempax = tempax >> 1; | |
21df8fc8 | 1102 | |
cc1e2398 AK |
1103 | if (ModeNo > 0x13) { |
1104 | if (modeflag & HalfDCLK) | |
1105 | tempax = tempax << 1; | |
21df8fc8 | 1106 | |
cc1e2398 | 1107 | temp = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
21df8fc8 | 1108 | |
cc1e2398 AK |
1109 | if (temp & InterlaceMode) |
1110 | tempbx = tempbx >> 1; | |
21df8fc8 | 1111 | |
cc1e2398 AK |
1112 | if (modeflag & DoubleScanMode) |
1113 | tempbx = tempbx << 1; | |
1114 | } | |
21df8fc8 | 1115 | |
cc1e2398 | 1116 | tempcx = 8; |
21df8fc8 | 1117 | |
cc1e2398 AK |
1118 | /* if (!(modeflag & Charx8Dot)) */ |
1119 | /* tempcx = 9; */ | |
21df8fc8 | 1120 | |
cc1e2398 AK |
1121 | tempax /= tempcx; |
1122 | tempax -= 1; | |
1123 | tempbx -= 1; | |
1124 | tempcx = tempax; | |
58839b01 AK |
1125 | temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
1126 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); | |
cc1e2398 | 1127 | data &= 0x7F; |
8104e329 AK |
1128 | xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */ |
1129 | xgifb_reg_set(pVBInfo->P3d4, 0x01, (unsigned short) (tempcx & 0xff)); | |
ec9e5d3e | 1130 | xgifb_reg_and_or(pVBInfo->P3d4, 0x0b, ~0x0c, |
cc1e2398 | 1131 | (unsigned short) ((tempcx & 0x0ff00) >> 10)); |
8104e329 | 1132 | xgifb_reg_set(pVBInfo->P3d4, 0x12, (unsigned short) (tempbx & 0xff)); |
cc1e2398 AK |
1133 | tempax = 0; |
1134 | tempbx = tempbx >> 8; | |
21df8fc8 | 1135 | |
cc1e2398 AK |
1136 | if (tempbx & 0x01) |
1137 | tempax |= 0x02; | |
21df8fc8 | 1138 | |
cc1e2398 AK |
1139 | if (tempbx & 0x02) |
1140 | tempax |= 0x40; | |
21df8fc8 | 1141 | |
ec9e5d3e | 1142 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x42, tempax); |
58839b01 | 1143 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x07); |
cc1e2398 AK |
1144 | data &= 0xFF; |
1145 | tempax = 0; | |
21df8fc8 | 1146 | |
cc1e2398 AK |
1147 | if (tempbx & 0x04) |
1148 | tempax |= 0x02; | |
21df8fc8 | 1149 | |
ec9e5d3e | 1150 | xgifb_reg_and_or(pVBInfo->P3d4, 0x0a, ~0x02, tempax); |
8104e329 | 1151 | xgifb_reg_set(pVBInfo->P3d4, 0x11, temp); |
cc1e2398 | 1152 | } |
21df8fc8 | 1153 | |
cc1e2398 AK |
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; | |
d7636e0b | 1164 | } |
1165 | ||
cc1e2398 | 1166 | static void XGI_SetCRT1Offset(unsigned short ModeNo, unsigned short ModeIdIndex, |
21df8fc8 | 1167 | unsigned short RefreshRateTableIndex, |
cc1e2398 | 1168 | struct xgi_hw_device_info *HwDeviceExtension, |
21df8fc8 | 1169 | struct vb_device_info *pVBInfo) |
d7636e0b | 1170 | { |
cc1e2398 | 1171 | unsigned short temp, ah, al, temp2, i, DisplayUnit; |
21df8fc8 | 1172 | |
cc1e2398 AK |
1173 | /* GetOffset */ |
1174 | temp = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo; | |
1175 | temp = temp >> 8; | |
1176 | temp = pVBInfo->ScreenOffset[temp]; | |
21df8fc8 | 1177 | |
cc1e2398 AK |
1178 | temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
1179 | temp2 &= InterlaceMode; | |
21df8fc8 | 1180 | |
cc1e2398 AK |
1181 | if (temp2) |
1182 | temp = temp << 1; | |
21df8fc8 | 1183 | |
cc1e2398 | 1184 | temp2 = pVBInfo->ModeType - ModeEGA; |
21df8fc8 | 1185 | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 1208 | |
cc1e2398 AK |
1209 | if ((ModeNo >= 0x26) && (ModeNo <= 0x28)) |
1210 | temp = temp * temp2 + temp2 / 2; | |
1211 | else | |
1212 | temp *= temp2; | |
21df8fc8 | 1213 | |
cc1e2398 AK |
1214 | /* SetOffset */ |
1215 | DisplayUnit = temp; | |
1216 | temp2 = temp; | |
1217 | temp = temp >> 8; /* ah */ | |
1218 | temp &= 0x0F; | |
58839b01 | 1219 | i = xgifb_reg_get(pVBInfo->P3c4, 0x0E); |
cc1e2398 AK |
1220 | i &= 0xF0; |
1221 | i |= temp; | |
8104e329 | 1222 | xgifb_reg_set(pVBInfo->P3c4, 0x0E, i); |
21df8fc8 | 1223 | |
cc1e2398 AK |
1224 | temp = (unsigned char) temp2; |
1225 | temp &= 0xFF; /* al */ | |
8104e329 | 1226 | xgifb_reg_set(pVBInfo->P3d4, 0x13, temp); |
21df8fc8 | 1227 | |
cc1e2398 AK |
1228 | /* SetDisplayUnit */ |
1229 | temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; | |
1230 | temp2 &= InterlaceMode; | |
1231 | if (temp2) | |
1232 | DisplayUnit >>= 1; | |
21df8fc8 | 1233 | |
cc1e2398 AK |
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; | |
21df8fc8 | 1241 | |
cc1e2398 AK |
1242 | if (HwDeviceExtension->jChipType >= XG20) |
1243 | if ((ModeNo == 0x4A) | (ModeNo == 0x49)) | |
1244 | ah -= 1; | |
21df8fc8 | 1245 | |
8104e329 | 1246 | xgifb_reg_set(pVBInfo->P3c4, 0x10, ah); |
d7636e0b | 1247 | } |
1248 | ||
cc1e2398 AK |
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) | |
d7636e0b | 1254 | { |
cc1e2398 | 1255 | unsigned short tempbx; |
d7636e0b | 1256 | |
cc1e2398 AK |
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 }; | |
21df8fc8 | 1266 | |
cc1e2398 AK |
1267 | unsigned short CRT2Index, VCLKIndex; |
1268 | unsigned short modeflag, resinfo; | |
1269 | unsigned char *CHTVVCLKPtr = NULL; | |
21df8fc8 PS |
1270 | |
1271 | if (ModeNo <= 0x13) { | |
cc1e2398 AK |
1272 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */ |
1273 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; | |
1274 | CRT2Index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; | |
21df8fc8 | 1275 | } else { |
cc1e2398 AK |
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; | |
21df8fc8 | 1280 | } |
21df8fc8 | 1281 | |
cc1e2398 AK |
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; | |
21df8fc8 | 1294 | |
cc1e2398 | 1295 | VCLKIndex += 25; |
21df8fc8 | 1296 | |
cc1e2398 AK |
1297 | } else { |
1298 | VCLKIndex = HiTVVCLK; | |
21df8fc8 | 1299 | |
cc1e2398 | 1300 | VCLKIndex += 25; |
21df8fc8 | 1301 | |
cc1e2398 | 1302 | } |
21df8fc8 | 1303 | |
cc1e2398 AK |
1304 | if (pVBInfo->SetFlag & TVSimuMode) { |
1305 | if (modeflag & Charx8Dot) { | |
1306 | VCLKIndex | |
1307 | = HiTVSimuVCLK; | |
21df8fc8 | 1308 | |
cc1e2398 | 1309 | VCLKIndex += 25; |
21df8fc8 | 1310 | |
cc1e2398 AK |
1311 | } else { |
1312 | VCLKIndex | |
1313 | = HiTVTextVCLK; | |
d7636e0b | 1314 | |
cc1e2398 | 1315 | VCLKIndex += 25; |
21df8fc8 | 1316 | |
cc1e2398 AK |
1317 | } |
1318 | } | |
21df8fc8 | 1319 | |
cc1e2398 AK |
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; | |
21df8fc8 | 1346 | |
cc1e2398 | 1347 | VCLKIndex += 25; |
d7636e0b | 1348 | |
cc1e2398 AK |
1349 | } else { |
1350 | VCLKIndex = TVVCLK; | |
d7636e0b | 1351 | |
cc1e2398 | 1352 | VCLKIndex += 25; |
d7636e0b | 1353 | |
cc1e2398 AK |
1354 | } |
1355 | } | |
1356 | } | |
1357 | } else { /* for CRT2 */ | |
d8ad0a6d | 1358 | VCLKIndex = (unsigned char) inb( |
cc1e2398 AK |
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; | |
21df8fc8 | 1373 | |
cc1e2398 AK |
1374 | if (pVBInfo->IF_DEF_CH7005 == 1) { |
1375 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) { | |
1376 | VCLKIndex &= 0x1f; | |
1377 | tempbx = 0; | |
21df8fc8 | 1378 | |
cc1e2398 AK |
1379 | if (pVBInfo->VBInfo & SetPALTV) |
1380 | tempbx += 2; | |
21df8fc8 | 1381 | |
cc1e2398 AK |
1382 | if (pVBInfo->VBInfo & SetCHTVOverScan) |
1383 | tempbx += 1; | |
21df8fc8 | 1384 | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 1401 | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 1416 | } |
cc1e2398 | 1417 | /* VCLKIndex = VCLKIndex&IndexMask; */ |
d7636e0b | 1418 | |
cc1e2398 | 1419 | return VCLKIndex; |
21df8fc8 | 1420 | } |
d7636e0b | 1421 | |
063b9c4b | 1422 | static void XGI_SetCRT1VCLK(unsigned short ModeNo, unsigned short ModeIdIndex, |
21df8fc8 PS |
1423 | struct xgi_hw_device_info *HwDeviceExtension, |
1424 | unsigned short RefreshRateTableIndex, | |
1425 | struct vb_device_info *pVBInfo) | |
d7636e0b | 1426 | { |
108afbf8 | 1427 | unsigned char index, data; |
21df8fc8 PS |
1428 | unsigned short vclkindex; |
1429 | ||
1430 | if (pVBInfo->IF_DEF_LVDS == 1) { | |
1431 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; | |
58839b01 | 1432 | data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF; |
8104e329 AK |
1433 | xgifb_reg_set(pVBInfo->P3c4, 0x31, data); |
1434 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, | |
21df8fc8 | 1435 | pVBInfo->VCLKData[index].SR2B); |
8104e329 | 1436 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, |
21df8fc8 | 1437 | pVBInfo->VCLKData[index].SR2C); |
8104e329 | 1438 | xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01); |
21df8fc8 PS |
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); | |
58839b01 | 1445 | data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF; |
8104e329 | 1446 | xgifb_reg_set(pVBInfo->P3c4, 0x31, data); |
21df8fc8 | 1447 | data = pVBInfo->VBVCLKData[vclkindex].Part4_A; |
8104e329 | 1448 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, data); |
21df8fc8 | 1449 | data = pVBInfo->VBVCLKData[vclkindex].Part4_B; |
8104e329 AK |
1450 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, data); |
1451 | xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01); | |
21df8fc8 PS |
1452 | } else { |
1453 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; | |
58839b01 | 1454 | data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF; |
8104e329 AK |
1455 | xgifb_reg_set(pVBInfo->P3c4, 0x31, data); |
1456 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, | |
21df8fc8 | 1457 | pVBInfo->VCLKData[index].SR2B); |
8104e329 | 1458 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, |
21df8fc8 | 1459 | pVBInfo->VCLKData[index].SR2C); |
8104e329 | 1460 | xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01); |
21df8fc8 | 1461 | } |
d7636e0b | 1462 | |
21df8fc8 PS |
1463 | if (HwDeviceExtension->jChipType >= XG20) { |
1464 | if (pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag & HalfDCLK) { | |
58839b01 | 1465 | data = xgifb_reg_get(pVBInfo->P3c4, 0x2B); |
8104e329 | 1466 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, data); |
58839b01 | 1467 | data = xgifb_reg_get(pVBInfo->P3c4, 0x2C); |
21df8fc8 PS |
1468 | index = data; |
1469 | index &= 0xE0; | |
1470 | data &= 0x1F; | |
1471 | data = data << 1; | |
1472 | data += 1; | |
1473 | data |= index; | |
8104e329 | 1474 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, data); |
21df8fc8 PS |
1475 | } |
1476 | } | |
1477 | } | |
d7636e0b | 1478 | |
063b9c4b | 1479 | static void XGI_SetCRT1FIFO(unsigned short ModeNo, |
21df8fc8 PS |
1480 | struct xgi_hw_device_info *HwDeviceExtension, |
1481 | struct vb_device_info *pVBInfo) | |
1482 | { | |
1483 | unsigned short data; | |
1484 | ||
58839b01 | 1485 | data = xgifb_reg_get(pVBInfo->P3c4, 0x3D); |
21df8fc8 | 1486 | data &= 0xfe; |
8104e329 | 1487 | xgifb_reg_set(pVBInfo->P3c4, 0x3D, data); /* diable auto-threshold */ |
21df8fc8 PS |
1488 | |
1489 | if (ModeNo > 0x13) { | |
8104e329 | 1490 | xgifb_reg_set(pVBInfo->P3c4, 0x08, 0x34); |
58839b01 | 1491 | data = xgifb_reg_get(pVBInfo->P3c4, 0x09); |
21df8fc8 | 1492 | data &= 0xC0; |
8104e329 | 1493 | xgifb_reg_set(pVBInfo->P3c4, 0x09, data | 0x30); |
58839b01 | 1494 | data = xgifb_reg_get(pVBInfo->P3c4, 0x3D); |
21df8fc8 | 1495 | data |= 0x01; |
8104e329 | 1496 | xgifb_reg_set(pVBInfo->P3c4, 0x3D, data); |
21df8fc8 PS |
1497 | } else { |
1498 | if (HwDeviceExtension->jChipType == XG27) { | |
8104e329 | 1499 | xgifb_reg_set(pVBInfo->P3c4, 0x08, 0x0E); |
58839b01 | 1500 | data = xgifb_reg_get(pVBInfo->P3c4, 0x09); |
21df8fc8 | 1501 | data &= 0xC0; |
8104e329 | 1502 | xgifb_reg_set(pVBInfo->P3c4, 0x09, data | 0x20); |
21df8fc8 | 1503 | } else { |
8104e329 | 1504 | xgifb_reg_set(pVBInfo->P3c4, 0x08, 0xAE); |
58839b01 | 1505 | data = xgifb_reg_get(pVBInfo->P3c4, 0x09); |
21df8fc8 | 1506 | data &= 0xF0; |
8104e329 | 1507 | xgifb_reg_set(pVBInfo->P3c4, 0x09, data); |
21df8fc8 PS |
1508 | } |
1509 | } | |
d7636e0b | 1510 | |
21df8fc8 PS |
1511 | if (HwDeviceExtension->jChipType == XG21) |
1512 | XGI_SetXG21FPBits(pVBInfo); /* Fix SR9[7:6] can't read back */ | |
1513 | } | |
d7636e0b | 1514 | |
cc1e2398 AK |
1515 | static void XGI_SetVCLKState(struct xgi_hw_device_info *HwDeviceExtension, |
1516 | unsigned short ModeNo, unsigned short RefreshRateTableIndex, | |
21df8fc8 PS |
1517 | struct vb_device_info *pVBInfo) |
1518 | { | |
cc1e2398 AK |
1519 | unsigned short data, data2 = 0; |
1520 | short VCLK; | |
d7636e0b | 1521 | |
cc1e2398 | 1522 | unsigned char index; |
d7636e0b | 1523 | |
cc1e2398 AK |
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 | } | |
d7636e0b | 1531 | |
58839b01 | 1532 | data = xgifb_reg_get(pVBInfo->P3c4, 0x32); |
cc1e2398 AK |
1533 | data &= 0xf3; |
1534 | if (VCLK >= 200) | |
1535 | data |= 0x0c; /* VCLK > 200 */ | |
d7636e0b | 1536 | |
cc1e2398 AK |
1537 | if (HwDeviceExtension->jChipType >= XG20) |
1538 | data &= ~0x04; /* 2 pixel mode */ | |
d7636e0b | 1539 | |
8104e329 | 1540 | xgifb_reg_set(pVBInfo->P3c4, 0x32, data); |
cc1e2398 AK |
1541 | |
1542 | if (HwDeviceExtension->jChipType < XG20) { | |
58839b01 | 1543 | data = xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
cc1e2398 AK |
1544 | data &= 0xE7; |
1545 | if (VCLK < 200) | |
1546 | data |= 0x10; | |
8104e329 | 1547 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, data); |
cc1e2398 AK |
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 | ||
ec9e5d3e | 1562 | xgifb_reg_and_or(pVBInfo->P3c4, 0x07, 0xFC, data2); |
cc1e2398 | 1563 | if (HwDeviceExtension->jChipType >= XG27) |
ec9e5d3e | 1564 | xgifb_reg_and_or(pVBInfo->P3c4, 0x40, 0xFC, data2 & 0x03); |
cc1e2398 AK |
1565 | |
1566 | } | |
1567 | ||
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 | ||
58839b01 | 1583 | if (xgifb_reg_get(pVBInfo->P3d4, 0x31) & 0x01) |
ec9e5d3e | 1584 | xgifb_reg_and_or(pVBInfo->P3c4, 0x1F, 0x3F, 0x00); |
cc1e2398 AK |
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 | } | |
21df8fc8 | 1600 | } |
d7636e0b | 1601 | |
21df8fc8 | 1602 | data &= InterlaceMode; |
d7636e0b | 1603 | |
21df8fc8 PS |
1604 | if (data) |
1605 | data2 |= 0x20; | |
d7636e0b | 1606 | |
ec9e5d3e | 1607 | xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x3F, data2); |
8104e329 | 1608 | /* xgifb_reg_set(pVBInfo->P3c4,0x06,data2); */ |
21df8fc8 PS |
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 | } | |
d7636e0b | 1622 | |
21df8fc8 | 1623 | data2 = data & 0x00FF; |
ec9e5d3e | 1624 | xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFF, data2); |
21df8fc8 | 1625 | data2 = (data & 0xFF00) >> 8; |
ec9e5d3e | 1626 | xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFC, data2); |
d7636e0b | 1627 | |
21df8fc8 | 1628 | if (modeflag & HalfDCLK) |
ec9e5d3e | 1629 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xF7, 0x08); |
21df8fc8 PS |
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 | ||
ec9e5d3e | 1641 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0F, ~0x48, data2); |
21df8fc8 PS |
1642 | data = 0x60; |
1643 | if (pVBInfo->ModeType != ModeText) { | |
1644 | data = data ^ 0x60; | |
1645 | if (pVBInfo->ModeType != ModeEGA) | |
1646 | data = data ^ 0xA0; | |
1647 | } | |
ec9e5d3e | 1648 | xgifb_reg_and_or(pVBInfo->P3c4, 0x21, 0x1F, data); |
21df8fc8 PS |
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 | ||
58839b01 | 1657 | data = xgifb_reg_get(pVBInfo->P3d4, 0x31); |
21df8fc8 PS |
1658 | |
1659 | if (HwDeviceExtension->jChipType == XG27) { | |
1660 | if (data & 0x40) | |
1661 | data = 0x2c; | |
1662 | else | |
1663 | data = 0x6c; | |
8104e329 | 1664 | xgifb_reg_set(pVBInfo->P3d4, 0x52, data); |
b9bf6e4e | 1665 | xgifb_reg_or(pVBInfo->P3d4, 0x51, 0x10); |
21df8fc8 PS |
1666 | } else if (HwDeviceExtension->jChipType >= XG20) { |
1667 | if (data & 0x40) | |
1668 | data = 0x33; | |
1669 | else | |
1670 | data = 0x73; | |
8104e329 AK |
1671 | xgifb_reg_set(pVBInfo->P3d4, 0x52, data); |
1672 | xgifb_reg_set(pVBInfo->P3d4, 0x51, 0x02); | |
21df8fc8 PS |
1673 | } else { |
1674 | if (data & 0x40) | |
1675 | data = 0x2c; | |
1676 | else | |
1677 | data = 0x6c; | |
8104e329 | 1678 | xgifb_reg_set(pVBInfo->P3d4, 0x52, data); |
21df8fc8 | 1679 | } |
d7636e0b | 1680 | |
d7636e0b | 1681 | } |
1682 | ||
21df8fc8 PS |
1683 | /* |
1684 | void XGI_VesaLowResolution(unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) | |
1685 | { | |
1686 | unsigned short modeflag; | |
d7636e0b | 1687 | |
21df8fc8 PS |
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) { | |
ec9e5d3e AK |
1699 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xf7, 0x00); |
1700 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0f, 0x7f, 0x00); | |
21df8fc8 PS |
1701 | return; |
1702 | } | |
1703 | } | |
1704 | } | |
ec9e5d3e AK |
1705 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0f, 0xff, 0x80); |
1706 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xf7, 0x00); | |
21df8fc8 PS |
1707 | return; |
1708 | } | |
1709 | } | |
1710 | } | |
ec9e5d3e | 1711 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0f, 0x7f, 0x00); |
21df8fc8 PS |
1712 | } |
1713 | */ | |
d7636e0b | 1714 | |
cc1e2398 AK |
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 | } | |
efdf4ee7 AK |
1737 | outb((unsigned short) dh, pVBInfo->P3c9); |
1738 | outb((unsigned short) bh, pVBInfo->P3c9); | |
1739 | outb((unsigned short) bl, pVBInfo->P3c9); | |
cc1e2398 AK |
1740 | } |
1741 | ||
063b9c4b | 1742 | static void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex, |
21df8fc8 PS |
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; | |
d7636e0b | 1747 | |
21df8fc8 PS |
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 | } | |
d7636e0b | 1766 | |
21df8fc8 PS |
1767 | if (time == 256) |
1768 | j = 16; | |
1769 | else | |
1770 | j = time; | |
d7636e0b | 1771 | |
efdf4ee7 AK |
1772 | outb(0xFF, pVBInfo->P3c6); |
1773 | outb(0x00, pVBInfo->P3c8); | |
d7636e0b | 1774 | |
21df8fc8 PS |
1775 | for (i = 0; i < j; i++) { |
1776 | data = table[i]; | |
d7636e0b | 1777 | |
21df8fc8 PS |
1778 | for (k = 0; k < 3; k++) { |
1779 | data2 = 0; | |
d7636e0b | 1780 | |
21df8fc8 PS |
1781 | if (data & 0x01) |
1782 | data2 = 0x2A; | |
d7636e0b | 1783 | |
21df8fc8 PS |
1784 | if (data & 0x02) |
1785 | data2 += 0x15; | |
d7636e0b | 1786 | |
efdf4ee7 | 1787 | outb(data2, pVBInfo->P3c9); |
21df8fc8 PS |
1788 | data = data >> 2; |
1789 | } | |
1790 | } | |
d7636e0b | 1791 | |
21df8fc8 PS |
1792 | if (time == 256) { |
1793 | for (i = 16; i < 32; i++) { | |
1794 | data = table[i]; | |
1795 | ||
1796 | for (k = 0; k < 3; k++) | |
efdf4ee7 | 1797 | outb(data, pVBInfo->P3c9); |
21df8fc8 PS |
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 | } | |
d7636e0b | 1833 | |
063b9c4b | 1834 | static void XGI_GetLVDSResInfo(unsigned short ModeNo, unsigned short ModeIdIndex, |
21df8fc8 PS |
1835 | struct vb_device_info *pVBInfo) |
1836 | { | |
1837 | unsigned short resindex, xres, yres, modeflag; | |
d7636e0b | 1838 | |
21df8fc8 PS |
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 */ | |
d7636e0b | 1843 | |
21df8fc8 PS |
1844 | /* if (ModeNo > 0x13) */ |
1845 | /* modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; */ | |
1846 | /* else */ | |
1847 | /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; */ | |
d7636e0b | 1848 | |
21df8fc8 PS |
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 */ | |
d7636e0b | 1853 | |
21df8fc8 | 1854 | /* resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); */ |
d7636e0b | 1855 | |
21df8fc8 PS |
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; | |
d7636e0b | 1866 | |
21df8fc8 PS |
1867 | if (modeflag & DoubleScanMode) |
1868 | yres = yres << 1; | |
1869 | } | |
1870 | /* if (modeflag & Charx8Dot) */ | |
1871 | /* { */ | |
d7636e0b | 1872 | |
21df8fc8 PS |
1873 | if (xres == 720) |
1874 | xres = 640; | |
d7636e0b | 1875 | |
21df8fc8 PS |
1876 | /* } */ |
1877 | pVBInfo->VGAHDE = xres; | |
1878 | pVBInfo->HDE = xres; | |
1879 | pVBInfo->VGAVDE = yres; | |
1880 | pVBInfo->VDE = yres; | |
1881 | } | |
d7636e0b | 1882 | |
cc1e2398 AK |
1883 | static void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo, |
1884 | unsigned short ModeIdIndex, | |
21df8fc8 PS |
1885 | unsigned short RefreshRateTableIndex, |
1886 | struct vb_device_info *pVBInfo) | |
1887 | { | |
cc1e2398 | 1888 | unsigned short i, tempdx, tempcx, tempbx, tempal, modeflag, table; |
d7636e0b | 1889 | |
cc1e2398 | 1890 | struct XGI330_LCDDataTablStruct *tempdi = NULL; |
d7636e0b | 1891 | |
cc1e2398 AK |
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; | |
21df8fc8 | 1900 | } |
cc1e2398 AK |
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; | |
21df8fc8 | 1910 | } |
d7636e0b | 1911 | |
cc1e2398 AK |
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; | |
21df8fc8 | 1919 | } |
d7636e0b | 1920 | |
cc1e2398 AK |
1921 | if (tempbx & 0x01) |
1922 | tempal = (tempal >> 4); | |
21df8fc8 | 1923 | |
cc1e2398 AK |
1924 | tempal = (tempal & 0x0f); |
1925 | } | |
21df8fc8 | 1926 | |
cc1e2398 | 1927 | tempcx = LCDLenList[tempbx]; /* mov cl,byte ptr cs:LCDLenList[bx] */ |
21df8fc8 | 1928 | |
cc1e2398 AK |
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); */ | |
21df8fc8 | 1937 | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 1968 | |
cc1e2398 AK |
1969 | if (tempdi == NULL) /* OEMUtil */ |
1970 | return NULL; | |
21df8fc8 | 1971 | |
cc1e2398 AK |
1972 | table = tempbx; |
1973 | i = 0; | |
21df8fc8 | 1974 | |
cc1e2398 AK |
1975 | while (tempdi[i].PANELID != 0xff) { |
1976 | tempdx = pVBInfo->LCDResInfo; | |
1977 | if (tempbx & 0x0080) { /* OEMUtil */ | |
1978 | tempbx &= (~0x0080); | |
1979 | tempdx = pVBInfo->LCDTypeInfo; | |
21df8fc8 PS |
1980 | } |
1981 | ||
cc1e2398 AK |
1982 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
1983 | tempdx &= (~PanelResInfo); | |
21df8fc8 | 1984 | |
cc1e2398 AK |
1985 | if (tempdi[i].PANELID == tempdx) { |
1986 | tempbx = tempdi[i].MASK; | |
1987 | tempdx = pVBInfo->LCDInfo; | |
21df8fc8 | 1988 | |
cc1e2398 AK |
1989 | if (ModeNo <= 0x13) /* alan 09/10/2003 */ |
1990 | tempdx |= SetLCDStdMode; | |
21df8fc8 | 1991 | |
cc1e2398 AK |
1992 | if (modeflag & HalfDCLK) |
1993 | tempdx |= SetLCDLowResolution; | |
21df8fc8 | 1994 | |
cc1e2398 AK |
1995 | tempbx &= tempdx; |
1996 | if (tempbx == tempdi[i].CAP) | |
1997 | break; | |
21df8fc8 | 1998 | } |
cc1e2398 AK |
1999 | i++; |
2000 | } | |
21df8fc8 | 2001 | |
cc1e2398 AK |
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; | |
21df8fc8 | 2039 | } |
cc1e2398 AK |
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; | |
21df8fc8 | 2077 | } |
cc1e2398 AK |
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]; | |
21df8fc8 | 2249 | else |
cc1e2398 AK |
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]; | |
21df8fc8 | 2256 | else |
cc1e2398 AK |
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]; | |
21df8fc8 | 2316 | else |
cc1e2398 AK |
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]; | |
21df8fc8 | 2323 | else |
cc1e2398 AK |
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; | |
21df8fc8 | 2338 | } |
cc1e2398 AK |
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; | |
21df8fc8 PS |
2349 | } |
2350 | } | |
cc1e2398 | 2351 | return NULL; |
d7636e0b | 2352 | } |
2353 | ||
cc1e2398 AK |
2354 | static void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo, |
2355 | unsigned short ModeIdIndex, | |
2356 | unsigned short RefreshRateTableIndex, | |
21df8fc8 PS |
2357 | struct vb_device_info *pVBInfo) |
2358 | { | |
cc1e2398 AK |
2359 | unsigned short i, tempdx, tempbx, tempal, modeflag, table; |
2360 | struct XGI330_TVDataTablStruct *tempdi = NULL; | |
21df8fc8 | 2361 | |
cc1e2398 | 2362 | tempbx = BX; |
21df8fc8 | 2363 | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 2371 | |
cc1e2398 AK |
2372 | tempal = tempal & 0x3f; |
2373 | table = tempbx; | |
21df8fc8 | 2374 | |
cc1e2398 AK |
2375 | switch (tempbx) { |
2376 | case 0: | |
2377 | tempdi = NULL; /*EPLCHTVCRT1Ptr_H;*/ | |
2378 | if (pVBInfo->IF_DEF_CH7007 == 1) | |
2379 | tempdi = XGI_EPLCHTVCRT1Ptr; | |
21df8fc8 | 2380 | |
cc1e2398 AK |
2381 | break; |
2382 | case 1: | |
2383 | tempdi = NULL; /*EPLCHTVCRT1Ptr_V;*/ | |
2384 | if (pVBInfo->IF_DEF_CH7007 == 1) | |
2385 | tempdi = XGI_EPLCHTVCRT1Ptr; | |
21df8fc8 | 2386 | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 2406 | |
cc1e2398 AK |
2407 | if (tempdi == NULL) /* OEMUtil */ |
2408 | return NULL; | |
21df8fc8 | 2409 | |
cc1e2398 | 2410 | tempdx = pVBInfo->TVInfo; |
21df8fc8 | 2411 | |
cc1e2398 AK |
2412 | if (pVBInfo->VBInfo & SetInSlaveMode) |
2413 | tempdx = tempdx | SetTVLockMode; | |
21df8fc8 | 2414 | |
cc1e2398 AK |
2415 | if (modeflag & HalfDCLK) |
2416 | tempdx = tempdx | SetTVLowResolution; | |
21df8fc8 | 2417 | |
cc1e2398 | 2418 | i = 0; |
21df8fc8 | 2419 | |
cc1e2398 AK |
2420 | while (tempdi[i].MASK != 0xffff) { |
2421 | if ((tempdx & tempdi[i].MASK) == tempdi[i].CAP) | |
2422 | break; | |
2423 | i++; | |
2424 | } | |
21df8fc8 | 2425 | |
cc1e2398 AK |
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; | |
21df8fc8 | 2474 | } |
cc1e2398 AK |
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; | |
21df8fc8 | 2491 | } |
cc1e2398 | 2492 | } else if (table == 0x06) { |
21df8fc8 | 2493 | } |
cc1e2398 | 2494 | return NULL; |
21df8fc8 | 2495 | } |
d7636e0b | 2496 | |
cc1e2398 AK |
2497 | static void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex, |
2498 | unsigned short RefreshRateTableIndex, | |
21df8fc8 PS |
2499 | struct vb_device_info *pVBInfo) |
2500 | { | |
cc1e2398 AK |
2501 | unsigned short tempbx; |
2502 | struct XGI330_LVDSDataStruct *LCDPtr = NULL; | |
2503 | struct XGI330_CHTVDataStruct *TVPtr = NULL; | |
d7636e0b | 2504 | |
cc1e2398 | 2505 | tempbx = 2; |
21df8fc8 | 2506 | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 2526 | } |
21df8fc8 | 2527 | |
cc1e2398 AK |
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; | |
21df8fc8 PS |
2547 | } |
2548 | } | |
21df8fc8 | 2549 | } |
21df8fc8 PS |
2550 | } |
2551 | ||
cc1e2398 AK |
2552 | static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex, |
2553 | unsigned short RefreshRateTableIndex, | |
21df8fc8 PS |
2554 | struct xgi_hw_device_info *HwDeviceExtension, |
2555 | struct vb_device_info *pVBInfo) | |
2556 | { | |
cc1e2398 AK |
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; | |
21df8fc8 PS |
2564 | |
2565 | if (ModeNo <= 0x13) | |
cc1e2398 | 2566 | index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; |
21df8fc8 | 2567 | else |
cc1e2398 | 2568 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; |
21df8fc8 | 2569 | |
cc1e2398 | 2570 | index = index & IndexMask; |
21df8fc8 | 2571 | |
cc1e2398 AK |
2572 | if ((pVBInfo->IF_DEF_ScaleLCD == 0) || ((pVBInfo->IF_DEF_ScaleLCD == 1) |
2573 | && (!(pVBInfo->LCDInfo & EnableScalingLCD)))) { | |
2574 | tempbx = 0; | |
21df8fc8 | 2575 | |
cc1e2398 AK |
2576 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
2577 | LCDPtr | |
2578 | = (struct XGI_LVDSCRT1HDataStruct *) XGI_GetLcdPtr( | |
2579 | tempbx, ModeNo, | |
2580 | ModeIdIndex, | |
2581 | RefreshRateTableIndex, | |
2582 | pVBInfo); | |
21df8fc8 | 2583 | |
cc1e2398 AK |
2584 | for (i = 0; i < 8; i++) |
2585 | pVBInfo->TimingH[0].data[i] = LCDPtr[0].Reg[i]; | |
2586 | } | |
21df8fc8 | 2587 | |
cc1e2398 AK |
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); | |
21df8fc8 | 2597 | |
cc1e2398 AK |
2598 | for (i = 0; i < 8; i++) |
2599 | pVBInfo->TimingH[0].data[i] | |
2600 | = CH7007TV_TimingHPtr[0].data[i]; | |
21df8fc8 PS |
2601 | } |
2602 | } | |
2603 | ||
cc1e2398 AK |
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 | */ | |
21df8fc8 | 2609 | |
cc1e2398 | 2610 | XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension); |
21df8fc8 | 2611 | |
cc1e2398 | 2612 | if (pVBInfo->IF_DEF_CH7007 == 1) { |
8104e329 | 2613 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, |
cc1e2398 | 2614 | CH7007TV_TimingHPtr[0].data[8]); |
8104e329 | 2615 | xgifb_reg_set(pVBInfo->P3c4, 0x2F, |
cc1e2398 | 2616 | CH7007TV_TimingHPtr[0].data[9]); |
21df8fc8 PS |
2617 | } |
2618 | ||
cc1e2398 | 2619 | tempbx = 1; |
21df8fc8 | 2620 | |
cc1e2398 AK |
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]; | |
21df8fc8 PS |
2630 | } |
2631 | ||
cc1e2398 AK |
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); | |
21df8fc8 | 2641 | |
cc1e2398 AK |
2642 | for (i = 0; i < 7; i++) |
2643 | pVBInfo->TimingV[0].data[i] | |
2644 | = CH7007TV_TimingVPtr[0].data[i]; | |
21df8fc8 PS |
2645 | } |
2646 | } | |
cc1e2398 AK |
2647 | /* if (pVBInfo->IF_DEF_CH7017 == 1) { |
2648 | if (pVBInfo->VBInfo & SetCRT2ToTV) | |
2649 | TVPtr = (struct XGI330_CHTVDataStruct *)XGI_GetTVPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); | |
21df8fc8 | 2650 | } |
cc1e2398 | 2651 | */ |
21df8fc8 | 2652 | |
cc1e2398 | 2653 | XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo); |
21df8fc8 | 2654 | |
cc1e2398 | 2655 | if (pVBInfo->IF_DEF_CH7007 == 1) { |
ec9e5d3e | 2656 | xgifb_reg_and_or(pVBInfo->P3c4, 0x33, ~0x01, |
cc1e2398 | 2657 | CH7007TV_TimingVPtr[0].data[7] & 0x01); |
8104e329 | 2658 | xgifb_reg_set(pVBInfo->P3c4, 0x34, |
cc1e2398 | 2659 | CH7007TV_TimingVPtr[0].data[8]); |
8104e329 | 2660 | xgifb_reg_set(pVBInfo->P3c4, 0x3F, |
cc1e2398 | 2661 | CH7007TV_TimingVPtr[0].data[9]); |
21df8fc8 | 2662 | |
21df8fc8 | 2663 | } |
cc1e2398 AK |
2664 | } |
2665 | } | |
21df8fc8 | 2666 | |
cc1e2398 AK |
2667 | static unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo) |
2668 | { | |
2669 | unsigned char tempal, tempah, tempbl, i; | |
2670 | ||
58839b01 | 2671 | tempah = xgifb_reg_get(pVBInfo->P3d4, 0x36); |
cc1e2398 AK |
2672 | tempal = tempah & 0x0F; |
2673 | tempah = tempah & 0xF0; | |
2674 | i = 0; | |
2675 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; | |
21df8fc8 | 2676 | |
cc1e2398 AK |
2677 | while (tempbl != 0xFF) { |
2678 | if (tempbl & 0x80) { /* OEMUtil */ | |
2679 | tempal = tempah; | |
2680 | tempbl = tempbl & ~(0x80); | |
21df8fc8 PS |
2681 | } |
2682 | ||
cc1e2398 AK |
2683 | if (tempal == tempbl) |
2684 | break; | |
21df8fc8 | 2685 | |
cc1e2398 | 2686 | i++; |
21df8fc8 | 2687 | |
cc1e2398 | 2688 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
21df8fc8 PS |
2689 | } |
2690 | ||
cc1e2398 | 2691 | return i; |
21df8fc8 PS |
2692 | } |
2693 | ||
cc1e2398 | 2694 | static unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo) |
21df8fc8 | 2695 | { |
cc1e2398 | 2696 | unsigned short tempah, tempal, tempbl, i; |
21df8fc8 | 2697 | |
cc1e2398 AK |
2698 | tempal = pVBInfo->LCDResInfo; |
2699 | tempah = pVBInfo->LCDTypeInfo; | |
21df8fc8 | 2700 | |
cc1e2398 AK |
2701 | i = 0; |
2702 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; | |
21df8fc8 | 2703 | |
cc1e2398 AK |
2704 | while (tempbl != 0xFF) { |
2705 | if ((tempbl & 0x80) && (tempbl != 0x80)) { | |
2706 | tempal = tempah; | |
2707 | tempbl &= ~0x80; | |
21df8fc8 PS |
2708 | } |
2709 | ||
cc1e2398 AK |
2710 | if (tempal == tempbl) |
2711 | break; | |
21df8fc8 | 2712 | |
cc1e2398 AK |
2713 | i++; |
2714 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; | |
2715 | } | |
21df8fc8 | 2716 | |
cc1e2398 AK |
2717 | if (tempbl == 0xFF) { |
2718 | pVBInfo->LCDResInfo = Panel1024x768; | |
2719 | pVBInfo->LCDTypeInfo = 0; | |
2720 | i = 0; | |
2721 | } | |
21df8fc8 | 2722 | |
cc1e2398 AK |
2723 | return i; |
2724 | } | |
21df8fc8 | 2725 | |
cc1e2398 AK |
2726 | static void XGI_GetLCDSync(unsigned short *HSyncWidth, unsigned short *VSyncWidth, |
2727 | struct vb_device_info *pVBInfo) | |
2728 | { | |
2729 | unsigned short Index; | |
21df8fc8 | 2730 | |
cc1e2398 AK |
2731 | Index = XGI_GetLCDCapPtr(pVBInfo); |
2732 | *HSyncWidth = pVBInfo->LCDCapList[Index].LCD_HSyncWidth; | |
2733 | *VSyncWidth = pVBInfo->LCDCapList[Index].LCD_VSyncWidth; | |
21df8fc8 | 2734 | |
cc1e2398 AK |
2735 | return; |
2736 | } | |
21df8fc8 | 2737 | |
cc1e2398 AK |
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; | |
21df8fc8 | 2746 | |
cc1e2398 AK |
2747 | if (ModeNo > 0x13) |
2748 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
2749 | else | |
2750 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
21df8fc8 | 2751 | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 2765 | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 2785 | |
cc1e2398 AK |
2786 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); |
2787 | push1 = tempbx; | |
2788 | push2 = tempax; | |
21df8fc8 | 2789 | |
cc1e2398 AK |
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; | |
21df8fc8 | 2804 | } else { |
cc1e2398 AK |
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; | |
21df8fc8 | 2820 | } |
21df8fc8 | 2821 | |
cc1e2398 | 2822 | tempax = pVBInfo->HT; |
21df8fc8 | 2823 | |
cc1e2398 AK |
2824 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
2825 | tempbx = LCDPtr1->LCDHDES; | |
2826 | else | |
2827 | tempbx = LCDPtr->LCDHDES; | |
21df8fc8 | 2828 | |
cc1e2398 AK |
2829 | tempcx = pVBInfo->HDE; |
2830 | tempbx = tempbx & 0x0fff; | |
2831 | tempcx += tempbx; | |
21df8fc8 | 2832 | |
cc1e2398 AK |
2833 | if (tempcx >= tempax) |
2834 | tempcx -= tempax; | |
21df8fc8 | 2835 | |
8104e329 | 2836 | xgifb_reg_set(pVBInfo->Part1Port, 0x1A, tempbx & 0x07); |
21df8fc8 | 2837 | |
cc1e2398 AK |
2838 | tempcx = tempcx >> 3; |
2839 | tempbx = tempbx >> 3; | |
2840 | ||
8104e329 | 2841 | xgifb_reg_set(pVBInfo->Part1Port, 0x16, |
cc1e2398 | 2842 | (unsigned short) (tempbx & 0xff)); |
8104e329 | 2843 | xgifb_reg_set(pVBInfo->Part1Port, 0x17, |
cc1e2398 AK |
2844 | (unsigned short) (tempcx & 0xff)); |
2845 | ||
2846 | tempax = pVBInfo->HT; | |
2847 | ||
2848 | if (pVBInfo->LCDInfo & EnableScalingLCD) | |
2849 | tempbx = LCDPtr1->LCDHRS; | |
21df8fc8 | 2850 | else |
cc1e2398 | 2851 | tempbx = LCDPtr->LCDHRS; |
21df8fc8 | 2852 | |
cc1e2398 | 2853 | tempcx = push2; |
21df8fc8 | 2854 | |
cc1e2398 AK |
2855 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
2856 | tempcx = LCDPtr1->LCDHSync; | |
21df8fc8 | 2857 | |
cc1e2398 | 2858 | tempcx += tempbx; |
21df8fc8 | 2859 | |
cc1e2398 AK |
2860 | if (tempcx >= tempax) |
2861 | tempcx -= tempax; | |
21df8fc8 | 2862 | |
cc1e2398 AK |
2863 | tempax = tempbx & 0x07; |
2864 | tempax = tempax >> 5; | |
2865 | tempcx = tempcx >> 3; | |
2866 | tempbx = tempbx >> 3; | |
21df8fc8 | 2867 | |
cc1e2398 AK |
2868 | tempcx &= 0x1f; |
2869 | tempax |= tempcx; | |
21df8fc8 | 2870 | |
8104e329 AK |
2871 | xgifb_reg_set(pVBInfo->Part1Port, 0x15, tempax); |
2872 | xgifb_reg_set(pVBInfo->Part1Port, 0x14, | |
cc1e2398 | 2873 | (unsigned short) (tempbx & 0xff)); |
21df8fc8 | 2874 | |
cc1e2398 AK |
2875 | tempax = pVBInfo->VT; |
2876 | if (pVBInfo->LCDInfo & EnableScalingLCD) | |
2877 | tempbx = LCDPtr1->LCDVDES; | |
2878 | else | |
2879 | tempbx = LCDPtr->LCDVDES; | |
2880 | tempcx = pVBInfo->VDE; | |
21df8fc8 | 2881 | |
cc1e2398 AK |
2882 | tempbx = tempbx & 0x0fff; |
2883 | tempcx += tempbx; | |
2884 | if (tempcx >= tempax) | |
2885 | tempcx -= tempax; | |
21df8fc8 | 2886 | |
8104e329 | 2887 | xgifb_reg_set(pVBInfo->Part1Port, 0x1b, |
cc1e2398 | 2888 | (unsigned short) (tempbx & 0xff)); |
8104e329 | 2889 | xgifb_reg_set(pVBInfo->Part1Port, 0x1c, |
cc1e2398 | 2890 | (unsigned short) (tempcx & 0xff)); |
21df8fc8 | 2891 | |
cc1e2398 AK |
2892 | tempbx = (tempbx >> 8) & 0x07; |
2893 | tempcx = (tempcx >> 8) & 0x07; | |
21df8fc8 | 2894 | |
8104e329 | 2895 | xgifb_reg_set(pVBInfo->Part1Port, 0x1d, |
cc1e2398 AK |
2896 | (unsigned short) ((tempcx << 3) |
2897 | | tempbx)); | |
21df8fc8 | 2898 | |
cc1e2398 AK |
2899 | tempax = pVBInfo->VT; |
2900 | if (pVBInfo->LCDInfo & EnableScalingLCD) | |
2901 | tempbx = LCDPtr1->LCDVRS; | |
2902 | else | |
2903 | tempbx = LCDPtr->LCDVRS; | |
21df8fc8 | 2904 | |
cc1e2398 AK |
2905 | /* tempbx = tempbx >> 4; */ |
2906 | tempcx = push1; | |
21df8fc8 | 2907 | |
cc1e2398 AK |
2908 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
2909 | tempcx = LCDPtr1->LCDVSync; | |
21df8fc8 | 2910 | |
cc1e2398 AK |
2911 | tempcx += tempbx; |
2912 | if (tempcx >= tempax) | |
2913 | tempcx -= tempax; | |
21df8fc8 | 2914 | |
8104e329 | 2915 | xgifb_reg_set(pVBInfo->Part1Port, 0x18, |
cc1e2398 | 2916 | (unsigned short) (tempbx & 0xff)); |
ec9e5d3e | 2917 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, ~0x0f, |
cc1e2398 | 2918 | (unsigned short) (tempcx & 0x0f)); |
21df8fc8 | 2919 | |
cc1e2398 | 2920 | tempax = ((tempbx >> 8) & 0x07) << 3; |
21df8fc8 | 2921 | |
cc1e2398 AK |
2922 | tempbx = pVBInfo->VGAVDE; |
2923 | if (tempbx != pVBInfo->VDE) | |
2924 | tempax |= 0x40; | |
21df8fc8 | 2925 | |
cc1e2398 AK |
2926 | if (pVBInfo->LCDInfo & EnableLVDSDDA) |
2927 | tempax |= 0x40; | |
21df8fc8 | 2928 | |
ec9e5d3e | 2929 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1a, 0x07, |
cc1e2398 | 2930 | tempax); |
21df8fc8 | 2931 | |
cc1e2398 AK |
2932 | tempcx = pVBInfo->VGAVT; |
2933 | tempbx = pVBInfo->VDE; | |
2934 | tempax = pVBInfo->VGAVDE; | |
2935 | tempcx -= tempax; | |
21df8fc8 | 2936 | |
cc1e2398 AK |
2937 | temp = tempax; /* 0430 ylshieh */ |
2938 | temp1 = (temp << 18) / tempbx; | |
21df8fc8 | 2939 | |
cc1e2398 | 2940 | tempdx = (unsigned short) ((temp << 18) % tempbx); |
21df8fc8 | 2941 | |
cc1e2398 AK |
2942 | if (tempdx != 0) |
2943 | temp1 += 1; | |
2944 | ||
2945 | temp2 = temp1; | |
2946 | push3 = temp2; | |
2947 | ||
8104e329 | 2948 | xgifb_reg_set(pVBInfo->Part1Port, 0x37, |
cc1e2398 | 2949 | (unsigned short) (temp2 & 0xff)); |
8104e329 | 2950 | xgifb_reg_set(pVBInfo->Part1Port, 0x36, |
cc1e2398 | 2951 | (unsigned short) ((temp2 >> 8) & 0xff)); |
21df8fc8 | 2952 | |
cc1e2398 AK |
2953 | tempbx = (unsigned short) (temp2 >> 16); |
2954 | tempax = tempbx & 0x03; | |
d7636e0b | 2955 | |
cc1e2398 AK |
2956 | tempbx = pVBInfo->VGAVDE; |
2957 | if (tempbx == pVBInfo->VDE) | |
2958 | tempax |= 0x04; | |
d7636e0b | 2959 | |
8104e329 | 2960 | xgifb_reg_set(pVBInfo->Part1Port, 0x35, tempax); |
21df8fc8 | 2961 | |
cc1e2398 AK |
2962 | if (pVBInfo->VBType & VB_XGI301C) { |
2963 | temp2 = push3; | |
8104e329 | 2964 | xgifb_reg_set(pVBInfo->Part4Port, 0x3c, |
cc1e2398 | 2965 | (unsigned short) (temp2 & 0xff)); |
8104e329 | 2966 | xgifb_reg_set(pVBInfo->Part4Port, 0x3b, |
cc1e2398 AK |
2967 | (unsigned short) ((temp2 >> 8) |
2968 | & 0xff)); | |
2969 | tempbx = (unsigned short) (temp2 >> 16); | |
ec9e5d3e | 2970 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x3a, |
cc1e2398 AK |
2971 | ~0xc0, |
2972 | (unsigned short) ((tempbx | |
2973 | & 0xff) << 6)); | |
21df8fc8 | 2974 | |
cc1e2398 AK |
2975 | tempcx = pVBInfo->VGAVDE; |
2976 | if (tempcx == pVBInfo->VDE) | |
ec9e5d3e | 2977 | xgifb_reg_and_or(pVBInfo->Part4Port, |
cc1e2398 AK |
2978 | 0x30, ~0x0c, 0x00); |
2979 | else | |
ec9e5d3e | 2980 | xgifb_reg_and_or(pVBInfo->Part4Port, |
cc1e2398 AK |
2981 | 0x30, ~0x0c, 0x08); |
2982 | } | |
21df8fc8 | 2983 | |
cc1e2398 AK |
2984 | tempcx = pVBInfo->VGAHDE; |
2985 | tempbx = pVBInfo->HDE; | |
21df8fc8 | 2986 | |
cc1e2398 | 2987 | temp1 = tempcx << 16; |
21df8fc8 | 2988 | |
cc1e2398 | 2989 | tempax = (unsigned short) (temp1 / tempbx); |
21df8fc8 | 2990 | |
cc1e2398 AK |
2991 | if ((tempbx & 0xffff) == (tempcx & 0xffff)) |
2992 | tempax = 65535; | |
d7636e0b | 2993 | |
cc1e2398 AK |
2994 | temp3 = tempax; |
2995 | temp1 = pVBInfo->VGAHDE << 16; | |
21df8fc8 | 2996 | |
cc1e2398 AK |
2997 | temp1 /= temp3; |
2998 | temp3 = temp3 << 16; | |
2999 | temp1 -= 1; | |
21df8fc8 | 3000 | |
cc1e2398 | 3001 | temp3 = (temp3 & 0xffff0000) + (temp1 & 0xffff); |
d7636e0b | 3002 | |
cc1e2398 | 3003 | tempax = (unsigned short) (temp3 & 0xff); |
8104e329 | 3004 | xgifb_reg_set(pVBInfo->Part1Port, 0x1f, tempax); |
21df8fc8 | 3005 | |
cc1e2398 AK |
3006 | temp1 = pVBInfo->VGAVDE << 18; |
3007 | temp1 = temp1 / push3; | |
3008 | tempbx = (unsigned short) (temp1 & 0xffff); | |
d7636e0b | 3009 | |
cc1e2398 AK |
3010 | if (pVBInfo->LCDResInfo == Panel1024x768) |
3011 | tempbx -= 1; | |
d7636e0b | 3012 | |
cc1e2398 AK |
3013 | tempax = ((tempbx >> 8) & 0xff) << 3; |
3014 | tempax |= (unsigned short) ((temp3 >> 8) & 0x07); | |
8104e329 | 3015 | xgifb_reg_set(pVBInfo->Part1Port, 0x20, |
cc1e2398 | 3016 | (unsigned short) (tempax & 0xff)); |
8104e329 | 3017 | xgifb_reg_set(pVBInfo->Part1Port, 0x21, |
cc1e2398 | 3018 | (unsigned short) (tempbx & 0xff)); |
21df8fc8 | 3019 | |
cc1e2398 | 3020 | temp3 = temp3 >> 16; |
21df8fc8 | 3021 | |
cc1e2398 AK |
3022 | if (modeflag & HalfDCLK) |
3023 | temp3 = temp3 >> 1; | |
21df8fc8 | 3024 | |
8104e329 | 3025 | xgifb_reg_set(pVBInfo->Part1Port, 0x22, |
cc1e2398 | 3026 | (unsigned short) ((temp3 >> 8) & 0xff)); |
8104e329 | 3027 | xgifb_reg_set(pVBInfo->Part1Port, 0x23, |
cc1e2398 AK |
3028 | (unsigned short) (temp3 & 0xff)); |
3029 | } | |
21df8fc8 PS |
3030 | } |
3031 | } | |
d7636e0b | 3032 | |
cc1e2398 AK |
3033 | /* --------------------------------------------------------------------- */ |
3034 | /* Function : XGI_GETLCDVCLKPtr */ | |
3035 | /* Input : */ | |
3036 | /* Output : al -> VCLK Index */ | |
3037 | /* Description : */ | |
3038 | /* --------------------------------------------------------------------- */ | |
3039 | static void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1, | |
21df8fc8 PS |
3040 | struct vb_device_info *pVBInfo) |
3041 | { | |
cc1e2398 | 3042 | unsigned short index; |
d7636e0b | 3043 | |
cc1e2398 AK |
3044 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
3045 | if (pVBInfo->IF_DEF_ScaleLCD == 1) { | |
3046 | if (pVBInfo->LCDInfo & EnableScalingLCD) | |
3047 | return; | |
21df8fc8 | 3048 | } |
d7636e0b | 3049 | |
cc1e2398 AK |
3050 | /* index = XGI_GetLCDCapPtr(pVBInfo); */ |
3051 | index = XGI_GetLCDCapPtr1(pVBInfo); | |
d7636e0b | 3052 | |
cc1e2398 AK |
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; | |
21df8fc8 | 3059 | } |
21df8fc8 | 3060 | } |
cc1e2398 | 3061 | return; |
d7636e0b | 3062 | } |
3063 | ||
cc1e2398 AK |
3064 | static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex, |
3065 | unsigned short ModeNo, unsigned short ModeIdIndex, | |
3066 | struct vb_device_info *pVBInfo) | |
d7636e0b | 3067 | { |
d7636e0b | 3068 | |
cc1e2398 AK |
3069 | unsigned short index, modeflag; |
3070 | unsigned short tempbx; | |
3071 | unsigned char tempal; | |
3072 | unsigned char *CHTVVCLKPtr = NULL; | |
d7636e0b | 3073 | |
cc1e2398 AK |
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 */ | |
d7636e0b | 3078 | |
cc1e2398 AK |
3079 | if ((pVBInfo->SetFlag & ProgrammingCRT2) && (!(pVBInfo->LCDInfo |
3080 | & EnableScalingLCD))) { /* {LCDA/LCDB} */ | |
3081 | index = XGI_GetLCDCapPtr(pVBInfo); | |
3082 | tempal = pVBInfo->LCDCapList[index].LCD_VCLK; | |
d7636e0b | 3083 | |
cc1e2398 AK |
3084 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) |
3085 | return tempal; | |
d7636e0b | 3086 | |
cc1e2398 AK |
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; | |
d7636e0b | 3098 | |
cc1e2398 AK |
3099 | } |
3100 | return tempal; | |
3101 | } | |
d7636e0b | 3102 | |
cc1e2398 AK |
3103 | if (pVBInfo->TVInfo & SetYPbPrMode750p) { |
3104 | tempal = YPbPr750pVCLK; | |
3105 | return tempal; | |
3106 | } | |
d7636e0b | 3107 | |
cc1e2398 AK |
3108 | if (pVBInfo->TVInfo & SetYPbPrMode525p) { |
3109 | tempal = YPbPr525pVCLK; | |
3110 | return tempal; | |
3111 | } | |
d7636e0b | 3112 | |
cc1e2398 | 3113 | tempal = NTSC1024VCLK; |
d7636e0b | 3114 | |
cc1e2398 AK |
3115 | if (!(pVBInfo->TVInfo & NTSC1024x768)) { |
3116 | tempal = TVVCLKDIV2; | |
3117 | if (!(pVBInfo->TVInfo & RPLLDIV2XO)) | |
3118 | tempal = TVVCLK; | |
3119 | } | |
d7636e0b | 3120 | |
cc1e2398 AK |
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} */ | |
d7636e0b | 3138 | |
cc1e2398 AK |
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 | } | |
d7636e0b | 3149 | |
cc1e2398 AK |
3150 | tempal = tempal & 0x0F; |
3151 | tempbx = 0; | |
d7636e0b | 3152 | |
cc1e2398 AK |
3153 | if (pVBInfo->TVInfo & SetPALTV) |
3154 | tempbx = tempbx + 2; | |
d7636e0b | 3155 | |
cc1e2398 AK |
3156 | if (pVBInfo->TVInfo & SetCHTVOverScan) |
3157 | tempbx++; | |
d7636e0b | 3158 | |
cc1e2398 | 3159 | /** tempbx = tempbx << 1; CH7007 ? **/ |
d7636e0b | 3160 | |
cc1e2398 AK |
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; | |
d7636e0b | 3178 | |
cc1e2398 AK |
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 | */ | |
d7636e0b | 3200 | |
cc1e2398 AK |
3201 | tempal = CHTVVCLKPtr[tempal]; |
3202 | return tempal; | |
3203 | } | |
d7636e0b | 3204 | |
21df8fc8 | 3205 | } |
d7636e0b | 3206 | |
d8ad0a6d | 3207 | tempal = (unsigned char) inb((pVBInfo->P3ca + 0x02)); |
cc1e2398 AK |
3208 | tempal = tempal >> 2; |
3209 | tempal &= 0x03; | |
d7636e0b | 3210 | |
cc1e2398 AK |
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; | |
d7636e0b | 3219 | } |
3220 | ||
cc1e2398 AK |
3221 | static void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0, |
3222 | unsigned char *di_1, struct vb_device_info *pVBInfo) | |
d7636e0b | 3223 | { |
cc1e2398 AK |
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 | } | |
d7636e0b | 3239 | } |
d7636e0b | 3240 | |
cc1e2398 AK |
3241 | static void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex, |
3242 | unsigned short RefreshRateTableIndex, | |
21df8fc8 PS |
3243 | struct vb_device_info *pVBInfo) |
3244 | { | |
cc1e2398 AK |
3245 | unsigned char di_0, di_1, tempal; |
3246 | int i; | |
21df8fc8 | 3247 | |
cc1e2398 AK |
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++) { | |
ec9e5d3e | 3254 | xgifb_reg_and_or(pVBInfo->P3d4, 0x31, ~0x30, |
cc1e2398 AK |
3255 | (unsigned short) (0x10 * i)); |
3256 | if (pVBInfo->IF_DEF_CH7007 == 1) { | |
8104e329 AK |
3257 | xgifb_reg_set(pVBInfo->P3c4, 0x2b, di_0); |
3258 | xgifb_reg_set(pVBInfo->P3c4, 0x2c, di_1); | |
cc1e2398 AK |
3259 | } else if ((!(pVBInfo->VBInfo & SetCRT2ToLCDA)) |
3260 | && (!(pVBInfo->VBInfo & SetInSlaveMode))) { | |
8104e329 AK |
3261 | xgifb_reg_set(pVBInfo->P3c4, 0x2e, di_0); |
3262 | xgifb_reg_set(pVBInfo->P3c4, 0x2f, di_1); | |
cc1e2398 | 3263 | } else { |
8104e329 AK |
3264 | xgifb_reg_set(pVBInfo->P3c4, 0x2b, di_0); |
3265 | xgifb_reg_set(pVBInfo->P3c4, 0x2c, di_1); | |
cc1e2398 AK |
3266 | } |
3267 | } | |
d7636e0b | 3268 | } |
3269 | ||
cc1e2398 AK |
3270 | static void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension, |
3271 | struct vb_device_info *pVBInfo) | |
d7636e0b | 3272 | { |
cc1e2398 | 3273 | unsigned short tempcl, tempch, temp, tempbl, tempax; |
d7636e0b | 3274 | |
cc1e2398 AK |
3275 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
3276 | | VB_XGI302LV | VB_XGI301C)) { | |
3277 | tempcl = 0; | |
3278 | tempch = 0; | |
58839b01 | 3279 | temp = xgifb_reg_get(pVBInfo->P3c4, 0x01); |
21df8fc8 | 3280 | |
cc1e2398 | 3281 | if (!(temp & 0x20)) { |
58839b01 | 3282 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x17); |
cc1e2398 | 3283 | if (temp & 0x80) { |
58839b01 | 3284 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x53); |
cc1e2398 AK |
3285 | if (!(temp & 0x40)) |
3286 | tempcl |= ActiveCRT1; | |
3287 | } | |
3288 | } | |
21df8fc8 | 3289 | |
58839b01 | 3290 | temp = xgifb_reg_get(pVBInfo->Part1Port, 0x2e); |
cc1e2398 | 3291 | temp &= 0x0f; |
21df8fc8 | 3292 | |
cc1e2398 | 3293 | if (!(temp == 0x08)) { |
58839b01 | 3294 | tempax = xgifb_reg_get(pVBInfo->Part1Port, 0x13); /* Check ChannelA by Part1_13 [2003/10/03] */ |
cc1e2398 AK |
3295 | if (tempax & 0x04) |
3296 | tempcl = tempcl | ActiveLCD; | |
21df8fc8 | 3297 | |
cc1e2398 | 3298 | temp &= 0x05; |
d7636e0b | 3299 | |
cc1e2398 AK |
3300 | if (!(tempcl & ActiveLCD)) |
3301 | if (temp == 0x01) | |
3302 | tempcl |= ActiveCRT2; | |
3303 | ||
3304 | if (temp == 0x04) | |
3305 | tempcl |= ActiveLCD; | |
3306 | ||
3307 | if (temp == 0x05) { | |
58839b01 | 3308 | temp = xgifb_reg_get(pVBInfo->Part2Port, 0x00); |
cc1e2398 AK |
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; | |
21df8fc8 | 3322 | } |
21df8fc8 | 3323 | |
cc1e2398 | 3324 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { |
58839b01 | 3325 | temp = xgifb_reg_get( |
cc1e2398 AK |
3326 | pVBInfo->Part2Port, |
3327 | 0x4d); | |
21df8fc8 | 3328 | |
cc1e2398 AK |
3329 | if (temp & 0x10) |
3330 | tempch |= ActiveYPbPr; | |
21df8fc8 | 3331 | } |
cc1e2398 AK |
3332 | |
3333 | if (tempch != 0) | |
3334 | tempcl |= ActiveTV; | |
21df8fc8 | 3335 | } |
cc1e2398 | 3336 | } |
21df8fc8 | 3337 | |
58839b01 | 3338 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x3d); |
cc1e2398 AK |
3339 | if (tempcl & ActiveLCD) { |
3340 | if ((pVBInfo->SetFlag & ReserveTVOption)) { | |
3341 | if (temp & ActiveTV) | |
3342 | tempcl |= ActiveTV; | |
21df8fc8 PS |
3343 | } |
3344 | } | |
cc1e2398 AK |
3345 | temp = tempcl; |
3346 | tempbl = ~ModeSwitchStatus; | |
ec9e5d3e | 3347 | xgifb_reg_and_or(pVBInfo->P3d4, 0x3d, tempbl, temp); |
21df8fc8 | 3348 | |
cc1e2398 | 3349 | if (!(pVBInfo->SetFlag & ReserveTVOption)) |
8104e329 | 3350 | xgifb_reg_set(pVBInfo->P3d4, 0x3e, tempch); |
cc1e2398 AK |
3351 | } else { |
3352 | return; | |
21df8fc8 | 3353 | } |
cc1e2398 | 3354 | } |
d7636e0b | 3355 | |
cc1e2398 AK |
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; | |
06587335 | 3362 | } else { |
cc1e2398 AK |
3363 | pVBInfo->Set_VGAType = VGA_XGI340; |
3364 | } | |
3365 | */ | |
3366 | pVBInfo->Set_VGAType = HwDeviceExtension->jChipType; | |
d7636e0b | 3367 | } |
3368 | ||
cc1e2398 | 3369 | void XGI_GetVBType(struct vb_device_info *pVBInfo) |
d7636e0b | 3370 | { |
cc1e2398 | 3371 | unsigned short flag, tempbx, tempah; |
d7636e0b | 3372 | |
cc1e2398 AK |
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; | |
58839b01 | 3379 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00); |
cc1e2398 AK |
3380 | if (flag != 0x02) { |
3381 | tempbx = VB_XGI301; | |
58839b01 | 3382 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x01); |
cc1e2398 AK |
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 | |
58839b01 | 3392 | = xgifb_reg_get( |
cc1e2398 AK |
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)) { | |
58839b01 | 3403 | flag = xgifb_reg_get( |
cc1e2398 AK |
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 | */ | |
d7636e0b | 3420 | |
d7636e0b | 3421 | } |
3422 | ||
cc1e2398 AK |
3423 | void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, |
3424 | struct xgi_hw_device_info *HwDeviceExtension, | |
21df8fc8 PS |
3425 | struct vb_device_info *pVBInfo) |
3426 | { | |
cc1e2398 | 3427 | unsigned short tempax, push, tempbx, temp, modeflag; |
d7636e0b | 3428 | |
cc1e2398 AK |
3429 | if (ModeNo <= 0x13) |
3430 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
3431 | else | |
3432 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
d7636e0b | 3433 | |
cc1e2398 AK |
3434 | pVBInfo->SetFlag = 0; |
3435 | pVBInfo->ModeType = modeflag & ModeInfoFlag; | |
3436 | tempbx = 0; | |
3437 | ||
3438 | if (pVBInfo->VBType & 0xFFFF) { | |
58839b01 | 3439 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x30); /* Check Display Device */ |
cc1e2398 | 3440 | tempbx = tempbx | temp; |
58839b01 | 3441 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x31); |
cc1e2398 AK |
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 | ||
58839b01 | 3451 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x38); |
cc1e2398 AK |
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; | |
d7636e0b | 3466 | |
cc1e2398 AK |
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; | |
21df8fc8 | 3477 | |
cc1e2398 AK |
3478 | if (temp & SetToLCDA) |
3479 | tempbx | |
3480 | |= SetCRT2ToLCDA; | |
3481 | } | |
3482 | } | |
3483 | } | |
3484 | } | |
3485 | } | |
21df8fc8 | 3486 | |
cc1e2398 AK |
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) { | |
58839b01 | 3500 | temp = xgifb_reg_get( |
cc1e2398 AK |
3501 | pVBInfo->P3d4, |
3502 | 0x35); /* shampoo add for new scratch */ | |
3503 | temp &= YPbPrMode; | |
3504 | tempbx |= SetCRT2ToHiVisionTV; | |
21df8fc8 | 3505 | |
cc1e2398 AK |
3506 | if (temp != YPbPrMode1080i) { |
3507 | tempbx | |
3508 | &= (~SetCRT2ToHiVisionTV); | |
3509 | tempbx | |
3510 | |= SetCRT2ToYPbPr; | |
3511 | } | |
3512 | } | |
21df8fc8 | 3513 | |
cc1e2398 AK |
3514 | /* tempbx |= SetCRT2ToYPbPr; */ |
3515 | } | |
3516 | } | |
3517 | } | |
21df8fc8 | 3518 | |
cc1e2398 | 3519 | tempax = push; /* restore CR31 */ |
21df8fc8 | 3520 | |
cc1e2398 AK |
3521 | if (pVBInfo->IF_DEF_LVDS == 0) { |
3522 | if (pVBInfo->IF_DEF_YPbPr == 1) { | |
3523 | if (pVBInfo->IF_DEF_HiVision == 1) | |
3524 | temp = 0x09FC; | |
21df8fc8 | 3525 | else |
cc1e2398 AK |
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; | |
21df8fc8 | 3539 | } else |
cc1e2398 AK |
3540 | temp = SetCRT2ToLCD; |
3541 | } | |
21df8fc8 | 3542 | |
cc1e2398 AK |
3543 | if (!(tempbx & temp)) { |
3544 | tempax |= DisableCRT2Display; | |
3545 | tempbx = 0; | |
21df8fc8 PS |
3546 | } |
3547 | ||
cc1e2398 AK |
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 | } | |
21df8fc8 PS |
3564 | } |
3565 | ||
cc1e2398 AK |
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 | } | |
21df8fc8 | 3580 | |
cc1e2398 AK |
3581 | if (!(pVBInfo->VBType & VB_NoLCD)) { |
3582 | if (tempbx & SetCRT2ToLCD) { | |
3583 | tempbx &= (0xFF00 | SetCRT2ToLCD | SwitchToCRT2 | |
3584 | | SetSimuScanMode); | |
3585 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr)); | |
3586 | } | |
3587 | } | |
21df8fc8 | 3588 | |
cc1e2398 AK |
3589 | if (tempbx & SetCRT2ToSCART) { |
3590 | tempbx &= (0xFF00 | SetCRT2ToSCART | SwitchToCRT2 | |
3591 | | SetSimuScanMode); | |
3592 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr)); | |
3593 | } | |
21df8fc8 | 3594 | |
cc1e2398 AK |
3595 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
3596 | if (tempbx & SetCRT2ToYPbPr) | |
3597 | tempbx &= (0xFF00 | SwitchToCRT2 | |
3598 | | SetSimuScanMode); | |
3599 | } | |
21df8fc8 | 3600 | |
cc1e2398 AK |
3601 | if (pVBInfo->IF_DEF_HiVision == 1) { |
3602 | if (tempbx & SetCRT2ToHiVisionTV) | |
3603 | tempbx &= (0xFF00 | SetCRT2ToHiVisionTV | |
3604 | | SwitchToCRT2 | |
3605 | | SetSimuScanMode); | |
3606 | } | |
21df8fc8 | 3607 | |
cc1e2398 AK |
3608 | if (tempax & DisableCRT2Display) { /* Set Display Device Info */ |
3609 | if (!(tempbx & (SwitchToCRT2 | SetSimuScanMode))) | |
3610 | tempbx = DisableCRT2Display; | |
3611 | } | |
21df8fc8 | 3612 | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 3622 | |
cc1e2398 AK |
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 | } | |
21df8fc8 PS |
3650 | } |
3651 | } | |
3652 | } | |
21df8fc8 | 3653 | |
cc1e2398 AK |
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; | |
21df8fc8 PS |
3660 | } |
3661 | } | |
21df8fc8 | 3662 | } |
cc1e2398 AK |
3663 | |
3664 | pVBInfo->VBInfo = tempbx; | |
21df8fc8 PS |
3665 | } |
3666 | ||
cc1e2398 | 3667 | void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex, |
21df8fc8 | 3668 | struct vb_device_info *pVBInfo) |
d7636e0b | 3669 | { |
cc1e2398 | 3670 | unsigned short temp, tempbx = 0, resinfo = 0, modeflag, index1; |
21df8fc8 | 3671 | |
cc1e2398 AK |
3672 | tempbx = 0; |
3673 | resinfo = 0; | |
d7636e0b | 3674 | |
cc1e2398 AK |
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 | } | |
d7636e0b | 3686 | |
cc1e2398 | 3687 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
58839b01 | 3688 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x35); |
cc1e2398 AK |
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) { | |
58839b01 | 3700 | index1 = xgifb_reg_get(pVBInfo->P3d4, 0x38); //PAL-M/PAL-N Info |
cc1e2398 AK |
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 | } | |
d7636e0b | 3708 | |
cc1e2398 | 3709 | if (pVBInfo->IF_DEF_CH7017 == 1) { |
58839b01 | 3710 | tempbx = xgifb_reg_get(pVBInfo->P3d4, 0x35); |
21df8fc8 | 3711 | |
cc1e2398 AK |
3712 | if (tempbx & TVOverScan) |
3713 | tempbx |= SetCHTVOverScan; | |
21df8fc8 PS |
3714 | } |
3715 | ||
cc1e2398 | 3716 | if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/04 */ |
58839b01 | 3717 | tempbx = xgifb_reg_get(pVBInfo->P3d4, 0x35); |
21df8fc8 | 3718 | |
cc1e2398 AK |
3719 | if (tempbx & TVOverScan) |
3720 | tempbx |= SetCHTVOverScan; | |
21df8fc8 | 3721 | } |
21df8fc8 | 3722 | |
cc1e2398 AK |
3723 | if (pVBInfo->IF_DEF_LVDS == 0) { |
3724 | if (pVBInfo->VBInfo & SetCRT2ToSCART) | |
3725 | tempbx |= SetPALTV; | |
3726 | } | |
d7636e0b | 3727 | |
cc1e2398 AK |
3728 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
3729 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { | |
58839b01 | 3730 | index1 = xgifb_reg_get(pVBInfo->P3d4, 0x35); |
cc1e2398 | 3731 | index1 &= YPbPrMode; |
d7636e0b | 3732 | |
cc1e2398 AK |
3733 | if (index1 == YPbPrMode525i) |
3734 | tempbx |= SetYPbPrMode525i; | |
21df8fc8 | 3735 | |
cc1e2398 AK |
3736 | if (index1 == YPbPrMode525p) |
3737 | tempbx = tempbx | SetYPbPrMode525p; | |
3738 | if (index1 == YPbPrMode750p) | |
3739 | tempbx = tempbx | SetYPbPrMode750p; | |
3740 | } | |
3741 | } | |
21df8fc8 | 3742 | |
cc1e2398 AK |
3743 | if (pVBInfo->IF_DEF_HiVision == 1) { |
3744 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) | |
3745 | tempbx = tempbx | SetYPbPrMode1080i | SetPALTV; | |
3746 | } | |
21df8fc8 | 3747 | |
cc1e2398 AK |
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; | |
21df8fc8 | 3758 | |
cc1e2398 AK |
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); | |
21df8fc8 | 3771 | } |
21df8fc8 | 3772 | } |
cc1e2398 AK |
3773 | } |
3774 | } | |
3775 | pVBInfo->TVInfo = tempbx; | |
3776 | } | |
21df8fc8 | 3777 | |
cc1e2398 AK |
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; | |
21df8fc8 | 3782 | |
cc1e2398 AK |
3783 | pVBInfo->LCDResInfo = 0; |
3784 | pVBInfo->LCDTypeInfo = 0; | |
3785 | pVBInfo->LCDInfo = 0; | |
21df8fc8 | 3786 | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 3793 | |
58839b01 | 3794 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x36); /* Get LCD Res.Info */ |
cc1e2398 | 3795 | tempbx = temp & 0x0F; |
21df8fc8 | 3796 | |
cc1e2398 AK |
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) { | |
58839b01 | 3803 | tempax = xgifb_reg_get(pVBInfo->P3d4, 0x33); |
cc1e2398 AK |
3804 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) |
3805 | tempax &= 0x0F; | |
21df8fc8 | 3806 | else |
cc1e2398 | 3807 | tempax = tempax >> 4; |
21df8fc8 | 3808 | |
cc1e2398 AK |
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; | |
21df8fc8 | 3815 | } |
cc1e2398 AK |
3816 | } |
3817 | } | |
21df8fc8 | 3818 | |
cc1e2398 | 3819 | pVBInfo->LCDResInfo = tempbx; |
21df8fc8 | 3820 | |
cc1e2398 | 3821 | /* End of LCD75 */ |
21df8fc8 | 3822 | |
cc1e2398 AK |
3823 | if (pVBInfo->IF_DEF_OEMUtil == 1) |
3824 | pVBInfo->LCDTypeInfo = (temp & 0xf0) >> 4; | |
21df8fc8 | 3825 | |
cc1e2398 AK |
3826 | if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))) |
3827 | return 0; | |
21df8fc8 | 3828 | |
cc1e2398 | 3829 | tempbx = 0; |
21df8fc8 | 3830 | |
58839b01 | 3831 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
d7636e0b | 3832 | |
cc1e2398 | 3833 | temp &= (ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable); |
d7636e0b | 3834 | |
cc1e2398 AK |
3835 | if ((pVBInfo->IF_DEF_ScaleLCD == 1) && (temp & LCDNonExpanding)) |
3836 | temp &= ~EnableScalingLCD; | |
d7636e0b | 3837 | |
cc1e2398 | 3838 | tempbx |= temp; |
d7636e0b | 3839 | |
cc1e2398 | 3840 | LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo); |
d7636e0b | 3841 | |
cc1e2398 | 3842 | tempax = pVBInfo->LCDCapList[LCDIdIndex].LCD_Capability; |
d7636e0b | 3843 | |
cc1e2398 AK |
3844 | if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */ |
3845 | if (((pVBInfo->VBType & VB_XGI302LV) || (pVBInfo->VBType | |
3846 | & VB_XGI301C)) && (tempax & LCDDualLink)) { | |
3847 | tempbx |= SetLCDDualLink; | |
21df8fc8 | 3848 | } |
21df8fc8 | 3849 | } |
21df8fc8 | 3850 | |
cc1e2398 AK |
3851 | if (pVBInfo->IF_DEF_CH7017 == 1) { |
3852 | if (tempax & LCDDualLink) | |
3853 | tempbx |= SetLCDDualLink; | |
3854 | } | |
21df8fc8 | 3855 | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 3862 | |
cc1e2398 AK |
3863 | /* |
3864 | if (tempax & LCDBToA) { | |
3865 | tempbx |= SetLCDBToA; | |
3866 | } | |
3867 | */ | |
21df8fc8 | 3868 | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 3886 | |
cc1e2398 AK |
3887 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
3888 | if (pVBInfo->VBInfo & SetNotSimuMode) | |
3889 | tempbx |= LCDVESATiming; | |
3890 | } else { | |
3891 | tempbx |= LCDVESATiming; | |
3892 | } | |
21df8fc8 | 3893 | |
cc1e2398 | 3894 | pVBInfo->LCDInfo = tempbx; |
d7636e0b | 3895 | |
cc1e2398 AK |
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 | } | |
d7636e0b | 3905 | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 3923 | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 3934 | } |
cc1e2398 | 3935 | */ |
d7636e0b | 3936 | |
cc1e2398 | 3937 | return 1; |
21df8fc8 | 3938 | } |
d7636e0b | 3939 | |
cc1e2398 AK |
3940 | unsigned char XGI_SearchModeID(unsigned short ModeNo, |
3941 | unsigned short *ModeIdIndex, struct vb_device_info *pVBInfo) | |
d7636e0b | 3942 | { |
cc1e2398 AK |
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 | } | |
d7636e0b | 3953 | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 3967 | } |
d7636e0b | 3968 | |
cc1e2398 | 3969 | return 1; |
21df8fc8 | 3970 | } |
d7636e0b | 3971 | |
cc1e2398 AK |
3972 | /* win2000 MM adapter not support standard mode! */ |
3973 | ||
3974 | #if 0 | |
3975 | static unsigned char XGINew_CheckMemorySize( | |
21df8fc8 | 3976 | struct xgi_hw_device_info *HwDeviceExtension, |
cc1e2398 AK |
3977 | unsigned short ModeNo, |
3978 | unsigned short ModeIdIndex, | |
21df8fc8 PS |
3979 | struct vb_device_info *pVBInfo) |
3980 | { | |
cc1e2398 | 3981 | unsigned short memorysize, modeflag, temp, temp1, tmp; |
d7636e0b | 3982 | |
cc1e2398 AK |
3983 | /* |
3984 | if ((HwDeviceExtension->jChipType == XGI_650) || | |
3985 | (HwDeviceExtension->jChipType == XGI_650M)) { | |
3986 | return 1; | |
21df8fc8 | 3987 | } |
cc1e2398 | 3988 | */ |
21df8fc8 PS |
3989 | |
3990 | if (ModeNo <= 0x13) | |
3991 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
3992 | else | |
3993 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
3994 | ||
cc1e2398 | 3995 | /* ModeType = modeflag&ModeInfoFlag; // Get mode type */ |
21df8fc8 | 3996 | |
cc1e2398 AK |
3997 | memorysize = modeflag & MemoryInfoFlag; |
3998 | memorysize = memorysize > MemorySizeShift; | |
3999 | memorysize++; /* Get memory size */ | |
21df8fc8 | 4000 | |
58839b01 | 4001 | temp = xgifb_reg_get(pVBInfo->P3c4, 0x14); /* Get DRAM Size */ |
cc1e2398 | 4002 | tmp = temp; |
21df8fc8 | 4003 | |
cc1e2398 AK |
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 | |
21df8fc8 | 4034 | |
cc1e2398 AK |
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 ; | |
21df8fc8 | 4040 | |
58839b01 | 4041 | data = xgifb_reg_get(pVBInfo->P3c4, 0x0F); |
cc1e2398 | 4042 | data &= 0x7F; |
8104e329 | 4043 | xgifb_reg_set(pVBInfo->P3c4, 0x0F, data); |
21df8fc8 | 4044 | |
cc1e2398 AK |
4045 | if (ModeNo > 0x13) { |
4046 | ModeFlag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
4047 | if ((ModeFlag & HalfDCLK) && (ModeFlag & DoubleScanMode)) { | |
58839b01 | 4048 | data = xgifb_reg_get(pVBInfo->P3c4, 0x0F); |
cc1e2398 | 4049 | data |= 0x80; |
8104e329 | 4050 | xgifb_reg_set(pVBInfo->P3c4, 0x0F, data); |
58839b01 | 4051 | data = xgifb_reg_get(pVBInfo->P3c4, 0x01); |
cc1e2398 | 4052 | data &= 0xF7; |
8104e329 | 4053 | xgifb_reg_set(pVBInfo->P3c4, 0x01, data); |
21df8fc8 | 4054 | } |
cc1e2398 AK |
4055 | } |
4056 | } | |
4057 | */ | |
21df8fc8 | 4058 | |
cc1e2398 AK |
4059 | static unsigned char XG21GPIODataTransfer(unsigned char ujDate) |
4060 | { | |
4061 | unsigned char ujRet = 0; | |
4062 | unsigned char i = 0; | |
21df8fc8 | 4063 | |
cc1e2398 AK |
4064 | for (i = 0; i < 8; i++) { |
4065 | ujRet = ujRet << 1; | |
4066 | /* ujRet |= GETBITS(ujDate >> i, 0:0); */ | |
4067 | ujRet |= (ujDate >> i) & 1; | |
21df8fc8 | 4068 | } |
d7636e0b | 4069 | |
cc1e2398 AK |
4070 | return ujRet; |
4071 | } | |
21df8fc8 | 4072 | |
cc1e2398 AK |
4073 | /*----------------------------------------------------------------------------*/ |
4074 | /* output */ | |
4075 | /* bl[5] : LVDS signal */ | |
4076 | /* bl[1] : LVDS backlight */ | |
4077 | /* bl[0] : LVDS VDD */ | |
4078 | /*----------------------------------------------------------------------------*/ | |
4079 | static unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo) | |
4080 | { | |
4081 | unsigned char CR4A, temp; | |
21df8fc8 | 4082 | |
58839b01 | 4083 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
dc50556b | 4084 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x23); /* enable GPIO write */ |
21df8fc8 | 4085 | |
58839b01 | 4086 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
21df8fc8 | 4087 | |
cc1e2398 AK |
4088 | temp = XG21GPIODataTransfer(temp); |
4089 | temp &= 0x23; | |
8104e329 | 4090 | xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A); |
cc1e2398 AK |
4091 | return temp; |
4092 | } | |
4093 | ||
4094 | /*----------------------------------------------------------------------------*/ | |
4095 | /* output */ | |
4096 | /* bl[5] : LVDS signal */ | |
4097 | /* bl[1] : LVDS backlight */ | |
4098 | /* bl[0] : LVDS VDD */ | |
4099 | /*----------------------------------------------------------------------------*/ | |
4100 | static unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo) | |
4101 | { | |
4102 | unsigned char CR4A, CRB4, temp; | |
21df8fc8 | 4103 | |
58839b01 | 4104 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
dc50556b | 4105 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x0C); /* enable GPIO write */ |
21df8fc8 | 4106 | |
58839b01 | 4107 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
21df8fc8 | 4108 | |
cc1e2398 AK |
4109 | temp &= 0x0C; |
4110 | temp >>= 2; | |
8104e329 | 4111 | xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A); |
58839b01 | 4112 | CRB4 = xgifb_reg_get(pVBInfo->P3d4, 0xB4); |
cc1e2398 AK |
4113 | temp |= ((CRB4 & 0x04) << 3); |
4114 | return temp; | |
4115 | } | |
21df8fc8 | 4116 | |
cc1e2398 AK |
4117 | void XGI_DisplayOn(struct xgi_hw_device_info *pXGIHWDE, |
4118 | struct vb_device_info *pVBInfo) | |
4119 | { | |
4120 | ||
ec9e5d3e | 4121 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x00); |
cc1e2398 AK |
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 | } | |
21df8fc8 | 4135 | |
21df8fc8 PS |
4136 | } |
4137 | ||
cc1e2398 | 4138 | if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/23 For CH7007 */ |
21df8fc8 | 4139 | |
cc1e2398 | 4140 | } |
21df8fc8 | 4141 | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 4155 | |
cc1e2398 | 4156 | } |
d7636e0b | 4157 | } |
4158 | ||
cc1e2398 | 4159 | void XGI_DisplayOff(struct xgi_hw_device_info *pXGIHWDE, |
21df8fc8 PS |
4160 | struct vb_device_info *pVBInfo) |
4161 | { | |
d7636e0b | 4162 | |
cc1e2398 AK |
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 | } | |
21df8fc8 PS |
4170 | } |
4171 | ||
cc1e2398 AK |
4172 | if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/23 For CH7007 */ |
4173 | /* if (IsCH7007TVMode(pVBInfo) == 0) */ | |
4174 | { | |
4175 | } | |
4176 | } | |
21df8fc8 | 4177 | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 4183 | |
cc1e2398 AK |
4184 | if (pVBInfo->IF_DEF_LVDS == 0) |
4185 | XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo); /* DVO/DVI signal off */ | |
4186 | } | |
21df8fc8 | 4187 | |
ec9e5d3e | 4188 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x20); |
cc1e2398 | 4189 | } |
21df8fc8 | 4190 | |
cc1e2398 AK |
4191 | static void XGI_WaitDisply(struct vb_device_info *pVBInfo) |
4192 | { | |
d8ad0a6d | 4193 | while ((inb(pVBInfo->P3da) & 0x01)) |
cc1e2398 | 4194 | break; |
21df8fc8 | 4195 | |
d8ad0a6d | 4196 | while (!(inb(pVBInfo->P3da) & 0x01)) |
cc1e2398 AK |
4197 | break; |
4198 | } | |
21df8fc8 | 4199 | |
cc1e2398 AK |
4200 | #if 0 |
4201 | static void XGI_WaitDisplay(struct vb_device_info *pVBInfo) | |
4202 | { | |
d8ad0a6d AK |
4203 | while (!(inb(pVBInfo->P3da) & 0x01)); |
4204 | while (inb(pVBInfo->P3da) & 0x01); | |
cc1e2398 AK |
4205 | } |
4206 | #endif | |
21df8fc8 | 4207 | |
cc1e2398 AK |
4208 | static void XGI_AutoThreshold(struct vb_device_info *pVBInfo) |
4209 | { | |
4210 | if (!(pVBInfo->SetFlag & Win9xDOSMode)) | |
b9bf6e4e | 4211 | xgifb_reg_or(pVBInfo->Part1Port, 0x01, 0x40); |
cc1e2398 | 4212 | } |
21df8fc8 | 4213 | |
cc1e2398 AK |
4214 | static void XGI_SaveCRT2Info(unsigned short ModeNo, struct vb_device_info *pVBInfo) |
4215 | { | |
4216 | unsigned short temp1, temp2; | |
21df8fc8 | 4217 | |
8104e329 | 4218 | xgifb_reg_set(pVBInfo->P3d4, 0x34, ModeNo); /* reserve CR34 for CRT1 Mode No */ |
cc1e2398 AK |
4219 | temp1 = (pVBInfo->VBInfo & SetInSlaveMode) >> 8; |
4220 | temp2 = ~(SetInSlaveMode >> 8); | |
ec9e5d3e | 4221 | xgifb_reg_and_or(pVBInfo->P3d4, 0x31, temp2, temp1); |
cc1e2398 | 4222 | } |
21df8fc8 | 4223 | |
cc1e2398 AK |
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; | |
21df8fc8 | 4228 | |
cc1e2398 AK |
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 */ | |
21df8fc8 | 4234 | } else { |
cc1e2398 AK |
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 */ | |
21df8fc8 | 4238 | |
cc1e2398 AK |
4239 | /* |
4240 | if (pVBInfo->IF_DEF_FSTN) { | |
4241 | xres *= 2; | |
4242 | yres *= 2; | |
4243 | } else { | |
4244 | */ | |
4245 | if (modeflag & HalfDCLK) | |
4246 | xres *= 2; | |
21df8fc8 | 4247 | |
cc1e2398 AK |
4248 | if (modeflag & DoubleScanMode) |
4249 | yres *= 2; | |
4250 | /* } */ | |
4251 | } | |
21df8fc8 | 4252 | |
cc1e2398 AK |
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; | |
21df8fc8 PS |
4259 | } |
4260 | } | |
4261 | ||
cc1e2398 AK |
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; | |
21df8fc8 PS |
4271 | } |
4272 | } | |
4273 | ||
cc1e2398 AK |
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 | } | |
21df8fc8 PS |
4285 | } |
4286 | } | |
4287 | } | |
cc1e2398 AK |
4288 | |
4289 | if (xres == 720) | |
4290 | xres = 640; | |
21df8fc8 PS |
4291 | } |
4292 | ||
cc1e2398 AK |
4293 | pVBInfo->VGAHDE = xres; |
4294 | pVBInfo->HDE = xres; | |
4295 | pVBInfo->VGAVDE = yres; | |
4296 | pVBInfo->VDE = yres; | |
4297 | } | |
21df8fc8 | 4298 | |
cc1e2398 AK |
4299 | static unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo) |
4300 | { | |
21df8fc8 | 4301 | |
cc1e2398 AK |
4302 | if ((pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) && |
4303 | (pVBInfo->LCDInfo & SetLCDDualLink)) /* shampoo0129 */ | |
4304 | return 1; | |
21df8fc8 | 4305 | |
cc1e2398 AK |
4306 | return 0; |
4307 | } | |
4308 | ||
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 | ||
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; | |
21df8fc8 | 4405 | |
21df8fc8 | 4406 | if (pVBInfo->LCDResInfo == Panel1024x768) { |
cc1e2398 AK |
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 */ | |
21df8fc8 | 4462 | if (!(pVBInfo->LCDInfo & LCDVESATiming)) { |
cc1e2398 AK |
4463 | if (pVBInfo->VGAVDE == 350) |
4464 | tempbx = 875; | |
4465 | else if (pVBInfo->VGAVDE == 400) | |
4466 | tempbx = 1000; | |
21df8fc8 PS |
4467 | } |
4468 | } | |
21df8fc8 | 4469 | |
cc1e2398 AK |
4470 | if (pVBInfo->LCDInfo & LCDNonExpanding) { |
4471 | tempax = pVBInfo->VGAHDE; | |
4472 | tempbx = pVBInfo->VGAVDE; | |
4473 | } | |
21df8fc8 | 4474 | |
cc1e2398 AK |
4475 | pVBInfo->HDE = tempax; |
4476 | pVBInfo->VDE = tempbx; | |
4477 | return; | |
4478 | } | |
21df8fc8 | 4479 | |
cc1e2398 AK |
4480 | if (pVBInfo->VBInfo & (SetCRT2ToTV)) { |
4481 | tempbx = 4; | |
4482 | TVPtr = (struct XGI_TVDataStruct *) XGI_GetTVPtr(tempbx, | |
4483 | ModeNo, ModeIdIndex, RefreshRateTableIndex, | |
4484 | pVBInfo); | |
21df8fc8 | 4485 | |
cc1e2398 AK |
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; | |
21df8fc8 | 4494 | |
cc1e2398 AK |
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; | |
21df8fc8 | 4502 | |
cc1e2398 AK |
4503 | if (pVBInfo->VGAVDE == 350) |
4504 | pVBInfo->TVInfo |= TVSimuMode; | |
21df8fc8 | 4505 | |
cc1e2398 AK |
4506 | tempax = ExtHiTVHT; |
4507 | tempbx = ExtHiTVVT; | |
21df8fc8 | 4508 | |
cc1e2398 | 4509 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
21df8fc8 | 4510 | if (pVBInfo->TVInfo & TVSimuMode) { |
cc1e2398 AK |
4511 | tempax = StHiTVHT; |
4512 | tempbx = StHiTVVT; | |
4513 | ||
4514 | if (!(modeflag & Charx8Dot)) { | |
4515 | tempax = StHiTextTVHT; | |
4516 | tempbx = StHiTextTVVT; | |
21df8fc8 PS |
4517 | } |
4518 | } | |
4519 | } | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 4535 | } else { |
cc1e2398 AK |
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; | |
21df8fc8 PS |
4543 | } |
4544 | } | |
21df8fc8 | 4545 | |
cc1e2398 AK |
4546 | pVBInfo->HT = tempax; |
4547 | pVBInfo->VT = tempbx; | |
4548 | return; | |
21df8fc8 | 4549 | } |
21df8fc8 PS |
4550 | } |
4551 | ||
cc1e2398 | 4552 | static void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex, |
21df8fc8 | 4553 | unsigned short RefreshRateTableIndex, |
21df8fc8 | 4554 | struct vb_device_info *pVBInfo) |
d7636e0b | 4555 | { |
cc1e2398 | 4556 | unsigned char di_0, di_1, tempal; |
21df8fc8 | 4557 | |
cc1e2398 AK |
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); | |
21df8fc8 | 4562 | |
cc1e2398 AK |
4563 | if (pVBInfo->VBType & VB_XGI301) { /* shampoo 0129 */ |
4564 | /* 301 */ | |
8104e329 AK |
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); | |
cc1e2398 | 4568 | } else { /* 301b/302b/301lv/302lv */ |
8104e329 AK |
4569 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0); |
4570 | xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1); | |
21df8fc8 PS |
4571 | } |
4572 | ||
8104e329 | 4573 | xgifb_reg_set(pVBInfo->Part4Port, 0x00, 0x12); |
21df8fc8 | 4574 | |
cc1e2398 | 4575 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) |
b9bf6e4e | 4576 | xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x28); |
cc1e2398 | 4577 | else |
b9bf6e4e | 4578 | xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x08); |
cc1e2398 | 4579 | } |
21df8fc8 | 4580 | |
cc1e2398 AK |
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; | |
21df8fc8 | 4587 | |
cc1e2398 AK |
4588 | if (ModeNo <= 0x13) |
4589 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
4590 | else | |
4591 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
21df8fc8 | 4592 | |
cc1e2398 | 4593 | index = (modeflag & ModeInfoFlag) - ModeEGA; |
21df8fc8 | 4594 | |
cc1e2398 AK |
4595 | if (index < 0) |
4596 | index = 0; | |
21df8fc8 | 4597 | |
cc1e2398 AK |
4598 | return ColorDepth[index]; |
4599 | } | |
21df8fc8 | 4600 | |
cc1e2398 AK |
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 }; | |
21df8fc8 | 4608 | |
cc1e2398 AK |
4609 | modeinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo; |
4610 | if (ModeNo <= 0x14) | |
4611 | infoflag = 0; | |
4612 | else | |
4613 | infoflag = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; | |
21df8fc8 | 4614 | |
cc1e2398 | 4615 | index = (modeinfo >> 8) & 0xFF; |
21df8fc8 | 4616 | |
cc1e2398 | 4617 | temp = pVBInfo->ScreenOffset[index]; |
21df8fc8 | 4618 | |
cc1e2398 AK |
4619 | if (infoflag & InterlaceMode) |
4620 | temp = temp << 1; | |
21df8fc8 | 4621 | |
cc1e2398 | 4622 | colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo); |
21df8fc8 | 4623 | |
cc1e2398 AK |
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; | |
21df8fc8 | 4633 | } |
cc1e2398 | 4634 | } |
21df8fc8 | 4635 | |
cc1e2398 AK |
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; | |
21df8fc8 | 4644 | |
cc1e2398 AK |
4645 | if (pVBInfo->VBInfo & SetInSlaveMode) |
4646 | return; | |
21df8fc8 | 4647 | |
cc1e2398 AK |
4648 | offset = XGI_GetOffset(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
4649 | HwDeviceExtension, pVBInfo); | |
4650 | temp = (unsigned char) (offset & 0xFF); | |
8104e329 | 4651 | xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp); |
cc1e2398 | 4652 | temp = (unsigned char) ((offset & 0xFF00) >> 8); |
8104e329 | 4653 | xgifb_reg_set(pVBInfo->Part1Port, 0x09, temp); |
cc1e2398 | 4654 | temp = (unsigned char) (((offset >> 3) & 0xFF) + 1); |
8104e329 | 4655 | xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp); |
cc1e2398 | 4656 | } |
21df8fc8 | 4657 | |
cc1e2398 AK |
4658 | static void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo) |
4659 | { | |
8104e329 | 4660 | xgifb_reg_set(pVBInfo->Part1Port, 0x01, 0x3B); /* threshold high ,disable auto threshold */ |
ec9e5d3e | 4661 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x02, ~(0x3F), 0x04); /* threshold low default 04h */ |
cc1e2398 | 4662 | } |
21df8fc8 | 4663 | |
cc1e2398 AK |
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; | |
21df8fc8 | 4670 | |
cc1e2398 AK |
4671 | if (ModeNo > 0x13) { |
4672 | CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; | |
4673 | CRT1Index &= IndexMask; | |
4674 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; | |
4675 | } | |
21df8fc8 | 4676 | |
cc1e2398 AK |
4677 | XGI_SetCRT2Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
4678 | HwDeviceExtension, pVBInfo); | |
4679 | XGI_SetCRT2FIFO(pVBInfo); | |
4680 | /* XGI_SetCRT2Sync(ModeNo,RefreshRateTableIndex); */ | |
21df8fc8 | 4681 | |
cc1e2398 | 4682 | for (tempcx = 4; tempcx < 7; tempcx++) |
8104e329 | 4683 | xgifb_reg_set(pVBInfo->Part1Port, tempcx, 0x0); |
21df8fc8 | 4684 | |
8104e329 AK |
4685 | xgifb_reg_set(pVBInfo->Part1Port, 0x50, 0x00); |
4686 | xgifb_reg_set(pVBInfo->Part1Port, 0x02, 0x44); /* temp 0206 */ | |
cc1e2398 | 4687 | } |
21df8fc8 | 4688 | |
cc1e2398 AK |
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; | |
21df8fc8 PS |
4701 | } |
4702 | ||
cc1e2398 AK |
4703 | if (ModeNo <= 0x13) |
4704 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
4705 | else | |
4706 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
21df8fc8 | 4707 | |
cc1e2398 AK |
4708 | /* bainy change table name */ |
4709 | if (modeflag & HalfDCLK) { | |
4710 | temp = (pVBInfo->VGAHT / 2 - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */ | |
8104e329 | 4711 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp); |
cc1e2398 | 4712 | temp = (((pVBInfo->VGAHT / 2 - 1) & 0xFF00) >> 8) << 4; |
ec9e5d3e | 4713 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp); |
cc1e2398 | 4714 | temp = (pVBInfo->VGAHDE / 2 + 16) & 0x0FF; /* BTVGA2HDEE 0x0A,0x0C */ |
8104e329 | 4715 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); |
cc1e2398 AK |
4716 | tempcx = ((pVBInfo->VGAHT - pVBInfo->VGAHDE) / 2) >> 2; |
4717 | pushbx = pVBInfo->VGAHDE / 2 + 16; | |
21df8fc8 | 4718 | tempcx = tempcx >> 1; |
cc1e2398 AK |
4719 | tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */ |
4720 | tempcx += tempbx; | |
21df8fc8 | 4721 | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 4733 | |
cc1e2398 AK |
4734 | tempbx += 4; |
4735 | tempcx += 4; | |
21df8fc8 | 4736 | |
cc1e2398 AK |
4737 | if (tempcx > (pVBInfo->VGAHT / 2)) |
4738 | tempcx = pVBInfo->VGAHT / 2; | |
21df8fc8 | 4739 | |
cc1e2398 | 4740 | temp = tempbx & 0x00FF; |
21df8fc8 | 4741 | |
8104e329 | 4742 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
cc1e2398 AK |
4743 | } else { |
4744 | temp = (pVBInfo->VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */ | |
8104e329 | 4745 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp); |
cc1e2398 | 4746 | temp = (((pVBInfo->VGAHT - 1) & 0xFF00) >> 8) << 4; |
ec9e5d3e | 4747 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp); |
cc1e2398 | 4748 | temp = (pVBInfo->VGAHDE + 16) & 0x0FF; /* BTVGA2HDEE 0x0A,0x0C */ |
8104e329 | 4749 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); |
cc1e2398 AK |
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; | |
21df8fc8 | 4755 | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 4769 | |
cc1e2398 AK |
4770 | if (tempcx > pVBInfo->VGAHT) |
4771 | tempcx = pVBInfo->VGAHT; | |
21df8fc8 | 4772 | |
cc1e2398 | 4773 | temp = tempbx & 0x00FF; |
8104e329 | 4774 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
cc1e2398 | 4775 | } |
21df8fc8 | 4776 | |
cc1e2398 AK |
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; | |
8104e329 | 4782 | xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp); |
21df8fc8 | 4783 | temp = tempcx & 0x00FF; |
8104e329 | 4784 | xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp); |
cc1e2398 | 4785 | tempcx = (pVBInfo->VGAVT - 1); |
21df8fc8 | 4786 | temp = tempcx & 0x00FF; |
21df8fc8 | 4787 | |
cc1e2398 AK |
4788 | if (pVBInfo->IF_DEF_CH7005 == 1) { |
4789 | if (pVBInfo->VBInfo & 0x0C) | |
4790 | temp--; | |
21df8fc8 | 4791 | } |
21df8fc8 | 4792 | |
8104e329 | 4793 | xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp); |
cc1e2398 AK |
4794 | tempbx = pVBInfo->VGAVDE - 1; |
4795 | temp = tempbx & 0x00FF; | |
8104e329 | 4796 | xgifb_reg_set(pVBInfo->Part1Port, 0x0F, temp); |
cc1e2398 AK |
4797 | temp = ((tempbx & 0xFF00) << 3) >> 8; |
4798 | temp |= ((tempcx & 0xFF00) >> 8); | |
8104e329 | 4799 | xgifb_reg_set(pVBInfo->Part1Port, 0x12, temp); |
21df8fc8 | 4800 | |
cc1e2398 AK |
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 */ | |
21df8fc8 | 4806 | |
cc1e2398 AK |
4807 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
4808 | tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[10]; | |
4809 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9]; | |
21df8fc8 | 4810 | |
cc1e2398 AK |
4811 | if (temp & 0x04) |
4812 | tempbx |= 0x0100; | |
21df8fc8 | 4813 | |
cc1e2398 AK |
4814 | if (temp & 0x080) |
4815 | tempbx |= 0x0200; | |
21df8fc8 | 4816 | |
cc1e2398 | 4817 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14]; |
21df8fc8 | 4818 | |
cc1e2398 AK |
4819 | if (temp & 0x08) |
4820 | tempbx |= 0x0400; | |
21df8fc8 | 4821 | |
cc1e2398 AK |
4822 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[11]; |
4823 | tempcx = (tempcx & 0xFF00) | (temp & 0x00FF); | |
21df8fc8 PS |
4824 | } |
4825 | ||
cc1e2398 | 4826 | temp = tempbx & 0x00FF; |
8104e329 | 4827 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); |
cc1e2398 AK |
4828 | temp = ((tempbx & 0xFF00) >> 8) << 4; |
4829 | temp = ((tempcx & 0x000F) | (temp)); | |
8104e329 | 4830 | xgifb_reg_set(pVBInfo->Part1Port, 0x11, temp); |
cc1e2398 | 4831 | tempax = 0; |
21df8fc8 | 4832 | |
cc1e2398 AK |
4833 | if (modeflag & DoubleScanMode) |
4834 | tempax |= 0x80; | |
21df8fc8 | 4835 | |
cc1e2398 AK |
4836 | if (modeflag & HalfDCLK) |
4837 | tempax |= 0x40; | |
21df8fc8 | 4838 | |
ec9e5d3e | 4839 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2C, ~0x0C0, tempax); |
cc1e2398 | 4840 | } |
21df8fc8 | 4841 | |
cc1e2398 AK |
4842 | static unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo) |
4843 | { | |
4844 | unsigned long tempax, tempbx; | |
21df8fc8 | 4845 | |
cc1e2398 AK |
4846 | tempbx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) * pVBInfo->RVBHCMAX) |
4847 | & 0xFFFF; | |
4848 | tempax = (pVBInfo->VT - pVBInfo->VDE) * pVBInfo->RVBHCFACT; | |
4849 | tempax = (tempax * pVBInfo->HT) / tempbx; | |
21df8fc8 | 4850 | |
cc1e2398 AK |
4851 | return (unsigned short) tempax; |
4852 | } | |
21df8fc8 | 4853 | |
cc1e2398 AK |
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; | |
21df8fc8 | 4861 | |
cc1e2398 AK |
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; | |
21df8fc8 PS |
4870 | } |
4871 | ||
cc1e2398 AK |
4872 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) |
4873 | return; | |
21df8fc8 | 4874 | |
cc1e2398 | 4875 | temp = 0xFF; /* set MAX HT */ |
8104e329 | 4876 | xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp); |
cc1e2398 AK |
4877 | /* if (modeflag & Charx8Dot) */ |
4878 | /* tempcx = 0x08; */ | |
4879 | /* else */ | |
4880 | tempcx = 0x08; | |
21df8fc8 | 4881 | |
cc1e2398 AK |
4882 | if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) |
4883 | modeflag |= Charx8Dot; | |
21df8fc8 | 4884 | |
cc1e2398 | 4885 | tempax = pVBInfo->VGAHDE; /* 0x04 Horizontal Display End */ |
21df8fc8 | 4886 | |
cc1e2398 AK |
4887 | if (modeflag & HalfDCLK) |
4888 | tempax = tempax >> 1; | |
21df8fc8 | 4889 | |
cc1e2398 AK |
4890 | tempax = (tempax / tempcx) - 1; |
4891 | tempbx |= ((tempax & 0x00FF) << 8); | |
4892 | temp = tempax & 0x00FF; | |
8104e329 | 4893 | xgifb_reg_set(pVBInfo->Part1Port, 0x04, temp); |
21df8fc8 | 4894 | |
cc1e2398 | 4895 | temp = (tempbx & 0xFF00) >> 8; |
21df8fc8 | 4896 | |
cc1e2398 AK |
4897 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
4898 | if (!(pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | |
4899 | | VB_XGI302LV | VB_XGI301C))) | |
4900 | temp += 2; | |
21df8fc8 | 4901 | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 4911 | } |
21df8fc8 PS |
4912 | } |
4913 | ||
8104e329 AK |
4914 | xgifb_reg_set(pVBInfo->Part1Port, 0x05, temp); /* 0x05 Horizontal Display Start */ |
4915 | xgifb_reg_set(pVBInfo->Part1Port, 0x06, 0x03); /* 0x06 Horizontal Blank end */ | |
21df8fc8 | 4916 | |
cc1e2398 AK |
4917 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { /* 030226 bainy */ |
4918 | if (pVBInfo->VBInfo & SetCRT2ToTV) | |
4919 | tempax = pVBInfo->VGAHT; | |
4920 | else | |
4921 | tempax = XGI_GetVGAHT2(pVBInfo); | |
4922 | } | |
21df8fc8 | 4923 | |
cc1e2398 AK |
4924 | if (tempax >= pVBInfo->VGAHT) |
4925 | tempax = pVBInfo->VGAHT; | |
21df8fc8 | 4926 | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 4942 | } else { |
cc1e2398 AK |
4943 | /* tempcx = tempbx & 0x00FF ; */ |
4944 | tempbx = (tempbx & 0xFF00) >> 8; | |
4945 | tempcx = (tempcx + tempbx) >> 1; | |
4946 | temp = (tempcx & 0x00FF) + 2; | |
21df8fc8 | 4947 | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 4975 | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 4991 | |
8104e329 AK |
4992 | xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp); /* 0x07 Horizontal Retrace Start */ |
4993 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, 0); /* 0x08 Horizontal Retrace End */ | |
21df8fc8 | 4994 | |
cc1e2398 AK |
4995 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
4996 | if (pVBInfo->TVInfo & TVSimuMode) { | |
4997 | if ((ModeNo == 0x06) || (ModeNo == 0x10) || (ModeNo | |
4998 | == 0x11) || (ModeNo == 0x13) || (ModeNo | |
4999 | == 0x0F)) { | |
8104e329 AK |
5000 | xgifb_reg_set(pVBInfo->Part1Port, 0x07, 0x5b); |
5001 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, 0x03); | |
cc1e2398 | 5002 | } |
21df8fc8 | 5003 | |
cc1e2398 AK |
5004 | if ((ModeNo == 0x00) || (ModeNo == 0x01)) { |
5005 | if (pVBInfo->TVInfo & SetNTSCTV) { | |
8104e329 | 5006 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 | 5007 | 0x07, 0x2A); |
8104e329 | 5008 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 AK |
5009 | 0x08, 0x61); |
5010 | } else { | |
8104e329 | 5011 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 | 5012 | 0x07, 0x2A); |
8104e329 | 5013 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 | 5014 | 0x08, 0x41); |
8104e329 | 5015 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 AK |
5016 | 0x0C, 0xF0); |
5017 | } | |
5018 | } | |
21df8fc8 | 5019 | |
cc1e2398 AK |
5020 | if ((ModeNo == 0x02) || (ModeNo == 0x03) || (ModeNo |
5021 | == 0x07)) { | |
5022 | if (pVBInfo->TVInfo & SetNTSCTV) { | |
8104e329 | 5023 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 | 5024 | 0x07, 0x54); |
8104e329 | 5025 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 AK |
5026 | 0x08, 0x00); |
5027 | } else { | |
8104e329 | 5028 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 | 5029 | 0x07, 0x55); |
8104e329 | 5030 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 | 5031 | 0x08, 0x00); |
8104e329 | 5032 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 AK |
5033 | 0x0C, 0xF0); |
5034 | } | |
5035 | } | |
21df8fc8 | 5036 | |
cc1e2398 AK |
5037 | if ((ModeNo == 0x04) || (ModeNo == 0x05) || (ModeNo |
5038 | == 0x0D) || (ModeNo == 0x50)) { | |
5039 | if (pVBInfo->TVInfo & SetNTSCTV) { | |
8104e329 | 5040 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 | 5041 | 0x07, 0x30); |
8104e329 | 5042 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 AK |
5043 | 0x08, 0x03); |
5044 | } else { | |
8104e329 | 5045 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 | 5046 | 0x07, 0x2f); |
8104e329 | 5047 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 AK |
5048 | 0x08, 0x02); |
5049 | } | |
21df8fc8 | 5050 | } |
21df8fc8 PS |
5051 | } |
5052 | } | |
5053 | ||
8104e329 | 5054 | xgifb_reg_set(pVBInfo->Part1Port, 0x18, 0x03); /* 0x18 SR0B */ |
ec9e5d3e | 5055 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0xF0, 0x00); |
8104e329 | 5056 | xgifb_reg_set(pVBInfo->Part1Port, 0x09, 0xFF); /* 0x09 Set Max VT */ |
21df8fc8 | 5057 | |
cc1e2398 AK |
5058 | tempbx = pVBInfo->VGAVT; |
5059 | push1 = tempbx; | |
5060 | tempcx = 0x121; | |
5061 | tempbx = pVBInfo->VGAVDE; /* 0x0E Virtical Display End */ | |
21df8fc8 | 5062 | |
cc1e2398 AK |
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; | |
21df8fc8 | 5073 | |
cc1e2398 | 5074 | push2 = tempbx; |
21df8fc8 | 5075 | |
cc1e2398 AK |
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; | |
8104e329 | 5090 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); /* 0x10 vertical Blank Start */ |
cc1e2398 AK |
5091 | tempbx = push2; |
5092 | tempbx--; | |
5093 | temp = tempbx & 0x00FF; | |
8104e329 | 5094 | xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp); |
d7636e0b | 5095 | |
cc1e2398 AK |
5096 | if (tempbx & 0x0100) |
5097 | tempcx |= 0x0002; | |
21df8fc8 | 5098 | |
cc1e2398 | 5099 | tempax = 0x000B; |
21df8fc8 | 5100 | |
cc1e2398 AK |
5101 | if (modeflag & DoubleScanMode) |
5102 | tempax |= 0x08000; | |
21df8fc8 | 5103 | |
cc1e2398 AK |
5104 | if (tempbx & 0x0200) |
5105 | tempcx |= 0x0040; | |
21df8fc8 | 5106 | |
cc1e2398 | 5107 | temp = (tempax & 0xFF00) >> 8; |
8104e329 | 5108 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
21df8fc8 | 5109 | |
cc1e2398 AK |
5110 | if (tempbx & 0x0400) |
5111 | tempcx |= 0x0600; | |
21df8fc8 | 5112 | |
8104e329 | 5113 | xgifb_reg_set(pVBInfo->Part1Port, 0x11, 0x00); /* 0x11 Vertival Blank End */ |
21df8fc8 | 5114 | |
cc1e2398 AK |
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 | } | |
21df8fc8 PS |
5160 | } |
5161 | } | |
5162 | } | |
cc1e2398 AK |
5163 | tempax = push1; |
5164 | tempax = tempax >> 2; | |
5165 | tempax++; | |
5166 | tempax += tempbx; | |
5167 | push1 = tempax; /* push ax */ | |
21df8fc8 | 5168 | |
cc1e2398 AK |
5169 | if ((pVBInfo->TVInfo & SetPALTV)) { |
5170 | if (tempbx <= 513) { | |
5171 | if (tempax >= 513) | |
5172 | tempbx = 513; | |
5173 | } | |
5174 | } | |
5175 | ||
5176 | temp = tempbx & 0x00FF; | |
8104e329 | 5177 | xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp); |
21df8fc8 PS |
5178 | tempbx--; |
5179 | temp = tempbx & 0x00FF; | |
8104e329 | 5180 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); |
21df8fc8 | 5181 | |
cc1e2398 AK |
5182 | if (tempbx & 0x0100) |
5183 | tempcx |= 0x0008; | |
21df8fc8 | 5184 | |
cc1e2398 | 5185 | if (tempbx & 0x0200) |
ec9e5d3e | 5186 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x0B, 0x0FF, 0x20); |
21df8fc8 | 5187 | |
cc1e2398 | 5188 | tempbx++; |
21df8fc8 | 5189 | |
cc1e2398 AK |
5190 | if (tempbx & 0x0100) |
5191 | tempcx |= 0x0004; | |
21df8fc8 | 5192 | |
cc1e2398 AK |
5193 | if (tempbx & 0x0200) |
5194 | tempcx |= 0x0080; | |
21df8fc8 | 5195 | |
cc1e2398 AK |
5196 | if (tempbx & 0x0400) |
5197 | tempcx |= 0x0C00; | |
21df8fc8 | 5198 | |
cc1e2398 AK |
5199 | tempbx = push1; /* pop ax */ |
5200 | temp = tempbx & 0x00FF; | |
5201 | temp &= 0x0F; | |
8104e329 | 5202 | xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp); /* 0x0D vertical Retrace End */ |
21df8fc8 | 5203 | |
cc1e2398 AK |
5204 | if (tempbx & 0x0010) |
5205 | tempcx |= 0x2000; | |
21df8fc8 | 5206 | |
cc1e2398 | 5207 | temp = tempcx & 0x00FF; |
8104e329 | 5208 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); /* 0x0A CR07 */ |
cc1e2398 | 5209 | temp = (tempcx & 0x0FF00) >> 8; |
8104e329 | 5210 | xgifb_reg_set(pVBInfo->Part1Port, 0x17, temp); /* 0x17 SR0A */ |
cc1e2398 AK |
5211 | tempax = modeflag; |
5212 | temp = (tempax & 0xFF00) >> 8; | |
21df8fc8 | 5213 | |
cc1e2398 | 5214 | temp = (temp >> 1) & 0x09; |
21df8fc8 | 5215 | |
cc1e2398 AK |
5216 | if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) |
5217 | temp |= 0x01; | |
21df8fc8 | 5218 | |
8104e329 AK |
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 */ | |
21df8fc8 | 5222 | |
cc1e2398 AK |
5223 | if (pVBInfo->LCDInfo & LCDRGB18Bit) |
5224 | temp = 0x80; | |
5225 | else | |
5226 | temp = 0x00; | |
21df8fc8 | 5227 | |
8104e329 | 5228 | xgifb_reg_set(pVBInfo->Part1Port, 0x1A, temp); /* 0x1A SR0E */ |
21df8fc8 | 5229 | |
cc1e2398 AK |
5230 | return; |
5231 | } | |
21df8fc8 | 5232 | |
cc1e2398 AK |
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; | |
21df8fc8 | 5241 | |
cc1e2398 AK |
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; | |
21df8fc8 PS |
5253 | } |
5254 | ||
cc1e2398 AK |
5255 | tempax = 0; |
5256 | ||
5257 | if (!(pVBInfo->VBInfo & SetCRT2ToAVIDEO)) | |
5258 | tempax |= 0x0800; | |
21df8fc8 | 5259 | |
cc1e2398 AK |
5260 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) |
5261 | tempax |= 0x0400; | |
21df8fc8 | 5262 | |
cc1e2398 AK |
5263 | if (pVBInfo->VBInfo & SetCRT2ToSCART) |
5264 | tempax |= 0x0200; | |
21df8fc8 | 5265 | |
cc1e2398 AK |
5266 | if (!(pVBInfo->TVInfo & SetPALTV)) |
5267 | tempax |= 0x1000; | |
21df8fc8 | 5268 | |
cc1e2398 AK |
5269 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) |
5270 | tempax |= 0x0100; | |
21df8fc8 | 5271 | |
cc1e2398 AK |
5272 | if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)) |
5273 | tempax &= 0xfe00; | |
21df8fc8 | 5274 | |
cc1e2398 | 5275 | tempax = (tempax & 0xff00) >> 8; |
21df8fc8 | 5276 | |
8104e329 | 5277 | xgifb_reg_set(pVBInfo->Part2Port, 0x0, tempax); |
cc1e2398 | 5278 | TimingPoint = pVBInfo->NTSCTiming; |
d7636e0b | 5279 | |
cc1e2398 AK |
5280 | if (pVBInfo->TVInfo & SetPALTV) |
5281 | TimingPoint = pVBInfo->PALTiming; | |
d7636e0b | 5282 | |
cc1e2398 AK |
5283 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
5284 | TimingPoint = pVBInfo->HiTVExtTiming; | |
d7636e0b | 5285 | |
cc1e2398 AK |
5286 | if (pVBInfo->VBInfo & SetInSlaveMode) |
5287 | TimingPoint = pVBInfo->HiTVSt2Timing; | |
d7636e0b | 5288 | |
cc1e2398 AK |
5289 | if (pVBInfo->SetFlag & TVSimuMode) |
5290 | TimingPoint = pVBInfo->HiTVSt1Timing; | |
21df8fc8 | 5291 | |
cc1e2398 AK |
5292 | if (!(modeflag & Charx8Dot)) |
5293 | TimingPoint = pVBInfo->HiTVTextTiming; | |
5294 | } | |
21df8fc8 PS |
5295 | |
5296 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { | |
5297 | if (pVBInfo->TVInfo & SetYPbPrMode525i) | |
cc1e2398 AK |
5298 | TimingPoint = pVBInfo->YPbPr525iTiming; |
5299 | ||
21df8fc8 | 5300 | if (pVBInfo->TVInfo & SetYPbPrMode525p) |
cc1e2398 AK |
5301 | TimingPoint = pVBInfo->YPbPr525pTiming; |
5302 | ||
21df8fc8 | 5303 | if (pVBInfo->TVInfo & SetYPbPrMode750p) |
cc1e2398 | 5304 | TimingPoint = pVBInfo->YPbPr750pTiming; |
21df8fc8 | 5305 | } |
d7636e0b | 5306 | |
cc1e2398 | 5307 | for (i = 0x01, j = 0; i <= 0x2D; i++, j++) |
8104e329 | 5308 | xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]); |
cc1e2398 AK |
5309 | |
5310 | for (i = 0x39; i <= 0x45; i++, j++) | |
8104e329 | 5311 | xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]); /* di->temp2[j] */ |
cc1e2398 AK |
5312 | |
5313 | if (pVBInfo->VBInfo & SetCRT2ToTV) | |
ec9e5d3e | 5314 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, 0x00); |
cc1e2398 AK |
5315 | |
5316 | temp = pVBInfo->NewFlickerMode; | |
5317 | temp &= 0x80; | |
ec9e5d3e | 5318 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xFF, temp); |
cc1e2398 | 5319 | |
21df8fc8 | 5320 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) |
cc1e2398 | 5321 | tempax = 950; |
21df8fc8 | 5322 | |
cc1e2398 AK |
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 | ||
8104e329 | 5350 | xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp); |
cc1e2398 AK |
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 | } | |
8104e329 | 5368 | xgifb_reg_set(pVBInfo->Part2Port, 0x02, temp); |
21df8fc8 | 5369 | } |
d7636e0b | 5370 | |
cc1e2398 AK |
5371 | /* 301b */ |
5372 | tempcx = pVBInfo->HT; | |
d7636e0b | 5373 | |
cc1e2398 AK |
5374 | if (XGI_IsLCDDualLink(pVBInfo)) |
5375 | tempcx = tempcx >> 1; | |
21df8fc8 | 5376 | |
cc1e2398 AK |
5377 | tempcx -= 2; |
5378 | temp = tempcx & 0x00FF; | |
8104e329 | 5379 | xgifb_reg_set(pVBInfo->Part2Port, 0x1B, temp); |
21df8fc8 | 5380 | |
cc1e2398 | 5381 | temp = (tempcx & 0xFF00) >> 8; |
ec9e5d3e | 5382 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F, temp); |
21df8fc8 | 5383 | |
cc1e2398 AK |
5384 | tempcx = pVBInfo->HT >> 1; |
5385 | push1 = tempcx; /* push cx */ | |
5386 | tempcx += 7; | |
21df8fc8 | 5387 | |
cc1e2398 AK |
5388 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) |
5389 | tempcx -= 4; | |
5390 | ||
5391 | temp = tempcx & 0x00FF; | |
5392 | temp = temp << 4; | |
ec9e5d3e | 5393 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x22, 0x0F, temp); |
cc1e2398 AK |
5394 | |
5395 | tempbx = TimingPoint[j] | ((TimingPoint[j + 1]) << 8); | |
5396 | tempbx += tempcx; | |
5397 | push2 = tempbx; | |
5398 | temp = tempbx & 0x00FF; | |
8104e329 | 5399 | xgifb_reg_set(pVBInfo->Part2Port, 0x24, temp); |
cc1e2398 AK |
5400 | temp = (tempbx & 0xFF00) >> 8; |
5401 | temp = temp << 4; | |
ec9e5d3e | 5402 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x25, 0x0F, temp); |
cc1e2398 AK |
5403 | |
5404 | tempbx = push2; | |
5405 | tempbx = tempbx + 8; | |
5406 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { | |
5407 | tempbx = tempbx - 4; | |
5408 | tempcx = tempbx; | |
21df8fc8 PS |
5409 | } |
5410 | ||
cc1e2398 | 5411 | temp = (tempbx & 0x00FF) << 4; |
ec9e5d3e | 5412 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x29, 0x0F, temp); |
d7636e0b | 5413 | |
cc1e2398 AK |
5414 | j += 2; |
5415 | tempcx += (TimingPoint[j] | ((TimingPoint[j + 1]) << 8)); | |
5416 | temp = tempcx & 0x00FF; | |
8104e329 | 5417 | xgifb_reg_set(pVBInfo->Part2Port, 0x27, temp); |
cc1e2398 | 5418 | temp = ((tempcx & 0xFF00) >> 8) << 4; |
ec9e5d3e | 5419 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x28, 0x0F, temp); |
21df8fc8 | 5420 | |
cc1e2398 AK |
5421 | tempcx += 8; |
5422 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) | |
5423 | tempcx -= 4; | |
21df8fc8 | 5424 | |
cc1e2398 AK |
5425 | temp = tempcx & 0xFF; |
5426 | temp = temp << 4; | |
ec9e5d3e | 5427 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2A, 0x0F, temp); |
cc1e2398 AK |
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; | |
ec9e5d3e | 5435 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2D, 0x0F, temp); |
cc1e2398 AK |
5436 | |
5437 | tempcx -= 11; | |
5438 | ||
5439 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) { | |
5440 | tempax = XGI_GetVGAHT2(pVBInfo); | |
5441 | tempcx = tempax - 1; | |
21df8fc8 | 5442 | } |
cc1e2398 | 5443 | temp = tempcx & 0x00FF; |
8104e329 | 5444 | xgifb_reg_set(pVBInfo->Part2Port, 0x2E, temp); |
d7636e0b | 5445 | |
cc1e2398 | 5446 | tempbx = pVBInfo->VDE; |
21df8fc8 | 5447 | |
cc1e2398 AK |
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; | |
21df8fc8 PS |
5462 | } |
5463 | ||
cc1e2398 AK |
5464 | tempbx -= 2; |
5465 | temp = tempbx & 0x00FF; | |
21df8fc8 | 5466 | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 5480 | } |
cc1e2398 | 5481 | } |
21df8fc8 | 5482 | |
8104e329 | 5483 | xgifb_reg_set(pVBInfo->Part2Port, 0x2F, temp); |
21df8fc8 | 5484 | |
cc1e2398 AK |
5485 | temp = (tempcx & 0xFF00) >> 8; |
5486 | temp |= ((tempbx & 0xFF00) >> 8) << 6; | |
21df8fc8 | 5487 | |
cc1e2398 AK |
5488 | if (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)) { |
5489 | if (pVBInfo->VBType & VB_XGI301LV) { | |
5490 | if (pVBInfo->TVInfo & SetYPbPrMode1080i) { | |
5491 | temp |= 0x10; | |
21df8fc8 | 5492 | |
cc1e2398 AK |
5493 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) |
5494 | temp |= 0x20; | |
5495 | } | |
5496 | } else { | |
5497 | temp |= 0x10; | |
5498 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) | |
5499 | temp |= 0x20; | |
21df8fc8 PS |
5500 | } |
5501 | } | |
21df8fc8 | 5502 | |
8104e329 | 5503 | xgifb_reg_set(pVBInfo->Part2Port, 0x30, temp); |
21df8fc8 | 5504 | |
cc1e2398 AK |
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; | |
21df8fc8 | 5509 | |
cc1e2398 AK |
5510 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
5511 | if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | |
5512 | | SetYPbPrMode750p))) | |
5513 | tempbx = tempbx >> 1; | |
5514 | } | |
21df8fc8 | 5515 | |
cc1e2398 AK |
5516 | if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) { |
5517 | temp = 0; | |
5518 | if (tempcx & 0x0400) | |
5519 | temp |= 0x20; | |
21df8fc8 | 5520 | |
cc1e2398 AK |
5521 | if (tempbx & 0x0400) |
5522 | temp |= 0x40; | |
21df8fc8 | 5523 | |
8104e329 | 5524 | xgifb_reg_set(pVBInfo->Part4Port, 0x10, temp); |
cc1e2398 | 5525 | } |
21df8fc8 | 5526 | |
cc1e2398 | 5527 | temp = (((tempbx - 3) & 0x0300) >> 8) << 5; |
8104e329 | 5528 | xgifb_reg_set(pVBInfo->Part2Port, 0x46, temp); |
cc1e2398 | 5529 | temp = (tempbx - 3) & 0x00FF; |
8104e329 | 5530 | xgifb_reg_set(pVBInfo->Part2Port, 0x47, temp); |
cc1e2398 | 5531 | } |
21df8fc8 | 5532 | |
cc1e2398 | 5533 | tempbx = tempbx & 0x00FF; |
21df8fc8 | 5534 | |
cc1e2398 AK |
5535 | if (!(modeflag & HalfDCLK)) { |
5536 | tempcx = pVBInfo->VGAHDE; | |
5537 | if (tempcx >= pVBInfo->HDE) { | |
5538 | tempbx |= 0x2000; | |
5539 | tempax &= 0x00FF; | |
5540 | } | |
5541 | } | |
21df8fc8 | 5542 | |
cc1e2398 | 5543 | tempcx = 0x0101; |
21df8fc8 | 5544 | |
cc1e2398 AK |
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 | } | |
21df8fc8 PS |
5552 | } |
5553 | } | |
5554 | ||
cc1e2398 AK |
5555 | if (!(tempbx & 0x2000)) { |
5556 | if (modeflag & HalfDCLK) | |
5557 | tempcx = (tempcx & 0xFF00) | ((tempcx & 0x00FF) << 1); | |
21df8fc8 | 5558 | |
cc1e2398 AK |
5559 | push1 = tempbx; |
5560 | tempeax = pVBInfo->VGAHDE; | |
5561 | tempebx = (tempcx & 0xFF00) >> 8; | |
5562 | longtemp = tempeax * tempebx; | |
5563 | tempecx = tempcx & 0x00FF; | |
5564 | longtemp = longtemp / tempecx; | |
21df8fc8 | 5565 | |
cc1e2398 AK |
5566 | /* 301b */ |
5567 | tempecx = 8 * 1024; | |
21df8fc8 | 5568 | |
cc1e2398 AK |
5569 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
5570 | | VB_XGI302LV | VB_XGI301C)) { | |
5571 | tempecx = tempecx * 8; | |
5572 | } | |
21df8fc8 | 5573 | |
cc1e2398 AK |
5574 | longtemp = longtemp * tempecx; |
5575 | tempecx = pVBInfo->HDE; | |
5576 | temp2 = longtemp % tempecx; | |
5577 | tempeax = longtemp / tempecx; | |
5578 | if (temp2 != 0) | |
5579 | tempeax += 1; | |
21df8fc8 | 5580 | |
cc1e2398 | 5581 | tempax = (unsigned short) tempeax; |
21df8fc8 | 5582 | |
cc1e2398 AK |
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 */ | |
21df8fc8 | 5589 | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 5599 | |
8104e329 | 5600 | xgifb_reg_set(pVBInfo->Part2Port, 0x44, temp); |
cc1e2398 | 5601 | temp = (tempbx & 0xFF00) >> 8; |
ec9e5d3e | 5602 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x45, ~0x03F, temp); |
cc1e2398 | 5603 | temp = tempcx & 0x00FF; |
21df8fc8 | 5604 | |
cc1e2398 AK |
5605 | if (tempbx & 0x2000) |
5606 | temp = 0; | |
21df8fc8 | 5607 | |
cc1e2398 AK |
5608 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
5609 | temp |= 0x18; | |
21df8fc8 | 5610 | |
ec9e5d3e | 5611 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x46, ~0x1F, temp); |
cc1e2398 AK |
5612 | if (pVBInfo->TVInfo & SetPALTV) { |
5613 | tempbx = 0x0382; | |
5614 | tempcx = 0x007e; | |
5615 | } else { | |
5616 | tempbx = 0x0369; | |
5617 | tempcx = 0x0061; | |
5618 | } | |
21df8fc8 | 5619 | |
cc1e2398 | 5620 | temp = tempbx & 0x00FF; |
8104e329 | 5621 | xgifb_reg_set(pVBInfo->Part2Port, 0x4b, temp); |
cc1e2398 | 5622 | temp = tempcx & 0x00FF; |
8104e329 | 5623 | xgifb_reg_set(pVBInfo->Part2Port, 0x4c, temp); |
21df8fc8 | 5624 | |
cc1e2398 AK |
5625 | temp = ((tempcx & 0xFF00) >> 8) & 0x03; |
5626 | temp = temp << 2; | |
5627 | temp |= ((tempbx & 0xFF00) >> 8) & 0x03; | |
21df8fc8 | 5628 | |
cc1e2398 AK |
5629 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { |
5630 | temp |= 0x10; | |
21df8fc8 | 5631 | |
cc1e2398 AK |
5632 | if (pVBInfo->TVInfo & SetYPbPrMode525p) |
5633 | temp |= 0x20; | |
21df8fc8 | 5634 | |
cc1e2398 AK |
5635 | if (pVBInfo->TVInfo & SetYPbPrMode750p) |
5636 | temp |= 0x60; | |
5637 | } | |
21df8fc8 | 5638 | |
8104e329 | 5639 | xgifb_reg_set(pVBInfo->Part2Port, 0x4d, temp); |
58839b01 | 5640 | temp = xgifb_reg_get(pVBInfo->Part2Port, 0x43); /* 301b change */ |
8104e329 | 5641 | xgifb_reg_set(pVBInfo->Part2Port, 0x43, (unsigned short) (temp - 3)); |
cc1e2398 AK |
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++) { | |
8104e329 | 5647 | xgifb_reg_set(pVBInfo->Part2Port, i, |
cc1e2398 | 5648 | TimingPoint[j]); |
21df8fc8 | 5649 | } |
8104e329 | 5650 | xgifb_reg_set(pVBInfo->Part2Port, 0x43, 0x72); |
21df8fc8 | 5651 | } |
cc1e2398 | 5652 | } |
21df8fc8 | 5653 | |
cc1e2398 AK |
5654 | /* [ycchen] 01/14/03 Modify for 301C PALM Support */ |
5655 | if (pVBInfo->VBType & VB_XGI301C) { | |
5656 | if (pVBInfo->TVInfo & SetPALMTV) | |
ec9e5d3e | 5657 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x08, |
cc1e2398 | 5658 | 0x08); /* PALM Mode */ |
21df8fc8 | 5659 | } |
21df8fc8 | 5660 | |
cc1e2398 | 5661 | if (pVBInfo->TVInfo & SetPALMTV) { |
58839b01 | 5662 | tempax = (unsigned char) xgifb_reg_get(pVBInfo->Part2Port, |
cc1e2398 AK |
5663 | 0x01); |
5664 | tempax--; | |
dc50556b | 5665 | xgifb_reg_and(pVBInfo->Part2Port, 0x01, tempax); |
d7636e0b | 5666 | |
cc1e2398 | 5667 | /* if ( !( pVBInfo->VBType & VB_XGI301C ) ) */ |
dc50556b | 5668 | xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xEF); |
cc1e2398 | 5669 | } |
21df8fc8 | 5670 | |
cc1e2398 AK |
5671 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
5672 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) | |
8104e329 | 5673 | xgifb_reg_set(pVBInfo->Part2Port, 0x0B, 0x00); |
21df8fc8 | 5674 | } |
cc1e2398 AK |
5675 | |
5676 | if (pVBInfo->VBInfo & SetCRT2ToTV) | |
5677 | return; | |
21df8fc8 | 5678 | } |
d7636e0b | 5679 | |
cc1e2398 AK |
5680 | static void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex, |
5681 | struct xgi_hw_device_info *HwDeviceExtension, | |
21df8fc8 PS |
5682 | unsigned short RefreshRateTableIndex, |
5683 | struct vb_device_info *pVBInfo) | |
5684 | { | |
cc1e2398 AK |
5685 | unsigned short push1, push2, pushbx, tempax, tempbx, tempcx, temp, |
5686 | tempah, tempbh, tempch, resinfo, modeflag, CRT1Index; | |
d7636e0b | 5687 | |
cc1e2398 | 5688 | struct XGI_LCDDesStruct *LCDBDesPtr = NULL; |
d7636e0b | 5689 | |
21df8fc8 | 5690 | if (ModeNo <= 0x13) { |
cc1e2398 AK |
5691 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; /* si+St_ResInfo */ |
5692 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; | |
21df8fc8 | 5693 | } else { |
cc1e2398 AK |
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; | |
21df8fc8 | 5699 | } |
d7636e0b | 5700 | |
cc1e2398 AK |
5701 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
5702 | return; | |
21df8fc8 | 5703 | |
cc1e2398 | 5704 | tempbx = pVBInfo->HDE; /* RHACTE=HDE-1 */ |
21df8fc8 | 5705 | |
cc1e2398 AK |
5706 | if (XGI_IsLCDDualLink(pVBInfo)) |
5707 | tempbx = tempbx >> 1; | |
21df8fc8 | 5708 | |
cc1e2398 AK |
5709 | tempbx -= 1; |
5710 | temp = tempbx & 0x00FF; | |
8104e329 | 5711 | xgifb_reg_set(pVBInfo->Part2Port, 0x2C, temp); |
cc1e2398 AK |
5712 | temp = (tempbx & 0xFF00) >> 8; |
5713 | temp = temp << 4; | |
ec9e5d3e | 5714 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2B, 0x0F, temp); |
cc1e2398 | 5715 | temp = 0x01; |
21df8fc8 | 5716 | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 5725 | } |
d7636e0b | 5726 | |
8104e329 | 5727 | xgifb_reg_set(pVBInfo->Part2Port, 0x0B, temp); |
cc1e2398 AK |
5728 | tempbx = pVBInfo->VDE; /* RTVACTEO=(VDE-1)&0xFF */ |
5729 | push1 = tempbx; | |
5730 | tempbx--; | |
5731 | temp = tempbx & 0x00FF; | |
8104e329 | 5732 | xgifb_reg_set(pVBInfo->Part2Port, 0x03, temp); |
cc1e2398 | 5733 | temp = ((tempbx & 0xFF00) >> 8) & 0x07; |
ec9e5d3e | 5734 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0C, ~0x07, temp); |
21df8fc8 | 5735 | |
cc1e2398 AK |
5736 | tempcx = pVBInfo->VT - 1; |
5737 | push2 = tempcx + 1; | |
5738 | temp = tempcx & 0x00FF; /* RVTVT=VT-1 */ | |
8104e329 | 5739 | xgifb_reg_set(pVBInfo->Part2Port, 0x19, temp); |
cc1e2398 AK |
5740 | temp = (tempcx & 0xFF00) >> 8; |
5741 | temp = temp << 5; | |
8104e329 | 5742 | xgifb_reg_set(pVBInfo->Part2Port, 0x1A, temp); |
ec9e5d3e AK |
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); | |
d7636e0b | 5747 | |
cc1e2398 AK |
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; | |
d7636e0b | 5754 | |
cc1e2398 AK |
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 | } | |
d7636e0b | 5768 | |
cc1e2398 AK |
5769 | if (pVBInfo->LCDInfo & EnableScalingLCD) { |
5770 | tempbx = pVBInfo->HDE; | |
5771 | tempcx = pVBInfo->VDE; | |
5772 | } | |
d7636e0b | 5773 | |
cc1e2398 AK |
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; | |
d7636e0b | 5782 | |
cc1e2398 AK |
5783 | if (tempcx >= tempax) |
5784 | tempcx -= tempax; /* lcdvdes */ | |
d7636e0b | 5785 | |
cc1e2398 | 5786 | temp = tempbx & 0x00FF; /* RVEQ1EQ=lcdvdes */ |
8104e329 | 5787 | xgifb_reg_set(pVBInfo->Part2Port, 0x05, temp); |
cc1e2398 | 5788 | temp = tempcx & 0x00FF; |
8104e329 | 5789 | xgifb_reg_set(pVBInfo->Part2Port, 0x06, temp); |
cc1e2398 AK |
5790 | tempch = ((tempcx & 0xFF00) >> 8) & 0x07; |
5791 | tempbh = ((tempbx & 0xFF00) >> 8) & 0x07; | |
5792 | tempah = tempch; | |
5793 | tempah = tempah << 3; | |
5794 | tempah |= tempbh; | |
8104e329 | 5795 | xgifb_reg_set(pVBInfo->Part2Port, 0x02, tempah); |
d7636e0b | 5796 | |
cc1e2398 AK |
5797 | /* getlcdsync() */ |
5798 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); | |
5799 | tempcx = tempbx; | |
5800 | tempax = pVBInfo->VT; | |
5801 | tempbx = pVBInfo->LCDVRS; | |
d7636e0b | 5802 | |
cc1e2398 AK |
5803 | /* if (SetLCD_Info & EnableScalingLCD) */ |
5804 | tempcx += tempbx; | |
5805 | if (tempcx >= tempax) | |
5806 | tempcx -= tempax; | |
d7636e0b | 5807 | |
cc1e2398 | 5808 | temp = tempbx & 0x00FF; /* RTVACTEE=lcdvrs */ |
8104e329 | 5809 | xgifb_reg_set(pVBInfo->Part2Port, 0x04, temp); |
cc1e2398 AK |
5810 | temp = (tempbx & 0xFF00) >> 8; |
5811 | temp = temp << 4; | |
5812 | temp |= (tempcx & 0x000F); | |
8104e329 | 5813 | xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp); |
cc1e2398 AK |
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; | |
8104e329 | 5837 | xgifb_reg_set(pVBInfo->Part2Port, 0x1F, temp); /* RHBLKE=lcdhdes */ |
cc1e2398 | 5838 | temp = ((tempbx & 0xFF00) >> 8) << 4; |
8104e329 | 5839 | xgifb_reg_set(pVBInfo->Part2Port, 0x20, temp); |
cc1e2398 | 5840 | temp = tempcx & 0x00FF; |
8104e329 | 5841 | xgifb_reg_set(pVBInfo->Part2Port, 0x23, temp); /* RHEQPLE=lcdhdee */ |
cc1e2398 | 5842 | temp = (tempcx & 0xFF00) >> 8; |
8104e329 | 5843 | xgifb_reg_set(pVBInfo->Part2Port, 0x25, temp); |
cc1e2398 AK |
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 */ | |
8104e329 | 5866 | xgifb_reg_set(pVBInfo->Part2Port, 0x1C, temp); |
cc1e2398 AK |
5867 | |
5868 | temp = (tempbx & 0xFF00) >> 8; | |
5869 | temp = temp << 4; | |
ec9e5d3e | 5870 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F0, temp); |
cc1e2398 | 5871 | temp = tempcx & 0x00FF; /* RHSYEXP2S=lcdhre */ |
8104e329 | 5872 | xgifb_reg_set(pVBInfo->Part2Port, 0x21, temp); |
cc1e2398 AK |
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 | ||
8104e329 AK |
5883 | xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp); |
5884 | xgifb_reg_set(pVBInfo->Part2Port, 0x30, 0xB3); | |
21df8fc8 | 5885 | } |
cc1e2398 AK |
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; | |
8104e329 | 5894 | xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp); |
21df8fc8 | 5895 | } |
cc1e2398 AK |
5896 | } |
5897 | } | |
5898 | ||
5899 | /* --------------------------------------------------------------------- */ | |
5900 | /* Function : XGI_GetTap4Ptr */ | |
5901 | /* Input : */ | |
5902 | /* Output : di -> Tap4 Reg. Setting Pointer */ | |
5903 | /* Description : */ | |
5904 | /* --------------------------------------------------------------------- */ | |
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) | |
21df8fc8 | 5945 | break; |
cc1e2398 AK |
5946 | i++; |
5947 | } | |
5948 | return &Tap4TimingPtr[i]; | |
5949 | } | |
5950 | ||
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 | |
dc50556b | 5961 | xgifb_reg_and(pVBInfo->Part2Port, 0x4E, 0xEB); /* Disable Tap4 */ |
cc1e2398 AK |
5962 | #else /* Tap4 Setting */ |
5963 | ||
5964 | Tap4TimingPtr = XGI_GetTap4Ptr(0, pVBInfo); /* Set Horizontal Scaling */ | |
5965 | for (i = 0x80, j = 0; i <= 0xBF; i++, j++) | |
8104e329 | 5966 | xgifb_reg_set(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]); |
cc1e2398 AK |
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++) | |
8104e329 | 5971 | xgifb_reg_set(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]); |
cc1e2398 AK |
5972 | } |
5973 | ||
5974 | if ((pVBInfo->VBInfo & SetCRT2ToTV) && (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV))) | |
ec9e5d3e | 5975 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x04); /* Enable V.Scaling */ |
cc1e2398 | 5976 | else |
ec9e5d3e | 5977 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x10); /* Enable H.Scaling */ |
cc1e2398 AK |
5978 | #endif |
5979 | } | |
5980 | ||
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 | ||
8104e329 | 5993 | xgifb_reg_set(pVBInfo->Part3Port, 0x00, 0x00); |
cc1e2398 | 5994 | if (pVBInfo->TVInfo & SetPALTV) { |
8104e329 AK |
5995 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA); |
5996 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8); | |
cc1e2398 | 5997 | } else { |
8104e329 AK |
5998 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xF5); |
5999 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xB7); | |
cc1e2398 AK |
6000 | } |
6001 | ||
6002 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) | |
6003 | return; | |
6004 | ||
6005 | if (pVBInfo->TVInfo & SetPALMTV) { | |
8104e329 AK |
6006 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA); |
6007 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8); | |
6008 | xgifb_reg_set(pVBInfo->Part3Port, 0x3D, 0xA8); | |
cc1e2398 AK |
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; | |
21df8fc8 | 6021 | } |
cc1e2398 AK |
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++) | |
8104e329 | 6030 | xgifb_reg_set(pVBInfo->Part3Port, i, tempdi[i]); |
cc1e2398 AK |
6031 | |
6032 | if (pVBInfo->VBType & VB_XGI301C) { /* Marcovision */ | |
6033 | if (pVBInfo->TVInfo & SetYPbPrMode525p) | |
8104e329 | 6034 | xgifb_reg_set(pVBInfo->Part3Port, 0x28, 0x3f); |
21df8fc8 PS |
6035 | } |
6036 | } | |
cc1e2398 AK |
6037 | return; |
6038 | } /* {end of XGI_SetGroup3} */ | |
d7636e0b | 6039 | |
cc1e2398 | 6040 | static void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex, |
21df8fc8 | 6041 | unsigned short RefreshRateTableIndex, |
cc1e2398 | 6042 | struct xgi_hw_device_info *HwDeviceExtension, |
21df8fc8 PS |
6043 | struct vb_device_info *pVBInfo) |
6044 | { | |
cc1e2398 | 6045 | unsigned short tempax, tempcx, tempbx, modeflag, temp, temp2; |
d7636e0b | 6046 | |
cc1e2398 AK |
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; | |
8104e329 | 6055 | xgifb_reg_set(pVBInfo->Part4Port, 0x13, temp); |
cc1e2398 AK |
6056 | |
6057 | tempbx = pVBInfo->RVBHCMAX; | |
6058 | temp = tempbx & 0x00FF; | |
8104e329 | 6059 | xgifb_reg_set(pVBInfo->Part4Port, 0x14, temp); |
cc1e2398 AK |
6060 | temp2 = ((tempbx & 0xFF00) >> 8) << 7; |
6061 | tempcx = pVBInfo->VGAHT - 1; | |
6062 | temp = tempcx & 0x00FF; | |
8104e329 | 6063 | xgifb_reg_set(pVBInfo->Part4Port, 0x16, temp); |
cc1e2398 AK |
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; | |
8104e329 | 6073 | xgifb_reg_set(pVBInfo->Part4Port, 0x17, temp); |
cc1e2398 | 6074 | temp = temp2 | ((tempcx & 0xFF00) >> 8); |
8104e329 | 6075 | xgifb_reg_set(pVBInfo->Part4Port, 0x15, temp); |
b9bf6e4e | 6076 | xgifb_reg_or(pVBInfo->Part4Port, 0x0D, 0x08); |
cc1e2398 AK |
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 | } | |
ec9e5d3e | 6112 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0E, ~0xEF, temp); |
cc1e2398 AK |
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; | |
8104e329 | 6123 | xgifb_reg_set(pVBInfo->Part4Port, 0x18, temp); |
cc1e2398 AK |
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); | |
8104e329 | 6143 | xgifb_reg_set(pVBInfo->Part4Port, 0x1B, temp); |
cc1e2398 AK |
6144 | |
6145 | temp = (unsigned short) ((tempebx & 0x0000FF00) >> 8); | |
8104e329 | 6146 | xgifb_reg_set(pVBInfo->Part4Port, 0x1A, temp); |
cc1e2398 AK |
6147 | tempbx = (unsigned short) (tempebx >> 16); |
6148 | temp = tempbx & 0x00FF; | |
6149 | temp = temp << 4; | |
6150 | temp |= ((tempcx & 0xFF00) >> 8); | |
8104e329 | 6151 | xgifb_reg_set(pVBInfo->Part4Port, 0x19, temp); |
cc1e2398 AK |
6152 | |
6153 | /* 301b */ | |
6154 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | |
6155 | | VB_XGI302LV | VB_XGI301C)) { | |
6156 | temp = 0x0028; | |
8104e329 | 6157 | xgifb_reg_set(pVBInfo->Part4Port, 0x1C, temp); |
cc1e2398 AK |
6158 | tempax = pVBInfo->VGAHDE; |
6159 | if (modeflag & HalfDCLK) | |
6160 | tempax = tempax >> 1; | |
d7636e0b | 6161 | |
cc1e2398 AK |
6162 | if (XGI_IsLCDDualLink(pVBInfo)) |
6163 | tempax = tempax >> 1; | |
d7636e0b | 6164 | |
cc1e2398 AK |
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; | |
21df8fc8 | 6178 | |
cc1e2398 AK |
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 | */ | |
21df8fc8 | 6200 | |
cc1e2398 AK |
6201 | temp = (tempax & 0xFF00) >> 8; |
6202 | temp = ((temp & 0x0003) << 4); | |
8104e329 | 6203 | xgifb_reg_set(pVBInfo->Part4Port, 0x1E, temp); |
cc1e2398 | 6204 | temp = (tempax & 0x00FF); |
8104e329 | 6205 | xgifb_reg_set(pVBInfo->Part4Port, 0x1D, temp); |
21df8fc8 | 6206 | |
cc1e2398 AK |
6207 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVisionTV)) { |
6208 | if (pVBInfo->VGAHDE > 800) | |
b9bf6e4e | 6209 | xgifb_reg_or(pVBInfo->Part4Port, 0x1E, 0x08); |
d7636e0b | 6210 | |
cc1e2398 AK |
6211 | } |
6212 | temp = 0x0036; | |
d7636e0b | 6213 | |
cc1e2398 AK |
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 | } | |
d7636e0b | 6225 | |
ec9e5d3e | 6226 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x1F, 0x00C0, temp); |
cc1e2398 AK |
6227 | tempbx = pVBInfo->HT; |
6228 | if (XGI_IsLCDDualLink(pVBInfo)) | |
6229 | tempbx = tempbx >> 1; | |
6230 | tempbx = (tempbx >> 1) - 2; | |
6231 | temp = ((tempbx & 0x0700) >> 8) << 3; | |
ec9e5d3e | 6232 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, 0x00C0, temp); |
cc1e2398 | 6233 | temp = tempbx & 0x00FF; |
8104e329 | 6234 | xgifb_reg_set(pVBInfo->Part4Port, 0x22, temp); |
cc1e2398 AK |
6235 | } |
6236 | /* end 301b */ | |
d7636e0b | 6237 | |
cc1e2398 AK |
6238 | if (pVBInfo->ISXPDOS == 0) |
6239 | XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, | |
6240 | pVBInfo); | |
6241 | } | |
d7636e0b | 6242 | |
cc1e2398 AK |
6243 | static void XGINew_EnableCRT2(struct vb_device_info *pVBInfo) |
6244 | { | |
ec9e5d3e | 6245 | xgifb_reg_and_or(pVBInfo->P3c4, 0x1E, 0xFF, 0x20); |
cc1e2398 | 6246 | } |
d7636e0b | 6247 | |
cc1e2398 AK |
6248 | static void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex, |
6249 | struct vb_device_info *pVBInfo) | |
6250 | { | |
6251 | unsigned short Pindex, Pdata; | |
d7636e0b | 6252 | |
cc1e2398 AK |
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); */ | |
21df8fc8 | 6260 | } |
21df8fc8 | 6261 | } |
cc1e2398 | 6262 | return; |
d7636e0b | 6263 | } |
6264 | ||
063b9c4b | 6265 | static void XGI_EnableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, |
21df8fc8 | 6266 | struct vb_device_info *pVBInfo) |
d7636e0b | 6267 | { |
ec9e5d3e | 6268 | xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x40); |
d7636e0b | 6269 | } |
6270 | ||
063b9c4b | 6271 | static void XGI_DisableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, |
21df8fc8 | 6272 | struct vb_device_info *pVBInfo) |
d7636e0b | 6273 | { |
6274 | ||
ec9e5d3e | 6275 | xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x00); |
d7636e0b | 6276 | } |
6277 | ||
d7636e0b | 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 | /*----------------------------------------------------------------------------*/ | |
21df8fc8 PS |
6287 | void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl, |
6288 | struct vb_device_info *pVBInfo) | |
d7636e0b | 6289 | { |
21df8fc8 | 6290 | unsigned char CR4A, temp; |
d7636e0b | 6291 | |
58839b01 | 6292 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
21df8fc8 PS |
6293 | tempbh &= 0x23; |
6294 | tempbl &= 0x23; | |
dc50556b | 6295 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */ |
d7636e0b | 6296 | |
21df8fc8 PS |
6297 | if (tempbh & 0x20) { |
6298 | temp = (tempbl >> 4) & 0x02; | |
d7636e0b | 6299 | |
ec9e5d3e | 6300 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp); /* CR B4[1] */ |
d7636e0b | 6301 | |
21df8fc8 | 6302 | } |
d7636e0b | 6303 | |
58839b01 | 6304 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
d7636e0b | 6305 | |
21df8fc8 PS |
6306 | temp = XG21GPIODataTransfer(temp); |
6307 | temp &= ~tempbh; | |
6308 | temp |= tempbl; | |
8104e329 | 6309 | xgifb_reg_set(pVBInfo->P3d4, 0x48, temp); |
d7636e0b | 6310 | } |
6311 | ||
21df8fc8 PS |
6312 | void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl, |
6313 | struct vb_device_info *pVBInfo) | |
d7636e0b | 6314 | { |
21df8fc8 PS |
6315 | unsigned char CR4A, temp; |
6316 | unsigned short tempbh0, tempbl0; | |
d7636e0b | 6317 | |
21df8fc8 PS |
6318 | tempbh0 = tempbh; |
6319 | tempbl0 = tempbl; | |
6320 | tempbh0 &= 0x20; | |
6321 | tempbl0 &= 0x20; | |
6322 | tempbh0 >>= 3; | |
6323 | tempbl0 >>= 3; | |
d7636e0b | 6324 | |
21df8fc8 PS |
6325 | if (tempbh & 0x20) { |
6326 | temp = (tempbl >> 4) & 0x02; | |
d7636e0b | 6327 | |
ec9e5d3e | 6328 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp); /* CR B4[1] */ |
d7636e0b | 6329 | |
21df8fc8 | 6330 | } |
ec9e5d3e | 6331 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~tempbh0, tempbl0); |
d7636e0b | 6332 | |
58839b01 | 6333 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
21df8fc8 PS |
6334 | tempbh &= 0x03; |
6335 | tempbl &= 0x03; | |
6336 | tempbh <<= 2; | |
6337 | tempbl <<= 2; /* GPIOC,GPIOD */ | |
dc50556b | 6338 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */ |
ec9e5d3e | 6339 | xgifb_reg_and_or(pVBInfo->P3d4, 0x48, ~tempbh, tempbl); |
d7636e0b | 6340 | } |
6341 | ||
6342 | /* --------------------------------------------------------------------- */ | |
80adad85 | 6343 | unsigned short XGI_GetLVDSOEMTableIndex(struct vb_device_info *pVBInfo) |
d7636e0b | 6344 | { |
21df8fc8 | 6345 | unsigned short index; |
d7636e0b | 6346 | |
58839b01 | 6347 | index = xgifb_reg_get(pVBInfo->P3d4, 0x36); |
21df8fc8 PS |
6348 | if (index < sizeof(XGI21_LCDCapList) |
6349 | / sizeof(struct XGI21_LVDSCapStruct)) | |
6350 | return index; | |
6351 | return 0; | |
d7636e0b | 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 | /* --------------------------------------------------------------------- */ | |
21df8fc8 PS |
6364 | void XGI_XG21SetPanelDelay(unsigned short tempbl, |
6365 | struct vb_device_info *pVBInfo) | |
d7636e0b | 6366 | { |
21df8fc8 | 6367 | unsigned short index; |
d7636e0b | 6368 | |
21df8fc8 PS |
6369 | index = XGI_GetLVDSOEMTableIndex(pVBInfo); |
6370 | if (tempbl == 1) | |
d80aaa01 | 6371 | mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S1); |
d7636e0b | 6372 | |
21df8fc8 | 6373 | if (tempbl == 2) |
d80aaa01 | 6374 | mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S2); |
d7636e0b | 6375 | |
21df8fc8 | 6376 | if (tempbl == 3) |
d80aaa01 | 6377 | mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S3); |
d7636e0b | 6378 | |
21df8fc8 | 6379 | if (tempbl == 4) |
d80aaa01 | 6380 | mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S4); |
d7636e0b | 6381 | } |
6382 | ||
82d6eb5b | 6383 | unsigned char XGI_XG21CheckLVDSMode(unsigned short ModeNo, |
21df8fc8 PS |
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; | |
d7636e0b | 6434 | } |
6435 | ||
80adad85 | 6436 | void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo) |
d7636e0b | 6437 | { |
21df8fc8 | 6438 | unsigned char temp; |
d7636e0b | 6439 | |
58839b01 | 6440 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); /* D[0] 1: 18bit */ |
21df8fc8 | 6441 | temp = (temp & 1) << 6; |
ec9e5d3e AK |
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 */ | |
d7636e0b | 6444 | |
6445 | } | |
6446 | ||
80adad85 | 6447 | void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo) |
d7636e0b | 6448 | { |
21df8fc8 | 6449 | unsigned char temp; |
d7636e0b | 6450 | |
58839b01 | 6451 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */ |
21df8fc8 | 6452 | temp = (temp & 3) << 6; |
ec9e5d3e AK |
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 */ | |
d7636e0b | 6455 | |
6456 | } | |
6457 | ||
063b9c4b | 6458 | static void XGI_SetXG21LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex, |
21df8fc8 PS |
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; | |
d8ad0a6d | 6472 | Miscdata = (unsigned char) inb(pVBInfo->P3cc); |
21df8fc8 | 6473 | |
efdf4ee7 | 6474 | outb((Miscdata & 0x3F) | temp, pVBInfo->P3c2); |
21df8fc8 PS |
6475 | |
6476 | temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability | |
6477 | & LCDPolarity); | |
ec9e5d3e AK |
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 */ | |
21df8fc8 PS |
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 | ||
58839b01 | 6538 | temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
8104e329 | 6539 | xgifb_reg_set(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */ |
21df8fc8 PS |
6540 | |
6541 | if (!(modeflag & Charx8Dot)) | |
b9bf6e4e | 6542 | xgifb_reg_or(pVBInfo->P3c4, 0x1, 0x1); |
21df8fc8 PS |
6543 | |
6544 | /* HT SR0B[1:0] CR00 */ | |
6545 | value = (LVDSHT >> 3) - 5; | |
ec9e5d3e | 6546 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8); |
8104e329 | 6547 | xgifb_reg_set(pVBInfo->P3d4, 0x0, (value & 0xFF)); |
21df8fc8 PS |
6548 | |
6549 | /* HBS SR0B[5:4] CR02 */ | |
6550 | value = (LVDSHBS >> 3) - 1; | |
ec9e5d3e | 6551 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4); |
8104e329 | 6552 | xgifb_reg_set(pVBInfo->P3d4, 0x2, (value & 0xFF)); |
21df8fc8 PS |
6553 | |
6554 | /* HBE SR0C[1:0] CR05[7] CR03[4:0] */ | |
6555 | value = (LVDSHBE >> 3) - 1; | |
ec9e5d3e AK |
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); | |
21df8fc8 PS |
6559 | |
6560 | /* HRS SR0B[7:6] CR04 */ | |
6561 | value = (LVDSHRS >> 3) + 2; | |
ec9e5d3e | 6562 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2); |
8104e329 | 6563 | xgifb_reg_set(pVBInfo->P3d4, 0x4, (value & 0xFF)); |
21df8fc8 PS |
6564 | |
6565 | /* Panel HRS SR2F[1:0] SR2E[7:0] */ | |
6566 | value--; | |
ec9e5d3e | 6567 | xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8); |
8104e329 | 6568 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, (value & 0xFF)); |
21df8fc8 PS |
6569 | |
6570 | /* HRE SR0C[2] CR05[4:0] */ | |
6571 | value = (LVDSHRE >> 3) + 2; | |
ec9e5d3e AK |
6572 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3); |
6573 | xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F); | |
21df8fc8 PS |
6574 | |
6575 | /* Panel HRE SR2F[7:2] */ | |
6576 | value--; | |
ec9e5d3e | 6577 | xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2); |
21df8fc8 PS |
6578 | |
6579 | /* VT SR0A[0] CR07[5][0] CR06 */ | |
6580 | value = LVDSVT - 2; | |
ec9e5d3e AK |
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); | |
8104e329 | 6584 | xgifb_reg_set(pVBInfo->P3d4, 0x06, (value & 0xFF)); |
21df8fc8 PS |
6585 | |
6586 | /* VBS SR0A[2] CR09[5] CR07[3] CR15 */ | |
6587 | value = LVDSVBS - 1; | |
ec9e5d3e AK |
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); | |
8104e329 | 6591 | xgifb_reg_set(pVBInfo->P3d4, 0x15, (value & 0xFF)); |
21df8fc8 PS |
6592 | |
6593 | /* VBE SR0A[4] CR16 */ | |
6594 | value = LVDSVBE - 1; | |
ec9e5d3e | 6595 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4); |
8104e329 | 6596 | xgifb_reg_set(pVBInfo->P3d4, 0x16, (value & 0xFF)); |
21df8fc8 PS |
6597 | |
6598 | /* VRS SR0A[3] CR7[7][2] CR10 */ | |
6599 | value = LVDSVRS - 1; | |
ec9e5d3e AK |
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); | |
8104e329 | 6603 | xgifb_reg_set(pVBInfo->P3d4, 0x10, (value & 0xFF)); |
21df8fc8 PS |
6604 | |
6605 | /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */ | |
ec9e5d3e | 6606 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0x03, (value & 0x600) >> 9); |
8104e329 | 6607 | xgifb_reg_set(pVBInfo->P3c4, 0x34, (value >> 1) & 0xFF); |
ec9e5d3e | 6608 | xgifb_reg_and_or(pVBInfo->P3d4, 0x33, ~0x01, value & 0x01); |
21df8fc8 PS |
6609 | |
6610 | /* VRE SR0A[5] CR11[3:0] */ | |
6611 | value = LVDSVRE - 1; | |
ec9e5d3e AK |
6612 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1); |
6613 | xgifb_reg_and_or(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F); | |
21df8fc8 PS |
6614 | |
6615 | /* Panel VRE SR3F[7:2] *//* SR3F[7] has to be 0, h/w bug */ | |
ec9e5d3e | 6616 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, (value << 2) & 0x7C); |
21df8fc8 PS |
6617 | |
6618 | for (temp = 0, value = 0; temp < 3; temp++) { | |
6619 | ||
ec9e5d3e | 6620 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, value); |
8104e329 | 6621 | xgifb_reg_set(pVBInfo->P3c4, |
21df8fc8 PS |
6622 | 0x2B, |
6623 | pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1); | |
8104e329 | 6624 | xgifb_reg_set(pVBInfo->P3c4, |
21df8fc8 PS |
6625 | 0x2C, |
6626 | pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2); | |
6627 | value += 0x10; | |
6628 | } | |
d7636e0b | 6629 | |
21df8fc8 | 6630 | if (!(modeflag & Charx8Dot)) { |
d8ad0a6d | 6631 | inb(pVBInfo->P3da); /* reset 3da */ |
efdf4ee7 AK |
6632 | outb(0x13, pVBInfo->P3c0); /* set index */ |
6633 | outb(0x00, pVBInfo->P3c0); /* set data, panning = 0, shift left 1 dot*/ | |
d7636e0b | 6634 | |
d8ad0a6d | 6635 | inb(pVBInfo->P3da); /* Enable Attribute */ |
efdf4ee7 | 6636 | outb(0x20, pVBInfo->P3c0); |
d7636e0b | 6637 | |
d8ad0a6d | 6638 | inb(pVBInfo->P3da); /* reset 3da */ |
21df8fc8 | 6639 | } |
d7636e0b | 6640 | |
6641 | } | |
6642 | ||
6643 | /* no shadow case */ | |
063b9c4b | 6644 | static void XGI_SetXG27LVDSPara(unsigned short ModeNo, unsigned short ModeIdIndex, |
21df8fc8 PS |
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; | |
d8ad0a6d | 6657 | Miscdata = (unsigned char) inb(pVBInfo->P3cc); |
21df8fc8 | 6658 | |
efdf4ee7 | 6659 | outb((Miscdata & 0x3F) | temp, pVBInfo->P3c2); |
21df8fc8 PS |
6660 | |
6661 | temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability | |
6662 | & LCDPolarity); | |
ec9e5d3e AK |
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 */ | |
21df8fc8 PS |
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; | |
d7636e0b | 6682 | |
21df8fc8 PS |
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; | |
d7636e0b | 6703 | |
21df8fc8 PS |
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 | ||
58839b01 | 6723 | temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
8104e329 | 6724 | xgifb_reg_set(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */ |
21df8fc8 PS |
6725 | |
6726 | if (!(modeflag & Charx8Dot)) | |
b9bf6e4e | 6727 | xgifb_reg_or(pVBInfo->P3c4, 0x1, 0x1); |
21df8fc8 PS |
6728 | |
6729 | /* HT SR0B[1:0] CR00 */ | |
6730 | value = (LVDSHT >> 3) - 5; | |
ec9e5d3e | 6731 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8); |
8104e329 | 6732 | xgifb_reg_set(pVBInfo->P3d4, 0x0, (value & 0xFF)); |
21df8fc8 PS |
6733 | |
6734 | /* HBS SR0B[5:4] CR02 */ | |
6735 | value = (LVDSHBS >> 3) - 1; | |
ec9e5d3e | 6736 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4); |
8104e329 | 6737 | xgifb_reg_set(pVBInfo->P3d4, 0x2, (value & 0xFF)); |
21df8fc8 PS |
6738 | |
6739 | /* HBE SR0C[1:0] CR05[7] CR03[4:0] */ | |
6740 | value = (LVDSHBE >> 3) - 1; | |
ec9e5d3e AK |
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); | |
21df8fc8 PS |
6744 | |
6745 | /* HRS SR0B[7:6] CR04 */ | |
6746 | value = (LVDSHRS >> 3) + 2; | |
ec9e5d3e | 6747 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2); |
8104e329 | 6748 | xgifb_reg_set(pVBInfo->P3d4, 0x4, (value & 0xFF)); |
21df8fc8 PS |
6749 | |
6750 | /* Panel HRS SR2F[1:0] SR2E[7:0] */ | |
6751 | value--; | |
ec9e5d3e | 6752 | xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8); |
8104e329 | 6753 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, (value & 0xFF)); |
21df8fc8 PS |
6754 | |
6755 | /* HRE SR0C[2] CR05[4:0] */ | |
6756 | value = (LVDSHRE >> 3) + 2; | |
ec9e5d3e AK |
6757 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3); |
6758 | xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F); | |
21df8fc8 PS |
6759 | |
6760 | /* Panel HRE SR2F[7:2] */ | |
6761 | value--; | |
ec9e5d3e | 6762 | xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2); |
21df8fc8 PS |
6763 | |
6764 | /* VT SR0A[0] CR07[5][0] CR06 */ | |
6765 | value = LVDSVT - 2; | |
ec9e5d3e AK |
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); | |
8104e329 | 6769 | xgifb_reg_set(pVBInfo->P3d4, 0x06, (value & 0xFF)); |
21df8fc8 PS |
6770 | |
6771 | /* VBS SR0A[2] CR09[5] CR07[3] CR15 */ | |
6772 | value = LVDSVBS - 1; | |
ec9e5d3e AK |
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); | |
8104e329 | 6776 | xgifb_reg_set(pVBInfo->P3d4, 0x15, (value & 0xFF)); |
21df8fc8 PS |
6777 | |
6778 | /* VBE SR0A[4] CR16 */ | |
6779 | value = LVDSVBE - 1; | |
ec9e5d3e | 6780 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4); |
8104e329 | 6781 | xgifb_reg_set(pVBInfo->P3d4, 0x16, (value & 0xFF)); |
21df8fc8 PS |
6782 | |
6783 | /* VRS SR0A[3] CR7[7][2] CR10 */ | |
6784 | value = LVDSVRS - 1; | |
ec9e5d3e AK |
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); | |
8104e329 | 6788 | xgifb_reg_set(pVBInfo->P3d4, 0x10, (value & 0xFF)); |
21df8fc8 PS |
6789 | |
6790 | /* Panel VRS SR35[2:0] SR34[7:0] */ | |
ec9e5d3e | 6791 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, (value & 0x700) >> 8); |
8104e329 | 6792 | xgifb_reg_set(pVBInfo->P3c4, 0x34, value & 0xFF); |
21df8fc8 PS |
6793 | |
6794 | /* VRE SR0A[5] CR11[3:0] */ | |
6795 | value = LVDSVRE - 1; | |
ec9e5d3e AK |
6796 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1); |
6797 | xgifb_reg_and_or(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F); | |
21df8fc8 PS |
6798 | |
6799 | /* Panel VRE SR3F[7:2] */ | |
ec9e5d3e | 6800 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, (value << 2) & 0xFC); |
21df8fc8 PS |
6801 | |
6802 | for (temp = 0, value = 0; temp < 3; temp++) { | |
6803 | ||
ec9e5d3e | 6804 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, value); |
8104e329 | 6805 | xgifb_reg_set(pVBInfo->P3c4, |
21df8fc8 PS |
6806 | 0x2B, |
6807 | pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1); | |
8104e329 | 6808 | xgifb_reg_set(pVBInfo->P3c4, |
21df8fc8 PS |
6809 | 0x2C, |
6810 | pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2); | |
6811 | value += 0x10; | |
6812 | } | |
d7636e0b | 6813 | |
21df8fc8 | 6814 | if (!(modeflag & Charx8Dot)) { |
d8ad0a6d | 6815 | inb(pVBInfo->P3da); /* reset 3da */ |
efdf4ee7 AK |
6816 | outb(0x13, pVBInfo->P3c0); /* set index */ |
6817 | outb(0x00, pVBInfo->P3c0); /* set data, panning = 0, shift left 1 dot*/ | |
d7636e0b | 6818 | |
d8ad0a6d | 6819 | inb(pVBInfo->P3da); /* Enable Attribute */ |
efdf4ee7 | 6820 | outb(0x20, pVBInfo->P3c0); |
d7636e0b | 6821 | |
d8ad0a6d | 6822 | inb(pVBInfo->P3da); /* reset 3da */ |
21df8fc8 | 6823 | } |
d7636e0b | 6824 | |
6825 | } | |
6826 | ||
6827 | /* --------------------------------------------------------------------- */ | |
6828 | /* Function : XGI_IsLCDON */ | |
6829 | /* Input : */ | |
dda08c59 BP |
6830 | /* Output : 0 : Skip PSC Control */ |
6831 | /* 1: Disable PSC */ | |
d7636e0b | 6832 | /* Description : */ |
6833 | /* --------------------------------------------------------------------- */ | |
063b9c4b | 6834 | static unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo) |
d7636e0b | 6835 | { |
21df8fc8 | 6836 | unsigned short tempax; |
d7636e0b | 6837 | |
21df8fc8 PS |
6838 | tempax = pVBInfo->VBInfo; |
6839 | if (tempax & SetCRT2ToDualEdge) | |
6840 | return 0; | |
6841 | else if (tempax & (DisableCRT2Display | SwitchToCRT2 | SetSimuScanMode)) | |
6842 | return 1; | |
d7636e0b | 6843 | |
21df8fc8 | 6844 | return 0; |
d7636e0b | 6845 | } |
6846 | ||
d7636e0b | 6847 | /* --------------------------------------------------------------------- */ |
6848 | /* Function : XGI_DisableChISLCD */ | |
6849 | /* Input : */ | |
dda08c59 | 6850 | /* Output : 0 -> Not LCD Mode */ |
d7636e0b | 6851 | /* Description : */ |
6852 | /* --------------------------------------------------------------------- */ | |
063b9c4b | 6853 | static unsigned char XGI_DisableChISLCD(struct vb_device_info *pVBInfo) |
d7636e0b | 6854 | { |
21df8fc8 | 6855 | unsigned short tempbx, tempah; |
d7636e0b | 6856 | |
21df8fc8 | 6857 | tempbx = pVBInfo->SetFlag & (DisableChA | DisableChB); |
58839b01 | 6858 | tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E)); |
d7636e0b | 6859 | |
21df8fc8 PS |
6860 | if (tempbx & (EnableChA | DisableChA)) { |
6861 | if (!(tempah & 0x08)) /* Chk LCDA Mode */ | |
6862 | return 0; | |
6863 | } | |
d7636e0b | 6864 | |
21df8fc8 PS |
6865 | if (!(tempbx & (EnableChB | DisableChB))) |
6866 | return 0; | |
d7636e0b | 6867 | |
21df8fc8 PS |
6868 | if (tempah & 0x01) /* Chk LCDB Mode */ |
6869 | return 1; | |
d7636e0b | 6870 | |
21df8fc8 | 6871 | return 0; |
d7636e0b | 6872 | } |
6873 | ||
d7636e0b | 6874 | /* --------------------------------------------------------------------- */ |
6875 | /* Function : XGI_EnableChISLCD */ | |
6876 | /* Input : */ | |
6877 | /* Output : 0 -> Not LCD mode */ | |
6878 | /* Description : */ | |
6879 | /* --------------------------------------------------------------------- */ | |
063b9c4b | 6880 | static unsigned char XGI_EnableChISLCD(struct vb_device_info *pVBInfo) |
d7636e0b | 6881 | { |
21df8fc8 | 6882 | unsigned short tempbx, tempah; |
d7636e0b | 6883 | |
21df8fc8 | 6884 | tempbx = pVBInfo->SetFlag & (EnableChA | EnableChB); |
58839b01 | 6885 | tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E)); |
d7636e0b | 6886 | |
21df8fc8 PS |
6887 | if (tempbx & (EnableChA | DisableChA)) { |
6888 | if (!(tempah & 0x08)) /* Chk LCDA Mode */ | |
6889 | return 0; | |
6890 | } | |
d7636e0b | 6891 | |
21df8fc8 | 6892 | if (!(tempbx & (EnableChB | DisableChB))) |
dda08c59 | 6893 | return 0; |
d7636e0b | 6894 | |
21df8fc8 PS |
6895 | if (tempah & 0x01) /* Chk LCDB Mode */ |
6896 | return 1; | |
d7636e0b | 6897 | |
cc1e2398 AK |
6898 | return 0; |
6899 | } | |
6900 | ||
6901 | void XGI_DisableBridge(struct xgi_hw_device_info *HwDeviceExtension, | |
6902 | struct vb_device_info *pVBInfo) | |
6903 | { | |
fd0ad470 | 6904 | unsigned short tempah = 0; |
cc1e2398 AK |
6905 | |
6906 | if (pVBInfo->SetFlag == Win9xDOSMode) | |
6907 | return; | |
6908 | ||
cc1e2398 AK |
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 | ||
dc50556b | 6944 | xgifb_reg_and(pVBInfo->Part4Port, 0x1F, tempah); /* disable part4_1f */ |
cc1e2398 AK |
6945 | |
6946 | if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) { | |
6947 | if (((pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))) | |
6948 | || (XGI_DisableChISLCD(pVBInfo)) | |
6949 | || (XGI_IsLCDON(pVBInfo))) | |
b9bf6e4e | 6950 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x80); /* LVDS Driver power down */ |
cc1e2398 AK |
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)) | |
dc50556b | 6964 | xgifb_reg_and(pVBInfo->Part1Port, 0x1e, 0xdf); /* Power down */ |
cc1e2398 AK |
6965 | } |
6966 | ||
dc50556b | 6967 | xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xdf); /* disable TV as primary VGA swap */ |
cc1e2398 AK |
6968 | |
6969 | if ((pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToDualEdge))) | |
dc50556b | 6970 | xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xdf); |
cc1e2398 AK |
6971 | |
6972 | if ((pVBInfo->SetFlag & DisableChB) || (pVBInfo->VBInfo | |
6973 | & (DisableCRT2Display | SetSimuScanMode)) | |
6974 | || ((!(pVBInfo->VBInfo & SetCRT2ToLCDA)) | |
6975 | && (pVBInfo->VBInfo | |
6976 | & (SetCRT2ToRAMDAC | |
6977 | | SetCRT2ToLCD | |
6978 | | SetCRT2ToTV)))) | |
b9bf6e4e | 6979 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80); /* BScreenOff=1 */ |
cc1e2398 AK |
6980 | |
6981 | if ((pVBInfo->SetFlag & DisableChB) || (pVBInfo->VBInfo | |
6982 | & (DisableCRT2Display | SetSimuScanMode)) | |
6983 | || (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) | |
6984 | || (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | |
6985 | | SetCRT2ToLCD | SetCRT2ToTV))) { | |
58839b01 | 6986 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00); /* save Part1 index 0 */ |
b9bf6e4e | 6987 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x10); /* BTDAC = 1, avoid VB reset */ |
dc50556b | 6988 | xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF); /* disable CRT2 */ |
8104e329 | 6989 | xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah); /* restore Part1 index 0 */ |
cc1e2398 AK |
6990 | } |
6991 | } else { /* {301} */ | |
6992 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) { | |
b9bf6e4e | 6993 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80); /* BScreenOff=1 */ |
dc50556b AK |
6994 | xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF); /* Disable CRT2 */ |
6995 | xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xDF); /* Disable TV asPrimary VGA swap */ | |
cc1e2398 AK |
6996 | } |
6997 | ||
6998 | if (pVBInfo->VBInfo & (DisableCRT2Display | SetCRT2ToLCDA | |
6999 | | SetSimuScanMode)) | |
7000 | XGI_DisplayOff(HwDeviceExtension, pVBInfo); | |
7001 | } | |
cc1e2398 AK |
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 | /* --------------------------------------------------------------------- */ | |
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 | /* --------------------------------------------------------------------- */ | |
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)++; | |
d7636e0b | 7091 | } |
7092 | ||
cc1e2398 | 7093 | static void XGI_SetDelayComp(struct vb_device_info *pVBInfo) |
d7636e0b | 7094 | { |
cc1e2398 | 7095 | unsigned short index; |
d7636e0b | 7096 | |
cc1e2398 | 7097 | unsigned char tempah, tempbl, tempbh; |
d7636e0b | 7098 | |
cc1e2398 AK |
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; | |
d7636e0b | 7105 | |
cc1e2398 AK |
7106 | index = XGI_GetTVPtrIndex(pVBInfo); /* Get TV Delay */ |
7107 | tempbl = pVBInfo->XGI_TVDelayList[index]; | |
d7636e0b | 7108 | |
cc1e2398 AK |
7109 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B |
7110 | | VB_XGI301LV | VB_XGI302LV | |
7111 | | VB_XGI301C)) | |
7112 | tempbl = pVBInfo->XGI_TVDelayList2[index]; | |
d7636e0b | 7113 | |
cc1e2398 AK |
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; | |
d7636e0b | 7125 | |
cc1e2398 AK |
7126 | if (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) |
7127 | tempbl = tempbh; | |
7128 | } | |
d7636e0b | 7129 | |
cc1e2398 AK |
7130 | tempbl &= 0x0F; |
7131 | tempbh &= 0xF0; | |
58839b01 | 7132 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x2D); |
d7636e0b | 7133 | |
cc1e2398 AK |
7134 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD |
7135 | | SetCRT2ToTV)) { /* Channel B */ | |
7136 | tempah &= 0xF0; | |
7137 | tempah |= tempbl; | |
7138 | } | |
d7636e0b | 7139 | |
cc1e2398 AK |
7140 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { /* Channel A */ |
7141 | tempah &= 0x0F; | |
7142 | tempah |= tempbh; | |
7143 | } | |
8104e329 | 7144 | xgifb_reg_set(pVBInfo->Part1Port, 0x2D, tempah); |
cc1e2398 AK |
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; | |
ec9e5d3e | 7155 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2D, 0x0f, |
cc1e2398 | 7156 | tempah); |
21df8fc8 | 7157 | } |
cc1e2398 AK |
7158 | } |
7159 | } | |
d7636e0b | 7160 | |
cc1e2398 AK |
7161 | static void XGI_SetLCDCap_A(unsigned short tempcx, struct vb_device_info *pVBInfo) |
7162 | { | |
7163 | unsigned short temp; | |
d7636e0b | 7164 | |
58839b01 | 7165 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
cc1e2398 AK |
7166 | |
7167 | if (temp & LCDRGB18Bit) { | |
ec9e5d3e | 7168 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F, |
cc1e2398 | 7169 | (unsigned short) (0x20 | (tempcx & 0x00C0))); /* Enable Dither */ |
ec9e5d3e | 7170 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80); |
cc1e2398 | 7171 | } else { |
ec9e5d3e | 7172 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F, |
cc1e2398 | 7173 | (unsigned short) (0x30 | (tempcx & 0x00C0))); |
ec9e5d3e | 7174 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00); |
21df8fc8 | 7175 | } |
d7636e0b | 7176 | |
cc1e2398 AK |
7177 | /* |
7178 | if (tempcx & EnableLCD24bpp) { // 24bits | |
ec9e5d3e AK |
7179 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F, (unsigned short)(0x30 | (tempcx&0x00C0))); |
7180 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00); | |
cc1e2398 | 7181 | } else { |
ec9e5d3e AK |
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); | |
21df8fc8 | 7184 | } |
cc1e2398 AK |
7185 | */ |
7186 | } | |
d7636e0b | 7187 | |
cc1e2398 AK |
7188 | /* --------------------------------------------------------------------- */ |
7189 | /* Function : XGI_SetLCDCap_B */ | |
7190 | /* Input : cx -> LCD Capability */ | |
7191 | /* Output : */ | |
7192 | /* Description : */ | |
7193 | /* --------------------------------------------------------------------- */ | |
7194 | static void XGI_SetLCDCap_B(unsigned short tempcx, struct vb_device_info *pVBInfo) | |
7195 | { | |
7196 | if (tempcx & EnableLCD24bpp) /* 24bits */ | |
ec9e5d3e | 7197 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0, |
cc1e2398 AK |
7198 | (unsigned short) (((tempcx & 0x00ff) >> 6) |
7199 | | 0x0c)); | |
7200 | else | |
ec9e5d3e | 7201 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0, |
cc1e2398 AK |
7202 | (unsigned short) (((tempcx & 0x00ff) >> 6) |
7203 | | 0x18)); /* Enable Dither */ | |
d7636e0b | 7204 | } |
7205 | ||
cc1e2398 | 7206 | static void SetSpectrum(struct vb_device_info *pVBInfo) |
d7636e0b | 7207 | { |
cc1e2398 | 7208 | unsigned short index; |
d7636e0b | 7209 | |
cc1e2398 | 7210 | index = XGI_GetLCDCapPtr(pVBInfo); |
d7636e0b | 7211 | |
dc50556b | 7212 | xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x8F); /* disable down spectrum D[4] */ |
cc1e2398 | 7213 | XGI_LongWait(pVBInfo); |
b9bf6e4e | 7214 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x20); /* reset spectrum */ |
cc1e2398 AK |
7215 | XGI_LongWait(pVBInfo); |
7216 | ||
8104e329 | 7217 | xgifb_reg_set(pVBInfo->Part4Port, 0x31, |
cc1e2398 | 7218 | pVBInfo->LCDCapList[index].Spectrum_31); |
8104e329 | 7219 | xgifb_reg_set(pVBInfo->Part4Port, 0x32, |
cc1e2398 | 7220 | pVBInfo->LCDCapList[index].Spectrum_32); |
8104e329 | 7221 | xgifb_reg_set(pVBInfo->Part4Port, 0x33, |
cc1e2398 | 7222 | pVBInfo->LCDCapList[index].Spectrum_33); |
8104e329 | 7223 | xgifb_reg_set(pVBInfo->Part4Port, 0x34, |
cc1e2398 AK |
7224 | pVBInfo->LCDCapList[index].Spectrum_34); |
7225 | XGI_LongWait(pVBInfo); | |
b9bf6e4e | 7226 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x40); /* enable spectrum */ |
d7636e0b | 7227 | } |
7228 | ||
cc1e2398 | 7229 | static void XGI_SetLCDCap(struct vb_device_info *pVBInfo) |
21df8fc8 | 7230 | { |
cc1e2398 | 7231 | unsigned short tempcx; |
21df8fc8 | 7232 | |
cc1e2398 | 7233 | tempcx = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(pVBInfo)].LCD_Capability; |
21df8fc8 PS |
7234 | |
7235 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | |
7236 | | VB_XGI302LV | VB_XGI301C)) { | |
cc1e2398 AK |
7237 | if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) { /* 301LV/302LV only */ |
7238 | /* Set 301LV Capability */ | |
8104e329 | 7239 | xgifb_reg_set(pVBInfo->Part4Port, 0x24, |
cc1e2398 | 7240 | (unsigned char) (tempcx & 0x1F)); |
21df8fc8 | 7241 | } |
cc1e2398 | 7242 | /* VB Driving */ |
ec9e5d3e | 7243 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D, |
cc1e2398 AK |
7244 | ~((EnableVBCLKDRVLOW | EnablePLLSPLOW) >> 8), |
7245 | (unsigned short) ((tempcx & (EnableVBCLKDRVLOW | |
7246 | | EnablePLLSPLOW)) >> 8)); | |
7247 | } | |
21df8fc8 | 7248 | |
cc1e2398 AK |
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); | |
21df8fc8 | 7255 | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 7265 | |
cc1e2398 AK |
7266 | /* --------------------------------------------------------------------- */ |
7267 | /* Function : XGI_SetAntiFlicker */ | |
7268 | /* Input : */ | |
7269 | /* Output : */ | |
7270 | /* Description : Set TV Customized Param. */ | |
7271 | /* --------------------------------------------------------------------- */ | |
7272 | static void XGI_SetAntiFlicker(unsigned short ModeNo, unsigned short ModeIdIndex, | |
7273 | struct vb_device_info *pVBInfo) | |
7274 | { | |
7275 | unsigned short tempbx, index; | |
21df8fc8 | 7276 | |
cc1e2398 | 7277 | unsigned char tempah; |
21df8fc8 | 7278 | |
cc1e2398 AK |
7279 | if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)) |
7280 | return; | |
21df8fc8 | 7281 | |
cc1e2398 AK |
7282 | tempbx = XGI_GetTVPtrIndex(pVBInfo); |
7283 | tempbx &= 0xFE; | |
21df8fc8 | 7284 | |
cc1e2398 AK |
7285 | if (ModeNo <= 0x13) |
7286 | index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVFlickerIndex; | |
7287 | else | |
7288 | index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVFlickerIndex; | |
21df8fc8 | 7289 | |
cc1e2398 AK |
7290 | tempbx += index; |
7291 | tempah = TVAntiFlickList[tempbx]; | |
7292 | tempah = tempah << 4; | |
21df8fc8 | 7293 | |
ec9e5d3e | 7294 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0x8F, tempah); |
cc1e2398 | 7295 | } |
21df8fc8 | 7296 | |
cc1e2398 AK |
7297 | static void XGI_SetEdgeEnhance(unsigned short ModeNo, unsigned short ModeIdIndex, |
7298 | struct vb_device_info *pVBInfo) | |
7299 | { | |
7300 | unsigned short tempbx, index; | |
21df8fc8 | 7301 | |
cc1e2398 | 7302 | unsigned char tempah; |
21df8fc8 | 7303 | |
cc1e2398 AK |
7304 | tempbx = XGI_GetTVPtrIndex(pVBInfo); |
7305 | tempbx &= 0xFE; | |
21df8fc8 | 7306 | |
cc1e2398 AK |
7307 | if (ModeNo <= 0x13) |
7308 | index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVEdgeIndex; | |
7309 | else | |
7310 | index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVEdgeIndex; | |
21df8fc8 | 7311 | |
cc1e2398 AK |
7312 | tempbx += index; |
7313 | tempah = TVEdgeList[tempbx]; | |
7314 | tempah = tempah << 5; | |
21df8fc8 | 7315 | |
ec9e5d3e | 7316 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, tempah); |
d7636e0b | 7317 | } |
7318 | ||
cc1e2398 | 7319 | static void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo) |
21df8fc8 | 7320 | { |
cc1e2398 | 7321 | unsigned short tempbx; |
21df8fc8 | 7322 | |
cc1e2398 | 7323 | unsigned char tempcl, tempch; |
21df8fc8 | 7324 | |
cc1e2398 | 7325 | unsigned long tempData; |
d7636e0b | 7326 | |
cc1e2398 AK |
7327 | XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */ |
7328 | tempData = TVPhaseList[tempbx]; | |
21df8fc8 | 7329 | |
8104e329 | 7330 | xgifb_reg_set(pVBInfo->Part2Port, 0x31, (unsigned short) (tempData |
cc1e2398 | 7331 | & 0x000000FF)); |
8104e329 | 7332 | xgifb_reg_set(pVBInfo->Part2Port, 0x32, (unsigned short) ((tempData |
cc1e2398 | 7333 | & 0x0000FF00) >> 8)); |
8104e329 | 7334 | xgifb_reg_set(pVBInfo->Part2Port, 0x33, (unsigned short) ((tempData |
cc1e2398 | 7335 | & 0x00FF0000) >> 16)); |
8104e329 | 7336 | xgifb_reg_set(pVBInfo->Part2Port, 0x34, (unsigned short) ((tempData |
cc1e2398 AK |
7337 | & 0xFF000000) >> 24)); |
7338 | } | |
21df8fc8 | 7339 | |
cc1e2398 AK |
7340 | static void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex, |
7341 | struct vb_device_info *pVBInfo) | |
7342 | { | |
7343 | unsigned short tempbx, index; | |
21df8fc8 | 7344 | |
cc1e2398 | 7345 | unsigned char tempcl, tempch, tempal, *filterPtr; |
21df8fc8 | 7346 | |
cc1e2398 | 7347 | XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */ |
21df8fc8 | 7348 | |
cc1e2398 AK |
7349 | switch (tempbx) { |
7350 | case 0x00: | |
7351 | case 0x04: | |
7352 | filterPtr = NTSCYFilter1; | |
7353 | break; | |
21df8fc8 | 7354 | |
cc1e2398 AK |
7355 | case 0x01: |
7356 | filterPtr = PALYFilter1; | |
7357 | break; | |
21df8fc8 | 7358 | |
cc1e2398 AK |
7359 | case 0x02: |
7360 | case 0x05: | |
7361 | case 0x0D: | |
7362 | filterPtr = PALMYFilter1; | |
7363 | break; | |
7364 | ||
7365 | case 0x03: | |
7366 | filterPtr = PALNYFilter1; | |
7367 | break; | |
21df8fc8 | 7368 | |
cc1e2398 AK |
7369 | case 0x08: |
7370 | case 0x0C: | |
7371 | filterPtr = NTSCYFilter2; | |
7372 | break; | |
21df8fc8 | 7373 | |
cc1e2398 AK |
7374 | case 0x0A: |
7375 | filterPtr = PALMYFilter2; | |
7376 | break; | |
21df8fc8 | 7377 | |
cc1e2398 AK |
7378 | case 0x0B: |
7379 | filterPtr = PALNYFilter2; | |
7380 | break; | |
21df8fc8 | 7381 | |
cc1e2398 AK |
7382 | case 0x09: |
7383 | filterPtr = PALYFilter2; | |
7384 | break; | |
21df8fc8 | 7385 | |
cc1e2398 AK |
7386 | default: |
7387 | return; | |
21df8fc8 | 7388 | } |
d7636e0b | 7389 | |
cc1e2398 AK |
7390 | if (ModeNo <= 0x13) |
7391 | tempal = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVYFilterIndex; | |
7392 | else | |
7393 | tempal | |
7394 | = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVYFilterIndex; | |
d7636e0b | 7395 | |
cc1e2398 AK |
7396 | if (tempcl == 0) |
7397 | index = tempal * 4; | |
7398 | else | |
7399 | index = tempal * 7; | |
d7636e0b | 7400 | |
cc1e2398 | 7401 | if ((tempcl == 0) && (tempch == 1)) { |
8104e329 AK |
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++]); | |
cc1e2398 | 7406 | } else { |
8104e329 AK |
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++]); | |
cc1e2398 | 7411 | } |
d7636e0b | 7412 | |
cc1e2398 AK |
7413 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
7414 | | VB_XGI302LV | VB_XGI301C)) { | |
8104e329 AK |
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++]); | |
cc1e2398 | 7418 | } |
d7636e0b | 7419 | } |
7420 | ||
d7636e0b | 7421 | /* --------------------------------------------------------------------- */ |
7422 | /* Function : XGI_OEM310Setting */ | |
7423 | /* Input : */ | |
7424 | /* Output : */ | |
7425 | /* Description : Customized Param. for 301 */ | |
7426 | /* --------------------------------------------------------------------- */ | |
063b9c4b | 7427 | static void XGI_OEM310Setting(unsigned short ModeNo, unsigned short ModeIdIndex, |
21df8fc8 | 7428 | struct vb_device_info *pVBInfo) |
d7636e0b | 7429 | { |
21df8fc8 PS |
7430 | if (pVBInfo->SetFlag & Win9xDOSMode) |
7431 | return; | |
d7636e0b | 7432 | |
21df8fc8 PS |
7433 | /* GetPart1IO(); */ |
7434 | XGI_SetDelayComp(pVBInfo); | |
d7636e0b | 7435 | |
21df8fc8 PS |
7436 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) |
7437 | XGI_SetLCDCap(pVBInfo); | |
d7636e0b | 7438 | |
21df8fc8 PS |
7439 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
7440 | /* GetPart2IO() */ | |
7441 | XGI_SetPhaseIncr(pVBInfo); | |
7442 | XGI_SetYFilter(ModeNo, ModeIdIndex, pVBInfo); | |
7443 | XGI_SetAntiFlicker(ModeNo, ModeIdIndex, pVBInfo); | |
d7636e0b | 7444 | |
21df8fc8 PS |
7445 | if (pVBInfo->VBType & VB_XGI301) |
7446 | XGI_SetEdgeEnhance(ModeNo, ModeIdIndex, pVBInfo); | |
7447 | } | |
d7636e0b | 7448 | } |
7449 | ||
cc1e2398 AK |
7450 | /* --------------------------------------------------------------------- */ |
7451 | /* Function : XGI_SetCRT2ModeRegs */ | |
7452 | /* Input : */ | |
7453 | /* Output : */ | |
7454 | /* Description : Origin code for crt2group */ | |
7455 | /* --------------------------------------------------------------------- */ | |
7456 | void XGI_SetCRT2ModeRegs(unsigned short ModeNo, | |
7457 | struct xgi_hw_device_info *HwDeviceExtension, | |
7458 | struct vb_device_info *pVBInfo) | |
d7636e0b | 7459 | { |
cc1e2398 AK |
7460 | unsigned short tempbl; |
7461 | short tempcl; | |
21df8fc8 | 7462 | |
cc1e2398 | 7463 | unsigned char tempah; |
21df8fc8 | 7464 | |
8104e329 | 7465 | /* xgifb_reg_set(pVBInfo->Part1Port, 0x03, 0x00); // fix write part1 index 0 BTDRAM bit Bug */ |
cc1e2398 AK |
7466 | tempah = 0; |
7467 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { | |
58839b01 | 7468 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00); |
cc1e2398 AK |
7469 | tempah &= ~0x10; /* BTRAMDAC */ |
7470 | tempah |= 0x40; /* BTRAM */ | |
21df8fc8 | 7471 | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 7489 | |
cc1e2398 AK |
7490 | /* 0210 shampoo |
7491 | if (pVBInfo->VBInfo & DisableCRT2Display) { | |
7492 | tempah = 0; | |
7493 | } | |
21df8fc8 | 7494 | |
8104e329 | 7495 | xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah); |
cc1e2398 AK |
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; | |
21df8fc8 | 7505 | } |
cc1e2398 AK |
7506 | } else { |
7507 | tempah = 0x040; | |
7508 | } | |
21df8fc8 | 7509 | |
cc1e2398 AK |
7510 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
7511 | tempah = (tempah ^ 0x050); | |
7512 | } | |
7513 | } | |
7514 | */ | |
21df8fc8 | 7515 | |
8104e329 | 7516 | xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah); |
cc1e2398 AK |
7517 | tempah = 0x08; |
7518 | tempbl = 0xf0; | |
7519 | ||
7520 | if (pVBInfo->VBInfo & DisableCRT2Display) { | |
ec9e5d3e | 7521 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl, tempah); |
cc1e2398 AK |
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; | |
ec9e5d3e | 7532 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, |
cc1e2398 AK |
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 | } | |
21df8fc8 | 7554 | |
cc1e2398 AK |
7555 | if (!(pVBInfo->VBInfo |
7556 | & SetCRT2ToDualEdge)) | |
7557 | tempah |= 0x08; | |
ec9e5d3e | 7558 | xgifb_reg_and_or(pVBInfo->Part1Port, |
cc1e2398 AK |
7559 | 0x2e, tempbl, tempah); |
7560 | } else { | |
ec9e5d3e | 7561 | xgifb_reg_and_or(pVBInfo->Part1Port, |
cc1e2398 AK |
7562 | 0x2e, tempbl, tempah); |
7563 | } | |
21df8fc8 | 7564 | } |
cc1e2398 | 7565 | } else { |
ec9e5d3e | 7566 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl, |
21df8fc8 PS |
7567 | tempah); |
7568 | } | |
7569 | } | |
d7636e0b | 7570 | |
cc1e2398 AK |
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; | |
21df8fc8 | 7579 | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 7589 | |
ec9e5d3e | 7590 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D, ~0x0BF, tempah); |
cc1e2398 AK |
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 | /* } */ | |
21df8fc8 | 7601 | } |
cc1e2398 AK |
7602 | |
7603 | if ((pVBInfo->LCDResInfo == Panel1280x1024) | |
7604 | || (pVBInfo->LCDResInfo == Panel1280x1024x75)) | |
7605 | tempah |= 0x80; | |
7606 | ||
7607 | if (pVBInfo->LCDResInfo == Panel1280x960) | |
7608 | tempah |= 0x80; | |
7609 | ||
8104e329 | 7610 | xgifb_reg_set(pVBInfo->Part4Port, 0x0C, tempah); |
d7636e0b | 7611 | } |
d7636e0b | 7612 | |
21df8fc8 PS |
7613 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
7614 | | VB_XGI302LV | VB_XGI301C)) { | |
cc1e2398 AK |
7615 | tempah = 0; |
7616 | tempbl = 0xfb; | |
21df8fc8 | 7617 | |
cc1e2398 AK |
7618 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { |
7619 | tempbl = 0xff; | |
7620 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) | |
7621 | tempah |= 0x04; /* shampoo 0129 */ | |
21df8fc8 | 7622 | } |
d7636e0b | 7623 | |
ec9e5d3e | 7624 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x13, tempbl, tempah); |
cc1e2398 AK |
7625 | tempah = 0x00; |
7626 | tempbl = 0xcf; | |
7627 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { | |
7628 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) | |
7629 | tempah |= 0x30; | |
7630 | } | |
d7636e0b | 7631 | |
ec9e5d3e | 7632 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2c, tempbl, tempah); |
cc1e2398 AK |
7633 | tempah = 0; |
7634 | tempbl = 0x3f; | |
d7636e0b | 7635 | |
cc1e2398 AK |
7636 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
7637 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) | |
7638 | tempah |= 0xc0; | |
7639 | } | |
ec9e5d3e | 7640 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, tempbl, tempah); |
21df8fc8 | 7641 | } |
d7636e0b | 7642 | |
cc1e2398 AK |
7643 | tempah = 0; |
7644 | tempbl = 0x7f; | |
7645 | if (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) { | |
7646 | tempbl = 0xff; | |
7647 | if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge)) | |
7648 | tempah |= 0x80; | |
21df8fc8 | 7649 | } |
d7636e0b | 7650 | |
ec9e5d3e | 7651 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x23, tempbl, tempah); |
d7636e0b | 7652 | |
cc1e2398 AK |
7653 | if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) { |
7654 | if (pVBInfo->LCDInfo & SetLCDDualLink) { | |
b9bf6e4e AK |
7655 | xgifb_reg_or(pVBInfo->Part4Port, 0x27, 0x20); |
7656 | xgifb_reg_or(pVBInfo->Part4Port, 0x34, 0x10); | |
cc1e2398 AK |
7657 | } |
7658 | } | |
d7636e0b | 7659 | } |
7660 | ||
cc1e2398 | 7661 | static void XGI_CloseCRTC(struct xgi_hw_device_info *HwDeviceExtension, |
21df8fc8 | 7662 | struct vb_device_info *pVBInfo) |
d7636e0b | 7663 | { |
cc1e2398 | 7664 | unsigned short tempbx; |
d7636e0b | 7665 | |
cc1e2398 | 7666 | tempbx = 0; |
d7636e0b | 7667 | |
cc1e2398 AK |
7668 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) |
7669 | tempbx = 0x08A0; | |
d7636e0b | 7670 | |
d7636e0b | 7671 | } |
7672 | ||
cc1e2398 | 7673 | void XGI_OpenCRTC(struct xgi_hw_device_info *HwDeviceExtension, |
21df8fc8 | 7674 | struct vb_device_info *pVBInfo) |
d7636e0b | 7675 | { |
cc1e2398 AK |
7676 | unsigned short tempbx; |
7677 | tempbx = 0; | |
d7636e0b | 7678 | } |
7679 | ||
cc1e2398 AK |
7680 | void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension, |
7681 | struct vb_device_info *pVBInfo) | |
d7636e0b | 7682 | { |
d7636e0b | 7683 | |
ec9e5d3e | 7684 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2f, 0xFF, 0x01); |
cc1e2398 | 7685 | |
d7636e0b | 7686 | } |
7687 | ||
cc1e2398 | 7688 | void XGI_LockCRT2(struct xgi_hw_device_info *HwDeviceExtension, |
21df8fc8 PS |
7689 | struct vb_device_info *pVBInfo) |
7690 | { | |
21df8fc8 | 7691 | |
ec9e5d3e | 7692 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2F, 0xFE, 0x00); |
21df8fc8 | 7693 | |
cc1e2398 | 7694 | } |
21df8fc8 | 7695 | |
cc1e2398 AK |
7696 | unsigned char XGI_BridgeIsOn(struct vb_device_info *pVBInfo) |
7697 | { | |
7698 | unsigned short flag; | |
21df8fc8 | 7699 | |
cc1e2398 AK |
7700 | if (pVBInfo->IF_DEF_LVDS == 1) { |
7701 | return 1; | |
7702 | } else { | |
58839b01 | 7703 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00); |
cc1e2398 AK |
7704 | if ((flag == 1) || (flag == 2)) |
7705 | return 1; /* 301b */ | |
7706 | else | |
7707 | return 0; | |
7708 | } | |
7709 | } | |
21df8fc8 | 7710 | |
cc1e2398 AK |
7711 | void XGI_LongWait(struct vb_device_info *pVBInfo) |
7712 | { | |
7713 | unsigned short i; | |
21df8fc8 | 7714 | |
58839b01 | 7715 | i = xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
21df8fc8 | 7716 | |
cc1e2398 AK |
7717 | if (!(i & 0xC0)) { |
7718 | for (i = 0; i < 0xFFFF; i++) { | |
d8ad0a6d | 7719 | if (!(inb(pVBInfo->P3da) & 0x08)) |
cc1e2398 AK |
7720 | break; |
7721 | } | |
21df8fc8 | 7722 | |
cc1e2398 | 7723 | for (i = 0; i < 0xFFFF; i++) { |
d8ad0a6d | 7724 | if ((inb(pVBInfo->P3da) & 0x08)) |
cc1e2398 AK |
7725 | break; |
7726 | } | |
7727 | } | |
7728 | } | |
21df8fc8 | 7729 | |
cc1e2398 AK |
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++) { | |
d8ad0a6d | 7738 | tempal = inb(pVBInfo->P3da); |
cc1e2398 AK |
7739 | if (temp & 0x01) { /* VBWaitMode2 */ |
7740 | if ((tempal & 0x08)) | |
7741 | continue; | |
21df8fc8 | 7742 | |
cc1e2398 AK |
7743 | if (!(tempal & 0x08)) |
7744 | break; | |
d7636e0b | 7745 | |
cc1e2398 AK |
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); | |
21df8fc8 | 7758 | } |
cc1e2398 AK |
7759 | return; |
7760 | } | |
21df8fc8 | 7761 | |
cc1e2398 AK |
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 }; | |
21df8fc8 | 7769 | |
cc1e2398 AK |
7770 | unsigned short RefreshRateTableIndex, i, modeflag, index, temp; |
7771 | ||
7772 | if (ModeNo <= 0x13) | |
7773 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
21df8fc8 | 7774 | else |
cc1e2398 | 7775 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
21df8fc8 | 7776 | |
cc1e2398 AK |
7777 | if (pVBInfo->IF_DEF_CH7005 == 1) { |
7778 | if (pVBInfo->VBInfo & SetCRT2ToTV) { | |
7779 | if (modeflag & HalfDCLK) | |
7780 | return 0; | |
7781 | } | |
21df8fc8 PS |
7782 | } |
7783 | ||
cc1e2398 AK |
7784 | if (ModeNo < 0x14) |
7785 | return 0xFFFF; | |
d7636e0b | 7786 | |
58839b01 | 7787 | index = xgifb_reg_get(pVBInfo->P3d4, 0x33); |
cc1e2398 AK |
7788 | index = index >> pVBInfo->SelectCRT2Rate; |
7789 | index &= 0x0F; | |
d7636e0b | 7790 | |
cc1e2398 AK |
7791 | if (pVBInfo->LCDInfo & LCDNonExpanding) |
7792 | index = 0; | |
d7636e0b | 7793 | |
cc1e2398 AK |
7794 | if (index > 0) |
7795 | index--; | |
d7636e0b | 7796 | |
cc1e2398 AK |
7797 | if (pVBInfo->SetFlag & ProgrammingCRT2) { |
7798 | if (pVBInfo->IF_DEF_CH7005 == 1) { | |
7799 | if (pVBInfo->VBInfo & SetCRT2ToTV) | |
7800 | index = 0; | |
7801 | } | |
d7636e0b | 7802 | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 7822 | } |
d7636e0b | 7823 | |
cc1e2398 AK |
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 | } | |
25985edc | 7837 | /* Alan 10/19/2007; do the similar adjustment like XGISearchCRT1Rate() */ |
cc1e2398 AK |
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++; | |
21df8fc8 PS |
7871 | } |
7872 | } | |
cc1e2398 AK |
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 | } | |
d7636e0b | 7880 | |
cc1e2398 AK |
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); | |
d7636e0b | 7899 | } |
7900 | ||
cc1e2398 | 7901 | unsigned char XGI_SetCRT2Group301(unsigned short ModeNo, |
21df8fc8 PS |
7902 | struct xgi_hw_device_info *HwDeviceExtension, |
7903 | struct vb_device_info *pVBInfo) | |
7904 | { | |
cc1e2398 | 7905 | unsigned short tempbx, ModeIdIndex, RefreshRateTableIndex; |
21df8fc8 | 7906 | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 7935 | |
cc1e2398 AK |
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 }; | |
21df8fc8 | 7941 | |
cc1e2398 | 7942 | unsigned char SR01 = 0, SR1F = 0, SR07 = 0, SR06 = 0; |
d7636e0b | 7943 | |
cc1e2398 AK |
7944 | unsigned char CR17, CR63, SR31; |
7945 | unsigned short temp; | |
7946 | unsigned char DAC_TEST_PARMS[3] = { 0x0F, 0x0F, 0x0F }; | |
d7636e0b | 7947 | |
cc1e2398 | 7948 | int i; |
8104e329 | 7949 | xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86); |
21df8fc8 | 7950 | |
cc1e2398 | 7951 | /* [2004/05/06] Vicent to fix XG42 single LCD sense to CRT+LCD */ |
8104e329 | 7952 | xgifb_reg_set(pVBInfo->P3d4, 0x57, 0x4A); |
58839b01 | 7953 | xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get( |
cc1e2398 | 7954 | pVBInfo->P3d4, 0x53) | 0x02)); |
21df8fc8 | 7955 | |
58839b01 AK |
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); | |
21df8fc8 | 7959 | |
8104e329 AK |
7960 | xgifb_reg_set(pVBInfo->P3c4, 0x01, (unsigned char) (SR01 & 0xDF)); |
7961 | xgifb_reg_set(pVBInfo->P3d4, 0x63, (unsigned char) (CR63 & 0xBF)); | |
21df8fc8 | 7962 | |
58839b01 | 7963 | CR17 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x17); |
8104e329 | 7964 | xgifb_reg_set(pVBInfo->P3d4, 0x17, (unsigned char) (CR17 | 0x80)); |
21df8fc8 | 7965 | |
58839b01 | 7966 | SR1F = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
8104e329 | 7967 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) (SR1F | 0x04)); |
21df8fc8 | 7968 | |
58839b01 | 7969 | SR07 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x07); |
8104e329 | 7970 | xgifb_reg_set(pVBInfo->P3c4, 0x07, (unsigned char) (SR07 & 0xFB)); |
58839b01 | 7971 | SR06 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x06); |
8104e329 | 7972 | xgifb_reg_set(pVBInfo->P3c4, 0x06, (unsigned char) (SR06 & 0xC3)); |
21df8fc8 | 7973 | |
8104e329 | 7974 | xgifb_reg_set(pVBInfo->P3d4, 0x11, 0x00); |
21df8fc8 | 7975 | |
cc1e2398 | 7976 | for (i = 0; i < 8; i++) |
8104e329 | 7977 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) i, CRTCData[i]); |
d7636e0b | 7978 | |
cc1e2398 | 7979 | for (i = 8; i < 11; i++) |
8104e329 | 7980 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 8), |
cc1e2398 | 7981 | CRTCData[i]); |
21df8fc8 | 7982 | |
cc1e2398 | 7983 | for (i = 11; i < 13; i++) |
8104e329 | 7984 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 4), |
cc1e2398 | 7985 | CRTCData[i]); |
21df8fc8 | 7986 | |
cc1e2398 | 7987 | for (i = 13; i < 16; i++) |
8104e329 | 7988 | xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i - 3), |
cc1e2398 | 7989 | CRTCData[i]); |
21df8fc8 | 7990 | |
8104e329 | 7991 | xgifb_reg_set(pVBInfo->P3c4, 0x0E, (unsigned char) (CRTCData[16] |
cc1e2398 | 7992 | & 0xE0)); |
21df8fc8 | 7993 | |
8104e329 AK |
7994 | xgifb_reg_set(pVBInfo->P3c4, 0x31, 0x00); |
7995 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x1B); | |
7996 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE1); | |
21df8fc8 | 7997 | |
efdf4ee7 | 7998 | outb(0x00, pVBInfo->P3c8); |
cc1e2398 AK |
7999 | |
8000 | for (i = 0; i < 256; i++) { | |
efdf4ee7 AK |
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)); | |
cc1e2398 AK |
8004 | } |
8005 | ||
8006 | XGI_VBLongWait(pVBInfo); | |
8007 | XGI_VBLongWait(pVBInfo); | |
8008 | XGI_VBLongWait(pVBInfo); | |
8009 | ||
8010 | mdelay(1); | |
8011 | ||
8012 | XGI_WaitDisply(pVBInfo); | |
d8ad0a6d | 8013 | temp = inb(pVBInfo->P3c2); |
cc1e2398 AK |
8014 | |
8015 | if (temp & 0x10) | |
ec9e5d3e | 8016 | xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x20); |
cc1e2398 | 8017 | else |
ec9e5d3e | 8018 | xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x00); |
21df8fc8 | 8019 | |
cc1e2398 | 8020 | /* alan, avoid display something, set BLACK DAC if not restore DAC */ |
efdf4ee7 | 8021 | outb(0x00, pVBInfo->P3c8); |
21df8fc8 | 8022 | |
cc1e2398 | 8023 | for (i = 0; i < 256; i++) { |
efdf4ee7 AK |
8024 | outb(0, (pVBInfo->P3c8 + 1)); |
8025 | outb(0, (pVBInfo->P3c8 + 1)); | |
8026 | outb(0, (pVBInfo->P3c8 + 1)); | |
21df8fc8 | 8027 | } |
d7636e0b | 8028 | |
8104e329 AK |
8029 | xgifb_reg_set(pVBInfo->P3c4, 0x01, SR01); |
8030 | xgifb_reg_set(pVBInfo->P3d4, 0x63, CR63); | |
8031 | xgifb_reg_set(pVBInfo->P3c4, 0x31, SR31); | |
21df8fc8 | 8032 | |
cc1e2398 | 8033 | /* [2004/05/11] Vicent */ |
58839b01 | 8034 | xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get( |
cc1e2398 | 8035 | pVBInfo->P3d4, 0x53) & 0xFD)); |
8104e329 | 8036 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) SR1F); |
cc1e2398 | 8037 | } |
21df8fc8 | 8038 | |
cc1e2398 AK |
8039 | void XGI_EnableBridge(struct xgi_hw_device_info *HwDeviceExtension, |
8040 | struct vb_device_info *pVBInfo) | |
8041 | { | |
fd0ad470 | 8042 | unsigned short tempah; |
21df8fc8 | 8043 | |
cc1e2398 AK |
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; | |
21df8fc8 | 8052 | } |
d7636e0b | 8053 | |
cc1e2398 AK |
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) { | |
8104e329 | 8058 | xgifb_reg_set(pVBInfo->Part1Port, 0x1E, 0x20); /* Power on */ |
cc1e2398 AK |
8059 | } else { |
8060 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { /* SetCRT2ToLCDA ) */ | |
8104e329 | 8061 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 AK |
8062 | 0x1E, 0x20); /* Power on */ |
8063 | } | |
8064 | } | |
21df8fc8 | 8065 | } |
d7636e0b | 8066 | |
cc1e2398 AK |
8067 | if (!(pVBInfo->SetFlag & DisableChB)) { |
8068 | if ((pVBInfo->SetFlag & EnableChB) || (pVBInfo->VBInfo | |
8069 | & (SetCRT2ToLCD | SetCRT2ToTV | |
8070 | | SetCRT2ToRAMDAC))) { | |
58839b01 | 8071 | tempah = (unsigned char) xgifb_reg_get( |
cc1e2398 AK |
8072 | pVBInfo->P3c4, 0x32); |
8073 | tempah &= 0xDF; | |
8074 | if (pVBInfo->VBInfo & SetInSlaveMode) { | |
8075 | if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) | |
8076 | tempah |= 0x20; | |
8077 | } | |
8104e329 | 8078 | xgifb_reg_set(pVBInfo->P3c4, 0x32, tempah); |
b9bf6e4e | 8079 | xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x20); |
d7636e0b | 8080 | |
58839b01 | 8081 | tempah = (unsigned char) xgifb_reg_get( |
cc1e2398 | 8082 | pVBInfo->Part1Port, 0x2E); |
d7636e0b | 8083 | |
cc1e2398 | 8084 | if (!(tempah & 0x80)) |
b9bf6e4e | 8085 | xgifb_reg_or(pVBInfo->Part1Port, |
cc1e2398 | 8086 | 0x2E, 0x80); /* BVBDOENABLE = 1 */ |
d7636e0b | 8087 | |
dc50556b | 8088 | xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F); /* BScreenOFF = 0 */ |
cc1e2398 AK |
8089 | } |
8090 | } | |
d7636e0b | 8091 | |
cc1e2398 AK |
8092 | if ((pVBInfo->SetFlag & (EnableChA | EnableChB)) |
8093 | || (!(pVBInfo->VBInfo & DisableCRT2Display))) { | |
ec9e5d3e | 8094 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x00, ~0xE0, |
cc1e2398 AK |
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))) | |
dc50556b | 8102 | xgifb_reg_and( |
cc1e2398 AK |
8103 | pVBInfo->Part4Port, |
8104 | 0x2A, 0x7F); /* LVDS PLL power on */ | |
8105 | } | |
dc50556b | 8106 | xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x7F); /* LVDS Driver power on */ |
cc1e2398 AK |
8107 | } |
8108 | } | |
d7636e0b | 8109 | |
cc1e2398 | 8110 | tempah = 0x00; |
d7636e0b | 8111 | |
cc1e2398 AK |
8112 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
8113 | tempah = 0xc0; | |
d7636e0b | 8114 | |
cc1e2398 AK |
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; | |
d7636e0b | 8122 | |
cc1e2398 AK |
8123 | if (pVBInfo->SetFlag |
8124 | & DisableChB) | |
8125 | tempah &= 0xBF; | |
d7636e0b | 8126 | |
cc1e2398 AK |
8127 | if (pVBInfo->SetFlag |
8128 | & DisableChA) | |
8129 | tempah &= 0x7F; | |
d7636e0b | 8130 | |
cc1e2398 AK |
8131 | if (pVBInfo->SetFlag |
8132 | & EnableChB) | |
8133 | tempah |= 0x40; | |
d7636e0b | 8134 | |
cc1e2398 AK |
8135 | if (pVBInfo->SetFlag |
8136 | & EnableChA) | |
8137 | tempah |= 0x80; | |
8138 | } | |
8139 | } | |
8140 | } | |
8141 | } | |
d7636e0b | 8142 | |
b9bf6e4e | 8143 | xgifb_reg_or(pVBInfo->Part4Port, 0x1F, tempah); /* EnablePart4_1F */ |
d7636e0b | 8144 | |
cc1e2398 AK |
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)) | |
b9bf6e4e | 8162 | xgifb_reg_or(pVBInfo->Part1Port, 0x1E, 0x20); /* enable CRT2 */ |
d7636e0b | 8163 | |
58839b01 | 8164 | tempah = (unsigned char) xgifb_reg_get(pVBInfo->Part1Port, |
cc1e2398 AK |
8165 | 0x2E); |
8166 | if (!(tempah & 0x80)) | |
b9bf6e4e | 8167 | xgifb_reg_or(pVBInfo->Part1Port, 0x2E, 0x80); /* BVBDOENABLE = 1 */ |
d7636e0b | 8168 | |
dc50556b | 8169 | xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F); |
cc1e2398 AK |
8170 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); |
8171 | } /* End of VB */ | |
d7636e0b | 8172 | } |
8173 | ||
cc1e2398 AK |
8174 | static void XGI_SetCRT1Group(struct xgi_hw_device_info *HwDeviceExtension, |
8175 | unsigned short ModeNo, unsigned short ModeIdIndex, | |
21df8fc8 | 8176 | struct vb_device_info *pVBInfo) |
d7636e0b | 8177 | { |
cc1e2398 | 8178 | unsigned short StandTableIndex, RefreshRateTableIndex, b3CC, temp; |
d7636e0b | 8179 | |
cc1e2398 | 8180 | unsigned short XGINew_P3cc = pVBInfo->P3cc; |
d7636e0b | 8181 | |
cc1e2398 AK |
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); | |
d7636e0b | 8192 | |
cc1e2398 AK |
8193 | /* if (pVBInfo->IF_DEF_ExpLink) */ |
8194 | if (HwDeviceExtension->jChipType == XG27) { | |
8195 | if (pVBInfo->IF_DEF_LVDS == 0) | |
8196 | XGI_SetDefaultVCLK(pVBInfo); | |
21df8fc8 | 8197 | } |
d7636e0b | 8198 | |
cc1e2398 AK |
8199 | temp = ~ProgrammingCRT2; |
8200 | pVBInfo->SetFlag &= temp; | |
8201 | pVBInfo->SelectCRT2Rate = 0; | |
d7636e0b | 8202 | |
cc1e2398 AK |
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; | |
21df8fc8 | 8208 | } |
cc1e2398 | 8209 | } |
d7636e0b | 8210 | |
cc1e2398 AK |
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)) { | |
8104e329 AK |
8228 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x4E); |
8229 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE9); | |
d8ad0a6d | 8230 | b3CC = (unsigned char) inb(XGINew_P3cc); |
efdf4ee7 | 8231 | outb((b3CC |= 0x0C), XGINew_P3cc); |
cc1e2398 AK |
8232 | } else if ((ModeNo == 0x04) | (ModeNo == 0x05) | (ModeNo |
8233 | == 0x0D)) { | |
8104e329 AK |
8234 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x1B); |
8235 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE3); | |
d8ad0a6d | 8236 | b3CC = (unsigned char) inb(XGINew_P3cc); |
efdf4ee7 | 8237 | outb((b3CC |= 0x0C), XGINew_P3cc); |
21df8fc8 | 8238 | } |
d7636e0b | 8239 | } |
d7636e0b | 8240 | |
cc1e2398 | 8241 | if (HwDeviceExtension->jChipType >= XG21) { |
58839b01 | 8242 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x38); |
cc1e2398 | 8243 | if (temp & 0xA0) { |
21df8fc8 | 8244 | |
dc50556b AK |
8245 | /* xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x20); *//* Enable write GPIOF */ |
8246 | /* xgifb_reg_and(pVBInfo->P3d4, 0x48, ~0x20); *//* P. DWN */ | |
cc1e2398 AK |
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); | |
21df8fc8 | 8254 | |
cc1e2398 AK |
8255 | XGI_UpdateXG21CRTC(ModeNo, pVBInfo, |
8256 | RefreshRateTableIndex); | |
21df8fc8 | 8257 | |
cc1e2398 AK |
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); | |
21df8fc8 | 8272 | } |
b9bf6e4e | 8273 | /* xgifb_reg_or(pVBInfo->P3d4, 0x48, 0x20); *//* P. ON */ |
21df8fc8 | 8274 | } |
21df8fc8 | 8275 | } |
d7636e0b | 8276 | |
cc1e2398 AK |
8277 | pVBInfo->SetFlag &= (~ProgrammingCRT2); |
8278 | XGI_SetCRT1FIFO(ModeNo, HwDeviceExtension, pVBInfo); | |
8279 | XGI_SetCRT1ModeRegs(HwDeviceExtension, ModeNo, ModeIdIndex, | |
8280 | RefreshRateTableIndex, pVBInfo); | |
d7636e0b | 8281 | |
cc1e2398 | 8282 | /* XGI_LoadCharacter(); //dif ifdef TVFont */ |
d7636e0b | 8283 | |
cc1e2398 AK |
8284 | XGI_LoadDAC(ModeNo, ModeIdIndex, pVBInfo); |
8285 | /* XGI_ClearBuffer(HwDeviceExtension, ModeNo, pVBInfo); */ | |
d7636e0b | 8286 | } |
8287 | ||
cc1e2398 AK |
8288 | unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension, |
8289 | unsigned short ModeNo) | |
21df8fc8 | 8290 | { |
cc1e2398 AK |
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*/ | |
cc1e2398 AK |
8312 | } else { |
8313 | pVBInfo->IF_DEF_YPbPr = 1; | |
8314 | pVBInfo->IF_DEF_HiVision = 1; | |
06587335 | 8315 | pVBInfo->IF_DEF_CRT2Monitor = 1; |
cc1e2398 AK |
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; | |
21df8fc8 | 8336 | |
cc1e2398 | 8337 | if (HwDeviceExtension->jChipType == XG21) { /* for x86 Linux, XG21 LVDS */ |
58839b01 | 8338 | if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) |
cc1e2398 AK |
8339 | pVBInfo->IF_DEF_LVDS = 1; |
8340 | } | |
8341 | if (HwDeviceExtension->jChipType == XG27) { | |
58839b01 AK |
8342 | if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) { |
8343 | if (xgifb_reg_get(pVBInfo->P3d4, 0x30) & 0x20) | |
cc1e2398 AK |
8344 | pVBInfo->IF_DEF_LVDS = 1; |
8345 | } | |
8346 | } | |
21df8fc8 | 8347 | |
cc1e2398 AK |
8348 | if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 */ |
8349 | XGI_GetVBType(pVBInfo); | |
21df8fc8 | 8350 | |
cc1e2398 AK |
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; | |
21df8fc8 | 8358 | } |
cc1e2398 | 8359 | */ |
8104e329 | 8360 | xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86); |
21df8fc8 | 8361 | |
cc1e2398 AK |
8362 | if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 1.Openkey */ |
8363 | XGI_UnLockCRT2(HwDeviceExtension, pVBInfo); | |
21df8fc8 | 8364 | |
cc1e2398 | 8365 | XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo); |
21df8fc8 | 8366 | |
cc1e2398 | 8367 | XGI_GetVGAType(HwDeviceExtension, pVBInfo); |
21df8fc8 | 8368 | |
cc1e2398 AK |
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); */ | |
21df8fc8 | 8375 | |
cc1e2398 AK |
8376 | if (pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToLCDA)) { |
8377 | XGI_SetCRT1Group(HwDeviceExtension, ModeNo, | |
8378 | ModeIdIndex, pVBInfo); | |
21df8fc8 | 8379 | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 8395 | |
cc1e2398 AK |
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; | |
21df8fc8 | 8402 | |
cc1e2398 AK |
8403 | case VB_CHIP_302: |
8404 | XGI_SetCRT2Group301(ModeNo, HwDeviceExtension, | |
8405 | pVBInfo); /*add for CRT2 */ | |
8406 | break; | |
21df8fc8 | 8407 | |
cc1e2398 AK |
8408 | default: |
8409 | break; | |
8410 | } | |
8411 | } | |
21df8fc8 | 8412 | |
cc1e2398 AK |
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; | |
21df8fc8 | 8422 | |
cc1e2398 AK |
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 | } | |
21df8fc8 | 8432 | |
cc1e2398 AK |
8433 | pVBInfo->SetFlag = 0; |
8434 | if (pVBInfo->IF_DEF_CH7007 != 1) | |
8435 | pVBInfo->VBInfo = DisableCRT2Display; | |
21df8fc8 | 8436 | |
cc1e2398 | 8437 | XGI_DisplayOff(HwDeviceExtension, pVBInfo); |
21df8fc8 | 8438 | |
cc1e2398 AK |
8439 | XGI_SetCRT1Group(HwDeviceExtension, ModeNo, ModeIdIndex, |
8440 | pVBInfo); | |
21df8fc8 | 8441 | |
cc1e2398 AK |
8442 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); |
8443 | /* | |
8444 | if (HwDeviceExtension->jChipType == XG21) | |
ec9e5d3e | 8445 | xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0x80, 0x80); |
cc1e2398 AK |
8446 | */ |
8447 | } | |
21df8fc8 | 8448 | |
cc1e2398 AK |
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); | |
21df8fc8 | 8459 | |
cc1e2398 AK |
8460 | if (temp == 0) |
8461 | return (0); | |
21df8fc8 | 8462 | |
cc1e2398 AK |
8463 | XGI_DisplayOff(HwDeviceExtension, pVBInfo) ; |
8464 | XGI_SetCRT1Group(HwDeviceExtension, ModeNo, ModeIdIndex, pVBInfo); | |
8465 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); | |
8466 | */ | |
21df8fc8 | 8467 | |
cc1e2398 | 8468 | XGI_UpdateModeInfo(HwDeviceExtension, pVBInfo); |
21df8fc8 | 8469 | |
cc1e2398 AK |
8470 | if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */ |
8471 | XGI_LockCRT2(HwDeviceExtension, pVBInfo); | |
21df8fc8 | 8472 | } |
21df8fc8 | 8473 | |
cc1e2398 | 8474 | return 1; |
d7636e0b | 8475 | } |