I have 6 WinTV HVR-1950 Model Category 751xx usb devices attached to one MythBuntu box recording 6 composite audio/video feeds from 6 security cameras.
Whenever the machine reboots the usb devices are assigned their device filename in non-repeatable and not well defined order so that each time /dev/video0 will probably be a different device.
So I knew that udev rules should solve the problem. At present, there are no attributes defined for these devices that can be used in a udev rules, but the driver does create a lot of useful information in files under /sys/class/pvrusb2/.
I first tried using the rules and script found on this page: http://www.isely.net/pvrusb2/utils.html
But they did not work. After several hours of troubleshooting and with some help, I finally found out the reason why: the /sys/class/pvrusb2/ folder and files are not yet available at the time that the udev rule is executing the program script.
To solve this problem, I’ve rewritten the script so that it will wait up to 15 seconds until these sys files are available, and then using the information, properly link each /dev/videoX device to a /dev/video_sn-XXXXXXX using the serial number of that device.
Then in MythTV I am able to use the /dev/video_sn-XXXXXXX filename which will be the exact same physical device every time.
I tried using the WAIT_FOR_SYSFS and WAIT_FOR keys in the rules file, but it also did not work for me.
If you find this information useful you might also find a useful ad on my site and click to read more about it.
Here are the files that work for me:
/etc/udev/rules.d/99-hvr1950.rules
KERNEL=="video[0-9]*", PROGRAM="/usr/bin/udev-hvr-1950.sh %m", SYMLINK+="video_%c", OWNER="mythtv", GROUP="mythtv"
/usr/bin/udev-hvr-1950.sh
#!/bin/bash
# author: Steve Gudmundson
pvrusb2=/sys/class/pvrusb2
search=$pvrusb2/sn-*
timeout=15
# find the serial number for this device #
count_seconds=0
minor_num=-1
until [ $count_seconds -gt $timeout ]
do
sleep 1
count_seconds=`expr $count_seconds + 1`
for file in $search
do
minor_num=`cat $file/v4l_minor_number`
if [ $minor_num -eq $1 ]
then
serial_num=”${file//$pvrusb2\//}”
echo $serial_num
exit 0
fi
done
done
echo unknown_$1
exit 0