Epiphan framegrabbers stream only once then need unbinding/rebinding to uvcvideo to work again
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
linux (Ubuntu) |
Expired
|
Undecided
|
Unassigned |
Bug Description
Video capture devices made by Epiphan Systems (vendor id 0x2b77) work once, but as soon as the video device is closed (or even if it is kept open but the application issues a VIDIOC_STREAMOFF ioctl) it won't work again - subsequent calls to VIDOC_DQBUF simply hang - until the device is unbound from and rebound to the uvcvideo module. (modprobe -r uvcvideo; modprobe uvcvideo also works).
For example:
ffplay /dev/video0 -- works fine and shows the captured stream.
ffplay /dev/video0 -- when run a second time: hangs and does not capture anything
modprobe -r uvcvideo ; modprobe uvcvideo; ffplay /dev/video -- works fine again.
Experimenting with the device and the uvcvideo module source code reveals that problem is the device is expecting SET_INTERFACE(0) to be sent to return it to a state where it can accept control requests and start streaming again.
The code in uvc_video.c has several comments stating that some bulk-transfer devices require a SET_INTERFACE(0) call to be made before any control commands, even though 0 is already the default and only valid interface value. And, the function uvc_video_init makes such a call (which is why the device starts working again after rebinding to the uvcvideo module). But no such call is made when streaming is stopped then restarted.
Furthermore, SET_INTERFACE(0) is the mechanism by which isochronous devices are told to stop streaming, and the comments in uvc_video_
The attached patch fixes the problem for these Epiphan devices by adding a SET_INTERFACE(0) call in two places. Either one by itself is sufficient to resolve the symptoms but I think it is probably safest to include both.
The first hunk adds a SET_INTERFACE(0) call in uvc_video_
The second hunk modifies the behaviour of uvc_video_
The patch is against 5.4.137 in the vanilla kernel.org source tree, but also applies cleanly to the 5.8.63 kernel in Ubuntu 20.4 LTS and to the 5.14-rc3 release candidate kernel.
Since this is clearly an upstream issue unrelated to any vendor modifications, should I also submit an upstream bug report directly to bugzilla.
tags: | added: patch |
If possible, please send the patch to mailing list directly, that's the quickest way to get the patch merged.