TV Out Joy!

Mon, Mar 7, 2005 with tags mythtv

I’ve had my MGA G400-MAX dual head video card since I built my current desktop computer back in April of 2000. I’ve used the second head for xinerama and dual monitor work in the past, it always worked pretty nicely. I sold the second monitor last year after I got my laptop. I figured I might as well get the second head to output on the TV.

Using the drivers provided by Matrox I was able to get the second head to output to the TV, but I couldn’t get XV accelerated video. This left me very sad as it meant that I there wasn’t any chance of me getting MythTV running on the TV. Well, today I finally fixed that problem. Yay!

I utilized the nice G400 TVOut HowTo from Thomasvs to get going. Amazingly, almost everything was easily installed from apt. The kernel already had all of the modules compiled, so that was no problem. fbset was installed via apt. I needed to go visit the debian matroxset packages. On Ubuntu these installed without any problem.

The next thing I did was to make the system load the appropriate modules at run time. So I added the following lines to my /etc/modules file, which autoloads modules at system boot time.

    # needed for doing TVOut
    mga
    i2c_matroxfb
    matroxfb_crtc2
    matroxfb_maven

The next step was to create a startup script. I’ve pasted that below. Save this as /etc/init.d/matroxTVOut.

:::bash
#!/bin/sh

. /lib/lsb/init-functions
. /etc/default/rcS

MATROXSET=/usr/bin/matroxset
FBSET=/usr/sbin/fbset
FBDEV=/dev/fb0
FBDEV2=/dev/fb1

# test to ensure that the proper tools are present
echo "Testing for matrox set"
test -f $MATROXSET || exit 0
echo "Testing for fbset"
test -f $FBSET || exit 0
echo "Testing for fbdev"
test -c $FBDEV || exit 0
echo "everything seems to be present"

case "$1" in
        start)
                log_begin_msg "Initializing Matrox TV out..."
                $MATROXSET -f $FBDEV -m 0
                $MATROXSET -f $FBDEV -m 3
                $MATROXSET -f $FBDEV -o 1 2
                $FBSET -fb $FBDEV -xres 800 -yres 600
                $FBSET -fb $FBDEV -left 54 -right 26 -lower 32 -upper 80 -hslen 40
                log_end_msg $?
                ;;
        stop)
                log_begin_msg "Stopping Matrox TV out..."
                $MATROXSET -f $FBDEV -m 0
                $MATROXSET -f $FBDEV2 -m 0
                $MATROXSET -f $FBDEV -m 1
                $FBSET -fb $FBDEV -left 0 -right 0 -lower 0 -upper 0
                log_end_msg $?
                ;;
        *)
                log_success_msg "Usage: matroxTVOut {start|stop}"
                exit 1
                ;;
esac

And you’ll need to add this your default startup scripts using update-rc.d. We’re almost there, the final step is to setup X11 so we can run it on the framebuffer device. The default Ubuntu setup is basically right, but we need to make some changes. We need to change the device setting.

Section "Device"
        Identifier      "Matrox Graphics, Inc. MGA G400 AGP"
        Driver          "mga"
        BusID           "PCI:1:0:0"
        Option          "hw cursor" "off"
        Option          "UseFBDev" "on"
EndSection

And the last little touch is to setup the output resolution in X11. This little snippet should take care of it for you.

Section "Screen"
        Identifier      "Default Screen"
        Device          "Matrox Graphics, Inc. MGA G400 AGP"
        Monitor         "AccuSync 95F"
        DefaultDepth    16
        DefaultFbBPP    16
        SubSection "Display"
                Depth 16
                Modes "800x600"
        EndSubSection
EndSection

And voila. We should have everything setup to make X11 run at 800x600 mode with output on both the monitor and the TV. You’ll want to look at Thomasvs' howto for more information on what I did with fbset.

MythTV TV Out Goodness

MythTV TV Out Goodness

MythTV Showing TV Out

MythTV Showing TV Out