atv_demod: optimize pal-i ring [1/1]
authornengwen.chen <nengwen.chen@amlogic.com>
Thu, 29 Aug 2019 09:20:55 +0000 (17:20 +0800)
committerTao Zeng <tao.zeng@amlogic.com>
Wed, 18 Sep 2019 05:28:07 +0000 (22:28 -0700)
PD#TV-8006

Problem:
1.optimize pal-i ring.

Solution:
1.optimize pal-i ring.
2.add pal-i peak filter.

Verify:
Verified by x301.

Change-Id: Id935a24712216aafc20ac150c2560dd998a76f56
Signed-off-by: nengwen.chen <nengwen.chen@amlogic.com>
drivers/amlogic/atv_demod/atvdemod_func.c
drivers/amlogic/atv_demod/atvdemod_func.h

index 6e9a361..980bf7c 100644 (file)
@@ -338,45 +338,67 @@ void atv_dmd_misc(void)
        pr_dbg("%s done.\n", __func__);
 }
 
-void atv_dmd_ring_filter(bool on)
+void atv_dmd_ring_filter(bool on, int std)
 {
-       unsigned long filter_status = 0;
+       int i = 0;
+       int filter = 0;
+       unsigned long status = 0;
+       unsigned long data = 0;
+       const unsigned int reg_addr[10] = {
+               0x10, 0x14, 0x18, 0x1c, 0x20, 0x24, 0x28, 0x2c, 0x30, 0x34,
+       };
+       const unsigned int peak_filter[][10] = {
+               /* default */
+               { 0x8423F6, 0xFF86A967, 0x37FE45, 0xFF86A967, 0x3C223B,
+                       0x8423F6, 0xFF86A967, 0x37FE45, 0xFF86A967, 0x3C223B },
+               /* ntsc-m */
+               { 0x8274bf, 0x1d175c, 0x2aa526, 0x1d175c, 0x2d19e4,
+                       0x8274bf, 0x1d175c, 0x2aa526, 0x1d175c, 0x2d19e4 },
+               /* pal-i */
+               { 0x94d888, 0x5a39fb, 0xd8ebb, 0x5a39fb, 0x226744,
+                       0x94d888, 0x5a39fb, 0xd8ebb, 0x5a39fb, 0x226744 }
+       };
+
        if (!is_meson_tl1_cpu() && !is_meson_tm2_cpu())
                return;
 
-       filter_status = atv_dmd_rd_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x4c);
-       if (((filter_status & 0x01) && on) || (!(filter_status & 0x01) && !on))
+       if (on) {
+               if (std == AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_BG) {
+                       filter = 2;
+               } else if (std == AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_DK) {
+                       filter = 2;
+               } else if (std == AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_I) {
+                       filter = 2;
+               } else if (std == AML_ATV_DEMOD_VIDEO_MODE_PROP_NTSC_M ||
+                               std == AML_ATV_DEMOD_VIDEO_MODE_PROP_NTSC) {
+                       filter = 1;
+               } else {
+                       filter = 0;
+                       on = false;
+               }
+       } else {
+               filter = 0;
+       }
+
+       status = atv_dmd_rd_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x4c);
+       data = atv_dmd_rd_long(APB_BLOCK_ADDR_GDE_EQUAL, reg_addr[0]);
+       if ((data == peak_filter[filter][0]) && on && (status & 0x01))
+               return;
+
+       if (!on && !(status & 0x01))
                return;
 
-       if (on) {
-               atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x10, 0x8274bf);
-               atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x14, 0x1d175c);
-               atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x18, 0x2aa526);
-               atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x1c, 0x1d175c);
-               atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x20, 0x2d19e4);
-               atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x24, 0x8274bf);
-               atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x28, 0x1d175c);
-               atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x2c, 0x2aa526);
-               atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x30, 0x1d175c);
-               atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x34, 0x2d19e4);
+       /* disable filter */
+       atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x4c, 0x0);
 
+       for (i = 0; i < 10; ++i) {
+               atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL,
+                               reg_addr[i], peak_filter[filter][i]);
+       }
+
+       if (on) {
                /* enable filter */
                atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x4c, 0x1);
-       } else {
-               /* default value */
-               atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x10, 0x8423F6);
-               atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x14, 0xFF86A967);
-               atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x18, 0x37FE45);
-               atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x1c, 0xFF86A967);
-               atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x20, 0x3C223B);
-               atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x24, 0x8423F6);
-               atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x28, 0xFF86A967);
-               atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x2c, 0x37FE45);
-               atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x30, 0xFF86A967);
-               atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x34, 0x3C223B);
-
-               /* disable filter */
-               atv_dmd_wr_long(APB_BLOCK_ADDR_GDE_EQUAL, 0x4c, 0x0);
        }
 
        pr_dbg("%s do atv_dmd_ring_filter %d ...\n", __func__, on);
@@ -2021,12 +2043,10 @@ int atvdemod_init(struct atv_demod_priv *priv)
        if (!priv->scanning || non_std_en)
                atv_dmd_misc();
 
-       if (!priv->scanning &&
-               (broad_std == AML_ATV_DEMOD_VIDEO_MODE_PROP_NTSC_M ||
-               broad_std == AML_ATV_DEMOD_VIDEO_MODE_PROP_NTSC))
-               atv_dmd_ring_filter(true);
+       if (!priv->scanning)
+               atv_dmd_ring_filter(true, broad_std);
        else
-               atv_dmd_ring_filter(false);
+               atv_dmd_ring_filter(false, broad_std);
 
        atv_dmd_soft_reset();
 
index f7e09d3..7d8324b 100644 (file)
@@ -70,7 +70,7 @@ extern void read_version_register(void);
 extern void check_communication_interface(void);
 extern void power_on_receiver(void);
 extern void atv_dmd_misc(void);
-extern void atv_dmd_ring_filter(bool on);
+void atv_dmd_ring_filter(bool on, int std);
 extern void configure_receiver(int Broadcast_Standard,
                               unsigned int Tuner_IF_Frequency,
                               int Tuner_Input_IF_inverted, int GDE_Curve,