Hauppauge HD-PVR

From MythTV Official Wiki
Revision as of 16:31, 17 April 2011 by Ghormann (talk | contribs) (HD-PVR Driver Compilation Howto)

Jump to: navigation, search
Hauppage HD-PVR
Vendors Website http://www.hauppauge.com/site/products/data_hdpvr.html
Input Formats Component, S-Video, and Composite (stereo and S/PDIF for audio)
Support Status Supported since 0.22
Driver hdpvr (part of the kernel since ~
Sound Driver not applicable
Chipset not applicable

The Hauppauge HD-PVR Model 1212.

The Hauppauge HD-PVR is the first consumer-level analog HD capture device available. The HD-PVR is a USB device that captures the component video outputs and analog/optical audio outputs of any consumer device (including cable/satellite set-top-boxes, HD Disk Players, video game consoles, and various other home media devices). The HD-PVR is a highly popular capture device because it captures video via component output, permitting the user to capture High-Definition video from most sources and without concern for encryption. In other words, since component video is not and cannot be encrypted, previously un-capturable HD sources such as satellite and premium television will now be fully accessible in MythTV. Prior to this device, component capture devices were cost-prohibitive and were not directly supportable within Linux.

The HD PVR captures at resolutions from VGA/D1 (480i) up to 1080i, and encodes the component inputs in real time using the h.264/MPEG-4 video codec and the AAC audio codec. The streams are muxed into a slightly modified MPEG-2 Transport Stream container. Capture resolution is dependent on the source (ie 720p video with be captured as such, 1080i as 1080i, etc.) but the bitrate is user-selectable from 1 Megabit/second up to 13.5 Megabits/second. The h.264 video codec is, bit-for-bit, up to 40% more efficient than the MPEG-2 video codec commonly used in US HDTV broadcasts today. A 13.5 Mb/s h.264 stream is roughly equivalent to a full-channel-bitrate MPEG-2 recording at approximately 19 Mb/s.

The HD-PVR uses modern codecs capable of exceptional compression rates at excellent quality. The tradeoff is that decoding h.264 material is very processor-intensive. If not using VDPAU, even systems which easily play back US broadcast HD are likely to fail altogether when playing back recording from the HD-PVR. Hauppauge recommends a dual-core CPU as a minimum if not using VDPAU; a frequently cited minimum for medium-bitrate h.264 playback is a Core 2 Duo 1.8 Ghz processor. HD Playback Reports acts as a repository for processor requirements to play High Definition material. HD-PVR users are encouraged to contribute to the page to ascertain real-world playback requirements with MythTV.

In all HD-PVR firmwares later than, AC-3 muxing via S/PDIF is available, allowing one to mux the original 5.1 channel audio track into the captured stream. To enable this functionality, be sure to set the audio input to S/PDIF by editing the capture card definition in mythtv-setup and setting the preferred input device to S/PDIF.

Important.png Note: If you are running a firmware earlier than 1.5.6, you should update the firmware as soon as possible. Hauppauge has fixed a bug that can under certain conditions cause the HD-PVR to become inoperable.

Possible Countermeasures

Some UK television providers (notably Virgin and Freesat) have attempted to counter the HD-PVR and similar devices by selectively disabling the component outputs of their set-top-boxes. In the US, the Motion Picture Association of America has requested that the Federal Communications Commission allow providers to selectively disable the component outputs of their devices when showing recently released movies.

There is a new solution to this countermeasure. A company called HDFury makes HDCP-compliant HDMI converters. The HD-FURY2 converts HDMI input into sound and component outputs. It is available from http://www.curtpalme.com. The original HDFury converts HDMI to RGB. It is available from Monoprice or http://www.curtpalme.com. The RGB output of the HDFury can be converted to component with a second device called Box1020. A user with an HDMI-only device could use the following path to convert HDMI to component video:

HDMI Source -> HDMI to DVI cable -> HD Fury -> Box1020 -> Component Cable -> HD-PVR or using the HD Fury2 the chain could be shorted to HDMI Source -> HD Fury2 -> Component Cable -> HD-PVR

At the time of this writing, the original HDFury and Box1020 cost approximately $210 US. The HD Fury2 sells for $249 US, but it eliminates the need for the Box1020 and adds a host of picture quality and stability improvements. Some users will be put off by the high cost and circuitousness of the solution, but for an increasing number of MythTV users, it may be the only option.

Firmware Upgrade Process

The firmware on the device cannot be upgraded through a GNU/Linux system at this time. Use the following process within a MS Windows installation:

  1. Visit the Hauppauge website and download the latest driver
  2. Unpack the driver into a folder
  3. Connect the HD-PVR to your computer via the USB cable and connect the power
  4. A window may pop-up asking you if you want to search for a driver, press the cancel button if possible
  5. Run the executable in the folder you created above
  6. If necessary, your firmware will be updated
  7. Disconnect the HD-PVR and reconnect to your backend system

HD-PVR Driver Compilation Howto

Note: As of Linux Kernel 2.6.30 the driver for the HD-PVR is now included by default. However, the driver may not have the necessary bits to enable the IR Transmitter. You only have to follow this procedure if your kernel does not include the driver, you want to use the IR Transmitter, or you need a newer driver.

The development branch of the HD-PVR Linux driver is available from the LinuxTV project.

Important.png Note: This how-two has been upgrade for more current kernal versions (2.6.32 and greater). The instructions in a historical [version] using the mercurial repository may still work on older kernels.)

Currently, firmware loading is unimplemented in the driver. As a result, if you have a "rev c1" or newer unit you must install the HD-PVR at least once on a Windows machine to load the firmware into it. If you have a Revision 2 unit (including a sticker marked "rev c2" on the bottom of the unit) then it will come loaded with a firmware. Once you have done so, you will need a working build environment, Mercurial, and kernel headers installed on your system. In Debian and debian-based distros, the following command should install all necessary dependencies to build the driver.

sudo apt-get install build-essential mercurial linux-headers-`uname -r` 

MythDora 10.21 with kernel includes drivers for the HD-PVR, no compilation is necessary.

In rpm based distros such as Mythdora, the following command should suffice assuming proper dev tools, kernel-headers and kernel-devel have already been installed.

sudo yum install mercurial

The HD-PVR driver is now included in v4l-dvb. You can check out the v4l-dvb repository with the following command:

hg clone http://linuxtv.org/hg/v4l-dvb

Important.png Note: As of 01/13/2011 the hdpvr driver found on linuxtv.org does not have the necessary bits to enable the IR Transmitter. In addition to the steps mentioned below for configuring lirc, one must apply Jarod Wilson's patch before compiling the hdpvr driver. Note: Multiple post on the mailing list have suggested this isn't stable with some of the latest hardware versions. If the hd-pvr box locks up between adjacent records, there is a good chance this patch is related.

cd ~/v4l-dvb
wget http://wilsonet.com/jarod/junk/hdpvr-ir-enable-v4l-dvb-tip.patch
patch -p1 < hdpvr-ir-enable-v4l-dvb-tip.patch

In best case scenarios, the following should be enough to compile and install the driver:

cd v4l-dvb
sudo make install 

Important.png Note: If compilation fails due to an error with the firedtv driver, then edit the file "v4l-dvb/v4l/.config" and change the line: "CONFIG_DVB_FIREDTV=m" to "CONFIG_DVB_FIREDTV=n". In addition, changing all lines to "=n" except for CONFIG_VIDEO_HDPVR will greatly speed up compile time.

Important.png Note: The HD-PVR driver may need editing if you have a very new device. You may need to edit hdpvr.h and hdpvr-core.c in linux/drivers/media/video/hdpvr of the v4l-dvb source. For hdpvr.h add a new ID. For example:


/* Define these values to match your devices */
#define HD_PVR_VENDOR_ID        0x2040
#define HD_PVR_PRODUCT_ID       0x4900
#define HD_PVR_PRODUCT_ID1      0x4901
#define HD_PVR_PRODUCT_ID2      0x4902
#define HD_PVR_PRODUCT_ID3      0x4982


/* Define these values to match your devices */
#define HD_PVR_VENDOR_ID        0x2040
#define HD_PVR_PRODUCT_ID       0x4900
#define HD_PVR_PRODUCT_ID1      0x4901
#define HD_PVR_PRODUCT_ID2      0x4902
#define HD_PVR_PRODUCT_ID3      0x4982
#define HD_PVR_PRODUCT_ID4      0x4903

For hdpvr-core.c make sure your new ID is used. For example:


static struct usb_device_id hdpvr_table[] = {
        { }                                     /* Terminating entry */


/* table of devices that work with this driver */
static struct usb_device_id hdpvr_table[] = {
        { }                                     /* Terminating entry */

To find your product id, run lsusb.

Bus 001 Device 005: ID 2040:4903 Hauppauge

In the above example, 4903 is the product id.

You can check an installed module for specific device support by running "modinfo hdpvr" and finding the "alias" lines. The numbers listed should match the output of lsusb. The following example shows a system that does not support the 4903 ID above and needs to be modified and re-compiled in order to work.

alias:          usb:v2040p4982d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v2040p4902d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v2040p4901d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v2040p4900d*dc*dsc*dp*ic*isc*ip*

If compilation and installation succeeded, it should be possible to load the HD-PVR driver with:

sudo modprobe hdpvr

If dmesg only shows "registered new interface driver hdpvr" and no /dev/video# device has been created, you probably have a newer device than your kernel module supports. Refer to the note above for instructions on how to fix this.

If dmesg shows "wrong firmware version," and "device init failed," then you did not install the device in Windows first and the firmware has not been loaded. Install the HD-PVR on a windows machine, install the drivers, and after that the device should work fine in Linux.

In Ubuntu, the module may fail to load and refer you to the dmesg command. If this happens, reboot and see if the error resolves itself. It is also possible that Ubuntu is prioritizing another, older copy of the v4l-dvb modules above the one you just installed, and the hdpvr will fail because the two versions do not match. Try a command like:

locate cx88-dvb.ko |grep `uname -r`

This will search for the cx88-dvb kernel module, which is provided in the Hg tree you just built, and also in default Ubuntu installs. If you see more than one copy of this file, you may need to move the older versions out of the way. In at least one case, alternate versions of all the modules were located in "/opt/ltsp/amd64/lib/modules/kernel version number/ubuntu/". The symbol mismatch was solved by moving the "/opt/ltsp/amd64/lib/modules/kernel version number/ubuntu/media" directory into a backup directory in the user's home, then rebooting.

Testing the Driver

Once the module has loaded successfully, you can check dmesg for output and to determine which /dev/video node it has created. You can then test the device as with any hardware encoder:

cat /dev/video1 > test.ts

Press Ctrl-C to stop the capture, and play it back with any compatible media player (ie mplayer, xine, MythTV).

Bitrate and Picture Controls

The HD-PVR driver is compatible with the v4l2-ctl command line utility included in ivtv-tools. To see a list of adjustable controls, use the following command:

v4l2-ctl --device=/dev/video0 -l

Substitute the correct video# in the example above. The following controls are presently supported in the driver:

Control Name Values Default Description
brightness 0 to 255 134 Brightness picture control over recordings.
contrast 0 to 255 128 Contrast picture control over recordings.
saturation 0 to 255 128 Saturation picture control over recordings.
hue 0 to 255 128 Hue picture control over recordings.
sharpness 0 to 255 128 Sharpness picture control over recordings.
audio_encoding 3 to 4 3 Control for Audio Encoding. 3=AAC, 4=AC3.
video_encoding 2 2 Non-adjustable control for Video Encoding (H.264).
video_bitrate_mode 0 to 1 1 Control for VBR versus CBR. 0=VBR, 1=CBR.
video_bitrate 1000000 to 13500000 6500000 Bitrate control over recordings in bits, from 1 Mbit/s to 13.5 Mbit/s.
video_peak_bitrate 1100000 to 20200000 9000000 Peak bitrate control in bits, from 1.1 Mbit/s to 20.2 Mbit/s.

You can adjust any of these values with a command like:

v4l2-ctl --device=/dev/video0 --set-ctrl=controlname=value

Or, for example:

v4l2-ctl --device=/dev/video0 --set-ctrl=video_bitrate=13500000

This command will set the bitrate to the maximum of 13.5 Mbit/s for the HD-PVR at /dev/video0.

The audio_encoding selection only works for PCM input. If the HD-PVR is fed AC3, then AC3 will always be muxed into the H.264.

Note that the picture controls currently do not have an effect as of kernel 2.6.31.

Miscellaneous Kernel Module Options

Several options exist that may be of assistance when troubleshooting or for certain use cases. If the audio output is too low, you can boost the audio signal by adding the following module option for the hdpvr module:


If you wish to see more verbose dmesg output, you can use the following module option:


Where # = an integer between 1 and 7, increasing in level of verbosity.


Sets the device node to /dev/video#


default video input: 0=Component, 1=S-Video, 2=Composite


default audio input: 0=RCA back, 1=RCA front, 2=S/PDIF. For firmware 0xf, this must apparently be set to 2 to enable 5.1ch AC3 recording, otherwise it records stereo only.

Configuring the HD-PVR in MythTV

MythTV 0.22 now includes support for the HD-PVR. See below for caveats and setup information.


Once the tuner has been added as an encoder in MythTV, it is vital that the user not access the tuner in outside programs such as cat, VLC, and mplayer. This can lead to MythTV's connection with the driver becoming unstable, and subsequent recordings failing until the driver is reloaded and power is cycled on the HD-PVR.

The last sync with libavcodec did greatly improve stability when playing material from the HD-PVR. If you still get playback crashes, try compiling myth with --disable-ssse3.

For Motorola STBs, it is also important to set the "4:3 Override" option to Off or Stretch. For some Motorola STBs, both the aspect ratio settings and output resolution controls can be found by powering down the STB and then pressing the Menu button.

Myth can become non-responsive due to run-away "mythbackend --generate-preview" processes. If you check your mythbackend logs and see it being flooded with ac3 or faac errors, it is likely the "generate-preview" process doing it. A "pkill -f generate-preview" will return your myth system to a usable state. You may even want to add that pkill to a cronjob.


The HD-PVR previously had problems gracefully dealing with resolution changes but those issues have been fixed. You can now allow your receiver to float between 480i, 480p, 720p and 1080i without causing the HD-PVR or MythTV to hang.

Tracking Progress

The HD-PVR is completely usable when using Myth 0.22, just make sure you are using the latest HD-PVR firmware.

As of September 1, 2009 IR blasting and receiving is tentatively working. Jarod Wilson has created patches for the lirc and hdpvr drivers. He's in the process of having his patches approved and committed.

Steps to Add the HD-PVR as a Capture Device in MythTV (0.22 or later)

  1. Compile the driver and test it for proper operation as described above.
  2. Run mythtv-setup, and enter option 2, Capture Cards.
  3. Add a new capture card. When prompted, select "H.264 Encoder Card (HD-PVR)" as the card type. Set the /dev/video node to the number of your HD-PVR. Finish adding the new capture card. You can also set the audio input on this screen. All cables must be functional and properly attached in order for capture to succeed with the HD-PVR. If every recording fails with a "Unknown type, recording width was 0" error in the mythbackend log, it is possible that one of your cables is faulty or has become disconnected.
  4. Enter option 3, "Video Sources." Set up a video source for your HD-PVR's tuner as described in the manual.
  5. Enter option 4, "Input Connections." Connect the video source to the appropriate input on the HD-PVR. Important Note: You must set a channel change script for the HD-PVR to work properly. If you don't care about channel changes, you can set it to /bin/true, but there absolutely must be a channel change script defined. Important Note 2: You must leave Preset tuner to channel empty or LiveTV and channel changes will not work.

Assuming you followed the directions carefully, you should now be able to record with the HD-PVR. If you get "Select Timeout" errors, these can sometimes be overcome by stopping the backend, removing the hdpvr module, cycling the power on the HD-PVR, modprobing the hdpvr module, and restarting the backend.

You can set the bitrate for the HD-PVR by going into Recording Profiles, and editing the profiles associated with HD-PVR encoders. These recording profiles have bitrate settings for low (480i/p), medium (720p), and high (1080i) resolution material, allowing you to set appropriate bitrates based upon the resolution of the material. If the max bitrate is set lower than the average bitrate, the result is CBR (Constant Bit Rate) at the rate specified by the average slider. If you want VBR (Variable Bit Rate), set the max slider to maximum, and then use the average slider to achieve the desired bitrate.

IR Transmitter Support

Fedora Core 12 currently has built-in support for the HD-PVR's IR blaster. In Fedora 12 follow the steps below to enable the IR transmitter. Other distributions may need custom compiled drivers. See the section below to compile drivers for the IR transmitter.

The HD-PVR, as with many other Hauppauge on-card emitters, only supports a fixed set of IR codes. The HD-PVR includes a wide variety of codes for most common set top boxes, but it may or may not contain codes for special buttons like arrow or menu buttons. See below for more information on codesets and lircd.conf.

Compile LIRC Modules for IR Transmitter Support

The HD-PVR's IR blaster must be supported in both the LinuxTV driver and the LIRC driver. If your distribution doesn't include support for the IR blaster you may build it yourself. The instructions below were written using a Mythbuntu 9.10 installation, but they should be applicable to other distributions.

  1. Begin by downloading and extracting the patched HD-PVR and LIRC drivers. These files were extracted from Fedora 12.

Important.png Note: The drivers provided in this step no longer compile on kernels 2.6.3x and newer without modifications. As an alternative, follow the steps mentioned above to download and compile the hdpvr driver from linuxtv.org. The latest Ubuntu already has an lirc driver that will work (all one has to do is recompile the hdpvr driver, not the lirc driver).

  1. If needed, install the tools you need to compile the drivers (kernel headers and a build environment). For Debian, Ubuntu, and Mythbuntu, issue the following command: apt-get install build-essential linux-headers-`uname -r`.
  2. Enter the hdpvr folder and issue the command make to build the HD-PVR driver.
  3. Enter the lirc folder and issue the make command to build lirc_dev.ko and lirc_zilog.ko. Note: This tarball contains an updated version of the LIRC driver framework, lirc_dev. If you have other lirc devices on this box you'll need to download and compile updated drivers for them as well. Copy the needed source to this working folder and re-issue the make command to build additional modules. See the LIRC source code included in your distribution.
  4. Be sure that mythbackend and any other processes that may be using the HD-PVR are stopped. Unload the HD-PVR driver (sudo rmmod hdpvr).
  5. Stop LIRC and any processes that may be using it.
  6. Find and back up your existing HD-PVR module (locate hdpvr.ko).
  7. Replace the existing hdpvr.ko with the one compiled above.
  8. Find and back up your existing LIRC modules lirc_dev.ko and lirc_zilog.ko.
  9. Replace the installed lirc_dev.ko and lirc_zilog.ko with the new versions.
  10. Load the HD-PVR driver (sudo modprobe hdpvr) and check dmesg for errors.
  11. Load the LIRC module (sudo modprobe lirc_zilog) and check dmesg for errors. Note: Be sure the HD-PVR firmware file is in place BEFORE you load the driver. If the firmware is missing modprobe will segfault and the new modules may lock up.
  12. Follow the steps to enable the IR transmitter.
Steps to Enable IR Transmitter
  1. Plug the IR emitter in to the HD-PVR. Affix the sticky portion to the front of your set top box, aligned towards the box's IR receiver.
  2. Install LIRC as appropriate for your distribution. Note: If your distribution does not package a sufficiently recent copy of LIRC to include support for the HD-PVR IR emitter, you may need to compile it yourself.
  3. Download the HD-PVR IR firmware. Put the firmware in your distribution's firmware directory, (commonly /lib/firmware).
  4. Download the lircd.conf file and place it where your distribution keeps LIRC configuration files (commonly /etc/lirc/).
  5. If necessary (usually not), set lirc to start at boot (service lirc on in Fedora, or update-rc.d lirc defaults in Debian-based distributions)
  6. Find the LIRC hardware.conf file in the LIRC configuration directory and edit it to include the following. If the HD PVR is the only IR device attached to your system, make sure and comment out all other TRANSMITTER and RECEIVER blocks that may already be in there. You may have to adjust the device and socket values depending on your particular setup.
#Chosen IR Transmitter
TRANSMITTER_MODULES="lirc_dev lirc_zilog"
  1. Restart LIRC and if needed load the module, lirc_zilog (modprobe lirc_zilog). Check dmesg to see if the module has successfully loaded. Check your devices (e.g. ls /dev/lirc*). If the HD PVR is the only device attached, then /dev/lirc0 and /dev/lircd should be the only devices. If there exists an lircd1 then hardware.conf may not be set up properly.
  2. Look at the codesets supported by the HD-PVR. The codes that start with a 0_ are for cable and 1_ are satellite.
  3. Use this script to send a power command to your Set Top Box.
  4. When the STB changes power state, the terminal will show which command set was used. Edit /etc/lirc/lircd.conf and remove the codes you don't need and (optionally) rename the ones you do. For instance 0_125_KEY_POWER becomes KEY_POWER.

At this point the IR transmitter should send the codes properly to the STB. Channel changes will still require a channel change script.