1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>V4L2 ioctl()</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="LINUX MEDIA INFRASTRUCTURE API"><link rel="up" href="user-func.html" title="Appendix A. Function Reference"><link rel="prev" href="func-close.html" title="V4L2 close()"><link rel="next" href="vidioc-create-bufs.html" title="ioctl VIDIOC_CREATE_BUFS"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">V4L2 ioctl()</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="func-close.html">Prev</a> </td><th width="60%" align="center">Appendix A. Function Reference</th><td width="20%" align="right"> <a accesskey="n" href="vidioc-create-bufs.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="func-ioctl"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>v4l2-ioctl — Program a V4L2 device</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include <sys/ioctl.h></pre><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">ioctl</b>(</code></td><td>int <var class="pdparam">fd</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">request</var>, </td></tr><tr><td> </td><td>void *<var class="pdparam">argp</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1"><a name="idp1111888460"></a><h2>Arguments</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="parameter"><code>fd</code></em></span></dt><dd><p>File descriptor returned by <a class="link" href="func-open.html" title="V4L2 open()"><code class="function">open()</code></a>.</p></dd><dt><span class="term"><em class="parameter"><code>request</code></em></span></dt><dd><p>V4L2 ioctl request code as defined in the <code class="filename">videodev2.h</code> header file, for example 2VIDIOC_QUERYCAP.</p></dd><dt><span class="term"><em class="parameter"><code>argp</code></em></span></dt><dd><p>Pointer to a function parameter, usually a structure.</p></dd></dl></div></div><div class="refsect1"><a name="idp1111893052"></a><h2>Description</h2><p>The <code class="function">ioctl()</code> function is used to program 3V4L2 devices. The argument <em class="parameter"><code>fd</code></em> must be an open 4file descriptor. An ioctl <em class="parameter"><code>request</code></em> has encoded 5in it whether the argument is an input, output or read/write 6parameter, and the size of the argument <em class="parameter"><code>argp</code></em> in 7bytes. Macros and defines specifying V4L2 ioctl requests are located 8in the <code class="filename">videodev2.h</code> header file. 9Applications should use their own copy, not include the version in the 10kernel sources on the system they compile on. All V4L2 ioctl requests, 11their respective function and parameters are specified in <a class="xref" href="user-func.html" title="Appendix A. Function Reference">Appendix A, <i>Function Reference</i></a>.</p></div><div class="refsect1"><a name="idp1111896308"></a><h2>Return Value</h2><p>On success <span class="returnvalue">0</span> is returned, on error <span class="returnvalue">-1</span> and the <code class="varname">errno</code> variable is set appropriately. The generic error codes are described at the <a class="link" href="gen_errors.html#gen-errors" title="Table 19.1. Generic error codes">Generic Error Codes</a> chapter.</p><p>When an ioctl that takes an output or read/write parameter fails, 12 the parameter remains unmodified.</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="func-close.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="user-func.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="vidioc-create-bufs.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">V4L2 close() </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> ioctl VIDIOC_CREATE_BUFS</td></tr></table></div></body></html> 13