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: | |
2328 | tempdi = XGI_EPLCHTVDataPtr; | |
2329 | break; | |
2330 | case 3: | |
2331 | tempdi = NULL; | |
2332 | break; | |
2333 | case 4: | |
2334 | tempdi = XGI_TVDataTable; | |
2335 | break; | |
2336 | case 5: | |
2337 | tempdi = NULL; | |
2338 | break; | |
2339 | case 6: | |
2340 | tempdi = XGI_EPLCHTVRegPtr; | |
2341 | break; | |
2342 | default: | |
2343 | break; | |
2344 | } | |
21df8fc8 | 2345 | |
cc1e2398 AK |
2346 | if (tempdi == NULL) /* OEMUtil */ |
2347 | return NULL; | |
21df8fc8 | 2348 | |
cc1e2398 | 2349 | tempdx = pVBInfo->TVInfo; |
21df8fc8 | 2350 | |
cc1e2398 AK |
2351 | if (pVBInfo->VBInfo & SetInSlaveMode) |
2352 | tempdx = tempdx | SetTVLockMode; | |
21df8fc8 | 2353 | |
cc1e2398 AK |
2354 | if (modeflag & HalfDCLK) |
2355 | tempdx = tempdx | SetTVLowResolution; | |
21df8fc8 | 2356 | |
cc1e2398 | 2357 | i = 0; |
21df8fc8 | 2358 | |
cc1e2398 AK |
2359 | while (tempdi[i].MASK != 0xffff) { |
2360 | if ((tempdx & tempdi[i].MASK) == tempdi[i].CAP) | |
2361 | break; | |
2362 | i++; | |
2363 | } | |
21df8fc8 | 2364 | |
1d7f656d KT |
2365 | /* 07/05/22 */ |
2366 | if (table == 0x00) { | |
cc1e2398 AK |
2367 | } else if (table == 0x01) { |
2368 | } else if (table == 0x04) { | |
2369 | switch (tempdi[i].DATAPTR) { | |
2370 | case 0: | |
2371 | return &XGI_ExtPALData[tempal]; | |
2372 | break; | |
2373 | case 1: | |
2374 | return &XGI_ExtNTSCData[tempal]; | |
2375 | break; | |
2376 | case 2: | |
2377 | return &XGI_StPALData[tempal]; | |
2378 | break; | |
2379 | case 3: | |
2380 | return &XGI_StNTSCData[tempal]; | |
2381 | break; | |
2382 | case 4: | |
2383 | return &XGI_ExtHiTVData[tempal]; | |
2384 | break; | |
2385 | case 5: | |
2386 | return &XGI_St2HiTVData[tempal]; | |
2387 | break; | |
2388 | case 6: | |
2389 | return &XGI_ExtYPbPr525iData[tempal]; | |
2390 | break; | |
2391 | case 7: | |
2392 | return &XGI_ExtYPbPr525pData[tempal]; | |
2393 | break; | |
2394 | case 8: | |
2395 | return &XGI_ExtYPbPr750pData[tempal]; | |
2396 | break; | |
2397 | case 9: | |
2398 | return &XGI_StYPbPr525iData[tempal]; | |
2399 | break; | |
2400 | case 10: | |
2401 | return &XGI_StYPbPr525pData[tempal]; | |
2402 | break; | |
2403 | case 11: | |
2404 | return &XGI_StYPbPr750pData[tempal]; | |
2405 | break; | |
2406 | case 12: /* avoid system hang */ | |
2407 | return &XGI_ExtNTSCData[tempal]; | |
2408 | break; | |
2409 | case 13: | |
2410 | return &XGI_St1HiTVData[tempal]; | |
2411 | break; | |
2412 | default: | |
2413 | break; | |
21df8fc8 | 2414 | } |
cc1e2398 AK |
2415 | } else if (table == 0x02) { |
2416 | switch (tempdi[i].DATAPTR) { | |
2417 | case 0: | |
2418 | return &XGI_CHTVUNTSCData[tempal]; | |
2419 | break; | |
2420 | case 1: | |
2421 | return &XGI_CHTVONTSCData[tempal]; | |
2422 | break; | |
2423 | case 2: | |
2424 | return &XGI_CHTVUPALData[tempal]; | |
2425 | break; | |
2426 | case 3: | |
2427 | return &XGI_CHTVOPALData[tempal]; | |
2428 | break; | |
2429 | default: | |
2430 | break; | |
21df8fc8 | 2431 | } |
cc1e2398 | 2432 | } else if (table == 0x06) { |
21df8fc8 | 2433 | } |
cc1e2398 | 2434 | return NULL; |
21df8fc8 | 2435 | } |
d7636e0b | 2436 | |
cc1e2398 AK |
2437 | static void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex, |
2438 | unsigned short RefreshRateTableIndex, | |
21df8fc8 PS |
2439 | struct vb_device_info *pVBInfo) |
2440 | { | |
cc1e2398 AK |
2441 | unsigned short tempbx; |
2442 | struct XGI330_LVDSDataStruct *LCDPtr = NULL; | |
d7636e0b | 2443 | |
cc1e2398 | 2444 | tempbx = 2; |
21df8fc8 | 2445 | |
cc1e2398 AK |
2446 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
2447 | LCDPtr = (struct XGI330_LVDSDataStruct *) XGI_GetLcdPtr(tempbx, | |
2448 | ModeNo, ModeIdIndex, RefreshRateTableIndex, | |
2449 | pVBInfo); | |
2450 | pVBInfo->VGAHT = LCDPtr->VGAHT; | |
2451 | pVBInfo->VGAVT = LCDPtr->VGAVT; | |
2452 | pVBInfo->HT = LCDPtr->LCDHT; | |
2453 | pVBInfo->VT = LCDPtr->LCDVT; | |
2454 | } | |
21df8fc8 | 2455 | |
cc1e2398 AK |
2456 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
2457 | if (!(pVBInfo->LCDInfo & (SetLCDtoNonExpanding | |
2458 | | EnableScalingLCD))) { | |
1d7f656d KT |
2459 | if ((pVBInfo->LCDResInfo == Panel1024x768) || |
2460 | (pVBInfo->LCDResInfo == Panel1024x768x75)) { | |
cc1e2398 AK |
2461 | pVBInfo->HDE = 1024; |
2462 | pVBInfo->VDE = 768; | |
1d7f656d KT |
2463 | } else if ((pVBInfo->LCDResInfo == Panel1280x1024) || |
2464 | (pVBInfo->LCDResInfo == Panel1280x1024x75)) { | |
cc1e2398 AK |
2465 | pVBInfo->HDE = 1280; |
2466 | pVBInfo->VDE = 1024; | |
2467 | } else if (pVBInfo->LCDResInfo == Panel1400x1050) { | |
2468 | pVBInfo->HDE = 1400; | |
2469 | pVBInfo->VDE = 1050; | |
2470 | } else { | |
2471 | pVBInfo->HDE = 1600; | |
2472 | pVBInfo->VDE = 1200; | |
21df8fc8 PS |
2473 | } |
2474 | } | |
21df8fc8 | 2475 | } |
21df8fc8 PS |
2476 | } |
2477 | ||
cc1e2398 AK |
2478 | static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex, |
2479 | unsigned short RefreshRateTableIndex, | |
21df8fc8 PS |
2480 | struct xgi_hw_device_info *HwDeviceExtension, |
2481 | struct vb_device_info *pVBInfo) | |
2482 | { | |
cc1e2398 AK |
2483 | unsigned char index; |
2484 | unsigned short tempbx, i; | |
2485 | struct XGI_LVDSCRT1HDataStruct *LCDPtr = NULL; | |
2486 | struct XGI_LVDSCRT1VDataStruct *LCDPtr1 = NULL; | |
21df8fc8 PS |
2487 | |
2488 | if (ModeNo <= 0x13) | |
cc1e2398 | 2489 | index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; |
21df8fc8 | 2490 | else |
cc1e2398 | 2491 | index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC; |
21df8fc8 | 2492 | |
cc1e2398 | 2493 | index = index & IndexMask; |
21df8fc8 | 2494 | |
1d7f656d KT |
2495 | if ((pVBInfo->IF_DEF_ScaleLCD == 0) || |
2496 | ((pVBInfo->IF_DEF_ScaleLCD == 1) && | |
2497 | (!(pVBInfo->LCDInfo & EnableScalingLCD)))) { | |
cc1e2398 | 2498 | tempbx = 0; |
21df8fc8 | 2499 | |
cc1e2398 | 2500 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
1d7f656d KT |
2501 | LCDPtr = (struct XGI_LVDSCRT1HDataStruct *) |
2502 | XGI_GetLcdPtr(tempbx, ModeNo, | |
2503 | ModeIdIndex, | |
2504 | RefreshRateTableIndex, | |
2505 | pVBInfo); | |
21df8fc8 | 2506 | |
cc1e2398 AK |
2507 | for (i = 0; i < 8; i++) |
2508 | pVBInfo->TimingH[0].data[i] = LCDPtr[0].Reg[i]; | |
2509 | } | |
21df8fc8 | 2510 | |
cc1e2398 | 2511 | XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension); |
21df8fc8 | 2512 | |
cc1e2398 | 2513 | tempbx = 1; |
21df8fc8 | 2514 | |
cc1e2398 | 2515 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
1d7f656d KT |
2516 | LCDPtr1 = (struct XGI_LVDSCRT1VDataStruct *) |
2517 | XGI_GetLcdPtr( | |
2518 | tempbx, | |
2519 | ModeNo, | |
2520 | ModeIdIndex, | |
2521 | RefreshRateTableIndex, | |
2522 | pVBInfo); | |
cc1e2398 AK |
2523 | for (i = 0; i < 7; i++) |
2524 | pVBInfo->TimingV[0].data[i] = LCDPtr1[0].Reg[i]; | |
21df8fc8 PS |
2525 | } |
2526 | ||
cc1e2398 | 2527 | XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo); |
cc1e2398 AK |
2528 | } |
2529 | } | |
21df8fc8 | 2530 | |
cc1e2398 AK |
2531 | static unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo) |
2532 | { | |
2533 | unsigned char tempal, tempah, tempbl, i; | |
2534 | ||
58839b01 | 2535 | tempah = xgifb_reg_get(pVBInfo->P3d4, 0x36); |
cc1e2398 AK |
2536 | tempal = tempah & 0x0F; |
2537 | tempah = tempah & 0xF0; | |
2538 | i = 0; | |
2539 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; | |
21df8fc8 | 2540 | |
cc1e2398 AK |
2541 | while (tempbl != 0xFF) { |
2542 | if (tempbl & 0x80) { /* OEMUtil */ | |
2543 | tempal = tempah; | |
2544 | tempbl = tempbl & ~(0x80); | |
21df8fc8 PS |
2545 | } |
2546 | ||
cc1e2398 AK |
2547 | if (tempal == tempbl) |
2548 | break; | |
21df8fc8 | 2549 | |
cc1e2398 | 2550 | i++; |
21df8fc8 | 2551 | |
cc1e2398 | 2552 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; |
21df8fc8 PS |
2553 | } |
2554 | ||
cc1e2398 | 2555 | return i; |
21df8fc8 PS |
2556 | } |
2557 | ||
cc1e2398 | 2558 | static unsigned short XGI_GetLCDCapPtr1(struct vb_device_info *pVBInfo) |
21df8fc8 | 2559 | { |
cc1e2398 | 2560 | unsigned short tempah, tempal, tempbl, i; |
21df8fc8 | 2561 | |
cc1e2398 AK |
2562 | tempal = pVBInfo->LCDResInfo; |
2563 | tempah = pVBInfo->LCDTypeInfo; | |
21df8fc8 | 2564 | |
cc1e2398 AK |
2565 | i = 0; |
2566 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; | |
21df8fc8 | 2567 | |
cc1e2398 AK |
2568 | while (tempbl != 0xFF) { |
2569 | if ((tempbl & 0x80) && (tempbl != 0x80)) { | |
2570 | tempal = tempah; | |
2571 | tempbl &= ~0x80; | |
21df8fc8 PS |
2572 | } |
2573 | ||
cc1e2398 AK |
2574 | if (tempal == tempbl) |
2575 | break; | |
21df8fc8 | 2576 | |
cc1e2398 AK |
2577 | i++; |
2578 | tempbl = pVBInfo->LCDCapList[i].LCD_ID; | |
2579 | } | |
21df8fc8 | 2580 | |
cc1e2398 AK |
2581 | if (tempbl == 0xFF) { |
2582 | pVBInfo->LCDResInfo = Panel1024x768; | |
2583 | pVBInfo->LCDTypeInfo = 0; | |
2584 | i = 0; | |
2585 | } | |
21df8fc8 | 2586 | |
cc1e2398 AK |
2587 | return i; |
2588 | } | |
21df8fc8 | 2589 | |
1d7f656d KT |
2590 | static void XGI_GetLCDSync(unsigned short *HSyncWidth, |
2591 | unsigned short *VSyncWidth, | |
2592 | struct vb_device_info *pVBInfo) | |
cc1e2398 AK |
2593 | { |
2594 | unsigned short Index; | |
21df8fc8 | 2595 | |
cc1e2398 AK |
2596 | Index = XGI_GetLCDCapPtr(pVBInfo); |
2597 | *HSyncWidth = pVBInfo->LCDCapList[Index].LCD_HSyncWidth; | |
2598 | *VSyncWidth = pVBInfo->LCDCapList[Index].LCD_VSyncWidth; | |
21df8fc8 | 2599 | |
cc1e2398 AK |
2600 | return; |
2601 | } | |
21df8fc8 | 2602 | |
cc1e2398 AK |
2603 | static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex, |
2604 | unsigned short RefreshRateTableIndex, | |
2605 | struct vb_device_info *pVBInfo) | |
2606 | { | |
2607 | unsigned short tempbx, tempax, tempcx, tempdx, push1, push2, modeflag; | |
2608 | unsigned long temp, temp1, temp2, temp3, push3; | |
2609 | struct XGI330_LCDDataDesStruct *LCDPtr = NULL; | |
2610 | struct XGI330_LCDDataDesStruct2 *LCDPtr1 = NULL; | |
21df8fc8 | 2611 | |
cc1e2398 AK |
2612 | if (ModeNo > 0x13) |
2613 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
2614 | else | |
2615 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
21df8fc8 | 2616 | |
cc1e2398 | 2617 | if (!(pVBInfo->SetFlag & Win9xDOSMode)) { |
a35cd0ba AK |
2618 | if (pVBInfo->IF_DEF_OEMUtil == 1) { |
2619 | tempbx = 8; | |
2620 | LCDPtr = (struct XGI330_LCDDataDesStruct *) | |
2621 | XGI_GetLcdPtr(tempbx, | |
2622 | ModeNo, | |
2623 | ModeIdIndex, | |
2624 | RefreshRateTableIndex, | |
2625 | pVBInfo); | |
2626 | } | |
2627 | ||
2628 | if ((pVBInfo->IF_DEF_OEMUtil == 0) || | |
2629 | (LCDPtr == NULL)) { | |
2630 | tempbx = 3; | |
2631 | if (pVBInfo->LCDInfo & EnableScalingLCD) | |
2632 | LCDPtr1 = | |
2633 | (struct XGI330_LCDDataDesStruct2 *) | |
2634 | XGI_GetLcdPtr( | |
2635 | tempbx, | |
2636 | ModeNo, | |
2637 | ModeIdIndex, | |
2638 | RefreshRateTableIndex, | |
2639 | pVBInfo); | |
2640 | else | |
2641 | LCDPtr = | |
2642 | (struct XGI330_LCDDataDesStruct *) | |
2643 | XGI_GetLcdPtr( | |
2644 | tempbx, | |
2645 | ModeNo, | |
2646 | ModeIdIndex, | |
2647 | RefreshRateTableIndex, | |
2648 | pVBInfo); | |
2649 | } | |
21df8fc8 | 2650 | |
a35cd0ba AK |
2651 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); |
2652 | push1 = tempbx; | |
2653 | push2 = tempax; | |
21df8fc8 | 2654 | |
a35cd0ba AK |
2655 | /* GetLCDResInfo */ |
2656 | if ((pVBInfo->LCDResInfo == Panel1024x768) || | |
2657 | (pVBInfo->LCDResInfo == Panel1024x768x75)) { | |
2658 | tempax = 1024; | |
2659 | tempbx = 768; | |
2660 | } else if ((pVBInfo->LCDResInfo == Panel1280x1024) || | |
2661 | (pVBInfo->LCDResInfo == Panel1280x1024x75)) { | |
2662 | tempax = 1280; | |
2663 | tempbx = 1024; | |
2664 | } else if (pVBInfo->LCDResInfo == Panel1400x1050) { | |
2665 | tempax = 1400; | |
2666 | tempbx = 1050; | |
2667 | } else { | |
2668 | tempax = 1600; | |
2669 | tempbx = 1200; | |
2670 | } | |
cc1e2398 | 2671 | |
a35cd0ba AK |
2672 | if (pVBInfo->LCDInfo & SetLCDtoNonExpanding) { |
2673 | pVBInfo->HDE = tempax; | |
2674 | pVBInfo->VDE = tempbx; | |
2675 | pVBInfo->VGAHDE = tempax; | |
2676 | pVBInfo->VGAVDE = tempbx; | |
2677 | } | |
cc1e2398 | 2678 | |
a35cd0ba AK |
2679 | if ((pVBInfo->IF_DEF_ScaleLCD == 1) && |
2680 | (pVBInfo->LCDInfo & EnableScalingLCD)) { | |
2681 | tempax = pVBInfo->HDE; | |
2682 | tempbx = pVBInfo->VDE; | |
2683 | } | |
21df8fc8 | 2684 | |
a35cd0ba | 2685 | tempax = pVBInfo->HT; |
21df8fc8 | 2686 | |
a35cd0ba AK |
2687 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
2688 | tempbx = LCDPtr1->LCDHDES; | |
2689 | else | |
2690 | tempbx = LCDPtr->LCDHDES; | |
21df8fc8 | 2691 | |
a35cd0ba AK |
2692 | tempcx = pVBInfo->HDE; |
2693 | tempbx = tempbx & 0x0fff; | |
2694 | tempcx += tempbx; | |
21df8fc8 | 2695 | |
a35cd0ba AK |
2696 | if (tempcx >= tempax) |
2697 | tempcx -= tempax; | |
21df8fc8 | 2698 | |
a35cd0ba | 2699 | xgifb_reg_set(pVBInfo->Part1Port, 0x1A, tempbx & 0x07); |
21df8fc8 | 2700 | |
a35cd0ba AK |
2701 | tempcx = tempcx >> 3; |
2702 | tempbx = tempbx >> 3; | |
cc1e2398 | 2703 | |
a35cd0ba AK |
2704 | xgifb_reg_set(pVBInfo->Part1Port, 0x16, |
2705 | (unsigned short) (tempbx & 0xff)); | |
2706 | xgifb_reg_set(pVBInfo->Part1Port, 0x17, | |
2707 | (unsigned short) (tempcx & 0xff)); | |
cc1e2398 | 2708 | |
a35cd0ba | 2709 | tempax = pVBInfo->HT; |
cc1e2398 | 2710 | |
a35cd0ba AK |
2711 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
2712 | tempbx = LCDPtr1->LCDHRS; | |
2713 | else | |
2714 | tempbx = LCDPtr->LCDHRS; | |
21df8fc8 | 2715 | |
a35cd0ba | 2716 | tempcx = push2; |
21df8fc8 | 2717 | |
a35cd0ba AK |
2718 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
2719 | tempcx = LCDPtr1->LCDHSync; | |
21df8fc8 | 2720 | |
a35cd0ba | 2721 | tempcx += tempbx; |
21df8fc8 | 2722 | |
a35cd0ba AK |
2723 | if (tempcx >= tempax) |
2724 | tempcx -= tempax; | |
21df8fc8 | 2725 | |
a35cd0ba AK |
2726 | tempax = tempbx & 0x07; |
2727 | tempax = tempax >> 5; | |
2728 | tempcx = tempcx >> 3; | |
2729 | tempbx = tempbx >> 3; | |
21df8fc8 | 2730 | |
a35cd0ba AK |
2731 | tempcx &= 0x1f; |
2732 | tempax |= tempcx; | |
21df8fc8 | 2733 | |
a35cd0ba AK |
2734 | xgifb_reg_set(pVBInfo->Part1Port, 0x15, tempax); |
2735 | xgifb_reg_set(pVBInfo->Part1Port, 0x14, | |
2736 | (unsigned short) (tempbx & 0xff)); | |
21df8fc8 | 2737 | |
a35cd0ba AK |
2738 | tempax = pVBInfo->VT; |
2739 | if (pVBInfo->LCDInfo & EnableScalingLCD) | |
2740 | tempbx = LCDPtr1->LCDVDES; | |
2741 | else | |
2742 | tempbx = LCDPtr->LCDVDES; | |
2743 | tempcx = pVBInfo->VDE; | |
21df8fc8 | 2744 | |
a35cd0ba AK |
2745 | tempbx = tempbx & 0x0fff; |
2746 | tempcx += tempbx; | |
2747 | if (tempcx >= tempax) | |
2748 | tempcx -= tempax; | |
21df8fc8 | 2749 | |
a35cd0ba AK |
2750 | xgifb_reg_set(pVBInfo->Part1Port, 0x1b, |
2751 | (unsigned short) (tempbx & 0xff)); | |
2752 | xgifb_reg_set(pVBInfo->Part1Port, 0x1c, | |
2753 | (unsigned short) (tempcx & 0xff)); | |
21df8fc8 | 2754 | |
a35cd0ba AK |
2755 | tempbx = (tempbx >> 8) & 0x07; |
2756 | tempcx = (tempcx >> 8) & 0x07; | |
21df8fc8 | 2757 | |
a35cd0ba AK |
2758 | xgifb_reg_set(pVBInfo->Part1Port, 0x1d, |
2759 | (unsigned short) ((tempcx << 3) | |
2760 | | tempbx)); | |
21df8fc8 | 2761 | |
a35cd0ba AK |
2762 | tempax = pVBInfo->VT; |
2763 | if (pVBInfo->LCDInfo & EnableScalingLCD) | |
2764 | tempbx = LCDPtr1->LCDVRS; | |
2765 | else | |
2766 | tempbx = LCDPtr->LCDVRS; | |
21df8fc8 | 2767 | |
a35cd0ba AK |
2768 | /* tempbx = tempbx >> 4; */ |
2769 | tempcx = push1; | |
21df8fc8 | 2770 | |
a35cd0ba AK |
2771 | if (pVBInfo->LCDInfo & EnableScalingLCD) |
2772 | tempcx = LCDPtr1->LCDVSync; | |
21df8fc8 | 2773 | |
a35cd0ba AK |
2774 | tempcx += tempbx; |
2775 | if (tempcx >= tempax) | |
2776 | tempcx -= tempax; | |
21df8fc8 | 2777 | |
a35cd0ba AK |
2778 | xgifb_reg_set(pVBInfo->Part1Port, 0x18, |
2779 | (unsigned short) (tempbx & 0xff)); | |
2780 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, ~0x0f, | |
2781 | (unsigned short) (tempcx & 0x0f)); | |
21df8fc8 | 2782 | |
a35cd0ba | 2783 | tempax = ((tempbx >> 8) & 0x07) << 3; |
21df8fc8 | 2784 | |
a35cd0ba AK |
2785 | tempbx = pVBInfo->VGAVDE; |
2786 | if (tempbx != pVBInfo->VDE) | |
2787 | tempax |= 0x40; | |
21df8fc8 | 2788 | |
a35cd0ba AK |
2789 | if (pVBInfo->LCDInfo & EnableLVDSDDA) |
2790 | tempax |= 0x40; | |
21df8fc8 | 2791 | |
a35cd0ba | 2792 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1a, 0x07, |
cc1e2398 | 2793 | tempax); |
21df8fc8 | 2794 | |
a35cd0ba AK |
2795 | tempcx = pVBInfo->VGAVT; |
2796 | tempbx = pVBInfo->VDE; | |
2797 | tempax = pVBInfo->VGAVDE; | |
2798 | tempcx -= tempax; | |
21df8fc8 | 2799 | |
a35cd0ba AK |
2800 | temp = tempax; /* 0430 ylshieh */ |
2801 | temp1 = (temp << 18) / tempbx; | |
21df8fc8 | 2802 | |
a35cd0ba | 2803 | tempdx = (unsigned short) ((temp << 18) % tempbx); |
21df8fc8 | 2804 | |
a35cd0ba AK |
2805 | if (tempdx != 0) |
2806 | temp1 += 1; | |
cc1e2398 | 2807 | |
a35cd0ba AK |
2808 | temp2 = temp1; |
2809 | push3 = temp2; | |
cc1e2398 | 2810 | |
a35cd0ba AK |
2811 | xgifb_reg_set(pVBInfo->Part1Port, 0x37, |
2812 | (unsigned short) (temp2 & 0xff)); | |
2813 | xgifb_reg_set(pVBInfo->Part1Port, 0x36, | |
2814 | (unsigned short) ((temp2 >> 8) & 0xff)); | |
21df8fc8 | 2815 | |
a35cd0ba AK |
2816 | tempbx = (unsigned short) (temp2 >> 16); |
2817 | tempax = tempbx & 0x03; | |
d7636e0b | 2818 | |
a35cd0ba AK |
2819 | tempbx = pVBInfo->VGAVDE; |
2820 | if (tempbx == pVBInfo->VDE) | |
2821 | tempax |= 0x04; | |
21df8fc8 | 2822 | |
a35cd0ba | 2823 | xgifb_reg_set(pVBInfo->Part1Port, 0x35, tempax); |
21df8fc8 | 2824 | |
a35cd0ba AK |
2825 | if (pVBInfo->VBType & VB_XGI301C) { |
2826 | temp2 = push3; | |
2827 | xgifb_reg_set(pVBInfo->Part4Port, | |
2828 | 0x3c, | |
2829 | (unsigned short) (temp2 & 0xff)); | |
2830 | xgifb_reg_set(pVBInfo->Part4Port, | |
2831 | 0x3b, | |
2832 | (unsigned short) ((temp2 >> 8) & | |
2833 | 0xff)); | |
2834 | tempbx = (unsigned short) (temp2 >> 16); | |
2835 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x3a, | |
2836 | ~0xc0, | |
2837 | (unsigned short) ((tempbx & | |
2838 | 0xff) << 6)); | |
2839 | ||
2840 | tempcx = pVBInfo->VGAVDE; | |
2841 | if (tempcx == pVBInfo->VDE) | |
2842 | xgifb_reg_and_or(pVBInfo->Part4Port, | |
2843 | 0x30, ~0x0c, 0x00); | |
2844 | else | |
2845 | xgifb_reg_and_or(pVBInfo->Part4Port, | |
2846 | 0x30, ~0x0c, 0x08); | |
2847 | } | |
21df8fc8 | 2848 | |
a35cd0ba AK |
2849 | tempcx = pVBInfo->VGAHDE; |
2850 | tempbx = pVBInfo->HDE; | |
21df8fc8 | 2851 | |
a35cd0ba | 2852 | temp1 = tempcx << 16; |
d7636e0b | 2853 | |
a35cd0ba | 2854 | tempax = (unsigned short) (temp1 / tempbx); |
21df8fc8 | 2855 | |
a35cd0ba AK |
2856 | if ((tempbx & 0xffff) == (tempcx & 0xffff)) |
2857 | tempax = 65535; | |
21df8fc8 | 2858 | |
a35cd0ba AK |
2859 | temp3 = tempax; |
2860 | temp1 = pVBInfo->VGAHDE << 16; | |
d7636e0b | 2861 | |
a35cd0ba AK |
2862 | temp1 /= temp3; |
2863 | temp3 = temp3 << 16; | |
2864 | temp1 -= 1; | |
21df8fc8 | 2865 | |
a35cd0ba | 2866 | temp3 = (temp3 & 0xffff0000) + (temp1 & 0xffff); |
d7636e0b | 2867 | |
a35cd0ba AK |
2868 | tempax = (unsigned short) (temp3 & 0xff); |
2869 | xgifb_reg_set(pVBInfo->Part1Port, 0x1f, tempax); | |
d7636e0b | 2870 | |
a35cd0ba AK |
2871 | temp1 = pVBInfo->VGAVDE << 18; |
2872 | temp1 = temp1 / push3; | |
2873 | tempbx = (unsigned short) (temp1 & 0xffff); | |
21df8fc8 | 2874 | |
a35cd0ba AK |
2875 | if (pVBInfo->LCDResInfo == Panel1024x768) |
2876 | tempbx -= 1; | |
21df8fc8 | 2877 | |
a35cd0ba AK |
2878 | tempax = ((tempbx >> 8) & 0xff) << 3; |
2879 | tempax |= (unsigned short) ((temp3 >> 8) & 0x07); | |
2880 | xgifb_reg_set(pVBInfo->Part1Port, 0x20, | |
2881 | (unsigned short) (tempax & 0xff)); | |
2882 | xgifb_reg_set(pVBInfo->Part1Port, 0x21, | |
2883 | (unsigned short) (tempbx & 0xff)); | |
21df8fc8 | 2884 | |
a35cd0ba AK |
2885 | temp3 = temp3 >> 16; |
2886 | ||
2887 | if (modeflag & HalfDCLK) | |
2888 | temp3 = temp3 >> 1; | |
2889 | ||
2890 | xgifb_reg_set(pVBInfo->Part1Port, 0x22, | |
2891 | (unsigned short) ((temp3 >> 8) & 0xff)); | |
2892 | xgifb_reg_set(pVBInfo->Part1Port, 0x23, | |
2893 | (unsigned short) (temp3 & 0xff)); | |
21df8fc8 PS |
2894 | } |
2895 | } | |
d7636e0b | 2896 | |
cc1e2398 AK |
2897 | /* --------------------------------------------------------------------- */ |
2898 | /* Function : XGI_GETLCDVCLKPtr */ | |
2899 | /* Input : */ | |
2900 | /* Output : al -> VCLK Index */ | |
2901 | /* Description : */ | |
2902 | /* --------------------------------------------------------------------- */ | |
2903 | static void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1, | |
21df8fc8 PS |
2904 | struct vb_device_info *pVBInfo) |
2905 | { | |
cc1e2398 | 2906 | unsigned short index; |
d7636e0b | 2907 | |
cc1e2398 AK |
2908 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
2909 | if (pVBInfo->IF_DEF_ScaleLCD == 1) { | |
2910 | if (pVBInfo->LCDInfo & EnableScalingLCD) | |
2911 | return; | |
21df8fc8 | 2912 | } |
d7636e0b | 2913 | |
cc1e2398 AK |
2914 | /* index = XGI_GetLCDCapPtr(pVBInfo); */ |
2915 | index = XGI_GetLCDCapPtr1(pVBInfo); | |
d7636e0b | 2916 | |
cc1e2398 AK |
2917 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { /* LCDB */ |
2918 | *di_0 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData1; | |
2919 | *di_1 = pVBInfo->LCDCapList[index].LCUCHAR_VCLKData2; | |
2920 | } else { /* LCDA */ | |
2921 | *di_0 = pVBInfo->LCDCapList[index].LCDA_VCLKData1; | |
2922 | *di_1 = pVBInfo->LCDCapList[index].LCDA_VCLKData2; | |
21df8fc8 | 2923 | } |
21df8fc8 | 2924 | } |
cc1e2398 | 2925 | return; |
d7636e0b | 2926 | } |
2927 | ||
cc1e2398 AK |
2928 | static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex, |
2929 | unsigned short ModeNo, unsigned short ModeIdIndex, | |
2930 | struct vb_device_info *pVBInfo) | |
d7636e0b | 2931 | { |
d7636e0b | 2932 | |
cc1e2398 | 2933 | unsigned short index, modeflag; |
cc1e2398 | 2934 | unsigned char tempal; |
d7636e0b | 2935 | |
cc1e2398 | 2936 | if (ModeNo <= 0x13) |
1d7f656d KT |
2937 | /* si+St_ResInfo */ |
2938 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
cc1e2398 | 2939 | else |
1d7f656d KT |
2940 | /* si+Ext_ResInfo */ |
2941 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
d7636e0b | 2942 | |
1d7f656d KT |
2943 | if ((pVBInfo->SetFlag & ProgrammingCRT2) && |
2944 | (!(pVBInfo->LCDInfo & EnableScalingLCD))) { /* {LCDA/LCDB} */ | |
cc1e2398 AK |
2945 | index = XGI_GetLCDCapPtr(pVBInfo); |
2946 | tempal = pVBInfo->LCDCapList[index].LCD_VCLK; | |
d7636e0b | 2947 | |
cc1e2398 AK |
2948 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) |
2949 | return tempal; | |
d7636e0b | 2950 | |
cc1e2398 | 2951 | /* {TV} */ |
1d7f656d KT |
2952 | if (pVBInfo->VBType & |
2953 | (VB_XGI301B | | |
2954 | VB_XGI302B | | |
2955 | VB_XGI301LV | | |
2956 | VB_XGI302LV | | |
2957 | VB_XGI301C)) { | |
cc1e2398 AK |
2958 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
2959 | tempal = HiTVVCLKDIV2; | |
2960 | if (!(pVBInfo->TVInfo & RPLLDIV2XO)) | |
2961 | tempal = HiTVVCLK; | |
2962 | if (pVBInfo->TVInfo & TVSimuMode) { | |
2963 | tempal = HiTVSimuVCLK; | |
2964 | if (!(modeflag & Charx8Dot)) | |
2965 | tempal = HiTVTextVCLK; | |
d7636e0b | 2966 | |
cc1e2398 AK |
2967 | } |
2968 | return tempal; | |
2969 | } | |
d7636e0b | 2970 | |
cc1e2398 AK |
2971 | if (pVBInfo->TVInfo & SetYPbPrMode750p) { |
2972 | tempal = YPbPr750pVCLK; | |
2973 | return tempal; | |
2974 | } | |
d7636e0b | 2975 | |
cc1e2398 AK |
2976 | if (pVBInfo->TVInfo & SetYPbPrMode525p) { |
2977 | tempal = YPbPr525pVCLK; | |
2978 | return tempal; | |
2979 | } | |
d7636e0b | 2980 | |
cc1e2398 | 2981 | tempal = NTSC1024VCLK; |
d7636e0b | 2982 | |
cc1e2398 AK |
2983 | if (!(pVBInfo->TVInfo & NTSC1024x768)) { |
2984 | tempal = TVVCLKDIV2; | |
2985 | if (!(pVBInfo->TVInfo & RPLLDIV2XO)) | |
2986 | tempal = TVVCLK; | |
2987 | } | |
d7636e0b | 2988 | |
cc1e2398 AK |
2989 | if (pVBInfo->VBInfo & SetCRT2ToTV) |
2990 | return tempal; | |
2991 | } | |
cc1e2398 | 2992 | } /* {End of VB} */ |
d7636e0b | 2993 | |
d8ad0a6d | 2994 | tempal = (unsigned char) inb((pVBInfo->P3ca + 0x02)); |
cc1e2398 AK |
2995 | tempal = tempal >> 2; |
2996 | tempal &= 0x03; | |
d7636e0b | 2997 | |
1d7f656d KT |
2998 | /* for Dot8 Scaling LCD */ |
2999 | if ((pVBInfo->LCDInfo & EnableScalingLCD) && (modeflag & Charx8Dot)) | |
cc1e2398 AK |
3000 | tempal = tempal ^ tempal; /* ; set to VCLK25MHz always */ |
3001 | ||
3002 | if (ModeNo <= 0x13) | |
3003 | return tempal; | |
3004 | ||
3005 | tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK; | |
3006 | return tempal; | |
d7636e0b | 3007 | } |
3008 | ||
cc1e2398 AK |
3009 | static void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0, |
3010 | unsigned char *di_1, struct vb_device_info *pVBInfo) | |
d7636e0b | 3011 | { |
83f76a9d | 3012 | if (pVBInfo->VBType & (VB_XGI301 | VB_XGI301B | VB_XGI302B |
cc1e2398 AK |
3013 | | VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) { |
3014 | if ((!(pVBInfo->VBInfo & SetCRT2ToLCDA)) && (pVBInfo->SetFlag | |
3015 | & ProgrammingCRT2)) { | |
3016 | *di_0 = (unsigned char) XGI_VBVCLKData[tempal].SR2B; | |
3017 | *di_1 = XGI_VBVCLKData[tempal].SR2C; | |
3018 | } | |
3019 | } else { | |
3020 | *di_0 = XGI_VCLKData[tempal].SR2B; | |
3021 | *di_1 = XGI_VCLKData[tempal].SR2C; | |
3022 | } | |
d7636e0b | 3023 | } |
d7636e0b | 3024 | |
cc1e2398 AK |
3025 | static void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex, |
3026 | unsigned short RefreshRateTableIndex, | |
21df8fc8 PS |
3027 | struct vb_device_info *pVBInfo) |
3028 | { | |
cc1e2398 AK |
3029 | unsigned char di_0, di_1, tempal; |
3030 | int i; | |
21df8fc8 | 3031 | |
cc1e2398 AK |
3032 | tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex, |
3033 | pVBInfo); | |
3034 | XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo); | |
3035 | XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo); | |
3036 | ||
3037 | for (i = 0; i < 4; i++) { | |
ec9e5d3e | 3038 | xgifb_reg_and_or(pVBInfo->P3d4, 0x31, ~0x30, |
cc1e2398 | 3039 | (unsigned short) (0x10 * i)); |
83f76a9d | 3040 | if ((!(pVBInfo->VBInfo & SetCRT2ToLCDA)) |
cc1e2398 | 3041 | && (!(pVBInfo->VBInfo & SetInSlaveMode))) { |
8104e329 AK |
3042 | xgifb_reg_set(pVBInfo->P3c4, 0x2e, di_0); |
3043 | xgifb_reg_set(pVBInfo->P3c4, 0x2f, di_1); | |
cc1e2398 | 3044 | } else { |
8104e329 AK |
3045 | xgifb_reg_set(pVBInfo->P3c4, 0x2b, di_0); |
3046 | xgifb_reg_set(pVBInfo->P3c4, 0x2c, di_1); | |
cc1e2398 AK |
3047 | } |
3048 | } | |
d7636e0b | 3049 | } |
3050 | ||
cc1e2398 AK |
3051 | static void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension, |
3052 | struct vb_device_info *pVBInfo) | |
d7636e0b | 3053 | { |
cc1e2398 | 3054 | unsigned short tempcl, tempch, temp, tempbl, tempax; |
d7636e0b | 3055 | |
cc1e2398 AK |
3056 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
3057 | | VB_XGI302LV | VB_XGI301C)) { | |
3058 | tempcl = 0; | |
3059 | tempch = 0; | |
58839b01 | 3060 | temp = xgifb_reg_get(pVBInfo->P3c4, 0x01); |
21df8fc8 | 3061 | |
cc1e2398 | 3062 | if (!(temp & 0x20)) { |
58839b01 | 3063 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x17); |
cc1e2398 | 3064 | if (temp & 0x80) { |
58839b01 | 3065 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x53); |
cc1e2398 AK |
3066 | if (!(temp & 0x40)) |
3067 | tempcl |= ActiveCRT1; | |
3068 | } | |
3069 | } | |
21df8fc8 | 3070 | |
58839b01 | 3071 | temp = xgifb_reg_get(pVBInfo->Part1Port, 0x2e); |
cc1e2398 | 3072 | temp &= 0x0f; |
21df8fc8 | 3073 | |
cc1e2398 | 3074 | if (!(temp == 0x08)) { |
1d7f656d KT |
3075 | /* Check ChannelA by Part1_13 [2003/10/03] */ |
3076 | tempax = xgifb_reg_get(pVBInfo->Part1Port, 0x13); | |
cc1e2398 AK |
3077 | if (tempax & 0x04) |
3078 | tempcl = tempcl | ActiveLCD; | |
21df8fc8 | 3079 | |
cc1e2398 | 3080 | temp &= 0x05; |
d7636e0b | 3081 | |
cc1e2398 AK |
3082 | if (!(tempcl & ActiveLCD)) |
3083 | if (temp == 0x01) | |
3084 | tempcl |= ActiveCRT2; | |
3085 | ||
3086 | if (temp == 0x04) | |
3087 | tempcl |= ActiveLCD; | |
3088 | ||
3089 | if (temp == 0x05) { | |
58839b01 | 3090 | temp = xgifb_reg_get(pVBInfo->Part2Port, 0x00); |
cc1e2398 AK |
3091 | |
3092 | if (!(temp & 0x08)) | |
3093 | tempch |= ActiveAVideo; | |
3094 | ||
3095 | if (!(temp & 0x04)) | |
3096 | tempch |= ActiveSVideo; | |
3097 | ||
3098 | if (temp & 0x02) | |
3099 | tempch |= ActiveSCART; | |
3100 | ||
3101 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { | |
3102 | if (temp & 0x01) | |
3103 | tempch |= ActiveHiTV; | |
21df8fc8 | 3104 | } |
21df8fc8 | 3105 | |
cc1e2398 | 3106 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { |
58839b01 | 3107 | temp = xgifb_reg_get( |
cc1e2398 AK |
3108 | pVBInfo->Part2Port, |
3109 | 0x4d); | |
21df8fc8 | 3110 | |
cc1e2398 AK |
3111 | if (temp & 0x10) |
3112 | tempch |= ActiveYPbPr; | |
21df8fc8 | 3113 | } |
cc1e2398 AK |
3114 | |
3115 | if (tempch != 0) | |
3116 | tempcl |= ActiveTV; | |
21df8fc8 | 3117 | } |
cc1e2398 | 3118 | } |
21df8fc8 | 3119 | |
58839b01 | 3120 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x3d); |
cc1e2398 AK |
3121 | if (tempcl & ActiveLCD) { |
3122 | if ((pVBInfo->SetFlag & ReserveTVOption)) { | |
3123 | if (temp & ActiveTV) | |
3124 | tempcl |= ActiveTV; | |
21df8fc8 PS |
3125 | } |
3126 | } | |
cc1e2398 AK |
3127 | temp = tempcl; |
3128 | tempbl = ~ModeSwitchStatus; | |
ec9e5d3e | 3129 | xgifb_reg_and_or(pVBInfo->P3d4, 0x3d, tempbl, temp); |
21df8fc8 | 3130 | |
cc1e2398 | 3131 | if (!(pVBInfo->SetFlag & ReserveTVOption)) |
8104e329 | 3132 | xgifb_reg_set(pVBInfo->P3d4, 0x3e, tempch); |
cc1e2398 AK |
3133 | } else { |
3134 | return; | |
21df8fc8 | 3135 | } |
cc1e2398 | 3136 | } |
d7636e0b | 3137 | |
cc1e2398 AK |
3138 | void XGI_GetVGAType(struct xgi_hw_device_info *HwDeviceExtension, |
3139 | struct vb_device_info *pVBInfo) | |
3140 | { | |
3141 | /* | |
3142 | if ( HwDeviceExtension->jChipType >= XG20 ) { | |
3143 | pVBInfo->Set_VGAType = XG20; | |
06587335 | 3144 | } else { |
cc1e2398 AK |
3145 | pVBInfo->Set_VGAType = VGA_XGI340; |
3146 | } | |
3147 | */ | |
3148 | pVBInfo->Set_VGAType = HwDeviceExtension->jChipType; | |
d7636e0b | 3149 | } |
3150 | ||
cc1e2398 | 3151 | void XGI_GetVBType(struct vb_device_info *pVBInfo) |
d7636e0b | 3152 | { |
cc1e2398 | 3153 | unsigned short flag, tempbx, tempah; |
d7636e0b | 3154 | |
cc1e2398 AK |
3155 | if (pVBInfo->IF_DEF_LVDS == 0) { |
3156 | tempbx = VB_XGI302B; | |
58839b01 | 3157 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00); |
cc1e2398 AK |
3158 | if (flag != 0x02) { |
3159 | tempbx = VB_XGI301; | |
58839b01 | 3160 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x01); |
cc1e2398 AK |
3161 | if (flag >= 0xB0) { |
3162 | tempbx = VB_XGI301B; | |
3163 | if (flag >= 0xC0) { | |
3164 | tempbx = VB_XGI301C; | |
3165 | if (flag >= 0xD0) { | |
3166 | tempbx = VB_XGI301LV; | |
3167 | if (flag >= 0xE0) { | |
3168 | tempbx = VB_XGI302LV; | |
1d7f656d KT |
3169 | tempah = xgifb_reg_get( |
3170 | pVBInfo->Part4Port, | |
3171 | 0x39); | |
cc1e2398 | 3172 | if (tempah != 0xFF) |
1d7f656d KT |
3173 | tempbx = |
3174 | VB_XGI301C; | |
cc1e2398 AK |
3175 | } |
3176 | } | |
3177 | } | |
3178 | ||
3179 | if (tempbx & (VB_XGI301B | VB_XGI302B)) { | |
58839b01 | 3180 | flag = xgifb_reg_get( |
cc1e2398 AK |
3181 | pVBInfo->Part4Port, |
3182 | 0x23); | |
3183 | ||
3184 | if (!(flag & 0x02)) | |
3185 | tempbx = tempbx | VB_NoLCD; | |
3186 | } | |
3187 | } | |
3188 | } | |
3189 | pVBInfo->VBType = tempbx; | |
3190 | } | |
d7636e0b | 3191 | } |
3192 | ||
cc1e2398 AK |
3193 | void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, |
3194 | struct xgi_hw_device_info *HwDeviceExtension, | |
21df8fc8 PS |
3195 | struct vb_device_info *pVBInfo) |
3196 | { | |
cc1e2398 | 3197 | unsigned short tempax, push, tempbx, temp, modeflag; |
d7636e0b | 3198 | |
cc1e2398 AK |
3199 | if (ModeNo <= 0x13) |
3200 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
3201 | else | |
3202 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
d7636e0b | 3203 | |
cc1e2398 AK |
3204 | pVBInfo->SetFlag = 0; |
3205 | pVBInfo->ModeType = modeflag & ModeInfoFlag; | |
3206 | tempbx = 0; | |
3207 | ||
3208 | if (pVBInfo->VBType & 0xFFFF) { | |
1d7f656d KT |
3209 | /* Check Display Device */ |
3210 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x30); | |
cc1e2398 | 3211 | tempbx = tempbx | temp; |
58839b01 | 3212 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x31); |
cc1e2398 AK |
3213 | push = temp; |
3214 | push = push << 8; | |
3215 | tempax = temp << 8; | |
3216 | tempbx = tempbx | tempax; | |
3217 | temp = (SetCRT2ToDualEdge | SetCRT2ToYPbPr | SetCRT2ToLCDA | |
3218 | | SetInSlaveMode | DisableCRT2Display); | |
3219 | temp = 0xFFFF ^ temp; | |
3220 | tempbx &= temp; | |
3221 | ||
58839b01 | 3222 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x38); |
cc1e2398 AK |
3223 | |
3224 | if (pVBInfo->IF_DEF_LCDA == 1) { | |
3225 | ||
3226 | if ((pVBInfo->Set_VGAType >= XG20) | |
3227 | || (pVBInfo->Set_VGAType >= XG40)) { | |
3228 | if (pVBInfo->IF_DEF_LVDS == 0) { | |
1d7f656d KT |
3229 | /* if ((pVBInfo->VBType & VB_XGI302B) |
3230 | || (pVBInfo->VBType & VB_XGI301LV) | |
3231 | || (pVBInfo->VBType & VB_XGI302LV) | |
3232 | || (pVBInfo->VBType & VB_XGI301C)) | |
3233 | */ | |
3234 | if (pVBInfo->VBType & | |
3235 | (VB_XGI302B | | |
3236 | VB_XGI301LV | | |
3237 | VB_XGI302LV | | |
3238 | VB_XGI301C)) { | |
cc1e2398 | 3239 | if (temp & EnableDualEdge) { |
1d7f656d KT |
3240 | tempbx |= |
3241 | SetCRT2ToDualEdge; | |
d7636e0b | 3242 | |
cc1e2398 | 3243 | if (temp & SetToLCDA) |
1d7f656d KT |
3244 | tempbx |= |
3245 | SetCRT2ToLCDA; | |
cc1e2398 AK |
3246 | } |
3247 | } | |
cc1e2398 AK |
3248 | } |
3249 | } | |
3250 | } | |
21df8fc8 | 3251 | |
cc1e2398 | 3252 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
1d7f656d KT |
3253 | /* [Billy] 07/05/04 */ |
3254 | if (((pVBInfo->IF_DEF_LVDS == 0) && | |
3255 | ((pVBInfo->VBType & VB_XGI301LV) || | |
3256 | (pVBInfo->VBType & VB_XGI302LV) || | |
83f76a9d | 3257 | (pVBInfo->VBType & VB_XGI301C)))) { |
cc1e2398 AK |
3258 | if (temp & SetYPbPr) { /* temp = CR38 */ |
3259 | if (pVBInfo->IF_DEF_HiVision == 1) { | |
1d7f656d KT |
3260 | /* shampoo add for new |
3261 | * scratch */ | |
58839b01 | 3262 | temp = xgifb_reg_get( |
cc1e2398 | 3263 | pVBInfo->P3d4, |
1d7f656d | 3264 | 0x35); |
cc1e2398 AK |
3265 | temp &= YPbPrMode; |
3266 | tempbx |= SetCRT2ToHiVisionTV; | |
21df8fc8 | 3267 | |
cc1e2398 | 3268 | if (temp != YPbPrMode1080i) { |
1d7f656d KT |
3269 | tempbx &= |
3270 | (~SetCRT2ToHiVisionTV); | |
3271 | tempbx |= | |
3272 | SetCRT2ToYPbPr; | |
cc1e2398 AK |
3273 | } |
3274 | } | |
21df8fc8 | 3275 | |
cc1e2398 AK |
3276 | /* tempbx |= SetCRT2ToYPbPr; */ |
3277 | } | |
3278 | } | |
3279 | } | |
21df8fc8 | 3280 | |
cc1e2398 | 3281 | tempax = push; /* restore CR31 */ |
21df8fc8 | 3282 | |
cc1e2398 AK |
3283 | if (pVBInfo->IF_DEF_LVDS == 0) { |
3284 | if (pVBInfo->IF_DEF_YPbPr == 1) { | |
3285 | if (pVBInfo->IF_DEF_HiVision == 1) | |
3286 | temp = 0x09FC; | |
21df8fc8 | 3287 | else |
cc1e2398 AK |
3288 | temp = 0x097C; |
3289 | } else { | |
3290 | if (pVBInfo->IF_DEF_HiVision == 1) | |
3291 | temp = 0x01FC; | |
3292 | else | |
3293 | temp = 0x017C; | |
3294 | } | |
3295 | } else { /* 3nd party chip */ | |
83f76a9d | 3296 | temp = SetCRT2ToLCD; |
cc1e2398 | 3297 | } |
21df8fc8 | 3298 | |
cc1e2398 AK |
3299 | if (!(tempbx & temp)) { |
3300 | tempax |= DisableCRT2Display; | |
3301 | tempbx = 0; | |
21df8fc8 PS |
3302 | } |
3303 | ||
cc1e2398 AK |
3304 | if (pVBInfo->IF_DEF_LCDA == 1) { /* Select Display Device */ |
3305 | if (!(pVBInfo->VBType & VB_NoLCD)) { | |
3306 | if (tempbx & SetCRT2ToLCDA) { | |
3307 | if (tempbx & SetSimuScanMode) | |
1d7f656d KT |
3308 | tempbx &= (~(SetCRT2ToLCD | |
3309 | SetCRT2ToRAMDAC | | |
3310 | SwitchToCRT2)); | |
cc1e2398 | 3311 | else |
1d7f656d KT |
3312 | tempbx &= (~(SetCRT2ToLCD | |
3313 | SetCRT2ToRAMDAC | | |
3314 | SetCRT2ToTV | | |
3315 | SwitchToCRT2)); | |
cc1e2398 AK |
3316 | } |
3317 | } | |
21df8fc8 PS |
3318 | } |
3319 | ||
cc1e2398 | 3320 | /* shampoo add */ |
1d7f656d KT |
3321 | /* for driver abnormal */ |
3322 | if (!(tempbx & (SwitchToCRT2 | SetSimuScanMode))) { | |
cc1e2398 AK |
3323 | if (pVBInfo->IF_DEF_CRT2Monitor == 1) { |
3324 | if (tempbx & SetCRT2ToRAMDAC) { | |
1d7f656d KT |
3325 | tempbx &= (0xFF00 | |
3326 | SetCRT2ToRAMDAC | | |
3327 | SwitchToCRT2 | | |
3328 | SetSimuScanMode); | |
cc1e2398 AK |
3329 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr)); |
3330 | } | |
3331 | } else { | |
1d7f656d KT |
3332 | tempbx &= (~(SetCRT2ToRAMDAC | |
3333 | SetCRT2ToLCD | | |
3334 | SetCRT2ToTV)); | |
cc1e2398 AK |
3335 | } |
3336 | } | |
21df8fc8 | 3337 | |
cc1e2398 AK |
3338 | if (!(pVBInfo->VBType & VB_NoLCD)) { |
3339 | if (tempbx & SetCRT2ToLCD) { | |
1d7f656d KT |
3340 | tempbx &= (0xFF00 | |
3341 | SetCRT2ToLCD | | |
3342 | SwitchToCRT2 | | |
3343 | SetSimuScanMode); | |
cc1e2398 AK |
3344 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr)); |
3345 | } | |
3346 | } | |
21df8fc8 | 3347 | |
cc1e2398 | 3348 | if (tempbx & SetCRT2ToSCART) { |
1d7f656d KT |
3349 | tempbx &= (0xFF00 | |
3350 | SetCRT2ToSCART | | |
3351 | SwitchToCRT2 | | |
3352 | SetSimuScanMode); | |
cc1e2398 AK |
3353 | tempbx &= (0x00FF | (~SetCRT2ToYPbPr)); |
3354 | } | |
21df8fc8 | 3355 | |
cc1e2398 AK |
3356 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
3357 | if (tempbx & SetCRT2ToYPbPr) | |
1d7f656d KT |
3358 | tempbx &= (0xFF00 | |
3359 | SwitchToCRT2 | | |
3360 | SetSimuScanMode); | |
cc1e2398 | 3361 | } |
21df8fc8 | 3362 | |
cc1e2398 AK |
3363 | if (pVBInfo->IF_DEF_HiVision == 1) { |
3364 | if (tempbx & SetCRT2ToHiVisionTV) | |
1d7f656d KT |
3365 | tempbx &= (0xFF00 | |
3366 | SetCRT2ToHiVisionTV | | |
3367 | SwitchToCRT2 | | |
3368 | SetSimuScanMode); | |
cc1e2398 | 3369 | } |
21df8fc8 | 3370 | |
cc1e2398 AK |
3371 | if (tempax & DisableCRT2Display) { /* Set Display Device Info */ |
3372 | if (!(tempbx & (SwitchToCRT2 | SetSimuScanMode))) | |
3373 | tempbx = DisableCRT2Display; | |
3374 | } | |
21df8fc8 | 3375 | |
cc1e2398 | 3376 | if (!(tempbx & DisableCRT2Display)) { |
1d7f656d KT |
3377 | if ((!(tempbx & DriverMode)) || |
3378 | (!(modeflag & CRT2Mode))) { | |
cc1e2398 AK |
3379 | if (pVBInfo->IF_DEF_LCDA == 1) { |
3380 | if (!(tempbx & SetCRT2ToLCDA)) | |
1d7f656d KT |
3381 | tempbx |= (SetInSlaveMode | |
3382 | SetSimuScanMode); | |
cc1e2398 | 3383 | } |
21df8fc8 | 3384 | |
cc1e2398 | 3385 | if (pVBInfo->IF_DEF_VideoCapture == 1) { |
1d7f656d KT |
3386 | if (((HwDeviceExtension->jChipType == |
3387 | XG40) && | |
3388 | (pVBInfo->Set_VGAType == XG40)) || | |
3389 | ((HwDeviceExtension->jChipType == | |
3390 | XG41) && | |
3391 | (pVBInfo->Set_VGAType == XG41)) || | |
3392 | ((HwDeviceExtension->jChipType == | |
3393 | XG42) && | |
3394 | (pVBInfo->Set_VGAType == XG42)) || | |
3395 | ((HwDeviceExtension->jChipType == | |
3396 | XG45) && | |
3397 | (pVBInfo->Set_VGAType == XG45))) { | |
cc1e2398 | 3398 | if (ModeNo <= 13) { |
1d7f656d KT |
3399 | if (!(tempbx & |
3400 | SetCRT2ToRAMDAC)) { | |
3401 | /*CRT2 not need | |
3402 | * to support*/ | |
3403 | tempbx &= | |
3404 | (0x00FF | | |
3405 | (~SetInSlaveMode)); | |
cc1e2398 AK |
3406 | pVBInfo->SetFlag |
3407 | |= EnableVCMode; | |
3408 | } | |
3409 | } | |
21df8fc8 PS |
3410 | } |
3411 | } | |
3412 | } | |
21df8fc8 | 3413 | |
1d7f656d KT |
3414 | /* LCD+TV can't support in slave mode |
3415 | * (Force LCDA+TV->LCDB) */ | |
3416 | if ((tempbx & SetInSlaveMode) && | |
3417 | (tempbx & SetCRT2ToLCDA)) { | |
3418 | tempbx ^= (SetCRT2ToLCD | | |
3419 | SetCRT2ToLCDA | | |
3420 | SetCRT2ToDualEdge); | |
cc1e2398 | 3421 | pVBInfo->SetFlag |= ReserveTVOption; |
21df8fc8 PS |
3422 | } |
3423 | } | |
21df8fc8 | 3424 | } |
cc1e2398 AK |
3425 | |
3426 | pVBInfo->VBInfo = tempbx; | |
21df8fc8 PS |
3427 | } |
3428 | ||
cc1e2398 | 3429 | void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex, |
21df8fc8 | 3430 | struct vb_device_info *pVBInfo) |
d7636e0b | 3431 | { |
cc1e2398 | 3432 | unsigned short temp, tempbx = 0, resinfo = 0, modeflag, index1; |
21df8fc8 | 3433 | |
cc1e2398 AK |
3434 | tempbx = 0; |
3435 | resinfo = 0; | |
d7636e0b | 3436 | |
cc1e2398 AK |
3437 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
3438 | if (ModeNo <= 0x13) { | |
1d7f656d KT |
3439 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex]. |
3440 | St_ModeFlag; /* si+St_ModeFlag */ | |
3441 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex]. | |
3442 | St_ResInfo; /* si+St_ResInfo */ | |
cc1e2398 | 3443 | } else { |
1d7f656d KT |
3444 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex]. |
3445 | Ext_ModeFlag; | |
3446 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex]. | |
3447 | Ext_RESINFO; /* si+Ext_ResInfo */ | |
cc1e2398 | 3448 | } |
d7636e0b | 3449 | |
cc1e2398 | 3450 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
58839b01 | 3451 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x35); |
cc1e2398 AK |
3452 | tempbx = temp; |
3453 | if (tempbx & SetPALTV) { | |
1d7f656d KT |
3454 | tempbx &= (SetCHTVOverScan | |
3455 | SetPALMTV | | |
3456 | SetPALNTV | | |
3457 | SetPALTV); | |
cc1e2398 | 3458 | if (tempbx & SetPALMTV) |
1d7f656d KT |
3459 | /* set to NTSC if PAL-M */ |
3460 | tempbx &= ~SetPALTV; | |
cc1e2398 | 3461 | } else |
1d7f656d KT |
3462 | tempbx &= (SetCHTVOverScan | |
3463 | SetNTSCJ | | |
3464 | SetPALTV); | |
cc1e2398 AK |
3465 | /* |
3466 | if (pVBInfo->IF_DEF_LVDS == 0) { | |
1d7f656d KT |
3467 | //PAL-M/PAL-N Info |
3468 | index1 = xgifb_reg_get(pVBInfo->P3d4, 0x38); | |
3469 | //00:PAL, 01:PAL-M, 10:PAL-N | |
3470 | temp2 = (index1 & 0xC0) >> 5; | |
cc1e2398 | 3471 | tempbx |= temp2; |
1d7f656d | 3472 | if (temp2 & 0x02) //PAL-M |
cc1e2398 AK |
3473 | tempbx &= (~SetPALTV); |
3474 | } | |
3475 | */ | |
3476 | } | |
d7636e0b | 3477 | |
cc1e2398 AK |
3478 | if (pVBInfo->IF_DEF_LVDS == 0) { |
3479 | if (pVBInfo->VBInfo & SetCRT2ToSCART) | |
3480 | tempbx |= SetPALTV; | |
3481 | } | |
d7636e0b | 3482 | |
cc1e2398 AK |
3483 | if (pVBInfo->IF_DEF_YPbPr == 1) { |
3484 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { | |
58839b01 | 3485 | index1 = xgifb_reg_get(pVBInfo->P3d4, 0x35); |
cc1e2398 | 3486 | index1 &= YPbPrMode; |
d7636e0b | 3487 | |
cc1e2398 AK |
3488 | if (index1 == YPbPrMode525i) |
3489 | tempbx |= SetYPbPrMode525i; | |
21df8fc8 | 3490 | |
cc1e2398 AK |
3491 | if (index1 == YPbPrMode525p) |
3492 | tempbx = tempbx | SetYPbPrMode525p; | |
3493 | if (index1 == YPbPrMode750p) | |
3494 | tempbx = tempbx | SetYPbPrMode750p; | |
3495 | } | |
3496 | } | |
21df8fc8 | 3497 | |
cc1e2398 AK |
3498 | if (pVBInfo->IF_DEF_HiVision == 1) { |
3499 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) | |
3500 | tempbx = tempbx | SetYPbPrMode1080i | SetPALTV; | |
3501 | } | |
21df8fc8 | 3502 | |
cc1e2398 | 3503 | if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */ |
1d7f656d KT |
3504 | if ((pVBInfo->VBInfo & SetInSlaveMode) && |
3505 | (!(pVBInfo->VBInfo & SetNotSimuMode))) | |
cc1e2398 AK |
3506 | tempbx |= TVSimuMode; |
3507 | ||
1d7f656d KT |
3508 | if (!(tempbx & SetPALTV) && |
3509 | (modeflag > 13) && | |
3510 | (resinfo == 8)) /* NTSC 1024x768, */ | |
cc1e2398 AK |
3511 | tempbx |= NTSC1024x768; |
3512 | ||
3513 | tempbx |= RPLLDIV2XO; | |
21df8fc8 | 3514 | |
cc1e2398 AK |
3515 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
3516 | if (pVBInfo->VBInfo & SetInSlaveMode) | |
3517 | tempbx &= (~RPLLDIV2XO); | |
3518 | } else { | |
1d7f656d KT |
3519 | if (tempbx & |
3520 | (SetYPbPrMode525p | SetYPbPrMode750p)) | |
cc1e2398 | 3521 | tempbx &= (~RPLLDIV2XO); |
1d7f656d KT |
3522 | else if (!(pVBInfo->VBType & |
3523 | (VB_XGI301B | | |
3524 | VB_XGI302B | | |
3525 | VB_XGI301LV | | |
3526 | VB_XGI302LV | | |
3527 | VB_XGI301C))) { | |
cc1e2398 AK |
3528 | if (tempbx & TVSimuMode) |
3529 | tempbx &= (~RPLLDIV2XO); | |
21df8fc8 | 3530 | } |
21df8fc8 | 3531 | } |
cc1e2398 AK |
3532 | } |
3533 | } | |
3534 | pVBInfo->TVInfo = tempbx; | |
3535 | } | |
21df8fc8 | 3536 | |
cc1e2398 AK |
3537 | unsigned char XGI_GetLCDInfo(unsigned short ModeNo, unsigned short ModeIdIndex, |
3538 | struct vb_device_info *pVBInfo) | |
3539 | { | |
3540 | unsigned short temp, tempax, tempbx, modeflag, resinfo = 0, LCDIdIndex; | |
21df8fc8 | 3541 | |
cc1e2398 AK |
3542 | pVBInfo->LCDResInfo = 0; |
3543 | pVBInfo->LCDTypeInfo = 0; | |
3544 | pVBInfo->LCDInfo = 0; | |
21df8fc8 | 3545 | |
cc1e2398 | 3546 | if (ModeNo <= 0x13) { |
1d7f656d KT |
3547 | /* si+St_ModeFlag // */ |
3548 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
cc1e2398 AK |
3549 | } else { |
3550 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
1d7f656d KT |
3551 | /* si+Ext_ResInfo // */ |
3552 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; | |
cc1e2398 | 3553 | } |
21df8fc8 | 3554 | |
58839b01 | 3555 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x36); /* Get LCD Res.Info */ |
cc1e2398 | 3556 | tempbx = temp & 0x0F; |
21df8fc8 | 3557 | |
cc1e2398 AK |
3558 | if (tempbx == 0) |
3559 | tempbx = Panel1024x768; /* default */ | |
3560 | ||
3561 | /* LCD75 [2003/8/22] Vicent */ | |
3562 | if ((tempbx == Panel1024x768) || (tempbx == Panel1280x1024)) { | |
3563 | if (pVBInfo->VBInfo & DriverMode) { | |
58839b01 | 3564 | tempax = xgifb_reg_get(pVBInfo->P3d4, 0x33); |
cc1e2398 AK |
3565 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) |
3566 | tempax &= 0x0F; | |
21df8fc8 | 3567 | else |
cc1e2398 | 3568 | tempax = tempax >> 4; |
21df8fc8 | 3569 | |
cc1e2398 AK |
3570 | if ((resinfo == 6) || (resinfo == 9)) { |
3571 | if (tempax >= 3) | |
3572 | tempbx |= PanelRef75Hz; | |
3573 | } else if ((resinfo == 7) || (resinfo == 8)) { | |
3574 | if (tempax >= 4) | |
3575 | tempbx |= PanelRef75Hz; | |
21df8fc8 | 3576 | } |
cc1e2398 AK |
3577 | } |
3578 | } | |
21df8fc8 | 3579 | |
cc1e2398 | 3580 | pVBInfo->LCDResInfo = tempbx; |
21df8fc8 | 3581 | |
cc1e2398 | 3582 | /* End of LCD75 */ |
21df8fc8 | 3583 | |
cc1e2398 AK |
3584 | if (pVBInfo->IF_DEF_OEMUtil == 1) |
3585 | pVBInfo->LCDTypeInfo = (temp & 0xf0) >> 4; | |
21df8fc8 | 3586 | |
cc1e2398 AK |
3587 | if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))) |
3588 | return 0; | |
21df8fc8 | 3589 | |
cc1e2398 | 3590 | tempbx = 0; |
21df8fc8 | 3591 | |
58839b01 | 3592 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
d7636e0b | 3593 | |
cc1e2398 | 3594 | temp &= (ScalingLCD | LCDNonExpanding | LCDSyncBit | SetPWDEnable); |
d7636e0b | 3595 | |
cc1e2398 AK |
3596 | if ((pVBInfo->IF_DEF_ScaleLCD == 1) && (temp & LCDNonExpanding)) |
3597 | temp &= ~EnableScalingLCD; | |
d7636e0b | 3598 | |
cc1e2398 | 3599 | tempbx |= temp; |
d7636e0b | 3600 | |
cc1e2398 | 3601 | LCDIdIndex = XGI_GetLCDCapPtr1(pVBInfo); |
d7636e0b | 3602 | |
cc1e2398 | 3603 | tempax = pVBInfo->LCDCapList[LCDIdIndex].LCD_Capability; |
d7636e0b | 3604 | |
cc1e2398 AK |
3605 | if (pVBInfo->IF_DEF_LVDS == 0) { /* shampoo */ |
3606 | if (((pVBInfo->VBType & VB_XGI302LV) || (pVBInfo->VBType | |
3607 | & VB_XGI301C)) && (tempax & LCDDualLink)) { | |
3608 | tempbx |= SetLCDDualLink; | |
21df8fc8 | 3609 | } |
21df8fc8 | 3610 | } |
21df8fc8 | 3611 | |
cc1e2398 AK |
3612 | if (pVBInfo->IF_DEF_LVDS == 0) { |
3613 | if ((pVBInfo->LCDResInfo == Panel1400x1050) && (pVBInfo->VBInfo | |
3614 | & SetCRT2ToLCD) && (ModeNo > 0x13) && (resinfo | |
3615 | == 9) && (!(tempbx & EnableScalingLCD))) | |
1d7f656d KT |
3616 | /* set to center in 1280x1024 LCDB for Panel1400x1050 */ |
3617 | tempbx |= SetLCDtoNonExpanding; | |
cc1e2398 | 3618 | } |
21df8fc8 | 3619 | |
cc1e2398 AK |
3620 | /* |
3621 | if (tempax & LCDBToA) { | |
3622 | tempbx |= SetLCDBToA; | |
3623 | } | |
3624 | */ | |
21df8fc8 | 3625 | |
cc1e2398 AK |
3626 | if (pVBInfo->IF_DEF_ExpLink == 1) { |
3627 | if (modeflag & HalfDCLK) { | |
3628 | /* if (!(pVBInfo->LCDInfo&LCDNonExpanding)) */ | |
3629 | if (!(tempbx & SetLCDtoNonExpanding)) { | |
3630 | tempbx |= EnableLVDSDDA; | |
3631 | } else { | |
3632 | if (ModeNo > 0x13) { | |
3633 | if (pVBInfo->LCDResInfo | |
3634 | == Panel1024x768) { | |
1d7f656d | 3635 | if (resinfo == 4) {/* 512x384 */ |
cc1e2398 AK |
3636 | tempbx |= EnableLVDSDDA; |
3637 | } | |
3638 | } | |
3639 | } | |
3640 | } | |
3641 | } | |
3642 | } | |
21df8fc8 | 3643 | |
cc1e2398 AK |
3644 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
3645 | if (pVBInfo->VBInfo & SetNotSimuMode) | |
3646 | tempbx |= LCDVESATiming; | |
3647 | } else { | |
3648 | tempbx |= LCDVESATiming; | |
3649 | } | |
21df8fc8 | 3650 | |
cc1e2398 | 3651 | pVBInfo->LCDInfo = tempbx; |
d7636e0b | 3652 | |
cc1e2398 AK |
3653 | if (pVBInfo->IF_DEF_PWD == 1) { |
3654 | if (pVBInfo->LCDInfo & SetPWDEnable) { | |
1d7f656d KT |
3655 | if ((pVBInfo->VBType & VB_XGI302LV) || |
3656 | (pVBInfo->VBType & VB_XGI301C)) { | |
cc1e2398 AK |
3657 | if (!(tempax & PWDEnable)) |
3658 | pVBInfo->LCDInfo &= ~SetPWDEnable; | |
3659 | } | |
3660 | } | |
3661 | } | |
d7636e0b | 3662 | |
cc1e2398 AK |
3663 | if (pVBInfo->IF_DEF_LVDS == 0) { |
3664 | if (tempax & (LockLCDBToA | StLCDBToA)) { | |
3665 | if (pVBInfo->VBInfo & SetInSlaveMode) { | |
3666 | if (!(tempax & LockLCDBToA)) { | |
3667 | if (ModeNo <= 0x13) { | |
1d7f656d KT |
3668 | pVBInfo->VBInfo &= |
3669 | ~(SetSimuScanMode | | |
3670 | SetInSlaveMode | | |
3671 | SetCRT2ToLCD); | |
3672 | pVBInfo->VBInfo |= | |
3673 | SetCRT2ToLCDA | | |
3674 | SetCRT2ToDualEdge; | |
cc1e2398 AK |
3675 | } |
3676 | } | |
3677 | } | |
3678 | } | |
3679 | } | |
21df8fc8 | 3680 | |
cc1e2398 AK |
3681 | /* |
3682 | if (pVBInfo->IF_DEF_LVDS == 0) { | |
3683 | if (tempax & (LockLCDBToA | StLCDBToA)) { | |
3684 | if (pVBInfo->VBInfo & SetInSlaveMode) { | |
1d7f656d KT |
3685 | if (!((!(tempax & LockLCDBToA)) && |
3686 | (ModeNo > 0x13))) { | |
3687 | pVBInfo->VBInfo &= | |
3688 | ~(SetSimuScanMode | | |
3689 | SetInSlaveMode | | |
3690 | SetCRT2ToLCD); | |
3691 | pVBInfo->VBInfo |= | |
3692 | SetCRT2ToLCDA | | |
3693 | SetCRT2ToDualEdge; | |
cc1e2398 AK |
3694 | } |
3695 | } | |
3696 | } | |
21df8fc8 | 3697 | } |
cc1e2398 | 3698 | */ |
d7636e0b | 3699 | |
cc1e2398 | 3700 | return 1; |
21df8fc8 | 3701 | } |
d7636e0b | 3702 | |
cc1e2398 AK |
3703 | unsigned char XGI_SearchModeID(unsigned short ModeNo, |
3704 | unsigned short *ModeIdIndex, struct vb_device_info *pVBInfo) | |
d7636e0b | 3705 | { |
cc1e2398 AK |
3706 | if (ModeNo <= 5) |
3707 | ModeNo |= 1; | |
3708 | if (ModeNo <= 0x13) { | |
1d7f656d KT |
3709 | /* for (*ModeIdIndex=0; |
3710 | *ModeIdIndex < sizeof(pVBInfo->SModeIDTable) | |
3711 | / sizeof(struct XGI_StStruct); | |
3712 | (*ModeIdIndex)++) */ | |
cc1e2398 | 3713 | for (*ModeIdIndex = 0;; (*ModeIdIndex)++) { |
1d7f656d KT |
3714 | if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == |
3715 | ModeNo) | |
cc1e2398 | 3716 | break; |
1d7f656d KT |
3717 | if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID == |
3718 | 0xFF) | |
cc1e2398 AK |
3719 | return 0; |
3720 | } | |
d7636e0b | 3721 | |
cc1e2398 AK |
3722 | if (ModeNo == 0x07) |
3723 | (*ModeIdIndex)++; /* 400 lines */ | |
3724 | if (ModeNo <= 3) | |
3725 | (*ModeIdIndex) += 2; /* 400 lines */ | |
3726 | /* else 350 lines */ | |
3727 | } else { | |
1d7f656d KT |
3728 | /* for (*ModeIdIndex=0; |
3729 | *ModeIdIndex < sizeof(pVBInfo->EModeIDTable) | |
3730 | / sizeof(struct XGI_ExtStruct); | |
3731 | (*ModeIdIndex)++) */ | |
cc1e2398 | 3732 | for (*ModeIdIndex = 0;; (*ModeIdIndex)++) { |
1d7f656d KT |
3733 | if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == |
3734 | ModeNo) | |
cc1e2398 | 3735 | break; |
1d7f656d KT |
3736 | if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == |
3737 | 0xFF) | |
cc1e2398 AK |
3738 | return 0; |
3739 | } | |
21df8fc8 | 3740 | } |
d7636e0b | 3741 | |
cc1e2398 | 3742 | return 1; |
21df8fc8 | 3743 | } |
d7636e0b | 3744 | |
cc1e2398 AK |
3745 | static unsigned char XG21GPIODataTransfer(unsigned char ujDate) |
3746 | { | |
3747 | unsigned char ujRet = 0; | |
3748 | unsigned char i = 0; | |
21df8fc8 | 3749 | |
cc1e2398 AK |
3750 | for (i = 0; i < 8; i++) { |
3751 | ujRet = ujRet << 1; | |
3752 | /* ujRet |= GETBITS(ujDate >> i, 0:0); */ | |
3753 | ujRet |= (ujDate >> i) & 1; | |
21df8fc8 | 3754 | } |
d7636e0b | 3755 | |
cc1e2398 AK |
3756 | return ujRet; |
3757 | } | |
21df8fc8 | 3758 | |
cc1e2398 AK |
3759 | /*----------------------------------------------------------------------------*/ |
3760 | /* output */ | |
3761 | /* bl[5] : LVDS signal */ | |
3762 | /* bl[1] : LVDS backlight */ | |
3763 | /* bl[0] : LVDS VDD */ | |
3764 | /*----------------------------------------------------------------------------*/ | |
3765 | static unsigned char XGI_XG21GetPSCValue(struct vb_device_info *pVBInfo) | |
3766 | { | |
3767 | unsigned char CR4A, temp; | |
21df8fc8 | 3768 | |
58839b01 | 3769 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
dc50556b | 3770 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x23); /* enable GPIO write */ |
21df8fc8 | 3771 | |
58839b01 | 3772 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
21df8fc8 | 3773 | |
cc1e2398 AK |
3774 | temp = XG21GPIODataTransfer(temp); |
3775 | temp &= 0x23; | |
8104e329 | 3776 | xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A); |
cc1e2398 AK |
3777 | return temp; |
3778 | } | |
3779 | ||
3780 | /*----------------------------------------------------------------------------*/ | |
3781 | /* output */ | |
3782 | /* bl[5] : LVDS signal */ | |
3783 | /* bl[1] : LVDS backlight */ | |
3784 | /* bl[0] : LVDS VDD */ | |
3785 | /*----------------------------------------------------------------------------*/ | |
3786 | static unsigned char XGI_XG27GetPSCValue(struct vb_device_info *pVBInfo) | |
3787 | { | |
3788 | unsigned char CR4A, CRB4, temp; | |
21df8fc8 | 3789 | |
58839b01 | 3790 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
dc50556b | 3791 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x0C); /* enable GPIO write */ |
21df8fc8 | 3792 | |
58839b01 | 3793 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
21df8fc8 | 3794 | |
cc1e2398 AK |
3795 | temp &= 0x0C; |
3796 | temp >>= 2; | |
8104e329 | 3797 | xgifb_reg_set(pVBInfo->P3d4, 0x4A, CR4A); |
58839b01 | 3798 | CRB4 = xgifb_reg_get(pVBInfo->P3d4, 0xB4); |
cc1e2398 AK |
3799 | temp |= ((CRB4 & 0x04) << 3); |
3800 | return temp; | |
3801 | } | |
21df8fc8 | 3802 | |
cc1e2398 AK |
3803 | void XGI_DisplayOn(struct xgi_hw_device_info *pXGIHWDE, |
3804 | struct vb_device_info *pVBInfo) | |
3805 | { | |
3806 | ||
ec9e5d3e | 3807 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x00); |
cc1e2398 AK |
3808 | if (pXGIHWDE->jChipType == XG21) { |
3809 | if (pVBInfo->IF_DEF_LVDS == 1) { | |
3810 | if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x1)) { | |
1d7f656d KT |
3811 | /* LVDS VDD on */ |
3812 | XGI_XG21BLSignalVDD(0x01, 0x01, pVBInfo); | |
cc1e2398 AK |
3813 | XGI_XG21SetPanelDelay(2, pVBInfo); |
3814 | } | |
3815 | if (!(XGI_XG21GetPSCValue(pVBInfo) & 0x20)) | |
1d7f656d KT |
3816 | /* LVDS signal on */ |
3817 | XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); | |
cc1e2398 | 3818 | XGI_XG21SetPanelDelay(3, pVBInfo); |
1d7f656d KT |
3819 | /* LVDS backlight on */ |
3820 | XGI_XG21BLSignalVDD(0x02, 0x02, pVBInfo); | |
cc1e2398 | 3821 | } else { |
1d7f656d KT |
3822 | /* DVO/DVI signal on */ |
3823 | XGI_XG21BLSignalVDD(0x20, 0x20, pVBInfo); | |
cc1e2398 | 3824 | } |
21df8fc8 | 3825 | |
21df8fc8 PS |
3826 | } |
3827 | ||
cc1e2398 AK |
3828 | if (pXGIHWDE->jChipType == XG27) { |
3829 | if (pVBInfo->IF_DEF_LVDS == 1) { | |
3830 | if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x1)) { | |
1d7f656d KT |
3831 | /* LVDS VDD on */ |
3832 | XGI_XG27BLSignalVDD(0x01, 0x01, pVBInfo); | |
cc1e2398 AK |
3833 | XGI_XG21SetPanelDelay(2, pVBInfo); |
3834 | } | |
3835 | if (!(XGI_XG27GetPSCValue(pVBInfo) & 0x20)) | |
1d7f656d KT |
3836 | /* LVDS signal on */ |
3837 | XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); | |
cc1e2398 | 3838 | XGI_XG21SetPanelDelay(3, pVBInfo); |
1d7f656d KT |
3839 | /* LVDS backlight on */ |
3840 | XGI_XG27BLSignalVDD(0x02, 0x02, pVBInfo); | |
cc1e2398 | 3841 | } else { |
1d7f656d KT |
3842 | /* DVO/DVI signal on */ |
3843 | XGI_XG27BLSignalVDD(0x20, 0x20, pVBInfo); | |
cc1e2398 | 3844 | } |
21df8fc8 | 3845 | |
cc1e2398 | 3846 | } |
d7636e0b | 3847 | } |
3848 | ||
cc1e2398 | 3849 | void XGI_DisplayOff(struct xgi_hw_device_info *pXGIHWDE, |
21df8fc8 PS |
3850 | struct vb_device_info *pVBInfo) |
3851 | { | |
d7636e0b | 3852 | |
cc1e2398 AK |
3853 | if (pXGIHWDE->jChipType == XG21) { |
3854 | if (pVBInfo->IF_DEF_LVDS == 1) { | |
1d7f656d KT |
3855 | /* LVDS backlight off */ |
3856 | XGI_XG21BLSignalVDD(0x02, 0x00, pVBInfo); | |
cc1e2398 AK |
3857 | XGI_XG21SetPanelDelay(3, pVBInfo); |
3858 | } else { | |
1d7f656d KT |
3859 | /* DVO/DVI signal off */ |
3860 | XGI_XG21BLSignalVDD(0x20, 0x00, pVBInfo); | |
cc1e2398 | 3861 | } |
21df8fc8 PS |
3862 | } |
3863 | ||
cc1e2398 AK |
3864 | if (pXGIHWDE->jChipType == XG27) { |
3865 | if ((XGI_XG27GetPSCValue(pVBInfo) & 0x2)) { | |
1d7f656d KT |
3866 | /* LVDS backlight off */ |
3867 | XGI_XG27BLSignalVDD(0x02, 0x00, pVBInfo); | |
cc1e2398 AK |
3868 | XGI_XG21SetPanelDelay(3, pVBInfo); |
3869 | } | |
21df8fc8 | 3870 | |
cc1e2398 | 3871 | if (pVBInfo->IF_DEF_LVDS == 0) |
1d7f656d KT |
3872 | /* DVO/DVI signal off */ |
3873 | XGI_XG27BLSignalVDD(0x20, 0x00, pVBInfo); | |
cc1e2398 | 3874 | } |
21df8fc8 | 3875 | |
ec9e5d3e | 3876 | xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x20); |
cc1e2398 | 3877 | } |
21df8fc8 | 3878 | |
cc1e2398 AK |
3879 | static void XGI_WaitDisply(struct vb_device_info *pVBInfo) |
3880 | { | |
d8ad0a6d | 3881 | while ((inb(pVBInfo->P3da) & 0x01)) |
cc1e2398 | 3882 | break; |
21df8fc8 | 3883 | |
d8ad0a6d | 3884 | while (!(inb(pVBInfo->P3da) & 0x01)) |
cc1e2398 AK |
3885 | break; |
3886 | } | |
21df8fc8 | 3887 | |
cc1e2398 AK |
3888 | static void XGI_AutoThreshold(struct vb_device_info *pVBInfo) |
3889 | { | |
3890 | if (!(pVBInfo->SetFlag & Win9xDOSMode)) | |
b9bf6e4e | 3891 | xgifb_reg_or(pVBInfo->Part1Port, 0x01, 0x40); |
cc1e2398 | 3892 | } |
21df8fc8 | 3893 | |
1d7f656d KT |
3894 | static void XGI_SaveCRT2Info(unsigned short ModeNo, |
3895 | struct vb_device_info *pVBInfo) | |
cc1e2398 AK |
3896 | { |
3897 | unsigned short temp1, temp2; | |
21df8fc8 | 3898 | |
1d7f656d KT |
3899 | /* reserve CR34 for CRT1 Mode No */ |
3900 | xgifb_reg_set(pVBInfo->P3d4, 0x34, ModeNo); | |
cc1e2398 AK |
3901 | temp1 = (pVBInfo->VBInfo & SetInSlaveMode) >> 8; |
3902 | temp2 = ~(SetInSlaveMode >> 8); | |
ec9e5d3e | 3903 | xgifb_reg_and_or(pVBInfo->P3d4, 0x31, temp2, temp1); |
cc1e2398 | 3904 | } |
21df8fc8 | 3905 | |
1d7f656d KT |
3906 | static void XGI_GetCRT2ResInfo(unsigned short ModeNo, |
3907 | unsigned short ModeIdIndex, | |
3908 | struct vb_device_info *pVBInfo) | |
cc1e2398 AK |
3909 | { |
3910 | unsigned short xres, yres, modeflag, resindex; | |
21df8fc8 | 3911 | |
cc1e2398 AK |
3912 | resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); |
3913 | if (ModeNo <= 0x13) { | |
3914 | xres = pVBInfo->StResInfo[resindex].HTotal; | |
3915 | yres = pVBInfo->StResInfo[resindex].VTotal; | |
1d7f656d KT |
3916 | /* si+St_ResInfo */ |
3917 | /* modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;*/ | |
21df8fc8 | 3918 | } else { |
cc1e2398 AK |
3919 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ |
3920 | yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */ | |
1d7f656d KT |
3921 | /* si+St_ModeFlag */ |
3922 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
21df8fc8 | 3923 | |
cc1e2398 AK |
3924 | /* |
3925 | if (pVBInfo->IF_DEF_FSTN) { | |
3926 | xres *= 2; | |
3927 | yres *= 2; | |
3928 | } else { | |
3929 | */ | |
3930 | if (modeflag & HalfDCLK) | |
3931 | xres *= 2; | |
21df8fc8 | 3932 | |
cc1e2398 AK |
3933 | if (modeflag & DoubleScanMode) |
3934 | yres *= 2; | |
3935 | /* } */ | |
3936 | } | |
21df8fc8 | 3937 | |
cc1e2398 AK |
3938 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
3939 | if (pVBInfo->IF_DEF_LVDS == 0) { | |
3940 | if (pVBInfo->LCDResInfo == Panel1600x1200) { | |
3941 | if (!(pVBInfo->LCDInfo & LCDVESATiming)) { | |
3942 | if (yres == 1024) | |
3943 | yres = 1056; | |
21df8fc8 PS |
3944 | } |
3945 | } | |
3946 | ||
cc1e2398 AK |
3947 | if (pVBInfo->LCDResInfo == Panel1280x1024) { |
3948 | if (yres == 400) | |
3949 | yres = 405; | |
3950 | else if (yres == 350) | |
3951 | yres = 360; | |
3952 | ||
3953 | if (pVBInfo->LCDInfo & LCDVESATiming) { | |
3954 | if (yres == 360) | |
3955 | yres = 375; | |
21df8fc8 PS |
3956 | } |
3957 | } | |
3958 | ||
cc1e2398 AK |
3959 | if (pVBInfo->LCDResInfo == Panel1024x768) { |
3960 | if (!(pVBInfo->LCDInfo & LCDVESATiming)) { | |
3961 | if (!(pVBInfo->LCDInfo | |
3962 | & LCDNonExpanding)) { | |
3963 | if (yres == 350) | |
3964 | yres = 357; | |
3965 | else if (yres == 400) | |
3966 | yres = 420; | |
3967 | else if (yres == 480) | |
3968 | yres = 525; | |
3969 | } | |
21df8fc8 PS |
3970 | } |
3971 | } | |
3972 | } | |
cc1e2398 AK |
3973 | |
3974 | if (xres == 720) | |
3975 | xres = 640; | |
21df8fc8 PS |
3976 | } |
3977 | ||
cc1e2398 AK |
3978 | pVBInfo->VGAHDE = xres; |
3979 | pVBInfo->HDE = xres; | |
3980 | pVBInfo->VGAVDE = yres; | |
3981 | pVBInfo->VDE = yres; | |
3982 | } | |
21df8fc8 | 3983 | |
cc1e2398 AK |
3984 | static unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo) |
3985 | { | |
21df8fc8 | 3986 | |
cc1e2398 AK |
3987 | if ((pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) && |
3988 | (pVBInfo->LCDInfo & SetLCDDualLink)) /* shampoo0129 */ | |
3989 | return 1; | |
21df8fc8 | 3990 | |
cc1e2398 AK |
3991 | return 0; |
3992 | } | |
3993 | ||
1d7f656d KT |
3994 | static void XGI_GetRAMDAC2DATA(unsigned short ModeNo, |
3995 | unsigned short ModeIdIndex, | |
3996 | unsigned short RefreshRateTableIndex, | |
3997 | struct vb_device_info *pVBInfo) | |
cc1e2398 AK |
3998 | { |
3999 | unsigned short tempax, tempbx, temp1, temp2, modeflag = 0, tempcx, | |
4000 | StandTableIndex, CRT1Index; | |
4001 | ||
4002 | pVBInfo->RVBHCMAX = 1; | |
4003 | pVBInfo->RVBHCFACT = 1; | |
4004 | ||
4005 | if (ModeNo <= 0x13) { | |
4006 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
4007 | StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo); | |
4008 | tempax = pVBInfo->StandTable[StandTableIndex].CRTC[0]; | |
4009 | tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[6]; | |
4010 | temp1 = pVBInfo->StandTable[StandTableIndex].CRTC[7]; | |
4011 | } else { | |
4012 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
1d7f656d KT |
4013 | CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex]. |
4014 | Ext_CRT1CRTC; | |
cc1e2398 | 4015 | CRT1Index &= IndexMask; |
1d7f656d KT |
4016 | temp1 = (unsigned short) pVBInfo-> |
4017 | XGINEWUB_CRT1Table[CRT1Index].CR[0]; | |
4018 | temp2 = (unsigned short) pVBInfo-> | |
4019 | XGINEWUB_CRT1Table[CRT1Index].CR[5]; | |
cc1e2398 | 4020 | tempax = (temp1 & 0xFF) | ((temp2 & 0x03) << 8); |
1d7f656d KT |
4021 | tempbx = (unsigned short) pVBInfo-> |
4022 | XGINEWUB_CRT1Table[CRT1Index].CR[8]; | |
4023 | tempcx = (unsigned short) pVBInfo-> | |
4024 | XGINEWUB_CRT1Table[CRT1Index].CR[14] << 8; | |
cc1e2398 AK |
4025 | tempcx &= 0x0100; |
4026 | tempcx = tempcx << 2; | |
4027 | tempbx |= tempcx; | |
1d7f656d KT |
4028 | temp1 = (unsigned short) pVBInfo-> |
4029 | XGINEWUB_CRT1Table[CRT1Index].CR[9]; | |
cc1e2398 AK |
4030 | } |
4031 | ||
4032 | if (temp1 & 0x01) | |
4033 | tempbx |= 0x0100; | |
4034 | ||
4035 | if (temp1 & 0x20) | |
4036 | tempbx |= 0x0200; | |
4037 | tempax += 5; | |
4038 | ||
4039 | if (modeflag & Charx8Dot) | |
4040 | tempax *= 8; | |
4041 | else | |
4042 | tempax *= 9; | |
4043 | ||
4044 | pVBInfo->VGAHT = tempax; | |
4045 | pVBInfo->HT = tempax; | |
4046 | tempbx++; | |
4047 | pVBInfo->VGAVT = tempbx; | |
4048 | pVBInfo->VT = tempbx; | |
4049 | } | |
4050 | ||
4051 | static void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex, | |
4052 | unsigned short RefreshRateTableIndex, | |
4053 | struct vb_device_info *pVBInfo) | |
4054 | { | |
4055 | unsigned short tempax = 0, tempbx, modeflag, resinfo; | |
4056 | ||
4057 | struct XGI_LCDDataStruct *LCDPtr = NULL; | |
4058 | struct XGI_TVDataStruct *TVPtr = NULL; | |
4059 | ||
4060 | if (ModeNo <= 0x13) { | |
1d7f656d KT |
4061 | /* si+St_ResInfo */ |
4062 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
cc1e2398 AK |
4063 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
4064 | } else { | |
1d7f656d KT |
4065 | /* si+Ext_ResInfo */ |
4066 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
cc1e2398 AK |
4067 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
4068 | } | |
4069 | ||
4070 | pVBInfo->NewFlickerMode = 0; | |
4071 | pVBInfo->RVBHRS = 50; | |
4072 | ||
4073 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { | |
4074 | XGI_GetRAMDAC2DATA(ModeNo, ModeIdIndex, RefreshRateTableIndex, | |
4075 | pVBInfo); | |
4076 | return; | |
4077 | } | |
4078 | ||
4079 | tempbx = 4; | |
4080 | ||
4081 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { | |
4082 | LCDPtr = (struct XGI_LCDDataStruct *) XGI_GetLcdPtr(tempbx, | |
4083 | ModeNo, ModeIdIndex, RefreshRateTableIndex, | |
4084 | pVBInfo); | |
4085 | ||
4086 | pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX; | |
4087 | pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT; | |
4088 | pVBInfo->VGAHT = LCDPtr->VGAHT; | |
4089 | pVBInfo->VGAVT = LCDPtr->VGAVT; | |
4090 | pVBInfo->HT = LCDPtr->LCDHT; | |
4091 | pVBInfo->VT = LCDPtr->LCDVT; | |
21df8fc8 | 4092 | |
21df8fc8 | 4093 | if (pVBInfo->LCDResInfo == Panel1024x768) { |
cc1e2398 AK |
4094 | tempax = 1024; |
4095 | tempbx = 768; | |
4096 | ||
4097 | if (!(pVBInfo->LCDInfo & LCDVESATiming)) { | |
4098 | if (pVBInfo->VGAVDE == 357) | |
4099 | tempbx = 527; | |
4100 | else if (pVBInfo->VGAVDE == 420) | |
4101 | tempbx = 620; | |
4102 | else if (pVBInfo->VGAVDE == 525) | |
4103 | tempbx = 775; | |
4104 | else if (pVBInfo->VGAVDE == 600) | |
4105 | tempbx = 775; | |
4106 | /* else if (pVBInfo->VGAVDE==350) tempbx=560; */ | |
4107 | /* else if (pVBInfo->VGAVDE==400) tempbx=640; */ | |
4108 | else | |
4109 | tempbx = 768; | |
4110 | } else | |
4111 | tempbx = 768; | |
4112 | } else if (pVBInfo->LCDResInfo == Panel1024x768x75) { | |
4113 | tempax = 1024; | |
4114 | tempbx = 768; | |
4115 | } else if (pVBInfo->LCDResInfo == Panel1280x1024) { | |
4116 | tempax = 1280; | |
4117 | if (pVBInfo->VGAVDE == 360) | |
4118 | tempbx = 768; | |
4119 | else if (pVBInfo->VGAVDE == 375) | |
4120 | tempbx = 800; | |
4121 | else if (pVBInfo->VGAVDE == 405) | |
4122 | tempbx = 864; | |
4123 | else | |
4124 | tempbx = 1024; | |
4125 | } else if (pVBInfo->LCDResInfo == Panel1280x1024x75) { | |
4126 | tempax = 1280; | |
4127 | tempbx = 1024; | |
4128 | } else if (pVBInfo->LCDResInfo == Panel1280x960) { | |
4129 | tempax = 1280; | |
4130 | if (pVBInfo->VGAVDE == 350) | |
4131 | tempbx = 700; | |
4132 | else if (pVBInfo->VGAVDE == 400) | |
4133 | tempbx = 800; | |
4134 | else if (pVBInfo->VGAVDE == 1024) | |
4135 | tempbx = 960; | |
4136 | else | |
4137 | tempbx = 960; | |
4138 | } else if (pVBInfo->LCDResInfo == Panel1400x1050) { | |
4139 | tempax = 1400; | |
4140 | tempbx = 1050; | |
4141 | ||
4142 | if (pVBInfo->VGAVDE == 1024) { | |
4143 | tempax = 1280; | |
4144 | tempbx = 1024; | |
4145 | } | |
4146 | } else if (pVBInfo->LCDResInfo == Panel1600x1200) { | |
4147 | tempax = 1600; | |
4148 | tempbx = 1200; /* alan 10/14/2003 */ | |
21df8fc8 | 4149 | if (!(pVBInfo->LCDInfo & LCDVESATiming)) { |
cc1e2398 AK |
4150 | if (pVBInfo->VGAVDE == 350) |
4151 | tempbx = 875; | |
4152 | else if (pVBInfo->VGAVDE == 400) | |
4153 | tempbx = 1000; | |
21df8fc8 PS |
4154 | } |
4155 | } | |
21df8fc8 | 4156 | |
cc1e2398 AK |
4157 | if (pVBInfo->LCDInfo & LCDNonExpanding) { |
4158 | tempax = pVBInfo->VGAHDE; | |
4159 | tempbx = pVBInfo->VGAVDE; | |
4160 | } | |
21df8fc8 | 4161 | |
cc1e2398 AK |
4162 | pVBInfo->HDE = tempax; |
4163 | pVBInfo->VDE = tempbx; | |
4164 | return; | |
4165 | } | |
21df8fc8 | 4166 | |
cc1e2398 AK |
4167 | if (pVBInfo->VBInfo & (SetCRT2ToTV)) { |
4168 | tempbx = 4; | |
4169 | TVPtr = (struct XGI_TVDataStruct *) XGI_GetTVPtr(tempbx, | |
4170 | ModeNo, ModeIdIndex, RefreshRateTableIndex, | |
4171 | pVBInfo); | |
21df8fc8 | 4172 | |
cc1e2398 AK |
4173 | pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX; |
4174 | pVBInfo->RVBHCFACT = TVPtr->RVBHCFACT; | |
4175 | pVBInfo->VGAHT = TVPtr->VGAHT; | |
4176 | pVBInfo->VGAVT = TVPtr->VGAVT; | |
4177 | pVBInfo->HDE = TVPtr->TVHDE; | |
4178 | pVBInfo->VDE = TVPtr->TVVDE; | |
4179 | pVBInfo->RVBHRS = TVPtr->RVBHRS; | |
4180 | pVBInfo->NewFlickerMode = TVPtr->FlickerMode; | |
21df8fc8 | 4181 | |
cc1e2398 AK |
4182 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
4183 | if (resinfo == 0x08) | |
4184 | pVBInfo->NewFlickerMode = 0x40; | |
4185 | else if (resinfo == 0x09) | |
4186 | pVBInfo->NewFlickerMode = 0x40; | |
4187 | else if (resinfo == 0x12) | |
4188 | pVBInfo->NewFlickerMode = 0x40; | |
21df8fc8 | 4189 | |
cc1e2398 AK |
4190 | if (pVBInfo->VGAVDE == 350) |
4191 | pVBInfo->TVInfo |= TVSimuMode; | |
21df8fc8 | 4192 | |
cc1e2398 AK |
4193 | tempax = ExtHiTVHT; |
4194 | tempbx = ExtHiTVVT; | |
21df8fc8 | 4195 | |
cc1e2398 | 4196 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
21df8fc8 | 4197 | if (pVBInfo->TVInfo & TVSimuMode) { |
cc1e2398 AK |
4198 | tempax = StHiTVHT; |
4199 | tempbx = StHiTVVT; | |
4200 | ||
4201 | if (!(modeflag & Charx8Dot)) { | |
4202 | tempax = StHiTextTVHT; | |
4203 | tempbx = StHiTextTVVT; | |
21df8fc8 PS |
4204 | } |
4205 | } | |
4206 | } | |
cc1e2398 AK |
4207 | } else if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { |
4208 | if (pVBInfo->TVInfo & SetYPbPrMode750p) { | |
4209 | tempax = YPbPrTV750pHT; /* Ext750pTVHT */ | |
4210 | tempbx = YPbPrTV750pVT; /* Ext750pTVVT */ | |
4211 | } | |
4212 | ||
4213 | if (pVBInfo->TVInfo & SetYPbPrMode525p) { | |
4214 | tempax = YPbPrTV525pHT; /* Ext525pTVHT */ | |
4215 | tempbx = YPbPrTV525pVT; /* Ext525pTVVT */ | |
4216 | } else if (pVBInfo->TVInfo & SetYPbPrMode525i) { | |
4217 | tempax = YPbPrTV525iHT; /* Ext525iTVHT */ | |
4218 | tempbx = YPbPrTV525iVT; /* Ext525iTVVT */ | |
4219 | if (pVBInfo->TVInfo & NTSC1024x768) | |
4220 | tempax = NTSC1024x768HT; | |
4221 | } | |
21df8fc8 | 4222 | } else { |
cc1e2398 AK |
4223 | tempax = PALHT; |
4224 | tempbx = PALVT; | |
4225 | if (!(pVBInfo->TVInfo & SetPALTV)) { | |
4226 | tempax = NTSCHT; | |
4227 | tempbx = NTSCVT; | |
4228 | if (pVBInfo->TVInfo & NTSC1024x768) | |
4229 | tempax = NTSC1024x768HT; | |
21df8fc8 PS |
4230 | } |
4231 | } | |
21df8fc8 | 4232 | |
cc1e2398 AK |
4233 | pVBInfo->HT = tempax; |
4234 | pVBInfo->VT = tempbx; | |
4235 | return; | |
21df8fc8 | 4236 | } |
21df8fc8 PS |
4237 | } |
4238 | ||
cc1e2398 | 4239 | static void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex, |
21df8fc8 | 4240 | unsigned short RefreshRateTableIndex, |
21df8fc8 | 4241 | struct vb_device_info *pVBInfo) |
d7636e0b | 4242 | { |
cc1e2398 | 4243 | unsigned char di_0, di_1, tempal; |
21df8fc8 | 4244 | |
cc1e2398 AK |
4245 | tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex, |
4246 | pVBInfo); | |
4247 | XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo); | |
4248 | XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo); | |
21df8fc8 | 4249 | |
cc1e2398 AK |
4250 | if (pVBInfo->VBType & VB_XGI301) { /* shampoo 0129 */ |
4251 | /* 301 */ | |
8104e329 AK |
4252 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, 0x10); |
4253 | xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1); | |
4254 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0); | |
cc1e2398 | 4255 | } else { /* 301b/302b/301lv/302lv */ |
8104e329 AK |
4256 | xgifb_reg_set(pVBInfo->Part4Port, 0x0A, di_0); |
4257 | xgifb_reg_set(pVBInfo->Part4Port, 0x0B, di_1); | |
21df8fc8 PS |
4258 | } |
4259 | ||
8104e329 | 4260 | xgifb_reg_set(pVBInfo->Part4Port, 0x00, 0x12); |
21df8fc8 | 4261 | |
cc1e2398 | 4262 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) |
b9bf6e4e | 4263 | xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x28); |
cc1e2398 | 4264 | else |
b9bf6e4e | 4265 | xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x08); |
cc1e2398 | 4266 | } |
21df8fc8 | 4267 | |
cc1e2398 AK |
4268 | static unsigned short XGI_GetColorDepth(unsigned short ModeNo, |
4269 | unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) | |
4270 | { | |
4271 | unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8 }; | |
4272 | short index; | |
4273 | unsigned short modeflag; | |
21df8fc8 | 4274 | |
cc1e2398 AK |
4275 | if (ModeNo <= 0x13) |
4276 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
4277 | else | |
4278 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
21df8fc8 | 4279 | |
cc1e2398 | 4280 | index = (modeflag & ModeInfoFlag) - ModeEGA; |
21df8fc8 | 4281 | |
cc1e2398 AK |
4282 | if (index < 0) |
4283 | index = 0; | |
21df8fc8 | 4284 | |
cc1e2398 AK |
4285 | return ColorDepth[index]; |
4286 | } | |
21df8fc8 | 4287 | |
1d7f656d KT |
4288 | static unsigned short XGI_GetOffset(unsigned short ModeNo, |
4289 | unsigned short ModeIdIndex, | |
cc1e2398 AK |
4290 | unsigned short RefreshRateTableIndex, |
4291 | struct xgi_hw_device_info *HwDeviceExtension, | |
4292 | struct vb_device_info *pVBInfo) | |
4293 | { | |
4294 | unsigned short temp, colordepth, modeinfo, index, infoflag, | |
4295 | ColorDepth[] = { 0x01, 0x02, 0x04 }; | |
21df8fc8 | 4296 | |
cc1e2398 AK |
4297 | modeinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo; |
4298 | if (ModeNo <= 0x14) | |
4299 | infoflag = 0; | |
4300 | else | |
1d7f656d KT |
4301 | infoflag = pVBInfo-> |
4302 | RefIndex[RefreshRateTableIndex].Ext_InfoFlag; | |
21df8fc8 | 4303 | |
cc1e2398 | 4304 | index = (modeinfo >> 8) & 0xFF; |
21df8fc8 | 4305 | |
cc1e2398 | 4306 | temp = pVBInfo->ScreenOffset[index]; |
21df8fc8 | 4307 | |
cc1e2398 AK |
4308 | if (infoflag & InterlaceMode) |
4309 | temp = temp << 1; | |
21df8fc8 | 4310 | |
cc1e2398 | 4311 | colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo); |
21df8fc8 | 4312 | |
cc1e2398 AK |
4313 | if ((ModeNo >= 0x7C) && (ModeNo <= 0x7E)) { |
4314 | temp = ModeNo - 0x7C; | |
4315 | colordepth = ColorDepth[temp]; | |
4316 | temp = 0x6B; | |
4317 | if (infoflag & InterlaceMode) | |
4318 | temp = temp << 1; | |
4319 | return temp * colordepth; | |
4320 | } else { | |
4321 | return temp * colordepth; | |
21df8fc8 | 4322 | } |
cc1e2398 | 4323 | } |
21df8fc8 | 4324 | |
cc1e2398 AK |
4325 | static void XGI_SetCRT2Offset(unsigned short ModeNo, |
4326 | unsigned short ModeIdIndex, | |
4327 | unsigned short RefreshRateTableIndex, | |
4328 | struct xgi_hw_device_info *HwDeviceExtension, | |
4329 | struct vb_device_info *pVBInfo) | |
4330 | { | |
4331 | unsigned short offset; | |
4332 | unsigned char temp; | |
21df8fc8 | 4333 | |
cc1e2398 AK |
4334 | if (pVBInfo->VBInfo & SetInSlaveMode) |
4335 | return; | |
21df8fc8 | 4336 | |
cc1e2398 AK |
4337 | offset = XGI_GetOffset(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
4338 | HwDeviceExtension, pVBInfo); | |
4339 | temp = (unsigned char) (offset & 0xFF); | |
8104e329 | 4340 | xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp); |
cc1e2398 | 4341 | temp = (unsigned char) ((offset & 0xFF00) >> 8); |
8104e329 | 4342 | xgifb_reg_set(pVBInfo->Part1Port, 0x09, temp); |
cc1e2398 | 4343 | temp = (unsigned char) (((offset >> 3) & 0xFF) + 1); |
8104e329 | 4344 | xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp); |
cc1e2398 | 4345 | } |
21df8fc8 | 4346 | |
cc1e2398 AK |
4347 | static void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo) |
4348 | { | |
1d7f656d KT |
4349 | /* threshold high ,disable auto threshold */ |
4350 | xgifb_reg_set(pVBInfo->Part1Port, 0x01, 0x3B); | |
4351 | /* threshold low default 04h */ | |
4352 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x02, ~(0x3F), 0x04); | |
cc1e2398 | 4353 | } |
21df8fc8 | 4354 | |
cc1e2398 AK |
4355 | static void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, |
4356 | struct xgi_hw_device_info *HwDeviceExtension, | |
4357 | unsigned short RefreshRateTableIndex, | |
4358 | struct vb_device_info *pVBInfo) | |
4359 | { | |
4360 | unsigned short tempcx = 0, CRT1Index = 0, resinfo = 0; | |
21df8fc8 | 4361 | |
cc1e2398 | 4362 | if (ModeNo > 0x13) { |
1d7f656d KT |
4363 | CRT1Index = pVBInfo-> |
4364 | RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; | |
cc1e2398 AK |
4365 | CRT1Index &= IndexMask; |
4366 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; | |
4367 | } | |
21df8fc8 | 4368 | |
cc1e2398 AK |
4369 | XGI_SetCRT2Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex, |
4370 | HwDeviceExtension, pVBInfo); | |
4371 | XGI_SetCRT2FIFO(pVBInfo); | |
4372 | /* XGI_SetCRT2Sync(ModeNo,RefreshRateTableIndex); */ | |
21df8fc8 | 4373 | |
cc1e2398 | 4374 | for (tempcx = 4; tempcx < 7; tempcx++) |
8104e329 | 4375 | xgifb_reg_set(pVBInfo->Part1Port, tempcx, 0x0); |
21df8fc8 | 4376 | |
8104e329 AK |
4377 | xgifb_reg_set(pVBInfo->Part1Port, 0x50, 0x00); |
4378 | xgifb_reg_set(pVBInfo->Part1Port, 0x02, 0x44); /* temp 0206 */ | |
cc1e2398 | 4379 | } |
21df8fc8 | 4380 | |
cc1e2398 AK |
4381 | static void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, |
4382 | struct xgi_hw_device_info *HwDeviceExtension, | |
4383 | unsigned short RefreshRateTableIndex, | |
4384 | struct vb_device_info *pVBInfo) | |
4385 | { | |
4386 | unsigned short temp = 0, tempax = 0, tempbx = 0, tempcx = 0, | |
4387 | pushbx = 0, CRT1Index = 0, modeflag, resinfo = 0; | |
4388 | ||
4389 | if (ModeNo > 0x13) { | |
1d7f656d KT |
4390 | CRT1Index = pVBInfo-> |
4391 | RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; | |
cc1e2398 AK |
4392 | CRT1Index &= IndexMask; |
4393 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; | |
21df8fc8 PS |
4394 | } |
4395 | ||
cc1e2398 AK |
4396 | if (ModeNo <= 0x13) |
4397 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
4398 | else | |
4399 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
21df8fc8 | 4400 | |
cc1e2398 AK |
4401 | /* bainy change table name */ |
4402 | if (modeflag & HalfDCLK) { | |
1d7f656d KT |
4403 | /* BTVGA2HT 0x08,0x09 */ |
4404 | temp = (pVBInfo->VGAHT / 2 - 1) & 0x0FF; | |
8104e329 | 4405 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp); |
cc1e2398 | 4406 | temp = (((pVBInfo->VGAHT / 2 - 1) & 0xFF00) >> 8) << 4; |
ec9e5d3e | 4407 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp); |
1d7f656d KT |
4408 | /* BTVGA2HDEE 0x0A,0x0C */ |
4409 | temp = (pVBInfo->VGAHDE / 2 + 16) & 0x0FF; | |
8104e329 | 4410 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); |
cc1e2398 AK |
4411 | tempcx = ((pVBInfo->VGAHT - pVBInfo->VGAHDE) / 2) >> 2; |
4412 | pushbx = pVBInfo->VGAHDE / 2 + 16; | |
21df8fc8 | 4413 | tempcx = tempcx >> 1; |
cc1e2398 AK |
4414 | tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */ |
4415 | tempcx += tempbx; | |
21df8fc8 | 4416 | |
cc1e2398 AK |
4417 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
4418 | tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4]; | |
1d7f656d KT |
4419 | tempbx |= ((pVBInfo-> |
4420 | XGINEWUB_CRT1Table[CRT1Index].CR[14] & | |
4421 | 0xC0) << 2); | |
cc1e2398 AK |
4422 | tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */ |
4423 | tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5]; | |
4424 | tempcx &= 0x1F; | |
4425 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[15]; | |
4426 | temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */ | |
4427 | tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */ | |
4428 | } | |
21df8fc8 | 4429 | |
cc1e2398 AK |
4430 | tempbx += 4; |
4431 | tempcx += 4; | |
21df8fc8 | 4432 | |
cc1e2398 AK |
4433 | if (tempcx > (pVBInfo->VGAHT / 2)) |
4434 | tempcx = pVBInfo->VGAHT / 2; | |
21df8fc8 | 4435 | |
cc1e2398 | 4436 | temp = tempbx & 0x00FF; |
21df8fc8 | 4437 | |
8104e329 | 4438 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
cc1e2398 AK |
4439 | } else { |
4440 | temp = (pVBInfo->VGAHT - 1) & 0x0FF; /* BTVGA2HT 0x08,0x09 */ | |
8104e329 | 4441 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, temp); |
cc1e2398 | 4442 | temp = (((pVBInfo->VGAHT - 1) & 0xFF00) >> 8) << 4; |
ec9e5d3e | 4443 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x09, ~0x0F0, temp); |
1d7f656d KT |
4444 | /* BTVGA2HDEE 0x0A,0x0C */ |
4445 | temp = (pVBInfo->VGAHDE + 16) & 0x0FF; | |
8104e329 | 4446 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); |
cc1e2398 AK |
4447 | tempcx = (pVBInfo->VGAHT - pVBInfo->VGAHDE) >> 2; /* cx */ |
4448 | pushbx = pVBInfo->VGAHDE + 16; | |
4449 | tempcx = tempcx >> 1; | |
4450 | tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */ | |
4451 | tempcx += tempbx; | |
21df8fc8 | 4452 | |
cc1e2398 AK |
4453 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
4454 | tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[3]; | |
1d7f656d KT |
4455 | tempbx |= ((pVBInfo-> |
4456 | XGINEWUB_CRT1Table[CRT1Index].CR[5] & | |
4457 | 0xC0) << 2); | |
cc1e2398 AK |
4458 | tempbx = (tempbx - 3) << 3; /* (VGAHRS-3)*8 */ |
4459 | tempcx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[4]; | |
4460 | tempcx &= 0x1F; | |
4461 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[6]; | |
4462 | temp = (temp & 0x04) << (5 - 2); /* VGAHRE D[5] */ | |
4463 | tempcx = ((tempcx | temp) - 3) << 3; /* (VGAHRE-3)*8 */ | |
4464 | tempbx += 16; | |
4465 | tempcx += 16; | |
4466 | } | |
21df8fc8 | 4467 | |
cc1e2398 AK |
4468 | if (tempcx > pVBInfo->VGAHT) |
4469 | tempcx = pVBInfo->VGAHT; | |
21df8fc8 | 4470 | |
cc1e2398 | 4471 | temp = tempbx & 0x00FF; |
8104e329 | 4472 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
cc1e2398 | 4473 | } |
21df8fc8 | 4474 | |
cc1e2398 AK |
4475 | tempax = (tempax & 0x00FF) | (tempbx & 0xFF00); |
4476 | tempbx = pushbx; | |
4477 | tempbx = (tempbx & 0x00FF) | ((tempbx & 0xFF00) << 4); | |
4478 | tempax |= (tempbx & 0xFF00); | |
4479 | temp = (tempax & 0xFF00) >> 8; | |
8104e329 | 4480 | xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp); |
21df8fc8 | 4481 | temp = tempcx & 0x00FF; |
8104e329 | 4482 | xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp); |
cc1e2398 | 4483 | tempcx = (pVBInfo->VGAVT - 1); |
21df8fc8 | 4484 | temp = tempcx & 0x00FF; |
21df8fc8 | 4485 | |
8104e329 | 4486 | xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp); |
cc1e2398 AK |
4487 | tempbx = pVBInfo->VGAVDE - 1; |
4488 | temp = tempbx & 0x00FF; | |
8104e329 | 4489 | xgifb_reg_set(pVBInfo->Part1Port, 0x0F, temp); |
cc1e2398 AK |
4490 | temp = ((tempbx & 0xFF00) << 3) >> 8; |
4491 | temp |= ((tempcx & 0xFF00) >> 8); | |
8104e329 | 4492 | xgifb_reg_set(pVBInfo->Part1Port, 0x12, temp); |
21df8fc8 | 4493 | |
cc1e2398 AK |
4494 | tempax = pVBInfo->VGAVDE; |
4495 | tempbx = pVBInfo->VGAVDE; | |
4496 | tempcx = pVBInfo->VGAVT; | |
1d7f656d KT |
4497 | /* BTVGA2VRS 0x10,0x11 */ |
4498 | tempbx = (pVBInfo->VGAVT + pVBInfo->VGAVDE) >> 1; | |
4499 | /* BTVGA2VRE 0x11 */ | |
4500 | tempcx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) >> 4) + tempbx + 1; | |
21df8fc8 | 4501 | |
cc1e2398 AK |
4502 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { |
4503 | tempbx = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[10]; | |
4504 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9]; | |
21df8fc8 | 4505 | |
cc1e2398 AK |
4506 | if (temp & 0x04) |
4507 | tempbx |= 0x0100; | |
21df8fc8 | 4508 | |
cc1e2398 AK |
4509 | if (temp & 0x080) |
4510 | tempbx |= 0x0200; | |
21df8fc8 | 4511 | |
cc1e2398 | 4512 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14]; |
21df8fc8 | 4513 | |
cc1e2398 AK |
4514 | if (temp & 0x08) |
4515 | tempbx |= 0x0400; | |
21df8fc8 | 4516 | |
cc1e2398 AK |
4517 | temp = pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[11]; |
4518 | tempcx = (tempcx & 0xFF00) | (temp & 0x00FF); | |
21df8fc8 PS |
4519 | } |
4520 | ||
cc1e2398 | 4521 | temp = tempbx & 0x00FF; |
8104e329 | 4522 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); |
cc1e2398 AK |
4523 | temp = ((tempbx & 0xFF00) >> 8) << 4; |
4524 | temp = ((tempcx & 0x000F) | (temp)); | |
8104e329 | 4525 | xgifb_reg_set(pVBInfo->Part1Port, 0x11, temp); |
cc1e2398 | 4526 | tempax = 0; |
21df8fc8 | 4527 | |
cc1e2398 AK |
4528 | if (modeflag & DoubleScanMode) |
4529 | tempax |= 0x80; | |
21df8fc8 | 4530 | |
cc1e2398 AK |
4531 | if (modeflag & HalfDCLK) |
4532 | tempax |= 0x40; | |
21df8fc8 | 4533 | |
ec9e5d3e | 4534 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2C, ~0x0C0, tempax); |
cc1e2398 | 4535 | } |
21df8fc8 | 4536 | |
cc1e2398 AK |
4537 | static unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo) |
4538 | { | |
4539 | unsigned long tempax, tempbx; | |
21df8fc8 | 4540 | |
cc1e2398 AK |
4541 | tempbx = ((pVBInfo->VGAVT - pVBInfo->VGAVDE) * pVBInfo->RVBHCMAX) |
4542 | & 0xFFFF; | |
4543 | tempax = (pVBInfo->VT - pVBInfo->VDE) * pVBInfo->RVBHCFACT; | |
4544 | tempax = (tempax * pVBInfo->HT) / tempbx; | |
21df8fc8 | 4545 | |
cc1e2398 AK |
4546 | return (unsigned short) tempax; |
4547 | } | |
21df8fc8 | 4548 | |
cc1e2398 AK |
4549 | static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex, |
4550 | struct xgi_hw_device_info *HwDeviceExtension, | |
4551 | unsigned short RefreshRateTableIndex, | |
4552 | struct vb_device_info *pVBInfo) | |
4553 | { | |
4554 | unsigned short push1, push2, tempax, tempbx = 0, tempcx, temp, resinfo, | |
4555 | modeflag, CRT1Index; | |
21df8fc8 | 4556 | |
cc1e2398 | 4557 | if (ModeNo <= 0x13) { |
1d7f656d KT |
4558 | /* si+St_ResInfo */ |
4559 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
cc1e2398 AK |
4560 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
4561 | } else { | |
1d7f656d KT |
4562 | /* si+Ext_ResInfo */ |
4563 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
cc1e2398 | 4564 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
1d7f656d KT |
4565 | CRT1Index = pVBInfo-> |
4566 | RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC; | |
cc1e2398 | 4567 | CRT1Index &= IndexMask; |
21df8fc8 PS |
4568 | } |
4569 | ||
cc1e2398 AK |
4570 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) |
4571 | return; | |
21df8fc8 | 4572 | |
cc1e2398 | 4573 | temp = 0xFF; /* set MAX HT */ |
8104e329 | 4574 | xgifb_reg_set(pVBInfo->Part1Port, 0x03, temp); |
cc1e2398 AK |
4575 | /* if (modeflag & Charx8Dot) */ |
4576 | /* tempcx = 0x08; */ | |
4577 | /* else */ | |
4578 | tempcx = 0x08; | |
21df8fc8 | 4579 | |
cc1e2398 AK |
4580 | if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) |
4581 | modeflag |= Charx8Dot; | |
21df8fc8 | 4582 | |
cc1e2398 | 4583 | tempax = pVBInfo->VGAHDE; /* 0x04 Horizontal Display End */ |
21df8fc8 | 4584 | |
cc1e2398 AK |
4585 | if (modeflag & HalfDCLK) |
4586 | tempax = tempax >> 1; | |
21df8fc8 | 4587 | |
cc1e2398 AK |
4588 | tempax = (tempax / tempcx) - 1; |
4589 | tempbx |= ((tempax & 0x00FF) << 8); | |
4590 | temp = tempax & 0x00FF; | |
8104e329 | 4591 | xgifb_reg_set(pVBInfo->Part1Port, 0x04, temp); |
21df8fc8 | 4592 | |
cc1e2398 | 4593 | temp = (tempbx & 0xFF00) >> 8; |
21df8fc8 | 4594 | |
cc1e2398 AK |
4595 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
4596 | if (!(pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | |
4597 | | VB_XGI302LV | VB_XGI301C))) | |
4598 | temp += 2; | |
21df8fc8 | 4599 | |
cc1e2398 AK |
4600 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
4601 | if (pVBInfo->VBType & VB_XGI301LV) { | |
4602 | if (pVBInfo->VBExtInfo == VB_YPbPr1080i) { | |
4603 | if (resinfo == 7) | |
4604 | temp -= 2; | |
4605 | } | |
4606 | } else if (resinfo == 7) { | |
4607 | temp -= 2; | |
4608 | } | |
21df8fc8 | 4609 | } |
21df8fc8 PS |
4610 | } |
4611 | ||
1d7f656d KT |
4612 | /* 0x05 Horizontal Display Start */ |
4613 | xgifb_reg_set(pVBInfo->Part1Port, 0x05, temp); | |
4614 | /* 0x06 Horizontal Blank end */ | |
4615 | xgifb_reg_set(pVBInfo->Part1Port, 0x06, 0x03); | |
21df8fc8 | 4616 | |
cc1e2398 AK |
4617 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { /* 030226 bainy */ |
4618 | if (pVBInfo->VBInfo & SetCRT2ToTV) | |
4619 | tempax = pVBInfo->VGAHT; | |
4620 | else | |
4621 | tempax = XGI_GetVGAHT2(pVBInfo); | |
4622 | } | |
21df8fc8 | 4623 | |
cc1e2398 AK |
4624 | if (tempax >= pVBInfo->VGAHT) |
4625 | tempax = pVBInfo->VGAHT; | |
21df8fc8 | 4626 | |
cc1e2398 AK |
4627 | if (modeflag & HalfDCLK) |
4628 | tempax = tempax >> 1; | |
4629 | ||
4630 | tempax = (tempax / tempcx) - 5; | |
4631 | tempcx = tempax; /* 20030401 0x07 horizontal Retrace Start */ | |
4632 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { | |
4633 | temp = (tempbx & 0x00FF) - 1; | |
4634 | if (!(modeflag & HalfDCLK)) { | |
4635 | temp -= 6; | |
4636 | if (pVBInfo->TVInfo & TVSimuMode) { | |
4637 | temp -= 4; | |
4638 | if (ModeNo > 0x13) | |
4639 | temp -= 10; | |
4640 | } | |
4641 | } | |
21df8fc8 | 4642 | } else { |
cc1e2398 AK |
4643 | /* tempcx = tempbx & 0x00FF ; */ |
4644 | tempbx = (tempbx & 0xFF00) >> 8; | |
4645 | tempcx = (tempcx + tempbx) >> 1; | |
4646 | temp = (tempcx & 0x00FF) + 2; | |
21df8fc8 | 4647 | |
cc1e2398 AK |
4648 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
4649 | temp -= 1; | |
4650 | if (!(modeflag & HalfDCLK)) { | |
4651 | if ((modeflag & Charx8Dot)) { | |
4652 | temp += 4; | |
4653 | if (pVBInfo->VGAHDE >= 800) | |
4654 | temp -= 6; | |
4655 | } | |
4656 | } | |
4657 | } else { | |
4658 | if (!(modeflag & HalfDCLK)) { | |
4659 | temp -= 4; | |
4660 | if (pVBInfo->LCDResInfo != Panel1280x960) { | |
4661 | if (pVBInfo->VGAHDE >= 800) { | |
4662 | temp -= 7; | |
1d7f656d KT |
4663 | if (pVBInfo->ModeType == |
4664 | ModeEGA) { | |
4665 | if (pVBInfo->VGAVDE == | |
4666 | 1024) { | |
cc1e2398 | 4667 | temp += 15; |
1d7f656d KT |
4668 | if (pVBInfo->LCDResInfo != Panel1280x1024) { |
4669 | temp += | |
4670 | 7; | |
cc1e2398 AK |
4671 | } |
4672 | } | |
4673 | } | |
21df8fc8 | 4674 | |
cc1e2398 AK |
4675 | if (pVBInfo->VGAHDE >= 1280) { |
4676 | if (pVBInfo->LCDResInfo | |
4677 | != Panel1280x960) { | |
4678 | if (pVBInfo->LCDInfo | |
4679 | & LCDNonExpanding) { | |
4680 | temp | |
4681 | += 28; | |
4682 | } | |
4683 | } | |
4684 | } | |
4685 | } | |
4686 | } | |
4687 | } | |
4688 | } | |
4689 | } | |
21df8fc8 | 4690 | |
1d7f656d KT |
4691 | /* 0x07 Horizontal Retrace Start */ |
4692 | xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp); | |
4693 | /* 0x08 Horizontal Retrace End */ | |
4694 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, 0); | |
21df8fc8 | 4695 | |
cc1e2398 AK |
4696 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
4697 | if (pVBInfo->TVInfo & TVSimuMode) { | |
4698 | if ((ModeNo == 0x06) || (ModeNo == 0x10) || (ModeNo | |
4699 | == 0x11) || (ModeNo == 0x13) || (ModeNo | |
4700 | == 0x0F)) { | |
8104e329 AK |
4701 | xgifb_reg_set(pVBInfo->Part1Port, 0x07, 0x5b); |
4702 | xgifb_reg_set(pVBInfo->Part1Port, 0x08, 0x03); | |
cc1e2398 | 4703 | } |
21df8fc8 | 4704 | |
cc1e2398 AK |
4705 | if ((ModeNo == 0x00) || (ModeNo == 0x01)) { |
4706 | if (pVBInfo->TVInfo & SetNTSCTV) { | |
8104e329 | 4707 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 | 4708 | 0x07, 0x2A); |
8104e329 | 4709 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 AK |
4710 | 0x08, 0x61); |
4711 | } else { | |
8104e329 | 4712 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 | 4713 | 0x07, 0x2A); |
8104e329 | 4714 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 | 4715 | 0x08, 0x41); |
8104e329 | 4716 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 AK |
4717 | 0x0C, 0xF0); |
4718 | } | |
4719 | } | |
21df8fc8 | 4720 | |
cc1e2398 AK |
4721 | if ((ModeNo == 0x02) || (ModeNo == 0x03) || (ModeNo |
4722 | == 0x07)) { | |
4723 | if (pVBInfo->TVInfo & SetNTSCTV) { | |
8104e329 | 4724 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 | 4725 | 0x07, 0x54); |
8104e329 | 4726 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 AK |
4727 | 0x08, 0x00); |
4728 | } else { | |
8104e329 | 4729 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 | 4730 | 0x07, 0x55); |
8104e329 | 4731 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 | 4732 | 0x08, 0x00); |
8104e329 | 4733 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 AK |
4734 | 0x0C, 0xF0); |
4735 | } | |
4736 | } | |
21df8fc8 | 4737 | |
cc1e2398 AK |
4738 | if ((ModeNo == 0x04) || (ModeNo == 0x05) || (ModeNo |
4739 | == 0x0D) || (ModeNo == 0x50)) { | |
4740 | if (pVBInfo->TVInfo & SetNTSCTV) { | |
8104e329 | 4741 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 | 4742 | 0x07, 0x30); |
8104e329 | 4743 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 AK |
4744 | 0x08, 0x03); |
4745 | } else { | |
8104e329 | 4746 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 | 4747 | 0x07, 0x2f); |
8104e329 | 4748 | xgifb_reg_set(pVBInfo->Part1Port, |
cc1e2398 AK |
4749 | 0x08, 0x02); |
4750 | } | |
21df8fc8 | 4751 | } |
21df8fc8 PS |
4752 | } |
4753 | } | |
4754 | ||
8104e329 | 4755 | xgifb_reg_set(pVBInfo->Part1Port, 0x18, 0x03); /* 0x18 SR0B */ |
ec9e5d3e | 4756 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0xF0, 0x00); |
8104e329 | 4757 | xgifb_reg_set(pVBInfo->Part1Port, 0x09, 0xFF); /* 0x09 Set Max VT */ |
21df8fc8 | 4758 | |
cc1e2398 AK |
4759 | tempbx = pVBInfo->VGAVT; |
4760 | push1 = tempbx; | |
4761 | tempcx = 0x121; | |
4762 | tempbx = pVBInfo->VGAVDE; /* 0x0E Virtical Display End */ | |
21df8fc8 | 4763 | |
cc1e2398 AK |
4764 | if (tempbx == 357) |
4765 | tempbx = 350; | |
4766 | if (tempbx == 360) | |
4767 | tempbx = 350; | |
4768 | if (tempbx == 375) | |
4769 | tempbx = 350; | |
4770 | if (tempbx == 405) | |
4771 | tempbx = 400; | |
4772 | if (tempbx == 525) | |
4773 | tempbx = 480; | |
21df8fc8 | 4774 | |
cc1e2398 | 4775 | push2 = tempbx; |
21df8fc8 | 4776 | |
cc1e2398 AK |
4777 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
4778 | if (pVBInfo->LCDResInfo == Panel1024x768) { | |
4779 | if (!(pVBInfo->LCDInfo & LCDVESATiming)) { | |
4780 | if (tempbx == 350) | |
4781 | tempbx += 5; | |
4782 | if (tempbx == 480) | |
4783 | tempbx += 5; | |
4784 | } | |
4785 | } | |
4786 | } | |
4787 | tempbx--; | |
4788 | temp = tempbx & 0x00FF; | |
4789 | tempbx--; | |
4790 | temp = tempbx & 0x00FF; | |
1d7f656d KT |
4791 | /* 0x10 vertical Blank Start */ |
4792 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); | |
cc1e2398 AK |
4793 | tempbx = push2; |
4794 | tempbx--; | |
4795 | temp = tempbx & 0x00FF; | |
8104e329 | 4796 | xgifb_reg_set(pVBInfo->Part1Port, 0x0E, temp); |
d7636e0b | 4797 | |
cc1e2398 AK |
4798 | if (tempbx & 0x0100) |
4799 | tempcx |= 0x0002; | |
21df8fc8 | 4800 | |
cc1e2398 | 4801 | tempax = 0x000B; |
21df8fc8 | 4802 | |
cc1e2398 AK |
4803 | if (modeflag & DoubleScanMode) |
4804 | tempax |= 0x08000; | |
21df8fc8 | 4805 | |
cc1e2398 AK |
4806 | if (tempbx & 0x0200) |
4807 | tempcx |= 0x0040; | |
21df8fc8 | 4808 | |
cc1e2398 | 4809 | temp = (tempax & 0xFF00) >> 8; |
8104e329 | 4810 | xgifb_reg_set(pVBInfo->Part1Port, 0x0B, temp); |
21df8fc8 | 4811 | |
cc1e2398 AK |
4812 | if (tempbx & 0x0400) |
4813 | tempcx |= 0x0600; | |
21df8fc8 | 4814 | |
1d7f656d KT |
4815 | /* 0x11 Vertival Blank End */ |
4816 | xgifb_reg_set(pVBInfo->Part1Port, 0x11, 0x00); | |
21df8fc8 | 4817 | |
cc1e2398 AK |
4818 | tempax = push1; |
4819 | tempax -= tempbx; /* 0x0C Vertical Retrace Start */ | |
4820 | tempax = tempax >> 2; | |
4821 | push1 = tempax; /* push ax */ | |
4822 | ||
4823 | if (resinfo != 0x09) { | |
4824 | tempax = tempax << 1; | |
4825 | tempbx += tempax; | |
4826 | } | |
4827 | ||
4828 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { | |
4829 | if (pVBInfo->VBType & VB_XGI301LV) { | |
4830 | if (pVBInfo->TVInfo & SetYPbPrMode1080i) { | |
4831 | tempbx -= 10; | |
4832 | } else { | |
4833 | if (pVBInfo->TVInfo & TVSimuMode) { | |
4834 | if (pVBInfo->TVInfo & SetPALTV) { | |
1d7f656d KT |
4835 | if (pVBInfo->VBType & |
4836 | VB_XGI301LV) { | |
4837 | if (!(pVBInfo->TVInfo & | |
4838 | (SetYPbPrMode525p | | |
4839 | SetYPbPrMode750p | | |
4840 | SetYPbPrMode1080i))) | |
cc1e2398 AK |
4841 | tempbx += 40; |
4842 | } else { | |
4843 | tempbx += 40; | |
4844 | } | |
4845 | } | |
4846 | } | |
4847 | } | |
4848 | } else { | |
4849 | tempbx -= 10; | |
4850 | } | |
4851 | } else { | |
4852 | if (pVBInfo->TVInfo & TVSimuMode) { | |
4853 | if (pVBInfo->TVInfo & SetPALTV) { | |
4854 | if (pVBInfo->VBType & VB_XGI301LV) { | |
1d7f656d KT |
4855 | if (!(pVBInfo->TVInfo & |
4856 | (SetYPbPrMode525p | | |
4857 | SetYPbPrMode750p | | |
4858 | SetYPbPrMode1080i))) | |
cc1e2398 AK |
4859 | tempbx += 40; |
4860 | } else { | |
4861 | tempbx += 40; | |
4862 | } | |
21df8fc8 PS |
4863 | } |
4864 | } | |
4865 | } | |
cc1e2398 AK |
4866 | tempax = push1; |
4867 | tempax = tempax >> 2; | |
4868 | tempax++; | |
4869 | tempax += tempbx; | |
4870 | push1 = tempax; /* push ax */ | |
21df8fc8 | 4871 | |
cc1e2398 AK |
4872 | if ((pVBInfo->TVInfo & SetPALTV)) { |
4873 | if (tempbx <= 513) { | |
4874 | if (tempax >= 513) | |
4875 | tempbx = 513; | |
4876 | } | |
4877 | } | |
4878 | ||
4879 | temp = tempbx & 0x00FF; | |
8104e329 | 4880 | xgifb_reg_set(pVBInfo->Part1Port, 0x0C, temp); |
21df8fc8 PS |
4881 | tempbx--; |
4882 | temp = tempbx & 0x00FF; | |
8104e329 | 4883 | xgifb_reg_set(pVBInfo->Part1Port, 0x10, temp); |
21df8fc8 | 4884 | |
cc1e2398 AK |
4885 | if (tempbx & 0x0100) |
4886 | tempcx |= 0x0008; | |
21df8fc8 | 4887 | |
cc1e2398 | 4888 | if (tempbx & 0x0200) |
ec9e5d3e | 4889 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x0B, 0x0FF, 0x20); |
21df8fc8 | 4890 | |
cc1e2398 | 4891 | tempbx++; |
21df8fc8 | 4892 | |
cc1e2398 AK |
4893 | if (tempbx & 0x0100) |
4894 | tempcx |= 0x0004; | |
21df8fc8 | 4895 | |
cc1e2398 AK |
4896 | if (tempbx & 0x0200) |
4897 | tempcx |= 0x0080; | |
21df8fc8 | 4898 | |
cc1e2398 AK |
4899 | if (tempbx & 0x0400) |
4900 | tempcx |= 0x0C00; | |
21df8fc8 | 4901 | |
cc1e2398 AK |
4902 | tempbx = push1; /* pop ax */ |
4903 | temp = tempbx & 0x00FF; | |
4904 | temp &= 0x0F; | |
1d7f656d KT |
4905 | /* 0x0D vertical Retrace End */ |
4906 | xgifb_reg_set(pVBInfo->Part1Port, 0x0D, temp); | |
21df8fc8 | 4907 | |
cc1e2398 AK |
4908 | if (tempbx & 0x0010) |
4909 | tempcx |= 0x2000; | |
21df8fc8 | 4910 | |
cc1e2398 | 4911 | temp = tempcx & 0x00FF; |
8104e329 | 4912 | xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp); /* 0x0A CR07 */ |
cc1e2398 | 4913 | temp = (tempcx & 0x0FF00) >> 8; |
8104e329 | 4914 | xgifb_reg_set(pVBInfo->Part1Port, 0x17, temp); /* 0x17 SR0A */ |
cc1e2398 AK |
4915 | tempax = modeflag; |
4916 | temp = (tempax & 0xFF00) >> 8; | |
21df8fc8 | 4917 | |
cc1e2398 | 4918 | temp = (temp >> 1) & 0x09; |
21df8fc8 | 4919 | |
cc1e2398 AK |
4920 | if (pVBInfo->VBType & (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) |
4921 | temp |= 0x01; | |
21df8fc8 | 4922 | |
8104e329 AK |
4923 | xgifb_reg_set(pVBInfo->Part1Port, 0x16, temp); /* 0x16 SR01 */ |
4924 | xgifb_reg_set(pVBInfo->Part1Port, 0x0F, 0); /* 0x0F CR14 */ | |
4925 | xgifb_reg_set(pVBInfo->Part1Port, 0x12, 0); /* 0x12 CR17 */ | |
21df8fc8 | 4926 | |
cc1e2398 AK |
4927 | if (pVBInfo->LCDInfo & LCDRGB18Bit) |
4928 | temp = 0x80; | |
4929 | else | |
4930 | temp = 0x00; | |
21df8fc8 | 4931 | |
8104e329 | 4932 | xgifb_reg_set(pVBInfo->Part1Port, 0x1A, temp); /* 0x1A SR0E */ |
21df8fc8 | 4933 | |
cc1e2398 AK |
4934 | return; |
4935 | } | |
21df8fc8 | 4936 | |
cc1e2398 AK |
4937 | static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex, |
4938 | unsigned short RefreshRateTableIndex, | |
4939 | struct xgi_hw_device_info *HwDeviceExtension, | |
4940 | struct vb_device_info *pVBInfo) | |
4941 | { | |
4942 | unsigned short i, j, tempax, tempbx, tempcx, temp, push1, push2, | |
4943 | modeflag, resinfo, crt2crtc; | |
4944 | unsigned char *TimingPoint; | |
21df8fc8 | 4945 | |
cc1e2398 AK |
4946 | unsigned long longtemp, tempeax, tempebx, temp2, tempecx; |
4947 | ||
4948 | if (ModeNo <= 0x13) { | |
1d7f656d KT |
4949 | /* si+St_ResInfo */ |
4950 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
cc1e2398 AK |
4951 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
4952 | crt2crtc = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC; | |
4953 | } else { | |
1d7f656d KT |
4954 | /* si+Ext_ResInfo */ |
4955 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
cc1e2398 | 4956 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
1d7f656d KT |
4957 | crt2crtc = pVBInfo->RefIndex[RefreshRateTableIndex]. |
4958 | Ext_CRT2CRTC; | |
21df8fc8 PS |
4959 | } |
4960 | ||
cc1e2398 AK |
4961 | tempax = 0; |
4962 | ||
4963 | if (!(pVBInfo->VBInfo & SetCRT2ToAVIDEO)) | |
4964 | tempax |= 0x0800; | |
21df8fc8 | 4965 | |
cc1e2398 AK |
4966 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) |
4967 | tempax |= 0x0400; | |
21df8fc8 | 4968 | |
cc1e2398 AK |
4969 | if (pVBInfo->VBInfo & SetCRT2ToSCART) |
4970 | tempax |= 0x0200; | |
21df8fc8 | 4971 | |
cc1e2398 AK |
4972 | if (!(pVBInfo->TVInfo & SetPALTV)) |
4973 | tempax |= 0x1000; | |
21df8fc8 | 4974 | |
cc1e2398 AK |
4975 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) |
4976 | tempax |= 0x0100; | |
21df8fc8 | 4977 | |
cc1e2398 AK |
4978 | if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)) |
4979 | tempax &= 0xfe00; | |
21df8fc8 | 4980 | |
cc1e2398 | 4981 | tempax = (tempax & 0xff00) >> 8; |
21df8fc8 | 4982 | |
8104e329 | 4983 | xgifb_reg_set(pVBInfo->Part2Port, 0x0, tempax); |
cc1e2398 | 4984 | TimingPoint = pVBInfo->NTSCTiming; |
d7636e0b | 4985 | |
cc1e2398 AK |
4986 | if (pVBInfo->TVInfo & SetPALTV) |
4987 | TimingPoint = pVBInfo->PALTiming; | |
d7636e0b | 4988 | |
cc1e2398 AK |
4989 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
4990 | TimingPoint = pVBInfo->HiTVExtTiming; | |
d7636e0b | 4991 | |
cc1e2398 AK |
4992 | if (pVBInfo->VBInfo & SetInSlaveMode) |
4993 | TimingPoint = pVBInfo->HiTVSt2Timing; | |
d7636e0b | 4994 | |
cc1e2398 AK |
4995 | if (pVBInfo->SetFlag & TVSimuMode) |
4996 | TimingPoint = pVBInfo->HiTVSt1Timing; | |
21df8fc8 | 4997 | |
cc1e2398 AK |
4998 | if (!(modeflag & Charx8Dot)) |
4999 | TimingPoint = pVBInfo->HiTVTextTiming; | |
5000 | } | |
21df8fc8 PS |
5001 | |
5002 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { | |
5003 | if (pVBInfo->TVInfo & SetYPbPrMode525i) | |
cc1e2398 AK |
5004 | TimingPoint = pVBInfo->YPbPr525iTiming; |
5005 | ||
21df8fc8 | 5006 | if (pVBInfo->TVInfo & SetYPbPrMode525p) |
cc1e2398 AK |
5007 | TimingPoint = pVBInfo->YPbPr525pTiming; |
5008 | ||
21df8fc8 | 5009 | if (pVBInfo->TVInfo & SetYPbPrMode750p) |
cc1e2398 | 5010 | TimingPoint = pVBInfo->YPbPr750pTiming; |
21df8fc8 | 5011 | } |
d7636e0b | 5012 | |
cc1e2398 | 5013 | for (i = 0x01, j = 0; i <= 0x2D; i++, j++) |
8104e329 | 5014 | xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]); |
cc1e2398 AK |
5015 | |
5016 | for (i = 0x39; i <= 0x45; i++, j++) | |
1d7f656d KT |
5017 | /* di->temp2[j] */ |
5018 | xgifb_reg_set(pVBInfo->Part2Port, i, TimingPoint[j]); | |
cc1e2398 AK |
5019 | |
5020 | if (pVBInfo->VBInfo & SetCRT2ToTV) | |
ec9e5d3e | 5021 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, 0x00); |
cc1e2398 AK |
5022 | |
5023 | temp = pVBInfo->NewFlickerMode; | |
5024 | temp &= 0x80; | |
ec9e5d3e | 5025 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xFF, temp); |
cc1e2398 | 5026 | |
21df8fc8 | 5027 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) |
cc1e2398 | 5028 | tempax = 950; |
21df8fc8 | 5029 | |
cc1e2398 AK |
5030 | if (pVBInfo->TVInfo & SetPALTV) |
5031 | tempax = 520; | |
5032 | else | |
5033 | tempax = 440; | |
5034 | ||
5035 | if (pVBInfo->VDE <= tempax) { | |
5036 | tempax -= pVBInfo->VDE; | |
5037 | tempax = tempax >> 2; | |
5038 | tempax = (tempax & 0x00FF) | ((tempax & 0x00FF) << 8); | |
5039 | push1 = tempax; | |
5040 | temp = (tempax & 0xFF00) >> 8; | |
5041 | temp += (unsigned short) TimingPoint[0]; | |
5042 | ||
5043 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | |
5044 | | VB_XGI302LV | VB_XGI301C)) { | |
5045 | if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO | |
5046 | | SetCRT2ToSVIDEO | SetCRT2ToSCART | |
5047 | | SetCRT2ToYPbPr)) { | |
5048 | tempcx = pVBInfo->VGAHDE; | |
5049 | if (tempcx >= 1024) { | |
5050 | temp = 0x17; /* NTSC */ | |
5051 | if (pVBInfo->TVInfo & SetPALTV) | |
5052 | temp = 0x19; /* PAL */ | |
5053 | } | |
5054 | } | |
5055 | } | |
5056 | ||
8104e329 | 5057 | xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp); |
cc1e2398 AK |
5058 | tempax = push1; |
5059 | temp = (tempax & 0xFF00) >> 8; | |
5060 | temp += TimingPoint[1]; | |
5061 | ||
5062 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | |
5063 | | VB_XGI302LV | VB_XGI301C)) { | |
5064 | if ((pVBInfo->VBInfo & (SetCRT2ToAVIDEO | |
5065 | | SetCRT2ToSVIDEO | SetCRT2ToSCART | |
5066 | | SetCRT2ToYPbPr))) { | |
5067 | tempcx = pVBInfo->VGAHDE; | |
5068 | if (tempcx >= 1024) { | |
5069 | temp = 0x1D; /* NTSC */ | |
5070 | if (pVBInfo->TVInfo & SetPALTV) | |
5071 | temp = 0x52; /* PAL */ | |
5072 | } | |
5073 | } | |
5074 | } | |
8104e329 | 5075 | xgifb_reg_set(pVBInfo->Part2Port, 0x02, temp); |
21df8fc8 | 5076 | } |
d7636e0b | 5077 | |
cc1e2398 AK |
5078 | /* 301b */ |
5079 | tempcx = pVBInfo->HT; | |
d7636e0b | 5080 | |
cc1e2398 AK |
5081 | if (XGI_IsLCDDualLink(pVBInfo)) |
5082 | tempcx = tempcx >> 1; | |
21df8fc8 | 5083 | |
cc1e2398 AK |
5084 | tempcx -= 2; |
5085 | temp = tempcx & 0x00FF; | |
8104e329 | 5086 | xgifb_reg_set(pVBInfo->Part2Port, 0x1B, temp); |
21df8fc8 | 5087 | |
cc1e2398 | 5088 | temp = (tempcx & 0xFF00) >> 8; |
ec9e5d3e | 5089 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F, temp); |
21df8fc8 | 5090 | |
cc1e2398 AK |
5091 | tempcx = pVBInfo->HT >> 1; |
5092 | push1 = tempcx; /* push cx */ | |
5093 | tempcx += 7; | |
21df8fc8 | 5094 | |
cc1e2398 AK |
5095 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) |
5096 | tempcx -= 4; | |
5097 | ||
5098 | temp = tempcx & 0x00FF; | |
5099 | temp = temp << 4; | |
ec9e5d3e | 5100 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x22, 0x0F, temp); |
cc1e2398 AK |
5101 | |
5102 | tempbx = TimingPoint[j] | ((TimingPoint[j + 1]) << 8); | |
5103 | tempbx += tempcx; | |
5104 | push2 = tempbx; | |
5105 | temp = tempbx & 0x00FF; | |
8104e329 | 5106 | xgifb_reg_set(pVBInfo->Part2Port, 0x24, temp); |
cc1e2398 AK |
5107 | temp = (tempbx & 0xFF00) >> 8; |
5108 | temp = temp << 4; | |
ec9e5d3e | 5109 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x25, 0x0F, temp); |
cc1e2398 AK |
5110 | |
5111 | tempbx = push2; | |
5112 | tempbx = tempbx + 8; | |
5113 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { | |
5114 | tempbx = tempbx - 4; | |
5115 | tempcx = tempbx; | |
21df8fc8 PS |
5116 | } |
5117 | ||
cc1e2398 | 5118 | temp = (tempbx & 0x00FF) << 4; |
ec9e5d3e | 5119 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x29, 0x0F, temp); |
d7636e0b | 5120 | |
cc1e2398 AK |
5121 | j += 2; |
5122 | tempcx += (TimingPoint[j] | ((TimingPoint[j + 1]) << 8)); | |
5123 | temp = tempcx & 0x00FF; | |
8104e329 | 5124 | xgifb_reg_set(pVBInfo->Part2Port, 0x27, temp); |
cc1e2398 | 5125 | temp = ((tempcx & 0xFF00) >> 8) << 4; |
ec9e5d3e | 5126 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x28, 0x0F, temp); |
21df8fc8 | 5127 | |
cc1e2398 AK |
5128 | tempcx += 8; |
5129 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) | |
5130 | tempcx -= 4; | |
21df8fc8 | 5131 | |
cc1e2398 AK |
5132 | temp = tempcx & 0xFF; |
5133 | temp = temp << 4; | |
ec9e5d3e | 5134 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2A, 0x0F, temp); |
cc1e2398 AK |
5135 | |
5136 | tempcx = push1; /* pop cx */ | |
5137 | j += 2; | |
5138 | temp = TimingPoint[j] | ((TimingPoint[j + 1]) << 8); | |
5139 | tempcx -= temp; | |
5140 | temp = tempcx & 0x00FF; | |
5141 | temp = temp << 4; | |
ec9e5d3e | 5142 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2D, 0x0F, temp); |
cc1e2398 AK |
5143 | |
5144 | tempcx -= 11; | |
5145 | ||
5146 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) { | |
5147 | tempax = XGI_GetVGAHT2(pVBInfo); | |
5148 | tempcx = tempax - 1; | |
21df8fc8 | 5149 | } |
cc1e2398 | 5150 | temp = tempcx & 0x00FF; |
8104e329 | 5151 | xgifb_reg_set(pVBInfo->Part2Port, 0x2E, temp); |
d7636e0b | 5152 | |
cc1e2398 | 5153 | tempbx = pVBInfo->VDE; |
21df8fc8 | 5154 | |
cc1e2398 AK |
5155 | if (pVBInfo->VGAVDE == 360) |
5156 | tempbx = 746; | |
5157 | if (pVBInfo->VGAVDE == 375) | |
5158 | tempbx = 746; | |
5159 | if (pVBInfo->VGAVDE == 405) | |
5160 | tempbx = 853; | |
5161 | ||
5162 | if (pVBInfo->VBInfo & SetCRT2ToTV) { | |
1d7f656d KT |
5163 | if (pVBInfo->VBType & |
5164 | (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) { | |
5165 | if (!(pVBInfo->TVInfo & | |
5166 | (SetYPbPrMode525p | SetYPbPrMode750p))) | |
cc1e2398 AK |
5167 | tempbx = tempbx >> 1; |
5168 | } else | |
5169 | tempbx = tempbx >> 1; | |
21df8fc8 PS |
5170 | } |
5171 | ||
cc1e2398 AK |
5172 | tempbx -= 2; |
5173 | temp = tempbx & 0x00FF; | |
21df8fc8 | 5174 | |
cc1e2398 AK |
5175 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
5176 | if (pVBInfo->VBType & VB_XGI301LV) { | |
5177 | if (pVBInfo->TVInfo & SetYPbPrMode1080i) { | |
5178 | if (pVBInfo->VBInfo & SetInSlaveMode) { | |
5179 | if (ModeNo == 0x2f) | |
5180 | temp += 1; | |
5181 | } | |
5182 | } | |
5183 | } else { | |
5184 | if (pVBInfo->VBInfo & SetInSlaveMode) { | |
5185 | if (ModeNo == 0x2f) | |
5186 | temp += 1; | |
5187 | } | |
21df8fc8 | 5188 | } |
cc1e2398 | 5189 | } |
21df8fc8 | 5190 | |
8104e329 | 5191 | xgifb_reg_set(pVBInfo->Part2Port, 0x2F, temp); |
21df8fc8 | 5192 | |
cc1e2398 AK |
5193 | temp = (tempcx & 0xFF00) >> 8; |
5194 | temp |= ((tempbx & 0xFF00) >> 8) << 6; | |
21df8fc8 | 5195 | |
cc1e2398 AK |
5196 | if (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)) { |
5197 | if (pVBInfo->VBType & VB_XGI301LV) { | |
5198 | if (pVBInfo->TVInfo & SetYPbPrMode1080i) { | |
5199 | temp |= 0x10; | |
21df8fc8 | 5200 | |
cc1e2398 AK |
5201 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) |
5202 | temp |= 0x20; | |
5203 | } | |
5204 | } else { | |
5205 | temp |= 0x10; | |
5206 | if (!(pVBInfo->VBInfo & SetCRT2ToSVIDEO)) | |
5207 | temp |= 0x20; | |
21df8fc8 PS |
5208 | } |
5209 | } | |
21df8fc8 | 5210 | |
8104e329 | 5211 | xgifb_reg_set(pVBInfo->Part2Port, 0x30, temp); |
21df8fc8 | 5212 | |
cc1e2398 AK |
5213 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
5214 | | VB_XGI302LV | VB_XGI301C)) { /* TV gatingno */ | |
5215 | tempbx = pVBInfo->VDE; | |
5216 | tempcx = tempbx - 2; | |
21df8fc8 | 5217 | |
cc1e2398 AK |
5218 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
5219 | if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | |
5220 | | SetYPbPrMode750p))) | |
5221 | tempbx = tempbx >> 1; | |
5222 | } | |
21df8fc8 | 5223 | |
cc1e2398 AK |
5224 | if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) { |
5225 | temp = 0; | |
5226 | if (tempcx & 0x0400) | |
5227 | temp |= 0x20; | |
21df8fc8 | 5228 | |
cc1e2398 AK |
5229 | if (tempbx & 0x0400) |
5230 | temp |= 0x40; | |
21df8fc8 | 5231 | |
8104e329 | 5232 | xgifb_reg_set(pVBInfo->Part4Port, 0x10, temp); |
cc1e2398 | 5233 | } |
21df8fc8 | 5234 | |
cc1e2398 | 5235 | temp = (((tempbx - 3) & 0x0300) >> 8) << 5; |
8104e329 | 5236 | xgifb_reg_set(pVBInfo->Part2Port, 0x46, temp); |
cc1e2398 | 5237 | temp = (tempbx - 3) & 0x00FF; |
8104e329 | 5238 | xgifb_reg_set(pVBInfo->Part2Port, 0x47, temp); |
cc1e2398 | 5239 | } |
21df8fc8 | 5240 | |
cc1e2398 | 5241 | tempbx = tempbx & 0x00FF; |
21df8fc8 | 5242 | |
cc1e2398 AK |
5243 | if (!(modeflag & HalfDCLK)) { |
5244 | tempcx = pVBInfo->VGAHDE; | |
5245 | if (tempcx >= pVBInfo->HDE) { | |
5246 | tempbx |= 0x2000; | |
5247 | tempax &= 0x00FF; | |
5248 | } | |
5249 | } | |
21df8fc8 | 5250 | |
cc1e2398 | 5251 | tempcx = 0x0101; |
21df8fc8 | 5252 | |
cc1e2398 AK |
5253 | if (pVBInfo->VBInfo & SetCRT2ToTV) { /*301b*/ |
5254 | if (pVBInfo->VGAHDE >= 1024) { | |
5255 | tempcx = 0x1920; | |
5256 | if (pVBInfo->VGAHDE >= 1280) { | |
5257 | tempcx = 0x1420; | |
5258 | tempbx = tempbx & 0xDFFF; | |
5259 | } | |
21df8fc8 PS |
5260 | } |
5261 | } | |
5262 | ||
cc1e2398 AK |
5263 | if (!(tempbx & 0x2000)) { |
5264 | if (modeflag & HalfDCLK) | |
5265 | tempcx = (tempcx & 0xFF00) | ((tempcx & 0x00FF) << 1); | |
21df8fc8 | 5266 | |
cc1e2398 AK |
5267 | push1 = tempbx; |
5268 | tempeax = pVBInfo->VGAHDE; | |
5269 | tempebx = (tempcx & 0xFF00) >> 8; | |
5270 | longtemp = tempeax * tempebx; | |
5271 | tempecx = tempcx & 0x00FF; | |
5272 | longtemp = longtemp / tempecx; | |
21df8fc8 | 5273 | |
cc1e2398 AK |
5274 | /* 301b */ |
5275 | tempecx = 8 * 1024; | |
21df8fc8 | 5276 | |
cc1e2398 AK |
5277 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
5278 | | VB_XGI302LV | VB_XGI301C)) { | |
5279 | tempecx = tempecx * 8; | |
5280 | } | |
21df8fc8 | 5281 | |
cc1e2398 AK |
5282 | longtemp = longtemp * tempecx; |
5283 | tempecx = pVBInfo->HDE; | |
5284 | temp2 = longtemp % tempecx; | |
5285 | tempeax = longtemp / tempecx; | |
5286 | if (temp2 != 0) | |
5287 | tempeax += 1; | |
21df8fc8 | 5288 | |
cc1e2398 | 5289 | tempax = (unsigned short) tempeax; |
21df8fc8 | 5290 | |
cc1e2398 AK |
5291 | /* 301b */ |
5292 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | |
5293 | | VB_XGI302LV | VB_XGI301C)) { | |
5294 | tempcx = ((tempax & 0xFF00) >> 5) >> 8; | |
5295 | } | |
5296 | /* end 301b */ | |
21df8fc8 | 5297 | |
cc1e2398 AK |
5298 | tempbx = push1; |
5299 | tempbx = (unsigned short) (((tempeax & 0x0000FF00) & 0x1F00) | |
5300 | | (tempbx & 0x00FF)); | |
5301 | tempax = (unsigned short) (((tempeax & 0x000000FF) << 8) | |
5302 | | (tempax & 0x00FF)); | |
5303 | temp = (tempax & 0xFF00) >> 8; | |
5304 | } else { | |
5305 | temp = (tempax & 0x00FF) >> 8; | |
5306 | } | |
21df8fc8 | 5307 | |
8104e329 | 5308 | xgifb_reg_set(pVBInfo->Part2Port, 0x44, temp); |
cc1e2398 | 5309 | temp = (tempbx & 0xFF00) >> 8; |
ec9e5d3e | 5310 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x45, ~0x03F, temp); |
cc1e2398 | 5311 | temp = tempcx & 0x00FF; |
21df8fc8 | 5312 | |
cc1e2398 AK |
5313 | if (tempbx & 0x2000) |
5314 | temp = 0; | |
21df8fc8 | 5315 | |
cc1e2398 AK |
5316 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
5317 | temp |= 0x18; | |
21df8fc8 | 5318 | |
ec9e5d3e | 5319 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x46, ~0x1F, temp); |
cc1e2398 AK |
5320 | if (pVBInfo->TVInfo & SetPALTV) { |
5321 | tempbx = 0x0382; | |
5322 | tempcx = 0x007e; | |
5323 | } else { | |
5324 | tempbx = 0x0369; | |
5325 | tempcx = 0x0061; | |
5326 | } | |
21df8fc8 | 5327 | |
cc1e2398 | 5328 | temp = tempbx & 0x00FF; |
8104e329 | 5329 | xgifb_reg_set(pVBInfo->Part2Port, 0x4b, temp); |
cc1e2398 | 5330 | temp = tempcx & 0x00FF; |
8104e329 | 5331 | xgifb_reg_set(pVBInfo->Part2Port, 0x4c, temp); |
21df8fc8 | 5332 | |
cc1e2398 AK |
5333 | temp = ((tempcx & 0xFF00) >> 8) & 0x03; |
5334 | temp = temp << 2; | |
5335 | temp |= ((tempbx & 0xFF00) >> 8) & 0x03; | |
21df8fc8 | 5336 | |
cc1e2398 AK |
5337 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { |
5338 | temp |= 0x10; | |
21df8fc8 | 5339 | |
cc1e2398 AK |
5340 | if (pVBInfo->TVInfo & SetYPbPrMode525p) |
5341 | temp |= 0x20; | |
21df8fc8 | 5342 | |
cc1e2398 AK |
5343 | if (pVBInfo->TVInfo & SetYPbPrMode750p) |
5344 | temp |= 0x60; | |
5345 | } | |
21df8fc8 | 5346 | |
8104e329 | 5347 | xgifb_reg_set(pVBInfo->Part2Port, 0x4d, temp); |
58839b01 | 5348 | temp = xgifb_reg_get(pVBInfo->Part2Port, 0x43); /* 301b change */ |
8104e329 | 5349 | xgifb_reg_set(pVBInfo->Part2Port, 0x43, (unsigned short) (temp - 3)); |
cc1e2398 AK |
5350 | |
5351 | if (!(pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p))) { | |
5352 | if (pVBInfo->TVInfo & NTSC1024x768) { | |
5353 | TimingPoint = XGI_NTSC1024AdjTime; | |
5354 | for (i = 0x1c, j = 0; i <= 0x30; i++, j++) { | |
8104e329 | 5355 | xgifb_reg_set(pVBInfo->Part2Port, i, |
cc1e2398 | 5356 | TimingPoint[j]); |
21df8fc8 | 5357 | } |
8104e329 | 5358 | xgifb_reg_set(pVBInfo->Part2Port, 0x43, 0x72); |
21df8fc8 | 5359 | } |
cc1e2398 | 5360 | } |
21df8fc8 | 5361 | |
cc1e2398 AK |
5362 | /* [ycchen] 01/14/03 Modify for 301C PALM Support */ |
5363 | if (pVBInfo->VBType & VB_XGI301C) { | |
5364 | if (pVBInfo->TVInfo & SetPALMTV) | |
ec9e5d3e | 5365 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x08, |
cc1e2398 | 5366 | 0x08); /* PALM Mode */ |
21df8fc8 | 5367 | } |
21df8fc8 | 5368 | |
cc1e2398 | 5369 | if (pVBInfo->TVInfo & SetPALMTV) { |
58839b01 | 5370 | tempax = (unsigned char) xgifb_reg_get(pVBInfo->Part2Port, |
cc1e2398 AK |
5371 | 0x01); |
5372 | tempax--; | |
dc50556b | 5373 | xgifb_reg_and(pVBInfo->Part2Port, 0x01, tempax); |
d7636e0b | 5374 | |
cc1e2398 | 5375 | /* if ( !( pVBInfo->VBType & VB_XGI301C ) ) */ |
dc50556b | 5376 | xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xEF); |
cc1e2398 | 5377 | } |
21df8fc8 | 5378 | |
cc1e2398 AK |
5379 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { |
5380 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) | |
8104e329 | 5381 | xgifb_reg_set(pVBInfo->Part2Port, 0x0B, 0x00); |
21df8fc8 | 5382 | } |
cc1e2398 AK |
5383 | |
5384 | if (pVBInfo->VBInfo & SetCRT2ToTV) | |
5385 | return; | |
21df8fc8 | 5386 | } |
d7636e0b | 5387 | |
cc1e2398 AK |
5388 | static void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex, |
5389 | struct xgi_hw_device_info *HwDeviceExtension, | |
21df8fc8 PS |
5390 | unsigned short RefreshRateTableIndex, |
5391 | struct vb_device_info *pVBInfo) | |
5392 | { | |
cc1e2398 AK |
5393 | unsigned short push1, push2, pushbx, tempax, tempbx, tempcx, temp, |
5394 | tempah, tempbh, tempch, resinfo, modeflag, CRT1Index; | |
d7636e0b | 5395 | |
cc1e2398 | 5396 | struct XGI_LCDDesStruct *LCDBDesPtr = NULL; |
d7636e0b | 5397 | |
21df8fc8 | 5398 | if (ModeNo <= 0x13) { |
1d7f656d KT |
5399 | /* si+St_ResInfo */ |
5400 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
cc1e2398 | 5401 | resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo; |
21df8fc8 | 5402 | } else { |
1d7f656d KT |
5403 | /* si+Ext_ResInfo */ |
5404 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
cc1e2398 | 5405 | resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO; |
1d7f656d KT |
5406 | CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex]. |
5407 | Ext_CRT1CRTC; | |
cc1e2398 | 5408 | CRT1Index &= IndexMask; |
21df8fc8 | 5409 | } |
d7636e0b | 5410 | |
cc1e2398 AK |
5411 | if (!(pVBInfo->VBInfo & SetCRT2ToLCD)) |
5412 | return; | |
21df8fc8 | 5413 | |
cc1e2398 | 5414 | tempbx = pVBInfo->HDE; /* RHACTE=HDE-1 */ |
21df8fc8 | 5415 | |
cc1e2398 AK |
5416 | if (XGI_IsLCDDualLink(pVBInfo)) |
5417 | tempbx = tempbx >> 1; | |
21df8fc8 | 5418 | |
cc1e2398 AK |
5419 | tempbx -= 1; |
5420 | temp = tempbx & 0x00FF; | |
8104e329 | 5421 | xgifb_reg_set(pVBInfo->Part2Port, 0x2C, temp); |
cc1e2398 AK |
5422 | temp = (tempbx & 0xFF00) >> 8; |
5423 | temp = temp << 4; | |
ec9e5d3e | 5424 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x2B, 0x0F, temp); |
cc1e2398 | 5425 | temp = 0x01; |
21df8fc8 | 5426 | |
cc1e2398 AK |
5427 | if (pVBInfo->LCDResInfo == Panel1280x1024) { |
5428 | if (pVBInfo->ModeType == ModeEGA) { | |
5429 | if (pVBInfo->VGAHDE >= 1024) { | |
5430 | temp = 0x02; | |
5431 | if (pVBInfo->LCDInfo & LCDVESATiming) | |
5432 | temp = 0x01; | |
5433 | } | |
5434 | } | |
21df8fc8 | 5435 | } |
d7636e0b | 5436 | |
8104e329 | 5437 | xgifb_reg_set(pVBInfo->Part2Port, 0x0B, temp); |
cc1e2398 AK |
5438 | tempbx = pVBInfo->VDE; /* RTVACTEO=(VDE-1)&0xFF */ |
5439 | push1 = tempbx; | |
5440 | tempbx--; | |
5441 | temp = tempbx & 0x00FF; | |
8104e329 | 5442 | xgifb_reg_set(pVBInfo->Part2Port, 0x03, temp); |
cc1e2398 | 5443 | temp = ((tempbx & 0xFF00) >> 8) & 0x07; |
ec9e5d3e | 5444 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0C, ~0x07, temp); |
21df8fc8 | 5445 | |
cc1e2398 AK |
5446 | tempcx = pVBInfo->VT - 1; |
5447 | push2 = tempcx + 1; | |
5448 | temp = tempcx & 0x00FF; /* RVTVT=VT-1 */ | |
8104e329 | 5449 | xgifb_reg_set(pVBInfo->Part2Port, 0x19, temp); |
cc1e2398 AK |
5450 | temp = (tempcx & 0xFF00) >> 8; |
5451 | temp = temp << 5; | |
8104e329 | 5452 | xgifb_reg_set(pVBInfo->Part2Port, 0x1A, temp); |
ec9e5d3e AK |
5453 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x09, 0xF0, 0x00); |
5454 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xF0, 0x00); | |
5455 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x17, 0xFB, 0x00); | |
5456 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x18, 0xDF, 0x00); | |
d7636e0b | 5457 | |
cc1e2398 AK |
5458 | /* Customized LCDB Des no add */ |
5459 | tempbx = 5; | |
5460 | LCDBDesPtr = (struct XGI_LCDDesStruct *) XGI_GetLcdPtr(tempbx, ModeNo, | |
5461 | ModeIdIndex, RefreshRateTableIndex, pVBInfo); | |
5462 | tempah = pVBInfo->LCDResInfo; | |
5463 | tempah &= PanelResInfo; | |
d7636e0b | 5464 | |
cc1e2398 AK |
5465 | if ((tempah == Panel1024x768) || (tempah == Panel1024x768x75)) { |
5466 | tempbx = 1024; | |
5467 | tempcx = 768; | |
1d7f656d KT |
5468 | } else if ((tempah == Panel1280x1024) || |
5469 | (tempah == Panel1280x1024x75)) { | |
cc1e2398 AK |
5470 | tempbx = 1280; |
5471 | tempcx = 1024; | |
5472 | } else if (tempah == Panel1400x1050) { | |
5473 | tempbx = 1400; | |
5474 | tempcx = 1050; | |
5475 | } else { | |
5476 | tempbx = 1600; | |
5477 | tempcx = 1200; | |
5478 | } | |
d7636e0b | 5479 | |
cc1e2398 AK |
5480 | if (pVBInfo->LCDInfo & EnableScalingLCD) { |
5481 | tempbx = pVBInfo->HDE; | |
5482 | tempcx = pVBInfo->VDE; | |
5483 | } | |
d7636e0b | 5484 | |
cc1e2398 AK |
5485 | pushbx = tempbx; |
5486 | tempax = pVBInfo->VT; | |
5487 | pVBInfo->LCDHDES = LCDBDesPtr->LCDHDES; | |
5488 | pVBInfo->LCDHRS = LCDBDesPtr->LCDHRS; | |
5489 | pVBInfo->LCDVDES = LCDBDesPtr->LCDVDES; | |
5490 | pVBInfo->LCDVRS = LCDBDesPtr->LCDVRS; | |
5491 | tempbx = pVBInfo->LCDVDES; | |
5492 | tempcx += tempbx; | |
d7636e0b | 5493 | |
cc1e2398 AK |
5494 | if (tempcx >= tempax) |
5495 | tempcx -= tempax; /* lcdvdes */ | |
d7636e0b | 5496 | |
cc1e2398 | 5497 | temp = tempbx & 0x00FF; /* RVEQ1EQ=lcdvdes */ |
8104e329 | 5498 | xgifb_reg_set(pVBInfo->Part2Port, 0x05, temp); |
cc1e2398 | 5499 | temp = tempcx & 0x00FF; |
8104e329 | 5500 | xgifb_reg_set(pVBInfo->Part2Port, 0x06, temp); |
cc1e2398 AK |
5501 | tempch = ((tempcx & 0xFF00) >> 8) & 0x07; |
5502 | tempbh = ((tempbx & 0xFF00) >> 8) & 0x07; | |
5503 | tempah = tempch; | |
5504 | tempah = tempah << 3; | |
5505 | tempah |= tempbh; | |
8104e329 | 5506 | xgifb_reg_set(pVBInfo->Part2Port, 0x02, tempah); |
d7636e0b | 5507 | |
cc1e2398 AK |
5508 | /* getlcdsync() */ |
5509 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); | |
5510 | tempcx = tempbx; | |
5511 | tempax = pVBInfo->VT; | |
5512 | tempbx = pVBInfo->LCDVRS; | |
d7636e0b | 5513 | |
cc1e2398 AK |
5514 | /* if (SetLCD_Info & EnableScalingLCD) */ |
5515 | tempcx += tempbx; | |
5516 | if (tempcx >= tempax) | |
5517 | tempcx -= tempax; | |
d7636e0b | 5518 | |
cc1e2398 | 5519 | temp = tempbx & 0x00FF; /* RTVACTEE=lcdvrs */ |
8104e329 | 5520 | xgifb_reg_set(pVBInfo->Part2Port, 0x04, temp); |
cc1e2398 AK |
5521 | temp = (tempbx & 0xFF00) >> 8; |
5522 | temp = temp << 4; | |
5523 | temp |= (tempcx & 0x000F); | |
8104e329 | 5524 | xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp); |
cc1e2398 AK |
5525 | tempcx = pushbx; |
5526 | tempax = pVBInfo->HT; | |
5527 | tempbx = pVBInfo->LCDHDES; | |
5528 | tempbx &= 0x0FFF; | |
5529 | ||
5530 | if (XGI_IsLCDDualLink(pVBInfo)) { | |
5531 | tempax = tempax >> 1; | |
5532 | tempbx = tempbx >> 1; | |
5533 | tempcx = tempcx >> 1; | |
5534 | } | |
5535 | ||
5536 | if (pVBInfo->VBType & VB_XGI302LV) | |
5537 | tempbx += 1; | |
5538 | ||
5539 | if (pVBInfo->VBType & VB_XGI301C) /* tap4 */ | |
5540 | tempbx += 1; | |
5541 | ||
5542 | tempcx += tempbx; | |
5543 | ||
5544 | if (tempcx >= tempax) | |
5545 | tempcx -= tempax; | |
5546 | ||
5547 | temp = tempbx & 0x00FF; | |
8104e329 | 5548 | xgifb_reg_set(pVBInfo->Part2Port, 0x1F, temp); /* RHBLKE=lcdhdes */ |
cc1e2398 | 5549 | temp = ((tempbx & 0xFF00) >> 8) << 4; |
8104e329 | 5550 | xgifb_reg_set(pVBInfo->Part2Port, 0x20, temp); |
cc1e2398 | 5551 | temp = tempcx & 0x00FF; |
8104e329 | 5552 | xgifb_reg_set(pVBInfo->Part2Port, 0x23, temp); /* RHEQPLE=lcdhdee */ |
cc1e2398 | 5553 | temp = (tempcx & 0xFF00) >> 8; |
8104e329 | 5554 | xgifb_reg_set(pVBInfo->Part2Port, 0x25, temp); |
cc1e2398 AK |
5555 | |
5556 | /* getlcdsync() */ | |
5557 | XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); | |
5558 | tempcx = tempax; | |
5559 | tempax = pVBInfo->HT; | |
5560 | tempbx = pVBInfo->LCDHRS; | |
5561 | /* if ( SetLCD_Info & EnableScalingLCD) */ | |
5562 | if (XGI_IsLCDDualLink(pVBInfo)) { | |
5563 | tempax = tempax >> 1; | |
5564 | tempbx = tempbx >> 1; | |
5565 | tempcx = tempcx >> 1; | |
5566 | } | |
5567 | ||
5568 | if (pVBInfo->VBType & VB_XGI302LV) | |
5569 | tempbx += 1; | |
5570 | ||
5571 | tempcx += tempbx; | |
5572 | ||
5573 | if (tempcx >= tempax) | |
5574 | tempcx -= tempax; | |
5575 | ||
5576 | temp = tempbx & 0x00FF; /* RHBURSTS=lcdhrs */ | |
8104e329 | 5577 | xgifb_reg_set(pVBInfo->Part2Port, 0x1C, temp); |
cc1e2398 AK |
5578 | |
5579 | temp = (tempbx & 0xFF00) >> 8; | |
5580 | temp = temp << 4; | |
ec9e5d3e | 5581 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F0, temp); |
cc1e2398 | 5582 | temp = tempcx & 0x00FF; /* RHSYEXP2S=lcdhre */ |
8104e329 | 5583 | xgifb_reg_set(pVBInfo->Part2Port, 0x21, temp); |
cc1e2398 AK |
5584 | |
5585 | if (!(pVBInfo->LCDInfo & LCDVESATiming)) { | |
5586 | if (pVBInfo->VGAVDE == 525) { | |
5587 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | |
5588 | | VB_XGI301LV | VB_XGI302LV | |
5589 | | VB_XGI301C)) { | |
5590 | temp = 0xC6; | |
5591 | } else | |
5592 | temp = 0xC4; | |
5593 | ||
8104e329 AK |
5594 | xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp); |
5595 | xgifb_reg_set(pVBInfo->Part2Port, 0x30, 0xB3); | |
21df8fc8 | 5596 | } |
cc1e2398 AK |
5597 | |
5598 | if (pVBInfo->VGAVDE == 420) { | |
5599 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | |
5600 | | VB_XGI301LV | VB_XGI302LV | |
5601 | | VB_XGI301C)) { | |
5602 | temp = 0x4F; | |
5603 | } else | |
5604 | temp = 0x4E; | |
8104e329 | 5605 | xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp); |
21df8fc8 | 5606 | } |
cc1e2398 AK |
5607 | } |
5608 | } | |
5609 | ||
5610 | /* --------------------------------------------------------------------- */ | |
5611 | /* Function : XGI_GetTap4Ptr */ | |
5612 | /* Input : */ | |
5613 | /* Output : di -> Tap4 Reg. Setting Pointer */ | |
5614 | /* Description : */ | |
5615 | /* --------------------------------------------------------------------- */ | |
5616 | static struct XGI301C_Tap4TimingStruct *XGI_GetTap4Ptr(unsigned short tempcx, | |
5617 | struct vb_device_info *pVBInfo) | |
5618 | { | |
5619 | unsigned short tempax, tempbx, i; | |
5620 | ||
5621 | struct XGI301C_Tap4TimingStruct *Tap4TimingPtr; | |
5622 | ||
5623 | if (tempcx == 0) { | |
5624 | tempax = pVBInfo->VGAHDE; | |
5625 | tempbx = pVBInfo->HDE; | |
5626 | } else { | |
5627 | tempax = pVBInfo->VGAVDE; | |
5628 | tempbx = pVBInfo->VDE; | |
5629 | } | |
5630 | ||
5631 | if (tempax < tempbx) | |
5632 | return &EnlargeTap4Timing[0]; | |
5633 | else if (tempax == tempbx) | |
5634 | return &NoScaleTap4Timing[0]; /* 1:1 */ | |
5635 | else | |
5636 | Tap4TimingPtr = NTSCTap4Timing; /* NTSC */ | |
5637 | ||
5638 | if (pVBInfo->TVInfo & SetPALTV) | |
5639 | Tap4TimingPtr = PALTap4Timing; | |
5640 | ||
5641 | if (pVBInfo->VBInfo & SetCRT2ToYPbPr) { | |
5642 | if (pVBInfo->TVInfo & SetYPbPrMode525i) | |
5643 | Tap4TimingPtr = YPbPr525iTap4Timing; | |
5644 | if (pVBInfo->TVInfo & SetYPbPrMode525p) | |
5645 | Tap4TimingPtr = YPbPr525pTap4Timing; | |
5646 | if (pVBInfo->TVInfo & SetYPbPrMode750p) | |
5647 | Tap4TimingPtr = YPbPr750pTap4Timing; | |
5648 | } | |
5649 | ||
5650 | if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) | |
5651 | Tap4TimingPtr = HiTVTap4Timing; | |
5652 | ||
5653 | i = 0; | |
5654 | while (Tap4TimingPtr[i].DE != 0xFFFF) { | |
5655 | if (Tap4TimingPtr[i].DE == tempax) | |
21df8fc8 | 5656 | break; |
cc1e2398 AK |
5657 | i++; |
5658 | } | |
5659 | return &Tap4TimingPtr[i]; | |
5660 | } | |
5661 | ||
5662 | static void XGI_SetTap4Regs(struct vb_device_info *pVBInfo) | |
5663 | { | |
5664 | unsigned short i, j; | |
5665 | ||
5666 | struct XGI301C_Tap4TimingStruct *Tap4TimingPtr; | |
5667 | ||
5668 | if (!(pVBInfo->VBType & VB_XGI301C)) | |
5669 | return; | |
5670 | ||
cc1e2398 AK |
5671 | Tap4TimingPtr = XGI_GetTap4Ptr(0, pVBInfo); /* Set Horizontal Scaling */ |
5672 | for (i = 0x80, j = 0; i <= 0xBF; i++, j++) | |
8104e329 | 5673 | xgifb_reg_set(pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]); |
cc1e2398 | 5674 | |
1d7f656d KT |
5675 | if ((pVBInfo->VBInfo & SetCRT2ToTV) && |
5676 | (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV))) { | |
5677 | /* Set Vertical Scaling */ | |
5678 | Tap4TimingPtr = XGI_GetTap4Ptr(1, pVBInfo); | |
cc1e2398 | 5679 | for (i = 0xC0, j = 0; i < 0xFF; i++, j++) |
1d7f656d KT |
5680 | xgifb_reg_set(pVBInfo->Part2Port, |
5681 | i, | |
5682 | Tap4TimingPtr->Reg[j]); | |
cc1e2398 AK |
5683 | } |
5684 | ||
1d7f656d KT |
5685 | if ((pVBInfo->VBInfo & SetCRT2ToTV) && |
5686 | (!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV))) | |
5687 | /* Enable V.Scaling */ | |
5688 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x04); | |
cc1e2398 | 5689 | else |
1d7f656d KT |
5690 | /* Enable H.Scaling */ |
5691 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x10); | |
cc1e2398 AK |
5692 | } |
5693 | ||
5694 | static void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex, | |
5695 | struct vb_device_info *pVBInfo) | |
5696 | { | |
5697 | unsigned short i; | |
5698 | unsigned char *tempdi; | |
5699 | unsigned short modeflag; | |
5700 | ||
5701 | if (ModeNo <= 0x13) | |
1d7f656d KT |
5702 | /* si+St_ResInfo */ |
5703 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
cc1e2398 | 5704 | else |
1d7f656d KT |
5705 | /* si+Ext_ResInfo */ |
5706 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
cc1e2398 | 5707 | |
8104e329 | 5708 | xgifb_reg_set(pVBInfo->Part3Port, 0x00, 0x00); |
cc1e2398 | 5709 | if (pVBInfo->TVInfo & SetPALTV) { |
8104e329 AK |
5710 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA); |
5711 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8); | |
cc1e2398 | 5712 | } else { |
8104e329 AK |
5713 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xF5); |
5714 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xB7); | |
cc1e2398 AK |
5715 | } |
5716 | ||
5717 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) | |
5718 | return; | |
5719 | ||
5720 | if (pVBInfo->TVInfo & SetPALMTV) { | |
8104e329 AK |
5721 | xgifb_reg_set(pVBInfo->Part3Port, 0x13, 0xFA); |
5722 | xgifb_reg_set(pVBInfo->Part3Port, 0x14, 0xC8); | |
5723 | xgifb_reg_set(pVBInfo->Part3Port, 0x3D, 0xA8); | |
cc1e2398 AK |
5724 | } |
5725 | ||
5726 | if ((pVBInfo->VBInfo & SetCRT2ToHiVisionTV) || (pVBInfo->VBInfo | |
5727 | & SetCRT2ToYPbPr)) { | |
5728 | if (pVBInfo->TVInfo & SetYPbPrMode525i) | |
5729 | return; | |
5730 | ||
5731 | tempdi = pVBInfo->HiTVGroup3Data; | |
5732 | if (pVBInfo->SetFlag & TVSimuMode) { | |
5733 | tempdi = pVBInfo->HiTVGroup3Simu; | |
5734 | if (!(modeflag & Charx8Dot)) | |
5735 | tempdi = pVBInfo->HiTVGroup3Text; | |
21df8fc8 | 5736 | } |
cc1e2398 AK |
5737 | |
5738 | if (pVBInfo->TVInfo & SetYPbPrMode525p) | |
5739 | tempdi = pVBInfo->Ren525pGroup3; | |
5740 | ||
5741 | if (pVBInfo->TVInfo & SetYPbPrMode750p) | |
5742 | tempdi = pVBInfo->Ren750pGroup3; | |
5743 | ||
5744 | for (i = 0; i <= 0x3E; i++) | |
8104e329 | 5745 | xgifb_reg_set(pVBInfo->Part3Port, i, tempdi[i]); |
cc1e2398 AK |
5746 | |
5747 | if (pVBInfo->VBType & VB_XGI301C) { /* Marcovision */ | |
5748 | if (pVBInfo->TVInfo & SetYPbPrMode525p) | |
8104e329 | 5749 | xgifb_reg_set(pVBInfo->Part3Port, 0x28, 0x3f); |
21df8fc8 PS |
5750 | } |
5751 | } | |
cc1e2398 AK |
5752 | return; |
5753 | } /* {end of XGI_SetGroup3} */ | |
d7636e0b | 5754 | |
cc1e2398 | 5755 | static void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex, |
21df8fc8 | 5756 | unsigned short RefreshRateTableIndex, |
cc1e2398 | 5757 | struct xgi_hw_device_info *HwDeviceExtension, |
21df8fc8 PS |
5758 | struct vb_device_info *pVBInfo) |
5759 | { | |
cc1e2398 | 5760 | unsigned short tempax, tempcx, tempbx, modeflag, temp, temp2; |
d7636e0b | 5761 | |
cc1e2398 AK |
5762 | unsigned long tempebx, tempeax, templong; |
5763 | ||
5764 | if (ModeNo <= 0x13) | |
1d7f656d KT |
5765 | /* si+St_ResInfo */ |
5766 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
cc1e2398 | 5767 | else |
1d7f656d KT |
5768 | /* si+Ext_ResInfo */ |
5769 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
cc1e2398 AK |
5770 | |
5771 | temp = pVBInfo->RVBHCFACT; | |
8104e329 | 5772 | xgifb_reg_set(pVBInfo->Part4Port, 0x13, temp); |
cc1e2398 AK |
5773 | |
5774 | tempbx = pVBInfo->RVBHCMAX; | |
5775 | temp = tempbx & 0x00FF; | |
8104e329 | 5776 | xgifb_reg_set(pVBInfo->Part4Port, 0x14, temp); |
cc1e2398 AK |
5777 | temp2 = ((tempbx & 0xFF00) >> 8) << 7; |
5778 | tempcx = pVBInfo->VGAHT - 1; | |
5779 | temp = tempcx & 0x00FF; | |
8104e329 | 5780 | xgifb_reg_set(pVBInfo->Part4Port, 0x16, temp); |
cc1e2398 AK |
5781 | |
5782 | temp = ((tempcx & 0xFF00) >> 8) << 3; | |
5783 | temp2 |= temp; | |
5784 | ||
5785 | tempcx = pVBInfo->VGAVT - 1; | |
5786 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) | |
5787 | tempcx -= 5; | |
5788 | ||
5789 | temp = tempcx & 0x00FF; | |
8104e329 | 5790 | xgifb_reg_set(pVBInfo->Part4Port, 0x17, temp); |
cc1e2398 | 5791 | temp = temp2 | ((tempcx & 0xFF00) >> 8); |
8104e329 | 5792 | xgifb_reg_set(pVBInfo->Part4Port, 0x15, temp); |
b9bf6e4e | 5793 | xgifb_reg_or(pVBInfo->Part4Port, 0x0D, 0x08); |
cc1e2398 AK |
5794 | tempcx = pVBInfo->VBInfo; |
5795 | tempbx = pVBInfo->VGAHDE; | |
5796 | ||
5797 | if (modeflag & HalfDCLK) | |
5798 | tempbx = tempbx >> 1; | |
5799 | ||
5800 | if (XGI_IsLCDDualLink(pVBInfo)) | |
5801 | tempbx = tempbx >> 1; | |
5802 | ||
5803 | if (tempcx & SetCRT2ToHiVisionTV) { | |
5804 | temp = 0; | |
5805 | if (tempbx <= 1024) | |
5806 | temp = 0xA0; | |
5807 | if (tempbx == 1280) | |
5808 | temp = 0xC0; | |
5809 | } else if (tempcx & SetCRT2ToTV) { | |
5810 | temp = 0xA0; | |
5811 | if (tempbx <= 800) | |
5812 | temp = 0x80; | |
5813 | } else { | |
5814 | temp = 0x80; | |
5815 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { | |
5816 | temp = 0; | |
5817 | if (tempbx > 800) | |
5818 | temp = 0x60; | |
5819 | } | |
5820 | } | |
5821 | ||
5822 | if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)) { | |
5823 | temp = 0x00; | |
5824 | if (pVBInfo->VGAHDE == 1280) | |
5825 | temp = 0x40; | |
5826 | if (pVBInfo->VGAHDE == 1024) | |
5827 | temp = 0x20; | |
5828 | } | |
ec9e5d3e | 5829 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0E, ~0xEF, temp); |
cc1e2398 AK |
5830 | |
5831 | tempebx = pVBInfo->VDE; | |
5832 | ||
5833 | if (tempcx & SetCRT2ToHiVisionTV) { | |
5834 | if (!(temp & 0xE000)) | |
5835 | tempbx = tempbx >> 1; | |
5836 | } | |
5837 | ||
5838 | tempcx = pVBInfo->RVBHRS; | |
5839 | temp = tempcx & 0x00FF; | |
8104e329 | 5840 | xgifb_reg_set(pVBInfo->Part4Port, 0x18, temp); |
cc1e2398 AK |
5841 | |
5842 | tempeax = pVBInfo->VGAVDE; | |
5843 | tempcx |= 0x04000; | |
5844 | ||
5845 | if (tempeax <= tempebx) { | |
5846 | tempcx = (tempcx & (~0x4000)); | |
5847 | tempeax = pVBInfo->VGAVDE; | |
5848 | } else { | |
5849 | tempeax -= tempebx; | |
5850 | } | |
5851 | ||
5852 | templong = (tempeax * 256 * 1024) % tempebx; | |
5853 | tempeax = (tempeax * 256 * 1024) / tempebx; | |
5854 | tempebx = tempeax; | |
5855 | ||
5856 | if (templong != 0) | |
5857 | tempebx++; | |
5858 | ||
5859 | temp = (unsigned short) (tempebx & 0x000000FF); | |
8104e329 | 5860 | xgifb_reg_set(pVBInfo->Part4Port, 0x1B, temp); |
cc1e2398 AK |
5861 | |
5862 | temp = (unsigned short) ((tempebx & 0x0000FF00) >> 8); | |
8104e329 | 5863 | xgifb_reg_set(pVBInfo->Part4Port, 0x1A, temp); |
cc1e2398 AK |
5864 | tempbx = (unsigned short) (tempebx >> 16); |
5865 | temp = tempbx & 0x00FF; | |
5866 | temp = temp << 4; | |
5867 | temp |= ((tempcx & 0xFF00) >> 8); | |
8104e329 | 5868 | xgifb_reg_set(pVBInfo->Part4Port, 0x19, temp); |
cc1e2398 AK |
5869 | |
5870 | /* 301b */ | |
5871 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | |
5872 | | VB_XGI302LV | VB_XGI301C)) { | |
5873 | temp = 0x0028; | |
8104e329 | 5874 | xgifb_reg_set(pVBInfo->Part4Port, 0x1C, temp); |
cc1e2398 AK |
5875 | tempax = pVBInfo->VGAHDE; |
5876 | if (modeflag & HalfDCLK) | |
5877 | tempax = tempax >> 1; | |
d7636e0b | 5878 | |
cc1e2398 AK |
5879 | if (XGI_IsLCDDualLink(pVBInfo)) |
5880 | tempax = tempax >> 1; | |
d7636e0b | 5881 | |
1d7f656d KT |
5882 | /* if((pVBInfo->VBInfo&(SetCRT2ToLCD)) || |
5883 | ((pVBInfo->TVInfo&SetYPbPrMode525p) || | |
5884 | (pVBInfo->TVInfo&SetYPbPrMode750p))) { */ | |
cc1e2398 AK |
5885 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { |
5886 | if (tempax > 800) | |
5887 | tempax -= 800; | |
5888 | } else { | |
5889 | if (pVBInfo->VGAHDE > 800) { | |
5890 | if (pVBInfo->VGAHDE == 1024) | |
5891 | tempax = (tempax * 25 / 32) - 1; | |
5892 | else | |
5893 | tempax = (tempax * 20 / 32) - 1; | |
5894 | } | |
5895 | } | |
5896 | tempax -= 1; | |
21df8fc8 | 5897 | |
cc1e2398 AK |
5898 | /* |
5899 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVisionTV)) { | |
5900 | if (pVBInfo->VBType & VB_XGI301LV) { | |
1d7f656d KT |
5901 | if (!(pVBInfo->TVInfo & |
5902 | (SetYPbPrMode525p | | |
5903 | SetYPbPrMode750p | | |
5904 | SetYPbPrMode1080i))) { | |
cc1e2398 AK |
5905 | if (pVBInfo->VGAHDE > 800) { |
5906 | if (pVBInfo->VGAHDE == 1024) | |
1d7f656d KT |
5907 | tempax =(tempax * 25 / |
5908 | 32) - 1; | |
cc1e2398 | 5909 | else |
1d7f656d KT |
5910 | tempax = (tempax * 20 / |
5911 | 32) - 1; | |
cc1e2398 AK |
5912 | } |
5913 | } | |
5914 | } else { | |
5915 | if (pVBInfo->VGAHDE > 800) { | |
5916 | if (pVBInfo->VGAHDE == 1024) | |
5917 | tempax = (tempax * 25 / 32) - 1; | |
5918 | else | |
5919 | tempax = (tempax * 20 / 32) - 1; | |
5920 | } | |
5921 | } | |
5922 | } | |
5923 | */ | |
21df8fc8 | 5924 | |
cc1e2398 AK |
5925 | temp = (tempax & 0xFF00) >> 8; |
5926 | temp = ((temp & 0x0003) << 4); | |
8104e329 | 5927 | xgifb_reg_set(pVBInfo->Part4Port, 0x1E, temp); |
cc1e2398 | 5928 | temp = (tempax & 0x00FF); |
8104e329 | 5929 | xgifb_reg_set(pVBInfo->Part4Port, 0x1D, temp); |
21df8fc8 | 5930 | |
cc1e2398 AK |
5931 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVisionTV)) { |
5932 | if (pVBInfo->VGAHDE > 800) | |
b9bf6e4e | 5933 | xgifb_reg_or(pVBInfo->Part4Port, 0x1E, 0x08); |
d7636e0b | 5934 | |
cc1e2398 AK |
5935 | } |
5936 | temp = 0x0036; | |
d7636e0b | 5937 | |
cc1e2398 AK |
5938 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
5939 | if (!(pVBInfo->TVInfo & (NTSC1024x768 | |
5940 | | SetYPbPrMode525p | SetYPbPrMode750p | |
5941 | | SetYPbPrMode1080i))) { | |
5942 | temp |= 0x0001; | |
5943 | if ((pVBInfo->VBInfo & SetInSlaveMode) | |
5944 | && (!(pVBInfo->TVInfo | |
5945 | & TVSimuMode))) | |
5946 | temp &= (~0x0001); | |
5947 | } | |
5948 | } | |
d7636e0b | 5949 | |
ec9e5d3e | 5950 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x1F, 0x00C0, temp); |
cc1e2398 AK |
5951 | tempbx = pVBInfo->HT; |
5952 | if (XGI_IsLCDDualLink(pVBInfo)) | |
5953 | tempbx = tempbx >> 1; | |
5954 | tempbx = (tempbx >> 1) - 2; | |
5955 | temp = ((tempbx & 0x0700) >> 8) << 3; | |
ec9e5d3e | 5956 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, 0x00C0, temp); |
cc1e2398 | 5957 | temp = tempbx & 0x00FF; |
8104e329 | 5958 | xgifb_reg_set(pVBInfo->Part4Port, 0x22, temp); |
cc1e2398 AK |
5959 | } |
5960 | /* end 301b */ | |
d7636e0b | 5961 | |
cc1e2398 AK |
5962 | if (pVBInfo->ISXPDOS == 0) |
5963 | XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, | |
5964 | pVBInfo); | |
5965 | } | |
d7636e0b | 5966 | |
cc1e2398 AK |
5967 | static void XGINew_EnableCRT2(struct vb_device_info *pVBInfo) |
5968 | { | |
ec9e5d3e | 5969 | xgifb_reg_and_or(pVBInfo->P3c4, 0x1E, 0xFF, 0x20); |
cc1e2398 | 5970 | } |
d7636e0b | 5971 | |
cc1e2398 AK |
5972 | static void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex, |
5973 | struct vb_device_info *pVBInfo) | |
5974 | { | |
5975 | unsigned short Pindex, Pdata; | |
d7636e0b | 5976 | |
cc1e2398 AK |
5977 | Pindex = pVBInfo->Part5Port; |
5978 | Pdata = pVBInfo->Part5Port + 1; | |
5979 | if (pVBInfo->ModeType == ModeVGA) { | |
5980 | if (!(pVBInfo->VBInfo & (SetInSlaveMode | LoadDACFlag | |
5981 | | CRT2DisplayFlag))) { | |
5982 | XGINew_EnableCRT2(pVBInfo); | |
5983 | /* LoadDAC2(pVBInfo->Part5Port, ModeNo, ModeIdIndex); */ | |
21df8fc8 | 5984 | } |
21df8fc8 | 5985 | } |
cc1e2398 | 5986 | return; |
d7636e0b | 5987 | } |
5988 | ||
063b9c4b | 5989 | static void XGI_EnableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, |
21df8fc8 | 5990 | struct vb_device_info *pVBInfo) |
d7636e0b | 5991 | { |
ec9e5d3e | 5992 | xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x40); |
d7636e0b | 5993 | } |
5994 | ||
063b9c4b | 5995 | static void XGI_DisableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, |
21df8fc8 | 5996 | struct vb_device_info *pVBInfo) |
d7636e0b | 5997 | { |
5998 | ||
ec9e5d3e | 5999 | xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x00); |
d7636e0b | 6000 | } |
6001 | ||
d7636e0b | 6002 | /*----------------------------------------------------------------------------*/ |
6003 | /* input */ | |
6004 | /* bl[5] : 1;LVDS signal on */ | |
6005 | /* bl[1] : 1;LVDS backlight on */ | |
6006 | /* bl[0] : 1:LVDS VDD on */ | |
6007 | /* bh: 100000b : clear bit 5, to set bit5 */ | |
6008 | /* 000010b : clear bit 1, to set bit1 */ | |
6009 | /* 000001b : clear bit 0, to set bit0 */ | |
6010 | /*----------------------------------------------------------------------------*/ | |
21df8fc8 PS |
6011 | void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl, |
6012 | struct vb_device_info *pVBInfo) | |
d7636e0b | 6013 | { |
21df8fc8 | 6014 | unsigned char CR4A, temp; |
d7636e0b | 6015 | |
58839b01 | 6016 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
21df8fc8 PS |
6017 | tempbh &= 0x23; |
6018 | tempbl &= 0x23; | |
dc50556b | 6019 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */ |
d7636e0b | 6020 | |
21df8fc8 PS |
6021 | if (tempbh & 0x20) { |
6022 | temp = (tempbl >> 4) & 0x02; | |
d7636e0b | 6023 | |
1d7f656d KT |
6024 | /* CR B4[1] */ |
6025 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp); | |
d7636e0b | 6026 | |
21df8fc8 | 6027 | } |
d7636e0b | 6028 | |
58839b01 | 6029 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x48); |
d7636e0b | 6030 | |
21df8fc8 PS |
6031 | temp = XG21GPIODataTransfer(temp); |
6032 | temp &= ~tempbh; | |
6033 | temp |= tempbl; | |
8104e329 | 6034 | xgifb_reg_set(pVBInfo->P3d4, 0x48, temp); |
d7636e0b | 6035 | } |
6036 | ||
21df8fc8 PS |
6037 | void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl, |
6038 | struct vb_device_info *pVBInfo) | |
d7636e0b | 6039 | { |
21df8fc8 PS |
6040 | unsigned char CR4A, temp; |
6041 | unsigned short tempbh0, tempbl0; | |
d7636e0b | 6042 | |
21df8fc8 PS |
6043 | tempbh0 = tempbh; |
6044 | tempbl0 = tempbl; | |
6045 | tempbh0 &= 0x20; | |
6046 | tempbl0 &= 0x20; | |
6047 | tempbh0 >>= 3; | |
6048 | tempbl0 >>= 3; | |
d7636e0b | 6049 | |
21df8fc8 PS |
6050 | if (tempbh & 0x20) { |
6051 | temp = (tempbl >> 4) & 0x02; | |
d7636e0b | 6052 | |
1d7f656d KT |
6053 | /* CR B4[1] */ |
6054 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~0x02, temp); | |
d7636e0b | 6055 | |
21df8fc8 | 6056 | } |
ec9e5d3e | 6057 | xgifb_reg_and_or(pVBInfo->P3d4, 0xB4, ~tempbh0, tempbl0); |
d7636e0b | 6058 | |
58839b01 | 6059 | CR4A = xgifb_reg_get(pVBInfo->P3d4, 0x4A); |
21df8fc8 PS |
6060 | tempbh &= 0x03; |
6061 | tempbl &= 0x03; | |
6062 | tempbh <<= 2; | |
6063 | tempbl <<= 2; /* GPIOC,GPIOD */ | |
dc50556b | 6064 | xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~tempbh); /* enable GPIO write */ |
ec9e5d3e | 6065 | xgifb_reg_and_or(pVBInfo->P3d4, 0x48, ~tempbh, tempbl); |
d7636e0b | 6066 | } |
6067 | ||
6068 | /* --------------------------------------------------------------------- */ | |
80adad85 | 6069 | unsigned short XGI_GetLVDSOEMTableIndex(struct vb_device_info *pVBInfo) |
d7636e0b | 6070 | { |
21df8fc8 | 6071 | unsigned short index; |
d7636e0b | 6072 | |
58839b01 | 6073 | index = xgifb_reg_get(pVBInfo->P3d4, 0x36); |
21df8fc8 PS |
6074 | if (index < sizeof(XGI21_LCDCapList) |
6075 | / sizeof(struct XGI21_LVDSCapStruct)) | |
6076 | return index; | |
6077 | return 0; | |
d7636e0b | 6078 | } |
6079 | ||
6080 | /* --------------------------------------------------------------------- */ | |
6081 | /* Function : XGI_XG21SetPanelDelay */ | |
6082 | /* Input : */ | |
6083 | /* Output : */ | |
6084 | /* Description : */ | |
6085 | /* I/P : bl : 1 ; T1 : the duration between CPL on and signal on */ | |
6086 | /* : bl : 2 ; T2 : the duration signal on and Vdd on */ | |
6087 | /* : bl : 3 ; T3 : the duration between CPL off and signal off */ | |
6088 | /* : bl : 4 ; T4 : the duration signal off and Vdd off */ | |
6089 | /* --------------------------------------------------------------------- */ | |
21df8fc8 PS |
6090 | void XGI_XG21SetPanelDelay(unsigned short tempbl, |
6091 | struct vb_device_info *pVBInfo) | |
d7636e0b | 6092 | { |
21df8fc8 | 6093 | unsigned short index; |
d7636e0b | 6094 | |
21df8fc8 PS |
6095 | index = XGI_GetLVDSOEMTableIndex(pVBInfo); |
6096 | if (tempbl == 1) | |
d80aaa01 | 6097 | mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S1); |
d7636e0b | 6098 | |
21df8fc8 | 6099 | if (tempbl == 2) |
d80aaa01 | 6100 | mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S2); |
d7636e0b | 6101 | |
21df8fc8 | 6102 | if (tempbl == 3) |
d80aaa01 | 6103 | mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S3); |
d7636e0b | 6104 | |
21df8fc8 | 6105 | if (tempbl == 4) |
d80aaa01 | 6106 | mdelay(pVBInfo->XG21_LVDSCapList[index].PSC_S4); |
d7636e0b | 6107 | } |
6108 | ||
82d6eb5b | 6109 | unsigned char XGI_XG21CheckLVDSMode(unsigned short ModeNo, |
21df8fc8 PS |
6110 | unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) |
6111 | { | |
6112 | unsigned short xres, yres, colordepth, modeflag, resindex, | |
6113 | lvdstableindex; | |
6114 | ||
6115 | resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); | |
6116 | if (ModeNo <= 0x13) { | |
6117 | xres = pVBInfo->StResInfo[resindex].HTotal; | |
6118 | yres = pVBInfo->StResInfo[resindex].VTotal; | |
1d7f656d KT |
6119 | /* si+St_ResInfo */ |
6120 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
21df8fc8 PS |
6121 | } else { |
6122 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ | |
6123 | yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */ | |
1d7f656d KT |
6124 | /* si+St_ModeFlag */ |
6125 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
21df8fc8 PS |
6126 | } |
6127 | ||
6128 | if (!(modeflag & Charx8Dot)) { | |
6129 | xres /= 9; | |
6130 | xres *= 8; | |
6131 | } | |
6132 | ||
6133 | if (ModeNo > 0x13) { | |
6134 | if ((ModeNo > 0x13) && (modeflag & HalfDCLK)) | |
6135 | xres *= 2; | |
6136 | ||
6137 | if ((ModeNo > 0x13) && (modeflag & DoubleScanMode)) | |
6138 | yres *= 2; | |
6139 | ||
6140 | } | |
6141 | ||
6142 | lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo); | |
6143 | if (xres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE)) | |
6144 | return 0; | |
6145 | ||
6146 | if (yres > (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE)) | |
6147 | return 0; | |
6148 | ||
6149 | if (ModeNo > 0x13) { | |
1d7f656d KT |
6150 | if ((xres != (pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
6151 | LVDSHDE)) || | |
6152 | (yres != (pVBInfo->XG21_LVDSCapList[lvdstableindex]. | |
6153 | LVDSVDE))) { | |
6154 | colordepth = XGI_GetColorDepth(ModeNo, | |
6155 | ModeIdIndex, | |
6156 | pVBInfo); | |
21df8fc8 PS |
6157 | if (colordepth > 2) |
6158 | return 0; | |
6159 | ||
6160 | } | |
6161 | } | |
6162 | return 1; | |
d7636e0b | 6163 | } |
6164 | ||
80adad85 | 6165 | void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo) |
d7636e0b | 6166 | { |
21df8fc8 | 6167 | unsigned char temp; |
d7636e0b | 6168 | |
58839b01 | 6169 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); /* D[0] 1: 18bit */ |
21df8fc8 | 6170 | temp = (temp & 1) << 6; |
1d7f656d KT |
6171 | /* SR06[6] 18bit Dither */ |
6172 | xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x40, temp); | |
6173 | /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: dual 12bits */ | |
6174 | xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); | |
d7636e0b | 6175 | |
6176 | } | |
6177 | ||
80adad85 | 6178 | void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo) |
d7636e0b | 6179 | { |
21df8fc8 | 6180 | unsigned char temp; |
d7636e0b | 6181 | |
1d7f656d KT |
6182 | /* D[1:0] 01: 18bit, 00: dual 12, 10: single 24 */ |
6183 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); | |
21df8fc8 | 6184 | temp = (temp & 3) << 6; |
1d7f656d KT |
6185 | /* SR06[7]0: dual 12/1: single 24 [6] 18bit Dither <= 0 h/w recommend */ |
6186 | xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0xc0, temp & 0x80); | |
6187 | /* SR09[7] enable FP output, SR09[6] 1: sigle 18bits, 0: 24bits */ | |
6188 | xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0xc0, temp | 0x80); | |
d7636e0b | 6189 | |
6190 | } | |
6191 | ||
64db29f5 AK |
6192 | static void xgifb_set_lvds(int chip_id, |
6193 | unsigned short ModeNo, | |
6194 | unsigned short ModeIdIndex, | |
6195 | struct vb_device_info *pVBInfo) | |
21df8fc8 PS |
6196 | { |
6197 | unsigned char temp, Miscdata; | |
6198 | unsigned short xres, yres, modeflag, resindex, lvdstableindex; | |
6199 | unsigned short LVDSHT, LVDSHBS, LVDSHRS, LVDSHRE, LVDSHBE; | |
6200 | unsigned short LVDSVT, LVDSVBS, LVDSVRS, LVDSVRE, LVDSVBE; | |
6201 | unsigned short value; | |
6202 | ||
6203 | lvdstableindex = XGI_GetLVDSOEMTableIndex(pVBInfo); | |
1d7f656d KT |
6204 | temp = (unsigned char) ((pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
6205 | LVDS_Capability & | |
6206 | (LCDPolarity << 8)) >> 8); | |
21df8fc8 | 6207 | temp &= LCDPolarity; |
d8ad0a6d | 6208 | Miscdata = (unsigned char) inb(pVBInfo->P3cc); |
21df8fc8 | 6209 | |
efdf4ee7 | 6210 | outb((Miscdata & 0x3F) | temp, pVBInfo->P3c2); |
21df8fc8 | 6211 | |
1d7f656d KT |
6212 | temp = (unsigned char) (pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
6213 | LVDS_Capability & LCDPolarity); | |
6214 | /* SR35[7] FP VSync polarity */ | |
6215 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x80, temp & 0x80); | |
6216 | /* SR30[5] FP HSync polarity */ | |
6217 | xgifb_reg_and_or(pVBInfo->P3c4, 0x30, ~0x20, (temp & 0x40) >> 1); | |
21df8fc8 | 6218 | |
64db29f5 AK |
6219 | if (chip_id == XG27) |
6220 | XGI_SetXG27FPBits(pVBInfo); | |
6221 | else | |
6222 | XGI_SetXG21FPBits(pVBInfo); | |
6223 | ||
21df8fc8 PS |
6224 | resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo); |
6225 | if (ModeNo <= 0x13) { | |
6226 | xres = pVBInfo->StResInfo[resindex].HTotal; | |
6227 | yres = pVBInfo->StResInfo[resindex].VTotal; | |
1d7f656d KT |
6228 | /* si+St_ResInfo */ |
6229 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
21df8fc8 PS |
6230 | } else { |
6231 | xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */ | |
6232 | yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */ | |
1d7f656d KT |
6233 | /* si+St_ModeFlag */ |
6234 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
21df8fc8 PS |
6235 | } |
6236 | ||
6237 | if (!(modeflag & Charx8Dot)) | |
6238 | xres = xres * 8 / 9; | |
6239 | ||
6240 | LVDSHT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT; | |
d7636e0b | 6241 | |
21df8fc8 PS |
6242 | LVDSHBS = xres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE |
6243 | - xres) / 2; | |
6244 | if ((ModeNo <= 0x13) && (modeflag & HalfDCLK)) | |
6245 | LVDSHBS -= xres / 4; | |
6246 | ||
6247 | if (LVDSHBS > LVDSHT) | |
6248 | LVDSHBS -= LVDSHT; | |
6249 | ||
6250 | LVDSHRS = LVDSHBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP; | |
6251 | if (LVDSHRS > LVDSHT) | |
6252 | LVDSHRS -= LVDSHT; | |
6253 | ||
6254 | LVDSHRE = LVDSHRS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC; | |
6255 | if (LVDSHRE > LVDSHT) | |
6256 | LVDSHRE -= LVDSHT; | |
6257 | ||
6258 | LVDSHBE = LVDSHBS + LVDSHT | |
6259 | - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE; | |
6260 | ||
6261 | LVDSVT = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT; | |
d7636e0b | 6262 | |
21df8fc8 PS |
6263 | LVDSVBS = yres + (pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE |
6264 | - yres) / 2; | |
6265 | if ((ModeNo > 0x13) && (modeflag & DoubleScanMode)) | |
6266 | LVDSVBS += yres / 2; | |
6267 | ||
6268 | if (LVDSVBS > LVDSVT) | |
6269 | LVDSVBS -= LVDSVT; | |
6270 | ||
6271 | LVDSVRS = LVDSVBS + pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP; | |
6272 | if (LVDSVRS > LVDSVT) | |
6273 | LVDSVRS -= LVDSVT; | |
6274 | ||
1d7f656d KT |
6275 | LVDSVRE = LVDSVRS + pVBInfo->XG21_LVDSCapList[lvdstableindex]. |
6276 | LVDSVSYNC; | |
21df8fc8 PS |
6277 | if (LVDSVRE > LVDSVT) |
6278 | LVDSVRE -= LVDSVT; | |
6279 | ||
6280 | LVDSVBE = LVDSVBS + LVDSVT | |
6281 | - pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE; | |
6282 | ||
58839b01 | 6283 | temp = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x11); |
8104e329 | 6284 | xgifb_reg_set(pVBInfo->P3d4, 0x11, temp & 0x7f); /* Unlock CRTC */ |
21df8fc8 PS |
6285 | |
6286 | if (!(modeflag & Charx8Dot)) | |
b9bf6e4e | 6287 | xgifb_reg_or(pVBInfo->P3c4, 0x1, 0x1); |
21df8fc8 PS |
6288 | |
6289 | /* HT SR0B[1:0] CR00 */ | |
6290 | value = (LVDSHT >> 3) - 5; | |
ec9e5d3e | 6291 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x03, (value & 0x300) >> 8); |
8104e329 | 6292 | xgifb_reg_set(pVBInfo->P3d4, 0x0, (value & 0xFF)); |
21df8fc8 PS |
6293 | |
6294 | /* HBS SR0B[5:4] CR02 */ | |
6295 | value = (LVDSHBS >> 3) - 1; | |
ec9e5d3e | 6296 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0x30, (value & 0x300) >> 4); |
8104e329 | 6297 | xgifb_reg_set(pVBInfo->P3d4, 0x2, (value & 0xFF)); |
21df8fc8 PS |
6298 | |
6299 | /* HBE SR0C[1:0] CR05[7] CR03[4:0] */ | |
6300 | value = (LVDSHBE >> 3) - 1; | |
ec9e5d3e AK |
6301 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x03, (value & 0xC0) >> 6); |
6302 | xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x80, (value & 0x20) << 2); | |
6303 | xgifb_reg_and_or(pVBInfo->P3d4, 0x03, ~0x1F, value & 0x1F); | |
21df8fc8 PS |
6304 | |
6305 | /* HRS SR0B[7:6] CR04 */ | |
6306 | value = (LVDSHRS >> 3) + 2; | |
ec9e5d3e | 6307 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0B, ~0xC0, (value & 0x300) >> 2); |
8104e329 | 6308 | xgifb_reg_set(pVBInfo->P3d4, 0x4, (value & 0xFF)); |
21df8fc8 PS |
6309 | |
6310 | /* Panel HRS SR2F[1:0] SR2E[7:0] */ | |
6311 | value--; | |
ec9e5d3e | 6312 | xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0x03, (value & 0x300) >> 8); |
8104e329 | 6313 | xgifb_reg_set(pVBInfo->P3c4, 0x2E, (value & 0xFF)); |
21df8fc8 PS |
6314 | |
6315 | /* HRE SR0C[2] CR05[4:0] */ | |
6316 | value = (LVDSHRE >> 3) + 2; | |
ec9e5d3e AK |
6317 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0C, ~0x04, (value & 0x20) >> 3); |
6318 | xgifb_reg_and_or(pVBInfo->P3d4, 0x05, ~0x1F, value & 0x1F); | |
21df8fc8 PS |
6319 | |
6320 | /* Panel HRE SR2F[7:2] */ | |
6321 | value--; | |
ec9e5d3e | 6322 | xgifb_reg_and_or(pVBInfo->P3c4, 0x2F, ~0xFC, value << 2); |
21df8fc8 PS |
6323 | |
6324 | /* VT SR0A[0] CR07[5][0] CR06 */ | |
6325 | value = LVDSVT - 2; | |
ec9e5d3e AK |
6326 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x01, (value & 0x400) >> 10); |
6327 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x20, (value & 0x200) >> 4); | |
6328 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x01, (value & 0x100) >> 8); | |
8104e329 | 6329 | xgifb_reg_set(pVBInfo->P3d4, 0x06, (value & 0xFF)); |
21df8fc8 PS |
6330 | |
6331 | /* VBS SR0A[2] CR09[5] CR07[3] CR15 */ | |
6332 | value = LVDSVBS - 1; | |
ec9e5d3e AK |
6333 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x04, (value & 0x400) >> 8); |
6334 | xgifb_reg_and_or(pVBInfo->P3d4, 0x09, ~0x20, (value & 0x200) >> 4); | |
6335 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x08, (value & 0x100) >> 5); | |
8104e329 | 6336 | xgifb_reg_set(pVBInfo->P3d4, 0x15, (value & 0xFF)); |
21df8fc8 PS |
6337 | |
6338 | /* VBE SR0A[4] CR16 */ | |
6339 | value = LVDSVBE - 1; | |
ec9e5d3e | 6340 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x10, (value & 0x100) >> 4); |
8104e329 | 6341 | xgifb_reg_set(pVBInfo->P3d4, 0x16, (value & 0xFF)); |
21df8fc8 PS |
6342 | |
6343 | /* VRS SR0A[3] CR7[7][2] CR10 */ | |
6344 | value = LVDSVRS - 1; | |
ec9e5d3e AK |
6345 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x08, (value & 0x400) >> 7); |
6346 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x80, (value & 0x200) >> 2); | |
6347 | xgifb_reg_and_or(pVBInfo->P3d4, 0x07, ~0x04, (value & 0x100) >> 6); | |
8104e329 | 6348 | xgifb_reg_set(pVBInfo->P3d4, 0x10, (value & 0xFF)); |
21df8fc8 | 6349 | |
64db29f5 AK |
6350 | if (chip_id == XG27) { |
6351 | /* Panel VRS SR35[2:0] SR34[7:0] */ | |
6352 | xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, | |
6353 | (value & 0x700) >> 8); | |
6354 | xgifb_reg_set(pVBInfo->P3c4, 0x34, value & 0xFF); | |
6355 | } else { | |
6356 | /* Panel VRS SR3F[1:0] SR34[7:0] SR33[0] */ | |
6357 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0x03, | |
6358 | (value & 0x600) >> 9); | |
6359 | xgifb_reg_set(pVBInfo->P3c4, 0x34, (value >> 1) & 0xFF); | |
6360 | xgifb_reg_and_or(pVBInfo->P3d4, 0x33, ~0x01, value & 0x01); | |
6361 | } | |
21df8fc8 PS |
6362 | |
6363 | /* VRE SR0A[5] CR11[3:0] */ | |
6364 | value = LVDSVRE - 1; | |
ec9e5d3e AK |
6365 | xgifb_reg_and_or(pVBInfo->P3c4, 0x0A, ~0x20, (value & 0x10) << 1); |
6366 | xgifb_reg_and_or(pVBInfo->P3d4, 0x11, ~0x0F, value & 0x0F); | |
21df8fc8 PS |
6367 | |
6368 | /* Panel VRE SR3F[7:2] */ | |
64db29f5 AK |
6369 | if (chip_id == XG27) |
6370 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, | |
6371 | (value << 2) & 0xFC); | |
6372 | else | |
6373 | /* SR3F[7] has to be 0, h/w bug */ | |
6374 | xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, | |
6375 | (value << 2) & 0x7C); | |
21df8fc8 PS |
6376 | |
6377 | for (temp = 0, value = 0; temp < 3; temp++) { | |
6378 | ||
ec9e5d3e | 6379 | xgifb_reg_and_or(pVBInfo->P3c4, 0x31, ~0x30, value); |
8104e329 | 6380 | xgifb_reg_set(pVBInfo->P3c4, |
1d7f656d KT |
6381 | 0x2B, |
6382 | pVBInfo->XG21_LVDSCapList[lvdstableindex]. | |
6383 | VCLKData1); | |
8104e329 | 6384 | xgifb_reg_set(pVBInfo->P3c4, |
1d7f656d KT |
6385 | 0x2C, |
6386 | pVBInfo->XG21_LVDSCapList[lvdstableindex]. | |
6387 | VCLKData2); | |
21df8fc8 PS |
6388 | value += 0x10; |
6389 | } | |
d7636e0b | 6390 | |
21df8fc8 | 6391 | if (!(modeflag & Charx8Dot)) { |
d8ad0a6d | 6392 | inb(pVBInfo->P3da); /* reset 3da */ |
efdf4ee7 | 6393 | outb(0x13, pVBInfo->P3c0); /* set index */ |
1d7f656d KT |
6394 | /* set data, panning = 0, shift left 1 dot*/ |
6395 | outb(0x00, pVBInfo->P3c0); | |
d7636e0b | 6396 | |
d8ad0a6d | 6397 | inb(pVBInfo->P3da); /* Enable Attribute */ |
efdf4ee7 | 6398 | outb(0x20, pVBInfo->P3c0); |
d7636e0b | 6399 | |
d8ad0a6d | 6400 | inb(pVBInfo->P3da); /* reset 3da */ |
21df8fc8 | 6401 | } |
d7636e0b | 6402 | |
6403 | } | |
6404 | ||
6405 | /* --------------------------------------------------------------------- */ | |
6406 | /* Function : XGI_IsLCDON */ | |
6407 | /* Input : */ | |
dda08c59 BP |
6408 | /* Output : 0 : Skip PSC Control */ |
6409 | /* 1: Disable PSC */ | |
d7636e0b | 6410 | /* Description : */ |
6411 | /* --------------------------------------------------------------------- */ | |
063b9c4b | 6412 | static unsigned char XGI_IsLCDON(struct vb_device_info *pVBInfo) |
d7636e0b | 6413 | { |
21df8fc8 | 6414 | unsigned short tempax; |
d7636e0b | 6415 | |
21df8fc8 PS |
6416 | tempax = pVBInfo->VBInfo; |
6417 | if (tempax & SetCRT2ToDualEdge) | |
6418 | return 0; | |
6419 | else if (tempax & (DisableCRT2Display | SwitchToCRT2 | SetSimuScanMode)) | |
6420 | return 1; | |
d7636e0b | 6421 | |
21df8fc8 | 6422 | return 0; |
d7636e0b | 6423 | } |
6424 | ||
d7636e0b | 6425 | /* --------------------------------------------------------------------- */ |
6426 | /* Function : XGI_DisableChISLCD */ | |
6427 | /* Input : */ | |
dda08c59 | 6428 | /* Output : 0 -> Not LCD Mode */ |
d7636e0b | 6429 | /* Description : */ |
6430 | /* --------------------------------------------------------------------- */ | |
063b9c4b | 6431 | static unsigned char XGI_DisableChISLCD(struct vb_device_info *pVBInfo) |
d7636e0b | 6432 | { |
21df8fc8 | 6433 | unsigned short tempbx, tempah; |
d7636e0b | 6434 | |
21df8fc8 | 6435 | tempbx = pVBInfo->SetFlag & (DisableChA | DisableChB); |
58839b01 | 6436 | tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E)); |
d7636e0b | 6437 | |
21df8fc8 PS |
6438 | if (tempbx & (EnableChA | DisableChA)) { |
6439 | if (!(tempah & 0x08)) /* Chk LCDA Mode */ | |
6440 | return 0; | |
6441 | } | |
d7636e0b | 6442 | |
21df8fc8 PS |
6443 | if (!(tempbx & (EnableChB | DisableChB))) |
6444 | return 0; | |
d7636e0b | 6445 | |
21df8fc8 PS |
6446 | if (tempah & 0x01) /* Chk LCDB Mode */ |
6447 | return 1; | |
d7636e0b | 6448 | |
21df8fc8 | 6449 | return 0; |
d7636e0b | 6450 | } |
6451 | ||
d7636e0b | 6452 | /* --------------------------------------------------------------------- */ |
6453 | /* Function : XGI_EnableChISLCD */ | |
6454 | /* Input : */ | |
6455 | /* Output : 0 -> Not LCD mode */ | |
6456 | /* Description : */ | |
6457 | /* --------------------------------------------------------------------- */ | |
063b9c4b | 6458 | static unsigned char XGI_EnableChISLCD(struct vb_device_info *pVBInfo) |
d7636e0b | 6459 | { |
21df8fc8 | 6460 | unsigned short tempbx, tempah; |
d7636e0b | 6461 | |
21df8fc8 | 6462 | tempbx = pVBInfo->SetFlag & (EnableChA | EnableChB); |
58839b01 | 6463 | tempah = ~((unsigned short) xgifb_reg_get(pVBInfo->Part1Port, 0x2E)); |
d7636e0b | 6464 | |
21df8fc8 PS |
6465 | if (tempbx & (EnableChA | DisableChA)) { |
6466 | if (!(tempah & 0x08)) /* Chk LCDA Mode */ | |
6467 | return 0; | |
6468 | } | |
d7636e0b | 6469 | |
21df8fc8 | 6470 | if (!(tempbx & (EnableChB | DisableChB))) |
dda08c59 | 6471 | return 0; |
d7636e0b | 6472 | |
21df8fc8 PS |
6473 | if (tempah & 0x01) /* Chk LCDB Mode */ |
6474 | return 1; | |
d7636e0b | 6475 | |
cc1e2398 AK |
6476 | return 0; |
6477 | } | |
6478 | ||
6479 | void XGI_DisableBridge(struct xgi_hw_device_info *HwDeviceExtension, | |
6480 | struct vb_device_info *pVBInfo) | |
6481 | { | |
fd0ad470 | 6482 | unsigned short tempah = 0; |
cc1e2398 AK |
6483 | |
6484 | if (pVBInfo->SetFlag == Win9xDOSMode) | |
6485 | return; | |
6486 | ||
cc1e2398 AK |
6487 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
6488 | | VB_XGI302LV | VB_XGI301C)) { | |
6489 | tempah = 0x3F; | |
1d7f656d KT |
6490 | if (!(pVBInfo->VBInfo & |
6491 | (DisableCRT2Display | SetSimuScanMode))) { | |
cc1e2398 AK |
6492 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { |
6493 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { | |
6494 | tempah = 0x7F; /* Disable Channel A */ | |
6495 | if (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) | |
1d7f656d KT |
6496 | /* Disable Channel B */ |
6497 | tempah = 0xBF; | |
cc1e2398 AK |
6498 | |
6499 | if (pVBInfo->SetFlag & DisableChB) | |
1d7f656d KT |
6500 | /* force to disable Cahnnel */ |
6501 | tempah &= 0xBF; | |
cc1e2398 AK |
6502 | |
6503 | if (pVBInfo->SetFlag & DisableChA) | |
1d7f656d KT |
6504 | /* Force to disable Channel B */ |
6505 | tempah &= 0x7F; | |
cc1e2398 AK |
6506 | } |
6507 | } | |
6508 | } | |
6509 | ||
1d7f656d KT |
6510 | /* disable part4_1f */ |
6511 | xgifb_reg_and(pVBInfo->Part4Port, 0x1F, tempah); | |
cc1e2398 AK |
6512 | |
6513 | if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) { | |
6514 | if (((pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA))) | |
6515 | || (XGI_DisableChISLCD(pVBInfo)) | |
6516 | || (XGI_IsLCDON(pVBInfo))) | |
1d7f656d KT |
6517 | /* LVDS Driver power down */ |
6518 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x80); | |
cc1e2398 AK |
6519 | } |
6520 | ||
6521 | if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo | |
6522 | & (DisableCRT2Display | SetCRT2ToLCDA | |
6523 | | SetSimuScanMode))) { | |
6524 | if (pVBInfo->SetFlag & GatingCRT) | |
6525 | XGI_EnableGatingCRT(HwDeviceExtension, pVBInfo); | |
6526 | XGI_DisplayOff(HwDeviceExtension, pVBInfo); | |
6527 | } | |
6528 | ||
6529 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { | |
6530 | if ((pVBInfo->SetFlag & DisableChA) || (pVBInfo->VBInfo | |
6531 | & SetCRT2ToLCDA)) | |
1d7f656d KT |
6532 | /* Power down */ |
6533 | xgifb_reg_and(pVBInfo->Part1Port, 0x1e, 0xdf); | |
cc1e2398 AK |
6534 | } |
6535 | ||
1d7f656d KT |
6536 | /* disable TV as primary VGA swap */ |
6537 | xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xdf); | |
cc1e2398 AK |
6538 | |
6539 | if ((pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToDualEdge))) | |
dc50556b | 6540 | xgifb_reg_and(pVBInfo->Part2Port, 0x00, 0xdf); |
cc1e2398 | 6541 | |
1d7f656d KT |
6542 | if ((pVBInfo->SetFlag & DisableChB) || |
6543 | (pVBInfo->VBInfo & | |
6544 | (DisableCRT2Display | SetSimuScanMode)) || | |
6545 | ((!(pVBInfo->VBInfo & SetCRT2ToLCDA)) && | |
6546 | (pVBInfo->VBInfo & | |
6547 | (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV)))) | |
6548 | /* BScreenOff=1 */ | |
6549 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80); | |
6550 | ||
6551 | if ((pVBInfo->SetFlag & DisableChB) || | |
6552 | (pVBInfo->VBInfo & | |
6553 | (DisableCRT2Display | SetSimuScanMode)) || | |
6554 | (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) || | |
6555 | (pVBInfo->VBInfo & | |
6556 | (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV))) { | |
6557 | /* save Part1 index 0 */ | |
6558 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00); | |
6559 | /* BTDAC = 1, avoid VB reset */ | |
6560 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x10); | |
6561 | /* disable CRT2 */ | |
6562 | xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF); | |
6563 | /* restore Part1 index 0 */ | |
6564 | xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah); | |
cc1e2398 AK |
6565 | } |
6566 | } else { /* {301} */ | |
6567 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToTV)) { | |
1d7f656d KT |
6568 | /* BScreenOff=1 */ |
6569 | xgifb_reg_or(pVBInfo->Part1Port, 0x00, 0x80); | |
6570 | /* Disable CRT2 */ | |
6571 | xgifb_reg_and(pVBInfo->Part1Port, 0x1E, 0xDF); | |
6572 | /* Disable TV asPrimary VGA swap */ | |
6573 | xgifb_reg_and(pVBInfo->P3c4, 0x32, 0xDF); | |
cc1e2398 AK |
6574 | } |
6575 | ||
6576 | if (pVBInfo->VBInfo & (DisableCRT2Display | SetCRT2ToLCDA | |
6577 | | SetSimuScanMode)) | |
6578 | XGI_DisplayOff(HwDeviceExtension, pVBInfo); | |
6579 | } | |
cc1e2398 AK |
6580 | } |
6581 | ||
6582 | /* --------------------------------------------------------------------- */ | |
6583 | /* Function : XGI_GetTVPtrIndex */ | |
6584 | /* Input : */ | |
6585 | /* Output : */ | |
6586 | /* Description : bx 0 : ExtNTSC */ | |
6587 | /* 1 : StNTSC */ | |
6588 | /* 2 : ExtPAL */ | |
6589 | /* 3 : StPAL */ | |
6590 | /* 4 : ExtHiTV */ | |
6591 | /* 5 : StHiTV */ | |
6592 | /* 6 : Ext525i */ | |
6593 | /* 7 : St525i */ | |
6594 | /* 8 : Ext525p */ | |
6595 | /* 9 : St525p */ | |
6596 | /* A : Ext750p */ | |
6597 | /* B : St750p */ | |
6598 | /* --------------------------------------------------------------------- */ | |
6599 | static unsigned short XGI_GetTVPtrIndex(struct vb_device_info *pVBInfo) | |
6600 | { | |
6601 | unsigned short tempbx = 0; | |
6602 | ||
6603 | if (pVBInfo->TVInfo & SetPALTV) | |
6604 | tempbx = 2; | |
6605 | if (pVBInfo->TVInfo & SetYPbPrMode1080i) | |
6606 | tempbx = 4; | |
6607 | if (pVBInfo->TVInfo & SetYPbPrMode525i) | |
6608 | tempbx = 6; | |
6609 | if (pVBInfo->TVInfo & SetYPbPrMode525p) | |
6610 | tempbx = 8; | |
6611 | if (pVBInfo->TVInfo & SetYPbPrMode750p) | |
6612 | tempbx = 10; | |
6613 | if (pVBInfo->TVInfo & TVSimuMode) | |
6614 | tempbx++; | |
6615 | ||
6616 | return tempbx; | |
6617 | } | |
6618 | ||
6619 | /* --------------------------------------------------------------------- */ | |
6620 | /* Function : XGI_GetTVPtrIndex2 */ | |
6621 | /* Input : */ | |
6622 | /* Output : bx 0 : NTSC */ | |
6623 | /* 1 : PAL */ | |
6624 | /* 2 : PALM */ | |
6625 | /* 3 : PALN */ | |
6626 | /* 4 : NTSC1024x768 */ | |
6627 | /* 5 : PAL-M 1024x768 */ | |
6628 | /* 6-7: reserved */ | |
6629 | /* cl 0 : YFilter1 */ | |
6630 | /* 1 : YFilter2 */ | |
6631 | /* ch 0 : 301A */ | |
6632 | /* 1 : 301B/302B/301LV/302LV */ | |
6633 | /* Description : */ | |
6634 | /* --------------------------------------------------------------------- */ | |
6635 | static void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char *tempcl, | |
6636 | unsigned char *tempch, struct vb_device_info *pVBInfo) | |
6637 | { | |
6638 | *tempbx = 0; | |
6639 | *tempcl = 0; | |
6640 | *tempch = 0; | |
6641 | ||
6642 | if (pVBInfo->TVInfo & SetPALTV) | |
6643 | *tempbx = 1; | |
6644 | ||
6645 | if (pVBInfo->TVInfo & SetPALMTV) | |
6646 | *tempbx = 2; | |
6647 | ||
6648 | if (pVBInfo->TVInfo & SetPALNTV) | |
6649 | *tempbx = 3; | |
6650 | ||
6651 | if (pVBInfo->TVInfo & NTSC1024x768) { | |
6652 | *tempbx = 4; | |
6653 | if (pVBInfo->TVInfo & SetPALMTV) | |
6654 | *tempbx = 5; | |
6655 | } | |
6656 | ||
6657 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | |
6658 | | VB_XGI302LV | VB_XGI301C)) { | |
6659 | if ((!(pVBInfo->VBInfo & SetInSlaveMode)) || (pVBInfo->TVInfo | |
6660 | & TVSimuMode)) { | |
6661 | *tempbx += 8; | |
6662 | *tempcl += 1; | |
6663 | } | |
6664 | } | |
6665 | ||
6666 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | |
6667 | | VB_XGI302LV | VB_XGI301C)) | |
6668 | (*tempch)++; | |
d7636e0b | 6669 | } |
6670 | ||
cc1e2398 | 6671 | static void XGI_SetDelayComp(struct vb_device_info *pVBInfo) |
d7636e0b | 6672 | { |
cc1e2398 | 6673 | unsigned short index; |
d7636e0b | 6674 | |
cc1e2398 | 6675 | unsigned char tempah, tempbl, tempbh; |
d7636e0b | 6676 | |
cc1e2398 AK |
6677 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
6678 | | VB_XGI302LV | VB_XGI301C)) { | |
6679 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA | |
6680 | | SetCRT2ToTV | SetCRT2ToRAMDAC)) { | |
6681 | tempbl = 0; | |
6682 | tempbh = 0; | |
d7636e0b | 6683 | |
cc1e2398 AK |
6684 | index = XGI_GetTVPtrIndex(pVBInfo); /* Get TV Delay */ |
6685 | tempbl = pVBInfo->XGI_TVDelayList[index]; | |
d7636e0b | 6686 | |
cc1e2398 AK |
6687 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B |
6688 | | VB_XGI301LV | VB_XGI302LV | |
6689 | | VB_XGI301C)) | |
6690 | tempbl = pVBInfo->XGI_TVDelayList2[index]; | |
d7636e0b | 6691 | |
cc1e2398 AK |
6692 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) |
6693 | tempbl = tempbl >> 4; | |
6694 | /* | |
6695 | if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) | |
6696 | tempbl = CRT2Delay1; // Get CRT2 Delay | |
1d7f656d KT |
6697 | if (pVBInfo->VBType & |
6698 | (VB_XGI301B | | |
6699 | VB_XGI302B | | |
6700 | VB_XGI301LV | | |
6701 | VB_XGI302LV | | |
6702 | VB_XGI301C)) | |
cc1e2398 AK |
6703 | tempbl = CRT2Delay2; |
6704 | */ | |
6705 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { | |
1d7f656d KT |
6706 | /* Get LCD Delay */ |
6707 | index = XGI_GetLCDCapPtr(pVBInfo); | |
6708 | tempbh = pVBInfo->LCDCapList[index]. | |
6709 | LCD_DelayCompensation; | |
d7636e0b | 6710 | |
cc1e2398 AK |
6711 | if (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) |
6712 | tempbl = tempbh; | |
6713 | } | |
d7636e0b | 6714 | |
cc1e2398 AK |
6715 | tempbl &= 0x0F; |
6716 | tempbh &= 0xF0; | |
58839b01 | 6717 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x2D); |
d7636e0b | 6718 | |
cc1e2398 AK |
6719 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD |
6720 | | SetCRT2ToTV)) { /* Channel B */ | |
6721 | tempah &= 0xF0; | |
6722 | tempah |= tempbl; | |
6723 | } | |
d7636e0b | 6724 | |
cc1e2398 AK |
6725 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { /* Channel A */ |
6726 | tempah &= 0x0F; | |
6727 | tempah |= tempbh; | |
6728 | } | |
8104e329 | 6729 | xgifb_reg_set(pVBInfo->Part1Port, 0x2D, tempah); |
cc1e2398 AK |
6730 | } |
6731 | } else if (pVBInfo->IF_DEF_LVDS == 1) { | |
6732 | tempbl = 0; | |
6733 | tempbh = 0; | |
6734 | if (pVBInfo->VBInfo & SetCRT2ToLCD) { | |
1d7f656d KT |
6735 | /* / Get LCD Delay */ |
6736 | tempah = pVBInfo->LCDCapList[ | |
6737 | XGI_GetLCDCapPtr(pVBInfo)]. | |
6738 | LCD_DelayCompensation; | |
cc1e2398 AK |
6739 | tempah &= 0x0f; |
6740 | tempah = tempah << 4; | |
ec9e5d3e | 6741 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2D, 0x0f, |
cc1e2398 | 6742 | tempah); |
21df8fc8 | 6743 | } |
cc1e2398 AK |
6744 | } |
6745 | } | |
d7636e0b | 6746 | |
1d7f656d KT |
6747 | static void XGI_SetLCDCap_A(unsigned short tempcx, |
6748 | struct vb_device_info *pVBInfo) | |
cc1e2398 AK |
6749 | { |
6750 | unsigned short temp; | |
d7636e0b | 6751 | |
58839b01 | 6752 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x37); |
cc1e2398 AK |
6753 | |
6754 | if (temp & LCDRGB18Bit) { | |
ec9e5d3e | 6755 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F, |
1d7f656d KT |
6756 | /* Enable Dither */ |
6757 | (unsigned short) (0x20 | (tempcx & 0x00C0))); | |
ec9e5d3e | 6758 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80); |
cc1e2398 | 6759 | } else { |
ec9e5d3e | 6760 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x19, 0x0F, |
cc1e2398 | 6761 | (unsigned short) (0x30 | (tempcx & 0x00C0))); |
ec9e5d3e | 6762 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00); |
21df8fc8 | 6763 | } |
d7636e0b | 6764 | |
cc1e2398 AK |
6765 | /* |
6766 | if (tempcx & EnableLCD24bpp) { // 24bits | |
1d7f656d KT |
6767 | xgifb_reg_and_or(pVBInfo->Part1Port, |
6768 | 0x19, | |
6769 | 0x0F, | |
6770 | (unsigned short)(0x30 | (tempcx&0x00C0))); | |
ec9e5d3e | 6771 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x00); |
cc1e2398 | 6772 | } else { |
1d7f656d KT |
6773 | xgifb_reg_and_or(pVBInfo->Part1Port, |
6774 | 0x19, | |
6775 | 0x0F, | |
6776 | // Enable Dither | |
6777 | (unsigned short)(0x20 | (tempcx&0x00C0))); | |
ec9e5d3e | 6778 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x1A, 0x7F, 0x80); |
21df8fc8 | 6779 | } |
cc1e2398 AK |
6780 | */ |
6781 | } | |
d7636e0b | 6782 | |
cc1e2398 AK |
6783 | /* --------------------------------------------------------------------- */ |
6784 | /* Function : XGI_SetLCDCap_B */ | |
6785 | /* Input : cx -> LCD Capability */ | |
6786 | /* Output : */ | |
6787 | /* Description : */ | |
6788 | /* --------------------------------------------------------------------- */ | |
1d7f656d KT |
6789 | static void XGI_SetLCDCap_B(unsigned short tempcx, |
6790 | struct vb_device_info *pVBInfo) | |
cc1e2398 AK |
6791 | { |
6792 | if (tempcx & EnableLCD24bpp) /* 24bits */ | |
ec9e5d3e | 6793 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0, |
cc1e2398 AK |
6794 | (unsigned short) (((tempcx & 0x00ff) >> 6) |
6795 | | 0x0c)); | |
6796 | else | |
ec9e5d3e | 6797 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x1A, 0xE0, |
cc1e2398 AK |
6798 | (unsigned short) (((tempcx & 0x00ff) >> 6) |
6799 | | 0x18)); /* Enable Dither */ | |
d7636e0b | 6800 | } |
6801 | ||
cc1e2398 | 6802 | static void SetSpectrum(struct vb_device_info *pVBInfo) |
d7636e0b | 6803 | { |
cc1e2398 | 6804 | unsigned short index; |
d7636e0b | 6805 | |
cc1e2398 | 6806 | index = XGI_GetLCDCapPtr(pVBInfo); |
d7636e0b | 6807 | |
1d7f656d KT |
6808 | /* disable down spectrum D[4] */ |
6809 | xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x8F); | |
cc1e2398 | 6810 | XGI_LongWait(pVBInfo); |
b9bf6e4e | 6811 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x20); /* reset spectrum */ |
cc1e2398 AK |
6812 | XGI_LongWait(pVBInfo); |
6813 | ||
8104e329 | 6814 | xgifb_reg_set(pVBInfo->Part4Port, 0x31, |
cc1e2398 | 6815 | pVBInfo->LCDCapList[index].Spectrum_31); |
8104e329 | 6816 | xgifb_reg_set(pVBInfo->Part4Port, 0x32, |
cc1e2398 | 6817 | pVBInfo->LCDCapList[index].Spectrum_32); |
8104e329 | 6818 | xgifb_reg_set(pVBInfo->Part4Port, 0x33, |
cc1e2398 | 6819 | pVBInfo->LCDCapList[index].Spectrum_33); |
8104e329 | 6820 | xgifb_reg_set(pVBInfo->Part4Port, 0x34, |
cc1e2398 AK |
6821 | pVBInfo->LCDCapList[index].Spectrum_34); |
6822 | XGI_LongWait(pVBInfo); | |
b9bf6e4e | 6823 | xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x40); /* enable spectrum */ |
d7636e0b | 6824 | } |
6825 | ||
cc1e2398 | 6826 | static void XGI_SetLCDCap(struct vb_device_info *pVBInfo) |
21df8fc8 | 6827 | { |
cc1e2398 | 6828 | unsigned short tempcx; |
21df8fc8 | 6829 | |
cc1e2398 | 6830 | tempcx = pVBInfo->LCDCapList[XGI_GetLCDCapPtr(pVBInfo)].LCD_Capability; |
21df8fc8 | 6831 | |
1d7f656d KT |
6832 | if (pVBInfo->VBType & |
6833 | (VB_XGI301B | | |
6834 | VB_XGI302B | | |
6835 | VB_XGI301LV | | |
6836 | VB_XGI302LV | | |
6837 | VB_XGI301C)) { /* 301LV/302LV only */ | |
6838 | if (pVBInfo->VBType & | |
6839 | (VB_XGI301LV | VB_XGI302LV | VB_XGI301C)) { | |
cc1e2398 | 6840 | /* Set 301LV Capability */ |
8104e329 | 6841 | xgifb_reg_set(pVBInfo->Part4Port, 0x24, |
cc1e2398 | 6842 | (unsigned char) (tempcx & 0x1F)); |
21df8fc8 | 6843 | } |
cc1e2398 | 6844 | /* VB Driving */ |
ec9e5d3e | 6845 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D, |
cc1e2398 AK |
6846 | ~((EnableVBCLKDRVLOW | EnablePLLSPLOW) >> 8), |
6847 | (unsigned short) ((tempcx & (EnableVBCLKDRVLOW | |
6848 | | EnablePLLSPLOW)) >> 8)); | |
6849 | } | |
21df8fc8 | 6850 | |
cc1e2398 AK |
6851 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
6852 | | VB_XGI302LV | VB_XGI301C)) { | |
6853 | if (pVBInfo->VBInfo & SetCRT2ToLCD) | |
6854 | XGI_SetLCDCap_B(tempcx, pVBInfo); | |
6855 | else if (pVBInfo->VBInfo & SetCRT2ToLCDA) | |
6856 | XGI_SetLCDCap_A(tempcx, pVBInfo); | |
21df8fc8 | 6857 | |
cc1e2398 AK |
6858 | if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) { |
6859 | if (tempcx & EnableSpectrum) | |
6860 | SetSpectrum(pVBInfo); | |
6861 | } | |
6862 | } else { | |
6863 | /* LVDS,CH7017 */ | |
6864 | XGI_SetLCDCap_A(tempcx, pVBInfo); | |
6865 | } | |
6866 | } | |
21df8fc8 | 6867 | |
cc1e2398 AK |
6868 | /* --------------------------------------------------------------------- */ |
6869 | /* Function : XGI_SetAntiFlicker */ | |
6870 | /* Input : */ | |
6871 | /* Output : */ | |
6872 | /* Description : Set TV Customized Param. */ | |
6873 | /* --------------------------------------------------------------------- */ | |
1d7f656d KT |
6874 | static void XGI_SetAntiFlicker(unsigned short ModeNo, |
6875 | unsigned short ModeIdIndex, | |
6876 | struct vb_device_info *pVBInfo) | |
cc1e2398 AK |
6877 | { |
6878 | unsigned short tempbx, index; | |
21df8fc8 | 6879 | |
cc1e2398 | 6880 | unsigned char tempah; |
21df8fc8 | 6881 | |
cc1e2398 AK |
6882 | if (pVBInfo->TVInfo & (SetYPbPrMode525p | SetYPbPrMode750p)) |
6883 | return; | |
21df8fc8 | 6884 | |
cc1e2398 AK |
6885 | tempbx = XGI_GetTVPtrIndex(pVBInfo); |
6886 | tempbx &= 0xFE; | |
21df8fc8 | 6887 | |
cc1e2398 AK |
6888 | if (ModeNo <= 0x13) |
6889 | index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVFlickerIndex; | |
6890 | else | |
6891 | index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVFlickerIndex; | |
21df8fc8 | 6892 | |
cc1e2398 AK |
6893 | tempbx += index; |
6894 | tempah = TVAntiFlickList[tempbx]; | |
6895 | tempah = tempah << 4; | |
21df8fc8 | 6896 | |
ec9e5d3e | 6897 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0x8F, tempah); |
cc1e2398 | 6898 | } |
21df8fc8 | 6899 | |
1d7f656d KT |
6900 | static void XGI_SetEdgeEnhance(unsigned short ModeNo, |
6901 | unsigned short ModeIdIndex, | |
6902 | struct vb_device_info *pVBInfo) | |
cc1e2398 AK |
6903 | { |
6904 | unsigned short tempbx, index; | |
21df8fc8 | 6905 | |
cc1e2398 | 6906 | unsigned char tempah; |
21df8fc8 | 6907 | |
cc1e2398 AK |
6908 | tempbx = XGI_GetTVPtrIndex(pVBInfo); |
6909 | tempbx &= 0xFE; | |
21df8fc8 | 6910 | |
cc1e2398 AK |
6911 | if (ModeNo <= 0x13) |
6912 | index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVEdgeIndex; | |
6913 | else | |
6914 | index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVEdgeIndex; | |
21df8fc8 | 6915 | |
cc1e2398 AK |
6916 | tempbx += index; |
6917 | tempah = TVEdgeList[tempbx]; | |
6918 | tempah = tempah << 5; | |
21df8fc8 | 6919 | |
ec9e5d3e | 6920 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, tempah); |
d7636e0b | 6921 | } |
6922 | ||
cc1e2398 | 6923 | static void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo) |
21df8fc8 | 6924 | { |
cc1e2398 | 6925 | unsigned short tempbx; |
21df8fc8 | 6926 | |
cc1e2398 | 6927 | unsigned char tempcl, tempch; |
21df8fc8 | 6928 | |
cc1e2398 | 6929 | unsigned long tempData; |
d7636e0b | 6930 | |
cc1e2398 AK |
6931 | XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */ |
6932 | tempData = TVPhaseList[tempbx]; | |
21df8fc8 | 6933 | |
8104e329 | 6934 | xgifb_reg_set(pVBInfo->Part2Port, 0x31, (unsigned short) (tempData |
cc1e2398 | 6935 | & 0x000000FF)); |
8104e329 | 6936 | xgifb_reg_set(pVBInfo->Part2Port, 0x32, (unsigned short) ((tempData |
cc1e2398 | 6937 | & 0x0000FF00) >> 8)); |
8104e329 | 6938 | xgifb_reg_set(pVBInfo->Part2Port, 0x33, (unsigned short) ((tempData |
cc1e2398 | 6939 | & 0x00FF0000) >> 16)); |
8104e329 | 6940 | xgifb_reg_set(pVBInfo->Part2Port, 0x34, (unsigned short) ((tempData |
cc1e2398 AK |
6941 | & 0xFF000000) >> 24)); |
6942 | } | |
21df8fc8 | 6943 | |
cc1e2398 AK |
6944 | static void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex, |
6945 | struct vb_device_info *pVBInfo) | |
6946 | { | |
6947 | unsigned short tempbx, index; | |
21df8fc8 | 6948 | |
cc1e2398 | 6949 | unsigned char tempcl, tempch, tempal, *filterPtr; |
21df8fc8 | 6950 | |
cc1e2398 | 6951 | XGI_GetTVPtrIndex2(&tempbx, &tempcl, &tempch, pVBInfo); /* bx, cl, ch */ |
21df8fc8 | 6952 | |
cc1e2398 AK |
6953 | switch (tempbx) { |
6954 | case 0x00: | |
6955 | case 0x04: | |
6956 | filterPtr = NTSCYFilter1; | |
6957 | break; | |
21df8fc8 | 6958 | |
cc1e2398 AK |
6959 | case 0x01: |
6960 | filterPtr = PALYFilter1; | |
6961 | break; | |
21df8fc8 | 6962 | |
cc1e2398 AK |
6963 | case 0x02: |
6964 | case 0x05: | |
6965 | case 0x0D: | |
cc1e2398 | 6966 | case 0x03: |
2555e945 | 6967 | filterPtr = xgifb_palmn_yfilter1; |
cc1e2398 | 6968 | break; |
21df8fc8 | 6969 | |
cc1e2398 AK |
6970 | case 0x08: |
6971 | case 0x0C: | |
cc1e2398 | 6972 | case 0x0A: |
cc1e2398 | 6973 | case 0x0B: |
cc1e2398 | 6974 | case 0x09: |
80f86f8f | 6975 | filterPtr = xgifb_yfilter2; |
cc1e2398 | 6976 | break; |
21df8fc8 | 6977 | |
cc1e2398 AK |
6978 | default: |
6979 | return; | |
21df8fc8 | 6980 | } |
d7636e0b | 6981 | |
cc1e2398 | 6982 | if (ModeNo <= 0x13) |
1d7f656d KT |
6983 | tempal = pVBInfo->SModeIDTable[ModeIdIndex]. |
6984 | VB_StTVYFilterIndex; | |
cc1e2398 | 6985 | else |
1d7f656d KT |
6986 | tempal = pVBInfo->EModeIDTable[ModeIdIndex]. |
6987 | VB_ExtTVYFilterIndex; | |
d7636e0b | 6988 | |
cc1e2398 AK |
6989 | if (tempcl == 0) |
6990 | index = tempal * 4; | |
6991 | else | |
6992 | index = tempal * 7; | |
d7636e0b | 6993 | |
cc1e2398 | 6994 | if ((tempcl == 0) && (tempch == 1)) { |
8104e329 AK |
6995 | xgifb_reg_set(pVBInfo->Part2Port, 0x35, 0); |
6996 | xgifb_reg_set(pVBInfo->Part2Port, 0x36, 0); | |
6997 | xgifb_reg_set(pVBInfo->Part2Port, 0x37, 0); | |
6998 | xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]); | |
cc1e2398 | 6999 | } else { |
8104e329 AK |
7000 | xgifb_reg_set(pVBInfo->Part2Port, 0x35, filterPtr[index++]); |
7001 | xgifb_reg_set(pVBInfo->Part2Port, 0x36, filterPtr[index++]); | |
7002 | xgifb_reg_set(pVBInfo->Part2Port, 0x37, filterPtr[index++]); | |
7003 | xgifb_reg_set(pVBInfo->Part2Port, 0x38, filterPtr[index++]); | |
cc1e2398 | 7004 | } |
d7636e0b | 7005 | |
cc1e2398 AK |
7006 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
7007 | | VB_XGI302LV | VB_XGI301C)) { | |
8104e329 AK |
7008 | xgifb_reg_set(pVBInfo->Part2Port, 0x48, filterPtr[index++]); |
7009 | xgifb_reg_set(pVBInfo->Part2Port, 0x49, filterPtr[index++]); | |
7010 | xgifb_reg_set(pVBInfo->Part2Port, 0x4A, filterPtr[index++]); | |
cc1e2398 | 7011 | } |
d7636e0b | 7012 | } |
7013 | ||
d7636e0b | 7014 | /* --------------------------------------------------------------------- */ |
7015 | /* Function : XGI_OEM310Setting */ | |
7016 | /* Input : */ | |
7017 | /* Output : */ | |
7018 | /* Description : Customized Param. for 301 */ | |
7019 | /* --------------------------------------------------------------------- */ | |
1d7f656d KT |
7020 | static void XGI_OEM310Setting(unsigned short ModeNo, |
7021 | unsigned short ModeIdIndex, | |
7022 | struct vb_device_info *pVBInfo) | |
d7636e0b | 7023 | { |
21df8fc8 PS |
7024 | if (pVBInfo->SetFlag & Win9xDOSMode) |
7025 | return; | |
d7636e0b | 7026 | |
21df8fc8 PS |
7027 | /* GetPart1IO(); */ |
7028 | XGI_SetDelayComp(pVBInfo); | |
d7636e0b | 7029 | |
21df8fc8 PS |
7030 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) |
7031 | XGI_SetLCDCap(pVBInfo); | |
d7636e0b | 7032 | |
21df8fc8 PS |
7033 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
7034 | /* GetPart2IO() */ | |
7035 | XGI_SetPhaseIncr(pVBInfo); | |
7036 | XGI_SetYFilter(ModeNo, ModeIdIndex, pVBInfo); | |
7037 | XGI_SetAntiFlicker(ModeNo, ModeIdIndex, pVBInfo); | |
d7636e0b | 7038 | |
21df8fc8 PS |
7039 | if (pVBInfo->VBType & VB_XGI301) |
7040 | XGI_SetEdgeEnhance(ModeNo, ModeIdIndex, pVBInfo); | |
7041 | } | |
d7636e0b | 7042 | } |
7043 | ||
cc1e2398 AK |
7044 | /* --------------------------------------------------------------------- */ |
7045 | /* Function : XGI_SetCRT2ModeRegs */ | |
7046 | /* Input : */ | |
7047 | /* Output : */ | |
7048 | /* Description : Origin code for crt2group */ | |
7049 | /* --------------------------------------------------------------------- */ | |
7050 | void XGI_SetCRT2ModeRegs(unsigned short ModeNo, | |
7051 | struct xgi_hw_device_info *HwDeviceExtension, | |
7052 | struct vb_device_info *pVBInfo) | |
d7636e0b | 7053 | { |
cc1e2398 AK |
7054 | unsigned short tempbl; |
7055 | short tempcl; | |
21df8fc8 | 7056 | |
cc1e2398 | 7057 | unsigned char tempah; |
21df8fc8 | 7058 | |
1d7f656d KT |
7059 | /* // fix write part1 index 0 BTDRAM bit Bug |
7060 | * xgifb_reg_set(pVBInfo->Part1Port, 0x03, 0x00); */ | |
cc1e2398 AK |
7061 | tempah = 0; |
7062 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { | |
58839b01 | 7063 | tempah = xgifb_reg_get(pVBInfo->Part1Port, 0x00); |
cc1e2398 AK |
7064 | tempah &= ~0x10; /* BTRAMDAC */ |
7065 | tempah |= 0x40; /* BTRAM */ | |
21df8fc8 | 7066 | |
cc1e2398 AK |
7067 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV |
7068 | | SetCRT2ToLCD)) { | |
7069 | tempah = 0x40; /* BTDRAM */ | |
7070 | if (ModeNo > 0x13) { | |
7071 | tempcl = pVBInfo->ModeType; | |
7072 | tempcl -= ModeVGA; | |
7073 | if (tempcl >= 0) { | |
1d7f656d KT |
7074 | /* BT Color */ |
7075 | tempah = (0x008 >> tempcl); | |
cc1e2398 AK |
7076 | if (tempah == 0) |
7077 | tempah = 1; | |
7078 | tempah |= 0x040; | |
7079 | } | |
7080 | } | |
7081 | if (pVBInfo->VBInfo & SetInSlaveMode) | |
7082 | tempah ^= 0x50; /* BTDAC */ | |
7083 | } | |
7084 | } | |
21df8fc8 | 7085 | |
cc1e2398 AK |
7086 | /* 0210 shampoo |
7087 | if (pVBInfo->VBInfo & DisableCRT2Display) { | |
7088 | tempah = 0; | |
7089 | } | |
21df8fc8 | 7090 | |
8104e329 | 7091 | xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah); |
cc1e2398 AK |
7092 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD)) { |
7093 | tempcl = pVBInfo->ModeType; | |
7094 | if (ModeNo > 0x13) { | |
7095 | tempcl -= ModeVGA; | |
7096 | if ((tempcl > 0) || (tempcl == 0)) { | |
7097 | tempah=(0x008>>tempcl) ; | |
7098 | if (tempah == 0) | |
7099 | tempah = 1; | |
7100 | tempah |= 0x040; | |
21df8fc8 | 7101 | } |
cc1e2398 AK |
7102 | } else { |
7103 | tempah = 0x040; | |
7104 | } | |
21df8fc8 | 7105 | |
cc1e2398 AK |
7106 | if (pVBInfo->VBInfo & SetInSlaveMode) { |
7107 | tempah = (tempah ^ 0x050); | |
7108 | } | |
7109 | } | |
7110 | */ | |
21df8fc8 | 7111 | |
8104e329 | 7112 | xgifb_reg_set(pVBInfo->Part1Port, 0x00, tempah); |
cc1e2398 AK |
7113 | tempah = 0x08; |
7114 | tempbl = 0xf0; | |
7115 | ||
7116 | if (pVBInfo->VBInfo & DisableCRT2Display) { | |
ec9e5d3e | 7117 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl, tempah); |
cc1e2398 AK |
7118 | } else { |
7119 | tempah = 0x00; | |
7120 | tempbl = 0xff; | |
7121 | ||
7122 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | |
7123 | | SetCRT2ToLCD | SetCRT2ToLCDA)) { | |
1d7f656d KT |
7124 | if ((pVBInfo->VBInfo & SetCRT2ToLCDA) && |
7125 | (!(pVBInfo->VBInfo & SetSimuScanMode))) { | |
cc1e2398 AK |
7126 | tempbl &= 0xf7; |
7127 | tempah |= 0x01; | |
ec9e5d3e | 7128 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, |
cc1e2398 AK |
7129 | tempbl, tempah); |
7130 | } else { | |
7131 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { | |
7132 | tempbl &= 0xf7; | |
7133 | tempah |= 0x01; | |
7134 | } | |
7135 | ||
1d7f656d KT |
7136 | if (pVBInfo->VBInfo & |
7137 | (SetCRT2ToRAMDAC | | |
7138 | SetCRT2ToTV | | |
7139 | SetCRT2ToLCD)) { | |
cc1e2398 AK |
7140 | tempbl &= 0xf8; |
7141 | tempah = 0x01; | |
7142 | ||
7143 | if (!(pVBInfo->VBInfo & SetInSlaveMode)) | |
7144 | tempah |= 0x02; | |
7145 | ||
1d7f656d KT |
7146 | if (!(pVBInfo->VBInfo & |
7147 | SetCRT2ToRAMDAC)) { | |
cc1e2398 | 7148 | tempah = tempah ^ 0x05; |
1d7f656d KT |
7149 | if (!(pVBInfo->VBInfo & |
7150 | SetCRT2ToLCD)) | |
cc1e2398 AK |
7151 | tempah = tempah ^ 0x01; |
7152 | } | |
21df8fc8 | 7153 | |
1d7f656d KT |
7154 | if (!(pVBInfo->VBInfo & |
7155 | SetCRT2ToDualEdge)) | |
cc1e2398 | 7156 | tempah |= 0x08; |
ec9e5d3e | 7157 | xgifb_reg_and_or(pVBInfo->Part1Port, |
cc1e2398 AK |
7158 | 0x2e, tempbl, tempah); |
7159 | } else { | |
ec9e5d3e | 7160 | xgifb_reg_and_or(pVBInfo->Part1Port, |
cc1e2398 AK |
7161 | 0x2e, tempbl, tempah); |
7162 | } | |
21df8fc8 | 7163 | } |
cc1e2398 | 7164 | } else { |
ec9e5d3e | 7165 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl, |
21df8fc8 PS |
7166 | tempah); |
7167 | } | |
7168 | } | |
d7636e0b | 7169 | |
cc1e2398 AK |
7170 | if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD |
7171 | | SetCRT2ToLCDA)) { | |
7172 | tempah &= (~0x08); | |
7173 | if ((pVBInfo->ModeType == ModeVGA) && (!(pVBInfo->VBInfo | |
7174 | & SetInSlaveMode))) { | |
7175 | tempah |= 0x010; | |
7176 | } | |
7177 | tempah |= 0x080; | |
21df8fc8 | 7178 | |
cc1e2398 | 7179 | if (pVBInfo->VBInfo & SetCRT2ToTV) { |
1d7f656d KT |
7180 | /* if (!(pVBInfo->TVInfo & |
7181 | (SetYPbPrMode525p | SetYPbPrMode750p))) { */ | |
cc1e2398 AK |
7182 | tempah |= 0x020; |
7183 | if (ModeNo > 0x13) { | |
7184 | if (pVBInfo->VBInfo & DriverMode) | |
7185 | tempah = tempah ^ 0x20; | |
7186 | } | |
7187 | /* } */ | |
7188 | } | |
21df8fc8 | 7189 | |
ec9e5d3e | 7190 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D, ~0x0BF, tempah); |
cc1e2398 AK |
7191 | tempah = 0; |
7192 | ||
7193 | if (pVBInfo->LCDInfo & SetLCDDualLink) | |
7194 | tempah |= 0x40; | |
7195 | ||
7196 | if (pVBInfo->VBInfo & SetCRT2ToTV) { | |
1d7f656d KT |
7197 | /* if ((!(pVBInfo->VBInfo & SetCRT2ToHiVisionTV)) && |
7198 | (!(pVBInfo->TVInfo & | |
7199 | (SetYPbPrMode525p | SetYPbPrMode750p)))) { */ | |
cc1e2398 AK |
7200 | if (pVBInfo->TVInfo & RPLLDIV2XO) |
7201 | tempah |= 0x40; | |
7202 | /* } */ | |
21df8fc8 | 7203 | } |
cc1e2398 AK |
7204 | |
7205 | if ((pVBInfo->LCDResInfo == Panel1280x1024) | |
7206 | || (pVBInfo->LCDResInfo == Panel1280x1024x75)) | |
7207 | tempah |= 0x80; | |
7208 | ||
7209 | if (pVBInfo->LCDResInfo == Panel1280x960) | |
7210 | tempah |= 0x80; | |
7211 | ||
8104e329 | 7212 | xgifb_reg_set(pVBInfo->Part4Port, 0x0C, tempah); |
d7636e0b | 7213 | } |
d7636e0b | 7214 | |
21df8fc8 PS |
7215 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
7216 | | VB_XGI302LV | VB_XGI301C)) { | |
cc1e2398 AK |
7217 | tempah = 0; |
7218 | tempbl = 0xfb; | |
21df8fc8 | 7219 | |
cc1e2398 AK |
7220 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { |
7221 | tempbl = 0xff; | |
7222 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) | |
7223 | tempah |= 0x04; /* shampoo 0129 */ | |
21df8fc8 | 7224 | } |
d7636e0b | 7225 | |
ec9e5d3e | 7226 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x13, tempbl, tempah); |
cc1e2398 AK |
7227 | tempah = 0x00; |
7228 | tempbl = 0xcf; | |
7229 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { | |
7230 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) | |
7231 | tempah |= 0x30; | |
7232 | } | |
d7636e0b | 7233 | |
ec9e5d3e | 7234 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2c, tempbl, tempah); |
cc1e2398 AK |
7235 | tempah = 0; |
7236 | tempbl = 0x3f; | |
d7636e0b | 7237 | |
cc1e2398 AK |
7238 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
7239 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) | |
7240 | tempah |= 0xc0; | |
7241 | } | |
ec9e5d3e | 7242 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, tempbl, tempah); |
21df8fc8 | 7243 | } |
d7636e0b | 7244 | |
cc1e2398 AK |
7245 | tempah = 0; |
7246 | tempbl = 0x7f; | |
7247 | if (!(pVBInfo->VBInfo & SetCRT2ToLCDA)) { | |
7248 | tempbl = 0xff; | |
7249 | if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge)) | |
7250 | tempah |= 0x80; | |
21df8fc8 | 7251 | } |
d7636e0b | 7252 | |
ec9e5d3e | 7253 | xgifb_reg_and_or(pVBInfo->Part4Port, 0x23, tempbl, tempah); |
d7636e0b | 7254 | |
cc1e2398 AK |
7255 | if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) { |
7256 | if (pVBInfo->LCDInfo & SetLCDDualLink) { | |
b9bf6e4e AK |
7257 | xgifb_reg_or(pVBInfo->Part4Port, 0x27, 0x20); |
7258 | xgifb_reg_or(pVBInfo->Part4Port, 0x34, 0x10); | |
cc1e2398 AK |
7259 | } |
7260 | } | |
d7636e0b | 7261 | } |
7262 | ||
cc1e2398 | 7263 | static void XGI_CloseCRTC(struct xgi_hw_device_info *HwDeviceExtension, |
21df8fc8 | 7264 | struct vb_device_info *pVBInfo) |
d7636e0b | 7265 | { |
cc1e2398 | 7266 | unsigned short tempbx; |
d7636e0b | 7267 | |
cc1e2398 | 7268 | tempbx = 0; |
d7636e0b | 7269 | |
cc1e2398 AK |
7270 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) |
7271 | tempbx = 0x08A0; | |
d7636e0b | 7272 | |
d7636e0b | 7273 | } |
7274 | ||
cc1e2398 AK |
7275 | void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension, |
7276 | struct vb_device_info *pVBInfo) | |
d7636e0b | 7277 | { |
d7636e0b | 7278 | |
ec9e5d3e | 7279 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2f, 0xFF, 0x01); |
cc1e2398 | 7280 | |
d7636e0b | 7281 | } |
7282 | ||
cc1e2398 | 7283 | void XGI_LockCRT2(struct xgi_hw_device_info *HwDeviceExtension, |
21df8fc8 PS |
7284 | struct vb_device_info *pVBInfo) |
7285 | { | |
21df8fc8 | 7286 | |
ec9e5d3e | 7287 | xgifb_reg_and_or(pVBInfo->Part1Port, 0x2F, 0xFE, 0x00); |
21df8fc8 | 7288 | |
cc1e2398 | 7289 | } |
21df8fc8 | 7290 | |
cc1e2398 AK |
7291 | unsigned char XGI_BridgeIsOn(struct vb_device_info *pVBInfo) |
7292 | { | |
7293 | unsigned short flag; | |
21df8fc8 | 7294 | |
cc1e2398 AK |
7295 | if (pVBInfo->IF_DEF_LVDS == 1) { |
7296 | return 1; | |
7297 | } else { | |
58839b01 | 7298 | flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00); |
cc1e2398 AK |
7299 | if ((flag == 1) || (flag == 2)) |
7300 | return 1; /* 301b */ | |
7301 | else | |
7302 | return 0; | |
7303 | } | |
7304 | } | |
21df8fc8 | 7305 | |
cc1e2398 AK |
7306 | void XGI_LongWait(struct vb_device_info *pVBInfo) |
7307 | { | |
7308 | unsigned short i; | |
21df8fc8 | 7309 | |
58839b01 | 7310 | i = xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
21df8fc8 | 7311 | |
cc1e2398 AK |
7312 | if (!(i & 0xC0)) { |
7313 | for (i = 0; i < 0xFFFF; i++) { | |
d8ad0a6d | 7314 | if (!(inb(pVBInfo->P3da) & 0x08)) |
cc1e2398 AK |
7315 | break; |
7316 | } | |
21df8fc8 | 7317 | |
cc1e2398 | 7318 | for (i = 0; i < 0xFFFF; i++) { |
d8ad0a6d | 7319 | if ((inb(pVBInfo->P3da) & 0x08)) |
cc1e2398 AK |
7320 | break; |
7321 | } | |
7322 | } | |
7323 | } | |
21df8fc8 | 7324 | |
cc1e2398 AK |
7325 | static void XGI_VBLongWait(struct vb_device_info *pVBInfo) |
7326 | { | |
7327 | unsigned short tempal, temp, i, j; | |
7328 | return; | |
7329 | if (!(pVBInfo->VBInfo & SetCRT2ToTV)) { | |
7330 | temp = 0; | |
7331 | for (i = 0; i < 3; i++) { | |
7332 | for (j = 0; j < 100; j++) { | |
d8ad0a6d | 7333 | tempal = inb(pVBInfo->P3da); |
cc1e2398 AK |
7334 | if (temp & 0x01) { /* VBWaitMode2 */ |
7335 | if ((tempal & 0x08)) | |
7336 | continue; | |
21df8fc8 | 7337 | |
cc1e2398 AK |
7338 | if (!(tempal & 0x08)) |
7339 | break; | |
d7636e0b | 7340 | |
cc1e2398 AK |
7341 | } else { /* VBWaitMode1 */ |
7342 | if (!(tempal & 0x08)) | |
7343 | continue; | |
7344 | ||
7345 | if ((tempal & 0x08)) | |
7346 | break; | |
7347 | } | |
7348 | } | |
7349 | temp = temp ^ 0x01; | |
7350 | } | |
7351 | } else { | |
7352 | XGI_LongWait(pVBInfo); | |
21df8fc8 | 7353 | } |
cc1e2398 AK |
7354 | return; |
7355 | } | |
21df8fc8 | 7356 | |
cc1e2398 AK |
7357 | unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE, |
7358 | unsigned short ModeNo, unsigned short ModeIdIndex, | |
7359 | struct vb_device_info *pVBInfo) | |
7360 | { | |
7361 | short LCDRefreshIndex[] = { 0x00, 0x00, 0x03, 0x01 }, | |
7362 | LCDARefreshIndex[] = { 0x00, 0x00, 0x03, 0x01, 0x01, | |
7363 | 0x01, 0x01 }; | |
21df8fc8 | 7364 | |
cc1e2398 AK |
7365 | unsigned short RefreshRateTableIndex, i, modeflag, index, temp; |
7366 | ||
7367 | if (ModeNo <= 0x13) | |
7368 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
21df8fc8 | 7369 | else |
cc1e2398 | 7370 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; |
21df8fc8 | 7371 | |
cc1e2398 AK |
7372 | if (ModeNo < 0x14) |
7373 | return 0xFFFF; | |
d7636e0b | 7374 | |
58839b01 | 7375 | index = xgifb_reg_get(pVBInfo->P3d4, 0x33); |
cc1e2398 AK |
7376 | index = index >> pVBInfo->SelectCRT2Rate; |
7377 | index &= 0x0F; | |
d7636e0b | 7378 | |
cc1e2398 AK |
7379 | if (pVBInfo->LCDInfo & LCDNonExpanding) |
7380 | index = 0; | |
d7636e0b | 7381 | |
cc1e2398 AK |
7382 | if (index > 0) |
7383 | index--; | |
d7636e0b | 7384 | |
cc1e2398 | 7385 | if (pVBInfo->SetFlag & ProgrammingCRT2) { |
cc1e2398 AK |
7386 | if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { |
7387 | if (pVBInfo->IF_DEF_LVDS == 0) { | |
7388 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | |
7389 | | VB_XGI301LV | VB_XGI302LV | |
7390 | | VB_XGI301C)) | |
1d7f656d KT |
7391 | /* 301b */ |
7392 | temp = LCDARefreshIndex[ | |
7393 | pVBInfo->LCDResInfo & 0x0F]; | |
cc1e2398 | 7394 | else |
1d7f656d KT |
7395 | temp = LCDRefreshIndex[ |
7396 | pVBInfo->LCDResInfo & 0x0F]; | |
cc1e2398 AK |
7397 | |
7398 | if (index > temp) | |
7399 | index = temp; | |
7400 | } else { | |
7401 | index = 0; | |
7402 | } | |
7403 | } | |
21df8fc8 | 7404 | } |
d7636e0b | 7405 | |
cc1e2398 AK |
7406 | RefreshRateTableIndex = pVBInfo->EModeIDTable[ModeIdIndex].REFindex; |
7407 | ModeNo = pVBInfo->RefIndex[RefreshRateTableIndex].ModeID; | |
7408 | if (pXGIHWDE->jChipType >= XG20) { /* for XG20, XG21, XG27 */ | |
7409 | /* | |
1d7f656d KT |
7410 | if (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag & |
7411 | XG2xNotSupport) { | |
cc1e2398 AK |
7412 | index++; |
7413 | } | |
7414 | */ | |
1d7f656d KT |
7415 | if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 800) && |
7416 | (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 600)) { | |
cc1e2398 AK |
7417 | index++; |
7418 | } | |
1d7f656d KT |
7419 | /* Alan 10/19/2007; |
7420 | * do the similar adjustment like XGISearchCRT1Rate() */ | |
7421 | if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1024) && | |
7422 | (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 768)) { | |
cc1e2398 AK |
7423 | index++; |
7424 | } | |
1d7f656d KT |
7425 | if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1280) && |
7426 | (pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 1024)) { | |
cc1e2398 AK |
7427 | index++; |
7428 | } | |
7429 | } | |
7430 | ||
7431 | i = 0; | |
7432 | do { | |
1d7f656d KT |
7433 | if (pVBInfo->RefIndex[RefreshRateTableIndex + i]. |
7434 | ModeID != ModeNo) | |
cc1e2398 | 7435 | break; |
1d7f656d KT |
7436 | temp = pVBInfo->RefIndex[RefreshRateTableIndex + i]. |
7437 | Ext_InfoFlag; | |
cc1e2398 AK |
7438 | temp &= ModeInfoFlag; |
7439 | if (temp < pVBInfo->ModeType) | |
7440 | break; | |
7441 | i++; | |
7442 | index--; | |
7443 | ||
7444 | } while (index != 0xFFFF); | |
7445 | if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) { | |
7446 | if (pVBInfo->VBInfo & SetInSlaveMode) { | |
1d7f656d KT |
7447 | temp = pVBInfo->RefIndex[RefreshRateTableIndex + i - 1]. |
7448 | Ext_InfoFlag; | |
cc1e2398 AK |
7449 | if (temp & InterlaceMode) |
7450 | i++; | |
21df8fc8 PS |
7451 | } |
7452 | } | |
cc1e2398 AK |
7453 | i--; |
7454 | if ((pVBInfo->SetFlag & ProgrammingCRT2)) { | |
7455 | temp = XGI_AjustCRT2Rate(ModeNo, ModeIdIndex, | |
7456 | RefreshRateTableIndex, &i, pVBInfo); | |
7457 | } | |
7458 | return RefreshRateTableIndex + i; /* return (0x01 | (temp1<<1)); */ | |
7459 | } | |
d7636e0b | 7460 | |
cc1e2398 AK |
7461 | static void XGI_SetLCDAGroup(unsigned short ModeNo, unsigned short ModeIdIndex, |
7462 | struct xgi_hw_device_info *HwDeviceExtension, | |
7463 | struct vb_device_info *pVBInfo) | |
7464 | { | |
7465 | unsigned short RefreshRateTableIndex; | |
7466 | /* unsigned short temp ; */ | |
7467 | ||
7468 | /* pVBInfo->SelectCRT2Rate = 0; */ | |
7469 | ||
7470 | pVBInfo->SetFlag |= ProgrammingCRT2; | |
7471 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, | |
7472 | ModeIdIndex, pVBInfo); | |
7473 | XGI_GetLVDSResInfo(ModeNo, ModeIdIndex, pVBInfo); | |
7474 | XGI_GetLVDSData(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); | |
7475 | XGI_ModCRT1Regs(ModeNo, ModeIdIndex, RefreshRateTableIndex, | |
7476 | HwDeviceExtension, pVBInfo); | |
7477 | XGI_SetLVDSRegs(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); | |
7478 | XGI_SetCRT2ECLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); | |
d7636e0b | 7479 | } |
7480 | ||
cc1e2398 | 7481 | unsigned char XGI_SetCRT2Group301(unsigned short ModeNo, |
21df8fc8 PS |
7482 | struct xgi_hw_device_info *HwDeviceExtension, |
7483 | struct vb_device_info *pVBInfo) | |
7484 | { | |
cc1e2398 | 7485 | unsigned short tempbx, ModeIdIndex, RefreshRateTableIndex; |
21df8fc8 | 7486 | |
cc1e2398 AK |
7487 | tempbx = pVBInfo->VBInfo; |
7488 | pVBInfo->SetFlag |= ProgrammingCRT2; | |
7489 | XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo); | |
7490 | pVBInfo->SelectCRT2Rate = 4; | |
7491 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, | |
7492 | ModeIdIndex, pVBInfo); | |
7493 | XGI_SaveCRT2Info(ModeNo, pVBInfo); | |
7494 | XGI_GetCRT2ResInfo(ModeNo, ModeIdIndex, pVBInfo); | |
7495 | XGI_GetCRT2Data(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); | |
7496 | XGI_PreSetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension, | |
7497 | RefreshRateTableIndex, pVBInfo); | |
7498 | XGI_SetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension, | |
7499 | RefreshRateTableIndex, pVBInfo); | |
7500 | XGI_SetLockRegs(ModeNo, ModeIdIndex, HwDeviceExtension, | |
7501 | RefreshRateTableIndex, pVBInfo); | |
7502 | XGI_SetGroup2(ModeNo, ModeIdIndex, RefreshRateTableIndex, | |
7503 | HwDeviceExtension, pVBInfo); | |
7504 | XGI_SetLCDRegs(ModeNo, ModeIdIndex, HwDeviceExtension, | |
7505 | RefreshRateTableIndex, pVBInfo); | |
7506 | XGI_SetTap4Regs(pVBInfo); | |
7507 | XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo); | |
7508 | XGI_SetGroup4(ModeNo, ModeIdIndex, RefreshRateTableIndex, | |
7509 | HwDeviceExtension, pVBInfo); | |
7510 | XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); | |
7511 | XGI_SetGroup5(ModeNo, ModeIdIndex, pVBInfo); | |
7512 | XGI_AutoThreshold(pVBInfo); | |
7513 | return 1; | |
7514 | } | |
21df8fc8 | 7515 | |
cc1e2398 AK |
7516 | void XGI_SenseCRT1(struct vb_device_info *pVBInfo) |
7517 | { | |
7518 | unsigned char CRTCData[17] = { 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, | |
7519 | 0x0B, 0x3E, 0xE9, 0x0B, 0xDF, 0xE7, 0x04, 0x00, 0x00, | |
7520 | 0x05, 0x00 }; | |
21df8fc8 | 7521 | |
cc1e2398 | 7522 | unsigned char SR01 = 0, SR1F = 0, SR07 = 0, SR06 = 0; |
d7636e0b | 7523 | |
cc1e2398 AK |
7524 | unsigned char CR17, CR63, SR31; |
7525 | unsigned short temp; | |
7526 | unsigned char DAC_TEST_PARMS[3] = { 0x0F, 0x0F, 0x0F }; | |
d7636e0b | 7527 | |
cc1e2398 | 7528 | int i; |
8104e329 | 7529 | xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86); |
21df8fc8 | 7530 | |
cc1e2398 | 7531 | /* [2004/05/06] Vicent to fix XG42 single LCD sense to CRT+LCD */ |
8104e329 | 7532 | xgifb_reg_set(pVBInfo->P3d4, 0x57, 0x4A); |
58839b01 | 7533 | xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get( |
cc1e2398 | 7534 | pVBInfo->P3d4, 0x53) | 0x02)); |
21df8fc8 | 7535 | |
58839b01 AK |
7536 | SR31 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x31); |
7537 | CR63 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x63); | |
7538 | SR01 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x01); | |
21df8fc8 | 7539 | |
8104e329 AK |
7540 | xgifb_reg_set(pVBInfo->P3c4, 0x01, (unsigned char) (SR01 & 0xDF)); |
7541 | xgifb_reg_set(pVBInfo->P3d4, 0x63, (unsigned char) (CR63 & 0xBF)); | |
21df8fc8 | 7542 | |
58839b01 | 7543 | CR17 = (unsigned char) xgifb_reg_get(pVBInfo->P3d4, 0x17); |
8104e329 | 7544 | xgifb_reg_set(pVBInfo->P3d4, 0x17, (unsigned char) (CR17 | 0x80)); |
21df8fc8 | 7545 | |
58839b01 | 7546 | SR1F = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x1F); |
8104e329 | 7547 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) (SR1F | 0x04)); |
21df8fc8 | 7548 | |
58839b01 | 7549 | SR07 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x07); |
8104e329 | 7550 | xgifb_reg_set(pVBInfo->P3c4, 0x07, (unsigned char) (SR07 & 0xFB)); |
58839b01 | 7551 | SR06 = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x06); |
8104e329 | 7552 | xgifb_reg_set(pVBInfo->P3c4, 0x06, (unsigned char) (SR06 & 0xC3)); |
21df8fc8 | 7553 | |
8104e329 | 7554 | xgifb_reg_set(pVBInfo->P3d4, 0x11, 0x00); |
21df8fc8 | 7555 | |
cc1e2398 | 7556 | for (i = 0; i < 8; i++) |
8104e329 | 7557 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) i, CRTCData[i]); |
d7636e0b | 7558 | |
cc1e2398 | 7559 | for (i = 8; i < 11; i++) |
8104e329 | 7560 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 8), |
cc1e2398 | 7561 | CRTCData[i]); |
21df8fc8 | 7562 | |
cc1e2398 | 7563 | for (i = 11; i < 13; i++) |
8104e329 | 7564 | xgifb_reg_set(pVBInfo->P3d4, (unsigned short) (i + 4), |
cc1e2398 | 7565 | CRTCData[i]); |
21df8fc8 | 7566 | |
cc1e2398 | 7567 | for (i = 13; i < 16; i++) |
8104e329 | 7568 | xgifb_reg_set(pVBInfo->P3c4, (unsigned short) (i - 3), |
cc1e2398 | 7569 | CRTCData[i]); |
21df8fc8 | 7570 | |
8104e329 | 7571 | xgifb_reg_set(pVBInfo->P3c4, 0x0E, (unsigned char) (CRTCData[16] |
cc1e2398 | 7572 | & 0xE0)); |
21df8fc8 | 7573 | |
8104e329 AK |
7574 | xgifb_reg_set(pVBInfo->P3c4, 0x31, 0x00); |
7575 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x1B); | |
7576 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE1); | |
21df8fc8 | 7577 | |
efdf4ee7 | 7578 | outb(0x00, pVBInfo->P3c8); |
cc1e2398 AK |
7579 | |
7580 | for (i = 0; i < 256; i++) { | |
efdf4ee7 AK |
7581 | outb((unsigned char) DAC_TEST_PARMS[0], (pVBInfo->P3c8 + 1)); |
7582 | outb((unsigned char) DAC_TEST_PARMS[1], (pVBInfo->P3c8 + 1)); | |
7583 | outb((unsigned char) DAC_TEST_PARMS[2], (pVBInfo->P3c8 + 1)); | |
cc1e2398 AK |
7584 | } |
7585 | ||
7586 | XGI_VBLongWait(pVBInfo); | |
7587 | XGI_VBLongWait(pVBInfo); | |
7588 | XGI_VBLongWait(pVBInfo); | |
7589 | ||
7590 | mdelay(1); | |
7591 | ||
7592 | XGI_WaitDisply(pVBInfo); | |
d8ad0a6d | 7593 | temp = inb(pVBInfo->P3c2); |
cc1e2398 AK |
7594 | |
7595 | if (temp & 0x10) | |
ec9e5d3e | 7596 | xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x20); |
cc1e2398 | 7597 | else |
ec9e5d3e | 7598 | xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x00); |
21df8fc8 | 7599 | |
cc1e2398 | 7600 | /* alan, avoid display something, set BLACK DAC if not restore DAC */ |
efdf4ee7 | 7601 | outb(0x00, pVBInfo->P3c8); |
21df8fc8 | 7602 | |
cc1e2398 | 7603 | for (i = 0; i < 256; i++) { |
efdf4ee7 AK |
7604 | outb(0, (pVBInfo->P3c8 + 1)); |
7605 | outb(0, (pVBInfo->P3c8 + 1)); | |
7606 | outb(0, (pVBInfo->P3c8 + 1)); | |
21df8fc8 | 7607 | } |
d7636e0b | 7608 | |
8104e329 AK |
7609 | xgifb_reg_set(pVBInfo->P3c4, 0x01, SR01); |
7610 | xgifb_reg_set(pVBInfo->P3d4, 0x63, CR63); | |
7611 | xgifb_reg_set(pVBInfo->P3c4, 0x31, SR31); | |
21df8fc8 | 7612 | |
cc1e2398 | 7613 | /* [2004/05/11] Vicent */ |
58839b01 | 7614 | xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get( |
cc1e2398 | 7615 | pVBInfo->P3d4, 0x53) & 0xFD)); |
8104e329 | 7616 | xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) SR1F); |
cc1e2398 | 7617 | } |
21df8fc8 | 7618 | |
cc1e2398 AK |
7619 | void XGI_EnableBridge(struct xgi_hw_device_info *HwDeviceExtension, |
7620 | struct vb_device_info *pVBInfo) | |
7621 | { | |
fd0ad470 | 7622 | unsigned short tempah; |
21df8fc8 | 7623 | |
cc1e2398 AK |
7624 | if (pVBInfo->SetFlag == Win9xDOSMode) { |
7625 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | |
7626 | | VB_XGI302LV | VB_XGI301C)) { | |
7627 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); | |
7628 | return; | |
7629 | } else | |
7630 | /* LVDS or CH7017 */ | |
7631 | return; | |
21df8fc8 | 7632 | } |
d7636e0b | 7633 | |
cc1e2398 AK |
7634 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
7635 | | VB_XGI302LV | VB_XGI301C)) { | |
7636 | if (!(pVBInfo->SetFlag & DisableChA)) { | |
7637 | if (pVBInfo->SetFlag & EnableChA) { | |
1d7f656d KT |
7638 | /* Power on */ |
7639 | xgifb_reg_set(pVBInfo->Part1Port, 0x1E, 0x20); | |
cc1e2398 | 7640 | } else { |
1d7f656d KT |
7641 | /* SetCRT2ToLCDA ) */ |
7642 | if (pVBInfo->VBInfo & SetCRT2ToDualEdge) { | |
7643 | /* Power on */ | |
8104e329 | 7644 | xgifb_reg_set(pVBInfo->Part1Port, |
1d7f656d | 7645 | 0x1E, 0x20); |
cc1e2398 AK |
7646 | } |
7647 | } | |
21df8fc8 | 7648 | } |
d7636e0b | 7649 | |
cc1e2398 AK |
7650 | if (!(pVBInfo->SetFlag & DisableChB)) { |
7651 | if ((pVBInfo->SetFlag & EnableChB) || (pVBInfo->VBInfo | |
7652 | & (SetCRT2ToLCD | SetCRT2ToTV | |
7653 | | SetCRT2ToRAMDAC))) { | |
58839b01 | 7654 | tempah = (unsigned char) xgifb_reg_get( |
cc1e2398 AK |
7655 | pVBInfo->P3c4, 0x32); |
7656 | tempah &= 0xDF; | |
7657 | if (pVBInfo->VBInfo & SetInSlaveMode) { | |
1d7f656d KT |
7658 | if (!(pVBInfo->VBInfo & |
7659 | SetCRT2ToRAMDAC)) | |
cc1e2398 AK |
7660 | tempah |= 0x20; |
7661 | } | |
8104e329 | 7662 | xgifb_reg_set(pVBInfo->P3c4, 0x32, tempah); |
b9bf6e4e | 7663 | xgifb_reg_or(pVBInfo->P3c4, 0x1E, 0x20); |
d7636e0b | 7664 | |
58839b01 | 7665 | tempah = (unsigned char) xgifb_reg_get( |
cc1e2398 | 7666 | pVBInfo->Part1Port, 0x2E); |
d7636e0b | 7667 | |
cc1e2398 | 7668 | if (!(tempah & 0x80)) |
1d7f656d | 7669 | /* BVBDOENABLE = 1 */ |
b9bf6e4e | 7670 | xgifb_reg_or(pVBInfo->Part1Port, |
1d7f656d KT |
7671 | 0x2E, 0x80); |
7672 | /* BScreenOFF = 0 */ | |
7673 | xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F); | |
cc1e2398 AK |
7674 | } |
7675 | } | |
d7636e0b | 7676 | |
cc1e2398 AK |
7677 | if ((pVBInfo->SetFlag & (EnableChA | EnableChB)) |
7678 | || (!(pVBInfo->VBInfo & DisableCRT2Display))) { | |
ec9e5d3e | 7679 | xgifb_reg_and_or(pVBInfo->Part2Port, 0x00, ~0xE0, |
cc1e2398 AK |
7680 | 0x20); /* shampoo 0129 */ |
7681 | if (pVBInfo->VBType & (VB_XGI302LV | VB_XGI301C)) { | |
7682 | if (!XGI_DisableChISLCD(pVBInfo)) { | |
1d7f656d KT |
7683 | if (XGI_EnableChISLCD(pVBInfo) || |
7684 | (pVBInfo->VBInfo & | |
7685 | (SetCRT2ToLCD | SetCRT2ToLCDA))) | |
7686 | /* LVDS PLL power on */ | |
dc50556b | 7687 | xgifb_reg_and( |
1d7f656d KT |
7688 | pVBInfo->Part4Port, |
7689 | 0x2A, | |
7690 | 0x7F); | |
cc1e2398 | 7691 | } |
1d7f656d KT |
7692 | /* LVDS Driver power on */ |
7693 | xgifb_reg_and(pVBInfo->Part4Port, 0x30, 0x7F); | |
cc1e2398 AK |
7694 | } |
7695 | } | |
d7636e0b | 7696 | |
cc1e2398 | 7697 | tempah = 0x00; |
d7636e0b | 7698 | |
cc1e2398 AK |
7699 | if (!(pVBInfo->VBInfo & DisableCRT2Display)) { |
7700 | tempah = 0xc0; | |
d7636e0b | 7701 | |
cc1e2398 AK |
7702 | if (!(pVBInfo->VBInfo & SetSimuScanMode)) { |
7703 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { | |
1d7f656d KT |
7704 | if (pVBInfo->VBInfo & |
7705 | SetCRT2ToDualEdge) { | |
cc1e2398 | 7706 | tempah = tempah & 0x40; |
1d7f656d KT |
7707 | if (pVBInfo->VBInfo & |
7708 | SetCRT2ToLCDA) | |
cc1e2398 | 7709 | tempah = tempah ^ 0xC0; |
d7636e0b | 7710 | |
1d7f656d KT |
7711 | if (pVBInfo->SetFlag & |
7712 | DisableChB) | |
cc1e2398 | 7713 | tempah &= 0xBF; |
d7636e0b | 7714 | |
1d7f656d KT |
7715 | if (pVBInfo->SetFlag & |
7716 | DisableChA) | |
cc1e2398 | 7717 | tempah &= 0x7F; |
d7636e0b | 7718 | |
1d7f656d KT |
7719 | if (pVBInfo->SetFlag & |
7720 | EnableChB) | |
cc1e2398 | 7721 | tempah |= 0x40; |
d7636e0b | 7722 | |
1d7f656d KT |
7723 | if (pVBInfo->SetFlag & |
7724 | EnableChA) | |
cc1e2398 AK |
7725 | tempah |= 0x80; |
7726 | } | |
7727 | } | |
7728 | } | |
7729 | } | |
d7636e0b | 7730 | |
1d7f656d KT |
7731 | /* EnablePart4_1F */ |
7732 | xgifb_reg_or(pVBInfo->Part4Port, 0x1F, tempah); | |
d7636e0b | 7733 | |
cc1e2398 AK |
7734 | if (pVBInfo->SetFlag & Win9xDOSMode) { |
7735 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); | |
7736 | return; | |
7737 | } | |
7738 | ||
7739 | if (!(pVBInfo->SetFlag & DisableChA)) { | |
7740 | XGI_VBLongWait(pVBInfo); | |
7741 | if (!(pVBInfo->SetFlag & GatingCRT)) { | |
1d7f656d KT |
7742 | XGI_DisableGatingCRT(HwDeviceExtension, |
7743 | pVBInfo); | |
cc1e2398 AK |
7744 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); |
7745 | XGI_VBLongWait(pVBInfo); | |
7746 | } | |
7747 | } | |
7748 | } /* 301 */ | |
7749 | else { /* LVDS */ | |
7750 | if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToLCD | |
7751 | | SetCRT2ToLCDA)) | |
1d7f656d KT |
7752 | /* enable CRT2 */ |
7753 | xgifb_reg_or(pVBInfo->Part1Port, 0x1E, 0x20); | |
d7636e0b | 7754 | |
58839b01 | 7755 | tempah = (unsigned char) xgifb_reg_get(pVBInfo->Part1Port, |
cc1e2398 AK |
7756 | 0x2E); |
7757 | if (!(tempah & 0x80)) | |
1d7f656d KT |
7758 | /* BVBDOENABLE = 1 */ |
7759 | xgifb_reg_or(pVBInfo->Part1Port, 0x2E, 0x80); | |
d7636e0b | 7760 | |
dc50556b | 7761 | xgifb_reg_and(pVBInfo->Part1Port, 0x00, 0x7F); |
cc1e2398 AK |
7762 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); |
7763 | } /* End of VB */ | |
d7636e0b | 7764 | } |
7765 | ||
cc1e2398 AK |
7766 | static void XGI_SetCRT1Group(struct xgi_hw_device_info *HwDeviceExtension, |
7767 | unsigned short ModeNo, unsigned short ModeIdIndex, | |
21df8fc8 | 7768 | struct vb_device_info *pVBInfo) |
d7636e0b | 7769 | { |
cc1e2398 | 7770 | unsigned short StandTableIndex, RefreshRateTableIndex, b3CC, temp; |
d7636e0b | 7771 | |
cc1e2398 | 7772 | unsigned short XGINew_P3cc = pVBInfo->P3cc; |
d7636e0b | 7773 | |
cc1e2398 AK |
7774 | /* XGINew_CRT1Mode = ModeNo; // SaveModeID */ |
7775 | StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo); | |
7776 | /* XGI_SetBIOSData(ModeNo, ModeIdIndex); */ | |
7777 | /* XGI_ClearBankRegs(ModeNo, ModeIdIndex); */ | |
7778 | XGI_SetSeqRegs(ModeNo, StandTableIndex, ModeIdIndex, pVBInfo); | |
7779 | XGI_SetMiscRegs(StandTableIndex, pVBInfo); | |
7780 | XGI_SetCRTCRegs(HwDeviceExtension, StandTableIndex, pVBInfo); | |
7781 | XGI_SetATTRegs(ModeNo, StandTableIndex, ModeIdIndex, pVBInfo); | |
7782 | XGI_SetGRCRegs(StandTableIndex, pVBInfo); | |
7783 | XGI_ClearExt1Regs(pVBInfo); | |
d7636e0b | 7784 | |
cc1e2398 AK |
7785 | /* if (pVBInfo->IF_DEF_ExpLink) */ |
7786 | if (HwDeviceExtension->jChipType == XG27) { | |
7787 | if (pVBInfo->IF_DEF_LVDS == 0) | |
7788 | XGI_SetDefaultVCLK(pVBInfo); | |
21df8fc8 | 7789 | } |
d7636e0b | 7790 | |
cc1e2398 AK |
7791 | temp = ~ProgrammingCRT2; |
7792 | pVBInfo->SetFlag &= temp; | |
7793 | pVBInfo->SelectCRT2Rate = 0; | |
d7636e0b | 7794 | |
cc1e2398 AK |
7795 | if (pVBInfo->VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV |
7796 | | VB_XGI302LV | VB_XGI301C)) { | |
7797 | if (pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToLCDA | |
7798 | | SetInSlaveMode)) { | |
7799 | pVBInfo->SetFlag |= ProgrammingCRT2; | |
21df8fc8 | 7800 | } |
cc1e2398 | 7801 | } |
d7636e0b | 7802 | |
cc1e2398 AK |
7803 | RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, |
7804 | ModeIdIndex, pVBInfo); | |
7805 | if (RefreshRateTableIndex != 0xFFFF) { | |
7806 | XGI_SetSync(RefreshRateTableIndex, pVBInfo); | |
7807 | XGI_SetCRT1CRTC(ModeNo, ModeIdIndex, RefreshRateTableIndex, | |
7808 | pVBInfo, HwDeviceExtension); | |
7809 | XGI_SetCRT1DE(HwDeviceExtension, ModeNo, ModeIdIndex, | |
7810 | RefreshRateTableIndex, pVBInfo); | |
7811 | XGI_SetCRT1Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex, | |
7812 | HwDeviceExtension, pVBInfo); | |
7813 | XGI_SetCRT1VCLK(ModeNo, ModeIdIndex, HwDeviceExtension, | |
7814 | RefreshRateTableIndex, pVBInfo); | |
7815 | } | |
7816 | ||
1d7f656d KT |
7817 | if ((HwDeviceExtension->jChipType >= XG20) && |
7818 | (HwDeviceExtension->jChipType < XG27)) { /* fix H/W DCLK/2 bug */ | |
cc1e2398 | 7819 | if ((ModeNo == 0x00) | (ModeNo == 0x01)) { |
8104e329 AK |
7820 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x4E); |
7821 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE9); | |
d8ad0a6d | 7822 | b3CC = (unsigned char) inb(XGINew_P3cc); |
efdf4ee7 | 7823 | outb((b3CC |= 0x0C), XGINew_P3cc); |
cc1e2398 AK |
7824 | } else if ((ModeNo == 0x04) | (ModeNo == 0x05) | (ModeNo |
7825 | == 0x0D)) { | |
8104e329 AK |
7826 | xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x1B); |
7827 | xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE3); | |
d8ad0a6d | 7828 | b3CC = (unsigned char) inb(XGINew_P3cc); |
efdf4ee7 | 7829 | outb((b3CC |= 0x0C), XGINew_P3cc); |
21df8fc8 | 7830 | } |
d7636e0b | 7831 | } |
d7636e0b | 7832 | |
cc1e2398 | 7833 | if (HwDeviceExtension->jChipType >= XG21) { |
58839b01 | 7834 | temp = xgifb_reg_get(pVBInfo->P3d4, 0x38); |
cc1e2398 | 7835 | if (temp & 0xA0) { |
21df8fc8 | 7836 | |
1d7f656d KT |
7837 | /* Enable write GPIOF */ |
7838 | /* xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x20); */ | |
7839 | /* P. DWN */ | |
7840 | /* xgifb_reg_and(pVBInfo->P3d4, 0x48, ~0x20); */ | |
cc1e2398 AK |
7841 | /* XG21 CRT1 Timing */ |
7842 | if (HwDeviceExtension->jChipType == XG27) | |
7843 | XGI_SetXG27CRTC(ModeNo, ModeIdIndex, | |
7844 | RefreshRateTableIndex, pVBInfo); | |
7845 | else | |
7846 | XGI_SetXG21CRTC(ModeNo, ModeIdIndex, | |
7847 | RefreshRateTableIndex, pVBInfo); | |
21df8fc8 | 7848 | |
cc1e2398 AK |
7849 | XGI_UpdateXG21CRTC(ModeNo, pVBInfo, |
7850 | RefreshRateTableIndex); | |
21df8fc8 | 7851 | |
105d8d0d AK |
7852 | xgifb_set_lcd(HwDeviceExtension->jChipType, |
7853 | pVBInfo, RefreshRateTableIndex, ModeNo); | |
cc1e2398 | 7854 | |
64db29f5 AK |
7855 | if (pVBInfo->IF_DEF_LVDS == 1) |
7856 | xgifb_set_lvds(HwDeviceExtension->jChipType, | |
7857 | ModeNo, ModeIdIndex, pVBInfo); | |
1d7f656d KT |
7858 | /* P. ON */ |
7859 | /* xgifb_reg_or(pVBInfo->P3d4, 0x48, 0x20); */ | |
21df8fc8 | 7860 | } |
21df8fc8 | 7861 | } |
d7636e0b | 7862 | |
cc1e2398 AK |
7863 | pVBInfo->SetFlag &= (~ProgrammingCRT2); |
7864 | XGI_SetCRT1FIFO(ModeNo, HwDeviceExtension, pVBInfo); | |
7865 | XGI_SetCRT1ModeRegs(HwDeviceExtension, ModeNo, ModeIdIndex, | |
7866 | RefreshRateTableIndex, pVBInfo); | |
d7636e0b | 7867 | |
cc1e2398 | 7868 | /* XGI_LoadCharacter(); //dif ifdef TVFont */ |
d7636e0b | 7869 | |
cc1e2398 AK |
7870 | XGI_LoadDAC(ModeNo, ModeIdIndex, pVBInfo); |
7871 | /* XGI_ClearBuffer(HwDeviceExtension, ModeNo, pVBInfo); */ | |
d7636e0b | 7872 | } |
7873 | ||
cc1e2398 AK |
7874 | unsigned char XGISetModeNew(struct xgi_hw_device_info *HwDeviceExtension, |
7875 | unsigned short ModeNo) | |
21df8fc8 | 7876 | { |
cc1e2398 | 7877 | unsigned short ModeIdIndex; |
1d7f656d KT |
7878 | /* unsigned char *pVBInfo->FBAddr = |
7879 | HwDeviceExtension->pjVideoMemoryAddress; */ | |
cc1e2398 AK |
7880 | struct vb_device_info VBINF; |
7881 | struct vb_device_info *pVBInfo = &VBINF; | |
7882 | pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase; | |
7883 | pVBInfo->BaseAddr = (unsigned long) HwDeviceExtension->pjIOAddress; | |
7884 | pVBInfo->IF_DEF_LVDS = 0; | |
cc1e2398 | 7885 | pVBInfo->IF_DEF_LCDA = 1; |
cc1e2398 AK |
7886 | pVBInfo->IF_DEF_VideoCapture = 0; |
7887 | pVBInfo->IF_DEF_ScaleLCD = 0; | |
7888 | pVBInfo->IF_DEF_OEMUtil = 0; | |
7889 | pVBInfo->IF_DEF_PWD = 0; | |
7890 | ||
7891 | if (HwDeviceExtension->jChipType >= XG20) { /* kuku 2004/06/25 */ | |
7892 | pVBInfo->IF_DEF_YPbPr = 0; | |
7893 | pVBInfo->IF_DEF_HiVision = 0; | |
7894 | pVBInfo->IF_DEF_CRT2Monitor = 0; | |
7895 | pVBInfo->VBType = 0; /*set VBType default 0*/ | |
cc1e2398 AK |
7896 | } else { |
7897 | pVBInfo->IF_DEF_YPbPr = 1; | |
7898 | pVBInfo->IF_DEF_HiVision = 1; | |
06587335 | 7899 | pVBInfo->IF_DEF_CRT2Monitor = 1; |
cc1e2398 AK |
7900 | } |
7901 | ||
7902 | pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14; | |
7903 | pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24; | |
7904 | pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10; | |
7905 | pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e; | |
7906 | pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12; | |
7907 | pVBInfo->P3cc = pVBInfo->BaseAddr + 0x1C; | |
7908 | pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a; | |
7909 | pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16; | |
7910 | pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17; | |
7911 | pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18; | |
7912 | pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19; | |
7913 | pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A; | |
7914 | pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00; | |
7915 | pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04; | |
7916 | pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10; | |
7917 | pVBInfo->Part3Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_12; | |
7918 | pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14; | |
7919 | pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2; | |
21df8fc8 | 7920 | |
1d7f656d KT |
7921 | /* for x86 Linux, XG21 LVDS */ |
7922 | if (HwDeviceExtension->jChipType == XG21) { | |
58839b01 | 7923 | if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) |
cc1e2398 AK |
7924 | pVBInfo->IF_DEF_LVDS = 1; |
7925 | } | |
7926 | if (HwDeviceExtension->jChipType == XG27) { | |
58839b01 AK |
7927 | if ((xgifb_reg_get(pVBInfo->P3d4, 0x38) & 0xE0) == 0xC0) { |
7928 | if (xgifb_reg_get(pVBInfo->P3d4, 0x30) & 0x20) | |
cc1e2398 AK |
7929 | pVBInfo->IF_DEF_LVDS = 1; |
7930 | } | |
7931 | } | |
21df8fc8 | 7932 | |
cc1e2398 AK |
7933 | if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 */ |
7934 | XGI_GetVBType(pVBInfo); | |
21df8fc8 | 7935 | |
cc1e2398 AK |
7936 | InitTo330Pointer(HwDeviceExtension->jChipType, pVBInfo); |
7937 | if (ModeNo & 0x80) { | |
7938 | ModeNo = ModeNo & 0x7F; | |
7939 | /* XGINew_flag_clearbuffer = 0; */ | |
7940 | } | |
7941 | /* else { | |
7942 | XGINew_flag_clearbuffer = 1; | |
21df8fc8 | 7943 | } |
cc1e2398 | 7944 | */ |
8104e329 | 7945 | xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86); |
21df8fc8 | 7946 | |
cc1e2398 AK |
7947 | if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 1.Openkey */ |
7948 | XGI_UnLockCRT2(HwDeviceExtension, pVBInfo); | |
21df8fc8 | 7949 | |
cc1e2398 | 7950 | XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo); |
21df8fc8 | 7951 | |
cc1e2398 | 7952 | XGI_GetVGAType(HwDeviceExtension, pVBInfo); |
21df8fc8 | 7953 | |
cc1e2398 AK |
7954 | if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */ |
7955 | XGI_GetVBInfo(ModeNo, ModeIdIndex, HwDeviceExtension, pVBInfo); | |
7956 | XGI_GetTVInfo(ModeNo, ModeIdIndex, pVBInfo); | |
7957 | XGI_GetLCDInfo(ModeNo, ModeIdIndex, pVBInfo); | |
7958 | XGI_DisableBridge(HwDeviceExtension, pVBInfo); | |
21df8fc8 | 7959 | |
cc1e2398 AK |
7960 | if (pVBInfo->VBInfo & (SetSimuScanMode | SetCRT2ToLCDA)) { |
7961 | XGI_SetCRT1Group(HwDeviceExtension, ModeNo, | |
7962 | ModeIdIndex, pVBInfo); | |
21df8fc8 | 7963 | |
cc1e2398 AK |
7964 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { |
7965 | XGI_SetLCDAGroup(ModeNo, ModeIdIndex, | |
7966 | HwDeviceExtension, pVBInfo); | |
7967 | } | |
7968 | } else { | |
7969 | if (!(pVBInfo->VBInfo & SwitchToCRT2)) { | |
7970 | XGI_SetCRT1Group(HwDeviceExtension, ModeNo, | |
7971 | ModeIdIndex, pVBInfo); | |
7972 | if (pVBInfo->VBInfo & SetCRT2ToLCDA) { | |
7973 | XGI_SetLCDAGroup(ModeNo, ModeIdIndex, | |
7974 | HwDeviceExtension, | |
7975 | pVBInfo); | |
7976 | } | |
7977 | } | |
7978 | } | |
21df8fc8 | 7979 | |
cc1e2398 AK |
7980 | if (pVBInfo->VBInfo & (SetSimuScanMode | SwitchToCRT2)) { |
7981 | switch (HwDeviceExtension->ujVBChipID) { | |
7982 | case VB_CHIP_301: | |
7983 | XGI_SetCRT2Group301(ModeNo, HwDeviceExtension, | |
7984 | pVBInfo); /*add for CRT2 */ | |
7985 | break; | |
21df8fc8 | 7986 | |
cc1e2398 AK |
7987 | case VB_CHIP_302: |
7988 | XGI_SetCRT2Group301(ModeNo, HwDeviceExtension, | |
7989 | pVBInfo); /*add for CRT2 */ | |
7990 | break; | |
21df8fc8 | 7991 | |
cc1e2398 AK |
7992 | default: |
7993 | break; | |
7994 | } | |
7995 | } | |
21df8fc8 | 7996 | |
cc1e2398 AK |
7997 | XGI_SetCRT2ModeRegs(ModeNo, HwDeviceExtension, pVBInfo); |
7998 | XGI_OEM310Setting(ModeNo, ModeIdIndex, pVBInfo); /*0212*/ | |
7999 | XGI_CloseCRTC(HwDeviceExtension, pVBInfo); | |
8000 | XGI_EnableBridge(HwDeviceExtension, pVBInfo); | |
8001 | } /* !XG20 */ | |
8002 | else { | |
8003 | if (pVBInfo->IF_DEF_LVDS == 1) | |
1d7f656d KT |
8004 | if (!XGI_XG21CheckLVDSMode(ModeNo, |
8005 | ModeIdIndex, | |
8006 | pVBInfo)) | |
cc1e2398 | 8007 | return 0; |
21df8fc8 | 8008 | |
cc1e2398 | 8009 | if (ModeNo <= 0x13) { |
1d7f656d KT |
8010 | pVBInfo->ModeType = pVBInfo->SModeIDTable[ModeIdIndex]. |
8011 | St_ModeFlag & ModeInfoFlag; | |
cc1e2398 | 8012 | } else { |
1d7f656d KT |
8013 | pVBInfo->ModeType = pVBInfo->EModeIDTable[ModeIdIndex]. |
8014 | Ext_ModeFlag & ModeInfoFlag; | |
cc1e2398 | 8015 | } |
21df8fc8 | 8016 | |
cc1e2398 | 8017 | pVBInfo->SetFlag = 0; |
83f76a9d | 8018 | pVBInfo->VBInfo = DisableCRT2Display; |
21df8fc8 | 8019 | |
cc1e2398 | 8020 | XGI_DisplayOff(HwDeviceExtension, pVBInfo); |
21df8fc8 | 8021 | |
cc1e2398 AK |
8022 | XGI_SetCRT1Group(HwDeviceExtension, ModeNo, ModeIdIndex, |
8023 | pVBInfo); | |
21df8fc8 | 8024 | |
cc1e2398 AK |
8025 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); |
8026 | /* | |
8027 | if (HwDeviceExtension->jChipType == XG21) | |
ec9e5d3e | 8028 | xgifb_reg_and_or(pVBInfo->P3c4, 0x09, ~0x80, 0x80); |
cc1e2398 AK |
8029 | */ |
8030 | } | |
21df8fc8 | 8031 | |
cc1e2398 AK |
8032 | /* |
8033 | if (ModeNo <= 0x13) { | |
8034 | modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag; | |
8035 | } else { | |
8036 | modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag; | |
8037 | } | |
8038 | pVBInfo->ModeType = modeflag&ModeInfoFlag; | |
8039 | pVBInfo->SetFlag = 0x00; | |
8040 | pVBInfo->VBInfo = DisableCRT2Display; | |
1d7f656d KT |
8041 | temp = XGINew_CheckMemorySize(HwDeviceExtension, |
8042 | ModeNo, | |
8043 | ModeIdIndex, | |
8044 | pVBInfo); | |
21df8fc8 | 8045 | |
cc1e2398 AK |
8046 | if (temp == 0) |
8047 | return (0); | |
21df8fc8 | 8048 | |
cc1e2398 AK |
8049 | XGI_DisplayOff(HwDeviceExtension, pVBInfo) ; |
8050 | XGI_SetCRT1Group(HwDeviceExtension, ModeNo, ModeIdIndex, pVBInfo); | |
8051 | XGI_DisplayOn(HwDeviceExtension, pVBInfo); | |
8052 | */ | |
21df8fc8 | 8053 | |
cc1e2398 | 8054 | XGI_UpdateModeInfo(HwDeviceExtension, pVBInfo); |
21df8fc8 | 8055 | |
cc1e2398 AK |
8056 | if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */ |
8057 | XGI_LockCRT2(HwDeviceExtension, pVBInfo); | |
21df8fc8 | 8058 | } |
21df8fc8 | 8059 | |
cc1e2398 | 8060 | return 1; |
d7636e0b | 8061 | } |