[alsa-devel] [PATCH 1/2] ASoC: simple-card-utils: add asoc_simple_card_of_parse_widgets()

Kuninori Morimoto kuninori.morimoto.gx at renesas.com
Fri Jun 16 03:38:50 CEST 2017


From: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>

Current simple card drivers are parsing widgets on each own driver
(only simple-card at this point, but will be supported on all drivers)
Encapsulation is one of simple card util's purpose.
Let's add asoc_simple_card_of_parse_widgets for it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
---
 include/sound/simple_card_utils.h     |  2 ++
 sound/soc/generic/simple-card-utils.c | 19 +++++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h
index 889c8ff..42c6a6a 100644
--- a/include/sound/simple_card_utils.h
+++ b/include/sound/simple_card_utils.h
@@ -103,5 +103,7 @@ void asoc_simple_card_parse_convert(struct device *dev, char *prefix,
 int asoc_simple_card_of_parse_routing(struct snd_soc_card *card,
 				      char *prefix,
 				      int optional);
+int asoc_simple_card_of_parse_widgets(struct snd_soc_card *card,
+				      char *prefix);
 
 #endif /* __SIMPLE_CARD_UTILS_H */
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index a2b6d95..26d64fa 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -397,6 +397,25 @@ int asoc_simple_card_of_parse_routing(struct snd_soc_card *card,
 }
 EXPORT_SYMBOL_GPL(asoc_simple_card_of_parse_routing);
 
+int asoc_simple_card_of_parse_widgets(struct snd_soc_card *card,
+				      char *prefix)
+{
+	struct device_node *node = card->dev->of_node;
+	char prop[128];
+
+	if (!prefix)
+		prefix = "";
+
+	snprintf(prop, sizeof(prop), "%s%s", prefix, "widgets");
+
+	if (of_property_read_bool(node, prop))
+		return snd_soc_of_parse_audio_simple_widgets(card, prop);
+
+	/* no widgets is not error */
+	return 0;
+}
+EXPORT_SYMBOL_GPL(asoc_simple_card_of_parse_widgets);
+
 /* Module information */
 MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>");
 MODULE_DESCRIPTION("ALSA SoC Simple Card Utils");
-- 
1.9.1



More information about the Alsa-devel mailing list