vidioc-create-bufs.xml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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 device buffers applications initialize relevant fields of
  58. the <structname>v4l2_create_buffers</structname> structure. They set the
  59. <structfield>type</structfield> field in the
  60. &v4l2-format; structure, embedded in this
  61. structure, to the respective stream or buffer type.
  62. <structfield>count</structfield> must be set to the number of required buffers.
  63. <structfield>memory</structfield> specifies the required I/O method. The
  64. <structfield>format</structfield> field shall typically be filled in using
  65. either the <constant>VIDIOC_TRY_FMT</constant> or
  66. <constant>VIDIOC_G_FMT</constant> ioctl(). Additionally, applications can adjust
  67. <structfield>sizeimage</structfield> fields to fit their specific needs. The
  68. <structfield>reserved</structfield> array must be zeroed.</para>
  69. <para>When the ioctl is called with a pointer to this structure the driver
  70. will attempt to allocate up to the requested number of buffers and store the
  71. actual number allocated and the starting index in the
  72. <structfield>count</structfield> and the <structfield>index</structfield> fields
  73. respectively. On return <structfield>count</structfield> can be smaller than
  74. the number requested. The driver may also increase buffer sizes if required,
  75. however, it will not update <structfield>sizeimage</structfield> field values.
  76. The user has to use <constant>VIDIOC_QUERYBUF</constant> to retrieve that
  77. information.</para>
  78. <table pgwide="1" frame="none" id="v4l2-create-buffers">
  79. <title>struct <structname>v4l2_create_buffers</structname></title>
  80. <tgroup cols="3">
  81. &cs-str;
  82. <tbody valign="top">
  83. <row>
  84. <entry>__u32</entry>
  85. <entry><structfield>index</structfield></entry>
  86. <entry>The starting buffer index, returned by the driver.</entry>
  87. </row>
  88. <row>
  89. <entry>__u32</entry>
  90. <entry><structfield>count</structfield></entry>
  91. <entry>The number of buffers requested or granted. If count == 0, then
  92. <constant>VIDIOC_CREATE_BUFS</constant> will set <structfield>index</structfield>
  93. to the current number of created buffers, and it will check the validity of
  94. <structfield>memory</structfield> and <structfield>format.type</structfield>.
  95. If those are invalid -1 is returned and errno is set to &EINVAL;,
  96. otherwise <constant>VIDIOC_CREATE_BUFS</constant> returns 0. It will
  97. never set errno to &EBUSY; in this particular case.</entry>
  98. </row>
  99. <row>
  100. <entry>__u32</entry>
  101. <entry><structfield>memory</structfield></entry>
  102. <entry>Applications set this field to
  103. <constant>V4L2_MEMORY_MMAP</constant>,
  104. <constant>V4L2_MEMORY_DMABUF</constant> or
  105. <constant>V4L2_MEMORY_USERPTR</constant>. See <xref linkend="v4l2-memory"
  106. /></entry>
  107. </row>
  108. <row>
  109. <entry>&v4l2-format;</entry>
  110. <entry><structfield>format</structfield></entry>
  111. <entry>Filled in by the application, preserved by the driver.</entry>
  112. </row>
  113. <row>
  114. <entry>__u32</entry>
  115. <entry><structfield>reserved</structfield>[8]</entry>
  116. <entry>A place holder for future extensions.</entry>
  117. </row>
  118. </tbody>
  119. </tgroup>
  120. </table>
  121. </refsect1>
  122. <refsect1>
  123. &return-value;
  124. <variablelist>
  125. <varlistentry>
  126. <term><errorcode>ENOMEM</errorcode></term>
  127. <listitem>
  128. <para>No memory to allocate buffers for <link linkend="mmap">memory
  129. mapped</link> I/O.</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>