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 52mapped</link> or <link linkend="userp">user pointer</link> 53I/O. Memory mapped buffers are located in device memory and must be 54allocated with this ioctl before they can be mapped into the 55application's address space. User buffers are allocated by 56applications themselves, and this ioctl is merely used to switch the 57driver into user pointer I/O mode and to setup some internal structures.</para> 58 59 <para>To allocate device buffers applications initialize all 60fields of the <structname>v4l2_requestbuffers</structname> structure. 61They set the <structfield>type</structfield> field to the respective 62stream or buffer type, the <structfield>count</structfield> field to 63the desired number of buffers, <structfield>memory</structfield> 64must be set to the requested I/O method and the <structfield>reserved</structfield> array 65must be zeroed. When the ioctl 66is called with a pointer to this structure the driver will attempt to allocate 67the requested number of buffers and it stores the actual number 68allocated in the <structfield>count</structfield> field. It can be 69smaller than the number requested, even zero, when the driver runs out 70of free memory. A larger number is also possible when the driver requires 71more buffers to function correctly. For example video output requires at least two buffers, 72one displayed and one filled by the application.</para> 73 <para>When the I/O method is not supported the ioctl 74returns an &EINVAL;.</para> 75 76 <para>Applications can call <constant>VIDIOC_REQBUFS</constant> 77again to change the number of buffers, however this cannot succeed 78when any buffers are still mapped. A <structfield>count</structfield> 79value of zero frees all buffers, after aborting or finishing any DMA 80in progress, an implicit &VIDIOC-STREAMOFF;. <!-- mhs: I see no 81reason why munmap()ping one or even all buffers must imply 82streamoff.--></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 98as 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 113higher. 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 128in progress, or reallocation of buffers was attempted although one or 129more 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 136requested I/O method (<structfield>memory</structfield>) is not 137supported.</para> 138 </listitem> 139 </varlistentry> 140 </variablelist> 141 </refsect1> 142</refentry> 143 144<!-- 145Local Variables: 146mode: sgml 147sgml-parent-document: "v4l2.sgml" 148indent-tabs-mode: nil 149End: 150--> 151