📄 lcdcclass.cpp
字号:
{
DEBUGMSG(GPE_ZONE_WARNING, (TEXT("LCDC: LCDC_ESC_RELEASE_WINDOW, invalid parameter\r\n")));
SetLastError(ERROR_INVALID_PARAMETER);
}
break;
case LCDC_ESC_ENABLE_WINDOW:
if(pvIn != NULL && cjIn == sizeof(lcdcGraphicWindowOP_t))
{
if(EnableGraphicWindow((pLcdcGraphicWindowOP_t)pvIn))
{
retval = ESC_SUCCESS;
}
else
{
DEBUGMSG(GPE_ZONE_WARNING, (TEXT("LCDC: LCDC_ESC_ENABLE_WINDOW, wrong request\r\n")));
SetLastError(ERROR_INVALID_SERVICE_CONTROL);
}
}
else
{
DEBUGMSG(GPE_ZONE_WARNING, (TEXT("LCDC: LCDC_ESC_ENABLE_WINDOW, invalid parameter\r\n")));
SetLastError(ERROR_INVALID_PARAMETER);
}
break;
case LCDC_ESC_DISABLE_WINDOW:
if(pvIn != NULL && cjIn == sizeof(lcdcGraphicWindowOP_t))
{
if(DisableGraphicWindow((pLcdcGraphicWindowOP_t)pvIn))
{
retval = ESC_SUCCESS;
}
else
{
DEBUGMSG(GPE_ZONE_WARNING, (TEXT("LCDC: LCDC_ESC_ENABLE_WINDOW, wrong request\r\n")));
SetLastError(ERROR_INVALID_SERVICE_CONTROL);
}
}
else
{
DEBUGMSG(GPE_ZONE_WARNING, (TEXT("LCDC: LCDC_ESC_DISABLE_WINDOW, invalid parameter\r\n")));
SetLastError(ERROR_INVALID_PARAMETER);
}
break;
case LCDC_ESC_FLIP_WINDOW:
if(pvIn != NULL && cjIn == sizeof(lcdcGraphicWindowOP_t))
{
if(FlipGraphicWindow((pLcdcGraphicWindowOP_t)pvIn))
{
retval = ESC_SUCCESS;
}
else
{
DEBUGMSG(GPE_ZONE_WARNING, (TEXT("LCDC: LCDC_ESC_ENABLE_WINDOW, wrong request\r\n")));
SetLastError(ERROR_INVALID_SERVICE_CONTROL);
}
}
else
{
DEBUGMSG(GPE_ZONE_WARNING, (TEXT("LCDC: LCDC_ESC_FLIP_WINDOW, invalid parameter\r\n")));
SetLastError(ERROR_INVALID_PARAMETER);
}
break;
case LCDC_ESC_GET_TRANSPARENCY:
if(pvIn != NULL && cjIn == sizeof(lcdcGraphicWindowOP_t))
{
if(GetGWTransparency((pLcdcGraphicWindowOP_t)pvIn))
{
retval = ESC_SUCCESS;
}
else
{
DEBUGMSG(GPE_ZONE_WARNING, (TEXT("LCDC: LCDC_ESC_GET_TRANSPARENCY, wrong request\r\n")));
}
}
else
{
DEBUGMSG(GPE_ZONE_WARNING, (TEXT("LCDC: LCDC_ESC_GET_TRANSPARENCY, invalid parameter\r\n")));
SetLastError(ERROR_INVALID_PARAMETER);
}
break;
case LCDC_ESC_SET_TRANSPARENCY:
if(pvIn != NULL && cjIn == sizeof(lcdcGraphicWindowOP_t))
{
if(SetGWTransparency((pLcdcGraphicWindowOP_t)pvIn))
{
retval = ESC_SUCCESS;
}
else
{
DEBUGMSG(GPE_ZONE_WARNING, (TEXT("LCDC: LCDC_ESC_SET_TRANSPARENCY, wrong request\r\n")));
}
}
else
{
DEBUGMSG(GPE_ZONE_WARNING, (TEXT("LCDC: LCDC_ESC_SET_TRANSPARENCY, invalid parameter\r\n")));
SetLastError(ERROR_INVALID_PARAMETER);
}
break;
case DRVESC_GETSCREENROTATION:
*(int *)pvOut = ((DMDO_0 | DMDO_90 | DMDO_180 | DMDO_270) << 8) | ((BYTE)m_iRotate);
retval=DISP_CHANGE_SUCCESSFUL;
break;
case DRVESC_SETSCREENROTATION:
if ((cjIn == DMDO_0) ||
(cjIn == DMDO_90) ||
(cjIn == DMDO_180) ||
(cjIn == DMDO_270) )
{
return DynRotate(cjIn);
}
retval=DISP_CHANGE_BADMODE;
break;
default:
retval = LcdcDrvEscape(pso, iEsc, cjIn, pvIn,cjOut, pvOut);
break;
}
return retval;
}
//------------------------------------------------------------------------------
// PRIVATE FUNCTIONS
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//
// FUNCTION: EnableGraphicWindow
//
// DESCRIPTION: This function is used to configure the Graphic Window
// and enable it if requested.
//
// PARAMETERS:
//
// RETURNS:
// TRUE successful
// FALSE failed
//
//------------------------------------------------------------------------------
BOOL LcdcClass::EnableGraphicWindow(pLcdcGraphicWindowOP_t pOp)
{
if(pOp->BufHandle && (pOp->BufHandle == m_hGraphicWindowHdl) && pOp->BufPhysicalAddr)
{
if(!m_bGraphicWindowRunning)
{
UINT32 tempGWCR = 0;
BOOL initState;
// Parameter validity check
if((pOp->XOffset + pOp->Width > m_LcdcCtx.VideoFrameWidth) ||
(pOp->YOffset + pOp->Height > m_LcdcCtx.VideoFrameHight) ||
(pOp->XOffset * BSPGetPixelSizeInByte() > pOp->LineStride) ||
(pOp->Width < 16))
{
goto _cleanUp;
}
INSREG32BF(&m_pLCDC->GWSR, LCDC_GWSR_GWH, pOp->Height);
INSREG32BF(&m_pLCDC->GWSR, LCDC_GWSR_GWW, LCDC_GW_SIZE_X(pOp->Width));
INSREG32BF(&m_pLCDC->GWVPWR, LCDC_GWVPWR_GWVPW, LCDC_GW_SIZE_STRIDE(pOp->LineStride));
INSREG32BF(&m_pLCDC->GWPR, LCDC_GWPR_GWXP, pOp->XOffset);
INSREG32BF(&m_pLCDC->GWPR, LCDC_GWPR_GWYP, pOp->YOffset);
INSREG32BF(&tempGWCR, LCDC_GWCR_GWAV, \
LCDC_GW_TRANSPARENCY(pOp->Transparency));
if(pOp->isFlipWindow)
{
m_pLCDC->GWSAR = (UINT32)pOp->BufPhysicalAddr + pOp->LineStride * (pOp->Height - 1);
INSREG32BF(&tempGWCR, LCDC_GWCR_GW_RVS, 1);
m_bGraphicWindowFlipped = TRUE;
}
else
{
m_pLCDC->GWSAR = (UINT32)pOp->BufPhysicalAddr;
m_bGraphicWindowFlipped = FALSE;
}
INSREG32BF(&tempGWCR, LCDC_GWCR_GWE, 1);
m_bGraphicWindowRunning = TRUE;
// Disable LCDC hw clocks
DDKClockSetGatingMode(DDK_CLOCK_GATE_INDEX_LCDC, DDK_CLOCK_GATE_MODE_DISABLE);
m_pLCDC->GWCR = tempGWCR;
// Re-enable LCDC hw clocks
initState = DDKClockSetGatingMode(DDK_CLOCK_GATE_INDEX_LCDC, DDK_CLOCK_GATE_MODE_ENABLE);
if(initState != TRUE)
{
ERRORMSG(1, (TEXT("LCDC Class: LCDC hw clock enable failed!\r\n")));
goto _cleanUp;
}
}
pOp->Result = ESC_SUCCESS;
}
else
{
goto _cleanUp;
}
return TRUE;
_cleanUp:
pOp->Result = ESC_FAILED;
ClearGraphicWindowRegs(m_pLCDC);
return FALSE;
}
//------------------------------------------------------------------------------
//
// FUNCTION: DisableGraphicWindow
//
// DESCRIPTION: This function is used to disable the Graphic Window.
//
// PARAMETERS:
//
// RETURNS:
// TRUE successful
// FALSE failed
//
//------------------------------------------------------------------------------
BOOL LcdcClass::DisableGraphicWindow(pLcdcGraphicWindowOP_t pOp)
{
if(pOp->BufHandle && (pOp->BufHandle == m_hGraphicWindowHdl))
{
if(m_bGraphicWindowRunning)
{
INSREG32BF(&m_pLCDC->GWCR, LCDC_GWCR_GWE, 0);
ClearGraphicWindowRegs(m_pLCDC);
m_bGraphicWindowRunning = FALSE;
}
pOp->Result = ESC_SUCCESS;
return TRUE;
}
else
{
pOp->Result = ESC_FAILED;
return FALSE;
}
}
//------------------------------------------------------------------------------
//
// FUNCTION: FlipGraphicWindow
//
// DESCRIPTION: This function is to flip the Graphic Window.
//
// PARAMETERS:
//
// RETURNS:
// TRUE successful
// FALSE failed
//
//------------------------------------------------------------------------------
BOOL LcdcClass::FlipGraphicWindow(pLcdcGraphicWindowOP_t pOp)
{
if(pOp->BufHandle && (pOp->BufHandle == m_hGraphicWindowHdl) && pOp->BufPhysicalAddr)
{
if(m_bGraphicWindowFlipped)
{
INSREG32BF(&m_pLCDC->GWCR, LCDC_GWCR_GW_RVS, 0);
OUTREG32(&m_pLCDC->GWSAR, (UINT32)pOp->BufPhysicalAddr);
m_bGraphicWindowFlipped = FALSE;
}
else
{
INSREG32BF(&m_pLCDC->GWCR, LCDC_GWCR_GW_RVS, 1);
OUTREG32(&m_pLCDC->GWSAR, (UINT32)pOp->BufPhysicalAddr + pOp->LineStride * (pOp->Height - 1));
m_bGraphicWindowFlipped = TRUE;
}
pOp->Result = ESC_SUCCESS;
return TRUE;
}
else
{
pOp->Result = ESC_FAILED;
return FALSE;
}
}
//------------------------------------------------------------------------------
//
// FUNCTION: GetGWTransparency
//
// DESCRIPTION: This function is to get current transparency of the
// graphic window.
//
// PARAMETERS:
//
// RETURNS:
// TRUE successful
// FALSE failed
//
//------------------------------------------------------------------------------
BOOL LcdcClass::GetGWTransparency(pLcdcGraphicWindowOP_t pOp)
{
if(pOp->BufHandle && (pOp->BufHandle == m_hGraphicWindowHdl))
{
pOp->Transparency =
LCDC_GW_TRANSPARENCY((UINT8)EXTREG32BF(&m_pLCDC->GWCR, LCDC_GWCR_GWAV));
pOp->Result = ESC_SUCCESS;
return TRUE;
}
else
{
pOp->Result = ESC_FAILED;
return FALSE;
}
}
//------------------------------------------------------------------------------
//
// FUNCTION: SetGWTransparency
//
// DESCRIPTION: This function is to set current transparency of the
// graphic window.
//
// PARAMETERS:
//
// RETURNS:
// TRUE successful
// FALSE failed
//
//------------------------------------------------------------------------------
BOOL LcdcClass::SetGWTransparency(pLcdcGraphicWindowOP_t pOp)
{
BOOL result = FALSE;
if(pOp->BufHandle && (pOp->BufHandle == m_hGraphicWindowHdl))
{
if((pOp->Transparency >= 0) &&
(pOp->Transparency <= 0xFF))
{
INSREG32BF(&m_pLCDC->GWCR, LCDC_GWCR_GWAV, \
LCDC_GW_TRANSPARENCY(pOp->Transparency));
pOp->Result = ESC_SUCCESS;
result = TRUE;
}
else
{
pOp->Result = ESC_FAILED;
SetLastError(ERROR_INVALID_PARAMETER);
}
}
else
{
pOp->Result = ESC_FAILED;
}
return result;
}
//------------------------------------------------------------------------------
//
// FUNCTION: AdvertisePowerInterface
//
// DESCRIPTION: This routine notifies the OS that we support the
// Power Manager IOCTLs (through ExtEscape(), which
// calls DrvEscape()).
//
// PARAMETERS: hInst - handle to module DLL
//
// RETURNS:
// TRUE successful
// FALSE failed
//
//------------------------------------------------------------------------------
BOOL LcdcClass::AdvertisePowerInterface(HMODULE hInst)
{
GUID gTemp;
BOOL fOk = FALSE;
HKEY hk;
DWORD dwStatus;
// assume we are advertising the default class
_tcscpy(m_szGuidClass, PMCLASS_DISPLAY);
m_szGuidClass[MAX_PATH-1] = 0;
fOk = ConvertStringToGuid(m_szGuidClass, &gTemp);
DEBUGCHK(fOk);
// check for an override in the registry
dwStatus = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("System\\GDI\\Drivers"), 0, 0, &hk);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -