Skip to content

Commit 7e1f29a

Browse files
committed
Fix: clear the "PuPu" noise again after ac101 as Master
1 parent d3d95d0 commit 7e1f29a

File tree

2 files changed

+44
-30
lines changed

2 files changed

+44
-30
lines changed

ac101.c

Lines changed: 44 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -243,21 +243,14 @@ static int late_enable_dac(struct snd_soc_codec* codec, int event) {
243243
ac10x->dac_enable++;
244244
break;
245245
case SND_SOC_DAPM_POST_PMD:
246-
#if 0
247-
if (ac10x->dac_enable > 0){
248-
ac10x->dac_enable--;
249-
#else
250-
{
251-
#endif
252-
if (ac10x->dac_enable != 0){
253-
ac10x->dac_enable = 0;
254-
255-
ac101_update_bits(codec, DAC_DIG_CTRL, (0x1<<ENHPF),(0x0<<ENHPF));
256-
ac101_update_bits(codec, DAC_DIG_CTRL, (0x1<<ENDA), (0x0<<ENDA));
257-
/*disable dac module clk*/
258-
ac101_update_bits(codec, MOD_CLK_ENA, (0x1<<MOD_CLK_DAC_DIG), (0x0<<MOD_CLK_DAC_DIG));
259-
ac101_update_bits(codec, MOD_RST_CTRL, (0x1<<MOD_RESET_DAC_DIG), (0x0<<MOD_RESET_DAC_DIG));
260-
}
246+
if (ac10x->dac_enable != 0){
247+
ac10x->dac_enable = 0;
248+
249+
ac101_update_bits(codec, DAC_DIG_CTRL, (0x1<<ENHPF),(0x0<<ENHPF));
250+
ac101_update_bits(codec, DAC_DIG_CTRL, (0x1<<ENDA), (0x0<<ENDA));
251+
/*disable dac module clk*/
252+
ac101_update_bits(codec, MOD_CLK_ENA, (0x1<<MOD_CLK_DAC_DIG), (0x0<<MOD_CLK_DAC_DIG));
253+
ac101_update_bits(codec, MOD_RST_CTRL, (0x1<<MOD_RESET_DAC_DIG), (0x0<<MOD_RESET_DAC_DIG));
261254
}
262255
break;
263256
}
@@ -543,6 +536,30 @@ static const unsigned ac101_bclkdivs[] = {
543536
128, 192, 0, 0,
544537
};
545538

539+
static int ac101_aif_play(struct ac10x_priv* ac10x) {
540+
struct snd_soc_codec * codec = ac10x->codec;
541+
542+
late_enable_dac(codec, SND_SOC_DAPM_PRE_PMU);
543+
ac101_headphone_event(codec, SND_SOC_DAPM_POST_PMU);
544+
if (drc_used) {
545+
drc_enable(codec, 1);
546+
}
547+
548+
/* Enable Left & Right Speaker */
549+
ac101_update_bits(codec, SPKOUT_CTRL, (0x1 << LSPK_EN) | (0x1 << RSPK_EN), (0x1 << LSPK_EN) | (0x1 << RSPK_EN));
550+
if (ac10x->gpiod_spk_amp_gate) {
551+
gpiod_set_value(ac10x->gpiod_spk_amp_gate, 1);
552+
}
553+
return 0;
554+
}
555+
556+
static void ac10x_work_aif_play(struct work_struct *work) {
557+
struct ac10x_priv *ac10x = container_of(work, struct ac10x_priv, dlywork.work);
558+
559+
ac101_aif_play(ac10x);
560+
return;
561+
}
562+
546563
int ac101_aif_mute(struct snd_soc_dai *codec_dai, int mute)
547564
{
548565
struct snd_soc_codec *codec = codec_dai->codec;
@@ -555,22 +572,17 @@ int ac101_aif_mute(struct snd_soc_dai *codec_dai, int mute)
555572
if (!mute) {
556573
#if _MASTER_MULTI_CODEC != _MASTER_AC101
557574
/* enable global clock */
558-
ac101_aif1clk(static_ac10x->codec, SND_SOC_DAPM_PRE_PMU);
575+
ac10x->aif1_clken = 0;
576+
ac101_aif1clk(codec, SND_SOC_DAPM_PRE_PMU);
577+
ac101_aif_play(ac10x);
578+
#else
579+
schedule_delayed_work(&ac10x->dlywork, msecs_to_jiffies(50));
559580
#endif
560-
561-
late_enable_dac(codec, SND_SOC_DAPM_PRE_PMU);
562-
ac101_headphone_event(codec, SND_SOC_DAPM_POST_PMU);
563-
if (drc_used) {
564-
drc_enable(codec, 1);
565-
}
566-
567-
/* Enable Left & Right Speaker */
568-
ac101_update_bits(codec, SPKOUT_CTRL, (0x1 << LSPK_EN) | (0x1 << RSPK_EN), (0x1 << LSPK_EN) | (0x1 << RSPK_EN));
569-
if (ac10x->gpiod_spk_amp_gate) {
570-
gpiod_set_value(ac10x->gpiod_spk_amp_gate, 1);
571-
}
572-
573581
} else {
582+
#if _MASTER_MULTI_CODEC == _MASTER_AC101
583+
cancel_delayed_work_sync(&ac10x->dlywork);
584+
#endif
585+
574586
if (ac10x->gpiod_spk_amp_gate) {
575587
gpiod_set_value(ac10x->gpiod_spk_amp_gate, 1);
576588
}
@@ -603,6 +615,8 @@ void ac101_aif_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai
603615
if (!codec_dai->active) {
604616
ac10x->aif1_clken = 1;
605617
ac101_aif1clk(codec, SND_SOC_DAPM_POST_PMD);
618+
} else {
619+
ac101_aif1clk(codec, SND_SOC_DAPM_PRE_PMU);
606620
}
607621
}
608622

@@ -1013,6 +1027,7 @@ int ac101_codec_probe(struct snd_soc_codec *codec)
10131027
}
10141028
ac10x->codec = codec;
10151029

1030+
INIT_DELAYED_WORK(&ac10x->dlywork, ac10x_work_aif_play);
10161031
INIT_WORK(&ac10x->codec_resume, codec_resume_work);
10171032
ac10x->dac_enable = 0;
10181033
ac10x->aif1_clken = 0;

ac10x.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ struct ac10x_priv {
5858
u8 aif1_clken;
5959

6060
struct work_struct codec_resume;
61-
struct delayed_work dlywork101;
6261
struct gpio_desc* gpiod_spk_amp_gate;
6362
/* member for ac101 .end */
6463
};

0 commit comments

Comments
 (0)