vidioc-create-bufs.xml 5.3 KB

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