-
Notifications
You must be signed in to change notification settings - Fork 7.6k
video: add stm32mp135f gc2145 camera board shield & enable dcmipp / st-mipid02 #91837
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
Changes from all commits
403319a
bde0f4d
cfb7df0
8a8d5b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Copyright (c) 2025 STMicroelectronics | ||
|
||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
config SHIELD_ST_MB1897_CAM | ||
def_bool $(shields_list_contains,st_mb1897_cam) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
CONFIG_VIDEO_STM32_DCMIPP_SENSOR_PIXEL_FORMAT="RGBP" | ||
CONFIG_VIDEO_STM32_DCMIPP_SENSOR_WIDTH=640 | ||
CONFIG_VIDEO_STM32_DCMIPP_SENSOR_HEIGHT=480 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Copyright (c) 2025 STMicroelectronics | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
&mipid02 { | ||
status = "okay"; | ||
}; | ||
|
||
&mco1 { | ||
status = "okay"; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
.. _st_mb1897_cam: | ||
|
||
ST_MB1897_CAM | ||
############# | ||
|
||
Overview | ||
******** | ||
|
||
The STM32MP135F discovery board is delivered with a CSI camera module | ||
connected to the STM32MP135F-DK board via a 15pins FFC connector. | ||
The camera module board (MB1897) embeds a Galaxycore GC2145 CSI sensor. | ||
|
||
.. figure:: st_mb1897_cam.webp | ||
:align: center | ||
:alt: ST-MB1897-CAM | ||
|
||
MB1897 Image (Credit: STMicroelectronics.) | ||
|
||
Requirements | ||
************ | ||
|
||
The camera module bundle is compatible with STM32 Discovery kits and | ||
Evaluation boards featuring a 15 pins FFC connector, such as the STM32MP13 | ||
Discovery kit. | ||
|
||
Usage | ||
***** | ||
|
||
The shield can be used in any application by setting ``SHIELD`` to | ||
``st_mb1897_cam`` for boards with the necessary device tree node labels. | ||
|
||
Set ``--shield "st_mb1897_cam"`` when you invoke ``west build``. For example: | ||
|
||
.. zephyr-app-commands:: | ||
:zephyr-app: samples/drivers/video/capture | ||
:board: stm32mp135f_dk | ||
:shield: st_mb1897_cam | ||
:goals: build |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
shield: | ||
name: st_mb1897_cam | ||
full_name: ST MB1897 camera module | ||
vendor: st | ||
supported_features: | ||
- video |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (c) 2025 STMicroelectronics | ||
* | ||
* 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; | ||
}; | ||
}; | ||
|
||
&csi_interface { | ||
status = "okay"; | ||
}; | ||
|
||
&csi_ep_in { | ||
remote-endpoint-label = "gc2145_ep_out"; | ||
bus-type = <VIDEO_BUS_TYPE_CSI2_DPHY>; | ||
data-lanes = <1 2>; | ||
}; | ||
|
||
&csi_i2c { | ||
status = "okay"; | ||
|
||
gc2145: camera@3c { | ||
compatible = "galaxycore,gc2145"; | ||
reg = <0x3c>; | ||
pwdn-gpios = <&csi_connector CSI_IO1 GPIO_ACTIVE_LOW>; | ||
reset-gpios = <&csi_connector CSI_IO0 GPIO_ACTIVE_LOW>; | ||
|
||
port { | ||
gc2145_ep_out: endpoint { | ||
remote-endpoint-label = "csi_ep_in"; | ||
data-lanes = <1 2>; | ||
bus-type = <VIDEO_BUS_TYPE_CSI2_DPHY>; | ||
}; | ||
}; | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# STM32MP135F DISCOVERY board configuration | ||
|
||
# Copyright (c) 2025 STMicroelectronics | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
if BOARD_STM32MP135F_DK | ||
|
||
if GPIO_MCP230XX | ||
|
||
config GPIO_MCP230XX_INIT_PRIORITY | ||
default I2C_INIT_PRIORITY | ||
|
||
endif # GPIO_MCP230XX | ||
|
||
endif # BOARD_STM32MP135F_DK |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,9 @@ | |
#include <st/mp13/stm32mp135.dtsi> | ||
#include <st/mp13/stm32mp135faex-pinctrl.dtsi> | ||
#include "zephyr/dt-bindings/display/panel.h" | ||
#include <zephyr/dt-bindings/gpio/raspberrypi-csi-connector.h> | ||
#include <zephyr/dt-bindings/input/input-event-codes.h> | ||
#include <zephyr/dt-bindings/video/video-interfaces.h> | ||
|
||
/ { | ||
model = "STMicroelectronics STM32MP135-DK board"; | ||
|
@@ -62,6 +64,15 @@ | |
led1 = &red_led_2; | ||
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 &mcp23017 4 0>, | ||
<CSI_IO1 0 &mcp23017 3 0>; | ||
}; | ||
}; | ||
|
||
&clk_hsi { | ||
|
@@ -89,6 +100,17 @@ | |
status = "okay"; | ||
}; | ||
|
||
&pll2 { | ||
clocks = <&clk_hse>; | ||
div-m = <3>; | ||
mul-n = <66>; | ||
div-p = <2>; | ||
div-q = <2>; | ||
div-r = <1>; | ||
fracn = <5120>; | ||
status = "okay"; | ||
}; | ||
|
||
&rcc { | ||
clock-frequency = <DT_FREQ_M(1000)>; | ||
clocks = <&pll>; | ||
|
@@ -124,10 +146,64 @@ | |
status = "okay"; | ||
}; | ||
|
||
&i2c5 { | ||
csi_i2c: &i2c5 { | ||
pinctrl-names = "default"; | ||
pinctrl-0 = <&i2c5_scl_pd1 &i2c5_sda_ph6>; | ||
status = "okay"; | ||
|
||
mipid02: bridge@14 { | ||
compatible = "st,mipid02"; | ||
reg = <0x14>; | ||
reset-gpios = <&mcp23017 2 GPIO_ACTIVE_LOW>; | ||
|
||
ports { | ||
#address-cells = <1>; | ||
#size-cells = <0>; | ||
port@0 { | ||
reg = <0>; | ||
|
||
csi_ep_in: endpoint { | ||
remote-endpoint-label = ""; | ||
}; | ||
}; | ||
|
||
port@2 { | ||
reg = <2>; | ||
|
||
mipid02_2: endpoint { | ||
bus-width = <8>; | ||
hsync-active = <0>; | ||
vsync-active = <0>; | ||
pclk-sample = <0>; | ||
remote-endpoint-label = "dcmipp_ep_in"; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
|
||
csi_interface: &dcmipp { | ||
pinctrl-0 = <&dcmipp_d0_pa9 &dcmipp_d1_pd0 &dcmipp_d2_pg10 &dcmipp_d3_pe4 | ||
&dcmipp_d4_pd11 &dcmipp_d5_pd3 &dcmipp_d6_pb8 &dcmipp_d7_pe14 | ||
&dcmipp_pixclk_pb7 &dcmipp_vsync_pg9 &dcmipp_hsync_ph8>; | ||
pinctrl-names = "default"; | ||
|
||
ports { | ||
port@0 { | ||
dcmipp_ep_in: endpoint { | ||
bus-width = <8>; | ||
hsync-active = <0>; | ||
vsync-active = <0>; | ||
pclk-sample = <0>; | ||
bus-type = <VIDEO_BUS_TYPE_PARALLEL>; | ||
remote-endpoint-label = "mipid02_2"; | ||
}; | ||
}; | ||
|
||
port@1 { | ||
csi_capture_port: endpoint { }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apparently There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not on that one since there is a compatible in the stm32mp135.dtsi There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see where the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Thanks for reminding me. Yes, I remember we have some constraints to support multiple pipes in the DCMIPP and come up to this solution but didn't pay attention to this particular trade-off. This is needed but not a real endpoint (no yaml, no remote-endpoint to interface with, no bus-type). Maybe we can try to see if we can have a nicer solution in the future. The current implementation is OK to me. Thanks. |
||
}; | ||
}; | ||
}; | ||
|
||
<dc { | ||
|
@@ -166,3 +242,16 @@ | |
def-back-color-green = <0xFF>; | ||
def-back-color-blue = <0xFF>; | ||
}; | ||
|
||
/* | ||
* MCO1 is used to clock ST-MIPID02, keep disabled here, will be | ||
* enabled by a shield when camera pipeline is enabled | ||
*/ | ||
&mco1 { | ||
clocks = <&rcc STM32_SRC_HSE MCO1_SEL(MCO1_SEL_HSE)>; | ||
prescaler = <MCO1_PRE(MCO_PRE_DIV_1)>; | ||
pinctrl-0 = <&rcc_mco_1_pd7>; | ||
pinctrl-names = "default"; | ||
|
||
status = "disabled"; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CONFIG_VIDEO_PIXEL_FORMAT="RGBP" | ||
CONFIG_VIDEO_FRAME_WIDTH=480 | ||
CONFIG_VIDEO_FRAME_HEIGHT=272 | ||
CONFIG_VIDEO_BUFFER_POOL_SZ_MAX=262000 | ||
CONFIG_VIDEO_SOURCE_CROP_LEFT=80 | ||
CONFIG_VIDEO_SOURCE_CROP_TOP=104 | ||
CONFIG_VIDEO_SOURCE_CROP_WIDTH=480 | ||
CONFIG_VIDEO_SOURCE_CROP_HEIGHT=272 | ||
josuah marked this conversation as resolved.
Show resolved
Hide resolved
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems you miss
#include <zephyr/dt-bindings/video/video-interfaces.h>
asVIDEO_BUS_TYPE_PARALLEL
is used laterThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually video-interfaces is already included within stm32mp135f.dtsi since it is being used to set the bus-type between the DCMIPP & the MIPID02 bridge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not surre if Zephyr impose or will impose IWYU (include-what-you-use) but I think it is a best practice as it offers clarity, modularity (the file is self-contained in terms of dependency) and robustness, i.e. your code won't break if the indirect includes are removed or changed in the future
... but this is non-blocking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, agree. I update the PR adding that include.