[media] uvcvideo: Enable VIDIOC_CREATE_BUFS
authorPhilipp Zabel <p.zabel@pengutronix.de>
Wed, 29 Jan 2014 16:13:52 +0000 (13:13 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Fri, 28 Feb 2014 16:24:32 +0000 (13:24 -0300)
This patch enables the ioctl to create additional buffers on the
videobuf2 capture queue.

[laurent.pinchart@ideasonboard.com: Acquire privileges instead of just
checking them in VIDIOC_CREATE_BUFS implementation]

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
drivers/media/usb/uvc/uvc_queue.c
drivers/media/usb/uvc/uvc_v4l2.c
drivers/media/usb/uvc/uvcvideo.h

index d46dd7011ed32fe68cd3fe373bacccfc3f0d9702..ff7be97024865cb14d2fc15341e37a0030166c07 100644 (file)
@@ -198,6 +198,18 @@ int uvc_query_buffer(struct uvc_video_queue *queue, struct v4l2_buffer *buf)
        return ret;
 }
 
+int uvc_create_buffers(struct uvc_video_queue *queue,
+                      struct v4l2_create_buffers *cb)
+{
+       int ret;
+
+       mutex_lock(&queue->mutex);
+       ret = vb2_create_bufs(&queue->queue, cb);
+       mutex_unlock(&queue->mutex);
+
+       return ret;
+}
+
 int uvc_queue_buffer(struct uvc_video_queue *queue, struct v4l2_buffer *buf)
 {
        int ret;
index 3afff92804d3c003b986237e385bf4d7c04596ef..378ae02e593b93a19bb9010a23f62175029bbefd 100644 (file)
@@ -1000,6 +1000,17 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
                return uvc_query_buffer(&stream->queue, buf);
        }
 
+       case VIDIOC_CREATE_BUFS:
+       {
+               struct v4l2_create_buffers *cb = arg;
+
+               ret = uvc_acquire_privileges(handle);
+               if (ret < 0)
+                       return ret;
+
+               return uvc_create_buffers(&stream->queue, cb);
+       }
+
        case VIDIOC_QBUF:
                if (!uvc_has_privileges(handle))
                        return -EBUSY;
index 61736324488bb2929abaf9bb88c9e10f3d2af429..143d5e51cb9633f432233fa37847d3c89b6b0cbf 100644 (file)
@@ -614,6 +614,8 @@ extern int uvc_alloc_buffers(struct uvc_video_queue *queue,
 extern void uvc_free_buffers(struct uvc_video_queue *queue);
 extern int uvc_query_buffer(struct uvc_video_queue *queue,
                struct v4l2_buffer *v4l2_buf);
+extern int uvc_create_buffers(struct uvc_video_queue *queue,
+               struct v4l2_create_buffers *v4l2_cb);
 extern int uvc_queue_buffer(struct uvc_video_queue *queue,
                struct v4l2_buffer *v4l2_buf);
 extern int uvc_dequeue_buffer(struct uvc_video_queue *queue,