xref: /linux/Documentation/userspace-api/media/v4l/func-ioctl.rst (revision 48dea9a700c8728cc31a1dd44588b97578de86ee)
1.. Permission is granted to copy, distribute and/or modify this
2.. document under the terms of the GNU Free Documentation License,
3.. Version 1.1 or any later version published by the Free Software
4.. Foundation, with no Invariant Sections, no Front-Cover Texts
5.. and no Back-Cover Texts. A copy of the license is included at
6.. Documentation/userspace-api/media/fdl-appendix.rst.
7..
8.. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections
9
10.. _func-ioctl:
11
12************
13V4L2 ioctl()
14************
15
16Name
17====
18
19v4l2-ioctl - Program a V4L2 device
20
21
22Synopsis
23========
24
25.. code-block:: c
26
27    #include <sys/ioctl.h>
28
29
30.. c:function:: int ioctl( int fd, int request, void *argp )
31    :name: v4l2-ioctl
32
33Arguments
34=========
35
36``fd``
37    File descriptor returned by :ref:`open() <func-open>`.
38
39``request``
40    V4L2 ioctl request code as defined in the ``videodev2.h`` header
41    file, for example VIDIOC_QUERYCAP.
42
43``argp``
44    Pointer to a function parameter, usually a structure.
45
46
47Description
48===========
49
50The :ref:`ioctl() <func-ioctl>` function is used to program V4L2 devices. The
51argument ``fd`` must be an open file descriptor. An ioctl ``request``
52has encoded in it whether the argument is an input, output or read/write
53parameter, and the size of the argument ``argp`` in bytes. Macros and
54defines specifying V4L2 ioctl requests are located in the
55``videodev2.h`` header file. Applications should use their own copy, not
56include the version in the kernel sources on the system they compile on.
57All V4L2 ioctl requests, their respective function and parameters are
58specified in :ref:`user-func`.
59
60
61Return Value
62============
63
64On success 0 is returned, on error -1 and the ``errno`` variable is set
65appropriately. The generic error codes are described at the
66:ref:`Generic Error Codes <gen-errors>` chapter.
67
68When an ioctl that takes an output or read/write parameter fails, the
69parameter remains unmodified.
70