diff --git a/src/vb_inta.c b/src/vb_inta.c deleted file mode 100644 index b6803b8..0000000 --- a/src/vb_inta.c +++ /dev/null @@ -1,1969 +0,0 @@ -/* #ifdef WIN2000 // INTA solution for WIN2000 */ - -#include -#include -#include -#include -#include - -#include "osdef.h" -#include "vb_def.h" -#include "vgatypes.h" -#include "vb_struct.h" - -#include "xgiv.h" -#include "dd_i2c.h" -#include "tools.h" - -#include "vb_util.h" -#include "vb_setmode.h" - -void SiSLVDSCH7019ControlCallback(PHW_DEVICE_EXTENSION pHWDE,PVOID Context); -void SiSTVCH7019ControlCallback(PHW_DEVICE_EXTENSION pHWDE, PVOID Context); -void XGINew_ExternalToBackup(PHW_DEVICE_EXTENSION pHWDE); -void XGINew_SetReadExternal(PHW_DEVICE_EXTENSION pHWDE); -void XGINew_SetReadInternal(PHW_DEVICE_EXTENSION pHWDE); -void XGINew_DisableWriteBackup(PHW_DEVICE_EXTENSION pHWDE); -void XGINew_EnableWriteBackup(PHW_DEVICE_EXTENSION pHWDE); -void XGINew_TurnOnBacklight(PHW_DEVICE_EXTENSION pHWDE); -int XGINew_WantToSetMode(PHW_DEVICE_EXTENSION pHWDE); -int XGINew_WantToChangeTimingRegister(PHW_DEVICE_EXTENSION pHWDE); -int XGINew_ReSet301VBTiming(PHW_DEVICE_EXTENSION pHWDE, PVB_DEVICE_INFO ); -void XGINew_TurnOffBacklight(PHW_DEVICE_EXTENSION pHWDE); -void XGINew_EnableWriteInternal(PHW_DEVICE_EXTENSION pHWDE); -void XGINew_DisableWriteInternal(PHW_DEVICE_EXTENSION pHWDE); -void XGINew_EnableWriteExternal(PHW_DEVICE_EXTENSION pHWDE); -void XGINew_DisableWriteExternal(PHW_DEVICE_EXTENSION pHWDE); -void XGINew_GRandAR13Changed(PHW_DEVICE_EXTENSION pHWDE); -BOOLEAN XGINew_IsVAMode(PVB_DEVICE_INFO pVBInfo ); -BOOLEAN XGINew_IsDualEdge(PVB_DEVICE_INFO pVBInfo); - - -/* --------------------------------------------------------------------- */ -/* Function : bVBIOSCanWorkWithINTA */ -/* Input : */ -/* Output : */ -/* Description : add INTA 03/18/03 */ -/* --------------------------------------------------------------------- */ -BOOLEAN bVBIOSCanWorkWithINTA(PXGI_HW_DEVICE_INFO pXGIHWDE) -{ - PUCHAR XGI_P3d4; - UCHAR bCR40,bCR41,bCR7D,bCR7E,bCR3A; - UCHAR bSaved3D4; - UCHAR temp; - - XGI_P3d4 = (PUCHAR) (pXGIHWDE->pjIOAddress); - XGI_P3d4 += CRTC_ADDRESS_PORT_COLOR; - - bSaved3D4 = VideoPortReadPortUchar(XGI_P3d4); - - if (pXGIHWDE->jChipType >= XG40) - { - VideoPortWritePortUchar(XGI_P3d4,0x7D); - bCR7D = VideoPortReadPortUchar(XGI_P3d4+1); - VideoPortWritePortUchar(XGI_P3d4,0x7E); - bCR7E = VideoPortReadPortUchar(XGI_P3d4+1); - } - else - { - VideoPortWritePortUchar(XGI_P3d4,0x40); - bCR40 = VideoPortReadPortUchar(XGI_P3d4+1); - VideoPortWritePortUchar(XGI_P3d4,0x41); - bCR41 = VideoPortReadPortUchar(XGI_P3d4+1); - } - VideoPortWritePortUchar(XGI_P3d4,0x3A); - bCR3A = VideoPortReadPortUchar(XGI_P3d4+1); - - VideoPortWritePortUchar(XGI_P3d4, bSaved3D4); - - if(pXGIHWDE->jChipType == SIS_330) - return FALSE; - if(bCR3A & 0x20) /* SMI??? */ - return FALSE; - - if (pXGIHWDE->jChipType >= XG40) - { - if ((bCR7D==0xFE)&&((bCR7E&0x0F)==0x0F)) - { - return TRUE; - } - else - { - return FALSE; - } - } - - if ((bCR40==0xFE)&&((bCR41&0xF0)==0xF0)) - { /* close CRTC */ - if((pXGIHWDE->jChipType == SIS_660)||(pXGIHWDE->jChipType == SIS_661)||(pXGIHWDE->jChipType == SIS_650M)||(pXGIHWDE->jChipType == SIS_760)) - { - VideoPortWritePortUchar(XGI_P3d4,0x51); - temp = VideoPortReadPortUchar(XGI_P3d4+1); - temp = (temp & (~0xE0)|0xA0); - VideoPortWritePortUchar(XGI_P3d4+1,temp); /* set write permitted */ - - VideoPortWritePortUchar(XGI_P3d4,0x56); - temp = VideoPortReadPortUchar(XGI_P3d4+1); - temp = (temp & (~0x18)|0x08); - VideoPortWritePortUchar(XGI_P3d4+1,temp); /* set read permitted */ - - } - return TRUE; - } - else - return FALSE; -} - -/* --------------------------------------------------------------------- */ -/* Function : DisableTimingRegWriteProtectINTA */ -/* Input : */ -/* Output : */ -/* Description : add INTA 03/18/03 */ -/* --------------------------------------------------------------------- */ -VOID DisableTimingRegWriteProtectINTA(PHW_DEVICE_EXTENSION pHWDE) -{ - PUCHAR XGI_P3d4; - UCHAR bCR51,bCR56,bCR61; - UCHAR bSaved3D4; - - XGI_P3d4 = pHWDE->pjIOAddress + CRTC_ADDRESS_PORT_COLOR; - - bSaved3D4 = VideoPortReadPortUchar(XGI_P3d4); - - VideoPortWritePortUchar(XGI_P3d4,0x61); - bCR61 = VideoPortReadPortUchar(XGI_P3d4+1); - VideoPortWritePortUchar(XGI_P3d4+1,(UCHAR)(bCR61&0xF7)); - - VideoPortWritePortUchar(XGI_P3d4,0x56); - bCR56 = VideoPortReadPortUchar(XGI_P3d4+1); - VideoPortWritePortUchar(XGI_P3d4+1,(UCHAR)(bCR56&0xE7)); - - VideoPortWritePortUchar(XGI_P3d4,0x51); - bCR51 = VideoPortReadPortUchar(XGI_P3d4+1); - VideoPortWritePortUchar(XGI_P3d4+1,(UCHAR)(bCR51&0x1F)); - - VideoPortWritePortUchar(XGI_P3d4, bSaved3D4); -} - -/* --------------------------------------------------------------------- */ -/* Function : EnableTimingRegWriteProtectINTA */ -/* Input : */ -/* Output : */ -/* Description : add INTA 03/18/03 */ -/* --------------------------------------------------------------------- */ -VOID EnableTimingRegWriteProtectINTA(PHW_DEVICE_EXTENSION pHWDE) -{ - - PUCHAR XGI_P3d4; - UCHAR bCR40,bCR41,bCR7D,bCR7E; - UCHAR bCR51,bCR56,bCR61; - UCHAR bSaved3D4; - - XGI_P3d4 = pHWDE->pjIOAddress + CRTC_ADDRESS_PORT_COLOR; - - bSaved3D4 = VideoPortReadPortUchar(XGI_P3d4); - - if (pHWDE->jChipID >= XG40) - { - VideoPortWritePortUchar(XGI_P3d4,0x7D); - bCR7D = VideoPortReadPortUchar(XGI_P3d4+1); - VideoPortWritePortUchar(XGI_P3d4,0x7E); - bCR7E = VideoPortReadPortUchar(XGI_P3d4+1); - - if ((bCR7D==0x00)&&((bCR7E&0x0F)==0x00)) - { - VideoPortWritePortUchar(XGI_P3d4,0x7D); - VideoPortWritePortUchar(XGI_P3d4+1,0xFF); - VideoPortWritePortUchar(XGI_P3d4,0x7E); - VideoPortWritePortUchar(XGI_P3d4+1,(UCHAR)(VideoPortReadPortUchar(XGI_P3d4+1)|0x0F)); - } - } - else - { - VideoPortWritePortUchar(XGI_P3d4,0x40); - bCR40 = VideoPortReadPortUchar(XGI_P3d4+1); - VideoPortWritePortUchar(XGI_P3d4,0x41); - bCR41 = VideoPortReadPortUchar(XGI_P3d4+1); - - if ((bCR40==0x00)&&((bCR41&0xF0)==0x00)) - { - VideoPortWritePortUchar(XGI_P3d4,0x40); - VideoPortWritePortUchar(XGI_P3d4+1,0xFF); - VideoPortWritePortUchar(XGI_P3d4,0x41); - VideoPortWritePortUchar(XGI_P3d4+1,(UCHAR)(VideoPortReadPortUchar(XGI_P3d4+1)|0xF0)); - } - } - - - VideoPortWritePortUchar(XGI_P3d4,0x61); - bCR61 = VideoPortReadPortUchar(XGI_P3d4+1); - VideoPortWritePortUchar(XGI_P3d4+1,(UCHAR)(bCR61|0x08)); - - VideoPortWritePortUchar(XGI_P3d4,0x56); - bCR56 = VideoPortReadPortUchar(XGI_P3d4+1); - VideoPortWritePortUchar(XGI_P3d4+1,(UCHAR)((bCR56&0xE7)|0x8)); - - VideoPortWritePortUchar(XGI_P3d4,0x51); - bCR51 = VideoPortReadPortUchar(XGI_P3d4+1); - VideoPortWritePortUchar(XGI_P3d4+1,(UCHAR)((bCR51&0x1F)|0xA0)); - - VideoPortWritePortUchar(XGI_P3d4, bSaved3D4); -} - -/* --------------------------------------------------------------------- */ -/* Function : vModifyLCDTiming301LVDS_INTANew */ -/* Input : */ -/* Output : */ -/* Description : add INTA 03/18/03 bainy */ -/* --------------------------------------------------------------------- */ -VOID vModifyLCDTiming301LVDS_INTANew( PHW_DEVICE_EXTENSION pHWDE ) -{ - PUCHAR XGINew_P3c4 , XGINew_P3d4 ; - UCHAR bSaved3C4 , bSaved3D4,temp ; - VB_DEVICE_INFO VBINF; - PVB_DEVICE_INFO pVBInfo = &VBINF; - XGINew_P3c4 = pHWDE->pjIOAddress + SEQ_ADDRESS_PORT ; - XGINew_P3d4 = pHWDE->pjIOAddress + CRTC_ADDRESS_PORT_COLOR ; - - VideoDebugPrint( ( 0 , "vModifyLCDTiming301LVDS_INTA: pHWDE->ulMonitorPowerState=%lx\n" , pHWDE->ulMonitorPowerState ) ) ; - VideoDebugPrint( ( 0 , "vModifyLCDTiming301LVDS_INTA: pHWDE->bMonitorPoweredOn=%x\n" , pHWDE->bMonitorPoweredOn ) ) ; - if ( pHWDE->ulMonitorPowerState == VideoPowerHibernate ) - return ; - - if ( !( pHWDE->bMonitorPoweredOn ) ) - return ; - - bSaved3C4 = VideoPortReadPortUchar( XGINew_P3c4 ) ; - bSaved3D4 = VideoPortReadPortUchar( XGINew_P3d4 ) ; - - - if ( XGINew_WantToSetMode( pHWDE ) ) - { - Newdebugcode( 0x66 ) ; - XGINew_TurnOffBacklight( pHWDE ) ; - XGI_DisplayOff(pVBInfo) ; - pHWDE->bCR34 = 0xFF ; - } - else - { - if ( XGINew_WantToChangeTimingRegister( pHWDE ) ) - { - Newdebugcode( 0x55 ) ; - XGINew_DisableWriteExternal( pHWDE ) ; - XGINew_EnableWriteInternal( pHWDE ) ; - XGINew_DisableWriteBackup( pHWDE ) ; - XGINew_SetReadInternal( pHWDE ) ; - VideoDebugPrint( ( 0 , "start ModifyLCD: %lx\n" , pHWDE->ulMonitorPowerState ) ) ; - XGINew_ReSet301VBTiming( pHWDE, pVBInfo ) ; - XGI_DisplayOn(pVBInfo) ; /* alan 2003/10/01 */ - XGINew_ExternalToBackup( pHWDE ) ; - XGINew_SetReadExternal( pHWDE ) ; - XGINew_DisableWriteInternal( pHWDE ) ; - XGINew_EnableWriteExternal( pHWDE ) ; - XGINew_DisableWriteBackup( pHWDE ) ; - XGINew_TurnOnBacklight( pHWDE ) ; - } - } - - VideoPortWritePortUchar( XGINew_P3c4 , bSaved3C4 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , bSaved3D4 ) ; - - XGINew_GRandAR13Changed( pHWDE ) ; - - - bSaved3C4 = VideoPortReadPortUchar( XGINew_P3c4) ; - bSaved3D4 = VideoPortReadPortUchar( XGINew_P3d4 ) ; - - VideoPortWritePortUchar( XGINew_P3c4 , bSaved3C4 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , bSaved3D4 ) ; - return ; -} - - -/* --------------------------------------------------------------------- */ -/* Function : vModifyLCDTiming301B_INTANew */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -VOID vModifyLCDTiming301B_INTANew( PHW_DEVICE_EXTENSION pHWDE ) -{ - PUCHAR XGINew_P3c4 , XGINew_P3d4 ; - UCHAR bSaved3C4 , bSaved3D4,temp ; - VB_DEVICE_INFO VBINF; - PVB_DEVICE_INFO pVBInfo = &VBINF; - XGINew_P3c4 = pHWDE->pjIOAddress + SEQ_ADDRESS_PORT ; - XGINew_P3d4 = pHWDE->pjIOAddress + CRTC_ADDRESS_PORT_COLOR ; - - VideoDebugPrint( ( 0 , "vModifyLCDTiming301B_INTANew: pHWDE->ulMonitorPowerState=%lx\n" , pHWDE->ulMonitorPowerState ) ) ; - VideoDebugPrint( ( 0 , "vModifyLCDTiming301B_INTANew: pHWDE->bMonitorPoweredOn=%x\n" , pHWDE->bMonitorPoweredOn ) ) ; - if ( pHWDE->ulMonitorPowerState == VideoPowerHibernate ) - return ; - - if ( !( pHWDE->bMonitorPoweredOn ) ) - return ; - - bSaved3C4 = VideoPortReadPortUchar( XGINew_P3c4) ; - bSaved3D4 = VideoPortReadPortUchar( XGINew_P3d4 ) ; - - - if ( XGINew_WantToSetMode( pHWDE ) ) - { - Newdebugcode( 0x66 ) ; - XGINew_TurnOffBacklight( pHWDE ) ; - XGI_DisplayOff(pVBInfo) ; - pHWDE->bCR34 = 0xFF ; - } - else - { - if ( XGINew_WantToChangeTimingRegister( pHWDE ) ) - { - Newdebugcode( 0x55 ) ; - XGINew_DisableWriteExternal( pHWDE ) ; - XGINew_EnableWriteInternal( pHWDE ) ; - XGINew_DisableWriteBackup( pHWDE ) ; - XGINew_SetReadInternal( pHWDE ) ; - VideoDebugPrint( ( 0 , "start ModifyLCD: %lx\n" , pHWDE->ulMonitorPowerState ) ) ; - XGINew_ReSet301VBTiming( pHWDE, pVBInfo ) ; - XGI_DisplayOn(pVBInfo) ; /* alan 2003/10/01 */ - XGINew_ExternalToBackup( pHWDE ) ; - XGINew_SetReadExternal( pHWDE ) ; - XGINew_DisableWriteInternal( pHWDE ) ; - XGINew_EnableWriteExternal( pHWDE ) ; - XGINew_DisableWriteBackup( pHWDE ) ; - XGINew_TurnOnBacklight( pHWDE ) ; - } - } - - VideoPortWritePortUchar( XGINew_P3c4 , bSaved3C4 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , bSaved3D4 ) ; - - XGINew_GRandAR13Changed( pHWDE ) ; - - - bSaved3C4 = VideoPortReadPortUchar( XGINew_P3c4 ) ; - bSaved3D4 = VideoPortReadPortUchar( XGINew_P3d4 ) ; - - VideoPortWritePortUchar( XGINew_P3c4 , bSaved3C4 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , bSaved3D4 ) ; - return ; -} - - -/* --------------------------------------------------------------------- */ -/* Function : vModifyCRT1Timing301LVDS_INTANew */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -VOID vModifyCRT1Timing301LVDS_INTANew( PHW_DEVICE_EXTENSION pHWDE ) -{ - return ; -} - - -/* --------------------------------------------------------------------- */ -/* Function : vModifyTVTiming301LVDS_INTANew */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -VOID vModifyTVTiming301LVDS_INTANew( PHW_DEVICE_EXTENSION pHWDE ) -{ - PUCHAR XGINew_P3c4 , XGINew_P3d4 ; - UCHAR bSaved3C4 , bSaved3D4 , temp ; - VB_DEVICE_INFO VBINF; - PVB_DEVICE_INFO pVBInfo = &VBINF; - XGINew_P3c4 = pHWDE->pjIOAddress + SEQ_ADDRESS_PORT ; - XGINew_P3d4 = pHWDE->pjIOAddress + CRTC_ADDRESS_PORT_COLOR ; - - VideoDebugPrint( ( 0 , "vModifyTVTiming301LVDS_INTA: pHWDE->ulMonitorPowerState=%lx\n" , pHWDE->ulMonitorPowerState ) ) ; - VideoDebugPrint( ( 0 , "vModifyTVTiming301LVDS_INTA: pHWDE->bMonitorPoweredOn=%x\n" , pHWDE->bMonitorPoweredOn ) ) ; - if ( pHWDE->ulMonitorPowerState == VideoPowerHibernate ) - return ; - - if ( !( pHWDE->bMonitorPoweredOn ) ) - return; - - bSaved3C4 = VideoPortReadPortUchar( XGINew_P3c4 ) ; - bSaved3D4 = VideoPortReadPortUchar( XGINew_P3d4 ) ; - - - if ( XGINew_WantToSetMode( pHWDE ) ) - { - Newdebugcode( 0x66 ) ; - XGINew_TurnOffBacklight( pHWDE ) ; - XGI_DisplayOff(pVBInfo) ; - pHWDE->bCR34 = 0xFF ; - } - else - { - if ( XGINew_WantToChangeTimingRegister( pHWDE ) ) - { - Newdebugcode( 0x55 ) ; - XGINew_DisableWriteExternal( pHWDE ) ; - XGINew_EnableWriteInternal( pHWDE ) ; - XGINew_DisableWriteBackup( pHWDE ) ; - XGINew_SetReadInternal( pHWDE ) ; - VideoDebugPrint( ( 0 , "start ModifyLCD: %lx\n" , pHWDE->ulMonitorPowerState ) ) ; - XGINew_ReSet301VBTiming( pHWDE, pVBInfo ) ; - XGI_DisplayOn(pVBInfo) ; /* alan 2003/10/01 */ - XGINew_ExternalToBackup( pHWDE ) ; - XGINew_SetReadExternal( pHWDE ) ; - XGINew_DisableWriteInternal( pHWDE ) ; - XGINew_EnableWriteExternal( pHWDE ) ; - XGINew_DisableWriteBackup( pHWDE ) ; - XGINew_TurnOnBacklight(pHWDE) ; - } - } - - VideoPortWritePortUchar( XGINew_P3c4 , bSaved3C4 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , bSaved3D4 ) ; - - /* XGINew_GRandAR13Changed(pHWDE) ; */ - - bSaved3C4 = VideoPortReadPortUchar( XGINew_P3c4 ) ; - bSaved3D4 = VideoPortReadPortUchar( XGINew_P3d4 ) ; - - VideoPortWritePortUchar( XGINew_P3c4 , bSaved3C4 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , bSaved3D4 ) ; - DelayUS( 1000 ) ; /* for CRT+TV quit debug in winxp dos. */ - - return ; -} - -/* --------------------------------------------------------------------- */ -/* Function : vModifyTVTiming301B_INTANew */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -VOID vModifyTVTiming301B_INTANew( PHW_DEVICE_EXTENSION pHWDE ) -{ - PUCHAR XGINew_P3c4 , XGINew_P3d4 ; - UCHAR bSaved3C4 , bSaved3D4 , temp ; - VB_DEVICE_INFO VBINF; - PVB_DEVICE_INFO pVBInfo = &VBINF; - XGINew_P3c4 = pHWDE->pjIOAddress + SEQ_ADDRESS_PORT ; - XGINew_P3d4 = pHWDE->pjIOAddress + CRTC_ADDRESS_PORT_COLOR ; - - VideoDebugPrint( ( 0 , "vModifyTVTiming301LVDS_INTA: pHWDE->ulMonitorPowerState=%lx\n" , pHWDE->ulMonitorPowerState ) ) ; - VideoDebugPrint( ( 0 , "vModifyTVTiming301LVDS_INTA: pHWDE->bMonitorPoweredOn=%x\n" , pHWDE->bMonitorPoweredOn ) ) ; - if ( pHWDE->ulMonitorPowerState == VideoPowerHibernate ) - return ; - - if ( !( pHWDE->bMonitorPoweredOn ) ) - return; - - bSaved3C4 = VideoPortReadPortUchar( XGINew_P3c4 ) ; - bSaved3D4 = VideoPortReadPortUchar( XGINew_P3d4 ) ; - - - if ( XGINew_WantToSetMode( pHWDE ) ) - { - Newdebugcode( 0x66 ) ; - XGINew_TurnOffBacklight( pHWDE ) ; - XGI_DisplayOff(pVBInfo) ; - pHWDE->bCR34 = 0xFF ; - } - else - { - if ( XGINew_WantToChangeTimingRegister( pHWDE ) ) - { - Newdebugcode( 0x55 ) ; - XGINew_DisableWriteExternal( pHWDE ) ; - XGINew_EnableWriteInternal( pHWDE ) ; - XGINew_DisableWriteBackup( pHWDE ) ; - XGINew_SetReadInternal( pHWDE ) ; - VideoDebugPrint( ( 0 , "start ModifyLCD: %lx\n" , pHWDE->ulMonitorPowerState ) ) ; - XGINew_ReSet301VBTiming( pHWDE, pVBInfo ) ; - XGI_DisplayOn(pVBInfo) ; /* alan 2003/10/01 */ - XGINew_ExternalToBackup( pHWDE ) ; - XGINew_SetReadExternal( pHWDE ) ; - XGINew_DisableWriteInternal( pHWDE ) ; - XGINew_EnableWriteExternal( pHWDE ) ; - XGINew_DisableWriteBackup( pHWDE ) ; - XGINew_TurnOnBacklight(pHWDE) ; - } - } - - VideoPortWritePortUchar( XGINew_P3c4 , bSaved3C4 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , bSaved3D4 ) ; - - /* XGINew_GRandAR13Changed(pHWDE) ; */ - - bSaved3C4 = VideoPortReadPortUchar( XGINew_P3c4 ) ; - bSaved3D4 = VideoPortReadPortUchar( XGINew_P3d4 ) ; - - VideoPortWritePortUchar( XGINew_P3c4 , bSaved3C4 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , bSaved3D4 ) ; - DelayUS( 1000 ) ; /* for CRT+TV quit debug in winxp dos. */ - - -} - -/* --------------------------------------------------------------------- */ -/* Function : vModifyLCDTimingLVDSNew */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -VOID vModifyLCDTimingLVDSNew( PHW_DEVICE_EXTENSION pHWDE ) -{ -} - - -/* --------------------------------------------------------------------- */ -/* Function : vModifyCRT1TimingLVDSNew */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -VOID vModifyCRT1TimingLVDSNew( PHW_DEVICE_EXTENSION pHWDE ) -{ -} - - -/* --------------------------------------------------------------------- */ -/* Function : vModifyCRT1TimingLVDS_INTANew */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -VOID vModifyCRT1TimingLVDS_INTANew(PHW_DEVICE_EXTENSION pHWDE) -{ - return ; -} - - -/* --------------------------------------------------------------------- */ -/* Function : vModifyLCDTimingLVDS_INTANew */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -VOID vModifyLCDTimingLVDS_INTANew(PHW_DEVICE_EXTENSION pHWDE) -{ - return ; -} - - -/* --------------------------------------------------------------------- */ -/* Function : vModifyTVTimingLVDS_INTANew */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -VOID vModifyTVTimingLVDS_INTANew(PHW_DEVICE_EXTENSION pHWDE) -{ - return ; -} - - -/* --------------------------------------------------------------------- */ -/* Function : vModifyCRT1TimingCH7019New */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -VOID vModifyCRT1TimingCH7019New(PHW_DEVICE_EXTENSION pHWDE) -{ -} - - -/* --------------------------------------------------------------------- */ -/* Function : vModifyCRT1TimingCH7019_INTANew */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -VOID vModifyCRT1TimingCH7019_INTANew(PHW_DEVICE_EXTENSION pHWDE) -{ - return ; -} - - -/* --------------------------------------------------------------------- */ -/* Function : vModifyLCDTimingCH7019_INTANew */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -VOID vModifyLCDTimingCH7019_INTANew(PHW_DEVICE_EXTENSION pHWDE) -{ - return ; -} - - -/* --------------------------------------------------------------------- */ -/* Function : vModifyLCDTimingCH7019New */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -VOID vModifyLCDTimingCH7019New(PHW_DEVICE_EXTENSION pHWDE) -{ - return ; -} - - -/* --------------------------------------------------------------------- */ -/* Function : vModifyTVTimingCH7019_INTANew */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -VOID vModifyTVTimingCH7019_INTANew(PHW_DEVICE_EXTENSION pHWDE) -{ - return ; -} - - -/* --------------------------------------------------------------------- */ -/* Function : vModifyTVTimingCH7019New */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -VOID vModifyTVTimingCH7019New(PHW_DEVICE_EXTENSION pHWDE) -{ - return ; -} - - -/* --------------------------------------------------------------------- */ -/* Function : vModifyLCDTiming301BNew */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -VOID vModifyLCDTiming301BNew(PHW_DEVICE_EXTENSION pHWDE) -{ - return ; -} - - -/* --------------------------------------------------------------------- */ -/* Function : vModifyCRT1Timing301LVDSNew */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -VOID vModifyCRT1Timing301LVDSNew(PHW_DEVICE_EXTENSION pHWDE) -{ - return ; -} - - -/* --------------------------------------------------------------------- */ -/* Function : vModifyLCDTiming301LVDSNew */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -VOID vModifyLCDTiming301LVDSNew(PHW_DEVICE_EXTENSION pHWDE) -{ - return ; -} - - -/* --------------------------------------------------------------------- */ -/* Function : vModifyTVTiming301LVDSNew */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -VOID vModifyTVTiming301LVDSNew(PHW_DEVICE_EXTENSION pHWDE) -{ -} - - -/* --------------------------------------------------------------------- */ -/* Function : XGINew_WantToSetMode */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -int XGINew_WantToSetMode(PHW_DEVICE_EXTENSION pHWDE) -{ - PUCHAR XGINew_P3d4 ; - - XGINew_P3d4 = pHWDE->pjIOAddress + CRTC_ADDRESS_PORT_COLOR ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x3A ) ; - if ( VideoPortReadPortUchar( XGINew_P3d4 + 1 ) & 8 ) - return( 1 ) ; - else - return( 0 ) ; -} - - -/* --------------------------------------------------------------------- */ -/* Function : XGINew_WantToChangeTimingRegister */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -int XGINew_WantToChangeTimingRegister(PHW_DEVICE_EXTENSION pHWDE) -{ - PUCHAR XGINew_P3c2 , XGINew_P3cc , XGINew_P3c4 , XGINew_P3d4 , XGINew_P3da , XGINew_P3c0 ; - UCHAR bCR56 ; - UCHAR temp , temp1 ; - UCHAR bCR0 , bCR1 , bCR2 , bCR3 , bCR4 , bCR5 , bCR6 , bCR7 ; - UCHAR bCR9 , bCR10 , bCR11 , bCR12 , bCR13 , bCR15 , bCR16 , bCR34 ; - UCHAR bSR0A , bSR0B , bSR0C ; - /* UCHAR bSR1 ; */ - UCHAR b3CC ; - /* UCHAR bAR13 ; */ - UCHAR Key ; - ULONG VGAHDE0 , VGAVDE0 , VGAHDE1 , VGAVDE1 ; - BOOL bWantToChange = 0 ; - - XGINew_P3c4 = pHWDE->pjIOAddress + SEQ_ADDRESS_PORT ; - XGINew_P3c2 = pHWDE->pjIOAddress + MISC_OUTPUT_REG_WRITE_PORT ; - XGINew_P3cc = pHWDE->pjIOAddress + MISC_OUTPUT_REG_READ_PORT ; - XGINew_P3d4 = pHWDE->pjIOAddress + CRTC_ADDRESS_PORT_COLOR ; - XGINew_P3da = pHWDE->pjIOAddress + 0x2A ; - XGINew_P3c0 = pHWDE->pjIOAddress + ATT_ADDRESS_PORT ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - bCR56 = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x08 ) ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x00 ) ; - bCR0 = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x00 ) ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x00 ) ; - temp = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - - if ( ( bCR0 != temp ) || ( pHWDE->bCR34 == 0xFF ) ) - { - bWantToChange = 1 ; - } - - pHWDE->bCR0 = bCR0 ; - - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x08 ) ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x01 ) ; - bCR1 = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x00 ) ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x01 ) ; - temp = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - - VGAHDE0 = temp ; - if ( ( bCR1 != temp ) || ( pHWDE->bCR34 == 0xFF ) ) - { - bWantToChange = 1 ; - } - - pHWDE->bCR1 = bCR1 ; - - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56&0xE7 ) | 0x08 ) ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x02 ) ; - bCR2 = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x00 ) ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x02 ) ; - temp = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - - if ( ( bCR2 != temp ) || ( pHWDE->bCR34 == 0xFF ) ) - { - bWantToChange = 1 ; - } - pHWDE->bCR2 = bCR2 ; - - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x08 ) ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x03 ) ; - bCR3 = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x00 ) ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x03 ) ; - temp = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - if ( ( ( bCR3 & 0x1F ) != ( temp & 0x1F ) ) || ( pHWDE->bCR34 == 0xFF ) ) - { - bWantToChange = 1 ; - } - pHWDE->bCR3 = bCR3 ; - - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x08 ) ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x04 ) ; - bCR4 = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x00 ) ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x04 ) ; - temp = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - if ( ( bCR4 != temp ) || ( pHWDE->bCR34 == 0xFF ) ) - { - bWantToChange = 1 ; - } - pHWDE->bCR4 = bCR4 ; - - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x08 ) ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x05 ) ; - bCR5 = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x00 ) ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x05 ) ; - temp = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - if ( ( bCR5 != temp ) || ( pHWDE->bCR34 == 0xFF ) ) - { - bWantToChange = 1 ; - } - pHWDE->bCR5 = bCR5 ; - - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4+1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x08 ) ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x06 ) ; - bCR6 = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x00 ) ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x06 ) ; - temp = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - if ( ( bCR6 != temp ) || ( pHWDE->bCR34 == 0xFF ) ) - { - bWantToChange = 1 ; - } - pHWDE->bCR6 = bCR6 ; - - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x08 ) ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x12 ) ; - bCR12 = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x00 ) ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x012 ) ; - temp = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - VGAVDE0 = temp ; - if ( ( bCR12 != temp ) || ( pHWDE->bCR34 == 0xFF ) ) - { - bWantToChange = 1 ; - } - pHWDE->bCR12 = bCR12 ; - - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; /* CR13 is not in INTA protect but the hardware do protect */ - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x08 ) ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x13 ) ; - bCR13 = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x00 ) ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x13 ) ; - temp = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - - if ( bCR13 != temp ) - { - VideoDebugPrint( ( 0 , "modify CR13\n" ) ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x51 ) ; - temp = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; /* save cr51 */ - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( 0x60 ) ) ; /* write permitted */ - VideoPortWritePortUchar( XGINew_P3d4 , 0x13 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , bCR13 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x51 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , temp ) ; /* restore cr51 */ - } - - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x08 ) ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x07 ) ; - bCR7 = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x00 ) ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x07 ) ; - temp = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - VGAVDE0 |= ( ( temp & 0x02 ) << 7 ) ; - VGAVDE0 |= ( ( temp & 0x40 ) << 3 ) ; - if ( ( ( bCR7 & 0xEF ) != ( temp & 0xEF ) ) || ( pHWDE->bCR34 == 0xFF ) ) - { - bWantToChange = 1 ; - } - pHWDE->bCR7 = bCR7 ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x08 ) ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x09 ) ; - bCR9 = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x00 ) ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x09 ) ; - temp = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - if ( ( ( bCR9 & 0x20 ) != ( temp & 0x20 ) ) || ( pHWDE->bCR34 == 0xFF ) ) - { - bWantToChange = 1 ; - } - pHWDE->bCR9 = bCR9 ; - - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x08 ) ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x10 ) ; - bCR10 = VideoPortReadPortUchar(XGINew_P3d4 + 1 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x00 ) ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x010 ) ; - temp = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - if ( ( bCR10 != temp ) || ( pHWDE->bCR34 == 0xFF ) ) - { - bWantToChange = 1 ; - } - pHWDE->bCR10 = bCR10 ; - - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x08 ) ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x11 ) ; - bCR11 = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x00 ) ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x011 ) ; - temp = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - if ( ( ( bCR11 & 0xF ) != ( temp & 0xF ) ) || ( pHWDE->bCR34 == 0xFF ) ) - { - bWantToChange = 1 ; - } - pHWDE->bCR11 = bCR11 ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x08 ) ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x15 ) ; - bCR15 = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x00 ) ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x015 ) ; - temp = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - if ( ( bCR15 != temp ) || ( pHWDE->bCR34 == 0xFF ) ) - { - bWantToChange = 1 ; - } - - pHWDE->bCR15 = bCR15 ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x08 ) ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x16 ) ; - bCR16 = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x00 ) ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x016 ) ; - temp = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - if ( ( bCR16!= temp ) || ( pHWDE->bCR34 == 0xFF ) ) - { - bWantToChange = 1 ; - } - pHWDE->bCR16 = bCR16 ; - - VideoPortWritePortUchar( XGINew_P3c4 , 0x5 ) ; - Key = VideoPortReadPortUchar( XGINew_P3c4 + 1 ) ; - VideoPortWritePortUshort( ( PUSHORT )XGINew_P3c4 , 0x8605 ) ; - - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x08 ) ) ; - VideoPortWritePortUchar( XGINew_P3c4 , 0x0A ) ; - bSR0A = VideoPortReadPortUchar( XGINew_P3c4 + 1 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x00 ) ) ; - VideoPortWritePortUchar( XGINew_P3c4 , 0x0A ) ; - temp = VideoPortReadPortUchar( XGINew_P3c4 + 1 ) ; - VGAVDE0 |= ( (temp & 0x02 ) << 9 ) ; - if ( ( bSR0A != temp ) || ( pHWDE->bCR34 == 0xFF ) ) - { - bWantToChange = 1 ; - } - pHWDE->bSR0A = bSR0A ; - - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x08 ) ) ; - VideoPortWritePortUchar( XGINew_P3c4,0x0B ) ; - bSR0B = VideoPortReadPortUchar( XGINew_P3c4 + 1 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 ,( UCHAR )( ( bCR56 & 0xE7 ) | 0x00 ) ) ; - VideoPortWritePortUchar( XGINew_P3c4 , 0x0B ) ; - temp = VideoPortReadPortUchar( XGINew_P3c4 + 1 ) ; - VGAHDE0 |= ( ( temp & 0x0C ) << 6 ) ; - if ( ( bSR0B!= temp ) || ( pHWDE->bCR34 == 0xFF ) ) - { - bWantToChange = 1 ; - } - pHWDE->bSR0B = bSR0B ; - - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x08 ) ) ; - VideoPortWritePortUchar( XGINew_P3c4 , 0x0C ) ; - bSR0C = VideoPortReadPortUchar( XGINew_P3c4 + 1 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x00 ) ) ; - VideoPortWritePortUchar( XGINew_P3c4,0x0C); - temp = VideoPortReadPortUchar( XGINew_P3c4 + 1 ) ; - if ( ( bSR0C != temp ) || ( pHWDE->bCR34 == 0xFF ) ) - { - bWantToChange = 1 ; - } - pHWDE->bSR0C = bSR0C ; - - if ( Key != 0xA1 ) - VideoPortWritePortUshort( ( PUSHORT )XGINew_P3c4 , 0x0005 ) ; - -/* - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x08 ) ) ; - VideoPortWritePortUchar( XGINew_P3c4 , 0x01 ) ; - bSR1 = VideoPortReadPortUchar( XGINew_P3c4 + 1 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x00 ) ) ; - VideoPortWritePortUchar( XGINew_P3c4 , 0x01 ) ; - temp = VideoPortReadPortUchar( XGINew_P3c4 + 1 ) ; - if( ( bSR1 & 0x01 ) != ( temp & 0x01 ) ) - { - VideoDebugPrint( ( 0 , "modify SR01 %x to %x \n" , temp , bSR1 ) ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x51 ) ; - temp = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; // save cr51 - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( 0x60 ) ) ; //write permitted - VideoPortWritePortUchar( XGINew_P3c4 , 0x01 ) ; - temp1 = VideoPortReadPortUchar( XGINew_P3c4 + 1 ) ; - temp1 = ( ( temp1 & 0xFE ) | ( bSR1 & 0x01) ) ; - VideoPortWritePortUchar( XGINew_P3c4 + 1 , temp1 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x51 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , temp ) ; //restore cr51 - } - - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x08 ) ) ; //E - bAR13 = VideoPortReadPortUchar( XGINew_P3da ) ; - VideoPortWritePortUchar( XGINew_P3c0 , 0x33 ) ; - bAR13 = VideoPortReadPortUchar( XGINew_P3c0 + 1 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x00 ) ) ; //I - temp = VideoPortReadPortUchar( XGINew_P3da ) ; - VideoPortWritePortUchar( XGINew_P3c0 , 0x33 ) ; - temp = VideoPortReadPortUchar( XGINew_P3c0 + 1 ) ; - if ( bAR13 != temp ) - { - VideoDebugPrint( ( 0 , "modify AR13 %x to %x\n" , temp , bAR13 ) ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x51 ) ; - temp1 = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; // save cr51 - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( 0x60 ) ) ; //write permitted - bAR13 = VideoPortReadPortUchar( XGINew_P3da ) ; - VideoPortWritePortUchar( XGINew_P3c0 , 0x33 ) ; - VideoPortWritePortUchar( XGINew_P3c0 + 1 , bAR13 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x51 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , temp ) ; //restore cr51 - } -*/ - - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x08 ) ) ; - b3CC = VideoPortReadPortUchar( XGINew_P3cc ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x00 ) ) ; - temp = VideoPortReadPortUchar( XGINew_P3cc ) ; - if ( ( ( b3CC & 0x0C ) != ( temp & 0x0C ) ) || ( pHWDE->bCR34 == 0xFF ) ) - { - bWantToChange = 1 ; - } - - pHWDE->b3CC = b3CC ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x34 ) ; - bCR34 = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - - bWantToChange = 0 ; /* we hope that change timing as little as possible */ - if ( bCR34!=pHWDE->bCR34 ) - { - bWantToChange = 1 ; - } - - pHWDE->bCR34 = bCR34 ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , bCR56 ) ; - - VGAHDE1 = ( pHWDE->bCR1 ) | ( ( pHWDE->bSR0B & 0x0C ) << 6 ) ; - VGAVDE1 = ( pHWDE->bCR12) | ( ( pHWDE->bCR7 & 0x02 ) << 7 ) | ( ( pHWDE->bCR7 & 0x40 ) << 3 ) | ( ( pHWDE->bSR0A & 0x02 ) << 9 ) ; - - if ( VGAHDE0 != VGAHDE1 ) - { - bWantToChange = 1 ; - } - if (VGAVDE0!=VGAVDE1) - { - bWantToChange = 1 ; - } - - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x08 ) ) ; - - return( bWantToChange ) ; -} - - -/* --------------------------------------------------------------------- */ -/* Function : XGINew_SetVBInfobyCR */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -BOOLEAN XGINew_SetVBInfobyCR( PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo ) -{ - - UCHAR temp ; - UCHAR bCR30 , bCR31 , ModeNo , bpart1_13 ; - USHORT ModeIdIndex , RefreshRateTableIndex ; - pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase ; - pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress ; - pVBInfo->BaseAddr = (USHORT)HwDeviceExtension->pjIOAddress ; - - if ( pVBInfo->FBAddr == 0 ) - return( FALSE ) ; - - if ( pVBInfo->BaseAddr == 0 ) - return( FALSE ) ; - - 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->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 ; - XGI_GetVBType(pVBInfo) ; - InitTo330Pointer( HwDeviceExtension->jChipType, pVBInfo ) ; - - bCR30 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x30 ) ; - bCR31 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x31 ) ; - - XGI_UnLockCRT2( HwDeviceExtension, pVBInfo) ; - pVBInfo->VBInfo = bCR30 + ( bCR31 << 8 ) ; - - pVBInfo->IF_DEF_LCDA = 1 ; /* alan 09/10/2003 */ - pVBInfo->IF_DEF_LVDS = 0 ; - pVBInfo->IF_DEF_CH7005 = 0 ; - pVBInfo->IF_DEF_HiVision = 0 ; -/* pVBInfo->IF_DEF_FSTN = 0 ; */ - pVBInfo->IF_DEF_YPbPr = 0 ; - - ModeNo = (UCHAR)XGINew_GetReg1( pVBInfo->P3d4 , 0x34 ) ; - temp = XGI_SearchModeID( ModeNo , &ModeIdIndex, pVBInfo ) ; /* 2.Get ModeID Table */ - if ( temp == 0 ) - return( 0 ) ; - XGI_GetVGAType( HwDeviceExtension, pVBInfo ) ; /* alan 09/12/2003 */ - XGI_GetVBType( pVBInfo ) ; /* alan 09/12/2003 */ - XGI_GetVBInfo( ModeNo , ModeIdIndex , HwDeviceExtension, pVBInfo ) ; - XGI_GetTVInfo( ModeNo , ModeIdIndex, pVBInfo ) ; - XGI_GetLCDInfo( ModeNo , ModeIdIndex, pVBInfo ) ; - - return( 1 ) ; -} - - -/* --------------------------------------------------------------------- */ -/* Function : XGINew_ModLCDALockMode */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -void XGINew_ModLCDALockMode( USHORT ModeNo , USHORT ModeIdIndex , USHORT RefreshRateTableIndex , - PXGI_HW_DEVICE_INFO HwDeviceExtension , USHORT HDE,USHORT VDE ) -{ - return ; -} - - -/* --------------------------------------------------------------------- */ -/* Function : XGINew_IsVAMode */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -BOOLEAN XGINew_IsVAMode( PVB_DEVICE_INFO pVBInfo ) -{ - USHORT flag ; - - flag = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ; - -#ifdef XGI315H - if ( ( flag & EnableDualEdge ) && ( flag & SetToLCDA ) ) - return( 0 ) ; - else - return( 1 ) ; -#endif - return( 1 ) ; -} - - -/* --------------------------------------------------------------------- */ -/* Function : XGINew_IsDualEdge */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -BOOLEAN XGINew_IsDualEdge( PVB_DEVICE_INFO pVBInfo ) -{ - USHORT flag ; - -#ifdef XGI315H - flag = XGINew_GetReg1( pVBInfo->P3d4 , 0x38 ) ; - if ( flag & EnableDualEdge ) - return( 0 ) ; - else - return( 1 ) ; -#endif - return( 1 ) ; -} - -/* --------------------------------------------------------------------- */ -/* Function : XGINew_ReSet301VBTiming */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -int XGINew_ReSet301VBTiming( PHW_DEVICE_EXTENSION pHWDE, PVB_DEVICE_INFO pVBInfo ) -{ - BOOLEAN bReturn , bCHA ; - UCHAR ModeNo , temp , bCR12 , bCR39 , Part1_13 ; - USHORT HDE , VDE ; - USHORT ModeIdIndex , RefreshRateTableIndex ; - - PXGI_HW_DEVICE_INFO HwDeviceExtension = pHWDE->pXGIHWDE ; - pVBInfo->ROMAddr = HwDeviceExtension->pjVirtualRomBase ; - pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress ; - pVBInfo->BaseAddr = ( USHORT )HwDeviceExtension->pjIOAddress ; - -#ifdef WIN2000 - pVBInfo->ISXPDOS = 1 ; -#endif - bReturn = XGINew_SetVBInfobyCR( HwDeviceExtension,pVBInfo ) ; - if ( bReturn == 0 ) - return( ERROR_INVALID_PARAMETER ) ; - - bCR39 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x39 ) ; - ModeNo = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x34 ) ; - bCR12 = ( UCHAR )XGINew_GetReg1( pVBInfo->P3d4 , 0x12 ) ; - Part1_13 = ( UCHAR )XGINew_GetReg1( pVBInfo->Part1Port , 0x13 ) ; - bCHA = Part1_13 & 0x04; - - XGINew_SetReg1( pVBInfo->P3c4 , 0x05 , 0x86 ) ; - - /* alan reset vb */ - if(pVBInfo->VBInfo & SetCRT2ToTV ) - { - temp = XGI_SearchModeID( ModeNo , &ModeIdIndex, pVBInfo ) ; - if ( temp != 0 ) - { - RefreshRateTableIndex = XGI_GetRatePtrCRT2( ModeNo , ModeIdIndex, pVBInfo ) ; - if ( RefreshRateTableIndex != 0xFFFF ) - { - XGINew_SetRegANDOR(pVBInfo->P3c4,0x06,~0x020,0x00); - XGI_SetCRT1Offset( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ; - } - bReturn = XGI_SetCRT2Group301( ModeNo , HwDeviceExtension, pVBInfo ) ; /* add for CRT2 */ - XGI_SetCRT2ModeRegs( ModeNo , HwDeviceExtension, pVBInfo ) ; - XGI_EnableBridge( HwDeviceExtension, pVBInfo ) ; - if ( bCR12 == 0xDA ) - { - XGINew_SetReg1( pVBInfo->Part1Port , 0x2F , 0x01 ) ; - XGINew_SetReg1( pVBInfo->Part1Port , 0x0E , bCR12 ) ; - } - } - } - else /* lcd */ - { - if ( !XGINew_IsDualEdge( pVBInfo ) ) - { - if ( !XGINew_IsVAMode(pVBInfo) ) - temp = 0x7F ; - else - temp = 0xBF ; - } - else - { - temp = 0x3F ; - } - XGINew_SetRegAND ( pVBInfo->Part4Port , 0x1F , temp ) ; - - HDE = 1024 ; - VDE = 768 ; - - switch( pVBInfo->LCDResInfo ) - { - case 0: - HDE = 1024 ; - VDE=768 ; - if( !bCHA ) - { - temp = XGI_SearchModeID( ModeNo , &ModeIdIndex , pVBInfo) ; - if ( temp != 0 ) - { - RefreshRateTableIndex = XGI_GetRatePtrCRT2( ModeNo , ModeIdIndex, pVBInfo ) ; - if ( RefreshRateTableIndex != 0xFFFF ) - { - XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x06 , ~0x020 , 0x00 ) ; - XGI_SetCRT1Offset( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ; - } - bReturn = XGI_SetCRT2Group301( ModeNo , HwDeviceExtension, pVBInfo ) ; /*add for CRT2 */ - XGI_SetCRT2ModeRegs( ModeNo , HwDeviceExtension, pVBInfo ) ; - XGI_EnableBridge( HwDeviceExtension, pVBInfo ) ; - if ( bCR12 == 0xDA ) - { - XGINew_SetReg1( pVBInfo->Part1Port , 0x2F , 0x01 ) ; - XGINew_SetReg1( pVBInfo->Part1Port , 0x0E , bCR12 ) ; - } - } - } - break ; - - case 1: - HDE = 800 ; - VDE = 600 ; - break ; - - case 2: - HDE = 1024 ; - VDE = 768 ; - if( !bCHA ) - { - temp = XGI_SearchModeID( ModeNo , &ModeIdIndex, pVBInfo ) ; /* 2.Get ModeID Table */ - if ( temp != 0 ) - { - RefreshRateTableIndex = XGI_GetRatePtrCRT2( ModeNo , ModeIdIndex, pVBInfo ) ; - if ( RefreshRateTableIndex != 0xFFFF ) - { - XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x06 , ~0x020 , 0x00 ) ; - XGI_SetCRT1Offset( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ; - } - bReturn = XGI_SetCRT2Group301( ModeNo , HwDeviceExtension, pVBInfo ) ; /* add for CRT2 */ - XGI_SetCRT2ModeRegs( ModeNo , HwDeviceExtension, pVBInfo ) ; - XGI_EnableBridge( HwDeviceExtension, pVBInfo ) ; - if ( bCR12 == 0xDA ) - { - XGINew_SetReg1( pVBInfo->Part1Port , 0x2F , 0x01 ) ; - XGINew_SetReg1( pVBInfo->Part1Port , 0x0E , bCR12 ) ; - } - } - } - break ; - - case 3: - HDE = 1280 ; - VDE = 1024 ; - XGINew_SetReg1(pVBInfo->P3d4 , 0x39 , ( UCHAR )( bCR39 | 0x04 ) ) ; - /* pVBInfo->VBInfo = XGINew_VBInfo | SetCRT2ToLCDA ; // alan 09/12/2003 */ - temp = XGI_SearchModeID( ModeNo , &ModeIdIndex, pVBInfo ) ; /* 2.Get ModeID Table */ - if ( temp != 0 ) - { - XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pHWDE->bSR2B ) ; - XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pHWDE->bSR2C ) ; - XGINew_SetReg1( pVBInfo->P3c4 , 0x2D , 0x01 ) ; - RefreshRateTableIndex = XGI_GetRatePtrCRT2( ModeNo , ModeIdIndex, pVBInfo ) ; - if ( RefreshRateTableIndex != 0xFFFF ) - { - XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x06 , ~0x020 , 0x00 ) ; - XGI_SetCRT1Offset( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ; - } - if (pVBInfo->VBInfo & SetCRT2ToLCDA) /* alan 09/12/2003 */ - { - XGI_SetLCDAGroup( ModeNo , ModeIdIndex , HwDeviceExtension, pVBInfo ) ; - if ( bCR12 == 0xDA ) - XGINew_SetReg1( pVBInfo->P3d4 , 0x12 , bCR12 ) ; - } - else - { - bReturn = XGI_SetCRT2Group301( ModeNo , HwDeviceExtension, pVBInfo ) ; /* add for CRT2 */ - XGI_SetCRT2ModeRegs( ModeNo , HwDeviceExtension, pVBInfo ) ; - XGI_EnableBridge( HwDeviceExtension, pVBInfo ) ; - if ( bCR12 == 0xDA ) - { - XGINew_SetReg1( pVBInfo->Part1Port , 0x2F , 0x01 ) ; - XGINew_SetReg1( pVBInfo->Part1Port , 0x0E , bCR12 ) ; - } - } - - bReturn = 1 ; - } - else - bReturn = 0 ; - break ; - - case 4: - break ; - case 5: - break ; - case 6: - break ; - case 7: - break ; - case 8: - break ; - - case 9: - HDE = 1400 ; - VDE = 1050 ; - XGINew_SetReg1( pVBInfo->P3d4 , 0x39 , ( UCHAR )( bCR39 | 0x04 ) ) ; - /* if ( HwDeviceExtension->jChipType == SIS_650M ) */ - /* XGINew_1400x1050Des_2 = ( XGI_LVDSDesStruct * )XGI651_1400x1050Des_2 ; */ - pVBInfo->VBInfo |= SetCRT2ToLCDA ; - temp = XGI_SearchModeID( ModeNo , &ModeIdIndex, pVBInfo ) ; /* 2.Get ModeID Table */ - if ( temp != 0 ) - { - XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pHWDE->bSR2B ) ; - XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pHWDE->bSR2C ) ; - XGINew_SetReg1( pVBInfo->P3c4 , 0x2D , 0x01 ) ; - RefreshRateTableIndex = XGI_GetRatePtrCRT2( ModeNo , ModeIdIndex, pVBInfo ) ; - if ( RefreshRateTableIndex != 0xFFFF ) - { - XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x06 , ~0x020 , 0x00 ) ; - XGI_SetCRT1Offset( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ; - } - XGI_SetLCDAGroup( ModeNo , ModeIdIndex , HwDeviceExtension, pVBInfo ) ; - if ( bCR12 == 0xDA ) - XGINew_SetReg1( pVBInfo->P3d4 , 0x12 , bCR12 ) ; - bReturn = 1 ; - } - else - bReturn = 0; - /* XGINew_SetReg1( pVBInfo->P3d4 , 0x39 , ( UCHAR )( bCR39 | 0x04 ) ) ; */ - break ; - - case 10: - HDE = 1280 ; - VDE = 768 ; - pVBInfo->VBInfo |= SetCRT2ToLCDA ; - temp = XGI_SearchModeID( ModeNo , &ModeIdIndex, pVBInfo ) ; /* 2.Get ModeID Table */ - if ( temp != 0 ) - { - XGINew_SetReg1( pVBInfo->P3c4 , 0x2B , pHWDE->bSR2B ) ; - XGINew_SetReg1( pVBInfo->P3c4 , 0x2C , pHWDE->bSR2C ) ; - XGINew_SetReg1( pVBInfo->P3c4 , 0x2D , 0x01 ) ; - RefreshRateTableIndex = XGI_GetRatePtrCRT2( ModeNo , ModeIdIndex, pVBInfo ) ; - if ( RefreshRateTableIndex != 0xFFFF ) - { - XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x06 , ~0x020 , 0x00 ) ; - XGI_SetCRT1Offset( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ; - } - XGI_SetLCDAGroup( ModeNo , ModeIdIndex , HwDeviceExtension, pVBInfo ) ; - if ( bCR12 == 0xDA ) - XGINew_SetReg1( pVBInfo->P3d4 , 0x12 , bCR12 ) ; - - bReturn = 1 ; - } - else - bReturn = 0 ; - - break ; - - case 11: - HDE = 1600 ; - VDE = 1200 ; - XGINew_SetReg1( pVBInfo->P3d4 , 0x39 , ( UCHAR )( bCR39 | 0x04 ) ) ; - temp = XGI_SearchModeID( ModeNo , &ModeIdIndex, pVBInfo ) ; /* 2.Get ModeID Table */ - if ( temp != 0 ) - { - RefreshRateTableIndex = XGI_GetRatePtrCRT2( ModeNo , ModeIdIndex, pVBInfo ) ; - if ( RefreshRateTableIndex != 0xFFFF ) - { - XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x06 , ~0x020 , 0x00 ) ; - XGI_SetCRT1Offset( ModeNo , ModeIdIndex , RefreshRateTableIndex , HwDeviceExtension, pVBInfo ) ; - } - bReturn = XGI_SetCRT2Group301(ModeNo , HwDeviceExtension, pVBInfo ) ; /* add for CRT2 */ - XGI_SetCRT2ModeRegs( ModeNo , HwDeviceExtension, pVBInfo ) ; - XGI_EnableBridge( HwDeviceExtension, pVBInfo ) ; - if ( bCR12 == 0xDA ) - { - XGINew_SetReg1( pVBInfo->Part1Port , 0x2F , 0x01 ) ; - XGINew_SetReg1( pVBInfo->Part1Port , 0x0E , bCR12 ) ; - } - } - break ; - - default: - break ; - } - - /* alan reset vb */ - - if ( !XGINew_IsDualEdge( pVBInfo ) ) - { - if ( !XGINew_IsVAMode( pVBInfo) ) - temp = 0x80 ; - else - temp = 0x40 ; - } - else - { - temp = 0xC0 ; - } - } - - XGINew_SetRegOR( pVBInfo->Part4Port , 0x1F , temp ) ; - - if ( bReturn == 0 ) - return( ERROR_INVALID_PARAMETER ) ; - else - return( 1 ) ; -} - - -/* --------------------------------------------------------------------- */ -/* Function : XGINew_TurnOffBacklight */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -void XGINew_TurnOffBacklight( PHW_DEVICE_EXTENSION pHWDE ) -{ - VIDEO_X86_BIOS_ARGUMENTS BIOSArguments ; - ULONG ultemp ; - PUCHAR pjCRTAddrPort , pjSeqAddrPort , pjCRT2Part1Port , pjCRT2Part4Port ; - VP_STATUS VPStatus ; - - pjCRTAddrPort = pHWDE->pjIOAddress + CRTC_ADDRESS_PORT_COLOR ; - pjSeqAddrPort = pHWDE->pjIOAddress + SEQ_ADDRESS_PORT ; - pjCRT2Part1Port = pHWDE->pjIOAddress + VB_PART1_OFFSET_04 ; - pjCRT2Part4Port = pHWDE->pjIOAddress + VB_PART4_OFFSET_14 ; - - /* Turn-off LVDS panel backlight */ - if ( pHWDE->ulDispActualState & MASK_OUTPUTSTATE_LCD ) - { - switch( pHWDE->bHasVB ) - { - case VB2_301: - switch( pHWDE->ujVBRevID ) - { - case 0xd0: /* 301LV */ - case 0xd1: - case 0xe0: /* 302LV */ - case 0xe1: - ExtPortSet( pjCRT2Part4Port , 0x26 , 0xFE , 0 ) ; - break ; - - default: - break ; - } - break ; - - case VB_LVDS: /* External LVDS chip */ - ExtPortSet( pjSeqAddrPort , IND_SR11_DDC_REG , 0xF7 , 0x08 ) ; - break ; - - case VB2_Chrontel: /* Chrontel LVDS */ - VideoPortZeroMemory( &BIOSArguments , sizeof( VIDEO_X86_BIOS_ARGUMENTS ) ) ; - BIOSArguments.Eax = 0x140B; - BIOSArguments.Ebx = 0x01; - /* VPStatus = VideoPortInt10( pHWDE , &BIOSArguments ) ; */ - break ; - - default: - break ; - } - } -} - - -/* --------------------------------------------------------------------- */ -/* Function : XGINew_TurnOnBacklight */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -void XGINew_TurnOnBacklight( PHW_DEVICE_EXTENSION pHWDE ) -{ - VIDEO_X86_BIOS_ARGUMENTS BIOSArguments ; - ULONG ultemp ; - PUCHAR pjCRTAddrPort , pjSeqAddrPort , pjCRT2Part1Port , pjCRT2Part4Port ; - VP_STATUS VPStatus ; - - pjCRTAddrPort = pHWDE->pjIOAddress + CRTC_ADDRESS_PORT_COLOR ; - pjSeqAddrPort = pHWDE->pjIOAddress + SEQ_ADDRESS_PORT ; - pjCRT2Part1Port = pHWDE->pjIOAddress + VB_PART1_OFFSET_04 ; - pjCRT2Part4Port = pHWDE->pjIOAddress + VB_PART4_OFFSET_14 ; - - if ( pHWDE->bMonitorPoweredOn ) - { - /* Turn-on LVDS panel backlight */ - if ( pHWDE->ulDispActualState & MASK_OUTPUTSTATE_LCD ) - { - switch (pHWDE->bHasVB) - { - case VB2_301: - switch( pHWDE->ujVBRevID ) - { - case 0xd0: /* 301LV */ - case 0xd1: - case 0xe0: /* 302LV */ - case 0xe1: - for( ultemp = 0 ; ultemp < 0x10000 ; ultemp++ ) - { - ExtPortIn( pjSeqAddrPort , 0x05 ) ; - } - ExtPortSet( pjCRT2Part4Port , 0x26 , 0xFF , 0x01 ) ; - break ; - - default: - break ; - } - break; - - case VB_LVDS: /* External LVDS chip */ - ExtPortSet( pjSeqAddrPort , IND_SR11_DDC_REG , 0xF7 , 0x00 ) ; - break ; - - case VB2_Chrontel: /* Chrontel LVDS */ - VideoPortZeroMemory(&BIOSArguments, sizeof( VIDEO_X86_BIOS_ARGUMENTS ) ) ; - BIOSArguments.Eax = 0x140B ; - BIOSArguments.Ebx = 0x0 ; - /* VPStatus = VideoPortInt10( pHWDE , &BIOSArguments ) ; */ - break ; - - default: - break ; - } - } - } -} - - -/* --------------------------------------------------------------------- */ -/* Function : XGINew_EnableWriteInternal */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -void XGINew_EnableWriteInternal( PHW_DEVICE_EXTENSION pHWDE ) -{ - PUCHAR XGINew_P3d4 ; - UCHAR bCR51 , bCR56 ; - - XGINew_P3d4 = pHWDE->pjIOAddress + CRTC_ADDRESS_PORT_COLOR ; - - VideoPortWritePortUchar( XGINew_P3d4 , 0x51 ) ; - bCR51 = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( bCR51 & 0x7F ) ) ; -} - - -/* --------------------------------------------------------------------- */ -/* Function : XGINew_DisableWriteInternal */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -void XGINew_DisableWriteInternal( PHW_DEVICE_EXTENSION pHWDE ) -{ - PUCHAR XGINew_P3d4 ; - UCHAR bCR51 , bCR56 ; - - - XGINew_P3d4 = pHWDE->pjIOAddress + CRTC_ADDRESS_PORT_COLOR ; - - VideoPortWritePortUchar( XGINew_P3d4 , 0x51 ) ; - bCR51 = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( bCR51 | 0x80 ) ) ; -} - - -/* --------------------------------------------------------------------- */ -/* Function : XGINew_EnableWriteExternal */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -void XGINew_EnableWriteExternal( PHW_DEVICE_EXTENSION pHWDE ) -{ - PUCHAR XGINew_P3c2 , XGINew_P3cc , XGINew_P3c4 , XGINew_P3d4 ; - UCHAR bCR51 , bCR56 ; - - XGINew_P3d4 = pHWDE->pjIOAddress + CRTC_ADDRESS_PORT_COLOR ; - - VideoPortWritePortUchar( XGINew_P3d4 , 0x51 ) ; - bCR51 = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( bCR51 & 0xBF ) ) ; -} - - -/* --------------------------------------------------------------------- */ -/* Function : XGINew_DisableWriteExternal */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -void XGINew_DisableWriteExternal( PHW_DEVICE_EXTENSION pHWDE ) -{ - PUCHAR XGINew_P3c2 , XGINew_P3cc , XGINew_P3c4 , XGINew_P3d4 ; - UCHAR bCR51 , bCR56 ; - - XGINew_P3d4 = pHWDE->pjIOAddress + CRTC_ADDRESS_PORT_COLOR ; - - VideoPortWritePortUchar( XGINew_P3d4 , 0x51 ) ; - bCR51 = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( bCR51 | 0x40 ) ) ; -} - - -/* --------------------------------------------------------------------- */ -/* Function : XGINew_EnableWriteBackup */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -void XGINew_EnableWriteBackup( PHW_DEVICE_EXTENSION pHWDE ) -{ - PUCHAR XGINew_P3d4 ; - UCHAR bCR51 , bCR56 ; - - XGINew_P3d4 = pHWDE->pjIOAddress + CRTC_ADDRESS_PORT_COLOR ; - - VideoPortWritePortUchar( XGINew_P3d4 , 0x51 ) ; - bCR51 = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( bCR51 & 0xDF ) ) ; -} - - -/* --------------------------------------------------------------------- */ -/* Function : XGINew_DisableWriteBackup */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -void XGINew_DisableWriteBackup( PHW_DEVICE_EXTENSION pHWDE ) -{ - PUCHAR XGINew_P3d4 ; - UCHAR bCR51 , bCR56 ; - - XGINew_P3d4 = pHWDE->pjIOAddress + CRTC_ADDRESS_PORT_COLOR ; - - VideoPortWritePortUchar( XGINew_P3d4 , 0x51 ) ; - bCR51 = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( bCR51 | 0x20 ) ) ; -} - - -/* --------------------------------------------------------------------- */ -/* Function : XGINew_SetReadInternal */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -void XGINew_SetReadInternal( PHW_DEVICE_EXTENSION pHWDE ) -{ - PUCHAR XGINew_P3d4 ; - UCHAR bCR51 , bCR56 ; - - XGINew_P3d4 = pHWDE->pjIOAddress + CRTC_ADDRESS_PORT_COLOR ; - - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - bCR56 = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( bCR56 & 0xE7 ) ) ; -} - - -/* --------------------------------------------------------------------- */ -/* Function : */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -void XGINew_SetReadExternal( PHW_DEVICE_EXTENSION pHWDE ) -{ - PUCHAR XGINew_P3d4 ; - UCHAR bCR51 , bCR56 ; - - XGINew_P3d4 = pHWDE->pjIOAddress + CRTC_ADDRESS_PORT_COLOR ; - - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - bCR56 = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x08 ) ) ; -} - - -/* --------------------------------------------------------------------- */ -/* Function : XGINew_ExternalToBackup */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -void XGINew_ExternalToBackup( PHW_DEVICE_EXTENSION pHWDE ) -{ - PUCHAR XGINew_P3c2 , XGINew_P3cc , XGINew_P3c4 , XGINew_P3d4 ; - UCHAR bCR56 , bCR51 ; - UCHAR temp ; - UCHAR bCR0 , bCR1 , bCR2 , bCR3 , bCR4 , bCR5 , bCR6 , bCR7 ; - UCHAR bCR9 , bCR10 , bCR11 , bCR12 , bCR15 , bCR16 , bCR34 ; - UCHAR bSR0A , bSR0B , bSR0C ; - UCHAR bSR1 ; - UCHAR b3CC ; - UCHAR Key ; - - XGINew_P3c4 = pHWDE->pjIOAddress + SEQ_ADDRESS_PORT ; - XGINew_P3c2 = pHWDE->pjIOAddress + MISC_OUTPUT_REG_WRITE_PORT ; - XGINew_P3cc = pHWDE->pjIOAddress + MISC_OUTPUT_REG_READ_PORT ; - XGINew_P3d4 = pHWDE->pjIOAddress + CRTC_ADDRESS_PORT_COLOR ; - - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - bCR56 = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR56 & 0xE7 ) | 0x10 ) ) ; - - VideoPortWritePortUchar( XGINew_P3d4 , 0x51 ) ; - bCR51 = VideoPortReadPortUchar( XGINew_P3d4 + 1 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( bCR51 & 0xDF ) | 0xC0 ) ) ; - - VideoPortWritePortUchar( XGINew_P3d4 , 0x34 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , pHWDE->bCR34 ) ; - - VideoPortWritePortUchar( XGINew_P3d4 ,0x11); - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( VideoPortReadPortUchar( XGINew_P3d4 + 1 ) & 0x7F ) ) ) ; - - VideoPortWritePortUchar( XGINew_P3d4 , 0x0 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , pHWDE->bCR0 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x1 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , pHWDE->bCR1 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x2 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , pHWDE->bCR2 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x3 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , pHWDE->bCR3 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x4 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , pHWDE->bCR4 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x5 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , pHWDE->bCR5 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x6 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , pHWDE->bCR6 ) ; - - VideoPortWritePortUchar( XGINew_P3d4 , 0x7 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( VideoPortReadPortUchar( XGINew_P3d4 + 1 ) & 0x10 ) | ( ( pHWDE->bCR7 ) & 0xEF ) ) ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x9 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( VideoPortReadPortUchar( XGINew_P3d4 + 1 ) & 0x5F ) | ( ( pHWDE->bCR9 ) & 0xA0 ) ) ) ; - - VideoPortWritePortUchar( XGINew_P3d4 , 0x10 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , pHWDE->bCR10 ) ; - - VideoPortWritePortUchar( XGINew_P3d4 , 0x11 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , ( UCHAR )( ( VideoPortReadPortUchar( XGINew_P3d4 + 1 ) & 0xF0 ) | ( ( pHWDE->bCR11 ) & 0x0F ) ) ) ; - - VideoPortWritePortUchar( XGINew_P3d4 , 0x12 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , pHWDE->bCR12 ) ; - - VideoPortWritePortUchar( XGINew_P3d4 , 0x15 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , pHWDE->bCR15 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x16 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , pHWDE->bCR16 ) ; - - - VideoPortWritePortUchar( XGINew_P3c2 , ( UCHAR )( ( VideoPortReadPortUchar( XGINew_P3cc ) & 0x33 ) | ( ( pHWDE->b3CC ) & 0xCC ) ) ) ; - - VideoPortWritePortUchar( XGINew_P3c4 , 0x5 ) ; - Key = VideoPortReadPortUchar( XGINew_P3c4 + 1 ) ; - VideoPortWritePortUshort( ( PUSHORT )XGINew_P3c4 , 0x8605 ) ; - - VideoPortWritePortUchar( XGINew_P3c4 , 0x0A ) ; - VideoPortWritePortUchar( XGINew_P3c4 + 1 , pHWDE->bSR0A ) ; - VideoPortWritePortUchar( XGINew_P3c4 , 0x0B ) ; - VideoPortWritePortUchar( XGINew_P3c4 + 1 , pHWDE->bSR0B ) ; - VideoPortWritePortUchar( XGINew_P3c4 , 0x0C ) ; - VideoPortWritePortUchar( XGINew_P3c4 + 1 , ( UCHAR )( ( VideoPortReadPortUchar( XGINew_P3c4 + 1 ) & 0xF8 ) | ( ( pHWDE->bSR0C ) & 0x07 ) ) ) ; - - if ( Key != 0xA1 ) - VideoPortWritePortUshort( ( PUSHORT )XGINew_P3c4 , 0x0005 ) ; - - VideoPortWritePortUchar( XGINew_P3d4 , 0x51 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , bCR51 ) ; - VideoPortWritePortUchar( XGINew_P3d4 , 0x56 ) ; - VideoPortWritePortUchar( XGINew_P3d4 + 1 , bCR56 ) ; -} - - -/* --------------------------------------------------------------------- */ -/* Function : XGINew_GRandAR13Changed */ -/* Input : */ -/* Output : */ -/* Description : */ -/* --------------------------------------------------------------------- */ -void XGINew_GRandAR13Changed(PHW_DEVICE_EXTENSION pHWDE ) -{ - PUCHAR XGINew_P3ce , XGINew_P3da , XGINew_P3c0 , XGINew_P3d4 , XGINew_P3c4 ; - UCHAR AR13 , GR6 , ModeNo , GRdata , temp , SRdata ; - USHORT ModeIdIndex , i , modeflag , index ; - BOOL bTimingChanged = 0 ; - -/* - PXGI_HW_DEVICE_INFO HwDeviceExtension = pHWDE->pXGIHWDE; - PUCHAR pVBInfo->ROMAddr = (ULONG)HwDeviceExtension->pjVirtualRomBase; - - XGINew_SModeIDTable = (XGI_StStruct *) XGI310_SModeIDTable; - XGINew_StandTable = (XGI_StandTableStruct *) XGI310_StandTable; - XGINew_EModeIDTable = (XGI_ExtStruct *) XGI310_EModeIDTable; - - XGINew_P3ce = pHWDE->pjIOAddress + GRAPH_ADDRESS_PORT; - XGINew_P3da = pHWDE->pjIOAddress + 0x2A; - XGINew_P3c0 = pHWDE->pjIOAddress + ATT_ADDRESS_PORT; - XGINew_P3c4 = pHWDE->pjIOAddress + SEQ_ADDRESS_PORT; - XGINew_P3d4 = pHWDE->pjIOAddress + CRTC_ADDRESS_PORT_COLOR; - - VideoPortWritePortUchar(XGINew_P3d4,0x34); - ModeNo = VideoPortReadPortUchar(XGINew_P3d4+1); - temp = XGI_SearchModeID(pVBInfo->ROMAddr,ModeNo,&ModeIdIndex, pVBInfo); - if(temp!=0) - { - if (ModeNo<=0x13) - { - index = XGINew_SModeIDTable[ModeIdIndex].St_StTableIndex; - modeflag = XGINew_SModeIDTable[ModeIdIndex].St_ModeFlag; - modeflag = modeflag&ModeInfoFlag; - } - else - { - modeflag = XGINew_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - modeflag = modeflag&ModeInfoFlag; - if ( modeflag <= 0x02 ) - index=0x1B; - else - index=0x0F; - } - VideoPortWritePortUchar(XGINew_P3ce,0x06); - GR6 = VideoPortReadPortUchar(XGINew_P3ce+1); - GRdata = XGINew_StandTable[index].GRC[6]; - - if ( GR6 != GRdata ) - { - for(i=0;i<=0x08;i++) - { - GRdata = XGINew_StandTable[index].GRC[i]; - VideoPortWritePortUchar(XGINew_P3ce,(UCHAR)i); - VideoPortWritePortUchar(XGINew_P3ce+1,GRdata); - } - if(modeflag>ModeVGA) - { - VideoPortWritePortUchar(XGINew_P3ce,0x05); - GRdata = VideoPortReadPortUchar(XGINew_P3ce+1); - GRdata = GRdata&0xBF; - VideoPortWritePortUchar(XGINew_P3ce+1,GRdata); - } - - for(i=02;i<=04;i++) - { - SRdata=XGINew_StandTable[index].SR[i-1]; - VideoPortWritePortUchar(XGINew_P3c4,(UCHAR)i); - VideoPortWritePortUchar(XGINew_P3c4+1,SRdata); - } - } - } - - if(pHWDE->bAR13==0) - { - AR13 = VideoPortReadPortUchar(XGINew_P3da); - VideoPortWritePortUchar(XGINew_P3c0,0x33); - AR13 = VideoPortReadPortUchar(XGINew_P3c0+1); - if (AR13!=0) - { - AR13 = VideoPortReadPortUchar(XGINew_P3da); - VideoPortWritePortUchar(XGINew_P3c0,0x33); - VideoPortWritePortUchar(XGINew_P3c0,0x00); - } - } -*/ -} - -/* #endif WIN2000 INTA solution for WIN2000 */ diff --git a/src/vb_inta.h b/src/vb_inta.h deleted file mode 100644 index 7e22ce1..0000000 --- a/src/vb_inta.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef _VBINTA_ -#define _VBINTA_ - -extern void SiSLVDSCH7019ControlCallback(PHW_DEVICE_EXTENSION pHWDE,PVOID Context); -extern void SiSTVCH7019ControlCallback(PHW_DEVICE_EXTENSION pHWDE, PVOID Context); -extern void XGINew_ExternalToBackup(PHW_DEVICE_EXTENSION pHWDE); -extern void XGINew_SetReadExternal(PHW_DEVICE_EXTENSION pHWDE); -extern void XGINew_SetReadInternal(PHW_DEVICE_EXTENSION pHWDE); -extern void XGINew_DisableWriteBackup(PHW_DEVICE_EXTENSION pHWDE); -extern void XGINew_EnableWriteBackup(PHW_DEVICE_EXTENSION pHWDE); -extern void XGINew_TurnOnBacklight(PHW_DEVICE_EXTENSION pHWDE); -extern int XGINew_WantToSetMode(PHW_DEVICE_EXTENSION pHWDE); -extern int XGINew_WantToChangeTimingRegister(PHW_DEVICE_EXTENSION pHWDE); -extern int XGINew_ReSet301VBTiming(PHW_DEVICE_EXTENSION pHWDE); -extern void XGINew_TurnOffBacklight(PHW_DEVICE_EXTENSION pHWDE); -extern void XGINew_EnableWriteInternal(PHW_DEVICE_EXTENSION pHWDE); -extern void XGINew_DisableWriteInternal(PHW_DEVICE_EXTENSION pHWDE); -extern void XGINew_EnableWriteExternal(PHW_DEVICE_EXTENSION pHWDE); -extern void XGINew_DisableWriteExternal(PHW_DEVICE_EXTENSION pHWDE); -extern void XGINew_GRandAR13Changed(PHW_DEVICE_EXTENSION pHWDE); -extern BOOLEAN XGINew_IsVAMode(PVB_DEVICE_INFO pVBInfo); - -#endif diff --git a/src/xgi_vdeo_old.c b/src/xgi_vdeo_old.c deleted file mode 100644 index 7218484..0000000 --- a/src/xgi_vdeo_old.c +++ /dev/null @@ -1,1503 +0,0 @@ -/*************************************************************************** - -Copyright 2004 eXtreme Graphics Innovation Corp, Inc., HsinChu, Taiwan. -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 INTEL, AND/OR ITS SUPPLIERS 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. - -**************************************************************************/ - -/* - * Formerly based on Xv driver for SiS 300, 315 and 330 series by - * Thomas Winischhofer - * - * Basic structure based on the mga Xv driver by Mark Vojkovich - * and i810 Xv driver by Jonathan Bian . - * - * Authors: - * Nan-Hsing Chang - * - * This supports the following chipsets: - * XGI340, XGI342: Full register range, one overlay (used for both CRT1 and CRT2 alt.) - * - */ - -#include "xf86.h" -#include "xf86_OSproc.h" -#include "xf86Resources.h" -#include "compiler.h" -#include "xf86PciInfo.h" -#include "xf86Pci.h" -#include "xf86fbman.h" -#include "regionstr.h" - -#include "xgi.h" -#include "xf86xv.h" -#include -#include "xaa.h" -#include "xaalocal.h" -#include "dixstruct.h" -#include "fourcc.h" - -/* TODO: move to xgi_regs.h */ -#include "xgi_videohw.h" -#include "xgi_video.h" - -static XF86VideoAdaptorPtr XGISetupImageVideo(ScreenPtr); -static int XGISetPortAttribute(ScrnInfoPtr, Atom, INT32, pointer); -static int XGIGetPortAttribute(ScrnInfoPtr, Atom ,INT32 *, pointer); -static void XGIQueryBestSize(ScrnInfoPtr, Bool, - short, short, short, short, unsigned int *, unsigned int *, pointer); -static int XGIPutImage( ScrnInfoPtr, - short, short, short, short, short, short, short, short, - int, unsigned char*, short, short, Bool, RegionPtr, pointer); -static int XGIQueryImageAttributes(ScrnInfoPtr, - int, unsigned short *, unsigned short *, int *, int *); -static void XGIStopVideo(ScrnInfoPtr, pointer, Bool); -/* static void XGIFreeOverlayMemory(ScrnInfoPtr pScrn); */ - -extern void SetSRRegMask(XGIPtr, CARD8, CARD8, CARD8); -extern void XGIUpdateXvGamma(XGIPtr, XGIPortPrivPtr); -#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE) - -void XGIInitVideo(ScreenPtr pScreen) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - XF86VideoAdaptorPtr *adaptors, *newAdaptors = NULL; - XF86VideoAdaptorPtr newAdaptor = NULL; - int num_adaptors; - - newAdaptor = XGISetupImageVideo(pScreen); - - num_adaptors = xf86XVListGenericAdaptors(pScrn, &adaptors); - - if(newAdaptor) { - if(!num_adaptors) { - num_adaptors = 1; - adaptors = &newAdaptor; - } else { - newAdaptors = /* need to free this someplace */ - xalloc((num_adaptors + 1) * sizeof(XF86VideoAdaptorPtr*)); - if(newAdaptors) { - memcpy(newAdaptors, adaptors, num_adaptors * - sizeof(XF86VideoAdaptorPtr)); - newAdaptors[num_adaptors] = newAdaptor; - adaptors = newAdaptors; - num_adaptors++; - } - } - } - - if(num_adaptors) - xf86XVScreenInit(pScreen, adaptors, num_adaptors); - - if(newAdaptors) - xfree(newAdaptors); - -} - - -/* client libraries expect an encoding */ -static XF86VideoEncodingRec DummyEncoding = -{ - 0, - "XV_IMAGE", - 0, 0, /* Will be filled in */ - {1, 1} -}; - -#define NUM_FORMATS 3 - -static XF86VideoFormatRec XGIFormats[NUM_FORMATS] = -{ - { 8, PseudoColor}, - {16, TrueColor}, - {24, TrueColor} -}; - -static char xgixvcolorkey[] = "XV_COLORKEY"; -static char xgixvbrightness[] = "XV_BRIGHTNESS"; -static char xgixvcontrast[] = "XV_CONTRAST"; -static char xgixvsaturation[] = "XV_SATURATION"; -static char xgixvhue[] = "XV_HUE"; -static char xgixvgammared[] = "XV_GAMMA_RED"; -static char xgixvgammagreen[] = "XV_GAMMA_GREEN"; -static char xgixvgammablue[] = "XV_GAMMA_BLUE"; - -#define NUM_ATTRIBUTES 8 - -static XF86AttributeRec XGIAttributes[NUM_ATTRIBUTES] = -{ - {XvSettable | XvGettable, 0, (1 << 24) - 1, xgixvcolorkey}, - {XvSettable | XvGettable, -128, 127, xgixvbrightness}, - {XvSettable | XvGettable, 0, 255, xgixvcontrast}, - {XvSettable | XvGettable, -180, 180, xgixvsaturation}, - {XvSettable | XvGettable, -180, 180, xgixvhue}, - {XvSettable | XvGettable, 100, 10000, xgixvgammared}, - {XvSettable | XvGettable, 100, 10000, xgixvgammagreen}, - {XvSettable | XvGettable, 100, 10000, xgixvgammablue}, -}; - -#define NUM_IMAGES 8 - -static XF86ImageRec XGIImages[NUM_IMAGES] = - { - XVIMAGE_YUY2, /* If order is changed, XGIOffscreenImages must be adapted */ - XVIMAGE_YV12, - XVIMAGE_UYVY, - { /* RGB 555 */ - PIXEL_FMT_RGB5, - XvRGB, - LSBFirst, - {'R','V','1','5', - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - 16, - XvPacked, - 1, - 15, 0x7C00, 0x03E0, 0x001F, - 0, 0, 0, - 0, 0, 0, - 0, 0, 0, - {'R', 'V', 'B',0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - XvTopToBottom - }, - { /* RGB 565 */ - PIXEL_FMT_RGB6, - XvRGB, - LSBFirst, - {'R','V','1','6', - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - 16, - XvPacked, - 1, - 16, 0xF800, 0x07E0, 0x001F, - 0, 0, 0, - 0, 0, 0, - 0, 0, 0, - {'R', 'V', 'B',0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - XvTopToBottom - }, - { /* YVYU */ - PIXEL_FMT_YVYU, \ - XvYUV, \ - LSBFirst, \ - {'Y','V','Y','U', - 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, - 16, - XvPacked, - 1, - 0, 0, 0, 0 , - 8, 8, 8, - 1, 2, 2, - 1, 1, 1, - {'Y','V','Y','U', - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - XvTopToBottom - }, - { /* NV12 */ - PIXEL_FMT_NV12, - XvYUV, - LSBFirst, - {'N','V','1','2', - 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, - 12, - XvPlanar, - 2, - 0, 0, 0, 0 , - 8, 8, 8, - 1, 2, 2, - 1, 2, 2, - {'Y','U','V',0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - XvTopToBottom - }, - { /* NV21 */ - PIXEL_FMT_NV21, - XvYUV, - LSBFirst, - {'N','V','2','1', - 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, - 12, - XvPlanar, - 2, - 0, 0, 0, 0, - 8, 8, 8, - 1, 2, 2, - 1, 2, 2, - {'Y','V','U',0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - XvTopToBottom - }, -}; - -static void -set_maxencoding(XGIPtr pXGI, XGIPortPrivPtr pPriv) -{ - DummyEncoding.width = IMAGE_MAX_WIDTH; - DummyEncoding.height = IMAGE_MAX_HEIGHT; -} - -static void -XGIResetXvGamma(ScrnInfoPtr pScrn) -{ - XGIPtr pXGI = XGIPTR(pScrn); - XGIPortPrivPtr pPriv = GET_PORT_PRIVATE(pScrn); - - XGIUpdateXvGamma(pXGI, pPriv); -} - -static void -XGISetPortDefaults(ScrnInfoPtr pScrn, XGIPortPrivPtr pPriv) -{ - pPriv->colorKey = 0x000101fe; - pPriv->brightness = 0; - pPriv->contrast = 128; - pPriv->saturation = 0; - pPriv->hue = 0; -} - -static XF86VideoAdaptorPtr -XGISetupImageVideo(ScreenPtr pScreen) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - XGIPtr pXGI = XGIPTR(pScrn); - XF86VideoAdaptorPtr adapt; - XGIPortPrivPtr pPriv; - - if(!(adapt = xcalloc(1, sizeof(XF86VideoAdaptorRec) + - sizeof(XGIPortPrivRec) + - sizeof(DevUnion)))) - return NULL; - - adapt->type = XvWindowMask | XvInputMask | XvImageMask; - adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; - /*adapt->name = "XGI Video Overlay"; */ - adapt->name = "XGI Video"; - adapt->nEncodings = 1; - adapt->pEncodings = &DummyEncoding; - adapt->nFormats = NUM_FORMATS; - adapt->pFormats = XGIFormats; - adapt->nPorts = 1; - adapt->pPortPrivates = (DevUnion*)(&adapt[1]); - - pPriv = (XGIPortPrivPtr)(&adapt->pPortPrivates[1]); - - adapt->pPortPrivates[0].ptr = (pointer)(pPriv); - adapt->pAttributes = XGIAttributes; - adapt->nAttributes = NUM_ATTRIBUTES; - adapt->nImages = NUM_IMAGES; - adapt->pImages = XGIImages; - adapt->PutVideo = NULL; - adapt->PutStill = NULL; - adapt->GetVideo = NULL; - adapt->GetStill = NULL; - adapt->StopVideo = XGIStopVideo; - adapt->SetPortAttribute = XGISetPortAttribute; - adapt->GetPortAttribute = XGIGetPortAttribute; - adapt->QueryBestSize = XGIQueryBestSize; - adapt->PutImage = XGIPutImage; - adapt->QueryImageAttributes = XGIQueryImageAttributes; - - pPriv->currentBuf = 0; - pPriv->linear = NULL; - pPriv->fbAreaPtr = NULL; - pPriv->fbSize = 0; - pPriv->videoStatus = 0; - pPriv->linebufMergeLimit = 1280; - - /* gotta uninit this someplace */ -#if defined(REGION_NULL) - REGION_NULL(pScreen, &pPriv->clip); -#else - REGION_INIT(pScreen, &pPriv->clip, NullBox, 0); -#endif - - /* Reset the properties to their defaults */ - XGISetPortDefaults(pScrn, pPriv); - - pXGI->adaptor = adapt; - pXGI->xvBrightness = MAKE_ATOM(xgixvbrightness); - pXGI->xvContrast = MAKE_ATOM(xgixvcontrast); - pXGI->xvColorKey = MAKE_ATOM(xgixvcolorkey); - pXGI->xvSaturation = MAKE_ATOM(xgixvsaturation); - pXGI->xvHue = MAKE_ATOM(xgixvhue); - pXGI->xvGammaRed = MAKE_ATOM(xgixvgammared); - pXGI->xvGammaGreen = MAKE_ATOM(xgixvgammagreen); - pXGI->xvGammaBlue = MAKE_ATOM(xgixvgammablue); - - /* set display register */ - if(pXGI->VBFlags) { - pPriv->displayMode = DISPMODE_MIRROR; - SetSRRegMask(pXGI, Index_SR_Graphic_Mode, 0x00, 0xc0); /* Only ovelray in CRT1*/ - SetSRRegMask(pXGI, Index_SR_Ext_Clock_Sel, 0x00, 0xc0); - } - else { - pPriv->displayMode = DISPMODE_SINGLE1; - SetSRRegMask(pXGI, Index_SR_Graphic_Mode, 0x00, 0xc0); - SetSRRegMask(pXGI, Index_SR_Ext_Clock_Sel, 0x00, 0xc0); - } - - set_maxencoding(pXGI, pPriv); - - XGIResetVideo(pScrn); - - pXGI->ResetXv = XGIResetVideo; - pXGI->ResetXvGamma = XGIResetXvGamma; - - return adapt; -} - - -static int -XGISetPortAttribute( - ScrnInfoPtr pScrn, - Atom attribute, - INT32 value, - pointer data -){ - XGIPortPrivPtr pPriv = (XGIPortPrivPtr)data; - XGIPtr pXGI = XGIPTR(pScrn); - - if (attribute == pXGI->xvBrightness) { - if((value < -128) || (value > 127)) - return BadValue; - - pPriv->brightness = value; - SetVideoBrightnessReg(pXGI, value); - } - else if (attribute == pXGI->xvContrast) { - if ((value < 0) || (value > 255)) - return BadValue; - - pPriv->contrast = value; - SetVideoContrastReg(pXGI, value); - } - else if (attribute == pXGI->xvSaturation){ - if ((value < -180) || (value > 180)) - return BadValue; - - pPriv->saturation = value; - SetVideoSaturationReg(pXGI, value); - } - else if (attribute == pXGI->xvHue){ - if ((value < -180) || (value > 180)) - return BadValue; - - pPriv->hue = value; - SetVideoHueReg(pXGI, value); - } - else if (attribute == pXGI->xvColorKey) { - pPriv->colorKey = value; - REGION_EMPTY(pScrn->pScreen, &pPriv->clip); - } else if(attribute == pXGI->xvGammaRed) { - if((value < 100) || (value > 10000)) - return BadValue; - - pXGI->XvGammaRed = value; - XGIUpdateXvGamma(pXGI, pPriv); - } else if(attribute == pXGI->xvGammaGreen) { - if((value < 100) || (value > 10000)) - return BadValue; - - pXGI->XvGammaGreen = value; - XGIUpdateXvGamma(pXGI, pPriv); - } else if(attribute == pXGI->xvGammaBlue) { - if((value < 100) || (value > 10000)) - return BadValue; - - pXGI->XvGammaBlue = value; - XGIUpdateXvGamma(pXGI, pPriv); - } else - return BadMatch; - - return Success; -} - -static int -XGIGetPortAttribute( - ScrnInfoPtr pScrn, - Atom attribute, - INT32 *value, - pointer data -){ - XGIPortPrivPtr pPriv = (XGIPortPrivPtr)data; - XGIPtr pXGI = XGIPTR(pScrn); - - if (attribute == pXGI->xvBrightness) { - *value = pPriv->brightness; - } - else if (attribute == pXGI->xvContrast) { - *value = pPriv->contrast; - } - else if (attribute == pXGI->xvSaturation) { - *value = pPriv->saturation; - } - else if (attribute == pXGI->xvHue) { - *value = pPriv->hue; - - } else if(attribute == pXGI->xvGammaRed) { - *value = pXGI->XvGammaRed; - - } else if(attribute == pXGI->xvGammaGreen) { - *value = pXGI->XvGammaGreen; - - } else if(attribute == pXGI->xvGammaBlue) { - *value = pXGI->XvGammaBlue; - - } - else if (attribute == pXGI->xvColorKey) { - *value = pPriv->colorKey; - - } - else - return BadMatch; - - return Success; -} - -static void -XGIQueryBestSize( - ScrnInfoPtr pScrn, - Bool motion, - short vid_w, short vid_h, - short drw_w, short drw_h, - unsigned int *p_w, unsigned int *p_h, - pointer data -){ - *p_w = drw_w; - *p_h = drw_h; - - /* TODO: report the HW limitation */ -} - - -void -set_scale_factor(XGIOverlayPtr pOverlay) -{ - float f_temp; - int NewPitch, srcPitch; - - CARD32 I=0; - - int dstW = pOverlay->dstBox.x2 - pOverlay->dstBox.x1; - int dstH = pOverlay->dstBox.y2 - pOverlay->dstBox.y1; - int srcW = pOverlay->srcW; - int srcH = pOverlay->srcH; - - NewPitch = srcPitch = pOverlay->pitch; - - /*Set 1 as default, because we don't need change 4-tap DDA scale value in the upscale case*/ - pOverlay->f_scale = 1.0; - - if (dstW == srcW) { - pOverlay->HUSF = 0x00; - pOverlay->IntBit = 0x05; - } - else if (dstW > srcW) { - - /*pOverlay->HUSF = (srcW << 16) / dstW; */ - - if ((dstW > 2) && (srcW > 2)) { - pOverlay->HUSF = (((srcW - 2) << 16) + dstW - 3) / (dstW - 2); - } - else { - pOverlay->HUSF = ((srcW << 16) + dstW - 1) / dstW; - } - pOverlay->IntBit = 0x04; - } - /* downscale in horizontal */ - else { - - int tmpW = dstW; - - I = 0x00; - - pOverlay->IntBit = 0x01; - - /* */ - while (srcW >= tmpW) - { - tmpW <<= 1; - I++; - } - - pOverlay->wHPre = (CARD8)(I - 1); - dstW <<= (I - 1); - - f_temp = srcW/dstW; - - /* we don't need to change 4-tap DDA scale if upscale */ - if (f_temp < 1.0) - f_temp = 1.0; - - pOverlay->f_scale = f_temp; - - if ((srcW % dstW)) - pOverlay->HUSF = ((srcW - dstW) << 16) / dstW; - else - pOverlay->HUSF = 0x00; - } - - if (dstH == srcH) { - pOverlay->VUSF = 0x00; - pOverlay->IntBit |= 0x0A; - } - else if (dstH > srcH) { - dstH += 0x02; - /*pOverlay->VUSF = (srcH << 16) / dstH;*/ - if ((dstH > 2) && (srcH > 2)) { - pOverlay->VUSF = (((srcH - 2) << 16) - 32768 + dstH - 3) / (dstH - 2); - } - else { - pOverlay->VUSF = ((srcH << 16) + dstH - 1) / dstH; - } - - pOverlay->IntBit |= 0x08; - } - /* downscale in vertical */ - else { - - CARD32 realI; - - I = realI = srcH / dstH; - pOverlay->IntBit |= 0x02; - - if (I < 2) - { - pOverlay->VUSF = ((srcH - dstH)<<16)/dstH; - } - else - { - if (((srcPitch * I)>>2) > 0xFFF) - { - I = (0xFFF*2/srcPitch); - pOverlay->VUSF = 0xFFFF; - } - else - { - dstH = I * dstH; - - if (srcH % dstH) - pOverlay->VUSF = ((srcH - dstH) << 16) / dstH; - else - pOverlay->VUSF = 0x00; - } - - /* set video frame buffer offset */ - NewPitch = (srcPitch*I); - } - } - - pOverlay->pitch = (CARD16)(NewPitch); - } - -void -set_contrast_factor(XGIPtr pXGI, XGIOverlayPtr pOverlay) -{ - ScrnInfoPtr pScrn = pXGI->pScrn; - CARD16 screenX = pScrn->currentMode->HDisplay; - CARD16 screenY = pScrn->currentMode->VDisplay; - - CARD32 value, SamplePixel, dwTotalPixel; - - CARD16 top, left; - CARD16 bottom, right; - - top = pOverlay->dstBox.y1; - bottom = pOverlay->dstBox.y2; - - if (bottom > screenY) - bottom = screenY; - - left = pOverlay->dstBox.x1; - right = pOverlay->dstBox.x2; - - if (right > screenX) - right = screenX; - - dwTotalPixel = (bottom - top) * (right - left); - - value = (dwTotalPixel - 10000) / 20000; - - if (value > 3 ) - value = 3; - - pOverlay->dwContrastFactor = value; - - switch (value) { - case 1: SamplePixel = 4096; break; - case 2: SamplePixel = 8192; break; - case 3: SamplePixel = 8192; break; - - default: - SamplePixel = 2048; - break; - } - - pOverlay->SamplePixel = (SamplePixel << 10) / dwTotalPixel; - -} - -static void -set_line_buf_size(XGIOverlayPtr pOverlay) -{ - CARD8 preHIDF; - CARD32 dwI; - CARD32 dwSrcWidth = pOverlay->srcW; - int pixelFormat = pOverlay->pixelFormat; - - if ((pixelFormat == PIXEL_FMT_YV12) || - (pixelFormat == PIXEL_FMT_NV12) || - (pixelFormat == PIXEL_FMT_NV21)) - { - preHIDF = pOverlay->wHPre & 0x07; - - if (preHIDF < 2) - { - preHIDF = 2; - } - - if (dwSrcWidth & ~(0xffffff80 << (preHIDF - 2))) - { - dwI = (dwSrcWidth >> (preHIDF + 5)) + 1; - } - else - { - dwI = dwSrcWidth >> (preHIDF + 5); - } - - pOverlay->lineBufSize = dwI * (0x01 << (preHIDF + 2)) - 1; - - } - /* not plane format */ - else - { - if (dwSrcWidth & 0x07) - dwI = (dwSrcWidth >> 3) + 1; - else - dwI = (dwSrcWidth >> 3); - - pOverlay->lineBufSize = dwI; - } -} - -static void -XGIDisplayVideo(ScrnInfoPtr pScrn, XGIPortPrivPtr pPriv) -{ - XGIPtr pXGI = XGIPTR(pScrn); - - short srcPitch = pPriv->srcPitch; - short height = pPriv->height; - XGIOverlayRec overlay; - int srcOffsetX=0, srcOffsetY=0; - int sx=0, sy=0; - - memset(&overlay, 0, sizeof(overlay)); - overlay.pixelFormat = pPriv->id; - overlay.pitch = srcPitch; - overlay.keyOP = 0x03; /* destination colorkey */ - overlay.bobEnable = 0x00; - - overlay.dstBox.x1 = pPriv->drw_x - pScrn->frameX0; - overlay.dstBox.x2 = pPriv->drw_x + pPriv->drw_w - pScrn->frameX0; - overlay.dstBox.y1 = pPriv->drw_y - pScrn->frameY0; - overlay.dstBox.y2 = pPriv->drw_y + pPriv->drw_h - pScrn->frameY0; - - if((overlay.dstBox.x2 < 0) || (overlay.dstBox.y2 < 0)) - return; - - if(overlay.dstBox.x1 < 0) { - srcOffsetX = pPriv->src_w * (-overlay.dstBox.x1) / pPriv->drw_w; - overlay.dstBox.x1 = 0; - } - if(overlay.dstBox.y1 < 0) { - srcOffsetY = pPriv->src_h * (-overlay.dstBox.y1) / pPriv->drw_h; - overlay.dstBox.y1 = 0; - } - - if (pPriv->videoStatus & CLIENT_CAPTURE_ON) - { - /* We use AutoFlip for capture, not need buffer address */ - overlay.PSY = 0x0000; - } - else - { - switch(pPriv->id){ - case PIXEL_FMT_YV12: - sx = (pPriv->src_x + srcOffsetX) & ~7; - sy = (pPriv->src_y + srcOffsetY) & ~1; - - overlay.PSY = pPriv->bufAddr[pPriv->currentBuf] + sx + sy*srcPitch; - overlay.PSV = pPriv->bufAddr[pPriv->currentBuf] + height*srcPitch + ((sx + sy*srcPitch/2) >> 1); - overlay.PSU = pPriv->bufAddr[pPriv->currentBuf] + height*srcPitch*5/4 + ((sx + sy*srcPitch/2) >> 1); - break; - - case PIXEL_FMT_NV12: - case PIXEL_FMT_NV21: - sx = (pPriv->src_x + srcOffsetX) & ~7; - sy = (pPriv->src_y + srcOffsetY) & ~1; - overlay.PSY = pPriv->bufAddr[pPriv->currentBuf] + sx + sy*srcPitch; - overlay.PSV = pPriv->bufAddr[pPriv->currentBuf] + height*srcPitch + ((sx + sy*srcPitch/2) >> 1); - overlay.PSU = overlay.PSV; - break; - - case PIXEL_FMT_YUY2: - case PIXEL_FMT_UYVY: - case PIXEL_FMT_YVYU: - case PIXEL_FMT_RGB6: - case PIXEL_FMT_RGB5: - sx = (pPriv->src_x + srcOffsetX) & ~1; - sy = (pPriv->src_y + srcOffsetY); - - overlay.PSY = pPriv->bufAddr[pPriv->currentBuf] + sx*2 + sy*srcPitch; - break; - - default: - /* ErrorF("UnSurpported Format"); */ - break; - } - - } - - overlay.srcW = pPriv->src_w - (sx - pPriv->src_x); - overlay.srcH = pPriv->src_h - (sy - pPriv->src_y); - - /* set line buffer length */ - set_line_buf_size (&overlay); - - /* set scale factor */ - set_scale_factor (&overlay); - - /* contrast factor */ - set_contrast_factor(pXGI, &overlay); - - SetSelectOverlayReg(pXGI, 0x00); - - SetColorkeyReg(pXGI, pPriv->colorKey); - - /* set overlay */ - SetOverlayReg(pXGI, &overlay); - - /* enable overlay */ - SetEnableOverlayReg(pXGI, TRUE); -} - - -static void -XGIStopVideo(ScrnInfoPtr pScrn, pointer data, Bool exit) -{ - XGIPortPrivPtr pPriv = (XGIPortPrivPtr)data; - XGIPtr pXGI = XGIPTR(pScrn); - - REGION_EMPTY(pScrn->pScreen, &pPriv->clip); - - if(exit) { - - if(pPriv->videoStatus & CLIENT_VIDEO_ON) { - SetEnableOverlayReg(pXGI, FALSE); - } - - if (pPriv->videoStatus & CLIENT_CAPTURE_ON) { - EnableCaptureAutoFlip(pXGI, FALSE); - } - - if(pPriv->fbAreaPtr) { - xf86FreeOffscreenArea(pPriv->fbAreaPtr); - pPriv->fbAreaPtr = NULL; - pPriv->fbSize = 0; - } - - - /* clear all flag */ - pPriv->videoStatus = 0; - - } else { - if(pPriv->videoStatus & CLIENT_VIDEO_ON) { - pPriv->videoStatus |= OFF_TIMER; - pPriv->offTime = currentTime.milliseconds + OFF_DELAY; - } - } -} - -typedef unsigned short u16; -typedef unsigned int u32; - -static int -XGIPutImage( - ScrnInfoPtr pScrn, - short src_x, short src_y, - short drw_x, short drw_y, - short src_w, short src_h, - short drw_w, short drw_h, - int id, unsigned char* buf, - short width, short height, - Bool sync, - RegionPtr clipBoxes, pointer data -){ - XGIPtr pXGI = XGIPTR(pScrn); - XGIPortPrivPtr pPriv = (XGIPortPrivPtr)data; - - int i; - - int totalSize=0; -/* int depth = pXGI->CurrentLayout.bitsPerPixel >> 3; */ - - pPriv->drw_x = drw_x; - pPriv->drw_y = drw_y; - pPriv->drw_w = drw_w; - pPriv->drw_h = drw_h; - pPriv->src_x = src_x; - pPriv->src_y = src_y; - pPriv->src_w = src_w; - pPriv->src_h = src_h; - pPriv->id = id; - pPriv->height = height; - - /* Pixel formats: - 1. YU12: 3 planes: H V - Y sample period 1 1 (8 bit per pixel) - V sample period 2 2 (8 bit per pixel, subsampled) - U sample period 2 2 (8 bit per pixel, subsampled) - - Y plane is fully sampled (width*height), U and V planes - are sampled in 2x2 blocks, hence a group of 4 pixels requires - 4 + 1 + 1 = 6 bytes. The data is planar, ie in single planes - for Y, U and V. - 2. UYVY: 3 planes: H V - Y sample period 1 1 (8 bit per pixel) - V sample period 2 1 (8 bit per pixel, subsampled) - U sample period 2 1 (8 bit per pixel, subsampled) - Y plane is fully sampled (width*height), U and V planes - are sampled in 2x1 blocks, hence a group of 4 pixels requires - 4 + 2 + 2 = 8 bytes. The data is bit packed, there are no separate - Y, U or V planes. - Bit order: U0 Y0 V0 Y1 U2 Y2 V2 Y3 ... - 3. I420: Like YU12, but planes U and V are in reverse order. - 4. YUY2: Like UYVY, but order is - Y0 U0 Y1 V0 Y2 U2 Y3 V2 ... - 5. YVYU: Like YUY2, but order is - Y0 V0 Y1 U0 Y2 V2 Y3 U2 ... - */ - switch(id){ - case PIXEL_FMT_YV12: - case PIXEL_FMT_NV12: - case PIXEL_FMT_NV21: - pPriv->srcPitch = (width + 7) & ~7; - totalSize = (pPriv->srcPitch * height * 3) >> 1; /* Verified */ - break; - case PIXEL_FMT_YUY2: - case PIXEL_FMT_UYVY: - case PIXEL_FMT_YVYU: - case PIXEL_FMT_RGB6: - case PIXEL_FMT_RGB5: - default: - pPriv->srcPitch = ((width << 1) + 3) & ~3; /* Verified */ - totalSize = pPriv->srcPitch * height; - } - - /* make it a multiple of 16 to simplify to copy loop */ - totalSize += 15; - totalSize &= ~15; - printf("PutImage\n"); - /* allocate memory */ - do { - int lines, pitch, depth; - BoxPtr pBox; - - if(totalSize == pPriv->fbSize) - break; - - pPriv->fbSize = totalSize; - - if(pPriv->fbAreaPtr) { - xf86FreeOffscreenArea(pPriv->fbAreaPtr); - } - - depth = (pScrn->bitsPerPixel + 7 ) / 8; - pitch = pScrn->displayWidth * depth; - lines = ((totalSize * 2) / pitch) + 1; - - pPriv->fbAreaPtr = xf86AllocateOffscreenArea(pScrn->pScreen, - pScrn->displayWidth, - lines, 0, NULL, NULL, NULL); - - if(!pPriv->fbAreaPtr) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Allocate video memory fails\n"); - return BadAlloc; - } - - pBox = &(pPriv->fbAreaPtr->box); - pPriv->bufAddr[0] = (pBox->x1 * depth) + (pBox->y1 * pitch); - pPriv->bufAddr[1] = pPriv->bufAddr[0] + totalSize; - - } while(0); - - /* copy data */ - if((pXGI->XvUseMemcpy) || (totalSize < 16)) { - #ifdef NewPath - memcpy(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf], buf, totalSize); - - #else - switch(id){ - case PIXEL_FMT_YV12: - { - BYTE *Y, *V, *U, *srcY, *srcV, *srcU; - - short srcPitch2 = pPriv->srcPitch >> 1; - short height2 = height >> 1; - short width2 = width >> 1; - - Y = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - V = Y + pPriv->srcPitch * height; - U = V + pPriv->srcPitch * height / 4 ; - - srcY = buf; - srcV = srcY + width * height; - srcU = srcV + width * height / 4; -#if !defined(__powerpc__) - for(i=0; isrcPitch, srcY + i*width, width); - - for(i=0; idepth == 16)//16 BPP - { - for(i=0; isrcPitch + j)) = *((u16 *)(srcY + i*width + j)); - } - } - - for(i=0; isrcPitch + j+1) = *(unsigned char *)(srcY + i*width + j); - *(unsigned char *)(Y + i * pPriv->srcPitch + j) = *(unsigned char *)(srcY + i*width + j+1); - } - } - - for(i=0; idepth == 24)//32 BPP - { - for(i=0; isrcPitch + j)) = *((u32 *)(srcY + i*width + j)); - } - } - - for(i=0; isrcPitch + j+3) = *(unsigned char *)(srcY + i*width + j); - *(unsigned char *)(Y + i * pPriv->srcPitch + j+2) = *(unsigned char *)(srcY + i*width + j+1); - *(unsigned char *)(Y + i * pPriv->srcPitch + j+1) = *(unsigned char *)(srcY + i*width + j+2); - *(unsigned char *)(Y + i * pPriv->srcPitch + j) = *(unsigned char *)(srcY + i*width + j+3); - } - } - - for(i=0; isrcPitch, srcY + i*width, width); - - for(i=0; i> 1; - - Y = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - VU = Y + pPriv->srcPitch * height; - - srcY = buf; - srcVU = srcY + width * height; -#if !defined(__powerpc__) - - for(i=0; isrcPitch, srcY + i*width, width); - - for(i=0; isrcPitch, srcVU + i*width, width); -#else - if(pScrn->depth == 16)//16 BPP - { - for(i=0; isrcPitch+j)) = *((u16 *)(srcY + i*width+j)); - } - } - - for(i=0; isrcPitch+j)) = *((u16 *)(srcVU + i*width+j)); - } - } -/* - for(i=0; isrcPitch+j) = *(unsigned char *)(srcY + i*width+j+1); - *(unsigned char *)(Y + i * pPriv->srcPitch+j+1) = *(unsigned char *)(srcY + i*width+j); - } - } - - for(i=0; isrcPitch+j) = *(unsigned char *)(srcVU + i*width+j+1); - *(unsigned char *)(VU + i * pPriv->srcPitch+j+1) = *(unsigned char *)(srcVU + i*width+j); - } - } */ - } - else if(pScrn->depth == 24)//32 BPP - { - - for(i=0; isrcPitch+j)) = *((u32 *)(srcY + i*width+j)); - } - } - - for(i=0; isrcPitch+j)) = *((u32 *)(srcVU + i*width+j)); - } - } -/* - for(i=0; isrcPitch+j) = *(unsigned char *)(srcY + i*width+j+3); - *(unsigned char *)(Y + i * pPriv->srcPitch+j+1) = *(unsigned char *)(srcY + i*width+j+2); - *(unsigned char *)(Y + i * pPriv->srcPitch+j+2) = *(unsigned char *)(srcY + i*width+j+1); - *(unsigned char *)(Y + i * pPriv->srcPitch+j+3) = *(unsigned char *)(srcY + i*width+j); - - } - } - - for(i=0; isrcPitch+j) = *(unsigned char *)(srcVU + i*width+j+3); - *(unsigned char *)(VU + i * pPriv->srcPitch+j+1) = *(unsigned char *)(srcVU + i*width+j+2); - *(unsigned char *)(VU + i * pPriv->srcPitch+j+2) = *(unsigned char *)(srcVU + i*width+j+1); - *(unsigned char *)(VU + i * pPriv->srcPitch+j+3) = *(unsigned char *)(srcVU + i*width+j); - - } - }*/ - } - else - { - for(i=0; isrcPitch, srcY + i*width, width); - - for(i=0; isrcPitch, srcVU + i*width, width); - } -#endif - break; - } - case PIXEL_FMT_YUY2: - case PIXEL_FMT_UYVY: - case PIXEL_FMT_YVYU: - case PIXEL_FMT_RGB6: - case PIXEL_FMT_RGB5: - { - BYTE *Base = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - - for(i=0; isrcPitch, buf + i*width*2, width*2); -#else - if(pScrn->depth == 16)//16 BPP - { - int j; - for(j=0; jsrcPitch+j)) = *((u16 *)(buf+i*width*2+j)); - } -/* for(j=0; jsrcPitch+j) = *(unsigned char *)(buf+i*width*2+j+1); - *(unsigned char *)(Base+i*pPriv->srcPitch+j+1) = *(unsigned char *)(buf+i*width*2+j); - }*/ - } - else if(pScrn->depth == 24)//24 BPP - { - int j; - for(j=0; jsrcPitch+j)) = *((u32 *)(buf+i*width*2+j)); - } - /* - int j; - for(j=0; jsrcPitch+j) = *(unsigned char *)(buf+i*width*2+j+3); - *(unsigned char *)(Base+i*pPriv->srcPitch+j+1) = *(unsigned char *)(buf+i*width*2+j+2); - *(unsigned char *)(Base+i*pPriv->srcPitch+j+2) = *(unsigned char *)(buf+i*width*2+j+1); - *(unsigned char *)(Base+i*pPriv->srcPitch+j+3) = *(unsigned char *)(buf+i*width*2+j); - - } */ - } - else - memcpy( Base + i * pPriv->srcPitch, buf + i*width*2, width*2); -#endif - break; - } - default: - memcpy(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf], buf, totalSize); - break; - } - #endif - - } - else { - - #ifdef NewPath - BYTE *Base = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - for(i=0; isrcPitch >> 1; - short height2 = height >> 1; - short width2 = width >> 1; - int j; - - Y = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - V = Y + pPriv->srcPitch * height; - U = V + pPriv->srcPitch * height / 4 ; - srcY = buf; - srcV = srcY + width * height; - srcU = srcV + width * height / 4; - ErrorF("else...YV12 case\n"); -/*#if !defined(__powerpc__)*/ - for(i=0; isrcPitch*i + j); - - for(i=0; isrcPitch + j+1) = *(unsigned char *)(srcY + i*width + j); - *(unsigned char *)(Y + i * pPriv->srcPitch + j) = *(unsigned char *)(srcY + i*width + j+1); - } - } - - for(i=0; i> 1; - - Y = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - VU = Y + pPriv->srcPitch * height; - - srcY = buf; - srcVU = srcY + width * height; - -/*#if !defined(__powerpc__)*/ - for(i=0; isrcPitch*i + j); - - for(i=0; isrcPitch*i + j); -/*#else - for(i=0; isrcPitch+j) = *(unsigned char *)(srcY + i*width+j+1); - *(unsigned char *)(Y + i * pPriv->srcPitch+j+1) = *(unsigned char *)(srcY + i*width+j); - } - } - - for(i=0; isrcPitch+j) = *(unsigned char *)(srcVU + i*width+j+1); - *(unsigned char *)(VU + i * pPriv->srcPitch+j+1) = *(unsigned char *)(srcVU + i*width+j); - } - - } -#endif -*/ - break; - } - case PIXEL_FMT_YUY2: - case PIXEL_FMT_UYVY: - case PIXEL_FMT_YVYU: - case PIXEL_FMT_RGB6: - case PIXEL_FMT_RGB5: - { - BYTE *Base = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - int j; - ErrorF("else...YUY2 case\n"); -//#if !defined(__powerpc__) - for(i=0; isrcPitch+j) = *(buf + width*i + j); -/*#else - { - for(j=0; jsrcPitch+j) = *(unsigned char *)(buf+i*width*2+j+1); - *(unsigned char *)(Base+i*pPriv->srcPitch+j+1) = *(unsigned char *)(buf+i*width*2+j); - } - } -#endif*/ - break; - } - default: - { - BYTE *Base = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - int j; - for(i=0; ipScreen, &pPriv->clip, clipBoxes)) - { - REGION_COPY(pScrn->pScreen, &pPriv->clip, clipBoxes); - - /* draw these */ - } else { - xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey, clipBoxes); - } /* update cliplist */ - - pPriv->currentBuf ^= 1; - pPriv->videoStatus = CLIENT_VIDEO_ON; - - return Success; -} - - -static int -XGIQueryImageAttributes( - ScrnInfoPtr pScrn, - int id, - unsigned short *w, unsigned short *h, - int *pitches, int *offsets -){ - int pitchY, pitchUV; - int size, sizeY, sizeUV; - - if(*w < IMAGE_MIN_WIDTH) *w = IMAGE_MIN_WIDTH; - if(*h < IMAGE_MIN_HEIGHT) *h = IMAGE_MIN_HEIGHT; - - if(*w > DummyEncoding.width) *w = DummyEncoding.width; - if(*h > DummyEncoding.height) *h = DummyEncoding.height; - - switch(id) { - case PIXEL_FMT_YV12: - *w = (*w + 7) & ~7; - *h = (*h + 1) & ~1; - pitchY = *w; - pitchUV = *w >> 1; - if(pitches) { - pitches[0] = pitchY; - pitches[1] = pitches[2] = pitchUV; - } - sizeY = pitchY * (*h); - sizeUV = pitchUV * ((*h) >> 1); - if(offsets) { - offsets[0] = 0; - offsets[1] = sizeY; - offsets[2] = sizeY + sizeUV; - } - size = sizeY + (sizeUV << 1); - break; - case PIXEL_FMT_NV12: - case PIXEL_FMT_NV21: - *w = (*w + 7) & ~7; - *h = (*h + 1) & ~1; - pitchY = *w; - pitchUV = *w; - if(pitches) { - pitches[0] = pitchY; - pitches[1] = pitchUV; - } - sizeY = pitchY * (*h); - sizeUV = pitchUV * ((*h) >> 1); - if(offsets) { - offsets[0] = 0; - offsets[1] = sizeY; - } - size = sizeY + (sizeUV << 1); - break; - case PIXEL_FMT_YUY2: - case PIXEL_FMT_UYVY: - case PIXEL_FMT_YVYU: - case PIXEL_FMT_RGB6: - case PIXEL_FMT_RGB5: - default: - *w = (*w + 1) & ~1; - pitchY = *w << 1; - if(pitches) pitches[0] = pitchY; - if(offsets) offsets[0] = 0; - size = pitchY * (*h); - break; - } - - return size; -} diff --git a/src/xgi_vide2.c b/src/xgi_vide2.c deleted file mode 100644 index 554e0d7..0000000 --- a/src/xgi_vide2.c +++ /dev/null @@ -1,1402 +0,0 @@ -/*************************************************************************** - -Copyright 2004 eXtreme Graphics Innovation Corp, Inc., HsinChu, Taiwan. -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 INTEL, AND/OR ITS SUPPLIERS 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. - -**************************************************************************/ - -/* - * Formerly based on Xv driver for SiS 300, 315 and 330 series by - * Thomas Winischhofer - * - * Basic structure based on the mga Xv driver by Mark Vojkovich - * and i810 Xv driver by Jonathan Bian . - * - * Authors: - * Nan-Hsing Chang - * - * This supports the following chipsets: - * XGI340, XGI342: Full register range, one overlay (used for both CRT1 and CRT2 alt.) - * - */ - -#include "xf86.h" -#include "xf86_OSproc.h" -#include "xf86Resources.h" -#include "compiler.h" -#include "xf86PciInfo.h" -#include "xf86Pci.h" -#include "xf86fbman.h" -#include "regionstr.h" - -#include "xgi.h" -#include "xf86xv.h" -#include -#include "xaa.h" -#include "xaalocal.h" -#include "dixstruct.h" -#include "fourcc.h" - -/* TODO: move to xgi_regs.h */ -#include "xgi_videohw.h" -#include "xgi_video.h" - -static XF86VideoAdaptorPtr XGISetupImageVideo(ScreenPtr); -static int XGISetPortAttribute(ScrnInfoPtr, Atom, INT32, pointer); -static int XGIGetPortAttribute(ScrnInfoPtr, Atom ,INT32 *, pointer); -static void XGIQueryBestSize(ScrnInfoPtr, Bool, - short, short, short, short, unsigned int *, unsigned int *, pointer); -static int XGIPutImage( ScrnInfoPtr, - short, short, short, short, short, short, short, short, - int, unsigned char*, short, short, Bool, RegionPtr, pointer); -static int XGIQueryImageAttributes(ScrnInfoPtr, - int, unsigned short *, unsigned short *, int *, int *); -static void XGIStopVideo(ScrnInfoPtr, pointer, Bool); -/* static void XGIFreeOverlayMemory(ScrnInfoPtr pScrn); */ - -extern void SetSRRegMask(XGIPtr, CARD8, CARD8, CARD8); -extern void XGIUpdateXvGamma(XGIPtr, XGIPortPrivPtr); -#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE) - -void XGIInitVideo(ScreenPtr pScreen) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - XF86VideoAdaptorPtr *adaptors, *newAdaptors = NULL; - XF86VideoAdaptorPtr newAdaptor = NULL; - int num_adaptors; - - newAdaptor = XGISetupImageVideo(pScreen); - - num_adaptors = xf86XVListGenericAdaptors(pScrn, &adaptors); - - if(newAdaptor) { - if(!num_adaptors) { - num_adaptors = 1; - adaptors = &newAdaptor; - } else { - newAdaptors = /* need to free this someplace */ - xalloc((num_adaptors + 1) * sizeof(XF86VideoAdaptorPtr*)); - if(newAdaptors) { - memcpy(newAdaptors, adaptors, num_adaptors * - sizeof(XF86VideoAdaptorPtr)); - newAdaptors[num_adaptors] = newAdaptor; - adaptors = newAdaptors; - num_adaptors++; - } - } - } - - if(num_adaptors) - xf86XVScreenInit(pScreen, adaptors, num_adaptors); - - if(newAdaptors) - xfree(newAdaptors); - -} - - -/* client libraries expect an encoding */ -static XF86VideoEncodingRec DummyEncoding = -{ - 0, - "XV_IMAGE", - 0, 0, /* Will be filled in */ - {1, 1} -}; - -#define NUM_FORMATS 3 - -static XF86VideoFormatRec XGIFormats[NUM_FORMATS] = -{ - { 8, PseudoColor}, - {16, TrueColor}, - {24, TrueColor} -}; - -static char xgixvcolorkey[] = "XV_COLORKEY"; -static char xgixvbrightness[] = "XV_BRIGHTNESS"; -static char xgixvcontrast[] = "XV_CONTRAST"; -static char xgixvsaturation[] = "XV_SATURATION"; -static char xgixvhue[] = "XV_HUE"; -static char xgixvgammared[] = "XV_GAMMA_RED"; -static char xgixvgammagreen[] = "XV_GAMMA_GREEN"; -static char xgixvgammablue[] = "XV_GAMMA_BLUE"; - -#define NUM_ATTRIBUTES 8 - -static XF86AttributeRec XGIAttributes[NUM_ATTRIBUTES] = -{ - {XvSettable | XvGettable, 0, (1 << 24) - 1, xgixvcolorkey}, - {XvSettable | XvGettable, -128, 127, xgixvbrightness}, - {XvSettable | XvGettable, 0, 255, xgixvcontrast}, - {XvSettable | XvGettable, -180, 180, xgixvsaturation}, - {XvSettable | XvGettable, -180, 180, xgixvhue}, - {XvSettable | XvGettable, 100, 10000, xgixvgammared}, - {XvSettable | XvGettable, 100, 10000, xgixvgammagreen}, - {XvSettable | XvGettable, 100, 10000, xgixvgammablue}, -}; - -#define NUM_IMAGES 8 - -static XF86ImageRec XGIImages[NUM_IMAGES] = - { - XVIMAGE_YUY2, /* If order is changed, XGIOffscreenImages must be adapted */ - XVIMAGE_YV12, - XVIMAGE_UYVY, - { /* RGB 555 */ - PIXEL_FMT_RGB5, - XvRGB, - LSBFirst, - {'R','V','1','5', - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - 16, - XvPacked, - 1, - 15, 0x7C00, 0x03E0, 0x001F, - 0, 0, 0, - 0, 0, 0, - 0, 0, 0, - {'R', 'V', 'B',0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - XvTopToBottom - }, - { /* RGB 565 */ - PIXEL_FMT_RGB6, - XvRGB, - LSBFirst, - {'R','V','1','6', - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - 16, - XvPacked, - 1, - 16, 0xF800, 0x07E0, 0x001F, - 0, 0, 0, - 0, 0, 0, - 0, 0, 0, - {'R', 'V', 'B',0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - XvTopToBottom - }, - { /* YVYU */ - PIXEL_FMT_YVYU, \ - XvYUV, \ - LSBFirst, \ - {'Y','V','Y','U', - 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, - 16, - XvPacked, - 1, - 0, 0, 0, 0 , - 8, 8, 8, - 1, 2, 2, - 1, 1, 1, - {'Y','V','Y','U', - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - XvTopToBottom - }, - { /* NV12 */ - PIXEL_FMT_NV12, - XvYUV, - LSBFirst, - {'N','V','1','2', - 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, - 12, - XvPlanar, - 2, - 0, 0, 0, 0 , - 8, 8, 8, - 1, 2, 2, - 1, 2, 2, - {'Y','U','V',0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - XvTopToBottom - }, - { /* NV21 */ - PIXEL_FMT_NV21, - XvYUV, - LSBFirst, - {'N','V','2','1', - 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, - 12, - XvPlanar, - 2, - 0, 0, 0, 0, - 8, 8, 8, - 1, 2, 2, - 1, 2, 2, - {'Y','V','U',0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - XvTopToBottom - }, -}; - -static void -set_maxencoding(XGIPtr pXGI, XGIPortPrivPtr pPriv) -{ - DummyEncoding.width = IMAGE_MAX_WIDTH; - DummyEncoding.height = IMAGE_MAX_HEIGHT; -} - -static void -XGIResetXvGamma(ScrnInfoPtr pScrn) -{ - XGIPtr pXGI = XGIPTR(pScrn); - XGIPortPrivPtr pPriv = GET_PORT_PRIVATE(pScrn); - - XGIUpdateXvGamma(pXGI, pPriv); -} - -static void -XGISetPortDefaults(ScrnInfoPtr pScrn, XGIPortPrivPtr pPriv) -{ - pPriv->colorKey = 0x000101fe; - pPriv->brightness = 0; - pPriv->contrast = 128; - pPriv->saturation = 0; - pPriv->hue = 0; -} - -static XF86VideoAdaptorPtr -XGISetupImageVideo(ScreenPtr pScreen) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - XGIPtr pXGI = XGIPTR(pScrn); - XF86VideoAdaptorPtr adapt; - XGIPortPrivPtr pPriv; - - if(!(adapt = xcalloc(1, sizeof(XF86VideoAdaptorRec) + - sizeof(XGIPortPrivRec) + - sizeof(DevUnion)))) - return NULL; - - adapt->type = XvWindowMask | XvInputMask | XvImageMask; - adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; - /*adapt->name = "XGI Video Overlay"; */ - adapt->name = "XGI Video"; - adapt->nEncodings = 1; - adapt->pEncodings = &DummyEncoding; - adapt->nFormats = NUM_FORMATS; - adapt->pFormats = XGIFormats; - adapt->nPorts = 1; - adapt->pPortPrivates = (DevUnion*)(&adapt[1]); - - pPriv = (XGIPortPrivPtr)(&adapt->pPortPrivates[1]); - - adapt->pPortPrivates[0].ptr = (pointer)(pPriv); - adapt->pAttributes = XGIAttributes; - adapt->nAttributes = NUM_ATTRIBUTES; - adapt->nImages = NUM_IMAGES; - adapt->pImages = XGIImages; - adapt->PutVideo = NULL; - adapt->PutStill = NULL; - adapt->GetVideo = NULL; - adapt->GetStill = NULL; - adapt->StopVideo = XGIStopVideo; - adapt->SetPortAttribute = XGISetPortAttribute; - adapt->GetPortAttribute = XGIGetPortAttribute; - adapt->QueryBestSize = XGIQueryBestSize; - adapt->PutImage = XGIPutImage; - adapt->QueryImageAttributes = XGIQueryImageAttributes; - - pPriv->currentBuf = 0; - pPriv->linear = NULL; - pPriv->fbAreaPtr = NULL; - pPriv->fbSize = 0; - pPriv->videoStatus = 0; - pPriv->linebufMergeLimit = 1280; - - /* gotta uninit this someplace */ -#if defined(REGION_NULL) - REGION_NULL(pScreen, &pPriv->clip); -#else - REGION_INIT(pScreen, &pPriv->clip, NullBox, 0); -#endif - - /* Reset the properties to their defaults */ - XGISetPortDefaults(pScrn, pPriv); - - pXGI->adaptor = adapt; - pXGI->xvBrightness = MAKE_ATOM(xgixvbrightness); - pXGI->xvContrast = MAKE_ATOM(xgixvcontrast); - pXGI->xvColorKey = MAKE_ATOM(xgixvcolorkey); - pXGI->xvSaturation = MAKE_ATOM(xgixvsaturation); - pXGI->xvHue = MAKE_ATOM(xgixvhue); - pXGI->xvGammaRed = MAKE_ATOM(xgixvgammared); - pXGI->xvGammaGreen = MAKE_ATOM(xgixvgammagreen); - pXGI->xvGammaBlue = MAKE_ATOM(xgixvgammablue); - - /* set display register */ - if(pXGI->VBFlags) { - pPriv->displayMode = DISPMODE_MIRROR; - SetSRRegMask(pXGI, Index_SR_Graphic_Mode, 0x00, 0xc0); /* Only ovelray in CRT1*/ - SetSRRegMask(pXGI, Index_SR_Ext_Clock_Sel, 0x00, 0xc0); - } - else { - pPriv->displayMode = DISPMODE_SINGLE1; - SetSRRegMask(pXGI, Index_SR_Graphic_Mode, 0x00, 0xc0); - SetSRRegMask(pXGI, Index_SR_Ext_Clock_Sel, 0x00, 0xc0); - } - - set_maxencoding(pXGI, pPriv); - - XGIResetVideo(pScrn); - - pXGI->ResetXv = XGIResetVideo; - pXGI->ResetXvGamma = XGIResetXvGamma; - - return adapt; -} - - -static int -XGISetPortAttribute( - ScrnInfoPtr pScrn, - Atom attribute, - INT32 value, - pointer data -){ - XGIPortPrivPtr pPriv = (XGIPortPrivPtr)data; - XGIPtr pXGI = XGIPTR(pScrn); - - if (attribute == pXGI->xvBrightness) { - if((value < -128) || (value > 127)) - return BadValue; - - pPriv->brightness = value; - SetVideoBrightnessReg(pXGI, value); - } - else if (attribute == pXGI->xvContrast) { - if ((value < 0) || (value > 255)) - return BadValue; - - pPriv->contrast = value; - SetVideoContrastReg(pXGI, value); - } - else if (attribute == pXGI->xvSaturation){ - if ((value < -180) || (value > 180)) - return BadValue; - - pPriv->saturation = value; - SetVideoSaturationReg(pXGI, value); - } - else if (attribute == pXGI->xvHue){ - if ((value < -180) || (value > 180)) - return BadValue; - - pPriv->hue = value; - SetVideoHueReg(pXGI, value); - } - else if (attribute == pXGI->xvColorKey) { - pPriv->colorKey = value; - REGION_EMPTY(pScrn->pScreen, &pPriv->clip); - } else if(attribute == pXGI->xvGammaRed) { - if((value < 100) || (value > 10000)) - return BadValue; - - pXGI->XvGammaRed = value; - XGIUpdateXvGamma(pXGI, pPriv); - } else if(attribute == pXGI->xvGammaGreen) { - if((value < 100) || (value > 10000)) - return BadValue; - - pXGI->XvGammaGreen = value; - XGIUpdateXvGamma(pXGI, pPriv); - } else if(attribute == pXGI->xvGammaBlue) { - if((value < 100) || (value > 10000)) - return BadValue; - - pXGI->XvGammaBlue = value; - XGIUpdateXvGamma(pXGI, pPriv); - } else - return BadMatch; - - return Success; -} - -static int -XGIGetPortAttribute( - ScrnInfoPtr pScrn, - Atom attribute, - INT32 *value, - pointer data -){ - XGIPortPrivPtr pPriv = (XGIPortPrivPtr)data; - XGIPtr pXGI = XGIPTR(pScrn); - - if (attribute == pXGI->xvBrightness) { - *value = pPriv->brightness; - } - else if (attribute == pXGI->xvContrast) { - *value = pPriv->contrast; - } - else if (attribute == pXGI->xvSaturation) { - *value = pPriv->saturation; - } - else if (attribute == pXGI->xvHue) { - *value = pPriv->hue; - - } else if(attribute == pXGI->xvGammaRed) { - *value = pXGI->XvGammaRed; - - } else if(attribute == pXGI->xvGammaGreen) { - *value = pXGI->XvGammaGreen; - - } else if(attribute == pXGI->xvGammaBlue) { - *value = pXGI->XvGammaBlue; - - } - else if (attribute == pXGI->xvColorKey) { - *value = pPriv->colorKey; - - } - else - return BadMatch; - - return Success; -} - -static void -XGIQueryBestSize( - ScrnInfoPtr pScrn, - Bool motion, - short vid_w, short vid_h, - short drw_w, short drw_h, - unsigned int *p_w, unsigned int *p_h, - pointer data -){ - *p_w = drw_w; - *p_h = drw_h; - - /* TODO: report the HW limitation */ -} - - -void -set_scale_factor(XGIOverlayPtr pOverlay) -{ - float f_temp; - int NewPitch, srcPitch; - - CARD32 I=0; - - int dstW = pOverlay->dstBox.x2 - pOverlay->dstBox.x1; - int dstH = pOverlay->dstBox.y2 - pOverlay->dstBox.y1; - int srcW = pOverlay->srcW; - int srcH = pOverlay->srcH; - - NewPitch = srcPitch = pOverlay->pitch; - - /*Set 1 as default, because we don't need change 4-tap DDA scale value in the upscale case*/ - pOverlay->f_scale = 1.0; - - if (dstW == srcW) { - pOverlay->HUSF = 0x00; - pOverlay->IntBit = 0x05; - } - else if (dstW > srcW) { - - /*pOverlay->HUSF = (srcW << 16) / dstW; */ - - if ((dstW > 2) && (srcW > 2)) { - pOverlay->HUSF = (((srcW - 2) << 16) + dstW - 3) / (dstW - 2); - } - else { - pOverlay->HUSF = ((srcW << 16) + dstW - 1) / dstW; - } - pOverlay->IntBit = 0x04; - } - /* downscale in horizontal */ - else { - - int tmpW = dstW; - - I = 0x00; - - pOverlay->IntBit = 0x01; - - /* */ - while (srcW >= tmpW) - { - tmpW <<= 1; - I++; - } - - pOverlay->wHPre = (CARD8)(I - 1); - dstW <<= (I - 1); - - f_temp = srcW/dstW; - - /* we don't need to change 4-tap DDA scale if upscale */ - if (f_temp < 1.0) - f_temp = 1.0; - - pOverlay->f_scale = f_temp; - - if ((srcW % dstW)) - pOverlay->HUSF = ((srcW - dstW) << 16) / dstW; - else - pOverlay->HUSF = 0x00; - } - - if (dstH == srcH) { - pOverlay->VUSF = 0x00; - pOverlay->IntBit |= 0x0A; - } - else if (dstH > srcH) { - dstH += 0x02; - /*pOverlay->VUSF = (srcH << 16) / dstH;*/ - if ((dstH > 2) && (srcH > 2)) { - pOverlay->VUSF = (((srcH - 2) << 16) - 32768 + dstH - 3) / (dstH - 2); - } - else { - pOverlay->VUSF = ((srcH << 16) + dstH - 1) / dstH; - } - - pOverlay->IntBit |= 0x08; - } - /* downscale in vertical */ - else { - - CARD32 realI; - - I = realI = srcH / dstH; - pOverlay->IntBit |= 0x02; - - if (I < 2) - { - pOverlay->VUSF = ((srcH - dstH)<<16)/dstH; - } - else - { - if (((srcPitch * I)>>2) > 0xFFF) - { - I = (0xFFF*2/srcPitch); - pOverlay->VUSF = 0xFFFF; - } - else - { - dstH = I * dstH; - - if (srcH % dstH) - pOverlay->VUSF = ((srcH - dstH) << 16) / dstH; - else - pOverlay->VUSF = 0x00; - } - - /* set video frame buffer offset */ - NewPitch = (srcPitch*I); - } - } - - pOverlay->pitch = (CARD16)(NewPitch); - } - -void -set_contrast_factor(XGIPtr pXGI, XGIOverlayPtr pOverlay) -{ - ScrnInfoPtr pScrn = pXGI->pScrn; - CARD16 screenX = pScrn->currentMode->HDisplay; - CARD16 screenY = pScrn->currentMode->VDisplay; - - CARD32 value, SamplePixel, dwTotalPixel; - - CARD16 top, left; - CARD16 bottom, right; - - top = pOverlay->dstBox.y1; - bottom = pOverlay->dstBox.y2; - - if (bottom > screenY) - bottom = screenY; - - left = pOverlay->dstBox.x1; - right = pOverlay->dstBox.x2; - - if (right > screenX) - right = screenX; - - dwTotalPixel = (bottom - top) * (right - left); - - value = (dwTotalPixel - 10000) / 20000; - - if (value > 3 ) - value = 3; - - pOverlay->dwContrastFactor = value; - - switch (value) { - case 1: SamplePixel = 4096; break; - case 2: SamplePixel = 8192; break; - case 3: SamplePixel = 8192; break; - - default: - SamplePixel = 2048; - break; - } - - pOverlay->SamplePixel = (SamplePixel << 10) / dwTotalPixel; - -} - -static void -set_line_buf_size(XGIOverlayPtr pOverlay) -{ - CARD8 preHIDF; - CARD32 dwI; - CARD32 dwSrcWidth = pOverlay->srcW; - int pixelFormat = pOverlay->pixelFormat; - - if ((pixelFormat == PIXEL_FMT_YV12) || - (pixelFormat == PIXEL_FMT_NV12) || - (pixelFormat == PIXEL_FMT_NV21)) - { - preHIDF = pOverlay->wHPre & 0x07; - - if (preHIDF < 2) - { - preHIDF = 2; - } - - if (dwSrcWidth & ~(0xffffff80 << (preHIDF - 2))) - { - dwI = (dwSrcWidth >> (preHIDF + 5)) + 1; - } - else - { - dwI = dwSrcWidth >> (preHIDF + 5); - } - - pOverlay->lineBufSize = dwI * (0x01 << (preHIDF + 2)) - 1; - - } - /* not plane format */ - else - { - if (dwSrcWidth & 0x07) - dwI = (dwSrcWidth >> 3) + 1; - else - dwI = (dwSrcWidth >> 3); - - pOverlay->lineBufSize = dwI; - } -} - -static void -XGIDisplayVideo(ScrnInfoPtr pScrn, XGIPortPrivPtr pPriv) -{ - XGIPtr pXGI = XGIPTR(pScrn); - - short srcPitch = pPriv->srcPitch; - short height = pPriv->height; - XGIOverlayRec overlay; - int srcOffsetX=0, srcOffsetY=0; - int sx=0, sy=0; - - memset(&overlay, 0, sizeof(overlay)); - overlay.pixelFormat = pPriv->id; - overlay.pitch = srcPitch; - overlay.keyOP = 0x03; /* destination colorkey */ - overlay.bobEnable = 0x00; - - overlay.dstBox.x1 = pPriv->drw_x - pScrn->frameX0; - overlay.dstBox.x2 = pPriv->drw_x + pPriv->drw_w - pScrn->frameX0; - overlay.dstBox.y1 = pPriv->drw_y - pScrn->frameY0; - overlay.dstBox.y2 = pPriv->drw_y + pPriv->drw_h - pScrn->frameY0; - - if((overlay.dstBox.x2 < 0) || (overlay.dstBox.y2 < 0)) - return; - - if(overlay.dstBox.x1 < 0) { - srcOffsetX = pPriv->src_w * (-overlay.dstBox.x1) / pPriv->drw_w; - overlay.dstBox.x1 = 0; - } - if(overlay.dstBox.y1 < 0) { - srcOffsetY = pPriv->src_h * (-overlay.dstBox.y1) / pPriv->drw_h; - overlay.dstBox.y1 = 0; - } - - if (pPriv->videoStatus & CLIENT_CAPTURE_ON) - { - /* We use AutoFlip for capture, not need buffer address */ - overlay.PSY = 0x0000; - } - else - { - switch(pPriv->id){ - case PIXEL_FMT_YV12: - sx = (pPriv->src_x + srcOffsetX) & ~7; - sy = (pPriv->src_y + srcOffsetY) & ~1; - - overlay.PSY = pPriv->bufAddr[pPriv->currentBuf] + sx + sy*srcPitch; - overlay.PSV = pPriv->bufAddr[pPriv->currentBuf] + height*srcPitch + ((sx + sy*srcPitch/2) >> 1); - overlay.PSU = pPriv->bufAddr[pPriv->currentBuf] + height*srcPitch*5/4 + ((sx + sy*srcPitch/2) >> 1); - break; - - case PIXEL_FMT_NV12: - case PIXEL_FMT_NV21: - sx = (pPriv->src_x + srcOffsetX) & ~7; - sy = (pPriv->src_y + srcOffsetY) & ~1; - overlay.PSY = pPriv->bufAddr[pPriv->currentBuf] + sx + sy*srcPitch; - overlay.PSV = pPriv->bufAddr[pPriv->currentBuf] + height*srcPitch + ((sx + sy*srcPitch/2) >> 1); - overlay.PSU = overlay.PSV; - break; - - case PIXEL_FMT_YUY2: - case PIXEL_FMT_UYVY: - case PIXEL_FMT_YVYU: - case PIXEL_FMT_RGB6: - case PIXEL_FMT_RGB5: - sx = (pPriv->src_x + srcOffsetX) & ~1; - sy = (pPriv->src_y + srcOffsetY); - - overlay.PSY = pPriv->bufAddr[pPriv->currentBuf] + sx*2 + sy*srcPitch; - break; - - default: - /* ErrorF("UnSurpported Format"); */ - break; - } - - } - - overlay.srcW = pPriv->src_w - (sx - pPriv->src_x); - overlay.srcH = pPriv->src_h - (sy - pPriv->src_y); - - /* set line buffer length */ - set_line_buf_size (&overlay); - - /* set scale factor */ - set_scale_factor (&overlay); - - /* contrast factor */ - set_contrast_factor(pXGI, &overlay); - - SetSelectOverlayReg(pXGI, 0x00); - - SetColorkeyReg(pXGI, pPriv->colorKey); - - /* set overlay */ - SetOverlayReg(pXGI, &overlay); - - /* enable overlay */ - SetEnableOverlayReg(pXGI, TRUE); -} - - -static void -XGIStopVideo(ScrnInfoPtr pScrn, pointer data, Bool exit) -{ - XGIPortPrivPtr pPriv = (XGIPortPrivPtr)data; - XGIPtr pXGI = XGIPTR(pScrn); - - REGION_EMPTY(pScrn->pScreen, &pPriv->clip); - - if(exit) { - - if(pPriv->videoStatus & CLIENT_VIDEO_ON) { - SetEnableOverlayReg(pXGI, FALSE); - } - - if (pPriv->videoStatus & CLIENT_CAPTURE_ON) { - EnableCaptureAutoFlip(pXGI, FALSE); - } - - if(pPriv->fbAreaPtr) { - xf86FreeOffscreenArea(pPriv->fbAreaPtr); - pPriv->fbAreaPtr = NULL; - pPriv->fbSize = 0; - } - - - /* clear all flag */ - pPriv->videoStatus = 0; - - } else { - if(pPriv->videoStatus & CLIENT_VIDEO_ON) { - pPriv->videoStatus |= OFF_TIMER; - pPriv->offTime = currentTime.milliseconds + OFF_DELAY; - } - } -} - - -static int -XGIPutImage( - ScrnInfoPtr pScrn, - short src_x, short src_y, - short drw_x, short drw_y, - short src_w, short src_h, - short drw_w, short drw_h, - int id, unsigned char* buf, - short width, short height, - Bool sync, - RegionPtr clipBoxes, pointer data -){ - XGIPtr pXGI = XGIPTR(pScrn); - XGIPortPrivPtr pPriv = (XGIPortPrivPtr)data; - - int i; - - int totalSize=0; -/* int depth = pXGI->CurrentLayout.bitsPerPixel >> 3; */ - - pPriv->drw_x = drw_x; - pPriv->drw_y = drw_y; - pPriv->drw_w = drw_w; - pPriv->drw_h = drw_h; - pPriv->src_x = src_x; - pPriv->src_y = src_y; - pPriv->src_w = src_w; - pPriv->src_h = src_h; - pPriv->id = id; - pPriv->height = height; - - /* Pixel formats: - 1. YU12: 3 planes: H V - Y sample period 1 1 (8 bit per pixel) - V sample period 2 2 (8 bit per pixel, subsampled) - U sample period 2 2 (8 bit per pixel, subsampled) - - Y plane is fully sampled (width*height), U and V planes - are sampled in 2x2 blocks, hence a group of 4 pixels requires - 4 + 1 + 1 = 6 bytes. The data is planar, ie in single planes - for Y, U and V. - 2. UYVY: 3 planes: H V - Y sample period 1 1 (8 bit per pixel) - V sample period 2 1 (8 bit per pixel, subsampled) - U sample period 2 1 (8 bit per pixel, subsampled) - Y plane is fully sampled (width*height), U and V planes - are sampled in 2x1 blocks, hence a group of 4 pixels requires - 4 + 2 + 2 = 8 bytes. The data is bit packed, there are no separate - Y, U or V planes. - Bit order: U0 Y0 V0 Y1 U2 Y2 V2 Y3 ... - 3. I420: Like YU12, but planes U and V are in reverse order. - 4. YUY2: Like UYVY, but order is - Y0 U0 Y1 V0 Y2 U2 Y3 V2 ... - 5. YVYU: Like YUY2, but order is - Y0 V0 Y1 U0 Y2 V2 Y3 U2 ... - */ - switch(id){ - case PIXEL_FMT_YV12: - case PIXEL_FMT_NV12: - case PIXEL_FMT_NV21: - pPriv->srcPitch = (width + 7) & ~7; - totalSize = (pPriv->srcPitch * height * 3) >> 1; /* Verified */ - break; - case PIXEL_FMT_YUY2: - case PIXEL_FMT_UYVY: - case PIXEL_FMT_YVYU: - case PIXEL_FMT_RGB6: - case PIXEL_FMT_RGB5: - default: - pPriv->srcPitch = ((width << 1) + 3) & ~3; /* Verified */ - totalSize = pPriv->srcPitch * height; - } - - /* make it a multiple of 16 to simplify to copy loop */ - totalSize += 15; - totalSize &= ~15; - printf("PutImage\n"); - /* allocate memory */ - do { - int lines, pitch, depth; - BoxPtr pBox; - - if(totalSize == pPriv->fbSize) - break; - - pPriv->fbSize = totalSize; - - if(pPriv->fbAreaPtr) { - xf86FreeOffscreenArea(pPriv->fbAreaPtr); - } - - depth = (pScrn->bitsPerPixel + 7 ) / 8; - pitch = pScrn->displayWidth * depth; - lines = ((totalSize * 2) / pitch) + 1; - - pPriv->fbAreaPtr = xf86AllocateOffscreenArea(pScrn->pScreen, - pScrn->displayWidth, - lines, 0, NULL, NULL, NULL); - - if(!pPriv->fbAreaPtr) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Allocate video memory fails\n"); - return BadAlloc; - } - - pBox = &(pPriv->fbAreaPtr->box); - pPriv->bufAddr[0] = (pBox->x1 * depth) + (pBox->y1 * pitch); - pPriv->bufAddr[1] = pPriv->bufAddr[0] + totalSize; - - } while(0); - - /* copy data */ - if((pXGI->XvUseMemcpy) || (totalSize < 16)) { - #ifdef NewPath - memcpy(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf], buf, totalSize); - - #else - switch(id){ - case PIXEL_FMT_YV12: - { - BYTE *Y, *V, *U, *srcY, *srcV, *srcU; - - short srcPitch2 = pPriv->srcPitch >> 1; - short height2 = height >> 1; - short width2 = width >> 1; - - Y = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - V = Y + pPriv->srcPitch * height; - U = V + pPriv->srcPitch * height / 4 ; - - srcY = buf; - srcV = srcY + width * height; - srcU = srcV + width * height / 4; -#if !defined(__powerpc__) - for(i=0; isrcPitch, srcY + i*width, width); - - for(i=0; idepth == 16)//16 BPP - { - for(i=0; isrcPitch + j+1) = *(unsigned char *)(srcY + i*width + j); - *(unsigned char *)(Y + i * pPriv->srcPitch + j) = *(unsigned char *)(srcY + i*width + j+1); - } - } - - for(i=0; idepth == 24)//32 BPP - { - for(i=0; isrcPitch + j+3) = *(unsigned char *)(srcY + i*width + j); - *(unsigned char *)(Y + i * pPriv->srcPitch + j+2) = *(unsigned char *)(srcY + i*width + j+1); - *(unsigned char *)(Y + i * pPriv->srcPitch + j+1) = *(unsigned char *)(srcY + i*width + j+2); - *(unsigned char *)(Y + i * pPriv->srcPitch + j) = *(unsigned char *)(srcY + i*width + j+3); - } - } - - for(i=0; idepth == 8) - ; - else - ; - -#endif - break; - } - case PIXEL_FMT_NV12: - case PIXEL_FMT_NV21: - { - BYTE *Y, *VU, *srcY, *srcVU; - - short height2 = height >> 1; - - Y = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - VU = Y + pPriv->srcPitch * height; - - srcY = buf; - srcVU = srcY + width * height; -#if !defined(__powerpc__) - - for(i=0; isrcPitch, srcY + i*width, width); - - for(i=0; isrcPitch, srcVU + i*width, width); -#else - if(pScrn->depth == 16)//16 BPP - { - for(i=0; isrcPitch+j) = *(unsigned char *)(srcY + i*width+j+1); - *(unsigned char *)(Y + i * pPriv->srcPitch+j+1) = *(unsigned char *)(srcY + i*width+j); - } - } - - for(i=0; isrcPitch+j) = *(unsigned char *)(srcVU + i*width+j+1); - *(unsigned char *)(VU + i * pPriv->srcPitch+j+1) = *(unsigned char *)(srcVU + i*width+j); - } - } - } - else if(pScrn->depth == 24)//32 BPP - { - for(i=0; isrcPitch+j) = *(unsigned char *)(srcY + i*width+j+3); - *(unsigned char *)(Y + i * pPriv->srcPitch+j+1) = *(unsigned char *)(srcY + i*width+j+2); - *(unsigned char *)(Y + i * pPriv->srcPitch+j+2) = *(unsigned char *)(srcY + i*width+j+1); - *(unsigned char *)(Y + i * pPriv->srcPitch+j+3) = *(unsigned char *)(srcY + i*width+j); - - } - } - - for(i=0; isrcPitch+j) = *(unsigned char *)(srcVU + i*width+j+3); - *(unsigned char *)(VU + i * pPriv->srcPitch+j+1) = *(unsigned char *)(srcVU + i*width+j+2); - *(unsigned char *)(VU + i * pPriv->srcPitch+j+2) = *(unsigned char *)(srcVU + i*width+j+1); - *(unsigned char *)(VU + i * pPriv->srcPitch+j+3) = *(unsigned char *)(srcVU + i*width+j); - - } - } - } - else - ; -#endif - break; - } - case PIXEL_FMT_YUY2: - case PIXEL_FMT_UYVY: - case PIXEL_FMT_YVYU: - case PIXEL_FMT_RGB6: - case PIXEL_FMT_RGB5: - { - BYTE *Base = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - - for(i=0; isrcPitch, buf + i*width*2, width*2); -#else - if(pScrn->depth == 16)//16 BPP - { - int j; - for(j=0; jsrcPitch+j) = *(unsigned char *)(buf+i*width*2+j+1); - *(unsigned char *)(Base+i*pPriv->srcPitch+j+1) = *(unsigned char *)(buf+i*width*2+j); - } - } - else if(pScrn->depth == 24)//24 BPP - { - int j; - for(j=0; jsrcPitch+j) = *(unsigned char *)(buf+i*width*2+j+3); - *(unsigned char *)(Base+i*pPriv->srcPitch+j+1) = *(unsigned char *)(buf+i*width*2+j+2); - *(unsigned char *)(Base+i*pPriv->srcPitch+j+2) = *(unsigned char *)(buf+i*width*2+j+1); - *(unsigned char *)(Base+i*pPriv->srcPitch+j+3) = *(unsigned char *)(buf+i*width*2+j); - - } - } - else - ; -#endif - break; - } - default: - memcpy(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf], buf, totalSize); - break; - } - #endif - - } - else { - - #ifdef NewPath - BYTE *Base = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - ErrorF("else...define NewPath\n"); - for(i=0; isrcPitch >> 1; - short height2 = height >> 1; - short width2 = width >> 1; - int j; - - Y = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - V = Y + pPriv->srcPitch * height; - U = V + pPriv->srcPitch * height / 4 ; - srcY = buf; - srcV = srcY + width * height; - srcU = srcV + width * height / 4; - ErrorF("else...YV12 case\n"); -//#if !defined(__powerpc__) - for(i=0; isrcPitch*i + j); - - for(i=0; isrcPitch + j+1) = *(unsigned char *)(srcY + i*width + j); - *(unsigned char *)(Y + i * pPriv->srcPitch + j) = *(unsigned char *)(srcY + i*width + j+1); - } - } - - for(i=0; i> 1; - - Y = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - VU = Y + pPriv->srcPitch * height; - - srcY = buf; - srcVU = srcY + width * height; - -#if !defined(__powerpc__) - for(i=0; isrcPitch*i + j); - - for(i=0; isrcPitch*i + j); -#else - for(i=0; isrcPitch+j) = *(unsigned char *)(srcY + i*width+j+1); - *(unsigned char *)(Y + i * pPriv->srcPitch+j+1) = *(unsigned char *)(srcY + i*width+j); - } - } - - for(i=0; isrcPitch+j) = *(unsigned char *)(srcVU + i*width+j+1); - *(unsigned char *)(VU + i * pPriv->srcPitch+j+1) = *(unsigned char *)(srcVU + i*width+j); - } - - } -#endif - break; - } - case PIXEL_FMT_YUY2: - case PIXEL_FMT_UYVY: - case PIXEL_FMT_YVYU: - case PIXEL_FMT_RGB6: - case PIXEL_FMT_RGB5: - { - BYTE *Base = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - int j; - ErrorF("else...YUY2 case\n"); -//#if !defined(__powerpc__) - for(i=0; isrcPitch+j) = *(buf + width*i + j); -/*#else - { - for(j=0; jsrcPitch+j) = *(unsigned char *)(buf+i*width*2+j+1); - *(unsigned char *)(Base+i*pPriv->srcPitch+j+1) = *(unsigned char *)(buf+i*width*2+j); - } - } -#endif*/ - break; - } - default: - { - BYTE *Base = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - int j; - for(i=0; ipScreen, &pPriv->clip, clipBoxes)) - { - REGION_COPY(pScrn->pScreen, &pPriv->clip, clipBoxes); - - /* draw these */ - } else { - xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey, clipBoxes); - } /* update cliplist */ - - pPriv->currentBuf ^= 1; - pPriv->videoStatus = CLIENT_VIDEO_ON; - - return Success; -} - - -static int -XGIQueryImageAttributes( - ScrnInfoPtr pScrn, - int id, - unsigned short *w, unsigned short *h, - int *pitches, int *offsets -){ - int pitchY, pitchUV; - int size, sizeY, sizeUV; - - if(*w < IMAGE_MIN_WIDTH) *w = IMAGE_MIN_WIDTH; - if(*h < IMAGE_MIN_HEIGHT) *h = IMAGE_MIN_HEIGHT; - - if(*w > DummyEncoding.width) *w = DummyEncoding.width; - if(*h > DummyEncoding.height) *h = DummyEncoding.height; - - switch(id) { - case PIXEL_FMT_YV12: - *w = (*w + 7) & ~7; - *h = (*h + 1) & ~1; - pitchY = *w; - pitchUV = *w >> 1; - if(pitches) { - pitches[0] = pitchY; - pitches[1] = pitches[2] = pitchUV; - } - sizeY = pitchY * (*h); - sizeUV = pitchUV * ((*h) >> 1); - if(offsets) { - offsets[0] = 0; - offsets[1] = sizeY; - offsets[2] = sizeY + sizeUV; - } - size = sizeY + (sizeUV << 1); - break; - case PIXEL_FMT_NV12: - case PIXEL_FMT_NV21: - *w = (*w + 7) & ~7; - *h = (*h + 1) & ~1; - pitchY = *w; - pitchUV = *w; - if(pitches) { - pitches[0] = pitchY; - pitches[1] = pitchUV; - } - sizeY = pitchY * (*h); - sizeUV = pitchUV * ((*h) >> 1); - if(offsets) { - offsets[0] = 0; - offsets[1] = sizeY; - } - size = sizeY + (sizeUV << 1); - break; - case PIXEL_FMT_YUY2: - case PIXEL_FMT_UYVY: - case PIXEL_FMT_YVYU: - case PIXEL_FMT_RGB6: - case PIXEL_FMT_RGB5: - default: - *w = (*w + 1) & ~1; - pitchY = *w << 1; - if(pitches) pitches[0] = pitchY; - if(offsets) offsets[0] = 0; - size = pitchY * (*h); - break; - } - - return size; -} diff --git a/src/xgi_video1.c b/src/xgi_video1.c deleted file mode 100644 index ef09d82..0000000 --- a/src/xgi_video1.c +++ /dev/null @@ -1,1273 +0,0 @@ -/*************************************************************************** - -Copyright 2004 eXtreme Graphics Innovation Corp, Inc., HsinChu, Taiwan. -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 INTEL, AND/OR ITS SUPPLIERS 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. - -**************************************************************************/ - -/* - * Formerly based on Xv driver for SiS 300, 315 and 330 series by - * Thomas Winischhofer - * - * Basic structure based on the mga Xv driver by Mark Vojkovich - * and i810 Xv driver by Jonathan Bian . - * - * Authors: - * Nan-Hsing Chang - * - * This supports the following chipsets: - * XGI340, XGI342: Full register range, one overlay (used for both CRT1 and CRT2 alt.) - * - */ - -#include "xf86.h" -#include "xf86_OSproc.h" -#include "xf86Resources.h" -#include "compiler.h" -#include "xf86PciInfo.h" -#include "xf86Pci.h" -#include "xf86fbman.h" -#include "regionstr.h" - -#include "xgi.h" -#include "xf86xv.h" -#include -#include "xaa.h" -#include "xaalocal.h" -#include "dixstruct.h" -#include "fourcc.h" - -/* TODO: move to xgi_regs.h */ -#include "xgi_videohw.h" -#include "xgi_video.h" - -static XF86VideoAdaptorPtr XGISetupImageVideo(ScreenPtr); -static int XGISetPortAttribute(ScrnInfoPtr, Atom, INT32, pointer); -static int XGIGetPortAttribute(ScrnInfoPtr, Atom ,INT32 *, pointer); -static void XGIQueryBestSize(ScrnInfoPtr, Bool, - short, short, short, short, unsigned int *, unsigned int *, pointer); -static int XGIPutImage( ScrnInfoPtr, - short, short, short, short, short, short, short, short, - int, unsigned char*, short, short, Bool, RegionPtr, pointer); -static int XGIQueryImageAttributes(ScrnInfoPtr, - int, unsigned short *, unsigned short *, int *, int *); -static void XGIStopVideo(ScrnInfoPtr, pointer, Bool); -/* static void XGIFreeOverlayMemory(ScrnInfoPtr pScrn); */ - -extern void SetSRRegMask(XGIPtr, CARD8, CARD8, CARD8); -extern void XGIUpdateXvGamma(XGIPtr, XGIPortPrivPtr); -#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE) - -void XGIInitVideo(ScreenPtr pScreen) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - XF86VideoAdaptorPtr *adaptors, *newAdaptors = NULL; - XF86VideoAdaptorPtr newAdaptor = NULL; - int num_adaptors; - - newAdaptor = XGISetupImageVideo(pScreen); - - num_adaptors = xf86XVListGenericAdaptors(pScrn, &adaptors); - - if(newAdaptor) { - if(!num_adaptors) { - num_adaptors = 1; - adaptors = &newAdaptor; - } else { - newAdaptors = /* need to free this someplace */ - xalloc((num_adaptors + 1) * sizeof(XF86VideoAdaptorPtr*)); - if(newAdaptors) { - memcpy(newAdaptors, adaptors, num_adaptors * - sizeof(XF86VideoAdaptorPtr)); - newAdaptors[num_adaptors] = newAdaptor; - adaptors = newAdaptors; - num_adaptors++; - } - } - } - - if(num_adaptors) - xf86XVScreenInit(pScreen, adaptors, num_adaptors); - - if(newAdaptors) - xfree(newAdaptors); - -} - - -/* client libraries expect an encoding */ -static XF86VideoEncodingRec DummyEncoding = -{ - 0, - "XV_IMAGE", - 0, 0, /* Will be filled in */ - {1, 1} -}; - -#define NUM_FORMATS 3 - -static XF86VideoFormatRec XGIFormats[NUM_FORMATS] = -{ - { 8, PseudoColor}, - {16, TrueColor}, - {24, TrueColor} -}; - -static char xgixvcolorkey[] = "XV_COLORKEY"; -static char xgixvbrightness[] = "XV_BRIGHTNESS"; -static char xgixvcontrast[] = "XV_CONTRAST"; -static char xgixvsaturation[] = "XV_SATURATION"; -static char xgixvhue[] = "XV_HUE"; -static char xgixvgammared[] = "XV_GAMMA_RED"; -static char xgixvgammagreen[] = "XV_GAMMA_GREEN"; -static char xgixvgammablue[] = "XV_GAMMA_BLUE"; - -#define NUM_ATTRIBUTES 8 - -static XF86AttributeRec XGIAttributes[NUM_ATTRIBUTES] = -{ - {XvSettable | XvGettable, 0, (1 << 24) - 1, xgixvcolorkey}, - {XvSettable | XvGettable, -128, 127, xgixvbrightness}, - {XvSettable | XvGettable, 0, 255, xgixvcontrast}, - {XvSettable | XvGettable, -180, 180, xgixvsaturation}, - {XvSettable | XvGettable, -180, 180, xgixvhue}, - {XvSettable | XvGettable, 100, 10000, xgixvgammared}, - {XvSettable | XvGettable, 100, 10000, xgixvgammagreen}, - {XvSettable | XvGettable, 100, 10000, xgixvgammablue}, -}; - -#define NUM_IMAGES 8 - -static XF86ImageRec XGIImages[NUM_IMAGES] = - { - XVIMAGE_YUY2, /* If order is changed, XGIOffscreenImages must be adapted */ - XVIMAGE_YV12, - XVIMAGE_UYVY, - { /* RGB 555 */ - PIXEL_FMT_RGB5, - XvRGB, - LSBFirst, - {'R','V','1','5', - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - 16, - XvPacked, - 1, - 15, 0x7C00, 0x03E0, 0x001F, - 0, 0, 0, - 0, 0, 0, - 0, 0, 0, - {'R', 'V', 'B',0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - XvTopToBottom - }, - { /* RGB 565 */ - PIXEL_FMT_RGB6, - XvRGB, - LSBFirst, - {'R','V','1','6', - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - 16, - XvPacked, - 1, - 16, 0xF800, 0x07E0, 0x001F, - 0, 0, 0, - 0, 0, 0, - 0, 0, 0, - {'R', 'V', 'B',0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - XvTopToBottom - }, - { /* YVYU */ - PIXEL_FMT_YVYU, \ - XvYUV, \ - LSBFirst, \ - {'Y','V','Y','U', - 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, - 16, - XvPacked, - 1, - 0, 0, 0, 0 , - 8, 8, 8, - 1, 2, 2, - 1, 1, 1, - {'Y','V','Y','U', - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - XvTopToBottom - }, - { /* NV12 */ - PIXEL_FMT_NV12, - XvYUV, - LSBFirst, - {'N','V','1','2', - 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, - 12, - XvPlanar, - 2, - 0, 0, 0, 0 , - 8, 8, 8, - 1, 2, 2, - 1, 2, 2, - {'Y','U','V',0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - XvTopToBottom - }, - { /* NV21 */ - PIXEL_FMT_NV21, - XvYUV, - LSBFirst, - {'N','V','2','1', - 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, - 12, - XvPlanar, - 2, - 0, 0, 0, 0, - 8, 8, 8, - 1, 2, 2, - 1, 2, 2, - {'Y','V','U',0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - XvTopToBottom - }, -}; - -static void -set_maxencoding(XGIPtr pXGI, XGIPortPrivPtr pPriv) -{ - DummyEncoding.width = IMAGE_MAX_WIDTH; - DummyEncoding.height = IMAGE_MAX_HEIGHT; -} - -static void -XGIResetXvGamma(ScrnInfoPtr pScrn) -{ - XGIPtr pXGI = XGIPTR(pScrn); - XGIPortPrivPtr pPriv = GET_PORT_PRIVATE(pScrn); - - XGIUpdateXvGamma(pXGI, pPriv); -} - -static void -XGISetPortDefaults(ScrnInfoPtr pScrn, XGIPortPrivPtr pPriv) -{ - pPriv->colorKey = 0x000101fe; - pPriv->brightness = 0; - pPriv->contrast = 128; - pPriv->saturation = 0; - pPriv->hue = 0; -} - -static XF86VideoAdaptorPtr -XGISetupImageVideo(ScreenPtr pScreen) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - XGIPtr pXGI = XGIPTR(pScrn); - XF86VideoAdaptorPtr adapt; - XGIPortPrivPtr pPriv; - - if(!(adapt = xcalloc(1, sizeof(XF86VideoAdaptorRec) + - sizeof(XGIPortPrivRec) + - sizeof(DevUnion)))) - return NULL; - - adapt->type = XvWindowMask | XvInputMask | XvImageMask; - adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; - /*adapt->name = "XGI Video Overlay"; */ - adapt->name = "XGI Video"; - adapt->nEncodings = 1; - adapt->pEncodings = &DummyEncoding; - adapt->nFormats = NUM_FORMATS; - adapt->pFormats = XGIFormats; - adapt->nPorts = 1; - adapt->pPortPrivates = (DevUnion*)(&adapt[1]); - - pPriv = (XGIPortPrivPtr)(&adapt->pPortPrivates[1]); - - adapt->pPortPrivates[0].ptr = (pointer)(pPriv); - adapt->pAttributes = XGIAttributes; - adapt->nAttributes = NUM_ATTRIBUTES; - adapt->nImages = NUM_IMAGES; - adapt->pImages = XGIImages; - adapt->PutVideo = NULL; - adapt->PutStill = NULL; - adapt->GetVideo = NULL; - adapt->GetStill = NULL; - adapt->StopVideo = XGIStopVideo; - adapt->SetPortAttribute = XGISetPortAttribute; - adapt->GetPortAttribute = XGIGetPortAttribute; - adapt->QueryBestSize = XGIQueryBestSize; - adapt->PutImage = XGIPutImage; - adapt->QueryImageAttributes = XGIQueryImageAttributes; - - pPriv->currentBuf = 0; - pPriv->linear = NULL; - pPriv->fbAreaPtr = NULL; - pPriv->fbSize = 0; - pPriv->videoStatus = 0; - pPriv->linebufMergeLimit = 1280; - - /* gotta uninit this someplace */ -#if defined(REGION_NULL) - REGION_NULL(pScreen, &pPriv->clip); -#else - REGION_INIT(pScreen, &pPriv->clip, NullBox, 0); -#endif - - /* Reset the properties to their defaults */ - XGISetPortDefaults(pScrn, pPriv); - - pXGI->adaptor = adapt; - pXGI->xvBrightness = MAKE_ATOM(xgixvbrightness); - pXGI->xvContrast = MAKE_ATOM(xgixvcontrast); - pXGI->xvColorKey = MAKE_ATOM(xgixvcolorkey); - pXGI->xvSaturation = MAKE_ATOM(xgixvsaturation); - pXGI->xvHue = MAKE_ATOM(xgixvhue); - pXGI->xvGammaRed = MAKE_ATOM(xgixvgammared); - pXGI->xvGammaGreen = MAKE_ATOM(xgixvgammagreen); - pXGI->xvGammaBlue = MAKE_ATOM(xgixvgammablue); - - /* set display register */ - if(pXGI->VBFlags) { - pPriv->displayMode = DISPMODE_MIRROR; - SetSRRegMask(pXGI, Index_SR_Graphic_Mode, 0x00, 0xc0); /* Only ovelray in CRT1*/ - SetSRRegMask(pXGI, Index_SR_Ext_Clock_Sel, 0x00, 0xc0); - } - else { - pPriv->displayMode = DISPMODE_SINGLE1; - SetSRRegMask(pXGI, Index_SR_Graphic_Mode, 0x00, 0xc0); - SetSRRegMask(pXGI, Index_SR_Ext_Clock_Sel, 0x00, 0xc0); - } - - set_maxencoding(pXGI, pPriv); - - XGIResetVideo(pScrn); - - pXGI->ResetXv = XGIResetVideo; - pXGI->ResetXvGamma = XGIResetXvGamma; - - return adapt; -} - - -static int -XGISetPortAttribute( - ScrnInfoPtr pScrn, - Atom attribute, - INT32 value, - pointer data -){ - XGIPortPrivPtr pPriv = (XGIPortPrivPtr)data; - XGIPtr pXGI = XGIPTR(pScrn); - - if (attribute == pXGI->xvBrightness) { - if((value < -128) || (value > 127)) - return BadValue; - - pPriv->brightness = value; - SetVideoBrightnessReg(pXGI, value); - } - else if (attribute == pXGI->xvContrast) { - if ((value < 0) || (value > 255)) - return BadValue; - - pPriv->contrast = value; - SetVideoContrastReg(pXGI, value); - } - else if (attribute == pXGI->xvSaturation){ - if ((value < -180) || (value > 180)) - return BadValue; - - pPriv->saturation = value; - SetVideoSaturationReg(pXGI, value); - } - else if (attribute == pXGI->xvHue){ - if ((value < -180) || (value > 180)) - return BadValue; - - pPriv->hue = value; - SetVideoHueReg(pXGI, value); - } - else if (attribute == pXGI->xvColorKey) { - pPriv->colorKey = value; - REGION_EMPTY(pScrn->pScreen, &pPriv->clip); - } else if(attribute == pXGI->xvGammaRed) { - if((value < 100) || (value > 10000)) - return BadValue; - - pXGI->XvGammaRed = value; - XGIUpdateXvGamma(pXGI, pPriv); - } else if(attribute == pXGI->xvGammaGreen) { - if((value < 100) || (value > 10000)) - return BadValue; - - pXGI->XvGammaGreen = value; - XGIUpdateXvGamma(pXGI, pPriv); - } else if(attribute == pXGI->xvGammaBlue) { - if((value < 100) || (value > 10000)) - return BadValue; - - pXGI->XvGammaBlue = value; - XGIUpdateXvGamma(pXGI, pPriv); - } else - return BadMatch; - - return Success; -} - -static int -XGIGetPortAttribute( - ScrnInfoPtr pScrn, - Atom attribute, - INT32 *value, - pointer data -){ - XGIPortPrivPtr pPriv = (XGIPortPrivPtr)data; - XGIPtr pXGI = XGIPTR(pScrn); - - if (attribute == pXGI->xvBrightness) { - *value = pPriv->brightness; - } - else if (attribute == pXGI->xvContrast) { - *value = pPriv->contrast; - } - else if (attribute == pXGI->xvSaturation) { - *value = pPriv->saturation; - } - else if (attribute == pXGI->xvHue) { - *value = pPriv->hue; - - } else if(attribute == pXGI->xvGammaRed) { - *value = pXGI->XvGammaRed; - - } else if(attribute == pXGI->xvGammaGreen) { - *value = pXGI->XvGammaGreen; - - } else if(attribute == pXGI->xvGammaBlue) { - *value = pXGI->XvGammaBlue; - - } - else if (attribute == pXGI->xvColorKey) { - *value = pPriv->colorKey; - - } - else - return BadMatch; - - return Success; -} - -static void -XGIQueryBestSize( - ScrnInfoPtr pScrn, - Bool motion, - short vid_w, short vid_h, - short drw_w, short drw_h, - unsigned int *p_w, unsigned int *p_h, - pointer data -){ - *p_w = drw_w; - *p_h = drw_h; - - /* TODO: report the HW limitation */ -} - - -void -set_scale_factor(XGIOverlayPtr pOverlay) -{ - float f_temp; - int NewPitch, srcPitch; - - CARD32 I=0; - - int dstW = pOverlay->dstBox.x2 - pOverlay->dstBox.x1; - int dstH = pOverlay->dstBox.y2 - pOverlay->dstBox.y1; - int srcW = pOverlay->srcW; - int srcH = pOverlay->srcH; - - NewPitch = srcPitch = pOverlay->pitch; - - /*Set 1 as default, because we don't need change 4-tap DDA scale value in the upscale case*/ - pOverlay->f_scale = 1.0; - - if (dstW == srcW) { - pOverlay->HUSF = 0x00; - pOverlay->IntBit = 0x05; - } - else if (dstW > srcW) { - - /*pOverlay->HUSF = (srcW << 16) / dstW; */ - - if ((dstW > 2) && (srcW > 2)) { - pOverlay->HUSF = (((srcW - 2) << 16) + dstW - 3) / (dstW - 2); - } - else { - pOverlay->HUSF = ((srcW << 16) + dstW - 1) / dstW; - } - pOverlay->IntBit = 0x04; - } - /* downscale in horizontal */ - else { - - int tmpW = dstW; - - I = 0x00; - - pOverlay->IntBit = 0x01; - - /* */ - while (srcW >= tmpW) - { - tmpW <<= 1; - I++; - } - - pOverlay->wHPre = (CARD8)(I - 1); - dstW <<= (I - 1); - - f_temp = srcW/dstW; - - /* we don't need to change 4-tap DDA scale if upscale */ - if (f_temp < 1.0) - f_temp = 1.0; - - pOverlay->f_scale = f_temp; - - if ((srcW % dstW)) - pOverlay->HUSF = ((srcW - dstW) << 16) / dstW; - else - pOverlay->HUSF = 0x00; - } - - if (dstH == srcH) { - pOverlay->VUSF = 0x00; - pOverlay->IntBit |= 0x0A; - } - else if (dstH > srcH) { - dstH += 0x02; - /*pOverlay->VUSF = (srcH << 16) / dstH;*/ - if ((dstH > 2) && (srcH > 2)) { - pOverlay->VUSF = (((srcH - 2) << 16) - 32768 + dstH - 3) / (dstH - 2); - } - else { - pOverlay->VUSF = ((srcH << 16) + dstH - 1) / dstH; - } - - pOverlay->IntBit |= 0x08; - } - /* downscale in vertical */ - else { - - CARD32 realI; - - I = realI = srcH / dstH; - pOverlay->IntBit |= 0x02; - - if (I < 2) - { - pOverlay->VUSF = ((srcH - dstH)<<16)/dstH; - } - else - { - if (((srcPitch * I)>>2) > 0xFFF) - { - I = (0xFFF*2/srcPitch); - pOverlay->VUSF = 0xFFFF; - } - else - { - dstH = I * dstH; - - if (srcH % dstH) - pOverlay->VUSF = ((srcH - dstH) << 16) / dstH; - else - pOverlay->VUSF = 0x00; - } - - /* set video frame buffer offset */ - NewPitch = (srcPitch*I); - } - } - - pOverlay->pitch = (CARD16)(NewPitch); - } - -void -set_contrast_factor(XGIPtr pXGI, XGIOverlayPtr pOverlay) -{ - ScrnInfoPtr pScrn = pXGI->pScrn; - CARD16 screenX = pScrn->currentMode->HDisplay; - CARD16 screenY = pScrn->currentMode->VDisplay; - - CARD32 value, SamplePixel, dwTotalPixel; - - CARD16 top, left; - CARD16 bottom, right; - - top = pOverlay->dstBox.y1; - bottom = pOverlay->dstBox.y2; - - if (bottom > screenY) - bottom = screenY; - - left = pOverlay->dstBox.x1; - right = pOverlay->dstBox.x2; - - if (right > screenX) - right = screenX; - - dwTotalPixel = (bottom - top) * (right - left); - - value = (dwTotalPixel - 10000) / 20000; - - if (value > 3 ) - value = 3; - - pOverlay->dwContrastFactor = value; - - switch (value) { - case 1: SamplePixel = 4096; break; - case 2: SamplePixel = 8192; break; - case 3: SamplePixel = 8192; break; - - default: - SamplePixel = 2048; - break; - } - - pOverlay->SamplePixel = (SamplePixel << 10) / dwTotalPixel; - -} - -static void -set_line_buf_size(XGIOverlayPtr pOverlay) -{ - CARD8 preHIDF; - CARD32 dwI; - CARD32 dwSrcWidth = pOverlay->srcW; - int pixelFormat = pOverlay->pixelFormat; - - if ((pixelFormat == PIXEL_FMT_YV12) || - (pixelFormat == PIXEL_FMT_NV12) || - (pixelFormat == PIXEL_FMT_NV21)) - { - preHIDF = pOverlay->wHPre & 0x07; - - if (preHIDF < 2) - { - preHIDF = 2; - } - - if (dwSrcWidth & ~(0xffffff80 << (preHIDF - 2))) - { - dwI = (dwSrcWidth >> (preHIDF + 5)) + 1; - } - else - { - dwI = dwSrcWidth >> (preHIDF + 5); - } - - pOverlay->lineBufSize = dwI * (0x01 << (preHIDF + 2)) - 1; - - } - /* not plane format */ - else - { - if (dwSrcWidth & 0x07) - dwI = (dwSrcWidth >> 3) + 1; - else - dwI = (dwSrcWidth >> 3); - - pOverlay->lineBufSize = dwI; - } -} - -static void -XGIDisplayVideo(ScrnInfoPtr pScrn, XGIPortPrivPtr pPriv) -{ - XGIPtr pXGI = XGIPTR(pScrn); - - short srcPitch = pPriv->srcPitch; - short height = pPriv->height; - XGIOverlayRec overlay; - int srcOffsetX=0, srcOffsetY=0; - int sx=0, sy=0; - - memset(&overlay, 0, sizeof(overlay)); - overlay.pixelFormat = pPriv->id; - overlay.pitch = srcPitch; - overlay.keyOP = 0x03; /* destination colorkey */ - overlay.bobEnable = 0x00; - - overlay.dstBox.x1 = pPriv->drw_x - pScrn->frameX0; - overlay.dstBox.x2 = pPriv->drw_x + pPriv->drw_w - pScrn->frameX0; - overlay.dstBox.y1 = pPriv->drw_y - pScrn->frameY0; - overlay.dstBox.y2 = pPriv->drw_y + pPriv->drw_h - pScrn->frameY0; - - if((overlay.dstBox.x2 < 0) || (overlay.dstBox.y2 < 0)) - return; - - if(overlay.dstBox.x1 < 0) { - srcOffsetX = pPriv->src_w * (-overlay.dstBox.x1) / pPriv->drw_w; - overlay.dstBox.x1 = 0; - } - if(overlay.dstBox.y1 < 0) { - srcOffsetY = pPriv->src_h * (-overlay.dstBox.y1) / pPriv->drw_h; - overlay.dstBox.y1 = 0; - } - - if (pPriv->videoStatus & CLIENT_CAPTURE_ON) - { - /* We use AutoFlip for capture, not need buffer address */ - overlay.PSY = 0x0000; - } - else - { - switch(pPriv->id){ - case PIXEL_FMT_YV12: - sx = (pPriv->src_x + srcOffsetX) & ~7; - sy = (pPriv->src_y + srcOffsetY) & ~1; - - overlay.PSY = pPriv->bufAddr[pPriv->currentBuf] + sx + sy*srcPitch; - overlay.PSV = pPriv->bufAddr[pPriv->currentBuf] + height*srcPitch + ((sx + sy*srcPitch/2) >> 1); - overlay.PSU = pPriv->bufAddr[pPriv->currentBuf] + height*srcPitch*5/4 + ((sx + sy*srcPitch/2) >> 1); - break; - - case PIXEL_FMT_NV12: - case PIXEL_FMT_NV21: - sx = (pPriv->src_x + srcOffsetX) & ~7; - sy = (pPriv->src_y + srcOffsetY) & ~1; - overlay.PSY = pPriv->bufAddr[pPriv->currentBuf] + sx + sy*srcPitch; - overlay.PSV = pPriv->bufAddr[pPriv->currentBuf] + height*srcPitch + ((sx + sy*srcPitch/2) >> 1); - overlay.PSU = overlay.PSV; - break; - - case PIXEL_FMT_YUY2: - case PIXEL_FMT_UYVY: - case PIXEL_FMT_YVYU: - case PIXEL_FMT_RGB6: - case PIXEL_FMT_RGB5: - sx = (pPriv->src_x + srcOffsetX) & ~1; - sy = (pPriv->src_y + srcOffsetY); - - overlay.PSY = pPriv->bufAddr[pPriv->currentBuf] + sx*2 + sy*srcPitch; - break; - - default: - /* ErrorF("UnSurpported Format"); */ - break; - } - - } - - overlay.srcW = pPriv->src_w - (sx - pPriv->src_x); - overlay.srcH = pPriv->src_h - (sy - pPriv->src_y); - - /* set line buffer length */ - set_line_buf_size (&overlay); - - /* set scale factor */ - set_scale_factor (&overlay); - - /* contrast factor */ - set_contrast_factor(pXGI, &overlay); - - SetSelectOverlayReg(pXGI, 0x00); - - SetColorkeyReg(pXGI, pPriv->colorKey); - - /* set overlay */ - SetOverlayReg(pXGI, &overlay); - - /* enable overlay */ - SetEnableOverlayReg(pXGI, TRUE); -} - - -static void -XGIStopVideo(ScrnInfoPtr pScrn, pointer data, Bool exit) -{ - XGIPortPrivPtr pPriv = (XGIPortPrivPtr)data; - XGIPtr pXGI = XGIPTR(pScrn); - - REGION_EMPTY(pScrn->pScreen, &pPriv->clip); - - if(exit) { - - if(pPriv->videoStatus & CLIENT_VIDEO_ON) { - SetEnableOverlayReg(pXGI, FALSE); - } - - if (pPriv->videoStatus & CLIENT_CAPTURE_ON) { - EnableCaptureAutoFlip(pXGI, FALSE); - } - - if(pPriv->fbAreaPtr) { - xf86FreeOffscreenArea(pPriv->fbAreaPtr); - pPriv->fbAreaPtr = NULL; - pPriv->fbSize = 0; - } - - - /* clear all flag */ - pPriv->videoStatus = 0; - - } else { - if(pPriv->videoStatus & CLIENT_VIDEO_ON) { - pPriv->videoStatus |= OFF_TIMER; - pPriv->offTime = currentTime.milliseconds + OFF_DELAY; - } - } -} - - -static int -XGIPutImage( - ScrnInfoPtr pScrn, - short src_x, short src_y, - short drw_x, short drw_y, - short src_w, short src_h, - short drw_w, short drw_h, - int id, unsigned char* buf, - short width, short height, - Bool sync, - RegionPtr clipBoxes, pointer data -){ - XGIPtr pXGI = XGIPTR(pScrn); - XGIPortPrivPtr pPriv = (XGIPortPrivPtr)data; - - int i; - - int totalSize=0; -/* int depth = pXGI->CurrentLayout.bitsPerPixel >> 3; */ - - pPriv->drw_x = drw_x; - pPriv->drw_y = drw_y; - pPriv->drw_w = drw_w; - pPriv->drw_h = drw_h; - pPriv->src_x = src_x; - pPriv->src_y = src_y; - pPriv->src_w = src_w; - pPriv->src_h = src_h; - pPriv->id = id; - pPriv->height = height; - - /* Pixel formats: - 1. YU12: 3 planes: H V - Y sample period 1 1 (8 bit per pixel) - V sample period 2 2 (8 bit per pixel, subsampled) - U sample period 2 2 (8 bit per pixel, subsampled) - - Y plane is fully sampled (width*height), U and V planes - are sampled in 2x2 blocks, hence a group of 4 pixels requires - 4 + 1 + 1 = 6 bytes. The data is planar, ie in single planes - for Y, U and V. - 2. UYVY: 3 planes: H V - Y sample period 1 1 (8 bit per pixel) - V sample period 2 1 (8 bit per pixel, subsampled) - U sample period 2 1 (8 bit per pixel, subsampled) - Y plane is fully sampled (width*height), U and V planes - are sampled in 2x1 blocks, hence a group of 4 pixels requires - 4 + 2 + 2 = 8 bytes. The data is bit packed, there are no separate - Y, U or V planes. - Bit order: U0 Y0 V0 Y1 U2 Y2 V2 Y3 ... - 3. I420: Like YU12, but planes U and V are in reverse order. - 4. YUY2: Like UYVY, but order is - Y0 U0 Y1 V0 Y2 U2 Y3 V2 ... - 5. YVYU: Like YUY2, but order is - Y0 V0 Y1 U0 Y2 V2 Y3 U2 ... - */ - switch(id){ - case PIXEL_FMT_YV12: - case PIXEL_FMT_NV12: - case PIXEL_FMT_NV21: - pPriv->srcPitch = (width + 7) & ~7; - totalSize = (pPriv->srcPitch * height * 3) >> 1; /* Verified */ - break; - case PIXEL_FMT_YUY2: - case PIXEL_FMT_UYVY: - case PIXEL_FMT_YVYU: - case PIXEL_FMT_RGB6: - case PIXEL_FMT_RGB5: - default: - pPriv->srcPitch = ((width << 1) + 3) & ~3; /* Verified */ - totalSize = pPriv->srcPitch * height; - } - - /* make it a multiple of 16 to simplify to copy loop */ - totalSize += 15; - totalSize &= ~15; - printf("PutImage\n"); - /* allocate memory */ - do { - int lines, pitch, depth; - BoxPtr pBox; - - if(totalSize == pPriv->fbSize) - break; - - pPriv->fbSize = totalSize; - - if(pPriv->fbAreaPtr) { - xf86FreeOffscreenArea(pPriv->fbAreaPtr); - } - - depth = (pScrn->bitsPerPixel + 7 ) / 8; - pitch = pScrn->displayWidth * depth; - lines = ((totalSize * 2) / pitch) + 1; - - pPriv->fbAreaPtr = xf86AllocateOffscreenArea(pScrn->pScreen, - pScrn->displayWidth, - lines, 0, NULL, NULL, NULL); - - if(!pPriv->fbAreaPtr) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Allocate video memory fails\n"); - return BadAlloc; - } - - pBox = &(pPriv->fbAreaPtr->box); - pPriv->bufAddr[0] = (pBox->x1 * depth) + (pBox->y1 * pitch); - pPriv->bufAddr[1] = pPriv->bufAddr[0] + totalSize; - - } while(0); - - /* copy data */ - if((pXGI->XvUseMemcpy) || (totalSize < 16)) { - #ifdef NewPath - memcpy(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf], buf, totalSize); - - #else - switch(id){ - case PIXEL_FMT_YV12: - { - BYTE *Y, *V, *U, *srcY, *srcV, *srcU; - - short srcPitch2 = pPriv->srcPitch >> 1; - short height2 = height >> 1; - short width2 = width >> 1; - - Y = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - V = Y + pPriv->srcPitch * height; - U = V + pPriv->srcPitch * height / 4 ; - - srcY = buf; - srcV = srcY + width * height; - srcU = srcV + width * height / 4; -#if !defined(__powerpc__) - for(i=0; isrcPitch, srcY + i*width, width); - - for(i=0; isrcPitch + j+1) = *(unsigned char *)(srcY + i*width + j); - *(unsigned char *)(Y + i * pPriv->srcPitch + j) = *(unsigned char *)(srcY + i*width + j+1); - } - } - - for(i=0; i> 1; - - Y = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - VU = Y + pPriv->srcPitch * height; - - srcY = buf; - srcVU = srcY + width * height; -#if !defined(__powerpc__) - - for(i=0; isrcPitch, srcY + i*width, width); - - for(i=0; isrcPitch, srcVU + i*width, width); -#else - for(i=0; isrcPitch+j) = *(unsigned char *)(srcY + i*width+j+1); - *(unsigned char *)(Y + i * pPriv->srcPitch+j+1) = *(unsigned char *)(srcY + i*width+j); - - } - - - } - - for(i=0; isrcPitch+j) = *(unsigned char *)(srcY + i*width+j+1); *(unsigned char *)(Y + i * pPriv->srcPitch+j+1) = *(unsigned char *)(srcY + i*width+j); } - - - - } - -#endif - break; - } - case PIXEL_FMT_YUY2: - case PIXEL_FMT_UYVY: - case PIXEL_FMT_YVYU: - case PIXEL_FMT_RGB6: - case PIXEL_FMT_RGB5: - { - BYTE *Base = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - - for(i=0; isrcPitch, buf + i*width*2, width*2); -#else - { - int j; - for(j=0; jsrcPitch+j) = *(unsigned char *)(buf+i*width*2+j+1); -*(unsigned char *)(Base+i*pPriv->srcPitch+j+1) = *(unsigned char *)(buf+i*width*2+j); - -/* - if(i==0 &&j<50) - ErrorF("IMAGE[%x]=%x ",j,*(buf+i*width*2+j)); - if(i==0 && j<=50 && (j%5==0)) - ErrorF("\n"); -*/ - } - } -#endif - break; - } - default: - memcpy(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf], buf, totalSize); - break; - } - #endif - - } else { - - #ifdef NewPath - BYTE *Base = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - - for(i=0; isrcPitch >> 1; - short height2 = height >> 1; - short width2 = width >> 1; - int j; - - Y = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - V = Y + pPriv->srcPitch * height; - U = V + pPriv->srcPitch * height / 4 ; - srcY = buf; - srcV = srcY + width * height; - srcU = srcV + width * height / 4; - - for(i=0; isrcPitch*i + j); - - for(i=0; i> 1; - - Y = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - VU = Y + pPriv->srcPitch * height; - - srcY = buf; - srcVU = srcY + width * height; - - for(i=0; isrcPitch*i + j); - - for(i=0; isrcPitch*i + j); - - break; - } - case PIXEL_FMT_YUY2: - case PIXEL_FMT_UYVY: - case PIXEL_FMT_YVYU: - case PIXEL_FMT_RGB6: - case PIXEL_FMT_RGB5: - { - BYTE *Base = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - int j; - for(i=0; isrcPitch+j) = *(buf + width*i + j); - - break; - } - default: - { - BYTE *Base = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - int j; - for(i=0; ipScreen, &pPriv->clip, clipBoxes)) - { - REGION_COPY(pScrn->pScreen, &pPriv->clip, clipBoxes); - - /* draw these */ - } else { - xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey, clipBoxes); - } /* update cliplist */ - - pPriv->currentBuf ^= 1; - pPriv->videoStatus = CLIENT_VIDEO_ON; - - return Success; -} - - -static int -XGIQueryImageAttributes( - ScrnInfoPtr pScrn, - int id, - unsigned short *w, unsigned short *h, - int *pitches, int *offsets -){ - int pitchY, pitchUV; - int size, sizeY, sizeUV; - - if(*w < IMAGE_MIN_WIDTH) *w = IMAGE_MIN_WIDTH; - if(*h < IMAGE_MIN_HEIGHT) *h = IMAGE_MIN_HEIGHT; - - if(*w > DummyEncoding.width) *w = DummyEncoding.width; - if(*h > DummyEncoding.height) *h = DummyEncoding.height; - - switch(id) { - case PIXEL_FMT_YV12: - *w = (*w + 7) & ~7; - *h = (*h + 1) & ~1; - pitchY = *w; - pitchUV = *w >> 1; - if(pitches) { - pitches[0] = pitchY; - pitches[1] = pitches[2] = pitchUV; - } - sizeY = pitchY * (*h); - sizeUV = pitchUV * ((*h) >> 1); - if(offsets) { - offsets[0] = 0; - offsets[1] = sizeY; - offsets[2] = sizeY + sizeUV; - } - size = sizeY + (sizeUV << 1); - break; - case PIXEL_FMT_NV12: - case PIXEL_FMT_NV21: - *w = (*w + 7) & ~7; - *h = (*h + 1) & ~1; - pitchY = *w; - pitchUV = *w; - if(pitches) { - pitches[0] = pitchY; - pitches[1] = pitchUV; - } - sizeY = pitchY * (*h); - sizeUV = pitchUV * ((*h) >> 1); - if(offsets) { - offsets[0] = 0; - offsets[1] = sizeY; - } - size = sizeY + (sizeUV << 1); - break; - case PIXEL_FMT_YUY2: - case PIXEL_FMT_UYVY: - case PIXEL_FMT_YVYU: - case PIXEL_FMT_RGB6: - case PIXEL_FMT_RGB5: - default: - *w = (*w + 1) & ~1; - pitchY = *w << 1; - if(pitches) pitches[0] = pitchY; - if(offsets) offsets[0] = 0; - size = pitchY * (*h); - break; - } - - return size; -} diff --git a/src/xgi_video_11.c b/src/xgi_video_11.c deleted file mode 100644 index a9c9a50..0000000 --- a/src/xgi_video_11.c +++ /dev/null @@ -1,1529 +0,0 @@ -/*************************************************************************** - -Copyright 2004 eXtreme Graphics Innovation Corp, Inc., HsinChu, Taiwan. -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 INTEL, AND/OR ITS SUPPLIERS 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. - -**************************************************************************/ - -/* - * Formerly based on Xv driver for SiS 300, 315 and 330 series by - * Thomas Winischhofer - * - * Basic structure based on the mga Xv driver by Mark Vojkovich - * and i810 Xv driver by Jonathan Bian . - * - * Authors: - * Nan-Hsing Chang - * - * This supports the following chipsets: - * XGI340, XGI342: Full register range, one overlay (used for both CRT1 and CRT2 alt.) - * - */ - -#include "xf86.h" -#include "xf86_OSproc.h" -#include "xf86Resources.h" -#include "compiler.h" -#include "xf86PciInfo.h" -#include "xf86Pci.h" -#include "xf86fbman.h" -#include "regionstr.h" - -#include "xgi.h" -#include "xf86xv.h" -#include -#include "xaa.h" -#include "xaalocal.h" -#include "dixstruct.h" -#include "fourcc.h" - -/* TODO: move to xgi_regs.h */ -#include "xgi_videohw.h" -#include "xgi_video.h" - -static XF86VideoAdaptorPtr XGISetupImageVideo(ScreenPtr); -static int XGISetPortAttribute(ScrnInfoPtr, Atom, INT32, pointer); -static int XGIGetPortAttribute(ScrnInfoPtr, Atom ,INT32 *, pointer); -static void XGIQueryBestSize(ScrnInfoPtr, Bool, - short, short, short, short, unsigned int *, unsigned int *, pointer); -static int XGIPutImage( ScrnInfoPtr, - short, short, short, short, short, short, short, short, - int, unsigned char*, short, short, Bool, RegionPtr, pointer); -static int XGIQueryImageAttributes(ScrnInfoPtr, - int, unsigned short *, unsigned short *, int *, int *); -static void XGIStopVideo(ScrnInfoPtr, pointer, Bool); -/* static void XGIFreeOverlayMemory(ScrnInfoPtr pScrn); */ - -extern void SetSRRegMask(XGIPtr, CARD8, CARD8, CARD8); -extern void XGIUpdateXvGamma(XGIPtr, XGIPortPrivPtr); -#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE) - -void XGIInitVideo(ScreenPtr pScreen) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - XF86VideoAdaptorPtr *adaptors, *newAdaptors = NULL; - XF86VideoAdaptorPtr newAdaptor = NULL; - int num_adaptors; - - newAdaptor = XGISetupImageVideo(pScreen); - - num_adaptors = xf86XVListGenericAdaptors(pScrn, &adaptors); - - if(newAdaptor) { - if(!num_adaptors) { - num_adaptors = 1; - adaptors = &newAdaptor; - } else { - newAdaptors = /* need to free this someplace */ - xalloc((num_adaptors + 1) * sizeof(XF86VideoAdaptorPtr*)); - if(newAdaptors) { - memcpy(newAdaptors, adaptors, num_adaptors * - sizeof(XF86VideoAdaptorPtr)); - newAdaptors[num_adaptors] = newAdaptor; - adaptors = newAdaptors; - num_adaptors++; - } - } - } - - if(num_adaptors) - xf86XVScreenInit(pScreen, adaptors, num_adaptors); - - if(newAdaptors) - xfree(newAdaptors); - -} - - -/* client libraries expect an encoding */ -static XF86VideoEncodingRec DummyEncoding = -{ - 0, - "XV_IMAGE", - 0, 0, /* Will be filled in */ - {1, 1} -}; - -#define NUM_FORMATS 3 - -static XF86VideoFormatRec XGIFormats[NUM_FORMATS] = -{ - { 8, PseudoColor}, - {16, TrueColor}, - {24, TrueColor} -}; - -static char xgixvcolorkey[] = "XV_COLORKEY"; -static char xgixvbrightness[] = "XV_BRIGHTNESS"; -static char xgixvcontrast[] = "XV_CONTRAST"; -static char xgixvsaturation[] = "XV_SATURATION"; -static char xgixvhue[] = "XV_HUE"; -static char xgixvgammared[] = "XV_GAMMA_RED"; -static char xgixvgammagreen[] = "XV_GAMMA_GREEN"; -static char xgixvgammablue[] = "XV_GAMMA_BLUE"; - -#define NUM_ATTRIBUTES 8 - -static XF86AttributeRec XGIAttributes[NUM_ATTRIBUTES] = -{ - {XvSettable | XvGettable, 0, (1 << 24) - 1, xgixvcolorkey}, - {XvSettable | XvGettable, -128, 127, xgixvbrightness}, - {XvSettable | XvGettable, 0, 255, xgixvcontrast}, - {XvSettable | XvGettable, -180, 180, xgixvsaturation}, - {XvSettable | XvGettable, -180, 180, xgixvhue}, - {XvSettable | XvGettable, 100, 10000, xgixvgammared}, - {XvSettable | XvGettable, 100, 10000, xgixvgammagreen}, - {XvSettable | XvGettable, 100, 10000, xgixvgammablue}, -}; - -#define NUM_IMAGES 8 - -static XF86ImageRec XGIImages[NUM_IMAGES] = - { - XVIMAGE_YUY2, /* If order is changed, XGIOffscreenImages must be adapted */ - XVIMAGE_YV12, - XVIMAGE_UYVY, - { /* RGB 555 */ - PIXEL_FMT_RGB5, - XvRGB, - LSBFirst, - {'R','V','1','5', - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - 16, - XvPacked, - 1, - 15, 0x7C00, 0x03E0, 0x001F, - 0, 0, 0, - 0, 0, 0, - 0, 0, 0, - {'R', 'V', 'B',0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - XvTopToBottom - }, - { /* RGB 565 */ - PIXEL_FMT_RGB6, - XvRGB, - LSBFirst, - {'R','V','1','6', - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - 16, - XvPacked, - 1, - 16, 0xF800, 0x07E0, 0x001F, - 0, 0, 0, - 0, 0, 0, - 0, 0, 0, - {'R', 'V', 'B',0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - XvTopToBottom - }, - { /* YVYU */ - PIXEL_FMT_YVYU, \ - XvYUV, \ - LSBFirst, \ - {'Y','V','Y','U', - 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, - 16, - XvPacked, - 1, - 0, 0, 0, 0 , - 8, 8, 8, - 1, 2, 2, - 1, 1, 1, - {'Y','V','Y','U', - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - XvTopToBottom - }, - { /* NV12 */ - PIXEL_FMT_NV12, - XvYUV, - LSBFirst, - {'N','V','1','2', - 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, - 12, - XvPlanar, - 2, - 0, 0, 0, 0 , - 8, 8, 8, - 1, 2, 2, - 1, 2, 2, - {'Y','U','V',0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - XvTopToBottom - }, - { /* NV21 */ - PIXEL_FMT_NV21, - XvYUV, - LSBFirst, - {'N','V','2','1', - 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, - 12, - XvPlanar, - 2, - 0, 0, 0, 0, - 8, 8, 8, - 1, 2, 2, - 1, 2, 2, - {'Y','V','U',0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - XvTopToBottom - }, -}; - -static void -set_maxencoding(XGIPtr pXGI, XGIPortPrivPtr pPriv) -{ - DummyEncoding.width = IMAGE_MAX_WIDTH; - DummyEncoding.height = IMAGE_MAX_HEIGHT; -} - -static void -XGIResetXvGamma(ScrnInfoPtr pScrn) -{ - XGIPtr pXGI = XGIPTR(pScrn); - XGIPortPrivPtr pPriv = GET_PORT_PRIVATE(pScrn); - - XGIUpdateXvGamma(pXGI, pPriv); -} - -static void -XGISetPortDefaults(ScrnInfoPtr pScrn, XGIPortPrivPtr pPriv) -{ - pPriv->colorKey = 0x000101fe; - pPriv->brightness = 0; - pPriv->contrast = 128; - pPriv->saturation = 0; - pPriv->hue = 0; -} - -static XF86VideoAdaptorPtr -XGISetupImageVideo(ScreenPtr pScreen) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - XGIPtr pXGI = XGIPTR(pScrn); - XF86VideoAdaptorPtr adapt; - XGIPortPrivPtr pPriv; - - if(!(adapt = xcalloc(1, sizeof(XF86VideoAdaptorRec) + - sizeof(XGIPortPrivRec) + - sizeof(DevUnion)))) - return NULL; - - adapt->type = XvWindowMask | XvInputMask | XvImageMask; - adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; - /*adapt->name = "XGI Video Overlay"; */ - adapt->name = "XGI Video"; - adapt->nEncodings = 1; - adapt->pEncodings = &DummyEncoding; - adapt->nFormats = NUM_FORMATS; - adapt->pFormats = XGIFormats; - adapt->nPorts = 1; - adapt->pPortPrivates = (DevUnion*)(&adapt[1]); - - pPriv = (XGIPortPrivPtr)(&adapt->pPortPrivates[1]); - - adapt->pPortPrivates[0].ptr = (pointer)(pPriv); - adapt->pAttributes = XGIAttributes; - adapt->nAttributes = NUM_ATTRIBUTES; - adapt->nImages = NUM_IMAGES; - adapt->pImages = XGIImages; - adapt->PutVideo = NULL; - adapt->PutStill = NULL; - adapt->GetVideo = NULL; - adapt->GetStill = NULL; - adapt->StopVideo = XGIStopVideo; - adapt->SetPortAttribute = XGISetPortAttribute; - adapt->GetPortAttribute = XGIGetPortAttribute; - adapt->QueryBestSize = XGIQueryBestSize; - adapt->PutImage = XGIPutImage; - adapt->QueryImageAttributes = XGIQueryImageAttributes; - - pPriv->currentBuf = 0; - pPriv->linear = NULL; - pPriv->fbAreaPtr = NULL; - pPriv->fbSize = 0; - pPriv->videoStatus = 0; - pPriv->linebufMergeLimit = 1280; - - /* gotta uninit this someplace */ -#if defined(REGION_NULL) - REGION_NULL(pScreen, &pPriv->clip); -#else - REGION_INIT(pScreen, &pPriv->clip, NullBox, 0); -#endif - - /* Reset the properties to their defaults */ - XGISetPortDefaults(pScrn, pPriv); - - pXGI->adaptor = adapt; - pXGI->xvBrightness = MAKE_ATOM(xgixvbrightness); - pXGI->xvContrast = MAKE_ATOM(xgixvcontrast); - pXGI->xvColorKey = MAKE_ATOM(xgixvcolorkey); - pXGI->xvSaturation = MAKE_ATOM(xgixvsaturation); - pXGI->xvHue = MAKE_ATOM(xgixvhue); - pXGI->xvGammaRed = MAKE_ATOM(xgixvgammared); - pXGI->xvGammaGreen = MAKE_ATOM(xgixvgammagreen); - pXGI->xvGammaBlue = MAKE_ATOM(xgixvgammablue); - - /* set display register */ - if(pXGI->VBFlags) { - pPriv->displayMode = DISPMODE_MIRROR; - SetSRRegMask(pXGI, Index_SR_Graphic_Mode, 0x00, 0xc0); /* Only ovelray in CRT1*/ - SetSRRegMask(pXGI, Index_SR_Ext_Clock_Sel, 0x00, 0xc0); - } - else { - pPriv->displayMode = DISPMODE_SINGLE1; - SetSRRegMask(pXGI, Index_SR_Graphic_Mode, 0x00, 0xc0); - SetSRRegMask(pXGI, Index_SR_Ext_Clock_Sel, 0x00, 0xc0); - } - - set_maxencoding(pXGI, pPriv); - - XGIResetVideo(pScrn); - - pXGI->ResetXv = XGIResetVideo; - pXGI->ResetXvGamma = XGIResetXvGamma; - - return adapt; -} - - -static int -XGISetPortAttribute( - ScrnInfoPtr pScrn, - Atom attribute, - INT32 value, - pointer data -){ - XGIPortPrivPtr pPriv = (XGIPortPrivPtr)data; - XGIPtr pXGI = XGIPTR(pScrn); - - if (attribute == pXGI->xvBrightness) { - if((value < -128) || (value > 127)) - return BadValue; - - pPriv->brightness = value; - SetVideoBrightnessReg(pXGI, value); - } - else if (attribute == pXGI->xvContrast) { - if ((value < 0) || (value > 255)) - return BadValue; - - pPriv->contrast = value; - SetVideoContrastReg(pXGI, value); - } - else if (attribute == pXGI->xvSaturation){ - if ((value < -180) || (value > 180)) - return BadValue; - - pPriv->saturation = value; - SetVideoSaturationReg(pXGI, value); - } - else if (attribute == pXGI->xvHue){ - if ((value < -180) || (value > 180)) - return BadValue; - - pPriv->hue = value; - SetVideoHueReg(pXGI, value); - } - else if (attribute == pXGI->xvColorKey) { - pPriv->colorKey = value; - REGION_EMPTY(pScrn->pScreen, &pPriv->clip); - } else if(attribute == pXGI->xvGammaRed) { - if((value < 100) || (value > 10000)) - return BadValue; - - pXGI->XvGammaRed = value; - XGIUpdateXvGamma(pXGI, pPriv); - } else if(attribute == pXGI->xvGammaGreen) { - if((value < 100) || (value > 10000)) - return BadValue; - - pXGI->XvGammaGreen = value; - XGIUpdateXvGamma(pXGI, pPriv); - } else if(attribute == pXGI->xvGammaBlue) { - if((value < 100) || (value > 10000)) - return BadValue; - - pXGI->XvGammaBlue = value; - XGIUpdateXvGamma(pXGI, pPriv); - } else - return BadMatch; - - return Success; -} - -static int -XGIGetPortAttribute( - ScrnInfoPtr pScrn, - Atom attribute, - INT32 *value, - pointer data -){ - XGIPortPrivPtr pPriv = (XGIPortPrivPtr)data; - XGIPtr pXGI = XGIPTR(pScrn); - - if (attribute == pXGI->xvBrightness) { - *value = pPriv->brightness; - } - else if (attribute == pXGI->xvContrast) { - *value = pPriv->contrast; - } - else if (attribute == pXGI->xvSaturation) { - *value = pPriv->saturation; - } - else if (attribute == pXGI->xvHue) { - *value = pPriv->hue; - - } else if(attribute == pXGI->xvGammaRed) { - *value = pXGI->XvGammaRed; - - } else if(attribute == pXGI->xvGammaGreen) { - *value = pXGI->XvGammaGreen; - - } else if(attribute == pXGI->xvGammaBlue) { - *value = pXGI->XvGammaBlue; - - } - else if (attribute == pXGI->xvColorKey) { - *value = pPriv->colorKey; - - } - else - return BadMatch; - - return Success; -} - -static void -XGIQueryBestSize( - ScrnInfoPtr pScrn, - Bool motion, - short vid_w, short vid_h, - short drw_w, short drw_h, - unsigned int *p_w, unsigned int *p_h, - pointer data -){ - *p_w = drw_w; - *p_h = drw_h; - - /* TODO: report the HW limitation */ -} - - -void -set_scale_factor(XGIOverlayPtr pOverlay) -{ - float f_temp; - int NewPitch, srcPitch; - - CARD32 I=0; - - int dstW = pOverlay->dstBox.x2 - pOverlay->dstBox.x1; - int dstH = pOverlay->dstBox.y2 - pOverlay->dstBox.y1; - int srcW = pOverlay->srcW; - int srcH = pOverlay->srcH; - - NewPitch = srcPitch = pOverlay->pitch; - - /*Set 1 as default, because we don't need change 4-tap DDA scale value in the upscale case*/ - pOverlay->f_scale = 1.0; - - if (dstW == srcW) { - pOverlay->HUSF = 0x00; - pOverlay->IntBit = 0x05; - } - else if (dstW > srcW) { - - /*pOverlay->HUSF = (srcW << 16) / dstW; */ - - if ((dstW > 2) && (srcW > 2)) { - pOverlay->HUSF = (((srcW - 2) << 16) + dstW - 3) / (dstW - 2); - } - else { - pOverlay->HUSF = ((srcW << 16) + dstW - 1) / dstW; - } - pOverlay->IntBit = 0x04; - } - /* downscale in horizontal */ - else { - - int tmpW = dstW; - - I = 0x00; - - pOverlay->IntBit = 0x01; - - /* */ - while (srcW >= tmpW) - { - tmpW <<= 1; - I++; - } - - pOverlay->wHPre = (CARD8)(I - 1); - dstW <<= (I - 1); - - f_temp = srcW/dstW; - - /* we don't need to change 4-tap DDA scale if upscale */ - if (f_temp < 1.0) - f_temp = 1.0; - - pOverlay->f_scale = f_temp; - - if ((srcW % dstW)) - pOverlay->HUSF = ((srcW - dstW) << 16) / dstW; - else - pOverlay->HUSF = 0x00; - } - - if (dstH == srcH) { - pOverlay->VUSF = 0x00; - pOverlay->IntBit |= 0x0A; - } - else if (dstH > srcH) { - dstH += 0x02; - /*pOverlay->VUSF = (srcH << 16) / dstH;*/ - if ((dstH > 2) && (srcH > 2)) { - pOverlay->VUSF = (((srcH - 2) << 16) - 32768 + dstH - 3) / (dstH - 2); - } - else { - pOverlay->VUSF = ((srcH << 16) + dstH - 1) / dstH; - } - - pOverlay->IntBit |= 0x08; - } - /* downscale in vertical */ - else { - - CARD32 realI; - - I = realI = srcH / dstH; - pOverlay->IntBit |= 0x02; - - if (I < 2) - { - pOverlay->VUSF = ((srcH - dstH)<<16)/dstH; - } - else - { - if (((srcPitch * I)>>2) > 0xFFF) - { - I = (0xFFF*2/srcPitch); - pOverlay->VUSF = 0xFFFF; - } - else - { - dstH = I * dstH; - - if (srcH % dstH) - pOverlay->VUSF = ((srcH - dstH) << 16) / dstH; - else - pOverlay->VUSF = 0x00; - } - - /* set video frame buffer offset */ - NewPitch = (srcPitch*I); - } - } - - pOverlay->pitch = (CARD16)(NewPitch); - } - -void -set_contrast_factor(XGIPtr pXGI, XGIOverlayPtr pOverlay) -{ - ScrnInfoPtr pScrn = pXGI->pScrn; - CARD16 screenX = pScrn->currentMode->HDisplay; - CARD16 screenY = pScrn->currentMode->VDisplay; - - CARD32 value, SamplePixel, dwTotalPixel; - - CARD16 top, left; - CARD16 bottom, right; - - top = pOverlay->dstBox.y1; - bottom = pOverlay->dstBox.y2; - - if (bottom > screenY) - bottom = screenY; - - left = pOverlay->dstBox.x1; - right = pOverlay->dstBox.x2; - - if (right > screenX) - right = screenX; - - dwTotalPixel = (bottom - top) * (right - left); - - value = (dwTotalPixel - 10000) / 20000; - - if (value > 3 ) - value = 3; - - pOverlay->dwContrastFactor = value; - - switch (value) { - case 1: SamplePixel = 4096; break; - case 2: SamplePixel = 8192; break; - case 3: SamplePixel = 8192; break; - - default: - SamplePixel = 2048; - break; - } - - pOverlay->SamplePixel = (SamplePixel << 10) / dwTotalPixel; - -} - -static void -set_line_buf_size(XGIOverlayPtr pOverlay) -{ - CARD8 preHIDF; - CARD32 dwI; - CARD32 dwSrcWidth = pOverlay->srcW; - int pixelFormat = pOverlay->pixelFormat; - - if ((pixelFormat == PIXEL_FMT_YV12) || - (pixelFormat == PIXEL_FMT_NV12) || - (pixelFormat == PIXEL_FMT_NV21)) - { - preHIDF = pOverlay->wHPre & 0x07; - - if (preHIDF < 2) - { - preHIDF = 2; - } - - if (dwSrcWidth & ~(0xffffff80 << (preHIDF - 2))) - { - dwI = (dwSrcWidth >> (preHIDF + 5)) + 1; - } - else - { - dwI = dwSrcWidth >> (preHIDF + 5); - } - - pOverlay->lineBufSize = dwI * (0x01 << (preHIDF + 2)) - 1; - - } - /* not plane format */ - else - { - if (dwSrcWidth & 0x07) - dwI = (dwSrcWidth >> 3) + 1; - else - dwI = (dwSrcWidth >> 3); - - pOverlay->lineBufSize = dwI; - } -} - -static void -XGIDisplayVideo(ScrnInfoPtr pScrn, XGIPortPrivPtr pPriv) -{ - XGIPtr pXGI = XGIPTR(pScrn); - - short srcPitch = pPriv->srcPitch; - short height = pPriv->height; - XGIOverlayRec overlay; - int srcOffsetX=0, srcOffsetY=0; - int sx=0, sy=0; - - memset(&overlay, 0, sizeof(overlay)); - overlay.pixelFormat = pPriv->id; - overlay.pitch = srcPitch; - overlay.keyOP = 0x03; /* destination colorkey */ - overlay.bobEnable = 0x00; - - overlay.dstBox.x1 = pPriv->drw_x - pScrn->frameX0; - overlay.dstBox.x2 = pPriv->drw_x + pPriv->drw_w - pScrn->frameX0; - overlay.dstBox.y1 = pPriv->drw_y - pScrn->frameY0; - overlay.dstBox.y2 = pPriv->drw_y + pPriv->drw_h - pScrn->frameY0; - - if((overlay.dstBox.x2 < 0) || (overlay.dstBox.y2 < 0)) - return; - - if(overlay.dstBox.x1 < 0) { - srcOffsetX = pPriv->src_w * (-overlay.dstBox.x1) / pPriv->drw_w; - overlay.dstBox.x1 = 0; - } - if(overlay.dstBox.y1 < 0) { - srcOffsetY = pPriv->src_h * (-overlay.dstBox.y1) / pPriv->drw_h; - overlay.dstBox.y1 = 0; - } - - if (pPriv->videoStatus & CLIENT_CAPTURE_ON) - { - /* We use AutoFlip for capture, not need buffer address */ - overlay.PSY = 0x0000; - } - else - { - switch(pPriv->id){ - case PIXEL_FMT_YV12: - sx = (pPriv->src_x + srcOffsetX) & ~7; - sy = (pPriv->src_y + srcOffsetY) & ~1; - - overlay.PSY = pPriv->bufAddr[pPriv->currentBuf] + sx + sy*srcPitch; - overlay.PSV = pPriv->bufAddr[pPriv->currentBuf] + height*srcPitch + ((sx + sy*srcPitch/2) >> 1); - overlay.PSU = pPriv->bufAddr[pPriv->currentBuf] + height*srcPitch*5/4 + ((sx + sy*srcPitch/2) >> 1); - break; - - case PIXEL_FMT_NV12: - case PIXEL_FMT_NV21: - sx = (pPriv->src_x + srcOffsetX) & ~7; - sy = (pPriv->src_y + srcOffsetY) & ~1; - overlay.PSY = pPriv->bufAddr[pPriv->currentBuf] + sx + sy*srcPitch; - overlay.PSV = pPriv->bufAddr[pPriv->currentBuf] + height*srcPitch + ((sx + sy*srcPitch/2) >> 1); - overlay.PSU = overlay.PSV; - break; - - case PIXEL_FMT_YUY2: - case PIXEL_FMT_UYVY: - case PIXEL_FMT_YVYU: - case PIXEL_FMT_RGB6: - case PIXEL_FMT_RGB5: - sx = (pPriv->src_x + srcOffsetX) & ~1; - sy = (pPriv->src_y + srcOffsetY); - - overlay.PSY = pPriv->bufAddr[pPriv->currentBuf] + sx*2 + sy*srcPitch; - break; - - default: - /* ErrorF("UnSurpported Format"); */ - break; - } - - } - - overlay.srcW = pPriv->src_w - (sx - pPriv->src_x); - overlay.srcH = pPriv->src_h - (sy - pPriv->src_y); - - /* set line buffer length */ - set_line_buf_size (&overlay); - - /* set scale factor */ - set_scale_factor (&overlay); - - /* contrast factor */ - set_contrast_factor(pXGI, &overlay); - - SetSelectOverlayReg(pXGI, 0x00); - - SetColorkeyReg(pXGI, pPriv->colorKey); - - /* set overlay */ - SetOverlayReg(pXGI, &overlay); - - /* enable overlay */ - SetEnableOverlayReg(pXGI, TRUE); -} - - -static void -XGIStopVideo(ScrnInfoPtr pScrn, pointer data, Bool exit) -{ - XGIPortPrivPtr pPriv = (XGIPortPrivPtr)data; - XGIPtr pXGI = XGIPTR(pScrn); - - REGION_EMPTY(pScrn->pScreen, &pPriv->clip); - - if(exit) { - - if(pPriv->videoStatus & CLIENT_VIDEO_ON) { - SetEnableOverlayReg(pXGI, FALSE); - } - - if (pPriv->videoStatus & CLIENT_CAPTURE_ON) { - EnableCaptureAutoFlip(pXGI, FALSE); - } - - if(pPriv->fbAreaPtr) { - xf86FreeOffscreenArea(pPriv->fbAreaPtr); - pPriv->fbAreaPtr = NULL; - pPriv->fbSize = 0; - } - - - /* clear all flag */ - pPriv->videoStatus = 0; - - } else { - if(pPriv->videoStatus & CLIENT_VIDEO_ON) { - pPriv->videoStatus |= OFF_TIMER; - pPriv->offTime = currentTime.milliseconds + OFF_DELAY; - } - } -} - - -static int -XGIPutImage( - ScrnInfoPtr pScrn, - short src_x, short src_y, - short drw_x, short drw_y, - short src_w, short src_h, - short drw_w, short drw_h, - int id, unsigned char* buf, - short width, short height, - Bool sync, - RegionPtr clipBoxes, pointer data -){ - XGIPtr pXGI = XGIPTR(pScrn); - XGIPortPrivPtr pPriv = (XGIPortPrivPtr)data; - - int i; - - int totalSize=0; -/* int depth = pXGI->CurrentLayout.bitsPerPixel >> 3; */ - - pPriv->drw_x = drw_x; - pPriv->drw_y = drw_y; - pPriv->drw_w = drw_w; - pPriv->drw_h = drw_h; - pPriv->src_x = src_x; - pPriv->src_y = src_y; - pPriv->src_w = src_w; - pPriv->src_h = src_h; - pPriv->id = id; - pPriv->height = height; - - /* Pixel formats: - 1. YU12: 3 planes: H V - Y sample period 1 1 (8 bit per pixel) - V sample period 2 2 (8 bit per pixel, subsampled) - U sample period 2 2 (8 bit per pixel, subsampled) - - Y plane is fully sampled (width*height), U and V planes - are sampled in 2x2 blocks, hence a group of 4 pixels requires - 4 + 1 + 1 = 6 bytes. The data is planar, ie in single planes - for Y, U and V. - 2. UYVY: 3 planes: H V - Y sample period 1 1 (8 bit per pixel) - V sample period 2 1 (8 bit per pixel, subsampled) - U sample period 2 1 (8 bit per pixel, subsampled) - Y plane is fully sampled (width*height), U and V planes - are sampled in 2x1 blocks, hence a group of 4 pixels requires - 4 + 2 + 2 = 8 bytes. The data is bit packed, there are no separate - Y, U or V planes. - Bit order: U0 Y0 V0 Y1 U2 Y2 V2 Y3 ... - 3. I420: Like YU12, but planes U and V are in reverse order. - 4. YUY2: Like UYVY, but order is - Y0 U0 Y1 V0 Y2 U2 Y3 V2 ... - 5. YVYU: Like YUY2, but order is - Y0 V0 Y1 U0 Y2 V2 Y3 U2 ... - */ - switch(id){ - case PIXEL_FMT_YV12: - case PIXEL_FMT_NV12: - case PIXEL_FMT_NV21: - pPriv->srcPitch = (width + 7) & ~7; - totalSize = (pPriv->srcPitch * height * 3) >> 1; /* Verified */ - break; - case PIXEL_FMT_YUY2: - case PIXEL_FMT_UYVY: - case PIXEL_FMT_YVYU: - case PIXEL_FMT_RGB6: - case PIXEL_FMT_RGB5: - default: - pPriv->srcPitch = ((width << 1) + 3) & ~3; /* Verified */ - totalSize = pPriv->srcPitch * height; - } - - /* make it a multiple of 16 to simplify to copy loop */ - totalSize += 15; - totalSize &= ~15; - printf("PutImage\n"); - /* allocate memory */ - do { - int lines, pitch, depth; - BoxPtr pBox; - - if(totalSize == pPriv->fbSize) - break; - - pPriv->fbSize = totalSize; - - if(pPriv->fbAreaPtr) { - xf86FreeOffscreenArea(pPriv->fbAreaPtr); - } - - depth = (pScrn->bitsPerPixel + 7 ) / 8; - pitch = pScrn->displayWidth * depth; - lines = ((totalSize * 2) / pitch) + 1; - - pPriv->fbAreaPtr = xf86AllocateOffscreenArea(pScrn->pScreen, - pScrn->displayWidth, - lines, 0, NULL, NULL, NULL); - - if(!pPriv->fbAreaPtr) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Allocate video memory fails\n"); - return BadAlloc; - } - - pBox = &(pPriv->fbAreaPtr->box); - pPriv->bufAddr[0] = (pBox->x1 * depth) + (pBox->y1 * pitch); - pPriv->bufAddr[1] = pPriv->bufAddr[0] + totalSize; - - } while(0); - - /* copy data */ - if((pXGI->XvUseMemcpy) || (totalSize < 16)) { - #ifdef NewPath - memcpy(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf], buf, totalSize); - - #else - switch(id){ - case PIXEL_FMT_YV12: - { - BYTE *Y, *V, *U, *srcY, *srcV, *srcU; - - short srcPitch2 = pPriv->srcPitch >> 1; - short height2 = height >> 1; - short width2 = width >> 1; - - Y = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - V = Y + pPriv->srcPitch * height; - U = V + pPriv->srcPitch * height / 4 ; - - srcY = buf; - srcV = srcY + width * height; - srcU = srcV + width * height / 4; -#if !defined(__powerpc__) - for(i=0; isrcPitch, srcY + i*width, width); - - for(i=0; idepth == 16)//16 BPP - { - for(i=0; isrcPitch + j)) = *((unsigned short *)(srcY + i*width + j)); - } - } - - for(i=0; isrcPitch + j+1) = *(unsigned char *)(srcY + i*width + j); - *(unsigned char *)(Y + i * pPriv->srcPitch + j) = *(unsigned char *)(srcY + i*width + j+1); - } - } - - for(i=0; idepth == 24)//32 BPP - { - for(i=0; isrcPitch + j)) = *((unsigned int *)(srcY + i*width + j)); - } - } - - for(i=0; isrcPitch + j+3) = *(unsigned char *)(srcY + i*width + j); - *(unsigned char *)(Y + i * pPriv->srcPitch + j+2) = *(unsigned char *)(srcY + i*width + j+1); - *(unsigned char *)(Y + i * pPriv->srcPitch + j+1) = *(unsigned char *)(srcY + i*width + j+2); - *(unsigned char *)(Y + i * pPriv->srcPitch + j) = *(unsigned char *)(srcY + i*width + j+3); - } - } - - for(i=0; isrcPitch, srcY + i*width, width); - - for(i=0; i> 1; - - Y = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - VU = Y + pPriv->srcPitch * height; - - srcY = buf; - srcVU = srcY + width * height; -#if !defined(__powerpc__) - - for(i=0; isrcPitch, srcY + i*width, width); - - for(i=0; isrcPitch, srcVU + i*width, width); -#else - if(pScrn->depth == 16)//16 BPP - { - for(i=0; isrcPitch+j)) = *((unsigned short *)(srcY + i*width+j)); - } - } - - for(i=0; isrcPitch+j)) = *((unsigned short *)(srcVU + i*width+j)); - } - } -/* - for(i=0; isrcPitch+j) = *(unsigned char *)(srcY + i*width+j+1); - *(unsigned char *)(Y + i * pPriv->srcPitch+j+1) = *(unsigned char *)(srcY + i*width+j); - } - } - - for(i=0; isrcPitch+j) = *(unsigned char *)(srcVU + i*width+j+1); - *(unsigned char *)(VU + i * pPriv->srcPitch+j+1) = *(unsigned char *)(srcVU + i*width+j); - } - } */ - } - else if(pScrn->depth == 24)//32 BPP - { - - for(i=0; isrcPitch+j)) = *((unsigned int *)(srcY + i*width+j)); - } - } - - for(i=0; isrcPitch+j)) = *((unsigned int *)(srcVU + i*width+j)); - } - } -/* - for(i=0; isrcPitch+j) = *(unsigned char *)(srcY + i*width+j+3); - *(unsigned char *)(Y + i * pPriv->srcPitch+j+1) = *(unsigned char *)(srcY + i*width+j+2); - *(unsigned char *)(Y + i * pPriv->srcPitch+j+2) = *(unsigned char *)(srcY + i*width+j+1); - *(unsigned char *)(Y + i * pPriv->srcPitch+j+3) = *(unsigned char *)(srcY + i*width+j); - - } - } - - for(i=0; isrcPitch+j) = *(unsigned char *)(srcVU + i*width+j+3); - *(unsigned char *)(VU + i * pPriv->srcPitch+j+1) = *(unsigned char *)(srcVU + i*width+j+2); - *(unsigned char *)(VU + i * pPriv->srcPitch+j+2) = *(unsigned char *)(srcVU + i*width+j+1); - *(unsigned char *)(VU + i * pPriv->srcPitch+j+3) = *(unsigned char *)(srcVU + i*width+j); - - } - }*/ - } - else - { - for(i=0; isrcPitch, srcY + i*width, width); - - for(i=0; isrcPitch, srcVU + i*width, width); - } -#endif - break; - } - case PIXEL_FMT_YUY2: - case PIXEL_FMT_UYVY: - case PIXEL_FMT_YVYU: - case PIXEL_FMT_RGB6: - case PIXEL_FMT_RGB5: - { - BYTE *Base = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - unsigned short *dest = (unsigned short *) Base; - /*ErrorF("YUY2 format,Color Depth=%d\n",pScrn->depth);*/ -#if !defined(__powerpc__) - for(i=0; isrcPitch, buf + i*width*2, width*2); -#else - if(pScrn->depth == 16)//16 BPP - { - - int j; - for(i=0; isrcPitch+j)) = *((unsigned short *)(buf+i*width*2+j)); - - - if(i==0 &&j<50) - { - ErrorF("IMAGE[%x]=%x ",j,*((unsigned char *)(buf+i*width*2+j))); - /* ErrorF("IMAGE[%x]=%x ",j,*((unsigned char *)(buf+i*width)*2+j)));*/ - } - if(i==0 && j<=50 && (j%5==0)) - ErrorF("\n"); - } - } - ErrorF("DstIMG[0]=%x\n",(unsigned char)*Base); - -/* for(j=0; jsrcPitch+j) = *(unsigned char *)(buf+i*width*2+j+1); - *(unsigned char *)(Base+i*pPriv->srcPitch+j+1) = *(unsigned char *)(buf+i*width*2+j); - }*/ - } - else if(pScrn->depth == 24)//24 BPP - { - int j; - for(i=0; isrcPitch+j)) = *((unsigned int *)(buf+i*width*2+j)); - - - if(i==0 &&j<50) - ErrorF("IMAGE[%x]=%x ",j,*((unsigned int *)(buf+i*width*2+j))); - if(i==0 && j<=50 && (j%5==0)) - ErrorF("\n"); - } - } - /* - int j; - for(j=0; jsrcPitch+j) = *(unsigned char *)(buf+i*width*2+j+3); - *(unsigned char *)(Base+i*pPriv->srcPitch+j+1) = *(unsigned char *)(buf+i*width*2+j+2); - *(unsigned char *)(Base+i*pPriv->srcPitch+j+2) = *(unsigned char *)(buf+i*width*2+j+1); - *(unsigned char *)(Base+i*pPriv->srcPitch+j+3) = *(unsigned char *)(buf+i*width*2+j); - - } */ - } - else - memcpy( Base + i * pPriv->srcPitch, buf + i*width*2, width*2); -#endif - break; - } - default: - memcpy(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf], buf, totalSize); - break; - } - #endif - - } - else { - - #ifdef NewPath - BYTE *Base = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - for(i=0; isrcPitch >> 1; - short height2 = height >> 1; - short width2 = width >> 1; - int j; - - Y = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - V = Y + pPriv->srcPitch * height; - U = V + pPriv->srcPitch * height / 4 ; - srcY = buf; - srcV = srcY + width * height; - srcU = srcV + width * height / 4; - ErrorF("else...YV12 case\n"); -/*#if !defined(__powerpc__)*/ - for(i=0; isrcPitch*i + j); - - for(i=0; isrcPitch + j+1) = *(unsigned char *)(srcY + i*width + j); - *(unsigned char *)(Y + i * pPriv->srcPitch + j) = *(unsigned char *)(srcY + i*width + j+1); - } - } - - for(i=0; i> 1; - - Y = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - VU = Y + pPriv->srcPitch * height; - - srcY = buf; - srcVU = srcY + width * height; - -/*#if !defined(__powerpc__)*/ - for(i=0; isrcPitch*i + j); - - for(i=0; isrcPitch*i + j); -/*#else - for(i=0; isrcPitch+j) = *(unsigned char *)(srcY + i*width+j+1); - *(unsigned char *)(Y + i * pPriv->srcPitch+j+1) = *(unsigned char *)(srcY + i*width+j); - } - } - - for(i=0; isrcPitch+j) = *(unsigned char *)(srcVU + i*width+j+1); - *(unsigned char *)(VU + i * pPriv->srcPitch+j+1) = *(unsigned char *)(srcVU + i*width+j); - } - - } -#endif -*/ - break; - } - case PIXEL_FMT_YUY2: - case PIXEL_FMT_UYVY: - case PIXEL_FMT_YVYU: - case PIXEL_FMT_RGB6: - case PIXEL_FMT_RGB5: - - { -#if 0 - BYTE *Base = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - int j; - ErrorF("else...YUY2 case\n"); -//#if !defined(__powerpc__) - for(i=0; isrcPitch+j) = *(buf + width*i + j); -/*#else - { - for(j=0; jsrcPitch+j) = *(unsigned char *)(buf+i*width*2+j+1); - *(unsigned char *)(Base+i*pPriv->srcPitch+j+1) = *(unsigned char *)(buf+i*width*2+j); - } - } -#endif*/ -#endif - break; - } - default: - { - BYTE *Base = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - int j; - for(i=0; ipScreen, &pPriv->clip, clipBoxes)) - { - REGION_COPY(pScrn->pScreen, &pPriv->clip, clipBoxes); - - /* draw these */ - } else { - xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey, clipBoxes); - } /* update cliplist */ - - pPriv->currentBuf ^= 1; - pPriv->videoStatus = CLIENT_VIDEO_ON; - - return Success; -} - - -static int -XGIQueryImageAttributes( - ScrnInfoPtr pScrn, - int id, - unsigned short *w, unsigned short *h, - int *pitches, int *offsets -){ - int pitchY, pitchUV; - int size, sizeY, sizeUV; - - if(*w < IMAGE_MIN_WIDTH) *w = IMAGE_MIN_WIDTH; - if(*h < IMAGE_MIN_HEIGHT) *h = IMAGE_MIN_HEIGHT; - - if(*w > DummyEncoding.width) *w = DummyEncoding.width; - if(*h > DummyEncoding.height) *h = DummyEncoding.height; - - switch(id) { - case PIXEL_FMT_YV12: - *w = (*w + 7) & ~7; - *h = (*h + 1) & ~1; - pitchY = *w; - pitchUV = *w >> 1; - if(pitches) { - pitches[0] = pitchY; - pitches[1] = pitches[2] = pitchUV; - } - sizeY = pitchY * (*h); - sizeUV = pitchUV * ((*h) >> 1); - if(offsets) { - offsets[0] = 0; - offsets[1] = sizeY; - offsets[2] = sizeY + sizeUV; - } - size = sizeY + (sizeUV << 1); - break; - case PIXEL_FMT_NV12: - case PIXEL_FMT_NV21: - *w = (*w + 7) & ~7; - *h = (*h + 1) & ~1; - pitchY = *w; - pitchUV = *w; - if(pitches) { - pitches[0] = pitchY; - pitches[1] = pitchUV; - } - sizeY = pitchY * (*h); - sizeUV = pitchUV * ((*h) >> 1); - if(offsets) { - offsets[0] = 0; - offsets[1] = sizeY; - } - size = sizeY + (sizeUV << 1); - break; - case PIXEL_FMT_YUY2: - case PIXEL_FMT_UYVY: - case PIXEL_FMT_YVYU: - case PIXEL_FMT_RGB6: - case PIXEL_FMT_RGB5: - default: - *w = (*w + 1) & ~1; - pitchY = *w << 1; - if(pitches) pitches[0] = pitchY; - if(offsets) offsets[0] = 0; - size = pitchY * (*h); - break; - } - - return size; -} diff --git a/src/xgi_video_g.c b/src/xgi_video_g.c deleted file mode 100644 index 18b56ea..0000000 --- a/src/xgi_video_g.c +++ /dev/null @@ -1,1238 +0,0 @@ -/*************************************************************************** - -Copyright 2004 eXtreme Graphics Innovation Corp, Inc., HsinChu, Taiwan. -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 INTEL, AND/OR ITS SUPPLIERS 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. - -**************************************************************************/ - -/* - * Formerly based on Xv driver for SiS 300, 315 and 330 series by - * Thomas Winischhofer - * - * Basic structure based on the mga Xv driver by Mark Vojkovich - * and i810 Xv driver by Jonathan Bian . - * - * Authors: - * Nan-Hsing Chang - * - * This supports the following chipsets: - * XGI340, XGI342: Full register range, one overlay (used for both CRT1 and CRT2 alt.) - * - */ - -#include "xf86.h" -#include "xf86_OSproc.h" -#include "xf86Resources.h" -#include "compiler.h" -#include "xf86PciInfo.h" -#include "xf86Pci.h" -#include "xf86fbman.h" -#include "regionstr.h" - -#include "xgi.h" -#include "xf86xv.h" -#include -#include "xaa.h" -#include "xaalocal.h" -#include "dixstruct.h" -#include "fourcc.h" - -/* TODO: move to xgi_regs.h */ -#include "xgi_videohw.h" -#include "xgi_video.h" - -static XF86VideoAdaptorPtr XGISetupImageVideo(ScreenPtr); -static int XGISetPortAttribute(ScrnInfoPtr, Atom, INT32, pointer); -static int XGIGetPortAttribute(ScrnInfoPtr, Atom ,INT32 *, pointer); -static void XGIQueryBestSize(ScrnInfoPtr, Bool, - short, short, short, short, unsigned int *, unsigned int *, pointer); -static int XGIPutImage( ScrnInfoPtr, - short, short, short, short, short, short, short, short, - int, unsigned char*, short, short, Bool, RegionPtr, pointer); -static int XGIQueryImageAttributes(ScrnInfoPtr, - int, unsigned short *, unsigned short *, int *, int *); -static void XGIStopVideo(ScrnInfoPtr, pointer, Bool); -/* static void XGIFreeOverlayMemory(ScrnInfoPtr pScrn); */ - -extern void SetSRRegMask(XGIPtr, CARD8, CARD8, CARD8); -extern void XGIUpdateXvGamma(XGIPtr, XGIPortPrivPtr); -#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE) - -void XGIInitVideo(ScreenPtr pScreen) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - XF86VideoAdaptorPtr *adaptors, *newAdaptors = NULL; - XF86VideoAdaptorPtr newAdaptor = NULL; - int num_adaptors; - - newAdaptor = XGISetupImageVideo(pScreen); - - num_adaptors = xf86XVListGenericAdaptors(pScrn, &adaptors); - - if(newAdaptor) { - if(!num_adaptors) { - num_adaptors = 1; - adaptors = &newAdaptor; - } else { - newAdaptors = /* need to free this someplace */ - xalloc((num_adaptors + 1) * sizeof(XF86VideoAdaptorPtr*)); - if(newAdaptors) { - memcpy(newAdaptors, adaptors, num_adaptors * - sizeof(XF86VideoAdaptorPtr)); - newAdaptors[num_adaptors] = newAdaptor; - adaptors = newAdaptors; - num_adaptors++; - } - } - } - - if(num_adaptors) - xf86XVScreenInit(pScreen, adaptors, num_adaptors); - - if(newAdaptors) - xfree(newAdaptors); - -} - - -/* client libraries expect an encoding */ -static XF86VideoEncodingRec DummyEncoding = -{ - 0, - "XV_IMAGE", - 0, 0, /* Will be filled in */ - {1, 1} -}; - -#define NUM_FORMATS 3 - -static XF86VideoFormatRec XGIFormats[NUM_FORMATS] = -{ - { 8, PseudoColor}, - {16, TrueColor}, - {24, TrueColor} -}; - -static char xgixvcolorkey[] = "XV_COLORKEY"; -static char xgixvbrightness[] = "XV_BRIGHTNESS"; -static char xgixvcontrast[] = "XV_CONTRAST"; -static char xgixvsaturation[] = "XV_SATURATION"; -static char xgixvhue[] = "XV_HUE"; -static char xgixvgammared[] = "XV_GAMMA_RED"; -static char xgixvgammagreen[] = "XV_GAMMA_GREEN"; -static char xgixvgammablue[] = "XV_GAMMA_BLUE"; - -#define NUM_ATTRIBUTES 8 - -static XF86AttributeRec XGIAttributes[NUM_ATTRIBUTES] = -{ - {XvSettable | XvGettable, 0, (1 << 24) - 1, xgixvcolorkey}, - {XvSettable | XvGettable, -128, 127, xgixvbrightness}, - {XvSettable | XvGettable, 0, 255, xgixvcontrast}, - {XvSettable | XvGettable, -180, 180, xgixvsaturation}, - {XvSettable | XvGettable, -180, 180, xgixvhue}, - {XvSettable | XvGettable, 100, 10000, xgixvgammared}, - {XvSettable | XvGettable, 100, 10000, xgixvgammagreen}, - {XvSettable | XvGettable, 100, 10000, xgixvgammablue}, -}; - -#define NUM_IMAGES 8 - -static XF86ImageRec XGIImages[NUM_IMAGES] = - { - XVIMAGE_YUY2, /* If order is changed, XGIOffscreenImages must be adapted */ - XVIMAGE_YV12, - XVIMAGE_UYVY, - { /* RGB 555 */ - PIXEL_FMT_RGB5, - XvRGB, - LSBFirst, - {'R','V','1','5', - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - 16, - XvPacked, - 1, - 15, 0x7C00, 0x03E0, 0x001F, - 0, 0, 0, - 0, 0, 0, - 0, 0, 0, - {'R', 'V', 'B',0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - XvTopToBottom - }, - { /* RGB 565 */ - PIXEL_FMT_RGB6, - XvRGB, - LSBFirst, - {'R','V','1','6', - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - 16, - XvPacked, - 1, - 16, 0xF800, 0x07E0, 0x001F, - 0, 0, 0, - 0, 0, 0, - 0, 0, 0, - {'R', 'V', 'B',0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - XvTopToBottom - }, - { /* YVYU */ - PIXEL_FMT_YVYU, \ - XvYUV, \ - LSBFirst, \ - {'Y','V','Y','U', - 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, - 16, - XvPacked, - 1, - 0, 0, 0, 0 , - 8, 8, 8, - 1, 2, 2, - 1, 1, 1, - {'Y','V','Y','U', - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - XvTopToBottom - }, - { /* NV12 */ - PIXEL_FMT_NV12, - XvYUV, - LSBFirst, - {'N','V','1','2', - 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, - 12, - XvPlanar, - 2, - 0, 0, 0, 0 , - 8, 8, 8, - 1, 2, 2, - 1, 2, 2, - {'Y','U','V',0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - XvTopToBottom - }, - { /* NV21 */ - PIXEL_FMT_NV21, - XvYUV, - LSBFirst, - {'N','V','2','1', - 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, - 12, - XvPlanar, - 2, - 0, 0, 0, 0, - 8, 8, 8, - 1, 2, 2, - 1, 2, 2, - {'Y','V','U',0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, - XvTopToBottom - }, -}; - -static void -set_maxencoding(XGIPtr pXGI, XGIPortPrivPtr pPriv) -{ - DummyEncoding.width = IMAGE_MAX_WIDTH; - DummyEncoding.height = IMAGE_MAX_HEIGHT; -} - -static void -XGIResetXvGamma(ScrnInfoPtr pScrn) -{ - XGIPtr pXGI = XGIPTR(pScrn); - XGIPortPrivPtr pPriv = GET_PORT_PRIVATE(pScrn); - - XGIUpdateXvGamma(pXGI, pPriv); -} - -static void -XGISetPortDefaults(ScrnInfoPtr pScrn, XGIPortPrivPtr pPriv) -{ - pPriv->colorKey = 0x000101fe; - pPriv->brightness = 0; - pPriv->contrast = 128; - pPriv->saturation = 0; - pPriv->hue = 0; -} - -static XF86VideoAdaptorPtr -XGISetupImageVideo(ScreenPtr pScreen) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - XGIPtr pXGI = XGIPTR(pScrn); - XF86VideoAdaptorPtr adapt; - XGIPortPrivPtr pPriv; - - if(!(adapt = xcalloc(1, sizeof(XF86VideoAdaptorRec) + - sizeof(XGIPortPrivRec) + - sizeof(DevUnion)))) - return NULL; - - adapt->type = XvWindowMask | XvInputMask | XvImageMask; - adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; - /*adapt->name = "XGI Video Overlay"; */ - adapt->name = "XGI Video"; - adapt->nEncodings = 1; - adapt->pEncodings = &DummyEncoding; - adapt->nFormats = NUM_FORMATS; - adapt->pFormats = XGIFormats; - adapt->nPorts = 1; - adapt->pPortPrivates = (DevUnion*)(&adapt[1]); - - pPriv = (XGIPortPrivPtr)(&adapt->pPortPrivates[1]); - - adapt->pPortPrivates[0].ptr = (pointer)(pPriv); - adapt->pAttributes = XGIAttributes; - adapt->nAttributes = NUM_ATTRIBUTES; - adapt->nImages = NUM_IMAGES; - adapt->pImages = XGIImages; - adapt->PutVideo = NULL; - adapt->PutStill = NULL; - adapt->GetVideo = NULL; - adapt->GetStill = NULL; - adapt->StopVideo = XGIStopVideo; - adapt->SetPortAttribute = XGISetPortAttribute; - adapt->GetPortAttribute = XGIGetPortAttribute; - adapt->QueryBestSize = XGIQueryBestSize; - adapt->PutImage = XGIPutImage; - adapt->QueryImageAttributes = XGIQueryImageAttributes; - - pPriv->currentBuf = 0; - pPriv->linear = NULL; - pPriv->fbAreaPtr = NULL; - pPriv->fbSize = 0; - pPriv->videoStatus = 0; - pPriv->linebufMergeLimit = 1280; - - /* gotta uninit this someplace */ -#if defined(REGION_NULL) - REGION_NULL(pScreen, &pPriv->clip); -#else - REGION_INIT(pScreen, &pPriv->clip, NullBox, 0); -#endif - - /* Reset the properties to their defaults */ - XGISetPortDefaults(pScrn, pPriv); - - pXGI->adaptor = adapt; - pXGI->xvBrightness = MAKE_ATOM(xgixvbrightness); - pXGI->xvContrast = MAKE_ATOM(xgixvcontrast); - pXGI->xvColorKey = MAKE_ATOM(xgixvcolorkey); - pXGI->xvSaturation = MAKE_ATOM(xgixvsaturation); - pXGI->xvHue = MAKE_ATOM(xgixvhue); - pXGI->xvGammaRed = MAKE_ATOM(xgixvgammared); - pXGI->xvGammaGreen = MAKE_ATOM(xgixvgammagreen); - pXGI->xvGammaBlue = MAKE_ATOM(xgixvgammablue); - - /* set display register */ - if(pXGI->VBFlags) { - pPriv->displayMode = DISPMODE_MIRROR; - SetSRRegMask(pXGI, Index_SR_Graphic_Mode, 0x00, 0xc0); /* Only ovelray in CRT1*/ - SetSRRegMask(pXGI, Index_SR_Ext_Clock_Sel, 0x00, 0xc0); - } - else { - pPriv->displayMode = DISPMODE_SINGLE1; - SetSRRegMask(pXGI, Index_SR_Graphic_Mode, 0x00, 0xc0); - SetSRRegMask(pXGI, Index_SR_Ext_Clock_Sel, 0x00, 0xc0); - } - - set_maxencoding(pXGI, pPriv); - - XGIResetVideo(pScrn); - - pXGI->ResetXv = XGIResetVideo; - pXGI->ResetXvGamma = XGIResetXvGamma; - - return adapt; -} - - -static int -XGISetPortAttribute( - ScrnInfoPtr pScrn, - Atom attribute, - INT32 value, - pointer data -){ - XGIPortPrivPtr pPriv = (XGIPortPrivPtr)data; - XGIPtr pXGI = XGIPTR(pScrn); - - if (attribute == pXGI->xvBrightness) { - if((value < -128) || (value > 127)) - return BadValue; - - pPriv->brightness = value; - SetVideoBrightnessReg(pXGI, value); - } - else if (attribute == pXGI->xvContrast) { - if ((value < 0) || (value > 255)) - return BadValue; - - pPriv->contrast = value; - SetVideoContrastReg(pXGI, value); - } - else if (attribute == pXGI->xvSaturation){ - if ((value < -180) || (value > 180)) - return BadValue; - - pPriv->saturation = value; - SetVideoSaturationReg(pXGI, value); - } - else if (attribute == pXGI->xvHue){ - if ((value < -180) || (value > 180)) - return BadValue; - - pPriv->hue = value; - SetVideoHueReg(pXGI, value); - } - else if (attribute == pXGI->xvColorKey) { - pPriv->colorKey = value; - REGION_EMPTY(pScrn->pScreen, &pPriv->clip); - } else if(attribute == pXGI->xvGammaRed) { - if((value < 100) || (value > 10000)) - return BadValue; - - pXGI->XvGammaRed = value; - XGIUpdateXvGamma(pXGI, pPriv); - } else if(attribute == pXGI->xvGammaGreen) { - if((value < 100) || (value > 10000)) - return BadValue; - - pXGI->XvGammaGreen = value; - XGIUpdateXvGamma(pXGI, pPriv); - } else if(attribute == pXGI->xvGammaBlue) { - if((value < 100) || (value > 10000)) - return BadValue; - - pXGI->XvGammaBlue = value; - XGIUpdateXvGamma(pXGI, pPriv); - } else - return BadMatch; - - return Success; -} - -static int -XGIGetPortAttribute( - ScrnInfoPtr pScrn, - Atom attribute, - INT32 *value, - pointer data -){ - XGIPortPrivPtr pPriv = (XGIPortPrivPtr)data; - XGIPtr pXGI = XGIPTR(pScrn); - - if (attribute == pXGI->xvBrightness) { - *value = pPriv->brightness; - } - else if (attribute == pXGI->xvContrast) { - *value = pPriv->contrast; - } - else if (attribute == pXGI->xvSaturation) { - *value = pPriv->saturation; - } - else if (attribute == pXGI->xvHue) { - *value = pPriv->hue; - - } else if(attribute == pXGI->xvGammaRed) { - *value = pXGI->XvGammaRed; - - } else if(attribute == pXGI->xvGammaGreen) { - *value = pXGI->XvGammaGreen; - - } else if(attribute == pXGI->xvGammaBlue) { - *value = pXGI->XvGammaBlue; - - } - else if (attribute == pXGI->xvColorKey) { - *value = pPriv->colorKey; - - } - else - return BadMatch; - - return Success; -} - -static void -XGIQueryBestSize( - ScrnInfoPtr pScrn, - Bool motion, - short vid_w, short vid_h, - short drw_w, short drw_h, - unsigned int *p_w, unsigned int *p_h, - pointer data -){ - *p_w = drw_w; - *p_h = drw_h; - - /* TODO: report the HW limitation */ -} - - -void -set_scale_factor(XGIOverlayPtr pOverlay) -{ - float f_temp; - int NewPitch, srcPitch; - - CARD32 I=0; - - int dstW = pOverlay->dstBox.x2 - pOverlay->dstBox.x1; - int dstH = pOverlay->dstBox.y2 - pOverlay->dstBox.y1; - int srcW = pOverlay->srcW; - int srcH = pOverlay->srcH; - - NewPitch = srcPitch = pOverlay->pitch; - - /*Set 1 as default, because we don't need change 4-tap DDA scale value in the upscale case*/ - pOverlay->f_scale = 1.0; - - if (dstW == srcW) { - pOverlay->HUSF = 0x00; - pOverlay->IntBit = 0x05; - } - else if (dstW > srcW) { - - /*pOverlay->HUSF = (srcW << 16) / dstW; */ - - if ((dstW > 2) && (srcW > 2)) { - pOverlay->HUSF = (((srcW - 2) << 16) + dstW - 3) / (dstW - 2); - } - else { - pOverlay->HUSF = ((srcW << 16) + dstW - 1) / dstW; - } - pOverlay->IntBit = 0x04; - } - /* downscale in horizontal */ - else { - - int tmpW = dstW; - - I = 0x00; - - pOverlay->IntBit = 0x01; - - /* */ - while (srcW >= tmpW) - { - tmpW <<= 1; - I++; - } - - pOverlay->wHPre = (CARD8)(I - 1); - dstW <<= (I - 1); - - f_temp = srcW/dstW; - - /* we don't need to change 4-tap DDA scale if upscale */ - if (f_temp < 1.0) - f_temp = 1.0; - - pOverlay->f_scale = f_temp; - - if ((srcW % dstW)) - pOverlay->HUSF = ((srcW - dstW) << 16) / dstW; - else - pOverlay->HUSF = 0x00; - } - - if (dstH == srcH) { - pOverlay->VUSF = 0x00; - pOverlay->IntBit |= 0x0A; - } - else if (dstH > srcH) { - dstH += 0x02; - /*pOverlay->VUSF = (srcH << 16) / dstH;*/ - if ((dstH > 2) && (srcH > 2)) { - pOverlay->VUSF = (((srcH - 2) << 16) - 32768 + dstH - 3) / (dstH - 2); - } - else { - pOverlay->VUSF = ((srcH << 16) + dstH - 1) / dstH; - } - - pOverlay->IntBit |= 0x08; - } - /* downscale in vertical */ - else { - - CARD32 realI; - - I = realI = srcH / dstH; - pOverlay->IntBit |= 0x02; - - if (I < 2) - { - pOverlay->VUSF = ((srcH - dstH)<<16)/dstH; - } - else - { - if (((srcPitch * I)>>2) > 0xFFF) - { - I = (0xFFF*2/srcPitch); - pOverlay->VUSF = 0xFFFF; - } - else - { - dstH = I * dstH; - - if (srcH % dstH) - pOverlay->VUSF = ((srcH - dstH) << 16) / dstH; - else - pOverlay->VUSF = 0x00; - } - - /* set video frame buffer offset */ - NewPitch = (srcPitch*I); - } - } - - pOverlay->pitch = (CARD16)(NewPitch); - } - -void -set_contrast_factor(XGIPtr pXGI, XGIOverlayPtr pOverlay) -{ - ScrnInfoPtr pScrn = pXGI->pScrn; - CARD16 screenX = pScrn->currentMode->HDisplay; - CARD16 screenY = pScrn->currentMode->VDisplay; - - CARD32 value, SamplePixel, dwTotalPixel; - - CARD16 top, left; - CARD16 bottom, right; - - top = pOverlay->dstBox.y1; - bottom = pOverlay->dstBox.y2; - - if (bottom > screenY) - bottom = screenY; - - left = pOverlay->dstBox.x1; - right = pOverlay->dstBox.x2; - - if (right > screenX) - right = screenX; - - dwTotalPixel = (bottom - top) * (right - left); - - value = (dwTotalPixel - 10000) / 20000; - - if (value > 3 ) - value = 3; - - pOverlay->dwContrastFactor = value; - - switch (value) { - case 1: SamplePixel = 4096; break; - case 2: SamplePixel = 8192; break; - case 3: SamplePixel = 8192; break; - - default: - SamplePixel = 2048; - break; - } - - pOverlay->SamplePixel = (SamplePixel << 10) / dwTotalPixel; - -} - -static void -set_line_buf_size(XGIOverlayPtr pOverlay) -{ - CARD8 preHIDF; - CARD32 dwI; - CARD32 dwSrcWidth = pOverlay->srcW; - int pixelFormat = pOverlay->pixelFormat; - - if ((pixelFormat == PIXEL_FMT_YV12) || - (pixelFormat == PIXEL_FMT_NV12) || - (pixelFormat == PIXEL_FMT_NV21)) - { - preHIDF = pOverlay->wHPre & 0x07; - - if (preHIDF < 2) - { - preHIDF = 2; - } - - if (dwSrcWidth & ~(0xffffff80 << (preHIDF - 2))) - { - dwI = (dwSrcWidth >> (preHIDF + 5)) + 1; - } - else - { - dwI = dwSrcWidth >> (preHIDF + 5); - } - - pOverlay->lineBufSize = dwI * (0x01 << (preHIDF + 2)) - 1; - - } - /* not plane format */ - else - { - if (dwSrcWidth & 0x07) - dwI = (dwSrcWidth >> 3) + 1; - else - dwI = (dwSrcWidth >> 3); - - pOverlay->lineBufSize = dwI; - } -} - -static void -XGIDisplayVideo(ScrnInfoPtr pScrn, XGIPortPrivPtr pPriv) -{ - XGIPtr pXGI = XGIPTR(pScrn); - - short srcPitch = pPriv->srcPitch; - short height = pPriv->height; - XGIOverlayRec overlay; - int srcOffsetX=0, srcOffsetY=0; - int sx=0, sy=0; - - memset(&overlay, 0, sizeof(overlay)); - overlay.pixelFormat = pPriv->id; - overlay.pitch = srcPitch; - overlay.keyOP = 0x03; /* destination colorkey */ - overlay.bobEnable = 0x00; - - overlay.dstBox.x1 = pPriv->drw_x - pScrn->frameX0; - overlay.dstBox.x2 = pPriv->drw_x + pPriv->drw_w - pScrn->frameX0; - overlay.dstBox.y1 = pPriv->drw_y - pScrn->frameY0; - overlay.dstBox.y2 = pPriv->drw_y + pPriv->drw_h - pScrn->frameY0; - - if((overlay.dstBox.x2 < 0) || (overlay.dstBox.y2 < 0)) - return; - - if(overlay.dstBox.x1 < 0) { - srcOffsetX = pPriv->src_w * (-overlay.dstBox.x1) / pPriv->drw_w; - overlay.dstBox.x1 = 0; - } - if(overlay.dstBox.y1 < 0) { - srcOffsetY = pPriv->src_h * (-overlay.dstBox.y1) / pPriv->drw_h; - overlay.dstBox.y1 = 0; - } - - if (pPriv->videoStatus & CLIENT_CAPTURE_ON) - { - /* We use AutoFlip for capture, not need buffer address */ - overlay.PSY = 0x0000; - } - else - { - switch(pPriv->id){ - case PIXEL_FMT_YV12: - sx = (pPriv->src_x + srcOffsetX) & ~7; - sy = (pPriv->src_y + srcOffsetY) & ~1; - - overlay.PSY = pPriv->bufAddr[pPriv->currentBuf] + sx + sy*srcPitch; - overlay.PSV = pPriv->bufAddr[pPriv->currentBuf] + height*srcPitch + ((sx + sy*srcPitch/2) >> 1); - overlay.PSU = pPriv->bufAddr[pPriv->currentBuf] + height*srcPitch*5/4 + ((sx + sy*srcPitch/2) >> 1); - break; - - case PIXEL_FMT_NV12: - case PIXEL_FMT_NV21: - sx = (pPriv->src_x + srcOffsetX) & ~7; - sy = (pPriv->src_y + srcOffsetY) & ~1; - overlay.PSY = pPriv->bufAddr[pPriv->currentBuf] + sx + sy*srcPitch; - overlay.PSV = pPriv->bufAddr[pPriv->currentBuf] + height*srcPitch + ((sx + sy*srcPitch/2) >> 1); - overlay.PSU = overlay.PSV; - break; - - case PIXEL_FMT_YUY2: - case PIXEL_FMT_UYVY: - case PIXEL_FMT_YVYU: - case PIXEL_FMT_RGB6: - case PIXEL_FMT_RGB5: - sx = (pPriv->src_x + srcOffsetX) & ~1; - sy = (pPriv->src_y + srcOffsetY); - - overlay.PSY = pPriv->bufAddr[pPriv->currentBuf] + sx*2 + sy*srcPitch; - break; - - default: - /* ErrorF("UnSurpported Format"); */ - break; - } - - } - - overlay.srcW = pPriv->src_w - (sx - pPriv->src_x); - overlay.srcH = pPriv->src_h - (sy - pPriv->src_y); - - /* set line buffer length */ - set_line_buf_size (&overlay); - - /* set scale factor */ - set_scale_factor (&overlay); - - /* contrast factor */ - set_contrast_factor(pXGI, &overlay); - - SetSelectOverlayReg(pXGI, 0x00); - - SetColorkeyReg(pXGI, pPriv->colorKey); - - /* set overlay */ - SetOverlayReg(pXGI, &overlay); - - /* enable overlay */ - SetEnableOverlayReg(pXGI, TRUE); -} - - -static void -XGIStopVideo(ScrnInfoPtr pScrn, pointer data, Bool exit) -{ - XGIPortPrivPtr pPriv = (XGIPortPrivPtr)data; - XGIPtr pXGI = XGIPTR(pScrn); - - REGION_EMPTY(pScrn->pScreen, &pPriv->clip); - - if(exit) { - - if(pPriv->videoStatus & CLIENT_VIDEO_ON) { - SetEnableOverlayReg(pXGI, FALSE); - } - - if (pPriv->videoStatus & CLIENT_CAPTURE_ON) { - EnableCaptureAutoFlip(pXGI, FALSE); - } - - if(pPriv->fbAreaPtr) { - xf86FreeOffscreenArea(pPriv->fbAreaPtr); - pPriv->fbAreaPtr = NULL; - pPriv->fbSize = 0; - } - - - /* clear all flag */ - pPriv->videoStatus = 0; - - } else { - if(pPriv->videoStatus & CLIENT_VIDEO_ON) { - pPriv->videoStatus |= OFF_TIMER; - pPriv->offTime = currentTime.milliseconds + OFF_DELAY; - } - } -} - - -static int -XGIPutImage( - ScrnInfoPtr pScrn, - short src_x, short src_y, - short drw_x, short drw_y, - short src_w, short src_h, - short drw_w, short drw_h, - int id, unsigned char* buf, - short width, short height, - Bool sync, - RegionPtr clipBoxes, pointer data -){ - XGIPtr pXGI = XGIPTR(pScrn); - XGIPortPrivPtr pPriv = (XGIPortPrivPtr)data; - - int i; - - int totalSize=0; -/* int depth = pXGI->CurrentLayout.bitsPerPixel >> 3; */ - - pPriv->drw_x = drw_x; - pPriv->drw_y = drw_y; - pPriv->drw_w = drw_w; - pPriv->drw_h = drw_h; - pPriv->src_x = src_x; - pPriv->src_y = src_y; - pPriv->src_w = src_w; - pPriv->src_h = src_h; - pPriv->id = id; - pPriv->height = height; - - /* Pixel formats: - 1. YU12: 3 planes: H V - Y sample period 1 1 (8 bit per pixel) - V sample period 2 2 (8 bit per pixel, subsampled) - U sample period 2 2 (8 bit per pixel, subsampled) - - Y plane is fully sampled (width*height), U and V planes - are sampled in 2x2 blocks, hence a group of 4 pixels requires - 4 + 1 + 1 = 6 bytes. The data is planar, ie in single planes - for Y, U and V. - 2. UYVY: 3 planes: H V - Y sample period 1 1 (8 bit per pixel) - V sample period 2 1 (8 bit per pixel, subsampled) - U sample period 2 1 (8 bit per pixel, subsampled) - Y plane is fully sampled (width*height), U and V planes - are sampled in 2x1 blocks, hence a group of 4 pixels requires - 4 + 2 + 2 = 8 bytes. The data is bit packed, there are no separate - Y, U or V planes. - Bit order: U0 Y0 V0 Y1 U2 Y2 V2 Y3 ... - 3. I420: Like YU12, but planes U and V are in reverse order. - 4. YUY2: Like UYVY, but order is - Y0 U0 Y1 V0 Y2 U2 Y3 V2 ... - 5. YVYU: Like YUY2, but order is - Y0 V0 Y1 U0 Y2 V2 Y3 U2 ... - */ - switch(id){ - case PIXEL_FMT_YV12: - case PIXEL_FMT_NV12: - case PIXEL_FMT_NV21: - pPriv->srcPitch = (width + 7) & ~7; - totalSize = (pPriv->srcPitch * height * 3) >> 1; /* Verified */ - break; - case PIXEL_FMT_YUY2: - case PIXEL_FMT_UYVY: - case PIXEL_FMT_YVYU: - case PIXEL_FMT_RGB6: - case PIXEL_FMT_RGB5: - default: - pPriv->srcPitch = ((width << 1) + 3) & ~3; /* Verified */ - totalSize = pPriv->srcPitch * height; - } - - /* make it a multiple of 16 to simplify to copy loop */ - totalSize += 15; - totalSize &= ~15; - printf("PutImage\n"); - /* allocate memory */ - do { - int lines, pitch, depth; - BoxPtr pBox; - - if(totalSize == pPriv->fbSize) - break; - - pPriv->fbSize = totalSize; - - if(pPriv->fbAreaPtr) { - xf86FreeOffscreenArea(pPriv->fbAreaPtr); - } - - depth = (pScrn->bitsPerPixel + 7 ) / 8; - pitch = pScrn->displayWidth * depth; - lines = ((totalSize * 2) / pitch) + 1; - - pPriv->fbAreaPtr = xf86AllocateOffscreenArea(pScrn->pScreen, - pScrn->displayWidth, - lines, 0, NULL, NULL, NULL); - - if(!pPriv->fbAreaPtr) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Allocate video memory fails\n"); - return BadAlloc; - } - - pBox = &(pPriv->fbAreaPtr->box); - pPriv->bufAddr[0] = (pBox->x1 * depth) + (pBox->y1 * pitch); - pPriv->bufAddr[1] = pPriv->bufAddr[0] + totalSize; - - } while(0); - - /* copy data */ - if((pXGI->XvUseMemcpy) || (totalSize < 16)) { - #ifdef NewPath - memcpy(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf], buf, totalSize); - - #else - switch(id){ - case PIXEL_FMT_YV12: - { - BYTE *Y, *V, *U, *srcY, *srcV, *srcU; - - short srcPitch2 = pPriv->srcPitch >> 1; - short height2 = height >> 1; - short width2 = width >> 1; - - Y = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - V = Y + pPriv->srcPitch * height; - U = V + pPriv->srcPitch * height / 4 ; - - srcY = buf; - srcV = srcY + width * height; - srcU = srcV + width * height / 4; -#ifdef OLD - for(i=0; isrcPitch, srcY + i*width, width); - - for(i=0; isrcPitch + j) = *(unsigned char *)(srcY + i*width + j); - } - - for(i=0; i> 1; - - Y = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - VU = Y + pPriv->srcPitch * height; - - srcY = buf; - srcVU = srcY + width * height; - for(i=0; isrcPitch, srcY + i*width, width); - - for(i=0; isrcPitch, srcVU + i*width, width); - break; - } - case PIXEL_FMT_YUY2: - case PIXEL_FMT_UYVY: - case PIXEL_FMT_YVYU: - case PIXEL_FMT_RGB6: - case PIXEL_FMT_RGB5: - { - BYTE *Base = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - - for(i=0; isrcPitch, buf + i*width*2, width*2); -#else - { - int j; - for(j=0; jsrcPitch+j) = *(unsigned char *)(buf+i*width*2+j+1); -*(unsigned char *)(Base+i*pPriv->srcPitch+j+1) = *(unsigned char *)(buf+i*width*2+j); - -/* - if(i==0 &&j<50) - ErrorF("IMAGE[%x]=%x ",j,*(buf+i*width*2+j)); - if(i==0 && j<=50 && (j%5==0)) - ErrorF("\n"); -*/ - } - } -#endif - break; - } - default: - memcpy(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf], buf, totalSize); - break; - } - #endif - - } else { - - #ifdef NewPath - BYTE *Base = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - - for(i=0; isrcPitch >> 1; - short height2 = height >> 1; - short width2 = width >> 1; - int j; - - Y = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - V = Y + pPriv->srcPitch * height; - U = V + pPriv->srcPitch * height / 4 ; - srcY = buf; - srcV = srcY + width * height; - srcU = srcV + width * height / 4; - - for(i=0; isrcPitch*i + j); - - for(i=0; i> 1; - - Y = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - VU = Y + pPriv->srcPitch * height; - - srcY = buf; - srcVU = srcY + width * height; - - for(i=0; isrcPitch*i + j); - - for(i=0; isrcPitch*i + j); - - break; - } - case PIXEL_FMT_YUY2: - case PIXEL_FMT_UYVY: - case PIXEL_FMT_YVYU: - case PIXEL_FMT_RGB6: - case PIXEL_FMT_RGB5: - { - BYTE *Base = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - int j; - for(i=0; isrcPitch+j) = *(buf + width*i + j); - - break; - } - default: - { - BYTE *Base = (BYTE *)(pXGI->FbBase + pPriv->bufAddr[pPriv->currentBuf]); - int j; - for(i=0; ipScreen, &pPriv->clip, clipBoxes)) - { - REGION_COPY(pScrn->pScreen, &pPriv->clip, clipBoxes); - - /* draw these */ - } else { - xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey, clipBoxes); - } /* update cliplist */ - - pPriv->currentBuf ^= 1; - pPriv->videoStatus = CLIENT_VIDEO_ON; - - return Success; -} - - -static int -XGIQueryImageAttributes( - ScrnInfoPtr pScrn, - int id, - unsigned short *w, unsigned short *h, - int *pitches, int *offsets -){ - int pitchY, pitchUV; - int size, sizeY, sizeUV; - - if(*w < IMAGE_MIN_WIDTH) *w = IMAGE_MIN_WIDTH; - if(*h < IMAGE_MIN_HEIGHT) *h = IMAGE_MIN_HEIGHT; - - if(*w > DummyEncoding.width) *w = DummyEncoding.width; - if(*h > DummyEncoding.height) *h = DummyEncoding.height; - - switch(id) { - case PIXEL_FMT_YV12: - *w = (*w + 7) & ~7; - *h = (*h + 1) & ~1; - pitchY = *w; - pitchUV = *w >> 1; - if(pitches) { - pitches[0] = pitchY; - pitches[1] = pitches[2] = pitchUV; - } - sizeY = pitchY * (*h); - sizeUV = pitchUV * ((*h) >> 1); - if(offsets) { - offsets[0] = 0; - offsets[1] = sizeY; - offsets[2] = sizeY + sizeUV; - } - size = sizeY + (sizeUV << 1); - break; - case PIXEL_FMT_NV12: - case PIXEL_FMT_NV21: - *w = (*w + 7) & ~7; - *h = (*h + 1) & ~1; - pitchY = *w; - pitchUV = *w; - if(pitches) { - pitches[0] = pitchY; - pitches[1] = pitchUV; - } - sizeY = pitchY * (*h); - sizeUV = pitchUV * ((*h) >> 1); - if(offsets) { - offsets[0] = 0; - offsets[1] = sizeY; - } - size = sizeY + (sizeUV << 1); - break; - case PIXEL_FMT_YUY2: - case PIXEL_FMT_UYVY: - case PIXEL_FMT_YVYU: - case PIXEL_FMT_RGB6: - case PIXEL_FMT_RGB5: - default: - *w = (*w + 1) & ~1; - pitchY = *w << 1; - if(pitches) pitches[0] = pitchY; - if(offsets) offsets[0] = 0; - size = pitchY * (*h); - break; - } - - return size; -} diff --git a/src/xgi_vidregs.h b/src/xgi_vidregs.h deleted file mode 100644 index babc4da..0000000 --- a/src/xgi_vidregs.h +++ /dev/null @@ -1,154 +0,0 @@ -#ifndef _SIS_VIDREG_H_ -#define _SIS_VIDREG_H_ - -/* VGA standard register */ -#define Index_SR_Graphic_Mode 0x06 -#define Index_SR_RAMDAC_Ctrl 0x07 -#define Index_SR_Threshold_Ctrl1 0x08 -#define Index_SR_Threshold_Ctrl2 0x09 -#define Index_SR_Misc_Ctrl 0x0F -#define Index_SR_DDC 0x11 -#define Index_SR_Feature_Connector_Ctrl 0x12 -#define Index_SR_DRAM_Sizing 0x14 -#define Index_SR_DRAM_State_Machine_Ctrl 0x15 -#define Index_SR_AGP_PCI_State_Machine 0x21 -#define Index_SR_Internal_MCLK0 0x28 -#define Index_SR_Internal_MCLK1 0x29 -#define Index_SR_Internal_DCLK1 0x2B -#define Index_SR_Internal_DCLK2 0x2C -#define Index_SR_Internal_DCLK3 0x2D -#define Index_SR_Ext_Clock_Sel 0x32 -#define Index_SR_Int_Status 0x34 -#define Index_SR_Int_Enable 0x35 -#define Index_SR_Int_Reset 0x36 -#define Index_SR_Power_On_Trap 0x38 -#define Index_SR_Power_On_Trap2 0x39 -#define Index_SR_Power_On_Trap3 0x3A - -/* video registers */ -#define Index_VI_Passwd 0x00 -#define Index_VI_Win_Hor_Disp_Start_Low 0x01 -#define Index_VI_Win_Hor_Disp_End_Low 0x02 -#define Index_VI_Win_Hor_Over 0x03 - -#define Index_VI_Win_Ver_Disp_Start_Low 0x04 -#define Index_VI_Win_Ver_Disp_End_Low 0x05 -#define Index_VI_Win_Ver_Over 0x06 - -#define Index_VI_Disp_Y_Buf_Start_Low 0x07 -#define Index_VI_Disp_Y_Buf_Start_Middle 0x08 -#define Index_VI_Disp_Y_Buf_Start_High 0x09 - -#define Index_VI_U_Buf_Start_Low 0x0A -#define Index_VI_U_Buf_Start_Middle 0x0B -#define Index_VI_U_Buf_Start_High 0x0C - -#define Index_VI_V_Buf_Start_Low 0x0D -#define Index_VI_V_Buf_Start_Middle 0x0E -#define Index_VI_V_Buf_Start_High 0x0F - -#define Index_VI_Disp_Y_Buf_Pitch_Low 0x10 -#define Index_VI_Disp_UV_Buf_Pitch_Low 0x11 -#define Index_VI_Disp_Y_UV_Buf_Pitch_High 0x12 - -#define Index_VI_Disp_Y_Buf_Preset_Low 0x13 -#define Index_VI_Disp_Y_Buf_Preset_Middle 0x14 -#define Index_VI_UV_Buf_Preset_Low 0x15 -#define Index_VI_UV_Buf_Preset_Middle 0x16 -#define Index_VI_Disp_Y_UV_Buf_Preset_High 0x17 - -#define Index_VI_Hor_Post_Up_Scale_Low 0x18 -#define Index_VI_Hor_Post_Up_Scale_High 0x19 -#define Index_VI_Ver_Up_Scale_Low 0x1A -#define Index_VI_Ver_Up_Scale_High 0x1B -#define Index_VI_Scale_Control 0x1C - -#define Index_VI_Play_Threshold_Low 0x1D -#define Index_VI_Play_Threshold_High 0x1E -#define Index_VI_Line_Buffer_Size 0x1F - -/* Destination color key */ -#define Index_VI_Overlay_ColorKey_Red_Min 0x20 -#define Index_VI_Overlay_ColorKey_Green_Min 0x21 -#define Index_VI_Overlay_ColorKey_Blue_Min 0x22 -#define Index_VI_Overlay_ColorKey_Red_Max 0x23 -#define Index_VI_Overlay_ColorKey_Green_Max 0x24 -#define Index_VI_Overlay_ColorKey_Blue_Max 0x25 - -/* Source color key */ -#define Index_VI_Overlay_ChromaKey_Red_Y_Min 0x26 -#define Index_VI_Overlay_ChromaKey_Green_U_Min 0x27 -#define Index_VI_Overlay_ChromaKey_Blue_V_Min 0x28 -#define Index_VI_Overlay_ChromaKey_Red_Y_Max 0x29 -#define Index_VI_Overlay_ChromaKey_Green_U_Max 0x2A -#define Index_VI_Overlay_ChromaKey_Blue_V_Max 0x2B - -#define Index_VI_Contrast_Factor 0x2C - -#define Index_VI_Brightness 0x2D -#define Index_VI_Contrast_Enh_Ctrl 0x2E - -#define Index_VI_Key_Overlay_OP 0x2F - -#define Index_VI_Control_Misc0 0x30 -#define Index_VI_Control_Misc1 0x31 -#define Index_VI_Control_Misc2 0x32 - -#define Index_MPEG_Read_Ctrl0 0x60 -#define Index_MPEG_Read_Ctrl1 0x61 -#define Index_MPEG_Read_Ctrl2 0x62 -#define Index_MPEG_Read_Ctrl3 0x63 -#define Index_MPEG_Ver_Up_Scale_Low 0x64 -#define Index_MPEG_Ver_Up_Scale_High 0x65 - -/* - CRT_2 function control register - */ -#define Index_CRT2_FC_CONTROL 0x00 -#define Index_CRT2_FC_SCREEN_HIGH 0x04 -#define Index_CRT2_FC_SCREEN_MID 0x05 -#define Index_CRT2_FC_SCREEN_LOW 0x06 -#define Index_CRT2_FC_ENABLE_WRITE 0x24 -#define Index_CRT2_FC_VR 0x25 -#define Index_CRT2_FC_VCount 0x27 -#define Index_CRT2_FC_VCount1 0x28 - -/* video attributes - these should probably be configurable on the fly - * so users with different desktop sizes can keep - * captured data off the desktop - */ -#define _VINWID 704 -#define _VINHGT _VINHGT_NTSC -#define _VINHGT_NTSC 240 -#define _VINHGT_PAL 290 -#define _VIN_WINDOW (704 * 291 * 2) -#define _VBI_WINDOW (704 * 64 * 2) - -#define _VIN_FIELD_EVEN 1 -#define _VIN_FIELD_ODD 2 -#define _VIN_FIELD_BOTH 4 - -#define vc_index_offset 0x00 -#define vc_data_offset 0x01 -#define vi_index_offset 0x02 -#define vi_data_offset 0x03 -#define crt2_index_offset 0x04 -#define crt2_port_offset 0x05 -#define sr_index_offset 0x44 -#define sr_data_offset 0x45 -#define cr_index_offset 0x54 -#define cr_data_offset 0x55 -#define input_stat 0x5A - -/* i2c registers */ -#define X_INDEXREG 0x14 -#define X_PORTREG 0x15 -#define X_DATA 0x0f -#define I2C_SCL 0x00 -#define I2C_SDA 0x01 -#define I2C_DELAY 10 - -/* mmio registers */ -#define REG_PRIM_CRT_COUNTER 0x8514 - -#endif /* _SIS_VIDREG_H_ */