vidioc-queryctrl.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. <refentry id="vidioc-queryctrl">
  2. <refmeta>
  3. <refentrytitle>ioctl VIDIOC_QUERYCTRL, VIDIOC_QUERYMENU</refentrytitle>
  4. &manvol;
  5. </refmeta>
  6. <refnamediv>
  7. <refname>VIDIOC_QUERYCTRL</refname>
  8. <refname>VIDIOC_QUERYMENU</refname>
  9. <refpurpose>Enumerate controls and menu control items</refpurpose>
  10. </refnamediv>
  11. <refsynopsisdiv>
  12. <funcsynopsis>
  13. <funcprototype>
  14. <funcdef>int <function>ioctl</function></funcdef>
  15. <paramdef>int <parameter>fd</parameter></paramdef>
  16. <paramdef>int <parameter>request</parameter></paramdef>
  17. <paramdef>struct v4l2_queryctrl *<parameter>argp</parameter></paramdef>
  18. </funcprototype>
  19. </funcsynopsis>
  20. <funcsynopsis>
  21. <funcprototype>
  22. <funcdef>int <function>ioctl</function></funcdef>
  23. <paramdef>int <parameter>fd</parameter></paramdef>
  24. <paramdef>int <parameter>request</parameter></paramdef>
  25. <paramdef>struct v4l2_querymenu *<parameter>argp</parameter></paramdef>
  26. </funcprototype>
  27. </funcsynopsis>
  28. </refsynopsisdiv>
  29. <refsect1>
  30. <title>Arguments</title>
  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_QUERYCTRL, VIDIOC_QUERYMENU</para>
  42. </listitem>
  43. </varlistentry>
  44. <varlistentry>
  45. <term><parameter>argp</parameter></term>
  46. <listitem>
  47. <para></para>
  48. </listitem>
  49. </varlistentry>
  50. </variablelist>
  51. </refsect1>
  52. <refsect1>
  53. <title>Description</title>
  54. <para>To query the attributes of a control applications set the
  55. <structfield>id</structfield> field of a &v4l2-queryctrl; and call the
  56. <constant>VIDIOC_QUERYCTRL</constant> ioctl with a pointer to this
  57. structure. The driver fills the rest of the structure or returns an
  58. &EINVAL; when the <structfield>id</structfield> is invalid.</para>
  59. <para>It is possible to enumerate controls by calling
  60. <constant>VIDIOC_QUERYCTRL</constant> with successive
  61. <structfield>id</structfield> values starting from
  62. <constant>V4L2_CID_BASE</constant> up to and exclusive
  63. <constant>V4L2_CID_BASE_LASTP1</constant>. Drivers may return
  64. <errorcode>EINVAL</errorcode> if a control in this range is not
  65. supported. Further applications can enumerate private controls, which
  66. are not defined in this specification, by starting at
  67. <constant>V4L2_CID_PRIVATE_BASE</constant> and incrementing
  68. <structfield>id</structfield> until the driver returns
  69. <errorcode>EINVAL</errorcode>.</para>
  70. <para>In both cases, when the driver sets the
  71. <constant>V4L2_CTRL_FLAG_DISABLED</constant> flag in the
  72. <structfield>flags</structfield> field this control is permanently
  73. disabled and should be ignored by the application.<footnote>
  74. <para><constant>V4L2_CTRL_FLAG_DISABLED</constant> was
  75. intended for two purposes: Drivers can skip predefined controls not
  76. supported by the hardware (although returning EINVAL would do as
  77. well), or disable predefined and private controls after hardware
  78. detection without the trouble of reordering control arrays and indices
  79. (EINVAL cannot be used to skip private controls because it would
  80. prematurely end the enumeration).</para></footnote></para>
  81. <para>When the application ORs <structfield>id</structfield> with
  82. <constant>V4L2_CTRL_FLAG_NEXT_CTRL</constant> the driver returns the
  83. next supported control, or <errorcode>EINVAL</errorcode> if there is
  84. none. Drivers which do not support this flag yet always return
  85. <errorcode>EINVAL</errorcode>.</para>
  86. <para>Additional information is required for menu controls: the
  87. names of the menu items. To query them applications set the
  88. <structfield>id</structfield> and <structfield>index</structfield>
  89. fields of &v4l2-querymenu; and call the
  90. <constant>VIDIOC_QUERYMENU</constant> ioctl with a pointer to this
  91. structure. The driver fills the rest of the structure or returns an
  92. &EINVAL; when the <structfield>id</structfield> or
  93. <structfield>index</structfield> is invalid. Menu items are enumerated
  94. by calling <constant>VIDIOC_QUERYMENU</constant> with successive
  95. <structfield>index</structfield> values from &v4l2-queryctrl;
  96. <structfield>minimum</structfield> to
  97. <structfield>maximum</structfield>, inclusive. Note that it is possible
  98. for <constant>VIDIOC_QUERYMENU</constant> to return an &EINVAL; for some
  99. indices between <structfield>minimum</structfield> and <structfield>maximum</structfield>.
  100. In that case that particular menu item is not supported by this driver. Also note that
  101. the <structfield>minimum</structfield> value is not necessarily 0.</para>
  102. <para>See also the examples in <xref linkend="control" />.</para>
  103. <table pgwide="1" frame="none" id="v4l2-queryctrl">
  104. <title>struct <structname>v4l2_queryctrl</structname></title>
  105. <tgroup cols="3">
  106. &cs-str;
  107. <tbody valign="top">
  108. <row>
  109. <entry>__u32</entry>
  110. <entry><structfield>id</structfield></entry>
  111. <entry>Identifies the control, set by the application. See
  112. <xref linkend="control-id" /> for predefined IDs. When the ID is ORed
  113. with V4L2_CTRL_FLAG_NEXT_CTRL the driver clears the flag and returns
  114. the first control with a higher ID. Drivers which do not support this
  115. flag yet always return an &EINVAL;.</entry>
  116. </row>
  117. <row>
  118. <entry>&v4l2-ctrl-type;</entry>
  119. <entry><structfield>type</structfield></entry>
  120. <entry>Type of control, see <xref
  121. linkend="v4l2-ctrl-type" />.</entry>
  122. </row>
  123. <row>
  124. <entry>__u8</entry>
  125. <entry><structfield>name</structfield>[32]</entry>
  126. <entry>Name of the control, a NUL-terminated ASCII
  127. string. This information is intended for the user.</entry>
  128. </row>
  129. <row>
  130. <entry>__s32</entry>
  131. <entry><structfield>minimum</structfield></entry>
  132. <entry>Minimum value, inclusive. This field gives a lower
  133. bound for <constant>V4L2_CTRL_TYPE_INTEGER</constant> controls and the
  134. lowest valid index for <constant>V4L2_CTRL_TYPE_MENU</constant> controls.
  135. For <constant>V4L2_CTRL_TYPE_STRING</constant> controls the minimum value
  136. gives the minimum length of the string. This length <emphasis>does not include the terminating
  137. zero</emphasis>. It may not be valid for any other type of control, including
  138. <constant>V4L2_CTRL_TYPE_INTEGER64</constant> controls. Note that this is a
  139. signed value.</entry>
  140. </row>
  141. <row>
  142. <entry>__s32</entry>
  143. <entry><structfield>maximum</structfield></entry>
  144. <entry>Maximum value, inclusive. This field gives an upper
  145. bound for <constant>V4L2_CTRL_TYPE_INTEGER</constant> controls and the
  146. highest valid index for <constant>V4L2_CTRL_TYPE_MENU</constant>
  147. controls. For <constant>V4L2_CTRL_TYPE_BITMASK</constant> controls it is the
  148. set of usable bits.
  149. For <constant>V4L2_CTRL_TYPE_STRING</constant> controls the maximum value
  150. gives the maximum length of the string. This length <emphasis>does not include the terminating
  151. zero</emphasis>. It may not be valid for any other type of control, including
  152. <constant>V4L2_CTRL_TYPE_INTEGER64</constant> controls. Note that this is a
  153. signed value.</entry>
  154. </row>
  155. <row>
  156. <entry>__s32</entry>
  157. <entry><structfield>step</structfield></entry>
  158. <entry><para>This field gives a step size for
  159. <constant>V4L2_CTRL_TYPE_INTEGER</constant> controls. For
  160. <constant>V4L2_CTRL_TYPE_STRING</constant> controls this field refers to
  161. the string length that has to be a multiple of this step size.
  162. It may not be valid for any other type of control, including
  163. <constant>V4L2_CTRL_TYPE_INTEGER64</constant>
  164. controls.</para><para>Generally drivers should not scale hardware
  165. control values. It may be necessary for example when the
  166. <structfield>name</structfield> or <structfield>id</structfield> imply
  167. a particular unit and the hardware actually accepts only multiples of
  168. said unit. If so, drivers must take care values are properly rounded
  169. when scaling, such that errors will not accumulate on repeated
  170. read-write cycles.</para><para>This field gives the smallest change of
  171. an integer control actually affecting hardware. Often the information
  172. is needed when the user can change controls by keyboard or GUI
  173. buttons, rather than a slider. When for example a hardware register
  174. accepts values 0-511 and the driver reports 0-65535, step should be
  175. 128.</para><para>Note that although signed, the step value is supposed to
  176. be always positive.</para></entry>
  177. </row>
  178. <row>
  179. <entry>__s32</entry>
  180. <entry><structfield>default_value</structfield></entry>
  181. <entry>The default value of a
  182. <constant>V4L2_CTRL_TYPE_INTEGER</constant>,
  183. <constant>_BOOLEAN</constant> or <constant>_MENU</constant> control.
  184. Not valid for other types of controls. Drivers reset controls only
  185. when the driver is loaded, not later, in particular not when the
  186. func-open; is called.</entry>
  187. </row>
  188. <row>
  189. <entry>__u32</entry>
  190. <entry><structfield>flags</structfield></entry>
  191. <entry>Control flags, see <xref
  192. linkend="control-flags" />.</entry>
  193. </row>
  194. <row>
  195. <entry>__u32</entry>
  196. <entry><structfield>reserved</structfield>[2]</entry>
  197. <entry>Reserved for future extensions. Drivers must set
  198. the array to zero.</entry>
  199. </row>
  200. </tbody>
  201. </tgroup>
  202. </table>
  203. <table pgwide="1" frame="none" id="v4l2-querymenu">
  204. <title>struct <structname>v4l2_querymenu</structname></title>
  205. <tgroup cols="3">
  206. &cs-str;
  207. <tbody valign="top">
  208. <row>
  209. <entry>__u32</entry>
  210. <entry><structfield>id</structfield></entry>
  211. <entry>Identifies the control, set by the application
  212. from the respective &v4l2-queryctrl;
  213. <structfield>id</structfield>.</entry>
  214. </row>
  215. <row>
  216. <entry>__u32</entry>
  217. <entry><structfield>index</structfield></entry>
  218. <entry>Index of the menu item, starting at zero, set by
  219. the application.</entry>
  220. </row>
  221. <row>
  222. <entry>__u8</entry>
  223. <entry><structfield>name</structfield>[32]</entry>
  224. <entry>Name of the menu item, a NUL-terminated ASCII
  225. string. This information is intended for the user.</entry>
  226. </row>
  227. <row>
  228. <entry>__u32</entry>
  229. <entry><structfield>reserved</structfield></entry>
  230. <entry>Reserved for future extensions. Drivers must set
  231. the array to zero.</entry>
  232. </row>
  233. </tbody>
  234. </tgroup>
  235. </table>
  236. <table pgwide="1" frame="none" id="v4l2-ctrl-type">
  237. <title>enum v4l2_ctrl_type</title>
  238. <tgroup cols="5" align="left">
  239. <colspec colwidth="30*" />
  240. <colspec colwidth="5*" align="center" />
  241. <colspec colwidth="5*" align="center" />
  242. <colspec colwidth="5*" align="center" />
  243. <colspec colwidth="55*" />
  244. <thead>
  245. <row>
  246. <entry>Type</entry>
  247. <entry><structfield>minimum</structfield></entry>
  248. <entry><structfield>step</structfield></entry>
  249. <entry><structfield>maximum</structfield></entry>
  250. <entry>Description</entry>
  251. </row>
  252. </thead>
  253. <tbody valign="top">
  254. <row>
  255. <entry><constant>V4L2_CTRL_TYPE_INTEGER</constant></entry>
  256. <entry>any</entry>
  257. <entry>any</entry>
  258. <entry>any</entry>
  259. <entry>An integer-valued control ranging from minimum to
  260. maximum inclusive. The step value indicates the increment between
  261. values which are actually different on the hardware.</entry>
  262. </row>
  263. <row>
  264. <entry><constant>V4L2_CTRL_TYPE_BOOLEAN</constant></entry>
  265. <entry>0</entry>
  266. <entry>1</entry>
  267. <entry>1</entry>
  268. <entry>A boolean-valued control. Zero corresponds to
  269. "disabled", and one means "enabled".</entry>
  270. </row>
  271. <row>
  272. <entry><constant>V4L2_CTRL_TYPE_MENU</constant></entry>
  273. <entry>&ge; 0</entry>
  274. <entry>1</entry>
  275. <entry>N-1</entry>
  276. <entry>The control has a menu of N choices. The names of
  277. the menu items can be enumerated with the
  278. <constant>VIDIOC_QUERYMENU</constant> ioctl.</entry>
  279. </row>
  280. <row>
  281. <entry><constant>V4L2_CTRL_TYPE_BITMASK</constant></entry>
  282. <entry>0</entry>
  283. <entry>n/a</entry>
  284. <entry>any</entry>
  285. <entry>A bitmask field. The maximum value is the set of bits that can
  286. be used, all other bits are to be 0. The maximum value is interpreted as a __u32,
  287. allowing the use of bit 31 in the bitmask.</entry>
  288. </row>
  289. <row>
  290. <entry><constant>V4L2_CTRL_TYPE_BUTTON</constant></entry>
  291. <entry>0</entry>
  292. <entry>0</entry>
  293. <entry>0</entry>
  294. <entry>A control which performs an action when set.
  295. Drivers must ignore the value passed with
  296. <constant>VIDIOC_S_CTRL</constant> and return an &EINVAL; on a
  297. <constant>VIDIOC_G_CTRL</constant> attempt.</entry>
  298. </row>
  299. <row>
  300. <entry><constant>V4L2_CTRL_TYPE_INTEGER64</constant></entry>
  301. <entry>n/a</entry>
  302. <entry>n/a</entry>
  303. <entry>n/a</entry>
  304. <entry>A 64-bit integer valued control. Minimum, maximum
  305. and step size cannot be queried.</entry>
  306. </row>
  307. <row>
  308. <entry><constant>V4L2_CTRL_TYPE_STRING</constant></entry>
  309. <entry>&ge; 0</entry>
  310. <entry>&ge; 1</entry>
  311. <entry>&ge; 0</entry>
  312. <entry>The minimum and maximum string lengths. The step size
  313. means that the string must be (minimum + N * step) characters long for
  314. N &ge; 0. These lengths do not include the terminating zero, so in order to
  315. pass a string of length 8 to &VIDIOC-S-EXT-CTRLS; you need to set the
  316. <structfield>size</structfield> field of &v4l2-ext-control; to 9. For &VIDIOC-G-EXT-CTRLS; you can
  317. set the <structfield>size</structfield> field to <structfield>maximum</structfield> + 1.
  318. Which character encoding is used will depend on the string control itself and
  319. should be part of the control documentation.</entry>
  320. </row>
  321. <row>
  322. <entry><constant>V4L2_CTRL_TYPE_CTRL_CLASS</constant></entry>
  323. <entry>n/a</entry>
  324. <entry>n/a</entry>
  325. <entry>n/a</entry>
  326. <entry>This is not a control. When
  327. <constant>VIDIOC_QUERYCTRL</constant> is called with a control ID
  328. equal to a control class code (see <xref linkend="ctrl-class" />) + 1, the
  329. ioctl returns the name of the control class and this control type.
  330. Older drivers which do not support this feature return an
  331. &EINVAL;.</entry>
  332. </row>
  333. </tbody>
  334. </tgroup>
  335. </table>
  336. <table pgwide="1" frame="none" id="control-flags">
  337. <title>Control Flags</title>
  338. <tgroup cols="3">
  339. &cs-def;
  340. <tbody valign="top">
  341. <row>
  342. <entry><constant>V4L2_CTRL_FLAG_DISABLED</constant></entry>
  343. <entry>0x0001</entry>
  344. <entry>This control is permanently disabled and should be
  345. ignored by the application. Any attempt to change the control will
  346. result in an &EINVAL;.</entry>
  347. </row>
  348. <row>
  349. <entry><constant>V4L2_CTRL_FLAG_GRABBED</constant></entry>
  350. <entry>0x0002</entry>
  351. <entry>This control is temporarily unchangeable, for
  352. example because another application took over control of the
  353. respective resource. Such controls may be displayed specially in a
  354. user interface. Attempts to change the control may result in an
  355. &EBUSY;.</entry>
  356. </row>
  357. <row>
  358. <entry><constant>V4L2_CTRL_FLAG_READ_ONLY</constant></entry>
  359. <entry>0x0004</entry>
  360. <entry>This control is permanently readable only. Any
  361. attempt to change the control will result in an &EINVAL;.</entry>
  362. </row>
  363. <row>
  364. <entry><constant>V4L2_CTRL_FLAG_UPDATE</constant></entry>
  365. <entry>0x0008</entry>
  366. <entry>A hint that changing this control may affect the
  367. value of other controls within the same control class. Applications
  368. should update their user interface accordingly.</entry>
  369. </row>
  370. <row>
  371. <entry><constant>V4L2_CTRL_FLAG_INACTIVE</constant></entry>
  372. <entry>0x0010</entry>
  373. <entry>This control is not applicable to the current
  374. configuration and should be displayed accordingly in a user interface.
  375. For example the flag may be set on a MPEG audio level 2 bitrate
  376. control when MPEG audio encoding level 1 was selected with another
  377. control.</entry>
  378. </row>
  379. <row>
  380. <entry><constant>V4L2_CTRL_FLAG_SLIDER</constant></entry>
  381. <entry>0x0020</entry>
  382. <entry>A hint that this control is best represented as a
  383. slider-like element in a user interface.</entry>
  384. </row>
  385. <row>
  386. <entry><constant>V4L2_CTRL_FLAG_WRITE_ONLY</constant></entry>
  387. <entry>0x0040</entry>
  388. <entry>This control is permanently writable only. Any
  389. attempt to read the control will result in an &EACCES; error code. This
  390. flag is typically present for relative controls or action controls where
  391. writing a value will cause the device to carry out a given action
  392. (&eg; motor control) but no meaningful value can be returned.</entry>
  393. </row>
  394. <row>
  395. <entry><constant>V4L2_CTRL_FLAG_VOLATILE</constant></entry>
  396. <entry>0x0080</entry>
  397. <entry>This control is volatile, which means that the value of the control
  398. changes continuously. A typical example would be the current gain value if the device
  399. is in auto-gain mode. In such a case the hardware calculates the gain value based on
  400. the lighting conditions which can change over time. Note that setting a new value for
  401. a volatile control will have no effect. The new value will just be ignored.</entry>
  402. </row>
  403. </tbody>
  404. </tgroup>
  405. </table>
  406. </refsect1>
  407. <refsect1>
  408. &return-value;
  409. <variablelist>
  410. <varlistentry>
  411. <term><errorcode>EINVAL</errorcode></term>
  412. <listitem>
  413. <para>The &v4l2-queryctrl; <structfield>id</structfield>
  414. is invalid. The &v4l2-querymenu; <structfield>id</structfield> is
  415. invalid or <structfield>index</structfield> is out of range (less than
  416. <structfield>minimum</structfield> or greater than <structfield>maximum</structfield>)
  417. or this particular menu item is not supported by the driver.</para>
  418. </listitem>
  419. </varlistentry>
  420. <varlistentry>
  421. <term><errorcode>EACCES</errorcode></term>
  422. <listitem>
  423. <para>An attempt was made to read a write-only control.</para>
  424. </listitem>
  425. </varlistentry>
  426. </variablelist>
  427. </refsect1>
  428. </refentry>