Force DVB Card Order

From MythTV Official Wiki
Revision as of 20:46, 24 January 2010 by Alexp789 (talk | contribs) (Created page with '== Forcing DVB Card Order == '''Background''' I built a system with two Hauppauge PCI DVB Cards, another Hauppauge PCI DVB Card (but is actually a USB Tuner) and a Hauppauge DVB…')

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Forcing DVB Card Order

Background

I built a system with two Hauppauge PCI DVB Cards, another Hauppauge PCI DVB Card (but is actually a USB Tuner) and a Hauppauge DVB-S2 card.... However these cards would appear on different '/dev/dvb/adapters' on each reboot, so I wrote this script. Note: I know this should be done with udev, however I couldn't get this to work correctly:

#!/bin/bash
#changed for 2x usb 1x pci 1x sat
#changed for 2x usb 2x pci 1x sat
usbcount=0
pcicount=2
satcount=4
for x in 0 1 2 3
do
        if [ -d /dev/dvb/adapter$x ]
        then
                mv /dev/dvb/adapter$x /dev/dvb/rawadapter$x
        fi
done
rm -f /dev/dvb/adapter?
for card in `find "/sys/devices/pci0000:00/" -iname "*frontend0" -printf "%p\n"`
do
        #echo "$card"
        if  "$card" == *usb* 
        then
                echo -en "Processing USB Card:\t"
                id=${card: -11:1}
                ln -s /dev/dvb/rawadapter${id} /dev/dvb/adapter${usbcount}
                echo -en "adapter${usbcount} - usb\n"
                let usbcount=$usbcount+1
        elif  grep ${card: 42:5}|wc -l` == 4 
        then
                echo -en "Processing Sat Card:\t"
                id=${card: -11:1}
                ln -s /dev/dvb/rawadapter${id} /dev/dvb/adapter${satcount}
                echo -en "adapter${satcount} - sat\n"
                let satcount=$satcount+1
        else
                echo -en "Processing PCI Card:\t"
                id=${card: -11:1}
                ln -s /dev/dvb/rawadapter${id} /dev/dvb/adapter${pcicount}
                echo -en "adapter${pcicount} - pci\n"
                let pcicount=$pcicount+1
        fi
done

The above script basically renames the 'adapter' devices to 'rawadapter', then creates symlinks to them, ensuring the 'order' of the symlinks is consistent.... So the usb cards are 0-1, pci 2-3 and Satellite 4.

Note the most upto date version of this script will be maintained on this page, and at [1]