[HKEY_LOCAL_MACHINE\System\GDI\Lcd]
"ScreenWidth" =dword:320
"ScreenHeight"=dword:1e0
"HBP" =dword:a
"HFP"=dword:14
"HSW" =dword:24
"PPL"=dword:1e0
"VBP" =dword:10
"VFP"=dword:d
"VSW" =dword:7
"LPP"=dword:0
"CLKDIV" =dword:40
"CPL"=dword:20
"IOE" =dword:0
"IPC"=dword:0
"IHS" =dword:0
"IVS"=dword:10
"RGB" =dword:3c
"LIGHT"=dword:0
2,更改底层
s3c2416_ldi.c
DWORD svsbuf[18];
int
GetLcdValueFromReg()
{
HKEY hKey;
int nRet = DMDO_0;
DWORD dwSize, dwAngle, dwType = REG_DWORD;
DWORD ScreenWidth=320;
DWORD ScreenHeight=240;
DWORD HBP=38;
DWORD HFP=2;
DWORD HSW=8;
DWORD PPL=19;
DWORD VBP=16;
DWORD VFP=4;
DWORD VSW=1;
DWORD LPP=239;
DWORD CLKDIV=5;
DWORD CPL=319;
DWORD IOE=0;
DWORD IPC=1;
DWORD IHS=1;
DWORD IVS=1;
DWORD RGB=1;
DWORD LIGHT=0;
if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SYSTEM\\GDI\\LCD"),0,0, &hKey))
{
dwSize = sizeof(DWORD);
if (ERROR_SUCCESS == RegQueryValueEx(hKey,
TEXT("LCDWIDTH"),
NULL,
&dwType,
(LPBYTE)&dwAngle,
&dwSize))
{
// LDI_MSG((_T("[LDI]--LDI_deinitialize_LCD_module() : %d\n\r"), dwAngle));
}
RegQueryValueEx(hKey, TEXT("ScreenWidth"), NULL,&dwType, (LPBYTE)&dwAngle,&dwSize);
svsbuf[0]=dwAngle;
RegQueryValueEx(hKey, TEXT("ScreenHeight"), NULL,&dwType, (LPBYTE)&dwAngle,&dwSize);
svsbuf[1]=dwAngle;
RegQueryValueEx(hKey, TEXT("HBP"), NULL,&dwType, (LPBYTE)&dwAngle,&dwSize);
svsbuf[2]=dwAngle;
RegQueryValueEx(hKey, TEXT("HFP"), NULL,&dwType, (LPBYTE)&dwAngle,&dwSize);
svsbuf[3]=dwAngle;
RegQueryValueEx(hKey, TEXT("HSW"), NULL,&dwType, (LPBYTE)&dwAngle,&dwSize);
svsbuf[4]=dwAngle;
RegQueryValueEx(hKey, TEXT("PPL"), NULL,&dwType, (LPBYTE)&dwAngle,&dwSize);
svsbuf[5]=dwAngle;
RegQueryValueEx(hKey, TEXT("VBP"), NULL,&dwType, (LPBYTE)&dwAngle,&dwSize);
svsbuf[6]=dwAngle;
RegQueryValueEx(hKey, TEXT("VFP"), NULL,&dwType, (LPBYTE)&dwAngle,&dwSize);
svsbuf[7]=dwAngle;
RegQueryValueEx(hKey, TEXT("VSW"), NULL,&dwType, (LPBYTE)&dwAngle,&dwSize);
svsbuf[8]=dwAngle;
RegQueryValueEx(hKey, TEXT("LPP"), NULL,&dwType, (LPBYTE)&dwAngle,&dwSize);
svsbuf[9]=dwAngle;
RegQueryValueEx(hKey, TEXT("CLKDIV"), NULL,&dwType, (LPBYTE)&dwAngle,&dwSize);
svsbuf[10]=dwAngle;
RegQueryValueEx(hKey, TEXT("CPL"), NULL,&dwType, (LPBYTE)&dwAngle,&dwSize);
svsbuf[11]=dwAngle;
RegQueryValueEx(hKey, TEXT("IOE"), NULL,&dwType, (LPBYTE)&dwAngle,&dwSize);
svsbuf[12]=dwAngle;
RegQueryValueEx(hKey, TEXT("IPC"), NULL,&dwType, (LPBYTE)&dwAngle,&dwSize);
svsbuf[13]=dwAngle;
RegQueryValueEx(hKey, TEXT("IHS"), NULL,&dwType, (LPBYTE)&dwAngle,&dwSize);
svsbuf[14]=dwAngle;
RegQueryValueEx(hKey, TEXT("IVS"), NULL,&dwType, (LPBYTE)&dwAngle,&dwSize);
svsbuf[15]=dwAngle;
RegQueryValueEx(hKey, TEXT("RGB"), NULL,&dwType, (LPBYTE)&dwAngle,&dwSize);
svsbuf[16]=dwAngle;
RegQueryValueEx(hKey, TEXT("LIGHT"), NULL,&dwType, (LPBYTE)&dwAngle,&dwSize);
svsbuf[17]=dwAngle;
RegCloseKey(hKey);
}
RETAILMSG(1, (TEXT("wNUM_BLOCKS : %d %d \r\n"), svsbuf[0], svsbuf[1]));
return dwAngle;
}
LDI_ERROR LDI_fill_output_device_information(void *pDevInfo)
{
LDI_ERROR error = LDI_SUCCESS;
tDevInfo *pDeviceInfo;
DWORD LCD_WD;
LDI_MSG((_T("[LDI]++LDI_fill_output_device_information()\n\r")));
if (pDevInfo == NULL)
{
LDI_ERR((_T("[LDI:ERR] LDI_fill_output_device_information() : Null Parameter\n\r")));
error = DISP_ERROR_NULL_PARAMETER;
goto CleanUp;
}
pDeviceInfo = (tDevInfo *)pDevInfo;
LCD_WD=GetLcdValueFromReg();
pDeviceInfo->RGBOutMode = LCD_RGB_OUT_MODE;
pDeviceInfo->uiWidth = svsbuf[0];//;
pDeviceInfo->uiHeight = svsbuf[1];//LCD_HEIGHT;
pDeviceInfo->VBPD_Value =svsbuf[6];// LCD_VBPD;
pDeviceInfo->VFPD_Value = svsbuf[7];//LCD_VFPD;
pDeviceInfo->VSPW_Value = svsbuf[8];//LCD_VSPW;
pDeviceInfo->HBPD_Value = svsbuf[2];//LCD_HBPD;
pDeviceInfo->HFPD_Value = svsbuf[3];//LCD_HFPD;
pDeviceInfo->HSPW_Value = svsbuf[4];//LCD_HSPW;
pDeviceInfo->VCLK_Polarity =svsbuf[9];// LCD_VCLK_POLARITY;
pDeviceInfo->HSYNC_Polarity =svsbuf[10];// LCD_HSYNC_POLARITY;
pDeviceInfo->VSYNC_Polarity =svsbuf[11];// LCD_VSYNC_POLARITY;
pDeviceInfo->VDEN_Polarity = svsbuf[12];//LCD_VDEN_POLARITY;
pDeviceInfo->PNR_Mode = svsbuf[13];//LCD_PNR_MODE;
pDeviceInfo->VCLK_Source = svsbuf[14];//LCD_VCLK_SOURCE;
pDeviceInfo->VCLK_Direction = svsbuf[15];//LCD_VCLK_DIRECTION;
pDeviceInfo->Frame_Rate =svsbuf[16];// LCD_FRAME_RATE; // VCLK (Max 10 MHz)
CleanUp:
LDI_MSG((_T("[LDI]--LDI_fill_output_device_information()\n\r")));
return error;
}
3还要改个地方s3c2416_disp.cpp
DWORD svsbuf[18];
int
GetLcdValueFromReg()
{
HKEY hKey;
int nRet = DMDO_0;
DWORD dwSize, dwAngle, dwType = REG_DWORD;
DWORD ScreenWidth=320;
DWORD ScreenHeight=240;
DWORD HBP=38;
DWORD HFP=2;
DWORD HSW=8;
DWORD PPL=19;
DWORD VBP=16;
DWORD VFP=4;
DWORD VSW=1;
DWORD LPP=239;
DWORD CLKDIV=5;
DWORD CPL=319;
DWORD IOE=0;
DWORD IPC=1;
DWORD IHS=1;
DWORD IVS=1;
DWORD RGB=1;
DWORD LIGHT=0;
if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SYSTEM\\GDI\\LCD"),0,0, &hKey))
{
dwSize = sizeof(DWORD);
if (ERROR_SUCCESS == RegQueryValueEx(hKey,
TEXT("LCDWIDTH"),
NULL,
&dwType,
(LPBYTE)&dwAngle,
&dwSize))
{
// LDI_MSG((_T("[LDI]--LDI_deinitialize_LCD_module() : %d\n\r"), dwAngle));
}
RegQueryValueEx(hKey, TEXT("ScreenWidth"), NULL,&dwType, (LPBYTE)&dwAngle,&dwSize);
svsbuf[0]=dwAngle;
RegQueryValueEx(hKey, TEXT("ScreenHeight"), NULL,&dwType, (LPBYTE)&dwAngle,&dwSize);
svsbuf[1]=dwAngle;
RegQueryValueEx(hKey, TEXT("HBP"), NULL,&dwType, (LPBYTE)&dwAngle,&dwSize);
svsbuf[2]=dwAngle;
RegQueryValueEx(hKey, TEXT("HFP"), NULL,&dwType, (LPBYTE)&dwAngle,&dwSize);
svsbuf[3]=dwAngle;
RegQueryValueEx(hKey, TEXT("HSW"), NULL,&dwType, (LPBYTE)&dwAngle,&dwSize);
svsbuf[4]=dwAngle;
RegQueryValueEx(hKey, TEXT("PPL"), NULL,&dwType, (LPBYTE)&dwAngle,&dwSize);
svsbuf[5]=dwAngle;
RegQueryValueEx(hKey, TEXT("VBP"), NULL,&dwType, (LPBYTE)&dwAngle,&dwSize);
svsbuf[6]=dwAngle;
RegQueryValueEx(hKey, TEXT("VFP"), NULL,&dwType, (LPBYTE)&dwAngle,&dwSize);
svsbuf[7]=dwAngle;
RegQueryValueEx(hKey, TEXT("VSW"), NULL,&dwType, (LPBYTE)&dwAngle,&dwSize);
svsbuf[8]=dwAngle;
RegQueryValueEx(hKey, TEXT("LPP"), NULL,&dwType, (LPBYTE)&dwAngle,&dwSize);
svsbuf[9]=dwAngle;
RegQueryValueEx(hKey, TEXT("CLKDIV"), NULL,&dwType, (LPBYTE)&dwAngle,&dwSize);
svsbuf[10]=dwAngle;
RegQueryValueEx(hKey, TEXT("CPL"), NULL,&dwType, (LPBYTE)&dwAngle,&dwSize);
svsbuf[11]=dwAngle;
RegQueryValueEx(hKey, TEXT("IOE"), NULL,&dwType, (LPBYTE)&dwAngle,&dwSize);
svsbuf[12]=dwAngle;
RegQueryValueEx(hKey, TEXT("IPC"), NULL,&dwType, (LPBYTE)&dwAngle,&dwSize);
svsbuf[13]=dwAngle;
RegQueryValueEx(hKey, TEXT("IHS"), NULL,&dwType, (LPBYTE)&dwAngle,&dwSize);
svsbuf[14]=dwAngle;
RegQueryValueEx(hKey, TEXT("IVS"), NULL,&dwType, (LPBYTE)&dwAngle,&dwSize);
svsbuf[15]=dwAngle;
RegQueryValueEx(hKey, TEXT("RGB"), NULL,&dwType, (LPBYTE)&dwAngle,&dwSize);
svsbuf[16]=dwAngle;
RegQueryValueEx(hKey, TEXT("LIGHT"), NULL,&dwType, (LPBYTE)&dwAngle,&dwSize);
svsbuf[17]=dwAngle;
RegCloseKey(hKey);
}
RETAILMSG(1, (TEXT("wNUM_BLOCKS : %d %d \r\n"), svsbuf[0], svsbuf[1]));
return dwAngle;
}
static void InitDisplay(void)
{
UINT8 pagewidth_in_byte = 0,offsize_in_byte = 0;
volatile S3C2416_IOPORT_REG *s2416IOP ;//= (S3C2416_IOPORT_REG *)OALPAtoVA(S3C2416_BASE_REG_PA_IOPORT, FALSE);
volatile S3C2416_LCD_REG *s2416LCD ;//= (S3C2416_LCD_REG *)OALPAtoVA(S3C2416_BASE_REG_PA_LCD, FALSE);
//volatile S3C2416_INTR_REG *s2416INTR = (S3C2416_INTR_REG *)OALPAtoVA(S3C2416_BASE_REG_PA_INTR, FALSE);
s2416LCD = (S3C2416_LCD_REG *)DrvLib_MapIoSpace(S3C2416_BASE_REG_PA_LCD, sizeof(S3C2416_LCD_REG), FALSE);
if (s2416LCD == NULL)
{
DISPDRV_ERR((_T("[DISPDRV:ERR] AllocResource() : m_pLcdConReg DrvLib_MapIoSpace() Failed \n\r")));
// return FALSE;
}
s2416IOP = (S3C2416_IOPORT_REG *)DrvLib_MapIoSpace(S3C2416_BASE_REG_PA_IOPORT, sizeof(S3C2416_IOPORT_REG), FALSE);
if (s2416IOP == NULL)
{
DISPDRV_ERR((_T("[DISPDRV:ERR] AllocResource() : m_pGPIOReg DrvLib_MapIoSpace() Failed \n\r")));
// return FALSE;
}
UINT8 clkval=0;
UINT16 hsync_cnt,vclk_cnt;
UINT16 lcd_horizon_value,lcd_line_value;
UINT8 lcd_vbpd,lcd_vfpd,lcd_vspw,lcd_hbpd,lcd_hfpd,lcd_hspw;
UINT8 lcd_frame_rate;
int i;
unsigned short *pFB;
#if 1
/*
enable lcd power gph11 ->H
s2416IOP->GPHDAT |= (1<<11);
s2416IOP->GPHCON &= ~(0x3<<22);
s2416IOP->GPHCON = (0x1<<22);
*/
// memset((void *)IMAGE_FRAMEBUFFER_UA_BASE, 0xFFFF, LCD_ARRAY_SIZE_TFT_16BIT);
// Set up the LCD controller registers to display a power-on bitmap image.
//
s2416IOP->MISCCR |= (1<<28); // select LCD controller for TFT lcd controller
s2416IOP->GPCUDP = 0xFFFFFFFF;
s2416IOP->GPCCON = 0xAAAAAAAA;
s2416IOP->GPDUDP = 0xFFFFFFFF;
s2416IOP->GPDCON = 0xAAAAAAAA;
s2416IOP->GPLCON = s2416IOP->GPLCON & ~(0x3ff<<20) | (0x1<< 28) | (0x1<< 26) | (0x1<< 24) | (0x1<< 22) | (0x1<< 20);
s2416IOP->GPLDAT |= (0x1f<<10);
lcd_horizon_value = svsbuf[0];
lcd_line_value = svsbuf[1];
lcd_vbpd = svsbuf[6];
lcd_vfpd = svsbuf[7];
lcd_vspw = svsbuf[8];
lcd_hbpd = svsbuf[2];
lcd_hfpd = svsbuf[3];
lcd_hspw = svsbuf[4];
lcd_frame_rate = svsbuf[16];
pagewidth_in_byte = lcd_horizon_value/8*16;
offsize_in_byte = 0;
//LcdWindowOnOff(LCD_WIN_ALL,LCD_OFF);
s2416LCD->WINCON0 &= ~0x01;
s2416LCD->WINCON1 &= ~0x01;
//LcdEnvidOnOff(LCD_OFF);
s2416LCD->VIDCON0 &= (~3); // ENVID Off using Per Frame method
//Basic_Display_Setting(window,WINCONx_16BPP_565,lcd_horizon_value,0);
s2416LCD->VIDCON0 = VIDCON0_S_RGB_IF|VIDCON0_S_RGB_PAR|VIDCON0_S_VCLK_GATING_OFF|VIDCON0_S_CLKDIR_DIVIDED|VIDCON0_S_CLKSEL_HCLK;
hsync_cnt = (lcd_vbpd+lcd_vfpd+lcd_vspw+lcd_line_value);
vclk_cnt = (lcd_hbpd+lcd_hfpd+lcd_hspw+lcd_horizon_value);
//clkval = (UINT8)(((float)S3C2416_HCLK/(float)(hsync_cnt*vclk_cnt*lcd_frame_rate*2))+0.5)-1;
clkval = (LCD_TFT_CLKVAL + 1);
s2416LCD->VIDCON0 |= (clkval <<VIDCON0_CLKVAL_F_SHIFT);
s2416LCD->VIDCON1 = VIDCON1_S_HSYNC_INVERTED|VIDCON1_S_VSYNC_INVERTED;
s2416LCD->VIDTCON0=((lcd_vbpd-1)<<VIDTCON0_BPD_S)|((lcd_vfpd-1)<<VIDTCON0_FPD_S)|(lcd_vspw-1);
s2416LCD->VIDTCON1=((lcd_hbpd-1)<<VIDTCON0_BPD_S)|((lcd_hfpd-1)<<VIDTCON0_FPD_S)|(lcd_hspw-1);
s2416LCD->VIDTCON2 = ((lcd_line_value-1)<<VIDTCON2_LINEVAL_S)|(lcd_horizon_value-1);
#if 1
//s2416LCD->WINCON0 = (0<<WINCON_SWAP_S)|(WINCONx_16WORD_BURST<<WINCON_BURSTLEN_S)|(WINCONx_16BPP_565<<WINCON_BPP_S); // 4word burst, 16bpp,
s2416LCD->WINCON0 = (0<<WINCON_SWAP_S)|(WINCONx_16WORD_BURST<<WINCON_BURSTLEN_S)|(WINCONx_16BPP_565<<WINCON_BPP_S); // 4word burst, 16bpp,
s2416LCD->VIDOSD0A = (0<<VIDOSDxAB_HORIZON_X_S)|(0);
// s2416LCD->VIDOSD0B = ((lcd_horizon_value-1)<<VIDOSDxAB_HORIZON_X_S)|(lcd_line_value-1);
s2416LCD->VIDOSD0B = ((lcd_horizon_value-1)<<VIDOSDxAB_HORIZON_X_S)|(lcd_line_value-1);
s2416LCD->VIDW00ADD0B0 = (UINT32)IMAGE_FRAMEBUFFER_DMA_BASE;
// buffer size
s2416LCD->VIDW00ADD1B0 = (UINT32)IMAGE_FRAMEBUFFER_DMA_BASE + (lcd_horizon_value*lcd_line_value*2);
// buffer size
s2416LCD->VIDW00ADD2B0 = (offsize_in_byte<<VIDWxADD2_OFFSET_SIZE_S)|(lcd_horizon_value*2);
s2416LCD->WINCON0 |= (1<<WINCON_SWAP_S);
//*WxKEYCON0_Reg_Addr[win_num] = 0;
//*WINxMAP_Reg_Addr[win_num] = 0;
s2416LCD->WINCON0 |= 0x1; // enable Win0
s2416LCD->WINCON1 = 0x0; // disable Win1
#endif
s2416LCD->VIDCON0 |= 0x3;
//s2416INTR->INTSUBMSK |= (0xf << IRQ_SUB_LCD1); // MASK all LCD Sub Interrupt
RETAILMSG(1,(TEXT("IMAGE_FRAMEBUFFER_UA_BASE\n")));
#if 1 //HJ_del 20120210
//enable backlight
s2416IOP->GPBUDP &= ~0x3;
s2416IOP->GPBCON = (s2416IOP->GPBCON & ~((3<<6)|(3<<2)|(3<<0))) | ((1<<6)|(1<<2)|(1<<0)); // Backlight Pwm control
s2416IOP->GPBDAT |=((1<<0) |(1<<3));
s2416IOP->GPBDAT &= ~(1<<1);
s2416IOP->GPBCON = s2416IOP->GPBCON & ~(0x3<<0) | (0x1<<0);
s2416IOP->GPBDAT = s2416IOP->GPBDAT | 0x1;
#endif
//s2416IOP->GPBCON = s2416IOP->GPBCON & ~(0x3<<0) | (0x1<<0);
//s2416IOP->GPBDAT = s2416IOP->GPBDAT | 0x1;
#endif
}
S3C2416Disp::S3C2416Disp()
{
DWORD dwSplashFrameBufferSize;
//volatile S3C2416_LCD_REG *s2416LCD = (S3C2416_LCD_REG *)OALPAtoVA(S3C2416_BASE_REG_PA_LCD, FALSE);
DISPDRV_MSG((_T("[DISPDRV] ++S3C2416Disp::S3C2416Disp()\n\r")));
m_pLcdConReg = NULL;
m_pGPIOReg = NULL;
m_pSPIReg = NULL;
m_VideoMemoryPhysicalBase = NULL;
m_VideoMemoryVirtualBase = NULL;
m_VideoMemorySize = 0;
m_pVideoMemoryHeap = NULL;
m_hVideoDrv = NULL;
m_CursorVisible = FALSE;
m_CursorDisabled = TRUE;
m_CursorForcedOff = FALSE;
memset (&m_CursorRect, 0x0, sizeof(m_CursorRect));
m_InDDraw = FALSE;
InitalizeOverlayContext();
m_bTVDMARunning = FALSE;
//---------------------
// Setup Mode Information
//---------------------
GetLcdValueFromReg();
// Initialize Screen Dimensions
m_dwDeviceScreenWidth = svsbuf[0];//LCD_WIDTH;
m_dwDeviceScreenHeight = svsbuf[1];// LCD_HEIGHT;
m_nScreenWidthSave = m_dwDeviceScreenWidth;
m_nScreenHeightSave = m_dwDeviceScreenHeight;
InitDisplay();
// Initialize Rotate Mode
m_iRotate = GetRotateModeFromReg();
SetRotateParams();
//----------------------------------------
// Initialize ModeInfoEX, modeInfo Data Structure
//----------------------------------------
//Setup ModeInfoEx, ModeInfo
m_pModeEx = &m_ModeInfoEx;
m_pMode = &m_ModeInfoEx.modeInfo;
memset(m_pModeEx, 0, sizeof(GPEModeEx));
#if (LCD_BPP == 16)
m_pModeEx->ePixelFormat = ddgpePixelFormat_565;
#elif (LCD_BPP == 32)
m_pModeEx->ePixelFormat = ddgpePixelFormat_8888;
#endif
// Fill GPEMode modeInfo
m_pMode->modeId = 0;
m_pMode->width = m_nScreenWidth;
m_pMode->height = m_nScreenHeight;
m_pMode->format = EDDGPEPixelFormatToEGPEFormat[m_pModeEx->ePixelFormat];
m_pMode->Bpp = EGPEFormatToBpp[m_pMode->format];
m_pMode->frequency = 60; // Usually LCD Panel require 60Hz
// Fill DDGPEStandardHeader
m_pModeEx->dwSize = sizeof(GPEModeEx);
m_pModeEx->dwVersion = GPEMODEEX_CURRENTVERSION;
// Fill ModeInfoEX
m_pModeEx->dwPixelFourCC = 0; // Should be Zero
m_pModeEx->dwPixelFormatData = 0; // Don't care
m_pModeEx->lPitch = m_dwDeviceScreenWidth*(m_pMode->Bpp/8);
m_pModeEx->dwFlags = 0; // Should be Zero
m_pModeEx->dwRBitMask = gBitMasks[0];
m_pModeEx->dwGBitMask = gBitMasks[1];
m_pModeEx->dwBBitMask = gBitMasks[2];
m_pModeEx->dwAlphaBitMask = 0x00000000;
// Initialize Power State
m_VideoPowerState = VideoPowerOn;
// Mapping Virtual Address (SFR, VideoMemory)
if (AllocResource() == FALSE)
{
DISPDRV_ERR((_T("[DISPDRV:ERR] S3C2416Disp() : AllocResource() Fail\n\r")));
return;
}
// Clear Video Memory (Leave frame buffer for splash image)
dwSplashFrameBufferSize = m_dwDeviceScreenWidth*m_dwDeviceScreenHeight*(m_pMode->Bpp/8);
memset ((void *)(m_VideoMemoryVirtualBase+dwSplashFrameBufferSize), 0x0, m_VideoMemorySize-dwSplashFrameBufferSize);
#if G2D_ACCELERATE
// Enable Block Power and Clock Source
// Todo : Power Management in Video Driver
// DevHWPowerGating(HWPWR_2D_ON);
// DevHWClockGating(HWCLK_2D_ON);
m_oG2D = new FIMGSE2D;
if(m_oG2D == NULL)
{
DISPDRV_ERR((_T("[DISPDRV:ERR] S3C2416Disp() : 2D Accelerator Initialization Fail\n\r")));
}
// Initialize Interrupt (Event, Interrupt)
if (m_oG2D)
{
BOOL bResult;
bResult = m_oG2D->InitializeInterrupt();
if(bResult==FALSE)
{
DISPDRV_ERR((_T("[DISPDRV:ERR] InitializeInterrupt() 2D Object is failed.\n\r")));
}
}
else
{
DISPDRV_ERR((_T("[DISPDRV:ERR] InitializeInterrupt() : 2D Object is not created.\n\r")));
}
#endif
// Initialize Critical Section
InitializeCriticalSection(&m_csDevice);
InitializeCriticalSection(&m_cs2D);
// Initialize Display Controller
if (DevInitialize() == FALSE)
{
DISPDRV_ERR((_T("[DISPDRV:ERR] S3C2416Disp() : InitializeDevice() Fail\n\r")));
return;
}
AdvertisePowerInterface(g_hmodDisplayDll);
DISPDRV_MSG((_T("[DISPDRV] --S3C2416Disp::S3C2416Disp()\n\r")));
}
5,应用程序
// AutoAddLcdDlg.cpp : 实现文件
//
#include "stdafx.h"
#include "AutoAddLcd.h"
#include "AutoAddLcdDlg.h"
#include "shellapi.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CAutoAddLcdDlg 对话框
CAutoAddLcdDlg::CAutoAddLcdDlg(CWnd* pParent /*=NULL*/)
: CDialog(CAutoAddLcdDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CAutoAddLcdDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAutoAddLcdDlg, CDialog)
#if defined(_DEVICE_RESOLUTION_AWARE) && !defined(WIN32_PLATFORM_WFSP)
ON_WM_SIZE()
#endif
//}}AFX_MSG_MAP
ON_BN_CLICKED(IDC_BUTTON1, &CAutoAddLcdDlg::OnBnChangeLcd)
END_MESSAGE_MAP()
// CAutoAddLcdDlg 消息处理程序
BOOL CAutoAddLcdDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动
// 执行此操作
SetIcon(m_hIcon, TRUE); // 设置大图标
SetIcon(m_hIcon, FALSE); // 设置小图标
// TODO: 在此添加额外的初始化代码
OnBnChangeLcd();
return TRUE; // 除非将焦点设置到控件,否则返回 TRUE
}
#if defined(_DEVICE_RESOLUTION_AWARE) && !defined(WIN32_PLATFORM_WFSP)
void CAutoAddLcdDlg::OnSize(UINT /*nType*/, int /*cx*/, int /*cy*/)
{
if (AfxIsDRAEnabled())
{
DRA::RelayoutDialog(
AfxGetResourceHandle(),
this->m_hWnd,
DRA::GetDisplayMode() != DRA::Portrait ?
MAKEINTRESOURCE(IDD_AUTOADDLCD_DIALOG_WIDE) :
MAKEINTRESOURCE(IDD_AUTOADDLCD_DIALOG));
}
}
#endif
#define CTL_CODE( DeviceType, Function, Method, Access ) ( \
((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \
)
//
#define METHOD_BUFFERED 0
#define FILE_ANY_ACCESS 0
#define IOCTL_SVE_FIMD_SET_INTERFACE_PARAM \
CTL_CODE(SVE_DEVICE_TYPE, SVE_FIMD_SET_INTERFACE_PARAM, METHOD_BUFFERED, FILE_ANY_ACCESS)
typedef enum
{
DISP_VIDOUT_RGBIF,
DISP_VIDOUT_I80IF_LDI0,
DISP_VIDOUT_I80IF_LDI1,
} DISP_VIDOUT_MODE;
typedef enum
{
DISP_16BIT_RGB565_P = 0,
DISP_16BIT_RGB565_S,
DISP_18BIT_RGB666_P,
DISP_18BIT_RGB666_S,
DISP_24BIT_RGB888_P,
DISP_24BIT_RGB888_S,
} DISP_RGBIFOUT_MODE;
typedef struct _tDevInfo
{
DISP_VIDOUT_MODE VideoOutMode;
DISP_RGBIFOUT_MODE RGBOutMode;
unsigned int uiWidth;
unsigned int uiHeight;
unsigned int VBPD_Value;
unsigned int VFPD_Value;
unsigned int VSPW_Value;
unsigned int HBPD_Value;
unsigned int HFPD_Value;
unsigned int HSPW_Value;
unsigned int VCLK_Polarity;
unsigned int HSYNC_Polarity;
unsigned int VSYNC_Polarity;
unsigned int VDEN_Polarity;
unsigned int PNR_Mode;
unsigned int VCLK_Source;
unsigned int Frame_Rate;
unsigned int VCLK_Direction;
} tDevInfo;
typedef struct
{
tDevInfo tRGBDevInfo; // RGB I/F Device Information
} SVEARG_FIMD_OUTPUT_IF;
#define IVCLK_FALL_EDGE (0<<7)
#define IVCLK_RISE_EDGE (1<<7)
#define IHSYNC_HIGH_ACTIVE (0<<6)
#define IHSYNC_LOW_ACTIVE (1<<6)
#define IVSYNC_HIGH_ACTIVE (0<<5)
#define IVSYNC_LOW_ACTIVE (1<<5)
#define IVDEN_HIGH_ACTIVE (0<<4)
#define IVDEN_LOW_ACTIVE (1<<4)
#define PNRMODE_RGB_P (0<<13)
#define PNRMODE_BGR_P (1<<13)
#define PNRMODE_RGB_S (2<<13)
#define PNRMODE_BGR_S (3<<13)
#define PNRMODE_MASK (3<<13)
#define CLKSEL_F_HCLK (0<<2)
#define CLKSEL_F_LCDCLK (1<<2)
#define CLKDIR_DIRECT (0<<4)
#define CLKDIR_DIVIDED (1<<4)
#define LCD_WIDTH 320
#define LCD_HEIGHT 240
#define LCD_VBPD 15
#define LCD_VFPD 4
#define LCD_VSPW 3
#define LCD_HBPD 38
#define LCD_HFPD 20
#define LCD_HSPW 30
#define LCD_RGB_OUT_MODE DISP_16BIT_RGB565_S
#define LCD_VCLK_POLARITY IVCLK_RISE_EDGE
#define LCD_HSYNC_POLARITY IHSYNC_LOW_ACTIVE
#define LCD_VSYNC_POLARITY IVSYNC_LOW_ACTIVE
#define LCD_VDEN_POLARITY IVDEN_HIGH_ACTIVE
#define LCD_PNR_MODE PNRMODE_RGB_P
#define LCD_VCLK_SOURCE CLKSEL_F_HCLK
#define LCD_VCLK_DIRECTION CLKDIR_DIVIDED
#define LCD_FRAME_RATE 60
#define LCD_TFT_CLKVAL 9
#define LCD_BPP 16
int LDI_fill_output_device_information(void *pDevInfo)
{
// LDI_ERROR error = LDI_SUCCESS;
tDevInfo *pDeviceInfo;
// LDI_MSG((_T("[LDI]++LDI_fill_output_device_information()\n\r")));
if (pDevInfo == NULL)
{
// LDI_ERR((_T("[LDI:ERR] LDI_fill_output_device_information() : Null Parameter\n\r")));
// error = DISP_ERROR_NULL_PARAMETER;
// goto CleanUp;
}
pDeviceInfo = (tDevInfo *)pDevInfo;
pDeviceInfo->RGBOutMode = LCD_RGB_OUT_MODE;
pDeviceInfo->uiWidth = LCD_WIDTH;
pDeviceInfo->uiHeight = LCD_HEIGHT;
pDeviceInfo->VBPD_Value = LCD_VBPD;
pDeviceInfo->VFPD_Value = LCD_VFPD;
pDeviceInfo->VSPW_Value = LCD_VSPW;
pDeviceInfo->HBPD_Value = LCD_HBPD;
pDeviceInfo->HFPD_Value = LCD_HFPD;
pDeviceInfo->HSPW_Value = LCD_HSPW;
pDeviceInfo->VCLK_Polarity = LCD_VCLK_POLARITY;
pDeviceInfo->HSYNC_Polarity = LCD_HSYNC_POLARITY;
pDeviceInfo->VSYNC_Polarity = LCD_VSYNC_POLARITY;
pDeviceInfo->VDEN_Polarity = LCD_VDEN_POLARITY;
pDeviceInfo->PNR_Mode = LCD_PNR_MODE;
pDeviceInfo->VCLK_Source = LCD_VCLK_SOURCE;
pDeviceInfo->VCLK_Direction = LCD_VCLK_DIRECTION;
pDeviceInfo->Frame_Rate = LCD_FRAME_RATE; // VCLK (Max 10 MHz)
//CleanUp:
// LDI_MSG((_T("[LDI]--LDI_fill_output_device_information()\n\r")));
return 0;
}
typedef enum
{
SVE_RESOURCE_API_BASE = 100,
// Resource Request/Release IOCTL(FIMD)
SVE_RSC_REQUEST_FIMD_INTERFACE,
SVE_RSC_RELEASE_FIMD_INTERFACE,
SVE_RSC_REQUEST_FIMD_WIN0,
SVE_RSC_RELEASE_FIMD_WIN0,
SVE_RSC_REQUEST_FIMD_WIN1,
SVE_RSC_RELEASE_FIMD_WIN1,
SVE_RESOURCE_API_END,
// FIMD Function IOCTL
SVE_FIMD_FUNCTION_API_BASE = 200,
SVE_FIMD_SET_INTERFACE_PARAM,
SVE_FIMD_SET_OUTPUT_RGBIF,
SVE_FIMD_SET_OUTPUT_ENABLE,
SVE_FIMD_SET_OUTPUT_DISABLE,
SVE_FIMD_SET_WINDOW_MODE,
SVE_FIMD_SET_WINDOW_POSITION,
SVE_FIMD_SET_WINDOW_FRAMEBUFFER,
SVE_FIMD_SET_WINDOW_COLORMAP,
SVE_FIMD_SET_WINDOW_ENABLE,
SVE_FIMD_SET_WINDOW_DISABLE,
SVE_FIMD_SET_WINDOW_BLEND_DISABLE,
SVE_FIMD_SET_WINDOW_BLEND_COLORKEY,
SVE_FIMD_SET_WINDOW_BLEND_ALPHA,
SVE_FIMD_WAIT_FRAME_INTERRUPT,
SVE_FIMD_GET_OUTPUT_STATUS,
SVE_FIMD_GET_WINDOW_STATUS,
SVE_FIMD_FUNCTION_API_END,
// Power Management IOCTL
SVE_PM_POWER_API_BASE = 1000,
SVE_PM_SET_POWER_ON,
SVE_PM_SET_POWER_OFF,
SVE_PM_GET_POWER_STATUS,
SVE_PM_POWER_API_END,
SVE_API_ENUM_END
} SVE_API_FUNCTION_CODE; // 0x0 ~ 0xFFF
DWORD svsbuf[18];
int
SetLcdValueFromReg()
{
HKEY hKey;
int nRet = DMDO_0;
DWORD dwSize, dwAngle, dwType = REG_DWORD;
DWORD ScreenWidth=320;
DWORD ScreenHeight=240;
DWORD HBP=38;
DWORD HFP=2;
DWORD HSW=8;
DWORD PPL=19;
DWORD VBP=16;
DWORD VFP=4;
DWORD VSW=1;
DWORD LPP=239;
DWORD CLKDIV=5;
DWORD CPL=319;
DWORD IOE=0;
DWORD IPC=1;
DWORD IHS=1;
DWORD IVS=1;
DWORD RGB=1;
DWORD LIGHT=0;
if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SYSTEM\\GDI\\LCD"),0,0, &hKey))
{
dwSize = sizeof(DWORD);
if (ERROR_SUCCESS == RegQueryValueEx(hKey,
TEXT("LCDWIDTH"),
NULL,
&dwType,
(LPBYTE)&dwAngle,
&dwSize))
{
// LDI_MSG((_T("[LDI]--LDI_deinitialize_LCD_module() : %d\n\r"), dwAngle));RegSetValueEx(hkey, _T("1"), 0, REG_SZ, (LPBYTE)_T("内容"), len));//字符串
}
dwAngle=svsbuf[0];
RegSetValueEx(hKey, TEXT("ScreenWidth"), NULL,REG_DWORD, (LPBYTE)&dwAngle,4);
dwAngle=svsbuf[1];
RegSetValueEx(hKey, TEXT("ScreenHeight"), NULL,REG_DWORD, (LPBYTE)&dwAngle,4);
#if 1
dwAngle=svsbuf[2];
RegSetValueEx(hKey, TEXT("HBP"), NULL,REG_DWORD, (LPBYTE)&dwAngle,4);
dwAngle=svsbuf[3];
RegSetValueEx(hKey, TEXT("HFP"), NULL,REG_DWORD, (LPBYTE)&dwAngle,4);
dwAngle=svsbuf[4];
RegSetValueEx(hKey, TEXT("HSW"), NULL,REG_DWORD, (LPBYTE)&dwAngle,4);
dwAngle=svsbuf[5];
RegSetValueEx(hKey, TEXT("PPL"), NULL,REG_DWORD, (LPBYTE)&dwAngle,4);
dwAngle=svsbuf[6];
RegSetValueEx(hKey, TEXT("VBP"), NULL,REG_DWORD, (LPBYTE)&dwAngle,4);
dwAngle=svsbuf[7];
RegSetValueEx(hKey, TEXT("VFP"), NULL,REG_DWORD, (LPBYTE)&dwAngle,4);
dwAngle=svsbuf[8];
RegSetValueEx(hKey, TEXT("VSW"), NULL,REG_DWORD, (LPBYTE)&dwAngle,4);
dwAngle=svsbuf[9];
RegSetValueEx(hKey, TEXT("LPP"), NULL,REG_DWORD, (LPBYTE)&dwAngle,4);
dwAngle=svsbuf[10];
RegSetValueEx(hKey, TEXT("CLKDIV"), NULL,REG_DWORD, (LPBYTE)&dwAngle,4);
dwAngle=svsbuf[11];
RegSetValueEx(hKey, TEXT("CPL"), NULL,REG_DWORD, (LPBYTE)&dwAngle,4);
dwAngle=svsbuf[12];
RegSetValueEx(hKey, TEXT("IOE"), NULL,REG_DWORD, (LPBYTE)&dwAngle,4);
dwAngle=svsbuf[13];
RegSetValueEx(hKey, TEXT("IPC"), NULL,REG_DWORD, (LPBYTE)&dwAngle,4);
dwAngle=svsbuf[14];
RegSetValueEx(hKey, TEXT("IHS"), NULL,REG_DWORD, (LPBYTE)&dwAngle,4);
dwAngle=svsbuf[15];
RegSetValueEx(hKey, TEXT("IVS"), NULL,REG_DWORD, (LPBYTE)&dwAngle,4);
dwAngle=svsbuf[16];
RegSetValueEx(hKey, TEXT("RGB"), NULL,REG_DWORD, (LPBYTE)&dwAngle,4);
dwAngle=svsbuf[17];
RegSetValueEx(hKey, TEXT("LIGHT"), NULL,REG_DWORD, (LPBYTE)&dwAngle,4);
#endif
RegCloseKey(hKey);
}
return dwAngle;
}
#define SVE_DEVICE_TYPE (0xA000) // SVE-unique device type
void CAutoAddLcdDlg::OnBnChangeLcd()
{
#if 1
bool svs=false;
int kl;
int i=0,m=12,x;int y[18]={12,13,4,4,4,4,4,4,4,4,7,4,4,4,4,4,4,6};
int j[21],value[18];
CString cs;
char sRead[18];
char buf[14];
//MessageBox(_T("1"));
char* buff[]={"ScreenWidth=","ScreenHeight=","HBP=","HFP=","HSW=","PPL=","VBP=","VFP=","VSW=","LPP=","CLKDIV=","CPL=","IOE=","IPC=","IHS=","IVS=","RGB=","LIGHT="};
CFile mFile;//(_T("\\FlashDisk\\LCDconfig.ini"),CFile::modeRead);
CFileException ex;
if (!mFile.Open(_T("\\FlashDisk\\LCDconfig.ini"), CFile::modeRead | CFile::shareDenyWrite, &ex))
{
MessageBox(_T("error"));
}
for( x=1;x<=18;x++)
{
while(1)
{
memset(buf,0,14);
mFile.Seek(i++,CFile::begin);
mFile.Read(buf,m);
if (strcmp(buff[x-1], buf) == 0)
{
j[x]=--i;
svs=true;
i=i+m;
m=y[x];
break;
}
}
}
for(int x=0;x<17;x++)
{
memset(buf,0,14);
mFile.Seek(j[x+1]+y[x],CFile::begin);
mFile.Read(buf,j[x+2]-j[x+1]-y[x]-2);
//svsbuf[x]=buf[0]+buf[1]+buf[2]
for(i=j[x+2]-j[x+1]-y[x]-2-1;i>=0;i--)
{
kl=1;
for(int k=0;k<i;k++)
kl*=10;
svsbuf[x]+=(buf[j[x+2]-j[x+1]-y[x]-2-1-i]-48)*kl;
}
//cs.Format(_T("%d %d %d %d %d %d"),svsbuf[x],buf[0],buf[1],buf[2],x,j[x+2]-j[x+1]-y[x]-2);
//MessageBox(cs);
}
mFile.Close();
SetLcdValueFromReg();
#endif
;
typedef BOOL (WINAPI *_TouchCalibrate)();
HINSTANCE hinstance = LoadLibrary(_T("coredll.dll"));
if (hinstance == NULL)
{
return;
}
//定义一个函数指针
_TouchCalibrate TouchCalibrate = NULL;
//获取函数入口地址
TouchCalibrate = (_TouchCalibrate)GetProcAddress(hinstance , L"TouchCalibrate");
if (TouchCalibrate == NULL)
{
return;
}
TouchCalibrate ();
FreeLibrary(hinstance );
SendMessage(WM_CLOSE);
}