Based on kernel version 3.0.4. Page generated on 2011-10-03 22:07 EST.
1 <refentry id="vidioc-reqbufs"> 2 <refmeta> 3 <refentrytitle>ioctl VIDIOC_REQBUFS</refentrytitle> 4 &manvol; 5 </refmeta> 6 7 <refnamediv> 8 <refname>VIDIOC_REQBUFS</refname> 9 <refpurpose>Initiate Memory Mapping 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_requestbuffers *<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_REQBUFS</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 51 <para>This ioctl is used to initiate <link linkend="mmap">memory 52 mapped</link> or <link linkend="userp">user pointer</link> 53 I/O. Memory mapped buffers are located in device memory and must be 54 allocated with this ioctl before they can be mapped into the 55 application's address space. User buffers are allocated by 56 applications themselves, and this ioctl is merely used to switch the 57 driver into user pointer I/O mode and to setup some internal structures.</para> 58 59 <para>To allocate device buffers applications initialize all 60 fields of the <structname>v4l2_requestbuffers</structname> structure. 61 They set the <structfield>type</structfield> field to the respective 62 stream or buffer type, the <structfield>count</structfield> field to 63 the desired number of buffers, <structfield>memory</structfield> 64 must be set to the requested I/O method and the <structfield>reserved</structfield> array 65 must be zeroed. When the ioctl 66 is called with a pointer to this structure the driver will attempt to allocate 67 the requested number of buffers and it stores the actual number 68 allocated in the <structfield>count</structfield> field. It can be 69 smaller than the number requested, even zero, when the driver runs out 70 of free memory. A larger number is also possible when the driver requires 71 more buffers to function correctly. For example video output requires at least two buffers, 72 one displayed and one filled by the application.</para> 73 <para>When the I/O method is not supported the ioctl 74 returns an &EINVAL;.</para> 75 76 <para>Applications can call <constant>VIDIOC_REQBUFS</constant> 77 again to change the number of buffers, however this cannot succeed 78 when any buffers are still mapped. A <structfield>count</structfield> 79 value of zero frees all buffers, after aborting or finishing any DMA 80 in progress, an implicit &VIDIOC-STREAMOFF;. <!-- mhs: I see no 81 reason why munmap()ping one or even all buffers must imply 82 streamoff.--></para> 83 84 <table pgwide="1" frame="none" id="v4l2-requestbuffers"> 85 <title>struct <structname>v4l2_requestbuffers</structname></title> 86 <tgroup cols="3"> 87 &cs-str; 88 <tbody valign="top"> 89 <row> 90 <entry>__u32</entry> 91 <entry><structfield>count</structfield></entry> 92 <entry>The number of buffers requested or granted.</entry> 93 </row> 94 <row> 95 <entry>&v4l2-buf-type;</entry> 96 <entry><structfield>type</structfield></entry> 97 <entry>Type of the stream or buffers, this is the same 98 as the &v4l2-format; <structfield>type</structfield> field. See <xref 99 linkend="v4l2-buf-type" /> for valid values.</entry> 100 </row> 101 <row> 102 <entry>&v4l2-memory;</entry> 103 <entry><structfield>memory</structfield></entry> 104 <entry>Applications set this field to 105 <constant>V4L2_MEMORY_MMAP</constant> or 106 <constant>V4L2_MEMORY_USERPTR</constant>.</entry> 107 </row> 108 <row> 109 <entry>__u32</entry> 110 <entry><structfield>reserved</structfield>[2]</entry> 111 <entry>A place holder for future extensions and custom 112 (driver defined) buffer types <constant>V4L2_BUF_TYPE_PRIVATE</constant> and 113 higher. This array should be zeroed by applications.</entry> 114 </row> 115 </tbody> 116 </tgroup> 117 </table> 118 </refsect1> 119 120 <refsect1> 121 &return-value; 122 123 <variablelist> 124 <varlistentry> 125 <term><errorcode>EBUSY</errorcode></term> 126 <listitem> 127 <para>The driver supports multiple opens and I/O is already 128 in progress, or reallocation of buffers was attempted although one or 129 more are still mapped.</para> 130 </listitem> 131 </varlistentry> 132 <varlistentry> 133 <term><errorcode>EINVAL</errorcode></term> 134 <listitem> 135 <para>The buffer type (<structfield>type</structfield> field) or the 136 requested I/O method (<structfield>memory</structfield>) is not 137 supported.</para> 138 </listitem> 139 </varlistentry> 140 </variablelist> 141 </refsect1> 142 </refentry> 143 144 <!-- 145 Local Variables: 146 mode: sgml 147 sgml-parent-document: "v4l2.sgml" 148 indent-tabs-mode: nil 149 End: 150 -->