All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luca Ceresoli <luca.ceresoli@bootlin.com>
To: Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	 Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	 Jonathan Corbet <corbet@lwn.net>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>,
	 Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	 linux-sound@vger.kernel.org, linux-doc@vger.kernel.org,
	 linux-kernel@vger.kernel.org,
	Luca Ceresoli <luca.ceresoli@bootlin.com>
Subject: [PATCH 11/12] ASoC: doc: dapm: update section "DAPM Widget Events"
Date: Tue, 16 Apr 2024 07:56:17 +0200	[thread overview]
Message-ID: <20240416-dapm-docs-v1-11-a818d2819bf6@bootlin.com> (raw)
In-Reply-To: <20240416-dapm-docs-v1-0-a818d2819bf6@bootlin.com>

The example in this section is not in the kernel sources anymore. Replace
it with an up to date code fragment. Reword the initial paragraph. Remove
"Please" which is not standard practice in documentation.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
 Documentation/sound/soc/dapm.rst | 30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/Documentation/sound/soc/dapm.rst b/Documentation/sound/soc/dapm.rst
index 5b370daed499..75a85c9e33ff 100644
--- a/Documentation/sound/soc/dapm.rst
+++ b/Documentation/sound/soc/dapm.rst
@@ -377,23 +377,29 @@ jacks can also be switched OFF.
 DAPM Widget Events
 ==================
 
-Some widgets can register their interest with the DAPM core in PM events.
-e.g. A Speaker with an amplifier registers a widget so the amplifier can be
-powered only when the spk is in use.
-::
+Widgets needing to implement a more complex behaviour than what DAPM can do
+can set a custom "event handler" by setting a function pointer. An example
+is a power supply needing to enable a GPIO::
 
-  /* turn speaker amplifier on/off depending on use */
-  static int corgi_amp_event(struct snd_soc_dapm_widget *w, int event)
+  static int sof_es8316_speaker_power_event(struct snd_soc_dapm_widget *w,
+  					  struct snd_kcontrol *kcontrol, int event)
   {
-	gpio_set_value(CORGI_GPIO_APM_ON, SND_SOC_DAPM_EVENT_ON(event));
-	return 0;
+  	if (SND_SOC_DAPM_EVENT_ON(event))
+  		gpiod_set_value_cansleep(gpio_pa, true);
+  	else
+  		gpiod_set_value_cansleep(gpio_pa, false);
+
+  	return 0;
   }
 
-  /* corgi machine dapm widgets */
-  static const struct snd_soc_dapm_widget wm8731_dapm_widgets =
-	SND_SOC_DAPM_SPK("Ext Spk", corgi_amp_event);
+  static const struct snd_soc_dapm_widget st_widgets[] = {
+  	...
+  	SND_SOC_DAPM_SUPPLY("Speaker Power", SND_SOC_NOPM, 0, 0,
+  			    sof_es8316_speaker_power_event,
+  			    SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
+  };
 
-Please see soc-dapm.h for all other widgets that support events.
+See soc-dapm.h for all other widgets that support events.
 
 
 Event types

-- 
2.34.1


  parent reply	other threads:[~2024-04-16  5:57 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-16  5:56 [PATCH 00/12] ASoC: doc: dapm: various improvements Luca Ceresoli
2024-04-16  5:56 ` [PATCH 01/12] ASoC: doc: dapm: fix typos Luca Ceresoli
2024-04-17  3:49   ` Bagas Sanjaya
2024-04-16  5:56 ` [PATCH 02/12] ASoC: doc: dapm: fix struct name Luca Ceresoli
2024-04-16  5:56 ` [PATCH 03/12] ASoC: doc: dapm: minor rewording Luca Ceresoli
2024-04-17  3:54   ` Bagas Sanjaya
2024-04-16  5:56 ` [PATCH 04/12] ASoC: doc: dapm: remove dash after colon Luca Ceresoli
2024-04-16  5:56 ` [PATCH 05/12] ASoC: doc: dapm: clarify it's an internal API Luca Ceresoli
2024-04-17  3:57   ` Bagas Sanjaya
2024-04-16  5:56 ` [PATCH 06/12] ASoC: doc: dapm: replace "map" with "graph" Luca Ceresoli
2024-04-16  5:56 ` [PATCH 07/12] ASoC: doc: dapm: extend initial descrption Luca Ceresoli
2024-04-17  4:05   ` Bagas Sanjaya
2024-04-16  5:56 ` [PATCH 08/12] ASoC: doc: dapm: describe how widgets and routes are registered Luca Ceresoli
2024-04-17  4:12   ` Bagas Sanjaya
2024-04-16  5:56 ` [PATCH 09/12] ASoC: doc: dapm: fix and improve section "Registering DAPM controls" Luca Ceresoli
2024-04-17  4:16   ` Bagas Sanjaya
2024-04-16  5:56 ` [PATCH 10/12] ASoC: doc: dapm: improve section "Codec/DSP Widget Interconnections" Luca Ceresoli
2024-04-17  4:33   ` Bagas Sanjaya
2024-04-17  5:08     ` Luca Ceresoli
2024-04-16  5:56 ` Luca Ceresoli [this message]
2024-04-16  5:56 ` [PATCH 12/12] ASoC: doc: dapm: update event types Luca Ceresoli
2024-04-16 21:23 ` [PATCH 00/12] ASoC: doc: dapm: various improvements Alexandre Belloni
2024-04-17  5:07   ` Luca Ceresoli
2024-04-17 23:30   ` Luca Ceresoli

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=20240416-dapm-docs-v1-11-a818d2819bf6@bootlin.com \
    --to=luca.ceresoli@bootlin.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=broonie@kernel.org \
    --cc=corbet@lwn.net \
    --cc=lgirdwood@gmail.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=thomas.petazzoni@bootlin.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.