Skip to content

Commit 084f0ac

Browse files
josuahkartben
authored andcommitted
drivers: video: controls: add the BASE and CAMERA controls
Add all the base controls present like they are in Linux into Zephyr, limited to those that can apply in the current system: - Buttons are left as integer for now. - Some description is modified to fit the Zephyr situation. - For the minimum number of buffer, Zephyr uses a different mechanism. - No audio support through the video subsystem. - Homogenize the wording Signed-off-by: Josuah Demangeon <me@josuah.net>
1 parent 2fc54ae commit 084f0ac

File tree

2 files changed

+301
-16
lines changed

2 files changed

+301
-16
lines changed

drivers/video/video_ctrls.c

Lines changed: 95 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,33 @@ LOG_MODULE_REGISTER(video_ctrls, CONFIG_VIDEO_LOG_LEVEL);
1717

1818
static inline const char *const *video_get_std_menu_ctrl(uint32_t id)
1919
{
20-
static const char *const camera_power_line_frequency[] = {"Disabled", "50 Hz", "60 Hz",
21-
"Auto", NULL};
22-
static const char *const camera_exposure_auto[] = {"Auto Mode", "Manual Mode",
23-
"Shutter Priority Mode",
24-
"Aperture Priority Mode", NULL};
20+
static char const *const power_line_frequency[] = {
21+
"Disabled", "50 Hz", "60 Hz", "Auto", NULL,
22+
};
23+
static char const *const exposure_auto[] = {
24+
"Auto Mode", "Manual Mode", "Shutter Priority Mode", "Aperture Priority Mode", NULL,
25+
};
26+
static char const *const colorfx[] = {
27+
"None", "Black & White", "Sepia", "Negative", "Emboss", "Sketch", "Sky Blue",
28+
"Grass Green", "Skin Whiten", "Vivid", "Aqua", "Art Freeze", "Silhouette",
29+
"Solarization", "Antique", "Set Cb/Cr", NULL,
30+
};
31+
static char const *const camera_orientation[] = {
32+
"Front", "Back", "External", NULL,
33+
};
2534

2635
switch (id) {
36+
/* User control menus */
2737
case VIDEO_CID_POWER_LINE_FREQUENCY:
28-
return camera_power_line_frequency;
38+
return power_line_frequency;
39+
40+
/* Camera control menus */
2941
case VIDEO_CID_EXPOSURE_AUTO:
30-
return camera_exposure_auto;
42+
return exposure_auto;
43+
case VIDEO_CID_COLORFX:
44+
return colorfx;
45+
case VIDEO_CID_CAMERA_ORIENTATION:
46+
return camera_orientation;
3147
default:
3248
return NULL;
3349
}
@@ -69,12 +85,22 @@ static inline void set_type_flag(uint32_t id, enum video_ctrl_type *type, uint32
6985
*flags = 0;
7086

7187
switch (id) {
88+
case VIDEO_CID_AUTO_WHITE_BALANCE:
89+
case VIDEO_CID_AUTOGAIN:
7290
case VIDEO_CID_HFLIP:
7391
case VIDEO_CID_VFLIP:
92+
case VIDEO_CID_HUE_AUTO:
93+
case VIDEO_CID_AUTOBRIGHTNESS:
94+
case VIDEO_CID_EXPOSURE_AUTO_PRIORITY:
95+
case VIDEO_CID_FOCUS_AUTO:
96+
case VIDEO_CID_WIDE_DYNAMIC_RANGE:
7497
*type = VIDEO_CTRL_TYPE_BOOLEAN;
7598
break;
7699
case VIDEO_CID_POWER_LINE_FREQUENCY:
100+
case VIDEO_CID_EXPOSURE_AUTO:
101+
case VIDEO_CID_COLORFX:
77102
case VIDEO_CID_TEST_PATTERN:
103+
case VIDEO_CID_CAMERA_ORIENTATION:
78104
*type = VIDEO_CTRL_TYPE_MENU;
79105
break;
80106
case VIDEO_CID_PIXEL_RATE:
@@ -388,6 +414,14 @@ static inline const char *video_get_ctrl_name(uint32_t id)
388414
return "Saturation";
389415
case VIDEO_CID_HUE:
390416
return "Hue";
417+
case VIDEO_CID_AUTO_WHITE_BALANCE:
418+
return "White Balance, Automatic";
419+
case VIDEO_CID_RED_BALANCE:
420+
return "Red Balance";
421+
case VIDEO_CID_BLUE_BALANCE:
422+
return "Blue Balance";
423+
case VIDEO_CID_GAMMA:
424+
return "Gamma";
391425
case VIDEO_CID_EXPOSURE:
392426
return "Exposure";
393427
case VIDEO_CID_AUTOGAIN:
@@ -402,10 +436,64 @@ static inline const char *video_get_ctrl_name(uint32_t id)
402436
return "Vertical Flip";
403437
case VIDEO_CID_POWER_LINE_FREQUENCY:
404438
return "Power Line Frequency";
439+
case VIDEO_CID_HUE_AUTO:
440+
return "Hue, Automatic";
441+
case VIDEO_CID_WHITE_BALANCE_TEMPERATURE:
442+
return "White Balance Temperature";
443+
case VIDEO_CID_SHARPNESS:
444+
return "Sharpness";
445+
case VIDEO_CID_BACKLIGHT_COMPENSATION:
446+
return "Backlight Compensation";
447+
case VIDEO_CID_COLORFX:
448+
return "Color Effects";
449+
case VIDEO_CID_AUTOBRIGHTNESS:
450+
return "Brightness, Automatic";
451+
case VIDEO_CID_BAND_STOP_FILTER:
452+
return "Band-Stop Filter";
453+
case VIDEO_CID_ALPHA_COMPONENT:
454+
return "Alpha Component";
405455

406456
/* Camera controls */
457+
case VIDEO_CID_EXPOSURE_AUTO:
458+
return "Auto Exposure";
459+
case VIDEO_CID_EXPOSURE_ABSOLUTE:
460+
return "Exposure Time, Absolute";
461+
case VIDEO_CID_EXPOSURE_AUTO_PRIORITY:
462+
return "Exposure, Dynamic Framerate";
463+
case VIDEO_CID_PAN_RELATIVE:
464+
return "Pan, Relative";
465+
case VIDEO_CID_TILT_RELATIVE:
466+
return "Tilt, Reset";
467+
case VIDEO_CID_PAN_ABSOLUTE:
468+
return "Pan, Absolute";
469+
case VIDEO_CID_TILT_ABSOLUTE:
470+
return "Tilt, Absolute";
471+
case VIDEO_CID_FOCUS_ABSOLUTE:
472+
return "Focus, Absolute";
473+
case VIDEO_CID_FOCUS_RELATIVE:
474+
return "Focus, Relative";
475+
case VIDEO_CID_FOCUS_AUTO:
476+
return "Focus, Automatic Continuous";
407477
case VIDEO_CID_ZOOM_ABSOLUTE:
408478
return "Zoom, Absolute";
479+
case VIDEO_CID_ZOOM_RELATIVE:
480+
return "Zoom, Relative";
481+
case VIDEO_CID_ZOOM_CONTINUOUS:
482+
return "Zoom, Continuous";
483+
case VIDEO_CID_IRIS_ABSOLUTE:
484+
return "Iris, Absolute";
485+
case VIDEO_CID_IRIS_RELATIVE:
486+
return "Iris, Relative";
487+
case VIDEO_CID_WIDE_DYNAMIC_RANGE:
488+
return "Wide Dynamic Range";
489+
case VIDEO_CID_PAN_SPEED:
490+
return "Pan, Speed";
491+
case VIDEO_CID_TILT_SPEED:
492+
return "Tilt, Speed";
493+
case VIDEO_CID_CAMERA_ORIENTATION:
494+
return "Camera Orientation";
495+
case VIDEO_CID_CAMERA_SENSOR_ROTATION:
496+
return "Camera Sensor Rotation";
409497

410498
/* JPEG encoder controls */
411499
case VIDEO_CID_JPEG_COMPRESSION_QUALITY:

include/zephyr/drivers/video-controls.h

Lines changed: 206 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,31 @@ extern "C" {
4242
*/
4343
#define VIDEO_CID_BASE 0x00980900
4444

45-
/** Amount of perceived light of the image, the luma (Y') value. */
45+
/** Picture brightness, or more precisely, the black level. */
4646
#define VIDEO_CID_BRIGHTNESS (VIDEO_CID_BASE + 0)
4747

48-
/** Amount of difference between the bright colors and dark colors. */
48+
/** Picture contrast or luma gain. */
4949
#define VIDEO_CID_CONTRAST (VIDEO_CID_BASE + 1)
5050

51-
/** Colorfulness of the image while preserving its brightness */
51+
/** Picture color saturation or chroma gain. */
5252
#define VIDEO_CID_SATURATION (VIDEO_CID_BASE + 2)
5353

54-
/** Shift in the tint of every colors, clockwise in a RGB color wheel */
54+
/** Hue or color balance. */
5555
#define VIDEO_CID_HUE (VIDEO_CID_BASE + 3)
5656

57-
/** Amount of time an image sensor is exposed to light, affecting the brightness */
57+
/** Automatic white balance (cameras). */
58+
#define VIDEO_CID_AUTO_WHITE_BALANCE (VIDEO_CID_BASE + 12)
59+
60+
/** Red chroma balance, as a ratio to the green channel. */
61+
#define VIDEO_CID_RED_BALANCE (VIDEO_CID_BASE + 14)
62+
63+
/** Blue chroma balance, as a ratio to the green channel. */
64+
#define VIDEO_CID_BLUE_BALANCE (VIDEO_CID_BASE + 15)
65+
66+
/** Gamma adjust. */
67+
#define VIDEO_CID_GAMMA (VIDEO_CID_BASE + 16)
68+
69+
/** Image sensor exposure time. */
5870
#define VIDEO_CID_EXPOSURE (VIDEO_CID_BASE + 17)
5971

6072
/** Automatic gain control */
@@ -81,9 +93,61 @@ enum video_power_line_frequency {
8193
VIDEO_CID_POWER_LINE_FREQUENCY_AUTO = 3,
8294
};
8395

84-
/** Balance of colors in direction of blue (cold) or red (warm) */
96+
/** Enables automatic hue control by the device.
97+
* Setting @ref VIDEO_CID_HUE while automatic hue control is enabled is undefined.
98+
* Drivers should ignore such request.
99+
*/
100+
#define VIDEO_CID_HUE_AUTO (VIDEO_CID_BASE + 25)
101+
102+
/** White balance settings as a color temperature in Kelvin.
103+
* A driver should have a minimum range of 2800 (incandescent) to 6500 (daylight).
104+
*/
85105
#define VIDEO_CID_WHITE_BALANCE_TEMPERATURE (VIDEO_CID_BASE + 26)
86106

107+
/** Adjusts the sharpness filters in a camera.
108+
* The minimum value disables the filters, higher values give a sharper picture.
109+
*/
110+
#define VIDEO_CID_SHARPNESS (VIDEO_CID_BASE + 27)
111+
112+
/** Adjusts the backlight compensation in a camera.
113+
* The minimum value disables backlight compensation.
114+
*/
115+
#define VIDEO_CID_BACKLIGHT_COMPENSATION (VIDEO_CID_BASE + 28)
116+
117+
/** Selects a color effect. */
118+
#define VIDEO_CID_COLORFX (VIDEO_CID_BASE + 31)
119+
enum video_colorfx {
120+
VIDEO_COLORFX_NONE = 0,
121+
VIDEO_COLORFX_BW = 1,
122+
VIDEO_COLORFX_SEPIA = 2,
123+
VIDEO_COLORFX_NEGATIVE = 3,
124+
VIDEO_COLORFX_EMBOSS = 4,
125+
VIDEO_COLORFX_SKETCH = 5,
126+
VIDEO_COLORFX_SKY_BLUE = 6,
127+
VIDEO_COLORFX_GRASS_GREEN = 7,
128+
VIDEO_COLORFX_SKIN_WHITEN = 8,
129+
VIDEO_COLORFX_VIVID = 9,
130+
VIDEO_COLORFX_AQUA = 10,
131+
VIDEO_COLORFX_ART_FREEZE = 11,
132+
VIDEO_COLORFX_SILHOUETTE = 12,
133+
VIDEO_COLORFX_SOLARIZATION = 13,
134+
VIDEO_COLORFX_ANTIQUE = 14,
135+
};
136+
137+
/* Enable Automatic Brightness. */
138+
#define VIDEO_CID_AUTOBRIGHTNESS (VIDEO_CID_BASE + 32)
139+
140+
/** Switch the band-stop filter of a camera sensor on or off, or specify its strength.
141+
* Such band-stop filters can be used, for example, to filter out the fluorescent light component.
142+
*/
143+
#define VIDEO_CID_BAND_STOP_FILTER (VIDEO_CID_BASE + 33)
144+
145+
/** Sets the alpha color component.
146+
* Some devices produce data with a user-controllable alpha component. Set the value applied to
147+
* the alpha channel of every pixel produced.
148+
*/
149+
#define VIDEO_CID_ALPHA_COMPONENT (VIDEO_CID_BASE + 41)
150+
87151
/** Last base CID + 1 */
88152
#define VIDEO_CID_LASTP1 (VIDEO_CID_BASE + 44)
89153

@@ -107,18 +171,151 @@ enum video_power_line_frequency {
107171
*/
108172
#define VIDEO_CID_CAMERA_CLASS_BASE 0x009a0900
109173

110-
/** Adjustments of exposure time and/or iris aperture. */
174+
/** Enables automatic adjustments of the exposure time and/or iris aperture.
175+
* Manual exposure or iris changes when it is not @ref VIDEO_EXPOSURE_MANUAL is undefined.
176+
* Drivers should ignore such requests.
177+
*/
111178
#define VIDEO_CID_EXPOSURE_AUTO (VIDEO_CID_CAMERA_CLASS_BASE + 1)
112-
enum video_exposure_auto_type {
179+
enum video_exposure_type {
113180
VIDEO_EXPOSURE_AUTO = 0,
114181
VIDEO_EXPOSURE_MANUAL = 1,
115182
VIDEO_EXPOSURE_SHUTTER_PRIORITY = 2,
116183
VIDEO_EXPOSURE_APERTURE_PRIORITY = 3
117184
};
118185

119-
/** Amount of optical zoom applied through to the camera optics */
186+
/** Determines the exposure time of the camera sensor.
187+
* The exposure time is limited by the frame in terval. Drivers should interpret the values as
188+
* 100 µs units, where the value 1 stands for 1/10000th of a second, 10000 for 1 second and 100000
189+
* for 10 seconds.
190+
*/
191+
#define VIDEO_CID_EXPOSURE_ABSOLUTE (VIDEO_CID_CAMERA_CLASS_BASE + 2)
192+
193+
/** Whether the device may dynamically vary the frame rate under the effect of auto-exposure
194+
* Applicable when @ref VIDEO_CID_EXPOSURE_AUTO is set to @ref VIDEO_EXPOSURE_AUTO or
195+
* @ref VIDEO_EXPOSURE_APERTURE_PRIORITY. Disabled by default: the frame rate must remain constant.
196+
*/
197+
#define VIDEO_CID_EXPOSURE_AUTO_PRIORITY (VIDEO_CID_CAMERA_CLASS_BASE + 3)
198+
199+
/** This write-only control turns the camera horizontally by the specified amount.
200+
* The unit is undefined. A positive value moves the camera to the right (clockwise when viewed
201+
* from above), a negative value to the left. A value of zero does not cause motion.
202+
*/
203+
#define VIDEO_CID_PAN_RELATIVE (VIDEO_CID_CAMERA_CLASS_BASE + 4)
204+
205+
/** This write-only control turns the camera vertically by the specified amount.
206+
* The unit is undefined. A positive value moves the camera up, a negative value down.
207+
* A value of zero does not cause motion.
208+
*/
209+
#define VIDEO_CID_TILT_RELATIVE (VIDEO_CID_CAMERA_CLASS_BASE + 5)
210+
211+
/** This control turns the camera horizontally to the specified position.
212+
* Positive values move the camera to the right (clockwise when viewed from above), negative
213+
* values to the left. Drivers should interpret the values as arc seconds, with valid values
214+
* between -180 * 3600 and +180 * 3600 inclusive.
215+
*/
216+
#define VIDEO_CID_PAN_ABSOLUTE (VIDEO_CID_CAMERA_CLASS_BASE + 8)
217+
218+
/** This control turns the camera vertically to the specified position.
219+
* Positive values move the camera up, negative values down. Drivers should interpret the values as
220+
* arc seconds, with valid values between -180 * 3600 and +180 * 3600 inclusive.
221+
*/
222+
#define VIDEO_CID_TILT_ABSOLUTE (VIDEO_CID_CAMERA_CLASS_BASE + 9)
223+
224+
/** This control sets the focal point of the camera to the specified position.
225+
* The unit is undefined. Positive values set the focus closer to the camera, negative values
226+
* towards infinity.
227+
*/
228+
#define VIDEO_CID_FOCUS_ABSOLUTE (VIDEO_CID_CAMERA_CLASS_BASE + 10)
229+
230+
/** This write-only control moves the focal point of the camera by the specified amount.
231+
* The unit is undefined. Positive values move the focus closer to the camera, negative values
232+
* towards infinity.
233+
*/
234+
#define VIDEO_CID_FOCUS_RELATIVE (VIDEO_CID_CAMERA_CLASS_BASE + 11)
235+
236+
/** Enables continuous automatic focus adjustments.
237+
* Manual focus adjustments while this control is on (set to 1) is undefined.
238+
* Drivers should ignore such requests.
239+
*/
240+
#define VIDEO_CID_FOCUS_AUTO (VIDEO_CID_CAMERA_CLASS_BASE + 12)
241+
242+
/** Specify the objective lens focal length as an absolute value.
243+
* The zoom unit is driver-specific and its value should be a positive integer.
244+
*/
120245
#define VIDEO_CID_ZOOM_ABSOLUTE (VIDEO_CID_CAMERA_CLASS_BASE + 13)
121246

247+
/** This write-only control sets the objective lens focal length relatively to the current value.
248+
* Positive values move the zoom lens group towards the telephoto direction, negative values
249+
* towards the wide-angle direction. The zoom unit is driver-specific.
250+
*/
251+
#define VIDEO_CID_ZOOM_RELATIVE (VIDEO_CID_CAMERA_CLASS_BASE + 14)
252+
253+
/** Start a continuous zoom movement.
254+
* Move the objective lens group at the specified speed until it reaches physical device limits or
255+
* until an explicit request to stop the movement. A positive value moves the zoom lens group
256+
* towards the telephoto direction. A value of zero stops the zoom lens group movement.
257+
* A negative value moves the zoom lens group towards the wide-angle direction.
258+
* The zoom speed unit is driver-specific.
259+
*/
260+
#define VIDEO_CID_ZOOM_CONTINUOUS (VIDEO_CID_CAMERA_CLASS_BASE + 15)
261+
262+
/** This control sets the camera's aperture to the specified value.
263+
* The unit is undefined. Larger values open the iris wider, smaller values close it.
264+
*/
265+
#define VIDEO_CID_IRIS_ABSOLUTE (VIDEO_CID_CAMERA_CLASS_BASE + 17)
266+
267+
/** This write-only control modifies the camera's aperture by the specified amount.
268+
* The unit is undefined. Positive values open the iris one step further, negative values close
269+
* it one step further.
270+
*/
271+
#define VIDEO_CID_IRIS_RELATIVE (VIDEO_CID_CAMERA_CLASS_BASE + 18)
272+
273+
/** Enables or disables the camera's wide dynamic range feature.
274+
* This feature allows to obtain clear images in situations where intensity of the illumination
275+
* varies significantly throughout the scene, i.e. there are simultaneously very dark and very
276+
* bright areas. It is most commonly realized in cameras by combining two subsequent frames with
277+
* different exposure times.
278+
*/
279+
#define VIDEO_CID_WIDE_DYNAMIC_RANGE (VIDEO_CID_CAMERA_CLASS_BASE + 21)
280+
281+
/**This control turns the camera horizontally at the specific speed.
282+
* The unit is undefined. A positive value moves the camera to the right (clockwise when viewed
283+
* from above), a negative value to the left. A value of zero stops the motion if one is in
284+
* progress and has no effect otherwise.
285+
*/
286+
#define VIDEO_CID_PAN_SPEED (VIDEO_CID_CAMERA_CLASS_BASE + 32)
287+
288+
/** This control turns the camera vertically at the specified speed.
289+
* The unit is undefined. A positive value moves the camera up, a negative value down.
290+
* A value of zero stops the motion if one is in progress and has no effect otherwise.
291+
*/
292+
#define VIDEO_CID_TILT_SPEED (VIDEO_CID_CAMERA_CLASS_BASE + 33)
293+
294+
/** This read-only control describes the camera position on the device
295+
* It by reports where the camera camera is installed, its mounting position on the device.
296+
* This control is particularly meaningful for devices which have a well defined orientation,
297+
* such as phones, laptops and portable devices since the control is expressed as a position
298+
* relative to the device's intended usage orientation.
299+
* , or , are said to have the
300+
* @ref VIDEO_CAMERA_ORIENTATION_EXTERNAL orientation.
301+
*/
302+
#define VIDEO_CID_CAMERA_ORIENTATION (VIDEO_CID_CAMERA_CLASS_BASE + 34)
303+
enum video_camera_orientation {
304+
/** Camera installed on the user-facing side of a phone/tablet/laptop device */
305+
VIDEO_CAMERA_ORIENTATION_FRONT = 0,
306+
/** Camera installed on the opposite side of the user */
307+
VIDEO_CAMERA_ORIENTATION_BACK = 1,
308+
/** Camera sensors not directly attached to the device or that can move freely */
309+
VIDEO_CAMERA_ORIENTATION_EXTERNAL = 2,
310+
};
311+
312+
/** This read-only control describes the orientation of the sensor in the device.
313+
* The value is the rotation correction in degrees in the counter-clockwise direction to be
314+
* applied to the captured images once captured to memory to compensate for the camera sensor
315+
* mounting rotation.
316+
*/
317+
#define VIDEO_CID_CAMERA_SENSOR_ROTATION (VIDEO_CID_CAMERA_CLASS_BASE + 35)
318+
122319
/**
123320
* @}
124321
*/

0 commit comments

Comments
 (0)