📄 uldrui.cpp
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
//------------------------------------------------------------------------------
//
// Copyright (C) 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: uldrui.cpp
//
// The ULDR display driver used by Update Application to show
// update progress on the screen.
//
//------------------------------------------------------------------------------
#include <updateappui.h>
#include "bsp.h"
#include "ipu.h"
#include "sdc.h"
//------------------------------------------------------------------------------
// External Functions
//------------------------------------------------------------------------------
// External Variables
extern "C" PANEL_INFO g_PanelArray[];
//------------------------------------------------------------------------------
// Defines
//------------------------------------------------------------------------------
// Types
//------------------------------------------------------------------------------
// Global Variables
#ifdef DEBUG
DBGPARAM dpCurSettings = {
L"ULDRUI", {
L"Undefined", L"Undefined", L"Undefined", L"Undefined",
L"Undefined", L"Undefined", L"Undefined", L"Undefined",
L"Undefined", L"Undefined", L"Undefined", L"Undefined",
L"Undefined", L"Undefined", L"Undefined", L"Undefined"
},
0x0000
};
#endif
static PANEL_INFO *g_pCurrentPanel;
static UINT16 *g_pVideoMemory = NULL;
static PCSP_PBC_REGS g_pPBC = NULL;
//------------------------------------------------------------------------------
// Local Variables
//------------------------------------------------------------------------------
// Local Functions
//------------------------------------------------------------------------------
//
// Function: InitDisplay
//
// You can use this function to set up your display driver and turn on
// your display or screen.
//
// Parameters:
// dwWidth
// [in] Width of the screen.
//
// dwHeight
// [in] Height of the screen.
//
// dwBitDepth
// [in] Depth of the screen.
//
// dwOrientation
// [in] Orientation of the screen.
// For Windows Mobile 5.0, this parameter is ignored.
// The orientation is always going to be set to portrait
// for every device type regardless of the mode you are using.
//
// Returns:
// TRUE indicates success. FALSE indicates failure.
//
//-----------------------------------------------------------------------------
BOOL InitDisplay(DWORD width, DWORD height, DWORD bpp, DWORD orientation)
{
BOOL rc = FALSE;
INT32 row, col;
PHYSICAL_ADDRESS physAddr;
// We support only 16 bpp...
if (bpp != 16)
{
RETAILMSG(TRUE, (L"ERROR: InitDisplay: "
L"Display doesn't support %d bpp\r\n", bpp));
goto cleanUp;
}
// Initialize IPU SDC
g_pCurrentPanel = (PANEL_INFO *) &g_PanelArray[IPU_PANEL_SHARP_TFT];
if (InitializeSDC(g_pCurrentPanel, bpp) != TRUE)
{
RETAILMSG(TRUE, (L"ERROR: InitDisplay: Failed to initialise IPU SDC"));
goto cleanUp;
}
// Allocate video memory that should be physically contiguous
/*
* IMPORTANT: There is no dedicated video memory for i.MX31
* processor, therefore, we have to share from
* system memory.
*/
if (g_pVideoMemory == NULL)
{
g_pVideoMemory = (UINT16 *)AllocPhysMem(g_pCurrentPanel->WIDTH * g_pCurrentPanel->HEIGHT * bpp / 8,
PAGE_EXECUTE_READWRITE, 0, 0, (ULONG *)&physAddr.QuadPart);
if (g_pVideoMemory == NULL)
{
RETAILMSG(TRUE, (L"ERROR: InitDisplay: Video memory allocation failed\r\n"));
goto cleanUp;
}
// Set buffer for SDC
BackgroundSetSrcBuffer(&physAddr);
}
// Map PBC and the turn on LCD
if (g_pPBC == NULL)
{
physAddr.QuadPart = BSP_BASE_REG_PA_PBC_BASE;
g_pPBC = (PCSP_PBC_REGS)MmMapIoSpace(physAddr, sizeof(CSP_PBC_REGS), FALSE);
if (g_pPBC == NULL)
{
RETAILMSG(TRUE, (L"ERROR: InitDisplay: PBC MmMapIoSpace failed\r\n"));
goto cleanUp;
}
OUTREG16(&g_pPBC->BCTRL1_SET, CSP_BITFMASK(PBC_BCTRL1_SET_LCDON));
}
// Enable SDC, start normal operation
EnableSDC();
// Fill screen with nice blue color....
for (row = 0; row < g_pCurrentPanel->HEIGHT; row++)
{
for (col = 0; col < g_pCurrentPanel->WIDTH; col++)
{
g_pVideoMemory[row * g_pCurrentPanel->WIDTH + col] = 0x001F;
}
}
// Done
rc = TRUE;
cleanUp:
return rc;
}
//------------------------------------------------------------------------------
//
// Function: DeinitDisplay
//
// This function performs all necessary actions to turn off
// the display or screen.
//
// Parameters:
// None.
//
// Returns:
// TRUE indicates success. FALSE indicates failure.
//
//-----------------------------------------------------------------------------
BOOL DeinitDisplay()
{
// Disable SDC
DisableSDC();
// Turn off LCD and then free PBC
if (g_pPBC != NULL)
{
OUTREG16(&g_pPBC->BCTRL1_CLEAR, CSP_BITFMASK(PBC_BCTRL1_CLEAR_LCDON));
MmUnmapIoSpace(g_pPBC, sizeof(CSP_PBC_REGS));
g_pPBC = NULL;
}
// Release video memory
if (g_pVideoMemory != NULL)
{
FreePhysMem(g_pVideoMemory);
g_pVideoMemory = NULL;
}
return TRUE;
}
//------------------------------------------------------------------------------
//
// Function: BltRect
//
// This function sets or blits the data for a given rectangular area
// on the screen or display.
//
// Parameters:
// rc
// [in] Rectangle that specifies what coordinates on the
// screen is going to be displayed.
//
// dwStride
// [in] Value that specifies how many bits there are per pixel.
// Use this value if you want to add multiple display depths
// on your device.
// For Windows Mobile 5.0, this value is set to 16.
//
// pBuffer
// [in] Buffer of data for the coordinates starting at the
// upper left hand corner of the rectangle.
// The very first data on the buffer is the pixel on the
// upper left hand corner of the rectangle.
//
// Returns:
// TRUE indicates success. FALSE indicates failure.
//
//-----------------------------------------------------------------------------
BOOL BltRect(RECT rc, DWORD stride, VOID *pBuffer)
{
volatile USHORT *pFrame = g_pVideoMemory;
DWORD screenWidth = g_pCurrentPanel->WIDTH;
USHORT *pData = (USHORT *)pBuffer;
LONG xs, ys, xt, yt;
// Convert stride from bytes to words
stride /= sizeof(USHORT);
for (yt = rc.top, ys = 0; yt < rc.bottom; yt++, ys++)
{
for (xt = rc.left, xs = 0; xt < rc.right; xt++, xs++)
{
pFrame[yt * screenWidth + xt] = pData[ys * stride + xs];
}
}
return TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -