V4L/DVB (8718): gspca: suspend/resume added.
authorJean-Francois Moine <moinejf@free.fr>
Wed, 3 Sep 2008 19:48:10 +0000 (16:48 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Wed, 3 Sep 2008 21:36:58 +0000 (18:36 -0300)
Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
22 files changed:
drivers/media/video/gspca/conex.c
drivers/media/video/gspca/etoms.c
drivers/media/video/gspca/gspca.c
drivers/media/video/gspca/gspca.h
drivers/media/video/gspca/mars.c
drivers/media/video/gspca/ov519.c
drivers/media/video/gspca/pac207.c
drivers/media/video/gspca/pac7311.c
drivers/media/video/gspca/sonixb.c
drivers/media/video/gspca/sonixj.c
drivers/media/video/gspca/spca500.c
drivers/media/video/gspca/spca501.c
drivers/media/video/gspca/spca505.c
drivers/media/video/gspca/spca506.c
drivers/media/video/gspca/spca508.c
drivers/media/video/gspca/spca561.c
drivers/media/video/gspca/stk014.c
drivers/media/video/gspca/sunplus.c
drivers/media/video/gspca/t613.c
drivers/media/video/gspca/tv8532.c
drivers/media/video/gspca/vc032x.c
drivers/media/video/gspca/zc3xx.c

index cd3a3f5829b273d17a277e7f9134f3e0cf54cc44..739ef557c43484bd267c092984f9b09093a99882 100644 (file)
@@ -1026,6 +1026,10 @@ static struct usb_driver sd_driver = {
        .id_table = device_table,
        .probe = sd_probe,
        .disconnect = gspca_disconnect,
+#ifdef CONFIG_PM
+       .suspend = gspca_suspend,
+       .resume = gspca_resume,
+#endif
 };
 
 /* -- module insert / remove -- */
index ca23c3f9aaa28ceba3a26cd14751d5c87980ddaa..a3cccab7b8140acde43b050f25f5f425ea0ac2ef 100644 (file)
@@ -926,6 +926,10 @@ static struct usb_driver sd_driver = {
        .id_table = device_table,
        .probe = sd_probe,
        .disconnect = gspca_disconnect,
+#ifdef CONFIG_PM
+       .suspend = gspca_suspend,
+       .resume = gspca_resume,
+#endif
 };
 
 /* -- module insert / remove -- */
index 15d302b28b795d7d5e727a1e1091964dbb1e651f..2f7bf263255c534850ab33aed419548196afec5e 100644 (file)
@@ -114,7 +114,8 @@ static void fill_frame(struct gspca_dev *gspca_dev,
        cam_pkt_op pkt_scan;
 
        if (urb->status != 0) {
-               PDEBUG(D_ERR|D_PACK, "urb status: %d", urb->status);
+               if (!gspca_dev->frozen)
+                       PDEBUG(D_ERR|D_PACK, "urb status: %d", urb->status);
                return;         /* disconnection ? */
        }
        pkt_scan = gspca_dev->sd_desc->pkt_scan;
@@ -1808,6 +1809,33 @@ void gspca_disconnect(struct usb_interface *intf)
 }
 EXPORT_SYMBOL(gspca_disconnect);
 
+#ifdef CONFIG_PM
+int gspca_suspend(struct usb_interface *intf, pm_message_t message)
+{
+       struct gspca_dev *gspca_dev = usb_get_intfdata(intf);
+
+       if (!gspca_dev->streaming)
+               return 0;
+       gspca_dev->frozen = 1;          /* avoid urb error messages */
+       gspca_dev->sd_desc->stopN(gspca_dev);
+       destroy_urbs(gspca_dev);
+       gspca_set_alt0(gspca_dev);
+       gspca_dev->sd_desc->stop0(gspca_dev);
+       return 0;
+}
+EXPORT_SYMBOL(gspca_suspend);
+
+int gspca_resume(struct usb_interface *intf)
+{
+       struct gspca_dev *gspca_dev = usb_get_intfdata(intf);
+
+       gspca_dev->frozen = 0;
+       if (!gspca_dev->streaming)
+               return 0;
+       return gspca_init_transfer(gspca_dev);
+}
+EXPORT_SYMBOL(gspca_resume);
+#endif
 /* -- cam driver utility functions -- */
 
 /* auto gain and exposure algorithm based on the knee algorithm described here:
index 5cb584546ee68c868d0e4bbcd64fe0813903e6d2..2596568e82fd1916e0e306bcbb1a24576b572c24 100644 (file)
@@ -154,6 +154,9 @@ struct gspca_dev {
        struct mutex queue_lock;        /* ISOC queue protection */
        __u32 sequence;                 /* frame sequence number */
        char streaming;
+#ifdef CONFIG_PM
+       char frozen;                    /* suspend - resume */
+#endif
        char users;                     /* number of opens */
        char present;                   /* device connected */
        char nbufread;                  /* number of buffers for read() */
@@ -173,6 +176,10 @@ struct gspca_frame *gspca_frame_add(struct gspca_dev *gspca_dev,
                                    struct gspca_frame *frame,
                                    const __u8 *data,
                                    int len);
+#ifdef CONFIG_PM
+int gspca_suspend(struct usb_interface *intf, pm_message_t message);
+int gspca_resume(struct usb_interface *intf);
+#endif
 int gspca_auto_gain_n_exposure(struct gspca_dev *gspca_dev, int avg_lum,
        int desired_avg_lum, int deadzone, int gain_knee, int exposure_knee);
 #endif /* GSPCAV2_H */
index 21c4ee56a10aaef3702d8b3a79cce7ddda884c5a..d7e209578186167197df746c6aadd46948ade94f 100644 (file)
@@ -439,6 +439,10 @@ static struct usb_driver sd_driver = {
        .id_table = device_table,
        .probe = sd_probe,
        .disconnect = gspca_disconnect,
+#ifdef CONFIG_PM
+       .suspend = gspca_suspend,
+       .resume = gspca_resume,
+#endif
 };
 
 /* -- module insert / remove -- */
index b4f00ec0885cc0ec6600f52f362cd2c16d21b2ff..c132f8d2cf05ff9e957488de84653eb1b209c20c 100644 (file)
@@ -2132,6 +2132,10 @@ static struct usb_driver sd_driver = {
        .id_table = device_table,
        .probe = sd_probe,
        .disconnect = gspca_disconnect,
+#ifdef CONFIG_PM
+       .suspend = gspca_suspend,
+       .resume = gspca_resume,
+#endif
 };
 
 /* -- module insert / remove -- */
index cee45b0486cbff42afc2cdcbbc4f237302112ec2..d9668f4cb4d177c60b9d17970624cb195d19feb4 100644 (file)
@@ -596,6 +596,10 @@ static struct usb_driver sd_driver = {
        .id_table = device_table,
        .probe = sd_probe,
        .disconnect = gspca_disconnect,
+#ifdef CONFIG_PM
+       .suspend = gspca_suspend,
+       .resume = gspca_resume,
+#endif
 };
 
 /* -- module insert / remove -- */
index e4f56e0d3ff3abc7e9763cade971a2ace4c47ff3..4cc9379ee4110647c5389d88714bdb95941f616c 100644 (file)
@@ -936,6 +936,10 @@ static struct usb_driver sd_driver = {
        .id_table = device_table,
        .probe = sd_probe,
        .disconnect = gspca_disconnect,
+#ifdef CONFIG_PM
+       .suspend = gspca_suspend,
+       .resume = gspca_resume,
+#endif
 };
 
 /* -- module insert / remove -- */
index 11210c71f66c38e6c673dc1709c712fe46e23c49..e535ced79f1619f4f701d0e16d40697717734b59 100644 (file)
@@ -1231,6 +1231,10 @@ static struct usb_driver sd_driver = {
        .id_table = device_table,
        .probe = sd_probe,
        .disconnect = gspca_disconnect,
+#ifdef CONFIG_PM
+       .suspend = gspca_suspend,
+       .resume = gspca_resume,
+#endif
 };
 
 /* -- module insert / remove -- */
index 11a29a96960232daf74a7e0dfc6973b6364cc8ff..0d4677688c9136f260c9c6d220fbec07f63689e4 100644 (file)
@@ -1617,6 +1617,10 @@ static struct usb_driver sd_driver = {
        .id_table = device_table,
        .probe = sd_probe,
        .disconnect = gspca_disconnect,
+#ifdef CONFIG_PM
+       .suspend = gspca_suspend,
+       .resume = gspca_resume,
+#endif
 };
 
 /* -- module insert / remove -- */
index 17fe2c2a440d8f222f434c4c2692db093ef4e50d..5a20385fb170159e881473ab3d16de75ab06adc1 100644 (file)
@@ -1093,6 +1093,10 @@ static struct usb_driver sd_driver = {
        .id_table = device_table,
        .probe = sd_probe,
        .disconnect = gspca_disconnect,
+#ifdef CONFIG_PM
+       .suspend = gspca_suspend,
+       .resume = gspca_resume,
+#endif
 };
 
 /* -- module insert / remove -- */
index 51a3c3429ef0c26b2f71cb2e9439eec3d1b98921..525f1b3400e4d99e36f6d55e6e5ab333d8ab6e82 100644 (file)
@@ -2154,6 +2154,10 @@ static struct usb_driver sd_driver = {
        .id_table = device_table,
        .probe = sd_probe,
        .disconnect = gspca_disconnect,
+#ifdef CONFIG_PM
+       .suspend = gspca_suspend,
+       .resume = gspca_resume,
+#endif
 };
 
 /* -- module insert / remove -- */
index eda29d609359fdd2833cb31426e1e3620cc8639e..8f00558c2f5934750fcb3697563cfc22ed3e06cf 100644 (file)
@@ -855,6 +855,10 @@ static struct usb_driver sd_driver = {
        .id_table = device_table,
        .probe = sd_probe,
        .disconnect = gspca_disconnect,
+#ifdef CONFIG_PM
+       .suspend = gspca_suspend,
+       .resume = gspca_resume,
+#endif
 };
 
 /* -- module insert / remove -- */
index f622fa75766dfb0df3c47affed9efe8883f23282..ae772488cf734abacb5770407e95e008f16f8972 100644 (file)
@@ -772,6 +772,10 @@ static struct usb_driver sd_driver = {
        .id_table = device_table,
        .probe = sd_probe,
        .disconnect = gspca_disconnect,
+#ifdef CONFIG_PM
+       .suspend = gspca_suspend,
+       .resume = gspca_resume,
+#endif
 };
 
 /* -- module insert / remove -- */
index 699340c17deabbcd548b0606e6d0bc86b206be75..7b38c4e70fdf3b3152f5615125839311d01bcddb 100644 (file)
@@ -1667,6 +1667,10 @@ static struct usb_driver sd_driver = {
        .id_table = device_table,
        .probe = sd_probe,
        .disconnect = gspca_disconnect,
+#ifdef CONFIG_PM
+       .suspend = gspca_suspend,
+       .resume = gspca_resume,
+#endif
 };
 
 /* -- module insert / remove -- */
index ec575f5672df54ad7e30f8768da82470075cc7e0..b6a013f1dec47fa6c94931bde9d11131214e3618 100644 (file)
@@ -1184,6 +1184,10 @@ static struct usb_driver sd_driver = {
        .id_table = device_table,
        .probe = sd_probe,
        .disconnect = gspca_disconnect,
+#ifdef CONFIG_PM
+       .suspend = gspca_suspend,
+       .resume = gspca_resume,
+#endif
 };
 
 /* -- module insert / remove -- */
index 16219cf6a6d5105b555126b5c381f7d1024bc0b7..387a8cf2b3b155b2512917566cfc8021210e9006 100644 (file)
@@ -564,6 +564,10 @@ static struct usb_driver sd_driver = {
        .id_table = device_table,
        .probe = sd_probe,
        .disconnect = gspca_disconnect,
+#ifdef CONFIG_PM
+       .suspend = gspca_suspend,
+       .resume = gspca_resume,
+#endif
 };
 
 /* -- module insert / remove -- */
index 54efa48bee014cd55d3cde1912debbe6c348cd9b..c935384fc232b4a2c46040cdc19dabbd64f18b9d 100644 (file)
@@ -1456,6 +1456,10 @@ static struct usb_driver sd_driver = {
        .id_table = device_table,
        .probe = sd_probe,
        .disconnect = gspca_disconnect,
+#ifdef CONFIG_PM
+       .suspend = gspca_suspend,
+       .resume = gspca_resume,
+#endif
 };
 
 /* -- module insert / remove -- */
index fd6918eefbb07283ce6616cb089baa3eedaf51c4..357a2edad21e2487eaff54a961b9297a47ae3b44 100644 (file)
@@ -1014,6 +1014,10 @@ static struct usb_driver sd_driver = {
        .id_table = device_table,
        .probe = sd_probe,
        .disconnect = gspca_disconnect,
+#ifdef CONFIG_PM
+       .suspend = gspca_suspend,
+       .resume = gspca_resume,
+#endif
 };
 
 /* -- module insert / remove -- */
index 1ff8ba2f7fe54ca83cb10a6428483bcf8b7bd694..d2273624a91d56e2c9223ac9de03f9da37c3681a 100644 (file)
@@ -644,6 +644,10 @@ static struct usb_driver sd_driver = {
        .id_table = device_table,
        .probe = sd_probe,
        .disconnect = gspca_disconnect,
+#ifdef CONFIG_PM
+       .suspend = gspca_suspend,
+       .resume = gspca_resume,
+#endif
 };
 
 /* -- module insert / remove -- */
index f4a52956e0d91eaf8e5b8b37eaee0651f3f040d6..47c7ce641d996238e4a35386977d709055af8d54 100644 (file)
@@ -1774,6 +1774,10 @@ static struct usb_driver sd_driver = {
        .id_table = device_table,
        .probe = sd_probe,
        .disconnect = gspca_disconnect,
+#ifdef CONFIG_PM
+       .suspend = gspca_suspend,
+       .resume = gspca_resume,
+#endif
 };
 
 /* -- module insert / remove -- */
index d36f4d7d22b741d8e55c48608092846ea84fa9f6..79436f27cd4ec0368b6ccdd0d421b70f62c93eee 100644 (file)
@@ -7584,6 +7584,10 @@ static struct usb_driver sd_driver = {
        .id_table = device_table,
        .probe = sd_probe,
        .disconnect = gspca_disconnect,
+#ifdef CONFIG_PM
+       .suspend = gspca_suspend,
+       .resume = gspca_resume,
+#endif
 };
 
 static int __init sd_mod_init(void)