Turn your Kuro into a Digital Video Recorder/Player

Although I have had my iPod Video for about 9 months I seldom watch video on it. I just can't bring myself to pay $2 for an episode of futurama when it is on TV every night. This month I will be installing a Hauppage WinTV-PVRUSB2 capture device on my Kuro and configuring it to automatically record shows and save them in my media directory so I can watch them at a later time with my Buffalo LinkTheater. Since I also have an iPod, as an aded bonus, we'll make the Kuro convert the video captures to the format my iPod uses for viewing on my iPod Video.

The WinTV-PVRUSB2 comes with a remote control, so I'll be configuring the remote to work with my MP3 player, adding the standard set of controls to the MP3 player that are normally seen on a stereo system. I'll also be adding any other functionality that comes to mind as I work through this project.

Build a custom kernel
The first step is to build a 2.6.18-rc3 kernel with V4L and PVRUSB2 support. Also required is the standard kernel support for the USB system. Once that is complete the firmware for the WinTV-PVRUSB2 needs to be extracted from the original windows driver. There were two (or three depending on the particular version) firmware files that needed to be extracted. Luckiny there is a script here that will automatically extract the firmware. The firmware needs to be copied into /lib/firmware. From there it will be loaded into the hardware on boot. In order to get the firmware to load you will need to emerge hotplug, coldplug, and add coldplug to the default runlevel. It goes without saying (although I'm saying it anyway) that udev is also required, of course, your 2.6 kernel will not boot without udev. Once that is done you should see something like the following in your dmesg:

usb 1-1: new high speed USB device using ehci_hcd and address 5 usb 1-1: configuration #1 chosen from 1 choice usb 1-1: reset high speed USB device using ehci_hcd and address 5 rs5c372_get_datetime, i2c_transfer returned -5 rs5c372_get_rtc_time:Command returned -5 msp3400 1-0040: MSP3445G-B8 found @ 0x80 (pvrusb2_a) msp3400 1-0040: MSP3445G-B8 supports radio, mode is autodetect and autoselect tuner 1-0043: chip found @ 0x86 (pvrusb2_a) tda9887 1-0043: tda988[5/6/7] found @ 0x43 (tuner) tuner 1-0061: chip found @ 0xc2 (pvrusb2_a) saa7115 1-0021: saa7115 found @ 0x42 (pvrusb2_a) tveeprom 1-0050: Hauppauge model 29032, rev D158, serial# 7429455 tveeprom 1-0050: tuner model is Philips FM1236 MK3 (idx 58, type 43) tveeprom 1-0050: TV standards NTSC(M) (eeprom 0x08) tveeprom 1-0050: audio processor is MSP3445 (idx 12) tveeprom 1-0050: decoder processor is SAA7115 (idx 19) tveeprom 1-0050: has radio, has IR remote tuner 1-0061: type set to 43 (Philips NTSC MK3 (FM1236MK3 or FM1236/F)) msp3400 1-0040: MSP3445G-B8 rev1 = 0x0207 rev2 = 0x2d48 msp3400 1-0040: Audio:   volume 65535 msp3400 1-0040: Audio:   balance 0 bass 0 treble 0 loudness off msp3400 1-0040: Standard: autodetect start (mono) msp3400 1-0040: Audmode: 0x0001 msp3400 1-0040: Routing: 0x00000000 (input) 0x00000044 (output) msp3400 1-0040: ACB:     0x0c00 tda9887 1-0043: Data bytes: b=0x14 c=0x30 e=0x44 tuner 1-0061: Tuner mode:     analog TV tuner 1-0061: Frequency:       175.25 MHz tuner 1-0061: Standard:       0x00000100 saa7115 1-0021: Audio frequency: 44100 Hz saa7115 1-0021: Input:          Composite 4 saa7115 1-0021: Video signal:   bad saa7115 1-0021: Frequency:      50 Hz saa7115 1-0021: Detected format: BW/No color pvrusb2: Device initialization completed successfully. pvrusb2: registered device video0 [mpeg]

Apparently I have no signal in my office. A quick trip to the side of the house to connect the cable wire in my office to the splitter and the device is ready to go:

Linux video capture interface: v2.00 usbcore: registered new interface driver pvrusb2 drivers/media/video/pvrusb2/pvrusb2-main.c: Hauppauge WinTV-PVR-USB2 MPEG2 Encoder/Tuner : V4L in-tree version drivers/media/video/pvrusb2/pvrusb2-main.c: Debug mask is 15 (0xf) usb 1-2.3: reset high speed USB device using ehci_hcd and address 5 scsi 2:0:0:0: CD-ROM           TSSTcorp CD/DVDW SH-S182M SB02 PQ: 0 ANSI: 0 scsi 2:0:0:0: Attached scsi generic sg1 type 5 usb-storage: device scan complete msp3400 1-0040: MSP3445G-B8 found @ 0x80 (pvrusb2_a) msp3400 1-0040: MSP3445G-B8 supports radio, mode is autodetect and autoselect saa7115 1-0021: saa7115 found (1f7115d0e100000) @ 0x42 (pvrusb2_a) tuner 1-0043: chip found @ 0x86 (pvrusb2_a) tda9887 1-0043: tda988[5/6/7] found @ 0x43 (tuner) tuner 1-0061: chip found @ 0xc2 (pvrusb2_a) tveeprom 1-0050: Hauppauge model 29032, rev D158, serial# 7429455 tveeprom 1-0050: tuner model is Philips FM1236 MK3 (idx 58, type 43) tveeprom 1-0050: TV standards NTSC(M) (eeprom 0x08) tveeprom 1-0050: audio processor is MSP3445 (idx 12) tveeprom 1-0050: decoder processor is SAA7115 (idx 19) tveeprom 1-0050: has radio, has IR receiver, has no IR transmitter tuner 1-0061: type set to 43 (Philips NTSC MK3 (FM1236MK3 or FM1236/F)) msp3400 1-0040: MSP3445G-B8 rev1 = 0x0207 rev2 = 0x2d48 msp3400 1-0040: Audio:   volume 65535 msp3400 1-0040: Audio:   balance 0 bass 0 treble 0 loudness off msp3400 1-0040: Standard: autodetect start (mono) msp3400 1-0040: Audmode: 0x0001 msp3400 1-0040: Routing: 0x00000000 (input) 0x00000044 (output) msp3400 1-0040: ACB:     0x0c00 saa7115 1-0021: Audio frequency: 48000 Hz saa7115 1-0021: Input:          Composite 4 saa7115 1-0021: Video signal:   VCR saa7115 1-0021: Frequency:      60 Hz saa7115 1-0021: Detected format: NTSC saa7115 1-0021: Width, Height:  720, 480 tda9887 1-0043: Data bytes: b=0x14 c=0x30 e=0x44 tuner 1-0061: Tuner mode:     analog TV tuner 1-0061: Frequency:       175.25 MHz tuner 1-0061: Standard:       0x00000100 pvrusb2: Device initialization completed successfully. pvrusb2: registered device video0 [mpeg]

Installing software
Now that the kernel and hardware portion is working it is time to work on the software part of this project. We'll be installing the MythTV backend on the Kuro and with a bit of luck configuring it via some custom scripts to run the iPod conversion.

The first application to install is qt. It contains qmake which is required to configure MythTV so lets emerge it. emerge qt

We also want to use the remote control that came with the WinTV-PVRUSB2 so we'll need lirc. emerge lirc

Now lets get started building MythTV. First we'll download the mythTV tarball, untar it and change directories into it, run configure and build it: cd ~ wget http://www.mythtv.org/modules.php?name=Downloads