Install a TV Tuner

Install a TV Tuner

Turn your Linux computer into a television set.

So you want to make your own digital video recorder (DVR) under Linux, or maybe you just want to watch TV on your computer. As long as the hardware is Linux-compatible, TV tuner installation under Linux really isn't too difficult for most cards. This hack fills you in on what you need to know to install a TV tuner under Linux.

Installation of the popular Hauppauge WinTV cards is covered in "Create a DVR with MythTV" [Hack #77].

The first step is to identify the chipset and Linux module your tuner card uses. If you have a copy of the Linux kernel source tree on your system, look in its Documentation/video4linux directory. Here you will find CARDLIST.bttv and CARDLIST.saa7134 files. Most common TV tuner cards will use the bttv driver, but check both lists and see if you can find your card. The lspci command can give you a clue about which card you have. For instance, here is the output for a machine with a bttv-compatible card:

	# lspci
	0000:00:0d.0 Multimedia video controller: Brooktree Corporation Bt878
	Video Capture (rev 11)
	0000:00:0d.1 Multimedia controller: Brooktree Corporation Bt878 Audio
	Capture (rev 11)

Most modern distributions ship with very modular kernels, so there's a good chance that the bttv and saa7134 modules are already compiled if you are using a stock kernel. If you built your own kernel, go to the Video For Linux section of your kernel config and make sure that Video For Linux support is enabled as a module as well as BT848 Video For Linux, Philips SAA7134 support, or whatever module corresponds to your particular chipset. Then recompile your kernel to create the new modules.

With your TV tuner card installed and Linux booted, load the module that corresponds with your tuner card as root. For this hack I will use the bttv module, since that's the most common:

	# modprobe bttv

With the module loaded, type lsmod and ensure that the tuner module was loaded and, if not, load that as well:

	# modprobe tuner

In your dmesg output, you should see quite a bit of output related to that module being installed:

	# dmesg
	Linux video capture interface: v1.00
	i2c-core.o: i2c core module version 2.6.1 (20010830)
	i2c-algo-bit.o: i2c bit algorithm module
	bttv: driver version 0.7.108 loaded
	bttv: using 4 buffers with 2080k (8320k total) for capture
	bttv: Host bridge needs ETBF enabled.
	bttv: Bt8xx card found (0).
	bttv0: Bt878 (rev 17) at 00:0d.0, irq: 17, latency: 32, mmio: 0xdf040000
	bttv0: detected: ATI TV Wonder/VE [card=64], PCI subsystem ID is 1002:0003
	bttv0: using: ATI TV-Wonder VE [card=64,autodetected]
	bttv0: enabling ETBF (430FX/VP3 compatibilty)
	i2c-core.o: adapter bt848 #0 registered as adapter 0.
	bttv0: using tuner=19

	bttv0: i2c: checking for TDA9875 @ 0xb0… not found
	bttv0: i2c: checking for TDA7432 @ 0x8a… not found
	i2c-core.o: driver i2c TV tuner driver registered.
	tuner: chip found @ 0xc0
	tuner: type set to 19 (Temic PAL* auto (4006 FN5))
	i2c-core.o: client [Temic PAL* auto (4006 FN5)] registered to adapter [bt848
	#0](pos. 0).
	bttv0: PLL: 28636363 => 35468950 .. ok
	bttv0: registered device video0
	bttv0: registered device vbi0

In this case, my bttv card is using /dev/video0, and the bttv module was able to automatically detect the tuner type (tuner=19). Now add these modules to your /etc/modules file so that they are loaded each time the system boots. If bttv isn't able to discover your tuner or card type, you can force the settings in /etc/modules.conf. Look through Documentation/video4linux/CARDLIST.tuner and Documentation/video4linux/CARDLIST.bttv for the card and tuner number that corresponds to your card, and then add the options lines to /etc/modules.conf:

	options bttv card=64
	options tuner tuner=19

If your TV tuner has a line-out jack, be sure to connect it to the line-in on your sound card, and open your mixer and make sure the line-in isn't muted. Otherwise, you won't be able to hear any sound from the tuner.

Now that the card is installed, check out [Hack #74] for information on configuring it for various video4linux frontends.

 Python   SQL   Java   php   Perl 
 game development   web development   internet   *nix   graphics   hardware 
 telecommunications   C++ 
 Flash   Active Directory   Windows