All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] ASoC: tlv320dac33: Power down digital parts, when not needed
@ 2010-12-10 11:26 Peter Ujfalusi
  2010-12-10 22:51 ` Liam Girdwood
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Ujfalusi @ 2010-12-10 11:26 UTC (permalink / raw)
  To: alsa-devel; +Cc: Mark Brown, Liam Girdwood

If the following scenario has been followed:
1. Enable analog bypass
amixer sset 'Analog Left Bypass' on
amixer sset 'Analog Right Bypass' on

2. Start playback
aplay -fdat -d3 /dev/zero

After the playback stopped (3 sec), and the soc timeout (5 sec),
the digital parts of the codec will remain powered up.
This means that the DAI clocks are continue to run, the
oscillator remain operational, etc.

Use the SND_SOC_DAPM_POST_PMD widget to get notification
about the stopped stream, and power down the digital
part of the codec.
If the analog bypass is enabled, than the codec will remain in
BIAS_ON level, and things will work correctly.
In case, if the bypass is disabled, than the codec will
fall to BIAS_STANDBY than to BIAS_OFF level, as it used
to.

The digital part of DAC33 is initialized at every stream start
(DAPM_PRE:PRE_PMU event), so subsequent streams (within 5 sec)
will have working DAI.
When the codec is coming out from BIAS_OFF, the full power-up
sequence followed by the same DAPM_PRE widget event will power up
the digital part.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 sound/soc/codecs/tlv320dac33.c |   23 +++++++++++++++++++++--
 1 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/tlv320dac33.c b/sound/soc/codecs/tlv320dac33.c
index b3445b3..776ac80 100644
--- a/sound/soc/codecs/tlv320dac33.c
+++ b/sound/soc/codecs/tlv320dac33.c
@@ -354,6 +354,21 @@ static inline void dac33_soft_power(struct snd_soc_codec *codec, int power)
 	dac33_write(codec, DAC33_PWR_CTRL, reg);
 }
 
+static inline void dac33_disable_digital(struct snd_soc_codec *codec)
+{
+	u8 reg;
+
+	/* Stop the DAI clock */
+	reg = dac33_read_reg_cache(codec, DAC33_SER_AUDIOIF_CTRL_B);
+	reg &= ~DAC33_BCLKON;
+	dac33_write(codec, DAC33_SER_AUDIOIF_CTRL_B, reg);
+
+	/* Power down the Oscillator, and DACs */
+	reg = dac33_read_reg_cache(codec, DAC33_PWR_CTRL);
+	reg &= ~(DAC33_OSCPDNB | DAC33_DACRPDNB | DAC33_DACLPDNB);
+	dac33_write(codec, DAC33_PWR_CTRL, reg);
+}
+
 static int dac33_hard_power(struct snd_soc_codec *codec, int power)
 {
 	struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec);
@@ -402,7 +417,7 @@ exit:
 	return ret;
 }
 
-static int playback_event(struct snd_soc_dapm_widget *w,
+static int dac33_playback_event(struct snd_soc_dapm_widget *w,
 		struct snd_kcontrol *kcontrol, int event)
 {
 	struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(w->codec);
@@ -414,6 +429,9 @@ static int playback_event(struct snd_soc_dapm_widget *w,
 			dac33_prepare_chip(dac33->substream);
 		}
 		break;
+	case SND_SOC_DAPM_POST_PMD:
+		dac33_disable_digital(w->codec);
+		break;
 	}
 	return 0;
 }
@@ -609,7 +627,8 @@ static const struct snd_soc_dapm_widget dac33_dapm_widgets[] = {
 	SND_SOC_DAPM_SUPPLY("Right DAC Power",
 			    DAC33_RDAC_PWR_CTRL, 2, 0, NULL, 0),
 
-	SND_SOC_DAPM_PRE("Prepare Playback", playback_event),
+	SND_SOC_DAPM_PRE("Pre Playback", dac33_playback_event),
+	SND_SOC_DAPM_POST("Post Playback", dac33_playback_event),
 };
 
 static const struct snd_soc_dapm_route audio_map[] = {
-- 
1.7.3.3

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

* Re: [PATCH v2] ASoC: tlv320dac33: Power down digital parts, when not needed
  2010-12-10 11:26 [PATCH v2] ASoC: tlv320dac33: Power down digital parts, when not needed Peter Ujfalusi
@ 2010-12-10 22:51 ` Liam Girdwood
  0 siblings, 0 replies; 2+ messages in thread
From: Liam Girdwood @ 2010-12-10 22:51 UTC (permalink / raw)
  To: Peter Ujfalusi; +Cc: alsa-devel, Mark Brown

On Fri, 2010-12-10 at 13:26 +0200, Peter Ujfalusi wrote:
> If the following scenario has been followed:
> 1. Enable analog bypass
> amixer sset 'Analog Left Bypass' on
> amixer sset 'Analog Right Bypass' on
> 
> 2. Start playback
> aplay -fdat -d3 /dev/zero
> 
> After the playback stopped (3 sec), and the soc timeout (5 sec),
> the digital parts of the codec will remain powered up.
> This means that the DAI clocks are continue to run, the
> oscillator remain operational, etc.
> 
> Use the SND_SOC_DAPM_POST_PMD widget to get notification
> about the stopped stream, and power down the digital
> part of the codec.
> If the analog bypass is enabled, than the codec will remain in
> BIAS_ON level, and things will work correctly.
> In case, if the bypass is disabled, than the codec will
> fall to BIAS_STANDBY than to BIAS_OFF level, as it used
> to.
> 
> The digital part of DAC33 is initialized at every stream start
> (DAPM_PRE:PRE_PMU event), so subsequent streams (within 5 sec)
> will have working DAI.
> When the codec is coming out from BIAS_OFF, the full power-up
> sequence followed by the same DAPM_PRE widget event will power up
> the digital part.
> 
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> ---

Applied.

Thanks

Liam
-- 
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk

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

end of thread, other threads:[~2010-12-10 22:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-10 11:26 [PATCH v2] ASoC: tlv320dac33: Power down digital parts, when not needed Peter Ujfalusi
2010-12-10 22:51 ` 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.