From: Peter Ujfalusi <peter.ujfalusi@nokia.com>
To: ext Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: "alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
"lrg@slimlogic.co.uk" <lrg@slimlogic.co.uk>
Subject: Re: [PATCH] ASoC: TWL4030: PM fix for output amplifiers
Date: Mon, 22 Mar 2010 16:04:56 +0200 [thread overview]
Message-ID: <201003221604.56497.peter.ujfalusi@nokia.com> (raw)
In-Reply-To: <20100322134701.GB1379@rakim.wolfsonmicro.main>
On Monday 22 March 2010 15:47:01 ext Mark Brown wrote:
> On Mon, Mar 22, 2010 at 03:36:07PM +0200, Peter Ujfalusi wrote:
> > Gain controls on outputs affect the power consumption
> > when the gain is set to non 0 value.
> > To prevent amps beeing enabled, when they are not
> > needed, introduce the following workaround:
> > Track the state of each of this type of output.
> > In twl4030_write only allow actual write, when the
> > given output is enabled, otherwise only update
> > the reg_cache.
> > The PGA event handlers on power up will write the cached
> > value to the chip (restoring gain, routing selection).
> > On power down 0 is written to the register (disabling
> > the amp, and also just in case clearing the routing).
>
> I'm not 100% clear on what the existing code is supposed to be doing so
> this explanation isn't entirely clear to me, sorry.
Sorry for that. So the purpose of this:
Most of the output register on the TWL looks like this (take PREDRIVEL):
PREDL_CTL (0x25):
bit 0: Voice enable
bit 1: Audio L1 enable
bit 2: Audio L2 enable
bit 3: Audio R2 enable
bit 4-5: Gain (0x0 - power down, 0x1 - 6dB, 0x2 - 0dB, 0x3 - -6dB)
Now bits 0 - 3 are part of the DAPM route implementation.
bit 4-5 (gain) has simple volume control.
If there is no audio activity, and user changes the routing, than the gain value
will be also written to the chip, which causes the amp to be enabled.
Same goes, if the user changes the volume during inactive, the amp will be
enabled.
The existing code did not handle this situation, it only muted the gain when the
DAPM route got disabled.
So if the user modifies a gain, which is not part of the DAPM route, than that
is going to be enabled all the time, since the DAPM off will not hit it.
In this way I can be sure, that no other gains are actually enabled, than the
ones which is needed.
Oh, and if these gain values are other than 0, than it means that the amp is on,
and consumes power. So I need to make sure, that they are off, when they are not
needed.
> If it's supposed to be holding the controls at a mute value while the
> PGA is powered down then this is something that ASoC could benefit from
> in general - it'd be much better if we could keep amplifiers muted while
> not in active use and sequence the unmute into the power management at
> the end since this is good for pop/click management in general. I'd
> started to look at this but not yet got enough time to finish off
> implementing it.
Yes, I have been also thinking about that, but I really don't know how it can be
done:
For the DAPM part it is kind of easy, since we can decide in the core when to
write to the chip, and when only to the reg_cache.
But since I have the gain in the same register, when the user changing the
volume, than that control don't have information about the associated DAPM
widget's state.
> What I'd been thinking of doing was introducing a new control type which
> would be the inverse of supply - something that's switched on whenever
> its inputs are switched on, sequenced to power on at the end of the
> sequence and power off at the start. This would support both events and
> a set of controls, with the controls doing what this looks like and only
> writing to the device when the widget is powered. I've not actually
> tried implementing this properly yet, though - it'd involve adding a
> new bunch of control types, sadly.
Well, I think the core could have some basic support for similar cases, but I'm
not sure if it is possible to cover all cases in the core.
I do think, that at least the TWL codec has to be handled in a custom way. For
now at least.
Should I add more explanation to the commit message to make the intention more
clear?
--
Péter
next prev parent reply other threads:[~2010-03-22 14:05 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-22 13:36 [PATCH] ASoC: TWL4030: PM fix for output amplifiers Peter Ujfalusi
2010-03-22 13:47 ` Mark Brown
2010-03-22 14:04 ` Peter Ujfalusi [this message]
2010-03-22 14:15 ` Mark Brown
2010-03-22 14:46 ` Peter Ujfalusi
2010-03-22 15:06 ` Mark Brown
2010-03-22 15:31 ` Peter Ujfalusi
2010-03-22 16:19 ` Mark Brown
2010-03-22 16:48 ` Liam Girdwood
2010-03-22 17:00 ` Mark Brown
2010-03-23 7:05 ` Peter Ujfalusi
2010-03-23 7:59 ` Peter Ujfalusi
2010-03-23 10:02 ` Mark Brown
2010-03-23 12:29 ` Peter Ujfalusi
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=201003221604.56497.peter.ujfalusi@nokia.com \
--to=peter.ujfalusi@nokia.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=lrg@slimlogic.co.uk \
/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.