diff options
| author | xgi0007 <xgi0007@linux.site> | 2010-05-06 13:22:39 +0800 |
|---|---|---|
| committer | xgi0007 <xgi0007@linux.site> | 2010-05-06 13:22:39 +0800 |
| commit | 19c426c15ffcf4a95a30c011daba7c41a52c2c4d (patch) | |
| tree | cce09958d1e15946c9ab45f48045b58c70dd3eec | |
| parent | 6357c787a30c02b7d5ed8fe7429ab7e85cc57411 (diff) | |
XGI:suport ARM, add EXA, I2c EDID, Custom Modes, Bugs fixed, ...
| -rw-r--r-- | src/init.c | 24 | ||||
| -rw-r--r-- | src/init.h | 1 | ||||
| -rw-r--r-- | src/valid_mode.h | 46 | ||||
| -rw-r--r-- | src/vb_ext.c | 306 | ||||
| -rw-r--r-- | src/vb_ext.h | 4 | ||||
| -rwxr-xr-x | src/vb_i2c.c | 1893 | ||||
| -rwxr-xr-x | src/vb_i2c.h | 184 | ||||
| -rw-r--r-- | src/vb_init.c | 25 | ||||
| -rw-r--r-- | src/vb_setmode.c | 423 | ||||
| -rw-r--r-- | src/vb_struct.h | 15 | ||||
| -rw-r--r-- | src/vgatypes.h | 9 | ||||
| -rw-r--r-- | src/xgi.h | 150 | ||||
| -rw-r--r-- | src/xgi_accel.c | 1117 | ||||
| -rw-r--r-- | src/xgi_accel.h | 84 | ||||
| -rw-r--r-- | src/xgi_cursor.c | 9 | ||||
| -rw-r--r-- | src/xgi_cursor.h | 4 | ||||
| -rw-r--r-- | src/xgi_dac.c | 124 | ||||
| -rw-r--r-- | src/xgi_dga.c | 6 | ||||
| -rw-r--r-- | src/xgi_dri.c | 2 | ||||
| -rw-r--r-- | src/xgi_driver.c | 1188 | ||||
| -rwxr-xr-x | src/xgi_memcpy.c | 1305 | ||||
| -rw-r--r-- | src/xgi_opt.c | 144 | ||||
| -rw-r--r-- | src/xgi_regs.h | 28 | ||||
| -rw-r--r-- | src/xgi_setup.c | 34 | ||||
| -rw-r--r-- | src/xgi_vga.c | 8 | ||||
| -rw-r--r-- | src/xgi_video.c | 23 | ||||
| -rw-r--r-- | src/xgi_video.h | 3 | ||||
| -rw-r--r-- | src/xgi_videohw.c | 2 |
28 files changed, 6722 insertions, 439 deletions
@@ -160,6 +160,9 @@ XGI_GetModeID(ULONG VBFlags, int HDisplay, int VDisplay, break;
case 1400:
break;
+ case 1440:
+ /* if(VDisplay == 900) ModeIndex = ModeIndex_1440x900[Depth]; */
+ break;
case 1600:
if(VDisplay == 1200) ModeIndex = ModeIndex_1600x1200[Depth];
break;
@@ -904,11 +907,6 @@ XGIBIOSSetMode(VB_DEVICE_INFO *XGI_Pr, PXGI_HW_DEVICE_INFO HwInfo, BOOLEAN SetModeRet = FALSE ;
UShort HDisplay = pXGI->scrnOffset >> 3 ;
- ModeNo = XGI_CalcModeIndex(pScrn, mode, pXGI->VBFlags);
- if(!ModeNo) return FALSE;
-
- xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "Setting standard mode 0x%x\n", ModeNo);
-
#if XGI_USING_BIOS_SETMODE
PDEBUG(ErrorF("XGI_USING_BIOS_SETMODE \n"));
if ((pXGI->pVbe != NULL) && (pXGI->pVbe->pInt10 != NULL)) {
@@ -935,8 +933,10 @@ XGIBIOSSetMode(VB_DEVICE_INFO *XGI_Pr, PXGI_HW_DEVICE_INFO HwInfo, HwInfo->Vertical_ACTIVE = mode->VDisplay;
HwInfo->Interlace=FALSE;
- if(mode->type == M_T_USERDEF) /* custom mode */
+ if( (mode->type == M_T_USERDEF) || ((mode->type & M_T_CLOCK_CRTC_C) == M_T_CLOCK_CRTC_C) ) /* custom mode */
{
+ xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "Setting a customer mode %dx%d\n", mode->HDisplay, mode->VDisplay);
+
HwInfo->SpecifyTiming = TRUE;
HwInfo->Horizontal_FP = mode->HSyncStart - mode->HDisplay; /* HSyncStart - HDisplay */
HwInfo->Horizontal_BP = mode->HTotal - mode->HSyncEnd; /* HTotal - HSyncEnd */
@@ -949,6 +949,11 @@ XGIBIOSSetMode(VB_DEVICE_INFO *XGI_Pr, PXGI_HW_DEVICE_INFO HwInfo, else
{
HwInfo->SpecifyTiming = FALSE;
+
+ ModeNo = XGI_CalcModeIndex(pScrn, mode, pXGI->VBFlags);
+ if(!ModeNo) return FALSE;
+
+ xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "Setting a standard mode 0x%x\n", ModeNo);
}
/* ------------------------------------------------------------------ */
@@ -958,13 +963,18 @@ XGIBIOSSetMode(VB_DEVICE_INFO *XGI_Pr, PXGI_HW_DEVICE_INFO HwInfo, /* SetPitch: Adapt to virtual size & position */
- if (ModeNo > 0x13) {
+ if ((ModeNo > 0x13) || (mode->type == M_T_USERDEF) || ((mode->type & M_T_CLOCK_CRTC_C) == M_T_CLOCK_CRTC_C)) {
XGI_SetReg(XGI_Pr->Part1Port, 0x2f, 1); //yilin for crt2pitch it shoude modify if not colone mode
XGI_SetReg(XGI_Pr->Part1Port, 0x07, (HDisplay & 0xFF));
XGI_SetRegANDOR(XGI_Pr->Part1Port, 0x09, 0xF0, (HDisplay>>8));
+ /* Jong10052009; Set pitch with HDisplay = pXGI->scrnOffset >> 3 */
+ PDEBUG(ErrorF("scrnOffset is %d...\n", pXGI->scrnOffset));
XGI_SetReg(XGI_Pr->P3d4,0x13,(HDisplay & 0xFF));
XGI_SetRegANDOR(XGI_Pr->P3c4,0x0E,0xF0,(HDisplay>>8));
+ /*
+ XGI_SetReg(XGI_Pr->P3d4,0x13,(HDisplay & 0xFF));
+ XGI_SetRegANDOR(XGI_Pr->P3c4,0x0E,0xF0,(HDisplay>>8)); */
}
return SetModeRet;
@@ -108,6 +108,7 @@ static const USHORT ModeIndex_1280x720[] = {0x79, 0x75, 0x00, 0x78}; static const USHORT ModeIndex_1280x800[] = {0x14, 0x15, 0x00, 0x16}; static const USHORT ModeIndex_1360x768[] = {0x48, 0x4b, 0x00, 0x4e}; static const USHORT ModeIndex_1400x1050[] = {0x26, 0x27, 0x00, 0x28}; /* 315 series only */ +/* static const USHORT ModeIndex_1440x900[] = {0x26, 0x27, 0x00, 0x28}; */ /* Jong@09292009 */ static const USHORT ModeIndex_1680x1050[] = {0x17, 0x18, 0x00, 0x19}; /* 315 series only */ static const USHORT ModeIndex_1600x1200[] = {0x3c, 0x3d, 0x00, 0x66}; static const USHORT ModeIndex_1920x1440[] = {0x68, 0x69, 0x00, 0x6b}; diff --git a/src/valid_mode.h b/src/valid_mode.h index 5a6eff9..7450308 100644 --- a/src/valid_mode.h +++ b/src/valid_mode.h @@ -38,14 +38,44 @@ typedef struct _SupportMode SupportMode *XgiMode; SupportMode XG20_Mode[]= { -{640, 480, 25200}, {640, 480, 31500}, {640, 480, 36000}, {640, 480, 44900}, {640, 480, 56250}, -{800, 600, 40000}, {800, 600, 50000}, {800, 600, 49500}, {800, 600, 56300}, {800, 600, 75800}, {800, 600, 84800}, {800, 600, 109175}, -{1024, 768, 65000}, {1024, 768, 75000}, {1024, 768, 78800}, {1024, 768, 94500}, {1024, 768, 104998}, {1024, 768, 132258}, {1024, 768, 192069}, -{1152, 864, 80350}, {1152, 864, 108000}, -{1280, 960, 108000}, {1280, 960, 125999}, {1280, 960, 148500}, {1280, 960, 178992}, {1280, 960, 217325}, -{1280, 1024, 108000}, {1280, 1024, 135000}, {1280, 1024, 157500}, {1280, 1024, 190960}, {1280, 1024, 233793}, -{1600, 1200, 162000}, {1600, 1200, 175500}, {1600, 1200, 189000}, {1600, 1200, 202500}, {1600, 1200, 229500}, - +{640, 480, 25175}, +{640, 480, 31500}, +{640, 480, 36000}, +{640, 480, 44900}, +{640, 480, 56250}, +{800, 600, 40000}, +{800, 600, 50000}, +{800, 600, 49500}, +{800, 600, 56300}, +{800, 600, 75800}, +{800, 600, 84800}, +{800, 600, 109175}, +{1024, 768, 65000}, +{1024, 768, 75000}, +{1024, 768, 78750}, +{1024, 768, 94500}, +{1024, 768, 104998}, +{1024, 768, 132258}, +{1024, 768, 192069}, +{1152, 864, 80350}, +{1152, 864, 108000}, +{1280, 960, 108000}, +{1280, 960, 125999}, +{1280, 960, 148500}, +{1280, 960, 178992}, +{1280, 960, 217325}, +{1280, 1024, 108000}, +{1280, 1024, 135000}, +{1280, 1024, 157500}, +{1280, 1024, 190960}, +{1280, 1024, 233793}, +/* {1440, 900, 106470}, *//* Jong@09292009; 1440x900@60 */ +{1600, 1200, 162000}, +{1600, 1200, 175500}, +{1600, 1200, 189000}, +{1600, 1200, 202500}, +{1600, 1200, 229500}, +/* {1680, 1050, 147140}, *//* Jong@09292009; 1680x1050@60 */ {0, 0, 0} }; diff --git a/src/vb_ext.c b/src/vb_ext.c index e8a16ce..3fd50c7 100644 --- a/src/vb_ext.c +++ b/src/vb_ext.c @@ -63,6 +63,11 @@ static BOOLEAN XGINew_Sense(USHORT tempbx, USHORT tempcx, static BOOLEAN XGINew_SenseHiTV(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo); +#ifdef DEBUG
+void XGIDumpSR(ScrnInfoPtr pScrn);
+void XGIDumpCR(ScrnInfoPtr pScrn);
+#endif + /************************************************************** Dynamic Sense *************************************************************/ @@ -442,3 +447,304 @@ BOOLEAN XGINew_SenseHiTV( PXGI_HW_DEVICE_INFO HwDeviceExtension , PVB_DEVICE_INF return( 0 ) ; } } + +void XGIPowerSaving(PVB_DEVICE_INFO pVBInfo, UCHAR PowerSavingStatus)
+{
+ ErrorF("XGIPowerSaving()...Begin\n");
+
+ if(PowerSavingStatus & 0x01) /* turn off DAC1 */
+ {
+ ErrorF("Turn off DAC1...\n");
+ /* XGI_SetRegAND((XGIIOADDRESS) pVBInfo->P3c4 , ??? , ??? ) ; */ /* ??? */
+ XGI_SetRegANDOR((XGIIOADDRESS) pVBInfo->P3c4 , 0x07 , ~0x20, 0x20 ) ; /* SR07[5] : Enable DAC1 power saving mode */
+ }
+ else
+ {
+ ErrorF("Turn on DAC1...\n");
+ /* XGI_SetRegAND((XGIIOADDRESS) pVBInfo->P3c4 , ??? , ??? ) ; */
+ XGI_SetRegAND((XGIIOADDRESS) pVBInfo->P3c4 , 0x07 , ~0x20 ) ;
+ }
+
+ if(PowerSavingStatus & 0x02) /* turn off DVO */
+ {
+ ErrorF("Turn off DVO...\n");
+ XGI_SetRegAND((XGIIOADDRESS) pVBInfo->P3c4 , 0x09 , ~0x80 ) ; /* SR09[7] : Disable FP panel output */
+ XGI_SetRegAND((XGIIOADDRESS) pVBInfo->P3d4 , 0xB4 , ~0x04 ) ; /* CRB4[2] : FP power down */
+ }
+ else
+ {
+ ErrorF("Turn on DVO...\n");
+ XGI_SetRegANDOR((XGIIOADDRESS) pVBInfo->P3c4 , 0x09 , ~0x80 , 0x80 ) ;
+ XGI_SetRegANDOR((XGIIOADDRESS) pVBInfo->P3d4 , 0xB4 , ~0x04 , 0x04 ) ;
+ }
+
+ if(PowerSavingStatus & 0x04) /* turn off DAC2 */
+ {
+ ErrorF("Turn off DAC2...\n");
+ XGI_SetRegAND((XGIIOADDRESS) pVBInfo->P3c4 , 0x07 , ~0x08 ) ; /* SR07[3] : Disable mirror DAC (DAC2) */
+ XGI_SetRegANDOR((XGIIOADDRESS) pVBInfo->P3c4 , 0x40 , ~0x20, 0x20 ) ; /* SR40[5] : Enable DAC2 power saving mode */
+ }
+ else
+ {
+ ErrorF("Turn on DAC2...\n");
+ XGI_SetRegANDOR((XGIIOADDRESS) pVBInfo->P3c4 , 0x07 , ~0x08 , 0x08 ) ;
+ XGI_SetRegAND((XGIIOADDRESS) pVBInfo->P3c4 , 0x40 , ~0x20 ) ;
+ }
+
+ ErrorF("XGIPowerSaving()...End\n");
+}
+ +extern UCHAR g_PowerSavingStatus; +extern void ResetVariableFor2DRegister();
+ +/* --------------------------------------------------------------------- */
+/* Function : XGISetDPMS */
+/* Input : */
+/* Output : */
+/* Description : */
+/* --------------------------------------------------------------------- */
+VOID XGISetDPMS(ScrnInfoPtr pScrn, PVB_DEVICE_INFO pVBInfo, PXGI_HW_DEVICE_INFO pXGIHWDE , ULONG VESA_POWER_STATE )
+{
+ USHORT ModeNo, ModeIdIndex ;
+ UCHAR temp ;
+ /* VB_DEVICE_INFO VBINF; */
+ /* PVB_DEVICE_INFO pVBInfo = pXGI->XGI_Pr */ /* &VBINF */;
+
+ ErrorF("XGISetDPMS(VESA_POWER_STATE = 0x%x)...\n", VESA_POWER_STATE);
+
+ InitTo330Pointer( pXGIHWDE->jChipType, pVBInfo ) ;
+ ReadVBIOSTablData( pXGIHWDE->jChipType , pVBInfo) ;
+
+ XGIInitMiscVBInfo(pXGIHWDE, pVBInfo);
+
+ /* Jong@08212009; ignored at present */
+ /*
+ if ( pVBInfo->IF_DEF_CH7007 == 0 )
+ {
+ XGINew_SetModeScratch ( pXGIHWDE , pVBInfo ) ;
+ } */
+
+ XGI_SetReg((XGIIOADDRESS) pVBInfo->P3c4 , 0x05 , 0x86 ) ; /* 1.Openkey */
+ XGI_UnLockCRT2( pXGIHWDE , pVBInfo) ;
+ ModeNo = XGI_GetReg((XGIIOADDRESS) pVBInfo->P3d4 , 0x34 ) ;
+ XGI_SearchModeID(pVBInfo->SModeIDTable, pVBInfo->EModeIDTable, 0x11, &ModeNo , &ModeIdIndex);
+ /* XGI_SearchModeID( ModeNo , &ModeIdIndex, pVBInfo ) ; */
+
+ /* Jong@08212009; ignored */
+ /*
+ if ( ( pXGIHWDE->ujVBChipID == VB_CHIP_301 ) || ( pXGIHWDE->ujVBChipID == VB_CHIP_302 ) || ( pVBInfo->IF_DEF_CH7007 == 1 ))
+ {
+ XGI_GetVBType( pVBInfo ) ;
+ XGI_GetVBInfo( ModeNo , ModeIdIndex , pXGIHWDE, pVBInfo ) ;
+ XGI_GetTVInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
+ XGI_GetLCDInfo( ModeNo , ModeIdIndex, pVBInfo ) ;
+ }
+
+ if ( VESA_POWER_STATE == 0x00000400 )
+ XGINew_SetReg1( pVBInfo->Part4Port , 0x31 , ( UCHAR )( XGINew_GetReg1( pVBInfo->Part4Port , 0x31 ) & 0xFE ) ) ;
+ else
+ XGINew_SetReg1( pVBInfo->Part4Port , 0x31 , ( UCHAR )( XGINew_GetReg1( pVBInfo->Part4Port , 0x31 ) | 0x01 ) ) ;
+ */
+
+ temp = ( UCHAR )XGI_GetReg((XGIIOADDRESS) pVBInfo->P3c4 , 0x1f ) ;
+ temp &= 0x3f ;
+ switch ( VESA_POWER_STATE )
+ {
+ case 0x00000000 : /* on */
+ /* Jong@08212009; not support */
+ /*
+ if ( ( pXGIHWDE->ujVBChipID == VB_CHIP_301 ) || ( pXGIHWDE->ujVBChipID == VB_CHIP_302 ) )
+ {
+ XGINew_SetReg1( pVBInfo->P3c4 , 0x1f , ( UCHAR )( temp | 0x00 ) ) ;
+ XGI_EnableBridge( pXGIHWDE, pVBInfo ) ;
+ }
+ else */
+ {
+ /* Handle LVDS */
+ if ( pVBInfo->IF_DEF_LVDS == 1 )
+ {
+ if ( pXGIHWDE->jChipType == XG21 )
+ {
+ XGI_XG21BLSignalVDD( 0x01 , 0x01, pVBInfo ) ; /* LVDS VDD on */
+ XGI_XG21SetPanelDelay( 2,pVBInfo ) ;
+ }
+
+ if ( pXGIHWDE->jChipType == XG27 )
+ {
+ XGI_XG27BLSignalVDD( 0x01 , 0x01, pVBInfo ) ; /* LVDS VDD on */
+ XGI_XG21SetPanelDelay( 2,pVBInfo ) ;
+ }
+ }
+
+ XGI_SetRegANDOR( (XGIIOADDRESS) pVBInfo->P3c4 , 0x1F , ~0xC0 , 0x00 ) ; /* VESA DPMS status on */
+ XGI_SetRegAND( (XGIIOADDRESS)pVBInfo->P3c4 , 0x01 , ~0x20 ) ; /* enable memory retrieve for CRTC */
+
+ if ( pXGIHWDE->jChipType == XG21 )
+ {
+ temp = XGI_GetReg((XGIIOADDRESS) pVBInfo->P3d4 , 0x38 ) ;
+ if ( temp & 0xE0 )
+ {
+ XGI_SetRegANDOR((XGIIOADDRESS) pVBInfo->P3c4 , 0x09 , ~0x80 , 0x80 ) ; /* DVO ON */
+ XGI_SetXG21FPBits( pVBInfo );
+ XGI_SetRegAND((XGIIOADDRESS) pVBInfo->P3d4 , 0x4A , ~0x20 ) ; /* Enable write GPIOF */
+ /*XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x48 , ~0x20 , 0x20 ) ;*/ /* LCD Display ON */
+ }
+
+ XGI_XG21BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* LVDS signal on */
+ XGI_DisplayOn( pXGIHWDE, pVBInfo );
+ }
+
+ if ( pXGIHWDE->jChipType == XG27 )
+ {
+ temp = XGI_GetReg((XGIIOADDRESS) pVBInfo->P3d4 , 0x38 ) ;
+ if ( temp & 0xE0 )
+ {
+ XGI_SetRegANDOR((XGIIOADDRESS) pVBInfo->P3c4 , 0x09 , ~0x80 , 0x80 ) ; /* DVO ON */
+ XGI_SetXG27FPBits( pVBInfo );
+ XGI_SetRegAND((XGIIOADDRESS) pVBInfo->P3d4 , 0x4A , ~0x20 ) ; /* Enable write GPIOF */
+ /*XGINew_SetRegANDOR( pVBInfo->P3d4 , 0x48 , ~0x20 , 0x20 ) ;*/ /* LCD Display ON */
+ }
+ XGI_XG27BLSignalVDD( 0x20 , 0x20, pVBInfo ) ; /* LVDS signal on */
+
+ XGIPowerSaving(pVBInfo, g_PowerSavingStatus);
+
+ XGI_DisplayOn( pXGIHWDE, pVBInfo );
+ }
+ }
+
+ /* Jong@08252009; reset variables of register */
+ ResetVariableFor2DRegister();
+
+ /* Turn on 2D engine */
+ XGI_SetRegANDOR((XGIIOADDRESS) pVBInfo->P3c4 , 0x1E , ~0x40 , 0x40 ) ; /* 2D ON */
+
+ break ;
+ case 0x00000100: /* standby */
+ PDEBUG(ErrorF("Standby...dump regs...0\n"));
+ PDEBUG(XGIDumpSR(pScrn));
+ PDEBUG(XGIDumpCR(pScrn));
+
+ if ( pXGIHWDE->jChipType >= XG21 )
+ {
+ XGI_DisplayOff( pXGIHWDE, pVBInfo );
+ }
+
+ PDEBUG(ErrorF("Standby...dump regs...1\n"));
+ PDEBUG(XGIDumpSR(pScrn));
+ PDEBUG(XGIDumpCR(pScrn));
+
+ if ( pXGIHWDE->jChipType == XG21 )
+ {
+ XGIPowerSaving(pVBInfo, 0x03); /* Turn off DAC1, DVO */
+ }
+
+ if ( pXGIHWDE->jChipType == XG27 )
+ {
+ XGIPowerSaving(pVBInfo, 0x07); /* Turn off DAC1, DAC2, DVO */
+ }
+
+ XGI_SetReg((XGIIOADDRESS) pVBInfo->P3c4 , 0x1f , ( UCHAR )( temp | 0x40 ) ) ;
+
+ /* Turn off 2D engine */
+ XGI_SetRegAND((XGIIOADDRESS) pVBInfo->P3c4 , 0x1E , ~0x40) ; /* 2D OFF */
+
+ PDEBUG(ErrorF("Standby...dump regs...2\n"));
+ PDEBUG(XGIDumpSR(pScrn));
+ PDEBUG(XGIDumpCR(pScrn));
+ break ;
+ case 0x00000200: /* suspend */
+ if ( pXGIHWDE->jChipType == XG21 )
+ {
+ XGI_DisplayOff( pXGIHWDE, pVBInfo );
+ XGI_XG21BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* LVDS signal off */
+ XGIPowerSaving(pVBInfo, 0x03); /* Turn off DAC1, DVO */
+ }
+
+ if ( pXGIHWDE->jChipType == XG27 )
+ {
+ XGI_DisplayOff( pXGIHWDE, pVBInfo );
+ XGI_XG27BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* LVDS signal off */
+ XGIPowerSaving(pVBInfo, 0x07); /* Turn off DAC1, DAC2, DVO */
+ }
+
+ XGI_SetReg((XGIIOADDRESS) pVBInfo->P3c4 , 0x1f , ( UCHAR )( temp | 0x80 ) ) ;
+
+ /* Turn off 2D engine */
+ XGI_SetRegAND((XGIIOADDRESS) pVBInfo->P3c4 , 0x1E , ~0x40) ; /* 2D OFF */
+
+ break ;
+ case 0x00000400: /* off */
+ /* Jong@08212009; not support */
+ /*
+ if ( (pXGIHWDE->ujVBChipID == VB_CHIP_301 ) || ( pXGIHWDE->ujVBChipID == VB_CHIP_302 ) )
+ {
+ XGINew_SetReg1( pVBInfo->P3c4 , 0x1f , ( UCHAR )( temp | 0xc0 ) ) ;
+ XGI_DisableBridge( pXGIHWDE, pVBInfo ) ;
+ }
+ else */
+ {
+ if ( pXGIHWDE->jChipType == XG21 )
+ {
+ XGI_DisplayOff( pXGIHWDE, pVBInfo );
+
+ XGI_XG21BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* LVDS signal off */
+
+ temp = XGI_GetReg((XGIIOADDRESS) pVBInfo->P3d4 , 0x38 ) ;
+
+ if ( temp & 0xE0 )
+ {
+ XGI_SetRegAND((XGIIOADDRESS) pVBInfo->P3c4 , 0x09 , ~0x80 ) ; /* DVO Off */
+ XGI_SetRegAND((XGIIOADDRESS) pVBInfo->P3d4 , 0x4A , ~0x20 ) ; /* Enable write GPIOF */
+ /*XGINew_SetRegAND( pVBInfo->P3d4 , 0x48 , ~0x20 ) ;*/ /* LCD Display OFF */
+ }
+
+ XGIPowerSaving(pVBInfo, 0x03); /* Turn off DAC1, DVO */
+
+ }
+
+ if ( pXGIHWDE->jChipType == XG27 )
+ {
+ XGI_DisplayOff( pXGIHWDE, pVBInfo );
+
+ XGI_XG27BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* LVDS signal off */
+
+ temp = XGI_GetReg((XGIIOADDRESS) pVBInfo->P3d4 , 0x38 ) ;
+
+ if ( temp & 0xE0 )
+ {
+ XGI_SetRegAND((XGIIOADDRESS) pVBInfo->P3c4 , 0x09 , ~0x80 ) ; /* DVO Off */
+ }
+
+ XGIPowerSaving(pVBInfo, 0x07); /* Turn off DAC1, DAC2, DVO */
+ }
+
+ XGI_SetRegANDOR((XGIIOADDRESS) pVBInfo->P3c4 , 0x1F , ~0xC0 , 0xC0 ) ;
+ XGI_SetRegOR((XGIIOADDRESS) pVBInfo->P3c4 , 0x01 , 0x20 ) ; /* CRT Off */
+
+ if ( ( pXGIHWDE->jChipType == XG21 ) && ( pVBInfo->IF_DEF_LVDS == 1 ) )
+ {
+ XGI_XG21SetPanelDelay( 4,pVBInfo ) ;
+ XGI_XG21BLSignalVDD( 0x01 , 0x00, pVBInfo ) ; /* LVDS VDD off */
+ XGI_XG21SetPanelDelay( 5,pVBInfo ) ;
+ }
+
+ if ( ( pXGIHWDE->jChipType == XG27 ) && ( pVBInfo->IF_DEF_LVDS == 1 ) )
+ {
+ XGI_XG21SetPanelDelay( 4,pVBInfo ) ;
+ XGI_XG27BLSignalVDD( 0x01 , 0x00, pVBInfo ) ; /* LVDS VDD off */
+ XGI_XG21SetPanelDelay( 5,pVBInfo ) ;
+ }
+ }
+
+ /* Turn off 2D engine */
+ XGI_SetRegAND((XGIIOADDRESS) pVBInfo->P3c4 , 0x1E , ~0x40) ; /* 2D OFF */
+
+ break ;
+
+ default:
+ ErrorF("XGISetDPMS()-invalid power status!\n");
+ break ;
+ }
+
+ XGI_LockCRT2( pXGIHWDE , pVBInfo ) ;
+}
diff --git a/src/vb_ext.h b/src/vb_ext.h index 9aaf447..33067f3 100644 --- a/src/vb_ext.h +++ b/src/vb_ext.h @@ -27,6 +27,8 @@ #ifndef _VBEXT_ #define _VBEXT_ +#include "xf86.h" /* Jong@08252009; for ScrnInfoPtr */
+ /* Jong 10/04/2007; merge code */ struct DWORDREGS { ULONG Eax, Ebx, Ecx, Edx, Esi, Edi, Ebp; @@ -53,6 +55,8 @@ extern void XGI_GetSenseStatus(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo); /* Jong 10/04/2007; merge code */ +extern void XGIInitMiscVBInfo(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo); /* Jong@08212009 */
+extern void XGISetDPMS(ScrnInfoPtr pScrn, PVB_DEVICE_INFO pVBInfo, PXGI_HW_DEVICE_INFO pXGIHWDE , ULONG VESA_POWER_STATE ) ; /* Jong@08212009 */
extern void XGINew_SetModeScratch ( PXGI_HW_DEVICE_INFO HwDeviceExtension , PVB_DEVICE_INFO pVBInfo ) ; extern void ReadVBIOSTablData( UCHAR ChipType , PVB_DEVICE_INFO pVBInfo); extern USHORT XGINew_SenseLCD(PXGI_HW_DEVICE_INFO,PVB_DEVICE_INFO pVBInfo); diff --git a/src/vb_i2c.c b/src/vb_i2c.c new file mode 100755 index 0000000..3dfc641 --- /dev/null +++ b/src/vb_i2c.c @@ -0,0 +1,1893 @@ +/* Jong 03/12/2009; added for supporting Xorg 7.0 */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "osdef.h"
+#include "vgatypes.h"
+/* #include "vb_util.h" */ /* Jong@08032009 */
+#include "vb_def.h"
+
+#ifdef WIN2000
+#include <dderror.h>
+#include <devioctl.h>
+#include <miniport.h>
+#include <ntddvdeo.h>
+#include <video.h>
+#include "xgiv.h"
+#include "dd_i2c.h"
+#include "tools.h"
+#endif /* WIN2000 */
+
+#ifdef LINUX_XF86
+#include "xf86.h"
+#include "xf86PciInfo.h"
+#include "xgi.h"
+#include "xgi_regs.h"
+#include "vb_i2c.h"
+#endif
+
+#ifdef LINUX_KERNEL
+#include <linux/version.h>
+#include <asm/io.h>
+#include <linux/types.h>
+#include "vb_i2c.h"
+
+/* Jong@08052009 */
+/* #include <linux/delay.h> */ /* udelay */
+
+#include "XGIfb.h"
+
+#endif
+
+
+
+/*char I2CAccessBuffer(PXGI_HW_DEVICE_INFO pHWDE, PI2CControl I2CCntl, ULONG DevAddr, ULONG Offset, PUCHAR pBuffer, ULONG ulSize); */
+char vGetEDIDExtensionBlocks(PXGI_HW_DEVICE_INFO pHWDE, PI2CControl pI2C, PUCHAR pjBuffer, ULONG ulBufferSize);
+char vGetEnhancedEDIDBlock(PXGI_HW_DEVICE_INFO pHWDE, PI2CControl pI2C, ULONG ulBlockID, ULONG ulBlockTag, PUCHAR pjBuffer, ULONG ulBufferSize);
+
+char I2COpen (PXGI_HW_DEVICE_INFO pHWDE,ULONG ulI2CEnable, ULONG ulChannelID, PI2CControl pI2CControl);
+char I2CAccess(PXGI_HW_DEVICE_INFO pHWDE, PI2CControl pI2CControl);
+BOOLEAN I2CNull( PXGI_HW_DEVICE_INFO pHWDE, PI2CControl pI2CControl);
+BOOLEAN I2CRead(PXGI_HW_DEVICE_INFO pHWDE, PI2CControl pI2CControl);
+BOOLEAN I2CWrite(PXGI_HW_DEVICE_INFO pHWDE, PI2CControl pI2CControl);
+BOOLEAN ResetI2C(PXGI_HW_DEVICE_INFO pHWDE, PI2CControl pI2CControl);
+BOOLEAN I2CRead(PXGI_HW_DEVICE_INFO pHWDE,PI2CControl pI2CControl);
+BOOLEAN I2CWrite(PXGI_HW_DEVICE_INFO pHWDE, PI2CControl pI2CControl);
+BOOLEAN ResetI2C(PXGI_HW_DEVICE_INFO pHWDE, PI2CControl pI2CControl);
+BOOLEAN Ack (PXGI_HW_DEVICE_INFO pHWDE, bool fPut);
+BOOLEAN NoAck(PXGI_HW_DEVICE_INFO pHWDE);
+BOOLEAN Start( PXGI_HW_DEVICE_INFO pHWDE);
+BOOLEAN Stop(PXGI_HW_DEVICE_INFO pHWDE);
+BOOLEAN WriteUCHARI2C(PXGI_HW_DEVICE_INFO pHWDE, UCHAR cData);
+BOOLEAN ReadUCHARI2C(PXGI_HW_DEVICE_INFO pHWDE, PUCHAR pBuffer);
+UCHAR ReverseUCHAR(UCHAR data);
+
+VOID vWriteClockLineDVI(PXGI_HW_DEVICE_INFO pHWDE, UCHAR data);
+VOID vWriteDataLineDVI(PXGI_HW_DEVICE_INFO pHWDE, UCHAR data);
+BOOLEAN bReadClockLineDVI(PXGI_HW_DEVICE_INFO pHWDE);
+BOOLEAN bReadDataLineDVI(PXGI_HW_DEVICE_INFO pHWDE);
+
+BOOLEAN bEDIDCheckSum(PUCHAR pjEDIDBuf,ULONG ulBufSize);
+
+VOID vWriteClockLineCRT(PXGI_HW_DEVICE_INFO pHWDE, UCHAR data);
+VOID vWriteDataLineCRT(PXGI_HW_DEVICE_INFO pHWDE, UCHAR data);
+BOOLEAN bReadClockLineCRT(PXGI_HW_DEVICE_INFO pHWDE);
+BOOLEAN bReadDataLineCRT(PXGI_HW_DEVICE_INFO pHWDE);
+
+/* Jong@08102009 */
+VOID vWriteClockLineFCNT(PXGI_HW_DEVICE_INFO pHWDE, UCHAR data);
+VOID vWriteDataLineFCNT(PXGI_HW_DEVICE_INFO pHWDE, UCHAR data);
+BOOLEAN bReadClockLineFCNT(PXGI_HW_DEVICE_INFO pHWDE);
+BOOLEAN bReadDataLineFCNT(PXGI_HW_DEVICE_INFO pHWDE);
+
+/* #define CRT_I2C */
+VOID vWriteClockLine(PXGI_HW_DEVICE_INFO pHWDE, UCHAR data);
+VOID vWriteDataLine(PXGI_HW_DEVICE_INFO pHWDE, UCHAR data);
+BOOLEAN bReadClockLine(PXGI_HW_DEVICE_INFO pHWDE);
+BOOLEAN bReadDataLine(PXGI_HW_DEVICE_INFO pHWDE);
+
+/* Jong@08052009 */
+extern UCHAR XGI_GetRegByte(XGIIOADDRESS port);
+
+/* Jong@08052009 */
+void I2C_DelayUS(ULONG MicroSeconds)
+{
+ ErrorF("");
+ /* udelay(MicroSeconds); */
+}
+
+
+typedef enum _I2C_ACCESS_CMD
+{
+ I2C_WRITE = 0,
+ I2C_READ
+/* Jong 08/18/2008; for XFree86 */
+ /* WRITE = 0,
+ READ */
+} I2C_ACCESS_CMD;
+
+/* For XG21 */
+
+#define ENABLE_GPIOA 0x01
+#define ENABLE_GPIOB 0x02
+#define ENABLE_GPIOC 0x04
+VOID
+EnableGPIOA(
+PUCHAR pjIOPort, I2C_ACCESS_CMD CmdType)
+{
+ PDEBUGI2C(ErrorF("EnableGPIOA()-pjIOPort=0x%x...\n", pjIOPort));
+
+ UCHAR ujCR4A = XGI_GetReg(pjIOPort, IND_CR4A_GPIO_REG_III);
+
+ if (CmdType == I2C_WRITE)
+ {
+ ujCR4A &= ~ENABLE_GPIOA;
+ }
+ else
+ {
+ ujCR4A |= ENABLE_GPIOA;
+ }
+
+ XGI_SetReg(pjIOPort, IND_CR4A_GPIO_REG_III, ujCR4A);
+}
+
+VOID
+EnableGPIOB(
+PUCHAR pjIOPort, I2C_ACCESS_CMD CmdType)
+{
+ UCHAR ujCR4A = XGI_GetReg(pjIOPort, IND_CR4A_GPIO_REG_III);
+
+ if (CmdType == I2C_WRITE)
+ {
+ ujCR4A &= ~ENABLE_GPIOB;
+ }
+ else
+ {
+ ujCR4A |= ENABLE_GPIOB;
+ }
+
+ XGI_SetReg(pjIOPort, IND_CR4A_GPIO_REG_III, ujCR4A);
+}
+
+VOID
+EnableGPIOC(
+PUCHAR pjIOPort, I2C_ACCESS_CMD CmdType)
+{
+ UCHAR ujCR4A = XGI_GetReg(pjIOPort, IND_CR4A_GPIO_REG_III);
+
+ if (CmdType == I2C_WRITE)
+ {
+ ujCR4A &= ~ENABLE_GPIOC;
+ }
+ else
+ {
+ ujCR4A |= ENABLE_GPIOC;
+ }
+
+ XGI_SetReg(pjIOPort, IND_CR4A_GPIO_REG_III, ujCR4A);
+}
+
+
+
+
+/**
+* Function: getGPIORWTranser()
+*
+* Description: This function is used based on Z9. Because of wrongly wired deployment by HW
+* the CR4A and CR48 for GPIO pins have reverse sequence. For example,
+* D[7:0] for read function is ordered as GPIOA to GPIOH, but D[7:0] for read
+* is as GPIOH~GPIOA
+*/
+UCHAR
+getGPIORWTransfer(
+UCHAR ujDate)
+{
+ UCHAR ujRet = 0;
+ UCHAR i = 0;
+
+ for (i=0; i<8; i++)
+ {
+ ujRet = ujRet << 1;
+ ujRet |= GETBITS(ujDate >> i, 0:0);
+ }
+
+ return ujRet;
+}
+
+
+
+char I2CAccessBuffer(PXGI_HW_DEVICE_INFO pHWDE, PI2CControl pI2CControl, ULONG ulDevAddr,
+ ULONG ulOffset, PUCHAR pBuffer,ULONG ulSize)
+{
+
+ I2CControl I2C;
+ ULONG i;
+
+ if ((ulSize == 0) || (pBuffer == NULL)) {
+ return -1;
+ }
+ if (ulDevAddr & 1) {
+ return -1;
+ }
+ if ((ulDevAddr > 0xFF) || (ulOffset > 0xFF)) {
+ return -1;
+ }
+
+ I2C.Command = pI2CControl->Command;
+ I2C.dwCookie = pI2CControl->dwCookie;
+ I2C.Data = pI2CControl->Data;
+ I2C. Flags = pI2CControl->Flags;
+ I2C.Status = pI2CControl->Status;
+ I2C.ClockRate = pI2CControl->ClockRate;
+ switch (pI2CControl->Command) {
+ case I2C_COMMAND_READ:
+ /* Reset I2C Bus */
+ I2C.Command = I2C_COMMAND_RESET;
+ I2CAccess(pHWDE, &I2C);
+ if (I2C.Status != I2C_STATUS_NOERROR) {
+ pI2CControl->Status = I2C.Status;
+ break;
+ }
+
+ /* Write Device Address */
+ I2C.Command = I2C_COMMAND_WRITE;
+ I2C.Flags = I2C_FLAGS_START | I2C_FLAGS_ACK;
+ I2C.Data = (UCHAR)ulDevAddr;
+ I2CAccess(pHWDE, &I2C);
+ if (I2C.Status != I2C_STATUS_NOERROR) {
+ pI2CControl->Status = I2C.Status;
+ break;
+ }
+
+ /* Write Register Offset */
+ I2C.Command = I2C_COMMAND_WRITE;
+ I2C.Flags = I2C_FLAGS_ACK | I2C_FLAGS_STOP;
+ I2C.Data = (UCHAR)ulOffset;
+ I2CAccess(pHWDE, &I2C);
+ if (I2C.Status != I2C_STATUS_NOERROR) {
+ pI2CControl->Status = I2C.Status;
+ break;
+ }
+
+ /* Write Device Read Address */
+ I2C.Command = I2C_COMMAND_WRITE;
+ I2C.Flags = I2C_FLAGS_START | I2C_FLAGS_ACK;
+ I2C.Data = (UCHAR)ulDevAddr + 1;
+ I2CAccess(pHWDE, &I2C);
+ if (I2C.Status != I2C_STATUS_NOERROR) {
+ pI2CControl->Status = I2C.Status;
+ break;
+ }
+
+ /* Read Data */
+ for (i=0; i< ulSize; i++) {
+ I2C.Command = I2C_COMMAND_READ;
+ I2C.Flags = I2C_FLAGS_ACK;
+ if (i == ulSize - 1) { /* Read Last UCHAR */
+ I2C.Flags |= I2C_FLAGS_STOP;
+ }
+ I2CAccess(pHWDE, &I2C);
+ if (I2C.Status != I2C_STATUS_NOERROR) {
+ pI2CControl->Status = I2C.Status;
+ break;
+ }
+ *pBuffer = I2C.Data;
+ pBuffer++;
+ }
+ pI2CControl->Status = I2C.Status;
+ break;
+
+ case I2C_COMMAND_WRITE:
+ /* Reset I2C Bus */
+ I2C.Command = I2C_COMMAND_RESET;
+ I2CAccess(pHWDE, &I2C);
+ if (I2C.Status != I2C_STATUS_NOERROR) {
+ pI2CControl->Status = I2C.Status;
+ break;
+ }
+
+ /* Write Device Address */
+ I2C.Command = I2C_COMMAND_WRITE;
+ I2C.Flags = I2C_FLAGS_START | I2C_FLAGS_ACK;
+ I2C.Data = (UCHAR)ulDevAddr;
+ I2CAccess(pHWDE, &I2C);
+ if (I2C.Status != I2C_STATUS_NOERROR) {
+ pI2CControl->Status = I2C.Status;
+ break;
+ }
+
+ /* Write Register Offset */
+ I2C.Command = I2C_COMMAND_WRITE;
+ I2C.Flags = I2C_FLAGS_ACK;
+ I2C.Data = (UCHAR)ulOffset;
+ I2CAccess(pHWDE, &I2C);
+ if (I2C.Status != I2C_STATUS_NOERROR) {
+ pI2CControl->Status = I2C.Status;
+ break;
+ }
+
+ /* Write Data */
+ for (i=0; i< ulSize; i++) {
+ I2C.Command = I2C_COMMAND_WRITE;
+ I2C.Flags = I2C_FLAGS_ACK;
+ if (i == ulSize - 1) { /* Read Last UCHAR */
+ I2C.Flags |= I2C_FLAGS_STOP;
+ }
+ I2C.Data = *pBuffer;
+ I2CAccess(pHWDE, &I2C);
+ if (I2C.Status != I2C_STATUS_NOERROR) {
+ pI2CControl->Status = I2C.Status;
+ break;
+ }
+ pBuffer++;
+ }
+ pI2CControl->Status = I2C.Status;
+ break;
+ }
+
+ if (pI2CControl->Status == I2C_STATUS_NOERROR)
+ {
+ return 0;
+ }
+ else
+ {
+ return -1;
+ }
+}
+
+
+/*************************************************************************
+// char vGetEDIDExtensionBlocks
+//
+// Routine Description:
+// Reads the extension part behind a 128KB block of EDID which is in 1.3
+// format. The extension part can be distributed into 128KB-blocks.
+//
+// Arguments:
+// pHWDE - Hardware extension object pointer
+// pI2C - I2C pointer
+// pjBuffer - EDID Buffer
+// ulBufferSize - Buffer size
+//
+//
+// Return Value:
+// Status of returning EDID.
+// NO_ERROR - success
+// ERROR_INVALID_PARAMETER - failed
+//
+****************************************************************************/
+char vGetEDIDExtensionBlocks(
+ PXGI_HW_DEVICE_INFO pHWDE,
+ PI2CControl pI2C,
+ PUCHAR pjBuffer,
+ ULONG ulBufferSize)
+{
+ char status;
+ ULONG ulBlockTag;
+ ULONG i;
+ PUCHAR pBlockMap;
+
+
+ if ((ulBufferSize < 128) || (pjBuffer == NULL))
+ {
+ return -1;
+ }
+
+ pI2C->Command = I2C_COMMAND_READ;
+ status = I2CAccessBuffer(pHWDE, pI2C, 0xA0, 128, pjBuffer, 128);
+ if ((status != 0) || (pI2C->Status != I2C_STATUS_NOERROR))
+ {
+ return status;
+ }
+
+ if (bEDIDCheckSum(pjBuffer, 128) != 0) {
+ return -1;
+ }
+
+ if (*pjBuffer == 0xF0)
+ { /* A Block Map, we should read other extension blocks*/
+ pBlockMap = pjBuffer;
+ for (i=1; i<=126; i++)
+ {
+ ulBlockTag = *(pBlockMap + i);
+ if (ulBlockTag)
+ {
+ pjBuffer += 128;
+ ulBufferSize -= 128;
+ status = vGetEnhancedEDIDBlock(pHWDE, pI2C, i+1, ulBlockTag, pjBuffer, ulBufferSize);
+ if ((status != 0) || (pI2C->Status != I2C_STATUS_NOERROR))
+ {
+ return -1;
+ }
+ }
+ else
+ {
+ if (i > 1)
+ {
+ return 0; /* All Extension blocks must be sequential, no holes allowed. (VESA E-EDID)*/
+ }
+ else
+ {
+ return -1;
+ }
+ }
+ }
+ /* We should read block # 128 */
+ pjBuffer += 128;
+ ulBufferSize -= 128;
+ ulBlockTag = 0xF0;
+ status = vGetEnhancedEDIDBlock(pHWDE, pI2C, 128, ulBlockTag, pjBuffer, ulBufferSize);
+ if ((status != 0) || (pI2C->Status != I2C_STATUS_NOERROR))
+ {
+ return 0; /* Monitor may has only 128 blocks (0~127) */
+ }
+
+ pBlockMap = pjBuffer;
+ for (i=1; i<=126; i++)
+ { /* Read Block # 128 ~ 254 */
+ ulBlockTag = *(pBlockMap + i);
+ if (ulBlockTag)
+ {
+ pjBuffer += 128;
+ ulBufferSize -= 128;
+ status = vGetEnhancedEDIDBlock(pHWDE, pI2C, i+128, ulBlockTag, pjBuffer, ulBufferSize);
+ if ((status != 0) || (pI2C->Status != I2C_STATUS_NOERROR))
+ {
+ return -1;
+ }
+ }
+ else
+ {
+ if (i > 1)
+ {
+ return 0; /* All Extension blocks must be sequential, no holes allowed. (VESA E-EDID) */
+ }
+ else
+ {
+ return -1;
+ }
+ }
+ }
+ }
+
+ return 0;
+}
+
+/*************************************************************************
+// char vGetEnhancedEDIDBlock
+//
+// Routine Description:
+// Get the EDID which is in Enhanced-EDID format via I2C. The parse-in block
+// tag(ulBlockTag) and the first UCHAR of the retrieved buffer should be identical.
+// Returns error when they are not, otherwise return NO_ERROR.
+//
+// Arguments:
+// pHWDE - Hardware extension object pointer
+// pI2C - I2C pointer
+// ulBlockID - Block ID
+// ulBlockTag - Block Tag
+// pjBuffer - EDID Buffer
+// ulBufferSize - Buffer size
+//
+//
+// Return Value:
+// Status of returning EDID.
+// NO_ERROR - success
+// ERROR_INVALID_PARAMETER - failed
+//
+****************************************************************************/
+char vGetEnhancedEDIDBlock(
+ PXGI_HW_DEVICE_INFO pHWDE,
+ PI2CControl pI2C,
+ ULONG ulBlockID,
+ ULONG ulBlockTag,
+ PUCHAR pjBuffer,
+ ULONG ulBufferSize)
+{
+ ULONG ulOffset, SegmentID;
+ char status;
+
+ if ((ulBufferSize < 128) || (pjBuffer == NULL))
+ {
+ return -1;
+ }
+
+ SegmentID = ulBlockID / 2;
+ ulOffset = (ulBlockID % 2) * 128;
+
+ pI2C->Command = I2C_COMMAND_WRITE;
+ status = I2CAccessBuffer(pHWDE, pI2C, 0x60, 0, (PUCHAR)&SegmentID, 1);
+ if ((status == NO_ERROR) && (pI2C->Status == I2C_STATUS_NOERROR))
+ {
+ pI2C->Command = I2C_COMMAND_READ;
+ status = I2CAccessBuffer(pHWDE, pI2C, 0xA0, ulOffset, pjBuffer, 128);
+ if ((status == 0) && (pI2C->Status == I2C_STATUS_NOERROR))
+ {
+ if (*pjBuffer != (UCHAR)ulBlockTag)
+ {
+ return -1;
+ }
+
+ if (bEDIDCheckSum(pjBuffer, 128) != 0)
+ {
+ return -1;
+ }
+ }
+ else
+ {
+ return ERROR_INVALID_PARAMETER;
+ }
+ }
+ else
+ {
+ return ERROR_INVALID_PARAMETER;
+ }
+
+
+ return NO_ERROR;
+}
+char I2COpen (PXGI_HW_DEVICE_INFO pHWDE, ULONG ulI2CEnable, ULONG ulChannelID, PI2CControl pI2CControl)
+{
+/*
+// printk("\nI2COpen(%d) : Channel ID = %d\n", ulI2CEnable, ulChannelID);
+ // we need to determine the Context area for each command we receive
+ // i.e. which hardware I2C bus is the command for.
+ // this is unimplemented here!
+*/
+ if (ulChannelID >= MAX_I2C_CHANNEL)
+ {
+ return ERROR_INVALID_PARAMETER;
+ }
+ if (ulI2CEnable) /* Open I2C Port */
+ {
+/* // verify clock rate. If you cannot implement the given rate,
+ // enable a lower clock rate closest to the request clock rate.
+ //
+ // put a better check here if your device can only do discrete
+ // clock rate values.
+*/
+ if (pI2CControl->ClockRate > I2C_MAX_CLOCK_RATE)
+ {
+ pI2CControl->ClockRate = I2C_MAX_CLOCK_RATE;
+ }
+ pI2CControl->Status = I2C_STATUS_NOERROR;
+ }
+ else /* Close I2C Port*/
+ {
+ /* Set Acquired state to FALSE */
+
+ pI2CControl->dwCookie = 0;
+ /* Set status */
+ pI2CControl->Status = I2C_STATUS_NOERROR;
+ }
+
+
+
+ return 0;
+}
+/* end of I2COpen */
+char I2CAccess(PXGI_HW_DEVICE_INFO pHWDE, PI2CControl pI2CControl)
+{
+ ULONG ulChannel = pI2CControl->dwCookie % MAX_I2C_CHANNEL;
+
+
+ if (pI2CControl->ClockRate > I2C_MAX_CLOCK_RATE)
+ {
+ pI2CControl->ClockRate = I2C_MAX_CLOCK_RATE;
+ }
+ if (pI2CControl->ClockRate == 0) {
+ pI2CControl->ClockRate = 20000;
+ }
+
+ pHWDE->I2CDelay = (1000000 / pI2CControl->ClockRate) * 10 * 2; /* in 100ns */
+ /* pHWDE->I2CDelay = (1000000 / pI2CControl->ClockRate) * 10; */ /* in 100ns */
+ /* pHWDE->I2CDelay = 100; */
+ /* PDEBUG(ErrorF("I2CAccess()-I2CDelay = %d...\n", pHWDE->I2CDelay)); */
+
+ /* pHWDE->I2CDelay = 100; */ /* Jong@08032009 */
+
+ switch (pI2CControl->Command)
+ {
+ /* Issue a STOP or START without a READ or WRITE Command */
+ case I2C_COMMAND_NULL:
+ if (I2CNull(pHWDE, pI2CControl) == FALSE) break;
+/* if (pI2CControl->Flags & I2C_FLAGS_STOP) {
+ pI2CContext->dwI2CPortAcquired = FALSE;
+ }
+*/ break;
+
+ /* READ or WRITE Command */
+ case I2C_COMMAND_READ:
+ if (I2CRead(pHWDE, pI2CControl) == FALSE) break;
+/* if (pI2CControl->Flags & I2C_FLAGS_STOP) {
+ pI2CContext->dwI2CPortAcquired = FALSE;
+ }
+*/ break;
+
+ case I2C_COMMAND_WRITE:
+ if (I2CWrite(pHWDE, pI2CControl) == FALSE) break;
+/* if (pI2CControl->Flags & I2C_FLAGS_STOP) {
+ pI2CContext->dwI2CPortAcquired = FALSE;
+ }
+*/ break;
+
+ case I2C_COMMAND_STATUS:
+ pI2CControl->Status = I2C_STATUS_NOERROR;
+ break;
+
+ case I2C_COMMAND_RESET:
+ /* Reset I2C bus */
+ if (ResetI2C(pHWDE, pI2CControl) == FALSE) break;
+ break;
+
+ default:
+ /* Invalid Command */
+ return ERROR_INVALID_PARAMETER;
+ }
+
+
+/* printk("\nI2CAccess(): I2C Cmd = 0x%X I2C Flags = 0x%X I2C Status = 0x%X I2C Data = 0x%X", pI2CControl->Command, pI2CControl->Flags, pI2CControl->Status, pI2CControl->Data); */
+
+ return NO_ERROR;
+}
+
+
+/*^^*
+ * Function: I2CNull
+ *
+ * Purpose: To complete an I2C instruction.
+ *
+ * Inputs: lpI2C_ContextData : PI2C_CONTEXT, pointer to data struct associated
+ * with card being accessed
+ * I2CCntl : PI2CControl, pointer to I2C control structure
+ *
+ * Outputs: void.
+ *^^*/
+BOOLEAN I2CNull( PXGI_HW_DEVICE_INFO pHWDE, PI2CControl pI2CControl)
+{
+ pI2CControl->Status = I2C_STATUS_ERROR;
+
+/*///// Issue STOP - START, if I2C_FLAGS_DATACHAINING ////////*/
+ if (pI2CControl->Flags & I2C_FLAGS_DATACHAINING)
+ {
+ if (Stop(pHWDE) == FALSE) return FALSE;
+ if (Start(pHWDE) == FALSE) return FALSE;
+ }
+
+/*///// Issue START ////////*/
+ if (pI2CControl->Flags & I2C_FLAGS_START)
+ {
+ if (Start(pHWDE) == FALSE) return FALSE;
+ }
+
+/*////// Issue STOP /////////*/
+ if (pI2CControl->Flags & I2C_FLAGS_STOP)
+ {
+ if (Stop(pHWDE) == FALSE) return FALSE;
+ }
+
+ pI2CControl->Status = I2C_STATUS_NOERROR;
+ return TRUE;
+}/* end of I2CNull()*/
+
+/*^^*
+ * Function: I2CRead
+ *
+ * Purpose: To complete an I2C instruction.
+ *
+ * Inputs: lpI2C_ContextData : PI2C_CONTEXT, pointer to data struct associated
+ * with card being accessed
+ * I2CCntl : PI2CControl, pointer to I2C control structure
+ *
+ * Outputs: void.
+ *^^*/
+BOOLEAN I2CRead(PXGI_HW_DEVICE_INFO pHWDE, PI2CControl pI2CControl)
+{
+ pI2CControl->Status = I2C_STATUS_ERROR;
+
+/*///// Issue STOP - START, if I2C_FLAGS_DATACHAINING ////////*/
+ if (pI2CControl->Flags & I2C_FLAGS_DATACHAINING)
+ {
+ if (Stop(pHWDE) == FALSE) return FALSE;
+ if (Start(pHWDE) == FALSE) return FALSE;
+ }
+
+/*///// Issue START ////////*/
+ if (pI2CControl->Flags & I2C_FLAGS_START)
+ {
+ if (Start(pHWDE) == FALSE) return FALSE;
+ }
+
+/*///// Read Command ///////*/
+ if (ReadUCHARI2C(pHWDE, &pI2CControl->Data) == FALSE)
+ return FALSE;
+
+ if (pI2CControl->Flags & I2C_FLAGS_STOP) {
+ if (NoAck(pHWDE) == FALSE) return FALSE;
+ }
+ else { /* Should we issue ACK*/
+ if (pI2CControl->Flags & I2C_FLAGS_ACK) {
+ if (Ack(pHWDE, SEND_ACK) == FALSE) return FALSE;
+ }
+ }
+
+/*////// Issue STOP /////////*/
+ if (pI2CControl->Flags & I2C_FLAGS_STOP)
+ {
+ if (Stop(pHWDE) == FALSE) return FALSE;
+ }
+
+ pI2CControl->Status = I2C_STATUS_NOERROR;
+ return TRUE;
+} /* end of I2CRead() */
+
+/*^^*
+ * Function: I2CWrite
+ *
+ * Purpose: To complete an I2C instruction.
+ *
+ * Inputs: lpI2C_ContextData : PI2C_CONTEXT, pointer to data struct associated
+ * with card being accessed
+ * I2CCntl : PI2CControl, pointer to I2C control structure
+ *
+ * Outputs: void.
+ *^^*/
+BOOLEAN I2CWrite(PXGI_HW_DEVICE_INFO pHWDE, PI2CControl pI2CControl)
+{
+ pI2CControl->Status = I2C_STATUS_ERROR;
+
+/*///// Issue STOP - START, if I2C_FLAGS_DATACHAINING ////////*/
+ if (pI2CControl->Flags & I2C_FLAGS_DATACHAINING)
+ {
+ if (Stop(pHWDE) == FALSE)
+ {
+
+ return FALSE;
+ }
+ if (Start(pHWDE) == FALSE)
+ {
+
+
+ return FALSE;
+ }
+ }
+
+/*///// Issue START ////////*/
+ if (pI2CControl->Flags & I2C_FLAGS_START)
+ {
+ if (Start(pHWDE) == FALSE)
+ {
+ return FALSE;
+ }
+ }
+
+/*///// Write Command ///////*/
+ if (WriteUCHARI2C(pHWDE, pI2CControl->Data) == FALSE)
+ {
+
+ return FALSE;
+ }
+
+ if (pI2CControl->Flags & I2C_FLAGS_ACK) {
+ if (Ack(pHWDE, RECV_ACK) == FALSE)
+ {
+ return FALSE;
+ }
+ }
+
+/*////// Issue STOP /////////*/
+ if (pI2CControl->Flags & I2C_FLAGS_STOP)
+ {
+ if (Stop(pHWDE) == FALSE)
+ {
+ return FALSE;
+ }
+ }
+
+ pI2CControl->Status = I2C_STATUS_NOERROR;
+ return TRUE;
+} /* end of I2CWrite() */
+
+/*^^*
+ * Function: ResetI2C
+ *
+ * Purpose: To reset I2CBus
+ *
+ * Inputs: lpI2C_ContextData : PI2C_CONTEXT, pointer to data struct associated with
+ * lpI2C_ContextData being accessed
+ *
+ * Outputs: UCHAR, the data that was read.
+ *^^*/
+BOOLEAN ResetI2C(PXGI_HW_DEVICE_INFO pHWDE, PI2CControl pI2CControl)
+{
+
+ if (Stop(pHWDE) == TRUE) {
+ pI2CControl->Status = I2C_STATUS_NOERROR;
+ return TRUE;
+ }
+ else {
+ pI2CControl->Status = I2C_STATUS_ERROR;
+ return FALSE;
+ }
+} /* ResetI2C() */
+
+
+
+
+/*^^*
+ * Function: Ack
+ *
+ * Purpose: To ask the I2C bus for an acknowledge.
+ *
+ * Inputs: lpI2C_ContextData : PI2C_CONTEXT, pointer to data struct associated with
+ * lpI2C_ContextData being accessed
+ *
+ * Outputs: char, ack status.
+ *^^*/
+BOOLEAN Ack (PXGI_HW_DEVICE_INFO pHWDE, bool fPut)
+{
+ BOOLEAN status = FALSE;
+ ULONG i, delay, delay2;
+ ULONG ack;
+
+ delay = pHWDE->I2CDelay / 10 / 2;
+ if (fPut == SEND_ACK) /* Send Ack into I2C bus */
+ {
+ vWriteDataLine(pHWDE, LODAT);
+ I2C_DelayUS(delay);
+
+ vWriteClockLine(pHWDE, HICLK);
+ I2C_DelayUS(delay);
+ if (bReadClockLine(pHWDE) != HICLK) {
+ i = 0;
+ delay2 = delay * 2;
+ I2C_DelayUS(delay2); /* Jong@08052008 */
+ do {
+ vWriteClockLine(pHWDE, HICLK);
+ I2C_DelayUS(delay2);
+ if (bReadClockLine(pHWDE) == HICLK) break;
+ i++;
+ delay2 *= 2;
+ if (i >= I2C_RETRY_COUNT) return FALSE;
+ } while (1);
+ }
+
+
+ I2C_DelayUS(delay); /* Jong@08052008 */
+ vWriteClockLine(pHWDE, LOCLK);
+ I2C_DelayUS(delay);
+
+ return TRUE;
+ }
+ else
+ {
+ /* Receive Ack from I2C bus */
+ vWriteDataLine(pHWDE, HIDAT);
+ I2C_DelayUS(delay);
+ ack = bReadDataLine(pHWDE);
+
+ I2C_DelayUS(delay); /* Jong@08052008 */
+ vWriteClockLine(pHWDE, HICLK);
+ I2C_DelayUS(delay);
+ if (bReadClockLine(pHWDE) != HICLK) {
+ i = 0;
+ delay2 = delay * 2;
+ do {
+ I2C_DelayUS(delay2); /* Jong@08052008 */
+ vWriteClockLine(pHWDE, HICLK);
+ I2C_DelayUS(delay2);
+ if (bReadClockLine(pHWDE) == HICLK) break;
+ i++;
+ delay2 *= 2;
+ if (i >= I2C_RETRY_COUNT) return FALSE;
+ } while (1);
+ }
+
+ I2C_DelayUS(delay); /* Jong@08052008 */
+ status = bReadDataLine(pHWDE);
+
+ I2C_DelayUS(delay); /* Jong@08052008 */
+ vWriteClockLine(pHWDE, LOCLK);
+ I2C_DelayUS(delay);
+
+ if (status != LODAT) {
+ if (ack == LODAT) {
+ status = LODAT;
+ }
+
+ else {
+
+ }
+
+ }
+ return (BOOLEAN)(status == LODAT);
+ }
+}/* end of Ack() */
+
+
+BOOLEAN NoAck(PXGI_HW_DEVICE_INFO pHWDE)
+{
+ ULONG i, delay, delay2;
+
+ delay = pHWDE->I2CDelay / 10 / 2;
+
+ vWriteDataLine(pHWDE, HIDAT);
+ I2C_DelayUS(delay);
+
+ vWriteClockLine(pHWDE, HICLK);
+ I2C_DelayUS(delay);
+ if (bReadClockLine(pHWDE) != HICLK) {
+ delay2 = delay * 2;
+ i = 0;
+ do {
+ I2C_DelayUS(delay2); /* Jong@08052008 */
+ vWriteClockLine(pHWDE, HICLK);
+ I2C_DelayUS(delay2);
+ if (bReadClockLine(pHWDE) == HICLK) break;
+ i++;
+ delay2 *= 2;
+ if (i >= I2C_RETRY_COUNT) return FALSE;
+ } while (1);
+ }
+
+ I2C_DelayUS(delay); /* Jong@08052008 */
+ vWriteClockLine(pHWDE, LOCLK);
+ I2C_DelayUS(delay);
+
+ return TRUE;
+}
+
+
+/*^^*
+ * Function: Start
+ *
+ * Purpose: To start a transfer on the I2C bus.
+ *
+ * Inputs: lpI2C_ContextData : PI2C_CONTEXT, pointer to data struct associated with
+ * lpI2C_ContextData being accessed
+ *
+ * Outputs: void.
+ *^^*/
+BOOLEAN Start( PXGI_HW_DEVICE_INFO pHWDE)
+{
+ ULONG i, delay, delay2;
+
+ delay = pHWDE->I2CDelay / 10 / 2;
+
+ vWriteDataLine(pHWDE, HIDAT);
+ I2C_DelayUS(delay);
+ if (bReadDataLine(pHWDE) != HIDAT) {
+ delay2 = delay * 2;
+ i = 0;
+ do {
+ I2C_DelayUS(delay2); /* Jong@08052008 */
+ vWriteDataLine(pHWDE, HIDAT);
+ I2C_DelayUS(delay2);
+ if (bReadDataLine(pHWDE) == HIDAT) break;
+ i++;
+ delay2 *= 2;
+ if (i >= I2C_RETRY_COUNT) return FALSE;
+ } while (1);
+ }
+
+ I2C_DelayUS(delay); /* Jong@08052008 */
+ vWriteClockLine(pHWDE, HICLK);
+ I2C_DelayUS(delay);
+ if (bReadClockLine(pHWDE) != HICLK) {
+ delay2 = delay * 2;
+ i = 0;
+ do {
+ I2C_DelayUS(delay2); /* Jong@08052008 */
+ vWriteClockLine(pHWDE, HICLK);
+ I2C_DelayUS(delay2);
+ if (bReadClockLine(pHWDE) == HICLK) break;
+ i++;
+ delay2 *= 2;
+ if (i >= I2C_RETRY_COUNT) return FALSE;
+ } while (1);
+ }
+
+ I2C_DelayUS(delay); /* Jong@08052008 */
+ vWriteDataLine(pHWDE, LODAT);
+ I2C_DelayUS(delay);
+
+ vWriteClockLine(pHWDE, LOCLK);
+ I2C_DelayUS(delay);
+
+ return TRUE;
+}/* end of Start */
+
+/*^^*
+ * Function: Stop
+ *
+ * Purpose: To stop a transfer on the I2C bus.
+ *
+ * Inputs: lpI2C_ContextData : PI2C_CONTEXT, pointer to data struct associated with
+ * lpI2C_ContextData being accessed
+ *
+ * Outputs: void.
+ *^^*/
+BOOLEAN Stop(PXGI_HW_DEVICE_INFO pHWDE)
+{
+ ULONG i, delay, delay2;
+
+ delay = pHWDE->I2CDelay / 10 / 2;
+ PDEBUGI2C(ErrorF("Stop()-begin-pHWDE->I2CDelay=%d, delay=%d...\n", pHWDE->I2CDelay, delay));
+
+ vWriteDataLine(pHWDE, LODAT);
+ I2C_DelayUS(delay);
+
+ vWriteClockLine(pHWDE, HICLK);
+ I2C_DelayUS(delay);
+ if (bReadClockLine(pHWDE) != HICLK) {
+ i = 0;
+ delay2 = delay * 2;
+ do {
+ I2C_DelayUS(delay2); /* Jong@08052008 */
+ vWriteClockLine(pHWDE, HICLK);
+ I2C_DelayUS(delay2);
+ if (bReadClockLine(pHWDE) == HICLK) break;
+ i++;
+ delay2 *= 2;
+ if (i >= I2C_RETRY_COUNT) return FALSE;
+ } while (1);
+ }
+
+ I2C_DelayUS(delay); /* Jong@08052008 */
+ vWriteDataLine(pHWDE, HIDAT);
+ I2C_DelayUS(delay);
+
+ return (BOOLEAN)(bReadDataLine(pHWDE) == HIDAT);
+}/* end of Stop*/
+
+/*^^*
+ * Function: WriteUCHARI2C
+ *
+ * Purpose: To write a UCHAR of data to the I2C bus.
+ *
+ * Inputs: lpI2C_ContextData : PI2C_CONTEXT, pointer to data struct associated with
+ * lpI2C_ContextData being accessed
+ * cData: UCHAR, the data to write
+ *
+ * Outputs: void.
+ *^^*/
+BOOLEAN WriteUCHARI2C(PXGI_HW_DEVICE_INFO pHWDE, UCHAR cData)
+{
+ ULONG i, j, delay, delay2;
+
+ cData = ReverseUCHAR(cData);
+
+ delay = pHWDE->I2CDelay / 10 / 2;
+
+ for (j=0; j<8; j++, cData>>=1)
+ {
+ I2C_DelayUS(delay); /* Jong@08052008 */
+ vWriteDataLine(pHWDE, cData);
+ I2C_DelayUS(delay);
+
+ vWriteClockLine(pHWDE, HICLK);
+ I2C_DelayUS(delay);
+ if (bReadClockLine(pHWDE) != HICLK) {
+ i = 0;
+ delay2 = delay * 2;
+ do {
+ I2C_DelayUS(delay2); /* Jong@08052008 */
+ vWriteClockLine(pHWDE, HICLK);
+ I2C_DelayUS(delay2);
+ if (bReadClockLine(pHWDE) == HICLK) break;
+ i++;
+ delay2 *= 2;
+ if (i >= I2C_RETRY_COUNT) return FALSE;
+ } while (1);
+ }
+
+ I2C_DelayUS(delay); /* Jong@08052008 */
+ vWriteClockLine(pHWDE, LOCLK);
+ I2C_DelayUS(delay);
+ }
+ return TRUE;
+}/* end of WriteUCHARI2C */
+
+/*^^*
+ * Function: ReadUCHARI2C
+ *
+ * Purpose: To read a UCHAR of data from the I2C bus.
+ *
+ * Inputs: lpI2C_ContextData : PI2C_CONTEXT, pointer to data struct associated with
+ * lpI2C_ContextData being accessed
+ *
+ * Outputs: UCHAR, the data that was read.
+ *^^*/
+BOOLEAN ReadUCHARI2C(PXGI_HW_DEVICE_INFO pHWDE, PUCHAR pBuffer)
+{
+ ULONG ulReadData, data, i, j, delay, delay2;
+
+ delay = pHWDE->I2CDelay / 10 / 2;
+
+ vWriteDataLine(pHWDE, HIDAT);
+ I2C_DelayUS(delay);
+
+ ulReadData = 0;
+ for (j = 0; j < 8; j++)
+ {
+ vWriteClockLine(pHWDE, HICLK);
+ I2C_DelayUS(delay);
+ if (bReadClockLine(pHWDE) != HICLK) {
+ i = 0;
+ delay2 = delay * 2;
+ do {
+ I2C_DelayUS(delay2); /* Jong@08052008 */
+ vWriteClockLine(pHWDE, HICLK);
+ I2C_DelayUS(delay2);
+ if (bReadClockLine(pHWDE) == HICLK) break;
+ i++;
+ delay2 *= 2;
+ if (i >= I2C_RETRY_COUNT) return FALSE;
+ } while (1);
+ }
+
+ I2C_DelayUS(delay); /* Jong@08052008 */
+ data = bReadDataLine(pHWDE);
+ ulReadData = (ulReadData << 1) | (data & 1);
+
+ I2C_DelayUS(delay); /* Jong@08052008 */
+ vWriteClockLine(pHWDE, LOCLK);
+ I2C_DelayUS(delay);
+
+ vWriteDataLine(pHWDE, HIDAT);
+ I2C_DelayUS(delay);
+ }
+
+ *pBuffer = (UCHAR) ulReadData;
+ return TRUE;
+}
+
+
+UCHAR ReverseUCHAR(UCHAR data)
+{
+ UCHAR rdata = 0;
+ int i;
+
+ for (i=0; i<8; i++)
+ {
+ rdata <<= 1;
+ rdata |= (data & 1);
+ data >>= 1;
+ }
+
+ return(rdata);
+}
+
+/************************************************************************************
+ For DVI I2C Interface
+***************************************************************************************/
+
+/*************************************************************************
+// VOID vWriteClockLineDVI()
+// IOReg xx14, index 0F is defined as follows:
+//
+// ... 1 0
+// --------|------|-------|
+// ...| Data | Clock |
+// ------------------------
+*************************************************************************/
+VOID vWriteClockLineDVI(PXGI_HW_DEVICE_INFO pHWDE, UCHAR data)
+{
+ UCHAR temp;
+ PUCHAR pjI2cIOBase;
+
+ PDEBUGI2C(ErrorF("vWriteClockLineDVI()...begin\n"));
+
+ if ((pHWDE->jChipType < XG21)&&(pHWDE->jChipType != XG27))
+ {
+ ErrorF("vWriteClockLineDVI()...0\n");
+ }
+ else
+ {
+ PDEBUGI2C(ErrorF("vWriteClockLineDVI()...1\n"));
+ pjI2cIOBase = pHWDE->pjIOAddress + CRTC_ADDRESS_PORT_COLOR;
+
+ /* Enable GPIOA Write */
+
+ EnableGPIOA(pjI2cIOBase, I2C_WRITE);
+
+ PDEBUGI2C(ErrorF("*1 - pHWDE->ucI2cDVI = %d\n", pHWDE->ucI2cDVI));
+ pHWDE->ucI2cDVI = (pHWDE->ucI2cDVI & MASK(1:1)) | SETBITS(data, 0:0);
+ PDEBUGI2C(ErrorF("*2 - pHWDE->ucI2cDVI = %d\n", pHWDE->ucI2cDVI));
+
+ temp = XGI_GetReg(pjI2cIOBase, IND_CR48_GPIO_REG_I);
+ PDEBUGI2C(ErrorF("IND_CR48_GPIO_REG_I = %d\n", temp));
+
+ {
+ UCHAR temp2 = getGPIORWTransfer(temp);
+ PDEBUGI2C(ErrorF("temp2 = %d\n", temp2));
+ temp = temp2;
+ }
+
+ temp = (temp & (~MASK(1:0))) | pHWDE->ucI2cDVI;
+ PDEBUGI2C(ErrorF("temp= %d\n", temp));
+ XGI_SetReg(pjI2cIOBase,IND_CR48_GPIO_REG_I, temp);
+ }
+
+ PDEBUGI2C(ErrorF("vWriteClockLineDVI()...end\n"));
+}
+
+/*************************************************************************
+// VOID vWriteDataLineDVI()
+// IOReg xx14, index 0F is defined as follows:
+//
+// ... 1 0
+// --------|------|-------|
+// ...| Data | Clock |
+// ------------------------
+*************************************************************************/
+VOID vWriteDataLineDVI(PXGI_HW_DEVICE_INFO pHWDE, UCHAR data)
+{
+ UCHAR temp;
+ PUCHAR pjI2cIOBase;
+
+ PDEBUGI2C(ErrorF("vWriteDataLineDVI()...begin\n"));
+
+ if ((pHWDE->jChipType < XG21)&&(pHWDE->jChipType != XG27))
+ {
+ ErrorF("vWriteDataLineDVI()...0\n");
+ }
+ else
+ {
+ PDEBUGI2C(ErrorF("vWriteDataLineDVI()...1\n"));
+ pjI2cIOBase = pHWDE->pjIOAddress + CRTC_ADDRESS_PORT_COLOR;
+
+
+ /* Enable GPIOB Write */
+
+ EnableGPIOB(pjI2cIOBase, I2C_WRITE);
+
+ PDEBUGI2C(ErrorF("*1 - pHWDE->ucI2cDVI = %d\n", pHWDE->ucI2cDVI));
+ pHWDE->ucI2cDVI = (pHWDE->ucI2cDVI & MASK(0:0)) | SETBITS(data, 1:1);
+ PDEBUGI2C(ErrorF("*2 - pHWDE->ucI2cDVI = %d\n", pHWDE->ucI2cDVI));
+
+ temp = XGI_GetReg(pjI2cIOBase, IND_CR48_GPIO_REG_I);
+ PDEBUGI2C(ErrorF("IND_CR48_GPIO_REG_I = %d\n", temp));
+
+ {
+ UCHAR temp2 = getGPIORWTransfer(temp);
+ PDEBUGI2C(ErrorF("temp2 = %d\n", temp2));
+
+ temp = temp2;
+ }
+
+ temp = (temp & (~MASK(1:0))) | pHWDE->ucI2cDVI;
+ PDEBUGI2C(ErrorF("temp = %d\n", temp));
+
+ XGI_SetReg(pjI2cIOBase,IND_CR48_GPIO_REG_I, temp);
+ }
+
+ PDEBUGI2C(ErrorF("vWriteDataLineDVI()...end\n"));
+}
+
+/*************************************************************************
+// BOOLEAN bReadClockLineDVI()
+// IOReg xx14, index 0F is defined as follows:
+//
+// ... 1 0
+// --------|------|-------|
+// ...| Data | Clock |
+// ------------------------
+*************************************************************************/
+BOOLEAN bReadClockLineDVI(PXGI_HW_DEVICE_INFO pHWDE)
+{
+ UCHAR cPortData;
+ PUCHAR pjI2cIOBase;
+
+ PDEBUGI2C(ErrorF("bReadClockLineDVI()...begin\n"));
+
+ if ((pHWDE->jChipType != XG21)&&(pHWDE->jChipType != XG27))
+ {
+ ErrorF("bReadClockLineDVI()...0\n");
+ }
+ else
+ {
+ PDEBUGI2C(ErrorF("bReadClockLineDVI()...1\n"));
+ pjI2cIOBase = pHWDE->pjIOAddress + CRTC_ADDRESS_PORT_COLOR;
+
+ /* Enable GPIOA READ */
+
+ EnableGPIOA(pjI2cIOBase, I2C_READ);
+
+ cPortData = XGI_GetReg(pjI2cIOBase, IND_CR48_GPIO_REG_I);
+ PDEBUGI2C(ErrorF("*1 - cPortData = %d...\n", cPortData));
+
+ cPortData = GETBITS(cPortData, 7:7);
+ PDEBUGI2C(ErrorF("*2 - cPortData = %d...\n", cPortData));
+ }
+
+ PDEBUGI2C(ErrorF("bReadClockLineDVI()...return(cPortData=%d)\n", cPortData));
+ return cPortData;
+}
+
+/*************************************************************************
+// BOOLEAN bReadDataLineDVI()
+// IOReg xx14, index 0F is defined as follows:
+//
+// ... 1 0
+// --------|------|-------|
+// ...| Data | Clock |
+// ------------------------
+*************************************************************************/
+BOOLEAN bReadDataLineDVI(PXGI_HW_DEVICE_INFO pHWDE)
+{
+ UCHAR cPortData;
+ PUCHAR pjI2cIOBase;
+
+ PDEBUGI2C(ErrorF("bReadDataLineDVI()...begin\n"));
+
+ if ((pHWDE->jChipType != XG21)&&(pHWDE->jChipType != XG27))
+ {
+ ErrorF("bReadDataLineDVI()...0\n");
+ }
+ else
+ {
+ PDEBUGI2C(ErrorF("bReadDataLineDVI()...1\n"));
+ pjI2cIOBase = pHWDE->pjIOAddress + CRTC_ADDRESS_PORT_COLOR;
+
+
+ /* Enable GPIOB Write */
+
+ EnableGPIOB(pjI2cIOBase, I2C_READ);
+
+ cPortData = XGI_GetReg(pjI2cIOBase, IND_CR48_GPIO_REG_I);
+ PDEBUGI2C(ErrorF("*1 - cPortData = %d...\n", cPortData));
+ cPortData = GETBITS(cPortData, 6:6);
+ PDEBUGI2C(ErrorF("*2 - cPortData = %d...\n", cPortData));
+ }
+
+
+ PDEBUGI2C(ErrorF("bReadDataLineDVI()...return(cPortData=%d)\n", cPortData));
+ return cPortData;
+}
+
+//*************************************************************************//
+// VOID vWaitForCRT1VsyncActive()
+// IoReg 3DA
+// ... 3 ...
+// --------|--------------|-------|
+// ...| Vertical Sync| |
+// --------------------------------
+//*************************************************************************//
+VOID vWaitForCRT1HsyncActive(PXGI_HW_DEVICE_INFO pHWDE)
+{
+ PUCHAR pjPort = pHWDE->pjIOAddress + INPUT_STATUS_1_COLOR;
+ ULONG i;
+
+ for (i = 0; i < 0x00FFFF; i++)
+ {
+ if ( (XGI_GetRegByte(pjPort) & 0x01) == 0)
+ {
+ // Inactive
+ break;
+ } //if
+ } //for-loop
+
+ for (i = 0; i < 0x00FFFF; i++)
+ {
+ if ( (XGI_GetRegByte(pjPort) & 0x01) != 0)
+ {
+ // active
+ break;
+ } //if
+ } //for-loop
+
+} //vWaitForCRT1HsyncActive()
+
+////////////////////////////////////////////////////////////////////////////////////
+//
+// For CRT I2C Interface
+//
+////////////////////////////////////////////////////////////////////////////////////
+
+//*************************************************************************//
+// VOID vWriteClockLineCRT()
+// IOReg SR11 is defined as follows:
+//
+// ... 1 0
+// --------|------|-------|
+// ...| Data | Clock |
+// ------------------------
+//*************************************************************************//
+VOID vWriteClockLineCRT(PXGI_HW_DEVICE_INFO pHWDE, UCHAR data)
+{
+ UCHAR temp, ujSR1F;
+ PUCHAR pjI2cIOBase = pHWDE->pjIOAddress + SEQ_ADDRESS_PORT;
+
+ PDEBUGI2C(ErrorF("I2C:Write CRT clock = %x\n", data & 1));
+
+ ujSR1F = XGI_GetReg(pjI2cIOBase, IND_SR1F_POWER_MANAGEMENT);
+
+ pHWDE->ucI2cCRT = (pHWDE->ucI2cCRT & MASK(1:1)) | SETBITS(data, 0:0);
+
+ temp = XGI_GetReg(pjI2cIOBase, IND_SR11_DDC_REG);
+ temp = (temp & (~MASK(1:0))) | pHWDE->ucI2cCRT;
+
+ //wait for CRT1 retrace only when CRT1 is enabled!
+ /* if (pHWDE->bMonitorPoweredOn) */ /* jong@08042009; ignore here */
+ {
+ if(!(data & 1) && ((ujSR1F & 0xC0)==0) )
+ {
+ vWaitForCRT1HsyncActive(pHWDE);
+ }
+ }
+
+ XGI_SetReg(pjI2cIOBase, IND_SR11_DDC_REG, temp);
+}
+
+//*************************************************************************//
+// VOID vWriteDataLineCRT()
+// IOReg SR11 is defined as follows:
+//
+// ... 1 0
+// --------|------|-------|
+// ...| Data | Clock |
+// ------------------------
+//*************************************************************************//
+VOID vWriteDataLineCRT(PXGI_HW_DEVICE_INFO pHWDE, UCHAR data)
+{
+ UCHAR temp, ujSR1F;
+ PUCHAR pjI2cIOBase = pHWDE->pjIOAddress + SEQ_ADDRESS_PORT;
+
+ PDEBUGI2C(ErrorF("I2C:Write CRT data = %x\n", data & 1));
+
+ ujSR1F = XGI_GetReg(pHWDE->pjIOAddress + SEQ_ADDRESS_PORT, IND_SR1F_POWER_MANAGEMENT);
+
+ pHWDE->ucI2cCRT = (pHWDE->ucI2cCRT & MASK(0:0)) | SETBITS(data, 1:1);
+ temp = XGI_GetReg(pjI2cIOBase, IND_SR11_DDC_REG);
+ temp = (temp & (~MASK(1:0))) | pHWDE->ucI2cCRT;
+
+ //wait for CRT1 retrace only when CRT1 is enabled!
+ /* if (pHWDE->bMonitorPoweredOn) */ /* Jong@08042009; ignore checking */
+ {
+ if(!(data & 1) && ((ujSR1F & 0xC0)==0) )
+ {
+ vWaitForCRT1HsyncActive(pHWDE);
+ }
+ }
+
+ XGI_SetReg(pjI2cIOBase, IND_SR11_DDC_REG, temp);
+}
+
+//*************************************************************************//
+// BOOLEAN bReadClockLineCRT()
+// IOReg SR11 is defined as follows:
+//
+// ... 1 0
+// --------|------|-------|
+// ...| Data | Clock |
+// ------------------------
+//*************************************************************************//
+BOOLEAN bReadClockLineCRT(PXGI_HW_DEVICE_INFO pHWDE)
+{
+ UCHAR cPortData;
+ PUCHAR pjI2cIOBase = pHWDE->pjIOAddress + SEQ_ADDRESS_PORT;
+
+ cPortData = XGI_GetReg(pjI2cIOBase, IND_SR11_DDC_REG);
+ cPortData = GETBITS(cPortData, 0:0);
+
+ PDEBUGI2C(ErrorF("I2C:Read Channel CRT clock = %x\n", cPortData));
+
+ return cPortData;
+}
+
+//*************************************************************************//
+// BOOLEAN bReadDataLineCRT()
+// IOReg SR11 is defined as follows:
+//
+// ... 1 0
+// --------|------|-------|
+// ...| Data | Clock |
+// ------------------------
+//*************************************************************************//
+BOOLEAN bReadDataLineCRT(PXGI_HW_DEVICE_INFO pHWDE)
+{
+ UCHAR cPortData;
+ PUCHAR pjI2cIOBase = pHWDE->pjIOAddress + SEQ_ADDRESS_PORT;
+
+ cPortData = XGI_GetReg(pjI2cIOBase, IND_SR11_DDC_REG);
+ cPortData = GETBITS(cPortData, 1:1);
+
+ PDEBUGI2C(ErrorF("I2C:Read Channel CRT data = %x\n", cPortData));
+
+ return cPortData;
+}
+
+////////////////////////////////////////////////////////////////////////////////////
+//
+// For Feature Connector I2C Interface
+//
+////////////////////////////////////////////////////////////////////////////////////
+
+//*************************************************************************//
+// VOID vWriteClockLineFCNT()
+// IOReg SR11 is defined as follows:
+//
+// ... 3 2 ...
+// --------|------|-------|-------|
+// ...| Data | Clock | |
+// --------------------------------
+//*************************************************************************//
+VOID vWriteClockLineFCNT(PXGI_HW_DEVICE_INFO pHWDE, UCHAR data)
+{
+ UCHAR temp;
+ PUCHAR pjI2cIOBase = pHWDE->pjIOAddress + SEQ_ADDRESS_PORT;
+
+ PDEBUGI2C(ErrorF("I2C:Write FCNT clock = %x\n", data & 1));
+
+ pHWDE->ucI2cFCNT = (pHWDE->ucI2cFCNT & MASK(3:3)) | SETBITS(data, 2:2);
+
+ temp = XGI_GetReg(pjI2cIOBase, IND_SR11_DDC_REG);
+ temp = (temp & (~MASK(3:2))) | pHWDE->ucI2cFCNT;
+
+ XGI_SetReg(pjI2cIOBase, IND_SR11_DDC_REG, temp);
+}
+
+//*************************************************************************//
+// VOID vWriteDataLineFCNT()
+// IOReg SR11 is defined as follows:
+//
+// ... 3 2 ...
+// --------|------|-------|-------|
+// ...| Data | Clock | |
+// --------------------------------
+//*************************************************************************//
+VOID vWriteDataLineFCNT(PXGI_HW_DEVICE_INFO pHWDE, UCHAR data)
+{
+ UCHAR temp, temp2, temp3;
+ PUCHAR pjI2cIOBase = pHWDE->pjIOAddress + SEQ_ADDRESS_PORT;
+
+ PDEBUGI2C(ErrorF("I2C:Write FCNT data = %x\n", data & 1));
+
+ pHWDE->ucI2cFCNT = (pHWDE->ucI2cFCNT & MASK(2:2)) | SETBITS(data, 3:3);
+
+ temp = XGI_GetReg(pjI2cIOBase, IND_SR11_DDC_REG);
+ temp = (temp & (~MASK(3:2))) | pHWDE->ucI2cFCNT;
+
+ XGI_SetReg(pjI2cIOBase, IND_SR11_DDC_REG, temp);
+}
+
+//*************************************************************************//
+// BOOLEAN bReadClockLineFCNT()
+// IOReg SR11 is defined as follows:
+//
+// ... 3 2 ...
+// --------|------|-------|-------|
+// ...| Data | Clock | |
+// --------------------------------
+//*************************************************************************//
+BOOLEAN bReadClockLineFCNT(PXGI_HW_DEVICE_INFO pHWDE)
+{
+ UCHAR cPortData;
+ PUCHAR pjI2cIOBase = pHWDE->pjIOAddress + SEQ_ADDRESS_PORT;
+
+ cPortData = XGI_GetReg(pjI2cIOBase, IND_SR11_DDC_REG);
+ cPortData = GETBITS(cPortData, 2:2);
+
+ PDEBUGI2C(ErrorF("I2C:Read Channel FCNT clock = %x\n", cPortData));
+
+ return cPortData;
+}
+
+//*************************************************************************//
+// BOOLEAN bReadDataLineFCNT()
+// IOReg SR11 is defined as follows:
+//
+// ... 3 2 ...
+// --------|------|-------|-------|
+// ...| Data | Clock | |
+// --------------------------------
+//*************************************************************************//
+BOOLEAN bReadDataLineFCNT(PXGI_HW_DEVICE_INFO pHWDE)
+{
+ UCHAR cPortData;
+ PUCHAR pjI2cIOBase = pHWDE->pjIOAddress + SEQ_ADDRESS_PORT;
+
+ cPortData = XGI_GetReg(pjI2cIOBase, IND_SR11_DDC_REG);
+ cPortData = GETBITS(cPortData, 3:3);
+
+ PDEBUGI2C(ErrorF("I2C:Read Channel FCNT data = %x\n", cPortData));
+
+ return cPortData;
+}
+
+/*=======================================================*/
+VOID vWriteClockLine(PXGI_HW_DEVICE_INFO pHWDE, UCHAR data)
+{
+ if(pHWDE->crtno == 0)
+ vWriteClockLineCRT(pHWDE, data);
+ else if(pHWDE->crtno == 1)
+ vWriteClockLineDVI(pHWDE, data);
+ else if(pHWDE->crtno == 2)
+ vWriteClockLineFCNT(pHWDE, data);
+ else
+ ErrorF("Error(XGI) : Unkonwn output device! \n");
+}
+
+VOID vWriteDataLine(PXGI_HW_DEVICE_INFO pHWDE, UCHAR data)
+{
+ if(pHWDE->crtno == 0)
+ vWriteDataLineCRT(pHWDE, data);
+ else if(pHWDE->crtno == 1)
+ vWriteDataLineDVI(pHWDE, data);
+ else if(pHWDE->crtno == 2)
+ vWriteDataLineFCNT(pHWDE, data);
+ else
+ ErrorF("Error(XGI) : Unkonwn output device! \n");
+}
+
+BOOLEAN bReadClockLine(PXGI_HW_DEVICE_INFO pHWDE)
+{
+ if(pHWDE->crtno == 0)
+ return(bReadClockLineCRT(pHWDE));
+ else if(pHWDE->crtno == 1)
+ return(bReadClockLineDVI(pHWDE));
+ else if(pHWDE->crtno == 2)
+ return(bReadClockLineFCNT(pHWDE));
+ else
+ ErrorF("Error(XGI) : Unkonwn output device! \n");
+}
+
+BOOLEAN bReadDataLine(PXGI_HW_DEVICE_INFO pHWDE)
+{
+ if(pHWDE->crtno == 0)
+ return(bReadDataLineCRT(pHWDE));
+ else if(pHWDE->crtno == 1)
+ return(bReadDataLineDVI(pHWDE));
+ else if(pHWDE->crtno == 2)
+ return(bReadDataLineFCNT(pHWDE));
+ else
+ ErrorF("Error(XGI) : Unkonwn output device! \n");
+}
+
+BOOLEAN bEDIDCheckSum(PUCHAR pjEDIDBuf,ULONG ulBufSize)
+{
+ ULONG i;
+ UCHAR ujSum = 0;
+ PUCHAR pujPtr;
+
+ pujPtr = pjEDIDBuf;
+
+ for (i = 0; i < ulBufSize; i++)
+ {
+ /* printk("pujPtr=%x, ",*pujPtr); */
+ ujSum += *(pujPtr++);
+ } /*for-loop */
+
+ return(ujSum);
+
+}
+
+/* Jong 08/03/2009; Get EDID functions; ported from MS Windows */
+//*************************************************************************\\
+// VP_STATUS vGetEDID_1
+//
+// Routine Description:
+// Get the EDID which is in version 1.x format via I2C.
+//
+// Arguments:
+// pHWDE - Hardware extension object pointer
+// pI2C - I2C pointer
+// pjBuffer - EDID Buffer
+// ulBufferSize - Buffer size
+//
+//
+// Return Value:
+// Status of returning EDID.
+// NO_ERROR - success
+// ERROR_INVALID_PARAMETER - failed
+//
+//****************************************************************************
+VP_STATUS vGetEDID_1(
+ PXGI_HW_DEVICE_INFO pHWDE,
+ PI2CControl pI2C,
+ PUCHAR pjBuffer,
+ ULONG ulBufferSize)
+{
+ VP_STATUS status;
+
+ PDEBUGI2C(ErrorF("vGetEDID_1()\n"));
+
+ if ((ulBufferSize < 128) || (pjBuffer == NULL)) {
+ return ERROR_INVALID_PARAMETER;
+ }
+
+ // Set Segment Block ID as 0 if Monitor support Enhanced-EDID
+ /*
+ pI2C->Command = I2C_COMMAND_WRITE_SEGMENT; // to replace I2C_COMMAND_WRITE
+ pI2C->Data = 0;
+ I2CAccessBuffer(pHWDE, pI2C, 0x60, 0, &(pI2C->Data), 0);
+ */
+ pI2C->Command = I2C_COMMAND_WRITE;
+ pI2C->Data = 0;
+ I2CAccessBuffer(pHWDE, pI2C, 0x60, 0, &(pI2C->Data), 0);
+
+ pI2C->Command = I2C_COMMAND_READ;
+ status = I2CAccessBuffer(pHWDE, pI2C, 0xA0, 0, pjBuffer, 128);
+ if ((status == NO_ERROR) && (pI2C->Status == I2C_STATUS_NOERROR))
+ {
+ // Check Block 0 EDID Header and its checksum
+ if ((*((PULONG)(pjBuffer )) != 0xFFFFFF00) ||
+ (*((PULONG)(pjBuffer+4)) != 0x00FFFFFF))
+ {
+ PDEBUGI2C(ErrorF("vGetEDID_1(): EDID Header Incorrect!!\n"));
+ return ERROR_INVALID_PARAMETER;
+ }
+
+ if (bEDIDCheckSum(pjBuffer, 128) != 0)
+ {
+ if ((*((PULONG)(pjBuffer+0x60)) ==0x4d636e79)&& (*((PULONG)(pjBuffer+0x64)) ==0x65747361))
+ {
+ return NO_ERROR; //To Fix SyncMaster Checksum error issue
+ }
+
+ PDEBUGI2C(ErrorF("vGetEDID_1(): EDID Checksum Error!!\n"));
+ return ERROR_INVALID_PARAMETER;
+ }
+
+ }
+ else
+ {
+ PDEBUGI2C(ErrorF("vGetEDID_1 : call I2CAccessBuffer(0xA0) fail !!!\n"));
+ return status;
+ }
+
+ return NO_ERROR;
+}
+
+//*************************************************************************\\
+// VP_STATUS vGetEDID_2
+//
+// Routine Description:
+// Get the EDID which is in version 2.0 format via I2C.
+//
+// Arguments:
+// pHWDE - Hardware extension object pointer
+// pI2C - I2C pointer
+// pjBuffer - EDID Buffer
+// ulBufferSize - Buffer size
+//
+//
+// Return Value:
+// Status of returning EDID.
+// NO_ERROR - success
+// ERROR_INVALID_PARAMETER - failed
+//
+//****************************************************************************
+VP_STATUS vGetEDID_2(
+ PXGI_HW_DEVICE_INFO pHWDE,
+ PI2CControl pI2C,
+ PUCHAR pjBuffer,
+ ULONG ulBufferSize)
+{
+ VP_STATUS status;
+
+ PDEBUGI2C(ErrorF("vGetEDID_2()\n"));
+
+ if ((ulBufferSize < 256) || (pjBuffer == NULL)) {
+ return ERROR_INVALID_PARAMETER;
+ }
+
+ pI2C->Command = I2C_COMMAND_READ;
+ status = I2CAccessBuffer(pHWDE, pI2C, 0xA2, 0, pjBuffer, 256);
+ if ((status != NO_ERROR) || (pI2C->Status != I2C_STATUS_NOERROR)) {
+ PDEBUGI2C(ErrorF("vGetEDID_2 : call I2CAccessBuffer(0xA2) fail !!!\n"));
+ usleep(5);
+ status = I2CAccessBuffer(pHWDE, pI2C, 0xA6, 0, pjBuffer, 256);
+ if ((status != NO_ERROR) || (pI2C->Status != I2C_STATUS_NOERROR)) {
+ PDEBUGI2C(ErrorF("vGetEDID_2 : call I2CAccessBuffer(0xA6) fail !!!\n"));
+ return ERROR_INVALID_PARAMETER;
+ }
+ }
+
+ if (*pjBuffer != 0x20)
+ {
+ return ERROR_INVALID_PARAMETER;
+ }
+
+ if (bEDIDCheckSum(pjBuffer, 256) != 0)
+ {
+ return ERROR_INVALID_PARAMETER;
+ }
+
+ return NO_ERROR;
+}
+
+//*************************************************************************\\
+// BOOLEAN bGetEDID
+//
+// Routine Description:
+// For driver to get the monitor EDID through I2C. This function works similar
+// with VideoPortDDCMonitorHelper() does.
+//
+//
+// Arguments:
+// pHWDE - Hardware extension object pointer
+// ulChannelID - Channel ID
+// pjEDIDBuffer - EDID Buffer
+// ulBufferSize - Buffer size
+//
+//
+// Return Value:
+// Status of returning EDID.
+// TRUE - success
+// FALSE - failed
+//
+//****************************************************************************
+BOOLEAN bGetEDID(
+ PXGI_HW_DEVICE_INFO pHWDE,
+ ULONG ulChannelID,
+ PUCHAR pjEDIDBuffer,
+ ULONG ulBufferSize)
+{
+ I2CControl I2C;
+ VP_STATUS status;
+
+ PDEBUGI2C(ErrorF("bGetEDID() is called.\n"));
+
+ if ((ulBufferSize != 0) && (pjEDIDBuffer != NULL))
+ {
+ memset(pjEDIDBuffer, 0, ulBufferSize);
+ }
+ else
+ {
+ PDEBUGI2C(ErrorF("bGetEDID()-(ulBufferSize == 0) || (pjEDIDBuffer == NULL)\n"));
+ return FALSE;
+ }
+
+ if (I2COpen(pHWDE, I2C_OPEN, ulChannelID, &I2C) != NO_ERROR)
+ {
+ PDEBUGI2C(ErrorF("bGetEDID()-I2COpen()-fail!\n"));
+ return FALSE;
+ }
+
+ // Force Monitor using DDC2 protocal...
+ I2C.ClockRate = I2C_MAX_CLOCK_RATE;
+ I2C.Command = I2C_COMMAND_WRITE;
+ I2C.Flags = I2C_FLAGS_STOP;
+ I2C.Data = 0xFF;
+ I2CAccess(pHWDE, &I2C);
+
+ // Reset I2C bus
+ I2C.Command = I2C_COMMAND_RESET;
+ I2CAccess(pHWDE, &I2C);
+ if (I2C.Status != I2C_STATUS_NOERROR)
+ {
+ PDEBUGI2C(ErrorF("bGetEDID() fail: Reset I2C bus fail.\n"));
+ return FALSE;
+ }
+
+ status = vGetEDID_2(pHWDE, &I2C, pjEDIDBuffer, ulBufferSize);
+ PDEBUGI2C(ErrorF("bGetEDID()-vGetEDID_2-status=%d\n", status == NO_ERROR ? 1:0));
+
+ if (status != NO_ERROR)
+ {
+ usleep(5);
+ status = vGetEDID_1(pHWDE, &I2C, pjEDIDBuffer, ulBufferSize);
+ PDEBUGI2C(ErrorF("bGetEDID()-vGetEDID_1-status=%d\n", status == NO_ERROR ? 1:0));
+
+ if (status == NO_ERROR)
+ {
+ if (*(pjEDIDBuffer+0x7E) != 0)
+ {
+ vGetEDIDExtensionBlocks(pHWDE, &I2C, pjEDIDBuffer+128, ulBufferSize-128);
+ PDEBUGI2C(ErrorF("bGetEDID()-vGetEDIDExtensionBlocks()\n"));
+ }
+ }
+ else
+ {
+ ErrorF( "bGetEDID() fail !!\n");
+ }
+ }
+
+ I2COpen(pHWDE, I2C_CLOSE, ulChannelID, &I2C);
+
+ PDEBUGI2C(ErrorF("bGetEDID()-return(%d)\n", status == NO_ERROR ? 1:0));
+ return (status == NO_ERROR);
+}
\ No newline at end of file diff --git a/src/vb_i2c.h b/src/vb_i2c.h new file mode 100755 index 0000000..ab684af --- /dev/null +++ b/src/vb_i2c.h @@ -0,0 +1,184 @@ +#ifndef _VBI2C_
+#define _VBI2C_
+#include "vgatypes.h"
+#ifdef LINUX_KERNEL
+/* Jong@08052009 */
+// #include <linux/delay.h> /* udelay */
+#endif
+#ifndef u32
+#define u32 unsigned long
+#define u8 unsigned long
+#endif
+
+/* Jong@08052009 */
+//#ifndef DelayUS
+//#define DelayUS(p) udelay(p)
+//#endif
+
+#define IND_CR48_GPIO_REG_I 0x48
+#define IND_CR4A_GPIO_REG_III 0x4A
+
+#define IND_SR11_DDC_REG 0x11 // index of DDC register
+#define IND_SR1F_POWER_MANAGEMENT 0x1F // index of power management reg
+
+#define INPUT_STATUS_1_COLOR 0x002A // Input Status 1 register read
+ // port in color mode
+
+/* Jong 08/03/2009; added for I2C */
+/*--------------------------------*/
+#define I2C_CRT 0
+#define I2C_DVI 1
+#define I2C_FCNT 2
+#define I2C_OPEN 1
+#define I2C_CLOSE 0
+
+#define I2C_RETRY_COUNT 10
+#define I2C_DEBUG_MSG 0
+#define MAX_I2C_CHANNEL 3
+
+#define SEND_ACK 0
+#define RECV_ACK 1
+
+#define HIDAT 1
+#define LODAT 0
+#define HICLK 1
+#define LOCLK 0
+
+#define I2C_COMMAND_NULL 0X0000
+#define I2C_COMMAND_READ 0X0001
+#define I2C_COMMAND_WRITE 0X0002
+#define I2C_COMMAND_STATUS 0X0004
+#define I2C_COMMAND_RESET 0X0008
+
+/* The following flags are provided on a READ or WRITE command */
+#define I2C_FLAGS_START 0X0001 /* START + addx */
+#define I2C_FLAGS_STOP 0X0002 /* STOP */
+#define I2C_FLAGS_DATACHAINING 0X0004 /* STOP, START + addx */
+#define I2C_FLAGS_ACK 0X0010 /* ACKNOWLEDGE (normally set) */
+
+/* The following status flags are returned on completion of the operation */
+#define I2C_STATUS_NOERROR 0X0000
+#define I2C_STATUS_BUSY 0X0001
+#define I2C_STATUS_ERROR 0X0002
+#define I2C_MAX_CLOCK_RATE (100*1000) /* Hz */
+
+#define ERROR_INVALID_PARAMETER -1
+#define NO_ERROR 0
+
+#define VP_STATUS char
+
+// n'th bit set as 1
+#define BIT(n) (1 << (n))
+// n bits set as 1 from bit(0) to bit(n-1)
+#define BITS(n) ((1 << (n)) - 1)
+// Select Large one from a:b
+#define LARGE(n) ((1?n) > (0?n) ? (1?n) : (0?n))
+// Select Small one from a:b
+#define SMALL(n) ((1?n) < (0?n) ? (1?n) : (0?n))
+// set bits as 1 between bit(a) and bit(b)
+//#define BITSMASK(a,b) ( (a)>(b) ? BITS((a)-(b)+1) << (b) : BITS((b)-(a)+1) << (a) )
+// The same as BITMASK(a,b) instead of parameters' format
+//#define MASK(n) BITSMASK(1?n, 0?n)
+// set bits as 1 between bit(a) and bit(b)
+#define MASK(n) ( BITS(LARGE(n)-SMALL(n)+1) << SMALL(n) )
+// get bits [a:b]'s binary value
+#define GETBITS(b,n) ( ((b) & MASK(n)) >> SMALL(n) ) /* Jong@08032009 */
+// set binary value from [a:0] to [c:d]
+#define SETBITS(b, n) ( ( (b) << ((1?n) > (0?n) ? (0?n) : (1?n)) ) & MASK(n) )
+// move bits value from [a:b] to [c:d]
+#define MOVEBITS(b, m, n) ( GETBITS(b, m) << ((1?n) > (0?n) ? (0?n) : (1?n)) )
+/*--------------------------------*/
+
+typedef struct _I2CControl {
+ ULONG Command; /* I2C_COMMAND_* */
+ u32 dwCookie; /* Context identifier returned on Open */
+ u8 Data; /* Data to write, or returned UCHAR */
+ u8 Reserved[3]; /* Filler */
+ ULONG Flags; /* I2C_FLAGS_* */
+ ULONG Status; /* I2C_STATUS_* */
+ ULONG ClockRate; /* Bus clockrate in Hz. */
+} I2CControl, *PI2CControl;
+
+typedef struct _I2CContext
+{
+ u32 dwI2CPortAcquired; /* port busy between start and stop */
+ u32 dwCookie; /* cookie image for this instance */
+ u32 dwCurCookie; /* cookie of current I2C channel owner */
+} I2C_CONTEXT, *PI2C_CONTEXT;
+
+
+typedef struct _EDID_V1_ {
+ ULONG ulHeader0;
+ ULONG ulHeader1;
+ struct {
+ UCHAR LoUCHAR;
+ UCHAR HiUCHAR;
+ } IDManufactureName;
+ USHORT IDProductCode;
+ ULONG IDSerialNumber;
+ UCHAR WeekOfManufacture;
+ UCHAR YearOfManufacture;
+ UCHAR bEDIDVersion; /* should be 1 */
+ UCHAR bEDIDRevision; /* should be 0~3 */
+ UCHAR bVideoInput;
+ UCHAR bMaxHzImageSize; /* cm */
+ UCHAR bMaxVtImageSize; /* cm */
+ UCHAR bGamma;
+ UCHAR bFeatureSupport;
+ UCHAR bColorCharacteristics[10];
+ UCHAR bEstablishedTiming[3];
+ USHORT usStandardTiming[8];
+ union {
+ struct {
+ USHORT usPixelClock;
+ UCHAR bHzActive;
+ UCHAR bHzBlank;
+ UCHAR bHzActiveBlank;
+ UCHAR bVtActive;
+ UCHAR bVtBlank;
+ UCHAR bVtActiveBlank;
+ UCHAR bHSyncOffset;
+ UCHAR bHSyncWidth;
+ UCHAR bVSyncOffsetWidth;
+ UCHAR bHzVtSyncOffsetWidth;
+ UCHAR bHzImageSize; /* mm */
+ UCHAR bVtImageSize; /* mm */
+ UCHAR bHzVtImageSize; /* mm */
+ UCHAR bHzBorder;
+ UCHAR bVtBorder;
+ UCHAR bFlags;
+ } DetailedTiming;
+ struct {
+ USHORT usReserved0;
+ UCHAR bReserved1;
+ UCHAR bTag;
+ UCHAR bReserved2;
+ UCHAR bData[13];
+ } MonitorDescriptor;
+ } Descriptor[4];
+ UCHAR bExtensionFlag;
+ UCHAR bChecksum;
+} EDID_V1, *PEDID_V1;
+
+typedef struct _XGI_I2C_CONTROL
+{
+ ULONG I2CDelay; /* 100ns units*/
+} XGI_I2C_CONTROL, *PXGI_I2C_CONTROL;
+
+/*extern char I2CAccessBuffer(PXGI_HW_DEVICE_INFO pHWDE, PI2CControl I2CCntl, ULONG DevAddr, ULONG Offset, PUCHAR pBuffer, ULONG ulSize);
+*/
+extern char vGetEDIDExtensionBlocks(PXGI_HW_DEVICE_INFO pHWDE, PI2CControl pI2C, PUCHAR pjBuffer, ULONG ulBufferSize);
+extern char vGetEnhancedEDIDBlock(PXGI_HW_DEVICE_INFO pHWDE, PI2CControl pI2C, ULONG ulBlockID, ULONG ulBlockTag, PUCHAR pjBuffer, ULONG ulBufferSize);
+
+
+extern char I2COpen (PXGI_HW_DEVICE_INFO pHWDE,ULONG ulI2CEnable, ULONG ulChannelID, PI2CControl pI2CControl);
+extern char I2CAccess(PXGI_HW_DEVICE_INFO pHWDE, PI2CControl pI2CControl);
+extern BOOLEAN I2CNull( PXGI_HW_DEVICE_INFO pHWDE, PI2CControl pI2CControl);
+extern BOOLEAN I2CRead(PXGI_HW_DEVICE_INFO pHWDE, PI2CControl pI2CControl);
+extern BOOLEAN I2CWrite(PXGI_HW_DEVICE_INFO pHWDE, PI2CControl pI2CControl);
+extern BOOLEAN ResetI2C(PXGI_HW_DEVICE_INFO pHWDE, PI2CControl pI2CControl);
+extern BOOLEAN I2CRead(PXGI_HW_DEVICE_INFO pHWDE,PI2CControl pI2CControl);
+extern BOOLEAN I2CWrite(PXGI_HW_DEVICE_INFO pHWDE, PI2CControl pI2CControl);
+extern BOOLEAN ResetI2C(PXGI_HW_DEVICE_INFO pHWDE, PI2CControl pI2CControl);
+
+#endif
diff --git a/src/vb_init.c b/src/vb_init.c index 7e4ba77..d51aa10 100644 --- a/src/vb_init.c +++ b/src/vb_init.c @@ -2962,14 +2962,21 @@ void XGINew_InitVBIOSData(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO /* ULONG ROMAddr = (ULONG)HwDeviceExtension->pjVirtualRomBase; */
pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase ;
pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress ;
- pVBInfo->BaseAddr = ( USHORT )HwDeviceExtension->pjIOAddress ;
+
+ /* pVBInfo->BaseAddr = ( USHORT )HwDeviceExtension->pjIOAddress ; */
+ pVBInfo->BaseAddr = ( ULONG )HwDeviceExtension->pjIOAddress ;
+
pVBInfo->RelIO = HwDeviceExtension->pjIOAddress - 0x30;
pVBInfo->ISXPDOS = 0 ;
pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14 ;
pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24 ;
pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10 ;
- pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e ;
+
+ pVBInfo->P3cc = pVBInfo->BaseAddr + 0x1c ; /* Jong 07/31/2009 */
+ PDEBUG(ErrorF("XGINew_InitVBIOSData()-pVBInfo->P3cc = %d\n", pVBInfo->P3cc));
+
+ pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e ;
pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12 ;
pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a ;
pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16 ;
@@ -3038,6 +3045,15 @@ void ReadVBIOSTablData( UCHAR ChipType , PVB_DEVICE_INFO pVBInfo) UCHAR j , k ;
ULONG ii , jj ;
+ /* Jong@08212009; no valid address of VBIOS ROM */
+ if(pVideoMemory == NULL)
+ {
+ ErrorF("XGI - No valid address of VBIOS ROM!\n");
+ return;
+ }
+ else
+ ErrorF("XGI - Read data from VBIOS ROM...\n");
+
i = pVideoMemory[ 0x1CF ] | ( pVideoMemory[ 0x1D0 ] << 8 ) ; /* UniROM */
if ( i != 0 )
UNIROM = 1 ;
@@ -3368,6 +3384,7 @@ void ReadVBIOSTablData( UCHAR ChipType , PVB_DEVICE_INFO pVBInfo) }
}
+ ErrorF("XGI - Read data from VBIOS ROM...End\n");
}
/* --------------------------------------------------------------------- */
@@ -3451,6 +3468,10 @@ void XGINew_SetDRAMModeRegister_XG27( PXGI_HW_DEVICE_INFO HwDeviceExtension ) pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17 ;
pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18 ;
pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19 ;
+
+ pVBInfo->P3cc = pVBInfo->BaseAddr + 0x1c ; /* Jong 07/31/2009 */
+ PDEBUG(ErrorF("XGINew_SetDRAMModeRegister_XG27()-pVBInfo->P3cc = %d\n", pVBInfo->P3cc));
+
pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A ;
pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00 ;
pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04 ;
diff --git a/src/vb_setmode.c b/src/vb_setmode.c index cd1afc7..377118f 100644 --- a/src/vb_setmode.c +++ b/src/vb_setmode.c @@ -489,6 +489,8 @@ XGISetModeNew(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo, unsigned vga_info; /* Jong 11/28/2007 */
+ PDEBUG(ErrorF("XGISetModeNew()...begin\n"));
+
/* Jong 10/03/2007 */
if ( HwDeviceExtension->jChipType == XG27 )
{
@@ -508,6 +510,8 @@ XGISetModeNew(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo, /* Jong 10/17/2007; merge code */
InitTo330Pointer( HwDeviceExtension->jChipType, pVBInfo ) ;
+ PDEBUG(ErrorF("XGISetModeNew()...1\n"));
+
if (ModeNo & 0x80) {
ModeNo = ModeNo & 0x7F;
}
@@ -530,9 +534,10 @@ XGISetModeNew(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo, #endif
#endif
- /* Jong 11/28/2007; pVBInfo field is not matching VGAINFO argument */
- /* if ( !XGI_SearchModeID(pVBInfo->SModeIDTable, pVBInfo->EModeIDTable, pVBInfo , &ModeNo , &ModeIdIndex) ) */
- if ( !XGI_SearchModeID(pVBInfo->SModeIDTable, pVBInfo->EModeIDTable, 0x11, &ModeNo , &ModeIdIndex) )
+ PDEBUG(ErrorF("XGISetModeNew()...2\n"));
+
+ if ( (!XGI_SearchModeID(pVBInfo->SModeIDTable, pVBInfo->EModeIDTable, 0x11, &ModeNo , &ModeIdIndex)) ||
+ (HwDeviceExtension->SpecifyTiming) )
{
switch (HwDeviceExtension->BPP)
{
@@ -592,6 +597,8 @@ XGISetModeNew(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo, }
}
+ PDEBUG(ErrorF("XGISetModeNew()...3\n"));
+
if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */
PDEBUG(ErrorF("XGI_GetVBInfo \n"));
XGI_GetVBInfo(ModeNo, ModeIdIndex, HwDeviceExtension, pVBInfo);
@@ -658,6 +665,8 @@ XGISetModeNew(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo, } /* !XG20 */
else
{
+ PDEBUG(ErrorF("XGISetModeNew()...4\n"));
+
/* Jong 10/04/2007 */
if ( pVBInfo->IF_DEF_LVDS == 1 )
{
@@ -667,6 +676,8 @@ XGISetModeNew(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo, }
}
+ PDEBUG(ErrorF("XGISetModeNew()...5\n"));
+
if (ModeNo <= 0x13) {
pVBInfo->ModeType =
pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag & ModeInfoFlag;
@@ -683,9 +694,18 @@ XGISetModeNew(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo, pVBInfo->VBInfo = DisableCRT2Display;
}
+ PDEBUG(ErrorF("XGISetModeNew()...6\n"));
+
XGI_DisplayOff(HwDeviceExtension,pVBInfo);
+ PDEBUG(ErrorF("XGISetModeNew()...7\n"));
+
XGI_SetCRT1Group(HwDeviceExtension, ModeNo, ModeIdIndex, pVBInfo);
+
+ PDEBUG(ErrorF("XGISetModeNew()...8\n"));
+
XGI_DisplayOn(HwDeviceExtension, pVBInfo);
+
+ PDEBUG(ErrorF("XGISetModeNew()...9\n"));
}
/*
@@ -710,16 +730,118 @@ XGISetModeNew(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo, XGI_DisplayOn( HwDeviceExtension, pVBInfo) ;
*/
ErrorF("Part2 0 = %x ",
- XGI_GetReg((XGIIOADDRESS) pVBInfo->Part2Port, 0x0));
+ XGI_GetReg((XGIIOADDRESS) pVBInfo->Part2Port, 0x0));
XGI_UpdateModeInfo(HwDeviceExtension, pVBInfo);
/* Jong 10/04/2007 */
if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 */
XGI_LockCRT2(HwDeviceExtension, pVBInfo);
+ PDEBUG(ErrorF("XGISetModeNew()...End\n"));
+
return (TRUE);
}
+#if 1
+void XGI_SetCRTVCLK(PVB_DEVICE_INFO pVBInfo, double dwPixelClock)
+{
+struct factor
+{
+ int sr2b7;
+ int sr2c7;
+ int sr2c6;
+ int sr2c5;
+ int dividend ;
+ int divisor ;
+};
+
+struct factor kind[16]=
+{
+ {0,0,0,0,1,1},
+ {0,0,0,1,1,2},
+ {0,0,1,0,1,3},
+ {0,0,1,1,1,4},
+ {1,0,0,0,2,1},
+ {1,0,0,1,2,2},
+ {1,0,1,0,2,3},
+ {1,0,1,1,2,4},
+ {0,1,0,0,1,1},
+ {0,1,0,1,1,4},
+ {0,1,1,0,1,6},
+ {0,1,1,1,1,8},
+ {1,1,0,0,2,1},
+ {1,1,0,1,2,4},
+ {1,1,1,0,2,6},
+ {1,1,1,1,2,8}
+};
+ int ii,jj,kk,ll,sr2b,sr2c,Numerator,DeNumerator;
+ double factor1,tempclock,vclk,temp1,min,clock;
+ double min_tempclock=150.0;
+
+ /* Alan 12/14/2007; support LVDS */
+ USHORT XGINew_P3cc = pVBInfo->P3cc;
+ UCHAR b3CC;
+
+ vclk=(double)dwPixelClock;
+ min=99.0;
+ while (min_tempclock>0.0)
+ {
+ for(ii=2;ii<=31;ii++) /* (DeNumerator1)It's value must >=2 */
+ {
+ for(jj=0;jj<=127;jj++) /* (Numerator1) */
+ {
+ for(kk=0;kk<=15;kk++)
+ {
+ tempclock=14.318*kind[kk].dividend*(jj+1)/(ii+1);
+ if ( (tempclock >= min_tempclock ) && ( tempclock <= 380) )
+ {
+ tempclock = tempclock / kind[kk].divisor ;
+ temp1=fabs(vclk-tempclock);
+ if(temp1<min)
+ {
+ clock=tempclock;
+ DeNumerator=ii;
+ Numerator=jj;
+ min=temp1;
+ factor1=(double) (kind[kk].dividend / kind[kk].divisor);
+ ll=kk;
+ }
+ }
+ }
+ }
+ }
+
+ if ((min/vclk)<0.01)
+ {
+ break;
+ }
+ else
+ {
+ min_tempclock -= 50.0;
+ }
+ }
+
+ sr2b=128*kind[ll].sr2b7+Numerator;
+ sr2c=128*kind[ll].sr2c7+64*kind[ll].sr2c6+32*kind[ll].sr2c5+DeNumerator;
+
+ if(pVBInfo->IF_DEF_LVDS == 1)
+ {
+ b3CC = (UCHAR)XGI_GetRegByte((XGIIOADDRESS) XGINew_P3cc) ;
+ switch (b3CC & 0x0c )
+ {
+ case 0x0 : XGI_SetRegANDOR((XGIIOADDRESS) pVBInfo->P3c4, 0x31, 0xCF, 0x10);
+ break;
+ case 0x4 : XGI_SetRegANDOR((XGIIOADDRESS) pVBInfo->P3c4, 0x31, 0xCF, 0x20);
+ break;
+ default : XGI_SetRegANDOR((XGIIOADDRESS) pVBInfo->P3c4, 0x31, 0xCF, 0x00);
+ break;
+ }
+ }
+
+ XGI_SetReg((XGIIOADDRESS) pVBInfo->P3c4 , 0x2B , (unsigned char) sr2b) ;
+ XGI_SetReg((XGIIOADDRESS) pVBInfo->P3c4 , 0x2C , (unsigned char) sr2c) ;
+}
+#else
/* Jong 10/17/2007; merge code */
void XGI_SetCRTVCLK(PVB_DEVICE_INFO pVBInfo, double dwPixelClock)
{
@@ -789,6 +911,7 @@ struct factor kind[16]= XGI_SetReg( (XGIIOADDRESS) pVBInfo->P3c4 , 0x2B , (unsigned char) sr2b) ;
XGI_SetReg( (XGIIOADDRESS) pVBInfo->P3c4 , 0x2C , (unsigned char) sr2c) ;
}
+#endif
/* Jong 10/17/2007; merge code */
void XGI_SetCRTTiming(
@@ -810,7 +933,17 @@ void XGI_SetCRTTiming( VerticalFrontPorch = pXGIHWDE->Vertical_FP;
VerticalSyncWidth = pXGIHWDE->Vertical_SYNC;
VerticalBackPorch = pXGIHWDE->Vertical_BP;
-
+
+ PDEBUG(ErrorF("XGI_SetCRTTiming()...\n"));
+ PDEBUG(ErrorF("HorizontalActivePixel = %d...\n", HorizontalActivePixel));
+ PDEBUG(ErrorF("HorizontalFrontPorch = %d...\n", HorizontalFrontPorch));
+ PDEBUG(ErrorF("HorizontalSyncWidth = %d...\n", HorizontalSyncWidth));
+ PDEBUG(ErrorF("HorizontalBackPorch = %d...\n", HorizontalBackPorch));
+ PDEBUG(ErrorF("VerticalActivePixel = %d...\n", VerticalActivePixel));
+ PDEBUG(ErrorF("VerticalFrontPorch = %d...\n", VerticalFrontPorch));
+ PDEBUG(ErrorF("VerticalSyncWidth = %d...\n", VerticalSyncWidth));
+ PDEBUG(ErrorF("VerticalBackPorch = %d...\n", VerticalBackPorch));
+
HT = HorizontalActivePixel + HorizontalFrontPorch + HorizontalSyncWidth + HorizontalBackPorch;
HDE = HorizontalActivePixel;
HRS = HorizontalActivePixel + HorizontalFrontPorch;
@@ -843,7 +976,8 @@ void XGI_SetCRTTiming( VT = VT - 1;
- temp = XGINew_GetReg1( pVBInfo->P3c4 , 0x06 ) ;
+ temp = XGI_GetReg( pVBInfo->P3c4 , 0x06 ) ;
+
temp = ((temp & 0x1c ) >> 2) * 8;
if (temp == 0)
temp = 8;
@@ -883,6 +1017,7 @@ void XGI_SetCRTTiming( XGI_SetRegANDOR((XGIIOADDRESS) pVBInfo->P3c4, 0x3F, 0x00, (((VRS) & 0x0600)>>9) | (((VRE) & 0x003F)<<2 )); /* VRS */
}
+
if ( pXGIHWDE->jChipType == XG27 )
{
XGI_SetRegANDOR((XGIIOADDRESS) pVBInfo->P3c4, 0x2e, 0x00, ((HRS-1) & 0xff)); /* HRS SR2E[7:0] */
@@ -892,6 +1027,7 @@ void XGI_SetCRTTiming( XGI_SetRegANDOR((XGIIOADDRESS) pVBInfo->P3c4, 0x3F, 0xFC, (((VRE) & 0x003F)<<2 )); /* VRE SR3F[7:2] */
}
+
if (VerticalActivePixel > 1024)
{
XGI_SetRegANDOR((XGIIOADDRESS) pVBInfo->P3c4, 0x0f, 0xf7, 0x08);
@@ -909,10 +1045,8 @@ void XGI_SetCRTTiming( XGI_SetRegANDOR((XGIIOADDRESS) pVBInfo->P3c4, 0x0c, 0xf8, (((HRE & 0x20) >> 3) | ((HT & 0xc0) >> 6)));
XGI_SetRegANDOR((XGIIOADDRESS) pVBInfo->P3c4, 0x0e, 0xf0, ((temp1 & 0xff00) >> 8));
XGI_SetRegANDOR((XGIIOADDRESS) pVBInfo->P3c4, 0x10, 0x00, temp);
-
-
-
- XGI_SetCRTVCLK (pVBInfo, pXGIHWDE->DCLK);
+
+ XGI_SetCRTVCLK (pVBInfo, pXGIHWDE->DCLK/1000.0);
if (pXGIHWDE->BPP==0x20)
{
@@ -961,6 +1095,8 @@ XGI_SetCRT1Group(PXGI_HW_DEVICE_INFO HwDeviceExtension, USHORT ModeNo, USHORT XGINew_P3c2 = pVBInfo->P3c2;
#endif
+ PDEBUG(ErrorF("XGI_SetCRT1Group()...begin\n"));
+
/* XGINew_CRT1Mode = ModeNo ; // SaveModeID */
XGI_SetSeqRegs(StandTableIndex, pVBInfo);
XGI_SetMiscRegs(StandTableIndex, pVBInfo);
@@ -969,6 +1105,8 @@ XGI_SetCRT1Group(PXGI_HW_DEVICE_INFO HwDeviceExtension, USHORT ModeNo, XGI_SetGRCRegs(StandTableIndex, pVBInfo);
XGI_ClearExt1Regs(ModeNo, pVBInfo);
+ PDEBUG(ErrorF("XGI_SetCRT1Group()...1\n"));
+
/* Jong 10/19/2007; merge code */
/* Jong 04/23/2008; All XG20,21,27 should do this */
/* if ( HwDeviceExtension->jChipType == XG27 ) */
@@ -984,6 +1122,8 @@ XGI_SetCRT1Group(PXGI_HW_DEVICE_INFO HwDeviceExtension, USHORT ModeNo, pVBInfo->SetFlag &= temp;
pVBInfo->SelectCRT2Rate = 0;
+ PDEBUG(ErrorF("XGI_SetCRT1Group()...2\n"));
+
if (pVBInfo->
VBType & (VB_XGI301B | VB_XGI302B | VB_XGI301LV | VB_XGI302LV |
VB_XGI301C)) {
@@ -997,6 +1137,8 @@ XGI_SetCRT1Group(PXGI_HW_DEVICE_INFO HwDeviceExtension, USHORT ModeNo, /* RefreshRateTableIndex = XGI_GetRatePtrCRT2( ModeNo, ModeIdIndex, pVBInfo); */
RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, ModeIdIndex, pVBInfo);
+ PDEBUG(ErrorF("XGI_SetCRT1Group()...3\n"));
+
if (RefreshRateTableIndex != 0xFFFF) {
XGI_SetSync(RefreshRateTableIndex, pVBInfo);
XGI_SetCRT1CRTC(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo,
@@ -1009,6 +1151,8 @@ XGI_SetCRT1Group(PXGI_HW_DEVICE_INFO HwDeviceExtension, USHORT ModeNo, RefreshRateTableIndex, pVBInfo);
}
+ PDEBUG(ErrorF("XGI_SetCRT1Group()...4\n"));
+
/* Jong 10/04/2007; merge code */
/* if (HwDeviceExtension->jChipType == XG20) { */
if ( ( HwDeviceExtension->jChipType >= XG20 ) &&
@@ -1031,9 +1175,12 @@ XGI_SetCRT1Group(PXGI_HW_DEVICE_INFO HwDeviceExtension, USHORT ModeNo, /* Jong 10/04/2007; merge code */
if ( HwDeviceExtension->jChipType >= XG21 )
{
+ PDEBUG(ErrorF("XGI_SetCRT1Group()...4-1\n"));
+
temp = XGI_GetReg( (XGIIOADDRESS) pVBInfo->P3d4 , 0x38 ) ;
if ( temp & 0xA0 )
{
+ PDEBUG(ErrorF("XGI_SetCRT1Group()...4-2\n"));
/*XGINew_SetRegAND( pVBInfo->P3d4 , 0x4A , ~0x20 ) ;*/ /* Enable write GPIOF */
/*XGINew_SetRegAND( pVBInfo->P3d4 , 0x48 , ~0x20 ) ;*/ /* P. DWN */
@@ -1043,6 +1190,8 @@ XGI_SetCRT1Group(PXGI_HW_DEVICE_INFO HwDeviceExtension, USHORT ModeNo, else
XGI_SetXG21CRTC( ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo );
+ PDEBUG(ErrorF("XGI_SetCRT1Group()...4-3\n"));
+
XGI_UpdateXG21CRTC( ModeNo , pVBInfo , RefreshRateTableIndex) ;
if ( HwDeviceExtension->jChipType == XG27 )
@@ -1050,6 +1199,8 @@ XGI_SetCRT1Group(PXGI_HW_DEVICE_INFO HwDeviceExtension, USHORT ModeNo, else
XGI_SetXG21LCD( pVBInfo , RefreshRateTableIndex , ModeNo );
+ PDEBUG(ErrorF("XGI_SetCRT1Group()...4-4\n"));
+
if ( pVBInfo->IF_DEF_LVDS == 1 )
{
if ( HwDeviceExtension->jChipType == XG27 )
@@ -1057,29 +1208,35 @@ XGI_SetCRT1Group(PXGI_HW_DEVICE_INFO HwDeviceExtension, USHORT ModeNo, else
XGI_SetXG21LVDSPara(ModeNo,ModeIdIndex, pVBInfo );
}
+
+ PDEBUG(ErrorF("XGI_SetCRT1Group()...4-5\n"));
/*XGINew_SetRegOR( pVBInfo->P3d4 , 0x48 , 0x20 ) ;*/ /* P. ON */
}
}
- /* Jong 10/04/2007; merge code */
+ pVBInfo->SetFlag &= (~ProgrammingCRT2);
+ XGI_SetCRT1FIFO(ModeNo, HwDeviceExtension, pVBInfo);
+ XGI_SetCRT1ModeRegs(HwDeviceExtension, ModeNo, ModeIdIndex,
+ RefreshRateTableIndex, pVBInfo);
+
if ( HwDeviceExtension->SpecialMode )
{
XGI_SetCRTTiming( HwDeviceExtension, pVBInfo );
}
- pVBInfo->SetFlag &= (~ProgrammingCRT2);
- XGI_SetCRT1FIFO(ModeNo, HwDeviceExtension, pVBInfo);
- XGI_SetCRT1ModeRegs(HwDeviceExtension, ModeNo, ModeIdIndex,
- RefreshRateTableIndex, pVBInfo);
+ PDEBUG(ErrorF("XGI_SetCRT1Group()...5\n"));
if (HwDeviceExtension->jChipType == XG40) { /* Copy reg settings to 2nd chip */
if (CheckDualChip(pVBInfo))
SetDualChipRegs(HwDeviceExtension, pVBInfo);
}
+ PDEBUG(ErrorF("XGI_SetCRT1Group()...6\n"));
+
/* XGI_LoadCharacter(); //dif ifdef TVFont */
XGI_LoadDAC(ModeNo, ModeIdIndex, pVBInfo);
+ PDEBUG(ErrorF("XGI_SetCRT1Group()...End\n"));
}
@@ -2058,8 +2215,8 @@ void XGI_SetXG27CRTC(USHORT ModeNo, USHORT ModeIdIndex, USHORT RefreshRateTableI /* --------------------------------------------------------------------- */
void XGI_SetXG21LCD(PVB_DEVICE_INFO pVBInfo,USHORT RefreshRateTableIndex,USHORT ModeNo)
{
- USHORT Data , Temp , b3CC ;
- USHORT XGI_P3cc ;
+ ULONG Data , Temp , b3CC ;
+ ULONG XGI_P3cc ;
if ( ModeNo > 0x13 )
Data = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
@@ -2092,11 +2249,14 @@ void XGI_SetXG21LCD(PVB_DEVICE_INFO pVBInfo,USHORT RefreshRateTableIndex,USHORT if ( ModeNo <= 0x13 )
{
+/* Jong 07/31/2009; might use XGINew_P3cc instead */
+#if 1
b3CC = (UCHAR) XGI_GetRegByte( (XGIIOADDRESS) XGI_P3cc ) ;
if ( b3CC & 0x40 )
XGI_SetRegOR( (XGIIOADDRESS) pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
if ( b3CC & 0x80 )
XGI_SetRegOR( (XGIIOADDRESS) pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
+#endif
}
else
{
@@ -2110,25 +2270,37 @@ void XGI_SetXG21LCD(PVB_DEVICE_INFO pVBInfo,USHORT RefreshRateTableIndex,USHORT /* Jong 10/04/2007; merge code */
void XGI_SetXG27LCD(PVB_DEVICE_INFO pVBInfo,USHORT RefreshRateTableIndex,USHORT ModeNo)
{
- USHORT Data , Temp , b3CC ;
- USHORT XGI_P3cc ;
+ ULONG Data , Temp , b3CC ;
+ ULONG XGI_P3cc ;
+
+ PDEBUG(ErrorF("XGI_SetXG27LCD()...begin\n"));
if ( ModeNo > 0x13 )
Data = pVBInfo->RefIndex[ RefreshRateTableIndex ].Ext_InfoFlag ;
+
XGI_P3cc = pVBInfo->P3cc ;
+ PDEBUG(ErrorF("XGI_SetXG27LCD()...1\n"));
+
XGI_SetReg( (XGIIOADDRESS) pVBInfo->P3d4 , 0x2E , 0x00 ) ;
XGI_SetReg( (XGIIOADDRESS) pVBInfo->P3d4 , 0x2F , 0x00 ) ;
XGI_SetReg( pVBInfo->P3d4 , 0x46 , 0x00 ) ;
XGI_SetReg( pVBInfo->P3d4 , 0x47 , 0x00 ) ;
+ PDEBUG(ErrorF("XGI_SetXG27LCD()...2\n"));
+
Temp = XGI_GetReg( (XGIIOADDRESS) pVBInfo->P3d4 , 0x37 ) ;
+
+ PDEBUG(ErrorF("XGI_SetXG27LCD()...3\n"));
+
if ( ( Temp & 0x03 ) == 0 ) /* dual 12 */
{
XGI_SetReg( (XGIIOADDRESS) pVBInfo->P3d4 , 0x46 , 0x13 ) ;
XGI_SetReg( (XGIIOADDRESS) pVBInfo->P3d4 , 0x47 , 0x13 ) ;
}
+ PDEBUG(ErrorF("XGI_SetXG27LCD()...4\n"));
+
if ( ((*pVBInfo->pDVOSetting)&0xC0) == 0xC0 )
{
XGI_SetReg( (XGIIOADDRESS) pVBInfo->P3d4 , 0x2E , *pVBInfo->pCR2E ) ;
@@ -2137,20 +2309,33 @@ void XGI_SetXG27LCD(PVB_DEVICE_INFO pVBInfo,USHORT RefreshRateTableIndex,USHORT XGI_SetReg( (XGIIOADDRESS) pVBInfo->P3d4 , 0x47 , *pVBInfo->pCR47 ) ;
}
+ PDEBUG(ErrorF("XGI_SetXG27LCD()...5\n"));
+
XGI_SetXG27FPBits(pVBInfo);
+ PDEBUG(ErrorF("XGI_SetXG27LCD()...6\n"));
+
XGI_SetRegOR( (XGIIOADDRESS) pVBInfo->P3c4 , 0x1E , 0x01 ) ; /* Negative blank polarity */
XGI_SetRegAND( (XGIIOADDRESS) pVBInfo->P3c4 , 0x30 , ~0x20 ) ; /* Hsync polarity */
XGI_SetRegAND( (XGIIOADDRESS) pVBInfo->P3c4 , 0x35 , ~0x80 ) ; /* Vsync polarity */
+ PDEBUG(ErrorF("XGI_SetXG27LCD()...7\n"));
+
if ( ModeNo <= 0x13 )
{
- b3CC = (UCHAR) XGI_GetRegByte( (XGIIOADDRESS) XGI_P3cc ) ;
+ PDEBUG(ErrorF("XGI_SetXG27LCD()...7-1-XGI_P3cc=%d\n", XGI_P3cc));
+
+/* Jong 07/31/2009; might use XGINew_P3cc instead */
+#if 1
+ b3CC = (UCHAR) XGI_GetRegByte( (XGIIOADDRESS) XGI_P3cc ) ;
if ( b3CC & 0x40 )
XGI_SetRegOR( (XGIIOADDRESS) pVBInfo->P3c4 , 0x30 , 0x20 ) ; /* Hsync polarity */
if ( b3CC & 0x80 )
XGI_SetRegOR( (XGIIOADDRESS) pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
+#endif
+
+ PDEBUG(ErrorF("XGI_SetXG27LCD()...7-2\n"));
}
else
{
@@ -2159,6 +2344,8 @@ void XGI_SetXG27LCD(PVB_DEVICE_INFO pVBInfo,USHORT RefreshRateTableIndex,USHORT if ( Data & 0x8000 )
XGI_SetRegOR( (XGIIOADDRESS) pVBInfo->P3c4 , 0x35 , 0x80 ) ; /* Vsync polarity */
}
+
+ PDEBUG(ErrorF("XGI_SetXG27LCD()...End\n"));
}
/* Jong 10/04/2007; merge code */
@@ -2172,7 +2359,12 @@ void XGI_UpdateXG21CRTC( USHORT ModeNo , PVB_DEVICE_INFO pVBInfo , USHORT Refres {
int i , index = -1;
+ PDEBUG(ErrorF("XGI_UpdateXG21CRTC()...begin\n"));
+
XGI_SetRegAND( (XGIIOADDRESS) pVBInfo->P3d4 , 0x11 , 0x7F ) ; /* Unlock CR0~7 */
+
+ PDEBUG(ErrorF("XGI_UpdateXG21CRTC()...1\n"));
+
if ( ModeNo <= 0x13 )
{
for( i = 0 ; i < 12 ; i++ )
@@ -2195,6 +2387,8 @@ void XGI_UpdateXG21CRTC( USHORT ModeNo , PVB_DEVICE_INFO pVBInfo , USHORT Refres index = 16 ;
}
+ PDEBUG(ErrorF("XGI_UpdateXG21CRTC()...2\n"));
+
if( index != -1 )
{
XGI_SetReg( (XGIIOADDRESS) pVBInfo->P3d4 , 0x02 , pVBInfo->UpdateCRT1[ index ].CR02 ) ;
@@ -2202,6 +2396,8 @@ void XGI_UpdateXG21CRTC( USHORT ModeNo , PVB_DEVICE_INFO pVBInfo , USHORT Refres XGI_SetReg( (XGIIOADDRESS) pVBInfo->P3d4 , 0x15 , pVBInfo->UpdateCRT1[ index ].CR15 ) ;
XGI_SetReg( (XGIIOADDRESS) pVBInfo->P3d4 , 0x16 , pVBInfo->UpdateCRT1[ index ].CR16 ) ;
}
+
+ PDEBUG(ErrorF("XGI_UpdateXG21CRTC()...End\n"));
}
/* --------------------------------------------------------------------- */
@@ -2515,8 +2711,14 @@ XGI_SetCRT1FIFO(USHORT ModeNo, PXGI_HW_DEVICE_INFO HwDeviceExtension, if (ModeNo > 0x13) {
XGI_SetReg((XGIIOADDRESS) pVBInfo->P3c4, 0x08, 0x34);
data = XGI_GetReg((XGIIOADDRESS) pVBInfo->P3c4, 0x09);
- data &= 0xF0;
- XGI_SetReg((XGIIOADDRESS) pVBInfo->P3c4, 0x09, data);
+
+ /* Jong 02/06/2009; performance; add 10 for WinBench 99 */
+ /* Jong 02/13/2009; might cause threshold noise of display; not sure */
+ /* data &= 0xF0;
+ XGI_SetReg((XGIIOADDRESS) pVBInfo->P3c4, 0x09, data); */
+ data &= 0xC0 ;
+ XGI_SetReg((XGIIOADDRESS) pVBInfo->P3c4 , 0x09 , data | 0x30) ;
+
data = XGI_GetReg((XGIIOADDRESS) pVBInfo->P3c4, 0x3D);
data |= 0x01;
XGI_SetReg((XGIIOADDRESS) pVBInfo->P3c4, 0x3D, data);
@@ -4110,6 +4312,8 @@ XGI_DisplayOn(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo) void
XGI_DisplayOff(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
{
+ PDEBUG(ErrorF("XGI_DisplayOff()...begin\n"));
+
/* Jong 10/04/2007; merge code */
if ( HwDeviceExtension->jChipType == XG21 )
{
@@ -4127,19 +4331,26 @@ XGI_DisplayOff(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo) /* Jong 10/04/2007; merge code */
if ( HwDeviceExtension->jChipType == XG27 )
{
- if ((XGI_XG27GetPSCValue( pVBInfo )&0x2))
- {
- XGI_XG27BLSignalVDD( 0x02 , 0x00, pVBInfo ) ; /* LVDS backlight off */
- XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
- }
-
+ PDEBUG(ErrorF("XG27\n"));
if ( pVBInfo->IF_DEF_LVDS == 0 )
{
+ PDEBUG(ErrorF("pVBInfo->IF_DEF_LVDS == 0 ...\n"));
XGI_XG27BLSignalVDD( 0x20 , 0x00, pVBInfo ) ; /* DVO/DVI signal off */
+ PDEBUG(ErrorF("After XGI_XG27BLSignalVDD() ...\n"));
+ }
+ else if ((XGI_XG27GetPSCValue( pVBInfo )&0x2)) /* Jong@09232009; bug fixing */
+ {
+ PDEBUG(ErrorF("XGI_XG27GetPSCValue( pVBInfo )&0x2 is true...\n"));
+ XGI_XG27BLSignalVDD( 0x02 , 0x00, pVBInfo ) ; /* LVDS backlight off */
+ PDEBUG(ErrorF("After XGI_XG27BLSignalVDD()...\n"));
+ XGI_XG21SetPanelDelay( 3,pVBInfo ) ;
+ PDEBUG(ErrorF("After XGI_XG21SetPanelDelay()...\n"));
}
}
+ PDEBUG(ErrorF("Before XGI_SetRegANDOR((XGIIOADDRESS) pVBInfo->P3c4, 0x01, 0xDF, 0x20) ...\n"));
XGI_SetRegANDOR((XGIIOADDRESS) pVBInfo->P3c4, 0x01, 0xDF, 0x20);
+ PDEBUG(ErrorF("Return from XGI_DisplayOff() ...\n"));
}
@@ -7572,16 +7783,28 @@ UCHAR XGI_XG27GetPSCValue(PVB_DEVICE_INFO pVBInfo) {
UCHAR CR4A,CRB4,temp;
+ PDEBUG(ErrorF("XGI_XG27GetPSCValue()...begin\n"));
+
CR4A = XGI_GetReg( (XGIIOADDRESS) pVBInfo->P3d4 , 0x4A ) ;
+ PDEBUG(ErrorF("XGI_XG27GetPSCValue()...1\n"));
XGI_SetRegAND( (XGIIOADDRESS) pVBInfo->P3d4 , 0x4A , ~0x0C ) ; /* enable GPIO write */
+ PDEBUG(ErrorF("XGI_XG27GetPSCValue()...2\n"));
temp = XGI_GetReg( (XGIIOADDRESS) pVBInfo->P3d4 , 0x48 ) ;
+ PDEBUG(ErrorF("XGI_XG27GetPSCValue()...3\n"));
temp &= 0x0C;
temp >>= 2;
- XGI_SetReg( (XGIIOADDRESS) pVBInfo->P3d4 , 0x4A , CR4A ) ;
+
+ XGI_SetReg( (XGIIOADDRESS) pVBInfo->P3d4 , 0x4A , CR4A ) ;
+ PDEBUG(ErrorF("XGI_XG27GetPSCValue()...4\n"));
+
CRB4 = XGI_GetReg( (XGIIOADDRESS) pVBInfo->P3d4 , 0xB4 ) ;
+ PDEBUG(ErrorF("XGI_XG27GetPSCValue()...5\n"));
+
temp |= ((CRB4&0x04)<<3);
+ PDEBUG(ErrorF("XGI_XG27GetPSCValue()...return\n"));
+
return temp;
}
@@ -7627,6 +7850,8 @@ void XGI_XG27BLSignalVDD(USHORT tempbh,USHORT tempbl, PVB_DEVICE_INFO pVBInfo) UCHAR CR4A,temp;
USHORT tempbh0,tempbl0;
+ PDEBUG(ErrorF("XGI_XG27BLSignalVDD()...begin\n"));
+
tempbh0 = tempbh;
tempbl0 = tempbl;
tempbh0 &= 0x20;
@@ -7638,18 +7863,27 @@ void XGI_XG27BLSignalVDD(USHORT tempbh,USHORT tempbl, PVB_DEVICE_INFO pVBInfo) {
temp = (tempbl>>4)&0x02;
- XGI_SetRegANDOR( (XGIIOADDRESS) pVBInfo->P3d4 , 0xB4 , ~0x02 , temp) ; /* CR B4[1] */
+ PDEBUG(ErrorF("XGI_XG27BLSignalVDD()...1\n"));
+ XGI_SetRegANDOR( (XGIIOADDRESS) pVBInfo->P3d4 , 0xB4 , ~0x02 , temp) ; /* CR B4[1] */
}
- XGI_SetRegANDOR( (XGIIOADDRESS) pVBInfo->P3d4 , 0xB4 , ~tempbh0 , tempbl0 ) ;
+ PDEBUG(ErrorF("XGI_XG27BLSignalVDD()...2\n"));
+ XGI_SetRegANDOR( (XGIIOADDRESS) pVBInfo->P3d4 , 0xB4 , ~tempbh0 , tempbl0 ) ; /* CR B4[0] if tempbh0 = 0x01 */
+
+ /* Enable related GPIO R/W */
+ PDEBUG(ErrorF("XGI_XG27BLSignalVDD()...3\n"));
CR4A = XGI_GetReg( (XGIIOADDRESS) pVBInfo->P3d4 , 0x4A ) ;
tempbh &= 0x03;
tempbl &= 0x03;
tempbh <<= 2;
- tempbl <<= 2; /* GPIOC,GPIOD */
- XGI_SetRegAND( (XGIIOADDRESS) pVBInfo->P3d4 , 0x4A , ~tempbh ) ; /* enable GPIO write */
+ tempbl <<= 2; /* GPIOC,GPIOD */
+
+ PDEBUG(ErrorF("XGI_XG27BLSignalVDD()...4\n"));
+ XGI_SetRegAND( (XGIIOADDRESS) pVBInfo->P3d4 , 0x4A , ~tempbh ) ; /* enable GPIO write */
+ PDEBUG(ErrorF("XGI_XG27BLSignalVDD()...5\n"));
XGI_SetRegANDOR( (XGIIOADDRESS) pVBInfo->P3d4 , 0x48 , ~tempbh , tempbl ) ;
+ PDEBUG(ErrorF("XGI_XG27BLSignalVDD()...return\n"));
}
/* Jong 10/04/2007; merge code */
@@ -7658,11 +7892,16 @@ USHORT XGI_GetLVDSOEMTableIndex(PVB_DEVICE_INFO pVBInfo) {
USHORT index ;
+ PDEBUG(ErrorF("XGI_GetLVDSOEMTableIndex()...begin\n"));
index = XGI_GetReg( (XGIIOADDRESS) pVBInfo->P3d4 , 0x36 ) ;
+ PDEBUG(ErrorF("XGI_GetLVDSOEMTableIndex()...1\n"));
if (index<sizeof(XGI21_LCDCapList)/sizeof(XGI21_LVDSCapStruct))
{
+ PDEBUG(ErrorF("XGI_GetLVDSOEMTableIndex()...2-return\n"));
return index;
}
+
+ PDEBUG(ErrorF("XGI_GetLVDSOEMTableIndex()...3-return\n"));
return 0;
}
@@ -7681,18 +7920,38 @@ void XGI_XG21SetPanelDelay(USHORT tempbl, PVB_DEVICE_INFO pVBInfo) {
USHORT index ;
+ PDEBUG(ErrorF("XGI_XG21SetPanelDelay()...begin\n"));
+
index = XGI_GetLVDSOEMTableIndex( pVBInfo );
+ PDEBUG(ErrorF("After XGI_GetLVDSOEMTableIndex()\n"));
+
if ( tempbl == 1 )
+ {
+ PDEBUG(ErrorF("tempbl == 1\n"));
XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S1, pVBInfo ) ;
+ PDEBUG(ErrorF("After XGINew_LCD_Wait_Time()\n"));
+ }
if ( tempbl == 2 )
+ {
+ PDEBUG(ErrorF("tempbl == 2\n"));
XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S2, pVBInfo ) ;
+ PDEBUG(ErrorF("After XGINew_LCD_Wait_Time()\n"));
+ }
if ( tempbl == 3 )
+ {
+ PDEBUG(ErrorF("tempbl == 3\n"));
XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S3, pVBInfo ) ;
+ PDEBUG(ErrorF("After XGINew_LCD_Wait_Time()\n"));
+ }
if ( tempbl == 4 )
+ {
+ PDEBUG(ErrorF("tempbl == 4\n"));
XGINew_LCD_Wait_Time( pVBInfo->XG21_LVDSCapList[ index ].PSC_S4, pVBInfo ) ;
+ PDEBUG(ErrorF("After XGINew_LCD_Wait_Time()\n"));
+ }
}
/* Jong 10/04/2007; merge code */
@@ -9629,9 +9888,13 @@ XGINew_LCD_Wait_Time(UCHAR DelayTime, PVB_DEVICE_INFO pVBInfo) flag = 0;
+ PDEBUG(ErrorF("XGINew_LCD_Wait_Time()...begin\n"));
+
for (i = 0; i < DelayTime; i++) {
for (j = 0; j < 66; j++) {
- temp = XGI_GetRegLong((XGIIOADDRESS) 0x61);
+
+ PDEBUG(ErrorF("i=%d, j=%d\n", i, j));
+ temp = XGI_GetRegLong((XGIIOADDRESS) 0x61);
temp &= 0x10;
if (temp == flag)
@@ -9640,6 +9903,8 @@ XGINew_LCD_Wait_Time(UCHAR DelayTime, PVB_DEVICE_INFO pVBInfo) flag = temp;
}
}
+
+ PDEBUG(ErrorF("XGINew_LCD_Wait_Time()...end\n"));
}
@@ -9888,3 +10153,93 @@ XGI_GetVCLK2Ptr(USHORT ModeNo, USHORT ModeIdIndex, return VCLKIndex;
}
+
+/* Jong@08212009 */
+void XGIInitMiscVBInfo(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo)
+{
+ PDEBUG(ErrorF("XGIInitMiscVBInfo()...Begin\n"));
+ pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase ;
+ pVBInfo->BaseAddr = ( ULONG )HwDeviceExtension->pjIOAddress ;
+
+ pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14 ;
+ pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24 ;
+ pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10 ;
+ pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e ;
+ pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12 ;
+ pVBInfo->P3cc = pVBInfo->BaseAddr + 0x1C ;
+ pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a ;
+ pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16 ;
+ pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17 ;
+ pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18 ;
+ pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19 ;
+ pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A ;
+
+ pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00 ;
+ pVBInfo->Part1Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_04 ;
+ pVBInfo->Part2Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_10 ;
+ pVBInfo->Part3Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_12 ;
+ pVBInfo->Part4Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 ;
+ pVBInfo->Part5Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_14 + 2 ;
+
+ pVBInfo->IF_DEF_LVDS = 0 ;
+ pVBInfo->IF_DEF_CH7005 = 0 ;
+ pVBInfo->IF_DEF_LCDA = 1 ;
+ pVBInfo->IF_DEF_CH7017 = 0 ;
+ pVBInfo->IF_DEF_CH7007 = 0 ; /* [Billy] 2007/05/14 */
+ pVBInfo->IF_DEF_VideoCapture = 0 ;
+ pVBInfo->IF_DEF_ScaleLCD = 0 ;
+ pVBInfo->IF_DEF_OEMUtil = 0 ;
+ pVBInfo->IF_DEF_PWD = 0 ;
+
+
+ if ( HwDeviceExtension->jChipType >= XG20 ) /* kuku 2004/06/25 */
+ {
+ pVBInfo->IF_DEF_YPbPr = 0 ;
+ pVBInfo->IF_DEF_HiVision = 0 ;
+ pVBInfo->IF_DEF_CRT2Monitor = 0 ;
+ }
+ else if ( HwDeviceExtension->jChipType >= XG40 )
+ {
+ pVBInfo->IF_DEF_YPbPr = 1 ;
+ pVBInfo->IF_DEF_HiVision = 1 ;
+ pVBInfo->IF_DEF_CRT2Monitor = 1 ;
+ }
+ else
+ {
+ pVBInfo->IF_DEF_YPbPr = 1 ;
+ pVBInfo->IF_DEF_HiVision = 1 ;
+ pVBInfo->IF_DEF_CRT2Monitor = 0 ;
+ }
+
+ if ( HwDeviceExtension->jChipType == XG21 ) /* for x86 Linux, XG21 LVDS */
+ {
+ if ( ( XGI_GetReg((XGIIOADDRESS) pVBInfo->P3d4 , 0x38 ) & 0xE0 ) == 0xC0 )
+ {
+ pVBInfo->IF_DEF_LVDS = 1 ;
+ }
+
+ if ( (XGI_GetReg((XGIIOADDRESS) pVBInfo->P3d4, 0x38) >> 5 & 0x07) == 0x03 ) /*CH7007 CR38 D[7-5]=011b*/
+ {
+ pVBInfo->IF_DEF_CH7007 = 1 ;
+ /* HwDeviceExtension->bCH7007 = 1; */
+ XGI_SetReg((XGIIOADDRESS) pVBInfo->P3c4, 0x30, 0x09); /* For if (pHWDE->bVGAEnabled)== 0 */
+/* if( HwDeviceExtension->pDevice == NULL ) */
+
+ HwDeviceExtension->pDevice= HwDeviceExtension;
+
+ }
+ }
+
+ if ( HwDeviceExtension->jChipType == XG27 )
+ {
+ if ( ( XGI_GetReg((XGIIOADDRESS) pVBInfo->P3d4 , 0x38 ) & 0xE0 ) == 0xC0 )
+ {
+ if ( XGI_GetReg((XGIIOADDRESS) pVBInfo->P3d4 , 0x30 ) & 0x20 )
+ {
+ pVBInfo->IF_DEF_LVDS = 1 ;
+ }
+ }
+ }
+
+ PDEBUG(ErrorF("XGIInitMiscVBInfo()...End\n"));
+}
\ No newline at end of file diff --git a/src/vb_struct.h b/src/vb_struct.h index 2ba26cf..f0d75e9 100644 --- a/src/vb_struct.h +++ b/src/vb_struct.h @@ -424,6 +424,16 @@ typedef struct _VB_DEVICE_INFO VB_DEVICE_INFO,*PVB_DEVICE_INFO; struct _VB_DEVICE_INFO
{
BOOLEAN ISXPDOS;
+
+ ULONG P3c4,P3d4,P3c0,P3ce,P3c2,P3cc;
+ ULONG P3ca,P3c6,P3c7,P3c8,P3c9,P3da;
+ ULONG Part0Port,Part1Port,Part2Port;
+ ULONG Part3Port,Part4Port,Part5Port;
+ ULONG RVBHCFACT,RVBHCMAX,RVBHRS;
+ ULONG VGAVT,VGAHT,VGAVDE,VGAHDE;
+ ULONG VT,HT,VDE,HDE;
+ ULONG LCDHRS,LCDVRS,LCDHDES,LCDVDES;
+ /*
USHORT P3c4,P3d4,P3c0,P3ce,P3c2,P3cc;
USHORT P3ca,P3c6,P3c7,P3c8,P3c9,P3da;
USHORT Part0Port,Part1Port,Part2Port;
@@ -431,7 +441,7 @@ struct _VB_DEVICE_INFO USHORT RVBHCFACT,RVBHCMAX,RVBHRS;
USHORT VGAVT,VGAHT,VGAVDE,VGAHDE;
USHORT VT,HT,VDE,HDE;
- USHORT LCDHRS,LCDVRS,LCDHDES,LCDVDES;
+ USHORT LCDHRS,LCDVRS,LCDHDES,LCDVDES; */
USHORT ModeType;
USHORT IF_DEF_TRUMPION,IF_DEF_DSTN;
@@ -449,7 +459,8 @@ struct _VB_DEVICE_INFO PUCHAR ROMAddr;
PUCHAR FBAddr;
- USHORT BaseAddr;
+ ULONG BaseAddr;
+ /* USHORT BaseAddr; */
XGIIOADDRESS RelIO;
DRAM4Type CR6B[CR6B_SIZE];
diff --git a/src/vgatypes.h b/src/vgatypes.h index 484dfd0..47426d5 100644 --- a/src/vgatypes.h +++ b/src/vgatypes.h @@ -56,7 +56,7 @@ #include "osdef.h" #ifdef LINUX_XF86 -#include "xorgVersion.h" +#include "xf86Version.h" #include "xf86Pci.h" #endif @@ -299,6 +299,13 @@ struct _XGI_HW_DEVICE_INFO double DCLK; UCHAR Interlace; /* Alan 08/10/2007; specify interlace or not */ /* --------------------------------------------------------------------- */ + + /* Jong 08/03/2009; support I2C */ + unsigned long I2CDelay; + UCHAR ucI2cCRT; + UCHAR ucI2cDVI; + UCHAR ucI2cFCNT; + int crtno; }; #endif @@ -32,52 +32,114 @@ #ifndef _XGI_H_
#define _XGI_H_
-/***************
+#define DEBUG
+#define DEBUG1
#define DEBUG2
+#define DEBUG3
+#define DEBUG4
+#define DEBUG5
+
+/***************
#define DEBUG
#define DEBUG1
+#define DEBUG2
#define DEBUG3
#define DEBUG4
#define DEBUG5
+#define DEBUGI2C
*****************/
+#ifndef XGI_VIDEO_HW /* avoid compile error in xgi_videohw.c; weird! */
+/* Jong 07/27/2009; use run-time debug instead except for HW acceleration routines */
+extern BOOL g_bRunTimeDebug;
+#define RUNTIMEDEBUG(p) if(g_bRunTimeDebug)p;
+
+/* Jong@08052009 */
+#ifdef DEBUGI2C
+#define PDEBUGI2C(p) p
+#else
+#define PDEBUGI2C(p)
+#endif
#ifdef DEBUG
-#define PDEBUG(p) p
+#define PDEBUG(p) RUNTIMEDEBUG(p)
#else
#define PDEBUG(p)
#endif
#ifdef DEBUG1
-#define PDEBUG1(p) p
+#define PDEBUG1(p) RUNTIMEDEBUG(p)
#else
#define PDEBUG1(p)
#endif
#ifdef DEBUG2
-#define PDEBUG2(p) p
+#define PDEBUG2(p) RUNTIMEDEBUG(p)
#else
#define PDEBUG2(p)
#endif
#ifdef DEBUG3
-#define PDEBUG3(p) p
+#define PDEBUG3(p) RUNTIMEDEBUG(p)
#else
#define PDEBUG3(p)
#endif
#ifdef DEBUG4
-#define PDEBUG4(p) p
+#define PDEBUG4(p) RUNTIMEDEBUG(p)
#else
#define PDEBUG4(p)
#endif
#ifdef DEBUG5
-#define PDEBUG5(p) p
+#define PDEBUG5(p) RUNTIMEDEBUG(p)
#else
#define PDEBUG5(p)
#endif
+#ifdef CDEBUG
+#define CPDEBUG(p) p
+#else
+#define CPDEBUG(p)
+#endif
+
+#ifdef CDEBUG1
+#define CPDEBUG1(p) p
+#else
+#define CPDEBUG1(p)
+#endif
+
+#ifdef CDEBUG2
+#define CPDEBUG2(p) p
+#else
+#define CPDEBUG2(p)
+#endif
+
+#ifdef CDEBUG3
+#define CPDEBUG3(p) p
+#else
+#define CPDEBUG3(p)
+#endif
+
+#ifdef CDEBUG4
+#define CPDEBUG4(p) p
+#else
+#define CPDEBUG4(p)
+#endif
+
+#ifdef CDEBUG5
+#define CPDEBUG5(p) p
+#else
+#define CPDEBUG5(p)
+#endif
+
+#ifdef ACCELDEBUG
+#define PACCELDEBUG(p) p
+#else
+#define PACCELDEBUG(p)
+#endif
+#endif
+
/* Always unlock the registers (should be set!) */
#define UNLOCK_ALWAYS
@@ -91,13 +153,41 @@ #include "xf86Cursor.h"
#include "xf86xv.h"
#include "compiler.h"
+
+#ifdef XORG_VERSION_CURRENT
+#include "xorgVersion.h"
+
+/* #if XORG_VERSION_CURRENT > XORG_VERSION_NUMERIC(7,0,0,0,0) */
+#if ((XORG_VERSION_CURRENT > XORG_VERSION_NUMERIC(7,0,0,0,0)) || (XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(2,0,0,0,0)) )
+#define XGIISXORGPOST70
+#endif
+
+#if (XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(6,9,0,0,0) )
+#define XGI_USE_EXA
+#endif
+
+#endif
+
+/* Jong 01/13/2009; support EXA */
+#define XGI_USE_XAA
+/* #define XGI_USE_EXA */
+
+#ifdef XGI_USE_XAA
#include "xaa.h"
+#endif
+#ifdef XGI_USE_EXA
+#include "exa.h"
+#endif
+
#include "vgaHW.h"
#include "vbe.h"
+/*
#ifdef XORG_VERSION_CURRENT
#include "xorgVersion.h"
-#endif
+#endif */
+
+/* #define XGIISXORGPOST70 */
#include "xgi_pci.h"
#include "osdef.h"
@@ -107,13 +197,24 @@ #ifdef XF86DRI
#define XGINEWDRI
#undef XGINEWDRI2
-#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(4,4,99,99,0) /* Adapt this when the time has come */
+
+#if XF86_VERSION_CURRENT >= XF86_VERSION_NUMERIC(4,4,99,99,0) /* Adapt this when the time has come */
#define XGINEWDRI2
#endif
+
#include "xf86drm.h"
#include "sarea.h"
#define _XF86DRI_SERVER_
+
+/* Jong@09032009 */
+#ifdef XORG_VERSION_CURRENT
+#if ( (XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(6,9,0,0,0)) || (XORG_VERSION_CURRENT <= XORG_VERSION_NUMERIC(2,0,0,0,0)) )
+#include "X11/dri/xf86dri.h"
+#else
#include "xf86dri.h"
+#endif
+#endif
+
#include "dri.h"
#include "GL/glxint.h"
#include "xgi_dri.h"
@@ -541,6 +642,7 @@ typedef struct { int numDGAModes;
Bool DGAactive;
Bool NoAccel;
+ Bool useEXA; /* Jong 01/13/2009; support EXA */
Bool NoXvideo;
Bool TurboQueue;
int ForceCRT1Type;
@@ -570,7 +672,22 @@ typedef struct { XGIRegRec SavedReg;
XGIRegRec ModeReg;
+
+#ifdef XGI_USE_XAA
XAAInfoRecPtr AccelInfoPtr;
+#endif
+#ifdef XGI_USE_EXA /* Jong 01/13/2009; support EXA */
+ ExaDriverPtr EXADriverPtr;
+ int fillPitch, fillBpp;
+ CARD32 fillDstBase;
+ int copyBpp;
+ int copySPitch, copyDPitch;
+ CARD32 copySrcBase, copyDstBase;
+ int copyXdir, copyYdir;
+ ExaOffscreenArea* exa_scratch;
+ unsigned int exa_scratch_next;
+#endif
+
CloseScreenProcPtr CloseScreen;
Bool (*ModeInit)(ScrnInfoPtr pScrn, DisplayModePtr mode);
void (*XGISave)(ScrnInfoPtr pScrn, XGIRegPtr xgireg);
@@ -637,6 +754,8 @@ typedef struct { int Rotate;
+ BOOLEAN HaveCustomModes; /* Jong 07/27/2009; support customer modes */
+
/* ShadowFB support */
Bool ShadowFB;
unsigned char *ShadowPtr;
@@ -729,7 +848,11 @@ typedef struct { BOOLEAN disablecolorkeycurrent;
CARD32 colorKey;
CARD32 MiscFlags;
+
+#ifdef XGI_USE_XAA
FBLinearPtr AccelLinearScratch;
+#endif
+
float zClearVal;
unsigned long bClrColor, dwColor;
int AllowHotkey;
@@ -781,6 +904,14 @@ typedef struct { Bool v4l_videoin;
int v4l_devnum; /* v4l device number, 0,1,2....*/
//~::::
+
+ int TargetRefreshRate;
+ Bool IgnoreDDC;
+
+ Bool Non_DDC_DefaultMode; + int Non_DDC_DefaultResolutionX ; + int Non_DDC_DefaultResolutionY ; + int Non_DDC_DefaultRefreshRate ; } XGIRec, *XGIPtr;
#ifdef XGIDUALHEAD
@@ -885,6 +1016,7 @@ extern void XGI_SetRegANDOR(XGIIOADDRESS Port, USHORT Index, USHORT DataAND, extern void XGI_SetRegAND(XGIIOADDRESS Port, USHORT Index, USHORT DataAND);
extern void XGI_SetRegOR(XGIIOADDRESS Port, USHORT Index, USHORT DataOR);
+#define uint8_t CARD8
extern void XGI_WriteDAC(XGIIOADDRESS dac_data, unsigned shift,
unsigned ordering, uint8_t red, uint8_t green, uint8_t blue);
diff --git a/src/xgi_accel.c b/src/xgi_accel.c index 2490348..b050ea1 100644 --- a/src/xgi_accel.c +++ b/src/xgi_accel.c @@ -49,11 +49,52 @@ #include "xgi.h"
#include "vb_def.h"
+/* Jong 01/13/2009; support EXA */
+#ifdef XGI_USE_XAA
#include "xaarop.h"
#include <xaa.h>
#include <xaalocal.h>
+#endif
+
#include <xf86fbman.h>
+#define DEV_HEIGHT 0xfff /* "Device height of destination bitmap" */
+
+/* Jong 07/24/2008; performance tuning */
+long g_srcbase=-1;
+long g_dstbase=-1;
+int g_src_x=-1;
+int g_src_y=-1;
+int g_dst_x=-1;
+int g_dst_y=-1;
+int g_width=-1;
+int g_height=-1;
+
+int g_Clipping_x1 = 0;
+int g_Clipping_y1 = 0;
+int g_Clipping_x2 = 4096;
+int g_Clipping_y2 = 4096;
+
+int g_LineColor=-1;
+int g_SolidColor=-1;
+int g_Rop=-1;
+int g_MonoPatFgColor=-1;
+int g_MonoPatBgColor=-1;
+int g_MonoPat0=-1;
+int g_MonoPat1=-1;
+
+/* Jong 01/19/2009; for EXA */
+int g_DstRectX = -1;
+int g_DstRectY = -1;
+int g_SrcPitch = -1;
+long g_SrcBase = -1;
+long g_DstBase = -1;
+int g_Fg = -1;
+
+/* struct timeval g_t0; */
+
+int g_trans_color=0;
+
/*************************************************************************/
void Volari_Sync(ScrnInfoPtr pScrn);
@@ -75,6 +116,53 @@ static void Volari_SubsequentMonoPatternFill(ScrnInfoPtr pScrn, int patx, int paty,
int x, int y, int w, int h);
+static void Volari_SetupForSolidLine(ScrnInfoPtr pScrn, int color, int rop,
+ unsigned int planemask);
+
+static void Volari_SubsequentSolidTwoPointLine(ScrnInfoPtr pScrn,
+ int x1, int y1, int x2, int y2, int flags);
+
+static void Volari_SubsequentSolidHorzVertLine(ScrnInfoPtr pScrn,
+ int x, int y, int len, int dir);
+
+static void Volari_SetupForDashedLine(ScrnInfoPtr pScrn,
+ int fg, int bg, int rop, unsigned int planemask,
+ int length, unsigned char *pattern);
+
+static void Volari_SubsequentDashedTwoPointLine(ScrnInfoPtr pScrn,
+ int x1, int y1, int x2, int y2,
+ int flags, int phase);
+
+static void Volari_SetClippingRectangle(ScrnInfoPtr pScrn, int x1, int y1, int x2, int y2);
+static void Volari_DisableClipping(ScrnInfoPtr pScrn);
+
+#ifdef XGI_USE_EXA /* Jong 01/13/2009; support EXA */
+void XGIEXASync(ScreenPtr pScreen, int marker);
+void XGIScratchSave(ScreenPtr pScreen, ExaOffscreenArea *area);
+Bool XGIUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, char *src, int src_pitch);
+Bool XGIUploadToScratch(PixmapPtr pSrc, PixmapPtr pDst);
+Bool XGIDownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h, char *dst, int dst_pitch);
+
+static Bool XGIPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planemask, Pixel fg);
+static void XGISolid(PixmapPtr pPixmap, int x1, int y1, int x2, int y2);
+static void XGIDoneSolid(PixmapPtr pPixmap);
+static Bool XGIPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir, int ydir,
+ int alu, Pixel planemask);
+static void XGICopy(PixmapPtr pDstPixmap, int srcX, int srcY, int dstX, int dstY, int width, int height);
+static void XGIDoneCopy(PixmapPtr pDstPixmap);
+
+#define XGI_HAVE_COMPOSITE
+#ifdef XGI_HAVE_COMPOSITE
+static Bool XGICheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
+ PicturePtr pDstPicture);
+static Bool XGIPrepareComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
+ PicturePtr pDstPicture, PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst);
+static void XGIComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, int dstX, int dstY,
+ int width, int height);
+static void XGIDoneComposite(PixmapPtr pDst);
+#endif
+#endif /* EXA */
+
void Volari_EnableAccelerator(ScrnInfoPtr pScrn) ;
static void Volari_InitCmdQueue(ScrnInfoPtr pScrn) ;
static void Volari_DisableDualPipe(ScrnInfoPtr pScrn) ;
@@ -85,9 +173,36 @@ extern Bool ForceToDisable2DEngine(ScrnInfoPtr pScrn); extern int FbDevExist;
+#define DEBUG_ACCEL_DYNAMICALLY
+
+#ifndef DEBUG_ACCEL_DYNAMICALLY
+#define DisableDrawingFunctionDynamically(bReturn) \
+ { \
+ }
+#else
+#define DisableDrawingFunctionDynamically(bReturn) \
+ { \
+ /* Jong - Good method for performance evaluation */ \
+ /*-----------------------------------------------*/ \
+ CARD8 CR37=0x00; /* Jong 09/11/2008; [7] for disable/enable NULL function dynamically */ \
+ /* Jong 09/12/2008; disable NULL function of HW acceleration dynamically by CR37[7] */ \
+ /* After test, this extra IO doesn't have significant loading */ \
+ CR37=XGI_GetReg(pXGI->XGI_Pr->P3d4, 0x37); \
+ \
+ if((CR37 & 0x80) != 0) \
+ { \
+ if(bReturn) \
+ return(bReturn); \
+ else \
+ return; \
+ } \
+ }
+#endif
+
#if X_BYTE_ORDER == X_BIG_ENDIAN
static CARD32 BE_SWAP32 (CARD32 val)
{
+ PDEBUG(ErrorF("X_BIG_ENDIAN...\n"));
if (CurrentColorDepth == 8)
return ((((val) & 0x000000ff) << 24) | \
(((val) & 0x0000ff00) << 8) | \
@@ -102,6 +217,7 @@ static CARD32 BE_SWAP32 (CARD32 val) #else
static CARD32 BE_SWAP32 (CARD32 val)
{
+ PACCELDEBUG(ErrorF("X_LITTLE_ENDIAN...\n"));
return val;
}
#endif
@@ -189,11 +305,11 @@ void Volari_Idle(XGIPtr pXGI) last_cqrp = cqrp;
}
- sleep(1);
+ /* sleep(1); */
#endif /* DEBUG */
- if (pXGI->Chipset == PCI_CHIP_XGIXG20)
- usleep(1);
+ /* if (pXGI->Chipset == PCI_CHIP_XGIXG20)
+ usleep(1); */
} while (1);
}
@@ -237,6 +353,43 @@ Volari_EnableAccelerator(ScrnInfoPtr pScrn) }
}
+/* Jong@08252009; reset variables for register */
+void ResetVariableFor2DRegister()
+{
+ g_srcbase=-1;
+ g_dstbase=-1;
+ g_src_x=-1;
+ g_src_y=-1;
+ g_dst_x=-1;
+ g_dst_y=-1;
+ g_width=-1;
+ g_height=-1;
+
+ g_Clipping_x1 = 0;
+ g_Clipping_y1 = 0;
+ g_Clipping_x2 = 4096;
+ g_Clipping_y2 = 4096;
+
+ g_LineColor=-1;
+ g_SolidColor=-1;
+ g_Rop=-1;
+ g_MonoPatFgColor=-1;
+ g_MonoPatBgColor=-1;
+ g_MonoPat0=-1;
+ g_MonoPat1=-1;
+
+ /* Jong 01/19/2009; for EXA */
+ g_DstRectX = -1;
+ g_DstRectY = -1;
+ g_SrcPitch = -1;
+ g_SrcBase = -1;
+ g_DstBase = -1;
+ g_Fg = -1;
+
+ g_trans_color=0;
+ /*----------------------------------------------------*/
+}
+
static void
Volari_InitCmdQueue(ScrnInfoPtr pScrn)
{
@@ -246,13 +399,15 @@ Volari_InitCmdQueue(ScrnInfoPtr pScrn) unsigned long ulSR26 ;
unsigned long temp ;
/* unsigned long ulFlag = 0 ; */
-/*
+
+ ResetVariableFor2DRegister();
+
PDEBUG(ErrorF("Volari_InitCmdQueue()\n"));
PDEBUG(ErrorF( "pXGI->IOBase = 0x%08lX, [%04X] = 0x%08lX\n",(unsigned long)(pXGI->IOBase),0x85c0, XGIMMIOLONG(0x85c0))) ;
PDEBUG(ErrorF( "pXGI->IOBase = 0x%08lX, [%04X] = 0x%08lX\n",(unsigned long)(pXGI->IOBase),0x85c4, XGIMMIOLONG(0x85c4))) ;
PDEBUG(ErrorF( "pXGI->IOBase = 0x%08lX, [%04X] = 0x%08lX\n",(unsigned long)(pXGI->IOBase),0x85c8, XGIMMIOLONG(0x85c8))) ;
PDEBUG(ErrorF( "pXGI->IOBase = 0x%08lX, [%04X] = 0x%08lX\n",(unsigned long)(pXGI->IOBase),0x85cc, XGIMMIOLONG(0x85cc))) ;
-*/
+
inXGIIDXREG(XGICR, 0x55, ulCR55) ;
andXGIIDXREG(XGICR, 0x55, 0x33) ;
orXGIIDXREG(XGISR, 0x26, 1) ; /* reset cmd queue */
@@ -366,20 +521,20 @@ Volari_InitCmdQueue(ScrnInfoPtr pScrn) temp = (unsigned long)pXGI->FbBase ;
temp += pXGI->cmdQueueOffset ;
pXGI->cmdQueueBase = (unsigned char *)temp ;
-/*
+
PDEBUG(ErrorF( "pXGI->FbBase = 0x%lX\n", pXGI->FbBase )) ;
PDEBUG(ErrorF( "pXGI->cmdQueueOffset = 0x%lX\n", pXGI->cmdQueueOffset )) ;
PDEBUG(ErrorF( "pXGI->cmdQueueBase = 0x%lX\n", pXGI->cmdQueueBase )) ;
-*/
+
outXGIIDXREG(XGISR, 0x26, ulSR26) ;
ulXGITempRP=Volari_GetHwRP() ;
-/*
+
PDEBUG(ErrorF( "pXGI->IOBase = 0x%08lX, [%04X] = 0x%08lX\n",(unsigned long)(pXGI->IOBase),0x85c0, XGIMMIOLONG(0x85c0))) ;
PDEBUG(ErrorF( "pXGI->IOBase = 0x%08lX, [%04X] = 0x%08lX\n",(unsigned long)(pXGI->IOBase),0x85c4, XGIMMIOLONG(0x85c4))) ;
PDEBUG(ErrorF( "pXGI->IOBase = 0x%08lX, [%04X] = 0x%08lX\n",(unsigned long)(pXGI->IOBase),0x85c8, XGIMMIOLONG(0x85c8))) ;
PDEBUG(ErrorF( "pXGI->IOBase = 0x%08lX, [%04X] = 0x%08lX\n",(unsigned long)(pXGI->IOBase),0x85cc, XGIMMIOLONG(0x85cc))) ;
-*/
+
/* XGI315 */
pXGI->cmdQueue_shareWP_only2D = ulXGITempRP;
/* pXGI->pCQ_shareWritePort = &(pXGI->cmdQueue_shareWP_only2D); */
@@ -399,7 +554,12 @@ Volari_InitCmdQueue(ScrnInfoPtr pScrn) Volari_Idle(pXGI);
}
- PDEBUG(ErrorF("Volari_InitCmdQueue() done.\n")) ;
+
+ PDEBUG(ErrorF("Volari_InitCmdQueue() done.\n")) ;
+ PDEBUG(ErrorF( "pXGI->IOBase = 0x%08lX, [%04X] = 0x%08lX\n",(unsigned long)(pXGI->IOBase),0x85c0, XGIMMIOLONG(0x85c0))) ;
+ PDEBUG(ErrorF( "pXGI->IOBase = 0x%08lX, [%04X] = 0x%08lX\n",(unsigned long)(pXGI->IOBase),0x85c4, XGIMMIOLONG(0x85c4))) ;
+ PDEBUG(ErrorF( "pXGI->IOBase = 0x%08lX, [%04X] = 0x%08lX\n",(unsigned long)(pXGI->IOBase),0x85c8, XGIMMIOLONG(0x85c8))) ;
+ PDEBUG(ErrorF( "pXGI->IOBase = 0x%08lX, [%04X] = 0x%08lX\n",(unsigned long)(pXGI->IOBase),0x85cc, XGIMMIOLONG(0x85cc))) ;
}
static void
@@ -457,7 +617,11 @@ Volari_DisableCmdQueue(ScrnInfoPtr pScrn) {
XGIPtr pXGI = XGIPTR(pScrn) ;
- andXGIIDXREG(XGISR, 0x26, 0x0F) ;
+ /* Jong@08112009; bug fixing */
+ /* andXGIIDXREG(XGISR, 0x26, 0x0F) ; */
+
+ orXGIIDXREG(XGISR, 0x26, 0x01) ;
+ andXGIIDXREG(XGISR, 0x26, 0x0C) ;
}
void
@@ -471,7 +635,10 @@ Volari_InitializeAccelerator(ScrnInfoPtr pScrn) Bool
Volari_AccelInit(ScreenPtr pScreen)
{
+#ifdef XGI_USE_XAA
XAAInfoRecPtr infoPtr;
+#endif
+
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
XGIPtr pXGI = XGIPTR(pScrn);
int reservedFbSize;
@@ -485,28 +652,33 @@ Volari_AccelInit(ScreenPtr pScreen) PDEBUG1(ErrorF("Volari_AccelInit()\n" )) ;
- pXGI->AccelInfoPtr = infoPtr = XAACreateInfoRec();
- if (!infoPtr) return FALSE;
+#ifdef XGI_USE_XAA
+ /* Jong 01/07/2008; force to disable 2D based on SR3A[6] for XG21 */
+ if( !((pXGI->Chipset == PCI_CHIP_XGIXG21) && ForceToDisable2DEngine(pScrn)) && !(pXGI->useEXA) )
+ {
+ PDEBUG(ErrorF("--- XAA ---\n" )) ;
+ pXGI->AccelInfoPtr = infoPtr = XAACreateInfoRec();
+ if (!infoPtr) return FALSE;
- Volari_InitializeAccelerator(pScrn);
+ Volari_InitializeAccelerator(pScrn);
- infoPtr->Flags = LINEAR_FRAMEBUFFER |
- OFFSCREEN_PIXMAPS |
- PIXMAP_CACHE;
+ infoPtr->Flags = LINEAR_FRAMEBUFFER |
+ OFFSCREEN_PIXMAPS |
+ PIXMAP_CACHE;
- /* sync */
- infoPtr->Sync = Volari_Sync;
+ /* sync */
+ infoPtr->Sync = Volari_Sync;
- if ((pScrn->bitsPerPixel != 8) &&
- (pScrn->bitsPerPixel != 16) &&
- (pScrn->bitsPerPixel != 32))
- {
- return FALSE;
- }
+ if ((pScrn->bitsPerPixel != 8) &&
+ (pScrn->bitsPerPixel != 16) &&
+ (pScrn->bitsPerPixel != 32))
+ {
+ return FALSE;
+ }
+
+
+ PDEBUG(ErrorF("--- Enable XAA ---\n" )) ;
- /* Jong 01/07/2008; force to disable 2D based on SR3A[6] for XG21 */
- if( !((pXGI->Chipset == PCI_CHIP_XGIXG21) && ForceToDisable2DEngine(pScrn)) )
- {
#ifdef XGIG2_SCR2SCRCOPY
/* BitBlt */
/* Jong 08/24/2007; cause an extra rectangle drawing at top-left corner while clicking "Computer" on Suse SP1 (Xorg6.9.0) */
@@ -514,6 +686,9 @@ Volari_AccelInit(ScreenPtr pScreen) {
infoPtr->SetupForScreenToScreenCopy = Volari_SetupForScreenToScreenCopy;
infoPtr->SubsequentScreenToScreenCopy = Volari_SubsequentScreenToScreenCopy;
+
+ /* Jong@08112009; bug fixing */
+ /* infoPtr->ScreenToScreenCopyFlags = NO_PLANEMASK | NO_TRANSPARENCY | ONLY_LEFT_TO_RIGHT_BITBLT; */
infoPtr->ScreenToScreenCopyFlags = NO_PLANEMASK | NO_TRANSPARENCY;
}
#endif
@@ -539,94 +714,250 @@ Volari_AccelInit(ScreenPtr pScreen) BIT_ORDER_IN_BYTE_MSBFIRST ;
#endif /* XGIG2_8X8MONOPATFILL */
}
+#endif /* XAA */
- /* init Frame Buffer Manager */
- reservedFbSize = 0;
- if (pXGI->TurboQueue)
- {
- reservedFbSize += pXGI->cmdQueueSize ;
- }
+/* Jong 01/13/2009; support EXA */
+#ifdef XGI_USE_EXA /* ----------------------- EXA ----------------------- */
+ PDEBUG(ErrorF("--- EXA ---\n" )) ;
+ if(pXGI->useEXA)
+ {
+ int obase = 0;
- if (pXGI->HWCursor)
- {
- reservedFbSize += VOLARI_CURSOR_SHAPE_SIZE;
- }
+ PDEBUG(ErrorF("--- Enable EXA ---\n" )) ;
-#ifdef XGIG2_COLOREXPSCANLN
- reservedFbSize += (pXGI->ColorExpandBufferNumber * pXGI->PerColorExpandBufferSize);
+#ifdef XGIISXORGPOST70 /* for Xorg 7.0 and above */
+ if(!(pXGI->EXADriverPtr = exaDriverAlloc()))
+#else
+ if(!(pXGI->EXADriverPtr = xnfcalloc(sizeof(ExaDriverRec), 1)))
+#endif
+ {
+ ErrorF("Failt to allocate EXADriverPtr!\n");
+ return FALSE;
+ }
+
+ /* data */
+#ifdef XGIISXORGPOST70
+ PDEBUG(ErrorF("--- Xorg7 and above - 1 ---\n" )) ;
+ pXGI->EXADriverPtr->exa_major = 2;
+ pXGI->EXADriverPtr->exa_minor = 0;
+
+ pXGI->EXADriverPtr->memoryBase = pXGI->FbBase;
+ pXGI->EXADriverPtr->memorySize = pXGI->maxxfbmem;
+#else
+ pXGI->EXADriverPtr->card.memoryBase = pXGI->FbBase;
+ pXGI->EXADriverPtr->card.memorySize = pXGI->maxxfbmem;
#endif
+ if(!obase) {
+ obase = pScrn->displayWidth * pScrn->virtualY * (pScrn->bitsPerPixel >> 3);
+ }
+
+#ifdef XGIISXORGPOST70
+ PDEBUG(ErrorF("--- Xorg7 and above - 2 ---\n" )) ;
+ pXGI->EXADriverPtr->offScreenBase = obase;
+ if(pXGI->EXADriverPtr->memorySize > pXGI->EXADriverPtr->offScreenBase)
+ {
+ PDEBUG(ErrorF("--- Xorg7 and above - 3 ---\n" )) ;
+ pXGI->EXADriverPtr->flags = EXA_OFFSCREEN_PIXMAPS;
+#else
+ pXGI->EXADriverPtr->card.offScreenBase = obase;
- UsableFbSize = pXGI->FbMapSize - reservedFbSize;
- AvailBufBase = pXGI->FbBase + UsableFbSize;
+ if(pXGI->EXADriverPtr->card.memorySize > pXGI->EXADriverPtr->card.offScreenBase)
+ {
+ pXGI->EXADriverPtr->card.flags = EXA_OFFSCREEN_PIXMAPS;
+#endif
+ }
+ else
+ {
+ pXGI->NoXvideo = TRUE;
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Not enough video RAM for offscreen memory manager. Xv disabled\n");
+ }
- for (i = 0; i < pXGI->ColorExpandBufferNumber; i++) {
- const int base = i * pXGI->PerColorExpandBufferSize;
+#ifdef XGIISXORGPOST70
+ PDEBUG(ErrorF("--- Xorg7 and above - 4 ---\n" )) ;
+ pXGI->EXADriverPtr->pixmapOffsetAlign = 32; /* 16; */ /* src/dst: double quad word boundary */
+ pXGI->EXADriverPtr->pixmapPitchAlign = 4; /* pitch: double word boundary */
+ pXGI->EXADriverPtr->maxX = 4095;
+ pXGI->EXADriverPtr->maxY = 4095;
+#else
+ pXGI->EXADriverPtr->card.pixmapOffsetAlign = 32; /* 16; */ /* src/dst: double quad word boundary */
+ pXGI->EXADriverPtr->card.pixmapPitchAlign = 4; /* pitch: double word boundary */
+ pXGI->EXADriverPtr->card.maxX = 4095;
+ pXGI->EXADriverPtr->card.maxY = 4095;
+#endif
- pXGI->ColorExpandBufferAddr[i] = AvailBufBase + base;
- pXGI->ColorExpandBufferScreenOffset[i] = UsableFbSize + base;
- }
+#ifdef XGIISXORGPOST70
-#ifdef XGIG2_IMAGEWRITE
- reservedFbSize += pXGI->ImageWriteBufferSize;
- UsableFbSize = pXGI->FbMapSize - reservedFbSize;
- pXGI->ImageWriteBufferAddr = AvailBufBase = pXGI->FbBase + UsableFbSize;
- infoPtr->ImageWriteRange = pXGI->ImageWriteBufferAddr;
-#endif /* XGIG2_IMAGEWRITE */
+ PDEBUG(ErrorF("Use EXA for HW acceleration for Xorg7 and above...\n"));
- Avail.x1 = 0;
- Avail.y1 = 0;
+ /* Sync */
+ pXGI->EXADriverPtr->WaitMarker = XGIEXASync;
-/*
- Avail.x2 = pScrn->displayWidth;
+ /* Solid fill */
+ pXGI->EXADriverPtr->PrepareSolid = XGIPrepareSolid;
+ pXGI->EXADriverPtr->Solid = XGISolid;
+ pXGI->EXADriverPtr->DoneSolid = XGIDoneSolid;
- ErrorF("FbDevExist=%s\n",FbDevExist?"TRUE":"FALSE");
-
- if( FbDevExist && (pXGI->Chipset != PCI_CHIP_XGIXG20 ) && (pXGI->Chipset != PCI_CHIP_XGIXG27 ) )
- {
- if( UsableFbSize >= 8*1024*1024 )
- {
- UsableFbSize = 8*1024*1024 ;
- }
- else
- {
- UsableFbSize = 4*1024*1024 ;
- }
- }
+ /* Copy */
+ pXGI->EXADriverPtr->PrepareCopy = XGIPrepareCopy;
+ pXGI->EXADriverPtr->Copy = XGICopy;
+ pXGI->EXADriverPtr->DoneCopy = XGIDoneCopy;
- PDEBUG1(ErrorF( "UsabelFbSize = %08lx\n", UsableFbSize )) ;
- Avail.y2 = UsableFbSize / pXGI->scrnOffset ;
+ /* Upload, download to/from Screen */
+ pXGI->EXADriverPtr->UploadToScreen = XGIUploadToScreen;
+ pXGI->EXADriverPtr->DownloadFromScreen = XGIDownloadFromScreen;
- if ((unsigned long)Avail.y2 > 8192)
- {
- Avail.y2 = 8192 ;
- }
-*/
+#ifdef XGI_HAVE_COMPOSITE
+ pXGI->EXADriverPtr->CheckComposite = XGICheckComposite;
+ pXGI->EXADriverPtr->PrepareComposite = XGIPrepareComposite;
+ pXGI->EXADriverPtr->Composite = XGIComposite;
+ pXGI->EXADriverPtr->DoneComposite = XGIDoneComposite;
+#endif
+#else
+ PDEBUG(ErrorF("Use EXA for HW acceleration for Xorg6.9...\n"));
+
+ /* Sync */
+ pXGI->EXADriverPtr->accel.WaitMarker = XGIEXASync;
+
+ /* Solid fill */
+ pXGI->EXADriverPtr->accel.PrepareSolid = XGIPrepareSolid;
+ pXGI->EXADriverPtr->accel.Solid = XGISolid;
+ pXGI->EXADriverPtr->accel.DoneSolid = XGIDoneSolid;
+
+ /* Copy */
+ pXGI->EXADriverPtr->accel.PrepareCopy = XGIPrepareCopy;
+ pXGI->EXADriverPtr->accel.Copy = XGICopy;
+ pXGI->EXADriverPtr->accel.DoneCopy = XGIDoneCopy;
+
+ /* Upload, download to/from Screen */
+ pXGI->EXADriverPtr->accel.UploadToScreen = XGIUploadToScreen;
+ pXGI->EXADriverPtr->accel.DownloadFromScreen = XGIDownloadFromScreen;
+
+#ifdef XGI_HAVE_COMPOSITE
+ pXGI->EXADriverPtr->accel.CheckComposite = XGICheckComposite;
+ pXGI->EXADriverPtr->accel.PrepareComposite = XGIPrepareComposite;
+ pXGI->EXADriverPtr->accel.Composite = XGIComposite;
+ pXGI->EXADriverPtr->accel.DoneComposite = XGIDoneComposite;
+#endif
+#endif /* POST70 */
+ }
+#endif /* EXA */
+
+#ifdef XGI_USE_XAA
+ if(!(pXGI->useEXA)) {
+ /* init Frame Buffer Manager */
+ reservedFbSize = 0;
+ if (pXGI->TurboQueue)
+ {
+ reservedFbSize += pXGI->cmdQueueSize ;
+ }
- UsableFbSize = pXGI->CursorOffset ;
- Avail.x1 = 0 ;
- Avail.y1 = 0 ;
- Avail.x2 = pScrn->displayWidth;
- Avail.y2 = UsableFbSize / pXGI->scrnOffset ;
+ if (pXGI->HWCursor)
+ {
+ reservedFbSize += VOLARI_CURSOR_SHAPE_SIZE;
+ }
+ #ifdef XGIG2_COLOREXPSCANLN
+ reservedFbSize += (pXGI->ColorExpandBufferNumber * pXGI->PerColorExpandBufferSize);
+ #endif
- if ((unsigned long)Avail.y2 > 8192)
- {
- Avail.y2 = 8192 ;
- }
+ UsableFbSize = pXGI->FbMapSize - reservedFbSize;
+ AvailBufBase = pXGI->FbBase + UsableFbSize;
+ for (i = 0; i < pXGI->ColorExpandBufferNumber; i++) {
+ const int base = i * pXGI->PerColorExpandBufferSize;
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "Usable FBSize = %08lx\n", UsableFbSize ) ;
+ pXGI->ColorExpandBufferAddr[i] = AvailBufBase + base;
+ pXGI->ColorExpandBufferScreenOffset[i] = UsableFbSize + base;
+ }
+ #ifdef XGIG2_IMAGEWRITE
+ reservedFbSize += pXGI->ImageWriteBufferSize;
+ UsableFbSize = pXGI->FbMapSize - reservedFbSize;
+ pXGI->ImageWriteBufferAddr = AvailBufBase = pXGI->FbBase + UsableFbSize;
+ infoPtr->ImageWriteRange = pXGI->ImageWriteBufferAddr;
+ #endif /* XGIG2_IMAGEWRITE */
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "Frame Buffer From (%d,%d) To (%d,%d)\n",
- Avail.x1, Avail.y1, Avail.x2, Avail.y2);
+ Avail.x1 = 0;
+ Avail.y1 = 0;
- xf86InitFBManager(pScreen, &Avail);
+ /*
+ Avail.x2 = pScrn->displayWidth;
- return(XAAInit(pScreen, infoPtr));
+ ErrorF("FbDevExist=%s\n",FbDevExist?"TRUE":"FALSE");
+
+ if( FbDevExist && (pXGI->Chipset != PCI_CHIP_XGIXG20 ) && (pXGI->Chipset != PCI_CHIP_XGIXG27 ) )
+ {
+ if( UsableFbSize >= 8*1024*1024 )
+ {
+ UsableFbSize = 8*1024*1024 ;
+ }
+ else
+ {
+ UsableFbSize = 4*1024*1024 ;
+ }
+ }
+
+ PDEBUG1(ErrorF( "UsabelFbSize = %08lx\n", UsableFbSize )) ;
+ Avail.y2 = UsableFbSize / pXGI->scrnOffset ;
+
+ if ((unsigned long)Avail.y2 > 8192)
+ {
+ Avail.y2 = 8192 ;
+ }
+ */
+
+ UsableFbSize = pXGI->CursorOffset ;
+ Avail.x1 = 0 ;
+ Avail.y1 = 0 ;
+ Avail.x2 = pScrn->displayWidth;
+ Avail.y2 = UsableFbSize / pXGI->scrnOffset ;
+
+
+ if ((unsigned long)Avail.y2 > 8192)
+ {
+ Avail.y2 = 8192 ;
+ }
+
+
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Usable FBSize = %08lx\n", UsableFbSize ) ;
+
+
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Frame Buffer From (%d,%d) To (%d,%d)\n",
+ Avail.x1, Avail.y1, Avail.x2, Avail.y2);
+
+ xf86InitFBManager(pScreen, &Avail);
+
+ return(XAAInit(pScreen, infoPtr));
+ }
+#endif /* XAA */
+
+#ifdef XGI_USE_EXA
+ if(pXGI->useEXA)
+ {
+ /* if(!pSiS->NoAccel) { */
+ if(!exaDriverInit(pScreen, pXGI->EXADriverPtr)) {
+ return FALSE;
+ }
+
+ /* Reserve locked offscreen scratch area of 128K for glyph data */
+ pXGI->exa_scratch = exaOffscreenAlloc(pScreen, 128 * 1024, 16, TRUE,
+ XGIScratchSave, pXGI);
+ if(pXGI->exa_scratch)
+ {
+ pXGI->exa_scratch_next = pXGI->exa_scratch->offset;
+#ifdef XGIISXORGPOST70
+ pXGI->EXADriverPtr->UploadToScratch = XGIUploadToScratch;
+#else
+ pXGI->EXADriverPtr->accel.UploadToScratch = XGIUploadToScratch;
+#endif
+ }
+ return TRUE;
+ }
+#endif /* EXA */
}
void
@@ -679,6 +1010,8 @@ static int xgiG2_PatALUConv[] = 0xFF, /* dest = 0xFF; 1, GXset, 0xF */
};
+/* ---------------------------- XAA -------------------------- */
+#ifdef XGI_USE_XAA
static void
Volari_SetupForScreenToScreenCopy(
ScrnInfoPtr pScrn,
@@ -686,10 +1019,9 @@ Volari_SetupForScreenToScreenCopy( unsigned int planemask, int trans_color)
{
XGIPtr pXGI = XGIPTR(pScrn);
-#ifdef SHOW_XAAINFO
+//#ifdef SHOW_XAAINFO
XAAInfoRecPtr pXAA = XAAPTR(pScrn);
-/*
- ErrorF("XAAInfoPtr->UsingPixmapCache = %s\n"
+ PDEBUG1(ErrorF("XAAInfoPtr->UsingPixmapCache = %s\n"
"XAAInfoPtr->CanDoMono8x8 = %s\n"
"XAAInfoPtr->CanDoColor8x8 = %s\n"
"XAAInfoPtr->CachePixelGranularity = %d\n"
@@ -725,9 +1057,8 @@ Volari_SetupForScreenToScreenCopy( pXAA->CacheColorExpandDensity,
pXAA->maxOffPixWidth,
pXAA->maxOffPixHeight,
- pXAA->NeedToSync ? "True" : "False");
-*/
-#endif
+ pXAA->NeedToSync ? "True" : "False"));
+//#endif
PDEBUG1(ErrorF("Setup ScreenCopy(%d, %d, 0x%x, 0x%x, 0x%x)\n",
xdir, ydir, rop, planemask, trans_color));
@@ -749,13 +1080,41 @@ Volari_SubsequentScreenToScreenCopy( {
XGIPtr pXGI = XGIPTR(pScrn);
long srcbase, dstbase;
-/*
+ int mymin, mymax; +
PDEBUG1(ErrorF("Subsequent ScreenCopy(%d,%d, %d,%d, %d,%d)\n",
src_x, src_y,
dst_x, dst_y,
width, height));
-*/
+
srcbase=dstbase=0;
+ mymin = min(src_y, dst_y); + mymax = max(src_y, dst_y); +
+#if 1 /* Jong@08112009; bug fixing */
+ if((mymax - mymin) < height) { + PDEBUG1(ErrorF("(mymax - mymin) < height...\n")); + if((src_y >= 2048) || (dst_y >= 2048)) { + PDEBUG1(ErrorF("(src_y >= 2048) || (dst_y >= 2048)...\n")); + srcbase = pXGI->scrnOffset * mymin; + dstbase = pXGI->scrnOffset * mymin; + src_y -= mymin; + dst_y -= mymin; + } + } else { + PDEBUG1(ErrorF("(mymax - mymin) >= height...\n")); + if(src_y >= 2048) { + PDEBUG1(ErrorF("src_y >= 2048...\n")); + srcbase = pXGI->scrnOffset * src_y; + src_y = 0; + } + if((dst_y >= pScrn->virtualY) || (dst_y >= 2048)) { + PDEBUG1(ErrorF("(dst_y >= pScrn->virtualY) || (dst_y >= 2048...\n")); + dstbase = pXGI->scrnOffset * dst_y; + dst_y = 0; + } + } +#else
if (src_y >= 2048)
{
srcbase=pXGI->scrnOffset*src_y;
@@ -766,11 +1125,12 @@ Volari_SubsequentScreenToScreenCopy( dstbase=pXGI->scrnOffset*dst_y;
dst_y=0;
}
- /*
+#endif
+
PDEBUG1(ErrorF("SrcBase = %08lX DstBase = %08lX\n",srcbase,dstbase)) ;
PDEBUG1(ErrorF("SrcX = %08lX SrcY = %08lX\n",src_x,src_y)) ;
PDEBUG1(ErrorF("DstX = %08lX DstY = %08lX\n",dst_x,dst_y)) ;
-*/
+
GuardBand(0x30 * Alignment);
Volari_SetupSRCBase(srcbase);
Volari_SetupDSTBase(dstbase);
@@ -778,6 +1138,9 @@ Volari_SubsequentScreenToScreenCopy( Volari_SetupDSTXY(dst_x,dst_y) ;
Volari_SetupRect(width, height) ;
Volari_DoCMD ;
+
+ /* Jong@08112009 */
+ PDEBUG(XGIDumpCMDQueue(pScrn));
}
static void
@@ -874,6 +1237,554 @@ Volari_SubsequentMonoPatternFill(ScrnInfoPtr pScrn, Volari_DoCMD ;
/*Volari_Idle(pXGI)*/;
}
+#endif /* XAA */
+/************************************************************************/
+
+/* Jong 01/13/2009; support EXA */
+#ifdef XGI_USE_EXA /* ---------------------------- EXA -------------------------- */
+void XGIEXASync(ScreenPtr pScreen, int marker)
+{
+ XGIPtr pXGI = XGIPTR(xf86Screens[pScreen->myNum]);
+
+ PACCELDEBUG(ErrorF("XGIEXASync()...\n"));
+
+ Volari_Idle;
+}
+
+static Bool
+XGIPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planemask, Pixel fg)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
+ XGIPtr pXGI = XGIPTR(pScrn);
+ CARD16 pitch;
+
+ PACCELDEBUG(ErrorF("XGIPrepareSolid...\n"));
+ /* DisableDrawingFunctionDynamically(TRUE); */
+
+ /* Planemask not supported */
+ if((planemask & ((1 << pPixmap->drawable.depth) - 1)) !=
+ (1 << pPixmap->drawable.depth) - 1) {
+ return FALSE;
+ }
+
+ if((pPixmap->drawable.bitsPerPixel != 8) &&
+ (pPixmap->drawable.bitsPerPixel != 16) &&
+ (pPixmap->drawable.bitsPerPixel != 32))
+ return FALSE;
+
+ /* Check that the pitch matches the hardware's requirements. Should
+ * never be a problem due to pixmapPitchAlign and fbScreenInit.
+ */
+ if(((pitch = exaGetPixmapPitch(pPixmap)) & 3))
+ return FALSE;
+
+ PACCELDEBUG(ErrorF("pitch=%d...\n", pitch));
+
+ Volari_ResetCmd ;
+
+ Volari_SetupPATFG((int)fg)
+
+ Volari_SetupDSTColorDepth((pPixmap->drawable.bitsPerPixel >> 4) << 16);
+ Volari_SetupDSTRect(pitch, DEV_HEIGHT)
+
+ Volari_SetupROP(xgiG2_PatALUConv[alu])
+ Volari_SetupCMDFlag(PATFG | BITBLT)
+
+ pXGI->fillDstBase = (CARD32)exaGetPixmapOffset(pPixmap); /* FBOFFSET is not used for Z-series */
+ PACCELDEBUG(ErrorF("pXGI->fillDstBase=0x%x...\n", pXGI->fillDstBase));
+
+ return TRUE;
+}
+
+static void
+XGISolid(PixmapPtr pPixmap, int x1, int y1, int x2, int y2)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
+ XGIPtr pXGI = XGIPTR(pScrn);
+ CARD32 Command;
+
+ PACCELDEBUG(ErrorF("XGISolid...\n"));
+ PACCELDEBUG(ErrorF("pXGI->CommandReg = 0x%x...\n", pXGI->CommandReg));
+ /* DisableDrawingFunctionDynamically(FALSE); */
+
+ Volari_SetupDSTXY(x1, y1)
+ Volari_SetupRect(x2-x1, y2-y1) ;
+ Volari_SetupDSTBase(pXGI->fillDstBase);
+ Volari_DoCMD
+}
+
+static void
+XGIDoneSolid(PixmapPtr pPixmap)
+{
+ PACCELDEBUG(ErrorF("XGIDoneSolid()...\n"));
+}
+
+static Bool
+XGIPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir, int ydir,
+ int alu, Pixel planemask)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum];
+ XGIPtr pXGI = XGIPTR(pScrn);
+ CARD32 srcbase, dstbase;
+ CARD16 srcpitch, dstpitch;
+
+ PACCELDEBUG(ErrorF("XGIPrepareCopy()...\n"));
+ PACCELDEBUG(ErrorF("pSrcPixmap->devPrivate.ptr=0x%x, pDstPixmap->devPrivate.ptr=0x%x...\n",
+ pSrcPixmap->devPrivate.ptr, pDstPixmap->devPrivate.ptr));
+ /* DisableDrawingFunctionDynamically(TRUE); */
+
+ /* Planemask not supported */
+ if((planemask & ((1 << pSrcPixmap->drawable.depth) - 1)) !=
+ (1 << pSrcPixmap->drawable.depth) - 1) {
+ return FALSE;
+ }
+
+ if((pDstPixmap->drawable.bitsPerPixel != 8) &&
+ (pDstPixmap->drawable.bitsPerPixel != 16) &&
+ (pDstPixmap->drawable.bitsPerPixel != 32))
+ return FALSE;
+
+ /* Jong 07/15/2009; bug fixing for moving window on console; might need stretch bitblt to set bitblt direction */
+ if((xdir != 0) || (ydir != 0)) return FALSE;
+
+ /* Check that the pitch matches the hardware's requirements. Should
+ * never be a problem due to pixmapPitchAlign and fbScreenInit.
+ */
+ if((srcpitch = exaGetPixmapPitch(pSrcPixmap)) & 3)
+ return FALSE;
+ if((dstpitch = exaGetPixmapPitch(pDstPixmap)) & 3)
+ return FALSE;
+
+ srcbase = (CARD32)exaGetPixmapOffset(pSrcPixmap); /* FBOFFSET is not used for Z-series */;
+
+ dstbase = (CARD32)exaGetPixmapOffset(pDstPixmap); /* FBOFFSET is not used for Z-series */
+
+ /* TODO: Will there eventually be overlapping blits?
+ * If so, good night. Then we must calculate new base addresses
+ * which are identical for source and dest, otherwise
+ * the chips direction-logic will fail. Certainly funny
+ * to re-calculate x and y then...
+ */
+
+ Volari_ResetCmd ;
+
+ Volari_SetupDSTColorDepth((pDstPixmap->drawable.bitsPerPixel >> 4) << 16);
+ Volari_SetupSRCPitch(srcpitch)
+ Volari_SetupDSTRect(dstpitch, DEV_HEIGHT)
+
+ Volari_SetupROP(xgiG2_ALUConv[alu])
+
+ Volari_SetupSRCBase(srcbase)
+ Volari_SetupDSTBase(dstbase)
+
+ return TRUE;
+}
+static void
+XGICopy(PixmapPtr pDstPixmap, int srcX, int srcY, int dstX, int dstY, int width, int height)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum];
+ XGIPtr pXGI = XGIPTR(pScrn);
+ CARD32 Command;
+
+ PACCELDEBUG(ErrorF("XGICopy()...\n"));
+ PACCELDEBUG(ErrorF("srcX=%d, srcY=%d, dstX=%d, dstY=%d...\n", srcX, srcY, dstX, dstY));
+ PACCELDEBUG(ErrorF("pDstPixmap->devPrivate.ptr=0x%x...\n", pDstPixmap->devPrivate.ptr));
+ /* DisableDrawingFunctionDynamically(FALSE); */
+
+ Volari_SetupSRCXY(srcX, srcY)
+ Volari_SetupDSTXY(dstX, dstY)
+
+ Volari_SetupRect(width, height)
+ Volari_DoCMD
+}
+
+static void
+XGIDoneCopy(PixmapPtr pDstPixmap)
+{
+ PACCELDEBUG(ErrorF("XGIDoneCopy()...\n"));
+}
+
+#ifdef XGI_HAVE_COMPOSITE
+static Bool
+XGICheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
+ PicturePtr pDstPicture)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pDstPicture->pDrawable->pScreen->myNum];
+ XGIPtr pXGI = XGIPTR(pScrn);
+
+ PACCELDEBUG(ErrorF("XGICheckComposite()...\n"));
+ /* DisableDrawingFunctionDynamically(TRUE); */
+
+ xf86DrvMsg(0, 0, "CC: %d Src %x (fi %d ca %d) Msk %x (%d %d) Dst %x (%d %d)\n",
+ op, pSrcPicture->format, pSrcPicture->filter, pSrcPicture->componentAlpha,
+ pMaskPicture ? pMaskPicture->format : 0x2011, pMaskPicture ? pMaskPicture->filter : -1,
+ pMaskPicture ? pMaskPicture->componentAlpha : -1,
+ pDstPicture->format, pDstPicture->filter, pDstPicture->componentAlpha);
+
+ if(pSrcPicture->transform || (pMaskPicture && pMaskPicture->transform) || pDstPicture->transform) {
+ xf86DrvMsg(0, 0, "CC: src tr %p msk %p dst %p !!!!!!!!!!!!!!!\n",
+ pSrcPicture->transform,
+ pMaskPicture ? pMaskPicture->transform : 0,
+ pDstPicture->transform);
+ }
+
+ return FALSE;
+}
+
+static Bool
+XGIPrepareComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
+ PicturePtr pDstPicture, PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum];
+ XGIPtr pXGI = XGIPTR(pScrn);
+
+ PACCELDEBUG(ErrorF("XGIPrepareComposite()...\n"));
+ /* DisableDrawingFunctionDynamically(TRUE); */
+
+ Volari_ResetCmd ;
+
+ return FALSE;
+}
+
+static void
+XGIComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, int dstX, int dstY,
+ int width, int height)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum];
+ XGIPtr pXGI = XGIPTR(pScrn);
+
+ PACCELDEBUG(ErrorF("XGIComposite()...\n"));
+ /* DisableDrawingFunctionDynamically(FALSE); */
+}
+
+static void
+XGIDoneComposite(PixmapPtr pDst)
+{
+}
+#endif
+
+/************************************************************************/
+/* libc memcpy() wrapper - generic */
/************************************************************************/
+static void XGI_libc_memcpy(UChar *dst, const UChar *src, int size)
+{
+ PACCELDEBUG(ErrorF("XGI_libc_memcpy()...\n"));
+ memcpy(dst, src, size);
+}
+
+extern void XGI_sse_memcpy(UChar *to, const UChar *from, int size);
+extern void XGI_builtin_memcpy_arm(UChar *to, const UChar *from, int size);
+
+void XGIMemCopyToVideoRam(XGIPtr pXGI, unsigned char *to, unsigned char *from, int size)
+{
+ int align = (ULONG)to & 31;
+ int align_size = 0;
+
+ if(align)
+ {
+ align_size = size > align ? align : size;
+
+ PDEBUG(ErrorF("XGI_libc_memcpy()...align_size=%d bytes\n", align_size));
+ XGI_libc_memcpy(to, from, align_size);
+
+ size -= align_size;
+ }
+
+ if( size > 0)
+ {
+#if defined(__arm__)
+ PDEBUG(ErrorF("XGI_builtin_memcpy_arm()...\n"));
+
+ XGI_builtin_memcpy_arm(to+align, from+align, size/4);
+
+ if(((ULONG)size & 3) )
+ {
+ PDEBUG(ErrorF("XGI_libc_memcpy...%d\n", (ULONG)size & 3));
+ XGI_libc_memcpy(to+align+(size/4)*4, from+align+(size/4)*4, (ULONG)size & 3);
+ }
+#else
+ PDEBUG(ErrorF("XGI_libc_memcpy()...\n"));
+ XGI_libc_memcpy(to+align, from+align, size);
+#endif
+ }
+}
+
+void XGIMemCopyFromVideoRam(XGIPtr pXGI, unsigned char *to, unsigned char *from, int size)
+{
+ int align = (ULONG)to & 31;
+ int align_size = 0;
+
+ if(align)
+ {
+ align_size = size > align ? align : size;
+
+ PDEBUG(ErrorF("XGI_libc_memcpy()...align_size=%d bytes\n", align_size));
+ XGI_libc_memcpy(to, from, align_size);
+
+ size -= align_size;
+ }
+
+ if( size > 0)
+ {
+#if defined(__arm__)
+ PDEBUG(ErrorF("XGI_builtin_memcpy_arm()...\n"));
+ XGI_builtin_memcpy_arm(to+align, from+align, size/4);
+
+ if(((ULONG)size & 3) )
+ {
+ PDEBUG(ErrorF("XGI_libc_memcpy...%d\n", (ULONG)size & 3));
+ XGI_libc_memcpy(to+align+(size/4)*4, from+align+(size/4)*4, (ULONG)size & 3);
+ }
+#else
+ PDEBUG(ErrorF("XGI_libc_memcpy()...\n"));
+ XGI_libc_memcpy(to+align, from+align, size);
+#endif
+ }
+}
+
+Bool
+XGIUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, char *src, int src_pitch)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum];
+ XGIPtr pXGI = XGIPTR(pScrn);
+ unsigned char *dst = pDst->devPrivate.ptr;
+ int dst_pitch = exaGetPixmapPitch(pDst);
+
+ int width = w;
+ int height = h;
+
+ unsigned char * to;
+ unsigned char * from;
+ int size;
+
+ PACCELDEBUG(ErrorF("XGIUploadToScreen(dst=0x%x, x=%d, y=%d, w=%d, h=%d, src=0x%x, src_pitch=%d)...\n",
+ dst, x, y, w, h, src, src_pitch));
+ /* DisableDrawingFunctionDynamically(TRUE); */
+
+ Volari_Sync(pScrn);
+ DisableDrawingFunctionDynamically(TRUE);
+
+ if(pDst->drawable.bitsPerPixel < 8)
+ return FALSE;
+
+ dst += (x * pDst->drawable.bitsPerPixel / 8) + (y * dst_pitch);
+
+ size = src_pitch < dst_pitch ? src_pitch : dst_pitch;
+
+ int BytePerPixel = pDst->drawable.bitsPerPixel / 8;
+
+ /* DisableDrawingFunctionDynamically(TRUE); */
+
+ /* Jong Lin; It would be wrong if (x,y) != (0,0) */
+ if((dst_pitch == src_pitch) && (dst_pitch/BytePerPixel == w) && (x == 0) && (y == 0))
+ {
+ XGIMemCopyToVideoRam(pXGI, dst, (unsigned char *)src,
+ w*(pDst->drawable.bitsPerPixel/8)*h);
+ }
+ else
+ {
+ while(h--) {
+ XGIMemCopyToVideoRam(pXGI, dst, (unsigned char *)src,
+ (w * pDst->drawable.bitsPerPixel / 8));
+
+ src += src_pitch;
+ dst += dst_pitch;
+ }
+ }
+
+ return TRUE;
+}
+
+Bool
+XGIUploadToScratch(PixmapPtr pSrc, PixmapPtr pDst)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pSrc->drawable.pScreen->myNum];
+ XGIPtr pXGI = XGIPTR(pScrn);
+ unsigned char *src, *dst;
+ int src_pitch = exaGetPixmapPitch(pSrc);
+ int dst_pitch, size, w, h, bytes;
+
+ DisableDrawingFunctionDynamically(TRUE);
+
+ w = pSrc->drawable.width;
+
+#ifdef XGIISXORGPOST70
+ dst_pitch = ((w * (pSrc->drawable.bitsPerPixel >> 3)) +
+ pXGI->EXADriverPtr->pixmapPitchAlign - 1) &
+ ~(pXGI->EXADriverPtr->pixmapPitchAlign - 1);
+#else
+ dst_pitch = ((w * (pSrc->drawable.bitsPerPixel >> 3)) +
+ pXGI->EXADriverPtr->card.pixmapPitchAlign - 1) &
+ ~(pXGI->EXADriverPtr->card.pixmapPitchAlign - 1);
+#endif
+
+ size = dst_pitch * pSrc->drawable.height;
+
+ if(size > pXGI->exa_scratch->size)
+ return FALSE;
+
+
+#ifdef XGIISXORGPOST70
+ pXGI->exa_scratch_next = (pXGI->exa_scratch_next +
+ pXGI->EXADriverPtr->pixmapOffsetAlign - 1) &
+ ~(pXGI->EXADriverPtr->pixmapOffsetAlign - 1);
+#else
+ pXGI->exa_scratch_next = (pXGI->exa_scratch_next +
+ pXGI->EXADriverPtr->card.pixmapOffsetAlign - 1) &
+ ~(pXGI->EXADriverPtr->card.pixmapOffsetAlign - 1);
+#endif
+
+ if(pXGI->exa_scratch_next + size >
+ pXGI->exa_scratch->offset + pXGI->exa_scratch->size) {
+#ifdef XGIISXORGPOST70
+ (pXGI->EXADriverPtr->WaitMarker)(pSrc->drawable.pScreen, 0);
+#else
+ (pXGI->EXADriverPtr->accel.WaitMarker)(pSrc->drawable.pScreen, 0);
+#endif
+ pXGI->exa_scratch_next = pXGI->exa_scratch->offset;
+ }
+
+ memcpy(pDst, pSrc, sizeof(*pDst));
+ pDst->devKind = dst_pitch;
+#ifdef XGIISXORGPOST70
+ pDst->devPrivate.ptr = pXGI->EXADriverPtr->memoryBase + pXGI->exa_scratch_next;
+#else
+ pDst->devPrivate.ptr = pXGI->EXADriverPtr->card.memoryBase + pXGI->exa_scratch_next;
+#endif
+
+ pXGI->exa_scratch_next += size;
+
+ src = pSrc->devPrivate.ptr;
+ src_pitch = exaGetPixmapPitch(pSrc);
+ dst = pDst->devPrivate.ptr;
+
+ bytes = (src_pitch < dst_pitch) ? src_pitch : dst_pitch;
+
+ h = pSrc->drawable.height;
+
+ Volari_Sync(pScrn);
+
+ while(h--) {
+ XGIMemCopyToVideoRam(pXGI, dst, src, size);
+ src += src_pitch;
+ dst += dst_pitch;
+ }
+
+ return TRUE;
+}
+
+Bool
+XGIDownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h, char *dst, int dst_pitch)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pSrc->drawable.pScreen->myNum];
+ XGIPtr pXGI = XGIPTR(pScrn);
+ unsigned char *src = pSrc->devPrivate.ptr;
+ int src_pitch = exaGetPixmapPitch(pSrc);
+ int size = src_pitch < dst_pitch ? src_pitch : dst_pitch;
+
+ /* Jong 02/13/2009; quit X while opening console terminal */
+ /* return(FALSE); */
+ /* DisableDrawingFunctionDynamically(TRUE); */
+
+ Volari_Sync(pScrn);
+ DisableDrawingFunctionDynamically(TRUE);
+
+ if(pSrc->drawable.bitsPerPixel < 8)
+ return FALSE;
+
+ src += (x * pSrc->drawable.bitsPerPixel / 8) + (y * src_pitch);
+
+ int BytePerPixel = pSrc->drawable.bitsPerPixel / 8;
+
+ /* DisableDrawingFunctionDynamically(TRUE); */
+
+ if((src_pitch == dst_pitch) && (dst_pitch/BytePerPixel == w) && (x == 0) && (y == 0))
+ {
+ PDEBUG(ErrorF("src_pitch == dst_pitch...\n"));
+ XGIMemCopyFromVideoRam(pXGI, (unsigned char *)dst, src,
+ (w * pSrc->drawable.bitsPerPixel / 8)*h);
+ }
+ else
+ {
+ while(h--) {
+ XGIMemCopyFromVideoRam(pXGI, (unsigned char *)dst, src,
+ (w * pSrc->drawable.bitsPerPixel / 8));
+ src += src_pitch;
+ dst += dst_pitch;
+ }
+ }
+
+ return TRUE;
+}
+
+void XGIScratchSave(ScreenPtr pScreen, ExaOffscreenArea *area)
+{
+ XGIPtr pXGI = XGIPTR(xf86Screens[pScreen->myNum]);
+ pXGI->exa_scratch = NULL;
+}
+#endif /* EXA */
+
+/* Jong@08112009 */
+void XGIDumpCMDQueue(ScrnInfoPtr pScrn)
+{
+ XGIPtr pXGI = XGIPTR(pScrn);
+
+ int i ;
+ unsigned long SwWP ;
+
+ ErrorF("----------------------------------------------------------------------\n") ;
+ ErrorF("CMD Queue\n") ;
+ ErrorF("----------------------------------------------------------------------\n") ;
+
+ SwWP = Volari_GetSwWP() ;
+ ErrorF("SwWP=0x%x\n", SwWP) ;
+ ErrorF("pXGI->cmdQueueBase=0x%x\n", pXGI->cmdQueueBase) ;
+ for( i = 0 ; i < SwWP ; i+=0x04 )
+ {
+ ErrorF("[%04X]: %08lX\n",i, *(CARD32 *)(pXGI->cmdQueueBase+i));
+ }
+}
+
+/* Jong@09182009; test for line missing */
+static void Volari_SetupForSolidLine(ScrnInfoPtr pScrn, int color, int rop,
+ unsigned int planemask)
+{
+ PDEBUG(ErrorF("Null - Volari_SetupForSolidLine()...\n"));
+}
+
+static void Volari_SubsequentSolidTwoPointLine(ScrnInfoPtr pScrn,
+ int x1, int y1, int x2, int y2, int flags)
+{
+ PDEBUG(ErrorF("Null - Volari_SubsequentSolidTwoPointLine()...\n"));
+}
+static void Volari_SubsequentSolidHorzVertLine(ScrnInfoPtr pScrn,
+ int x, int y, int len, int dir)
+{
+ PDEBUG(ErrorF("Null - Volari_SubsequentSolidHorzVertLine()...\n"));
+}
+
+static void Volari_SetupForDashedLine(ScrnInfoPtr pScrn,
+ int fg, int bg, int rop, unsigned int planemask,
+ int length, unsigned char *pattern)
+{
+ PDEBUG(ErrorF("Null - Volari_SetupForDashedLine()...\n"));
+}
+
+static void Volari_SubsequentDashedTwoPointLine(ScrnInfoPtr pScrn,
+ int x1, int y1, int x2, int y2,
+ int flags, int phase)
+{
+ PDEBUG(ErrorF("Null - Volari_SubsequentDashedTwoPointLine()...\n"));
+}
+
+static void Volari_SetClippingRectangle(ScrnInfoPtr pScrn, int x1, int y1, int x2, int y2)
+{
+ PDEBUG(ErrorF("Null - Volari_SetClippingRectangle()...\n"));
+}
+
+static void Volari_DisableClipping(ScrnInfoPtr pScrn)
+{
+ PDEBUG(ErrorF("Null - Volari_DisableClipping()...\n"));
+}
diff --git a/src/xgi_accel.h b/src/xgi_accel.h index a0fa9f5..5a75bd7 100644 --- a/src/xgi_accel.h +++ b/src/xgi_accel.h @@ -117,7 +117,6 @@ #define BandSize 0x10 /* Jong 09/27/2007; recover for compiler error */ -typedef unsigned long ulong ; /* typedef unsigned long ulong ; */ unsigned long r_port, w_port ; @@ -133,25 +132,27 @@ extern void Volari_Idle(XGIPtr pXGI); #define Volari_GetSwWP() (unsigned long)(*(pXGI->pCQ_shareWritePort)) #define Volari_GetHwRP() (unsigned long)(MMIO_IN32(pXGI->IOBase, 0x85c8)) +void XGIDumpCMDQueue(ScrnInfoPtr pScrn);
+ #define Volari_SyncWP\ {\ unsigned long p ;\ \ p = *(pXGI->pCQ_shareWritePort);\ - PDEBUG4(ErrorF("Volari_SyncWP(%08lx)\n",(p)));\ + PACCELDEBUG(ErrorF("Volari_SyncWP(%08lx)\n",(p)));\ MMIO_OUT32(pXGI->IOBase, 0x85c4,(p)) ;\ } #define Volari_UpdateHwWP(p)\ {\ - PDEBUG4(ErrorF("Volari_UpdateHwWP(%08lx)\n",(p)));\ + PACCELDEBUG(ErrorF("Volari_UpdateHwWP(%08lx)\n",(p)));\ *(pXGI->pCQ_shareWritePort) = (p) ;\ MMIO_OUT32(pXGI->IOBase, 0x85c4, (p)) ;\ } #define Volari_UpdateSwWP(p)\ {\ - PDEBUG4(ErrorF("Volari_UpdateSwWP(%08lx)\n",(p)));\ + PACCELDEBUG(ErrorF("Volari_UpdateSwWP(%08lx)\n",(p)));\ *(pXGI->pCQ_shareWritePort) = (p) ;\ } @@ -234,7 +235,7 @@ extern void Volari_Idle(XGIPtr pXGI); {\ unsigned long ulTemp ;\ \ - PDEBUG4(ErrorF("pXGI->CommandReg = %08lX\n", pXGI->CommandReg));\ + PACCELDEBUG(ErrorF("pXGI->CommandReg = %08lX\n", pXGI->CommandReg));\ \ ulTemp = Volari_GetSwWP() ;\ \ @@ -268,6 +269,9 @@ extern void Volari_Idle(XGIPtr pXGI); {\ unsigned long ulTemp ;\ \ + if(base != g_srcbase) \ + { \ + g_srcbase = base; \ ulTemp = Volari_GetSwWP() ;\ \ *(CARD32 *)(pXGI->cmdQueueBase+ulTemp) = \ @@ -286,7 +290,7 @@ extern void Volari_Idle(XGIPtr pXGI); ulTemp += 0x08 ;\ ulTemp &= pXGI->cmdQueueSizeMask ;\ Volari_UpdateSwWP(ulTemp) ;\ - \ + } \ } @@ -301,6 +305,9 @@ extern void Volari_Idle(XGIPtr pXGI); #define Volari_SetupSRCPitch(pitch) \ {\ unsigned long ulTemp ;\ + if(pitch != g_SrcPitch) \ + { \ + g_SrcPitch = pitch; \ \ ulTemp = Volari_GetSwWP() ;\ \ @@ -320,6 +327,7 @@ extern void Volari_Idle(XGIPtr pXGI); ulTemp += 0x08 ;\ ulTemp &= pXGI->cmdQueueSizeMask ;\ Volari_UpdateSwWP(ulTemp) ;\ + } \ \ } @@ -334,6 +342,10 @@ extern void Volari_Idle(XGIPtr pXGI); {\ unsigned long ulTemp ;\ \ + if((x != g_src_x) || (y != g_src_y)) \ + { \ + g_src_x = x; \ + g_src_y = y; \ ulTemp = Volari_GetSwWP() ;\ \ *(CARD32 *)(pXGI->cmdQueueBase+ulTemp) = \ @@ -352,7 +364,7 @@ extern void Volari_Idle(XGIPtr pXGI); ulTemp += 0x08 ;\ ulTemp &= pXGI->cmdQueueSizeMask ;\ Volari_UpdateSwWP(ulTemp) ;\ - \ + } \ } /*********************************************************************** @@ -367,6 +379,9 @@ extern void Volari_Idle(XGIPtr pXGI); {\ unsigned long ulTemp ;\ \ + if(base != g_dstbase) \ + { \ + g_dstbase=base; \ ulTemp = Volari_GetSwWP() ;\ \ *(CARD32 *)(pXGI->cmdQueueBase+ulTemp) = \ @@ -385,7 +400,7 @@ extern void Volari_Idle(XGIPtr pXGI); ulTemp += 0x08 ;\ ulTemp &= pXGI->cmdQueueSizeMask ;\ Volari_UpdateSwWP(ulTemp) ;\ - \ + } \ } /*********************************************************************** @@ -400,6 +415,10 @@ extern void Volari_Idle(XGIPtr pXGI); {\ unsigned long ulTemp ;\ \ + if((x != g_dst_x) || (y != g_dst_y)) \ + { \ + g_dst_x = x; \ + g_dst_y = y; \ ulTemp = Volari_GetSwWP() ;\ \ *(CARD32 *)(pXGI->cmdQueueBase+ulTemp) = \ @@ -418,7 +437,7 @@ extern void Volari_Idle(XGIPtr pXGI); ulTemp += 0x08 ;\ ulTemp &= pXGI->cmdQueueSizeMask ;\ Volari_UpdateSwWP(ulTemp) ;\ - \ + } \ } /*********************************************************************** @@ -433,6 +452,10 @@ extern void Volari_Idle(XGIPtr pXGI); {\ unsigned long ulTemp ;\ \ + if( (x != g_DstRectX) || (y != g_DstRectY)) \ + { \ + g_DstRectX = x; \ + g_DstRectY = y; \ ulTemp = Volari_GetSwWP() ;\ \ *(CARD32 *)(pXGI->cmdQueueBase+ulTemp) = \ @@ -452,6 +475,7 @@ extern void Volari_Idle(XGIPtr pXGI); ulTemp &= pXGI->cmdQueueSizeMask ;\ Volari_UpdateSwWP(ulTemp) ;\ Volari_UpdateHwWP(ulTemp) ;\ + } \ \ } @@ -476,6 +500,10 @@ extern void Volari_Idle(XGIPtr pXGI); {\ unsigned long ulTemp ;\ \ + if( (w != g_width) || (h != g_height)) \ + { \ + g_width = w; \ + g_height = h; \ ulTemp = Volari_GetSwWP() ;\ \ *(CARD32 *)(pXGI->cmdQueueBase+ulTemp) = \ @@ -494,7 +522,7 @@ extern void Volari_Idle(XGIPtr pXGI); ulTemp += 0x08 ;\ ulTemp &= pXGI->cmdQueueSizeMask ;\ Volari_UpdateSwWP(ulTemp) ;\ - \ + } \ } /*********************************************************************** @@ -526,6 +554,9 @@ extern void Volari_Idle(XGIPtr pXGI); {\ unsigned long ulTemp ;\ \ + if( color != g_MonoPatFgColor) \ + { \ + g_MonoPatFgColor = color; \ ulTemp = Volari_GetSwWP() ;\ \ *(CARD32 *)(pXGI->cmdQueueBase+ulTemp) = \ @@ -545,6 +576,7 @@ extern void Volari_Idle(XGIPtr pXGI); ulTemp &= pXGI->cmdQueueSizeMask ;\ Volari_UpdateSwWP(ulTemp) ;\ Volari_UpdateHwWP(ulTemp) ;\ + } \ \ } @@ -552,6 +584,9 @@ extern void Volari_Idle(XGIPtr pXGI); {\ unsigned long ulTemp ;\ \ + if( color != g_MonoPatBgColor) \ + { \ + g_MonoPatBgColor = color; \ ulTemp = Volari_GetSwWP() ;\ \ *(CARD32 *)(pXGI->cmdQueueBase+ulTemp) = \ @@ -570,6 +605,7 @@ extern void Volari_Idle(XGIPtr pXGI); ulTemp += 0x08 ;\ ulTemp &= pXGI->cmdQueueSizeMask ;\ Volari_UpdateSwWP(ulTemp) ;\ + } \ \ } @@ -818,6 +854,10 @@ extern void Volari_Idle(XGIPtr pXGI); {\ unsigned long ulTemp ;\ \ + if((x != g_src_y) || (y != g_src_x)) \ + { \ + g_src_x = y; \ + g_src_y = x; \ ulTemp = Volari_GetSwWP() ;\ \ *(CARD32 *)(pXGI->cmdQueueBase+ulTemp) = \ @@ -836,13 +876,17 @@ extern void Volari_Idle(XGIPtr pXGI); ulTemp += 0x08 ;\ ulTemp &= pXGI->cmdQueueSizeMask ;\ Volari_UpdateSwWP(ulTemp) ;\ - \ + } \ } #define Volari_SetupX1Y1(x,y) \ {\ unsigned long ulTemp ;\ \ + if((x != g_dst_y) || (y != g_dst_x)) \ + { \ + g_dst_x = y; \ + g_dst_y = x; \ ulTemp = Volari_GetSwWP() ;\ \ *(CARD32 *)(pXGI->cmdQueueBase+ulTemp) = \ @@ -861,7 +905,7 @@ extern void Volari_Idle(XGIPtr pXGI); ulTemp += 0x08 ;\ ulTemp &= pXGI->cmdQueueSizeMask ;\ Volari_UpdateSwWP(ulTemp) ;\ - \ + } \ } #define Volari_SetupLineCount(c) \ @@ -870,6 +914,9 @@ extern void Volari_Idle(XGIPtr pXGI); \ ulTemp = Volari_GetSwWP() ;\ \ + if(c != g_width) \ + { \ + g_width = c; \ *(CARD32 *)(pXGI->cmdQueueBase+ulTemp) = \ (CARD32)BE_SWAP32(GR_SKPC_HEADER + BR(6) + 0x30000 ) ;\ *(CARD32 *)(pXGI->cmdQueueBase+ulTemp+4) =\ @@ -886,13 +933,16 @@ extern void Volari_Idle(XGIPtr pXGI); ulTemp += 0x08 ;\ ulTemp &= pXGI->cmdQueueSizeMask ;\ Volari_UpdateSwWP(ulTemp) ;\ - \ + } \ } #define Volari_SetupStylePeriod(p) \ {\ unsigned long ulTemp ;\ \ + if(p != g_height) \ + { \ + g_height = c; \ ulTemp = Volari_GetSwWP() ;\ \ *(CARD32 *)(pXGI->cmdQueueBase+ulTemp) = \ @@ -911,13 +961,17 @@ extern void Volari_Idle(XGIPtr pXGI); ulTemp += 0x08 ;\ ulTemp &= pXGI->cmdQueueSizeMask ;\ Volari_UpdateSwWP(ulTemp) ;\ - \ + } \ } #define Volari_SetupStylePeriodCount(p,c) \ {\ unsigned long ulTemp ;\ \ + if((c != g_width) || (p != g_height)) \ + { \ + g_width = c; \ + g_height = p; \ ulTemp = Volari_GetSwWP() ;\ \ *(CARD32 *)(pXGI->cmdQueueBase+ulTemp) = \ @@ -936,7 +990,7 @@ extern void Volari_Idle(XGIPtr pXGI); ulTemp += 0x08 ;\ ulTemp &= pXGI->cmdQueueSizeMask ;\ Volari_UpdateSwWP(ulTemp) ;\ - \ + } \ } #define Volari_SetupStyle(ls,hs) \ diff --git a/src/xgi_cursor.c b/src/xgi_cursor.c index 2d5d8c6..2c7fedd 100644 --- a/src/xgi_cursor.c +++ b/src/xgi_cursor.c @@ -86,7 +86,9 @@ Volari_ShowCursor(ScrnInfoPtr pScrn) } XGIG1_SetCursorPosition(pScrn, currX, currY) ; - XGI_WaitEndRetrace(pXGI->RelIO); + + /* Jong 02/05/2009; improve performance of WinBench 99 */ + /* XGI_WaitEndRetrace(pXGI->RelIO); */ } static void @@ -99,8 +101,11 @@ Volari_HideCursor(ScrnInfoPtr pScrn) if (pXGI->VBFlags & CRT2_ENABLE) { xgiG1CRT2_DisableHWCursor() ; } + XGIG1_SetCursorPosition(pScrn, currX, currY) ; - XGI_WaitEndRetrace(pXGI->RelIO); + + /* Jong 02/05/2009; improve performance of WinBench 99 */ + /* XGI_WaitEndRetrace(pXGI->RelIO); */ } static void diff --git a/src/xgi_cursor.h b/src/xgi_cursor.h index 64bb87f..5b963dc 100644 --- a/src/xgi_cursor.h +++ b/src/xgi_cursor.h @@ -59,12 +59,12 @@ #define xgiG1CRT1_SetCursorPositionX(x,preset)\ {\ - XGIMMIOLONG(0x850C) = BE_SWAP32((x) | ((preset)>>16));\ + XGIMMIOLONG(0x850C) = BE_SWAP32((x) | ((preset)<<16));\ } #define xgiG1CRT1_SetCursorPositionY(y,preset)\ {\ - XGIMMIOLONG(0x8510) =BE_SWAP32((y) | ((preset)>>16));\ + XGIMMIOLONG(0x8510) =BE_SWAP32((y) | ((preset)<<16));\ } /* Jill, read MMIO need swap, 2006/6/22*/ diff --git a/src/xgi_dac.c b/src/xgi_dac.c index 3f21143..e07498f 100644 --- a/src/xgi_dac.c +++ b/src/xgi_dac.c @@ -47,7 +47,7 @@ #include "xf86.h" #include "xf86_OSproc.h" -#include "xorgVersion.h" +#include "xf86Version.h" #include "xf86PciInfo.h" #include "xf86Pci.h" #include "xf86DDC.h" @@ -306,13 +306,22 @@ Volari_Save(ScrnInfoPtr pScrn, XGIRegPtr xgiReg) vgaHWGetIOBase(VGAHWPTR(pScrn)); vgaIOBase = VGAHWPTR(pScrn)->IOBase; +#if !defined(__arm__)
outw(VGA_SEQ_INDEX, 0x8605); +#else + moutl(XGISR, 0x8605); +#endif for (i = 0x06; i <= 0x3F; i++) { - outb(VGA_SEQ_INDEX, i); - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, + /* outb(VGA_SEQ_INDEX, i); */ + outb(XGISR, i); + + /* xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, "XR%02X Contents - %02X \n", i, inb(VGA_SEQ_DATA)); - xgiReg->xgiRegs3C4[i] = inb(VGA_SEQ_DATA); + xgiReg->xgiRegs3C4[i] = inb(VGA_SEQ_DATA); */ + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, + "XR%02X Contents - %02X \n", i, inb(XGISR+1)); + xgiReg->xgiRegs3C4[i] = inb(XGISR+1); } for (i=0x19; i<0x5C; i++) { @@ -326,6 +335,7 @@ Volari_Save(ScrnInfoPtr pScrn, XGIRegPtr xgiReg) for (i=0x19; i<0x5C; i++) { inXGIIDXREG(XGICR, i, xgiReg->xgiRegs3D4[i]); } + // yilin save the VB register outXGIIDXREG(XGIPART1, 0x2f, 0x01); @@ -346,7 +356,6 @@ Volari_Save(ScrnInfoPtr pScrn, XGIRegPtr xgiReg) inXGIIDXREG(XGIPART4, i, xgiReg->VBPart4[i]); } - PDEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "Volari_Save(ScrnInfoPtr pScrn, XGIRegPtr xgiReg) Done\n")); @@ -368,8 +377,10 @@ Volari_Restore(ScrnInfoPtr pScrn, XGIRegPtr xgiReg) outXGIIDXREG(XGISR, 0x05, 0x86); + #if 1 -/* Volari_DisableAccelerator(pScrn) ; */ + /* Jong@08112009; recover this line */ + /* Volari_DisableAccelerator(pScrn) ; */ #else inXGIIDXREG(XGISR, 0x1E, temp); @@ -398,19 +409,31 @@ Volari_Restore(ScrnInfoPtr pScrn, XGIRegPtr xgiReg) for (i = 0x06; i <= 0x3F; i++) { /* if( !(i==0x16 || i==0x18 || i==0x19 || i==0x28 || i==0x29 || i==0x2E || i==0x2F) ) { */ if( !(i==0x16 ) ) { - outb(VGA_SEQ_INDEX,i); - xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO,4, + /* outb(VGA_SEQ_INDEX,i); */ + outb(XGISR,i); + + /* xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO,4, "XR%X Contents - %02X ", i, inb(VGA_SEQ_DATA)); outb(VGA_SEQ_DATA,xgiReg->xgiRegs3C4[i]); xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO,4, "Restore to - %02X Read after - %02X\n", - xgiReg->xgiRegs3C4[i], inb(VGA_SEQ_DATA)); + xgiReg->xgiRegs3C4[i], inb(VGA_SEQ_DATA)); */ + + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO,4, + "XR%X Contents - %02X ", i, inb(XGISR+1)); + + outb(XGISR+1,xgiReg->xgiRegs3C4[i]); + + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO,4, + "Restore to - %02X Read after - %02X\n", + xgiReg->xgiRegs3C4[i], inb(XGISR+1)); } } +#if 0 // yilin restore the VB register outXGIIDXREG(XGIPART1, 0x2f, 0x01); for (i=0; i<0x50; i++) @@ -429,13 +452,18 @@ Volari_Restore(ScrnInfoPtr pScrn, XGIRegPtr xgiReg) { outXGIIDXREG(XGIPART4, i, xgiReg->VBPart4[i]); } - +#endif outb(pXGI->RelIO+0x42, xgiReg->xgiRegs3C2); /* MemClock needs this to take effect */ - outw(VGA_SEQ_INDEX, 0x0100); /* Synchronous Reset */ +#if !defined(__arm__)
+ outw(VGA_SEQ_INDEX, 0x0100); /* Synchronous Reset */ +#else + moutl(XGISR, 0x0100); /* Synchronous Reset */ +#endif + PDEBUG(XGIDumpRegs(pScrn)) ; //yilin xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, "Volari_Restore(ScrnInfoPtr pScrn, XGIRegPtr xgiReg) Done\n"); @@ -508,20 +536,29 @@ static int XG20_MemBandWidth(ScrnInfoPtr pScrn) inXGIIDXREG(XGISR, 0x39, SR39); inXGIIDXREG(XGICR, 0x97, CR97); - if (CR97 & 0x10) - { - if (CR97 & 0x01) + /* Jong@09082009; modify for XG27 */ + if(pXGI->Chipset == PCI_CHIP_XGIXG27) + { + if (CR97 & 0xC1) + total *= 2; + } + else /* XG20/21 */ + { + if (CR97 & 0x10) { - total *= 2; + if (CR97 & 0x01) + { + total *= 2; + } } - } - else - { - if (SR39 & 0x2) - { - total *= 2; + else + { + if (SR39 & 0x2) + { + total *= 2; + } } - } + } /*-------------------------------------------------------*/ PDEBUG5(ErrorF("Total Adapter Bandwidth is %fM\n", total/1000)); @@ -529,6 +566,40 @@ static int XG20_MemBandWidth(ScrnInfoPtr pScrn) return (int)(total / magic); } +extern unsigned int g_GammaRed; +extern unsigned int g_GammaGreen; +extern unsigned int g_GammaBlue; + +void XGIAdjustGamma(ScrnInfoPtr pScrn, unsigned int gammaRed, unsigned int gammaGreen, unsigned int gammaBlue) +{ + XGIPtr pXGI = XGIPTR(pScrn); + int num = 255, i; + double red = 1.0 / (double)((double)gammaRed / 1000); + double green = 1.0 / (double)((double)gammaGreen / 1000); + double blue = 1.0 / (double)((double)gammaBlue / 1000); + CARD8 GammaRampRed[256], GammaRampGreen[256], GammaRampBlue[256]; + + for(i = 0; i <= num; i++) { + GammaRampRed[i] = + (red == 1.0) ? i : (CARD8)(pow((double)i / (double)num, red) * (double)num + 0.5); + + GammaRampGreen[i] = + (green == 1.0) ? i : (CARD8)(pow((double)i / (double)num, green) * (double)num + 0.5); + + GammaRampBlue[i] = + (blue == 1.0) ? i : (CARD8)(pow((double)i / (double)num, blue) * (double)num + 0.5); + } + + /* set gamma ramp to HW */ + for(i = 0; i <= 255; i++) { + MMIO_OUT32(pXGI->IOBase, 0x8570, + (i << 24) | + (GammaRampBlue[i] << 16) | + (GammaRampGreen[i] << 8) | + GammaRampRed[i]); + } +} + void XGILoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, VisualPtr pVisual) @@ -624,6 +695,9 @@ PDEBUG(ErrorF("\ndogamma1 SR7=%x ", SR7)); if (!IS_DUAL_HEAD(pXGI) || !IS_SECOND_HEAD(pXGI)) { } + + if(pXGI->CurrentLayout.depth != 8) + XGIAdjustGamma(pScrn, g_GammaRed, g_GammaGreen, g_GammaBlue); } void @@ -649,11 +723,13 @@ XG40Mclk(XGIPtr pXGI) unsigned char Num, Denum; /* Numerator */ - inXGIIDXREG(0x3c4, 0x28, Num); + /* inXGIIDXREG(0x3c4, 0x28, Num); */ + inXGIIDXREG(XGISR, 0x28, Num); mclk = 14318 * ((Num & 0x7f) + 1); /* Denumerator */ - inXGIIDXREG(0x3c4, 0x29, Denum); + /* inXGIIDXREG(0x3c4, 0x29, Denum); */ + inXGIIDXREG(XGISR, 0x29, Denum); mclk = mclk / ((Denum & 0x1f) + 1); /* Divider */ diff --git a/src/xgi_dga.c b/src/xgi_dga.c index ac495c4..04f90aa 100644 --- a/src/xgi_dga.c +++ b/src/xgi_dga.c @@ -307,11 +307,13 @@ XGI_FillRect ( ){ XGIPtr pXGI = XGIPTR(pScrn); +#ifdef XGI_USE_XAA if(pXGI->AccelInfoPtr) { (*pXGI->AccelInfoPtr->SetupForSolidFill)(pScrn, color, GXcopy, ~0); (*pXGI->AccelInfoPtr->SubsequentSolidFillRect)(pScrn, x, y, w, h); SET_SYNC_FLAG(pXGI->AccelInfoPtr); } +#endif } static void @@ -320,9 +322,11 @@ XGI_Sync( ){ XGIPtr pXGI = XGIPTR(pScrn); +#ifdef XGI_USE_XAA if(pXGI->AccelInfoPtr) { (*pXGI->AccelInfoPtr->Sync)(pScrn); } +#endif } static void @@ -334,6 +338,7 @@ XGI_BlitRect( ){ XGIPtr pXGI = XGIPTR(pScrn); +#ifdef XGI_USE_XAA if(pXGI->AccelInfoPtr) { int xdir = ((srcx < dstx) && (srcy == dsty)) ? -1 : 1; int ydir = (srcy < dsty) ? -1 : 1; @@ -344,6 +349,7 @@ XGI_BlitRect( pScrn, srcx, srcy, dstx, dsty, w, h); SET_SYNC_FLAG(pXGI->AccelInfoPtr); } +#endif } static Bool diff --git a/src/xgi_dri.c b/src/xgi_dri.c index 08b58e1..d6a6d3d 100644 --- a/src/xgi_dri.c +++ b/src/xgi_dri.c @@ -66,7 +66,7 @@ #include "xgi_accel.h" #include "xgi_common.h" -#include <drm.h> +#include <drm/drm.h> extern void GlxSetVisualConfigs( int nconfigs, diff --git a/src/xgi_driver.c b/src/xgi_driver.c index 3ec7d45..2ce7279 100644 --- a/src/xgi_driver.c +++ b/src/xgi_driver.c @@ -47,10 +47,9 @@ #include "config.h"
#endif
-/* Jong 09/27/2007; added for PACKAGE_VERSION_MAJOR,... */
-#define PACKAGE_VERSION_MAJOR 1
+#define PACKAGE_VERSION_MAJOR 6
#define PACKAGE_VERSION_MINOR 1
-#define PACKAGE_VERSION_PATCHLEVEL 0
+#define PACKAGE_VERSION_PATCHLEVEL 6803
#include "fb.h"
#include "mibank.h"
@@ -58,16 +57,14 @@ #include "xf86.h"
#include "xf86Priv.h"
#include "xf86_OSproc.h"
-#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 6
#include "xf86Resources.h"
-#include "xf86RAC.h"
-#endif
#include "dixstruct.h"
-#include "xorgVersion.h"
+#include "xf86Version.h"
#include "xf86PciInfo.h"
#include "xf86Pci.h"
#include "xf86cmap.h"
#include "vgaHW.h"
+#include "xf86RAC.h"
#include "shadowfb.h"
#include "vbe.h"
@@ -87,13 +84,8 @@ #include "globals.h"
-#ifdef HAVE_XEXTPROTO_71
-#include <X11/extensions/dpmsconst.h>
-#else
#define DPMS_SERVER
#include <X11/extensions/dpms.h>
-#endif
-
#if defined(XvExtension)
#include "xf86xv.h"
@@ -108,8 +100,11 @@ #include <unistd.h>
#endif
+/* Jong 01/22/2009; compiler error; type conflict */
+/*
#include <fcntl.h>
#include <sys/ioctl.h>
+*/
#ifdef XSERVER_LIBPCIACCESS
static Bool XGIPciProbe(DriverPtr drv, int entity_num,
@@ -129,6 +124,13 @@ static int XGIEntityIndex = -1; int g_CountOfUserDefinedModes=0;
xf86MonPtr g_pMonitorDVI=NULL; /* Jong 12/04/2007; used for filtering of CRT1 modes */
+/* Jong 07/27/2009; use run-time debug instead except for HW acceleration routines */
+/* Set Option "RunTimeDebug" to "true" in X configuration file */
+BOOL g_bRunTimeDebug=0;
+
+/* Jong@09072009 */
+unsigned char g_DVI_I_SignalType = 0x00;
+
/*
* This is intentionally screen-independent. It indicates the binding
* choice made in the first PreInit.
@@ -227,6 +229,17 @@ static const char *xaaSymbols[] = { NULL
};
+#ifdef XGI_USE_EXA
+static const char *exaSymbols[] = {
+ "exaGetVersion",
+ "exaDriverInit",
+ "exaDriverFini",
+ "exaOffscreenAlloc",
+ "exaOffscreenFree",
+ NULL
+};
+#endif
+
static const char *vgahwSymbols[] = {
"vgaHWFreeHWRec",
"vgaHWGetHWRec",
@@ -443,8 +456,8 @@ static const ModeTiming StdTiming[] = { static void XGIDumpPalette(ScrnInfoPtr pScrn);
#ifdef DEBUG
-static void XGIDumpSR(ScrnInfoPtr pScrn);
-static void XGIDumpCR(ScrnInfoPtr pScrn);
+void XGIDumpSR(ScrnInfoPtr pScrn);
+void XGIDumpCR(ScrnInfoPtr pScrn);
static void XGIDumpGR(ScrnInfoPtr pScrn);
static void XGIDumpPart1(ScrnInfoPtr pScrn);
static void XGIDumpPart2(ScrnInfoPtr pScrn);
@@ -474,7 +487,13 @@ xgiSetup(pointer module, pointer opts, int *errmaj, int *errmin) if (!setupDone) {
setupDone = TRUE;
+/* Jong@09022009 */
+#if (XORG_VERSION_CURRENT > XORG_VERSION_NUMERIC(6,9,0,0,0) )
xf86AddDriver(&XGI, module, HaveDriverFuncs);
+#else
+ xf86AddDriver(&XGI, module, 0);
+#endif
+
LoaderRefSymLists(vgahwSymbols, fbSymbols, xaaSymbols,
shadowSymbols, ramdacSymbols, ddcSymbols,
vbeSymbols, int10Symbols,
@@ -591,6 +610,15 @@ XGIFreeRec(ScrnInfoPtr pScrn) pScrn->driverPrivate = NULL;
}
+/*
+ SR1F Power management register
+ D7 Force CRT1 into DPMS suspend mode
+ 0: disable
+ 1: enable
+ D6 Force CRT1 into DPMS stand-by mode
+ 0: disable
+ 1: enable
+*/
static void
XGIDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode,
int flags)
@@ -604,6 +632,18 @@ XGIDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
"XGIDisplayPowerManagementSet(%d)\n", PowerManagementMode);
+#if 1
+ PVB_DEVICE_INFO pVBInfo = pXGI->XGI_Pr;
+ PXGI_HW_DEVICE_INFO pHwDevInfo = &pXGI->xgi_HwDevExt;
+ ULONG PowerState = 0xFFFFFFFF;
+
+ if((PowerManagementMode != 0) && (PowerManagementMode <= 3))
+ PowerState = 0x00000001 << (PowerManagementMode + 7);
+ else
+ PowerState = 0x0;
+
+ XGISetDPMS(pScrn, pVBInfo, pHwDevInfo, PowerState);
+#else
if (IS_DUAL_HEAD(pXGI)) {
if (IS_SECOND_HEAD(pXGI))
docrt2 = FALSE;
@@ -618,6 +658,8 @@ XGIDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, switch (PowerManagementMode) {
case DPMSModeOn: /* HSync: On, VSync: On */
+ PDEBUG(ErrorF("!-DPMSMode-On...\n"));
+
if (docrt1)
pXGI->Blank = FALSE;
@@ -633,6 +675,8 @@ XGIDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, break;
case DPMSModeSuspend: /* HSync: On, VSync: Off */
+ PDEBUG(ErrorF("!-DPMSMode-Suspend...\n"));
+
if (docrt1)
pXGI->Blank = TRUE;
@@ -648,6 +692,8 @@ XGIDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, break;
case DPMSModeStandby: /* HSync: Off, VSync: On */
+ PDEBUG(ErrorF("!-DPMSMode-Standby...\n"));
+
if (docrt1)
pXGI->Blank = TRUE;
@@ -663,6 +709,8 @@ XGIDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, break;
case DPMSModeOff: /* HSync: Off, VSync: Off */
+ PDEBUG(ErrorF("!-DPMSMode-Off...\n"));
+
if (docrt1)
pXGI->Blank = TRUE;
@@ -703,7 +751,93 @@ XGIDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, usleep(10000);
outXGIIDXREG(XGISR, 0x00, 0x03); /* End Reset */
}
+#endif
+}
+
+typedef struct
+{
+ unsigned char name[10];
+ unsigned int DCLK;
+ unsigned int HDisplay;
+ unsigned int HSyncStart;
+ unsigned int HSyncEnd;
+ unsigned int HTotal;
+ unsigned int VDisplay;
+ unsigned int VSyncStart;
+ unsigned int VSyncEnd;
+ unsigned int VTotal;
+} XGITimingInfo;
+
+XGITimingInfo ExtraAvailableModeTiming[]= +{ + {"1440x900", + 106470, + 1440, 1520, 1672, 1904, + 900, 901, 904, 932},
+ {"1680x1050", + 146250, + 1680, 1784, 1960, 2240, + 1050, 1053, 1059, 1089},
+ {"0x0", + 106470, + 1440, 1520, 1672, 1904, + 900, 901, 904, 932}
+};
+
+int ExtraAvailableModeTimingCount = 1;
+
+void XGIAddAvailableModes(DisplayModePtr availModes)
+{
+ DisplayModePtr p;
+ DisplayModePtr q;
+ DisplayModePtr last;
+ DisplayModePtr first;
+ int i;
+
+ /* Scan to last node */
+ for (q = availModes; q != NULL; q = q->next){
+ last = q;
+ }
+
+ /* first = availModes->next; */
+
+ /* Add all modes of ExtraAvailableModeTiming[] */
+ for(i=0; /* i < ExtraAvailableModeTimingCount */ xf86NameCmp(ExtraAvailableModeTiming[i].name, "0x0") != 0 ; i++)
+ {
+ p = xnfcalloc(1, sizeof(DisplayModeRec));
+
+ p->prev = last;
+ p->next = NULL;
+ last->next = p;
+
+ /*
+ first->next->prev = p;
+ p->prev = first;
+ p->next = first->next;
+ first->next = p;
+ */
+
+ p->name = xnfalloc(strlen(ExtraAvailableModeTiming[i].name) + 1);
+ p->name = ExtraAvailableModeTiming[i].name;
+ p->status = MODE_OK;
+
+ p->type = M_T_CLOCK_CRTC_C /* M_T_BUILTIN */ /* M_T_USERDEF */ ;
+ p->Clock = ExtraAvailableModeTiming[i].DCLK;
+ p->HDisplay = ExtraAvailableModeTiming[i].HDisplay;
+ p->HSyncStart = ExtraAvailableModeTiming[i].HSyncStart;
+ p->HSyncEnd = ExtraAvailableModeTiming[i].HSyncEnd;
+ p->HTotal = ExtraAvailableModeTiming[i].HTotal;
+
+ p->VDisplay = ExtraAvailableModeTiming[i].VDisplay;
+ p->VSyncStart = ExtraAvailableModeTiming[i].VSyncStart;
+ p->VSyncEnd = ExtraAvailableModeTiming[i].VSyncEnd;
+ p->VTotal = ExtraAvailableModeTiming[i].VTotal;
+
+ p->Flags = 5;
+
+ last = p;
+ }
}
/* Mandatory */
@@ -902,6 +1036,8 @@ XGICopyModeNLink(ScrnInfoPtr pScrn, DisplayModePtr dest, DisplayModePtr mode;
int dx = 0, dy = 0;
+ ErrorF("XGICopyModeNLink()...Use Virtual Size-1\n");
+
if (!((mode = xalloc(sizeof(DisplayModeRec)))))
return dest;
memcpy(mode, i, sizeof(DisplayModeRec));
@@ -1233,6 +1369,7 @@ XGIRecalcDefaultVirtualSize(ScrnInfoPtr pScrn) int max;
static const char *str = "MergedFB: Virtual %s %d\n";
+ ErrorF("XGIRecalcDefaultVirtualSize()...Update Virtual Size-1\n");
if (!(pScrn->display->virtualX)) {
mode = bmode = pScrn->modes;
max = 0;
@@ -1243,6 +1380,7 @@ XGIRecalcDefaultVirtualSize(ScrnInfoPtr pScrn) } while (mode != bmode);
pScrn->virtualX = max;
pScrn->displayWidth = max;
+ ErrorF("XGIRecalcDefaultVirtualSize()...Update Virtual Size-2-pScrn->virtualX=%d\n", pScrn->virtualX);
xf86DrvMsg(pScrn->scrnIndex, X_PROBED, str, "width", max);
}
if (!(pScrn->display->virtualY)) {
@@ -1268,6 +1406,8 @@ XGIMergedFBSetDpi(ScrnInfoPtr pScrn1, ScrnInfoPtr pScrn2, XGIScrn2Rel srel) int ddcWidthmm = 0, ddcHeightmm = 0;
const char *dsstr = "MergedFB: Display dimensions: (%d, %d) mm\n";
+ ErrorF("XGIMergedFBSetDpi()...Use Virtual Size -1\n");
+
/* This sets the DPI for MergedFB mode. The problem is that
* this can never be exact, because the output devices may
* have different dimensions. This function tries to compromise
@@ -1454,7 +1594,21 @@ XGIInternalDDC(ScrnInfoPtr pScrn, int crtno) crtno_means_str[crtno]);
}
- if (xf86LoadSubModule(pScrn, "int10")) {
+/* Jong 08/03/2009; get EDID with I2C function instead of VBIOS call */
+#if 1
+ ErrorF("get EDID with I2C function instead of VBIOS call...\n");
+
+ PXGI_HW_DEVICE_INFO pHwDevInfo = &pXGI->xgi_HwDevExt;
+ PUCHAR pjEDIDBuffer = buffer;
+ ULONG ulBufferSize = 256;
+
+ pHwDevInfo->crtno = crtno;
+ int bEDID = bGetEDID(pHwDevInfo, crtno, pjEDIDBuffer, ulBufferSize);
+
+#else
+ ErrorF("get EDID with VBIOS call...\n");
+ if (xf86LoadSubModule(pScrn, "int10"))
+ {
xf86LoaderReqSymLists(int10Symbols, NULL);
pInt = xf86InitInt10(pXGI->pEnt->index);
if (pInt == NULL) {
@@ -1472,7 +1626,8 @@ XGIInternalDDC(ScrnInfoPtr pScrn, int crtno) }
}
- if (pInt) {
+ if (pInt)
+ {
pInt->ax = 0x4f15; /* VESA DDC supporting */
pInt->bx = 1; /* get EDID */
pInt->cx = crtno; /* port 0 or 1 for CRT 1 or 2 */
@@ -1485,18 +1640,25 @@ XGIInternalDDC(ScrnInfoPtr pScrn, int crtno) ("ax = %04X bx = %04X cx = %04X dx = %04X si = %04X di = %04X es = %04X\n",
pInt->ax, pInt->bx, pInt->cx, pInt->dx, pInt->si, pInt->di,
pInt->es));
+#endif
- if ((pInt->ax & 0xff00) == 0) {
+#if 0
+ if ((pInt->ax & 0xff00) == 0)
+ {
int i;
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "XGIInternalDDC(): VESA get DDC success for CRT %d.\n",
- crtno + 1);
for (i = 0; i < 128; i++) {
buffer[i] = page[i];
}
+#else /* Jong 08/03/2009; get EDID with I2C function instead of VBIOS call */
+ if(bEDID == 1)
+ {
+ int i;
+#endif
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "XGIInternalDDC(): VESA get DDC success for output channel %d.\n",
+ crtno + 1);
-#ifdef DEBUG5
for (i = 0; i < 128; i += 16) {
unsigned j;
ErrorF("EDID[%02X]", i);
@@ -1505,13 +1667,15 @@ XGIInternalDDC(ScrnInfoPtr pScrn, int crtno) }
ErrorF("\n");
}
-#endif /* DEBUG3 */
+
+ g_DVI_I_SignalType = (buffer[20] & 0x80) >> 7;
+ ErrorF("DVI-I : %s signal ...\n", (g_DVI_I_SignalType == 0x01) ? "DVI" : "CRT" );
xf86LoaderReqSymLists(ddcSymbols, NULL);
- /* Jong 09/04/2007; Alan fixed abnormal EDID data */
- /* pMonitor = xf86InterpretEDID(pScrn->scrnIndex, buffer) ; */
- if ( (buffer[0]==0) && (buffer[7]==0) )
+ /* Jong 09/04/2007; Alan fixed abnormal EDID data */
+ /* pMonitor = xf86InterpretEDID(pScrn->scrnIndex, buffer) ; */
+ if ( (buffer[0]==0) && (buffer[7]==0) )
{
for (i=1;i<7;i++)
{
@@ -1533,13 +1697,17 @@ XGIInternalDDC(ScrnInfoPtr pScrn, int crtno) }
else {
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
- "XGIInternalDDC(): VESA get DDC fail for CRT %d.\n",
+ "XGIInternalDDC(): VESA get DDC fail for output channel %d.\n",
crtno + 1);
}
+/* Jong 08/03/2009; get EDID with I2C function instead of VBIOS call */
+#if 0
xf86Int10FreePages(pInt, page, 1);
xf86FreeInt10(pInt);
}
+#endif
+
return pMonitor;
}
@@ -1967,6 +2135,15 @@ XGISyncDDCMonitorRange(MonPtr monitor, MonitorRangePtr range) return;
}
+ monitor->nHsync++;
+ monitor->nVrefresh++;
+
+#if 1
+ monitor->hsync[monitor->nHsync-1].lo = range->loH;
+ monitor->hsync[monitor->nHsync-1].hi = range->hiH;
+ monitor->vrefresh[monitor->nVrefresh-1].lo = range->loV;
+ monitor->vrefresh[monitor->nVrefresh-1].hi = range->hiV;
+#else
for (i = 0; i < monitor->nHsync; i++) {
monitor->hsync[i].lo = range->loH;
monitor->hsync[i].hi = range->hiH;
@@ -1976,17 +2153,34 @@ XGISyncDDCMonitorRange(MonPtr monitor, MonitorRangePtr range) monitor->vrefresh[i].lo = range->loV;
monitor->vrefresh[i].hi = range->hiV;
}
+#endif
}
+/* Jong@08212009; defined in vb_ext.c */
+extern void XGIPowerSaving(PVB_DEVICE_INFO pVBInfo, UCHAR PowerSavingStatus);
+UCHAR g_PowerSavingStatus = 0x00; +
static void
XGIDDCPreInit(ScrnInfoPtr pScrn)
{
XGIPtr pXGI = XGIPTR(pScrn);
xf86MonPtr pMonitor = NULL;
+ xf86MonPtr pMonitorCRT1 = NULL;
xf86MonPtr pMonitorDVI = NULL;
+ xf86MonPtr pMonitorCRT2 = NULL;
Bool didddc2;
+ UCHAR PowerSavingStatus = 0xFF; /* 0x00; */
+
+ if(pXGI->IgnoreDDC)
+ {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Ignore DDC detection --> No EDID info...turn on all DAC and DVO\n");
+ XGIPowerSaving(pXGI->XGI_Pr, 0x00);
+ return;
+ }
+
static const char *ddcsstr =
"CRT%d DDC monitor info: ************************************\n";
static const char *ddcestr =
@@ -2016,65 +2210,201 @@ XGIDDCPreInit(ScrnInfoPtr pScrn) /* Now (re-)load and initialize the DDC module */
if (!didddc2) {
- if (xf86LoadSubModule(pScrn, "ddc")) {
+ if (xf86LoadSubModule(pScrn, "ddc"))
+ {
xf86LoaderReqSymLists(ddcSymbols, NULL);
- pMonitor = XGIInternalDDC(pScrn, 0);
- if (pMonitor == NULL) {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "Could not retrieve DDC data\n");
- }
+ if (pXGI->xgi_HwDevExt.jChipType == XG27)
+ {
+ ErrorF("Getting CRT EDID (DAC1-CRT1)...\n");
+ pMonitorCRT1 = XGIInternalDDC(pScrn, 0);
- if (pXGI->xgi_HwDevExt.jChipType == XG21) {
- PDEBUG(ErrorF("Getting XG21 DVI EDID...\n"));
- pMonitorDVI = XGIInternalDDC(pScrn, 1);
- if (pMonitorDVI == NULL) {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "Could not retrieve DVI DDC data\n");
- }
- else /* Jong 12/04/2007; used for filtering of CRT1 modes */
- g_pMonitorDVI=pMonitorDVI;
+ if (pMonitorCRT1 == NULL)
+ {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Could not retrieve DDC data for CRT1\n");
+ /* PowerSavingStatus |= 0x01; */ /* device is not detected through DAC1 */
- if ((pMonitor == NULL) && (pMonitorDVI != NULL)) {
- pMonitor = pMonitorDVI;
- }
- }
+ ErrorF("Getting DVI EDID (DVO)...\n");
+ pMonitorDVI = XGIInternalDDC(pScrn, 1);
+ if (pMonitorDVI == NULL) {
+ /* PowerSavingStatus |= 0x02; */ /* device is not detected through DVO */
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Could not retrieve DDC data for DVI\n");
+ }
+ else
+ {
+ PowerSavingStatus &= ~0x02; /* device is detected through DVO */
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Succeed to retrieve DDC data for DVI\n");
+ }
+ }
+ else
+ {
+ if(g_DVI_I_SignalType == 0x00) /* analog CRT */
+ PowerSavingStatus &= ~0x01; /* CRT device is detected */
+ else /* DVI digital */
+ PowerSavingStatus &= ~0x02; /* DVI device is detected */
+
+
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Succeed to retrieve DDC data for %s\n", (g_DVI_I_SignalType == 0x01) ? "DVI" : "CRT");
+ }
+
+ ErrorF("Getting CRT EDID (CRT2)...\n");
+ pMonitorCRT2 = XGIInternalDDC(pScrn, 2);
+
+ if (pMonitorCRT2 == NULL) {
+ /* PowerSavingStatus |= 0x04; */ /* device is not detected through DAC2 */
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Could not retrieve DDC data for CRT2\n");
+ }
+ else /* Used for filtering of CRT1/DVI modes; g_pMonitorDVI is not a good naming; should be g_pMonitorFilter */
+ {
+ PowerSavingStatus &= ~0x04; /* device is detected through DAC2 */
+ g_pMonitorDVI=pMonitorCRT2;
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Succeed to retrieve DDC data for CRT2\n");
+ }
+
+ if (pMonitorCRT1 != NULL)
+ pMonitor = pMonitorCRT1;
+ else if(pMonitorDVI != NULL)
+ pMonitor = pMonitorDVI;
+ else if(pMonitorCRT2 != NULL)
+ pMonitor = pMonitorCRT2;
+ }
+ else /* for XG20/21 */
+ {
+ ErrorF("Getting CRT EDID (CRT1)...\n");
+ pMonitor = XGIInternalDDC(pScrn, 0);
+
+ if (pMonitor == NULL) {
+ PowerSavingStatus |= 0x01; /* device is not detected through DAC1 */
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Could not retrieve DDC data\n");
+ }
+
+ if (pXGI->xgi_HwDevExt.jChipType == XG21) /* CRT1 -DVI */
+ {
+ ErrorF("Getting XG21 DVI EDID (crt2)...\n");
+ pMonitorDVI = XGIInternalDDC(pScrn, 1);
+
+ if (pMonitorDVI == NULL) {
+ PowerSavingStatus |= 0x02; /* device is not detected through DVO */
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Could not retrieve DVI DDC data\n");
+ }
+ else /* Jong 12/04/2007; used for filtering of CRT1 modes */
+ {
+ g_pMonitorDVI=pMonitorDVI;
+ }
+
+ if ((pMonitor == NULL) && (pMonitorDVI != NULL)) {
+ pMonitor = pMonitorDVI;
+ }
+ }
+ }
}
}
+ ErrorF("PowerSavingStatus = 0x%x...\n", PowerSavingStatus);
+
+ if(PowerSavingStatus == 0xFF)
+ PowerSavingStatus = 0x00;
+
+
+/* if((pXGI->xgi_HwDevExt.jChipType == XG27) && (PowerSavingStatus == 0x07))
+ PowerSavingStatus = 0x00;
+
+ if((pXGI->xgi_HwDevExt.jChipType == XG21) && (PowerSavingStatus == 0x03))
+ PowerSavingStatus = 0x00;
+*/
+
+ XGIPowerSaving(pXGI->XGI_Pr, PowerSavingStatus);
+ g_PowerSavingStatus = PowerSavingStatus;
+
/* initialize */
- if (pMonitor) {
- pXGI->CRT1Range.loH = 1000;
- pXGI->CRT1Range.loV = 1000;
- pXGI->CRT1Range.hiH = 0;
- pXGI->CRT1Range.hiV = 0;
- XGIGetMonitorRangeByDDC(&(pXGI->CRT1Range), pMonitor);
- }
- else {
- pXGI->CRT1Range.loH = 0;
- pXGI->CRT1Range.loV = 0;
- pXGI->CRT1Range.hiH = 1000;
- pXGI->CRT1Range.hiV = 1000;
- }
+ if (pXGI->xgi_HwDevExt.jChipType == XG27)
+ {
+ if (pMonitorCRT1) {
+ pXGI->CRT1Range.loH = 1000;
+ pXGI->CRT1Range.loV = 1000;
+ pXGI->CRT1Range.hiH = 0;
+ pXGI->CRT1Range.hiV = 0;
+ XGIGetMonitorRangeByDDC(&(pXGI->CRT1Range), pMonitorCRT1);
+
+ if (pMonitorDVI) {
+ XGIGetMonitorRangeByDDC(&(pXGI->CRT1Range), pMonitorDVI);
+ }
+ }
+ else {
+ if (pMonitorDVI) {
+ pXGI->CRT1Range.loV = 1000;
+ pXGI->CRT1Range.loH = 1000;
+ pXGI->CRT1Range.hiH = 0;
+ pXGI->CRT1Range.hiV = 0;
+ XGIGetMonitorRangeByDDC(&(pXGI->CRT1Range), pMonitorDVI);
+ }
+ else {
+ pXGI->CRT1Range.loH = 0;
+ pXGI->CRT1Range.loV = 0;
+ pXGI->CRT1Range.hiH = 1000;
+ pXGI->CRT1Range.hiV = 1000;
+ }
+ }
- if (pMonitorDVI) {
- pXGI->CRT2Range.loV = 1000;
- pXGI->CRT2Range.loH = 1000;
- pXGI->CRT2Range.hiH = 0;
- pXGI->CRT2Range.hiV = 0;
- XGIGetMonitorRangeByDDC(&(pXGI->CRT2Range), pMonitorDVI);
- }
- else {
- pXGI->CRT2Range.loH = 0;
- pXGI->CRT2Range.loV = 0;
- pXGI->CRT2Range.hiH = 1000;
- pXGI->CRT2Range.hiV = 1000;
- }
+ if (pMonitorCRT2) {
+ pXGI->CRT2Range.loV = 1000;
+ pXGI->CRT2Range.loH = 1000;
+ pXGI->CRT2Range.hiH = 0;
+ pXGI->CRT2Range.hiV = 0;
+ XGIGetMonitorRangeByDDC(&(pXGI->CRT2Range), pMonitorCRT2);
+ }
+ else {
+ pXGI->CRT2Range.loH = 0;
+ pXGI->CRT2Range.loV = 0;
+ pXGI->CRT2Range.hiH = 1000;
+ pXGI->CRT2Range.hiV = 1000;
+ }
+ }
+ else /* XG20/21 */
+ {
+ if (pMonitor) {
+ pXGI->CRT1Range.loH = 1000;
+ pXGI->CRT1Range.loV = 1000;
+ pXGI->CRT1Range.hiH = 0;
+ pXGI->CRT1Range.hiV = 0;
+ XGIGetMonitorRangeByDDC(&(pXGI->CRT1Range), pMonitor);
+ }
+ else {
+ pXGI->CRT1Range.loH = 0;
+ pXGI->CRT1Range.loV = 0;
+ pXGI->CRT1Range.hiH = 1000;
+ pXGI->CRT1Range.hiV = 1000;
+ }
+
+ if (pMonitorDVI) {
+ pXGI->CRT2Range.loV = 1000;
+ pXGI->CRT2Range.loH = 1000;
+ pXGI->CRT2Range.hiH = 0;
+ pXGI->CRT2Range.hiV = 0;
+ XGIGetMonitorRangeByDDC(&(pXGI->CRT2Range), pMonitorDVI);
+ }
+ else {
+ pXGI->CRT2Range.loH = 0;
+ pXGI->CRT2Range.loV = 0;
+ pXGI->CRT2Range.hiH = 1000;
+ pXGI->CRT2Range.hiV = 1000;
+ }
+ }
- if (pXGI->xgi_HwDevExt.jChipType == XG21) {
+ /* Jong@08132009 */
+ /* if (pXGI->xgi_HwDevExt.jChipType == XG21) { */
+ if ((pXGI->xgi_HwDevExt.jChipType == XG21) || (pXGI->xgi_HwDevExt.jChipType == XG27) ) {
/* Mode range intersecting */
if (pXGI->CRT1Range.loH < pXGI->CRT2Range.loH) {
pXGI->CRT1Range.loH = pXGI->CRT2Range.loH;
@@ -2090,9 +2420,9 @@ XGIDDCPreInit(ScrnInfoPtr pScrn) }
}
- if (pMonitor) {
- XGISyncDDCMonitorRange(pScrn->monitor, &pXGI->CRT1Range);
- }
+ if (pMonitor) {
+ XGISyncDDCMonitorRange(pScrn->monitor, &pXGI->CRT1Range);
+ }
if (pScrn->monitor) {
pScrn->monitor->DDC = pMonitor;
@@ -2358,7 +2688,7 @@ XGIPreInit(ScrnInfoPtr pScrn, int flags) */
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "XGI driver (%s)\n", XGI_RELEASE_DATE);
+ "XGI driver (%s)\n", "01/21/2009" /*XGI_RELEASE_DATE*/);
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
"Copyright (C) 2001-2004 Thomas Winischhofer <thomas@winischhofer.net> and others\n");
@@ -2417,15 +2747,28 @@ XGIPreInit(ScrnInfoPtr pScrn, int flags) (pXGI->Primary ? "primary" : "secondary"));
if (pXGI->Primary) {
+#if defined(__arm__)
+ VGAHWPTR(pScrn)->MapPhys = pXGI->PciInfo->ioBase[2] + 0xf2000000;
+#endif
+
VGAHWPTR(pScrn)->MapSize = 0x10000; /* Standard 64k VGA window */
if (!vgaHWMapMem(pScrn)) {
XGIErrorLog(pScrn, "Could not map VGA memory\n");
XGIFreeRec(pScrn);
return FALSE;
+ } else {
+#if defined(__arm__)
+ vgaHWSetMmioFuncs(VGAHWPTR(pScrn), VGAHWPTR(pScrn)->Base, 0);
+#endif
+
+ xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
+ "VGA memory map from 0x%x to 0x%x \n",
+ pXGI->PciInfo->ioBase[2], VGAHWPTR(pScrn)->Base);
}
}
vgaHWGetIOBase(VGAHWPTR(pScrn));
+ /* Jong@08262009; why not to modify ??? */
/* We "patch" the PIOOffset inside vgaHW in order to force
* the vgaHW module to use our relocated i/o ports.
*/
@@ -2455,14 +2798,12 @@ XGIPreInit(ScrnInfoPtr pScrn, int flags) #endif /* !defined(__alpha__) */
}
-#ifndef XSERVER_LIBPCIACCESS
xf86SetOperatingState(resVgaMem, pXGI->pEnt->index, ResUnusedOpr);
/* Operations for which memory access is required */
pScrn->racMemFlags = RAC_FB | RAC_COLORMAP | RAC_CURSOR | RAC_VIEWPORT;
/* Operations for which I/O access is required */
pScrn->racIoFlags = RAC_COLORMAP | RAC_CURSOR | RAC_VIEWPORT;
-#endif
/* The ramdac module should be loaded here when needed */
if (!xf86LoadSubModule(pScrn, "ramdac")) {
@@ -2590,7 +2931,7 @@ XGIPreInit(ScrnInfoPtr pScrn, int flags) FbDevExist = FALSE;
if((pXGI->Chipset != PCI_CHIP_XGIXG20)&&(pXGI->Chipset != PCI_CHIP_XGIXG21)&&( pXGI->Chipset != PCI_CHIP_XGIXG27 ))
{
- if ((fd = open("/dev/fb", O_RDONLY)) != -1) { + if ((fd = open("/dev/fb", 'r')) != -1) {
PDEBUG(ErrorF("--- open /dev/fb.... \n"));
ioctl(fd, FBIOGET_FSCREENINFO, &fix);
if (fix.accel == FB_ACCEL_XGI_GLAMOUR) {
@@ -2680,6 +3021,10 @@ XGIPreInit(ScrnInfoPtr pScrn, int flags) }
/* Get our relocated IO registers */
+#if defined(__arm__)
+ pXGI->RelIO = (XGIIOADDRESS)(((IOADDRESS)VGAHWPTR(pScrn)->Base & 0xFFFFFFFC) + pXGI->IODBase);
+
+#else
pXGI->RelIO = (XGIIOADDRESS) (pXGI->IODBase |
#ifdef XSERVER_LIBPCIACCESS
(pXGI->PciInfo->regions[2].base_addr & 0xFFFC)
@@ -2687,9 +3032,12 @@ XGIPreInit(ScrnInfoPtr pScrn, int flags) (pXGI->PciInfo->ioBase[2] & 0xFFFC)
#endif
);
+#endif
+
pXGI->xgi_HwDevExt.pjIOAddress = (XGIIOADDRESS) (pXGI->RelIO + 0x30);
xf86DrvMsg(pScrn->scrnIndex, from, "Relocated IO registers at 0x%lX\n",
(unsigned long) pXGI->RelIO);
+ ErrorF("xgi_driver.c-pXGI->xgi_HwDevExt.pjIOAddress=0x%x...\n", pXGI->xgi_HwDevExt.pjIOAddress);
if (!xf86SetDepthBpp(pScrn, 0, 0, 0, pix24flags)) {
XGIErrorLog(pScrn, "xf86SetDepthBpp() error\n");
@@ -2840,7 +3188,8 @@ XGIPreInit(ScrnInfoPtr pScrn, int flags) * The cmap layer needs this to be initialised.
*/
{
- Gamma zeros = { 0.0, 0.0, 0.0 };
+ Gamma zeros = { 0.0, 0.0, 0.0 };
+ /* Gamma zeros = { 0.5, 0.5, 0.5 }; */
if (!xf86SetGamma(pScrn, zeros)) {
XGIErrorLog(pScrn, "xf86SetGamma() error\n");
@@ -2934,7 +3283,6 @@ XGIPreInit(ScrnInfoPtr pScrn, int flags) (unsigned long) pXGI->IOAddress, pXGI->mmioSize);
pXGI->xgi_HwDevExt.bIntegratedMMEnabled = TRUE;
-#ifndef XSERVER_LIBPCIACCESS
/* Register the PCI-assigned resources. */
if (xf86RegisterResources(pXGI->pEnt->index, NULL, ResExclusive)) {
XGIErrorLog(pScrn,
@@ -2949,7 +3297,6 @@ XGIPreInit(ScrnInfoPtr pScrn, int flags) XGIFreeRec(pScrn);
return FALSE;
}
-#endif
from = X_PROBED;
if (pXGI->pEnt->device->videoRam != 0) {
@@ -3330,6 +3677,7 @@ XGIPreInit(ScrnInfoPtr pScrn, int flags) * mode into account.)
*/
+#if !defined(__arm__)
#if !defined(__powerpc__)
/* Now load and initialize VBE module. */
if (xf86LoadSubModule(pScrn, "vbe")) {
@@ -3346,8 +3694,40 @@ XGIPreInit(ScrnInfoPtr pScrn, int flags) "Could not load VBE module\n");
}
- XGIDDCPreInit(pScrn);
#endif
+#endif
+
+
+ XGIDDCPreInit(pScrn);
+
+ /* Jong 07/29/2009; Proposal : use wide range for HorizSync and strict range for VertRefresh; And set 1024x768 in Modes of Screen section */
+ /* Jong 07/17/2009; fix issue of only one mode (800x600) */
+ /* if (no Horizsync or VertRefresh is spefified in Monitor section) and (no DDC detection) */
+ /* then apply followings as default Hsync and VRefresh (1024x768x60HZ) */
+ /* XGIDDCPreInit() should be called first to get EDID but need I2C programming instead of VBIOS call */
+ if(pScrn->monitor->DDC == NULL)
+ {
+ ErrorF("Non-DDC minitor or NO EDID information...\n");
+
+ if(pScrn->monitor->nHsync == 0)
+ {
+ pScrn->monitor->nHsync = 1;
+ pScrn->monitor->hsync[0].lo=30;
+ pScrn->monitor->hsync[0].hi=50;
+ ErrorF("No HorizSync information set in Monitor section and use default (%d, %d)...\n",
+ pScrn->monitor->hsync[0].lo, pScrn->monitor->hsync[0].hi);
+ }
+
+ if(pScrn->monitor->nVrefresh == 0)
+ {
+ pScrn->monitor->nVrefresh = 1;
+ pScrn->monitor->vrefresh[0].lo=40;
+ pScrn->monitor->vrefresh[0].hi=60;
+ ErrorF("No VertRefresh information set in Monitor section and use default (%d, %d)...\n",
+ pScrn->monitor->vrefresh[0].lo, pScrn->monitor->vrefresh[0].hi);
+ }
+ }
+
/* From here, we mainly deal with clocks and modes */
/* Set the min pixel clock */
@@ -3411,9 +3791,12 @@ XGIPreInit(ScrnInfoPtr pScrn, int flags) #endif
XGIDumpMonPtr(pScrn->monitor);
- /* Jong 12/05/2007; filter support modes of CRT1 by CRT2 DDC */
+
+ XGIAddAvailableModes(pScrn->monitor->Modes);
+
/* XGIFilterModeByDDC(pScrn->monitor->Modes, g_pMonitorDVI); */ /* Do it in XGIValidMode() */
+ ErrorF("Call xf86ValidateModes()...Use Virtual Size-1-Virtual Size=%d\n", pScrn->display->virtualX);
i = xf86ValidateModes(pScrn, pScrn->monitor->Modes, pScrn->display->modes, clockRanges, NULL, 256, 2048, /* min / max pitch */
pScrn->bitsPerPixel * 8, 128, 2048, /* min / max height */
pScrn->display->virtualX,
@@ -3439,33 +3822,34 @@ XGIPreInit(ScrnInfoPtr pScrn, int flags) * pScrn->virtualY;
if (memreq > pXGI->maxxfbmem) {
- XGIErrorLog(pScrn,
- "Virtual screen too big for memory; %ldK needed, %ldK available\n",
- memreq / 1024, pXGI->maxxfbmem / 1024);
-
- if (pXGIEnt)
- pXGIEnt->ErrorAfterFirst = TRUE;
-
- if (pXGI->pInt)
- xf86FreeInt10(pXGI->pInt);
- pXGI->pInt = NULL;
- xgiRestoreExtRegisterLock(pXGI, srlockReg, crlockReg);
- XGIFreeRec(pScrn);
- return FALSE;
- }
- else if (pXGI->loadDRI && !IS_DUAL_HEAD(pXGI)) {
- pXGI->maxxfbmem = memreq;
- pXGI->DRIheapstart = pXGI->DRIheapend = 0;
-
- if (pXGI->maxxfbmem == pXGI->availMem) {
- xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
- "All video memory used for framebuffer. DRI will be disabled.\n");
- pXGI->loadDRI = FALSE;
- }
- else {
- pXGI->DRIheapstart = pXGI->maxxfbmem;
- pXGI->DRIheapend = pXGI->availMem;
- }
+ XGIErrorLog(pScrn,
+ "Virtual screen too big for memory; %ldK needed, %ldK available\n",
+ memreq / 1024, pXGI->maxxfbmem / 1024);
+
+ if (pXGIEnt)
+ pXGIEnt->ErrorAfterFirst = TRUE;
+
+ if (pXGI->pInt)
+ xf86FreeInt10(pXGI->pInt);
+ pXGI->pInt = NULL;
+ xgiRestoreExtRegisterLock(pXGI, srlockReg, crlockReg);
+ XGIFreeRec(pScrn);
+ return FALSE;
+ }
+ else if (pXGI->loadDRI && !IS_DUAL_HEAD(pXGI))
+ {
+ pXGI->maxxfbmem = memreq;
+ pXGI->DRIheapstart = pXGI->DRIheapend = 0;
+
+ if (pXGI->maxxfbmem == pXGI->availMem) {
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "All video memory used for framebuffer. DRI will be disabled.\n");
+ pXGI->loadDRI = FALSE;
+ }
+ else {
+ pXGI->DRIheapstart = pXGI->maxxfbmem;
+ pXGI->DRIheapend = pXGI->availMem;
+ }
}
@@ -3474,10 +3858,12 @@ XGIPreInit(ScrnInfoPtr pScrn, int flags) * which are unsuitable for dual head mode.
* -) Find the highest used pixelclock on the master head.
*/
- if (IS_DUAL_HEAD(pXGI) && !IS_SECOND_HEAD(pXGI)) {
+ if (IS_DUAL_HEAD(pXGI) && !IS_SECOND_HEAD(pXGI))
+ {
pXGIEnt->maxUsedClock = 0;
- if ((p = first = pScrn->modes)) {
+ if ((p = first = pScrn->modes))
+ {
do {
n = p->next;
@@ -3530,7 +3916,8 @@ XGIPreInit(ScrnInfoPtr pScrn, int flags) }
#endif
- /* Print the list of modes being used */
+ /* Print the list of modes being used ; call xf86Mode.c-xf86PrintModeline() to print */
+ ErrorF("Call xf86PrintModes(pScrn) to list all valid modes...\n");
xf86PrintModes(pScrn);
#ifdef XGIMERGED
@@ -3670,14 +4057,19 @@ XGIPreInit(ScrnInfoPtr pScrn, int flags) }
else
#endif
- xf86SetDpi(pScrn, 0, 0);
+
+ /* Jong 07/30/2009; might cause small font size */
+ xf86SetDpi(pScrn, 0, 0);
+
+#if 0
/*yilin@20080407 fix the font too small problem at low resolution*/
if((pScrn->xDpi < 65)||(pScrn->yDpi < 65))
{
pScrn->xDpi = 75;
pScrn->yDpi = 75;
}
+#endif
/* Load fb module */
switch (pScrn->bitsPerPixel) {
@@ -3714,22 +4106,40 @@ XGIPreInit(ScrnInfoPtr pScrn, int flags) xf86LoaderReqSymLists(fbSymbols, NULL);
/* Load XAA if needed */
- if (!pXGI->NoAccel) {
+ if (!pXGI->NoAccel)
+ {
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Accel enabled\n");
- if (!xf86LoadSubModule(pScrn, "xaa")) {
- XGIErrorLog(pScrn, "Could not load xaa module\n");
- if (pXGIEnt)
- pXGIEnt->ErrorAfterFirst = TRUE;
+#ifdef XGI_USE_XAA
+ if(!(pXGI->useEXA))
+ {
+ if (!xf86LoadSubModule(pScrn, "xaa")) {
+ XGIErrorLog(pScrn, "Could not load xaa module\n");
+
+ if (pXGIEnt)
+ pXGIEnt->ErrorAfterFirst = TRUE;
+
+ if (pXGI->pInt)
+ xf86FreeInt10(pXGI->pInt);
+ xgiRestoreExtRegisterLock(pXGI, srlockReg, crlockReg);
+ XGIFreeRec(pScrn);
+ return FALSE;
+ }
+ xf86LoaderReqSymLists(xaaSymbols, NULL);
+ }
+#endif
- if (pXGI->pInt)
- xf86FreeInt10(pXGI->pInt);
- xgiRestoreExtRegisterLock(pXGI, srlockReg, crlockReg);
- XGIFreeRec(pScrn);
- return FALSE;
- }
- xf86LoaderReqSymLists(xaaSymbols, NULL);
- }
+#ifdef XGI_USE_EXA
+ if(pXGI->useEXA)
+ {
+ if(!xf86LoadSubModule(pScrn, "exa")) {
+ XGIErrorLog(pScrn, "Could not load exa module\n");
+ return FALSE;
+ }
+ xf86LoaderReqSymLists(exaSymbols, NULL);
+ }
+#endif
+ }
/* Load shadowfb if needed */
if (pXGI->ShadowFB) {
@@ -4020,6 +4430,30 @@ XGIModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) unsigned char tmpval;
#endif
+ PDEBUG(ErrorF("XGIModeInit\n"));
+ PDEBUG(ErrorF("mode->HDisplay = %d\n", mode->HDisplay));
+ PDEBUG(ErrorF("mode->VDisplay = %d\n", mode->VDisplay));
+
+ PDEBUG(ErrorF("Before update...\n"));
+ PDEBUG(ErrorF("pScrn->virtualX = %d\n", pScrn->virtualX));
+ PDEBUG(ErrorF("pScrn->virtualY = %d\n", pScrn->virtualY));
+ PDEBUG(ErrorF("pScrn->displayWidth = %d\n", pScrn->displayWidth));
+ PDEBUG(ErrorF("pScrn->frameX0 = %d\n", pScrn->frameX0));
+ PDEBUG(ErrorF("pScrn->frameY0 = %d\n", pScrn->frameY0));
+ PDEBUG(ErrorF("pScrn->frameX1 = %d\n", pScrn->frameX1));
+ PDEBUG(ErrorF("pScrn->frameY1 = %d\n", pScrn->frameY1));
+
+ /* pScrn->displayWidth=mode->HDisplay; */
+
+ if(pXGI->TargetRefreshRate)
+ mode->VRefresh = pXGI->TargetRefreshRate;
+
+ if((pScrn->monitor->DDC == NULL) && (pXGI->Non_DDC_DefaultMode)) + { + mode->HDisplay = pXGI->Non_DDC_DefaultResolutionX; + mode->VDisplay = pXGI->Non_DDC_DefaultResolutionY; + mode->VRefresh = pXGI->Non_DDC_DefaultRefreshRate; + } /* PDEBUG(ErrorF("XGIModeInit(). \n")); */
PDEBUG(ErrorF
@@ -4036,39 +4470,42 @@ XGIModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) XGIModifyModeInfo(mode); /* Quick check of the mode parameters */
- if (IS_DUAL_HEAD(pXGI)) {
+ if (IS_DUAL_HEAD(pXGI))
+ {
XGIEntPtr pXGIEnt = ENTITY_PRIVATE(pXGI);
- if (!(*pXGI->ModeInit) (pScrn, mode)) {
- XGIErrorLog(pScrn, "ModeInit() failed\n");
- return FALSE;
- }
+ if (!(*pXGI->ModeInit) (pScrn, mode)) {
+ XGIErrorLog(pScrn, "ModeInit() failed\n");
+ return FALSE;
+ }
- pScrn->vtSema = TRUE;
+ pScrn->vtSema = TRUE;
- /* Head 2 (slave) is always CRT1 */
- XGIPreSetMode(pScrn, mode, XGI_MODE_CRT1);
- if (!XGIBIOSSetModeCRT1(pXGI->XGI_Pr, &pXGI->xgi_HwDevExt, pScrn,
- mode)) {
- XGIErrorLog(pScrn, "XGIBIOSSetModeCRT1() failed\n");
- return FALSE;
- }
- XGIPostSetMode(pScrn, &pXGI->ModeReg);
- XGIAdjustFrame(pXGIEnt->pScrn_1->scrnIndex, pXGIEnt->pScrn_1->frameX0,
- pXGIEnt->pScrn_1->frameY0, 0);
+ /* Head 2 (slave) is always CRT1 */
+ XGIPreSetMode(pScrn, mode, XGI_MODE_CRT1);
+ if (!XGIBIOSSetModeCRT1(pXGI->XGI_Pr, &pXGI->xgi_HwDevExt, pScrn,
+ mode))
+ {
+ XGIErrorLog(pScrn, "XGIBIOSSetModeCRT1() failed\n");
+ return FALSE;
+ }
+
+ XGIPostSetMode(pScrn, &pXGI->ModeReg);
+ XGIAdjustFrame(pXGIEnt->pScrn_1->scrnIndex, pXGIEnt->pScrn_1->frameX0,
+ pXGIEnt->pScrn_1->frameY0, 0);
}
else
{
- /* For other chipsets, use the old method */
+ /* For other chipsets, use the old method */
- /* Initialise the ModeReg values */
- if (!vgaHWInit(pScrn, mode)) {
- XGIErrorLog(pScrn, "vgaHWInit() failed\n");
- return FALSE;
- }
+ /* Initialise the ModeReg values */
+ if (!vgaHWInit(pScrn, mode)) {
+ XGIErrorLog(pScrn, "vgaHWInit() failed\n");
+ return FALSE;
+ }
- /* Reset our PIOOffset as vgaHWInit might have reset it */
- VGAHWPTR(pScrn)->PIOOffset = pXGI->IODBase - 0x380 +
+ /* Reset our PIOOffset as vgaHWInit might have reset it */
+ VGAHWPTR(pScrn)->PIOOffset = pXGI->IODBase - 0x380 +
#ifdef XSERVER_LIBPCIACCESS
(pXGI->PciInfo->regions[2].base_addr & 0xFFFC)
#else
@@ -4076,35 +4513,35 @@ XGIModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) #endif
;
- /* Prepare the register contents */
- if (!(*pXGI->ModeInit) (pScrn, mode)) {
- XGIErrorLog(pScrn, "ModeInit() failed\n");
- return FALSE;
- }
+ /* Prepare the register contents */
+ if (!(*pXGI->ModeInit) (pScrn, mode)) {
+ XGIErrorLog(pScrn, "ModeInit() failed\n");
+ return FALSE;
+ }
- pScrn->vtSema = TRUE;
+ pScrn->vtSema = TRUE;
- /* Program the registers */
- vgaHWProtect(pScrn, TRUE);
- vgaReg = &hwp->ModeReg;
- xgiReg = &pXGI->ModeReg;
+ /* Program the registers */
+ vgaHWProtect(pScrn, TRUE);
+ vgaReg = &hwp->ModeReg;
+ xgiReg = &pXGI->ModeReg;
- vgaReg->Attribute[0x10] = 0x01;
- if (pScrn->bitsPerPixel > 8) {
- vgaReg->Graphics[0x05] = 0x00;
- }
+ vgaReg->Attribute[0x10] = 0x01;
+ if (pScrn->bitsPerPixel > 8) {
+ vgaReg->Graphics[0x05] = 0x00;
+ }
- vgaHWRestore(pScrn, vgaReg, VGA_SR_MODE);
+ vgaHWRestore(pScrn, vgaReg, VGA_SR_MODE);
- (*pXGI->XGIRestore) (pScrn, xgiReg);
+ (*pXGI->XGIRestore) (pScrn, xgiReg);
#ifdef TWDEBUG
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "REAL REGISTER CONTENTS AFTER SETMODE:\n");
- (*pXGI->ModeInit) (pScrn, mode);
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "REAL REGISTER CONTENTS AFTER SETMODE:\n");
+ (*pXGI->ModeInit) (pScrn, mode);
#endif
- vgaHWProtect(pScrn, FALSE);
+ vgaHWProtect(pScrn, FALSE);
}
@@ -4141,6 +4578,8 @@ XGIModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) outXGIIDXREG(XGICR, 0x4D, tmpval);
#endif
+ XGISetDPMS(pScrn, pXGI->XGI_Pr, &pXGI->xgi_HwDevExt , 0x00000000 );
+
return TRUE;
}
@@ -4160,9 +4599,11 @@ XGIRestore(ScrnInfoPtr pScrn) PDEBUG(ErrorF("XGIRestore():\n"));
/* Wait for the accelerators */
- if (pXGI->AccelInfoPtr) {
+#ifdef XGI_USE_XAA
+ if (!(pXGI->useEXA) && pXGI->AccelInfoPtr) {
(*pXGI->AccelInfoPtr->Sync) (pScrn);
}
+#endif
vgaHWProtect(pScrn, TRUE);
@@ -4170,8 +4611,13 @@ XGIRestore(ScrnInfoPtr pScrn) xgiSaveUnlockExtRegisterLock(pXGI, NULL, NULL);
#endif
+ /* Volari_DisableCmdQueue(pScrn) ; */
+
+ /* Volari_Restore() */
(*pXGI->XGIRestore) (pScrn, xgiReg);
+ pXGI->xgi_HwDevExt.SpecifyTiming = FALSE;
+
/* Jong 11/14/2007; resolve no display of DVI after leaving VT */
/* But there's no int10 for PPC... */
/* XGIRestorePrevMode(pScrn) ; */
@@ -4210,12 +4656,32 @@ XGIBlockHandler(int i, pointer blockData, pointer pTimeout, pointer pReadmask) }
}
+/* Jong@08122009 */
+int g_virtualX;
+int g_virtualY;
+int g_frameX0;
+int g_frameY0;
+int g_frameX1;
+int g_frameY1;
+
+void xgiRestoreVirtual(ScrnInfoPtr pScrn)
+{
+ pScrn->virtualX = g_virtualX;
+ pScrn->virtualY = g_virtualY;
+ pScrn->frameX0 = g_frameX0;
+ pScrn->frameY0 = g_frameY0;
+ pScrn->frameX1 = g_frameX1;
+ pScrn->frameY1 = g_frameY1;
+}
+
/* Mandatory
* This gets called at the start of each server generation
*
* We use pScrn and not CurrentLayout here, because the
* properties we use have not changed (displayWidth,
* depth, bitsPerPixel)
+ *
+ * pScrn->displayWidth : memory pitch
*/
static Bool
XGIScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
@@ -4233,23 +4699,61 @@ XGIScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) ErrorF("XGIScreenInit\n");
pScrn = xf86Screens[pScreen->myNum];
+ PDEBUG(ErrorF("pScrn->currentMode->HDisplay = %d\n", pScrn->currentMode->HDisplay));
+ PDEBUG(ErrorF("pScrn->currentMode->VDisplay = %d\n", pScrn->currentMode->VDisplay));
+
+ PDEBUG(ErrorF("Before update...\n"));
+ PDEBUG(ErrorF("pScrn->virtualX = %d\n", pScrn->virtualX));
+ PDEBUG(ErrorF("pScrn->virtualY = %d\n", pScrn->virtualY));
+ PDEBUG(ErrorF("pScrn->displayWidth = %d\n", pScrn->displayWidth));
+ PDEBUG(ErrorF("pScrn->frameX0 = %d\n", pScrn->frameX0));
+ PDEBUG(ErrorF("pScrn->frameY0 = %d\n", pScrn->frameY0));
+ PDEBUG(ErrorF("pScrn->frameX1 = %d\n", pScrn->frameX1));
+ PDEBUG(ErrorF("pScrn->frameY1 = %d\n", pScrn->frameY1));
+
+/* Jong 07/29/2009; fix bug of switch mode */
+#if 1
/* Jong 08/30/2007; no virtual screen for all cases */
/* Jong 08/22/2007; support modeline */
/* if(g_CountOfUserDefinedModes > 0) */
{
- pScrn->virtualX=pScrn->currentMode->HDisplay;
- pScrn->virtualY=pScrn->currentMode->VDisplay;
- pScrn->displayWidth=pScrn->currentMode->HDisplay;
- pScrn->frameX0=0;
- pScrn->frameY0=0;
- pScrn->frameX1=pScrn->currentMode->HDisplay-1;
- pScrn->frameY1=pScrn->currentMode->VDisplay-1;
+ /* Jong@08122009 */
+ g_virtualX = pScrn->virtualX;
+ g_virtualY = pScrn->virtualY;
+ g_frameX0 = pScrn->frameX0;
+ g_frameY0 = pScrn->frameY0;
+ g_frameX1 = pScrn->frameX1;
+ g_frameY1 = pScrn->frameY1;
+
+ /*
+ pScrn->virtualX=pScrn->currentMode->HDisplay;
+ pScrn->virtualY=pScrn->currentMode->VDisplay;
+ */
+
+ //pScrn->displayWidth=pScrn->currentMode->HDisplay;
+
+ /*
+ pScrn->frameX0=0;
+ pScrn->frameY0=0;
+ pScrn->frameX1=pScrn->currentMode->HDisplay-1;
+ pScrn->frameY1=pScrn->currentMode->VDisplay-1; */
}
+#endif
+
+ PDEBUG(ErrorF("After update...\n"));
+ PDEBUG(ErrorF("pScrn->virtualX = %d\n", pScrn->virtualX));
+ PDEBUG(ErrorF("pScrn->virtualY = %d\n", pScrn->virtualY));
+ PDEBUG(ErrorF("pScrn->displayWidth = %d\n", pScrn->displayWidth));
+ PDEBUG(ErrorF("pScrn->frameX0 = %d\n", pScrn->frameX0));
+ PDEBUG(ErrorF("pScrn->frameY0 = %d\n", pScrn->frameY0));
+ PDEBUG(ErrorF("pScrn->frameX1 = %d\n", pScrn->frameX1));
+ PDEBUG(ErrorF("pScrn->frameY1 = %d\n", pScrn->frameY1));
hwp = VGAHWPTR(pScrn);
pXGI = XGIPTR(pScrn);
+#if !defined(__arm__)
#if !defined(__powerpc__)
if (!IS_DUAL_HEAD(pXGI) || !IS_SECOND_HEAD(pXGI)) {
if (xf86LoadSubModule(pScrn, "vbe")) {
@@ -4263,6 +4767,7 @@ XGIScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) }
}
#endif /* if !defined(__powerpc__) */
+#endif
if (IS_DUAL_HEAD(pXGI)) {
pXGIEnt = ENTITY_PRIVATE(pXGI);
@@ -4313,6 +4818,9 @@ XGIScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) return FALSE;
}
+ /* Jong@08122009; still at virtual */
+ /* xgiRestoreVirtual(); */
+
PDEBUG(ErrorF("--- XGIModeInit --- \n"));
PDEBUG(XGIDumpRegs(pScrn));
@@ -4324,7 +4832,10 @@ XGIScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) XGISaveScreen(pScreen, SCREEN_SAVER_ON);
/* Set the viewport */
- XGIAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
+ XGIAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
+ /* XGIAdjustFrame(scrnIndex, 0, 0, 0); */
+
+ /* xgiRestoreVirtual(pScrn); */
/*
* The next step is to setup the screen's visuals, and initialise the
@@ -4360,9 +4871,14 @@ XGIScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) return FALSE;
}
+ /*xgiRestoreVirtual(pScrn); */
+
+#if 0
+ ErrorF("Use Virtual Size - *1\n");
width = pScrn->virtualX;
height = pScrn->virtualY;
displayWidth = pScrn->displayWidth;
+#endif
if (pXGI->Rotate) {
height = pScrn->virtualX;
@@ -4417,6 +4933,8 @@ XGIScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) }
#endif
+ /* xgiRestoreVirtual(pScrn); */
+
/*
* Call the framebuffer layer's ScreenInit function, and fill in other
* pScreen fields.
@@ -4426,14 +4944,48 @@ XGIScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) case 8:
case 16:
case 32:
- ret = fbScreenInit(pScreen, FBStart, width,
+
+/* Jong 07/30/2009; fix bug of small font */
+#if 1
+ PDEBUG(ErrorF("Use Virtual Size - *1\n"));
+ width = /* pScrn->virtualX; */ pScrn->currentMode->HDisplay;
+ height = /* pScrn->virtualY;*/ pScrn->currentMode->VDisplay;
+
+ /* Jong@10022009 */
+ displayWidth = pScrn->displayWidth; /* important to set pitch correctly */
+#endif
+ PDEBUG(ErrorF("Call fbScreenInit()...\n"));
+ PDEBUG(ErrorF("width=%d, height=%d, pScrn->xDpi=%d, pScrn->yDpi=%d, displayWidth=%d, pScrn->bitsPerPixel=%d...\n",
+ width, height, pScrn->xDpi, pScrn->yDpi,displayWidth, pScrn->bitsPerPixel));
+
+ /* in fbscreen.c */
+ /* (xsize, ysize) : virtual size (1600, 1200)
+ (dpix, dpiy) : (75, 75)
+ (542) pScreen->mmWidth = (xsize * 254 + dpix * 5) / (dpix * 10);
+ (406) pScreen->mmHeight = (ysize * 254 + dpiy * 5) / (dpiy * 10); */
+
+ /* ret = fbScreenInit(pScreen, FBStart, width, */
+ ret = fbScreenInit(pScreen, FBStart , width,
height, pScrn->xDpi, pScrn->yDpi,
displayWidth, pScrn->bitsPerPixel);
+
+ /* Jong 07/30/2009; bug fixing for small font size */
+ pScreen->mmWidth = (pScrn->currentMode->HDisplay * 254 + pScrn->xDpi * 5) / (pScrn->xDpi * 10);
+ pScreen->mmHeight = (pScrn->currentMode->VDisplay * 254 + pScrn->yDpi * 5) / (pScrn->yDpi * 10);
+
+ PDEBUG(ErrorF("pScrn->xDpi = %d\n", pScrn->xDpi));
+ PDEBUG(ErrorF("pScrn->yDpi = %d\n", pScrn->yDpi));
+ PDEBUG(ErrorF("pScreen->mmWidth = %d\n", pScreen->mmWidth));
+ PDEBUG(ErrorF("pScreen->mmHeight = %d\n", pScreen->mmHeight));
+
break;
default:
ret = FALSE;
break;
}
+
+ xgiRestoreVirtual(pScrn);
+
if (!ret) {
XGIErrorLog(pScrn, "Unsupported bpp (%d) or fbScreenInit() failed\n",
pScrn->bitsPerPixel);
@@ -4456,9 +5008,13 @@ XGIScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) }
}
+ /* xgiRestoreVirtual(pScrn); */
+
/* Initialize RENDER ext; must be after RGB ordering fixed */
fbPictureInit(pScreen, 0, 0);
+ /* xgiRestoreVirtual(pScrn); */
+
/* hardware cursor needs to wrap this layer <-- TW: what does that mean? */
if (!pXGI->ShadowFB)
XGIDGAInit(pScreen);
@@ -4592,10 +5148,18 @@ XGIScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) pXGI->XGI_SD_Flags |= XGI_SD_ISDEPTH8;
pXGI->XGI_SD_Flags &= ~XGI_SD_SUPPORTXVGAMMA1;
}
+
PDEBUG(ErrorF("XGIScreenInit() End. \n"));
PDEBUG(XGIDumpPalette(pScrn));
PDEBUG(XGIDumpRegs(pScrn));
+ /* xgiRestoreVirtual(); */
+ XGIAdjustFrame(scrnIndex, 0, 0, 0);
+ pScrn->frameX0 = 0;
+ pScrn->frameY0 = 0;
+ pScrn->frameX1 = pScrn->currentMode->HDisplay - 1 ;
+ pScrn->frameY1 = pScrn->currentMode->VDisplay - 1;
+
return TRUE;
}
@@ -4606,23 +5170,128 @@ XGISwitchMode(int scrnIndex, DisplayModePtr mode, int flags) ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
XGIPtr pXGI = XGIPTR(pScrn);
- ErrorF("XGISwitchMode\n");
+ if(pXGI->TargetRefreshRate)
+ mode->VRefresh = pXGI->TargetRefreshRate;
+
+ PDEBUG(ErrorF("XGISwitchMode\n"));
+ PDEBUG(ErrorF("mode->HDisplay = %d\n", mode->HDisplay));
+ PDEBUG(ErrorF("mode->VDisplay = %d\n", mode->VDisplay));
+
+ PDEBUG(ErrorF("Before update...\n"));
+ PDEBUG(ErrorF("pScrn->virtualX = %d\n", pScrn->virtualX));
+ PDEBUG(ErrorF("pScrn->virtualY = %d\n", pScrn->virtualY));
+ PDEBUG(ErrorF("pScrn->displayWidth = %d\n", pScrn->displayWidth));
+ PDEBUG(ErrorF("pScrn->frameX0 = %d\n", pScrn->frameX0));
+ PDEBUG(ErrorF("pScrn->frameY0 = %d\n", pScrn->frameY0));
+ PDEBUG(ErrorF("pScrn->frameX1 = %d\n", pScrn->frameX1));
+ PDEBUG(ErrorF("pScrn->frameY1 = %d\n", pScrn->frameY1));
+
+ PDEBUG(ErrorF("pScrn->xDpi = %d\n", pScrn->xDpi));
+ PDEBUG(ErrorF("pScrn->yDpi = %d\n", pScrn->yDpi));
+ PDEBUG(ErrorF("pScreen->mmWidth = %d\n", pScrn->pScreen->mmWidth));
+ PDEBUG(ErrorF("pScreen->mmHeight = %d\n", pScrn->pScreen->mmHeight));
+
+ /* Jong@08122009 */
+ //pScrn->frameX0 = 0;
+ //pScrn->frameY0 = 0;
+ //pScrn->frameX1 = mode->HDisplay;
+ //pScrn->frameY1 = mode->VDisplay;
if (!pXGI->NoAccel) {
- if (pXGI->AccelInfoPtr) {
+#ifdef XGI_USE_XAA
+ if (!(pXGI->useEXA) && pXGI->AccelInfoPtr) {
(*pXGI->AccelInfoPtr->Sync) (pScrn);
PDEBUG(ErrorF("XGISwitchMode Accel Enabled. \n"));
}
+#endif
}
+
PDEBUG(ErrorF
("XGISwitchMode (%d, %d) \n", mode->HDisplay, mode->VDisplay));
+#if 1
+ /* Jong 07/29/2009; Set the viewport; still not working */
+ XGIAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
+#endif
+
if (!(XGIModeInit(xf86Screens[scrnIndex], mode)))
return FALSE;
+
+#if 0
+ int height, width, displayWidth;
+ unsigned char *FBStart;
+ int ret;
+
+ if (pXGI->ShadowFB) {
+ displayWidth = pXGI->ShadowPitch / (pScrn->bitsPerPixel >> 3);
+ FBStart = pXGI->ShadowPtr;
+ }
+ else {
+ pXGI->ShadowPtr = NULL;
+ FBStart = pXGI->FbBase;
+ }
+
+ width = pScrn->virtualX; /* 1024; */ /* pScrn->currentMode->HDisplay; */
+ height = pScrn->virtualY; /* 768; */ /* pScrn->currentMode->VDisplay; */
+ displayWidth = pScrn->displayWidth; /* important to set pitch correctly */
+
+ ErrorF("Call fbScreenInit()...\n");
+ ErrorF("width=%d, height=%d, pScrn->xDpi=%d, pScrn->yDpi=%d, displayWidth=%d, pScrn->bitsPerPixel=%d...\n",
+ width, height, pScrn->xDpi, pScrn->yDpi,displayWidth, pScrn->bitsPerPixel);
+
+ /* in fbscreen.c */
+ /* (xsize, ysize) : virtual size (1600, 1200)
+ (dpix, dpiy) : (75, 75)
+ (542) pScreen->mmWidth = (xsize * 254 + dpix * 5) / (dpix * 10);
+ (406) pScreen->mmHeight = (ysize * 254 + dpiy * 5) / (dpiy * 10); */
+
+ ret = fbScreenInit(pScrn->pScreen, FBStart, width,
+ height, pScrn->xDpi, pScrn->yDpi,
+ displayWidth, pScrn->bitsPerPixel);
+#endif
+
+ /* Jong 07/30/2009; bug fixing for small font size */
+ pScrn->pScreen->mmWidth = (pScrn->virtualX * 254 + pScrn->xDpi * 5) / (pScrn->xDpi * 10);
+ pScrn->pScreen->mmHeight = (pScrn->virtualY * 254 + pScrn->yDpi * 5) / (pScrn->yDpi * 10);
+
+#if 0
+ /* Jong 08/30/2007; no virtual screen for all cases */
+ /* Jong 08/22/2007; support modeline */
+ /* if(g_CountOfUserDefinedModes > 0) */
+ {
+
+ pScrn->virtualX=mode->HDisplay;
+ pScrn->virtualY=mode->VDisplay;
+
+ pScrn->displayWidth=mode->HDisplay;
+ pScrn->frameX0=0;
+ pScrn->frameY0=0;
+ pScrn->frameX1=mode->HDisplay-1;
+ pScrn->frameY1=mode->VDisplay-1;
+ }
+#endif
+
+ PDEBUG(ErrorF("After update...\n"));
+ PDEBUG(ErrorF("pScrn->virtualX = %d\n", pScrn->virtualX));
+ PDEBUG(ErrorF("pScrn->virtualY = %d\n", pScrn->virtualY));
+ PDEBUG(ErrorF("pScrn->displayWidth = %d\n", pScrn->displayWidth));
+ PDEBUG(ErrorF("pScrn->frameX0 = %d\n", pScrn->frameX0));
+ PDEBUG(ErrorF("pScrn->frameY0 = %d\n", pScrn->frameY0));
+ PDEBUG(ErrorF("pScrn->frameX1 = %d\n", pScrn->frameX1));
+ PDEBUG(ErrorF("pScrn->frameY1 = %d\n", pScrn->frameY1));
+
+ PDEBUG(ErrorF("pScrn->xDpi = %d\n", pScrn->xDpi));
+ PDEBUG(ErrorF("pScrn->yDpi = %d\n", pScrn->yDpi));
+ PDEBUG(ErrorF("pScreen->mmWidth = %d\n", pScrn->pScreen->mmWidth));
+ PDEBUG(ErrorF("pScreen->mmHeight = %d\n", pScrn->pScreen->mmHeight));
+
/* Since RandR (indirectly) uses SwitchMode(), we need to
* update our Xinerama info here, too, in case of resizing
*/
+
+ /* sleep(3); */ /* Jong 07/30/2009; wait to be ready for drawing */;
+
return TRUE;
}
@@ -5076,15 +5745,17 @@ XGICloseScreen(int scrnIndex, ScreenPtr pScreen) pXGI->pInt = NULL;
}
+#ifdef XGI_USE_XAA
if (pXGI->AccelLinearScratch) {
xf86FreeOffscreenLinear(pXGI->AccelLinearScratch);
pXGI->AccelLinearScratch = NULL;
}
- if (pXGI->AccelInfoPtr) {
+ if (!(pXGI->useEXA) && pXGI->AccelInfoPtr) {
XAADestroyInfoRec(pXGI->AccelInfoPtr);
pXGI->AccelInfoPtr = NULL;
}
+#endif
if (pXGI->CursorInfoPtr) {
xf86DestroyCursorInfoRec(pXGI->CursorInfoPtr);
@@ -5132,6 +5803,40 @@ XGIFreeScreen(int scrnIndex, int flags) }
+/* Jong 07/02/2008; Validate user-defined mode */
+int XGIValidateUserDefMode(XGIPtr pXGI, DisplayModePtr mode)
+{
+ UShort i = (pXGI->CurrentLayout.bitsPerPixel+7)/8 - 1;
+
+
+#if 1
+ if((mode->HDisplay >= 1600) && (mode->VDisplay >= 1200) && (mode->VRefresh > 60))
+ {
+ ErrorF("Not support over (1600,1200) 60Hz ... Reduce to (1600,1200) 60Hz\n");
+ mode->type=48; /* not user-defined */
+ mode->VRefresh = 60.0;
+
+ mode->Clock=mode->SynthClock=162000; /* from XG20_Mode[] */ /* ((float)(mode->VTotal*mode->HTotal)+0.5) * (mode->VRefresh) / 1000.0; */
+ ErrorF("Update clock to %d...\n", mode->Clock);
+ return(-111) ;
+ }
+#endif
+
+#if 0
+ if(XGI_GetModeID(0, mode->HDisplay, mode->VDisplay, i, 0, 0) == 0)
+ {
+ /* Jong 11/10/2008; support custom mode without ModeID */
+ if( !((pXGI->HaveCustomModes) && (!(mode->type & M_T_DEFAULT))) )
+ {
+ ErrorF("Can't get Mode ID...\n");
+ return(MODE_NOMODE) ;
+ }
+ }
+#endif
+
+ return(MODE_OK);
+}
+
/* Checks if a mode is suitable for the selected chipset. */
static int
@@ -5145,21 +5850,67 @@ XGIValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) int i = 0;
int VRefresh;
+ /* Jong 07/27/2009; support custom mode without ModeID */
+ pXGI->HaveCustomModes = TRUE;
+
VRefresh =
(int) ((float) (Clock * 1000) /
(float) (mode->VTotal * mode->HTotal) + 0.5);
- /* Jong 08/21/2007; support modeline */
- /* We skip mode checking here and need improvement further */
- if(mode->type == M_T_USERDEF)
- return(MODE_OK);
+ /* Jong@09252009 */
+ if(mode->VRefresh == 0)
+ mode->VRefresh = VRefresh;
- PDEBUG5(ErrorF("XGIValidMode()."));
+ if((mode->type == M_T_USERDEF) || ((mode->type & M_T_CLOCK_CRTC_C) == M_T_CLOCK_CRTC_C))
+ {
+ VRefresh = mode->VRefresh;
+ Clock = mode->Clock;
+ }
+
+ PDEBUG5(ErrorF("\nXGIValidMode()-->"));
PDEBUG5(ErrorF
("CLK=%5.3fMhz %dx%d@%d ", (float) Clock / 1000, HDisplay,
VDisplay, VRefresh));
PDEBUG5(ErrorF("(VT,HT)=(%d,%d)\n", mode->VTotal, mode->HTotal));
+ PDEBUG5(ErrorF("flags = %d\n", flags));
+ if(flags == MODECHECK_FINAL)
+ PDEBUG5(ErrorF("This is a final check...\n"));
+
+#if 1
+ if((mode->type == M_T_USERDEF) || ((mode->type & M_T_CLOCK_CRTC_C) == M_T_CLOCK_CRTC_C))
+ {
+ if(pScrn->monitor->DDC)
+ {
+ if(XGICheckModeByDDC(mode, pScrn->monitor->DDC) == FALSE)
+ {
+ ErrorF("It's a user-defined mode...rejected by EDID (pScrn->monitor->DDC)...return MODE_NOMODE\n");
+ return (MODE_NOMODE);
+ }
+ }
+
+ PDEBUG5(ErrorF("It's a user-defined mode...return MODE_OK (might need more checking here) \n"));
+ return(MODE_OK);
+ }
+#else
+ if((mode->type == M_T_USERDEF) || ((mode->type & M_T_CLOCK_CRTC_C) == M_T_CLOCK_CRTC_C))
+ {
+ iRet=XGIValidateUserDefMode(pXGI, mode);
+ if(iRet != -111)
+ {
+ if(iRet == MODE_OK)
+ ErrorF("User-defined mode---MODE_OK\n");
+ else
+ ErrorF("User-defined mode---MODE_NOMODE\n");
+
+ return(iRet);
+ }
+ }
+#endif
+ if(mode->VRefresh == 0)
+ mode->VRefresh = VRefresh;
+
+#if 0
if (pXGI->VBFlags & CRT2_LCD) {
if ((HDisplay > 1600 && VDisplay > 1200)
|| (HDisplay < 640 && VDisplay < 480)) {
@@ -5182,6 +5933,7 @@ XGIValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) return (MODE_NOMODE);
}
}
+#endif
if ((pXGI->Chipset == PCI_CHIP_XGIXG20) ||(pXGI->Chipset == PCI_CHIP_XGIXG21) ||( pXGI->Chipset == PCI_CHIP_XGIXG27 )) {
XgiMode = XG20_Mode;
@@ -5195,22 +5947,50 @@ XGIValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) (XgiMode[i].VDisplay != VDisplay)) {
if (XgiMode[i].Clock == 0) {
PDEBUG5(ErrorF
- ("--- NO_Mode support for %dx%d@%dHz\n", HDisplay,
+ ("--- Mode %dx%d@%dHz is not defined in support mode table of driver\n", HDisplay,
VDisplay, VRefresh));
+ PDEBUG5(ErrorF("Mode is invalid...return MODE_NOMODE\n"));
return (MODE_NOMODE);
}
else
i++;
}
- PDEBUG5(ErrorF("Mode OK\n"));
- /* Jong 12/05/2007; filter mode of CRT1 with CRT2 DDC for XG21 */
- if(g_pMonitorDVI)
+ if(pScrn->monitor->DDC)
{
- if(XGICheckModeByDDC(mode, g_pMonitorDVI) == FALSE)
- return (MODE_NOMODE);
+ if(XGICheckModeByDDC(mode, pScrn->monitor->DDC) == FALSE)
+ {
+ ErrorF("Rejected by EDID (pScrn->monitor->DDC)...return MODE_NOMODE\n");
+ return (MODE_NOMODE);
+ }
+ }
+
+ if (pXGI->Chipset == PCI_CHIP_XGIXG27)
+ {
+ if(((g_PowerSavingStatus & 0x03) < 0x03) &&
+ ((g_PowerSavingStatus & 0x04) == 0x00) &&
+ g_pMonitorDVI)
+ {
+ if(XGICheckModeByDDC(mode, g_pMonitorDVI) == FALSE)
+ {
+ PDEBUG5(ErrorF("Rejected by CRT2 EDID...return MODE_NOMODE\n"));
+ return (MODE_NOMODE);
+ }
+ }
+ }
+ else /* Jong 12/05/2007; filter mode of CRT1 with CRT2 DDC for XG21 */
+ {
+ if(g_pMonitorDVI)
+ {
+ if(XGICheckModeByDDC(mode, g_pMonitorDVI) == FALSE)
+ {
+ PDEBUG5(ErrorF("Rejected by DVI EDID...return MODE_NOMODE\n"));
+ return (MODE_NOMODE);
+ }
+ }
}
+ PDEBUG5(ErrorF("Mode is valid...return MODE_OK\n"));
return (MODE_OK);
}
@@ -5571,6 +6351,8 @@ XGIPreSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode, int viewmode) outXGIIDXREG(XGISR, 0x00, 0x03);
}
}
+
+ andXGIIDXREG(XGISR, 0x1f, 0xfb); /* disable DAC pedestal to reduce brightness */
}
/* PostSetMode:
@@ -5989,7 +6771,8 @@ xgiSaveUnlockExtRegisterLock(XGIPtr pXGI, unsigned char *reg1, #ifdef TWDEBUG
for (i = 0; i <= 0x3f; i++) {
inXGIIDXREG(XGISR, i, val1);
- inXGIIDXREG(0x3c4, i, val2);
+ /* inXGIIDXREG(0x3c4, i, val2); */
+ inXGIIDXREG(XGISR, i, val2);
xf86DrvMsg(pXGI->pScrn->scrnIndex, X_INFO,
"SR%02d: RelIO=0x%02x 0x3c4=0x%02x (%d)\n",
i, val1, val2, mylockcalls);
@@ -6454,10 +7237,16 @@ XGIDumpPalette(ScrnInfoPtr pScrn) ("----------------------------------------------------------------------\n");
for (i = 0; i < 0xFF; i += 0x04) {
for (j = 0; j < 16; j++) {
- outb(0x3c7, i + j);
+ /* outb(0x3c7, i + j); */
+ outb(XGISR+3, i + j);
+
+ /*
temp[0] = inb(0x3c9);
temp[1] = inb(0x3c9);
- temp[2] = inb(0x3c9);
+ temp[2] = inb(0x3c9); */
+ temp[0] = inb(XGISR+5);
+ temp[1] = inb(XGISR+5);
+ temp[2] = inb(XGISR+5);
ErrorF("PA[%02X]: %02X %02X %02X", i + j,
temp[0], temp[1], temp[2]);
@@ -6467,3 +7256,4 @@ XGIDumpPalette(ScrnInfoPtr pScrn) ErrorF("\n");
#endif
}
+
diff --git a/src/xgi_memcpy.c b/src/xgi_memcpy.c new file mode 100755 index 0000000..3fed150 --- /dev/null +++ b/src/xgi_memcpy.c @@ -0,0 +1,1305 @@ +/*
+ * XGI memcpy() routines (assembly)
+ *
+ * Copyright (C) 2004-2005 Thomas Winischhofer
+ *
+ * Idea and some code bits from via_memcpy.c which is
+ * Copyright (C) 2004 Thomas Hellstroem, All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sub license,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE CODE SUPPLIER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+/* #include "xgi.h" */
+
+/* Jong 07/10/2008; use run-time debug instead except for HW acceleration routines */
+/* extern bool g_bRunTimeDebug;
+#define RUNTIMEDEBUG(p) if(g_bRunTimeDebug)p; */
+
+/* #define DEBUG */
+#ifdef DEBUG
+#define PDEBUG(p) p /* RUNTIMEDEBUG(p) */
+#else
+#define PDEBUG(p)
+#endif
+
+/* Jong 01/15/2009; CPU flags (for memcpy() etc.) */
+#define XGI_CPUFL_LIBC 0x0001
+#define XGI_CPUFL_BI 0x0002
+#define XGI_CPUFL_SSE 0x0004
+#define XGI_CPUFL_MMX 0x0008
+#define XGI_CPUFL_3DNOW 0x0010
+#define XGI_CPUFL_MMX2 0x0020
+#define XGI_CPUFL_BI2 0x0040
+#define XGI_CPUFL_SSE2 0x0080
+#define XGI_CPUFL_FLAG 0x8000
+
+#if 0 /* Debug */
+#define XGIDGBMC
+#endif
+
+/* Jong 01/07/2009; debug */
+/*
+#ifdef XGI_DEBUG
+#define PDEBUG(p) p
+#else
+#define PDEBUG(p)
+#endif
+*/
+
+#if 0 /* Jong 01/15/2009; ignore at the moment */
+extern unsigned int XGIAllocateFBMemory(ScrnInfoPtr pScrn, void **handle, int bytesize);
+extern void XGIFreeFBMemory(ScrnInfoPtr pScrn, void **handle);
+#endif
+
+#define CPUBUFFERSIZE 2048 /* Size of /proc/cpuinfo buffer */
+#define BUFFERSIZE (576 * 1152) /* Matches 720x576 YUV420 */
+
+/************************************************************************/
+/* arch specific memcpy() routines */
+/************************************************************************/
+
+/* i386, AMD64 */
+
+#define FENCE \
+ __asm__ __volatile__( \
+ " sfence\n" \
+ : \
+ : \
+ : "memory");
+
+#define FENCEMMS \
+ __asm__ __volatile__ ( \
+ " sfence\n" \
+ " emms\n" \
+ : \
+ : \
+ : "memory");
+
+#define FEMMS \
+ __asm__ __volatile__( \
+ " femms\n" \
+ : \
+ : \
+ : "memory");
+
+#define EMMS \
+ __asm__ __volatile__( \
+ " emms\n" \
+ : \
+ : \
+ : "memory");
+
+#define SSE_PREFETCH " prefetchnta "
+#define NOW_PREFETCH " prefetch "
+
+#define PREFETCH1(arch_prefetch,from) \
+ __asm__ __volatile__ ( \
+ arch_prefetch "(%0)\n" \
+ arch_prefetch "32(%0)\n" \
+ arch_prefetch "64(%0)\n" \
+ arch_prefetch "96(%0)\n" \
+ arch_prefetch "128(%0)\n" \
+ arch_prefetch "160(%0)\n" \
+ arch_prefetch "192(%0)\n" \
+ arch_prefetch "256(%0)\n" \
+ arch_prefetch "288(%0)\n" \
+ : \
+ : "r" (from) );
+
+#define PREFETCH2(arch_prefetch,from) \
+ __asm__ __volatile__ ( \
+ arch_prefetch "320(%0)\n" \
+ : \
+ : "r" (from) );
+
+#define PREFETCH3(arch_prefetch,from) \
+ __asm__ __volatile__ ( \
+ arch_prefetch "288(%0)\n" \
+ : \
+ : "r" (from) );
+
+#define small_memcpy_i386(to,from,n) \
+ { \
+ __asm__ __volatile__( \
+ " cld\n" \
+ " shrl $1, %%ecx\n" \
+ " jnc 1f\n" \
+ " movsb\n" \
+ "1: shrl $1, %%ecx\n" \
+ " jnc 2f\n" \
+ " movsw\n" \
+ "2: rep ; movsl" \
+ : "=&D" (to), "=&S" (from) \
+ : "c" (n), "0" ((long) to), "1" ((long) from) \
+ : "memory", "cc"); \
+ PDEBUG(ErrorF("Jong-small_memcpy_i386(to,from,n)...\n")); \
+ }
+
+#define small_memcpy_amd64(to,from,n) \
+ { \
+ __asm__ __volatile__( \
+ " cld\n" \
+ " shrq $1, %%rcx\n" \
+ " jnc 1f\n" \
+ " movsb\n" \
+ "1: shrq $1, %%rcx\n" \
+ " jnc 2f\n" \
+ " movsw\n" \
+ "2: shrq $1, %%rcx\n" \
+ " jnc 3f\n" \
+ " movsl\n" \
+ "3: rep ; movsq" \
+ : "=&D" (to), "=&S" (from) \
+ : "c" (n), "0" ((long) to), "1" ((long) from) \
+ : "memory", "cc"); \
+ PDEBUG(ErrorF("Jong-small_memcpy_amd64(to,from,n)...\n")); \
+ }
+
+#define MMX_CPY(prefetch,from,to,dummy,lcnt) \
+ __asm__ __volatile__ ( \
+ "1:\n" \
+ prefetch "320(%1)\n" \
+ " movq (%1), %%mm0\n" \
+ " movq 8(%1), %%mm1\n" \
+ " movq 16(%1), %%mm2\n" \
+ " movq 24(%1), %%mm3\n" \
+ " movq %%mm0, (%0)\n" \
+ " movq %%mm1, 8(%0)\n" \
+ " movq %%mm2, 16(%0)\n" \
+ " movq %%mm3, 24(%0)\n" \
+ prefetch "352(%1)\n" \
+ " movq 32(%1), %%mm0\n" \
+ " movq 40(%1), %%mm1\n" \
+ " movq 48(%1), %%mm2\n" \
+ " movq 56(%1), %%mm3\n" \
+ " leal 64(%1),%1\n" \
+ " movq %%mm0, 32(%0)\n" \
+ " movq %%mm1, 40(%0)\n" \
+ " movq %%mm2, 48(%0)\n" \
+ " movq %%mm3, 56(%0)\n" \
+ " decl %2\n" \
+ " leal 64(%0),%0\n" \
+ " jne 1b\n" \
+ : "=&D"(to), "=&S"(from), "=&r"(dummy) \
+ : "0" (to), "1" (from), "2" (lcnt) \
+ : "memory", "cc"); \
+ PDEBUG(ErrorF("Jong-MMX_CPY(prefetch,from,to,dummy,lcnt)...\n"));
+
+
+#define SSE_CPY(prefetch,from,to,dummy,lcnt) \
+ if((ULong) from & 15) { \
+ __asm__ __volatile__ ( \
+ "1:\n" \
+ prefetch "320(%1)\n" \
+ " movups (%1), %%xmm0\n" \
+ " movups 16(%1), %%xmm1\n" \
+ " movntps %%xmm0, (%0)\n" \
+ " movntps %%xmm1, 16(%0)\n" \
+ prefetch "352(%1)\n" \
+ " movups 32(%1), %%xmm2\n" \
+ " movups 48(%1), %%xmm3\n" \
+ " leal 64(%1),%1\n" \
+ " movntps %%xmm2, 32(%0)\n" \
+ " movntps %%xmm3, 48(%0)\n" \
+ " decl %2\n" \
+ " leal 64(%0),%0\n" \
+ " jne 1b\n" \
+ : "=&D"(to), "=&S"(from), "=&r"(dummy) \
+ : "0" (to), "1" (from), "2" (lcnt) \
+ : "memory", "cc"); \
+ PDEBUG(ErrorF("Jong-SSE_CPY(prefetch,from,to,dummy,lcnt)-1...\n")); \
+ } else { \
+ __asm__ __volatile__ ( \
+ "2:\n" \
+ prefetch "320(%1)\n" \
+ " movaps (%1), %%xmm0\n" \
+ " movaps 16(%1), %%xmm1\n" \
+ " movntps %%xmm0, (%0)\n" \
+ " movntps %%xmm1, 16(%0)\n" \
+ prefetch "352(%1)\n" \
+ " movaps 32(%1), %%xmm2\n" \
+ " movaps 48(%1), %%xmm3\n" \
+ " leal 64(%1),%1\n" \
+ " movntps %%xmm2, 32(%0)\n" \
+ " movntps %%xmm3, 48(%0)\n" \
+ " decl %2\n" \
+ " leal 64(%0),%0\n" \
+ " jne 2b\n" \
+ : "=&D"(to), "=&S"(from), "=&r"(dummy) \
+ : "0" (to), "1" (from), "2" (lcnt) \
+ : "memory", "cc"); \
+ PDEBUG(ErrorF("Jong-SSE_CPY(prefetch,from,to,dummy,lcnt)-2...\n")); \
+ }
+
+#define SSE64_CPY(prefetch,from,to,dummy,lcnt) \
+ if((ULong) from & 15) { \
+ __asm__ __volatile__ ( \
+ "1:\n" \
+ prefetch "320(%1)\n" \
+ " movups (%1), %%xmm0\n" \
+ " movups 16(%1), %%xmm1\n" \
+ " movntps %%xmm0, (%0)\n" \
+ " movntps %%xmm1, 16(%0)\n" \
+ prefetch "352(%1)\n" \
+ " movups 32(%1), %%xmm2\n" \
+ " movups 48(%1), %%xmm3\n" \
+ " leaq 64(%1),%1\n" \
+ " movntps %%xmm2, 32(%0)\n" \
+ " movntps %%xmm3, 48(%0)\n" \
+ " decl %2\n" \
+ " leaq 64(%0),%0\n" \
+ " jne 1b\n" \
+ : "=&D"(to), "=&S"(from), "=&r"(dummy) \
+ : "0" (to), "1" (from), "2" (lcnt) \
+ : "memory", "cc"); \
+ PDEBUG(ErrorF("Jong-SSE64_CPY(prefetch,from,to,dummy,lcnt)-1...\n")); \
+ } else { \
+ __asm__ __volatile__ ( \
+ "2:\n" \
+ prefetch "320(%1)\n" \
+ " movaps (%1), %%xmm0\n" \
+ " movaps 16(%1), %%xmm1\n" \
+ " movntps %%xmm0, (%0)\n" \
+ " movntps %%xmm1, 16(%0)\n" \
+ prefetch "352(%1)\n" \
+ " movaps 32(%1), %%xmm2\n" \
+ " movaps 48(%1), %%xmm3\n" \
+ " leaq 64(%1),%1\n" \
+ " movntps %%xmm2, 32(%0)\n" \
+ " movntps %%xmm3, 48(%0)\n" \
+ " decl %2\n" \
+ " leaq 64(%0),%0\n" \
+ " jne 2b\n" \
+ : "=&D"(to), "=&S"(from), "=&r"(dummy) \
+ : "0" (to), "1" (from), "2" (lcnt) \
+ : "memory", "cc"); \
+ PDEBUG(ErrorF("Jong-SSE64_CPY(prefetch,from,to,dummy,lcnt)-2...\n")); \
+ }
+
+#define MMXEXT_CPY(prefetch,from,to,dummy,lcnt) \
+ __asm__ __volatile__ ( \
+ ".p2align 4,,7\n" \
+ "1:\n" \
+ prefetch "320(%1)\n" \
+ " movq (%1), %%mm0\n" \
+ " movq 8(%1), %%mm1\n" \
+ " movq 16(%1), %%mm2\n" \
+ " movq 24(%1), %%mm3\n" \
+ " movntq %%mm0, (%0)\n" \
+ " movntq %%mm1, 8(%0)\n" \
+ " movntq %%mm2, 16(%0)\n" \
+ " movntq %%mm3, 24(%0)\n" \
+ prefetch "352(%1)\n" \
+ " movq 32(%1), %%mm0\n" \
+ " movq 40(%1), %%mm1\n" \
+ " movq 48(%1), %%mm2\n" \
+ " movq 56(%1), %%mm3\n" \
+ " leal 64(%1),%1\n" \
+ " movntq %%mm0, 32(%0)\n" \
+ " movntq %%mm1, 40(%0)\n" \
+ " movntq %%mm2, 48(%0)\n" \
+ " movntq %%mm3, 56(%0)\n" \
+ " decl %2\n" \
+ " leal 64(%0),%0\n" \
+ " jne 1b\n" \
+ : "=&D"(to), "=&S"(from), "=&r"(dummy) \
+ : "0" (to), "1" (from), "2" (lcnt) \
+ : "memory", "cc"); \
+ PDEBUG(ErrorF("Jong-MMXEXT_CPY(prefetch,from,to,dummy,lcnt)...\n"));
+
+
+#define PREFETCH_FUNC(prefix,itype,ptype,begin,fence,small) \
+ \
+/* static void prefix##_memcpy(UChar *to, */ \
+ void prefix##_memcpy(UChar *to, \
+ const UChar *from, \
+ int size) \
+ { \
+ int lcnt = size >> 6; \
+ int rest = size & 63; \
+ register int dummy; \
+ \
+ PREFETCH1(ptype##_PREFETCH,from); \
+ begin; \
+ PDEBUG(ErrorF("Jong-After-begin()...\n")); \
+ if(lcnt) { \
+ PDEBUG(ErrorF("Jong-Before-SSE_CPY()...\n")); \
+ itype##_CPY(ptype##_PREFETCH,from,to,dummy,lcnt); \
+ PDEBUG(ErrorF("Jong-After-SSE_CPY()...\n")); \
+ } \
+ if(rest) { \
+ PDEBUG(ErrorF("Jong-Before-PREFETCH2()...\n")); \
+ PREFETCH2(ptype##_PREFETCH,from); \
+ PDEBUG(ErrorF("Jong-After-PREFETCH2()...\n")); \
+ small(to, from, rest); \
+ PDEBUG(ErrorF("Jong-After-small...\n")); \
+ PREFETCH3(ptype##_PREFETCH,from); \
+ PDEBUG(ErrorF("Jong-After-PREFETCH3()...\n")); \
+ } \
+ PDEBUG(ErrorF("Jong-Before-fence...\n")); \
+ fence; \
+ PDEBUG(ErrorF("Jong-PREFETCH_FUNC(prefix,itype,ptype,begin,fence,small)-end...\n")); \
+ }
+
+#define NOPREFETCH_FUNC(prefix,itype,begin,fence,small) \
+ \
+ static void prefix##_memcpy(UChar *to, \
+ const UChar *from, \
+ int size) \
+ { \
+ int lcnt = size >> 6; \
+ int rest = size & 63; \
+ register int dummy; \
+ \
+ begin; \
+ if(lcnt) { \
+ itype##_CPY("#",from,to,dummy,lcnt); \
+ } \
+ if(rest) { \
+ small(to, from, rest); \
+ } \
+ fence; \
+ PDEBUG(ErrorF("Jong-NOPREFETCH_FUNC(prefix,itype,ptype,begin,fence,small)...\n")); \
+ }
+
+/* Other archs */
+
+/* ... */
+
+
+#if 0 /* Jong 01/15/2009; ignore at the moment */
+/* Type for table for benchmark list */
+typedef struct {
+ vidCopyFunc mFunc;
+ char *mName;
+ unsigned int mycpuflag;
+ int grade;
+ int gradefrom;
+ Bool reqAlignment;
+} XGIMCFuncData;
+#endif
+
+/************************************************************************/
+/* libc memcpy() wrapper - generic */
+/************************************************************************/
+#define UChar unsigned char
+
+void XGI_libc_memcpy(UChar *dst, const UChar *src, int size)
+{
+ PDEBUG(ErrorF("Jong-XGI_libc_memcpy()...\n"));
+ memcpy(dst, src, size);
+}
+
+/************************************************************************/
+/* We only do all that stuff under gcc; no idea what other compilers */
+/* would do with our asm code. */
+/************************************************************************/
+
+#ifndef __GNUC__
+
+unsigned int XGIGetCPUFlags(ScrnInfoPtr pScrn)
+{
+ PDEBUG(ErrorF("Jong-XGIGetCPUFlags(ScrnInfoPtr pScrn)...\n"));
+ return 0;
+}
+
+vidCopyFunc XGIVidCopyInit(ScreenPtr pScreen, vidCopyFunc *UMemCpy, Bool from)
+{
+ PDEBUG(ErrorF("Jong-XGIVidCopyInit()...\n"));
+ *UMemCpy = XGI_libc_memcpy;
+ return XGI_libc_memcpy;
+}
+
+vidCopyFunc XGIVidCopyGetDefault(void)
+{
+ PDEBUG(ErrorF("Jong-XGIVidCopyGetDefault()...\n"));
+ return XGI_libc_memcpy;
+}
+
+#else /* ! Everything below is gcc specific ! */
+
+/************************************************************************/
+/* Definitions for archs and OSes */
+/************************************************************************/
+
+#undef XGI_checkosforsse
+#undef XGI_canBenchmark
+#undef XGI_haveProc
+#undef XGI_haveBuiltInMC
+
+/* Jong Lin */
+#if defined(__arm__)
+void XGI_builtin_memcpy_arm(UChar *to, const UChar *from, int n)
+{
+ long d1,d2,d3;
+
+ PDEBUG(ErrorF("XGI_builtin_memcpy_arm_begin-size=%d...\n", n));
+
+ __asm__ __volatile__(
+ " start: \n"
+ /* " stmfd sp!, {r0-r12}\n" */ /* Save some working registers */
+ " blockcopy: \n"
+ " movs r3,r2, lsr #3\n" /* Number of eight word multiples */
+ " beq copywords\n" /* Less than eight words to move? */
+ " stmfd sp!, {r4-r11}\n" /* Save some working registers */
+ " octcopy: \n"
+ " ldmia r1!, {r4-r11}\n" /* Load 8 words from the source */
+ " stmia r0!, {r4-r11}\n" /* Put them at the destination */
+ " subs r3, r3, #1\n" /* Decrement the counter */
+ " bne octcopy\n" /* ... copy more */
+ " ldmfd sp!, {r4-r11}\n" /* Don't need these now - restore */
+ " copywords: \n"
+ " ands r2, r2, #7\n" /* Number of odd words to copy */
+ " beq stop\n" /* No words left to copy? */
+ " wordcopy: \n"
+ " ldr r3, [r1], #4\n" /* Load a word from the source */
+ " str r3, [r0], #4\n" /* and store it to the destination */
+ " subs r2, r2, #1\n" /* Decrement the counter */
+ " bne wordcopy\n" /* ... copy more */
+ " stop: \n"
+ /* "ldmfd sp!, {r0-r12}\n" */ /* Don't need these now - restore */
+ :
+ :"r" ((long) to), "r" ((long) from), "r" ((unsigned long) n)
+ : "memory", "r3");
+
+}
+#endif
+
+#if defined(__i386__) /* ***************************************** i386 */
+
+#define XGI_checkosforsse /* Does this cpu support sse and do we need to check os? */
+#define XGI_canBenchmark /* Can we perform a benchmark? */
+#ifdef XGI_LINUX
+#define XGI_haveProc /* Do we have /proc/cpuinfo or similar? */
+#endif
+#define XGI_haveBuiltInMC /* Is there a built-in memcpy for this arch? */
+
+/* Built-in memcpy for i386 */
+#define size_t int
+static __inline void * builtin_memcpy(void * to, const void * from, size_t n)
+{
+ int d1,d2,d3;
+
+ __asm__ __volatile__(
+ " cld\n"
+ " shrl $1, %%ecx\n"
+ " jnc 1f\n"
+ " movsb\n"
+ "1: shrl $1, %%ecx\n"
+ " jnc 2f\n"
+ " movsw\n"
+ "2: rep ; movsl\n"
+ : "=&c" (d1), "=&D" (d2), "=&S" (d3)
+ : "0" (n), "1" ((long) to), "2" ((long) from)
+ : "memory", "cc");
+
+ PDEBUG(ErrorF("Jong-__inline builtin_memcpy() for i386...\n"));
+ return(to);
+}
+
+/* Alternative for 586: Unroll loop, copy 32 bytes at a time */
+static void XGI_builtin_memcp2(UChar *to, const UChar *from, int n)
+{
+ int d1,d2,d3;
+
+ __asm__ __volatile__(
+ " movl %%edi, %%eax\n"
+ " cmpl $32, %%ecx\n"
+ " cld\n"
+ " jbe 3f\n"
+ " negl %%eax\n" /* Align dest */
+ " andl $3, %%eax\n"
+ " subl %%eax, %%ecx\n"
+ " xchgl %%eax, %%ecx\n"
+ " rep ; movsb\n"
+ " movl %%eax, %%ecx\n"
+ " subl $32, %%ecx\n"
+ " js 2f\n"
+ " movl (%%edi), %%eax\n"
+ "1: movl 28(%%edi), %%edx\n" /* Trick: Read-ahead */
+ " subl $32, %%ecx\n"
+ " movl (%%esi), %%eax\n"
+ " movl 4(%%esi), %%edx\n"
+ " movl %%eax, (%%edi)\n"
+ " movl %%edx, 4(%%edi)\n"
+ " movl 8(%%esi), %%eax\n"
+ " movl 12(%%esi), %%edx\n"
+ " movl %%eax, 8(%%edi)\n"
+ " movl %%edx, 12(%%edi)\n"
+ " movl 16(%%esi), %%eax\n"
+ " movl 20(%%esi), %%edx\n"
+ " movl %%eax, 16(%%edi)\n"
+ " movl %%edx, 20(%%edi)\n"
+ " movl 24(%%esi), %%eax\n"
+ " movl 28(%%esi), %%edx\n"
+ " movl %%eax, 24(%%edi)\n"
+ " movl %%edx, 28(%%edi)\n"
+ " leal 32(%%esi), %%esi\n"
+ " leal 32(%%edi), %%edi\n"
+ " jns 1b\n"
+ "2: addl $32, %%ecx\n"
+ "3: rep ; movsb"
+ : "=&c" (d1), "=&D" (d2), "=&S" (d3)
+ : "0" (n), "1" ((long) to), "2" ((long) from)
+ : "eax", "edx", "memory", "cc");
+
+ PDEBUG(ErrorF("Jong-XGI_builtin_memcp2()-copy 32 bytes at a time-586...\n"));
+}
+
+static unsigned int taketime(void) /* get current time (for benchmarking) */
+{
+ unsigned int eax;
+
+ __asm__ volatile (
+ " pushl %%ebx\n"
+ " cpuid\n"
+ " rdtsc\n"
+ " popl %%ebx\n"
+ : "=a" (eax)
+ : "0" (0)
+ : "ecx", "edx", "cc");
+
+ return(eax);
+}
+
+#elif defined(__AMD64__) || defined(__amd64__) || defined(__x86_64__) /***************** AMD64 */
+
+#define XGI_checkosforsse /* Does this cpu support sse and do we need to check os? */
+#define XGI_canBenchmark /* Can we perform a benchmark? */
+#ifdef XGI_LINUX
+#define XGI_haveProc /* Do we have /proc/cpuinfo or similar? */
+#endif
+#define XGI_haveBuiltInMC /* Is there a built-in memcpy for this arch? */
+
+/* Built-in memcpy for AMD64 */
+static __inline void * builtin_memcpy(void * to, const void * from, int n)
+{
+ long d1, d2, d3;
+
+ __asm__ __volatile__ (
+ " cld\n"
+ " rep ; movsq\n"
+ " movq %4, %%rcx\n"
+ " rep ; movsb"
+ : "=%c" (d1), "=&D" (d2), "=&S" (d3)
+ : "0" ((ULong)(n >> 3)), "q" ((ULong)(n & 7)),
+ "1" ((long) to), "2" ((long) from)
+ : "memory");
+
+ PDEBUG(ErrorF("Jong-builtin_memcpy() for AMD64...\n"));
+ return(to);
+}
+
+/* Alternative: Unroll loop, copy 32 bytes at a time */
+static void XGI_builtin_memcp2(UChar *to, const UChar *from, int n)
+{
+ long d1,d2,d3;
+
+ __asm__ __volatile__(
+ " movq %%rdi, %%rax\n"
+ " cmpq $32, %%rcx\n"
+ " cld\n" /* Pipeline; no other flags but DF */
+ " jbe 1f\n"
+ " negq %%rax\n" /* Align dest */
+ " andq $7, %%rax\n"
+ " subq %%rax, %%rcx\n"
+ " xchgq %%rax, %%rcx\n"
+ " rep ; movsb\n"
+ " movq %%rax, %%rcx\n"
+ " subq $32, %%rcx\n"
+ " js 2f\n"
+ ".p2align 4\n"
+ "3: subq $32, %%rcx\n"
+ " movq (%%rsi), %%rax\n"
+ " movq 8(%%rsi), %%rdx\n"
+ " movq 16(%%rsi), %%r8\n"
+ " movq 24(%%rsi), %%r9\n"
+ " movq %%rax, (%%rdi)\n"
+ " movq %%rdx, 8(%%rdi)\n"
+ " movq %%r8, 16(%%rdi)\n"
+ " movq %%r9, 24(%%rdi)\n"
+ " leaq 32(%%rsi), %%rsi\n"
+ " leaq 32(%%rdi), %%rdi\n"
+ " jns 3b\n"
+ "2: addq $32, %%rcx\n"
+ "1: rep ; movsb"
+ : "=&c" (d1), "=&D" (d2), "=&S" (d3)
+ :"0" ((ULong) n), "1" ((long) to), "2" ((long) from)
+ : "rax", "rdx", "r8", "r9", "memory", "cc");
+
+ PDEBUG(ErrorF("Jong-XGI_builtin_memcp2()-copy 32 bytes at a time-AMD...\n"));
+}
+
+static unsigned int taketime(void) /* get current time (for benchmarking) */
+{
+ unsigned int eax;
+
+ __asm__ volatile (
+ " pushq %%rbx\n"
+ " cpuid\n"
+ " rdtsc\n"
+ " popq %%rbx\n"
+ : "=a" (eax)
+ : "0" (0)
+ : "rcx", "rdx", "cc");
+
+ return(eax);
+}
+
+#else /* **************************************** Other archs */
+
+/* 1. Can we do a benchmark? */
+/* #define XGI_canBenchmark */
+
+/* 2. Do we have /proc filesystem or similar for CPU information? */
+/* #define XGI_haveproc */
+
+/* 3. Optional: build-in memcpy() */
+/* #define XGI_haveBuiltInMC */
+/* static __inline void * builtin_memcpy(void * to, const void * from, int n)
+ {
+ }
+*/
+
+/* 4. Function for getting current time (for benchmarking) */
+/* static unsigned int taketime(void)
+ {
+ }
+*/
+
+#endif
+
+/************************************************************************/
+/* Generic built-in memcpy wrapper */
+/************************************************************************/
+
+#ifdef XGI_haveBuiltInMC
+static void XGI_builtin_memcpy(UChar *dst, const UChar *src, int size)
+{
+ PDEBUG(ErrorF("Jong-XGI_builtin_memcpy()...\n"));
+ builtin_memcpy(dst, src, size);
+}
+#endif
+
+#if 0 /* Jong 01/15/2009; ignore at the moment */
+/************************************************************************/
+/* Generic routines if Benchmark can be performed (all archs, all OSes) */
+/************************************************************************/
+
+#ifdef XGI_canBenchmark
+
+/* Get time (unsigned int) */
+static unsigned int time_function(vidCopyFunc mf, UChar *buf1, UChar *buf2, int size)
+{
+ unsigned int t1, t2;
+
+ t1 = taketime();
+
+ (*mf)(buf1, buf2, size);
+
+ t2 = taketime();
+
+ return((t1 < t2) ? t2 - t1 : 0xFFFFFFFFU - (t1 - t2 - 1));
+}
+
+/* Allocate an area of offscreen FB memory (buf1), a simulated video
+ * player buffer (buf2) and a pool of uninitialized "video" data (buf3).
+ */
+static void *
+XGI_AllocBuffers(ScrnInfoPtr pScrn, UChar **buf1, UChar **buf2, UChar **buf3)
+{
+ XGIPtr pXGI = XGIPTR(pScrn);
+ unsigned int offset;
+ void *handle = NULL;
+
+ if(!(offset = XGIAllocateFBMemory(pScrn, &handle, BUFFERSIZE + 31))) {
+ return NULL;
+ }
+ (*buf1) = (UChar *)pXGI->FbBase + offset;
+ (*buf1) = (UChar *)(((ULong)(*buf1) + 31) & ~31);
+
+ if(!((*buf2) = (UChar *)xalloc(BUFFERSIZE + 15))) {
+ XGIFreeFBMemory(pScrn, &handle);
+ return NULL;
+ }
+
+ if(!((*buf3) = (UChar *)xalloc(BUFFERSIZE + 15))) {
+ xfree((*buf2));
+ XGIFreeFBMemory(pScrn, &handle);
+ return NULL;
+ }
+
+ return handle;
+}
+#endif
+
+/* Perform Benchmark */
+static int XGI_BenchmarkMemcpy(ScrnInfoPtr pScrn, XGIMCFuncData *MCFunctions,
+ unsigned int myCPUflags, UChar *buf1, UChar *buf2,
+ UChar *buf3, char *frqBuf, double cpuFreq,
+ vidCopyFunc *UMemCpy, int *best2, Bool from)
+{
+ XGIMCFuncData *curData;
+ int j = 0, bestSoFar = 0;
+ unsigned int tmp1, tmp2, best = 0xFFFFFFFFU, sbest = 0xFFFFFFFFU;
+
+ (*best2) = 0;
+
+ /* Make probable buf1 and buf2 are not paged out by referencing them */
+ XGI_libc_memcpy(buf1, buf2, BUFFERSIZE);
+
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Benchmarking %s RAM to %s RAM memory transfer methods:\n",
+ from ? "video" : "system",
+ from ? "system" : "video");
+
+#ifdef TWDEBUG
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Benchmark: CPUFlags %x\n", myCPUflags);
+#endif
+
+ j = 0;
+ while(MCFunctions[j].mFunc) {
+ PDEBUG(ErrorF("Check function[%d]-%s...\n", j, MCFunctions[j].mName));
+
+ curData = MCFunctions + j;
+
+ if(myCPUflags & curData->mycpuflag) {
+
+ /* Simulate setup of the video buffer and copy result to framebuffer */
+ /* Do this 4 times to verify results */
+ if(!from) {
+ XGI_builtin_memcpy(buf2, buf3, BUFFERSIZE);
+ tmp1 = time_function(curData->mFunc, buf1, buf2, BUFFERSIZE);
+ XGI_builtin_memcpy(buf2, buf3, BUFFERSIZE);
+ tmp2 = time_function(curData->mFunc, buf1, buf2, BUFFERSIZE);
+ tmp1 = (tmp2 < tmp1) ? tmp2 : tmp1;
+ XGI_builtin_memcpy(buf2, buf3, BUFFERSIZE);
+ tmp2 = time_function(curData->mFunc, buf1, buf2, BUFFERSIZE);
+ tmp1 = (tmp2 < tmp1) ? tmp2 : tmp1;
+ XGI_builtin_memcpy(buf2, buf3, BUFFERSIZE);
+ tmp2 = time_function(curData->mFunc, buf1, buf2, BUFFERSIZE);
+ tmp1 = (tmp2 < tmp1) ? tmp2 : tmp1;
+ } else {
+ XGI_builtin_memcpy(buf3, buf2, BUFFERSIZE);
+ tmp1 = time_function(curData->mFunc, buf2, buf1, BUFFERSIZE);
+ XGI_builtin_memcpy(buf3, buf2, BUFFERSIZE);
+ tmp2 = time_function(curData->mFunc, buf2, buf1, BUFFERSIZE);
+ tmp1 = (tmp2 < tmp1) ? tmp2 : tmp1;
+ XGI_builtin_memcpy(buf3, buf2, BUFFERSIZE);
+ tmp2 = time_function(curData->mFunc, buf2, buf1, BUFFERSIZE);
+ tmp1 = (tmp2 < tmp1) ? tmp2 : tmp1;
+ XGI_builtin_memcpy(buf3, buf2, BUFFERSIZE);
+ tmp2 = time_function(curData->mFunc, buf2, buf1, BUFFERSIZE);
+ tmp1 = (tmp2 < tmp1) ? tmp2 : tmp1;
+ }
+
+ if((!frqBuf) || (tmp1 == 0)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+ "\tChecked %s memcpy()... \t%u\n",curData->mName, tmp1);
+ } else {
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+ "\tChecked %s memcpy()... \t%.1f MiB/s\n",
+ curData->mName,
+ cpuFreq * 1.e6 * (double)BUFFERSIZE / ((double)(tmp1) * (double)(0x100000)));
+ }
+
+ if(tmp1 < best) {
+ best = tmp1;
+ bestSoFar = j;
+ PDEBUG(ErrorF("* bestSoFar is %d...\n", bestSoFar));
+ }
+
+ if(!curData->reqAlignment) {
+ if(tmp1 < sbest) {
+ sbest = tmp1;
+ (*best2) = j;
+ }
+ }
+
+ }
+
+ j++;
+ }
+
+ PDEBUG(ErrorF("***** The best is func(%d)-%s...\n", bestSoFar, MCFunctions[bestSoFar].mName));
+
+ /* Jong 01/07/2009; test for performance */
+ /* bestSoFar = 2; */ /* the worst case; buit-in-2 */
+ return bestSoFar;
+}
+
+static vidCopyFunc XGI_GetBestByGrade(ScrnInfoPtr pScrn, XGIMCFuncData *MCFunctions,
+ unsigned int myCPUflags, vidCopyFunc *UMemCpy, Bool from)
+{
+ int j = 0, best = -1, secondbest = -1, bestSoFar = 10, best2SoFar = 10;
+ int grade;
+
+ *UMemCpy = XGI_libc_memcpy;
+
+ while(MCFunctions[j].mFunc) {
+ if(myCPUflags & MCFunctions[j].mycpuflag) {
+ grade = from ? MCFunctions[j].gradefrom : MCFunctions[j].grade;
+ if(grade < bestSoFar) {
+ best = j;
+ bestSoFar = grade;
+ }
+ if(grade < best2SoFar) {
+ if(!MCFunctions[j].reqAlignment) {
+ secondbest = j;
+ best2SoFar = grade;
+ }
+ }
+ }
+ j++;
+ }
+ if(best >= 0) {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Chose %s method for aligned data transfers %s video RAM\n",
+ MCFunctions[best].mName,
+ from ? "from" : "to");
+ if(secondbest >= 0) {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Chose %s method for unaligned data transfers %s video RAM\n",
+ MCFunctions[secondbest].mName,
+ from ? "from" : "to");
+ *UMemCpy = MCFunctions[secondbest].mFunc;
+ }
+ return MCFunctions[best].mFunc;
+ }
+
+ return XGI_libc_memcpy;
+}
+#endif /* canBenchmark */
+
+/**********************************************************************/
+/* Generic routines if /proc filesystem is available (Linux) */
+/**********************************************************************/
+
+#ifdef XGI_haveProc
+/* Linux: Read file (/proc/cpuinfo) into buffer */
+static int XGI_ReadProc(char *buf, char *filename)
+{
+ FILE *cpuInfoFile;
+ int count;
+
+ if((cpuInfoFile = fopen(filename, "r")) == NULL) {
+ return 0;
+ }
+
+ count = fread(buf, 1, CPUBUFFERSIZE, cpuInfoFile);
+ if(ferror(cpuInfoFile)) {
+ fclose(cpuInfoFile);
+ return 0;
+ }
+
+ fclose(cpuInfoFile);
+
+ if(count >= CPUBUFFERSIZE - 2) {
+ return 0;
+ }
+
+ buf[count] = 0;
+
+ return count;
+}
+
+/* Linux: Extract CPU speed from /proc/cpuinfo */
+static char *XGI_GetCPUFreq(ScrnInfoPtr pScrn, char *buf, double *cpuFreq)
+{
+ char *frqBuf, *endBuf;
+
+ (*cpuFreq) = 0.0;
+
+ if((frqBuf = strstr(buf,"cpu MHz\t\t:"))) {
+ frqBuf += 11;
+ (*cpuFreq) = strtod(frqBuf, &endBuf);
+ if(endBuf == frqBuf) frqBuf = NULL;
+ if((*cpuFreq) < 10.0) frqBuf = NULL; /* sanity check */
+ if(frqBuf) {
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "CPU frequency %.2fMhz\n", (*cpuFreq));
+ }
+ }
+
+ return frqBuf;
+}
+#endif /* haveProc */
+
+/**********************************************************************/
+/* Arch-specific routines */
+/**********************************************************************/
+
+#ifdef XGI_checkosforsse /* Common i386, AMD64 */
+
+#ifdef XGICHECKOSSSE
+
+#ifndef XFree86LOADER
+#include <setjmp.h>
+#endif
+
+static jmp_buf sigill_return;
+
+static void sigill_handler(void)
+{
+ longjmp(sigill_return, 1);
+}
+#endif
+
+#if 0 /* Jong 01/15/2009; ignore at the moment */
+static Bool CheckOSforSSE(ScrnInfoPtr pScrn)
+{
+#ifdef XGICHECKOSSSE /* Check OS for SSE possible: */
+ int signo = -1;
+
+#ifdef XGIDGBMC
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Checking OS SSE support\n");
+#endif
+
+ xf86InterceptSigIll(&sigill_handler);
+
+ if(setjmp(sigill_return)) {
+ signo = 4;
+ } else {
+ __asm__ __volatile__ (" xorps %xmm0, %xmm0\n");
+ /* __asm__ __volatile__ (" .byte 0xff\n"); */ /* For test */
+ }
+
+ xf86InterceptSigIll(NULL);
+
+#ifdef XGIDGBMC
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "OS SSE support signal %d\n", signo);
+#endif
+
+ if(signo != -1) {
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+ "OS does not support SSE instructions\n");
+ }
+
+ return (signo >= 0) ? FALSE : TRUE;
+
+#else /* no check for SSE possible: */
+
+ XGIPtr pXGI = XGIPTR(pScrn);
+
+ xf86DrvMsg(pScrn->scrnIndex, pXGI->XvSSEMemcpy ? X_WARNING : X_INFO,
+ "Checking OS for SSE support is not supported in this version of " XGIMYSERVERNAME "\n");
+
+ if(pXGI->XvSSEMemcpy) {
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "If you get a signal 4 here, set the option \"UseSSE\" to \"off\".\n");
+ return TRUE;
+ } else {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "If your OS supports SSE, set the option \"UseSSE\" to \"on\".\n");
+ return FALSE;
+ }
+#endif
+}
+
+#endif /* XGI_checkosforsse */
+#endif
+
+#ifdef __i386__ /* i386 specific *************************************/
+#define ULong unsigned long
+
+PREFETCH_FUNC(XGI_sse,SSE,SSE,,FENCE,small_memcpy_i386)
+PREFETCH_FUNC(XGI_mmxext,MMXEXT,SSE,EMMS,FENCEMMS,small_memcpy_i386)
+PREFETCH_FUNC(XGI_now,MMX,NOW,FEMMS,FEMMS,small_memcpy_i386)
+NOPREFETCH_FUNC(XGI_mmx,MMX,EMMS,EMMS,small_memcpy_i386)
+
+#if 0 /* Jong 01/15/2009; ignore at the moment */
+static XGIMCFuncData MCFunctions_i386[] = {
+ {XGI_libc_memcpy, "libc", XGI_CPUFL_LIBC, 4, 4, FALSE},
+ {XGI_builtin_memcpy,"built-in-1",XGI_CPUFL_BI, 5, 5, FALSE},
+ {XGI_builtin_memcp2,"built-in-2",XGI_CPUFL_BI2, 6, 6, FALSE},
+ {XGI_mmx_memcpy, "MMX", XGI_CPUFL_MMX, 3, 3, FALSE},
+ {XGI_sse_memcpy, "SSE", XGI_CPUFL_SSE, 1, 0, TRUE},
+ {XGI_now_memcpy, "3DNow!", XGI_CPUFL_3DNOW, 2, 2, FALSE},
+ {XGI_mmxext_memcpy, "MMX2", XGI_CPUFL_MMX2, 0, 1, FALSE},
+ {NULL, "", 0, 10, 10, FALSE}
+};
+#endif
+
+#define Def_FL (XGI_CPUFL_LIBC | XGI_CPUFL_BI | XGI_CPUFL_BI2) /* Default methods */
+
+#define cpuid(op, eax, ebx, ecx, edx) \
+ __asm__ __volatile__ ( \
+ " pushl %%ebx\n" \
+ " cpuid\n" \
+ " movl %%ebx, %1\n" \
+ " popl %%ebx\n" \
+ : "=a" (eax), "=r" (ebx), \
+ "=c" (ecx), "=d" (edx) \
+ : "a" (op) \
+ : "cc")
+
+#if 0 /* Jong 01/15/2009; ignore at the moment */
+static Bool cpuIDSupported(ScrnInfoPtr pScrn)
+{
+ int eax, ebx, ecx, edx;
+
+ /* Check for cpuid instruction */
+ __asm__ __volatile__ (
+ " pushf\n"
+ " popl %0\n"
+ " movl %0, %1\n"
+ " xorl $0x200000, %0\n"
+ " push %0\n"
+ " popf\n"
+ " pushf\n"
+ " popl %0\n"
+ : "=a" (eax), "=c" (ecx)
+ :
+ : "cc");
+
+ if(eax == ecx) {
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "CPU does not support CPUID instruction\n");
+ return FALSE;
+ }
+
+ /* Check for cpuid level */
+ cpuid(0x00000000, eax, ebx, ecx, edx);
+ if(!eax) {
+ return FALSE;
+ }
+
+ /* Check for RDTSC */
+ cpuid(0x00000001, eax, ebx, ecx, edx);
+
+ if(!(edx & 0x10)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "CPU does not support RDTSC instruction\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static unsigned int XGI_GetCpuFeatures(ScrnInfoPtr pScrn)
+{
+ unsigned int flags = 0, eax, ebx, ecx, edx;
+ Bool IsAMD;
+
+ /* Check if cpuid and rdtsc instructions are supported */
+ if(!cpuIDSupported(pScrn)) {
+ return 0;
+ }
+
+ cpuid(0x00000000, eax, ebx, ecx, edx);
+
+ IsAMD = (ebx == 0x68747541) && (edx == 0x69746e65) && (ecx == 0x444d4163);
+
+ cpuid(0x00000001, eax, ebx, ecx, edx);
+ /* MMX */
+ if(edx & 0x00800000) flags |= XGI_CPUFL_MMX;
+ /* SSE, MMXEXT */
+ if(edx & 0x02000000) flags |= (XGI_CPUFL_SSE | XGI_CPUFL_MMX2);
+ /* SSE2 - don't need this one directly, set SSE instead */
+ if(edx & 0x04000000) flags |= (XGI_CPUFL_SSE | XGI_CPUFL_SSE2);
+
+ cpuid(0x80000000, eax, ebx, ecx, edx);
+ if(eax >= 0x80000001) {
+ cpuid(0x80000001, eax, ebx, ecx, edx);
+ /* 3DNow! */
+ if(edx & 0x80000000) flags |= XGI_CPUFL_3DNOW;
+ /* AMD MMXEXT */
+ if(IsAMD && (edx & 0x00400000)) flags |= XGI_CPUFL_MMX2;
+ }
+
+ return flags;
+}
+#endif
+
+#elif defined(__AMD64__) || defined(__amd64__) || defined(__x86_64__) /* AMD64 specific ***** */
+
+PREFETCH_FUNC(XGI_sse,SSE64,SSE,,FENCE,small_memcpy_amd64)
+
+#if 0 /* Jong 01/15/2009; ignore at the moment */
+
+static XGIMCFuncData MCFunctions_AMD64[] = {
+ {XGI_libc_memcpy, "libc", XGI_CPUFL_LIBC, 2, 2, FALSE},
+ {XGI_builtin_memcpy,"built-in-1",XGI_CPUFL_BI, 1, 1, FALSE},
+ {XGI_builtin_memcp2,"built-in-2",XGI_CPUFL_BI2, 3, 3, FALSE},
+ {XGI_sse_memcpy, "SSE", XGI_CPUFL_SSE, 0, 0, TRUE},
+ {NULL, "", 0, 10, 10, FALSE}
+};
+
+#define Def_FL (XGI_CPUFL_LIBC | XGI_CPUFL_BI | XGI_CPUFL_BI2)
+
+static unsigned int XGI_GetCpuFeatures(ScrnInfoPtr pScrn)
+{
+ return((unsigned int)(XGI_CPUFL_SSE|XGI_CPUFL_SSE2));
+}
+#endif
+
+#else /* Specific for other archs ******************************** */
+
+/* Fill in here */
+#if 0 /* Jong 01/15/2009; ignore at the moment */
+
+#define Def_FL (XGI_CPUFL_LIBC)
+
+static unsigned int XGI_GetCpuFeatures(ScrnInfoPtr pScrn)
+{
+ return((unsigned int)(0));
+}
+
+#endif
+
+#endif
+
+/**********************************************************************/
+/* Benchmark the video copy routines and choose the fastest */
+/**********************************************************************/
+
+#if 0 /* Jong 01/15/2009; ignore at the moment */
+#ifdef XGI_canBenchmark
+static vidCopyFunc
+XGIVidCopyInitGen(ScreenPtr pScreen, XGIMCFuncData *MCFunctions, vidCopyFunc *UMemCpy, Bool from)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ XGIPtr pXGI = XGIPTR(pScrn);
+ void *fbhandle = NULL;
+ char *frqBuf = NULL;
+ UChar *buf1, *buf2, *buf3;
+ double cpuFreq = 0.0;
+ unsigned int myCPUflags = pXGI->CPUFlags | Def_FL;
+ int best, secondbest;
+#ifdef XGI_haveProc
+ char buf[CPUBUFFERSIZE];
+#endif
+
+ PDEBUG(ErrorF("---XGIVidCopyInitGen()...begin\n"));
+ *UMemCpy = XGI_libc_memcpy;
+
+ /* Bail out if user disabled benchmarking */
+ if(!pXGI->BenchMemCpy) {
+ PDEBUG(ErrorF("---return XGI_libc_memcpy() as vidCopyFunc...\n"));
+ return XGI_libc_memcpy;
+ }
+
+#ifdef XGI_haveProc
+ /* Read /proc/cpuinfo into buf */
+ if(XGI_ReadProc(buf, "/proc/cpuinfo")) {
+
+ /* Extract CPU frequency */
+ frqBuf = XGI_GetCPUFreq(pScrn, buf, &cpuFreq);
+
+ }
+#endif
+
+ /* Allocate buffers; buf1:LFB; buf2,buf3:system memory */
+ if(!(fbhandle = XGI_AllocBuffers(pScrn, &buf1, &buf2, &buf3))) {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Failed to allocate video RAM for video data transfer benchmark\n");
+ return XGI_GetBestByGrade(pScrn, MCFunctions, myCPUflags, UMemCpy, from);
+ }
+
+ /* Perform Benchmark */
+ PDEBUG(ErrorF("---Perform XGI_BenchmarkMemcpy()...\n"));
+ best = XGI_BenchmarkMemcpy(pScrn, MCFunctions, myCPUflags, buf1,
+ (UChar *)(((unsigned long)buf2 + 15) & ~15),
+ (UChar *)(((unsigned long)buf3 + 15) & ~15),
+ frqBuf, cpuFreq, UMemCpy, &secondbest, from);
+
+ /* Free buffers */
+ XGIFreeFBMemory(pScrn, &fbhandle);
+ xfree(buf2);
+ xfree(buf3);
+
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+ "Using %s method for aligned data transfers %s video RAM\n",
+ MCFunctions[best].mName,
+ from ? "from" : "to");
+
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+ "Using %s method for unaligned data transfers %s video RAM\n",
+ MCFunctions[secondbest].mName,
+ from ? "from" : "to");
+
+ return MCFunctions[best].mFunc;
+}
+#endif /* canBenchmark */
+#endif
+
+/**********************************************************************/
+/* main(): Get CPU capabilities */
+/* (called externally) */
+/**********************************************************************/
+#if 0 /* Jong 01/15/2009; ignore at the moment */
+
+unsigned int
+XGIGetCPUFlags(ScrnInfoPtr pScrn)
+{
+ unsigned int myCPUflags = XGI_GetCpuFeatures(pScrn);
+
+#ifdef XGI_checkosforsse
+ if(myCPUflags & (XGI_CPUFL_SSE | XGI_CPUFL_SSE2)) {
+
+ /* Check if OS supports usage of SSE instructions */
+ if(!(CheckOSforSSE(pScrn))) {
+ myCPUflags &= ~(XGI_CPUFL_SSE | XGI_CPUFL_SSE2);
+ }
+
+ }
+#endif
+
+ return myCPUflags;
+}
+
+#endif
+
+/**********************************************************************/
+/* main(): XGIVidCopyInit() */
+/* (called externally) */
+/* (XGIGetCPUFlags must be called before this one) */
+/**********************************************************************/
+
+#if 0 /* Jong 01/15/2009; ignore at the moment */
+vidCopyFunc XGIVidCopyInit(ScreenPtr pScreen, vidCopyFunc *UMemCpy, Bool from)
+{
+/* Jong 01/08/2009; test for performance */
+#if defined(__i386__) && defined(XGI_canBenchmark)
+ PDEBUG(ErrorF("XGIVidCopyInit()-i386...\n"));
+ return(XGIVidCopyInitGen(pScreen, MCFunctions_i386, UMemCpy, from));
+#elif (defined(__AMD64__) || defined(__amd64__) || defined(__x86_64__)) && defined(XGI_canBenchmark)
+ PDEBUG(ErrorF("XGIVidCopyInit()-AMD64-x86_64...\n"));
+ return(XGIVidCopyInitGen(pScreen, MCFunctions_AMD64, UMemCpy, from));
+#else /* Other cases: Use libc memcpy() */
+ *UMemCpy = XGI_libc_memcpy;
+ PDEBUG(ErrorF("XGIVidCopyInit()-generic...\n"));
+ return XGI_libc_memcpy;
+#endif
+}
+#endif
+
+#if 0 /* Jong 01/15/2009; ignore at the moment */
+vidCopyFunc XGIVidCopyGetDefault(void)
+{
+ return XGI_libc_memcpy;
+}
+#endif
+
+#endif /* GNU C */
+
+
diff --git a/src/xgi_opt.c b/src/xgi_opt.c index 4aac85e..f25ae79 100644 --- a/src/xgi_opt.c +++ b/src/xgi_opt.c @@ -47,6 +47,7 @@ typedef enum { OPTION_SW_CURSOR, OPTION_HW_CURSOR, + OPTION_ACCELMETHOD, OPTION_NOACCEL, OPTION_TURBOQUEUE, OPTION_RENDER, @@ -97,6 +98,11 @@ typedef enum { OPTION_ENABLEXGICTRL, OPTION_STOREDBRI, OPTION_STOREDPBRI, + OPTION_RUNTIME_DEBUG, /* Jong 07/27/2009 */
+ OPTION_TARGET_RATE, /* Jong@09032009 */
+ OPTION_IGNORE_DDC, /* Jong@09032009 */
+ OPTION_NONDDC_DEFAULT_MODE, /* Jong@09042009 */
+ OPTION_GAMMA_RGB, /* Jong@09092009 */
#ifdef XGI_CP XGI_CP_OPT_OPTIONS #endif @@ -106,12 +112,13 @@ typedef enum { static const OptionInfoRec XGIOptions[] = { { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_HW_CURSOR, "HWcursor", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_ACCELMETHOD, "AccelMethod", OPTV_STRING, {0}, FALSE }, { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_TURBOQUEUE, "TurboQueue", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_RENDER, "RenderAcceleration", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_FORCE_CRT1TYPE, "ForceCRT1Type", OPTV_STRING, {0}, FALSE }, { OPTION_FORCE_CRT2TYPE, "ForceCRT2Type", OPTV_STRING, {0}, FALSE }, - { OPTION_YPBPRAR, "YPbPrAspectRatio", OPTV_STRING, {0}, FALSE }, + { OPTION_YPBPRAR, "YPbPrAspectRatio", OPTV_STRING, {0}, FALSE }, { OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_DRI, "DRI", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_AGP_SIZE, "AGPSize", OPTV_INTEGER, {0}, FALSE }, @@ -152,6 +159,11 @@ static const OptionInfoRec XGIOptions[] = { { OPTION_CRT2POS2, "TwinViewOrientation", OPTV_STRING, {0}, FALSE }, /* alias */ { OPTION_METAMODES, "MetaModes", OPTV_STRING, {0}, FALSE }, { OPTION_MERGEDDPI, "MergedDPI", OPTV_STRING, {0}, FALSE }, + { OPTION_RUNTIME_DEBUG, "RunTimeDebug", OPTV_BOOLEAN, {0}, -1 }, /* Jong 07/27/2009 */
+ { OPTION_TARGET_RATE, "TargetRate", OPTV_INTEGER, {0}, -1 }, /* Jong@09032009 */
+ { OPTION_IGNORE_DDC, "IgnoreDDC", OPTV_BOOLEAN, {0}, -1 }, /* Jong@09032009 */
+ { OPTION_NONDDC_DEFAULT_MODE, "NonDDCDefaultMode", OPTV_STRING, {0}, FALSE }, /* Jong@09042009 */
+ { OPTION_GAMMA_RGB, "GammaRGB", OPTV_STRING, {0}, FALSE }, /* Jong@09092009 */
#ifdef XGIXINERAMA { OPTION_NOXGIXINERAMA, "NoMergedXinerama", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_NOXGIXINERAMA2, "NoTwinviewXineramaInfo", OPTV_BOOLEAN, {0}, FALSE }, /* alias */ @@ -164,6 +176,10 @@ static const OptionInfoRec XGIOptions[] = { { -1, NULL, OPTV_NONE, {0}, FALSE } }; +unsigned int g_GammaRed; +unsigned int g_GammaGreen; +unsigned int g_GammaBlue; + void xgiOptions(ScrnInfoPtr pScrn) { @@ -201,7 +217,13 @@ xgiOptions(ScrnInfoPtr pScrn) pXGI->HWCursor = TRUE; pXGI->Rotate = FALSE; pXGI->ShadowFB = FALSE; - pXGI->loadDRI = TRUE; + + /* Jong 01/22/2009; only XG40 has 3-d feature */ + if(pXGI->Chipset == PCI_CHIP_XGIXG40) + pXGI->loadDRI = TRUE; + else + pXGI->loadDRI = FALSE; + pXGI->agpWantedPages = AGP_PAGES; pXGI->NoXvideo = FALSE; pXGI->maxxfbmem = 0; @@ -251,6 +273,99 @@ xgiOptions(ScrnInfoPtr pScrn) /* Collect the options */ + int TargetRefreshRate = 0; + if(xf86GetOptValInteger(pXGI->Options /* pScrn->monitor->options */, OPTION_TARGET_RATE, &TargetRefreshRate)) + { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Monitor (Option) : Set target refresh rate at %d for all modes...\n", TargetRefreshRate); + } + + pXGI->TargetRefreshRate = TargetRefreshRate; + + pXGI->IgnoreDDC = FALSE; + if(xf86GetOptValBool(pXGI->Options, OPTION_IGNORE_DDC, &pXGI->IgnoreDDC)) + { + if(pXGI->IgnoreDDC == TRUE) + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Monitor (Option) : IgnoreDDC \n"); + } +#if 0 /* can support 1280x768 but not being applied */ + else + { + pXGI->IgnoreDDC = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Monitor (Option) : set IgnoreDDC as default\n"); + } +#endif + + pXGI->Non_DDC_DefaultMode = FALSE; + pXGI->Non_DDC_DefaultResolutionX = 1024; + pXGI->Non_DDC_DefaultResolutionY = 768; + pXGI->Non_DDC_DefaultRefreshRate = 60; + + char ModeStringFormat[32] = "%[^x]x%[^@]@%[^\n]" /* "%[^x]+%[^@]+%[^H^z]" */; + char* Non_DDCDefaultMode = ""; + char Non_DDCDefaultResolutionX[8] = ""; + char Non_DDCDefaultResolutionY[8] = ""; + char Non_DDCDefaultRefreshRate[8] = ""; + + /* strcpy(ModeStringFormat, "%[^+]x%[^+]@%[^\n]"); */ + + if((Non_DDCDefaultMode = (char *)xf86GetOptValString(pXGI->Options, OPTION_NONDDC_DEFAULT_MODE))) + { + sscanf(Non_DDCDefaultMode, ModeStringFormat, + Non_DDCDefaultResolutionX , + Non_DDCDefaultResolutionY , + Non_DDCDefaultRefreshRate ); + + if( (xf86NameCmp(Non_DDCDefaultResolutionX,"") == NULL) || (xf86NameCmp(Non_DDCDefaultResolutionY,"") == NULL) ) + { + strcpy(Non_DDCDefaultResolutionX, "1024"); + strcpy(Non_DDCDefaultResolutionY, "768"); + } + + if( (xf86NameCmp(Non_DDCDefaultRefreshRate,"") == NULL) || (xf86NameCmp(Non_DDCDefaultRefreshRate,"auto") == NULL) ) + strcpy(Non_DDCDefaultRefreshRate, "60"); + + ErrorF("Non-DDC default mode is (%s x %s @ %s Hz)...\n", + Non_DDCDefaultResolutionX , + Non_DDCDefaultResolutionY , + Non_DDCDefaultRefreshRate ); + + pXGI->Non_DDC_DefaultMode = TRUE; + + pXGI->Non_DDC_DefaultResolutionX = atoi(Non_DDCDefaultResolutionX); + pXGI->Non_DDC_DefaultResolutionY = atoi(Non_DDCDefaultResolutionY); + pXGI->Non_DDC_DefaultRefreshRate = atoi(Non_DDCDefaultRefreshRate); + + ErrorF("Non-DDC default mode is (%d x %d @ %d Hz)...\n", + pXGI->Non_DDC_DefaultResolutionX , + pXGI->Non_DDC_DefaultResolutionY , + pXGI->Non_DDC_DefaultRefreshRate ); + } + + /* Jong@09092009; gamma value */ + g_GammaRed = g_GammaGreen = g_GammaBlue = 1000; + + char GammaStringFormat[32] = "%[^,],%[^,],%[^\n]"; + char* GammaRGB = ""; + char GammaRed[8] = ""; + char GammaGreen[8] = ""; + char GammaBlue[8] = ""; + + if((GammaRGB = (char *)xf86GetOptValString(pXGI->Options, OPTION_GAMMA_RGB))) + { + ErrorF("GammaRGB is (%s) from xorg.conf\n", GammaRGB); + sscanf(GammaRGB, GammaStringFormat, + GammaRed , + GammaGreen , + GammaBlue ); + ErrorF("GammaRGB is (%s, %s, %s) after parsing\n", GammaRed, GammaGreen, GammaBlue); + + g_GammaRed = atoi(GammaRed); + g_GammaGreen = atoi(GammaGreen); + g_GammaBlue = atoi(GammaBlue); + + ErrorF("GammaRGB is (%d, %d, %d) after atoi()\n", g_GammaRed, g_GammaGreen, g_GammaBlue); + } + /* MaxXFBMem * This options limits the amount of video memory X uses for screen * and off-screen buffers. This option should be used if using DRI @@ -276,9 +391,28 @@ xgiOptions(ScrnInfoPtr pScrn) xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "2D Acceleration disabled\n"); } + /* Jong@10022009; for xvinfo */ if ((pXGI->Chipset== PCI_CHIP_XGIXG20)||(pXGI->Chipset== PCI_CHIP_XGIXG21)||(pXGI->Chipset== PCI_CHIP_XGIXG27)) - pXGI->NoXvideo = TRUE; + pXGI->NoXvideo = TRUE; + pXGI->useEXA = FALSE; /* default : XAA */ + if(!pXGI->NoAccel) + { + from = X_DEFAULT; + if((strptr = (char *)xf86GetOptValString(pXGI->Options, OPTION_ACCELMETHOD))) { + if(!xf86NameCmp(strptr,"XAA")) { + from = X_CONFIG; + pXGI->useEXA = FALSE; + } else if(!xf86NameCmp(strptr,"EXA")) { + from = X_CONFIG; + pXGI->useEXA = TRUE; + } + } + + xf86DrvMsg(pScrn->scrnIndex, from, "Using %s acceleration architecture\n", + pXGI->useEXA ? "EXA" : "XAA"); + } + /* SWCursor * HWCursor * Chooses whether to use the hardware or software cursor @@ -435,6 +569,10 @@ xgiOptions(ScrnInfoPtr pScrn) } } + /* Jong 07/27/2009; get option of run-time debug */
+ if(!xf86GetOptValBool(pXGI->Options, OPTION_RUNTIME_DEBUG, &g_bRunTimeDebug))
+ g_bRunTimeDebug=0;
+ #ifdef XF86DRI /* DRI */ from = X_DEFAULT; diff --git a/src/xgi_regs.h b/src/xgi_regs.h index a02dad6..a1abcae 100644 --- a/src/xgi_regs.h +++ b/src/xgi_regs.h @@ -29,6 +29,32 @@ #ifndef _XGI_REGS_H_ #define _XGI_REGS_H_ +/* Jong 02/11/2009; replace inb/outb */ +#if defined(__arm__)
+#ifndef minb +#define minb(p) MMIO_IN8(0, (p)) +#endif +#ifndef moutb +#define moutb(p,v) MMIO_OUT8(0, (p),(v)) +#endif +#ifndef minw +#define minw(p) MMIO_IN16(0, (p)) +#endif +#ifndef moutw +#define moutw(p,v) MMIO_OUT16(0, (p)) +#endif +#ifndef minl +#define minl(p) MMIO_IN32(0, (p)) +#endif +#ifndef moutl +#define moutl(p,v) MMIO_OUT32(0, (p), (v)) +#endif + +/* Jong 02/11/2009; replace inb/outb */ +#define inb(p) minb(p) +#define outb(p, v) moutb(p, v) +#endif + #include "vgaHW.h" #define inXGIREG(base) inb(base) @@ -79,7 +105,7 @@ #define GENMASK(mask) BITMASK(1?mask,0?mask) #define GETBITS(var,mask) (((var) & GENMASK(mask)) >> (0?mask)) -#define SETBITS(val,mask) ((val) << (0?mask)) +/* #define SETBITS(val,mask) ((val) << (0?mask)) */ /* Jong@08032009 */ #define SETBIT(n) (1<<(n)) #define GETBITSTR(val,from,to) ((GETBITS(val,from)) << (0?to)) diff --git a/src/xgi_setup.c b/src/xgi_setup.c index a43965f..1bf8f44 100644 --- a/src/xgi_setup.c +++ b/src/xgi_setup.c @@ -39,8 +39,11 @@ #include "xf86Pci.h"
#include "xf86.h"
#include "fb.h"
+#include "xf1bpp.h"
+#include "xf4bpp.h"
#include "xf86_OSproc.h"
-#include "xorgVersion.h"
+#include "xf86Resources.h"
+#include "xf86Version.h"
#include "xf86cmap.h"
@@ -53,13 +56,8 @@ #include <X11/extensions/xf86dgastr.h>
#include "globals.h"
-#ifdef HAVE_XEXTPROTO_71 -#include <X11/extensions/dpmsconst.h> -#else -#define DPMS_SERVER -#include <X11/extensions/dpms.h> -#endif - +#define DPMS_SERVER
+#include <X11/extensions/dpms.h>
#include "vb_def.h"
extern int FbDevExist;
@@ -174,19 +172,10 @@ xgiXG2X_Setup(ScrnInfoPtr pScrn) ulMemSize = 8*1024 ;
}
- if (pXGI->Chipset == PCI_CHIP_XGIXG40) {
- const unsigned revision =
-#ifdef XSERVER_LIBPCIACCESS
- pXGI->PciInfo->revision
-#else
- pciReadLong(pXGI->PciTag, 0x08) & 0x0FF
-#endif
- ;
-
- /* Revision 2 cards encode the memory config bits slightly differently
- * from revision 1 cards.
- */
- if (revision == 2) {
+ if( pXGI->Chipset == PCI_CHIP_XGIXG40)
+ {
+ if ( (pciReadLong(pXGI->PciTag, 0x08) & 0xFF ) == 2 )
+ {
switch((ulMemConfig>>2)&0x1)
{
case 0:
@@ -582,12 +571,15 @@ XGI_InitHwDevInfo(ScrnInfoPtr pScrn) pHwDevInfo->pDevice = pXGI ;
pHwDevInfo->pjVirtualRomBase = pXGI->BIOS ;
+ PDEBUG(ErrorF("pHwDevInfo->pjVirtualRomBase = pXGI->BIOS = 0x%08lx\n",(ULONG)(pXGI->BIOS))) ;
+
pHwDevInfo->pjCustomizedROMImage = NULL ;
pHwDevInfo->pjVideoMemoryAddress = (UCHAR*)(pXGI->FbBase) ;
PDEBUG(ErrorF("pXGI->FbBase = 0x%08lx\n",(ULONG)(pXGI->FbBase))) ;
PDEBUG(ErrorF("pHwDevInfo->pjVideoMemoryAddress = 0x%08lx\n",(ULONG)(pHwDevInfo->pjVideoMemoryAddress))) ;
pHwDevInfo->ulVideoMemorySize = pXGI->FbMapSize ;
pHwDevInfo->pjIOAddress = pXGI->RelIO + 0x30 ;
+ PDEBUG(ErrorF("pHwDevInfo->pjIOAddress = 0x%08lx\n",(ULONG)(pHwDevInfo->pjIOAddress ))) ;
switch (pXGI->Chipset) {
case PCI_CHIP_XGIXG40:
diff --git a/src/xgi_vga.c b/src/xgi_vga.c index c6c6b4b..6003eb3 100644 --- a/src/xgi_vga.c +++ b/src/xgi_vga.c @@ -38,7 +38,7 @@ #include "xf86.h"
#include "xf86_OSproc.h"
-#include "xorgVersion.h"
+#include "xf86Version.h"
#include "xf86PciInfo.h"
#include "xf86Pci.h"
@@ -86,7 +86,11 @@ PDEBUG(ErrorF("XG40Init()\n")); (*pXGI->XGISave)(pScrn, pReg);
+#if !defined(__arm__)
outw(VGA_SEQ_INDEX, 0x8605);
+#else
+ moutl(XGISR, 0x8605);
+#endif
pReg->xgiRegs3C4[6] &= ~GENMASK(4:2);
@@ -220,7 +224,7 @@ PDEBUG(ErrorF("XG40Init()\n")); pReg->xgiRegs3C4[0x2D] = 0x80;
} /* end of set vclk */
- if (clock > 150000) { /* enable two-pixel mode */
+ if ( (pXGI->Chipset == PCI_CHIP_XGIXG40) && (clock > 150000) ) { /* enable two-pixel mode */
pReg->xgiRegs3C4[0x07] |= 0x80;
pReg->xgiRegs3C4[0x32] |= 0x08;
} else {
diff --git a/src/xgi_video.c b/src/xgi_video.c index 77a5a63..895f1d6 100644 --- a/src/xgi_video.c +++ b/src/xgi_video.c @@ -45,7 +45,15 @@ #include "config.h" #endif +/* Jong@09022009 */ +#ifdef XORG_VERSION_CURRENT
+#include "xorgVersion.h"
+
+#if (XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(6,9,0,0,0) )
#define VC //video capture +#endif + +#endif # ifdef VC #include <stdio.h> @@ -61,6 +69,7 @@ #include "xf86.h" #include "xf86_OSproc.h" +#include "xf86Resources.h" #include "compiler.h" #include "xf86PciInfo.h" #include "xf86Pci.h" @@ -465,8 +474,12 @@ XGISetupImageVideo(ScreenPtr pScreen) # endif //VC pPriv->currentBuf = 0; + +#ifdef XGI_USE_XAA pPriv->linear = NULL; pPriv->fbAreaPtr = NULL; +#endif + pPriv->fbSize = 0; pPriv->videoStatus = 0; pPriv->linebufMergeLimit = 1280; @@ -1039,12 +1052,13 @@ XGIStopVideo(ScrnInfoPtr pScrn, pointer data, Bool exit) } # endif //VC +#ifdef XGI_USE_XAA if(pPriv->fbAreaPtr) { xf86FreeOffscreenArea(pPriv->fbAreaPtr); pPriv->fbAreaPtr = NULL; pPriv->fbSize = 0; } - +#endif /* clear all flag */ pPriv->videoStatus = 0; @@ -1145,14 +1159,17 @@ XGIPutImage( pPriv->fbSize = totalSize; +#ifdef XGI_USE_XAA if(pPriv->fbAreaPtr) { xf86FreeOffscreenArea(pPriv->fbAreaPtr); } - +#endif + depth = (pScrn->bitsPerPixel + 7 ) / 8; pitch = pScrn->displayWidth * depth; lines = ((totalSize * 2) / pitch) + 1; +#ifdef XGI_USE_XAA pPriv->fbAreaPtr = xf86AllocateOffscreenArea(pScrn->pScreen, pScrn->displayWidth, lines, 0, NULL, NULL, NULL); @@ -1166,7 +1183,7 @@ XGIPutImage( pBox = &(pPriv->fbAreaPtr->box); pPriv->bufAddr[0] = (pBox->x1 * depth) + (pBox->y1 * pitch); pPriv->bufAddr[1] = pPriv->bufAddr[0] + totalSize; - +#endif } while(0); /* copy data */ diff --git a/src/xgi_video.h b/src/xgi_video.h index 96e0f89..7ff7d55 100644 --- a/src/xgi_video.h +++ b/src/xgi_video.h @@ -59,8 +59,11 @@ #define BOB_ODD 2 typedef struct { +#ifdef XGI_USE_XAA FBLinearPtr linear; FBAreaPtr fbAreaPtr; +#endif + int fbSize; CARD32 bufAddr[2]; diff --git a/src/xgi_videohw.c b/src/xgi_videohw.c index b050f92..09fedb5 100644 --- a/src/xgi_videohw.c +++ b/src/xgi_videohw.c @@ -34,7 +34,9 @@ #include "config.h" #endif +#define XGI_VIDEO_HW /* avoid compile error in xgi.h; weird! */
#include "xgi.h" + #include "xgi_videohw.h" #include "xgi_video.h" #include "fourcc.h" |
