aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/gspca')
-rw-r--r--drivers/media/video/gspca/conex.c3
-rw-r--r--drivers/media/video/gspca/finepix.c8
-rw-r--r--drivers/media/video/gspca/gspca.c56
-rw-r--r--drivers/media/video/gspca/gspca.h6
-rw-r--r--drivers/media/video/gspca/pac7311.c3
-rw-r--r--drivers/media/video/gspca/spca501.c3
-rw-r--r--drivers/media/video/gspca/spca505.c4
-rw-r--r--drivers/media/video/gspca/spca561.c3
-rw-r--r--drivers/media/video/gspca/vc032x.c3
-rw-r--r--drivers/media/video/gspca/zc3xx.c3
10 files changed, 63 insertions, 29 deletions
diff --git a/drivers/media/video/gspca/conex.c b/drivers/media/video/gspca/conex.c
index a9d51ba7c57c..de28354ea5ba 100644
--- a/drivers/media/video/gspca/conex.c
+++ b/drivers/media/video/gspca/conex.c
@@ -846,10 +846,13 @@ static int sd_start(struct gspca_dev *gspca_dev)
846 return 0; 846 return 0;
847} 847}
848 848
849/* called on streamoff with alt 0 and on disconnect */
849static void sd_stop0(struct gspca_dev *gspca_dev) 850static void sd_stop0(struct gspca_dev *gspca_dev)
850{ 851{
851 int retry = 50; 852 int retry = 50;
852 853
854 if (!gspca_dev->present)
855 return;
853 reg_w_val(gspca_dev, 0x0000, 0x00); 856 reg_w_val(gspca_dev, 0x0000, 0x00);
854 reg_r(gspca_dev, 0x0002, 1); 857 reg_r(gspca_dev, 0x0002, 1);
855 reg_w_val(gspca_dev, 0x0053, 0x00); 858 reg_w_val(gspca_dev, 0x0053, 0x00);
diff --git a/drivers/media/video/gspca/finepix.c b/drivers/media/video/gspca/finepix.c
index 65d3cbfe6b27..607942fd7970 100644
--- a/drivers/media/video/gspca/finepix.c
+++ b/drivers/media/video/gspca/finepix.c
@@ -276,6 +276,12 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
276 /* Stop the state machine */ 276 /* Stop the state machine */
277 if (dev->state != FPIX_NOP) 277 if (dev->state != FPIX_NOP)
278 wait_for_completion(&dev->can_close); 278 wait_for_completion(&dev->can_close);
279}
280
281/* called on streamoff with alt 0 and disconnect */
282static void sd_stop0(struct gspca_dev *gspca_dev)
283{
284 struct usb_fpix *dev = (struct usb_fpix *) gspca_dev;
279 285
280 usb_free_urb(dev->control_urb); 286 usb_free_urb(dev->control_urb);
281 dev->control_urb = NULL; 287 dev->control_urb = NULL;
@@ -385,6 +391,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
385error: 391error:
386 /* Free the ressources */ 392 /* Free the ressources */
387 sd_stopN(gspca_dev); 393 sd_stopN(gspca_dev);
394 sd_stop0(gspca_dev);
388 return ret; 395 return ret;
389} 396}
390 397
@@ -425,6 +432,7 @@ static const struct sd_desc sd_desc = {
425 .init = sd_init, 432 .init = sd_init,
426 .start = sd_start, 433 .start = sd_start,
427 .stopN = sd_stopN, 434 .stopN = sd_stopN,
435 .stop0 = sd_stop0,
428}; 436};
429 437
430/* -- device connect -- */ 438/* -- device connect -- */
diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c
index e48fbfc8ad05..748a87e82e44 100644
--- a/drivers/media/video/gspca/gspca.c
+++ b/drivers/media/video/gspca/gspca.c
@@ -646,15 +646,14 @@ static void gspca_stream_off(struct gspca_dev *gspca_dev)
646{ 646{
647 gspca_dev->streaming = 0; 647 gspca_dev->streaming = 0;
648 atomic_set(&gspca_dev->nevent, 0); 648 atomic_set(&gspca_dev->nevent, 0);
649 if (gspca_dev->present) { 649 if (gspca_dev->present
650 if (gspca_dev->sd_desc->stopN) 650 && gspca_dev->sd_desc->stopN)
651 gspca_dev->sd_desc->stopN(gspca_dev); 651 gspca_dev->sd_desc->stopN(gspca_dev);
652 destroy_urbs(gspca_dev); 652 destroy_urbs(gspca_dev);
653 gspca_set_alt0(gspca_dev); 653 gspca_set_alt0(gspca_dev);
654 if (gspca_dev->sd_desc->stop0) 654 if (gspca_dev->sd_desc->stop0)
655 gspca_dev->sd_desc->stop0(gspca_dev); 655 gspca_dev->sd_desc->stop0(gspca_dev);
656 PDEBUG(D_STREAM, "stream off OK"); 656 PDEBUG(D_STREAM, "stream off OK");
657 }
658} 657}
659 658
660static void gspca_set_default_mode(struct gspca_dev *gspca_dev) 659static void gspca_set_default_mode(struct gspca_dev *gspca_dev)
@@ -863,7 +862,7 @@ static int dev_open(struct inode *inode, struct file *file)
863 int ret; 862 int ret;
864 863
865 PDEBUG(D_STREAM, "%s open", current->comm); 864 PDEBUG(D_STREAM, "%s open", current->comm);
866 gspca_dev = (struct gspca_dev *) video_devdata(file); 865 gspca_dev = video_drvdata(file);
867 if (mutex_lock_interruptible(&gspca_dev->queue_lock)) 866 if (mutex_lock_interruptible(&gspca_dev->queue_lock))
868 return -ERESTARTSYS; 867 return -ERESTARTSYS;
869 if (!gspca_dev->present) { 868 if (!gspca_dev->present) {
@@ -875,6 +874,13 @@ static int dev_open(struct inode *inode, struct file *file)
875 ret = -EBUSY; 874 ret = -EBUSY;
876 goto out; 875 goto out;
877 } 876 }
877
878 /* protect the subdriver against rmmod */
879 if (!try_module_get(gspca_dev->module)) {
880 ret = -ENODEV;
881 goto out;
882 }
883
878 gspca_dev->users++; 884 gspca_dev->users++;
879 885
880 /* one more user */ 886 /* one more user */
@@ -884,10 +890,10 @@ static int dev_open(struct inode *inode, struct file *file)
884#ifdef GSPCA_DEBUG 890#ifdef GSPCA_DEBUG
885 /* activate the v4l2 debug */ 891 /* activate the v4l2 debug */
886 if (gspca_debug & D_V4L2) 892 if (gspca_debug & D_V4L2)
887 gspca_dev->vdev.debug |= V4L2_DEBUG_IOCTL 893 gspca_dev->vdev->debug |= V4L2_DEBUG_IOCTL
888 | V4L2_DEBUG_IOCTL_ARG; 894 | V4L2_DEBUG_IOCTL_ARG;
889 else 895 else
890 gspca_dev->vdev.debug &= ~(V4L2_DEBUG_IOCTL 896 gspca_dev->vdev->debug &= ~(V4L2_DEBUG_IOCTL
891 | V4L2_DEBUG_IOCTL_ARG); 897 | V4L2_DEBUG_IOCTL_ARG);
892#endif 898#endif
893 ret = 0; 899 ret = 0;
@@ -921,6 +927,7 @@ static int dev_close(struct inode *inode, struct file *file)
921 gspca_dev->memory = GSPCA_MEMORY_NO; 927 gspca_dev->memory = GSPCA_MEMORY_NO;
922 } 928 }
923 file->private_data = NULL; 929 file->private_data = NULL;
930 module_put(gspca_dev->module);
924 mutex_unlock(&gspca_dev->queue_lock); 931 mutex_unlock(&gspca_dev->queue_lock);
925 932
926 PDEBUG(D_STREAM, "close done"); 933 PDEBUG(D_STREAM, "close done");
@@ -1748,11 +1755,6 @@ out:
1748 return ret; 1755 return ret;
1749} 1756}
1750 1757
1751static void dev_release(struct video_device *vfd)
1752{
1753 /* nothing */
1754}
1755
1756static struct file_operations dev_fops = { 1758static struct file_operations dev_fops = {
1757 .owner = THIS_MODULE, 1759 .owner = THIS_MODULE,
1758 .open = dev_open, 1760 .open = dev_open,
@@ -1800,7 +1802,7 @@ static struct video_device gspca_template = {
1800 .name = "gspca main driver", 1802 .name = "gspca main driver",
1801 .fops = &dev_fops, 1803 .fops = &dev_fops,
1802 .ioctl_ops = &dev_ioctl_ops, 1804 .ioctl_ops = &dev_ioctl_ops,
1803 .release = dev_release, /* mandatory */ 1805 .release = video_device_release,
1804 .minor = -1, 1806 .minor = -1,
1805}; 1807};
1806 1808
@@ -1869,17 +1871,18 @@ int gspca_dev_probe(struct usb_interface *intf,
1869 init_waitqueue_head(&gspca_dev->wq); 1871 init_waitqueue_head(&gspca_dev->wq);
1870 1872
1871 /* init video stuff */ 1873 /* init video stuff */
1872 memcpy(&gspca_dev->vdev, &gspca_template, sizeof gspca_template); 1874 gspca_dev->vdev = video_device_alloc();
1873 gspca_dev->vdev.parent = &dev->dev; 1875 memcpy(gspca_dev->vdev, &gspca_template, sizeof gspca_template);
1874 memcpy(&gspca_dev->fops, &dev_fops, sizeof gspca_dev->fops); 1876 gspca_dev->vdev->parent = &dev->dev;
1875 gspca_dev->vdev.fops = &gspca_dev->fops; 1877 gspca_dev->module = module;
1876 gspca_dev->fops.owner = module; /* module protection */
1877 gspca_dev->present = 1; 1878 gspca_dev->present = 1;
1878 ret = video_register_device(&gspca_dev->vdev, 1879 video_set_drvdata(gspca_dev->vdev, gspca_dev);
1880 ret = video_register_device(gspca_dev->vdev,
1879 VFL_TYPE_GRABBER, 1881 VFL_TYPE_GRABBER,
1880 video_nr); 1882 video_nr);
1881 if (ret < 0) { 1883 if (ret < 0) {
1882 err("video_register_device err %d", ret); 1884 err("video_register_device err %d", ret);
1885 video_device_release(gspca_dev->vdev);
1883 goto out; 1886 goto out;
1884 } 1887 }
1885 1888
@@ -1887,7 +1890,8 @@ int gspca_dev_probe(struct usb_interface *intf,
1887 PDEBUG(D_PROBE, "probe ok"); 1890 PDEBUG(D_PROBE, "probe ok");
1888 return 0; 1891 return 0;
1889out: 1892out:
1890 kref_put(&gspca_dev->kref, gspca_delete); 1893 kfree(gspca_dev->usb_buf);
1894 kfree(gspca_dev);
1891 return ret; 1895 return ret;
1892} 1896}
1893EXPORT_SYMBOL(gspca_dev_probe); 1897EXPORT_SYMBOL(gspca_dev_probe);
@@ -1905,7 +1909,7 @@ void gspca_disconnect(struct usb_interface *intf)
1905 usb_set_intfdata(intf, NULL); 1909 usb_set_intfdata(intf, NULL);
1906 1910
1907/* We don't want people trying to open up the device */ 1911/* We don't want people trying to open up the device */
1908 video_unregister_device(&gspca_dev->vdev); 1912 video_unregister_device(gspca_dev->vdev);
1909 1913
1910 gspca_dev->present = 0; 1914 gspca_dev->present = 0;
1911 gspca_dev->streaming = 0; 1915 gspca_dev->streaming = 0;
diff --git a/drivers/media/video/gspca/gspca.h b/drivers/media/video/gspca/gspca.h
index 1d9dc90b4791..d25e8d69373b 100644
--- a/drivers/media/video/gspca/gspca.h
+++ b/drivers/media/video/gspca/gspca.h
@@ -97,7 +97,7 @@ struct sd_desc {
97 cam_pkt_op pkt_scan; 97 cam_pkt_op pkt_scan;
98/* optional operations */ 98/* optional operations */
99 cam_v_op stopN; /* called on stream off - main alt */ 99 cam_v_op stopN; /* called on stream off - main alt */
100 cam_v_op stop0; /* called on stream off - alt 0 */ 100 cam_v_op stop0; /* called on stream off & disconnect - alt 0 */
101 cam_v_op dq_callback; /* called when a frame has been dequeued */ 101 cam_v_op dq_callback; /* called when a frame has been dequeued */
102 cam_jpg_op get_jcomp; 102 cam_jpg_op get_jcomp;
103 cam_jpg_op set_jcomp; 103 cam_jpg_op set_jcomp;
@@ -120,8 +120,8 @@ struct gspca_frame {
120}; 120};
121 121
122struct gspca_dev { 122struct gspca_dev {
123 struct video_device vdev; /* !! must be the first item */ 123 struct video_device *vdev;
124 struct file_operations fops; 124 struct module *module; /* subdriver handling the device */
125 struct usb_device *dev; 125 struct usb_device *dev;
126 struct kref kref; 126 struct kref kref;
127 struct file *capt_file; /* file doing video capture */ 127 struct file *capt_file; /* file doing video capture */
diff --git a/drivers/media/video/gspca/pac7311.c b/drivers/media/video/gspca/pac7311.c
index e5ff9a6199ef..fbd45e235d97 100644
--- a/drivers/media/video/gspca/pac7311.c
+++ b/drivers/media/video/gspca/pac7311.c
@@ -749,10 +749,13 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
749 reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_6=LED */ 749 reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_6=LED */
750} 750}
751 751
752/* called on streamoff with alt 0 and on disconnect */
752static void sd_stop0(struct gspca_dev *gspca_dev) 753static void sd_stop0(struct gspca_dev *gspca_dev)
753{ 754{
754 struct sd *sd = (struct sd *) gspca_dev; 755 struct sd *sd = (struct sd *) gspca_dev;
755 756
757 if (!gspca_dev->present)
758 return;
756 if (sd->sensor == SENSOR_PAC7302) { 759 if (sd->sensor == SENSOR_PAC7302) {
757 reg_w(gspca_dev, 0xff, 0x01); 760 reg_w(gspca_dev, 0xff, 0x01);
758 reg_w(gspca_dev, 0x78, 0x40); 761 reg_w(gspca_dev, 0x78, 0x40);
diff --git a/drivers/media/video/gspca/spca501.c b/drivers/media/video/gspca/spca501.c
index b742f260c7ca..e29954c1c38c 100644
--- a/drivers/media/video/gspca/spca501.c
+++ b/drivers/media/video/gspca/spca501.c
@@ -2022,8 +2022,11 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
2022 reg_write(gspca_dev->dev, SPCA501_REG_CTLRL, 0x01, 0x00); 2022 reg_write(gspca_dev->dev, SPCA501_REG_CTLRL, 0x01, 0x00);
2023} 2023}
2024 2024
2025/* called on streamoff with alt 0 and on disconnect */
2025static void sd_stop0(struct gspca_dev *gspca_dev) 2026static void sd_stop0(struct gspca_dev *gspca_dev)
2026{ 2027{
2028 if (!gspca_dev->present)
2029 return;
2027 reg_write(gspca_dev->dev, SPCA501_REG_CTLRL, 0x05, 0x00); 2030 reg_write(gspca_dev->dev, SPCA501_REG_CTLRL, 0x05, 0x00);
2028} 2031}
2029 2032
diff --git a/drivers/media/video/gspca/spca505.c b/drivers/media/video/gspca/spca505.c
index b345749213cf..895b9fe4018c 100644
--- a/drivers/media/video/gspca/spca505.c
+++ b/drivers/media/video/gspca/spca505.c
@@ -742,8 +742,12 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
742 reg_write(gspca_dev->dev, 0x02, 0x00, 0x00); 742 reg_write(gspca_dev->dev, 0x02, 0x00, 0x00);
743} 743}
744 744
745/* called on streamoff with alt 0 and on disconnect */
745static void sd_stop0(struct gspca_dev *gspca_dev) 746static void sd_stop0(struct gspca_dev *gspca_dev)
746{ 747{
748 if (!gspca_dev->present)
749 return;
750
747 /* This maybe reset or power control */ 751 /* This maybe reset or power control */
748 reg_write(gspca_dev->dev, 0x03, 0x03, 0x20); 752 reg_write(gspca_dev->dev, 0x03, 0x03, 0x20);
749 reg_write(gspca_dev->dev, 0x03, 0x01, 0x0); 753 reg_write(gspca_dev->dev, 0x03, 0x01, 0x0);
diff --git a/drivers/media/video/gspca/spca561.c b/drivers/media/video/gspca/spca561.c
index 020a03c466c1..c3de4e44123d 100644
--- a/drivers/media/video/gspca/spca561.c
+++ b/drivers/media/video/gspca/spca561.c
@@ -766,10 +766,13 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
766 } 766 }
767} 767}
768 768
769/* called on streamoff with alt 0 and on disconnect */
769static void sd_stop0(struct gspca_dev *gspca_dev) 770static void sd_stop0(struct gspca_dev *gspca_dev)
770{ 771{
771 struct sd *sd = (struct sd *) gspca_dev; 772 struct sd *sd = (struct sd *) gspca_dev;
772 773
774 if (!gspca_dev->present)
775 return;
773 if (sd->chip_revision == Rev012A) { 776 if (sd->chip_revision == Rev012A) {
774 reg_w_val(gspca_dev->dev, 0x8118, 0x29); 777 reg_w_val(gspca_dev->dev, 0x8118, 0x29);
775 reg_w_val(gspca_dev->dev, 0x8114, 0x08); 778 reg_w_val(gspca_dev->dev, 0x8114, 0x08);
diff --git a/drivers/media/video/gspca/vc032x.c b/drivers/media/video/gspca/vc032x.c
index be46d9232540..17af353ddd1c 100644
--- a/drivers/media/video/gspca/vc032x.c
+++ b/drivers/media/video/gspca/vc032x.c
@@ -1633,10 +1633,13 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
1633 reg_w(dev, 0xa0, 0x09, 0xb003); 1633 reg_w(dev, 0xa0, 0x09, 0xb003);
1634} 1634}
1635 1635
1636/* called on streamoff with alt 0 and on disconnect */
1636static void sd_stop0(struct gspca_dev *gspca_dev) 1637static void sd_stop0(struct gspca_dev *gspca_dev)
1637{ 1638{
1638 struct usb_device *dev = gspca_dev->dev; 1639 struct usb_device *dev = gspca_dev->dev;
1639 1640
1641 if (!gspca_dev->present)
1642 return;
1640 reg_w(dev, 0x89, 0xffff, 0xffff); 1643 reg_w(dev, 0x89, 0xffff, 0xffff);
1641} 1644}
1642 1645
diff --git a/drivers/media/video/gspca/zc3xx.c b/drivers/media/video/gspca/zc3xx.c
index 8b3101d347c3..0befacf49855 100644
--- a/drivers/media/video/gspca/zc3xx.c
+++ b/drivers/media/video/gspca/zc3xx.c
@@ -7336,10 +7336,13 @@ static int sd_start(struct gspca_dev *gspca_dev)
7336 return 0; 7336 return 0;
7337} 7337}
7338 7338
7339/* called on streamoff with alt 0 and on disconnect */
7339static void sd_stop0(struct gspca_dev *gspca_dev) 7340static void sd_stop0(struct gspca_dev *gspca_dev)
7340{ 7341{
7341 struct sd *sd = (struct sd *) gspca_dev; 7342 struct sd *sd = (struct sd *) gspca_dev;
7342 7343
7344 if (!gspca_dev->present)
7345 return;
7343 send_unknown(gspca_dev->dev, sd->sensor); 7346 send_unknown(gspca_dev->dev, sd->sensor);
7344} 7347}
7345 7348