aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/videobuf2-core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/videobuf2-core.c')
-rw-r--r--drivers/media/video/videobuf2-core.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/drivers/media/video/videobuf2-core.c b/drivers/media/video/videobuf2-core.c
index 6698c77e0f64..6ba1461d51ef 100644
--- a/drivers/media/video/videobuf2-core.c
+++ b/drivers/media/video/videobuf2-core.c
@@ -37,6 +37,9 @@ module_param(debug, int, 0644);
37#define call_qop(q, op, args...) \ 37#define call_qop(q, op, args...) \
38 (((q)->ops->op) ? ((q)->ops->op(args)) : 0) 38 (((q)->ops->op) ? ((q)->ops->op(args)) : 0)
39 39
40#define V4L2_BUFFER_STATE_FLAGS (V4L2_BUF_FLAG_MAPPED | V4L2_BUF_FLAG_QUEUED | \
41 V4L2_BUF_FLAG_DONE | V4L2_BUF_FLAG_ERROR)
42
40/** 43/**
41 * __vb2_buf_mem_alloc() - allocate video memory for the given buffer 44 * __vb2_buf_mem_alloc() - allocate video memory for the given buffer
42 */ 45 */
@@ -51,7 +54,7 @@ static int __vb2_buf_mem_alloc(struct vb2_buffer *vb,
51 for (plane = 0; plane < vb->num_planes; ++plane) { 54 for (plane = 0; plane < vb->num_planes; ++plane) {
52 mem_priv = call_memop(q, plane, alloc, q->alloc_ctx[plane], 55 mem_priv = call_memop(q, plane, alloc, q->alloc_ctx[plane],
53 plane_sizes[plane]); 56 plane_sizes[plane]);
54 if (!mem_priv) 57 if (IS_ERR_OR_NULL(mem_priv))
55 goto free; 58 goto free;
56 59
57 /* Associate allocator private data with this plane */ 60 /* Associate allocator private data with this plane */
@@ -284,7 +287,7 @@ static int __fill_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b)
284 struct vb2_queue *q = vb->vb2_queue; 287 struct vb2_queue *q = vb->vb2_queue;
285 int ret = 0; 288 int ret = 0;
286 289
287 /* Copy back data such as timestamp, input, etc. */ 290 /* Copy back data such as timestamp, flags, input, etc. */
288 memcpy(b, &vb->v4l2_buf, offsetof(struct v4l2_buffer, m)); 291 memcpy(b, &vb->v4l2_buf, offsetof(struct v4l2_buffer, m));
289 b->input = vb->v4l2_buf.input; 292 b->input = vb->v4l2_buf.input;
290 b->reserved = vb->v4l2_buf.reserved; 293 b->reserved = vb->v4l2_buf.reserved;
@@ -313,7 +316,10 @@ static int __fill_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b)
313 b->m.userptr = vb->v4l2_planes[0].m.userptr; 316 b->m.userptr = vb->v4l2_planes[0].m.userptr;
314 } 317 }
315 318
316 b->flags = 0; 319 /*
320 * Clear any buffer state related flags.
321 */
322 b->flags &= ~V4L2_BUFFER_STATE_FLAGS;
317 323
318 switch (vb->state) { 324 switch (vb->state) {
319 case VB2_BUF_STATE_QUEUED: 325 case VB2_BUF_STATE_QUEUED:
@@ -519,6 +525,7 @@ int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req)
519 num_buffers = min_t(unsigned int, req->count, VIDEO_MAX_FRAME); 525 num_buffers = min_t(unsigned int, req->count, VIDEO_MAX_FRAME);
520 memset(plane_sizes, 0, sizeof(plane_sizes)); 526 memset(plane_sizes, 0, sizeof(plane_sizes));
521 memset(q->alloc_ctx, 0, sizeof(q->alloc_ctx)); 527 memset(q->alloc_ctx, 0, sizeof(q->alloc_ctx));
528 q->memory = req->memory;
522 529
523 /* 530 /*
524 * Ask the driver how many buffers and planes per buffer it requires. 531 * Ask the driver how many buffers and planes per buffer it requires.
@@ -560,8 +567,6 @@ int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req)
560 ret = num_buffers; 567 ret = num_buffers;
561 } 568 }
562 569
563 q->memory = req->memory;
564
565 /* 570 /*
566 * Return the number of successfully allocated buffers 571 * Return the number of successfully allocated buffers
567 * to the userspace. 572 * to the userspace.
@@ -715,6 +720,8 @@ static int __fill_vb2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b,
715 720
716 vb->v4l2_buf.field = b->field; 721 vb->v4l2_buf.field = b->field;
717 vb->v4l2_buf.timestamp = b->timestamp; 722 vb->v4l2_buf.timestamp = b->timestamp;
723 vb->v4l2_buf.input = b->input;
724 vb->v4l2_buf.flags = b->flags & ~V4L2_BUFFER_STATE_FLAGS;
718 725
719 return 0; 726 return 0;
720} 727}