Search:  
Gentoo Wiki

TV_Tuner

Contents

Introduction

Installing a TV tuner in Linux is quite simple. All you really need to do is activate the correct kernel parameters and emerge some software and it should "just work".

Configuring the kernel

Get into the kernel configuration as normal (i.e. cd /usr/src/linux && make menuconfig).

Linux Kernel Configuration: Kernel 2.6
 Device Drivers --->
      Multimedia Devices --->
        <M> DVB for Linux
        [*] Load and attach frontend and tuner driver modules as needed
        [*] DVB/ATSC adapters -->
          ... select your adapter in this section ...
        [ ] DAB adapters

To start off you must activate DVB support: Navigate to "Device drivers" -> "Multimedia Devices" and activate "DVB for Linux" either as built in or a module. Remember that if you choose this as a module you must either modprobe it every time you want to use it or add it to /etc/modules.autoload.d/kernel-2.6.

Next you must add drivers for your specific card under the "DVB/ATSC adapters" section. I selected the bt848 driver for my Hauppauge WinTV Go, this driver is for boards with the Brooktree Bt848/848A/849/878/879 chips, it may be worth noting that the cx2388x driver, which is marked as the successor for the bt878, does not work with bt878 boards. The bt848 driver requires I2C support, so if you can't find the bt848 driver in your menu enable I2C first, under "Device drivers" -> "I2C support".

Now all that is left is to save the new configuration and then to recompile the kernel (i.e. make && make modules_install), not forgetting to copy the compiled kernel to wherever it is kept for booting.

LinuxTV (v4l-dvb)

If your card is not supported by the current kernel yet, you can try out the latest version of LinuxTV from the v4l-dvb repository. Firstly, emerge mercurial: emerge -av dev-util/mercurial.

Since you must repeat these operation every time you compile a new kernel, you can keep the sources in /usr/src/. Yyou can choose a different directory as well.

Code: Compiling v4l-dvb from source
cd /usr/src/

Then, you have to synchronize your (actually empty) sources:

Code: Compiling v4l-dvb from source
hg clone http://linuxtv.org/hg/v4l-dvb
cd v4l-dvb

Enable the drivers you need. Since everything is marked as module, if you're not in hurry and you don't have a tiny hard disk, you can also compile everything (the default way).

Code: Compiling v4l-dvb from source
make menuconfig
make && make install

DVB channel scan

If you have a DVB card, then you cannot use tvtime. Two other options are mplayer and xine, but first you will need to create a channels.conf file. Also, you will need to make sure that whatever package you are using has been emerged with the appropriate use flags, i.e. DVB support.

To do this, first we emerge linuxtv-dvb-apps. Note that if you have a USB card, you may compile it with the USE flag usb.

This will install several small and useful utilities, the one we will be using is dvbscan. Next, navigate to /usr/share/dvb/dvb-t/ - this will have a number of files in it, you need to find the transmitter nearest to you. For example, my closest transmitter is the one at Crystal Palace, so I need the file uk-CrystalPalace. If you don't know your nearest transmitter and you're in the UK, head over to the UK digital TV reception predictor and type in your postcode, then your nearest transmitter will be displayed. If there is no transmitter file for your location, emerge the w_scan utility to bootstrap dvbscan (w_scan searches the whole DVB-C/DVB-T range for used frequencies):

emerge media-tv/w_scan
Note: Use w_scan's option -f to specify DVB/ATSC type:

VDR

Once w_scan has been emerged we can create our own frequency file:

w_scan -x > dvb_frequencies

dvbscan will be used for scanning while w_scan generated the initial tuning data. Now we can pass this transmitter data to dvbscan, and it will create a channels.conf file for us. This will create a channel list that is compatible with VDR:

Code: Scan for channels with initial tuning data
dvbscan dvb_frequencies > channels.conf

Since w_scan is a complete blindscanner for DVB-T/DVB-C/ATSC, it may also generate the channels.conf directly:

Code: Scan for channels without initial tuning data
w_scan > channels.conf

tzap/czap, Xine, VLC, MPlayer

If you need a channel list that can be used for tzap/czap, Xine, VLC and MPlayer, you need to set the parameter -X:

Code: Scan for channels
w_scan -X > channels.conf

Then copy the resulting file (channels.conf) to the application directories:

Code: Scan for channels
# tzap
mkdir -p ~/.tzap/
cp channels.conf ~/.tzap/

# Xine
mkdir -p ~/.xine/
cp channels.conf ~/.xine/

# MPlayer
mkdir -p ~/.mplayer/
cp channels.conf ~/.mplayer/

Kaffeine

Kaffeine channel lists have a different format. Here is how to create the channel list for Kaffeine:

w_scan -k > channels.dvb

Watching TV

I recommend TVtime to anyone wanting to watch TV, whether you want a PVR solution or not, TVtime will at least allow you to reliably test your setup. This is where you come to really appreciate Gentoo's style. Simply type emerge tvtime as root, and voila (emerge --pretend --verbose tvtime if you want to check dependences and use flags).

Now just type tvtime as a regular user (it's a good idea to do this in a console under X, as if there are any problems the text output of tvtime could be very useful at this stage) and use the OSD menus to set up your channels.

There are other useful packages in portage, such PVRs as Freevo or MythTV and XMLTV for TV listings.

Xine

You may use your card with the Xine player. You must have dvb in your USE flags defined so that emerge --ask --verbose xine-lib xine-ui compiles the dvb-plugin for Xine.

After putting a channels.conf in ~/.xine you can start xine, with a click on dvb you should be able to watch TV now. To switch beetween the channels you can try to use your mousewheel, or deactivate Numlock and use the keys 8 and 2.

Xine can then be launched and clicking on the dvb button should display your television.

MPlayer

Be sure you have compiled MPlayer with the USE flag dvb.

mplayer "dvb://channel name"

This should provide the output of whatever channel name you selected. These can be found in the channels.conf file.

VLC

Be sure you have compiled VLC with the USE flag dvb.

vlc channels.conf

tzap channel list

Tune a frequency and program first.

tzap -r "channel name" &

Then watch the current channel using MPlayer or Xine like this:

EPG

tv_grab_dvb dumps the DVB EPG information in a XMLTV format.

Code: Compiling tv_grab_dvb from source
cd /usr/src/
svn co http://www.darkskiez.co.uk/svn/tv_grab_dvb/trunk tv_grab_dvb
cd tv_grab_dvb
make
cp tv_grab_dvb /usr/bin/

To uninstall tv_grab_dvb, delete tv_grab_dvb from /usr/bin/ and the source directory:

Code: Uninstall tv_grab_dvb
rm /usr/bin/tv_grab_dvb/
rm -rf /usr/src/tv_grab_dvb/

You can pipe the EPG data into a file like this: tv_grab_dvb > whatson.xml.

Recording

Saving the TS stream (MPEG-2)

Tune a frequency and set up device for TS recording.

tzap -r "channel name" &

Saving the stream:

If you want to use a different video PID/audio PID, you can use dvbstream:

Instead of using a combination of *zap and dvbstream, you can use dvbstream alone provided you pass which frequency to tune and list the correct PIDs. For example:

Using mencoder (MPEG-2)

mencoder "dvb://channel" -o output.mpg -oac copy -ovc copy -of mpeg -mpegopts format=dvd

Using mencoder with transcoding (x264)

mencoder "dvb://channel" -oac copy -ovc x264 -x264encopts threads=auto:bitrate=896:subq=3:me=hex:frameref=3:bframes=3 -vf scale=464:352 -o output.avi -frames $((25*60*95))

Troubleshooting

If Video4Linux is correctly configured you should have many "Video(x)" devices in /dev.

If the driver is correctly installed cat /dev/video0 should output infinite garbage (press Ctrl+C to stop). Otherwise you will get /dev/video0: No such device, in which case you may have selected the wrong driver, the card may not be supported...

With DVB cards, there should be a device registered at something similar to /dev/dvb. However, this is not a video device, it is actually a directory containing the components of the card.

Typing dmesg as root can provide useful information as to whether the card was detected. With a PCI card, you would see references to the board by typing lspci as root, this is also very useful in determining the correct driver. Typing dmesg (replacing Hauppage with the card brand/name or its kernel module name) will strip the dmesg output down, just providing information on your TV tuner.

If a DVB card has been successfully registered, dmesg should output (somewhere) registered new device at /dev/dvb (or something similar).

If you have a problem with firmware, whereby dmesg just reports found a $cardname in cold state, attempting to load firmware and you dual boot with Microsoft Windows, try booting into Microsoft Windows first, activate the device, then reboot into Gentoo. While not a great fix, it can be useful if you dual-boot and you are having big firmware problems.

See also

Retrieved from "http://www.gentoo-wiki.info/TV_Tuner"

Last modified: Sat, 11 Oct 2008 12:13:00 +0000 Hits: 26,406