From: Takashi Iwai Subject: Re: No snd_pcm_resume_all() ? Date: Tue, 18 Apr 2006 15:12:32 +0200 Message-ID: References: <1145321918.4705.4.camel@localhost.localdomain> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Return-path: Received: from mx1.suse.de (mail.suse.de [195.135.220.2]) by alsa.jcu.cz (ALSA's E-mail Delivery System) with ESMTP id 4E56A1A9 for ; Tue, 18 Apr 2006 15:12:37 +0200 (MEST) In-Reply-To: <1145321918.4705.4.camel@localhost.localdomain> Sender: alsa-devel-admin@lists.sourceforge.net Errors-To: alsa-devel-admin@lists.sourceforge.net List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , List-Archive: To: Benjamin Herrenschmidt Cc: alsa-devel@alsa-project.org, Johannes Berg List-Id: alsa-devel@alsa-project.org At Tue, 18 Apr 2006 10:58:38 +1000, Benjamin Herrenschmidt wrote: > > Hi ! > > While tweaking a bit the power management code in Johannes' new snd-aoa > for powermac, I got it to properly suspend & resume playback on > sleep/waekup of the machine. However, an Alsa bit is missing for that to > work and I'd like to understand why. > > On suspend, it's fairly simple, we call snd_pcm_suspend_all() to suspend > all streams before we go put the hardware into low power state. > > On resume, I would expect to have a similar snd_pcm_resume_all() to call > after I've restored the hardware & codecs state. However... it's not > there. I hacked one up myself (patch below) and it seems to work fine. > > It appears that Alsa expects the streams to be resumed via some userland > initiated ioctl, which for some reason is never called on my machine. > What is the rationale there ? it's userland that is expected to > save/restore hardware state ? That doesn't really match the linux PM > model at this point and it seems that Alsa userland isn't notified of > suspend/resume at least on powermacs. Possibly didn't set SNDRV_PCM_INFO_RESUME bit to snd_pcm_hardware.info flags? > Just adding snd_pcm_resume_all() and calling it at the right time seems > to work fine for us, thus is there any reason why the patch below > couldn't be pushed upstream ? Indeed, the pcm resume was designed to be called from application to restart. The flow is like below: When suspended, the app calls snd_pcm_resume() (via ioctl), and it's firstly blocked by snd_power_wait() until the power state becomes D0. At resume, the driver resume callback sets to D0 once after the chip is re-initialized and ready for use. Then woken-up snd_pcm_resume() triggers the stream. So, calling snd_pcm_resume_all() in the resume callback is basically superfluous. When SNDRV_PCM_INFO_RESUME is not set, snd_pcm_resume() doesn't trigger but returns an error. Then the app is supposed to do reset-and-restart by itself. (Or use a helper function in alsa-lib to do this all, too.) Takashi ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642