vidioc-queryctrl.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  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> (0) to
  97. <structfield>maximum</structfield>, inclusive.</para>
  98. <para>See also the examples in <xref linkend="control" />.</para>
  99. <table pgwide="1" frame="none" id="v4l2-queryctrl">
  100. <title>struct <structname>v4l2_queryctrl</structname></title>
  101. <tgroup cols="3">
  102. &cs-str;
  103. <tbody valign="top">
  104. <row>
  105. <entry>__u32</entry>
  106. <entry><structfield>id</structfield></entry>
  107. <entry>Identifies the control, set by the application. See
  108. <xref linkend="control-id" /> for predefined IDs. When the ID is ORed
  109. with V4L2_CTRL_FLAG_NEXT_CTRL the driver clears the flag and returns
  110. the first control with a higher ID. Drivers which do not support this
  111. flag yet always return an &EINVAL;.</entry>
  112. </row>
  113. <row>
  114. <entry>&v4l2-ctrl-type;</entry>
  115. <entry><structfield>type</structfield></entry>
  116. <entry>Type of control, see <xref
  117. linkend="v4l2-ctrl-type" />.</entry>
  118. </row>
  119. <row>
  120. <entry>__u8</entry>
  121. <entry><structfield>name</structfield>[32]</entry>
  122. <entry>Name of the control, a NUL-terminated ASCII
  123. string. This information is intended for the user.</entry>
  124. </row>
  125. <row>
  126. <entry>__s32</entry>
  127. <entry><structfield>minimum</structfield></entry>
  128. <entry>Minimum value, inclusive. This field gives a lower
  129. bound for <constant>V4L2_CTRL_TYPE_INTEGER</constant> controls and the
  130. lowest valid index (always 0) for <constant>V4L2_CTRL_TYPE_MENU</constant> controls.
  131. For <constant>V4L2_CTRL_TYPE_STRING</constant> controls the minimum value
  132. gives the minimum length of the string. This length <emphasis>does not include the terminating
  133. zero</emphasis>. It may not be valid for any other type of control, including
  134. <constant>V4L2_CTRL_TYPE_INTEGER64</constant> controls. Note that this is a
  135. signed value.</entry>
  136. </row>
  137. <row>
  138. <entry>__s32</entry>
  139. <entry><structfield>maximum</structfield></entry>
  140. <entry>Maximum value, inclusive. This field gives an upper
  141. bound for <constant>V4L2_CTRL_TYPE_INTEGER</constant> controls and the
  142. highest valid index for <constant>V4L2_CTRL_TYPE_MENU</constant>
  143. controls.
  144. For <constant>V4L2_CTRL_TYPE_STRING</constant> controls the maximum value
  145. gives the maximum length of the string. This length <emphasis>does not include the terminating
  146. zero</emphasis>. It may not be valid for any other type of control, including
  147. <constant>V4L2_CTRL_TYPE_INTEGER64</constant> controls. Note that this is a
  148. signed value.</entry>
  149. </row>
  150. <row>
  151. <entry>__s32</entry>
  152. <entry><structfield>step</structfield></entry>
  153. <entry><para>This field gives a step size for
  154. <constant>V4L2_CTRL_TYPE_INTEGER</constant> controls. For
  155. <constant>V4L2_CTRL_TYPE_STRING</constant> controls this field refers to
  156. the string length that has to be a multiple of this step size.
  157. It may not be valid for any other type of control, including
  158. <constant>V4L2_CTRL_TYPE_INTEGER64</constant>
  159. controls.</para><para>Generally drivers should not scale hardware
  160. control values. It may be necessary for example when the
  161. <structfield>name</structfield> or <structfield>id</structfield> imply
  162. a particular unit and the hardware actually accepts only multiples of
  163. said unit. If so, drivers must take care values are properly rounded
  164. when scaling, such that errors will not accumulate on repeated
  165. read-write cycles.</para><para>This field gives the smallest change of
  166. an integer control actually affecting hardware. Often the information
  167. is needed when the user can change controls by keyboard or GUI
  168. buttons, rather than a slider. When for example a hardware register
  169. accepts values 0-511 and the driver reports 0-65535, step should be
  170. 128.</para><para>Note that although signed, the step value is supposed to
  171. be always positive.</para></entry>
  172. </row>
  173. <row>
  174. <entry>__s32</entry>
  175. <entry><structfield>default_value</structfield></entry>
  176. <entry>The default value of a
  177. <constant>V4L2_CTRL_TYPE_INTEGER</constant>,
  178. <constant>_BOOLEAN</constant> or <constant>_MENU</constant> control.
  179. Not valid for other types of controls. Drivers reset controls only
  180. when the driver is loaded, not later, in particular not when the
  181. func-open; is called.</entry>
  182. </row>
  183. <row>
  184. <entry>__u32</entry>
  185. <entry><structfield>flags</structfield></entry>
  186. <entry>Control flags, see <xref
  187. linkend="control-flags" />.</entry>
  188. </row>
  189. <row>
  190. <entry>__u32</entry>
  191. <entry><structfield>reserved</structfield>[2]</entry>
  192. <entry>Reserved for future extensions. Drivers must set
  193. the array to zero.</entry>
  194. </row>
  195. </tbody>
  196. </tgroup>
  197. </table>
  198. <table pgwide="1" frame="none" id="v4l2-querymenu">
  199. <title>struct <structname>v4l2_querymenu</structname></title>
  200. <tgroup cols="3">
  201. &cs-str;
  202. <tbody valign="top">
  203. <row>
  204. <entry>__u32</entry>
  205. <entry><structfield>id</structfield></entry>
  206. <entry>Identifies the control, set by the application
  207. from the respective &v4l2-queryctrl;
  208. <structfield>id</structfield>.</entry>
  209. </row>
  210. <row>
  211. <entry>__u32</entry>
  212. <entry><structfield>index</structfield></entry>
  213. <entry>Index of the menu item, starting at zero, set by
  214. the application.</entry>
  215. </row>
  216. <row>
  217. <entry>__u8</entry>
  218. <entry><structfield>name</structfield>[32]</entry>
  219. <entry>Name of the menu item, a NUL-terminated ASCII
  220. string. This information is intended for the user.</entry>
  221. </row>
  222. <row>
  223. <entry>__u32</entry>
  224. <entry><structfield>reserved</structfield></entry>
  225. <entry>Reserved for future extensions. Drivers must set
  226. the array to zero.</entry>
  227. </row>
  228. </tbody>
  229. </tgroup>
  230. </table>
  231. <table pgwide="1" frame="none" id="v4l2-ctrl-type">
  232. <title>enum v4l2_ctrl_type</title>
  233. <tgroup cols="5" align="left">
  234. <colspec colwidth="30*" />
  235. <colspec colwidth="5*" align="center" />
  236. <colspec colwidth="5*" align="center" />
  237. <colspec colwidth="5*" align="center" />
  238. <colspec colwidth="55*" />
  239. <thead>
  240. <row>
  241. <entry>Type</entry>
  242. <entry><structfield>minimum</structfield></entry>
  243. <entry><structfield>step</structfield></entry>
  244. <entry><structfield>maximum</structfield></entry>
  245. <entry>Description</entry>
  246. </row>
  247. </thead>
  248. <tbody valign="top">
  249. <row>
  250. <entry><constant>V4L2_CTRL_TYPE_INTEGER</constant></entry>
  251. <entry>any</entry>
  252. <entry>any</entry>
  253. <entry>any</entry>
  254. <entry>An integer-valued control ranging from minimum to
  255. maximum inclusive. The step value indicates the increment between
  256. values which are actually different on the hardware.</entry>
  257. </row>
  258. <row>
  259. <entry><constant>V4L2_CTRL_TYPE_BOOLEAN</constant></entry>
  260. <entry>0</entry>
  261. <entry>1</entry>
  262. <entry>1</entry>
  263. <entry>A boolean-valued control. Zero corresponds to
  264. "disabled", and one means "enabled".</entry>
  265. </row>
  266. <row>
  267. <entry><constant>V4L2_CTRL_TYPE_MENU</constant></entry>
  268. <entry>0</entry>
  269. <entry>1</entry>
  270. <entry>N-1</entry>
  271. <entry>The control has a menu of N choices. The names of
  272. the menu items can be enumerated with the
  273. <constant>VIDIOC_QUERYMENU</constant> ioctl.</entry>
  274. </row>
  275. <row>
  276. <entry><constant>V4L2_CTRL_TYPE_BUTTON</constant></entry>
  277. <entry>0</entry>
  278. <entry>0</entry>
  279. <entry>0</entry>
  280. <entry>A control which performs an action when set.
  281. Drivers must ignore the value passed with
  282. <constant>VIDIOC_S_CTRL</constant> and return an &EINVAL; on a
  283. <constant>VIDIOC_G_CTRL</constant> attempt.</entry>
  284. </row>
  285. <row>
  286. <entry><constant>V4L2_CTRL_TYPE_INTEGER64</constant></entry>
  287. <entry>n/a</entry>
  288. <entry>n/a</entry>
  289. <entry>n/a</entry>
  290. <entry>A 64-bit integer valued control. Minimum, maximum
  291. and step size cannot be queried.</entry>
  292. </row>
  293. <row>
  294. <entry><constant>V4L2_CTRL_TYPE_STRING</constant></entry>
  295. <entry>&ge; 0</entry>
  296. <entry>&ge; 1</entry>
  297. <entry>&ge; 0</entry>
  298. <entry>The minimum and maximum string lengths. The step size
  299. means that the string must be (minimum + N * step) characters long for
  300. N &ge; 0. These lengths do not include the terminating zero, so in order to
  301. pass a string of length 8 to &VIDIOC-S-EXT-CTRLS; you need to set the
  302. <structfield>size</structfield> field of &v4l2-ext-control; to 9. For &VIDIOC-G-EXT-CTRLS; you can
  303. set the <structfield>size</structfield> field to <structfield>maximum</structfield> + 1.
  304. Which character encoding is used will depend on the string control itself and
  305. should be part of the control documentation.</entry>
  306. </row>
  307. <row>
  308. <entry><constant>V4L2_CTRL_TYPE_CTRL_CLASS</constant></entry>
  309. <entry>n/a</entry>
  310. <entry>n/a</entry>
  311. <entry>n/a</entry>
  312. <entry>This is not a control. When
  313. <constant>VIDIOC_QUERYCTRL</constant> is called with a control ID
  314. equal to a control class code (see <xref linkend="ctrl-class" />), the
  315. ioctl returns the name of the control class and this control type.
  316. Older drivers which do not support this feature return an
  317. &EINVAL;.</entry>
  318. </row>
  319. </tbody>
  320. </tgroup>
  321. </table>
  322. <table pgwide="1" frame="none" id="control-flags">
  323. <title>Control Flags</title>
  324. <tgroup cols="3">
  325. &cs-def;
  326. <tbody valign="top">
  327. <row>
  328. <entry><constant>V4L2_CTRL_FLAG_DISABLED</constant></entry>
  329. <entry>0x0001</entry>
  330. <entry>This control is permanently disabled and should be
  331. ignored by the application. Any attempt to change the control will
  332. result in an &EINVAL;.</entry>
  333. </row>
  334. <row>
  335. <entry><constant>V4L2_CTRL_FLAG_GRABBED</constant></entry>
  336. <entry>0x0002</entry>
  337. <entry>This control is temporarily unchangeable, for
  338. example because another application took over control of the
  339. respective resource. Such controls may be displayed specially in a
  340. user interface. Attempts to change the control may result in an
  341. &EBUSY;.</entry>
  342. </row>
  343. <row>
  344. <entry><constant>V4L2_CTRL_FLAG_READ_ONLY</constant></entry>
  345. <entry>0x0004</entry>
  346. <entry>This control is permanently readable only. Any
  347. attempt to change the control will result in an &EINVAL;.</entry>
  348. </row>
  349. <row>
  350. <entry><constant>V4L2_CTRL_FLAG_UPDATE</constant></entry>
  351. <entry>0x0008</entry>
  352. <entry>A hint that changing this control may affect the
  353. value of other controls within the same control class. Applications
  354. should update their user interface accordingly.</entry>
  355. </row>
  356. <row>
  357. <entry><constant>V4L2_CTRL_FLAG_INACTIVE</constant></entry>
  358. <entry>0x0010</entry>
  359. <entry>This control is not applicable to the current
  360. configuration and should be displayed accordingly in a user interface.
  361. For example the flag may be set on a MPEG audio level 2 bitrate
  362. control when MPEG audio encoding level 1 was selected with another
  363. control.</entry>
  364. </row>
  365. <row>
  366. <entry><constant>V4L2_CTRL_FLAG_SLIDER</constant></entry>
  367. <entry>0x0020</entry>
  368. <entry>A hint that this control is best represented as a
  369. slider-like element in a user interface.</entry>
  370. </row>
  371. <row>
  372. <entry><constant>V4L2_CTRL_FLAG_WRITE_ONLY</constant></entry>
  373. <entry>0x0040</entry>
  374. <entry>This control is permanently writable only. Any
  375. attempt to read the control will result in an &EACCES; error code. This
  376. flag is typically present for relative controls or action controls where
  377. writing a value will cause the device to carry out a given action
  378. (&eg; motor control) but no meaningful value can be returned.</entry>
  379. </row>
  380. </tbody>
  381. </tgroup>
  382. </table>
  383. </refsect1>
  384. <refsect1>
  385. &return-value;
  386. <variablelist>
  387. <varlistentry>
  388. <term><errorcode>EINVAL</errorcode></term>
  389. <listitem>
  390. <para>The &v4l2-queryctrl; <structfield>id</structfield>
  391. is invalid. The &v4l2-querymenu; <structfield>id</structfield> or
  392. <structfield>index</structfield> is invalid.</para>
  393. </listitem>
  394. </varlistentry>
  395. <varlistentry>
  396. <term><errorcode>EACCES</errorcode></term>
  397. <listitem>
  398. <para>An attempt was made to read a write-only control.</para>
  399. </listitem>
  400. </varlistentry>
  401. </variablelist>
  402. </refsect1>
  403. </refentry>
  404. <!--
  405. Local Variables:
  406. mode: sgml
  407. sgml-parent-document: "v4l2.sgml"
  408. indent-tabs-mode: nil
  409. End:
  410. -->