All of 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: Vinod Koul <vinod.koul@intel.com>,
	alsa-devel@alsa-project.org, Lars-Peter Clausen <lars@metafoo.de>
Subject: [PATCH v2 09/11] ASoC: Add component level set_bias_level() support
Date: Mon, 16 Jun 2014 18:13:09 +0200	[thread overview]
Message-ID: <1402935191-18398-10-git-send-email-lars@metafoo.de> (raw)
In-Reply-To: <1402935191-18398-1-git-send-email-lars@metafoo.de>

This patch adds a set_bias_level() callback to the snd_soc_component_driver
struct similar to that found in the snd_soc_codec_driver struct. This will allow
any component type and not just CODECs to implement such a callback.

The semantics of the component driver and CODEC driver set_bias_level()
callbacks slightly differ. While the CODEC driver callback only takes the target
bias level, the component driver callback takes both the current and the target
bias level. Also for the component driver callback the current bias level will
be automatically updated to the target bias level if the callback does not
return an error, whereas with the CODEC bias level callback this has to be done
in every callback by hand. The change in semantics was implement because the new
semantics more closly match what drivers need. Most drivers are interested in
both the current and the target bias level and all drivers update the current to
the target bias level in case there is no error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 include/sound/soc.h  |  4 ++++
 sound/soc/soc-core.c | 17 +++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 9a5b4f6..e560b6f 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -680,6 +680,10 @@ struct snd_soc_component_driver {
 	void (*seq_notifier)(struct snd_soc_component *, enum snd_soc_dapm_type,
 		int subseq);
 	int (*stream_event)(struct snd_soc_component *, int event);
+	int (*set_bias_level)(struct snd_soc_component *component,
+		enum snd_soc_bias_level current_level,
+		enum snd_soc_bias_level target_level);
+	bool idle_bias_off;
 };
 
 struct snd_soc_component {
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 5fe732f..a414689 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -4011,6 +4011,20 @@ static int snd_soc_component_stream_event(struct snd_soc_dapm_context *dapm,
 	return component->driver->stream_event(component, event);
 }
 
+static int snd_soc_component_set_bias_level(struct snd_soc_dapm_context *dapm,
+	enum snd_soc_bias_level target_level)
+{
+	struct snd_soc_component *component = dapm->component;
+	int ret;
+
+	ret = component->driver->set_bias_level(component, dapm->bias_level,
+		target_level);
+	if (ret == 0)
+		dapm->bias_level = target_level;
+
+	return ret;
+}
+
 static int snd_soc_component_initialize(struct snd_soc_component *component,
 	const struct snd_soc_component_driver *driver, struct device *dev)
 {
@@ -4032,10 +4046,13 @@ static int snd_soc_component_initialize(struct snd_soc_component *component,
 	dapm->dev = dev;
 	dapm->component = component;
 	dapm->bias_level = SND_SOC_BIAS_OFF;
+	dapm->idle_bias_off = driver->idle_bias_off;
 	if (driver->seq_notifier)
 		dapm->seq_notifier = snd_soc_component_seq_notifier;
 	if (driver->stream_event)
 		dapm->stream_event = snd_soc_component_stream_event;
+	if (driver->set_bias_level)
+		dapm->set_bias_level = snd_soc_component_set_bias_level;
 
 	INIT_LIST_HEAD(&component->dai_list);
 	mutex_init(&component->io_mutex);
-- 
1.8.0

  parent reply	other threads:[~2014-06-16 16:13 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-16 16:13 [PATCH v2 00/11] ASoC: Add support for DAPM at the component level Lars-Peter Clausen
2014-06-16 16:13 ` [PATCH v2 01/11] ASoC: Move name_prefix from CODEC to component Lars-Peter Clausen
2014-06-21 20:03   ` Mark Brown
2014-06-16 16:13 ` [PATCH v2 02/11] ASoC: Move name and id from CODEC/platform " Lars-Peter Clausen
2014-06-21 20:04   ` Mark Brown
2014-06-16 16:13 ` [PATCH v2 03/11] ASoC: Split component registration into two steps Lars-Peter Clausen
2014-06-21 20:05   ` Mark Brown
2014-06-16 16:13 ` [PATCH v2 04/11] ASoC: Auto disconnect pins from all DAPM contexts Lars-Peter Clausen
2014-06-21 20:07   ` Mark Brown
2014-06-16 16:13 ` [PATCH v2 05/11] ASoC: Add a set_bias_level() callback to the DAPM context struct Lars-Peter Clausen
2014-06-21 20:14   ` Mark Brown
2014-06-22  5:26     ` Vinod Koul
2014-06-22 10:12       ` Mark Brown
2014-06-23  4:34         ` Vinod Koul
2014-06-23 10:08           ` Mark Brown
2014-06-21 20:34   ` Mark Brown
2014-06-16 16:13 ` [PATCH v2 06/11] ASoC: Add DAPM support at the component level Lars-Peter Clausen
2014-06-21 20:34   ` Mark Brown
2014-06-16 16:13 ` [PATCH v2 07/11] ASoC: Use component DAPM context for platforms Lars-Peter Clausen
2014-06-21 20:34   ` Mark Brown
2014-06-16 16:13 ` [PATCH v2 08/11] ASoC: Add component level stream_event() and seq_notifier() support Lars-Peter Clausen
2014-06-21 20:35   ` Mark Brown
2014-06-16 16:13 ` Lars-Peter Clausen [this message]
2014-06-21 20:38   ` [PATCH v2 09/11] ASoC: Add component level set_bias_level() support Mark Brown
2014-06-16 16:13 ` [PATCH v2 10/11] ASoC: dapm: Remove DAI DAPM context Lars-Peter Clausen
2014-06-21 20:36   ` Mark Brown
2014-06-16 16:13 ` [PATCH v2 11/11] ASoC: dapm: Remove platform field from widget and dapm context struct Lars-Peter Clausen
2014-06-21 20:36   ` Mark Brown

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=1402935191-18398-10-git-send-email-lars@metafoo.de \
    --to=lars@metafoo.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=vinod.koul@intel.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.