162306a36Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 262306a36Sopenharmony_ci.. c:namespace:: V4L 362306a36Sopenharmony_ci 462306a36Sopenharmony_ci.. _io: 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci############ 762306a36Sopenharmony_ciInput/Output 862306a36Sopenharmony_ci############ 962306a36Sopenharmony_ciThe V4L2 API defines several different methods to read from or write to 1062306a36Sopenharmony_cia device. All drivers exchanging data with applications must support at 1162306a36Sopenharmony_cileast one of them. 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ciThe classic I/O method using the :c:func:`read()` and 1462306a36Sopenharmony_ci:c:func:`write()` function is automatically selected after opening a 1562306a36Sopenharmony_ciV4L2 device. When the driver does not support this method attempts to 1662306a36Sopenharmony_ciread or write will fail at any time. 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ciOther methods must be negotiated. To select the streaming I/O method 1962306a36Sopenharmony_ciwith memory mapped or user buffers applications call the 2062306a36Sopenharmony_ci:ref:`VIDIOC_REQBUFS` ioctl. 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ciVideo overlay can be considered another I/O method, although the 2362306a36Sopenharmony_ciapplication does not directly receive the image data. It is selected by 2462306a36Sopenharmony_ciinitiating video overlay with the :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` 2562306a36Sopenharmony_ciioctl. For more information see :ref:`overlay`. 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ciGenerally exactly one I/O method, including overlay, is associated with 2862306a36Sopenharmony_cieach file descriptor. The only exceptions are applications not 2962306a36Sopenharmony_ciexchanging data with a driver ("panel applications", see :ref:`open`) 3062306a36Sopenharmony_ciand drivers permitting simultaneous video capturing and overlay using 3162306a36Sopenharmony_cithe same file descriptor, for compatibility with V4L and earlier 3262306a36Sopenharmony_civersions of V4L2. 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ci:ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` and :ref:`VIDIOC_REQBUFS` would permit this to some 3562306a36Sopenharmony_cidegree, but for simplicity drivers need not support switching the I/O 3662306a36Sopenharmony_cimethod (after first switching away from read/write) other than by 3762306a36Sopenharmony_ciclosing and reopening the device. 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ciThe following sections describe the various I/O methods in more detail. 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_ci.. toctree:: 4262306a36Sopenharmony_ci :maxdepth: 1 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ci rw 4562306a36Sopenharmony_ci mmap 4662306a36Sopenharmony_ci userp 4762306a36Sopenharmony_ci dmabuf 4862306a36Sopenharmony_ci buffer 4962306a36Sopenharmony_ci field-order 50