Skip to content

Commit 99a871e

Browse files
committed
drivers: video: introduce "GET" sub-operations
The video_get_ctrl() API permits to retrieve a value from a device using standard CIDs from <zephyr/drivers/video-controls.h>. The CIDs do not come with a range information, and to know which value to apply to a video driver, knowing the minimum and maximum value before-hand is required. This prevents building generic layers that handle any video devices, such as protocols such as USB UVC, GigE Vision, or anything making use of "zephyr,camera" chosen node. This commit introduces extra flags added to the CIDs that indicates to the target device that instead of returning the current value, they should return the minimum, maximum, or default value instead, with the same type as the current value. The GET_CUR operation having a flag of 0x00, this makes all drivers implicitly support this new API, with an opt-in migration to also support the extra controls, correctly rejecting the unsupported extra operations by default. Signed-off-by: Josuah Demangeon <me@josuah.net>
1 parent b6aed5c commit 99a871e

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

include/zephyr/drivers/video-controls.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,31 @@ extern "C" {
4242
* @}
4343
*/
4444

45+
/**
46+
* @name Control Get operations
47+
*
48+
* Extra flags for video controls to inquire about the dimensions of an existing
49+
* control: the minimum, maximum, or default value.
50+
*
51+
* For instance, OR-ing @c VIDEO_CID_CAMERA_EXPOSURE and @c VIDEO_CTRL_GET_MAX
52+
* permits to query the maximum exposure time instead of the current exposure
53+
* time.
54+
*
55+
* If no Control Get flag is added to a CID, the behavior is to fetch the current
56+
* value as with @ref VIDEO_CTRL_GET_CUR.
57+
* These must only be used along with the @ref video_get_ctrl() API.
58+
*
59+
* @{
60+
*/
61+
#define VIDEO_CTRL_GET_CUR 0x00000000 /**< Get the current value */
62+
#define VIDEO_CTRL_GET_MIN 0x00001000 /**< Get the minimum value */
63+
#define VIDEO_CTRL_GET_MAX 0x00002000 /**< Get the maximum value */
64+
#define VIDEO_CTRL_GET_DEF 0x00003000 /**< Get the default value */
65+
#define VIDEO_CTRL_GET_MASK 0x0000f000 /**< Mask for get operations */
66+
/**
67+
* @}
68+
*/
69+
4570
/**
4671
* @name Generic class control IDs
4772
* @{

include/zephyr/drivers/video.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* @brief Video Interface
1717
* @defgroup video_interface Video Interface
1818
* @since 2.1
19-
* @version 1.0.0
19+
* @version 1.1.0
2020
* @ingroup io_interfaces
2121
* @{
2222
*/

0 commit comments

Comments
 (0)