V4L/DVB (9740): sms1xxx: add USB suspend and hibernation support
authorUri Shkolnik <uris@siano-ms.com>
Sat, 22 Nov 2008 17:08:46 +0000 (14:08 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 29 Dec 2008 19:53:41 +0000 (17:53 -0200)
This patch provides USB suspend and hibernation support
for Siano's SMS chipset based USB device

Signed-off-by: Uri Shkolnik <uris@siano-ms.com>
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/dvb/siano/smsusb.c

index 87a3c24454b9903e5ad0fdc6aba160cf512091d6..5d7ca341771995941d1810effabf7a104a83224c 100644 (file)
@@ -432,11 +432,56 @@ static void smsusb_disconnect(struct usb_interface *intf)
        smsusb_term_device(intf);
 }
 
+static int smsusb_suspend(struct usb_interface *intf, pm_message_t msg)
+{
+       struct smsusb_device_t *dev =
+               (struct smsusb_device_t *)usb_get_intfdata(intf);
+       printk(KERN_INFO "%s  Entering status %d.\n", __func__, msg.event);
+       smsusb_stop_streaming(dev);
+       return 0;
+}
+
+static int smsusb_resume(struct usb_interface *intf)
+{
+       int rc, i;
+       struct smsusb_device_t *dev =
+               (struct smsusb_device_t *)usb_get_intfdata(intf);
+       struct usb_device *udev = interface_to_usbdev(intf);
+
+       printk(KERN_INFO "%s  Entering.\n", __func__);
+       usb_clear_halt(udev, usb_rcvbulkpipe(udev, 0x81));
+       usb_clear_halt(udev, usb_rcvbulkpipe(udev, 0x02));
+
+       for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++)
+               printk(KERN_INFO "endpoint %d %02x %02x %d\n", i,
+                      intf->cur_altsetting->endpoint[i].desc.bEndpointAddress,
+                      intf->cur_altsetting->endpoint[i].desc.bmAttributes,
+                      intf->cur_altsetting->endpoint[i].desc.wMaxPacketSize);
+
+       if (intf->num_altsetting > 0) {
+               rc = usb_set_interface(udev,
+                                      intf->cur_altsetting->desc.
+                                      bInterfaceNumber, 0);
+               if (rc < 0) {
+                       printk(KERN_INFO
+                              "%s usb_set_interface failed, rc %d\n",
+                              __func__, rc);
+                       return rc;
+               }
+       }
+
+       smsusb_start_streaming(dev);
+       return 0;
+}
+
 static struct usb_driver smsusb_driver = {
        .name                   = "sms1xxx",
        .probe                  = smsusb_probe,
        .disconnect             = smsusb_disconnect,
        .id_table               = smsusb_id_table,
+
+       .suspend                = smsusb_suspend,
+       .resume                 = smsusb_resume,
 };
 
 int smsusb_register(void)