* [PATCH v3 0/2] ASoC: wm8731: interface activation order
@ 2026-11-28 9:23 Rafael Diniz
2026-11-28 9:23 ` [PATCH v3 1/2] ASoC: wm8731: activate the interface after the converters, before the outputs Rafael Diniz
2026-11-28 9:23 ` [PATCH v3 2/2] ASoC: wm8731: use one sample width for both directions Rafael Diniz
0 siblings, 2 replies; 9+ messages in thread
From: Rafael Diniz @ 2026-11-28 9:23 UTC (permalink / raw)
To: Mark Brown, Liam Girdwood
Cc: Charles Keepax, Jaroslav Kysela, Takashi Iwai, patches,
linux-sound
On a WM8731 that provides the clocks (96 kHz from a 12 MHz crystal, as
on the AudioInjector stereo card for the Raspberry Pi), about one
capture start in five came up deaf: DC offset and noise at their usual
levels, no signal, until the interface was deactivated and activated
again. The trigger is the ADC powering up under an active interface,
which the driver's ACTIVE supply widget does on every capture start.
Patch 1 powers the ADC and DAC from one supply that sets ACTIVE once
they are up and clears it before they go down, so ACTIVE also comes
before OUTPD is cleared, as the datasheet asks. Patch 2 makes both
directions use one sample width, as they already use one rate.
Changes in v3:
- Split in two patches (Charles).
- ACTIVE is set and cleared by the converters' supply itself (POST_PMU
and PRE_PMD) instead of a DAPM post widget: it now comes before the
output mixer clears OUTPD (Mark), and it also runs on power changes
that are not stream events, such as a mixer switch (also raised by
the AI review).
- Dropped the -EBUSY check in hw_params. symmetric_rate already keeps
the rate, and patch 2 sets symmetric_sample_bits for the width
(Charles). This also drops the false -EBUSY within pmdown_time that
the AI review found.
- The supply powers the ADC and DAC only; the line input keeps its own
widget. In v2 it was on the supply too, and as the AudioInjector
card's machine driver keeps the line input powered, the converters and
the interface then never went down on that card: v2's hardware result
came from that, not from the new order. v3's result is with the
converters and ACTIVE switching on every start.
v2: https://lore.kernel.org/linux-sound/20261120080825.2078162-1-rafael@riseup.net/
Rafael Diniz (2):
ASoC: wm8731: activate the interface after the converters, before the
outputs
ASoC: wm8731: use one sample width for both directions
sound/soc/codecs/wm8731.c | 60 +++++++++++++++++++++++++++++++++++----
sound/soc/codecs/wm8731.h | 7 +++++
2 files changed, 62 insertions(+), 5 deletions(-)
base-commit: 4405c18c95d2d0f99f6c581ef0ee8591a1aa6ccd
--
2.47.3
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH v3 1/2] ASoC: wm8731: activate the interface after the converters, before the outputs 2026-11-28 9:23 [PATCH v3 0/2] ASoC: wm8731: interface activation order Rafael Diniz @ 2026-11-28 9:23 ` Rafael Diniz 2026-11-30 10:28 ` Charles Keepax 2026-11-30 16:54 ` Mark Brown 2026-11-28 9:23 ` [PATCH v3 2/2] ASoC: wm8731: use one sample width for both directions Rafael Diniz 1 sibling, 2 replies; 9+ messages in thread From: Rafael Diniz @ 2026-11-28 9:23 UTC (permalink / raw) To: Mark Brown, Liam Girdwood Cc: Charles Keepax, Jaroslav Kysela, Takashi Iwai, patches, linux-sound The datasheet's power-up sequence powers everything but the outputs, sets the other registers, activates the digital audio interface and clears OUTPD last. The driver has ACTIVE as a supply widget of its own, which DAPM powers ahead of the ADC and DAC, so every stream start powers a converter up under an active interface. With the codec as clock provider at 96 kHz from a 12 MHz crystal (USB mode), as on the AudioInjector stereo card for the Raspberry Pi, about one capture start in five then leaves the ADC delivering its DC offset and noise at their usual levels but no signal, until the interface is deactivated and activated again. Both orders reproduce it on a running codec over I2C: the driver's start order (interface active, then the ADC powered up) went deaf in 1 of 8 trials, and powering the ADC down and up under an active interface in 2 of 8. Activating the interface with the ADC already powered stayed healthy in 42 of 42. Power the ADC and DAC from one supply, with the interface inactive, and set ACTIVE from the same supply's POST_PMU event once they are up; clear it in PRE_PMD before they go down. DAPM runs supplies before the output mixer (OUTPD) when powering up and after it when powering down, so ACTIVE is set before OUTPD is cleared, as the datasheet asks, and the events run on any power change, a mixer switch as well as a stream start. A subsequence orders the supply after the oscillator going up and before it going down. A second stream finds the converters powered and the interface left as it is. The register writes traced on that card follow the datasheet's order: oscillator, ADC and DAC, ACTIVE, then OUTPD for playback; OUTPD, ACTIVE, ADC and DAC, oscillator going down. Turning the HiFi playback switch on under a running playback stream sets ACTIVE the same way, and the line bypass alone powers only the output mixer. Tested on a Raspberry Pi 4 with that card, 6.18.60 (Raspberry Pi kernel, where the driver is the same as here): after each of 30 daemon restarts, each a fresh capture and playback start with nothing in user space cycling the interface, the capture decoded a test transmission from a second station; before this patch about one start in five came up deaf. Built with W=1 on mainline. The analysis, the I2C reproducers, the patch and this changelog were written with Claude Code (Claude Opus 5.5) from the reported fault, the kernel sources and the review of v2, and the tool ran the hardware tests on the submitter's test setup at the submitter's direction. Fixes: 8a27bd9a3318 ("ASoC: Manage WM8731 ACTIVE bit as a supply widget") Link: https://github.com/raspberrypi/linux/issues/7776 Signed-off-by: Rafael Diniz <rafael@riseup.net> --- sound/soc/codecs/wm8731.c | 59 +++++++++++++++++++++++++++++++++++---- sound/soc/codecs/wm8731.h | 7 +++++ 2 files changed, 61 insertions(+), 5 deletions(-) diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index f25b50919..d2f65f543 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c @@ -167,18 +167,67 @@ SOC_DAPM_SINGLE("HiFi Playback Switch", WM8731_APANA, 4, 1, 0), static const struct snd_kcontrol_new wm8731_input_mux_controls = SOC_DAPM_ENUM("Input Select", wm8731_insel_enum); +/* + * The datasheet's power-up sequence powers everything but the outputs, sets + * the other registers, activates the digital audio interface and powers the + * outputs last. With the codec as clock provider at 96 kHz (12 MHz crystal, + * USB mode), powering the ADC up under an active interface left it, about + * one time in five, delivering its DC offset and noise but no signal, until + * the interface was deactivated and activated again. + * + * So one supply powers the ADC and DAC, with the interface inactive, and + * activates the interface once they are up; going down, it deactivates the + * interface before powering them down. A second stream finds them powered + * and the interface left as it is. DAPM runs supplies before the output + * mixer (OUTPD) when powering up and after it when powering down, as the + * datasheet's sequence has it; the subsequence puts this supply after the + * oscillator going up and before it going down. + */ +#define WM8731_PWR_CONVERTERS (WM8731_PWR_ADCPD | WM8731_PWR_DACPD) + +static int wm8731_converters_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + + switch (event) { + case SND_SOC_DAPM_PRE_PMU: + snd_soc_component_update_bits(component, WM8731_PWR, + WM8731_PWR_CONVERTERS, 0); + break; + case SND_SOC_DAPM_POST_PMU: + snd_soc_component_update_bits(component, WM8731_ACTIVE, + WM8731_ACTIVE_ACTIVE, + WM8731_ACTIVE_ACTIVE); + break; + case SND_SOC_DAPM_PRE_PMD: + snd_soc_component_update_bits(component, WM8731_ACTIVE, + WM8731_ACTIVE_ACTIVE, 0); + break; + case SND_SOC_DAPM_POST_PMD: + snd_soc_component_update_bits(component, WM8731_PWR, + WM8731_PWR_CONVERTERS, + WM8731_PWR_CONVERTERS); + break; + } + return 0; +} + static const struct snd_soc_dapm_widget wm8731_dapm_widgets[] = { -SND_SOC_DAPM_SUPPLY("ACTIVE",WM8731_ACTIVE, 0, 0, NULL, 0), SND_SOC_DAPM_SUPPLY("OSC", WM8731_PWR, 5, 1, NULL, 0), +SND_SOC_DAPM_SUPPLY_S("Converters", 1, SND_SOC_NOPM, 0, 0, + wm8731_converters_event, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_MIXER("Output Mixer", WM8731_PWR, 4, 1, &wm8731_output_mixer_controls[0], ARRAY_SIZE(wm8731_output_mixer_controls)), -SND_SOC_DAPM_DAC("DAC", "HiFi Playback", WM8731_PWR, 3, 1), +SND_SOC_DAPM_DAC("DAC", "HiFi Playback", SND_SOC_NOPM, 0, 0), SND_SOC_DAPM_OUTPUT("LOUT"), SND_SOC_DAPM_OUTPUT("LHPOUT"), SND_SOC_DAPM_OUTPUT("ROUT"), SND_SOC_DAPM_OUTPUT("RHPOUT"), -SND_SOC_DAPM_ADC("ADC", "HiFi Capture", WM8731_PWR, 2, 1), +SND_SOC_DAPM_ADC("ADC", "HiFi Capture", SND_SOC_NOPM, 0, 0), SND_SOC_DAPM_MUX("Input Mux", SND_SOC_NOPM, 0, 0, &wm8731_input_mux_controls), SND_SOC_DAPM_PGA("Line Input", WM8731_PWR, 0, 1, NULL, 0), SND_SOC_DAPM_MICBIAS("Mic Bias", WM8731_PWR, 1, 1), @@ -199,8 +248,8 @@ static int wm8731_check_osc(struct snd_soc_dapm_widget *source, static const struct snd_soc_dapm_route wm8731_intercon[] = { {"DAC", NULL, "OSC", wm8731_check_osc}, {"ADC", NULL, "OSC", wm8731_check_osc}, - {"DAC", NULL, "ACTIVE"}, - {"ADC", NULL, "ACTIVE"}, + {"DAC", NULL, "Converters"}, + {"ADC", NULL, "Converters"}, /* output mixer */ {"Output Mixer", "Line Bypass Switch", "Line Input"}, diff --git a/sound/soc/codecs/wm8731.h b/sound/soc/codecs/wm8731.h index 8d5a7a9ca..2c422c43f 100644 --- a/sound/soc/codecs/wm8731.h +++ b/sound/soc/codecs/wm8731.h @@ -33,6 +33,13 @@ struct snd_pcm_hw_constraint_list; #define WM8731_ACTIVE 0x09 #define WM8731_RESET 0x0f +/* WM8731_PWR */ +#define WM8731_PWR_ADCPD 0x0004 +#define WM8731_PWR_DACPD 0x0008 + +/* WM8731_ACTIVE */ +#define WM8731_ACTIVE_ACTIVE 0x0001 + #define WM8731_CACHEREGNUM 10 #define WM8731_SYSCLK_MCLK 0 -- 2.47.3 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v3 1/2] ASoC: wm8731: activate the interface after the converters, before the outputs 2026-11-28 9:23 ` [PATCH v3 1/2] ASoC: wm8731: activate the interface after the converters, before the outputs Rafael Diniz @ 2026-11-30 10:28 ` Charles Keepax 2026-11-30 16:54 ` Mark Brown 1 sibling, 0 replies; 9+ messages in thread From: Charles Keepax @ 2026-11-30 10:28 UTC (permalink / raw) To: Rafael Diniz Cc: Mark Brown, Liam Girdwood, Jaroslav Kysela, Takashi Iwai, patches, linux-sound On Sat, Nov 28, 2026 at 09:23:04AM +0000, Rafael Diniz wrote: > +#define WM8731_PWR_CONVERTERS (WM8731_PWR_ADCPD | WM8731_PWR_DACPD) > + > +static int wm8731_converters_event(struct snd_soc_dapm_widget *w, > + struct snd_kcontrol *kcontrol, int event) > +{ > + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); > + > + switch (event) { > + case SND_SOC_DAPM_PRE_PMU: > + snd_soc_component_update_bits(component, WM8731_PWR, > + WM8731_PWR_CONVERTERS, 0); > + break; > + case SND_SOC_DAPM_POST_PMU: > + snd_soc_component_update_bits(component, WM8731_ACTIVE, > + WM8731_ACTIVE_ACTIVE, > + WM8731_ACTIVE_ACTIVE); > + break; > + case SND_SOC_DAPM_PRE_PMD: > + snd_soc_component_update_bits(component, WM8731_ACTIVE, > + WM8731_ACTIVE_ACTIVE, 0); > + break; > + case SND_SOC_DAPM_POST_PMD: > + snd_soc_component_update_bits(component, WM8731_PWR, > + WM8731_PWR_CONVERTERS, > + WM8731_PWR_CONVERTERS); > + break; > + } > + return 0; > +} > + > static const struct snd_soc_dapm_widget wm8731_dapm_widgets[] = { > -SND_SOC_DAPM_SUPPLY("ACTIVE",WM8731_ACTIVE, 0, 0, NULL, 0), > SND_SOC_DAPM_SUPPLY("OSC", WM8731_PWR, 5, 1, NULL, 0), > +SND_SOC_DAPM_SUPPLY_S("Converters", 1, SND_SOC_NOPM, 0, 0, > + wm8731_converters_event, > + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | > + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), > SND_SOC_DAPM_MIXER("Output Mixer", WM8731_PWR, 4, 1, > &wm8731_output_mixer_controls[0], > ARRAY_SIZE(wm8731_output_mixer_controls)), > -SND_SOC_DAPM_DAC("DAC", "HiFi Playback", WM8731_PWR, 3, 1), > +SND_SOC_DAPM_DAC("DAC", "HiFi Playback", SND_SOC_NOPM, 0, 0), > SND_SOC_DAPM_OUTPUT("LOUT"), > SND_SOC_DAPM_OUTPUT("LHPOUT"), > SND_SOC_DAPM_OUTPUT("ROUT"), > SND_SOC_DAPM_OUTPUT("RHPOUT"), > -SND_SOC_DAPM_ADC("ADC", "HiFi Capture", WM8731_PWR, 2, 1), > +SND_SOC_DAPM_ADC("ADC", "HiFi Capture", SND_SOC_NOPM, 0, 0), > SND_SOC_DAPM_MUX("Input Mux", SND_SOC_NOPM, 0, 0, &wm8731_input_mux_controls), > SND_SOC_DAPM_PGA("Line Input", WM8731_PWR, 0, 1, NULL, 0), > SND_SOC_DAPM_MICBIAS("Mic Bias", WM8731_PWR, 1, 1), Don't you still have a different sequence from the datasheet here. Assuming everything powers up and I didn't make a mistake, you have: 1) Power OSCPD 2) Power ADCPD/DACPD 3) Set ACTIVE 4) Power MICPD 5) Power OUTPD 6) Power LINEINPD And I think following the section of the datasheet Mark linked you want: 1) Power OSCPD 2) Power ADCPD/DACPD 3) Power MICPD 4) Power LINEINPD 5) Set ACTIVE 6) Power OUTPD Although doubt the order of 2-4 matter in there. Thanks, Charles ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3 1/2] ASoC: wm8731: activate the interface after the converters, before the outputs 2026-11-28 9:23 ` [PATCH v3 1/2] ASoC: wm8731: activate the interface after the converters, before the outputs Rafael Diniz 2026-11-30 10:28 ` Charles Keepax @ 2026-11-30 16:54 ` Mark Brown 2026-11-30 17:14 ` Charles Keepax 1 sibling, 1 reply; 9+ messages in thread From: Mark Brown @ 2026-11-30 16:54 UTC (permalink / raw) To: Rafael Diniz Cc: Mark Brown, Liam Girdwood, Charles Keepax, Jaroslav Kysela, Takashi Iwai, patches, linux-sound > The datasheet's power-up sequence powers everything but the outputs, > sets the other registers, activates the digital audio interface and > clears OUTPD last. The driver has ACTIVE as a supply widget of its own, > which DAPM powers ahead of the ADC and DAC, so every stream start powers > a converter up under an active interface. > Power the ADC and DAC from one supply, with the interface inactive, and > set ACTIVE from the same supply's POST_PMU event once they are up; clear > +#define WM8731_PWR_CONVERTERS (WM8731_PWR_ADCPD | WM8731_PWR_DACPD) > +static int wm8731_converters_event(struct snd_soc_dapm_widget *w, > + struct snd_kcontrol *kcontrol, int event) > +{ > + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); > + > + switch (event) { > + case SND_SOC_DAPM_PRE_PMU: > + snd_soc_component_update_bits(component, WM8731_PWR, > + WM8731_PWR_CONVERTERS, 0); > + break; ... > + case SND_SOC_DAPM_POST_PMD: > + snd_soc_component_update_bits(component, WM8731_PWR, > + WM8731_PWR_CONVERTERS, > + WM8731_PWR_CONVERTERS); > + break; > + } > + return 0; > +} This means we'll always power both the ADC and DAC, even if only one is in use. I'm not sure any of the users of this device are likely to be super power sensitive, but it's possible. -- Mark Brown <broonie@kernel.org> ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3 1/2] ASoC: wm8731: activate the interface after the converters, before the outputs 2026-11-30 16:54 ` Mark Brown @ 2026-11-30 17:14 ` Charles Keepax 2026-11-30 17:26 ` Mark Brown 0 siblings, 1 reply; 9+ messages in thread From: Charles Keepax @ 2026-11-30 17:14 UTC (permalink / raw) To: Mark Brown Cc: Rafael Diniz, Liam Girdwood, Jaroslav Kysela, Takashi Iwai, patches, linux-sound On Mon, Nov 30, 2026 at 04:54:42PM +0000, Mark Brown wrote: > > The datasheet's power-up sequence powers everything but the outputs, > > sets the other registers, activates the digital audio interface and > > clears OUTPD last. The driver has ACTIVE as a supply widget of its own, > > which DAPM powers ahead of the ADC and DAC, so every stream start powers > > a converter up under an active interface. > > > Power the ADC and DAC from one supply, with the interface inactive, and > > set ACTIVE from the same supply's POST_PMU event once they are up; clear > > > > +#define WM8731_PWR_CONVERTERS (WM8731_PWR_ADCPD | WM8731_PWR_DACPD) > > > +static int wm8731_converters_event(struct snd_soc_dapm_widget *w, > > + struct snd_kcontrol *kcontrol, int event) > > +{ > > + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); > > + > > + switch (event) { > > + case SND_SOC_DAPM_PRE_PMU: > > + snd_soc_component_update_bits(component, WM8731_PWR, > > + WM8731_PWR_CONVERTERS, 0); > > + break; > > ... > > > + case SND_SOC_DAPM_POST_PMD: > > + snd_soc_component_update_bits(component, WM8731_PWR, > > + WM8731_PWR_CONVERTERS, > > + WM8731_PWR_CONVERTERS); > > + break; > > + } > > + return 0; > > +} > > This means we'll always power both the ADC and DAC, even if only one is > in use. I'm not sure any of the users of this device are likely to be > super power sensitive, but it's possible. Can we do better than that though? From user-space they are separate capture and playback files, so whatever one is opened second will find the hardware in an already powered state. Assuming the problem is as described the only other alternative would be to glitch the already open stream whilst the other powers up, which seems worse than increased power draw. Thanks, Charles ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3 1/2] ASoC: wm8731: activate the interface after the converters, before the outputs 2026-11-30 17:14 ` Charles Keepax @ 2026-11-30 17:26 ` Mark Brown 2026-11-30 17:37 ` Charles Keepax 0 siblings, 1 reply; 9+ messages in thread From: Mark Brown @ 2026-11-30 17:26 UTC (permalink / raw) To: Charles Keepax Cc: Rafael Diniz, Liam Girdwood, Jaroslav Kysela, Takashi Iwai, patches, linux-sound [-- Attachment #1: Type: text/plain, Size: 913 bytes --] On Mon, Nov 30, 2026 at 05:14:32PM +0000, Charles Keepax wrote: > On Mon, Nov 30, 2026 at 04:54:42PM +0000, Mark Brown wrote: > > This means we'll always power both the ADC and DAC, even if only one is > > in use. I'm not sure any of the users of this device are likely to be > > super power sensitive, but it's possible. > Can we do better than that though? From user-space they are > separate capture and playback files, so whatever one is opened > second will find the hardware in an already powered state. > Assuming the problem is as described the only other alternative > would be to glitch the already open stream whilst the other > powers up, which seems worse than increased power draw. It does rather depend if people routinely do simultaneous playback and capture in the first place, and for capture you'll might find the glitch happens before the CPU starts paying attention to the incoming data. [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3 1/2] ASoC: wm8731: activate the interface after the converters, before the outputs 2026-11-30 17:26 ` Mark Brown @ 2026-11-30 17:37 ` Charles Keepax 0 siblings, 0 replies; 9+ messages in thread From: Charles Keepax @ 2026-11-30 17:37 UTC (permalink / raw) To: Mark Brown Cc: Rafael Diniz, Liam Girdwood, Jaroslav Kysela, Takashi Iwai, patches, linux-sound On Mon, Nov 30, 2026 at 05:26:47PM +0000, Mark Brown wrote: > On Mon, Nov 30, 2026 at 05:14:32PM +0000, Charles Keepax wrote: > > On Mon, Nov 30, 2026 at 04:54:42PM +0000, Mark Brown wrote: > > > > This means we'll always power both the ADC and DAC, even if only one is > > > in use. I'm not sure any of the users of this device are likely to be > > > super power sensitive, but it's possible. > > > Can we do better than that though? From user-space they are > > separate capture and playback files, so whatever one is opened > > second will find the hardware in an already powered state. > > Assuming the problem is as described the only other alternative > > would be to glitch the already open stream whilst the other > > powers up, which seems worse than increased power draw. > > It does rather depend if people routinely do simultaneous playback and > capture in the first place, and for capture you'll might find the glitch > happens before the CPU starts paying attention to the incoming data. That is fair, I do somewhat imagine the primary user-case could be playback heavy here. I guess we can do a setup that glitches the active stream turning active on and off and see if anyone complains. Thanks, Charles ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v3 2/2] ASoC: wm8731: use one sample width for both directions 2026-11-28 9:23 [PATCH v3 0/2] ASoC: wm8731: interface activation order Rafael Diniz 2026-11-28 9:23 ` [PATCH v3 1/2] ASoC: wm8731: activate the interface after the converters, before the outputs Rafael Diniz @ 2026-11-28 9:23 ` Rafael Diniz 2026-11-30 10:03 ` Charles Keepax 1 sibling, 1 reply; 9+ messages in thread From: Rafael Diniz @ 2026-11-28 9:23 UTC (permalink / raw) To: Mark Brown, Liam Girdwood Cc: Charles Keepax, Jaroslav Kysela, Takashi Iwai, patches, linux-sound Playback and capture share one interface format register (IFACE), whose IWL field sets the word length for both directions, as SRATE sets one sample rate for both. symmetric_rate already makes a second stream use the rate of the running one, but a second stream at a different width rewrites IWL under the running stream, which then carries samples of the wrong length. Set symmetric_sample_bits, so the second stream gets the width of the running one. Its hw_params then writes back the values already there; rewriting SRATE and IFACE with their values under an active interface stayed healthy in 12 of 12 trials on the hardware below. Tested on a Raspberry Pi 4 with the AudioInjector stereo card, 6.18.60 (Raspberry Pi kernel, where the driver is the same as here): with a 32-bit capture stream running, a 16-bit playback stream is refused as a format not available, and the register trace shows no write to IFACE. Built with W=1 on mainline. This patch and its changelog were written with Claude Code (Claude Opus 5.5) following the review of v2. Signed-off-by: Rafael Diniz <rafael@riseup.net> --- sound/soc/codecs/wm8731.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index d2f65f543..0e639c319 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c @@ -606,6 +606,7 @@ static struct snd_soc_dai_driver wm8731_dai = { .formats = WM8731_FORMATS,}, .ops = &wm8731_dai_ops, .symmetric_rate = 1, + .symmetric_sample_bits = 1, }; static const struct snd_soc_component_driver soc_component_dev_wm8731 = { -- 2.47.3 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v3 2/2] ASoC: wm8731: use one sample width for both directions 2026-11-28 9:23 ` [PATCH v3 2/2] ASoC: wm8731: use one sample width for both directions Rafael Diniz @ 2026-11-30 10:03 ` Charles Keepax 0 siblings, 0 replies; 9+ messages in thread From: Charles Keepax @ 2026-11-30 10:03 UTC (permalink / raw) To: Rafael Diniz Cc: Mark Brown, Liam Girdwood, Jaroslav Kysela, Takashi Iwai, patches, linux-sound On Sat, Nov 28, 2026 at 09:23:05AM +0000, Rafael Diniz wrote: > Playback and capture share one interface format register (IFACE), whose > IWL field sets the word length for both directions, as SRATE sets one > sample rate for both. symmetric_rate already makes a second stream use > the rate of the running one, but a second stream at a different width > rewrites IWL under the running stream, which then carries samples of the > wrong length. > > Set symmetric_sample_bits, so the second stream gets the width of the > running one. Its hw_params then writes back the values already there; > rewriting SRATE and IFACE with their values under an active interface > stayed healthy in 12 of 12 trials on the hardware below. > > Tested on a Raspberry Pi 4 with the AudioInjector stereo card, 6.18.60 > (Raspberry Pi kernel, where the driver is the same as here): with a > 32-bit capture stream running, a 16-bit playback stream is refused as a > format not available, and the register trace shows no write to IFACE. > Built with W=1 on mainline. > > This patch and its changelog were written with Claude Code (Claude Opus > 5.5) following the review of v2. > > Signed-off-by: Rafael Diniz <rafael@riseup.net> > --- Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com> Thanks, Charles ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-11-30 17:38 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-28 9:23 [PATCH v3 0/2] ASoC: wm8731: interface activation order Rafael Diniz 2026-11-28 9:23 ` [PATCH v3 1/2] ASoC: wm8731: activate the interface after the converters, before the outputs Rafael Diniz 2026-11-30 10:28 ` Charles Keepax 2026-11-30 16:54 ` Mark Brown 2026-11-30 17:14 ` Charles Keepax 2026-11-30 17:26 ` Mark Brown 2026-11-30 17:37 ` Charles Keepax 2026-11-28 9:23 ` [PATCH v3 2/2] ASoC: wm8731: use one sample width for both directions Rafael Diniz 2026-11-30 10:03 ` Charles Keepax
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox