162306a36Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
262306a36Sopenharmony_ci.. c:namespace:: V4L
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci.. _VIDIOC_G_CTRL:
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci**********************************
762306a36Sopenharmony_ciioctl VIDIOC_G_CTRL, VIDIOC_S_CTRL
862306a36Sopenharmony_ci**********************************
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ciName
1162306a36Sopenharmony_ci====
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ciVIDIOC_G_CTRL - VIDIOC_S_CTRL - Get or set the value of a control
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ciSynopsis
1662306a36Sopenharmony_ci========
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci.. c:macro:: VIDIOC_G_CTRL
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci``int ioctl(int fd, VIDIOC_G_CTRL, struct v4l2_control *argp)``
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci.. c:macro:: VIDIOC_S_CTRL
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci``int ioctl(int fd, VIDIOC_S_CTRL, struct v4l2_control *argp)``
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ciArguments
2762306a36Sopenharmony_ci=========
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci``fd``
3062306a36Sopenharmony_ci    File descriptor returned by :c:func:`open()`.
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ci``argp``
3362306a36Sopenharmony_ci    Pointer to struct :c:type:`v4l2_control`.
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ciDescription
3662306a36Sopenharmony_ci===========
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ciTo get the current value of a control applications initialize the ``id``
3962306a36Sopenharmony_cifield of a struct :c:type:`v4l2_control` and call the
4062306a36Sopenharmony_ci:ref:`VIDIOC_G_CTRL <VIDIOC_G_CTRL>` ioctl with a pointer to this structure. To change the
4162306a36Sopenharmony_civalue of a control applications initialize the ``id`` and ``value``
4262306a36Sopenharmony_cifields of a struct :c:type:`v4l2_control` and call the
4362306a36Sopenharmony_ci:ref:`VIDIOC_S_CTRL <VIDIOC_G_CTRL>` ioctl.
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ciWhen the ``id`` is invalid drivers return an ``EINVAL`` error code. When the
4662306a36Sopenharmony_ci``value`` is out of bounds drivers can choose to take the closest valid
4762306a36Sopenharmony_civalue or return an ``ERANGE`` error code, whatever seems more appropriate.
4862306a36Sopenharmony_ciHowever, :ref:`VIDIOC_S_CTRL <VIDIOC_G_CTRL>` is a write-only ioctl, it does not return the
4962306a36Sopenharmony_ciactual new value. If the ``value`` is inappropriate for the control
5062306a36Sopenharmony_ci(e.g. if it refers to an unsupported menu index of a menu control), then
5162306a36Sopenharmony_ciEINVAL error code is returned as well.
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_ciThese ioctls work only with user controls. For other control classes the
5462306a36Sopenharmony_ci:ref:`VIDIOC_G_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>`,
5562306a36Sopenharmony_ci:ref:`VIDIOC_S_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` or
5662306a36Sopenharmony_ci:ref:`VIDIOC_TRY_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` must be used.
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_ci.. c:type:: v4l2_control
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ci.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_ci.. flat-table:: struct v4l2_control
6362306a36Sopenharmony_ci    :header-rows:  0
6462306a36Sopenharmony_ci    :stub-columns: 0
6562306a36Sopenharmony_ci    :widths:       1 1 2
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci    * - __u32
6862306a36Sopenharmony_ci      - ``id``
6962306a36Sopenharmony_ci      - Identifies the control, set by the application.
7062306a36Sopenharmony_ci    * - __s32
7162306a36Sopenharmony_ci      - ``value``
7262306a36Sopenharmony_ci      - New value or current value.
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ciReturn Value
7562306a36Sopenharmony_ci============
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ciOn success 0 is returned, on error -1 and the ``errno`` variable is set
7862306a36Sopenharmony_ciappropriately. The generic error codes are described at the
7962306a36Sopenharmony_ci:ref:`Generic Error Codes <gen-errors>` chapter.
8062306a36Sopenharmony_ci
8162306a36Sopenharmony_ciEINVAL
8262306a36Sopenharmony_ci    The struct :c:type:`v4l2_control` ``id`` is invalid
8362306a36Sopenharmony_ci    or the ``value`` is inappropriate for the given control (i.e. if a
8462306a36Sopenharmony_ci    menu item is selected that is not supported by the driver according
8562306a36Sopenharmony_ci    to :ref:`VIDIOC_QUERYMENU <VIDIOC_QUERYCTRL>`).
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ciERANGE
8862306a36Sopenharmony_ci    The struct :c:type:`v4l2_control` ``value`` is out of
8962306a36Sopenharmony_ci    bounds.
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_ciEBUSY
9262306a36Sopenharmony_ci    The control is temporarily not changeable, possibly because another
9362306a36Sopenharmony_ci    applications took over control of the device function this control
9462306a36Sopenharmony_ci    belongs to.
9562306a36Sopenharmony_ci
9662306a36Sopenharmony_ciEACCES
9762306a36Sopenharmony_ci    Attempt to set a read-only control or to get a write-only control.
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ci    Or if there is an attempt to set an inactive control and the driver is
10062306a36Sopenharmony_ci    not capable of caching the new value until the control is active again.
101