jasonwzs
Posts: 8
Joined: Sat Dec 12, 2015 6:34 am

Relationship between UV4L driver and official V4L2 driver

Sat Dec 12, 2015 8:10 pm

What's the relationship between uv4l driver and official v4l2 driver for raspberry pi camera module?
I installed uv4l driver on my raspi and I know there is an official v4l2 driver already bundled with raspbian.
Questions:
1. Will these two drivers loaded automatically when Pi is booted?
2. Which driver will be used if some application calls v4l2 API?
3. Is it possible to enable/disable one of the drivers?
4. raspstill/raspvid etc command lines and PiCamera python module will not use v4l driver, correct?
5. In which case the driver will be used?

Thanks,
Jason

RpiName
Posts: 712
Joined: Sat Jul 06, 2013 3:14 am

Re: Relationship between UV4L driver and official V4L2 drive

Sat Dec 12, 2015 8:36 pm

jasonwzs wrote:What's the relationship between uv4l driver and official v4l2 driver for raspberry pi camera module?
Lot of differences and similarities, but no relationships.
jasonwzs wrote: Questions:
1. Will these two drivers loaded automatically when Pi is booted?
The UV4L driver will be loaded automatically at boot if the uv4l-raspicam-extras package is installed.
jasonwzs wrote: 2. Which driver will be used if some application calls v4l2 API?
It depends on which device node your v4l2 application is accessing. The UV4L driver can be configured to register the first free device node found in the system starting from /dev/video0 on. This should be the default if you have the above package installed.
jasonwzs wrote: 3. Is it possible to enable/disable one of the drivers?
I do not know what you mean by "disable" exactly. You can kill the 'uv4l' system process associated with a given uv4l driver instance at any time, but I don't see any reason to do this if resource consumption is a concern, as memory and CPU usages are basically ~0% when uv4l is idle.

jasonwzs
Posts: 8
Joined: Sat Dec 12, 2015 6:34 am

Re: Relationship between UV4L driver and official V4L2 drive

Sat Dec 12, 2015 9:44 pm

It depends on which device node your v4l2 application is accessing. The UV4L driver can be configured to register the first free device node found in the system starting from /dev/video0 on. This should be the default if you have the above package installed.
So I can use uv4l to register /dev/video0 and use official v4l2 driver to register /dev/video1 but both of these two devices refer to same camera. If the application access /dev/video0 uv4l driver will be used, if the application access /dev/video1, the other driver will be used. Is my understanding correct?

RpiName
Posts: 712
Joined: Sat Jul 06, 2013 3:14 am

Re: Relationship between UV4L driver and official V4L2 drive

Sat Dec 12, 2015 9:50 pm

jasonwzs wrote:So I can use uv4l to register /dev/video0 and use official v4l2 driver to register /dev/video1 but both of these two devices refer to same camera. If the application access /dev/video0 uv4l driver will be used, if the application access /dev/video1, the other driver will be used. Is my understanding correct?
Correct, but what is the result of accessing both device nodes at the same time or even one at a time is another issue.

jasonwzs
Posts: 8
Joined: Sat Dec 12, 2015 6:34 am

Re: Relationship between UV4L driver and official V4L2 drive

Sat Dec 12, 2015 9:54 pm

The UV4L driver will be loaded automatically at boot if the uv4l-raspicam-extras package is installed.
If uv4l-raspicam-extras package is not installed, but I run the uv4l command like below:
sudo uv4l -nopreview --auto-video_nr --driver raspicam --encoding h264 --width 640 --height 480 --framerate 20 --server-option '--port=9090' --server-option '--max-queued-connections=30' --server-option '--max-streams=25' --server-option '--max-threads=29'
It means the driver will also be loaded, correct?
Is there any command to check if uv4l driver is loaded?

RpiName
Posts: 712
Joined: Sat Jul 06, 2013 3:14 am

Re: Relationship between UV4L driver and official V4L2 drive

Sat Dec 12, 2015 10:09 pm

jasonwzs wrote:If uv4l-raspicam-extras package is not installed, but I run the uv4l command like below:
sudo uv4l -nopreview --auto-video_nr --driver raspicam --encoding h264 --width 640 --height 480 --framerate 20 --server-option '--port=9090' --server-option '--max-queued-connections=30' --server-option '--max-streams=25' --server-option '--max-threads=29'
It means the driver will also be loaded, correct?
Correct, you do not need sudo.
jasonwzs wrote: Is there any command to check if uv4l driver is loaded?
Check the presence of the registered device node, which is a file, or do a pgrep uv4l...just to mention two simple ways.

jasonwzs
Posts: 8
Joined: Sat Dec 12, 2015 6:34 am

Re: Relationship between UV4L driver and official V4L2 drive

Sat Dec 12, 2015 10:10 pm

Thanks for your answer!
Can you also confirm if my understanding below is correct?
4. raspstill/raspvid etc command lines and PiCamera python module will not use v4l driver, correct?

RpiName
Posts: 712
Joined: Sat Jul 06, 2013 3:14 am

Re: Relationship between UV4L driver and official V4L2 drive

Sat Dec 12, 2015 10:14 pm

jasonwzs wrote:Can you also confirm if my understanding below is correct?
4. raspstill/raspvid etc command lines and PiCamera python module will not use v4l driver, correct?
I do not know that, sorry.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7021
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Relationship between UV4L driver and official V4L2 drive

Sat Dec 12, 2015 10:23 pm

jasonwzs wrote:Thanks for your answer!
Can you also confirm if my understanding below is correct?
4. raspstill/raspvid etc command lines and PiCamera python module will not use v4l driver, correct?
They don't. They use MMAL to talk direct to the Gpu services.

In answer to the question of what happens if more than one device is attempted to be opened at once, generally speaking whichever is opened first will get the camera. Subsequent attempts will get an error that the client app may or may not handle well. Raspistill/vid will release the camera immediately on exit, as will the official driver on stopping all streams. I don't know on uv4l2 as to when it will release the camera.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

jasonwzs
Posts: 8
Joined: Sat Dec 12, 2015 6:34 am

Re: Relationship between UV4L driver and official V4L2 drive

Mon Dec 14, 2015 3:56 am

Thanks for your explaining!

wenboown
Posts: 2
Joined: Mon Aug 20, 2018 2:54 pm

Re: Relationship between UV4L driver and official V4L2 drive

Sun Jun 23, 2019 5:01 pm

jasonwzs wrote:
Sat Dec 12, 2015 9:44 pm
So I can use uv4l to register /dev/video0 and use official v4l2 driver to register /dev/video1 but both of these two devices refer to same camera.
Hi Jasonwzs,

Can you elaborate how to register video0 with uv4l and video1 with v4l2? I tried to do something similar but failed. Thank you very much!

Return to “Camera board”