From b480d6ba32aaf465880756919d12f3a93275a8f0 Mon Sep 17 00:00:00 2001 From: Evoke Zhang Date: Fri, 24 May 2019 15:40:34 +0800 Subject: [PATCH] tvafe: change force_nostd adjust to sysfs node [1/1] PD#TV-5482 Problem: Image flicker for non-std avin, because the force_nostd parameter is modified to a unsuitable value. Solution: remove force_nostd paramete, add sysfs node support for force_nostd Verify: x301 Change-Id: Ic50a311c6b5a63bcbd1d56651713de5be60a38a2 Signed-off-by: Evoke Zhang --- drivers/amlogic/media/vin/tvin/tvafe/tvafe.h | 1 + .../amlogic/media/vin/tvin/tvafe/tvafe_cvd.c | 33 +++++++---- .../media/vin/tvin/tvafe/tvafe_debug.c | 59 +++++++++---------- 3 files changed, 51 insertions(+), 42 deletions(-) diff --git a/drivers/amlogic/media/vin/tvin/tvafe/tvafe.h b/drivers/amlogic/media/vin/tvin/tvafe/tvafe.h index 79e7429caea4..dc53c8ac3cec 100644 --- a/drivers/amlogic/media/vin/tvin/tvafe/tvafe.h +++ b/drivers/amlogic/media/vin/tvin/tvafe/tvafe.h @@ -114,6 +114,7 @@ extern bool force_stable; extern unsigned int cutwindow_val_h[5]; extern unsigned int cutwindow_val_v[5]; +extern unsigned int force_nostd; #endif /* _TVAFE_H */ diff --git a/drivers/amlogic/media/vin/tvin/tvafe/tvafe_cvd.c b/drivers/amlogic/media/vin/tvin/tvafe/tvafe_cvd.c index c0da0ca938a3..f83dfccc777a 100644 --- a/drivers/amlogic/media/vin/tvin/tvafe/tvafe_cvd.c +++ b/drivers/amlogic/media/vin/tvin/tvafe/tvafe_cvd.c @@ -153,12 +153,11 @@ module_param(config_force_fmt, uint, 0664); MODULE_PARM_DESC(config_force_fmt, "after try TRY_FORMAT_MAX times ,we will force one fmt"); -/*0:normal 1:force nonstandard configure*/ -/*2:force don't nonstandard configure*/ -static unsigned int force_nostd = 2; -module_param(force_nostd, uint, 0644); -MODULE_PARM_DESC(force_nostd, - "fixed nosig problem by removing the nostd config.\n"); +/*0:normal nonstandard configure every loop*/ +/*1:force nonstandard configure every loop*/ +/*2:nonstandard configure once*/ +/*3:force don't nonstandard configure*/ +unsigned int force_nostd = 2; /*0x001:enable cdto adj 0x010:enable 3d adj 0x100:enable pga;*/ /*0x1000:enable hs adj,which can instead cdto*/ @@ -606,17 +605,21 @@ static void tvafe_cvd2_non_std_config(struct tvafe_cvd2_s *cvd2) 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", + __func__, force_nostd, + cvd2->info.non_std_config, + cvd2->info.non_std_enable); + } if ((cvd2->info.non_std_config == cvd2->info.non_std_enable) && - (force_nostd&0x2)) + (force_nostd == 2)) return; cvd2->info.non_std_config = cvd2->info.non_std_enable; if (cvd2->info.non_std_config && (!(force_nostd&0x1))) { if (cvd_nonstd_dbg_en) { - tvafe_pr_info("%s: config non-std signal reg.\n", - __func__); - tvafe_pr_info("%s: noise_strenth=%d.\n", - __func__, noise_strenth); + tvafe_pr_info("%s: config non-std signal reg, noise_strenth=%d\n", + __func__, noise_strenth); } #ifdef CONFIG_AM_SI2176 @@ -1257,6 +1260,14 @@ static void tvafe_cvd2_non_std_signal_det( cvd2->info.non_std_enable = 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, + cvd2->info.non_std_enable); + } + } } /* diff --git a/drivers/amlogic/media/vin/tvin/tvafe/tvafe_debug.c b/drivers/amlogic/media/vin/tvin/tvafe/tvafe_debug.c index 904db5d34625..b210e01e5d9c 100644 --- a/drivers/amlogic/media/vin/tvin/tvafe/tvafe_debug.c +++ b/drivers/amlogic/media/vin/tvin/tvafe/tvafe_debug.c @@ -200,11 +200,9 @@ static ssize_t tvafe_store(struct device *dev, struct device_attribute *attr, const char *buff, size_t count) { unsigned char fmt_index = 0; - struct tvafe_dev_s *devp; - unsigned long tmp = 0; char *buf_orig, *parm[47] = {NULL}; - long val; + unsigned int val; devp = dev_get_drvdata(dev); if (!buff) @@ -235,17 +233,15 @@ static ssize_t tvafe_store(struct device *dev, else tvafe_pr_info("%s:invaild command.", buff); } else if (!strncmp(buff, "disableapi", strlen("disableapi"))) { - if (kstrtoul(buff+strlen("disableapi")+1, 10, &tmp) == 0) - disableapi = tmp; + if (kstrtouint(buff+strlen("disableapi")+1, 10, &val) == 0) + disableapi = val; } else if (!strncmp(buff, "force_stable", strlen("force_stable"))) { - if (kstrtoul(buff+strlen("force_stable")+1, 10, &tmp) == 0) - force_stable = tmp; + if (kstrtouint(buff+strlen("force_stable")+1, 10, &val) == 0) + force_stable = val; } else if (!strncmp(buff, "tvafe_enable", strlen("tvafe_enable"))) { - if (kstrtoul(parm[1], 10, &val) < 0) { - kfree(buf_orig); - return -EINVAL; - } + if (kstrtouint(parm[1], 10, &val) < 0) + goto tvafe_store_err; if (val) { tvafe_enable_module(true); devp->flags &= (~TVAFE_POWERDOWN_IN_IDLE); @@ -258,10 +254,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 (kstrtoul(parm[1], 10, &val) < 0) { - kfree(buf_orig); - return -EINVAL; - } + if (kstrtouint(parm[1], 10, &val) < 0) + goto tvafe_store_err; if (val) { tvafe_set_snow_cfg(true); tvafe_pr_info("[tvafe..]hadware snow cfg en\n"); @@ -270,10 +264,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 (kstrtoul(parm[1], 10, &val) < 0) { - kfree(buf_orig); - return -EINVAL; - } + if (kstrtouint(parm[1], 10, &val) < 0) + goto tvafe_store_err; if (val) { tvafe_snow_config(1); tvafe_snow_config_clamp(1); @@ -287,10 +279,8 @@ 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 (kstrtoul(parm[1], 10, &val) < 0) { - kfree(buf_orig); - return -EINVAL; - } + 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); @@ -301,10 +291,8 @@ static ssize_t tvafe_store(struct device *dev, /*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*/ - if (kstrtoul(parm[1], 10, &val) < 0) { - kfree(buf_orig); - return -EINVAL; - } + if (kstrtouint(parm[1], 10, &val) < 0) + goto tvafe_store_err; if (val) { devp->tvafe.cvd2.nonstd_detect_dis = true; pr_info("[tvafe..]%s:disable nonstd detect\n", @@ -315,10 +303,8 @@ static ssize_t tvafe_store(struct device *dev, __func__); } } else if (!strncmp(buff, "rf_ntsc50_en", strlen("rf_ntsc50_en"))) { - if (kstrtoul(parm[1], 10, &val) < 0) { - kfree(buf_orig); - return -EINVAL; - } + if (kstrtouint(parm[1], 10, &val) < 0) + goto tvafe_store_err; if (val) { tvafe_cvd2_rf_ntsc50_en(true); pr_info("[tvafe..]%s:tvafe_cvd2_rf_ntsc50_en\n", @@ -328,10 +314,19 @@ static ssize_t tvafe_store(struct device *dev, pr_info("[tvafe..]%s:tvafe_cvd2_rf_ntsc50_dis\n", __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", + __func__, force_nostd); } else tvafe_pr_info("[%s]:invaild command.\n", __func__); kfree(buf_orig); return count; + +tvafe_store_err: + kfree(buf_orig); + return -EINVAL; } static ssize_t tvafe_show(struct device *dev, @@ -355,6 +350,8 @@ static ssize_t tvafe_show(struct device *dev, "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; } -- 2.34.1