Skip to content

drivers: video: add imx219 sensor (RPi Cam v2) #88011

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

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
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
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
Copy link
Collaborator

Choose a reason for hiding this comment

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

where is Kconfig.imx219? :)

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