Browse Source

[media] videobuf: Allow reqbufs(0) to free current buffers

All the infrastructure for this is already there, and despite our desires for
the old videobuf code to go away, it is currently still in use in 18 drivers.

Allowing reqbufs(0) makes these drivers behave consistent with modern drivers,
making live easier for userspace, see e.g. :
https://bugzilla.gnome.org/show_bug.cgi?id=735660

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Hans de Goede 11 years ago
parent
commit
b7900eedfb
1 changed files with 6 additions and 5 deletions
  1. 6 5
      drivers/media/v4l2-core/videobuf-core.c

+ 6 - 5
drivers/media/v4l2-core/videobuf-core.c

@@ -441,11 +441,6 @@ int videobuf_reqbufs(struct videobuf_queue *q,
 	unsigned int size, count;
 	unsigned int size, count;
 	int retval;
 	int retval;
 
 
-	if (req->count < 1) {
-		dprintk(1, "reqbufs: count invalid (%d)\n", req->count);
-		return -EINVAL;
-	}
-
 	if (req->memory != V4L2_MEMORY_MMAP     &&
 	if (req->memory != V4L2_MEMORY_MMAP     &&
 	    req->memory != V4L2_MEMORY_USERPTR  &&
 	    req->memory != V4L2_MEMORY_USERPTR  &&
 	    req->memory != V4L2_MEMORY_OVERLAY) {
 	    req->memory != V4L2_MEMORY_OVERLAY) {
@@ -471,6 +466,12 @@ int videobuf_reqbufs(struct videobuf_queue *q,
 		goto done;
 		goto done;
 	}
 	}
 
 
+	if (req->count == 0) {
+		dprintk(1, "reqbufs: count invalid (%d)\n", req->count);
+		retval = __videobuf_free(q);
+		goto done;
+	}
+
 	count = req->count;
 	count = req->count;
 	if (count > VIDEO_MAX_FRAME)
 	if (count > VIDEO_MAX_FRAME)
 		count = VIDEO_MAX_FRAME;
 		count = VIDEO_MAX_FRAME;