^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)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) .. _control:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) User Controls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) Devices typically have a number of user-settable controls such as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) brightness, saturation and so on, which would be presented to the user
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) on a graphical user interface. But, different devices will have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) different controls available, and furthermore, the range of possible
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) values, and the default value will vary from device to device. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) control ioctls provide the information and a mechanism to create a nice
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) user interface for these controls that will work correctly with any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) All controls are accessed using an ID value. V4L2 defines several IDs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) for specific purposes. Drivers can also implement their own custom
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) controls using ``V4L2_CID_PRIVATE_BASE`` [#f1]_ and higher values. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) pre-defined control IDs have the prefix ``V4L2_CID_``, and are listed in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) :ref:`control-id`. The ID is used when querying the attributes of a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) control, and when getting or setting the current value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) Generally applications should present controls to the user without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) assumptions about their purpose. Each control comes with a name string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) the user is supposed to understand. When the purpose is non-intuitive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) the driver writer should provide a user manual, a user interface plug-in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) or a driver specific panel application. Predefined IDs were introduced
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) to change a few controls programmatically, for example to mute a device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) during a channel switch.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) Drivers may enumerate different controls after switching the current
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) video input or output, tuner or modulator, or audio input or output.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) Different in the sense of other bounds, another default and current
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) value, step size or other menu items. A control with a certain *custom*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) ID can also change name and type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) If a control is not applicable to the current configuration of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) device (for example, it doesn't apply to the current video input)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) drivers set the ``V4L2_CTRL_FLAG_INACTIVE`` flag.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) Control values are stored globally, they do not change when switching
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) except to stay within the reported bounds. They also do not change e. g.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) when the device is opened or closed, when the tuner radio frequency is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) changed or generally never without application request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) V4L2 specifies an event mechanism to notify applications when controls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) change value (see
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) :ref:`VIDIOC_SUBSCRIBE_EVENT`, event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) ``V4L2_EVENT_CTRL``), panel applications might want to make use of that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) in order to always reflect the correct control value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) All controls use machine endianness.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) .. _control-id:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) Control IDs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) ===========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) ``V4L2_CID_BASE``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) First predefined ID, equal to ``V4L2_CID_BRIGHTNESS``.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) ``V4L2_CID_USER_BASE``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) Synonym of ``V4L2_CID_BASE``.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) ``V4L2_CID_BRIGHTNESS`` ``(integer)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) Picture brightness, or more precisely, the black level.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) ``V4L2_CID_CONTRAST`` ``(integer)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) Picture contrast or luma gain.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) ``V4L2_CID_SATURATION`` ``(integer)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) Picture color saturation or chroma gain.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) ``V4L2_CID_HUE`` ``(integer)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) Hue or color balance.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) ``V4L2_CID_AUDIO_VOLUME`` ``(integer)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) Overall audio volume. Note some drivers also provide an OSS or ALSA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) mixer interface.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) ``V4L2_CID_AUDIO_BALANCE`` ``(integer)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) Audio stereo balance. Minimum corresponds to all the way left,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) maximum to right.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) ``V4L2_CID_AUDIO_BASS`` ``(integer)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) Audio bass adjustment.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) ``V4L2_CID_AUDIO_TREBLE`` ``(integer)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) Audio treble adjustment.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) ``V4L2_CID_AUDIO_MUTE`` ``(boolean)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) Mute audio, i. e. set the volume to zero, however without affecting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) ``V4L2_CID_AUDIO_VOLUME``. Like ALSA drivers, V4L2 drivers must mute
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) at load time to avoid excessive noise. Actually the entire device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) should be reset to a low power consumption state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) ``V4L2_CID_AUDIO_LOUDNESS`` ``(boolean)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) Loudness mode (bass boost).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) ``V4L2_CID_BLACK_LEVEL`` ``(integer)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) Another name for brightness (not a synonym of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) ``V4L2_CID_BRIGHTNESS``). This control is deprecated and should not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) be used in new drivers and applications.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) ``V4L2_CID_AUTO_WHITE_BALANCE`` ``(boolean)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) Automatic white balance (cameras).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) ``V4L2_CID_DO_WHITE_BALANCE`` ``(button)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) This is an action control. When set (the value is ignored), the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) device will do a white balance and then hold the current setting.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) Contrast this with the boolean ``V4L2_CID_AUTO_WHITE_BALANCE``,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) which, when activated, keeps adjusting the white balance.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) ``V4L2_CID_RED_BALANCE`` ``(integer)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) Red chroma balance.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) ``V4L2_CID_BLUE_BALANCE`` ``(integer)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) Blue chroma balance.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) ``V4L2_CID_GAMMA`` ``(integer)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) Gamma adjust.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) ``V4L2_CID_WHITENESS`` ``(integer)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) Whiteness for grey-scale devices. This is a synonym for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) ``V4L2_CID_GAMMA``. This control is deprecated and should not be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) used in new drivers and applications.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) ``V4L2_CID_EXPOSURE`` ``(integer)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) Exposure (cameras). [Unit?]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) ``V4L2_CID_AUTOGAIN`` ``(boolean)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) Automatic gain/exposure control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) ``V4L2_CID_GAIN`` ``(integer)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) Gain control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) Primarily used to control gain on e.g. TV tuners but also on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) webcams. Most devices control only digital gain with this control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) but on some this could include analogue gain as well. Devices that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) recognise the difference between digital and analogue gain use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) controls ``V4L2_CID_DIGITAL_GAIN`` and ``V4L2_CID_ANALOGUE_GAIN``.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) ``V4L2_CID_HFLIP`` ``(boolean)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) Mirror the picture horizontally.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) ``V4L2_CID_VFLIP`` ``(boolean)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) Mirror the picture vertically.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) .. _v4l2-power-line-frequency:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) ``V4L2_CID_POWER_LINE_FREQUENCY`` ``(enum)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) Enables a power line frequency filter to avoid flicker. Possible
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) values for ``enum v4l2_power_line_frequency`` are:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) ``V4L2_CID_POWER_LINE_FREQUENCY_DISABLED`` (0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) ``V4L2_CID_POWER_LINE_FREQUENCY_50HZ`` (1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) ``V4L2_CID_POWER_LINE_FREQUENCY_60HZ`` (2) and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) ``V4L2_CID_POWER_LINE_FREQUENCY_AUTO`` (3).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) ``V4L2_CID_HUE_AUTO`` ``(boolean)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) Enables automatic hue control by the device. The effect of setting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) ``V4L2_CID_HUE`` while automatic hue control is enabled is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) undefined, drivers should ignore such request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) ``V4L2_CID_WHITE_BALANCE_TEMPERATURE`` ``(integer)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) This control specifies the white balance settings as a color
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) temperature in Kelvin. A driver should have a minimum of 2800
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) (incandescent) to 6500 (daylight). For more information about color
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) temperature see
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) `Wikipedia <http://en.wikipedia.org/wiki/Color_temperature>`__.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) ``V4L2_CID_SHARPNESS`` ``(integer)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) Adjusts the sharpness filters in a camera. The minimum value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) disables the filters, higher values give a sharper picture.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) ``V4L2_CID_BACKLIGHT_COMPENSATION`` ``(integer)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) Adjusts the backlight compensation in a camera. The minimum value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) disables backlight compensation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) ``V4L2_CID_CHROMA_AGC`` ``(boolean)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) Chroma automatic gain control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) ``V4L2_CID_CHROMA_GAIN`` ``(integer)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) Adjusts the Chroma gain control (for use when chroma AGC is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) disabled).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) ``V4L2_CID_COLOR_KILLER`` ``(boolean)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) Enable the color killer (i. e. force a black & white image in case
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) of a weak video signal).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) .. _v4l2-colorfx:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) ``V4L2_CID_COLORFX`` ``(enum)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) Selects a color effect. The following values are defined:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) .. tabularcolumns:: |p{5.5cm}|p{12cm}|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) .. flat-table::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) :header-rows: 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) :stub-columns: 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) :widths: 11 24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) * - ``V4L2_COLORFX_NONE``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) - Color effect is disabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) * - ``V4L2_COLORFX_ANTIQUE``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) - An aging (old photo) effect.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) * - ``V4L2_COLORFX_ART_FREEZE``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) - Frost color effect.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) * - ``V4L2_COLORFX_AQUA``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) - Water color, cool tone.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) * - ``V4L2_COLORFX_BW``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) - Black and white.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) * - ``V4L2_COLORFX_EMBOSS``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) - Emboss, the highlights and shadows replace light/dark boundaries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) and low contrast areas are set to a gray background.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) * - ``V4L2_COLORFX_GRASS_GREEN``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) - Grass green.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) * - ``V4L2_COLORFX_NEGATIVE``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) - Negative.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) * - ``V4L2_COLORFX_SEPIA``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) - Sepia tone.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) * - ``V4L2_COLORFX_SKETCH``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) - Sketch.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) * - ``V4L2_COLORFX_SKIN_WHITEN``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) - Skin whiten.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) * - ``V4L2_COLORFX_SKY_BLUE``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) - Sky blue.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) * - ``V4L2_COLORFX_SOLARIZATION``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) - Solarization, the image is partially reversed in tone, only color
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) values above or below a certain threshold are inverted.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) * - ``V4L2_COLORFX_SILHOUETTE``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) - Silhouette (outline).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) * - ``V4L2_COLORFX_VIVID``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) - Vivid colors.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) * - ``V4L2_COLORFX_SET_CBCR``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) - The Cb and Cr chroma components are replaced by fixed coefficients
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) determined by ``V4L2_CID_COLORFX_CBCR`` control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) ``V4L2_CID_COLORFX_CBCR`` ``(integer)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) Determines the Cb and Cr coefficients for ``V4L2_COLORFX_SET_CBCR``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) color effect. Bits [7:0] of the supplied 32 bit value are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) interpreted as Cr component, bits [15:8] as Cb component and bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) [31:16] must be zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) ``V4L2_CID_AUTOBRIGHTNESS`` ``(boolean)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) Enable Automatic Brightness.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) ``V4L2_CID_ROTATE`` ``(integer)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) Rotates the image by specified angle. Common angles are 90, 270 and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 180. Rotating the image to 90 and 270 will reverse the height and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) width of the display window. It is necessary to set the new height
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) and width of the picture using the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ioctl according to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) rotation angle selected.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) ``V4L2_CID_BG_COLOR`` ``(integer)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) Sets the background color on the current output device. Background
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) color needs to be specified in the RGB24 format. The supplied 32 bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) value is interpreted as bits 0-7 Red color information, bits 8-15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) Green color information, bits 16-23 Blue color information and bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 24-31 must be zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) ``V4L2_CID_ILLUMINATORS_1 V4L2_CID_ILLUMINATORS_2`` ``(boolean)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) Switch on or off the illuminator 1 or 2 of the device (usually a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) microscope).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) ``V4L2_CID_MIN_BUFFERS_FOR_CAPTURE`` ``(integer)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) This is a read-only control that can be read by the application and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) used as a hint to determine the number of CAPTURE buffers to pass to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) REQBUFS. The value is the minimum number of CAPTURE buffers that is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) necessary for hardware to work.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) ``V4L2_CID_MIN_BUFFERS_FOR_OUTPUT`` ``(integer)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) This is a read-only control that can be read by the application and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) used as a hint to determine the number of OUTPUT buffers to pass to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) REQBUFS. The value is the minimum number of OUTPUT buffers that is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) necessary for hardware to work.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) .. _v4l2-alpha-component:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) ``V4L2_CID_ALPHA_COMPONENT`` ``(integer)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) Sets the alpha color component. When a capture device (or capture
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) queue of a mem-to-mem device) produces a frame format that includes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) an alpha component (e.g.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) :ref:`packed RGB image formats <pixfmt-rgb>`) and the alpha value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) is not defined by the device or the mem-to-mem input data this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) control lets you select the alpha component value of all pixels.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) When an output device (or output queue of a mem-to-mem device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) consumes a frame format that doesn't include an alpha component and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) the device supports alpha channel processing this control lets you
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) set the alpha component value of all pixels for further processing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) in the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) ``V4L2_CID_LASTP1``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) End of the predefined control IDs (currently
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) ``V4L2_CID_ALPHA_COMPONENT`` + 1).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) ``V4L2_CID_PRIVATE_BASE``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) ID of the first custom (driver specific) control. Applications
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) depending on particular custom controls should check the driver name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) and version, see :ref:`querycap`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) Applications can enumerate the available controls with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) :ref:`VIDIOC_QUERYCTRL` and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) :ref:`VIDIOC_QUERYMENU <VIDIOC_QUERYCTRL>` ioctls, get and set a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) control value with the :ref:`VIDIOC_G_CTRL <VIDIOC_G_CTRL>` and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) :ref:`VIDIOC_S_CTRL <VIDIOC_G_CTRL>` ioctls. Drivers must implement
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) ``VIDIOC_QUERYCTRL``, ``VIDIOC_G_CTRL`` and ``VIDIOC_S_CTRL`` when the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) device has one or more controls, ``VIDIOC_QUERYMENU`` when it has one or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) more menu type controls.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) .. _enum_all_controls:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) Example: Enumerating all controls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) =================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) .. code-block:: c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) struct v4l2_queryctrl queryctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) struct v4l2_querymenu querymenu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) static void enumerate_menu(__u32 id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) printf(" Menu items:\\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) memset(&querymenu, 0, sizeof(querymenu));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) querymenu.id = id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) for (querymenu.index = queryctrl.minimum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) querymenu.index <= queryctrl.maximum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) querymenu.index++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) if (0 == ioctl(fd, VIDIOC_QUERYMENU, &querymenu)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) printf(" %s\\n", querymenu.name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) memset(&queryctrl, 0, sizeof(queryctrl));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) queryctrl.id = V4L2_CTRL_FLAG_NEXT_CTRL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) while (0 == ioctl(fd, VIDIOC_QUERYCTRL, &queryctrl)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) if (!(queryctrl.flags & V4L2_CTRL_FLAG_DISABLED)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) printf("Control %s\\n", queryctrl.name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) if (queryctrl.type == V4L2_CTRL_TYPE_MENU)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) enumerate_menu(queryctrl.id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) queryctrl.id |= V4L2_CTRL_FLAG_NEXT_CTRL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) if (errno != EINVAL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) perror("VIDIOC_QUERYCTRL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) exit(EXIT_FAILURE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) Example: Enumerating all controls including compound controls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) =============================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) .. code-block:: c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) struct v4l2_query_ext_ctrl query_ext_ctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) memset(&query_ext_ctrl, 0, sizeof(query_ext_ctrl));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) query_ext_ctrl.id = V4L2_CTRL_FLAG_NEXT_CTRL | V4L2_CTRL_FLAG_NEXT_COMPOUND;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) while (0 == ioctl(fd, VIDIOC_QUERY_EXT_CTRL, &query_ext_ctrl)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) if (!(query_ext_ctrl.flags & V4L2_CTRL_FLAG_DISABLED)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) printf("Control %s\\n", query_ext_ctrl.name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) if (query_ext_ctrl.type == V4L2_CTRL_TYPE_MENU)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) enumerate_menu(query_ext_ctrl.id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) query_ext_ctrl.id |= V4L2_CTRL_FLAG_NEXT_CTRL | V4L2_CTRL_FLAG_NEXT_COMPOUND;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) if (errno != EINVAL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) perror("VIDIOC_QUERY_EXT_CTRL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) exit(EXIT_FAILURE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) Example: Enumerating all user controls (old style)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) ==================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) .. code-block:: c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) memset(&queryctrl, 0, sizeof(queryctrl));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) for (queryctrl.id = V4L2_CID_BASE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) queryctrl.id < V4L2_CID_LASTP1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) queryctrl.id++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) if (0 == ioctl(fd, VIDIOC_QUERYCTRL, &queryctrl)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) if (queryctrl.flags & V4L2_CTRL_FLAG_DISABLED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) printf("Control %s\\n", queryctrl.name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) if (queryctrl.type == V4L2_CTRL_TYPE_MENU)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) enumerate_menu(queryctrl.id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) if (errno == EINVAL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) perror("VIDIOC_QUERYCTRL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) exit(EXIT_FAILURE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) for (queryctrl.id = V4L2_CID_PRIVATE_BASE;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) queryctrl.id++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) if (0 == ioctl(fd, VIDIOC_QUERYCTRL, &queryctrl)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) if (queryctrl.flags & V4L2_CTRL_FLAG_DISABLED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) printf("Control %s\\n", queryctrl.name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) if (queryctrl.type == V4L2_CTRL_TYPE_MENU)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) enumerate_menu(queryctrl.id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) if (errno == EINVAL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) perror("VIDIOC_QUERYCTRL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) exit(EXIT_FAILURE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) Example: Changing controls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) ==========================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) .. code-block:: c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) struct v4l2_queryctrl queryctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) struct v4l2_control control;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) memset(&queryctrl, 0, sizeof(queryctrl));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) queryctrl.id = V4L2_CID_BRIGHTNESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) if (-1 == ioctl(fd, VIDIOC_QUERYCTRL, &queryctrl)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) if (errno != EINVAL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) perror("VIDIOC_QUERYCTRL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) exit(EXIT_FAILURE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) printf("V4L2_CID_BRIGHTNESS is not supportedn");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) } else if (queryctrl.flags & V4L2_CTRL_FLAG_DISABLED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) printf("V4L2_CID_BRIGHTNESS is not supportedn");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) memset(&control, 0, sizeof (control));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) control.id = V4L2_CID_BRIGHTNESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) control.value = queryctrl.default_value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) if (-1 == ioctl(fd, VIDIOC_S_CTRL, &control)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) perror("VIDIOC_S_CTRL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) exit(EXIT_FAILURE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) memset(&control, 0, sizeof(control));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) control.id = V4L2_CID_CONTRAST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) if (0 == ioctl(fd, VIDIOC_G_CTRL, &control)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) control.value += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) /* The driver may clamp the value or return ERANGE, ignored here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) if (-1 == ioctl(fd, VIDIOC_S_CTRL, &control)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) && errno != ERANGE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) perror("VIDIOC_S_CTRL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) exit(EXIT_FAILURE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) /* Ignore if V4L2_CID_CONTRAST is unsupported */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) } else if (errno != EINVAL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) perror("VIDIOC_G_CTRL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) exit(EXIT_FAILURE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) control.id = V4L2_CID_AUDIO_MUTE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) control.value = 1; /* silence */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) /* Errors ignored */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) ioctl(fd, VIDIOC_S_CTRL, &control);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) .. [#f1]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) The use of ``V4L2_CID_PRIVATE_BASE`` is problematic because different
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) drivers may use the same ``V4L2_CID_PRIVATE_BASE`` ID for different
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) controls. This makes it hard to programmatically set such controls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) since the meaning of the control with that ID is driver dependent. In
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) order to resolve this drivers use unique IDs and the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) ``V4L2_CID_PRIVATE_BASE`` IDs are mapped to those unique IDs by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) kernel. Consider these ``V4L2_CID_PRIVATE_BASE`` IDs as aliases to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) the real IDs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) Many applications today still use the ``V4L2_CID_PRIVATE_BASE`` IDs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) instead of using :ref:`VIDIOC_QUERYCTRL` with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) the ``V4L2_CTRL_FLAG_NEXT_CTRL`` flag to enumerate all IDs, so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) support for ``V4L2_CID_PRIVATE_BASE`` is still around.