Predictable video assignment for HD-PVR using udev
Version 1 (christian, 08/06/2010 06:52 pm)
1 | 1 | h1. Predictable video assignment for HD-PVR using udev |
|
---|---|---|---|
2 | 1 | ||
3 | 1 | If you have more than one HD-PVR on your system then it is possible that they will occasionally swap positions on video0 and video1 after a reboot. The result of course is that then your channel changer will change the channel on one set top box (STB) and you will end up recording on another. |
|
4 | 1 | ||
5 | 1 | In order to prevent this, you can use *udev* rules to force assignment of specific HD_PVRs to specific video devices. |
|
6 | 1 | ||
7 | 1 | First, execute the following: |
|
8 | 1 | <pre>udevadm info -a -p $(udevadm info -q path -n /dev/video0)</pre> |
|
9 | 1 | and look for something like: |
|
10 | 1 | <pre> ATTRS{product}=="Hauppauge HD PVR" |
|
11 | 1 | ATTRS{serial}=="xxxxxxxx"</pre> |
|
12 | 1 | where *xxxxxxxx* is the short form serial number of the HD PVR |
|
13 | 1 | ||
14 | 1 | Alternatively this can be found using: |
|
15 | 1 | <pre>udevadm info --query=all --name=/dev/video0</pre> |
|
16 | 1 | and look for |
|
17 | 1 | <pre>E: ID_SERIAL_SHORT=xxxxxxxx</pre> |
|
18 | 1 | ||
19 | 1 | Next, you need to create a file for udev to execute when an HD-PVR is found. The file should be */etc/udev/rules.d/* and you can call it something like *78-hdpvr.rules*. This file will have the following content with one line for each HD-PVR you have: |
|
20 | 1 | <pre>KERNEL=="video[0-9]*" , ATTRS{product}=="Hauppauge HD PVR" , ATTRS{serial}=="xxxxxxxx" , NAME="v4l/video0", SYMLINK+="video0" |
|
21 | 1 | KERNEL=="video[0-9]*" , ATTRS{product}=="Hauppauge HD PVR" , ATTRS{serial}=="yyyyyyyy" , NAME="v4l/video1", SYMLINK+="video1"</pre> |
|
22 | 1 | where *xxxxxxxx* and *yyyyyyyy* are the values obtained with udevadm. |
|
23 | 1 | ||
24 | 1 | To clarify, this will assign the HD-PVR with the matching serial number to /dev/v4l/videoX and create a symlink in /dev/videoX. The "+=" means preserve any other links created to these devices so be default on our system /dev/video will be the same symlink as /dev/video0. |
|
25 | 1 | ||
26 | 1 | If you want to verify that udev id doing what you want then you can use the following command: |
|
27 | 1 | <pre>udevadm test /class/video4linux/video0</pre> |
|
28 | 1 | substituting the appropriate video identifies (ie. video0 or video1). Read through the resulting output and verify that it executed your command and created the needed links. |