diff options
Diffstat (limited to 'drivers/usb/gadget/function/uvc_queue.c')
-rw-r--r-- | drivers/usb/gadget/function/uvc_queue.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/drivers/usb/gadget/function/uvc_queue.c b/drivers/usb/gadget/function/uvc_queue.c index d617c39a0052..3628938785ac 100644 --- a/drivers/usb/gadget/function/uvc_queue.c +++ b/drivers/usb/gadget/function/uvc_queue.c | |||
@@ -61,9 +61,10 @@ static int uvc_queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt, | |||
61 | static int uvc_buffer_prepare(struct vb2_buffer *vb) | 61 | static int uvc_buffer_prepare(struct vb2_buffer *vb) |
62 | { | 62 | { |
63 | struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue); | 63 | struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue); |
64 | struct uvc_buffer *buf = container_of(vb, struct uvc_buffer, buf); | 64 | struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); |
65 | struct uvc_buffer *buf = container_of(vbuf, struct uvc_buffer, buf); | ||
65 | 66 | ||
66 | if (vb->v4l2_buf.type == V4L2_BUF_TYPE_VIDEO_OUTPUT && | 67 | if (vb->type == V4L2_BUF_TYPE_VIDEO_OUTPUT && |
67 | vb2_get_plane_payload(vb, 0) > vb2_plane_size(vb, 0)) { | 68 | vb2_get_plane_payload(vb, 0) > vb2_plane_size(vb, 0)) { |
68 | uvc_trace(UVC_TRACE_CAPTURE, "[E] Bytes used out of bounds.\n"); | 69 | uvc_trace(UVC_TRACE_CAPTURE, "[E] Bytes used out of bounds.\n"); |
69 | return -EINVAL; | 70 | return -EINVAL; |
@@ -75,7 +76,7 @@ static int uvc_buffer_prepare(struct vb2_buffer *vb) | |||
75 | buf->state = UVC_BUF_STATE_QUEUED; | 76 | buf->state = UVC_BUF_STATE_QUEUED; |
76 | buf->mem = vb2_plane_vaddr(vb, 0); | 77 | buf->mem = vb2_plane_vaddr(vb, 0); |
77 | buf->length = vb2_plane_size(vb, 0); | 78 | buf->length = vb2_plane_size(vb, 0); |
78 | if (vb->v4l2_buf.type == V4L2_BUF_TYPE_VIDEO_CAPTURE) | 79 | if (vb->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) |
79 | buf->bytesused = 0; | 80 | buf->bytesused = 0; |
80 | else | 81 | else |
81 | buf->bytesused = vb2_get_plane_payload(vb, 0); | 82 | buf->bytesused = vb2_get_plane_payload(vb, 0); |
@@ -86,7 +87,8 @@ static int uvc_buffer_prepare(struct vb2_buffer *vb) | |||
86 | static void uvc_buffer_queue(struct vb2_buffer *vb) | 87 | static void uvc_buffer_queue(struct vb2_buffer *vb) |
87 | { | 88 | { |
88 | struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue); | 89 | struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue); |
89 | struct uvc_buffer *buf = container_of(vb, struct uvc_buffer, buf); | 90 | struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); |
91 | struct uvc_buffer *buf = container_of(vbuf, struct uvc_buffer, buf); | ||
90 | unsigned long flags; | 92 | unsigned long flags; |
91 | 93 | ||
92 | spin_lock_irqsave(&queue->irqlock, flags); | 94 | spin_lock_irqsave(&queue->irqlock, flags); |
@@ -98,7 +100,7 @@ static void uvc_buffer_queue(struct vb2_buffer *vb) | |||
98 | * directly. The next QBUF call will fail with -ENODEV. | 100 | * directly. The next QBUF call will fail with -ENODEV. |
99 | */ | 101 | */ |
100 | buf->state = UVC_BUF_STATE_ERROR; | 102 | buf->state = UVC_BUF_STATE_ERROR; |
101 | vb2_buffer_done(&buf->buf, VB2_BUF_STATE_ERROR); | 103 | vb2_buffer_done(vb, VB2_BUF_STATE_ERROR); |
102 | } | 104 | } |
103 | 105 | ||
104 | spin_unlock_irqrestore(&queue->irqlock, flags); | 106 | spin_unlock_irqrestore(&queue->irqlock, flags); |
@@ -242,7 +244,7 @@ void uvcg_queue_cancel(struct uvc_video_queue *queue, int disconnect) | |||
242 | queue); | 244 | queue); |
243 | list_del(&buf->queue); | 245 | list_del(&buf->queue); |
244 | buf->state = UVC_BUF_STATE_ERROR; | 246 | buf->state = UVC_BUF_STATE_ERROR; |
245 | vb2_buffer_done(&buf->buf, VB2_BUF_STATE_ERROR); | 247 | vb2_buffer_done(&buf->buf.vb2_buf, VB2_BUF_STATE_ERROR); |
246 | } | 248 | } |
247 | /* This must be protected by the irqlock spinlock to avoid race | 249 | /* This must be protected by the irqlock spinlock to avoid race |
248 | * conditions between uvc_queue_buffer and the disconnection event that | 250 | * conditions between uvc_queue_buffer and the disconnection event that |
@@ -314,7 +316,7 @@ struct uvc_buffer *uvcg_queue_next_buffer(struct uvc_video_queue *queue, | |||
314 | if ((queue->flags & UVC_QUEUE_DROP_INCOMPLETE) && | 316 | if ((queue->flags & UVC_QUEUE_DROP_INCOMPLETE) && |
315 | buf->length != buf->bytesused) { | 317 | buf->length != buf->bytesused) { |
316 | buf->state = UVC_BUF_STATE_QUEUED; | 318 | buf->state = UVC_BUF_STATE_QUEUED; |
317 | vb2_set_plane_payload(&buf->buf, 0, 0); | 319 | vb2_set_plane_payload(&buf->buf.vb2_buf, 0, 0); |
318 | return buf; | 320 | return buf; |
319 | } | 321 | } |
320 | 322 | ||
@@ -325,12 +327,12 @@ struct uvc_buffer *uvcg_queue_next_buffer(struct uvc_video_queue *queue, | |||
325 | else | 327 | else |
326 | nextbuf = NULL; | 328 | nextbuf = NULL; |
327 | 329 | ||
328 | buf->buf.v4l2_buf.field = V4L2_FIELD_NONE; | 330 | buf->buf.field = V4L2_FIELD_NONE; |
329 | buf->buf.v4l2_buf.sequence = queue->sequence++; | 331 | buf->buf.sequence = queue->sequence++; |
330 | v4l2_get_timestamp(&buf->buf.v4l2_buf.timestamp); | 332 | v4l2_get_timestamp(&buf->buf.timestamp); |
331 | 333 | ||
332 | vb2_set_plane_payload(&buf->buf, 0, buf->bytesused); | 334 | vb2_set_plane_payload(&buf->buf.vb2_buf, 0, buf->bytesused); |
333 | vb2_buffer_done(&buf->buf, VB2_BUF_STATE_DONE); | 335 | vb2_buffer_done(&buf->buf.vb2_buf, VB2_BUF_STATE_DONE); |
334 | 336 | ||
335 | return nextbuf; | 337 | return nextbuf; |
336 | } | 338 | } |