From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: alsa-devel@alsa-project.org
Cc: Takashi Iwai <tiwai@suse.de>, Johannes Berg <johannes@sipsolutions.net>
Subject: No snd_pcm_resume_all() ?
Date: Tue, 18 Apr 2006 10:58:38 +1000 [thread overview]
Message-ID: <1145321918.4705.4.camel@localhost.localdomain> (raw)
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.
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 ?
Cheers,
Ben.
Index: linux-work/sound/core/pcm_native.c
===================================================================
--- linux-work.orig/sound/core/pcm_native.c 2006-04-13 09:58:55.000000000 +1000
+++ linux-work/sound/core/pcm_native.c 2006-04-18 10:34:46.000000000 +1000
@@ -1176,6 +1176,35 @@
return res;
}
+/**
+ * snd_pcm_resume_all
+ * @pcm: the PCM instance
+ *
+ * Trigger RESUME to all substreams in the given pcm.
+ * After this call, all streams that were SUSPENDED gets resumed to RUNNING state.
+ */
+int snd_pcm_resume_all(struct snd_pcm *pcm)
+{
+ struct snd_pcm_substream *substream;
+ int stream, err = 0;
+
+ if (! pcm)
+ return 0;
+
+ for (stream = 0; stream < 2; stream++) {
+ for (substream = pcm->streams[stream].substream;
+ substream; substream = substream->next) {
+ /* FIXME: the open/close code should lock this as well */
+ if (substream->runtime == NULL)
+ continue;
+ err = snd_pcm_resume(substream);
+ if (err < 0 && err != -EBUSY)
+ return err;
+ }
+ }
+ return 0;
+}
+
#else
static int snd_pcm_resume(struct snd_pcm_substream *substream)
@@ -1183,6 +1212,11 @@
return -ENOSYS;
}
+int snd_pcm_resume_all(struct snd_pcm *pcm)
+{
+ return -ENOSYS;
+}
+
#endif /* CONFIG_PM */
/*
Index: linux-work/include/sound/pcm.h
===================================================================
--- linux-work.orig/include/sound/pcm.h 2006-04-13 09:58:51.000000000 +1000
+++ linux-work/include/sound/pcm.h 2006-04-18 10:37:23.000000000 +1000
@@ -464,6 +464,7 @@
#ifdef CONFIG_PM
int snd_pcm_suspend(struct snd_pcm_substream *substream);
int snd_pcm_suspend_all(struct snd_pcm *pcm);
+int snd_pcm_resume_all(struct snd_pcm *pcm);
#endif
int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream, unsigned int cmd, void *arg);
int snd_pcm_open_substream(struct snd_pcm *pcm, int stream, struct file *file,
Index: linux-work/sound/core/pcm.c
===================================================================
--- linux-work.orig/sound/core/pcm.c 2006-04-13 09:58:55.000000000 +1000
+++ linux-work/sound/core/pcm.c 2006-04-18 10:36:35.000000000 +1000
@@ -1110,6 +1110,7 @@
#ifdef CONFIG_PM
EXPORT_SYMBOL(snd_pcm_suspend);
EXPORT_SYMBOL(snd_pcm_suspend_all);
+EXPORT_SYMBOL(snd_pcm_resume_all);
#endif
EXPORT_SYMBOL(snd_pcm_kernel_ioctl);
EXPORT_SYMBOL(snd_pcm_mmap_data);
-------------------------------------------------------
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
next reply other threads:[~2006-04-18 0:58 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-18 0:58 Benjamin Herrenschmidt [this message]
2006-04-18 1:20 ` No snd_pcm_resume_all() ? Lee Revell
2006-04-18 1:27 ` Benjamin Herrenschmidt
2006-04-18 1:36 ` Lee Revell
2006-04-18 1:45 ` Lee Revell
2006-04-18 2:13 ` Benjamin Herrenschmidt
2006-04-18 2:12 ` Benjamin Herrenschmidt
2006-04-18 13:12 ` Takashi Iwai
2006-04-18 17:55 ` Johannes Berg
2006-04-18 18:05 ` Takashi Iwai
2006-04-18 18:06 ` Johannes Berg
2006-04-18 18:10 ` Takashi Iwai
2006-04-18 18:12 ` Johannes Berg
2006-04-18 18:25 ` Takashi Iwai
2006-04-18 18:40 ` Johannes Berg
2006-04-18 18:54 ` Takashi Iwai
2006-04-18 19:27 ` Jaroslav Kysela
2006-04-18 20:59 ` Benjamin Herrenschmidt
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=1145321918.4705.4.camel@localhost.localdomain \
--to=benh@kernel.crashing.org \
--cc=alsa-devel@alsa-project.org \
--cc=johannes@sipsolutions.net \
--cc=tiwai@suse.de \
/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.