📄 backlight.c
字号:
//
// 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) 2005-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
//
//------------------------------------------------------------------------------
/*
Module Name:
backlight.c
Abstract:
Implementation of Windows CE LCD Backlight device driver.
For MX31, the IOMux settings, clock gating, and IPU configuration are done
in the display initialization code. Only the backlight intensity control
code is in this driver.
Functions:
Notes:
*/
#ifdef PLAT_PMC
#include <bsp.h>
#include <backlight.h>
//------------------------------------------------------------------------------
// Types
// This is a dummy struct to keep PMCBOOTLOADER backlight MDD happy
typedef struct
{
int dummy;
} PWMBACKLIGHT, *PPWMBACKLIGHT;
static PWMBACKLIGHT gPWMBacklight;
//------------------------------------------------------------------------------
// Local Variables
static PCSP_IPU_REGS g_pIPU;
//------------------------------------------------------------------------------
// Local Functions
void Plat_DisplayGetBacklightConfig(PBACKLIGHTCONFIG pConfig)
{
pConfig->pwm = 0;
// Backlight enable signal
pConfig->gpioEnable.type = GPIO_NONE;
// MX31 display has a normal brightness scale,
pConfig->dwRange = 255;
pConfig->nLevels = 5;
pConfig->dwPercent[0] = 0;
pConfig->dwLevel[0] = 0;
pConfig->dwPercent[1] = 25;
pConfig->dwLevel[1] = 64;
pConfig->dwPercent[2] = 50;
pConfig->dwLevel[2] = 128;
pConfig->dwPercent[3] = 75;
pConfig->dwLevel[3] = 192;
pConfig->dwPercent[4] = 100;
pConfig->dwLevel[4] = 255;
}
/*++
Routine Description:
This is the low level initialization routine for the Backlight driver.
Arguments:
RegistryPath - Pointer to the name of registry key of the backlight driver.
.
Return Value:
The status of the operation.
--*/
BOOL
BacklightPDDInitialize(
PBACKLIGHT pBacklight
)
{
PHYSICAL_ADDRESS phyAddr;
PPWMBACKLIGHT pPWMBacklight = NULL;
BOOL fOk = FALSE;
DEBUGMSG(1,(L"+BacklightPDDInitialize\r\n"));
/* Dummy Code to keep PMC backlight MDD happy */
if (pBacklight == NULL) {
DEBUGMSG (1, (L"-BacklightPDDInitialize(error): Bad parameters\r\n"));
goto done;
}
pPWMBacklight = &gPWMBacklight;
memset(pPWMBacklight, 0, sizeof(*pPWMBacklight));
pBacklight->pvPDD = (PVOID)pPWMBacklight;
/* End of dummy code to keep PMC backlight MDD happy */
phyAddr.QuadPart = CSP_BASE_REG_PA_IPU;
// Map peripheral physical address to virtual address
g_pIPU = (PCSP_IPU_REGS)MmMapIoSpace(phyAddr, sizeof(CSP_IPU_REGS), FALSE);
// Initialization completed successfully
fOk = TRUE;
done:
// did we succeed?
if(!fOk) {
BacklightPDDDeinitialize((PBACKLIGHT) pPWMBacklight);
if (pBacklight != NULL)
pBacklight->pvPDD = NULL;
}
DEBUGMSG((pPWMBacklight == NULL),
(_T("BacklightPDDInitialize: returning 0x%08x\r\n"), pPWMBacklight));
RETAILMSG(1, (L"BacklightPDDInitialize: fOk = %d, PWMReg: %x\r\n", fOk));
return fOk;
}
/*++
Routine Description:
This is the low lvel deinitialization routine for the Backlight driver.
Arguments:
pBacklight - Pointer to driver object created by the system.
Return Value:
The status of the operation.
--*/
BOOL
BacklightPDDDeinitialize(
PBACKLIGHT pBacklight
)
{
/* Dummy Code to keep PMCBootloader backlight MDD happy */
PPWMBACKLIGHT pPWMBacklight = (PPWMBACKLIGHT)pBacklight->pvPDD;
if (NULL != pPWMBacklight) {
// disable hardware
// TODO: Disable PWM?
#if 0 // Statically allocate so we can run in the bootloader
// free structure
LocalFree(pPWMBacklight);
// TODO: Unmap the IPU memory?
#endif
}
/* End of dummy Code to keep PMC backlight MDD happy */
return TRUE;
}
/*++
Routine Description:
This is used to set the brightness of the backlight. The caller must
hold the backlight critical section.
Arguments:
pBacklight - Pointer to driver object created by the system.
dwBrightness - percentage of brightness level 0 - 100 %
Return Value:
The status of the operation.
--*/
BOOL
BacklightPDDSetLevel(
PBACKLIGHT pBacklight,
DWORD level
)
{
// 'pBacklight' is a dummy variable
// Use 'level' to set backlight level in the IPU
INSREG32BF(&g_pIPU->SDC_CUR_BLINK_PWM_CTRL,
IPU_SDC_CUR_BLINK_PWM_CTRL_PWM,
level);
return TRUE;
}
// this routine is called during suspend to save backlight state
void
BacklightPDDPowerDown(PBACKLIGHT pBacklight)
{
// nothing to do, we save state during initialization and normal operation
}
// this routine is called during resume to restore backlight state
void
BacklightPDDPowerUp(PBACKLIGHT pBacklight)
{
// nothing to do, power-up done in display driver
}
///////////////////////////////////////////////////////////////////////////////
// MX31 chip support: dummy routines to keep PMC MDD happy
// Get access to the GPIO registers
PVOID GetGpioAccess(void)
{
return (PVOID) 1; // Just lie, so the caller thinks we succeeded
}
// Free up access to the GPIO registers
void FreeGpioAccess(PVOID pGPIOReg)
{
}
// Set a GPIO as a general purpose output
void SetGpioOutput(PVOID pv, GPIODEF gpio)
{
}
// Set GPIO state either active or inactive
void SetGpioState(PVOID pv, GPIODEF gpio, BOOL bState)
{
}
#endif // PLAT_PMC
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -