18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 28c2ecf20Sopenharmony_ci.. c:namespace:: V4L 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci.. _func-ioctl: 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci************ 78c2ecf20Sopenharmony_ciV4L2 ioctl() 88c2ecf20Sopenharmony_ci************ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ciName 118c2ecf20Sopenharmony_ci==== 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_civ4l2-ioctl - Program a V4L2 device 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ciSynopsis 168c2ecf20Sopenharmony_ci======== 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci.. code-block:: c 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci #include <sys/ioctl.h> 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci``int ioctl(int fd, int request, void *argp)`` 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ciArguments 258c2ecf20Sopenharmony_ci========= 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci``fd`` 288c2ecf20Sopenharmony_ci File descriptor returned by :c:func:`open()`. 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci``request`` 318c2ecf20Sopenharmony_ci V4L2 ioctl request code as defined in the ``videodev2.h`` header 328c2ecf20Sopenharmony_ci file, for example VIDIOC_QUERYCAP. 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci``argp`` 358c2ecf20Sopenharmony_ci Pointer to a function parameter, usually a structure. 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ciDescription 388c2ecf20Sopenharmony_ci=========== 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ciThe :ref:`ioctl() <func-ioctl>` function is used to program V4L2 devices. The 418c2ecf20Sopenharmony_ciargument ``fd`` must be an open file descriptor. An ioctl ``request`` 428c2ecf20Sopenharmony_cihas encoded in it whether the argument is an input, output or read/write 438c2ecf20Sopenharmony_ciparameter, and the size of the argument ``argp`` in bytes. Macros and 448c2ecf20Sopenharmony_cidefines specifying V4L2 ioctl requests are located in the 458c2ecf20Sopenharmony_ci``videodev2.h`` header file. Applications should use their own copy, not 468c2ecf20Sopenharmony_ciinclude the version in the kernel sources on the system they compile on. 478c2ecf20Sopenharmony_ciAll V4L2 ioctl requests, their respective function and parameters are 488c2ecf20Sopenharmony_cispecified in :ref:`user-func`. 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ciReturn Value 518c2ecf20Sopenharmony_ci============ 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ciOn success 0 is returned, on error -1 and the ``errno`` variable is set 548c2ecf20Sopenharmony_ciappropriately. The generic error codes are described at the 558c2ecf20Sopenharmony_ci:ref:`Generic Error Codes <gen-errors>` chapter. 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ciWhen an ioctl that takes an output or read/write parameter fails, the 588c2ecf20Sopenharmony_ciparameter remains unmodified. 59