📄 pdpmarathon.cpp
字号:
nDisplayStart = m_sRelative.VAS;
nDisplayEnd = m_sRelative.VBBS;
#ifdef FIXME /* Need to remove DD defines */
int nCurrLineCount;
switch(dwFlags)
{
case PDPWAITVB_I_TESTVB:
/* Request for current vertical blank status */
nCurrLineCount = GetCurrentScanLine();
/* current line in front porch? */
if(nCurrLineCount >= nDisplayEnd ||
/* current line in back porch? */
nCurrLineCount < nDisplayStart)
{
*pdwStatus = TRUE; /* Represents the In VBlank status.*/
}
else
{
*pdwStatus = FALSE;
}
/* we got the vertical blank status */
return PDP_ERROR_OK;
/* request dealt with */
case PDPWAITVB_BLOCKBEGIN:
/*
Request for the beginning of the vertical blank
We detect if we have already entered the back porch
and if we have not we wait for the start of vblank
(this is more reliable than waiting for a specific
scan line as if any other threads are running we may
not get a slice a miss the scanline)
*/
if(GetCurrentScanLine() < (DWORD) nDisplayEnd)
{
/* We're not in a vblank at the moment so wait for the start */
while(GetCurrentScanLine() < (DWORD) nDisplayEnd);
}
else
{
/*
If we are already in a vblank, wait for it to end
then wait for it to start again
*/
while(GetCurrentScanLine() >= (DWORD) nDisplayEnd);
while(GetCurrentScanLine() < (DWORD) nDisplayEnd);
}
/* wait until block begin successful */
*pdwStatus = DD_OK;
/* request dealt with */
return PDP_ERROR_OK;
case PDPWAITVB_BLOCKEND:
/* Request for the end of the vertical blank */
if(GetCurrentScanLine() < (DWORD) nDisplayStart)
{
/*
We're already in the vblank, so wait for the end
of the vblank
*/
while(GetCurrentScanLine() < (DWORD) nDisplayStart);
}
else
{
/*
We're currently either in the display, or back porch
so wait for the front porch then wait for the vblank
to end
*/
while(GetCurrentScanLine() >= (DWORD) nDisplayStart);
while(GetCurrentScanLine() < (DWORD) nDisplayStart);
}
/* we successfully reached blockend */
*pdwStatus = DD_OK;
/* request dealt with */
return PDP_ERROR_OK;
}
EXIT("PDP_WaitVBlank");
return PDP_ERROR_INVALID_PARAMS;
#else /* FIXME */
return(0);
#endif /* FIXME */
}
/*****************************************************************************
FUNCTION : PDP_SetCursorRotation
Description: Sets the cursor rotation
PARAMETERS : DWORD containing the orientation field.
RETURNS : PDP_ERROR_OK
*****************************************************************************/
PDP_ERROR PDPMarathon::PDP_SetCursorRotation(DWORD dwRotation)
{
PDP_TEMPCURSOR sCursor;
m_dwCursorRotation=dwRotation;
if( m_sCursorShapeInfo.wCursor_Attribs & PDP_CURSOR_ENABLE )
{
ApplyRotation(&sCursor);
DecodeTempCursor(sCursor);
}
UpdateDisplay();
return PDP_ERROR_OK;
}
/*****************************************************************************
FUNCTION : PDP_SetColorspaceConversion
Description: Sets the current color space conversion coefficients
PARAMETERS : Structure containg the coefficients
RETURNS : PDP_ERROR_OK
*****************************************************************************/
PDP_ERROR PDPMarathon::PDP_SetColorspaceConversion(PPDP_CSCCoeffs psCoeffs)
{
ENTER("PDP_SetColorspaceConversion");
DP_CSCCoeffs *pscCoeffs;
pscCoeffs=(DP_CSCCoeffs*)psCoeffs;
DP_SetColorSpaceCoeffecients (*pscCoeffs);
UpdateDisplay();
EXIT("PDP_SetColorspaceConversion");
return PDP_ERROR_OK;
}
/*****************************************************************************
FUNCTION : PDP_ScreenUpdate
Description: Forces a screen update on Single shot mode
PARAMETERS :
RETURNS : PDP_ERROR_OK
*****************************************************************************/
PDP_ERROR PDPMarathon::PDP_ScreenUpdate()
{
m_sDevData.psDevInfoKM->sDeviceSpecific.sDisplay.bIsDirty=IMG_TRUE;
UpdateDisplay();
return PDP_ERROR_OK;
}
void PDPMarathon::UpdateDisplay()
{
switch(m_eDisplayUpdate)
{
case PDP_FULL_REFRESH:
/* do nothing here*/
break;
case PDP_REDUCED_REFRESH:
#ifdef FORCE_UPDATE_ON_REDUCED_REFRESH
break;
#endif
case PDP_SINGLE_REFRESH:
/* Write to the Update register...*/
DP_WriteToMemory(PDP_UPDATECTRL,1);
break;
}
}
/*****************************************************************************
FUNCTION : PDP_EnumerateModeList
Description: Enumerates the Modes supported on the attached panel
PARAMETERS : PDP_EnumerateModesList psModeEnum: Pointer to hold the mode list
RETURNS : PDP_ERROR_OK
*****************************************************************************/
PDP_ERROR PDPMarathon::PDP_EnumerateModeList(PPDP_EnumerateModesList psModeEnum)
{
psModeEnum->psModeList=m_psModeList;
psModeEnum->wCount=m_wModeCount;
return PDP_ERROR_OK;
}
/*****************************************************************************
FUNCTION : PDP_IsScreenDirty
Description: Returns the fact that the screen has changed
PARAMETERS :
RETURNS : PDP_ERROR_OK
*****************************************************************************/
PDP_ERROR PDPMarathon::PDP_IsScreenDirty(BOOL *pbIsDirty)
{
*pbIsDirty=m_sDevData.psDevInfoKM->sDeviceSpecific.sDisplay.bIsDirty;
m_sDevData.psDevInfoKM->sDeviceSpecific.sDisplay.bIsDirty=IMG_FALSE;
return PDP_ERROR_OK;
}
/*****************************************************************************
FUNCTION : PDP_BacklightControl
Description: Controls the Backlight for LCD displays
PARAMETERS : PDWORD pdwBrightness, BOOL bGet
RETURNS : PDP_ERROR_OK
*****************************************************************************/
PDP_ERROR PDPMarathon::PDP_BacklightControl(PDWORD pdwBrightness, BOOL bGet)
{
ENTER("PDP_BacklightControl");
if(bGet)
{
*pdwBrightness=m_dwBacklight;
}
else
{
if(*pdwBrightness>100)
{
return PDP_ERROR_INVALID_PARAMS;
}
m_dwBacklight = *pdwBrightness;
SysSetPWM(m_dwPWMPort,m_dwBacklightPeriod,m_dwBacklight); // switch backlight on
}
EXIT("PDP_BacklightControl");
return PDP_ERROR_OK;
}
/*****************************************************************************
FUNCTION : PDP_ActiveRectangle
Description: Gets/Sets the Active rectangle for the display
PARAMETERS : PPDP_ActiveRect psActiveRect, BOOL bGet
RETURNS : PDP_ERROR_OK
*****************************************************************************/
PDP_ERROR PDPMarathon::PDP_ActiveRectangle(PPDP_ACTIVERECT psActiveRect,BOOL bGet)
{
WORD wHDES,wHDEF,wVDES,wVDEF;
DWORD dwHDETiming,dwVDETiming;
if(bGet)
{
*psActiveRect=m_sActiveRect;
}
else
{
// Validate the rectangle that we have been asked to do.
// It should be smaller than the active display.
if(psActiveRect->wLeft>psActiveRect->wRight)
{
return PDP_ERROR_INVALID_PARAMS;
}
if(psActiveRect->wRight> m_sRelative.HRBS)
{
return PDP_ERROR_INVALID_PARAMS;
}
if(psActiveRect->wTop>psActiveRect->wBottom)
{
return PDP_ERROR_INVALID_PARAMS;
}
if(psActiveRect->wBottom> m_sRelative.VBBS)
{
return PDP_ERROR_INVALID_PARAMS;
}
// now that we have a valid rectangle lets set it!
// Our four registers are
/*
HDES = HLBS + left
HDEF = HLBS + Right
VDES = VTBS + top
VEDF = VTBS + bottom
*/
dwHDETiming=*m_cRegControl.m_pdwHDE;
dwVDETiming=*m_cRegControl.m_pdwVDE;
wHDES = psActiveRect->wLeft;
wHDEF = psActiveRect->wRight;
wVDES = psActiveRect->wTop;
wVDEF = psActiveRect->wBottom;
dwHDETiming=(wHDES<<16) | wHDEF;
dwVDETiming=(wVDES<<16) | wVDEF;
// Now write them;
*m_cRegControl.m_pdwHDE=dwHDETiming;
*m_cRegControl.m_pdwVDE=dwVDETiming;
m_sActiveRect=*psActiveRect;
}
return PDP_ERROR_OK;
}
/*****************************************************************************
FUNCTION : PDP_PixelClock
Description: Controls the Backlight for LCD displays
PARAMETERS : PDWORD pdwPixClock, BOOL bGet
RETURNS : PDP_ERROR_OK
*****************************************************************************/
PDP_ERROR PDPMarathon::PDP_PixelClock(PDWORD pdwPixClock, BOOL bGet)
{
ENTER("PDP_BacklightControl");
if(bGet)
{
*pdwPixClock=m_dwPixClock;
}
else
{
m_dwPixClock=*pdwPixClock;
SysSetPixClkFrequency(m_dwPixClock);
}
EXIT("PDP_BacklightControl");
return PDP_ERROR_OK;
}
/*****************************************************************************
FUNCTION : PDP_ReducedRefresh
Description: Controls the Reduced Refresh rate/single shot mode behaviour
PARAMETERS : PBYTE pbyUpdateRate,PBOOL pbSingleShot, BOOL bGet
RETURNS : PDP_ERROR_OK
*****************************************************************************/
PDP_ERROR PDPMarathon::PDP_ReducedRefresh(PBYTE pbyUpdateRate,PBOOL pbSingleShot, BOOL bGet)
{
ENTER("PDP_ReducedRefresh");
DWORD dwOrField=0;
if(bGet)
{
*pbSingleShot=(*m_cRegControl.m_pdwSyncCtrl)&1<<24;
*pbyUpdateRate=(BYTE)(((*m_cRegControl.m_pdwSyncCtrl)&(0xf<<16))>>16);
}
else
{
dwOrField= *pbSingleShot? (1<<24):0;
dwOrField=dwOrField | ((*pbyUpdateRate&0xf)<<16);
*m_cRegControl.m_pdwSyncCtrl=(*m_cRegControl.m_pdwSyncCtrl & (~(1<<24)|(0xf<<16))) | dwOrField;
}
EXIT("PDP_ReducedRefresh");
return PDP_ERROR_OK;
}
/*****************************************************************************
FUNCTION : PDP_OutputMask
Description: Controls the outputMaskValue
PARAMETERS : PDWORD pdwLowerPowerMask,PDWORD pdwFullPowerMask,BOOL bReset, BOOL bGet)
RETURNS : PDP_ERROR_OK
*****************************************************************************/
PDP_ERROR PDPMarathon::PDP_OutputMask(PDWORD pdwLowerPowerMask,PDWORD pdwFullPowerMask,BOOL bReset, BOOL bGet)
{
ENTER("PDP_OutputMask");
if(bGet)
{
if(m_bUserOutputMask)
{
*pdwLowerPowerMask=m_dwUserLowPowerMask;
*pdwFullPowerMask=m_dwUserFullPowerMask;
}
else
{
*pdwLowerPowerMask=m_dwDefaultLowPowerMask;
*pdwFullPowerMask=m_dwDefaultFullPowerMask;
}
}
else
{
if(bReset)
{
m_bUserOutputMask=FALSE;
if(m_eLastState==PVRSRV_POWER_STATE_D0)
{
// we are in full power mode so use the full power mask
*m_cRegControl.m_pdwOutputMask=m_dwDefaultFullPowerMask;
}
else
{
// we are in a low power mode so use the low power mask
*m_cRegControl.m_pdwOutputMask=m_dwDefaultLowPowerMask;
}
}
else
{
m_dwUserLowPowerMask=*pdwLowerPowerMask;
m_dwUserFullPowerMask=*pdwFullPowerMask;
m_bUserOutputMask=TRUE;
if(m_eLastState==PVRSRV_POWER_STATE_D0)
{
// we are in full power mode so use the full power mask
*m_cRegControl.m_pdwOutputMask=m_dwUserFullPowerMask;
}
else
{
// we are in a low power mode so use the low power mask
*m_cRegControl.m_pdwOutputMask=m_dwUserLowPowerMask;
}
}
}
EXIT("PDP_OutputMask");
return PDP_ERROR_OK;
}
/*****************************************************************************
FUNCTION : PDP_Deinit
Description: De-initialises the PDP.
PARAMETERS :
RETURNS : PDP_ERROR_OK
*****************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -