📄 bsplcdc.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) 2004-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
//
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// INCLUDE FILES
//------------------------------------------------------------------------------
#include <windows.h>
#include <winddi.h>
#include <gpe.h>
#include "bsp.h"
#include "bsplcdc.h"
//------------------------------------------------------------------------------
// GLOBAL DEFINITIONS
//------------------------------------------------------------------------------
ULONG BitMasks[] = { 0xF800, 0x07E0, 0x001F };
lcdcMode_t lcdcModes[LCDC_MODE_NUM] = {
//mode #0, 240x320 16Bpp 60Hz
{0, BSP_PREF_DISPLAY_WIDTH,
BSP_PREF_DISPLAY_HEIGHT,
BSP_PREF_DISPLAY_BPP, 60, gpe16Bpp},
//put other modes here in future expansion
};
static PCSP_PBC_REGS pPBC = NULL;
//------------------------------------------------------------------------------
//
// Function: BSPSetDevCaps
//
// This method changes the devices's capability
void BSPSetDevCaps(GDIINFO * pDevCaps)
{
pDevCaps->flRaster &= ~(RC_PALETTE);
}
//------------------------------------------------------------------------------
//
// Function: BSPGetLCDCBitMasks
//
// This method returns the bitmask used by BSP
ULONG* BSPGetLCDCBitMasks(void)
{
return BitMasks;
}
//------------------------------------------------------------------------------
//
// Function: BSPGetModeNum
//
// This method returns the number of gpdMode supported by BSP
ULONG BSPGetModeNum(void)
{
return LCDC_MODE_NUM;
}
//------------------------------------------------------------------------------
//
// Function: BSPGetModeInfo
//
// This method populates a GPEMode structure with
// data for the requested mode.
SCODE BSPGetModeInfo(GPEMode * pMode, int modeNo)
{
*pMode = lcdcModes[modeNo].gpeMode;
return S_OK;
}
//------------------------------------------------------------------------------
//
// Function: BSPSetMode
//
// This method enables the device driver
// and requests a specific mode for the display.
SCODE BSPSetMode(int modeId, HPALETTE *pPalette)
{
if(modeId != 0)
return E_INVALIDARG;
if (pPalette)
{
// 15,16,24, and 32bpp primaries are defined by red,green, and blue
*pPalette = EngCreatePalette (
PAL_BITFIELDS,
0,
NULL,
BitMasks[0],
BitMasks[1],
BitMasks[2]);
}
return S_OK;
}
//------------------------------------------------------------------------------
//
// Function: BSPInitLCDC
//
// This method initiaizes the LCDC parameters specific to BSP
// and does initializaion for BSP hardware
BOOL BSPInitLCDC(PLCDCCTX pContext)
{
PHYSICAL_ADDRESS phyAddr;
if(!pContext) return FALSE;
pContext->pGPEModeInfo = &lcdcModes[0].gpeMode;
pContext->VideoFrameHight = BSP_PREF_DISPLAY_HEIGHT;
pContext->VideoFrameWidth = BSP_PREF_DISPLAY_WIDTH;
pContext->VideoMemoryPhyAdd = IMAGE_SHARE_FRAMEBUFFER_RAM_PA_START;
pContext->VideoMemorySize = (UINT32)IMAGE_SHARE_FRAMEBUFFER_RAM_SIZE;
phyAddr.QuadPart = BSP_BASE_REG_PA_PBC_BASE;
pPBC = (PCSP_PBC_REGS)MmMapIoSpace(phyAddr, sizeof(CSP_PBC_REGS), FALSE);
if (pPBC == NULL){
return FALSE;
}
return TRUE;
}
//------------------------------------------------------------------------------
//
// Function: BSPDeinitLCDC
//
// This method deinitiaizes the LCDC BSP-secific hardware
void BSPDeinitLCDC(PLCDCCTX pContext)
{
if(pPBC != NULL){
MmUnmapIoSpace(pPBC, sizeof(CSP_PBC_REGS));
pPBC = NULL;
}
}
//------------------------------------------------------------------------------
//
// Function: BSPTurnOnLCD
//
// This method turns on lcd panel just in case
void BSPTurnOnLCD(void)
{
OUTREG16(&pPBC->BCTRL1_SET, CSP_BITFMASK(PBC_BCTRL1_LCDON));
}
//------------------------------------------------------------------------------
//
// Function: BSPTurnOffLCD
//
// This method turns off lcd panel just in case
void BSPTurnOffLCD(void)
{
OUTREG16(&pPBC->BCTRL1_CLEAR, CSP_BITFMASK(PBC_BCTRL1_LCDON));
}
//------------------------------------------------------------------------------
//
// Function: BSPGetPixelSizeInByte
//
// This method returns the size of pixel in bytes
UINT16 BSPGetPixelSizeInByte(void)
{
return LCDC_PIXEL_SIZE_BYTES(BSP_PREF_DISPLAY_BPP);
}
//------------------------------------------------------------------------------
// END OF FILE
//------------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -