summaryrefslogtreecommitdiff
path: root/drivers/media/v4l2-core/videobuf2-core.c
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2015-11-20 14:25:52 +0300
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-12-18 19:03:00 +0300
commit489648afcd309bb84567b59e140d9cdeddecb356 (patch)
tree651130166f7677aafeeb4031c9bbf06196014868 /drivers/media/v4l2-core/videobuf2-core.c
parent10cc3b1e12964ae71aefefb2c2b61304d2264cac (diff)
downloadlinux-489648afcd309bb84567b59e140d9cdeddecb356.tar.xz
[media] videobuf2-core: move __setup_lengths into __vb2_queue_alloc()
Rather than setting up the lengths at the end, set them up when the vb2_buffer is allocated. This also ensures that buf_init() sees the right length values. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/v4l2-core/videobuf2-core.c')
-rw-r--r--drivers/media/v4l2-core/videobuf2-core.c24
1 files changed, 3 insertions, 21 deletions
diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index 5cd418e57ea5..96dca473bc83 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -287,25 +287,6 @@ static void __vb2_buf_dmabuf_put(struct vb2_buffer *vb)
}
/**
- * __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->planes[plane].length = q->plane_sizes[plane];
- }
-}
-
-/**
* __setup_offsets() - setup unique offsets ("cookies") for every plane in
* every buffer on the queue
*/
@@ -351,7 +332,7 @@ static void __setup_offsets(struct vb2_queue *q, unsigned int n)
static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory,
unsigned int num_buffers, unsigned int num_planes)
{
- unsigned int buffer;
+ unsigned int buffer, plane;
struct vb2_buffer *vb;
int ret;
@@ -369,6 +350,8 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory,
vb->index = q->num_buffers + buffer;
vb->type = q->type;
vb->memory = memory;
+ for (plane = 0; plane < num_planes; ++plane)
+ vb->planes[plane].length = q->plane_sizes[plane];
/* Allocate video buffer memory for the MMAP type */
if (memory == VB2_MEMORY_MMAP) {
@@ -397,7 +380,6 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory,
q->bufs[q->num_buffers + buffer] = vb;
}
- __setup_lengths(q, buffer);
if (memory == VB2_MEMORY_MMAP)
__setup_offsets(q, buffer);