![](https://csdnimg.cn/release/download_crawler_static/12390692/bg11.jpg)
Linux Media Subsystem Documentation, Release
User Controls
Devices typically have a number of user-settable controls such as brightness, saturation and so
on, which would be presented to the user on a graphical user interface. But, different devices
will have different controls available, and furthermore, the range of possible values, and the
default value will vary from device to device. The control ioctls provide the information and a
mechanism to create a nice user interface for these controls that will work correctly with any
device.
All controls are accessed using an ID value. V4L2 defines several IDs for specific purposes.
Drivers can also implement their own custom controls using V4L2_CID_PRIVATE_BASE
1
and
higher values. The pre-defined control IDs have the prefix V4L2_CID_, and are listed in Control
IDs . The ID is used when querying the attributes of a control, and when getting or setting the
current value.
Generally applications should present controls to the user without assumptions about their
purpose. Each control comes with a name string the user is supposed to understand. When the
purpose is non-intuitive the driver writer should provide a user manual, a user interface plug-in
or a driver specific panel application. Predefined IDs were introduced to change a few controls
programmatically, for example to mute a device during a channel switch.
Drivers may enumerate different controls after switching the current video input or output,
tuner or modulator, or audio input or output. Different in the sense of other bounds, another
default and current value, step size or other menu items. A control with a certain custom ID
can also change name and type.
If a control is not applicable to the current configuration of the device (for example, it doesn’t
apply to the current video input) drivers set the V4L2_CTRL_FLAG_INACTIVE flag.
Control values are stored globally, they do not change when switching except to stay within the
reported bounds. They also do not change e. g. when the device is opened or closed, when the
tuner radio frequency is changed or generally never without application request.
V4L2 specifies an event mechanism to notify applications when controls change value (see
ioctl VIDIOC_SUBSCRIBE_EVENT, VIDIOC_UNSUBSCRIBE_EVENT , event V4L2_EVENT_CTRL),
panel applications might want to make use of that in order to always reflect the correct control
value.
All controls use machine endianness.
Control IDs
V4L2_CID_BASE First predefined ID, equal to V4L2_CID_BRIGHTNESS.
V4L2_CID_USER_BASE Synonym of V4L2_CID_BASE.
V4L2_CID_BRIGHTNESS (integer) Picture brightness, or more precisely, the black level.
1
The use of V4L2_CID_PRIVATE_BASE is problematic because different drivers may use the same
V4L2_CID_PRIVATE_BASE ID for different controls. This makes it hard to programmatically set such controls since
the meaning of the control with that ID is driver dependent. In order to resolve this drivers use unique IDs and the
V4L2_CID_PRIVATE_BASE IDs are mapped to those unique IDs by the kernel. Consider these V4L2_CID_PRIVATE_BASE
IDs as aliases to the real IDs.
Many applications today still use the V4L2_CID_PRIVATE_BASE IDs instead of using ioctls VIDIOC_QUERYCTRL,
VIDIOC_QUERY_EXT_CTRL and VIDIOC_QUERYMENU with the V4L2_CTRL_FLAG_NEXT_CTRL flag to enumerate all
IDs, so support for V4L2_CID_PRIVATE_BASE is still around.
1.2. Part I - Video for Linux API 13