Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions boards/shields/raspberry_pi_camera_module_2/Kconfig.shield
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright (c) 2025 tinyVision.ai Inc.
# SPDX-License-Identifier: Apache-2.0

config SHIELD_RASPBERRY_PI_CAMERA_MODULE_2
def_bool $(shields_list_contains,raspberry_pi_camera_module_2)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CONFIG_VIDEO_STM32_DCMIPP_SENSOR_PIXEL_FORMAT="pBAA"
CONFIG_VIDEO_STM32_DCMIPP_SENSOR_WIDTH=3280
CONFIG_VIDEO_STM32_DCMIPP_SENSOR_HEIGHT=2464
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CONFIG_VIDEO_STM32_DCMIPP_SENSOR_PIXEL_FORMAT="pBAA"
CONFIG_VIDEO_STM32_DCMIPP_SENSOR_WIDTH=3280
CONFIG_VIDEO_STM32_DCMIPP_SENSOR_HEIGHT=2464
55 changes: 55 additions & 0 deletions boards/shields/raspberry_pi_camera_module_2/doc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
.. _raspberry_pi_camera_module_2:

Raspberry Pi Camera Module 2
############################

Overview
********

The Raspberry Pi camera module 2 provides a Sony IMX219 rolling shutter in a module featuring a
15-pin FFC connector popularized by Raspberry Pi, present on a wide range of boards.

The NoIR variant is the same as the normal variant, except with the infra-red filter removed.

.. figure:: rpi_cam_v2_normal.jpg
:width: 500px
:align: center
:alt: Raspberry Pi Camera Module 2

Raspberry Pi Camera Module 2, normal variant (Credit: Raspberry Pi.)

.. figure:: rpi_cam_v2_noir.jpg
:width: 500px
:align: center
:alt: Raspberry Pi Camera Module 2 NoIR

Raspberry Pi Camera Module 2, NoIR variant (Credit: Raspberry Pi.)

Requirements
************

The camera module is compatible with all boards featuring a 15 pins FFC connector and the necessary
devicetree definitions for a :dtcompatible:`raspberrypi,csi-connector`.

Usage
*****

The shield can be used in any application by setting ``SHIELD`` to
``raspberry_pi_camera_module_2`` for boards with the necessary device tree node labels:

.. zephyr-app-commands::
:zephyr-app: samples/drivers/video/capture
:board: stm32n6570_dk
:shield: raspberry_pi_camera_module_2
:goals: build

References
**********

- `Product page <https://www.raspberrypi.com/products/camera-module-v2/>`_

- `Product page (NoIR) <https://www.raspberrypi.com/products/pi-noir-camera-v2/>`_

- `Datasheet <https://datasheets.raspberrypi.com/camera/camera-module-2-schematics.pdf>`_

- `Mechanical drawing <https://datasheets.raspberrypi.com/camera/camera-module-2-mechanical-drawing.pdf>`_
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2025 tinyVision.ai Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/dt-bindings/gpio/raspberrypi-csi-connector.h>
#include <zephyr/dt-bindings/video/video-interfaces.h>

/ {
chosen {
zephyr,camera = &csi_capture_port;
};

imx219_input_clock: imx219-input-clock {
compatible = "fixed-clock";
clock-frequency = <24000000>;
#clock-cells = <0>;
};
};

&csi_interface {
status = "okay";
};

&csi_ep_in {
remote-endpoint-label = "imx219_ep_out";
bus-type = <VIDEO_BUS_TYPE_CSI2_DPHY>;
data-lanes = <1 2>;
};

&csi_i2c {
imx219: imx219@10 {
compatible = "sony,imx219";
clocks = <&imx219_input_clock>;
reg = <0x10>;

port {
imx219_ep_out: endpoint {
remote-endpoint-label = "csi_ep_in";
bus-type = <VIDEO_BUS_TYPE_CSI2_DPHY>;
data-lanes = <1 2>;
};
};
};
};
6 changes: 6 additions & 0 deletions boards/shields/raspberry_pi_camera_module_2/shield.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
shield:
name: raspberry_pi_camera_module_2
full_name: Raspberry Pi Camera Module 2
vendor: Raspberry Pi
supported_features:
- video
3 changes: 3 additions & 0 deletions boards/shields/st_b_cams_imx_mb1854/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ config VIDEO_STM32_DCMIPP_SENSOR_WIDTH
config VIDEO_STM32_DCMIPP_SENSOR_HEIGHT
default 1944

config GPIO_HOGS
default y

endif # VIDEO_STM32_DCMIPP
11 changes: 4 additions & 7 deletions boards/shields/st_b_cams_imx_mb1854/st_b_cams_imx_mb1854.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,8 @@
};
};

&csi_connector {
/* Power the camera module */
en-module-gpios {
gpio-hog;
gpios = <CSI_IO1 GPIO_ACTIVE_HIGH>;
output-high;
};
/* Power the camera module */
&csi_gpio1_hog {
status = "okay";
output-high;
};
54 changes: 54 additions & 0 deletions boards/st/nucleo_n657x0_q/nucleo_n657x0_q_common.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <st/n6/stm32n657X0.dtsi>
#include <st/n6/stm32n657x0hxq-pinctrl.dtsi>
#include <zephyr/dt-bindings/flash_controller/xspi.h>
#include <zephyr/dt-bindings/gpio/raspberrypi-csi-connector.h>
#include <zephyr/dt-bindings/input/input-event-codes.h>
#include "arduino_r3_connector.dtsi"

Expand Down Expand Up @@ -54,6 +55,31 @@
led2 = &red_led;
sw0 = &user_button;
};

csi_connector: connector_csi {
compatible = "raspberrypi,csi-connector";
#gpio-cells = <2>;
gpio-map-mask = <0xffffffff 0xffffffc0>;
gpio-map-pass-thru = <0 0x3f>;
gpio-map = <CSI_IO0 0 &gpioo 5 0>,
<CSI_IO1 0 &gpioa 0 0>;
};
};

&gpioo {
csi_gpio0_hog: csi-gpio0-hog {
gpio-hog;
gpios = <5 GPIO_ACTIVE_HIGH>;
status = "disabled";
};
};

&gpioa {
csi_gpio1_hog: csi-gpio1-hog {
gpio-hog;
gpios = <0 GPIO_ACTIVE_HIGH>;
status = "disabled";
};
};

&clk_hse {
Expand Down Expand Up @@ -115,6 +141,12 @@
status = "okay";
};

&ic17 {
pll-src = <1>;
ic-div = <4>;
status = "okay";
};

&perck {
clocks = <&rcc STM32_SRC_HSI PER_SEL(0)>;
status = "okay";
Expand Down Expand Up @@ -160,6 +192,16 @@
status = "okay";
};

csi_i2c: &i2c2 {
clocks = <&rcc STM32_CLOCK(APB1, 22)>,
<&rcc STM32_SRC_CKPER I2C2_SEL(1)>;
pinctrl-0 = <&i2c2_scl_pb10 &i2c2_sda_pb11>;
pinctrl-names = "default";
clock-frequency = <I2C_BITRATE_STANDARD>;
status = "okay";

};

&i2c4 {
clocks = <&rcc STM32_CLOCK(APB4, 7)>,
<&rcc STM32_SRC_CKPER I2C4_SEL(1)>;
Expand Down Expand Up @@ -257,3 +299,15 @@ zephyr_udc0: &usbotg_hs1 {
};
};
};

csi_interface: &dcmipp {
ports {
port@0 {
csi_ep_in: endpoint { };
};

port@1 {
csi_capture_port: endpoint@1 { };
};
};
};
16 changes: 16 additions & 0 deletions boards/st/stm32n6570_dk/stm32n6570_dk_common.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,22 @@
};
};

&gpioc {
csi_gpio0_hog: csi-gpio0-hog {
gpio-hog;
gpios = <8 GPIO_ACTIVE_HIGH>;
status = "disabled";
};
};

&gpiod {
csi_gpio1_hog: csi-gpio1-hog {
gpio-hog;
gpios = <2 GPIO_ACTIVE_HIGH>;
status = "disabled";
};
};

&i2c2 {
status = "okay";
clocks = <&rcc STM32_CLOCK(APB1, 22)>,
Expand Down
37 changes: 20 additions & 17 deletions drivers/video/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,27 @@ zephyr_library_sources(video_common.c)
zephyr_library_sources(video_ctrls.c)
zephyr_library_sources(video_device.c)

zephyr_library_sources_ifdef(CONFIG_VIDEO_MCUX_CSI video_mcux_csi.c)
# zephyr-keep-sorted-start
zephyr_library_sources_ifdef(CONFIG_VIDEO_EMUL_IMAGER video_emul_imager.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_EMUL_RX video_emul_rx.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_ESP32 video_esp32_dvp.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_GC2145 gc2145.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_IMX219 imx219.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_IMX335 imx335.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_MCUX_CSI video_mcux_csi.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_MCUX_MIPI_CSI2RX video_mcux_mipi_csi2rx.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_MCUX_SDMA video_mcux_smartdma.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_MT9M114 mt9m114.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_OV2640 ov2640.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_OV5640 ov5640.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_OV7670 ov7670.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_OV7725 ov7725.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_OV9655 ov9655.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_SHELL video_shell.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_SW_GENERATOR video_sw_generator.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_MT9M114 mt9m114.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_OV7725 ov7725.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_OV2640 ov2640.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_GC2145 gc2145.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_STM32_DCMI video_stm32_dcmi.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_OV5640 ov5640.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_OV7670 ov7670.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_OV9655 ov9655.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_ESP32 video_esp32_dvp.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_MCUX_SDMA video_mcux_smartdma.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_EMUL_IMAGER video_emul_imager.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_EMUL_RX video_emul_rx.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_IMX335 imx335.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_ST_MIPID02 video_st_mipid02.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_STM32_DCMIPP video_stm32_dcmipp.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_STM32_DCMI video_stm32_dcmi.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_STM32_DCMIPP video_stm32_dcmipp.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_ST_MIPID02 video_st_mipid02.c)
zephyr_library_sources_ifdef(CONFIG_VIDEO_SW_GENERATOR video_sw_generator.c)
# zephyr-keep-sorted-stop

zephyr_linker_sources(DATA_SECTIONS video.ld)
39 changes: 12 additions & 27 deletions drivers/video/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -58,42 +58,27 @@ config VIDEO_I2C_RETRY_NUM
The default is to not retry. Board configuration files or user project can then
use the number of retries that matches their situation.

# zephyr-keep-sorted-start
source "drivers/video/Kconfig.emul_imager"
source "drivers/video/Kconfig.emul_rx"
source "drivers/video/Kconfig.esp32_dvp"

source "drivers/video/Kconfig.gc2145"
source "drivers/video/Kconfig.imx219"
source "drivers/video/Kconfig.imx335"
source "drivers/video/Kconfig.mcux_csi"

source "drivers/video/Kconfig.mcux_mipi_csi2rx"

source "drivers/video/Kconfig.shell"

source "drivers/video/Kconfig.sw_generator"

source "drivers/video/Kconfig.mcux_sdma"
source "drivers/video/Kconfig.mt9m114"

source "drivers/video/Kconfig.ov7725"

source "drivers/video/Kconfig.ov2640"

source "drivers/video/Kconfig.stm32_dcmi"

source "drivers/video/Kconfig.ov5640"

source "drivers/video/Kconfig.ov7670"

source "drivers/video/Kconfig.ov7725"
source "drivers/video/Kconfig.ov9655"

source "drivers/video/Kconfig.gc2145"

source "drivers/video/Kconfig.mcux_sdma"

source "drivers/video/Kconfig.emul_imager"

source "drivers/video/Kconfig.emul_rx"

source "drivers/video/Kconfig.imx335"

source "drivers/video/Kconfig.shell"
source "drivers/video/Kconfig.st_mipid02"

source "drivers/video/Kconfig.stm32_dcmi"
source "drivers/video/Kconfig.stm32_dcmipp"
source "drivers/video/Kconfig.sw_generator"
# zephyr-keep-sorted-stop

endif # VIDEO
10 changes: 10 additions & 0 deletions drivers/video/Kconfig.imx219
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) 2024 tinyVision.ai Inc.
# SPDX-License-Identifier: Apache-2.0

config VIDEO_IMX219
bool "IMX219 8 Mega-Pixel CMOS image sensor"
select I2C
depends on DT_HAS_SONY_IMX219_ENABLED
default y
help
Enable driver for IMX219 8 Mega-Pixel CMOS image sensor
Loading
Loading