alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Mark Brown <broonie@kernel.org>, Liam Girdwood <lgirdwood@gmail.com>
Cc: "Andreas Irestål" <Andreas.Irestal@axis.com>,
	alsa-devel@alsa-project.org,
	"Lars-Peter Clausen" <lars@metafoo.de>,
	"Stephen Warren" <swarren@nvidia.com>,
	"Hebbar Gururaja" <gururaja.hebbar@ti.com>
Subject: [PATCH 5/5] ASoC: tlv320aic3x: Use snd_soc_dapm_mixer_update_power
Date: Wed, 24 Jul 2013 15:27:39 +0200	[thread overview]
Message-ID: <1374672459-5202-5-git-send-email-lars@metafoo.de> (raw)
In-Reply-To: <1374672459-5202-1-git-send-email-lars@metafoo.de>

Use snd_soc_dapm_mixer_update_power() instead of reimplementing its
functionality.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 sound/soc/codecs/tlv320aic3x.c | 49 ++++++++++++++----------------------------
 1 file changed, 16 insertions(+), 33 deletions(-)

diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index cad4fb1..d3417c8 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -147,10 +147,9 @@ static int snd_soc_dapm_put_volsw_aic3x(struct snd_kcontrol *kcontrol,
 	int max = mc->max;
 	unsigned int mask = (1 << fls(max)) - 1;
 	unsigned int invert = mc->invert;
-	unsigned short val, val_mask;
-	int ret;
-	struct snd_soc_dapm_path *path;
-	int found = 0;
+	unsigned short val;
+	struct snd_soc_dapm_update update;
+	int connect, change;
 
 	val = (ucontrol->value.integer.value[0] & mask);
 
@@ -158,42 +157,26 @@ static int snd_soc_dapm_put_volsw_aic3x(struct snd_kcontrol *kcontrol,
 	if (val)
 		val = mask;
 
+	connect = !!val;
+
 	if (invert)
 		val = mask - val;
-	val_mask = mask << shift;
-	val = val << shift;
-
-	mutex_lock(&widget->codec->mutex);
 
-	if (snd_soc_test_bits(widget->codec, reg, val_mask, val)) {
-		/* find dapm widget path assoc with kcontrol */
-		list_for_each_entry(path, &widget->dapm->card->paths, list) {
-			if (path->kcontrol != kcontrol)
-				continue;
+	mask <<= shift;
+	val <<= shift;
 
-			/* found, now check type */
-			found = 1;
-			if (val)
-				/* new connection */
-				path->connect = invert ? 0 : 1;
-			else
-				/* old connection must be powered down */
-				path->connect = invert ? 1 : 0;
+	change = snd_soc_test_bits(widget->codec, val, mask, reg);
+	if (change) {
+		update.kcontrol = kcontrol;
+		update.reg = reg;
+		update.mask = mask;
+		update.val = val;
 
-			dapm_mark_dirty(path->source, "tlv320aic3x source");
-			dapm_mark_dirty(path->sink, "tlv320aic3x sink");
-
-			break;
-		}
+		snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, connect,
+			&update);
 	}
 
-	mutex_unlock(&widget->codec->mutex);
-
-	if (found)
-		snd_soc_dapm_sync(widget->dapm);
-
-	ret = snd_soc_update_bits_locked(widget->codec, reg, val_mask, val);
-	return ret;
+	return change;
 }
 
 /*
-- 
1.8.0

  parent reply	other threads:[~2013-07-24 13:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-24 13:27 [PATCH 1/5] ASoC: dapm: Fix return value of snd_soc_dapm_put_{volsw, enum_virt}() Lars-Peter Clausen
2013-07-24 13:27 ` [PATCH 2/5] ASoC: dapm: Pass snd_soc_card directly to soc_dpcm_runtime_update() Lars-Peter Clausen
2013-07-24 13:27 ` [PATCH 3/5] ASoC: dapm: Run widget updates for shared controls at the same time Lars-Peter Clausen
2013-07-24 13:27 ` [PATCH 4/5] ASoC: dapm: Add a update parameter to snd_soc_dapm_{mux, mixer}_update_power Lars-Peter Clausen
2013-07-24 13:27 ` Lars-Peter Clausen [this message]
2013-07-24 13:56 ` [PATCH 1/5] ASoC: dapm: Fix return value of snd_soc_dapm_put_{volsw, enum_virt}() 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=1374672459-5202-5-git-send-email-lars@metafoo.de \
    --to=lars@metafoo.de \
    --cc=Andreas.Irestal@axis.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=gururaja.hebbar@ti.com \
    --cc=lgirdwood@gmail.com \
    --cc=swarren@nvidia.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;
as well as URLs for NNTP newsgroup(s).