From c7fa6f5281f67ffbc7b727e49e2c9d1625c9f619 Mon Sep 17 00:00:00 2001 From: tanhua1 Date: Thu, 19 Aug 2021 13:31:15 +0800 Subject: [PATCH] backlight: support backlight current align configuration for exp mode lm3697 exp mode backlight current with the different curve to other chips, add backlight current align configuration for the same current at the same hal level, to support the same brightness at the same hal level Change-Id: Ib6ac8dc3bb36389ba2c885c3e4b986ac9316bdc4 Signed-off-by: tanhua1 Reviewed-on: https://gerrit.mot.com/2045773 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Dezhen Hou Reviewed-by: Shanshan Dai Reviewed-by: Xiangpo Zhao Submit-Approved: Jira Key --- drivers/backlight/lm3697/ti_lm3697.h | 8 ++++++++ .../backlight/lm3697/ti_lm3697_backlight.c | 20 ++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/drivers/backlight/lm3697/ti_lm3697.h b/drivers/backlight/lm3697/ti_lm3697.h index 357867a907de..03f5c5318c93 100644 --- a/drivers/backlight/lm3697/ti_lm3697.h +++ b/drivers/backlight/lm3697/ti_lm3697.h @@ -208,6 +208,9 @@ struct ti_lmu_bl { /* Map type */ unsigned int map_type; + /* Align boost current to AW chip */ + unsigned int led_current_align; + struct pwm_device *pwm; }; @@ -236,6 +239,11 @@ enum backlight_map_type { LINEAR_TYPE }; +enum backlight_exp_current_align { + ALIGN_NONE, + ALIGN_AW99703 +}; + extern struct ti_lmu_bl_cfg lmu_bl_cfg[LMU_MAX_ID]; extern int ti_lmu_backlight_device_init(void); extern void ti_lmu_backlight_exit(void); diff --git a/drivers/backlight/lm3697/ti_lm3697_backlight.c b/drivers/backlight/lm3697/ti_lm3697_backlight.c index 1bfe5579b072..112330009ad8 100644 --- a/drivers/backlight/lm3697/ti_lm3697_backlight.c +++ b/drivers/backlight/lm3697/ti_lm3697_backlight.c @@ -246,7 +246,7 @@ static int ti_lmu_backlight_update_brightness_register(struct ti_lmu_bl *lmu_bl, int ret; // int i = 0; - regmap_write(regmap, 0x13, 0x22); + regmap_write(regmap, 0x13, 0x11); if (lmu_bl->mode == BL_PWM_BASED) { switch (cfg->pwm_action) { @@ -287,6 +287,14 @@ static int ti_lmu_backlight_update_brightness_register(struct ti_lmu_bl *lmu_bl, if (!reginfo->brightness_lsb) return -EINVAL; + if(lmu_bl->map_type == EXPONENTIAL_TYPE && lmu_bl->led_current_align) { + if(brightness) { + pr_info("[bkl] %s brightness = %d, align = %d\n", __func__, + brightness, lmu_bl->led_current_align); + brightness = brightness*8383/10000+324; + } + } + reg = reginfo->brightness_lsb[lmu_bl->bank_id]; ret = regmap_update_bits(regmap, reg, LMU_BACKLIGHT_11BIT_LSB_MASK, @@ -430,6 +438,12 @@ static void ti_lmu_backlight_of_get_light_properties(struct device_node *np, pr_info("[bkl] %s map_type default %d\n", __func__, lmu_bl->map_type); } + + if(of_property_read_u32(np, "current-align-type", &lmu_bl->led_current_align)) { + lmu_bl->led_current_align = ALIGN_NONE; + pr_info("[bkl] %s led_current_align default %d, no align, keep as lm3697 exp mode\n", __func__, + lmu_bl->led_current_align); + } } static void ti_lmu_backlight_of_get_brightness_mode(struct device_node *np, @@ -619,8 +633,8 @@ static int ti_lmu_backlight_init(struct ti_lmu_bl_chip *chip) regmap_write(regmap, 0x18, 0x15);//21.8mA default regmap_write(regmap, 0x1A, boost_ctl); regmap_write(regmap, 0x1C, 0x0E); - regmap_write(regmap, 0x22, 0x07); - regmap_write(regmap, 0x23, 0xFF); + //regmap_write(regmap, 0x22, 0x07); + //regmap_write(regmap, 0x23, 0xFF); regmap_write(regmap, 0x24, 0x02); regmap_write(regmap, 0xB4, 0x03);