[alsa-devel] [PATCH 3/4] ASoC: Add optional pointer to codec interconnects to snd_soc_codec_driver

Jarkko Nikula jhnikula at gmail.com
Wed Jan 26 12:58:16 CET 2011


This is aimed to as an alternative to snd_soc_dapm_add_routes call in codec
drivers that have only single interconnect map. By doing this in soc-core
saves from doing error checking in codec drivers.

This idea came from Mark Brown <broonie at opensource.wolfsonmicro.com>.

Signed-off-by: Jarkko Nikula <jhnikula at gmail.com>
---
 include/sound/soc.h  |    8 ++++++++
 sound/soc/soc-core.c |   22 +++++++++++++++++++++-
 2 files changed, 29 insertions(+), 1 deletions(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index fec03ae..38597c0 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -551,6 +551,14 @@ struct snd_soc_codec_driver {
 
 	void (*seq_notifier)(struct snd_soc_dapm_context *,
 			     enum snd_soc_dapm_type);
+
+	/*
+	 * optional map of codec audio path interconnects. Can be used as
+	 * an alternative for snd_soc_dapm_add_routes call in codec drivers
+	 * that have only single interconnect map
+	 */
+	const struct snd_soc_dapm_route *route;
+	int num_routes;
 };
 
 /* SoC platform interface */
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 17484b1..2dbb91e 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1402,7 +1402,7 @@ static void soc_set_name_prefix(struct snd_soc_card *card,
 static int soc_probe_codec(struct snd_soc_card *card,
 			   struct snd_soc_codec *codec)
 {
-	int ret = 0;
+	int ret = 0, err;
 
 	codec->card = card;
 	codec->dapm.card = card;
@@ -1421,6 +1421,18 @@ static int soc_probe_codec(struct snd_soc_card *card,
 		}
 	}
 
+	if (codec->driver->route) {
+		ret = snd_soc_dapm_add_routes(&codec->dapm,
+					      codec->driver->route,
+					      codec->driver->num_routes);
+		if (ret < 0) {
+			dev_err(codec->dev,
+				"asoc: failed to add interconnects: %d\n",
+				ret);
+			goto err_routes;
+		}
+	}
+
 	soc_init_codec_debugfs(codec);
 
 	/* mark codec as probed and add to card codec list */
@@ -1430,6 +1442,14 @@ static int soc_probe_codec(struct snd_soc_card *card,
 
 	return 0;
 
+err_routes:
+	if (codec->driver->remove) {
+		err = codec->driver->remove(codec);
+		if (err < 0)
+			dev_err(codec->dev,
+				"asoc: failed to remove %s: %d\n",
+				codec->name, err);
+	}
 err_probe:
 	module_put(codec->dev->driver->owner);
 
-- 
1.7.2.3



More information about the Alsa-devel mailing list