func-ioctl.xml 4.6 KB

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