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