📄 ddipu_sdc_misc.cpp
字号:
//-----------------------------------------------------------------------------
// Copyright (C) 2004-2005, MOTOROLA, INC. All Rights Reserved
// THIS SOURCE CODE IS CONFIDENTIAL AND PROPRIETARY AND MAY NOT
// BE USED OR DISTRIBUTED WITHOUT THE WRITTEN PERMISSION OF
// MOTOROLA, INC.
//-----------------------------------------------------------------------------
//
// Copyright (C) 2005, 2006, Freescale Semiconductor, Inc. All Rights Reserved
// THIS SOURCE CODE IS CONFIDENTIAL AND PROPRIETARY AND MAY NOT
// BE USED OR DISTRIBUTED WITHOUT THE WRITTEN PERMISSION OF
// Freescale Semiconductor, Inc.
//
//-----------------------------------------------------------------------------
//------------------------------------------------------------------------------
//
// File: ddipu_sdc_line.cpp
//
// Implementation of DDIPU_SDC miscellaneous functions.
//
//------------------------------------------------------------------------------
#include "precomp.h"
#include <cmnintrin.h>
#include "freescaleLogo.c"
#ifdef PLAT_PMC
#include <disppm.h>
// TODO: These definitions should be in disppm.h
extern "C" BOOL Plat_DisplayModeValid(DWORD dwMode); // Determine if a given mode is currently valid
extern "C" BOOL Plat_DisplaySetMode(PVOID pGPIOReg, DWORD dwMode); // Switching display mode - set power, etc.
#include <backlight.h>
#endif
//------------------------------------------------------------------------------
// External Functions
//------------------------------------------------------------------------------
// External Variables
//------------------------------------------------------------------------------
// Defines
#define SPLASH_SCREEN_BACKGROUND 0xFF // white
//------------------------------------------------------------------------------
// Types
//------------------------------------------------------------------------------
// Global Variables
//------------------------------------------------------------------------------
// Local Variables
//------------------------------------------------------------------------------
// Local Functions
//------------------------------------------------------------------------------
//
// Function: DrvEscape
//
// This routine handles the needed DrvEscape codes.
//
// Parameters:
// dhpdev
// [in] Handle to the device that is getting the DrvEscape call.
//
// pso
// [in] Pointer to a SURFOBJ structure that describes the surface
// to which the call is directed.
//
// iEsc
// [in] Query. The meaning of the other parameters depends on
// this value. QUERYESCSUPPORT is the only predefined value; it
// queries whether the driver supports a particular escape function.
// In this case, pvIn points to an escape function number; cjOut and
// pvOut are ignored. If the specified function is supported, the
// return value is nonzero.
//
// cjIn
// [in] Size, in bytes, of the buffer pointed to by pvIn.
//
// pvIn
// [in] Pointer to the input data for the call. The format of the
// input data depends on the query specified by the iEsc parameter.
//
// cjOut
// [in] Size, in bytes, of the buffer pointed to by pvOut.
//
// pvOut
// [out] Pointer to the output buffer. The format of the output data
// depends on the query specified by the iEsc parameter.
//
// Returns:
// TRUE successful
// FALSE failed
//
//------------------------------------------------------------------------------
ULONG DDIPU_SDC::DrvEscape(SURFOBJ * pso, ULONG iEsc, ULONG cjIn, PVOID pvIn, ULONG cjOut, PVOID pvOut)
{
ULONG retval = ESC_FAILED;
PVIDEO_POWER_MANAGEMENT psPowerManagement;
switch(iEsc)
{
case QUERYESCSUPPORT:
if(pvIn != NULL && cjIn == sizeof(DWORD))
{
// Query DrvEscap support functions
DWORD EscapeFunction;
EscapeFunction = *(DWORD *)pvIn;
if ((EscapeFunction == QUERYESCSUPPORT) ||
(EscapeFunction == SETPOWERMANAGEMENT) ||
(EscapeFunction == GETPOWERMANAGEMENT) ||
(EscapeFunction == IOCTL_POWER_CAPABILITIES) ||
(EscapeFunction == IOCTL_POWER_QUERY) ||
(EscapeFunction == IOCTL_POWER_SET) ||
(EscapeFunction == IOCTL_POWER_GET) ||
(EscapeFunction == GETVFRAMEPHYSICAL) ||
(EscapeFunction == GETVFRAMELEN) ||
(EscapeFunction == DRVESC_GETSCREENROTATION) ||
(EscapeFunction == DRVESC_SETSCREENROTATION) ||
#ifdef PLAT_PMC
(EscapeFunction == DISPLAY_GET_BRIGHTNESS) ||
(EscapeFunction == DISPLAY_SET_BRIGHTNESS) ||
#endif
(EscapeFunction == DISPLAY_GET_OUTPUT_MODE) ||
(EscapeFunction == DISPLAY_SET_OUTPUT_MODE) ||
(EscapeFunction == VF_GET_DISPLAY_INFO) ||
(EscapeFunction == VF_CONFIG) ||
(EscapeFunction == VF_SET_OFFSET) ||
(EscapeFunction == VF_BUF_SET) ||
(EscapeFunction == VF_ENABLE) ||
(EscapeFunction == VF_DISABLE) ||
(EscapeFunction == VF_PEEKPOKE)
)
retval = ESC_SUCCESS;
/*
else
retval = DrvEscapeGAPI(iEsc, cjIn, pvIn, cjOut, pvOut);
*/
if(retval != ESC_SUCCESS)
SetLastError(ERROR_INVALID_PARAMETER);
}
else
SetLastError(ERROR_INVALID_PARAMETER);
break;
case SETPOWERMANAGEMENT :
DEBUGMSG(GPE_ZONE_WARNING, (TEXT("DDIPU_SDC DrvEscape: SETPOWERMANAGEMENT\r\n")));
if (psPowerManagement = (PVIDEO_POWER_MANAGEMENT) pvIn)
{
if (cjIn >= sizeof(VIDEO_POWER_MANAGEMENT))
{
switch(psPowerManagement->PowerState)
{
case VideoPowerOff:
DEBUGMSG(GPE_ZONE_WARNING, (TEXT("DDIPU_SDC DrvEscape: BackLight Off for screen toggle\r\n")));
// turn on display
SetDisplayPower(D0);
retval = ESC_SUCCESS;
break;
case VideoPowerOn:
DEBUGMSG(GPE_ZONE_WARNING, (TEXT("DDIPU_SDC DrvEscape: BackLight ON for screen toggle\r\n")));
// turn off display
SetDisplayPower(D4);
retval = ESC_SUCCESS;
break;
default:
DEBUGMSG(GPE_ZONE_WARNING, (TEXT("DDIPU_SDC DrvEscape: SetPowerManagement : unsupported power state requested\r\n")));
break;
}
}
else
SetLastError(ERROR_INVALID_PARAMETER);
}
else
SetLastError(ERROR_INVALID_PARAMETER);
break;
case GETPOWERMANAGEMENT:
DEBUGMSG(GPE_ZONE_WARNING, (TEXT("DDIPU_SDC DrvEscape: GETPOWERMANAGEMENT\r\n")));
if (psPowerManagement = (PVIDEO_POWER_MANAGEMENT) pvOut)
{
if (cjOut >= sizeof(VIDEO_POWER_MANAGEMENT))
{
psPowerManagement->Length = sizeof(VIDEO_POWER_MANAGEMENT);
psPowerManagement->DPMSVersion = 0x0100;
psPowerManagement->PowerState = PmToVideoPowerState(m_Dx);
retval = ESC_SUCCESS;
}
else
{
SetLastError(ERROR_INVALID_PARAMETER);
}
}
else
{
SetLastError(ERROR_INVALID_PARAMETER);
}
break;
case IOCTL_POWER_CAPABILITIES:
DEBUGMSG(GPE_ZONE_WARNING, (TEXT("DDIPU_SDC DrvEscape: IOCTL_POWER_CAPABILITIES\r\n")));
if(pvOut != NULL && cjOut == sizeof(POWER_CAPABILITIES))
{
PPOWER_CAPABILITIES ppc = (PPOWER_CAPABILITIES)pvOut;
#ifdef PLAT_PMC
DISPLIoctlPowerCapabilities((DWORD)this, ppc, NULL);
#else
memset(ppc, 0, sizeof(POWER_CAPABILITIES));
ppc->DeviceDx = 0x11; // support D0 and D4
ppc->WakeFromDx = 0x00; // No wake capability
ppc->InrushDx = 0x00; // No in rush requirement
ppc->Power[D0] = 600; // 0.6W
ppc->Power[D1] = PwrDeviceUnspecified;
ppc->Power[D2] = PwrDeviceUnspecified;
ppc->Power[D3] = PwrDeviceUnspecified;
ppc->Power[D4] = 0;
ppc->Latency[D0] = 0;
ppc->Latency[D1] = PwrDeviceUnspecified;
ppc->Latency[D2] = PwrDeviceUnspecified;
ppc->Latency[D3] = PwrDeviceUnspecified;
ppc->Latency[D4] = 0;
ppc->Flags = 0;
#endif
retval = ESC_SUCCESS;
}
else
SetLastError(ERROR_INVALID_PARAMETER);
break;
case IOCTL_POWER_QUERY:
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.
CEDEVICE_POWER_STATE NewDx = *(PCEDEVICE_POWER_STATE)pvOut;
if(VALID_DX(NewDx))
{
// this is a valid Dx state so return a good status
retval = ESC_SUCCESS;
}
else
SetLastError(ERROR_INVALID_PARAMETER);
DEBUGMSG(GPE_ZONE_WARNING, (TEXT("DDIPU_SDC DrvEscape: IOCTL_POWER_QUERY %u %s\r\n"),
NewDx, retval? L"succeeded" : L"failed"));
}
else
SetLastError(ERROR_INVALID_PARAMETER);
break;
case IOCTL_POWER_GET:
if(pvOut != NULL && cjOut == sizeof(CEDEVICE_POWER_STATE))
{
CEDEVICE_POWER_STATE CurrentDx = m_Dx;
#ifdef PLAT_PMC
DISPLIoctlPowerGet((DWORD)this, (PCEDEVICE_POWER_STATE)pvOut, NULL);
#else
*(PCEDEVICE_POWER_STATE)pvOut = CurrentDx;
#endif
retval = ESC_SUCCESS;
DEBUGMSG(GPE_ZONE_WARNING, (TEXT("DDIPU_SDC DrvEscape: %s IOCTL_POWER_GET: passing back %u\r\n"), m_szDevName, CurrentDx));
}
else
SetLastError(ERROR_INVALID_PARAMETER);
break;
case IOCTL_POWER_SET:
if(pvOut != NULL && cjOut == sizeof(CEDEVICE_POWER_STATE))
{
CEDEVICE_POWER_STATE NewDx = *(PCEDEVICE_POWER_STATE)pvOut;
#ifdef PLAT_PMC
CEDEVICE_POWER_STATE CurrentDx;
if (TRUE == DISPLIoctlPowerSet((DWORD)this, CallSetDisplayPower, NewDx, &CurrentDx, NULL))
{
retval = ESC_SUCCESS;
}
#else
if(VALID_DX(NewDx))
{
SetDisplayPower(NewDx);
retval = ESC_SUCCESS;
DEBUGMSG(GPE_ZONE_WARNING, (TEXT("DDIPU_SDC DrvEscape: %s IOCTL_POWER_SET %u: passing back %u\r\n"), m_szDevName, NewDx, m_Dx));
}
else
{
SetLastError(ERROR_INVALID_PARAMETER);
DEBUGMSG(GPE_ZONE_WARNING, (TEXT("DDIPU_SDC DrvEscape: IOCTL_POWER_SET: invalid state request %u\r\n"), NewDx));
}
#endif
}
else
SetLastError(ERROR_INVALID_PARAMETER);
break;
case GETVFRAMEPHYSICAL :
if ((cjOut >= sizeof(DWORD)) && (pvOut != NULL))
{
*(DWORD *)pvOut = (unsigned long) m_pLAW;
retval = ESC_SUCCESS;
}
else
{
SetLastError (ERROR_INVALID_PARAMETER);
retval = ESC_FAILED;
}
break;
case GETVFRAMELEN :
if ((cjOut >= sizeof(DWORD)) && (pvOut != NULL))
{
*(DWORD *)pvOut = m_nVideoMemorySize;
retval = ESC_SUCCESS;
}
else
{
SetLastError (ERROR_INVALID_PARAMETER);
retval = ESC_FAILED;
}
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))
{
retval = SetRotation( m_pMode->modeId, cjIn );
}
else
{
retval = DISP_CHANGE_BADMODE;
}
break;
case DISPLAY_SET_OUTPUT_MODE:
if(pvIn && cjIn == sizeof(DWORD))
{
DWORD dwDisplayMode = *(DWORD *)pvIn;
if (dwDisplayMode != m_pMode->modeId)
{
#ifdef PLAT_PMC
// See if this mode switch is currently valid
if (Plat_DisplayModeValid(dwDisplayMode) == FALSE)
{
retval = ESC_FAILED;
break;
}
else
{
// make sure panel is off if not going from same <-> same config
DISPLSetMode((DWORD)this, DISPLAY_MODE_NONE, TRUE);
}
#endif
retval = (SetMode((int) dwDisplayMode, NULL) == S_FALSE) ? ESC_FAILED : ESC_SUCCESS;
#ifdef PLAT_PMC
// signal a deferred mode change to the PM
// TODO: Should we defer it?
DISPLSetMode((DWORD)this, dwDisplayMode, FALSE);
#endif
}
}
break;
case DISPLAY_GET_OUTPUT_MODE:
if(pvOut != NULL && cjOut == sizeof(DWORD))
{
//Check if pointer initialized...
//
if( pvOut != NULL )
{
DWORD *pDispMode = (DWORD *)pvOut;
*pDispMode = m_pMode->modeId;
cjOut = sizeof(DWORD);
retval = ESC_SUCCESS;
}
else
{
SetLastError (ERROR_INVALID_PARAMETER);
retval = ESC_FAILED;
}
}
break;
#ifdef PLAT_PMC
case DISPLAY_SET_BRIGHTNESS:
if(cjIn == sizeof(DWORD) && pvIn)
{
if (TRUE == DISPLSetBrightness((DWORD)this, *(PDWORD)pvIn))
{
retval = ESC_SUCCESS;
}
}
break;
case DISPLAY_GET_BRIGHTNESS:
if(cjOut == sizeof(DWORD) && pvOut)
{
if (TRUE == DISPLGetBrightness((DWORD)this, (PDWORD)pvOut))
{
retval = ESC_SUCCESS;
}
}
break;
#endif
case VF_GET_DISPLAY_INFO:
//Check if pointer initialized...
//
if( pvOut != NULL )
{
PDISPLAY_CHARACTERISTIC pDisChar = (PDISPLAY_CHARACTERISTIC)pvOut;
pDisChar->eType = eIPU_SDC;
pDisChar->width = m_pMode->width;
pDisChar->height = m_pMode->height;
pDisChar->bpp = m_pMode->Bpp;
cjOut = sizeof(DISPLAY_CHARACTERISTIC);
retval = ESC_SUCCESS;
}
else
{
SetLastError (ERROR_INVALID_PARAMETER);
retval = ESC_FAILED;
}
break;
case VF_CONFIG:
// trying to validate the input parameters as best as we can..
//
if ((cjIn >= sizeof(DISPLAY_SDC_FG_CONFIG_DATA)) && (pvIn != NULL))
{
ForegroundWindowConfig((PDISPLAY_SDC_FG_CONFIG_DATA)pvIn);
retval = 1;
}
else
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -