display_main.cpp
来自「6410BSP3」· C++ 代码 · 共 1,962 行 · 第 1/5 页
CPP
1,962 行
case DISP_V_ACTIVE:
case DISP_V_FRONTPORCH:
default:
return FALSE;
break;
}
}
SCODE
S3C6410Disp::SetPalette(const PALETTEENTRY *source, USHORT firstEntry, USHORT numEntries)
{
DEBUGMSG (GPE_ZONE_INIT, (TEXT("%s()\r\n"), _T(__FUNCTION__)));
if (firstEntry + numEntries > 256 || source == NULL)
{
return E_INVALIDARG;
}
return S_OK;
}
int
S3C6410Disp::GetGameXInfo(ULONG iEsc, ULONG cjIn, PVOID pvIn, ULONG cjOut, PVOID pvOut)
{
int RetVal = 0; // Default not supported
GXDeviceInfo * pgxoi;
void *pCheckBufOut = NULL;
RETAILMSG(DISP_ZONE_ENTER, (_T("[DISPDRV] ++%s()\n\r"), _T(__FUNCTION__)));
// GAPI only support P8, RGB444, RGB555, RGB565, and RGB888
if ((cjOut >= sizeof(GXDeviceInfo)) && (pvOut != NULL)
&& (m_pMode->Bpp == 8 || m_pMode->Bpp == 16 || m_pMode->Bpp == 24 || m_pMode->Bpp == 32))
{
if(FAILED(CeOpenCallerBuffer(&pCheckBufOut, pvOut, cjOut, ARG_IO_PTR, FALSE)))
{
DEBUGMSG( DISP_ZONE_ERROR, (_T("Display GetGameXInfo: CeOpenCallerBuffer failed.\r\n")) );
return ESC_FAILED;
}
if (((GXDeviceInfo *) pCheckBufOut)->idVersion == kidVersion100)
{
pgxoi = (GXDeviceInfo *) pCheckBufOut;
pgxoi->idVersion = kidVersion100;
pgxoi->pvFrameBuffer = (void *)m_pPrimarySurface->Buffer();
pgxoi->cbStride = m_pPrimarySurface->Stride();
pgxoi->cxWidth = m_pPrimarySurface->Width();
pgxoi->cyHeight = m_pPrimarySurface->Height();
if (m_pMode->Bpp == 8)
{
pgxoi->cBPP = 8;
pgxoi->ffFormat = kfPalette;
}
else if (m_pMode->Bpp == 16)
{
pgxoi->cBPP = 16;
pgxoi->ffFormat= kfDirect | kfDirect565;
}
else if (m_pMode->Bpp == 24)
{
pgxoi->cBPP = 24;
pgxoi->ffFormat = kfDirect | kfDirect888;
}
else
{
pgxoi->cBPP = 32;
pgxoi->ffFormat = kfDirect | kfDirect888;
}
if (m_iRotate == DMDO_90 || m_iRotate == DMDO_270 )
pgxoi->ffFormat |= kfLandscape; // Rotated
pgxoi->vkButtonUpPortrait = VK_UP;
pgxoi->vkButtonUpLandscape = VK_LEFT;
pgxoi->vkButtonDownPortrait = VK_DOWN;
pgxoi->vkButtonDownLandscape = VK_RIGHT;
pgxoi->vkButtonLeftPortrait = VK_LEFT;
pgxoi->vkButtonLeftLandscape = VK_DOWN;
pgxoi->vkButtonRightPortrait = VK_RIGHT;
pgxoi->vkButtonRightLandscape = VK_UP;
pgxoi->vkButtonAPortrait = 0xC3; // far right button
pgxoi->vkButtonALandscape = 0xC5; // record button on side
pgxoi->vkButtonBPortrait = 0xC4; // second from right button
pgxoi->vkButtonBLandscape = 0xC1;
pgxoi->vkButtonCPortrait = 0xC5; // far left button
pgxoi->vkButtonCLandscape = 0xC2; // far left button
pgxoi->vkButtonStartPortrait = 134; // action button
pgxoi->vkButtonStartLandscape = 134;
pgxoi->ptButtonUp.x = 120;
pgxoi->ptButtonUp.y = 330;
pgxoi->ptButtonDown.x = 120;
pgxoi->ptButtonDown.y = 390;
pgxoi->ptButtonLeft.x = 90;
pgxoi->ptButtonLeft.y = 360;
pgxoi->ptButtonRight.x = 150;
pgxoi->ptButtonRight.y = 360;
pgxoi->ptButtonA.x = 180;
pgxoi->ptButtonA.y = 330;
pgxoi->ptButtonB.x = 210;
pgxoi->ptButtonB.y = 345;
pgxoi->ptButtonC.x = -50;
pgxoi->ptButtonC.y = 0;
pgxoi->ptButtonStart.x = 120;
pgxoi->ptButtonStart.y = 360;
pgxoi->pvReserved1 = (void *) 0;
pgxoi->pvReserved2 = (void *) 0;
RetVal = ESC_SUCCESS;
if(FAILED(CeCloseCallerBuffer(pCheckBufOut, pvOut, cjOut, ARG_IO_PTR)))
{
DEBUGMSG( DISP_ZONE_ERROR, (_T("Display GetGameXInfo: CeCloseCallerBuffer failed.\r\n")) );
return ESC_FAILED;
}
}
else
{
RETAILMSG(DISP_ZONE_ERROR, (_T("[DISPDRV:ERR] GetGameXInfo() : Invalid Parameter\n\r")));
SetLastError (ERROR_INVALID_PARAMETER);
RetVal = ESC_FAILED;
}
}
else
{
RETAILMSG(DISP_ZONE_ERROR, (_T("[DISPDRV:ERR] GetGameXInfo() : Invalid Parameter\n\r")));
SetLastError (ERROR_INVALID_PARAMETER);
RetVal = ESC_FAILED;
}
RETAILMSG(DISP_ZONE_ERROR, (_T("[DISPDRV] --%s()\n\r"), _T(__FUNCTION__)));
return(RetVal);
}
int
S3C6410Disp::GetRawFrameBuffer(ULONG iEsc, ULONG cjIn, PVOID pvIn, ULONG cjOut, PVOID pvOut)
{
int RetVal = ESC_SUCCESS; // Default not supported
RawFrameBufferInfo *pRawFB;
void *pCheckBufOut = NULL;
RETAILMSG(DISP_ZONE_ENTER, (_T("[DISPDRV] ++%s()\n\r"), _T(__FUNCTION__)));
if ((cjOut >= sizeof(RawFrameBufferInfo)) && (pvOut != NULL))
{
if(FAILED(CeOpenCallerBuffer(&pCheckBufOut, pvOut, cjOut, ARG_IO_PTR, FALSE)))
{
DEBUGMSG( DISP_ZONE_ERROR, (_T("Display GetRawFrameBuffer: CeOpenCallerBuffer failed.\r\n")) );
return ESC_FAILED;
}
pRawFB = (RawFrameBufferInfo *)pCheckBufOut;
pRawFB->wBPP = m_pMode->Bpp;
if (pRawFB->wBPP == gpe32Bpp)
{
pRawFB->wFormat= RAW_FORMAT_OTHER;
pRawFB->cxStride = m_pPrimarySurface->Stride();
pRawFB->cyStride = sizeof(DWORD);
}
else
{
pRawFB->wFormat= RAW_FORMAT_565;
pRawFB->cxStride = m_pPrimarySurface->Stride();
pRawFB->cyStride = sizeof(WORD);
}
pRawFB->cxPixels = m_pPrimarySurface->Width();
pRawFB->cyPixels = m_pPrimarySurface->Height();
pRawFB->pFramePointer = (void *)m_pPrimarySurface->Buffer();
RETAILMSG(DISP_ZONE_ENTER, (_T("[DISPDRV:INF] GetRawFrameBuffer() : Stride=%d, xPixel=%d, yPixel=%d, FramePointer=0x%08x\r\n"),
pRawFB->cyStride, pRawFB->cxPixels, pRawFB->cyPixels, pRawFB->pFramePointer));
RetVal = ESC_SUCCESS;
if(FAILED(CeCloseCallerBuffer(pCheckBufOut, pvOut, cjOut, ARG_IO_PTR)))
{
DEBUGMSG( DISP_ZONE_ERROR, (_T("Display GetGameXInfo: CeCloseCallerBuffer failed.\r\n")) );
return ESC_FAILED;
}
}
else
{
RETAILMSG(DISP_ZONE_ERROR, (_T("[DISPDRV:ERR] GetRawFrameBuffer() : Invalid Parameter\n\r")));
SetLastError (ERROR_INVALID_PARAMETER);
RetVal = ESC_FAILED;
}
RETAILMSG(DISP_ZONE_ENTER, (_T("[DISPDRV] --%s()\n\r"), _T(__FUNCTION__)));
return(RetVal);
}
ULONG
S3C6410Disp::DrvEscape(SURFOBJ * pso, ULONG iEsc, ULONG cjIn, void *pvIn, ULONG cjOut, void *pvOut)
{
ULONG Result = 0;
RETAILMSG(DISP_ZONE_ENTER, (_T("[DISPDRV] --%s(0x%08x)\n\r"), _T(__FUNCTION__), iEsc));
if (iEsc == QUERYESCSUPPORT)
{
if ((*(DWORD*)pvIn == GETGXINFO)
|| (*(DWORD*)pvIn == GETRAWFRAMEBUFFER)
|| (*(DWORD*)pvIn == DRVESC_GETSCREENROTATION)
|| (*(DWORD*)pvIn == DRVESC_SETSCREENROTATION)
|| (*(DWORD*)pvIn == SETPOWERMANAGEMENT)
|| (*(DWORD*)pvIn == GETPOWERMANAGEMENT)
|| (*(DWORD*)pvIn == IOCTL_POWER_CAPABILITIES)
|| (*(DWORD*)pvIn == IOCTL_POWER_QUERY)
|| (*(DWORD*)pvIn == IOCTL_POWER_SET)
|| (*(DWORD*)pvIn == IOCTL_POWER_GET)
|| (*(DWORD*)pvIn == DRVESC_OUTPUT_RGB)
|| (*(DWORD*)pvIn == DRVESC_OUTPUT_TV)
|| (*(DWORD*)pvIn == DRVESC_OUTPUT_SWITCH)
|| (*(DWORD*)pvIn == DRVESC_TV_DMA_DISABLE)
|| (*(DWORD*)pvIn == DRVESC_TV_DMA_PRIMARY)
|| (*(DWORD*)pvIn == DRVESC_TV_DMA_OVERLAY)
|| (*(DWORD*)pvIn == DRVESC_G2D_ACCEL_SET))
{
// The escape is supported.
return 1;
}
else
{
// The escape isn't supported.
#if DO_DISPPERF
return DispPerfQueryEsc(*(DWORD*)pvIn);;
#else
return 0;
#endif
}
}
else if (iEsc == DRVESC_GETSCREENROTATION)
{
RETAILMSG(DISP_ZONE_TEMP, (_T("[DISPDRV] DrvEscape() : DRVESC_GETSCREENROTATION\n\r")));
#ifdef TEMP_FIX_ROTATION_BUG
// Initialize Rotate Mode
if(g_bTempFirstRotation)
{
DEVMODE DevMode;
int NewAngle = GetRotateModeFromReg();
g_bTempFirstRotation = FALSE;
memset (&DevMode, 0, sizeof (DevMode));
DevMode.dmSize = sizeof (DevMode);
DevMode.dmFields = DM_DISPLAYORIENTATION;
DevMode.dmDisplayOrientation = NewAngle;
if (DISP_CHANGE_SUCCESSFUL == ChangeDisplaySettingsEx(NULL, &DevMode, NULL, 0, NULL))
{
RETAILMSG(DISP_ZONE_ENTER, (_T("ChangeDisplaySettingsEx changed rotation angle to %d\r\n"), NewAngle));
}
else
{
RETAILMSG(DISP_ZONE_ERROR, (_T("ChangeDisplaySettingsEx failed to change the rotation angle to %d\r\n"), NewAngle));
}
}
#endif
*(int *)pvOut = ((DMDO_0 | DMDO_90 | DMDO_180 | DMDO_270) << 8) | ((BYTE)m_iRotate);
return DISP_CHANGE_SUCCESSFUL;
}
else if (iEsc == DRVESC_SETSCREENROTATION)
{
RETAILMSG(DISP_ZONE_TEMP, (_T("[DISPDRV] DrvEscape() : DRVESC_SETSCREENROTATION\n\r")));
if ((cjIn == DMDO_0) ||
(cjIn == DMDO_90) ||
(cjIn == DMDO_180) ||
(cjIn == DMDO_270) )
{
return DynRotate(cjIn);
}
return DISP_CHANGE_BADMODE;
}
else if (iEsc == GETGXINFO)
{
RETAILMSG(DISP_ZONE_TEMP, (_T("[DISPDRV] DrvEscape() : GETGXINFO\n\r")));
return GetGameXInfo(iEsc, cjIn, pvIn, cjOut, pvOut);
}
else if (iEsc == GETRAWFRAMEBUFFER)
{
RETAILMSG(DISP_ZONE_TEMP, (_T("[DISPDRV] DrvEscape() : GETRAWFRAMEBUFFER\n\r")));
return GetRawFrameBuffer(iEsc, cjIn, pvIn, cjOut, pvOut);
}
else if (iEsc == SETPOWERMANAGEMENT)
{
RETAILMSG(DISP_ZONE_TEMP, (_T("[DISPDRV] DrvEscape() : SETPOWERMANAGEMENT\n\r")));
if ((cjIn >= sizeof (VIDEO_POWER_MANAGEMENT)) && (pvIn != NULL))
{
PVIDEO_POWER_MANAGEMENT pvpm = (PVIDEO_POWER_MANAGEMENT)pvIn;
if (pvpm->Length >= sizeof (VIDEO_POWER_MANAGEMENT))
{
SetDisplayPowerState((VIDEO_POWER_STATE)(pvpm->PowerState));
}
}
if (Result != ESC_SUCCESS)
{
RETAILMSG(DISP_ZONE_ERROR, (_T("[DISPDRV:ERR] DrvEscape() : SETPOWERMANAGEMENT Fail\n\r")));
// Shouldn't get here if everything was ok.
SetLastError(ERROR_INVALID_PARAMETER);
Result = ESC_FAILED;
}
return Result;
}
else if (iEsc == GETPOWERMANAGEMENT)
{
RETAILMSG(DISP_ZONE_TEMP, (_T("[DISPDRV] DrvEscape() : GETPOWERMANAGEMENT\n\r")));
if ((cjOut >= sizeof (VIDEO_POWER_MANAGEMENT)) && (pvOut != NULL))
{
PVIDEO_POWER_MANAGEMENT pvpm = (PVIDEO_POWER_MANAGEMENT)pvOut;
pvpm->Length = sizeof (VIDEO_POWER_MANAGEMENT);
pvpm->DPMSVersion = 0;
pvpm->PowerState = m_VideoPowerState;
Result = ESC_SUCCESS;
}
else
{
RETAILMSG(DISP_ZONE_ERROR, (_T("[DISPDRV:ERR] DrvEscape() : GETPOWERMANAGEMENT Fail\n\r")));
// Shouldn't get here if everything was ok.
SetLastError(ERROR_INVALID_PARAMETER);
Result = ESC_FAILED;
}
return Result;
}
else if (iEsc == IOCTL_POWER_CAPABILITIES)
{
RETAILMSG(DISP_ZONE_TEMP, (_T("[DISPDRV] DrvEscape() : IOCTL_POWER_CAPABILITIES\n\r")));
// tell the power manager about ourselves
if (pvOut != NULL && cjOut == sizeof(POWER_CAPABILITIES))
{
__try
{
PPOWER_CAPABILITIES ppc = (PPOWER_CAPABILITIES) pvOut;
memset(ppc, 0, sizeof(*ppc));
ppc->DeviceDx = DX_MASK(D0) | DX_MASK(D4);
Result = ESC_SUCCESS;
}
__except(GetExceptionCode()==STATUS_ACCESS_VIOLATION ?
EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)
{
RETAILMSG(DISP_ZONE_ERROR, (_T("[DISPDRV:ERR] DrvEscape() : IOCTL_POWER_CAPABILITIES Exception Occurs\n\r")));
Result = ESC_FAILED;
}
}
return Result;
}
else if(iEsc == IOCTL_POWER_QUERY)
{
RETAILMSG(DISP_ZONE_TEMP, (_T("[DISPDRV] DrvEscape() : IOCTL_POWER_QUERY\n\r")));
if(pvOut != NULL && cjOut == sizeof(CEDEVICE_POWER_STATE))
{
// return a good status on any valid query, since we are always ready to
// change power states.
__try
{
CEDEVICE_POWER_STATE NewDx = *(PCEDEVICE_POWER_STATE) pvOut;
if(VALID_DX(NewDx))
{
// this is a valid Dx state so return a good status
Result = ESC_SUCCESS;
}
else
{
RETAILMSG(DISP_ZONE_ERROR, (_T("[DISPDRV:ERR] DrvEscape() : IOCTL_POWER_QUERY Fail\n\r")));
Result = ESC_FAILED;
}
}
__except(GetExceptionCode()==STATUS_ACCESS_VIOLATION ?
EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?