func-ioctl.rst 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
  2. .. c:namespace:: V4L
  3. .. _func-ioctl:
  4. ************
  5. V4L2 ioctl()
  6. ************
  7. Name
  8. ====
  9. v4l2-ioctl - Program a V4L2 device
  10. Synopsis
  11. ========
  12. .. code-block:: c
  13. #include <sys/ioctl.h>
  14. ``int ioctl(int fd, int request, void *argp)``
  15. Arguments
  16. =========
  17. ``fd``
  18. File descriptor returned by :c:func:`open()`.
  19. ``request``
  20. V4L2 ioctl request code as defined in the ``videodev2.h`` header
  21. file, for example VIDIOC_QUERYCAP.
  22. ``argp``
  23. Pointer to a function parameter, usually a structure.
  24. Description
  25. ===========
  26. The :ref:`ioctl() <func-ioctl>` function is used to program V4L2 devices. The
  27. argument ``fd`` must be an open file descriptor. An ioctl ``request``
  28. has encoded in it whether the argument is an input, output or read/write
  29. parameter, and the size of the argument ``argp`` in bytes. Macros and
  30. defines specifying V4L2 ioctl requests are located in the
  31. ``videodev2.h`` header file. Applications should use their own copy, not
  32. include the version in the kernel sources on the system they compile on.
  33. All V4L2 ioctl requests, their respective function and parameters are
  34. specified in :ref:`user-func`.
  35. Return Value
  36. ============
  37. On success 0 is returned, on error -1 and the ``errno`` variable is set
  38. appropriately. The generic error codes are described at the
  39. :ref:`Generic Error Codes <gen-errors>` chapter.
  40. When an ioctl that takes an output or read/write parameter fails, the
  41. parameter remains unmodified.