umlaeute / v4l2loopback

v4l2-loopback device
GNU General Public License v2.0
3.7k stars 527 forks source link

Document the max. number of v4l2loopback devices or how to increase it #367

Open RokerHRO opened 3 years ago

RokerHRO commented 3 years ago

Step 2: Describe your environment

Step 3: Describe the problem:

I tried to load the v4l2loopback kernel module with more than 8 video devices. Only 8 devices are created. No error message is emitted.

dmesg tells:

v4l2loopback: number of devices is limited to: 8

This limit is not mentioned on the v4l2loopback documentation and also whether it is possible to increase that limit and if yes, how to increase it and if there are any disadvantages when set this limit to a far too high number etc.

umlaeute commented 3 years ago

patches welcome

RokerHRO commented 3 years ago

I'd do that if I were sure whether this limit exists in the v4l core itself or only in the v4l2loopback driver or somewhere else and whether it can be raised by simply changing a magic constant somewhere (in the source or can it be changed at runtime?) and what the disadvantages of such a change would be.

But at least tell the users about this limit would be easy for everyone with write access to this project. :-)

umlaeute commented 3 years ago

so far, it's documented in the source-code (only):

https://github.com/umlaeute/v4l2loopback/blob/99cc2968f2f3125ff16f67ff7087d55223433a02/v4l2loopback.c#L183-L191

however, the new dynamic device management kind of obsoletes this, as you can (dynamically) create as many devices as you want to.

e.g. i just created 128 additional loopback devices using:

for i in $(seq 128); do
  v4l2loopback-ctl add
done
umlaeute commented 3 years ago

to answer your question more specifically:

I'd do that if I were sure whether this limit exists in the v4l core itself or only in the v4l2loopback driver or somewhere else and whether it can be raised by simply changing a magic constant somewhere (in the source or can it be changed at runtime?)

there's a hard limitation in the kernel, where the minor device number is an unsigned 8bit value. given that v4l uses a fixed major device numer (81) this forces the maximum number of /dev/video devices to be 256.

and what the disadvantages of such a change would be.

(iirc) the main reason for the hardcoded limit to 8 devices is to prevent the innocent user to shoot themselves in their knees. it probably could be set to the absolute maximum (256) if this is really important. i think that so far most people who need "a lot" of devices also need a way to dynamically allocate (and deallocate) them.

RokerHRO commented 3 years ago

@umlaeute : Thank you for your detailed answers! :-) So now when we have all the necessary information together, where can it be added to the documentation, so other users don't have to dig into the kernel sources (and misinterpreting e.g. the comment above the MAX_DEVICES constant as a hard compile-time constant that cannot be changed without recompilation etc.)?

umlaeute commented 3 years ago

so other users don't have to dig into the kernel sources

well they don't really have to read the kernel source, just the module source. but of course, even that might be too much.

and misinterpreting e.g. the comment above the MAX_DEVICES constant as a hard compile-time constant

not sure i understand that. where do you think there is a misinterpretation?

the MAX_DEVICES is the hard coded maximum of devices that can be created when loading the module. if you want to change that, you indeed need to recompile the module. using dynamic device managment simply bypasses this restriction.