-
Notifications
You must be signed in to change notification settings - Fork 8.1k
video: gc2145/stm32_dcmi support Crop and basic DMA recovery #97491
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
base: main
Are you sure you want to change the base?
Conversation
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.
Thanks @KurtE for this PR. This is roughly good to me, some comments, small things to cleanup but nothing really big.
Only the last comment about the dcmi_dma_callback needs to be checked more. I recall seeing a potential issue before in the dma_stm32 code so I check this in parallel of your update of this PR.
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.
Reword 1st commit message to remove reference to video_stm32_dcmi, the cam driver could be used with any cam controller.
Reword 3rd commit message to remove the unnecessary talk about the other PR, and to have a message that actually describes the change and why it's needed.
4e37920
to
e21d91f
Compare
Twister failings... Is this another case where I should rebase again? |
You can see what is failing & why here |
e21d91f
to
d3244ca
Compare
Hi @KurtE, sorry for the delay. I checked the latest update and also gave it a try on my STM32H747I-DISCO. While I am not able to see the exact same DMA error symptoms as you, I managed to see several points:
(since channel / status are no more used, it is necessary to have ARG_UNUSED for those two). Could you check again on your side with PR #97741 applied and if ok, perform the above modifications as well in your PR ? In my experiment, since I force errors (either via DMA transfer error or DCMI overrun), there were lot of DCMI Restart happening and the system was becoming barely usable (very very slow) but, I guess in a normal situation (where those errors only come from time to time) that would be ok. |
d3244ca
to
fd62451
Compare
Thanks @KurtE for the check. Good news. Regarding the distorded image, is it fixed like that or it is like you can see the DMA actually writing into the memory and the image slowly coming up from the top fo the bottom ? At first I kind of thought that the patch I provided "helped" to get things a bit better but now I am not sure that is really the case, could you confirm ? This splitted frame is not something you had before ? What is better before my patch ? Regarding your PR, except this point to be clarified (but considering that this is error handling and if things are better than before, we might be ok to first go with this first improvement), I am ok with your code so ok to Approve it. If you can, could you just change the last patch commit message ? I think the part talking about PR is not needed and no need to have the update as well at the end. Once merged, those commits are no more related to PR so it doesn't make sense to refer to PRs. |
Thanks, the image does keep changing, so it is not hung and as I mentioned often times it will resync, although sometimes I think we still show two sometimes three messages pre recovery:
Will update the commit message |
fd62451
to
55fc348
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.
Two minor comments, you can update them if you think this is worth it, but not critical.
Thanks a lot for all the modifications and bringing the first sensor with video_set_selection()
support!
Adding a DNM flag to let the author of the PR decide if they want another push, or if the PR is ready to go. If the latter, then simply say so and we can remove the DNM flag, otherwise feel free to make the edits. Thanks all for the help with the review! |
Implements the set_selection and get_selection APIs, if forwarded to it by a camera controller. It uses the new messages to allow you to set a crop window on top of the current format window. It also then allows you to move this crop window around in the frame window. With this driver I also updated it to allow any resolution from the displays min to max limits. static const struct video_format_cap fmts[] = { GC2145_VIDEO_FORMAT_CAP_HL(128, 1600, 128, 1200, VIDEO_PIX_FMT_RGB565), GC2145_VIDEO_FORMAT_CAP_HL(128, 1600, 128, 1200, VIDEO_PIX_FMT_YUYV), When the resolution is set, it computes the scale factor. Using the set_selection(VIDEO_SEL_TGT_CROP) allows you define a crop window within the format window. It clamps the ratio to a max of 3 as some other drivers limit it saying it helps with frame rates. Signed-off-by: Kurt Eckhardt <[email protected]>
Forward the get_selection and set_selection APIs to the camera objects, to allow some of the selections to be supported at the camera level. Signed-off-by: Kurt Eckhardt <[email protected]>
On several boards, such as the Arduino Giga and Portenta H7, they are often times setup with their camera buffers and potentially video buffers in SDRam. This can lead to a significant number of DMA errors, which currently stops the camera from returning any additional frames. Signed-off-by: Kurt Eckhardt <[email protected]>
faba9a3
55fc348
to
faba9a3
Compare
@josuah - I pushed up the two changes. |
|
Added support to video_stm32_dcmi for the new
set and get selection. These implementations simply forward the message to the underlying
camera object if they support these messages.
GC2145 was updated first to support setting a crop window, using the order
try out these changes. The camera now allows me to follow the call order
of calls that @josuah mentioned in another pr/issue.
With this driver I also updated it to allow more or less any video resolution:
{
.pixelformat = format, .width_min = width_l, .width_max = width_h,
.height_min = height_l, .height_max = height_h, .width_step = 0, .height_step = 0,
}
static const struct video_format_cap fmts[] = {
GC2145_VIDEO_FORMAT_CAP_HL(128, 1600, 128, 1200, VIDEO_PIX_FMT_RGB565),
GC2145_VIDEO_FORMAT_CAP_HL(128, 1600, 128, 1200, VIDEO_PIX_FMT_YUYV),
When resolution is set, it computes the scale factor. If you then later call set_crop, the same code is
used except it uses the ratios computed from the set_resolution.
In addition, I pulled in the minimal DCMI changes, that allow the camera code to recover after some DMA
errors.
This is a partial replacement for #93797 It does not support the SNAPSHOT mode that is part of that PR, but decided
it might be simpler and easier to understand if this was done instead in smaller steps.