Skip to content

Commit 8c226b9

Browse files
josuahkartben
authored andcommitted
drivers: video: controls: document each control and move classes
Make controls more readable and intuitive to extend, with definition of each control value to help disambiguate between similar controls, such as BRIGHTNESS vs GAIN. Move the class definition to the top of each relevant class, like it is on Linux for the V4L2_CID_..._CLASS_BASE variables. Signed-off-by: Josuah Demangeon <[email protected]>
1 parent 217f053 commit 8c226b9

File tree

1 file changed

+92
-36
lines changed

1 file changed

+92
-36
lines changed

include/zephyr/drivers/video-controls.h

Lines changed: 92 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -23,55 +23,68 @@
2323
* inter-operability and debugging devices end-to-end across Linux and
2424
* Zephyr.
2525
*
26+
* This list is maintained compatible to the Linux kernel definitions in
27+
* @c linux/include/uapi/linux/v4l2-controls.h
28+
*
2629
* @{
2730
*/
2831

2932
#ifdef __cplusplus
3033
extern "C" {
3134
#endif
3235

33-
/**
34-
* @name Control classes
35-
*
36-
* List of control classes, to group related controls together in blocks.
37-
*
38-
* This list is kept identical to the Linux kernel definitions.
39-
*
40-
* @{
41-
*/
42-
#define VIDEO_CID_BASE 0x00980900 /**< Base class controls */
43-
#define VIDEO_CID_CODEC_CLASS_BASE 0x00990900 /**< Stateful codec controls */
44-
#define VIDEO_CID_CAMERA_CLASS_BASE 0x009a0900 /**< Camera class controls */
45-
#define VIDEO_CID_FLASH_CLASS_BASE 0x009c0900 /**< Camera flash controls */
46-
#define VIDEO_CID_JPEG_CLASS_BASE 0x009d0900 /**< JPEG-compression controls */
47-
#define VIDEO_CID_IMAGE_SOURCE_CLASS_BASE 0x009e0900 /**< Image source controls */
48-
#define VIDEO_CID_IMAGE_PROC_CLASS_BASE 0x009f0900 /**< Image processing controls */
49-
#define VIDEO_CID_PRIVATE_BASE 0x08000000 /**< Vendor-specific class controls */
50-
/**
51-
* @}
52-
*/
53-
5436
/**
5537
* @name Base class control IDs
5638
* @{
5739
*/
58-
#define VIDEO_CID_BRIGHTNESS (VIDEO_CID_BASE + 0)
59-
#define VIDEO_CID_CONTRAST (VIDEO_CID_BASE + 1)
60-
#define VIDEO_CID_SATURATION (VIDEO_CID_BASE + 2)
61-
#define VIDEO_CID_HUE (VIDEO_CID_BASE + 3)
62-
#define VIDEO_CID_EXPOSURE (VIDEO_CID_BASE + 17)
63-
#define VIDEO_CID_GAIN (VIDEO_CID_BASE + 19)
64-
#define VIDEO_CID_HFLIP (VIDEO_CID_BASE + 20)
65-
#define VIDEO_CID_VFLIP (VIDEO_CID_BASE + 21)
66-
/** Power line frequency (enum) filter to avoid flicker */
67-
#define VIDEO_CID_POWER_LINE_FREQUENCY (VIDEO_CID_BASE + 24)
40+
#define VIDEO_CID_BASE 0x00980900
41+
42+
/** Amount of perceived light of the image, the luma (Y') value. */
43+
#define VIDEO_CID_BRIGHTNESS (VIDEO_CID_BASE + 0)
44+
45+
/** Amount of difference between the bright colors and dark colors. */
46+
#define VIDEO_CID_CONTRAST (VIDEO_CID_BASE + 1)
47+
48+
/** Colorfulness of the image while preserving its brightness */
49+
#define VIDEO_CID_SATURATION (VIDEO_CID_BASE + 2)
50+
51+
/** Shift in the tint of every colors, clockwise in a RGB color wheel */
52+
#define VIDEO_CID_HUE (VIDEO_CID_BASE + 3)
53+
54+
/** Amount of time an image sensor is exposed to light, affecting the brightness */
55+
#define VIDEO_CID_EXPOSURE (VIDEO_CID_BASE + 17)
56+
57+
/** Amount of amplification performed to each pixel electrical signal, affecting the brightness */
58+
#define VIDEO_CID_GAIN (VIDEO_CID_BASE + 19)
59+
60+
/** Flip the image horizontally: the left side becomes the right side */
61+
#define VIDEO_CID_HFLIP (VIDEO_CID_BASE + 20)
62+
63+
/** Flip the image vertically: the top side becomes the bottom side */
64+
#define VIDEO_CID_VFLIP (VIDEO_CID_BASE + 21)
65+
66+
/** Frequency of the power line to compensate for, avoiding flicker due to artificial lighting */
67+
#define VIDEO_CID_POWER_LINE_FREQUENCY (VIDEO_CID_BASE + 24)
6868
enum video_power_line_frequency {
6969
VIDEO_CID_POWER_LINE_FREQUENCY_DISABLED = 0,
7070
VIDEO_CID_POWER_LINE_FREQUENCY_50HZ = 1,
7171
VIDEO_CID_POWER_LINE_FREQUENCY_60HZ = 2,
7272
VIDEO_CID_POWER_LINE_FREQUENCY_AUTO = 3,
7373
};
74-
#define VIDEO_CID_WHITE_BALANCE_TEMPERATURE (VIDEO_CID_BASE + 26)
74+
75+
/** Balance of colors in direction of blue (cold) or red (warm) */
76+
#define VIDEO_CID_WHITE_BALANCE_TEMPERATURE (VIDEO_CID_BASE + 26)
77+
78+
/**
79+
* @}
80+
*/
81+
82+
/**
83+
* @name Stateful codec controls IDs
84+
* @{
85+
*/
86+
#define VIDEO_CID_CODEC_CLASS_BASE 0x00990900
87+
7588
/**
7689
* @}
7790
*/
@@ -80,7 +93,21 @@ enum video_power_line_frequency {
8093
* @name Camera class controls IDs
8194
* @{
8295
*/
83-
#define VIDEO_CID_ZOOM_ABSOLUTE (VIDEO_CID_CAMERA_CLASS_BASE + 13)
96+
#define VIDEO_CID_CAMERA_CLASS_BASE 0x009a0900
97+
98+
/** Amount of optical zoom applied through to the camera optics */
99+
#define VIDEO_CID_ZOOM_ABSOLUTE (VIDEO_CID_CAMERA_CLASS_BASE + 13)
100+
101+
/**
102+
* @}
103+
*/
104+
105+
/**
106+
* @name Camera Flash class control IDs
107+
* @{
108+
*/
109+
#define VIDEO_CID_FLASH_CLASS_BASE 0x009c0900
110+
84111
/**
85112
* @}
86113
*/
@@ -89,7 +116,21 @@ enum video_power_line_frequency {
89116
* @name JPEG class control IDs
90117
* @{
91118
*/
92-
#define VIDEO_CID_JPEG_COMPRESSION_QUALITY (VIDEO_CID_JPEG_CLASS_BASE + 3)
119+
#define VIDEO_CID_JPEG_CLASS_BASE 0x009d0900
120+
121+
/** Quality (Q) factor of the JPEG algorithm, also increasing the data size */
122+
#define VIDEO_CID_JPEG_COMPRESSION_QUALITY (VIDEO_CID_JPEG_CLASS_BASE + 3)
123+
124+
/**
125+
* @}
126+
*/
127+
128+
/**
129+
* @name Image Source class control IDs
130+
* @{
131+
*/
132+
#define VIDEO_CID_IMAGE_SOURCE_CLASS_BASE 0x009e0900
133+
93134
/**
94135
* @}
95136
*/
@@ -98,9 +139,24 @@ enum video_power_line_frequency {
98139
* @name Image Processing class control IDs
99140
* @{
100141
*/
142+
#define VIDEO_CID_IMAGE_PROC_CLASS_BASE 0x009f0900
143+
101144
/** Pixel rate (pixels/second) in the device's pixel array. This control is read-only. */
102-
#define VIDEO_CID_PIXEL_RATE (VIDEO_CID_IMAGE_PROC_CLASS_BASE + 2)
103-
#define VIDEO_CID_TEST_PATTERN (VIDEO_CID_IMAGE_PROC_CLASS_BASE + 3)
145+
#define VIDEO_CID_PIXEL_RATE (VIDEO_CID_IMAGE_PROC_CLASS_BASE + 2)
146+
147+
/** Selection of the type of test pattern to represent */
148+
#define VIDEO_CID_TEST_PATTERN (VIDEO_CID_IMAGE_PROC_CLASS_BASE + 3)
149+
150+
/**
151+
* @}
152+
*/
153+
154+
/**
155+
* @name Vendor-specific class control IDs
156+
* @{
157+
*/
158+
#define VIDEO_CID_PRIVATE_BASE 0x08000000
159+
104160
/**
105161
* @}
106162
*/

0 commit comments

Comments
 (0)