Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] media: vb2: fix incorrect v4l2_buffer->flags handling

Videobuf2 core assumes that driver doesn't set any buffer flags.
This is correct for buffer state flags that videobuf2 manages,
but the other flags like V4L2_BUF_FLAG_{KEY,P,B}FRAME,
V4L2_BUF_FLAG_TIMECODE and V4L2_BUF_FLAG_INPUT should be passed from or to
the driver.

Reported-by: Jonghun Han <jonghun.han@samsung.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
CC: Pawel Osciak <pawel@osciak.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Marek Szyprowski and committed by
Mauro Carvalho Chehab
ea42c8ec 89582654

+10 -2
+10 -2
drivers/media/video/videobuf2-core.c
··· 37 37 #define call_qop(q, op, args...) \ 38 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 44 * __vb2_buf_mem_alloc() - allocate video memory for the given buffer 42 45 */ ··· 287 284 struct vb2_queue *q = vb->vb2_queue; 288 285 int ret = 0; 289 286 290 - /* Copy back data such as timestamp, input, etc. */ 287 + /* Copy back data such as timestamp, flags, input, etc. */ 291 288 memcpy(b, &vb->v4l2_buf, offsetof(struct v4l2_buffer, m)); 292 289 b->input = vb->v4l2_buf.input; 293 290 b->reserved = vb->v4l2_buf.reserved; ··· 316 313 b->m.userptr = vb->v4l2_planes[0].m.userptr; 317 314 } 318 315 319 - b->flags = 0; 316 + /* 317 + * Clear any buffer state related flags. 318 + */ 319 + b->flags &= ~V4L2_BUFFER_STATE_FLAGS; 320 320 321 321 switch (vb->state) { 322 322 case VB2_BUF_STATE_QUEUED: ··· 721 715 722 716 vb->v4l2_buf.field = b->field; 723 717 vb->v4l2_buf.timestamp = b->timestamp; 718 + vb->v4l2_buf.input = b->input; 719 + vb->v4l2_buf.flags = b->flags & ~V4L2_BUFFER_STATE_FLAGS; 724 720 725 721 return 0; 726 722 }