Skip to content

Commit ce5a4f1

Browse files
lucaceresolibroonie
authored andcommitted
ASoC: doc: dapm: update section "DAPM Widget Events"
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. Reviewed-by: Alexandre Belloni <[email protected]> Signed-off-by: Luca Ceresoli <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 057acfb commit ce5a4f1

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

Documentation/sound/soc/dapm.rst

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -376,23 +376,29 @@ jacks can also be switched OFF.
376376
DAPM Widget Events
377377
==================
378378

379-
Some widgets can register their interest with the DAPM core in PM events.
380-
e.g. A Speaker with an amplifier registers a widget so the amplifier can be
381-
powered only when the spk is in use.
382-
::
379+
Widgets needing to implement a more complex behaviour than what DAPM can do
380+
can set a custom "event handler" by setting a function pointer. An example
381+
is a power supply needing to enable a GPIO::
383382

384-
/* turn speaker amplifier on/off depending on use */
385-
static int corgi_amp_event(struct snd_soc_dapm_widget *w, int event)
383+
static int sof_es8316_speaker_power_event(struct snd_soc_dapm_widget *w,
384+
struct snd_kcontrol *kcontrol, int event)
386385
{
387-
gpio_set_value(CORGI_GPIO_APM_ON, SND_SOC_DAPM_EVENT_ON(event));
388-
return 0;
386+
if (SND_SOC_DAPM_EVENT_ON(event))
387+
gpiod_set_value_cansleep(gpio_pa, true);
388+
else
389+
gpiod_set_value_cansleep(gpio_pa, false);
390+
391+
return 0;
389392
}
390393

391-
/* corgi machine dapm widgets */
392-
static const struct snd_soc_dapm_widget wm8731_dapm_widgets =
393-
SND_SOC_DAPM_SPK("Ext Spk", corgi_amp_event);
394+
static const struct snd_soc_dapm_widget st_widgets[] = {
395+
...
396+
SND_SOC_DAPM_SUPPLY("Speaker Power", SND_SOC_NOPM, 0, 0,
397+
sof_es8316_speaker_power_event,
398+
SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
399+
};
394400

395-
Please see soc-dapm.h for all other widgets that support events.
401+
See soc-dapm.h for all other widgets that support events.
396402

397403

398404
Event types

0 commit comments

Comments
 (0)