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

[media] vb2-core: add support for count == 0 in create_bufs

This also fixes incorrect error handling in create_bufs: the return code
of __vb2_queue_alloc is the number of allocated buffers, and not a
traditional error code.
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 37d9ed94
...@@ -669,9 +669,9 @@ static int __create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create ...@@ -669,9 +669,9 @@ static int __create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create
/* Finally, allocate buffers and video memory */ /* Finally, allocate buffers and video memory */
ret = __vb2_queue_alloc(q, create->memory, num_buffers, ret = __vb2_queue_alloc(q, create->memory, num_buffers,
num_planes); num_planes);
if (ret < 0) { if (ret == 0) {
dprintk(1, "Memory allocation failed with error: %d\n", ret); dprintk(1, "Memory allocation failed\n");
return ret; return -ENOMEM;
} }
allocated_buffers = ret; allocated_buffers = ret;
...@@ -702,7 +702,7 @@ static int __create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create ...@@ -702,7 +702,7 @@ static int __create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create
if (ret < 0) { if (ret < 0) {
__vb2_queue_free(q, allocated_buffers); __vb2_queue_free(q, allocated_buffers);
return ret; return -ENOMEM;
} }
/* /*
...@@ -726,6 +726,8 @@ int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create) ...@@ -726,6 +726,8 @@ int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create)
int ret = __verify_memory_type(q, create->memory, create->format.type); int ret = __verify_memory_type(q, create->memory, create->format.type);
create->index = q->num_buffers; create->index = q->num_buffers;
if (create->count == 0)
return ret != -EBUSY ? ret : 0;
return ret ? ret : __create_bufs(q, create); return ret ? ret : __create_bufs(q, create);
} }
EXPORT_SYMBOL_GPL(vb2_create_bufs); EXPORT_SYMBOL_GPL(vb2_create_bufs);
......
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