tvafe: support nostd config nostd_vs_th in dts [1/1]
authorEvoke Zhang <evoke.zhang@amlogic.com>
Mon, 10 Jun 2019 10:59:37 +0000 (18:59 +0800)
committerTao Zeng <tao.zeng@amlogic.com>
Tue, 2 Jul 2019 08:46:32 +0000 (01:46 -0700)
PD#TV-6046

Problem:
nostd atv display flicker

Solution:
config nostd_vs_th in dts for special tuner

Verify:
x301

Change-Id: Ibdb6422b0a9f031dab0a88b1654c566bcaa0c0d0
Signed-off-by: Evoke Zhang <evoke.zhang@amlogic.com>
arch/arm/boot/dts/amlogic/tl1_t962x2_x301_1g.dts
arch/arm/boot/dts/amlogic/tl1_t962x2_x301_2g.dts
arch/arm64/boot/dts/amlogic/tl1_t962x2_x301_1g.dts
arch/arm64/boot/dts/amlogic/tl1_t962x2_x301_2g.dts
drivers/amlogic/media/vin/tvin/tvafe/tvafe.c
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
drivers/amlogic/media/vin/tvin/tvafe/tvafe_general.c
drivers/amlogic/media/vin/tvin/tvafe/tvafe_general.h

index a1a9b8d..01c79f4 100644 (file)
 
                cutwindow_val_h = <0 10 18 20 62>; /* level 0~4 */
                cutwindow_val_v = <4  8 14 16 24>;  /* level 0~4 */
+               /* auto_adj_en:
+                * bit0 -- auto cdto
+                * bit1 -- auto hs
+                * bit2 -- auto vs
+                * bit3 -- auto de
+                * bit4 -- auto 3dcomb
+                * bit5 -- auto pga
+                */
+               auto_adj_en = <0x3e>;
+               /* val: default=0, 0x1, 0xf1, 0xe1, 0x11 for special tuner
+                * force_flag: force setting to std mode, default=0
+                */
+               nostd_vs_th = <0 0>; /* val, force_flag */
        };
 
        vbi {
index f3c1782..063415c 100644 (file)
 
                cutwindow_val_h = <0 10 18 20 62>; /* level 0~4 */
                cutwindow_val_v = <4  8 14 16 24>;  /* level 0~4 */
+               /* auto_adj_en:
+                * bit0 -- auto cdto
+                * bit1 -- auto hs
+                * bit2 -- auto vs
+                * bit3 -- auto de
+                * bit4 -- auto 3dcomb
+                * bit5 -- auto pga
+                */
+               auto_adj_en = <0x3e>;
+               /* val: default=0, 0x1, 0xf1, 0xe1, 0x11 for special tuner
+                * force_flag: force setting to std mode, default=0
+                */
+               nostd_vs_th = <0 0>; /* val, force_flag */
        };
 
        vbi {
index 91ce75a..4d02d95 100644 (file)
 
                cutwindow_val_h = <0 10 18 20 62>; /* level 0~4 */
                cutwindow_val_v = <4  8 14 16 24>;  /* level 0~4 */
+               /* auto_adj_en:
+                * bit0 -- auto cdto
+                * bit1 -- auto hs
+                * bit2 -- auto vs
+                * bit3 -- auto de
+                * bit4 -- auto 3dcomb
+                * bit5 -- auto pga
+                */
+               auto_adj_en = <0x3e>;
+               /* val: default=0, 0x1, 0xf1, 0xe1, 0x11 for special tuner
+                * force_flag: force setting to std mode, default=0
+                */
+               nostd_vs_th = <0 0>; /* val, force_flag */
        };
 
        vbi {
index 4258a02..57830db 100644 (file)
 
                cutwindow_val_h = <0 10 18 20 62>; /* level 0~4 */
                cutwindow_val_v = <4  8 14 16 24>;  /* level 0~4 */
+               /* auto_adj_en:
+                * bit0 -- auto cdto
+                * bit1 -- auto hs
+                * bit2 -- auto vs
+                * bit3 -- auto de
+                * bit4 -- auto 3dcomb
+                * bit5 -- auto pga
+                */
+               auto_adj_en = <0x3e>;
+               /* val: default=0, 0x1, 0xf1, 0xe1, 0x11 for special tuner
+                * force_flag: force setting to std mode, default=0
+                */
+               nostd_vs_th = <0 0>; /* val, force_flag */
        };
 
        vbi {
index 9c24d2e..465aa60 100644 (file)
@@ -86,15 +86,6 @@ static bool enable_db_reg = true;
 module_param(enable_db_reg, bool, 0644);
 MODULE_PARM_DESC(enable_db_reg, "enable/disable tvafe load reg");
 
-bool tvafe_dbg_enable;
-module_param(tvafe_dbg_enable, bool, 0644);
-MODULE_PARM_DESC(tvafe_dbg_enable, "enable/disable tvafe debug enable");
-
-/*level4: 48-->62 for ntsc-m*/
-unsigned int cutwindow_val_h[5] = {0, 10, 18, 20, 62};
-unsigned int cutwindow_val_v[5] = {4, 8, 14, 16, 24};
-static int cutwindow_val_vs_ve = TVAFE_VS_VE_VAL;
-
 /*tvconfig snow config*/
 static bool snow_cfg;
 /*1: snow function on;*/
@@ -114,14 +105,50 @@ unsigned int av1_plugin_state;
 unsigned int av2_plugin_state;
 #endif
 
+/*tvafe_dbg_print:
+ *bit[0]:normal flow debug print
+ *bit[1]:
+ *bit[2]:vsync isr debug print
+ *bit[3]:smr debug print
+ *bit[4]:nonstd debug print
+ */
+unsigned int tvafe_dbg_print;
+
 #ifdef CONFIG_AMLOGIC_ATV_DEMOD
 static struct tvafe_info_s *g_tvafe_info;
 #endif
 
+static struct tvafe_user_param_s tvafe_user_param = {
+       .cutwindow_val_h = {0, 10, 18, 20, 62},
+       /*level4: 48-->62 for ntsc-m*/
+       .cutwindow_val_v = {4, 8, 14, 16, 24},
+       .cutwindow_val_vs_ve = TVAFE_VS_VE_VAL,
+       /* auto_adj_en:
+        * bit[5]: auto pga
+        * bit[4]: auto 3d comb
+        * bit[3]: auto de
+        * bit[2]: auto vs
+        * bit[1]: auto hs
+        * bit[0]: auto cdto
+        */
+       .auto_adj_en = 0x3e,
+       .nostd_vs_th = 0x0,
+       .force_vs_th_flag = 0,
+       .nostd_stable_cnt = 3,
+
+       /*4 is the test result@20171101 on fluke-54200 and DVD*/
+       .skip_vf_num = 4,
+};
+
+struct tvafe_user_param_s *tvafe_get_user_param(void)
+{
+       return &tvafe_user_param;
+}
+
 /*
  * tvafe check support port
  */
-int tvafe_dec_support(struct tvin_frontend_s *fe, enum tvin_port_e port)
+static int tvafe_dec_support(struct tvin_frontend_s *fe, enum tvin_port_e port)
 {
        struct tvafe_dev_s *devp = container_of(fe,
                                struct tvafe_dev_s, frontend);
@@ -135,7 +162,7 @@ int tvafe_dec_support(struct tvin_frontend_s *fe, enum tvin_port_e port)
 }
 
 #ifdef CONFIG_CMA
-void tvafe_cma_alloc(struct tvafe_dev_s *devp)
+static void tvafe_cma_alloc(struct tvafe_dev_s *devp)
 {
        unsigned int mem_size = devp->cma_mem_size;
        int flags = CODEC_MM_FLAGS_CMA_FIRST|CODEC_MM_FLAGS_CMA_CLEAR|
@@ -172,7 +199,7 @@ void tvafe_cma_alloc(struct tvafe_dev_s *devp)
        }
 }
 
-void tvafe_cma_release(struct tvafe_dev_s *devp)
+static void tvafe_cma_release(struct tvafe_dev_s *devp)
 {
        if (devp->cma_config_en == 0)
                return;
@@ -213,7 +240,7 @@ static int tvafe_get_v_fmt(void)
 /*
  * tvafe open port and init register
  */
-int tvafe_dec_open(struct tvin_frontend_s *fe, enum tvin_port_e port)
+static int tvafe_dec_open(struct tvin_frontend_s *fe, enum tvin_port_e port)
 {
        struct tvafe_dev_s *devp = container_of(fe, struct tvafe_dev_s,
                                                frontend);
@@ -312,7 +339,7 @@ int tvafe_dec_open(struct tvin_frontend_s *fe, enum tvin_port_e port)
 /*
  * tvafe start after signal stable
  */
-void tvafe_dec_start(struct tvin_frontend_s *fe, enum tvin_sig_fmt_e fmt)
+static void tvafe_dec_start(struct tvin_frontend_s *fe, enum tvin_sig_fmt_e fmt)
 {
        struct tvafe_dev_s *devp = container_of(fe, struct tvafe_dev_s,
                                                frontend);
@@ -374,7 +401,7 @@ void tvafe_dec_start(struct tvin_frontend_s *fe, enum tvin_sig_fmt_e fmt)
 /*
  * tvafe stop port
  */
-void tvafe_dec_stop(struct tvin_frontend_s *fe, enum tvin_port_e port)
+static void tvafe_dec_stop(struct tvin_frontend_s *fe, enum tvin_port_e port)
 {
        struct tvafe_dev_s *devp = container_of(fe, struct tvafe_dev_s,
                                                frontend);
@@ -403,8 +430,7 @@ void tvafe_dec_stop(struct tvin_frontend_s *fe, enum tvin_port_e port)
        tvafe->parm.port = port;
        /* need to do ... */
        /** write 7740 register for cvbs clamp **/
-       if ((port >= TVIN_PORT_CVBS0) && (port <= TVIN_PORT_CVBS3) &&
-               !(devp->flags & TVAFE_POWERDOWN_IN_IDLE)) {
+       if (!(devp->flags & TVAFE_POWERDOWN_IN_IDLE)) {
 
                tvafe->cvd2.fmt_loop_cnt = 0;
                /* reset loop cnt after channel switch */
@@ -438,7 +464,7 @@ void tvafe_dec_stop(struct tvin_frontend_s *fe, enum tvin_port_e port)
 /*
  * tvafe close port
  */
-void tvafe_dec_close(struct tvin_frontend_s *fe)
+static void tvafe_dec_close(struct tvin_frontend_s *fe)
 {
        struct tvafe_dev_s *devp = container_of(fe, struct tvafe_dev_s,
                                                frontend);
@@ -520,7 +546,7 @@ void tvafe_dec_close(struct tvin_frontend_s *fe)
 /*
  * tvafe vsync interrupt function
  */
-int tvafe_dec_isr(struct tvin_frontend_s *fe, unsigned int hcnt64)
+static int tvafe_dec_isr(struct tvin_frontend_s *fe, unsigned int hcnt64)
 {
        struct tvafe_dev_s *devp = container_of(fe, struct tvafe_dev_s,
                                                frontend);
@@ -548,70 +574,73 @@ int tvafe_dec_isr(struct tvin_frontend_s *fe, unsigned int hcnt64)
                        return TVIN_BUF_SKIP;
        }
 
+       if ((port < TVIN_PORT_CVBS0) || (port > TVIN_PORT_CVBS3))
+               return TVIN_BUF_SKIP;
+
+       if (tvafe->cvd2.info.isr_cnt++ >= 65536)
+               tvafe->cvd2.info.isr_cnt = 0;
+
        /* TVAFE CVD2 3D works abnormally => reset cvd2 */
-       if ((port >= TVIN_PORT_CVBS0) && (port <= TVIN_PORT_CVBS3))
-               tvafe_cvd2_check_3d_comb(&tvafe->cvd2);
+       tvafe_cvd2_check_3d_comb(&tvafe->cvd2);
 
 #ifdef TVAFE_SET_CVBS_PGA_EN
-       if ((port >= TVIN_PORT_CVBS0) && (port <= TVIN_PORT_CVBS3) &&
-               (port != TVIN_PORT_CVBS3))
+       if (port != TVIN_PORT_CVBS3)
                tvafe_cvd2_adj_pga(&tvafe->cvd2);
 #endif
+
+       if (tvafe->parm.info.fmt == TVIN_SIG_FMT_CVBS_PAL_I) {
 #ifdef TVAFE_SET_CVBS_CDTO_EN
-       if (tvafe->parm.info.fmt == TVIN_SIG_FMT_CVBS_PAL_I)
                tvafe_cvd2_adj_cdto(&tvafe->cvd2, hcnt64);
 #endif
-       if (tvafe->parm.info.fmt == TVIN_SIG_FMT_CVBS_PAL_I)
                tvafe_cvd2_adj_hs(&tvafe->cvd2, hcnt64);
-       else if (tvafe->parm.info.fmt == TVIN_SIG_FMT_CVBS_NTSC_M)
+       else if (tvafe->parm.info.fmt == TVIN_SIG_FMT_CVBS_NTSC_M)
                tvafe_cvd2_adj_hs_ntsc(&tvafe->cvd2, hcnt64);
 
-       if ((port >= TVIN_PORT_CVBS0) && (port <= TVIN_PORT_CVBS3)) {
-               aspect_ratio = tvafe_cvd2_get_wss();
-               switch (aspect_ratio) {
-               case TVIN_ASPECT_NULL:
-                       count[TVIN_ASPECT_NULL]++;
-                       break;
-               case TVIN_ASPECT_1x1:
-                       count[TVIN_ASPECT_1x1]++;
-                       break;
-               case TVIN_ASPECT_4x3_FULL:
-                       count[TVIN_ASPECT_4x3_FULL]++;
-                       break;
-               case TVIN_ASPECT_14x9_FULL:
-                       count[TVIN_ASPECT_14x9_FULL]++;
-                       break;
-               case TVIN_ASPECT_14x9_LB_CENTER:
-                       count[TVIN_ASPECT_14x9_LB_CENTER]++;
-                       break;
-               case TVIN_ASPECT_14x9_LB_TOP:
-                       count[TVIN_ASPECT_14x9_LB_TOP]++;
-                       break;
-               case TVIN_ASPECT_16x9_FULL:
-                       count[TVIN_ASPECT_16x9_FULL]++;
-                       break;
-               case TVIN_ASPECT_16x9_LB_CENTER:
-                       count[TVIN_ASPECT_16x9_LB_CENTER]++;
-                       break;
-               case TVIN_ASPECT_16x9_LB_TOP:
-                       count[TVIN_ASPECT_16x9_LB_TOP]++;
-                       break;
-               case TVIN_ASPECT_MAX:
-                       break;
-               }
-               /*over 30/40 times,ratio is effective*/
-               if (++(tvafe->aspect_ratio_cnt) > TVAFE_RATIO_CNT) {
-                       for (i = 0; i < TVIN_ASPECT_MAX; i++) {
-                               if (count[i] > 30) {
-                                       tvafe->aspect_ratio = i;
-                                       break;
-                               }
+       aspect_ratio = tvafe_cvd2_get_wss();
+       switch (aspect_ratio) {
+       case TVIN_ASPECT_NULL:
+               count[TVIN_ASPECT_NULL]++;
+               break;
+       case TVIN_ASPECT_1x1:
+               count[TVIN_ASPECT_1x1]++;
+               break;
+       case TVIN_ASPECT_4x3_FULL:
+               count[TVIN_ASPECT_4x3_FULL]++;
+               break;
+       case TVIN_ASPECT_14x9_FULL:
+               count[TVIN_ASPECT_14x9_FULL]++;
+               break;
+       case TVIN_ASPECT_14x9_LB_CENTER:
+               count[TVIN_ASPECT_14x9_LB_CENTER]++;
+               break;
+       case TVIN_ASPECT_14x9_LB_TOP:
+               count[TVIN_ASPECT_14x9_LB_TOP]++;
+               break;
+       case TVIN_ASPECT_16x9_FULL:
+               count[TVIN_ASPECT_16x9_FULL]++;
+               break;
+       case TVIN_ASPECT_16x9_LB_CENTER:
+               count[TVIN_ASPECT_16x9_LB_CENTER]++;
+               break;
+       case TVIN_ASPECT_16x9_LB_TOP:
+               count[TVIN_ASPECT_16x9_LB_TOP]++;
+               break;
+       case TVIN_ASPECT_MAX:
+               break;
+       }
+       /*over 30/40 times,ratio is effective*/
+       if (++(tvafe->aspect_ratio_cnt) > TVAFE_RATIO_CNT) {
+               for (i = 0; i < TVIN_ASPECT_MAX; i++) {
+                       if (count[i] > 30) {
+                               tvafe->aspect_ratio = i;
+                               break;
                        }
-                       for (i = 0; i < TVIN_ASPECT_MAX; i++)
-                               count[i] = 0;
-                       tvafe->aspect_ratio_cnt = 0;
                }
+               for (i = 0; i < TVIN_ASPECT_MAX; i++)
+                       count[i] = 0;
+               tvafe->aspect_ratio_cnt = 0;
        }
+
        return TVIN_BUF_NULL;
 }
 
@@ -645,25 +674,28 @@ bool tvafe_is_nosig(struct tvin_frontend_s *fe)
        }
        if (force_stable)
                return ret;
-       if ((port >= TVIN_PORT_CVBS0) && (port <= TVIN_PORT_CVBS3)) {
-               ret = tvafe_cvd2_no_sig(&tvafe->cvd2, &devp->mem);
 
+       if ((port < TVIN_PORT_CVBS0) || (port > TVIN_PORT_CVBS3))
+               return ret;
+
+       if (tvafe->cvd2.info.smr_cnt++ >= 65536)
+               tvafe->cvd2.info.smr_cnt = 0;
+
+       ret = tvafe_cvd2_no_sig(&tvafe->cvd2, &devp->mem);
+       if ((port == TVIN_PORT_CVBS3) &&
+               (tvafe->cvd2.config_fmt == TVIN_SIG_FMT_CVBS_PAL_I)) {
                /*fix black side when config atv snow*/
-               if (ret && (port == TVIN_PORT_CVBS3) &&
-                       (devp->flags & TVAFE_FLAG_DEV_SNOW_FLAG) &&
-                       (tvafe->cvd2.config_fmt == TVIN_SIG_FMT_CVBS_PAL_I) &&
+               if (ret && (devp->flags & TVAFE_FLAG_DEV_SNOW_FLAG) &&
                        (tvafe->cvd2.info.state != TVAFE_CVD2_STATE_FIND))
                        tvafe_snow_config_acd();
-               else if ((tvafe->cvd2.config_fmt == TVIN_SIG_FMT_CVBS_PAL_I) &&
-                       (tvafe->cvd2.info.state == TVAFE_CVD2_STATE_FIND) &&
-                       (port == TVIN_PORT_CVBS3))
+               else if (tvafe->cvd2.info.state == TVAFE_CVD2_STATE_FIND)
                        tvafe_snow_config_acd_resume();
-
-               /* normal sigal & adc reg error, reload source mux */
-               if (tvafe->cvd2.info.adc_reload_en && !ret)
-                       tvafe_set_source_muxing(port, devp->pinmux);
        }
 
+       /* normal sigal & adc reg error, reload source mux */
+       if (tvafe->cvd2.info.adc_reload_en && !ret)
+               tvafe_set_source_muxing(port, devp->pinmux);
+
        return ret;
 }
 
@@ -714,7 +746,6 @@ enum tvin_sig_fmt_e tvafe_get_fmt(struct tvin_frontend_s *fe)
        enum tvin_port_e port = tvafe->parm.port;
 
        if (!(devp->flags & TVAFE_FLAG_DEV_OPENED)) {
-
                tvafe_pr_err("tvafe havn't opened, get sig fmt error!!!\n");
                return fmt;
        }
@@ -722,7 +753,7 @@ enum tvin_sig_fmt_e tvafe_get_fmt(struct tvin_frontend_s *fe)
                fmt = tvafe_cvd2_get_format(&tvafe->cvd2);
 
        tvafe->parm.info.fmt = fmt;
-       if (tvafe_dbg_enable)
+       if (tvafe_dbg_print & TVAFE_DBG_SMR)
                tvafe_pr_info("%s fmt:%s.\n", __func__,
                        tvin_sig_fmt_str(fmt));
 
@@ -738,9 +769,10 @@ void tvafe_get_sig_property(struct tvin_frontend_s *fe,
        struct tvafe_dev_s *devp = container_of(fe, struct tvafe_dev_s,
                                                frontend);
        struct tvafe_info_s *tvafe = &devp->tvafe;
+       struct tvafe_user_param_s *user_param = &tvafe_user_param;
        enum tvin_port_e port = tvafe->parm.port;
-       unsigned int hs_adj_lev = cutwindow_val_h[1];
-       unsigned int vs_adj_lev = cutwindow_val_v[1];
+       unsigned int hs_adj_lev = user_param->cutwindow_val_h[1];
+       unsigned int vs_adj_lev = user_param->cutwindow_val_v[1];
        unsigned int i;
 
        if (!(devp->flags & TVAFE_FLAG_DEV_OPENED) ||
@@ -758,7 +790,7 @@ void tvafe_get_sig_property(struct tvin_frontend_s *fe,
                if (tvafe->cvd2.info.vs_adj_en) {
                        i = tvafe->cvd2.info.vs_adj_level;
                        if (i < 5)
-                               vs_adj_lev = cutwindow_val_v[i];
+                               vs_adj_lev = user_param->cutwindow_val_v[i];
                        else
                                vs_adj_lev = 0;
                        prop->vs = vs_adj_lev;
@@ -770,11 +802,11 @@ void tvafe_get_sig_property(struct tvin_frontend_s *fe,
                if (tvafe->cvd2.info.hs_adj_en) {
                        i = tvafe->cvd2.info.hs_adj_level;
                        if (i < 4) {
-                               hs_adj_lev = cutwindow_val_h[i];
+                               hs_adj_lev = user_param->cutwindow_val_h[i];
                        } else if (i == 4) {
-                               hs_adj_lev = cutwindow_val_h[i];
-                               prop->vs = cutwindow_val_vs_ve;
-                               prop->ve = cutwindow_val_vs_ve;
+                               hs_adj_lev = user_param->cutwindow_val_h[i];
+                               prop->vs = user_param->cutwindow_val_vs_ve;
+                               prop->ve = user_param->cutwindow_val_vs_ve;
                        } else {
                                hs_adj_lev = 0;
                        }
@@ -795,8 +827,7 @@ void tvafe_get_sig_property(struct tvin_frontend_s *fe,
        prop->aspect_ratio = tvafe->aspect_ratio;
        prop->decimation_ratio = 0;
        prop->dvi_info = 0;
-       /*4 is the test result@20171101 on fluke-54200 and DVD*/
-       prop->skip_vf_num = 4;
+       prop->skip_vf_num = user_param->skip_vf_num;
 }
 /*
  *get cvbs secam source's phase
@@ -841,7 +872,7 @@ static bool tvafe_cvbs_check_frame_skip(struct tvin_frontend_s *fe)
                ret = false;
        } else if ((cvd2->hw.no_sig || !cvd2->hw.h_lock || !cvd2->hw.v_lock) &&
                ((port >= TVIN_PORT_CVBS1) && (port <= TVIN_PORT_CVBS2))) {
-               if (tvafe_dbg_enable)
+               if (tvafe_dbg_print & TVAFE_DBG_NORMAL)
                        tvafe_pr_err("cvbs signal unstable, skip frame!!!\n");
                ret = true;
        }
@@ -901,6 +932,7 @@ static long tvafe_ioctl(struct file *file,
        struct tvafe_dev_s *devp = file->private_data;
        struct tvafe_info_s *tvafe = &devp->tvafe;
        enum tvafe_cvbs_video_e cvbs_lock_status = TVAFE_CVBS_VIDEO_HV_UNLOCKED;
+       enum tvin_sig_fmt_e fmt = TVIN_SIG_FMT_NULL;
 
        if (_IOC_TYPE(cmd) != _TM_T) {
                tvafe_pr_err("%s invalid command: %u\n", __func__, cmd);
@@ -960,59 +992,44 @@ static long tvafe_ioctl(struct file *file,
                tvafe_snow_function_flag = true;
                tvafe_snow_config(1);
                tvafe_snow_config_clamp(1);
-               if (tvafe_dbg_enable)
+               if (tvafe_dbg_print & TVAFE_DBG_NORMAL)
                        tvafe_pr_info("TVIN_IOC_S_AFE_SONWON\n");
                break;
        case TVIN_IOC_S_AFE_SONWOFF:
                tvafe_snow_config(0);
                tvafe_snow_config_clamp(0);
                devp->flags &= (~TVAFE_FLAG_DEV_SNOW_FLAG);
-               if (tvafe_dbg_enable)
+               if (tvafe_dbg_print & TVAFE_DBG_NORMAL)
                        tvafe_pr_info("TVIN_IOC_S_AFE_SONWOFF\n");
                break;
        case TVIN_IOC_G_AFE_CVBS_LOCK:
-               {
-                       cvbs_lock_status =
-                       tvafe_cvd2_get_lock_status(&tvafe->cvd2);
-                       if (copy_to_user(argp,
-                               &cvbs_lock_status, sizeof(int))) {
-
-                               ret = -EFAULT;
-                               break;
-                       }
-                       tvafe_pr_info("%s: get cvd2 lock status :%d.\n",
-                               __func__, cvbs_lock_status);
+               cvbs_lock_status = tvafe_cvd2_get_lock_status(&tvafe->cvd2);
+               if (copy_to_user(argp, &cvbs_lock_status, sizeof(int))) {
+                       ret = -EFAULT;
                        break;
                }
+               tvafe_pr_info("%s: get cvd2 lock status :%d.\n",
+                       __func__, cvbs_lock_status);
+               break;
        case TVIN_IOC_S_AFE_CVBS_STD:
-               {
-                       enum tvin_sig_fmt_e fmt = TVIN_SIG_FMT_NULL;
-
-                       if (copy_from_user(&fmt, argp,
-                               sizeof(enum tvin_sig_fmt_e))) {
-                               ret = -EFAULT;
-                               break;
-                       }
-                       tvafe->cvd2.manual_fmt = fmt;
-                       tvafe_pr_info("%s: ioctl set cvd2 manual fmt:%s.\n",
-                               __func__, tvin_sig_fmt_str(fmt));
-                       if (fmt != TVIN_SIG_FMT_NULL)
-                               manual_flag = 1;
+               if (copy_from_user(&fmt, argp, sizeof(enum tvin_sig_fmt_e))) {
+                       ret = -EFAULT;
                        break;
                }
+               tvafe->cvd2.manual_fmt = fmt;
+               tvafe_pr_info("%s: ioctl set cvd2 manual fmt:%s.\n",
+                       __func__, tvin_sig_fmt_str(fmt));
+               if (fmt != TVIN_SIG_FMT_NULL)
+                       manual_flag = 1;
+               break;
        case TVIN_IOC_G_AFE_CVBS_STD:
-               {
-                       enum tvin_sig_fmt_e fmt = TVIN_SIG_FMT_NULL;
-
-                       if (tvafe->cvd2.info.state == TVAFE_CVD2_STATE_FIND)
-                               fmt = tvafe->cvd2.config_fmt;
-                       if (copy_to_user(argp, &fmt,
-                                       sizeof(enum tvin_sig_fmt_e)))
-                               ret = -EFAULT;
-                       tvafe_pr_info("%s: ioctl get fmt:%s.\n",
-                               __func__, tvin_sig_fmt_str(fmt));
-                       break;
-               }
+               if (tvafe->cvd2.info.state == TVAFE_CVD2_STATE_FIND)
+                       fmt = tvafe->cvd2.config_fmt;
+               if (copy_to_user(argp, &fmt, sizeof(enum tvin_sig_fmt_e)))
+                       ret = -EFAULT;
+               tvafe_pr_info("%s: ioctl get fmt:%s.\n",
+                       __func__, tvin_sig_fmt_str(fmt));
+               break;
        default:
                ret = -ENOIOCTLCMD;
                break;
@@ -1168,6 +1185,41 @@ static void tvafe_clktree_probe(struct device *dev)
                tvafe_pr_err("error: %s: clk vdac_clk_gate\n", __func__);
 }
 
+static void tvafe_user_parameters_config(struct device_node *of_node)
+{
+       unsigned int val[5];
+       int ret;
+
+       if (!of_node)
+               return;
+
+       /* cutwindow config */
+       ret = of_property_read_u32_array(of_node, "cutwindow_val_h",
+                       tvafe_user_param.cutwindow_val_h, 5);
+       if (ret)
+               tvafe_pr_err("Can't get cutwindow_val_h\n");
+       ret = of_property_read_u32_array(of_node, "cutwindow_val_v",
+                       tvafe_user_param.cutwindow_val_v, 5);
+       if (ret)
+               tvafe_pr_err("Can't get cutwindow_val_v\n");
+
+       ret = of_property_read_u32(of_node, "auto_adj_en", &val[0]);
+       if (ret == 0) {
+               tvafe_pr_info("find auto_adj_en: 0x%x\n", val[0]);
+               tvafe_user_param.auto_adj_en = val[0];
+       }
+
+       ret = of_property_read_u32_array(of_node, "nostd_vs_th",
+                       val, 2);
+       if (ret == 0) {
+               tvafe_user_param.nostd_vs_th = val[0];
+               tvafe_user_param.force_vs_th_flag = val[1];
+               tvafe_pr_info("find nostd_vs_th: 0x%x %d\n",
+                       tvafe_user_param.nostd_vs_th,
+                       tvafe_user_param.force_vs_th_flag);
+       }
+}
+
 struct meson_tvafe_data meson_gxtvbb_tvafe_data = {
        .cpu_id = CPU_TYPE_GXTVBB,
        .name = "meson-gxtvbb-tvafe",
@@ -1367,15 +1419,7 @@ static int tvafe_drv_probe(struct platform_device *pdev)
        tvafe_pr_info("%s: tvafe maped reg_base =%p, size=%x\n",
                        __func__, tvafe_reg_base, size_io_reg);
 
-       /* cutwindow config */
-       if (of_property_read_u32_array(pdev->dev.of_node, "cutwindow_val_h",
-                       cutwindow_val_h, 5)) {
-               tvafe_pr_err("Can't get cutwindow_val_h\n");
-       }
-       if (of_property_read_u32_array(pdev->dev.of_node, "cutwindow_val_v",
-                       cutwindow_val_v, 5)) {
-               tvafe_pr_err("Can't get cutwindow_val_v\n");
-       }
+       tvafe_user_parameters_config(pdev->dev.of_node);
 
        /* frontend */
        tvin_frontend_init(&tdevp->frontend, &tvafe_dec_ops,
index dc53c8a..32218e0 100644 (file)
@@ -32,7 +32,7 @@
 /* ************************************************* */
 /* *** macro definitions ********************************************* */
 /* *********************************************************** */
-#define TVAFE_VER "Ref.2019/04/24"
+#define TVAFE_VER "Ref.2019/07/02"
 
 /* used to set the flag of tvafe_dev_s */
 #define TVAFE_FLAG_DEV_OPENED 0x00000010
@@ -61,6 +61,24 @@ struct tvafe_info_s {
        unsigned int aspect_ratio_cnt;
 };
 
+#define TVAFE_AUTO_CDTO    (1 << 0)
+#define TVAFE_AUTO_HS      (1 << 1)
+#define TVAFE_AUTO_VS      (1 << 2)
+#define TVAFE_AUTO_DE      (1 << 3)
+#define TVAFE_AUTO_3DCOMB  (1 << 4)
+#define TVAFE_AUTO_PGA     (1 << 5)
+
+struct tvafe_user_param_s {
+       unsigned int cutwindow_val_h[5];
+       unsigned int cutwindow_val_v[5];
+       unsigned int cutwindow_val_vs_ve;
+       unsigned int auto_adj_en;
+       unsigned int nostd_vs_th;
+       unsigned int force_vs_th_flag;
+       unsigned int nostd_stable_cnt;
+       unsigned int skip_vf_num;
+};
+
 /* tvafe device structure */
 struct tvafe_dev_s {
        int     index;
@@ -81,6 +99,7 @@ struct tvafe_dev_s {
        struct tvafe_cvd2_mem_s mem;
 
        struct tvafe_info_s tvafe;
+
        unsigned int cma_config_en;
        /*cma_config_flag:1:share with codec_mm;0:cma alone*/
        unsigned int cma_config_flag;
@@ -97,6 +116,8 @@ struct tvafe_dev_s {
 bool tvafe_get_snow_cfg(void);
 void tvafe_set_snow_cfg(bool cfg);
 
+struct tvafe_user_param_s *tvafe_get_user_param(void);
+
 typedef int (*hook_func_t)(void);
 extern void aml_fe_hook_cvd(hook_func_t atv_mode,
                hook_func_t cvd_hv_lock, hook_func_t get_fmt);
@@ -112,9 +133,15 @@ extern void tvafe_remove_device_files(struct device *dev);
 extern bool disableapi;
 extern bool force_stable;
 
-extern unsigned int cutwindow_val_h[5];
-extern unsigned int cutwindow_val_v[5];
 extern unsigned int force_nostd;
 
+#define TVAFE_DBG_NORMAL     (1 << 0)
+#define TVAFE_DBG_ISR        (1 << 4)
+#define TVAFE_DBG_SMR        (1 << 8)
+#define TVAFE_DBG_SMR2       (1 << 9)
+#define TVAFE_DBG_NOSTD      (1 << 12)
+#define TVAFE_DBG_NOSTD2     (1 << 13)
+extern unsigned int tvafe_dbg_print;
+
 #endif  /* _TVAFE_H */
 
index f83dfcc..5b6e18a 100644 (file)
@@ -115,12 +115,8 @@ static int scene_colorful_old;
 static int auto_de_en = 1;
 static int lock_cnt;
 static unsigned int cvd_reg8a = 0xa;
-static int auto_vs_en = 1;
 static bool ntsc50_en;
 
-module_param(auto_vs_en, int, 0664);
-MODULE_PARM_DESC(auto_vs_en, "auto_vs_en\n");
-
 module_param(auto_de_en, int, 0664);
 MODULE_PARM_DESC(auto_de_en, "auto_de_en\n");
 
@@ -135,14 +131,6 @@ 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 bool cvd_dbg_en;
-module_param(cvd_dbg_en, bool, 0664);
-MODULE_PARM_DESC(cvd_dbg_en, "cvd2 debug enable");
-
-static bool cvd_nonstd_dbg_en;
-module_param(cvd_nonstd_dbg_en, bool, 0664);
-MODULE_PARM_DESC(cvd_nonstd_dbg_en, "cvd2 nonstd debug enable");
-
 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");
@@ -222,8 +210,6 @@ static bool cvd_pr1_chroma_flag;
 static bool cvd_pr2_chroma_flag;
 
 /* zhuangwei, nonstd experiment */
-static short nonstd_cnt;
-static short nonstd_flag;
 static unsigned int chroma_sum_pre1;
 static unsigned int chroma_sum_pre2;
 static unsigned int chroma_sum_pre3;
@@ -232,7 +218,7 @@ static unsigned int noise1;
 static unsigned int noise2;
 static unsigned int noise3;
 /* test */
-static short print_cnt;
+#define NOSTD_DEBUG_PRINT_CNT     100
 
 unsigned int vbi_mem_start;
 
@@ -259,7 +245,7 @@ void cvd_vbi_config(void)
        W_APB_BIT(CVD2_VBI_CONTROL, 1, 0, 1);
        W_APB_REG(CVD2_VSYNC_VBI_LOCKOUT_START, 0x00000000);
        W_APB_REG(CVD2_VSYNC_VBI_LOCKOUT_END, 0x00000025);
-       if (cvd_dbg_en)
+       if (tvafe_dbg_print & TVAFE_DBG_SMR)
                tvafe_pr_info("cvd_vbi_config\n");
 }
 
@@ -277,7 +263,7 @@ static void tvafe_cvd2_memory_init(struct tvafe_cvd2_mem_s *mem,
 
        if ((mem->start == 0) || (mem->size == 0)) {
 
-               if (cvd_dbg_en)
+               if (tvafe_dbg_print & TVAFE_DBG_SMR)
                        tvafe_pr_info("%s: cvd2 memory size error!!!\n",
                        __func__);
                return;
@@ -360,7 +346,7 @@ static void tvafe_cvd2_filter_config(void)
                W_APB_REG(ACD_REG_96, 0x0);
                break;
        }
-       if (cvd_dbg_en)
+       if (tvafe_dbg_print & TVAFE_DBG_SMR)
                tvafe_pr_info("%s cvd2 filter config level %d.\n",
                                __func__, CVD2_FILTER_CONFIG_LEVEL);
 
@@ -372,6 +358,7 @@ static void tvafe_cvd2_filter_config(void)
 static void tvafe_cvd2_write_mode_reg(struct tvafe_cvd2_s *cvd2,
                struct tvafe_cvd2_mem_s *mem)
 {
+       struct tvafe_user_param_s *user_param = tvafe_get_user_param();
        unsigned int i = 0;
 
        /*disable vbi*/
@@ -445,7 +432,7 @@ static void tvafe_cvd2_write_mode_reg(struct tvafe_cvd2_s *cvd2,
        }
 
        if ((cvd2->vd_port == TVIN_PORT_CVBS1) ||
-               (cvd2->vd_port == TVIN_PORT_CVBS2)) {
+               (cvd2->vd_port == TVIN_PORT_CVBS2)) { /* avin */
                if (cvd2->config_fmt == TVIN_SIG_FMT_CVBS_NTSC_M) {
                        W_APB_REG(CVD2_VSYNC_SIGNAL_THRESHOLD, 0x7d);
                        if (tvafe_cpu_type() == CPU_TYPE_TL1) {
@@ -463,6 +450,13 @@ static void tvafe_cvd2_write_mode_reg(struct tvafe_cvd2_s *cvd2,
                                W_APB_REG(ACD_REG_8C, 0x38000);
                        }
                }
+       } else if ((cvd2->vd_port == TVIN_PORT_CVBS3) ||
+                       (cvd2->vd_port == TVIN_PORT_CVBS0)) { /* atv */
+               if (cvd2->config_fmt == TVIN_SIG_FMT_CVBS_PAL_I) {
+                       if (user_param->force_vs_th_flag)
+                               W_APB_BIT(CVD2_VSYNC_SIGNAL_THRESHOLD,
+                                       user_param->nostd_vs_th, 0, 8);
+               }
        }
 
        /* reload CVD2 reg 0x87, 0x93, 0x94, 0x95, 0x96, 0xe6, 0xfa (int) */
@@ -586,9 +580,9 @@ static void tvafe_cvd2_write_mode_reg(struct tvafe_cvd2_s *cvd2,
 /*
  * tvafe cvd2 configure Reg for non-standard signal
  */
-static void tvafe_cvd2_non_std_config(struct tvafe_cvd2_s *cvd2)
+void tvafe_cvd2_non_std_config(struct tvafe_cvd2_s *cvd2)
 {
-       static unsigned int time_non_count = 50;
+       struct tvafe_user_param_s *user_param = tvafe_get_user_param();
        unsigned int noise_read = 0;
        unsigned int noise_strenth = 0;
 
@@ -598,26 +592,27 @@ static void tvafe_cvd2_non_std_config(struct tvafe_cvd2_s *cvd2)
        noise1 = noise_read;
        noise_strenth = (noise1+(noise2<<1)+noise3)>>2;
 
-       if (time_non_count) {
-               time_non_count--;
-               return;
-       }
-       time_non_count = 200;
        if (force_nostd == 3)
                return;
-       if (cvd_nonstd_dbg_en) {
-               tvafe_pr_info("%s: force_nostd=%d, non_std_config=%d, non_std_enable=%d\n",
+
+       if (cvd2->info.nonstd_print_cnt == 0) {
+               if (tvafe_dbg_print & TVAFE_DBG_NOSTD2) {
+                       tvafe_pr_info("%s: force_nostd=%d, non_std_config=%d, non_std_enable=%d\n",
                        __func__, force_nostd,
                        cvd2->info.non_std_config,
                        cvd2->info.non_std_enable);
+               }
        }
+       if (cvd2->info.nonstd_print_cnt++ >= NOSTD_DEBUG_PRINT_CNT)
+               cvd2->info.nonstd_print_cnt = 0;
+
        if ((cvd2->info.non_std_config == cvd2->info.non_std_enable) &&
                (force_nostd == 2))
                return;
        cvd2->info.non_std_config = cvd2->info.non_std_enable;
-       if (cvd2->info.non_std_config && (!(force_nostd&0x1))) {
+       if (cvd2->info.non_std_config && (force_nostd != 0x1)) {
 
-               if (cvd_nonstd_dbg_en) {
+               if (tvafe_dbg_print & TVAFE_DBG_NOSTD) {
                        tvafe_pr_info("%s: config non-std signal reg, noise_strenth=%d\n",
                                __func__, noise_strenth);
                }
@@ -669,8 +664,8 @@ static void tvafe_cvd2_non_std_config(struct tvafe_cvd2_s *cvd2)
 
                        /*config 0 for tuner R840/mxl661*/
                        /*si2151 si2159 r842 may need set 1*/
-                       W_APB_BIT(CVD2_VSYNC_SIGNAL_THRESHOLD, 0,
-                               VS_SIGNAL_AUTO_TH_BIT, VS_SIGNAL_AUTO_TH_WID);
+                       W_APB_BIT(CVD2_VSYNC_SIGNAL_THRESHOLD,
+                               user_param->nostd_vs_th, 0, 8);
 
                        /* vsync signal is not good */
                        W_APB_REG(CVD2_NOISE_THRESHOLD, 0x00);
@@ -688,9 +683,8 @@ static void tvafe_cvd2_non_std_config(struct tvafe_cvd2_s *cvd2)
 #endif
 
        } else {
-               if (cvd_nonstd_dbg_en)
-                       tvafe_pr_info("%s: out of non-std signal.\n",
-                               __func__);
+               if (tvafe_dbg_print & TVAFE_DBG_NOSTD)
+                       tvafe_pr_info("%s: out of non-std signal.\n", __func__);
                W_APB_REG(CVD2_HSYNC_RISING_EDGE_START, 0x6d);
                /*bit 15 dis/enabled by avin detect*/
                W_APB_BIT(TVFE_CLAMP_INTF, 0x666, 0, 12);
@@ -707,7 +701,7 @@ static void tvafe_cvd2_non_std_config(struct tvafe_cvd2_s *cvd2)
 
                                W_APB_REG(CVD2_VSYNC_SIGNAL_THRESHOLD, 0xf0);
                                W_APB_REG(CVD2_VSYNC_CNTL, 0x2);
-                               if (cvd_nonstd_dbg_en)
+                               if (tvafe_dbg_print & TVAFE_DBG_NOSTD)
                                        tvafe_pr_info("%s: out of non-std signal.rssi=%d\n",
                                        __func__, cvd_get_rf_strength());
                        }
@@ -717,7 +711,7 @@ static void tvafe_cvd2_non_std_config(struct tvafe_cvd2_s *cvd2)
                                SYNC_SENSITIVITY) {
                                W_APB_REG(CVD2_VSYNC_SIGNAL_THRESHOLD, 0xf0);
                                W_APB_REG(CVD2_VSYNC_CNTL, 0x2);
-                               if (cvd_nonstd_dbg_en)
+                               if (tvafe_dbg_print & TVAFE_DBG_NOSTD)
                                        tvafe_pr_info("%s: use the cvd register to judge the rssi.rssi=%u\n",
                                __func__, R_APB_REG(CVD2_SYNC_NOISE_STATUS));
                        }
@@ -792,44 +786,43 @@ static void tvafe_cvd2_set_cdto(unsigned int cdto)
 void tvafe_cvd2_set_default_cdto(struct tvafe_cvd2_s *cvd2)
 {
        if (!cvd2) {
-
                tvafe_pr_info("%s cvd2 null error.\n", __func__);
                return;
        }
-               switch (cvd2->config_fmt) {
 
-               case TVIN_SIG_FMT_CVBS_NTSC_M:
-                       if (tvafe_cvd2_get_cdto() != CVD2_CHROMA_DTO_NTSC_M)
-                               tvafe_cvd2_set_cdto(CVD2_CHROMA_DTO_NTSC_M);
-                       break;
-               case TVIN_SIG_FMT_CVBS_NTSC_443:
-                       if (tvafe_cvd2_get_cdto() != CVD2_CHROMA_DTO_NTSC_443)
-                               tvafe_cvd2_set_cdto(CVD2_CHROMA_DTO_NTSC_443);
-                       break;
-               case TVIN_SIG_FMT_CVBS_PAL_I:
-                       if (tvafe_cvd2_get_cdto() != CVD2_CHROMA_DTO_PAL_I)
-                               tvafe_cvd2_set_cdto(CVD2_CHROMA_DTO_PAL_I);
-                       break;
-               case TVIN_SIG_FMT_CVBS_PAL_M:
-                       if (tvafe_cvd2_get_cdto() != CVD2_CHROMA_DTO_PAL_M)
-                               tvafe_cvd2_set_cdto(CVD2_CHROMA_DTO_PAL_M);
-                       break;
-               case TVIN_SIG_FMT_CVBS_PAL_60:
-                       if (tvafe_cvd2_get_cdto() != CVD2_CHROMA_DTO_PAL_60)
-                               tvafe_cvd2_set_cdto(CVD2_CHROMA_DTO_PAL_60);
-                       break;
-               case TVIN_SIG_FMT_CVBS_PAL_CN:
-                       if (tvafe_cvd2_get_cdto() != CVD2_CHROMA_DTO_PAL_CN)
-                               tvafe_cvd2_set_cdto(CVD2_CHROMA_DTO_PAL_CN);
-                       break;
-               case TVIN_SIG_FMT_CVBS_SECAM:
-                       if (tvafe_cvd2_get_cdto() != CVD2_CHROMA_DTO_SECAM)
-                               tvafe_cvd2_set_cdto(CVD2_CHROMA_DTO_SECAM);
-                       break;
-               default:
-                       break;
+       switch (cvd2->config_fmt) {
+       case TVIN_SIG_FMT_CVBS_NTSC_M:
+               if (tvafe_cvd2_get_cdto() != CVD2_CHROMA_DTO_NTSC_M)
+                       tvafe_cvd2_set_cdto(CVD2_CHROMA_DTO_NTSC_M);
+               break;
+       case TVIN_SIG_FMT_CVBS_NTSC_443:
+               if (tvafe_cvd2_get_cdto() != CVD2_CHROMA_DTO_NTSC_443)
+                       tvafe_cvd2_set_cdto(CVD2_CHROMA_DTO_NTSC_443);
+               break;
+       case TVIN_SIG_FMT_CVBS_PAL_I:
+               if (tvafe_cvd2_get_cdto() != CVD2_CHROMA_DTO_PAL_I)
+                       tvafe_cvd2_set_cdto(CVD2_CHROMA_DTO_PAL_I);
+               break;
+       case TVIN_SIG_FMT_CVBS_PAL_M:
+               if (tvafe_cvd2_get_cdto() != CVD2_CHROMA_DTO_PAL_M)
+                       tvafe_cvd2_set_cdto(CVD2_CHROMA_DTO_PAL_M);
+               break;
+       case TVIN_SIG_FMT_CVBS_PAL_60:
+               if (tvafe_cvd2_get_cdto() != CVD2_CHROMA_DTO_PAL_60)
+                       tvafe_cvd2_set_cdto(CVD2_CHROMA_DTO_PAL_60);
+               break;
+       case TVIN_SIG_FMT_CVBS_PAL_CN:
+               if (tvafe_cvd2_get_cdto() != CVD2_CHROMA_DTO_PAL_CN)
+                       tvafe_cvd2_set_cdto(CVD2_CHROMA_DTO_PAL_CN);
+               break;
+       case TVIN_SIG_FMT_CVBS_SECAM:
+               if (tvafe_cvd2_get_cdto() != CVD2_CHROMA_DTO_SECAM)
+                       tvafe_cvd2_set_cdto(CVD2_CHROMA_DTO_SECAM);
+               break;
+       default:
+               break;
        }
-       if (cvd_dbg_en)
+       if (tvafe_dbg_print & TVAFE_DBG_ISR)
                tvafe_pr_info("%s set cdto to default fmt %s.\n",
                                __func__, tvin_sig_fmt_str(cvd2->config_fmt));
 }
@@ -845,7 +838,7 @@ inline void tvafe_cvd2_try_format(struct tvafe_cvd2_s *cvd2,
        if ((fmt < TVIN_SIG_FMT_CVBS_NTSC_M) ||
                (fmt > TVIN_SIG_FMT_CVBS_NTSC_50)) {
 
-               if (cvd_dbg_en)
+               if (tvafe_dbg_print & TVAFE_DBG_SMR)
                        tvafe_pr_err("%s: cvd2 try format error!!!\n",
                        __func__);
                return;
@@ -865,7 +858,7 @@ inline void tvafe_cvd2_try_format(struct tvafe_cvd2_s *cvd2,
 /*
  * tvafe cvd2 get signal status from Reg
  */
-void tvafe_cvd2_get_signal_status(struct tvafe_cvd2_s *cvd2)
+static void tvafe_cvd2_get_signal_status(struct tvafe_cvd2_s *cvd2)
 {
        int data = 0;
 
@@ -946,7 +939,7 @@ void tvafe_cvd2_get_signal_status(struct tvafe_cvd2_s *cvd2)
                !cvd2->hw_data[2].secam_detected)
                cvd2->hw.secam_detected = false;
 
-       if (cnt_dbg_en & 1)
+       if (tvafe_dbg_print & TVAFE_DBG_SMR2)
                tvafe_pr_info("acc4xx_cnt=%d,acc425_cnt=%d,acc3xx_cnt=%d,acc358_cnt=%d\n",
                        cvd2->hw.acc4xx_cnt, cvd2->hw.acc425_cnt,
                        cvd2->hw.acc3xx_cnt, cvd2->hw.acc358_cnt);
@@ -979,7 +972,7 @@ void tvafe_cvd2_get_signal_status(struct tvafe_cvd2_s *cvd2)
        }
        if (++ cvd2->hw_data_cur >= 3)
                cvd2->hw_data_cur = 0;
-       if (cnt_dbg_en & 2)
+       if (tvafe_dbg_print & TVAFE_DBG_SMR2)
                tvafe_pr_info("[%d]:hw.fsc_358=%d,hw.fsc_425=%d,hw.fsc_443 =%d\n",
                __LINE__, cvd2->hw.fsc_358,
                cvd2->hw.fsc_425, cvd2->hw.fsc_443);
@@ -1192,15 +1185,14 @@ EXPORT_SYMBOL(tvafe_cvd2_get_hv_lock);
 /*
  * tvafe cvd2 non-standard signal detection
  */
-static void tvafe_cvd2_non_std_signal_det(
-                               struct tvafe_cvd2_s *cvd2)
+static void tvafe_cvd2_non_std_signal_det(struct tvafe_cvd2_s *cvd2)
 {
+       struct tvafe_user_param_s *user_param = tvafe_get_user_param();
        unsigned short dgain = 0;
        unsigned long chroma_sum_filt_tmp = 0;
        unsigned long chroma_sum_filt = 0;
        unsigned long chroma_sum_in = 0;
 
-
        chroma_sum_in = rd_bits(0, VDIN_HIST_CHROMA_SUM,
                                HIST_CHROMA_SUM_BIT,  HIST_CHROMA_SUM_WID);
        chroma_sum_pre3 = chroma_sum_pre2;
@@ -1216,33 +1208,22 @@ static void tvafe_cvd2_non_std_signal_det(
        else
                scene_colorful = 0;
 
-       if (print_cnt == 0x50)
-               print_cnt = 0;
-       else
-               print_cnt = print_cnt + 1;
-
-       if (print_cnt == 0x28) {
-               if (cvd_nonstd_dbg_en)
-                       tvafe_pr_info("%s: scene_colorful = %d, chroma_sum_filt = %ld\n",
-                       __func__, scene_colorful, chroma_sum_filt);
-       }
-
        if ((cvd2->hw.h_nonstd | (cvd2->hw.v_nonstd && scene_colorful)) &&
-               (nonstd_cnt < CVD2_NONSTD_CNT_INC_LIMIT)) {
+               (cvd2->info.nonstd_cnt < CVD2_NONSTD_CNT_INC_LIMIT)) {
 
-               nonstd_cnt = nonstd_cnt + CVD2_NONSTD_CNT_INC_STEP;
+               cvd2->info.nonstd_cnt += CVD2_NONSTD_CNT_INC_STEP;
 
        } else if ((!cvd2->hw.h_nonstd) && (!cvd2->hw.v_nonstd) &&
-                       (nonstd_cnt >= CVD2_NONSTD_CNT_DEC_LIMIT)) {
+                       (cvd2->info.nonstd_cnt >= CVD2_NONSTD_CNT_DEC_LIMIT)) {
 
-               nonstd_cnt = nonstd_cnt - CVD2_NONSTD_CNT_DEC_STEP;
+               cvd2->info.nonstd_cnt -= CVD2_NONSTD_CNT_DEC_STEP;
 
        }
 
-       if (nonstd_cnt <= CVD2_NONSTD_FLAG_OFF_TH)
-               nonstd_flag = 0;
-       else if (nonstd_cnt >= CVD2_NONSTD_FLAG_ON_TH)
-               nonstd_flag = 1;
+       if (cvd2->info.nonstd_cnt <= CVD2_NONSTD_FLAG_OFF_TH)
+               cvd2->info.nonstd_flag = 0;
+       else if (cvd2->info.nonstd_cnt >= CVD2_NONSTD_FLAG_ON_TH)
+               cvd2->info.nonstd_flag = 1;
 
        if ((cvd2->config_fmt == TVIN_SIG_FMT_CVBS_PAL_I) && cvd2->hw.line625) {
 
@@ -1251,22 +1232,52 @@ static void tvafe_cvd2_non_std_signal_det(
                dgain |= R_APB_BIT(CVD2_AGC_GAIN_STATUS_11_8,
                                AGC_GAIN_11_8_BIT, AGC_GAIN_11_8_WID)<<8;
                if ((dgain >= TVAFE_CVD2_NONSTD_DGAIN_MAX) ||
-                               cvd2->hw.h_nonstd || nonstd_flag){
+                               cvd2->hw.h_nonstd || cvd2->info.nonstd_flag) {
 
-                       cvd2->info.non_std_enable = 1;
+                       cvd2->info.nonstd_flag_adv = 1;
 
                } else {
 
-                       cvd2->info.non_std_enable = 0;
+                       cvd2->info.nonstd_flag_adv = 0;
                }
        }
 
-       if (print_cnt == 0x28) {
-               if (cvd_nonstd_dbg_en) {
-                       tvafe_pr_info("%s: nonstd_cnt=%d, nonstd_flag=%d, dgain=0x%x, non_std_enable=%d\n",
-                               __func__, nonstd_cnt, nonstd_flag, dgain,
+       if (cvd2->info.non_std_enable_tmp != cvd2->info.nonstd_flag_adv) {
+               cvd2->info.non_std_enable_tmp = cvd2->info.nonstd_flag_adv;
+               cvd2->info.nonstd_stable_cnt = 0;
+               if (tvafe_dbg_print & TVAFE_DBG_NOSTD) {
+                       tvafe_pr_info("%s: scene_colorful = %d, chroma_sum_filt = %ld, hw_h_nonstd=%d, hw_v_nonstd=%d\n",
+                               __func__, scene_colorful, chroma_sum_filt,
+                               cvd2->hw.h_nonstd, cvd2->hw.v_nonstd);
+                       tvafe_pr_info("%s: smr_cnt=%d, nonstd_cnt=%d, nonstd_flag=%d, dgain=0x%x, non_std_enable=%d\n",
+                               __func__, cvd2->info.smr_cnt,
+                               cvd2->info.nonstd_cnt,
+                               cvd2->info.nonstd_flag, dgain,
                                cvd2->info.non_std_enable);
                }
+       } else {
+               /* filter for nostd_stable_cnt*10ms */
+               if (cvd2->info.nonstd_stable_cnt <
+                       user_param->nostd_stable_cnt) {
+                       cvd2->info.nonstd_stable_cnt++;
+               } else if (cvd2->info.nonstd_stable_cnt ==
+                       user_param->nostd_stable_cnt) {
+                       cvd2->info.non_std_enable =
+                               cvd2->info.non_std_enable_tmp;
+                       cvd2->info.nonstd_stable_cnt++;
+                       if (tvafe_dbg_print & TVAFE_DBG_NOSTD) {
+                               tvafe_pr_info("%s: scene_colorful = %d, chroma_sum_filt = %ld, hw_h_nonstd=%d, hw_v_nonstd=%d\n",
+                                       __func__, scene_colorful,
+                                       chroma_sum_filt,
+                                       cvd2->hw.h_nonstd,
+                                       cvd2->hw.v_nonstd);
+                               tvafe_pr_info("%s: smr_cnt=%d, nonstd_cnt=%d, nonstd_flag=%d, dgain=0x%x, non_std_enable=%d\n",
+                                       __func__, cvd2->info.smr_cnt,
+                                       cvd2->info.nonstd_cnt,
+                                       cvd2->info.nonstd_flag, dgain,
+                                       cvd2->info.non_std_enable);
+                       }
+               }
        }
 }
 
@@ -1301,68 +1312,60 @@ static bool tvafe_cvd2_condition_shift(struct tvafe_cvd2_s *cvd2)
 {
        bool ret = false;
 
-       /* check non standard signal, ignore SECAM/525 mode */
-       if (!tvafe_cvd2_sig_unstable(cvd2))
-               tvafe_cvd2_non_std_signal_det(cvd2);
-
-       if (cvd2->manual_fmt)
-               return false;
-
        if (tvafe_cvd2_sig_unstable(cvd2)) {
-
-               if (cvd_dbg_en)
+               if (tvafe_dbg_print & TVAFE_DBG_SMR)
                        tvafe_pr_info("%s: sig unstable, nosig:%d,h-lock:%d,v-lock:%d\n",
                        __func__,
                        cvd2->hw.no_sig, cvd2->hw.h_lock, cvd2->hw.v_lock);
                return true;
        }
 
-       /* check line flag */
-               switch (cvd2->config_fmt) {
-
-               case TVIN_SIG_FMT_CVBS_PAL_I:
-               case TVIN_SIG_FMT_CVBS_PAL_CN:
-               case TVIN_SIG_FMT_CVBS_SECAM:
-               case TVIN_SIG_FMT_CVBS_NTSC_50:
-                       if (!cvd2->hw.line625) {
+       /* check non standard signal, ignore SECAM/525 mode */
+       tvafe_cvd2_non_std_signal_det(cvd2);
 
-                               ret = true;
-                               cvd2->fmt_loop_cnt = 0;
-                               if (cvd_dbg_en)
-                                       tvafe_pr_info("%s: reset fmt try cnt 525 line\n",
-                                       __func__);
-                       }
-                       break;
-               case TVIN_SIG_FMT_CVBS_PAL_M:
-               case TVIN_SIG_FMT_CVBS_NTSC_443:
-               case TVIN_SIG_FMT_CVBS_PAL_60:
-               case TVIN_SIG_FMT_CVBS_NTSC_M:
-                       if (cvd2->hw.line625) {
+       if (cvd2->manual_fmt)
+               return false;
 
-                               ret = true;
-                               cvd2->fmt_loop_cnt = 0;
-                               if (cvd_dbg_en)
-                                       tvafe_pr_info("%s: reset fmt try cnt 625 line\n",
-                                       __func__);
-                       }
-                       break;
-               default:
-                       break;
+       /* check line flag */
+       switch (cvd2->config_fmt) {
+       case TVIN_SIG_FMT_CVBS_PAL_I:
+       case TVIN_SIG_FMT_CVBS_PAL_CN:
+       case TVIN_SIG_FMT_CVBS_SECAM:
+       case TVIN_SIG_FMT_CVBS_NTSC_50:
+               if (!cvd2->hw.line625) {
+                       ret = true;
+                       cvd2->fmt_loop_cnt = 0;
+                       if (tvafe_dbg_print & TVAFE_DBG_SMR)
+                               tvafe_pr_info("%s: reset fmt try cnt 525 line\n",
+                               __func__);
+               }
+               break;
+       case TVIN_SIG_FMT_CVBS_PAL_M:
+       case TVIN_SIG_FMT_CVBS_NTSC_443:
+       case TVIN_SIG_FMT_CVBS_PAL_60:
+       case TVIN_SIG_FMT_CVBS_NTSC_M:
+               if (cvd2->hw.line625) {
+                       ret = true;
+                       cvd2->fmt_loop_cnt = 0;
+                       if (tvafe_dbg_print & TVAFE_DBG_SMR)
+                               tvafe_pr_info("%s: reset fmt try cnt 625 line\n",
+                               __func__);
+               }
+               break;
+       default:
+               break;
        }
        if (ret) {
-
-               if (cvd_dbg_en)
+               if (tvafe_dbg_print & TVAFE_DBG_SMR)
                        tvafe_pr_info("%s: line625 error!!!!\n", __func__);
                return true;
        }
-       if (cvd2->hw.no_color_burst) {
 
+       if (cvd2->hw.no_color_burst) {
                /* for SECAM format, set PAL_I */
                if (cvd2->config_fmt != TVIN_SIG_FMT_CVBS_SECAM) {
                        /* set default fmt */
-
-                       if (!cvd_pr_flag && cvd_dbg_en) {
-
+                       if (!cvd_pr_flag && (tvafe_dbg_print & TVAFE_DBG_SMR)) {
                                cvd_pr_flag = true;
                                tvafe_pr_info("%s: no-color-burst, do not change mode.\n",
                                        __func__);
@@ -1373,9 +1376,7 @@ static bool tvafe_cvd2_condition_shift(struct tvafe_cvd2_s *cvd2)
        /* ignore pal flag because of cdto adjustment */
        if ((cvd2->info.non_std_worst || cvd2->hw.h_nonstd) &&
                        (cvd2->config_fmt == TVIN_SIG_FMT_CVBS_PAL_I)) {
-
-               if (!cvd_pr_flag && cvd_dbg_en) {
-
+               if (!cvd_pr_flag && (tvafe_dbg_print & TVAFE_DBG_SMR)) {
                        cvd_pr_flag = true;
                        tvafe_pr_info("%s: if adj cdto or h-nonstd, ignore mode change.\n",
                                __func__);
@@ -1388,14 +1389,11 @@ static bool tvafe_cvd2_condition_shift(struct tvafe_cvd2_s *cvd2)
                (cvd2->config_fmt == TVIN_SIG_FMT_CVBS_NTSC_M)) {
 
                if (cvd2->info.ntsc_switch_cnt++ >= NTSC_SW_MAXCNT)
-
                        cvd2->info.ntsc_switch_cnt = 0;
 
-
                if (cvd2->info.ntsc_switch_cnt <= NTSC_SW_MIDCNT) {
-
                        if (R_APB_BIT(CVD2_CHROMA_DTO_INCREMENT_23_16,
-                       CDTO_INC_23_16_BIT, CDTO_INC_23_16_WID) != 0x2e){
+                       CDTO_INC_23_16_BIT, CDTO_INC_23_16_WID) != 0x2e) {
 
                                W_APB_BIT(CVD2_CHROMA_DTO_INCREMENT_23_16, 0x2e,
                                        CDTO_INC_23_16_BIT, CDTO_INC_23_16_WID);
@@ -1410,8 +1408,8 @@ static bool tvafe_cvd2_condition_shift(struct tvafe_cvd2_s *cvd2)
                                W_APB_BIT(CVD2_PHASE_OFFSE_RANGE, 0x20,
                        PHASE_OFFSET_RANGE_BIT, PHASE_OFFSET_RANGE_WID);
                        }
-                       if (!cvd_pr1_chroma_flag && cvd_dbg_en) {
-
+                       if (!cvd_pr1_chroma_flag &&
+                               (tvafe_dbg_print & TVAFE_DBG_SMR)) {
                                cvd_pr1_chroma_flag = true;
                                cvd_pr2_chroma_flag = false;
                                tvafe_pr_info("%s: change cdto to ntsc-m\n",
@@ -1422,7 +1420,7 @@ static bool tvafe_cvd2_condition_shift(struct tvafe_cvd2_s *cvd2)
 
                        if (R_APB_BIT(CVD2_CHROMA_DTO_INCREMENT_23_16,
                                CDTO_INC_23_16_BIT, CDTO_INC_23_16_WID) !=
-                               0x23){
+                               0x23) {
 
                                W_APB_BIT(CVD2_CHROMA_DTO_INCREMENT_23_16, 0x23,
                                        CDTO_INC_23_16_BIT, CDTO_INC_23_16_WID);
@@ -1439,8 +1437,8 @@ static bool tvafe_cvd2_condition_shift(struct tvafe_cvd2_s *cvd2)
                                        PHASE_OFFSET_RANGE_BIT,
                                        PHASE_OFFSET_RANGE_WID);
                        }
-                       if (!cvd_pr2_chroma_flag && cvd_dbg_en) {
-
+                       if (!cvd_pr2_chroma_flag &&
+                               (tvafe_dbg_print & TVAFE_DBG_SMR)) {
                                cvd_pr2_chroma_flag = true;
                                cvd_pr1_chroma_flag = false;
                                tvafe_pr_info("%s: change cdto to pal-m\n",
@@ -1451,67 +1449,62 @@ static bool tvafe_cvd2_condition_shift(struct tvafe_cvd2_s *cvd2)
        if (((cvd2->vd_port == TVIN_PORT_CVBS3) ||
                (cvd2->vd_port == TVIN_PORT_CVBS0)) &&
                force_fmt_flag) {
-               if (cvd_dbg_en)
+               if (tvafe_dbg_print & TVAFE_DBG_SMR)
                        tvafe_pr_info("[%s]:ignore the pal/358/443 flag and return\n",
                        __func__);
                return false;
        }
        if (ignore_pal_nt)
-
                return false;
 
        /* check pal/secam flag */
-               switch (cvd2->config_fmt) {
-
-               case TVIN_SIG_FMT_CVBS_PAL_I:
-               case TVIN_SIG_FMT_CVBS_PAL_CN:
-               case TVIN_SIG_FMT_CVBS_PAL_60:
-               case TVIN_SIG_FMT_CVBS_PAL_M:
-                       if (!cvd2->hw.pal)
-                               ret = true;
-                       break;
-               case TVIN_SIG_FMT_CVBS_SECAM:
-                       if (!cvd2->hw.secam || !cvd2->hw.secam_detected)
-                               ret = true;
-                       break;
-               case TVIN_SIG_FMT_CVBS_NTSC_443:
-               case TVIN_SIG_FMT_CVBS_NTSC_M:
-               case TVIN_SIG_FMT_CVBS_NTSC_50:
-                       if (cvd2->hw.pal)
-                               ret = true;
-                       break;
-               default:
-                       break;
+       switch (cvd2->config_fmt) {
+       case TVIN_SIG_FMT_CVBS_PAL_I:
+       case TVIN_SIG_FMT_CVBS_PAL_CN:
+       case TVIN_SIG_FMT_CVBS_PAL_60:
+       case TVIN_SIG_FMT_CVBS_PAL_M:
+               if (!cvd2->hw.pal)
+                       ret = true;
+               break;
+       case TVIN_SIG_FMT_CVBS_SECAM:
+               if (!cvd2->hw.secam || !cvd2->hw.secam_detected)
+                       ret = true;
+               break;
+       case TVIN_SIG_FMT_CVBS_NTSC_443:
+       case TVIN_SIG_FMT_CVBS_NTSC_M:
+       case TVIN_SIG_FMT_CVBS_NTSC_50:
+               if (cvd2->hw.pal)
+                       ret = true;
+               break;
+       default:
+               break;
        }
        if (ignore_443_358) {
-
                if (ret)
                        return true;
                else
                        return false;
        }
        /*check 358/443*/
-               switch (cvd2->config_fmt) {
-
-               case TVIN_SIG_FMT_CVBS_PAL_CN:
-               case TVIN_SIG_FMT_CVBS_PAL_M:
-               case TVIN_SIG_FMT_CVBS_NTSC_M:
-               case TVIN_SIG_FMT_CVBS_NTSC_50:
-                       if (!cvd2->hw.fsc_358 && cvd2->hw.fsc_443)
-                               ret = true;
-                       break;
-               case TVIN_SIG_FMT_CVBS_PAL_I:
-               case TVIN_SIG_FMT_CVBS_PAL_60:
-               case TVIN_SIG_FMT_CVBS_NTSC_443:
-                       if (cvd2->hw.fsc_358 && !cvd2->hw.fsc_443)
-                               ret = true;
-                       break;
-               default:
-                       break;
+       switch (cvd2->config_fmt) {
+       case TVIN_SIG_FMT_CVBS_PAL_CN:
+       case TVIN_SIG_FMT_CVBS_PAL_M:
+       case TVIN_SIG_FMT_CVBS_NTSC_M:
+       case TVIN_SIG_FMT_CVBS_NTSC_50:
+               if (!cvd2->hw.fsc_358 && cvd2->hw.fsc_443)
+                       ret = true;
+               break;
+       case TVIN_SIG_FMT_CVBS_PAL_I:
+       case TVIN_SIG_FMT_CVBS_PAL_60:
+       case TVIN_SIG_FMT_CVBS_NTSC_443:
+               if (cvd2->hw.fsc_358 && !cvd2->hw.fsc_443)
+                       ret = true;
+               break;
+       default:
+               break;
        }
        if (ret) {
-
-               if (cvd_dbg_en)
+               if (tvafe_dbg_print & TVAFE_DBG_SMR)
                        tvafe_pr_info("%s: pal is %d,secam flag is %d, changed.\n",
                        __func__, cvd2->hw.pal, cvd2->hw.secam);
                return true;
@@ -1554,19 +1547,20 @@ static void cvd_force_config_fmt(struct tvafe_cvd2_s *cvd2,
 
 }
 
-
-
 /*
- * tvafe cvd2 search video format function
+ * tvafe cvd2 search video format function: cvd2 state machine
  */
 
 static void tvafe_cvd2_search_video_mode(struct tvafe_cvd2_s *cvd2,
                        struct tvafe_cvd2_mem_s *mem)
 {
        unsigned int shift_cnt = 0;
+
        /* execute manual mode */
        if ((cvd2->manual_fmt) && (cvd2->config_fmt != cvd2->manual_fmt) &&
                (cvd2->config_fmt != TVIN_SIG_FMT_NULL)) {
+               tvafe_pr_info("%s: manual_fmt:%s\n",
+                               __func__, tvin_sig_fmt_str(cvd2->manual_fmt));
                tvafe_cvd2_try_format(cvd2, mem, cvd2->manual_fmt);
        }
        /* state-machine */
@@ -1574,15 +1568,16 @@ static void tvafe_cvd2_search_video_mode(struct tvafe_cvd2_s *cvd2,
                /* wait for signal setup */
                if (tvafe_cvd2_sig_unstable(cvd2)) {
                        cvd2->info.state_cnt = 0;
-                       if (!cvd_pr_flag && cvd_dbg_en) {
+                       if (!cvd_pr_flag && (tvafe_dbg_print & TVAFE_DBG_SMR)) {
                                cvd_pr_flag = true;
                                tvafe_pr_info("%s: sig unstable,nosig:%d,h-lock:%d,v-lock:%d.\n",
                                __func__, cvd2->hw.no_sig, cvd2->hw.h_lock,
                                cvd2->hw.v_lock);
                        }
+                       return;
                }
                /* wait for signal stable */
-               else if (++cvd2->info.state_cnt <= FMT_WAIT_CNT)
+               if (++cvd2->info.state_cnt <= FMT_WAIT_CNT)
                        return;
                force_fmt_flag = 0;
                cvd_pr_flag = false;
@@ -1592,13 +1587,13 @@ static void tvafe_cvd2_search_video_mode(struct tvafe_cvd2_s *cvd2,
                if (cvd2->manual_fmt) {
                        try_format_cnt = 0;
                        cvd2->info.state = TVAFE_CVD2_STATE_FIND;
-                       if (cvd_dbg_en)
+                       if (tvafe_dbg_print & TVAFE_DBG_SMR)
                                tvafe_pr_info("%s: manual fmt is:%s,do not need try other format!!!\n",
                                __func__, tvin_sig_fmt_str(cvd2->manual_fmt));
                        return;
                }
                /* auto mode */
-               if (cvd_dbg_en)
+               if (tvafe_dbg_print & TVAFE_DBG_SMR)
                        tvafe_pr_info("%s: switch to fmt:%s,hnon:%d,vnon:%d,c-lk:%d,pal:%d,secam:%d,h-lk:%d,v-lk:%d,fsc358:%d,fsc425:%d,fsc443:%d,secam detected %d,line625:%d\n",
                        __func__, tvin_sig_fmt_str(cvd2->config_fmt),
                        cvd2->hw.h_nonstd, cvd2->hw.v_nonstd,
@@ -1607,7 +1602,7 @@ static void tvafe_cvd2_search_video_mode(struct tvafe_cvd2_s *cvd2,
                        cvd2->hw.v_lock, cvd2->hw.fsc_358,
                        cvd2->hw.fsc_425, cvd2->hw.fsc_443,
                        cvd2->hw.secam_detected, cvd2->hw.line625);
-               if (cvd_dbg_en)
+               if (tvafe_dbg_print & TVAFE_DBG_SMR)
                        tvafe_pr_info("acc4xx_cnt = %d,acc425_cnt = %d,acc3xx_cnt = %d,acc358_cnt = %d secam_detected:%d\n",
                        cvd2->hw_data[cvd2->hw_data_cur].acc4xx_cnt,
                        cvd2->hw_data[cvd2->hw_data_cur].acc425_cnt,
@@ -1645,14 +1640,14 @@ static void tvafe_cvd2_search_video_mode(struct tvafe_cvd2_s *cvd2,
                                }
                        } else {
                                /* 525 lines */
-                               if (cvd_dbg_en)
+                               if (tvafe_dbg_print & TVAFE_DBG_SMR)
                                        tvafe_pr_info("%s dismatch pal_i line625 %d!!!and the  fsc358 %d,pal %d,fsc_443:%d",
                                        __func__, cvd2->hw.line625,
                                        cvd2->hw.fsc_358, cvd2->hw.pal,
                                        cvd2->hw.fsc_443);
                                tvafe_cvd2_try_format(cvd2, mem,
                                TVIN_SIG_FMT_CVBS_PAL_M);
-                               if (cvd_dbg_en)
+                               if (tvafe_dbg_print & TVAFE_DBG_SMR)
                                        tvafe_pr_info("%sdismatch pal_i and after try other format: line625 %d!!!and the  fsc358 %d,pal %d,fsc_443:%d",
                                        __func__, cvd2->hw.line625,
                                        cvd2->hw.fsc_358,
@@ -1675,7 +1670,7 @@ static void tvafe_cvd2_search_video_mode(struct tvafe_cvd2_s *cvd2,
                                tvafe_cvd2_try_format(cvd2, mem,
                                        TVIN_SIG_FMT_CVBS_NTSC_50);
                        else {
-                               if (cvd_dbg_en)
+                               if (tvafe_dbg_print & TVAFE_DBG_SMR)
                                        tvafe_pr_info("%s dismatch pal_cn line625 %d, fsc358 %d,pal %d",
                                        __func__, cvd2->hw.line625,
                                        cvd2->hw.fsc_358, cvd2->hw.pal);
@@ -1726,7 +1721,7 @@ static void tvafe_cvd2_search_video_mode(struct tvafe_cvd2_s *cvd2,
                                /*confirm SECAM */
                                cvd2->info.state = TVAFE_CVD2_STATE_FIND;
                        } else {
-                       if (cvd_dbg_en)
+                       if (tvafe_dbg_print & TVAFE_DBG_SMR)
                                tvafe_pr_info("%s dismatch secam line625 %d, secam_detected %d",
                                __func__, cvd2->hw.line625,
                                cvd2->hw.secam_detected);
@@ -1750,7 +1745,7 @@ static void tvafe_cvd2_search_video_mode(struct tvafe_cvd2_s *cvd2,
                                /* => confirm PAL_M */
                                cvd2->info.state = TVAFE_CVD2_STATE_FIND;
                        } else {
-                       if (cvd_dbg_en)
+                       if (tvafe_dbg_print & TVAFE_DBG_SMR)
                                tvafe_pr_info("%s dismatch pal m line625 %d, fsc358 %d,pal %d",
                                __func__, cvd2->hw.line625,
                                cvd2->hw.fsc_358, cvd2->hw.pal);
@@ -1782,7 +1777,7 @@ static void tvafe_cvd2_search_video_mode(struct tvafe_cvd2_s *cvd2,
                                /*confirm NTSC_M */
                                cvd2->info.state = TVAFE_CVD2_STATE_FIND;
                        } else {
-                               if (cvd_dbg_en)
+                               if (tvafe_dbg_print & TVAFE_DBG_SMR)
                                        tvafe_pr_info("%s dismatch ntsc m line625 %d, fsc358 %d,pal %d",
                                        __func__, cvd2->hw.line625,
                                        cvd2->hw.fsc_358, cvd2->hw.pal);
@@ -1798,7 +1793,7 @@ static void tvafe_cvd2_search_video_mode(struct tvafe_cvd2_s *cvd2,
                                cvd2->info.state = TVAFE_CVD2_STATE_FIND;
                        else{
                                /* set default to pal i */
-                               if (cvd_dbg_en)
+                               if (tvafe_dbg_print & TVAFE_DBG_SMR)
                                        tvafe_pr_info("%s dismatch pal 60 line625 %d, fsc443 %d,pal %d",
                                        __func__, cvd2->hw.line625,
                                        cvd2->hw.fsc_443, cvd2->hw.pal);
@@ -1815,7 +1810,7 @@ static void tvafe_cvd2_search_video_mode(struct tvafe_cvd2_s *cvd2,
                                TVAFE_CVD2_STATE_FIND;
                        else{
                                /* set default to pal i */
-                               if (cvd_dbg_en)
+                               if (tvafe_dbg_print & TVAFE_DBG_SMR)
                                        tvafe_pr_info("%s dismatch NTSC_443 line625 %d, fsc443 %d,pal %d",
                                        __func__, cvd2->hw.line625,
                                        cvd2->hw.fsc_443, cvd2->hw.pal);
@@ -1836,16 +1831,17 @@ static void tvafe_cvd2_search_video_mode(struct tvafe_cvd2_s *cvd2,
                default:
                        break;
                }
-               if (cvd_dbg_en)
+               if (tvafe_dbg_print & TVAFE_DBG_SMR)
                        tvafe_pr_info("%s: current fmt is:%s\n",
                        __func__, tvin_sig_fmt_str(cvd2->config_fmt));
        } else if (cvd2->info.state == TVAFE_CVD2_STATE_FIND) {
                /* manual mode => go directly to the manual format */
                try_format_cnt = 0;
                if (tvafe_cvd2_condition_shift(cvd2)) {
-                       shift_cnt = cvd2_shift_cnt;
                        if (cvd2->info.non_std_enable)
                                shift_cnt = cvd2_shift_cnt*10;
+                       else
+                               shift_cnt = cvd2_shift_cnt;
                        /* if no color burst,*/
                        /*pal flag can not be trusted */
                        if (cvd2->info.fmt_shift_cnt++ > shift_cnt) {
@@ -1855,6 +1851,10 @@ static void tvafe_cvd2_search_video_mode(struct tvafe_cvd2_s *cvd2,
                                cvd2->info.ntsc_switch_cnt = 0;
                                try_format_cnt = 0;
                                cvd_pr_flag = false;
+                               if (tvafe_dbg_print & TVAFE_DBG_SMR) {
+                                       tvafe_pr_info("%s: fmt_shift try_format\n",
+                                       __func__);
+                               }
                        }
                }
                /* non-standard signal config */
@@ -1866,11 +1866,16 @@ static void tvafe_cvd2_search_video_mode(struct tvafe_cvd2_s *cvd2,
 #ifdef TVAFE_CVD2_AUTO_DE_ENABLE
 static void tvafe_cvd2_auto_de(struct tvafe_cvd2_s *cvd2)
 {
+       struct tvafe_user_param_s *user_param = tvafe_get_user_param();
        struct tvafe_cvd2_lines_s *lines = &cvd2->info.vlines;
        unsigned int i = 0, l_ave = 0, l_max = 0, l_min = 0xff, tmp = 0;
 
+       if ((user_param->auto_adj_en & TVAFE_AUTO_DE) == 0)
+               return;
+
        if (!cvd2->hw.line625 || (cvd2->config_fmt != TVIN_SIG_FMT_CVBS_PAL_I))
                return;
+
        lines->val[0] = lines->val[1];
        lines->val[1] = lines->val[2];
        lines->val[2] = lines->val[3];
@@ -1884,7 +1889,7 @@ static void tvafe_cvd2_auto_de(struct tvafe_cvd2_s *cvd2)
        }
        if (lines->check_cnt++ == TVAFE_CVD2_AUTO_DE_CHECK_CNT) {
                lines->check_cnt = 0;
-               /* if (cvd_dbg_en) */
+               /* if (tvafe_dbg_print & TVAFE_DBG_SMR) */
        /* tvafe_pr_info("%s: check lines every 100*10ms\n", __func__); */
                l_ave = (l_ave - l_max - l_min + 1) >> 1;
                /* get the average value */
@@ -1901,7 +1906,7 @@ static void tvafe_cvd2_auto_de(struct tvafe_cvd2_s *cvd2)
                                        lines->de_offset);
                                W_APB_REG(ACD_REG_2E, tmp);
                                scene_colorful_old = 0;
-                               if (cvd_dbg_en)
+                               if (tvafe_dbg_print & TVAFE_DBG_SMR)
                                        tvafe_pr_info("%s: lrg vlines:%d, de_offset:%d tmp:%x\n",
                                __func__, l_ave, lines->de_offset, tmp);
                        }
@@ -1913,7 +1918,7 @@ static void tvafe_cvd2_auto_de(struct tvafe_cvd2_s *cvd2)
                                        lines->de_offset + 1);
                                W_APB_REG(ACD_REG_2E, tmp);
                                scene_colorful_old = 0;
-                               if (cvd_dbg_en)
+                               if (tvafe_dbg_print & TVAFE_DBG_SMR)
                                        tvafe_pr_info("%s: vlines:%d, de_offset:%d tmp:%x\n",
                                        __func__, l_ave, lines->de_offset, tmp);
                                lines->de_offset--;
@@ -1924,14 +1929,18 @@ static void tvafe_cvd2_auto_de(struct tvafe_cvd2_s *cvd2)
 /* vlis advice new add @20170329 */
 static void tvafe_cvd2_adj_vs(struct tvafe_cvd2_s *cvd2)
 {
+       struct tvafe_user_param_s *user_param = tvafe_get_user_param();
        struct tvafe_cvd2_lines_s *lines = &cvd2->info.vlines;
        unsigned int i = 0, l_ave = 0, l_max = 0, l_min = 0xff;
 
+       if ((user_param->auto_adj_en & TVAFE_AUTO_VS) == 0)
+               return;
+
        if (!cvd2->hw.line625 ||
                ((cvd2->config_fmt != TVIN_SIG_FMT_CVBS_PAL_I) &&
                (cvd2->config_fmt != TVIN_SIG_FMT_CVBS_NTSC_M)))
                return;
-       if (auto_de_en == 0) {
+       if ((user_param->auto_adj_en & TVAFE_AUTO_DE)  == 0) {
                lines->val[0] = lines->val[1];
                lines->val[1] = lines->val[2];
                lines->val[2] = lines->val[3];
@@ -1988,14 +1997,13 @@ void tvafe_cvd2_set_default_de(struct tvafe_cvd2_s *cvd2)
                return;
 #ifdef TVAFE_CVD2_AUTO_DE_ENABLE
        if (!cvd2) {
-
                tvafe_pr_info("%s error.\n", __func__);
                return;
        }
        /*write default de to register*/
        W_APB_REG(ACD_REG_2E,  (rf_acd_table[cvd2->config_fmt-
                                TVIN_SIG_FMT_CVBS_NTSC_M][0x2e]));
-       if (cvd_dbg_en)
+       if (tvafe_dbg_print & TVAFE_DBG_SMR)
                tvafe_pr_info("%s set default de %s.\n",
                                __func__, tvin_sig_fmt_str(cvd2->config_fmt));
        scene_colorful_old = 1;
@@ -2015,7 +2023,7 @@ static void tvafe_cvd2_reinit(struct tvafe_cvd2_s *cvd2)
                        (cvd2->config_fmt == TVIN_SIG_FMT_CVBS_PAL_I)) {
 
                tvafe_cvd2_set_cdto(CVD2_CHROMA_DTO_PAL_I);
-               if (cvd_dbg_en)
+               if (tvafe_dbg_print & TVAFE_DBG_SMR)
                        tvafe_pr_info("%s: set default cdto.\n", __func__);
 
        }
@@ -2027,23 +2035,24 @@ static void tvafe_cvd2_reinit(struct tvafe_cvd2_s *cvd2)
        /*pali to nosignal,restore default vstart-end after auto de*/
        if (cvd2->config_fmt == TVIN_SIG_FMT_CVBS_PAL_I) {
                W_APB_REG(ACD_REG_2E, 0x170137);
-               if (cvd_dbg_en)
+               if (tvafe_dbg_print & TVAFE_DBG_SMR)
                        pr_info("[tvafe..] %s: reset auto de.\n", __func__);
        }
        /* init variable */
        memset(&cvd2->info, 0, sizeof(struct tvafe_cvd2_info_s));
        cvd2->cvd2_init_en = true;
 
-       if (cvd_dbg_en)
+       if (tvafe_dbg_print & TVAFE_DBG_SMR)
                tvafe_pr_info("%s: reinit cvd2.\n", __func__);
 }
 
 /*
- * tvafe cvd2 signal status
+ * tvafe cvd2 signal status for smr
  */
 inline bool tvafe_cvd2_no_sig(struct tvafe_cvd2_s *cvd2,
                        struct tvafe_cvd2_mem_s *mem)
 {
+       struct tvafe_user_param_s *user_param = tvafe_get_user_param();
        static bool ret;
 
        tvafe_cvd2_get_signal_status(cvd2);
@@ -2054,27 +2063,24 @@ inline bool tvafe_cvd2_no_sig(struct tvafe_cvd2_s *cvd2,
 
        /* init if no signal input */
        if (cvd2->hw.no_sig) {
-
                ret = true;
                tvafe_cvd2_reinit(cvd2);
-
        } else {
                ret = false;
                cvd2->cvd2_init_en = false;
 #ifdef TVAFE_CVD2_AUTO_DE_ENABLE
-       if (((!scene_colorful) && auto_de_en) || auto_vs_en) {
-               if (auto_de_en)
+               if ((!scene_colorful) &&
+                       ((user_param->auto_adj_en & TVAFE_AUTO_DE) ||
+                       (user_param->auto_adj_en & TVAFE_AUTO_VS))) {
                        tvafe_cvd2_auto_de(cvd2);
-               if (auto_vs_en)
                        tvafe_cvd2_adj_vs(cvd2);
-       } else
-               tvafe_cvd2_set_default_de(cvd2);
+               } else
+                       tvafe_cvd2_set_default_de(cvd2);
 #endif
        }
        if (ret && try_format_cnt) {
-
                try_format_cnt = 0;
-               if (cvd_dbg_en)
+               if (tvafe_dbg_print & TVAFE_DBG_SMR)
                        tvafe_pr_info("%s: initialize try_format_cnt to zero.\n",
                                        __func__);
        }
@@ -2110,12 +2116,13 @@ inline enum tvin_sig_fmt_e tvafe_cvd2_get_format(
  */
 inline void tvafe_cvd2_adj_pga(struct tvafe_cvd2_s *cvd2)
 {
+       struct tvafe_user_param_s *user_param = tvafe_get_user_param();
        unsigned short dg_max = 0, dg_min = 0xffff, dg_ave = 0, i = 0, pga = 0;
        unsigned int tmp = 0;
        unsigned int step = 0;
        unsigned int delta_dg = 0;
 
-       if ((cvd_isr_en & 0x100) == 0)
+       if ((user_param->auto_adj_en & TVAFE_AUTO_PGA) == 0)
                return;
 
        cvd2->info.dgain[0] = cvd2->info.dgain[1];
@@ -2154,7 +2161,7 @@ inline void tvafe_cvd2_adj_pga(struct tvafe_cvd2_s *cvd2)
                        (pga >= (255+97))) {
                        return;
                }
-               if (cvd_dbg_en)
+               if (tvafe_dbg_print & TVAFE_DBG_ISR)
                        tvafe_pr_info("%s: dg_ave_last:0x%x dg_ave:0x%x. pga 0x%x.\n",
                        __func__, dg_ave_last, dg_ave, pga);
                dg_ave_last = dg_ave;
@@ -2186,12 +2193,12 @@ inline void tvafe_cvd2_adj_pga(struct tvafe_cvd2_s *cvd2)
                        pga = 2;
                if (pga != R_APB_BIT(TVFE_VAFE_CTRL1,
                        VAFE_PGA_GAIN_BIT, VAFE_PGA_GAIN_WID)){
-                       if (cvd_dbg_en)
+                       if (tvafe_dbg_print & TVAFE_DBG_ISR)
                                tvafe_pr_info("%s: set pag:0x%x. current dgain 0x%x.\n",
                                        __func__, pga, cvd2->info.dgain[3]);
                        W_APB_BIT(TVFE_VAFE_CTRL1, pga,
                        VAFE_PGA_GAIN_BIT, VAFE_PGA_GAIN_WID);
-                       if (cvd_dbg_en)
+                       if (tvafe_dbg_print & TVAFE_DBG_ISR)
                                tvafe_pr_info("%s: pga_step_last:0x%x step:0x%x.\n",
                                        __func__, pga_step_last, step);
                }
@@ -2231,21 +2238,23 @@ static void tvafe_cvd2_cdto_tune(unsigned int cur, unsigned int dest)
        W_APB_REG(CVD2_CHROMA_DTO_INCREMENT_7_0,   (cur >>  0) & 0x000000ff);
 
 }
+
 inline void tvafe_cvd2_adj_hs(struct tvafe_cvd2_s *cvd2,
                        unsigned int hcnt64)
 {
+       struct tvafe_user_param_s *user_param = tvafe_get_user_param();
        unsigned int hcnt64_max, hcnt64_min, temp, delta;
        unsigned int diff, hcnt64_ave, i;
        unsigned int hcnt64_standard = 0;
 
+       if ((user_param->auto_adj_en & TVAFE_AUTO_HS) == 0)
+               return;
+
        if (cvd2->config_fmt == TVIN_SIG_FMT_CVBS_PAL_I)
                hcnt64_standard = 0x31380;
        else if (cvd2->config_fmt == TVIN_SIG_FMT_CVBS_NTSC_M)
                hcnt64_standard = 0x30e0e;
 
-       if ((cvd_isr_en & 0x1000) == 0)
-               return;
-
        /* only for pal-i adjusment */
        if ((cvd2->config_fmt != TVIN_SIG_FMT_CVBS_PAL_I) &&
                (cvd2->config_fmt != TVIN_SIG_FMT_CVBS_NTSC_M))
@@ -2318,6 +2327,20 @@ inline void tvafe_cvd2_adj_hs(struct tvafe_cvd2_s *cvd2,
                                /*@20190530 vlsi adjust colorbar display*/
                                W_APB_REG(ACD_REG_66, 0x80000f10);
                                W_APB_REG(ACD_REG_64, 0xff00);
+
+                               cvd2->info.auto_hs_flag =
+                                       ((1 << CVD2_AUTO_HS_ADJ_EN) |
+                                       (1 << CVD2_AUTO_HS_ADJ_DIR) |
+                                       (temp));
+
+                               if (tvafe_dbg_print & TVAFE_DBG_ISR) {
+                                       tvafe_pr_info("%s: hs_adj_dir:%d, 0x2e:0x%x, 0x12d:0x%x, 0x128:0x%x\n",
+                                               __func__,
+                                               cvd2->info.hs_adj_dir,
+                                       R_APB_REG(CVD2_ACTIVE_VIDEO_HSTART),
+                                               R_APB_REG(ACD_REG_2D),
+                                               R_APB_REG(ACD_REG_28));
+                               }
                        } else {
                                /*0x128*/
                                temp = (acd_128_l1 - acd_128) *
@@ -2341,8 +2364,26 @@ inline void tvafe_cvd2_adj_hs(struct tvafe_cvd2_s *cvd2,
 
                                /*@20190530 vlsi adjust colorbar display*/
                                W_APB_REG(ACD_REG_66, 0x0);
+
+                               cvd2->info.auto_hs_flag =
+                                       ((1 << CVD2_AUTO_HS_ADJ_EN) |
+                                       (0 << CVD2_AUTO_HS_ADJ_DIR) |
+                                       (temp));
+
+                               if (tvafe_dbg_print & TVAFE_DBG_ISR) {
+                                       tvafe_pr_info("%s: hs_adj_dir:%d, 0x2e:0x%x, 0x12d:0x%x, 0x128:0x%x\n",
+                                               __func__,
+                                               cvd2->info.hs_adj_dir,
+                                       R_APB_REG(CVD2_ACTIVE_VIDEO_HSTART),
+                                               R_APB_REG(ACD_REG_2D),
+                                               R_APB_REG(ACD_REG_28));
+                               }
                        }
                } else {
+                       if (cvd2->info.auto_hs_flag &
+                               (1 << CVD2_AUTO_HS_DEFAULT))
+                               return;
+
                        if (R_APB_REG(CVD2_YC_SEPARATION_CONTROL) != 0x12)
                                W_APB_REG(CVD2_YC_SEPARATION_CONTROL, 0x12);
                        if (R_APB_REG(CVD2_H_LOOP_MAXSTATE) != 0xd)
@@ -2356,9 +2397,26 @@ inline void tvafe_cvd2_adj_hs(struct tvafe_cvd2_s *cvd2,
                        cvd2->info.hs_adj_en = 0;
                        cvd2->info.hs_adj_level = 0;
                        acd_h = acd_h_back;
+
+                       cvd2->info.auto_hs_flag = (1 << CVD2_AUTO_HS_DEFAULT);
+
+                       if (tvafe_dbg_print & TVAFE_DBG_ISR) {
+                               tvafe_pr_info("%s: recovery default setting\n",
+                                       __func__);
+                       }
                }
        } else {
+               if (cvd2->info.auto_hs_flag & (1 << CVD2_AUTO_HS_UNSTABLE))
+                       return;
+
                /*signal unstable,set default value*/
+               if (R_APB_REG(CVD2_YC_SEPARATION_CONTROL) != 0x12)
+                       W_APB_REG(CVD2_YC_SEPARATION_CONTROL, 0x12);
+               if (R_APB_REG(CVD2_H_LOOP_MAXSTATE) != 0xd)
+                       W_APB_REG(CVD2_H_LOOP_MAXSTATE, 0xd);
+               if (R_APB_REG(CVD2_REG_87) != 0x0)
+                       W_APB_REG(CVD2_REG_87, 0x0);
+
                W_APB_REG(ACD_REG_2D, acd_h_back);
                W_APB_BIT(CVD2_ACTIVE_VIDEO_HSTART, cvd_2e,
                                        HACTIVE_START_BIT, HACTIVE_START_WID);
@@ -2366,16 +2424,24 @@ inline void tvafe_cvd2_adj_hs(struct tvafe_cvd2_s *cvd2,
                cvd2->info.hs_adj_en = 0;
                cvd2->info.hs_adj_level = 0;
                acd_h = acd_h_back;
+
+               cvd2->info.auto_hs_flag = (1 << CVD2_AUTO_HS_UNSTABLE);
+
+               if (tvafe_dbg_print & TVAFE_DBG_ISR) {
+                       tvafe_pr_info("%s: signal unstable to default setting\n",
+                               __func__);
+               }
        }
 }
 
 inline void tvafe_cvd2_adj_hs_ntsc(struct tvafe_cvd2_s *cvd2,
                        unsigned int hcnt64)
 {
+       struct tvafe_user_param_s *user_param = tvafe_get_user_param();
        unsigned int hcnt64_max, hcnt64_min;
        unsigned int diff, hcnt64_ave, i, hcnt64_standard = 0x30e0e;
 
-       if ((cvd_isr_en & 0x1000) == 0)
+       if ((user_param->auto_adj_en & TVAFE_AUTO_HS) == 0)
                return;
 
        /* only for ntsc-m adjusment */
@@ -2432,13 +2498,13 @@ inline void tvafe_cvd2_adj_hs_ntsc(struct tvafe_cvd2_s *cvd2,
 inline void tvafe_cvd2_adj_cdto(struct tvafe_cvd2_s *cvd2,
                        unsigned int hcnt64)
 {
+       struct tvafe_user_param_s *user_param = tvafe_get_user_param();
        unsigned int hcnt64_max = 0, hcnt64_min = 0xffffffff,
                                hcnt64_ave = 0, i = 0;
        unsigned int cur_cdto = 0, diff = 0;
        u64 cal_cdto = 0;
 
-
-       if ((cvd_isr_en & 0x001) == 0)
+       if ((user_param->auto_adj_en & TVAFE_AUTO_CDTO) == 0)
                return;
 
        /* only for pal-i adjusment */
@@ -2486,7 +2552,7 @@ inline void tvafe_cvd2_adj_cdto(struct tvafe_cvd2_s *cvd2,
                }
                cvd2->info.non_std_worst = 1;
 
-               if (cvd_dbg_en)
+               if (tvafe_dbg_print & TVAFE_DBG_ISR)
                        tvafe_pr_info("%s: adj cdto from:0x%x to:0x%x\n",
                                        __func__, (u32)cur_cdto, (u32)cal_cdto);
                tvafe_cvd2_cdto_tune(cur_cdto, (unsigned int)cal_cdto);
@@ -2590,9 +2656,10 @@ static inline void tvafe_cvd2_sync_hight_tune(
  */
 inline void tvafe_cvd2_check_3d_comb(struct tvafe_cvd2_s *cvd2)
 {
+       struct tvafe_user_param_s *user_param = tvafe_get_user_param();
        unsigned int cvd2_3d_status = R_APB_REG(CVD2_REG_95);
 
-       if ((cvd_isr_en & 0x010) == 0)
+       if ((user_param->auto_adj_en & TVAFE_AUTO_3DCOMB) == 0)
                return;
 
 #ifdef SYNC_HEIGHT_AUTO_TUNING
@@ -2608,7 +2675,7 @@ inline void tvafe_cvd2_check_3d_comb(struct tvafe_cvd2_s *cvd2)
 
                W_APB_BIT(CVD2_REG_B2, 1, COMB2D_ONLY_BIT, COMB2D_ONLY_WID);
                W_APB_BIT(CVD2_REG_B2, 0, COMB2D_ONLY_BIT, COMB2D_ONLY_WID);
-               /* if (cvd_dbg_en) */
+               /* if (tvafe_dbg_print & TVAFE_DBG_ISR) */
                /* tvafe_pr_info("%s: reset 3d comb  sts:0x%x\n", */
                /*__func__, cvd2_3d_status); */
        }
index b664153..346a853 100644 (file)
@@ -117,6 +117,11 @@ struct tvafe_cvd2_lines_s {
 };
 #endif
 
+#define CVD2_AUTO_HS_DEFAULT    28
+#define CVD2_AUTO_HS_UNSTABLE   29
+#define CVD2_AUTO_HS_ADJ_DIR    30
+#define CVD2_AUTO_HS_ADJ_EN     31
+
 /* cvd2 signal information */
 struct tvafe_cvd2_info_s {
        enum tvafe_cvd2_state_e state;
@@ -133,7 +138,13 @@ struct tvafe_cvd2_info_s {
 #endif
        unsigned int comb_check_cnt;
        unsigned int fmt_shift_cnt;
+       unsigned short nonstd_cnt;
+       unsigned short nonstd_stable_cnt;
+       unsigned short nonstd_print_cnt;
+       bool nonstd_flag;
+       bool nonstd_flag_adv;
        bool non_std_enable;
+       bool non_std_enable_tmp;
        bool non_std_config;
        bool non_std_worst;
        bool adc_reload_en;
@@ -141,11 +152,15 @@ struct tvafe_cvd2_info_s {
        bool vs_adj_en;
        /*0:+;1:-*/
        bool hs_adj_dir;
+       unsigned int auto_hs_flag;
 
 #ifdef TVAFE_CVD2_AUTO_DE_ENABLE
        struct tvafe_cvd2_lines_s vlines;
 #endif
        unsigned int ntsc_switch_cnt;
+
+       unsigned int smr_cnt;
+       unsigned int isr_cnt;
 };
 
 /* CVD2 status list */
@@ -201,10 +216,10 @@ extern void tvafe_snow_config_clamp(unsigned int onoff);
 extern void tvafe_snow_config_acd(void);
 extern void tvafe_snow_config_acd_resume(void);
 extern enum tvin_aspect_ratio_e tvafe_cvd2_get_wss(void);
-extern void tvafe_cvd2_get_signal_status(struct tvafe_cvd2_s *cvd2);
 extern void cvd_vbi_mem_set(unsigned int offset, unsigned int size);
 extern void cvd_vbi_config(void);
 extern void tvafe_cvd2_rf_ntsc50_en(bool v);
+extern void tvafe_cvd2_non_std_config(struct tvafe_cvd2_s *cvd2);
 
 extern bool tvafe_snow_function_flag;
 
index b210e01..94f920e 100644 (file)
@@ -44,6 +44,9 @@ static void tvafe_state(struct tvafe_dev_s *devp)
        struct tvafe_cvd2_info_s *cvd2_info = &cvd2->info;
        struct tvafe_cvd2_lines_s *vlines = &cvd2_info->vlines;
        struct tvafe_cvd2_hw_data_s *hw = &cvd2->hw;
+       struct tvafe_user_param_s *user_param = tvafe_get_user_param();
+       int i;
+
        /* top dev info */
        tvafe_pr_info("\n!!tvafe_dev_s info:\n");
        tvafe_pr_info("size of tvafe_dev_s:%d\n", devp->sizeof_tvafe_dev_s);
@@ -113,6 +116,8 @@ static void tvafe_state(struct tvafe_dev_s *devp)
                cvd2_info->vs_adj_level);
        tvafe_pr_info("tvafe_cvd2_info_s->vs_adj_en:%d\n",
                cvd2_info->vs_adj_en);
+       tvafe_pr_info("tvafe_cvd2_info_s->auto_hs_flag:0x%08x\n",
+               cvd2_info->auto_hs_flag);
 #ifdef TVAFE_SET_CVBS_CDTO_EN
        tvafe_pr_info("tvafe_cvd2_info_s->hcnt64[0]:0x%x\n",
                cvd2_info->hcnt64[0]);
@@ -123,6 +128,11 @@ static void tvafe_state(struct tvafe_dev_s *devp)
        tvafe_pr_info("tvafe_cvd2_info_s->hcnt64[3]:0x%x\n",
                cvd2_info->hcnt64[3]);
 #endif
+       tvafe_pr_info("tvafe_cvd2_info_s->smr_cnt:%d\n",
+               cvd2_info->smr_cnt);
+       tvafe_pr_info("tvafe_cvd2_info_s->isr_cnt:%d\n",
+               cvd2_info->isr_cnt);
+
        /* tvafe_cvd2_info_s->tvafe_cvd2_lines_s struct info */
        tvafe_pr_info("\n!!tvafe_cvd2_info_s->tvafe_cvd2_lines_s struct info:\n");
        tvafe_pr_info("tvafe_cvd2_lines_s->check_cnt:0x%x\n",
@@ -174,6 +184,22 @@ static void tvafe_state(struct tvafe_dev_s *devp)
        tvafe_pr_info("tvafe_cvd2_hw_data_s->fsc_358:%d\n", hw->fsc_358);
        tvafe_pr_info("tvafe_cvd2_hw_data_s->fsc_425:%d\n", hw->fsc_425);
        tvafe_pr_info("tvafe_cvd2_hw_data_s->fsc_443:%d\n", hw->fsc_443);
+       for (i = 0; i < 5; i++) {
+               tvafe_pr_info("cutwindow_val_h[%d]:%d\n",
+                       i, user_param->cutwindow_val_h[i]);
+       }
+       for (i = 0; i < 5; i++) {
+               tvafe_pr_info("cutwindow_val_v[%d]:%d\n",
+                       i, user_param->cutwindow_val_v[i]);
+       }
+       tvafe_pr_info("cutwindow_val_vs_ve:%d\n",
+               user_param->cutwindow_val_vs_ve);
+       tvafe_pr_info("auto_adj_en:%d\n", user_param->auto_adj_en);
+       tvafe_pr_info("nostd_vs_th:0x%x\n", user_param->nostd_vs_th);
+       tvafe_pr_info("force_vs_th_flag:0x%x\n", user_param->force_vs_th_flag);
+       tvafe_pr_info("nostd_stable_cnt:0x%x\n", user_param->nostd_stable_cnt);
+       tvafe_pr_info("skip_vf_num:0x%x\n", user_param->skip_vf_num);
+       tvafe_pr_info("tvafe version :  %s\n", TVAFE_VER);
 }
 
 static void tvafe_parse_param(char *buf_orig, char **parm)
@@ -201,6 +227,7 @@ static ssize_t tvafe_store(struct device *dev,
 {
        unsigned char fmt_index = 0;
        struct tvafe_dev_s *devp;
+       struct tvafe_user_param_s *user_param = tvafe_get_user_param();
        char *buf_orig, *parm[47] = {NULL};
        unsigned int val;
 
@@ -254,6 +281,8 @@ static ssize_t tvafe_store(struct device *dev,
        } else if (!strncmp(buff, "afe_ver", strlen("afe_ver"))) {
                tvafe_pr_info("tvafe version :  %s\n", TVAFE_VER);
        } else if (!strncmp(buff, "snowcfg", strlen("snowcfg"))) {
+               if (!parm[1])
+                       goto tvafe_store_err;
                if (kstrtouint(parm[1], 10, &val) < 0)
                        goto tvafe_store_err;
                if (val) {
@@ -264,6 +293,8 @@ static ssize_t tvafe_store(struct device *dev,
                        tvafe_pr_info("[tvafe..]hadware snow cfg dis\n");
                }
        } else if (!strncmp(buff, "snowon", strlen("snowon"))) {
+               if (!parm[1])
+                       goto tvafe_store_err;
                if (kstrtouint(parm[1], 10, &val) < 0)
                        goto tvafe_store_err;
                if (val) {
@@ -279,15 +310,19 @@ static ssize_t tvafe_store(struct device *dev,
                        tvafe_pr_info("%s:tvafe snowoff\n", __func__);
                }
        } else if (!strcmp(parm[0], "frame_skip_enable")) {
-               if (kstrtouint(parm[1], 10, &val) < 0)
-                       goto tvafe_store_err;
-               devp->frame_skip_enable = val;
+               if (parm[1]) {
+                       if (kstrtouint(parm[1], 10, &val) < 0)
+                               goto tvafe_store_err;
+                       devp->frame_skip_enable = val;
+               }
                tvafe_pr_info("frame_skip_enable:%d\n",
                        devp->frame_skip_enable);
        } else if (!strncmp(buff, "state", strlen("state"))) {
                tvafe_state(devp);
        } else if (!strncmp(buff, "nonstd_detect_dis",
                strlen("nonstd_detect_dis"))) {
+               if (!parm[1])
+                       goto tvafe_store_err;
                /*patch for Very low probability hanging issue on atv close*/
                /*only appeared in one project,this for reserved debug*/
                /*default setting to disable the nonstandard signal detect*/
@@ -303,6 +338,8 @@ static ssize_t tvafe_store(struct device *dev,
                                __func__);
                }
        } else if (!strncmp(buff, "rf_ntsc50_en", strlen("rf_ntsc50_en"))) {
+               if (!parm[1])
+                       goto tvafe_store_err;
                if (kstrtouint(parm[1], 10, &val) < 0)
                        goto tvafe_store_err;
                if (val) {
@@ -315,10 +352,59 @@ static ssize_t tvafe_store(struct device *dev,
                                __func__);
                }
        } else if (!strncmp(buff, "force_nostd", strlen("force_nostd"))) {
-               if (kstrtouint(parm[1], 10, &force_nostd) < 0)
-                       goto tvafe_store_err;
-               pr_info("[tvafe..]%s: set force_nostd = %d\n",
+               if (parm[1]) {
+                       if (kstrtouint(parm[1], 10, &force_nostd) < 0)
+                               goto tvafe_store_err;
+               }
+               pr_info("[tvafe..]%s: force_nostd = %d\n",
                        __func__, force_nostd);
+       } else if (!strncmp(buff, "force_vs_th", strlen("force_vs_th"))) {
+               if (parm[1]) {
+                       if (kstrtouint(parm[1], 10,
+                               &user_param->force_vs_th_flag) < 0)
+                               goto tvafe_store_err;
+               }
+               pr_info("[tvafe..]%s: force_vs_th_flag = 0x%x\n",
+                       __func__, user_param->force_vs_th_flag);
+       } else if (!strncmp(buff, "nostd_vs_th", strlen("nostd_vs_th"))) {
+               if (parm[1]) {
+                       if (kstrtouint(parm[1], 16,
+                               &user_param->nostd_vs_th) < 0)
+                               goto tvafe_store_err;
+               }
+               pr_info("[tvafe..]%s: nostd_vs_th = 0x%x\n",
+                       __func__, user_param->nostd_vs_th);
+       } else if (!strncmp(buff, "nostd_cnt", strlen("nostd_cnt"))) {
+               if (parm[1]) {
+                       if (kstrtouint(parm[1], 10,
+                               &user_param->nostd_stable_cnt) < 0)
+                               goto tvafe_store_err;
+               }
+               pr_info("[tvafe..]%s: nostd_stable_cnt = 0x%x\n",
+                       __func__, user_param->nostd_stable_cnt);
+       } else if (!strncmp(buff, "auto_adj", strlen("auto_adj"))) {
+               if (parm[1]) {
+                       if (kstrtouint(parm[1], 16,
+                               &user_param->auto_adj_en) < 0)
+                               goto tvafe_store_err;
+               }
+               pr_info("[tvafe..]%s: auto_adj_en = 0x%x\n",
+                       __func__, user_param->auto_adj_en);
+       } else if (!strncmp(buff, "skip_vf_num", strlen("skip_vf_num"))) {
+               if (parm[1]) {
+                       if (kstrtouint(parm[1], 10,
+                               &user_param->skip_vf_num) < 0)
+                               goto tvafe_store_err;
+               }
+               pr_info("[tvafe..]%s: skip_vf_num = %d\n",
+                       __func__, user_param->skip_vf_num);
+       } else if (!strncmp(buff, "dbg_print", strlen("dbg_print"))) {
+               if (parm[1]) {
+                       if (kstrtouint(parm[1], 16, &tvafe_dbg_print) < 0)
+                               goto tvafe_store_err;
+               }
+               pr_info("[tvafe..]%s: tvafe_dbg_print = 0x%x\n",
+                       __func__, tvafe_dbg_print);
        } else
                tvafe_pr_info("[%s]:invaild command.\n", __func__);
        kfree(buf_orig);
@@ -329,30 +415,45 @@ tvafe_store_err:
        return -EINVAL;
 }
 
+static const char *tvafe_debug_usage_str = {
+"Usage:\n"
+"    echo cvdfmt ntsc/ntsc443/pali/palm/palcn/pal60/secam/null > /sys/class/tvafe/tvafe0/debug;conifg manual fmt\n"
+"\n"
+"    echo disableapi val(d) > /sys/class/tvafe/tvafe0/debug;enable/ignore api cmd\n"
+"\n"
+"    echo force_stable val(d) > /sys/class/tvafe/tvafe0/debug;force stable or not force\n"
+"\n"
+"    echo tvafe_enable val(d) > /sys/class/tvafe/tvafe0/debug;tvafe enable/disable\n"
+"\n"
+"    echo afe_ver > /sys/class/tvafe/tvafe0/debug;show tvafe version\n"
+"\n"
+"    echo snow val(d) > /sys/class/tvafe/tvafe0/debug;snow on/off\n"
+"\n"
+"    echo frame_skip_enable val(d) > /sys/class/tvafe/tvafe0/debug;frame skip enable/disable\n"
+"\n"
+"    echo state > /sys/class/tvafe/tvafe0/debug;show tvafe status\n"
+"\n"
+"    echo force_nostd val(d) > /sys/class/tvafe/tvafe0/debug;set force_nostd policy\n"
+"\n"
+"    echo nostd_vs_th val(h) > /sys/class/tvafe/tvafe0/debug;set nostd_vs_th\n"
+"\n"
+"    echo force_vs_th val(h) > /sys/class/tvafe/tvafe0/debug;set force_vs_th flag\n"
+"\n"
+"    echo nostd_cnt val(d) > /sys/class/tvafe/tvafe0/debug;set nostd_stable_cnt\n"
+"\n"
+"    echo skip_vf_num val(d) > /sys/class/tvafe/tvafe0/debug;set skip_vf_num for vdin\n"
+"\n"
+"    echo dbg_print val(h) > /sys/class/tvafe/tvafe0/debug;enable debug print\n"
+"    bit[0]: normal debug info\n"
+"    bit[4]: vsync isr debug info\n"
+"    bit[8]: smr debug info\n"
+"    bit[12]: nostd debug info\n"
+};
+
 static ssize_t tvafe_show(struct device *dev,
                struct device_attribute *attr, char *buf)
 {
-       ssize_t len = 0;
-
-       len += sprintf(buf+len,
-               "echo cvdfmt ntsc/ntsc443/pali/palm/palcn/pal60/secam/null > /sys/class/tvafe/tvafe0/debug;conifg manual fmt\n");
-       len += sprintf(buf+len,
-               "echo disableapi val(d) > /sys/class/tvafe/tvafe0/debug;enable/ignore api cmd\n");
-       len += sprintf(buf+len,
-               "echo force_stable val(d) > /sys/class/tvafe/tvafe0/debug;force stable or not force\n");
-       len += sprintf(buf+len,
-               "echo tvafe_enable val(d) > /sys/class/tvafe/tvafe0/debug;tvafe enable/disable\n");
-       len += sprintf(buf+len,
-               "echo afe_ver > /sys/class/tvafe/tvafe0/debug;show tvafe version\n");
-       len += sprintf(buf+len,
-               "echo snow val(d) > /sys/class/tvafe/tvafe0/debug;snow on/off\n");
-       len += sprintf(buf+len,
-               "echo frame_skip_enable val(d) > /sys/class/tvafe/tvafe0/debug;frame skip enable/disable\n");
-       len += sprintf(buf+len,
-               "echo state > /sys/class/tvafe/tvafe0/debug;show tvafe status\n");
-       len += sprintf(buf+len,
-               "echo force_nostd val(d) > /sys/class/tvafe/tvafe0/debug;set force_nostd policy\n");
-       return len;
+       return sprintf(buf, "%s\n", tvafe_debug_usage_str);
 }
 
 static DEVICE_ATTR(debug, 0644, tvafe_show, tvafe_store);
@@ -631,6 +732,7 @@ static ssize_t tvafe_cutwindow_show(struct device *dev,
 static ssize_t tvafe_cutwindow_store(struct device *dev,
                struct device_attribute *attr, const char *buff, size_t count)
 {
+       struct tvafe_user_param_s *user_param = tvafe_get_user_param();
        char *buf_orig, *parm[20] = {NULL};
        unsigned int index, val;
        char *pr_buf;
@@ -647,7 +749,7 @@ static ssize_t tvafe_cutwindow_store(struct device *dev,
                if (index < 5) {
                        if (kstrtouint(parm[2], 10, &val) < 0)
                                goto tvafe_cutwindow_store_err;
-                       cutwindow_val_h[index] = val;
+                       user_param->cutwindow_val_h[index] = val;
                        pr_info("set cutwindow_h[%d] = %d\n", index, val);
                } else {
                        pr_info("error: invalid index %d\n", index);
@@ -658,7 +760,7 @@ static ssize_t tvafe_cutwindow_store(struct device *dev,
                if (index < 5) {
                        if (kstrtouint(parm[2], 10, &val) < 0)
                                goto tvafe_cutwindow_store_err;
-                       cutwindow_val_v[index] = val;
+                       user_param->cutwindow_val_v[index] = val;
                        pr_info("set cutwindow_v[%d] = %d\n", index, val);
                } else {
                        pr_info("error: invalid index %d\n", index);
@@ -673,12 +775,12 @@ static ssize_t tvafe_cutwindow_store(struct device *dev,
                pr_len += sprintf(pr_buf+pr_len, "cutwindow_h:");
                for (index = 0; index < 5; index++) {
                        pr_len += sprintf(pr_buf+pr_len,
-                                       " %d", cutwindow_val_h[index]);
+                               " %d", user_param->cutwindow_val_h[index]);
                }
                pr_len += sprintf(pr_buf+pr_len, "\ncutwindow_v:");
                for (index = 0; index < 5; index++) {
                        pr_len += sprintf(pr_buf+pr_len,
-                                       " %d", cutwindow_val_v[index]);
+                               " %d", user_param->cutwindow_val_v[index]);
                }
                pr_info("%s\n", pr_buf);
                kfree(pr_buf);
index 7da6f83..62b9e58 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/amlogic/media/frame_provider/tvin/tvin.h>
 #include "../tvin_global.h"
 #include "../tvin_format_table.h"
+#include "tvafe.h"
 #include "tvafe_regs.h"
 #include "tvafe_cvd.h"
 #include "tvafe_debug.h"
@@ -326,7 +327,7 @@ void tvafe_set_regmap(struct am_regs_s *p)
 for (i = 0; i < p->length; i++) {
        switch (p->am_reg[i].type) {
        case REG_TYPE_PHY:
-               if (tvafe_dbg_enable)
+               if (tvafe_dbg_print & TVAFE_DBG_NORMAL)
                        tvafe_pr_info("%s: bus type: phy..\n", __func__);
                break;
        case REG_TYPE_CBUS:
@@ -337,7 +338,7 @@ for (i = 0; i < p->length; i++) {
                        (aml_read_cbus(p->am_reg[i].addr) &
                        (~(p->am_reg[i].mask))) |
                        (p->am_reg[i].val & p->am_reg[i].mask));
-               if (tvafe_dbg_enable)
+               if (tvafe_dbg_print & TVAFE_DBG_NORMAL)
                        tvafe_pr_info("%s: cbus: Reg0x%x(%u)=0x%x(%u)val=%x(%u)mask=%x(%u)\n",
                                __func__, p->am_reg[i].addr, p->am_reg[i].addr,
                                (p->am_reg[i].val & p->am_reg[i].mask),
@@ -353,7 +354,7 @@ for (i = 0; i < p->length; i++) {
                        (R_APB_REG(p->am_reg[i].addr<<2) &
                        (~(p->am_reg[i].mask))) |
                        (p->am_reg[i].val & p->am_reg[i].mask));
-               if (tvafe_dbg_enable)
+               if (tvafe_dbg_print & TVAFE_DBG_NORMAL)
                        tvafe_pr_info("%s: apb: Reg0x%x(%u)=0x%x(%u)val=%x(%u)mask=%x(%u)\n",
                                __func__, p->am_reg[i].addr, p->am_reg[i].addr,
                                (p->am_reg[i].val & p->am_reg[i].mask),
@@ -362,7 +363,7 @@ for (i = 0; i < p->length; i++) {
                                p->am_reg[i].mask, p->am_reg[i].mask);
                break;
        default:
-               if (tvafe_dbg_enable)
+               if (tvafe_dbg_print & TVAFE_DBG_NORMAL)
                        tvafe_pr_info("%s: bus type error!!!bustype = 0x%x................\n",
                                __func__, p->am_reg[i].type);
                break;
@@ -619,8 +620,8 @@ int adc_set_pll_cntl(bool on, unsigned int module_sel, void *pDtvPara)
                mutex_lock(&pll_mutex);
                adc_pll_chg &= ~module_sel;
                mutex_unlock(&pll_mutex);
-               if (tvafe_dbg_enable)
-                       tvafe_pr_info("\n%s: init flag on:%d,module:0x%x,flag:0x%x\n",
+               if (tvafe_dbg_print & TVAFE_DBG_NORMAL)
+                       tvafe_pr_info("%s: init flag on:%d,module:0x%x,flag:0x%x\n",
                                __func__, on, module_sel, adc_pll_chg);
                return ret;
        }
@@ -689,8 +690,8 @@ int adc_set_pll_cntl(bool on, unsigned int module_sel, void *pDtvPara)
                mutex_unlock(&pll_mutex);
                if (adc_pll_lock_cnt == 10)
                        tvafe_pr_info("%s: adc pll lock fail!!!\n", __func__);
-               if (tvafe_dbg_enable)
-                       tvafe_pr_info("\n%s: on:%d,module:0x%x,flag:0x%x...\n",
+               if (tvafe_dbg_print & TVAFE_DBG_NORMAL)
+                       tvafe_pr_info("%s: on:%d,module:0x%x,flag:0x%x...\n",
                                __func__, on, module_sel, adc_pll_chg);
                break;
        case ADC_EN_TVAFE: /* tvafe */
@@ -779,8 +780,8 @@ int adc_set_pll_cntl(bool on, unsigned int module_sel, void *pDtvPara)
                mutex_unlock(&pll_mutex);
                if (adc_pll_lock_cnt == 10)
                        tvafe_pr_info("%s: adc pll lock fail!!!\n", __func__);
-               if (tvafe_dbg_enable)
-                       tvafe_pr_info("\n%s: on:%d,module:0x%x,flag:0x%x...\n",
+               if (tvafe_dbg_print & TVAFE_DBG_NORMAL)
+                       tvafe_pr_info("%s: on:%d,module:0x%x,flag:0x%x...\n",
                                __func__, on, module_sel, adc_pll_chg);
 
                break;
@@ -855,8 +856,8 @@ int adc_set_pll_cntl(bool on, unsigned int module_sel, void *pDtvPara)
                mutex_unlock(&pll_mutex);
                if (adc_pll_lock_cnt >= 10)
                        tvafe_pr_info("%s: adc pll lock fail!!!\n", __func__);
-               if (tvafe_dbg_enable)
-                       tvafe_pr_info("\n%s: on:%d,module:0x%x,flag:0x%x...\n",
+               if (tvafe_dbg_print & TVAFE_DBG_NORMAL)
+                       tvafe_pr_info("%s: on:%d,module:0x%x,flag:0x%x...\n",
                                __func__, on, module_sel, adc_pll_chg);
                break;
        case ADC_EN_DTV_DEMODPLL: /* dtv demod */
@@ -937,7 +938,7 @@ int adc_set_pll_cntl(bool on, unsigned int module_sel, void *pDtvPara)
                mutex_unlock(&pll_mutex);
                if (adc_pll_lock_cnt == 10)
                        tvafe_pr_info("%s: adc pll lock fail!!!\n", __func__);
-               if (tvafe_dbg_enable)
+               if (tvafe_dbg_print & TVAFE_DBG_NORMAL)
                        tvafe_pr_info("\n%s: on:%d,module:0x%x,flag:0x%x...\n",
                                __func__, on, module_sel, adc_pll_chg);
                break;
index 0e978f0..f2067aa 100644 (file)
@@ -195,7 +195,6 @@ extern int tvafe_cpu_type(void);
 extern void tvafe_clk_gate_ctrl(int status);
 
 extern struct mutex pll_mutex;
-extern bool tvafe_dbg_enable;
 
 #endif  /* _TVAFE_GENERAL_H */