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

📄 ddipu_sdc_misc.cpp

📁 Freescale ARM11系列CPU MX31的WINCE 5.0下的BSP
💻 CPP
📖 第 1 页 / 共 3 页
字号:
    return retval;
}


//------------------------------------------------------------------------------
//
// Function: IsBusy
//
// Method to determine whether IPU SDC is available
// to transfer the frame buffer to display panel.
//
// Parameters:
//      None.
//
// Returns:
//      TRUE            busy
//      FALSE           not busy
//
//------------------------------------------------------------------------------
int DDIPU_SDC::IsBusy(VOID)
{
    return FALSE;
}


//------------------------------------------------------------------------------
//
// Function: InVBlank
//
// Timing method.
//
// Parameters:
//      None.
//
// Returns:
//      TRUE            busy
//      FALSE           not busy
//
//------------------------------------------------------------------------------
int DDIPU_SDC::InVBlank(VOID)
{
    return (!IsBusy());
}


//------------------------------------------------------------------------------
//
// Function: WaitForNotBusy
//
// Method to wait for the frame buffer is ready to update.
//
// Parameters:
//      None.
//
// Returns:
//      None.
//
//------------------------------------------------------------------------------
VOID DDIPU_SDC::WaitForNotBusy(DisplayPlane dispPlane)
{
    UINT8 retry = MAX_BUSY_RETRY; // Wait for 5 milliseconds is long enough.

    DisplayPlaneWaitForNotBusy(dispPlane);

    return;
}


//------------------------------------------------------------------------------
//
// Function: WaitForVerticalBlank
//
// This callback function helps the application synchronize itself
// with the vertical blanking interval (VBI).
//
// Parameters:
//      pd
//          [in, out] Pointer to a DDHAL_WAITFORVERTICALBLANKDATA structure
//          that contains the vertical blank information.
//
// Returns:
//      DDHAL_DRIVER_HANDLED
//      DDHAL_DRIVER_NOTHANDLED
//
//------------------------------------------------------------------------------
DWORD DDIPU_SDC::WaitForVerticalBlank(LPDDHAL_WAITFORVERTICALBLANKDATA pd)
{
    /*
    typedef struct _DDHAL_WAITFORVERTICALBLANKDATA
    {
        LPDDRAWI_DIRECTDRAW_GBL lpDD;               // driver struct
        DWORD                   dwFlags;            // flags
        DWORD                   bIsInVB;            // is in vertical blank
        DWORD                   hEvent;             // event
        HRESUL                  ddRVal;             // return value
        LPDDHAL_WAITFORVERTICALBLANK WaitForVerticalBlank;
                                                    // PRIVATE: ptr to callback
    } DDHAL_WAITFORVERTICALBLANKDATA;
    */

    switch(pd->dwFlags)
    {
        case DDWAITVB_I_TESTVB:
            // If TESTVB, it's just a request for the current vertical blank
            if(InVBlank())
                pd->bIsInVB = TRUE;
            else
                pd->bIsInVB = FALSE;

            pd->ddRVal = DD_OK;
            return DDHAL_DRIVER_HANDLED;

        case DDWAITVB_BLOCKBEGIN:
            // Returns when the vertical blank interval begins.
            WaitForNotBusy(DisplayPlane_0);
            pd->ddRVal = DD_OK;
            return DDHAL_DRIVER_HANDLED;

        case DDWAITVB_BLOCKEND:
            // Returns when the vertical blank interval ends and display begins.
            pd->ddRVal = DDERR_NOVSYNCHW; // TODO:
            return DDHAL_DRIVER_HANDLED;
    }

    return DDHAL_DRIVER_NOTHANDLED;
}


//------------------------------------------------------------------------------
//
// Function: GetPanelTypeFromRegistry
//
// Gets the current panel type from registry.
//
// Parameters:
//      None.
//
// Returns:
//      Panel type number for initial display panel.
//
//------------------------------------------------------------------------------
DWORD DDIPU_SDC::GetPanelTypeFromRegistry(VOID)
{
    DWORD dwPanelNum = -1;
    LONG  error;
    HKEY  hKey;
    DWORD dwSize, dwPanelType;

    // Open registry key for display driver
    error = RegOpenKeyEx(HKEY_LOCAL_MACHINE, VIDEO_REG_PATH, 0 , 0, &hKey);
    if (error != ERROR_SUCCESS)
    {
        DEBUGMSG(GPE_ZONE_ERROR,(TEXT("DDIPU_SDC GetModeFromRegistry: Failed to open reg path:%s [Error:0x%x]\r\n"), VIDEO_REG_PATH, error));
        goto _donePanel;
    }

    // Panel Type
#ifdef VPMX31
    // Virtio supports only Sharp Panel
    dwPanelType = 0;
#else
    dwSize = sizeof(dwPanelType);
    error = RegQueryValueEx(hKey, PANEL_TYPE, NULL, NULL, (LPBYTE)&dwPanelType, (LPDWORD)&dwSize);
    if (error != ERROR_SUCCESS)
    {
        DEBUGMSG(GPE_ZONE_WARNING,
                 (TEXT("DDIPU_SDC GetModeFromRegistry: Failed to get display panel type, Error 0x%X\r\n"), error));
        goto _donePanel;
    }

    dwPanelNum = 31 - _CountLeadingZeros(dwPanelType);
#endif

_donePanel:
    // Close registry key
    RegCloseKey(hKey);

    DEBUGMSG(GPE_ZONE_INIT, (TEXT("DDIPU_SDC GetPanelTypeFromRegistry: %s!\r\n"), (dwPanelNum != -1) ? L"succeeds" : L"fails"));

    return dwPanelNum;
}


//------------------------------------------------------------------------------
//
// Function: GetTVModeSupportFromRegistry
//
// Read registry value to see if TV mode is supported.
//
// Parameters:
//      None.
//
// Returns:
//      TRUE if TV mode supported, FALSE if not supported.
//
//------------------------------------------------------------------------------
BOOL DDIPU_SDC::GetTVModeSupportFromRegistry(VOID)
{
    DWORD dwTVSupport = -1;
    BOOL  retVal = FALSE;
    LONG  error;
    HKEY  hKey;
    DWORD dwSize;

    // Open registry key for display driver
    error = RegOpenKeyEx(HKEY_LOCAL_MACHINE, VIDEO_REG_PATH, 0 , 0, &hKey);
    if (error != ERROR_SUCCESS)
    {
        DEBUGMSG(GPE_ZONE_ERROR,(TEXT("DDIPU_SDC GetTVModeSupportFromRegistry: Failed to open reg path:%s [Error:0x%x]\r\n"), VIDEO_REG_PATH, error));
        goto _doneTV;
    }

    // Retrieve TV Support info from registry
    dwSize = sizeof(int);
    error = RegQueryValueEx(hKey, TV_SUPPORT, NULL, NULL,(LPBYTE)&dwTVSupport, (LPDWORD)&dwSize);
    if (error != ERROR_SUCCESS)
    {
        DEBUGMSG(GPE_ZONE_ERROR,(TEXT("DDIPU_SDC GetTVModeSupportFromRegistry: Failed to get the TV Support info [Error:0x%x]\r\n"),error));
        goto _doneTV;
    }

    if (dwTVSupport == 1)
    {
        m_bTVSupported = TRUE;
    }
    else if (dwTVSupport == 0)
    {
        m_bTVSupported = FALSE;
    }
    else
    {
        DEBUGMSG(GPE_ZONE_ERROR,(TEXT("DDIPU_SDC GetTVModeSupportFromRegistry: TV Support info invalid: %x\r\n"), dwTVSupport));
        goto _doneTV;
    }

    retVal = TRUE;

_doneTV:
    // Close registry key
    RegCloseKey(hKey);

    DEBUGMSG(GPE_ZONE_INIT, (TEXT("DDIPU_SDC GetTVModeSupportFromRegistry: %s!\r\n"), (dwTVSupport != -1) ? L"succeeds" : L"fails"));

    return retVal;
}



//------------------------------------------------------------------------------
//
// Function: GetVMemSizeFromRegistry
//
// Get the size of video RAM requested by user from registry.
//
// Parameters:
//      None.
//
// Returns:
//      TRUE if successful
//      FALSE if failed
//
//------------------------------------------------------------------------------
BOOL DDIPU_SDC::GetVMemSizeFromRegistry(VOID)
{
    BOOL result = TRUE;
    LONG  error;
    HKEY  hKey;
    DWORD dwSize;
    ULONG iAlignment;

    // Open registry key for display driver
    error = RegOpenKeyEx(HKEY_LOCAL_MACHINE, VIDEO_REG_PATH, 0 , 0, &hKey);
    if (error != ERROR_SUCCESS)
    {
        DEBUGMSG(GPE_ZONE_ERROR,(TEXT("%s: Failed to open reg path:%s [Error:0x%x]\r\n"), __WFUNCTION__, VIDEO_REG_PATH, error));
        result = FALSE;
        goto _doneVMem;
    }
#ifdef VPMX31
    // Sharp Display,
    m_nVideoMemorySize = 100000;
#else
    // Retrieve screen width from registry
    dwSize = sizeof(int);
    error = RegQueryValueEx(hKey, VIDEO_MEM_SIZE, NULL, NULL,(LPBYTE)&m_nVideoMemorySize, (LPDWORD)&dwSize);
    if (error != ERROR_SUCCESS)
    {
        DEBUGMSG(GPE_ZONE_ERROR,(TEXT("DDIPU_SDC GetVMemSizeFromRegistry: Failed to get the video RAM size [Error:0x%x].  Setting to default.\r\n"),error));
        result = FALSE;
        m_nVideoMemorySize = DEFAULT_VIDEO_MEM_SIZE;
        goto _doneVMem;
    }
#endif
    // Aligned to 64k bytes
    iAlignment = (1UL << 0xF) - 1;
    m_nVideoMemorySize = (m_nVideoMemorySize + iAlignment) & (~iAlignment);

_doneVMem:
    // Close registry key
    RegCloseKey(hKey);

    DEBUGMSG(GPE_ZONE_INIT, (TEXT("DDIPU_SDC GetVMemSizeFromRegistry: %s, size is %d!\r\n"), result ? L"succeeds" : L"fails", m_nVideoMemorySize));

    return result;
}


//------------------------------------------------------------------------------
//
// Function: LoadFreescaleLogo
//
// Load the Freescale logon onto screen.
//
// Parameters:
//
// Returns:
//      None.
//
//------------------------------------------------------------------------------
VOID DDIPU_SDC::LoadFreescaleLogo(GPESurf * pSurf)
{
    if(pSurf)
    {
        LoadFreescaleLogo(pSurf->Buffer());
    }
}

VOID DDIPU_SDC::LoadFreescaleLogo(VOID * pFramePointer)
{
    if(pFramePointer)
    {
        BYTE *pfb = (BYTE *)pFramePointer;
        int bmpWidth, bmpHeight;
        int h, w, pixelBytes;
        int i, j;

        pixelBytes = m_nScreenBpp/8;

        // Sainty check
        if(bitmap_width * bitmap_height * pixelBytes != sizeof(bitmap_data))
        {
            DEBUGMSG(GPE_ZONE_WARNING, (TEXT("DDIPU_SDC LoadFreescaleLogo: un-matched logo, width %d, height %d, size %d\r\n"), bitmap_width, bitmap_height, sizeof(bitmap_data)));
            DEBUGMSG(GPE_ZONE_WARNING, (TEXT("DDIPU_SDC LoadFreescaleLogo: Splash screen is NOT loaded!\r\n")));
            return;
        }

        bmpWidth  = (bitmap_width  > m_nScreenWidthSave)  ? m_nScreenWidthSave  : bitmap_width;
        bmpHeight = (bitmap_height > m_nScreenHeightSave) ? m_nScreenHeightSave : bitmap_height;

        w = (m_nScreenWidthSave - bmpWidth) / 2;
        h = (m_nScreenHeightSave - bmpHeight) / 2;

        // Pre-set the whole screen as white color
        memset(pfb, SPLASH_SCREEN_BACKGROUND, m_nScreenStride * m_nScreenHeightSave);

        // Copy and centre splash screen in framebuffer.
        j = bmpWidth * pixelBytes;
        pfb += w * pixelBytes + h * m_nScreenStride;
        for(i = 0; i < bmpHeight; i++)
        {

            memcpy(pfb, &bitmap_data[i * bitmap_width], j);
            pfb += m_nScreenStride;
        }
    }
}

#ifdef PLAT_PMC

// Determine if a given mode is currently valid
BOOL Plat_DisplayModeValid(DWORD dwMode)
{
    // TV cable detect?
    return TRUE;
}

BOOL Plat_DisplaySetMode(PVOID pGPIOReg, DWORD dwMode)
{
    return TRUE;
}

#endif

⌨️ 快捷键说明

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