deinterlace: pq: fix combing_fix_en can not change [1/1]
authorJihong Sui <jihong.sui@amlogic.com>
Tue, 24 Sep 2019 02:39:41 +0000 (10:39 +0800)
committerTao Zeng <tao.zeng@amlogic.com>
Wed, 25 Sep 2019 07:20:18 +0000 (00:20 -0700)
PD#SWPL-11557

Problem:
Some scenes flicker badly, such as the roof

Solution:
The modification requirements come from,
yanling(VLSI), bencheng.jing
a. patch 62052:
need change mtn parameter back to old for local 1080i;
b. patch 71464:
need fix combing_fix_en can not change;

Verify:
x301

Change-Id: I3e067930f0e4dea9f300e888a6ee3f96caf987fb
Signed-off-by: Jihong Sui <jihong.sui@amlogic.com>
drivers/amlogic/media/deinterlace/deinterlace.c
drivers/amlogic/media/deinterlace/deinterlace.h
drivers/amlogic/media/deinterlace/deinterlace_dbg.c
drivers/amlogic/media/deinterlace/deinterlace_mtn.c
drivers/amlogic/media/deinterlace/deinterlace_mtn.h
drivers/amlogic/media/deinterlace/di_pqa.h
drivers/amlogic/media/di_multi/deinterlace.c
drivers/amlogic/media/di_multi/deinterlace.h
drivers/amlogic/media/di_multi/di_data_l.h
drivers/amlogic/media/di_multi/di_prc.c

index 901aba0..2a52f70 100644 (file)
@@ -3593,7 +3593,7 @@ static void pre_de_done_buf_config(void)
 
                        }
                        post_wr_buf->vframe->di_pulldown |= 0x08;
-                       if (combing_fix_en)
+                       if (di_pre_stru.combing_fix_en)
                                cur_lev = adaptive_combing_fixing(
                                di_pre_stru.mtn_status,
                                        glb_field_mot_num,
@@ -3932,6 +3932,7 @@ static unsigned char pre_de_buf_config(void)
        u32 rls_timeout;
        u32 afbc_busy;
        u32 is_afbc_mode;
+       bool flg_1080i = false;
 
        if (di_blocking || !atomic_read(&de_devp->mem_flag))
                return 0;
@@ -4436,14 +4437,8 @@ jiffies_to_msecs(jiffies_64 - vframe->ready_jiffies64));
                } else {
                /*********************************/
                if ((di_buf->vframe->width >= 1920) &&
-                       (di_buf->vframe->height >= 1080) &&
-                       is_meson_tl1_cpu()) {
-                       if (combing_fix_en) {
-                               combing_fix_en = false;
-                               fix_tl1_1080i_sawtooth_patch();
-                       }
-               } else
-                       combing_fix_en = true;
+                   (di_buf->vframe->height >= 1080))
+                       flg_1080i = true;
 
                /*********************************/
                        if (
@@ -4627,6 +4622,21 @@ jiffies_to_msecs(jiffies_64 - vframe->ready_jiffies64));
                recovery_flag++;
                return 0;
        }
+       if (is_meson_tl1_cpu()  &&
+           combing_fix_en      &&
+           flg_1080i) {
+               di_pre_stru.combing_fix_en = false;
+               fix_tl1_1080i_sawtooth_patch();
+       } else {
+               di_pre_stru.combing_fix_en = combing_fix_en;
+       }
+
+       if (di_pre_stru.combing_fix_en) {
+               if (flg_1080i)
+                       com_patch_pre_sw_set(1);
+               else
+                       com_patch_pre_sw_set(0);
+       }
        return 1;
 }
 
index c562e95..2cae178 100644 (file)
@@ -376,6 +376,8 @@ struct di_pre_stru_s {
        bool retry_en;
        unsigned int retry_index;
        unsigned int retry_cnt;
+       /*****************/
+       bool combing_fix_en;
 };
 
 struct di_post_stru_s {
index 0f9079c..191f686 100644 (file)
@@ -587,6 +587,8 @@ static int dump_di_pre_stru_seq(struct seq_file *seq, void *v)
                di_pre_stru_p->bypass_pre ? "true" : "false");
        seq_printf(seq, "%-25s = %s\n", "invert_flag",
                di_pre_stru_p->invert_flag ? "true" : "false");
+       seq_printf(seq, "%-25s = %s\n", "combing_fix_en",
+                  di_pre_stru_p->combing_fix_en ? "true" : "false");
 
        return 0;
 }
index 6c3681f..e2c3d65 100644 (file)
@@ -182,18 +182,18 @@ static unsigned int combing_normal_setting[MAX_NUM_DI_REG] = {
 };
 
 static unsigned int combing_bias_motion_setting[MAX_NUM_DI_REG] = {
-       0x00202015,
-       0x1A1A3A62,
-       0x15200101,
-       0x01200440,
-       0x74200D0D,
-       0x0D5A1520,
-       0x0A0A0201,
-       0x1A1A2662,
-       0x0D200302,
-       0x02020606,
-       0x05080344,
-       0x40020a04,
+       0x00202015,     /* 0 */
+       0x1A1A3A62,     /* 1 */
+       0x15200101,     /* 2 */
+       0x01200440,     /* 3 */
+       0x74200D0D,     /* 4 */
+       0x0D5A1520,     /* 5 */
+       0x0A0A0201,     /* 6 */
+       0x1A1A2662,     /* 7 */
+       0x0D200302,     /* 8 */
+       0x02020606,     /* 9 */
+       0x05080344,     /* 10 */
+       0x40020a04,     /* 11 */
        /*idea from mingliang.dong & vlsi zheng.bao begin*/
        0x0001FF12, /* 0x0001ff0c */
        0x00200204, /* 0x00400204 */
@@ -203,17 +203,17 @@ static unsigned int combing_bias_motion_setting[MAX_NUM_DI_REG] = {
 };
 
 static unsigned int combing_very_motion_setting[MAX_NUM_DI_REG] = {
-       0x00202015,
-       0x1A1A3A62,
-       0x15200101,
-       0x01200440,
-       0x74200D0D,
-       0x0D5A1520,
-       0x0A0A0201,
-       0x1A1A2662,
-       0x0D200302,
-       0x02020606,
-       0x05080344,
+       0x00202015,     /* 0 */
+       0x1A1A3A62,     /* 1 */
+       0x15200101,     /* 2 */
+       0x01200440,     /* 3 */
+       0x74200D0D,     /* 4 */
+       0x0D5A1520,     /* 5 */
+       0x0A0A0201,     /* 6 */
+       0x1A1A2662,     /* 7 */
+       0x0D200302,     /* 8 */
+       0x02020606,     /* 9 */
+       0x05080344,     /* 10 */
        /*idea from mingliang.dong & vlsi zheng.bao begin*/
        0x60000404, /* 0x40020a04*/
        0x0001FF12, /* 0x0001ff0c */
@@ -222,6 +222,74 @@ static unsigned int combing_very_motion_setting[MAX_NUM_DI_REG] = {
        /*idea from mingliang.dong & vlsi zheng.bao end*/
        0x00000131
 };
+
+/**************************************************
+ *
+ **************************************************/
+static const unsigned int combing_bias_p_1080i[] = {
+       /**/
+       0x40020a04,     /* 11 */
+       /*idea from mingliang.dong & vlsi zheng.bao begin*/
+       0x0001ff0c,
+       0x00400204,
+       0x00016404,
+};
+
+static const unsigned int combing_bias_p_ori[] = {
+       /**/
+       0x40020a04,     /* 11 */
+       /*idea from mingliang.dong & vlsi zheng.bao begin*/
+       0x0001FF12, /* 0x0001ff0c */
+       0x00200204, /* 0x00400204 */
+       0x00012002, /* 0x00016404 */
+};
+
+static const unsigned int combing_very_p_1080i[] = {
+       /*idea from mingliang.dong & vlsi zheng.bao begin*/
+       0x40020a04,
+       0x0001ff0c,
+       0x00400204,
+       0x00016404,
+       /*idea from mingliang.dong & vlsi zheng.bao end*/
+
+};
+
+static const unsigned int combing_very_p_ori[] = {
+       /*idea from mingliang.dong & vlsi zheng.bao begin*/
+       0x60000404, /* 0x40020a04*/
+       0x0001FF12, /* 0x0001ff0c */
+       0x00200204, /* 0x00400204 */
+       0x00012002, /* 0x00016404 */
+       /*idea from mingliang.dong & vlsi zheng.bao end*/
+};
+
+static unsigned int di_mtn_p_mode;
+
+void com_patch_pre_sw_set(unsigned int mode)
+{
+       unsigned int *p1, *p2;
+       /*mode is 0: ori*/
+       /*mode is 1: 1080i*/
+       if (mode == di_mtn_p_mode)
+               return;
+
+       p1 = &combing_bias_motion_setting[11];
+       p2 = &combing_very_motion_setting[11];
+       if (mode == 0) {
+               memcpy(p1, &combing_bias_p_ori[0],
+                      sizeof(combing_bias_p_ori));
+               memcpy(p2, &combing_very_p_ori[0],
+                      sizeof(combing_very_p_ori));
+               di_mtn_p_mode = 0;
+       } else if (mode == 1) {
+               memcpy(p1, &combing_bias_p_1080i[0],
+                      sizeof(combing_bias_p_1080i));
+               memcpy(p2, &combing_very_p_1080i[0],
+                      sizeof(combing_very_p_1080i));
+               di_mtn_p_mode = 1;
+       }
+}
+
 /*special for resolution test file*/
 static unsigned int combing_resolution_setting[MAX_NUM_DI_REG] = {
        0x00202015,
@@ -301,6 +369,7 @@ void mtn_int_combing_glbmot(void)
        if (is_meson_tl1_cpu() || is_meson_tm2_cpu()) {/*from VLSI yanling.liu*/
                combing_glbmot_radprat[0] = 30;
        }
+       di_mtn_p_mode = 0;
 }
 void adpative_combing_exit(void)
 {
@@ -819,6 +888,7 @@ static const struct mtn_op_s di_ops_mtn = {
        .fix_tl1_1080i_sawtooth_patch   = fix_tl1_1080i_sawtooth_patch,
        .adaptive_combing_fixing        = adaptive_combing_fixing,
        .adpative_combing_config        = adpative_combing_config,
+       .com_patch_pre_sw_set           = com_patch_pre_sw_set,
        /*.module_para                  = dim_seq_file_module_para_mtn,*/
 };
 
index 13cc468..8c7c6d2 100644 (file)
@@ -46,5 +46,6 @@ int adaptive_combing_fixing(
        int bit_mode);
 void adpative_combing_exit(void);
 extern void mtn_int_combing_glbmot(void);
+void com_patch_pre_sw_set(unsigned int mode);
 
 #endif
index dbe4380..74d669b 100644 (file)
@@ -123,6 +123,7 @@ struct mtn_op_s {
                                           enum vframe_source_type_e src_type,
                                           bool prog,
                                           enum tvin_sig_fmt_e fmt);
+       void (*com_patch_pre_sw_set)(unsigned int mode);
        int (*module_para)(struct seq_file *seq);
 };
 
index da4fc2d..64332e6 100644 (file)
@@ -3294,7 +3294,8 @@ void dim_pre_de_done_buf_config(unsigned int channel, bool flg_timeout)
                                                overturn,
                                                ppre->di_inp_buf->vframe);
                        /*if (combing_fix_en)*/
-                       if (dimp_get(eDI_MP_combing_fix_en)) {
+                       /*if (dimp_get(eDI_MP_combing_fix_en)) {*/
+                       if (ppre->combing_fix_en) {
                                tmp_cur_lev /*cur_lev*/
                                = get_ops_mtn()->adaptive_combing_fixing(
                                        ppre->mtn_status,
@@ -3759,6 +3760,7 @@ unsigned char dim_pre_de_buf_config(unsigned int channel)
        struct di_post_stru_s *ppost = get_post_stru(channel);
        struct di_dev_s *de_devp = get_dim_de_devp();
        int cfg_prog_proc = dimp_get(eDI_MP_prog_proc_config);
+       bool flg_1080i = false;
 
        if (di_blocking || !dip_cma_st_is_ready(channel))
                return 0;
@@ -4215,21 +4217,11 @@ unsigned char dim_pre_de_buf_config(unsigned int channel)
                        }
                } else {
                /*********************************/
-               if ((di_buf->vframe->width >= 1920)     &&
-                   (di_buf->vframe->height >= 1080)    &&
-                   is_meson_tl1_cpu()) {
-                       /*if (combing_fix_en) {*/
-                       if (dimp_get(eDI_MP_combing_fix_en)) {
-                               /*combing_fix_en = false;*/
-                               dimp_set(eDI_MP_combing_fix_en, 0);
-                               get_ops_mtn()->fix_tl1_1080i_sawtooth_patch();
-                       }
-               } else {
-                       /*combing_fix_en = true;*/
-                       dimp_set(eDI_MP_combing_fix_en, 1);
-               }
-
+               if ((di_buf->vframe->width >= 1920) &&
+                   (di_buf->vframe->height >= 1080))
+                       flg_1080i = true;
                /*********************************/
+
                        if (!ppre->di_chan2_buf_dup_p) {
                                ppre->field_count_for_cont = 0;
                                /* ignore contp2rd and contprd */
@@ -4406,6 +4398,21 @@ unsigned char dim_pre_de_buf_config(unsigned int channel)
                recovery_flag++;
                return 0;
        }
+       if (is_meson_tl1_cpu()                  &&
+           di_mpr(combing_fix_en)              &&
+           flg_1080i) {
+               ppre->combing_fix_en = false;
+               get_ops_mtn()->fix_tl1_1080i_sawtooth_patch();
+       } else {
+               ppre->combing_fix_en = di_mpr(combing_fix_en);
+       }
+
+       if (ppre->combing_fix_en) {
+               if (flg_1080i)
+                       get_ops_mtn()->com_patch_pre_sw_set(1);
+               else
+                       get_ops_mtn()->com_patch_pre_sw_set(0);
+       }
        return 1;
 }
 
index 8a1cac0..a529710 100644 (file)
@@ -413,6 +413,7 @@ struct di_pre_stru_s {
        unsigned long irq_time[2];
        /* combing adaptive */
        struct combing_status_s *mtn_status;
+       bool combing_fix_en;
 };
 
 struct di_post_stru_s {
index 82a6682..bdec462 100644 (file)
@@ -483,7 +483,7 @@ enum eDI_MP_UI_T {
        eDI_MP_SUB_DI_B,
 
        eDI_MP_force_prog,      /*force_prog bool*/
-       eDI_MP_combing_fix_en,  /*combing_fix_en bool*/
+       edi_mp_combing_fix_en,  /*combing_fix_en bool*/
        eDI_MP_cur_lev,         /*cur_lev*/
        eDI_MP_pps_dstw,        /*pps_dstw*/
        eDI_MP_pps_dsth,        /*pps_dsth*/
@@ -1357,6 +1357,8 @@ static inline int dimp_dec(enum eDI_MP_UI_T idx)
        return get_datal()->mp_uit[idx];
 }
 
+#define di_mpr(x) dimp_get(edi_mp_##x)
+
 /******************************************
  *     mm
  *****************************************/
index 3a98e99..8929fdf 100644 (file)
@@ -202,8 +202,8 @@ const struct di_mp_uit_s di_mp_ui_top[] = {
                        eDI_MP_SUB_DI_B, 0},
        [eDI_MP_force_prog]  = {"bool:force_prog:1",
                        eDI_MP_force_prog, 1},
-       [eDI_MP_combing_fix_en]  = {"bool:combing_fix_en,def:1",
-                       eDI_MP_combing_fix_en, 1},
+       [edi_mp_combing_fix_en]  = {"bool:combing_fix_en,def:1",
+                       edi_mp_combing_fix_en, 1},
        [eDI_MP_cur_lev]  = {"int cur_lev,def:2",
                        eDI_MP_cur_lev, 2},
        [eDI_MP_pps_dstw]  = {"pps_dstw:int",