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

📄 ddipu_sdc_misc.cpp

📁 Freescale ARM11系列CPU MX31的WINCE 5.0下的BSP
💻 CPP
📖 第 1 页 / 共 3 页
字号:
//-----------------------------------------------------------------------------
//  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, AND ITS USE AND DISTRIBUTION, IS SUBJECT TO THE TERMS
//  AND CONDITIONS OF THE APPLICABLE LICENSE AGREEMENT
//
//------------------------------------------------------------------------------
//
//  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

// Include GAPI support only for Windows Mobile builds.
#if defined(BSP_POCKETPC) || defined(BSP_SMARTPHONE)
#include <winuserm.h> // Needed for virtual keypad VK keycodes.
#include <gxinfo.h>   // Needed for GAPI data structure definitions.
#endif

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


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


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


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


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


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


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


// Only include GAPI support for Windows Mobile builds.
#if defined(BSP_POCKETPC) || defined(BSP_SMARTPHONE)
//------------------------------------------------------------------------------
//
// Function: GetGameXInfo
//
// This routine returns the display driver information needed for GAPI support.
//
// 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:
//     -1               Error, failed to return display driver settings.
//      0               Not supported.
//      1               Successfully returned display driver settings.
//
//------------------------------------------------------------------------------
int DDIPU_SDC::GetGameXInfo( ULONG iEsc, ULONG cjIn, PVOID pvIn, ULONG cjOut,
                             PVOID pvOut )
{
    int     RetVal = 0;     // Default not supported
    GXDeviceInfo * pgxoi;

    // We only provide GAPI support for 16-bit RGB565.
    //
    if ((cjOut >= sizeof(GXDeviceInfo)) && (pvOut != NULL)
        && (m_pMode->Bpp == 16))
    {
        if (((GXDeviceInfo *) pvOut)->idVersion == kidVersion100)
        {
            pgxoi = (GXDeviceInfo *) pvOut;

            // This is the only value defined in the GXDeviceInfo online help.
            //
            pgxoi->idVersion = kidVersion100;

            // Return framebuffer configuration information.
            //
            pgxoi->pvFrameBuffer = (void *)m_pPrimarySurface->Buffer();
            pgxoi->cbStride = m_pPrimarySurface->Stride();
            pgxoi->cxWidth = m_pPrimarySurface->Width();
            pgxoi->cyHeight = m_pPrimarySurface->Height();

            // For 16-bit RGB565 direct mapped (no palette) mode.
            //
            pgxoi->cBPP = 16;
            pgxoi->ffFormat= kfDirect | kfDirect565;

            // Define virtual keycodes for portrait orientation controls.
            // This is simply the normal orientation for the rocker switch.
            //
            pgxoi->vkButtonUpPortrait     = VK_UP;
            pgxoi->vkButtonDownPortrait   = VK_DOWN;
            pgxoi->vkButtonLeftPortrait   = VK_LEFT;
            pgxoi->vkButtonRightPortrait  = VK_RIGHT;

            // Define virtual keycodes for landscape orientation controls.
            // For the landscape orientation, just take both the normal
            // display and keypad orientation and rotate it 90 degrees
            // clockwise. This results in the following mapping for the
            // rocker switch.
            //
            pgxoi->vkButtonUpLandscape    = VK_LEFT;
            pgxoi->vkButtonDownLandscape  = VK_RIGHT;
            pgxoi->vkButtonLeftLandscape  = VK_DOWN;
            pgxoi->vkButtonRightLandscape = VK_UP;

            // Define A, B, C, and rotate display action keys on the keypad
            // for portrait mode.
            //
            pgxoi->vkButtonAPortrait      = VK_TSOFT1; // Softkey 1 button
            pgxoi->vkButtonBPortrait      = VK_TSOFT2; // Softkey 2 button
            pgxoi->vkButtonCPortrait      = VK_TSTAR;  // Asterisk button
            pgxoi->vkButtonStartPortrait  = VK_ACTION; // Send button

            // Define A, B, C, and rotate display action keys for landscape
            // mode. Unlike the rocker switch, we don't really want to remap
            // the action keys when changing the display orientation.
            //
            pgxoi->vkButtonALandscape     = VK_TSOFT1; // Softkey 1 button
            pgxoi->vkButtonBLandscape     = VK_TSOFT2; // Softkey 2 button
            pgxoi->vkButtonCLandscape     = VK_TSTAR;  // Asterisk button
            pgxoi->vkButtonStartLandscape = VK_ACTION; // Send button

            // Define display (X,Y) positions for all buttons. This assumes
            // that the default startup orientation is portrait mode. Note
            // that the following (X,Y) coordinates are given in screen
            // coordinates but do not map directly to the physical screen
            // display.
            //
            // Instead, imagine a "virtual display" that extends below the
            // physical LCD panel for another 240 pixels and with a width of
            // 240 pixels. Then the following coordinates approximately maps
            // the actual keypad to this extended virtual display.
            //
            pgxoi->ptButtonUp.x    = 100; // Position of rocker UP button.
            pgxoi->ptButtonUp.y    = 330;

            pgxoi->ptButtonDown.x  = 100; // Position of rocker DOWN button.
            pgxoi->ptButtonDown.y  = 390;

            pgxoi->ptButtonLeft.x  = 70;  // Position of rocker LEFT button.
            pgxoi->ptButtonLeft.y  = 360;

            pgxoi->ptButtonRight.x = 130; // Position of rocker RIGHT button.
            pgxoi->ptButtonRight.y = 360;

            pgxoi->ptButtonA.x = 50;      // Position of the KEY 1 button.
            pgxoi->ptButtonA.y = 330;

            pgxoi->ptButtonB.x = 150;     // Position of the KEY 2 button.
            pgxoi->ptButtonB.y = 330;

            pgxoi->ptButtonC.x = 50;      // Position of the ASTERISK button.
            pgxoi->ptButtonC.y = 440;

            pgxoi->ptButtonStart.x = 20;  // Position of the SEND button.
            pgxoi->ptButtonStart.y = 330;

            // These fields are currently unused.
            pgxoi->pvReserved1 = (void *) 0;
            pgxoi->pvReserved2 = (void *) 0;

            RetVal = 1;
        }
        else
        {
            SetLastError (ERROR_INVALID_PARAMETER);
            RetVal = -1;
        }
    }
    else
    {
        SetLastError (ERROR_INVALID_PARAMETER);
        RetVal = -1;
    }

    return(RetVal);
}
#endif // BSP_POCKETPC || BSP_SMARTPHONE

//------------------------------------------------------------------------------
//
// 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 DDIPU_SDC::DrvEscapeGAPI(ULONG iEsc, ULONG cjIn, PVOID pvIn, ULONG cjOut,
                               PVOID pvOut)
{
    ULONG rc = ESC_FAILED;

#if defined(BSP_POCKETPC) || defined(BSP_SMARTPHONE)

    switch(iEsc)
    {
        case QUERYESCSUPPORT:

            DWORD EscapeFunction;
            EscapeFunction = *(DWORD *)pvIn;

            // GETGXINFO is the only additional GAPI-specific IOCTL code
            // that we need to support.
            if (EscapeFunction == GETGXINFO)
            {
                rc = ESC_SUCCESS;
            }
            break;

        case GETGXINFO:

            if (GetGameXInfo(iEsc, cjIn, pvIn, cjOut, pvOut) == 1)
            {
                rc = ESC_SUCCESS;
            }
            break;
    }

#endif

    return rc;
}

//------------------------------------------------------------------------------
//
// 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 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

⌨️ 快捷键说明

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