[mythtv-users] Fedora card detection order

Allen J. Newton anewton at alturia.fleet.org
Wed Aug 23 16:59:23 UTC 2006

Hey!  I finally get to contribute something.

Daniel Agar wrote:
> Subject: Fedora card detection order
> I use fedora core 5 and have 2 x pvr150 and an ati tv wonder
> My modprobe.conf is as follows
> # ivtv modules setup
> alias char-major-81 videodev
> alias char-major-81-0 ivtv
> alias char-major-61 lirc_i2c
> alias char-major-81-1 ivtv
> # bttv
> alias char-major-81-2 bttv
> but the order always seems random, with or without these options. What can
> be done about this?

This was driving me nuts for quite awhile, too.  Nothing I tried from dinking
with modprobe.conf to adding modprobe lines to rc.sysinit would cause the
/dev/videox devices to map the same between reboots.  Frankly, I hope someone
has a better suggestion than I do, because mine is kind of a kludge, but it
solved the problem for me.

I created the attached script to deal with the situation.  What it basically
does is creates symlinks in /dev.  It creates /dev/dvrx (where x is 0, 1, and
so forth) for each /dev/videox device which appears to produce MPEG-2 headers
when read from, and /dev/winTVx for other /dev/videox devices (where "x" is a
single digit) that produce anything (assumed here to be MJPEG/AVI source).  If
the device doesn't produce anything, the script doesn't produce a link to it.

It also handles the /dev/radio, /dev/vbi and /dev/lirc links for my system.
Yours may vary, so please feel free to modify as you need.

Last but not least, what I did was change the devices I use in mythtvsetup
from /dev/video0, etc, to /dev/dvr0 for MPEG-2 devices and /dev/winTV0, etc,
for MJPEG devices.  Now I don't worry about which /dev/videox devices give
what, any more.

The script is called setVideoDevs and should be installed into /etc/init.d/
and is chkconfig-compliant and set to launch before lircd and mythbackend.


Allen J. Newton  (anewton at alturia.fleet.org)
-------------- next part --------------
# Init file to fix /dev/video links
# chkconfig: 2345 85 11
# description: Fix /dev/video links

if ($arg1 ne "start") {

@bytes     0x00, 0x00, 0x01, 0xBA,
    0x44, 0x00, 0x04, 0x00,
    0x04, 0x01, 0x01, 0xD1

$devNum $dvrNum $winTVNum 
foreach $dev (glob "/dev/video?") {
    #print "dev     sysopen (VDEV, $dev, O_RDONLY)
        or die "Could not open $dev: $!";

    $numBytes     #print "read $numBytes bytes\n";

    if ($numBytes = 0) {

    if ($data eq $mpegStr) {
        #print "Found MPEG source!\n";
        unlink "/dev/dvr$dvrNum";
        symlink "$dev", "/dev/dvr$dvrNum";

        #$lircNum         #if ($dvrNum = 0) {
        #    unlink "/dev/lirc";
        #    system("modprobe lirc_i2c");
        #    symlink "/dev/lirc$lircNum", "/dev/lirc";
    } else {
        unlink "/dev/winTV$winTVNum";
        symlink "$dev", "/dev/winTV$winTVNum";
        if ($winTVNum = 0) {
            unlink "/dev/radio";
            symlink "/dev/radio$devNum", "/dev/radio";
            unlink "/dev/vbi";
            symlink "/dev/vbi$devNum", "/dev/vbi";

    close VDEV;
    ++ $devNum;

More information about the mythtv-users mailing list