⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ddlcdcmisc.cpp

📁 Microsoft WinCE 6.0 BSP FINAL release source code for use with the i.MX27ADS TO2 WCE600_FINAL_MX27_S
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//------------------------------------------------------------------------------
//
//  Copyright (c) Microsoft Corporation.  All rights reserved.
//
//------------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//  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, 2007, Inc. All Rights Reserved.
//  THIS SOURCE CODE, AND ITS USE AND DISTRIBUTION, IS SUBJECT TO THE TERMS
//  AND CONDITIONS OF THE APPLICABLE LICENSE AGREEMENT
//---------------------------------------------------------------------------

//------------------------------------------------------------------------------
//
// File:        /drivers/display/DDLCDC/DDLcdcMisc.cpp
// Purpose:     miscellaneous functions
//
//------------------------------------------------------------------------------

#include "precomp.h"


//------------------------------------------------------------------------------
// External Functions


//------------------------------------------------------------------------------
// External Variables


//------------------------------------------------------------------------------
// Defines
#define SPLASH_SCREEN_BACKGROUND    0xFF        // white


//------------------------------------------------------------------------------
// Types


//------------------------------------------------------------------------------
// Global Variables


//------------------------------------------------------------------------------
// Local Variables


//------------------------------------------------------------------------------
// Local Functions


//------------------------------------------------------------------------------
//
// Function: DrvEscapeGAPI
//
// This routine handles the needed DrvEscape codes for GAPI. Note that GAPI
// is only supported for Windows Mobile.
//
// Parameters:
//      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:
//      ESC_SUCCESS    successful
//      ESC_FAILED     failed
//
//------------------------------------------------------------------------------

ULONG MX27DDLcdc::DrvEscapeGAPI(ULONG iEsc, ULONG cjIn, void * pvIn, ULONG cjOut, void * pvOut)
{
    return ESC_FAILED;
}

//------------------------------------------------------------------------------
//
// Function: DrvEscape
//
// This routine handles the needed DrvEscape codes.
//
// Parameters:
//      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 MX27DDLcdc::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 == DRVESC_GETSCREENROTATION) ||
                    (EscapeFunction == DRVESC_SETSCREENROTATION)
                    )
                    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("MX27DDLcdc DrvEscape: SETPOWERMANAGEMENT\r\n")));
            if (psPowerManagement = (PVIDEO_POWER_MANAGEMENT) pvIn)
            {        
                if (cjIn >= sizeof(VIDEO_POWER_MANAGEMENT))
               {
                        DWORD err = ERROR_SUCCESS;
        
                        //Ask Power Manager to update the system power state, 
                        //PM will call us back with IOCTL_POWER_SET
                        switch(psPowerManagement->PowerState)
                        {
                            case VideoPowerOff:
                                    DEBUGMSG(GPE_ZONE_WARNING,(TEXT("MX27DDLcdc DrvEscape: Requesting POWER_STATE_IDLE\r\n")));
                                    #if (!defined(ULDR))
                                    err = SetSystemPowerState(0, POWER_STATE_IDLE, POWER_FORCE);
                                    #endif
                                    INSREG32BF(&m_pLcdcReg->PCCR, LCDC_PCCR_PW, 0);
                                    DEBUGMSG(GPE_ZONE_WARNING, (TEXT("MX27DDLcdc DrvEscape: BackLight Off for screen toggle\r\n")));
                                    break;

                            case VideoPowerOn:
                                    DEBUGMSG(GPE_ZONE_WARNING, (TEXT("MX27DDLcdc DrvEscape: Requesting POWER_STATE_ON\r\n")));
                                    #if (!defined(ULDR))
                                    err = SetSystemPowerState(0, POWER_STATE_ON, POWER_FORCE);
                                    #endif
                                    INSREG32BF(&m_pLcdcReg->PCCR, LCDC_PCCR_PW, 100);
                                    DEBUGMSG(GPE_ZONE_WARNING, (TEXT("MX27DDLcdc DrvEscape: BackLight ON for screen toggle\r\n")));  
                                    break;

                            default:
                                    DEBUGMSG(GPE_ZONE_WARNING, (TEXT("MX27DDLcdc DrvEscape: SetPowerManagement : unsupported power state requested\r\n")));                            
                                    break;
                        }

                        if(ERROR_SUCCESS == err)
                            retval = ESC_SUCCESS;
               }
                else
                    SetLastError(ERROR_INVALID_PARAMETER);
            }
            else
                SetLastError(ERROR_INVALID_PARAMETER);

            break;

        case GETPOWERMANAGEMENT:
            //DEBUGMSG(GPE_ZONE_WARNING, (TEXT("MX27DDLcdc 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("MX27DDLcdc DrvEscape: IOCTL_POWER_CAPABILITIES\r\n")));
            if(pvOut != NULL && cjOut == sizeof(POWER_CAPABILITIES))
            {
                PPOWER_CAPABILITIES ppc = (PPOWER_CAPABILITIES)pvOut;
                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;
                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("MX27DDLcdc 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;
                *(PCEDEVICE_POWER_STATE)pvOut = CurrentDx;
                retval = ESC_SUCCESS;
                DEBUGMSG(GPE_ZONE_WARNING, (TEXT("MX27DDLcdc 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;
                if(VALID_DX(NewDx))
                {
                    SetDisplayPower(NewDx);
                    retval = ESC_SUCCESS;
                    DEBUGMSG(GPE_ZONE_WARNING, (TEXT("MX27DDLcdc 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("MX27DDLcdc DrvEscape: IOCTL_POWER_SET: invalid state request %u\r\n"), NewDx));
                }
            } 
            else
                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))
            {
                retval = DynRotate(cjIn);
            }
            else
            {
                retval = DISP_CHANGE_BADMODE;
            }
            break;

        default :
            retval = DrvEscapeGAPI(iEsc, cjIn, pvIn,cjOut, pvOut);
            break;
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -