Merge branches 'amba', 'fixes', 'misc' and 'tauros2' into for-next
[sfrench/cifs-2.6.git] / Documentation / DocBook / media / v4l / vidioc-create-bufs.xml
1 <refentry id="vidioc-create-bufs">
2   <refmeta>
3     <refentrytitle>ioctl VIDIOC_CREATE_BUFS</refentrytitle>
4     &manvol;
5   </refmeta>
6
7   <refnamediv>
8     <refname>VIDIOC_CREATE_BUFS</refname>
9     <refpurpose>Create buffers for Memory Mapped or User Pointer or DMA Buffer
10     I/O</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_create_buffers *<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_CREATE_BUFS</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 used to create buffers for <link linkend="mmap">memory
59 mapped</link> or <link linkend="userp">user pointer</link> or <link
60 linkend="dmabuf">DMA buffer</link> I/O. It can be used as an alternative or in
61 addition to the &VIDIOC-REQBUFS; ioctl, when a tighter
62 control over buffers is required. This ioctl can be called multiple times to
63 create buffers of different sizes.</para>
64
65     <para>To allocate the device buffers applications must initialize the
66 relevant fields of the <structname>v4l2_create_buffers</structname> structure.
67 The <structfield>count</structfield> field must be set to the number of
68 requested buffers, the <structfield>memory</structfield> field specifies the
69 requested I/O method and the <structfield>reserved</structfield> array must be
70 zeroed.</para>
71
72     <para>The <structfield>format</structfield> field specifies the image format
73 that the buffers must be able to handle. The application has to fill in this
74 &v4l2-format;. Usually this will be done using the &VIDIOC-TRY-FMT; or &VIDIOC-G-FMT; ioctls
75 to ensure that the requested format is supported by the driver.
76 Based on the format's <structfield>type</structfield> field the requested buffer
77 size (for single-planar) or plane sizes (for multi-planar formats) will be
78 used for the allocated buffers. The driver may return an error if the size(s)
79 are not supported by the hardware (usually because they are too small).</para>
80
81     <para>The buffers created by this ioctl will have as minimum size the size
82 defined by the <structfield>format.pix.sizeimage</structfield> field (or the
83 corresponding fields for other format types). Usually if the
84 <structfield>format.pix.sizeimage</structfield> field is less than the minimum
85 required for the given format, then an error will be returned since drivers will
86 typically not allow this. If it is larger, then the value will be used as-is.
87 In other words, the driver may reject the requested size, but if it is accepted
88 the driver will use it unchanged.</para>
89
90     <para>When the ioctl is called with a pointer to this structure the driver
91 will attempt to allocate up to the requested number of buffers and store the
92 actual number allocated and the starting index in the
93 <structfield>count</structfield> and the <structfield>index</structfield> fields
94 respectively. On return <structfield>count</structfield> can be smaller than
95 the number requested.</para>
96
97     <table pgwide="1" frame="none" id="v4l2-create-buffers">
98       <title>struct <structname>v4l2_create_buffers</structname></title>
99       <tgroup cols="3">
100         &cs-str;
101         <tbody valign="top">
102           <row>
103             <entry>__u32</entry>
104             <entry><structfield>index</structfield></entry>
105             <entry>The starting buffer index, returned by the driver.</entry>
106           </row>
107           <row>
108             <entry>__u32</entry>
109             <entry><structfield>count</structfield></entry>
110             <entry>The number of buffers requested or granted. If count == 0, then
111             <constant>VIDIOC_CREATE_BUFS</constant> will set <structfield>index</structfield>
112             to the current number of created buffers, and it will check the validity of
113             <structfield>memory</structfield> and <structfield>format.type</structfield>.
114             If those are invalid -1 is returned and errno is set to &EINVAL;,
115             otherwise <constant>VIDIOC_CREATE_BUFS</constant> returns 0. It will
116             never set errno to &EBUSY; in this particular case.</entry>
117           </row>
118           <row>
119             <entry>__u32</entry>
120             <entry><structfield>memory</structfield></entry>
121             <entry>Applications set this field to
122 <constant>V4L2_MEMORY_MMAP</constant>,
123 <constant>V4L2_MEMORY_DMABUF</constant> or
124 <constant>V4L2_MEMORY_USERPTR</constant>. See <xref linkend="v4l2-memory"
125 /></entry>
126           </row>
127           <row>
128             <entry>&v4l2-format;</entry>
129             <entry><structfield>format</structfield></entry>
130             <entry>Filled in by the application, preserved by the driver.</entry>
131           </row>
132           <row>
133             <entry>__u32</entry>
134             <entry><structfield>reserved</structfield>[8]</entry>
135             <entry>A place holder for future extensions. Drivers and applications
136 must set the array to zero.</entry>
137           </row>
138         </tbody>
139       </tgroup>
140     </table>
141   </refsect1>
142
143   <refsect1>
144     &return-value;
145
146     <variablelist>
147       <varlistentry>
148         <term><errorcode>ENOMEM</errorcode></term>
149         <listitem>
150           <para>No memory to allocate buffers for <link linkend="mmap">memory
151 mapped</link> I/O.</para>
152         </listitem>
153       </varlistentry>
154       <varlistentry>
155         <term><errorcode>EINVAL</errorcode></term>
156         <listitem>
157           <para>The buffer type (<structfield>format.type</structfield> field),
158 requested I/O method (<structfield>memory</structfield>) or format
159 (<structfield>format</structfield> field) is not valid.</para>
160         </listitem>
161       </varlistentry>
162     </variablelist>
163   </refsect1>
164 </refentry>