Skip to content

drivers: video: CONFIG_VIDEO_SW_GENERATOR -> zephyr,video-sw-generator #88780

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

Merged
Merged
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
2 changes: 2 additions & 0 deletions doc/build/dts/api/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,8 @@ device.
- Sets UART device used for the Bluetooth monitor logging
* - zephyr,bt-hci
- Selects the HCI device used by the Bluetooth host stack
* - zephyr,camera
- Video input device, typically a camera.
* - zephyr,canbus
- Sets the default CAN controller
* - zephyr,ccm
Expand Down
7 changes: 2 additions & 5 deletions drivers/video/Kconfig.sw_generator
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# MT9m114

# Copyright (c) 2016 Linaro Limited
# SPDX-License-Identifier: Apache-2.0

DT_CHOSEN_ZEPHYR_CAMERA := zephyr,camera

config VIDEO_SW_GENERATOR
bool "Video Software Generator"
depends on !$(dt_chosen_enabled,$(DT_CHOSEN_ZEPHYR_CAMERA))
depends on DT_HAS_ZEPHYR_VIDEO_SW_GENERATOR_ENABLED
default y
help
Enable video pattern generator (for testing purposes).
31 changes: 17 additions & 14 deletions drivers/video/video_sw_generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

#define DT_DRV_COMPAT zephyr_sw_generator
#define DT_DRV_COMPAT zephyr_video_sw_generator

#include <zephyr/drivers/video-controls.h>
#include <zephyr/drivers/video.h>
Expand Down Expand Up @@ -455,14 +455,6 @@ static DEVICE_API(video, video_sw_generator_driver_api) = {
#endif
};

static struct video_sw_generator_data video_sw_generator_data_0 = {
.fmt.width = 320,
.fmt.height = 160,
.fmt.pitch = 320 * 2,
.fmt.pixelformat = VIDEO_PIX_FMT_RGB565,
.frame_rate = DEFAULT_FRAME_RATE,
};

static int video_sw_generator_init_controls(const struct device *dev)
{
struct video_sw_generator_data *data = dev->data;
Expand All @@ -483,8 +475,19 @@ static int video_sw_generator_init(const struct device *dev)
return video_sw_generator_init_controls(dev);
}

DEVICE_DEFINE(video_sw_generator, "VIDEO_SW_GENERATOR", &video_sw_generator_init, NULL,
&video_sw_generator_data_0, NULL, POST_KERNEL, CONFIG_VIDEO_INIT_PRIORITY,
&video_sw_generator_driver_api);

VIDEO_DEVICE_DEFINE(video_sw_generator, DEVICE_GET(video_sw_generator), NULL);
#define VIDEO_SW_GENERATOR_DEFINE(n) \
static struct video_sw_generator_data video_sw_generator_data_##n = { \
.fmt.width = 320, \
.fmt.height = 160, \
.fmt.pitch = 320 * 2, \
.fmt.pixelformat = VIDEO_PIX_FMT_RGB565, \
.frame_rate = DEFAULT_FRAME_RATE, \
}; \
\
DEVICE_DT_INST_DEFINE(n, &video_sw_generator_init, NULL, &video_sw_generator_data_##n, \
NULL, POST_KERNEL, CONFIG_VIDEO_INIT_PRIORITY, \
&video_sw_generator_driver_api); \
\
VIDEO_DEVICE_DEFINE(video_sw_generator_##n, DEVICE_DT_INST_GET(n), NULL);

DT_INST_FOREACH_STATUS_OKAY(VIDEO_SW_GENERATOR_DEFINE)
6 changes: 6 additions & 0 deletions dts/bindings/video/zephyr,video-sw-generator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright 2025 tinyVision.ai Inc.
# SPDX-License-Identifier: Apache-2.0

description: Emulated Video test pattern generator

compatible: "zephyr,video-sw-generator"
11 changes: 9 additions & 2 deletions samples/drivers/video/capture/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,16 @@ For :ref:`native_sim`, build this sample application with the following commands
:goals: build
:compact:

For testing purpose without the need of any real video capture and/or display hardwares,
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.
specifying the shields, and using :ref:`snippet-video-sw-generator`:

.. zephyr-app-commands::
:zephyr-app: samples/drivers/video/capture
:board: native_sim/native/64
:snippets: video-sw-generator
:goals: build
:compact:

For controlling the camera device using shell commands instead of continuously capturing the data,
append ``-DCONFIG_VIDEO_SHELL=y`` to the build command:
Expand Down
1 change: 0 additions & 1 deletion samples/drivers/video/capture/prj.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
CONFIG_VIDEO=y
CONFIG_VIDEO_SW_GENERATOR=y
CONFIG_SHELL=y
CONFIG_DEVICE_SHELL=y
CONFIG_PRINTK=y
Expand Down
8 changes: 5 additions & 3 deletions samples/drivers/video/capture/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ tests:
- shield
- samples
extra_args:
- platform:mimxrt1064_evk:SHIELD="dvp_fpc24_mt9m114;rk043fn66hs_ctg"
- platform:mimxrt1064_evk/mimxrt1064:SHIELD="dvp_fpc24_mt9m114;rk043fn66hs_ctg"
- platform:mimxrt1170_evk/mimxrt1176/cm7:SHIELD="nxp_btb44_ov5640;rk055hdmipi4ma0"
- platform:mimxrt1170_evk@B/mimxrt1176/cm7:SHIELD="nxp_btb44_ov5640;rk055hdmipi4ma0"
- platform:frdm_mcxn947/mcxn947/cpu0:SHIELD="dvp_20pin_ov7670;lcd_par_s035_8080"
Expand All @@ -26,15 +26,15 @@ tests:
- "Pattern OK"
platform_allow:
- arduino_nicla_vision/stm32h747xx/m7
- mimxrt1064_evk
- mimxrt1064_evk/mimxrt1064
- mimxrt1170_evk/mimxrt1176/cm7
- mimxrt1170_evk@B/mimxrt1176/cm7
- frdm_mcxn947/mcxn947/cpu0
- mm_swiftio
- esp32s3_eye/esp32s3/procpu
depends_on: video
integration_platforms:
- mimxrt1064_evk
- mimxrt1064_evk/mimxrt1064
- mimxrt1170_evk/mimxrt1176/cm7
sample.video.capture.shell:
tags:
Expand All @@ -45,6 +45,8 @@ tests:
- CONFIG_VIDEO_SHELL=y
- CONFIG_FPU=y
- CONFIG_DISPLAY=n
extra_args:
- platform:native_sim/native/64:SNIPPET="video-sw-generator"
harness: console
harness_config:
type: one_line
Expand Down
20 changes: 4 additions & 16 deletions samples/drivers/video/capture/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,15 @@
#include <zephyr/drivers/video-controls.h>

#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(main);

#ifdef CONFIG_TEST
#include "check_test_pattern.h"

#define LOG_LEVEL LOG_LEVEL_DBG
LOG_MODULE_REGISTER(main, LOG_LEVEL_DBG);
#else
#define LOG_LEVEL CONFIG_LOG_DEFAULT_LEVEL
LOG_MODULE_REGISTER(main, CONFIG_LOG_DEFAULT_LEVEL);
#endif

#define VIDEO_DEV_SW "VIDEO_SW_GENERATOR"

#if DT_HAS_CHOSEN(zephyr_display)
static inline int display_setup(const struct device *const display_dev, const uint32_t pixfmt)
{
Expand Down Expand Up @@ -92,6 +89,7 @@ int main(void)
{
struct video_buffer *buffers[CONFIG_VIDEO_BUFFER_POOL_NUM_MAX];
struct video_buffer *vbuf = &(struct video_buffer){};
const struct device *video_dev;
struct video_format fmt;
struct video_caps caps;
struct video_frmival frmival;
Expand All @@ -108,21 +106,11 @@ int main(void)
return 0;
}

#if DT_HAS_CHOSEN(zephyr_camera)
const struct device *const video_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_camera));

video_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_camera));
if (!device_is_ready(video_dev)) {
LOG_ERR("%s: video device is not ready", video_dev->name);
return 0;
}
#else
const struct device *const video_dev = device_get_binding(VIDEO_DEV_SW);

if (video_dev == NULL) {
LOG_ERR("%s: video device not found or failed to initialized", VIDEO_DEV_SW);
return 0;
}
#endif

LOG_INF("Video device: %s", video_dev->name);

Expand Down
10 changes: 10 additions & 0 deletions samples/drivers/video/capture_to_lvgl/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ For :zephyr:board:`mini_stm32h743`, build this sample application with the follo
:gen-args: -DCONFIG_BOOT_DELAY=2000
:compact:

For testing purpose and without the need of any real video capture hardware,
a video software pattern generator is supported by using :ref:`snippet-video-sw-generator`:

.. zephyr-app-commands::
:zephyr-app: samples/drivers/video/capture
:board: native_sim/native/64
:snippets: video-sw-generator
:goals: build
:compact:

Sample Output
=============

Expand Down
1 change: 0 additions & 1 deletion samples/drivers/video/capture_to_lvgl/prj.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
CONFIG_VIDEO=y
CONFIG_VIDEO_SW_GENERATOR=y

CONFIG_PRINTK=y
CONFIG_LOG=y
Expand Down
17 changes: 3 additions & 14 deletions samples/drivers/video/capture_to_lvgl/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,20 @@
#include <zephyr/drivers/display.h>
#include <zephyr/drivers/video.h>
#include <zephyr/drivers/video-controls.h>
#include <lvgl.h>

#define LOG_LEVEL CONFIG_LOG_DEFAULT_LEVEL
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(main);
#include <lvgl.h>

#define VIDEO_DEV_SW "VIDEO_SW_GENERATOR"
LOG_MODULE_REGISTER(main, CONFIG_LOG_DEFAULT_LEVEL);

int main(void)
{
struct video_buffer *buffers[2];
struct video_buffer *vbuf = &(struct video_buffer){};
const struct device *display_dev;
const struct device *video_dev;
struct video_format fmt;
struct video_caps caps;
enum video_buf_type type = VIDEO_BUF_TYPE_OUTPUT;
const struct device *video_dev;
size_t bsize;
int i = 0;

Expand All @@ -35,19 +32,11 @@ int main(void)
return 0;
}

#if DT_HAS_CHOSEN(zephyr_camera)
video_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_camera));
if (!device_is_ready(video_dev)) {
LOG_ERR("%s device is not ready", video_dev->name);
return 0;
}
#else
video_dev = device_get_binding(VIDEO_DEV_SW);
if (video_dev == NULL) {
LOG_ERR("%s device not found", VIDEO_DEV_SW);
return 0;
}
#endif

LOG_INF("- Device name: %s", video_dev->name);

Expand Down
10 changes: 10 additions & 0 deletions samples/drivers/video/tcpserversink/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ If a mt9m114 camera shield is missing, video software generator will be used ins
:goals: build
:compact:

For testing purpose and without the need of any real video capture hardware,
a video software pattern generator is supported by using :ref:`snippet-video-sw-generator`:

.. zephyr-app-commands::
:zephyr-app: samples/drivers/video/capture
:board: native_sim/native/64
:snippets: video-sw-generator
:goals: build
:compact:

Sample Output
=============

Expand Down
1 change: 0 additions & 1 deletion samples/drivers/video/tcpserversink/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@ CONFIG_NET_CONFIG_SETTINGS=y
CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.0.2.1"

CONFIG_VIDEO=y
CONFIG_VIDEO_SW_GENERATOR=y
6 changes: 3 additions & 3 deletions samples/drivers/video/tcpserversink/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ tests:
- net
- socket
- shield
platform_allow: mimxrt1064_evk
platform_allow: mimxrt1064_evk/mimxrt1064
depends_on:
- video
- netif
integration_platforms:
- mimxrt1064_evk
- mimxrt1064_evk/mimxrt1064
extra_args:
- platform:mimxrt1064_evk:SHIELD=dvp_fpc24_mt9m114
- platform:mimxrt1064_evk/mimxrt1064:SHIELD=dvp_fpc24_mt9m114
Loading