From d285d4ec35a4e7d84425a88ae0faadade2298085 Mon Sep 17 00:00:00 2001 From: Alain Volmat Date: Mon, 30 Jun 2025 16:28:52 +0200 Subject: [PATCH 1/4] shields: st_b_cams_imx_mb1854: set sensor conf if DCMIPP is enabled Instead of having a conf file for all variants of STM32N6570_DK, set the necessary settings for any platform which has DCMIPP enabled. Signed-off-by: Alain Volmat --- .../st_b_cams_imx_mb1854/Kconfig.defconfig | 17 +++++++++++++++++ .../boards/stm32n6570_dk.conf | 3 --- .../boards/stm32n6570_dk_stm32n657xx_sb.conf | 3 --- 3 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 boards/shields/st_b_cams_imx_mb1854/Kconfig.defconfig delete mode 100644 boards/shields/st_b_cams_imx_mb1854/boards/stm32n6570_dk.conf delete mode 100644 boards/shields/st_b_cams_imx_mb1854/boards/stm32n6570_dk_stm32n657xx_sb.conf diff --git a/boards/shields/st_b_cams_imx_mb1854/Kconfig.defconfig b/boards/shields/st_b_cams_imx_mb1854/Kconfig.defconfig new file mode 100644 index 0000000000000..ce0297675d285 --- /dev/null +++ b/boards/shields/st_b_cams_imx_mb1854/Kconfig.defconfig @@ -0,0 +1,17 @@ +# ST_B_CAMS_IMX_MB1854 configuration + +# Copyright (c) 2025 STMicroelectronics +# SPDX-License-Identifier: Apache-2.0 + +if VIDEO_STM32_DCMIPP + +config VIDEO_STM32_DCMIPP_SENSOR_PIXEL_FORMAT + default "pRAA" + +config VIDEO_STM32_DCMIPP_SENSOR_WIDTH + default 2592 + +config VIDEO_STM32_DCMIPP_SENSOR_HEIGHT + default 1944 + +endif # VIDEO_STM32_DCMIPP diff --git a/boards/shields/st_b_cams_imx_mb1854/boards/stm32n6570_dk.conf b/boards/shields/st_b_cams_imx_mb1854/boards/stm32n6570_dk.conf deleted file mode 100644 index f89907f917235..0000000000000 --- a/boards/shields/st_b_cams_imx_mb1854/boards/stm32n6570_dk.conf +++ /dev/null @@ -1,3 +0,0 @@ -CONFIG_VIDEO_STM32_DCMIPP_SENSOR_PIXEL_FORMAT="pRAA" -CONFIG_VIDEO_STM32_DCMIPP_SENSOR_WIDTH=2592 -CONFIG_VIDEO_STM32_DCMIPP_SENSOR_HEIGHT=1944 diff --git a/boards/shields/st_b_cams_imx_mb1854/boards/stm32n6570_dk_stm32n657xx_sb.conf b/boards/shields/st_b_cams_imx_mb1854/boards/stm32n6570_dk_stm32n657xx_sb.conf deleted file mode 100644 index f89907f917235..0000000000000 --- a/boards/shields/st_b_cams_imx_mb1854/boards/stm32n6570_dk_stm32n657xx_sb.conf +++ /dev/null @@ -1,3 +0,0 @@ -CONFIG_VIDEO_STM32_DCMIPP_SENSOR_PIXEL_FORMAT="pRAA" -CONFIG_VIDEO_STM32_DCMIPP_SENSOR_WIDTH=2592 -CONFIG_VIDEO_STM32_DCMIPP_SENSOR_HEIGHT=1944 From ad8c6bbfe4b476f831a2ca40dd63f8f8b7baf4f2 Mon Sep 17 00:00:00 2001 From: Alain Volmat Date: Mon, 30 Jun 2025 16:30:50 +0200 Subject: [PATCH 2/4] samples: video: capture: add conf for stm32n6570_dk fsbl Add the board conf file for the stm32n6570_dk in its fsbl variant. Signed-off-by: Alain Volmat --- .../capture/boards/stm32n6570_dk_stm32n657xx_fsbl.conf | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 samples/drivers/video/capture/boards/stm32n6570_dk_stm32n657xx_fsbl.conf diff --git a/samples/drivers/video/capture/boards/stm32n6570_dk_stm32n657xx_fsbl.conf b/samples/drivers/video/capture/boards/stm32n6570_dk_stm32n657xx_fsbl.conf new file mode 100644 index 0000000000000..4cb5c1c804e02 --- /dev/null +++ b/samples/drivers/video/capture/boards/stm32n6570_dk_stm32n657xx_fsbl.conf @@ -0,0 +1,6 @@ +CONFIG_VIDEO_FRAME_WIDTH=800 +CONFIG_VIDEO_FRAME_HEIGHT=480 +CONFIG_VIDEO_PIXEL_FORMAT="RGBP" +CONFIG_VIDEO_BUFFER_POOL_SZ_MAX=800000 +CONFIG_VIDEO_BUFFER_POOL_NUM_MAX=2 +CONFIG_MAIN_STACK_SIZE=2048 From 10ff4c7e12f75768a0713b53f751d6d8f30049c9 Mon Sep 17 00:00:00 2001 From: Alain Volmat Date: Mon, 30 Jun 2025 16:38:53 +0200 Subject: [PATCH 3/4] samples: video: capture_to_lvgl: add stm32n6570_dk/fsbl conf Add the conf file for the stm32n6570_dk in its FSBL variant Signed-off-by: Alain Volmat --- .../boards/stm32n6570_dk_stm32n657xx_fsbl.conf | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 samples/drivers/video/capture_to_lvgl/boards/stm32n6570_dk_stm32n657xx_fsbl.conf diff --git a/samples/drivers/video/capture_to_lvgl/boards/stm32n6570_dk_stm32n657xx_fsbl.conf b/samples/drivers/video/capture_to_lvgl/boards/stm32n6570_dk_stm32n657xx_fsbl.conf new file mode 100644 index 0000000000000..8920fa813a2b2 --- /dev/null +++ b/samples/drivers/video/capture_to_lvgl/boards/stm32n6570_dk_stm32n657xx_fsbl.conf @@ -0,0 +1,5 @@ +CONFIG_VIDEO_WIDTH=800 +CONFIG_VIDEO_HEIGHT=480 +CONFIG_VIDEO_BUFFER_POOL_SZ_MAX=800000 +CONFIG_VIDEO_BUFFER_POOL_NUM_MAX=2 +CONFIG_MAIN_STACK_SIZE=4096 From b37a2d7a34e7bc456e832fe85e2af6ebf8a5a4b9 Mon Sep 17 00:00:00 2001 From: Alain Volmat Date: Mon, 30 Jun 2025 16:50:09 +0200 Subject: [PATCH 4/4] samples: video: capture_to_lvgl: add crop/compose support Demonstrate the crop/compose API by introducing 4 new CONFIG options in order to define the crop area. Moreover, if the selection API is available and if the targetted size is different from the current crop size, then try to apply a compose in order to reach the targetted format size. Signed-off-by: Alain Volmat --- samples/drivers/video/capture_to_lvgl/Kconfig | 26 +++++++++++ .../drivers/video/capture_to_lvgl/src/main.c | 45 ++++++++++++++++++- 2 files changed, 69 insertions(+), 2 deletions(-) diff --git a/samples/drivers/video/capture_to_lvgl/Kconfig b/samples/drivers/video/capture_to_lvgl/Kconfig index edff9ffbc3708..0a675d24b47be 100644 --- a/samples/drivers/video/capture_to_lvgl/Kconfig +++ b/samples/drivers/video/capture_to_lvgl/Kconfig @@ -7,6 +7,32 @@ mainmenu "Video capture to LVGL sample application" menu "Video capture configuration" +config VIDEO_SOURCE_CROP_LEFT + int "Crop area left value" + default 0 + help + Left value of the crop area within the video source. + +config VIDEO_SOURCE_CROP_TOP + int "Crop area top value" + default 0 + help + Top value of the crop area within the video source. + +config VIDEO_SOURCE_CROP_WIDTH + int "Crop area width value" + default 0 + help + Width value of the crop area within the video source. + If set to 0, the crop is not applied. + +config VIDEO_SOURCE_CROP_HEIGHT + int "Crop area height value" + default 0 + help + Height value of the crop area within the video source. + If set to 0, the crop is not applied. + config VIDEO_WIDTH int "Define the width of the video" default 320 diff --git a/samples/drivers/video/capture_to_lvgl/src/main.c b/samples/drivers/video/capture_to_lvgl/src/main.c index c04a3b04b6183..2d79aaa812d42 100644 --- a/samples/drivers/video/capture_to_lvgl/src/main.c +++ b/samples/drivers/video/capture_to_lvgl/src/main.c @@ -23,8 +23,12 @@ int main(void) struct video_format fmt; struct video_caps caps; enum video_buf_type type = VIDEO_BUF_TYPE_OUTPUT; + struct video_selection sel = { + .type = VIDEO_BUF_TYPE_OUTPUT, + }; size_t bsize; int i = 0; + int err; display_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_display)); if (!device_is_ready(display_dev)) { @@ -66,11 +70,50 @@ int main(void) return 0; } + /* Set the crop setting if necessary */ +#if CONFIG_VIDEO_SOURCE_CROP_WIDTH && CONFIG_VIDEO_SOURCE_CROP_HEIGHT + sel.target = VIDEO_SEL_TGT_CROP; + sel.rect.left = CONFIG_VIDEO_SOURCE_CROP_LEFT; + sel.rect.top = CONFIG_VIDEO_SOURCE_CROP_TOP; + sel.rect.width = CONFIG_VIDEO_SOURCE_CROP_WIDTH; + sel.rect.height = CONFIG_VIDEO_SOURCE_CROP_HEIGHT; + if (video_set_selection(video_dev, &sel)) { + LOG_ERR("Unable to set selection crop"); + return 0; + } + LOG_INF("Selection crop set to (%u,%u)/%ux%u", + sel.rect.left, sel.rect.top, sel.rect.width, sel.rect.height); +#endif + /* Set format */ fmt.width = CONFIG_VIDEO_WIDTH; fmt.height = CONFIG_VIDEO_HEIGHT; fmt.pixelformat = VIDEO_PIX_FMT_RGB565; + /* + * Check (if possible) if targeted size is same as crop + * and if compose is necessary + */ + sel.target = VIDEO_SEL_TGT_CROP; + err = video_get_selection(video_dev, &sel); + if (err < 0 && err != -ENOSYS) { + LOG_ERR("Unable to get selection crop"); + return 0; + } + + if (err == 0 && (sel.rect.width != fmt.width || sel.rect.height != fmt.height)) { + sel.target = VIDEO_SEL_TGT_COMPOSE; + sel.rect.left = 0; + sel.rect.top = 0; + sel.rect.width = fmt.width; + sel.rect.height = fmt.height; + err = video_set_selection(video_dev, &sel); + if (err < 0 && err != -ENOSYS) { + LOG_ERR("Unable to set selection compose"); + return 0; + } + } + if (video_set_format(video_dev, &fmt)) { LOG_ERR("Unable to set up video format"); return 0; @@ -134,8 +177,6 @@ int main(void) /* Grab video frames */ vbuf->type = type; while (1) { - int err; - err = video_dequeue(video_dev, &vbuf, K_FOREVER); if (err) { LOG_ERR("Unable to dequeue video buf");