18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 28c2ecf20Sopenharmony_ci.. c:namespace:: V4L 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci.. _VIDIOC_QUERYCTRL: 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci******************************************************************* 78c2ecf20Sopenharmony_ciioctls VIDIOC_QUERYCTRL, VIDIOC_QUERY_EXT_CTRL and VIDIOC_QUERYMENU 88c2ecf20Sopenharmony_ci******************************************************************* 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ciName 118c2ecf20Sopenharmony_ci==== 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ciVIDIOC_QUERYCTRL - VIDIOC_QUERY_EXT_CTRL - VIDIOC_QUERYMENU - Enumerate controls and menu control items 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ciSynopsis 168c2ecf20Sopenharmony_ci======== 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci``int ioctl(int fd, int VIDIOC_QUERYCTRL, struct v4l2_queryctrl *argp)`` 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci.. c:macro:: VIDIOC_QUERY_EXT_CTRL 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci``int ioctl(int fd, VIDIOC_QUERY_EXT_CTRL, struct v4l2_query_ext_ctrl *argp)`` 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci.. c:macro:: VIDIOC_QUERYMENU 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci``int ioctl(int fd, VIDIOC_QUERYMENU, struct v4l2_querymenu *argp)`` 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ciArguments 298c2ecf20Sopenharmony_ci========= 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci``fd`` 328c2ecf20Sopenharmony_ci File descriptor returned by :c:func:`open()`. 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci``argp`` 358c2ecf20Sopenharmony_ci Pointer to struct :c:type:`v4l2_queryctrl`, :c:type:`v4l2_query_ext_ctrl` 368c2ecf20Sopenharmony_ci or :c:type:`v4l2_querymenu` (depending on the ioctl). 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ciDescription 398c2ecf20Sopenharmony_ci=========== 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ciTo query the attributes of a control applications set the ``id`` field 428c2ecf20Sopenharmony_ciof a struct :ref:`v4l2_queryctrl <v4l2-queryctrl>` and call the 438c2ecf20Sopenharmony_ci``VIDIOC_QUERYCTRL`` ioctl with a pointer to this structure. The driver 448c2ecf20Sopenharmony_cifills the rest of the structure or returns an ``EINVAL`` error code when the 458c2ecf20Sopenharmony_ci``id`` is invalid. 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ciIt is possible to enumerate controls by calling ``VIDIOC_QUERYCTRL`` 488c2ecf20Sopenharmony_ciwith successive ``id`` values starting from ``V4L2_CID_BASE`` up to and 498c2ecf20Sopenharmony_ciexclusive ``V4L2_CID_LASTP1``. Drivers may return ``EINVAL`` if a control in 508c2ecf20Sopenharmony_cithis range is not supported. Further applications can enumerate private 518c2ecf20Sopenharmony_cicontrols, which are not defined in this specification, by starting at 528c2ecf20Sopenharmony_ci``V4L2_CID_PRIVATE_BASE`` and incrementing ``id`` until the driver 538c2ecf20Sopenharmony_cireturns ``EINVAL``. 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ciIn both cases, when the driver sets the ``V4L2_CTRL_FLAG_DISABLED`` flag 568c2ecf20Sopenharmony_ciin the ``flags`` field this control is permanently disabled and should 578c2ecf20Sopenharmony_cibe ignored by the application. [#f1]_ 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ciWhen the application ORs ``id`` with ``V4L2_CTRL_FLAG_NEXT_CTRL`` the 608c2ecf20Sopenharmony_cidriver returns the next supported non-compound control, or ``EINVAL`` if 618c2ecf20Sopenharmony_cithere is none. In addition, the ``V4L2_CTRL_FLAG_NEXT_COMPOUND`` flag 628c2ecf20Sopenharmony_cican be specified to enumerate all compound controls (i.e. controls with 638c2ecf20Sopenharmony_citype ≥ ``V4L2_CTRL_COMPOUND_TYPES`` and/or array control, in other words 648c2ecf20Sopenharmony_cicontrols that contain more than one value). Specify both 658c2ecf20Sopenharmony_ci``V4L2_CTRL_FLAG_NEXT_CTRL`` and ``V4L2_CTRL_FLAG_NEXT_COMPOUND`` in 668c2ecf20Sopenharmony_ciorder to enumerate all controls, compound or not. Drivers which do not 678c2ecf20Sopenharmony_cisupport these flags yet always return ``EINVAL``. 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ciThe ``VIDIOC_QUERY_EXT_CTRL`` ioctl was introduced in order to better 708c2ecf20Sopenharmony_cisupport controls that can use compound types, and to expose additional 718c2ecf20Sopenharmony_cicontrol information that cannot be returned in struct 728c2ecf20Sopenharmony_ci:ref:`v4l2_queryctrl <v4l2-queryctrl>` since that structure is full. 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci``VIDIOC_QUERY_EXT_CTRL`` is used in the same way as 758c2ecf20Sopenharmony_ci``VIDIOC_QUERYCTRL``, except that the ``reserved`` array must be zeroed 768c2ecf20Sopenharmony_cias well. 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ciAdditional information is required for menu controls: the names of the 798c2ecf20Sopenharmony_cimenu items. To query them applications set the ``id`` and ``index`` 808c2ecf20Sopenharmony_cifields of struct :ref:`v4l2_querymenu <v4l2-querymenu>` and call the 818c2ecf20Sopenharmony_ci``VIDIOC_QUERYMENU`` ioctl with a pointer to this structure. The driver 828c2ecf20Sopenharmony_cifills the rest of the structure or returns an ``EINVAL`` error code when the 838c2ecf20Sopenharmony_ci``id`` or ``index`` is invalid. Menu items are enumerated by calling 848c2ecf20Sopenharmony_ci``VIDIOC_QUERYMENU`` with successive ``index`` values from struct 858c2ecf20Sopenharmony_ci:ref:`v4l2_queryctrl <v4l2-queryctrl>` ``minimum`` to ``maximum``, 868c2ecf20Sopenharmony_ciinclusive. 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci.. note:: 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci It is possible for ``VIDIOC_QUERYMENU`` to return 918c2ecf20Sopenharmony_ci an ``EINVAL`` error code for some indices between ``minimum`` and 928c2ecf20Sopenharmony_ci ``maximum``. In that case that particular menu item is not supported by 938c2ecf20Sopenharmony_ci this driver. Also note that the ``minimum`` value is not necessarily 0. 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ciSee also the examples in :ref:`control`. 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{1.2cm}|p{3.6cm}|p{12.7cm}| 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci.. _v4l2-queryctrl: 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci.. cssclass:: longtable 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci.. flat-table:: struct v4l2_queryctrl 1048c2ecf20Sopenharmony_ci :header-rows: 0 1058c2ecf20Sopenharmony_ci :stub-columns: 0 1068c2ecf20Sopenharmony_ci :widths: 1 1 2 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_ci * - __u32 1098c2ecf20Sopenharmony_ci - ``id`` 1108c2ecf20Sopenharmony_ci - Identifies the control, set by the application. See 1118c2ecf20Sopenharmony_ci :ref:`control-id` for predefined IDs. When the ID is ORed with 1128c2ecf20Sopenharmony_ci V4L2_CTRL_FLAG_NEXT_CTRL the driver clears the flag and 1138c2ecf20Sopenharmony_ci returns the first control with a higher ID. Drivers which do not 1148c2ecf20Sopenharmony_ci support this flag yet always return an ``EINVAL`` error code. 1158c2ecf20Sopenharmony_ci * - __u32 1168c2ecf20Sopenharmony_ci - ``type`` 1178c2ecf20Sopenharmony_ci - Type of control, see :c:type:`v4l2_ctrl_type`. 1188c2ecf20Sopenharmony_ci * - __u8 1198c2ecf20Sopenharmony_ci - ``name``\ [32] 1208c2ecf20Sopenharmony_ci - Name of the control, a NUL-terminated ASCII string. This 1218c2ecf20Sopenharmony_ci information is intended for the user. 1228c2ecf20Sopenharmony_ci * - __s32 1238c2ecf20Sopenharmony_ci - ``minimum`` 1248c2ecf20Sopenharmony_ci - Minimum value, inclusive. This field gives a lower bound for the 1258c2ecf20Sopenharmony_ci control. See enum :c:type:`v4l2_ctrl_type` how 1268c2ecf20Sopenharmony_ci the minimum value is to be used for each possible control type. 1278c2ecf20Sopenharmony_ci Note that this a signed 32-bit value. 1288c2ecf20Sopenharmony_ci * - __s32 1298c2ecf20Sopenharmony_ci - ``maximum`` 1308c2ecf20Sopenharmony_ci - Maximum value, inclusive. This field gives an upper bound for the 1318c2ecf20Sopenharmony_ci control. See enum :c:type:`v4l2_ctrl_type` how 1328c2ecf20Sopenharmony_ci the maximum value is to be used for each possible control type. 1338c2ecf20Sopenharmony_ci Note that this a signed 32-bit value. 1348c2ecf20Sopenharmony_ci * - __s32 1358c2ecf20Sopenharmony_ci - ``step`` 1368c2ecf20Sopenharmony_ci - This field gives a step size for the control. See enum 1378c2ecf20Sopenharmony_ci :c:type:`v4l2_ctrl_type` how the step value is 1388c2ecf20Sopenharmony_ci to be used for each possible control type. Note that this an 1398c2ecf20Sopenharmony_ci unsigned 32-bit value. 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_ci Generally drivers should not scale hardware control values. It may 1428c2ecf20Sopenharmony_ci be necessary for example when the ``name`` or ``id`` imply a 1438c2ecf20Sopenharmony_ci particular unit and the hardware actually accepts only multiples 1448c2ecf20Sopenharmony_ci of said unit. If so, drivers must take care values are properly 1458c2ecf20Sopenharmony_ci rounded when scaling, such that errors will not accumulate on 1468c2ecf20Sopenharmony_ci repeated read-write cycles. 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_ci This field gives the smallest change of an integer control 1498c2ecf20Sopenharmony_ci actually affecting hardware. Often the information is needed when 1508c2ecf20Sopenharmony_ci the user can change controls by keyboard or GUI buttons, rather 1518c2ecf20Sopenharmony_ci than a slider. When for example a hardware register accepts values 1528c2ecf20Sopenharmony_ci 0-511 and the driver reports 0-65535, step should be 128. 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ci Note that although signed, the step value is supposed to be always 1558c2ecf20Sopenharmony_ci positive. 1568c2ecf20Sopenharmony_ci * - __s32 1578c2ecf20Sopenharmony_ci - ``default_value`` 1588c2ecf20Sopenharmony_ci - The default value of a ``V4L2_CTRL_TYPE_INTEGER``, ``_BOOLEAN``, 1598c2ecf20Sopenharmony_ci ``_BITMASK``, ``_MENU`` or ``_INTEGER_MENU`` control. Not valid 1608c2ecf20Sopenharmony_ci for other types of controls. 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci .. note:: 1638c2ecf20Sopenharmony_ci 1648c2ecf20Sopenharmony_ci Drivers reset controls to their default value only when 1658c2ecf20Sopenharmony_ci the driver is first loaded, never afterwards. 1668c2ecf20Sopenharmony_ci * - __u32 1678c2ecf20Sopenharmony_ci - ``flags`` 1688c2ecf20Sopenharmony_ci - Control flags, see :ref:`control-flags`. 1698c2ecf20Sopenharmony_ci * - __u32 1708c2ecf20Sopenharmony_ci - ``reserved``\ [2] 1718c2ecf20Sopenharmony_ci - Reserved for future extensions. Drivers must set the array to 1728c2ecf20Sopenharmony_ci zero. 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_ci 1758c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{1.2cm}|p{5.0cm}|p{11.3cm}| 1768c2ecf20Sopenharmony_ci 1778c2ecf20Sopenharmony_ci.. _v4l2-query-ext-ctrl: 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_ci.. cssclass:: longtable 1808c2ecf20Sopenharmony_ci 1818c2ecf20Sopenharmony_ci.. flat-table:: struct v4l2_query_ext_ctrl 1828c2ecf20Sopenharmony_ci :header-rows: 0 1838c2ecf20Sopenharmony_ci :stub-columns: 0 1848c2ecf20Sopenharmony_ci :widths: 1 1 2 1858c2ecf20Sopenharmony_ci 1868c2ecf20Sopenharmony_ci * - __u32 1878c2ecf20Sopenharmony_ci - ``id`` 1888c2ecf20Sopenharmony_ci - Identifies the control, set by the application. See 1898c2ecf20Sopenharmony_ci :ref:`control-id` for predefined IDs. When the ID is ORed with 1908c2ecf20Sopenharmony_ci ``V4L2_CTRL_FLAG_NEXT_CTRL`` the driver clears the flag and 1918c2ecf20Sopenharmony_ci returns the first non-compound control with a higher ID. When the 1928c2ecf20Sopenharmony_ci ID is ORed with ``V4L2_CTRL_FLAG_NEXT_COMPOUND`` the driver clears 1938c2ecf20Sopenharmony_ci the flag and returns the first compound control with a higher ID. 1948c2ecf20Sopenharmony_ci Set both to get the first control (compound or not) with a higher 1958c2ecf20Sopenharmony_ci ID. 1968c2ecf20Sopenharmony_ci * - __u32 1978c2ecf20Sopenharmony_ci - ``type`` 1988c2ecf20Sopenharmony_ci - Type of control, see :c:type:`v4l2_ctrl_type`. 1998c2ecf20Sopenharmony_ci * - char 2008c2ecf20Sopenharmony_ci - ``name``\ [32] 2018c2ecf20Sopenharmony_ci - Name of the control, a NUL-terminated ASCII string. This 2028c2ecf20Sopenharmony_ci information is intended for the user. 2038c2ecf20Sopenharmony_ci * - __s64 2048c2ecf20Sopenharmony_ci - ``minimum`` 2058c2ecf20Sopenharmony_ci - Minimum value, inclusive. This field gives a lower bound for the 2068c2ecf20Sopenharmony_ci control. See enum :c:type:`v4l2_ctrl_type` how 2078c2ecf20Sopenharmony_ci the minimum value is to be used for each possible control type. 2088c2ecf20Sopenharmony_ci Note that this a signed 64-bit value. 2098c2ecf20Sopenharmony_ci * - __s64 2108c2ecf20Sopenharmony_ci - ``maximum`` 2118c2ecf20Sopenharmony_ci - Maximum value, inclusive. This field gives an upper bound for the 2128c2ecf20Sopenharmony_ci control. See enum :c:type:`v4l2_ctrl_type` how 2138c2ecf20Sopenharmony_ci the maximum value is to be used for each possible control type. 2148c2ecf20Sopenharmony_ci Note that this a signed 64-bit value. 2158c2ecf20Sopenharmony_ci * - __u64 2168c2ecf20Sopenharmony_ci - ``step`` 2178c2ecf20Sopenharmony_ci - This field gives a step size for the control. See enum 2188c2ecf20Sopenharmony_ci :c:type:`v4l2_ctrl_type` how the step value is 2198c2ecf20Sopenharmony_ci to be used for each possible control type. Note that this an 2208c2ecf20Sopenharmony_ci unsigned 64-bit value. 2218c2ecf20Sopenharmony_ci 2228c2ecf20Sopenharmony_ci Generally drivers should not scale hardware control values. It may 2238c2ecf20Sopenharmony_ci be necessary for example when the ``name`` or ``id`` imply a 2248c2ecf20Sopenharmony_ci particular unit and the hardware actually accepts only multiples 2258c2ecf20Sopenharmony_ci of said unit. If so, drivers must take care values are properly 2268c2ecf20Sopenharmony_ci rounded when scaling, such that errors will not accumulate on 2278c2ecf20Sopenharmony_ci repeated read-write cycles. 2288c2ecf20Sopenharmony_ci 2298c2ecf20Sopenharmony_ci This field gives the smallest change of an integer control 2308c2ecf20Sopenharmony_ci actually affecting hardware. Often the information is needed when 2318c2ecf20Sopenharmony_ci the user can change controls by keyboard or GUI buttons, rather 2328c2ecf20Sopenharmony_ci than a slider. When for example a hardware register accepts values 2338c2ecf20Sopenharmony_ci 0-511 and the driver reports 0-65535, step should be 128. 2348c2ecf20Sopenharmony_ci * - __s64 2358c2ecf20Sopenharmony_ci - ``default_value`` 2368c2ecf20Sopenharmony_ci - The default value of a ``V4L2_CTRL_TYPE_INTEGER``, ``_INTEGER64``, 2378c2ecf20Sopenharmony_ci ``_BOOLEAN``, ``_BITMASK``, ``_MENU``, ``_INTEGER_MENU``, ``_U8`` 2388c2ecf20Sopenharmony_ci or ``_U16`` control. Not valid for other types of controls. 2398c2ecf20Sopenharmony_ci 2408c2ecf20Sopenharmony_ci .. note:: 2418c2ecf20Sopenharmony_ci 2428c2ecf20Sopenharmony_ci Drivers reset controls to their default value only when 2438c2ecf20Sopenharmony_ci the driver is first loaded, never afterwards. 2448c2ecf20Sopenharmony_ci * - __u32 2458c2ecf20Sopenharmony_ci - ``flags`` 2468c2ecf20Sopenharmony_ci - Control flags, see :ref:`control-flags`. 2478c2ecf20Sopenharmony_ci * - __u32 2488c2ecf20Sopenharmony_ci - ``elem_size`` 2498c2ecf20Sopenharmony_ci - The size in bytes of a single element of the array. Given a char 2508c2ecf20Sopenharmony_ci pointer ``p`` to a 3-dimensional array you can find the position 2518c2ecf20Sopenharmony_ci of cell ``(z, y, x)`` as follows: 2528c2ecf20Sopenharmony_ci ``p + ((z * dims[1] + y) * dims[0] + x) * elem_size``. 2538c2ecf20Sopenharmony_ci ``elem_size`` is always valid, also when the control isn't an 2548c2ecf20Sopenharmony_ci array. For string controls ``elem_size`` is equal to 2558c2ecf20Sopenharmony_ci ``maximum + 1``. 2568c2ecf20Sopenharmony_ci * - __u32 2578c2ecf20Sopenharmony_ci - ``elems`` 2588c2ecf20Sopenharmony_ci - The number of elements in the N-dimensional array. If this control 2598c2ecf20Sopenharmony_ci is not an array, then ``elems`` is 1. The ``elems`` field can 2608c2ecf20Sopenharmony_ci never be 0. 2618c2ecf20Sopenharmony_ci * - __u32 2628c2ecf20Sopenharmony_ci - ``nr_of_dims`` 2638c2ecf20Sopenharmony_ci - The number of dimension in the N-dimensional array. If this 2648c2ecf20Sopenharmony_ci control is not an array, then this field is 0. 2658c2ecf20Sopenharmony_ci * - __u32 2668c2ecf20Sopenharmony_ci - ``dims[V4L2_CTRL_MAX_DIMS]`` 2678c2ecf20Sopenharmony_ci - The size of each dimension. The first ``nr_of_dims`` elements of 2688c2ecf20Sopenharmony_ci this array must be non-zero, all remaining elements must be zero. 2698c2ecf20Sopenharmony_ci * - __u32 2708c2ecf20Sopenharmony_ci - ``reserved``\ [32] 2718c2ecf20Sopenharmony_ci - Reserved for future extensions. Applications and drivers must set 2728c2ecf20Sopenharmony_ci the array to zero. 2738c2ecf20Sopenharmony_ci 2748c2ecf20Sopenharmony_ci 2758c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{1.2cm}|p{1.0cm}|p{1.7cm}|p{13.0cm}| 2768c2ecf20Sopenharmony_ci 2778c2ecf20Sopenharmony_ci.. _v4l2-querymenu: 2788c2ecf20Sopenharmony_ci 2798c2ecf20Sopenharmony_ci.. flat-table:: struct v4l2_querymenu 2808c2ecf20Sopenharmony_ci :header-rows: 0 2818c2ecf20Sopenharmony_ci :stub-columns: 0 2828c2ecf20Sopenharmony_ci :widths: 1 1 2 2838c2ecf20Sopenharmony_ci 2848c2ecf20Sopenharmony_ci * - __u32 2858c2ecf20Sopenharmony_ci - ``id`` 2868c2ecf20Sopenharmony_ci - Identifies the control, set by the application from the respective 2878c2ecf20Sopenharmony_ci struct :ref:`v4l2_queryctrl <v4l2-queryctrl>` ``id``. 2888c2ecf20Sopenharmony_ci * - __u32 2898c2ecf20Sopenharmony_ci - ``index`` 2908c2ecf20Sopenharmony_ci - Index of the menu item, starting at zero, set by the application. 2918c2ecf20Sopenharmony_ci * - union { 2928c2ecf20Sopenharmony_ci - (anonymous) 2938c2ecf20Sopenharmony_ci * - __u8 2948c2ecf20Sopenharmony_ci - ``name``\ [32] 2958c2ecf20Sopenharmony_ci - Name of the menu item, a NUL-terminated ASCII string. This 2968c2ecf20Sopenharmony_ci information is intended for the user. This field is valid for 2978c2ecf20Sopenharmony_ci ``V4L2_CTRL_TYPE_MENU`` type controls. 2988c2ecf20Sopenharmony_ci * - __s64 2998c2ecf20Sopenharmony_ci - ``value`` 3008c2ecf20Sopenharmony_ci - Value of the integer menu item. This field is valid for 3018c2ecf20Sopenharmony_ci ``V4L2_CTRL_TYPE_INTEGER_MENU`` type controls. 3028c2ecf20Sopenharmony_ci * - } 3038c2ecf20Sopenharmony_ci - 3048c2ecf20Sopenharmony_ci * - __u32 3058c2ecf20Sopenharmony_ci - ``reserved`` 3068c2ecf20Sopenharmony_ci - Reserved for future extensions. Drivers must set the array to 3078c2ecf20Sopenharmony_ci zero. 3088c2ecf20Sopenharmony_ci 3098c2ecf20Sopenharmony_ci 3108c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{5.8cm}|p{1.4cm}|p{1.0cm}|p{1.4cm}|p{6.9cm}| 3118c2ecf20Sopenharmony_ci 3128c2ecf20Sopenharmony_ci.. c:type:: v4l2_ctrl_type 3138c2ecf20Sopenharmony_ci 3148c2ecf20Sopenharmony_ci.. cssclass:: longtable 3158c2ecf20Sopenharmony_ci 3168c2ecf20Sopenharmony_ci.. flat-table:: enum v4l2_ctrl_type 3178c2ecf20Sopenharmony_ci :header-rows: 1 3188c2ecf20Sopenharmony_ci :stub-columns: 0 3198c2ecf20Sopenharmony_ci :widths: 30 5 5 5 55 3208c2ecf20Sopenharmony_ci 3218c2ecf20Sopenharmony_ci * - Type 3228c2ecf20Sopenharmony_ci - ``minimum`` 3238c2ecf20Sopenharmony_ci - ``step`` 3248c2ecf20Sopenharmony_ci - ``maximum`` 3258c2ecf20Sopenharmony_ci - Description 3268c2ecf20Sopenharmony_ci * - ``V4L2_CTRL_TYPE_INTEGER`` 3278c2ecf20Sopenharmony_ci - any 3288c2ecf20Sopenharmony_ci - any 3298c2ecf20Sopenharmony_ci - any 3308c2ecf20Sopenharmony_ci - An integer-valued control ranging from minimum to maximum 3318c2ecf20Sopenharmony_ci inclusive. The step value indicates the increment between values. 3328c2ecf20Sopenharmony_ci * - ``V4L2_CTRL_TYPE_BOOLEAN`` 3338c2ecf20Sopenharmony_ci - 0 3348c2ecf20Sopenharmony_ci - 1 3358c2ecf20Sopenharmony_ci - 1 3368c2ecf20Sopenharmony_ci - A boolean-valued control. Zero corresponds to "disabled", and one 3378c2ecf20Sopenharmony_ci means "enabled". 3388c2ecf20Sopenharmony_ci * - ``V4L2_CTRL_TYPE_MENU`` 3398c2ecf20Sopenharmony_ci - ≥ 0 3408c2ecf20Sopenharmony_ci - 1 3418c2ecf20Sopenharmony_ci - N-1 3428c2ecf20Sopenharmony_ci - The control has a menu of N choices. The names of the menu items 3438c2ecf20Sopenharmony_ci can be enumerated with the ``VIDIOC_QUERYMENU`` ioctl. 3448c2ecf20Sopenharmony_ci * - ``V4L2_CTRL_TYPE_INTEGER_MENU`` 3458c2ecf20Sopenharmony_ci - ≥ 0 3468c2ecf20Sopenharmony_ci - 1 3478c2ecf20Sopenharmony_ci - N-1 3488c2ecf20Sopenharmony_ci - The control has a menu of N choices. The values of the menu items 3498c2ecf20Sopenharmony_ci can be enumerated with the ``VIDIOC_QUERYMENU`` ioctl. This is 3508c2ecf20Sopenharmony_ci similar to ``V4L2_CTRL_TYPE_MENU`` except that instead of strings, 3518c2ecf20Sopenharmony_ci the menu items are signed 64-bit integers. 3528c2ecf20Sopenharmony_ci * - ``V4L2_CTRL_TYPE_BITMASK`` 3538c2ecf20Sopenharmony_ci - 0 3548c2ecf20Sopenharmony_ci - n/a 3558c2ecf20Sopenharmony_ci - any 3568c2ecf20Sopenharmony_ci - A bitmask field. The maximum value is the set of bits that can be 3578c2ecf20Sopenharmony_ci used, all other bits are to be 0. The maximum value is interpreted 3588c2ecf20Sopenharmony_ci as a __u32, allowing the use of bit 31 in the bitmask. 3598c2ecf20Sopenharmony_ci * - ``V4L2_CTRL_TYPE_BUTTON`` 3608c2ecf20Sopenharmony_ci - 0 3618c2ecf20Sopenharmony_ci - 0 3628c2ecf20Sopenharmony_ci - 0 3638c2ecf20Sopenharmony_ci - A control which performs an action when set. Drivers must ignore 3648c2ecf20Sopenharmony_ci the value passed with ``VIDIOC_S_CTRL`` and return an ``EACCES`` error 3658c2ecf20Sopenharmony_ci code on a ``VIDIOC_G_CTRL`` attempt. 3668c2ecf20Sopenharmony_ci * - ``V4L2_CTRL_TYPE_INTEGER64`` 3678c2ecf20Sopenharmony_ci - any 3688c2ecf20Sopenharmony_ci - any 3698c2ecf20Sopenharmony_ci - any 3708c2ecf20Sopenharmony_ci - A 64-bit integer valued control. Minimum, maximum and step size 3718c2ecf20Sopenharmony_ci cannot be queried using ``VIDIOC_QUERYCTRL``. Only 3728c2ecf20Sopenharmony_ci ``VIDIOC_QUERY_EXT_CTRL`` can retrieve the 64-bit min/max/step 3738c2ecf20Sopenharmony_ci values, they should be interpreted as n/a when using 3748c2ecf20Sopenharmony_ci ``VIDIOC_QUERYCTRL``. 3758c2ecf20Sopenharmony_ci * - ``V4L2_CTRL_TYPE_STRING`` 3768c2ecf20Sopenharmony_ci - ≥ 0 3778c2ecf20Sopenharmony_ci - ≥ 1 3788c2ecf20Sopenharmony_ci - ≥ 0 3798c2ecf20Sopenharmony_ci - The minimum and maximum string lengths. The step size means that 3808c2ecf20Sopenharmony_ci the string must be (minimum + N * step) characters long for N ≥ 0. 3818c2ecf20Sopenharmony_ci These lengths do not include the terminating zero, so in order to 3828c2ecf20Sopenharmony_ci pass a string of length 8 to 3838c2ecf20Sopenharmony_ci :ref:`VIDIOC_S_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` you need to 3848c2ecf20Sopenharmony_ci set the ``size`` field of struct 3858c2ecf20Sopenharmony_ci :c:type:`v4l2_ext_control` to 9. For 3868c2ecf20Sopenharmony_ci :ref:`VIDIOC_G_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` you can set 3878c2ecf20Sopenharmony_ci the ``size`` field to ``maximum`` + 1. Which character encoding is 3888c2ecf20Sopenharmony_ci used will depend on the string control itself and should be part 3898c2ecf20Sopenharmony_ci of the control documentation. 3908c2ecf20Sopenharmony_ci * - ``V4L2_CTRL_TYPE_CTRL_CLASS`` 3918c2ecf20Sopenharmony_ci - n/a 3928c2ecf20Sopenharmony_ci - n/a 3938c2ecf20Sopenharmony_ci - n/a 3948c2ecf20Sopenharmony_ci - This is not a control. When ``VIDIOC_QUERYCTRL`` is called with a 3958c2ecf20Sopenharmony_ci control ID equal to a control class code (see :ref:`ctrl-class`) 3968c2ecf20Sopenharmony_ci + 1, the ioctl returns the name of the control class and this 3978c2ecf20Sopenharmony_ci control type. Older drivers which do not support this feature 3988c2ecf20Sopenharmony_ci return an ``EINVAL`` error code. 3998c2ecf20Sopenharmony_ci * - ``V4L2_CTRL_TYPE_U8`` 4008c2ecf20Sopenharmony_ci - any 4018c2ecf20Sopenharmony_ci - any 4028c2ecf20Sopenharmony_ci - any 4038c2ecf20Sopenharmony_ci - An unsigned 8-bit valued control ranging from minimum to maximum 4048c2ecf20Sopenharmony_ci inclusive. The step value indicates the increment between values. 4058c2ecf20Sopenharmony_ci * - ``V4L2_CTRL_TYPE_U16`` 4068c2ecf20Sopenharmony_ci - any 4078c2ecf20Sopenharmony_ci - any 4088c2ecf20Sopenharmony_ci - any 4098c2ecf20Sopenharmony_ci - An unsigned 16-bit valued control ranging from minimum to maximum 4108c2ecf20Sopenharmony_ci inclusive. The step value indicates the increment between values. 4118c2ecf20Sopenharmony_ci * - ``V4L2_CTRL_TYPE_U32`` 4128c2ecf20Sopenharmony_ci - any 4138c2ecf20Sopenharmony_ci - any 4148c2ecf20Sopenharmony_ci - any 4158c2ecf20Sopenharmony_ci - An unsigned 32-bit valued control ranging from minimum to maximum 4168c2ecf20Sopenharmony_ci inclusive. The step value indicates the increment between values. 4178c2ecf20Sopenharmony_ci * - ``V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS`` 4188c2ecf20Sopenharmony_ci - n/a 4198c2ecf20Sopenharmony_ci - n/a 4208c2ecf20Sopenharmony_ci - n/a 4218c2ecf20Sopenharmony_ci - A struct :c:type:`v4l2_ctrl_mpeg2_slice_params`, containing MPEG-2 4228c2ecf20Sopenharmony_ci slice parameters for stateless video decoders. 4238c2ecf20Sopenharmony_ci * - ``V4L2_CTRL_TYPE_MPEG2_QUANTIZATION`` 4248c2ecf20Sopenharmony_ci - n/a 4258c2ecf20Sopenharmony_ci - n/a 4268c2ecf20Sopenharmony_ci - n/a 4278c2ecf20Sopenharmony_ci - A struct :c:type:`v4l2_ctrl_mpeg2_quantization`, containing MPEG-2 4288c2ecf20Sopenharmony_ci quantization matrices for stateless video decoders. 4298c2ecf20Sopenharmony_ci * - ``V4L2_CTRL_TYPE_AREA`` 4308c2ecf20Sopenharmony_ci - n/a 4318c2ecf20Sopenharmony_ci - n/a 4328c2ecf20Sopenharmony_ci - n/a 4338c2ecf20Sopenharmony_ci - A struct :c:type:`v4l2_area`, containing the width and the height 4348c2ecf20Sopenharmony_ci of a rectangular area. Units depend on the use case. 4358c2ecf20Sopenharmony_ci * - ``V4L2_CTRL_TYPE_H264_SPS`` 4368c2ecf20Sopenharmony_ci - n/a 4378c2ecf20Sopenharmony_ci - n/a 4388c2ecf20Sopenharmony_ci - n/a 4398c2ecf20Sopenharmony_ci - A struct :c:type:`v4l2_ctrl_h264_sps`, containing H264 4408c2ecf20Sopenharmony_ci sequence parameters for stateless video decoders. 4418c2ecf20Sopenharmony_ci * - ``V4L2_CTRL_TYPE_H264_PPS`` 4428c2ecf20Sopenharmony_ci - n/a 4438c2ecf20Sopenharmony_ci - n/a 4448c2ecf20Sopenharmony_ci - n/a 4458c2ecf20Sopenharmony_ci - A struct :c:type:`v4l2_ctrl_h264_pps`, containing H264 4468c2ecf20Sopenharmony_ci picture parameters for stateless video decoders. 4478c2ecf20Sopenharmony_ci * - ``V4L2_CTRL_TYPE_H264_SCALING_MATRIX`` 4488c2ecf20Sopenharmony_ci - n/a 4498c2ecf20Sopenharmony_ci - n/a 4508c2ecf20Sopenharmony_ci - n/a 4518c2ecf20Sopenharmony_ci - A struct :c:type:`v4l2_ctrl_h264_scaling_matrix`, containing H264 4528c2ecf20Sopenharmony_ci scaling matrices for stateless video decoders. 4538c2ecf20Sopenharmony_ci * - ``V4L2_CTRL_TYPE_H264_SLICE_PARAMS`` 4548c2ecf20Sopenharmony_ci - n/a 4558c2ecf20Sopenharmony_ci - n/a 4568c2ecf20Sopenharmony_ci - n/a 4578c2ecf20Sopenharmony_ci - A struct :c:type:`v4l2_ctrl_h264_slice_params`, containing H264 4588c2ecf20Sopenharmony_ci slice parameters for stateless video decoders. 4598c2ecf20Sopenharmony_ci * - ``V4L2_CTRL_TYPE_H264_DECODE_PARAMS`` 4608c2ecf20Sopenharmony_ci - n/a 4618c2ecf20Sopenharmony_ci - n/a 4628c2ecf20Sopenharmony_ci - n/a 4638c2ecf20Sopenharmony_ci - A struct :c:type:`v4l2_ctrl_h264_decode_params`, containing H264 4648c2ecf20Sopenharmony_ci decode parameters for stateless video decoders. 4658c2ecf20Sopenharmony_ci * - ``V4L2_CTRL_TYPE_HEVC_SPS`` 4668c2ecf20Sopenharmony_ci - n/a 4678c2ecf20Sopenharmony_ci - n/a 4688c2ecf20Sopenharmony_ci - n/a 4698c2ecf20Sopenharmony_ci - A struct :c:type:`v4l2_ctrl_hevc_sps`, containing HEVC Sequence 4708c2ecf20Sopenharmony_ci Parameter Set for stateless video decoders. 4718c2ecf20Sopenharmony_ci * - ``V4L2_CTRL_TYPE_HEVC_PPS`` 4728c2ecf20Sopenharmony_ci - n/a 4738c2ecf20Sopenharmony_ci - n/a 4748c2ecf20Sopenharmony_ci - n/a 4758c2ecf20Sopenharmony_ci - A struct :c:type:`v4l2_ctrl_hevc_pps`, containing HEVC Picture 4768c2ecf20Sopenharmony_ci Parameter Set for stateless video decoders. 4778c2ecf20Sopenharmony_ci * - ``V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS`` 4788c2ecf20Sopenharmony_ci - n/a 4798c2ecf20Sopenharmony_ci - n/a 4808c2ecf20Sopenharmony_ci - n/a 4818c2ecf20Sopenharmony_ci - A struct :c:type:`v4l2_ctrl_hevc_slice_params`, containing HEVC 4828c2ecf20Sopenharmony_ci slice parameters for stateless video decoders. 4838c2ecf20Sopenharmony_ci 4848c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}| 4858c2ecf20Sopenharmony_ci 4868c2ecf20Sopenharmony_ci.. _control-flags: 4878c2ecf20Sopenharmony_ci 4888c2ecf20Sopenharmony_ci.. cssclass:: longtable 4898c2ecf20Sopenharmony_ci 4908c2ecf20Sopenharmony_ci.. flat-table:: Control Flags 4918c2ecf20Sopenharmony_ci :header-rows: 0 4928c2ecf20Sopenharmony_ci :stub-columns: 0 4938c2ecf20Sopenharmony_ci :widths: 3 1 4 4948c2ecf20Sopenharmony_ci 4958c2ecf20Sopenharmony_ci * - ``V4L2_CTRL_FLAG_DISABLED`` 4968c2ecf20Sopenharmony_ci - 0x0001 4978c2ecf20Sopenharmony_ci - This control is permanently disabled and should be ignored by the 4988c2ecf20Sopenharmony_ci application. Any attempt to change the control will result in an 4998c2ecf20Sopenharmony_ci ``EINVAL`` error code. 5008c2ecf20Sopenharmony_ci * - ``V4L2_CTRL_FLAG_GRABBED`` 5018c2ecf20Sopenharmony_ci - 0x0002 5028c2ecf20Sopenharmony_ci - This control is temporarily unchangeable, for example because 5038c2ecf20Sopenharmony_ci another application took over control of the respective resource. 5048c2ecf20Sopenharmony_ci Such controls may be displayed specially in a user interface. 5058c2ecf20Sopenharmony_ci Attempts to change the control may result in an ``EBUSY`` error code. 5068c2ecf20Sopenharmony_ci * - ``V4L2_CTRL_FLAG_READ_ONLY`` 5078c2ecf20Sopenharmony_ci - 0x0004 5088c2ecf20Sopenharmony_ci - This control is permanently readable only. Any attempt to change 5098c2ecf20Sopenharmony_ci the control will result in an ``EINVAL`` error code. 5108c2ecf20Sopenharmony_ci * - ``V4L2_CTRL_FLAG_UPDATE`` 5118c2ecf20Sopenharmony_ci - 0x0008 5128c2ecf20Sopenharmony_ci - A hint that changing this control may affect the value of other 5138c2ecf20Sopenharmony_ci controls within the same control class. Applications should update 5148c2ecf20Sopenharmony_ci their user interface accordingly. 5158c2ecf20Sopenharmony_ci * - ``V4L2_CTRL_FLAG_INACTIVE`` 5168c2ecf20Sopenharmony_ci - 0x0010 5178c2ecf20Sopenharmony_ci - This control is not applicable to the current configuration and 5188c2ecf20Sopenharmony_ci should be displayed accordingly in a user interface. For example 5198c2ecf20Sopenharmony_ci the flag may be set on a MPEG audio level 2 bitrate control when 5208c2ecf20Sopenharmony_ci MPEG audio encoding level 1 was selected with another control. 5218c2ecf20Sopenharmony_ci * - ``V4L2_CTRL_FLAG_SLIDER`` 5228c2ecf20Sopenharmony_ci - 0x0020 5238c2ecf20Sopenharmony_ci - A hint that this control is best represented as a slider-like 5248c2ecf20Sopenharmony_ci element in a user interface. 5258c2ecf20Sopenharmony_ci * - ``V4L2_CTRL_FLAG_WRITE_ONLY`` 5268c2ecf20Sopenharmony_ci - 0x0040 5278c2ecf20Sopenharmony_ci - This control is permanently writable only. Any attempt to read the 5288c2ecf20Sopenharmony_ci control will result in an ``EACCES`` error code error code. This flag 5298c2ecf20Sopenharmony_ci is typically present for relative controls or action controls 5308c2ecf20Sopenharmony_ci where writing a value will cause the device to carry out a given 5318c2ecf20Sopenharmony_ci action (e. g. motor control) but no meaningful value can be 5328c2ecf20Sopenharmony_ci returned. 5338c2ecf20Sopenharmony_ci * - ``V4L2_CTRL_FLAG_VOLATILE`` 5348c2ecf20Sopenharmony_ci - 0x0080 5358c2ecf20Sopenharmony_ci - This control is volatile, which means that the value of the 5368c2ecf20Sopenharmony_ci control changes continuously. A typical example would be the 5378c2ecf20Sopenharmony_ci current gain value if the device is in auto-gain mode. In such a 5388c2ecf20Sopenharmony_ci case the hardware calculates the gain value based on the lighting 5398c2ecf20Sopenharmony_ci conditions which can change over time. 5408c2ecf20Sopenharmony_ci 5418c2ecf20Sopenharmony_ci .. note:: 5428c2ecf20Sopenharmony_ci 5438c2ecf20Sopenharmony_ci Setting a new value for a volatile control will be ignored 5448c2ecf20Sopenharmony_ci unless 5458c2ecf20Sopenharmony_ci :ref:`V4L2_CTRL_FLAG_EXECUTE_ON_WRITE <FLAG_EXECUTE_ON_WRITE>` 5468c2ecf20Sopenharmony_ci is also set. 5478c2ecf20Sopenharmony_ci Setting a new value for a volatile control will *never* trigger a 5488c2ecf20Sopenharmony_ci :ref:`V4L2_EVENT_CTRL_CH_VALUE <ctrl-changes-flags>` event. 5498c2ecf20Sopenharmony_ci * - ``V4L2_CTRL_FLAG_HAS_PAYLOAD`` 5508c2ecf20Sopenharmony_ci - 0x0100 5518c2ecf20Sopenharmony_ci - This control has a pointer type, so its value has to be accessed 5528c2ecf20Sopenharmony_ci using one of the pointer fields of struct 5538c2ecf20Sopenharmony_ci :c:type:`v4l2_ext_control`. This flag is set 5548c2ecf20Sopenharmony_ci for controls that are an array, string, or have a compound type. 5558c2ecf20Sopenharmony_ci In all cases you have to set a pointer to memory containing the 5568c2ecf20Sopenharmony_ci payload of the control. 5578c2ecf20Sopenharmony_ci * .. _FLAG_EXECUTE_ON_WRITE: 5588c2ecf20Sopenharmony_ci 5598c2ecf20Sopenharmony_ci - ``V4L2_CTRL_FLAG_EXECUTE_ON_WRITE`` 5608c2ecf20Sopenharmony_ci - 0x0200 5618c2ecf20Sopenharmony_ci - The value provided to the control will be propagated to the driver 5628c2ecf20Sopenharmony_ci even if it remains constant. This is required when the control 5638c2ecf20Sopenharmony_ci represents an action on the hardware. For example: clearing an 5648c2ecf20Sopenharmony_ci error flag or triggering the flash. All the controls of the type 5658c2ecf20Sopenharmony_ci ``V4L2_CTRL_TYPE_BUTTON`` have this flag set. 5668c2ecf20Sopenharmony_ci * .. _FLAG_MODIFY_LAYOUT: 5678c2ecf20Sopenharmony_ci 5688c2ecf20Sopenharmony_ci - ``V4L2_CTRL_FLAG_MODIFY_LAYOUT`` 5698c2ecf20Sopenharmony_ci - 0x0400 5708c2ecf20Sopenharmony_ci - Changing this control value may modify the layout of the 5718c2ecf20Sopenharmony_ci buffer (for video devices) or the media bus format (for sub-devices). 5728c2ecf20Sopenharmony_ci 5738c2ecf20Sopenharmony_ci A typical example would be the ``V4L2_CID_ROTATE`` control. 5748c2ecf20Sopenharmony_ci 5758c2ecf20Sopenharmony_ci Note that typically controls with this flag will also set the 5768c2ecf20Sopenharmony_ci ``V4L2_CTRL_FLAG_GRABBED`` flag when buffers are allocated or 5778c2ecf20Sopenharmony_ci streaming is in progress since most drivers do not support changing 5788c2ecf20Sopenharmony_ci the format in that case. 5798c2ecf20Sopenharmony_ci 5808c2ecf20Sopenharmony_ciReturn Value 5818c2ecf20Sopenharmony_ci============ 5828c2ecf20Sopenharmony_ci 5838c2ecf20Sopenharmony_ciOn success 0 is returned, on error -1 and the ``errno`` variable is set 5848c2ecf20Sopenharmony_ciappropriately. The generic error codes are described at the 5858c2ecf20Sopenharmony_ci:ref:`Generic Error Codes <gen-errors>` chapter. 5868c2ecf20Sopenharmony_ci 5878c2ecf20Sopenharmony_ciEINVAL 5888c2ecf20Sopenharmony_ci The struct :ref:`v4l2_queryctrl <v4l2-queryctrl>` ``id`` is 5898c2ecf20Sopenharmony_ci invalid. The struct :ref:`v4l2_querymenu <v4l2-querymenu>` ``id`` 5908c2ecf20Sopenharmony_ci is invalid or ``index`` is out of range (less than ``minimum`` or 5918c2ecf20Sopenharmony_ci greater than ``maximum``) or this particular menu item is not 5928c2ecf20Sopenharmony_ci supported by the driver. 5938c2ecf20Sopenharmony_ci 5948c2ecf20Sopenharmony_ciEACCES 5958c2ecf20Sopenharmony_ci An attempt was made to read a write-only control. 5968c2ecf20Sopenharmony_ci 5978c2ecf20Sopenharmony_ci.. [#f1] 5988c2ecf20Sopenharmony_ci ``V4L2_CTRL_FLAG_DISABLED`` was intended for two purposes: Drivers 5998c2ecf20Sopenharmony_ci can skip predefined controls not supported by the hardware (although 6008c2ecf20Sopenharmony_ci returning ``EINVAL`` would do as well), or disable predefined and private 6018c2ecf20Sopenharmony_ci controls after hardware detection without the trouble of reordering 6028c2ecf20Sopenharmony_ci control arrays and indices (``EINVAL`` cannot be used to skip private 6038c2ecf20Sopenharmony_ci controls because it would prematurely end the enumeration). 604