[linux-dvb] V4L2 Bug and/or Bad Docs for VIDIOC_REQBUFS ioctl()

andrzej zaborowski balrogg at gmail.com
Tue Dec 30 05:56:33 CET 2008

[Forwarding from a coder who wants to be anonymous]

The documentation at:


says that the VIDIOC_REQBUFS ioctl(), used to initiate memory mapping
or user pointer i/o on V4L2 devices, returns a 0 upon success, or a -1
on error, and sets errno to either EBUSY or EINVAL. The code, however,
does not follow this logic.

In /usr/src/linux/drivers/media/video/videobuf-core.c, in the function

 int videobuf_reqbufs(struct videobuf_queue *q, \
                      struct v4l2_requestbuffers *req);

If an error occours, "return -EINVAL" is called. If an error does not
occour, execution reaches the following statement:

 retval = __videobuf_mmap_setup(q, count, size, req->memory);

followed by:

 req->count = retval;


 return retval;

So, the value being returned, upon success, is the value returned from
the call to __videobuf_mmap_setup(). Looking inside the code for this
function, the buffers are setup inside a for() loop, and the last value
of "i" used as a counter for that loop is returned. In other words, the
buffers allocated count is returned.

So, is the documentation wrong ? or is the code wrong ?

More information about the linux-dvb mailing list