|[Home] [Credit Search] [Category Browser] [Staff Roll Call]||The LINUX.COM Article Archive|
|Originally Published: Monday, 18 June 2001||Author: Dave Madeley|
|Published to: develop_articles/Development Articles||Page: 1/1 - [Std View]|
Using Your Brooktree Chipset TV Card in Linux
This week Linux.com contributor Dave Madeley looks at what it takes to watch TV on your Linux box equipped with a TV capture card. We take a look at kernel compilation, video devices and configuration. Finally Dave takes a look at some applications you can use to watch TV, listen to the radio or even check out Teletext.
The Brooktree chipsets TV cards (BT848 and BT787) are fully supported under Linux using the bttv drivers. Many popular TV cards are supported under bttv including: Lifeview Flyvideo cards, Hauppauge cards, Micro Cards and any other Brooktree based cards. In this article we'll take a look at what it takes to turn your Linux box into a fully functional television. My Linux distribution is RedHat 6.1 running on a P200MMX with a Lifeview FlyVideo 98FM
The bttv driver can be downloaded as compile-able modules from http://bytesex.org/bttv/. These can be plugged into any kernel (I originally tried with the 2.2.12-20 and 2.3.3 kernels). You could go that route too, but it is not the easy way to go. Due to new kernel features (such as the I2C interface) it is much easier to download the latest kernel and that way everything is compatible. Currently the latest kernel is 2.4.4 that can be downloaded (if you haven't got it already) from the Kernel Archives. You will also require the new modutils-2.4.4, also available at the archive.
If you are new to compiling kernel source then you might check out the Kernel HOWTO. If you're fairly confident then the README and the included documentation should be sufficient. When configuring the options for your kernel the following are required in order for your TV card to work (it is easier in the long run to compile these as modules, therefore make sure you include modular code support and the kernel auto loader).
Ensure these options are compiled as modules (m):
- I2C Core
- I2C Devices
- I2C Algorithms (this should be all I2C items)
- Video4Linux (v4l) API driver
- Bttv drivers (this includes all the required modules for TV, radio and teletext)
- Bttv mixer device (from the sound section)
Compile your kernel, the modules and install the lot ready for booting. If you upgraded from an earlier kernel and were told to rename conf.modules to modules.conf then do so. After doing this you will have to edit your SysV scripts:
# kwrite /etc/rc.d/rc.sysinit
Find the lines referring to any modules that are loaded on boot (usually sound and midi) and change all references to conf.modules to modules.conf. Reboot your machine.
If everything goes to plan we're almost there. If you are using a S3 Trio 64 chipset video card (like my ASUS) then it is also recommended that you upgrade to Xfree86 4.0 (do this anyway). You can get the new version of XFree86 (4.03) from http://xfree86.org. When downloading XFree86 download the script Xinstall.sh from /linux-libc5/ first. This will tell you which distribution to download.
$ cd [XFree86 download directory]
# sh Xinstall.sh -check
It will tell you your running Linux, kernel 2.4.4 on an i586 or something similar and then indicate which distribution you should download. In my case it was linux-glibc21. The files FILES will tell you which files you need, because you don't need them all! Follow the documentation to install XFree86.
Next we need to create video devices in our /dev directory and add options to modules.conf for the bttv modules.
$ cd /usr/src/linux/Documentation/v4l/bttv/
This will create quite a number of v4l devices. Now we need to edit modules.conf to add our bttv options.
$ kwrite Modules.conf &
# kwrite /etc/modules.conf &
Copy the lines from the example to the real thing. You might want to add some comments so this section is easily identifiable later. In your terminal type:
$ cat CARDLIST |more
This produces a list of cards and tuners supported by bttv. Write down the numbers of the possible cards (there should be just one) and possible tuners (there could be a few possibilities if you don't know).
On the line that says:
options bttv card=1 radio=1
change it to:
options bttv card=[card no] radio=[1/0] tuner=[tuner no]
in my case:
## Fly Video 98 FM ##
options bttv card=56 radio=1 tuner=5
Here is my modules.conf:
alias eth0 ne2k-pci
alias sound sb
alias midi opl3
options opl3 io=0x388
options sb io=0x240 irq=10 dma=1 mpu_io=0x330
alias char-major-89 i2c-dev
options i2c-core i2c_debug=1
options i2c-algo-bit bit_test=1
alias char-major-81 videodev
alias char-major-81-0 bttv
alias char-major-81-64 bttv ##radio loader
alias char-major-81-224 bttv ## teletext loader
options bttv card=56 radio=1 tuner=5
options tuner debug=1
Save and exit then check the module dependencies:
# /sbin/depmod -a
If you have chosen a wrong value then you may have to fiddle around till you get it right. Go to a terminal (no in X, X is not very verbose when dealing with modules)
# /sbin/modprobe bttv
You should receive a screen of data informing you of the events taking place and that everything happened successfully. It may inform you that overlaying has been disabled, take note of this.
Now what? Now we need some applications to grab our newly compiled imaging capabilities. The TV application is XawTV (http://bytesex.org/xawtv), the XawTV source package has a number of programs in it. XawTV (a TV viewing program for X), FbTV (another TV viewing program which uses the frame buffer, unless you compiled frame buffer support I wouldn't worry about this one), a ncurses radio application (if your card has radio features this can control them), a video capture application and an ftp based web cam. If you can install RPMs the easiest way to install these is by compiling the source into RPMs:
# rpm -tb xawtv-3.43.tgz
Several packages will be generated and you can choose the ones you want. Install the packages you want (or take them all if you like to use wildcards).
We're almost there; we need to create a configuration file for XawTV. While XawTV can do this to some extent itself, it is easier for us to write the preliminary one from scratch. The configuration file is called ~/.xawtv. Check out the manual pages for most of the features that can be written into the config file, but mine looks like this:
freqtab = australia #set this appropriately
pixsize = 128 x 96
pixcols = 1
jpeg-quality = 75
mjpeg-quality = 50
keypad-ntsc = no
osd = yes #on screen display
mixer = line #this is the sound device your card is attached to
ratio = 4:3
fullscreen = 768x576
# [Station name]
# capture = overlay | grabdisplay | on | off
# input = Television | Composite1 | S-Video | ...
# norm = PAL | NTSC | SECAM | ...
# channel = #
# fine = # (-128..+127)
# key = keysym | modifier+keysym
# color = #
# bright = #
# hue = #
# contrast = #
norm = PAL #set this to suit
input = Television
capture = grab #remember whether or not your board
[ABC] #supported overlay?
channel = 2
key = F2
channel = 7
key = F7
channel = 9
key = F9
channel = 10
key = F10
channel = 28
key = F11
channel = 31
key = F12
Run XawTV by typing xawtv into the xterm command line. It should report your kernel version, bttv version, windows manager and information on your display features. Then give you the goods.
If you are having problems first check you're using a suitable capture mode. If you're getting static then you probably have the wrong tuner selected. Play around till you get it right, the manuals give lots of information on the config file settings.
Write a script (or make an alias, or type this into your launcher command line) that executes the following command to disable your screensaver while watching TV. (if you have xscreensaver, of course!)
xscreensaver-command -exit;xawtv;xscreensaver -no-splash &
Finally you'll want to configure your radio. The radio application included with XawTV is ncurses based and will run off kradio configuration files. If you don't have kradio you can create a file called ~/.radio:
1=94500000 #Frequencies are in Hz so this is 94.5MHz
94500000=The Mix 94.5 #Name the Stations here
As well as kradio there is Gradio if you don't have either of these try searching Freshmeat.
What about Teletext? The most popular teletext program is AleVT, you can download this from http://lecker.essen.de/~froese. There is also a GNOME Panel applet for GNOME Users, you can get this from: http://people.debian.org/~mvo/xawtv_applet.
You should now have a fully functional LinuxTV, I hope this helps in some way. If not you can always go back to the large amount of included documentation, plus try these sites:
The next step is for someone who is good at C (I am not) to write an applet that provides support for the remotes provided with some cards, so bug your friends: someone must be up to the challenge!