Skip to content

video: dcmi: add endpoint usage in dcmi & update dma property in dtsi #89627

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
merged 11 commits into from
May 14, 2025

Conversation

avolmat-st
Copy link
Collaborator

@avolmat-st avolmat-st commented May 7, 2025

This PR update the DCMI driver / bindings and all users of this driver in order to rely on the video-interfaces bindings rather that having its own properties.
In a second step, considering that the DMA settings are closely linked to the IP itself and the way it is connected internally, I propose to move the dma property from within the board dts into the dtsi so that each board / shield overlay do not have to copy again the same property. As a matter of fact the dcmi driver is also setting most of the DMA settings from within the driver itself.

@avolmat-st
Copy link
Collaborator Author

Sadly I do not have the HW to test it right now so I have only been able to compile test it. Could someone having those setup perform a sanity check that I didn't broke anything ?

@ngphibang
Copy link
Collaborator

ngphibang commented May 7, 2025

cc @CharlesDias so that he is aware of this to avoid duplicate work. I think part of this has been started in #85452 but this one is more complete.

Could you add an overlay and test case in video's build_all tests as well so that the DCMI driver can get in the CI (#85178) ?

Thanks !

hsync-active = <0>;
vsync-active = <0>;
pixelclk-active = <1>;
capture-rate = <1>;
Copy link
Collaborator

@ngphibang ngphibang May 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems analogy with the camera framerate ? Would you support of changing framerate with the video API after removing this propperty ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I only removed it from the example, it is still present in the bindings itself. However it is optional and within the driver I took care of having DT_PROP_OR with a default to 1, aka no frame skip. So since this is the default (and actually quite natural), I thought it is simply not necessary to mention it here.

Regarding the already started work, sorry, I wasn't aware about it hence I did that. Sure I can add the remaining bits within the build_all tests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I just had a look at the PR #85452 now so I understand better your point. The DCMI IP is actually capable of frame dropping. The capture-rate mentioned here is actually more like a drop rate. 1 means keep 1/1 frames (aka all), 2 means keep 1 frame out of 2 and 4 would mean keep 1 frame out of 4.
So, basically, it would be possible to map this on the framerate API by first checking the framerate up the pipeline to figure out (if possible) the source framerate (might have to go quite far there might be a bridge or so in the middle), and then compute the rate between the framerate expected by the caller compared to the framerate of the source. Not an impossible thing. I can give it a shot, however again, I will only be able to blindly check it since I don't have currently a working setup with the DCMI on it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @avolmat-st. Thanks for your contribution.

@ngphibang, it's ok for me to continue with this PR instead of #85452. :-)

I tested this PR with the west build -p -b stm32h7b3i_dk --shield st_b_cams_omv_mb1683 samples/drivers/video/capture_to_lvgl/ and worked!

@avolmat-st
Copy link
Collaborator Author

avolmat-st commented May 8, 2025

frmival set/get/enum support added and simply tested using a stm32l4r9i using the video shell.
I also added an additionnal commit to change a bit handling of the set/get fmt.

Last commit adds a testcase within test/drivers/build_all/video in order to test build the dcmi. For that purpose I am using one of the board and its shield so that dcmi get enabled and thus build. I ran this with twister and it seems to build, however couldn't figure out how to see the full log and really ensure that dcmi get enabled in this configuration.

@ngphibang is that what you were expecting regarding the testcase ? I saw that in case of the NXP board there is an overlay within the build_all folder, it seems to me that if really shield get enabled then it should be enough to enable the build of the driver no ?

@ngphibang
Copy link
Collaborator

ngphibang commented May 10, 2025

Last commit adds a testcase within test/drivers/build_all/video in order to test build the dcmi. For that purpose I am using one of the board and its shield so that dcmi get enabled and thus build. I ran this with twister and it seems to build, however couldn't figure out how to see the full log and really ensure that dcmi get enabled in this configuration.

@ngphibang is that what you were expecting regarding the testcase ? I saw that in case of the NXP board there is an overlay within the build_all folder, it seems to me that if really shield get enabled then it should be enough to enable the build of the driver no ?

Yes, the driver get built by just adding the shield as an extra args in the test case as you did (if we have only one platform_allow).

The NXP's case is a bit different. We have CSI which is common on 2 platforms, and if I remember well, when I did:

  drivers.video.mcux_csi.build:
    platform_allow:
      - mimxrt1064_evk
      - mimxrt1170_evk/mimxrt1176/cm7
    extra_args:
      - platform:mimxrt1064_evk:SHIELD=dvp_fpc24_mt9m114
      - platform:mimxrt1170_evk/mimxrt1176/cm7:SHIELD=nxp_btb44_ov5640

It didn't get built because "platform" is not taken into account. I didn't know why.

Another reason is that I see this in the app.overlay of the build_all video:

/*
 * Copyright (c) 2022, Kumar Gala <galak@kernel.org>
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Application overlay for testing driver builds
 *
 * Names in this file should be chosen in a way that won't conflict
 * with real-world devicetree nodes, to allow these tests to run on
 * (and be extended to test) real hardware.
 */

So, I supposed that for CI testing, we should declare "fake" nodes to avoid conflicting with real-world device tree node, and so, should not use the real shield (?). So, to simplify things for two above reasons, I made the overlay.

I am not expert in test, so if you find some thing, I am willing to learn.

ngphibang
ngphibang previously approved these changes May 10, 2025
Copy link
Collaborator

@ngphibang ngphibang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very nice to me ! Thank you for doing the migration of the driver.

Waiting for your finding on the build_all video test (to see if overlay is the right thing to do or the simple extra args).

@github-actions github-actions bot added the Release Notes To be mentioned in the release notes label May 12, 2025
josuah
josuah previously approved these changes May 12, 2025
Copy link
Member

@erwango erwango left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM

Alain Volmat added 10 commits May 12, 2025 16:14
Update the bindings of the stm32-dcmi driver rely on
properties described within the endpoints and already
detailed within the video-interfaces.yaml.

With that, several properties located at the node root
are now moved into the port / endpoint:

  sensor -> endpoint: remote-endpoint-label
  vsync-active -> endpoint: vsync-active
  hsync-active -> endpoint: hsync-active
  pixelclk-active -> endpoint: pclk-sample
  bus-width -> endpoint: bus-width

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Perform sensor interface properties parsing based on values
retrieved via the endpoint rather than the root of the node.
Use DT_PROP_OR to ensure proper configuration of optional
settings.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Update overlay following usage of video-interfaces based
endpoint properties by the dcmi driver.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Update overlay following usage of video-interfaces based
endpoint properties by the dcmi driver.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Update overlay following usage of video-interfaces based
endpoint properties by the dcmi driver.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Usage of dma is mandatory for the dcmi and this property is
tightly coupled with the soc itself since the configuration of
the dma depends on the source/destination, and the request line
is also fixed for an ip.
Instead of having to always have the dma property part of the
board or shield dts/overlay, add the dma property into the
dcmi node of the stm32h7.dtsi.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
With the addition of the dma property within the soc dtsi, it is
no more necessary to add it within the board dts.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
This commit mainly correct the get/set format handling and how
DCMI format is stored within the driver.  struct video_format
within the data structure is used to store the format.
Reworked way to handle get format to avoid calling the sensor
set_fmt whenever performing the get_fmt.
Slightly adjusted code to as much as possible reuse return
values provided by functions.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Implement the video API frame interval handling in order
to control the framerate of capture.

This allow to remove the capture-rate DT property as well.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Add a testcase for building the stm32 dcmi driver on all
currently supported platforms / shields.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
@avolmat-st
Copy link
Collaborator Author

PR rebased to correct merge conflict

Add note regarding the move of the video/dcmi driver
to the usage of endpoint based video-interfaces
bindings.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
@avolmat-st avolmat-st force-pushed the video_stm32h7_dcmi_dt_dma branch from 9f4fc29 to dba3ba4 Compare May 12, 2025 14:18
@avolmat-st
Copy link
Collaborator Author

Otherwise LGTM

migration-guide message formatting update.

Copy link

@erwango erwango assigned erwango and unassigned kartben May 13, 2025
@nashif nashif merged commit 34622c0 into zephyrproject-rtos:main May 14, 2025
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Shields Shields (add-on boards) area: Video Video subsystem platform: STM32 ST Micro STM32 Release Notes To be mentioned in the release notes
Projects
None yet
8 participants