From 67f7dd1c7a3903c14e6ecf3586d54f18d99cbd67 Mon Sep 17 00:00:00 2001 From: Josuah Demangeon Date: Sat, 26 Apr 2025 01:08:29 +0000 Subject: [PATCH 1/3] dts: bindings: gpio: add arducam 20-pin camera connector Add the 20-pin camera connector used by at least Arducam, Waveshare, Olimex, Arduino, NXP, ST, Adafruit that connects image sensor module boards and devkits. Signed-off-by: Josuah Demangeon --- .../gpio/arducam,dvp-20pin-connector.yaml | 47 +++++++++++++++++++ dts/bindings/vendor-prefixes.txt | 1 + .../dt-bindings/gpio/dvp-20pin-connector.h | 33 +++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 dts/bindings/gpio/arducam,dvp-20pin-connector.yaml create mode 100644 include/zephyr/dt-bindings/gpio/dvp-20pin-connector.h diff --git a/dts/bindings/gpio/arducam,dvp-20pin-connector.yaml b/dts/bindings/gpio/arducam,dvp-20pin-connector.yaml new file mode 100644 index 000000000000..571b3bdb8b1c --- /dev/null +++ b/dts/bindings/gpio/arducam,dvp-20pin-connector.yaml @@ -0,0 +1,47 @@ +# Copyright 2025 tinyVision.ai Inc. +# SPDX-License-Identifier: Apache-2.0 + +description: | + GPIO pins exposed on ArduCam 20-pin header camera connector, + originally designed to connect Arducam modules to Arduino Giga R1, + but further used by other vendors of camera and devkits. + + The connector layout is depicted below: + + 1 3V3 2 GND + 3 SCL 4 SDA + 5 VS 6 HS + 7 PCLK 8 XCLK + 9 D7 10 D6 + 11 D5 12 D4 + 13 D3 14 D2 + 15 D1 16 D0 + 17 PEN 18 PDN + 19 PEN 20 PDN + + In many variants, the last row containing the pins 19 and 20 is + not present, and the pins 17 and 18 are used for the same purpose + instead. + + The following node labels can be used for use in shields: + + - dvp_20pin_interface: the video interface that receives the video + feed and use with the zephyr,camera chosen node. + + - dvp_20pin_ep_in: video endpoint of the devkit receiving the video + feed (see video-interfaces.yaml). + + - dvp_20pin_ep_out: video endpoint of the camera module to interconnect + with this endpoint (see video-interfaces.yaml). + + - dvp_20pin_i2c: the I2C device of the devkit on which the camera + module is instantiated. + + - dvp_20pin_gpio: the gpio nexus using the arducam,dvp-20pin-connector + that defines the camera 'reset' pin, 'power-down' pin, etc. + + See for pin description. + +compatible: "arducam,dvp-20pin-connector" + +include: [gpio-nexus.yaml, base.yaml] diff --git a/dts/bindings/vendor-prefixes.txt b/dts/bindings/vendor-prefixes.txt index 70c43fdc8b71..e17770ae96ed 100644 --- a/dts/bindings/vendor-prefixes.txt +++ b/dts/bindings/vendor-prefixes.txt @@ -70,6 +70,7 @@ arc Synopsys, Inc. (formerly ARC International PLC) archermind ArcherMind Technology (Nanjing) Co., Ltd. arctic Arctic Sand arcx arcx Inc. / Archronix Inc. +arducam Arducam arduino Arduino aries Aries Embedded GmbH arm ARM Ltd. diff --git a/include/zephyr/dt-bindings/gpio/dvp-20pin-connector.h b/include/zephyr/dt-bindings/gpio/dvp-20pin-connector.h new file mode 100644 index 000000000000..2eee3cf1e324 --- /dev/null +++ b/include/zephyr/dt-bindings/gpio/dvp-20pin-connector.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 tinyVision.ai Inc. + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef INCLUDE_ZEPHYR_DT_BINDINGS_GPIO_DVP_20PIN_CONNECTOR_H_ +#define INCLUDE_ZEPHYR_DT_BINDINGS_GPIO_DVP_20PIN_CONNECTOR_H_ + +/** Pin number mask (0..20). */ +#define DVP_20PIN_MASK 0xff + +/** + * @name Arducam DVP 20-pin or 18-pin connector pinout + * @{ + */ +#define DVP_20PIN_SCL 3 /**< I2C pin */ +#define DVP_20PIN_SDA 4 /**< I2C pin */ +#define DVP_20PIN_VS 5 /**< Vertical sync */ +#define DVP_20PIN_HS 6 /**< Horizontal sync */ +#define DVP_20PIN_PCLK 7 /**< Pixel clock used to transmit the data */ +#define DVP_20PIN_XCLK 8 /**< System clock often needed for I2C communication */ +#define DVP_20PIN_D7 9 /**< Parallel port data */ +#define DVP_20PIN_D6 10 /**< Parallel port data */ +#define DVP_20PIN_D5 11 /**< Parallel port data */ +#define DVP_20PIN_D4 12 /**< Parallel port data */ +#define DVP_20PIN_D3 13 /**< Parallel port data */ +#define DVP_20PIN_D2 14 /**< Parallel port data */ +#define DVP_20PIN_D1 15 /**< Parallel port data */ +#define DVP_20PIN_D0 16 /**< Parallel port data */ +#define DVP_20PIN_PEN 17 /**< Power Enable, typicaly shorted with pin 19 */ +#define DVP_20PIN_PDN 18 /**< Power Down, typicaly shorted with pin 20 */ +/** @} */ + +#endif /* INCLUDE_ZEPHYR_DT_BINDINGS_GPIO_DVP_20PIN_CONNECTOR_H_ */ From 143d501f1bc8dcd712c411a570f459be566b0ff9 Mon Sep 17 00:00:00 2001 From: Josuah Demangeon Date: Sat, 26 Apr 2025 10:11:19 +0000 Subject: [PATCH 2/3] boards: nxp: frdm_mcxn947: migrate ov7670 to a shield The OV7670 was defined as part of the FRDM-MCXN947 board attached to the SmartDMA and I2C peripheral. Migrate the devicetree to a reusable shield that can be swapped with other image sensors. Signed-off-by: Josuah Demangeon --- boards/nxp/frdm_mcxn947/frdm_mcxn947.dtsi | 42 +++++----- .../shields/dvp_20pin_ov7670/Kconfig.shield | 5 ++ boards/shields/dvp_20pin_ov7670/doc/index.rst | 81 +++++++++++++++++++ .../dvp_20pin_ov7670/dvp_20pin_ov7670.overlay | 37 +++++++++ .../capture/boards/frdm_mcxn947_cpu0.overlay | 11 --- 5 files changed, 146 insertions(+), 30 deletions(-) create mode 100644 boards/shields/dvp_20pin_ov7670/Kconfig.shield create mode 100644 boards/shields/dvp_20pin_ov7670/doc/index.rst create mode 100644 boards/shields/dvp_20pin_ov7670/dvp_20pin_ov7670.overlay delete mode 100644 samples/drivers/video/capture/boards/frdm_mcxn947_cpu0.overlay diff --git a/boards/nxp/frdm_mcxn947/frdm_mcxn947.dtsi b/boards/nxp/frdm_mcxn947/frdm_mcxn947.dtsi index 6867b44d2780..7c38c7956599 100644 --- a/boards/nxp/frdm_mcxn947/frdm_mcxn947.dtsi +++ b/boards/nxp/frdm_mcxn947/frdm_mcxn947.dtsi @@ -7,6 +7,7 @@ #include "frdm_mcxn947-pinctrl.dtsi" #include #include +#include / { aliases{ @@ -95,38 +96,22 @@ nxp_8080_touch_panel_i2c: &flexcomm2_lpi2c2 { pinctrl-0 = <&pinmux_flexcomm7_lpi2c>; pinctrl-names = "default"; clock-frequency = ; - ov7670: ov7670@21 { - compatible = "ovti,ov7670"; - 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"; - }; - }; - }; }; /* SmartDMA is used for video driver on this board */ &smartdma { + /* Shields do not enable video-sdma parent node so enable it by default */ status = "okay"; program-mem = <0x4000000>; + video_sdma: video-sdma { - status = "okay"; + status = "disabled"; compatible = "nxp,video-smartdma"; pinctrl-0 = <&pinmux_smartdma_camera>; pinctrl-names = "default"; vsync-pin = <4>; hsync-pin = <11>; pclk-pin = <5>; - - port { - sdma_ep_in: endpoint { - remote-endpoint-label = "ov7670_ep_out"; - }; - }; }; }; @@ -300,3 +285,22 @@ zephyr_mipi_dbi_parallel: &flexio0_lcd { pinctrl-0 = <&pinmux_sctimer>; pinctrl-names = "default"; }; + +/* + * Connection with camera modules such as the dvp_20pin_ov7670 shield + */ + +/ { + dvp_20pin_gpio: dvp-20pin-connector { + compatible = "arducam,dvp-20pin-connector"; + #gpio-cells = <2>; + gpio-map-mask = ; + gpio-map-pass-thru = <0x0 GPIO_DT_FLAGS_MASK>; + gpio-map = , + ; + }; +}; + +dvp_20pin_i2c: &flexcomm7_lpi2c7 {}; + +dvp_20pin_interface: &video_sdma {}; diff --git a/boards/shields/dvp_20pin_ov7670/Kconfig.shield b/boards/shields/dvp_20pin_ov7670/Kconfig.shield new file mode 100644 index 000000000000..466a176635b2 --- /dev/null +++ b/boards/shields/dvp_20pin_ov7670/Kconfig.shield @@ -0,0 +1,5 @@ +# Copyright 2025 tinyVision.ai Inc. +# SPDX-License-Identifier: Apache-2.0 + +config SHIELD_DVP_20PIN_OV7670 + def_bool $(shields_list_contains,SHIELD_DVP_20PIN_OV7670) diff --git a/boards/shields/dvp_20pin_ov7670/doc/index.rst b/boards/shields/dvp_20pin_ov7670/doc/index.rst new file mode 100644 index 000000000000..8cd0166a3a0e --- /dev/null +++ b/boards/shields/dvp_20pin_ov7670/doc/index.rst @@ -0,0 +1,81 @@ +.. _dvp_20pin_ov7670: + +DVP 20-pin OV7670 Camera Module +############################### + +Overview +******** + +This series of shields supports the camera modules which use a 18-pin connector compatible with +the ``arducam,dvp-20pin-connector`` to connect a devkit to an OV7670 image sensor via DVP +(Digital Video Port), aka parallel interface. + +Only 18 pins out of the 20-pin connector are present + +It was originally produced by `Arducam`_ but is discontinuited, and now `Olimex`_ provides it. + +Pins assignment +=============== + ++-----+--------------+-----+--------------+ +| Pin | Function | Pin | Function | ++=====+==============+=====+==============+ +| 1 | 3V3 | 2 | GND | ++-----+--------------+-----+--------------+ +| 3 | SCL | 4 | SDA | ++-----+--------------+-----+--------------+ +| 5 | VS | 6 | HS | ++-----+--------------+-----+--------------+ +| 7 | PCLK | 8 | XCLK | ++-----+--------------+-----+--------------+ +| 9 | D7 | 10 | D6 | ++-----+--------------+-----+--------------+ +| 11 | D5 | 12 | D4 | ++-----+--------------+-----+--------------+ +| 13 | D3 | 14 | D2 | ++-----+--------------+-----+--------------+ +| 15 | D1 | 16 | D0 | ++-----+--------------+-----+--------------+ +| 17 | POWER_EN | 18 | POWER_DOWN | ++-----+--------------+-----+--------------+ + +Requirements +************ + +This shield can be used with any board which provides a 18 or 20-pin header spread over two rows +of 9 or 10 pins each with the above pinout, such as the `arduino Giga R1`_, `NXP FRDM-MCXN947`_, +ST boards with the `ST-CAMS-OMV`_ adapter, or any other board with a compatible connector. + +Alternatively, it is possible to use jumper wires to connect the module to any devkit that +exposes their camera parallel port to pin headers. + +Programming +*********** + +Set ``--shield dvp_20pin_ov7670`` when you invoke ``west build``. For example: + +.. zephyr-app-commands:: + :zephyr-app: samples/drivers/video/capture + :board: frdm_mcxn947 + :shield: dvp_20pin_ov7670 + :goals: build + +References +********** + +.. target-notes:: + +.. _ST-CAMS-OMV: + https://www.st.com/en/evaluation-tools/b-cams-omv.html + +.. _Arducam: + https://docs.arducam.com/DVP-Camera-Module/Arduino-GIGA/Arduino-GIGA/Quick-Start-Guide/ + +.. _Arduino Giga R1: + https://docs.arduino.cc/tutorials/giga-r1-wifi/giga-camera/ + +.. _NXP FRDM-MCXN947: + https://www.nxp.com/docs/en/application-note/AN14191.pdf + +.. _Olimex: + https://www.olimex.com/Products/Components/Camera/CAMERA-OV7670/ diff --git a/boards/shields/dvp_20pin_ov7670/dvp_20pin_ov7670.overlay b/boards/shields/dvp_20pin_ov7670/dvp_20pin_ov7670.overlay new file mode 100644 index 000000000000..0e0529edec75 --- /dev/null +++ b/boards/shields/dvp_20pin_ov7670/dvp_20pin_ov7670.overlay @@ -0,0 +1,37 @@ +/* + * Copyright 2024 NXP + * Copyright 2025 tinyVision.ai Inc. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/ { + chosen { + zephyr,camera = &dvp_20pin_interface; + }; +}; + +&dvp_20pin_i2c { + ov7670: ov7670@21 { + compatible = "ovti,ov7670"; + reg = <0x21>; + reset-gpios = <&dvp_20pin_gpio DVP_20PIN_PEN GPIO_ACTIVE_HIGH>; + pwdn-gpios = <&dvp_20pin_gpio DVP_20PIN_PDN GPIO_ACTIVE_HIGH>; + + port { + ov7670_ep_out: endpoint { + remote-endpoint-label = "dvp_20pin_ep_in"; + }; + }; + }; +}; + +&dvp_20pin_interface { + status = "okay"; + + port { + dvp_20pin_ep_in: endpoint { + remote-endpoint-label = "ov7670_ep_out"; + }; + }; +}; diff --git a/samples/drivers/video/capture/boards/frdm_mcxn947_cpu0.overlay b/samples/drivers/video/capture/boards/frdm_mcxn947_cpu0.overlay deleted file mode 100644 index db18ee736c4f..000000000000 --- a/samples/drivers/video/capture/boards/frdm_mcxn947_cpu0.overlay +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright 2024 NXP - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/{ - chosen { - zephyr,camera = &video_sdma; - }; -}; From cb237fcd7171213a286cb064f7fda29dfed26ea5 Mon Sep 17 00:00:00 2001 From: Josuah Demangeon Date: Sun, 27 Apr 2025 11:08:29 +0000 Subject: [PATCH 3/3] samples: drivers: video: capture: add FRDM-MCXN947 Add FRDM-MCXN947 to the video capture sample documentation and twister YAML configuration, using the DVP OV7670 camera module newly introduced. Signed-off-by: Josuah Demangeon --- samples/drivers/video/capture/README.rst | 16 ++++++++++++++-- samples/drivers/video/capture/sample.yaml | 2 ++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/samples/drivers/video/capture/README.rst b/samples/drivers/video/capture/README.rst index 2a8fefc0ff0e..9da9aa3abf23 100644 --- a/samples/drivers/video/capture/README.rst +++ b/samples/drivers/video/capture/README.rst @@ -19,10 +19,13 @@ Supported camera modules on some i.MX RT boards can be found below. - `Camera iMXRT`_ - :zephyr:board:`mimxrt1064_evk` -- `MT9M114 camera module`_ + with a `MT9M114 camera module`_ - :zephyr:board:`mimxrt1170_evk` -- `OV5640 camera module`_ + with an `OV5640 camera module`_ + +- :zephyr:board:`frdm_mcxn947` + with any ``arducam,dvp-20pin-connector`` camera module such as :ref:`dvp_20pin_ov7670`. Also :zephyr:board:`arduino_nicla_vision` can be used in this sample as capture device, in that case The user can transfer the captured frames through on board USB. @@ -70,6 +73,15 @@ commands: :goals: build :compact: +For :zephyr:board:`frdm_mcxn947`, build this sample application with the following commands: + +.. zephyr-app-commands:: + :zephyr-app: samples/drivers/video/capture + :board: frdm_mcxn947/mcxn947/cpu0 + :shield: dvp_20pin_ov7670 + :goals: build + :compact: + For testing purpose without the need of any real video capture and/or display hardwares, a video software pattern generator is supported by the above build commands without specifying the shields. diff --git a/samples/drivers/video/capture/sample.yaml b/samples/drivers/video/capture/sample.yaml index 4cee752b3f38..fbb28a2b536a 100644 --- a/samples/drivers/video/capture/sample.yaml +++ b/samples/drivers/video/capture/sample.yaml @@ -10,6 +10,7 @@ tests: - platform:mimxrt1064_evk:SHIELD="dvp_fpc24_mt9m114;rk043fn66hs_ctg" - platform:mimxrt1170_evk/mimxrt1176/cm7:SHIELD="nxp_btb44_ov5640;rk055hdmipi4ma0" - platform:mimxrt1170_evk@B/mimxrt1176/cm7:SHIELD="nxp_btb44_ov5640;rk055hdmipi4ma0" + - platform:frdm_mcxn947/mcxn947/cpu0:SHIELD="dvp_20pin_ov7670" extra_configs: - CONFIG_TEST=y - CONFIG_FPU=y @@ -28,6 +29,7 @@ tests: - mimxrt1064_evk - mimxrt1170_evk/mimxrt1176/cm7 - mimxrt1170_evk@B/mimxrt1176/cm7 + - frdm_mcxn947/mcxn947/cpu0 - mm_swiftio - esp32s3_eye/esp32s3/procpu depends_on: video