From 24eba4ca64c0636ffea83af7a998f45ef5be76ba Mon Sep 17 00:00:00 2001 From: "zhiwei.yuan" Date: Wed, 23 Oct 2019 19:46:33 +0800 Subject: [PATCH] tvafe: garbage was seen when switch PAL to NTSC by sinco DVD [1/1] PD#SWPL-15686 Problem: report unstable state is too late,so that black screen is deferred. Solution: reduce shift condition cnt Verify: verified by t962x2_x301 Change-Id: Iafc38998b4d451ec3f4ddfd14c72ed54a68efbe5 Signed-off-by: zhiwei.yuan --- drivers/amlogic/media/vin/tvin/tvafe/tvafe.h | 2 + drivers/amlogic/media/vin/tvin/tvafe/tvafe_cvd.c | 44 ++++++++++++++++------ drivers/amlogic/media/vin/tvin/tvafe/tvafe_cvd.h | 5 +++ drivers/amlogic/media/vin/tvin/tvafe/tvafe_debug.c | 28 ++++++++++++++ 4 files changed, 68 insertions(+), 11 deletions(-) diff --git a/drivers/amlogic/media/vin/tvin/tvafe/tvafe.h b/drivers/amlogic/media/vin/tvin/tvafe/tvafe.h index 452f687..89d2411 100644 --- a/drivers/amlogic/media/vin/tvin/tvafe/tvafe.h +++ b/drivers/amlogic/media/vin/tvin/tvafe/tvafe.h @@ -140,6 +140,8 @@ extern int tvafe_hiu_reg_write(unsigned int reg, unsigned int val); extern int tvafe_device_create_file(struct device *dev); extern void tvafe_remove_device_files(struct device *dev); int tvafe_pq_config_probe(struct meson_tvafe_data *tvafe_data); +void cvd_set_shift_cnt(enum tvafe_cvd2_shift_cnt_e src, unsigned int val); +unsigned int cvd_get_shift_cnt(enum tvafe_cvd2_shift_cnt_e src); extern bool disableapi; extern bool force_stable; diff --git a/drivers/amlogic/media/vin/tvin/tvafe/tvafe_cvd.c b/drivers/amlogic/media/vin/tvin/tvafe/tvafe_cvd.c index d206500..b825832 100644 --- a/drivers/amlogic/media/vin/tvin/tvafe/tvafe_cvd.c +++ b/drivers/amlogic/media/vin/tvin/tvafe/tvafe_cvd.c @@ -36,9 +36,6 @@ #include "../vdin/vdin_ctl.h" /***************************Local defines**********************************/ -#define TVAFE_CVD2_SHIFT_CNT 6 -/* cnt*10ms,delay for fmt shift counter */ - #define TVAFE_CVD2_NONSTD_DGAIN_MAX 0x500 /* CVD max digital gain for non-std signal */ #define TVAFE_CVD2_NONSTD_CNT_MAX 0x0A @@ -121,9 +118,9 @@ static int cdto_adj_step = TVAFE_CVD2_CDTO_ADJ_STEP; module_param(cdto_adj_step, int, 0664); MODULE_PARM_DESC(cdto_adj_step, "cvd2_adj_step"); -static int cvd2_shift_cnt = TVAFE_CVD2_SHIFT_CNT; -module_param(cvd2_shift_cnt, int, 0664); -MODULE_PARM_DESC(cvd2_shift_cnt, "cvd2_shift_cnt"); +/* cnt*10ms,delay for fmt shift counter */ +static unsigned int cvd2_shift_cnt_atv = 6; +static unsigned int cvd2_shift_cnt_av = 2; /*force the fmt for chrome off,for example ntsc pal_i 12*/ static unsigned int config_force_fmt; @@ -212,6 +209,29 @@ static unsigned int noise3; unsigned int vbi_mem_start; +void cvd_set_shift_cnt(enum tvafe_cvd2_shift_cnt_e src, unsigned int val) +{ + if (src == TVAFE_CVD2_SHIFT_CNT_ATV) + cvd2_shift_cnt_atv = val; + else if (src == TVAFE_CVD2_SHIFT_CNT_AV) + cvd2_shift_cnt_av = val; + else + pr_err("[%s]wrong src para.\n", __func__); +} + +unsigned int cvd_get_shift_cnt(enum tvafe_cvd2_shift_cnt_e src) +{ + unsigned int shift_cnt = 0; + + if (src == TVAFE_CVD2_SHIFT_CNT_ATV) + shift_cnt = cvd2_shift_cnt_atv; + else if (src == TVAFE_CVD2_SHIFT_CNT_AV) + shift_cnt = cvd2_shift_cnt_av; + else + pr_err("[%s]wrong src para.\n", __func__); + + return shift_cnt; +} void cvd_vbi_mem_set(unsigned int offset, unsigned int size) { @@ -1549,10 +1569,13 @@ static void tvafe_cvd2_search_video_mode(struct tvafe_cvd2_s *cvd2, unsigned int try_format_max; if ((cvd2->vd_port == TVIN_PORT_CVBS3) || - (cvd2->vd_port == TVIN_PORT_CVBS0)) + (cvd2->vd_port == TVIN_PORT_CVBS0)) { try_format_max = try_fmt_max_atv; - else + shift_cnt = cvd2_shift_cnt_atv; + } else { try_format_max = try_fmt_max_av; + shift_cnt = cvd2_shift_cnt_av; + } /* execute manual mode */ if ((cvd2->manual_fmt) && (cvd2->config_fmt != cvd2->manual_fmt) && @@ -1837,9 +1860,8 @@ static void tvafe_cvd2_search_video_mode(struct tvafe_cvd2_s *cvd2, try_format_cnt = 0; if (tvafe_cvd2_condition_shift(cvd2)) { if (cvd2->info.non_std_enable) - shift_cnt = cvd2_shift_cnt*10; - else - shift_cnt = cvd2_shift_cnt; + shift_cnt *= 10; + /* if no color burst,*/ /*pal flag can not be trusted */ if (cvd2->info.fmt_shift_cnt++ > shift_cnt) { diff --git a/drivers/amlogic/media/vin/tvin/tvafe/tvafe_cvd.h b/drivers/amlogic/media/vin/tvin/tvafe/tvafe_cvd.h index ce89bd5..2ccd992 100644 --- a/drivers/amlogic/media/vin/tvin/tvafe/tvafe_cvd.h +++ b/drivers/amlogic/media/vin/tvin/tvafe/tvafe_cvd.h @@ -68,6 +68,11 @@ enum tvafe_cvd2_state_e { TVAFE_CVD2_STATE_FIND, }; +enum tvafe_cvd2_shift_cnt_e { + TVAFE_CVD2_SHIFT_CNT_ATV = 0, + TVAFE_CVD2_SHIFT_CNT_AV, +}; + /* ****************************************** */ /* *** structure definitions *********** */ /***************************************************** */ diff --git a/drivers/amlogic/media/vin/tvin/tvafe/tvafe_debug.c b/drivers/amlogic/media/vin/tvin/tvafe/tvafe_debug.c index f963af9..27ccbe8 100644 --- a/drivers/amlogic/media/vin/tvin/tvafe/tvafe_debug.c +++ b/drivers/amlogic/media/vin/tvin/tvafe/tvafe_debug.c @@ -484,6 +484,34 @@ static ssize_t tvafe_store(struct device *dev, } pr_info("[tvafe..]%s: tvafe_dbg_print = 0x%x\n", __func__, tvafe_dbg_print); + } else if (!strcmp(parm[0], "shift_cnt_av")) { + if (parm[1]) { + if (kstrtouint(parm[1], 10, &val) < 0) { + pr_info("str->uint error.\n"); + goto tvafe_store_err; + } else { + cvd_set_shift_cnt(TVAFE_CVD2_SHIFT_CNT_AV, + val); + pr_info("[tvafe]%s: av shift cnt = %d\n", + __func__, val); + } + } else + pr_info("[shift_cnt_av]miss parameter,ori val = %d\n", + cvd_get_shift_cnt(TVAFE_CVD2_SHIFT_CNT_AV)); + } else if (!strcmp(parm[0], "shift_cnt_atv")) { + if (parm[1]) { + if (kstrtouint(parm[1], 10, &val) < 0) { + pr_info("str->uint error.\n"); + goto tvafe_store_err; + } else { + cvd_set_shift_cnt(TVAFE_CVD2_SHIFT_CNT_ATV, + val); + pr_info("[tvafe]%s: atv shift cnt = %d\n", + __func__, val); + } + } else + pr_info("[shift_cnt_atv]miss parameter,ori val = %d\n", + cvd_get_shift_cnt(TVAFE_CVD2_SHIFT_CNT_ATV)); } else tvafe_pr_info("[%s]:invaild command.\n", __func__); kfree(buf_orig); -- 2.7.4