diff mbox series

[SRU,Focal,1/2] ASoC: add control components management

Message ID 20200224014550.8197-2-hui.wang@canonical.com
State New
Headers show
Series alsa/asoc: export the number of dmic to userspace to work with the latest ucm2 (focal) | expand

Commit Message

Hui Wang Feb. 24, 2020, 1:45 a.m. UTC
From: Jaroslav Kysela <perex@perex.cz>

BugLink: https://bugs.launchpad.net/bugs/1864400

This ASCII string can carry additional information about
soundcard components or configuration. Add the possibility
to set this string via the ASoC card.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Cc: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20191119174933.25526-1-perex@perex.cz
Signed-off-by: Mark Brown <broonie@kernel.org>
(cherry picked from commit dc73d73aa7145f55412611f3eead1e85ae026785)
Signed-off-by: Hui Wang <hui.wang@canonical.com>
---
 include/sound/soc.h  |  1 +
 sound/soc/soc-core.c | 13 +++++++++++++
 2 files changed, 14 insertions(+)
diff mbox series

Patch

diff --git a/include/sound/soc.h b/include/sound/soc.h
index f264c6509f00..efc5fb8f3d64 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -978,6 +978,7 @@  struct snd_soc_card {
 	const char *name;
 	const char *long_name;
 	const char *driver_name;
+	const char *components;
 	char dmi_longname[80];
 	char topology_shortname[32];
 
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 68dc29670b93..f61e5b50a66f 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2082,6 +2082,19 @@  static int snd_soc_instantiate_card(struct snd_soc_card *card)
 		}
 	}
 
+	if (card->components) {
+		/* the current implementation of snd_component_add() accepts */
+		/* multiple components in the string separated by space, */
+		/* but the string collision (identical string) check might */
+		/* not work correctly */
+		ret = snd_component_add(card->snd_card, card->components);
+		if (ret < 0) {
+			dev_err(card->dev, "ASoC: %s snd_component_add() failed: %d\n",
+				card->name, ret);
+			goto probe_end;
+		}
+	}
+
 	if (card->late_probe) {
 		ret = card->late_probe(card);
 		if (ret < 0) {