Commit | Line | Data |
---|---|---|
d7636e0b | 1 | |
1d7f656d | 2 | #include <linux/io.h> |
d80aaa01 | 3 | #include <linux/delay.h> |
d7636e0b | 4 | #include <linux/types.h> |
d7636e0b | 5 | #include "XGIfb.h" |
d7636e0b | 6 | |
d7636e0b | 7 | |
8 | #include "vb_def.h" | |
9 | #include "vgatypes.h" | |
10 | #include "vb_struct.h" | |
11 | #include "vb_util.h" | |
12 | #include "vb_table.h" | |
5e60b97c | 13 | #include "vb_setmode.h" |
d7636e0b | 14 | |
15 | ||
16 | #define IndexMask 0xff | |
d7636e0b | 17 | |
8922967e | 18 | static unsigned short XGINew_MDA_DAC[] = { |
82d6eb5b BP |
19 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
20 | 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, | |
21 | 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, | |
22 | 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, | |
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 | ||
8922967e | 28 | static unsigned short XGINew_CGA_DAC[] = { |
82d6eb5b BP |
29 | 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15, |
30 | 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15, | |
31 | 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F, | |
32 | 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F, | |
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 | ||
8922967e | 38 | static unsigned short XGINew_EGA_DAC[] = { |
82d6eb5b BP |
39 | 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x05, 0x15, |
40 | 0x20, 0x30, 0x24, 0x34, 0x21, 0x31, 0x25, 0x35, | |
41 | 0x08, 0x18, 0x0C, 0x1C, 0x09, 0x19, 0x0D, 0x1D, | |
42 | 0x28, 0x38, 0x2C, 0x3C, 0x29, 0x39, 0x2D, 0x3D, | |
43 | 0x02, 0x12, 0x06, 0x16, 0x03, 0x13, 0x07, 0x17, | |
44 | 0x22, 0x32, 0x26, 0x36, 0x23, 0x33, 0x27, 0x37, | |
45 | 0x0A, 0x1A, 0x0E, 0x1E, 0x0B, 0x1B, 0x0F, 0x1F, | |
46 | 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F}; | |
47 | ||
8922967e | 48 | static unsigned short XGINew_VGA_DAC[] = { |
82d6eb5b BP |
49 | 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15, |
50 | 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F, | |
51 | 0x00, 0x05, 0x08, 0x0B, 0x0E, 0x11, 0x14, 0x18, | |
52 | 0x1C, 0x20, 0x24, 0x28, 0x2D, 0x32, 0x38, 0x3F, | |
53 | 0x00, 0x10, 0x1F, 0x2F, 0x3F, 0x1F, 0x27, 0x2F, | |
54 | 0x37, 0x3F, 0x2D, 0x31, 0x36, 0x3A, 0x3F, 0x00, | |
55 | 0x07, 0x0E, 0x15, 0x1C, 0x0E, 0x11, 0x15, 0x18, | |
56 | 0x1C, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x00, 0x04, | |
57 | 0x08, 0x0C, 0x10, 0x08, 0x0A, 0x0C, 0x0E, 0x10, | |
58 | 0x0B, 0x0C, 0x0D, 0x0F, 0x10}; | |
d7636e0b | 59 | |
80adad85 | 60 | void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo) |
d7636e0b | 61 | { |
21df8fc8 PS |
62 | pVBInfo->SModeIDTable = (struct XGI_StStruct *) XGI330_SModeIDTable; |
63 | pVBInfo->StandTable = (struct XGI_StandTableStruct *) XGI330_StandTable; | |
64 | pVBInfo->EModeIDTable = (struct XGI_ExtStruct *) XGI330_EModeIDTable; | |
65 | pVBInfo->RefIndex = (struct XGI_Ext2Struct *) XGI330_RefIndex; | |
66 | pVBInfo->XGINEWUB_CRT1Table | |
67 | = (struct XGI_CRT1TableStruct *) XGI_CRT1Table; | |
68 | ||
69 | /* add for new UNIVGABIOS */ | |
1d7f656d KT |
70 | /* XGINew_UBLCDDataTable = |
71 | * (struct XGI_LCDDataTablStruct *) XGI_LCDDataTable; */ | |
21df8fc8 PS |
72 | /* XGINew_UBTVDataTable = (XGI_TVDataTablStruct *) XGI_TVDataTable; */ |
73 | ||
06587335 AK |
74 | pVBInfo->MCLKData = (struct XGI_MCLKDataStruct *) XGI340New_MCLKData; |
75 | pVBInfo->ECLKData = (struct XGI_ECLKDataStruct *) XGI340_ECLKData; | |
21df8fc8 PS |
76 | pVBInfo->VCLKData = (struct XGI_VCLKDataStruct *) XGI_VCLKData; |
77 | pVBInfo->VBVCLKData = (struct XGI_VBVCLKDataStruct *) XGI_VBVCLKData; | |
78 | pVBInfo->ScreenOffset = XGI330_ScreenOffset; | |
79 | pVBInfo->StResInfo = (struct XGI_StResInfoStruct *) XGI330_StResInfo; | |
80 | pVBInfo->ModeResInfo | |
81 | = (struct XGI_ModeResInfoStruct *) XGI330_ModeResInfo; | |
82 | ||
83 | pVBInfo->pOutputSelect = &XGI330_OutputSelect; | |
84 | pVBInfo->pSoftSetting = &XGI330_SoftSetting; | |
85 | pVBInfo->pSR07 = &XGI330_SR07; | |
86 | pVBInfo->LCDResInfo = 0; | |
87 | pVBInfo->LCDTypeInfo = 0; | |
88 | pVBInfo->LCDInfo = 0; | |
89 | pVBInfo->VBInfo = 0; | |
90 | pVBInfo->TVInfo = 0; | |
91 | ||
92 | pVBInfo->SR15 = XGI340_SR13; | |
93 | pVBInfo->CR40 = XGI340_cr41; | |
94 | pVBInfo->SR25 = XGI330_sr25; | |
95 | pVBInfo->pSR31 = &XGI330_sr31; | |
96 | pVBInfo->pSR32 = &XGI330_sr32; | |
97 | pVBInfo->CR6B = XGI340_CR6B; | |
98 | pVBInfo->CR6E = XGI340_CR6E; | |
99 | pVBInfo->CR6F = XGI340_CR6F; | |
100 | pVBInfo->CR89 = XGI340_CR89; | |
101 | pVBInfo->AGPReg = XGI340_AGPReg; | |
102 | pVBInfo->SR16 = XGI340_SR16; | |
103 | pVBInfo->pCRCF = &XG40_CRCF; | |
104 | pVBInfo->pXGINew_DRAMTypeDefinition = &XG40_DRAMTypeDefinition; | |
105 | ||
106 | pVBInfo->CR49 = XGI330_CR49; | |
107 | pVBInfo->pSR1F = &XGI330_SR1F; | |
108 | pVBInfo->pSR21 = &XGI330_SR21; | |
109 | pVBInfo->pSR22 = &XGI330_SR22; | |
110 | pVBInfo->pSR23 = &XGI330_SR23; | |
111 | pVBInfo->pSR24 = &XGI330_SR24; | |
112 | pVBInfo->pSR33 = &XGI330_SR33; | |
113 | ||
114 | pVBInfo->pCRT2Data_1_2 = &XGI330_CRT2Data_1_2; | |
115 | pVBInfo->pCRT2Data_4_D = &XGI330_CRT2Data_4_D; | |
116 | pVBInfo->pCRT2Data_4_E = &XGI330_CRT2Data_4_E; | |
117 | pVBInfo->pCRT2Data_4_10 = &XGI330_CRT2Data_4_10; | |
118 | pVBInfo->pRGBSenseData = &XGI330_RGBSenseData; | |
119 | pVBInfo->pVideoSenseData = &XGI330_VideoSenseData; | |
120 | pVBInfo->pYCSenseData = &XGI330_YCSenseData; | |
121 | pVBInfo->pRGBSenseData2 = &XGI330_RGBSenseData2; | |
122 | pVBInfo->pVideoSenseData2 = &XGI330_VideoSenseData2; | |
123 | pVBInfo->pYCSenseData2 = &XGI330_YCSenseData2; | |
124 | ||
125 | pVBInfo->NTSCTiming = XGI330_NTSCTiming; | |
126 | pVBInfo->PALTiming = XGI330_PALTiming; | |
127 | pVBInfo->HiTVExtTiming = XGI330_HiTVExtTiming; | |
128 | pVBInfo->HiTVSt1Timing = XGI330_HiTVSt1Timing; | |
129 | pVBInfo->HiTVSt2Timing = XGI330_HiTVSt2Timing; | |
130 | pVBInfo->HiTVTextTiming = XGI330_HiTVTextTiming; | |
131 | pVBInfo->YPbPr750pTiming = XGI330_YPbPr750pTiming; | |
132 | pVBInfo->YPbPr525pTiming = XGI330_YPbPr525pTiming; | |
133 | pVBInfo->YPbPr525iTiming = XGI330_YPbPr525iTiming; | |
134 | pVBInfo->HiTVGroup3Data = XGI330_HiTVGroup3Data; | |
135 | pVBInfo->HiTVGroup3Simu = XGI330_HiTVGroup3Simu; | |
136 | pVBInfo->HiTVGroup3Text = XGI330_HiTVGroup3Text; | |
137 | pVBInfo->Ren525pGroup3 = XGI330_Ren525pGroup3; | |
138 | pVBInfo->Ren750pGroup3 = XGI330_Ren750pGroup3; | |
139 | ||
140 | pVBInfo->TimingH = (struct XGI_TimingHStruct *) XGI_TimingH; | |
141 | pVBInfo->TimingV = (struct XGI_TimingVStruct *) XGI_TimingV; | |
142 | pVBInfo->UpdateCRT1 = (struct XGI_XG21CRT1Struct *) XGI_UpdateCRT1Table; | |
143 | ||
144 | pVBInfo->CHTVVCLKUNTSC = XGI330_CHTVVCLKUNTSC; | |
145 | pVBInfo->CHTVVCLKONTSC = XGI330_CHTVVCLKONTSC; | |
146 | pVBInfo->CHTVVCLKUPAL = XGI330_CHTVVCLKUPAL; | |
147 | pVBInfo->CHTVVCLKOPAL = XGI330_CHTVVCLKOPAL; | |
148 | ||
149 | /* 310 customization related */ | |
150 | if ((pVBInfo->VBType & VB_XGI301LV) || (pVBInfo->VBType & VB_XGI302LV)) | |
151 | pVBInfo->LCDCapList = XGI_LCDDLCapList; | |
152 | else | |
153 | pVBInfo->LCDCapList = XGI_LCDCapList; | |
d7636e0b | 154 | |
21df8fc8 PS |
155 | if ((ChipType == XG21) || (ChipType == XG27)) |
156 | pVBInfo->XG21_LVDSCapList = XGI21_LCDCapList; | |
d7636e0b | 157 | |
21df8fc8 PS |
158 | pVBInfo->XGI_TVDelayList = XGI301TVDelayList; |
159 | pVBInfo->XGI_TVDelayList2 = XGI301TVDelayList2; | |
d7636e0b | 160 | |
21df8fc8 | 161 | pVBInfo->pXGINew_I2CDefinition = &XG40_I2CDefinition; |
d7636e0b | 162 | |
21df8fc8 PS |
163 | if (ChipType >= XG20) |
164 | pVBInfo->pXGINew_CR97 = &XG20_CR97; | |
d7636e0b | 165 | |
21df8fc8 PS |
166 | if (ChipType == XG27) { |
167 | pVBInfo->MCLKData | |
168 | = (struct XGI_MCLKDataStruct *) XGI27New_MCLKData; | |
169 | pVBInfo->CR40 = XGI27_cr41; | |
170 | pVBInfo->pXGINew_CR97 = &XG27_CR97; | |
171 | pVBInfo->pSR36 = &XG27_SR36; | |
172 | pVBInfo->pCR8F = &XG27_CR8F; | |
173 | pVBInfo->pCRD0 = XG27_CRD0; | |
174 | pVBInfo->pCRDE = XG27_CRDE; | |
175 | pVBInfo->pSR40 = &XG27_SR40; | |
176 | pVBInfo->pSR41 = &XG27_SR41; | |
177 | ||
178 | } | |
179 | ||
180 | if (ChipType >= XG20) { | |
181 | pVBInfo->pDVOSetting = &XG21_DVOSetting; | |
182 | pVBInfo->pCR2E = &XG21_CR2E; | |
183 | pVBInfo->pCR2F = &XG21_CR2F; | |
184 | pVBInfo->pCR46 = &XG21_CR46; | |
185 | pVBInfo->pCR47 = &XG21_CR47; | |
186 | } | |
187 | ||
188 | } | |
d7636e0b | 189 | |
1d7f656d KT |
190 | static unsigned char XGI_GetModePtr(unsigned short ModeNo, |
191 | unsigned short ModeIdIndex, | |
192 | struct vb_device_info *pVBInfo) | |
21df8fc8 | 193 | { |
cc1e2398 | 194 | unsigned char index; |
21df8fc8 | 195 | |
cc1e2398 AK |
196 | if (ModeNo <= 0x13) |
197 | index = pVBInfo->SModeIDTable[ModeIdIndex].St_StTableIndex; | |
198 | else { | |
199 | if (pVBInfo->ModeType <= 0x02) | |
200 | index = 0x1B; /* 02 -> ModeEGA */ | |
201 | else | |
202 | index = 0x0F; | |
21df8fc8 | 203 | } |
cc1e2398 AK |
204 | return index; /* Get pVBInfo->StandTable index */ |
205 | } | |
d7636e0b | 206 | |
cc1e2398 | 207 | /* |
1d7f656d KT |
208 | unsigned char XGI_SetBIOSData(unsigned short ModeNo, |
209 | unsigned short ModeIdIndex) { | |
cc1e2398 AK |
210 | return (0); |
211 | } | |
212 | */ | |
21df8fc8 | 213 | |
1d7f656d KT |
214 | /* unsigned char XGI_ClearBankRegs(unsigned short ModeNo, |
215 | unsigned short ModeIdIndex) { | |
cc1e2398 AK |
216 | return( 0 ) ; |
217 | } | |
218 | */ | |
219 | ||
1d7f656d KT |
220 | static void XGI_SetSeqRegs(unsigned short ModeNo, |
221 | unsigned short StandTableIndex, | |
222 | unsigned short ModeIdIndex, | |
223 | struct vb_device_info *pVBInfo) | |
cc1e2398 AK |
224 | { |
225 | unsigned char tempah, SRdata; | |
cc1e2398 AK |
226 | unsigned short i, modeflag; |
227 | ||
228 | if (ModeNo <= 0x13) | |
229 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
230 | else | |
231 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
232 | ||
8104e329 | 233 | xgifb_reg_set(pVBInfo->P3c4, 0x00, 0x03); /* Set SR0 */ |
cc1e2398 AK |
234 | tempah = pVBInfo->StandTable[StandTableIndex].SR[0]; |
235 | ||
236 | i = SetCRT2ToLCDA; | |
237 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { | |
238 | tempah |= 0x01; | |
239 | } else { | |
240 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD)) { | |
241 | if (pVBInfo->VBInfo & SetInSlaveMode) | |
242 | tempah |= 0x01; | |
21df8fc8 PS |
243 | } |
244 | } | |
d7636e0b | 245 | |
cc1e2398 | 246 | tempah |= 0x20; /* screen off */ |
8104e329 | 247 | xgifb_reg_set(pVBInfo->P3c4, 0x01, tempah); /* Set SR1 */ |
d7636e0b | 248 | |
cc1e2398 | 249 | for (i = 02; i <= 04; i++) { |
1d7f656d KT |
250 | /* Get SR2,3,4 from file */ |
251 | SRdata = pVBInfo->StandTable[StandTableIndex].SR[i - 1]; | |
8104e329 | 252 | xgifb_reg_set(pVBInfo->P3c4, i, SRdata); /* Set SR2 3 4 */ |
21df8fc8 | 253 | } |
cc1e2398 AK |
254 | } |
255 | ||
256 | static void XGI_SetMiscRegs(unsigned short StandTableIndex, | |
1d7f656d | 257 | struct vb_device_info *pVBInfo) |
cc1e2398 AK |
258 | { |
259 | unsigned char Miscdata; | |
260 | ||
1d7f656d KT |
261 | /* Get Misc from file */ |
262 | Miscdata = pVBInfo->StandTable[StandTableIndex].MISC; | |
cc1e2398 | 263 | /* |
1d7f656d KT |
264 | if (pVBInfo->VBType & (VB_XGI301B | |
265 | VB_XGI302B | | |
266 | VB_XGI301LV | | |
267 | VB_XGI302LV | | |
268 | VB_XGI301C)) { | |
cc1e2398 AK |
269 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { |
270 | Miscdata |= 0x0C; | |
271 | } | |
21df8fc8 PS |
272 | } |
273 | */ | |
21df8fc8 | 274 | |
efdf4ee7 | 275 | outb(Miscdata, pVBInfo->P3c2); /* Set Misc(3c2) */ |
cc1e2398 | 276 | } |
21df8fc8 | 277 | |
cc1e2398 | 278 | static void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension, |
1d7f656d KT |
279 | unsigned short StandTableIndex, |
280 | struct vb_device_info *pVBInfo) | |
cc1e2398 AK |
281 | { |
282 | unsigned char CRTCdata; | |
283 | unsigned short i; | |
21df8fc8 | 284 | |
58839b01 | 285 | CRTCdata = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
cc1e2398 | 286 | CRTCdata &= 0x7f; |
8104e329 | 287 | xgifb_reg_set(pVBInfo->P3d4, 0x11, CRTCdata); /* Unlock CRTC */ |
21df8fc8 | 288 | |
cc1e2398 | 289 | for (i = 0; i <= 0x18; i++) { |
1d7f656d KT |
290 | /* Get CRTC from file */ |
291 | CRTCdata = pVBInfo->StandTable[StandTableIndex].CRTC[i]; | |
8104e329 | 292 | xgifb_reg_set(pVBInfo->P3d4, i, CRTCdata); /* Set CRTC(3d4) */ |
cc1e2398 AK |
293 | } |
294 | /* | |
1d7f656d KT |
295 | if ((HwDeviceExtension->jChipType == XGI_630) && |
296 | (HwDeviceExtension->jChipRevision == 0x30)) { | |
cc1e2398 AK |
297 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
298 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) { | |
8104e329 | 299 | xgifb_reg_set(pVBInfo->P3d4, 0x18, 0xFE); |
cc1e2398 AK |
300 | } |
301 | } | |
302 | } | |
303 | */ | |
304 | } | |
21df8fc8 | 305 | |
1d7f656d KT |
306 | static void XGI_SetATTRegs(unsigned short ModeNo, |
307 | unsigned short StandTableIndex, | |
308 | unsigned short ModeIdIndex, | |
309 | struct vb_device_info *pVBInfo) | |
cc1e2398 AK |
310 | { |
311 | unsigned char ARdata; | |
312 | unsigned short i, modeflag; | |
21df8fc8 | 313 | |
cc1e2398 AK |
314 | if (ModeNo <= 0x13) |
315 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
316 | else | |
317 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
318 | ||
319 | for (i = 0; i <= 0x13; i++) { | |
320 | ARdata = pVBInfo->StandTable[StandTableIndex].ATTR[i]; | |
321 | if (modeflag & Charx8Dot) { /* ifndef Dot9 */ | |
322 | if (i == 0x13) { | |
21df8fc8 | 323 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { |
cc1e2398 AK |
324 | ARdata = 0; |
325 | } else { | |
326 | if (pVBInfo->VBInfo & (SetCRT2ToTV | |
327 | | SetCRT2ToLCD)) { | |
1d7f656d KT |
328 | if (pVBInfo->VBInfo & |
329 | SetInSlaveMode) | |
cc1e2398 AK |
330 | ARdata = 0; |
331 | } | |
21df8fc8 PS |
332 | } |
333 | } | |
334 | } | |
335 | ||
d8ad0a6d | 336 | inb(pVBInfo->P3da); /* reset 3da */ |
efdf4ee7 AK |
337 | outb(i, pVBInfo->P3c0); /* set index */ |
338 | outb(ARdata, pVBInfo->P3c0); /* set data */ | |
cc1e2398 | 339 | } |
21df8fc8 | 340 | |
d8ad0a6d | 341 | inb(pVBInfo->P3da); /* reset 3da */ |
efdf4ee7 AK |
342 | outb(0x14, pVBInfo->P3c0); /* set index */ |
343 | outb(0x00, pVBInfo->P3c0); /* set data */ | |
d8ad0a6d | 344 | inb(pVBInfo->P3da); /* Enable Attribute */ |
efdf4ee7 | 345 | outb(0x20, pVBInfo->P3c0); |
cc1e2398 | 346 | } |
21df8fc8 | 347 | |
cc1e2398 | 348 | static void XGI_SetGRCRegs(unsigned short StandTableIndex, |
1d7f656d | 349 | struct vb_device_info *pVBInfo) |
cc1e2398 AK |
350 | { |
351 | unsigned char GRdata; | |
352 | unsigned short i; | |
21df8fc8 | 353 | |
cc1e2398 | 354 | for (i = 0; i <= 0x08; i++) { |
1d7f656d KT |
355 | /* Get GR from file */ |
356 | GRdata = pVBInfo->StandTable[StandTableIndex].GRC[i]; | |
8104e329 | 357 | xgifb_reg_set(pVBInfo->P3ce, i, GRdata); /* Set GR(3ce) */ |
cc1e2398 | 358 | } |
21df8fc8 | 359 | |
cc1e2398 | 360 | if (pVBInfo->ModeType > ModeVGA) { |
58839b01 | 361 | GRdata = (unsigned char) xgifb_reg_get(pVBInfo->P3ce, 0x05); |
cc1e2398 | 362 | GRdata &= 0xBF; /* 256 color disable */ |
8104e329 | 363 | xgifb_reg_set(pVBInfo->P3ce, 0x05, GRdata); |
21df8fc8 | 364 | } |
cc1e2398 | 365 | } |
d7636e0b | 366 | |
cc1e2398 AK |
367 | static void XGI_ClearExt1Regs(struct vb_device_info *pVBInfo) |
368 | { | |
369 | unsigned short i; | |
d7636e0b | 370 | |
cc1e2398 | 371 | for (i = 0x0A; i <= 0x0E; i++) |
8104e329 | 372 | xgifb_reg_set(pVBInfo->P3c4, i, 0x00); /* Clear SR0A-SR0E */ |
cc1e2398 | 373 | } |
d7636e0b | 374 | |
cc1e2398 AK |
375 | static unsigned char XGI_SetDefaultVCLK(struct vb_device_info *pVBInfo) |
376 | { | |
d7636e0b | 377 | |
ec9e5d3e | 378 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x20); |
8104e329 AK |
379 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, pVBInfo->VCLKData[0].SR2B); |
380 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, pVBInfo->VCLKData[0].SR2C); | |
21df8fc8 | 381 | |
ec9e5d3e | 382 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, 0x10); |
8104e329 AK |
383 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, pVBInfo->VCLKData[1].SR2B); |
384 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, pVBInfo->VCLKData[1].SR2C); | |
21df8fc8 | 385 | |
dc50556b | 386 | xgifb_reg_and(pVBInfo->P3c4, 0x31, ~0x30); |
cc1e2398 | 387 | return 0; |
d7636e0b | 388 | } |
389 | ||
cc1e2398 AK |
390 | static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo, |
391 | unsigned short ModeIdIndex, | |
392 | unsigned short RefreshRateTableIndex, unsigned short *i, | |
21df8fc8 PS |
393 | struct vb_device_info *pVBInfo) |
394 | { | |
cc1e2398 | 395 | unsigned short tempax, tempbx, resinfo, modeflag, infoflag; |
21df8fc8 | 396 | |
cc1e2398 | 397 | if (ModeNo <= 0x13) |
1d7f656d KT |
398 | /* si+St_ModeFlag */ |
399 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
cc1e2398 AK |
400 | else |
401 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
21df8fc8 | 402 | |
cc1e2398 AK |
403 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
404 | tempbx = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID; | |
405 | tempax = 0; | |
21df8fc8 | 406 | |
cc1e2398 AK |
407 | if (pVBInfo->IF_DEF_LVDS == 0) { |
408 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { | |
409 | tempax |= SupportRAMDAC2; | |
21df8fc8 | 410 | |
cc1e2398 AK |
411 | if (pVBInfo->VBType & VB_XGI301C) |
412 | tempax |= SupportCRT2in301C; | |
21df8fc8 | 413 | } |
21df8fc8 | 414 | |
1d7f656d KT |
415 | /* 301b */ |
416 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { | |
cc1e2398 | 417 | tempax |= SupportLCD; |
21df8fc8 | 418 | |
cc1e2398 AK |
419 | if (pVBInfo->LCDResInfo != Panel1280x1024) { |
420 | if (pVBInfo->LCDResInfo != Panel1280x960) { | |
1d7f656d KT |
421 | if (pVBInfo->LCDInfo & |
422 | LCDNonExpanding) { | |
cc1e2398 AK |
423 | if (resinfo >= 9) { |
424 | tempax = 0; | |
425 | return 0; | |
426 | } | |
427 | } | |
428 | } | |
429 | } | |
21df8fc8 | 430 | } |
21df8fc8 | 431 | |
cc1e2398 | 432 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { /* for HiTV */ |
1d7f656d KT |
433 | if ((pVBInfo->VBType & VB_XGI301LV) && |
434 | (pVBInfo->VBExtInfo == VB_YPbPr1080i)) { | |
cc1e2398 AK |
435 | tempax |= SupportYPbPr; |
436 | if (pVBInfo->VBInfo & SetInSlaveMode) { | |
437 | if (resinfo == 4) | |
438 | return 0; | |
21df8fc8 | 439 | |
cc1e2398 AK |
440 | if (resinfo == 3) |
441 | return 0; | |
21df8fc8 | 442 | |
cc1e2398 AK |
443 | if (resinfo > 7) |
444 | return 0; | |
445 | } | |
446 | } else { | |
447 | tempax |= SupportHiVisionTV; | |
448 | if (pVBInfo->VBInfo & SetInSlaveMode) { | |
449 | if (resinfo == 4) | |
450 | return 0; | |
21df8fc8 | 451 | |
cc1e2398 AK |
452 | if (resinfo == 3) { |
453 | if (pVBInfo->SetFlag | |
454 | & TVSimuMode) | |
455 | return 0; | |
456 | } | |
21df8fc8 | 457 | |
cc1e2398 AK |
458 | if (resinfo > 7) |
459 | return 0; | |
460 | } | |
21df8fc8 | 461 | } |
cc1e2398 | 462 | } else { |
1d7f656d KT |
463 | if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO | |
464 | SetCRT2ToSVIDEO | | |
465 | SetCRT2ToSCART | | |
466 | SetCRT2ToYPbPr | | |
467 | SetCRT2ToHiVisionTV)) { | |
cc1e2398 | 468 | tempax |= SupportTV; |
21df8fc8 | 469 | |
cc1e2398 AK |
470 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B |
471 | | VB_XGI301LV | VB_XGI302LV | |
472 | | VB_XGI301C)) { | |
473 | tempax |= SupportTV1024; | |
474 | } | |
21df8fc8 | 475 | |
cc1e2398 AK |
476 | if (!(pVBInfo->VBInfo & SetPALTV)) { |
477 | if (modeflag & NoSupportSimuTV) { | |
1d7f656d KT |
478 | if (pVBInfo->VBInfo & |
479 | SetInSlaveMode) { | |
480 | if (!(pVBInfo->VBInfo & | |
481 | SetNotSimuMode)) { | |
cc1e2398 AK |
482 | return 0; |
483 | } | |
484 | } | |
485 | } | |
486 | } | |
487 | } | |
488 | } | |
489 | } else { /* for LVDS */ | |
490 | if (pVBInfo->IF_DEF_CH7005 == 1) { | |
491 | if (pVBInfo->VBInfo & SetCRT2ToTV) | |
492 | tempax |= SupportCHTV; | |
493 | } | |
21df8fc8 | 494 | |
cc1e2398 AK |
495 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
496 | tempax |= SupportLCD; | |
d7636e0b | 497 | |
cc1e2398 AK |
498 | if (resinfo > 0x08) |
499 | return 0; /* 1024x768 */ | |
d7636e0b | 500 | |
cc1e2398 AK |
501 | if (pVBInfo->LCDResInfo < Panel1024x768) { |
502 | if (resinfo > 0x07) | |
503 | return 0; /* 800x600 */ | |
d7636e0b | 504 | |
cc1e2398 AK |
505 | if (resinfo == 0x04) |
506 | return 0; /* 512x384 */ | |
507 | } | |
508 | } | |
509 | } | |
21df8fc8 | 510 | |
1d7f656d KT |
511 | for (; pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID == |
512 | tempbx; (*i)--) { | |
513 | infoflag = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)]. | |
514 | Ext_InfoFlag; | |
cc1e2398 AK |
515 | if (infoflag & tempax) |
516 | return 1; | |
21df8fc8 | 517 | |
cc1e2398 AK |
518 | if ((*i) == 0) |
519 | break; | |
21df8fc8 | 520 | } |
d7636e0b | 521 | |
cc1e2398 | 522 | for ((*i) = 0;; (*i)++) { |
1d7f656d KT |
523 | infoflag = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)]. |
524 | Ext_InfoFlag; | |
cc1e2398 AK |
525 | if (pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID |
526 | != tempbx) { | |
527 | return 0; | |
528 | } | |
d7636e0b | 529 | |
cc1e2398 AK |
530 | if (infoflag & tempax) |
531 | return 1; | |
21df8fc8 | 532 | } |
cc1e2398 | 533 | return 1; |
d7636e0b | 534 | } |
535 | ||
cc1e2398 | 536 | static void XGI_SetSync(unsigned short RefreshRateTableIndex, |
21df8fc8 | 537 | struct vb_device_info *pVBInfo) |
d7636e0b | 538 | { |
cc1e2398 | 539 | unsigned short sync, temp; |
d7636e0b | 540 | |
1d7f656d KT |
541 | /* di+0x00 */ |
542 | sync = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag >> 8; | |
cc1e2398 AK |
543 | sync &= 0xC0; |
544 | temp = 0x2F; | |
545 | temp |= sync; | |
efdf4ee7 | 546 | outb(temp, pVBInfo->P3c2); /* Set Misc(3c2) */ |
d7636e0b | 547 | } |
548 | ||
cc1e2398 AK |
549 | static void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo, |
550 | struct xgi_hw_device_info *HwDeviceExtension) | |
d7636e0b | 551 | { |
cc1e2398 AK |
552 | unsigned char data, data1, pushax; |
553 | unsigned short i, j; | |
d7636e0b | 554 | |
8104e329 AK |
555 | /* xgifb_reg_set(pVBInfo->P3d4, 0x51, 0); */ |
556 | /* xgifb_reg_set(pVBInfo->P3d4, 0x56, 0); */ | |
ec9e5d3e | 557 | /* xgifb_reg_and_or(pVBInfo->P3d4, 0x11, 0x7f, 0x00); */ |
d7636e0b | 558 | |
1d7f656d KT |
559 | /* unlock cr0-7 */ |
560 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); | |
cc1e2398 | 561 | data &= 0x7F; |
8104e329 | 562 | xgifb_reg_set(pVBInfo->P3d4, 0x11, data); |
cc1e2398 AK |
563 | |
564 | data = pVBInfo->TimingH[0].data[0]; | |
8104e329 | 565 | xgifb_reg_set(pVBInfo->P3d4, 0, data); |
cc1e2398 AK |
566 | |
567 | for (i = 0x01; i <= 0x04; i++) { | |
568 | data = pVBInfo->TimingH[0].data[i]; | |
8104e329 | 569 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 1), data); |
21df8fc8 | 570 | } |
d7636e0b | 571 | |
cc1e2398 AK |
572 | for (i = 0x05; i <= 0x06; i++) { |
573 | data = pVBInfo->TimingH[0].data[i]; | |
8104e329 | 574 | xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i + 6), data); |
cc1e2398 | 575 | } |
d7636e0b | 576 | |
58839b01 | 577 | j = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0e); |
cc1e2398 AK |
578 | j &= 0x1F; |
579 | data = pVBInfo->TimingH[0].data[7]; | |
580 | data &= 0xE0; | |
581 | data |= j; | |
8104e329 | 582 | xgifb_reg_set(pVBInfo->P3c4, 0x0e, data); |
21df8fc8 | 583 | |
cc1e2398 | 584 | if (HwDeviceExtension->jChipType >= XG20) { |
58839b01 | 585 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x04); |
cc1e2398 | 586 | data = data - 1; |
8104e329 | 587 | xgifb_reg_set(pVBInfo->P3d4, 0x04, data); |
58839b01 | 588 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x05); |
cc1e2398 AK |
589 | data1 = data; |
590 | data1 &= 0xE0; | |
591 | data &= 0x1F; | |
592 | if (data == 0) { | |
593 | pushax = data; | |
58839b01 | 594 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, |
cc1e2398 AK |
595 | 0x0c); |
596 | data &= 0xFB; | |
8104e329 | 597 | xgifb_reg_set(pVBInfo->P3c4, 0x0c, data); |
cc1e2398 | 598 | data = pushax; |
21df8fc8 | 599 | } |
cc1e2398 AK |
600 | data = data - 1; |
601 | data |= data1; | |
8104e329 | 602 | xgifb_reg_set(pVBInfo->P3d4, 0x05, data); |
58839b01 | 603 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0e); |
cc1e2398 AK |
604 | data = data >> 5; |
605 | data = data + 3; | |
606 | if (data > 7) | |
607 | data = data - 7; | |
608 | data = data << 5; | |
ec9e5d3e | 609 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0e, ~0xE0, data); |
21df8fc8 | 610 | } |
21df8fc8 PS |
611 | } |
612 | ||
1d7f656d KT |
613 | static void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex, |
614 | unsigned short ModeNo, | |
615 | struct vb_device_info *pVBInfo) | |
d7636e0b | 616 | { |
cc1e2398 AK |
617 | unsigned char data; |
618 | unsigned short i, j; | |
d7636e0b | 619 | |
8104e329 AK |
620 | /* xgifb_reg_set(pVBInfo->P3d4, 0x51, 0); */ |
621 | /* xgifb_reg_set(pVBInfo->P3d4, 0x56, 0); */ | |
ec9e5d3e | 622 | /* xgifb_reg_and_or(pVBInfo->P3d4, 0x11, 0x7f, 0x00); */ |
cc1e2398 AK |
623 | |
624 | for (i = 0x00; i <= 0x01; i++) { | |
625 | data = pVBInfo->TimingV[0].data[i]; | |
8104e329 | 626 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 6), data); |
21df8fc8 | 627 | } |
d7636e0b | 628 | |
cc1e2398 AK |
629 | for (i = 0x02; i <= 0x03; i++) { |
630 | data = pVBInfo->TimingV[0].data[i]; | |
8104e329 | 631 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x0e), data); |
21df8fc8 | 632 | } |
d7636e0b | 633 | |
cc1e2398 AK |
634 | for (i = 0x04; i <= 0x05; i++) { |
635 | data = pVBInfo->TimingV[0].data[i]; | |
8104e329 | 636 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 0x11), data); |
cc1e2398 | 637 | } |
d7636e0b | 638 | |
58839b01 | 639 | j = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x0a); |
cc1e2398 AK |
640 | j &= 0xC0; |
641 | data = pVBInfo->TimingV[0].data[6]; | |
642 | data &= 0x3F; | |
643 | data |= j; | |
8104e329 | 644 | xgifb_reg_set(pVBInfo->P3c4, 0x0a, data); |
d7636e0b | 645 | |
cc1e2398 AK |
646 | data = pVBInfo->TimingV[0].data[6]; |
647 | data &= 0x80; | |
648 | data = data >> 2; | |
d7636e0b | 649 | |
cc1e2398 AK |
650 | if (ModeNo <= 0x13) |
651 | i = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
652 | else | |
653 | i = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
d7636e0b | 654 | |
cc1e2398 AK |
655 | i &= DoubleScanMode; |
656 | if (i) | |
657 | data |= 0x80; | |
d7636e0b | 658 | |
58839b01 | 659 | j = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x09); |
cc1e2398 AK |
660 | j &= 0x5F; |
661 | data |= j; | |
8104e329 | 662 | xgifb_reg_set(pVBInfo->P3d4, 0x09, data); |
d7636e0b | 663 | } |
664 | ||
cc1e2398 AK |
665 | static void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, |
666 | unsigned short RefreshRateTableIndex, | |
667 | struct vb_device_info *pVBInfo, | |
668 | struct xgi_hw_device_info *HwDeviceExtension) | |
21df8fc8 | 669 | { |
cc1e2398 AK |
670 | unsigned char index, data; |
671 | unsigned short i; | |
21df8fc8 | 672 | |
1d7f656d KT |
673 | /* Get index */ |
674 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; | |
cc1e2398 | 675 | index = index & IndexMask; |
21df8fc8 | 676 | |
58839b01 | 677 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
cc1e2398 | 678 | data &= 0x7F; |
8104e329 | 679 | xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */ |
21df8fc8 | 680 | |
cc1e2398 AK |
681 | for (i = 0; i < 8; i++) |
682 | pVBInfo->TimingH[0].data[i] | |
683 | = pVBInfo->XGINEWUB_CRT1Table[index].CR[i]; | |
21df8fc8 | 684 | |
cc1e2398 AK |
685 | for (i = 0; i < 7; i++) |
686 | pVBInfo->TimingV[0].data[i] | |
687 | = pVBInfo->XGINEWUB_CRT1Table[index].CR[i + 8]; | |
21df8fc8 | 688 | |
cc1e2398 | 689 | XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension); |
21df8fc8 | 690 | |
cc1e2398 | 691 | XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo); |
21df8fc8 | 692 | |
cc1e2398 | 693 | if (pVBInfo->ModeType > 0x03) |
8104e329 | 694 | xgifb_reg_set(pVBInfo->P3d4, 0x14, 0x4F); |
21df8fc8 PS |
695 | } |
696 | ||
cc1e2398 AK |
697 | /* --------------------------------------------------------------------- */ |
698 | /* Function : XGI_SetXG21CRTC */ | |
699 | /* Input : Stand or enhance CRTC table */ | |
700 | /* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */ | |
701 | /* Description : Set LCD timing */ | |
702 | /* --------------------------------------------------------------------- */ | |
703 | static void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, | |
704 | unsigned short RefreshRateTableIndex, | |
21df8fc8 | 705 | struct vb_device_info *pVBInfo) |
d7636e0b | 706 | { |
cc1e2398 AK |
707 | unsigned char StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx; |
708 | unsigned short Temp1, Temp2, Temp3; | |
21df8fc8 | 709 | |
cc1e2398 AK |
710 | if (ModeNo <= 0x13) { |
711 | StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo); | |
1d7f656d KT |
712 | /* CR04 HRS */ |
713 | Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[4]; | |
714 | /* SR2E [7:0]->HRS */ | |
715 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); | |
716 | /* Tempbx: CR05 HRE */ | |
717 | Tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[5]; | |
cc1e2398 AK |
718 | Tempbx &= 0x1F; /* Tempbx: HRE[4:0] */ |
719 | Tempcx = Tempax; | |
720 | Tempcx &= 0xE0; /* Tempcx: HRS[7:5] */ | |
721 | Tempdx = Tempcx | Tempbx; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */ | |
722 | if (Tempbx < (Tempax & 0x1F)) /* IF HRE < HRS */ | |
723 | Tempdx |= 0x20; /* Tempdx: HRE = HRE + 0x20 */ | |
724 | Tempdx <<= 2; /* Tempdx << 2 */ | |
1d7f656d KT |
725 | /* SR2F [7:2]->HRE */ |
726 | xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempdx); | |
ec9e5d3e | 727 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00); |
21df8fc8 | 728 | |
1d7f656d KT |
729 | /* Tempax: CR16 VRS */ |
730 | Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[16]; | |
cc1e2398 AK |
731 | Tempbx = Tempax; /* Tempbx=Tempax */ |
732 | Tempax &= 0x01; /* Tempax: VRS[0] */ | |
b9bf6e4e | 733 | xgifb_reg_or(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS */ |
1d7f656d KT |
734 | |
735 | /* Tempax: CR7 VRS */ | |
736 | Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[7]; | |
cc1e2398 AK |
737 | Tempdx = Tempbx >> 1; /* Tempdx: VRS[7:1] */ |
738 | Tempcx = Tempax & 0x04; /* Tempcx: CR7[2] */ | |
739 | Tempcx <<= 5; /* Tempcx[7]: VRS[8] */ | |
740 | Tempdx |= Tempcx; /* Tempdx: VRS[8:1] */ | |
1d7f656d KT |
741 | /* SR34[7:0]: VRS[8:1] */ |
742 | xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempdx); | |
21df8fc8 | 743 | |
1d7f656d KT |
744 | /* Temp1[8]: VRS[8] unsigned char -> unsigned short */ |
745 | Temp1 = Tempcx << 1; | |
cc1e2398 AK |
746 | Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */ |
747 | Tempax &= 0x80; /* Tempax[7]: CR7[7] */ | |
748 | Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */ | |
749 | Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */ | |
21df8fc8 | 750 | |
1d7f656d KT |
751 | /* CR16 VRE */ |
752 | Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[17]; | |
cc1e2398 AK |
753 | Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */ |
754 | Temp2 = Temp1 & 0x3F0; /* Temp2[9:4]: VRS[9:4] */ | |
755 | Temp2 |= Tempax; /* Temp2[9:0]: VRE[9:0] */ | |
756 | Temp3 = Temp1 & 0x0F; /* Temp3[3:0]: VRS[3:0] */ | |
757 | if (Tempax < Temp3) /* VRE[3:0]<VRS[3:0] */ | |
758 | Temp2 |= 0x10; /* Temp2: VRE + 0x10 */ | |
759 | Temp2 &= 0xFF; /* Temp2[7:0]: VRE[7:0] */ | |
760 | Tempax = (unsigned char) Temp2; /* Tempax[7:0]: VRE[7:0] */ | |
761 | Tempax <<= 2; /* Tempax << 2: VRE[5:0] */ | |
762 | Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */ | |
763 | Temp1 >>= 9; /* [10:9]->[1:0] */ | |
764 | Tempbx = (unsigned char) Temp1; /* Tempbx[1:0]: VRS[10:9] */ | |
765 | Tempax |= Tempbx; /* VRE[5:0]VRS[10:9] */ | |
766 | Tempax &= 0x7F; | |
1d7f656d KT |
767 | /* SR3F D[7:2]->VRE D[1:0]->VRS */ |
768 | xgifb_reg_set(pVBInfo->P3c4, 0x3F, Tempax); | |
cc1e2398 AK |
769 | } else { |
770 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; | |
1d7f656d KT |
771 | /* Tempax: CR4 HRS */ |
772 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3]; | |
cc1e2398 | 773 | Tempcx = Tempax; /* Tempcx: HRS */ |
1d7f656d KT |
774 | /* SR2E[7:0]->HRS */ |
775 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); | |
21df8fc8 | 776 | |
cc1e2398 AK |
777 | Tempdx = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SRB */ |
778 | Tempdx &= 0xC0; /* Tempdx[7:6]: SRB[7:6] */ | |
779 | Temp1 = Tempdx; /* Temp1[7:6]: HRS[9:8] */ | |
780 | Temp1 <<= 2; /* Temp1[9:8]: HRS[9:8] */ | |
781 | Temp1 |= Tempax; /* Temp1[9:0]: HRS[9:0] */ | |
21df8fc8 | 782 | |
cc1e2398 AK |
783 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */ |
784 | Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */ | |
21df8fc8 | 785 | |
cc1e2398 AK |
786 | Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[6]; /* SRC */ |
787 | Tempbx &= 0x04; /* Tempbx[2]: HRE[5] */ | |
788 | Tempbx <<= 3; /* Tempbx[5]: HRE[5] */ | |
789 | Tempax |= Tempbx; /* Tempax[5:0]: HRE[5:0] */ | |
21df8fc8 | 790 | |
cc1e2398 AK |
791 | Temp2 = Temp1 & 0x3C0; /* Temp2[9:6]: HRS[9:6] */ |
792 | Temp2 |= Tempax; /* Temp2[9:0]: HRE[9:0] */ | |
21df8fc8 | 793 | |
cc1e2398 AK |
794 | Tempcx &= 0x3F; /* Tempcx[5:0]: HRS[5:0] */ |
795 | if (Tempax < Tempcx) /* HRE < HRS */ | |
796 | Temp2 |= 0x40; /* Temp2 + 0x40 */ | |
21df8fc8 | 797 | |
cc1e2398 AK |
798 | Temp2 &= 0xFF; |
799 | Tempax = (unsigned char) Temp2; /* Tempax: HRE[7:0] */ | |
800 | Tempax <<= 2; /* Tempax[7:2]: HRE[5:0] */ | |
801 | Tempdx >>= 6; /* Tempdx[7:6]->[1:0] HRS[9:8] */ | |
802 | Tempax |= Tempdx; /* HRE[5:0]HRS[9:8] */ | |
1d7f656d KT |
803 | /* SR2F D[7:2]->HRE, D[1:0]->HRS */ |
804 | xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax); | |
ec9e5d3e | 805 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00); |
21df8fc8 | 806 | |
1d7f656d KT |
807 | /* CR10 VRS */ |
808 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10]; | |
cc1e2398 AK |
809 | Tempbx = Tempax; /* Tempbx: VRS */ |
810 | Tempax &= 0x01; /* Tempax[0]: VRS[0] */ | |
b9bf6e4e | 811 | xgifb_reg_or(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS[0] */ |
1d7f656d KT |
812 | /* CR7[2][7] VRE */ |
813 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9]; | |
cc1e2398 AK |
814 | Tempcx = Tempbx >> 1; /* Tempcx[6:0]: VRS[7:1] */ |
815 | Tempdx = Tempax & 0x04; /* Tempdx[2]: CR7[2] */ | |
816 | Tempdx <<= 5; /* Tempdx[7]: VRS[8] */ | |
817 | Tempcx |= Tempdx; /* Tempcx[7:0]: VRS[8:1] */ | |
8104e329 | 818 | xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempcx); /* SR34[8:1]->VRS */ |
21df8fc8 | 819 | |
cc1e2398 AK |
820 | Temp1 = Tempdx; /* Temp1[7]: Tempdx[7] */ |
821 | Temp1 <<= 1; /* Temp1[8]: VRS[8] */ | |
822 | Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */ | |
823 | Tempax &= 0x80; | |
824 | Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */ | |
825 | Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */ | |
1d7f656d KT |
826 | /* Tempax: SRA */ |
827 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; | |
cc1e2398 AK |
828 | Tempax &= 0x08; /* Tempax[3]: VRS[3] */ |
829 | Temp2 = Tempax; | |
830 | Temp2 <<= 7; /* Temp2[10]: VRS[10] */ | |
831 | Temp1 |= Temp2; /* Temp1[10:0]: VRS[10:0] */ | |
21df8fc8 | 832 | |
1d7f656d KT |
833 | /* Tempax: CR11 VRE */ |
834 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11]; | |
cc1e2398 | 835 | Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */ |
1d7f656d KT |
836 | /* Tempbx: SRA */ |
837 | Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; | |
cc1e2398 AK |
838 | Tempbx &= 0x20; /* Tempbx[5]: VRE[5] */ |
839 | Tempbx >>= 1; /* Tempbx[4]: VRE[4] */ | |
840 | Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */ | |
841 | Temp2 = Temp1 & 0x7E0; /* Temp2[10:5]: VRS[10:5] */ | |
842 | Temp2 |= Tempax; /* Temp2[10:5]: VRE[10:5] */ | |
21df8fc8 | 843 | |
cc1e2398 AK |
844 | Temp3 = Temp1 & 0x1F; /* Temp3[4:0]: VRS[4:0] */ |
845 | if (Tempax < Temp3) /* VRE < VRS */ | |
846 | Temp2 |= 0x20; /* VRE + 0x20 */ | |
d7636e0b | 847 | |
cc1e2398 AK |
848 | Temp2 &= 0xFF; |
849 | Tempax = (unsigned char) Temp2; /* Tempax: VRE[7:0] */ | |
850 | Tempax <<= 2; /* Tempax[7:0]; VRE[5:0]00 */ | |
851 | Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */ | |
852 | Temp1 >>= 9; /* Temp1[1:0]: VRS[10:9] */ | |
853 | Tempbx = (unsigned char) Temp1; | |
854 | Tempax |= Tempbx; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */ | |
855 | Tempax &= 0x7F; | |
1d7f656d KT |
856 | /* SR3F D[7:2]->VRE D[1:0]->VRS */ |
857 | xgifb_reg_set(pVBInfo->P3c4, 0x3F, Tempax); | |
21df8fc8 | 858 | } |
d7636e0b | 859 | } |
860 | ||
1d7f656d KT |
861 | static void XGI_SetXG27CRTC(unsigned short ModeNo, |
862 | unsigned short ModeIdIndex, | |
863 | unsigned short RefreshRateTableIndex, | |
864 | struct vb_device_info *pVBInfo) | |
21df8fc8 | 865 | { |
cc1e2398 | 866 | unsigned short StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx; |
21df8fc8 | 867 | |
cc1e2398 AK |
868 | if (ModeNo <= 0x13) { |
869 | StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo); | |
1d7f656d KT |
870 | /* CR04 HRS */ |
871 | Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[4]; | |
872 | /* SR2E [7:0]->HRS */ | |
873 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); | |
874 | /* Tempbx: CR05 HRE */ | |
875 | Tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[5]; | |
cc1e2398 AK |
876 | Tempbx &= 0x1F; /* Tempbx: HRE[4:0] */ |
877 | Tempcx = Tempax; | |
878 | Tempcx &= 0xE0; /* Tempcx: HRS[7:5] */ | |
879 | Tempdx = Tempcx | Tempbx; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */ | |
880 | if (Tempbx < (Tempax & 0x1F)) /* IF HRE < HRS */ | |
881 | Tempdx |= 0x20; /* Tempdx: HRE = HRE + 0x20 */ | |
882 | Tempdx <<= 2; /* Tempdx << 2 */ | |
1d7f656d KT |
883 | /* SR2F [7:2]->HRE */ |
884 | xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempdx); | |
ec9e5d3e | 885 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00); |
d7636e0b | 886 | |
1d7f656d KT |
887 | /* Tempax: CR10 VRS */ |
888 | Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[16]; | |
8104e329 | 889 | xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempax); /* SR34[7:0]->VRS */ |
cc1e2398 | 890 | Tempcx = Tempax; /* Tempcx=Tempax=VRS[7:0] */ |
1d7f656d KT |
891 | /* Tempax[7][2]: CR7[7][2] VRS[9][8] */ |
892 | Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[7]; | |
cc1e2398 AK |
893 | Tempbx = Tempax; /* Tempbx=CR07 */ |
894 | Tempax &= 0x04; /* Tempax[2]: CR07[2] VRS[8] */ | |
895 | Tempax >>= 2; | |
1d7f656d KT |
896 | /* SR35 D[0]->VRS D[8] */ |
897 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x01, Tempax); | |
cc1e2398 AK |
898 | Tempcx |= (Tempax << 8); /* Tempcx[8] |= VRS[8] */ |
899 | Tempcx |= (Tempbx & 0x80) << 2; /* Tempcx[9] |= VRS[9] */ | |
d7636e0b | 900 | |
1d7f656d KT |
901 | /* CR11 VRE */ |
902 | Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[17]; | |
cc1e2398 AK |
903 | Tempax &= 0x0F; /* Tempax: VRE[3:0] */ |
904 | Tempbx = Tempcx; /* Tempbx=Tempcx=VRS[9:0] */ | |
905 | Tempbx &= 0x3F0; /* Tempbx[9:4]: VRS[9:4] */ | |
906 | Tempbx |= Tempax; /* Tempbx[9:0]: VRE[9:0] */ | |
907 | if (Tempax <= (Tempcx & 0x0F)) /* VRE[3:0]<=VRS[3:0] */ | |
908 | Tempbx |= 0x10; /* Tempbx: VRE + 0x10 */ | |
1d7f656d KT |
909 | /* Tempax[7:0]: VRE[7:0] */ |
910 | Tempax = (unsigned char) Tempbx & 0xFF; | |
cc1e2398 AK |
911 | Tempax <<= 2; /* Tempax << 2: VRE[5:0] */ |
912 | Tempcx = (Tempcx & 0x600) >> 8; /* Tempcx VRS[10:9] */ | |
1d7f656d KT |
913 | /* SR3F D[7:2]->VRE D[5:0] */ |
914 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax); | |
915 | /* SR35 D[2:1]->VRS[10:9] */ | |
916 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x06, Tempcx); | |
cc1e2398 AK |
917 | } else { |
918 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; | |
1d7f656d KT |
919 | /* Tempax: CR4 HRS */ |
920 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3]; | |
cc1e2398 | 921 | Tempbx = Tempax; /* Tempbx: HRS[7:0] */ |
1d7f656d KT |
922 | /* SR2E[7:0]->HRS */ |
923 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax); | |
d7636e0b | 924 | |
1d7f656d KT |
925 | /* SR0B */ |
926 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; | |
cc1e2398 AK |
927 | Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/ |
928 | Tempbx |= (Tempax << 2); /* Tempbx: HRS[9:0] */ | |
d7636e0b | 929 | |
cc1e2398 AK |
930 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */ |
931 | Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */ | |
932 | Tempcx = Tempax; /* Tempcx: HRE[4:0] */ | |
d7636e0b | 933 | |
cc1e2398 AK |
934 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[6]; /* SRC */ |
935 | Tempax &= 0x04; /* Tempax[2]: HRE[5] */ | |
936 | Tempax <<= 3; /* Tempax[5]: HRE[5] */ | |
937 | Tempcx |= Tempax; /* Tempcx[5:0]: HRE[5:0] */ | |
d7636e0b | 938 | |
cc1e2398 AK |
939 | Tempbx = Tempbx & 0x3C0; /* Tempbx[9:6]: HRS[9:6] */ |
940 | Tempbx |= Tempcx; /* Tempbx: HRS[9:6]HRE[5:0] */ | |
d7636e0b | 941 | |
1d7f656d KT |
942 | /* Tempax: CR4 HRS */ |
943 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3]; | |
cc1e2398 AK |
944 | Tempax &= 0x3F; /* Tempax: HRS[5:0] */ |
945 | if (Tempcx <= Tempax) /* HRE[5:0] < HRS[5:0] */ | |
946 | Tempbx += 0x40; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/ | |
d7636e0b | 947 | |
cc1e2398 AK |
948 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SR0B */ |
949 | Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/ | |
950 | Tempax >>= 6; /* Tempax[1:0]: HRS[9:8]*/ | |
951 | Tempax |= ((Tempbx << 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */ | |
1d7f656d KT |
952 | /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */ |
953 | xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax); | |
ec9e5d3e | 954 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00); |
d7636e0b | 955 | |
1d7f656d KT |
956 | /* CR10 VRS */ |
957 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10]; | |
958 | /* SR34[7:0]->VRS[7:0] */ | |
959 | xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempax); | |
d7636e0b | 960 | |
cc1e2398 | 961 | Tempcx = Tempax; /* Tempcx <= VRS[7:0] */ |
1d7f656d KT |
962 | /* CR7[7][2] VRS[9][8] */ |
963 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9]; | |
cc1e2398 AK |
964 | Tempbx = Tempax; /* Tempbx <= CR07[7:0] */ |
965 | Tempax = Tempax & 0x04; /* Tempax[2]: CR7[2]: VRS[8] */ | |
966 | Tempax >>= 2; /* Tempax[0]: VRS[8] */ | |
1d7f656d KT |
967 | /* SR35[0]: VRS[8] */ |
968 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x01, Tempax); | |
cc1e2398 AK |
969 | Tempcx |= (Tempax << 8); /* Tempcx <= VRS[8:0] */ |
970 | Tempcx |= ((Tempbx & 0x80) << 2); /* Tempcx <= VRS[9:0] */ | |
1d7f656d KT |
971 | /* Tempax: SR0A */ |
972 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; | |
cc1e2398 AK |
973 | Tempax &= 0x08; /* SR0A[3] VRS[10] */ |
974 | Tempcx |= (Tempax << 7); /* Tempcx <= VRS[10:0] */ | |
d7636e0b | 975 | |
1d7f656d KT |
976 | /* Tempax: CR11 VRE */ |
977 | Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11]; | |
cc1e2398 | 978 | Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */ |
1d7f656d KT |
979 | /* Tempbx: SR0A */ |
980 | Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14]; | |
cc1e2398 AK |
981 | Tempbx &= 0x20; /* Tempbx[5]: SR0A[5]: VRE[4] */ |
982 | Tempbx >>= 1; /* Tempbx[4]: VRE[4] */ | |
983 | Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */ | |
984 | Tempbx = Tempcx; /* Tempbx: VRS[10:0] */ | |
985 | Tempbx &= 0x7E0; /* Tempbx[10:5]: VRS[10:5] */ | |
986 | Tempbx |= Tempax; /* Tempbx: VRS[10:5]VRE[4:0] */ | |
d7636e0b | 987 | |
cc1e2398 AK |
988 | if (Tempbx <= Tempcx) /* VRE <= VRS */ |
989 | Tempbx |= 0x20; /* VRE + 0x20 */ | |
d7636e0b | 990 | |
1d7f656d KT |
991 | /* Tempax: Tempax[7:0]; VRE[5:0]00 */ |
992 | Tempax = (Tempbx << 2) & 0xFF; | |
993 | /* SR3F[7:2]:VRE[5:0] */ | |
994 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax); | |
cc1e2398 | 995 | Tempax = Tempcx >> 8; |
1d7f656d KT |
996 | /* SR35[2:0]:VRS[10:8] */ |
997 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, Tempax); | |
21df8fc8 | 998 | } |
cc1e2398 | 999 | } |
d7636e0b | 1000 | |
cc1e2398 AK |
1001 | /* --------------------------------------------------------------------- */ |
1002 | /* Function : XGI_SetXG21LCD */ | |
1003 | /* Input : */ | |
1004 | /* Output : FCLK duty cycle, FCLK delay compensation */ | |
1005 | /* Description : All values set zero */ | |
1006 | /* --------------------------------------------------------------------- */ | |
1007 | static void XGI_SetXG21LCD(struct vb_device_info *pVBInfo, | |
1008 | unsigned short RefreshRateTableIndex, unsigned short ModeNo) | |
1009 | { | |
1010 | unsigned short Data, Temp, b3CC; | |
1011 | unsigned short XGI_P3cc; | |
1012 | ||
1013 | XGI_P3cc = pVBInfo->P3cc; | |
1014 | ||
8104e329 AK |
1015 | xgifb_reg_set(pVBInfo->P3d4, 0x2E, 0x00); |
1016 | xgifb_reg_set(pVBInfo->P3d4, 0x2F, 0x00); | |
1017 | xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x00); | |
1018 | xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x00); | |
cc1e2398 | 1019 | if (((*pVBInfo->pDVOSetting) & 0xC0) == 0xC0) { |
8104e329 AK |
1020 | xgifb_reg_set(pVBInfo->P3d4, 0x2E, *pVBInfo->pCR2E); |
1021 | xgifb_reg_set(pVBInfo->P3d4, 0x2F, *pVBInfo->pCR2F); | |
1022 | xgifb_reg_set(pVBInfo->P3d4, 0x46, *pVBInfo->pCR46); | |
1023 | xgifb_reg_set(pVBInfo->P3d4, 0x47, *pVBInfo->pCR47); | |
21df8fc8 | 1024 | } |
d7636e0b | 1025 | |
58839b01 | 1026 | Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
21df8fc8 | 1027 | |
cc1e2398 | 1028 | if (Temp & 0x01) { |
b9bf6e4e AK |
1029 | xgifb_reg_or(pVBInfo->P3c4, 0x06, 0x40); /* 18 bits FP */ |
1030 | xgifb_reg_or(pVBInfo->P3c4, 0x09, 0x40); | |
cc1e2398 AK |
1031 | } |
1032 | ||
b9bf6e4e | 1033 | xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */ |
cc1e2398 | 1034 | |
dc50556b AK |
1035 | xgifb_reg_and(pVBInfo->P3c4, 0x30, ~0x20); |
1036 | xgifb_reg_and(pVBInfo->P3c4, 0x35, ~0x80); | |
cc1e2398 AK |
1037 | |
1038 | if (ModeNo <= 0x13) { | |
d8ad0a6d | 1039 | b3CC = (unsigned char) inb(XGI_P3cc); |
cc1e2398 | 1040 | if (b3CC & 0x40) |
1d7f656d KT |
1041 | /* Hsync polarity */ |
1042 | xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20); | |
cc1e2398 | 1043 | if (b3CC & 0x80) |
1d7f656d KT |
1044 | /* Vsync polarity */ |
1045 | xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80); | |
cc1e2398 AK |
1046 | } else { |
1047 | Data = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; | |
1048 | if (Data & 0x4000) | |
1d7f656d KT |
1049 | /* Hsync polarity */ |
1050 | xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20); | |
cc1e2398 | 1051 | if (Data & 0x8000) |
1d7f656d KT |
1052 | /* Vsync polarity */ |
1053 | xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80); | |
21df8fc8 | 1054 | } |
d7636e0b | 1055 | } |
1056 | ||
cc1e2398 | 1057 | static void XGI_SetXG27LCD(struct vb_device_info *pVBInfo, |
1d7f656d KT |
1058 | unsigned short RefreshRateTableIndex, |
1059 | unsigned short ModeNo) | |
21df8fc8 | 1060 | { |
cc1e2398 AK |
1061 | unsigned short Data, Temp, b3CC; |
1062 | unsigned short XGI_P3cc; | |
21df8fc8 | 1063 | |
cc1e2398 | 1064 | XGI_P3cc = pVBInfo->P3cc; |
21df8fc8 | 1065 | |
8104e329 AK |
1066 | xgifb_reg_set(pVBInfo->P3d4, 0x2E, 0x00); |
1067 | xgifb_reg_set(pVBInfo->P3d4, 0x2F, 0x00); | |
1068 | xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x00); | |
1069 | xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x00); | |
21df8fc8 | 1070 | |
58839b01 | 1071 | Temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
cc1e2398 | 1072 | if ((Temp & 0x03) == 0) { /* dual 12 */ |
8104e329 AK |
1073 | xgifb_reg_set(pVBInfo->P3d4, 0x46, 0x13); |
1074 | xgifb_reg_set(pVBInfo->P3d4, 0x47, 0x13); | |
21df8fc8 PS |
1075 | } |
1076 | ||
cc1e2398 | 1077 | if (((*pVBInfo->pDVOSetting) & 0xC0) == 0xC0) { |
8104e329 AK |
1078 | xgifb_reg_set(pVBInfo->P3d4, 0x2E, *pVBInfo->pCR2E); |
1079 | xgifb_reg_set(pVBInfo->P3d4, 0x2F, *pVBInfo->pCR2F); | |
1080 | xgifb_reg_set(pVBInfo->P3d4, 0x46, *pVBInfo->pCR46); | |
1081 | xgifb_reg_set(pVBInfo->P3d4, 0x47, *pVBInfo->pCR47); | |
21df8fc8 PS |
1082 | } |
1083 | ||
cc1e2398 | 1084 | XGI_SetXG27FPBits(pVBInfo); |
21df8fc8 | 1085 | |
b9bf6e4e | 1086 | xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x01); /* Negative blank polarity */ |
21df8fc8 | 1087 | |
dc50556b AK |
1088 | xgifb_reg_and(pVBInfo->P3c4, 0x30, ~0x20); /* Hsync polarity */ |
1089 | xgifb_reg_and(pVBInfo->P3c4, 0x35, ~0x80); /* Vsync polarity */ | |
21df8fc8 | 1090 | |
cc1e2398 | 1091 | if (ModeNo <= 0x13) { |
d8ad0a6d | 1092 | b3CC = (unsigned char) inb(XGI_P3cc); |
cc1e2398 | 1093 | if (b3CC & 0x40) |
1d7f656d KT |
1094 | /* Hsync polarity */ |
1095 | xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20); | |
cc1e2398 | 1096 | if (b3CC & 0x80) |
1d7f656d KT |
1097 | /* Vsync polarity */ |
1098 | xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80); | |
cc1e2398 AK |
1099 | } else { |
1100 | Data = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; | |
1101 | if (Data & 0x4000) | |
1d7f656d KT |
1102 | /* Hsync polarity */ |
1103 | xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20); | |
cc1e2398 | 1104 | if (Data & 0x8000) |
1d7f656d KT |
1105 | /* Vsync polarity */ |
1106 | xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80); | |
cc1e2398 | 1107 | } |
21df8fc8 | 1108 | } |
d7636e0b | 1109 | |
1110 | /* --------------------------------------------------------------------- */ | |
cc1e2398 AK |
1111 | /* Function : XGI_UpdateXG21CRTC */ |
1112 | /* Input : */ | |
1113 | /* Output : CRT1 CRTC */ | |
1114 | /* Description : Modify CRT1 Hsync/Vsync to fix LCD mode timing */ | |
d7636e0b | 1115 | /* --------------------------------------------------------------------- */ |
1d7f656d KT |
1116 | static void XGI_UpdateXG21CRTC(unsigned short ModeNo, |
1117 | struct vb_device_info *pVBInfo, | |
1118 | unsigned short RefreshRateTableIndex) | |
cc1e2398 AK |
1119 | { |
1120 | int i, index = -1; | |
1121 | ||
dc50556b | 1122 | xgifb_reg_and(pVBInfo->P3d4, 0x11, 0x7F); /* Unlock CR0~7 */ |
cc1e2398 AK |
1123 | if (ModeNo <= 0x13) { |
1124 | for (i = 0; i < 12; i++) { | |
1125 | if (ModeNo == pVBInfo->UpdateCRT1[i].ModeID) | |
1126 | index = i; | |
1127 | } | |
1128 | } else { | |
1d7f656d KT |
1129 | if (ModeNo == 0x2E && |
1130 | (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC == | |
1131 | RES640x480x60)) | |
cc1e2398 | 1132 | index = 12; |
1d7f656d KT |
1133 | else if (ModeNo == 0x2E && |
1134 | (pVBInfo->RefIndex[RefreshRateTableIndex]. | |
1135 | Ext_CRT1CRTC == RES640x480x72)) | |
cc1e2398 AK |
1136 | index = 13; |
1137 | else if (ModeNo == 0x2F) | |
1138 | index = 14; | |
1139 | else if (ModeNo == 0x50) | |
1140 | index = 15; | |
1141 | else if (ModeNo == 0x59) | |
1142 | index = 16; | |
1143 | } | |
1144 | ||
1145 | if (index != -1) { | |
8104e329 | 1146 | xgifb_reg_set(pVBInfo->P3d4, 0x02, |
cc1e2398 | 1147 | pVBInfo->UpdateCRT1[index].CR02); |
8104e329 | 1148 | xgifb_reg_set(pVBInfo->P3d4, 0x03, |
cc1e2398 | 1149 | pVBInfo->UpdateCRT1[index].CR03); |
8104e329 | 1150 | xgifb_reg_set(pVBInfo->P3d4, 0x15, |
cc1e2398 | 1151 | pVBInfo->UpdateCRT1[index].CR15); |
8104e329 | 1152 | xgifb_reg_set(pVBInfo->P3d4, 0x16, |
cc1e2398 AK |
1153 | pVBInfo->UpdateCRT1[index].CR16); |
1154 | } | |
1155 | } | |
1156 | ||
1157 | static void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension, | |
1158 | unsigned short ModeNo, unsigned short ModeIdIndex, | |
21df8fc8 PS |
1159 | unsigned short RefreshRateTableIndex, |
1160 | struct vb_device_info *pVBInfo) | |
1161 | { | |
cc1e2398 AK |
1162 | unsigned short resindex, tempax, tempbx, tempcx, temp, modeflag; |
1163 | ||
1164 | unsigned char data; | |
1165 | ||
1166 | resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); | |
21df8fc8 PS |
1167 | |
1168 | if (ModeNo <= 0x13) { | |
cc1e2398 AK |
1169 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; |
1170 | tempax = pVBInfo->StResInfo[resindex].HTotal; | |
1171 | tempbx = pVBInfo->StResInfo[resindex].VTotal; | |
1172 | } else { | |
1173 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
1174 | tempax = pVBInfo->ModeResInfo[resindex].HTotal; | |
1175 | tempbx = pVBInfo->ModeResInfo[resindex].VTotal; | |
1176 | } | |
21df8fc8 | 1177 | |
cc1e2398 AK |
1178 | if (modeflag & HalfDCLK) |
1179 | tempax = tempax >> 1; | |
21df8fc8 | 1180 | |
cc1e2398 AK |
1181 | if (ModeNo > 0x13) { |
1182 | if (modeflag & HalfDCLK) | |
1183 | tempax = tempax << 1; | |
21df8fc8 | 1184 | |
cc1e2398 | 1185 | temp = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
21df8fc8 | 1186 | |
cc1e2398 AK |
1187 | if (temp & InterlaceMode) |
1188 | tempbx = tempbx >> 1; | |
21df8fc8 | 1189 | |
cc1e2398 AK |
1190 | if (modeflag & DoubleScanMode) |
1191 | tempbx = tempbx << 1; | |
1192 | } | |
21df8fc8 | 1193 | |
cc1e2398 | 1194 | tempcx = 8; |
21df8fc8 | 1195 | |
cc1e2398 AK |
1196 | /* if (!(modeflag & Charx8Dot)) */ |
1197 | /* tempcx = 9; */ | |
21df8fc8 | 1198 | |
cc1e2398 AK |
1199 | tempax /= tempcx; |
1200 | tempax -= 1; | |
1201 | tempbx -= 1; | |
1202 | tempcx = tempax; | |
58839b01 AK |
1203 | temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
1204 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); | |
cc1e2398 | 1205 | data &= 0x7F; |
8104e329 AK |
1206 | xgifb_reg_set(pVBInfo->P3d4, 0x11, data); /* Unlock CRTC */ |
1207 | xgifb_reg_set(pVBInfo->P3d4, 0x01, (unsigned short) (tempcx & 0xff)); | |
ec9e5d3e | 1208 | xgifb_reg_and_or(pVBInfo->P3d4, 0x0b, ~0x0c, |
cc1e2398 | 1209 | (unsigned short) ((tempcx & 0x0ff00) >> 10)); |
8104e329 | 1210 | xgifb_reg_set(pVBInfo->P3d4, 0x12, (unsigned short) (tempbx & 0xff)); |
cc1e2398 AK |
1211 | tempax = 0; |
1212 | tempbx = tempbx >> 8; | |
21df8fc8 | 1213 | |
cc1e2398 AK |
1214 | if (tempbx & 0x01) |
1215 | tempax |= 0x02; | |
21df8fc8 | 1216 | |
cc1e2398 AK |
1217 | if (tempbx & 0x02) |
1218 | tempax |= 0x40; | |
21df8fc8 | 1219 | |
ec9e5d3e | 1220 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x42, tempax); |
58839b01 | 1221 | data = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x07); |
cc1e2398 AK |
1222 | data &= 0xFF; |
1223 | tempax = 0; | |
21df8fc8 | 1224 | |
cc1e2398 AK |
1225 | if (tempbx & 0x04) |
1226 | tempax |= 0x02; | |
21df8fc8 | 1227 | |
ec9e5d3e | 1228 | xgifb_reg_and_or(pVBInfo->P3d4, 0x0a, ~0x02, tempax); |
8104e329 | 1229 | xgifb_reg_set(pVBInfo->P3d4, 0x11, temp); |
cc1e2398 | 1230 | } |
21df8fc8 | 1231 | |
cc1e2398 AK |
1232 | unsigned short XGI_GetResInfo(unsigned short ModeNo, |
1233 | unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) | |
1234 | { | |
1235 | unsigned short resindex; | |
1236 | ||
1237 | if (ModeNo <= 0x13) | |
1d7f656d KT |
1238 | /* si+St_ResInfo */ |
1239 | resindex = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; | |
cc1e2398 | 1240 | else |
1d7f656d KT |
1241 | /* si+Ext_ResInfo */ |
1242 | resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; | |
cc1e2398 | 1243 | return resindex; |
d7636e0b | 1244 | } |
1245 | ||
1d7f656d KT |
1246 | static void XGI_SetCRT1Offset(unsigned short ModeNo, |
1247 | unsigned short ModeIdIndex, | |
1248 | unsigned short RefreshRateTableIndex, | |
1249 | struct xgi_hw_device_info *HwDeviceExtension, | |
1250 | struct vb_device_info *pVBInfo) | |
d7636e0b | 1251 | { |
cc1e2398 | 1252 | unsigned short temp, ah, al, temp2, i, DisplayUnit; |
21df8fc8 | 1253 | |
cc1e2398 AK |
1254 | /* GetOffset */ |
1255 | temp = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo; | |
1256 | temp = temp >> 8; | |
1257 | temp = pVBInfo->ScreenOffset[temp]; | |
21df8fc8 | 1258 | |
cc1e2398 AK |
1259 | temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; |
1260 | temp2 &= InterlaceMode; | |
21df8fc8 | 1261 | |
cc1e2398 AK |
1262 | if (temp2) |
1263 | temp = temp << 1; | |
21df8fc8 | 1264 | |
cc1e2398 | 1265 | temp2 = pVBInfo->ModeType - ModeEGA; |
21df8fc8 | 1266 | |
cc1e2398 AK |
1267 | switch (temp2) { |
1268 | case 0: | |
1269 | temp2 = 1; | |
1270 | break; | |
1271 | case 1: | |
1272 | temp2 = 2; | |
1273 | break; | |
1274 | case 2: | |
1275 | temp2 = 4; | |
1276 | break; | |
1277 | case 3: | |
1278 | temp2 = 4; | |
1279 | break; | |
1280 | case 4: | |
1281 | temp2 = 6; | |
1282 | break; | |
1283 | case 5: | |
1284 | temp2 = 8; | |
1285 | break; | |
1286 | default: | |
1287 | break; | |
1288 | } | |
21df8fc8 | 1289 | |
cc1e2398 AK |
1290 | if ((ModeNo >= 0x26) && (ModeNo <= 0x28)) |
1291 | temp = temp * temp2 + temp2 / 2; | |
1292 | else | |
1293 | temp *= temp2; | |
21df8fc8 | 1294 | |
cc1e2398 AK |
1295 | /* SetOffset */ |
1296 | DisplayUnit = temp; | |
1297 | temp2 = temp; | |
1298 | temp = temp >> 8; /* ah */ | |
1299 | temp &= 0x0F; | |
58839b01 | 1300 | i = xgifb_reg_get(pVBInfo->P3c4, 0x0E); |
cc1e2398 AK |
1301 | i &= 0xF0; |
1302 | i |= temp; | |
8104e329 | 1303 | xgifb_reg_set(pVBInfo->P3c4, 0x0E, i); |
21df8fc8 | 1304 | |
cc1e2398 AK |
1305 | temp = (unsigned char) temp2; |
1306 | temp &= 0xFF; /* al */ | |
8104e329 | 1307 | xgifb_reg_set(pVBInfo->P3d4, 0x13, temp); |
21df8fc8 | 1308 | |
cc1e2398 AK |
1309 | /* SetDisplayUnit */ |
1310 | temp2 = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag; | |
1311 | temp2 &= InterlaceMode; | |
1312 | if (temp2) | |
1313 | DisplayUnit >>= 1; | |
21df8fc8 | 1314 | |
cc1e2398 AK |
1315 | DisplayUnit = DisplayUnit << 5; |
1316 | ah = (DisplayUnit & 0xff00) >> 8; | |
1317 | al = DisplayUnit & 0x00ff; | |
1318 | if (al == 0) | |
1319 | ah += 1; | |
1320 | else | |
1321 | ah += 2; | |
21df8fc8 | 1322 | |
cc1e2398 AK |
1323 | if (HwDeviceExtension->jChipType >= XG20) |
1324 | if ((ModeNo == 0x4A) | (ModeNo == 0x49)) | |
1325 | ah -= 1; | |
21df8fc8 | 1326 | |
8104e329 | 1327 | xgifb_reg_set(pVBInfo->P3c4, 0x10, ah); |
d7636e0b | 1328 | } |
1329 | ||
cc1e2398 AK |
1330 | static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo, |
1331 | unsigned short ModeIdIndex, | |
1332 | unsigned short RefreshRateTableIndex, | |
1333 | struct xgi_hw_device_info *HwDeviceExtension, | |
1334 | struct vb_device_info *pVBInfo) | |
d7636e0b | 1335 | { |
cc1e2398 | 1336 | unsigned short tempbx; |
d7636e0b | 1337 | |
1d7f656d KT |
1338 | unsigned short LCDXlat1VCLK[4] = { VCLK65 + 2, |
1339 | VCLK65 + 2, | |
1340 | VCLK65 + 2, | |
1341 | VCLK65 + 2 }; | |
1342 | unsigned short LCDXlat2VCLK[4] = { VCLK108_2 + 5, | |
1343 | VCLK108_2 + 5, | |
1344 | VCLK108_2 + 5, | |
1345 | VCLK108_2 + 5 }; | |
cc1e2398 | 1346 | unsigned short LVDSXlat1VCLK[4] = { VCLK40, VCLK40, VCLK40, VCLK40 }; |
1d7f656d KT |
1347 | unsigned short LVDSXlat2VCLK[4] = { VCLK65 + 2, |
1348 | VCLK65 + 2, | |
1349 | VCLK65 + 2, | |
1350 | VCLK65 + 2 }; | |
1351 | unsigned short LVDSXlat3VCLK[4] = { VCLK65 + 2, | |
1352 | VCLK65 + 2, | |
1353 | VCLK65 + 2, | |
1354 | VCLK65 + 2 }; | |
21df8fc8 | 1355 | |
cc1e2398 AK |
1356 | unsigned short CRT2Index, VCLKIndex; |
1357 | unsigned short modeflag, resinfo; | |
1358 | unsigned char *CHTVVCLKPtr = NULL; | |
21df8fc8 PS |
1359 | |
1360 | if (ModeNo <= 0x13) { | |
1d7f656d KT |
1361 | /* si+St_ResInfo */ |
1362 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
cc1e2398 AK |
1363 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
1364 | CRT2Index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; | |
21df8fc8 | 1365 | } else { |
1d7f656d KT |
1366 | /* si+Ext_ResInfo */ |
1367 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
cc1e2398 | 1368 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
1d7f656d KT |
1369 | CRT2Index = pVBInfo->RefIndex[RefreshRateTableIndex]. |
1370 | Ext_CRT2CRTC; | |
21df8fc8 | 1371 | } |
21df8fc8 | 1372 | |
cc1e2398 AK |
1373 | if (pVBInfo->IF_DEF_LVDS == 0) { |
1374 | CRT2Index = CRT2Index >> 6; /* for LCD */ | |
1375 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { /*301b*/ | |
1376 | if (pVBInfo->LCDResInfo != Panel1024x768) | |
1377 | VCLKIndex = LCDXlat2VCLK[CRT2Index]; | |
1378 | else | |
1379 | VCLKIndex = LCDXlat1VCLK[CRT2Index]; | |
1380 | } else { /* for TV */ | |
1381 | if (pVBInfo->VBInfo & SetCRT2ToTV) { | |
1382 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { | |
1383 | if (pVBInfo->SetFlag & RPLLDIV2XO) { | |
1384 | VCLKIndex = HiTVVCLKDIV2; | |
cc1e2398 | 1385 | VCLKIndex += 25; |
cc1e2398 AK |
1386 | } else { |
1387 | VCLKIndex = HiTVVCLK; | |
cc1e2398 | 1388 | VCLKIndex += 25; |
cc1e2398 | 1389 | } |
21df8fc8 | 1390 | |
cc1e2398 AK |
1391 | if (pVBInfo->SetFlag & TVSimuMode) { |
1392 | if (modeflag & Charx8Dot) { | |
1d7f656d KT |
1393 | VCLKIndex = |
1394 | HiTVSimuVCLK; | |
cc1e2398 | 1395 | VCLKIndex += 25; |
cc1e2398 | 1396 | } else { |
1d7f656d KT |
1397 | VCLKIndex = |
1398 | HiTVTextVCLK; | |
cc1e2398 | 1399 | VCLKIndex += 25; |
cc1e2398 AK |
1400 | } |
1401 | } | |
21df8fc8 | 1402 | |
1d7f656d KT |
1403 | /* 301lv */ |
1404 | if (pVBInfo->VBType & VB_XGI301LV) { | |
1405 | if (!(pVBInfo->VBExtInfo == | |
1406 | VB_YPbPr1080i)) { | |
1407 | VCLKIndex = | |
1408 | YPbPr750pVCLK; | |
cc1e2398 | 1409 | if (!(pVBInfo->VBExtInfo |
1d7f656d KT |
1410 | == |
1411 | VB_YPbPr750p)) { | |
1412 | VCLKIndex = | |
1413 | YPbPr525pVCLK; | |
cc1e2398 AK |
1414 | if (!(pVBInfo->VBExtInfo |
1415 | == VB_YPbPr525p)) { | |
1416 | VCLKIndex | |
1417 | = YPbPr525iVCLK_2; | |
1418 | if (!(pVBInfo->SetFlag | |
1419 | & RPLLDIV2XO)) | |
1420 | VCLKIndex | |
1421 | = YPbPr525iVCLK; | |
1422 | } | |
1423 | } | |
1424 | } | |
1425 | } | |
1426 | } else { | |
1427 | if (pVBInfo->VBInfo & SetCRT2ToTV) { | |
1d7f656d KT |
1428 | if (pVBInfo->SetFlag & |
1429 | RPLLDIV2XO) { | |
cc1e2398 | 1430 | VCLKIndex = TVVCLKDIV2; |
cc1e2398 | 1431 | VCLKIndex += 25; |
cc1e2398 AK |
1432 | } else { |
1433 | VCLKIndex = TVVCLK; | |
cc1e2398 | 1434 | VCLKIndex += 25; |
cc1e2398 AK |
1435 | } |
1436 | } | |
1437 | } | |
1438 | } else { /* for CRT2 */ | |
1d7f656d | 1439 | /* Port 3cch */ |
d8ad0a6d | 1440 | VCLKIndex = (unsigned char) inb( |
1d7f656d | 1441 | (pVBInfo->P3ca + 0x02)); |
cc1e2398 AK |
1442 | VCLKIndex = ((VCLKIndex >> 2) & 0x03); |
1443 | if (ModeNo > 0x13) { | |
1d7f656d KT |
1444 | /* di+Ext_CRTVCLK */ |
1445 | VCLKIndex = | |
1446 | pVBInfo->RefIndex[ | |
1447 | RefreshRateTableIndex]. | |
1448 | Ext_CRTVCLK; | |
cc1e2398 AK |
1449 | VCLKIndex &= IndexMask; |
1450 | } | |
1451 | } | |
1452 | } | |
1453 | } else { /* LVDS */ | |
1454 | if (ModeNo <= 0x13) | |
1455 | VCLKIndex = CRT2Index; | |
1456 | else | |
1457 | VCLKIndex = CRT2Index; | |
21df8fc8 | 1458 | |
cc1e2398 AK |
1459 | if (pVBInfo->IF_DEF_CH7005 == 1) { |
1460 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) { | |
1461 | VCLKIndex &= 0x1f; | |
1462 | tempbx = 0; | |
21df8fc8 | 1463 | |
cc1e2398 AK |
1464 | if (pVBInfo->VBInfo & SetPALTV) |
1465 | tempbx += 2; | |
21df8fc8 | 1466 | |
cc1e2398 AK |
1467 | if (pVBInfo->VBInfo & SetCHTVOverScan) |
1468 | tempbx += 1; | |
21df8fc8 | 1469 | |
cc1e2398 AK |
1470 | switch (tempbx) { |
1471 | case 0: | |
1472 | CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC; | |
1473 | break; | |
1474 | case 1: | |
1475 | CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC; | |
1476 | break; | |
1477 | case 2: | |
1478 | CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL; | |
1479 | break; | |
1480 | case 3: | |
1481 | CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL; | |
1482 | break; | |
1483 | default: | |
1484 | break; | |
1485 | } | |
21df8fc8 | 1486 | |
cc1e2398 AK |
1487 | VCLKIndex = CHTVVCLKPtr[VCLKIndex]; |
1488 | } | |
1489 | } else { | |
1490 | VCLKIndex = VCLKIndex >> 6; | |
1d7f656d KT |
1491 | if ((pVBInfo->LCDResInfo == Panel800x600) || |
1492 | (pVBInfo->LCDResInfo == Panel320x480)) | |
cc1e2398 | 1493 | VCLKIndex = LVDSXlat1VCLK[VCLKIndex]; |
1d7f656d KT |
1494 | else if ((pVBInfo->LCDResInfo == Panel1024x768) || |
1495 | (pVBInfo->LCDResInfo == Panel1024x768x75)) | |
cc1e2398 AK |
1496 | VCLKIndex = LVDSXlat2VCLK[VCLKIndex]; |
1497 | else | |
1498 | VCLKIndex = LVDSXlat3VCLK[VCLKIndex]; | |
1499 | } | |
21df8fc8 | 1500 | } |
cc1e2398 | 1501 | /* VCLKIndex = VCLKIndex&IndexMask; */ |
d7636e0b | 1502 | |
cc1e2398 | 1503 | return VCLKIndex; |
21df8fc8 | 1504 | } |
d7636e0b | 1505 | |
1d7f656d KT |
1506 | static void XGI_SetCRT1VCLK(unsigned short ModeNo, |
1507 | unsigned short ModeIdIndex, | |
1508 | struct xgi_hw_device_info *HwDeviceExtension, | |
1509 | unsigned short RefreshRateTableIndex, | |
1510 | struct vb_device_info *pVBInfo) | |
d7636e0b | 1511 | { |
108afbf8 | 1512 | unsigned char index, data; |
21df8fc8 PS |
1513 | unsigned short vclkindex; |
1514 | ||
1515 | if (pVBInfo->IF_DEF_LVDS == 1) { | |
1516 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; | |
58839b01 | 1517 | data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF; |
8104e329 AK |
1518 | xgifb_reg_set(pVBInfo->P3c4, 0x31, data); |
1519 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, | |
21df8fc8 | 1520 | pVBInfo->VCLKData[index].SR2B); |
8104e329 | 1521 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, |
21df8fc8 | 1522 | pVBInfo->VCLKData[index].SR2C); |
8104e329 | 1523 | xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01); |
21df8fc8 PS |
1524 | } else if ((pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
1525 | | VB_XGI302LV | VB_XGI301C)) && (pVBInfo->VBInfo | |
1526 | & SetCRT2ToLCDA)) { | |
1527 | vclkindex = XGI_GetVCLK2Ptr(ModeNo, ModeIdIndex, | |
1528 | RefreshRateTableIndex, HwDeviceExtension, | |
1529 | pVBInfo); | |
58839b01 | 1530 | data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF; |
8104e329 | 1531 | xgifb_reg_set(pVBInfo->P3c4, 0x31, data); |
21df8fc8 | 1532 | data = pVBInfo->VBVCLKData[vclkindex].Part4_A; |
8104e329 | 1533 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, data); |
21df8fc8 | 1534 | data = pVBInfo->VBVCLKData[vclkindex].Part4_B; |
8104e329 AK |
1535 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, data); |
1536 | xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01); | |
21df8fc8 PS |
1537 | } else { |
1538 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; | |
58839b01 | 1539 | data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF; |
8104e329 AK |
1540 | xgifb_reg_set(pVBInfo->P3c4, 0x31, data); |
1541 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, | |
21df8fc8 | 1542 | pVBInfo->VCLKData[index].SR2B); |
8104e329 | 1543 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, |
21df8fc8 | 1544 | pVBInfo->VCLKData[index].SR2C); |
8104e329 | 1545 | xgifb_reg_set(pVBInfo->P3c4, 0x2D, 0x01); |
21df8fc8 | 1546 | } |
d7636e0b | 1547 | |
21df8fc8 | 1548 | if (HwDeviceExtension->jChipType >= XG20) { |
1d7f656d KT |
1549 | if (pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag & |
1550 | HalfDCLK) { | |
58839b01 | 1551 | data = xgifb_reg_get(pVBInfo->P3c4, 0x2B); |
8104e329 | 1552 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, data); |
58839b01 | 1553 | data = xgifb_reg_get(pVBInfo->P3c4, 0x2C); |
21df8fc8 PS |
1554 | index = data; |
1555 | index &= 0xE0; | |
1556 | data &= 0x1F; | |
1557 | data = data << 1; | |
1558 | data += 1; | |
1559 | data |= index; | |
8104e329 | 1560 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, data); |
21df8fc8 PS |
1561 | } |
1562 | } | |
1563 | } | |
d7636e0b | 1564 | |
063b9c4b | 1565 | static void XGI_SetCRT1FIFO(unsigned short ModeNo, |
21df8fc8 PS |
1566 | struct xgi_hw_device_info *HwDeviceExtension, |
1567 | struct vb_device_info *pVBInfo) | |
1568 | { | |
1569 | unsigned short data; | |
1570 | ||
58839b01 | 1571 | data = xgifb_reg_get(pVBInfo->P3c4, 0x3D); |
21df8fc8 | 1572 | data &= 0xfe; |
8104e329 | 1573 | xgifb_reg_set(pVBInfo->P3c4, 0x3D, data); /* diable auto-threshold */ |
21df8fc8 PS |
1574 | |
1575 | if (ModeNo > 0x13) { | |
8104e329 | 1576 | xgifb_reg_set(pVBInfo->P3c4, 0x08, 0x34); |
58839b01 | 1577 | data = xgifb_reg_get(pVBInfo->P3c4, 0x09); |
21df8fc8 | 1578 | data &= 0xC0; |
8104e329 | 1579 | xgifb_reg_set(pVBInfo->P3c4, 0x09, data | 0x30); |
58839b01 | 1580 | data = xgifb_reg_get(pVBInfo->P3c4, 0x3D); |
21df8fc8 | 1581 | data |= 0x01; |
8104e329 | 1582 | xgifb_reg_set(pVBInfo->P3c4, 0x3D, data); |
21df8fc8 PS |
1583 | } else { |
1584 | if (HwDeviceExtension->jChipType == XG27) { | |
8104e329 | 1585 | xgifb_reg_set(pVBInfo->P3c4, 0x08, 0x0E); |
58839b01 | 1586 | data = xgifb_reg_get(pVBInfo->P3c4, 0x09); |
21df8fc8 | 1587 | data &= 0xC0; |
8104e329 | 1588 | xgifb_reg_set(pVBInfo->P3c4, 0x09, data | 0x20); |
21df8fc8 | 1589 | } else { |
8104e329 | 1590 | xgifb_reg_set(pVBInfo->P3c4, 0x08, 0xAE); |
58839b01 | 1591 | data = xgifb_reg_get(pVBInfo->P3c4, 0x09); |
21df8fc8 | 1592 | data &= 0xF0; |
8104e329 | 1593 | xgifb_reg_set(pVBInfo->P3c4, 0x09, data); |
21df8fc8 PS |
1594 | } |
1595 | } | |
d7636e0b | 1596 | |
21df8fc8 PS |
1597 | if (HwDeviceExtension->jChipType == XG21) |
1598 | XGI_SetXG21FPBits(pVBInfo); /* Fix SR9[7:6] can't read back */ | |
1599 | } | |
d7636e0b | 1600 | |
cc1e2398 AK |
1601 | static void XGI_SetVCLKState(struct xgi_hw_device_info *HwDeviceExtension, |
1602 | unsigned short ModeNo, unsigned short RefreshRateTableIndex, | |
21df8fc8 PS |
1603 | struct vb_device_info *pVBInfo) |
1604 | { | |
cc1e2398 AK |
1605 | unsigned short data, data2 = 0; |
1606 | short VCLK; | |
d7636e0b | 1607 | |
cc1e2398 | 1608 | unsigned char index; |
d7636e0b | 1609 | |
cc1e2398 AK |
1610 | if (ModeNo <= 0x13) |
1611 | VCLK = 0; | |
1612 | else { | |
1613 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; | |
1614 | index &= IndexMask; | |
1615 | VCLK = pVBInfo->VCLKData[index].CLOCK; | |
1616 | } | |
d7636e0b | 1617 | |
58839b01 | 1618 | data = xgifb_reg_get(pVBInfo->P3c4, 0x32); |
cc1e2398 AK |
1619 | data &= 0xf3; |
1620 | if (VCLK >= 200) | |
1621 | data |= 0x0c; /* VCLK > 200 */ | |
d7636e0b | 1622 | |
cc1e2398 AK |
1623 | if (HwDeviceExtension->jChipType >= XG20) |
1624 | data &= ~0x04; /* 2 pixel mode */ | |
d7636e0b | 1625 | |
8104e329 | 1626 | xgifb_reg_set(pVBInfo->P3c4, 0x32, data); |
cc1e2398 AK |
1627 | |
1628 | if (HwDeviceExtension->jChipType < XG20) { | |
58839b01 | 1629 | data = xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
cc1e2398 AK |
1630 | data &= 0xE7; |
1631 | if (VCLK < 200) | |
1632 | data |= 0x10; | |
8104e329 | 1633 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, data); |
cc1e2398 AK |
1634 | } |
1635 | ||
1636 | /* Jong for Adavantech LCD ripple issue | |
1637 | if ((VCLK >= 0) && (VCLK < 135)) | |
1638 | data2 = 0x03; | |
1639 | else if ((VCLK >= 135) && (VCLK < 160)) | |
1640 | data2 = 0x02; | |
1641 | else if ((VCLK >= 160) && (VCLK < 260)) | |
1642 | data2 = 0x01; | |
1643 | else if (VCLK > 260) | |
1644 | data2 = 0x00; | |
1645 | */ | |
1646 | data2 = 0x00; | |
1647 | ||
ec9e5d3e | 1648 | xgifb_reg_and_or(pVBInfo->P3c4, 0x07, 0xFC, data2); |
cc1e2398 | 1649 | if (HwDeviceExtension->jChipType >= XG27) |
ec9e5d3e | 1650 | xgifb_reg_and_or(pVBInfo->P3c4, 0x40, 0xFC, data2 & 0x03); |
cc1e2398 AK |
1651 | |
1652 | } | |
1653 | ||
1654 | static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension, | |
1655 | unsigned short ModeNo, unsigned short ModeIdIndex, | |
1656 | unsigned short RefreshRateTableIndex, | |
1657 | struct vb_device_info *pVBInfo) | |
1658 | { | |
1659 | unsigned short data, data2, data3, infoflag = 0, modeflag, resindex, | |
1660 | xres; | |
1661 | ||
1662 | if (ModeNo > 0x13) { | |
1663 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
1d7f656d KT |
1664 | infoflag = pVBInfo->RefIndex[RefreshRateTableIndex]. |
1665 | Ext_InfoFlag; | |
cc1e2398 | 1666 | } else |
1d7f656d KT |
1667 | /* si+St_ModeFlag */ |
1668 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
cc1e2398 | 1669 | |
58839b01 | 1670 | if (xgifb_reg_get(pVBInfo->P3d4, 0x31) & 0x01) |
ec9e5d3e | 1671 | xgifb_reg_and_or(pVBInfo->P3c4, 0x1F, 0x3F, 0x00); |
cc1e2398 AK |
1672 | |
1673 | if (ModeNo > 0x13) | |
1674 | data = infoflag; | |
1675 | else | |
1676 | data = 0; | |
1677 | ||
1678 | data2 = 0; | |
1679 | ||
1680 | if (ModeNo > 0x13) { | |
1681 | if (pVBInfo->ModeType > 0x02) { | |
1682 | data2 |= 0x02; | |
1683 | data3 = pVBInfo->ModeType - ModeVGA; | |
1684 | data3 = data3 << 2; | |
1685 | data2 |= data3; | |
1686 | } | |
21df8fc8 | 1687 | } |
d7636e0b | 1688 | |
21df8fc8 | 1689 | data &= InterlaceMode; |
d7636e0b | 1690 | |
21df8fc8 PS |
1691 | if (data) |
1692 | data2 |= 0x20; | |
d7636e0b | 1693 | |
ec9e5d3e | 1694 | xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x3F, data2); |
8104e329 | 1695 | /* xgifb_reg_set(pVBInfo->P3c4,0x06,data2); */ |
21df8fc8 PS |
1696 | resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); |
1697 | if (ModeNo <= 0x13) | |
1698 | xres = pVBInfo->StResInfo[resindex].HTotal; | |
1699 | else | |
1700 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ | |
1701 | ||
1702 | data = 0x0000; | |
1703 | if (infoflag & InterlaceMode) { | |
1704 | if (xres == 1024) | |
1705 | data = 0x0035; | |
1706 | else if (xres == 1280) | |
1707 | data = 0x0048; | |
1708 | } | |
d7636e0b | 1709 | |
21df8fc8 | 1710 | data2 = data & 0x00FF; |
ec9e5d3e | 1711 | xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFF, data2); |
21df8fc8 | 1712 | data2 = (data & 0xFF00) >> 8; |
ec9e5d3e | 1713 | xgifb_reg_and_or(pVBInfo->P3d4, 0x19, 0xFC, data2); |
d7636e0b | 1714 | |
21df8fc8 | 1715 | if (modeflag & HalfDCLK) |
ec9e5d3e | 1716 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xF7, 0x08); |
21df8fc8 PS |
1717 | |
1718 | data2 = 0; | |
1719 | ||
1720 | if (modeflag & LineCompareOff) | |
1721 | data2 |= 0x08; | |
1722 | ||
1723 | if (ModeNo > 0x13) { | |
1724 | if (pVBInfo->ModeType == ModeEGA) | |
1725 | data2 |= 0x40; | |
1726 | } | |
1727 | ||
ec9e5d3e | 1728 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0F, ~0x48, data2); |
21df8fc8 PS |
1729 | data = 0x60; |
1730 | if (pVBInfo->ModeType != ModeText) { | |
1731 | data = data ^ 0x60; | |
1732 | if (pVBInfo->ModeType != ModeEGA) | |
1733 | data = data ^ 0xA0; | |
1734 | } | |
ec9e5d3e | 1735 | xgifb_reg_and_or(pVBInfo->P3c4, 0x21, 0x1F, data); |
21df8fc8 PS |
1736 | |
1737 | XGI_SetVCLKState(HwDeviceExtension, ModeNo, RefreshRateTableIndex, | |
1738 | pVBInfo); | |
1739 | ||
1740 | /* if (modeflag&HalfDCLK) //030305 fix lowresolution bug */ | |
1741 | /* if (XGINew_IF_DEF_NEW_LOWRES) */ | |
1d7f656d KT |
1742 | /* XGI_VesaLowResolution(ModeNo, ModeIdIndex); |
1743 | * //030305 fix lowresolution bug */ | |
21df8fc8 | 1744 | |
58839b01 | 1745 | data = xgifb_reg_get(pVBInfo->P3d4, 0x31); |
21df8fc8 PS |
1746 | |
1747 | if (HwDeviceExtension->jChipType == XG27) { | |
1748 | if (data & 0x40) | |
1749 | data = 0x2c; | |
1750 | else | |
1751 | data = 0x6c; | |
8104e329 | 1752 | xgifb_reg_set(pVBInfo->P3d4, 0x52, data); |
b9bf6e4e | 1753 | xgifb_reg_or(pVBInfo->P3d4, 0x51, 0x10); |
21df8fc8 PS |
1754 | } else if (HwDeviceExtension->jChipType >= XG20) { |
1755 | if (data & 0x40) | |
1756 | data = 0x33; | |
1757 | else | |
1758 | data = 0x73; | |
8104e329 AK |
1759 | xgifb_reg_set(pVBInfo->P3d4, 0x52, data); |
1760 | xgifb_reg_set(pVBInfo->P3d4, 0x51, 0x02); | |
21df8fc8 PS |
1761 | } else { |
1762 | if (data & 0x40) | |
1763 | data = 0x2c; | |
1764 | else | |
1765 | data = 0x6c; | |
8104e329 | 1766 | xgifb_reg_set(pVBInfo->P3d4, 0x52, data); |
21df8fc8 | 1767 | } |
d7636e0b | 1768 | |
d7636e0b | 1769 | } |
1770 | ||
21df8fc8 | 1771 | /* |
1d7f656d KT |
1772 | void XGI_VesaLowResolution(unsigned short ModeNo, |
1773 | unsigned short ModeIdIndex, | |
1774 | struct vb_device_info *pVBInfo) | |
21df8fc8 PS |
1775 | { |
1776 | unsigned short modeflag; | |
d7636e0b | 1777 | |
21df8fc8 PS |
1778 | if (ModeNo > 0x13) |
1779 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
1780 | else | |
1781 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
1782 | ||
1783 | if (ModeNo > 0x13) { | |
1784 | if (modeflag & DoubleScanMode) { | |
1785 | if (modeflag & HalfDCLK) { | |
1d7f656d KT |
1786 | if (pVBInfo->VBType & VB_XGI301B | |
1787 | VB_XGI302B | | |
1788 | VB_XGI301LV | | |
1789 | VB_XGI302LV | | |
1790 | VB_XGI301C)) { | |
1791 | if (!(pVBInfo->VBInfo & | |
1792 | SetCRT2ToRAMDAC)) { | |
1793 | if (pVBInfo->VBInfo & | |
1794 | SetInSlaveMode) { | |
1795 | xgifb_reg_and_or( | |
1796 | pVBInfo->P3c4, | |
1797 | 0x01, | |
1798 | 0xf7, | |
1799 | 0x00); | |
1800 | xgifb_reg_and_or( | |
1801 | pVBInfo->P3c4, | |
1802 | 0x0f, | |
1803 | 0x7f, | |
1804 | 0x00); | |
21df8fc8 PS |
1805 | return; |
1806 | } | |
1807 | } | |
1808 | } | |
1d7f656d KT |
1809 | xgifb_reg_and_or(pVBInfo->P3c4, |
1810 | 0x0f, | |
1811 | 0xff, | |
1812 | 0x80); | |
1813 | xgifb_reg_and_or(pVBInfo->P3c4, | |
1814 | 0x01, | |
1815 | 0xf7, | |
1816 | 0x00); | |
21df8fc8 PS |
1817 | return; |
1818 | } | |
1819 | } | |
1820 | } | |
ec9e5d3e | 1821 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0f, 0x7f, 0x00); |
21df8fc8 PS |
1822 | } |
1823 | */ | |
d7636e0b | 1824 | |
1d7f656d KT |
1825 | static void XGI_WriteDAC(unsigned short dl, |
1826 | unsigned short ah, | |
1827 | unsigned short al, | |
1828 | unsigned short dh, | |
1829 | struct vb_device_info *pVBInfo) | |
cc1e2398 AK |
1830 | { |
1831 | unsigned short temp, bh, bl; | |
1832 | ||
1833 | bh = ah; | |
1834 | bl = al; | |
1835 | ||
1836 | if (dl != 0) { | |
1837 | temp = bh; | |
1838 | bh = dh; | |
1839 | dh = temp; | |
1840 | if (dl == 1) { | |
1841 | temp = bl; | |
1842 | bl = dh; | |
1843 | dh = temp; | |
1844 | } else { | |
1845 | temp = bl; | |
1846 | bl = bh; | |
1847 | bh = temp; | |
1848 | } | |
1849 | } | |
efdf4ee7 AK |
1850 | outb((unsigned short) dh, pVBInfo->P3c9); |
1851 | outb((unsigned short) bh, pVBInfo->P3c9); | |
1852 | outb((unsigned short) bl, pVBInfo->P3c9); | |
cc1e2398 AK |
1853 | } |
1854 | ||
063b9c4b | 1855 | static void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex, |
21df8fc8 PS |
1856 | struct vb_device_info *pVBInfo) |
1857 | { | |
1858 | unsigned short data, data2, time, i, j, k, m, n, o, si, di, bx, dl, al, | |
1859 | ah, dh, *table = NULL; | |
d7636e0b | 1860 | |
21df8fc8 PS |
1861 | if (ModeNo <= 0x13) |
1862 | data = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
1863 | else | |
1864 | data = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
1865 | ||
1866 | data &= DACInfoFlag; | |
1867 | time = 64; | |
1868 | ||
1869 | if (data == 0x00) | |
1870 | table = XGINew_MDA_DAC; | |
1871 | else if (data == 0x08) | |
1872 | table = XGINew_CGA_DAC; | |
1873 | else if (data == 0x10) | |
1874 | table = XGINew_EGA_DAC; | |
1875 | else if (data == 0x18) { | |
1876 | time = 256; | |
1877 | table = XGINew_VGA_DAC; | |
1878 | } | |
d7636e0b | 1879 | |
21df8fc8 PS |
1880 | if (time == 256) |
1881 | j = 16; | |
1882 | else | |
1883 | j = time; | |
d7636e0b | 1884 | |
efdf4ee7 AK |
1885 | outb(0xFF, pVBInfo->P3c6); |
1886 | outb(0x00, pVBInfo->P3c8); | |
d7636e0b | 1887 | |
21df8fc8 PS |
1888 | for (i = 0; i < j; i++) { |
1889 | data = table[i]; | |
d7636e0b | 1890 | |
21df8fc8 PS |
1891 | for (k = 0; k < 3; k++) { |
1892 | data2 = 0; | |
d7636e0b | 1893 | |
21df8fc8 PS |
1894 | if (data & 0x01) |
1895 | data2 = 0x2A; | |
d7636e0b | 1896 | |
21df8fc8 PS |
1897 | if (data & 0x02) |
1898 | data2 += 0x15; | |
d7636e0b | 1899 | |
efdf4ee7 | 1900 | outb(data2, pVBInfo->P3c9); |
21df8fc8 PS |
1901 | data = data >> 2; |
1902 | } | |
1903 | } | |
d7636e0b | 1904 | |
21df8fc8 PS |
1905 | if (time == 256) { |
1906 | for (i = 16; i < 32; i++) { | |
1907 | data = table[i]; | |
1908 | ||
1909 | for (k = 0; k < 3; k++) | |
efdf4ee7 | 1910 | outb(data, pVBInfo->P3c9); |
21df8fc8 PS |
1911 | } |
1912 | ||
1913 | si = 32; | |
1914 | ||
1915 | for (m = 0; m < 9; m++) { | |
1916 | di = si; | |
1917 | bx = si + 0x04; | |
1918 | dl = 0; | |
1919 | ||
1920 | for (n = 0; n < 3; n++) { | |
1921 | for (o = 0; o < 5; o++) { | |
1922 | dh = table[si]; | |
1923 | ah = table[di]; | |
1924 | al = table[bx]; | |
1925 | si++; | |
1926 | XGI_WriteDAC(dl, ah, al, dh, pVBInfo); | |
1927 | } | |
1928 | ||
1929 | si -= 2; | |
1930 | ||
1931 | for (o = 0; o < 3; o++) { | |
1932 | dh = table[bx]; | |
1933 | ah = table[di]; | |
1934 | al = table[si]; | |
1935 | si--; | |
1936 | XGI_WriteDAC(dl, ah, al, dh, pVBInfo); | |
1937 | } | |
1938 | ||
1939 | dl++; | |
1940 | } | |
1941 | ||
1942 | si += 5; | |
1943 | } | |
1944 | } | |
1945 | } | |
d7636e0b | 1946 | |
1d7f656d KT |
1947 | static void XGI_GetLVDSResInfo(unsigned short ModeNo, |
1948 | unsigned short ModeIdIndex, | |
1949 | struct vb_device_info *pVBInfo) | |
21df8fc8 PS |
1950 | { |
1951 | unsigned short resindex, xres, yres, modeflag; | |
d7636e0b | 1952 | |
21df8fc8 | 1953 | if (ModeNo <= 0x13) |
1d7f656d KT |
1954 | /* si+St_ResInfo */ |
1955 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; | |
21df8fc8 | 1956 | else |
1d7f656d KT |
1957 | /* si+Ext_ResInfo */ |
1958 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; | |
d7636e0b | 1959 | |
21df8fc8 PS |
1960 | /* if (ModeNo > 0x13) */ |
1961 | /* modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; */ | |
1962 | /* else */ | |
1963 | /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; */ | |
d7636e0b | 1964 | |
21df8fc8 | 1965 | if (ModeNo <= 0x13) |
1d7f656d KT |
1966 | /* si+St_ResInfo */ |
1967 | resindex = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; | |
21df8fc8 | 1968 | else |
1d7f656d KT |
1969 | /* si+Ext_ResInfo */ |
1970 | resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; | |
d7636e0b | 1971 | |
21df8fc8 | 1972 | /* resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); */ |
d7636e0b | 1973 | |
21df8fc8 PS |
1974 | if (ModeNo <= 0x13) { |
1975 | xres = pVBInfo->StResInfo[resindex].HTotal; | |
1976 | yres = pVBInfo->StResInfo[resindex].VTotal; | |
1977 | } else { | |
1978 | xres = pVBInfo->ModeResInfo[resindex].HTotal; | |
1979 | yres = pVBInfo->ModeResInfo[resindex].VTotal; | |
1980 | } | |
1981 | if (ModeNo > 0x13) { | |
1982 | if (modeflag & HalfDCLK) | |
1983 | xres = xres << 1; | |
d7636e0b | 1984 | |
21df8fc8 PS |
1985 | if (modeflag & DoubleScanMode) |
1986 | yres = yres << 1; | |
1987 | } | |
1988 | /* if (modeflag & Charx8Dot) */ | |
1989 | /* { */ | |
d7636e0b | 1990 | |
21df8fc8 PS |
1991 | if (xres == 720) |
1992 | xres = 640; | |
d7636e0b | 1993 | |
21df8fc8 PS |
1994 | /* } */ |
1995 | pVBInfo->VGAHDE = xres; | |
1996 | pVBInfo->HDE = xres; | |
1997 | pVBInfo->VGAVDE = yres; | |
1998 | pVBInfo->VDE = yres; | |
1999 | } | |
d7636e0b | 2000 | |
cc1e2398 AK |
2001 | static void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo, |
2002 | unsigned short ModeIdIndex, | |
21df8fc8 PS |
2003 | unsigned short RefreshRateTableIndex, |
2004 | struct vb_device_info *pVBInfo) | |
2005 | { | |
cc1e2398 | 2006 | unsigned short i, tempdx, tempcx, tempbx, tempal, modeflag, table; |
d7636e0b | 2007 | |
cc1e2398 | 2008 | struct XGI330_LCDDataTablStruct *tempdi = NULL; |
d7636e0b | 2009 | |
cc1e2398 AK |
2010 | tempbx = BX; |
2011 | ||
2012 | if (ModeNo <= 0x13) { | |
2013 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
2014 | tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; | |
2015 | } else { | |
2016 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
2017 | tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; | |
21df8fc8 | 2018 | } |
cc1e2398 AK |
2019 | |
2020 | tempal = tempal & 0x0f; | |
2021 | ||
2022 | if (tempbx <= 1) { /* ExpLink */ | |
2023 | if (ModeNo <= 0x13) { | |
1d7f656d KT |
2024 | /* find no Ext_CRT2CRTC2 */ |
2025 | tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; | |
cc1e2398 | 2026 | } else { |
1d7f656d KT |
2027 | tempal = pVBInfo->RefIndex[RefreshRateTableIndex]. |
2028 | Ext_CRT2CRTC; | |
21df8fc8 | 2029 | } |
d7636e0b | 2030 | |
cc1e2398 AK |
2031 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { |
2032 | if (ModeNo <= 0x13) | |
1d7f656d KT |
2033 | tempal = pVBInfo->SModeIDTable[ModeIdIndex]. |
2034 | St_CRT2CRTC2; | |
cc1e2398 | 2035 | else |
1d7f656d KT |
2036 | tempal = pVBInfo->RefIndex[ |
2037 | RefreshRateTableIndex]. | |
2038 | Ext_CRT2CRTC2; | |
21df8fc8 | 2039 | } |
d7636e0b | 2040 | |
cc1e2398 AK |
2041 | if (tempbx & 0x01) |
2042 | tempal = (tempal >> 4); | |
21df8fc8 | 2043 | |
cc1e2398 AK |
2044 | tempal = (tempal & 0x0f); |
2045 | } | |
21df8fc8 | 2046 | |
cc1e2398 | 2047 | tempcx = LCDLenList[tempbx]; /* mov cl,byte ptr cs:LCDLenList[bx] */ |
21df8fc8 | 2048 | |
cc1e2398 AK |
2049 | if (pVBInfo->LCDInfo & EnableScalingLCD) { /* ScaleLCD */ |
2050 | if ((tempbx == 5) || (tempbx) == 7) | |
2051 | tempcx = LCDDesDataLen2; | |
2052 | else if ((tempbx == 3) || (tempbx == 8)) | |
2053 | tempcx = LVDSDesDataLen2; | |
2054 | } | |
2055 | /* mov di, word ptr cs:LCDDataList[bx] */ | |
1d7f656d KT |
2056 | /* tempdi = pVideoMemory[LCDDataList + tempbx * 2] | |
2057 | (pVideoMemory[LCDDataList + tempbx * 2 + 1] << 8); */ | |
21df8fc8 | 2058 | |
cc1e2398 AK |
2059 | switch (tempbx) { |
2060 | case 0: | |
2061 | tempdi = XGI_EPLLCDCRT1Ptr_H; | |
2062 | break; | |
2063 | case 1: | |
2064 | tempdi = XGI_EPLLCDCRT1Ptr_V; | |
2065 | break; | |
2066 | case 2: | |
2067 | tempdi = XGI_EPLLCDDataPtr; | |
2068 | break; | |
2069 | case 3: | |
2070 | tempdi = XGI_EPLLCDDesDataPtr; | |
2071 | break; | |
2072 | case 4: | |
2073 | tempdi = XGI_LCDDataTable; | |
2074 | break; | |
2075 | case 5: | |
2076 | tempdi = XGI_LCDDesDataTable; | |
2077 | break; | |
2078 | case 6: | |
2079 | tempdi = XGI_EPLCHLCDRegPtr; | |
2080 | break; | |
2081 | case 7: | |
2082 | case 8: | |
2083 | case 9: | |
2084 | tempdi = NULL; | |
2085 | break; | |
2086 | default: | |
2087 | break; | |
2088 | } | |
21df8fc8 | 2089 | |
cc1e2398 AK |
2090 | if (tempdi == NULL) /* OEMUtil */ |
2091 | return NULL; | |
21df8fc8 | 2092 | |
cc1e2398 AK |
2093 | table = tempbx; |
2094 | i = 0; | |
21df8fc8 | 2095 | |
cc1e2398 AK |
2096 | while (tempdi[i].PANELID != 0xff) { |
2097 | tempdx = pVBInfo->LCDResInfo; | |
2098 | if (tempbx & 0x0080) { /* OEMUtil */ | |
2099 | tempbx &= (~0x0080); | |
2100 | tempdx = pVBInfo->LCDTypeInfo; | |
21df8fc8 PS |
2101 | } |
2102 | ||
cc1e2398 AK |
2103 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
2104 | tempdx &= (~PanelResInfo); | |
21df8fc8 | 2105 | |
cc1e2398 AK |
2106 | if (tempdi[i].PANELID == tempdx) { |
2107 | tempbx = tempdi[i].MASK; | |
2108 | tempdx = pVBInfo->LCDInfo; | |
21df8fc8 | 2109 | |
cc1e2398 AK |
2110 | if (ModeNo <= 0x13) /* alan 09/10/2003 */ |
2111 | tempdx |= SetLCDStdMode; | |
21df8fc8 | 2112 | |
cc1e2398 AK |
2113 | if (modeflag & HalfDCLK) |
2114 | tempdx |= SetLCDLowResolution; | |
21df8fc8 | 2115 | |
cc1e2398 AK |
2116 | tempbx &= tempdx; |
2117 | if (tempbx == tempdi[i].CAP) | |
2118 | break; | |
21df8fc8 | 2119 | } |
cc1e2398 AK |
2120 | i++; |
2121 | } | |
21df8fc8 | 2122 | |
cc1e2398 AK |
2123 | if (table == 0) { |
2124 | switch (tempdi[i].DATAPTR) { | |
2125 | case 0: | |
2126 | return &XGI_LVDSCRT11024x768_1_H[tempal]; | |
2127 | break; | |
2128 | case 1: | |
2129 | return &XGI_LVDSCRT11024x768_2_H[tempal]; | |
2130 | break; | |
2131 | case 2: | |
2132 | return &XGI_LVDSCRT11280x1024_1_H[tempal]; | |
2133 | break; | |
2134 | case 3: | |
2135 | return &XGI_LVDSCRT11280x1024_2_H[tempal]; | |
2136 | break; | |
2137 | case 4: | |
2138 | return &XGI_LVDSCRT11400x1050_1_H[tempal]; | |
2139 | break; | |
2140 | case 5: | |
2141 | return &XGI_LVDSCRT11400x1050_2_H[tempal]; | |
2142 | break; | |
2143 | case 6: | |
2144 | return &XGI_LVDSCRT11600x1200_1_H[tempal]; | |
2145 | break; | |
2146 | case 7: | |
2147 | return &XGI_LVDSCRT11024x768_1_Hx75[tempal]; | |
2148 | break; | |
2149 | case 8: | |
2150 | return &XGI_LVDSCRT11024x768_2_Hx75[tempal]; | |
2151 | break; | |
2152 | case 9: | |
2153 | return &XGI_LVDSCRT11280x1024_1_Hx75[tempal]; | |
2154 | break; | |
2155 | case 10: | |
2156 | return &XGI_LVDSCRT11280x1024_2_Hx75[tempal]; | |
2157 | break; | |
2158 | default: | |
2159 | break; | |
21df8fc8 | 2160 | } |
cc1e2398 AK |
2161 | } else if (table == 1) { |
2162 | switch (tempdi[i].DATAPTR) { | |
2163 | case 0: | |
2164 | return &XGI_LVDSCRT11024x768_1_V[tempal]; | |
2165 | break; | |
2166 | case 1: | |
2167 | return &XGI_LVDSCRT11024x768_2_V[tempal]; | |
2168 | break; | |
2169 | case 2: | |
2170 | return &XGI_LVDSCRT11280x1024_1_V[tempal]; | |
2171 | break; | |
2172 | case 3: | |
2173 | return &XGI_LVDSCRT11280x1024_2_V[tempal]; | |
2174 | break; | |
2175 | case 4: | |
2176 | return &XGI_LVDSCRT11400x1050_1_V[tempal]; | |
2177 | break; | |
2178 | case 5: | |
2179 | return &XGI_LVDSCRT11400x1050_2_V[tempal]; | |
2180 | break; | |
2181 | case 6: | |
2182 | return &XGI_LVDSCRT11600x1200_1_V[tempal]; | |
2183 | break; | |
2184 | case 7: | |
2185 | return &XGI_LVDSCRT11024x768_1_Vx75[tempal]; | |
2186 | break; | |
2187 | case 8: | |
2188 | return &XGI_LVDSCRT11024x768_2_Vx75[tempal]; | |
2189 | break; | |
2190 | case 9: | |
2191 | return &XGI_LVDSCRT11280x1024_1_Vx75[tempal]; | |
2192 | break; | |
2193 | case 10: | |
2194 | return &XGI_LVDSCRT11280x1024_2_Vx75[tempal]; | |
2195 | break; | |
2196 | default: | |
2197 | break; | |
21df8fc8 | 2198 | } |
cc1e2398 AK |
2199 | } else if (table == 2) { |
2200 | switch (tempdi[i].DATAPTR) { | |
2201 | case 0: | |
2202 | return &XGI_LVDS1024x768Data_1[tempal]; | |
2203 | break; | |
2204 | case 1: | |
2205 | return &XGI_LVDS1024x768Data_2[tempal]; | |
2206 | break; | |
2207 | case 2: | |
2208 | return &XGI_LVDS1280x1024Data_1[tempal]; | |
2209 | break; | |
2210 | case 3: | |
2211 | return &XGI_LVDS1280x1024Data_2[tempal]; | |
2212 | break; | |
2213 | case 4: | |
2214 | return &XGI_LVDS1400x1050Data_1[tempal]; | |
2215 | break; | |
2216 | case 5: | |
2217 | return &XGI_LVDS1400x1050Data_2[tempal]; | |
2218 | break; | |
2219 | case 6: | |
2220 | return &XGI_LVDS1600x1200Data_1[tempal]; | |
2221 | break; | |
2222 | case 7: | |
2223 | return &XGI_LVDSNoScalingData[tempal]; | |
2224 | break; | |
2225 | case 8: | |
2226 | return &XGI_LVDS1024x768Data_1x75[tempal]; | |
2227 | break; | |
2228 | case 9: | |
2229 | return &XGI_LVDS1024x768Data_2x75[tempal]; | |
2230 | break; | |
2231 | case 10: | |
2232 | return &XGI_LVDS1280x1024Data_1x75[tempal]; | |
2233 | break; | |
2234 | case 11: | |
2235 | return &XGI_LVDS1280x1024Data_2x75[tempal]; | |
2236 | break; | |
2237 | case 12: | |
2238 | return &XGI_LVDSNoScalingDatax75[tempal]; | |
2239 | break; | |
2240 | default: | |
2241 | break; | |
2242 | } | |
2243 | } else if (table == 3) { | |
2244 | switch (tempdi[i].DATAPTR) { | |
2245 | case 0: | |
2246 | return &XGI_LVDS1024x768Des_1[tempal]; | |
2247 | break; | |
2248 | case 1: | |
2249 | return &XGI_LVDS1024x768Des_3[tempal]; | |
2250 | break; | |
2251 | case 2: | |
2252 | return &XGI_LVDS1024x768Des_2[tempal]; | |
2253 | break; | |
2254 | case 3: | |
2255 | return &XGI_LVDS1280x1024Des_1[tempal]; | |
2256 | break; | |
2257 | case 4: | |
2258 | return &XGI_LVDS1280x1024Des_2[tempal]; | |
2259 | break; | |
2260 | case 5: | |
2261 | return &XGI_LVDS1400x1050Des_1[tempal]; | |
2262 | break; | |
2263 | case 6: | |
2264 | return &XGI_LVDS1400x1050Des_2[tempal]; | |
2265 | break; | |
2266 | case 7: | |
2267 | return &XGI_LVDS1600x1200Des_1[tempal]; | |
2268 | break; | |
2269 | case 8: | |
2270 | return &XGI_LVDSNoScalingDesData[tempal]; | |
2271 | break; | |
2272 | case 9: | |
2273 | return &XGI_LVDS1024x768Des_1x75[tempal]; | |
2274 | break; | |
2275 | case 10: | |
2276 | return &XGI_LVDS1024x768Des_3x75[tempal]; | |
2277 | break; | |
2278 | case 11: | |
2279 | return &XGI_LVDS1024x768Des_2x75[tempal]; | |
2280 | break; | |
2281 | case 12: | |
2282 | return &XGI_LVDS1280x1024Des_1x75[tempal]; | |
2283 | break; | |
2284 | case 13: | |
2285 | return &XGI_LVDS1280x1024Des_2x75[tempal]; | |
2286 | break; | |
2287 | case 14: | |
2288 | return &XGI_LVDSNoScalingDesDatax75[tempal]; | |
2289 | break; | |
2290 | default: | |
2291 | break; | |
2292 | } | |
2293 | } else if (table == 4) { | |
2294 | switch (tempdi[i].DATAPTR) { | |
2295 | case 0: | |
2296 | return &XGI_ExtLCD1024x768Data[tempal]; | |
2297 | break; | |
2298 | case 1: | |
2299 | return &XGI_StLCD1024x768Data[tempal]; | |
2300 | break; | |
2301 | case 2: | |
2302 | return &XGI_CetLCD1024x768Data[tempal]; | |
2303 | break; | |
2304 | case 3: | |
2305 | return &XGI_ExtLCD1280x1024Data[tempal]; | |
2306 | break; | |
2307 | case 4: | |
2308 | return &XGI_StLCD1280x1024Data[tempal]; | |
2309 | break; | |
2310 | case 5: | |
2311 | return &XGI_CetLCD1280x1024Data[tempal]; | |
2312 | break; | |
2313 | case 6: | |
2314 | return &XGI_ExtLCD1400x1050Data[tempal]; | |
2315 | break; | |
2316 | case 7: | |
2317 | return &XGI_StLCD1400x1050Data[tempal]; | |
2318 | break; | |
2319 | case 8: | |
2320 | return &XGI_CetLCD1400x1050Data[tempal]; | |
2321 | break; | |
2322 | case 9: | |
2323 | return &XGI_ExtLCD1600x1200Data[tempal]; | |
2324 | break; | |
2325 | case 10: | |
2326 | return &XGI_StLCD1600x1200Data[tempal]; | |
2327 | break; | |
2328 | case 11: | |
2329 | return &XGI_NoScalingData[tempal]; | |
2330 | break; | |
2331 | case 12: | |
2332 | return &XGI_ExtLCD1024x768x75Data[tempal]; | |
2333 | break; | |
2334 | case 13: | |
2335 | return &XGI_ExtLCD1024x768x75Data[tempal]; | |
2336 | break; | |
2337 | case 14: | |
2338 | return &XGI_CetLCD1024x768x75Data[tempal]; | |
2339 | break; | |
2340 | case 15: | |
2341 | return &XGI_ExtLCD1280x1024x75Data[tempal]; | |
2342 | break; | |
2343 | case 16: | |
2344 | return &XGI_StLCD1280x1024x75Data[tempal]; | |
2345 | break; | |
2346 | case 17: | |
2347 | return &XGI_CetLCD1280x1024x75Data[tempal]; | |
2348 | break; | |
2349 | case 18: | |
2350 | return &XGI_NoScalingDatax75[tempal]; | |
2351 | break; | |
2352 | default: | |
2353 | break; | |
2354 | } | |
2355 | } else if (table == 5) { | |
2356 | switch (tempdi[i].DATAPTR) { | |
2357 | case 0: | |
2358 | return &XGI_ExtLCDDes1024x768Data[tempal]; | |
2359 | break; | |
2360 | case 1: | |
2361 | return &XGI_StLCDDes1024x768Data[tempal]; | |
2362 | break; | |
2363 | case 2: | |
2364 | return &XGI_CetLCDDes1024x768Data[tempal]; | |
2365 | break; | |
2366 | case 3: | |
1d7f656d KT |
2367 | if ((pVBInfo->VBType & VB_XGI301LV) || |
2368 | (pVBInfo->VBType & VB_XGI302LV)) | |
cc1e2398 | 2369 | return &XGI_ExtLCDDLDes1280x1024Data[tempal]; |
21df8fc8 | 2370 | else |
cc1e2398 AK |
2371 | return &XGI_ExtLCDDes1280x1024Data[tempal]; |
2372 | break; | |
2373 | case 4: | |
1d7f656d KT |
2374 | if ((pVBInfo->VBType & VB_XGI301LV) || |
2375 | (pVBInfo->VBType & VB_XGI302LV)) | |
cc1e2398 | 2376 | return &XGI_StLCDDLDes1280x1024Data[tempal]; |
21df8fc8 | 2377 | else |
cc1e2398 AK |
2378 | return &XGI_StLCDDes1280x1024Data[tempal]; |
2379 | break; | |
2380 | case 5: | |
1d7f656d KT |
2381 | if ((pVBInfo->VBType & VB_XGI301LV) || |
2382 | (pVBInfo->VBType & VB_XGI302LV)) | |
cc1e2398 AK |
2383 | return &XGI_CetLCDDLDes1280x1024Data[tempal]; |
2384 | else | |
2385 | return &XGI_CetLCDDes1280x1024Data[tempal]; | |
2386 | break; | |
2387 | case 6: | |
1d7f656d KT |
2388 | if ((pVBInfo->VBType & VB_XGI301LV) || |
2389 | (pVBInfo->VBType & VB_XGI302LV)) | |
cc1e2398 AK |
2390 | return &XGI_ExtLCDDLDes1400x1050Data[tempal]; |
2391 | else | |
2392 | return &XGI_ExtLCDDes1400x1050Data[tempal]; | |
2393 | break; | |
2394 | case 7: | |
1d7f656d KT |
2395 | if ((pVBInfo->VBType & VB_XGI301LV) || |
2396 | (pVBInfo->VBType & VB_XGI302LV)) | |
cc1e2398 AK |
2397 | return &XGI_StLCDDLDes1400x1050Data[tempal]; |
2398 | else | |
2399 | return &XGI_StLCDDes1400x1050Data[tempal]; | |
2400 | break; | |
2401 | case 8: | |
2402 | return &XGI_CetLCDDes1400x1050Data[tempal]; | |
2403 | break; | |
2404 | case 9: | |
2405 | return &XGI_CetLCDDes1400x1050Data2[tempal]; | |
2406 | break; | |
2407 | case 10: | |
1d7f656d KT |
2408 | if ((pVBInfo->VBType & VB_XGI301LV) || |
2409 | (pVBInfo->VBType & VB_XGI302LV)) | |
cc1e2398 AK |
2410 | return &XGI_ExtLCDDLDes1600x1200Data[tempal]; |
2411 | else | |
2412 | return &XGI_ExtLCDDes1600x1200Data[tempal]; | |
2413 | break; | |
2414 | case 11: | |
1d7f656d KT |
2415 | if ((pVBInfo->VBType & VB_XGI301LV) || |
2416 | (pVBInfo->VBType & VB_XGI302LV)) | |
cc1e2398 AK |
2417 | return &XGI_StLCDDLDes1600x1200Data[tempal]; |
2418 | else | |
2419 | return &XGI_StLCDDes1600x1200Data[tempal]; | |
2420 | break; | |
2421 | case 12: | |
2422 | return &XGI_NoScalingDesData[tempal]; | |
2423 | break; | |
2424 | case 13: | |
2425 | return &XGI_ExtLCDDes1024x768x75Data[tempal]; | |
2426 | break; | |
2427 | case 14: | |
2428 | return &XGI_StLCDDes1024x768x75Data[tempal]; | |
2429 | break; | |
2430 | case 15: | |
2431 | return &XGI_CetLCDDes1024x768x75Data[tempal]; | |
2432 | break; | |
2433 | case 16: | |
1d7f656d KT |
2434 | if ((pVBInfo->VBType & VB_XGI301LV) || |
2435 | (pVBInfo->VBType & VB_XGI302LV)) | |
cc1e2398 | 2436 | return &XGI_ExtLCDDLDes1280x1024x75Data[tempal]; |
21df8fc8 | 2437 | else |
cc1e2398 AK |
2438 | return &XGI_ExtLCDDes1280x1024x75Data[tempal]; |
2439 | break; | |
2440 | case 17: | |
1d7f656d KT |
2441 | if ((pVBInfo->VBType & VB_XGI301LV) || |
2442 | (pVBInfo->VBType & VB_XGI302LV)) | |
cc1e2398 | 2443 | return &XGI_StLCDDLDes1280x1024x75Data[tempal]; |
21df8fc8 | 2444 | else |
cc1e2398 AK |
2445 | return &XGI_StLCDDes1280x1024x75Data[tempal]; |
2446 | break; | |
2447 | case 18: | |
1d7f656d KT |
2448 | if ((pVBInfo->VBType & VB_XGI301LV) || |
2449 | (pVBInfo->VBType & VB_XGI302LV)) | |
cc1e2398 AK |
2450 | return &XGI_CetLCDDLDes1280x1024x75Data[tempal]; |
2451 | else | |
2452 | return &XGI_CetLCDDes1280x1024x75Data[tempal]; | |
2453 | break; | |
2454 | case 19: | |
2455 | return &XGI_NoScalingDesDatax75[tempal]; | |
2456 | break; | |
2457 | default: | |
2458 | break; | |
21df8fc8 | 2459 | } |
cc1e2398 AK |
2460 | } else if (table == 6) { |
2461 | switch (tempdi[i].DATAPTR) { | |
2462 | case 0: | |
2463 | return &XGI_CH7017LV1024x768[tempal]; | |
2464 | break; | |
2465 | case 1: | |
2466 | return &XGI_CH7017LV1400x1050[tempal]; | |
2467 | break; | |
2468 | default: | |
2469 | break; | |
21df8fc8 PS |
2470 | } |
2471 | } | |
cc1e2398 | 2472 | return NULL; |
d7636e0b | 2473 | } |
2474 | ||
cc1e2398 AK |
2475 | static void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo, |
2476 | unsigned short ModeIdIndex, | |
2477 | unsigned short RefreshRateTableIndex, | |
21df8fc8 PS |
2478 | struct vb_device_info *pVBInfo) |
2479 | { | |
cc1e2398 AK |
2480 | unsigned short i, tempdx, tempbx, tempal, modeflag, table; |
2481 | struct XGI330_TVDataTablStruct *tempdi = NULL; | |
21df8fc8 | 2482 | |
cc1e2398 | 2483 | tempbx = BX; |
21df8fc8 | 2484 | |
cc1e2398 AK |
2485 | if (ModeNo <= 0x13) { |
2486 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
2487 | tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; | |
2488 | } else { | |
2489 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
2490 | tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; | |
2491 | } | |
21df8fc8 | 2492 | |
cc1e2398 AK |
2493 | tempal = tempal & 0x3f; |
2494 | table = tempbx; | |
21df8fc8 | 2495 | |
cc1e2398 AK |
2496 | switch (tempbx) { |
2497 | case 0: | |
2498 | tempdi = NULL; /*EPLCHTVCRT1Ptr_H;*/ | |
2499 | if (pVBInfo->IF_DEF_CH7007 == 1) | |
2500 | tempdi = XGI_EPLCHTVCRT1Ptr; | |
21df8fc8 | 2501 | |
cc1e2398 AK |
2502 | break; |
2503 | case 1: | |
2504 | tempdi = NULL; /*EPLCHTVCRT1Ptr_V;*/ | |
2505 | if (pVBInfo->IF_DEF_CH7007 == 1) | |
2506 | tempdi = XGI_EPLCHTVCRT1Ptr; | |
21df8fc8 | 2507 | |
cc1e2398 AK |
2508 | break; |
2509 | case 2: | |
2510 | tempdi = XGI_EPLCHTVDataPtr; | |
2511 | break; | |
2512 | case 3: | |
2513 | tempdi = NULL; | |
2514 | break; | |
2515 | case 4: | |
2516 | tempdi = XGI_TVDataTable; | |
2517 | break; | |
2518 | case 5: | |
2519 | tempdi = NULL; | |
2520 | break; | |
2521 | case 6: | |
2522 | tempdi = XGI_EPLCHTVRegPtr; | |
2523 | break; | |
2524 | default: | |
2525 | break; | |
2526 | } | |
21df8fc8 | 2527 | |
cc1e2398 AK |
2528 | if (tempdi == NULL) /* OEMUtil */ |
2529 | return NULL; | |
21df8fc8 | 2530 | |
cc1e2398 | 2531 | tempdx = pVBInfo->TVInfo; |
21df8fc8 | 2532 | |
cc1e2398 AK |
2533 | if (pVBInfo->VBInfo & SetInSlaveMode) |
2534 | tempdx = tempdx | SetTVLockMode; | |
21df8fc8 | 2535 | |
cc1e2398 AK |
2536 | if (modeflag & HalfDCLK) |
2537 | tempdx = tempdx | SetTVLowResolution; | |
21df8fc8 | 2538 | |
cc1e2398 | 2539 | i = 0; |
21df8fc8 | 2540 | |
cc1e2398 AK |
2541 | while (tempdi[i].MASK != 0xffff) { |
2542 | if ((tempdx & tempdi[i].MASK) == tempdi[i].CAP) | |
2543 | break; | |
2544 | i++; | |
2545 | } | |
21df8fc8 | 2546 | |
1d7f656d KT |
2547 | /* 07/05/22 */ |
2548 | if (table == 0x00) { | |
cc1e2398 AK |
2549 | } else if (table == 0x01) { |
2550 | } else if (table == 0x04) { | |
2551 | switch (tempdi[i].DATAPTR) { | |
2552 | case 0: | |
2553 | return &XGI_ExtPALData[tempal]; | |
2554 | break; | |
2555 | case 1: | |
2556 | return &XGI_ExtNTSCData[tempal]; | |
2557 | break; | |
2558 | case 2: | |
2559 | return &XGI_StPALData[tempal]; | |
2560 | break; | |
2561 | case 3: | |
2562 | return &XGI_StNTSCData[tempal]; | |
2563 | break; | |
2564 | case 4: | |
2565 | return &XGI_ExtHiTVData[tempal]; | |
2566 | break; | |
2567 | case 5: | |
2568 | return &XGI_St2HiTVData[tempal]; | |
2569 | break; | |
2570 | case 6: | |
2571 | return &XGI_ExtYPbPr525iData[tempal]; | |
2572 | break; | |
2573 | case 7: | |
2574 | return &XGI_ExtYPbPr525pData[tempal]; | |
2575 | break; | |
2576 | case 8: | |
2577 | return &XGI_ExtYPbPr750pData[tempal]; | |
2578 | break; | |
2579 | case 9: | |
2580 | return &XGI_StYPbPr525iData[tempal]; | |
2581 | break; | |
2582 | case 10: | |
2583 | return &XGI_StYPbPr525pData[tempal]; | |
2584 | break; | |
2585 | case 11: | |
2586 | return &XGI_StYPbPr750pData[tempal]; | |
2587 | break; | |
2588 | case 12: /* avoid system hang */ | |
2589 | return &XGI_ExtNTSCData[tempal]; | |
2590 | break; | |
2591 | case 13: | |
2592 | return &XGI_St1HiTVData[tempal]; | |
2593 | break; | |
2594 | default: | |
2595 | break; | |
21df8fc8 | 2596 | } |
cc1e2398 AK |
2597 | } else if (table == 0x02) { |
2598 | switch (tempdi[i].DATAPTR) { | |
2599 | case 0: | |
2600 | return &XGI_CHTVUNTSCData[tempal]; | |
2601 | break; | |
2602 | case 1: | |
2603 | return &XGI_CHTVONTSCData[tempal]; | |
2604 | break; | |
2605 | case 2: | |
2606 | return &XGI_CHTVUPALData[tempal]; | |
2607 | break; | |
2608 | case 3: | |
2609 | return &XGI_CHTVOPALData[tempal]; | |
2610 | break; | |
2611 | default: | |
2612 | break; | |
21df8fc8 | 2613 | } |
cc1e2398 | 2614 | } else if (table == 0x06) { |
21df8fc8 | 2615 | } |
cc1e2398 | 2616 | return NULL; |
21df8fc8 | 2617 | } |
d7636e0b | 2618 | |
cc1e2398 AK |
2619 | static void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex, |
2620 | unsigned short RefreshRateTableIndex, | |
21df8fc8 PS |
2621 | struct vb_device_info *pVBInfo) |
2622 | { | |
cc1e2398 AK |
2623 | unsigned short tempbx; |
2624 | struct XGI330_LVDSDataStruct *LCDPtr = NULL; | |
d7636e0b | 2625 | |
cc1e2398 | 2626 | tempbx = 2; |
21df8fc8 | 2627 | |
cc1e2398 AK |
2628 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
2629 | LCDPtr = (struct XGI330_LVDSDataStruct *) XGI_GetLcdPtr(tempbx, | |
2630 | ModeNo, ModeIdIndex, RefreshRateTableIndex, | |
2631 | pVBInfo); | |
2632 | pVBInfo->VGAHT = LCDPtr->VGAHT; | |
2633 | pVBInfo->VGAVT = LCDPtr->VGAVT; | |
2634 | pVBInfo->HT = LCDPtr->LCDHT; | |
2635 | pVBInfo->VT = LCDPtr->LCDVT; | |
2636 | } | |
21df8fc8 | 2637 | |
cc1e2398 AK |
2638 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
2639 | if (!(pVBInfo->LCDInfo & (SetLCDtoNonExpanding | |
2640 | | EnableScalingLCD))) { | |
1d7f656d KT |
2641 | if ((pVBInfo->LCDResInfo == Panel1024x768) || |
2642 | (pVBInfo->LCDResInfo == Panel1024x768x75)) { | |
cc1e2398 AK |
2643 | pVBInfo->HDE = 1024; |
2644 | pVBInfo->VDE = 768; | |
1d7f656d KT |
2645 | } else if ((pVBInfo->LCDResInfo == Panel1280x1024) || |
2646 | (pVBInfo->LCDResInfo == Panel1280x1024x75)) { | |
cc1e2398 AK |
2647 | pVBInfo->HDE = 1280; |
2648 | pVBInfo->VDE = 1024; | |
2649 | } else if (pVBInfo->LCDResInfo == Panel1400x1050) { | |
2650 | pVBInfo->HDE = 1400; | |
2651 | pVBInfo->VDE = 1050; | |
2652 | } else { | |
2653 | pVBInfo->HDE = 1600; | |
2654 | pVBInfo->VDE = 1200; | |
21df8fc8 PS |
2655 | } |
2656 | } | |
21df8fc8 | 2657 | } |
21df8fc8 PS |
2658 | } |
2659 | ||
cc1e2398 AK |
2660 | static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex, |
2661 | unsigned short RefreshRateTableIndex, | |
21df8fc8 PS |
2662 | struct xgi_hw_device_info *HwDeviceExtension, |
2663 | struct vb_device_info *pVBInfo) | |
2664 | { | |
cc1e2398 AK |
2665 | unsigned char index; |
2666 | unsigned short tempbx, i; | |
2667 | struct XGI_LVDSCRT1HDataStruct *LCDPtr = NULL; | |
2668 | struct XGI_LVDSCRT1VDataStruct *LCDPtr1 = NULL; | |
2669 | /* struct XGI330_CHTVDataStruct *TVPtr = NULL; */ | |
2670 | struct XGI_CH7007TV_TimingHStruct *CH7007TV_TimingHPtr = NULL; | |
2671 | struct XGI_CH7007TV_TimingVStruct *CH7007TV_TimingVPtr = NULL; | |
21df8fc8 PS |
2672 | |
2673 | if (ModeNo <= 0x13) | |
cc1e2398 | 2674 | index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; |
21df8fc8 | 2675 | else |
cc1e2398 | 2676 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; |
21df8fc8 | 2677 | |
cc1e2398 | 2678 | index = index & IndexMask; |
21df8fc8 | 2679 | |
1d7f656d KT |
2680 | if ((pVBInfo->IF_DEF_ScaleLCD == 0) || |
2681 | ((pVBInfo->IF_DEF_ScaleLCD == 1) && | |
2682 | (!(pVBInfo->LCDInfo & EnableScalingLCD)))) { | |
cc1e2398 | 2683 | tempbx = 0; |
21df8fc8 | 2684 | |
cc1e2398 | 2685 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
1d7f656d KT |
2686 | LCDPtr = (struct XGI_LVDSCRT1HDataStruct *) |
2687 | XGI_GetLcdPtr(tempbx, ModeNo, | |
2688 | ModeIdIndex, | |
2689 | RefreshRateTableIndex, | |
2690 | pVBInfo); | |
21df8fc8 | 2691 | |
cc1e2398 AK |
2692 | for (i = 0; i < 8; i++) |
2693 | pVBInfo->TimingH[0].data[i] = LCDPtr[0].Reg[i]; | |
2694 | } | |
21df8fc8 | 2695 | |
cc1e2398 AK |
2696 | if (pVBInfo->IF_DEF_CH7007 == 1) { |
2697 | if (pVBInfo->VBInfo & SetCRT2ToTV) { | |
1d7f656d KT |
2698 | CH7007TV_TimingHPtr = |
2699 | (struct XGI_CH7007TV_TimingHStruct *) | |
2700 | XGI_GetTVPtr( | |
2701 | tempbx, | |
2702 | ModeNo, | |
2703 | ModeIdIndex, | |
2704 | RefreshRateTableIndex, | |
2705 | pVBInfo); | |
21df8fc8 | 2706 | |
cc1e2398 | 2707 | for (i = 0; i < 8; i++) |
1d7f656d KT |
2708 | pVBInfo->TimingH[0].data[i] = |
2709 | CH7007TV_TimingHPtr[0].data[i]; | |
21df8fc8 PS |
2710 | } |
2711 | } | |
2712 | ||
cc1e2398 | 2713 | XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension); |
21df8fc8 | 2714 | |
cc1e2398 | 2715 | if (pVBInfo->IF_DEF_CH7007 == 1) { |
8104e329 | 2716 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, |
cc1e2398 | 2717 | CH7007TV_TimingHPtr[0].data[8]); |
8104e329 | 2718 | xgifb_reg_set(pVBInfo->P3c4, 0x2F, |
cc1e2398 | 2719 | CH7007TV_TimingHPtr[0].data[9]); |
21df8fc8 PS |
2720 | } |
2721 | ||
cc1e2398 | 2722 | tempbx = 1; |
21df8fc8 | 2723 | |
cc1e2398 | 2724 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
1d7f656d KT |
2725 | LCDPtr1 = (struct XGI_LVDSCRT1VDataStruct *) |
2726 | XGI_GetLcdPtr( | |
2727 | tempbx, | |
2728 | ModeNo, | |
2729 | ModeIdIndex, | |
2730 | RefreshRateTableIndex, | |
2731 | pVBInfo); | |
cc1e2398 AK |
2732 | for (i = 0; i < 7; i++) |
2733 | pVBInfo->TimingV[0].data[i] = LCDPtr1[0].Reg[i]; | |
21df8fc8 PS |
2734 | } |
2735 | ||
cc1e2398 AK |
2736 | if (pVBInfo->IF_DEF_CH7007 == 1) { |
2737 | if (pVBInfo->VBInfo & SetCRT2ToTV) { | |
1d7f656d KT |
2738 | CH7007TV_TimingVPtr = |
2739 | (struct XGI_CH7007TV_TimingVStruct *) | |
2740 | XGI_GetTVPtr( | |
2741 | tempbx, | |
2742 | ModeNo, | |
2743 | ModeIdIndex, | |
2744 | RefreshRateTableIndex, | |
2745 | pVBInfo); | |
21df8fc8 | 2746 | |
cc1e2398 | 2747 | for (i = 0; i < 7; i++) |
1d7f656d KT |
2748 | pVBInfo->TimingV[0].data[i] = |
2749 | CH7007TV_TimingVPtr[0].data[i]; | |
21df8fc8 PS |
2750 | } |
2751 | } | |
21df8fc8 | 2752 | |
cc1e2398 | 2753 | XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo); |
21df8fc8 | 2754 | |
cc1e2398 | 2755 | if (pVBInfo->IF_DEF_CH7007 == 1) { |
ec9e5d3e | 2756 | xgifb_reg_and_or(pVBInfo->P3c4, 0x33, ~0x01, |
cc1e2398 | 2757 | CH7007TV_TimingVPtr[0].data[7] & 0x01); |
8104e329 | 2758 | xgifb_reg_set(pVBInfo->P3c4, 0x34, |
cc1e2398 | 2759 | CH7007TV_TimingVPtr[0].data[8]); |
8104e329 | 2760 | xgifb_reg_set(pVBInfo->P3c4, 0x3F, |
cc1e2398 | 2761 | CH7007TV_TimingVPtr[0].data[9]); |
21df8fc8 | 2762 | |
21df8fc8 | 2763 | } |
cc1e2398 AK |
2764 | } |
2765 | } | |
21df8fc8 | 2766 | |
cc1e2398 AK |
2767 | static unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo) |
2768 | { | |
2769 | unsigned char tempal, tempah, tempbl, i; | |
2770 | ||
58839b01 | 2771 | tempah = xgifb_reg_get(pVBInfo->P3d4, 0x36); |
cc1e2398 AK |
2772 | tempal = tempah & 0x0F; |
2773 | tempah = tempah & 0xF0; | |
2774 | i = 0; | |
2775 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; | |
21df8fc8 | 2776 | |
cc1e2398 AK |
2777 | while (tempbl != 0xFF) { |
2778 | if (tempbl & 0x80) { /* OEMUtil */ | |
2779 | tempal = tempah; | |
2780 | tempbl = tempbl & ~(0x80); | |
21df8fc8 PS |
2781 | } |
2782 | ||
cc1e2398 AK |
2783 | if (tempal == tempbl) |
2784 | break; | |
21df8fc8 | 2785 | |
cc1e2398 | 2786 | i++; |
21df8fc8 | 2787 | |
cc1e2398 | 2788 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
21df8fc8 PS |
2789 | } |
2790 | ||
cc1e2398 | 2791 | return i; |
21df8fc8 PS |
2792 | } |
2793 | ||
cc1e2398 | 2794 | static unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo) |
21df8fc8 | 2795 | { |
cc1e2398 | 2796 | unsigned short tempah, tempal, tempbl, i; |
21df8fc8 | 2797 | |
cc1e2398 AK |
2798 | tempal = pVBInfo->LCDResInfo; |
2799 | tempah = pVBInfo->LCDTypeInfo; | |
21df8fc8 | 2800 | |
cc1e2398 AK |
2801 | i = 0; |
2802 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; | |
21df8fc8 | 2803 | |
cc1e2398 AK |
2804 | while (tempbl != 0xFF) { |
2805 | if ((tempbl & 0x80) && (tempbl != 0x80)) { | |
2806 | tempal = tempah; | |
2807 | tempbl &= ~0x80; | |
21df8fc8 PS |
2808 | } |
2809 | ||
cc1e2398 AK |
2810 | if (tempal == tempbl) |
2811 | break; | |
21df8fc8 | 2812 | |
cc1e2398 AK |
2813 | i++; |
2814 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; | |
2815 | } | |
21df8fc8 | 2816 | |
cc1e2398 AK |
2817 | if (tempbl == 0xFF) { |
2818 | pVBInfo->LCDResInfo = Panel1024x768; | |
2819 | pVBInfo->LCDTypeInfo = 0; | |
2820 | i = 0; | |
2821 | } | |
21df8fc8 | 2822 | |
cc1e2398 AK |
2823 | return i; |
2824 | } | |
21df8fc8 | 2825 | |
1d7f656d KT |
2826 | static void XGI_GetLCDSync(unsigned short *HSyncWidth, |
2827 | unsigned short *VSyncWidth, | |
2828 | struct vb_device_info *pVBInfo) | |
cc1e2398 AK |
2829 | { |
2830 | unsigned short Index; | |
21df8fc8 | 2831 | |
cc1e2398 AK |
2832 | Index = XGI_GetLCDCapPtr(pVBInfo); |
2833 | *HSyncWidth = pVBInfo->LCDCapList[Index].LCD_HSyncWidth; | |
2834 | *VSyncWidth = pVBInfo->LCDCapList[Index].LCD_VSyncWidth; | |
21df8fc8 | 2835 | |
cc1e2398 AK |
2836 | return; |
2837 | } | |
21df8fc8 | 2838 | |
cc1e2398 AK |
2839 | static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex, |
2840 | unsigned short RefreshRateTableIndex, | |
2841 | struct vb_device_info *pVBInfo) | |
2842 | { | |
2843 | unsigned short tempbx, tempax, tempcx, tempdx, push1, push2, modeflag; | |
2844 | unsigned long temp, temp1, temp2, temp3, push3; | |
2845 | struct XGI330_LCDDataDesStruct *LCDPtr = NULL; | |
2846 | struct XGI330_LCDDataDesStruct2 *LCDPtr1 = NULL; | |
21df8fc8 | 2847 | |
cc1e2398 AK |
2848 | if (ModeNo > 0x13) |
2849 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
2850 | else | |
2851 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
21df8fc8 | 2852 | |
cc1e2398 | 2853 | if (!(pVBInfo->SetFlag & Win9xDOSMode)) { |
a35cd0ba AK |
2854 | if (pVBInfo->IF_DEF_OEMUtil == 1) { |
2855 | tempbx = 8; | |
2856 | LCDPtr = (struct XGI330_LCDDataDesStruct *) | |
2857 | XGI_GetLcdPtr(tempbx, | |
2858 | ModeNo, | |
2859 | ModeIdIndex, | |
2860 | RefreshRateTableIndex, | |
2861 | pVBInfo); | |
2862 | } | |
2863 | ||
2864 | if ((pVBInfo->IF_DEF_OEMUtil == 0) || | |
2865 | (LCDPtr == NULL)) { | |
2866 | tempbx = 3; | |
2867 | if (pVBInfo->LCDInfo & EnableScalingLCD) | |
2868 | LCDPtr1 = | |
2869 | (struct XGI330_LCDDataDesStruct2 *) | |
2870 | XGI_GetLcdPtr( | |
2871 | tempbx, | |
2872 | ModeNo, | |
2873 | ModeIdIndex, | |
2874 | RefreshRateTableIndex, | |
2875 | pVBInfo); | |
2876 | else | |
2877 | LCDPtr = | |
2878 | (struct XGI330_LCDDataDesStruct *) | |
2879 | XGI_GetLcdPtr( | |
2880 | tempbx, | |
2881 | ModeNo, | |
2882 | ModeIdIndex, | |
2883 | RefreshRateTableIndex, | |
2884 | pVBInfo); | |
2885 | } | |
21df8fc8 | 2886 | |
a35cd0ba AK |
2887 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); |
2888 | push1 = tempbx; | |
2889 | push2 = tempax; | |
21df8fc8 | 2890 | |
a35cd0ba AK |
2891 | /* GetLCDResInfo */ |
2892 | if ((pVBInfo->LCDResInfo == Panel1024x768) || | |
2893 | (pVBInfo->LCDResInfo == Panel1024x768x75)) { | |
2894 | tempax = 1024; | |
2895 | tempbx = 768; | |
2896 | } else if ((pVBInfo->LCDResInfo == Panel1280x1024) || | |
2897 | (pVBInfo->LCDResInfo == Panel1280x1024x75)) { | |
2898 | tempax = 1280; | |
2899 | tempbx = 1024; | |
2900 | } else if (pVBInfo->LCDResInfo == Panel1400x1050) { | |
2901 | tempax = 1400; | |
2902 | tempbx = 1050; | |
2903 | } else { | |
2904 | tempax = 1600; | |
2905 | tempbx = 1200; | |
2906 | } | |
cc1e2398 | 2907 | |
a35cd0ba AK |
2908 | if (pVBInfo->LCDInfo & SetLCDtoNonExpanding) { |
2909 | pVBInfo->HDE = tempax; | |
2910 | pVBInfo->VDE = tempbx; | |
2911 | pVBInfo->VGAHDE = tempax; | |
2912 | pVBInfo->VGAVDE = tempbx; | |
2913 | } | |
cc1e2398 | 2914 | |
a35cd0ba AK |
2915 | if ((pVBInfo->IF_DEF_ScaleLCD == 1) && |
2916 | (pVBInfo->LCDInfo & EnableScalingLCD)) { | |
2917 | tempax = pVBInfo->HDE; | |
2918 | tempbx = pVBInfo->VDE; | |
2919 | } | |
21df8fc8 | 2920 | |
a35cd0ba | 2921 | tempax = pVBInfo->HT; |
21df8fc8 | 2922 | |
a35cd0ba AK |
2923 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
2924 | tempbx = LCDPtr1->LCDHDES; | |
2925 | else | |
2926 | tempbx = LCDPtr->LCDHDES; | |
21df8fc8 | 2927 | |
a35cd0ba AK |
2928 | tempcx = pVBInfo->HDE; |
2929 | tempbx = tempbx & 0x0fff; | |
2930 | tempcx += tempbx; | |
21df8fc8 | 2931 | |
a35cd0ba AK |
2932 | if (tempcx >= tempax) |
2933 | tempcx -= tempax; | |
21df8fc8 | 2934 | |
a35cd0ba | 2935 | xgifb_reg_set(pVBInfo->Part1Port, 0x1A, tempbx & 0x07); |
21df8fc8 | 2936 | |
a35cd0ba AK |
2937 | tempcx = tempcx >> 3; |
2938 | tempbx = tempbx >> 3; | |
cc1e2398 | 2939 | |
a35cd0ba AK |
2940 | xgifb_reg_set(pVBInfo->Part1Port, 0x16, |
2941 | (unsigned short) (tempbx & 0xff)); | |
2942 | xgifb_reg_set(pVBInfo->Part1Port, 0x17, | |
2943 | (unsigned short) (tempcx & 0xff)); | |
cc1e2398 | 2944 | |
a35cd0ba | 2945 | tempax = pVBInfo->HT; |
cc1e2398 | 2946 | |
a35cd0ba AK |
2947 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
2948 | tempbx = LCDPtr1->LCDHRS; | |
2949 | else | |
2950 | tempbx = LCDPtr->LCDHRS; | |
21df8fc8 | 2951 | |
a35cd0ba | 2952 | tempcx = push2; |
21df8fc8 | 2953 | |
a35cd0ba AK |
2954 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
2955 | tempcx = LCDPtr1->LCDHSync; | |
21df8fc8 | 2956 | |
a35cd0ba | 2957 | tempcx += tempbx; |
21df8fc8 | 2958 | |
a35cd0ba AK |
2959 | if (tempcx >= tempax) |
2960 | tempcx -= tempax; | |
21df8fc8 | 2961 | |
a35cd0ba AK |
2962 | tempax = tempbx & 0x07; |
2963 | tempax = tempax >> 5; | |
2964 | tempcx = tempcx >> 3; | |
2965 | tempbx = tempbx >> 3; | |
21df8fc8 | 2966 | |
a35cd0ba AK |
2967 | tempcx &= 0x1f; |
2968 | tempax |= tempcx; | |
21df8fc8 | 2969 | |
a35cd0ba AK |
2970 | xgifb_reg_set(pVBInfo->Part1Port, 0x15, tempax); |
2971 | xgifb_reg_set(pVBInfo->Part1Port, 0x14, | |
2972 | (unsigned short) (tempbx & 0xff)); | |
21df8fc8 | 2973 | |
a35cd0ba AK |
2974 | tempax = pVBInfo->VT; |
2975 | if (pVBInfo->LCDInfo & EnableScalingLCD) | |
2976 | tempbx = LCDPtr1->LCDVDES; | |
2977 | else | |
2978 | tempbx = LCDPtr->LCDVDES; | |
2979 | tempcx = pVBInfo->VDE; | |
21df8fc8 | 2980 | |
a35cd0ba AK |
2981 | tempbx = tempbx & 0x0fff; |
2982 | tempcx += tempbx; | |
2983 | if (tempcx >= tempax) | |
2984 | tempcx -= tempax; | |
21df8fc8 | 2985 | |
a35cd0ba AK |
2986 | xgifb_reg_set(pVBInfo->Part1Port, 0x1b, |
2987 | (unsigned short) (tempbx & 0xff)); | |
2988 | xgifb_reg_set(pVBInfo->Part1Port, 0x1c, | |
2989 | (unsigned short) (tempcx & 0xff)); | |
21df8fc8 | 2990 | |
a35cd0ba AK |
2991 | tempbx = (tempbx >> 8) & 0x07; |
2992 | tempcx = (tempcx >> 8) & 0x07; | |
21df8fc8 | 2993 | |
a35cd0ba AK |
2994 | xgifb_reg_set(pVBInfo->Part1Port, 0x1d, |
2995 | (unsigned short) ((tempcx << 3) | |
2996 | | tempbx)); | |
21df8fc8 | 2997 | |
a35cd0ba AK |
2998 | tempax = pVBInfo->VT; |
2999 | if (pVBInfo->LCDInfo & EnableScalingLCD) | |
3000 | tempbx = LCDPtr1->LCDVRS; | |
3001 | else | |
3002 | tempbx = LCDPtr->LCDVRS; | |
21df8fc8 | 3003 | |
a35cd0ba AK |
3004 | /* tempbx = tempbx >> 4; */ |
3005 | tempcx = push1; | |
21df8fc8 | 3006 | |
a35cd0ba AK |
3007 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
3008 | tempcx = LCDPtr1->LCDVSync; | |
21df8fc8 | 3009 | |
a35cd0ba AK |
3010 | tempcx += tempbx; |
3011 | if (tempcx >= tempax) | |
3012 | tempcx -= tempax; | |
21df8fc8 | 3013 | |
a35cd0ba AK |
3014 | xgifb_reg_set(pVBInfo->Part1Port, 0x18, |
3015 | (unsigned short) (tempbx & 0xff)); | |
3016 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, ~0x0f, | |
3017 | (unsigned short) (tempcx & 0x0f)); | |
21df8fc8 | 3018 | |
a35cd0ba | 3019 | tempax = ((tempbx >> 8) & 0x07) << 3; |
21df8fc8 | 3020 | |
a35cd0ba AK |
3021 | tempbx = pVBInfo->VGAVDE; |
3022 | if (tempbx != pVBInfo->VDE) | |
3023 | tempax |= 0x40; | |
21df8fc8 | 3024 | |
a35cd0ba AK |
3025 | if (pVBInfo->LCDInfo & EnableLVDSDDA) |
3026 | tempax |= 0x40; | |
21df8fc8 | 3027 | |
a35cd0ba | 3028 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1a, 0x07, |
cc1e2398 | 3029 | tempax); |
21df8fc8 | 3030 | |
a35cd0ba AK |
3031 | tempcx = pVBInfo->VGAVT; |
3032 | tempbx = pVBInfo->VDE; | |
3033 | tempax = pVBInfo->VGAVDE; | |
3034 | tempcx -= tempax; | |
21df8fc8 | 3035 | |
a35cd0ba AK |
3036 | temp = tempax; /* 0430 ylshieh */ |
3037 | temp1 = (temp << 18) / tempbx; | |
21df8fc8 | 3038 | |
a35cd0ba | 3039 | tempdx = (unsigned short) ((temp << 18) % tempbx); |
21df8fc8 | 3040 | |
a35cd0ba AK |
3041 | if (tempdx != 0) |
3042 | temp1 += 1; | |
cc1e2398 | 3043 | |
a35cd0ba AK |
3044 | temp2 = temp1; |
3045 | push3 = temp2; | |
cc1e2398 | 3046 | |
a35cd0ba AK |
3047 | xgifb_reg_set(pVBInfo->Part1Port, 0x37, |
3048 | (unsigned short) (temp2 & 0xff)); | |
3049 | xgifb_reg_set(pVBInfo->Part1Port, 0x36, | |
3050 | (unsigned short) ((temp2 >> 8) & 0xff)); | |
21df8fc8 | 3051 | |
a35cd0ba AK |
3052 | tempbx = (unsigned short) (temp2 >> 16); |
3053 | tempax = tempbx & 0x03; | |
d7636e0b | 3054 | |
a35cd0ba AK |
3055 | tempbx = pVBInfo->VGAVDE; |
3056 | if (tempbx == pVBInfo->VDE) | |
3057 | tempax |= 0x04; | |
21df8fc8 | 3058 | |
a35cd0ba | 3059 | xgifb_reg_set(pVBInfo->Part1Port, 0x35, tempax); |
21df8fc8 | 3060 | |
a35cd0ba AK |
3061 | if (pVBInfo->VBType & VB_XGI301C) { |
3062 | temp2 = push3; | |
3063 | xgifb_reg_set(pVBInfo->Part4Port, | |
3064 | 0x3c, | |
3065 | (unsigned short) (temp2 & 0xff)); | |
3066 | xgifb_reg_set(pVBInfo->Part4Port, | |
3067 | 0x3b, | |
3068 | (unsigned short) ((temp2 >> 8) & | |
3069 | 0xff)); | |
3070 | tempbx = (unsigned short) (temp2 >> 16); | |
3071 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x3a, | |
3072 | ~0xc0, | |
3073 | (unsigned short) ((tempbx & | |
3074 | 0xff) << 6)); | |
3075 | ||
3076 | tempcx = pVBInfo->VGAVDE; | |
3077 | if (tempcx == pVBInfo->VDE) | |
3078 | xgifb_reg_and_or(pVBInfo->Part4Port, | |
3079 | 0x30, ~0x0c, 0x00); | |
3080 | else | |
3081 | xgifb_reg_and_or(pVBInfo->Part4Port, | |
3082 | 0x30, ~0x0c, 0x08); | |
3083 | } | |
21df8fc8 | 3084 | |
a35cd0ba AK |
3085 | tempcx = pVBInfo->VGAHDE; |
3086 | tempbx = pVBInfo->HDE; | |
21df8fc8 | 3087 | |
a35cd0ba | 3088 | temp1 = tempcx << 16; |
d7636e0b | 3089 | |
a35cd0ba | 3090 | tempax = (unsigned short) (temp1 / tempbx); |
21df8fc8 | 3091 | |
a35cd0ba AK |
3092 | if ((tempbx & 0xffff) == (tempcx & 0xffff)) |
3093 | tempax = 65535; | |
21df8fc8 | 3094 | |
a35cd0ba AK |
3095 | temp3 = tempax; |
3096 | temp1 = pVBInfo->VGAHDE << 16; | |
d7636e0b | 3097 | |
a35cd0ba AK |
3098 | temp1 /= temp3; |
3099 | temp3 = temp3 << 16; | |
3100 | temp1 -= 1; | |
21df8fc8 | 3101 | |
a35cd0ba | 3102 | temp3 = (temp3 & 0xffff0000) + (temp1 & 0xffff); |
d7636e0b | 3103 | |
a35cd0ba AK |
3104 | tempax = (unsigned short) (temp3 & 0xff); |
3105 | xgifb_reg_set(pVBInfo->Part1Port, 0x1f, tempax); | |
d7636e0b | 3106 | |
a35cd0ba AK |
3107 | temp1 = pVBInfo->VGAVDE << 18; |
3108 | temp1 = temp1 / push3; | |
3109 | tempbx = (unsigned short) (temp1 & 0xffff); | |
21df8fc8 | 3110 | |
a35cd0ba AK |
3111 | if (pVBInfo->LCDResInfo == Panel1024x768) |
3112 | tempbx -= 1; | |
21df8fc8 | 3113 | |
a35cd0ba AK |
3114 | tempax = ((tempbx >> 8) & 0xff) << 3; |
3115 | tempax |= (unsigned short) ((temp3 >> 8) & 0x07); | |
3116 | xgifb_reg_set(pVBInfo->Part1Port, 0x20, | |
3117 | (unsigned short) (tempax & 0xff)); | |
3118 | xgifb_reg_set(pVBInfo->Part1Port, 0x21, | |
3119 | (unsigned short) (tempbx & 0xff)); | |
21df8fc8 | 3120 | |
a35cd0ba AK |
3121 | temp3 = temp3 >> 16; |
3122 | ||
3123 | if (modeflag & HalfDCLK) | |
3124 | temp3 = temp3 >> 1; | |
3125 | ||
3126 | xgifb_reg_set(pVBInfo->Part1Port, 0x22, | |
3127 | (unsigned short) ((temp3 >> 8) & 0xff)); | |
3128 | xgifb_reg_set(pVBInfo->Part1Port, 0x23, | |
3129 | (unsigned short) (temp3 & 0xff)); | |
21df8fc8 PS |
3130 | } |
3131 | } | |
d7636e0b | 3132 | |
cc1e2398 AK |
3133 | /* --------------------------------------------------------------------- */ |
3134 | /* Function : XGI_GETLCDVCLKPtr */ | |
3135 | /* Input : */ | |
3136 | /* Output : al -> VCLK Index */ | |
3137 | /* Description : */ | |
3138 | /* --------------------------------------------------------------------- */ | |
3139 | static void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1, | |
21df8fc8 PS |
3140 | struct vb_device_info *pVBInfo) |
3141 | { | |
cc1e2398 | 3142 | unsigned short index; |
d7636e0b | 3143 | |
cc1e2398 AK |
3144 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
3145 | if (pVBInfo->IF_DEF_ScaleLCD == 1) { | |
3146 | if (pVBInfo->LCDInfo & EnableScalingLCD) | |
3147 | return; | |
21df8fc8 | 3148 | } |
d7636e0b | 3149 | |
cc1e2398 AK |
3150 | /* index = XGI_GetLCDCapPtr(pVBInfo); */ |
3151 | index = XGI_GetLCDCapPtr1(pVBInfo); | |
d7636e0b | 3152 | |
cc1e2398 AK |
3153 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { /* LCDB */ |
3154 | *di_0 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData1; | |
3155 | *di_1 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData2; | |
3156 | } else { /* LCDA */ | |
3157 | *di_0 = pVBInfo->LCDCapList[index].LCDA_VCLKData1; | |
3158 | *di_1 = pVBInfo->LCDCapList[index].LCDA_VCLKData2; | |
21df8fc8 | 3159 | } |
21df8fc8 | 3160 | } |
cc1e2398 | 3161 | return; |
d7636e0b | 3162 | } |
3163 | ||
cc1e2398 AK |
3164 | static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex, |
3165 | unsigned short ModeNo, unsigned short ModeIdIndex, | |
3166 | struct vb_device_info *pVBInfo) | |
d7636e0b | 3167 | { |
d7636e0b | 3168 | |
cc1e2398 AK |
3169 | unsigned short index, modeflag; |
3170 | unsigned short tempbx; | |
3171 | unsigned char tempal; | |
3172 | unsigned char *CHTVVCLKPtr = NULL; | |
d7636e0b | 3173 | |
cc1e2398 | 3174 | if (ModeNo <= 0x13) |
1d7f656d KT |
3175 | /* si+St_ResInfo */ |
3176 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
cc1e2398 | 3177 | else |
1d7f656d KT |
3178 | /* si+Ext_ResInfo */ |
3179 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
d7636e0b | 3180 | |
1d7f656d KT |
3181 | if ((pVBInfo->SetFlag & ProgrammingCRT2) && |
3182 | (!(pVBInfo->LCDInfo & EnableScalingLCD))) { /* {LCDA/LCDB} */ | |
cc1e2398 AK |
3183 | index = XGI_GetLCDCapPtr(pVBInfo); |
3184 | tempal = pVBInfo->LCDCapList[index].LCD_VCLK; | |
d7636e0b | 3185 | |
cc1e2398 AK |
3186 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) |
3187 | return tempal; | |
d7636e0b | 3188 | |
cc1e2398 | 3189 | /* {TV} */ |
1d7f656d KT |
3190 | if (pVBInfo->VBType & |
3191 | (VB_XGI301B | | |
3192 | VB_XGI302B | | |
3193 | VB_XGI301LV | | |
3194 | VB_XGI302LV | | |
3195 | VB_XGI301C)) { | |
cc1e2398 AK |
3196 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
3197 | tempal = HiTVVCLKDIV2; | |
3198 | if (!(pVBInfo->TVInfo & RPLLDIV2XO)) | |
3199 | tempal = HiTVVCLK; | |
3200 | if (pVBInfo->TVInfo & TVSimuMode) { | |
3201 | tempal = HiTVSimuVCLK; | |
3202 | if (!(modeflag & Charx8Dot)) | |
3203 | tempal = HiTVTextVCLK; | |
d7636e0b | 3204 | |
cc1e2398 AK |
3205 | } |
3206 | return tempal; | |
3207 | } | |
d7636e0b | 3208 | |
cc1e2398 AK |
3209 | if (pVBInfo->TVInfo & SetYPbPrMode750p) { |
3210 | tempal = YPbPr750pVCLK; | |
3211 | return tempal; | |
3212 | } | |
d7636e0b | 3213 | |
cc1e2398 AK |
3214 | if (pVBInfo->TVInfo & SetYPbPrMode525p) { |
3215 | tempal = YPbPr525pVCLK; | |
3216 | return tempal; | |
3217 | } | |
d7636e0b | 3218 | |
cc1e2398 | 3219 | tempal = NTSC1024VCLK; |
d7636e0b | 3220 | |
cc1e2398 AK |
3221 | if (!(pVBInfo->TVInfo & NTSC1024x768)) { |
3222 | tempal = TVVCLKDIV2; | |
3223 | if (!(pVBInfo->TVInfo & RPLLDIV2XO)) | |
3224 | tempal = TVVCLK; | |
3225 | } | |
d7636e0b | 3226 | |
cc1e2398 AK |
3227 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
3228 | return tempal; | |
3229 | } | |
cc1e2398 | 3230 | } /* {End of VB} */ |
d7636e0b | 3231 | |
1d7f656d KT |
3232 | if ((pVBInfo->IF_DEF_CH7007 == 1) && |
3233 | (pVBInfo->VBType & VB_CH7007)) { /* [Billy] 07/05/08 CH7007 */ | |
3234 | /* VideoDebugPrint(( | |
3235 | 0, | |
3236 | "XGI_GetVCLKPtr: pVBInfo->IF_DEF_CH7007==1\n")); */ | |
cc1e2398 AK |
3237 | if ((pVBInfo->VBInfo & SetCRT2ToTV)) { |
3238 | if (ModeNo <= 0x13) { | |
1d7f656d KT |
3239 | tempal = pVBInfo->SModeIDTable[ModeIdIndex]. |
3240 | St_CRT2CRTC; | |
cc1e2398 | 3241 | } else { |
1d7f656d KT |
3242 | tempal = pVBInfo->RefIndex[ |
3243 | RefreshRateTableIndex].Ext_CRT2CRTC; | |
cc1e2398 | 3244 | } |
d7636e0b | 3245 | |
cc1e2398 AK |
3246 | tempal = tempal & 0x0F; |
3247 | tempbx = 0; | |
d7636e0b | 3248 | |
cc1e2398 AK |
3249 | if (pVBInfo->TVInfo & SetPALTV) |
3250 | tempbx = tempbx + 2; | |
d7636e0b | 3251 | |
cc1e2398 AK |
3252 | if (pVBInfo->TVInfo & SetCHTVOverScan) |
3253 | tempbx++; | |
d7636e0b | 3254 | |
cc1e2398 | 3255 | /** tempbx = tempbx << 1; CH7007 ? **/ |
d7636e0b | 3256 | |
cc1e2398 AK |
3257 | /* [Billy]07/05/29 CH7007 */ |
3258 | if (pVBInfo->IF_DEF_CH7007 == 1) { | |
3259 | switch (tempbx) { | |
3260 | case 0: | |
3261 | CHTVVCLKPtr = XGI7007_CHTVVCLKUNTSC; | |
3262 | break; | |
3263 | case 1: | |
3264 | CHTVVCLKPtr = XGI7007_CHTVVCLKONTSC; | |
3265 | break; | |
3266 | case 2: | |
3267 | CHTVVCLKPtr = XGI7007_CHTVVCLKUPAL; | |
3268 | break; | |
3269 | case 3: | |
3270 | CHTVVCLKPtr = XGI7007_CHTVVCLKOPAL; | |
3271 | break; | |
3272 | default: | |
3273 | break; | |
d7636e0b | 3274 | |
cc1e2398 AK |
3275 | } |
3276 | } | |
3277 | /* else { | |
3278 | switch(tempbx) { | |
3279 | case 0: | |
3280 | CHTVVCLKPtr = pVBInfo->CHTVVCLKUNTSC; | |
3281 | break; | |
3282 | case 1: | |
3283 | CHTVVCLKPtr = pVBInfo->CHTVVCLKONTSC; | |
3284 | break; | |
3285 | case 2: | |
3286 | CHTVVCLKPtr = pVBInfo->CHTVVCLKUPAL; | |
3287 | break; | |
3288 | case 3: | |
3289 | CHTVVCLKPtr = pVBInfo->CHTVVCLKOPAL; | |
3290 | break; | |
3291 | default: | |
3292 | break; | |
3293 | } | |
3294 | } | |
3295 | */ | |
d7636e0b | 3296 | |
cc1e2398 AK |
3297 | tempal = CHTVVCLKPtr[tempal]; |
3298 | return tempal; | |
3299 | } | |
d7636e0b | 3300 | |
21df8fc8 | 3301 | } |
d7636e0b | 3302 | |
d8ad0a6d | 3303 | tempal = (unsigned char) inb((pVBInfo->P3ca + 0x02)); |
cc1e2398 AK |
3304 | tempal = tempal >> 2; |
3305 | tempal &= 0x03; | |
d7636e0b | 3306 | |
1d7f656d KT |
3307 | /* for Dot8 Scaling LCD */ |
3308 | if ((pVBInfo->LCDInfo & EnableScalingLCD) && (modeflag & Charx8Dot)) | |
cc1e2398 AK |
3309 | tempal = tempal ^ tempal; /* ; set to VCLK25MHz always */ |
3310 | ||
3311 | if (ModeNo <= 0x13) | |
3312 | return tempal; | |
3313 | ||
3314 | tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; | |
3315 | return tempal; | |
d7636e0b | 3316 | } |
3317 | ||
cc1e2398 AK |
3318 | static void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0, |
3319 | unsigned char *di_1, struct vb_device_info *pVBInfo) | |
d7636e0b | 3320 | { |
cc1e2398 | 3321 | if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 2007/05/16 */ |
1d7f656d KT |
3322 | /* VideoDebugPrint(( |
3323 | 0, | |
3324 | "XGI_GetVCLKLen: pVBInfo->IF_DEF_CH7007==1\n")); */ | |
cc1e2398 AK |
3325 | *di_0 = (unsigned char) XGI_CH7007VCLKData[tempal].SR2B; |
3326 | *di_1 = (unsigned char) XGI_CH7007VCLKData[tempal].SR2C; | |
3327 | } else if (pVBInfo->VBType & (VB_XGI301 | VB_XGI301B | VB_XGI302B | |
3328 | | VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) { | |
3329 | if ((!(pVBInfo->VBInfo & SetCRT2ToLCDA)) && (pVBInfo->SetFlag | |
3330 | & ProgrammingCRT2)) { | |
3331 | *di_0 = (unsigned char) XGI_VBVCLKData[tempal].SR2B; | |
3332 | *di_1 = XGI_VBVCLKData[tempal].SR2C; | |
3333 | } | |
3334 | } else { | |
3335 | *di_0 = XGI_VCLKData[tempal].SR2B; | |
3336 | *di_1 = XGI_VCLKData[tempal].SR2C; | |
3337 | } | |
d7636e0b | 3338 | } |
d7636e0b | 3339 | |
cc1e2398 AK |
3340 | static void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex, |
3341 | unsigned short RefreshRateTableIndex, | |
21df8fc8 PS |
3342 | struct vb_device_info *pVBInfo) |
3343 | { | |
cc1e2398 AK |
3344 | unsigned char di_0, di_1, tempal; |
3345 | int i; | |
21df8fc8 | 3346 | |
cc1e2398 AK |
3347 | tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex, |
3348 | pVBInfo); | |
3349 | XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo); | |
3350 | XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo); | |
3351 | ||
3352 | for (i = 0; i < 4; i++) { | |
ec9e5d3e | 3353 | xgifb_reg_and_or(pVBInfo->P3d4, 0x31, ~0x30, |
cc1e2398 AK |
3354 | (unsigned short) (0x10 * i)); |
3355 | if (pVBInfo->IF_DEF_CH7007 == 1) { | |
8104e329 AK |
3356 | xgifb_reg_set(pVBInfo->P3c4, 0x2b, di_0); |
3357 | xgifb_reg_set(pVBInfo->P3c4, 0x2c, di_1); | |
cc1e2398 AK |
3358 | } else if ((!(pVBInfo->VBInfo & SetCRT2ToLCDA)) |
3359 | && (!(pVBInfo->VBInfo & SetInSlaveMode))) { | |
8104e329 AK |
3360 | xgifb_reg_set(pVBInfo->P3c4, 0x2e, di_0); |
3361 | xgifb_reg_set(pVBInfo->P3c4, 0x2f, di_1); | |
cc1e2398 | 3362 | } else { |
8104e329 AK |
3363 | xgifb_reg_set(pVBInfo->P3c4, 0x2b, di_0); |
3364 | xgifb_reg_set(pVBInfo->P3c4, 0x2c, di_1); | |
cc1e2398 AK |
3365 | } |
3366 | } | |
d7636e0b | 3367 | } |
3368 | ||
cc1e2398 AK |
3369 | static void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension, |
3370 | struct vb_device_info *pVBInfo) | |
d7636e0b | 3371 | { |
cc1e2398 | 3372 | unsigned short tempcl, tempch, temp, tempbl, tempax; |
d7636e0b | 3373 | |
cc1e2398 AK |
3374 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
3375 | | VB_XGI302LV | VB_XGI301C)) { | |
3376 | tempcl = 0; | |
3377 | tempch = 0; | |
58839b01 | 3378 | temp = xgifb_reg_get(pVBInfo->P3c4, 0x01); |
21df8fc8 | 3379 | |
cc1e2398 | 3380 | if (!(temp & 0x20)) { |
58839b01 | 3381 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x17); |
cc1e2398 | 3382 | if (temp & 0x80) { |
58839b01 | 3383 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x53); |
cc1e2398 AK |
3384 | if (!(temp & 0x40)) |
3385 | tempcl |= ActiveCRT1; | |
3386 | } | |
3387 | } | |
21df8fc8 | 3388 | |
58839b01 | 3389 | temp = xgifb_reg_get(pVBInfo->Part1Port, 0x2e); |
cc1e2398 | 3390 | temp &= 0x0f; |
21df8fc8 | 3391 | |
cc1e2398 | 3392 | if (!(temp == 0x08)) { |
1d7f656d KT |
3393 | /* Check ChannelA by Part1_13 [2003/10/03] */ |
3394 | tempax = xgifb_reg_get(pVBInfo->Part1Port, 0x13); | |
cc1e2398 AK |
3395 | if (tempax & 0x04) |
3396 | tempcl = tempcl | ActiveLCD; | |
21df8fc8 | 3397 | |
cc1e2398 | 3398 | temp &= 0x05; |
d7636e0b | 3399 | |
cc1e2398 AK |
3400 | if (!(tempcl & ActiveLCD)) |
3401 | if (temp == 0x01) | |
3402 | tempcl |= ActiveCRT2; | |
3403 | ||
3404 | if (temp == 0x04) | |
3405 | tempcl |= ActiveLCD; | |
3406 | ||
3407 | if (temp == 0x05) { | |
58839b01 | 3408 | temp = xgifb_reg_get(pVBInfo->Part2Port, 0x00); |
cc1e2398 AK |
3409 | |
3410 | if (!(temp & 0x08)) | |
3411 | tempch |= ActiveAVideo; | |
3412 | ||
3413 | if (!(temp & 0x04)) | |
3414 | tempch |= ActiveSVideo; | |
3415 | ||
3416 | if (temp & 0x02) | |
3417 | tempch |= ActiveSCART; | |
3418 | ||
3419 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { | |
3420 | if (temp & 0x01) | |
3421 | tempch |= ActiveHiTV; | |
21df8fc8 | 3422 | } |
21df8fc8 | 3423 | |
cc1e2398 | 3424 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { |
58839b01 | 3425 | temp = xgifb_reg_get( |
cc1e2398 AK |
3426 | pVBInfo->Part2Port, |
3427 | 0x4d); | |
21df8fc8 | 3428 | |
cc1e2398 AK |
3429 | if (temp & 0x10) |
3430 | tempch |= ActiveYPbPr; | |
21df8fc8 | 3431 | } |
cc1e2398 AK |
3432 | |
3433 | if (tempch != 0) | |
3434 | tempcl |= ActiveTV; | |
21df8fc8 | 3435 | } |
cc1e2398 | 3436 | } |
21df8fc8 | 3437 | |
58839b01 | 3438 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x3d); |
cc1e2398 AK |
3439 | if (tempcl & ActiveLCD) { |
3440 | if ((pVBInfo->SetFlag & ReserveTVOption)) { | |
3441 | if (temp & ActiveTV) | |
3442 | tempcl |= ActiveTV; | |
21df8fc8 PS |
3443 | } |
3444 | } | |
cc1e2398 AK |
3445 | temp = tempcl; |
3446 | tempbl = ~ModeSwitchStatus; | |
ec9e5d3e | 3447 | xgifb_reg_and_or(pVBInfo->P3d4, 0x3d, tempbl, temp); |
21df8fc8 | 3448 | |
cc1e2398 | 3449 | if (!(pVBInfo->SetFlag & ReserveTVOption)) |
8104e329 | 3450 | xgifb_reg_set(pVBInfo->P3d4, 0x3e, tempch); |
cc1e2398 AK |
3451 | } else { |
3452 | return; | |
21df8fc8 | 3453 | } |
cc1e2398 | 3454 | } |
d7636e0b | 3455 | |
cc1e2398 AK |
3456 | void XGI_GetVGAType(struct xgi_hw_device_info *HwDeviceExtension, |
3457 | struct vb_device_info *pVBInfo) | |
3458 | { | |
3459 | /* | |
3460 | if ( HwDeviceExtension->jChipType >= XG20 ) { | |
3461 | pVBInfo->Set_VGAType = XG20; | |
06587335 | 3462 | } else { |
cc1e2398 AK |
3463 | pVBInfo->Set_VGAType = VGA_XGI340; |
3464 | } | |
3465 | */ | |
3466 | pVBInfo->Set_VGAType = HwDeviceExtension->jChipType; | |
d7636e0b | 3467 | } |
3468 | ||
cc1e2398 | 3469 | void XGI_GetVBType(struct vb_device_info *pVBInfo) |
d7636e0b | 3470 | { |
cc1e2398 | 3471 | unsigned short flag, tempbx, tempah; |
d7636e0b | 3472 | |
cc1e2398 AK |
3473 | if (pVBInfo->IF_DEF_CH7007 == 1) { |
3474 | pVBInfo->VBType = VB_CH7007; | |
3475 | return; | |
3476 | } | |
3477 | if (pVBInfo->IF_DEF_LVDS == 0) { | |
3478 | tempbx = VB_XGI302B; | |
58839b01 | 3479 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00); |
cc1e2398 AK |
3480 | if (flag != 0x02) { |
3481 | tempbx = VB_XGI301; | |
58839b01 | 3482 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x01); |
cc1e2398 AK |
3483 | if (flag >= 0xB0) { |
3484 | tempbx = VB_XGI301B; | |
3485 | if (flag >= 0xC0) { | |
3486 | tempbx = VB_XGI301C; | |
3487 | if (flag >= 0xD0) { | |
3488 | tempbx = VB_XGI301LV; | |
3489 | if (flag >= 0xE0) { | |
3490 | tempbx = VB_XGI302LV; | |
1d7f656d KT |
3491 | tempah = xgifb_reg_get( |
3492 | pVBInfo->Part4Port, | |
3493 | 0x39); | |
cc1e2398 | 3494 | if (tempah != 0xFF) |
1d7f656d KT |
3495 | tempbx = |
3496 | VB_XGI301C; | |
cc1e2398 AK |
3497 | } |
3498 | } | |
3499 | } | |
3500 | ||
3501 | if (tempbx & (VB_XGI301B | VB_XGI302B)) { | |
58839b01 | 3502 | flag = xgifb_reg_get( |
cc1e2398 AK |
3503 | pVBInfo->Part4Port, |
3504 | 0x23); | |
3505 | ||
3506 | if (!(flag & 0x02)) | |
3507 | tempbx = tempbx | VB_NoLCD; | |
3508 | } | |
3509 | } | |
3510 | } | |
3511 | pVBInfo->VBType = tempbx; | |
3512 | } | |
d7636e0b | 3513 | } |
3514 | ||
cc1e2398 AK |
3515 | void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, |
3516 | struct xgi_hw_device_info *HwDeviceExtension, | |
21df8fc8 PS |
3517 | struct vb_device_info *pVBInfo) |
3518 | { | |
cc1e2398 | 3519 | unsigned short tempax, push, tempbx, temp, modeflag; |
d7636e0b | 3520 | |
cc1e2398 AK |
3521 | if (ModeNo <= 0x13) |
3522 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
3523 | else | |
3524 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
d7636e0b | 3525 | |
cc1e2398 AK |
3526 | pVBInfo->SetFlag = 0; |
3527 | pVBInfo->ModeType = modeflag & ModeInfoFlag; | |
3528 | tempbx = 0; | |
3529 | ||
3530 | if (pVBInfo->VBType & 0xFFFF) { | |
1d7f656d KT |
3531 | /* Check Display Device */ |
3532 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x30); | |
cc1e2398 | 3533 | tempbx = tempbx | temp; |
58839b01 | 3534 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x31); |
cc1e2398 AK |
3535 | push = temp; |
3536 | push = push << 8; | |
3537 | tempax = temp << 8; | |
3538 | tempbx = tempbx | tempax; | |
3539 | temp = (SetCRT2ToDualEdge | SetCRT2ToYPbPr | SetCRT2ToLCDA | |
3540 | | SetInSlaveMode | DisableCRT2Display); | |
3541 | temp = 0xFFFF ^ temp; | |
3542 | tempbx &= temp; | |
3543 | ||
58839b01 | 3544 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x38); |
cc1e2398 AK |
3545 | |
3546 | if (pVBInfo->IF_DEF_LCDA == 1) { | |
3547 | ||
3548 | if ((pVBInfo->Set_VGAType >= XG20) | |
3549 | || (pVBInfo->Set_VGAType >= XG40)) { | |
3550 | if (pVBInfo->IF_DEF_LVDS == 0) { | |
1d7f656d KT |
3551 | /* if ((pVBInfo->VBType & VB_XGI302B) |
3552 | || (pVBInfo->VBType & VB_XGI301LV) | |
3553 | || (pVBInfo->VBType & VB_XGI302LV) | |
3554 | || (pVBInfo->VBType & VB_XGI301C)) | |
3555 | */ | |
3556 | if (pVBInfo->VBType & | |
3557 | (VB_XGI302B | | |
3558 | VB_XGI301LV | | |
3559 | VB_XGI302LV | | |
3560 | VB_XGI301C)) { | |
cc1e2398 | 3561 | if (temp & EnableDualEdge) { |
1d7f656d KT |
3562 | tempbx |= |
3563 | SetCRT2ToDualEdge; | |
d7636e0b | 3564 | |
cc1e2398 | 3565 | if (temp & SetToLCDA) |
1d7f656d KT |
3566 | tempbx |= |
3567 | SetCRT2ToLCDA; | |
cc1e2398 AK |
3568 | } |
3569 | } | |
cc1e2398 AK |
3570 | } |
3571 | } | |
3572 | } | |
21df8fc8 | 3573 | |
cc1e2398 | 3574 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
1d7f656d KT |
3575 | /* [Billy] 07/05/04 */ |
3576 | if (((pVBInfo->IF_DEF_LVDS == 0) && | |
3577 | ((pVBInfo->VBType & VB_XGI301LV) || | |
3578 | (pVBInfo->VBType & VB_XGI302LV) || | |
3579 | (pVBInfo->VBType & VB_XGI301C))) || | |
1d7f656d KT |
3580 | ((pVBInfo->IF_DEF_CH7007 == 1) && |
3581 | (pVBInfo->VBType & VB_CH7007))) { | |
cc1e2398 AK |
3582 | if (temp & SetYPbPr) { /* temp = CR38 */ |
3583 | if (pVBInfo->IF_DEF_HiVision == 1) { | |
1d7f656d KT |
3584 | /* shampoo add for new |
3585 | * scratch */ | |
58839b01 | 3586 | temp = xgifb_reg_get( |
cc1e2398 | 3587 | pVBInfo->P3d4, |
1d7f656d | 3588 | 0x35); |
cc1e2398 AK |
3589 | temp &= YPbPrMode; |
3590 | tempbx |= SetCRT2ToHiVisionTV; | |
21df8fc8 | 3591 | |
cc1e2398 | 3592 | if (temp != YPbPrMode1080i) { |
1d7f656d KT |
3593 | tempbx &= |
3594 | (~SetCRT2ToHiVisionTV); | |
3595 | tempbx |= | |
3596 | SetCRT2ToYPbPr; | |
cc1e2398 AK |
3597 | } |
3598 | } | |
21df8fc8 | 3599 | |
cc1e2398 AK |
3600 | /* tempbx |= SetCRT2ToYPbPr; */ |
3601 | } | |
3602 | } | |
3603 | } | |
21df8fc8 | 3604 | |
cc1e2398 | 3605 | tempax = push; /* restore CR31 */ |
21df8fc8 | 3606 | |
cc1e2398 AK |
3607 | if (pVBInfo->IF_DEF_LVDS == 0) { |
3608 | if (pVBInfo->IF_DEF_YPbPr == 1) { | |
3609 | if (pVBInfo->IF_DEF_HiVision == 1) | |
3610 | temp = 0x09FC; | |
21df8fc8 | 3611 | else |
cc1e2398 AK |
3612 | temp = 0x097C; |
3613 | } else { | |
3614 | if (pVBInfo->IF_DEF_HiVision == 1) | |
3615 | temp = 0x01FC; | |
3616 | else | |
3617 | temp = 0x017C; | |
3618 | } | |
3619 | } else { /* 3nd party chip */ | |
1d7f656d | 3620 | /* [Billy] 07/05/03 */ |
a35cd0ba | 3621 | if (pVBInfo->IF_DEF_CH7007 == 1) |
cc1e2398 | 3622 | temp = SetCRT2ToTV; |
1d7f656d | 3623 | else |
cc1e2398 AK |
3624 | temp = SetCRT2ToLCD; |
3625 | } | |
21df8fc8 | 3626 | |
cc1e2398 AK |
3627 | if (!(tempbx & temp)) { |
3628 | tempax |= DisableCRT2Display; | |
3629 | tempbx = 0; | |
21df8fc8 PS |
3630 | } |
3631 | ||
cc1e2398 AK |
3632 | if (pVBInfo->IF_DEF_LCDA == 1) { /* Select Display Device */ |
3633 | if (!(pVBInfo->VBType & VB_NoLCD)) { | |
3634 | if (tempbx & SetCRT2ToLCDA) { | |
3635 | if (tempbx & SetSimuScanMode) | |
1d7f656d KT |
3636 | tempbx &= (~(SetCRT2ToLCD | |
3637 | SetCRT2ToRAMDAC | | |
3638 | SwitchToCRT2)); | |
cc1e2398 | 3639 | else |
1d7f656d KT |
3640 | tempbx &= (~(SetCRT2ToLCD | |
3641 | SetCRT2ToRAMDAC | | |
3642 | SetCRT2ToTV | | |
3643 | SwitchToCRT2)); | |
cc1e2398 AK |
3644 | } |
3645 | } | |
21df8fc8 PS |
3646 | } |
3647 | ||
cc1e2398 | 3648 | /* shampoo add */ |
1d7f656d KT |
3649 | /* for driver abnormal */ |
3650 | if (!(tempbx & (SwitchToCRT2 | SetSimuScanMode))) { | |
cc1e2398 AK |
3651 | if (pVBInfo->IF_DEF_CRT2Monitor == 1) { |
3652 | if (tempbx & SetCRT2ToRAMDAC) { | |
1d7f656d KT |
3653 | tempbx &= (0xFF00 | |
3654 | SetCRT2ToRAMDAC | | |
3655 | SwitchToCRT2 | | |
3656 | SetSimuScanMode); | |
cc1e2398 AK |
3657 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr)); |
3658 | } | |
3659 | } else { | |
1d7f656d KT |
3660 | tempbx &= (~(SetCRT2ToRAMDAC | |
3661 | SetCRT2ToLCD | | |
3662 | SetCRT2ToTV)); | |
cc1e2398 AK |
3663 | } |
3664 | } | |
21df8fc8 | 3665 | |
cc1e2398 AK |
3666 | if (!(pVBInfo->VBType & VB_NoLCD)) { |
3667 | if (tempbx & SetCRT2ToLCD) { | |
1d7f656d KT |
3668 | tempbx &= (0xFF00 | |
3669 | SetCRT2ToLCD | | |
3670 | SwitchToCRT2 | | |
3671 | SetSimuScanMode); | |
cc1e2398 AK |
3672 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr)); |
3673 | } | |
3674 | } | |
21df8fc8 | 3675 | |
cc1e2398 | 3676 | if (tempbx & SetCRT2ToSCART) { |
1d7f656d KT |
3677 | tempbx &= (0xFF00 | |
3678 | SetCRT2ToSCART | | |
3679 | SwitchToCRT2 | | |
3680 | SetSimuScanMode); | |
cc1e2398 AK |
3681 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr)); |
3682 | } | |
21df8fc8 | 3683 | |
cc1e2398 AK |
3684 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
3685 | if (tempbx & SetCRT2ToYPbPr) | |
1d7f656d KT |
3686 | tempbx &= (0xFF00 | |
3687 | SwitchToCRT2 | | |
3688 | SetSimuScanMode); | |
cc1e2398 | 3689 | } |
21df8fc8 | 3690 | |
cc1e2398 AK |
3691 | if (pVBInfo->IF_DEF_HiVision == 1) { |
3692 | if (tempbx & SetCRT2ToHiVisionTV) | |
1d7f656d KT |
3693 | tempbx &= (0xFF00 | |
3694 | SetCRT2ToHiVisionTV | | |
3695 | SwitchToCRT2 | | |
3696 | SetSimuScanMode); | |
cc1e2398 | 3697 | } |
21df8fc8 | 3698 | |
cc1e2398 AK |
3699 | if (tempax & DisableCRT2Display) { /* Set Display Device Info */ |
3700 | if (!(tempbx & (SwitchToCRT2 | SetSimuScanMode))) | |
3701 | tempbx = DisableCRT2Display; | |
3702 | } | |
21df8fc8 | 3703 | |
cc1e2398 | 3704 | if (!(tempbx & DisableCRT2Display)) { |
1d7f656d KT |
3705 | if ((!(tempbx & DriverMode)) || |
3706 | (!(modeflag & CRT2Mode))) { | |
cc1e2398 AK |
3707 | if (pVBInfo->IF_DEF_LCDA == 1) { |
3708 | if (!(tempbx & SetCRT2ToLCDA)) | |
1d7f656d KT |
3709 | tempbx |= (SetInSlaveMode | |
3710 | SetSimuScanMode); | |
cc1e2398 | 3711 | } |
21df8fc8 | 3712 | |
cc1e2398 | 3713 | if (pVBInfo->IF_DEF_VideoCapture == 1) { |
1d7f656d KT |
3714 | if (((HwDeviceExtension->jChipType == |
3715 | XG40) && | |
3716 | (pVBInfo->Set_VGAType == XG40)) || | |
3717 | ((HwDeviceExtension->jChipType == | |
3718 | XG41) && | |
3719 | (pVBInfo->Set_VGAType == XG41)) || | |
3720 | ((HwDeviceExtension->jChipType == | |
3721 | XG42) && | |
3722 | (pVBInfo->Set_VGAType == XG42)) || | |
3723 | ((HwDeviceExtension->jChipType == | |
3724 | XG45) && | |
3725 | (pVBInfo->Set_VGAType == XG45))) { | |
cc1e2398 | 3726 | if (ModeNo <= 13) { |
1d7f656d KT |
3727 | if (!(tempbx & |
3728 | SetCRT2ToRAMDAC)) { | |
3729 | /*CRT2 not need | |
3730 | * to support*/ | |
3731 | tempbx &= | |
3732 | (0x00FF | | |
3733 | (~SetInSlaveMode)); | |
cc1e2398 AK |
3734 | pVBInfo->SetFlag |
3735 | |= EnableVCMode; | |
3736 | } | |
3737 | } | |
21df8fc8 PS |
3738 | } |
3739 | } | |
3740 | } | |
21df8fc8 | 3741 | |
1d7f656d KT |
3742 | /* LCD+TV can't support in slave mode |
3743 | * (Force LCDA+TV->LCDB) */ | |
3744 | if ((tempbx & SetInSlaveMode) && | |
3745 | (tempbx & SetCRT2ToLCDA)) { | |
3746 | tempbx ^= (SetCRT2ToLCD | | |
3747 | SetCRT2ToLCDA | | |
3748 | SetCRT2ToDualEdge); | |
cc1e2398 | 3749 | pVBInfo->SetFlag |= ReserveTVOption; |
21df8fc8 PS |
3750 | } |
3751 | } | |
21df8fc8 | 3752 | } |
cc1e2398 AK |
3753 | |
3754 | pVBInfo->VBInfo = tempbx; | |
21df8fc8 PS |
3755 | } |
3756 | ||
cc1e2398 | 3757 | void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex, |
21df8fc8 | 3758 | struct vb_device_info *pVBInfo) |
d7636e0b | 3759 | { |
cc1e2398 | 3760 | unsigned short temp, tempbx = 0, resinfo = 0, modeflag, index1; |
21df8fc8 | 3761 | |
cc1e2398 AK |
3762 | tempbx = 0; |
3763 | resinfo = 0; | |
d7636e0b | 3764 | |
cc1e2398 AK |
3765 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
3766 | if (ModeNo <= 0x13) { | |
1d7f656d KT |
3767 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex]. |
3768 | St_ModeFlag; /* si+St_ModeFlag */ | |
3769 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex]. | |
3770 | St_ResInfo; /* si+St_ResInfo */ | |
cc1e2398 | 3771 | } else { |
1d7f656d KT |
3772 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex]. |
3773 | Ext_ModeFlag; | |
3774 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex]. | |
3775 | Ext_RESINFO; /* si+Ext_ResInfo */ | |
cc1e2398 | 3776 | } |
d7636e0b | 3777 | |
cc1e2398 | 3778 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
58839b01 | 3779 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x35); |
cc1e2398 AK |
3780 | tempbx = temp; |
3781 | if (tempbx & SetPALTV) { | |
1d7f656d KT |
3782 | tempbx &= (SetCHTVOverScan | |
3783 | SetPALMTV | | |
3784 | SetPALNTV | | |
3785 | SetPALTV); | |
cc1e2398 | 3786 | if (tempbx & SetPALMTV) |
1d7f656d KT |
3787 | /* set to NTSC if PAL-M */ |
3788 | tempbx &= ~SetPALTV; | |
cc1e2398 | 3789 | } else |
1d7f656d KT |
3790 | tempbx &= (SetCHTVOverScan | |
3791 | SetNTSCJ | | |
3792 | SetPALTV); | |
cc1e2398 AK |
3793 | /* |
3794 | if (pVBInfo->IF_DEF_LVDS == 0) { | |
1d7f656d KT |
3795 | //PAL-M/PAL-N Info |
3796 | index1 = xgifb_reg_get(pVBInfo->P3d4, 0x38); | |
3797 | //00:PAL, 01:PAL-M, 10:PAL-N | |
3798 | temp2 = (index1 & 0xC0) >> 5; | |
cc1e2398 | 3799 | tempbx |= temp2; |
1d7f656d | 3800 | if (temp2 & 0x02) //PAL-M |
cc1e2398 AK |
3801 | tempbx &= (~SetPALTV); |
3802 | } | |
3803 | */ | |
3804 | } | |
d7636e0b | 3805 | |
cc1e2398 | 3806 | if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/04 */ |
58839b01 | 3807 | tempbx = xgifb_reg_get(pVBInfo->P3d4, 0x35); |
21df8fc8 | 3808 | |
cc1e2398 AK |
3809 | if (tempbx & TVOverScan) |
3810 | tempbx |= SetCHTVOverScan; | |
21df8fc8 | 3811 | } |
21df8fc8 | 3812 | |
cc1e2398 AK |
3813 | if (pVBInfo->IF_DEF_LVDS == 0) { |
3814 | if (pVBInfo->VBInfo & SetCRT2ToSCART) | |
3815 | tempbx |= SetPALTV; | |
3816 | } | |
d7636e0b | 3817 | |
cc1e2398 AK |
3818 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
3819 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { | |
58839b01 | 3820 | index1 = xgifb_reg_get(pVBInfo->P3d4, 0x35); |
cc1e2398 | 3821 | index1 &= YPbPrMode; |
d7636e0b | 3822 | |
cc1e2398 AK |
3823 | if (index1 == YPbPrMode525i) |
3824 | tempbx |= SetYPbPrMode525i; | |
21df8fc8 | 3825 | |
cc1e2398 AK |
3826 | if (index1 == YPbPrMode525p) |
3827 | tempbx = tempbx | SetYPbPrMode525p; | |
3828 | if (index1 == YPbPrMode750p) | |
3829 | tempbx = tempbx | SetYPbPrMode750p; | |
3830 | } | |
3831 | } | |
21df8fc8 | 3832 | |
cc1e2398 AK |
3833 | if (pVBInfo->IF_DEF_HiVision == 1) { |
3834 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) | |
3835 | tempbx = tempbx | SetYPbPrMode1080i | SetPALTV; | |
3836 | } | |
21df8fc8 | 3837 | |
cc1e2398 | 3838 | if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */ |
1d7f656d KT |
3839 | if ((pVBInfo->VBInfo & SetInSlaveMode) && |
3840 | (!(pVBInfo->VBInfo & SetNotSimuMode))) | |
cc1e2398 AK |
3841 | tempbx |= TVSimuMode; |
3842 | ||
1d7f656d KT |
3843 | if (!(tempbx & SetPALTV) && |
3844 | (modeflag > 13) && | |
3845 | (resinfo == 8)) /* NTSC 1024x768, */ | |
cc1e2398 AK |
3846 | tempbx |= NTSC1024x768; |
3847 | ||
3848 | tempbx |= RPLLDIV2XO; | |
21df8fc8 | 3849 | |
cc1e2398 AK |
3850 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
3851 | if (pVBInfo->VBInfo & SetInSlaveMode) | |
3852 | tempbx &= (~RPLLDIV2XO); | |
3853 | } else { | |
1d7f656d KT |
3854 | if (tempbx & |
3855 | (SetYPbPrMode525p | SetYPbPrMode750p)) | |
cc1e2398 | 3856 | tempbx &= (~RPLLDIV2XO); |
1d7f656d KT |
3857 | else if (!(pVBInfo->VBType & |
3858 | (VB_XGI301B | | |
3859 | VB_XGI302B | | |
3860 | VB_XGI301LV | | |
3861 | VB_XGI302LV | | |
3862 | VB_XGI301C))) { | |
cc1e2398 AK |
3863 | if (tempbx & TVSimuMode) |
3864 | tempbx &= (~RPLLDIV2XO); | |
21df8fc8 | 3865 | } |
21df8fc8 | 3866 | } |
cc1e2398 AK |
3867 | } |
3868 | } | |
3869 | pVBInfo->TVInfo = tempbx; | |
3870 | } | |
21df8fc8 | 3871 | |
cc1e2398 AK |
3872 | unsigned char XGI_GetLCDInfo(unsigned short ModeNo, unsigned short ModeIdIndex, |
3873 | struct vb_device_info *pVBInfo) | |
3874 | { | |
3875 | unsigned short temp, tempax, tempbx, modeflag, resinfo = 0, LCDIdIndex; | |
21df8fc8 | 3876 | |
cc1e2398 AK |
3877 | pVBInfo->LCDResInfo = 0; |
3878 | pVBInfo->LCDTypeInfo = 0; | |
3879 | pVBInfo->LCDInfo = 0; | |
21df8fc8 | 3880 | |
cc1e2398 | 3881 | if (ModeNo <= 0x13) { |
1d7f656d KT |
3882 | /* si+St_ModeFlag // */ |
3883 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
cc1e2398 AK |
3884 | } else { |
3885 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
1d7f656d KT |
3886 | /* si+Ext_ResInfo // */ |
3887 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; | |
cc1e2398 | 3888 | } |
21df8fc8 | 3889 | |
58839b01 | 3890 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x36); /* Get LCD Res.Info */ |
cc1e2398 | 3891 | tempbx = temp & 0x0F; |
21df8fc8 | 3892 | |
cc1e2398 AK |
3893 | if (tempbx == 0) |
3894 | tempbx = Panel1024x768; /* default */ | |
3895 | ||
3896 | /* LCD75 [2003/8/22] Vicent */ | |
3897 | if ((tempbx == Panel1024x768) || (tempbx == Panel1280x1024)) { | |
3898 | if (pVBInfo->VBInfo & DriverMode) { | |
58839b01 | 3899 | tempax = xgifb_reg_get(pVBInfo->P3d4, 0x33); |
cc1e2398 AK |
3900 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) |
3901 | tempax &= 0x0F; | |
21df8fc8 | 3902 | else |
cc1e2398 | 3903 | tempax = tempax >> 4; |
21df8fc8 | 3904 | |
cc1e2398 AK |
3905 | if ((resinfo == 6) || (resinfo == 9)) { |
3906 | if (tempax >= 3) | |
3907 | tempbx |= PanelRef75Hz; | |
3908 | } else if ((resinfo == 7) || (resinfo == 8)) { | |
3909 | if (tempax >= 4) | |
3910 | tempbx |= PanelRef75Hz; | |
21df8fc8 | 3911 | } |
cc1e2398 AK |
3912 | } |
3913 | } | |
21df8fc8 | 3914 | |
cc1e2398 | 3915 | pVBInfo->LCDResInfo = tempbx; |
21df8fc8 | 3916 | |
cc1e2398 | 3917 | /* End of LCD75 */ |
21df8fc8 | 3918 | |
cc1e2398 AK |
3919 | if (pVBInfo->IF_DEF_OEMUtil == 1) |
3920 | pVBInfo->LCDTypeInfo = (temp & 0xf0) >> 4; | |
21df8fc8 | 3921 | |
cc1e2398 AK |
3922 | if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))) |
3923 | return 0; | |
21df8fc8 | 3924 | |
cc1e2398 | 3925 | tempbx = 0; |
21df8fc8 | 3926 | |
58839b01 | 3927 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
d7636e0b | 3928 | |
cc1e2398 | 3929 | temp &= (ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable); |
d7636e0b | 3930 | |
cc1e2398 AK |
3931 | if ((pVBInfo->IF_DEF_ScaleLCD == 1) && (temp & LCDNonExpanding)) |
3932 | temp &= ~EnableScalingLCD; | |
d7636e0b | 3933 | |
cc1e2398 | 3934 | tempbx |= temp; |
d7636e0b | 3935 | |
cc1e2398 | 3936 | LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo); |
d7636e0b | 3937 | |
cc1e2398 | 3938 | tempax = pVBInfo->LCDCapList[LCDIdIndex].LCD_Capability; |
d7636e0b | 3939 | |
cc1e2398 AK |
3940 | if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */ |
3941 | if (((pVBInfo->VBType & VB_XGI302LV) || (pVBInfo->VBType | |
3942 | & VB_XGI301C)) && (tempax & LCDDualLink)) { | |
3943 | tempbx |= SetLCDDualLink; | |
21df8fc8 | 3944 | } |
21df8fc8 | 3945 | } |
21df8fc8 | 3946 | |
cc1e2398 AK |
3947 | if (pVBInfo->IF_DEF_LVDS == 0) { |
3948 | if ((pVBInfo->LCDResInfo == Panel1400x1050) && (pVBInfo->VBInfo | |
3949 | & SetCRT2ToLCD) && (ModeNo > 0x13) && (resinfo | |
3950 | == 9) && (!(tempbx & EnableScalingLCD))) | |
1d7f656d KT |
3951 | /* set to center in 1280x1024 LCDB for Panel1400x1050 */ |
3952 | tempbx |= SetLCDtoNonExpanding; | |
cc1e2398 | 3953 | } |
21df8fc8 | 3954 | |
cc1e2398 AK |
3955 | /* |
3956 | if (tempax & LCDBToA) { | |
3957 | tempbx |= SetLCDBToA; | |
3958 | } | |
3959 | */ | |
21df8fc8 | 3960 | |
cc1e2398 AK |
3961 | if (pVBInfo->IF_DEF_ExpLink == 1) { |
3962 | if (modeflag & HalfDCLK) { | |
3963 | /* if (!(pVBInfo->LCDInfo&LCDNonExpanding)) */ | |
3964 | if (!(tempbx & SetLCDtoNonExpanding)) { | |
3965 | tempbx |= EnableLVDSDDA; | |
3966 | } else { | |
3967 | if (ModeNo > 0x13) { | |
3968 | if (pVBInfo->LCDResInfo | |
3969 | == Panel1024x768) { | |
1d7f656d | 3970 | if (resinfo == 4) {/* 512x384 */ |
cc1e2398 AK |
3971 | tempbx |= EnableLVDSDDA; |
3972 | } | |
3973 | } | |
3974 | } | |
3975 | } | |
3976 | } | |
3977 | } | |
21df8fc8 | 3978 | |
cc1e2398 AK |
3979 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
3980 | if (pVBInfo->VBInfo & SetNotSimuMode) | |
3981 | tempbx |= LCDVESATiming; | |
3982 | } else { | |
3983 | tempbx |= LCDVESATiming; | |
3984 | } | |
21df8fc8 | 3985 | |
cc1e2398 | 3986 | pVBInfo->LCDInfo = tempbx; |
d7636e0b | 3987 | |
cc1e2398 AK |
3988 | if (pVBInfo->IF_DEF_PWD == 1) { |
3989 | if (pVBInfo->LCDInfo & SetPWDEnable) { | |
1d7f656d KT |
3990 | if ((pVBInfo->VBType & VB_XGI302LV) || |
3991 | (pVBInfo->VBType & VB_XGI301C)) { | |
cc1e2398 AK |
3992 | if (!(tempax & PWDEnable)) |
3993 | pVBInfo->LCDInfo &= ~SetPWDEnable; | |
3994 | } | |
3995 | } | |
3996 | } | |
d7636e0b | 3997 | |
cc1e2398 AK |
3998 | if (pVBInfo->IF_DEF_LVDS == 0) { |
3999 | if (tempax & (LockLCDBToA | StLCDBToA)) { | |
4000 | if (pVBInfo->VBInfo & SetInSlaveMode) { | |
4001 | if (!(tempax & LockLCDBToA)) { | |
4002 | if (ModeNo <= 0x13) { | |
1d7f656d KT |
4003 | pVBInfo->VBInfo &= |
4004 | ~(SetSimuScanMode | | |
4005 | SetInSlaveMode | | |
4006 | SetCRT2ToLCD); | |
4007 | pVBInfo->VBInfo |= | |
4008 | SetCRT2ToLCDA | | |
4009 | SetCRT2ToDualEdge; | |
cc1e2398 AK |
4010 | } |
4011 | } | |
4012 | } | |
4013 | } | |
4014 | } | |
21df8fc8 | 4015 | |
cc1e2398 AK |
4016 | /* |
4017 | if (pVBInfo->IF_DEF_LVDS == 0) { | |
4018 | if (tempax & (LockLCDBToA | StLCDBToA)) { | |
4019 | if (pVBInfo->VBInfo & SetInSlaveMode) { | |
1d7f656d KT |
4020 | if (!((!(tempax & LockLCDBToA)) && |
4021 | (ModeNo > 0x13))) { | |
4022 | pVBInfo->VBInfo &= | |
4023 | ~(SetSimuScanMode | | |
4024 | SetInSlaveMode | | |
4025 | SetCRT2ToLCD); | |
4026 | pVBInfo->VBInfo |= | |
4027 | SetCRT2ToLCDA | | |
4028 | SetCRT2ToDualEdge; | |
cc1e2398 AK |
4029 | } |
4030 | } | |
4031 | } | |
21df8fc8 | 4032 | } |
cc1e2398 | 4033 | */ |
d7636e0b | 4034 | |
cc1e2398 | 4035 | return 1; |
21df8fc8 | 4036 | } |
d7636e0b | 4037 | |
cc1e2398 AK |
4038 | unsigned char XGI_SearchModeID(unsigned short ModeNo, |
4039 | unsigned short *ModeIdIndex, struct vb_device_info *pVBInfo) | |
d7636e0b | 4040 | { |
cc1e2398 AK |
4041 | if (ModeNo <= 5) |
4042 | ModeNo |= 1; | |
4043 | if (ModeNo <= 0x13) { | |
1d7f656d KT |
4044 | /* for (*ModeIdIndex=0; |
4045 | *ModeIdIndex < sizeof(pVBInfo->SModeIDTable) | |
4046 | / sizeof(struct XGI_StStruct); | |
4047 | (*ModeIdIndex)++) */ | |
cc1e2398 | 4048 | for (*ModeIdIndex = 0;; (*ModeIdIndex)++) { |
1d7f656d KT |
4049 | if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == |
4050 | ModeNo) | |
cc1e2398 | 4051 | break; |
1d7f656d KT |
4052 | if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == |
4053 | 0xFF) | |
cc1e2398 AK |
4054 | return 0; |
4055 | } | |
d7636e0b | 4056 | |
cc1e2398 AK |
4057 | if (ModeNo == 0x07) |
4058 | (*ModeIdIndex)++; /* 400 lines */ | |
4059 | if (ModeNo <= 3) | |
4060 | (*ModeIdIndex) += 2; /* 400 lines */ | |
4061 | /* else 350 lines */ | |
4062 | } else { | |
1d7f656d KT |
4063 | /* for (*ModeIdIndex=0; |
4064 | *ModeIdIndex < sizeof(pVBInfo->EModeIDTable) | |
4065 | / sizeof(struct XGI_ExtStruct); | |
4066 | (*ModeIdIndex)++) */ | |
cc1e2398 | 4067 | for (*ModeIdIndex = 0;; (*ModeIdIndex)++) { |
1d7f656d KT |
4068 | if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == |
4069 | ModeNo) | |
cc1e2398 | 4070 | break; |
1d7f656d KT |
4071 | if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == |
4072 | 0xFF) | |
cc1e2398 AK |
4073 | return 0; |
4074 | } | |
21df8fc8 | 4075 | } |
d7636e0b | 4076 | |
cc1e2398 | 4077 | return 1; |
21df8fc8 | 4078 | } |
d7636e0b | 4079 | |
cc1e2398 AK |
4080 | /* win2000 MM adapter not support standard mode! */ |
4081 | ||
4082 | #if 0 | |
4083 | static unsigned char XGINew_CheckMemorySize( | |
21df8fc8 | 4084 | struct xgi_hw_device_info *HwDeviceExtension, |
cc1e2398 AK |
4085 | unsigned short ModeNo, |
4086 | unsigned short ModeIdIndex, | |
21df8fc8 PS |
4087 | struct vb_device_info *pVBInfo) |
4088 | { | |
cc1e2398 | 4089 | unsigned short memorysize, modeflag, temp, temp1, tmp; |
d7636e0b | 4090 | |
cc1e2398 AK |
4091 | /* |
4092 | if ((HwDeviceExtension->jChipType == XGI_650) || | |
4093 | (HwDeviceExtension->jChipType == XGI_650M)) { | |
4094 | return 1; | |
21df8fc8 | 4095 | } |
cc1e2398 | 4096 | */ |
21df8fc8 PS |
4097 | |
4098 | if (ModeNo <= 0x13) | |
4099 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
4100 | else | |
4101 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
4102 | ||
cc1e2398 | 4103 | /* ModeType = modeflag&ModeInfoFlag; // Get mode type */ |
21df8fc8 | 4104 | |
cc1e2398 AK |
4105 | memorysize = modeflag & MemoryInfoFlag; |
4106 | memorysize = memorysize > MemorySizeShift; | |
4107 | memorysize++; /* Get memory size */ | |
21df8fc8 | 4108 | |
58839b01 | 4109 | temp = xgifb_reg_get(pVBInfo->P3c4, 0x14); /* Get DRAM Size */ |
cc1e2398 | 4110 | tmp = temp; |
21df8fc8 | 4111 | |
cc1e2398 | 4112 | if (HwDeviceExtension->jChipType == XG40) { |
1d7f656d KT |
4113 | /* memory size per channel SR14[7:4] */ |
4114 | temp = 1 << ((temp & 0x0F0) >> 4); | |
cc1e2398 AK |
4115 | if ((tmp & 0x0c) == 0x0C) { /* Qual channels */ |
4116 | temp <<= 2; | |
4117 | } else if ((tmp & 0x0c) == 0x08) { /* Dual channels */ | |
4118 | temp <<= 1; | |
4119 | } | |
4120 | } else if (HwDeviceExtension->jChipType == XG42) { | |
1d7f656d KT |
4121 | /* memory size per channel SR14[7:4] */ |
4122 | temp = 1 << ((temp & 0x0F0) >> 4); | |
cc1e2398 AK |
4123 | if ((tmp & 0x04) == 0x04) { /* Dual channels */ |
4124 | temp <<= 1; | |
4125 | } | |
4126 | } else if (HwDeviceExtension->jChipType == XG45) { | |
1d7f656d KT |
4127 | /* memory size per channel SR14[7:4] */ |
4128 | temp = 1 << ((temp & 0x0F0) >> 4); | |
cc1e2398 AK |
4129 | if ((tmp & 0x0c) == 0x0C) { /* Qual channels */ |
4130 | temp <<= 2; | |
4131 | } else if ((tmp & 0x0c) == 0x08) { /* triple channels */ | |
4132 | temp1 = temp; | |
4133 | temp <<= 1; | |
4134 | temp += temp1; | |
4135 | } else if ((tmp & 0x0c) == 0x04) { /* Dual channels */ | |
4136 | temp <<= 1; | |
4137 | } | |
4138 | } | |
4139 | if (temp < memorysize) | |
4140 | return 0; | |
4141 | else | |
4142 | return 1; | |
4143 | } | |
4144 | #endif | |
21df8fc8 | 4145 | |
cc1e2398 | 4146 | /* |
1d7f656d KT |
4147 | void XGINew_IsLowResolution(unsigned short ModeNo, |
4148 | unsigned short ModeIdIndex, | |
4149 | unsigned char XGINew_CheckMemorySize( | |
4150 | struct xgi_hw_device_info *HwDeviceExtension, | |
4151 | unsigned short ModeNo, | |
4152 | unsigned short ModeIdIndex, | |
4153 | struct vb_device_info *pVBInfo) | |
cc1e2398 AK |
4154 | { |
4155 | unsigned short data ; | |
4156 | unsigned short ModeFlag ; | |
21df8fc8 | 4157 | |
58839b01 | 4158 | data = xgifb_reg_get(pVBInfo->P3c4, 0x0F); |
cc1e2398 | 4159 | data &= 0x7F; |
8104e329 | 4160 | xgifb_reg_set(pVBInfo->P3c4, 0x0F, data); |
21df8fc8 | 4161 | |
cc1e2398 AK |
4162 | if (ModeNo > 0x13) { |
4163 | ModeFlag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
4164 | if ((ModeFlag & HalfDCLK) && (ModeFlag & DoubleScanMode)) { | |
58839b01 | 4165 | data = xgifb_reg_get(pVBInfo->P3c4, 0x0F); |
cc1e2398 | 4166 | data |= 0x80; |
8104e329 | 4167 | xgifb_reg_set(pVBInfo->P3c4, 0x0F, data); |
58839b01 | 4168 | data = xgifb_reg_get(pVBInfo->P3c4, 0x01); |
cc1e2398 | 4169 | data &= 0xF7; |
8104e329 | 4170 | xgifb_reg_set(pVBInfo->P3c4, 0x01, data); |
21df8fc8 | 4171 | } |
cc1e2398 AK |
4172 | } |
4173 | } | |
4174 | */ | |
21df8fc8 | 4175 | |
cc1e2398 AK |
4176 | static unsigned char XG21GPIODataTransfer(unsigned char ujDate) |
4177 | { | |
4178 | unsigned char ujRet = 0; | |
4179 | unsigned char i = 0; | |
21df8fc8 | 4180 | |
cc1e2398 AK |
4181 | for (i = 0; i < 8; i++) { |
4182 | ujRet = ujRet << 1; | |
4183 | /* ujRet |= GETBITS(ujDate >> i, 0:0); */ | |
4184 | ujRet |= (ujDate >> i) & 1; | |
21df8fc8 | 4185 | } |
d7636e0b | 4186 | |
cc1e2398 AK |
4187 | return ujRet; |
4188 | } | |
21df8fc8 | 4189 | |
cc1e2398 AK |
4190 | /*----------------------------------------------------------------------------*/ |
4191 | /* output */ | |
4192 | /* bl[5] : LVDS signal */ | |
4193 | /* bl[1] : LVDS backlight */ | |
4194 | /* bl[0] : LVDS VDD */ | |
4195 | /*----------------------------------------------------------------------------*/ | |
4196 | static unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo) | |
4197 | { | |
4198 | unsigned char CR4A, temp; | |
21df8fc8 | 4199 | |
58839b01 | 4200 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
dc50556b | 4201 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x23); /* enable GPIO write */ |
21df8fc8 | 4202 | |
58839b01 | 4203 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
21df8fc8 | 4204 | |
cc1e2398 AK |
4205 | temp = XG21GPIODataTransfer(temp); |
4206 | temp &= 0x23; | |
8104e329 | 4207 | xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A); |
cc1e2398 AK |
4208 | return temp; |
4209 | } | |
4210 | ||
4211 | /*----------------------------------------------------------------------------*/ | |
4212 | /* output */ | |
4213 | /* bl[5] : LVDS signal */ | |
4214 | /* bl[1] : LVDS backlight */ | |
4215 | /* bl[0] : LVDS VDD */ | |
4216 | /*----------------------------------------------------------------------------*/ | |
4217 | static unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo) | |
4218 | { | |
4219 | unsigned char CR4A, CRB4, temp; | |
21df8fc8 | 4220 | |
58839b01 | 4221 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
dc50556b | 4222 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x0C); /* enable GPIO write */ |
21df8fc8 | 4223 | |
58839b01 | 4224 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
21df8fc8 | 4225 | |
cc1e2398 AK |
4226 | temp &= 0x0C; |
4227 | temp >>= 2; | |
8104e329 | 4228 | xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A); |
58839b01 | 4229 | CRB4 = xgifb_reg_get(pVBInfo->P3d4, 0xB4); |
cc1e2398 AK |
4230 | temp |= ((CRB4 & 0x04) << 3); |
4231 | return temp; | |
4232 | } | |
21df8fc8 | 4233 | |
cc1e2398 AK |
4234 | void XGI_DisplayOn(struct xgi_hw_device_info *pXGIHWDE, |
4235 | struct vb_device_info *pVBInfo) | |
4236 | { | |
4237 | ||
ec9e5d3e | 4238 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x00); |
cc1e2398 AK |
4239 | if (pXGIHWDE->jChipType == XG21) { |
4240 | if (pVBInfo->IF_DEF_LVDS == 1) { | |
4241 | if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x1)) { | |
1d7f656d KT |
4242 | /* LVDS VDD on */ |
4243 | XGI_XG21BLSignalVDD(0x01, 0x01, pVBInfo); | |
cc1e2398 AK |
4244 | XGI_XG21SetPanelDelay(2, pVBInfo); |
4245 | } | |
4246 | if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x20)) | |
1d7f656d KT |
4247 | /* LVDS signal on */ |
4248 | XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); | |
cc1e2398 | 4249 | XGI_XG21SetPanelDelay(3, pVBInfo); |
1d7f656d KT |
4250 | /* LVDS backlight on */ |
4251 | XGI_XG21BLSignalVDD(0x02, 0x02, pVBInfo); | |
cc1e2398 | 4252 | } else { |
1d7f656d KT |
4253 | /* DVO/DVI signal on */ |
4254 | XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); | |
cc1e2398 | 4255 | } |
21df8fc8 | 4256 | |
21df8fc8 PS |
4257 | } |
4258 | ||
1d7f656d KT |
4259 | /* [Billy] 07/05/23 For CH7007 */ |
4260 | if (pVBInfo->IF_DEF_CH7007 == 1) { | |
cc1e2398 | 4261 | } |
21df8fc8 | 4262 | |
cc1e2398 AK |
4263 | if (pXGIHWDE->jChipType == XG27) { |
4264 | if (pVBInfo->IF_DEF_LVDS == 1) { | |
4265 | if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x1)) { | |
1d7f656d KT |
4266 | /* LVDS VDD on */ |
4267 | XGI_XG27BLSignalVDD(0x01, 0x01, pVBInfo); | |
cc1e2398 AK |
4268 | XGI_XG21SetPanelDelay(2, pVBInfo); |
4269 | } | |
4270 | if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x20)) | |
1d7f656d KT |
4271 | /* LVDS signal on */ |
4272 | XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); | |
cc1e2398 | 4273 | XGI_XG21SetPanelDelay(3, pVBInfo); |
1d7f656d KT |
4274 | /* LVDS backlight on */ |
4275 | XGI_XG27BLSignalVDD(0x02, 0x02, pVBInfo); | |
cc1e2398 | 4276 | } else { |
1d7f656d KT |
4277 | /* DVO/DVI signal on */ |
4278 | XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); | |
cc1e2398 | 4279 | } |
21df8fc8 | 4280 | |
cc1e2398 | 4281 | } |
d7636e0b | 4282 | } |
4283 | ||
cc1e2398 | 4284 | void XGI_DisplayOff(struct xgi_hw_device_info *pXGIHWDE, |
21df8fc8 PS |
4285 | struct vb_device_info *pVBInfo) |
4286 | { | |
d7636e0b | 4287 | |
cc1e2398 AK |
4288 | if (pXGIHWDE->jChipType == XG21) { |
4289 | if (pVBInfo->IF_DEF_LVDS == 1) { | |
1d7f656d KT |
4290 | /* LVDS backlight off */ |
4291 | XGI_XG21BLSignalVDD(0x02, 0x00, pVBInfo); | |
cc1e2398 AK |
4292 | XGI_XG21SetPanelDelay(3, pVBInfo); |
4293 | } else { | |
1d7f656d KT |
4294 | /* DVO/DVI signal off */ |
4295 | XGI_XG21BLSignalVDD(0x20, 0x00, pVBInfo); | |
cc1e2398 | 4296 | } |
21df8fc8 PS |
4297 | } |
4298 | ||
cc1e2398 AK |
4299 | if (pVBInfo->IF_DEF_CH7007 == 1) { /* [Billy] 07/05/23 For CH7007 */ |
4300 | /* if (IsCH7007TVMode(pVBInfo) == 0) */ | |
4301 | { | |
4302 | } | |
4303 | } | |
21df8fc8 | 4304 | |
cc1e2398 AK |
4305 | if (pXGIHWDE->jChipType == XG27) { |
4306 | if ((XGI_XG27GetPSCValue(pVBInfo) & 0x2)) { | |
1d7f656d KT |
4307 | /* LVDS backlight off */ |
4308 | XGI_XG27BLSignalVDD(0x02, 0x00, pVBInfo); | |
cc1e2398 AK |
4309 | XGI_XG21SetPanelDelay(3, pVBInfo); |
4310 | } | |
21df8fc8 | 4311 | |
cc1e2398 | 4312 | if (pVBInfo->IF_DEF_LVDS == 0) |
1d7f656d KT |
4313 | /* DVO/DVI signal off */ |
4314 | XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo); | |
cc1e2398 | 4315 | } |
21df8fc8 | 4316 | |
ec9e5d3e | 4317 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x20); |
cc1e2398 | 4318 | } |
21df8fc8 | 4319 | |
cc1e2398 AK |
4320 | static void XGI_WaitDisply(struct vb_device_info *pVBInfo) |
4321 | { | |
d8ad0a6d | 4322 | while ((inb(pVBInfo->P3da) & 0x01)) |
cc1e2398 | 4323 | break; |
21df8fc8 | 4324 | |
d8ad0a6d | 4325 | while (!(inb(pVBInfo->P3da) & 0x01)) |
cc1e2398 AK |
4326 | break; |
4327 | } | |
21df8fc8 | 4328 | |
cc1e2398 AK |
4329 | #if 0 |
4330 | static void XGI_WaitDisplay(struct vb_device_info *pVBInfo) | |
4331 | { | |
1d7f656d KT |
4332 | while (!(inb(pVBInfo->P3da) & 0x01)) |
4333 | ; | |
4334 | while (inb(pVBInfo->P3da) & 0x01) | |
4335 | ; | |
cc1e2398 AK |
4336 | } |
4337 | #endif | |
21df8fc8 | 4338 | |
cc1e2398 AK |
4339 | static void XGI_AutoThreshold(struct vb_device_info *pVBInfo) |
4340 | { | |
4341 | if (!(pVBInfo->SetFlag & Win9xDOSMode)) | |
b9bf6e4e | 4342 | xgifb_reg_or(pVBInfo->Part1Port, 0x01, 0x40); |
cc1e2398 | 4343 | } |
21df8fc8 | 4344 | |
1d7f656d KT |
4345 | static void XGI_SaveCRT2Info(unsigned short ModeNo, |
4346 | struct vb_device_info *pVBInfo) | |
cc1e2398 AK |
4347 | { |
4348 | unsigned short temp1, temp2; | |
21df8fc8 | 4349 | |
1d7f656d KT |
4350 | /* reserve CR34 for CRT1 Mode No */ |
4351 | xgifb_reg_set(pVBInfo->P3d4, 0x34, ModeNo); | |
cc1e2398 AK |
4352 | temp1 = (pVBInfo->VBInfo & SetInSlaveMode) >> 8; |
4353 | temp2 = ~(SetInSlaveMode >> 8); | |
ec9e5d3e | 4354 | xgifb_reg_and_or(pVBInfo->P3d4, 0x31, temp2, temp1); |
cc1e2398 | 4355 | } |
21df8fc8 | 4356 | |
1d7f656d KT |
4357 | static void XGI_GetCRT2ResInfo(unsigned short ModeNo, |
4358 | unsigned short ModeIdIndex, | |
4359 | struct vb_device_info *pVBInfo) | |
cc1e2398 AK |
4360 | { |
4361 | unsigned short xres, yres, modeflag, resindex; | |
21df8fc8 | 4362 | |
cc1e2398 AK |
4363 | resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); |
4364 | if (ModeNo <= 0x13) { | |
4365 | xres = pVBInfo->StResInfo[resindex].HTotal; | |
4366 | yres = pVBInfo->StResInfo[resindex].VTotal; | |
1d7f656d KT |
4367 | /* si+St_ResInfo */ |
4368 | /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;*/ | |
21df8fc8 | 4369 | } else { |
cc1e2398 AK |
4370 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ |
4371 | yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */ | |
1d7f656d KT |
4372 | /* si+St_ModeFlag */ |
4373 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
21df8fc8 | 4374 | |
cc1e2398 AK |
4375 | /* |
4376 | if (pVBInfo->IF_DEF_FSTN) { | |
4377 | xres *= 2; | |
4378 | yres *= 2; | |
4379 | } else { | |
4380 | */ | |
4381 | if (modeflag & HalfDCLK) | |
4382 | xres *= 2; | |
21df8fc8 | 4383 | |
cc1e2398 AK |
4384 | if (modeflag & DoubleScanMode) |
4385 | yres *= 2; | |
4386 | /* } */ | |
4387 | } | |
21df8fc8 | 4388 | |
cc1e2398 AK |
4389 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
4390 | if (pVBInfo->IF_DEF_LVDS == 0) { | |
4391 | if (pVBInfo->LCDResInfo == Panel1600x1200) { | |
4392 | if (!(pVBInfo->LCDInfo & LCDVESATiming)) { | |
4393 | if (yres == 1024) | |
4394 | yres = 1056; | |
21df8fc8 PS |
4395 | } |
4396 | } | |
4397 | ||
cc1e2398 AK |
4398 | if (pVBInfo->LCDResInfo == Panel1280x1024) { |
4399 | if (yres == 400) | |
4400 | yres = 405; | |
4401 | else if (yres == 350) | |
4402 | yres = 360; | |
4403 | ||
4404 | if (pVBInfo->LCDInfo & LCDVESATiming) { | |
4405 | if (yres == 360) | |
4406 | yres = 375; | |
21df8fc8 PS |
4407 | } |
4408 | } | |
4409 | ||
cc1e2398 AK |
4410 | if (pVBInfo->LCDResInfo == Panel1024x768) { |
4411 | if (!(pVBInfo->LCDInfo & LCDVESATiming)) { | |
4412 | if (!(pVBInfo->LCDInfo | |
4413 | & LCDNonExpanding)) { | |
4414 | if (yres == 350) | |
4415 | yres = 357; | |
4416 | else if (yres == 400) | |
4417 | yres = 420; | |
4418 | else if (yres == 480) | |
4419 | yres = 525; | |
4420 | } | |
21df8fc8 PS |
4421 | } |
4422 | } | |
4423 | } | |
cc1e2398 AK |
4424 | |
4425 | if (xres == 720) | |
4426 | xres = 640; | |
21df8fc8 PS |
4427 | } |
4428 | ||
cc1e2398 AK |
4429 | pVBInfo->VGAHDE = xres; |
4430 | pVBInfo->HDE = xres; | |
4431 | pVBInfo->VGAVDE = yres; | |
4432 | pVBInfo->VDE = yres; | |
4433 | } | |
21df8fc8 | 4434 | |
cc1e2398 AK |
4435 | static unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo) |
4436 | { | |
21df8fc8 | 4437 | |
cc1e2398 AK |
4438 | if ((pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) && |
4439 | (pVBInfo->LCDInfo & SetLCDDualLink)) /* shampoo0129 */ | |
4440 | return 1; | |
21df8fc8 | 4441 | |
cc1e2398 AK |
4442 | return 0; |
4443 | } | |
4444 | ||
1d7f656d KT |
4445 | static void XGI_GetRAMDAC2DATA(unsigned short ModeNo, |
4446 | unsigned short ModeIdIndex, | |
4447 | unsigned short RefreshRateTableIndex, | |
4448 | struct vb_device_info *pVBInfo) | |
cc1e2398 AK |
4449 | { |
4450 | unsigned short tempax, tempbx, temp1, temp2, modeflag = 0, tempcx, | |
4451 | StandTableIndex, CRT1Index; | |
4452 | ||
4453 | pVBInfo->RVBHCMAX = 1; | |
4454 | pVBInfo->RVBHCFACT = 1; | |
4455 | ||
4456 | if (ModeNo <= 0x13) { | |
4457 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
4458 | StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo); | |
4459 | tempax = pVBInfo->StandTable[StandTableIndex].CRTC[0]; | |
4460 | tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[6]; | |
4461 | temp1 = pVBInfo->StandTable[StandTableIndex].CRTC[7]; | |
4462 | } else { | |
4463 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
1d7f656d KT |
4464 | CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex]. |
4465 | Ext_CRT1CRTC; | |
cc1e2398 | 4466 | CRT1Index &= IndexMask; |
1d7f656d KT |
4467 | temp1 = (unsigned short) pVBInfo-> |
4468 | XGINEWUB_CRT1Table[CRT1Index].CR[0]; | |
4469 | temp2 = (unsigned short) pVBInfo-> | |
4470 | XGINEWUB_CRT1Table[CRT1Index].CR[5]; | |
cc1e2398 | 4471 | tempax = (temp1 & 0xFF) | ((temp2 & 0x03) << 8); |
1d7f656d KT |
4472 | tempbx = (unsigned short) pVBInfo-> |
4473 | XGINEWUB_CRT1Table[CRT1Index].CR[8]; | |
4474 | tempcx = (unsigned short) pVBInfo-> | |
4475 | XGINEWUB_CRT1Table[CRT1Index].CR[14] << 8; | |
cc1e2398 AK |
4476 | tempcx &= 0x0100; |
4477 | tempcx = tempcx << 2; | |
4478 | tempbx |= tempcx; | |
1d7f656d KT |
4479 | temp1 = (unsigned short) pVBInfo-> |
4480 | XGINEWUB_CRT1Table[CRT1Index].CR[9]; | |
cc1e2398 AK |
4481 | } |
4482 | ||
4483 | if (temp1 & 0x01) | |
4484 | tempbx |= 0x0100; | |
4485 | ||
4486 | if (temp1 & 0x20) | |
4487 | tempbx |= 0x0200; | |
4488 | tempax += 5; | |
4489 | ||
4490 | if (modeflag & Charx8Dot) | |
4491 | tempax *= 8; | |
4492 | else | |
4493 | tempax *= 9; | |
4494 | ||
4495 | pVBInfo->VGAHT = tempax; | |
4496 | pVBInfo->HT = tempax; | |
4497 | tempbx++; | |
4498 | pVBInfo->VGAVT = tempbx; | |
4499 | pVBInfo->VT = tempbx; | |
4500 | } | |
4501 | ||
4502 | static void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex, | |
4503 | unsigned short RefreshRateTableIndex, | |
4504 | struct vb_device_info *pVBInfo) | |
4505 | { | |
4506 | unsigned short tempax = 0, tempbx, modeflag, resinfo; | |
4507 | ||
4508 | struct XGI_LCDDataStruct *LCDPtr = NULL; | |
4509 | struct XGI_TVDataStruct *TVPtr = NULL; | |
4510 | ||
4511 | if (ModeNo <= 0x13) { | |
1d7f656d KT |
4512 | /* si+St_ResInfo */ |
4513 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
cc1e2398 AK |
4514 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
4515 | } else { | |
1d7f656d KT |
4516 | /* si+Ext_ResInfo */ |
4517 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
cc1e2398 AK |
4518 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
4519 | } | |
4520 | ||
4521 | pVBInfo->NewFlickerMode = 0; | |
4522 | pVBInfo->RVBHRS = 50; | |
4523 | ||
4524 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { | |
4525 | XGI_GetRAMDAC2DATA(ModeNo, ModeIdIndex, RefreshRateTableIndex, | |
4526 | pVBInfo); | |
4527 | return; | |
4528 | } | |
4529 | ||
4530 | tempbx = 4; | |
4531 | ||
4532 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { | |
4533 | LCDPtr = (struct XGI_LCDDataStruct *) XGI_GetLcdPtr(tempbx, | |
4534 | ModeNo, ModeIdIndex, RefreshRateTableIndex, | |
4535 | pVBInfo); | |
4536 | ||
4537 | pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX; | |
4538 | pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT; | |
4539 | pVBInfo->VGAHT = LCDPtr->VGAHT; | |
4540 | pVBInfo->VGAVT = LCDPtr->VGAVT; | |
4541 | pVBInfo->HT = LCDPtr->LCDHT; | |
4542 | pVBInfo->VT = LCDPtr->LCDVT; | |
21df8fc8 | 4543 | |
21df8fc8 | 4544 | if (pVBInfo->LCDResInfo == Panel1024x768) { |
cc1e2398 AK |
4545 | tempax = 1024; |
4546 | tempbx = 768; | |
4547 | ||
4548 | if (!(pVBInfo->LCDInfo & LCDVESATiming)) { | |
4549 | if (pVBInfo->VGAVDE == 357) | |
4550 | tempbx = 527; | |
4551 | else if (pVBInfo->VGAVDE == 420) | |
4552 | tempbx = 620; | |
4553 | else if (pVBInfo->VGAVDE == 525) | |
4554 | tempbx = 775; | |
4555 | else if (pVBInfo->VGAVDE == 600) | |
4556 | tempbx = 775; | |
4557 | /* else if (pVBInfo->VGAVDE==350) tempbx=560; */ | |
4558 | /* else if (pVBInfo->VGAVDE==400) tempbx=640; */ | |
4559 | else | |
4560 | tempbx = 768; | |
4561 | } else | |
4562 | tempbx = 768; | |
4563 | } else if (pVBInfo->LCDResInfo == Panel1024x768x75) { | |
4564 | tempax = 1024; | |
4565 | tempbx = 768; | |
4566 | } else if (pVBInfo->LCDResInfo == Panel1280x1024) { | |
4567 | tempax = 1280; | |
4568 | if (pVBInfo->VGAVDE == 360) | |
4569 | tempbx = 768; | |
4570 | else if (pVBInfo->VGAVDE == 375) | |
4571 | tempbx = 800; | |
4572 | else if (pVBInfo->VGAVDE == 405) | |
4573 | tempbx = 864; | |
4574 | else | |
4575 | tempbx = 1024; | |
4576 | } else if (pVBInfo->LCDResInfo == Panel1280x1024x75) { | |
4577 | tempax = 1280; | |
4578 | tempbx = 1024; | |
4579 | } else if (pVBInfo->LCDResInfo == Panel1280x960) { | |
4580 | tempax = 1280; | |
4581 | if (pVBInfo->VGAVDE == 350) | |
4582 | tempbx = 700; | |
4583 | else if (pVBInfo->VGAVDE == 400) | |
4584 | tempbx = 800; | |
4585 | else if (pVBInfo->VGAVDE == 1024) | |
4586 | tempbx = 960; | |
4587 | else | |
4588 | tempbx = 960; | |
4589 | } else if (pVBInfo->LCDResInfo == Panel1400x1050) { | |
4590 | tempax = 1400; | |
4591 | tempbx = 1050; | |
4592 | ||
4593 | if (pVBInfo->VGAVDE == 1024) { | |
4594 | tempax = 1280; | |
4595 | tempbx = 1024; | |
4596 | } | |
4597 | } else if (pVBInfo->LCDResInfo == Panel1600x1200) { | |
4598 | tempax = 1600; | |
4599 | tempbx = 1200; /* alan 10/14/2003 */ | |
21df8fc8 | 4600 | if (!(pVBInfo->LCDInfo & LCDVESATiming)) { |
cc1e2398 AK |
4601 | if (pVBInfo->VGAVDE == 350) |
4602 | tempbx = 875; | |
4603 | else if (pVBInfo->VGAVDE == 400) | |
4604 | tempbx = 1000; | |
21df8fc8 PS |
4605 | } |
4606 | } | |
21df8fc8 | 4607 | |
cc1e2398 AK |
4608 | if (pVBInfo->LCDInfo & LCDNonExpanding) { |
4609 | tempax = pVBInfo->VGAHDE; | |
4610 | tempbx = pVBInfo->VGAVDE; | |
4611 | } | |
21df8fc8 | 4612 | |
cc1e2398 AK |
4613 | pVBInfo->HDE = tempax; |
4614 | pVBInfo->VDE = tempbx; | |
4615 | return; | |
4616 | } | |
21df8fc8 | 4617 | |
cc1e2398 AK |
4618 | if (pVBInfo->VBInfo & (SetCRT2ToTV)) { |
4619 | tempbx = 4; | |
4620 | TVPtr = (struct XGI_TVDataStruct *) XGI_GetTVPtr(tempbx, | |
4621 | ModeNo, ModeIdIndex, RefreshRateTableIndex, | |
4622 | pVBInfo); | |
21df8fc8 | 4623 | |
cc1e2398 AK |
4624 | pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX; |
4625 | pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT; | |
4626 | pVBInfo->VGAHT = TVPtr->VGAHT; | |
4627 | pVBInfo->VGAVT = TVPtr->VGAVT; | |
4628 | pVBInfo->HDE = TVPtr->TVHDE; | |
4629 | pVBInfo->VDE = TVPtr->TVVDE; | |
4630 | pVBInfo->RVBHRS = TVPtr->RVBHRS; | |
4631 | pVBInfo->NewFlickerMode = TVPtr->FlickerMode; | |
21df8fc8 | 4632 | |
cc1e2398 AK |
4633 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
4634 | if (resinfo == 0x08) | |
4635 | pVBInfo->NewFlickerMode = 0x40; | |
4636 | else if (resinfo == 0x09) | |
4637 | pVBInfo->NewFlickerMode = 0x40; | |
4638 | else if (resinfo == 0x12) | |
4639 | pVBInfo->NewFlickerMode = 0x40; | |
21df8fc8 | 4640 | |
cc1e2398 AK |
4641 | if (pVBInfo->VGAVDE == 350) |
4642 | pVBInfo->TVInfo |= TVSimuMode; | |
21df8fc8 | 4643 | |
cc1e2398 AK |
4644 | tempax = ExtHiTVHT; |
4645 | tempbx = ExtHiTVVT; | |
21df8fc8 | 4646 | |
cc1e2398 | 4647 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
21df8fc8 | 4648 | if (pVBInfo->TVInfo & TVSimuMode) { |
cc1e2398 AK |
4649 | tempax = StHiTVHT; |
4650 | tempbx = StHiTVVT; | |
4651 | ||
4652 | if (!(modeflag & Charx8Dot)) { | |
4653 | tempax = StHiTextTVHT; | |
4654 | tempbx = StHiTextTVVT; | |
21df8fc8 PS |
4655 | } |
4656 | } | |
4657 | } | |
cc1e2398 AK |
4658 | } else if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { |
4659 | if (pVBInfo->TVInfo & SetYPbPrMode750p) { | |
4660 | tempax = YPbPrTV750pHT; /* Ext750pTVHT */ | |
4661 | tempbx = YPbPrTV750pVT; /* Ext750pTVVT */ | |
4662 | } | |
4663 | ||
4664 | if (pVBInfo->TVInfo & SetYPbPrMode525p) { | |
4665 | tempax = YPbPrTV525pHT; /* Ext525pTVHT */ | |
4666 | tempbx = YPbPrTV525pVT; /* Ext525pTVVT */ | |
4667 | } else if (pVBInfo->TVInfo & SetYPbPrMode525i) { | |
4668 | tempax = YPbPrTV525iHT; /* Ext525iTVHT */ | |
4669 | tempbx = YPbPrTV525iVT; /* Ext525iTVVT */ | |
4670 | if (pVBInfo->TVInfo & NTSC1024x768) | |
4671 | tempax = NTSC1024x768HT; | |
4672 | } | |
21df8fc8 | 4673 | } else { |
cc1e2398 AK |
4674 | tempax = PALHT; |
4675 | tempbx = PALVT; | |
4676 | if (!(pVBInfo->TVInfo & SetPALTV)) { | |
4677 | tempax = NTSCHT; | |
4678 | tempbx = NTSCVT; | |
4679 | if (pVBInfo->TVInfo & NTSC1024x768) | |
4680 | tempax = NTSC1024x768HT; | |
21df8fc8 PS |
4681 | } |
4682 | } | |
21df8fc8 | 4683 | |
cc1e2398 AK |
4684 | pVBInfo->HT = tempax; |
4685 | pVBInfo->VT = tempbx; | |
4686 | return; | |
21df8fc8 | 4687 | } |
21df8fc8 PS |
4688 | } |
4689 | ||
cc1e2398 | 4690 | static void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex, |
21df8fc8 | 4691 | unsigned short RefreshRateTableIndex, |
21df8fc8 | 4692 | struct vb_device_info *pVBInfo) |
d7636e0b | 4693 | { |
cc1e2398 | 4694 | unsigned char di_0, di_1, tempal; |
21df8fc8 | 4695 | |
cc1e2398 AK |
4696 | tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex, |
4697 | pVBInfo); | |
4698 | XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo); | |
4699 | XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo); | |
21df8fc8 | 4700 | |
cc1e2398 AK |
4701 | if (pVBInfo->VBType & VB_XGI301) { /* shampoo 0129 */ |
4702 | /* 301 */ | |
8104e329 AK |
4703 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, 0x10); |
4704 | xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1); | |
4705 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0); | |
cc1e2398 | 4706 | } else { /* 301b/302b/301lv/302lv */ |
8104e329 AK |
4707 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0); |
4708 | xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1); | |
21df8fc8 PS |
4709 | } |
4710 | ||
8104e329 | 4711 | xgifb_reg_set(pVBInfo->Part4Port, 0x00, 0x12); |
21df8fc8 | 4712 | |
cc1e2398 | 4713 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) |
b9bf6e4e | 4714 | xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x28); |
cc1e2398 | 4715 | else |
b9bf6e4e | 4716 | xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x08); |
cc1e2398 | 4717 | } |
21df8fc8 | 4718 | |
cc1e2398 AK |
4719 | static unsigned short XGI_GetColorDepth(unsigned short ModeNo, |
4720 | unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) | |
4721 | { | |
4722 | unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8 }; | |
4723 | short index; | |
4724 | unsigned short modeflag; | |
21df8fc8 | 4725 | |
cc1e2398 AK |
4726 | if (ModeNo <= 0x13) |
4727 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
4728 | else | |
4729 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
21df8fc8 | 4730 | |
cc1e2398 | 4731 | index = (modeflag & ModeInfoFlag) - ModeEGA; |
21df8fc8 | 4732 | |
cc1e2398 AK |
4733 | if (index < 0) |
4734 | index = 0; | |
21df8fc8 | 4735 | |
cc1e2398 AK |
4736 | return ColorDepth[index]; |
4737 | } | |
21df8fc8 | 4738 | |
1d7f656d KT |
4739 | static unsigned short XGI_GetOffset(unsigned short ModeNo, |
4740 | unsigned short ModeIdIndex, | |
cc1e2398 AK |
4741 | unsigned short RefreshRateTableIndex, |
4742 | struct xgi_hw_device_info *HwDeviceExtension, | |
4743 | struct vb_device_info *pVBInfo) | |
4744 | { | |
4745 | unsigned short temp, colordepth, modeinfo, index, infoflag, | |
4746 | ColorDepth[] = { 0x01, 0x02, 0x04 }; | |
21df8fc8 | 4747 | |
cc1e2398 AK |
4748 | modeinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo; |
4749 | if (ModeNo <= 0x14) | |
4750 | infoflag = 0; | |
4751 | else | |
1d7f656d KT |
4752 | infoflag = pVBInfo-> |
4753 | RefIndex[RefreshRateTableIndex].Ext_InfoFlag; | |
21df8fc8 | 4754 | |
cc1e2398 | 4755 | index = (modeinfo >> 8) & 0xFF; |
21df8fc8 | 4756 | |
cc1e2398 | 4757 | temp = pVBInfo->ScreenOffset[index]; |
21df8fc8 | 4758 | |
cc1e2398 AK |
4759 | if (infoflag & InterlaceMode) |
4760 | temp = temp << 1; | |
21df8fc8 | 4761 | |
cc1e2398 | 4762 | colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo); |
21df8fc8 | 4763 | |
cc1e2398 AK |
4764 | if ((ModeNo >= 0x7C) && (ModeNo <= 0x7E)) { |
4765 | temp = ModeNo - 0x7C; | |
4766 | colordepth = ColorDepth[temp]; | |
4767 | temp = 0x6B; | |
4768 | if (infoflag & InterlaceMode) | |
4769 | temp = temp << 1; | |
4770 | return temp * colordepth; | |
4771 | } else { | |
4772 | return temp * colordepth; | |
21df8fc8 | 4773 | } |
cc1e2398 | 4774 | } |
21df8fc8 | 4775 | |
cc1e2398 AK |
4776 | static void XGI_SetCRT2Offset(unsigned short ModeNo, |
4777 | unsigned short ModeIdIndex, | |
4778 | unsigned short RefreshRateTableIndex, | |
4779 | struct xgi_hw_device_info *HwDeviceExtension, | |
4780 | struct vb_device_info *pVBInfo) | |
4781 | { | |
4782 | unsigned short offset; | |
4783 | unsigned char temp; | |
21df8fc8 | 4784 | |
cc1e2398 AK |
4785 | if (pVBInfo->VBInfo & SetInSlaveMode) |
4786 | return; | |
21df8fc8 | 4787 | |
cc1e2398 AK |
4788 | offset = XGI_GetOffset(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
4789 | HwDeviceExtension, pVBInfo); | |
4790 | temp = (unsigned char) (offset & 0xFF); | |
8104e329 | 4791 | xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp); |
cc1e2398 | 4792 | temp = (unsigned char) ((offset & 0xFF00) >> 8); |
8104e329 | 4793 | xgifb_reg_set(pVBInfo->Part1Port, 0x09, temp); |
cc1e2398 | 4794 | temp = (unsigned char) (((offset >> 3) & 0xFF) + 1); |
8104e329 | 4795 | xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp); |
cc1e2398 | 4796 | } |
21df8fc8 | 4797 | |
cc1e2398 AK |
4798 | static void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo) |
4799 | { | |
1d7f656d KT |
4800 | /* threshold high ,disable auto threshold */ |
4801 | xgifb_reg_set(pVBInfo->Part1Port, 0x01, 0x3B); | |
4802 | /* threshold low default 04h */ | |
4803 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x02, ~(0x3F), 0x04); | |
cc1e2398 | 4804 | } |
21df8fc8 | 4805 | |
cc1e2398 AK |
4806 | static void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, |
4807 | struct xgi_hw_device_info *HwDeviceExtension, | |
4808 | unsigned short RefreshRateTableIndex, | |
4809 | struct vb_device_info *pVBInfo) | |
4810 | { | |
4811 | unsigned short tempcx = 0, CRT1Index = 0, resinfo = 0; | |
21df8fc8 | 4812 | |
cc1e2398 | 4813 | if (ModeNo > 0x13) { |
1d7f656d KT |
4814 | CRT1Index = pVBInfo-> |
4815 | RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; | |
cc1e2398 AK |
4816 | CRT1Index &= IndexMask; |
4817 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; | |
4818 | } | |
21df8fc8 | 4819 | |
cc1e2398 AK |
4820 | XGI_SetCRT2Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
4821 | HwDeviceExtension, pVBInfo); | |
4822 | XGI_SetCRT2FIFO(pVBInfo); | |
4823 | /* XGI_SetCRT2Sync(ModeNo,RefreshRateTableIndex); */ | |
21df8fc8 | 4824 | |
cc1e2398 | 4825 | for (tempcx = 4; tempcx < 7; tempcx++) |
8104e329 | 4826 | xgifb_reg_set(pVBInfo->Part1Port, tempcx, 0x0); |
21df8fc8 | 4827 | |
8104e329 AK |
4828 | xgifb_reg_set(pVBInfo->Part1Port, 0x50, 0x00); |
4829 | xgifb_reg_set(pVBInfo->Part1Port, 0x02, 0x44); /* temp 0206 */ | |
cc1e2398 | 4830 | } |
21df8fc8 | 4831 | |
cc1e2398 AK |
4832 | static void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, |
4833 | struct xgi_hw_device_info *HwDeviceExtension, | |
4834 | unsigned short RefreshRateTableIndex, | |
4835 | struct vb_device_info *pVBInfo) | |
4836 | { | |
4837 | unsigned short temp = 0, tempax = 0, tempbx = 0, tempcx = 0, | |
4838 | pushbx = 0, CRT1Index = 0, modeflag, resinfo = 0; | |
4839 | ||
4840 | if (ModeNo > 0x13) { | |
1d7f656d KT |
4841 | CRT1Index = pVBInfo-> |
4842 | RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; | |
cc1e2398 AK |
4843 | CRT1Index &= IndexMask; |
4844 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; | |
21df8fc8 PS |
4845 | } |
4846 | ||
cc1e2398 AK |
4847 | if (ModeNo <= 0x13) |
4848 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
4849 | else | |
4850 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
21df8fc8 | 4851 | |
cc1e2398 AK |
4852 | /* bainy change table name */ |
4853 | if (modeflag & HalfDCLK) { | |
1d7f656d KT |
4854 | /* BTVGA2HT 0x08,0x09 */ |
4855 | temp = (pVBInfo->VGAHT / 2 - 1) & 0x0FF; | |
8104e329 | 4856 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp); |
cc1e2398 | 4857 | temp = (((pVBInfo->VGAHT / 2 - 1) & 0xFF00) >> 8) << 4; |
ec9e5d3e | 4858 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp); |
1d7f656d KT |
4859 | /* BTVGA2HDEE 0x0A,0x0C */ |
4860 | temp = (pVBInfo->VGAHDE / 2 + 16) & 0x0FF; | |
8104e329 | 4861 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); |
cc1e2398 AK |
4862 | tempcx = ((pVBInfo->VGAHT - pVBInfo->VGAHDE) / 2) >> 2; |
4863 | pushbx = pVBInfo->VGAHDE / 2 + 16; | |
21df8fc8 | 4864 | tempcx = tempcx >> 1; |
cc1e2398 AK |
4865 | tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */ |
4866 | tempcx += tempbx; | |
21df8fc8 | 4867 | |
cc1e2398 AK |
4868 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
4869 | tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4]; | |
1d7f656d KT |
4870 | tempbx |= ((pVBInfo-> |
4871 | XGINEWUB_CRT1Table[CRT1Index].CR[14] & | |
4872 | 0xC0) << 2); | |
cc1e2398 AK |
4873 | tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */ |
4874 | tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5]; | |
4875 | tempcx &= 0x1F; | |
4876 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[15]; | |
4877 | temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */ | |
4878 | tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */ | |
4879 | } | |
21df8fc8 | 4880 | |
cc1e2398 AK |
4881 | tempbx += 4; |
4882 | tempcx += 4; | |
21df8fc8 | 4883 | |
cc1e2398 AK |
4884 | if (tempcx > (pVBInfo->VGAHT / 2)) |
4885 | tempcx = pVBInfo->VGAHT / 2; | |
21df8fc8 | 4886 | |
cc1e2398 | 4887 | temp = tempbx & 0x00FF; |
21df8fc8 | 4888 | |
8104e329 | 4889 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
cc1e2398 AK |
4890 | } else { |
4891 | temp = (pVBInfo->VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */ | |
8104e329 | 4892 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp); |
cc1e2398 | 4893 | temp = (((pVBInfo->VGAHT - 1) & 0xFF00) >> 8) << 4; |
ec9e5d3e | 4894 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp); |
1d7f656d KT |
4895 | /* BTVGA2HDEE 0x0A,0x0C */ |
4896 | temp = (pVBInfo->VGAHDE + 16) & 0x0FF; | |
8104e329 | 4897 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); |
cc1e2398 AK |
4898 | tempcx = (pVBInfo->VGAHT - pVBInfo->VGAHDE) >> 2; /* cx */ |
4899 | pushbx = pVBInfo->VGAHDE + 16; | |
4900 | tempcx = tempcx >> 1; | |
4901 | tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */ | |
4902 | tempcx += tempbx; | |
21df8fc8 | 4903 | |
cc1e2398 AK |
4904 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
4905 | tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[3]; | |
1d7f656d KT |
4906 | tempbx |= ((pVBInfo-> |
4907 | XGINEWUB_CRT1Table[CRT1Index].CR[5] & | |
4908 | 0xC0) << 2); | |
cc1e2398 AK |
4909 | tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */ |
4910 | tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4]; | |
4911 | tempcx &= 0x1F; | |
4912 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[6]; | |
4913 | temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */ | |
4914 | tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */ | |
4915 | tempbx += 16; | |
4916 | tempcx += 16; | |
4917 | } | |
21df8fc8 | 4918 | |
cc1e2398 AK |
4919 | if (tempcx > pVBInfo->VGAHT) |
4920 | tempcx = pVBInfo->VGAHT; | |
21df8fc8 | 4921 | |
cc1e2398 | 4922 | temp = tempbx & 0x00FF; |
8104e329 | 4923 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
cc1e2398 | 4924 | } |
21df8fc8 | 4925 | |
cc1e2398 AK |
4926 | tempax = (tempax & 0x00FF) | (tempbx & 0xFF00); |
4927 | tempbx = pushbx; | |
4928 | tempbx = (tempbx & 0x00FF) | ((tempbx & 0xFF00) << 4); | |
4929 | tempax |= (tempbx & 0xFF00); | |
4930 | temp = (tempax & 0xFF00) >> 8; | |
8104e329 | 4931 | xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp); |
21df8fc8 | 4932 | temp = tempcx & 0x00FF; |
8104e329 | 4933 | xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp); |
cc1e2398 | 4934 | tempcx = (pVBInfo->VGAVT - 1); |
21df8fc8 | 4935 | temp = tempcx & 0x00FF; |
21df8fc8 | 4936 | |
cc1e2398 AK |
4937 | if (pVBInfo->IF_DEF_CH7005 == 1) { |
4938 | if (pVBInfo->VBInfo & 0x0C) | |
4939 | temp--; | |
21df8fc8 | 4940 | } |
21df8fc8 | 4941 | |
8104e329 | 4942 | xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp); |
cc1e2398 AK |
4943 | tempbx = pVBInfo->VGAVDE - 1; |
4944 | temp = tempbx & 0x00FF; | |
8104e329 | 4945 | xgifb_reg_set(pVBInfo->Part1Port, 0x0F, temp); |
cc1e2398 AK |
4946 | temp = ((tempbx & 0xFF00) << 3) >> 8; |
4947 | temp |= ((tempcx & 0xFF00) >> 8); | |
8104e329 | 4948 | xgifb_reg_set(pVBInfo->Part1Port, 0x12, temp); |
21df8fc8 | 4949 | |
cc1e2398 AK |
4950 | tempax = pVBInfo->VGAVDE; |
4951 | tempbx = pVBInfo->VGAVDE; | |
4952 | tempcx = pVBInfo->VGAVT; | |
1d7f656d KT |
4953 | /* BTVGA2VRS 0x10,0x11 */ |
4954 | tempbx = (pVBInfo->VGAVT + pVBInfo->VGAVDE) >> 1; | |
4955 | /* BTVGA2VRE 0x11 */ | |
4956 | tempcx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) >> 4) + tempbx + 1; | |
21df8fc8 | 4957 | |
cc1e2398 AK |
4958 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
4959 | tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[10]; | |
4960 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9]; | |
21df8fc8 | 4961 | |
cc1e2398 AK |
4962 | if (temp & 0x04) |
4963 | tempbx |= 0x0100; | |
21df8fc8 | 4964 | |
cc1e2398 AK |
4965 | if (temp & 0x080) |
4966 | tempbx |= 0x0200; | |
21df8fc8 | 4967 | |
cc1e2398 | 4968 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14]; |
21df8fc8 | 4969 | |
cc1e2398 AK |
4970 | if (temp & 0x08) |
4971 | tempbx |= 0x0400; | |
21df8fc8 | 4972 | |
cc1e2398 AK |
4973 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[11]; |
4974 | tempcx = (tempcx & 0xFF00) | (temp & 0x00FF); | |
21df8fc8 PS |
4975 | } |
4976 | ||
cc1e2398 | 4977 | temp = tempbx & 0x00FF; |
8104e329 | 4978 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); |
cc1e2398 AK |
4979 | temp = ((tempbx & 0xFF00) >> 8) << 4; |
4980 | temp = ((tempcx & 0x000F) | (temp)); | |
8104e329 | 4981 | xgifb_reg_set(pVBInfo->Part1Port, 0x11, temp); |
cc1e2398 | 4982 | tempax = 0; |
21df8fc8 | 4983 | |
cc1e2398 AK |
4984 | if (modeflag & DoubleScanMode) |
4985 | tempax |= 0x80; | |
21df8fc8 | 4986 | |
cc1e2398 AK |
4987 | if (modeflag & HalfDCLK) |
4988 | tempax |= 0x40; | |
21df8fc8 | 4989 | |
ec9e5d3e | 4990 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2C, ~0x0C0, tempax); |
cc1e2398 | 4991 | } |
21df8fc8 | 4992 | |
cc1e2398 AK |
4993 | static unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo) |
4994 | { | |
4995 | unsigned long tempax, tempbx; | |
21df8fc8 | 4996 | |
cc1e2398 AK |
4997 | tempbx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) * pVBInfo->RVBHCMAX) |
4998 | & 0xFFFF; | |
4999 | tempax = (pVBInfo->VT - pVBInfo->VDE) * pVBInfo->RVBHCFACT; | |
5000 | tempax = (tempax * pVBInfo->HT) / tempbx; | |
21df8fc8 | 5001 | |
cc1e2398 AK |
5002 | return (unsigned short) tempax; |
5003 | } | |
21df8fc8 | 5004 | |
cc1e2398 AK |
5005 | static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex, |
5006 | struct xgi_hw_device_info *HwDeviceExtension, | |
5007 | unsigned short RefreshRateTableIndex, | |
5008 | struct vb_device_info *pVBInfo) | |
5009 | { | |
5010 | unsigned short push1, push2, tempax, tempbx = 0, tempcx, temp, resinfo, | |
5011 | modeflag, CRT1Index; | |
21df8fc8 | 5012 | |
cc1e2398 | 5013 | if (ModeNo <= 0x13) { |
1d7f656d KT |
5014 | /* si+St_ResInfo */ |
5015 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
cc1e2398 AK |
5016 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
5017 | } else { | |
1d7f656d KT |
5018 | /* si+Ext_ResInfo */ |
5019 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
cc1e2398 | 5020 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
1d7f656d KT |
5021 | CRT1Index = pVBInfo-> |
5022 | RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; | |
cc1e2398 | 5023 | CRT1Index &= IndexMask; |
21df8fc8 PS |
5024 | } |
5025 | ||
cc1e2398 AK |
5026 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) |
5027 | return; | |
21df8fc8 | 5028 | |
cc1e2398 | 5029 | temp = 0xFF; /* set MAX HT */ |
8104e329 | 5030 | xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp); |
cc1e2398 AK |
5031 | /* if (modeflag & Charx8Dot) */ |
5032 | /* tempcx = 0x08; */ | |
5033 | /* else */ | |
5034 | tempcx = 0x08; | |
21df8fc8 | 5035 | |
cc1e2398 AK |
5036 | if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) |
5037 | modeflag |= Charx8Dot; | |
21df8fc8 | 5038 | |
cc1e2398 | 5039 | tempax = pVBInfo->VGAHDE; /* 0x04 Horizontal Display End */ |
21df8fc8 | 5040 | |
cc1e2398 AK |
5041 | if (modeflag & HalfDCLK) |
5042 | tempax = tempax >> 1; | |
21df8fc8 | 5043 | |
cc1e2398 AK |
5044 | tempax = (tempax / tempcx) - 1; |
5045 | tempbx |= ((tempax & 0x00FF) << 8); | |
5046 | temp = tempax & 0x00FF; | |
8104e329 | 5047 | xgifb_reg_set(pVBInfo->Part1Port, 0x04, temp); |
21df8fc8 | 5048 | |
cc1e2398 | 5049 | temp = (tempbx & 0xFF00) >> 8; |
21df8fc8 | 5050 | |
cc1e2398 AK |
5051 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
5052 | if (!(pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | |
5053 | | VB_XGI302LV | VB_XGI301C))) | |
5054 | temp += 2; | |
21df8fc8 | 5055 | |
cc1e2398 AK |
5056 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
5057 | if (pVBInfo->VBType & VB_XGI301LV) { | |
5058 | if (pVBInfo->VBExtInfo == VB_YPbPr1080i) { | |
5059 | if (resinfo == 7) | |
5060 | temp -= 2; | |
5061 | } | |
5062 | } else if (resinfo == 7) { | |
5063 | temp -= 2; | |
5064 | } | |
21df8fc8 | 5065 | } |
21df8fc8 PS |
5066 | } |
5067 | ||
1d7f656d KT |
5068 | /* 0x05 Horizontal Display Start */ |
5069 | xgifb_reg_set(pVBInfo->Part1Port, 0x05, temp); | |
5070 | /* 0x06 Horizontal Blank end */ | |
5071 | xgifb_reg_set(pVBInfo->Part1Port, 0x06, 0x03); | |
21df8fc8 | 5072 | |
cc1e2398 AK |
5073 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { /* 030226 bainy */ |
5074 | if (pVBInfo->VBInfo & SetCRT2ToTV) | |
5075 | tempax = pVBInfo->VGAHT; | |
5076 | else | |
5077 | tempax = XGI_GetVGAHT2(pVBInfo); | |
5078 | } | |
21df8fc8 | 5079 | |
cc1e2398 AK |
5080 | if (tempax >= pVBInfo->VGAHT) |
5081 | tempax = pVBInfo->VGAHT; | |
21df8fc8 | 5082 | |
cc1e2398 AK |
5083 | if (modeflag & HalfDCLK) |
5084 | tempax = tempax >> 1; | |
5085 | ||
5086 | tempax = (tempax / tempcx) - 5; | |
5087 | tempcx = tempax; /* 20030401 0x07 horizontal Retrace Start */ | |
5088 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { | |
5089 | temp = (tempbx & 0x00FF) - 1; | |
5090 | if (!(modeflag & HalfDCLK)) { | |
5091 | temp -= 6; | |
5092 | if (pVBInfo->TVInfo & TVSimuMode) { | |
5093 | temp -= 4; | |
5094 | if (ModeNo > 0x13) | |
5095 | temp -= 10; | |
5096 | } | |
5097 | } | |
21df8fc8 | 5098 | } else { |
cc1e2398 AK |
5099 | /* tempcx = tempbx & 0x00FF ; */ |
5100 | tempbx = (tempbx & 0xFF00) >> 8; | |
5101 | tempcx = (tempcx + tempbx) >> 1; | |
5102 | temp = (tempcx & 0x00FF) + 2; | |
21df8fc8 | 5103 | |
cc1e2398 AK |
5104 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
5105 | temp -= 1; | |
5106 | if (!(modeflag & HalfDCLK)) { | |
5107 | if ((modeflag & Charx8Dot)) { | |
5108 | temp += 4; | |
5109 | if (pVBInfo->VGAHDE >= 800) | |
5110 | temp -= 6; | |
5111 | } | |
5112 | } | |
5113 | } else { | |
5114 | if (!(modeflag & HalfDCLK)) { | |
5115 | temp -= 4; | |
5116 | if (pVBInfo->LCDResInfo != Panel1280x960) { | |
5117 | if (pVBInfo->VGAHDE >= 800) { | |
5118 | temp -= 7; | |
1d7f656d KT |
5119 | if (pVBInfo->ModeType == |
5120 | ModeEGA) { | |
5121 | if (pVBInfo->VGAVDE == | |
5122 | 1024) { | |
cc1e2398 | 5123 | temp += 15; |
1d7f656d KT |
5124 | if (pVBInfo->LCDResInfo != Panel1280x1024) { |
5125 | temp += | |
5126 | 7; | |
cc1e2398 AK |
5127 | } |
5128 | } | |
5129 | } | |
21df8fc8 | 5130 | |
cc1e2398 AK |
5131 | if (pVBInfo->VGAHDE >= 1280) { |
5132 | if (pVBInfo->LCDResInfo | |
5133 | != Panel1280x960) { | |
5134 | if (pVBInfo->LCDInfo | |
5135 | & LCDNonExpanding) { | |
5136 | temp | |
5137 | += 28; | |
5138 | } | |
5139 | } | |
5140 | } | |
5141 | } | |
5142 | } | |
5143 | } | |
5144 | } | |
5145 | } | |
21df8fc8 | 5146 | |
1d7f656d KT |
5147 | /* 0x07 Horizontal Retrace Start */ |
5148 | xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp); | |
5149 | /* 0x08 Horizontal Retrace End */ | |
5150 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, 0); | |
21df8fc8 | 5151 | |
cc1e2398 AK |
5152 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
5153 | if (pVBInfo->TVInfo & TVSimuMode) { | |
5154 | if ((ModeNo == 0x06) || (ModeNo == 0x10) || (ModeNo | |
5155 | == 0x11) || (ModeNo == 0x13) || (ModeNo | |
5156 | == 0x0F)) { | |
8104e329 AK |
5157 | xgifb_reg_set(pVBInfo->Part1Port, 0x07, 0x5b); |
5158 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, 0x03); | |
cc1e2398 | 5159 | } |
21df8fc8 | 5160 | |
cc1e2398 AK |
5161 | if ((ModeNo == 0x00) || (ModeNo == 0x01)) { |
5162 | if (pVBInfo->TVInfo & SetNTSCTV) { | |
8104e329 | 5163 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 | 5164 | 0x07, 0x2A); |
8104e329 | 5165 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 AK |
5166 | 0x08, 0x61); |
5167 | } else { | |
8104e329 | 5168 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 | 5169 | 0x07, 0x2A); |
8104e329 | 5170 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 | 5171 | 0x08, 0x41); |
8104e329 | 5172 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 AK |
5173 | 0x0C, 0xF0); |
5174 | } | |
5175 | } | |
21df8fc8 | 5176 | |
cc1e2398 AK |
5177 | if ((ModeNo == 0x02) || (ModeNo == 0x03) || (ModeNo |
5178 | == 0x07)) { | |
5179 | if (pVBInfo->TVInfo & SetNTSCTV) { | |
8104e329 | 5180 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 | 5181 | 0x07, 0x54); |
8104e329 | 5182 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 AK |
5183 | 0x08, 0x00); |
5184 | } else { | |
8104e329 | 5185 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 | 5186 | 0x07, 0x55); |
8104e329 | 5187 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 | 5188 | 0x08, 0x00); |
8104e329 | 5189 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 AK |
5190 | 0x0C, 0xF0); |
5191 | } | |
5192 | } | |
21df8fc8 | 5193 | |
cc1e2398 AK |
5194 | if ((ModeNo == 0x04) || (ModeNo == 0x05) || (ModeNo |
5195 | == 0x0D) || (ModeNo == 0x50)) { | |
5196 | if (pVBInfo->TVInfo & SetNTSCTV) { | |
8104e329 | 5197 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 | 5198 | 0x07, 0x30); |
8104e329 | 5199 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 AK |
5200 | 0x08, 0x03); |
5201 | } else { | |
8104e329 | 5202 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 | 5203 | 0x07, 0x2f); |
8104e329 | 5204 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 AK |
5205 | 0x08, 0x02); |
5206 | } | |
21df8fc8 | 5207 | } |
21df8fc8 PS |
5208 | } |
5209 | } | |
5210 | ||
8104e329 | 5211 | xgifb_reg_set(pVBInfo->Part1Port, 0x18, 0x03); /* 0x18 SR0B */ |
ec9e5d3e | 5212 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0xF0, 0x00); |
8104e329 | 5213 | xgifb_reg_set(pVBInfo->Part1Port, 0x09, 0xFF); /* 0x09 Set Max VT */ |
21df8fc8 | 5214 | |
cc1e2398 AK |
5215 | tempbx = pVBInfo->VGAVT; |
5216 | push1 = tempbx; | |
5217 | tempcx = 0x121; | |
5218 | tempbx = pVBInfo->VGAVDE; /* 0x0E Virtical Display End */ | |
21df8fc8 | 5219 | |
cc1e2398 AK |
5220 | if (tempbx == 357) |
5221 | tempbx = 350; | |
5222 | if (tempbx == 360) | |
5223 | tempbx = 350; | |
5224 | if (tempbx == 375) | |
5225 | tempbx = 350; | |
5226 | if (tempbx == 405) | |
5227 | tempbx = 400; | |
5228 | if (tempbx == 525) | |
5229 | tempbx = 480; | |
21df8fc8 | 5230 | |
cc1e2398 | 5231 | push2 = tempbx; |
21df8fc8 | 5232 | |
cc1e2398 AK |
5233 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
5234 | if (pVBInfo->LCDResInfo == Panel1024x768) { | |
5235 | if (!(pVBInfo->LCDInfo & LCDVESATiming)) { | |
5236 | if (tempbx == 350) | |
5237 | tempbx += 5; | |
5238 | if (tempbx == 480) | |
5239 | tempbx += 5; | |
5240 | } | |
5241 | } | |
5242 | } | |
5243 | tempbx--; | |
5244 | temp = tempbx & 0x00FF; | |
5245 | tempbx--; | |
5246 | temp = tempbx & 0x00FF; | |
1d7f656d KT |
5247 | /* 0x10 vertical Blank Start */ |
5248 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); | |
cc1e2398 AK |
5249 | tempbx = push2; |
5250 | tempbx--; | |
5251 | temp = tempbx & 0x00FF; | |
8104e329 | 5252 | xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp); |
d7636e0b | 5253 | |
cc1e2398 AK |
5254 | if (tempbx & 0x0100) |
5255 | tempcx |= 0x0002; | |
21df8fc8 | 5256 | |
cc1e2398 | 5257 | tempax = 0x000B; |
21df8fc8 | 5258 | |
cc1e2398 AK |
5259 | if (modeflag & DoubleScanMode) |
5260 | tempax |= 0x08000; | |
21df8fc8 | 5261 | |
cc1e2398 AK |
5262 | if (tempbx & 0x0200) |
5263 | tempcx |= 0x0040; | |
21df8fc8 | 5264 | |
cc1e2398 | 5265 | temp = (tempax & 0xFF00) >> 8; |
8104e329 | 5266 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
21df8fc8 | 5267 | |
cc1e2398 AK |
5268 | if (tempbx & 0x0400) |
5269 | tempcx |= 0x0600; | |
21df8fc8 | 5270 | |
1d7f656d KT |
5271 | /* 0x11 Vertival Blank End */ |
5272 | xgifb_reg_set(pVBInfo->Part1Port, 0x11, 0x00); | |
21df8fc8 | 5273 | |
cc1e2398 AK |
5274 | tempax = push1; |
5275 | tempax -= tempbx; /* 0x0C Vertical Retrace Start */ | |
5276 | tempax = tempax >> 2; | |
5277 | push1 = tempax; /* push ax */ | |
5278 | ||
5279 | if (resinfo != 0x09) { | |
5280 | tempax = tempax << 1; | |
5281 | tempbx += tempax; | |
5282 | } | |
5283 | ||
5284 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { | |
5285 | if (pVBInfo->VBType & VB_XGI301LV) { | |
5286 | if (pVBInfo->TVInfo & SetYPbPrMode1080i) { | |
5287 | tempbx -= 10; | |
5288 | } else { | |
5289 | if (pVBInfo->TVInfo & TVSimuMode) { | |
5290 | if (pVBInfo->TVInfo & SetPALTV) { | |
1d7f656d KT |
5291 | if (pVBInfo->VBType & |
5292 | VB_XGI301LV) { | |
5293 | if (!(pVBInfo->TVInfo & | |
5294 | (SetYPbPrMode525p | | |
5295 | SetYPbPrMode750p | | |
5296 | SetYPbPrMode1080i))) | |
cc1e2398 AK |
5297 | tempbx += 40; |
5298 | } else { | |
5299 | tempbx += 40; | |
5300 | } | |
5301 | } | |
5302 | } | |
5303 | } | |
5304 | } else { | |
5305 | tempbx -= 10; | |
5306 | } | |
5307 | } else { | |
5308 | if (pVBInfo->TVInfo & TVSimuMode) { | |
5309 | if (pVBInfo->TVInfo & SetPALTV) { | |
5310 | if (pVBInfo->VBType & VB_XGI301LV) { | |
1d7f656d KT |
5311 | if (!(pVBInfo->TVInfo & |
5312 | (SetYPbPrMode525p | | |
5313 | SetYPbPrMode750p | | |
5314 | SetYPbPrMode1080i))) | |
cc1e2398 AK |
5315 | tempbx += 40; |
5316 | } else { | |
5317 | tempbx += 40; | |
5318 | } | |
21df8fc8 PS |
5319 | } |
5320 | } | |
5321 | } | |
cc1e2398 AK |
5322 | tempax = push1; |
5323 | tempax = tempax >> 2; | |
5324 | tempax++; | |
5325 | tempax += tempbx; | |
5326 | push1 = tempax; /* push ax */ | |
21df8fc8 | 5327 | |
cc1e2398 AK |
5328 | if ((pVBInfo->TVInfo & SetPALTV)) { |
5329 | if (tempbx <= 513) { | |
5330 | if (tempax >= 513) | |
5331 | tempbx = 513; | |
5332 | } | |
5333 | } | |
5334 | ||
5335 | temp = tempbx & 0x00FF; | |
8104e329 | 5336 | xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp); |
21df8fc8 PS |
5337 | tempbx--; |
5338 | temp = tempbx & 0x00FF; | |
8104e329 | 5339 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); |
21df8fc8 | 5340 | |
cc1e2398 AK |
5341 | if (tempbx & 0x0100) |
5342 | tempcx |= 0x0008; | |
21df8fc8 | 5343 | |
cc1e2398 | 5344 | if (tempbx & 0x0200) |
ec9e5d3e | 5345 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x0B, 0x0FF, 0x20); |
21df8fc8 | 5346 | |
cc1e2398 | 5347 | tempbx++; |
21df8fc8 | 5348 | |
cc1e2398 AK |
5349 | if (tempbx & 0x0100) |
5350 | tempcx |= 0x0004; | |
21df8fc8 | 5351 | |
cc1e2398 AK |
5352 | if (tempbx & 0x0200) |
5353 | tempcx |= 0x0080; | |
21df8fc8 | 5354 | |
cc1e2398 AK |
5355 | if (tempbx & 0x0400) |
5356 | tempcx |= 0x0C00; | |
21df8fc8 | 5357 | |
cc1e2398 AK |
5358 | tempbx = push1; /* pop ax */ |
5359 | temp = tempbx & 0x00FF; | |
5360 | temp &= 0x0F; | |
1d7f656d KT |
5361 | /* 0x0D vertical Retrace End */ |
5362 | xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp); | |
21df8fc8 | 5363 | |
cc1e2398 AK |
5364 | if (tempbx & 0x0010) |
5365 | tempcx |= 0x2000; | |
21df8fc8 | 5366 | |
cc1e2398 | 5367 | temp = tempcx & 0x00FF; |
8104e329 | 5368 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); /* 0x0A CR07 */ |
cc1e2398 | 5369 | temp = (tempcx & 0x0FF00) >> 8; |
8104e329 | 5370 | xgifb_reg_set(pVBInfo->Part1Port, 0x17, temp); /* 0x17 SR0A */ |
cc1e2398 AK |
5371 | tempax = modeflag; |
5372 | temp = (tempax & 0xFF00) >> 8; | |
21df8fc8 | 5373 | |
cc1e2398 | 5374 | temp = (temp >> 1) & 0x09; |
21df8fc8 | 5375 | |
cc1e2398 AK |
5376 | if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) |
5377 | temp |= 0x01; | |
21df8fc8 | 5378 | |
8104e329 AK |
5379 | xgifb_reg_set(pVBInfo->Part1Port, 0x16, temp); /* 0x16 SR01 */ |
5380 | xgifb_reg_set(pVBInfo->Part1Port, 0x0F, 0); /* 0x0F CR14 */ | |
5381 | xgifb_reg_set(pVBInfo->Part1Port, 0x12, 0); /* 0x12 CR17 */ | |
21df8fc8 | 5382 | |
cc1e2398 AK |
5383 | if (pVBInfo->LCDInfo & LCDRGB18Bit) |
5384 | temp = 0x80; | |
5385 | else | |
5386 | temp = 0x00; | |
21df8fc8 | 5387 | |
8104e329 | 5388 | xgifb_reg_set(pVBInfo->Part1Port, 0x1A, temp); /* 0x1A SR0E */ |
21df8fc8 | 5389 | |
cc1e2398 AK |
5390 | return; |
5391 | } | |
21df8fc8 | 5392 | |
cc1e2398 AK |
5393 | static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex, |
5394 | unsigned short RefreshRateTableIndex, | |
5395 | struct xgi_hw_device_info *HwDeviceExtension, | |
5396 | struct vb_device_info *pVBInfo) | |
5397 | { | |
5398 | unsigned short i, j, tempax, tempbx, tempcx, temp, push1, push2, | |
5399 | modeflag, resinfo, crt2crtc; | |
5400 | unsigned char *TimingPoint; | |
21df8fc8 | 5401 | |
cc1e2398 AK |
5402 | unsigned long longtemp, tempeax, tempebx, temp2, tempecx; |
5403 | ||
5404 | if (ModeNo <= 0x13) { | |
1d7f656d KT |
5405 | /* si+St_ResInfo */ |
5406 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
cc1e2398 AK |
5407 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
5408 | crt2crtc = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; | |
5409 | } else { | |
1d7f656d KT |
5410 | /* si+Ext_ResInfo */ |
5411 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
cc1e2398 | 5412 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
1d7f656d KT |
5413 | crt2crtc = pVBInfo->RefIndex[RefreshRateTableIndex]. |
5414 | Ext_CRT2CRTC; | |
21df8fc8 PS |
5415 | } |
5416 | ||
cc1e2398 AK |
5417 | tempax = 0; |
5418 | ||
5419 | if (!(pVBInfo->VBInfo & SetCRT2ToAVIDEO)) | |
5420 | tempax |= 0x0800; | |
21df8fc8 | 5421 | |
cc1e2398 AK |
5422 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) |
5423 | tempax |= 0x0400; | |
21df8fc8 | 5424 | |
cc1e2398 AK |
5425 | if (pVBInfo->VBInfo & SetCRT2ToSCART) |
5426 | tempax |= 0x0200; | |
21df8fc8 | 5427 | |
cc1e2398 AK |
5428 | if (!(pVBInfo->TVInfo & SetPALTV)) |
5429 | tempax |= 0x1000; | |
21df8fc8 | 5430 | |
cc1e2398 AK |
5431 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) |
5432 | tempax |= 0x0100; | |
21df8fc8 | 5433 | |
cc1e2398 AK |
5434 | if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)) |
5435 | tempax &= 0xfe00; | |
21df8fc8 | 5436 | |
cc1e2398 | 5437 | tempax = (tempax & 0xff00) >> 8; |
21df8fc8 | 5438 | |
8104e329 | 5439 | xgifb_reg_set(pVBInfo->Part2Port, 0x0, tempax); |
cc1e2398 | 5440 | TimingPoint = pVBInfo->NTSCTiming; |
d7636e0b | 5441 | |
cc1e2398 AK |
5442 | if (pVBInfo->TVInfo & SetPALTV) |
5443 | TimingPoint = pVBInfo->PALTiming; | |
d7636e0b | 5444 | |
cc1e2398 AK |
5445 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
5446 | TimingPoint = pVBInfo->HiTVExtTiming; | |
d7636e0b | 5447 | |
cc1e2398 AK |
5448 | if (pVBInfo->VBInfo & SetInSlaveMode) |
5449 | TimingPoint = pVBInfo->HiTVSt2Timing; | |
d7636e0b | 5450 | |
cc1e2398 AK |
5451 | if (pVBInfo->SetFlag & TVSimuMode) |
5452 | TimingPoint = pVBInfo->HiTVSt1Timing; | |
21df8fc8 | 5453 | |
cc1e2398 AK |
5454 | if (!(modeflag & Charx8Dot)) |
5455 | TimingPoint = pVBInfo->HiTVTextTiming; | |
5456 | } | |
21df8fc8 PS |
5457 | |
5458 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { | |
5459 | if (pVBInfo->TVInfo & SetYPbPrMode525i) | |
cc1e2398 AK |
5460 | TimingPoint = pVBInfo->YPbPr525iTiming; |
5461 | ||
21df8fc8 | 5462 | if (pVBInfo->TVInfo & SetYPbPrMode525p) |
cc1e2398 AK |
5463 | TimingPoint = pVBInfo->YPbPr525pTiming; |
5464 | ||
21df8fc8 | 5465 | if (pVBInfo->TVInfo & SetYPbPrMode750p) |
cc1e2398 | 5466 | TimingPoint = pVBInfo->YPbPr750pTiming; |
21df8fc8 | 5467 | } |
d7636e0b | 5468 | |
cc1e2398 | 5469 | for (i = 0x01, j = 0; i <= 0x2D; i++, j++) |
8104e329 | 5470 | xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]); |
cc1e2398 AK |
5471 | |
5472 | for (i = 0x39; i <= 0x45; i++, j++) | |
1d7f656d KT |
5473 | /* di->temp2[j] */ |
5474 | xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]); | |
cc1e2398 AK |
5475 | |
5476 | if (pVBInfo->VBInfo & SetCRT2ToTV) | |
ec9e5d3e | 5477 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, 0x00); |
cc1e2398 AK |
5478 | |
5479 | temp = pVBInfo->NewFlickerMode; | |
5480 | temp &= 0x80; | |
ec9e5d3e | 5481 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xFF, temp); |
cc1e2398 | 5482 | |
21df8fc8 | 5483 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) |
cc1e2398 | 5484 | tempax = 950; |
21df8fc8 | 5485 | |
cc1e2398 AK |
5486 | if (pVBInfo->TVInfo & SetPALTV) |
5487 | tempax = 520; | |
5488 | else | |
5489 | tempax = 440; | |
5490 | ||
5491 | if (pVBInfo->VDE <= tempax) { | |
5492 | tempax -= pVBInfo->VDE; | |
5493 | tempax = tempax >> 2; | |
5494 | tempax = (tempax & 0x00FF) | ((tempax & 0x00FF) << 8); | |
5495 | push1 = tempax; | |
5496 | temp = (tempax & 0xFF00) >> 8; | |
5497 | temp += (unsigned short) TimingPoint[0]; | |
5498 | ||
5499 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | |
5500 | | VB_XGI302LV | VB_XGI301C)) { | |
5501 | if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO | |
5502 | | SetCRT2ToSVIDEO | SetCRT2ToSCART | |
5503 | | SetCRT2ToYPbPr)) { | |
5504 | tempcx = pVBInfo->VGAHDE; | |
5505 | if (tempcx >= 1024) { | |
5506 | temp = 0x17; /* NTSC */ | |
5507 | if (pVBInfo->TVInfo & SetPALTV) | |
5508 | temp = 0x19; /* PAL */ | |
5509 | } | |
5510 | } | |
5511 | } | |
5512 | ||
8104e329 | 5513 | xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp); |
cc1e2398 AK |
5514 | tempax = push1; |
5515 | temp = (tempax & 0xFF00) >> 8; | |
5516 | temp += TimingPoint[1]; | |
5517 | ||
5518 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | |
5519 | | VB_XGI302LV | VB_XGI301C)) { | |
5520 | if ((pVBInfo->VBInfo & (SetCRT2ToAVIDEO | |
5521 | | SetCRT2ToSVIDEO | SetCRT2ToSCART | |
5522 | | SetCRT2ToYPbPr))) { | |
5523 | tempcx = pVBInfo->VGAHDE; | |
5524 | if (tempcx >= 1024) { | |
5525 | temp = 0x1D; /* NTSC */ | |
5526 | if (pVBInfo->TVInfo & SetPALTV) | |
5527 | temp = 0x52; /* PAL */ | |
5528 | } | |
5529 | } | |
5530 | } | |
8104e329 | 5531 | xgifb_reg_set(pVBInfo->Part2Port, 0x02, temp); |
21df8fc8 | 5532 | } |
d7636e0b | 5533 | |
cc1e2398 AK |
5534 | /* 301b */ |
5535 | tempcx = pVBInfo->HT; | |
d7636e0b | 5536 | |
cc1e2398 AK |
5537 | if (XGI_IsLCDDualLink(pVBInfo)) |
5538 | tempcx = tempcx >> 1; | |
21df8fc8 | 5539 | |
cc1e2398 AK |
5540 | tempcx -= 2; |
5541 | temp = tempcx & 0x00FF; | |
8104e329 | 5542 | xgifb_reg_set(pVBInfo->Part2Port, 0x1B, temp); |
21df8fc8 | 5543 | |
cc1e2398 | 5544 | temp = (tempcx & 0xFF00) >> 8; |
ec9e5d3e | 5545 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F, temp); |
21df8fc8 | 5546 | |
cc1e2398 AK |
5547 | tempcx = pVBInfo->HT >> 1; |
5548 | push1 = tempcx; /* push cx */ | |
5549 | tempcx += 7; | |
21df8fc8 | 5550 | |
cc1e2398 AK |
5551 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) |
5552 | tempcx -= 4; | |
5553 | ||
5554 | temp = tempcx & 0x00FF; | |
5555 | temp = temp << 4; | |
ec9e5d3e | 5556 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x22, 0x0F, temp); |
cc1e2398 AK |
5557 | |
5558 | tempbx = TimingPoint[j] | ((TimingPoint[j + 1]) << 8); | |
5559 | tempbx += tempcx; | |
5560 | push2 = tempbx; | |
5561 | temp = tempbx & 0x00FF; | |
8104e329 | 5562 | xgifb_reg_set(pVBInfo->Part2Port, 0x24, temp); |
cc1e2398 AK |
5563 | temp = (tempbx & 0xFF00) >> 8; |
5564 | temp = temp << 4; | |
ec9e5d3e | 5565 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x25, 0x0F, temp); |
cc1e2398 AK |
5566 | |
5567 | tempbx = push2; | |
5568 | tempbx = tempbx + 8; | |
5569 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { | |
5570 | tempbx = tempbx - 4; | |
5571 | tempcx = tempbx; | |
21df8fc8 PS |
5572 | } |
5573 | ||
cc1e2398 | 5574 | temp = (tempbx & 0x00FF) << 4; |
ec9e5d3e | 5575 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x29, 0x0F, temp); |
d7636e0b | 5576 | |
cc1e2398 AK |
5577 | j += 2; |
5578 | tempcx += (TimingPoint[j] | ((TimingPoint[j + 1]) << 8)); | |
5579 | temp = tempcx & 0x00FF; | |
8104e329 | 5580 | xgifb_reg_set(pVBInfo->Part2Port, 0x27, temp); |
cc1e2398 | 5581 | temp = ((tempcx & 0xFF00) >> 8) << 4; |
ec9e5d3e | 5582 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x28, 0x0F, temp); |
21df8fc8 | 5583 | |
cc1e2398 AK |
5584 | tempcx += 8; |
5585 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) | |
5586 | tempcx -= 4; | |
21df8fc8 | 5587 | |
cc1e2398 AK |
5588 | temp = tempcx & 0xFF; |
5589 | temp = temp << 4; | |
ec9e5d3e | 5590 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2A, 0x0F, temp); |
cc1e2398 AK |
5591 | |
5592 | tempcx = push1; /* pop cx */ | |
5593 | j += 2; | |
5594 | temp = TimingPoint[j] | ((TimingPoint[j + 1]) << 8); | |
5595 | tempcx -= temp; | |
5596 | temp = tempcx & 0x00FF; | |
5597 | temp = temp << 4; | |
ec9e5d3e | 5598 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2D, 0x0F, temp); |
cc1e2398 AK |
5599 | |
5600 | tempcx -= 11; | |
5601 | ||
5602 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) { | |
5603 | tempax = XGI_GetVGAHT2(pVBInfo); | |
5604 | tempcx = tempax - 1; | |
21df8fc8 | 5605 | } |
cc1e2398 | 5606 | temp = tempcx & 0x00FF; |
8104e329 | 5607 | xgifb_reg_set(pVBInfo->Part2Port, 0x2E, temp); |
d7636e0b | 5608 | |
cc1e2398 | 5609 | tempbx = pVBInfo->VDE; |
21df8fc8 | 5610 | |
cc1e2398 AK |
5611 | if (pVBInfo->VGAVDE == 360) |
5612 | tempbx = 746; | |
5613 | if (pVBInfo->VGAVDE == 375) | |
5614 | tempbx = 746; | |
5615 | if (pVBInfo->VGAVDE == 405) | |
5616 | tempbx = 853; | |
5617 | ||
5618 | if (pVBInfo->VBInfo & SetCRT2ToTV) { | |
1d7f656d KT |
5619 | if (pVBInfo->VBType & |
5620 | (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) { | |
5621 | if (!(pVBInfo->TVInfo & | |
5622 | (SetYPbPrMode525p | SetYPbPrMode750p))) | |
cc1e2398 AK |
5623 | tempbx = tempbx >> 1; |
5624 | } else | |
5625 | tempbx = tempbx >> 1; | |
21df8fc8 PS |
5626 | } |
5627 | ||
cc1e2398 AK |
5628 | tempbx -= 2; |
5629 | temp = tempbx & 0x00FF; | |
21df8fc8 | 5630 | |
cc1e2398 AK |
5631 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
5632 | if (pVBInfo->VBType & VB_XGI301LV) { | |
5633 | if (pVBInfo->TVInfo & SetYPbPrMode1080i) { | |
5634 | if (pVBInfo->VBInfo & SetInSlaveMode) { | |
5635 | if (ModeNo == 0x2f) | |
5636 | temp += 1; | |
5637 | } | |
5638 | } | |
5639 | } else { | |
5640 | if (pVBInfo->VBInfo & SetInSlaveMode) { | |
5641 | if (ModeNo == 0x2f) | |
5642 | temp += 1; | |
5643 | } | |
21df8fc8 | 5644 | } |
cc1e2398 | 5645 | } |
21df8fc8 | 5646 | |
8104e329 | 5647 | xgifb_reg_set(pVBInfo->Part2Port, 0x2F, temp); |
21df8fc8 | 5648 | |
cc1e2398 AK |
5649 | temp = (tempcx & 0xFF00) >> 8; |
5650 | temp |= ((tempbx & 0xFF00) >> 8) << 6; | |
21df8fc8 | 5651 | |
cc1e2398 AK |
5652 | if (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)) { |
5653 | if (pVBInfo->VBType & VB_XGI301LV) { | |
5654 | if (pVBInfo->TVInfo & SetYPbPrMode1080i) { | |
5655 | temp |= 0x10; | |
21df8fc8 | 5656 | |
cc1e2398 AK |
5657 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) |
5658 | temp |= 0x20; | |
5659 | } | |
5660 | } else { | |
5661 | temp |= 0x10; | |
5662 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) | |
5663 | temp |= 0x20; | |
21df8fc8 PS |
5664 | } |
5665 | } | |
21df8fc8 | 5666 | |
8104e329 | 5667 | xgifb_reg_set(pVBInfo->Part2Port, 0x30, temp); |
21df8fc8 | 5668 | |
cc1e2398 AK |
5669 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
5670 | | VB_XGI302LV | VB_XGI301C)) { /* TV gatingno */ | |
5671 | tempbx = pVBInfo->VDE; | |
5672 | tempcx = tempbx - 2; | |
21df8fc8 | 5673 | |
cc1e2398 AK |
5674 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
5675 | if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | |
5676 | | SetYPbPrMode750p))) | |
5677 | tempbx = tempbx >> 1; | |
5678 | } | |
21df8fc8 | 5679 | |
cc1e2398 AK |
5680 | if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) { |
5681 | temp = 0; | |
5682 | if (tempcx & 0x0400) | |
5683 | temp |= 0x20; | |
21df8fc8 | 5684 | |
cc1e2398 AK |
5685 | if (tempbx & 0x0400) |
5686 | temp |= 0x40; | |
21df8fc8 | 5687 | |
8104e329 | 5688 | xgifb_reg_set(pVBInfo->Part4Port, 0x10, temp); |
cc1e2398 | 5689 | } |
21df8fc8 | 5690 | |
cc1e2398 | 5691 | temp = (((tempbx - 3) & 0x0300) >> 8) << 5; |
8104e329 | 5692 | xgifb_reg_set(pVBInfo->Part2Port, 0x46, temp); |
cc1e2398 | 5693 | temp = (tempbx - 3) & 0x00FF; |
8104e329 | 5694 | xgifb_reg_set(pVBInfo->Part2Port, 0x47, temp); |
cc1e2398 | 5695 | } |
21df8fc8 | 5696 | |
cc1e2398 | 5697 | tempbx = tempbx & 0x00FF; |
21df8fc8 | 5698 | |
cc1e2398 AK |
5699 | if (!(modeflag & HalfDCLK)) { |
5700 | tempcx = pVBInfo->VGAHDE; | |
5701 | if (tempcx >= pVBInfo->HDE) { | |
5702 | tempbx |= 0x2000; | |
5703 | tempax &= 0x00FF; | |
5704 | } | |
5705 | } | |
21df8fc8 | 5706 | |
cc1e2398 | 5707 | tempcx = 0x0101; |
21df8fc8 | 5708 | |
cc1e2398 AK |
5709 | if (pVBInfo->VBInfo & SetCRT2ToTV) { /*301b*/ |
5710 | if (pVBInfo->VGAHDE >= 1024) { | |
5711 | tempcx = 0x1920; | |
5712 | if (pVBInfo->VGAHDE >= 1280) { | |
5713 | tempcx = 0x1420; | |
5714 | tempbx = tempbx & 0xDFFF; | |
5715 | } | |
21df8fc8 PS |
5716 | } |
5717 | } | |
5718 | ||
cc1e2398 AK |
5719 | if (!(tempbx & 0x2000)) { |
5720 | if (modeflag & HalfDCLK) | |
5721 | tempcx = (tempcx & 0xFF00) | ((tempcx & 0x00FF) << 1); | |
21df8fc8 | 5722 | |
cc1e2398 AK |
5723 | push1 = tempbx; |
5724 | tempeax = pVBInfo->VGAHDE; | |
5725 | tempebx = (tempcx & 0xFF00) >> 8; | |
5726 | longtemp = tempeax * tempebx; | |
5727 | tempecx = tempcx & 0x00FF; | |
5728 | longtemp = longtemp / tempecx; | |
21df8fc8 | 5729 | |
cc1e2398 AK |
5730 | /* 301b */ |
5731 | tempecx = 8 * 1024; | |
21df8fc8 | 5732 | |
cc1e2398 AK |
5733 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
5734 | | VB_XGI302LV | VB_XGI301C)) { | |
5735 | tempecx = tempecx * 8; | |
5736 | } | |
21df8fc8 | 5737 | |
cc1e2398 AK |
5738 | longtemp = longtemp * tempecx; |
5739 | tempecx = pVBInfo->HDE; | |
5740 | temp2 = longtemp % tempecx; | |
5741 | tempeax = longtemp / tempecx; | |
5742 | if (temp2 != 0) | |
5743 | tempeax += 1; | |
21df8fc8 | 5744 | |
cc1e2398 | 5745 | tempax = (unsigned short) tempeax; |
21df8fc8 | 5746 | |
cc1e2398 AK |
5747 | /* 301b */ |
5748 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | |
5749 | | VB_XGI302LV | VB_XGI301C)) { | |
5750 | tempcx = ((tempax & 0xFF00) >> 5) >> 8; | |
5751 | } | |
5752 | /* end 301b */ | |
21df8fc8 | 5753 | |
cc1e2398 AK |
5754 | tempbx = push1; |
5755 | tempbx = (unsigned short) (((tempeax & 0x0000FF00) & 0x1F00) | |
5756 | | (tempbx & 0x00FF)); | |
5757 | tempax = (unsigned short) (((tempeax & 0x000000FF) << 8) | |
5758 | | (tempax & 0x00FF)); | |
5759 | temp = (tempax & 0xFF00) >> 8; | |
5760 | } else { | |
5761 | temp = (tempax & 0x00FF) >> 8; | |
5762 | } | |
21df8fc8 | 5763 | |
8104e329 | 5764 | xgifb_reg_set(pVBInfo->Part2Port, 0x44, temp); |
cc1e2398 | 5765 | temp = (tempbx & 0xFF00) >> 8; |
ec9e5d3e | 5766 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x45, ~0x03F, temp); |
cc1e2398 | 5767 | temp = tempcx & 0x00FF; |
21df8fc8 | 5768 | |
cc1e2398 AK |
5769 | if (tempbx & 0x2000) |
5770 | temp = 0; | |
21df8fc8 | 5771 | |
cc1e2398 AK |
5772 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
5773 | temp |= 0x18; | |
21df8fc8 | 5774 | |
ec9e5d3e | 5775 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x46, ~0x1F, temp); |
cc1e2398 AK |
5776 | if (pVBInfo->TVInfo & SetPALTV) { |
5777 | tempbx = 0x0382; | |
5778 | tempcx = 0x007e; | |
5779 | } else { | |
5780 | tempbx = 0x0369; | |
5781 | tempcx = 0x0061; | |
5782 | } | |
21df8fc8 | 5783 | |
cc1e2398 | 5784 | temp = tempbx & 0x00FF; |
8104e329 | 5785 | xgifb_reg_set(pVBInfo->Part2Port, 0x4b, temp); |
cc1e2398 | 5786 | temp = tempcx & 0x00FF; |
8104e329 | 5787 | xgifb_reg_set(pVBInfo->Part2Port, 0x4c, temp); |
21df8fc8 | 5788 | |
cc1e2398 AK |
5789 | temp = ((tempcx & 0xFF00) >> 8) & 0x03; |
5790 | temp = temp << 2; | |
5791 | temp |= ((tempbx & 0xFF00) >> 8) & 0x03; | |
21df8fc8 | 5792 | |
cc1e2398 AK |
5793 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { |
5794 | temp |= 0x10; | |
21df8fc8 | 5795 | |
cc1e2398 AK |
5796 | if (pVBInfo->TVInfo & SetYPbPrMode525p) |
5797 | temp |= 0x20; | |
21df8fc8 | 5798 | |
cc1e2398 AK |
5799 | if (pVBInfo->TVInfo & SetYPbPrMode750p) |
5800 | temp |= 0x60; | |
5801 | } | |
21df8fc8 | 5802 | |
8104e329 | 5803 | xgifb_reg_set(pVBInfo->Part2Port, 0x4d, temp); |
58839b01 | 5804 | temp = xgifb_reg_get(pVBInfo->Part2Port, 0x43); /* 301b change */ |
8104e329 | 5805 | xgifb_reg_set(pVBInfo->Part2Port, 0x43, (unsigned short) (temp - 3)); |
cc1e2398 AK |
5806 | |
5807 | if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))) { | |
5808 | if (pVBInfo->TVInfo & NTSC1024x768) { | |
5809 | TimingPoint = XGI_NTSC1024AdjTime; | |
5810 | for (i = 0x1c, j = 0; i <= 0x30; i++, j++) { | |
8104e329 | 5811 | xgifb_reg_set(pVBInfo->Part2Port, i, |
cc1e2398 | 5812 | TimingPoint[j]); |
21df8fc8 | 5813 | } |
8104e329 | 5814 | xgifb_reg_set(pVBInfo->Part2Port, 0x43, 0x72); |
21df8fc8 | 5815 | } |
cc1e2398 | 5816 | } |
21df8fc8 | 5817 | |
cc1e2398 AK |
5818 | /* [ycchen] 01/14/03 Modify for 301C PALM Support */ |
5819 | if (pVBInfo->VBType & VB_XGI301C) { | |
5820 | if (pVBInfo->TVInfo & SetPALMTV) | |
ec9e5d3e | 5821 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x08, |
cc1e2398 | 5822 | 0x08); /* PALM Mode */ |
21df8fc8 | 5823 | } |
21df8fc8 | 5824 | |
cc1e2398 | 5825 | if (pVBInfo->TVInfo & SetPALMTV) { |
58839b01 | 5826 | tempax = (unsigned char) xgifb_reg_get(pVBInfo->Part2Port, |
cc1e2398 AK |
5827 | 0x01); |
5828 | tempax--; | |
dc50556b | 5829 | xgifb_reg_and(pVBInfo->Part2Port, 0x01, tempax); |
d7636e0b | 5830 | |
cc1e2398 | 5831 | /* if ( !( pVBInfo->VBType & VB_XGI301C ) ) */ |
dc50556b | 5832 | xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xEF); |
cc1e2398 | 5833 | } |
21df8fc8 | 5834 | |
cc1e2398 AK |
5835 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
5836 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) | |
8104e329 | 5837 | xgifb_reg_set(pVBInfo->Part2Port, 0x0B, 0x00); |
21df8fc8 | 5838 | } |
cc1e2398 AK |
5839 | |
5840 | if (pVBInfo->VBInfo & SetCRT2ToTV) | |
5841 | return; | |
21df8fc8 | 5842 | } |
d7636e0b | 5843 | |
cc1e2398 AK |
5844 | static void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex, |
5845 | struct xgi_hw_device_info *HwDeviceExtension, | |
21df8fc8 PS |
5846 | unsigned short RefreshRateTableIndex, |
5847 | struct vb_device_info *pVBInfo) | |
5848 | { | |
cc1e2398 AK |
5849 | unsigned short push1, push2, pushbx, tempax, tempbx, tempcx, temp, |
5850 | tempah, tempbh, tempch, resinfo, modeflag, CRT1Index; | |
d7636e0b | 5851 | |
cc1e2398 | 5852 | struct XGI_LCDDesStruct *LCDBDesPtr = NULL; |
d7636e0b | 5853 | |
21df8fc8 | 5854 | if (ModeNo <= 0x13) { |
1d7f656d KT |
5855 | /* si+St_ResInfo */ |
5856 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
cc1e2398 | 5857 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
21df8fc8 | 5858 | } else { |
1d7f656d KT |
5859 | /* si+Ext_ResInfo */ |
5860 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
cc1e2398 | 5861 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
1d7f656d KT |
5862 | CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex]. |
5863 | Ext_CRT1CRTC; | |
cc1e2398 | 5864 | CRT1Index &= IndexMask; |
21df8fc8 | 5865 | } |
d7636e0b | 5866 | |
cc1e2398 AK |
5867 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
5868 | return; | |
21df8fc8 | 5869 | |
cc1e2398 | 5870 | tempbx = pVBInfo->HDE; /* RHACTE=HDE-1 */ |
21df8fc8 | 5871 | |
cc1e2398 AK |
5872 | if (XGI_IsLCDDualLink(pVBInfo)) |
5873 | tempbx = tempbx >> 1; | |
21df8fc8 | 5874 | |
cc1e2398 AK |
5875 | tempbx -= 1; |
5876 | temp = tempbx & 0x00FF; | |
8104e329 | 5877 | xgifb_reg_set(pVBInfo->Part2Port, 0x2C, temp); |
cc1e2398 AK |
5878 | temp = (tempbx & 0xFF00) >> 8; |
5879 | temp = temp << 4; | |
ec9e5d3e | 5880 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2B, 0x0F, temp); |
cc1e2398 | 5881 | temp = 0x01; |
21df8fc8 | 5882 | |
cc1e2398 AK |
5883 | if (pVBInfo->LCDResInfo == Panel1280x1024) { |
5884 | if (pVBInfo->ModeType == ModeEGA) { | |
5885 | if (pVBInfo->VGAHDE >= 1024) { | |
5886 | temp = 0x02; | |
5887 | if (pVBInfo->LCDInfo & LCDVESATiming) | |
5888 | temp = 0x01; | |
5889 | } | |
5890 | } | |
21df8fc8 | 5891 | } |
d7636e0b | 5892 | |
8104e329 | 5893 | xgifb_reg_set(pVBInfo->Part2Port, 0x0B, temp); |
cc1e2398 AK |
5894 | tempbx = pVBInfo->VDE; /* RTVACTEO=(VDE-1)&0xFF */ |
5895 | push1 = tempbx; | |
5896 | tempbx--; | |
5897 | temp = tempbx & 0x00FF; | |
8104e329 | 5898 | xgifb_reg_set(pVBInfo->Part2Port, 0x03, temp); |
cc1e2398 | 5899 | temp = ((tempbx & 0xFF00) >> 8) & 0x07; |
ec9e5d3e | 5900 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0C, ~0x07, temp); |
21df8fc8 | 5901 | |
cc1e2398 AK |
5902 | tempcx = pVBInfo->VT - 1; |
5903 | push2 = tempcx + 1; | |
5904 | temp = tempcx & 0x00FF; /* RVTVT=VT-1 */ | |
8104e329 | 5905 | xgifb_reg_set(pVBInfo->Part2Port, 0x19, temp); |
cc1e2398 AK |
5906 | temp = (tempcx & 0xFF00) >> 8; |
5907 | temp = temp << 5; | |
8104e329 | 5908 | xgifb_reg_set(pVBInfo->Part2Port, 0x1A, temp); |
ec9e5d3e AK |
5909 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x09, 0xF0, 0x00); |
5910 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xF0, 0x00); | |
5911 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x17, 0xFB, 0x00); | |
5912 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x18, 0xDF, 0x00); | |
d7636e0b | 5913 | |
cc1e2398 AK |
5914 | /* Customized LCDB Des no add */ |
5915 | tempbx = 5; | |
5916 | LCDBDesPtr = (struct XGI_LCDDesStruct *) XGI_GetLcdPtr(tempbx, ModeNo, | |
5917 | ModeIdIndex, RefreshRateTableIndex, pVBInfo); | |
5918 | tempah = pVBInfo->LCDResInfo; | |
5919 | tempah &= PanelResInfo; | |
d7636e0b | 5920 | |
cc1e2398 AK |
5921 | if ((tempah == Panel1024x768) || (tempah == Panel1024x768x75)) { |
5922 | tempbx = 1024; | |
5923 | tempcx = 768; | |
1d7f656d KT |
5924 | } else if ((tempah == Panel1280x1024) || |
5925 | (tempah == Panel1280x1024x75)) { | |
cc1e2398 AK |
5926 | tempbx = 1280; |
5927 | tempcx = 1024; | |
5928 | } else if (tempah == Panel1400x1050) { | |
5929 | tempbx = 1400; | |
5930 | tempcx = 1050; | |
5931 | } else { | |
5932 | tempbx = 1600; | |
5933 | tempcx = 1200; | |
5934 | } | |
d7636e0b | 5935 | |
cc1e2398 AK |
5936 | if (pVBInfo->LCDInfo & EnableScalingLCD) { |
5937 | tempbx = pVBInfo->HDE; | |
5938 | tempcx = pVBInfo->VDE; | |
5939 | } | |
d7636e0b | 5940 | |
cc1e2398 AK |
5941 | pushbx = tempbx; |
5942 | tempax = pVBInfo->VT; | |
5943 | pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES; | |
5944 | pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS; | |
5945 | pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES; | |
5946 | pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS; | |
5947 | tempbx = pVBInfo->LCDVDES; | |
5948 | tempcx += tempbx; | |
d7636e0b | 5949 | |
cc1e2398 AK |
5950 | if (tempcx >= tempax) |
5951 | tempcx -= tempax; /* lcdvdes */ | |
d7636e0b | 5952 | |
cc1e2398 | 5953 | temp = tempbx & 0x00FF; /* RVEQ1EQ=lcdvdes */ |
8104e329 | 5954 | xgifb_reg_set(pVBInfo->Part2Port, 0x05, temp); |
cc1e2398 | 5955 | temp = tempcx & 0x00FF; |
8104e329 | 5956 | xgifb_reg_set(pVBInfo->Part2Port, 0x06, temp); |
cc1e2398 AK |
5957 | tempch = ((tempcx & 0xFF00) >> 8) & 0x07; |
5958 | tempbh = ((tempbx & 0xFF00) >> 8) & 0x07; | |
5959 | tempah = tempch; | |
5960 | tempah = tempah << 3; | |
5961 | tempah |= tempbh; | |
8104e329 | 5962 | xgifb_reg_set(pVBInfo->Part2Port, 0x02, tempah); |
d7636e0b | 5963 | |
cc1e2398 AK |
5964 | /* getlcdsync() */ |
5965 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); | |
5966 | tempcx = tempbx; | |
5967 | tempax = pVBInfo->VT; | |
5968 | tempbx = pVBInfo->LCDVRS; | |
d7636e0b | 5969 | |
cc1e2398 AK |
5970 | /* if (SetLCD_Info & EnableScalingLCD) */ |
5971 | tempcx += tempbx; | |
5972 | if (tempcx >= tempax) | |
5973 | tempcx -= tempax; | |
d7636e0b | 5974 | |
cc1e2398 | 5975 | temp = tempbx & 0x00FF; /* RTVACTEE=lcdvrs */ |
8104e329 | 5976 | xgifb_reg_set(pVBInfo->Part2Port, 0x04, temp); |
cc1e2398 AK |
5977 | temp = (tempbx & 0xFF00) >> 8; |
5978 | temp = temp << 4; | |
5979 | temp |= (tempcx & 0x000F); | |
8104e329 | 5980 | xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp); |
cc1e2398 AK |
5981 | tempcx = pushbx; |
5982 | tempax = pVBInfo->HT; | |
5983 | tempbx = pVBInfo->LCDHDES; | |
5984 | tempbx &= 0x0FFF; | |
5985 | ||
5986 | if (XGI_IsLCDDualLink(pVBInfo)) { | |
5987 | tempax = tempax >> 1; | |
5988 | tempbx = tempbx >> 1; | |
5989 | tempcx = tempcx >> 1; | |
5990 | } | |
5991 | ||
5992 | if (pVBInfo->VBType & VB_XGI302LV) | |
5993 | tempbx += 1; | |
5994 | ||
5995 | if (pVBInfo->VBType & VB_XGI301C) /* tap4 */ | |
5996 | tempbx += 1; | |
5997 | ||
5998 | tempcx += tempbx; | |
5999 | ||
6000 | if (tempcx >= tempax) | |
6001 | tempcx -= tempax; | |
6002 | ||
6003 | temp = tempbx & 0x00FF; | |
8104e329 | 6004 | xgifb_reg_set(pVBInfo->Part2Port, 0x1F, temp); /* RHBLKE=lcdhdes */ |
cc1e2398 | 6005 | temp = ((tempbx & 0xFF00) >> 8) << 4; |
8104e329 | 6006 | xgifb_reg_set(pVBInfo->Part2Port, 0x20, temp); |
cc1e2398 | 6007 | temp = tempcx & 0x00FF; |
8104e329 | 6008 | xgifb_reg_set(pVBInfo->Part2Port, 0x23, temp); /* RHEQPLE=lcdhdee */ |
cc1e2398 | 6009 | temp = (tempcx & 0xFF00) >> 8; |
8104e329 | 6010 | xgifb_reg_set(pVBInfo->Part2Port, 0x25, temp); |
cc1e2398 AK |
6011 | |
6012 | /* getlcdsync() */ | |
6013 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); | |
6014 | tempcx = tempax; | |
6015 | tempax = pVBInfo->HT; | |
6016 | tempbx = pVBInfo->LCDHRS; | |
6017 | /* if ( SetLCD_Info & EnableScalingLCD) */ | |
6018 | if (XGI_IsLCDDualLink(pVBInfo)) { | |
6019 | tempax = tempax >> 1; | |
6020 | tempbx = tempbx >> 1; | |
6021 | tempcx = tempcx >> 1; | |
6022 | } | |
6023 | ||
6024 | if (pVBInfo->VBType & VB_XGI302LV) | |
6025 | tempbx += 1; | |
6026 | ||
6027 | tempcx += tempbx; | |
6028 | ||
6029 | if (tempcx >= tempax) | |
6030 | tempcx -= tempax; | |
6031 | ||
6032 | temp = tempbx & 0x00FF; /* RHBURSTS=lcdhrs */ | |
8104e329 | 6033 | xgifb_reg_set(pVBInfo->Part2Port, 0x1C, temp); |
cc1e2398 AK |
6034 | |
6035 | temp = (tempbx & 0xFF00) >> 8; | |
6036 | temp = temp << 4; | |
ec9e5d3e | 6037 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F0, temp); |
cc1e2398 | 6038 | temp = tempcx & 0x00FF; /* RHSYEXP2S=lcdhre */ |
8104e329 | 6039 | xgifb_reg_set(pVBInfo->Part2Port, 0x21, temp); |
cc1e2398 AK |
6040 | |
6041 | if (!(pVBInfo->LCDInfo & LCDVESATiming)) { | |
6042 | if (pVBInfo->VGAVDE == 525) { | |
6043 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | |
6044 | | VB_XGI301LV | VB_XGI302LV | |
6045 | | VB_XGI301C)) { | |
6046 | temp = 0xC6; | |
6047 | } else | |
6048 | temp = 0xC4; | |
6049 | ||
8104e329 AK |
6050 | xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp); |
6051 | xgifb_reg_set(pVBInfo->Part2Port, 0x30, 0xB3); | |
21df8fc8 | 6052 | } |
cc1e2398 AK |
6053 | |
6054 | if (pVBInfo->VGAVDE == 420) { | |
6055 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | |
6056 | | VB_XGI301LV | VB_XGI302LV | |
6057 | | VB_XGI301C)) { | |
6058 | temp = 0x4F; | |
6059 | } else | |
6060 | temp = 0x4E; | |
8104e329 | 6061 | xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp); |
21df8fc8 | 6062 | } |
cc1e2398 AK |
6063 | } |
6064 | } | |
6065 | ||
6066 | /* --------------------------------------------------------------------- */ | |
6067 | /* Function : XGI_GetTap4Ptr */ | |
6068 | /* Input : */ | |
6069 | /* Output : di -> Tap4 Reg. Setting Pointer */ | |
6070 | /* Description : */ | |
6071 | /* --------------------------------------------------------------------- */ | |
6072 | static struct XGI301C_Tap4TimingStruct *XGI_GetTap4Ptr(unsigned short tempcx, | |
6073 | struct vb_device_info *pVBInfo) | |
6074 | { | |
6075 | unsigned short tempax, tempbx, i; | |
6076 | ||
6077 | struct XGI301C_Tap4TimingStruct *Tap4TimingPtr; | |
6078 | ||
6079 | if (tempcx == 0) { | |
6080 | tempax = pVBInfo->VGAHDE; | |
6081 | tempbx = pVBInfo->HDE; | |
6082 | } else { | |
6083 | tempax = pVBInfo->VGAVDE; | |
6084 | tempbx = pVBInfo->VDE; | |
6085 | } | |
6086 | ||
6087 | if (tempax < tempbx) | |
6088 | return &EnlargeTap4Timing[0]; | |
6089 | else if (tempax == tempbx) | |
6090 | return &NoScaleTap4Timing[0]; /* 1:1 */ | |
6091 | else | |
6092 | Tap4TimingPtr = NTSCTap4Timing; /* NTSC */ | |
6093 | ||
6094 | if (pVBInfo->TVInfo & SetPALTV) | |
6095 | Tap4TimingPtr = PALTap4Timing; | |
6096 | ||
6097 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { | |
6098 | if (pVBInfo->TVInfo & SetYPbPrMode525i) | |
6099 | Tap4TimingPtr = YPbPr525iTap4Timing; | |
6100 | if (pVBInfo->TVInfo & SetYPbPrMode525p) | |
6101 | Tap4TimingPtr = YPbPr525pTap4Timing; | |
6102 | if (pVBInfo->TVInfo & SetYPbPrMode750p) | |
6103 | Tap4TimingPtr = YPbPr750pTap4Timing; | |
6104 | } | |
6105 | ||
6106 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) | |
6107 | Tap4TimingPtr = HiTVTap4Timing; | |
6108 | ||
6109 | i = 0; | |
6110 | while (Tap4TimingPtr[i].DE != 0xFFFF) { | |
6111 | if (Tap4TimingPtr[i].DE == tempax) | |
21df8fc8 | 6112 | break; |
cc1e2398 AK |
6113 | i++; |
6114 | } | |
6115 | return &Tap4TimingPtr[i]; | |
6116 | } | |
6117 | ||
6118 | static void XGI_SetTap4Regs(struct vb_device_info *pVBInfo) | |
6119 | { | |
6120 | unsigned short i, j; | |
6121 | ||
6122 | struct XGI301C_Tap4TimingStruct *Tap4TimingPtr; | |
6123 | ||
6124 | if (!(pVBInfo->VBType & VB_XGI301C)) | |
6125 | return; | |
6126 | ||
6127 | #ifndef Tap4 | |
dc50556b | 6128 | xgifb_reg_and(pVBInfo->Part2Port, 0x4E, 0xEB); /* Disable Tap4 */ |
cc1e2398 AK |
6129 | #else /* Tap4 Setting */ |
6130 | ||
6131 | Tap4TimingPtr = XGI_GetTap4Ptr(0, pVBInfo); /* Set Horizontal Scaling */ | |
6132 | for (i = 0x80, j = 0; i <= 0xBF; i++, j++) | |
8104e329 | 6133 | xgifb_reg_set(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]); |
cc1e2398 | 6134 | |
1d7f656d KT |
6135 | if ((pVBInfo->VBInfo & SetCRT2ToTV) && |
6136 | (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV))) { | |
6137 | /* Set Vertical Scaling */ | |
6138 | Tap4TimingPtr = XGI_GetTap4Ptr(1, pVBInfo); | |
cc1e2398 | 6139 | for (i = 0xC0, j = 0; i < 0xFF; i++, j++) |
1d7f656d KT |
6140 | xgifb_reg_set(pVBInfo->Part2Port, |
6141 | i, | |
6142 | Tap4TimingPtr->Reg[j]); | |
cc1e2398 AK |
6143 | } |
6144 | ||
1d7f656d KT |
6145 | if ((pVBInfo->VBInfo & SetCRT2ToTV) && |
6146 | (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV))) | |
6147 | /* Enable V.Scaling */ | |
6148 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x04); | |
cc1e2398 | 6149 | else |
1d7f656d KT |
6150 | /* Enable H.Scaling */ |
6151 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x10); | |
cc1e2398 AK |
6152 | #endif |
6153 | } | |
6154 | ||
6155 | static void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex, | |
6156 | struct vb_device_info *pVBInfo) | |
6157 | { | |
6158 | unsigned short i; | |
6159 | unsigned char *tempdi; | |
6160 | unsigned short modeflag; | |
6161 | ||
6162 | if (ModeNo <= 0x13) | |
1d7f656d KT |
6163 | /* si+St_ResInfo */ |
6164 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
cc1e2398 | 6165 | else |
1d7f656d KT |
6166 | /* si+Ext_ResInfo */ |
6167 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
cc1e2398 | 6168 | |
8104e329 | 6169 | xgifb_reg_set(pVBInfo->Part3Port, 0x00, 0x00); |
cc1e2398 | 6170 | if (pVBInfo->TVInfo & SetPALTV) { |
8104e329 AK |
6171 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA); |
6172 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8); | |
cc1e2398 | 6173 | } else { |
8104e329 AK |
6174 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xF5); |
6175 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xB7); | |
cc1e2398 AK |
6176 | } |
6177 | ||
6178 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) | |
6179 | return; | |
6180 | ||
6181 | if (pVBInfo->TVInfo & SetPALMTV) { | |
8104e329 AK |
6182 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA); |
6183 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8); | |
6184 | xgifb_reg_set(pVBInfo->Part3Port, 0x3D, 0xA8); | |
cc1e2398 AK |
6185 | } |
6186 | ||
6187 | if ((pVBInfo->VBInfo & SetCRT2ToHiVisionTV) || (pVBInfo->VBInfo | |
6188 | & SetCRT2ToYPbPr)) { | |
6189 | if (pVBInfo->TVInfo & SetYPbPrMode525i) | |
6190 | return; | |
6191 | ||
6192 | tempdi = pVBInfo->HiTVGroup3Data; | |
6193 | if (pVBInfo->SetFlag & TVSimuMode) { | |
6194 | tempdi = pVBInfo->HiTVGroup3Simu; | |
6195 | if (!(modeflag & Charx8Dot)) | |
6196 | tempdi = pVBInfo->HiTVGroup3Text; | |
21df8fc8 | 6197 | } |
cc1e2398 AK |
6198 | |
6199 | if (pVBInfo->TVInfo & SetYPbPrMode525p) | |
6200 | tempdi = pVBInfo->Ren525pGroup3; | |
6201 | ||
6202 | if (pVBInfo->TVInfo & SetYPbPrMode750p) | |
6203 | tempdi = pVBInfo->Ren750pGroup3; | |
6204 | ||
6205 | for (i = 0; i <= 0x3E; i++) | |
8104e329 | 6206 | xgifb_reg_set(pVBInfo->Part3Port, i, tempdi[i]); |
cc1e2398 AK |
6207 | |
6208 | if (pVBInfo->VBType & VB_XGI301C) { /* Marcovision */ | |
6209 | if (pVBInfo->TVInfo & SetYPbPrMode525p) | |
8104e329 | 6210 | xgifb_reg_set(pVBInfo->Part3Port, 0x28, 0x3f); |
21df8fc8 PS |
6211 | } |
6212 | } | |
cc1e2398 AK |
6213 | return; |
6214 | } /* {end of XGI_SetGroup3} */ | |
d7636e0b | 6215 | |
cc1e2398 | 6216 | static void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex, |
21df8fc8 | 6217 | unsigned short RefreshRateTableIndex, |
cc1e2398 | 6218 | struct xgi_hw_device_info *HwDeviceExtension, |
21df8fc8 PS |
6219 | struct vb_device_info *pVBInfo) |
6220 | { | |
cc1e2398 | 6221 | unsigned short tempax, tempcx, tempbx, modeflag, temp, temp2; |
d7636e0b | 6222 | |
cc1e2398 AK |
6223 | unsigned long tempebx, tempeax, templong; |
6224 | ||
6225 | if (ModeNo <= 0x13) | |
1d7f656d KT |
6226 | /* si+St_ResInfo */ |
6227 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
cc1e2398 | 6228 | else |
1d7f656d KT |
6229 | /* si+Ext_ResInfo */ |
6230 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
cc1e2398 AK |
6231 | |
6232 | temp = pVBInfo->RVBHCFACT; | |
8104e329 | 6233 | xgifb_reg_set(pVBInfo->Part4Port, 0x13, temp); |
cc1e2398 AK |
6234 | |
6235 | tempbx = pVBInfo->RVBHCMAX; | |
6236 | temp = tempbx & 0x00FF; | |
8104e329 | 6237 | xgifb_reg_set(pVBInfo->Part4Port, 0x14, temp); |
cc1e2398 AK |
6238 | temp2 = ((tempbx & 0xFF00) >> 8) << 7; |
6239 | tempcx = pVBInfo->VGAHT - 1; | |
6240 | temp = tempcx & 0x00FF; | |
8104e329 | 6241 | xgifb_reg_set(pVBInfo->Part4Port, 0x16, temp); |
cc1e2398 AK |
6242 | |
6243 | temp = ((tempcx & 0xFF00) >> 8) << 3; | |
6244 | temp2 |= temp; | |
6245 | ||
6246 | tempcx = pVBInfo->VGAVT - 1; | |
6247 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) | |
6248 | tempcx -= 5; | |
6249 | ||
6250 | temp = tempcx & 0x00FF; | |
8104e329 | 6251 | xgifb_reg_set(pVBInfo->Part4Port, 0x17, temp); |
cc1e2398 | 6252 | temp = temp2 | ((tempcx & 0xFF00) >> 8); |
8104e329 | 6253 | xgifb_reg_set(pVBInfo->Part4Port, 0x15, temp); |
b9bf6e4e | 6254 | xgifb_reg_or(pVBInfo->Part4Port, 0x0D, 0x08); |
cc1e2398 AK |
6255 | tempcx = pVBInfo->VBInfo; |
6256 | tempbx = pVBInfo->VGAHDE; | |
6257 | ||
6258 | if (modeflag & HalfDCLK) | |
6259 | tempbx = tempbx >> 1; | |
6260 | ||
6261 | if (XGI_IsLCDDualLink(pVBInfo)) | |
6262 | tempbx = tempbx >> 1; | |
6263 | ||
6264 | if (tempcx & SetCRT2ToHiVisionTV) { | |
6265 | temp = 0; | |
6266 | if (tempbx <= 1024) | |
6267 | temp = 0xA0; | |
6268 | if (tempbx == 1280) | |
6269 | temp = 0xC0; | |
6270 | } else if (tempcx & SetCRT2ToTV) { | |
6271 | temp = 0xA0; | |
6272 | if (tempbx <= 800) | |
6273 | temp = 0x80; | |
6274 | } else { | |
6275 | temp = 0x80; | |
6276 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { | |
6277 | temp = 0; | |
6278 | if (tempbx > 800) | |
6279 | temp = 0x60; | |
6280 | } | |
6281 | } | |
6282 | ||
6283 | if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)) { | |
6284 | temp = 0x00; | |
6285 | if (pVBInfo->VGAHDE == 1280) | |
6286 | temp = 0x40; | |
6287 | if (pVBInfo->VGAHDE == 1024) | |
6288 | temp = 0x20; | |
6289 | } | |
ec9e5d3e | 6290 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0E, ~0xEF, temp); |
cc1e2398 AK |
6291 | |
6292 | tempebx = pVBInfo->VDE; | |
6293 | ||
6294 | if (tempcx & SetCRT2ToHiVisionTV) { | |
6295 | if (!(temp & 0xE000)) | |
6296 | tempbx = tempbx >> 1; | |
6297 | } | |
6298 | ||
6299 | tempcx = pVBInfo->RVBHRS; | |
6300 | temp = tempcx & 0x00FF; | |
8104e329 | 6301 | xgifb_reg_set(pVBInfo->Part4Port, 0x18, temp); |
cc1e2398 AK |
6302 | |
6303 | tempeax = pVBInfo->VGAVDE; | |
6304 | tempcx |= 0x04000; | |
6305 | ||
6306 | if (tempeax <= tempebx) { | |
6307 | tempcx = (tempcx & (~0x4000)); | |
6308 | tempeax = pVBInfo->VGAVDE; | |
6309 | } else { | |
6310 | tempeax -= tempebx; | |
6311 | } | |
6312 | ||
6313 | templong = (tempeax * 256 * 1024) % tempebx; | |
6314 | tempeax = (tempeax * 256 * 1024) / tempebx; | |
6315 | tempebx = tempeax; | |
6316 | ||
6317 | if (templong != 0) | |
6318 | tempebx++; | |
6319 | ||
6320 | temp = (unsigned short) (tempebx & 0x000000FF); | |
8104e329 | 6321 | xgifb_reg_set(pVBInfo->Part4Port, 0x1B, temp); |
cc1e2398 AK |
6322 | |
6323 | temp = (unsigned short) ((tempebx & 0x0000FF00) >> 8); | |
8104e329 | 6324 | xgifb_reg_set(pVBInfo->Part4Port, 0x1A, temp); |
cc1e2398 AK |
6325 | tempbx = (unsigned short) (tempebx >> 16); |
6326 | temp = tempbx & 0x00FF; | |
6327 | temp = temp << 4; | |
6328 | temp |= ((tempcx & 0xFF00) >> 8); | |
8104e329 | 6329 | xgifb_reg_set(pVBInfo->Part4Port, 0x19, temp); |
cc1e2398 AK |
6330 | |
6331 | /* 301b */ | |
6332 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | |
6333 | | VB_XGI302LV | VB_XGI301C)) { | |
6334 | temp = 0x0028; | |
8104e329 | 6335 | xgifb_reg_set(pVBInfo->Part4Port, 0x1C, temp); |
cc1e2398 AK |
6336 | tempax = pVBInfo->VGAHDE; |
6337 | if (modeflag & HalfDCLK) | |
6338 | tempax = tempax >> 1; | |
d7636e0b | 6339 | |
cc1e2398 AK |
6340 | if (XGI_IsLCDDualLink(pVBInfo)) |
6341 | tempax = tempax >> 1; | |
d7636e0b | 6342 | |
1d7f656d KT |
6343 | /* if((pVBInfo->VBInfo&(SetCRT2ToLCD)) || |
6344 | ((pVBInfo->TVInfo&SetYPbPrMode525p) || | |
6345 | (pVBInfo->TVInfo&SetYPbPrMode750p))) { */ | |
cc1e2398 AK |
6346 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
6347 | if (tempax > 800) | |
6348 | tempax -= 800; | |
6349 | } else { | |
6350 | if (pVBInfo->VGAHDE > 800) { | |
6351 | if (pVBInfo->VGAHDE == 1024) | |
6352 | tempax = (tempax * 25 / 32) - 1; | |
6353 | else | |
6354 | tempax = (tempax * 20 / 32) - 1; | |
6355 | } | |
6356 | } | |
6357 | tempax -= 1; | |
21df8fc8 | 6358 | |
cc1e2398 AK |
6359 | /* |
6360 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVisionTV)) { | |
6361 | if (pVBInfo->VBType & VB_XGI301LV) { | |
1d7f656d KT |
6362 | if (!(pVBInfo->TVInfo & |
6363 | (SetYPbPrMode525p | | |
6364 | SetYPbPrMode750p | | |
6365 | SetYPbPrMode1080i))) { | |
cc1e2398 AK |
6366 | if (pVBInfo->VGAHDE > 800) { |
6367 | if (pVBInfo->VGAHDE == 1024) | |
1d7f656d KT |
6368 | tempax =(tempax * 25 / |
6369 | 32) - 1; | |
cc1e2398 | 6370 | else |
1d7f656d KT |
6371 | tempax = (tempax * 20 / |
6372 | 32) - 1; | |
cc1e2398 AK |
6373 | } |
6374 | } | |
6375 | } else { | |
6376 | if (pVBInfo->VGAHDE > 800) { | |
6377 | if (pVBInfo->VGAHDE == 1024) | |
6378 | tempax = (tempax * 25 / 32) - 1; | |
6379 | else | |
6380 | tempax = (tempax * 20 / 32) - 1; | |
6381 | } | |
6382 | } | |
6383 | } | |
6384 | */ | |
21df8fc8 | 6385 | |
cc1e2398 AK |
6386 | temp = (tempax & 0xFF00) >> 8; |
6387 | temp = ((temp & 0x0003) << 4); | |
8104e329 | 6388 | xgifb_reg_set(pVBInfo->Part4Port, 0x1E, temp); |
cc1e2398 | 6389 | temp = (tempax & 0x00FF); |
8104e329 | 6390 | xgifb_reg_set(pVBInfo->Part4Port, 0x1D, temp); |
21df8fc8 | 6391 | |
cc1e2398 AK |
6392 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVisionTV)) { |
6393 | if (pVBInfo->VGAHDE > 800) | |
b9bf6e4e | 6394 | xgifb_reg_or(pVBInfo->Part4Port, 0x1E, 0x08); |
d7636e0b | 6395 | |
cc1e2398 AK |
6396 | } |
6397 | temp = 0x0036; | |
d7636e0b | 6398 | |
cc1e2398 AK |
6399 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
6400 | if (!(pVBInfo->TVInfo & (NTSC1024x768 | |
6401 | | SetYPbPrMode525p | SetYPbPrMode750p | |
6402 | | SetYPbPrMode1080i))) { | |
6403 | temp |= 0x0001; | |
6404 | if ((pVBInfo->VBInfo & SetInSlaveMode) | |
6405 | && (!(pVBInfo->TVInfo | |
6406 | & TVSimuMode))) | |
6407 | temp &= (~0x0001); | |
6408 | } | |
6409 | } | |
d7636e0b | 6410 | |
ec9e5d3e | 6411 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x1F, 0x00C0, temp); |
cc1e2398 AK |
6412 | tempbx = pVBInfo->HT; |
6413 | if (XGI_IsLCDDualLink(pVBInfo)) | |
6414 | tempbx = tempbx >> 1; | |
6415 | tempbx = (tempbx >> 1) - 2; | |
6416 | temp = ((tempbx & 0x0700) >> 8) << 3; | |
ec9e5d3e | 6417 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, 0x00C0, temp); |
cc1e2398 | 6418 | temp = tempbx & 0x00FF; |
8104e329 | 6419 | xgifb_reg_set(pVBInfo->Part4Port, 0x22, temp); |
cc1e2398 AK |
6420 | } |
6421 | /* end 301b */ | |
d7636e0b | 6422 | |
cc1e2398 AK |
6423 | if (pVBInfo->ISXPDOS == 0) |
6424 | XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, | |
6425 | pVBInfo); | |
6426 | } | |
d7636e0b | 6427 | |
cc1e2398 AK |
6428 | static void XGINew_EnableCRT2(struct vb_device_info *pVBInfo) |
6429 | { | |
ec9e5d3e | 6430 | xgifb_reg_and_or(pVBInfo->P3c4, 0x1E, 0xFF, 0x20); |
cc1e2398 | 6431 | } |
d7636e0b | 6432 | |
cc1e2398 AK |
6433 | static void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex, |
6434 | struct vb_device_info *pVBInfo) | |
6435 | { | |
6436 | unsigned short Pindex, Pdata; | |
d7636e0b | 6437 | |
cc1e2398 AK |
6438 | Pindex = pVBInfo->Part5Port; |
6439 | Pdata = pVBInfo->Part5Port + 1; | |
6440 | if (pVBInfo->ModeType == ModeVGA) { | |
6441 | if (!(pVBInfo->VBInfo & (SetInSlaveMode | LoadDACFlag | |
6442 | | CRT2DisplayFlag))) { | |
6443 | XGINew_EnableCRT2(pVBInfo); | |
6444 | /* LoadDAC2(pVBInfo->Part5Port, ModeNo, ModeIdIndex); */ | |
21df8fc8 | 6445 | } |
21df8fc8 | 6446 | } |
cc1e2398 | 6447 | return; |
d7636e0b | 6448 | } |
6449 | ||
063b9c4b | 6450 | static void XGI_EnableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, |
21df8fc8 | 6451 | struct vb_device_info *pVBInfo) |
d7636e0b | 6452 | { |
ec9e5d3e | 6453 | xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x40); |
d7636e0b | 6454 | } |
6455 | ||
063b9c4b | 6456 | static void XGI_DisableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, |
21df8fc8 | 6457 | struct vb_device_info *pVBInfo) |
d7636e0b | 6458 | { |
6459 | ||
ec9e5d3e | 6460 | xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x00); |
d7636e0b | 6461 | } |
6462 | ||
d7636e0b | 6463 | /*----------------------------------------------------------------------------*/ |
6464 | /* input */ | |
6465 | /* bl[5] : 1;LVDS signal on */ | |
6466 | /* bl[1] : 1;LVDS backlight on */ | |
6467 | /* bl[0] : 1:LVDS VDD on */ | |
6468 | /* bh: 100000b : clear bit 5, to set bit5 */ | |
6469 | /* 000010b : clear bit 1, to set bit1 */ | |
6470 | /* 000001b : clear bit 0, to set bit0 */ | |
6471 | /*----------------------------------------------------------------------------*/ | |
21df8fc8 PS |
6472 | void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl, |
6473 | struct vb_device_info *pVBInfo) | |
d7636e0b | 6474 | { |
21df8fc8 | 6475 | unsigned char CR4A, temp; |
d7636e0b | 6476 | |
58839b01 | 6477 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
21df8fc8 PS |
6478 | tempbh &= 0x23; |
6479 | tempbl &= 0x23; | |
dc50556b | 6480 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */ |
d7636e0b | 6481 | |
21df8fc8 PS |
6482 | if (tempbh & 0x20) { |
6483 | temp = (tempbl >> 4) & 0x02; | |
d7636e0b | 6484 | |
1d7f656d KT |
6485 | /* CR B4[1] */ |
6486 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp); | |
d7636e0b | 6487 | |
21df8fc8 | 6488 | } |
d7636e0b | 6489 | |
58839b01 | 6490 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
d7636e0b | 6491 | |
21df8fc8 PS |
6492 | temp = XG21GPIODataTransfer(temp); |
6493 | temp &= ~tempbh; | |
6494 | temp |= tempbl; | |
8104e329 | 6495 | xgifb_reg_set(pVBInfo->P3d4, 0x48, temp); |
d7636e0b | 6496 | } |
6497 | ||
21df8fc8 PS |
6498 | void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl, |
6499 | struct vb_device_info *pVBInfo) | |
d7636e0b | 6500 | { |
21df8fc8 PS |
6501 | unsigned char CR4A, temp; |
6502 | unsigned short tempbh0, tempbl0; | |
d7636e0b | 6503 | |
21df8fc8 PS |
6504 | tempbh0 = tempbh; |
6505 | tempbl0 = tempbl; | |
6506 | tempbh0 &= 0x20; | |
6507 | tempbl0 &= 0x20; | |
6508 | tempbh0 >>= 3; | |
6509 | tempbl0 >>= 3; | |
d7636e0b | 6510 | |
21df8fc8 PS |
6511 | if (tempbh & 0x20) { |
6512 | temp = (tempbl >> 4) & 0x02; | |
d7636e0b | 6513 | |
1d7f656d KT |
6514 | /* CR B4[1] */ |
6515 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp); | |
d7636e0b | 6516 | |
21df8fc8 | 6517 | } |
ec9e5d3e | 6518 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~tempbh0, tempbl0); |
d7636e0b | 6519 | |
58839b01 | 6520 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
21df8fc8 PS |
6521 | tempbh &= 0x03; |
6522 | tempbl &= 0x03; | |
6523 | tempbh <<= 2; | |
6524 | tempbl <<= 2; /* GPIOC,GPIOD */ | |
dc50556b | 6525 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */ |
ec9e5d3e | 6526 | xgifb_reg_and_or(pVBInfo->P3d4, 0x48, ~tempbh, tempbl); |
d7636e0b | 6527 | } |
6528 | ||
6529 | /* --------------------------------------------------------------------- */ | |
80adad85 | 6530 | unsigned short XGI_GetLVDSOEMTableIndex(struct vb_device_info *pVBInfo) |
d7636e0b | 6531 | { |
21df8fc8 | 6532 | unsigned short index; |
d7636e0b | 6533 | |
58839b01 | 6534 | index = xgifb_reg_get(pVBInfo->P3d4, 0x36); |
21df8fc8 PS |
6535 | if (index < sizeof(XGI21_LCDCapList) |
6536 | / sizeof(struct XGI21_LVDSCapStruct)) | |
6537 | return index; | |
6538 | return 0; | |
d7636e0b | 6539 | } |
6540 | ||
6541 | /* --------------------------------------------------------------------- */ | |
6542 | /* Function : XGI_XG21SetPanelDelay */ | |
6543 | /* Input : */ | |
6544 | /* Output : */ | |
6545 | /* Description : */ | |
6546 | /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */ | |
6547 | /* : bl : 2 ; T2 : the duration signal on and Vdd on */ | |
6548 | /* : bl : 3 ; T3 : the duration between CPL off and signal off */ | |
6549 | /* : bl : 4 ; T4 : the duration signal off and Vdd off */ | |
6550 | /* --------------------------------------------------------------------- */ | |
21df8fc8 PS |
6551 | void XGI_XG21SetPanelDelay(unsigned short tempbl, |
6552 | struct vb_device_info *pVBInfo) | |
d7636e0b | 6553 | { |
21df8fc8 | 6554 | unsigned short index; |
d7636e0b | 6555 | |
21df8fc8 PS |
6556 | index = XGI_GetLVDSOEMTableIndex(pVBInfo); |
6557 | if (tempbl == 1) | |
d80aaa01 | 6558 | mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S1); |
d7636e0b | 6559 | |
21df8fc8 | 6560 | if (tempbl == 2) |
d80aaa01 | 6561 | mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S2); |
d7636e0b | 6562 | |
21df8fc8 | 6563 | if (tempbl == 3) |
d80aaa01 | 6564 | mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S3); |
d7636e0b | 6565 | |
21df8fc8 | 6566 | if (tempbl == 4) |
d80aaa01 | 6567 | mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S4); |
d7636e0b | 6568 | } |
6569 | ||
82d6eb5b | 6570 | unsigned char XGI_XG21CheckLVDSMode(unsigned short ModeNo, |
21df8fc8 PS |
6571 | unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) |
6572 | { | |
6573 | unsigned short xres, yres, colordepth, modeflag, resindex, | |
6574 | lvdstableindex; | |
6575 | ||
6576 | resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); | |
6577 | if (ModeNo <= 0x13) { | |
6578 | xres = pVBInfo->StResInfo[resindex].HTotal; | |
6579 | yres = pVBInfo->StResInfo[resindex].VTotal; | |
1d7f656d KT |
6580 | /* si+St_ResInfo */ |
6581 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
21df8fc8 PS |
6582 | } else { |
6583 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ | |
6584 | yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */ | |
1d7f656d KT |
6585 | /* si+St_ModeFlag */ |
6586 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
21df8fc8 PS |
6587 | } |
6588 | ||
6589 | if (!(modeflag & Charx8Dot)) { | |
6590 | xres /= 9; | |
6591 | xres *= 8; | |
6592 | } | |
6593 | ||
6594 | if (ModeNo > 0x13) { | |
6595 | if ((ModeNo > 0x13) && (modeflag & HalfDCLK)) | |
6596 | xres *= 2; | |
6597 | ||
6598 | if ((ModeNo > 0x13) && (modeflag & DoubleScanMode)) | |
6599 | yres *= 2; | |
6600 | ||
6601 | } | |
6602 | ||
6603 | lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo); | |
6604 | if (xres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE)) | |
6605 | return 0; | |
6606 | ||
6607 | if (yres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE)) | |
6608 | return 0; | |
6609 | ||
6610 | if (ModeNo > 0x13) { | |
1d7f656d KT |
6611 | if ((xres != (pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
6612 | LVDSHDE)) || | |
6613 | (yres != (pVBInfo->XG21_LVDSCapList[lvdstableindex]. | |
6614 | LVDSVDE))) { | |
6615 | colordepth = XGI_GetColorDepth(ModeNo, | |
6616 | ModeIdIndex, | |
6617 | pVBInfo); | |
21df8fc8 PS |
6618 | if (colordepth > 2) |
6619 | return 0; | |
6620 | ||
6621 | } | |
6622 | } | |
6623 | return 1; | |
d7636e0b | 6624 | } |
6625 | ||
80adad85 | 6626 | void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo) |
d7636e0b | 6627 | { |
21df8fc8 | 6628 | unsigned char temp; |
d7636e0b | 6629 | |
58839b01 | 6630 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); /* D[0] 1: 18bit */ |
21df8fc8 | 6631 | temp = (temp & 1) << 6; |
1d7f656d KT |
6632 | /* SR06[6] 18bit Dither */ |
6633 | xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x40, temp); | |
6634 | /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */ | |
6635 | xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); | |
d7636e0b | 6636 | |
6637 | } | |
6638 | ||
80adad85 | 6639 | void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo) |
d7636e0b | 6640 | { |
21df8fc8 | 6641 | unsigned char temp; |
d7636e0b | 6642 | |
1d7f656d KT |
6643 | /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */ |
6644 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); | |
21df8fc8 | 6645 | temp = (temp & 3) << 6; |
1d7f656d KT |
6646 | /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */ |
6647 | xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0xc0, temp & 0x80); | |
6648 | /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */ | |
6649 | xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); | |
d7636e0b | 6650 | |
6651 | } | |
6652 | ||
1d7f656d KT |
6653 | static void XGI_SetXG21LVDSPara(unsigned short ModeNo, |
6654 | unsigned short ModeIdIndex, | |
6655 | struct vb_device_info *pVBInfo) | |
21df8fc8 PS |
6656 | { |
6657 | unsigned char temp, Miscdata; | |
6658 | unsigned short xres, yres, modeflag, resindex, lvdstableindex; | |
6659 | unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE; | |
6660 | unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE; | |
6661 | unsigned short value; | |
6662 | ||
6663 | lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo); | |
6664 | ||
1d7f656d KT |
6665 | temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
6666 | LVDS_Capability & | |
6667 | (LCDPolarity << 8)) >> 8); | |
21df8fc8 | 6668 | temp &= LCDPolarity; |
d8ad0a6d | 6669 | Miscdata = (unsigned char) inb(pVBInfo->P3cc); |
21df8fc8 | 6670 | |
efdf4ee7 | 6671 | outb((Miscdata & 0x3F) | temp, pVBInfo->P3c2); |
21df8fc8 | 6672 | |
1d7f656d KT |
6673 | temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
6674 | LVDS_Capability & LCDPolarity); | |
6675 | /* SR35[7] FP VSync polarity */ | |
6676 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80); | |
6677 | /* SR30[5] FP HSync polarity */ | |
6678 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); | |
21df8fc8 PS |
6679 | |
6680 | XGI_SetXG21FPBits(pVBInfo); | |
6681 | resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); | |
6682 | if (ModeNo <= 0x13) { | |
6683 | xres = pVBInfo->StResInfo[resindex].HTotal; | |
6684 | yres = pVBInfo->StResInfo[resindex].VTotal; | |
1d7f656d KT |
6685 | /* si+St_ResInfo */ |
6686 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
21df8fc8 PS |
6687 | } else { |
6688 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ | |
6689 | yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */ | |
1d7f656d KT |
6690 | /* si+St_ModeFlag */ |
6691 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
21df8fc8 PS |
6692 | } |
6693 | ||
6694 | if (!(modeflag & Charx8Dot)) | |
6695 | xres = xres * 8 / 9; | |
6696 | ||
6697 | LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT; | |
6698 | ||
6699 | LVDSHBS = xres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE | |
6700 | - xres) / 2; | |
6701 | if ((ModeNo <= 0x13) && (modeflag & HalfDCLK)) | |
6702 | LVDSHBS -= xres / 4; | |
6703 | ||
6704 | if (LVDSHBS > LVDSHT) | |
6705 | LVDSHBS -= LVDSHT; | |
6706 | ||
6707 | LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP; | |
6708 | if (LVDSHRS > LVDSHT) | |
6709 | LVDSHRS -= LVDSHT; | |
6710 | ||
6711 | LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC; | |
6712 | if (LVDSHRE > LVDSHT) | |
6713 | LVDSHRE -= LVDSHT; | |
6714 | ||
6715 | LVDSHBE = LVDSHBS + LVDSHT | |
6716 | - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE; | |
6717 | ||
6718 | LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT; | |
6719 | ||
6720 | LVDSVBS = yres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE | |
6721 | - yres) / 2; | |
6722 | if ((ModeNo > 0x13) && (modeflag & DoubleScanMode)) | |
6723 | LVDSVBS += yres / 2; | |
6724 | ||
6725 | if (LVDSVBS > LVDSVT) | |
6726 | LVDSVBS -= LVDSVT; | |
6727 | ||
6728 | LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP; | |
6729 | if (LVDSVRS > LVDSVT) | |
6730 | LVDSVRS -= LVDSVT; | |
6731 | ||
6732 | LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC; | |
6733 | if (LVDSVRE > LVDSVT) | |
6734 | LVDSVRE -= LVDSVT; | |
6735 | ||
6736 | LVDSVBE = LVDSVBS + LVDSVT | |
6737 | - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE; | |
6738 | ||
58839b01 | 6739 | temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
8104e329 | 6740 | xgifb_reg_set(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */ |
21df8fc8 PS |
6741 | |
6742 | if (!(modeflag & Charx8Dot)) | |
b9bf6e4e | 6743 | xgifb_reg_or(pVBInfo->P3c4, 0x1, 0x1); |
21df8fc8 PS |
6744 | |
6745 | /* HT SR0B[1:0] CR00 */ | |
6746 | value = (LVDSHT >> 3) - 5; | |
ec9e5d3e | 6747 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8); |
8104e329 | 6748 | xgifb_reg_set(pVBInfo->P3d4, 0x0, (value & 0xFF)); |
21df8fc8 PS |
6749 | |
6750 | /* HBS SR0B[5:4] CR02 */ | |
6751 | value = (LVDSHBS >> 3) - 1; | |
ec9e5d3e | 6752 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4); |
8104e329 | 6753 | xgifb_reg_set(pVBInfo->P3d4, 0x2, (value & 0xFF)); |
21df8fc8 PS |
6754 | |
6755 | /* HBE SR0C[1:0] CR05[7] CR03[4:0] */ | |
6756 | value = (LVDSHBE >> 3) - 1; | |
ec9e5d3e AK |
6757 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6); |
6758 | xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2); | |
6759 | xgifb_reg_and_or(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F); | |
21df8fc8 PS |
6760 | |
6761 | /* HRS SR0B[7:6] CR04 */ | |
6762 | value = (LVDSHRS >> 3) + 2; | |
ec9e5d3e | 6763 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2); |
8104e329 | 6764 | xgifb_reg_set(pVBInfo->P3d4, 0x4, (value & 0xFF)); |
21df8fc8 PS |
6765 | |
6766 | /* Panel HRS SR2F[1:0] SR2E[7:0] */ | |
6767 | value--; | |
ec9e5d3e | 6768 | xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8); |
8104e329 | 6769 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, (value & 0xFF)); |
21df8fc8 PS |
6770 | |
6771 | /* HRE SR0C[2] CR05[4:0] */ | |
6772 | value = (LVDSHRE >> 3) + 2; | |
ec9e5d3e AK |
6773 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3); |
6774 | xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F); | |
21df8fc8 PS |
6775 | |
6776 | /* Panel HRE SR2F[7:2] */ | |
6777 | value--; | |
ec9e5d3e | 6778 | xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2); |
21df8fc8 PS |
6779 | |
6780 | /* VT SR0A[0] CR07[5][0] CR06 */ | |
6781 | value = LVDSVT - 2; | |
ec9e5d3e AK |
6782 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10); |
6783 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4); | |
6784 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8); | |
8104e329 | 6785 | xgifb_reg_set(pVBInfo->P3d4, 0x06, (value & 0xFF)); |
21df8fc8 PS |
6786 | |
6787 | /* VBS SR0A[2] CR09[5] CR07[3] CR15 */ | |
6788 | value = LVDSVBS - 1; | |
ec9e5d3e AK |
6789 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8); |
6790 | xgifb_reg_and_or(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4); | |
6791 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5); | |
8104e329 | 6792 | xgifb_reg_set(pVBInfo->P3d4, 0x15, (value & 0xFF)); |
21df8fc8 PS |
6793 | |
6794 | /* VBE SR0A[4] CR16 */ | |
6795 | value = LVDSVBE - 1; | |
ec9e5d3e | 6796 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4); |
8104e329 | 6797 | xgifb_reg_set(pVBInfo->P3d4, 0x16, (value & 0xFF)); |
21df8fc8 PS |
6798 | |
6799 | /* VRS SR0A[3] CR7[7][2] CR10 */ | |
6800 | value = LVDSVRS - 1; | |
ec9e5d3e AK |
6801 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7); |
6802 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2); | |
6803 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6); | |
8104e329 | 6804 | xgifb_reg_set(pVBInfo->P3d4, 0x10, (value & 0xFF)); |
21df8fc8 PS |
6805 | |
6806 | /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */ | |
ec9e5d3e | 6807 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0x03, (value & 0x600) >> 9); |
8104e329 | 6808 | xgifb_reg_set(pVBInfo->P3c4, 0x34, (value >> 1) & 0xFF); |
ec9e5d3e | 6809 | xgifb_reg_and_or(pVBInfo->P3d4, 0x33, ~0x01, value & 0x01); |
21df8fc8 PS |
6810 | |
6811 | /* VRE SR0A[5] CR11[3:0] */ | |
6812 | value = LVDSVRE - 1; | |
ec9e5d3e AK |
6813 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1); |
6814 | xgifb_reg_and_or(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F); | |
21df8fc8 PS |
6815 | |
6816 | /* Panel VRE SR3F[7:2] *//* SR3F[7] has to be 0, h/w bug */ | |
ec9e5d3e | 6817 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, (value << 2) & 0x7C); |
21df8fc8 PS |
6818 | |
6819 | for (temp = 0, value = 0; temp < 3; temp++) { | |
6820 | ||
ec9e5d3e | 6821 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, value); |
8104e329 | 6822 | xgifb_reg_set(pVBInfo->P3c4, |
1d7f656d KT |
6823 | 0x2B, |
6824 | pVBInfo->XG21_LVDSCapList[lvdstableindex]. | |
6825 | VCLKData1); | |
8104e329 | 6826 | xgifb_reg_set(pVBInfo->P3c4, |
1d7f656d KT |
6827 | 0x2C, |
6828 | pVBInfo->XG21_LVDSCapList[lvdstableindex]. | |
6829 | VCLKData2); | |
21df8fc8 PS |
6830 | value += 0x10; |
6831 | } | |
d7636e0b | 6832 | |
21df8fc8 | 6833 | if (!(modeflag & Charx8Dot)) { |
d8ad0a6d | 6834 | inb(pVBInfo->P3da); /* reset 3da */ |
efdf4ee7 | 6835 | outb(0x13, pVBInfo->P3c0); /* set index */ |
1d7f656d KT |
6836 | /* set data, panning = 0, shift left 1 dot*/ |
6837 | outb(0x00, pVBInfo->P3c0); | |
d7636e0b | 6838 | |
d8ad0a6d | 6839 | inb(pVBInfo->P3da); /* Enable Attribute */ |
efdf4ee7 | 6840 | outb(0x20, pVBInfo->P3c0); |
d7636e0b | 6841 | |
d8ad0a6d | 6842 | inb(pVBInfo->P3da); /* reset 3da */ |
21df8fc8 | 6843 | } |
d7636e0b | 6844 | |
6845 | } | |
6846 | ||
6847 | /* no shadow case */ | |
1d7f656d KT |
6848 | static void XGI_SetXG27LVDSPara(unsigned short ModeNo, |
6849 | unsigned short ModeIdIndex, | |
6850 | struct vb_device_info *pVBInfo) | |
21df8fc8 PS |
6851 | { |
6852 | unsigned char temp, Miscdata; | |
6853 | unsigned short xres, yres, modeflag, resindex, lvdstableindex; | |
6854 | unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE; | |
6855 | unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE; | |
6856 | unsigned short value; | |
6857 | ||
6858 | lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo); | |
1d7f656d KT |
6859 | temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
6860 | LVDS_Capability & | |
6861 | (LCDPolarity << 8)) >> 8); | |
21df8fc8 | 6862 | temp &= LCDPolarity; |
d8ad0a6d | 6863 | Miscdata = (unsigned char) inb(pVBInfo->P3cc); |
21df8fc8 | 6864 | |
efdf4ee7 | 6865 | outb((Miscdata & 0x3F) | temp, pVBInfo->P3c2); |
21df8fc8 | 6866 | |
1d7f656d KT |
6867 | temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
6868 | LVDS_Capability & LCDPolarity); | |
6869 | /* SR35[7] FP VSync polarity */ | |
6870 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80); | |
6871 | /* SR30[5] FP HSync polarity */ | |
6872 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); | |
21df8fc8 PS |
6873 | |
6874 | XGI_SetXG27FPBits(pVBInfo); | |
6875 | resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); | |
6876 | if (ModeNo <= 0x13) { | |
6877 | xres = pVBInfo->StResInfo[resindex].HTotal; | |
6878 | yres = pVBInfo->StResInfo[resindex].VTotal; | |
1d7f656d KT |
6879 | /* si+St_ResInfo */ |
6880 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
21df8fc8 PS |
6881 | } else { |
6882 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ | |
6883 | yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */ | |
1d7f656d KT |
6884 | /* si+St_ModeFlag */ |
6885 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
21df8fc8 PS |
6886 | } |
6887 | ||
6888 | if (!(modeflag & Charx8Dot)) | |
6889 | xres = xres * 8 / 9; | |
6890 | ||
6891 | LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT; | |
d7636e0b | 6892 | |
21df8fc8 PS |
6893 | LVDSHBS = xres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE |
6894 | - xres) / 2; | |
6895 | if ((ModeNo <= 0x13) && (modeflag & HalfDCLK)) | |
6896 | LVDSHBS -= xres / 4; | |
6897 | ||
6898 | if (LVDSHBS > LVDSHT) | |
6899 | LVDSHBS -= LVDSHT; | |
6900 | ||
6901 | LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP; | |
6902 | if (LVDSHRS > LVDSHT) | |
6903 | LVDSHRS -= LVDSHT; | |
6904 | ||
6905 | LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC; | |
6906 | if (LVDSHRE > LVDSHT) | |
6907 | LVDSHRE -= LVDSHT; | |
6908 | ||
6909 | LVDSHBE = LVDSHBS + LVDSHT | |
6910 | - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE; | |
6911 | ||
6912 | LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT; | |
d7636e0b | 6913 | |
21df8fc8 PS |
6914 | LVDSVBS = yres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE |
6915 | - yres) / 2; | |
6916 | if ((ModeNo > 0x13) && (modeflag & DoubleScanMode)) | |
6917 | LVDSVBS += yres / 2; | |
6918 | ||
6919 | if (LVDSVBS > LVDSVT) | |
6920 | LVDSVBS -= LVDSVT; | |
6921 | ||
6922 | LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP; | |
6923 | if (LVDSVRS > LVDSVT) | |
6924 | LVDSVRS -= LVDSVT; | |
6925 | ||
1d7f656d KT |
6926 | LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
6927 | LVDSVSYNC; | |
21df8fc8 PS |
6928 | if (LVDSVRE > LVDSVT) |
6929 | LVDSVRE -= LVDSVT; | |
6930 | ||
6931 | LVDSVBE = LVDSVBS + LVDSVT | |
6932 | - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE; | |
6933 | ||
58839b01 | 6934 | temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
8104e329 | 6935 | xgifb_reg_set(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */ |
21df8fc8 PS |
6936 | |
6937 | if (!(modeflag & Charx8Dot)) | |
b9bf6e4e | 6938 | xgifb_reg_or(pVBInfo->P3c4, 0x1, 0x1); |
21df8fc8 PS |
6939 | |
6940 | /* HT SR0B[1:0] CR00 */ | |
6941 | value = (LVDSHT >> 3) - 5; | |
ec9e5d3e | 6942 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8); |
8104e329 | 6943 | xgifb_reg_set(pVBInfo->P3d4, 0x0, (value & 0xFF)); |
21df8fc8 PS |
6944 | |
6945 | /* HBS SR0B[5:4] CR02 */ | |
6946 | value = (LVDSHBS >> 3) - 1; | |
ec9e5d3e | 6947 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4); |
8104e329 | 6948 | xgifb_reg_set(pVBInfo->P3d4, 0x2, (value & 0xFF)); |
21df8fc8 PS |
6949 | |
6950 | /* HBE SR0C[1:0] CR05[7] CR03[4:0] */ | |
6951 | value = (LVDSHBE >> 3) - 1; | |
ec9e5d3e AK |
6952 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6); |
6953 | xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2); | |
6954 | xgifb_reg_and_or(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F); | |
21df8fc8 PS |
6955 | |
6956 | /* HRS SR0B[7:6] CR04 */ | |
6957 | value = (LVDSHRS >> 3) + 2; | |
ec9e5d3e | 6958 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2); |
8104e329 | 6959 | xgifb_reg_set(pVBInfo->P3d4, 0x4, (value & 0xFF)); |
21df8fc8 PS |
6960 | |
6961 | /* Panel HRS SR2F[1:0] SR2E[7:0] */ | |
6962 | value--; | |
ec9e5d3e | 6963 | xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8); |
8104e329 | 6964 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, (value & 0xFF)); |
21df8fc8 PS |
6965 | |
6966 | /* HRE SR0C[2] CR05[4:0] */ | |
6967 | value = (LVDSHRE >> 3) + 2; | |
ec9e5d3e AK |
6968 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3); |
6969 | xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F); | |
21df8fc8 PS |
6970 | |
6971 | /* Panel HRE SR2F[7:2] */ | |
6972 | value--; | |
ec9e5d3e | 6973 | xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2); |
21df8fc8 PS |
6974 | |
6975 | /* VT SR0A[0] CR07[5][0] CR06 */ | |
6976 | value = LVDSVT - 2; | |
ec9e5d3e AK |
6977 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10); |
6978 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4); | |
6979 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8); | |
8104e329 | 6980 | xgifb_reg_set(pVBInfo->P3d4, 0x06, (value & 0xFF)); |
21df8fc8 PS |
6981 | |
6982 | /* VBS SR0A[2] CR09[5] CR07[3] CR15 */ | |
6983 | value = LVDSVBS - 1; | |
ec9e5d3e AK |
6984 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8); |
6985 | xgifb_reg_and_or(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4); | |
6986 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5); | |
8104e329 | 6987 | xgifb_reg_set(pVBInfo->P3d4, 0x15, (value & 0xFF)); |
21df8fc8 PS |
6988 | |
6989 | /* VBE SR0A[4] CR16 */ | |
6990 | value = LVDSVBE - 1; | |
ec9e5d3e | 6991 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4); |
8104e329 | 6992 | xgifb_reg_set(pVBInfo->P3d4, 0x16, (value & 0xFF)); |
21df8fc8 PS |
6993 | |
6994 | /* VRS SR0A[3] CR7[7][2] CR10 */ | |
6995 | value = LVDSVRS - 1; | |
ec9e5d3e AK |
6996 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7); |
6997 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2); | |
6998 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6); | |
8104e329 | 6999 | xgifb_reg_set(pVBInfo->P3d4, 0x10, (value & 0xFF)); |
21df8fc8 PS |
7000 | |
7001 | /* Panel VRS SR35[2:0] SR34[7:0] */ | |
ec9e5d3e | 7002 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, (value & 0x700) >> 8); |
8104e329 | 7003 | xgifb_reg_set(pVBInfo->P3c4, 0x34, value & 0xFF); |
21df8fc8 PS |
7004 | |
7005 | /* VRE SR0A[5] CR11[3:0] */ | |
7006 | value = LVDSVRE - 1; | |
ec9e5d3e AK |
7007 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1); |
7008 | xgifb_reg_and_or(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F); | |
21df8fc8 PS |
7009 | |
7010 | /* Panel VRE SR3F[7:2] */ | |
ec9e5d3e | 7011 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, (value << 2) & 0xFC); |
21df8fc8 PS |
7012 | |
7013 | for (temp = 0, value = 0; temp < 3; temp++) { | |
7014 | ||
ec9e5d3e | 7015 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, value); |
8104e329 | 7016 | xgifb_reg_set(pVBInfo->P3c4, |
1d7f656d KT |
7017 | 0x2B, |
7018 | pVBInfo->XG21_LVDSCapList[lvdstableindex]. | |
7019 | VCLKData1); | |
8104e329 | 7020 | xgifb_reg_set(pVBInfo->P3c4, |
1d7f656d KT |
7021 | 0x2C, |
7022 | pVBInfo->XG21_LVDSCapList[lvdstableindex]. | |
7023 | VCLKData2); | |
21df8fc8 PS |
7024 | value += 0x10; |
7025 | } | |
d7636e0b | 7026 | |
21df8fc8 | 7027 | if (!(modeflag & Charx8Dot)) { |
d8ad0a6d | 7028 | inb(pVBInfo->P3da); /* reset 3da */ |
efdf4ee7 | 7029 | outb(0x13, pVBInfo->P3c0); /* set index */ |
1d7f656d KT |
7030 | /* set data, panning = 0, shift left 1 dot*/ |
7031 | outb(0x00, pVBInfo->P3c0); | |
d7636e0b | 7032 | |
d8ad0a6d | 7033 | inb(pVBInfo->P3da); /* Enable Attribute */ |
efdf4ee7 | 7034 | outb(0x20, pVBInfo->P3c0); |
d7636e0b | 7035 | |
d8ad0a6d | 7036 | inb(pVBInfo->P3da); /* reset 3da */ |
21df8fc8 | 7037 | } |
d7636e0b | 7038 | |
7039 | } | |
7040 | ||
7041 | /* --------------------------------------------------------------------- */ | |
7042 | /* Function : XGI_IsLCDON */ | |
7043 | /* Input : */ | |
dda08c59 BP |
7044 | /* Output : 0 : Skip PSC Control */ |
7045 | /* 1: Disable PSC */ | |
d7636e0b | 7046 | /* Description : */ |
7047 | /* --------------------------------------------------------------------- */ | |
063b9c4b | 7048 | static unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo) |
d7636e0b | 7049 | { |
21df8fc8 | 7050 | unsigned short tempax; |
d7636e0b | 7051 | |
21df8fc8 PS |
7052 | tempax = pVBInfo->VBInfo; |
7053 | if (tempax & SetCRT2ToDualEdge) | |
7054 | return 0; | |
7055 | else if (tempax & (DisableCRT2Display | SwitchToCRT2 | SetSimuScanMode)) | |
7056 | return 1; | |
d7636e0b | 7057 | |
21df8fc8 | 7058 | return 0; |
d7636e0b | 7059 | } |
7060 | ||
d7636e0b | 7061 | /* --------------------------------------------------------------------- */ |
7062 | /* Function : XGI_DisableChISLCD */ | |
7063 | /* Input : */ | |
dda08c59 | 7064 | /* Output : 0 -> Not LCD Mode */ |
d7636e0b | 7065 | /* Description : */ |
7066 | /* --------------------------------------------------------------------- */ | |
063b9c4b | 7067 | static unsigned char XGI_DisableChISLCD(struct vb_device_info *pVBInfo) |
d7636e0b | 7068 | { |
21df8fc8 | 7069 | unsigned short tempbx, tempah; |
d7636e0b | 7070 | |
21df8fc8 | 7071 | tempbx = pVBInfo->SetFlag & (DisableChA | DisableChB); |
58839b01 | 7072 | tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E)); |
d7636e0b | 7073 | |
21df8fc8 PS |
7074 | if (tempbx & (EnableChA | DisableChA)) { |
7075 | if (!(tempah & 0x08)) /* Chk LCDA Mode */ | |
7076 | return 0; | |
7077 | } | |
d7636e0b | 7078 | |
21df8fc8 PS |
7079 | if (!(tempbx & (EnableChB | DisableChB))) |
7080 | return 0; | |
d7636e0b | 7081 | |
21df8fc8 PS |
7082 | if (tempah & 0x01) /* Chk LCDB Mode */ |
7083 | return 1; | |
d7636e0b | 7084 | |
21df8fc8 | 7085 | return 0; |
d7636e0b | 7086 | } |
7087 | ||
d7636e0b | 7088 | /* --------------------------------------------------------------------- */ |
7089 | /* Function : XGI_EnableChISLCD */ | |
7090 | /* Input : */ | |
7091 | /* Output : 0 -> Not LCD mode */ | |
7092 | /* Description : */ | |
7093 | /* --------------------------------------------------------------------- */ | |
063b9c4b | 7094 | static unsigned char XGI_EnableChISLCD(struct vb_device_info *pVBInfo) |
d7636e0b | 7095 | { |
21df8fc8 | 7096 | unsigned short tempbx, tempah; |
d7636e0b | 7097 | |
21df8fc8 | 7098 | tempbx = pVBInfo->SetFlag & (EnableChA | EnableChB); |
58839b01 | 7099 | tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E)); |
d7636e0b | 7100 | |
21df8fc8 PS |
7101 | if (tempbx & (EnableChA | DisableChA)) { |
7102 | if (!(tempah & 0x08)) /* Chk LCDA Mode */ | |
7103 | return 0; | |
7104 | } | |
d7636e0b | 7105 | |
21df8fc8 | 7106 | if (!(tempbx & (EnableChB | DisableChB))) |
dda08c59 | 7107 | return 0; |
d7636e0b | 7108 | |
21df8fc8 PS |
7109 | if (tempah & 0x01) /* Chk LCDB Mode */ |
7110 | return 1; | |
d7636e0b | 7111 | |
cc1e2398 AK |
7112 | return 0; |
7113 | } | |
7114 | ||
7115 | void XGI_DisableBridge(struct xgi_hw_device_info *HwDeviceExtension, | |
7116 | struct vb_device_info *pVBInfo) | |
7117 | { | |
fd0ad470 | 7118 | unsigned short tempah = 0; |
cc1e2398 AK |
7119 | |
7120 | if (pVBInfo->SetFlag == Win9xDOSMode) | |
7121 | return; | |
7122 | ||
cc1e2398 AK |
7123 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
7124 | | VB_XGI302LV | VB_XGI301C)) { | |
7125 | tempah = 0x3F; | |
1d7f656d KT |
7126 | if (!(pVBInfo->VBInfo & |
7127 | (DisableCRT2Display | SetSimuScanMode))) { | |
cc1e2398 AK |
7128 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { |
7129 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { | |
7130 | tempah = 0x7F; /* Disable Channel A */ | |
7131 | if (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) | |
1d7f656d KT |
7132 | /* Disable Channel B */ |
7133 | tempah = 0xBF; | |
cc1e2398 AK |
7134 | |
7135 | if (pVBInfo->SetFlag & DisableChB) | |
1d7f656d KT |
7136 | /* force to disable Cahnnel */ |
7137 | tempah &= 0xBF; | |
cc1e2398 AK |
7138 | |
7139 | if (pVBInfo->SetFlag & DisableChA) | |
1d7f656d KT |
7140 | /* Force to disable Channel B */ |
7141 | tempah &= 0x7F; | |
cc1e2398 AK |
7142 | } |
7143 | } | |
7144 | } | |
7145 | ||
1d7f656d KT |
7146 | /* disable part4_1f */ |
7147 | xgifb_reg_and(pVBInfo->Part4Port, 0x1F, tempah); | |
cc1e2398 AK |
7148 | |
7149 | if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) { | |
7150 | if (((pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))) | |
7151 | || (XGI_DisableChISLCD(pVBInfo)) | |
7152 | || (XGI_IsLCDON(pVBInfo))) | |
1d7f656d KT |
7153 | /* LVDS Driver power down */ |
7154 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x80); | |
cc1e2398 AK |
7155 | } |
7156 | ||
7157 | if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo | |
7158 | & (DisableCRT2Display | SetCRT2ToLCDA | |
7159 | | SetSimuScanMode))) { | |
7160 | if (pVBInfo->SetFlag & GatingCRT) | |
7161 | XGI_EnableGatingCRT(HwDeviceExtension, pVBInfo); | |
7162 | XGI_DisplayOff(HwDeviceExtension, pVBInfo); | |
7163 | } | |
7164 | ||
7165 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { | |
7166 | if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo | |
7167 | & SetCRT2ToLCDA)) | |
1d7f656d KT |
7168 | /* Power down */ |
7169 | xgifb_reg_and(pVBInfo->Part1Port, 0x1e, 0xdf); | |
cc1e2398 AK |
7170 | } |
7171 | ||
1d7f656d KT |
7172 | /* disable TV as primary VGA swap */ |
7173 | xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xdf); | |
cc1e2398 AK |
7174 | |
7175 | if ((pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToDualEdge))) | |
dc50556b | 7176 | xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xdf); |
cc1e2398 | 7177 | |
1d7f656d KT |
7178 | if ((pVBInfo->SetFlag & DisableChB) || |
7179 | (pVBInfo->VBInfo & | |
7180 | (DisableCRT2Display | SetSimuScanMode)) || | |
7181 | ((!(pVBInfo->VBInfo & SetCRT2ToLCDA)) && | |
7182 | (pVBInfo->VBInfo & | |
7183 | (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV)))) | |
7184 | /* BScreenOff=1 */ | |
7185 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80); | |
7186 | ||
7187 | if ((pVBInfo->SetFlag & DisableChB) || | |
7188 | (pVBInfo->VBInfo & | |
7189 | (DisableCRT2Display | SetSimuScanMode)) || | |
7190 | (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) || | |
7191 | (pVBInfo->VBInfo & | |
7192 | (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV))) { | |
7193 | /* save Part1 index 0 */ | |
7194 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00); | |
7195 | /* BTDAC = 1, avoid VB reset */ | |
7196 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x10); | |
7197 | /* disable CRT2 */ | |
7198 | xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF); | |
7199 | /* restore Part1 index 0 */ | |
7200 | xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah); | |
cc1e2398 AK |
7201 | } |
7202 | } else { /* {301} */ | |
7203 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) { | |
1d7f656d KT |
7204 | /* BScreenOff=1 */ |
7205 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80); | |
7206 | /* Disable CRT2 */ | |
7207 | xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF); | |
7208 | /* Disable TV asPrimary VGA swap */ | |
7209 | xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xDF); | |
cc1e2398 AK |
7210 | } |
7211 | ||
7212 | if (pVBInfo->VBInfo & (DisableCRT2Display | SetCRT2ToLCDA | |
7213 | | SetSimuScanMode)) | |
7214 | XGI_DisplayOff(HwDeviceExtension, pVBInfo); | |
7215 | } | |
cc1e2398 AK |
7216 | } |
7217 | ||
7218 | /* --------------------------------------------------------------------- */ | |
7219 | /* Function : XGI_GetTVPtrIndex */ | |
7220 | /* Input : */ | |
7221 | /* Output : */ | |
7222 | /* Description : bx 0 : ExtNTSC */ | |
7223 | /* 1 : StNTSC */ | |
7224 | /* 2 : ExtPAL */ | |
7225 | /* 3 : StPAL */ | |
7226 | /* 4 : ExtHiTV */ | |
7227 | /* 5 : StHiTV */ | |
7228 | /* 6 : Ext525i */ | |
7229 | /* 7 : St525i */ | |
7230 | /* 8 : Ext525p */ | |
7231 | /* 9 : St525p */ | |
7232 | /* A : Ext750p */ | |
7233 | /* B : St750p */ | |
7234 | /* --------------------------------------------------------------------- */ | |
7235 | static unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo) | |
7236 | { | |
7237 | unsigned short tempbx = 0; | |
7238 | ||
7239 | if (pVBInfo->TVInfo & SetPALTV) | |
7240 | tempbx = 2; | |
7241 | if (pVBInfo->TVInfo & SetYPbPrMode1080i) | |
7242 | tempbx = 4; | |
7243 | if (pVBInfo->TVInfo & SetYPbPrMode525i) | |
7244 | tempbx = 6; | |
7245 | if (pVBInfo->TVInfo & SetYPbPrMode525p) | |
7246 | tempbx = 8; | |
7247 | if (pVBInfo->TVInfo & SetYPbPrMode750p) | |
7248 | tempbx = 10; | |
7249 | if (pVBInfo->TVInfo & TVSimuMode) | |
7250 | tempbx++; | |
7251 | ||
7252 | return tempbx; | |
7253 | } | |
7254 | ||
7255 | /* --------------------------------------------------------------------- */ | |
7256 | /* Function : XGI_GetTVPtrIndex2 */ | |
7257 | /* Input : */ | |
7258 | /* Output : bx 0 : NTSC */ | |
7259 | /* 1 : PAL */ | |
7260 | /* 2 : PALM */ | |
7261 | /* 3 : PALN */ | |
7262 | /* 4 : NTSC1024x768 */ | |
7263 | /* 5 : PAL-M 1024x768 */ | |
7264 | /* 6-7: reserved */ | |
7265 | /* cl 0 : YFilter1 */ | |
7266 | /* 1 : YFilter2 */ | |
7267 | /* ch 0 : 301A */ | |
7268 | /* 1 : 301B/302B/301LV/302LV */ | |
7269 | /* Description : */ | |
7270 | /* --------------------------------------------------------------------- */ | |
7271 | static void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char *tempcl, | |
7272 | unsigned char *tempch, struct vb_device_info *pVBInfo) | |
7273 | { | |
7274 | *tempbx = 0; | |
7275 | *tempcl = 0; | |
7276 | *tempch = 0; | |
7277 | ||
7278 | if (pVBInfo->TVInfo & SetPALTV) | |
7279 | *tempbx = 1; | |
7280 | ||
7281 | if (pVBInfo->TVInfo & SetPALMTV) | |
7282 | *tempbx = 2; | |
7283 | ||
7284 | if (pVBInfo->TVInfo & SetPALNTV) | |
7285 | *tempbx = 3; | |
7286 | ||
7287 | if (pVBInfo->TVInfo & NTSC1024x768) { | |
7288 | *tempbx = 4; | |
7289 | if (pVBInfo->TVInfo & SetPALMTV) | |
7290 | *tempbx = 5; | |
7291 | } | |
7292 | ||
7293 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | |
7294 | | VB_XGI302LV | VB_XGI301C)) { | |
7295 | if ((!(pVBInfo->VBInfo & SetInSlaveMode)) || (pVBInfo->TVInfo | |
7296 | & TVSimuMode)) { | |
7297 | *tempbx += 8; | |
7298 | *tempcl += 1; | |
7299 | } | |
7300 | } | |
7301 | ||
7302 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | |
7303 | | VB_XGI302LV | VB_XGI301C)) | |
7304 | (*tempch)++; | |
d7636e0b | 7305 | } |
7306 | ||
cc1e2398 | 7307 | static void XGI_SetDelayComp(struct vb_device_info *pVBInfo) |
d7636e0b | 7308 | { |
cc1e2398 | 7309 | unsigned short index; |
d7636e0b | 7310 | |
cc1e2398 | 7311 | unsigned char tempah, tempbl, tempbh; |
d7636e0b | 7312 | |
cc1e2398 AK |
7313 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
7314 | | VB_XGI302LV | VB_XGI301C)) { | |
7315 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA | |
7316 | | SetCRT2ToTV | SetCRT2ToRAMDAC)) { | |
7317 | tempbl = 0; | |
7318 | tempbh = 0; | |
d7636e0b | 7319 | |
cc1e2398 AK |
7320 | index = XGI_GetTVPtrIndex(pVBInfo); /* Get TV Delay */ |
7321 | tempbl = pVBInfo->XGI_TVDelayList[index]; | |
d7636e0b | 7322 | |
cc1e2398 AK |
7323 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B |
7324 | | VB_XGI301LV | VB_XGI302LV | |
7325 | | VB_XGI301C)) | |
7326 | tempbl = pVBInfo->XGI_TVDelayList2[index]; | |
d7636e0b | 7327 | |
cc1e2398 AK |
7328 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) |
7329 | tempbl = tempbl >> 4; | |
7330 | /* | |
7331 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) | |
7332 | tempbl = CRT2Delay1; // Get CRT2 Delay | |
1d7f656d KT |
7333 | if (pVBInfo->VBType & |
7334 | (VB_XGI301B | | |
7335 | VB_XGI302B | | |
7336 | VB_XGI301LV | | |
7337 | VB_XGI302LV | | |
7338 | VB_XGI301C)) | |
cc1e2398 AK |
7339 | tempbl = CRT2Delay2; |
7340 | */ | |
7341 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { | |
1d7f656d KT |
7342 | /* Get LCD Delay */ |
7343 | index = XGI_GetLCDCapPtr(pVBInfo); | |
7344 | tempbh = pVBInfo->LCDCapList[index]. | |
7345 | LCD_DelayCompensation; | |
d7636e0b | 7346 | |
cc1e2398 AK |
7347 | if (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) |
7348 | tempbl = tempbh; | |
7349 | } | |
d7636e0b | 7350 | |
cc1e2398 AK |
7351 | tempbl &= 0x0F; |
7352 | tempbh &= 0xF0; | |
58839b01 | 7353 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x2D); |
d7636e0b | 7354 | |
cc1e2398 AK |
7355 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD |
7356 | | SetCRT2ToTV)) { /* Channel B */ | |
7357 | tempah &= 0xF0; | |
7358 | tempah |= tempbl; | |
7359 | } | |
d7636e0b | 7360 | |
cc1e2398 AK |
7361 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { /* Channel A */ |
7362 | tempah &= 0x0F; | |
7363 | tempah |= tempbh; | |
7364 | } | |
8104e329 | 7365 | xgifb_reg_set(pVBInfo->Part1Port, 0x2D, tempah); |
cc1e2398 AK |
7366 | } |
7367 | } else if (pVBInfo->IF_DEF_LVDS == 1) { | |
7368 | tempbl = 0; | |
7369 | tempbh = 0; | |
7370 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { | |
1d7f656d KT |
7371 | /* / Get LCD Delay */ |
7372 | tempah = pVBInfo->LCDCapList[ | |
7373 | XGI_GetLCDCapPtr(pVBInfo)]. | |
7374 | LCD_DelayCompensation; | |
cc1e2398 AK |
7375 | tempah &= 0x0f; |
7376 | tempah = tempah << 4; | |
ec9e5d3e | 7377 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2D, 0x0f, |
cc1e2398 | 7378 | tempah); |
21df8fc8 | 7379 | } |
cc1e2398 AK |
7380 | } |
7381 | } | |
d7636e0b | 7382 | |
1d7f656d KT |
7383 | static void XGI_SetLCDCap_A(unsigned short tempcx, |
7384 | struct vb_device_info *pVBInfo) | |
cc1e2398 AK |
7385 | { |
7386 | unsigned short temp; | |
d7636e0b | 7387 | |
58839b01 | 7388 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
cc1e2398 AK |
7389 | |
7390 | if (temp & LCDRGB18Bit) { | |
ec9e5d3e | 7391 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F, |
1d7f656d KT |
7392 | /* Enable Dither */ |
7393 | (unsigned short) (0x20 | (tempcx & 0x00C0))); | |
ec9e5d3e | 7394 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80); |
cc1e2398 | 7395 | } else { |
ec9e5d3e | 7396 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F, |
cc1e2398 | 7397 | (unsigned short) (0x30 | (tempcx & 0x00C0))); |
ec9e5d3e | 7398 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00); |
21df8fc8 | 7399 | } |
d7636e0b | 7400 | |
cc1e2398 AK |
7401 | /* |
7402 | if (tempcx & EnableLCD24bpp) { // 24bits | |
1d7f656d KT |
7403 | xgifb_reg_and_or(pVBInfo->Part1Port, |
7404 | 0x19, | |
7405 | 0x0F, | |
7406 | (unsigned short)(0x30 | (tempcx&0x00C0))); | |
ec9e5d3e | 7407 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00); |
cc1e2398 | 7408 | } else { |
1d7f656d KT |
7409 | xgifb_reg_and_or(pVBInfo->Part1Port, |
7410 | 0x19, | |
7411 | 0x0F, | |
7412 | // Enable Dither | |
7413 | (unsigned short)(0x20 | (tempcx&0x00C0))); | |
ec9e5d3e | 7414 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80); |
21df8fc8 | 7415 | } |
cc1e2398 AK |
7416 | */ |
7417 | } | |
d7636e0b | 7418 | |
cc1e2398 AK |
7419 | /* --------------------------------------------------------------------- */ |
7420 | /* Function : XGI_SetLCDCap_B */ | |
7421 | /* Input : cx -> LCD Capability */ | |
7422 | /* Output : */ | |
7423 | /* Description : */ | |
7424 | /* --------------------------------------------------------------------- */ | |
1d7f656d KT |
7425 | static void XGI_SetLCDCap_B(unsigned short tempcx, |
7426 | struct vb_device_info *pVBInfo) | |
cc1e2398 AK |
7427 | { |
7428 | if (tempcx & EnableLCD24bpp) /* 24bits */ | |
ec9e5d3e | 7429 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0, |
cc1e2398 AK |
7430 | (unsigned short) (((tempcx & 0x00ff) >> 6) |
7431 | | 0x0c)); | |
7432 | else | |
ec9e5d3e | 7433 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0, |
cc1e2398 AK |
7434 | (unsigned short) (((tempcx & 0x00ff) >> 6) |
7435 | | 0x18)); /* Enable Dither */ | |
d7636e0b | 7436 | } |
7437 | ||
cc1e2398 | 7438 | static void SetSpectrum(struct vb_device_info *pVBInfo) |
d7636e0b | 7439 | { |
cc1e2398 | 7440 | unsigned short index; |
d7636e0b | 7441 | |
cc1e2398 | 7442 | index = XGI_GetLCDCapPtr(pVBInfo); |
d7636e0b | 7443 | |
1d7f656d KT |
7444 | /* disable down spectrum D[4] */ |
7445 | xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x8F); | |
cc1e2398 | 7446 | XGI_LongWait(pVBInfo); |
b9bf6e4e | 7447 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x20); /* reset spectrum */ |
cc1e2398 AK |
7448 | XGI_LongWait(pVBInfo); |
7449 | ||
8104e329 | 7450 | xgifb_reg_set(pVBInfo->Part4Port, 0x31, |
cc1e2398 | 7451 | pVBInfo->LCDCapList[index].Spectrum_31); |
8104e329 | 7452 | xgifb_reg_set(pVBInfo->Part4Port, 0x32, |
cc1e2398 | 7453 | pVBInfo->LCDCapList[index].Spectrum_32); |
8104e329 | 7454 | xgifb_reg_set(pVBInfo->Part4Port, 0x33, |
cc1e2398 | 7455 | pVBInfo->LCDCapList[index].Spectrum_33); |
8104e329 | 7456 | xgifb_reg_set(pVBInfo->Part4Port, 0x34, |
cc1e2398 AK |
7457 | pVBInfo->LCDCapList[index].Spectrum_34); |
7458 | XGI_LongWait(pVBInfo); | |
b9bf6e4e | 7459 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x40); /* enable spectrum */ |
d7636e0b | 7460 | } |
7461 | ||
cc1e2398 | 7462 | static void XGI_SetLCDCap(struct vb_device_info *pVBInfo) |
21df8fc8 | 7463 | { |
cc1e2398 | 7464 | unsigned short tempcx; |
21df8fc8 | 7465 | |
cc1e2398 | 7466 | tempcx = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(pVBInfo)].LCD_Capability; |
21df8fc8 | 7467 | |
1d7f656d KT |
7468 | if (pVBInfo->VBType & |
7469 | (VB_XGI301B | | |
7470 | VB_XGI302B | | |
7471 | VB_XGI301LV | | |
7472 | VB_XGI302LV | | |
7473 | VB_XGI301C)) { /* 301LV/302LV only */ | |
7474 | if (pVBInfo->VBType & | |
7475 | (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) { | |
cc1e2398 | 7476 | /* Set 301LV Capability */ |
8104e329 | 7477 | xgifb_reg_set(pVBInfo->Part4Port, 0x24, |
cc1e2398 | 7478 | (unsigned char) (tempcx & 0x1F)); |
21df8fc8 | 7479 | } |
cc1e2398 | 7480 | /* VB Driving */ |
ec9e5d3e | 7481 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D, |
cc1e2398 AK |
7482 | ~((EnableVBCLKDRVLOW | EnablePLLSPLOW) >> 8), |
7483 | (unsigned short) ((tempcx & (EnableVBCLKDRVLOW | |
7484 | | EnablePLLSPLOW)) >> 8)); | |
7485 | } | |
21df8fc8 | 7486 | |
cc1e2398 AK |
7487 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
7488 | | VB_XGI302LV | VB_XGI301C)) { | |
7489 | if (pVBInfo->VBInfo & SetCRT2ToLCD) | |
7490 | XGI_SetLCDCap_B(tempcx, pVBInfo); | |
7491 | else if (pVBInfo->VBInfo & SetCRT2ToLCDA) | |
7492 | XGI_SetLCDCap_A(tempcx, pVBInfo); | |
21df8fc8 | 7493 | |
cc1e2398 AK |
7494 | if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) { |
7495 | if (tempcx & EnableSpectrum) | |
7496 | SetSpectrum(pVBInfo); | |
7497 | } | |
7498 | } else { | |
7499 | /* LVDS,CH7017 */ | |
7500 | XGI_SetLCDCap_A(tempcx, pVBInfo); | |
7501 | } | |
7502 | } | |
21df8fc8 | 7503 | |
cc1e2398 AK |
7504 | /* --------------------------------------------------------------------- */ |
7505 | /* Function : XGI_SetAntiFlicker */ | |
7506 | /* Input : */ | |
7507 | /* Output : */ | |
7508 | /* Description : Set TV Customized Param. */ | |
7509 | /* --------------------------------------------------------------------- */ | |
1d7f656d KT |
7510 | static void XGI_SetAntiFlicker(unsigned short ModeNo, |
7511 | unsigned short ModeIdIndex, | |
7512 | struct vb_device_info *pVBInfo) | |
cc1e2398 AK |
7513 | { |
7514 | unsigned short tempbx, index; | |
21df8fc8 | 7515 | |
cc1e2398 | 7516 | unsigned char tempah; |
21df8fc8 | 7517 | |
cc1e2398 AK |
7518 | if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)) |
7519 | return; | |
21df8fc8 | 7520 | |
cc1e2398 AK |
7521 | tempbx = XGI_GetTVPtrIndex(pVBInfo); |
7522 | tempbx &= 0xFE; | |
21df8fc8 | 7523 | |
cc1e2398 AK |
7524 | if (ModeNo <= 0x13) |
7525 | index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVFlickerIndex; | |
7526 | else | |
7527 | index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVFlickerIndex; | |
21df8fc8 | 7528 | |
cc1e2398 AK |
7529 | tempbx += index; |
7530 | tempah = TVAntiFlickList[tempbx]; | |
7531 | tempah = tempah << 4; | |
21df8fc8 | 7532 | |
ec9e5d3e | 7533 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0x8F, tempah); |
cc1e2398 | 7534 | } |
21df8fc8 | 7535 | |
1d7f656d KT |
7536 | static void XGI_SetEdgeEnhance(unsigned short ModeNo, |
7537 | unsigned short ModeIdIndex, | |
7538 | struct vb_device_info *pVBInfo) | |
cc1e2398 AK |
7539 | { |
7540 | unsigned short tempbx, index; | |
21df8fc8 | 7541 | |
cc1e2398 | 7542 | unsigned char tempah; |
21df8fc8 | 7543 | |
cc1e2398 AK |
7544 | tempbx = XGI_GetTVPtrIndex(pVBInfo); |
7545 | tempbx &= 0xFE; | |
21df8fc8 | 7546 | |
cc1e2398 AK |
7547 | if (ModeNo <= 0x13) |
7548 | index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVEdgeIndex; | |
7549 | else | |
7550 | index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVEdgeIndex; | |
21df8fc8 | 7551 | |
cc1e2398 AK |
7552 | tempbx += index; |
7553 | tempah = TVEdgeList[tempbx]; | |
7554 | tempah = tempah << 5; | |
21df8fc8 | 7555 | |
ec9e5d3e | 7556 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, tempah); |
d7636e0b | 7557 | } |
7558 | ||
cc1e2398 | 7559 | static void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo) |
21df8fc8 | 7560 | { |
cc1e2398 | 7561 | unsigned short tempbx; |
21df8fc8 | 7562 | |
cc1e2398 | 7563 | unsigned char tempcl, tempch; |
21df8fc8 | 7564 | |
cc1e2398 | 7565 | unsigned long tempData; |
d7636e0b | 7566 | |
cc1e2398 AK |
7567 | XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */ |
7568 | tempData = TVPhaseList[tempbx]; | |
21df8fc8 | 7569 | |
8104e329 | 7570 | xgifb_reg_set(pVBInfo->Part2Port, 0x31, (unsigned short) (tempData |
cc1e2398 | 7571 | & 0x000000FF)); |
8104e329 | 7572 | xgifb_reg_set(pVBInfo->Part2Port, 0x32, (unsigned short) ((tempData |
cc1e2398 | 7573 | & 0x0000FF00) >> 8)); |
8104e329 | 7574 | xgifb_reg_set(pVBInfo->Part2Port, 0x33, (unsigned short) ((tempData |
cc1e2398 | 7575 | & 0x00FF0000) >> 16)); |
8104e329 | 7576 | xgifb_reg_set(pVBInfo->Part2Port, 0x34, (unsigned short) ((tempData |
cc1e2398 AK |
7577 | & 0xFF000000) >> 24)); |
7578 | } | |
21df8fc8 | 7579 | |
cc1e2398 AK |
7580 | static void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex, |
7581 | struct vb_device_info *pVBInfo) | |
7582 | { | |
7583 | unsigned short tempbx, index; | |
21df8fc8 | 7584 | |
cc1e2398 | 7585 | unsigned char tempcl, tempch, tempal, *filterPtr; |
21df8fc8 | 7586 | |
cc1e2398 | 7587 | XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */ |
21df8fc8 | 7588 | |
cc1e2398 AK |
7589 | switch (tempbx) { |
7590 | case 0x00: | |
7591 | case 0x04: | |
7592 | filterPtr = NTSCYFilter1; | |
7593 | break; | |
21df8fc8 | 7594 | |
cc1e2398 AK |
7595 | case 0x01: |
7596 | filterPtr = PALYFilter1; | |
7597 | break; | |
21df8fc8 | 7598 | |
cc1e2398 AK |
7599 | case 0x02: |
7600 | case 0x05: | |
7601 | case 0x0D: | |
7602 | filterPtr = PALMYFilter1; | |
7603 | break; | |
7604 | ||
7605 | case 0x03: | |
7606 | filterPtr = PALNYFilter1; | |
7607 | break; | |
21df8fc8 | 7608 | |
cc1e2398 AK |
7609 | case 0x08: |
7610 | case 0x0C: | |
7611 | filterPtr = NTSCYFilter2; | |
7612 | break; | |
21df8fc8 | 7613 | |
cc1e2398 AK |
7614 | case 0x0A: |
7615 | filterPtr = PALMYFilter2; | |
7616 | break; | |
21df8fc8 | 7617 | |
cc1e2398 AK |
7618 | case 0x0B: |
7619 | filterPtr = PALNYFilter2; | |
7620 | break; | |
21df8fc8 | 7621 | |
cc1e2398 AK |
7622 | case 0x09: |
7623 | filterPtr = PALYFilter2; | |
7624 | break; | |
21df8fc8 | 7625 | |
cc1e2398 AK |
7626 | default: |
7627 | return; | |
21df8fc8 | 7628 | } |
d7636e0b | 7629 | |
cc1e2398 | 7630 | if (ModeNo <= 0x13) |
1d7f656d KT |
7631 | tempal = pVBInfo->SModeIDTable[ModeIdIndex]. |
7632 | VB_StTVYFilterIndex; | |
cc1e2398 | 7633 | else |
1d7f656d KT |
7634 | tempal = pVBInfo->EModeIDTable[ModeIdIndex]. |
7635 | VB_ExtTVYFilterIndex; | |
d7636e0b | 7636 | |
cc1e2398 AK |
7637 | if (tempcl == 0) |
7638 | index = tempal * 4; | |
7639 | else | |
7640 | index = tempal * 7; | |
d7636e0b | 7641 | |
cc1e2398 | 7642 | if ((tempcl == 0) && (tempch == 1)) { |
8104e329 AK |
7643 | xgifb_reg_set(pVBInfo->Part2Port, 0x35, 0); |
7644 | xgifb_reg_set(pVBInfo->Part2Port, 0x36, 0); | |
7645 | xgifb_reg_set(pVBInfo->Part2Port, 0x37, 0); | |
7646 | xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]); | |
cc1e2398 | 7647 | } else { |
8104e329 AK |
7648 | xgifb_reg_set(pVBInfo->Part2Port, 0x35, filterPtr[index++]); |
7649 | xgifb_reg_set(pVBInfo->Part2Port, 0x36, filterPtr[index++]); | |
7650 | xgifb_reg_set(pVBInfo->Part2Port, 0x37, filterPtr[index++]); | |
7651 | xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]); | |
cc1e2398 | 7652 | } |
d7636e0b | 7653 | |
cc1e2398 AK |
7654 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
7655 | | VB_XGI302LV | VB_XGI301C)) { | |
8104e329 AK |
7656 | xgifb_reg_set(pVBInfo->Part2Port, 0x48, filterPtr[index++]); |
7657 | xgifb_reg_set(pVBInfo->Part2Port, 0x49, filterPtr[index++]); | |
7658 | xgifb_reg_set(pVBInfo->Part2Port, 0x4A, filterPtr[index++]); | |
cc1e2398 | 7659 | } |
d7636e0b | 7660 | } |
7661 | ||
d7636e0b | 7662 | /* --------------------------------------------------------------------- */ |
7663 | /* Function : XGI_OEM310Setting */ | |
7664 | /* Input : */ | |
7665 | /* Output : */ | |
7666 | /* Description : Customized Param. for 301 */ | |
7667 | /* --------------------------------------------------------------------- */ | |
1d7f656d KT |
7668 | static void XGI_OEM310Setting(unsigned short ModeNo, |
7669 | unsigned short ModeIdIndex, | |
7670 | struct vb_device_info *pVBInfo) | |
d7636e0b | 7671 | { |
21df8fc8 PS |
7672 | if (pVBInfo->SetFlag & Win9xDOSMode) |
7673 | return; | |
d7636e0b | 7674 | |
21df8fc8 PS |
7675 | /* GetPart1IO(); */ |
7676 | XGI_SetDelayComp(pVBInfo); | |
d7636e0b | 7677 | |
21df8fc8 PS |
7678 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) |
7679 | XGI_SetLCDCap(pVBInfo); | |
d7636e0b | 7680 | |
21df8fc8 PS |
7681 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
7682 | /* GetPart2IO() */ | |
7683 | XGI_SetPhaseIncr(pVBInfo); | |
7684 | XGI_SetYFilter(ModeNo, ModeIdIndex, pVBInfo); | |
7685 | XGI_SetAntiFlicker(ModeNo, ModeIdIndex, pVBInfo); | |
d7636e0b | 7686 | |
21df8fc8 PS |
7687 | if (pVBInfo->VBType & VB_XGI301) |
7688 | XGI_SetEdgeEnhance(ModeNo, ModeIdIndex, pVBInfo); | |
7689 | } | |
d7636e0b | 7690 | } |
7691 | ||
cc1e2398 AK |
7692 | /* --------------------------------------------------------------------- */ |
7693 | /* Function : XGI_SetCRT2ModeRegs */ | |
7694 | /* Input : */ | |
7695 | /* Output : */ | |
7696 | /* Description : Origin code for crt2group */ | |
7697 | /* --------------------------------------------------------------------- */ | |
7698 | void XGI_SetCRT2ModeRegs(unsigned short ModeNo, | |
7699 | struct xgi_hw_device_info *HwDeviceExtension, | |
7700 | struct vb_device_info *pVBInfo) | |
d7636e0b | 7701 | { |
cc1e2398 AK |
7702 | unsigned short tempbl; |
7703 | short tempcl; | |
21df8fc8 | 7704 | |
cc1e2398 | 7705 | unsigned char tempah; |
21df8fc8 | 7706 | |
1d7f656d KT |
7707 | /* // fix write part1 index 0 BTDRAM bit Bug |
7708 | * xgifb_reg_set(pVBInfo->Part1Port, 0x03, 0x00); */ | |
cc1e2398 AK |
7709 | tempah = 0; |
7710 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { | |
58839b01 | 7711 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00); |
cc1e2398 AK |
7712 | tempah &= ~0x10; /* BTRAMDAC */ |
7713 | tempah |= 0x40; /* BTRAM */ | |
21df8fc8 | 7714 | |
cc1e2398 AK |
7715 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV |
7716 | | SetCRT2ToLCD)) { | |
7717 | tempah = 0x40; /* BTDRAM */ | |
7718 | if (ModeNo > 0x13) { | |
7719 | tempcl = pVBInfo->ModeType; | |
7720 | tempcl -= ModeVGA; | |
7721 | if (tempcl >= 0) { | |
1d7f656d KT |
7722 | /* BT Color */ |
7723 | tempah = (0x008 >> tempcl); | |
cc1e2398 AK |
7724 | if (tempah == 0) |
7725 | tempah = 1; | |
7726 | tempah |= 0x040; | |
7727 | } | |
7728 | } | |
7729 | if (pVBInfo->VBInfo & SetInSlaveMode) | |
7730 | tempah ^= 0x50; /* BTDAC */ | |
7731 | } | |
7732 | } | |
21df8fc8 | 7733 | |
cc1e2398 AK |
7734 | /* 0210 shampoo |
7735 | if (pVBInfo->VBInfo & DisableCRT2Display) { | |
7736 | tempah = 0; | |
7737 | } | |
21df8fc8 | 7738 | |
8104e329 | 7739 | xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah); |
cc1e2398 AK |
7740 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD)) { |
7741 | tempcl = pVBInfo->ModeType; | |
7742 | if (ModeNo > 0x13) { | |
7743 | tempcl -= ModeVGA; | |
7744 | if ((tempcl > 0) || (tempcl == 0)) { | |
7745 | tempah=(0x008>>tempcl) ; | |
7746 | if (tempah == 0) | |
7747 | tempah = 1; | |
7748 | tempah |= 0x040; | |
21df8fc8 | 7749 | } |
cc1e2398 AK |
7750 | } else { |
7751 | tempah = 0x040; | |
7752 | } | |
21df8fc8 | 7753 | |
cc1e2398 AK |
7754 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
7755 | tempah = (tempah ^ 0x050); | |
7756 | } | |
7757 | } | |
7758 | */ | |
21df8fc8 | 7759 | |
8104e329 | 7760 | xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah); |
cc1e2398 AK |
7761 | tempah = 0x08; |
7762 | tempbl = 0xf0; | |
7763 | ||
7764 | if (pVBInfo->VBInfo & DisableCRT2Display) { | |
ec9e5d3e | 7765 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl, tempah); |
cc1e2398 AK |
7766 | } else { |
7767 | tempah = 0x00; | |
7768 | tempbl = 0xff; | |
7769 | ||
7770 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | |
7771 | | SetCRT2ToLCD | SetCRT2ToLCDA)) { | |
1d7f656d KT |
7772 | if ((pVBInfo->VBInfo & SetCRT2ToLCDA) && |
7773 | (!(pVBInfo->VBInfo & SetSimuScanMode))) { | |
cc1e2398 AK |
7774 | tempbl &= 0xf7; |
7775 | tempah |= 0x01; | |
ec9e5d3e | 7776 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, |
cc1e2398 AK |
7777 | tempbl, tempah); |
7778 | } else { | |
7779 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { | |
7780 | tempbl &= 0xf7; | |
7781 | tempah |= 0x01; | |
7782 | } | |
7783 | ||
1d7f656d KT |
7784 | if (pVBInfo->VBInfo & |
7785 | (SetCRT2ToRAMDAC | | |
7786 | SetCRT2ToTV | | |
7787 | SetCRT2ToLCD)) { | |
cc1e2398 AK |
7788 | tempbl &= 0xf8; |
7789 | tempah = 0x01; | |
7790 | ||
7791 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) | |
7792 | tempah |= 0x02; | |
7793 | ||
1d7f656d KT |
7794 | if (!(pVBInfo->VBInfo & |
7795 | SetCRT2ToRAMDAC)) { | |
cc1e2398 | 7796 | tempah = tempah ^ 0x05; |
1d7f656d KT |
7797 | if (!(pVBInfo->VBInfo & |
7798 | SetCRT2ToLCD)) | |
cc1e2398 AK |
7799 | tempah = tempah ^ 0x01; |
7800 | } | |
21df8fc8 | 7801 | |
1d7f656d KT |
7802 | if (!(pVBInfo->VBInfo & |
7803 | SetCRT2ToDualEdge)) | |
cc1e2398 | 7804 | tempah |= 0x08; |
ec9e5d3e | 7805 | xgifb_reg_and_or(pVBInfo->Part1Port, |
cc1e2398 AK |
7806 | 0x2e, tempbl, tempah); |
7807 | } else { | |
ec9e5d3e | 7808 | xgifb_reg_and_or(pVBInfo->Part1Port, |
cc1e2398 AK |
7809 | 0x2e, tempbl, tempah); |
7810 | } | |
21df8fc8 | 7811 | } |
cc1e2398 | 7812 | } else { |
ec9e5d3e | 7813 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl, |
21df8fc8 PS |
7814 | tempah); |
7815 | } | |
7816 | } | |
d7636e0b | 7817 | |
cc1e2398 AK |
7818 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD |
7819 | | SetCRT2ToLCDA)) { | |
7820 | tempah &= (~0x08); | |
7821 | if ((pVBInfo->ModeType == ModeVGA) && (!(pVBInfo->VBInfo | |
7822 | & SetInSlaveMode))) { | |
7823 | tempah |= 0x010; | |
7824 | } | |
7825 | tempah |= 0x080; | |
21df8fc8 | 7826 | |
cc1e2398 | 7827 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
1d7f656d KT |
7828 | /* if (!(pVBInfo->TVInfo & |
7829 | (SetYPbPrMode525p | SetYPbPrMode750p))) { */ | |
cc1e2398 AK |
7830 | tempah |= 0x020; |
7831 | if (ModeNo > 0x13) { | |
7832 | if (pVBInfo->VBInfo & DriverMode) | |
7833 | tempah = tempah ^ 0x20; | |
7834 | } | |
7835 | /* } */ | |
7836 | } | |
21df8fc8 | 7837 | |
ec9e5d3e | 7838 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D, ~0x0BF, tempah); |
cc1e2398 AK |
7839 | tempah = 0; |
7840 | ||
7841 | if (pVBInfo->LCDInfo & SetLCDDualLink) | |
7842 | tempah |= 0x40; | |
7843 | ||
7844 | if (pVBInfo->VBInfo & SetCRT2ToTV) { | |
1d7f656d KT |
7845 | /* if ((!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)) && |
7846 | (!(pVBInfo->TVInfo & | |
7847 | (SetYPbPrMode525p | SetYPbPrMode750p)))) { */ | |
cc1e2398 AK |
7848 | if (pVBInfo->TVInfo & RPLLDIV2XO) |
7849 | tempah |= 0x40; | |
7850 | /* } */ | |
21df8fc8 | 7851 | } |
cc1e2398 AK |
7852 | |
7853 | if ((pVBInfo->LCDResInfo == Panel1280x1024) | |
7854 | || (pVBInfo->LCDResInfo == Panel1280x1024x75)) | |
7855 | tempah |= 0x80; | |
7856 | ||
7857 | if (pVBInfo->LCDResInfo == Panel1280x960) | |
7858 | tempah |= 0x80; | |
7859 | ||
8104e329 | 7860 | xgifb_reg_set(pVBInfo->Part4Port, 0x0C, tempah); |
d7636e0b | 7861 | } |
d7636e0b | 7862 | |
21df8fc8 PS |
7863 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
7864 | | VB_XGI302LV | VB_XGI301C)) { | |
cc1e2398 AK |
7865 | tempah = 0; |
7866 | tempbl = 0xfb; | |
21df8fc8 | 7867 | |
cc1e2398 AK |
7868 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { |
7869 | tempbl = 0xff; | |
7870 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) | |
7871 | tempah |= 0x04; /* shampoo 0129 */ | |
21df8fc8 | 7872 | } |
d7636e0b | 7873 | |
ec9e5d3e | 7874 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x13, tempbl, tempah); |
cc1e2398 AK |
7875 | tempah = 0x00; |
7876 | tempbl = 0xcf; | |
7877 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { | |
7878 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) | |
7879 | tempah |= 0x30; | |
7880 | } | |
d7636e0b | 7881 | |
ec9e5d3e | 7882 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2c, tempbl, tempah); |
cc1e2398 AK |
7883 | tempah = 0; |
7884 | tempbl = 0x3f; | |
d7636e0b | 7885 | |
cc1e2398 AK |
7886 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
7887 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) | |
7888 | tempah |= 0xc0; | |
7889 | } | |
ec9e5d3e | 7890 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, tempbl, tempah); |
21df8fc8 | 7891 | } |
d7636e0b | 7892 | |
cc1e2398 AK |
7893 | tempah = 0; |
7894 | tempbl = 0x7f; | |
7895 | if (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) { | |
7896 | tempbl = 0xff; | |
7897 | if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge)) | |
7898 | tempah |= 0x80; | |
21df8fc8 | 7899 | } |
d7636e0b | 7900 | |
ec9e5d3e | 7901 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x23, tempbl, tempah); |
d7636e0b | 7902 | |
cc1e2398 AK |
7903 | if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) { |
7904 | if (pVBInfo->LCDInfo & SetLCDDualLink) { | |
b9bf6e4e AK |
7905 | xgifb_reg_or(pVBInfo->Part4Port, 0x27, 0x20); |
7906 | xgifb_reg_or(pVBInfo->Part4Port, 0x34, 0x10); | |
cc1e2398 AK |
7907 | } |
7908 | } | |
d7636e0b | 7909 | } |
7910 | ||
cc1e2398 | 7911 | static void XGI_CloseCRTC(struct xgi_hw_device_info *HwDeviceExtension, |
21df8fc8 | 7912 | struct vb_device_info *pVBInfo) |
d7636e0b | 7913 | { |
cc1e2398 | 7914 | unsigned short tempbx; |
d7636e0b | 7915 | |
cc1e2398 | 7916 | tempbx = 0; |
d7636e0b | 7917 | |
cc1e2398 AK |
7918 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) |
7919 | tempbx = 0x08A0; | |
d7636e0b | 7920 | |
d7636e0b | 7921 | } |
7922 | ||
cc1e2398 AK |
7923 | void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension, |
7924 | struct vb_device_info *pVBInfo) | |
d7636e0b | 7925 | { |
d7636e0b | 7926 | |
ec9e5d3e | 7927 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2f, 0xFF, 0x01); |
cc1e2398 | 7928 | |
d7636e0b | 7929 | } |
7930 | ||
cc1e2398 | 7931 | void XGI_LockCRT2(struct xgi_hw_device_info *HwDeviceExtension, |
21df8fc8 PS |
7932 | struct vb_device_info *pVBInfo) |
7933 | { | |
21df8fc8 | 7934 | |
ec9e5d3e | 7935 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2F, 0xFE, 0x00); |
21df8fc8 | 7936 | |
cc1e2398 | 7937 | } |
21df8fc8 | 7938 | |
cc1e2398 AK |
7939 | unsigned char XGI_BridgeIsOn(struct vb_device_info *pVBInfo) |
7940 | { | |
7941 | unsigned short flag; | |
21df8fc8 | 7942 | |
cc1e2398 AK |
7943 | if (pVBInfo->IF_DEF_LVDS == 1) { |
7944 | return 1; | |
7945 | } else { | |
58839b01 | 7946 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00); |
cc1e2398 AK |
7947 | if ((flag == 1) || (flag == 2)) |
7948 | return 1; /* 301b */ | |
7949 | else | |
7950 | return 0; | |
7951 | } | |
7952 | } | |
21df8fc8 | 7953 | |
cc1e2398 AK |
7954 | void XGI_LongWait(struct vb_device_info *pVBInfo) |
7955 | { | |
7956 | unsigned short i; | |
21df8fc8 | 7957 | |
58839b01 | 7958 | i = xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
21df8fc8 | 7959 | |
cc1e2398 AK |
7960 | if (!(i & 0xC0)) { |
7961 | for (i = 0; i < 0xFFFF; i++) { | |
d8ad0a6d | 7962 | if (!(inb(pVBInfo->P3da) & 0x08)) |
cc1e2398 AK |
7963 | break; |
7964 | } | |
21df8fc8 | 7965 | |
cc1e2398 | 7966 | for (i = 0; i < 0xFFFF; i++) { |
d8ad0a6d | 7967 | if ((inb(pVBInfo->P3da) & 0x08)) |
cc1e2398 AK |
7968 | break; |
7969 | } | |
7970 | } | |
7971 | } | |
21df8fc8 | 7972 | |
cc1e2398 AK |
7973 | static void XGI_VBLongWait(struct vb_device_info *pVBInfo) |
7974 | { | |
7975 | unsigned short tempal, temp, i, j; | |
7976 | return; | |
7977 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) { | |
7978 | temp = 0; | |
7979 | for (i = 0; i < 3; i++) { | |
7980 | for (j = 0; j < 100; j++) { | |
d8ad0a6d | 7981 | tempal = inb(pVBInfo->P3da); |
cc1e2398 AK |
7982 | if (temp & 0x01) { /* VBWaitMode2 */ |
7983 | if ((tempal & 0x08)) | |
7984 | continue; | |
21df8fc8 | 7985 | |
cc1e2398 AK |
7986 | if (!(tempal & 0x08)) |
7987 | break; | |
d7636e0b | 7988 | |
cc1e2398 AK |
7989 | } else { /* VBWaitMode1 */ |
7990 | if (!(tempal & 0x08)) | |
7991 | continue; | |
7992 | ||
7993 | if ((tempal & 0x08)) | |
7994 | break; | |
7995 | } | |
7996 | } | |
7997 | temp = temp ^ 0x01; | |
7998 | } | |
7999 | } else { | |
8000 | XGI_LongWait(pVBInfo); | |
21df8fc8 | 8001 | } |
cc1e2398 AK |
8002 | return; |
8003 | } | |
21df8fc8 | 8004 | |
cc1e2398 AK |
8005 | unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE, |
8006 | unsigned short ModeNo, unsigned short ModeIdIndex, | |
8007 | struct vb_device_info *pVBInfo) | |
8008 | { | |
8009 | short LCDRefreshIndex[] = { 0x00, 0x00, 0x03, 0x01 }, | |
8010 | LCDARefreshIndex[] = { 0x00, 0x00, 0x03, 0x01, 0x01, | |
8011 | 0x01, 0x01 }; | |
21df8fc8 | 8012 | |
cc1e2398 AK |
8013 | unsigned short RefreshRateTableIndex, i, modeflag, index, temp; |
8014 | ||
8015 | if (ModeNo <= 0x13) | |
8016 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
21df8fc8 | 8017 | else |
cc1e2398 | 8018 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
21df8fc8 | 8019 | |
cc1e2398 AK |
8020 | if (pVBInfo->IF_DEF_CH7005 == 1) { |
8021 | if (pVBInfo->VBInfo & SetCRT2ToTV) { | |
8022 | if (modeflag & HalfDCLK) | |
8023 | return 0; | |
8024 | } | |
21df8fc8 PS |
8025 | } |
8026 | ||
cc1e2398 AK |
8027 | if (ModeNo < 0x14) |
8028 | return 0xFFFF; | |
d7636e0b | 8029 | |
58839b01 | 8030 | index = xgifb_reg_get(pVBInfo->P3d4, 0x33); |
cc1e2398 AK |
8031 | index = index >> pVBInfo->SelectCRT2Rate; |
8032 | index &= 0x0F; | |
d7636e0b | 8033 | |
cc1e2398 AK |
8034 | if (pVBInfo->LCDInfo & LCDNonExpanding) |
8035 | index = 0; | |
d7636e0b | 8036 | |
cc1e2398 AK |
8037 | if (index > 0) |
8038 | index--; | |
d7636e0b | 8039 | |
cc1e2398 AK |
8040 | if (pVBInfo->SetFlag & ProgrammingCRT2) { |
8041 | if (pVBInfo->IF_DEF_CH7005 == 1) { | |
8042 | if (pVBInfo->VBInfo & SetCRT2ToTV) | |
8043 | index = 0; | |
8044 | } | |
d7636e0b | 8045 | |
cc1e2398 AK |
8046 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
8047 | if (pVBInfo->IF_DEF_LVDS == 0) { | |
8048 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | |
8049 | | VB_XGI301LV | VB_XGI302LV | |
8050 | | VB_XGI301C)) | |
1d7f656d KT |
8051 | /* 301b */ |
8052 | temp = LCDARefreshIndex[ | |
8053 | pVBInfo->LCDResInfo & 0x0F]; | |
cc1e2398 | 8054 | else |
1d7f656d KT |
8055 | temp = LCDRefreshIndex[ |
8056 | pVBInfo->LCDResInfo & 0x0F]; | |
cc1e2398 AK |
8057 | |
8058 | if (index > temp) | |
8059 | index = temp; | |
8060 | } else { | |
8061 | index = 0; | |
8062 | } | |
8063 | } | |
21df8fc8 | 8064 | } |
d7636e0b | 8065 | |
cc1e2398 AK |
8066 | RefreshRateTableIndex = pVBInfo->EModeIDTable[ModeIdIndex].REFindex; |
8067 | ModeNo = pVBInfo->RefIndex[RefreshRateTableIndex].ModeID; | |
8068 | if (pXGIHWDE->jChipType >= XG20) { /* for XG20, XG21, XG27 */ | |
8069 | /* | |
1d7f656d KT |
8070 | if (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag & |
8071 | XG2xNotSupport) { | |
cc1e2398 AK |
8072 | index++; |
8073 | } | |
8074 | */ | |
1d7f656d KT |
8075 | if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 800) && |
8076 | (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 600)) { | |
cc1e2398 AK |
8077 | index++; |
8078 | } | |
1d7f656d KT |
8079 | /* Alan 10/19/2007; |
8080 | * do the similar adjustment like XGISearchCRT1Rate() */ | |
8081 | if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1024) && | |
8082 | (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 768)) { | |
cc1e2398 AK |
8083 | index++; |
8084 | } | |
1d7f656d KT |
8085 | if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1280) && |
8086 | (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 1024)) { | |
cc1e2398 AK |
8087 | index++; |
8088 | } | |
8089 | } | |
8090 | ||
8091 | i = 0; | |
8092 | do { | |
1d7f656d KT |
8093 | if (pVBInfo->RefIndex[RefreshRateTableIndex + i]. |
8094 | ModeID != ModeNo) | |
cc1e2398 | 8095 | break; |
1d7f656d KT |
8096 | temp = pVBInfo->RefIndex[RefreshRateTableIndex + i]. |
8097 | Ext_InfoFlag; | |
cc1e2398 AK |
8098 | temp &= ModeInfoFlag; |
8099 | if (temp < pVBInfo->ModeType) | |
8100 | break; | |
8101 | i++; | |
8102 | index--; | |
8103 | ||
8104 | } while (index != 0xFFFF); | |
8105 | if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) { | |
8106 | if (pVBInfo->VBInfo & SetInSlaveMode) { | |
1d7f656d KT |
8107 | temp = pVBInfo->RefIndex[RefreshRateTableIndex + i - 1]. |
8108 | Ext_InfoFlag; | |
cc1e2398 AK |
8109 | if (temp & InterlaceMode) |
8110 | i++; | |
21df8fc8 PS |
8111 | } |
8112 | } | |
cc1e2398 AK |
8113 | i--; |
8114 | if ((pVBInfo->SetFlag & ProgrammingCRT2)) { | |
8115 | temp = XGI_AjustCRT2Rate(ModeNo, ModeIdIndex, | |
8116 | RefreshRateTableIndex, &i, pVBInfo); | |
8117 | } | |
8118 | return RefreshRateTableIndex + i; /* return (0x01 | (temp1<<1)); */ | |
8119 | } | |
d7636e0b | 8120 | |
cc1e2398 AK |
8121 | static void XGI_SetLCDAGroup(unsigned short ModeNo, unsigned short ModeIdIndex, |
8122 | struct xgi_hw_device_info *HwDeviceExtension, | |
8123 | struct vb_device_info *pVBInfo) | |
8124 | { | |
8125 | unsigned short RefreshRateTableIndex; | |
8126 | /* unsigned short temp ; */ | |
8127 | ||
8128 | /* pVBInfo->SelectCRT2Rate = 0; */ | |
8129 | ||
8130 | pVBInfo->SetFlag |= ProgrammingCRT2; | |
8131 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, | |
8132 | ModeIdIndex, pVBInfo); | |
8133 | XGI_GetLVDSResInfo(ModeNo, ModeIdIndex, pVBInfo); | |
8134 | XGI_GetLVDSData(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); | |
8135 | XGI_ModCRT1Regs(ModeNo, ModeIdIndex, RefreshRateTableIndex, | |
8136 | HwDeviceExtension, pVBInfo); | |
8137 | XGI_SetLVDSRegs(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); | |
8138 | XGI_SetCRT2ECLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); | |
d7636e0b | 8139 | } |
8140 | ||
cc1e2398 | 8141 | unsigned char XGI_SetCRT2Group301(unsigned short ModeNo, |
21df8fc8 PS |
8142 | struct xgi_hw_device_info *HwDeviceExtension, |
8143 | struct vb_device_info *pVBInfo) | |
8144 | { | |
cc1e2398 | 8145 | unsigned short tempbx, ModeIdIndex, RefreshRateTableIndex; |
21df8fc8 | 8146 | |
cc1e2398 AK |
8147 | tempbx = pVBInfo->VBInfo; |
8148 | pVBInfo->SetFlag |= ProgrammingCRT2; | |
8149 | XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo); | |
8150 | pVBInfo->SelectCRT2Rate = 4; | |
8151 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, | |
8152 | ModeIdIndex, pVBInfo); | |
8153 | XGI_SaveCRT2Info(ModeNo, pVBInfo); | |
8154 | XGI_GetCRT2ResInfo(ModeNo, ModeIdIndex, pVBInfo); | |
8155 | XGI_GetCRT2Data(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); | |
8156 | XGI_PreSetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension, | |
8157 | RefreshRateTableIndex, pVBInfo); | |
8158 | XGI_SetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension, | |
8159 | RefreshRateTableIndex, pVBInfo); | |
8160 | XGI_SetLockRegs(ModeNo, ModeIdIndex, HwDeviceExtension, | |
8161 | RefreshRateTableIndex, pVBInfo); | |
8162 | XGI_SetGroup2(ModeNo, ModeIdIndex, RefreshRateTableIndex, | |
8163 | HwDeviceExtension, pVBInfo); | |
8164 | XGI_SetLCDRegs(ModeNo, ModeIdIndex, HwDeviceExtension, | |
8165 | RefreshRateTableIndex, pVBInfo); | |
8166 | XGI_SetTap4Regs(pVBInfo); | |
8167 | XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo); | |
8168 | XGI_SetGroup4(ModeNo, ModeIdIndex, RefreshRateTableIndex, | |
8169 | HwDeviceExtension, pVBInfo); | |
8170 | XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); | |
8171 | XGI_SetGroup5(ModeNo, ModeIdIndex, pVBInfo); | |
8172 | XGI_AutoThreshold(pVBInfo); | |
8173 | return 1; | |
8174 | } | |
21df8fc8 | 8175 | |
cc1e2398 AK |
8176 | void XGI_SenseCRT1(struct vb_device_info *pVBInfo) |
8177 | { | |
8178 | unsigned char CRTCData[17] = { 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, | |
8179 | 0x0B, 0x3E, 0xE9, 0x0B, 0xDF, 0xE7, 0x04, 0x00, 0x00, | |
8180 | 0x05, 0x00 }; | |
21df8fc8 | 8181 | |
cc1e2398 | 8182 | unsigned char SR01 = 0, SR1F = 0, SR07 = 0, SR06 = 0; |
d7636e0b | 8183 | |
cc1e2398 AK |
8184 | unsigned char CR17, CR63, SR31; |
8185 | unsigned short temp; | |
8186 | unsigned char DAC_TEST_PARMS[3] = { 0x0F, 0x0F, 0x0F }; | |
d7636e0b | 8187 | |
cc1e2398 | 8188 | int i; |
8104e329 | 8189 | xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86); |
21df8fc8 | 8190 | |
cc1e2398 | 8191 | /* [2004/05/06] Vicent to fix XG42 single LCD sense to CRT+LCD */ |
8104e329 | 8192 | xgifb_reg_set(pVBInfo->P3d4, 0x57, 0x4A); |
58839b01 | 8193 | xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get( |
cc1e2398 | 8194 | pVBInfo->P3d4, 0x53) | 0x02)); |
21df8fc8 | 8195 | |
58839b01 AK |
8196 | SR31 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x31); |
8197 | CR63 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x63); | |
8198 | SR01 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x01); | |
21df8fc8 | 8199 | |
8104e329 AK |
8200 | xgifb_reg_set(pVBInfo->P3c4, 0x01, (unsigned char) (SR01 & 0xDF)); |
8201 | xgifb_reg_set(pVBInfo->P3d4, 0x63, (unsigned char) (CR63 & 0xBF)); | |
21df8fc8 | 8202 | |
58839b01 | 8203 | CR17 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x17); |
8104e329 | 8204 | xgifb_reg_set(pVBInfo->P3d4, 0x17, (unsigned char) (CR17 | 0x80)); |
21df8fc8 | 8205 | |
58839b01 | 8206 | SR1F = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
8104e329 | 8207 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) (SR1F | 0x04)); |
21df8fc8 | 8208 | |
58839b01 | 8209 | SR07 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x07); |
8104e329 | 8210 | xgifb_reg_set(pVBInfo->P3c4, 0x07, (unsigned char) (SR07 & 0xFB)); |
58839b01 | 8211 | SR06 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x06); |
8104e329 | 8212 | xgifb_reg_set(pVBInfo->P3c4, 0x06, (unsigned char) (SR06 & 0xC3)); |
21df8fc8 | 8213 | |
8104e329 | 8214 | xgifb_reg_set(pVBInfo->P3d4, 0x11, 0x00); |
21df8fc8 | 8215 | |
cc1e2398 | 8216 | for (i = 0; i < 8; i++) |
8104e329 | 8217 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) i, CRTCData[i]); |
d7636e0b | 8218 | |
cc1e2398 | 8219 | for (i = 8; i < 11; i++) |
8104e329 | 8220 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 8), |
cc1e2398 | 8221 | CRTCData[i]); |
21df8fc8 | 8222 | |
cc1e2398 | 8223 | for (i = 11; i < 13; i++) |
8104e329 | 8224 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 4), |
cc1e2398 | 8225 | CRTCData[i]); |
21df8fc8 | 8226 | |
cc1e2398 | 8227 | for (i = 13; i < 16; i++) |
8104e329 | 8228 | xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i - 3), |
cc1e2398 | 8229 | CRTCData[i]); |
21df8fc8 | 8230 | |
8104e329 | 8231 | xgifb_reg_set(pVBInfo->P3c4, 0x0E, (unsigned char) (CRTCData[16] |
cc1e2398 | 8232 | & 0xE0)); |
21df8fc8 | 8233 | |
8104e329 AK |
8234 | xgifb_reg_set(pVBInfo->P3c4, 0x31, 0x00); |
8235 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x1B); | |
8236 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE1); | |
21df8fc8 | 8237 | |
efdf4ee7 | 8238 | outb(0x00, pVBInfo->P3c8); |
cc1e2398 AK |
8239 | |
8240 | for (i = 0; i < 256; i++) { | |
efdf4ee7 AK |
8241 | outb((unsigned char) DAC_TEST_PARMS[0], (pVBInfo->P3c8 + 1)); |
8242 | outb((unsigned char) DAC_TEST_PARMS[1], (pVBInfo->P3c8 + 1)); | |
8243 | outb((unsigned char) DAC_TEST_PARMS[2], (pVBInfo->P3c8 + 1)); | |
cc1e2398 AK |
8244 | } |
8245 | ||
8246 | XGI_VBLongWait(pVBInfo); | |
8247 | XGI_VBLongWait(pVBInfo); | |
8248 | XGI_VBLongWait(pVBInfo); | |
8249 | ||
8250 | mdelay(1); | |
8251 | ||
8252 | XGI_WaitDisply(pVBInfo); | |
d8ad0a6d | 8253 | temp = inb(pVBInfo->P3c2); |
cc1e2398 AK |
8254 | |
8255 | if (temp & 0x10) | |
ec9e5d3e | 8256 | xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x20); |
cc1e2398 | 8257 | else |
ec9e5d3e | 8258 | xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x00); |
21df8fc8 | 8259 | |
cc1e2398 | 8260 | /* alan, avoid display something, set BLACK DAC if not restore DAC */ |
efdf4ee7 | 8261 | outb(0x00, pVBInfo->P3c8); |
21df8fc8 | 8262 | |
cc1e2398 | 8263 | for (i = 0; i < 256; i++) { |
efdf4ee7 AK |
8264 | outb(0, (pVBInfo->P3c8 + 1)); |
8265 | outb(0, (pVBInfo->P3c8 + 1)); | |
8266 | outb(0, (pVBInfo->P3c8 + 1)); | |
21df8fc8 | 8267 | } |
d7636e0b | 8268 | |
8104e329 AK |
8269 | xgifb_reg_set(pVBInfo->P3c4, 0x01, SR01); |
8270 | xgifb_reg_set(pVBInfo->P3d4, 0x63, CR63); | |
8271 | xgifb_reg_set(pVBInfo->P3c4, 0x31, SR31); | |
21df8fc8 | 8272 | |
cc1e2398 | 8273 | /* [2004/05/11] Vicent */ |
58839b01 | 8274 | xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get( |
cc1e2398 | 8275 | pVBInfo->P3d4, 0x53) & 0xFD)); |
8104e329 | 8276 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) SR1F); |
cc1e2398 | 8277 | } |
21df8fc8 | 8278 | |
cc1e2398 AK |
8279 | void XGI_EnableBridge(struct xgi_hw_device_info *HwDeviceExtension, |
8280 | struct vb_device_info *pVBInfo) | |
8281 | { | |
fd0ad470 | 8282 | unsigned short tempah; |
21df8fc8 | 8283 | |
cc1e2398 AK |
8284 | if (pVBInfo->SetFlag == Win9xDOSMode) { |
8285 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | |
8286 | | VB_XGI302LV | VB_XGI301C)) { | |
8287 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); | |
8288 | return; | |
8289 | } else | |
8290 | /* LVDS or CH7017 */ | |
8291 | return; | |
21df8fc8 | 8292 | } |
d7636e0b | 8293 | |
cc1e2398 AK |
8294 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
8295 | | VB_XGI302LV | VB_XGI301C)) { | |
8296 | if (!(pVBInfo->SetFlag & DisableChA)) { | |
8297 | if (pVBInfo->SetFlag & EnableChA) { | |
1d7f656d KT |
8298 | /* Power on */ |
8299 | xgifb_reg_set(pVBInfo->Part1Port, 0x1E, 0x20); | |
cc1e2398 | 8300 | } else { |
1d7f656d KT |
8301 | /* SetCRT2ToLCDA ) */ |
8302 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { | |
8303 | /* Power on */ | |
8104e329 | 8304 | xgifb_reg_set(pVBInfo->Part1Port, |
1d7f656d | 8305 | 0x1E, 0x20); |
cc1e2398 AK |
8306 | } |
8307 | } | |
21df8fc8 | 8308 | } |
d7636e0b | 8309 | |
cc1e2398 AK |
8310 | if (!(pVBInfo->SetFlag & DisableChB)) { |
8311 | if ((pVBInfo->SetFlag & EnableChB) || (pVBInfo->VBInfo | |
8312 | & (SetCRT2ToLCD | SetCRT2ToTV | |
8313 | | SetCRT2ToRAMDAC))) { | |
58839b01 | 8314 | tempah = (unsigned char) xgifb_reg_get( |
cc1e2398 AK |
8315 | pVBInfo->P3c4, 0x32); |
8316 | tempah &= 0xDF; | |
8317 | if (pVBInfo->VBInfo & SetInSlaveMode) { | |
1d7f656d KT |
8318 | if (!(pVBInfo->VBInfo & |
8319 | SetCRT2ToRAMDAC)) | |
cc1e2398 AK |
8320 | tempah |= 0x20; |
8321 | } | |
8104e329 | 8322 | xgifb_reg_set(pVBInfo->P3c4, 0x32, tempah); |
b9bf6e4e | 8323 | xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x20); |
d7636e0b | 8324 | |
58839b01 | 8325 | tempah = (unsigned char) xgifb_reg_get( |
cc1e2398 | 8326 | pVBInfo->Part1Port, 0x2E); |
d7636e0b | 8327 | |
cc1e2398 | 8328 | if (!(tempah & 0x80)) |
1d7f656d | 8329 | /* BVBDOENABLE = 1 */ |
b9bf6e4e | 8330 | xgifb_reg_or(pVBInfo->Part1Port, |
1d7f656d KT |
8331 | 0x2E, 0x80); |
8332 | /* BScreenOFF = 0 */ | |
8333 | xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F); | |
cc1e2398 AK |
8334 | } |
8335 | } | |
d7636e0b | 8336 | |
cc1e2398 AK |
8337 | if ((pVBInfo->SetFlag & (EnableChA | EnableChB)) |
8338 | || (!(pVBInfo->VBInfo & DisableCRT2Display))) { | |
ec9e5d3e | 8339 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x00, ~0xE0, |
cc1e2398 AK |
8340 | 0x20); /* shampoo 0129 */ |
8341 | if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) { | |
8342 | if (!XGI_DisableChISLCD(pVBInfo)) { | |
1d7f656d KT |
8343 | if (XGI_EnableChISLCD(pVBInfo) || |
8344 | (pVBInfo->VBInfo & | |
8345 | (SetCRT2ToLCD | SetCRT2ToLCDA))) | |
8346 | /* LVDS PLL power on */ | |
dc50556b | 8347 | xgifb_reg_and( |
1d7f656d KT |
8348 | pVBInfo->Part4Port, |
8349 | 0x2A, | |
8350 | 0x7F); | |
cc1e2398 | 8351 | } |
1d7f656d KT |
8352 | /* LVDS Driver power on */ |
8353 | xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x7F); | |
cc1e2398 AK |
8354 | } |
8355 | } | |
d7636e0b | 8356 | |
cc1e2398 | 8357 | tempah = 0x00; |
d7636e0b | 8358 | |
cc1e2398 AK |
8359 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
8360 | tempah = 0xc0; | |
d7636e0b | 8361 | |
cc1e2398 AK |
8362 | if (!(pVBInfo->VBInfo & SetSimuScanMode)) { |
8363 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { | |
1d7f656d KT |
8364 | if (pVBInfo->VBInfo & |
8365 | SetCRT2ToDualEdge) { | |
cc1e2398 | 8366 | tempah = tempah & 0x40; |
1d7f656d KT |
8367 | if (pVBInfo->VBInfo & |
8368 | SetCRT2ToLCDA) | |
cc1e2398 | 8369 | tempah = tempah ^ 0xC0; |
d7636e0b | 8370 | |
1d7f656d KT |
8371 | if (pVBInfo->SetFlag & |
8372 | DisableChB) | |
cc1e2398 | 8373 | tempah &= 0xBF; |
d7636e0b | 8374 | |
1d7f656d KT |
8375 | if (pVBInfo->SetFlag & |
8376 | DisableChA) | |
cc1e2398 | 8377 | tempah &= 0x7F; |
d7636e0b | 8378 | |
1d7f656d KT |
8379 | if (pVBInfo->SetFlag & |
8380 | EnableChB) | |
cc1e2398 | 8381 | tempah |= 0x40; |
d7636e0b | 8382 | |
1d7f656d KT |
8383 | if (pVBInfo->SetFlag & |
8384 | EnableChA) | |
cc1e2398 AK |
8385 | tempah |= 0x80; |
8386 | } | |
8387 | } | |
8388 | } | |
8389 | } | |
d7636e0b | 8390 | |
1d7f656d KT |
8391 | /* EnablePart4_1F */ |
8392 | xgifb_reg_or(pVBInfo->Part4Port, 0x1F, tempah); | |
d7636e0b | 8393 | |
cc1e2398 AK |
8394 | if (pVBInfo->SetFlag & Win9xDOSMode) { |
8395 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); | |
8396 | return; | |
8397 | } | |
8398 | ||
8399 | if (!(pVBInfo->SetFlag & DisableChA)) { | |
8400 | XGI_VBLongWait(pVBInfo); | |
8401 | if (!(pVBInfo->SetFlag & GatingCRT)) { | |
1d7f656d KT |
8402 | XGI_DisableGatingCRT(HwDeviceExtension, |
8403 | pVBInfo); | |
cc1e2398 AK |
8404 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); |
8405 | XGI_VBLongWait(pVBInfo); | |
8406 | } | |
8407 | } | |
8408 | } /* 301 */ | |
8409 | else { /* LVDS */ | |
8410 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD | |
8411 | | SetCRT2ToLCDA)) | |
1d7f656d KT |
8412 | /* enable CRT2 */ |
8413 | xgifb_reg_or(pVBInfo->Part1Port, 0x1E, 0x20); | |
d7636e0b | 8414 | |
58839b01 | 8415 | tempah = (unsigned char) xgifb_reg_get(pVBInfo->Part1Port, |
cc1e2398 AK |
8416 | 0x2E); |
8417 | if (!(tempah & 0x80)) | |
1d7f656d KT |
8418 | /* BVBDOENABLE = 1 */ |
8419 | xgifb_reg_or(pVBInfo->Part1Port, 0x2E, 0x80); | |
d7636e0b | 8420 | |
dc50556b | 8421 | xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F); |
cc1e2398 AK |
8422 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); |
8423 | } /* End of VB */ | |
d7636e0b | 8424 | } |
8425 | ||
cc1e2398 AK |
8426 | static void XGI_SetCRT1Group(struct xgi_hw_device_info *HwDeviceExtension, |
8427 | unsigned short ModeNo, unsigned short ModeIdIndex, | |
21df8fc8 | 8428 | struct vb_device_info *pVBInfo) |
d7636e0b | 8429 | { |
cc1e2398 | 8430 | unsigned short StandTableIndex, RefreshRateTableIndex, b3CC, temp; |
d7636e0b | 8431 | |
cc1e2398 | 8432 | unsigned short XGINew_P3cc = pVBInfo->P3cc; |
d7636e0b | 8433 | |
cc1e2398 AK |
8434 | /* XGINew_CRT1Mode = ModeNo; // SaveModeID */ |
8435 | StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo); | |
8436 | /* XGI_SetBIOSData(ModeNo, ModeIdIndex); */ | |
8437 | /* XGI_ClearBankRegs(ModeNo, ModeIdIndex); */ | |
8438 | XGI_SetSeqRegs(ModeNo, StandTableIndex, ModeIdIndex, pVBInfo); | |
8439 | XGI_SetMiscRegs(StandTableIndex, pVBInfo); | |
8440 | XGI_SetCRTCRegs(HwDeviceExtension, StandTableIndex, pVBInfo); | |
8441 | XGI_SetATTRegs(ModeNo, StandTableIndex, ModeIdIndex, pVBInfo); | |
8442 | XGI_SetGRCRegs(StandTableIndex, pVBInfo); | |
8443 | XGI_ClearExt1Regs(pVBInfo); | |
d7636e0b | 8444 | |
cc1e2398 AK |
8445 | /* if (pVBInfo->IF_DEF_ExpLink) */ |
8446 | if (HwDeviceExtension->jChipType == XG27) { | |
8447 | if (pVBInfo->IF_DEF_LVDS == 0) | |
8448 | XGI_SetDefaultVCLK(pVBInfo); | |
21df8fc8 | 8449 | } |
d7636e0b | 8450 | |
cc1e2398 AK |
8451 | temp = ~ProgrammingCRT2; |
8452 | pVBInfo->SetFlag &= temp; | |
8453 | pVBInfo->SelectCRT2Rate = 0; | |
d7636e0b | 8454 | |
cc1e2398 AK |
8455 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
8456 | | VB_XGI302LV | VB_XGI301C)) { | |
8457 | if (pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToLCDA | |
8458 | | SetInSlaveMode)) { | |
8459 | pVBInfo->SetFlag |= ProgrammingCRT2; | |
21df8fc8 | 8460 | } |
cc1e2398 | 8461 | } |
d7636e0b | 8462 | |
cc1e2398 AK |
8463 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, |
8464 | ModeIdIndex, pVBInfo); | |
8465 | if (RefreshRateTableIndex != 0xFFFF) { | |
8466 | XGI_SetSync(RefreshRateTableIndex, pVBInfo); | |
8467 | XGI_SetCRT1CRTC(ModeNo, ModeIdIndex, RefreshRateTableIndex, | |
8468 | pVBInfo, HwDeviceExtension); | |
8469 | XGI_SetCRT1DE(HwDeviceExtension, ModeNo, ModeIdIndex, | |
8470 | RefreshRateTableIndex, pVBInfo); | |
8471 | XGI_SetCRT1Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex, | |
8472 | HwDeviceExtension, pVBInfo); | |
8473 | XGI_SetCRT1VCLK(ModeNo, ModeIdIndex, HwDeviceExtension, | |
8474 | RefreshRateTableIndex, pVBInfo); | |
8475 | } | |
8476 | ||
1d7f656d KT |
8477 | if ((HwDeviceExtension->jChipType >= XG20) && |
8478 | (HwDeviceExtension->jChipType < XG27)) { /* fix H/W DCLK/2 bug */ | |
cc1e2398 | 8479 | if ((ModeNo == 0x00) | (ModeNo == 0x01)) { |
8104e329 AK |
8480 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x4E); |
8481 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE9); | |
d8ad0a6d | 8482 | b3CC = (unsigned char) inb(XGINew_P3cc); |
efdf4ee7 | 8483 | outb((b3CC |= 0x0C), XGINew_P3cc); |
cc1e2398 AK |
8484 | } else if ((ModeNo == 0x04) | (ModeNo == 0x05) | (ModeNo |
8485 | == 0x0D)) { | |
8104e329 AK |
8486 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x1B); |
8487 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE3); | |
d8ad0a6d | 8488 | b3CC = (unsigned char) inb(XGINew_P3cc); |
efdf4ee7 | 8489 | outb((b3CC |= 0x0C), XGINew_P3cc); |
21df8fc8 | 8490 | } |
d7636e0b | 8491 | } |
d7636e0b | 8492 | |
cc1e2398 | 8493 | if (HwDeviceExtension->jChipType >= XG21) { |
58839b01 | 8494 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x38); |
cc1e2398 | 8495 | if (temp & 0xA0) { |
21df8fc8 | 8496 | |
1d7f656d KT |
8497 | /* Enable write GPIOF */ |
8498 | /* xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x20); */ | |
8499 | /* P. DWN */ | |
8500 | /* xgifb_reg_and(pVBInfo->P3d4, 0x48, ~0x20); */ | |
cc1e2398 AK |
8501 | /* XG21 CRT1 Timing */ |
8502 | if (HwDeviceExtension->jChipType == XG27) | |
8503 | XGI_SetXG27CRTC(ModeNo, ModeIdIndex, | |
8504 | RefreshRateTableIndex, pVBInfo); | |
8505 | else | |
8506 | XGI_SetXG21CRTC(ModeNo, ModeIdIndex, | |
8507 | RefreshRateTableIndex, pVBInfo); | |
21df8fc8 | 8508 | |
cc1e2398 AK |
8509 | XGI_UpdateXG21CRTC(ModeNo, pVBInfo, |
8510 | RefreshRateTableIndex); | |
21df8fc8 | 8511 | |
cc1e2398 AK |
8512 | if (HwDeviceExtension->jChipType == XG27) |
8513 | XGI_SetXG27LCD(pVBInfo, RefreshRateTableIndex, | |
8514 | ModeNo); | |
8515 | else | |
8516 | XGI_SetXG21LCD(pVBInfo, RefreshRateTableIndex, | |
8517 | ModeNo); | |
8518 | ||
8519 | if (pVBInfo->IF_DEF_LVDS == 1) { | |
8520 | if (HwDeviceExtension->jChipType == XG27) | |
8521 | XGI_SetXG27LVDSPara(ModeNo, | |
8522 | ModeIdIndex, pVBInfo); | |
8523 | else | |
8524 | XGI_SetXG21LVDSPara(ModeNo, | |
8525 | ModeIdIndex, pVBInfo); | |
21df8fc8 | 8526 | } |
1d7f656d KT |
8527 | /* P. ON */ |
8528 | /* xgifb_reg_or(pVBInfo->P3d4, 0x48, 0x20); */ | |
21df8fc8 | 8529 | } |
21df8fc8 | 8530 | } |
d7636e0b | 8531 | |
cc1e2398 AK |
8532 | pVBInfo->SetFlag &= (~ProgrammingCRT2); |
8533 | XGI_SetCRT1FIFO(ModeNo, HwDeviceExtension, pVBInfo); | |
8534 | XGI_SetCRT1ModeRegs(HwDeviceExtension, ModeNo, ModeIdIndex, | |
8535 | RefreshRateTableIndex, pVBInfo); | |
d7636e0b | 8536 | |
cc1e2398 | 8537 | /* XGI_LoadCharacter(); //dif ifdef TVFont */ |
d7636e0b | 8538 | |
cc1e2398 AK |
8539 | XGI_LoadDAC(ModeNo, ModeIdIndex, pVBInfo); |
8540 | /* XGI_ClearBuffer(HwDeviceExtension, ModeNo, pVBInfo); */ | |
d7636e0b | 8541 | } |
8542 | ||
cc1e2398 AK |
8543 | unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension, |
8544 | unsigned short ModeNo) | |
21df8fc8 | 8545 | { |
cc1e2398 | 8546 | unsigned short ModeIdIndex; |
1d7f656d KT |
8547 | /* unsigned char *pVBInfo->FBAddr = |
8548 | HwDeviceExtension->pjVideoMemoryAddress; */ | |
cc1e2398 AK |
8549 | struct vb_device_info VBINF; |
8550 | struct vb_device_info *pVBInfo = &VBINF; | |
8551 | pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase; | |
8552 | pVBInfo->BaseAddr = (unsigned long) HwDeviceExtension->pjIOAddress; | |
8553 | pVBInfo->IF_DEF_LVDS = 0; | |
8554 | pVBInfo->IF_DEF_CH7005 = 0; | |
8555 | pVBInfo->IF_DEF_LCDA = 1; | |
cc1e2398 AK |
8556 | pVBInfo->IF_DEF_CH7007 = 0; /* [Billy] 2007/05/14 */ |
8557 | pVBInfo->IF_DEF_VideoCapture = 0; | |
8558 | pVBInfo->IF_DEF_ScaleLCD = 0; | |
8559 | pVBInfo->IF_DEF_OEMUtil = 0; | |
8560 | pVBInfo->IF_DEF_PWD = 0; | |
8561 | ||
8562 | if (HwDeviceExtension->jChipType >= XG20) { /* kuku 2004/06/25 */ | |
8563 | pVBInfo->IF_DEF_YPbPr = 0; | |
8564 | pVBInfo->IF_DEF_HiVision = 0; | |
8565 | pVBInfo->IF_DEF_CRT2Monitor = 0; | |
8566 | pVBInfo->VBType = 0; /*set VBType default 0*/ | |
cc1e2398 AK |
8567 | } else { |
8568 | pVBInfo->IF_DEF_YPbPr = 1; | |
8569 | pVBInfo->IF_DEF_HiVision = 1; | |
06587335 | 8570 | pVBInfo->IF_DEF_CRT2Monitor = 1; |
cc1e2398 AK |
8571 | } |
8572 | ||
8573 | pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14; | |
8574 | pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24; | |
8575 | pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10; | |
8576 | pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e; | |
8577 | pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12; | |
8578 | pVBInfo->P3cc = pVBInfo->BaseAddr + 0x1C; | |
8579 | pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a; | |
8580 | pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16; | |
8581 | pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17; | |
8582 | pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18; | |
8583 | pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19; | |
8584 | pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A; | |
8585 | pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00; | |
8586 | pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04; | |
8587 | pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10; | |
8588 | pVBInfo->Part3Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_12; | |
8589 | pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14; | |
8590 | pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2; | |
21df8fc8 | 8591 | |
1d7f656d KT |
8592 | /* for x86 Linux, XG21 LVDS */ |
8593 | if (HwDeviceExtension->jChipType == XG21) { | |
58839b01 | 8594 | if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) |
cc1e2398 AK |
8595 | pVBInfo->IF_DEF_LVDS = 1; |
8596 | } | |
8597 | if (HwDeviceExtension->jChipType == XG27) { | |
58839b01 AK |
8598 | if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) { |
8599 | if (xgifb_reg_get(pVBInfo->P3d4, 0x30) & 0x20) | |
cc1e2398 AK |
8600 | pVBInfo->IF_DEF_LVDS = 1; |
8601 | } | |
8602 | } | |
21df8fc8 | 8603 | |
cc1e2398 AK |
8604 | if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 */ |
8605 | XGI_GetVBType(pVBInfo); | |
21df8fc8 | 8606 | |
cc1e2398 AK |
8607 | InitTo330Pointer(HwDeviceExtension->jChipType, pVBInfo); |
8608 | if (ModeNo & 0x80) { | |
8609 | ModeNo = ModeNo & 0x7F; | |
8610 | /* XGINew_flag_clearbuffer = 0; */ | |
8611 | } | |
8612 | /* else { | |
8613 | XGINew_flag_clearbuffer = 1; | |
21df8fc8 | 8614 | } |
cc1e2398 | 8615 | */ |
8104e329 | 8616 | xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86); |
21df8fc8 | 8617 | |
cc1e2398 AK |
8618 | if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 1.Openkey */ |
8619 | XGI_UnLockCRT2(HwDeviceExtension, pVBInfo); | |
21df8fc8 | 8620 | |
cc1e2398 | 8621 | XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo); |
21df8fc8 | 8622 | |
cc1e2398 | 8623 | XGI_GetVGAType(HwDeviceExtension, pVBInfo); |
21df8fc8 | 8624 | |
cc1e2398 AK |
8625 | if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */ |
8626 | XGI_GetVBInfo(ModeNo, ModeIdIndex, HwDeviceExtension, pVBInfo); | |
8627 | XGI_GetTVInfo(ModeNo, ModeIdIndex, pVBInfo); | |
8628 | XGI_GetLCDInfo(ModeNo, ModeIdIndex, pVBInfo); | |
8629 | XGI_DisableBridge(HwDeviceExtension, pVBInfo); | |
21df8fc8 | 8630 | |
cc1e2398 AK |
8631 | if (pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToLCDA)) { |
8632 | XGI_SetCRT1Group(HwDeviceExtension, ModeNo, | |
8633 | ModeIdIndex, pVBInfo); | |
21df8fc8 | 8634 | |
cc1e2398 AK |
8635 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { |
8636 | XGI_SetLCDAGroup(ModeNo, ModeIdIndex, | |
8637 | HwDeviceExtension, pVBInfo); | |
8638 | } | |
8639 | } else { | |
8640 | if (!(pVBInfo->VBInfo & SwitchToCRT2)) { | |
8641 | XGI_SetCRT1Group(HwDeviceExtension, ModeNo, | |
8642 | ModeIdIndex, pVBInfo); | |
8643 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { | |
8644 | XGI_SetLCDAGroup(ModeNo, ModeIdIndex, | |
8645 | HwDeviceExtension, | |
8646 | pVBInfo); | |
8647 | } | |
8648 | } | |
8649 | } | |
21df8fc8 | 8650 | |
cc1e2398 AK |
8651 | if (pVBInfo->VBInfo & (SetSimuScanMode | SwitchToCRT2)) { |
8652 | switch (HwDeviceExtension->ujVBChipID) { | |
8653 | case VB_CHIP_301: | |
8654 | XGI_SetCRT2Group301(ModeNo, HwDeviceExtension, | |
8655 | pVBInfo); /*add for CRT2 */ | |
8656 | break; | |
21df8fc8 | 8657 | |
cc1e2398 AK |
8658 | case VB_CHIP_302: |
8659 | XGI_SetCRT2Group301(ModeNo, HwDeviceExtension, | |
8660 | pVBInfo); /*add for CRT2 */ | |
8661 | break; | |
21df8fc8 | 8662 | |
cc1e2398 AK |
8663 | default: |
8664 | break; | |
8665 | } | |
8666 | } | |
21df8fc8 | 8667 | |
cc1e2398 AK |
8668 | XGI_SetCRT2ModeRegs(ModeNo, HwDeviceExtension, pVBInfo); |
8669 | XGI_OEM310Setting(ModeNo, ModeIdIndex, pVBInfo); /*0212*/ | |
8670 | XGI_CloseCRTC(HwDeviceExtension, pVBInfo); | |
8671 | XGI_EnableBridge(HwDeviceExtension, pVBInfo); | |
8672 | } /* !XG20 */ | |
8673 | else { | |
8674 | if (pVBInfo->IF_DEF_LVDS == 1) | |
1d7f656d KT |
8675 | if (!XGI_XG21CheckLVDSMode(ModeNo, |
8676 | ModeIdIndex, | |
8677 | pVBInfo)) | |
cc1e2398 | 8678 | return 0; |
21df8fc8 | 8679 | |
cc1e2398 | 8680 | if (ModeNo <= 0x13) { |
1d7f656d KT |
8681 | pVBInfo->ModeType = pVBInfo->SModeIDTable[ModeIdIndex]. |
8682 | St_ModeFlag & ModeInfoFlag; | |
cc1e2398 | 8683 | } else { |
1d7f656d KT |
8684 | pVBInfo->ModeType = pVBInfo->EModeIDTable[ModeIdIndex]. |
8685 | Ext_ModeFlag & ModeInfoFlag; | |
cc1e2398 | 8686 | } |
21df8fc8 | 8687 | |
cc1e2398 AK |
8688 | pVBInfo->SetFlag = 0; |
8689 | if (pVBInfo->IF_DEF_CH7007 != 1) | |
8690 | pVBInfo->VBInfo = DisableCRT2Display; | |
21df8fc8 | 8691 | |
cc1e2398 | 8692 | XGI_DisplayOff(HwDeviceExtension, pVBInfo); |
21df8fc8 | 8693 | |
cc1e2398 AK |
8694 | XGI_SetCRT1Group(HwDeviceExtension, ModeNo, ModeIdIndex, |
8695 | pVBInfo); | |
21df8fc8 | 8696 | |
cc1e2398 AK |
8697 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); |
8698 | /* | |
8699 | if (HwDeviceExtension->jChipType == XG21) | |
ec9e5d3e | 8700 | xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0x80, 0x80); |
cc1e2398 AK |
8701 | */ |
8702 | } | |
21df8fc8 | 8703 | |
cc1e2398 AK |
8704 | /* |
8705 | if (ModeNo <= 0x13) { | |
8706 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
8707 | } else { | |
8708 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
8709 | } | |
8710 | pVBInfo->ModeType = modeflag&ModeInfoFlag; | |
8711 | pVBInfo->SetFlag = 0x00; | |
8712 | pVBInfo->VBInfo = DisableCRT2Display; | |
1d7f656d KT |
8713 | temp = XGINew_CheckMemorySize(HwDeviceExtension, |
8714 | ModeNo, | |
8715 | ModeIdIndex, | |
8716 | pVBInfo); | |
21df8fc8 | 8717 | |
cc1e2398 AK |
8718 | if (temp == 0) |
8719 | return (0); | |
21df8fc8 | 8720 | |
cc1e2398 AK |
8721 | XGI_DisplayOff(HwDeviceExtension, pVBInfo) ; |
8722 | XGI_SetCRT1Group(HwDeviceExtension, ModeNo, ModeIdIndex, pVBInfo); | |
8723 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); | |
8724 | */ | |
21df8fc8 | 8725 | |
cc1e2398 | 8726 | XGI_UpdateModeInfo(HwDeviceExtension, pVBInfo); |
21df8fc8 | 8727 | |
cc1e2398 AK |
8728 | if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */ |
8729 | XGI_LockCRT2(HwDeviceExtension, pVBInfo); | |
21df8fc8 | 8730 | } |
21df8fc8 | 8731 | |
cc1e2398 | 8732 | return 1; |
d7636e0b | 8733 | } |