Skip to content
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

support v4l2 event apis #345

Merged

Conversation

vicamo
Copy link
Contributor

@vicamo vicamo commented Sep 16, 2020

This is an attempt to enable V4L2 Events API in v4l2loopback. Now we have:

$ v4l2-compliance -v -d /dev/video1
...
        test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK

When v4l2_fh_init() is called, kernel V4L2 subsystem would assume
file->private_data is a pointer to a v4l2_fh instance.  Follow this and
update corresponding references with a `fh_to_opener` macro.

Signed-off-by: You-Sheng Yang <vicamo@gmail.com>
Signed-off-by: You-Sheng Yang <vicamo@gmail.com>
Signed-off-by: You-Sheng Yang <vicamo@gmail.com>
@umlaeute
Copy link
Owner

which problems does this PR solve?

@vicamo
Copy link
Contributor Author

vicamo commented Sep 21, 2020

Hi, this will be a new feature to support V4L2 Event API as akvcam, another v4l2 loopback implementation, does, and at the same time be an attempt to refactor v4l2loopback with in-kernel sub frameworks like v4l2-fh.

@umlaeute
Copy link
Owner

Hi, this will be a new feature to support V4L2 Event API as akvcam, another v4l2 loopback implementation, does,

so what is the use-case?

and at the same time be an attempt to refactor v4l2loopback with in-kernel sub frameworks like v4l2-fh.

i welcome this, however:

  • afaict, this is really unrelated to the "event API" feature. it should go into a separate PR (just telling; luckily it seems that all the changes are in separate commit)
  • will this work with older kernels as well? (aka: do we need ifdef-protectors for legacy support?)

@vicamo
Copy link
Contributor Author

vicamo commented Oct 13, 2020

Rebase on latest develop branch. Tested build old kernels as well. So far 3.16 is the oldest kernel known working, and it fails on 3.13 due to incompatibility introduced by IDR.

So there is a project called libcamera, which is to wrap V4L2 and other ways of camera access in a user space library and provide unified API interface. Under libcamera, there is no more directly access to underlying video devices, so a compatible layer based on LD_PRELOAD was implemented. However, it introduces additional troubles in security reasons as well as adoption difficulties especially for those container based application packages. So a loopback device that connects both libcamera and traditional V4L2 based applications is the right solution. That's when v4l2loopback/akvcam emerges from the horizon. In order to have better handle of the device states, V4L2 Event API provides an official way to notify both sides.

And since V4L2 Events API is based on v4l2_fh sub framework, and it's automatically achieved by implementations using v4l2_fh, the major task here is to add and use v4l2_fh in the opener structure.

That's the full story. :)

@umlaeute umlaeute merged commit 53824d4 into umlaeute:develop Oct 13, 2020
@vicamo vicamo deleted the for-upstream/support-v4l2-event-apis branch October 14, 2020 01:26
@vicamo vicamo restored the for-upstream/support-v4l2-event-apis branch October 14, 2020 01:34
@vicamo vicamo deleted the for-upstream/support-v4l2-event-apis branch October 14, 2020 01:38
vicamo added a commit to vicamo/v4l2loopback that referenced this pull request Mar 13, 2021
v4l2-compliance complains about "Video Capture cap set, but no Video
Capture formats defined" because V4L2_CAP_VIDEO_M2M is set and yet
vidioc_enum_fmt_cap implementation would simply return -EINVAL before
being ready for capturing.

V4L2 memory-to-memory operatons have never been actually supported. It
was introduced in an attempt to fix umlaeute#67,
VIDIOC_G/S_PRIORITY test failures reported by v4l2-compliance, but
VIDIOC_G/S_PRIORITY is an exclusive feature when V4L2 file handle
framework is used, and this was certainly not the case until
umlaeute#345 that brought in v4l2_fh for V4L2 Event API
support.

This change removes all declarations of M2M support.

Signed-off-by: You-Sheng Yang <vicamo@gmail.com>
vicamo added a commit to vicamo/v4l2loopback that referenced this pull request Mar 13, 2021
v4l2-compliance complains about "Video Capture cap set, but no Video
Capture formats defined" because V4L2_CAP_VIDEO_M2M is set and yet
vidioc_enum_fmt_cap implementation would simply return -EINVAL before
being ready for capturing.

V4L2 memory-to-memory operatons have never been actually supported. It
was introduced in an attempt to fix umlaeute#67,
VIDIOC_G/S_PRIORITY test failures reported by v4l2-compliance, but
VIDIOC_G/S_PRIORITY is an exclusive feature when V4L2 file handle
framework is used, and this was certainly not the case until
umlaeute#345 that brought in v4l2_fh for V4L2 Event API
support.

This change removes all declarations of M2M support.

Signed-off-by: You-Sheng Yang <vicamo@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants