tvafe: garbage was seen when switch PAL to NTSC by sinco DVD [1/1]
authorzhiwei.yuan <zhiwei.yuan@amlogic.com>
Wed, 23 Oct 2019 11:46:33 +0000 (19:46 +0800)
committerJianxin Pan <jianxin.pan@amlogic.com>
Wed, 30 Oct 2019 05:47:27 +0000 (22:47 -0700)
PD#SWPL-15686

Problem:
report unstable state is too late,so that black screen is deferred.

Solution:
reduce shift condition cnt

Verify:
verified by t962x2_x301

Change-Id: Iafc38998b4d451ec3f4ddfd14c72ed54a68efbe5
Signed-off-by: zhiwei.yuan <zhiwei.yuan@amlogic.com>
drivers/amlogic/media/vin/tvin/tvafe/tvafe.h
drivers/amlogic/media/vin/tvin/tvafe/tvafe_cvd.c
drivers/amlogic/media/vin/tvin/tvafe/tvafe_cvd.h
drivers/amlogic/media/vin/tvin/tvafe/tvafe_debug.c

index 452f6875236b39d8cfa0b45c678fe944d9a29990..89d2411784903df037b3c6115eef768821a0a7ac 100644 (file)
@@ -140,6 +140,8 @@ extern int tvafe_hiu_reg_write(unsigned int reg, unsigned int val);
 extern int tvafe_device_create_file(struct device *dev);
 extern void tvafe_remove_device_files(struct device *dev);
 int tvafe_pq_config_probe(struct meson_tvafe_data *tvafe_data);
+void cvd_set_shift_cnt(enum tvafe_cvd2_shift_cnt_e src, unsigned int val);
+unsigned int cvd_get_shift_cnt(enum tvafe_cvd2_shift_cnt_e src);
 
 extern bool disableapi;
 extern bool force_stable;
index d206500ac77132bef039068ae00eaf941c0c2e9f..b825832da700936fdfc7cac302930d9f6dc8901d 100644 (file)
@@ -36,9 +36,6 @@
 #include "../vdin/vdin_ctl.h"
 /***************************Local defines**********************************/
 
-#define TVAFE_CVD2_SHIFT_CNT                6
-/* cnt*10ms,delay for fmt shift counter */
-
 #define TVAFE_CVD2_NONSTD_DGAIN_MAX         0x500
 /* CVD max digital gain for non-std signal */
 #define TVAFE_CVD2_NONSTD_CNT_MAX           0x0A
@@ -121,9 +118,9 @@ static int cdto_adj_step = TVAFE_CVD2_CDTO_ADJ_STEP;
 module_param(cdto_adj_step, int, 0664);
 MODULE_PARM_DESC(cdto_adj_step, "cvd2_adj_step");
 
-static int cvd2_shift_cnt = TVAFE_CVD2_SHIFT_CNT;
-module_param(cvd2_shift_cnt, int, 0664);
-MODULE_PARM_DESC(cvd2_shift_cnt, "cvd2_shift_cnt");
+/* cnt*10ms,delay for fmt shift counter */
+static unsigned int cvd2_shift_cnt_atv = 6;
+static unsigned int cvd2_shift_cnt_av = 2;
 
 /*force the fmt for chrome off,for example ntsc pal_i 12*/
 static unsigned int config_force_fmt;
@@ -212,6 +209,29 @@ static unsigned int noise3;
 
 unsigned int vbi_mem_start;
 
+void cvd_set_shift_cnt(enum tvafe_cvd2_shift_cnt_e src, unsigned int val)
+{
+       if (src == TVAFE_CVD2_SHIFT_CNT_ATV)
+               cvd2_shift_cnt_atv = val;
+       else if (src == TVAFE_CVD2_SHIFT_CNT_AV)
+               cvd2_shift_cnt_av = val;
+       else
+               pr_err("[%s]wrong src para.\n", __func__);
+}
+
+unsigned int cvd_get_shift_cnt(enum tvafe_cvd2_shift_cnt_e src)
+{
+       unsigned int shift_cnt = 0;
+
+       if (src == TVAFE_CVD2_SHIFT_CNT_ATV)
+               shift_cnt = cvd2_shift_cnt_atv;
+       else if (src == TVAFE_CVD2_SHIFT_CNT_AV)
+               shift_cnt = cvd2_shift_cnt_av;
+       else
+               pr_err("[%s]wrong src para.\n", __func__);
+
+       return shift_cnt;
+}
 
 void cvd_vbi_mem_set(unsigned int offset, unsigned int size)
 {
@@ -1549,10 +1569,13 @@ static void tvafe_cvd2_search_video_mode(struct tvafe_cvd2_s *cvd2,
        unsigned int try_format_max;
 
        if ((cvd2->vd_port == TVIN_PORT_CVBS3) ||
-               (cvd2->vd_port == TVIN_PORT_CVBS0))
+           (cvd2->vd_port == TVIN_PORT_CVBS0)) {
                try_format_max = try_fmt_max_atv;
-       else
+               shift_cnt = cvd2_shift_cnt_atv;
+       } else {
                try_format_max = try_fmt_max_av;
+               shift_cnt = cvd2_shift_cnt_av;
+       }
 
        /* execute manual mode */
        if ((cvd2->manual_fmt) && (cvd2->config_fmt != cvd2->manual_fmt) &&
@@ -1837,9 +1860,8 @@ static void tvafe_cvd2_search_video_mode(struct tvafe_cvd2_s *cvd2,
                try_format_cnt = 0;
                if (tvafe_cvd2_condition_shift(cvd2)) {
                        if (cvd2->info.non_std_enable)
-                               shift_cnt = cvd2_shift_cnt*10;
-                       else
-                               shift_cnt = cvd2_shift_cnt;
+                               shift_cnt *= 10;
+
                        /* if no color burst,*/
                        /*pal flag can not be trusted */
                        if (cvd2->info.fmt_shift_cnt++ > shift_cnt) {
index ce89bd59c55502bfff27013ac5b60055614fc3fb..2ccd9921e93d1e6c739123da48f853aa5720e89d 100644 (file)
@@ -68,6 +68,11 @@ enum tvafe_cvd2_state_e {
        TVAFE_CVD2_STATE_FIND,
 };
 
+enum tvafe_cvd2_shift_cnt_e {
+       TVAFE_CVD2_SHIFT_CNT_ATV = 0,
+       TVAFE_CVD2_SHIFT_CNT_AV,
+};
+
 /* ****************************************** */
 /* *** structure definitions *********** */
 /***************************************************** */
index f963af99832b598151be2107d72fc3c320f6d009..27ccbe89473bddbc98816b3e201e24c62a78adb4 100644 (file)
@@ -484,6 +484,34 @@ static ssize_t tvafe_store(struct device *dev,
                }
                pr_info("[tvafe..]%s: tvafe_dbg_print = 0x%x\n",
                        __func__, tvafe_dbg_print);
+       } else if  (!strcmp(parm[0], "shift_cnt_av")) {
+               if (parm[1]) {
+                       if (kstrtouint(parm[1], 10, &val) < 0) {
+                               pr_info("str->uint error.\n");
+                               goto tvafe_store_err;
+                       } else {
+                               cvd_set_shift_cnt(TVAFE_CVD2_SHIFT_CNT_AV,
+                                                 val);
+                               pr_info("[tvafe]%s: av shift cnt = %d\n",
+                                       __func__, val);
+                       }
+               } else
+                       pr_info("[shift_cnt_av]miss parameter,ori val = %d\n",
+                               cvd_get_shift_cnt(TVAFE_CVD2_SHIFT_CNT_AV));
+       } else if  (!strcmp(parm[0], "shift_cnt_atv")) {
+               if (parm[1]) {
+                       if (kstrtouint(parm[1], 10, &val) < 0) {
+                               pr_info("str->uint error.\n");
+                               goto tvafe_store_err;
+                       } else {
+                               cvd_set_shift_cnt(TVAFE_CVD2_SHIFT_CNT_ATV,
+                                                 val);
+                               pr_info("[tvafe]%s: atv shift cnt = %d\n",
+                                       __func__, val);
+                       }
+               } else
+                       pr_info("[shift_cnt_atv]miss parameter,ori val = %d\n",
+                               cvd_get_shift_cnt(TVAFE_CVD2_SHIFT_CNT_ATV));
        } else
                tvafe_pr_info("[%s]:invaild command.\n", __func__);
        kfree(buf_orig);