aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/DocBook
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-12-13 22:22:22 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-13 22:22:22 -0500
commitd8c532c40721f7507896d202b8cae3b3642d2b0d (patch)
tree42b1ce76671eb85324281ed93491432f4523f983 /Documentation/DocBook
parente777d192ffb9f2929d547a2f8a5f65b7db7a9552 (diff)
parent77c53d0b56264a8fc5844e087ad15fffe20c299d (diff)
Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
Pull media updates from Mauro Carvalho Chehab: - Missing MAINTAINERS entries were added for several drivers - Adds V4L2 support for DMABUF handling, allowing zero-copy buffer sharing between V4L2 devices and GPU - Got rid of all warnings when compiling with W=1 on x86 - Add a new driver for Exynos hardware (s3c-camif) - Several bug fixes, cleanups and driver improvements * 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (243 commits) [media] omap3isp: Replace cpu_is_omap3630() with ISP revision check [media] omap3isp: Prepare/unprepare clocks before/after enable/disable [media] omap3isp: preview: Add support for 8-bit formats at the sink pad [media] omap3isp: Replace printk with dev_* [media] omap3isp: Find source pad from external entity [media] omap3isp: Configure CSI-2 phy based on platform data [media] omap3isp: Add PHY routing configuration [media] omap3isp: Add CSI configuration registers from control block to ISP resources [media] omap3isp: Remove unneeded module memory address definitions [media] omap3isp: Use monotonic timestamps for statistics buffers [media] uvcvideo: Fix control value clamping for unsigned integer controls [media] uvcvideo: Mark first output terminal as default video node [media] uvcvideo: Add VIDIOC_[GS]_PRIORITY support [media] uvcvideo: Return -ENOTTY for unsupported ioctls [media] uvcvideo: Set device_caps in VIDIOC_QUERYCAP [media] uvcvideo: Don't fail when an unsupported format is requested [media] uvcvideo: Return -EACCES when trying to access a read/write-only control [media] uvcvideo: Set error_idx properly for extended controls API failures [media] rtl28xxu: add NOXON DAB/DAB+ USB dongle rev 2 [media] fc2580: write some registers conditionally ...
Diffstat (limited to 'Documentation/DocBook')
-rw-r--r--Documentation/DocBook/media/v4l/compat.xml7
-rw-r--r--Documentation/DocBook/media/v4l/io.xml188
-rw-r--r--Documentation/DocBook/media/v4l/v4l2.xml1
-rw-r--r--Documentation/DocBook/media/v4l/vidioc-create-bufs.xml16
-rw-r--r--Documentation/DocBook/media/v4l/vidioc-expbuf.xml212
-rw-r--r--Documentation/DocBook/media/v4l/vidioc-qbuf.xml17
-rw-r--r--Documentation/DocBook/media/v4l/vidioc-reqbufs.xml47
7 files changed, 456 insertions, 32 deletions
diff --git a/Documentation/DocBook/media/v4l/compat.xml b/Documentation/DocBook/media/v4l/compat.xml
index 4fdf6b562d1c..3dd9e78815d1 100644
--- a/Documentation/DocBook/media/v4l/compat.xml
+++ b/Documentation/DocBook/media/v4l/compat.xml
@@ -2586,6 +2586,13 @@ ioctls.</para>
2586 <para>Vendor and device specific media bus pixel formats. 2586 <para>Vendor and device specific media bus pixel formats.
2587 <xref linkend="v4l2-mbus-vendor-spec-fmts" />.</para> 2587 <xref linkend="v4l2-mbus-vendor-spec-fmts" />.</para>
2588 </listitem> 2588 </listitem>
2589 <listitem>
2590 <para>Importing DMABUF file descriptors as a new IO method described
2591 in <xref linkend="dmabuf" />.</para>
2592 </listitem>
2593 <listitem>
2594 <para>Exporting DMABUF files using &VIDIOC-EXPBUF; ioctl.</para>
2595 </listitem>
2589 </itemizedlist> 2596 </itemizedlist>
2590 </section> 2597 </section>
2591 2598
diff --git a/Documentation/DocBook/media/v4l/io.xml b/Documentation/DocBook/media/v4l/io.xml
index b5d1cbdc558b..388a34032653 100644
--- a/Documentation/DocBook/media/v4l/io.xml
+++ b/Documentation/DocBook/media/v4l/io.xml
@@ -331,7 +331,7 @@ application until one or more buffers can be dequeued. By default
331outgoing queue. When the <constant>O_NONBLOCK</constant> flag was 331outgoing queue. When the <constant>O_NONBLOCK</constant> flag was
332given to the &func-open; function, <constant>VIDIOC_DQBUF</constant> 332given to the &func-open; function, <constant>VIDIOC_DQBUF</constant>
333returns immediately with an &EAGAIN; when no buffer is available. The 333returns immediately with an &EAGAIN; when no buffer is available. The
334&func-select; or &func-poll; function are always available.</para> 334&func-select; or &func-poll; functions are always available.</para>
335 335
336 <para>To start and stop capturing or output applications call the 336 <para>To start and stop capturing or output applications call the
337&VIDIOC-STREAMON; and &VIDIOC-STREAMOFF; ioctl. Note 337&VIDIOC-STREAMON; and &VIDIOC-STREAMOFF; ioctl. Note
@@ -472,6 +472,165 @@ rest should be evident.</para>
472 </footnote></para> 472 </footnote></para>
473 </section> 473 </section>
474 474
475 <section id="dmabuf">
476 <title>Streaming I/O (DMA buffer importing)</title>
477
478 <note>
479 <title>Experimental</title>
480 <para>This is an <link linkend="experimental"> experimental </link>
481 interface and may change in the future.</para>
482 </note>
483
484<para>The DMABUF framework provides a generic method for sharing buffers
485between multiple devices. Device drivers that support DMABUF can export a DMA
486buffer to userspace as a file descriptor (known as the exporter role), import a
487DMA buffer from userspace using a file descriptor previously exported for a
488different or the same device (known as the importer role), or both. This
489section describes the DMABUF importer role API in V4L2.</para>
490
491 <para>Refer to <link linked="vidioc-expbuf"> DMABUF exporting </link> for
492details about exporting V4L2 buffers as DMABUF file descriptors.</para>
493
494<para>Input and output devices support the streaming I/O method when the
495<constant>V4L2_CAP_STREAMING</constant> flag in the
496<structfield>capabilities</structfield> field of &v4l2-capability; returned by
497the &VIDIOC-QUERYCAP; ioctl is set. Whether importing DMA buffers through
498DMABUF file descriptors is supported is determined by calling the
499&VIDIOC-REQBUFS; ioctl with the memory type set to
500<constant>V4L2_MEMORY_DMABUF</constant>.</para>
501
502 <para>This I/O method is dedicated to sharing DMA buffers between different
503devices, which may be V4L devices or other video-related devices (e.g. DRM).
504Buffers (planes) are allocated by a driver on behalf of an application. Next,
505these buffers are exported to the application as file descriptors using an API
506which is specific for an allocator driver. Only such file descriptor are
507exchanged. The descriptors and meta-information are passed in &v4l2-buffer; (or
508in &v4l2-plane; in the multi-planar API case). The driver must be switched
509into DMABUF I/O mode by calling the &VIDIOC-REQBUFS; with the desired buffer
510type.</para>
511
512 <example>
513 <title>Initiating streaming I/O with DMABUF file descriptors</title>
514
515 <programlisting>
516&v4l2-requestbuffers; reqbuf;
517
518memset(&amp;reqbuf, 0, sizeof (reqbuf));
519reqbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
520reqbuf.memory = V4L2_MEMORY_DMABUF;
521reqbuf.count = 1;
522
523if (ioctl(fd, &VIDIOC-REQBUFS;, &amp;reqbuf) == -1) {
524 if (errno == EINVAL)
525 printf("Video capturing or DMABUF streaming is not supported\n");
526 else
527 perror("VIDIOC_REQBUFS");
528
529 exit(EXIT_FAILURE);
530}
531 </programlisting>
532 </example>
533
534 <para>The buffer (plane) file descriptor is passed on the fly with the
535&VIDIOC-QBUF; ioctl. In case of multiplanar buffers, every plane can be
536associated with a different DMABUF descriptor. Although buffers are commonly
537cycled, applications can pass a different DMABUF descriptor at each
538<constant>VIDIOC_QBUF</constant> call.</para>
539
540 <example>
541 <title>Queueing DMABUF using single plane API</title>
542
543 <programlisting>
544int buffer_queue(int v4lfd, int index, int dmafd)
545{
546 &v4l2-buffer; buf;
547
548 memset(&amp;buf, 0, sizeof buf);
549 buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
550 buf.memory = V4L2_MEMORY_DMABUF;
551 buf.index = index;
552 buf.m.fd = dmafd;
553
554 if (ioctl(v4lfd, &VIDIOC-QBUF;, &amp;buf) == -1) {
555 perror("VIDIOC_QBUF");
556 return -1;
557 }
558
559 return 0;
560}
561 </programlisting>
562 </example>
563
564 <example>
565 <title>Queueing DMABUF using multi plane API</title>
566
567 <programlisting>
568int buffer_queue_mp(int v4lfd, int index, int dmafd[], int n_planes)
569{
570 &v4l2-buffer; buf;
571 &v4l2-plane; planes[VIDEO_MAX_PLANES];
572 int i;
573
574 memset(&amp;buf, 0, sizeof buf);
575 buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
576 buf.memory = V4L2_MEMORY_DMABUF;
577 buf.index = index;
578 buf.m.planes = planes;
579 buf.length = n_planes;
580
581 memset(&amp;planes, 0, sizeof planes);
582
583 for (i = 0; i &lt; n_planes; ++i)
584 buf.m.planes[i].m.fd = dmafd[i];
585
586 if (ioctl(v4lfd, &VIDIOC-QBUF;, &amp;buf) == -1) {
587 perror("VIDIOC_QBUF");
588 return -1;
589 }
590
591 return 0;
592}
593 </programlisting>
594 </example>
595
596 <para>Captured or displayed buffers are dequeued with the
597&VIDIOC-DQBUF; ioctl. The driver can unlock the buffer at any
598time between the completion of the DMA and this ioctl. The memory is
599also unlocked when &VIDIOC-STREAMOFF; is called, &VIDIOC-REQBUFS;, or
600when the device is closed.</para>
601
602 <para>For capturing applications it is customary to enqueue a
603number of empty buffers, to start capturing and enter the read loop.
604Here the application waits until a filled buffer can be dequeued, and
605re-enqueues the buffer when the data is no longer needed. Output
606applications fill and enqueue buffers, when enough buffers are stacked
607up output is started. In the write loop, when the application
608runs out of free buffers it must wait until an empty buffer can be
609dequeued and reused. Two methods exist to suspend execution of the
610application until one or more buffers can be dequeued. By default
611<constant>VIDIOC_DQBUF</constant> blocks when no buffer is in the
612outgoing queue. When the <constant>O_NONBLOCK</constant> flag was
613given to the &func-open; function, <constant>VIDIOC_DQBUF</constant>
614returns immediately with an &EAGAIN; when no buffer is available. The
615&func-select; and &func-poll; functions are always available.</para>
616
617 <para>To start and stop capturing or displaying applications call the
618&VIDIOC-STREAMON; and &VIDIOC-STREAMOFF; ioctls. Note that
619<constant>VIDIOC_STREAMOFF</constant> removes all buffers from both queues and
620unlocks all buffers as a side effect. Since there is no notion of doing
621anything "now" on a multitasking system, if an application needs to synchronize
622with another event it should examine the &v4l2-buffer;
623<structfield>timestamp</structfield> of captured buffers, or set the field
624before enqueuing buffers for output.</para>
625
626 <para>Drivers implementing DMABUF importing I/O must support the
627<constant>VIDIOC_REQBUFS</constant>, <constant>VIDIOC_QBUF</constant>,
628<constant>VIDIOC_DQBUF</constant>, <constant>VIDIOC_STREAMON</constant> and
629<constant>VIDIOC_STREAMOFF</constant> ioctls, and the
630<function>select()</function> and <function>poll()</function> functions.</para>
631
632 </section>
633
475 <section id="async"> 634 <section id="async">
476 <title>Asynchronous I/O</title> 635 <title>Asynchronous I/O</title>
477 636
@@ -673,6 +832,14 @@ memory, set by the application. See <xref linkend="userp" /> for details.
673 <structname>v4l2_buffer</structname> structure.</entry> 832 <structname>v4l2_buffer</structname> structure.</entry>
674 </row> 833 </row>
675 <row> 834 <row>
835 <entry></entry>
836 <entry>int</entry>
837 <entry><structfield>fd</structfield></entry>
838 <entry>For the single-plane API and when
839<structfield>memory</structfield> is <constant>V4L2_MEMORY_DMABUF</constant> this
840is the file descriptor associated with a DMABUF buffer.</entry>
841 </row>
842 <row>
676 <entry>__u32</entry> 843 <entry>__u32</entry>
677 <entry><structfield>length</structfield></entry> 844 <entry><structfield>length</structfield></entry>
678 <entry></entry> 845 <entry></entry>
@@ -744,6 +911,15 @@ should set this to 0.</entry>
744 </entry> 911 </entry>
745 </row> 912 </row>
746 <row> 913 <row>
914 <entry></entry>
915 <entry>int</entry>
916 <entry><structfield>fd</structfield></entry>
917 <entry>When the memory type in the containing &v4l2-buffer; is
918 <constant>V4L2_MEMORY_DMABUF</constant>, this is a file
919 descriptor associated with a DMABUF buffer, similar to the
920 <structfield>fd</structfield> field in &v4l2-buffer;.</entry>
921 </row>
922 <row>
747 <entry>__u32</entry> 923 <entry>__u32</entry>
748 <entry><structfield>data_offset</structfield></entry> 924 <entry><structfield>data_offset</structfield></entry>
749 <entry></entry> 925 <entry></entry>
@@ -923,7 +1099,7 @@ application. Drivers set or clear this flag when the
923 </row> 1099 </row>
924 <row> 1100 <row>
925 <entry><constant>V4L2_BUF_FLAG_NO_CACHE_INVALIDATE</constant></entry> 1101 <entry><constant>V4L2_BUF_FLAG_NO_CACHE_INVALIDATE</constant></entry>
926 <entry>0x0400</entry> 1102 <entry>0x0800</entry>
927 <entry>Caches do not have to be invalidated for this buffer. 1103 <entry>Caches do not have to be invalidated for this buffer.
928Typically applications shall use this flag if the data captured in the buffer 1104Typically applications shall use this flag if the data captured in the buffer
929is not going to be touched by the CPU, instead the buffer will, probably, be 1105is not going to be touched by the CPU, instead the buffer will, probably, be
@@ -932,7 +1108,7 @@ passed on to a DMA-capable hardware unit for further processing or output.
932 </row> 1108 </row>
933 <row> 1109 <row>
934 <entry><constant>V4L2_BUF_FLAG_NO_CACHE_CLEAN</constant></entry> 1110 <entry><constant>V4L2_BUF_FLAG_NO_CACHE_CLEAN</constant></entry>
935 <entry>0x0800</entry> 1111 <entry>0x1000</entry>
936 <entry>Caches do not have to be cleaned for this buffer. 1112 <entry>Caches do not have to be cleaned for this buffer.
937Typically applications shall use this flag for output buffers if the data 1113Typically applications shall use this flag for output buffers if the data
938in this buffer has not been created by the CPU but by some DMA-capable unit, 1114in this buffer has not been created by the CPU but by some DMA-capable unit,
@@ -964,6 +1140,12 @@ pointer</link> I/O.</entry>
964 <entry>3</entry> 1140 <entry>3</entry>
965 <entry>[to do]</entry> 1141 <entry>[to do]</entry>
966 </row> 1142 </row>
1143 <row>
1144 <entry><constant>V4L2_MEMORY_DMABUF</constant></entry>
1145 <entry>4</entry>
1146 <entry>The buffer is used for <link linkend="dmabuf">DMA shared
1147buffer</link> I/O.</entry>
1148 </row>
967 </tbody> 1149 </tbody>
968 </tgroup> 1150 </tgroup>
969 </table> 1151 </table>
diff --git a/Documentation/DocBook/media/v4l/v4l2.xml b/Documentation/DocBook/media/v4l/v4l2.xml
index 10ccde9d16d0..4d110b1ad3e9 100644
--- a/Documentation/DocBook/media/v4l/v4l2.xml
+++ b/Documentation/DocBook/media/v4l/v4l2.xml
@@ -543,6 +543,7 @@ and discussions on the V4L mailing list.</revremark>
543 &sub-enuminput; 543 &sub-enuminput;
544 &sub-enumoutput; 544 &sub-enumoutput;
545 &sub-enumstd; 545 &sub-enumstd;
546 &sub-expbuf;
546 &sub-g-audio; 547 &sub-g-audio;
547 &sub-g-audioout; 548 &sub-g-audioout;
548 &sub-g-crop; 549 &sub-g-crop;
diff --git a/Documentation/DocBook/media/v4l/vidioc-create-bufs.xml b/Documentation/DocBook/media/v4l/vidioc-create-bufs.xml
index a8cda1acacd9..cd9943672434 100644
--- a/Documentation/DocBook/media/v4l/vidioc-create-bufs.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-create-bufs.xml
@@ -6,7 +6,8 @@
6 6
7 <refnamediv> 7 <refnamediv>
8 <refname>VIDIOC_CREATE_BUFS</refname> 8 <refname>VIDIOC_CREATE_BUFS</refname>
9 <refpurpose>Create buffers for Memory Mapped or User Pointer I/O</refpurpose> 9 <refpurpose>Create buffers for Memory Mapped or User Pointer or DMA Buffer
10 I/O</refpurpose>
10 </refnamediv> 11 </refnamediv>
11 12
12 <refsynopsisdiv> 13 <refsynopsisdiv>
@@ -55,11 +56,11 @@
55 </note> 56 </note>
56 57
57 <para>This ioctl is used to create buffers for <link linkend="mmap">memory 58 <para>This ioctl is used to create buffers for <link linkend="mmap">memory
58mapped</link> or <link linkend="userp">user pointer</link> 59mapped</link> or <link linkend="userp">user pointer</link> or <link
59I/O. It can be used as an alternative or in addition to the 60linkend="dmabuf">DMA buffer</link> I/O. It can be used as an alternative or in
60<constant>VIDIOC_REQBUFS</constant> ioctl, when a tighter control over buffers 61addition to the <constant>VIDIOC_REQBUFS</constant> ioctl, when a tighter
61is required. This ioctl can be called multiple times to create buffers of 62control over buffers is required. This ioctl can be called multiple times to
62different sizes.</para> 63create buffers of different sizes.</para>
63 64
64 <para>To allocate device buffers applications initialize relevant fields of 65 <para>To allocate device buffers applications initialize relevant fields of
65the <structname>v4l2_create_buffers</structname> structure. They set the 66the <structname>v4l2_create_buffers</structname> structure. They set the
@@ -109,7 +110,8 @@ information.</para>
109 <entry>__u32</entry> 110 <entry>__u32</entry>
110 <entry><structfield>memory</structfield></entry> 111 <entry><structfield>memory</structfield></entry>
111 <entry>Applications set this field to 112 <entry>Applications set this field to
112<constant>V4L2_MEMORY_MMAP</constant> or 113<constant>V4L2_MEMORY_MMAP</constant>,
114<constant>V4L2_MEMORY_DMABUF</constant> or
113<constant>V4L2_MEMORY_USERPTR</constant>. See <xref linkend="v4l2-memory" 115<constant>V4L2_MEMORY_USERPTR</constant>. See <xref linkend="v4l2-memory"
114/></entry> 116/></entry>
115 </row> 117 </row>
diff --git a/Documentation/DocBook/media/v4l/vidioc-expbuf.xml b/Documentation/DocBook/media/v4l/vidioc-expbuf.xml
new file mode 100644
index 000000000000..72dfbd20a802
--- /dev/null
+++ b/Documentation/DocBook/media/v4l/vidioc-expbuf.xml
@@ -0,0 +1,212 @@
1<refentry id="vidioc-expbuf">
2
3 <refmeta>
4 <refentrytitle>ioctl VIDIOC_EXPBUF</refentrytitle>
5 &manvol;
6 </refmeta>
7
8 <refnamediv>
9 <refname>VIDIOC_EXPBUF</refname>
10 <refpurpose>Export a buffer as a DMABUF file descriptor.</refpurpose>
11 </refnamediv>
12
13 <refsynopsisdiv>
14 <funcsynopsis>
15 <funcprototype>
16 <funcdef>int <function>ioctl</function></funcdef>
17 <paramdef>int <parameter>fd</parameter></paramdef>
18 <paramdef>int <parameter>request</parameter></paramdef>
19 <paramdef>struct v4l2_exportbuffer *<parameter>argp</parameter></paramdef>
20 </funcprototype>
21 </funcsynopsis>
22 </refsynopsisdiv>
23
24 <refsect1>
25 <title>Arguments</title>
26
27 <variablelist>
28 <varlistentry>
29 <term><parameter>fd</parameter></term>
30 <listitem>
31 <para>&fd;</para>
32 </listitem>
33 </varlistentry>
34 <varlistentry>
35 <term><parameter>request</parameter></term>
36 <listitem>
37 <para>VIDIOC_EXPBUF</para>
38 </listitem>
39 </varlistentry>
40 <varlistentry>
41 <term><parameter>argp</parameter></term>
42 <listitem>
43 <para></para>
44 </listitem>
45 </varlistentry>
46 </variablelist>
47 </refsect1>
48
49 <refsect1>
50 <title>Description</title>
51
52 <note>
53 <title>Experimental</title>
54 <para>This is an <link linkend="experimental"> experimental </link>
55 interface and may change in the future.</para>
56 </note>
57
58<para>This ioctl is an extension to the <link linkend="mmap">memory
59mapping</link> I/O method, therefore it is available only for
60<constant>V4L2_MEMORY_MMAP</constant> buffers. It can be used to export a
61buffer as a DMABUF file at any time after buffers have been allocated with the
62&VIDIOC-REQBUFS; ioctl.</para>
63
64<para> To export a buffer, applications fill &v4l2-exportbuffer;. The
65<structfield> type </structfield> field is set to the same buffer type as was
66previously used with &v4l2-requestbuffers;<structfield> type </structfield>.
67Applications must also set the <structfield> index </structfield> field. Valid
68index numbers range from zero to the number of buffers allocated with
69&VIDIOC-REQBUFS; (&v4l2-requestbuffers;<structfield> count </structfield>)
70minus one. For the multi-planar API, applications set the <structfield> plane
71</structfield> field to the index of the plane to be exported. Valid planes
72range from zero to the maximal number of valid planes for the currently active
73format. For the single-planar API, applications must set <structfield> plane
74</structfield> to zero. Additional flags may be posted in the <structfield>
75flags </structfield> field. Refer to a manual for open() for details.
76Currently only O_CLOEXEC is supported. All other fields must be set to zero.
77In the case of multi-planar API, every plane is exported separately using
78multiple <constant> VIDIOC_EXPBUF </constant> calls. </para>
79
80<para> After calling <constant>VIDIOC_EXPBUF</constant> the <structfield> fd
81</structfield> field will be set by a driver. This is a DMABUF file
82descriptor. The application may pass it to other DMABUF-aware devices. Refer to
83<link linkend="dmabuf">DMABUF importing</link> for details about importing
84DMABUF files into V4L2 nodes. It is recommended to close a DMABUF file when it
85is no longer used to allow the associated memory to be reclaimed. </para>
86
87 </refsect1>
88 <refsect1>
89 <section>
90 <title>Examples</title>
91
92 <example>
93 <title>Exporting a buffer.</title>
94 <programlisting>
95int buffer_export(int v4lfd, &v4l2-buf-type; bt, int index, int *dmafd)
96{
97 &v4l2-exportbuffer; expbuf;
98
99 memset(&amp;expbuf, 0, sizeof(expbuf));
100 expbuf.type = bt;
101 expbuf.index = index;
102 if (ioctl(v4lfd, &VIDIOC-EXPBUF;, &amp;expbuf) == -1) {
103 perror("VIDIOC_EXPBUF");
104 return -1;
105 }
106
107 *dmafd = expbuf.fd;
108
109 return 0;
110}
111 </programlisting>
112 </example>
113
114 <example>
115 <title>Exporting a buffer using the multi-planar API.</title>
116 <programlisting>
117int buffer_export_mp(int v4lfd, &v4l2-buf-type; bt, int index,
118 int dmafd[], int n_planes)
119{
120 int i;
121
122 for (i = 0; i &lt; n_planes; ++i) {
123 &v4l2-exportbuffer; expbuf;
124
125 memset(&amp;expbuf, 0, sizeof(expbuf));
126 expbuf.type = bt;
127 expbuf.index = index;
128 expbuf.plane = i;
129 if (ioctl(v4lfd, &VIDIOC-EXPBUF;, &amp;expbuf) == -1) {
130 perror("VIDIOC_EXPBUF");
131 while (i)
132 close(dmafd[--i]);
133 return -1;
134 }
135 dmafd[i] = expbuf.fd;
136 }
137
138 return 0;
139}
140 </programlisting>
141 </example>
142 </section>
143 </refsect1>
144
145 <refsect1>
146 <table pgwide="1" frame="none" id="v4l2-exportbuffer">
147 <title>struct <structname>v4l2_exportbuffer</structname></title>
148 <tgroup cols="3">
149 &cs-str;
150 <tbody valign="top">
151 <row>
152 <entry>__u32</entry>
153 <entry><structfield>type</structfield></entry>
154 <entry>Type of the buffer, same as &v4l2-format;
155<structfield>type</structfield> or &v4l2-requestbuffers;
156<structfield>type</structfield>, set by the application. See <xref
157linkend="v4l2-buf-type" /></entry>
158 </row>
159 <row>
160 <entry>__u32</entry>
161 <entry><structfield>index</structfield></entry>
162 <entry>Number of the buffer, set by the application. This field is
163only used for <link linkend="mmap">memory mapping</link> I/O and can range from
164zero to the number of buffers allocated with the &VIDIOC-REQBUFS; and/or
165&VIDIOC-CREATE-BUFS; ioctls. </entry>
166 </row>
167 <row>
168 <entry>__u32</entry>
169 <entry><structfield>plane</structfield></entry>
170 <entry>Index of the plane to be exported when using the
171multi-planar API. Otherwise this value must be set to zero. </entry>
172 </row>
173 <row>
174 <entry>__u32</entry>
175 <entry><structfield>flags</structfield></entry>
176 <entry>Flags for the newly created file, currently only <constant>
177O_CLOEXEC </constant> is supported, refer to the manual of open() for more
178details.</entry>
179 </row>
180 <row>
181 <entry>__s32</entry>
182 <entry><structfield>fd</structfield></entry>
183 <entry>The DMABUF file descriptor associated with a buffer. Set by
184 the driver.</entry>
185 </row>
186 <row>
187 <entry>__u32</entry>
188 <entry><structfield>reserved[11]</structfield></entry>
189 <entry>Reserved field for future use. Must be set to zero.</entry>
190 </row>
191 </tbody>
192 </tgroup>
193 </table>
194
195 </refsect1>
196
197 <refsect1>
198 &return-value;
199 <variablelist>
200 <varlistentry>
201 <term><errorcode>EINVAL</errorcode></term>
202 <listitem>
203 <para>A queue is not in MMAP mode or DMABUF exporting is not
204supported or <structfield> flags </structfield> or <structfield> type
205</structfield> or <structfield> index </structfield> or <structfield> plane
206</structfield> fields are invalid.</para>
207 </listitem>
208 </varlistentry>
209 </variablelist>
210 </refsect1>
211
212</refentry>
diff --git a/Documentation/DocBook/media/v4l/vidioc-qbuf.xml b/Documentation/DocBook/media/v4l/vidioc-qbuf.xml
index 2d37abefce13..3504a7f2f382 100644
--- a/Documentation/DocBook/media/v4l/vidioc-qbuf.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-qbuf.xml
@@ -109,6 +109,23 @@ they cannot be swapped out to disk. Buffers remain locked until
109dequeued, until the &VIDIOC-STREAMOFF; or &VIDIOC-REQBUFS; ioctl is 109dequeued, until the &VIDIOC-STREAMOFF; or &VIDIOC-REQBUFS; ioctl is
110called, or until the device is closed.</para> 110called, or until the device is closed.</para>
111 111
112 <para>To enqueue a <link linkend="dmabuf">DMABUF</link> buffer applications
113set the <structfield>memory</structfield> field to
114<constant>V4L2_MEMORY_DMABUF</constant> and the <structfield>m.fd</structfield>
115field to a file descriptor associated with a DMABUF buffer. When the
116multi-planar API is used the <structfield>m.fd</structfield> fields of the
117passed array of &v4l2-plane; have to be used instead. When
118<constant>VIDIOC_QBUF</constant> is called with a pointer to this structure the
119driver sets the <constant>V4L2_BUF_FLAG_QUEUED</constant> flag and clears the
120<constant>V4L2_BUF_FLAG_MAPPED</constant> and
121<constant>V4L2_BUF_FLAG_DONE</constant> flags in the
122<structfield>flags</structfield> field, or it returns an error code. This
123ioctl locks the buffer. Locking a buffer means passing it to a driver for a
124hardware access (usually DMA). If an application accesses (reads/writes) a
125locked buffer then the result is undefined. Buffers remain locked until
126dequeued, until the &VIDIOC-STREAMOFF; or &VIDIOC-REQBUFS; ioctl is called, or
127until the device is closed.</para>
128
112 <para>Applications call the <constant>VIDIOC_DQBUF</constant> 129 <para>Applications call the <constant>VIDIOC_DQBUF</constant>
113ioctl to dequeue a filled (capturing) or displayed (output) buffer 130ioctl to dequeue a filled (capturing) or displayed (output) buffer
114from the driver's outgoing queue. They just set the 131from the driver's outgoing queue. They just set the
diff --git a/Documentation/DocBook/media/v4l/vidioc-reqbufs.xml b/Documentation/DocBook/media/v4l/vidioc-reqbufs.xml
index 2b50ef2007f3..78a06a9a5ece 100644
--- a/Documentation/DocBook/media/v4l/vidioc-reqbufs.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-reqbufs.xml
@@ -48,28 +48,30 @@
48 <refsect1> 48 <refsect1>
49 <title>Description</title> 49 <title>Description</title>
50 50
51 <para>This ioctl is used to initiate <link linkend="mmap">memory 51<para>This ioctl is used to initiate <link linkend="mmap">memory mapped</link>,
52mapped</link> or <link linkend="userp">user pointer</link> 52<link linkend="userp">user pointer</link> or <link
53I/O. Memory mapped buffers are located in device memory and must be 53linkend="dmabuf">DMABUF</link> based I/O. Memory mapped buffers are located in
54allocated with this ioctl before they can be mapped into the 54device memory and must be allocated with this ioctl before they can be mapped
55application's address space. User buffers are allocated by 55into the application's address space. User buffers are allocated by
56applications themselves, and this ioctl is merely used to switch the 56applications themselves, and this ioctl is merely used to switch the driver
57driver into user pointer I/O mode and to setup some internal structures.</para> 57into user pointer I/O mode and to setup some internal structures.
58Similarly, DMABUF buffers are allocated by applications through a device
59driver, and this ioctl only configures the driver into DMABUF I/O mode without
60performing any direct allocation.</para>
58 61
59 <para>To allocate device buffers applications initialize all 62 <para>To allocate device buffers applications initialize all fields of the
60fields of the <structname>v4l2_requestbuffers</structname> structure. 63<structname>v4l2_requestbuffers</structname> structure. They set the
61They set the <structfield>type</structfield> field to the respective 64<structfield>type</structfield> field to the respective stream or buffer type,
62stream or buffer type, the <structfield>count</structfield> field to 65the <structfield>count</structfield> field to the desired number of buffers,
63the desired number of buffers, <structfield>memory</structfield> 66<structfield>memory</structfield> must be set to the requested I/O method and
64must be set to the requested I/O method and the <structfield>reserved</structfield> array 67the <structfield>reserved</structfield> array must be zeroed. When the ioctl is
65must be zeroed. When the ioctl 68called with a pointer to this structure the driver will attempt to allocate the
66is called with a pointer to this structure the driver will attempt to allocate 69requested number of buffers and it stores the actual number allocated in the
67the requested number of buffers and it stores the actual number 70<structfield>count</structfield> field. It can be smaller than the number
68allocated in the <structfield>count</structfield> field. It can be 71requested, even zero, when the driver runs out of free memory. A larger number
69smaller than the number requested, even zero, when the driver runs out 72is also possible when the driver requires more buffers to function correctly.
70of free memory. A larger number is also possible when the driver requires 73For example video output requires at least two buffers, one displayed and one
71more buffers to function correctly. For example video output requires at least two buffers, 74filled by the application.</para>
72one displayed and one filled by the application.</para>
73 <para>When the I/O method is not supported the ioctl 75 <para>When the I/O method is not supported the ioctl
74returns an &EINVAL;.</para> 76returns an &EINVAL;.</para>
75 77
@@ -102,7 +104,8 @@ as the &v4l2-format; <structfield>type</structfield> field. See <xref
102 <entry>__u32</entry> 104 <entry>__u32</entry>
103 <entry><structfield>memory</structfield></entry> 105 <entry><structfield>memory</structfield></entry>
104 <entry>Applications set this field to 106 <entry>Applications set this field to
105<constant>V4L2_MEMORY_MMAP</constant> or 107<constant>V4L2_MEMORY_MMAP</constant>,
108<constant>V4L2_MEMORY_DMABUF</constant> or
106<constant>V4L2_MEMORY_USERPTR</constant>. See <xref linkend="v4l2-memory" 109<constant>V4L2_MEMORY_USERPTR</constant>. See <xref linkend="v4l2-memory"
107/>.</entry> 110/>.</entry>
108 </row> 111 </row>