-
Notifications
You must be signed in to change notification settings - Fork 539
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
Stronger V4L2 compliance in REQBUF #611
base: main
Are you sure you want to change the base?
Conversation
looking forward to this. |
313ad8e
to
d935c8e
Compare
Allow either writer or reader to enumerate all formats except when the format has been fixed (by, say, a writer, or keep_format).
Use macros for all buffer flag-setting, including return values.
Add prepare_buffer_queue which can both increase and decrease the size of outbufs_list
assign opener type in first call to read() use REQBUFS for allocation in first call to read() and write()
126c93b
to
ced5930
Compare
V4L2 UAPI states that REQBUFS has STREAMOFF effect when the count is zero.
Use REQBUFS as a (safe) mechanism to 'free' buffers when file handle is closed; ensures that any future improvements to REQBUFS or STREAMOFF will also uplift open()/close().
Ensure that format and buffer (type) negotiation ioctls follow a consistent convention for whether the buffer type is available. When announcing all (device) capabilities, no restrictions. When not announcing all; allow OUTPUT when `ready_for_output`; and allow CAPTURE when `keep_format` or `ready_for_capture`.
ced5930
to
68676b6
Compare
Apologies for the extra actions - I had to rebase and fix an incompatibility with the older kernel UAPI. There's still a few commits to come - just going through some more testing, and trying to make each commit as 'small' as possible so there's a reasonably clear progression from start to finish. [edit] |
i take it, that a Draft-PR is only partially working, and you'll probably want to clean it up in the end - so don't worry about intermediate build failures. and while I do think it is great to support older kernels, sometimes it is simply not feasible. e.g. i think that the xenial builds fail because the base images are broken (because it is really old and github-actions wrongly assume that they can run a newer bulid of |
🚧 A work in progress 🚧
Originally raised in #598. The goal is to improve compliance with the V4L2 REQBUFS specification:
This first appeared as an issue in some earlier experiments I was doing with tiagocoutinho/linuxpy.
Summary
If an opener REQBUFS successfully; then both the format and number of buffers should be fixed until (all) openers have freed the buffers (REQBUFS with count zero). If another opener tries to S_FMT, or REQBUFS while they are fixed - it has to eat what it is served (but they will return success). ENUM_FMT will report all available formats unless keep_format is set.
There is now less distinction between a reader and a writer prior to acquiring a claim (or 'reference') to buffers - so readers may 'lock' in a format if no writers have already done so.
Details
To achieve this the existing
ready_for_capture
,ready_for_output
,active_readers
, andopener->type
are retired - and instead:image_ref_count
.count = 0
('frees' buffers - but doesn't actually free them).count = 0
now performs a STREAMOFF as suggested in V4L2.used_buffers
as thecount
- provided there are no other errors.CAPTURE
orOUTPUT
); otherwise EINVAL.write()
uses REQBUFS to allocate buffers and STREAMON to acquire write tokenclose()
, via REQBUFS withcount = 0
, releases any held token and 'frees' (claim to) buffers.In progress
There is still testing to do to ensure that existing behaviour is preserved, and stricter compliance is achieved. The final commit needs to be tidied up once testing is complete.
Some minor quality-of-life improvements are included:
open_count
inclose()
. 248b3f5timeout_image_io
CTRL. ba4789av4l2loopback-ctl
. 5931810add()
(sizeimage
was missing). e40cf90