1 <refentry id="func-ioctl">
3 <refentrytitle>V4L2 ioctl()</refentrytitle>
8 <refname>v4l2-ioctl</refname>
9 <refpurpose>Program a V4L2 device</refpurpose>
14 <funcsynopsisinfo>#include <sys/ioctl.h></funcsynopsisinfo>
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>
25 <title>Arguments</title>
29 <term><parameter>fd</parameter></term>
35 <term><parameter>request</parameter></term>
37 <para>V4L2 ioctl request code as defined in the <filename>videodev2.h</filename> header file, for example
38 VIDIOC_QUERYCAP.</para>
42 <term><parameter>argp</parameter></term>
44 <para>Pointer to a function parameter, usually a structure.</para>
51 <title>Description</title>
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>
67 <title>Return Value</title>
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>
84 <term><errorcode>EBADF</errorcode></term>
86 <para><parameter>fd</parameter> is not a valid open file
91 <term><errorcode>EBUSY</errorcode></term>
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>
99 <term><errorcode>EFAULT</errorcode></term>
101 <para><parameter>argp</parameter> references an inaccessible
106 <term><errorcode>ENOTTY</errorcode></term>
108 <para><parameter>fd</parameter> is not associated with a
109 character special device.</para>
113 <term><errorcode>EINVAL</errorcode></term>
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>
122 <term><errorcode>ENOMEM</errorcode></term>
124 <para>Not enough physical or virtual memory was available to
125 complete the request.</para>
129 <term><errorcode>ERANGE</errorcode></term>
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>
142 sgml-parent-document: "v4l2.sgml"
143 indent-tabs-mode: nil