Persistent DVB tuner device names

I’m a user of the excellent MythTV PVR software, and in my system are two tuners: one digital terrestrial and one digital satellite. A problem I had for some time was that their device names under linux were not the same on each boot, so MythTV got very upset and would not record things.

After digging around online for ages I found a document with the trick to keeping persistent device names for tuner cards, which I’m sorry to say I’ve now lost. Here goes, for the sake of Google archiving…

Start with listing the PCI devices to see their Vendor and Bus ID:

oliver@htpc:~$ lspci -nnv
<snipped...>

03:05.0 Multimedia controller [0480]: Philips Semiconductors SAA7146 [1131:7146] (rev 01)
	Subsystem: Technotrend Systemtechnik GmbH S2-3200 [13c2:1019]
	Flags: bus master, medium devsel, latency 64, IRQ 20
	Memory at febffc00 (32-bit, non-prefetchable) [size=512]
	Kernel driver in use: budget_ci dvb
	Kernel modules: budget-ci

03:06.0 Multimedia controller [0480]: Philips Semiconductors SAA7146 [1131:7146] (rev 01)
	Subsystem: Technotrend Systemtechnik GmbH Technotrend-Budget/Hauppauge WinTV-NOVA-T DVB card [13c2:1005]
	Flags: bus master, medium devsel, latency 64, IRQ 21
	Memory at febff800 (32-bit, non-prefetchable) [size=512]
	Kernel driver in use: budget dvb
	Kernel modules: budget

Hopefully there’s enough information for you to tell which card is which, if as like my situation the (highlighted) description lines are almost identical. Above, the terrestrial card is WinTV-NOVA-T and the satellite card is S2-3200.

The pieces of information you want to record for each card are the Bus ID – the number such as 03:05.0 at the start of the highlighted line, and the Vendor ID – the first number before the colon in square brackets such as 1131.

We’re going to use udev rules, but not to set the device names, instead creating alias (or duplicate) names which are used by MythTV configuration.

oliver@htpc:~$ cat /etc/udev/rules.d/15-videosymlinks.rules

SUBSYSTEM=="dvb", ATTRS{vendor}=="0x1131", KERNELS=="0000:03:06.0", PROGRAM="/bin/sh -c 'K=%k; K=$${K#dvb}; printf dvb/adapter101/%%s $${K#*.}'", SYMLINK+="%c"
SUBSYSTEM=="dvb", ATTRS{vendor}=="0x1131", KERNELS=="0000:03:05.0", PROGRAM="/bin/sh -c 'K=%k; K=$${K#dvb}; printf dvb/adapter102/%%s $${K#*.}'", SYMLINK+="%c"

I’ve identified the cards by matching both their Vendor ID (note it’s Hex so prefixed with 0x) and Bus ID, and chosen names adapter101 and adapter102 (scroll to the right to see). The high numbers are because, as I explained, the original device names are still present:

oliver@htpc:~$ ls -1 /dev/dvb/
adapter0
adapter1
adapter101
adapter102

Within these alias device directories are in fact symlinks (automatically created!) to the correct card device data, whatever its name happens to be on this boot:

oliver@htpc:~$ ll /dev/dvb/adapter101/
total 0
drwxr-xr-x 2 root root 120 2010-12-12 13:03 ./
drwxr-xr-x 6 root root 120 2010-12-12 13:03 ../
lrwxrwxrwx 1 root root  18 2010-12-12 13:03 demux0 -> ../adapter0/demux0
lrwxrwxrwx 1 root root  16 2010-12-12 13:03 dvr0 -> ../adapter0/dvr0
lrwxrwxrwx 1 root root  21 2010-12-12 13:03 frontend0 -> ../adapter0/frontend0
lrwxrwxrwx 1 root root  16 2010-12-12 13:03 net0 -> ../adapter0/net0

When configuring MythTV use the new alias names and this problem is solved.

This entry was posted in htpc, linux. Bookmark the permalink.

Comments are closed.