amvecm: add 3x65 bin gamma setting function [1/1]
authorBencheng Jing <bencheng.jing@amlogic.com>
Sat, 6 Apr 2019 10:40:06 +0000 (18:40 +0800)
committerTao Zeng <tao.zeng@amlogic.com>
Wed, 31 Jul 2019 06:10:12 +0000 (23:10 -0700)
PD#SWPL-6644

Problem:
add 3x65 bin gamma function

Solution:
add 3x65 bin gamma function

Verify:
tm2

Change-Id: I1f70af4b7ad6b5906004c1912e2b8f5e4366da4e
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
drivers/amlogic/media/enhancement/amvecm/arch/vpp_regs.h

index fe01997..48bfd1d 100644 (file)
@@ -1666,4 +1666,49 @@ void dump_plut3d_reg_table(void)
        }
 }
 
+void set_gamma_regs(int en, int sel)
+{
+       int i;
+       int *gamma_lut = NULL;
+
+       static int gamma_lut_default[66] =  {
+       0, 0, 0, 1, 2, 4, 6, 8, 11, 14, 17, 21, 26, 31,
+       36, 42, 49, 55, 63, 71, 79, 88, 98, 108, 118,
+       129, 141, 153, 166, 179, 193, 208, 223, 238,
+       255, 271, 289, 307, 325, 344, 364, 384, 405,
+       427, 449, 472, 495, 519, 544, 569, 595, 621,
+       649, 676, 705, 734, 763, 794, 825, 856, 888,
+       921, 955, 989, 1023, 0};
+
+       static int gamma_lut_straight[66] =  {
+        0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160,
+        176, 192, 208, 224, 240, 256, 272, 288, 304, 320,
+        336, 352, 368, 384, 400, 416, 432, 448, 464, 480,
+        496, 512, 528, 544, 560, 576, 592, 608, 624, 640,
+        656, 672, 688, 704, 720, 736, 752, 768, 784, 800,
+        816, 832, 848, 864, 880, 896, 912, 928, 944, 960,
+        976, 992, 1008, 1023, 0};
+
+       if (!sel)
+               gamma_lut = gamma_lut_default;
+       else
+               gamma_lut = gamma_lut_straight;
+
+       if (en) {
+               WRITE_VPP_REG(VPP_GAMMA_BIN_ADDR, 0);
+               for (i = 0; i < 33; i = i + 1)
+                       WRITE_VPP_REG(VPP_GAMMA_BIN_DATA,
+                               (((gamma_lut[i*2+1]<<2)&0xffff)<<16 |
+                                       ((gamma_lut[i*2]<<2)&0xffff)));
+               for (i = 0; i < 33; i = i + 1)
+                       WRITE_VPP_REG(VPP_GAMMA_BIN_DATA,
+                               (((gamma_lut[i*2+1]<<2)&0xffff)<<16 |
+                                       ((gamma_lut[i*2]<<2)&0xffff)));
+               for (i = 0; i < 33; i = i + 1)
+                       WRITE_VPP_REG(VPP_GAMMA_BIN_DATA,
+                               (((gamma_lut[i*2+1]<<2)&0xffff)<<16 |
+                                       ((gamma_lut[i*2]<<2)&0xffff)));
+               WRITE_VPP_REG_BITS(VPP_GAMMA_CTRL, 0x1, 0, 1);
+       }
+}
 
index 6963dfe..d9f047e 100644 (file)
@@ -168,6 +168,6 @@ extern void dump_plut3d_table(void);
 extern void dump_plut3d_reg_table(void);
 
 extern void amvecm_gamma_init(bool en);
-
+extern void set_gamma_regs(int en, int sel);
 #endif
 
index 8b6c2d5..5f7c6c4 100644 (file)
@@ -5565,6 +5565,13 @@ static ssize_t amvecm_debug_store(struct class *cla,
                                overscan_table[i].afd_enable,
                                overscan_table[i].load_flag);
                }
+       } else if (!strcmp(parm[0], "set_gamma_lut_65")) {
+               if (!strcmp(parm[1], "default"))
+                       set_gamma_regs(1, 0);
+               else if (!strcmp(parm[1], "straight"))
+                       set_gamma_regs(1, 1);
+               else
+                       pr_info("unsupport cmd\n");
        } else
                pr_info("unsupport cmd\n");
 
index d9b5448..93c941c 100644 (file)
 #define VPP_LUT3D_CBUS2RAM_CTRL                        0x39d1
 #define VPP_LUT3D_RAM_ADDR                             0x39d2
 #define VPP_LUT3D_RAM_DATA                             0x39d3
+#define VPP_GAMMA_CTRL                                 0x39d4
+#define VPP_GAMMA_BIN_ADDR                             0x39d5
+#define VPP_GAMMA_BIN_DATA                             0x39d6
 
 #define ENCL_VIDEO_EN          0x1ca0