All of lore.kernel.org
 help / color / mirror / Atom feed
* No snd_pcm_resume_all() ?
@ 2006-04-18  0:58 Benjamin Herrenschmidt
  2006-04-18  1:20 ` Lee Revell
  2006-04-18 13:12 ` Takashi Iwai
  0 siblings, 2 replies; 18+ messages in thread
From: Benjamin Herrenschmidt @ 2006-04-18  0:58 UTC (permalink / raw)
  To: alsa-devel; +Cc: Takashi Iwai, Johannes Berg

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

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2006-04-18 20:59 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-18  0:58 No snd_pcm_resume_all() ? Benjamin Herrenschmidt
2006-04-18  1:20 ` 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

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.