2 #include <linux/types.h>
9 #include "vb_setmode.h"
12 /**************************************************************
13 *********************** Dynamic Sense ************************
14 *************************************************************/
16 static unsigned char XGINew_Is301B(struct vb_device_info *pVBInfo)
20 flag = xgifb_reg_get(pVBInfo->Part4Port, 0x01);
28 static unsigned char XGINew_Sense(unsigned short tempbx,
29 unsigned short tempcx,
30 struct vb_device_info *pVBInfo)
32 unsigned short temp, i, tempch;
35 xgifb_reg_set(pVBInfo->Part4Port, 0x11, temp);
36 temp = (tempbx & 0xFF00) >> 8;
37 temp |= (tempcx & 0x00FF);
38 xgifb_reg_and_or(pVBInfo->Part4Port, 0x10, ~0x1F, temp);
40 for (i = 0; i < 10; i++)
41 XGI_LongWait(pVBInfo);
43 tempch = (tempcx & 0x7F00) >> 8;
44 temp = xgifb_reg_get(pVBInfo->Part4Port, 0x03);
55 XGINew_GetLCDDDCInfo(struct xgi_hw_device_info *HwDeviceExtension,
56 struct vb_device_info *pVBInfo)
61 if (HwDeviceExtension->ulCRT2LCDType == LCD_UNKNOWN) {
64 temp = (unsigned short) HwDeviceExtension->ulCRT2LCDType;
65 switch (HwDeviceExtension->ulCRT2LCDType) {
93 xgifb_reg_and_or(pVBInfo->P3d4, 0x36, 0xF0, temp);
98 static unsigned char XGINew_GetPanelID(struct vb_device_info *pVBInfo)
100 unsigned short PanelTypeTable[16] = { SyncNN | PanelRGB18Bit
101 | Panel800x600 | _PanelType00, SyncNN | PanelRGB18Bit
102 | Panel1024x768 | _PanelType01, SyncNN | PanelRGB18Bit
103 | Panel800x600 | _PanelType02, SyncNN | PanelRGB18Bit
104 | Panel640x480 | _PanelType03, SyncNN | PanelRGB18Bit
105 | Panel1024x768 | _PanelType04, SyncNN | PanelRGB18Bit
106 | Panel1024x768 | _PanelType05, SyncNN | PanelRGB18Bit
107 | Panel1024x768 | _PanelType06, SyncNN | PanelRGB24Bit
108 | Panel1024x768 | _PanelType07, SyncNN | PanelRGB18Bit
109 | Panel800x600 | _PanelType08, SyncNN | PanelRGB18Bit
110 | Panel1024x768 | _PanelType09, SyncNN | PanelRGB18Bit
111 | Panel800x600 | _PanelType0A, SyncNN | PanelRGB18Bit
112 | Panel1024x768 | _PanelType0B, SyncNN | PanelRGB18Bit
113 | Panel1024x768 | _PanelType0C, SyncNN | PanelRGB24Bit
114 | Panel1024x768 | _PanelType0D, SyncNN | PanelRGB18Bit
115 | Panel1024x768 | _PanelType0E, SyncNN | PanelRGB18Bit
116 | Panel1024x768 | _PanelType0F };
117 unsigned short tempax, tempbx, temp;
118 /* unsigned short return_flag; */
120 tempax = xgifb_reg_get(pVBInfo->P3c4, 0x1A);
121 tempbx = tempax & 0x1E;
127 if (!(tempax & 0x10)) {
128 if (pVBInfo->IF_DEF_LVDS == 1) {
130 temp = xgifb_reg_get(pVBInfo->P3c4, 0x38);
138 temp = xgifb_reg_get(pVBInfo->P3c4, 0x39);
147 tempbx = tempbx >> 1;
148 temp = tempbx & 0x00F;
149 xgifb_reg_set(pVBInfo->P3d4, 0x36, temp);
151 tempbx = PanelTypeTable[tempbx];
153 temp = (tempbx & 0xFF00) >> 8;
154 xgifb_reg_and_or(pVBInfo->P3d4, 0x37, ~(LCDSyncBit
155 | LCDRGB18Bit), temp);
161 XGINew_BridgeIsEnable(struct xgi_hw_device_info *HwDeviceExtension,
162 struct vb_device_info *pVBInfo)
166 if (XGI_BridgeIsOn(pVBInfo) == 0) {
167 flag = xgifb_reg_get(pVBInfo->Part1Port, 0x0);
179 XGINew_SenseHiTV(struct xgi_hw_device_info *HwDeviceExtension,
180 struct vb_device_info *pVBInfo)
182 unsigned short tempbx, tempcx, temp, i, tempch;
184 tempbx = *pVBInfo->pYCSenseData2;
188 temp = tempbx & 0xFF;
189 xgifb_reg_set(pVBInfo->Part4Port, 0x11, temp);
190 temp = (tempbx & 0xFF00) >> 8;
191 temp |= (tempcx & 0x00FF);
192 xgifb_reg_and_or(pVBInfo->Part4Port, 0x10, ~0x1F, temp);
194 for (i = 0; i < 10; i++)
195 XGI_LongWait(pVBInfo);
197 tempch = (tempcx & 0xFF00) >> 8;
198 temp = xgifb_reg_get(pVBInfo->Part4Port, 0x03);
199 temp = temp ^ (0x0E);
205 tempbx = *pVBInfo->pVideoSenseData2;
208 temp = tempbx & 0xFF;
209 xgifb_reg_set(pVBInfo->Part4Port, 0x11, temp);
210 temp = (tempbx & 0xFF00) >> 8;
211 temp |= (tempcx & 0x00FF);
212 xgifb_reg_and_or(pVBInfo->Part4Port, 0x10, ~0x1F, temp);
214 for (i = 0; i < 10; i++)
215 XGI_LongWait(pVBInfo);
217 tempch = (tempcx & 0xFF00) >> 8;
218 temp = xgifb_reg_get(pVBInfo->Part4Port, 0x03);
219 temp = temp ^ (0x0E);
222 if (temp != tempch) {
227 temp = tempbx & 0xFF;
228 xgifb_reg_set(pVBInfo->Part4Port, 0x11, temp);
229 temp = (tempbx & 0xFF00) >> 8;
230 temp |= (tempcx & 0x00FF);
231 xgifb_reg_and_or(pVBInfo->Part4Port, 0x10, ~0x1F, temp);
233 for (i = 0; i < 10; i++)
234 XGI_LongWait(pVBInfo);
236 tempch = (tempcx & 0xFF00) >> 8;
237 temp = xgifb_reg_get(pVBInfo->Part4Port, 0x03);
238 temp = temp ^ (0x0E);
248 void XGI_GetSenseStatus(struct xgi_hw_device_info *HwDeviceExtension,
249 struct vb_device_info *pVBInfo)
251 unsigned short tempax = 0, tempbx, tempcx, temp,
252 P2reg0 = 0, SenseModeNo = 0,
253 OutputSelect = *pVBInfo->pOutputSelect,
255 pVBInfo->BaseAddr = (unsigned long) HwDeviceExtension->pjIOAddress;
257 if (pVBInfo->IF_DEF_LVDS == 1) {
258 /* ynlai 02/27/2002 */
259 tempax = xgifb_reg_get(pVBInfo->P3c4, 0x1A);
260 tempbx = xgifb_reg_get(pVBInfo->P3c4, 0x1B);
261 tempax = ((tempax & 0xFE) >> 1) | (tempbx << 8);
262 if (tempax == 0x00) { /* Get Panel id from DDC */
263 temp = XGINew_GetLCDDDCInfo(HwDeviceExtension, pVBInfo);
264 if (temp == 1) { /* LCD connect */
265 /* set CR39 bit0="1" */
266 xgifb_reg_and_or(pVBInfo->P3d4,
268 /* clean CR37 bit4="0" */
269 xgifb_reg_and_or(pVBInfo->P3d4,
272 } else { /* LCD don't connect */
276 XGINew_GetPanelID(pVBInfo);
280 tempbx = ~(LCDSense | AVIDEOSense | SVIDEOSense);
281 xgifb_reg_and_or(pVBInfo->P3d4, 0x32, tempbx, temp);
282 } else { /* for 301 */
283 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { /* for HiVision */
284 tempax = xgifb_reg_get(pVBInfo->P3c4, 0x38);
285 temp = tempax & 0x01;
286 tempax = xgifb_reg_get(pVBInfo->P3c4, 0x3A);
287 temp = temp | (tempax & 0x02);
288 xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xA0, temp);
290 if (XGI_BridgeIsOn(pVBInfo)) {
291 P2reg0 = xgifb_reg_get(pVBInfo->Part2Port,
293 if (!XGINew_BridgeIsEnable(HwDeviceExtension,
296 /* xgifb_reg_set(pVBInfo->P3d4, 0x30, 0x41);
297 * XGISetModeNew(HwDeviceExtension, 0x2e);
298 * // ynlai InitMode */
300 temp = XGI_SearchModeID(SenseModeNo,
303 XGI_GetVGAType(HwDeviceExtension,
305 XGI_GetVBType(pVBInfo);
306 pVBInfo->SetFlag = 0x00;
307 pVBInfo->ModeType = ModeVGA;
308 pVBInfo->VBInfo = SetCRT2ToRAMDAC |
317 XGI_EnableBridge(HwDeviceExtension,
319 XGI_SetCRT2Group301(SenseModeNo,
322 XGI_SetCRT2ModeRegs(0x2e,
325 /* XGI_DisableBridge(HwDeviceExtension,
327 /* Display Off 0212 */
328 xgifb_reg_and_or(pVBInfo->P3c4,
332 for (i = 0; i < 20; i++)
333 XGI_LongWait(pVBInfo);
335 xgifb_reg_set(pVBInfo->Part2Port, 0x00, 0x1c);
337 tempbx = *pVBInfo->pRGBSenseData;
339 if (!(XGINew_Is301B(pVBInfo)))
340 tempbx = *pVBInfo->pRGBSenseData2;
343 if (XGINew_Sense(tempbx, tempcx, pVBInfo)) {
344 if (XGINew_Sense(tempbx,
347 tempax |= Monitor2Sense;
350 if (pVBInfo->VBType & VB_XGI301C)
351 xgifb_reg_or(pVBInfo->Part4Port,
355 /* add by kuku for Multi-adapter sense HiTV */
356 if (XGINew_SenseHiTV(HwDeviceExtension,
359 if ((pVBInfo->VBType & VB_XGI301C))
360 tempax ^= (HiTVSense |
365 if (!(tempax & (HiTVSense | YPbPrSense))) {
366 tempbx = *pVBInfo->pYCSenseData;
367 if (!(XGINew_Is301B(pVBInfo)))
368 tempbx = *pVBInfo->pYCSenseData2;
370 if (XGINew_Sense(tempbx,
373 if (XGINew_Sense(tempbx,
376 tempax |= SVIDEOSense;
379 if (OutputSelect & BoardTVType) {
380 tempbx = *pVBInfo->pVideoSenseData;
382 if (!(XGINew_Is301B(pVBInfo)))
383 tempbx = *pVBInfo->pVideoSenseData2;
386 if (XGINew_Sense(tempbx,
389 if (XGINew_Sense(tempbx,
392 tempax |= AVIDEOSense;
395 if (!(tempax & SVIDEOSense)) {
396 tempbx = *pVBInfo->pVideoSenseData;
398 if (!(XGINew_Is301B(pVBInfo)))
399 tempbx = *pVBInfo->pVideoSenseData2;
402 if (XGINew_Sense(tempbx,
405 if (XGINew_Sense(tempbx, tempcx, pVBInfo))
406 tempax |= AVIDEOSense;
412 if (!(tempax & Monitor2Sense)) {
413 if (XGINew_SenseLCD(HwDeviceExtension, pVBInfo))
418 XGINew_Sense(tempbx, tempcx, pVBInfo);
420 xgifb_reg_and_or(pVBInfo->P3d4, 0x32, ~0xDF, tempax);
421 xgifb_reg_set(pVBInfo->Part2Port, 0x00, P2reg0);
423 if (!(P2reg0 & 0x20)) {
424 pVBInfo->VBInfo = DisableCRT2Display;
425 /* XGI_SetCRT2Group301(SenseModeNo,
431 XGI_DisableBridge(HwDeviceExtension, pVBInfo); /* shampoo 0226 */
435 unsigned short XGINew_SenseLCD(struct xgi_hw_device_info *HwDeviceExtension,
436 struct vb_device_info *pVBInfo)
438 /* unsigned short SoftSetting ; */
441 temp = XGINew_GetLCDDDCInfo(HwDeviceExtension, pVBInfo);