Guennadi Liakhovetski | 5509328 | 2011-09-28 08:10:58 -0300 | [diff] [blame] | 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 I/O</refpurpose> |
| 10 | </refnamediv> |
| 11 | |
| 12 | <refsynopsisdiv> |
| 13 | <funcsynopsis> |
| 14 | <funcprototype> |
| 15 | <funcdef>int <function>ioctl</function></funcdef> |
| 16 | <paramdef>int <parameter>fd</parameter></paramdef> |
| 17 | <paramdef>int <parameter>request</parameter></paramdef> |
| 18 | <paramdef>struct v4l2_create_buffers *<parameter>argp</parameter></paramdef> |
| 19 | </funcprototype> |
| 20 | </funcsynopsis> |
| 21 | </refsynopsisdiv> |
| 22 | |
| 23 | <refsect1> |
| 24 | <title>Arguments</title> |
| 25 | |
| 26 | <variablelist> |
| 27 | <varlistentry> |
| 28 | <term><parameter>fd</parameter></term> |
| 29 | <listitem> |
| 30 | <para>&fd;</para> |
| 31 | </listitem> |
| 32 | </varlistentry> |
| 33 | <varlistentry> |
| 34 | <term><parameter>request</parameter></term> |
| 35 | <listitem> |
| 36 | <para>VIDIOC_CREATE_BUFS</para> |
| 37 | </listitem> |
| 38 | </varlistentry> |
| 39 | <varlistentry> |
| 40 | <term><parameter>argp</parameter></term> |
| 41 | <listitem> |
| 42 | <para></para> |
| 43 | </listitem> |
| 44 | </varlistentry> |
| 45 | </variablelist> |
| 46 | </refsect1> |
| 47 | |
| 48 | <refsect1> |
| 49 | <title>Description</title> |
| 50 | |
Hans Verkuil | 7dcc606 | 2012-05-15 08:04:28 -0300 | [diff] [blame] | 51 | <note> |
| 52 | <title>Experimental</title> |
| 53 | <para>This is an <link linkend="experimental"> experimental </link> |
| 54 | interface and may change in the future.</para> |
| 55 | </note> |
| 56 | |
Guennadi Liakhovetski | 5509328 | 2011-09-28 08:10:58 -0300 | [diff] [blame] | 57 | <para>This ioctl is used to create buffers for <link linkend="mmap">memory |
| 58 | mapped</link> or <link linkend="userp">user pointer</link> |
| 59 | I/O. It can be used as an alternative or in addition to the |
| 60 | <constant>VIDIOC_REQBUFS</constant> ioctl, when a tighter control over buffers |
| 61 | is required. This ioctl can be called multiple times to create buffers of |
| 62 | different sizes.</para> |
| 63 | |
| 64 | <para>To allocate device buffers applications initialize relevant fields of |
| 65 | the <structname>v4l2_create_buffers</structname> structure. They set the |
| 66 | <structfield>type</structfield> field in the |
Nicolas THERY | 6992c08 | 2012-07-18 11:41:36 -0300 | [diff] [blame] | 67 | &v4l2-format; structure, embedded in this |
Guennadi Liakhovetski | 5509328 | 2011-09-28 08:10:58 -0300 | [diff] [blame] | 68 | structure, to the respective stream or buffer type. |
| 69 | <structfield>count</structfield> must be set to the number of required buffers. |
| 70 | <structfield>memory</structfield> specifies the required I/O method. The |
| 71 | <structfield>format</structfield> field shall typically be filled in using |
| 72 | either the <constant>VIDIOC_TRY_FMT</constant> or |
| 73 | <constant>VIDIOC_G_FMT</constant> ioctl(). Additionally, applications can adjust |
| 74 | <structfield>sizeimage</structfield> fields to fit their specific needs. The |
| 75 | <structfield>reserved</structfield> array must be zeroed.</para> |
| 76 | |
| 77 | <para>When the ioctl is called with a pointer to this structure the driver |
| 78 | will attempt to allocate up to the requested number of buffers and store the |
| 79 | actual number allocated and the starting index in the |
| 80 | <structfield>count</structfield> and the <structfield>index</structfield> fields |
| 81 | respectively. On return <structfield>count</structfield> can be smaller than |
| 82 | the number requested. The driver may also increase buffer sizes if required, |
| 83 | however, it will not update <structfield>sizeimage</structfield> field values. |
| 84 | The user has to use <constant>VIDIOC_QUERYBUF</constant> to retrieve that |
| 85 | information.</para> |
| 86 | |
| 87 | <table pgwide="1" frame="none" id="v4l2-create-buffers"> |
| 88 | <title>struct <structname>v4l2_create_buffers</structname></title> |
| 89 | <tgroup cols="3"> |
| 90 | &cs-str; |
| 91 | <tbody valign="top"> |
| 92 | <row> |
| 93 | <entry>__u32</entry> |
| 94 | <entry><structfield>index</structfield></entry> |
| 95 | <entry>The starting buffer index, returned by the driver.</entry> |
| 96 | </row> |
| 97 | <row> |
| 98 | <entry>__u32</entry> |
| 99 | <entry><structfield>count</structfield></entry> |
Hans Verkuil | 5d44f5e | 2012-06-22 05:47:30 -0300 | [diff] [blame] | 100 | <entry>The number of buffers requested or granted. If count == 0, then |
| 101 | <constant>VIDIOC_CREATE_BUFS</constant> will set <structfield>index</structfield> |
| 102 | to the current number of created buffers, and it will check the validity of |
| 103 | <structfield>memory</structfield> and <structfield>format.type</structfield>. |
| 104 | If those are invalid -1 is returned and errno is set to &EINVAL;, |
| 105 | otherwise <constant>VIDIOC_CREATE_BUFS</constant> returns 0. It will |
| 106 | never set errno to &EBUSY; in this particular case.</entry> |
Guennadi Liakhovetski | 5509328 | 2011-09-28 08:10:58 -0300 | [diff] [blame] | 107 | </row> |
| 108 | <row> |
Sakari Ailus | 6016af8 | 2012-05-10 02:02:07 -0300 | [diff] [blame] | 109 | <entry>__u32</entry> |
Guennadi Liakhovetski | 5509328 | 2011-09-28 08:10:58 -0300 | [diff] [blame] | 110 | <entry><structfield>memory</structfield></entry> |
| 111 | <entry>Applications set this field to |
| 112 | <constant>V4L2_MEMORY_MMAP</constant> or |
Sakari Ailus | 6016af8 | 2012-05-10 02:02:07 -0300 | [diff] [blame] | 113 | <constant>V4L2_MEMORY_USERPTR</constant>. See <xref linkend="v4l2-memory" |
| 114 | /></entry> |
Guennadi Liakhovetski | 5509328 | 2011-09-28 08:10:58 -0300 | [diff] [blame] | 115 | </row> |
| 116 | <row> |
Nicolas THERY | 6992c08 | 2012-07-18 11:41:36 -0300 | [diff] [blame] | 117 | <entry>&v4l2-format;</entry> |
Guennadi Liakhovetski | 5509328 | 2011-09-28 08:10:58 -0300 | [diff] [blame] | 118 | <entry><structfield>format</structfield></entry> |
Sakari Ailus | af03891 | 2012-05-31 18:51:05 -0300 | [diff] [blame] | 119 | <entry>Filled in by the application, preserved by the driver.</entry> |
Guennadi Liakhovetski | 5509328 | 2011-09-28 08:10:58 -0300 | [diff] [blame] | 120 | </row> |
| 121 | <row> |
| 122 | <entry>__u32</entry> |
| 123 | <entry><structfield>reserved</structfield>[8]</entry> |
| 124 | <entry>A place holder for future extensions.</entry> |
| 125 | </row> |
| 126 | </tbody> |
| 127 | </tgroup> |
| 128 | </table> |
| 129 | </refsect1> |
| 130 | |
| 131 | <refsect1> |
| 132 | &return-value; |
| 133 | |
| 134 | <variablelist> |
| 135 | <varlistentry> |
| 136 | <term><errorcode>ENOMEM</errorcode></term> |
| 137 | <listitem> |
| 138 | <para>No memory to allocate buffers for <link linkend="mmap">memory |
| 139 | mapped</link> I/O.</para> |
| 140 | </listitem> |
| 141 | </varlistentry> |
| 142 | <varlistentry> |
| 143 | <term><errorcode>EINVAL</errorcode></term> |
| 144 | <listitem> |
| 145 | <para>The buffer type (<structfield>type</structfield> field) or the |
| 146 | requested I/O method (<structfield>memory</structfield>) is not |
| 147 | supported.</para> |
| 148 | </listitem> |
| 149 | </varlistentry> |
| 150 | </variablelist> |
| 151 | </refsect1> |
| 152 | </refentry> |