Commit a5e3d743 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

[media] vb2: regression fix: always set length field.

Commit dc77523c ensured that m.offset is
only set for the MMAP memory mode by calling __setup_offsets only for that
mode.

However, __setup_offsets also initializes the length fields, and that should
be done regardless of the memory mode. Because of that change the v4l2-ctl
test application fails for the USERPTR mode.

This fix creates a __setup_lengths function that sets the length, and
__setup_offsets just sets the offset and no longer touches the length.
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Acked-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
parent 3d8b24d2
...@@ -144,6 +144,25 @@ static void __vb2_buf_dmabuf_put(struct vb2_buffer *vb) ...@@ -144,6 +144,25 @@ static void __vb2_buf_dmabuf_put(struct vb2_buffer *vb)
__vb2_plane_dmabuf_put(q, &vb->planes[plane]); __vb2_plane_dmabuf_put(q, &vb->planes[plane]);
} }
/**
* __setup_lengths() - setup initial lengths for every plane in
* every buffer on the queue
*/
static void __setup_lengths(struct vb2_queue *q, unsigned int n)
{
unsigned int buffer, plane;
struct vb2_buffer *vb;
for (buffer = q->num_buffers; buffer < q->num_buffers + n; ++buffer) {
vb = q->bufs[buffer];
if (!vb)
continue;
for (plane = 0; plane < vb->num_planes; ++plane)
vb->v4l2_planes[plane].length = q->plane_sizes[plane];
}
}
/** /**
* __setup_offsets() - setup unique offsets ("cookies") for every plane in * __setup_offsets() - setup unique offsets ("cookies") for every plane in
* every buffer on the queue * every buffer on the queue
...@@ -169,7 +188,6 @@ static void __setup_offsets(struct vb2_queue *q, unsigned int n) ...@@ -169,7 +188,6 @@ static void __setup_offsets(struct vb2_queue *q, unsigned int n)
continue; continue;
for (plane = 0; plane < vb->num_planes; ++plane) { for (plane = 0; plane < vb->num_planes; ++plane) {
vb->v4l2_planes[plane].length = q->plane_sizes[plane];
vb->v4l2_planes[plane].m.mem_offset = off; vb->v4l2_planes[plane].m.mem_offset = off;
dprintk(3, "Buffer %d, plane %d offset 0x%08lx\n", dprintk(3, "Buffer %d, plane %d offset 0x%08lx\n",
...@@ -241,6 +259,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum v4l2_memory memory, ...@@ -241,6 +259,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum v4l2_memory memory,
q->bufs[q->num_buffers + buffer] = vb; q->bufs[q->num_buffers + buffer] = vb;
} }
__setup_lengths(q, buffer);
if (memory == V4L2_MEMORY_MMAP) if (memory == V4L2_MEMORY_MMAP)
__setup_offsets(q, buffer); __setup_offsets(q, buffer);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment