^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) .. c:namespace:: V4L
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) .. _VIDIOC_G_CTRL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) **********************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) ioctl VIDIOC_G_CTRL, VIDIOC_S_CTRL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) **********************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) Name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) ====
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) VIDIOC_G_CTRL - VIDIOC_S_CTRL - Get or set the value of a control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) Synopsis
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) ========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) .. c:macro:: VIDIOC_G_CTRL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) ``int ioctl(int fd, VIDIOC_G_CTRL, struct v4l2_control *argp)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) .. c:macro:: VIDIOC_S_CTRL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) ``int ioctl(int fd, VIDIOC_S_CTRL, struct v4l2_control *argp)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) Arguments
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) =========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) ``fd``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) File descriptor returned by :c:func:`open()`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) ``argp``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) Pointer to struct :c:type:`v4l2_control`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) Description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) ===========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) To get the current value of a control applications initialize the ``id``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) field of a struct :c:type:`v4l2_control` and call the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) :ref:`VIDIOC_G_CTRL <VIDIOC_G_CTRL>` ioctl with a pointer to this structure. To change the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) value of a control applications initialize the ``id`` and ``value``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) fields of a struct :c:type:`v4l2_control` and call the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) :ref:`VIDIOC_S_CTRL <VIDIOC_G_CTRL>` ioctl.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) When the ``id`` is invalid drivers return an ``EINVAL`` error code. When the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) ``value`` is out of bounds drivers can choose to take the closest valid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) value or return an ``ERANGE`` error code, whatever seems more appropriate.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) However, :ref:`VIDIOC_S_CTRL <VIDIOC_G_CTRL>` is a write-only ioctl, it does not return the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) actual new value. If the ``value`` is inappropriate for the control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) (e.g. if it refers to an unsupported menu index of a menu control), then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) EINVAL error code is returned as well.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) These ioctls work only with user controls. For other control classes the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) :ref:`VIDIOC_G_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>`,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) :ref:`VIDIOC_S_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) :ref:`VIDIOC_TRY_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>` must be used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) .. c:type:: v4l2_control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) .. flat-table:: struct v4l2_control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) :header-rows: 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) :stub-columns: 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) :widths: 1 1 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) * - __u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) - ``id``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) - Identifies the control, set by the application.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) * - __s32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) - ``value``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) - New value or current value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) Return Value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) ============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) On success 0 is returned, on error -1 and the ``errno`` variable is set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) appropriately. The generic error codes are described at the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) :ref:`Generic Error Codes <gen-errors>` chapter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) EINVAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) The struct :c:type:`v4l2_control` ``id`` is invalid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) or the ``value`` is inappropriate for the given control (i.e. if a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) menu item is selected that is not supported by the driver according
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) to :ref:`VIDIOC_QUERYMENU <VIDIOC_QUERYCTRL>`).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) ERANGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) The struct :c:type:`v4l2_control` ``value`` is out of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) bounds.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) EBUSY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) The control is temporarily not changeable, possibly because another
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) applications took over control of the device function this control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) belongs to.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) EACCES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) Attempt to set a read-only control or to get a write-only control.