vlock: update lcd vlock parameter flow [1/1]
authorEvoke Zhang <evoke.zhang@amlogic.com>
Fri, 12 Oct 2018 11:43:25 +0000 (19:43 +0800)
committerJianxin Pan <jianxin.pan@amlogic.com>
Wed, 17 Oct 2018 06:47:11 +0000 (23:47 -0700)
PD#SWPL-321

Problem:
vlock parameters load fail for lcd unifykey loading is later

Solution:
use queue work to sync lcd unifykey vlock parameters

Verify:
txlx r311

Change-Id: I17fac4ca48fbd8f5b929eccfd38eb7e8a4b5b845
Signed-off-by: Evoke Zhang <evoke.zhang@amlogic.com>
drivers/amlogic/media/enhancement/amvecm/amvecm.c
drivers/amlogic/media/enhancement/amvecm/vlock.c
drivers/amlogic/media/enhancement/amvecm/vlock.h
drivers/amlogic/media/vout/lcd/lcd_common.c
include/linux/amlogic/media/vout/lcd/lcd_notify.h

index 75029a1..5dd375d 100644 (file)
@@ -88,6 +88,10 @@ struct amvecm_dev_s {
 
 };
 
+#ifdef CONFIG_AMLOGIC_LCD
+struct work_struct aml_lcd_vlock_param_work;
+#endif
+
 static struct amvecm_dev_s amvecm_dev;
 
 spinlock_t vpp_lcd_gamma_lock;
@@ -5211,6 +5215,8 @@ static int aml_vecm_probe(struct platform_device *pdev)
        ret = aml_lcd_notifier_register(&aml_lcd_gamma_nb);
        if (ret)
                pr_info("register aml_lcd_gamma_notifier failed\n");
+
+       INIT_WORK(&aml_lcd_vlock_param_work, vlock_lcd_param_work);
 #endif
        /* #if (MESON_CPU_TYPE == MESON_CPU_TYPE_MESONG9TV) */
        if (is_meson_gxtvbb_cpu() || is_meson_txl_cpu()
@@ -5290,6 +5296,7 @@ static int __exit aml_vecm_remove(struct platform_device *pdev)
        unregister_chrdev_region(devp->devno, 1);
 #ifdef CONFIG_AMLOGIC_LCD
        aml_lcd_notifier_unregister(&aml_lcd_gamma_nb);
+       cancel_work_sync(&aml_lcd_vlock_param_work);
 #endif
        probe_ok = 0;
        pr_info("[amvecm.] : amvecm_exit.\n");
index 9e47876..cef3999 100644 (file)
@@ -1312,11 +1312,38 @@ void vdin_vlock_input_sel(unsigned int type,
 }
 EXPORT_SYMBOL(vdin_vlock_input_sel);
 
-void vlock_param_config(struct device_node *node)
-{
 #ifdef CONFIG_AMLOGIC_LCD
+#define VLOCK_LCD_RETRY_MAX    100
+void vlock_lcd_param_work(struct work_struct *p_work)
+{
        unsigned int param[LCD_VLOCK_PARAM_NUM] = {0};
+       int i = 0;
+
+       while (i++ < VLOCK_LCD_RETRY_MAX) {
+               aml_lcd_notifier_call_chain(LCD_EVENT_VLOCK_PARAM, &param);
+               if (param[0] & LCD_VLOCK_PARAM_BIT_UPDATE) {
+                       if (param[0] & LCD_VLOCK_PARAM_BIT_VALID) {
+                               vlock_en = param[1];
+                               vlock_mode = param[2];
+                               vlock_pll_m_limit = param[3];
+                               vlock_line_limit = param[4];
+
+                               if (vlock_mode &
+                                       VLOCK_MODE_MANUAL_MIX_PLL_ENC) {
+                                       vlock_mode &=
+                                               ~VLOCK_MODE_MANUAL_MIX_PLL_ENC;
+                                       vlock_mode |= VLOCK_MODE_MANUAL_PLL;
+                               }
+                       }
+                       break;
+               }
+               msleep(20);
+       }
+}
 #endif
+
+void vlock_param_config(struct device_node *node)
+{
        unsigned int val;
        int ret;
 
@@ -1342,13 +1369,7 @@ void vlock_param_config(struct device_node *node)
                vlock_line_limit = val;
 
 #ifdef CONFIG_AMLOGIC_LCD
-       aml_lcd_notifier_call_chain(LCD_EVENT_VLOCK_PARAM, &param);
-       if (param[0]) { /* lcd vlock param is valid */
-               vlock_en = param[1];
-               vlock_mode = param[2];
-               vlock_pll_m_limit = param[3];
-               vlock_line_limit = param[4];
-       }
+       schedule_work(&aml_lcd_vlock_param_work);
 #endif
 
        if (vlock_mode & VLOCK_MODE_MANUAL_MIX_PLL_ENC) {
index 68fa2b2..83b8563 100644 (file)
@@ -111,5 +111,9 @@ extern int amvecm_hiu_reg_write(unsigned int reg, unsigned int val);
 extern void vdin_vlock_input_sel(unsigned int type,
        enum vframe_source_type_e source_type);
 extern void vlock_param_config(struct device_node *node);
+#ifdef CONFIG_AMLOGIC_LCD
+extern struct work_struct aml_lcd_vlock_param_work;
+extern void vlock_lcd_param_work(struct work_struct *p_work);
+#endif
 #endif
 
index 4e94f18..b8817ea 100644 (file)
@@ -685,12 +685,12 @@ int lcd_vlock_param_load_from_dts(struct lcd_config_s *pconf,
        unsigned int para[4];
        int ret;
 
+       pconf->lcd_control.vlock_param[0] = LCD_VLOCK_PARAM_BIT_UPDATE;
+
        ret = of_property_read_u32_array(child, "vlock_attr", &para[0], 4);
-       if (ret) {
-               pconf->lcd_control.vlock_param[0] = 0;
-       } else {
+       if (ret == 0) {
                LCDPR("find vlock_attr\n");
-               pconf->lcd_control.vlock_param[0] = 1; /* vlock_param valid */
+               pconf->lcd_control.vlock_param[0] |= LCD_VLOCK_PARAM_BIT_VALID;
                pconf->lcd_control.vlock_param[1] = para[0];
                pconf->lcd_control.vlock_param[2] = para[1];
                pconf->lcd_control.vlock_param[3] = para[2];
@@ -707,7 +707,7 @@ int lcd_vlock_param_load_from_unifykey(struct lcd_config_s *pconf,
 
        p = buf;
 
-       pconf->lcd_control.vlock_param[0] = 0;
+       pconf->lcd_control.vlock_param[0] = LCD_VLOCK_PARAM_BIT_UPDATE;
        pconf->lcd_control.vlock_param[1] = *(p + LCD_UKEY_VLOCK_VAL_0);
        pconf->lcd_control.vlock_param[2] = *(p + LCD_UKEY_VLOCK_VAL_1);
        pconf->lcd_control.vlock_param[3] = *(p + LCD_UKEY_VLOCK_VAL_2);
@@ -717,7 +717,7 @@ int lcd_vlock_param_load_from_unifykey(struct lcd_config_s *pconf,
                pconf->lcd_control.vlock_param[3] ||
                pconf->lcd_control.vlock_param[4]) {
                LCDPR("find vlock_attr\n");
-               pconf->lcd_control.vlock_param[0] = 1;
+               pconf->lcd_control.vlock_param[0] |= LCD_VLOCK_PARAM_BIT_VALID;
        }
 
        return 0;
index 2d6e55b..adffaf0 100644 (file)
@@ -76,6 +76,8 @@
 #define LCD_EVENT_TEST_PATTERN      (1 << 14)
 
 #define LCD_VLOCK_PARAM_NUM         5
+#define LCD_VLOCK_PARAM_BIT_UPDATE  (1 << 4)
+#define LCD_VLOCK_PARAM_BIT_VALID   (1 << 0)
 #define LCD_EVENT_VLOCK_PARAM       (1 << 16)