amvecm: fix flicker when change between Launcher and Signal Source [1/1]
authorBencheng Jing <bencheng.jing@amlogic.com>
Thu, 25 Oct 2018 12:42:16 +0000 (20:42 +0800)
committerJianxin Pan <jianxin.pan@amlogic.com>
Mon, 29 Oct 2018 05:09:55 +0000 (22:09 -0700)
PD#SWPL-848

Problem:
ioctrl set the same gamma value again

Solution:
if the gamma value is same as the ioctrl userspace value, do not set again

Verify:
txlx

Change-Id: I6f17f5ff234513c5a886004aedea81b9945c5b98
Signed-off-by: Bencheng Jing <bencheng.jing@amlogic.com>
drivers/amlogic/media/enhancement/amvecm/amve.c
drivers/amlogic/media/enhancement/amvecm/amve.h
drivers/amlogic/media/enhancement/amvecm/amvecm.c

index 469c692..6ae7493 100644 (file)
@@ -76,6 +76,8 @@ struct tcon_gamma_table_s video_gamma_table_b;
 struct tcon_gamma_table_s video_gamma_table_r_adj;
 struct tcon_gamma_table_s video_gamma_table_g_adj;
 struct tcon_gamma_table_s video_gamma_table_b_adj;
+struct tcon_gamma_table_s video_gamma_table_ioctl_set;
+
 struct tcon_rgb_ogo_s video_rgb_ogo = {
        0, /* wb enable */
        0, /* -1024~1023, r_pre_offset */
index 2b089f6..cbd8d09 100644 (file)
@@ -64,6 +64,7 @@ extern struct ve_dnlp_s am_ve_dnlp;
 extern struct tcon_gamma_table_s video_gamma_table_r;
 extern struct tcon_gamma_table_s video_gamma_table_g;
 extern struct tcon_gamma_table_s video_gamma_table_b;
+extern struct tcon_gamma_table_s video_gamma_table_ioctl_set;
 extern struct tcon_gamma_table_s video_gamma_table_r_adj;
 extern struct tcon_gamma_table_s video_gamma_table_g_adj;
 extern struct tcon_gamma_table_s video_gamma_table_b_adj;
index 1a8ba0a..38daf87 100644 (file)
@@ -1205,6 +1205,20 @@ static int amvecm_set_saturation_hue_post(int val1,
        return 0;
 }
 
+static int gamma_table_compare(struct tcon_gamma_table_s *table1,
+       struct tcon_gamma_table_s *table2)
+{
+       int i = 0, flag = 0;
+
+       for (i = 0; i < 256; i++)
+               if (table1->data[i] != table2->data[i]) {
+                       flag = 1;
+                       break;
+               }
+
+       return flag;
+}
+
 static long amvecm_ioctl(struct file *file,
                unsigned int cmd, unsigned long arg)
 {
@@ -1300,34 +1314,52 @@ static long amvecm_ioctl(struct file *file,
                if (!gamma_en)
                        return -EINVAL;
 
-               if (copy_from_user(&video_gamma_table_r,
+               if (copy_from_user(&video_gamma_table_ioctl_set,
                                (void __user *)arg,
                                sizeof(struct tcon_gamma_table_s)))
                        ret = -EFAULT;
-               else
+               else if (gamma_table_compare(&video_gamma_table_ioctl_set,
+                       &video_gamma_table_r)) {
+                       memcpy(&video_gamma_table_r,
+                               &video_gamma_table_ioctl_set,
+                               sizeof(struct tcon_gamma_table_s));
                        vecm_latch_flag |= FLAG_GAMMA_TABLE_R;
+               } else
+                       pr_amvecm_dbg("load same gamma_r table,no need to change\n");
                break;
        case AMVECM_IOC_GAMMA_TABLE_G:
                if (!gamma_en)
                        return -EINVAL;
 
-               if (copy_from_user(&video_gamma_table_g,
+               if (copy_from_user(&video_gamma_table_ioctl_set,
                                (void __user *)arg,
                                sizeof(struct tcon_gamma_table_s)))
                        ret = -EFAULT;
-               else
+               else if (gamma_table_compare(&video_gamma_table_ioctl_set,
+                       &video_gamma_table_g)) {
+                       memcpy(&video_gamma_table_g,
+                               &video_gamma_table_ioctl_set,
+                               sizeof(struct tcon_gamma_table_s));
                        vecm_latch_flag |= FLAG_GAMMA_TABLE_G;
+               } else
+                       pr_amvecm_dbg("load same gamma_g table,no need to change\n");
                break;
        case AMVECM_IOC_GAMMA_TABLE_B:
                if (!gamma_en)
                        return -EINVAL;
 
-               if (copy_from_user(&video_gamma_table_b,
+               if (copy_from_user(&video_gamma_table_ioctl_set,
                                (void __user *)arg,
                                sizeof(struct tcon_gamma_table_s)))
                        ret = -EFAULT;
-               else
+               else if (gamma_table_compare(&video_gamma_table_ioctl_set,
+                       &video_gamma_table_b)) {
+                       memcpy(&video_gamma_table_b,
+                               &video_gamma_table_ioctl_set,
+                               sizeof(struct tcon_gamma_table_s));
                        vecm_latch_flag |= FLAG_GAMMA_TABLE_B;
+               } else
+                       pr_amvecm_dbg("load same gamma_b table,no need to change\n");
                break;
        case AMVECM_IOC_S_RGB_OGO:
                if (!wb_en)