diff options
author | Derek Fang <derek.fang@realtek.com> | 2021-10-01 15:41:13 +0800 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2021-10-01 19:35:04 +0100 |
commit | 0b26ca1725fa16a2d28a86f89173f9df2a3fe8d7 (patch) | |
tree | 0ad3830893dcf323aeb52b40db3ccb9f7e15b67b /sound/soc | |
parent | 04a8374c321db55834d5a9f3a9ceecb04b3cfbf5 (diff) | |
download | linux-0b26ca1725fa16a2d28a86f89173f9df2a3fe8d7.tar.gz linux-0b26ca1725fa16a2d28a86f89173f9df2a3fe8d7.tar.bz2 linux-0b26ca1725fa16a2d28a86f89173f9df2a3fe8d7.zip |
ASoC: rt5682s: Fix HP noise caused by SAR mode switch when the system resumes
When the system resumes from S3, if the system plays a beep,
there is continuous "Zizi.." noise from HP that could be heard.
It is caused by the SAR mode switch during the combo jack
re-detection which be executed parallelly in a workqueue
after the system resumes.
This patch changes the behavior of SAR mode switch to
avoid this issue.
Signed-off-by: Derek Fang <derek.fang@realtek.com>
Link: https://lore.kernel.org/r/20211001074113.2223-2-derek.fang@realtek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc')
-rw-r--r-- | sound/soc/codecs/rt5682s.c | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/sound/soc/codecs/rt5682s.c b/sound/soc/codecs/rt5682s.c index 5ae54a51ff9e..639a50fa95e2 100644 --- a/sound/soc/codecs/rt5682s.c +++ b/sound/soc/codecs/rt5682s.c @@ -779,7 +779,8 @@ static int rt5682s_headset_detect(struct snd_soc_component *component, int jack_ RT5682S_FAST_OFF_MASK, RT5682S_FAST_OFF_EN); snd_soc_component_update_bits(component, RT5682S_SAR_IL_CMD_1, RT5682S_SAR_SEL_MB1_2_MASK, val << RT5682S_SAR_SEL_MB1_2_SFT); - rt5682s_sar_power_mode(component, SAR_PWR_SAVING, 1); + if (!snd_soc_dapm_get_pin_status(&component->dapm, "SAR")) + rt5682s_sar_power_mode(component, SAR_PWR_SAVING, 1); rt5682s_enable_push_button_irq(component); break; default: @@ -1313,18 +1314,6 @@ static int is_using_asrc(struct snd_soc_dapm_widget *w, } } -static int is_headset_type(struct snd_soc_dapm_widget *w, - struct snd_soc_dapm_widget *sink) -{ - struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); - struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component); - - if ((rt5682s->jack_type & SND_JACK_HEADSET) == SND_JACK_HEADSET) - return 1; - - return 0; -} - static int rt5682s_hp_amp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { @@ -1372,6 +1361,10 @@ static int sar_power_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component); + + if ((rt5682s->jack_type & SND_JACK_HEADSET) != SND_JACK_HEADSET) + return 0; switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -1784,7 +1777,7 @@ static const struct snd_soc_dapm_route rt5682s_dapm_routes[] = { {"CLKDET SYS", NULL, "MCLK0 DET PWR"}, {"BST1 CBJ", NULL, "IN1P"}, - {"BST1 CBJ", NULL, "SAR", is_headset_type}, + {"BST1 CBJ", NULL, "SAR"}, {"RECMIX1L", "CBJ Switch", "BST1 CBJ"}, {"RECMIX1L", NULL, "RECMIX1L Power"}, @@ -1890,7 +1883,7 @@ static const struct snd_soc_dapm_route rt5682s_dapm_routes[] = { {"HP Amp", NULL, "DAC L1"}, {"HP Amp", NULL, "DAC R1"}, {"HP Amp", NULL, "CLKDET SYS"}, - {"HP Amp", NULL, "SAR", is_headset_type}, + {"HP Amp", NULL, "SAR"}, {"HPOL", NULL, "HP Amp"}, {"HPOR", NULL, "HP Amp"}, @@ -2823,8 +2816,9 @@ static int rt5682s_resume(struct snd_soc_component *component) if (rt5682s->hs_jack) { rt5682s->jack_type = 0; + rt5682s_sar_power_mode(component, SAR_PWR_NORMAL, 0); mod_delayed_work(system_power_efficient_wq, - &rt5682s->jack_detect_work, msecs_to_jiffies(250)); + &rt5682s->jack_detect_work, msecs_to_jiffies(0)); } return 0; |