drivers: video: controls: add the BASE and CAMERA controls#88924
drivers: video: controls: add the BASE and CAMERA controls#88924kartben merged 1 commit intozephyrproject-rtos:mainfrom
Conversation
5bb4384 to
bb9f7c0
Compare
| static const char *const camera_power_line_frequency[] = {"Disabled", "50 Hz", "60 Hz", | ||
| "Auto", NULL}; | ||
| static const char *const camera_exposure_auto[] = {"Auto Mode", "Manual Mode", | ||
| "Shutter Priority Mode", | ||
| "Aperture Priority Mode", NULL}; | ||
|
|
There was a problem hiding this comment.
Proposing a slightly different strategy aiming to reduce effort when adding new controls.
There was a problem hiding this comment.
I think with the old static array definition, the data is stored once and persist to the end of the program. By changing to anonymous literal like that, it needs to create temporal char arrays each time the function is called, no ?
There was a problem hiding this comment.
Right, they are not static, so it is less obvious for average C developer like me what happens in such case, I'd have to look at the standard to know, while static const char *const names[]; is obvious.
| enum video_exposure_auto_type { | ||
| enum video_exposure_auto { |
There was a problem hiding this comment.
Maybe I should do it the other way around: keep the _type suffix every time...
There was a problem hiding this comment.
enum video_exposure_auto is confused with one of the exposure type: VIDEO_EXPOSURE_AUTO = 0,
I think it should rather be enum video_exposure_type as the type suffice is important to say that, for example in a function foo(enum video_exposure_type type) we should put one of the exposure types : auto or manual or shutter, etc.
LGTM, it always good to have new controls support ready, though we should keep in mind that some platforms will be very low in resources and may only want to act as dumb image capture, without embedded control or processing (general comment for the whole video subsystem). So maybe at some point we should think about optimizing this and have unused stuff stripped, either via the preprocessor or linker. |
ngphibang
left a comment
There was a problem hiding this comment.
nits:
- commit title:
drivers: video: controls: add more BASE and CAMERA control IDs - commit message:
- "Buttons are left as integer for now": I don't see where is the button stuffs ?
- "For the minimum number of buffer, Zephyr uses a different mechanism": I don't see where is the buffer stuffs ?
| static const char *const camera_power_line_frequency[] = {"Disabled", "50 Hz", "60 Hz", | ||
| "Auto", NULL}; | ||
| static const char *const camera_exposure_auto[] = {"Auto Mode", "Manual Mode", | ||
| "Shutter Priority Mode", | ||
| "Aperture Priority Mode", NULL}; | ||
|
|
There was a problem hiding this comment.
I think with the old static array definition, the data is stored once and persist to the end of the program. By changing to anonymous literal like that, it needs to create temporal char arrays each time the function is called, no ?
| enum video_exposure_auto_type { | ||
| enum video_exposure_auto { |
There was a problem hiding this comment.
enum video_exposure_auto is confused with one of the exposure type: VIDEO_EXPOSURE_AUTO = 0,
I think it should rather be enum video_exposure_type as the type suffice is important to say that, for example in a function foo(enum video_exposure_type type) we should put one of the exposure types : auto or manual or shutter, etc.
|
Thank you for adding many more control IDs.
In general, not specific to this PR, I think incremental development is a better approach. We should only add what we need (and even more most of people need, for example, in Linux there are a number of extensions proposed by vendors not go to upstream due to this reason) to avoid dead/unused code.
Agreed. The controls IDs do not take much space. But in other cases, apart from resources concern, code should be added if having its usage (e.g. utility functions, etc.). This is not only for the resources concerns but for clarity (people may ask why it is there but have no usage) and consistency (code can be added without proving its usage). When unused code added, I think it will stay there for a very long time because people think "it's better not to touch them maybe someone else need them ...". Just some thought in general :-). About the PR, it's fine to me to add all the "common" control IDs that we think "will be used". Some controls seems very rarely used. |
Big tables of strings can be big in resource use, I will compare the size before/after for the capture example of various boards and compare it there.
I will go check what the image sensor and UVC could implement and whitelist these controls. This should help with code size too. Thank you all for the feedback! :) |
I noticed that on the Linux doc site:
|
This was about these controls in Linux:
In Zephyr this seems to be how it is currently done: zephyr/include/zephyr/drivers/video.h Line 101 in 4680590 |
bb9f7c0 to
f74cc53
Compare
josuah
left a comment
There was a problem hiding this comment.
I went ahead and marked as 'resolved' each of these:
- KEEP everything used by uvc or libcamera or ov5640 or multiple sensors
- REMOVE everything used by a one or two ISP chips or CPUs
Remain only the special cases.
|
I made a choice for each of remaining cases. Thanks |
josuah
left a comment
There was a problem hiding this comment.
Thank you! All ready to go then.
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>
f74cc53 to
ab35f97
Compare
Downstream:
The new control framework is merged! 🎉
It seemed easier to batch-import controls than add them one by one in a hundred of small pull requests. Is this the right approach? Controls from the "BASE" and "CAMERA" that Zephyr APIs can support, (not audio and not video compression) are chosen.
P.S.: Clang-format is ignored for
video_get_std_menu_ctrl()in particular, as its heuristic was picking a different strategy for every line.