-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Allow STM32 DCMIPP to work with UVC sample #94562
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
Allow STM32 DCMIPP to work with UVC sample #94562
Conversation
|
fcd6732 to
371ef0e
Compare
|
Simply rebased for the time being, removing the DCMIPP Planar commit which are not already merged. |
371ef0e to
99218f4
Compare
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.
LGTM. Thanks
b0f77aa to
5120e27
Compare
|
Updated, simply rebase the 6 commits of this PR on top of the commits of PR #93192. ret = app_add_format(vcap->pixelformat, video_common_fmts[j].width,
video_common_fmts[j].height, has_sup_fmts);
if (ret != 0) {
return ret;
} |
|
|
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.
Removed DNM as dependencies are merged or on merge-list.
LGTM for the video additions, thank you!
Waiting @jfischer-no feedback and #93192 to be merged to +1
Currently the DCMIPP driver rely on a Kconfig in order to
select the right sensor resolution / format to pick.
This also makes the exposure of caps easier since it can
be exposed as:
DUMP pipe: same caps as mentioned in Kconfig
MAIN pipe: any format supported on this pipe and resolution
starting at sensor selected resolution down to
64 times smaller (which is the maximum of the
downscale)
AUX pipe: same as MAIN except without the semi-planar and
planar formats
Signed-off-by: Alain Volmat <[email protected]>
Some devices allow for downscale / upscale via the set_selection compose API. When using it, it is necessary to perform a set_selection of the compose target prior to setting the format. In order to allow non-compose aware application to benefit from it, introduce a helper which take care of setting the compose prior to setting the format. Signed-off-by: Alain Volmat <[email protected]>
Simplify the code by using the video_set_compose_format helper. Signed-off-by: Alain Volmat <[email protected]>
Honor the CONFIG_VIDEO_BUFFER_POOL_ALIGN config by using the video_buffer_aligned_alloc function instead of video_buffer_alloc in order to provide properly aligned buffers to drivers. Signed-off-by: Alain Volmat <[email protected]>
Use the helper video_set_compose_format in order to allow controlling the compose. Signed-off-by: Alain Volmat <[email protected]>
Select from commonly used resolution when the video device advertise capabilities using range. Signed-off-by: Alain Volmat <[email protected]>
5120e27 to
d2e3f66
Compare
| STM32_DCMIPP_MAX_PIPE_SCALE_FACTOR), \ | ||
| .height_max = CONFIG_VIDEO_STM32_DCMIPP_SENSOR_HEIGHT, \ | ||
| .width_step = pixmul, .height_step = 1, \ | ||
| } |
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.
This closing brace should be indented by a tab IMHO, since it's part of a macro.
| sel.rect.width = CONFIG_VIDEO_SOURCE_CROP_WIDTH; | ||
| sel.rect.height = CONFIG_VIDEO_SOURCE_CROP_HEIGHT; | ||
| if (video_set_selection(video_dev, &sel)) { | ||
| if (video_set_selection(video_dev, &crop_sel)) { |
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.
Prefer
if (video_set_selection(video_dev, &crop_sel) < 0) {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.
That is nonsense, even would introduce undefined behavior and -1 from my side.
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.
What do you mean by an undefined behavior?
If you prefer:
if (video_set_selection(video_dev, &crop_sel) != 0) {I'm fine too.
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.
That is completely different proposal, at least for USB that would be preferable, but there is no difference between if (video_set_selection(video_dev, &crop_sel) != 0) { and if (video_set_selection(video_dev, &crop_sel)) {.
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.
My mistake. I misised we're here in a demo sample.
| VIDEO_FOURCC_TO_STR(fmt.pixelformat), fmt.width, fmt.height); | ||
|
|
||
| if (video_set_format(video_dev, &fmt)) { | ||
| if (video_set_compose_format(video_dev, &fmt)) { |
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.
Ditto:
if (video_set_compose_format(video_dev, &fmt) < 0) {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.
Same as #94562 (comment)
|
|
By the way, my review comments are non blocking (hence I did not send a "Request change" notif). |
|
The previous style from the samples is from long ago and new PRs tried to be locally consistent (discussion at #95862 (comment) for instance). Importing the video sample code as-is implies a PR to go fix that (#96072). But why not importing the sample code using the current Zephyr coding style directly. Thanks for pointing it out! The large amount of code in samples is meant to be refactored into identical helpers for all samples in the meantime that libMP is proposed [video, pdf]. |



This PR contains various area commits.
I keep this in draft since this is still work in progress and I'd like to open the discussion about those topics.
I added the
video_set_compose_formathelper (probably not the best name) in order to add automatically the call to set_selection. However we might want, in the same helper or not to go even further of that and, if the device support it use crop to achieve the format requested, there could also be an option to for example keep aspect-ratio, which do the heavy lifting of checking the native resolution and perform the crop / compose in order to get a frame with the requested resolution while keeping aspect-ratio (if it has been asked to).I used this new helper on the UVC sample as well, making it easy to select the right resolution.
When a device is advertising a range of width/height, the current UVC sample only expose the max and min resolutions (assuming they can be achieved from a memory point of view).
There would be various way to achieve computing of intermediate resolutions, computing the aspect ratio as well, depending on the step value advertised by the device the amount of intermediate resolution requested (or should I say limited).
In a trial to keep it simple, I put instead a list of commonly used resolution and have the sample app simply check if this can be achieved or not.
This PR depends on 2 other PRs, PR #93192 and PR #94081 so I merged them at the beginning so only the last 6 commits are relevant in this serie.