amvecm: add option for applying gamma [1/1]
authorXihai Zhu <xihai.zhu@amlogic.com>
Wed, 3 Jul 2019 11:47:12 +0000 (07:47 -0400)
committerTao Zeng <tao.zeng@amlogic.com>
Fri, 2 Aug 2019 02:07:51 +0000 (19:07 -0700)
PD#SWPL-11288

Problem:
we'd better provide the flexibility
for gamma applying protection

Solution:
add option to let user to choose
if the applying protection is needed
or not

Verify:
tl1

Change-Id: I3f215545c7921134a282571d7f734bb8b42d553e
Signed-off-by: Xihai Zhu <xihai.zhu@amlogic.com>
drivers/amlogic/media/enhancement/amvecm/amve.c
drivers/amlogic/media/enhancement/amvecm/amve.h
drivers/amlogic/media/enhancement/amvecm/amvecm.c

index 48bfd1d..18ef253 100644 (file)
@@ -47,6 +47,7 @@
 /* printk(KERN_##(KERN_INFO) "AMVECM: " fmt, ## args) */
 
 #define GAMMA_RETRY        1000
+unsigned int gamma_loadprotect_en = 1;
 
 /* 0: Invalid */
 /* 1: Valid */
@@ -292,6 +293,9 @@ void vpp_set_lcd_gamma_table(u16 *data, u32 rgb_mask)
 
        spin_lock_irqsave(&vpp_lcd_gamma_lock, flags);
 
+       if (gamma_loadprotect_en)
+               WRITE_VPP_REG_BITS(L_GAMMA_CNTL_PORT, 0, GAMMA_EN, 1);
+
        while (!(READ_VPP_REG(L_GAMMA_CNTL_PORT) & (0x1 << ADR_RDY))) {
                udelay(10);
                if (cnt++ > GAMMA_RETRY)
@@ -319,6 +323,10 @@ void vpp_set_lcd_gamma_table(u16 *data, u32 rgb_mask)
                                    (0x1 << rgb_mask)   |
                                    (0x23 << HADR));
 
+       if (gamma_loadprotect_en)
+               VSYNC_WR_MPEG_REG_BITS(L_GAMMA_CNTL_PORT,
+                       gamma_en, GAMMA_EN, 1);
+
        spin_unlock_irqrestore(&vpp_lcd_gamma_lock, flags);
 }
 
index d9f047e..23f8421 100644 (file)
@@ -57,6 +57,7 @@ struct ve_regs_s {
        unsigned int rsv:5;
 };
 
+extern unsigned int gamma_loadprotect_en;
 extern struct ve_hist_s video_ve_hist;
 extern void ve_hist_gamma_reset(void);
 extern unsigned int ve_size;
index 5f7c6c4..1c8b1e2 100644 (file)
@@ -5101,8 +5101,10 @@ static const char *amvecm_debug_usage_str = {
        "echo vpp_size > /sys/class/amvecm/debug; get vpp size config\n"
        "echo wb enable > /sys/class/amvecm/debug\n"
        "echo wb disable > /sys/class/amvecm/debug\n"
-       "echo gama enable > /sys/class/amvecm/debug\n"
-       "echo gama disable > /sys/class/amvecm/debug\n"
+       "echo gamma enable > /sys/class/amvecm/debug\n"
+       "echo gamma disable > /sys/class/amvecm/debug\n"
+       "echo gamma load_protect_en > /sys/class/amvecm/debug\n"
+       "echo gamma load_protect_dis > /sys/class/amvecm/debug\n"
        "echo sr peaking_en > /sys/class/amvecm/debug\n"
        "echo sr peaking_dis > /sys/class/amvecm/debug\n"
        "echo sr lcti_en > /sys/class/amvecm/debug\n"
@@ -5180,6 +5182,12 @@ static ssize_t amvecm_debug_store(struct class *cla,
                } else if (!strncmp(parm[1], "disable", 7)) {
                        vecm_latch_flag |= FLAG_GAMMA_TABLE_DIS;/* gamma off */
                        pr_info("disable gamma\n");
+               } else if (!strncmp(parm[1], "load_protect_en", 15)) {
+                       gamma_loadprotect_en = 1;
+                       pr_info("disable gamma before loading new gamma\n");
+               } else if (!strncmp(parm[1], "load_protect_dis", 16)) {
+                       gamma_loadprotect_en = 0;
+                       pr_info("loading new gamma without pretect");
                }
        } else if (!strncmp(parm[0], "sr", 2)) {
                if (!strncmp(parm[1], "peaking_en", 10)) {