MythTV & WinPVR Howto

Michael Dipper 08.10.2005

Please note that this page hasn't been updated for a while and most probably will show outdated information. It is mainly kept here for reference.

Someadays in 2004 the idea of building up my own, debian based PVR came to my mind. A spare Pentium4 machine and a Hauppauge WinPVR-350 were purchased rather quickly but then the adventure started. I realized that anything can work smooth and perfect but documentation on the web is incredibly distributed.

This page is my personal, small attempt to collect all information to get my special setup easily up and running. Take it as it is and don't ask me for other possible setups :) Of course any feedback on errors or improvements is welcome.

Steps to success

  1. Introduction
  2. Hardware
  3. System preparation
  4. Getting the IR running

Introduction

My system is based on the following hardware components:

Basic System Setup

I assume you are an experienced Debian user and have installed your Debian Sarge system ready to use. There are no special recommendations but a big partition for storing video & audio is a good idea. The minimum Sarge install is absolutely necessary, I will mention all further packages needed.

After finishing the base install, you have to add some additional sources for mythtv and supporting packages to your /etc/apt/sources.list:

# Debian base (use a mirror nearby)
deb http://ftp.de.debian.org/debian/ sarge main
deb-src http://ftp.de.debian.org/debian/ sarge main  
# Security updates 
deb http://security.debian.org/ sarge/updates main  
# 3rd party packages for mythtv 
deb ftp://ftp.nerim.net/debian-marillat/ unstable main 
deb http://dijkstra.csh.rit.edu/~mdz/debian unstable mythtv 
# ???
deb http://www.pcxperience.org/apt/debian stable/
deb-src http://www.pcxperience.org/apt/debian stable/
# 3rd party packages for mplayer\\ 
deb ftp://ftp.nerim.net/debian-marillat/ testing main

First of all and especially before building kernel modules it is a good idea to bring Debian to the latest patch level. Please note that I exclusively use Linux 2.6.

apt-get update apt-get upgrade

Kernel Konfig

Since we have to compile several kernel modules, we need kernel-sources and some tools - please replace the kernel with the latest 2.6 version available as package:

apt-get install kernel-package 
apt-get install kernel-image-2.6.8-2-686 
apt-get install kernel-source-2.6.8 
apt-get install gcc g++ libc6-dev sharutils

Extract the kernel and make some links necessary to build ivtv:

cd /usr/src 
tar xvpjf kernel-source-2.6.8.tar.bz2 
ln -s kernel-source-2.6.8 linux-2.6 
ln -s linux-2.6 linux 
ln -s /usr/src/linux-2.6 /lib/modules/2.6.8-2-686/build

Prepare the kernel to build modules against (we do not have to build a new kernel itselves):

cd /usr/src/linux 
cp /boot/config-2.6.8-2-686 ./.config 
make oldconfig 
make prepare 
echo "-2-686" > .extraversion

Reboot and check that the new kernel is running smooth.

Driver Install

Now we have to install the driver for the WinPVR, called “ivtv”. Please note that there is an “official” but rather old version on Sourceforge which will *not* run with latest WinPVR. Instead use the drivers from the 0.2 or 0.3 series from dl.ivtvdriver.org.

cd /usr/src 
tar xvpzf ivtv-0.3.2a.tar.gz 
cd ivtv-0.3.2a 
cd driver 
make 
make install 
cd ../utils 
make 
make install 
rm /lib/modules/2.6.8-2-686/kernel/drivers/media/video/msp3400.ko

The msp3400 kernel module has to be deleted since ivtv provides its own, improved module.

Additionally you have to extract the IVTV firmware from an official Windows-Driver Package and put the two files to /lib/modules:

root@vcr:/lib/modules 
# -rw-r--r-- 1 root root 262144 Nov 23 21:14   ivtv-fw-dec.bin 
-rw-r--r-- 1 root root 262144 Nov 23 21:14 ivtv-fw-enc.bin

To insure that the ivtv modules are loaded in the correct order and with options set, put these module options to /etc/modprobe.d/ivtv - they apply to my german, model 990 WinPVR:

# Remote 
alias char-major-61 lirc_i2c 
# WinPVR 
alias char-major-81 videodev 
alias char-major-81-0 ivtv 
alias char-major-81-1 bttv 
options ivtv ivtv_std=2 tda9887=0 ivtv_debug=1    
options msp3400 once=1 simple=1 
options tuner pal=1 
install ivtv /sbin/modprobe tuner; /sbin/modprobe msp3400; /sbin/modprobe saa7115; \ /sbin/modprobe saa7127; /sbin/modprobe --ignore-install ivtv; \ /usr/local/bin/ivtvctl -j reg=0x6c,val=0xfa; /sbin/modprobe lirc_i2c; \ /sbin/modprobe ivtv-fb; \ /usr/local/bin/ivtvfbctl /dev/fb0 -noglobalalpha -localalpha

In our case we want to wake up the server using the onboard RTC, so we have to load the appropriate modules rtc and apm. Note that we tweak the system here since genrtc breaks RTC support on latest debian 2.6 kernels, so the following entry in /etc/modprobe.d/rtc simply replaces genrtc by rtc module:

install genrtc /sbin/modprobe rtc

Ensure that the modules get loaded by putting them in /etc/modules:

ivtv nvram apm

Reboot and check if ivtv gets loaded properly and if all hardware ist detected!

Base Install

The next step is to install all the MythTV and associated tools via debian packages. There are some binaries we have to build on our own but this will be described later. We will use KDE as a nifty window manager, since it allows easy implementation of features like password less login, auto login or sound system.

apt-get install x-window-system-core xserver-xfree86 kde kdm mythtv sudo

Relax and get a cup of coffee :)

If the install completes, insure that that there are two users mythtv and mythv-setup sharing the same UID.

mythtv:x:1005:1005::/home/mythtv:/bin/sh   
mythtv-setup:x:1005:1005::/home/mythtv-setup:/bin/sh

Put your mysql access passwords in /etc/mythtv/mysql.txt and make them visible from the mythv user's homedirectories - mysql should have been installed together with myththv:

mkdir /home/mythtv/.mythtv 
cd /home/mythtv/.mythtv 
ln -s /etc/mythtv/mysql.txt 
mkdir /home/mythtv-setup 
cd /home/mythtv-setup 
ln -s ../mythtv/.mythtv

Put an .xsession file in user mythtv's home:

# PAL 
/usr/local/bin/ivtvctl -u 0xff
/usr/local/bin/ivtvctl -f width=720,height=576 
# Tuner 
/usr/local/bin/ivtvctl -p 4 
/usr/local/bin/ivtvctl -j reg=0x6c,val=0xfa
# MythTv 
/usr/local/bin/irxevent & 
/usr/bin/mythfrontend

And the same for user mythtv-setup:

# PAL 
/usr/local/bin/ivtvctl -u 0xff 
/usr/local/bin/ivtvctl -f width=720,height=576 
# Tuner 
/usr/local/bin/ivtvctl -p 4 
/usr/local/bin/ivtvctl -j reg=0x6c,val=0xfa 
# MythTv 
/usr/local/bin/irxevent & 
/usr/bin/mythtv-setup

Now we are actually done and just some finetuning is missing.

Login as mythtv-setup and make your settings, relogin as mythtv and us your new PVR :)

KDE/X11 Konfig

Here are my suggested settings for X11/KDE/MythTV

If I use the PVR or want to avoid shutdown I simply have to login as mythtv.

Note that you must *not* shutdown the computer manually in this setup since MythTV has to set the next RTC-wakeup time prior to shutdown. Instead just go back to the KDE-Login and wait for the automatic shutdown.

To allow MythTV automatic shutdown and setting of the RTC, add the following to /etc/sudoers

mythtv ALL = NOPASSWD: /usr/sbin/nvram-wakeup, /sbin/poweroff

and do the appropriate settings in the setup dialogues using sudo.

IR Remote Control Support

The WinPCR 350, model 990, contains a new infrared unit. It has ??? keys and is silver/grey coloured. Please note that keycodes have changed in opposite to the previous version!

There are two possibilites to route IR commands to MythTV. The first option is to compile IR support directly in mythv. Since I wanted to use the precompiled debian packages I decided to use the second option. A small daemon, called lird, is able to send simulated keystrokes to MythTV.

I have adapted the available configs to suite the new infrared unit, links for downloading lircd.conf and lircrc may be found some lines below.

Currently the lirc driver has to be compiled from source, since available packages don't support the IR port on WinPVR, model 990. You need at least version 0.7.0:

apt-get install dialog 
apt-get install libx11-dev
tar xvpzf lirc-0.7.0.tar.gz 
cd lirc-0.7.0 
./configure --with-x --with-driver=hauppauge
make 
make install 
chgrp mythtv /dev/lircm 
chgrp mythtv /dev/lircd 
chmod g+r,g+w /dev/lircm 
chmod g+r,g+w /dev/lircd

Be sure that the tool “irxevent” gets built and installed in /usr/local/bin - sometimes configure doesn't detect X11 properly!

Sample Configfiles lircd.conf and lircrc may be found here. Place them in /etc.

lircd.conf lircrc

MPlayer

While it is quite easy to record TV shows with MythTV, you need separate tools to play DVDs or any AVI, WMV, … file. I recommend mplayer. Unfortunately you have to compile it on your own, because prebuild packages haven't built in the ivtv MPEG decoder output. Also direct lirc support is very valuable, otherwise you have no way to stop an mplayer once running.

Other Features

Features I am currently working on are integrated DVD-Burning, DVD-Playing or the Web-Frontend. Stay tuned :)

Local Configuration & EPG

My local installation is set up to work in the cable network of Kabel-BW Stuttgart, Germany. EPG may be grabbed from Prisma Online with tv_grab_de_prisma. I prefer this over grabbing from TV Today since the performance seems to be better and changes on the server's HTML structure are more seldom. Latest frequency table and MySQL-Dump of the channel-table suitable for direct import into MythTV is available here.

channel.dmp channel.mysql