-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Merged
cfriedt
merged 6 commits into
zephyrproject-rtos:main
from
avolmat-st:pr-dcmipp-caps-uvc-range
Oct 23, 2025
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
dfe5139
video: dcmipp: expose dcmipp caps for all 3 pipes.
ee17acf
video: introduce video_set_compose_format helper
49458fc
samples: video: capture: use video_set_compose_format helper
fe96014
samples: usb: uvc: ensure video buffer is properly aligned
a5971e1
samples: usb: uvc: use video_set_compose_format
d2e3f66
samples: usb: uvc: select applicable resolutions from range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -98,10 +98,14 @@ int main(void) | |
| struct video_frmival frmival; | ||
| struct video_frmival_enum fie; | ||
| enum video_buf_type type = VIDEO_BUF_TYPE_OUTPUT; | ||
| #if (CONFIG_VIDEO_SOURCE_CROP_WIDTH && CONFIG_VIDEO_SOURCE_CROP_HEIGHT) || \ | ||
| CONFIG_VIDEO_FRAME_HEIGHT || CONFIG_VIDEO_FRAME_WIDTH | ||
| struct video_selection sel = { | ||
| #if (CONFIG_VIDEO_SOURCE_CROP_WIDTH && CONFIG_VIDEO_SOURCE_CROP_HEIGHT) | ||
| struct video_selection crop_sel = { | ||
| .type = VIDEO_BUF_TYPE_OUTPUT, | ||
| .target = VIDEO_SEL_TGT_CROP; | ||
| .rect.left = CONFIG_VIDEO_SOURCE_CROP_LEFT; | ||
| .rect.top = CONFIG_VIDEO_SOURCE_CROP_TOP; | ||
| .rect.width = CONFIG_VIDEO_SOURCE_CROP_WIDTH; | ||
| .rect.height = CONFIG_VIDEO_SOURCE_CROP_HEIGHT; | ||
| }; | ||
| #endif | ||
| unsigned int frame = 0; | ||
|
|
@@ -149,20 +153,14 @@ int main(void) | |
|
|
||
| /* Set the crop setting if necessary */ | ||
| #if CONFIG_VIDEO_SOURCE_CROP_WIDTH && CONFIG_VIDEO_SOURCE_CROP_HEIGHT | ||
| sel.target = VIDEO_SEL_TGT_CROP; | ||
| sel.rect.left = CONFIG_VIDEO_SOURCE_CROP_LEFT; | ||
| sel.rect.top = CONFIG_VIDEO_SOURCE_CROP_TOP; | ||
| 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)) { | ||
| LOG_ERR("Unable to set selection crop"); | ||
| return 0; | ||
| } | ||
| LOG_INF("Selection crop set to (%u,%u)/%ux%u", | ||
| sel.rect.left, sel.rect.top, sel.rect.width, sel.rect.height); | ||
| #endif | ||
|
|
||
| #if CONFIG_VIDEO_FRAME_HEIGHT || CONFIG_VIDEO_FRAME_WIDTH | ||
| #if CONFIG_VIDEO_FRAME_HEIGHT | ||
| fmt.height = CONFIG_VIDEO_FRAME_HEIGHT; | ||
| #endif | ||
|
|
@@ -171,39 +169,14 @@ int main(void) | |
| fmt.width = CONFIG_VIDEO_FRAME_WIDTH; | ||
| #endif | ||
|
|
||
| /* | ||
| * Check (if possible) if targeted size is same as crop | ||
| * and if compose is necessary | ||
| */ | ||
| sel.target = VIDEO_SEL_TGT_CROP; | ||
| err = video_get_selection(video_dev, &sel); | ||
| if (err < 0 && err != -ENOSYS) { | ||
| LOG_ERR("Unable to get selection crop"); | ||
| return 0; | ||
| } | ||
|
|
||
| if (err == 0 && (sel.rect.width != fmt.width || sel.rect.height != fmt.height)) { | ||
| sel.target = VIDEO_SEL_TGT_COMPOSE; | ||
| sel.rect.left = 0; | ||
| sel.rect.top = 0; | ||
| sel.rect.width = fmt.width; | ||
| sel.rect.height = fmt.height; | ||
| err = video_set_selection(video_dev, &sel); | ||
| if (err < 0 && err != -ENOSYS) { | ||
| LOG_ERR("Unable to set selection compose"); | ||
| return 0; | ||
| } | ||
| } | ||
| #endif | ||
|
|
||
| if (strcmp(CONFIG_VIDEO_PIXEL_FORMAT, "")) { | ||
| fmt.pixelformat = VIDEO_FOURCC_FROM_STR(CONFIG_VIDEO_PIXEL_FORMAT); | ||
| } | ||
|
|
||
| LOG_INF("- Video format: %s %ux%u", | ||
| 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Same as #94562 (comment) |
||
| LOG_ERR("Unable to set format"); | ||
| return 0; | ||
| } | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
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:
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) {andif (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.