1<refentry id="vidioc-g-ext-ctrls"> 2 <refmeta> 3 <refentrytitle>ioctl VIDIOC_G_EXT_CTRLS, VIDIOC_S_EXT_CTRLS, 4VIDIOC_TRY_EXT_CTRLS</refentrytitle> 5 &manvol; 6 </refmeta> 7 8 <refnamediv> 9 <refname>VIDIOC_G_EXT_CTRLS</refname> 10 <refname>VIDIOC_S_EXT_CTRLS</refname> 11 <refname>VIDIOC_TRY_EXT_CTRLS</refname> 12 <refpurpose>Get or set the value of several controls, try control 13values</refpurpose> 14 </refnamediv> 15 16 <refsynopsisdiv> 17 <funcsynopsis> 18 <funcprototype> 19 <funcdef>int <function>ioctl</function></funcdef> 20 <paramdef>int <parameter>fd</parameter></paramdef> 21 <paramdef>int <parameter>request</parameter></paramdef> 22 <paramdef>struct v4l2_ext_controls 23*<parameter>argp</parameter></paramdef> 24 </funcprototype> 25 </funcsynopsis> 26 </refsynopsisdiv> 27 28 <refsect1> 29 <title>Arguments</title> 30 31 <variablelist> 32 <varlistentry> 33 <term><parameter>fd</parameter></term> 34 <listitem> 35 <para>&fd;</para> 36 </listitem> 37 </varlistentry> 38 <varlistentry> 39 <term><parameter>request</parameter></term> 40 <listitem> 41 <para>VIDIOC_G_EXT_CTRLS, VIDIOC_S_EXT_CTRLS, 42VIDIOC_TRY_EXT_CTRLS</para> 43 </listitem> 44 </varlistentry> 45 <varlistentry> 46 <term><parameter>argp</parameter></term> 47 <listitem> 48 <para></para> 49 </listitem> 50 </varlistentry> 51 </variablelist> 52 </refsect1> 53 54 <refsect1> 55 <title>Description</title> 56 57 <para>These ioctls allow the caller to get or set multiple 58controls atomically. Control IDs are grouped into control classes (see 59<xref linkend="ctrl-class" />) and all controls in the control array 60must belong to the same control class.</para> 61 62 <para>Applications must always fill in the 63<structfield>count</structfield>, 64<structfield>ctrl_class</structfield>, 65<structfield>controls</structfield> and 66<structfield>reserved</structfield> fields of &v4l2-ext-controls;, and 67initialize the &v4l2-ext-control; array pointed to by the 68<structfield>controls</structfield> fields.</para> 69 70 <para>To get the current value of a set of controls applications 71initialize the <structfield>id</structfield>, 72<structfield>size</structfield> and <structfield>reserved2</structfield> fields 73of each &v4l2-ext-control; and call the 74<constant>VIDIOC_G_EXT_CTRLS</constant> ioctl. String controls controls 75must also set the <structfield>string</structfield> field.</para> 76 77 <para>If the <structfield>size</structfield> is too small to 78receive the control result (only relevant for pointer-type controls 79like strings), then the driver will set <structfield>size</structfield> 80to a valid value and return an &ENOSPC;. You should re-allocate the 81string memory to this new size and try again. It is possible that the 82same issue occurs again if the string has grown in the meantime. It is 83recommended to call &VIDIOC-QUERYCTRL; first and use 84<structfield>maximum</structfield>+1 as the new <structfield>size</structfield> 85value. It is guaranteed that that is sufficient memory. 86</para> 87 88 <para>To change the value of a set of controls applications 89initialize the <structfield>id</structfield>, <structfield>size</structfield>, 90<structfield>reserved2</structfield> and 91<structfield>value/string</structfield> fields of each &v4l2-ext-control; and 92call the <constant>VIDIOC_S_EXT_CTRLS</constant> ioctl. The controls 93will only be set if <emphasis>all</emphasis> control values are 94valid.</para> 95 96 <para>To check if a set of controls have correct values applications 97initialize the <structfield>id</structfield>, <structfield>size</structfield>, 98<structfield>reserved2</structfield> and 99<structfield>value/string</structfield> fields of each &v4l2-ext-control; and 100call the <constant>VIDIOC_TRY_EXT_CTRLS</constant> ioctl. It is up to 101the driver whether wrong values are automatically adjusted to a valid 102value or if an error is returned.</para> 103 104 <para>When the <structfield>id</structfield> or 105<structfield>ctrl_class</structfield> is invalid drivers return an 106&EINVAL;. When the value is out of bounds drivers can choose to take 107the closest valid value or return an &ERANGE;, whatever seems more 108appropriate. In the first case the new value is set in 109&v4l2-ext-control;.</para> 110 111 <para>The driver will only set/get these controls if all control 112values are correct. This prevents the situation where only some of the 113controls were set/get. Only low-level errors (⪚ a failed i2c 114command) can still cause this situation.</para> 115 116 <table pgwide="1" frame="none" id="v4l2-ext-control"> 117 <title>struct <structname>v4l2_ext_control</structname></title> 118 <tgroup cols="4"> 119 &cs-ustr; 120 <tbody valign="top"> 121 <row> 122 <entry>__u32</entry> 123 <entry><structfield>id</structfield></entry> 124 <entry></entry> 125 <entry>Identifies the control, set by the 126application.</entry> 127 </row> 128 <row> 129 <entry>__u32</entry> 130 <entry><structfield>size</structfield></entry> 131 <entry></entry> 132 <entry>The total size in bytes of the payload of this 133control. This is normally 0, but for pointer controls this should be 134set to the size of the memory containing the payload, or that will 135receive the payload. If <constant>VIDIOC_G_EXT_CTRLS</constant> finds 136that this value is less than is required to store 137the payload result, then it is set to a value large enough to store the 138payload result and ENOSPC is returned. Note that for string controls 139this <structfield>size</structfield> field should not be confused with the length of the string. 140This field refers to the size of the memory that contains the string. 141The actual <emphasis>length</emphasis> of the string may well be much smaller. 142</entry> 143 </row> 144 <row> 145 <entry>__u32</entry> 146 <entry><structfield>reserved2</structfield>[1]</entry> 147 <entry></entry> 148 <entry>Reserved for future extensions. Drivers and 149applications must set the array to zero.</entry> 150 </row> 151 <row> 152 <entry>union</entry> 153 <entry>(anonymous)</entry> 154 </row> 155 <row> 156 <entry></entry> 157 <entry>__s32</entry> 158 <entry><structfield>value</structfield></entry> 159 <entry>New value or current value.</entry> 160 </row> 161 <row> 162 <entry></entry> 163 <entry>__s64</entry> 164 <entry><structfield>value64</structfield></entry> 165 <entry>New value or current value.</entry> 166 </row> 167 <row> 168 <entry></entry> 169 <entry>char *</entry> 170 <entry><structfield>string</structfield></entry> 171 <entry>A pointer to a string.</entry> 172 </row> 173 </tbody> 174 </tgroup> 175 </table> 176 177 <table pgwide="1" frame="none" id="v4l2-ext-controls"> 178 <title>struct <structname>v4l2_ext_controls</structname></title> 179 <tgroup cols="3"> 180 &cs-str; 181 <tbody valign="top"> 182 <row> 183 <entry>__u32</entry> 184 <entry><structfield>ctrl_class</structfield></entry> 185 <entry>The control class to which all controls belong, see 186<xref linkend="ctrl-class" />. Drivers that use a kernel framework for handling 187controls will also accept a value of 0 here, meaning that the controls can 188belong to any control class. Whether drivers support this can be tested by setting 189<structfield>ctrl_class</structfield> to 0 and calling <constant>VIDIOC_TRY_EXT_CTRLS</constant> 190with a <structfield>count</structfield> of 0. If that succeeds, then the driver 191supports this feature.</entry> 192 </row> 193 <row> 194 <entry>__u32</entry> 195 <entry><structfield>count</structfield></entry> 196 <entry>The number of controls in the controls array. May 197also be zero.</entry> 198 </row> 199 <row> 200 <entry>__u32</entry> 201 <entry><structfield>error_idx</structfield></entry> 202 <entry>Set by the driver in case of an error. If it is equal 203to <structfield>count</structfield>, then no actual changes were made to 204controls. In other words, the error was not associated with setting a particular 205control. If it is another value, then only the controls up to <structfield>error_idx-1</structfield> 206were modified and control <structfield>error_idx</structfield> is the one that 207caused the error. The <structfield>error_idx</structfield> value is undefined 208if the ioctl returned 0 (success).</entry> 209 </row> 210 <row> 211 <entry>__u32</entry> 212 <entry><structfield>reserved</structfield>[2]</entry> 213 <entry>Reserved for future extensions. Drivers and 214applications must set the array to zero.</entry> 215 </row> 216 <row> 217 <entry>&v4l2-ext-control; *</entry> 218 <entry><structfield>controls</structfield></entry> 219 <entry>Pointer to an array of 220<structfield>count</structfield> v4l2_ext_control structures. Ignored 221if <structfield>count</structfield> equals zero.</entry> 222 </row> 223 </tbody> 224 </tgroup> 225 </table> 226 227 <table pgwide="1" frame="none" id="ctrl-class"> 228 <title>Control classes</title> 229 <tgroup cols="3"> 230 &cs-def; 231 <tbody valign="top"> 232 <row> 233 <entry><constant>V4L2_CTRL_CLASS_USER</constant></entry> 234 <entry>0x980000</entry> 235 <entry>The class containing user controls. These controls 236are described in <xref linkend="control" />. All controls that can be set 237using the &VIDIOC-S-CTRL; and &VIDIOC-G-CTRL; ioctl belong to this 238class.</entry> 239 </row> 240 <row> 241 <entry><constant>V4L2_CTRL_CLASS_MPEG</constant></entry> 242 <entry>0x990000</entry> 243 <entry>The class containing MPEG compression controls. 244These controls are described in <xref 245 linkend="mpeg-controls" />.</entry> 246 </row> 247 <row> 248 <entry><constant>V4L2_CTRL_CLASS_CAMERA</constant></entry> 249 <entry>0x9a0000</entry> 250 <entry>The class containing camera controls. 251These controls are described in <xref 252 linkend="camera-controls" />.</entry> 253 </row> 254 <row> 255 <entry><constant>V4L2_CTRL_CLASS_FM_TX</constant></entry> 256 <entry>0x9b0000</entry> 257 <entry>The class containing FM Transmitter (FM TX) controls. 258These controls are described in <xref 259 linkend="fm-tx-controls" />.</entry> 260 </row> 261 <row> 262 <entry><constant>V4L2_CTRL_CLASS_FLASH</constant></entry> 263 <entry>0x9c0000</entry> 264 <entry>The class containing flash device controls. 265These controls are described in <xref 266 linkend="flash-controls" />.</entry> 267 </row> 268 </tbody> 269 </tgroup> 270 </table> 271 272 </refsect1> 273 274 <refsect1> 275 &return-value; 276 277 <variablelist> 278 <varlistentry> 279 <term><errorcode>EINVAL</errorcode></term> 280 <listitem> 281 <para>The &v4l2-ext-control; <structfield>id</structfield> 282is invalid or the &v4l2-ext-controls; 283<structfield>ctrl_class</structfield> is invalid. This error code is 284also returned by the <constant>VIDIOC_S_EXT_CTRLS</constant> and 285<constant>VIDIOC_TRY_EXT_CTRLS</constant> ioctls if two or more 286control values are in conflict.</para> 287 </listitem> 288 </varlistentry> 289 <varlistentry> 290 <term><errorcode>ERANGE</errorcode></term> 291 <listitem> 292 <para>The &v4l2-ext-control; <structfield>value</structfield> 293is out of bounds.</para> 294 </listitem> 295 </varlistentry> 296 <varlistentry> 297 <term><errorcode>EBUSY</errorcode></term> 298 <listitem> 299 <para>The control is temporarily not changeable, possibly 300because another applications took over control of the device function 301this control belongs to.</para> 302 </listitem> 303 </varlistentry> 304 <varlistentry> 305 <term><errorcode>ENOSPC</errorcode></term> 306 <listitem> 307 <para>The space reserved for the control's payload is insufficient. 308The field <structfield>size</structfield> is set to a value that is enough 309to store the payload and this error code is returned.</para> 310 </listitem> 311 </varlistentry> 312 <varlistentry> 313 <term><errorcode>EACCES</errorcode></term> 314 <listitem> 315 <para>Attempt to try or set a read-only control or to get a 316 write-only control.</para> 317 </listitem> 318 </varlistentry> 319 </variablelist> 320 </refsect1> 321</refentry> 322 323