📄 decoder.c
字号:
g_M24VAState.sIDCTSlavePort.pui32SlavePortLinAddr = g_M24VAState.sHWInfo.sDeviceSpecific.sM24VA.pvSPIDCT;
g_M24VAState.sIDCTSlavePort.ui32SPAddOn = 0;
/* An IDCT buffer is not in use. */
g_M24VAState.sIDCTSlavePort.pSPBufferBase = NULL;
g_M24VAState.sIDCTSlavePort.pSPBuffer = NULL;
g_M24VAState.sIDCTSlavePort.pSPFlushThreshold = NULL;
g_M24VAState.sIZZSlavePort.pui32SlavePortLinAddr = g_M24VAState.sHWInfo.sDeviceSpecific.sM24VA.pvSPIDCT;
g_M24VAState.sIZZSlavePort.pSPBufferBase = g_M24VAState.aui32IZZWriteBuffer;
g_M24VAState.sIZZSlavePort.pSPBuffer = g_M24VAState.aui32IZZWriteBuffer;
g_M24VAState.sIZZSlavePort.pSPFlushThreshold = &g_M24VAState.aui32IZZWriteBuffer[M24VA_SW_IZZ_FIFO_SIZE];
g_M24VAState.sIZZSlavePort.ui32SPAddOn = 0;
/*************************************************************************/
g_M24VAState.ui32CurrentProcessID = (IMG_UINT32) GetOwnerProcess();
g_M24VAState.pui32DeviceResource = (IMG_UINT32*) &(g_M24VAState.sM24VADevData.psDevInfoKM->sDeviceSpecific.sMpeg.hDeviceResource);
/* Soft reset the core to ensure that it is in a known state */
M24VA_Reset();
return(M24VAError_OK);
}
/*****************************************************************************
FUNCTION : M24VA_Configuration
PURPOSE : Return M24VA configuration
PARAMETERS : pui32Config - location to return configuration data
RETURNS : M24VAError
Notes :
*****************************************************************************/
M24VAError PVRAPI M24VA_Configuration(IMG_UINT32 *pui32Config)
{
*pui32Config = 0;
#ifndef IMG_M24VAg
{
IMG_UINT32 ui32Cfg;
ui32Cfg = (M24VA_READREG(M24VAREG_CORE_ID) & M24VA_CORE_ID_CONFIG_MASK) >> M24VA_CORE_ID_CONFIG_SHIFT;
if(ui32Cfg & 1) *pui32Config |= M24VA_CONFIG_FORMAT_CONVERSION_SUPPORTED;
if(ui32Cfg & 2) *pui32Config |= M24VA_CONFIG_IZZ_IDCT_SUPPORTED;
}
#endif
return(M24VAError_OK);
}
/*****************************************************************************
FUNCTION : M24VA_Deinitialise
PURPOSE : De-initialise m24va interface
PARAMETERS :
RETURNS : M24VAError
Notes : Unmaps hardware views
*****************************************************************************/
M24VAError PVRAPI M24VA_Deinitialise()
{
M24VAError eError = M24VAError_OK;
if(!g_M24VAState.bHardwareInUse)
{
return(M24VAError_NotInitialised);
}
/* Release hardware */
{
DRVESC_M24VA_ACQUIRE_PARAMS sM24VAAcquire;
sM24VAAcquire.dwAcquire = FALSE;
sM24VAAcquire.dwProcessID = GetCurrentProcessId();
if(ExtEscape(g_M24VAState.hdcDriver, DRVESC_M24VA_ACQUIRE, 0, NULL,
sizeof(sM24VAAcquire), (LPSTR)&sM24VAAcquire) < 0)
{
eError = M24VAError_HardwareNotAvailable;
}
if(g_M24VAState.hServices)
{
PVRSRVConnectMPEGApplication(&g_M24VAState.sM24VADevData, IMG_FALSE);
PVRSRVReleaseHWInfo(&g_M24VAState.sM24VADevData, &g_M24VAState.sHWInfo);
PVRSRVReleaseDeviceData(&g_M24VAState.sM24VADevData);
PVRSRVDisconnect(g_M24VAState.hServices);
g_M24VAState.hServices = NULL;
}
if(g_M24VAState.hdcDriver)
{
ReleaseDC(NULL, g_M24VAState.hdcDriver);
g_M24VAState.hdcDriver = NULL;
}
}
g_M24VAState.bHardwareInUse = FALSE;
return(eError);
}
/*****************************************************************************
FUNCTION : M24VA_Reset
PURPOSE : S/W Reset of M24VA
PARAMETERS :
RETURNS : M24VAError
Notes :
*****************************************************************************/
PVRAPI M24VAError M24VA_Reset()
{
AcquireMPEG();
M24VA_WRITEREG(M24VAREG_SOFT_RESET, 1, NULL);
g_M24VAState.sCMDSlavePort.iu32SPFree = 0;
g_M24VAState.sCMDSlavePort.pSPBuffer = g_M24VAState.sCMDSlavePort.pSPBufferBase;
g_M24VAState.sIDCTSlavePort.iu32SPFree = 0;
g_M24VAState.sIDCTSlavePort.pSPBuffer = NULL; /* An IDCT buffer is not in use. */
g_M24VAState.sIZZSlavePort.iu32SPFree = 0;
g_M24VAState.sIZZSlavePort.pSPBuffer = g_M24VAState.sIZZSlavePort.pSPBufferBase;
M24VA_WRITEREG(M24VAREG_SOFT_RESET, 0, NULL);
/* Clear MC and colour space conversion comlete flags */
M24VA_WRITEREG(M24VAREG_INTERRUPT_CLEAR, M24VA_INTERRUPT_MC | M24VA_INTERRUPT_YUVCONV, NULL);
ReleaseMPEG();
return(M24VAError_OK);
}
/*****************************************************************************
FUNCTION : M24VA_FrameDimensions
PURPOSE : Setup Frame dimensions
PARAMETERS : Frame dimensions in pixels
RETURNS : M24VAError
Notes :
*****************************************************************************/
M24VAError PVRAPI M24VA_FrameDimensions(IMG_UINT32 ui32Height, IMG_UINT32 ui32Width)
{
M24VA_PDUMP(("-- Image dimensions are %dx%d\n", ui32Width, ui32Height));
AcquireMPEG();
M24VA_WRITEREG(M24VAREG_IMAGE_DIMENSIONS,(ui32Width << M24VA_IMG_DIM_WIDTH_SHIFT) |
(ui32Height << M24VA_IMG_DIM_HEIGHT_SHIFT),
NULL);
ReleaseMPEG();
g_M24VAState.ui32Width = ui32Width;
g_M24VAState.ui32Height = ui32Height;
return(M24VAError_OK);
}
/*****************************************************************************
FUNCTION : M24VA_FrameAllocate
PURPOSE : Allocate frame buffers
PARAMETERS :
RETURNS : M24VAError
Notes :
*****************************************************************************/
PVRAPI M24VAError M24VA_FrameAllocate(SMSurface *phFrames, IMG_UINT32 ui32FrameCnt)
{
IMG_UINT32 ui32Loop;
for(ui32Loop = 0; ui32Loop < ui32FrameCnt; ui32Loop++)
{
PINT_SM_HANDLE pSurface;
pSurface = M24VA_FRAMEALLOCATE(g_M24VAState.ui32Width,
g_M24VAState.ui32Height,
M24VA_SURF_FORMAT_420);
if(!pSurface)
{
return(M24VAError_OutOfMemory);
}
phFrames[ui32Loop] = (SMSurface) pSurface;
}
return(M24VAError_OK);
}
/*****************************************************************************
FUNCTION : M24VA_FrameFree
PURPOSE : Free frame buffers
PARAMETERS :
RETURNS : M24VAError
Notes :
*****************************************************************************/
M24VAError PVRAPI M24VA_FrameFree(SMSurface *phFrames, IMG_UINT32 ui32FrameCnt)
{
IMG_UINT32 uint32Loop;
PINT_SM_HANDLE pSurf = (PINT_SM_HANDLE) phFrames[0];
if (pSurf->bDirectDrawActive)
{
return M24VAError_IllegalFunctionCall;
}
M24VA_FlushHardware(TRUE, TRUE);
for(uint32Loop = 0; uint32Loop < ui32FrameCnt; uint32Loop++)
{
PINT_SM_HANDLE pSurface = (PINT_SM_HANDLE) phFrames[uint32Loop];
if(pSurface) M24VA_FRAMEFREE(pSurface);
phFrames[uint32Loop] = (SMSurface) NULL;
}
return(M24VAError_OK);
}
/*****************************************************************************
FUNCTION : M24VA_BeginFrame
PURPOSE : Begin frame
PARAMETERS :
RETURNS : M24VAError
Notes :
*****************************************************************************/
M24VAError PVRAPI M24VA_BeginFrame(SMSurface hOutputSurface, IMG_BOOL bEnableIDCT)
{
PINT_SM_HANDLE pSurface = (PINT_SM_HANDLE) hOutputSurface;
PVRSRV_SYNC_INFO *psSyncInfo;
IMG_UINT32 ui32Counter = 0;
enum {eTIMEOUT = 50000};
if(pSurface->eFormat != M24VA_SURF_FORMAT_420)
{
return(M24VAError_IncorrectSurfaceFormat);
}
if (pSurface->bDirectDrawActive == IMG_FALSE)
{
psSyncInfo = pSurface->psMemInfo->psSyncInfo;
while (psSyncInfo->ui32ReadOpsComplete < psSyncInfo->ui32ReadOpsPending)
{
StallExecution(10);
if (++ui32Counter >= eTIMEOUT)
{
return M24VAError_SurfaceUnavailable;
}
}
}
AcquireMPEG();
/* Setup iDCT mode */
#ifndef IMG_M24VAg
/* Must not write IDCT data within 8 Marathon cycles of this command */
M24VA_WRITEREG(M24VAREG_ENABLE_IDCT, bEnableIDCT ? M24VA_IDCT_ENABLE : 0, NULL);
#endif
/* Setup reference frame */
M24VA_WRITEREG(M24VAREG_OUTPUT_BASE,(DWORD)(pSurface->ui32FBOffset) >> M24VAREG_BASE_SHIFT,
pSurface);
M24VA_WRITEREG(M24VAREG_STRIDE_SIZE, pSurface->ui32Stride >>3, NULL);
ReleaseMPEG();
if(!g_M24VAState.bDummyImageWriteSent)
{
/* Send dummy image write to ensure that the last address written registers have a
value. Required to ensure that the flush hardware function works correctly. */
M24VA_WriteMCCmdData(M24VA_CMD_IMAGE_WRITE | M24VA_IMAGE_WRITE_WIDTH_8 |
M24VA_IMAGE_WRITE_HGHT_8);
g_M24VAState.bDummyImageWriteSent = TRUE;
}
return(M24VAError_OK);
}
/*****************************************************************************
FUNCTION : M24VA_EndFrame
PURPOSE : End frame
PARAMETERS :
RETURNS : M24VAError
Notes :
*****************************************************************************/
M24VAError PVRAPI M24VA_EndFrame(IMG_BOOL bFlushHardware)
{
if(bFlushHardware || g_eScriptMode != M24VA_NoScript)
{
M24VA_FlushHardware(TRUE,FALSE);
}
else
{
AcquireMPEG();
M24VA_SPBufferFlush(&g_M24VAState.sCMDSlavePort);
M24VA_SPBufferFlush(&g_M24VAState.sIZZSlavePort);
ReleaseMPEG();
}
return(M24VAError_OK);
}
/*****************************************************************************
FUNCTION : M24VA_AbortFrame
PURPOSE : Abort Frame
PARAMETERS :
RETURNS : M24VAError
Notes :
*****************************************************************************/
M24VAError PVRAPI M24VA_AbortFrame()
{
M24VA_Reset();
return(M24VAError_OK);
}
/*****************************************************************************
FUNCTION : M24VA_SetReferenceFrameAddress
PURPOSE : Setup referece frames
PARAMETERS :
RETURNS : M24VAError
Notes :
*****************************************************************************/
M24VAError PVRAPI M24VA_SetReferenceFrameAddress(IMG_UINT32 ui32FrameNo, SMSurface hSurface)
{
DWORD dwRefRegister;
PINT_SM_HANDLE pSurface = (PINT_SM_HANDLE) hSurface;
if(pSurface->eFormat != M24VA_SURF_FORMAT_420)
{
return(M24VAError_IncorrectSurfaceFormat);
}
switch(ui32FrameNo)
{
case 1: dwRefRegister = M24VAREG_REF1_BASE; break;
case 2: dwRefRegister = M24VAREG_REF2_BASE; break;
default: return(M24VAError_InvalidParameter);
}
AcquireMPEG();
M24VA_WRITEREG(dwRefRegister,(DWORD)(pSurface->ui32FBOffset) >> M24VAREG_BASE_SHIFT,
pSurface);
ReleaseMPEG();
return(M24VAError_OK);
}
/*****************************************************************************
FUNCTION : M24VA_FrameBeginAccess
PURPOSE : Access surface
PARAMETERS :
RETURNS : M24VAError
Notes :
*****************************************************************************/
M24VAError PVRAPI M24VA_FrameBeginAccess(SMSurface hSurface,
IMG_UINT8 **ppuint8FrameAddress,
IMG_UINT32 *pui32FrameStride,
IMG_BOOL bFlushHardware)
{
PINT_SM_HANDLE pSurface = (PINT_SM_HANDLE) hSurface;
/* Return error if application is using DirectDraw */
if (pSurface->bDirectDrawActive)
{
return M24VAError_IllegalFunctionCall;
}
*ppuint8FrameAddress = pSurface->pui8LinAddress;
if(pui32FrameStride)
{
*pui32FrameStride = pSurface->ui32Stride;
}
if(bFlushHardware)
{
M24VA_FlushHardware(TRUE, TRUE);
}
return(M24VAError_OK);
}
/*****************************************************************************
FUNCTION : M24VA_FrameEndAccess
PURPOSE : End direct access to surface
PARAMETERS :
RETURNS : M24VAError
Notes :
*****************************************************************************/
M24VAError PVRAPI M24VA_FrameEndAccess(SMSurface hSurface)
{
PINT_SM_HANDLE pSurface = (PINT_SM_HANDLE) hSurface;
/* Return error if application is using DirectDraw */
if (pSurface->bDirectDrawActive)
{
return M24VAError_IllegalFunctionCall;
}
return(M24VAError_OK);
}
/*****************************************************************************
FUNCTION : M24VA_WriteMCCmdData
PURPOSE : Write Motion compensation command data
PARAMETERS :
RETURNS : M24VAError
Notes :
*****************************************************************************/
M24VAError PVRAPI M24VA_WriteMCCmdData(IMG_UINT32 ui32Data)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -