[alsa-devel] power state in power save mode

Takashi Iwai tiwai at suse.de
Thu Apr 11 14:17:21 CEST 2019


On Thu, 11 Apr 2019 13:39:21 +0200,
Kailang wrote:
> 
> Hi Takashi,
> 
> I also checked the value by simply printk.
> I put printk in alc256_init() and alc256_shutup().
> Without power save, i could see the expected value at suspend and resume.
> 
> With power save, alc256_init() will run after music play, it will print out value 0x0 at this time.
> alc256_shutup() already run at count down time value of power_save = ?.
> So, alc256_shutup will not run again when system suspend. power state value will also not print out during suspend.
> Is this  the expectation behavior?

Yes, the same suspend/resume path is used for the codec driver for
both runtime and system suspend/resume.  For the runtime PM, the
callbacks are called with power_state=0.

> I test add your patch.
> Then test with power save option. Wait time up, codec go to power save mode(run alc256_shutup()). 
> Let system to suspend.(it will not run alc256_shutup() again)
> Then resume it. Play a short wave file. alc256_init() will run after music play, it will value 0x10 at this time.
> 
> I think alc256_shutup() will not update power state when it with power save option.
> If I want to use alc256_shutup() to check power state then do some thing, I think it's impossible. Right?

When the system was already in the runtime suspended state, it won't
trigger the codec suspend again.  With the recent code (after the
commit b5a236c175b0), we enforce the resume even if it wasn't used at
the suspend time.  So for the resume, it's always woken up with the
proper power_state when the system is resumed via S3/S4 (not via
runtime PM).



Takashi

> 
> BR,
> Kailang
> 
> ________________________________________
> 從: Takashi Iwai [tiwai at suse.de]
> 寄件日期: 2019年4月10日 下午 11:52
> 至: Kailang
> 副本:  (alsa-devel at alsa-project.org)
> 主旨: Re: power state in power save mode
> 
> On Wed, 10 Apr 2019 05:00:31 +0200,
> Kailang wrote:
> >
> > > -----Original Message-----
> > > From: Takashi Iwai <tiwai at suse.de>
> > > Sent: Tuesday, April 9, 2019 6:15 PM
> > > To: Kailang <kailang at realtek.com>
> > > Cc: (alsa-devel at alsa-project.org) <alsa-devel at alsa-project.org>
> > > Subject: Re: power state in power save mode
> > >
> > > On Tue, 09 Apr 2019 11:54:27 +0200,
> > > Kailang wrote:
> > > >
> > > > Hi Takashi,
> > > >
> > > > https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git/commit
> > > > /?h=for-next&id=98081ca62cbac31fb0f7efaf90b2e7384ce22257
> > > >
> > > > Use upper patch to print power state in function alc256_init() and
> > > alc256_shutup().
> > > > But when kernel turn on power_save = 1. (echo 1 >
> > > > /sys/module/snd_hda_intel/parameters/power_save)
> > > >
> > > > The print power state value always be 0x0.
> > >
> > > That's expected, it means PM_EVENT_ON.
> > > The power_state value is changed only during the suspend and resume.
> > > Once after returning from resume, it's set to PM_EVENT_ON.
> >
> > I also test suspend and resume. It also show 0x0.
> > If it turn off power save, power state value will normally.
> 
> What exactly did you see?  I checked the value by simply printk and it
> behaved as expected, both with and without power save.
> 
> > >
> > > > ( If it turn off power save, power state value will normally)
> > >
> > > What does it mean exactly...?
> > >
> > > Actually one missing piece is to set PMSG_ON at the device initialization.  A
> > > patch like below.
> >
> > Add this patch, the power state value will show on suspend and resume. Right?
> > I will test it later.
> 
> This won't change anything about the suspend/resume behavior, but it's
> just for some consistency in case the driver refers to the state
> before entering the suspend/resume callback.
> 
> 
> Takashi
> 
> 
> > >
> > >
> > > thanks,
> > >
> > > Takashi
> > >
> > > --- a/sound/pci/hda/hda_codec.c
> > > +++ b/sound/pci/hda/hda_codec.c
> > > @@ -969,6 +969,7 @@ int snd_hda_codec_device_new(struct hda_bus *bus,
> > > struct snd_card *card,
> > >
> > >     /* power-up all before initialization */
> > >     hda_set_power_state(codec, AC_PWRST_D0);
> > > +   codec->core.dev.power.power_state = PMSG_ON;
> > >
> > >     snd_hda_codec_proc_new(codec);
> > >
> > >
> > > ------Please consider the environment before printing this e-mail.
> >


More information about the Alsa-devel mailing list