📄 resources.c
字号:
the reserved FIFO space will only be released when the port is released
@Input *psDevInfo :
@Input ui32SlavePortType :
@Input ui32Bytes :
@Return PVRSRV_ERROR :
******************************************************************************/
IMG_EXPORT
PVRSRV_ERROR IMG_CALLCONV PVRSRVRelease2DFifoSpace (PVRSRV_DEV_INFO *psDevInfo,
IMG_UINT32 ui32Bytes)
{
IMG_UINT32 *pui32Reserve = &psDevInfo->sDeviceSpecific.s3D.ui32BytesReserved2d;
if (*pui32Reserve < ui32Bytes)
{
PVR_DPF((PVR_DBG_ERROR,"PVRSRVRelease2DFifoSpace: (bytes to release) > (bytes reserved)"));
return PVRSRV_ERROR_INVALID_PARAMS;
}
else
{
*pui32Reserve -= ui32Bytes;
}
return PVRSRV_OK;
}
/*!
******************************************************************************
@Function PVRSRVRelease3DFifoSpace
@Description
Utlity: Releases FIFO space reserved for a given port. If this function is not called
the reserved FIFO space will only be released when the port is released
@Input *psDevInfo :
@Input ui32SlavePortType :
@Input ui32Bytes :
@Return PVRSRV_ERROR :
******************************************************************************/
IMG_EXPORT
PVRSRV_ERROR IMG_CALLCONV PVRSRVRelease3DFifoSpace (PVRSRV_DEV_INFO *psDevInfo,
IMG_UINT32 ui32Bytes)
{
IMG_UINT32 *pui32Reserve = &psDevInfo->sDeviceSpecific.s3D.ui32BytesReservedTA;
if (*pui32Reserve < ui32Bytes)
{
PVR_DPF((PVR_DBG_ERROR,"PVRSRVRelease3DFifoSpace: (bytes to release) > (bytes reserved)"));
return PVRSRV_ERROR_INVALID_PARAMS;
}
else
{
*pui32Reserve -= ui32Bytes;
}
return PVRSRV_OK;
}
#ifdef FIX_HW_PRN_335
/*!
******************************************************************************
@Function PVRSRVDiscardCompletedTAScene
@Description
USER MODE FUNCTION
resets andfrees memory allocated to current scene.
@Input psDevData : UM devdata
@Input psTARenderInfo : Current TA/Render Info
@Input psHWInfo : HW Info structure
@Return PVRSRV_ERROR :
******************************************************************************/
IMG_EXPORT
PVRSRV_ERROR IMG_CALLCONV PVRSRVDiscardCompletedTAScene (PVRSRV_DEV_INFO *psDevInfo,
PVRSRV_TARENDERINFO *psTARenderInfo,
PVRSRV_HW_INFO *psHWInfo)
{
DEVICE3D *ps3D = &psDevInfo->sDeviceSpecific.s3D;
PVR3DIF_SHAREDDATA *psSharedData = psTARenderInfo->psSharedData;
/* have we already discarded the current scene? */
if(psSharedData->bSceneInvalidated)
{
return PVRSRV_OK;
}
/* Wait TA to complete */
if(PollForValue ((volatile IMG_UINT32 *)&ps3D->bTAIdle,
IMG_TRUE,
0xFFFFFFFF,
MAX_HW_TIME_US/WAIT_TRY_COUNT,
WAIT_TRY_COUNT) != PVRSRV_OK)
{
PVR_DPF((PVR_DBG_ERROR, "PVRSRVDiscardTAScene: Failed to get TA Idle"));
goto ErrorExit;
}
/* OK, discard the scene */
WriteHWReg(psHWInfo->pvRegsBase, MBX1_TAGLOBREG_EVM_TA_TIMEOUT, 1);
PDUMPREG(psTARenderInfo->psPDContext, PDUMPTAGS_REG_MBX, MBX1_TAGLOBREG_EVM_TA_TIMEOUT, 1);
/* and wait for required state */
if(PollForValue ((volatile IMG_UINT32 *)&ps3D->bEVMDAlloc,
IMG_TRUE,
0xFFFFFFFF,
MAX_HW_TIME_US/WAIT_TRY_COUNT,
WAIT_TRY_COUNT) != PVRSRV_OK)
{
PVR_DPF((PVR_DBG_ERROR, "PVRSRVDiscardTAScene: Failed to get EVM Dalloc"));
goto ErrorExit;
}
if(PollForValue ((volatile IMG_UINT32 *)&ps3D->bTATimeOut,
IMG_TRUE,
0xFFFFFFFF,
MAX_HW_TIME_US/WAIT_TRY_COUNT,
WAIT_TRY_COUNT) != PVRSRV_OK)
{
PVR_DPF((PVR_DBG_ERROR, "PVRSRVDiscardTAScene: Failed to get TA Timeout"));
goto ErrorExit;
}
PDUMPPOL(psTARenderInfo->psPDContext, PDUMPTAGS_REG_MBX, MBX1_TAGLOBREG_INTSTATUS, MBX1_INT_TA_TIMEOUT|MBX1_INT_EVM_DALLOC, MBX1_INT_TA_TIMEOUT|MBX1_INT_EVM_DALLOC, 0, 10, 10000);
PDUMPREG(psTARenderInfo->psPDContext, PDUMPTAGS_REG_MBX, MBX1_GLOBREG_INT_CLEAR, MBX1_INT_TA_TIMEOUT|MBX1_INT_EVM_DALLOC);
/* clear state */
ps3D->bEVMDAlloc = IMG_FALSE;
ps3D->bTATimeOut = IMG_FALSE;
/* Clear context status */
psSharedData->aui32ContextStatus[psSharedData->ui32CurrentRenderData] = PVR3DIF_3DCTL_FREE;
/* free the HW context id */
FreeHWContextID(psDevInfo, psSharedData->aui32HWContextID[psSharedData->ui32CurrentRenderData]);
/* invalidate current scene */
psSharedData->bSceneInvalidated = IMG_TRUE;
/* clear the stream error flag */
ps3D->bTAStreamErrorInterrupt = IMG_FALSE;
#ifdef FIX_HW_PRN_296
/* record we got a stream error */
ps3D->bLastContextStreamError = IMG_TRUE;
#endif
ErrorExit :
return PVRSRV_OK;
}
#endif
/*!
******************************************************************************
@Function PVRSRVDiscardTAScene
@Description
USER MODE FUNCTION
Stops TA midscene, resets and frees memory allocated to current scene.
@Input psDevData : UM devdata
@Input psTARenderInfo : Current TA/Render Info
@Input psHWInfo : HW Info structure
@Input bDoIgnoreStreamError : are we here because of a stream error?
@Return PVRSRV_ERROR :
******************************************************************************/
IMG_EXPORT
PVRSRV_ERROR IMG_CALLCONV PVRSRVDiscardTAScene (PVRSRV_DEV_INFO *psDevInfo,
PVRSRV_TARENDERINFO *psTARenderInfo,
PVRSRV_HW_INFO *psHWInfo,
IMG_BOOL bDoIgnoreStreamError)
{
DEVICE3D *ps3D = &psDevInfo->sDeviceSpecific.s3D;
PVR3DIF_SHAREDDATA *psSharedData = psTARenderInfo->psSharedData;
PVRSRV_ERROR eError;
IMG_UINT32 i;
IMG_BOOL bTimeout;
IMG_BOOL bStart;
IMG_UINT32 uiStart;
/* have we already discarded the current scene? */
if(psSharedData->bSceneInvalidated)
{
return PVRSRV_OK;
}
if(bDoIgnoreStreamError)
{
/*
if we got a stream error then the we may need to send multiple terminates
before the TA recognises one as a terminate]
*/
for (i=0; i<100; i++)
{
eError = StopTA(psDevInfo, psHWInfo, IMG_TRUE, IMG_TRUE, psTARenderInfo);
if (eError == PVRSRV_OK)
break;
}
}
else
{
for (i=0; i<100; i++)
{
eError = StopTA(psDevInfo, psHWInfo, IMG_FALSE, IMG_TRUE, psTARenderInfo);
if (eError == PVRSRV_OK)
break;
}
}
if(eError != PVRSRV_OK)
{
return eError;
}
/*
EVM dalloc is used for the render too so we need to block
all render processing then poll for any the current render to finish
then we can proceed
*/
ps3D->bBlock3DProcessing = IMG_TRUE;
if(PollForValue ((volatile IMG_UINT32 *)&ps3D->b3DIdle,
IMG_TRUE,
0xFFFFFFFF,
MAX_HW_TIME_US/WAIT_TRY_COUNT,
WAIT_TRY_COUNT) != PVRSRV_OK)
{
PVR_DPF((PVR_DBG_ERROR, "PVRSRVDiscardTAScene: Failed to flush previous render"));
goto ErrorExit;
}
/* OK, discard the scene */
WriteHWReg(psHWInfo->pvRegsBase, MBX1_TAGLOBREG_EVM_TA_TIMEOUT, 1);
PDUMPREG(psTARenderInfo->psPDContext, PDUMPTAGS_REG_MBX, MBX1_TAGLOBREG_EVM_TA_TIMEOUT, 1);
/* and wait for required state */
if(PollForValue ((volatile IMG_UINT32 *)&ps3D->bEVMDAlloc,
IMG_TRUE,
0xFFFFFFFF,
MAX_HW_TIME_US/WAIT_TRY_COUNT,
WAIT_TRY_COUNT) != PVRSRV_OK)
{
PVR_DPF((PVR_DBG_ERROR, "PVRSRVDiscardTAScene: Failed to get EVM Dalloc"));
goto ErrorExit;
}
if(PollForValue ((volatile IMG_UINT32 *)&ps3D->bTATimeOut,
IMG_TRUE,
0xFFFFFFFF,
MAX_HW_TIME_US/WAIT_TRY_COUNT,
WAIT_TRY_COUNT) != PVRSRV_OK)
{
PVR_DPF((PVR_DBG_ERROR, "PVRSRVDiscardTAScene: Failed to get TA Timeout"));
goto ErrorExit;
}
PDUMPPOL(psTARenderInfo->psPDContext, PDUMPTAGS_REG_MBX, MBX1_TAGLOBREG_INTSTATUS, MBX1_INT_TA_TIMEOUT|MBX1_INT_EVM_DALLOC, MBX1_INT_TA_TIMEOUT|MBX1_INT_EVM_DALLOC, 0, 10, 10000);
PDUMPREG(psTARenderInfo->psPDContext, PDUMPTAGS_REG_MBX, MBX1_GLOBREG_INT_CLEAR, MBX1_INT_TA_TIMEOUT|MBX1_INT_EVM_DALLOC);
/* clear state */
ps3D->bEVMDAlloc = IMG_FALSE;
ps3D->bTATimeOut = IMG_FALSE;
/*
start dummy processing
*/
psDevInfo->bDummyProcessing = IMG_TRUE;
bTimeout = IMG_TRUE;
bStart = IMG_FALSE;
uiStart = 0;
if (psSharedData->aui32ContextStatus[psSharedData->ui32CurrentRenderData] != PVR3DIF_3DCTL_FREE)
{
do
{
SysKickCmdProc (psHWInfo->pui32KickerAddr);
if (bStart == IMG_FALSE)
{
bStart = IMG_TRUE;
uiStart = HostClockus();
}
HostWaitus(MAX_HW_TIME_US/WAIT_TRY_COUNT);
if (psSharedData->aui32ContextStatus[psSharedData->ui32CurrentRenderData] == PVR3DIF_3DCTL_FREE)
{
bTimeout = IMG_FALSE;
break;
}
HostReleaseThreadQuanta();
} while ((HostClockus() - uiStart) < MAX_HW_TIME_US);
}
if (bTimeout == IMG_TRUE)
{
PVR_DPF((PVR_DBG_ERROR, "PVRSRVDiscardTAScene: Failed to dummy process render of current scene"));
goto ErrorExit;
}
/*
stop dummy processing
*/
psDevInfo->bDummyProcessing = IMG_FALSE;
/* invalidate current scene */
psSharedData->bSceneInvalidated = IMG_TRUE;
/* clear the stream error flag */
ps3D->bTAStreamErrorInterrupt = IMG_FALSE;
#ifdef FIX_HW_PRN_296
/* record we got a stream error */
ps3D->bLastContextStreamError = IMG_TRUE;
#endif
ErrorExit :
/* resume command processing */
ps3D->bBlock3DProcessing = IMG_FALSE;
return PVRSRV_OK;
}
/*!
******************************************************************************
@Function PVRSRVFlushQueue
@Description
USER MODE FUNCTION
empties queue
@Input psQueueInfo : q info
@Return PVRSRV_ERROR :
******************************************************************************/
IMG_EXPORT
PVRSRV_ERROR IMG_CALLCONV PVRSRVFlushQueue (PVRSRV_QUEUE_INFO *psQueueInfo)
{
IMG_UINT32 i;
IMG_BOOL bStart;
IMG_UINT32 uiStart;
bStart = IMG_FALSE;
uiStart = 0;
i = 0;
do
{
if (psQueueInfo->ui32ReadOffset == psQueueInfo->ui32WriteOffset)
{
return PVRSRV_OK;
}
else if (i > 100)
{
SysKickCmdProc (psQueueInfo->pui32KickerAddr);
HostReleaseThreadQuanta();
}
if (bStart == IMG_FALSE)
{
bStart = IMG_TRUE;
uiStart = HostClockus();
}
HostWaitus(MAX_HW_TIME_US/WAIT_TRY_COUNT);
i++;
} while ((HostClockus() - uiStart) < MAX_HW_TIME_US);
PVR_DPF((PVR_DBG_ERROR, "PVRSRVFlushQueue: Failed to flush queue"));
return PVRSRV_ERROR_GENERIC;
}
/*!
******************************************************************************
@Function PollForValue
@Description
Polls for a value to match a masked read of sysmem
@Input pui32LinMemAddr : CPU linear address of the mem to poll
@Input ui32Value : req'd value
@Input ui32Mask : Mask
@Input ui32Waitus : wait between tries (us)
@Input ui32Tries : number of tries
@Return PVRSRV_ERROR :
******************************************************************************/
IMG_EXPORT
PVRSRV_ERROR PollForValue ( volatile IMG_UINT32* pui32LinMemAddr,
IMG_UINT32 ui32Value,
IMG_UINT32 ui32Mask,
IMG_UINT32 ui32Waitus,
IMG_UINT32 ui32Tries)
{
IMG_BOOL bStart;
IMG_UINT32 uiStart;
bStart = IMG_FALSE;
uiStart = 0;
do
{
if ((*pui32LinMemAddr & ui32Mask) == ui32Value)
{
return PVRSRV_OK;
}
if (bStart == IMG_FALSE)
{
bStart = IMG_TRUE;
uiStart = HostClockus();
}
HostWaitus(ui32Waitus);
} while ((HostClockus() - uiStart) < (ui32Tries * ui32Waitus));
return PVRSRV_ERROR_GENERIC;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -