xref: /linux/Documentation/userspace-api/media/v4l/func-ioctl.rst (revision 059b1c5b15579b09c3787c3a3f843574233ab976)
1059b1c5bSMauro Carvalho Chehab.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
254f38fcaSMauro Carvalho Chehab
354f38fcaSMauro Carvalho Chehab.. _func-ioctl:
454f38fcaSMauro Carvalho Chehab
554f38fcaSMauro Carvalho Chehab************
654f38fcaSMauro Carvalho ChehabV4L2 ioctl()
754f38fcaSMauro Carvalho Chehab************
854f38fcaSMauro Carvalho Chehab
954f38fcaSMauro Carvalho ChehabName
1054f38fcaSMauro Carvalho Chehab====
1154f38fcaSMauro Carvalho Chehab
1254f38fcaSMauro Carvalho Chehabv4l2-ioctl - Program a V4L2 device
1354f38fcaSMauro Carvalho Chehab
1454f38fcaSMauro Carvalho Chehab
1554f38fcaSMauro Carvalho ChehabSynopsis
1654f38fcaSMauro Carvalho Chehab========
1754f38fcaSMauro Carvalho Chehab
1854f38fcaSMauro Carvalho Chehab.. code-block:: c
1954f38fcaSMauro Carvalho Chehab
2054f38fcaSMauro Carvalho Chehab    #include <sys/ioctl.h>
2154f38fcaSMauro Carvalho Chehab
2254f38fcaSMauro Carvalho Chehab
2354f38fcaSMauro Carvalho Chehab.. c:function:: int ioctl( int fd, int request, void *argp )
2454f38fcaSMauro Carvalho Chehab    :name: v4l2-ioctl
2554f38fcaSMauro Carvalho Chehab
2654f38fcaSMauro Carvalho ChehabArguments
2754f38fcaSMauro Carvalho Chehab=========
2854f38fcaSMauro Carvalho Chehab
2954f38fcaSMauro Carvalho Chehab``fd``
3054f38fcaSMauro Carvalho Chehab    File descriptor returned by :ref:`open() <func-open>`.
3154f38fcaSMauro Carvalho Chehab
3254f38fcaSMauro Carvalho Chehab``request``
3354f38fcaSMauro Carvalho Chehab    V4L2 ioctl request code as defined in the ``videodev2.h`` header
3454f38fcaSMauro Carvalho Chehab    file, for example VIDIOC_QUERYCAP.
3554f38fcaSMauro Carvalho Chehab
3654f38fcaSMauro Carvalho Chehab``argp``
3754f38fcaSMauro Carvalho Chehab    Pointer to a function parameter, usually a structure.
3854f38fcaSMauro Carvalho Chehab
3954f38fcaSMauro Carvalho Chehab
4054f38fcaSMauro Carvalho ChehabDescription
4154f38fcaSMauro Carvalho Chehab===========
4254f38fcaSMauro Carvalho Chehab
4354f38fcaSMauro Carvalho ChehabThe :ref:`ioctl() <func-ioctl>` function is used to program V4L2 devices. The
4454f38fcaSMauro Carvalho Chehabargument ``fd`` must be an open file descriptor. An ioctl ``request``
4554f38fcaSMauro Carvalho Chehabhas encoded in it whether the argument is an input, output or read/write
4654f38fcaSMauro Carvalho Chehabparameter, and the size of the argument ``argp`` in bytes. Macros and
4754f38fcaSMauro Carvalho Chehabdefines specifying V4L2 ioctl requests are located in the
4854f38fcaSMauro Carvalho Chehab``videodev2.h`` header file. Applications should use their own copy, not
4954f38fcaSMauro Carvalho Chehabinclude the version in the kernel sources on the system they compile on.
5054f38fcaSMauro Carvalho ChehabAll V4L2 ioctl requests, their respective function and parameters are
5154f38fcaSMauro Carvalho Chehabspecified in :ref:`user-func`.
5254f38fcaSMauro Carvalho Chehab
5354f38fcaSMauro Carvalho Chehab
5454f38fcaSMauro Carvalho ChehabReturn Value
5554f38fcaSMauro Carvalho Chehab============
5654f38fcaSMauro Carvalho Chehab
5754f38fcaSMauro Carvalho ChehabOn success 0 is returned, on error -1 and the ``errno`` variable is set
5854f38fcaSMauro Carvalho Chehabappropriately. The generic error codes are described at the
5954f38fcaSMauro Carvalho Chehab:ref:`Generic Error Codes <gen-errors>` chapter.
6054f38fcaSMauro Carvalho Chehab
6154f38fcaSMauro Carvalho ChehabWhen an ioctl that takes an output or read/write parameter fails, the
6254f38fcaSMauro Carvalho Chehabparameter remains unmodified.
63