Video Digital Recorder: Linux Configuration

Software Setup

Installing Mandrake

The Mandrake install was fairly straight forward. I selected CD boot in the BIOS and I was off. I chose expert mode and went with most of the defaults. For hard disk partitioning, I decided to go with 1.5 Gig for root, 250 Mb for swap, 250 Mb for var, and the rest for home. I wanted to have a relatively svelt system to save as much hard disk for video, so I didn't install anything much besides Gnome. I did select the option for SSH client and server, since I use that for my home network to access machines. I figured if I needed anything else I could install it later.

Compiling The Kernel

Unfortunately, recompiling the kernel is pretty much required to get everything working properly. While none of the Linux drivers or software necessary is unstable, most of it still not polished. In particular, some parts of the kernel need to be compiled as a module instead of into the kernel in order for the Marvel driver to take advantage of them.

I have been using Mandrake a while, and the kernel included with Mandrake 9.0 is the first one that I have actually been able to compile successfully. Good information about compiling the kernel can be found in the included README file, or the HOWTO at http://www.linuxdoc.org/HOWTO/Kernel-HOWTO.html. At the very least you will need to set the code maturity level to allow experimental selections, and compile Video4Linux as a module. So under Multimedia Devices select m for module, then under Video For Linux DO NOT select any support for Zoran devices. Under Character devices for I2C Support select I2C Suppport, Bit Banging, and Device interfaces are compiled into the kernel. Also under character devices, if you have an AGP video card, and you probably do, make sure that is compiled into the kernel as well.

If you plan on using the TV out, then you will also need to compile in support for the framebuffer. Under Console Drivers select frame buffer support, and then all the support you want for your card. The (http://www.linuxdoc.org/HOWTO/Framebuffer-HOWTO.html) framebuffer HOWTO is a little out of date, but it has good information about what you need to compile into the kernel. I never appended a video option in lilo.conf, though. If you plan on using lirc, you may need to either compile serial port support as a module or not at all depending on your hardware. Unfortunately you really can't tell until you compile lirc, but it is easy to recompile the kernel later if you need to.

And in general I turn off everything I'm not using on the general principle that it will improve performance. So I didn't compile in Parallel Port, Multi-Device, Telephony, SCSI, FireWire, I2O, Amatuer Radio, IrDA, ISDN, Old CD-ROM, Input Core, or USB support. My final word about recompiling your kernel is that make sure you ALWAYS have at least one known good kernel setup for lilo: For example never clobber the original setup.

Until Mandrake 9.0 sound was a major issue. Now it is a no brainer. Just use the stock ALSA drivers and you should be fine.

SourceForge Marvel Driver

Luckily video drivers for the Matrox Marvel G200-TV are included in the XFree86 package, but that still leaves drivers for the tuner, MJPEG encoder, and MJPEG decoder. You can get these from the Marvel SourceForge Project at http://marvel.sourceforge.net

It is probably best to grab the latest version from the CVS repository, and there are directions for doing this on the website. The drivers are under constant development, and the folks sometimes wait a while before producing a "stable" release. Frankly I would rather they spend their time as they are. :-)

Downloading, compiling, and installation was fairly straight forward. If you have configured the kernel and kernel modules correctly, adding support for the whole G400-TV card should be as simple as running the update script, which inserts modules into the kernel to drive the tuner and en/decoding.

You might get a warning when running the update script about i2c not existing, and needing to compile VIDEO_ZORAN into the kernel. As I said earlier, Zoran support in the kernel is broken. What you really need to do is run "make i2c-algo-ks.o" in the mgavideo driver directory.

You can tell Linux to load the modules whenever an application needs to use the special hardware, and then unload them when they aren't needed. I actually prefer to create a special init script to load the marvel modules and other VDR related stuff, but if you want to try it, do the following. Copy all the mgavideo modules (*.o) from wherever you compiled them to the directory /lib/modules//misc, where is (surprise, surprise) your kernel version. You may have to create the misc directory. Then open up the file /etc/modules.conf in you favorite text editor and add the following:

alias char-major-81 mgajpg
post-install mgajpg modprobe maven

If your second head is a television instead of a monitor, then replace the post-install line with "options mga_core vdo_enable=0". Finally, run depmod -a and the modules should load automatically whenever you need them and unload themselves after you don't use them a while.

Framebuffer Setup

Unfortunately setting up the framebuffer is a bit of a black art, and what little documentation there is about it is usually not up to date. You will need the utility called matroxset. If you are going to use TV-Out you need the program maven-prog to adjust the brightness. If you plan on running console applications then you need to get the progran con2fb and a file called fb.modes (AKA fb.modes.vesa60.gz) to stick in your /etc directory. The file fb.modes.vesa60.gz and the source code for the two utilities are available at http://knihovny.cvut.cz/ftp/pub/linux/matroxfb-latest/

The first hurdle to get over is compiling the kernel correctly. If you get an error about /dev/fb0 not existing then that is your problem. The next hurdle is the matroxset program itself. It is a wonderful program and the author Petr Vandrovec (VANDROVE@vc.cvut.cz) is a genius, but his documentation is, well, not as great as it could be I guess. :-) Use gunzip to extract the files in matroxset-0.3.tar.gz, run make to create the executable, and then copy it to /usr/local/bin. If the path /usr/local/bin isn't in your path then it needs to be.

Here is the short, short version to set the G400 second head to TV-Out
matroxset -f /dev/fb1 -m 0
matroxset -f /dev/fb0 -m 3
matroxset -o 1 2

Here is the short, short version to set the G200 to TV-Out:
matroxset -f /dev/fb0 -m 2
matroxset -f /dev/fb0 -o 1 2

NOTE: You must do this BEFORE loading the marvel drivers! The space after the switches are very important. The switch to get the usage information is "-help". Be sure to run the matroxset commands before you use mgavideo. In fact, I added them to the end of /etc/rc.d/rc.sysinit. The initial setup XFree86 is surprisingly easy. Just use the regular mga video driver that comes with XFree86 4.0.3, but add the options "usefbdev" and "NoHWcursor". Some video resolutions don't work well on the second head, but most do. The display on the television will probably be squished out of shape, but fixing that will be one of the last things to do. That is because when you fix the television display, your monitor display gets squished. :-)

Here is the short, short version to set the TV-Out brightness and contrast:
/usr/local/bin/matrox 0x1e 0xb0 > /dev/null
/usr/local/bin/matrox 0x20 0xb0 > /dev/null
/usr/local/bin/matrox 0x22 0xb0 > /dev/null

You actually have to edit the matrox.c file and change fb1 to fb0 if you are using a G200. You can fiddle with the second hex value until you are satisfied. I also setuid the executable and insert the lines into my .bash_profile, which creates a nice effect when you log in.

More information on framebuffers can be found at:

http://www.linuxdoc.org/HOWTO/Framebuffer-HOWTO.html
http://alge.anart.no/linux/kernel-docs/fb/matroxfb.txt
http://alge.anart.no/linux/kernel-docs/fb/framebuffer.txt

SourceForge DXR3 Driver

If you are not using a Dxr3 you can skip to the next section. The drivers for the DXR3 and the Hollywood Plus are the same, since they are basically the same card. The DXR3 project HOWTO is very good, so this section will be short. Grab the latest stable version and extract the tarball. I used version 0.7.2. Change to the modules directory and run the make-modules and make-install scripts. Then change to the top directory and run make and make install. Finally, as instructed in the HOWTO, make the nodes in the /dev directory.

The only real problem is that you have to mess with the microcode. First you have get the windows driver, then you have to exctract the microcode, and then you have to uplaod the microcode everytime you load the DXR3 driver. It's not horrible, just a bother. Again, the HOWTO is very good explaining this.

The HOWTO explains how to test the card, but not where to get the test files. The mpg123 program comes with Mandrake. I found two good test files (test.mp3 and test.mpg) at http://fredrik.hubbe.net/plugger/test.html Start up XawTV and set the video source to S-Video. Don't panic if all you see is a big green blob at first. Some of the modules take options, and you will almost definately need to tweak the settings. So have fun going through the cycle of testing, editing the load module script, running the remove module script, running the load module script, and uploading the microcode.

Pretty much the only thing left to do is to copy the modules you need over to where ever you put the Marvel modules. The modules you need are eeprom, adv717x, bt865, and em8300. And don't forget to copy the microcode to the etc directory.

LIRC Server

LIRC is a set of programs that takes input from a remote control and translates it into commands on the computer. I use LIRC to get the Logitech remote control working with the various computer programs, and believe me that using a regular remote control somehow makes the VDR seem much more like an appliance and less like a computer.

The documentation looks outstanding, but I found it a bit frustrating at first because they never bother to explain basic concepts. The short version is that lirc needs a kernel module. The lirc software covers a mind boggling array of hardware, and so the right module could either be the regular kernel support or one of many special lirc modules. There's no way to know in advance until you try to compile lirc and it tells you. Oh, by the way, you need the cdialog package to run the lirc configure script.

One wrong turn I took is that I told lirc that I had hardware that I didn't have, and so it told me I needed the wrong module. My advise to you is to buy cheap IR hardware on Ebay (after checking the lirc website at http://www.lirc.org first, of course) and then dig around when configuring lirc for the right setting. Once you have that, you are over a major hurdle. Whatever you do, unless you are using the lirc_serial module totally ignore anything having to do with the setserial command.

Mandrake 9.0 actually comes with a lirc RPM, but I haven't played with it yet.

XFree86

At this point all of the major hardware should be configured properly, so now it's time to get the television display looking good. As I said before, this will improve the television display at the expense of the monitor display. I spent a lot of time on this. At first I played with using the real FBDev X server instead of the FBDev option in the mga X Server. I played with fb.modes, and combined with the matroxset utility I got very proficient with the dual head setup. However, XawTV does not like the Real FBDev X server.

So it was back to mga X server. There is a nice utility called xvidtune that looks like it would do the trick, but for the longest time it wouldn't let me do what I wanted to do. Finally, I hit upon the answer. I updated the Monitor section with completely ridiculous settings for horizontal sync and vertical refresh: "HorizSync 30-50" and "VertRefresh 50-70". After setting that, xvidtune never complained and I could stretch the screen as much as I wanted. Certain resolutions screws up one or both displays, but xvidtune always returns to the last known good setup. Fair warning, though, that this technique could possibly damage your monitor, especially older monitors.

Once I found the right settings, xvidtune will spit out the correct ModeLine to be added to the Monitor section in XF86Config. I suggest you use a unique name so that later on if you temporarily want to use the monitor you can just add a normal resolution to the Screen section. Here is the modeline I added:

ModeLine "800x600tv" 40.00 800 806 859 918 600 653 657 762 +hsync +vsync

This gives a 800x600, 16 bit color display on the television. A higher resolution display is just as easy to configure, but few televisions are readable at anything higher than 800x600.

BlackBox Window Manager

The BlackBox window manager is a small but poweful window manager. After replacing the standard window manager that comes with Gnome, Sawfish, with BlackBox I noticed immediate improvement. The session started faster, the was a big improvement in memory usage, and a small improvement in CPU usage. BlackBox doesn't have near the bells and whistles as Sawfish, but for this application I don't need them. The BlackBox homepage is http://blackbox.alug.org/

BlackBox is configured with a few text files, and offers a variety style packages to change the appearance. I haven't had a chance to customize BlackBox yet.

Errata

You will probably want to disable the screen saver so that 20 minutes into a movie the screen doesn't go blank. :-) In either the global or personal startup shell script (probably either bashrc or cshrc) include the command "xset s off".

If you plan on getting a VDR application going, then you will probably want to make sure the clock on the VDR is set properly. You can set up a NTP (Network Time Protocol) server, or else you can just use cron and rdate to set the clock periodicaly. I have it set to update the clock once a day in the middle of the night.


Mail James This document was last updated January 18, 2003. James Bearden is not responsible for all information accessible from this web page. Links to the rest of the Internet point to material maintained by many other people and organizations. Please read the following disclaimer before use of this WWW page.