2020-07-16 11:51:14

by Alper Nebi Yasak

[permalink] [raw]
Subject: Speaker pops with max98357a on rk3399-gru-kevin since v5.7

Hi,

I have been getting "pop" sounds from the speaker on my rk3399-gru-kevin
for a while, and bisected it to 128f825aeab7 ("ASoC: max98357a: move
control of SD_MODE to DAPM"), but looks like the pops were somewhat
expected:

On 12 Feb 2020 13:55:15 +0800, Tzung-Bi Shih wrote [1]:
> Possible drawback: may generate pop noise when BCLK=on but LRCLK=off.
> As the datasheet[2] mentioned:
> > Do not remove LRCLK while BCLK is present.
> > Removing LRCLK while BCLK is present can cause unexpected output behavior
> > including a large DC output voltage.

[1] https://lore.kernel.org/alsa-devel/[email protected]/

As of v5.8-rc5 I'm still getting the speaker pops. More info below, but
not all pops coincide with "set sdmode" messages, and vice versa.
Reverting that commit stops the pops, but then the "Speakers Switch" can
no longer mute the speakers.

I don't really know much about these things, could anyone have a look at
it? I'll try to read relevant documentation and code to make sense of it,
but wanted to send an email in case there is an immediately obvious
solution (besides reverting) and maybe just nobody had the time to
implement it yet.

Thanks in advance.

---

I've experimented a bit on a Debian userspace (with #define DEBUG 1
to get sdmode messages), here's what happens without PulseAudio:
- When playback starts, speaker pops with "set sdmode to 1".
- During playback, toggling "Speakers Switch" sets sdmode to 0/1 and
mutes/unmutes speakers without any pops.
- Pausing/resuming playback (like seeking on a media player) make pops
without changing sdmode. Also pops when playback ends (e.g. when
"speaker-test -l 1" quits).
- A few seconds after playback ends, speaker pops for the last time with
"set sdmode to 0".
- Within that few seconds, toggling "Speakers Switch" sets sdmode to 0/1
and makes a pop each time.

It's mostly the same with PulseAudio but:
- Pause/resume during playback doesn't make any pops.
- The penultimate pop happens a few seconds after playback stops, when
PA says it's suspending the max98357a device (no sdmode changes).
- The final pop comes a few seconds after that (still with "set sdmode
to 0").

Even without any playback it makes several pops during boot when e.g.
PulseAudio starts/stops running in the display manager or in the user
session.


2020-07-17 02:28:59

by Tzung-Bi Shih

[permalink] [raw]
Subject: Re: Speaker pops with max98357a on rk3399-gru-kevin since v5.7

On Thu, Jul 16, 2020 at 7:49 PM Alper Nebi Yasak
<[email protected]> wrote:
> I have been getting "pop" sounds from the speaker on my rk3399-gru-kevin
> for a while, and bisected it to 128f825aeab7 ("ASoC: max98357a: move
> control of SD_MODE to DAPM"), but looks like the pops were somewhat
> expected:

I am not convinced the pop comes from 128f825aeab7.

> As of v5.8-rc5 I'm still getting the speaker pops. More info below, but
> not all pops coincide with "set sdmode" messages, and vice versa.
> Reverting that commit stops the pops, but then the "Speakers Switch" can
> no longer mute the speakers.

(I don't have a rk3399-gru-kevin so I got another test machine with MAX98357A.)
(I was testing with and without an audio server.)
Observations:
- I can hear the pop either with or without 128f825aeab7 (with and
without sdmode-delay).
- The pop noise is not always. Higher probability after stopping
playback than before starting.
- As you also mentioned, the pop noise is not directly related to
SD_MODE transition.

2020-07-20 22:41:22

by Alper Nebi Yasak

[permalink] [raw]
Subject: Re: Speaker pops with max98357a on rk3399-gru-kevin since v5.7

On 17/07/2020 05:27, Tzung-Bi Shih wrote:
> I am not convinced the pop comes from 128f825aeab7.

Maybe some pre-existing defect in rk3399_gru_sound got exposed by
128f825aeab7 or the machine driver needs some changes to complement
that commit?

> (I don't have a rk3399-gru-kevin so I got another test machine with MAX98357A.)
> (I was testing with and without an audio server.)

Your observations are also a bit different from mine, which IMO also
suggests the machine driver is the true culprit -- I'd guess the pops
you hear would be from a different problem in your test machine's
machine driver?

(Let me restate my observations to contrast with yours, as I feel my
previous explanation was too wordy:)

> Observations:
> - I can hear the pop either with or without 128f825aeab7 (with and
> without sdmode-delay).

I never hear pops without 128f825aeab7, but always hear pops with it.
(no change when I remove "sdmode-delay" from the device-tree)

> - The pop noise is not always. Higher probability after stopping
> playback than before starting.

I always hear one pop when starting playback, and two pops (with a few
seconds between them) when stopping playback.

2020-07-21 11:49:37

by Tzung-Bi Shih

[permalink] [raw]
Subject: Re: Speaker pops with max98357a on rk3399-gru-kevin since v5.7

On Tue, Jul 21, 2020 at 6:40 AM Alper Nebi Yasak
<[email protected]> wrote:
>
> On 17/07/2020 05:27, Tzung-Bi Shih wrote:
> > I am not convinced the pop comes from 128f825aeab7.
>
> Maybe some pre-existing defect in rk3399_gru_sound got exposed by
> 128f825aeab7 or the machine driver needs some changes to complement
> that commit?

Hi, I got a rk3399-gru-kevin and can reproduce the issue.

Could you take a try on the proposed patch here
https://patchwork.kernel.org/patch/11675533/ to see if it fixes?

2020-07-21 13:33:12

by Alper Nebi Yasak

[permalink] [raw]
Subject: Re: Speaker pops with max98357a on rk3399-gru-kevin since v5.7

On 21/07/2020 14:46, Tzung-Bi Shih wrote:
> Hi, I got a rk3399-gru-kevin and can reproduce the issue.
>
> Could you take a try on the proposed patch here
> https://patchwork.kernel.org/patch/11675533/ to see if it fixes?

It does eliminate the pops, thanks.

(I've replied to the patch, I am sending this for completeness as the Cc
list isn't exactly the same.)