xref: /OK3568_Linux_fs/kernel/Documentation/userspace-api/media/v4l/func-ioctl.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2*4882a593Smuzhiyun.. c:namespace:: V4L
3*4882a593Smuzhiyun
4*4882a593Smuzhiyun.. _func-ioctl:
5*4882a593Smuzhiyun
6*4882a593Smuzhiyun************
7*4882a593SmuzhiyunV4L2 ioctl()
8*4882a593Smuzhiyun************
9*4882a593Smuzhiyun
10*4882a593SmuzhiyunName
11*4882a593Smuzhiyun====
12*4882a593Smuzhiyun
13*4882a593Smuzhiyunv4l2-ioctl - Program a V4L2 device
14*4882a593Smuzhiyun
15*4882a593SmuzhiyunSynopsis
16*4882a593Smuzhiyun========
17*4882a593Smuzhiyun
18*4882a593Smuzhiyun.. code-block:: c
19*4882a593Smuzhiyun
20*4882a593Smuzhiyun    #include <sys/ioctl.h>
21*4882a593Smuzhiyun
22*4882a593Smuzhiyun``int ioctl(int fd, int request, void *argp)``
23*4882a593Smuzhiyun
24*4882a593SmuzhiyunArguments
25*4882a593Smuzhiyun=========
26*4882a593Smuzhiyun
27*4882a593Smuzhiyun``fd``
28*4882a593Smuzhiyun    File descriptor returned by :c:func:`open()`.
29*4882a593Smuzhiyun
30*4882a593Smuzhiyun``request``
31*4882a593Smuzhiyun    V4L2 ioctl request code as defined in the ``videodev2.h`` header
32*4882a593Smuzhiyun    file, for example VIDIOC_QUERYCAP.
33*4882a593Smuzhiyun
34*4882a593Smuzhiyun``argp``
35*4882a593Smuzhiyun    Pointer to a function parameter, usually a structure.
36*4882a593Smuzhiyun
37*4882a593SmuzhiyunDescription
38*4882a593Smuzhiyun===========
39*4882a593Smuzhiyun
40*4882a593SmuzhiyunThe :ref:`ioctl() <func-ioctl>` function is used to program V4L2 devices. The
41*4882a593Smuzhiyunargument ``fd`` must be an open file descriptor. An ioctl ``request``
42*4882a593Smuzhiyunhas encoded in it whether the argument is an input, output or read/write
43*4882a593Smuzhiyunparameter, and the size of the argument ``argp`` in bytes. Macros and
44*4882a593Smuzhiyundefines specifying V4L2 ioctl requests are located in the
45*4882a593Smuzhiyun``videodev2.h`` header file. Applications should use their own copy, not
46*4882a593Smuzhiyuninclude the version in the kernel sources on the system they compile on.
47*4882a593SmuzhiyunAll V4L2 ioctl requests, their respective function and parameters are
48*4882a593Smuzhiyunspecified in :ref:`user-func`.
49*4882a593Smuzhiyun
50*4882a593SmuzhiyunReturn Value
51*4882a593Smuzhiyun============
52*4882a593Smuzhiyun
53*4882a593SmuzhiyunOn success 0 is returned, on error -1 and the ``errno`` variable is set
54*4882a593Smuzhiyunappropriately. The generic error codes are described at the
55*4882a593Smuzhiyun:ref:`Generic Error Codes <gen-errors>` chapter.
56*4882a593Smuzhiyun
57*4882a593SmuzhiyunWhen an ioctl that takes an output or read/write parameter fails, the
58*4882a593Smuzhiyunparameter remains unmodified.
59