📄 xsl_vd_gpeinit.cpp
字号:
//
// Copyright (c) Chrontel Inc. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Chrontel 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.
//
/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
Module Name:
vd_GPEInit.cpp
Abstract:
Functions:
Notes:
Revision:
12/20/02, Roger Yu, Create the file
--*/
#include "precomp.h"
#include "XSLGPE.h"
//#include "vga.h"
#include "palette.h" // for 8Bpp we use the natural palette
//#include "bootarg.h"
#ifdef CLEARTYPE
#include <ctblt.h>
#endif //CLEARTYPE
#include "chrontel.h"
#ifdef _ARM_ // for XScale PXA2xx processor video driver
/*-----------------------------------------------------------------
IllegalInstrHandler
This function is a temporarily-installed low-level SEH
(structured exception handler) that we use to detect
an illegal instruction exception and push past it.
-----------------------------------------------------------------*/
extern PALETTEENTRY _rgbIdentity[]; // 8bit 256 color
extern PALETTEENTRY _rgb16Identity[]; // 16 color
extern unsigned shiftright;
XSLGPE::XSLGPE (void)
{
m_pvFlatFrameBuffer = NULL;
m_VirtualFrameBuffer = NULL;
DEBUGMSG(GPE_ZONE_INIT,(TEXT("XSLGPE::XSLGPE\r\n")));
//++++@@@ Initialize physical registers mapping
CHDBG(( TEXT("XSLBPE:INIT: Map Registers\n") ))
if (0 != MapRegisterZones()) return; // return if failed
//***********************************
// Set Display default value in case no registry setting
//
if (-1== GetVideoParamRegistry(&m_nScreenWidth, &m_nScreenHeight,
(int*)&m_colorDepth, &m_IsTftPanel, &m_IsDualPanel,
(int*)&hVideoOutDevice))
{
//@@## Use this setting for LM8V31 dual-STN panel
m_IsTftPanel =0;
m_IsDualPanel =1;
m_nScreenWidth = 640;
m_nScreenHeight = 480;
m_colorDepth = 16;
hVideoOutDevice = VOD_ATTR_DEFAULT;
//@@## Use the following value if 320x240 TFTQVGA panel as defalut
/*
m_IsTftPanel =1;
m_IsDualPanel =0;
m_nScreenWidth = 320;
m_nScreenHeight = 240;
m_colorDepth = 16;
hVideoOutDevice = VOD_ATTR_DEFAULT;
*/
}
//@###04-02-03. Roger Yu
// We now use the upper 16bits of m_IsTftPanel tell whether we
// should shrink the display pixels.
shiftright = m_IsTftPanel>>16;
m_IsTftPanel = m_IsTftPanel & 0xffff;
CHDBG(( TEXT("XSLBPE:OutCfg=%x, Ask to shrink right %d pixels"), hVideoOutDevice, shiftright ))
//@###
// We fix the color depth to only 8bits and 16bits
if (m_colorDepth >16) m_colorDepth = 16;
if (m_colorDepth <8) m_colorDepth = 8;
if (m_IsTftPanel) m_IsTftPanel=1;
if (m_IsDualPanel) m_IsDualPanel=1;
// clear bit mask is bpp is less than 8
if ( 8==m_colorDepth) {
// 8 bit color
gBitMasks[0] = gBitMasks[1] = gBitMasks[2] =0;
m_RedMaskSize = 0;
m_RedMaskPosition = 0;
m_GreenMaskSize = 0;
m_GreenMaskPosition = 0;
m_BlueMaskSize = 0;
m_BlueMaskPosition = 0;
}
else {
// 16 Bit color
m_RedMaskSize = 5;
m_RedMaskPosition = 11;
m_GreenMaskSize = 6;
m_GreenMaskPosition = 5;
m_BlueMaskSize = 5;
m_BlueMaskPosition = 0;
}
bIsTftPanel = m_IsTftPanel;
m_cxPhysicalScreen = m_nScreenWidth;
m_cyPhysicalScreen = m_nScreenHeight;
m_cbScanLineLength = (m_cxPhysicalScreen*m_colorDepth)>>3;
// Then we allocate the frame buffer
if (0!=AllocLcdMemory( m_nScreenWidth, m_nScreenHeight, m_colorDepth))
{
return;
}
CHDBG(( TEXT("XSLBPE:INIT: TFTPanel=%d, DualPanel=%d"), m_IsTftPanel, m_IsDualPanel ))
m_pvFlatFrameBuffer = (ULONG)physFlatFrameBuffer;
m_VirtualFrameBuffer = (ULONG)virtFlatFrameBuffer;
// set rest of ModeInfo values
m_ModeInfo.modeId = 0;
m_ModeInfo.width = m_nScreenWidth;
//#ifdef FORCE_RIGHT_BLACK // Adjust for Image Shrink at right
m_ModeInfo.width-=shiftright;
//#endif
m_ModeInfo.height = m_nScreenHeight;
m_ModeInfo.Bpp = m_colorDepth;
m_ModeInfo.frequency = 60; // ?
switch (m_colorDepth)
{
case 8:
m_ModeInfo.format = gpe8Bpp;
break;
case 16:
m_ModeInfo.format = gpe16Bpp;
break;
default:
DEBUGMSG(GPE_ZONE_ERROR,(TEXT("Invalid BPP value passed to driver - %d\r\n"), m_ModeInfo.Bpp));
m_ModeInfo.format = gpeUndefined;
break;
}
m_pMode = &m_ModeInfo;
m_p2DVideoMemory = new Node2D(m_cbScanLineLength * 8UL / m_pMode->Bpp, (lcdFramePages*lcdFramePageSize)/m_cbScanLineLength, 0, 0, 4);
if(!m_p2DVideoMemory)
{
RETAILMSG (1, (L"new Node2D failed\n"));
return;
}
if(FAILED(AllocSurface(&m_pPrimarySurface, m_nScreenWidth, m_nScreenHeight, m_pMode->format, GPE_REQUIRE_VIDEO_MEMORY)))
{
RETAILMSG (1, (L"Couldn't allocate primary surface\n"));
return;
}
m_CursorVisible = FALSE;
m_CursorDisabled = TRUE;
m_CursorForcedOff = FALSE;
memset (&m_CursorRect, 0x0, sizeof(m_CursorRect));
#ifdef CLEARTYPE
HKEY hKey;
DWORD dwValue;
ULONG ulGamma = DEFAULT_CT_GAMMA;
if (ERROR_SUCCESS == RegCreateKeyEx(HKEY_LOCAL_MACHINE,szGamma,0, NULL,0,0,0,&hKey,&dwValue))
{
if (dwValue == REG_OPENED_EXISTING_KEY)
{
DWORD dwType = REG_DWORD;
DWORD dwSize = sizeof(LONG);
if (ERROR_SUCCESS == RegQueryValueEx(hKey,szGammaValue,0,&dwType,(BYTE *)&dwValue,&dwSize))
{
ulGamma = dwValue;
}
}
else if (dwValue == REG_CREATED_NEW_KEY )
{
RegSetValueEx(hKey,szGammaValue,0,REG_DWORD,(BYTE *)&ulGamma,sizeof(DWORD));
}
RegCloseKey(hKey);
}
SetClearTypeBltGamma(ulGamma);
SetClearTypeBltMasks(gBitMasks[0], gBitMasks[1], gBitMasks[2]);
#endif //CLEARTYPE
//#ifdef FORCE_RIGHT_BLACK
CleanFrameBuffer((PVOID)m_VirtualFrameBuffer,m_nScreenWidth,
m_nScreenHeight, m_colorDepth );
//#endif
if (8==m_colorDepth)
SetPalette(_rgbIdentity, 0, 256);
else SetPalette(_rgb16Identity, 0, 16);
//$$$
LcdSetupGPIOs();
// Turn off LCD controller first
DispDrvrPowerHandler(TRUE);
//++++
// DebugBreak();
//hVodDev = VOD_ATTR_DEFAULT | VOD_ATTR_TV | VOD_ATTR_VGA;
hVodDev = FindEncoder();
if (0== (hVodDev & hVideoOutDevice)) hVideoOutDevice = VOD_ATTR_DEFAULT;
// dispScreenX = m_nScreenWidth;
// dispScreenY = m_nScreenHeight;
int sy;
sy = m_nScreenHeight;
if ((VOD_ATTR_DEFAULT==hVideoOutDevice) && (m_IsDualPanel)) sy = (m_nScreenHeight/2);
dptVideoTiming = *FindCrtcTiming(m_nScreenWidth, sy,
(VOD_ATTR_DEFAULT!=hVideoOutDevice) );
CHDBG(( TEXT("XSLBPE:INIT: SX=%d, SY=%d, Color=%d, DPC mode=%d"), m_nScreenWidth, m_nScreenHeight, m_colorDepth, dptVideoTiming.flFlags.bClockDouble ))
if (VOD_ATTR_DEFAULT != hVideoOutDevice) {
// Check if the VOD device exists
if (hVodDev & hVideoOutDevice) {
vod_Initialize(hVideoOutDevice);
}
SetDmaDescriptor(0, 0, m_nScreenWidth, m_nScreenHeight, dptVideoTiming.flFlags.bLineDouble);
// Turn on LCD controller now
// DebugBreak();
LcdControlInit(1, 0);
}
else { // Default Local Panel
if (bIsTftPanel) {
// Single Panel Active (TFT) mode
SetDmaDescriptor(0, 0, m_nScreenWidth, m_nScreenHeight, dptVideoTiming.flFlags.bLineDouble);
}
else {
// Dual Panel Passive (STN) mode
SetDmaDescriptor(m_IsDualPanel, 0, m_nScreenWidth, m_nScreenHeight, 0); // no-line-double
}
// Turn on LCD controller now
// DebugBreak();
LcdControlInit(m_IsTftPanel, m_IsDualPanel);
}
DispDrvrPowerHandler(FALSE);
// Turn on display with VOD device
PowerHandler(FALSE);
CHDBG(( TEXT("XSLGPE::INIT, Finish INIT ######PLEASE NOTICE####\n") ))
}
#endif // _ARM_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -