3. Enabling Support for Your Bt8x8 Hardware in Linux

3.1. The Bttv Driver

Drivers for Bt8x8-based hardware have been a part of the Linux kernel since version 2.2.0, and are likely to be already enabled in your running kernel if you have not recompiled or otherwise replaced your system's stock kernel with a custom version. If unavailable, Bt8x8 support can be enabled two ways:

3.1.1. Module or In-Kernel?

It is likely the stock kernel that was installed on your Linux system, if unmodified, already supports Bt8x8-based hardware. The driver will exist either as a loadable module or within the already running kernel. An easy way to tell is to use the dmesg command piped into less (for easy viewing) to look for an acknowledgement that the driver in question was loaded when your system started up:

   $ dmesg | less

...which may yield something like the following, depending on your exact Bt8x8 chipset features and kernel version (in this case, 2.6):

   Jan 26 19:40:04 localhost kernel: bttv: driver version 0.9.15 loaded
   Jan 26 19:40:04 localhost kernel: bttv: using 8 buffers with 2080k 
      (520 pages) each for capture
   Jan 26 19:40:04 localhost kernel: bttv: Bt8xx card found (0).
   Jan 26 19:40:04 localhost kernel: ACPI: PCI interrupt 0000:02:09.0[A] -> 
      GSI 17 (level, low) -> IRQ 17
   Jan 26 19:40:04 localhost kernel: bttv0: Bt878 (rev 2) at 0000:02:09.0, 
      irq: 17, latency: 32, mmio: 0xe7000000
   Jan 26 19:40:04 localhost kernel: bttv0: detected: Hauppauge WinTV 
      [card=10], PCI subsystem ID is 0070:13eb
   Jan 26 19:40:04 localhost kernel: bttv0: using: Hauppauge (bt878) [card=10, 
      autodetected]
   Jan 26 19:40:04 localhost kernel: bttv0: using tuner=2
   Jan 26 19:40:04 localhost kernel: tuner: chip found at addr 0xc2 i2c-bus 
      bt878 #0 [sw]
   Jan 26 19:40:04 localhost kernel: tuner: type set to 2 (Philips NTSC 
      (FI1236, FM1236 and compatibles)) by bt878 #0 [sw]

If you don't see it, the particular driver module you are interested in may be available but not necessarily loaded at that time. If you know what the module is named, try using find; in this example we are looking for the 'bttv' module:

   $ find /lib/modules -name bttv.o

Note that up until the 2.4 series modules had the suffix .o; for 2.6+ series kernels this was replaced with .ko.

You can get a list of all modules available by typing the following at the command line:

 
   $ ls -R /lib/modules/`uname -r`/kernel 

Where `uname -r`, surrounded by forward tick marks, is your kernel version number. The following output is an example of what you might find in a Bttv-ready kernel, where everything is loaded as a module (edited for brevity):

   /lib/modules/2.6.8/kernel/drivers/media/video:
    btcx-risc.ko    ir-kbd-i2c.ko  tda9875.ko  tvaudio.ko      video-buf.ko
    bttv.ko         msp3400.ko     tda9887.ko  v4l1-compat.ko  videodev.ko
    ir-kbd-gpio.ko  tda7432.ko     tuner.ko    v4l2-common.ko

Again, your output may vary by the currently running kernel capabilities.

Once you know which module your hardware needs you can find out if it is already loaded by typing at the command line or in a terminal window:

   # lsmod

As shown by the prompt above, you will need to have root privileges to do this. You should get output similar to, but not necessarily limited to the following:

   snd_bt87x              11400  0
   tuner                  18832  0
   tvaudio                20428  0
   msp3400                22100  0
   bttv                  145804  0
   video_buf              17476  1 bttv
   i2c_algo_bit            8904  1 bttv
   v4l2_common             4928  1 bttv
   videodev                7232  2 quickcam,bttv

Most stock kernels are compiled with kmod, which enables automatic loading of necessary modules when the appropriate hardware is detected. It may not always do so, however, so if you don't have the particular module you're seeking loaded and you think the module may be available, try loading it manually with modprobe, as in the following example (using the bttv module):

   # modprobe -v bttv

3.2. No Bttv module or in-kernel support found?

If your running kernel or precompiled distribution kernel inexplicably doesn't have Bt8x8 support enabled or available, your can always acquire new kernel source code from the Linux kernel.org source code repository. If you are unfamiliar with the prerequisites and procedure of compiling your own kernel, I direct you to the Kernel HOWTO for more information.

If you do recompile, the Bttv driver itself will obviously need to be enabled, and is found in the heading entitled "Multimedia Devices" -> "Video for Linux" in the 2.4 and earlier kernels in menuconfig or xconfig, or alternatively in "Device Drivers" -> "Multimedia Devices" -> "Video for Linux" -> "BT848 Video For Linux" in the 2.6+ series.

Note

You will need i2c subsystem support enabled as well as i2c-algo-bit.

Device support (i2c-dev) is not required for Bt8x8 support. Earlier than kernel version 2.3.34 i2c is not present in the kernel source and a patch must be fetched and applied to your source, found at the lm_sensors homepage.

If you are running a 2.4 series kernel, btaudio in the OSS "Sound" category is optional if you want to use external speakers attached to the the card's audio out jack, and either (or both) OSS or ALSA sound system btaudio drivers in the 2.6+ series.

3.3. Configuration Requirements for Use of your Bttv Hardware

Once you know your kernel is enabled you can proceed to some minor tuning that may already be done for you depending on your system and distributor and distribution features.

3.3.1. Device Files

If you are using Device Filesystem (devfs) or udev your work in this respect may be done for you dynamically, but at the same time the devices may not exist until they are recognized by the kernel (i.e., the necessary modules loaded), so be sure you have taken care of the previously outlined prerequisites first.

The Linux kernel requires a virtual device node be created to access and control a particular piece of hardware. This node may have already been created for you automatically; ls -l /dev/video* (with an asterisk) or alternatively find /dev -name video* or even visual inspection of the /dev directory with your favorite file manager can give you an idea if the video devices exist. If so you can proceed to Section 3.4; if not you will need to create them manually.

An easy way to create them, if available with your Linux distribution, is use of the MAKEDEV script, which may be located in /dev or the usual places for storing executable commands (/bin,/sbin and so on). The manual page for MAKEDEV (man MAKEDEV) can guide you further, but be aware of the device-specific command options. If MAKEDEV doesn't work or doesn't exist, or you just prefer doing things the hard way, move on to the next paragraph.

A device can be created as a block (such as a drive), a FIFO (file-in-file-out or pipe, as in xconsole) or a character device, which represents other hardware. Each device has a major and a minor number "coordinate" to tell the kernel what it is and where to access it. These numbers are not arbitrary. The major number 81 with minor number 0, 1, 2, and so on are by convention assigned to Video4linux devices, including TV tuner boards and webcams. In order to create the video device /dev/video0, use mknod at the command line:

   # mknod /dev/video0 c 81 0

where c represents a character device.

You can use the following script, which I have borrowed from the kernel source (located in linux/Documentation/video4linux/bttv/MAKEDEV of the source tree):

   #!/bin/bash
   function makedev () {
	for dev in 0 1 2 3; do echo "/dev/$1$dev:
	char 81 $[ $2 + $dev ]" rm -f /dev/$1$dev
	mknod /dev/$1$dev c 81 $[ $2 + $dev ] chmod
	666 /dev/$1$dev
   	done

   	# symlink for default device
	rm -f /dev/$1 ln -s /dev/${1}0 /dev/$1
   	}

	# see http://roadrunner.swansea.uk.linux.org/v4lapi.shtml
	echo "*** new device names ***" makedev video
	0 makedev radio 64 makedev vtx 192 makedev vbi 224
	# "*** old device names (for compatibility only) ***"
	#makedev bttv 0 #makedev bttv-fm 64 #makedev bttv-vbi 224

Simply copy and paste the above into your favorite editing program, save it as MAKEDEV or whatever name you like, make it executable (i.e., chmod u+x MAKEDEV), and then execute it as root:

   # ./MAKEDEV

3.4. Groups and Permissions

It is a good idea to be sure that your user account can access the device once all modules are loaded and device nodes created. The most security-conscious way to do that is to add access for a particular group. On my system, the members of the group 'video' are allowed to use the webcam, scanner and other photographic devices. The way to accomplish this is to first change the ownership of the devices in /dev like so (as root):

   # chown root.video /dev/usb/video*

...where root.video are the owner and group the device will now belong to. Obviously, the specific command will vary by your system and the type of device. It is important that you change the ownership of the device node itself and not the symlink; symlinks' ownerships are affected only by changing the parent devices or files they point to.

To see if your user account is a member of the group in question, as root issue the following command:
   # grep -e video /etc/group
You should see something like the following:

   video:x:44:

...where '44' is the group number. Since no members follow the last colon in the 'video' group, we can add them, let's say user 'jhs' with the command

   # adduser jhs  video

After this, it's simply a matter of allowing read and write access for the user in question of the device like so:

   # chmod g+rw /dev/v4l/video0

...where g+rw means add read and write access for group. See the documentation for chmod (man chmod or info chmod) for further info.