📄 bsptcled.cpp
字号:
//------------------------------------------------------------------------------
//
// Copyright (C) 2005, Motorola Inc. All Rights Reserved
//
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//
// File: bsptcled.cpp
//
// Provides the implementation for BSP-specific tcled support.
//
//------------------------------------------------------------------------------
#include <windows.h>
#include "pmic_tcled.h"
#include "pmic_bklight.h"
#include "bsptcled.h"
//-----------------------------------------------------------------------------
// Defines
#define BSP_TCLED_DEBUG FALSE
//-----------------------------------------------------------------------------
// Types
//-----------------------------------------------------------------------------
// External Functions
//-----------------------------------------------------------------------------
// External Variables
//-----------------------------------------------------------------------------
// Global Variables
//-----------------------------------------------------------------------------
// Local Variables
//-----------------------------------------------------------------------------
// Local Functions
//-----------------------------------------------------------------------------
//
// Function: BSPTcledInit
//
// This function initializes the tcled PMIC
//
// Parameters:
// none
//
// Returns:
// TRUE means success
// FALSE means fail
//
//-----------------------------------------------------------------------------
BOOL BSPTcledInit(void)
{
BOOL rc = TRUE;
DEBUGMSG(BSP_TCLED_DEBUG, (TEXT("+BSPTcledInit \r\n")));
DEBUGMSG(BSP_TCLED_DEBUG, (TEXT("-BSPTcledInit \r\n")));
return rc;
}
//-----------------------------------------------------------------------------
//
// Function: BSPTcledDeinit
//
// This function deinitializes the tcled PMIC
//
// Parameters:
// none
//
// Returns:
// TRUE means success
// FALSE means fail
//
//-----------------------------------------------------------------------------
BOOL BSPTcledDeinit(void)
{
BOOL rc = TRUE;
DEBUGMSG(BSP_TCLED_DEBUG, (TEXT("+BSPTcledDeinit \r\n")));
DEBUGMSG(BSP_TCLED_DEBUG, (TEXT("-BSPTcledDeinit \r\n")));
return rc;
}
//-----------------------------------------------------------------------------
//
// Function: BSPTcledIOControl
//
// This function handles the IOCotrol to the tcled pmic
//
// Parameters:
// dwContext
// [in] Context of call
// Ioctl
// [in] the io control code passed from upper layer
// pInBuf
// [in] IN buffer
// InBufLen
// [in] size of IN buffer
// pOutBuf
// [out] OUT buffer
// OutBufLen
// [out] size of OUT buffer
// pdwBytesTransferred
// [out] returned bytes
//
// Returns:
// TRUE means success
// FALSE means fail
//
//-----------------------------------------------------------------------------
BOOL BSPTcledIOControl(
DWORD dwContext,
DWORD Ioctl,
PUCHAR pInBuf,
DWORD InBufLen,
PUCHAR pOutBuf,
DWORD OutBufLen,
PDWORD pdwBytesTransferred)
{
BOOL rc = TRUE;
PFUN_CURRENT_PKT pFunCurrentPkt;
PFUN_CYCLETIME_PKT pFunCycleTimePkt;
PFUN_DUTYCYCLE_PKT pFunDutyCyclePkt;
PIND_CURRENT_PKT pIndCurrentPkt;
PIND_BLINK_PKT pIndBlinkPkt;
PFUN_PATTERN_PKT pFunPatternPkt;
PFUN_STROBE_PKT pFunStrobePkt;
PFUN_SPEED_PKT pFunSpeedPkt;
DEBUGMSG(BSP_TCLED_DEBUG, (TEXT("+BSPTcledIOControl \r\n")));
switch(Ioctl)
{
case TCLED_IOCTL_ENABLE:
if (pInBuf == NULL)
rc = FALSE;
if(rc == TRUE)
{
if(PmicBacklightMasterEnable() != PMIC_SUCCESS)
{
ERRORMSG(TRUE, (TEXT("pfnPmicBacklightMasterEnable failed\r\n")));
rc = FALSE;
}
if(PmicTCLEDEnable((TCLED_MODE)*pInBuf, TCLED_FUN_BANK1) != PMIC_SUCCESS)
{
ERRORMSG(TRUE, (TEXT("pfnPmicTCLEDEnable failed\r\n")));
rc = FALSE;
}
}
break;
case TCLED_IOCTL_DISABLE:
if(PmicBacklightMasterDisable() != PMIC_SUCCESS)
{
ERRORMSG(TRUE, (TEXT("pfnPmicBacklightMasterDisable failed\r\n")));
rc = FALSE;
}
if(PmicTCLEDDisable(TCLED_FUN_BANK1) != PMIC_SUCCESS)
{
ERRORMSG(TRUE, (TEXT("pfnPmicTCLEDDisable failed\r\n")));
rc = FALSE;
}
break;
case TCLED_IOCTL_GETMODE:
if (pOutBuf == NULL)
rc = FALSE;
if (rc == TRUE)
{
if(PmicTCLEDGetMode((TCLED_MODE*)pOutBuf, TCLED_FUN_BANK1) != PMIC_SUCCESS)
{
ERRORMSG(TRUE, (TEXT("pfnPmicTCLEDGetMode failed\r\n")));
rc = FALSE;
}
}
break;
case TCLED_IOCTL_IND_SETCURRENTLEVEL:
if (pInBuf != NULL)
pIndCurrentPkt = (PIND_CURRENT_PKT)pInBuf;
else
rc = FALSE;
if (rc == TRUE)
{
if(PmicTCLEDIndicatorSetCurrentLevel(pIndCurrentPkt->channel, pIndCurrentPkt->level) != PMIC_SUCCESS)
{
ERRORMSG(TRUE, (TEXT("pfnPmicTCLEDIndicatorSetCurrentLevel failed\r\n")));
rc = FALSE;
}
}
break;
case TCLED_IOCTL_IND_GETCURRENTLEVEL:
if (pOutBuf != NULL)
pIndCurrentPkt = (PIND_CURRENT_PKT)pOutBuf;
else
rc = FALSE;
if (rc == TRUE)
{
if(PmicTCLEDIndicatorGetCurrentLevel(pIndCurrentPkt->channel, &pIndCurrentPkt->level) != PMIC_SUCCESS)
{
ERRORMSG(TRUE, (TEXT("pfnPmicTCLEDIndicatorGetCurrentLevel failed\r\n")));
rc = FALSE;
}
}
break;
case TCLED_IOCTL_IND_SETBLINKPATTERN:
if (pInBuf != NULL)
pIndBlinkPkt = (PIND_BLINK_PKT)pInBuf;
else
rc = FALSE;
if (rc == TRUE)
{
if(PmicTCLEDIndicatorSetBlinkPattern(pIndBlinkPkt->channel, pIndBlinkPkt->mode, pIndBlinkPkt->skip) != PMIC_SUCCESS)
{
ERRORMSG(TRUE, (TEXT("pfnPmicTCLEDIndicatorSetBlinkPattern failed\r\n")));
rc = FALSE;
}
}
break;
case TCLED_IOCTL_IND_GETBLINKPATTERN:
if (pOutBuf != NULL)
pIndBlinkPkt = (PIND_BLINK_PKT)pOutBuf;
else
rc = FALSE;
if (rc == TRUE)
{
if(PmicTCLEDIndicatorGetBlinkPattern(pIndBlinkPkt->channel, &pIndBlinkPkt->mode, &pIndBlinkPkt->skip) != PMIC_SUCCESS)
{
ERRORMSG(TRUE, (TEXT("pfnPmicTCLEDIndicatorGetBlinkPattern failed\r\n")));
rc = FALSE;
}
}
break;
case TCLED_IOCTL_FUN_SETCURRENTLEVEL:
if (pInBuf != NULL)
pFunCurrentPkt = (PFUN_CURRENT_PKT)pInBuf;
else
rc = FALSE;
if (rc == TRUE)
{
if(PmicTCLEDFunLightSetCurrentLevel(pFunCurrentPkt->bank, pFunCurrentPkt->channel, pFunCurrentPkt->level) != PMIC_SUCCESS)
{
ERRORMSG(TRUE, (TEXT("pfnPmicTCLEDFunLightSetCurrentLevel failed\r\n")));
rc = FALSE;
}
}
break;
case TCLED_IOCTL_FUN_GETCURRENTLEVEL:
if (pOutBuf != NULL)
pFunCurrentPkt = (PFUN_CURRENT_PKT)pOutBuf;
else
rc = FALSE;
if (rc == TRUE)
{
if(PmicTCLEDFunLightGetCurrentLevel(pFunCurrentPkt->bank, pFunCurrentPkt->channel, &pFunCurrentPkt->level) != PMIC_SUCCESS)
{
ERRORMSG(TRUE, (TEXT("pfnPmicTCLEDFunLightGetCurrentLevel failed\r\n")));
rc = FALSE;
}
}
break;
case TCLED_IOCTL_FUN_SETCYCLETIME:
if (pInBuf != NULL)
pFunCycleTimePkt = (PFUN_CYCLETIME_PKT)pInBuf;
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -