Fedora Video Devices Changing Every re-boot

Post date: Nov 9, 2008 11:46:49 PM

Every time I was re-booting my video devices changed numbers. Not such a big deal unless you run mythtv and Zoneminder on a dedicatred video box with 8 video inputs from various cards. Zoneminder and mythtv kept getting misdirected on every re-boot. It wasn't often so I lived with it for a while.

    • I finally had enough and fixed it by writing some udev rules for the video devices. I used the following email ( http://www.mythtv.org/pipermail/mythtv-users/2006-November/157481.html ) as a guide. It uses a small script (see the right text box) that figures out the varying number to append to the device and the actual udev rules in the /etc/udev/rules.d directory to recognize my different cards and link them to a static name that never changes after a re-boot.I have 4 video cards Hauppauge pvr-350 (1 input mpg encoding input port and 1 mpg decoder output port),
    • Hauppauge HVR-1800 (2 ports),
    • BTTV based 4-port video input card,
    • and a USB hauppauge HVR-950 (1 input)
    1. So there is lots of devices that show up! There were a couple of important things to get right for this all to work correctly.identifying the devices correctly and getting that into the udev rules
    2. numbering the udev rules correctly so they get run in a consistant order.

v4ldev_namer script

#!/bin/bash

# http://www.mythtv.org/pipermail/mythtv-users/2006-November/157481.html

# video device namer app called from the udev rules in /etc/udev/rules.d

# Use udevinfo -a -p /class/video4linux/videoN replace N with the vid number you want info on

# this script requires 1 passed string that specifies the base link name to use

files=`ls -1 /dev/${1}* 2>/dev/null`

for i in $files

do

devnbr=${i##/dev/${1}}

done

if [ -z $devnbr ]; then

devnbr=0

else

devnbr=$((devnbr+1))

fi

echo ${1}${devnbr}

Getting the udev device details use the command: #udevinfo -a -p /class/video4linux/videoN

replace N with the vid number you want info on

This gives you all the details to use in the udev rules to specifically recognize the individual cards.

Once the cards are recognized by the rule, the rule calls the script in the box above to create the symblic link.

Here are my 4 udev rules I added to my /etc/udev/rules.d directory.

Note the filename numbering... They are run in sequential order.

30-ivtv.rules

KERNEL=="video?", ATTR{name}=="ivtv? encoder MPG", ATTRS{vendor}=="0x4444", PROGRAM="/usr/local/bin/v4ldev_namer ivtv", SYMLINK+="%c"

KERNEL=="video??", ATTR{name}=="ivtv? encoder YUV", ATTRS{vendor}=="0x4444", PROGRAM="/usr/local/bin/v4ldev_namer ivtvEncYUV", SYMLINK+="%c"

KERNEL=="video??", ATTR{name}=="ivtv? decoder MPG", ATTRS{vendor}=="0x4444", PROGRAM="/usr/local/bin/v4ldev_namer ivtvDec", SYMLINK+="%c"

KERNEL=="video??", ATTR{name}=="ivtv? decoder YUV", ATTRS{vendor}=="0x4444", PROGRAM="/usr/local/bin/v4ldev_namer ivtvDecYUV", SYMLINK+="%c"

KERNEL=="vbi?", ATTR{name}=="ivtv? encoder VBI", ATTRS{vendor}=="0x4444", PROGRAM="/usr/local/bin/v4ldev_namer ivtvVbi", SYMLINK+="%c"

KERNEL=="vbi?", ATTR{name}=="ivtv? decoder VBI", ATTRS{vendor}=="0x4444", PROGRAM="/usr/local/bin/v4ldev_namer ivtvVbiDec", SYMLINK+="%c"

KERNEL=="vbi??", ATTR{name}=="ivtv? decoder VOUT", ATTRS{vendor}=="0x4444", PROGRAM="/usr/local/bin/v4ldev_namer ivtvVbiVout", SYMLINK+="%c"

KERNEL=="radio?", ATTR{name}=="ivtv? encoder radio", ATTRS{vendor}=="0x4444", PROGRAM="/usr/local/bin/v4ldev_namer ivtvRadio", SYMLINK+="%c"

KERNEL=="audio?", ATTR{name}=="ivtv? encoder VBI", ATTRS{vendor}=="0x4444", PROGRAM="/usr/local/bin/v4ldev_namer ivtvAudio", SYMLINK+="%c"

31-bttv.rules

KERNEL=="video?", DRIVERS=="bttv", ATTR{name}=="BT878 video (ProVideo PV150)", PROGRAM="/usr/local/bin/v4ldev_namer bttv_vid", SYMLINK+="%c"

KERNEL=="vbi?", DRIVERS=="bttv", ATTR{name}=="BT878 vbi (ProVideo PV150)", PROGRAM="/usr/local/bin/v4ldev_namer bttv_vbi", SYMLINK+="%c"

KERNEL=="audio?", DRIVERS=="Bt87x", PROGRAM="/usr/local/bin/v4ldev_namer bttv_aud", SYMLINK+="%c"

KERNEL=="dsp?", DRIVERS=="Bt87x", PROGRAM="/usr/local/bin/v4ldev_namer bttv_dsp", SYMLINK+="%c"

32-uvc.rules

KERNEL=="video?", ATTR{name}=="em28xx #0 video", ATTRS{idVendor}=="2040", PROGRAM="/usr/local/bin/v4ldev_namer usbVid", SYMLINK+="%c"

KERNEL=="vbi?", ATTR{name}=="em28xx #0 vbi", ATTRS{serial}=="4027620474", PROGRAM="/usr/local/bin/v4ldev_namer usbVbi", SYMLINK+="%c"

33-cx23885.rules

KERNEL=="video?", DRIVERS=="cx23885", PROGRAM="/usr/local/bin/v4ldev_namer hvrVid", SYMLINK+="%c"

KERNEL=="video?", DRIVERS=="cx23885", PROGRAM="/usr/local/bin/v4ldev_namer hvrVid", SYMLINK+="%c"

Magically this results in my video devices showing up with a static symbolically linked name that mythtv and zoneminder can use every time!

Video Device Links

[root@dvr rules.d]# ls -la /dev/vid* /dev/ivtv* /dev/btt* /dev/hvr* /dev/usbV*

ls: cannot access /dev/usbV*: No such file or directory

lrwxrwxrwx 1 root root 4 2008-11-09 11:16 /dev/bttv_vbi0 -> vbi1

lrwxrwxrwx 1 root root 4 2008-11-09 11:16 /dev/bttv_vbi1 -> vbi2

lrwxrwxrwx 1 root root 4 2008-11-09 11:16 /dev/bttv_vbi2 -> vbi3

lrwxrwxrwx 1 root root 4 2008-11-09 11:16 /dev/bttv_vbi3 -> vbi4

lrwxrwxrwx 1 root root 6 2008-11-09 11:16 /dev/bttv_vid0 -> video1

lrwxrwxrwx 1 root root 6 2008-11-09 11:16 /dev/bttv_vid1 -> video2

lrwxrwxrwx 1 root root 6 2008-11-09 11:16 /dev/bttv_vid2 -> video3

lrwxrwxrwx 1 root root 6 2008-11-09 11:16 /dev/bttv_vid3 -> video4

lrwxrwxrwx 1 root root 6 2008-11-09 11:16 /dev/hvrVid0 -> video6

lrwxrwxrwx 1 root root 6 2008-11-09 11:16 /dev/ivtv0 -> video0

lrwxrwxrwx 1 root root 7 2008-11-09 11:16 /dev/ivtvDec0 -> video16

lrwxrwxrwx 1 root root 7 2008-11-09 11:16 /dev/ivtvDecYUV0 -> video48

lrwxrwxrwx 1 root root 7 2008-11-09 11:16 /dev/ivtvEncYUV0 -> video32

lrwxrwxrwx 1 root root 6 2008-11-09 11:16 /dev/ivtvRadio0 -> radio0

lrwxrwxrwx 1 root root 4 2008-11-09 11:16 /dev/ivtvVbi0 -> vbi0

lrwxrwxrwx 1 root root 4 2008-11-09 11:16 /dev/ivtvVbiDec0 -> vbi8

lrwxrwxrwx 1 root root 5 2008-11-09 11:16 /dev/ivtvVbiVout0 -> vbi16

lrwxrwxrwx 1 root root 6 2008-11-09 11:16 /dev/video -> video0

crw-rw----+ 1 mythtv media 81, 0 2008-11-09 11:16 /dev/video0

crw-rw----+ 1 mythtv media 81, 1 2008-11-09 11:17 /dev/video1

crw-rw----+ 1 mythtv media 81, 16 2008-11-09 11:16 /dev/video16

crw-rw----+ 1 mythtv media 81, 2 2008-11-09 11:16 /dev/video2

crw-rw----+ 1 mythtv media 81, 24 2008-11-09 11:16 /dev/video24

crw-rw----+ 1 mythtv media 81, 3 2008-11-09 11:17 /dev/video3

crw-rw----+ 1 mythtv media 81, 32 2008-11-09 11:16 /dev/video32

crw-rw----+ 1 mythtv media 81, 4 2008-11-09 11:17 /dev/video4

crw-rw----+ 1 mythtv media 81, 48 2008-11-09 11:16 /dev/video48

crw-rw----+ 1 mythtv media 81, 5 2008-11-09 11:16 /dev/video5

crw-rw----+ 1 mythtv media 81, 6 2008-11-09 11:16 /dev/video6

Other web links to help out