Commit 27a36df6 authored by Frank Schaefer's avatar Frank Schaefer Committed by Mauro Carvalho Chehab

[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: default avatarFrank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent ef74a0b9
...@@ -3016,8 +3016,6 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev, ...@@ -3016,8 +3016,6 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev,
const char *chip_name = default_chip_name; const char *chip_name = default_chip_name;
dev->udev = udev; dev->udev = udev;
mutex_init(&dev->vb_queue_lock);
mutex_init(&dev->vb_vbi_queue_lock);
mutex_init(&dev->ctrl_urb_lock); mutex_init(&dev->ctrl_urb_lock);
spin_lock_init(&dev->slock); spin_lock_init(&dev->slock);
......
...@@ -1045,9 +1045,10 @@ static int em28xx_vb2_setup(struct em28xx *dev) ...@@ -1045,9 +1045,10 @@ static int em28xx_vb2_setup(struct em28xx *dev)
{ {
int rc; int rc;
struct vb2_queue *q; struct vb2_queue *q;
struct em28xx_v4l2 *v4l2 = dev->v4l2;
/* Setup Videobuf2 for Video capture */ /* Setup Videobuf2 for Video capture */
q = &dev->vb_vidq; q = &v4l2->vb_vidq;
q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
q->io_modes = VB2_READ | VB2_MMAP | VB2_USERPTR | VB2_DMABUF; q->io_modes = VB2_READ | VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
...@@ -1061,7 +1062,7 @@ static int em28xx_vb2_setup(struct em28xx *dev) ...@@ -1061,7 +1062,7 @@ static int em28xx_vb2_setup(struct em28xx *dev)
return rc; return rc;
/* Setup Videobuf2 for VBI capture */ /* Setup Videobuf2 for VBI capture */
q = &dev->vb_vbiq; q = &v4l2->vb_vbiq;
q->type = V4L2_BUF_TYPE_VBI_CAPTURE; q->type = V4L2_BUF_TYPE_VBI_CAPTURE;
q->io_modes = VB2_READ | VB2_MMAP | VB2_USERPTR; q->io_modes = VB2_READ | VB2_MMAP | VB2_USERPTR;
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
...@@ -2479,8 +2480,10 @@ static int em28xx_v4l2_init(struct em28xx *dev) ...@@ -2479,8 +2480,10 @@ static int em28xx_v4l2_init(struct em28xx *dev)
ret = -ENODEV; ret = -ENODEV;
goto unregister_dev; goto unregister_dev;
} }
v4l2->vdev->queue = &dev->vb_vidq; mutex_init(&v4l2->vb_queue_lock);
v4l2->vdev->queue->lock = &dev->vb_queue_lock; mutex_init(&v4l2->vb_vbi_queue_lock);
v4l2->vdev->queue = &v4l2->vb_vidq;
v4l2->vdev->queue->lock = &v4l2->vb_queue_lock;
/* disable inapplicable ioctls */ /* disable inapplicable ioctls */
if (dev->board.is_webcam) { if (dev->board.is_webcam) {
...@@ -2515,8 +2518,8 @@ static int em28xx_v4l2_init(struct em28xx *dev) ...@@ -2515,8 +2518,8 @@ static int em28xx_v4l2_init(struct em28xx *dev)
v4l2->vbi_dev = em28xx_vdev_init(dev, &em28xx_video_template, v4l2->vbi_dev = em28xx_vdev_init(dev, &em28xx_video_template,
"vbi"); "vbi");
v4l2->vbi_dev->queue = &dev->vb_vbiq; v4l2->vbi_dev->queue = &v4l2->vb_vbiq;
v4l2->vbi_dev->queue->lock = &dev->vb_vbi_queue_lock; v4l2->vbi_dev->queue->lock = &v4l2->vb_vbi_queue_lock;
/* disable inapplicable ioctls */ /* disable inapplicable ioctls */
v4l2_disable_ioctl(v4l2->vdev, VIDIOC_S_PARM); v4l2_disable_ioctl(v4l2->vdev, VIDIOC_S_PARM);
......
...@@ -509,6 +509,12 @@ struct em28xx_v4l2 { ...@@ -509,6 +509,12 @@ struct em28xx_v4l2 {
struct video_device *vdev; struct video_device *vdev;
struct video_device *vbi_dev; struct video_device *vbi_dev;
struct video_device *radio_dev; struct video_device *radio_dev;
/* Videobuf2 */
struct vb2_queue vb_vidq;
struct vb2_queue vb_vbiq;
struct mutex vb_queue_lock;
struct mutex vb_vbi_queue_lock;
}; };
struct em28xx_audio { struct em28xx_audio {
...@@ -650,12 +656,6 @@ struct em28xx { ...@@ -650,12 +656,6 @@ struct em28xx {
struct mutex lock; struct mutex lock;
struct mutex ctrl_urb_lock; /* protects urb_buf */ struct mutex ctrl_urb_lock; /* protects urb_buf */
/* Videobuf2 */
struct vb2_queue vb_vidq;
struct vb2_queue vb_vbiq;
struct mutex vb_queue_lock;
struct mutex vb_vbi_queue_lock;
/* resources in use */ /* resources in use */
unsigned int resources; unsigned int resources;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment