📄 lcd_plat.c
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR INDEMNITIES.
//
//
// (C) Copyright 2006 Marvell International Ltd.
// All Rights Reserved
//
#include <windows.h>
#include <types.h>
#include <string.h>
#include <stdio.h>
#include <tchar.h>
#include <nkintr.h>
#include <monahans.h>
#include <ceddk.h>
#include "args.h"
#include "ebootcfg.h"
#include "ioctl_cfg.h"
#include "DispDrvr.h"
#define DEFINE_CURSOR_GLOBALS
#include "PMIC_DRV.h"
#include "lcd_plat.h"
#include "lcd_panels.h"
UINT get_blit_option()
{
DWORD out_size;
BSP_ARGS args;
KernelIoControl(IOCTL_GET_BSP_ARGS, NULL, 0,
&args, sizeof(BSP_ARGS), &out_size);
return args.DefaultBlit;
}
static DWORD get_panel_type()
{
DWORD out_size;
BSP_ARGS args;
KernelIoControl(IOCTL_GET_BSP_ARGS, NULL, 0,
&args, sizeof(BSP_ARGS), &out_size);
return args.DefaultLCDPanel;
}
BOOL is_dual_panel()
{
DWORD cfg = get_panel_type();
switch (cfg)
{
case LCD_PANEL_ID_VGA_QVGA_OLED_LEAD:
case LCD_PANEL_ID_VGA_QVGA_OLED_LEAD_FREE:
case LCD_PANEL_ID_VGA_QVGA_OLED_LEAD_FREE_LANDSCAPE:
return TRUE;
default:
return FALSE;
}
}
void get_screen_size(UINT32 *width, UINT32 *height)
{
HKEY hKey;
static WCHAR s_szGPERegKey[] = L"Drivers\\Display\\GPE";
// default size
*width = 240;
*height = 320;
// Open GPE's regkey and read the know values from it.
if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE,
s_szGPERegKey,
0,
0,
&hKey))
{
DWORD dwType;
DWORD dwValue;
DWORD dwSize;
dwSize = sizeof (ULONG);
if (ERROR_SUCCESS == RegQueryValueEx(hKey,
L"HorizontalSize",
NULL,
&dwType,
(BYTE*)&dwValue,
&dwSize))
{
if (REG_DWORD == dwType)
{
*width = dwValue;
}
}
dwSize = sizeof (ULONG);
if (ERROR_SUCCESS == RegQueryValueEx(hKey,
L"VerticalSize",
NULL,
&dwType,
(BYTE*)&dwValue,
&dwSize))
{
if (REG_DWORD == dwType)
{
*height = dwValue;
}
}
}
}
static BOOL is_vga()
{
UINT32 width, height;
get_screen_size(&width, &height);
return width * height == 640 * 480;
}
BOOL LCDPanelSelect(void** panel)
{
active_panel_t *p;
DWORD cfg;
cfg = get_panel_type();
switch (cfg)
{
case LCD_PANEL_ID_VGA_QVGA_OLED_LEAD:
p = (void*)vga_qvga_panel_init(is_vga(), 1);
break;
case LCD_PANEL_ID_VGA_QVGA_OLED_LEAD_FREE:
case LCD_PANEL_ID_VGA_QVGA_OLED_LEAD_FREE_LANDSCAPE:
default:
p = (void*)vga_qvga_panel_init(is_vga(), 0);
break;
}
*panel = (void*)p;
return TRUE;
}
void set_lcd_domain(BOOL enable)
{
/* PMIC Upgrade */
/*
HANDLE pic_drv;
DWORD domain=PIC_DOMAIN_DEBUG_3V;
pic_drv = CreateFile(PIC_FILE_NAME, 0, 0, NULL, 0, 0, NULL);
if (!pic_drv)
ERRORMSG(1, (TEXT("open pic file failed!\r\n")));
if(!DeviceIoControl(pic_drv, enable?(PIC_ENABLE_DOMAIN):(PIC_DISABLE_DOMAIN), &domain, sizeof(domain),
0,0,0,0))
{
ERRORMSG(1,(_T("Error %s domain for LCD.\r\n"), enable? _T("enabling"):_T("disabling")));
return;
}
CloseHandle(pic_drv);
*/
PXA_STATUS_T ulStatus = PXA_STATUS_SUCCESS;
if (enable)
{
/* Enable */
ulStatus = PMIC_EnablePower(PMIC_LCD_CLIENT_ID);
if (PXA_STATUS_SUCCESS != ulStatus)
{
ERRORMSG(1,(_T("[LCD] set_lcd_domain failed in PMIC_EnablePower (ulStatus = %d) .\r\n"), ulStatus));
return;
}
}
else
{
/* Disable */
ulStatus = PMIC_DisablePower(PMIC_LCD_CLIENT_ID);
if (PXA_STATUS_SUCCESS != ulStatus)
{
ERRORMSG(1,(_T("[LCD] set_lcd_domain failed in PMIC_DisablePower (ulStatus = %d) .\r\n"), ulStatus));
return;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -