Monday, July 8, 2019

Creative CT6840 Webcam on Tinker Board

The Creative CT6840 webcam is about 20 years old.  Windows 10 does not recognize it; but Linux (4.4.0 x86_64 Ubuntu 16.04) does load the driver and runs it fine,
[28163.448127] usb 1-2: new full-speed USB device number 3 using xhci_hcd
[28163.765592] usb 1-2: New USB device found, idVendor=05a9, idProduct=0511
[28163.765595] usb 1-2: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[28164.813944] media: Linux media interface: v0.10
[28164.821933] Linux video capture interface: v2.00
[28164.826858] gspca_main: v2.14.0 registered
[28164.831722] gspca_main: ov519-2.14.0 probing 05a9:0511
[28165.040996] input: ov519 as /devices/pci0000:00/0000:00:0c.0/usb1/1-2/input/input8
[28165.041553] usbcore: registered new interface driver ov519
So does Armbian on OrangePi.  This is the great advantage of using an open-source OS.  VLC, cheese, or guvcview can be used to view the images.

This webcam uses OV511 camera-to-USB bridge chip.  OmniVision's OV511 is designed to work with the company's single-chip image sensors, the OV7610 Series and the OV7110 Series.  OV7610 is 1/3 in VGA color image sensor, with 8.4 x 8.4 um^2 pixel size, capable of 30Hz progressive at 640x480.  The quality of the image is not very good.  We can appreciate the great advance in the imaging sensor technology during the last 20 years.

However, there is no driver for it on the TinkerOS distribution.  The driver source code is in TinkerBoard debian_kernel source on Github.  We will try to compile it ourselves.  We downloaded the kernel source 4.4.103+ for TinkerOS Debian V2.0.7.  The driver source code is drivers/media/usb/gspca/ov519.c . We like to compile the driver to a kernel module without having to build the entire OS.  We copy the kernel config file from /lib/modules and Module.symvers from /usr/src/linux-headers to the source directory, then
make kernelversion
to confirm the version number.
make menuconfig 
to enable the ov51x module,
make ARCH=arm drivers/media/usb/gspca/ov519.ko, 
but that only makes ov519.o.
make ARCH=arm modules SUBDIRS=drivers/media/usb/gspca/ 
makes ov519.ko.
make ARCH=arm modules_install SUBDIRS=drivers/media/usb/gspca/ 
installs the kernel module in  /lib/modules/4.4.103/extra/. Run
depmod
modprobe gspca_ov519.ko . 
[   31.583420] usb 1-1.2: new full-speed USB device number 7 using dwc2
[   31.684866] usb 1-1.2: New USB device found, idVendor=05a9, idProduct=0511
[   31.684887] usb 1-1.2: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[   31.732956] gspca_main: v2.14.0 registered
[   31.741516] gspca_main: ov519-2.14.0 probing 05a9:0511
[   31.938123] input: ov519 as /devices/platform/ff540000.usb/usb1/1-1/1-1.2/input/input7
[   31.939754] usbcore: registered new interface driver ov519
But the image does not come out right; it appears to be some kind of format error.

Try Armbian kernel.  It works; guvcview shows a frame rate of 7.5 fps.
Linux tinkerboard 4.19.33-rockchip #5.77 SMP PREEMPT Wed Apr 3 17:06:29 CEST 2019 armv7l armv7l armv7l GNU/Linux
[   84.650548] usb 1-1.2: new full-speed USB device number 7 using dwc2
[   84.751749] usb 1-1.2: New USB device found, idVendor=05a9, idProduct=0511, bcdDevice= 1.00
[   84.751762] usb 1-1.2: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[   84.805728] gspca_main: v2.14.0 registered
[   84.809936] gspca_main: ov519-2.14.0 probing 05a9:0511
[   85.040060] input: ov519 as /devices/platform/ff540000.usb/usb1/1-1/1-1.2/input/input7
[   85.040954] usbcore: registered new interface driver ov519
Probing does not always succeed for some reason.