From 7b0ef35d93e94ef357a3909a222f64122c5ebb3d Mon Sep 17 00:00:00 2001 From: Shuai Li Date: Mon, 22 Apr 2019 10:52:18 +0800 Subject: [PATCH] audio: enable hw resmaple pause thd [1/1] PD#TV-4638 Problem: Speaker output high frequency howling after change from pattern 615 to pattern 1 on chroma22294. The hw resampler keeps sending noise if it has no input. Solution: Enable the hw resample pause thd by default. Verify: TL1 X301. Change-Id: Ib6f0924025e155eaa8ba0e3681b307f7ff56b449 Signed-off-by: Shuai Li --- sound/soc/amlogic/auge/resample.c | 15 ++++++++------- sound/soc/amlogic/auge/resample_hw.c | 11 +++++++++++ sound/soc/amlogic/auge/resample_hw.h | 1 + 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/sound/soc/amlogic/auge/resample.c b/sound/soc/amlogic/auge/resample.c index 8678361..f3a9948 100644 --- a/sound/soc/amlogic/auge/resample.c +++ b/sound/soc/amlogic/auge/resample.c @@ -271,18 +271,19 @@ int resample_set(enum resample_idx id, enum samplerate_index index) struct audioresample *p_resample = get_audioresample(id); int ret = 0; + if (!p_resample) + return 0; + pr_info("%s resample_%c to %s, last %s\n", __func__, (id == RESAMPLE_A) ? 'a' : 'b', auge_resample_texts[index], auge_resample_texts[p_resample->asrc_rate_idx]); - if (!p_resample) +#if 0 + if (index == p_resample->asrc_rate_idx) return 0; - - //if (index == p_resample->asrc_rate_idx) - // return 0; - +#endif p_resample->asrc_rate_idx = index; resample_rate = resample_idx2rate(index); @@ -443,7 +444,7 @@ static const struct snd_kcontrol_new asrc_a_controls[] = { mixer_audiobus_read, mixer_audiobus_write, NULL), SOC_SINGLE_EXT_TLV("Hw resample pause thd", - EE_AUDIO_RESAMPLEA_CTRL2, 0, 0xffffff, 0, + EE_AUDIO_RESAMPLEA_CTRL2, 11, 0x1fff, 0, mixer_audiobus_read, mixer_audiobus_write, NULL), SOC_ENUM_EXT("Hw resample module", @@ -462,7 +463,7 @@ static const struct snd_kcontrol_new asrc_b_controls[] = { mixer_audiobus_read, mixer_audiobus_write, NULL), SOC_SINGLE_EXT_TLV("Hw resample b pause thd", - EE_AUDIO_RESAMPLEB_CTRL2, 0, 0xffffff, 0, + EE_AUDIO_RESAMPLEB_CTRL2, 11, 0x1fff, 0, mixer_audiobus_read, mixer_audiobus_write, NULL), SOC_ENUM_EXT("Hw resample b module", diff --git a/sound/soc/amlogic/auge/resample_hw.c b/sound/soc/amlogic/auge/resample_hw.c index 03ca3aa..73c7dd3 100644 --- a/sound/soc/amlogic/auge/resample_hw.c +++ b/sound/soc/amlogic/auge/resample_hw.c @@ -115,6 +115,7 @@ int resample_set_hw_param(enum resample_idx id, reg = EE_AUDIO_RESAMPLEA_CTRL2 + offset * id; audiobus_update_bits(reg, 1 << 25, 1 << 25); + resample_set_hw_pause_thd(id, 128); return 0; } @@ -160,3 +161,13 @@ void resample_ctrl_write(enum resample_idx id, int value) audiobus_write(reg, value); } + +int resample_set_hw_pause_thd(enum resample_idx id, unsigned int thd) +{ + int offset = EE_AUDIO_RESAMPLEB_CTRL2 - EE_AUDIO_RESAMPLEA_CTRL2; + int reg = EE_AUDIO_RESAMPLEA_CTRL2 + offset * id; + + audiobus_write(reg, 1 << 24 | thd << 11); + + return 0; +} diff --git a/sound/soc/amlogic/auge/resample_hw.h b/sound/soc/amlogic/auge/resample_hw.h index 5d7c3dd..61b0629 100644 --- a/sound/soc/amlogic/auge/resample_hw.h +++ b/sound/soc/amlogic/auge/resample_hw.h @@ -41,5 +41,6 @@ extern void resample_format_set(enum resample_idx id, int ch_num, int bits); extern int resample_ctrl_read(enum resample_idx id); extern void resample_ctrl_write(enum resample_idx id, int value); +int resample_set_hw_pause_thd(enum resample_idx id, unsigned int thd); #endif -- 2.7.4