1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>ioctl VIDIOC_G_CTRL, VIDIOC_S_CTRL</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&#160;A.&#160;Function Reference"><link rel="prev" href="vidioc-g-crop.html" title="ioctl VIDIOC_G_CROP, VIDIOC_S_CROP"><link rel="next" href="vidioc-g-dv-timings.html" title="ioctl VIDIOC_G_DV_TIMINGS, VIDIOC_S_DV_TIMINGS"></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">ioctl VIDIOC_G_CTRL, VIDIOC_S_CTRL</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="vidioc-g-crop.html">Prev</a>&#160;</td><th width="60%" align="center">Appendix&#160;A.&#160;Function Reference</th><td width="20%" align="right">&#160;<a accesskey="n" href="vidioc-g-dv-timings.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="vidioc-g-ctrl"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>VIDIOC_G_CTRL, VIDIOC_S_CTRL &#8212; Get or set the value of a control</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><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>&#160;</td><td>int <var class="pdparam">request</var>, </td></tr><tr><td>&#160;</td><td>struct v4l2_control
2*<var class="pdparam">argp</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer">&#160;</div></div></div><div class="refsect1"><a name="idp1113812644"></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>VIDIOC_G_CTRL, VIDIOC_S_CTRL</p></dd><dt><span class="term"><em class="parameter"><code>argp</code></em></span></dt><dd><p></p></dd></dl></div></div><div class="refsect1"><a name="idp1113816748"></a><h2>Description</h2><p>To get the current value of a control applications
3initialize the <em class="structfield"><code>id</code></em> field of a struct
4<span class="structname">v4l2_control</span> and call the
5<code class="constant">VIDIOC_G_CTRL</code> ioctl with a pointer to this
6structure. To change the value of a control applications initialize
7the <em class="structfield"><code>id</code></em> and <em class="structfield"><code>value</code></em>
8fields of a struct <span class="structname">v4l2_control</span> and call the
9<code class="constant">VIDIOC_S_CTRL</code> ioctl.</p><p>When the <em class="structfield"><code>id</code></em> is invalid drivers
10return an <span class="errorcode">EINVAL</span> error code. When the <em class="structfield"><code>value</code></em> is out
11of bounds drivers can choose to take the closest valid value or return
12an <span class="errorcode">ERANGE</span> error code, whatever seems more appropriate. However,
13<code class="constant">VIDIOC_S_CTRL</code> is a write-only ioctl, it does not
14return the actual new value. If the <em class="structfield"><code>value</code></em>
15is inappropriate for the control (e.g. if it refers to an unsupported
16menu index of a menu control), then <span class="errorcode">EINVAL</span> error code is returned as well.</p><p>These ioctls work only with user controls. For other
17control classes the <a class="link" href="vidioc-g-ext-ctrls.html" title="ioctl VIDIOC_G_EXT_CTRLS, VIDIOC_S_EXT_CTRLS, VIDIOC_TRY_EXT_CTRLS"><code class="constant">VIDIOC_G_EXT_CTRLS</code></a>, <a class="link" href="vidioc-g-ext-ctrls.html" title="ioctl VIDIOC_G_EXT_CTRLS, VIDIOC_S_EXT_CTRLS, VIDIOC_TRY_EXT_CTRLS"><code class="constant">VIDIOC_S_EXT_CTRLS</code></a> or
18<a class="link" href="vidioc-g-ext-ctrls.html" title="ioctl VIDIOC_G_EXT_CTRLS, VIDIOC_S_EXT_CTRLS, VIDIOC_TRY_EXT_CTRLS"><code class="constant">VIDIOC_TRY_EXT_CTRLS</code></a> must be used.</p><div class="table"><a name="v4l2-control"></a><p class="title"><b>Table&#160;A.56.&#160;struct <span class="structname">v4l2_control</span></b></p><div class="table-contents"><table summary="struct v4l2_control" width="100%" border="0"><colgroup><col class="c1"><col class="c2"><col class="c3"></colgroup><tbody valign="top"><tr><td valign="top">__u32</td><td valign="top"><em class="structfield"><code>id</code></em></td><td valign="top">Identifies the control, set by the
19application.</td></tr><tr><td valign="top">__s32</td><td valign="top"><em class="structfield"><code>value</code></em></td><td valign="top">New value or current value.</td></tr></tbody></table></div></div><br class="table-break"></div><div class="refsect1"><a name="idp1113828892"></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&#160;19.1.&#160;Generic error codes">Generic Error Codes</a> chapter.</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><span class="errorcode">EINVAL</span></span></dt><dd><p>The struct&#160;<a class="link" href="vidioc-g-ctrl.html#v4l2-control" title="Table&#160;A.56.&#160;struct v4l2_control">v4l2_control</a> <em class="structfield"><code>id</code></em> is
20invalid or the <em class="structfield"><code>value</code></em> is inappropriate for
21the given control (i.e. if a menu item is selected that is not supported
22by the driver according to <a class="link" href="vidioc-queryctrl.html" title="ioctl VIDIOC_QUERYCTRL, VIDIOC_QUERY_EXT_CTRL, VIDIOC_QUERYMENU"><code class="constant">VIDIOC_QUERYMENU</code></a>).</p></dd><dt><span class="term"><span class="errorcode">ERANGE</span></span></dt><dd><p>The struct&#160;<a class="link" href="vidioc-g-ctrl.html#v4l2-control" title="Table&#160;A.56.&#160;struct v4l2_control">v4l2_control</a> <em class="structfield"><code>value</code></em>
23is out of bounds.</p></dd><dt><span class="term"><span class="errorcode">EBUSY</span></span></dt><dd><p>The control is temporarily not changeable, possibly
24because another applications took over control of the device function
25this control belongs to.</p></dd><dt><span class="term"><span class="errorcode">EACCES</span></span></dt><dd><p>Attempt to set a read-only control or to get a
26	  write-only control.</p></dd></dl></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="vidioc-g-crop.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="user-func.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="vidioc-g-dv-timings.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">ioctl VIDIOC_G_CROP, VIDIOC_S_CROP&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;ioctl VIDIOC_G_DV_TIMINGS, VIDIOC_S_DV_TIMINGS</td></tr></table></div></body></html>
27