18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
28c2ecf20Sopenharmony_ci.. c:namespace:: V4L
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci.. _VIDIOC_G_CTRL:
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci**********************************
78c2ecf20Sopenharmony_ciioctl VIDIOC_G_CTRL, VIDIOC_S_CTRL
88c2ecf20Sopenharmony_ci**********************************
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ciName
118c2ecf20Sopenharmony_ci====
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ciVIDIOC_G_CTRL - VIDIOC_S_CTRL - Get or set the value of a control
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ciSynopsis
168c2ecf20Sopenharmony_ci========
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci.. c:macro:: VIDIOC_G_CTRL
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci``int ioctl(int fd, VIDIOC_G_CTRL, struct v4l2_control *argp)``
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci.. c:macro:: VIDIOC_S_CTRL
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci``int ioctl(int fd, VIDIOC_S_CTRL, struct v4l2_control *argp)``
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ciArguments
278c2ecf20Sopenharmony_ci=========
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci``fd``
308c2ecf20Sopenharmony_ci    File descriptor returned by :c:func:`open()`.
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci``argp``
338c2ecf20Sopenharmony_ci    Pointer to struct :c:type:`v4l2_control`.
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ciDescription
368c2ecf20Sopenharmony_ci===========
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ciTo get the current value of a control applications initialize the ``id``
398c2ecf20Sopenharmony_cifield of a struct :c:type:`v4l2_control` and call the
408c2ecf20Sopenharmony_ci:ref:`VIDIOC_G_CTRL <VIDIOC_G_CTRL>` ioctl with a pointer to this structure. To change the
418c2ecf20Sopenharmony_civalue of a control applications initialize the ``id`` and ``value``
428c2ecf20Sopenharmony_cifields of a struct :c:type:`v4l2_control` and call the
438c2ecf20Sopenharmony_ci:ref:`VIDIOC_S_CTRL <VIDIOC_G_CTRL>` ioctl.
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ciWhen the ``id`` is invalid drivers return an ``EINVAL`` error code. When the
468c2ecf20Sopenharmony_ci``value`` is out of bounds drivers can choose to take the closest valid
478c2ecf20Sopenharmony_civalue or return an ``ERANGE`` error code, whatever seems more appropriate.
488c2ecf20Sopenharmony_ciHowever, :ref:`VIDIOC_S_CTRL <VIDIOC_G_CTRL>` is a write-only ioctl, it does not return the
498c2ecf20Sopenharmony_ciactual new value. If the ``value`` is inappropriate for the control
508c2ecf20Sopenharmony_ci(e.g. if it refers to an unsupported menu index of a menu control), then
518c2ecf20Sopenharmony_ciEINVAL error code is returned as well.
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ciThese ioctls work only with user controls. For other control classes the
548c2ecf20Sopenharmony_ci:ref:`VIDIOC_G_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>`,
558c2ecf20Sopenharmony_ci:ref:`VIDIOC_S_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` or
568c2ecf20Sopenharmony_ci:ref:`VIDIOC_TRY_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` must be used.
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci.. c:type:: v4l2_control
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci.. flat-table:: struct v4l2_control
638c2ecf20Sopenharmony_ci    :header-rows:  0
648c2ecf20Sopenharmony_ci    :stub-columns: 0
658c2ecf20Sopenharmony_ci    :widths:       1 1 2
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci    * - __u32
688c2ecf20Sopenharmony_ci      - ``id``
698c2ecf20Sopenharmony_ci      - Identifies the control, set by the application.
708c2ecf20Sopenharmony_ci    * - __s32
718c2ecf20Sopenharmony_ci      - ``value``
728c2ecf20Sopenharmony_ci      - New value or current value.
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ciReturn Value
758c2ecf20Sopenharmony_ci============
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ciOn success 0 is returned, on error -1 and the ``errno`` variable is set
788c2ecf20Sopenharmony_ciappropriately. The generic error codes are described at the
798c2ecf20Sopenharmony_ci:ref:`Generic Error Codes <gen-errors>` chapter.
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ciEINVAL
828c2ecf20Sopenharmony_ci    The struct :c:type:`v4l2_control` ``id`` is invalid
838c2ecf20Sopenharmony_ci    or the ``value`` is inappropriate for the given control (i.e. if a
848c2ecf20Sopenharmony_ci    menu item is selected that is not supported by the driver according
858c2ecf20Sopenharmony_ci    to :ref:`VIDIOC_QUERYMENU <VIDIOC_QUERYCTRL>`).
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ciERANGE
888c2ecf20Sopenharmony_ci    The struct :c:type:`v4l2_control` ``value`` is out of
898c2ecf20Sopenharmony_ci    bounds.
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ciEBUSY
928c2ecf20Sopenharmony_ci    The control is temporarily not changeable, possibly because another
938c2ecf20Sopenharmony_ci    applications took over control of the device function this control
948c2ecf20Sopenharmony_ci    belongs to.
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ciEACCES
978c2ecf20Sopenharmony_ci    Attempt to set a read-only control or to get a write-only control.
98