摘自mt6755平台Android L cust_led.c
#include
#include
#include
#include
#include
#include
//extern int mtkfb_set_backlight_level(unsigned int level);
//extern int mtkfb_set_backlight_pwm(int div);
extern int disp_bls_set_backlight(unsigned int level);
// Only support 64 levels of backlight (when lcd-backlight = MT65XX_LED_MODE_PWM)
#define BACKLIGHT_LEVEL_PWM_64_FIFO_MODE_SUPPORT 64
// Support 256 levels of backlight (when lcd-backlight = MT65XX_LED_MODE_PWM)
#define BACKLIGHT_LEVEL_PWM_256_SUPPORT 256
// Configure the support type "BACKLIGHT_LEVEL_PWM_256_SUPPORT" or "BACKLIGHT_LEVEL_PWM_64_FIFO_MODE_SUPPORT" !!
#define BACKLIGHT_LEVEL_PWM_MODE_CONFIG BACKLIGHT_LEVEL_PWM_256_SUPPORT
unsigned int Cust_GetBacklightLevelSupport_byPWM(void)
{
return BACKLIGHT_LEVEL_PWM_MODE_CONFIG;
}
unsigned int brightness_mapping(unsigned int level)
{
unsigned int mapped_level;
mapped_level = level;
return mapped_level;
}
/*
* To explain How to set these para for cust_led_list[] of led/backlight
* "name" para: led or backlight
* "mode" para:which mode for led/backlight
* such as:
* MT65XX_LED_MODE_NONE,
* MT65XX_LED_MODE_PWM,
* MT65XX_LED_MODE_GPIO,
* MT65XX_LED_MODE_PMIC,
* MT65XX_LED_MODE_CUST_LCM,
* MT65XX_LED_MODE_CUST_BLS_PWM
*
*"data" para: control methord for led/backlight
* such as:
* MT65XX_LED_PMIC_LCD_ISINK=0,
* MT65XX_LED_PMIC_NLED_ISINK0,
* MT65XX_LED_PMIC_NLED_ISINK1,
* MT65XX_LED_PMIC_NLED_ISINK2,
* MT65XX_LED_PMIC_NLED_ISINK3
*
*"PWM_config" para:PWM(AP side Or BLS module), by default setting{0,0,0,0,0} Or {0}
*struct PWM_config {
* int clock_source;
* int div;
* int low_duration;
* int High_duration;
* BOOL pmic_pad;//AP side PWM pin in PMIC chip (only 89 needs confirm); 1:yes 0:no(default)
*};
*-------------------------------------------------------------------------------------------
* for AP PWM setting as follow:
*1. PWM config data
* clock_source: clock source frequency, can be 0/1
* div: clock division, can be any value within 0~7 (i.e. 1/2^(div) = /1, /2, /4, /8, /16, /32, /64, /128)
* low_duration: only for BACKLIGHT_LEVEL_PWM_64_FIFO_MODE_SUPPORT
* High_duration: only for BACKLIGHT_LEVEL_PWM_64_FIFO_MODE_SUPPORT
*
*2. PWM freq.
* If BACKLIGHT_LEVEL_PWM_MODE_CONFIG = BACKLIGHT_LEVEL_PWM_256_SUPPORT,
* PWM freq. = clock source / 2^(div) / 256
*
* If BACKLIGHT_LEVEL_PWM_MODE_CONFIG = BACKLIGHT_LEVEL_PWM_64_FIFO_MODE_SUPPORT,
* PWM freq. = clock source / 2^(div) / [(High_duration+1)(Level')+(low_duration+1)(64 - Level')]
* = clock source / 2^(div) / [(High_duration+1)*64] (when low_duration = High_duration)
*Clock source:
* 0: block clock/1625 = 26M/1625 = 16K (MT6571)
* 1: block clock = 26M (MT6571)
*Div: 0~7
*
*For example, in MT6571, PWM_config = {1,1,0,0,0}
* ==> PWM freq. = 26M/2^1/256 = 50.78 KHz ( when BACKLIGHT_LEVEL_PWM_256_SUPPORT )
* ==> PWM freq. = 26M/2^1/(0+1)*64 = 203.13 KHz ( when BACKLIGHT_LEVEL_PWM_64_FIFO_MODE_SUPPORT )
*-------------------------------------------------------------------------------------------
* for BLS PWM setting as follow:
*1. PWM config data
* clock_source: clock source frequency, can be 0/1/2/3
* div: clock division, can be any value within 0~1023
* low_duration: non-use
* High_duration: non-use
* pmic_pad: non-use
*
*2. PWM freq.= clock source / (div + 1) /1024
*Clock source:
* 0: 26 MHz
* 1: 104 MHz
* 2: 124.8 MHz
* 3: 156 MHz
*Div: 0~1023
*
*By default, clock_source = 0 and div = 0 => PWM freq. = 26 KHz
*-------------------------------------------------------------------------------------------
*/
static struct cust_mt65xx_led cust_led_list[MT65XX_LED_TYPE_TOTAL] = {
{"red", MT65XX_LED_MODE_NONE, -1,{0}},
{"green", MT65XX_LED_MODE_NONE, -1,{0}},
{"blue", MT65XX_LED_MODE_NONE, -1,{0}},
{"jogball-backlight", MT65XX_LED_MODE_NONE, -1,{0}},
{"keyboard-backlight",MT65XX_LED_MODE_NONE, -1,{0}},
{"button-backlight", MT65XX_LED_MODE_NONE, -1,{0}},
{"lcd-backlight", MT65XX_LED_MODE_CUST_BLS_PWM, (long)disp_bls_set_backlight, {3, 0, 0, 0, 0} },
};
struct cust_mt65xx_led *get_cust_led_list(void)
{
return cust_led_list;
}