[alsa-devel] [PATCH] ASoC: tlv320dac33: Power down digital parts, when not needed
If the following scenarion 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.
Signed-off-by: Peter Ujfalusi peter.ujfalusi@nokia.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[] = {
On Fri, Dec 10, 2010 at 12:14:49PM +0200, Peter Ujfalusi wrote:
If the following scenarion has been followed:
- Enable analog bypass
amixer sset 'Analog Left Bypass' on amixer sset 'Analog Right Bypass' on
Acked-by: Mark Brown broonie@opensource.wolfsonmicro.com
It'd have been nice to have mentioned how the digital gets turned back on in the changelog!
On Friday 10 December 2010 12:44:49 ext Mark Brown wrote:
On Fri, Dec 10, 2010 at 12:14:49PM +0200, Peter Ujfalusi wrote:
If the following scenarion has been followed:
- Enable analog bypass
amixer sset 'Analog Left Bypass' on amixer sset 'Analog Right Bypass' on
Acked-by: Mark Brown broonie@opensource.wolfsonmicro.com
It'd have been nice to have mentioned how the digital gets turned back on in the changelog!
Currently the codec is going to be reset at every stream start, since it can get confused, if I fail to do that, especially, when the FIFO is enabled. In case, when the bypass was not enabled the codec anyway will hit BIAS_OFF, so next time, when we power it on, it is going through the power-up sequence.
I do have some plans to actually remove the need for this reset requirement at every stream start (it adds considerable amount of latency, and other unwanted side effects).
I can resend the patch with updated changelog.
participants (2)
-
Mark Brown
-
Peter Ujfalusi