From 64c9b916c8a46e3f19ac5c4b13c010664d29bc60 Mon Sep 17 00:00:00 2001 From: Josuah Demangeon Date: Mon, 2 Jun 2025 12:30:05 +0000 Subject: [PATCH 1/3] samples: drivers: video: add DT_HAS_CHOSEN() safeguards Add macros giving hints to users using #error, about what might be missing to build and run the samples, such as a missing "chosen" devicetree node. Signed-off-by: Josuah Demangeon --- samples/drivers/video/capture/src/main.c | 4 ++++ samples/drivers/video/capture_to_lvgl/src/main.c | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/samples/drivers/video/capture/src/main.c b/samples/drivers/video/capture/src/main.c index d744c1604de4..5e07318b0853 100644 --- a/samples/drivers/video/capture/src/main.c +++ b/samples/drivers/video/capture/src/main.c @@ -22,6 +22,10 @@ LOG_MODULE_REGISTER(main, LOG_LEVEL_DBG); LOG_MODULE_REGISTER(main, CONFIG_LOG_DEFAULT_LEVEL); #endif +#if !DT_HAS_CHOSEN(zephyr_camera) +#error No camera chosen in devicetree. Missing "--shield" or "--snippet video-sw-generator" flag? +#endif + #if DT_HAS_CHOSEN(zephyr_display) static inline int display_setup(const struct device *const display_dev, const uint32_t pixfmt) { diff --git a/samples/drivers/video/capture_to_lvgl/src/main.c b/samples/drivers/video/capture_to_lvgl/src/main.c index c04a3b04b618..69b39b3904b8 100644 --- a/samples/drivers/video/capture_to_lvgl/src/main.c +++ b/samples/drivers/video/capture_to_lvgl/src/main.c @@ -14,6 +14,14 @@ LOG_MODULE_REGISTER(main, CONFIG_LOG_DEFAULT_LEVEL); +#if !DT_HAS_CHOSEN(zephyr_camera) +#error No camera chosen in devicetree. Missing "--shield" or "--snippet video-sw-generator" flag? +#endif + +#if !DT_HAS_CHOSEN(zephyr_display) +#error No display chosen in devicetree. Missing "--shield" flag? +#endif + int main(void) { struct video_buffer *buffers[2]; From 6dea9d5d8e0461544730f4050c585e9c576ca424 Mon Sep 17 00:00:00 2001 From: Josuah Demangeon Date: Mon, 2 Jun 2025 12:35:14 +0000 Subject: [PATCH 2/3] samples: drivers: video: capture: remove invalid build instruction Remove the build instruction from README about using the native_sim without using the video-sw-generator snippet, as it cannot build. Signed-off-by: Josuah Demangeon --- samples/drivers/video/capture/README.rst | 8 -------- 1 file changed, 8 deletions(-) diff --git a/samples/drivers/video/capture/README.rst b/samples/drivers/video/capture/README.rst index 43c5f79a8b9f..39049daed97b 100644 --- a/samples/drivers/video/capture/README.rst +++ b/samples/drivers/video/capture/README.rst @@ -83,14 +83,6 @@ using the :ref:`dvp_20pin_ov7670` and :ref:`lcd_par_s035` connected to the board :goals: build :compact: -For :ref:`native_sim`, build this sample application with the following commands: - -.. zephyr-app-commands:: - :zephyr-app: samples/drivers/video/capture - :board: native_sim - :goals: build - :compact: - For testing purpose and 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, and using :ref:`snippet-video-sw-generator`: From 893ff229627b7528f8ab957e370ca732ef551e95 Mon Sep 17 00:00:00 2001 From: Josuah Demangeon Date: Mon, 2 Jun 2025 12:43:35 +0000 Subject: [PATCH 3/3] doc: release: mention new video-sw-generator snippet This snippet got introduced, and is not a breaking change for C APIs but still introduce a change of command line to use for building projects, so add a migration guide entry. Signed-off-by: Josuah Demangeon --- doc/releases/migration-guide-4.2.rst | 3 +++ doc/releases/release-notes-4.2.rst | 1 + 2 files changed, 4 insertions(+) diff --git a/doc/releases/migration-guide-4.2.rst b/doc/releases/migration-guide-4.2.rst index d1340c0b6f9c..28f67c1231f0 100644 --- a/doc/releases/migration-guide-4.2.rst +++ b/doc/releases/migration-guide-4.2.rst @@ -718,6 +718,9 @@ Video size on a per driver basis. Existing applications will not be broken by this change but can be simplified as performed in the sample in the commit ``33dcbe37cfd3593e8c6e9cfd218dd31fdd533598``. +* Samples and projects using the :ref:`native simulator ` now require specifying the + ``--snippet`` :ref:`video-sw-generator ` to build correctly. + Audio ===== diff --git a/doc/releases/release-notes-4.2.rst b/doc/releases/release-notes-4.2.rst index 7adfabd7506d..bdebeee4c548 100644 --- a/doc/releases/release-notes-4.2.rst +++ b/doc/releases/release-notes-4.2.rst @@ -278,6 +278,7 @@ New APIs and options * :c:func:`video_api_ctrl_t` * :c:func:`video_query_ctrl` * :c:func:`video_print_ctrl` + * :ref:`video-sw-generator ` * PCIe