Configuration of a PVR-350 on my Freevo Box

Hardware, Software

My system is a small BareBone, Using a NVIDIA Nforce2 Chipset, an Athlon 1400 Mobile, 512 MB DDR Memory, a 160 Gb IDE Disk.
The embedded video controller is the NForce 2 controller, without a TV Out.
To build a HTPC, I needed a TV Card. Until a lot of others, I'm not at this time planning to use a DVB receiver : My town is in the DVB area, but I receive TV trougth Cable, and (until now), the cable signal is Analog, or if Digital, can only be decoded trough a proprietary decoder.
So, to be able to record the 22 Analog channels I receive, and also to be able to show my TVBOX on my TV, I choose a PVR-350 card.
For he Linux distro : I choose the distro I know the best : I did my first installation with Mandrake 10.1, and then reinstalled the system with Mandriva2007.

Hauppauge PVR-350 installation

Mandriva 2007 is build on a kernel 2.6.17. This kernel supports natively the PVR-350 card. But the firmware files aren't furnished.
The firmware files can be found here (with a lot of other useful informations)
On Mandriva 2007, these file should be in this directory :
You probably have to adapt for your distribution.
After that, loading the ivtv module should go nice.

Just do
# modprobre ivtv
# dmesg
you should see something like that :
i2c /dev entries driver
Linux video capture interface: v1.00
ivtv: ==================== START INIT IVTV ====================
ivtv: version 0.7.3 (tagged release) loading
ivtv: Linux version: 2.6.17-5mdv SMP mod_unload 686 gcc-4.1
ivtv: In case of problems please include the debug info between
ivtv: the START INIT IVTV and END INIT IVTV lines, along with
ivtv: any module options, when mailing the ivtv-users mailinglist.
ivtv0: Autodetected Hauppauge WinTV PVR-350 card (cx23415 based)
ACPI: PCI Interrupt Link [LNK3] enabled at IRQ 12
PCI: setting IRQ 12 as level-triggered
ACPI: PCI Interrupt 0000:01:06.0[A] -> Link [LNK3] -> GSI 12 (level, low) -> IRQ 12
ivtv0: Unreasonably low latency timer, setting to 64 (was 32)
tveeprom 0-0050: The eeprom says no radio is present, but the tuner type
tveeprom 0-0050: indicates otherwise. I will assume that radio is present.
tveeprom 0-0050: Hauppauge model 48139, rev K257, serial# 2980036
tveeprom 0-0050: tuner model is Philips FM1216 ME MK3 (idx 57, type 38)
tveeprom 0-0050: TV standards PAL(B/G) PAL(I) SECAM(L/L') PAL(D/D1/K) (eeprom 0x74)
tveeprom 0-0050: audio processor is MSP4418 (idx 25)
tveeprom 0-0050: decoder processor is SAA7115 (idx 19)
tveeprom 0-0050: has radio, has IR remote
tuner 0-0061: chip found @ 0xc2 (ivtv i2c driver #0)
tda9887 0-0043: chip found @ 0x86 (ivtv i2c driver #0)
saa7115 0-0021: saa7115 found @ 0x42 (ivtv i2c driver #0)
saa7127 0-0044: saa7129 found @ 0x88 (ivtv i2c driver #0)
msp3400 0-0040: MSP4418G-B3 found @ 0x80 (ivtv i2c driver #0)
msp3400 0-0040: MSP4418G-B3 supports nicam and radio, mode is autodetect and autoselect
ivtv0: loaded v4l-cx2341x-enc.fw firmware (262144 bytes)
ivtv0: loaded v4l-cx2341x-dec.fw firmware (262144 bytes)
ivtv0: Encoder revision: 0x02050032
ivtv0: Decoder revision: 0x02020023
ivtv0: Allocate DMA encoder MPEG stream: 128 x 32768 buffers (4096KB total)
ivtv0: Allocate DMA encoder YUV stream: 161 x 12960 buffers (2048KB total)
ivtv0: Allocate DMA encoder VBI stream: 80 x 26208 buffers (2048KB total)
ivtv0: Allocate DMA encoder PCM audio stream: 455 x 4608 buffers (2048KB total)
ivtv0: Create encoder radio stream
ivtv0: Allocate DMA decoder MPEG stream: 16 x 65536 buffers (1024KB total)
ivtv0: Allocate DMA decoder VBI stream: 512 x 2048 buffers (1024KB total)
ivtv0: Create decoder VOUT stream
ivtv0: Allocate DMA decoder YUV stream: 20 x 51840 buffers (1024KB total)
ivtv0: loaded v4l-cx2341x-init.mpg firmware (155648 bytes)
tuner 0-0061: type set to 38 (Philips PAL/SECAM multi (FM1216ME MK3))
ivtv0: Initialized Hauppauge WinTV PVR-350, card #0
ivtv: ==================== END INIT IVTV ====================

Setting the PVR-350 TV-Out as the default X-Desktop

That is a little more tricky. The fact is that you need a driver for X-Windows, and this driver is not so easy to find precompiled, and I wasn't able to compile it myself.
First, some links that were very useful for me :
XV on PVR-350 The most complete article I found. Mostly NTSC oriented.
How to PVR-350 as X Desktop (In German :-) I hope you'll like that ! Very convenient for PAL information)

Then, how I did that.
You should be sure that your TV-Out is working properly. So, take one of the mpeg file you captured with the PVR-350, and send this file to the card (for the TV) :
cat video.mpeg >/dev/video16
You should see the movie on the TV

Then, you must install the X driver for your distribution. Remember, this driver is highly related to your kernel level, but also (if not more) to your XFrre86 / Xorg version.
In my case, (kernel 2.6.17, xorg 7.1), I finally find these files (one for i386, one for Athlon64 - And I'm sorry, but I don't find the source page any more !)
Select the file you need, rename it and copy it in the directory /usr/lib/xorg/modules/drivers
Again, the place may vary, please check your installation

After that, you should be able to load the ivtv-fb module :
modprobe ivtv-fb

You should see something like that :
ivtv0-osd: Framebuffer module loaded (attached to ivtv card id 0)
ivtv0-osd: screen coords: [0 0] -> [720 576]
ivtv0-osd: original global alpha = 208
ivtv0-osd: current OSD state = 39
ivtv0-osd: new global alpha = 208 (1 255 0)
ivtv0-osd: framebuffer at 0xd1510000, mapped to 0xe1490000, size 1665k
ivtv0-osd: mode is 720x576x32, linelength=2880
ivtv0-osd: fb1: cx23415 TV out frame buffer device
ivtv1: Allocate DMA decoder OSD stream: 16 x 65536 buffers (1024KB total)
It's maybe time for a little break, so see if the two modules ivtv and ivtv-fb load alone after a reboot. If they don't (mostly the case), you'll have to help then.
In my case, I simply add in the file /etc/modprobe.preload these lines :
It's now time to configure xorg.
This part is nicely explained in the two link I put before.
Be very careful about the BusID part
Here are the relevant parts of my xorg.conf file :
Section "Monitor"
    Identifier "PAL_TV"
    HorizSync 30-68
    VertRefresh 50 # 50-120
    # I did some tests to use a 16:9 TV Screen, but it seems that the
    # driver only works in 720 x 576 mode.
    # Anyway, if you want to test other settings, you can obtain the next lines
    # with the gtf tools. For example, for the 2 next lines, I wanted to test
    # A horisotal resolution of 720 pixel, a vertical resolution of 432
    # and a refresh frequency of 50 Hz (Better on my display than 60 Hz)
    # the command is
    # gtf 720 432 50
    # 720x432 @ 50.00 Hz (GTF) hsync: 22.25 kHz; pclk: 19.22 MHz
    Modeline "720x432"  19.22  720 720 792 864  432 433 436 445  -HSync +Vsync
    # 720x576 @ 50.00 Hz (GTF) hsync: 29.65 kHz; pclk: 26.57 MHz
    Modeline "720x576"  26.57  720 736 808 896  576 577 580 593  -HSync +Vsync
    # 960x576 @ 50.00 Hz (GTF) hsync: 29.65 kHz; pclk: 35.58 MHz
    Modeline "960x576"  35.58  960 984 1080 1200  576 577 580 593  -HSync +Vsync

Section "Device"
    Identifier "Hauppauge_PVR350"
    Driver "ivtvdev"
    BusID "1:6:0"
    Option "fbdev" "/dev/fb1"
    # Option "ivtv" "/dev/fb1"
    # Screen 0
    Option "VideoOverlay" "on"
    Option "XVideo" "1"

Section "Screen"
    Identifier "TV"
    Device "Hauppauge_PVR350"
    Monitor "PAL_TV"
    DefaultDepth 24
    DefaultFbbpp 32
    Subsection "Display"
        Depth 24
        Modes "720x576"
        FbBpp 32
Normally, after that, if you launch startx, you should see your desktop on your TV.

It's now time to test freevo on your brand new XTV Desktop :
freevo -fs should do the work.

If this is working, it's time to do that automatically.

I use a solution given in the freevo wiki : the autologin feature.

In my case, (using the user 'freevo' for freevo), here are the relevant lines in /etc/inittab :
1:3:respawn:/sbin/mingetty --autologin freevo tty1

The .bash_profile of freevo contains that :
case "`tty `" in
/dev/tty1) $HOME/bin/freevo_start && exit ;;

Finally, that's my freevo_start file :
if [ -f "$HOME/freevobloc" ]
date >>$LOG
echo "There's a 'freevobloc' file, I don't start" >>$LOG
exec sleep 600
echo "Freevo starting ..." >>$LOG
date >>$LOG
freevo cache >>$LOG 2>&1
exec freevo -fs >>$LOG 2>&1

Whit this configuration, whenever the freevo process stop, it is restarted by inittab. So, in case I don't want that freevo restart, I just create an empty 'freevobloc' file in the home directory of freevo.

Well that's nearly all, I think.

If you have any question, you can drop me a mail at   schirrms AT schirrms dot net, but preferably, you should drop a mail in the freevo user list (if in English) or in the freevo french forum (if in French).

I really want to thank the lot of people who works on the freevo project, and also all people who gave me so useful information on the net to setup my TVBOX.

Made with Nvu