1059b1c5bSMauro Carvalho Chehab.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2407e84cdSMauro Carvalho Chehab.. c:namespace:: V4L
354f38fcaSMauro Carvalho Chehab
454f38fcaSMauro Carvalho Chehab.. _io:
554f38fcaSMauro Carvalho Chehab
654f38fcaSMauro Carvalho Chehab############
754f38fcaSMauro Carvalho ChehabInput/Output
854f38fcaSMauro Carvalho Chehab############
954f38fcaSMauro Carvalho ChehabThe V4L2 API defines several different methods to read from or write to
1054f38fcaSMauro Carvalho Chehaba device. All drivers exchanging data with applications must support at
1154f38fcaSMauro Carvalho Chehableast one of them.
1254f38fcaSMauro Carvalho Chehab
13407e84cdSMauro Carvalho ChehabThe classic I/O method using the :c:func:`read()` and
14407e84cdSMauro Carvalho Chehab:c:func:`write()` function is automatically selected after opening a
1554f38fcaSMauro Carvalho ChehabV4L2 device. When the driver does not support this method attempts to
1654f38fcaSMauro Carvalho Chehabread or write will fail at any time.
1754f38fcaSMauro Carvalho Chehab
1854f38fcaSMauro Carvalho ChehabOther methods must be negotiated. To select the streaming I/O method
1954f38fcaSMauro Carvalho Chehabwith memory mapped or user buffers applications call the
20*17611d3fSHans Verkuil:ref:`VIDIOC_REQBUFS` ioctl.
2154f38fcaSMauro Carvalho Chehab
2254f38fcaSMauro Carvalho ChehabVideo overlay can be considered another I/O method, although the
2354f38fcaSMauro Carvalho Chehabapplication does not directly receive the image data. It is selected by
2454f38fcaSMauro Carvalho Chehabinitiating video overlay with the :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>`
2554f38fcaSMauro Carvalho Chehabioctl. For more information see :ref:`overlay`.
2654f38fcaSMauro Carvalho Chehab
2754f38fcaSMauro Carvalho ChehabGenerally exactly one I/O method, including overlay, is associated with
2854f38fcaSMauro Carvalho Chehabeach file descriptor. The only exceptions are applications not
2954f38fcaSMauro Carvalho Chehabexchanging data with a driver ("panel applications", see :ref:`open`)
3054f38fcaSMauro Carvalho Chehaband drivers permitting simultaneous video capturing and overlay using
3154f38fcaSMauro Carvalho Chehabthe same file descriptor, for compatibility with V4L and earlier
3254f38fcaSMauro Carvalho Chehabversions of V4L2.
3354f38fcaSMauro Carvalho Chehab
3454f38fcaSMauro Carvalho Chehab:ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` and :ref:`VIDIOC_REQBUFS` would permit this to some
3554f38fcaSMauro Carvalho Chehabdegree, but for simplicity drivers need not support switching the I/O
3654f38fcaSMauro Carvalho Chehabmethod (after first switching away from read/write) other than by
3754f38fcaSMauro Carvalho Chehabclosing and reopening the device.
3854f38fcaSMauro Carvalho Chehab
3954f38fcaSMauro Carvalho ChehabThe following sections describe the various I/O methods in more detail.
4054f38fcaSMauro Carvalho Chehab
4154f38fcaSMauro Carvalho Chehab.. toctree::
4254f38fcaSMauro Carvalho Chehab    :maxdepth: 1
4354f38fcaSMauro Carvalho Chehab
4454f38fcaSMauro Carvalho Chehab    rw
4554f38fcaSMauro Carvalho Chehab    mmap
4654f38fcaSMauro Carvalho Chehab    userp
4754f38fcaSMauro Carvalho Chehab    dmabuf
4854f38fcaSMauro Carvalho Chehab    buffer
4954f38fcaSMauro Carvalho Chehab    field-order
50