I'm Ready for my Cam Closeup

When I started, I had no idea what should happen when a cam is plugged in and what has to be done to make it work. That's a bit like flying blind to a target unknown--frustrating indeed. It would have been immensely helpful if I had some idea of what the end result ought to be.

What I now know is that it all works automagically--provided the necessary driver modules are bundled with the kernel and the hotplug agent is properly set up. I was using Mandrake 9.1 so both were true. Thus, the challenge mostly is in selecting the cam device.

(Note: If you have trouble seeing the listings below, hit "switch to printable format" at the bottom of the page.)

Here is a rough description of what you should expect when you install your cam:

  • Plug the cam into the USB port.
  • The kernel detects the insertion and invokes the hotplug agent. The hotplug process (hopefully) recognizes the cam type and loads the required device modules.
  • You should be able to see this process in the /var/log/messages file. Here is an example:
    kernel: hub.c: new USB device 00:07.2-1, assigned address 3
    kernel: usb.c: USB device 3 (vend/prod 0x5a9/0xa511) is not claimed by any active driver.
    /etc/hotplug/usb.agent: Setup ov511 for USB product 5a9/a511/100
    kernel: i2c-core.o: i2c core module version 2.7.0 (20021208)
    kernel: Linux video capture interface: v1.00
    kernel: usb.c: registered new driver ov511
    kernel: ov511_main.c: USB OV511+ video device found
    kernel: ov511_main.c: model: Generic Camera (no ID)
    kernel: ov511_main.c: i2c write retries exhausted
    kernel: ov511_main.c: I2C write error (-1)
    kernel: ov511_main.c: Sensor is an OV6620
    kernel: ov511_main.c: Device 3 on bus 1 registered to minor 0
    kernel: ov511_main.c: v2.16 : ov511 USB Camera Driver
    
  • Here is an example of what an unsupported cam looks like:
    kernel: hub.c: new USB device 00:07.2-2, assigned address 5
    kernel: usb.c: USB device 5 (vend/prod 0x46d/0x810) is not claimed by any active driver.
    /etc/hotplug/usb.agent: ... no modules for USB product 46d/810/100
    
  • After a successful hotplug, you should have both a cam driver module and the videodev driver module loaded into the kernel. I verified this for my ov511 cam by doing:
    $ /sbin/lsmod | grep ov511
    ov511                105580   0
    videodev               7872   1 [ov511]
    i2c-core              21192   0 [ov511]
    usbcore               72992   1 [ov511 usb-uhci]
    

    I knew I needed to search for ov511 by looking at the messages log to find which driver was registered.

  • The videodev module should have created the appropriate nodes in the /dev directory.
    $ ls -l /dev/v4l/* /dev/vid*
    crw-------    1 chip     sys       81,   0 Dec 31  1969 /dev/v4l/video0
    lr-xr-xr-x    1 root     root           10 Oct 14 10:31 /dev/video -> v4l/video0
    lr-xr-xr-x    1 root     root           10 Oct 14 10:31 /dev/video0 -> v4l/video0
    

    Notice how the cam hotplug script was clever enough to give me ownership of the video0 device.

  • At this point you should be ready to crank things up. I found xawtv and camstream to be useful utilities for testing the cam. Mandrake 9.1 includes RPMS for both. For my application, I'm using the webcam utility that's part of the xawtv package.

See, wasn't that easy? The tough part is yet to come: selecting a compatible cam.

There is an online database of USB cams that are supported by Linux. It was useless for this task. Most of the entries are for devices you can't find in the store, and current models are frequently not listed. Moreover, the data are user-contributed and not verified, and thus suspect. For instance, is the Ezonics USB Cam II compatible or not? The database provides conflicting answers. It doesn't can't seem to agree on the name of the device, let alone whether or not it works. (Answer: this cam was made with three different chipsets. Some work, others don't.)

The best solution for finding a compatible device is to visit the web sites for the various cam drivers. These sites will tell you which web cams are supported and provide any necessary documentation you might need to get it going. Here are some of the driver sites I visited:

  • pwc - Phillips Webcam. This driver supports the current mid-to-upper end Logitech cams, among others. The driver is included with Mandrake 9.1. The compressor module is not! More on that in a sec.
  • qce - Logitech QuickCam Express. The driver module actually is called mod_quickcam and is included in Mandrake 9.1.
  • Mandrake 9.1 also includes the following drivers for older and lower-end cams: cpia and ov511

I ended up selecting the Logitech QuickCam Zoom and I'm delighted with it. It provides clear, sharp images at resolutions up to 640x480. I'm surprised at how well it does in low-light situations. It is supported by the pwc driver, so Mandrake recognized it.

There was just one tiny problem: at anything but the smallest image sizes you get nothing but a green image. That's because at the larger sizes the cam compresses the image, and decompression is handled by a separate pwcx module. That module is not provided with Mandrake Linux because it's not available in source form. The author had to sign a non-disclosure to get the specs. He provides a binary version at his web site. So, I download the module and installed it manually.

Here is what I did:

  • Download the pwcx and unbundle the archive.
  • Run:
    # cp usb-pwcx-8.2.2/x86/gcc-3.2/pwcx-2.4.20.o /usr/local/webcam/pwcx-i386.o
    
  • Add a line to the end of /etc/modules.conf that says:
    post-install pwc /sbin/insmod --force /usr/local/webcam/pwcx-i386.o >/dev/null 2>&1 || :
    

I'm pleased with how well the cam works under Linux. Under Windows, it's another story. The bloated Logitech crapware trashed my Windows 98 installation. The system now boots up to no taskbar, no icons and no processes running--not even the Windows Explorer. This happens even in safe mode! So, the next time somebody tells you how much easier it is to setup stuff on Windows than it is on Linux, point them here.

Your rating: None

Trackbacks

Trackback URL for this post: http://www.unicom.com/trackback/160