Skip to content

Commit 36de8c0

Browse files
lucaceresolibroonie
authored andcommitted
ASoC: doc: dapm: describe how widgets and routes are registered
The small paragraph describing how to register widgets is incomplete (does not mention routes) and mentions snd_soc_dapm_new_control() which is not really used. Moreover it appears as a part of the "Virtual Widgets" subsection. Replace it with a detailed and current description of how widgets and routes are registered, mentioning both static declaration and runtime registration. Also make this a section on its own. Reviewed-by: Alexandre Belloni <[email protected]> Reviewed-by: Bagas Sanjaya <[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 dd5f36e commit 36de8c0

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

Documentation/sound/soc/dapm.rst

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,42 @@ a virtual widget - a widget with no control bits e.g.
250250

251251
This can be used to merge two signal paths together in software.
252252

253-
After all the widgets have been defined, they can then be added to the DAPM
254-
subsystem individually with a call to snd_soc_dapm_new_control().
253+
Registering DAPM controls
254+
=========================
255+
256+
In many cases the DAPM widgets implemented statically in a ``static const
257+
struct snd_soc_dapm_widget`` array and the routes connecting them in a
258+
``static const struct snd_soc_dapm_route`` array in a codec driver, and
259+
simply declared via the ``dapm_widgets`` and ``num_dapm_widgets`` fields of
260+
the ``struct snd_soc_component_driver`` so the driver registration will
261+
take care of populating them::
262+
263+
static const struct snd_soc_dapm_widget wm2000_dapm_widgets[] = {
264+
SND_SOC_DAPM_OUTPUT("SPKN"),
265+
SND_SOC_DAPM_OUTPUT("SPKP"),
266+
...
267+
};
268+
269+
/* Target, Path, Source */
270+
static const struct snd_soc_dapm_route wm2000_audio_map[] = {
271+
{ "SPKN", NULL, "ANC Engine" },
272+
{ "SPKP", NULL, "ANC Engine" },
273+
...
274+
};
275+
276+
static const struct snd_soc_component_driver soc_component_dev_wm2000 = {
277+
...
278+
.dapm_widgets = wm2000_dapm_widgets,
279+
.num_dapm_widgets = ARRAY_SIZE(wm2000_dapm_widgets),
280+
...
281+
};
282+
283+
In more complex cases the list of DAPM widgets and/or routes can be only
284+
known at build time. This happens for example when a driver supports
285+
different models having a different set of features. In those cases
286+
separate widgets and routes arrays implementing the case-specific features
287+
can be registered programmatically by calling snd_soc_dapm_new_controls()
288+
and snd_soc_dapm_add_routes().
255289

256290

257291
Codec/DSP Widget Interconnections

0 commit comments

Comments
 (0)