From f0bc21721eb845b8ca954a4d7cffde04ab3bb0a2 Mon Sep 17 00:00:00 2001 From: Phi Bang Nguyen Date: Wed, 23 Apr 2025 16:04:51 +0200 Subject: [PATCH 1/4] drivers: video: smartdma: Fix a typo breaking the build Fix a typo so that it won't break the build. Signed-off-by: Phi Bang Nguyen --- drivers/video/video_mcux_smartdma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/video_mcux_smartdma.c b/drivers/video/video_mcux_smartdma.c index d9388b0951d6..0316e1ce0705 100644 --- a/drivers/video/video_mcux_smartdma.c +++ b/drivers/video/video_mcux_smartdma.c @@ -371,7 +371,7 @@ static DEVICE_API(video, nxp_video_sdma_api) = { PINCTRL_DT_INST_DEFINE(inst); \ const struct nxp_video_sdma_config sdma_config_##inst = { \ .dma_dev = DEVICE_DT_GET(DT_INST_PARENT(inst)), \ - .sensor_dev = SOURCE_DEV(n), \ + .sensor_dev = SOURCE_DEV(inst), \ .pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(inst), \ .vsync_pin = DT_INST_PROP(inst, vsync_pin), \ .hsync_pin = DT_INST_PROP(inst, hsync_pin), \ From 8ee08367c8bcb986cbb2df28523c06eaa9b358e1 Mon Sep 17 00:00:00 2001 From: Phi Bang Nguyen Date: Tue, 8 Apr 2025 22:35:24 +0200 Subject: [PATCH 2/4] drivers: video: Use video interfaces binding for ov7670 and smartdma Have ov7670 and video smartdma use video interfaces binding. With this, we can fix the chicken-egg issue in init priority and don't need the workaround anymore. Signed-off-by: Phi Bang Nguyen --- boards/nxp/frdm_mcxn947/frdm_mcxn947.dtsi | 13 ++++++++++++- drivers/video/video_mcux_smartdma.c | 2 +- dts/bindings/video/nxp,video-smartdma.yaml | 8 ++++---- dts/bindings/video/ovti,ov7670.yaml | 4 ++++ .../video/capture/boards/frdm_mcxn947_cpu0.conf | 3 --- 5 files changed, 21 insertions(+), 9 deletions(-) diff --git a/boards/nxp/frdm_mcxn947/frdm_mcxn947.dtsi b/boards/nxp/frdm_mcxn947/frdm_mcxn947.dtsi index 3ebc13c0e9a9..6867b44d2780 100644 --- a/boards/nxp/frdm_mcxn947/frdm_mcxn947.dtsi +++ b/boards/nxp/frdm_mcxn947/frdm_mcxn947.dtsi @@ -100,6 +100,12 @@ nxp_8080_touch_panel_i2c: &flexcomm2_lpi2c2 { reset-gpios = <&gpio1 19 GPIO_ACTIVE_HIGH>; pwdn-gpios = <&gpio1 18 GPIO_ACTIVE_HIGH>; reg = <0x21>; + + port { + ov7670_ep_out: endpoint { + remote-endpoint-label = "sdma_ep_in"; + }; + }; }; }; @@ -112,10 +118,15 @@ nxp_8080_touch_panel_i2c: &flexcomm2_lpi2c2 { compatible = "nxp,video-smartdma"; pinctrl-0 = <&pinmux_smartdma_camera>; pinctrl-names = "default"; - sensor = <&ov7670>; vsync-pin = <4>; hsync-pin = <11>; pclk-pin = <5>; + + port { + sdma_ep_in: endpoint { + remote-endpoint-label = "ov7670_ep_out"; + }; + }; }; }; diff --git a/drivers/video/video_mcux_smartdma.c b/drivers/video/video_mcux_smartdma.c index 0316e1ce0705..bf624ecb47a1 100644 --- a/drivers/video/video_mcux_smartdma.c +++ b/drivers/video/video_mcux_smartdma.c @@ -365,7 +365,7 @@ static DEVICE_API(video, nxp_video_sdma_api) = { .flush = nxp_video_sdma_flush }; -#define SOURCE_DEV(inst) DEVICE_DT_GET(DT_INST_PHANDLE(inst, sensor)) +#define SOURCE_DEV(inst) DEVICE_DT_GET(DT_NODE_REMOTE_DEVICE(DT_INST_ENDPOINT_BY_ID(inst, 0, 0))) #define NXP_VIDEO_SDMA_INIT(inst) \ PINCTRL_DT_INST_DEFINE(inst); \ diff --git a/dts/bindings/video/nxp,video-smartdma.yaml b/dts/bindings/video/nxp,video-smartdma.yaml index 5312f2b3bc37..0ae3d4386634 100644 --- a/dts/bindings/video/nxp,video-smartdma.yaml +++ b/dts/bindings/video/nxp,video-smartdma.yaml @@ -8,10 +8,6 @@ compatible: "nxp,video-smartdma" include: [base.yaml, pinctrl-device.yaml] properties: - sensor: - required: true - type: phandle - description: phandle of connected sensor device vsync-pin: required: true type: int @@ -27,3 +23,7 @@ properties: type: int description: | GPIO0 pin index to use for PCLK input. Only pins 0-15 may be used. + +child-binding: + child-binding: + include: video-interfaces.yaml diff --git a/dts/bindings/video/ovti,ov7670.yaml b/dts/bindings/video/ovti,ov7670.yaml index 4b8fa88f1170..01ddc9849301 100644 --- a/dts/bindings/video/ovti,ov7670.yaml +++ b/dts/bindings/video/ovti,ov7670.yaml @@ -18,3 +18,7 @@ properties: receives this as an active high signal include: i2c-device.yaml + +child-binding: + child-binding: + include: video-interfaces.yaml diff --git a/samples/drivers/video/capture/boards/frdm_mcxn947_cpu0.conf b/samples/drivers/video/capture/boards/frdm_mcxn947_cpu0.conf index 4a604bc267ef..2302ba1e88b9 100644 --- a/samples/drivers/video/capture/boards/frdm_mcxn947_cpu0.conf +++ b/samples/drivers/video/capture/boards/frdm_mcxn947_cpu0.conf @@ -1,5 +1,2 @@ CONFIG_VIDEO_BUFFER_POOL_SZ_MAX=40000 CONFIG_VIDEO_BUFFER_POOL_NUM_MAX=2 -# Workaround for issue where SDMA driver needs to start before camera, so that -# clock output will be generated for camera device -CONFIG_CHECK_INIT_PRIORITIES=n From ef44619bef3fe52feccd8dd01a54ffa55aaa9fb8 Mon Sep 17 00:00:00 2001 From: Phi Bang Nguyen Date: Wed, 9 Apr 2025 00:03:30 +0200 Subject: [PATCH 3/4] tests: drivers: build_all: video: Add test case for smartdma Add built-only test case for smartdma driver Signed-off-by: Phi Bang Nguyen --- .../video/frdm_mcxn947_mcxn947_cpu0.overlay | 69 +++++++++++++++++++ tests/drivers/build_all/video/testcase.yaml | 3 + 2 files changed, 72 insertions(+) create mode 100644 tests/drivers/build_all/video/frdm_mcxn947_mcxn947_cpu0.overlay diff --git a/tests/drivers/build_all/video/frdm_mcxn947_mcxn947_cpu0.overlay b/tests/drivers/build_all/video/frdm_mcxn947_mcxn947_cpu0.overlay new file mode 100644 index 000000000000..eb5c47dd3bd1 --- /dev/null +++ b/tests/drivers/build_all/video/frdm_mcxn947_mcxn947_cpu0.overlay @@ -0,0 +1,69 @@ +/* + * Copyright 2025 NXP + * + * SPDX-License-Identifier: Apache-2.0 + * + * 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. + */ + +#include + +/ { + test { + #address-cells = <1>; + #size-cells = <1>; + + test_gpio: gpio@deadbeef { + compatible = "vnd,gpio"; + gpio-controller; + reg = <0xdeadbeef 0x1000>; + #gpio-cells = <0x2>; + }; + + test_flexcomm7_lpi2c7: lpi2c@11112222 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "nxp,lpi2c"; + reg = <0x11112222 0x1000>; + clocks = <&syscon MCUX_FLEXCOMM7_CLK>; + clock-frequency = ; + test_ov7670: ov7670@1 { + compatible = "ovti,ov7670"; + reset-gpios = <&test_gpio 19 GPIO_ACTIVE_HIGH>; + pwdn-gpios = <&test_gpio 18 GPIO_ACTIVE_HIGH>; + reg = <0x1>; + + port { + test_ov7670_ep_out: endpoint { + remote-endpoint-label = "test_sdma_ep_in"; + }; + }; + }; + }; + + test_smartdma: smartdma@22223333 { + compatible = "nxp,smartdma"; + reg = <0x22223333 0x1000>; + interrupt-parent = <&nvic>; + interrupts = <0 0>; + program-mem = <0x4000000>; + #dma-cells = <0>; + test_video_sdma: video-sdma { + compatible = "nxp,video-smartdma"; + pinctrl-0 = <&pinmux_smartdma_camera>; + pinctrl-names = "default"; + vsync-pin = <4>; + hsync-pin = <11>; + pclk-pin = <5>; + + port { + test_sdma_ep_in: endpoint { + remote-endpoint-label = "test_ov7670_ep_out"; + }; + }; + }; + }; + }; +}; diff --git a/tests/drivers/build_all/video/testcase.yaml b/tests/drivers/build_all/video/testcase.yaml index 88160e8721b1..57e74e801686 100644 --- a/tests/drivers/build_all/video/testcase.yaml +++ b/tests/drivers/build_all/video/testcase.yaml @@ -19,3 +19,6 @@ tests: platform_allow: - mimxrt1170_evk/mimxrt1176/cm7 - mimxrt1170_evk@B/mimxrt1176/cm7 + drivers.video.mcux_smartdma.build: + platform_allow: + - frdm_mcxn947/mcxn947/cpu0 From 9603a8c9afd7fa47a5bfdf61a80697d89208c7d9 Mon Sep 17 00:00:00 2001 From: Phi Bang Nguyen Date: Thu, 24 Apr 2025 13:54:23 +0200 Subject: [PATCH 4/4] tests: drivers: build_all: video: Move board-specific overlays to boards Move board-specific overlays to boards folder Signed-off-by: Phi Bang Nguyen --- .../video/{ => boards}/frdm_mcxn947_mcxn947_cpu0.overlay | 0 .../video/{ => boards}/mimxrt1170_evk_mimxrt1176_cm7.overlay | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename tests/drivers/build_all/video/{ => boards}/frdm_mcxn947_mcxn947_cpu0.overlay (100%) rename tests/drivers/build_all/video/{ => boards}/mimxrt1170_evk_mimxrt1176_cm7.overlay (100%) diff --git a/tests/drivers/build_all/video/frdm_mcxn947_mcxn947_cpu0.overlay b/tests/drivers/build_all/video/boards/frdm_mcxn947_mcxn947_cpu0.overlay similarity index 100% rename from tests/drivers/build_all/video/frdm_mcxn947_mcxn947_cpu0.overlay rename to tests/drivers/build_all/video/boards/frdm_mcxn947_mcxn947_cpu0.overlay diff --git a/tests/drivers/build_all/video/mimxrt1170_evk_mimxrt1176_cm7.overlay b/tests/drivers/build_all/video/boards/mimxrt1170_evk_mimxrt1176_cm7.overlay similarity index 100% rename from tests/drivers/build_all/video/mimxrt1170_evk_mimxrt1176_cm7.overlay rename to tests/drivers/build_all/video/boards/mimxrt1170_evk_mimxrt1176_cm7.overlay