Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbcaca7f

Browse files
committed
camera: try to defer init of video objects
This change, removes the automatic starting of the PWM clock on theGIGA, at startup. Instead it starts the clock if/when the sketch callsthe Camera::begin method.But to make this work, we also need to not start up the video objects, untilafter the MCLK has been started. We can do that with marking themas zephyr,deferred-init
1 parent658a690 commitbcaca7f

File tree

4 files changed

+65
-33
lines changed

4 files changed

+65
-33
lines changed

‎libraries/Camera/src/camera.cpp‎

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,73 @@ Camera::Camera() : vdev(NULL), byte_swap(false), yuv_to_gray(false) {
4545
}
4646
}
4747

48+
#if defined(CONFIG_VIDEO)
49+
#include<zephyr/kernel.h>
50+
#include<zephyr/device.h>
51+
#include<zephyr/drivers/clock_control.h>
52+
#include<zephyr/logging/log.h>
53+
54+
intcamera_ext_clock_enable(void) {
55+
int ret;
56+
uint32_t rate;
57+
conststructdevice *cam_ext_clk_dev =DEVICE_DT_GET(DT_NODELABEL(pwmclock));
58+
59+
if (!device_is_ready(cam_ext_clk_dev)) {
60+
return -ENODEV;
61+
}
62+
63+
ret =clock_control_on(cam_ext_clk_dev, (clock_control_subsys_t)0);
64+
if (ret <0) {
65+
return ret;
66+
}
67+
68+
ret =clock_control_get_rate(cam_ext_clk_dev, (clock_control_subsys_t)0, &rate);
69+
if (ret <0) {
70+
return ret;
71+
}
72+
73+
return0;
74+
}
75+
#else
76+
#ERROR"CONFIG_VIDEO is not defined for this variant"
77+
#endif
78+
4879
boolCamera::begin(uint32_t width,uint32_t height,uint32_t pixformat,bool byte_swap) {
4980
#if DT_HAS_CHOSEN(zephyr_camera)
5081
this->vdev =DEVICE_DT_GET(DT_CHOSEN(zephyr_camera));
5182
#endif
5283

53-
if (!this->vdev || !device_is_ready(this->vdev)) {
84+
// start the clock
85+
int ret;
86+
87+
if (!this->vdev) {
5488
returnfalse;
5589
}
5690

91+
camera_ext_clock_enable();
92+
delay(50);
93+
94+
if (!device_is_ready(this->vdev)) {
95+
// device probably has zephyr,deferred-init
96+
// On GIGA and Portenta H7 and probably others starts DCIM object
97+
if ((ret =device_init(this->vdev)) <0) {
98+
printk("device_init camera(%p) failed:%d\n",this->vdev, ret);
99+
returnfalse;
100+
}
101+
}
102+
103+
// Now see if the actual camera is defined in choosen. And see if it is ready
104+
#if DT_HAS_CHOSEN(zephyr_camera_sensor)
105+
conststructdevice *camera_sensor =DEVICE_DT_GET(DT_CHOSEN(zephyr_camera_sensor));
106+
if (!device_is_ready(camera_sensor)) {
107+
if ((ret =device_init(camera_sensor)) <0) {
108+
printk("device_init camera sensor(%p) failed:%d\n", camera_sensor, ret);
109+
returnfalse;
110+
}
111+
}
112+
113+
#endif
114+
57115
switch (pixformat) {
58116
case CAMERA_RGB565:
59117
this->byte_swap = byte_swap;

‎loader/fixups.c‎

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -74,38 +74,6 @@ static void zephyr_input_callback(struct input_event *evt, void *user_data) {
7474
INPUT_CALLBACK_DEFINE(NULL,zephyr_input_callback,NULL);
7575
#endif
7676

77-
#if defined(CONFIG_BOARD_ARDUINO_GIGA_R1)&& defined(CONFIG_VIDEO)
78-
#include<zephyr/kernel.h>
79-
#include<zephyr/device.h>
80-
#include<zephyr/drivers/clock_control.h>
81-
#include<zephyr/logging/log.h>
82-
83-
intcamera_ext_clock_enable(void) {
84-
intret;
85-
uint32_trate;
86-
conststructdevice*cam_ext_clk_dev=DEVICE_DT_GET(DT_NODELABEL(pwmclock));
87-
88-
if (!device_is_ready(cam_ext_clk_dev)) {
89-
return-ENODEV;
90-
}
91-
92-
ret=clock_control_on(cam_ext_clk_dev, (clock_control_subsys_t)0);
93-
if (ret<0) {
94-
returnret;
95-
}
96-
97-
ret=clock_control_get_rate(cam_ext_clk_dev, (clock_control_subsys_t)0,&rate);
98-
if (ret<0) {
99-
returnret;
100-
}
101-
102-
return0;
103-
}
104-
105-
SYS_INIT(camera_ext_clock_enable,POST_KERNEL,CONFIG_CLOCK_CONTROL_PWM_INIT_PRIORITY);
106-
107-
#endif
108-
10977
#if defined(CONFIG_SHARED_MULTI_HEAP)
11078
#include<zephyr/kernel.h>
11179
#include<zephyr/devicetree.h>

‎variants/arduino_giga_r1_stm32h747xx_m7/arduino_giga_r1_stm32h747xx_m7.overlay‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
gc2145: gc2145@3c {
3333
compatible = "galaxycore,gc2145";
3434
reg = <0x3c>;
35+
zephyr,deferred-init;
3536
reset-gpios = <&gpiod 4 GPIO_ACTIVE_LOW>;
3637
pwdn-gpios = <&gpioa 1 GPIO_ACTIVE_LOW>;
3738

@@ -148,6 +149,7 @@
148149

149150
&dcmi {
150151
status = "okay";
152+
zephyr,deferred-init;
151153
/* ext-sdram = <&sdram1>; */
152154
pinctrl-0 = <&dcmi_hsync_ph8 &dcmi_pixclk_pa6 &dcmi_vsync_pi5
153155
&dcmi_d0_ph9 &dcmi_d1_ph10 &dcmi_d2_ph11 &dcmi_d3_pg11
@@ -320,6 +322,7 @@
320322
/{
321323
chosen {
322324
zephyr,camera = &dcmi;
325+
zephyr,camera-sensor = &gc2145;
323326
/* zephyr,console = &board_cdc_acm_uart; */
324327
};
325328

‎variants/arduino_portenta_h7_stm32h747xx_m7/arduino_portenta_h7_stm32h747xx_m7.overlay‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
gc2145: gc2145@3c {
2121
compatible = "galaxycore,gc2145";
2222
reg = <0x3c>;
23+
zephyr,deferred-init;
2324
status = "okay";
2425

2526
reset-gpios = <&gpioe 3 GPIO_ACTIVE_LOW>;
@@ -132,6 +133,7 @@
132133

133134
&dcmi {
134135
status = "okay";
136+
zephyr,deferred-init;
135137
/* ext-sdram = <&sdram1>; */
136138
pinctrl-0 = <&dcmi_hsync_pa4 &dcmi_pixclk_pa6 &dcmi_vsync_pi5
137139
&dcmi_d0_ph9 &dcmi_d1_ph10 &dcmi_d2_ph11 &dcmi_d3_ph12
@@ -245,6 +247,7 @@
245247
/ {
246248
chosen {
247249
zephyr,camera = &dcmi;
250+
zephyr,camera-sensor = &gc2145;
248251
zephyr,console = &usart6;
249252
zephyr,shell-uart = &usart6;
250253
zephyr,cdc-acm-uart0 = &usart6;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp