Epiphan framegrabbers stream only once then need unbinding/rebinding to uvcvideo to work again

Bug #1938669 reported by Philip Spencer
8
This bug affects 1 person
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_stop_streaming state that the UVC specification is unclear on how a bulk-based device should be told to stop streaming, so it is reasonable to expect this particular bulk-based device might be expecting the same SET_INTERFACE(0) call that an isochronous device would get as means of being told to stop streaming.

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_start_streaming, but only in the bulk-based case where 0 is the only possible interface value (it won't mess with an isochronous device that might be set to a different interface).

The second hunk modifies the behaviour of uvc_video_stop_streaming to call SET_INTERFACE(0) unconditionally instead of only calling it for isochronous devices. Since interface 0 should already be set on non-isochronous devices, it should be safe to set it again, and this way devices that are expecting it as a signal to stop streaming will get it.

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.kernel.org?

Tags: patch
Revision history for this message
Philip Spencer (philipspencer) wrote :
tags: added: patch
Revision history for this message
Kai-Heng Feng (kaihengfeng) wrote :

If possible, please send the patch to mailing list directly, that's the quickest way to get the patch merged.

Revision history for this message
Philip Spencer (philipspencer) wrote :

Thanks; I have done so, to the uvcvideo maintainer with copies to the media input maintainer, LKML and the linux-media mailing list, as indicated by the get_maintainer.pl script.

Revision history for this message
Ubuntu Kernel Bot (ubuntu-kernel-bot) wrote : Missing required logs.

This bug is missing log files that will aid in diagnosing the problem. While running an Ubuntu kernel (not a mainline or third-party kernel) please enter the following command in a terminal window:

apport-collect 1938669

and then change the status of the bug to 'Confirmed'.

If, due to the nature of the issue you have encountered, you are unable to run this command, please add a comment stating that fact and change the bug status to 'Confirmed'.

This change has been made by an automated script, maintained by the Ubuntu Kernel Team.

Changed in linux (Ubuntu):
status: New → Incomplete
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for linux (Ubuntu) because there has been no activity for 60 days.]

Changed in linux (Ubuntu):
status: Incomplete → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.