Search:  
Gentoo Wiki

HOWTO_Setup_Kernel/System_for_MythTV

This article is part of the HOWTO series.
Installation Kernel & Hardware Networks Portage Software System X Server Gaming Non-x86 Emulators Misc

MythTV Series

MythTV

Installation

Tips/Tweaking

Usage

edit
« Previous – Index | Next – X Setup »

First thing to do is to get a working base gentoo system, please refer to the Gentoo Handbook.

Depending on how much hard disk space you are prepared to spare, grab about 5–10GB for your / partition while leaving the rest for your recordings directory. This is where we're going to store all your media, you want to make this either XFS or JFS.

Warning: You should not use ReiserFS for your recordings directory as you will get corrupted recordings.

Contents

Hardware/System Configuration

Filesystems

To optimize MythTV (especially if you are setting up a combined front & backend) there are three areas of storage it is useful to keep on separate drives; the system, 'recordings' and 'other media'. 'Other media' being a drive that stores ripped/downloded videos and music etc.

The xfs filesystem seems to be the best choice for the recordings drive.If you want to use xfs for any drive or partition. Make sure you have the xfs tools installed:

# emerge sys-fs/xfsprogs
# emerge sys-fs/xfsdump

For regular usage it is not normally necessary to defragment a Linux drive. However, an xfs drive or partition used by MythTV can get fragmented. To find out how fragmented a partition is you can use one of the xfs tools :

# xfs_db -c frag -r /dev/YOUR_PARTITION

What filesystem to use on your other drives depends on how or what you use them for. Ext3 should be great in most cases.

Optimizing

If any optimizing is needed on an xfs filesystem you can use this command:

# xfs_fsr -v

This will defragment any xfs drives found in your 'fstab'. You can set it as a cron job if you wish, some people run it nightly, it depends on your usage.

There are some things that can be done to increase disk performance and reduce Fragmentation:

Here is an example '/etc/fstab' for MythTV usage:

File: /etc/fstab

/dev/hda1          /boot           ext2         defaults                                        1 2
/dev/hda2          none            swap         sw                                              0 0
/dev/hda3          /               ext3         noatime                                         0 1
/dev/hdb1          /recordings     xfs          defaults,noatime,nodiratime,allocsize=512m      0 2
/dev/hdc1          /multimedia     ext3         defaults,noatime,data=writeback                 0 2
/dev/cdrom         /mnt/cdrom      auto         noauto,user,ro                                  0 0

shm                /dev/shm        tmpfs        nodev,nosuid,noexec                             0 0

TV card setup

Hauppauge WinTV-Nova-T

This is a standard definition digital terrestrial TV card. There are two versions of this card, one with a Philips chipset and the newer ones that have a Conexant chipset. Running 'lspci -v' should help you determine which card you have, here is an example listing for the Conexant chipset. This first section will focus on getting the Conexant one working. You will get 3 lists for each card.

# lspci -v
01:08.0 Multimedia video controller: Conexant CX23880/1/2/3 PCI Video and Audio Decoder (rev 05)
       Subsystem: Hauppauge computer works Inc. Unknown device 9002
       Flags: bus master, medium devsel, latency 32, IRQ 16
       Memory at f4000000 (32-bit, non-prefetchable) [size=16M]
       Capabilities: [44] Vital Product Data
       Capabilities: [4c] Power Management version 2
01:08.2 Multimedia controller: Conexant CX23880/1/2/3 PCI Video and Audio Decoder [MPEG Port] (rev 05)
       Subsystem: Hauppauge computer works Inc. Nova-T DVB-T Model 909
       Flags: bus master, medium devsel, latency 32, IRQ 16
       Memory at f5000000 (32-bit, non-prefetchable) [size=16M]
       Capabilities: [4c] Power Management version 2
01:08.4 Multimedia controller: Conexant CX23880/1/2/3 PCI Video and Audio Decoder [IR Port] (rev 05)
       Subsystem: Hauppauge computer works Inc. Nova-T DVB-T Model 909
       Flags: bus master, medium devsel, latency 32, IRQ 11
       Memory at f6000000 (32-bit, non-prefetchable) [size=16M]
       Capabilities: [4c] Power Management version 2

The cx2388x chip is the successor to the bt848/bt878 chips. If you use the Genkernel you just need to make sure it is configured as follows.

# genkernel --menuconfig all
Linux Kernel Configuration: Linux Kernel v2.6.22-gentoo-r2 Configuration (Conexant Hauppauge WinTV-Nova-T)
Device Drivers --->
  Multimedia devices --->  
    <*> Video For Linux
    [*]   Enable Video For Linux API 1 (DEPRECATED)
    ---   Enable Video For Linux API 1 compatible Layer
    [*]   Video capture adapters  --->
      ...
      [*]   Autoselect pertinent encoders/decoders and other helper chips
      ...
      < >   Hexium Gemini frame grabber
      <M>   Conexant 2388x (bt878 successor) support
      <M>     Conexant 2388x DMA audio support
      <M>     Blackbird MPEG encoder support (cx2388x + cx23416)
      <M>     DVB/ATSC Support for cx2388x based TV cards
      < >   Conexant cx23416/cx23415 MPEG encoder/decoder support
      ...
    [ ]   Radio Adapters  --->
    <*> DVB for Linux  
    [*]   Load and attach frontend modules as needed
    [*]   DVB/ATSC adapters  --->
      ...
          Customise DVB Frontends  --->
           ...
           <M> Conexant cx22702 demodulator (OFDM)
           ...
    [*] DAB adapters
    < >   DABUSB driver

That's it, upon a reboot it should all be detected.

One way to check is to make sure you have a '/dev/dvb' directory. It should be automatically created.

Just for some extra info, here is a list of the modules you need loaded (for both variants of card). Some of the 'budget' ones may not actually be necessary.

Check the modules you have loaded with

# lsmod

For extra help or more detail use the LinuxTV wiki

Hauppauge remote (bt848/bt878)

If you have a Hauppauge tuner/remote control, choose these options to allow them to function:

Linux Kernel Configuration: (gentoo-sources-2.6.x)
Loadable Module support --->
   Enable loadable module support
         <*> Module unloading
         <*> Automatic kernel module loading
Device Drivers --->
   Character devices --->
         <*> Enhanced Real Time Clock Support
 I2C support --->
   <M> I2C support
   <M>   I2C device interface
 Multimedia devices --->
   <M> Video For Linux
         Video For Linux --->
               <*> BT848 Video For Linux (see BT848 below)
               <*> Add support for additional audio chipsets (ivtv wouldn't compile without this)
               <*> Add support for additional video chipsets (ivtv wouldn't compile without this)
 Graphics support --->
   [*] Support for frame buffer devices
 Sound --->
   <*> Sound card support
         Advanced Linux Sound Architecture --->
               <M> Advanced Linux Sound Architecture
               <*> OSS API emulation (I couldn't find this one!)
               <M> OSS Mixer API
               <M> OSS PCM (digital audio) API
               <M> RTC Timer support
                   PCI devices  --->
                             <M> Bt87x Audio Capture (see BT848 below)

menuconfig has changed and some of the information listed above is outdated. Using these settings below I have personally gotten ivtv to work with a Hauppage 150 on a brand new amd64 install with ivtv 0.7.0 and gentoo-sources-2.6.17-r4. Any settings not shown are in thier default state.

Linux Kernel Configuration: (gentoo-sources-2.6.17-r4)
Device Drivers --->
  I2C support --->
    <*> I2C support
    <*>   I2C device interface
  Multimedia devices --->
    <*> Video For Linux
        Video Capture Adapters --->
          <*> BT848 Video For Linux
              Encoders and Decoders --->
                <*> Wolfson Microelectronics WM8775 audio ADC with input mixer
                <*> Wolfson Microelectronics WM8739 stereo audio ADC
                <*> Conexant CX2584x audio/video decoders
                <*> Philips SAA7113/4/5 video decoders (OBSOLETED)
                <*> Philips SAA7127/9 digital video encoders
  Sound --->
    <*> Sound card support
        Advanced Linux Sound Architecture --->
          <*> Advanced Linux Sound Architecture
          <*> OSS Mixer API
          <*> OSS PCM (digital audio) API
          <*>   OSS PCM (digital audio) API - Include plugin system (NEW)
          <*> RTC Timer support
          PCI Devices --->
            <*> Bt87x Audio Capture

USE flags

To save recompiling at later stages it is good to get your USE flags correct before you start installing MythTV. This example is from a working Myth box. Remember to Change the graphics and sound flags if needed.

You can set your Gentoo installation to use the 'desktop' profile. This will take care of some of the flags needed. Where <your arch> is likely to be one of the following: x86 or amd64.

# eselect profile set default-linux/<your arch>/2007.0/desktop

Now update your environment

# env-update && source /etc/profile

There are a few USE flags the desktop profile does not cover and some you need to remove. For example I use Xfce as a window manager so you will see KDE and GNOME have a '-' in front of them. Again, remember to amend the sound and graphics flags to suit your system. This is what the USE section looks like in my '/etc/make.conf' you can just copy and paste it into yours

USE="3dnow a52 aac alsa automount avhi -berkdb bindist caps cdr cdb cddb cups curl dbus
directfb dts dvb dvd dvdr encode esd exif fam ffmpeg flac firefox gd gdbm
gif -gnome gpm gtk gtk2 gstreamer hal ieee1394 java javascript joystick
jpeg -kde -kerberos ldap lirc lm_sensors mad mailwrapper mikmod mmx mp3
mpeg mysql nptl nsplugin ntponly nxclient ogg opengl pcre pdf png posix qt3
-qt4 quicktime samba sdl server startup-notification spell threads transcode
truetype type1 unicode usb v4l vcd vorbis wifi win32codecs xcomposite xml
xine xvmc xvid"
VIDEO_CARDS="vga vesa nv nvidia s3virge"
ALSA_CARDS="intel8x0 intel8x0m"
LINGUAS="en_GB en en_US"

And here is the finished list of USE flags for the system (note the lack of qt4). You can view yours by running

# emerge --info
Note: MythTV does not support UTF8. Make sure to add -utf8 to your '/etc/make.conf' if 'emerge --info' lists it.
USE="3dnow X a52 aac acl acpi alsa amd64 arts automount avhi bindist bitmap-fonts cairo
caps cdb cddb cdr cli cracklib crypt cups curl dbus directfb dri dts dvb dvd dvdr dvdread
eds emboss encode esd evo exif fam ffmpeg firefox flac fortran gd gdbm gif gpm gstreamer
gtk gtk2 hal iconv ieee1394 ipv6 isdnlog java javascript joystick jpeg ldap lirc lm_sensors
mad mailwrapper midi mikmod mmx mp3 mpeg mudflap mysql ncurses nls nptl nptlonly nsplugin
ntponly nxclient ogg opengl openmp oss pam pcre pdf perl png posix pppd python qt3
qt3support quicktime readline reflection samba sdl server session spell spl sse sse2
ssl startup-notification svg tcpd threads tiff transcode truetype truetype-fonts type1
type1-fonts unicode usb v4l vcd vorbis wifi xcomposite xine xml xorg xv xvid xvmc zlib"
ALSA_CARDS="intel8x0 intel8x0m" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop
empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mulaw multi null plug rate
route share shm softvol" ELIBC="glibc" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux"
LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text"
LINGUAS="en_gb en en_US" USERLAND="GNU" VIDEO_CARDS="vga vesa nv nvidia s3virge"


Most of these flags are needed for a successful MythTV box. However if there is one you do not need eg. amd64 just add it to your '/etc/make.conf with a '-' in front of it.

Note: You can check what all the USE flags are for in the Gentoo docs There are a few MythTV specific ones.

Power saving

CPU AMD

Check out the PowerNow! part of the wiki.

With an AMD CPU that supports Powernow! and the powernowd you can very easily save yourself a bit of electricity.

# genkernel --menuconfig all

Navigate to 'Power management options' > 'CPU Frequency Scaling'

Linux Kernel Configuration: Linux Kernel v2.6.22-gentoo-r2 Configuration (AMD PowerNow!)
[*] CPU Frequency Scaling
[ ] Enable CPUfreq debugging
<M> CPU frequency translation statistics
[ ] CPU frequency translation statistics details
    Default CPUFreq governor (performance)  --->
--- 'performance governor
< > 'powersave' governor
<M> 'userspace' governor for userspace frequency scaling
<M> 'ondemand' cpufreq policy governor

Make sure CPU Frequency Scaling is built in and the 'userspace' governor is a module. Then select the other governors you want, I would recommend using just 'ondemand'. When your kernel has finished compiling edit your 'modules.autoload' file to contain the governor modules you selected eg.

File: /etc/modules.autoload/kernel-2.6

# /etc/modules.autoload.d/kernel-2.6:  kernel modules to load when system boots.
#
# Note that this file is for 2.6 kernels.
#
# Add the names of modules that you'd like to load when the system
# starts into this file, one per line.  Comments begin with # and
# are ignored.  Read man modules.autoload for additional details.

# For example:
# aic7xxx
snd-intel8x0
cpufreq_ondemand
cpufreq_userspace
nvidia

Give you machine a reboot then

# emerge sys-power/powernowd
# rc-update add powernowd default

Lastly we just have to make sure that the powernowd responds to 'nice' programs (MythTVs transcode deamon operates as a 'nice' program). Just amend your '/etc/init.d/powernowd' script to contain 'powernowd -qn'. You might also want to adjust the CPU upper and lower usage limits, I set them so the CPU only drops in power when the computer is really idle. Live TV gives me about 10% CPU usage so I set the upper limit to 5 eg.

File: /etc/init.d/powernowd

#!/sbin/runscript

depend() {
        need localmount
        use logger
}

start() {
        ebegin "Starting powernowd"
        /usr/sbin/powernowd -qn -u 5 -l 4 ${POWERNOWD_OPTS}
        eend $?
}

stop() {
        ebegin "Stopping powernowd"
        start-stop-daemon --stop --exec /usr/sbin/powernowd
        eend $?
}

That's it, powernowd will start on your next boot, or you can start it with

# /etc/init.d/powernowd start

To check what speed your CPU is running at

# cat /proc/cpuinfo

CPU Intel

Simple email notification

You may want your MythTV box to email you with error logs etc. The SMART daemon is a good example of this, it can email you if your hard drive(s) have errors. So here is how to set up command line emailing which can then be included in scrpts etc.

First you need to install 'mail'

# emerge mail-client/mailx

Then, so you can send mail to an external smtp server, you need to install 'ssmtp'

# emerge mail-mta/ssmtp

Now just configure ssmtp. It has two config files

File: /etc/ssmtp.conf

# /etc/ssmtp.conf -- a config file for sSMTP sendmail.

mailhub=smtp.yoursmtpserver.com

rewriteDomain=smtp.yoursmtpserver.com

FromLineOverride=YES

File: /etc/ssmtp/revaliases

# sSMTP aliases
#
# Format:       local_account:outgoing_address:mailhub
#
# Example: root:your_login@your.domain:mailhub.your.domain[:port]
# where [:port] is an optional port number that defaults to 25.

root:YOUR@EMAILADDRESS:smtp.yoursmtpserver.com

That's it now you can give it a test

# mail -s "testing ssmtp" mail@whoever.com 
  Type your message
  'Enter'
  crl-d
  'Enter'

If you want the sender to be something more specific than 'root' just edit your '/etc/passwd' file eg.

File: /etc/passwd

root:x:0:0:YOUR_CHOSEN_NAME:/root:/bin/bash


Last modified: Fri, 26 Sep 2008 04:23:00 +0000 Hits: 24,558