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