ccflags-y += -I.
ccflags-y += -Idrivers/media/dvb-core
-#ccflags-y += -Idrivers/amlogic/tuners/mxl661
-#ccflags-y += -Idrivers/amlogic/tuners/si2151
-
-#obj-m += aml_atvdemod.o
-#
-#aml_atvdemod-objs = atvdemod_func.o atvauddemod_func.o
-#
-#aml_atvdemod-objs += atv_demod_v4l2.o atv_demod_driver.o atv_demod_ops.o
-#
-#ccflags-y += -I.
-#ccflags-y += -Idrivers/media/dvb-core
-#
-#TARGET_PRODUCT=t962e_r321
-#KERNEL_ARCH=arm64
-#CROSS_COMPILE=aarch64-linux-gnu-
-#PRODUCT_OUT=../../../../out/target/product/$(TARGET_PRODUCT)/obj/KERNEL_OBJ
-#
-#KBUILD_EXTRA_SYMBOLS += $(shell pwd)/../tuner/si2151_4.9/Module.symvers
-#
-#export KBUILD_EXTRA_SYMBOLS
-#
-#all:
-# $(MAKE) -C $(PRODUCT_OUT) M=$(shell pwd) ARCH=$(KERNEL_ARCH) CROSS_COMPILE=$(CROSS_COMPILE) modules
-#
-#clean:
-# rm -rf *.ko .*.ko.cmd *.o *.order *.symvers -f *.cmd .*.o.cmd *.mod.c .tmp_versions/
\ No newline at end of file
extern int atvdemod_debug_en;
+#undef pr_fmt
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#undef pr_info
-#define pr_info(args...)\
+#define pr_info(fmt, ...)\
do {\
- if (atvdemod_debug_en)\
- printk(args);\
+ if (1)\
+ printk(fmt, ##__VA_ARGS__);\
} while (0)
#undef pr_dbg
-#define pr_dbg(args...) \
+#define pr_dbg(fmt, ...) \
do {\
- if (atvdemod_debug_en == 2)\
- printk(args);\
+ if (atvdemod_debug_en)\
+ printk(fmt, ##__VA_ARGS__);\
} while (0)
#undef pr_err
-#define pr_err(args...) \
+#define pr_err(fmt, ...) \
do {\
if (1)\
- printk(args);\
+ printk(fmt, ##__VA_ARGS__);\
} while (0)
#endif /* __ATV_DEMOD_DEBUG_H__ */
parm[n++] = token;
}
- if (!strncmp(parm[0], "init", strlen("init"))) {
+ if (!strncmp(parm[0], "init", 4)) {
ret = atv_demod_enter_mode();
if (ret)
- pr_info("[tuner..] atv_restart error.\n");
- } else if (!strncmp(parm[0], "audout_mode", strlen("audout_mode"))) {
+ pr_info("atv init error.\n");
+ } else if (!strncmp(parm[0], "audout_mode", 11)) {
if (get_atvdemod_state() == ATVDEMOD_STATE_WORK) {
if (is_meson_txlx_cpu()) {
atvauddemod_set_outputmode();
- pr_info("[tuner..] atvauddemod_set_outputmode done ....\n");
+ pr_info("atvauddemod_set_outputmode done ....\n");
}
} else {
- pr_info("[tuner..] atvdemod_state not work ....\n");
+ pr_info("atvdemod_state not work ....\n");
}
- } else if (!strncmp(parm[0], "signal_audmode",
- strlen("signal_audmode"))) {
+ } else if (!strncmp(parm[0], "signal_audmode", 14)) {
int stereo_flag, sap_flag;
if (get_atvdemod_state() == ATVDEMOD_STATE_WORK) {
if (is_meson_txlx_cpu()) {
update_btsc_mode(1, &stereo_flag, &sap_flag);
- pr_info("[tuner..] get signal_audmode done ....\n");
+ pr_info("get signal_audmode done ....\n");
}
} else {
- pr_info("[tuner..] atvdemod_state not work ....\n");
+ pr_info("atvdemod_state not work ....\n");
}
} else if (!strncmp(parm[0], "clk", 3)) {
adc_set_pll_cntl(1, 0x1, NULL);
if (is_meson_txlx_cpu() || is_meson_txhd_cpu())
aud_demod_clk_gate(1);
pr_info("atvdemod_clk_init done ....\n");
- } else if (!strcmp(parm[0], "tune")) {
+ } else if (!strncmp(parm[0], "tune", 4)) {
/* val = simple_strtol(parm[1], NULL, 10); */
- } else if (!strcmp(parm[0], "set")) {
- if (!strncmp(parm[1], "avout_gain", strlen("avout_gain"))) {
+ } else if (!strncmp(parm[0], "set", 3)) {
+ if (!strncmp(parm[1], "avout_gain", 10)) {
if (kstrtoul(buf + strlen("avout_offset") + 1,
10, &tmp) == 0)
val = tmp;
atv_dmd_wr_byte(0x0c, 0x01, val & 0xff);
- } else if (!strncmp(parm[1], "avout_offset",
- strlen("avout_offset"))) {
+ } else if (!strncmp(parm[1], "avout_offset", 12)) {
if (kstrtoul(buf + strlen("avout_offset") + 1,
10, &tmp) == 0)
val = tmp;
atv_dmd_wr_byte(0x0c, 0x04, val & 0xff);
- } else if (!strncmp(parm[1], "atv_gain",
- strlen("atv_gain"))) {
+ } else if (!strncmp(parm[1], "atv_gain", 8)) {
if (kstrtoul(buf + strlen("atv_gain") + 1,
10, &tmp) == 0)
val = tmp;
atv_dmd_wr_byte(0x19, 0x01, val & 0xff);
- } else if (!strncmp(parm[1], "atv_offset",
- strlen("atv_offset"))) {
+ } else if (!strncmp(parm[1], "atv_offset", 10)) {
if (kstrtoul(buf + strlen("atv_offset") + 1,
10, &tmp) == 0)
val = tmp;
atv_dmd_wr_byte(0x19, 0x04, val & 0xff);
}
- } else if (!strcmp(parm[0], "get")) {
- if (!strncmp(parm[1], "avout_gain", strlen("avout_gain"))) {
+ } else if (!strncmp(parm[0], "get", 3)) {
+ if (!strncmp(parm[1], "avout_gain", 10)) {
val = atv_dmd_rd_byte(0x0c, 0x01);
pr_dbg("avout_gain:0x%x\n", val);
- } else if (!strncmp(parm[1], "avout_offset",
- strlen("avout_offset"))) {
+ } else if (!strncmp(parm[1], "avout_offset", 12)) {
val = atv_dmd_rd_byte(0x0c, 0x04);
pr_dbg("avout_offset:0x%x\n", val);
- } else if (!strncmp(parm[1], "atv_gain",
- strlen("atv_gain"))) {
+ } else if (!strncmp(parm[1], "atv_gain", 8)) {
val = atv_dmd_rd_byte(0x19, 0x01);
pr_dbg("atv_gain:0x%x\n", val);
- } else if (!strncmp(parm[1], "atv_offset",
- strlen("atv_offset"))) {
+ } else if (!strncmp(parm[1], "atv_offset", 10)) {
val = atv_dmd_rd_byte(0x19, 0x04);
pr_dbg("atv_offset:0x%x\n", val);
}
- } else if (!strncmp(parm[0], "snr_hist", strlen("snr_hist"))) {
+ } else if (!strncmp(parm[0], "snr_hist", 8)) {
data_snr_avg = 0;
for (i = 0; i < 128; i++) {
data_snr[i] = (atv_dmd_rd_long(APB_BLOCK_ADDR_VDAGC,
pr_dbg("**********snr_hist_128avg:0x%x(%d)*********\n",
data_snr_avg,
data_snr_avg);
- } else if (!strncmp(parm[0], "afc_info", strlen("afc_info"))) {
+ } else if (!strncmp(parm[0], "afc_info", 8)) {
data_afc = retrieve_vpll_carrier_afc();
- pr_dbg("[amlatvdemod..]afc %d Khz.\n", data_afc);
- } else if (!strncmp(parm[0], "ver_info", strlen("ver_info"))) {
- pr_dbg("[amlatvdemod..]aml_atvdemod_ver %s.\n",
+ pr_dbg("afc %d Khz.\n", data_afc);
+ } else if (!strncmp(parm[0], "ver_info", 8)) {
+ pr_dbg("aml_atvdemod_ver %s.\n",
AMLATVDEMOD_VER);
- } else if (!strncmp(parm[0], "audio_autodet",
- strlen("audio_autodet"))) {
+ } else if (!strncmp(parm[0], "audio_autodet", 13)) {
aml_audiomode_autodet(NULL);
- } else if (!strncmp(parm[0], "overmodule_det",
- strlen("overmodule_det"))) {
+ } else if (!strncmp(parm[0], "overmodule_det", 14)) {
/* unsigned long over_threshold, */
/* int det_mode = auto_det_mode; */
aml_atvdemod_overmodule_det();
- } else if (!strncmp(parm[0], "audio_gain_set",
- strlen("audio_gain_set"))) {
+ } else if (!strncmp(parm[0], "audio_gain_set", 14)) {
if (kstrtoul(buf + strlen("audio_gain_set") + 1, 16, &tmp) == 0)
val = tmp;
aml_audio_valume_gain_set(val);
pr_dbg("audio_gain_set : %d\n", val);
- } else if (!strncmp(parm[0], "audio_gain_get",
- strlen("audio_gain_get"))) {
+ } else if (!strncmp(parm[0], "audio_gain_get", 14)) {
val = aml_audio_valume_gain_get();
pr_dbg("audio_gain_get : %d\n", val);
- } else if (!strncmp(parm[0], "fix_pwm_adj",
- strlen("fix_pwm_adj"))) {
+ } else if (!strncmp(parm[0], "fix_pwm_adj", 11)) {
if (kstrtoul(parm[1], 10, &tmp) == 0) {
val = tmp;
aml_fix_PWM_adjust(val);
}
- } else if (!strncmp(parm[0], "rs", strlen("rs"))) {
+ } else if (!strncmp(parm[0], "rs", 2)) {
if (kstrtoul(parm[1], 16, &tmp) == 0)
block_addr = tmp;
if (kstrtoul(parm[2], 16, &tmp) == 0)
pr_dbg("rs block_addr:0x%x,block_reg:0x%x,block_val:0x%x\n",
block_addr,
block_reg, block_val);
- } else if (!strncmp(parm[0], "ws", strlen("ws"))) {
+ } else if (!strncmp(parm[0], "ws", 2)) {
if (kstrtoul(parm[1], 16, &tmp) == 0)
block_addr = tmp;
if (kstrtoul(parm[2], 16, &tmp) == 0)
block_reg, block_val);
block_val = atv_dmd_rd_long(block_addr, block_reg);
pr_dbg("readback_val:0x%x\n", block_val);
- } else if (!strncmp(parm[0], "pin_mux", strlen("pin_mux"))) {
+ } else if (!strncmp(parm[0], "pin_mux", 7)) {
aml_atvdemod_dev->pin = devm_pinctrl_get_select(
aml_atvdemod_dev->dev,
aml_atvdemod_dev->pin_name);
pr_dbg("atvdemod agc pinmux name:%s\n",
aml_atvdemod_dev->pin_name);
- } else if (!strncmp(parm[0], "snr_cur", strlen("snr_cur"))) {
+ } else if (!strncmp(parm[0], "snr_cur", 7)) {
data_snr_avg = aml_atvdemod_get_snr_ex();
pr_dbg("**********snr_cur:%d*********\n", data_snr_avg);
- } else if (!strncmp(parm[0], "pll_status", strlen("pll_status"))) {
+ } else if (!strncmp(parm[0], "pll_status", 10)) {
int vpll_lock;
retrieve_vpll_carrier_lock(&vpll_lock);
pr_dbg("visual carrier lock:locked\n");
else
pr_dbg("visual carrier lock:unlocked\n");
- } else if (!strncmp(parm[0], "line_lock", strlen("line_lock"))) {
+ } else if (!strncmp(parm[0], "line_lock", 9)) {
int line_lock;
retrieve_vpll_carrier_line_lock(&line_lock);
pr_dbg("line lock:locked\n");
else
pr_dbg("line lock:unlocked\n");
- } else if (!strncmp(parm[0], "audio_power", strlen("audio_power"))) {
+ } else if (!strncmp(parm[0], "audio_power", 11)) {
int audio_power = 0;
retrieve_vpll_carrier_audio_power(&audio_power);
- } else if (!strncmp(parm[0], "adc_power", strlen("adc_power"))) {
+ } else if (!strncmp(parm[0], "adc_power", 9)) {
int adc_power = 0;
retrieve_adc_power(&adc_power);
pr_dbg("adc_power:%d\n", adc_power);
- } else if (!strncmp(parm[0], "search_atv", strlen("search_atv"))) {
+ } else if (!strncmp(parm[0], "search_atv", 10)) {
unsigned int freq = 0;
struct analog_parameters params;
struct dvb_frontend *fe = NULL;
params.std = V4L2_STD_PAL_I;
fe->ops.analog_ops.set_params(fe, ¶ms);
- } else if (!strncmp(parm[0], "mode_set", strlen("mode_set"))) {
+ } else if (!strncmp(parm[0], "mode_set", 8)) {
int priv_cfg = AML_ATVDEMOD_INIT;
struct dvb_frontend *fe = NULL;
if (ret)
pr_err("can't find tuner.\n");
else {
- if (!strncmp(str, "mxl661_tuner",
- strlen("mxl661_tuner")))
+ if (!strncmp(str, "mxl661_tuner", 12))
pdev->tuner_id = AM_TUNER_MXL661;
- else if (!strncmp(str, "si2151_tuner",
- strlen("si2151_tuner")))
+ else if (!strncmp(str, "si2151_tuner", 12))
pdev->tuner_id = AM_TUNER_SI2151;
- else if (!strncmp(str, "r840_tuner",
- strlen("r840_tuner")))
+ else if (!strncmp(str, "r840_tuner", 10))
pdev->tuner_id = AM_TUNER_R840;
else
pr_err("can't find tuner: %s.\n", str);
int size_io_reg = 0;
struct aml_atvdemod_device *dev = NULL;
- pr_info("%s.\n", __func__);
-
- dev = kzalloc(sizeof(struct aml_atvdemod_device), GFP_KERNEL);
- if (!dev) {
- ret = -ENOMEM;
- goto fail_alloc_device;
- }
+ dev = devm_kmalloc(&pdev->dev, sizeof(struct aml_atvdemod_device),
+ GFP_KERNEL);
+ if (!dev)
+ return -ENOMEM;
dev->name = ATVDEMOD_DEVICE_NAME;
+ dev->cls.name = ATVDEMOD_DEVICE_NAME;
+#if 0
+ dev->cls.name = devm_kmalloc(&pdev->dev, sizeof(ATVDEMOD_DEVICE_NAME),
+ GFP_KERNEL);
+ if (!dev->cls.name)
+ return -ENOMEM;
- dev->cls.name = kzalloc(strlen(ATVDEMOD_DEVICE_NAME), GFP_KERNEL);
- if (!dev->cls.name) {
- ret = -ENOMEM;
- goto fail_alloc_class;
- }
+ snprintf((char *)dev->cls.name, sizeof(ATVDEMOD_DEVICE_NAME), "%s",
+ ATVDEMOD_DEVICE_NAME);
+#endif
- sprintf((char *)dev->cls.name, "%s", ATVDEMOD_DEVICE_NAME);
dev->cls.class_attrs = atvdemod_debug_class_attrs;
ret = class_register(&dev->cls);
if (ret) {
- dev_err(&pdev->dev, "class_create fail.\n");
+ pr_err("class_create fail.\n");
goto fail_create_class;
}
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
- dev_err(&pdev->dev, "get demod memory resource fail.\n");
+ pr_err("get demod memory resource fail.\n");
goto fail_get_resource;
}
dev->demod_reg_base = devm_ioremap_nocache(&pdev->dev,
res->start, size_io_reg);
if (!dev->demod_reg_base) {
- dev_err(&pdev->dev, "demod ioremap failed.\n");
+ pr_err("demod ioremap failed.\n");
goto fail_get_resource;
}
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
if (!res) {
- dev_err(&pdev->dev, "no audio demod memory resource.\n");
+ pr_err("no audio demod memory resource.\n");
dev->audio_reg_base = NULL;
} else {
size_io_reg = resource_size(res);
dev->audio_reg_base = devm_ioremap_nocache(
&pdev->dev, res->start, size_io_reg);
if (!dev->audio_reg_base) {
- dev_err(&pdev->dev, "audio ioremap failed.\n");
+ pr_err("audio ioremap failed.\n");
goto fail_get_resource;
}
dev->v4l2_ad.tuner_id = dev->tuner_id;
ret = v4l2_resister_frontend(&dev->v4l2_ad, &dev->v4l2_fe);
if (ret) {
- dev_err(&pdev->dev, "resister v4l2 fail.\n");
+ pr_err("resister v4l2 fail.\n");
goto fail_register_v4l2;
}
amlatvdemod_devp = dev;
- pr_info("probe ok.\n");
+ pr_info("%s: OK.\n", __func__);
return 0;
fail_get_resource:
class_unregister(&dev->cls);
fail_create_class:
- kfree(dev->cls.name);
-fail_alloc_class:
- kfree(dev);
-fail_alloc_device:
- pr_info("[amlatvdemod]: atvdemod_init fail.\n");
+ /*devm_kfree(&pdev->dev, dev->cls.name);*/
+ devm_kfree(&pdev->dev, dev);
+
+ pr_info("%s: fail.\n", __func__);
return ret;
}
amlatvdemod_devp = NULL;
- kfree(dev->cls.name);
- kfree(dev);
+ /*devm_kfree(&pdev->dev, dev->cls.name);*/
+ devm_kfree(&pdev->dev, dev);
- pr_dbg("[amlatvdemod] : aml_atvdemod_remove.\n");
+ pr_info("%s: OK.\n", __func__);
return 0;
}
static void aml_atvdemod_shutdown(struct platform_device *pdev)
{
- pr_info("%s done.\n", __func__);
+ pr_info("%s: OK.\n", __func__);
}
static int aml_atvdemod_suspend(struct platform_device *pdev,
v4l2_frontend_suspend(&dev->v4l2_fe);
- pr_info("%s: OK\n", __func__);
+ pr_info("%s: OK.\n", __func__);
return 0;
}
v4l2_frontend_resume(&dev->v4l2_fe);
- pr_info("%s: OK\n", __func__);
+ pr_info("%s: OK.\n", __func__);
return 0;
}
static int __init aml_atvdemod_init(void)
{
if (platform_driver_register(&aml_atvdemod_driver)) {
- pr_err("failed to register amlatvdemod driver module\n");
+ pr_err("%s: failed to register driver.\n", __func__);
return -ENODEV;
}
- pr_dbg("[amlatvdemod..]%s: driver init ok.\n", __func__);
+ pr_info("%s: OK.\n", __func__);
return 0;
}
static void __exit aml_atvdemod_exit(void)
{
platform_driver_unregister(&aml_atvdemod_driver);
- pr_dbg("[amlatvdemod..]%s: driver exit ok.\n", __func__);
+ pr_info("%s: OK.\n", __func__);
}
MODULE_AUTHOR("nengwen.chen <nengwen.chen@amlogic.com>");
else
*state = 0;
- pr_info("aml_fe_get_atvaudio_state: %d, power = %d.\n",
+ pr_dbg("aml_fe_get_atvaudio_state: %d, power = %d.\n",
*state, power);
}
}
/* set_aft_thread_enable(1, 0); */
- //memset(&(amlatvdemod_devp->parm), 0, sizeof(amlatvdemod_devp->parm));
+ /*
+ * memset(&(amlatvdemod_devp->parm), 0,
+ * sizeof(amlatvdemod_devp->parm));
+ */
atvdemod_state = ATVDEMOD_STATE_WORK;
- pr_info("%s: OK\n", __func__);
+ pr_info("%s: OK.\n", __func__);
return 0;
}
adc_set_pll_cntl(0, 0x1, NULL);
if (is_meson_txlx_cpu() || is_meson_txhd_cpu())
aud_demod_clk_gate(0);
- //memset(&(amlatvdemod_devp->parm), 0, sizeof(amlatvdemod_devp->parm));
+
+ /*
+ * memset(&(amlatvdemod_devp->parm), 0,
+ * sizeof(amlatvdemod_devp->parm));
+ */
atvdemod_state = ATVDEMOD_STATE_IDEL;
- pr_info("%s: OK\n", __func__);
+ pr_info("%s: OK.\n", __func__);
return 0;
}
if (!is_atvdemod_scan_mode())
atvauddemod_init();
- pr_info("[amlatvdemod..]%s set std color %lld, audio type %lld.\n",
+ pr_info("%s: set std color %lld, audio type %lld.\n",
__func__, amlatvdemod_devp->std, amlatvdemod_devp->std);
- pr_info("[amlatvdemod..]%s set if_freq %d, if_inv %d.\n",
+ pr_info("%s: set if_freq %d, if_inv %d.\n",
__func__, amlatvdemod_devp->if_freq,
amlatvdemod_devp->if_inv);
}
-
- pr_err("%s: tuner_id = %d.\n", __func__, atvdemod_param->tuner_id);
}
static int atv_demod_has_signal(struct dvb_frontend *fe, u16 *signal)
pr_info("visual carrier lock:unlocked\n");
}
- pr_err("%s.\n", __func__);
-
return 0;
}
set_atvdemod_state(ATVDEMOD_STATE_SLEEP);
}
- pr_info("%s: OK\n", __func__);
+ pr_info("%s: OK.\n", __func__);
}
static void atv_demod_tuner_status(struct dvb_frontend *fe)
{
- pr_err("%s.\n", __func__);
+ pr_info("%s.\n", __func__);
}
static int atv_demod_get_afc(struct dvb_frontend *fe, s32 *afc)
{
*afc = retrieve_vpll_carrier_afc();
- pr_info("%s: afc %d.\n", __func__, *afc);
-
return 0;
}
fe->analog_demod_priv = NULL;
- pr_err("%s.\n", __func__);
+ pr_info("%s: OK.\n", __func__);
}
static int atv_demod_set_config(struct dvb_frontend *fe, void *priv_cfg)
int *state = (int *) priv_cfg;
if (!state) {
- pr_err("%s state == NULL.\n", __func__);
+ pr_err("%s: state == NULL.\n", __func__);
return -1;
}
mutex_unlock(&atv_demod_list_mutex);
- pr_err("%s done.\n", __func__);
-
return 0;
}
struct i2c_adapter *i2c_adap, u8 i2c_addr, u32 tuner_id)
{
int instance = 0;
+ void *p = NULL;
struct atv_demod_priv *priv = NULL;
mutex_lock(&atv_demod_list_mutex);
case AM_TUNER_R840:
break;
case AM_TUNER_SI2151:
- v4l2_attach(si2151_attach, fe, i2c_adap, i2c_addr);
+ p = v4l2_attach(si2151_attach, fe, i2c_adap, i2c_addr);
break;
case AM_TUNER_MXL661:
- v4l2_attach(mxl661_attach, fe, i2c_adap, i2c_addr);
+ p = v4l2_attach(mxl661_attach, fe, i2c_adap, i2c_addr);
break;
}
+ if (!p)
+ pr_err("%s: v4l2_attach tuner %d error.\n",
+ __func__, tuner_id);
+
return fe;
}
aml_fe_hook_atv_status = atv_mode;
aml_fe_hook_hv_lock = cvd_hv_lock;
aml_fe_hook_get_fmt = get_fmt;
- pr_dbg("[aml_fe]%s\n", __func__);
+
+ pr_info("%s: OK.\n", __func__);
}
EXPORT_SYMBOL(aml_fe_hook_cvd);
std = V4L2_STD_SECAM_DK;
break;
default:
- pr_err("%s: unsupport fmt: 0x%0x.\n", __func__, fmt);
+ pr_err("%s: Unsupport fmt: 0x%0x.\n", __func__, fmt);
}
return std;
std = V4L2_STD_SECAM;
break;
default:
- pr_err("%s err fmt: 0x%x\n", __func__, fmt);
+ pr_err("%s: Unsupport fmt: 0x%x\n", __func__, fmt);
break;
}
return std;
}
static void v4l2_fe_try_analog_format(struct v4l2_frontend *v4l2_fe,
- bool auto_search_std, v4l2_std_id *video_fmt, int *audio_fmt)
+ bool auto_search_std, v4l2_std_id *video_fmt,
+ unsigned int *audio_fmt)
{
struct dvb_frontend *fe = &v4l2_fe->v4l2_ad->fe;
struct v4l2_analog_parameters *p = &v4l2_fe->params;
int try_vfmt_cnt = 300;
int varify_cnt = 0;
v4l2_std_id std_bk = 0;
- int audio = 0;
+ unsigned int audio = 0;
if (auto_search_std == true) {
for (i = 0; i < try_vfmt_cnt; i++) {
i, (unsigned int) std_bk);
if (std_bk == 0) {
- pr_err("[%s] failed to get v fmt !!\n", __func__);
- pr_err("[%s] vfmt assume PAL !!\n", __func__);
+ pr_err("%s: failed to get video fmt, assume PAL.\n",
+ __func__);
std_bk = TVIN_SIG_FMT_CVBS_PAL_I;
p->std = V4L2_STD_PAL_I;
p->frequency += 1;
#endif
#else /* Now, force to NTSC_M, Ours demod only support M for NTSC.*/
audio = V4L2_STD_NTSC_M;
- std_bk |= V4L2_COLOR_STD_NTSC;
+ *video_fmt |= V4L2_COLOR_STD_NTSC;
#endif
} else if (std_bk == V4L2_STD_SECAM) {
audio = V4L2_STD_SECAM_L;
- std_bk |= V4L2_COLOR_STD_SECAM;
+ *video_fmt |= V4L2_COLOR_STD_SECAM;
} else {
/*V4L2_COLOR_STD_PAL*/
- std_bk |= V4L2_COLOR_STD_PAL;
+ *video_fmt |= V4L2_COLOR_STD_PAL;
amlatvdemod_set_std(AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_DK);
audio = aml_audiomode_autodet(fe);
+ pr_info("autodet audmode 0x%x\n", audio);
audio = demod_fmt_2_v4l2_std(audio);
+ pr_info("v4l2_std audmode 0x%x\n", audio);
#if 0 /* Why do this to me? We need support PAL_M.*/
if (audio == V4L2_STD_PAL_M) {
audio = demod_fmt_2_v4l2_std(broad_std_except_pal_m);
- pr_err("select audmode 0x%x\n", audio);
+ pr_info("select audmode 0x%x\n", audio);
}
#endif
}
if (abs(p->frequency - freq_success) < 3000000
&& p->frequency > 45000000) {
ktime_get_ts(&time_now);
- //if (debug_fe & 0x2)
- pr_err("%s: tv_sec now:%ld,tv_sec success:%ld\n",
+ pr_err("[%s] tv_sec now:%ld,tv_sec success:%ld\n",
__func__, time_now.tv_sec, success_time.tv_sec);
/* beyond 10s search same frequency is ok */
if ((time_now.tv_sec - success_time.tv_sec) < 10)
else if (fe->ops.tuner_ops.get_afc)
fe->ops.tuner_ops.get_afc(fe, &afc);
- //if (debug_fe & 0x2)
- pr_err("[%s] get afc %d khz, freq %u.\n",
+ pr_dbg("[%s] get afc %d khz, freq %u.\n",
__func__, afc, p->frequency);
if (afc == 0xffff) {
if (lock_cnt > 0) {
p->frequency = temp_freq +
temp_afc * 1000;
- pr_err("%s, force lock, f:%d\n",
+ pr_err("[%s] force lock, f:%d\n",
__func__, p->frequency);
break;
}
p->frequency += afc * 1000;
if (unlikely(p->frequency > maxafcfreq)) {
- pr_err("[%s]:[%d] is exceed maxafcfreq[%d]\n",
+ pr_err("[%s] [%d] is exceed maxafcfreq[%d]\n",
__func__, p->frequency, maxafcfreq);
p->frequency = set_freq;
return -1;
}
#if 0 /*if enable ,it would miss program*/
if (unlikely(c->frequency < minafcfreq)) {
- pr_dbg("[%s]:[%d] is exceed minafcfreq[%d]\n",
+ pr_dbg("[%s] [%d] is exceed minafcfreq[%d]\n",
__func__, c->frequency, minafcfreq);
c->frequency = set_freq;
return -1;
}
#endif
if (likely(!(count--))) {
- pr_err("[%s]:exceed the afc count\n", __func__);
+ pr_err("[%s] exceed the afc count\n", __func__);
p->frequency = set_freq;
return -1;
}
freq_success = p->frequency;
ktime_get_ts(&success_time);
- //if (debug_fe & 0x2)
- pr_err("[%s] get afc %d khz done, freq %u.\n",
+ pr_dbg("[%s] get afc %d khz done, freq %u.\n",
__func__, afc, p->frequency);
}
__u32 afc_step = 0;
int tuner_status_cnt_local = tuner_status_cnt;
v4l2_std_id std_bk = 0;
- int audio = 0;
+ unsigned int audio = 0;
int double_check_cnt = 1;
bool auto_search_std = false;
int search_count = 0;
}
if (p->afc_range == 0) {
- pr_err("[%s]:afc_range == 0, skip the search\n", __func__);
+ pr_err("[%s] afc_range == 0, skip the search\n", __func__);
return V4L2_SEARCH_INVALID;
}
- pr_err("[%s] afc_range: [%d], tuner type: [%d], freq: [%d].\n",
- __func__, p->afc_range,
- v4l2_fe->v4l2_ad->tuner_id, p->frequency);
+ pr_info("[%s] afc_range: [%d], tuner: [%d], freq: [%d], flag: [%d].\n",
+ __func__, p->afc_range, v4l2_fe->v4l2_ad->tuner_id,
+ p->frequency, p->flag);
/* backup the freq by api */
set_freq = p->frequency;
if (p->std == 0) {
p->std = V4L2_STD_PAL_I;
auto_search_std = true;
- pr_dbg("%s, user analog.std is 0, so set it to PAL | I.\n",
+ pr_dbg("[%s] user analog.std is 0, so set it to PAL | I.\n",
__func__);
}
}
/**enter auto search mode**/
- pr_dbg("%s Auto search user std: 0x%08x\n",
+ pr_dbg("[%s] Auto search std: 0x%08x\n",
__func__, (unsigned int) p->std);
#ifdef DEBUG_TIME_CUS
#ifdef DEBUG_TIME_CUS
time_end = jiffies_to_msecs(jiffies);
time_delta = time_end - time_start;
- pr_dbg("[ATV_SEARCH_SUCCESS]%s: time_delta:%d ms\n",
+ pr_dbg("[%s] time_delta:%d ms\n",
__func__, time_delta);
#endif
/*sync param */
#ifdef DEBUG_TIME_CUS
time_end = jiffies_to_msecs(jiffies);
time_delta = time_end - time_start;
- pr_dbg("[ATV_SEARCH_FAILED]%s: time_delta:%d ms\n",
- __func__, time_delta);
+ pr_dbg("[%s] time_delta:%d ms\n", __func__, time_delta);
#endif
}
#ifdef DEBUG_TIME_CUS
time_end = jiffies_to_msecs(jiffies);
time_delta = time_end - time_start;
- pr_dbg("[ATV_SEARCH_FAILED]%s: time_delta:%d ms\n",
- __func__, time_delta);
+ pr_dbg("[%s] time_delta:%d ms\n", __func__, time_delta);
#endif
pr_dbg("[%s] [%d] over of range [min=%d, max=%d], search failed.\n",
struct v4l2_frontend_private *fepriv = v4l2_fe->frontend_priv;
struct v4l2_fe_events *events = &fepriv->events;
- pr_err("%s.\n", __func__);
+ pr_dbg("%s.\n", __func__);
if (events->overflow) {
events->overflow = 0;
struct v4l2_frontend_event *e = NULL;
int wp;
- pr_err("%s.\n", __func__);
+ pr_dbg("%s.\n", __func__);
mutex_lock(&events->mtx);
enum v4l2_status s = V4L2_TIMEDOUT;
unsigned long timeout = 0;
- pr_err("%s: thread start.\n", __func__);
+ pr_info("%s: thread start.\n", __func__);
fepriv->delay = 3 * HZ;
fepriv->status = 0;
/* pr_dbg("%s: state = %d.\n", __func__, fepriv->state); */
if (fepriv->state & V4L2FE_STATE_RETUNE) {
- pr_err("%s: Retune requested, V4L2FE_STATE_RETUNE.\n",
+ pr_dbg("%s: Retune requested, V4L2FE_STATE_RETUNE.\n",
__func__);
fepriv->state = V4L2FE_STATE_TUNED;
}
v4l2_frontend_wakeup(v4l2_fe);
- pr_err("%s: thread exit state = %d.\n", __func__, fepriv->state);
+ pr_dbg("%s: thread exit state = %d.\n", __func__, fepriv->state);
return 0;
}
{
struct v4l2_frontend_private *fepriv = v4l2_fe->frontend_priv;
- pr_err("%s.\n", __func__);
+ pr_dbg("%s.\n", __func__);
fepriv->exit = V4L2_FE_NORMAL_EXIT;
/* paranoia check in case a signal arrived */
if (fepriv->thread)
- pr_err("%s: warning: thread %p won't exit\n",
+ pr_info("%s: warning: thread %p won't exit\n",
__func__, fepriv->thread);
}
struct task_struct *thread = NULL;
struct v4l2_frontend_private *fepriv = v4l2_fe->frontend_priv;
- pr_err("%s.\n", __func__);
+ pr_dbg("%s.\n", __func__);
if (fepriv->thread) {
if (fepriv->exit == V4L2_FE_NO_EXIT)
struct v4l2_frontend_private *fepriv = v4l2_fe->frontend_priv;
struct dvb_frontend *fe = &v4l2_fe->v4l2_ad->fe;
- pr_err("%s.\n", __func__);
+ pr_dbg("%s.\n", __func__);
freq_min = fe->ops.tuner_ops.info.frequency_min;
freq_max = fe->ops.tuner_ops.info.frequency_max;
if (freq_min == 0 || freq_max == 0)
- pr_err("%s: demod or tuner frequency limits undefined.\n",
+ pr_info("%s: demod or tuner frequency limits undefined.\n",
__func__);
/* range check: frequency */
static int v4l2_get_frontend(struct v4l2_frontend *v4l2_fe,
struct v4l2_analog_parameters *p)
{
+ pr_dbg("%s.\n", __func__);
+
+ memcpy(p, &v4l2_fe->params, sizeof(struct v4l2_analog_parameters));
return 0;
}
struct analog_demod_ops *analog_ops = NULL;
int priv_cfg = 0;
- pr_err("%s: params = %ld.\n", __func__, params);
+ pr_dbg("%s: params = %ld.\n", __func__, params);
fepriv->state = V4L2FE_STATE_IDLE;
static void v4l2_frontend_vdev_release(struct video_device *dev)
{
- pr_err("%s.\n", __func__);
+ pr_dbg("%s.\n", __func__);
}
static ssize_t v4l2_frontend_read(struct file *filp, char __user *buf,
size_t count, loff_t *ppos)
{
- pr_err("%s.\n", __func__);
+ pr_dbg("%s.\n", __func__);
return 0;
}
static ssize_t v4l2_frontend_write(struct file *filp, const char __user *buf,
size_t count, loff_t *ppos)
{
- pr_err("%s.\n", __func__);
+ pr_dbg("%s.\n", __func__);
return 0;
}
poll_wait(filp, &fepriv->events.wait_queue, pts);
- if (fepriv->events.eventw != fepriv->events.eventr)
+ if (fepriv->events.eventw != fepriv->events.eventr) {
+ pr_dbg("%s: POLLIN | POLLRDNORM | POLLPRI.\n", __func__);
return (POLLIN | POLLRDNORM | POLLPRI);
+ }
- pr_info("%s.\n", __func__);
return 0;
}
unsigned int cmd, void *arg)
{
int ret = 0;
+ int need_lock = 1;
struct v4l2_frontend *v4l2_fe = video_get_drvdata(video_devdata(filp));
struct v4l2_frontend_private *fepriv = v4l2_fe->frontend_priv;
- pr_err("%s: cmd = 0x%x.\n", __func__, cmd);
+ pr_dbg("%s: cmd = 0x%x.\n", __func__, cmd);
if (fepriv->exit != V4L2_FE_NO_EXIT)
return -ENODEV;
- if (down_interruptible(&fepriv->sem))
- return -ERESTARTSYS;
+ if (cmd == V4L2_READ_STATUS || cmd == V4L2_GET_FRONTEND)
+ need_lock = 0;
+
+ if (need_lock)
+ if (down_interruptible(&fepriv->sem))
+ return -ERESTARTSYS;
+
+ if (fepriv->exit != DVB_FE_NO_EXIT) {
+ up(&fepriv->sem);
+ return -ENODEV;
+ }
switch (cmd) {
- case V4L2_SET_FRONTEND:
+ case V4L2_SET_FRONTEND: /* 0x40285669 */
ret = v4l2_set_frontend(v4l2_fe,
(struct v4l2_analog_parameters *) arg);
break;
(struct v4l2_analog_parameters *) arg);
break;
- case V4L2_GET_EVENT:
+ case V4L2_GET_EVENT: /* 0x8030566b */
ret = v4l2_frontend_get_event(v4l2_fe,
(struct v4l2_frontend_event *) arg,
filp->f_flags);
break;
- case V4L2_SET_MODE:
+ case V4L2_SET_MODE: /* 0x566c */
ret = v4l2_frontend_set_mode(v4l2_fe, (unsigned long) arg);
break;
break;
}
- up(&fepriv->sem);
+ if (need_lock)
+ up(&fepriv->sem);
return ret;
}
break;
}
- if (p == NULL)
- pr_err("%s: v4l2_attach error.\n", __func__);
+ if (p == NULL) {
+ pr_err("%s: v4l2_attach tuner %d error.\n",
+ __func__, v4l2_fe->v4l2_ad->tuner_id);
+ return -EBUSY;
+ }
}
ret = v4l2_frontend_start(v4l2_fe);
fepriv->events.eventr = fepriv->events.eventw = 0;
- pr_err("%s.\n", fepriv->v4l2dev->name);
- pr_err("%s.\n", __func__);
+ pr_info("%s: %s OK.\n", __func__, fepriv->v4l2dev->name);
return ret;
}
static int v4l2_frontend_release(struct file *filp)
{
- struct v4l2_frontend *v4l2_fe = video_get_drvdata(video_devdata(filp));
- struct v4l2_frontend_private *fepriv = v4l2_fe->frontend_priv;
-
- pr_err("%s.\n", fepriv->v4l2dev->name);
- pr_err("%s.\n", __func__);
+ pr_info("%s: OK.\n", __func__);
return 0;
}
static int v4l2_frontend_vidioc_g_audio(struct file *file, void *fh,
struct v4l2_audio *a)
{
- pr_err("%s.\n", __func__);
+ pr_dbg("%s.\n", __func__);
return 0;
}
static int v4l2_frontend_vidioc_s_audio(struct file *filp, void *fh,
const struct v4l2_audio *a)
{
- pr_err("%s.\n", __func__);
+ pr_dbg("%s.\n", __func__);
return 0;
}
static int v4l2_frontend_vidioc_g_tuner(struct file *filp, void *fh,
struct v4l2_tuner *a)
{
- pr_err("%s.\n", __func__);
+ pr_dbg("%s.\n", __func__);
return 0;
}
static int v4l2_frontend_vidioc_s_tuner(struct file *filp, void *fh,
const struct v4l2_tuner *a)
{
- pr_err("%s.\n", __func__);
+ pr_dbg("%s.\n", __func__);
return 0;
}
static int v4l2_frontend_vidioc_g_frequency(struct file *filp, void *fh,
struct v4l2_frequency *a)
{
- pr_err("%s.\n", __func__);
+ pr_dbg("%s.\n", __func__);
return 0;
}
static int v4l2_frontend_vidioc_s_frequency(struct file *filp, void *fh,
const struct v4l2_frequency *a)
{
- pr_err("%s.\n", __func__);
+ pr_dbg("%s.\n", __func__);
return 0;
}
static int v4l2_frontend_vidioc_enum_freq_bands(struct file *filp, void *fh,
struct v4l2_frequency_band *band)
{
- pr_err("%s.\n", __func__);
+ pr_dbg("%s.\n", __func__);
return 0;
}
static int v4l2_frontend_vidioc_g_modulator(struct file *filp, void *fh,
struct v4l2_modulator *a)
{
- pr_err("%s.\n", __func__);
+ pr_dbg("%s.\n", __func__);
return 0;
}
static int v4l2_frontend_vidioc_s_modulator(struct file *filp, void *fh,
const struct v4l2_modulator *a)
{
- pr_err("%s.\n", __func__);
+ pr_dbg("%s.\n", __func__);
return 0;
}
int v4l2_frontend_vidioc_streamon(struct file *filp, void *fh,
enum v4l2_buf_type i)
{
- pr_err("%s.\n", __func__);
+ pr_dbg("%s.\n", __func__);
return 0;
}
int v4l2_frontend_vidioc_streamoff(struct file *filp, void *fh,
enum v4l2_buf_type i)
{
- pr_err("%s.\n", __func__);
+ pr_dbg("%s.\n", __func__);
return 0;
}
struct v4l2_frontend_private *fepriv = NULL;
struct v4l2_atvdemod_device *v4l2dev = NULL;
- if (v4l2_ad == NULL || v4l2_fe == NULL) {
+ if (!v4l2_ad || !v4l2_fe) {
pr_err("NULL pointer.\n");
return -1;
}
v4l2_fe->frontend_priv = kzalloc(sizeof(struct v4l2_frontend_private),
GFP_KERNEL);
- if (v4l2_fe->frontend_priv == NULL) {
+ if (!v4l2_fe->frontend_priv) {
mutex_unlock(&v4l2_fe_mutex);
pr_err("kzalloc fail.\n");
return -ENOMEM;
fepriv->v4l2dev = kzalloc(sizeof(struct v4l2_atvdemod_device),
GFP_KERNEL);
- if (fepriv->v4l2dev == NULL) {
+ if (!fepriv->v4l2dev) {
ret = -ENOMEM;
goto malloc_fail;
}
mutex_unlock(&v4l2_fe_mutex);
- pr_err("resister aml atv demod device.\n");
+ pr_info("%s: OK.\n", __func__);
return 0;
kfree(v4l2_fe->frontend_priv);
v4l2_fail:
mutex_unlock(&v4l2_fe_mutex);
+ pr_info("%s: Fail.\n", __func__);
return ret;
}
mutex_unlock(&v4l2_fe_mutex);
- pr_err("unregister aml atv demod device.\n");
+ pr_info("%s: OK.\n", __func__);
return 0;
}
struct dvb_tuner_ops tuner_ops = fe->ops.tuner_ops;
struct analog_demod_ops analog_ops = fe->ops.analog_ops;
- pr_info("%s.\n", __func__);
-
if (analog_ops.standby)
analog_ops.standby(fe);
if (tuner_ops.suspend)
tuner_ops.suspend(fe);
+ pr_info("%s: OK.\n", __func__);
+
return ret;
}
struct analog_demod_ops analog_ops = fe->ops.analog_ops;
int priv_cfg = AML_ATVDEMOD_RESUME;
- pr_info("%s.\n", __func__);
-
if (analog_ops.set_config)
analog_ops.set_config(fe, &priv_cfg);
fepriv->state = V4L2FE_STATE_RETUNE;
v4l2_frontend_wakeup(v4l2_fe);
+ pr_info("%s: OK.\n", __func__);
+
return ret;
}
if (thd_flag == 0) {
thd_tmp_v += adec_rd_reg(OV_CNT_REPORT) & 0xffff;
- pr_info("#0x12:0x%x\n", (adec_rd_reg(OV_CNT_REPORT) & 0xffff));
+ pr_dbg("#0x12:0x%x\n", (adec_rd_reg(OV_CNT_REPORT) & 0xffff));
if (thd_cnt == 15) {
thd_tmp_v /= 3;
if (thd_tmp_v > audio_thd_threshold1) {
} else if (thd_flag == 1) {
thd_tmp_v += adec_rd_reg(OV_CNT_REPORT) & 0xffff;
- pr_info("#0x13:0x%x\n", (adec_rd_reg(OV_CNT_REPORT) & 0xffff));
+ pr_dbg("#0x13:0x%x\n", (adec_rd_reg(OV_CNT_REPORT) & 0xffff));
if (thd_cnt == 15) {
thd_tmp_v /= 3;
if (thd_tmp_v <= audio_thd_threshold2) {
last_stereo_flag = stereo_flag;
last_sap_flag = sap_flag;
- pr_info("[tuner..] atvdemod_monitor_audio done ....\n");
+ pr_dbg("atvdemod_monitor_audio done ....\n");
}
}
line_lock = data & 0x10;
line_lock_strong = data & 0x8;
- pr_info("line_lock = 0x%x, line_lock_strong = 0x%x\n",
+ pr_dbg("line_lock = 0x%x, line_lock_strong = 0x%x\n",
line_lock, line_lock_strong);
*lock = (line_lock | line_lock_strong);
*power = data & 0xffff;
}
- pr_info("retrieve_vpll_carrier_audio_power: %d.\n", *power);
+ pr_dbg("retrieve_vpll_carrier_audio_power: %d.\n", *power);
}
int retrieve_vpll_carrier_afc(void)
if ((pll_lock == 1) || (line_lock == 0x10)) {
/*if pll unlock, afc is invalid*/
- pr_err("[afc invalid] pll: %d, line: %d, line_strong: %d, field: %d.\n",
+ pr_info("[afc invalid] pll: %d, line: %d, line_strong: %d, field: %d.\n",
pll_lock, line_lock,
line_lock_strong, field_lock);
mix1_freq_cur = atv_dmd_rd_byte(APB_BLOCK_ADDR_MIXER_1, 0x0);
delta_mix1_freq = abs(mix1_freq_cur - mix1_freq);
if ((lock&0x1) == 0)
- pr_info("%s visual carrier lock:locked\n", __func__);
+ pr_dbg("%s visual carrier lock:locked\n", __func__);
else
- pr_info("%s visual carrier lock:unlocked\n", __func__);
+ pr_dbg("%s visual carrier lock:unlocked\n", __func__);
/* set_pll_lpf(lock); */
retrieve_frequency_offset(&freq_offset);
/* pr_info("visual carrier offset:%d Hz\n",*/
param->param.std = V4L2_STD_PAL;
switch (broad_std) {
case AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_DK:
- param->param.std |= V4L2_STD_PAL_DK;
+ param->param.std = V4L2_STD_PAL_DK;
param->param.audmode = V4L2_STD_PAL_DK;
break;
case AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_I:
- param->param.std |= V4L2_STD_PAL_I;
+ param->param.std = V4L2_STD_PAL_I;
param->param.audmode = V4L2_STD_PAL_I;
break;
case AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_BG:
- param->param.std |= V4L2_STD_PAL_BG;
+ param->param.std = V4L2_STD_PAL_BG;
param->param.audmode = V4L2_STD_PAL_BG;
break;
case AML_ATV_DEMOD_VIDEO_MODE_PROP_PAL_M:
- param->param.std |= V4L2_STD_PAL_M;
+ param->param.std = V4L2_STD_PAL_M;
param->param.audmode = V4L2_STD_PAL_M;
break;
default:
- param->param.std |= V4L2_STD_PAL_DK;
+ param->param.std = V4L2_STD_PAL_DK;
param->param.audmode = V4L2_STD_PAL_DK;
}
param->param.frequency += 1;