-
Notifications
You must be signed in to change notification settings - Fork 8.2k
drivers: video: controls: rename all CIDs to Linux counterpart #78802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d1d932a
32f2a72
b34d97a
b41d529
7f5e3e8
845d408
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
ngphibang marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,85 +1,162 @@ | ||
| /** | ||
| * @file | ||
| * | ||
| * @brief Public APIs for Video. | ||
| */ | ||
|
|
||
| /* | ||
| * Copyright (c) 2019 Linaro Limited. | ||
| * Copyright (c) 2024 tinyVision.ai Inc. | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| #ifndef ZEPHYR_INCLUDE_VIDEO_CONTROLS_H_ | ||
| #define ZEPHYR_INCLUDE_VIDEO_CONTROLS_H_ | ||
|
|
||
| /** | ||
| * @file | ||
| * | ||
| * @brief Public APIs for Video. | ||
| */ | ||
|
|
||
| /** | ||
| * @brief Video controls | ||
| * @defgroup video_controls Video Controls | ||
| * @ingroup io_interfaces | ||
| * | ||
| * The Video control IDs (CIDs) are introduced with the same name as | ||
| * Linux V4L2 subsystem and under the same class. This facilitates | ||
| * inter-operability and debugging devices end-to-end across Linux and | ||
| * Zephyr. | ||
| * | ||
| * This list is maintained compatible to the Linux kernel definitions in | ||
| * @c linux/include/uapi/linux/v4l2-controls.h | ||
| * | ||
| * @{ | ||
| */ | ||
|
|
||
| #include <zephyr/device.h> | ||
| #include <stddef.h> | ||
| #include <zephyr/kernel.h> | ||
|
|
||
| #include <zephyr/types.h> | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| /** | ||
| * @name Control classes | ||
| * @name Base class control IDs | ||
| * @{ | ||
| */ | ||
| #define VIDEO_CTRL_CLASS_GENERIC 0x00000000 /**< Generic class controls */ | ||
| #define VIDEO_CTRL_CLASS_CAMERA 0x00010000 /**< Camera class controls */ | ||
| #define VIDEO_CTRL_CLASS_MPEG 0x00020000 /**< MPEG-compression controls */ | ||
| #define VIDEO_CTRL_CLASS_JPEG 0x00030000 /**< JPEG-compression controls */ | ||
| #define VIDEO_CTRL_CLASS_VENDOR 0xFFFF0000 /**< Vendor-specific class controls */ | ||
| #define VIDEO_CID_BASE 0x00980900 | ||
|
|
||
| /** Amount of perceived light of the image, the luma (Y') value. */ | ||
| #define VIDEO_CID_BRIGHTNESS (VIDEO_CID_BASE + 0) | ||
|
|
||
| /** Amount of difference between the bright colors and dark colors. */ | ||
| #define VIDEO_CID_CONTRAST (VIDEO_CID_BASE + 1) | ||
|
|
||
| /** Colorfulness of the image while preserving its brightness */ | ||
| #define VIDEO_CID_SATURATION (VIDEO_CID_BASE + 2) | ||
|
|
||
| /** Shift in the tint of every colors, clockwise in a RGB color wheel */ | ||
| #define VIDEO_CID_HUE (VIDEO_CID_BASE + 3) | ||
|
|
||
| /** Amount of time an image sensor is exposed to light, affecting the brightness */ | ||
| #define VIDEO_CID_EXPOSURE (VIDEO_CID_BASE + 17) | ||
|
Comment on lines
+42
to
+55
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I appreciate the effort to make sure all public API is documented but FWIW I find these oddly worded for some reason. I guess that's what happens when the names are already mostly self-explanatory and one doesn't want to literally paraphrase them in the comment. Not blocking though :)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I have same thoughts too and sometimes, the explanation is not totally correct as it is difficult to explain in short words, so it is better to not explain, developers who actually use these CID need to understand them, I think :-). But it's not a blocking point.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reading them again, these do not help understanding what the control do. Better not risk defining them slightly differently than Linux ones. Frequent issue of newbies: they reinvent the wheel. New PR to address these small changes. Thank you for the feedback . :)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about a link to this page for reference?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I think it's a good idea but I am not sure if it's OK in Zephyr to refer to documentation of a different project. |
||
|
|
||
| /** Amount of amplification performed to each pixel electrical signal, affecting the brightness */ | ||
| #define VIDEO_CID_GAIN (VIDEO_CID_BASE + 19) | ||
|
|
||
| /** Flip the image horizontally: the left side becomes the right side */ | ||
| #define VIDEO_CID_HFLIP (VIDEO_CID_BASE + 20) | ||
|
|
||
| /** Flip the image vertically: the top side becomes the bottom side */ | ||
| #define VIDEO_CID_VFLIP (VIDEO_CID_BASE + 21) | ||
|
|
||
| /** Frequency of the power line to compensate for, avoiding flicker due to artificial lighting */ | ||
| #define VIDEO_CID_POWER_LINE_FREQUENCY (VIDEO_CID_BASE + 24) | ||
| enum video_power_line_frequency { | ||
| VIDEO_CID_POWER_LINE_FREQUENCY_DISABLED = 0, | ||
| VIDEO_CID_POWER_LINE_FREQUENCY_50HZ = 1, | ||
| VIDEO_CID_POWER_LINE_FREQUENCY_60HZ = 2, | ||
| VIDEO_CID_POWER_LINE_FREQUENCY_AUTO = 3, | ||
| }; | ||
|
|
||
| /** Balance of colors in direction of blue (cold) or red (warm) */ | ||
| #define VIDEO_CID_WHITE_BALANCE_TEMPERATURE (VIDEO_CID_BASE + 26) | ||
|
|
||
| /** | ||
| * @} | ||
| */ | ||
|
|
||
| /** | ||
| * @name Stateful codec controls IDs | ||
| * @{ | ||
| */ | ||
| #define VIDEO_CID_CODEC_CLASS_BASE 0x00990900 | ||
|
|
||
| /** | ||
| * @} | ||
| */ | ||
|
|
||
| /** | ||
| * @name Generic class control IDs | ||
| * @name Camera class controls IDs | ||
| * @{ | ||
| */ | ||
| /** Mirror the picture horizontally */ | ||
| #define VIDEO_CID_HFLIP (VIDEO_CTRL_CLASS_GENERIC + 0) | ||
| /** Mirror the picture vertically */ | ||
| #define VIDEO_CID_VFLIP (VIDEO_CTRL_CLASS_GENERIC + 1) | ||
| /** Power line frequency (enum) filter to avoid flicker */ | ||
| #define VIDEO_CID_POWER_LINE_FREQUENCY (VIDEO_CTRL_CLASS_GENERIC + 2) | ||
| #define VIDEO_CID_CAMERA_CLASS_BASE 0x009a0900 | ||
|
|
||
| /** Amount of optical zoom applied through to the camera optics */ | ||
| #define VIDEO_CID_ZOOM_ABSOLUTE (VIDEO_CID_CAMERA_CLASS_BASE + 13) | ||
|
|
||
| /** | ||
| * @} | ||
| */ | ||
|
|
||
| /** | ||
| * @name Camera Flash class control IDs | ||
| * @{ | ||
| */ | ||
| #define VIDEO_CID_FLASH_CLASS_BASE 0x009c0900 | ||
|
|
||
| /** | ||
| * @} | ||
| */ | ||
|
|
||
| /** | ||
| * @name JPEG class control IDs | ||
| * @{ | ||
| */ | ||
| #define VIDEO_CID_JPEG_CLASS_BASE 0x009d0900 | ||
|
|
||
| /** Quality (Q) factor of the JPEG algorithm, also increasing the data size */ | ||
| #define VIDEO_CID_JPEG_COMPRESSION_QUALITY (VIDEO_CID_JPEG_CLASS_BASE + 3) | ||
|
|
||
| /** | ||
| * @} | ||
| */ | ||
|
|
||
| /** | ||
| * @name Image Source class control IDs | ||
| * @{ | ||
| */ | ||
| #define VIDEO_CID_IMAGE_SOURCE_CLASS_BASE 0x009e0900 | ||
|
|
||
| /** | ||
| * @} | ||
| */ | ||
|
|
||
| /** | ||
| * @name Image Processing class control IDs | ||
| * @{ | ||
| */ | ||
| #define VIDEO_CID_IMAGE_PROC_CLASS_BASE 0x009f0900 | ||
|
|
||
| /** Pixel rate (pixels/second) in the device's pixel array. This control is read-only. */ | ||
| #define VIDEO_CID_PIXEL_RATE (VIDEO_CTRL_CLASS_GENERIC + 3) | ||
| #define VIDEO_CID_PIXEL_RATE (VIDEO_CID_IMAGE_PROC_CLASS_BASE + 2) | ||
|
|
||
| enum video_power_line_frequency { | ||
| VIDEO_CID_POWER_LINE_FREQUENCY_DISABLED = 0, | ||
| VIDEO_CID_POWER_LINE_FREQUENCY_50HZ = 1, | ||
| VIDEO_CID_POWER_LINE_FREQUENCY_60HZ = 2, | ||
| VIDEO_CID_POWER_LINE_FREQUENCY_AUTO = 3, | ||
| }; | ||
| /** Selection of the type of test pattern to represent */ | ||
| #define VIDEO_CID_TEST_PATTERN (VIDEO_CID_IMAGE_PROC_CLASS_BASE + 3) | ||
|
|
||
| /** | ||
| * @} | ||
| */ | ||
|
|
||
| /** | ||
| * @name Camera class control IDs | ||
| * @name Vendor-specific class control IDs | ||
| * @{ | ||
| */ | ||
| #define VIDEO_CID_CAMERA_EXPOSURE (VIDEO_CTRL_CLASS_CAMERA + 0) | ||
| #define VIDEO_CID_CAMERA_GAIN (VIDEO_CTRL_CLASS_CAMERA + 1) | ||
| #define VIDEO_CID_CAMERA_ZOOM (VIDEO_CTRL_CLASS_CAMERA + 2) | ||
| #define VIDEO_CID_CAMERA_BRIGHTNESS (VIDEO_CTRL_CLASS_CAMERA + 3) | ||
| #define VIDEO_CID_CAMERA_SATURATION (VIDEO_CTRL_CLASS_CAMERA + 4) | ||
| #define VIDEO_CID_CAMERA_WHITE_BAL (VIDEO_CTRL_CLASS_CAMERA + 5) | ||
| #define VIDEO_CID_CAMERA_CONTRAST (VIDEO_CTRL_CLASS_CAMERA + 6) | ||
| #define VIDEO_CID_CAMERA_TEST_PATTERN (VIDEO_CTRL_CLASS_CAMERA + 7) | ||
| #define VIDEO_CID_CAMERA_QUALITY (VIDEO_CTRL_CLASS_CAMERA + 8) | ||
| #define VIDEO_CID_CAMERA_HUE (VIDEO_CTRL_CLASS_CAMERA + 9) | ||
| #define VIDEO_CID_PRIVATE_BASE 0x08000000 | ||
|
|
||
| /** | ||
| * @} | ||
| */ | ||
|
|
@@ -88,8 +165,6 @@ enum video_power_line_frequency { | |
| } | ||
| #endif | ||
|
|
||
| /* Controls */ | ||
|
|
||
| /** | ||
| * @} | ||
| */ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.