All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jarkko Nikula <jhnikula@gmail.com>
To: alsa-devel@alsa-project.org
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>,
	Peter Ujfalusi <peter.ujfalusi@nokia.com>,
	Liam Girdwood <lrg@slimlogic.co.uk>
Subject: [PATCH 2/4] ASoC: Add optional pointer to machine audio routes to snd_soc_card
Date: Wed, 26 Jan 2011 13:58:15 +0200	[thread overview]
Message-ID: <1296043097-11720-2-git-send-email-jhnikula@gmail.com> (raw)
In-Reply-To: <1296043097-11720-1-git-send-email-jhnikula@gmail.com>

This is targeted mostly to cross-device setups where single audio map
defining routes around and between the codecs looks cleaner than defining
and registering maps to each codec separately from machine init callbacks.

This could be also used to reduce simple machine init callbacks where only
snd_soc_dapm_add_routes and snd_soc_dapm_sync are called. However, this does
work only if the widgets names are unique in the system.

Idea of common audio map came from Peter Ujfalusi <peter.ujfalusi@nokia.com>.

Signed-off-by: Jarkko Nikula <jhnikula@gmail.com>
Cc: Peter Ujfalusi <peter.ujfalusi@nokia.com>
---
 include/sound/soc.h  |    8 ++++++++
 sound/soc/soc-core.c |   21 +++++++++++++++++++++
 2 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 1355ef0..fec03ae 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -686,6 +686,14 @@ struct snd_soc_card {
 	struct snd_soc_pcm_runtime *rtd_aux;
 	int num_aux_rtd;
 
+	/*
+	 * optional machine audio map. Can be used as an alternative for
+	 * snd_soc_dapm_add_routes call in machine init in single codec setup
+	 * or as a common audio map in cross-device setup
+	 */
+	const struct snd_soc_dapm_route *route;
+	int num_routes;
+
 	struct work_struct deferred_resume_work;
 
 	/* lists of probed devices belonging to this card */
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 4da185f..17484b1 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1727,6 +1727,7 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card)
 	struct snd_soc_codec *codec;
 	struct snd_soc_codec_conf *codec_conf;
 	enum snd_soc_compress_type compress_type;
+	const char *temp;
 	int ret, i;
 
 	mutex_lock(&card->mutex);
@@ -1810,6 +1811,26 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card)
 		}
 	}
 
+	if (card->route) {
+		/*
+		 * use the last codec and dapm context of it when setting up
+		 * the common audio map
+		 */
+		codec = list_first_entry(&card->codec_dev_list,
+					 struct snd_soc_codec, card_list);
+		temp = codec->name_prefix;
+		codec->name_prefix = NULL;
+		ret = snd_soc_dapm_add_routes(&codec->dapm,
+					      card->route, card->num_routes);
+		if (ret < 0) {
+			pr_err("asoc: failed to add routes %s: %d\n",
+			       card->name, ret);
+			goto probe_aux_dev_err;
+		}
+		codec->name_prefix = temp;
+		snd_soc_dapm_sync(&codec->dapm);
+	}
+
 	snprintf(card->snd_card->shortname, sizeof(card->snd_card->shortname),
 		 "%s",  card->name);
 	snprintf(card->snd_card->longname, sizeof(card->snd_card->longname),
-- 
1.7.2.3

  reply	other threads:[~2011-01-26 11:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-26 11:58 [PATCH 1/4] ASoC: soc-core: Increment codec and platform driver refcounts before probing Jarkko Nikula
2011-01-26 11:58 ` Jarkko Nikula [this message]
2011-01-26 13:35   ` [PATCH 2/4] ASoC: Add optional pointer to machine audio routes to snd_soc_card Mark Brown
2011-01-26 11:58 ` [PATCH 3/4] ASoC: Add optional pointer to codec interconnects to snd_soc_codec_driver Jarkko Nikula
2011-01-26 13:41   ` Mark Brown
2011-01-26 11:58 ` [PATCH 4/4] ASoC: Convert bunch of codecs to use soc-core interconnect registration Jarkko Nikula
2011-01-26 13:28   ` Mark Brown
2011-01-26 13:41     ` Jarkko Nikula
2011-01-27  6:57   ` Peter Ujfalusi
2011-01-27  7:21     ` Jarkko Nikula
2011-01-27  9:58       ` Mark Brown
2011-01-26 14:28 ` [PATCH 1/4] ASoC: soc-core: Increment codec and platform driver refcounts before probing Jarkko Nikula

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1296043097-11720-2-git-send-email-jhnikula@gmail.com \
    --to=jhnikula@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=lrg@slimlogic.co.uk \
    --cc=peter.ujfalusi@nokia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.