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