2020-08-26 10:03:09 +03:00
.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2018-08-30 17:15:26 +03:00
2016-06-30 16:18:56 +03:00
.. _io:
############
Input/Output
############
The V4L2 API defines several different methods to read from or write to
a device. All drivers exchanging data with applications must support at
least one of them.
2016-07-04 18:56:17 +03:00
The classic I/O method using the :ref: `read() <func-read>` and
:ref: `write() <func-write>` function is automatically selected after opening a
2016-06-30 16:18:56 +03:00
V4L2 device. When the driver does not support this method attempts to
read or write will fail at any time.
Other methods must be negotiated. To select the streaming I/O method
with memory mapped or user buffers applications call the
2016-07-01 19:58:44 +03:00
:ref: `VIDIOC_REQBUFS` ioctl. The asynchronous I/O
2016-06-30 16:18:56 +03:00
method is not defined yet.
Video overlay can be considered another I/O method, although the
application does not directly receive the image data. It is selected by
2016-07-01 19:42:29 +03:00
initiating video overlay with the :ref: `VIDIOC_S_FMT <VIDIOC_G_FMT>`
2016-06-30 16:18:56 +03:00
ioctl. For more information see :ref: `overlay` .
Generally exactly one I/O method, including overlay, is associated with
each file descriptor. The only exceptions are applications not
exchanging data with a driver ("panel applications", see :ref: `open` )
and drivers permitting simultaneous video capturing and overlay using
the same file descriptor, for compatibility with V4L and earlier
versions of V4L2.
2016-07-01 20:33:56 +03:00
:ref: `VIDIOC_S_FMT <VIDIOC_G_FMT>` and :ref: `VIDIOC_REQBUFS` would permit this to some
2016-06-30 16:18:56 +03:00
degree, but for simplicity drivers need not support switching the I/O
method (after first switching away from read/write) other than by
closing and reopening the device.
The following sections describe the various I/O methods in more detail.
.. toctree ::
:maxdepth: 1
rw
mmap
userp
dmabuf
async
buffer
field-order