MythTV and VPAU

Introduction
On the MythTV roadmap official support for VDPAU will be added in the 0.22 release of MythTV. This is still quite a way out. However Jean Yves Avenard has backported the VDPAU code from the 0.22 release to 0.21 release. The only way to get this to work in a Gentoo environment is to download the sources, apply the patches and compile the code yourself. In this page I will share my experiences that might help you to get a working version of MythTV 0.21 with VDPAU support. 

Why VDPAU (Video Decode and Presentation API for Unix)
VDPAU is an API developed by NVIDIA. It enables the application to benefit of the GPU-accelerated decode functions for processing MPEG-1, MPEG-2, H.264, and VC-1 bitstreams.  Two observations here, you need the nvidia driver binaries and you need an Nvidia based GPU subsystem. This benchmark gives an illustration of the benefits of using VDPAU. Bottom line is a less powerfull CPU is required to run mythTV, solutions using quiet fanless ITX motherboards are now feasible. However there are currently only a very few ITX boards that fulfill the following requirements, lowpower, onboard nvidia GPU with DVI/HDMI output and H.264 hardware decoding, pci slot (for DVB receivers) and onboard digital audio out.  So lets get started.

Requirements

 * Minimal kernel version 2.6.28 required for S2API support
 * installed.
 * You must have nvidia drivers 180.x (official stable) or 185.x (beta) installed.
 * Gentoo's mythTV distribution is a 0.21 version.
 * Understand the use of USE flags

Packages needed
To be able to download the various packages the subversion toolkit is needed.

I suggest to keep the sources of all the packages under /usr/local/src

MythTV
The MythTV SVN page contains info on the sources of MythTV. Make sure you start of from the directory and use the following command to download the sources:

Where BRANCHEVERSION is the version mentioned on the VDPAU patch web to which the patches are applied. I would suggest to rename the release-0-21-fixes directory and create a symbolic link to the release-0-21-fixes directory. This helps to keep track of which branch version you are using.

MythTV VDPAU Patches
The MythTV VDPAU Page contains the link to the latest version of the patch package and to what branch version of MythTV this needs to be applied.  Download the patch file from the above page. TBD

DVB Softcam scasc-ng
TBD

Compiling the code
The mythtv package is a very complex package with dependencies on lots of libraries from other packages. The mythtv page list them for the unbutu environment. To avoid having to map them to the corresponding package names in Gentoo and pull those in one by one we let emerge do the job for us. This means we need to have the right USE flags set at the appropriate place.USE flags are either used global or a package specific context. To make it confusing they sometimes are used both global and package specific. USE flags for global use should be specified in and the package specific ones in  file. Gentoo Linux Use Variable Descriptionpage lists the definitions of all USE flags and by which packages they are used. From this page it is clear that there are only a very limited set of flags directly used by mythtv. They should go in the file. The page Making Sense of Gentoo's USE flags is recommended reading too.  Depending on your requirements the lines for mythtv in file might look like: mythtv USE flags Before emerging the mythtv package do a sanity check on the current Portage tree. Start with an update on the Portage tree

Followed by a check on the impact of the change of the USE flags. If you are unsure of the impact add the flag to run a simulated update first.

Before kicking of the mythtv compilation process check the uptodate kernel headers are installed by executing the following commands,

Not sure the above is correct, the official way seem to be to do a emerge of the kernel headers files package(linux-headers), but that package is old and out of sync with the kernel source version (gentoo-sources) Now is the time to let emerge do the work in pulling in all the packages needed to build mythtv.

This emerge step might take quite some time to finish. By this time we have an plain Gentoo mythtv distribution installed. Now is the time to overlay the VDPAU version over the standard version.

Applying the VDPAU Patch
Go to the mythtv code directory and issue the following command (note the actual patch file name depends on the version you just downloaded.

Configuring MythTV compile environment
Go into the MythTV directory and create the following script:

Setting up the environment
Verify that XvMC is selected for nvidia

You might see something like this eselect Use

to select nvidia eselect result

Usefull Resources

 * MythTV, Initial Installation
 * mythtv page
 * XvMC in MythTV
 * MythTV source patches for VDPAU
 * Gentoo Linux Use Variable Description
 * Making Sense of Gentoo's USE flags