These little beasties are pretty hard to get working in Ubuntu 10.04 LTS but here is a step by step walk through to get it working within minutes :) just type the highlighted commands in a terminal session....
firstly identify you have an SN9C202 or similar camera by using
lsusb
which should return something like this
Bus 002 Device 002: ID 045e:0040 Microsoft Corp. Wheel Mouse Optical
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 004: ID 0c45:628f Microdia PC Camera with Microphone (SN9C202 + OV9650)
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Once you have indeed confirmed you have the offending camera follow the steps below.....
firstly install Git with the following command line
sudo apt-get install git-core
1. Download the source code
From a command-line prompt, cd to a directory where you want to download it, default "home" will do then run the command:
git clone http://repo.or.cz/r/microdia.git
This will create a folder named "microdia" which contains all the source code.
Sometimes the above command doesn't work. In such cases please try this one:
git clone http://repo.or.cz/microdia.git
2. Install bare minimum packages
To be able to compile the driver, you must have kernel sources and the necessary tools to compile it. For most applications you will also need libv4l.
Debian/Ubuntu
sudo apt-get install kernel-package linux-headers build-essential ctags libv4l
(this might take a while depending on how fast your connection is)
Note: linux-source is not necessary, rather linux-headers with the same version of your kernel will install /lib/modules//build.
Attention: Do _NOT_ under any circumstances use "sudo make" or "make". There are no root privileges necessary at this point and using them causes a never ending chain of different problems later on.
3. Setting up the compilation environment
The linux kernel needs to be locally compiled in order to compile the microdia driver.
If the kernel is not compiled, "make" will complain of "modpost" missing.
The Makefile expects the source of linux to be located in /lib/modules/$(KVER)/build, if this is not the case edit the Makefile to set KSRC to point to the linux source location.
4. Building Microdia driver from source
After installing Git (command line to get git shown above), you need to download microdia kernel driver source. After installing Kernel packages and necessary tools to compile it, you will be able to compile it by typing:
cd microdia
make
Attention: Do _NOT_ under any circumstances use "sudo make" or "make". There are no root privileges necessary at this point and using them causes a never ending chain of different problems later on.
Troubleshooting MAKE errors
If you get the following error:
make: *** [driver] Error 127
Error 127 simply means that the module is not in the proper location. This is not a major error.
5. Loading the driver
sudo insmod ./sn9c20x.ko
If everything works fine you won't see any message on stdout, but your dmesg will have lines like the following:
sn9c20x: SN9C20X USB 2.0 webcam driver loaded
sn9c20x: SN9C20X USB 2.0 Webcam - XXXX:XXXX plugged-in.
sn9c20x: Detected XXX Sensor
sn9c20x: SN9C20X USB 2.0 Webcam is now controlling video device /dev/video0
usbcore: registered new interface driver usb_sn9c20x_driver
sn9c20x: v2008.10 : SN9C20X USB 2.0 Webcam Driver
Troubleshooting insmod errors
insmod sn9c20x.ko
insmod: error inserting 'sn9c20x.ko': -1 File exists (which is what I experienced)
means a similar module is was already loaded into the kernel and needs to be removed first. To find out which model that is, do:
lsmod | grep sn9c20x
you should see something like this
gspca_sn9c20x 31616 0
gspca_main 26816 1 gspca_sn9c20x
From which you can then figure out the module name (gspca_sn9c20x in my case) and replace it with the new module as shown below
sudo rmmod gspca_sn9c20x
sudo insmod snc9c20x.ko
Make sure you type all of this from within the git cloned microdia directory or else it will simply bomb on you. You can now check to see if the module is loaded:
lsmod | grep sn9c20x
and you should see the driver installed.....
Update the dependencies for every module.
sudo depmod -a
sudo m-a update,prepare
if the sudo m-a update,prepare fails you'll need to run the following and repeat the command line above
sudo apt-get install module-assistant
then
sudo m-a update,prepare
FIXME: more possibilities
6. Test it using Skype or the command line shown below
Please note that the test requires libv4l for video decoding. mplayer does not support JPEG compression on its own.
LD_PRELOAD=/usr/lib/libv4l/v4l2convert.so mplayer tv:// \
-tv driver=v4l2:width=640:height=480:fps=25:device=/dev/video0 -vo x11
7. Installing the Microdia Driver
Once you're happy that it's working as expected ....
open a terminal session and put the following commands in to weld it into the operating system :)
sudo strip -g sn9c20x.ko
sudo mkdir -p /lib/modules/`uname -r`/kernel/drivers/media/video/usbvideo/
sudo cp sn9c20x.ko /lib/modules/`uname -r`/kernel/drivers/media/video/usbvideo/
sudo depmod -a
Just cut and paste the above ... you might need to press the enter key for the last command to execute
voila .... working webcam :)