1 #include <linux/version.h>
3 #include <linux/types.h>
10 #include "vb_setmode.h"
12 extern unsigned char XGI330_SoftSetting;
13 extern unsigned char XGI330_OutputSelect;
14 extern unsigned short XGI330_RGBSenseData2;
15 extern unsigned short XGI330_YCSenseData2;
16 extern unsigned short XGI330_VideoSenseData2;
17 void XGI_GetSenseStatus(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo);
18 unsigned char XGINew_GetPanelID(struct vb_device_info *pVBInfo);
19 unsigned short XGINew_SenseLCD(struct xgi_hw_device_info *,
20 struct vb_device_info *pVBInfo);
21 unsigned char XGINew_GetLCDDDCInfo(struct xgi_hw_device_info *HwDeviceExtension,
22 struct vb_device_info *pVBInfo);
23 void XGISetDPMS(struct xgi_hw_device_info *pXGIHWDE,
24 unsigned long VESA_POWER_STATE);
25 unsigned char XGINew_BridgeIsEnable(struct xgi_hw_device_info *, struct vb_device_info *pVBInfo);
26 unsigned char XGINew_Sense(unsigned short tempbx, unsigned short tempcx,
27 struct vb_device_info *pVBInfo);
28 unsigned char XGINew_SenseHiTV(struct xgi_hw_device_info *HwDeviceExtension,
29 struct vb_device_info *pVBInfo);
31 /**************************************************************
33 *************************************************************/
35 void XGI_WaitDisplay(void);
36 unsigned char XGI_Is301C(struct vb_device_info *);
37 unsigned char XGI_Is301LV(struct vb_device_info *);
41 /* --------------------------------------------------------------------- */
42 /* Function : XGINew_Is301B */
46 /* --------------------------------------------------------------------- */
47 unsigned char XGINew_Is301B(struct vb_device_info *pVBInfo)
51 flag = XGINew_GetReg1( pVBInfo->Part4Port , 0x01 ) ;
54 return( 0 ) ; /* 301b */
59 /* --------------------------------------------------------------------- */
60 /* Function : XGI_Is301C */
64 /* --------------------------------------------------------------------- */
65 unsigned char XGI_Is301C(struct vb_device_info *pVBInfo)
67 if ( ( XGINew_GetReg1( pVBInfo->Part4Port , 0x01 ) & 0xF0 ) == 0xC0 )
70 if ( XGINew_GetReg1( pVBInfo->Part4Port , 0x01 ) >= 0xD0 )
72 if ( XGINew_GetReg1( pVBInfo->Part4Port , 0x39 ) == 0xE0 )
80 /* --------------------------------------------------------------------- */
81 /* Function : XGI_Is301LV */
85 /* --------------------------------------------------------------------- */
86 unsigned char XGI_Is301LV(struct vb_device_info *pVBInfo)
88 if ( XGINew_GetReg1( pVBInfo->Part4Port , 0x01 ) >= 0xD0 )
90 if ( XGINew_GetReg1( pVBInfo->Part4Port , 0x39 ) == 0xFF )
99 /* --------------------------------------------------------------------- */
100 /* Function : XGINew_Sense */
104 /* --------------------------------------------------------------------- */
105 unsigned char XGINew_Sense(unsigned short tempbx,
106 unsigned short tempcx,
107 struct vb_device_info *pVBInfo)
109 unsigned short temp, i, tempch;
111 temp = tempbx & 0xFF ;
112 XGINew_SetReg1( pVBInfo->Part4Port , 0x11 , temp ) ;
113 temp = ( tempbx & 0xFF00 ) >> 8 ;
114 temp |= ( tempcx & 0x00FF ) ;
115 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x10 , ~0x1F , temp ) ;
117 for( i = 0 ; i < 10 ; i++ )
118 XGI_LongWait( pVBInfo) ;
120 tempch = ( tempcx & 0x7F00 ) >> 8 ;
121 temp = XGINew_GetReg1( pVBInfo->Part4Port , 0x03 ) ;
122 temp = temp ^ ( 0x0E ) ;
132 /* --------------------------------------------------------------------- */
133 /* Function : XGISetDPMS */
137 /* --------------------------------------------------------------------- */
138 void XGISetDPMS(struct xgi_hw_device_info *pXGIHWDE,
139 unsigned long VESA_POWER_STATE)
141 unsigned short ModeNo, ModeIdIndex;
143 struct vb_device_info VBINF;
144 struct vb_device_info *pVBInfo = &VBINF;
145 pVBInfo->BaseAddr = (unsigned long)pXGIHWDE->pjIOAddress ;
146 pVBInfo->ROMAddr = pXGIHWDE->pjVirtualRomBase ;
149 pVBInfo->IF_DEF_LVDS = 0 ;
150 pVBInfo->IF_DEF_CH7005 = 0 ;
151 pVBInfo->IF_DEF_HiVision = 1 ;
152 pVBInfo->IF_DEF_LCDA = 1 ;
153 pVBInfo->IF_DEF_CH7017 = 0 ;
154 pVBInfo->IF_DEF_YPbPr = 1 ;
155 pVBInfo->IF_DEF_CRT2Monitor = 0 ;
156 pVBInfo->IF_DEF_VideoCapture = 0 ;
157 pVBInfo->IF_DEF_ScaleLCD = 0 ;
158 pVBInfo->IF_DEF_OEMUtil = 0 ;
159 pVBInfo->IF_DEF_PWD = 0 ;
161 InitTo330Pointer( pXGIHWDE->jChipType, pVBInfo ) ;
162 ReadVBIOSTablData( pXGIHWDE->jChipType , pVBInfo) ;
164 pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14 ;
165 pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24 ;
166 pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10 ;
167 pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e ;
168 pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12 ;
169 pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a ;
170 pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16 ;
171 pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17 ;
172 pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18 ;
173 pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19 ;
174 pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A ;
175 pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00 ;
176 pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04 ;
177 pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10 ;
178 pVBInfo->Part3Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_12 ;
179 pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 ;
180 pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2 ;
182 if ( pXGIHWDE->jChipType == XG27 )
184 if ( ( XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) & 0xE0 ) == 0xC0 )
186 if ( XGINew_GetReg1( pVBInfo->P3d4 , 0x30 ) & 0x20 )
188 pVBInfo->IF_DEF_LVDS = 1 ;
193 if ( pVBInfo->IF_DEF_CH7007 == 0 )
195 XGINew_SetModeScratch ( pXGIHWDE , pVBInfo ) ;
197 XGINew_SetReg1( pVBInfo->P3c4 , 0x05 , 0x86 ) ; /* 1.Openkey */
198 XGI_UnLockCRT2( pXGIHWDE , pVBInfo) ;
199 ModeNo = XGINew_GetReg1( pVBInfo->P3d4 , 0x34 ) ;
200 XGI_SearchModeID( ModeNo , &ModeIdIndex, pVBInfo ) ;
201 XGI_GetVGAType( pXGIHWDE , pVBInfo ) ;
203 if ( ( pXGIHWDE->ujVBChipID == VB_CHIP_301 ) || ( pXGIHWDE->ujVBChipID == VB_CHIP_302 ) || ( pVBInfo->IF_DEF_CH7007 == 1 ))
205 XGI_GetVBType( pVBInfo ) ;
206 XGI_GetVBInfo( ModeNo , ModeIdIndex , pXGIHWDE, pVBInfo ) ;
207 XGI_GetTVInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
208 XGI_GetLCDInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
211 if ( VESA_POWER_STATE == 0x00000400 )
212 XGINew_SetReg1(pVBInfo->Part4Port, 0x31, (unsigned char)(XGINew_GetReg1(pVBInfo->Part4Port, 0x31) & 0xFE));
214 XGINew_SetReg1(pVBInfo->Part4Port, 0x31, (unsigned char)(XGINew_GetReg1(pVBInfo->Part4Port, 0x31) | 0x01));
216 temp = (unsigned char)XGINew_GetReg1(pVBInfo->P3c4, 0x1f);
218 switch ( VESA_POWER_STATE )
220 case 0x00000000: /* on */
221 if ( ( pXGIHWDE->ujVBChipID == VB_CHIP_301 ) || ( pXGIHWDE->ujVBChipID == VB_CHIP_302 ) )
223 XGINew_SetReg1(pVBInfo->P3c4, 0x1f, (unsigned char)(temp | 0x00));
224 XGI_EnableBridge( pXGIHWDE, pVBInfo ) ;
228 if ( pXGIHWDE->jChipType == XG21 )
230 if ( pVBInfo->IF_DEF_LVDS == 1 )
232 XGI_XG21BLSignalVDD( 0x01 , 0x01, pVBInfo ) ; /* LVDS VDD on */
233 XGI_XG21SetPanelDelay( 2,pVBInfo ) ;
236 if ( pXGIHWDE->jChipType == XG27 )
238 if ( pVBInfo->IF_DEF_LVDS == 1 )
240 XGI_XG27BLSignalVDD( 0x01 , 0x01, pVBInfo ) ; /* LVDS VDD on */
241 XGI_XG21SetPanelDelay( 2,pVBInfo ) ;
244 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x1F , ~0xC0 , 0x00 ) ;
245 XGINew_SetRegAND( pVBInfo->P3c4 , 0x01 , ~0x20 ) ; /* CRT on */
247 if ( pXGIHWDE->jChipType == XG21 )
249 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ;
252 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x09 , ~0x80 , 0x80 ) ; /* DVO ON */
253 XGI_SetXG21FPBits( pVBInfo );
254 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x20 ) ; /* Enable write GPIOF */
255 /*XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x48 , ~0x20 , 0x20 ) ;*/ /* LCD Display ON */
257 XGI_XG21BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* LVDS signal on */
258 XGI_DisplayOn( pXGIHWDE, pVBInfo );
260 if ( pXGIHWDE->jChipType == XG27 )
262 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ;
265 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x09 , ~0x80 , 0x80 ) ; /* DVO ON */
266 XGI_SetXG27FPBits( pVBInfo );
267 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x20 ) ; /* Enable write GPIOF */
268 /*XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x48 , ~0x20 , 0x20 ) ;*/ /* LCD Display ON */
270 XGI_XG27BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* LVDS signal on */
271 XGI_DisplayOn( pXGIHWDE, pVBInfo );
275 case 0x00000100: /* standby */
276 if ( pXGIHWDE->jChipType >= XG21 )
278 XGI_DisplayOff( pXGIHWDE, pVBInfo );
281 XGINew_SetReg1(pVBInfo->P3c4, 0x1f, (unsigned char)(temp | 0x40));
283 case 0x00000200: /* suspend */
284 if ( pXGIHWDE->jChipType == XG21 )
286 XGI_DisplayOff( pXGIHWDE, pVBInfo );
287 XGI_XG21BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* LVDS signal off */
289 if ( pXGIHWDE->jChipType == XG27 )
291 XGI_DisplayOff( pXGIHWDE, pVBInfo );
292 XGI_XG27BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* LVDS signal off */
294 XGINew_SetReg1(pVBInfo->P3c4, 0x1f, (unsigned char)(temp | 0x80));
296 case 0x00000400: /* off */
297 if ( (pXGIHWDE->ujVBChipID == VB_CHIP_301 ) || ( pXGIHWDE->ujVBChipID == VB_CHIP_302 ) )
299 XGINew_SetReg1(pVBInfo->P3c4, 0x1f, (unsigned char)(temp | 0xc0));
300 XGI_DisableBridge( pXGIHWDE, pVBInfo ) ;
304 if ( pXGIHWDE->jChipType == XG21 )
306 XGI_DisplayOff( pXGIHWDE, pVBInfo );
308 XGI_XG21BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* LVDS signal off */
310 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ;
313 XGINew_SetRegAND( pVBInfo->P3c4 , 0x09 , ~0x80 ) ; /* DVO Off */
314 XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x20 ) ; /* Enable write GPIOF */
315 /*XGINew_SetRegAND( pVBInfo->P3d4 , 0x48 , ~0x20 ) ;*/ /* LCD Display OFF */
318 if ( pXGIHWDE->jChipType == XG27 )
320 XGI_DisplayOff( pXGIHWDE, pVBInfo );
322 XGI_XG27BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* LVDS signal off */
324 temp = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ;
327 XGINew_SetRegAND( pVBInfo->P3c4 , 0x09 , ~0x80 ) ; /* DVO Off */
330 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x1F , ~0xC0 , 0xC0 ) ;
331 XGINew_SetRegOR( pVBInfo->P3c4 , 0x01 , 0x20 ) ; /* CRT Off */
333 if ( ( pXGIHWDE->jChipType == XG21 ) && ( pVBInfo->IF_DEF_LVDS == 1 ) )
335 XGI_XG21SetPanelDelay( 4,pVBInfo ) ;
336 XGI_XG21BLSignalVDD( 0x01 , 0x00, pVBInfo ) ; /* LVDS VDD off */
337 XGI_XG21SetPanelDelay( 5,pVBInfo ) ;
339 if ( ( pXGIHWDE->jChipType == XG27 ) && ( pVBInfo->IF_DEF_LVDS == 1 ) )
341 XGI_XG21SetPanelDelay( 4,pVBInfo ) ;
342 XGI_XG27BLSignalVDD( 0x01 , 0x00, pVBInfo ) ; /* LVDS VDD off */
343 XGI_XG21SetPanelDelay( 5,pVBInfo ) ;
351 XGI_LockCRT2( pXGIHWDE , pVBInfo ) ;
356 /* --------------------------------------------------------------------- */
357 /* Function : XGI_GetSenseStatus */
361 /* --------------------------------------------------------------------- */
362 void XGI_GetSenseStatus(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
364 unsigned short tempax = 0 , tempbx , tempcx , temp ,
365 P2reg0 = 0 , SenseModeNo = 0 , OutputSelect = *pVBInfo->pOutputSelect ,
367 pVBInfo->BaseAddr = (unsigned long)HwDeviceExtension->pjIOAddress ;
369 if ( pVBInfo->IF_DEF_LVDS == 1 )
371 tempax = XGINew_GetReg1( pVBInfo->P3c4 , 0x1A ) ; /* ynlai 02/27/2002 */
372 tempbx = XGINew_GetReg1( pVBInfo->P3c4 , 0x1B ) ;
373 tempax = ( ( tempax & 0xFE ) >> 1 ) | ( tempbx << 8 ) ;
374 if ( tempax == 0x00 )
375 { /* Get Panel id from DDC */
376 temp = XGINew_GetLCDDDCInfo( HwDeviceExtension, pVBInfo ) ;
379 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x39 , 0xFF , 0x01 ) ; /* set CR39 bit0="1" */
380 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x37 , 0xEF , 0x00 ) ; /* clean CR37 bit4="0" */
384 { /* LCD don't connect */
390 XGINew_GetPanelID(pVBInfo) ;
394 tempbx = ~( LCDSense | AVIDEOSense | SVIDEOSense ) ;
395 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x32 , tempbx , temp ) ;
399 if ( pVBInfo->VBInfo & SetCRT2ToHiVisionTV )
401 tempax = XGINew_GetReg1( pVBInfo->P3c4 , 0x38 ) ;
402 temp = tempax & 0x01 ;
403 tempax = XGINew_GetReg1( pVBInfo->P3c4 , 0x3A ) ;
404 temp = temp | ( tempax & 0x02 ) ;
405 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x32 , 0xA0 , temp ) ;
409 if ( XGI_BridgeIsOn( pVBInfo ) )
411 P2reg0 = XGINew_GetReg1( pVBInfo->Part2Port , 0x00 ) ;
412 if ( !XGINew_BridgeIsEnable( HwDeviceExtension, pVBInfo ) )
415 /* XGINew_SetReg1( pVBInfo->P3d4 , 0x30 , 0x41 ) ; */
416 /* XGISetModeNew( HwDeviceExtension , 0x2e ) ; // ynlai InitMode */
418 temp = XGI_SearchModeID( SenseModeNo , &ModeIdIndex, pVBInfo ) ;
419 XGI_GetVGAType( HwDeviceExtension , pVBInfo) ;
420 XGI_GetVBType( pVBInfo ) ;
421 pVBInfo->SetFlag = 0x00 ;
422 pVBInfo->ModeType = ModeVGA ;
423 pVBInfo->VBInfo = SetCRT2ToRAMDAC | LoadDACFlag | SetInSlaveMode ;
424 XGI_GetLCDInfo( 0x2e , ModeIdIndex, pVBInfo ) ;
425 XGI_GetTVInfo( 0x2e , ModeIdIndex, pVBInfo ) ;
426 XGI_EnableBridge( HwDeviceExtension, pVBInfo ) ;
427 XGI_SetCRT2Group301( SenseModeNo , HwDeviceExtension, pVBInfo ) ;
428 XGI_SetCRT2ModeRegs( 0x2e , HwDeviceExtension, pVBInfo ) ;
429 /* XGI_DisableBridge( HwDeviceExtension, pVBInfo ) ; */
430 XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x01 , 0xDF , 0x20 ) ; /* Display Off 0212 */
431 for( i = 0 ; i < 20 ; i++ )
433 XGI_LongWait(pVBInfo) ;
436 XGINew_SetReg1( pVBInfo->Part2Port , 0x00 , 0x1c ) ;
438 tempbx = *pVBInfo->pRGBSenseData ;
440 if ( !( XGINew_Is301B( pVBInfo ) ) )
442 tempbx = *pVBInfo->pRGBSenseData2 ;
446 if ( XGINew_Sense(tempbx , tempcx, pVBInfo ) )
448 if ( XGINew_Sense(tempbx , tempcx, pVBInfo ) )
450 tempax |= Monitor2Sense ;
454 if ( pVBInfo->VBType & VB_XGI301C)
456 XGINew_SetRegOR( pVBInfo->Part4Port , 0x0d , 0x04 ) ;
459 if ( XGINew_SenseHiTV( HwDeviceExtension , pVBInfo) ) /* add by kuku for Multi-adapter sense HiTV */
461 tempax |= HiTVSense ;
462 if ( ( pVBInfo->VBType & VB_XGI301C ) )
464 tempax ^= ( HiTVSense | YPbPrSense ) ;
468 if ( !( tempax & ( HiTVSense | YPbPrSense ) ) ) /* start */
471 tempbx = *pVBInfo->pYCSenseData ;
473 if ( !( XGINew_Is301B( pVBInfo ) ) )
475 tempbx=*pVBInfo->pYCSenseData2;
479 if ( XGINew_Sense(tempbx , tempcx, pVBInfo ) )
481 if ( XGINew_Sense(tempbx , tempcx, pVBInfo ) )
483 tempax |= SVIDEOSense ;
487 if ( OutputSelect & BoardTVType )
489 tempbx = *pVBInfo->pVideoSenseData ;
491 if ( !( XGINew_Is301B( pVBInfo ) ) )
493 tempbx = *pVBInfo->pVideoSenseData2 ;
497 if ( XGINew_Sense(tempbx , tempcx, pVBInfo ) )
499 if ( XGINew_Sense(tempbx , tempcx, pVBInfo ) )
501 tempax |= AVIDEOSense ;
507 if ( !( tempax & SVIDEOSense ) )
509 tempbx = *pVBInfo->pVideoSenseData ;
511 if ( !( XGINew_Is301B( pVBInfo ) ) )
513 tempbx=*pVBInfo->pVideoSenseData2;
517 if ( XGINew_Sense(tempbx , tempcx, pVBInfo ) )
519 if ( XGINew_Sense(tempbx , tempcx, pVBInfo ) )
521 tempax |= AVIDEOSense ;
528 if ( !( tempax & Monitor2Sense ) )
530 if ( XGINew_SenseLCD( HwDeviceExtension, pVBInfo ) )
537 XGINew_Sense(tempbx , tempcx, pVBInfo ) ;
539 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x32 , ~0xDF , tempax ) ;
540 XGINew_SetReg1( pVBInfo->Part2Port , 0x00 , P2reg0 ) ;
542 if ( !( P2reg0 & 0x20 ) )
544 pVBInfo->VBInfo = DisableCRT2Display ;
545 /* XGI_SetCRT2Group301( SenseModeNo , HwDeviceExtension, pVBInfo ) ; */
549 XGI_DisableBridge( HwDeviceExtension, pVBInfo ) ; /* shampoo 0226 */
555 /* --------------------------------------------------------------------- */
556 /* Function : XGINew_SenseLCD */
560 /* --------------------------------------------------------------------- */
561 unsigned short XGINew_SenseLCD(struct xgi_hw_device_info *HwDeviceExtension,
562 struct vb_device_info *pVBInfo)
564 /* unsigned short SoftSetting ; */
565 unsigned short temp ;
567 if ( ( HwDeviceExtension->jChipType >= XG20 ) || ( HwDeviceExtension->jChipType >= XG40 ) )
570 temp=XGINew_GetPanelID(pVBInfo) ;
573 temp = XGINew_GetLCDDDCInfo( HwDeviceExtension, pVBInfo ) ;
579 /* --------------------------------------------------------------------- */
580 /* Function : XGINew_GetLCDDDCInfo */
584 /* --------------------------------------------------------------------- */
585 unsigned char XGINew_GetLCDDDCInfo(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
587 unsigned short temp ;
590 if ( HwDeviceExtension->ulCRT2LCDType == LCD_UNKNOWN )
596 temp = (unsigned short)HwDeviceExtension->ulCRT2LCDType ;
597 switch( HwDeviceExtension->ulCRT2LCDType )
626 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x36 , 0xF0 , temp ) ;
632 /* --------------------------------------------------------------------- */
637 /* --------------------------------------------------------------------- */
638 unsigned char XGINew_GetPanelID(struct vb_device_info *pVBInfo)
640 unsigned short PanelTypeTable[16] = {
641 SyncNN | PanelRGB18Bit | Panel800x600 | _PanelType00,
642 SyncNN | PanelRGB18Bit | Panel1024x768 | _PanelType01,
643 SyncNN | PanelRGB18Bit | Panel800x600 | _PanelType02,
644 SyncNN | PanelRGB18Bit | Panel640x480 | _PanelType03,
645 SyncNN | PanelRGB18Bit | Panel1024x768 | _PanelType04,
646 SyncNN | PanelRGB18Bit | Panel1024x768 | _PanelType05,
647 SyncNN | PanelRGB18Bit | Panel1024x768 | _PanelType06,
648 SyncNN | PanelRGB24Bit | Panel1024x768 | _PanelType07,
649 SyncNN | PanelRGB18Bit | Panel800x600 | _PanelType08,
650 SyncNN | PanelRGB18Bit | Panel1024x768 | _PanelType09,
651 SyncNN | PanelRGB18Bit | Panel800x600 | _PanelType0A,
652 SyncNN | PanelRGB18Bit | Panel1024x768 | _PanelType0B,
653 SyncNN | PanelRGB18Bit | Panel1024x768 | _PanelType0C,
654 SyncNN | PanelRGB24Bit | Panel1024x768 | _PanelType0D,
655 SyncNN | PanelRGB18Bit | Panel1024x768 | _PanelType0E,
656 SyncNN | PanelRGB18Bit | Panel1024x768 | _PanelType0F };
657 unsigned short tempax , tempbx, temp;
658 /* unsigned short return_flag ; */
660 tempax = XGINew_GetReg1( pVBInfo->P3c4 , 0x1A ) ;
661 tempbx = tempax & 0x1E ;
668 if ( !( tempax & 0x10 ) )
670 if ( pVBInfo->IF_DEF_LVDS == 1 )
673 temp = XGINew_GetReg1( pVBInfo->P3c4 , 0x38 ) ;
681 temp = XGINew_GetReg1( pVBInfo->P3c4 , 0x39 ) ;
692 tempbx = tempbx >> 1 ;
693 temp = tempbx & 0x00F ;
694 XGINew_SetReg1( pVBInfo->P3d4 , 0x36 , temp ) ;
696 tempbx = PanelTypeTable[ tempbx ] ;
698 temp = ( tempbx & 0xFF00 ) >> 8 ;
699 XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x37 , ~( LCDSyncBit | LCDRGB18Bit ) , temp ) ;
705 /* --------------------------------------------------------------------- */
706 /* Function : XGINew_BridgeIsEnable */
710 /* --------------------------------------------------------------------- */
711 unsigned char XGINew_BridgeIsEnable(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
713 unsigned short flag ;
715 if ( XGI_BridgeIsOn( pVBInfo ) == 0 )
717 flag = XGINew_GetReg1( pVBInfo->Part1Port , 0x0 ) ;
732 /* ------------------------------------------------------ */
733 /* Function : XGINew_SenseHiTV */
737 /* ------------------------------------------------------ */
738 unsigned char XGINew_SenseHiTV(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
740 unsigned short tempbx , tempcx , temp , i , tempch;
742 tempbx = *pVBInfo->pYCSenseData2 ;
746 temp = tempbx & 0xFF ;
747 XGINew_SetReg1( pVBInfo->Part4Port , 0x11 , temp ) ;
748 temp = ( tempbx & 0xFF00 ) >> 8 ;
749 temp |= ( tempcx & 0x00FF ) ;
750 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x10 , ~0x1F , temp ) ;
752 for( i = 0 ; i < 10 ; i++ )
753 XGI_LongWait(pVBInfo) ;
755 tempch = ( tempcx & 0xFF00 ) >> 8;
756 temp = XGINew_GetReg1( pVBInfo->Part4Port , 0x03 ) ;
757 temp = temp ^ ( 0x0E ) ;
760 if ( temp != tempch )
763 tempbx = *pVBInfo->pVideoSenseData2 ;
766 temp = tempbx & 0xFF ;
767 XGINew_SetReg1( pVBInfo->Part4Port , 0x11 , temp ) ;
768 temp = ( tempbx & 0xFF00 ) >> 8 ;
769 temp |= ( tempcx & 0x00FF ) ;
770 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x10 , ~0x1F , temp ) ;
772 for( i = 0 ; i < 10 ; i++ )
773 XGI_LongWait(pVBInfo) ;
775 tempch = ( tempcx & 0xFF00 ) >> 8;
776 temp = XGINew_GetReg1( pVBInfo->Part4Port , 0x03 ) ;
777 temp = temp ^ ( 0x0E ) ;
780 if ( temp != tempch )
786 temp = tempbx & 0xFF ;
787 XGINew_SetReg1( pVBInfo->Part4Port , 0x11 , temp ) ;
788 temp = ( tempbx & 0xFF00 ) >> 8 ;
789 temp |= ( tempcx & 0x00FF ) ;
790 XGINew_SetRegANDOR( pVBInfo->Part4Port , 0x10 , ~0x1F , temp ) ;
792 for( i = 0 ; i < 10 ; i++ )
793 XGI_LongWait(pVBInfo) ;
795 tempch = ( tempcx & 0xFF00 ) >> 8;
796 temp = XGINew_GetReg1( pVBInfo->Part4Port , 0x03 ) ;
797 temp = temp ^ ( 0x0E ) ;
800 if ( temp != tempch )
810 ;-----------------------------------------------------------------------------
811 ; Description: Get Panel support
813 ; BL: Panel ID=81h for no scaler LVDS
814 ; BH: Panel enhanced Mode Count
815 ; CX: Panel H. resolution
816 ; DX: PAnel V. resolution
817 ;-----------------------------------------------------------------------------
819 void XGI_XG21Fun14Sub70(struct vb_device_info *pVBInfo, PX86_REGS pBiosArguments)
822 unsigned short ModeIdIndex;
823 unsigned short ModeNo;
825 unsigned short EModeCount;
826 unsigned short lvdstableindex;
828 lvdstableindex = XGI_GetLVDSOEMTableIndex( pVBInfo );
829 pBiosArguments->h.bl = 0x81;
830 pBiosArguments->x.cx = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHDE;
831 pBiosArguments->x.dx = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVDE;
834 pBiosArguments->x.ax = 0x0014;
835 for( ModeIdIndex = 0 ; ; ModeIdIndex ++ )
837 ModeNo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeID;
838 if ( pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeID == 0xFF )
840 pBiosArguments->h.bh = (unsigned char) EModeCount;
843 if ( !XGI_XG21CheckLVDSMode( ModeNo , ModeIdIndex, pVBInfo) )
851 ;-----------------------------------------------------------------------------
853 ; Description: Get Panel mode ID for enhanced mode
854 ; I/P : BH: EModeIndex ( which < Panel enhanced Mode Count )
857 ; CX: H. resolution of the assigned by the index
858 ; DX: V. resolution of the assigned by the index
860 ;-----------------------------------------------------------------------------
862 void XGI_XG21Fun14Sub71(struct vb_device_info *pVBInfo, PX86_REGS pBiosArguments)
865 unsigned short EModeCount;
866 unsigned short ModeIdIndex, resindex;
867 unsigned short ModeNo;
868 unsigned short EModeIndex = pBiosArguments->h.bh;
871 for( ModeIdIndex = 0 ; ; ModeIdIndex ++ )
873 ModeNo = pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeID;
874 if ( pVBInfo->EModeIDTable[ ModeIdIndex ].Ext_ModeID == 0xFF )
876 pBiosArguments->x.ax = 0x0114;
879 if ( !XGI_XG21CheckLVDSMode( ModeNo , ModeIdIndex, pVBInfo) )
883 if (EModeCount == EModeIndex)
885 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
886 pBiosArguments->h.bl = (unsigned char) ModeNo;
887 pBiosArguments->x.cx = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
888 pBiosArguments->x.dx = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
889 pBiosArguments->x.ax = 0x0014;
897 ;-----------------------------------------------------------------------------
899 ; Description: Validate Panel modes ID support
903 ; CX: H. resolution of the assigned by the index
904 ; DX: V. resolution of the assigned by the index
906 ;-----------------------------------------------------------------------------
908 void XGI_XG21Fun14Sub72(struct vb_device_info *pVBInfo, PX86_REGS pBiosArguments)
910 unsigned short ModeIdIndex, resindex;
911 unsigned short ModeNo;
914 ModeNo = pBiosArguments->h.bl ;
915 XGI_SearchModeID( ModeNo, &ModeIdIndex, pVBInfo);
916 if ( !XGI_XG21CheckLVDSMode( ModeNo , ModeIdIndex, pVBInfo) )
918 pBiosArguments->x.cx = 0;
919 pBiosArguments->x.dx = 0;
920 pBiosArguments->x.ax = 0x0114;
923 resindex = XGI_GetResInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
924 if ( ModeNo <= 0x13 )
926 pBiosArguments->x.cx = pVBInfo->StResInfo[ resindex ].HTotal ;
927 pBiosArguments->x.dx = pVBInfo->StResInfo[ resindex ].VTotal ;
931 pBiosArguments->x.cx = pVBInfo->ModeResInfo[ resindex ].HTotal ; /* xres->ax */
932 pBiosArguments->x.dx = pVBInfo->ModeResInfo[ resindex ].VTotal ; /* yres->bx */
935 pBiosArguments->x.ax = 0x0014;
940 ;-----------------------------------------------------------------------------
941 ; Description: Get Customized Panel misc. information support
943 ; to get panel horizontal timing
944 ; to get panel vertical timing
945 ; to get channel clock parameter
946 ; to get panel misc information
949 ; BL: for input Select = 0 ;
950 ; BX: *Value1 = Horizontal total
951 ; CX: *Value2 = Horizontal front porch
952 ; DX: *Value2 = Horizontal sync width
953 ; BL: for input Select = 1 ;
954 ; BX: *Value1 = Vertical total
955 ; CX: *Value2 = Vertical front porch
956 ; DX: *Value2 = Vertical sync width
957 ; BL: for input Select = 2 ;
958 ; BX: Value1 = The first CLK parameter
959 ; CX: Value2 = The second CLK parameter
960 ; BL: for input Select = 4 ;
961 ; BX[15]: *Value1 D[15] VESA V. Polarity
962 ; BX[14]: *Value1 D[14] VESA H. Polarity
963 ; BX[7]: *Value1 D[7] Panel V. Polarity
964 ; BX[6]: *Value1 D[6] Panel H. Polarity
965 ;-----------------------------------------------------------------------------
967 void XGI_XG21Fun14Sub73(struct vb_device_info *pVBInfo, PX86_REGS pBiosArguments)
969 unsigned char Select;
971 unsigned short lvdstableindex;
973 lvdstableindex = XGI_GetLVDSOEMTableIndex( pVBInfo );
974 Select = pBiosArguments->h.bl;
979 pBiosArguments->x.bx = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHT;
980 pBiosArguments->x.cx = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHFP;
981 pBiosArguments->x.dx = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSHSYNC;
984 pBiosArguments->x.bx = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVT;
985 pBiosArguments->x.cx = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVFP;
986 pBiosArguments->x.dx = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDSVSYNC;
989 pBiosArguments->x.bx = pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData1;
990 pBiosArguments->x.cx = pVBInfo->XG21_LVDSCapList[lvdstableindex].VCLKData2;
993 pBiosArguments->x.bx = pVBInfo->XG21_LVDSCapList[lvdstableindex].LVDS_Capability;
997 pBiosArguments->x.ax = 0x0014;
1001 void XGI_XG21Fun14(struct xgi_hw_device_info *pXGIHWDE, PX86_REGS pBiosArguments)
1003 struct vb_device_info VBINF;
1004 struct vb_device_info *pVBInfo = &VBINF;
1006 pVBInfo->IF_DEF_LVDS = 0 ;
1007 pVBInfo->IF_DEF_CH7005 = 0 ;
1008 pVBInfo->IF_DEF_HiVision = 1 ;
1009 pVBInfo->IF_DEF_LCDA = 1 ;
1010 pVBInfo->IF_DEF_CH7017 = 0 ;
1011 pVBInfo->IF_DEF_YPbPr = 1 ;
1012 pVBInfo->IF_DEF_CRT2Monitor = 0 ;
1013 pVBInfo->IF_DEF_VideoCapture = 0 ;
1014 pVBInfo->IF_DEF_ScaleLCD = 0 ;
1015 pVBInfo->IF_DEF_OEMUtil = 0 ;
1016 pVBInfo->IF_DEF_PWD = 0 ;
1018 InitTo330Pointer( pXGIHWDE->jChipType, pVBInfo ) ;
1019 ReadVBIOSTablData( pXGIHWDE->jChipType , pVBInfo) ;
1021 pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14 ;
1022 pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24 ;
1023 pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10 ;
1024 pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e ;
1025 pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12 ;
1026 pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a ;
1027 pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16 ;
1028 pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17 ;
1029 pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18 ;
1030 pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19 ;
1031 pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A ;
1032 pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00 ;
1033 pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04 ;
1034 pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10 ;
1035 pVBInfo->Part3Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_12 ;
1036 pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 ;
1037 pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2 ;
1039 switch(pBiosArguments->x.ax)
1042 XGI_XG21Fun14Sub70( pVBInfo , pBiosArguments ) ;
1045 XGI_XG21Fun14Sub71( pVBInfo , pBiosArguments ) ;
1048 XGI_XG21Fun14Sub72( pVBInfo , pBiosArguments ) ;
1051 XGI_XG21Fun14Sub73( pVBInfo , pBiosArguments ) ;