You are not logged in.

#1 2013-04-26 12:52:06

Jindur
Member
Registered: 2011-09-29
Posts: 184

udev rules problem (2 webcams, assigning videoX devices)

I've got a built-in webcam (notebook) and an external one connected too, different vendor/product IDs.
I want the built-in cam to be video0 and the external one video1.

I added a file /etc/udev/rules.d/25-name-video-devices.rules containing:

#external cam has ID eb1a:2571
SUBSYSTEM=="video4linux", BUS=="usb", SYSFS{idVendor}=="eb1a", SYSFS{idProduct}=="2571", NAME="video1"
#internal cam has ID 5986:030c
SUBSYSTEM=="video4linux", BUS=="usb", SYSFS{idVendor}=="5986", SYSFS{idProduct}=="030c", NAME="video0"

but it doesn't seem to have effect. After a reboot, the internal cam is now video1 and the external one video0..

any ideas?

Offline

#2 2013-04-26 16:24:48

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: udev rules problem (2 webcams, assigning videoX devices)

SYSFS is deprecated.

Pastebin these somewhere:

udevadm info -a --name /dev/video0
udevadm info -a --name /dev/video1

Edit: This is probably what you want:

SUBSYSTEM=="video4linux", ATTRS{idVendor}=="eb1a", ATTRS{idProduct}=="2571", NAME:="video1"
SUBSYSTEM=="video4linux", ATTRS{idVendor}=="5986", ATTRS{idProduct}=="030c", NAME:="video0"

Edit2: Although, messing with the kernel's own names is inelegant (e.g. a third webcam will play havoc with the names until you write a rule for that too), better with symlinks:

SUBSYSTEM=="video4linux", ATTRS{idVendor}=="eb1a", ATTRS{idProduct}=="2571", SYMLINK+="videoext"
SUBSYSTEM=="video4linux", ATTRS{idVendor}=="5986", ATTRS{idProduct}=="030c", SYMLINK+="videoint"

Yet another edit: Specifying SUBSYSTEM is a bit more elegant than:  KERNEL=="video[0-9]*"

Last edited by brebs (2013-04-26 16:38:24)

Offline

#3 2013-04-27 18:05:05

Jindur
Member
Registered: 2011-09-29
Posts: 184

Re: udev rules problem (2 webcams, assigning videoX devices)

Thanks, the symlink stuff does not work unfortunately. I do get the devices /dev/video0,video1,videoint,videoext listed, but ALL of them give this error in guvcview:

video device: /dev/video1                 <--- replace with 0/int/ext accordingly
ERROR opening V4L2 interface for /dev/video0
ERROR opening V4L2 interface for /dev/video1
unable to detect video devices on your system (0)
ERROR opening V4L interface: Permission denied
Init video returned -1
VIDIOC_REQBUFS - Failed to delete buffers: Inappropriate ioctl for device (errno 25)

I will try the NAME:= instead of SYMLINK+= on next machine reboot.

Offline

#4 2013-04-27 18:13:22

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: udev rules problem (2 webcams, assigning videoX devices)

Jindur wrote:

ERROR opening V4L interface: Permission denied

Well, look at your permissions on /dev/video*, and think about what groups you're in.

Offline

#5 2013-04-27 23:10:17

Jindur
Member
Registered: 2011-09-29
Posts: 184

Re: udev rules problem (2 webcams, assigning videoX devices)

I didn't change any permissions about /dev/vide0 and /dev/video1, and I was able to use them before.
I did a ls -la /dev/video* and noticed that while dev/video0,1 are root:video, the two links are root:root.
I did

sudo chown root:video /dev/videoint

and strangely while midnight commander claims it is root:video a command ls -la will still display them as root:root.
Further although I KNOW that my user is in group video (and I readded him to be safe and opened a new terminal), 'groups' does not list video, lol.
So no matter what, suddenly only my root user can use guvcview /dev/videoXXX, just what is going on here..

$ ls -la /dev/vid*
crw-rw----+ 1 root video 81, 0 Apr 27 19:35 /dev/video0
crw-rw----+ 1 root video 81, 1 Apr 27 19:28 /dev/video1
lrwxrwxrwx  1 root root      6 Apr 27 19:35 /dev/videoext -> video0
lrwxrwxrwx  1 root root      6 Apr 27 19:28 /dev/videoint -> video1

Last edited by Jindur (2013-04-27 23:18:11)

Offline

#6 2013-04-27 23:21:36

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: udev rules problem (2 webcams, assigning videoX devices)

Don't change the permissions of *symlinks* - google it wink

Offline

#7 2013-04-28 00:24:43

Jindur
Member
Registered: 2011-09-29
Posts: 184

Re: udev rules problem (2 webcams, assigning videoX devices)

Ohh, I think I even knew this at some point, but forgot about it ^^.
Well anyway so symlinks aren't the problem. But then why can my user not access the video devices? (Worked before and as I said I didn't change permissions or groups in anyway.)

And why does this happen:

$ groups
lp wheel mail uucp audio storage power users vboxusers bumblebee
$ sudo gpasswd -a jindur video
Adding user jindur to group video
$ bash
$ groups
lp wheel mail uucp audio storage power users vboxusers bumblebee

Where is 'video'?!

Edit:

$ groups jindur
lp wheel mail uucp video audio storage power vboxusers bumblebee users

so I guess just relogging in the terminal doesn't work, I have to relog in X.
But I still wonder why my video devices stopped working although they worked fine before changing the udev rules.

Last edited by Jindur (2013-04-28 00:27:20)

Offline

#8 2013-04-28 00:26:01

skunktrader
Member
From: Brisbane, Australia
Registered: 2010-02-14
Posts: 1,538

Re: udev rules problem (2 webcams, assigning videoX devices)

Jindur wrote:

Where is 'video'?!

You need to login again

Offline

#9 2013-04-28 00:28:47

Jindur
Member
Registered: 2011-09-29
Posts: 184

Re: udev rules problem (2 webcams, assigning videoX devices)

lol, I just clicked on logout as ALWAYS smile it worked a few hours ago and always in before that too, now I just got

Received error while trying to log out:
Could not get owner of name 'org.xfce.SessionManager': no such name

???

Last edited by Jindur (2013-04-28 00:29:08)

Offline

#10 2013-04-28 00:39:45

Jindur
Member
Registered: 2011-09-29
Posts: 184

Re: udev rules problem (2 webcams, assigning videoX devices)

Ok, cameras work now. Wrong order (pretty sure I used the correct tags though :-p) but whatever.
We'll see if the order is persistent after next restart.^^
Thanks

Last edited by Jindur (2013-04-28 00:40:20)

Offline

#11 2013-05-08 09:43:41

Andorinita
Member
Registered: 2013-05-08
Posts: 4

Re: udev rules problem (2 webcams, assigning videoX devices)

Hello, sorry to answer to that post now but I have a similar problem.
I need to use my built-in webcam through Wine, so I made a udev rule :
SUBSYSTEM=="video4linux", ATTRS{idVendor}=="05ca", ATTRS{idProduct}=="180a", SYMLINK+="videoint"
That is in the file named 25-name-video-devices.rules inside /etc/udev/rules.d/

And when I do ls -la /dev/vid* , I get :
crw-rw----+ 1 root video 81, 0 mai    8 11:08 /dev/video0
lrwxrwxrwx  1 root root      6 mai    8 11:08 /dev/videoint -> video0

So it looks like I have the same problem as Jindur, with the permissions. When I try to use the webcam through Wine, it isn't even detected. Jindur, I am not sure how you solved it, but could you please explain it to me?

Thanks a lot !

Offline

#12 2013-05-08 10:42:39

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: udev rules problem (2 webcams, assigning videoX devices)

webcam through Wine

That's not well supported, apparently - see wine wiki.

Looks like, for wine, you should be setting up the group permissions within /dev/bus/usb/ rather than /dev/video*

Offline

#13 2013-05-08 10:57:09

Andorinita
Member
Registered: 2013-05-08
Posts: 4

Re: udev rules problem (2 webcams, assigning videoX devices)

Thanks for your answer!
But since the camera is built-in and not an usb one, do I still need to use /dev/bus/usb?

Last edited by Andorinita (2013-05-08 10:58:38)

Offline

#14 2013-05-08 11:26:28

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: udev rules problem (2 webcams, assigning videoX devices)

Maybe. You tell me - what bus is it using? Probably USB.

Offline

#15 2013-05-09 10:29:43

Andorinita
Member
Registered: 2013-05-08
Posts: 4

Re: udev rules problem (2 webcams, assigning videoX devices)

Sorry for the late reply. It looks like it is using USB indeed, and bus 1 in particular :
lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 002: ID 0bda:0158 Realtek Semiconductor Corp. USB 2.0 multicard reader
Bus 001 Device 003: ID 05ca:180a Ricoh Co., Ltd

How can I change the permissions?

Offline

Board footer

Powered by FluxBB