aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/usb
diff options
context:
space:
mode:
authorFrank Schaefer <fschaefer.oss@googlemail.com>2014-03-24 15:33:13 -0400
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-05-23 12:13:35 -0400
commit27a36df63b5befa3b142d4aef54f3a240c8bd977 (patch)
treebb56f5388018cab5bc2cc33d6b7a21100043c024 /drivers/media/usb
parentef74a0b9ff56caa0e10be620d3b59f2176984430 (diff)
[media] em28xx: move videobuf2 related data from struct em28xx to struct v4l2
The video and VBI-specific VB2 queue and mutexes are used only by the v4l2 sub-driver. Move them to the V4L2 struct, preventing wasting memory if this sub-driver is not used. Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media/usb')
-rw-r--r--drivers/media/usb/em28xx/em28xx-cards.c2
-rw-r--r--drivers/media/usb/em28xx/em28xx-video.c15
-rw-r--r--drivers/media/usb/em28xx/em28xx.h12
3 files changed, 15 insertions, 14 deletions
diff --git a/drivers/media/usb/em28xx/em28xx-cards.c b/drivers/media/usb/em28xx/em28xx-cards.c
index 406fa3407728..7e402f46ea13 100644
--- a/drivers/media/usb/em28xx/em28xx-cards.c
+++ b/drivers/media/usb/em28xx/em28xx-cards.c
@@ -3016,8 +3016,6 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev,
3016 const char *chip_name = default_chip_name; 3016 const char *chip_name = default_chip_name;
3017 3017
3018 dev->udev = udev; 3018 dev->udev = udev;
3019 mutex_init(&dev->vb_queue_lock);
3020 mutex_init(&dev->vb_vbi_queue_lock);
3021 mutex_init(&dev->ctrl_urb_lock); 3019 mutex_init(&dev->ctrl_urb_lock);
3022 spin_lock_init(&dev->slock); 3020 spin_lock_init(&dev->slock);
3023 3021
diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c
index 0e8f73dfe323..1e2ea6032f5f 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -1045,9 +1045,10 @@ static int em28xx_vb2_setup(struct em28xx *dev)
1045{ 1045{
1046 int rc; 1046 int rc;
1047 struct vb2_queue *q; 1047 struct vb2_queue *q;
1048 struct em28xx_v4l2 *v4l2 = dev->v4l2;
1048 1049
1049 /* Setup Videobuf2 for Video capture */ 1050 /* Setup Videobuf2 for Video capture */
1050 q = &dev->vb_vidq; 1051 q = &v4l2->vb_vidq;
1051 q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 1052 q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1052 q->io_modes = VB2_READ | VB2_MMAP | VB2_USERPTR | VB2_DMABUF; 1053 q->io_modes = VB2_READ | VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
1053 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 1054 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
@@ -1061,7 +1062,7 @@ static int em28xx_vb2_setup(struct em28xx *dev)
1061 return rc; 1062 return rc;
1062 1063
1063 /* Setup Videobuf2 for VBI capture */ 1064 /* Setup Videobuf2 for VBI capture */
1064 q = &dev->vb_vbiq; 1065 q = &v4l2->vb_vbiq;
1065 q->type = V4L2_BUF_TYPE_VBI_CAPTURE; 1066 q->type = V4L2_BUF_TYPE_VBI_CAPTURE;
1066 q->io_modes = VB2_READ | VB2_MMAP | VB2_USERPTR; 1067 q->io_modes = VB2_READ | VB2_MMAP | VB2_USERPTR;
1067 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 1068 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
@@ -2479,8 +2480,10 @@ static int em28xx_v4l2_init(struct em28xx *dev)
2479 ret = -ENODEV; 2480 ret = -ENODEV;
2480 goto unregister_dev; 2481 goto unregister_dev;
2481 } 2482 }
2482 v4l2->vdev->queue = &dev->vb_vidq; 2483 mutex_init(&v4l2->vb_queue_lock);
2483 v4l2->vdev->queue->lock = &dev->vb_queue_lock; 2484 mutex_init(&v4l2->vb_vbi_queue_lock);
2485 v4l2->vdev->queue = &v4l2->vb_vidq;
2486 v4l2->vdev->queue->lock = &v4l2->vb_queue_lock;
2484 2487
2485 /* disable inapplicable ioctls */ 2488 /* disable inapplicable ioctls */
2486 if (dev->board.is_webcam) { 2489 if (dev->board.is_webcam) {
@@ -2515,8 +2518,8 @@ static int em28xx_v4l2_init(struct em28xx *dev)
2515 v4l2->vbi_dev = em28xx_vdev_init(dev, &em28xx_video_template, 2518 v4l2->vbi_dev = em28xx_vdev_init(dev, &em28xx_video_template,
2516 "vbi"); 2519 "vbi");
2517 2520
2518 v4l2->vbi_dev->queue = &dev->vb_vbiq; 2521 v4l2->vbi_dev->queue = &v4l2->vb_vbiq;
2519 v4l2->vbi_dev->queue->lock = &dev->vb_vbi_queue_lock; 2522 v4l2->vbi_dev->queue->lock = &v4l2->vb_vbi_queue_lock;
2520 2523
2521 /* disable inapplicable ioctls */ 2524 /* disable inapplicable ioctls */
2522 v4l2_disable_ioctl(v4l2->vdev, VIDIOC_S_PARM); 2525 v4l2_disable_ioctl(v4l2->vdev, VIDIOC_S_PARM);
diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h
index fc3f8b8e70bf..71d88570395a 100644
--- a/drivers/media/usb/em28xx/em28xx.h
+++ b/drivers/media/usb/em28xx/em28xx.h
@@ -509,6 +509,12 @@ struct em28xx_v4l2 {
509 struct video_device *vdev; 509 struct video_device *vdev;
510 struct video_device *vbi_dev; 510 struct video_device *vbi_dev;
511 struct video_device *radio_dev; 511 struct video_device *radio_dev;
512
513 /* Videobuf2 */
514 struct vb2_queue vb_vidq;
515 struct vb2_queue vb_vbiq;
516 struct mutex vb_queue_lock;
517 struct mutex vb_vbi_queue_lock;
512}; 518};
513 519
514struct em28xx_audio { 520struct em28xx_audio {
@@ -650,12 +656,6 @@ struct em28xx {
650 struct mutex lock; 656 struct mutex lock;
651 struct mutex ctrl_urb_lock; /* protects urb_buf */ 657 struct mutex ctrl_urb_lock; /* protects urb_buf */
652 658
653 /* Videobuf2 */
654 struct vb2_queue vb_vidq;
655 struct vb2_queue vb_vbiq;
656 struct mutex vb_queue_lock;
657 struct mutex vb_vbi_queue_lock;
658
659 /* resources in use */ 659 /* resources in use */
660 unsigned int resources; 660 unsigned int resources;
661 661