Building a Linux PVR

From BB-ZONE

A little writeup on my experiences building a Linux based video recorder. I'll try to keep this up-to-date as I go along and hopefuly resolve the last remaining issues.


Contents

Why?

Well, why not. I had this idea for quite a while and one day at lunch we came to talk about stock digital recorders vs VIA EPIA board based home grown solutions.

This inspired me to check out MythTV once again and get an impression how the software side is coming along. I have to admit I was very impressed. Last time I tried MythTV it I got almost nothing to work. This time I didn't have any trouble setting it up and using features like timeshift, Electronic Program Guide, playback on remote machines, etc. After having it on my desktop, the urge grew to get it in the living room on some kind of dedicated hardware. A perfect project for the Xmas vacation.

The next step was too look for some hardware...

Hardware selection

Selecting the right hardware took me much longer than I liked. While I usually assemble my computers myself, I don't enjoy surfing the Web for parts, checking out specs, looking for drivers, and finding the best price too much.

Linux support a MUST

There is no way I run anything but Linux on my machines. So the hardware must be supported by my favorite OS. No way around it. Noise level as low as possible

As this device is supposed to end up in my living room, is can't be noisy. The two main components adding to the noise level are fans and hard drives. While you can build a fan less system, I doubt that the computing power of these devices is quite what I need. As you will see, i ended up with one 8cm fan which runs very slowly most of the time. Small form factor

I want to set this up in my living room. So all of the usual PC form factors are not suitable. It has to be small and fit into the rack under the TV. Shopping list So here is what I ended up with:

  • Shuttle ST62K Barebone
    This seemed a good compromise between horsepower and noise. Shuttle's Heat-pipe technology got good reviews and there is a wide range of CPU's to select from for this board. The box is small and not too ugly. The only backdrop is the ATI video chipset. This will force me into using a binary only driver and deal with all the hazzle involved.
  • Intel Celeron 2,4 GHz, 512MB DDR40 RAM
    Don't need a P4 to watch TV and 512MB should be plenty for this use.
  • SEAGATE ST3160023A - 160GB
    Seagate advertises 'Best combination of performance, acoustics and robustness', that's what I'm looking for -- I guess..
  • TEAC DV-516E DVD-ROM
    Just some DVD drive...
  • Terratec Cinergy 400TV
    This is the TV card I have in my desktop. I know it works, it's cheap, so why not get it again. I thought about getting a Hauppauge PVR 350 with hardware mpeg. but it's more than 3 times the price and Linux support is still shaky. So I opted for what I knew and got the Terratec card.
  • D-Link DWL-122 Air 11Mbit WLAN USB Adapter
    This was a tricky choice. I would rather used a 802.11g adapter. But according to our mobile team (yes, it pays off to work for SuSE :) there are no 802.11g USB adapter supported by Linux yet. So I got the cheapest 802.11b and will upgrade as soon as a better one becomes available. It has to be USB, as the only PCI slot of the Shuttle is already used by the TV card.
  • USB Sound Blaster Live! 24-bit External
    After I realized that the onboard ATI IXP audio doesn't work as I hoped (more here) I got this USB audio adapter. I hope this is only a temporary solution until a better driver is available.

Assembly

The long awaited day came and the hardware arrived. Putting the part together shouldn't present a problem for anyone who isn't afraid to use a screwdriver and has some confidence in using this tool. The toughest part was putting getting the TV card in it's PCI slot. The slot space in the rear of the cover is very narrow and the connectors on the card are fairly wide. But with carefully applied force this obstacle can be mastered as well.

One detail I didn't look out for was the audio connector for the TV card. The Terratec Cinergy 400TV doesn't have an on board audio connector, but only a jack at the rear. The Shuttle board's audio in however is on the front. Routing a cable from the rear to the front didn't seem very appealing. So I custom made a cable to plug into the mainboards onboard audio connector, route it thour a hole in the back of the case outside and connect it to the rear jack of the TV card. This way I don't need to have any cables in the front of the case. First boot and installing Linux

After all the parts whereassembled, I hooked my old 9 Inch Monitor up, connected a USB keyboard and mouse and powered the box up. It all looked good until I noticed that the keyboard didn't respond. OK, so I did the initial BIOS setup using an PS/2 keyboard and tried again with the same result. The board doesn't like USB keyboards.

No big deal I though and went on with the installation. I installed SuSE Linux Professional 9.2 over the network (using an install server and a boot CD). All went fine. Did the usual tunings (DMA for the DVD drive mostly) and tried to set up the USB WLAN card. By now I had the USB keyboard connected again. But something was still weird about USB. In combination with the D-Link USB adapter I got strange results. Sometimes it worked, sometimes it didn't. The usual next step is to update the BIOS, which I did. I also got a cheapo wireless keyboard/mouse (PS/2) and this together with the BIOS update made the WLAN card work reliably. Not an optimal solution. But having a wireless keyboard hooked up and stowed away in some drawer may prove beneficial later on anyway. There are only so many things you can do with a remote...

The next speed bump I hit was the X server. To get the TV out working I need to use the binary only driver ATI supplies. After struggling to get it to work I read that X.org's version 6.8 is not (yet?) supported by this driver. This however is what comes with SuSE's 9.2. After an unsuccessful attempt to build X.org 6.7 I decided to install SuSE 9.1 instead. There is nothing in 9.2 that I need that's not in 9.1 as well.

The 9.1 installation went well. I decided to use the 2.6.8 kernel (SuSE 9.2) instead of the slightly older 2.6.5 that ships with 9.1. Having recent drivers can't be a bad thing. XWindow and TV out

Back to the XFree configuration. SuSE 9.1 includes XFree 4.3.99, ATI's driver should work with this release. And it does. Well, kind of. After spending some time with the latest release and not getting the results I wanted. I started browsing the web and found Paul Eggleton's Shuttle ST62K + Linux page. He has similar issues with ATI's driver, but seems to have a working setup. So I took his advise and used the 3.12.0 version of ATI's driver and applied the binary patch he describes (change /usr/X11R6/lib/modules/drivers/fglrx_drv.o at locations 13B2F and 13BE4 from 2C to 19). And finally I got a good quality image on TV out. I tried to get TV and VGA working in parallel but didn't succeed. Where you get a picture seems to depend on what is connected at power up. I gave up pretty quickly as there wont be an CRT connected anyway. Here is the XF86Config file I use.

Add-On Software

Well, the most important software isobviously MythTV. It has some reprequisits however which SuSE doesn't ship. Most of them you at PackMan's Links2Linux.de, some you have to build yourself. I got everything needed and continued to set up MythTV. There were no problems worth mentioning. What helped is that hit the ususal pitfalls when I initially played with it on my desktop machine.

After setting up the frequency table and getting xmltv to fill up the program schedule it was time to hook the Shuttle up to my TV. And what can I say, it works nicely. The quality of the TV out is surprisingly good. I a bit was concerned after the initial test (I connected the Shuttle's TV-Out to the TV-In of my desktop) wasn't all that promising. But the image I get on the TV is more than satisfying.

To have MythTV available right after booting the box, I created a 'special' user, marked it as 'auto-login' and use this .xinitrc for this user. No need for a windowmanager or any additional load to be created, when MythTV is all I want.

One thing I worry about is that I get prebuffering pause errors when watching Live TV and Recordings. There are short interruptions in the stream every few minutes. There a re a few things I didn't try yet to fix this. It's not such a big deal, but it becomes kinda annoying after a while. Sound Quality

What bothers me more than the little skips in the stream is the poor sound quality. As my amplifyer doesn't have inputs for analog surround sound I planed on using the SPDIF out of the on-board sound the Shuttle provides. So far I didn't have any luck getting this to work however.

According to everything I found on his topic it should work, but somehow it doesn't.

Updates

2005-01-05 USB Soundcard as fallback

It seemed like the sound is more of a problem than I initially suspected. Not so much the bad quality and the missing SPDIF out, but the support of the ATI IXP chipset in general. With the help of the MythTV Users mailing list I was able to trace the problem I had with prebuffering pauses and the resulting screen jitter back to the audio driver. It seems like many MythTV users who use the atiixp driver had this problem and the only way to resolve it is to use a different sound card.

Well, with on-board sound and no PCI slot to spare the only option I have is to use a USB sound card. So I purchased a USB Sound Blaster Live! 24-bit External audio adapter, hooked it up to the USB port and use it for playback now. Capture is still done by the ATI on-board audio. SPDIF works fine with the soundblaster card and no jitter, skips or similar disruptions during playback anymore.

I reported the problems with the ATI driver to the developer who wrote the driver (we work for the same company...:). Let's hope this issue can be resolved soon...

2005-01-16 Solved Sound Problems

Thanks to Takashi Iwai the problem with the atiixp module is gone. Updating to ALSA 1.0.8rc2 and applying this patch solved the prebuffering pause errors I was getting. The patch should be part of ALSA 1.0.8. Now I just have to fond a working .asound to get the SPDIF out to work. Remote Control

The remote control that came with the Terratec card worked out of the box, no setup necessary. But it worked differently than I expected. Instead of using lirc, it just shows up as additional keyboard.

While this is kinda nice, it also introduces a more involved setup. To get the keys to do what I want I opted to use a custom Xmodmap mapping the keycode the remote supplies to the keys controlling MythTV the way I like it. I also created a custom keymap for xine (I ditched Mplayer) to go along with it. Both are not perfect yet and I'll have to continue adjusting them. But they do work in most cases.

Open Issues

Here is my list of issues I want to address in the not to distant future:

  • Remote control setup not perfect yet...
  • Get SPDIFout to work on ATI IXP card
  • Get the temperature sensors to work

Useful Links

There are a few non obvious links I found which prooved to be especially helpful:

Feedback appreciated...

If you found this useful, have questions, or even better: answers, please don't hesitate to drop me a note.

Views