diff mbox

[1/2] v4l2: vb2: fix queue reallocation and REQBUFS(0) case

Message ID 1296219400-2582-2-git-send-email-m.szyprowski@samsung.com (mailing list archive)
State RFC
Headers show

Commit Message

Marek Szyprowski Jan. 28, 2011, 12:56 p.m. UTC
None
diff mbox

Patch

diff --git a/drivers/media/video/videobuf2-core.c b/drivers/media/video/videobuf2-core.c
index cc7ab0a..2f724ed 100644
--- a/drivers/media/video/videobuf2-core.c
+++ b/drivers/media/video/videobuf2-core.c
@@ -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 immedietely without calling
+		 * driver's queue_setup() callback and allocating resources.
+		 */
+		if (req->count == 0)
+			return 0;
 	}
 
 	/*