-
Notifications
You must be signed in to change notification settings - Fork 7.6k
driver: video: esp32: add video_flush()
callback
#86915
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Sorry to comment a bit late when this is just merged but when
video_esp32_flush()
is called (by video_stream_stop()), the video_esp32_set_stream() is already called. This is the same error as in video_emul driver which I fixed here.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.
If the driver's
flush()
does not perform the needed "stop" actions, then the user should always callvideo_stream_stop()
beforevideo_flush()
... But asvideo_stream_stop()
already callsvideo_flush()
, that suggests thatvideo_flush()
should be deprecated in the long run?There remain the need to handle
bool cancel
... In that case,set_stream()
would need to be a more generic operation maybe... Likeset_stream(START)
,set_stream(STOP)
,set_stream(CANCEL)
etc.Maybe this comes as part of the video control framework PR, in which case I'll just wait patiently. :)
Uh oh!
There was an error while loading. Please reload this page.
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.
No, here we talk only the case cancel = true that means the flush callback is surely called by video_stream_stop() and in video_stream_stop(), set_stream(false) is already called before calling the flush, so no need to call it again.
Uh oh!
There was an error while loading. Please reload this page.
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.
For a broader scope of discussion about
video_flush()
, there's my long comment here.Firstly, I think we need to agree on what to do to "flush" when stopping stream. It then depends on what we agree on what to do to restart. As widely adopted in Linux as a general rule (in my quoted comment), restart is like a new start, user needs to (re-)enqueue buffers. So, when flushing, both fifo_in and fifo_out need to be emptied / cleaned so that everything can be restarted again.
However, current implementation of flush callback in some Zephyr drivers like esp32, csi, sw_generator is just taking all the buffers in the fifo_in and put them to fifo_out. It needs to be rethinked.
Another difficulty is low level drivers (which Zephyr drivers are based on) do it differently, for example, the CSI low level driver puts all the buffers in fifo_out into the fifo_in (contracdictory with what Zephyr driver does) as it expected to be able to restart right away without re-enqueuing buffer (by user).
And Linux does not expose flushing API to driver but does it implicitly in the v4l2 framework ...
So it's a bit complicated. I will try to address this because it is also related to removing the video_endpoint_id in flushing API.
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.
BTW, I don't see any usecase / need to force a flush when stream is on-going (cancel = false) ?
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.
I will pursue on this PR if that makes sense...
#87070 (comment)
Thank you for your in-depth answer!