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

📄 ipu_adc.cpp

📁 Freescale ARM11系列CPU MX31的WINCE 5.0下的BSP
💻 CPP
📖 第 1 页 / 共 3 页
字号:
//               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:
//      The return value is dependent on the query specified by the iEsc
//      parameter. If the function specified in the query is not supported,
//      the return value is zero.
//
//------------------------------------------------------------------------------
ULONG IPU_ADC::DrvEscape(SURFOBJ *pso,
                         ULONG    iEsc,
                         ULONG    cjIn,
                         PVOID    pvIn,
                         ULONG    cjOut,
                         PVOID    pvOut)
{
    DWORD SupportChk;
    int   RetVal = 0; // default return value: "not supported"

    switch (iEsc) {
    case QUERYESCSUPPORT:
        if (cjIn == sizeof(DWORD))
        {
            SupportChk = *(DWORD *)pvIn;
            switch ( SupportChk )
            {
            case CONTRASTCOMMAND:
            case SETPOWERMANAGEMENT:
            case GETPOWERMANAGEMENT:
            case DRVESC_GETSCREENROTATION:
            case DRVESC_SETSCREENROTATION:
                RetVal = 1;
                break;
            }
        }
        else
        {
            SetLastError(ERROR_INVALID_PARAMETER);
            RetVal = -1;
            break;
        }
        break;

    case CONTRASTCOMMAND:
        break;

    case GETPOWERMANAGEMENT:
        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_PowerState;
            RetVal = 1;
        }
        else
        {
            SetLastError (ERROR_INVALID_PARAMETER);
            RetVal = -1;
        }
        break;

    case SETPOWERMANAGEMENT:
        if( (cjIn >= sizeof(VIDEO_POWER_MANAGEMENT)) && (pvIn != NULL) )
        {
            PVIDEO_POWER_MANAGEMENT pvpm = (PVIDEO_POWER_MANAGEMENT)pvIn;
            if (pvpm->Length >= sizeof(VIDEO_POWER_MANAGEMENT) )
            {
                switch (pvpm->PowerState)
                {
                case VideoPowerOn:
                    // Backlight control -- To be implemented
                case VideoPowerStandBy:
                    // turn on display
                    PowerHandler(FALSE);
                    RetVal = 1;
                    m_PowerState = pvpm->PowerState;
                    break;

                case VideoPowerOff:
                case VideoPowerSuspend:
                    // turn off display
                    PowerHandler(TRUE);
                    RetVal = 1;
                    m_PowerState = pvpm->PowerState;
                    break;
                }
            }
        }

        if (RetVal != 1)
        {
            SetLastError(ERROR_INVALID_PARAMETER);
        }
        break;

    case DRVESC_GETSCREENROTATION:
        if ((cjIn >= sizeof(int)) && (pvIn != NULL))
    {
        *(int *)pvOut = ((DMDO_0 | DMDO_90 | DMDO_180 | DMDO_270) << 8) |
                        ((BYTE)m_iRotate);
            RetVal = DISP_CHANGE_SUCCESSFUL;
    }
        else
    {
            SetLastError(ERROR_INVALID_PARAMETER);
            RetVal = -1;
        }
        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:
        break;
    }

    return RetVal;
}


//------------------------------------------------------------------------------
//
// Function: IPU_ADC::GetRotateModeFromReg
//
// Get rotation angle from registry.
//
// Parameters:
//      None.
//
// Returns:
//      rotation angle.
//
//------------------------------------------------------------------------------
int IPU_ADC::GetRotateModeFromReg()
{
    HKEY hKey;
    int result;

    if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE,
                                      DISPLAY_ROTATION,
                                      0,
                                      0,
                                      &hKey))
    {
        DWORD dwSize, dwAngle, dwType = REG_DWORD;
        dwSize = sizeof(DWORD);
        if (ERROR_SUCCESS == RegQueryValueEx(hKey,
                                             TEXT("ANGLE"),
                                             NULL,
                                             &dwType,
                                             (LPBYTE)&dwAngle,
                                             &dwSize))
        {
            switch (dwAngle)
            {
            case 0:
                result = DMDO_0;
                break;
            case 90:
                result = DMDO_90;
                break;
            case 180:
                result = DMDO_180;
                break;
            case 270:
                result = DMDO_270;
                break;
            default:
                result = DMDO_DEFAULT;
                break;
            }
        }
        RegCloseKey(hKey);
    }

    return result;
}


//------------------------------------------------------------------------------
//
// Function: IPU_ADC::SetRotateParams
//
// Set rotation parameters
//
// Parameters:
//      None.
//
// Returns:
//      None.
//
//------------------------------------------------------------------------------
void IPU_ADC::SetRotateParams()
{
    m_nScreenWidthSave = m_nScreenWidth;
    m_nScreenHeightSave = m_nScreenHeight;

    switch(m_iRotate)
    {
    case DMDO_0:
    case DMDO_180:
        break;

    case DMDO_90:
    case DMDO_270:
        m_nScreenHeight = m_nScreenWidthSave;
        m_nScreenWidth = m_nScreenHeightSave;
        break;
    default:
        break;
    }

    return;
}


//------------------------------------------------------------------------------
//
// Function: IPU_ADC::DynRotate
//
// Set dynamic rotation
//
// Parameters:
//      angle
//          [in] rotation angle code.
//
// Returns:
//      DISP_CHANGE_SUCCESSFUL if successful.
//
//------------------------------------------------------------------------------
LONG IPU_ADC::DynRotate(int angle)
{
    GPESurfRotate *pSurf = (GPESurfRotate *)m_pPrimarySurface;

    if (angle == m_iRotate)
    {
        return DISP_CHANGE_SUCCESSFUL;
    }

    m_iRotate = angle;

    switch(m_iRotate)
    {
    case DMDO_0:
    case DMDO_180:
        m_nScreenHeight = m_nScreenHeightSave;
        m_nScreenWidth = m_nScreenWidthSave;
        break;
    case DMDO_90:
    case DMDO_270:
        m_nScreenHeight = m_nScreenWidthSave;
        m_nScreenWidth = m_nScreenHeightSave;
        break;
    }

    m_pMode->width = m_nScreenWidth;
    m_pMode->height = m_nScreenHeight;
    pSurf->SetRotation(m_nScreenWidth, m_nScreenHeight, angle);

    return DISP_CHANGE_SUCCESSFUL;
}

//------------------------------------------------------------------------------
//
// Function: RegisterDDHALAPI
//
// Set pointer shape
//
// Parameters:
//
// Returns:
//      S_OK if successful.
//
//------------------------------------------------------------------------------
void RegisterDDHALAPI()
{
    // No DDHAL support in 24bpp wrapper
}


//------------------------------------------------------------------------------
//
// Function: DrvGetMasks
//
// This function retrieves the color masks for the display device's current
// mode. The ClearType and anti-aliased font libraries use this function.
//
// Parameters:
//      dhpdev
//          [in] Handle to the display device for which to retrieve color mask
//               information.
//
// Returns:
//      A pointer to three consecutive ULONG values. Each ULONG represents the
//      mask for a particular color component, red, green, or blue. For example,
//      a RGB565 based display returns (0xf800, 0x07e0, 0x001f).
//
//------------------------------------------------------------------------------
ULONG *APIENTRY DrvGetMasks(DHPDEV dhpdev)
{
    if (bpp == 16)
    {
        return gBitMasks16;
    }
    else
    {
        return gBitMasks24;
    }
}


//------------------------------------------------------------------------------
//
// Function: IPU_ADCSurf::IPU_ADCSurf
//
// Constructor of class IPU_ADCSurf.
//
// Parameters:
//      width
//          [in]
//      height
//          [in]
//      offset
//          [in]
//      pBits
//          [in]
//      stride
//          [in]
//      format
//          [in]
//      pNode
//          [in]
//
// Returns:
//      None.
//
//------------------------------------------------------------------------------
IPU_ADCSurf::IPU_ADCSurf(int width,
                         int height,
                         ULONG offset,
                         PVOID pBits,
                         int stride,
                         EGPEFormat format,
                         Node2D *pNode)
    : GPESurf(width, height, pBits, stride, format)
{
    m_pNode2D = pNode;
    m_fInVideoMemory = FALSE;
    m_nOffsetInVideoMemory = offset;
}


//------------------------------------------------------------------------------
//
// Function: IPU_ADCSurf::~IPU_ADCSurf
//
// Destructor of class IPU_ADCSurf.
//
// Parameters:
//      None.
//
// Returns:
//      None.
//
//------------------------------------------------------------------------------
IPU_ADCSurf::~IPU_ADCSurf(void)
{
    m_pNode2D->Free();
}

⌨️ 快捷键说明

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