Merge branch 'timers-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[pandora-kernel.git] / Documentation / DocBook / v4l / func-ioctl.xml
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
38 VIDIOC_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
54 V4L2 devices. The argument <parameter>fd</parameter> must be an open
55 file descriptor. An ioctl <parameter>request</parameter> has encoded
56 in it whether the argument is an input, output or read/write
57 parameter, and the size of the argument <parameter>argp</parameter> in
58 bytes. Macros and defines specifying V4L2 ioctl requests are located
59 in the <filename>videodev2.h</filename> header file.
60 Applications should use their own copy, not include the version in the
61 kernel sources on the system they compile on. All V4L2 ioctl requests,
62 their 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
73 output or read/write parameter it remains unmodified, and the
74 <varname>errno</varname> variable is set appropriately. See below for
75 possible error codes. Generic errors like <errorcode>EBADF</errorcode>
76 or <errorcode>EFAULT</errorcode> are not listed in the sections
77 discussing individual ioctl requests.</para>
78     <para>Note ioctls may return undefined error codes. Since errors
79 may have side effects such as a driver reset applications should
80 abort 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
87 descriptor.</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
94 this error code is returned when I/O is in progress or the driver
95 supports 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
102 memory 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
109 character 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
116 to by <parameter>argp</parameter> is not valid. This is a very common
117 error 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
125 complete 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 <!--
140 Local Variables:
141 mode: sgml
142 sgml-parent-document: "v4l2.sgml"
143 indent-tabs-mode: nil
144 End:
145 -->