1 #include <linux/version.h>
3 #include <linux/types.h>
10 #include "vb_setmode.h"
13 /**************************************************************
14 *********************** Dynamic Sense ************************
15 *************************************************************/
17 static unsigned char XGINew_Is301B(struct vb_device_info
*pVBInfo
)
21 flag
= xgifb_reg_get(pVBInfo
->Part4Port
, 0x01);
29 static unsigned char XGINew_Sense(unsigned short tempbx
,
30 unsigned short tempcx
,
31 struct vb_device_info
*pVBInfo
)
33 unsigned short temp
, i
, tempch
;
36 xgifb_reg_set(pVBInfo
->Part4Port
, 0x11, temp
);
37 temp
= (tempbx
& 0xFF00) >> 8;
38 temp
|= (tempcx
& 0x00FF);
39 xgifb_reg_and_or(pVBInfo
->Part4Port
, 0x10, ~0x1F, temp
);
41 for (i
= 0; i
< 10; i
++)
42 XGI_LongWait(pVBInfo
);
44 tempch
= (tempcx
& 0x7F00) >> 8;
45 temp
= xgifb_reg_get(pVBInfo
->Part4Port
, 0x03);
56 XGINew_GetLCDDDCInfo(struct xgi_hw_device_info
*HwDeviceExtension
,
57 struct vb_device_info
*pVBInfo
)
62 if (HwDeviceExtension
->ulCRT2LCDType
== LCD_UNKNOWN
) {
65 temp
= (unsigned short) HwDeviceExtension
->ulCRT2LCDType
;
66 switch (HwDeviceExtension
->ulCRT2LCDType
) {
94 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x36, 0xF0, temp
);
99 static unsigned char XGINew_GetPanelID(struct vb_device_info
*pVBInfo
)
101 unsigned short PanelTypeTable
[16] = { SyncNN
| PanelRGB18Bit
102 | Panel800x600
| _PanelType00
, SyncNN
| PanelRGB18Bit
103 | Panel1024x768
| _PanelType01
, SyncNN
| PanelRGB18Bit
104 | Panel800x600
| _PanelType02
, SyncNN
| PanelRGB18Bit
105 | Panel640x480
| _PanelType03
, SyncNN
| PanelRGB18Bit
106 | Panel1024x768
| _PanelType04
, SyncNN
| PanelRGB18Bit
107 | Panel1024x768
| _PanelType05
, SyncNN
| PanelRGB18Bit
108 | Panel1024x768
| _PanelType06
, SyncNN
| PanelRGB24Bit
109 | Panel1024x768
| _PanelType07
, SyncNN
| PanelRGB18Bit
110 | Panel800x600
| _PanelType08
, SyncNN
| PanelRGB18Bit
111 | Panel1024x768
| _PanelType09
, SyncNN
| PanelRGB18Bit
112 | Panel800x600
| _PanelType0A
, SyncNN
| PanelRGB18Bit
113 | Panel1024x768
| _PanelType0B
, SyncNN
| PanelRGB18Bit
114 | Panel1024x768
| _PanelType0C
, SyncNN
| PanelRGB24Bit
115 | Panel1024x768
| _PanelType0D
, SyncNN
| PanelRGB18Bit
116 | Panel1024x768
| _PanelType0E
, SyncNN
| PanelRGB18Bit
117 | Panel1024x768
| _PanelType0F
};
118 unsigned short tempax
, tempbx
, temp
;
119 /* unsigned short return_flag; */
121 tempax
= xgifb_reg_get(pVBInfo
->P3c4
, 0x1A);
122 tempbx
= tempax
& 0x1E;
128 if (!(tempax & 0x10)) {
129 if (pVBInfo->IF_DEF_LVDS == 1) {
131 temp = xgifb_reg_get(pVBInfo->P3c4, 0x38);
139 temp = xgifb_reg_get(pVBInfo->P3c4, 0x39);
148 tempbx
= tempbx
>> 1;
149 temp
= tempbx
& 0x00F;
150 xgifb_reg_set(pVBInfo
->P3d4
, 0x36, temp
);
152 tempbx
= PanelTypeTable
[tempbx
];
154 temp
= (tempbx
& 0xFF00) >> 8;
155 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x37, ~(LCDSyncBit
156 | LCDRGB18Bit
), temp
);
162 XGINew_BridgeIsEnable(struct xgi_hw_device_info
*HwDeviceExtension
,
163 struct vb_device_info
*pVBInfo
)
167 if (XGI_BridgeIsOn(pVBInfo
) == 0) {
168 flag
= xgifb_reg_get(pVBInfo
->Part1Port
, 0x0);
180 XGINew_SenseHiTV(struct xgi_hw_device_info
*HwDeviceExtension
,
181 struct vb_device_info
*pVBInfo
)
183 unsigned short tempbx
, tempcx
, temp
, i
, tempch
;
185 tempbx
= *pVBInfo
->pYCSenseData2
;
189 temp
= tempbx
& 0xFF;
190 xgifb_reg_set(pVBInfo
->Part4Port
, 0x11, temp
);
191 temp
= (tempbx
& 0xFF00) >> 8;
192 temp
|= (tempcx
& 0x00FF);
193 xgifb_reg_and_or(pVBInfo
->Part4Port
, 0x10, ~0x1F, temp
);
195 for (i
= 0; i
< 10; i
++)
196 XGI_LongWait(pVBInfo
);
198 tempch
= (tempcx
& 0xFF00) >> 8;
199 temp
= xgifb_reg_get(pVBInfo
->Part4Port
, 0x03);
200 temp
= temp
^ (0x0E);
206 tempbx
= *pVBInfo
->pVideoSenseData2
;
209 temp
= tempbx
& 0xFF;
210 xgifb_reg_set(pVBInfo
->Part4Port
, 0x11, temp
);
211 temp
= (tempbx
& 0xFF00) >> 8;
212 temp
|= (tempcx
& 0x00FF);
213 xgifb_reg_and_or(pVBInfo
->Part4Port
, 0x10, ~0x1F, temp
);
215 for (i
= 0; i
< 10; i
++)
216 XGI_LongWait(pVBInfo
);
218 tempch
= (tempcx
& 0xFF00) >> 8;
219 temp
= xgifb_reg_get(pVBInfo
->Part4Port
, 0x03);
220 temp
= temp
^ (0x0E);
223 if (temp
!= tempch
) {
228 temp
= tempbx
& 0xFF;
229 xgifb_reg_set(pVBInfo
->Part4Port
, 0x11, temp
);
230 temp
= (tempbx
& 0xFF00) >> 8;
231 temp
|= (tempcx
& 0x00FF);
232 xgifb_reg_and_or(pVBInfo
->Part4Port
, 0x10, ~0x1F, temp
);
234 for (i
= 0; i
< 10; i
++)
235 XGI_LongWait(pVBInfo
);
237 tempch
= (tempcx
& 0xFF00) >> 8;
238 temp
= xgifb_reg_get(pVBInfo
->Part4Port
, 0x03);
239 temp
= temp
^ (0x0E);
249 void XGI_GetSenseStatus(struct xgi_hw_device_info
*HwDeviceExtension
,
250 struct vb_device_info
*pVBInfo
)
252 unsigned short tempax
= 0, tempbx
, tempcx
, temp
,
253 P2reg0
= 0, SenseModeNo
= 0,
254 OutputSelect
= *pVBInfo
->pOutputSelect
,
256 pVBInfo
->BaseAddr
= (unsigned long) HwDeviceExtension
->pjIOAddress
;
258 if (pVBInfo
->IF_DEF_LVDS
== 1) {
259 /* ynlai 02/27/2002 */
260 tempax
= xgifb_reg_get(pVBInfo
->P3c4
, 0x1A);
261 tempbx
= xgifb_reg_get(pVBInfo
->P3c4
, 0x1B);
262 tempax
= ((tempax
& 0xFE) >> 1) | (tempbx
<< 8);
263 if (tempax
== 0x00) { /* Get Panel id from DDC */
264 temp
= XGINew_GetLCDDDCInfo(HwDeviceExtension
, pVBInfo
);
265 if (temp
== 1) { /* LCD connect */
266 /* set CR39 bit0="1" */
267 xgifb_reg_and_or(pVBInfo
->P3d4
,
269 /* clean CR37 bit4="0" */
270 xgifb_reg_and_or(pVBInfo
->P3d4
,
273 } else { /* LCD don't connect */
277 XGINew_GetPanelID(pVBInfo
);
281 tempbx
= ~(LCDSense
| AVIDEOSense
| SVIDEOSense
);
282 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x32, tempbx
, temp
);
283 } else { /* for 301 */
284 if (pVBInfo
->VBInfo
& SetCRT2ToHiVisionTV
) { /* for HiVision */
285 tempax
= xgifb_reg_get(pVBInfo
->P3c4
, 0x38);
286 temp
= tempax
& 0x01;
287 tempax
= xgifb_reg_get(pVBInfo
->P3c4
, 0x3A);
288 temp
= temp
| (tempax
& 0x02);
289 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x32, 0xA0, temp
);
291 if (XGI_BridgeIsOn(pVBInfo
)) {
292 P2reg0
= xgifb_reg_get(pVBInfo
->Part2Port
,
294 if (!XGINew_BridgeIsEnable(HwDeviceExtension
,
297 /* xgifb_reg_set(pVBInfo->P3d4, 0x30, 0x41);
298 * XGISetModeNew(HwDeviceExtension, 0x2e);
299 * // ynlai InitMode */
301 temp
= XGI_SearchModeID(SenseModeNo
,
304 XGI_GetVGAType(HwDeviceExtension
,
306 XGI_GetVBType(pVBInfo
);
307 pVBInfo
->SetFlag
= 0x00;
308 pVBInfo
->ModeType
= ModeVGA
;
309 pVBInfo
->VBInfo
= SetCRT2ToRAMDAC
|
318 XGI_EnableBridge(HwDeviceExtension
,
320 XGI_SetCRT2Group301(SenseModeNo
,
323 XGI_SetCRT2ModeRegs(0x2e,
326 /* XGI_DisableBridge(HwDeviceExtension,
328 /* Display Off 0212 */
329 xgifb_reg_and_or(pVBInfo
->P3c4
,
333 for (i
= 0; i
< 20; i
++)
334 XGI_LongWait(pVBInfo
);
336 xgifb_reg_set(pVBInfo
->Part2Port
, 0x00, 0x1c);
338 tempbx
= *pVBInfo
->pRGBSenseData
;
340 if (!(XGINew_Is301B(pVBInfo
)))
341 tempbx
= *pVBInfo
->pRGBSenseData2
;
344 if (XGINew_Sense(tempbx
, tempcx
, pVBInfo
)) {
345 if (XGINew_Sense(tempbx
,
348 tempax
|= Monitor2Sense
;
351 if (pVBInfo
->VBType
& VB_XGI301C
)
352 xgifb_reg_or(pVBInfo
->Part4Port
,
356 /* add by kuku for Multi-adapter sense HiTV */
357 if (XGINew_SenseHiTV(HwDeviceExtension
,
360 if ((pVBInfo
->VBType
& VB_XGI301C
))
361 tempax
^= (HiTVSense
|
366 if (!(tempax
& (HiTVSense
| YPbPrSense
))) {
367 tempbx
= *pVBInfo
->pYCSenseData
;
368 if (!(XGINew_Is301B(pVBInfo
)))
369 tempbx
= *pVBInfo
->pYCSenseData2
;
371 if (XGINew_Sense(tempbx
,
374 if (XGINew_Sense(tempbx
,
377 tempax
|= SVIDEOSense
;
380 if (OutputSelect
& BoardTVType
) {
381 tempbx
= *pVBInfo
->pVideoSenseData
;
383 if (!(XGINew_Is301B(pVBInfo
)))
384 tempbx
= *pVBInfo
->pVideoSenseData2
;
387 if (XGINew_Sense(tempbx
,
390 if (XGINew_Sense(tempbx
,
393 tempax
|= AVIDEOSense
;
396 if (!(tempax
& SVIDEOSense
)) {
397 tempbx
= *pVBInfo
->pVideoSenseData
;
399 if (!(XGINew_Is301B(pVBInfo
)))
400 tempbx
= *pVBInfo
->pVideoSenseData2
;
403 if (XGINew_Sense(tempbx
,
406 if (XGINew_Sense(tempbx
, tempcx
, pVBInfo
))
407 tempax
|= AVIDEOSense
;
413 if (!(tempax
& Monitor2Sense
)) {
414 if (XGINew_SenseLCD(HwDeviceExtension
, pVBInfo
))
419 XGINew_Sense(tempbx
, tempcx
, pVBInfo
);
421 xgifb_reg_and_or(pVBInfo
->P3d4
, 0x32, ~0xDF, tempax
);
422 xgifb_reg_set(pVBInfo
->Part2Port
, 0x00, P2reg0
);
424 if (!(P2reg0
& 0x20)) {
425 pVBInfo
->VBInfo
= DisableCRT2Display
;
426 /* XGI_SetCRT2Group301(SenseModeNo,
432 XGI_DisableBridge(HwDeviceExtension
, pVBInfo
); /* shampoo 0226 */
436 unsigned short XGINew_SenseLCD(struct xgi_hw_device_info
*HwDeviceExtension
,
437 struct vb_device_info
*pVBInfo
)
439 /* unsigned short SoftSetting ; */
442 temp
= XGINew_GetLCDDDCInfo(HwDeviceExtension
, pVBInfo
);