Skip to content

Commit 950e730

Browse files
committed
drivers: video: Introduce video_mdev structure
The video_mdev structure is used to determine a video device, usually a DMA or ISP device, as a main device of the video pipeline it belongs to. The main video device represents the whole pipeline to communicate with the application. The video subsystem expose the list of main video devices to userspace via two APIs: - video_get_dev() : get a video device by index - video_get_devs_num() : get the number of registered video devices With this, we don't need to define a zephyr,camera chosen node anymore. Moreover, application can switch between multiple video devices/pipelines and not restricted to a single pre-defined camera node. Signed-off-by: Phi Bang Nguyen <[email protected]>
1 parent 89dd0ef commit 950e730

File tree

22 files changed

+106
-76
lines changed

22 files changed

+106
-76
lines changed

boards/arduino/nicla_vision/arduino_nicla_vision_stm32h747xx_m7.dts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
zephyr,sram = &sram0;
2323
zephyr,flash = &flash0;
2424
zephyr,code-partition = &slot0_partition;
25-
zephyr,camera = &dcmi;
2625
};
2726

2827
aliases {

boards/espressif/esp32s3_eye/esp32s3_eye_procpu.dts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
zephyr,code-partition = &slot0_partition;
3232
zephyr,bt-hci = &esp32_bt_hci;
3333
zephyr,display = &st7789v;
34-
zephyr,camera = &lcd_cam;
3534
};
3635

3736
buttons {

boards/seeed/xiao_esp32s3/xiao_esp32s3_procpu_sense.dts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
/ {
1212
model = "Seeed Xiao ESP32S3 PROCPU Sense";
1313
compatible = "seeed,xiao-esp32s3";
14-
15-
chosen {
16-
zephyr,camera = &lcd_cam;
17-
};
1814
};
1915

2016
&i2c1 {

boards/shields/dvp_fpc24_mt9m114/dvp_fpc24_mt9m114.overlay

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
/{
8-
chosen {
9-
zephyr,camera = &dvp_fpc24_interface;
10-
};
11-
};
12-
137
&dvp_fpc24_i2c {
148
mt9m114: mt9m114@48 {
159
compatible = "aptina,mt9m114";

boards/shields/nxp_btb44_ov5640/nxp_btb44_ov5640.overlay

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@
66

77
#include <zephyr/dt-bindings/video/video-interfaces.h>
88

9-
/{
10-
chosen {
11-
zephyr,camera = &nxp_csi;
12-
};
13-
};
14-
159
&nxp_cam_i2c {
1610
status = "okay";
1711

boards/shields/st_b_cams_omv_mb1683/st_b_cams_omv_mb1683.overlay

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@
77

88
#include <zephyr/dt-bindings/video/video-interfaces.h>
99

10-
/ {
11-
chosen {
12-
zephyr,camera = &st_cam_dvp;
13-
};
14-
};
15-
1610
&st_cam_i2c {
1711

1812
ov5640: ov5640@3c {

boards/shields/weact_ov2640_cam_module/weact_ov2640_cam_module.overlay

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
/ {
8-
chosen {
9-
zephyr,camera = &zephyr_camera_dvp;
10-
};
11-
};
12-
137
&zephyr_camera_i2c {
148
status = "okay";
159
clock-frequency = <I2C_BITRATE_FAST>;

cmake/linker_script/common/common-ram.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ endif()
127127

128128
if(CONFIG_VIDEO)
129129
zephyr_iterable_section(NAME video_device GROUP DATA_REGION ${XIP_ALIGN_WITH_INPUT} SUBALIGN ${CONFIG_LINKER_ITERABLE_SUBALIGN})
130+
zephyr_iterable_section(NAME video_mdev GROUP DATA_REGION ${XIP_ALIGN_WITH_INPUT} SUBALIGN ${CONFIG_LINKER_ITERABLE_SUBALIGN})
130131
endif()
131132

132133
if(CONFIG_LOG)

drivers/video/video.ld

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#include <zephyr/linker/iterable_sections.h>
22

33
ITERABLE_SECTION_RAM(video_device, Z_LINK_ITERABLE_SUBALIGN)
4+
ITERABLE_SECTION_RAM(video_mdev, Z_LINK_ITERABLE_SUBALIGN)

drivers/video/video_device.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7+
#include <zephyr/drivers/video.h>
8+
79
#include "video_device.h"
810

911
struct video_device *video_find_vdev(const struct device *dev)
@@ -20,3 +22,21 @@ struct video_device *video_find_vdev(const struct device *dev)
2022

2123
return NULL;
2224
}
25+
26+
const struct device *video_get_dev(uint8_t i)
27+
{
28+
const struct video_mdev *vmd = NULL;
29+
30+
STRUCT_SECTION_GET(video_mdev, i, &vmd);
31+
32+
return vmd->dev;
33+
}
34+
35+
uint8_t video_get_devs_num(void)
36+
{
37+
uint8_t count = 0;
38+
39+
STRUCT_SECTION_COUNT(video_mdev, &count);
40+
41+
return count;
42+
}

0 commit comments

Comments
 (0)