diff options
author | Tomasz Stanislawski <t.stanislaws@samsung.com> | 2012-06-14 10:32:22 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-11-25 14:20:55 -0500 |
commit | 19b6ef51640fb35666884c7b577b1a24a4be8e34 (patch) | |
tree | fea5f251a36e7c076ffe7cf19d7dec7d8dcf0f56 /Documentation/DocBook | |
parent | b799d09a157da71566e8013a62073435550cab6d (diff) |
[media] Documentation: media: description of DMABUF exporting in V4L2
This patch adds description and usage examples for exporting
DMABUF file descriptor in V4L2.
Signed-off-by: Tomasz Stanislawski <t.stanislaws@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'Documentation/DocBook')
-rw-r--r-- | Documentation/DocBook/media/v4l/compat.xml | 3 | ||||
-rw-r--r-- | Documentation/DocBook/media/v4l/io.xml | 3 | ||||
-rw-r--r-- | Documentation/DocBook/media/v4l/v4l2.xml | 1 | ||||
-rw-r--r-- | Documentation/DocBook/media/v4l/vidioc-expbuf.xml | 212 |
4 files changed, 219 insertions, 0 deletions
diff --git a/Documentation/DocBook/media/v4l/compat.xml b/Documentation/DocBook/media/v4l/compat.xml index 50eb63024eb7..3dd9e78815d1 100644 --- a/Documentation/DocBook/media/v4l/compat.xml +++ b/Documentation/DocBook/media/v4l/compat.xml | |||
@@ -2590,6 +2590,9 @@ ioctls.</para> | |||
2590 | <para>Importing DMABUF file descriptors as a new IO method described | 2590 | <para>Importing DMABUF file descriptors as a new IO method described |
2591 | in <xref linkend="dmabuf" />.</para> | 2591 | in <xref linkend="dmabuf" />.</para> |
2592 | </listitem> | 2592 | </listitem> |
2593 | <listitem> | ||
2594 | <para>Exporting DMABUF files using &VIDIOC-EXPBUF; ioctl.</para> | ||
2595 | </listitem> | ||
2593 | </itemizedlist> | 2596 | </itemizedlist> |
2594 | </section> | 2597 | </section> |
2595 | 2598 | ||
diff --git a/Documentation/DocBook/media/v4l/io.xml b/Documentation/DocBook/media/v4l/io.xml index be0fad7e1209..388a34032653 100644 --- a/Documentation/DocBook/media/v4l/io.xml +++ b/Documentation/DocBook/media/v4l/io.xml | |||
@@ -488,6 +488,9 @@ DMA buffer from userspace using a file descriptor previously exported for a | |||
488 | different or the same device (known as the importer role), or both. This | 488 | different or the same device (known as the importer role), or both. This |
489 | section describes the DMABUF importer role API in V4L2.</para> | 489 | section describes the DMABUF importer role API in V4L2.</para> |
490 | 490 | ||
491 | <para>Refer to <link linked="vidioc-expbuf"> DMABUF exporting </link> for | ||
492 | details about exporting V4L2 buffers as DMABUF file descriptors.</para> | ||
493 | |||
491 | <para>Input and output devices support the streaming I/O method when the | 494 | <para>Input and output devices support the streaming I/O method when the |
492 | <constant>V4L2_CAP_STREAMING</constant> flag in the | 495 | <constant>V4L2_CAP_STREAMING</constant> flag in the |
493 | <structfield>capabilities</structfield> field of &v4l2-capability; returned by | 496 | <structfield>capabilities</structfield> field of &v4l2-capability; returned by |
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-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 | ||
59 | mapping</link> I/O method, therefore it is available only for | ||
60 | <constant>V4L2_MEMORY_MMAP</constant> buffers. It can be used to export a | ||
61 | buffer 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 | ||
66 | previously used with &v4l2-requestbuffers;<structfield> type </structfield>. | ||
67 | Applications must also set the <structfield> index </structfield> field. Valid | ||
68 | index numbers range from zero to the number of buffers allocated with | ||
69 | &VIDIOC-REQBUFS; (&v4l2-requestbuffers;<structfield> count </structfield>) | ||
70 | minus 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 | ||
72 | range from zero to the maximal number of valid planes for the currently active | ||
73 | format. For the single-planar API, applications must set <structfield> plane | ||
74 | </structfield> to zero. Additional flags may be posted in the <structfield> | ||
75 | flags </structfield> field. Refer to a manual for open() for details. | ||
76 | Currently only O_CLOEXEC is supported. All other fields must be set to zero. | ||
77 | In the case of multi-planar API, every plane is exported separately using | ||
78 | multiple <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 | ||
82 | descriptor. The application may pass it to other DMABUF-aware devices. Refer to | ||
83 | <link linkend="dmabuf">DMABUF importing</link> for details about importing | ||
84 | DMABUF files into V4L2 nodes. It is recommended to close a DMABUF file when it | ||
85 | is 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> | ||
95 | int buffer_export(int v4lfd, &v4l2-buf-type; bt, int index, int *dmafd) | ||
96 | { | ||
97 | &v4l2-exportbuffer; expbuf; | ||
98 | |||
99 | memset(&expbuf, 0, sizeof(expbuf)); | ||
100 | expbuf.type = bt; | ||
101 | expbuf.index = index; | ||
102 | if (ioctl(v4lfd, &VIDIOC-EXPBUF;, &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> | ||
117 | int 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 < n_planes; ++i) { | ||
123 | &v4l2-exportbuffer; expbuf; | ||
124 | |||
125 | memset(&expbuf, 0, sizeof(expbuf)); | ||
126 | expbuf.type = bt; | ||
127 | expbuf.index = index; | ||
128 | expbuf.plane = i; | ||
129 | if (ioctl(v4lfd, &VIDIOC-EXPBUF;, &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 | ||
157 | linkend="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 | ||
163 | only used for <link linkend="mmap">memory mapping</link> I/O and can range from | ||
164 | zero 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 | ||
171 | multi-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> | ||
177 | O_CLOEXEC </constant> is supported, refer to the manual of open() for more | ||
178 | details.</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 | ||
204 | supported 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> | ||