diff options
Diffstat (limited to 'drivers/media/usb/uvc/uvc_queue.c')
-rw-r--r-- | drivers/media/usb/uvc/uvc_queue.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c index f16b9b42689d..b49bcab0c38c 100644 --- a/drivers/media/usb/uvc/uvc_queue.c +++ b/drivers/media/usb/uvc/uvc_queue.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/videodev2.h> | 20 | #include <linux/videodev2.h> |
21 | #include <linux/vmalloc.h> | 21 | #include <linux/vmalloc.h> |
22 | #include <linux/wait.h> | 22 | #include <linux/wait.h> |
23 | #include <media/videobuf2-v4l2.h> | ||
23 | #include <media/videobuf2-vmalloc.h> | 24 | #include <media/videobuf2-vmalloc.h> |
24 | 25 | ||
25 | #include "uvcvideo.h" | 26 | #include "uvcvideo.h" |
@@ -60,7 +61,7 @@ static void uvc_queue_return_buffers(struct uvc_video_queue *queue, | |||
60 | queue); | 61 | queue); |
61 | list_del(&buf->queue); | 62 | list_del(&buf->queue); |
62 | buf->state = state; | 63 | buf->state = state; |
63 | vb2_buffer_done(&buf->buf, vb2_state); | 64 | vb2_buffer_done(&buf->buf.vb2_buf, vb2_state); |
64 | } | 65 | } |
65 | } | 66 | } |
66 | 67 | ||
@@ -89,10 +90,11 @@ static int uvc_queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt, | |||
89 | 90 | ||
90 | static int uvc_buffer_prepare(struct vb2_buffer *vb) | 91 | static int uvc_buffer_prepare(struct vb2_buffer *vb) |
91 | { | 92 | { |
93 | struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); | ||
92 | struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue); | 94 | struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue); |
93 | struct uvc_buffer *buf = container_of(vb, struct uvc_buffer, buf); | 95 | struct uvc_buffer *buf = container_of(vbuf, struct uvc_buffer, buf); |
94 | 96 | ||
95 | if (vb->v4l2_buf.type == V4L2_BUF_TYPE_VIDEO_OUTPUT && | 97 | if (vb->type == V4L2_BUF_TYPE_VIDEO_OUTPUT && |
96 | vb2_get_plane_payload(vb, 0) > vb2_plane_size(vb, 0)) { | 98 | vb2_get_plane_payload(vb, 0) > vb2_plane_size(vb, 0)) { |
97 | uvc_trace(UVC_TRACE_CAPTURE, "[E] Bytes used out of bounds.\n"); | 99 | uvc_trace(UVC_TRACE_CAPTURE, "[E] Bytes used out of bounds.\n"); |
98 | return -EINVAL; | 100 | return -EINVAL; |
@@ -105,7 +107,7 @@ static int uvc_buffer_prepare(struct vb2_buffer *vb) | |||
105 | buf->error = 0; | 107 | buf->error = 0; |
106 | buf->mem = vb2_plane_vaddr(vb, 0); | 108 | buf->mem = vb2_plane_vaddr(vb, 0); |
107 | buf->length = vb2_plane_size(vb, 0); | 109 | buf->length = vb2_plane_size(vb, 0); |
108 | if (vb->v4l2_buf.type == V4L2_BUF_TYPE_VIDEO_CAPTURE) | 110 | if (vb->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) |
109 | buf->bytesused = 0; | 111 | buf->bytesused = 0; |
110 | else | 112 | else |
111 | buf->bytesused = vb2_get_plane_payload(vb, 0); | 113 | buf->bytesused = vb2_get_plane_payload(vb, 0); |
@@ -115,8 +117,9 @@ static int uvc_buffer_prepare(struct vb2_buffer *vb) | |||
115 | 117 | ||
116 | static void uvc_buffer_queue(struct vb2_buffer *vb) | 118 | static void uvc_buffer_queue(struct vb2_buffer *vb) |
117 | { | 119 | { |
120 | struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); | ||
118 | struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue); | 121 | struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue); |
119 | struct uvc_buffer *buf = container_of(vb, struct uvc_buffer, buf); | 122 | struct uvc_buffer *buf = container_of(vbuf, struct uvc_buffer, buf); |
120 | unsigned long flags; | 123 | unsigned long flags; |
121 | 124 | ||
122 | spin_lock_irqsave(&queue->irqlock, flags); | 125 | spin_lock_irqsave(&queue->irqlock, flags); |
@@ -127,7 +130,7 @@ static void uvc_buffer_queue(struct vb2_buffer *vb) | |||
127 | * directly. The next QBUF call will fail with -ENODEV. | 130 | * directly. The next QBUF call will fail with -ENODEV. |
128 | */ | 131 | */ |
129 | buf->state = UVC_BUF_STATE_ERROR; | 132 | buf->state = UVC_BUF_STATE_ERROR; |
130 | vb2_buffer_done(&buf->buf, VB2_BUF_STATE_ERROR); | 133 | vb2_buffer_done(vb, VB2_BUF_STATE_ERROR); |
131 | } | 134 | } |
132 | 135 | ||
133 | spin_unlock_irqrestore(&queue->irqlock, flags); | 136 | spin_unlock_irqrestore(&queue->irqlock, flags); |
@@ -135,12 +138,13 @@ static void uvc_buffer_queue(struct vb2_buffer *vb) | |||
135 | 138 | ||
136 | static void uvc_buffer_finish(struct vb2_buffer *vb) | 139 | static void uvc_buffer_finish(struct vb2_buffer *vb) |
137 | { | 140 | { |
141 | struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); | ||
138 | struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue); | 142 | struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue); |
139 | struct uvc_streaming *stream = uvc_queue_to_stream(queue); | 143 | struct uvc_streaming *stream = uvc_queue_to_stream(queue); |
140 | struct uvc_buffer *buf = container_of(vb, struct uvc_buffer, buf); | 144 | struct uvc_buffer *buf = container_of(vbuf, struct uvc_buffer, buf); |
141 | 145 | ||
142 | if (vb->state == VB2_BUF_STATE_DONE) | 146 | if (vb->state == VB2_BUF_STATE_DONE) |
143 | uvc_video_clock_update(stream, &vb->v4l2_buf, buf); | 147 | uvc_video_clock_update(stream, vbuf, buf); |
144 | } | 148 | } |
145 | 149 | ||
146 | static int uvc_start_streaming(struct vb2_queue *vq, unsigned int count) | 150 | static int uvc_start_streaming(struct vb2_queue *vq, unsigned int count) |
@@ -398,7 +402,7 @@ struct uvc_buffer *uvc_queue_next_buffer(struct uvc_video_queue *queue, | |||
398 | buf->error = 0; | 402 | buf->error = 0; |
399 | buf->state = UVC_BUF_STATE_QUEUED; | 403 | buf->state = UVC_BUF_STATE_QUEUED; |
400 | buf->bytesused = 0; | 404 | buf->bytesused = 0; |
401 | vb2_set_plane_payload(&buf->buf, 0, 0); | 405 | vb2_set_plane_payload(&buf->buf.vb2_buf, 0, 0); |
402 | return buf; | 406 | return buf; |
403 | } | 407 | } |
404 | 408 | ||
@@ -412,8 +416,8 @@ struct uvc_buffer *uvc_queue_next_buffer(struct uvc_video_queue *queue, | |||
412 | spin_unlock_irqrestore(&queue->irqlock, flags); | 416 | spin_unlock_irqrestore(&queue->irqlock, flags); |
413 | 417 | ||
414 | buf->state = buf->error ? VB2_BUF_STATE_ERROR : UVC_BUF_STATE_DONE; | 418 | buf->state = buf->error ? VB2_BUF_STATE_ERROR : UVC_BUF_STATE_DONE; |
415 | vb2_set_plane_payload(&buf->buf, 0, buf->bytesused); | 419 | vb2_set_plane_payload(&buf->buf.vb2_buf, 0, buf->bytesused); |
416 | vb2_buffer_done(&buf->buf, VB2_BUF_STATE_DONE); | 420 | vb2_buffer_done(&buf->buf.vb2_buf, VB2_BUF_STATE_DONE); |
417 | 421 | ||
418 | return nextbuf; | 422 | return nextbuf; |
419 | } | 423 | } |