From 87315a572a5174cf7a225882d548055402cc7ae9 Mon Sep 17 00:00:00 2001 From: Evoke Zhang Date: Tue, 10 Apr 2018 18:30:26 +0800 Subject: [PATCH] lcd: prevent lcd enable repeatedly to avoid abnormal display PD#164037: lcd: prevent lcd enable repeatedly to avoid abnormal display also optimize backlight init state by detect lcd state Change-Id: I517c3c47aa5fcb0f5026f6dd782e5f522ec847aa Signed-off-by: Evoke Zhang --- drivers/amlogic/media/vout/backlight/aml_bl.c | 35 +++++++++++++++-------- drivers/amlogic/media/vout/backlight/aml_bl_reg.h | 1 + drivers/amlogic/media/vout/lcd/lcd_vout.c | 11 +++++++ 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/drivers/amlogic/media/vout/backlight/aml_bl.c b/drivers/amlogic/media/vout/backlight/aml_bl.c index 7c3575b..f55034d 100644 --- a/drivers/amlogic/media/vout/backlight/aml_bl.c +++ b/drivers/amlogic/media/vout/backlight/aml_bl.c @@ -2945,6 +2945,28 @@ static const struct of_device_id bl_dt_match_table[] = { }; #endif +static void aml_bl_init_status_update(void) +{ + unsigned int state; + + state = bl_vcbus_read(ENCL_VIDEO_EN); + if (state == 0) /* default disable lcd & backlight */ + return; + + /* update bl status */ + bl_drv->state = (BL_STATE_LCD_ON | + BL_STATE_BL_POWER_ON | BL_STATE_BL_ON); + bl_on_request = 1; + + if (brightness_bypass) { + aml_bl_set_level(bl_level_uboot); + bl_on_level = bl_level_uboot; + } else { + aml_bl_update_status(bl_drv->bldev); + bl_on_level = bl_drv->bconf->level_default; + } +} + static int aml_bl_probe(struct platform_device *pdev) { const struct of_device_id *match; @@ -3028,18 +3050,7 @@ static int aml_bl_probe(struct platform_device *pdev) #endif aml_bl_creat_class(); - /* update bl status */ - bl_drv->state = (BL_STATE_LCD_ON | - BL_STATE_BL_POWER_ON | BL_STATE_BL_ON); - bl_on_request = 1; - - if (brightness_bypass) { - aml_bl_set_level(bl_level_uboot); - bl_on_level = bl_level_uboot; - } else { - aml_bl_update_status(bl_drv->bldev); - bl_on_level = bconf->level_default; - } + aml_bl_init_status_update(); BLPR("probe OK\n"); return 0; diff --git a/drivers/amlogic/media/vout/backlight/aml_bl_reg.h b/drivers/amlogic/media/vout/backlight/aml_bl_reg.h index 8e38f8c..53cac44 100644 --- a/drivers/amlogic/media/vout/backlight/aml_bl_reg.h +++ b/drivers/amlogic/media/vout/backlight/aml_bl_reg.h @@ -46,6 +46,7 @@ #define VPU_VPU_PWM_V2 0x2732 #define VPU_VPU_PWM_V3 0x2733 +#define ENCL_VIDEO_EN 0x1ca0 #define ENCL_VIDEO_MAX_LNCNT 0x1cbb diff --git a/drivers/amlogic/media/vout/lcd/lcd_vout.c b/drivers/amlogic/media/vout/lcd/lcd_vout.c index f2afba6..41b6e14 100644 --- a/drivers/amlogic/media/vout/lcd/lcd_vout.c +++ b/drivers/amlogic/media/vout/lcd/lcd_vout.c @@ -377,6 +377,12 @@ static int lcd_power_encl_on_notifier(struct notifier_block *nb, if (lcd_debug_print_flag) LCDPR("%s: 0x%lx\n", __func__, event); + + if (lcd_driver->lcd_status & LCD_STATUS_ENCL_ON) { + LCDPR("lcd is already enabled\n"); + return NOTIFY_OK; + } + lcd_power_encl_on(); return NOTIFY_OK; @@ -414,6 +420,11 @@ static int lcd_power_if_on_notifier(struct notifier_block *nb, if (lcd_debug_print_flag) LCDPR("%s: 0x%lx\n", __func__, event); + if (lcd_driver->lcd_status & LCD_STATUS_IF_ON) { + LCDPR("lcd interface is already enabled\n"); + return NOTIFY_OK; + } + if (lcd_driver->lcd_status & LCD_STATUS_ENCL_ON) { lcd_power_if_on(); } else { -- 2.7.4