📄 vd_powerhandler.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_Powerhandler.cpp
Abstract:
Functions:
Notes:
Revision:
12/20/02, Roger Yu, Create the file
--*/
#include "precomp.h"
#include "XSLGPE.h"
//#ifdef _X86_ // for X86 Emulator
//#include <libi2c.h>
#include "chrontel.h"
#include <lcd.h>
#define LCD_BPP_MASK 0x07000000
#define LCD0_PAS 0x80
#define LCD0_SDS 0x04
DISPTIMING dptVideoTiming ={ sizeof(DISPTIMING), 0 };
void LcdControlInit(int isTft, int isDualPanel)
{
volatile SA2lcdregs* lcd = (volatile SA2lcdregs*)Xsl_MapReg[LCDREG].mapaddr;
if (VOD_ATTR_DEFAULT != hVideoOutDevice) {
lcd->LCCR0 =0x003008F8;
lcd->LCCR3 =0x0420FF01; // PSD=1, Output 25Mhz when L=27
}
else {
// Intel DBPXA255 system
// we assume the STN panel is dual-panel (THIS ONLY for LM31 panel)
if (!isTft) {
lcd->LCCR0 =0x0010107c;
lcd->LCCR3 =0x0440FF0C; // PSD=12, Output 3Mhz when L=27
}
else {
lcd->LCCR0 =0x003008F8;
//For 240x320 TFT QVGA (Legend Sharp LCD???)
lcd->LCCR3 =0x0400000B; // PSD=1, Output 4.5Mhz when L=27
//For 176x220 TFT
// lcd->LCCR3 =0x0460FF012; // PSD=12, Output 3Mhz when L=27
}
//
if (isTft) lcd->LCCR0 |= LCD0_PAS;
else lcd->LCCR0 &= (~LCD0_PAS);
if (isDualPanel) lcd->LCCR0 |= LCD0_SDS;
else lcd->LCCR0 &= (~LCD0_SDS);
}
}
void DispDrvrPowerHandler(BOOL bOff)
{
volatile SA2lcdregs* lcd = (volatile SA2lcdregs*)Xsl_MapReg[LCDREG].mapaddr;
if (bOff) {
//### special processing for STN panel
LcdContrast(0);
BcrEnable(0);
//##
LcdOnOff(0);
// lcd->LCCR0 &= ~LCD_ENB;
//### special processing for STN panel
BcrOnOff(0);
//###
}
else {
LcdSetupGPIOs();
if (!bIsTftPanel) {
BcrEnable(0);
//### special processing for STN panel
BcrOnOff(0);
}
lcd->FDADR0 = frameDescriptorCh0->FIDR;
lcd->FDADR1 = frameDescriptorCh1->FIDR;
lcd->LCCR3 = (lcd->LCCR3 & ~LCD_BPP_MASK) | LCD_BPP(lcdFrameBitsPerPixel);
if (!bIsTftPanel) { // special processing for STN panel
BcrOnOff(1);
}
LcdOnOff(1);
//lcd->LCCR0 |= LCD_ENB;
if (!bIsTftPanel) { // special processing for STN panel
BcrEnable(1);
LcdContrast(209);
}
}
}
VOID XSLGPE::PowerHandler(BOOL bOff)
{
if (bOff) {
if (videoPMState.PowerState != VideoPowerOff) {
// turn off video driver
vod_SetPower(hVideoOutDevice, VideoPowerOff);
DispDrvrPowerHandler(TRUE);
videoPMState.PowerState = VideoPowerOff;
}
}
else {
if (videoPMState.PowerState != VideoPowerOn) {
// assume lcd CRTC timing not set
isCrtcTimeSet = FALSE;
if (VOD_ATTR_DEFAULT==hVideoOutDevice)
LcdControlInit(m_IsTftPanel, m_IsDualPanel);
else LcdControlInit(1, 0); // force for CHVOD device
CHDBG((TEXT("XSLGPE::Power On VOD device, Output=%x"),hVideoOutDevice ))
// Turn lcdOn by call DispDrvrPowerHandler(FALSE);
// DispDrvrPowerHandler(FALSE);
if (vod_GetConnectStatus(hVideoOutDevice)) {
// and ask driver to setTiming
vod_SetTiming(hVideoOutDevice, &dptVideoTiming); // tell VOD device timing
//@#$
SetCrtcTiming( &dptVideoTiming);
DispDrvrPowerHandler(FALSE); // Turn on video output
isCrtcTimeSet = TRUE;
//@#$
Sleep(5); // delay 100ms for LCD clock become stable
vod_SetPower(hVideoOutDevice, VideoPowerOn);
vod_PostSetTiming(hVideoOutDevice);
}
// When there is no VOD device, or VOD device didn't call
// vos_SetTiming, we need set Controller timing here
if (!isCrtcTimeSet) {
// Turn LcdOn
SetCrtcTiming( &dptVideoTiming);
DispDrvrPowerHandler(FALSE);
isCrtcTimeSet=TRUE;
}
videoPMState.PowerState = VideoPowerOn;
}
}
return;
}
void XSLGPE::ContrastCmd(ULONG cjIn, PVOID pvIn, ULONG cjOut, PVOID pvOut)
{
//@@##NOTE: This implement only apply to IDP-PCA250 BSP
// For different BSP, changes need be made
ContrastCmdParm *ccm;
ccm = (ContrastCmdParm *)pvIn;
if (ccm && (ccm->command == CONTRAST_CMD_SET)
&& (VOD_ATTR_DEFAULT & hVideoOutDevice) ) // only for SDTN panel
{
LcdContrast( 0x1ff & ccm->parm );
}
//@@##
return;
}
//#endif // _X86_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -