-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
drivers: video: Add support for STM32 DCMI #71462
drivers: video: Add support for STM32 DCMI #71462
Conversation
e35d0c7
to
fe7f3ba
Compare
Fix code style and remove the code to generate mock images. |
fe7f3ba
to
de5ab1f
Compare
Fix compliance errors. |
drivers/video/video_stm32_dcmi.c
Outdated
|
||
vbuf->bytesused = data->pitch * data->height; | ||
|
||
int err = HAL_DCMI_Start_DMA(&data->hdcmi, DCMI_MODE_SNAPSHOT, |
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.
Any plan to support continuous capture?
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.
I don't have intention for this version. Maybe in a future as an improvement.
Both sample codes for video capture are based on performing an enqueue command before dequeue. In this way, I believe that a snapshot strategy is enough.
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 If i we enqueue two buffers? should'nt we start DMA transfer only for the first one? and restart internally on frame done?
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.
The function HAL_DCMI_Start_DMA
can be called only on time. If this function is called again, the HAL_ERROR
is returned.
In the ST sample code, only one video buffer is used. Below is described the workflow in those samples:
- Start the DCMI via HAL_DCMI_Start_DMA in DCMI_MODE_CONTINUOUS.
- When the HAL_DCMI_FrameEventCallback is trigger, call the HAL_DCMI_Suspend.
- Retrieve the video buffer.
- Resume the DCMI via HAL_DCMI_Resume.
- Repeat item 2.
I can try to reproduce that workflow, but I believe that the result will be the same. Please, let me know if I missed something.
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.
Think better, I believe it's more sensible to retain the existing workflow, since the video buffer is passed through the enqueue function. I mean, call the HAL_DCMI_Start_DMA inside the enqueue.
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.
Does it work with the simple generic video capture sample in samples/subsys/video/capture/ ?
(If we enqueue several buffers, I would expect that seconds one is used once the first one as been completed, and so on.)
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.
I created this sample version. It'll work if you enqueue just one buffer. Link to the sample code #71463.
Next week I'll try to look more into DCMI ST API to check if I can do better.
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.
Hi, @loicpoulain.
I changed the driver to work as continuous capture and with more than one video framebuffer.
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.
Since HAL_DCMI_Start_DMA can only work with one buffer, I created a dedicated buffer to store the frame data. This is the current workflow:
- application enqueue one or more buffers.
- call start capture function.
- The DCMI driver creates a buffer with CONFIG_VIDEO_BUFFER_POOL_SZ_MAX size to store the frame data and starts the capture in continuous mode.
- when the interrupt occurs, call DCMI suspend function
- If a video buffer is available, copy the frame data from the DCMI buffer to the video buffer.
- resume the DCMI capture.
- go to item 4.
This driver was tested with this sample code #71463
de5ab1f
to
12db860
Compare
Rebase the branch and small changes to the YAML to became similar to Linux YAML. |
12db860
to
24d2201
Compare
d045930
to
44da247
Compare
Update the driver to work in DCMI_MODE_CONTINUOUS and with more than one video framebuffer in the application. |
f660106
to
eba3d80
Compare
Add the capture-rate property. This allows us to set up the frame capture rate. |
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.
A great thanks for this contribution.
eba3d80
to
afb098a
Compare
Implement the previous suggestions, except the one about changing the check for the |
afb098a
to
6da44e2
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.
Last round of comments and this'll be fine to me. Thanks again @CharlesDias !
Add the DCMI node into stm32h7.dtsi. Signed-off-by: Charles Dias <[email protected]>
6da44e2
to
b421621
Compare
Add Kconfig, DCMI driver, Yaml, and CMakeLists files Signed-off-by: Charles Dias <[email protected]>
b421621
to
0a8e77e
Compare
Implement @fabiobaltieri's suggestions. |
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 !
interrupts: | ||
required: true | ||
|
||
sensor: |
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 got changed in #72623
Will need some new PR to update depending on the outcome.
Dear,
The goal is to provide the STM32 DCMI driver. I'm creating the sample to capture a frame image and sent it to LCD ( PR #71463). That sample has been tested on the mini_stm32h743 target with the OV2640 camera model.
Note: This current version was implemented only for STM32H7 family and doesn't support the JPEG pix format.
Related PR:
document_4958923842157282345.mp4