xref: /linux/Documentation/userspace-api/media/v4l/io.rst (revision 54f38fcae536ea202ce7d6a359521492fba30c1f)
1*54f38fcaSMauro Carvalho Chehab.. Permission is granted to copy, distribute and/or modify this
2*54f38fcaSMauro Carvalho Chehab.. document under the terms of the GNU Free Documentation License,
3*54f38fcaSMauro Carvalho Chehab.. Version 1.1 or any later version published by the Free Software
4*54f38fcaSMauro Carvalho Chehab.. Foundation, with no Invariant Sections, no Front-Cover Texts
5*54f38fcaSMauro Carvalho Chehab.. and no Back-Cover Texts. A copy of the license is included at
6*54f38fcaSMauro Carvalho Chehab.. Documentation/userspace-api/media/fdl-appendix.rst.
7*54f38fcaSMauro Carvalho Chehab..
8*54f38fcaSMauro Carvalho Chehab.. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections
9*54f38fcaSMauro Carvalho Chehab
10*54f38fcaSMauro Carvalho Chehab.. _io:
11*54f38fcaSMauro Carvalho Chehab
12*54f38fcaSMauro Carvalho Chehab############
13*54f38fcaSMauro Carvalho ChehabInput/Output
14*54f38fcaSMauro Carvalho Chehab############
15*54f38fcaSMauro Carvalho ChehabThe V4L2 API defines several different methods to read from or write to
16*54f38fcaSMauro Carvalho Chehaba device. All drivers exchanging data with applications must support at
17*54f38fcaSMauro Carvalho Chehableast one of them.
18*54f38fcaSMauro Carvalho Chehab
19*54f38fcaSMauro Carvalho ChehabThe classic I/O method using the :ref:`read() <func-read>` and
20*54f38fcaSMauro Carvalho Chehab:ref:`write() <func-write>` function is automatically selected after opening a
21*54f38fcaSMauro Carvalho ChehabV4L2 device. When the driver does not support this method attempts to
22*54f38fcaSMauro Carvalho Chehabread or write will fail at any time.
23*54f38fcaSMauro Carvalho Chehab
24*54f38fcaSMauro Carvalho ChehabOther methods must be negotiated. To select the streaming I/O method
25*54f38fcaSMauro Carvalho Chehabwith memory mapped or user buffers applications call the
26*54f38fcaSMauro Carvalho Chehab:ref:`VIDIOC_REQBUFS` ioctl. The asynchronous I/O
27*54f38fcaSMauro Carvalho Chehabmethod is not defined yet.
28*54f38fcaSMauro Carvalho Chehab
29*54f38fcaSMauro Carvalho ChehabVideo overlay can be considered another I/O method, although the
30*54f38fcaSMauro Carvalho Chehabapplication does not directly receive the image data. It is selected by
31*54f38fcaSMauro Carvalho Chehabinitiating video overlay with the :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>`
32*54f38fcaSMauro Carvalho Chehabioctl. For more information see :ref:`overlay`.
33*54f38fcaSMauro Carvalho Chehab
34*54f38fcaSMauro Carvalho ChehabGenerally exactly one I/O method, including overlay, is associated with
35*54f38fcaSMauro Carvalho Chehabeach file descriptor. The only exceptions are applications not
36*54f38fcaSMauro Carvalho Chehabexchanging data with a driver ("panel applications", see :ref:`open`)
37*54f38fcaSMauro Carvalho Chehaband drivers permitting simultaneous video capturing and overlay using
38*54f38fcaSMauro Carvalho Chehabthe same file descriptor, for compatibility with V4L and earlier
39*54f38fcaSMauro Carvalho Chehabversions of V4L2.
40*54f38fcaSMauro Carvalho Chehab
41*54f38fcaSMauro Carvalho Chehab:ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` and :ref:`VIDIOC_REQBUFS` would permit this to some
42*54f38fcaSMauro Carvalho Chehabdegree, but for simplicity drivers need not support switching the I/O
43*54f38fcaSMauro Carvalho Chehabmethod (after first switching away from read/write) other than by
44*54f38fcaSMauro Carvalho Chehabclosing and reopening the device.
45*54f38fcaSMauro Carvalho Chehab
46*54f38fcaSMauro Carvalho ChehabThe following sections describe the various I/O methods in more detail.
47*54f38fcaSMauro Carvalho Chehab
48*54f38fcaSMauro Carvalho Chehab
49*54f38fcaSMauro Carvalho Chehab.. toctree::
50*54f38fcaSMauro Carvalho Chehab    :maxdepth: 1
51*54f38fcaSMauro Carvalho Chehab
52*54f38fcaSMauro Carvalho Chehab    rw
53*54f38fcaSMauro Carvalho Chehab    mmap
54*54f38fcaSMauro Carvalho Chehab    userp
55*54f38fcaSMauro Carvalho Chehab    dmabuf
56*54f38fcaSMauro Carvalho Chehab    async
57*54f38fcaSMauro Carvalho Chehab    buffer
58*54f38fcaSMauro Carvalho Chehab    field-order
59