Next Previous Contents

22. Example Configurations.

This section contains configurations which you may find useful.

22.1 Hauppauge PVR-250/350 hardware MPEG-2 encoder

NOTE: THE FOLLOWING DOCUMENTATION IS PROVIDED AS-IS AND IS NOT GUARANTEED TO WORK WITH YOUR DISTRIBUTION. FOR IVTV DRIVER ASSISTANCE, SEE THE IVTV MAILING LIST. https://lists.sourceforge.net/lists/listinfo/ivtv-devel SEE THE IVTV FAQ IF YOU HAVE QUESTIONS OR ISSUES. http://ivtv.sourceforge.net/
These instructions work for Mandrake 9.1 on a backend machine which is hosting a single PVR-250 capture card.

Install the Mandrake kernel source. If you are using a different Mandrake kernel level (ie, not 2.4.21-0.16mdk as in the example below, then alter the urpmi command appropriately.)

$ uname -a
Linux pvr 2.4.21-0.16mdk #1 Fri Apr 11 06:51:54 CEST 2003 i686 unknown
unknown GNU/Linux

$ su
# urpmi kernel-source

NOTE: You do not need to recompile your kernel.
Download the latest IVTV driver from Sourceforge. Check http://sourceforge.net/projects/ivtv/ for the current version. Right now (2004-01-21), it's 0.1.9. Untar the file.
$ tar -xzf ivtv-0.1.9.tar.gz

This should create an ivtv directory. Switch to it and perform the following commands:

$ cd ivtv/utils
$ wget http://hauppauge.lightpath.net/software/pvr250/pvr250_17_21288.exe
$ su
# ./ivtvfwextract.pl pvr250_17_21288.exe
# exit
$ cd ../driver

The ivtvfwextract program extracts the firmware required for the card. You may want to go to the Hauppauge website and download the latest Windows driver if the wget command fails.

ivtv also needs to know how your kernel was compiled. The default Makefile is not configured for the way Mandrake "does things". At the top of the Makefile in the driver directory is a line like this:

KERNELDIR= /lib/modules/$(KERNVER)/build
edit it so that it looks like:
KERNELDIR= /usr/src/linux

NOTE: If you are running a distribution / kernel which is using the new version of i2c (version 2.8.x, found in the latest Mandrake and Cooker) you will need to make the following edit. Look for
# uncomment if you use i2c 2.8.0+
#CFLAGS += -DNEW_I2C
and remove the "#" from the line containing CFLAGS.

Next, compile the driver:

$ cd ~/ivtv/driver
$ make

Compile the test_ioctl program:

$ cd ../utils
$ make
$ su
# cp test_ioctl /usr/local/bin
# exit

NOTE: You may get warnings about i2c during the compile. Ignore them if they look something like this:
#warning Using temporary hack for missing I2C driver-ID for saa7114

However, if you get an actual compile error where the compile doesn't finish and the error looks like: saa7115.c:1117: error: unknown field 'inc_use' specified in initializer then you didn't uncomment CFLAGS as specified above.

Add the following to /etc/modules.conf:

NOTE: You do not need to add the last line "add above..." if you will not be using the IR remote that came with the card.
alias char-major-81     videodev
alias char-major-81-0   ivtv
alias char-major-61 lirc_i2c
options ivtv debug=1
options tuner type=2
options msp3400 once=1 simple=1
add below ivtv msp3400 saa7115 tuner
add above ivtv lirc_dev lirc_i2c

NOTE: You must specify the tuner type manually. See ~/ivtv/driver/tuner.h for a listing of tuners. In the above example, tuner type=2 is a Phillips NTSC. Use an appropriate tuner type for your system and video standard. The debug=1 parameter on the ivtv line actually means less debugging output will be printed.
At this point we need to ensure that there are no other versions of msp3400.o that would be loaded instead of the version that is created by ivtv. Note that in the command below we are using the backtick, usually located on the same key as the tilde " " and not the single quote.
$ su
# cd /lib/modules/`uname -r`
# pwd
/lib/modules/2.4.21-0.16mdk
# find . -name "msp3400*" | xargs rm -f

Next, copy the files that were compiled in the driver directory into the appropriate modules directory:

$ su
# make install
# depmod -ae

Finally, load the ivtv driver:

# modprobe ivtv
# exit

Check that the card is being recognized on the PCI bus:

$ lspci -v
<snip>

00:0c.0 Multimedia video controller: Internext Compression Inc iTVC15 MPEG-2
Encoder (rev 01)
        Subsystem: Hauppauge computer works Inc.: Unknown device 4801
        Flags: bus master, medium devsel, latency 32, IRQ 11
        Memory at d0000000 (32-bit, prefetchable) [size=64M]
        Capabilities: <available only to root>

If you don't see your card on the PCI bus, make sure that it's been installed in a bus-master slot. For some motherboards, only the PCI slots closest to the AGP slot are bus-mastering.

Check that the ivtv driver has created a new video device:

$ ls -l /dev/v4l/vi*
crw-------    1 mythtv   sys       81, 224 Dec 31  1969 vbi0
crw-------    1 mythtv   sys       81,   0 Dec 31  1969 video0
crw-------    1 mythtv   sys       81,  32 Dec 31  1969 video32

In this case, the ivtv device is video0.

You can now add this card available to MythTV. Go into your mythtv setup directory on the machine hosting the hardware MPEG-2 card. When you add a new capture card, ensure that you are using the video0 device.

NOTE: As of 2003-04-25 the ivtv driver does not support VBI, so closed-captioning is not available.
Leave the VBI device, audio device and audio sampling rate limit at the default values. Change the default input to an appropriate setting for your configuration. Change the card type to "Hardware MPEG Encoder Card" and press ENTER.

The remaining setup is just like a standard V4L card; define a video source if you have not already done so, and assign the video source to a video card input on the Input Connections screen.

Some people report issues with the ivtv module not being loaded when required by MythTV. To get around this, you can modprobe the ivtv driver before using it. The simplest technique is to add the modprobe command to /etc/rc.d/rc.local:

# echo "/sbin/modprobe ivtv" >> /etc/rc.d/rc.local

NOTE: some people complain that their PVR-250/350 card is not capturing audio. The most likely source for this is that your system is not loading the correct msp3400.o file; ivtv uses a custom msp3400.c, and if the resulting module isn't loaded you will not get sound. Switch to your /lib/modules directory and rename the existing msp3400.o file, then copy the msp3400.o from the ivtv driver directory and re-run depmod. If that still doesn't work, then check the ivtv mailing list for more information. You may wish to perform an updatedb as root and then do a locate msp3400 to find all the msp3400.o.gz files that may be on your system. For example, Mandrake has a msp3400.o.gz in the 3rdparty subdirectory which will take precedence over the custom version created by ivtv. You can check if you have the correct msp3400 loaded by typing (as root): modinfo msp3400 | grep "parm: *standard". If you don't get a line that says: "parm: standard int", then you're not loading the correct msp3400.
Check to ensure that you're loading the correct msp3400 module.
 
# modinfo msp3400
filename:    /lib/modules/2.4.22-9mdk/kernel/drivers/media/video/msp3400.o

Check that the path is correct for your kernel version, and that the driver being loaded is in /media/video and not some other directory.

NOTE: Some people report "ghosting" issues with their PVR-250s, where there is a faint copy of whatever is on the screen appearing to the right of the image. If you have this issue, it's fairly obvious. This is a firmware issue, apparently. There are two ways around this:
  1. Run at 720x480 resolution
  2. Turn off DNR

To turn off DNR, add the following to your rc.local:

/path/to/ivtv/utils/test_ioctl --set-codec-params=dnr_mode=0,dnr_temporal=0

22.2 Hauppauge PVR-250 remote and MythTV's native LIRC support

NOTE: THE FOLLOWING DOCUMENTATION IS PROVIDED AS-IS AND IS NOT GUARANTEED TO WORK WITH YOUR DISTRIBUTION. FOR LIRC DRIVER ASSISTANCE, SEE THE LIRC MAILING LIST. http://lists.sourceforge.net/lists/listinfo/lirc-list
These instructions work for Mandrake 9.2 on a frontend machine which is hosting a single PVR-250 capture card using MythTV's native LIRC support.

First, you need to ensure that you've installed the kernel source appropriate for the kernel that you're running. In this case, we're using kernel 2.4.22-9, so when installing the kernel-source ensure that you've got the correct version.

$ su
# uname -a
Linux frontend 2.4.22-9mdk #1 sam sep 13 06:54:11 CEST 2003 i686 unknown
unknown GNU/Linux
# rpm -qa|grep kernel-source
kernel-source-2.4.22-9mdk

If you've already installed LIRC from the Mandrake packages, it's going to be version 0.6.6, and that won't work. Uninstall it:

$ su
# urpme lirc lirc-remotes liblirc-devel
# rm -rf /dev/lirc*
# exit

Check to ensure that you don't have other versions of lirc modules and programs on your system:

$ su
# updatedb
# locate lirc_i2c|grep `uname -r`
/usr/src/linux-2.4.22-9mdk/3rdparty/lirc/lirc_i2c.c
/lib/modules/2.4.22-9mdk/kernel/3rdparty/lirc/lirc_i2c.o.gz

# locate lirc_dev|grep `uname -r`
/usr/src/linux-2.4.22-9mdk/3rdparty/lirc/lirc_dev.c
/usr/src/linux-2.4.22-9mdk/3rdparty/lirc/lirc_dev.h
/usr/src/linux-2.4.22-9mdk/include/linux/modules/lirc_dev.stamp
/usr/src/linux-2.4.22-9mdk/include/linux/modules/lirc_dev.ver
/lib/modules/2.4.22-9mdk/kernel/3rdparty/lirc/lirc_dev.o.gz

# locate irw|grep "/usr"
/usr/bin/irw
/usr/local/bin/irw
/usr/local/man/man1/irw.1

# locate lircd|grep "/usr"
/usr/src/linux-2.4.22-9mdk/3rdparty/lirc/lircd.conf.RM-050
/usr/share/man/man8/lircd.8.bz2
/usr/share/doc/lirc-0.6.6/html/lircd.html
/usr/sbin/lircd
/usr/local/sbin/lircd
/usr/local/man/man8/lircd.8

# locate irxevent|grep "/usr"
/usr/share/man/man1/irxevent.1.bz2
/usr/share/doc/lirc-0.6.6/html/irxevent.html
/usr/share/doc/lirc-0.6.6/irxevent.keys
/usr/bin/irxevent
/usr/local/bin/irxevent
/usr/local/man/man1/irxevent.1
As you can see, there were a number of different versions of lirc already installed on this system. They must be removed. We don't care about the source code or the man pages, only the executables and the kernel modules.
$ su
# rm -rf /lib/modules/2.4.22-9mdk/kernel/3rdparty/lirc
# rm -rf /usr/sbin/lircd /usr/local/sbin/lircd
# rm -rf /usr/bin/irxevent /usr/local/bin/irxevent
# rm -rf /usr/bin/irw /usr/local/bin/irw

Download the lirc-0.7.0pre2 tarball:

$ wget http://lirc.sourceforge.net/software/snapshots/lirc-0.7.0pre2.tar.bz2
$ tar -xjf lirc-0.7.0pre2.tar.bz2

Mandrake now includes i2c version 2.8.0 which changes the semantics of some low-level calls. You will need to patch LIRC in order for it to work correctly. Download the patch and install:

$ cd lirc-0.7.0pre2
$ wget http://delvare.nerim.net/i2c/other/lirc-CVS-i2c-2.8.0.patch
$ patch -p1 < lirc-CVS-i2c-2.8.0.patch

Next, run the LIRC setup program:

$ ./setup.sh

Select "1" (Driver configuration), then scroll down to "5" (TV Card), press ENTER, then scroll down to "f" (Hauppauge TV card) and press ENTER again. Once back at the main menu, press "3" for Save and run configure.

If your build environment is ready, LIRC will create a Makefile for you. Switch to root and compile:

$ su
# make
# make install

NOTE: If you receive a compile error stating: lirc_i2c.c:296: unknown field 'owner' specified in initializer, you will need to edit the file and comment out a line in the source code. See message http://www.gossamer-threads.com/lists/mythtv/users/40136 for detailed instructions.
As a part of the make install process, LIRC will create the appropriate device for you in /dev. Check to make sure:
$ ls -l /dev/lirc*
crw-r--r--    1 root     root      61,   0 Sep 18 15:36 /dev/lirc
srw-rw-rw-    1 root     root            0 Sep 18 15:38 /dev/lircd=

Your modules.conf file should have already been modified if you've followed the instructions above for installing the PVR-250. modprobe the lirc_i2c driver, run the lircd program and then check your /var/log/messages and /var/log/lircd files.

$ su
# modprobe lirc_i2c
# lsmod
Module                  Size  Used by    Not tainted
lirc_i2c                5124   0
lirc_dev               10096   1  [lirc_i2c]
...
# lircd
# tail /var/log/messages
Sep 18 15:38:26 frontend kernel: lirc_i2c: chip found @ 0x18 (Hauppauge IR)
Sep 18 15:38:26 frontend kernel: lirc_dev: lirc_register_plugin:sample_rate:
10
...
# tail /var/log/lircd
Sep 18 15:24:52 frontend lircd 0.7.0pre2: lircd(hauppauge) ready

To check that your remote is working correctly, run the irw program and start pressing buttons. If nothing is happening, you must begin troubleshooting. Things to check:

If none of the above works, and irw still isn't showing keypresses, then you will need to ask your question on the LIRC list.

Assuming that irw is showing keypresses, you can continue: To enable native LIRC support within MythTV, you will need to modify your settings.pro file and recompile. Your settings.pro should look like this:

# Native lirc support
CONFIG += using_lirc
LIRC_LIBS = -llirc_client

Recompile and install:

$ make distclean; make
$ su
# make install

If you're not using native LIRC support, ensure that the button names that come up with irw match the ones in the .lircrc file in your home directory. Note that if you are not using native LIRC support, the .lircrc file is in your home directory and has a "." as the first character.

Since we're using native LIRC support within MythTV, copy the configfiles/hauppauge-lircrc-nativelirc file into your .mythtv/ directory and call it lircrc. It has a slightly different format than what you would use if you were using irxevent. Also note that it is in your .mythtv directory and does not have a "." in the filename.

$ cp configfiles/hauppauge-lircrc-nativelirc ~/.mythtv/lircrc

Add the commands to load the LIRC device drivers and start lircd to your rc.local:

$ su
# echo "modprobe lirc_i2c" >> /etc/rc.d/rc.local
# echo "/usr/local/sbin/lircd" >> /etc/rc.d/rc.local
# exit

You should now have native LIRC support within MythTV.

22.3 Logical Volume Manager (LVM)

LVM greatly increases the flexibility you have in managing your storage than traditional physical partitions. This section will provide some brief notes on how to use LVM to create storage space for your video files and how to add additional disk space in the future. There's lots more that can be done with LVM, so check the LVM HOWTO http://tldp.org/HOWTO/LVM-HOWTO/ document for details.

If you don't understand how to partition a drive, or how to change the partition type you should stop and look at documentation on how to perform these steps.

BIG FAT WARNING: Using an incorrect parameter can make your files inaccessible, prevent your computer from booting, etc. Be careful!

Make sure your kernel configuration includes LVM support or that it's available as a module. Today, most vendors include this by default. You'll also want to ensure that you have a copy of the LVM utilities; check your distribution, or get the latest versions from http://www.sistina.com/products_lvm.htm and build them manually.

Check that the vgscan program is being run at some point during your boot sequence - most distributions do this by default. Look for a message during boot up that looks like this: vgscan -- reading all physical volumes (this may take a while...) If you don't see any messages during boot, you may need to install a LVM init script or confirm that you have all of the LVM packages installed from your distribution.

LVM uses a few concepts you should be familiar with before starting.

The following example assumes that you want to create a LVM partition from a chunk of space in /dev/hda5, using a reiserfs filesystem and mounted on /var/video. You later decide to extend this filesystem by adding a new disk: /dev/hdb.

You need to create at least one LVM partition for a physical volume. Use fdisk or your favorite partition editor to set the type to LVM (0x8e). If you're using an entire disk, create one big partition rather than using the device itself. e.g. use /dev/hdb1 not /dev/hdb.

In the following example, you have a 15GB disk. The first 6GB are set as your boot partition. /dev/hda2 was added as an extended partition, and within that partition you created the /dev/hda5 linux (ext2) partition.

# fdisk /dev/hda

The number of cylinders for this disk is set to 1823.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/hda: 15.0 GB, 15000330240 bytes
255 heads, 63 sectors/track, 1823 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/hda1   *         1       764   6136798+  83  Linux
/dev/hda2           765      1823   8506417+   5  Extended
/dev/hda5           765      1823   8506417   83  Linux

Command (m for help): t
Partition number (1-6): 5
Hex code (type L to list codes): 8e

Command (m for help): p

Disk /dev/hda: 15.0 GB, 15000330240 bytes
255 heads, 63 sectors/track, 1823 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/hda1   *         1       764   6136798+  83  Linux
/dev/hda2           765      1823   8506417+   5  Extended
/dev/hda5           765      1823   8506417   8e  Linux LVM

Command (m for help): w

#

Create the LVM physical volume from the partitions (repeat if you have multiple partitions to use):

# pvcreate /dev/hda5
Create a LVM volume group out of this physical volume called "VGforMyth" that is allocated in chunks that are a multiple of 64MB
# vgcreate VGforMyth -s 64m /dev/hda5
Create a logical volume of 5GB called "video" and then create the reiserfs filesystem and mount it:
# lvcreate --name video --size 5G VGforMyth
# mkreiserfs /dev/VGforMyth/video
# mount /dev/VGforMyth/video /var/video
Now create a 3GB volume for mythmusic files if you like:
# lvcreate --name music --size 3G VGforMyth
# mkreiserfs /dev/VGforMyth/music
# mount /dev/VGforMyth/music /var/music
Display the volume group status: # vgdisplay -v

Now, lets suppose you want to add a 60GB hard disk to the system as hdb and allocate 50GB of it to video storage.

First, create a single partition /dev/hdb1 covering the whole disk and make it type 0x8e using your partition editor.

# fdisk /dev/hdb .... create partition, set type, save and reboot if it says you have to

Create the new LVM physical volume:

# pvcreate /dev/hdb1

Add the new physical volume to the volume group:

# vgextend VGforMyth /dev/hdb1

NOTE: You may get errors at this point stating that there are no physical volumes available for adding to the LV, even though you know for a fact that there are. You may need to specify the physical volume in the /dev/ide/host/bus/target/lun/etc format.
Once you've completed one of the following two procedures, use df to check that you've got more space.

ReiserFS

Make the logical volume used for video bigger:

# lvextend --size +50G /dev/VGforMyth/video

Unmount, resize and remount the filesystem. Technically, you don't need to unmount and remount the ReiserFS.

# umount /var/video
# resize_reiserfs /dev/VGforMyth/video
# mount /dev/VGforMyth/video /var/video

ext2 or ext3

LVM comes with a program called e2fsadm.

Unmount, resize and remount the filesystem. The filesystem must be unmounted during this procedure.

# umount /var/video
# e2fsadm --size +50G /dev/VGforMyth/video
# mount /dev/VGforMyth/video /var/video

22.4 Advanced Partition Formatting

The partitions that your distribution sets up for you may not be optimized for large files. Using LVM in conjunction with the following techniques can be quite useful.

Unlike a typical filesystem, a MythTV video partition is usually a very large filesystem filled with a fairly small number of large files. Filesystem I/O is usually not an issue, even in multi-tuner and/or multi-frontend setups.

There is however, one aspect of filesystem performance that can have a bearing on the performance of MythTV. In Linux, deleting a file will utilize I/O bandwidth until the deletion has been completed. If deleting the file takes long enough, the video capture buffer may overrun, thereby resulting in dropped frames. Some filesystems are faster at deleting files than others and, for multi-gigbyte MythTV video files, these differences can be significant.

Fortunately, there are published tests ( http://aurora.zemris.fer.hr/filesystems/big.html) that provide insight into filesystem performance under conditions relevant to MythTV usage. In addition, some limited testing (archived at http://www.gossamer-threads.com/lists/mythtv/users/52672) with very large files (10 gigabytes) was reported in the MythTV Users mailing list.

Ext2

Ext2 was the defacto standard Linux filesystem for many years. It is stable, provides good I/O performance and can quickly delete large files. The primary disadvantage of Ext2 is that it is not a journaling filesystem, so a file system consistency check (fsck, which is normally only performed after a system crash) can take many hours on a filesystem the size of a typical MythTV partition.

Ext3

Ext3 is Ext2 with a journal, so your biggest gain is that in case of a crash and reboot you won't have to wait very long for your partition to be remounted.

There are options available when formatting an Ext3 partition, as in:

# mkfs.ext3 -T largefile4 /dev/hdb1

This example assumes that /dev/hdb1 has already been created using fdisk. If you're using LVM, /dev/hdb1 may be something like /dev/VGforMyth/video.

The "-T largefile4" option creates one inode per 4 megabytes, which can provide a few percent more storage space. However, tests indicate that using the "-T largefile4" option can drastically increase the amount of time required to delete a large file and thus it should only be used with encoder settings that produce small video files (YMMV).

You can check on your filesystem using the dumpe2fs program. See the man page for details.

ReiserFS

The Reiser filesystem is another journaling filesystem commonly distributed with Linux. It is known to be an extremely efficient filesystem and it especially excels at managing partitions containing a large number of small files. However, tests indicate it is not the fastest at deleting very large files. For that reason, it may not be the best choice when using encoder bitrates that produce very large files.

JFS

JFS (Journaling File System) is a journaling filesystem originally developed by IBM for AIX which was later released as open source. While not as common as Ext3 or ReiserFS, it is distributed with RedHat 9 (RH9) and Fedora Core 1 (RHFC1) and Mandrake as well as other distros. According to tests, JFS is the file deletion speed king, deleting virtually any file in under one second, even files as large as 10 gigabytes.

XFS

XFS is a journaling file system originally developed by SGI for Irix, and later released as open source. While not a part of the default RedHat Linux 9 or Fedora Core installation (although it is a part of Mandrake and Fedora Core 2), it can be easily installed via ATrpms. XFS provides deletion speeds for large files only slightly slower than JFS. According to the test results shown at ( http://aurora.zemris.fer.hr/filesystems/big.html), XFS provide higher I/O rates than JFS, albeit at a higher CPU loading. This may cause issues if you do not have the spare CPU capacity to handle XFS, potentially leading to dropped frames.

22.5 HDTV with the Air2PC-ATSC-PCI card

The Air2PC card has the capability to capture over-the-air HDTV signals (8VSB) and unencrypted HDTV (QAM) off of cable TV. The Air2PC card is installed as a DVB device and is supported within MythTV.

First, you must compile a version of the Linux kernel to support the new tuner device. Version 2.6.11 supports the card in 8VSB mode. If you wish to use QAM, you will need to patch the kernel, or wait until 2.6.12.

Download the source to 2.6.11. At the time of this writing (2005-02-09), the latest is 2.6.11-rc3.

$ su
# cd /usr/src
# wget http://www.kernel.org/pub/linux/kernel/v2.6/testing/linux-2.6.11-rc3.tar.bz2
# tar -xjf linux-2.6.11-rc3.tar.bz2
# cd linux-2.6.11-rc3

To be continued...


Next Previous Contents