All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: Sync initial widget state with hardware
@ 2011-02-09 17:56 Mark Brown
  2011-02-09 17:59 ` Mark Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Brown @ 2011-02-09 17:56 UTC (permalink / raw)
  To: Liam Girdwood; +Cc: alsa-devel, patches, Mark Brown

ASoC generally uses the register defaults for everything, but in some
cases the hardware will default to enabling some of the DAPM widgets
(clocks for example). Ensure that DAPM knows about the actual widget
state at initialisation by reading the enable bits after instantiating
the widgets so they don't get left enabled needlessly.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 sound/soc/soc-dapm.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index d0342aa..b4e8755 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -1664,6 +1664,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_add_routes);
 int snd_soc_dapm_new_widgets(struct snd_soc_dapm_context *dapm)
 {
 	struct snd_soc_dapm_widget *w;
+	unsigned int val;
 
 	list_for_each_entry(w, &dapm->card->widgets, list)
 	{
@@ -1712,6 +1713,18 @@ int snd_soc_dapm_new_widgets(struct snd_soc_dapm_context *dapm)
 		case snd_soc_dapm_post:
 			break;
 		}
+
+		/* Read the initial power state from the device */
+		if (w->reg >= 0) {
+			val = snd_soc_read(w->codec, w->reg);
+			val &= 1 << w->shift;
+			if (w->invert)
+				val = !val;
+
+			if (val)
+				w->active = 1;
+		}
+
 		w->new = 1;
 	}
 
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ASoC: Sync initial widget state with hardware
  2011-02-09 17:56 [PATCH] ASoC: Sync initial widget state with hardware Mark Brown
@ 2011-02-09 17:59 ` Mark Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2011-02-09 17:59 UTC (permalink / raw)
  To: Liam Girdwood; +Cc: alsa-devel, patches

On Wed, Feb 09, 2011 at 05:56:23PM +0000, Mark Brown wrote:
> ASoC generally uses the register defaults for everything, but in some
> cases the hardware will default to enabling some of the DAPM widgets
> (clocks for example). Ensure that DAPM knows about the actual widget
> state at initialisation by reading the enable bits after instantiating
> the widgets so they don't get left enabled needlessly.

Sorry, that's the wrong way to do this - will send an updated patch
shortly.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ASoC: Sync initial widget state with hardware
  2011-02-09 18:04 Mark Brown
@ 2011-02-09 21:50 ` Liam Girdwood
  0 siblings, 0 replies; 4+ messages in thread
From: Liam Girdwood @ 2011-02-09 21:50 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel, patches

On Wed, 2011-02-09 at 18:04 +0000, Mark Brown wrote:
> ASoC generally uses the register defaults for everything, but in some
> cases the hardware will default to enabling some of the DAPM widgets
> (clocks for example). Ensure that DAPM knows about the actual widget
> state at initialisation by reading the enable bits after instantiating
> the widgets so they don't get left enabled needlessly.
> 
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
-- 
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] ASoC: Sync initial widget state with hardware
@ 2011-02-09 18:04 Mark Brown
  2011-02-09 21:50 ` Liam Girdwood
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Brown @ 2011-02-09 18:04 UTC (permalink / raw)
  To: Liam Girdwood; +Cc: alsa-devel, patches, Mark Brown

ASoC generally uses the register defaults for everything, but in some
cases the hardware will default to enabling some of the DAPM widgets
(clocks for example). Ensure that DAPM knows about the actual widget
state at initialisation by reading the enable bits after instantiating
the widgets so they don't get left enabled needlessly.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 sound/soc/soc-dapm.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index d0342aa..b30eda6 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -1664,6 +1664,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_add_routes);
 int snd_soc_dapm_new_widgets(struct snd_soc_dapm_context *dapm)
 {
 	struct snd_soc_dapm_widget *w;
+	unsigned int val;
 
 	list_for_each_entry(w, &dapm->card->widgets, list)
 	{
@@ -1712,6 +1713,18 @@ int snd_soc_dapm_new_widgets(struct snd_soc_dapm_context *dapm)
 		case snd_soc_dapm_post:
 			break;
 		}
+
+		/* Read the initial power state from the device */
+		if (w->reg >= 0) {
+			val = snd_soc_read(w->codec, w->reg);
+			val &= 1 << w->shift;
+			if (w->invert)
+				val = !val;
+
+			if (val)
+				w->power = 1;
+		}
+
 		w->new = 1;
 	}
 
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-02-09 21:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-09 17:56 [PATCH] ASoC: Sync initial widget state with hardware Mark Brown
2011-02-09 17:59 ` Mark Brown
2011-02-09 18:04 Mark Brown
2011-02-09 21:50 ` Liam Girdwood

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.