vidioc-create-bufs.xml 4.6 KB

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