Discussion:
[linux-uvc-devel] Using multiple webcams on the 1 USB bus
stuart
2015-12-30 00:46:21 UTC
Permalink
Hi,

I have had a lot of trouble in the past getting multiple webcams to work
on the one USB bus and I believe now that they were bandwidth related.
At present I am mostly using Logitech C270s and they are hopeless at
reporting the USB bandwidth that they need so only one camera will work
on a 480Mbit/s bus at 1280x960 and 10fps.

My testing has shown that a C270 running at 1280x960 produces MJPEGs
200kbytes big so in theory it should only need 10x200000x8 = 16Mbit/s
however it asks for 196Mbit/s.

I looked at the uvcvideo module and there is a quirks=128 module
parameter but is ignored if the stream is MJPEG compressed.

Let me first say that I think what I am proposing is ugly however I
can't think of anything better.

I have modified the uvcvideo module so that I can provide a
"compression" factor to the module through the V4L2 interface. It is a
"hacky" in that I used the priv attribute in the struct v4l2_pix_format
to specify the value. In the module I use the quirks=128 code to
calculate the size of the uncompressed image and then divide by the
compression factor to work out what USB bandwidth to use.

To protect innocent users of the "priv" attribute against an unexpected
"dead" camera I set the top bits of the priv attribute to to 0xfeed000
to identify it as a compression attribute. I did this because I know
nothing about what priv is used for. It seems wrong to put an explicit
attribute into the V4L2 interface but it would make this a lot cleaner.

I store the "bCompression" attribute in struct uvc_streaming structure
because I had trouble working out the lifespan of the other structures
used in the module.

By default I use a compression factor of 10 which allows a large margin
for if the camera encounters a particularly hard image to compress. The
C270 running at 1280x960 and 10fps now uses 41Mbit/s and I can easily
run 4 cameras on one bus.

The uvcvideo code I have attached is from Ubuntu 14.04. I am attaching
the original code and the modified code to allow a "diff -r".

If this proposal is unacceptable then I invite alternative suggestions
and I will look deeper into the uvcvideo code to find better ways of
implementing it if this will help.

Thank you for for this project because it has made so many webcams
usable with Linux.
reik red
2016-01-02 22:10:27 UTC
Permalink
------------------------------------------------------------------------------
Paul Fertser
2016-01-02 22:26:54 UTC
Permalink
Hey,

A bit offtopic but might come useful for the others as well.
AND also a MIPS version for tp-link wdr3600 router with openWRT, specifically
4.8-2014.04 r4
2625) ) #3 Wed Oct 1 14:00:51 CEST 2014
In fact, it should be trivial to add a kernel patch to OpenWrt (this
is the correct spelling btw). Just copy a patch file to
target/linux/generic/patches-3.10 under something like
999-uvc-bandwidth-fix.patch name, then run "make target/linux/clean"
and "make" to build your image.

HTH
--
Be free, use free (http://www.gnu.org/philosophy/free-sw.html) software!
mailto:***@gmail.com

------------------------------------------------------------------------------
stuart
2016-01-08 05:52:23 UTC
Permalink
Hi All,

I have added the compression attribute as a module parameter for cases
where the user has no control over the software making V4L2 calls.

***@gmail.com and I have made the changes to OpenWrt (kernel version
4.1.13) and loaded it onto a TP-Link Wdr3600 router. With
compression=10 the router has had 3*C270 (Logitech) cameras running
simultaneously at 1280x960 and 15fps in MJPG format through a usb 2.0
hub. More are theoretically possible but there are no more cameras
available. The original uvcvideo module supports only one camera in
this mode.

The attached code is what was used for OpenWrt since it is the most
recent kernel that has been modified for testing.

Stuart.
Post by stuart
Hi,
I have had a lot of trouble in the past getting multiple webcams to
work on the one USB bus and I believe now that they were bandwidth
related. At present I am mostly using Logitech C270s and they are
hopeless at reporting the USB bandwidth that they need so only one
camera will work on a 480Mbit/s bus at 1280x960 and 10fps.
My testing has shown that a C270 running at 1280x960 produces MJPEGs
200kbytes big so in theory it should only need 10x200000x8 = 16Mbit/s
however it asks for 196Mbit/s.
I looked at the uvcvideo module and there is a quirks=128 module
parameter but is ignored if the stream is MJPEG compressed.
Let me first say that I think what I am proposing is ugly however I
can't think of anything better.
I have modified the uvcvideo module so that I can provide a
"compression" factor to the module through the V4L2 interface. It is a
"hacky" in that I used the priv attribute in the struct
v4l2_pix_format to specify the value. In the module I use the
quirks=128 code to calculate the size of the uncompressed image and
then divide by the compression factor to work out what USB bandwidth
to use.
To protect innocent users of the "priv" attribute against an
unexpected "dead" camera I set the top bits of the priv attribute to
to 0xfeed000 to identify it as a compression attribute. I did this
because I know nothing about what priv is used for. It seems wrong to
put an explicit attribute into the V4L2 interface but it would make
this a lot cleaner.
I store the "bCompression" attribute in struct uvc_streaming structure
because I had trouble working out the lifespan of the other structures
used in the module.
By default I use a compression factor of 10 which allows a large
margin for if the camera encounters a particularly hard image to
compress. The C270 running at 1280x960 and 10fps now uses 41Mbit/s and
I can easily run 4 cameras on one bus.
The uvcvideo code I have attached is from Ubuntu 14.04. I am
attaching the original code and the modified code to allow a "diff -r".
If this proposal is unacceptable then I invite alternative suggestions
and I will look deeper into the uvcvideo code to find better ways of
implementing it if this will help.
Thank you for for this project because it has made so many webcams
usable with Linux.
------------------------------------------------------------------------------
_______________________________________________
Linux-uvc-devel mailing list
https://lists.sourceforge.net/lists/listinfo/linux-uvc-devel
stuart
2016-01-10 02:21:20 UTC
Permalink
Hi All,

I am resending this email because my first attempt contained plain text
and HTML as an alternative and this somehow made it not viewable in the
mailing list.

In addition to V4L2 support I have added the compression attribute as a
module parameter for cases where the user has no control over the
software making V4L2 calls.

***@gmail.com and I have made the changes to OpenWrt (kernel version
4.1.13) and loaded it onto a TP-Link Wdr3600 router. With
compression=10 the router has had 3*C270 (Logitech) cameras running
simultaneously at 1280x960 and 15fps in MJPG format through a usb 2.0
hub. More are theoretically possible but there are no more cameras
available for testing. The original uvcvideo module supports only
one camera in this mode.

The attached code is what was used for OpenWrt since it is the most
recent kernel that has been modified for testing. I have included
the original and modified code so a "diff -r" will show the changes.

Stuart.

Loading...