-
Notifications
You must be signed in to change notification settings - Fork 8.2k
video: esp32: initialize format #95890
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -386,6 +386,16 @@ static int video_esp32_init(const struct device *dev) | |||||||||||||
| return -ENODEV; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| if (!device_is_ready(cfg->source_dev)) { | ||||||||||||||
| LOG_ERR("Source device not ready"); | ||||||||||||||
| return -ENODEV; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| if (video_get_format(dev, &data->video_format) < 0) { | ||||||||||||||
| LOG_ERR("Failed to get default format from source device"); | ||||||||||||||
| return -EINVAL; | ||||||||||||||
| } | ||||||||||||||
|
Comment on lines
+394
to
+397
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you explain why the esp32_dvp needs to get the format from the source here in
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it intentional not to set a default format in the drivers?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is not intentional, most of the sensor drivers set its default format. However, it is not mandatory, so we should not check this in the receiver init function and return failed as it's not an issue if it is not set at initialization, I think.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @josuah could you give your oppinion on this?
The root cause is that the sensor and capture driver are not properly synchronized after startup.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently there is the assumption that a default format will be set before any intervention from the sample: zephyr/samples/drivers/video/capture/src/main.c Lines 144 to 149 in 1d6b675
But this is a tricky situation: now users in a might want to modify the driver (where the default comes from) to get the resolution. In the meantime, setting the default is still the best that can be done?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to add a check to the samples so that if fmt is not set correctly, we should not continue. The order should be
Anyway, checking the sensor default format here in the receiver init() and force the driver stop initializing here is not the right way I think, because user can set the format later. Furthermore, the check : is not sufficient as |
||||||||||||||
|
|
||||||||||||||
| return 0; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason to require the sensor to be initialized before the dvp ? If so, you should change the init order of the dvp (currently, they are the same order and no guarantee for that).
Otherwise, I don't see in the code any reason for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the call to
video_get_format(dev, &data->video_format)will be forwarded to thesource_devi think this is needed.The driver expects the
sourceproperty set and therefore I think the initialization sequence is correct because lcd_cam depends on the sensor driver?https://github.com/zephyrproject-rtos/zephyr/blob/5bef4a9d6264761c10d739b345eb2f7ded719099/boards/espressif/esp32s3_eye/esp32s3_eye_procpu.dts#L150C1-L150C21
Or should the driver actually be updated to make use of
remote-endpoint? In that case yes we would have to handle the initialization sequence differently.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, just realize that the
esp32_dvpis not yet migrated to use the port / endpoint mechanism, issue here:#80514
Could you help to do this if possible ? An example is here #88323
With the new remote-endpoint and no direct phandle reference we don't need the sensor initialized before the dvp anymore (if it is not explicitely required for some reason)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe I find some time tomorrow. I will do an other PR then.