vidioc-create-bufs.xml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <refentry id="vidioc-create-bufs">
  2. <refmeta>
  3. <refentrytitle>ioctl VIDIOC_CREATE_BUFS</refentrytitle>
  4. &manvol;
  5. </refmeta>
  6. <refnamediv>
  7. <refname>VIDIOC_CREATE_BUFS</refname>
  8. <refpurpose>Create buffers for Memory Mapped or User Pointer or DMA Buffer
  9. I/O</refpurpose>
  10. </refnamediv>
  11. <refsynopsisdiv>
  12. <funcsynopsis>
  13. <funcprototype>
  14. <funcdef>int <function>ioctl</function></funcdef>
  15. <paramdef>int <parameter>fd</parameter></paramdef>
  16. <paramdef>int <parameter>request</parameter></paramdef>
  17. <paramdef>struct v4l2_create_buffers *<parameter>argp</parameter></paramdef>
  18. </funcprototype>
  19. </funcsynopsis>
  20. </refsynopsisdiv>
  21. <refsect1>
  22. <title>Arguments</title>
  23. <variablelist>
  24. <varlistentry>
  25. <term><parameter>fd</parameter></term>
  26. <listitem>
  27. <para>&fd;</para>
  28. </listitem>
  29. </varlistentry>
  30. <varlistentry>
  31. <term><parameter>request</parameter></term>
  32. <listitem>
  33. <para>VIDIOC_CREATE_BUFS</para>
  34. </listitem>
  35. </varlistentry>
  36. <varlistentry>
  37. <term><parameter>argp</parameter></term>
  38. <listitem>
  39. <para></para>
  40. </listitem>
  41. </varlistentry>
  42. </variablelist>
  43. </refsect1>
  44. <refsect1>
  45. <title>Description</title>
  46. <note>
  47. <title>Experimental</title>
  48. <para>This is an <link linkend="experimental"> experimental </link>
  49. interface and may change in the future.</para>
  50. </note>
  51. <para>This ioctl is used to create buffers for <link linkend="mmap">memory
  52. mapped</link> or <link linkend="userp">user pointer</link> or <link
  53. linkend="dmabuf">DMA buffer</link> I/O. It can be used as an alternative or in
  54. addition to the <constant>VIDIOC_REQBUFS</constant> ioctl, when a tighter
  55. control over buffers is required. This ioctl can be called multiple times to
  56. create buffers of different sizes.</para>
  57. <para>To allocate the device buffers applications must initialize the
  58. relevant fields of the <structname>v4l2_create_buffers</structname> structure.
  59. The <structfield>count</structfield> field must be set to the number of
  60. requested buffers, the <structfield>memory</structfield> field specifies the
  61. requested I/O method and the <structfield>reserved</structfield> array must be
  62. zeroed.</para>
  63. <para>The <structfield>format</structfield> field specifies the image format
  64. that the buffers must be able to handle. The application has to fill in this
  65. &v4l2-format;. Usually this will be done using the
  66. <constant>VIDIOC_TRY_FMT</constant> or <constant>VIDIOC_G_FMT</constant> ioctl()
  67. to ensure that the requested format is supported by the driver. Unsupported
  68. formats will result in an error.</para>
  69. <para>The buffers created by this ioctl will have as minimum size the size
  70. defined by the <structfield>format.pix.sizeimage</structfield> field. If the
  71. <structfield>format.pix.sizeimage</structfield> field is less than the minimum
  72. required for the given format, then <structfield>sizeimage</structfield> will be
  73. increased by the driver to that minimum to allocate the buffers. If it is
  74. larger, then the value will be used as-is. The same applies to the
  75. <structfield>sizeimage</structfield> field of the
  76. <structname>v4l2_plane_pix_format</structname> structure in the case of
  77. multiplanar formats.</para>
  78. <para>When the ioctl is called with a pointer to this structure the driver
  79. will attempt to allocate up to the requested number of buffers and store the
  80. actual number allocated and the starting index in the
  81. <structfield>count</structfield> and the <structfield>index</structfield> fields
  82. respectively. On return <structfield>count</structfield> can be smaller than
  83. the number requested. The driver may also increase buffer sizes if required,
  84. however, it will not update <structfield>sizeimage</structfield> field values.
  85. The user has to use <constant>VIDIOC_QUERYBUF</constant> to retrieve that
  86. information.</para>
  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>
  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>
  107. </row>
  108. <row>
  109. <entry>__u32</entry>
  110. <entry><structfield>memory</structfield></entry>
  111. <entry>Applications set this field to
  112. <constant>V4L2_MEMORY_MMAP</constant>,
  113. <constant>V4L2_MEMORY_DMABUF</constant> or
  114. <constant>V4L2_MEMORY_USERPTR</constant>. See <xref linkend="v4l2-memory"
  115. /></entry>
  116. </row>
  117. <row>
  118. <entry>&v4l2-format;</entry>
  119. <entry><structfield>format</structfield></entry>
  120. <entry>Filled in by the application, preserved by the driver.</entry>
  121. </row>
  122. <row>
  123. <entry>__u32</entry>
  124. <entry><structfield>reserved</structfield>[8]</entry>
  125. <entry>A place holder for future extensions. Drivers and applications
  126. must set the array to zero.</entry>
  127. </row>
  128. </tbody>
  129. </tgroup>
  130. </table>
  131. </refsect1>
  132. <refsect1>
  133. &return-value;
  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>format.type</structfield> field),
  146. requested I/O method (<structfield>memory</structfield>) or format
  147. (<structfield>format</structfield> field) is not valid.</para>
  148. </listitem>
  149. </varlistentry>
  150. </variablelist>
  151. </refsect1>
  152. </refentry>