atv_demod: optimize the stereo audio recognition [1/1]

PD#TV-3569

Problem:
optimize the stereo audio recognition.

Solution:
1.optimize the stereo audio recognition.
2.remove redundant code.
3.atv demod version: V2.10.

Verify:
verified by x301.

Change-Id: If8933bdd897a7c3e6b6ff9753d7ff971a0432ef9
Signed-off-by: nengwen.chen <nengwen.chen@amlogic.com>
This commit is contained in:
nengwen.chen
2019-04-16 16:35:41 +08:00
committed by Tao Zeng
parent 1ace6fc01d
commit eb55931268
8 changed files with 48 additions and 40 deletions

View File

@@ -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)

View File

@@ -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;

View File

@@ -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);

View File

@@ -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;
}
}

View File

@@ -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);

View File

@@ -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:

View File

@@ -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;

View File

@@ -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,