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