diff --git a/drivers/amlogic/atv_demod/atv_demod_debug.c b/drivers/amlogic/atv_demod/atv_demod_debug.c index 284eeb838218..a29da9cce6fe 100644 --- a/drivers/amlogic/atv_demod/atv_demod_debug.c +++ b/drivers/amlogic/atv_demod/atv_demod_debug.c @@ -118,6 +118,7 @@ DEBUGFS_CREATE_FILE(sum2_thd_l, 0640, dentry, fops, int)\ DEBUGFS_CREATE_FILE(afc_default, 0640, dentry, fops, int)\ DEBUGFS_CREATE_FILE(snr_threshold, 0640, dentry, fops, int)\ + DEBUGFS_CREATE_FILE(snr_val, 0640, dentry, fops, int)\ } @@ -134,6 +135,7 @@ DEBUGFS_DENTRY_DEFINE(sum2_thd_h); DEBUGFS_DENTRY_DEFINE(sum2_thd_l); DEBUGFS_DENTRY_DEFINE(afc_default); DEBUGFS_DENTRY_DEFINE(snr_threshold); +DEBUGFS_DENTRY_DEFINE(snr_val); struct dentry_value *debugfs_dentry[] = { DEBUGFS_DENTRY_VALUE(non_std_thld_4c_h), @@ -146,6 +148,7 @@ struct dentry_value *debugfs_dentry[] = { DEBUGFS_DENTRY_VALUE(sum2_thd_l), DEBUGFS_DENTRY_VALUE(afc_default), DEBUGFS_DENTRY_VALUE(snr_threshold), + DEBUGFS_DENTRY_VALUE(snr_val), }; static int debugfs_open(struct inode *node, struct file *file) diff --git a/drivers/amlogic/atv_demod/atv_demod_driver.c b/drivers/amlogic/atv_demod/atv_demod_driver.c index 02d21fcca595..dd165b38520e 100644 --- a/drivers/amlogic/atv_demod/atv_demod_driver.c +++ b/drivers/amlogic/atv_demod/atv_demod_driver.c @@ -45,7 +45,7 @@ #include "atvauddemod_func.h" -#define AMLATVDEMOD_VER "V2.09" +#define AMLATVDEMOD_VER "V2.10" struct aml_atvdemod_device *amlatvdemod_devp; @@ -560,6 +560,7 @@ int aml_attach_tuner(struct aml_atvdemod_device *dev) void *p = NULL; struct v4l2_frontend *v4l2_fe = &dev->v4l2_fe; struct dvb_frontend *fe = &v4l2_fe->fe; + struct atv_demod_priv *priv = fe->analog_demod_priv; struct tuner_config *cfg = NULL; if (dev->tuner_cur < 0) { @@ -598,9 +599,7 @@ int aml_attach_tuner(struct aml_atvdemod_device *dev) if (p != NULL) { dev->tuner_attached = true; - v4l2_fe->tuner_id = cfg->id; - v4l2_fe->i2c.addr = cfg->i2c_addr; - v4l2_fe->i2c.adapter = dev->tuners[dev->tuner_cur].i2c_adp; + priv->atvdemod_param.tuner_id = cfg->id; } else { pr_err("%s: attach tuner [%d] error.\n", __func__, cfg->id); return -1; diff --git a/drivers/amlogic/atv_demod/atv_demod_ops.c b/drivers/amlogic/atv_demod/atv_demod_ops.c index 2c442d358878..9feb01e7765b 100644 --- a/drivers/amlogic/atv_demod/atv_demod_ops.c +++ b/drivers/amlogic/atv_demod/atv_demod_ops.c @@ -543,6 +543,8 @@ static void atvdemod_fe_try_analog_format(struct v4l2_frontend *v4l2_fe, struct dvb_frontend *fe = &v4l2_fe->fe; struct v4l2_analog_parameters *p = &v4l2_fe->params; struct analog_parameters params; + struct atv_demod_priv *priv = fe->analog_demod_priv; + unsigned int tuner_id = priv->atvdemod_param.tuner_id; int i = 0; int try_vfmt_cnt = 300; int varify_cnt = 0; @@ -564,8 +566,8 @@ static void atvdemod_fe_try_analog_format(struct v4l2_frontend *v4l2_fe, pr_dbg("get cvbs_std varify_cnt:%d, cnt:%d, cvbs_std:0x%x\n", varify_cnt, i, (unsigned int) cvbs_std); - if (((v4l2_fe->tuner_id == AM_TUNER_R840 - || v4l2_fe->tuner_id == AM_TUNER_R842) + if (((tuner_id == AM_TUNER_R840 + || tuner_id == AM_TUNER_R842) && varify_cnt > 0) || varify_cnt > 3) break; @@ -703,6 +705,7 @@ static int atvdemod_fe_afc_closer(struct v4l2_frontend *v4l2_fe, int minafcfreq, struct dvb_frontend *fe = &v4l2_fe->fe; struct v4l2_analog_parameters *p = &v4l2_fe->params; struct analog_parameters params; + struct atv_demod_priv *priv = fe->analog_demod_priv; int afc = 100; __u32 set_freq; int count = 25; @@ -711,7 +714,7 @@ static int atvdemod_fe_afc_closer(struct v4l2_frontend *v4l2_fe, int minafcfreq, static int temp_freq, temp_afc; struct timespec time_now; static struct timespec success_time; - unsigned int tuner_id = v4l2_fe->tuner_id; + unsigned int tuner_id = priv->atvdemod_param.tuner_id; pr_dbg("[%s] freq_success: %d, freq: %d, minfreq: %d, maxfreq: %d\n", __func__, freq_success, p->frequency, minafcfreq, maxafcfreq); @@ -937,7 +940,7 @@ static enum v4l2_search atvdemod_fe_search(struct v4l2_frontend *v4l2_fe) int search_count = 0; /* bool try_secam = false; */ int ret = -1; - unsigned int tuner_id = v4l2_fe->tuner_id; + unsigned int tuner_id = 0; int priv_cfg = 0; if (unlikely(!fe || !p || @@ -960,6 +963,8 @@ static enum v4l2_search atvdemod_fe_search(struct v4l2_frontend *v4l2_fe) return V4L2_SEARCH_INVALID; } + tuner_id = priv->atvdemod_param.tuner_id; + pr_info("[%s] afc_range: [%d], tuner: [%d], freq: [%d], flag: [%d].\n", __func__, p->afc_range, tuner_id, p->frequency, p->flag); diff --git a/drivers/amlogic/atv_demod/atv_demod_v4l2.c b/drivers/amlogic/atv_demod/atv_demod_v4l2.c index 7e4fb017c422..2db6a35590b7 100644 --- a/drivers/amlogic/atv_demod/atv_demod_v4l2.c +++ b/drivers/amlogic/atv_demod/atv_demod_v4l2.c @@ -602,7 +602,6 @@ static int v4l2_property_process_set(struct v4l2_frontend *v4l2_fe, v4l2_fe->fe.ops.tuner_ops.release(&v4l2_fe->fe); } - v4l2_fe->tuner_id = id; if (aml_attach_tuner(amlatvdemod_devp) < 0) { pr_err("%s: attach tuner %d error.\n", __func__, id); @@ -823,8 +822,8 @@ static int v4l2_frontend_open(struct file *filp) if (!amlatvdemod_devp->analog_attached) { ret = aml_attach_demod(amlatvdemod_devp); if (ret < 0) { - pr_err("%s: attach demod %d error.\n", - __func__, v4l2_fe->tuner_id); + pr_err("%s: line %d, error ret %d.\n", + __func__, __LINE__, ret); return -EBUSY; } } @@ -832,8 +831,8 @@ static int v4l2_frontend_open(struct file *filp) if (!amlatvdemod_devp->tuner_attached) { ret = aml_attach_tuner(amlatvdemod_devp); if (ret < 0) { - pr_err("%s: attach tuner %d error.\n", - __func__, v4l2_fe->tuner_id); + pr_err("%s: line %d, error ret %d.\n", + __func__, __LINE__, ret); return -EBUSY; } } diff --git a/drivers/amlogic/atv_demod/atv_demod_v4l2.h b/drivers/amlogic/atv_demod/atv_demod_v4l2.h index 6fc3078090e4..b944ab93b23d 100644 --- a/drivers/amlogic/atv_demod/atv_demod_v4l2.h +++ b/drivers/amlogic/atv_demod/atv_demod_v4l2.h @@ -183,9 +183,6 @@ struct v4l2_adapter { struct device *dev; struct dvb_frontend fe; - - struct i2c_client i2c; - unsigned int tuner_id; }; struct v4l2_frontend_ops { @@ -201,8 +198,6 @@ struct v4l2_frontend { struct device *dev; struct dvb_frontend fe; - unsigned int tuner_id; - struct i2c_client i2c; enum v4l2_tuner_type mode; @@ -224,9 +219,6 @@ struct v4l2_atvdemod_device { struct video_device *video_dev; struct mutex lock; - - struct i2c_client i2c; - unsigned int tuner_id; }; int v4l2_resister_frontend(struct v4l2_frontend *v4l2_fe); diff --git a/drivers/amlogic/atv_demod/atvauddemod_func.c b/drivers/amlogic/atv_demod/atvauddemod_func.c index e472216c7c47..1eb56505e85e 100644 --- a/drivers/amlogic/atv_demod/atvauddemod_func.c +++ b/drivers/amlogic/atv_demod/atvauddemod_func.c @@ -392,9 +392,9 @@ void set_a2k(void) adec_wr_reg(ADDR_LPR_GAIN_ADJ, 0x3e0); adec_wr_reg(ADDR_LPR_COMP_CTRL, 0x010); - adec_wr_reg(ADDR_IIR_SPEED_CTRL, 0xff5d7f7f/*0xd65d7f7f*/); - adec_wr_reg(STEREO_DET_THD, 0x4000); - adec_wr_reg(DUAL_DET_THD, 0x4000); + adec_wr_reg(ADDR_IIR_SPEED_CTRL, 0xd65d7f7f); + adec_wr_reg(STEREO_DET_THD, 0x1000); + adec_wr_reg(DUAL_DET_THD, 0x1000); adec_wr_reg((ADDR_SEL_CTRL), 0x1000); } @@ -430,9 +430,9 @@ void set_a2g(void) adec_wr_reg(ADDR_LPR_GAIN_ADJ, 0x3e0); adec_wr_reg(ADDR_LPR_COMP_CTRL, 0x010); - adec_wr_reg(ADDR_IIR_SPEED_CTRL, 0xff5d7f7f/*0xd65d7f7f*/); - adec_wr_reg(STEREO_DET_THD, 0x4000); - adec_wr_reg(DUAL_DET_THD, 0x4000); + adec_wr_reg(ADDR_IIR_SPEED_CTRL, 0xd65d7f7f); + adec_wr_reg(STEREO_DET_THD, 0x1000); + adec_wr_reg(DUAL_DET_THD, 0x1000); } void set_a2bg(void) @@ -466,9 +466,9 @@ void set_a2bg(void) adec_wr_reg(ADDR_LPR_GAIN_ADJ, 0x3e0); adec_wr_reg(ADDR_LPR_COMP_CTRL, 0x010); - adec_wr_reg(ADDR_IIR_SPEED_CTRL, 0xff5d7f7f/*0xd65d7f7f*/); - adec_wr_reg(STEREO_DET_THD, 0x4000); - adec_wr_reg(DUAL_DET_THD, 0x4000); + adec_wr_reg(ADDR_IIR_SPEED_CTRL, 0xd65d7f7f); + adec_wr_reg(STEREO_DET_THD, 0x1000); + adec_wr_reg(DUAL_DET_THD, 0x1000); } void set_a2dk1(void) @@ -502,9 +502,9 @@ void set_a2dk1(void) adec_wr_reg(ADDR_LPR_GAIN_ADJ, 0x3e0); adec_wr_reg(ADDR_LPR_COMP_CTRL, 0x010); - adec_wr_reg(ADDR_IIR_SPEED_CTRL, 0xff5d7f7f/*0xd65d7f7f*/); - adec_wr_reg(STEREO_DET_THD, 0x4000); - adec_wr_reg(DUAL_DET_THD, 0x4000); + adec_wr_reg(ADDR_IIR_SPEED_CTRL, 0xd65d7f7f); + adec_wr_reg(STEREO_DET_THD, 0x1000); + adec_wr_reg(DUAL_DET_THD, 0x1000); } void set_a2dk2(void) @@ -538,9 +538,9 @@ void set_a2dk2(void) adec_wr_reg(ADDR_LPR_GAIN_ADJ, 0x3e0); adec_wr_reg(ADDR_LPR_COMP_CTRL, 0x010); - adec_wr_reg(ADDR_IIR_SPEED_CTRL, 0xff5d7f7f/*0xd65d7f7f*/); - adec_wr_reg(STEREO_DET_THD, 0x4000); - adec_wr_reg(DUAL_DET_THD, 0x4000); + adec_wr_reg(ADDR_IIR_SPEED_CTRL, 0xd65d7f7f); + adec_wr_reg(STEREO_DET_THD, 0x1000); + adec_wr_reg(DUAL_DET_THD, 0x1000); } void set_a2dk3(void) @@ -574,9 +574,9 @@ void set_a2dk3(void) adec_wr_reg(ADDR_LPR_GAIN_ADJ, 0x3e0); adec_wr_reg(ADDR_LPR_COMP_CTRL, 0x010); - adec_wr_reg(ADDR_IIR_SPEED_CTRL, 0xff5d7f7f/*0xd65d7f7f*/); - adec_wr_reg(STEREO_DET_THD, 0x4000); - adec_wr_reg(DUAL_DET_THD, 0x4000); + adec_wr_reg(ADDR_IIR_SPEED_CTRL, 0xd65d7f7f); + adec_wr_reg(STEREO_DET_THD, 0x1000); + adec_wr_reg(DUAL_DET_THD, 0x1000); } void set_eiaj(void) @@ -1402,6 +1402,15 @@ void set_outputmode(uint32_t standard, uint32_t outmode) case AUDIO_STANDARD_A2_DK1: case AUDIO_STANDARD_A2_DK2: case AUDIO_STANDARD_A2_DK3: + if (standard != AUDIO_STANDARD_EIAJ + && !aud_reinit + && atvdemod_get_snr_val() < 50) { + /* Fixed weak signal, unstable */ + adec_wr_reg(ADDR_IIR_SPEED_CTRL, 0xff5d7f7f); + adec_wr_reg(STEREO_DET_THD, 0x4000); + adec_wr_reg(DUAL_DET_THD, 0x4000); + } + set_a2_eiaj_outputmode(outmode); break; case AUDIO_STANDARD_NICAM_DK: diff --git a/drivers/amlogic/atv_demod/atvdemod_func.c b/drivers/amlogic/atv_demod/atvdemod_func.c index 69399af0ad7b..de89d459bb4e 100644 --- a/drivers/amlogic/atv_demod/atvdemod_func.c +++ b/drivers/amlogic/atv_demod/atvdemod_func.c @@ -111,7 +111,7 @@ enum AUDIO_SCAN_ID { }; static unsigned int mix1_freq; -static int snr_val; +int snr_val; int broad_std_except_pal_m; diff --git a/drivers/amlogic/atv_demod/atvdemod_func.h b/drivers/amlogic/atv_demod/atvdemod_func.h index 57149c934722..40dfe16c23ae 100644 --- a/drivers/amlogic/atv_demod/atvdemod_func.h +++ b/drivers/amlogic/atv_demod/atvdemod_func.h @@ -27,6 +27,7 @@ extern int broad_std_except_pal_m; extern unsigned int aud_std; extern unsigned int aud_mode; extern bool audio_thd_en; +extern bool aud_reinit; enum broadcast_standard_e { ATVDEMOD_STD_NTSC = 0,