]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
[media] v4l2: vb2: fix queue reallocation and REQBUFS(0) case
authorMarek Szyprowski <m.szyprowski@samsung.com>
Wed, 9 Mar 2011 17:03:24 +0000 (14:03 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 22 Mar 2011 07:54:23 +0000 (04:54 -0300)
This patch fixes 2 minor bugs in videobuf2 core:
1. Queue should be reallocated if one change the memory access
method without changing the number of buffers.
2. In case of REQBUFS(0), the request should not be passed to the
driver.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/videobuf2-core.c

index cc7ab0a17b68fb4b6bc8a1567b7862614558ebcf..c5f99c7d397965f279427150035ffd931784593a 100644 (file)
@@ -488,7 +488,7 @@ int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req)
                return -EINVAL;
        }
 
-       if (req->count == 0 || q->num_buffers != 0) {
+       if (req->count == 0 || q->num_buffers != 0 || q->memory != req->memory) {
                /*
                 * We already have buffers allocated, so first check if they
                 * are not in use and can be freed.
@@ -501,6 +501,13 @@ int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req)
                ret = __vb2_queue_free(q);
                if (ret != 0)
                        return ret;
+
+               /*
+                * In case of REQBUFS(0) return immediately without calling
+                * driver's queue_setup() callback and allocating resources.
+                */
+               if (req->count == 0)
+                       return 0;
        }
 
        /*