Skip to content

Commit 0b26ca1

Browse files
oortcometbroonie
authored andcommitted
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>
1 parent 04a8374 commit 0b26ca1

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

sound/soc/codecs/rt5682s.c

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,8 @@ static int rt5682s_headset_detect(struct snd_soc_component *component, int jack_
779779
RT5682S_FAST_OFF_MASK, RT5682S_FAST_OFF_EN);
780780
snd_soc_component_update_bits(component, RT5682S_SAR_IL_CMD_1,
781781
RT5682S_SAR_SEL_MB1_2_MASK, val << RT5682S_SAR_SEL_MB1_2_SFT);
782-
rt5682s_sar_power_mode(component, SAR_PWR_SAVING, 1);
782+
if (!snd_soc_dapm_get_pin_status(&component->dapm, "SAR"))
783+
rt5682s_sar_power_mode(component, SAR_PWR_SAVING, 1);
783784
rt5682s_enable_push_button_irq(component);
784785
break;
785786
default:
@@ -1313,18 +1314,6 @@ static int is_using_asrc(struct snd_soc_dapm_widget *w,
13131314
}
13141315
}
13151316

1316-
static int is_headset_type(struct snd_soc_dapm_widget *w,
1317-
struct snd_soc_dapm_widget *sink)
1318-
{
1319-
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
1320-
struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component);
1321-
1322-
if ((rt5682s->jack_type & SND_JACK_HEADSET) == SND_JACK_HEADSET)
1323-
return 1;
1324-
1325-
return 0;
1326-
}
1327-
13281317
static int rt5682s_hp_amp_event(struct snd_soc_dapm_widget *w,
13291318
struct snd_kcontrol *kcontrol, int event)
13301319
{
@@ -1372,6 +1361,10 @@ static int sar_power_event(struct snd_soc_dapm_widget *w,
13721361
struct snd_kcontrol *kcontrol, int event)
13731362
{
13741363
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
1364+
struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component);
1365+
1366+
if ((rt5682s->jack_type & SND_JACK_HEADSET) != SND_JACK_HEADSET)
1367+
return 0;
13751368

13761369
switch (event) {
13771370
case SND_SOC_DAPM_PRE_PMU:
@@ -1784,7 +1777,7 @@ static const struct snd_soc_dapm_route rt5682s_dapm_routes[] = {
17841777
{"CLKDET SYS", NULL, "MCLK0 DET PWR"},
17851778

17861779
{"BST1 CBJ", NULL, "IN1P"},
1787-
{"BST1 CBJ", NULL, "SAR", is_headset_type},
1780+
{"BST1 CBJ", NULL, "SAR"},
17881781

17891782
{"RECMIX1L", "CBJ Switch", "BST1 CBJ"},
17901783
{"RECMIX1L", NULL, "RECMIX1L Power"},
@@ -1890,7 +1883,7 @@ static const struct snd_soc_dapm_route rt5682s_dapm_routes[] = {
18901883
{"HP Amp", NULL, "DAC L1"},
18911884
{"HP Amp", NULL, "DAC R1"},
18921885
{"HP Amp", NULL, "CLKDET SYS"},
1893-
{"HP Amp", NULL, "SAR", is_headset_type},
1886+
{"HP Amp", NULL, "SAR"},
18941887

18951888
{"HPOL", NULL, "HP Amp"},
18961889
{"HPOR", NULL, "HP Amp"},
@@ -2823,8 +2816,9 @@ static int rt5682s_resume(struct snd_soc_component *component)
28232816

28242817
if (rt5682s->hs_jack) {
28252818
rt5682s->jack_type = 0;
2819+
rt5682s_sar_power_mode(component, SAR_PWR_NORMAL, 0);
28262820
mod_delayed_work(system_power_efficient_wq,
2827-
&rt5682s->jack_detect_work, msecs_to_jiffies(250));
2821+
&rt5682s->jack_detect_work, msecs_to_jiffies(0));
28282822
}
28292823

28302824
return 0;

0 commit comments

Comments
 (0)