Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Mark Brown <broonie@kernel.org>, Liam Girdwood <lgirdwood@gmail.com>
Cc: alsa-devel@alsa-project.org, Lars-Peter Clausen <lars@metafoo.de>
Subject: [PATCH 06/11] ASoC: Add a set_bias_level() callback to the DAPM context struct
Date: Sun, 18 May 2014 14:24:13 +0200	[thread overview]
Message-ID: <1400415858-11025-7-git-send-email-lars@metafoo.de> (raw)
In-Reply-To: <1400415858-11025-1-git-send-email-lars@metafoo.de>

Currently the DAPM code directly looks at the CODEC driver struct to get a
handle to the set_bias_level() callback. This patch adds a new set_bias_level()
callback to the DAPM context struct. The DAPM code will use this new callback
instead of the CODEC callback. For CODECs the new callback is set up to call the
CODEC specific set_bias_level callback(). Not looking directly at the CODEC
driver struct will allow non CODEC DAPM contexts to implement a set_bias_level()
callback.

This is also similar to how the seq_notifier() and stream_event() callbacks are
currently handled.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 include/sound/soc-dapm.h |  2 ++
 sound/soc/soc-core.c     |  9 +++++++++
 sound/soc/soc-dapm.c     | 11 +++--------
 3 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
index 8db627c..3a5c4f9 100644
--- a/include/sound/soc-dapm.h
+++ b/include/sound/soc-dapm.h
@@ -601,6 +601,8 @@ struct snd_soc_dapm_context {
 	struct list_head list;
 
 	int (*stream_event)(struct snd_soc_dapm_context *dapm, int event);
+	int (*set_bias_level)(struct snd_soc_dapm_context *dapm,
+			      enum snd_soc_bias_level level);
 
 #ifdef CONFIG_DEBUG_FS
 	struct dentry *debugfs_dapm;
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index bca8a71..f42429c 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -4285,6 +4285,13 @@ static int snd_soc_codec_drv_read(struct snd_soc_component *component,
 	return 0;
 }
 
+static int snd_soc_codec_set_bias_level(struct snd_soc_dapm_context *dapm,
+	enum snd_soc_bias_level level)
+{
+	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm);
+	return codec->driver->set_bias_level(codec, level);
+}
+
 /**
  * snd_soc_register_codec - Register a codec with the ASoC core
  *
@@ -4322,6 +4329,8 @@ int snd_soc_register_codec(struct device *dev,
 	codec->dapm.component = &codec->component;
 	codec->dapm.seq_notifier = codec_drv->seq_notifier;
 	codec->dapm.stream_event = codec_drv->stream_event;
+	if (codec_drv->set_bias_level)
+		codec->dapm.set_bias_level = snd_soc_codec_set_bias_level;
 	codec->dev = dev;
 	codec->driver = codec_drv;
 	codec->component.val_bytes = codec_drv->reg_word_size;
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 3ccbf9b..297b712 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -427,15 +427,10 @@ static int snd_soc_dapm_set_bias_level(struct snd_soc_dapm_context *dapm,
 	if (ret != 0)
 		goto out;
 
-	if (dapm->codec) {
-		if (dapm->codec->driver->set_bias_level)
-			ret = dapm->codec->driver->set_bias_level(dapm->codec,
-								  level);
-		else
-			dapm->bias_level = level;
-	} else if (!card || dapm != &card->dapm) {
+	if (dapm->set_bias_level)
+		ret = dapm->set_bias_level(dapm, level);
+	else if (!card || dapm != &card->dapm)
 		dapm->bias_level = level;
-	}
 
 	if (ret != 0)
 		goto out;
-- 
1.8.0

  parent reply	other threads:[~2014-05-18 12:24 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-18 12:24 [PATCH 00/11] ASoC: Add support for DAPM at the component level Lars-Peter Clausen
2014-05-18 12:24 ` [PATCH 01/11] ASoC: Move name_prefix from CODEC to component Lars-Peter Clausen
2014-05-18 12:24 ` [PATCH 02/11] ASoC: Move name and id from CODEC/platform " Lars-Peter Clausen
2014-05-18 12:24 ` [PATCH 03/11] ASoC: Split component registration into two steps Lars-Peter Clausen
2014-05-18 12:24 ` [PATCH 04/11] ASoC: Auto disconnect pins from all DAPM contexts Lars-Peter Clausen
2014-05-18 12:24 ` [PATCH 05/11] ASoC: Add helper functions to cast from DAPM context to CODEC/platform Lars-Peter Clausen
2014-05-26 19:36   ` Lars-Peter Clausen
2014-06-01 18:18     ` Mark Brown
2014-06-06  5:47     ` Vinod Koul
2014-06-06  6:20       ` Lars-Peter Clausen
2014-05-18 12:24 ` Lars-Peter Clausen [this message]
2014-05-18 12:24 ` [PATCH 07/11] ASoC: Add DAPM support at the component level Lars-Peter Clausen
2014-05-18 12:24 ` [PATCH 08/11] ASoC: Use component DAPM context for platforms Lars-Peter Clausen
2014-05-18 12:24 ` [PATCH 09/11] ASoC: Add component level stream_event() and seq_notifier() support Lars-Peter Clausen
2014-05-18 12:24 ` [PATCH 10/11] ASoC: Add component level set_bias_level() support Lars-Peter Clausen
2014-05-18 12:24 ` [PATCH 11/11] ASoC: dapm: Remove DAI DAPM context Lars-Peter Clausen

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=1400415858-11025-7-git-send-email-lars@metafoo.de \
    --to=lars@metafoo.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox