Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>
To: "David Márquez" <davidmarquezfernandez@gmail.com>,
	linux-sound@vger.kernel.org
Cc: sound-open-firmware@alsa-project.org, broonie@kernel.org,
	kai.vehmanen@linux.intel.com
Subject: Re: [BUG] ASoC: Intel: sof_es8336: speaker amp GPIO stays off after stream stop/restart (no sound until "Speaker Switch" is toggled)
Date: Mon, 5 Oct 2026 13:22:10 +0200	[thread overview]
Message-ID: <33d869bc-ec8a-4d9e-8ba4-350bddce7ccf@linux.dev> (raw)
In-Reply-To: <CAFmy3_zQ1VNUJJ9H1kkvHxf50Pg9AQ4H1rXZbyz6-zxJxcYowg@mail.gmail.com>


> Problem
> -------
> The speaker randomly goes silent, typically when a browser stops and
> restarts playback (for example YouTube ad transitions). While it is
> silent the PCM is RUNNING and hw_ptr advances at 48 kHz, PipeWire reports
> no errors, the ALSA mixer is unchanged and nothing is logged in dmesg.
> Toggling "Speaker Switch" off and on restores the sound without closing
> the PCM. Before I worked around it, this happened 15 times in about 10
> hours of use on one day.
my money is on the asymmetric code structure which mixes DAPM and stream
triggers, see below.

> Evidence
> --------
> I captured the full DAPM debugfs tree, the ES8336 regmap registers and
> /sys/kernel/debug/gpio in the broken and in the working state. Everything
> is identical (including "Speaker Power: On" and "Speaker: On") except the
> speaker enable GPIO:
> 
>   broken:   gpio-541 (speakers-enable) out lo ACTIVE LOW
>   working:  gpio-541 (speakers-enable) out hi ACTIVE LOW
> 
> Setting pmdown_time to 0 on the codec and BE links did not prevent it.
> 
> Analysis
> --------
> In sound/soc/intel/boards/sof_es8336.c, sof_8336_trigger() drives the
> speaker GPIO to the "off" level on PAUSE_PUSH, SUSPEND and STOP without
> updating priv->speaker_en, while START, PAUSE_RELEASE and RESUME do
> nothing. The GPIO is only restored by sof_es8316_speaker_power_event()
> when DAPM actually powers the "Speaker Power" supply down and up again.
> If the stream is stopped and started again without that full power
> cycle, nothing re-enables the amplifier: the GPIO stays off while DAPM
> still considers the speaker on. I have not determined which exact path
> triggers it on my machine (pause/resume, xrun recovery, or a restart
> within pmdown_time).

Does this happen if the time between stop and restart is greater than
3s, or only when the delta is really short? In the latter case, IIRC
there's a DAPM feature where the power down happens with a delay, to
avoid unnecessary power transitions. so if the new stream starts
immediately, then the power-up transition will never happen.

> Proposed change (sketch, not a formal patch)
> --------------------------------------------
> Re-enable the amplifier on resume when the driver believes it is on:
> 
> case SNDRV_PCM_TRIGGER_START:
> case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
> case SNDRV_PCM_TRIGGER_RESUME:
> + if (substream->stream == 0 && priv->speaker_en == false)
> + schedule_delayed_work(&priv->pcm_pop_work,
> +      msecs_to_jiffies(70));
> break;

alternatively you could deal with power management only in
sof_es8316_speaker_power_event(), and completely remove the transitions
on trigger start/stop/pause. In general it's a bad idea to add delays to
the trigger, it's supposed to be real fast.



  reply	other threads:[~2026-10-05 12:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-04 17:12 [BUG] ASoC: Intel: sof_es8336: speaker amp GPIO stays off after stream stop/restart (no sound until "Speaker Switch" is toggled) David Márquez
2026-10-05 11:22 ` Pierre-Louis Bossart [this message]
2026-10-05 12:17   ` Mark Brown
2026-10-05 21:30     ` David Márquez
2026-10-06 21:27       ` David Márquez
2026-10-07  5:37         ` David Márquez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=33d869bc-ec8a-4d9e-8ba4-350bddce7ccf@linux.dev \
    --to=pierre-louis.bossart@linux.dev \
    --cc=broonie@kernel.org \
    --cc=davidmarquezfernandez@gmail.com \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=linux-sound@vger.kernel.org \
    --cc=sound-open-firmware@alsa-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox