[alsa-devel] [PATCH 2/3] ALSA: hda - WAKEEN feature enabling for runtime pm

Wang, Xingchao xingchao.wang at intel.com
Tue Jul 23 10:06:21 CEST 2013



> -----Original Message-----
> From: David Henningsson [mailto:david.henningsson at canonical.com]
> Sent: Tuesday, July 23, 2013 3:37 PM
> To: Wang Xingchao
> Cc: alsa-devel at alsa-project.org; tiwai at suse.de; Girdwood, Liam R; Wang,
> Xingchao
> Subject: Re: [PATCH 2/3] ALSA: hda - WAKEEN feature enabling for runtime pm
> 
> On 07/22/2013 09:19 AM, Wang Xingchao wrote:
> > With runtime power save feature enabled, Headphone hotplug event will
> > not be detected while controller/codec in D3. HDA has feature WAKEEN
> > to let codec wake up system if controller is in D3 or system in
> > S3.(HDA Spec 4.5.9.2/3). Codec can send out INT or wake up controller
> > depending on whether CIE or GIE enabled.(Figure 4, Interupt
> > structure).
> 
> Oh, so you actually got it working? Nice! :-)
> 
> > The controller must be in RESET mode after enter runtime-suspend,
> > otherwise it will not be waken up even if codec send out wake-up
> > event. And STATESTS will be cleared after controller brought out of RESET
> mode.
> 
> There seems to be nothing in this patch that sets the controller in RESET mode,
> is this something done in a later patch, or is that code already present today,
> or...?

Yeah, an interesting story on this. You can see the original patch in attached file, it did add
reset before runtime-suspend. But I find Mengdong did same thing for another bug fix already.

commit 3af3f356e16041c3353210214da601782e2cd8b4
Author: Mengdong Lin <mengdong.lin at intel.com>
Date:   Mon Jun 24 10:18:54 2013 -0400

    ALSA: hda - reset hda link during system/runtime suspend

    If all the codecs report ClkStopOK (OK to stop bus clock) after being put to
    D3, this patch will reset the HDA link before the controller is put to D3.

    So the link will be in reset during system or runtime suspend, the bus clock
    stops and the codecs are in D3(ClkStop) state.

    This may help to reduce power consumption by dozens of mW on some peripheral
    hda codecs.

    Signed-off-by: Mengdong Lin <mengdong.lin at intel.com>
    Signed-off-by: Takashi Iwai <tiwai at suse.de>

Thanks
--xingchao
> 
> > This patch only enable WAKEEN for runtime-suspend(Controller D3) mode,
> > not for system S3 mode. with tool "evtest", Headphone hotplug events
> > could be cought and reported successfully.
> 
> >
> > Signed-off-by: Wang Xingchao <xingchao.wang at linux.intel.com>
> > ---
> >   sound/pci/hda/hda_intel.c | 25 +++++++++++++++++++++++++
> >   1 file changed, 25 insertions(+)
> >
> > diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
> > index 8860dd5..a7ac7fd 100644
> > --- a/sound/pci/hda/hda_intel.c
> > +++ b/sound/pci/hda/hda_intel.c
> > @@ -2970,6 +2970,11 @@ static int azx_runtime_suspend(struct device
> *dev)
> >   {
> >   	struct snd_card *card = dev_get_drvdata(dev);
> >   	struct azx *chip = card->private_data;
> > +	int status;
> > +
> > +	/* enable controller wake up event */
> > +	azx_writew(chip, WAKEEN, azx_readw(chip, WAKEEN) |
> > +		  STATESTS_INT_MASK);
> >
> >   	azx_stop_chip(chip);
> >   	azx_enter_link_reset(chip);
> > @@ -2983,11 +2988,31 @@ static int azx_runtime_resume(struct device
> *dev)
> >   {
> >   	struct snd_card *card = dev_get_drvdata(dev);
> >   	struct azx *chip = card->private_data;
> > +	struct hda_bus *bus;
> > +	struct hda_codec *codec;
> > +	int status;
> >
> >   	if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL)
> >   		hda_display_power(true);
> > +
> > +	/* Read STATESTS before controller reset */
> > +	status = azx_readw(chip, STATESTS);
> > +
> >   	azx_init_pci(chip);
> >   	azx_init_chip(chip, 1);
> > +
> > +	bus = chip->bus;
> > +	if (status && bus) {
> > +		list_for_each_entry(codec, &bus->codec_list, list)
> > +			if (status & (1 << codec->addr))
> > +				queue_delayed_work(codec->bus->workq,
> > +						   &codec->jackpoll_work,
> codec->jackpoll_interval);
> 
> Is there a reason you want to move the jack detection to a delayed work, i e,
> why can't we just call:
> 
>   	snd_hda_jack_set_dirty_all(codec);
>   	snd_hda_jack_poll_all(codec);
> 
> ...from here?
> 
> > +	}
> > +
> > +	/* disable controller Wake Up event*/
> > +	azx_writew(chip, WAKEEN, azx_readw(chip, WAKEEN) &
> > +			~STATESTS_INT_MASK);
> > +
> >   	return 0;
> >   }
> >
> >
> 
> 
> 
> --
> David Henningsson, Canonical Ltd.
> https://launchpad.net/~diwic
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ALSA-hda-WAKEEN-feature-enabling-for-runtime-pm.patch
Type: application/octet-stream
Size: 2990 bytes
Desc: 0001-ALSA-hda-WAKEEN-feature-enabling-for-runtime-pm.patch
URL: <http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20130723/0357e5e8/attachment.obj>


More information about the Alsa-devel mailing list