Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: Rafael Diniz <rafael@riseup.net>
Cc: Mark Brown <broonie@kernel.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	patches@opensource.cirrus.com, linux-sound@vger.kernel.org
Subject: Re: [PATCH v4 1/2] ASoC: wm8731: activate the interface after the inputs, before the outputs
Date: Thu, 3 Dec 2026 10:55:23 +0000	[thread overview]
Message-ID: <axFKm39wVzqjvIag@opensource.cirrus.com> (raw)
In-Reply-To: <20261130201710.3737693-2-rafael@riseup.net>

On Mon, Nov 30, 2026 at 08:17:08PM +0000, Rafael Diniz wrote:
> +static void wm8731_activate(struct snd_soc_component *component)
> +{
> +	snd_soc_component_update_bits(component, WM8731_ACTIVE,
> +				      WM8731_ACTIVE_ACTIVE,
> +				      WM8731_ACTIVE_ACTIVE);
> +}
> +
> +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_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 int wm8731_adc_event(struct snd_soc_dapm_widget *w,
> +			    struct snd_kcontrol *kcontrol, int event)
> +{
> +	wm8731_activate(snd_soc_dapm_to_component(w->dapm));
> +	return 0;
> +}
> +
> +static int wm8731_dac_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);
> +
> +	/* Otherwise the outputs' own event activates it */
> +	if (!(snd_soc_component_read(component, WM8731_PWR) & WM8731_PWR_OUTPD))
> +		wm8731_activate(component);
> +	return 0;
> +}
> +
> +static int wm8731_outputs_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);
> +
> +	/* Not for the line bypass alone, with the converters down */
> +	if (!(snd_soc_component_read(component, WM8731_PWR) &
> +	      WM8731_PWR_CONVERTERS))
> +		wm8731_activate(component);
> +	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_MIXER("Output Mixer", WM8731_PWR, 4, 1,
> +SND_SOC_DAPM_SUPPLY_S("Converters", 1, SND_SOC_NOPM, 0, 0,
> +		      wm8731_converters_event,
> +		      SND_SOC_DAPM_PRE_PMU |
> +		      SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
> +SND_SOC_DAPM_MIXER("Output Mixer", SND_SOC_NOPM, 0, 0,
>  	&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_OUT_DRV_E("Outputs", WM8731_PWR, 4, 1, NULL, 0,
> +		       wm8731_outputs_event, SND_SOC_DAPM_PRE_PMU),
> +SND_SOC_DAPM_DAC_E("DAC", "HiFi Playback", SND_SOC_NOPM, 0, 0,
> +		   wm8731_dac_event, SND_SOC_DAPM_POST_PMU),
>  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_E("ADC", "HiFi Capture", SND_SOC_NOPM, 0, 0,
> +		   wm8731_adc_event, SND_SOC_DAPM_POST_PMU),
>  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),

This looks slightly better I think this gets the power up to:

1) Power OSCPD
2) Power ADCPD/DACPD
3) Power MICPD
4) Set ACTIVE
5) Power LINEINPD
6) Power OUTPD

That still seems to have the LINEINPD in the wrong place to me
and it seems quite complex. Why the complex handling on the
active bit? It seems to be attempting to delay disabling the
active bit until the very end of the power down, but I was
expecting the power down to just basically be the inverse of the
power up. Is there an additional requirement in the datasheet I
am missing?

Thanks,
Charles

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

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 20:17 [PATCH v4 0/2] ASoC: wm8731: interface activation order Rafael Diniz
2026-11-30 20:17 ` [PATCH v4 1/2] ASoC: wm8731: activate the interface after the inputs, before the outputs Rafael Diniz
2026-12-03 10:55   ` Charles Keepax [this message]
2026-11-30 20:17 ` [PATCH v4 2/2] ASoC: wm8731: use one sample width for both directions Rafael Diniz
2026-12-01 12:00   ` Mark Brown

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=axFKm39wVzqjvIag@opensource.cirrus.com \
    --to=ckeepax@opensource.cirrus.com \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-sound@vger.kernel.org \
    --cc=patches@opensource.cirrus.com \
    --cc=perex@perex.cz \
    --cc=rafael@riseup.net \
    --cc=tiwai@suse.com \
    /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