lcd: prevent lcd enable repeatedly to avoid abnormal display
authorEvoke Zhang <evoke.zhang@amlogic.com>
Tue, 10 Apr 2018 10:30:26 +0000 (18:30 +0800)
committerYixun Lan <yixun.lan@amlogic.com>
Thu, 12 Apr 2018 07:09:30 +0000 (23:09 -0800)
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 <evoke.zhang@amlogic.com>
drivers/amlogic/media/vout/backlight/aml_bl.c
drivers/amlogic/media/vout/backlight/aml_bl_reg.h
drivers/amlogic/media/vout/lcd/lcd_vout.c

index 7c3575b..f55034d 100644 (file)
@@ -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;
index 8e38f8c..53cac44 100644 (file)
@@ -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
 
 
index f2afba6..41b6e14 100644 (file)
@@ -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 {