📄 pdpregcontrol.cpp
字号:
PARAMETERS :
RETURNS : void
*****************************************************************************/
void PDPRegControl::WriteReg ( WORD wOffset , DWORD dwValue )
{
m_pdwRegBase[wOffset/4]=dwValue;
#ifdef PDPPDUMP
PDumpReg(PDUMPTAGS_REG_PDP,wOffset,dwValue);
#endif
}
/*****************************************************************************
FUNCTION : WriteReg
Description: Writes the given value to the reqested register
PARAMETERS :
RETURNS : void
*****************************************************************************/
void PDPRegControl::WriteBlockingReg ( WORD wOffset , DWORD dwValue )
{
DWORD dwTimeout=400000000;
do
{
// Should we put a timeout here? Probably
m_pdwRegBase[wOffset/4]=dwValue;
dwTimeout--;
if(dwTimeout==0)
{
PVR_DPF((PVR_DBG_ERROR, "Timeout writing 0x%08x to register 0x%04x",dwValue,wOffset));
break;
}
}while(m_pdwRegBase[wOffset/4]!=dwValue);
#ifdef PDPPDUMP
PDumpReg(PDUMPTAGS_REG_PDP,wOffset,dwValue);
#endif
}
/*****************************************************************************
FUNCTION : ReadReg
Description: returns the requested register
PARAMETERS : WORD wOffset
RETURNS : DWORD requested register value
*****************************************************************************/
DWORD PDPRegControl::ReadReg ( WORD wOffset )
{
return m_pdwRegBase[wOffset/4];
}
/*****************************************************************************
FUNCTION : AddReg
Description: puts the requested register write in the pending buffer
PARAMETERS : WORD wOffset,DWORD dwValue
RETURNS : DWORD 0 = success, 1 =failure
*****************************************************************************/
DWORD PDPRegControl::AddReg(WORD wOffset,DWORD dwValue)
{
if( (m_nIndex-(m_nBufferNumber*(m_wSize/2)) + 2) < m_wSize/2 )
{
m_aListLoader[m_nIndex]=(DWORD)wOffset;
m_aListLoader[m_nIndex+1]=dwValue;
m_nIndex+=2;
#ifdef PDPPDUMP
PDumpReg(PDUMPTAGS_REG_PDP,wOffset,dwValue);
#endif
}
else
{
// we could hit the buffer now and wait until the next buffer is free...
return 1;
}
return 0;
}
/*****************************************************************************
FUNCTION : SendRegs
Description: Actions the currently pending buffer
PARAMETERS :
RETURNS : DWORD 0
*****************************************************************************/
DWORD PDPRegControl::SendRegs()
{
int nIndex=0;
nIndex=m_nBufferNumber*m_wSize/2;
DWORD dwWaitCount=0;
// first wait for any outstanding list to have been started...
while((*m_pdwListControl & (1<<23)))
{
dwWaitCount++;
}
// wait for the loader to be inactive
while(!(*m_pdwListStatus & (1<<23)))
{
dwWaitCount++;
}
*m_pdwListControl= (((m_nIndex-nIndex)/2)<<24) | (1<<23) | ((m_dwListPhysBase + (m_nBufferNumber * (m_wSize/2) * sizeof(DWORD)))>>4);
m_nBufferNumber=1-m_nBufferNumber;
m_nIndex=m_nBufferNumber*m_wSize/2;
return 0;
}
/*********************************************************************************
This is the PDPReg Class implementation, it has not been given it's own file
as it is a very small class, only used when pdumping is enabled and is intimatly
associated with the register control class
*********************************************************************************/
#ifdef PDUMP
/*****************************************************************************
FUNCTION : CreateRegisterMapping
Description: Creates a pointer from a base address and an offset
PARAMETERS : volatile PDWORD m_pdwRegBase , WORD wOffset
RETURNS : nothing
*****************************************************************************/
void PDPReg::CreateRegisterMapping(volatile PDWORD pdwRegBase,WORD wOffset)
{
m_pdwReg=&pdwRegBase[wOffset/4];
}
/*****************************************************************************
FUNCTION : =
Description: assigns a dword value to the m_pdwReg pointer location
PARAMETERS : const DWORD dwValue
RETURNS :
*****************************************************************************/
void PDPReg::operator=(const DWORD dwValue)
{
// here we need to extract the wOffset Value
#ifdef PDPPDUMP
PDumpReg(PDUMPTAGS_REG_PDP,m_wOffset,dwValue);
#endif
*m_pdwReg=dwValue;
}
/*****************************************************************************
FUNCTION : PDPReg
Description: Constructor function that sets up the register mapping
PARAMETERS : volatile PDWORD pdwRegBase,WORD wOffset
RETURNS : this
*****************************************************************************/
PDPReg::PDPReg(volatile PDWORD pdwRegBase,WORD wOffset)
{
m_wOffset=wOffset;
CreateRegisterMapping(pdwRegBase,wOffset);
}
/*****************************************************************************
FUNCTION : (DWORD)
Description: Overloaded copy function that gives the value of the member pointer location
PARAMETERS :
RETURNS : *m_pdwReg
*****************************************************************************/
PDPReg::operator DWORD()
{
return *(this->m_pdwReg);
}
#endif
#endif /* SUPPORT_PDP_DISPLAY */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -