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