^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) .. c:namespace:: V4L
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) .. _io:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) ############
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) Input/Output
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) ############
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) The V4L2 API defines several different methods to read from or write to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) a device. All drivers exchanging data with applications must support at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) least one of them.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) The classic I/O method using the :c:func:`read()` and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) :c:func:`write()` function is automatically selected after opening a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) V4L2 device. When the driver does not support this method attempts to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) read or write will fail at any time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) Other methods must be negotiated. To select the streaming I/O method
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) with memory mapped or user buffers applications call the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) :ref:`VIDIOC_REQBUFS` ioctl. The asynchronous I/O
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) method is not defined yet.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) Video overlay can be considered another I/O method, although the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) application does not directly receive the image data. It is selected by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) initiating video overlay with the :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) ioctl. For more information see :ref:`overlay`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) Generally exactly one I/O method, including overlay, is associated with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) each file descriptor. The only exceptions are applications not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) exchanging data with a driver ("panel applications", see :ref:`open`)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) and drivers permitting simultaneous video capturing and overlay using
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) the same file descriptor, for compatibility with V4L and earlier
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) versions of V4L2.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` and :ref:`VIDIOC_REQBUFS` would permit this to some
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) degree, but for simplicity drivers need not support switching the I/O
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) method (after first switching away from read/write) other than by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) closing and reopening the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) The following sections describe the various I/O methods in more detail.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) .. toctree::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) :maxdepth: 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) rw
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) mmap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) userp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) dmabuf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) async
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) field-order