Video for Linux Two API Specification: Revision 0.24
Prev |  | Next

# V4L2 ioctl()

## Name

v4l2-ioctl -- Program a V4L2 device

## Synopsis

    #include <sys/ioctl.h>

``int ioctl`(int fd, int request, void *argp);`

## Arguments

`fd`

  File descriptor returned by `open()`.

`request`

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

`argp`

  Pointer to a function parameter, usually a structure.

## Description

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 Reference I, 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.

EBADF

  `fd` is not a valid open file descriptor.

EBUSY

  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.

EFAULT

  `argp` references an inaccessible memory area.

ENOTTY

  `fd` is not associated with a character special device.

EINVAL

  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 Reference I, Function Reference for actual causes.

ENOMEM

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

ERANGE

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

Prev | Home | Next
V4L2 close() | Up | ioctl VIDIOC_CROPCAP