1 #include <linux/version.h>
3 #include <linux/types.h>
10 #include "vb_setmode.h"
12 static unsigned char XGINew_GetPanelID(struct vb_device_info *pVBInfo);
13 static unsigned char XGINew_GetLCDDDCInfo(
14 struct xgi_hw_device_info *HwDeviceExtension,
15 struct vb_device_info *pVBInfo);
16 static unsigned char XGINew_BridgeIsEnable(struct xgi_hw_device_info *,
17 struct vb_device_info *pVBInfo);
18 static unsigned char XGINew_SenseHiTV(struct xgi_hw_device_info *HwDeviceExtension,
19 struct vb_device_info *pVBInfo);
21 /**************************************************************
22 *********************** Dynamic Sense ************************
23 *************************************************************/
25 static unsigned char XGINew_Is301B(struct vb_device_info *pVBInfo)
29 flag = XGINew_GetReg1(pVBInfo->Part4Port, 0x01);
37 static unsigned char XGINew_Sense(unsigned short tempbx, unsigned short tempcx, struct vb_device_info *pVBInfo)
39 unsigned short temp, i, tempch;
42 XGINew_SetReg1(pVBInfo->Part4Port, 0x11, temp);
43 temp = (tempbx & 0xFF00) >> 8;
44 temp |= (tempcx & 0x00FF);
45 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x10, ~0x1F, temp);
47 for (i = 0; i < 10; i++)
48 XGI_LongWait(pVBInfo);
50 tempch = (tempcx & 0x7F00) >> 8;
51 temp = XGINew_GetReg1(pVBInfo->Part4Port, 0x03);
61 void XGI_GetSenseStatus(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
63 unsigned short tempax = 0, tempbx, tempcx, temp, P2reg0 = 0, SenseModeNo = 0,
64 OutputSelect = *pVBInfo->pOutputSelect, ModeIdIndex, i;
65 pVBInfo->BaseAddr = (unsigned long) HwDeviceExtension->pjIOAddress;
67 if (pVBInfo->IF_DEF_LVDS == 1) {
68 tempax = XGINew_GetReg1(pVBInfo->P3c4, 0x1A); /* ynlai 02/27/2002 */
69 tempbx = XGINew_GetReg1(pVBInfo->P3c4, 0x1B);
70 tempax = ((tempax & 0xFE) >> 1) | (tempbx << 8);
71 if (tempax == 0x00) { /* Get Panel id from DDC */
72 temp = XGINew_GetLCDDDCInfo(HwDeviceExtension, pVBInfo);
73 if (temp == 1) { /* LCD connect */
74 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x39, 0xFF, 0x01); /* set CR39 bit0="1" */
75 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x37, 0xEF, 0x00); /* clean CR37 bit4="0" */
77 } else { /* LCD don't connect */
81 XGINew_GetPanelID(pVBInfo);
85 tempbx = ~(LCDSense | AVIDEOSense | SVIDEOSense);
86 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x32, tempbx, temp);
87 } else { /* for 301 */
88 if (pVBInfo->VBInfo & SetCRT2ToHiVisionTV) { /* for HiVision */
89 tempax = XGINew_GetReg1(pVBInfo->P3c4, 0x38);
91 tempax = XGINew_GetReg1(pVBInfo->P3c4, 0x3A);
92 temp = temp | (tempax & 0x02);
93 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x32, 0xA0, temp);
95 if (XGI_BridgeIsOn(pVBInfo)) {
96 P2reg0 = XGINew_GetReg1(pVBInfo->Part2Port, 0x00);
97 if (!XGINew_BridgeIsEnable(HwDeviceExtension, pVBInfo)) {
99 /* XGINew_SetReg1(pVBInfo->P3d4, 0x30, 0x41); */
100 /* XGISetModeNew(HwDeviceExtension, 0x2e); // ynlai InitMode */
102 temp = XGI_SearchModeID(SenseModeNo, &ModeIdIndex, pVBInfo);
103 XGI_GetVGAType(HwDeviceExtension, pVBInfo);
104 XGI_GetVBType(pVBInfo);
105 pVBInfo->SetFlag = 0x00;
106 pVBInfo->ModeType = ModeVGA;
107 pVBInfo->VBInfo = SetCRT2ToRAMDAC | LoadDACFlag | SetInSlaveMode;
108 XGI_GetLCDInfo(0x2e, ModeIdIndex, pVBInfo);
109 XGI_GetTVInfo(0x2e, ModeIdIndex, pVBInfo);
110 XGI_EnableBridge(HwDeviceExtension, pVBInfo);
111 XGI_SetCRT2Group301(SenseModeNo, HwDeviceExtension, pVBInfo);
112 XGI_SetCRT2ModeRegs(0x2e, HwDeviceExtension, pVBInfo);
113 /* XGI_DisableBridge( HwDeviceExtension, pVBInfo ) ; */
114 XGINew_SetRegANDOR(pVBInfo->P3c4, 0x01, 0xDF, 0x20); /* Display Off 0212 */
115 for (i = 0; i < 20; i++)
116 XGI_LongWait(pVBInfo);
118 XGINew_SetReg1(pVBInfo->Part2Port, 0x00, 0x1c);
120 tempbx = *pVBInfo->pRGBSenseData;
122 if (!(XGINew_Is301B(pVBInfo)))
123 tempbx = *pVBInfo->pRGBSenseData2;
126 if (XGINew_Sense(tempbx, tempcx, pVBInfo)) {
127 if (XGINew_Sense(tempbx, tempcx, pVBInfo))
128 tempax |= Monitor2Sense;
131 if (pVBInfo->VBType & VB_XGI301C)
132 XGINew_SetRegOR(pVBInfo->Part4Port, 0x0d, 0x04);
134 if (XGINew_SenseHiTV(HwDeviceExtension, pVBInfo)) { /* add by kuku for Multi-adapter sense HiTV */
136 if ((pVBInfo->VBType & VB_XGI301C))
137 tempax ^= (HiTVSense | YPbPrSense);
140 if (!(tempax & (HiTVSense | YPbPrSense))) { /* start */
142 tempbx = *pVBInfo->pYCSenseData;
144 if (!(XGINew_Is301B(pVBInfo)))
145 tempbx = *pVBInfo->pYCSenseData2;
148 if (XGINew_Sense(tempbx, tempcx, pVBInfo)) {
149 if (XGINew_Sense(tempbx, tempcx, pVBInfo))
150 tempax |= SVIDEOSense;
153 if (OutputSelect & BoardTVType) {
154 tempbx = *pVBInfo->pVideoSenseData;
156 if (!(XGINew_Is301B(pVBInfo)))
157 tempbx = *pVBInfo->pVideoSenseData2;
160 if (XGINew_Sense(tempbx, tempcx, pVBInfo)) {
161 if (XGINew_Sense(tempbx, tempcx, pVBInfo))
162 tempax |= AVIDEOSense;
165 if (!(tempax & SVIDEOSense)) {
166 tempbx = *pVBInfo->pVideoSenseData;
168 if (!(XGINew_Is301B(pVBInfo)))
169 tempbx = *pVBInfo->pVideoSenseData2;
172 if (XGINew_Sense(tempbx, tempcx, pVBInfo)) {
173 if (XGINew_Sense(tempbx, tempcx, pVBInfo))
174 tempax |= AVIDEOSense;
180 if (!(tempax & Monitor2Sense)) {
181 if (XGINew_SenseLCD(HwDeviceExtension, pVBInfo))
186 XGINew_Sense(tempbx, tempcx, pVBInfo);
188 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x32, ~0xDF, tempax);
189 XGINew_SetReg1(pVBInfo->Part2Port, 0x00, P2reg0);
191 if (!(P2reg0 & 0x20)) {
192 pVBInfo->VBInfo = DisableCRT2Display;
193 /* XGI_SetCRT2Group301(SenseModeNo, HwDeviceExtension, pVBInfo); */
197 XGI_DisableBridge(HwDeviceExtension, pVBInfo); /* shampoo 0226 */
201 unsigned short XGINew_SenseLCD(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
203 /* unsigned short SoftSetting ; */
206 if ((HwDeviceExtension->jChipType >= XG20) || (HwDeviceExtension->jChipType >= XG40))
209 temp = XGINew_GetPanelID(pVBInfo);
212 temp = XGINew_GetLCDDDCInfo(HwDeviceExtension, pVBInfo);
217 static unsigned char XGINew_GetLCDDDCInfo(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
222 if (HwDeviceExtension->ulCRT2LCDType == LCD_UNKNOWN) {
225 temp = (unsigned short) HwDeviceExtension->ulCRT2LCDType;
226 switch (HwDeviceExtension->ulCRT2LCDType) {
254 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x36, 0xF0, temp);
259 static unsigned char XGINew_GetPanelID(struct vb_device_info *pVBInfo)
261 unsigned short PanelTypeTable[16] = { SyncNN | PanelRGB18Bit
262 | Panel800x600 | _PanelType00, SyncNN | PanelRGB18Bit
263 | Panel1024x768 | _PanelType01, SyncNN | PanelRGB18Bit
264 | Panel800x600 | _PanelType02, SyncNN | PanelRGB18Bit
265 | Panel640x480 | _PanelType03, SyncNN | PanelRGB18Bit
266 | Panel1024x768 | _PanelType04, SyncNN | PanelRGB18Bit
267 | Panel1024x768 | _PanelType05, SyncNN | PanelRGB18Bit
268 | Panel1024x768 | _PanelType06, SyncNN | PanelRGB24Bit
269 | Panel1024x768 | _PanelType07, SyncNN | PanelRGB18Bit
270 | Panel800x600 | _PanelType08, SyncNN | PanelRGB18Bit
271 | Panel1024x768 | _PanelType09, SyncNN | PanelRGB18Bit
272 | Panel800x600 | _PanelType0A, SyncNN | PanelRGB18Bit
273 | Panel1024x768 | _PanelType0B, SyncNN | PanelRGB18Bit
274 | Panel1024x768 | _PanelType0C, SyncNN | PanelRGB24Bit
275 | Panel1024x768 | _PanelType0D, SyncNN | PanelRGB18Bit
276 | Panel1024x768 | _PanelType0E, SyncNN | PanelRGB18Bit
277 | Panel1024x768 | _PanelType0F };
278 unsigned short tempax, tempbx, temp;
279 /* unsigned short return_flag; */
281 tempax = XGINew_GetReg1(pVBInfo->P3c4, 0x1A);
282 tempbx = tempax & 0x1E;
288 if (!(tempax & 0x10)) {
289 if (pVBInfo->IF_DEF_LVDS == 1) {
291 temp = XGINew_GetReg1(pVBInfo->P3c4, 0x38);
299 temp = XGINew_GetReg1(pVBInfo->P3c4, 0x39);
308 tempbx = tempbx >> 1;
309 temp = tempbx & 0x00F;
310 XGINew_SetReg1(pVBInfo->P3d4, 0x36, temp);
312 tempbx = PanelTypeTable[tempbx];
314 temp = (tempbx & 0xFF00) >> 8;
315 XGINew_SetRegANDOR(pVBInfo->P3d4, 0x37, ~(LCDSyncBit
316 | LCDRGB18Bit), temp);
321 static unsigned char XGINew_BridgeIsEnable(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
325 if (XGI_BridgeIsOn(pVBInfo) == 0) {
326 flag = XGINew_GetReg1(pVBInfo->Part1Port, 0x0);
337 static unsigned char XGINew_SenseHiTV(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
339 unsigned short tempbx, tempcx, temp, i, tempch;
341 tempbx = *pVBInfo->pYCSenseData2;
345 temp = tempbx & 0xFF;
346 XGINew_SetReg1(pVBInfo->Part4Port, 0x11, temp);
347 temp = (tempbx & 0xFF00) >> 8;
348 temp |= (tempcx & 0x00FF);
349 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x10, ~0x1F, temp);
351 for (i = 0; i < 10; i++)
352 XGI_LongWait(pVBInfo);
354 tempch = (tempcx & 0xFF00) >> 8;
355 temp = XGINew_GetReg1(pVBInfo->Part4Port, 0x03);
356 temp = temp ^ (0x0E);
362 tempbx = *pVBInfo->pVideoSenseData2;
365 temp = tempbx & 0xFF;
366 XGINew_SetReg1(pVBInfo->Part4Port, 0x11, temp);
367 temp = (tempbx & 0xFF00) >> 8;
368 temp |= (tempcx & 0x00FF);
369 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x10, ~0x1F, temp);
371 for (i = 0; i < 10; i++)
372 XGI_LongWait(pVBInfo);
374 tempch = (tempcx & 0xFF00) >> 8;
375 temp = XGINew_GetReg1(pVBInfo->Part4Port, 0x03);
376 temp = temp ^ (0x0E);
379 if (temp != tempch) {
384 temp = tempbx & 0xFF;
385 XGINew_SetReg1(pVBInfo->Part4Port, 0x11, temp);
386 temp = (tempbx & 0xFF00) >> 8;
387 temp |= (tempcx & 0x00FF);
388 XGINew_SetRegANDOR(pVBInfo->Part4Port, 0x10, ~0x1F, temp);
390 for (i = 0; i < 10; i++)
391 XGI_LongWait(pVBInfo);
393 tempch = (tempcx & 0xFF00) >> 8;
394 temp = XGINew_GetReg1(pVBInfo->Part4Port, 0x03);
395 temp = temp ^ (0x0E);