MythTV DVB Setup Guide

Compiled by Martin Smith
V0.20 March 2005 (for MythTV Version 0.17)

Contents

Part 1 - Intro and Hardware Setup

What is DVB?
Installing and Testing Hardware
Hardware Installation
Install Drivers
Test Scanning and Tuning
Hardware Troubleshooting

Part 2 - MythTV DVB Configuration

Backup MySQL
Load DVB Drivers
Add DVB Channel Data
Upgrading a 0.16 Database to 0.17
Configure Capturecard
Testing the Card
Additional XMLTV config (now obsolete)
Configuring a second card
More on DVB Stream Errors
Collecting Data on Signal Quality
Adventures With a new Motherboard
My System Specs
Using the Freeview EPG with MythTV

Part 3 - Additional Information

Conditional Access Modules
Notes for the 2.6 Kernel
Links

Other Documents

I've also written a document containing notes on Building a Storage Server about my experiences in putting together a Linux machine to act as a networked file server for video data.

What Is DVB?

DVB is Digital Video Broadcasting, a set of digital television standards with a large amount of industry support.

There are several advantages to digital TV. Programme guides and flexible digital services are much easier than with analogue.  In several countries the intention is to phase out analogue TV over time and DVB is one of the leading systems that may replace it.

For various technical reasons DVB is able to make better use of bandwidth than analogue transmissions. This means that several digital channels can be transmitted in place of one analogue channel. This is done by multiplexing the signals and you will often see DVB-T referred to as a multiplex or mux.

Picture quality can also be better, though this is not always true. If too many channels are squeezed into the same multiplex then the quality can drop.

Digital signals are more resistent to some types of interference that plagues analogue TV, for example ghosting. However uers in weak signal areas may find that they are unable to get usable pictures whereas they can receive at least some analogue channels. This is going to make plans to switch off analogue signals somewhat more complicated.

Some analogue aerial installations for DVB-T may need to be upgraded or realigned. In the UK there is a postcode checker that can give some idea about what the likely reception will be at your location. Users of DVB over cable and satellite don't have to worry about this.

Standardisation should keep the cost of hardware down. For example in the UK a basic DVB-T set top box can be bought for 50. Some of the budget class PCI cards are around the same price or maybe slightly more.

Before You Start

With version 0.17 of MythTV and its new improvements to the DVB support things should be much easier now. It shouldn't be necessary (yeah weasel words I know) to manually enter channel information or do anything via SQL to set up a new installation from scratch.

Upgrading from a previous version requires a one off database change, which I've documented later, assuming you want to keep your existing channel configuration.

For the moment I've left the older instructions in place in this document and tried to signpost which bits apply to particular situations. The main thing to remember is that it's now much easier than it used to be and not all of the sections will be relevant to new installs.

Installing and Testing Hardware

There's no doubt that getting a working Linux DVB installation is currently more complicated than for the analogue cards. As support makes its way into the mainstream Linux kernel then this will hopefully change. For the moment you'll need a combination of luck, skill and patience.

Step one is to get your DVB hardware working. It's important to do this before worrying about configuring MythTV to use it. If it doesn't work outside MythTV with the basic utilities then it won't work inside it being driven by a complex application. In these cases the DVB driver forums and mailing lists are probably better resources to start with.

This process can be summarised as:
The aim at the end is to have video from the card and know that it is stable and working correctly.

Hardware Installation

DVB hardware is normally either a PCI card or USB attached module. The Linux DVB drivers include support for both types but not every card that's supported under Windows works under Linux. This is normally because manufacturers refuse to release the necessary information.

The budget PCI cards look similar to analogue capture cards and are quite small. The full featured cards are bigger and may prove difficult to fit into the smaller type of case popular for MythTV projects. All TV tuners tend to run hot. Small cases can present challenges in this area, especially with multiple cards..

Before buying anything make sure the card is fully supported by Linux drivers. This is not always as easy as it sounds as manufacturers often ship cards with different hardware under the same name. For example there are at least three different versions of the Nova-T card on sale. I bought two cards at roughly the same time and they use different frontend chips.

After installing a PCI card check for its presence with lspci. For example I would see this for one of my cards:
00:0a.0 Multimedia controller: Philips Semiconductors SAA7146 (rev 01)
For USB you may need to load additional modules for the adapter to be recognised. I don't have any USB adapters so I don't know the exact details of this. The USB devices should announce themselves in the system log when they're connected. If this doesn't happen then you may have missing USB modules that need to be loaded.

Install Drivers

Note: For users of later model Nova-T cards with the Conexant chips on them (check the output of lspci) Richie Jarvis has a page on getting them to work that may well be useful to read and follow before continuing with the rest of this..

The current stable Linux kernel (the 2.4 series) does not include support for DVB devices. There are several drivers available on the net to address this. The most up to date is known as dvb-kernel and is the development track for inclusion in the upcoming 2.6 linux kernel. When this kernel is released users of DVB hardware should have an easier time. If you are using 2.6 then please check this 2.6 related section and remember that the instructions in this section below are meant for users of 2.4.  I'm now using 2.6 on my machine but I'll leave these instructions here for now.

Until then you will have to download and build the appropriate driver. I'll assume here that you are planning to use dvb-kernel as it supports more devices and are using the 2.4 kernel. For example recent Nova-T cards with a TDA10045 chip are not supported by the older driver.

There are potential problems if you already have analogue capture cards because some of the DVB drivers provide their own versions of modules that are also present in the 2.4 kernel. It may not be possible to get a particular combination of analogue and digital cards to work.

For some cards you must apply specific kernel patches. A recent standard kernel version e.g. 2.4.28 is recommended in most cases unless the patch instructions specify a particular one.

Do not use a kernel modified by your Linux vendor if you need to apply patches. They may conflict with vendor patches and fail to work. If you have any trouble at all building the DVB modules against a vendor kernel try it against a stock 2.4 kernel before complaining to driver mailing lists.

Be careful: Always keep the last good kernel around, never overwrite your only working kernel image even if you have only made a minor configuration change and definitely not if you've applied a patch. A handy boot floppy or rescue CD is another useful piece of insurance.

Check out the current driver from CVS at linuxtv.org by following the instructions given on this page.

Change to the build-2.4. subdirectory and run these commands:
# ./getlinks
# make
This should build the driver and not report any errors. For testing purposes there is no need to install the modules in /lib/modules.

You now need to make sure that the device nodes for DVB are available. You should have a /dev/dvb/adapter0/ directory containg several subdevices e.g frontend0. If they don't exist then create this directory and use the MAKEDEV.SH script (or mknod in a pinch) to create the following devices in it:
crw-rw-rw-    1 root     root     250,   1 May  8 22:25 audio0
crw-rw-rw- 1 root root 250, 6 May 8 22:25 ca0
crw-rw-rw- 1 root root 250, 4 May 8 22:25 demux0
crw-rw-rw- 1 root root 250, 5 May 8 22:25 dvr0
crw-rw-rw- 1 root root 250, 3 May 8 22:25 frontend0
crw-rw-rw- 1 root root 250, 7 May 8 22:25 net0
crw-rw-rw- 1 root root 250, 8 May 8 22:25 osd0
crw-rw-rw- 1 root root 250, 0 May 8 22:25 video0
If you have more then one card then make sure additional adapter directories have been created e.g. /dev/dvb/adapter1 containing:
crw-rw-rw-    1 root     root     250,  65 May  8 22:25 audio0
crw-rw-rw- 1 root root 250, 70 May 8 22:25 ca0
crw-rw-rw- 1 root root 250, 68 May 8 22:25 demux0
crw-rw-rw- 1 root root 250, 69 May 8 22:25 dvr0
crw-rw-rw- 1 root root 250, 67 May 8 22:25 frontend0
crw-rw-rw- 1 root root 250, 71 May 8 22:25 net0
crw-rw-rw- 1 root root 250, 72 May 8 22:25 osd0
crw-rw-rw- 1 root root 250, 64 May 8 22:25 video0
Now load the modules with the script provided:
# ./insmod.sh load
This may print errors as it attempts to load all the DVB modules. The ones that don't match your hardware will fail to initialise. That's not a problem as long as the correct driver did work. To find out what's happened run:
# dmesg
Look for a line that indicates your DVB hardware was initialised and also most importantly that the 'frontend' for your DVB card was also registered. Why? Because the hardware variants usually have different frontends. If you don't have a supported frontend chip then the card will not work, even though the driver detects and registers the adapter.

For example with my recent model Nova-T card: I see this
DVB: registering new adapter (TT-Budget/WinTV-NOVA-T  PCI).
tda1004x: Detected Philips TDA10045H.
tda1004x: Detected Philips TDM1316L tuner.
DVB: registering frontend 0:0 (Philips TDA10045H)...
The format may be different for other drivers but the same information should be present.

Do not proceed past this point if your card is not initialised. It probably means your card is not supported or needs a kernel patch / additional  configuration. Your first course of action should probably be to search the DVB mailing list archives for posts by people in a similar situation.

If your card has been succesfully detected and initialised then we can move on.

Test Scanning and Tuning of Channels

Connect an aerial to your card before proceeding with the next steps (for DVB-T) or connect up your satellite or cable equipmnent as appropriate.

Note: An external aerial is strongly recommended for DVB-T. A set top aerial will only work in areas of high signal strength. Unless you live right under a transmitter I don't rate your chances of success very highly. In the UK you can get a prediction of your reception quality. This is only a guideline but may be useful. For my location the result is "Aerials for FREEVIEW reception must be in good condition".

Now you need to install some utilities to tune your card. These are not required by MythTV but are needed to get you going.

We'll be using a program called scan in combination with tzap. For DVB-S or DVB-C the programs are szap and czap respectively.

To add some confusion these applications are not shipped with the dvb-kernel driver. You will need to check out the DVB module (from the same place as before) and build that software.

Now change to the apps/scan directory under where the package was compiled. Run the scan utility like this:
# ./scan dvb-t/uk-CrystalPalace > channels.conf
If there is no frequency file for your area then you can easily create one. In the UK a list of DVB-T transmitter frequencies can be found at the BBC Reception website.

If everything is ok then the channels.conf file will contain the list of channels the card found by scanning what's been transmitted. If there is a predefined list for your transmitter then compare it to the output you got from the above command.

Once you have a good channels .conf create a directory under your home directory called .tzap, .szap or .czap and copy the channels.conf file there. This is also the information you'll need later to configure MythTV so you may want to print it out for reference.

Now pick a channel e.g. in the UK we can use BBC ONE and in one window do this:
# tzap "BBC ONE" (or szap or czap)
Leave this running and watch for the magic word FE_LOCK to appear in the output. This means the DVB card is receiving data correctly and is locked onto a valid DVB signal. This normally appears within a couple of seconds.

Now the card is tuned we can proceed to view one of the MPEG streams being broadcast.

To to this we'll need a combination of dvbstream and mplayer. We'll use dvbstream to demultiplex the stream and mplayer to display it.

Check out the latest CVS for dvbstream and build it. Do not use the .tar version as it is out of date. Either download the latest MPlayer version or install an appropriate RPM etc. for your distribution. It's also been brought to my attention that you don't strictly need tzap as dvbstream can do the tuning for you. Anyway, I've documented what worked for me at the time I did it.

Now look at your channels.conf file for the channel you tuned above. For my setup on the Crystal Palace transmitter this line looks like:
BBC ONE:505833330:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_3_4:FEC_NONE:QAM_16:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE:600:601
The last two numbers are the IDs of the video and audio stream within the multiplex. We also need the transmission parameters to feed to dvbstream. The command I would use for the channel above is this:
# dvbstream -o -ps -qam 16 -cr 3_4 600 601 | mplayer -
You'll need different options if you have DVB-S or DVB-C. See the documentation for dvbstream.

The result should be a perfect DVB picture of your chosen channel. It should not stutter or break up and the audio should be clean. It's just possible that occasional artefacts may appear but they shouldn't be very noticeable. If the video breaks up, has major colour problems, has a very low frame rate or is corrupt then there is something wrong.

If you have more than one card in your system you can now repeat the tuning and display process for each. E.g. I have a second dvbcard so I would do:
# tzap -a 1 "BBC ONE"
# dvbstream -c 1 -ps -qam 16 -cr 3_4 600 601 | mplayer -
If you can't get a proper video stream displayed then there is no point going any further to configure MythTV and you should concentrate on finding out what's wrong.

Some Troubleshooting Suggestions

Signal strength and aerial quality

If you're using DVB-T then this is a factor. It's hard to check this without additional equipment. If your analogue TV quality is also poor then it may be worth having your aerial checked out. The DVB hardware shows the signal strength when you run tzap. If it's high then this isn't the problem.

If you can borrow a Set Top Box for a couple of days then you can use this as a doublecheck. If this is able to display a picture correctly then signal strength can again be ruled out.

PCI issues

These do occur with some chipsets and motherboards because of the PCI transfer settings used by the DVB drivers. The large amounts of data shipped around for DVB can expose problems that would not otherwise be noticed. Check your BIOS PCI settings. If there is an option for 'Delayed Transaction' or something that's equivalent then make sure it is turned on.

You may be able to improve matters by changing the PCI settings of the board for the Latency Timer. I mention this in part 2 when I talk about my experiences with a new motherboard.

If you have a motherboard and chipset that suffers from this problem then I'm afraid there isn't a great deal else that you can do about it. Be careful in that it can cause data corruption during the transfers and this can be similar to that with faulty memory. It's a good idea to run comprehensive memory tests before throwing the motherboard out.

Faulty memory

This can create infuriating problems that are hard to track down. The best bet here is to download MemTest and let it run for a few cycles. If this succeeds then memory problems can pretty much be ruled out.

Unsupported hardware variant

New cards do come out from time to time and you might be an unwitting early adopter. Search the mailing list for information on people with the same card. You might need the numbers from the chips on the card and it's worth doing an lspci -vn for the numeric PCI identifiers of the card.

Like I sais earlier for users of later model Nova-T cards with the Conexant chips on them (check the output of lspci) Richie Jarvis has a page on getting them to work that may well be useful to read and follow before continuing with the rest of this..

Setting up MythTV for DVB

Now we can move on to Part 2 where we start to configure Myth to use the DVB card.

Martin Smith
Last Updated March 2005
. Hosted with the nice people at clued up hosting.