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