Introduction

This guide explains how I turned a via epia MII C3 - ML eden, with a Hauppauge PVR 350 TV tuner card, into a Kubuntu-based MythTV box to watch and record TV shows, and even pause live TV. It automatically downloads the most recent TV guide every night to keep the system up to date. For the software installation I used as many standard Kubuntu and Debian packages as possible, but still it took me quite a while to get everything up and running, so I decided to share my experiences on this page. I started from a standard Kubuntu installation (this guide explains the MythTV installation for both Kubuntu Dapper and Kubuntu Edgy), added the Ivtv drivers for the Hauppauge PVR 350, got the remote control working and installed MythTV. I hope you find this information useful. All feedback/additions on this document are very welcome!

Specifications

  • Now: Via Epia ML eden
  • Before: Via Epia MII C3
  • 512 MB Ram
  • 160 GB hard disk
  • DVD/RW
  • Silverstone Case
  • Hauppauge PVR 350 TV tuner card
  • Silverstone Case
    Epia ML
    PVR 350

    Install Kubuntu Dapper/Edgy

    This is the easy part: just download a Kubuntu Dapper or Edgy install CD from the Kubuntu download page (I would recomment Edgy), and install your desktop environment. Everything should work out just fine here. I choose Kubuntu instead of something like KnopMyth because I didn't only want a MythTV box, but I also wanted to use my Via Epia as a regular PC for email, internet, etc. The cool thing is you can use both the TV function and the PC function simultaneously! So I can be watching TV and change channels with the remote, while my girlfriend is working on some office document using the mouse and keyboard.

    The following two sections only for the via epia MII, which has quite some issues with DMA and freezing. When you're not using the Via Epia MII, everything should just work after the default installation, and you can move on to installing the Ivtv driver for the PVR 350 tuner card.

    Solve via epia MII DMA problem

    With the default Kubuntu kernel I ran into a DMA problem on the MII c3 (that I why I sold my Via Epia MII C3 and bought a Via Epia ML eden. When your board suffers from this problem, you'll see the following lines in your log file:

    /var/log/dmesg

    ...
    hda: DMA timeout retry
    hda: timeout waiting for DMA

    I solved this by compiling my own kernel, where I selected the via C3-2 (Nehemaih) architecture instead of the i386 architecture in the default kernel. Here's how I did this:
    First download the kernel sources:

    sudo apt-get install linux-source-2.6.xx

    This copies a tarred kernel in /usr/src/. Untar the kernel:

    tar xvfj linux-source-2.6.xx.tar.bz2

    Go into the new directory, and copy the configuration file from your percompiled kernel into this directory.

    cd linux-source-2.6.xx
    cp /boot/config-2.6.xx-yy-386 .config

    and change your configuration:

    make menuconfig

    Here you select the via C3-2 (Nehemaih) architecture instead of the i386 architecture. Exit the menu and run:

    make
    make-kpkg kernel_image --initrd

    And finally install the debian package it generated:

    sudo dpkg -i linux-image-2.6.xx.deb

    and you're ready to go without the DMA problems.

    Solve via epia MII freezing/crashing problem

    Lots of people found their via epia MII suddenly freeze, especially while under heavy hard disk load. According to Via this also is a DMA problem. This issue can be completely fixed on the via epia M series, but not on the via epia MII series. After the fix my system didn't freeze for quite a while. But, the problem came back... If you still want to try the fix, there are two things you need to do. First you need to disable frequency scaling in your kernel. This is similar to what's explained in solving the DMA problem. Next, you'll need to update your BIOS. Therefore you first download the newest BIOS version for the via epia M series or for the via epia MII series or the via epia CF series. To load the new BIOS, you can find detailed instructions here. You'll need the latest version of LinuxBIOS to load the new BIOS into the flash memory:

    ./flash_rom -w dmatest_epiam2.bin

    After loading the flash, just reboot, and you should be running without the lockups.


    Update April 12 2006:

    The lockups came back anyway... I was so tired of all the problems related to the MII series (DMA and lockups) and got myself a via epia ML eden fanless board. It works perfectly silent and stays very cool. And, it's hardly noticeable that the processor is less powerful. It's the ideal TV box in my opinion!

    Ivtv driver

    The PVR 350 is a very nice TV tuner card, with a hardware MPEG2 encoder and decoder. So instead of running plugging your TV cable straight to your TV, you plug it into the PVR card, and attach the TV out of the PVR card to your TV. The PVR card will encode any TV channel on the fly into a MPEG2 stream and send it to your computer. The only thing your computer needs to do is to buffer the MPEG2 stream, and send it back to the PVR card to view it on your TV. In this way you can basically use any old computer as your MythTV box. I choose a small and silent via epia MII (can you run MythTV on a via epia?)

    Make ivtv modules

    Ivtv is an open source implementation of the drivers you need for the PVR card. To install the ivtv drivers, you first need to remove a few kernel modules that ivtv provides but that are also included in the Kubuntu Dapper kernel (when using Kubuntu Edgy, you should skip this step):

    cd /lib/modules/2.6.15-22-386/kernel/drivers/
    rm media/video/msp3400.ko
    rm media/video/tda9887.ko
    rm media/video/tuner.ko
    rm media/video/tveeprom.ko

    Then download the ivtv sources here into /usr/src/ and untar. For Dapper use version 0.4, and for Edgy version 0.7
    Go to folder /usr/src/ivtv/drivers and

    make
    make install

    Now update your module list:

    update-modules

    Load modules at boottime

    In /etc/modules you need to add the following lines:

    /etc/modules

    # TV
    ir-kbd-i2c
    evdev
    tda9887
    ivtv
    ivtv-fb
    lirc_i2c

    in /etc/modprobe.d/options you add the following options (when using Kubuntu Edgy, you should skip this step):

    /etc/modprobe.d/options

    # ivtv
    options ivtv-fb ivtv_fb_card_id=0
    options ivtv ivtv_std=2 tda9887=0
    options tda9887 pal=B

    and in /etc/modutils/ivtv you need to add this:

    /etc/modutils/ivtv

    alias char-major-81 videodev
    alias char-major-81-0 ivtv
    alias char-major-61
    lirc_i2c

    Load the PVR Firmware

    Using ivtv 0.4.4 and higher, loading the firmware just got a whole lot easier. You need to put the files v4l-cx2341x-dec.fw, v4l-cx2341x-enc.fw and v4l-cx2341x-init.mpg in your /lib/firmware/ folder. The firmware will be automatically loaded together with the ivtv module. If you don't trust the firmware files here, you can extract them yourself, following the instructions on this site.

    Channel change command

    Now you need In /etc/init.d/changechannel:

    /etc/init.d/changechannel

    #!/bin/bash
    channel=$(echo "$1 * 16" | bc)
    ivtvctl -r $channel

    You will need to tell MythTV to use this command. This is a menu option in the MythTV setup.

    Remote controle

    I used this site to get the remote control to work.

    Get input channel

    The infrared can be used as a /dev/input/eventx using the ir-kbd-i2c and the evdev modules.
    First make sure these two modules are loaded:

    modprobe evdev
    modprobe ir-kbd-i2c

    Now, to use this module, you need the input-utils, which are available as a Debian package:

    sudo apt-get install input-utils

    To check which event id your remote uses, run:

    lsinput

    and look for the number of the Hauppage remote (mine is 2)
    When pressing keys, the event codes are logged to the demesg:

    dmesg tail

    Look at the code that matches each key of the remote, and put all this information in configuration file /etc/hauppauge/pvr350.conf. Then upload this config file to the driver:

    input-kbd -f /etc/hauppauge/pvr350.conf 2

    To see if things are working for you, run:

    input-events 2

    and press some buttons. You should see them output to the terminal.

    To load this config file automatically at boot time, create the file /etc/init.d/hauppauge_remote with the line:

    /etc/init.d/hauppauge_remote

    input-kbd -f /etc/hauppauge/pvr350.conf 2

    and run it at boot time by linking into the rc2 directory:

    cd /etc/rc2.d
    ln -s ../init.d/hauppauge_remote S18hauppauge_remote

    Link between infrared and MythTV

    install lirc:

    sudo apt-get install lirc

    Then make a configuration file /etc/lirc/lircd.conf
    In /etc/lirc/hardware.conf put the lines:

    /etc/lirc/hardware.conf

    # Arguments which will be used when launching lircd
    LIRCD_ARGS="-H dev/input -d /dev/input/event2"

    Test using

    irw

    Adjust the file ~/.mythtv/lircrc so it matches the commands in /etc/lirc/lircd.conf

    MythTV

    Can you run MythTV on a Via Epia?


    Computational power

    Why would this be an issue? Well, encoding and decoding a live TV stream takes quite a lot of computing power. When buying my first via epia, I first opted for the more powerful MII series with a fan. However, with just a regular capture card, the processor was still too slow to watch live TV. Recording a show and watching it at a later time was the best I could do (live TV is requires more processing power since then the encoding and decoding happens simultaneously). So, in the end I ended up buying a Hauppauge PVR 350 TV tuner card, with a build in MPEG2 encoder and decoder. And this is just the prefect combination, it works like a charm. However, since in this case you don't really need the extra computing power of the MII series. Therfore I bought the super silent fan-less Via Epia ML eden fanless board. It works perfectly silent and stays very cool. And, it's hardly noticeable that the processor is less powerful. It's the ideal TV box in my opinion! Be aware that the ML edis is not powerful enough to play divx movies, it only works well with the PVR 350 hardware encoding/decoding.


    Hard disk

    The PVR 350 uses mpeg2 video encoding, which requires about 1 GB of disk space for an hour of TV. So you'll need about 5 GB of disk space for the installation of Kubuntu Edgy, and another 10-20 GB to record TV shows.

    Get MythTV packages

    I tried the easy way, without compiling anything myself. The more 'out of the box' the better. Luckily there are Dapper packages available of the latest MythTV 0.20 release. Just add the following line to your /etc/apt/sources.list (if you're using the Edgy release, you can skip this step. Edgy already has MythTV 0.20 in its multiverse repository):

    /etc/apt/sources.list

    # this line for MythTV dapper
    deb http://hamsta.net/mythtv/files/dapper/ ./

    and run

    sudo apt-get update
    sudo apt-get install mythtv mysql-server

    MySQL database permissions problem

    After the installation of the Debian packages I still had some problems with the permissions of the MySql database MythTV uses to store all its information (such as program guide etc.). MythTV uses a database called 'mythconverg'. To fix the permission problem, change the permissions of user MythTV:

    mysql -u root -p

    Now type your root password for the MySql database. If you didn't set any password, just press enter

    SET PASSWORD FOR mythtv@localhost = PASSWORD('mythtv');
    GRANT ALL ON mythconverg.* TO mythtv@'%' IDENTIFIED BY 'mythtv';

    Now go the setup of MythTV and set the same username and password in the designated fields.

    Belgian/Dutch TV program schedule

    First you need to get xmltv:

    sudo apt-get install xmltv

    Then you need to get a script to rip your local TV schedule from some webpage. Since there's no script available for Belgium, I used the Dutch one, which worked fine for me (90% of the channels Between Belgium and the Netherlands are the same). The script that came with MythTV was outdated (every time the webpage you're ripping from changes it's layout you need to update your script). I got the tv_grab_nl script from here. It's always up-to-date, and from time to time I download the latest one.
    To get a list of all available channels, run:

    tv_grab_nl --configure

    and select all the channels you would like to include in your database.
    Then, to update your database, run:

    mythfilldatabase

    And now, just be patient, this might take a few hours. It might be a good idea to set up MythTV to automatically run mythfilldatabase every night.

    Setup MythTV backend

    Now the easy part. To setup MythTV, run:

    sudo mythtv-setup

    and go through all the menu's. This part doesn't need explanation. Just make sure all folders you specify are readable/writable for the MythTV user.
    To start MythTV at boot time, there is one little trick. Mythbackend needs a username and password to access the Mysql database. This password is found in the file /home/mythtv/.mythtv/mysql.txt. however, at boot time, Mythbackend doesn't look in this file, but in the file /etc/mythtv/mysql.txt. So make sure you enter the username and password in both these configuration files.

    X org

    My ideal situation would be to have a regular KDE desktop on the monitor of my computer, and have MythTV permanently on the TV-out of the pvr 350 tuner card. I have tried to get this working, but this always resulted in a freeze of the whole system. You can download the /etc/X11/xorg.conf settings I tried.

    However, I found another solution that is not all too bad: I have a standard X org configuration, which means that when I start MythTV, it just appears on my computer monitor in a window, like any otehr program would. But MythTV makes it possible (a setting in the menu of Mythfrontend) to switch to the TV screen once you start playing live TV or a recorded show! Not perfect, but I'm very happy with this configuration.