The following guidance might be useful in helping to configure a USB Webcam on a Linux system.
A web camera (or webcam) is a real-time camera whose images can be accessed using the World Wide Web, instant messaging, or a PC video calling application. For summary details about webcams see: http://en.wikipedia.org/wiki/Webcam.
The following notes recount configuration of a Labtech Pro USB Webcam on my Linux Web-server, detailing what worked after much experimentation (and not describing too much about the many blind-alleys, etc, encountered along the way). Jump straight to the drivers section for details.
The ultimate aim of setting up a Webcam to run on my Linux server was to be able to integrate that with the ZoneMinder application so that I could remotely manage and control a suite of webcams from the Linux server. For details about how I installed and configured ZoneMinder to use this, and other Webcams, on my Linux Web-server see my ZoneMinder link.
Later a second USB webcam, a Yht Vimicro ZC301P webcam, was added. Details about the drivers for this webcam are here.
Finally a Logitech QuickCam Deluxe for Notebooks was also acquired for use on a Linux workstation (Acer 4000 WLMi Travelmate laptop PC) on the same LAN as the Linux Web-server. The details for configuring this are also described here. This webcam was not specifically for use with ZoneMinder, but was used with webcam_server.
Investigating the configuration:
# uname -a Linux hostname 2.6.9-42.0.3.EL #1 Fri Oct 6 05:59:54 CDT 2006 i686 i686 i386 GNU/Linux # # date Tue Jan 23 13:53:44 GMT 2007
During this process of investigating, installing and configuring the Labtech Pro USB Webcam a number of kernel commands are of great assistance.
Initially the Labtech Pro USB Webcam on the Linux Server was using the front upper USB port, and this is shown in the following configuration report:
# lsusb Bus 002 Device 003: ID 046d:08a2 Logitech, Inc. Labtec WebCam Pro Bus 002 Device 001: ID 0000:0000 Bus 001 Device 002: ID 148f:2573 Ralink Technology, Corp. Bus 001 Device 001: ID 0000:0000 #
After moving things about a bit to accommodate other peripherals the WebCam and USB WiFi adaptor were put on rear USB ports (Bus 001), with a Bytestor USB memory stick on lower front USB port (Bus 002), and this is as shown below:
# lsusb Bus 002 Device 004: ID 0d7d:1320 Phison Electronics Corp. PS2031 Flash Disk Bus 002 Device 001: ID 0000:0000 Bus 001 Device 003: ID 046d:08a2 Logitech, Inc. Labtec WebCam Pro Bus 001 Device 002: ID 148f:2573 Ralink Technology, Corp. Bus 001 Device 001: ID 0000:0000 #
Checking the configuration for the Labtech Pro USB Webcam device (belwo) shows that it is not currently configured on the system.
# lsmod | grep usb usb_storage 60809 0 scsi_mod 123213 2 sd_mod,usb_storage snd_usb_audio 59681 0 snd_usb_lib 12225 1 snd_usb_audio snd_pcm 97225 3 snd_usb_audio,snd_intel8x0,snd_pcm_oss snd_rawmidi 26853 2 snd_usb_lib,snd_mpu401_uart snd 55973 10 snd_usb_audio,snd_intel8x0,snd_ac97_codec,snd_pcm_oss,snd_mixer_oss,snd_pcm,snd_timer,snd_mpu401_uart,snd_rawmidi,snd_seq_device # lsmod | grep cam #
The details defining a Labtech Pro USB Webcam and appropriate driver are:
Details for: Labtec Webcam Labtec Pro, from http://www.qbik.ch/usb/devices/showdev.php?id=2889 VGA webcam, Category: Video ID 0x046d:0x08a2 Driver spca5xx Linux-USB link http://mxhaard.free.fr Vendor link http://www.labtec.com
The drivers are available from: Linux kernel webcams Driver GSPCA / SPCA5xx and more details in general from http://mxhaard.free.fr/.
Labtec 102 0x046d 0x08a2 Webcam Pro Zc0302 Pas102b Yes jpeg spca5xx/LE ****** Comment Vga webcamera Z-star zc0302 chips jpeg camera 640x480 352x288 native jpeg stream 640x480 352x288 320x240 176x144 palette rgb565 rgb16 rgb24 yuv420p Sound is supported by usb_audio Submitted by Xhaard Michel ( mxhaardfree.fr ) Submitted on Fri, 08 Oct 2004 21:06:05 +0200 Last edited on Tue, 28 Dec 2004 17:28:30 +0100
A number of other driver options were initially tried for the Labtech Pro USB Webcam but none of these could be made to work. Examples, including the various failure/error messages encountered, are described in abandoned drivers.
A second USB webcam, a Yht Vimicro ZC301P USB Webcam, was acquired for use with the Linux Web-server.
Searching the web for a suitable driver indicated that the already installed spca5xx-20060501 was the correct driver to use. It was, however, found that pluging this webcam to the same bus as the orginal webcam (Labtech Pro USB Webcam above) resulted in the system hanging. Therefore this second webcam was connected to the front USB ports and this allowed the webcam to be successfully accessed (by gnomemeeting).
# lsusb ... Bus 002 Device 002: ID 0ac8:301b Z-Star Microelectronics Corp. ZC0301 WebCam Bus 002 Device 001: ID 0000:0000 Bus 001 Device 003: ID 046d:08a2 Logitech, Inc. Labtec WebCam Pro Bus 001 Device 002: ID 0409:0059 NEC Corp. HighSpeed Hub Bus 001 Device 001: ID 0000:0000 #
It also has been successfully configured to be used by ZoneMinder which is the main reason for attaching the webcams to the Linux server.
# lsmod | grep video videodev 10049 1 spca5xx # dmesg | less .... lots snipped out ... usb 1-1: new full speed USB device using address 2 usb 1-2: new full speed USB device using address 3 hub 1-2:1.0: USB hub found hub 1-2:1.0: 4 ports detected Linux video capture interface: v1.00 /usr/local/src/spca5xx-20060501/drivers/usb/spca5xx.c: USB SPCA5XX camera found. Type Vimicro Zc301P 0x301b /usr/local/src/spca5xx-20060501/drivers/usb/spca5xx.c: [spca5xx_probe:5480] Camera type JPEG /usr/local/src/spca5xx-20060501/drivers/usb/zc3xx.h: [zc3xx_config:527] Find Sensor PB0330 /usr/local/src/spca5xx-20060501/drivers/usb/spca5xx.c: [spca5xx_getcapability:1765] maxw 640 maxh 480 minw 176 minh 144 usbcore: registered new driver spca5xx /usr/local/src/spca5xx-20060501/drivers/usb/spca5xx.c: spca5xx driver 00.60.00 registered usb 1-2.1: new full speed USB device using address 4 /usr/local/src/spca5xx-20060501/drivers/usb/spca5xx.c: USB SPCA5XX camera found. Type Labtec Webcam Pro Zc0302 + Hdcs2020 /usr/local/src/spca5xx-20060501/drivers/usb/spca5xx.c: [spca5xx_probe:5480] Camera type JPEG ACPI: Power Button (FF) [PWRF] /usr/local/src/spca5xx-20060501/drivers/usb/zc3xx.h: [zc3xx_config:543] Find Sensor PAS202BCB /usr/local/src/spca5xx-20060501/drivers/usb/spca5xx.c: [spca5xx_getcapability:1765] maxw 640 maxh 480 minw 176 minh 144 usb 1-2.1: control timeout on ep0in usb 1-2.1: control timeout on ep0in EXT3 FS on hda9, internal journal device-mapper: 4.5.5-ioctl (2006-12-01) initialised: dm-devel@redhat.com .... lots snipped out ... eth0: no IPv6 routers present Installing knfsd (copyright (C) 1996 okir@monad.swb.de). application firefox-bin uses obsolete OSS audio interface /usr/local/src/spca5xx-20060501/drivers/usb/spca5xx.c: [spca50x_isoc_irq:1506] Non-zero status (-84) in isoc completion handler. /usr/local/src/spca5xx-20060501/drivers/usb/spca5xx.c: [spca50x_isoc_irq:1506] Non-zero status (-84) in isoc completion handler. usb 1-1: USB disconnect, address 2 usb 1-1: new full speed USB device using address 5 /usr/local/src/spca5xx-20060501/drivers/usb/spca5xx.c: USB SPCA5XX camera found. Type Vimicro Zc301P 0x301b /usr/local/src/spca5xx-20060501/drivers/usb/spca5xx.c: [spca5xx_probe:5480] Camera type JPEG /usr/local/src/spca5xx-20060501/drivers/usb/zc3xx.h: [zc3xx_config:527] Find Sensor PB0330 /usr/local/src/spca5xx-20060501/drivers/usb/spca5xx.c: [spca5xx_getcapability:1765] maxw 640 maxh 480 minw 176 minh 144 (END)
[root@99dpr-004 ~]# lsmod | more Module Size Used by nfsd 210945 17 .... ac 4933 0 spca5xx 604432 0 videodev 10049 1 spca5xx ...
Another USB webcam, a Logitech QuickCam Deluxe for Notebooks was acquired. This time the webcam was for use with a Linux workstation (an Acer Travelmate laptop PC).
Again the SPCA5xx driver was found to be the most appropriate driver for this make/model of webcam.
The build and installation of the webcam software on the laptop is described in Build and Install Software on Workstation (Acer laptop).
Having first downloaded the software from the SPCA5xx webcam driver site to a suitable location on the server, then unpack and build the spca5xx.ko Loadable Kernel Module (LKM) as follows:
# pwd /usr/local/src # tar zxvf spca5xx-20060501.tar.gz # cd spca5xx-20060501 # pwd /usr/local/src/spca5xx-20060501 # make Building SPCA5XX driver for 2.5/2.6 kernel. Remember: you must have read/write access to your kernel source tree. make -C /lib/modules/`uname -r`/build SUBDIRS=/usr/local/src/spca5xx-20060501 CC=cc modules make[1]: Entering directory `/usr/src/kernels/2.6.9-42.0.3.EL-i686' CC [M] /usr/local/src/spca5xx-20060501/drivers/usb/spca5xx.o CC [M] /usr/local/src/spca5xx-20060501/drivers/usb/spcadecoder.o LD [M] /usr/local/src/spca5xx-20060501/spca5xx.o Building modules, stage 2. MODPOST CC /usr/local/src/spca5xx-20060501/spca5xx.mod.o LD [M] /usr/local/src/spca5xx-20060501/spca5xx.ko make[1]: Leaving directory `/usr/src/kernels/2.6.9-42.0.3.EL-i686' # # ls -l /lib/modules/`uname -r`/kernel/drivers/usb total 40 drwxr-xr-x 2 root root 4096 Dec 1 22:30 atm drwxr-xr-x 2 root root 4096 Dec 1 22:30 class drwxr-xr-x 2 root root 4096 Dec 1 22:30 host drwxr-xr-x 2 root root 4096 Dec 1 22:30 image drwxr-xr-x 2 root root 4096 Dec 1 22:30 input drwxr-xr-x 3 root root 4096 Jan 21 19:46 media drwxr-xr-x 2 root root 4096 Dec 1 22:30 misc drwxr-xr-x 2 root root 4096 Dec 10 19:25 net drwxr-xr-x 2 root root 4096 Dec 1 22:30 serial drwxr-xr-x 2 root root 4096 Dec 1 22:30 storage # # uname -r 2.6.9-42.0.3.EL # # make install mkdir -p /lib/modules/`uname -r`/kernel/drivers/usb/media/ rm -f /lib/modules/`uname -r`/kernel/drivers/usb/media/spca50x.ko rm -f /lib/modules/`uname -r`/kernel/drivers/usb/media/et61x.ko install -c -m 0644 spca5xx.ko /lib/modules/`uname -r`/kernel/drivers/usb/media/ /sbin/depmod -ae
The built software is ready; add the modules into the Linux kernel.
# modprobe videodev # lsmod | grep video videodev 10049 0
# modprobe --list | grep cam /lib/modules/2.6.9-42.0.3.EL/misc/quickcam.ko /lib/modules/2.6.9-42.0.3.EL/kernel/drivers/usb/media/ibmcam.ko /lib/modules/2.6.9-42.0.3.EL/kernel/drivers/usb/media/vicam.ko /lib/modules/2.6.9-42.0.3.EL/kernel/drivers/usb/media/quickcam.ko /lib/modules/2.6.9-42.0.3.EL/kernel/drivers/usb/media/ultracam.ko /lib/modules/2.6.9-42.0.3.EL/kernel/drivers/media/video/ovcamchip/ovcamchip.ko
# modprobe spca5xx # modprobe --list | grep spca5 /lib/modules/2.6.9-42.0.3.EL/kernel/drivers/usb/media/spca5xx.ko
Use system commands such as dmesg, lsusb and lsmod to check the system configuration.
Console system message details as below:
# dmesg | less ... Linux video capture interface: v1.00 /usr/local/src/spca5xx-20060501/drivers/usb/spca5xx.c: USB SPCA5XX camera found. Type Labtec Webcam Pro Zc0302 + Hdcs2020 /usr/local/src/spca5xx-20060501/drivers/usb/spca5xx.c: [spca5xx_probe:5480] Camera type JPEG /usr/local/src/spca5xx-20060501/drivers/usb/zc3xx.h: [zc3xx_config:543] Find Sensor PAS202BCB /usr/local/src/spca5xx-20060501/drivers/usb/spca5xx.c: [spca5xx_getcapability:1765] maxw 640 maxh 480 minw 176 minh 144 usbcore: registered new driver spca5xx /usr/local/src/spca5xx-20060501/drivers/usb/spca5xx.c: spca5xx driver 00.60.00 registered
USB devices details as below:
# lsusb Bus 002 Device 001: ID 0000:0000 Bus 001 Device 002: ID 046d:08a2 Logitech, Inc. Labtec WebCam Pro Bus 001 Device 001: ID 0000:0000
Full LKM listed configuration details as below:
# lsmod Module Size Used by spca5xx 604432 1 videodev 10049 2 spca5xx vfat 14657 0 fat 44385 1 vfat nfsd 213889 17 ... usb_storage 60809 0 ... uhci_hcd 31321 0 snd_usb_audio 59681 0 snd_usb_lib 12225 1 snd_usb_audio snd_intel8x0 34025 0 snd_ac97_codec 64145 1 snd_intel8x0 snd_pcm_oss 49401 0 snd_mixer_oss 18241 1 snd_pcm_oss snd_pcm 97225 3 snd_usb_audio,snd_intel8x0,snd_pcm_oss snd_timer 30149 1 snd_pcm snd_page_alloc 9929 2 snd_intel8x0,snd_pcm snd_mpu401_uart 8897 1 snd_intel8x0 snd_rawmidi 26853 2 snd_usb_lib,snd_mpu401_uart snd_seq_device 8265 1 snd_rawmidi snd 55973 10 snd_usb_audio,snd_intel8x0,snd_ac97_codec,snd_pcm_oss,snd_mixer_oss,snd_pcm,snd_timer,snd_mpu401_uart,snd_rawmidi,snd_seq_device soundcore 10017 1 snd rt73 196736 0 3c59x 39421 0 ... jbd 71385 1 ext3 #
The build and installation of the webcam software on the laptop is described in a separate web-page: Build and Install Software on Workstation (Acer laptop).
The Linux kernel requires a virtual device node be created in order to be able to access and control the device in question.
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.
Usually all possible device inodes reside in a directory /dev in the Linux system. Since the webcam driver uses the Video4Linux interface, it uses device inodes with major 81, minor 0...63. It does NOT use the 'usbcam' devices at major 180, minor 80. This is, typically, how the /dev directory should look:
# ls -l /dev/video* lrwxrwxrwx 1 root root 11 Jan 31 21:07 /dev/video -> /dev/video0 crw-rw---- 1 root video 81, 0 Nov 25 1998 /dev/video0 crw-rw---- 1 root video 81, 1 Nov 25 1998 /dev/video1 crw-rw---- 1 root video 81, 2 Nov 25 1998 /dev/video2 crw-rw---- 1 root video 81, 3 Nov 25 1998 /dev/video3 #
Create the device inodes with commands like mknod /dev/video0 c 81 0 (this requires root permission), and up to 64 video devices can be created.
It is not necessary to have a 'video' group, but if you have a multi-user system you may wish to give only certain people access to the video devices. If you are the only one using the system you can forget about this and just set the access permissions to 666 (rw-rw-rw-).
Thus 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 as shown below:
# mknod /dev/video0 c 81 0 # chmod a+r /dev/video0 # ln -s /dev/video0 /dev/video
Check for a suitable group (e.g. video) and if necessary add it to the system:
# groupadd video # more /etc/passwd # more /etc/group # # chgrp video /dev/video0 # ls -l # chmod g+rw /dev/video0 # ls -l
Then add any necessary users to the group and set the permissions to allow group access:
# adduser tom video # adduser dick video # adduser harry video # chmod g+rw /dev/v4l/video0
This steps above can be automated in a script such as follows:
# more MakeVideoDevice.sh #!/bin/sh # From http://www.linux.com/base/ldp/howto/Webcam-HOWTO/dev-intro.html # use as ./MakeVideoDevice.sh 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 0664 /dev/$1$dev chgrp video /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 # omitted for time being # 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
Need to ensure that the modules are re-loaded after a reboot. If necessary update the module configuration file to include the Labtech Pro USB Webcam device. Use vi /etc/modprobe.conf to add the necessary details. Otherwise it is a case of re-inserting the module after every re-boot.
Re-building will be necessary after an upgrade that results in an upgraded kernel. Thus, for example, after a yum update result in a new kernel version as shown:
# yum update # # .... output deleted # # uname -a Linux hostname 2.6.9-42.0.10.EL #1 Tue Feb 27 09:24:42 EST 2007 i686 i686 i386 GNU/Linux #
The following is a brief reprise of the steps necessary to re-build the kernel driver and re-install it.
# cd /usr/local/src/spca5xx/spca5xx-20060501 # ls -l # make # # .... output deleted (see example output earlier) # # make install # # .... output deleted (see example output earlier) # # modprobe videodev # modprobe spca5xx # modprobe --list | grep spca5xx /lib/modules/2.6.9-42.0.10.EL/kernel/drivers/usb/media/spca5xx.ko # dmesg | less # # .... output deleted (see example output earlier) # # lsmod # # .... output deleted (see example output earlier)
Finally if the webcam is being used with Zoneminder then it will be necessary to re-start Zoneminder to use the re-built webcam module.
# service zm restart Stopping ZoneMinder: [ OK ] Starting ZoneMinder: [ OK ] #
Full details about using Zoneminder, and configuring webcams for use by Zoneminder are available in my ZoneMinder link.
The following general links are useful references when setting up a Webcam under Linux: