From: Val Packett <val@packett.cool>
To: Vladyslav Tymoshchuk <tvlad744@gmail.com>,
Mark Brown <broonie@kernel.org>,
Liam Girdwood <lgirdwood@gmail.com>
Cc: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Srinivas Kandagatla <srini@kernel.org>,
Luca Weiss <luca.weiss@fairphone.com>,
Jorijn van der Graaf <jorijnvdgraaf@catcrafts.net>,
Federico Amedeo Izzo <federico@izzo.pro>,
linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-kernel@vger.kernel.org, phone-devel@vger.kernel.org,
~postmarketos/upstreaming@lists.sr.ht
Subject: Re: [PATCH v2] ASoC: codecs: aw88261: complete the start at trigger time
Date: Sun, 18 Oct 2026 19:44:31 -0300 [thread overview]
Message-ID: <7d1fd5e4-a35a-4675-8b0c-005e9f022646@packett.cool> (raw)
In-Reply-To: <58c229e2-ee81-4b75-92e9-1eaee2d19d0b@packett.cool>
On 10/18/26 4:20 PM, Val Packett wrote:
>
> On 10/17/26 7:00 AM, Vladyslav Tymoshchuk wrote:
>> The amplifier is started from the PRE_PMU event of its AIF widget, that
>> is from DAPM in prepare. aw88261_dev_start() waits up to 20 ms there for
>> the PLL to lock to the bit clock and powers the amplifier down again if
>> it does not.
>>
>> The Qualcomm AudioReach backends only start their graph, and with it
>> the I2S/TDM clocks, in trigger since commit b54a38af7138 ("ASoC: qcom:
>> q6apm-lpass-dai: move graph start to trigger"). There every start fails
>> with "start failure (-1)" and the speaker stays silent for the whole
>> stream, as seen with six AW88261 on a TDM link of SM8750.
>>
>> Split the start at the first step that needs the bit clock, the PLL
>> lock check, whatever the host does:
>>
>> - PRE_PMU clears power down (PWDN), configures the I2S interface and
>> the PLL and writes the boost settings of aw88261_reg_force_set().
>> The amplifier stays powered down (AMPPD) and muted.
>> - The unmute, called after the trigger of the CPU DAI with
>> .mute_unmute_on_trigger, does the rest: it checks the PLL lock,
>> clears AMPPD, checks SYSST, enables the feedback and unmutes. If the
>> PLL does not lock, "start failure" is logged, the amplifier is left
>> as PRE_PMU left it and the next trigger start tries again.
>> - The mute in trigger undoes the unmute (mute, feedback off, AMPPD),
>> and POST_PMD sets PWDN as before.
>>
>> So only the steps that need the clock run in trigger: 14 register
>> accesses and 1 ms per amplifier for the unmute when the PLL has locked,
>> 12 and 1 ms for the mute. The same steps run there on hosts that have
>> the clock running from prepare. aw88261_reg_force_set() only writes
>> boost settings and now runs before AMPPD is cleared rather than right
>> after.
>>
>> wsa883x and wsa884x split their start the same way, with the
>> configuration in DAPM and GLOBAL_PA_EN in the trigger-time mute. The
>> vendor driver of this amplifier family (aw882xx) also starts the
>> amplifier from .mute_stream, with the same sequence.
>>
>> The register accesses go over I2C and sleep, so they need a nonatomic
>> trigger, which the Qualcomm DPCM links using this codec have. On an
>> atomic PCM, as seen from substream->pcm->nonatomic in .startup, PRE_PMU
>> does the whole start as before and the mute callback does nothing.
>>
>> POST_PMD can also run for an amplifier that was never powered up, as
>> seen when the card is registered, so make "already power off" a debug
>> message.
>>
>> Assisted-by: LLM
>> Signed-off-by: Vladyslav Tymoshchuk <tvlad744@gmail.com>
>> ---
>> [..]
>> +/*
>> + * First part of the start, which does not need the bit clock: power
>> up and
>> + * configure the I2S interface and the PLL. The amplifier stays
>> powered down
>> + * (AMPPD) and muted.
>> + */
>> +static int aw88261_dev_power_up(struct aw88261 *aw88261)
>> [..]
>> +/*
>> + * Second part of the start, which needs the bit clock as the PLL
>> locks to
>> + * it: check the lock, enable the amplifier and the feedback, and
>> unmute.
>> + * On failure the device is left as aw88261_dev_power_up() left it.
>> + */
>> +static int aw88261_dev_enable(struct aw88261 *aw88261)
>> [..]
>> +/* Undo aw88261_dev_enable() */
>> +static void aw88261_dev_disable(struct aw_device *aw_dev)
>> [..]
>> +static int aw88261_dev_start(struct aw88261 *aw88261, bool enable)
>
> "power_up", "start", *and* "enable".. this naming is a mess now.
>
> Would be nicer to make the *names* more descriptive of what's actually
> being turned on/off.
>
>> [..]
>> --- a/sound/soc/codecs/aw88261.h
>> +++ b/sound/soc/codecs/aw88261.h
>> @@ -564,6 +564,8 @@ enum {
>> enum {
>> AW88261_DEV_PW_OFF = 0,
>> AW88261_DEV_PW_ON,
>> + /* powered up and configured, amplifier off: waits for the bit
>> clock */
>> + AW88261_DEV_PW_READY,
>
> Would make more sense to stick the intermediate state in the, well,
> middle. And rename the states to something that makes sense like {
> OFF, WAITING_FOR_BIT_CLOCK, RUNNING } instead of making everything a
> comment like the slop machine left it.
>
>> [..]
>> base-commit: 0f8bc3b93b76d16682a4d4999f9559b1e18016f9
>
>
> It does work here, anyhow, so
>
> Tested-by: Val Packett <val@packett.cool> # sm7325-motorola-dubai
Though after this last reboot now, it's weirdly stuck when on the
speaker profile, changing the volume did not play the "boop" sounds..
(nothing appearing in dmesg).. until I switched to the earpiece profile,
when a big bunch of those played in a row!
Not guaranteed that this is related to these driver changes, but
suspicious..
> Thanks,
> ~val
>
prev parent reply other threads:[~2026-10-18 22:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-17 10:00 Vladyslav Tymoshchuk
2026-10-18 19:20 ` Val Packett
2026-10-18 22:44 ` Val Packett [this message]
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=7d1fd5e4-a35a-4675-8b0c-005e9f022646@packett.cool \
--to=val@packett.cool \
--cc=broonie@kernel.org \
--cc=federico@izzo.pro \
--cc=jorijnvdgraaf@catcrafts.net \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=luca.weiss@fairphone.com \
--cc=perex@perex.cz \
--cc=phone-devel@vger.kernel.org \
--cc=srini@kernel.org \
--cc=tiwai@suse.com \
--cc=tvlad744@gmail.com \
--cc=~postmarketos/upstreaming@lists.sr.ht \
/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
all inboxes | Powered by JetHome®