Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=f85bf29c9435baf927e1817e6b43c9429b84f822
Commit:     f85bf29c9435baf927e1817e6b43c9429b84f822
Parent:     175859bf1602c7ee38d720daa14a287072cc2b72
Author:     Oliver Neukum <[EMAIL PROTECTED]>
AuthorDate: Fri Dec 14 14:42:41 2007 +0100
Committer:  Jaroslav Kysela <[EMAIL PROTECTED]>
CommitDate: Thu Jan 31 17:29:36 2008 +0100

    [ALSA] usb audio suspend support
    
    This patch implements suspend/resume support for USB audio devices.
    It works with the microphone in my camera.
    
    Signed-off-by: Oliver Neukum <[EMAIL PROTECTED]>
    Signed-off-by: Takashi Iwai <[EMAIL PROTECTED]>
    Signed-off-by: Jaroslav Kysela <[EMAIL PROTECTED]>
---
 sound/usb/usbaudio.c |   41 +++++++++++++++++++++++++++++++++++++++++
 sound/usb/usbaudio.h |    1 +
 2 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
index 967b823..c52461d 100644
--- a/sound/usb/usbaudio.c
+++ b/sound/usb/usbaudio.c
@@ -2077,6 +2077,8 @@ int snd_usb_ctl_msg(struct usb_device *dev, unsigned int 
pipe, __u8 request,
 static int usb_audio_probe(struct usb_interface *intf,
                           const struct usb_device_id *id);
 static void usb_audio_disconnect(struct usb_interface *intf);
+static int usb_audio_suspend(struct usb_interface *intf, pm_message_t message);
+static int usb_audio_resume(struct usb_interface *intf);
 
 static struct usb_device_id usb_audio_ids [] = {
 #include "usbquirks.h"
@@ -2092,6 +2094,8 @@ static struct usb_driver usb_audio_driver = {
        .name =         "snd-usb-audio",
        .probe =        usb_audio_probe,
        .disconnect =   usb_audio_disconnect,
+       .suspend =      usb_audio_suspend,
+       .resume =       usb_audio_resume,
        .id_table =     usb_audio_ids,
 };
 
@@ -3654,6 +3658,43 @@ static void usb_audio_disconnect(struct usb_interface 
*intf)
                                 dev_get_drvdata(&intf->dev));
 }
 
+static int usb_audio_suspend(struct usb_interface *intf, pm_message_t message)
+{
+       struct snd_usb_audio *chip = dev_get_drvdata(&intf->dev);
+       struct list_head *p;
+       struct snd_usb_stream *as;
+
+       if (chip == (void *)-1L)
+               return 0;
+
+       snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot);
+       if (!chip->num_suspended_intf++) {
+               list_for_each(p, &chip->pcm_list) {
+                       as = list_entry(p, struct snd_usb_stream, list);
+                       snd_pcm_suspend_all(as->pcm);
+               }
+       }
+
+       return 0;
+}
+
+static int usb_audio_resume(struct usb_interface *intf)
+{
+       struct snd_usb_audio *chip = dev_get_drvdata(&intf->dev);
+
+       if (chip == (void *)-1L)
+               return 0;
+       if (--chip->num_suspended_intf)
+               return 0;
+       /*
+        * ALSA leaves material resumption to user space
+        * we just notify
+        */
+
+       snd_power_change_state(chip->card, SNDRV_CTL_POWER_D0);
+
+       return 0;
+}
 
 static int __init snd_usb_audio_init(void)
 {
diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h
index 2272f45..7cf18c3 100644
--- a/sound/usb/usbaudio.h
+++ b/sound/usb/usbaudio.h
@@ -126,6 +126,7 @@ struct snd_usb_audio {
        u32 usb_id;
        int shutdown;
        int num_interfaces;
+       int num_suspended_intf;
 
        struct list_head pcm_list;      /* list of pcm streams */
        int pcm_devs;
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to