func-ioctl.xml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <refentry id="func-ioctl">
  2. <refmeta>
  3. <refentrytitle>V4L2 ioctl()</refentrytitle>
  4. &manvol;
  5. </refmeta>
  6. <refnamediv>
  7. <refname>v4l2-ioctl</refname>
  8. <refpurpose>Program a V4L2 device</refpurpose>
  9. </refnamediv>
  10. <refsynopsisdiv>
  11. <funcsynopsis>
  12. <funcsynopsisinfo>#include &lt;sys/ioctl.h&gt;</funcsynopsisinfo>
  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>void *<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>V4L2 ioctl request code as defined in the <filename>videodev2.h</filename> header file, for example
  34. VIDIOC_QUERYCAP.</para>
  35. </listitem>
  36. </varlistentry>
  37. <varlistentry>
  38. <term><parameter>argp</parameter></term>
  39. <listitem>
  40. <para>Pointer to a function parameter, usually a structure.</para>
  41. </listitem>
  42. </varlistentry>
  43. </variablelist>
  44. </refsect1>
  45. <refsect1>
  46. <title>Description</title>
  47. <para>The <function>ioctl()</function> function is used to program
  48. V4L2 devices. The argument <parameter>fd</parameter> must be an open
  49. file descriptor. An ioctl <parameter>request</parameter> has encoded
  50. in it whether the argument is an input, output or read/write
  51. parameter, and the size of the argument <parameter>argp</parameter> in
  52. bytes. Macros and defines specifying V4L2 ioctl requests are located
  53. in the <filename>videodev2.h</filename> header file.
  54. Applications should use their own copy, not include the version in the
  55. kernel sources on the system they compile on. All V4L2 ioctl requests,
  56. their respective function and parameters are specified in <xref
  57. linkend="user-func" />.</para>
  58. </refsect1>
  59. <refsect1>
  60. <title>Return Value</title>
  61. <para>On success the <function>ioctl()</function> function returns
  62. <returnvalue>0</returnvalue> and does not reset the
  63. <varname>errno</varname> variable. On failure
  64. <returnvalue>-1</returnvalue> is returned, when the ioctl takes an
  65. output or read/write parameter it remains unmodified, and the
  66. <varname>errno</varname> variable is set appropriately. See below for
  67. possible error codes. Generic errors like <errorcode>EBADF</errorcode>
  68. or <errorcode>EFAULT</errorcode> are not listed in the sections
  69. discussing individual ioctl requests.</para>
  70. <para>Note ioctls may return undefined error codes. Since errors
  71. may have side effects such as a driver reset applications should
  72. abort on unexpected errors.</para>
  73. <variablelist>
  74. <varlistentry>
  75. <term><errorcode>EBADF</errorcode></term>
  76. <listitem>
  77. <para><parameter>fd</parameter> is not a valid open file
  78. descriptor.</para>
  79. </listitem>
  80. </varlistentry>
  81. <varlistentry>
  82. <term><errorcode>EBUSY</errorcode></term>
  83. <listitem>
  84. <para>The property cannot be changed right now. Typically
  85. this error code is returned when I/O is in progress or the driver
  86. supports multiple opens and another process locked the property.</para>
  87. </listitem>
  88. </varlistentry>
  89. <varlistentry>
  90. <term><errorcode>EFAULT</errorcode></term>
  91. <listitem>
  92. <para><parameter>argp</parameter> references an inaccessible
  93. memory area.</para>
  94. </listitem>
  95. </varlistentry>
  96. <varlistentry>
  97. <term><errorcode>ENOTTY</errorcode></term>
  98. <listitem>
  99. <para><parameter>fd</parameter> is not associated with a
  100. character special device.</para>
  101. </listitem>
  102. </varlistentry>
  103. <varlistentry>
  104. <term><errorcode>EINVAL</errorcode></term>
  105. <listitem>
  106. <para>The <parameter>request</parameter> or the data pointed
  107. to by <parameter>argp</parameter> is not valid. This is a very common
  108. error code, see the individual ioctl requests listed in <xref
  109. linkend="user-func" /> for actual causes.</para>
  110. </listitem>
  111. </varlistentry>
  112. <varlistentry>
  113. <term><errorcode>ENOMEM</errorcode></term>
  114. <listitem>
  115. <para>Not enough physical or virtual memory was available to
  116. complete the request.</para>
  117. </listitem>
  118. </varlistentry>
  119. <varlistentry>
  120. <term><errorcode>ERANGE</errorcode></term>
  121. <listitem>
  122. <para>The application attempted to set a control with the
  123. &VIDIOC-S-CTRL; ioctl to a value which is out of bounds.</para>
  124. </listitem>
  125. </varlistentry>
  126. </variablelist>
  127. </refsect1>
  128. </refentry>
  129. <!--
  130. Local Variables:
  131. mode: sgml
  132. sgml-parent-document: "v4l2.sgml"
  133. indent-tabs-mode: nil
  134. End:
  135. -->