Path: blob/master/Documentation/DocBook/v4l/func-ioctl.xml
10821 views
<refentry id="func-ioctl">1<refmeta>2<refentrytitle>V4L2 ioctl()</refentrytitle>3&manvol;4</refmeta>56<refnamediv>7<refname>v4l2-ioctl</refname>8<refpurpose>Program a V4L2 device</refpurpose>9</refnamediv>1011<refsynopsisdiv>12<funcsynopsis>13<funcsynopsisinfo>#include <sys/ioctl.h></funcsynopsisinfo>14<funcprototype>15<funcdef>int <function>ioctl</function></funcdef>16<paramdef>int <parameter>fd</parameter></paramdef>17<paramdef>int <parameter>request</parameter></paramdef>18<paramdef>void *<parameter>argp</parameter></paramdef>19</funcprototype>20</funcsynopsis>21</refsynopsisdiv>2223<refsect1>24<title>Arguments</title>2526<variablelist>27<varlistentry>28<term><parameter>fd</parameter></term>29<listitem>30<para>&fd;</para>31</listitem>32</varlistentry>33<varlistentry>34<term><parameter>request</parameter></term>35<listitem>36<para>V4L2 ioctl request code as defined in the <filename>videodev2.h</filename> header file, for example37VIDIOC_QUERYCAP.</para>38</listitem>39</varlistentry>40<varlistentry>41<term><parameter>argp</parameter></term>42<listitem>43<para>Pointer to a function parameter, usually a structure.</para>44</listitem>45</varlistentry>46</variablelist>47</refsect1>4849<refsect1>50<title>Description</title>5152<para>The <function>ioctl()</function> function is used to program53V4L2 devices. The argument <parameter>fd</parameter> must be an open54file descriptor. An ioctl <parameter>request</parameter> has encoded55in it whether the argument is an input, output or read/write56parameter, and the size of the argument <parameter>argp</parameter> in57bytes. Macros and defines specifying V4L2 ioctl requests are located58in the <filename>videodev2.h</filename> header file.59Applications should use their own copy, not include the version in the60kernel sources on the system they compile on. All V4L2 ioctl requests,61their respective function and parameters are specified in <xref62linkend="user-func" />.</para>63</refsect1>6465<refsect1>66<title>Return Value</title>6768<para>On success the <function>ioctl()</function> function returns69<returnvalue>0</returnvalue> and does not reset the70<varname>errno</varname> variable. On failure71<returnvalue>-1</returnvalue> is returned, when the ioctl takes an72output or read/write parameter it remains unmodified, and the73<varname>errno</varname> variable is set appropriately. See below for74possible error codes. Generic errors like <errorcode>EBADF</errorcode>75or <errorcode>EFAULT</errorcode> are not listed in the sections76discussing individual ioctl requests.</para>77<para>Note ioctls may return undefined error codes. Since errors78may have side effects such as a driver reset applications should79abort on unexpected errors.</para>8081<variablelist>82<varlistentry>83<term><errorcode>EBADF</errorcode></term>84<listitem>85<para><parameter>fd</parameter> is not a valid open file86descriptor.</para>87</listitem>88</varlistentry>89<varlistentry>90<term><errorcode>EBUSY</errorcode></term>91<listitem>92<para>The property cannot be changed right now. Typically93this error code is returned when I/O is in progress or the driver94supports multiple opens and another process locked the property.</para>95</listitem>96</varlistentry>97<varlistentry>98<term><errorcode>EFAULT</errorcode></term>99<listitem>100<para><parameter>argp</parameter> references an inaccessible101memory area.</para>102</listitem>103</varlistentry>104<varlistentry>105<term><errorcode>ENOTTY</errorcode></term>106<listitem>107<para><parameter>fd</parameter> is not associated with a108character special device.</para>109</listitem>110</varlistentry>111<varlistentry>112<term><errorcode>EINVAL</errorcode></term>113<listitem>114<para>The <parameter>request</parameter> or the data pointed115to by <parameter>argp</parameter> is not valid. This is a very common116error code, see the individual ioctl requests listed in <xref117linkend="user-func" /> for actual causes.</para>118</listitem>119</varlistentry>120<varlistentry>121<term><errorcode>ENOMEM</errorcode></term>122<listitem>123<para>Not enough physical or virtual memory was available to124complete the request.</para>125</listitem>126</varlistentry>127<varlistentry>128<term><errorcode>ERANGE</errorcode></term>129<listitem>130<para>The application attempted to set a control with the131&VIDIOC-S-CTRL; ioctl to a value which is out of bounds.</para>132</listitem>133</varlistentry>134</variablelist>135</refsect1>136</refentry>137138<!--139Local Variables:140mode: sgml141sgml-parent-document: "v4l2.sgml"142indent-tabs-mode: nil143End:144-->145146147