Configuring your webcam to work under Linux

18489

By Bruce Byfield

The best scenario for configuring a webcam is when you buy an external one. Numerous sites exist for different manufacturers and models, and a Web search can often tell you whether GNU/Linux supports a given webcam. In most cases, you probably won’t find much information on the manufacturer’s site, but you will generally find community-built sites, often complete with user comments. Howard Shane’s The Webcam HOTO, while showing its age in some ways, includes many useful links for consumers. For FireWire cameras, try The IEEE1394 Digital Camera List, which is maintained by Damien Douxchamps.

An especially useful site is Michel Xhaard’s A Free World, whose Spca5xx drivers are starting to find their way into the repositories of major distributions, including Debian. If your driver is listed on this site and your distribution includes packages for these drivers, then your webcam may be configurable automatically when the packages are installed, with little or no effort on your part.

However, at times — especially with a laptop — you may be working with a built-in webcam that, chances are, was not your main consideration when you purchased, or with a distribution that doesn’t include driver packages. In such cases, a Web search on your computer model may turn up information on how to set up the webcam.

More often, you will have to obtain information about the camera directly from the computer. You have several ways of doing so:

  • Test the camera using a suitable program (see below). If it works, then your camera is one of those directly supported by the kernel. This scenario is uncommon today, but you might get lucky.
  • Use the command dmesg | more to see whether the camera was detected during bootup. Should you find a reference to it, then search /lib/modules for the /usb subfolder and see if a loadable kernel module exists for it (you may have make a reasoned guess from among those listed). The exact position of this subfolder varies with the distribution; in Debian, it is /lib/modules/kernel/build/drivers/usb, while in Fedora 7 it is /lib/modules/kernel/kernel/drivers/usb.
  • These days, the most likely possibility is that you have a USB camera. Use lsusb or, if your distribution includes it, the graphical tool v4l2-tool to see a list of USB devices. Locate the camera through its name, a process of elimination, or guesswork, and record the eight-digit number with a colon in the middle in the last column of its listing. This number identifies the vendor and product ID, which you can use to find a possible driver on the Internet. If you are using v4l2-tool, then entering the IDs on the Suggest Driver tab may even give you the name of a suggested driver. Armed with this information, you can search the Internet for the driver, then download and compile it. In some cases, you may have to download dependencies first. For instance, for the Ricoh R5U870 driver, you will have to install a Dynamic Kernel Module Support (DKMS) package as well.

In the case of the Ricoh R5U870, having DKMS enabled means that the driver can be automatically installed as soon as it is successfully compiled. Conceivably, you might have to install the driver via a kernel patch, although that should be rare unless you have an older webcam. Most of the time, when you have the driver ready, you will have to use modprobe drivermodulename to load it into the kernel. When you are satisifed that it works, add the driver name to /etc/modules or the line modprobe drivermodulename to /etc/rc.d/rc.local to enable the camera at boot time.

Testing

Having come this far, you are over the worst, but some difficulties may still be waiting in ambush as you prepare to test. Depending on the distribution, you may need to use the addgroup command to add a new video group, and to add user accounts to the group in /etc/group so that everybody can use the camera. In addition, you should test the webcam with a variety of programs, such as CamStream, Ekiga, and Kopete, because one of them may not work with your particular camera or its driver. In some cases, upgrading to a newer version of a program may suddenly give you support.

If you use DKMS to install a webcam driver, you may find that another peripheral stops working (in my case, it was the wireless card enabled by Ndiswrapper). This problem may persist if you reboot, but miraculously vanish if you shut down the machine and restart. If it doesn’t, uninstalling whatever has stopped working and reinstalling it may be a solution.

Conclusion

Unavoidably, this article provides only a starting point. Not only are webcams available in an overwhelming array of manufacturers and models, but many are rebrandings of other cameras sold under a different name, and individual cameras sold as the same model may differ internally.

Nor, like many hardware makers, do the manufacturers of webcams show much interest in releasing GNU/Linux drivers. That means that many of the drivers that exist are the work of community developers doing reverse engineering, many of whom seem never to have considered standardizing their work with that of others.

For these reasons, many details have to be left to the particular camera and module. However, for many users, the problem is not that webcam configuration is difficult so much as the fact that they lack an overview. Perhaps with the resources and circumstances given here, you can start the process knowing what you might be in for, and, when one alternative fails, what other approaches you can try.