v4l2-ioctl — Program a V4L2 device


#include <sys/ioctl.h>
int ioctl(int  fd,
 int  request,
 void * argp);



File descriptor returned by open().


V4L2 ioctl request code as defined in the videodev.h header file, for example VIDIOC_QUERYCAP.


Pointer to a function parameter, usually a structure.


The ioctl() function is used to program V4L2 devices. The argument fd must be an open file descriptor. An ioctl request has encoded in it whether the argument is an input, output or read/write parameter, and the size of the argument argp in bytes. Macros and defines specifying V4L2 ioctl requests are located in the videodev.h header file. Applications should use their own copy, not include the version in the kernel sources on the system they compile on. All V4L2 ioctl requests, their respective function and parameters are specified in Function Reference.

Return Value

On success the ioctl() function returns 0 and does not reset the errno variable. On failure -1 is returned, when the ioctl takes an output or read/write parameter it remains unmodified, and the errno variable is set appropriately. See below for possible error codes. Generic errors like EBADF or EFAULT are not listed in the sections discussing individual ioctl requests.

Note ioctls may return undefined error codes. Since errors may have side effects such as a driver reset applications should abort on unexpected errors.


fd is not a valid open file descriptor.


The property cannot be changed right now. Typically this error code is returned when I/O is in progress or the driver supports multiple opens and another process locked the property.


argp references an inaccessible memory area.


fd is not associated with a character special device.


The request or the data pointed to by argp is not valid. This is a very common error code, see the individual ioctl requests listed in Function Reference for actual causes.


Not enough physical or virtual memory was available to complete the request.


The application attempted to set a control with the VIDIOC_S_CTRL ioctl to a value which is out of bounds.