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;*/
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);
}
#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|
}
}
-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;
/*
* 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);
/*
* 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);
/*
* 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);
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 */
/*
* 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);
/*
* 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);
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;
}
}
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;
}
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;
}
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));
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) ||
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;
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;
}
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
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;
}
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);
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;
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",
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,
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");
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");
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;
static unsigned int noise2;
static unsigned int noise3;
/* test */
-static short print_cnt;
+#define NOSTD_DEBUG_PRINT_CNT 100
unsigned int vbi_mem_start;
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");
}
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;
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);
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*/
}
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) {
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) */
/*
* 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;
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);
}
/*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);
#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);
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());
}
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));
}
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));
}
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;
/*
* 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;
!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);
}
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);
/*
* 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;
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) {
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);
+ }
+ }
}
}
{
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__);
/* 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__);
(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);
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",
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);
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",
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;
}
-
-
/*
- * 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 */
/* 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;
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,
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,
}
} 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,
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);
/*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);
/* => 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);
/*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);
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);
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);
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) {
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 */
#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];
}
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 */
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);
}
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--;
/* 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];
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;
(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__);
}
/*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);
/* 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__);
}
*/
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];
(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;
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);
}
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))
/*@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) *
/*@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)
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);
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 */
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 */
}
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);
*/
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
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); */
}
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);
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]);
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",
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)
{
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;
} 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) {
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) {
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*/
__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) {
__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);
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);
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;
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);
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);
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);