18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 28c2ecf20Sopenharmony_ci.. c:namespace:: V4L 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci.. _io: 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci############ 78c2ecf20Sopenharmony_ciInput/Output 88c2ecf20Sopenharmony_ci############ 98c2ecf20Sopenharmony_ciThe V4L2 API defines several different methods to read from or write to 108c2ecf20Sopenharmony_cia device. All drivers exchanging data with applications must support at 118c2ecf20Sopenharmony_cileast one of them. 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ciThe classic I/O method using the :c:func:`read()` and 148c2ecf20Sopenharmony_ci:c:func:`write()` function is automatically selected after opening a 158c2ecf20Sopenharmony_ciV4L2 device. When the driver does not support this method attempts to 168c2ecf20Sopenharmony_ciread or write will fail at any time. 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ciOther methods must be negotiated. To select the streaming I/O method 198c2ecf20Sopenharmony_ciwith memory mapped or user buffers applications call the 208c2ecf20Sopenharmony_ci:ref:`VIDIOC_REQBUFS` ioctl. The asynchronous I/O 218c2ecf20Sopenharmony_cimethod is not defined yet. 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ciVideo overlay can be considered another I/O method, although the 248c2ecf20Sopenharmony_ciapplication does not directly receive the image data. It is selected by 258c2ecf20Sopenharmony_ciinitiating video overlay with the :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` 268c2ecf20Sopenharmony_ciioctl. For more information see :ref:`overlay`. 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ciGenerally exactly one I/O method, including overlay, is associated with 298c2ecf20Sopenharmony_cieach file descriptor. The only exceptions are applications not 308c2ecf20Sopenharmony_ciexchanging data with a driver ("panel applications", see :ref:`open`) 318c2ecf20Sopenharmony_ciand drivers permitting simultaneous video capturing and overlay using 328c2ecf20Sopenharmony_cithe same file descriptor, for compatibility with V4L and earlier 338c2ecf20Sopenharmony_civersions of V4L2. 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci:ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` and :ref:`VIDIOC_REQBUFS` would permit this to some 368c2ecf20Sopenharmony_cidegree, but for simplicity drivers need not support switching the I/O 378c2ecf20Sopenharmony_cimethod (after first switching away from read/write) other than by 388c2ecf20Sopenharmony_ciclosing and reopening the device. 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ciThe following sections describe the various I/O methods in more detail. 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci.. toctree:: 438c2ecf20Sopenharmony_ci :maxdepth: 1 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci rw 468c2ecf20Sopenharmony_ci mmap 478c2ecf20Sopenharmony_ci userp 488c2ecf20Sopenharmony_ci dmabuf 498c2ecf20Sopenharmony_ci async 508c2ecf20Sopenharmony_ci buffer 518c2ecf20Sopenharmony_ci field-order 52