Building the bleeding-edge PSEYE driver (for your specific Kernel version!)

So, you want to install the latest PSEYE driver and you’re running the latest kernel version. The drivers for the Playstation Eye usually are up to date with the latest kernel- which make life easy. Follow this tutorial for downloading the git and building the driver: [1]

But, what if you’re on a platform which doesn’t currently support the latest kernel version? Or maybe you just want to stick with the kernel version you’re currently running. But if you try to build the latest driver it can fail due to differences between kernel versions. So there are a couple of options:

1. Use the driver which was current for your version of the kernel- this is will work, but won’t contain any changes to the driver which has happened since then, so you’ll be missing out on all the new features!!

2. Use the current driver but only reverse patches that are applicable for the compatibility with the kernel. And luckily video for linux has your back! The media_build git (git://linuxtv.org/media_build.git) from linuxtv.org is just for this. It contains a set of patches which will revert the driver to the required kernel version without reverting new features to the drivers themselves. So you’ll want to do something like this: [2]

In my case I want to build the latest PSEYE for the 2.6.32 kernel, while the current drivers are time of writing are for the 2.6.40 kernel. For my project I will be compiling these drivers for the BeagleBoard using OpenEmbedded. Now this is a little bit tricky as I will need to manually insert all the relevant patches into the kernel recipe. I have discussed this process in an earlier post: “OpenEmbbeded: Linux kernel + adding PSEYE (patched) modules” where I built the driver using method 1 from above, ie: reverting to an older driver version.

First I cloned the latest git of the gspca driver and the media_build git:

dave@ubuntu:~/setup-scripts/sources/gspca-latest$ git clone git://linuxtv.org/jfrancois/gspca.git
Cloning into gspca...
remote: Counting objects: 2011313, done.
remote: Compressing objects: 100% (353721/353721), done.
remote: Total 2011313 (delta 1644787), reused 2003581 (delta 1639209)
Receiving objects: 100% (2011313/2011313), 472.56 MiB | 190 KiB/s, done.
Resolving deltas: 100% (1644787/1644787), done.

Rather than using the scripts in the media_build I want to run the patches manually with:

for i in $(cat /home/dave/setup-scripts/sources/gspca-latest/media_build/backports/v2.6.32_series
    patch -p1 < /home/dave/setup-scripts/sources/gspca-latest/media_build/backports/$i
done
dave@ubuntu:~/setup-scripts/sources/gspca-latest/gspca$ ./do_patch_v2.6.32
patching file drivers/media/video/cx18/cx18-driver.c
patching file drivers/media/video/cx18/cx18-driver.h
patching file drivers/media/video/cx18/cx18-streams.h
patching file drivers/media/rc/rc-main.c
patching file drivers/media/dvb/dvb-usb/dvb-usb-remote.c
patching file drivers/media/video/videobuf2-memops.c
patching file drivers/media/dvb/firewire/firedtv-fw.c
patching file drivers/media/video/bt8xx/bttv-input.c
patching file drivers/media/video/cx18/cx18-i2c.c
patching file drivers/media/video/cx23885/cx23885-i2c.c
patching file drivers/media/video/em28xx/em28xx-cards.c
Hunk #1 succeeded at 2443 (offset -11 lines).
patching file drivers/media/video/ivtv/ivtv-i2c.c
patching file drivers/media/video/v4l2-common.c
patching file drivers/media/video/ivtv/ivtv-driver.c
Hunk #3 succeeded at 1013 (offset 2 lines).
Hunk #4 succeeded at 1241 (offset 2 lines).
Hunk #5 succeeded at 1381 (offset 2 lines).
patching file drivers/media/video/ivtv/ivtv-driver.h
patching file drivers/media/video/ivtv/ivtv-irq.c
patching file drivers/media/video/ivtv/ivtv-irq.h
patching file drivers/media/dvb/dvb-core/dvb_net.c
patching file drivers/media/rc/imon.c
patching file drivers/media/dvb/frontends/tua6100.c
patching file drivers/media/rc/rc-main.c
patching file drivers/media/dvb/dvb-usb/dvb-usb-remote.c
patching file drivers/media/video/pvrusb2/pvrusb2-sysfs.c
patching file drivers/media/rc/rc-core-priv.h
patching file drivers/media/rc/ir-raw.c
patching file drivers/media/video/cx23885/cx23888-ir.c
patching file drivers/media/video/cx25840/cx25840-ir.c
patching file drivers/media/video/meye.c
patching file drivers/media/video/meye.h
patching file include/media/lirc_dev.h

The driver is then patched for backwards compatibility with the 2.6.32 kernel. I then do a diff of this patched driver with the current 2.6.32 kernel driver:

dave@ubuntu:~/setup-scripts/sources/gspca-latest$ diff -rupN v2.6.32_kernel/drivers/media/video/gspca/ gspca/drivers/media/video/gspca/ > update_gspca.patch

So the patch I’ve just created, patches the 2.6.32 kernel with the new gspca driver which is patched for backwards compatibility.

I insert this into my OpenEmbedded recipes recompile the kernel in OpenEmbedded as described here: “OpenEmbbeded: Linux kernel + adding PSEYE (patched) modules“:

dave@ubuntu:~/setup-scripts$ MACHINE=beagleboard ./oebb.sh bitbake virtual/kernel -c clean
dave@ubuntu:~/setup-scripts$ MACHINE=beagleboard ./oebb.sh bitbake virtual/kernel

So if you’re doing anything like me and using an experimental driver which is off the main video for linux tree then it is highly possibly that you’ll get some compile errors due to changes in the code since the official version. You could either use the main v4l tree or go through each of the compile errors and fix them yourself. I decided to fix each of the errors as there didn’t appear to be too many.

The compile errors I was getting:

|   CC [M]  drivers/media/video/gspca/conex.o
|   CC [M]  drivers/media/video/gspca/etoms.o
|   CC [M]  drivers/media/video/gspca/finepix.o
|   CC [M]  drivers/media/video/gspca/gspca.o
| drivers/media/video/gspca/gspca.c: In function 'alloc_and_submit_int_urb':
| drivers/media/video/gspca/gspca.c:216: error: implicit declaration of function 'usb_alloc_coherent'
| drivers/media/video/gspca/gspca.c:217: warning: assignment makes pointer from integer without a cast
| drivers/media/video/gspca/gspca.c:236: error: implicit declaration of function 'usb_free_coherent'
| drivers/media/video/gspca/gspca.c: In function 'create_urbs':
| drivers/media/video/gspca/gspca.c:738: warning: assignment makes pointer from integer without a cast
| drivers/media/video/gspca/gspca.c: In function 'gspca_release':
| drivers/media/video/gspca/gspca.c:1208: error: implicit declaration of function 'video_device_node_name'
| drivers/media/video/gspca/gspca.c:1208: warning: format '%s' expects type 'char *', but argument 2 has type 'int'
| drivers/media/video/gspca/gspca.c: In function 'gspca_dev_probe2':
| drivers/media/video/gspca/gspca.c:2270: warning: format '%s' expects type 'char *', but argument 2 has type 'int'
| drivers/media/video/gspca/gspca.c: In function 'gspca_disconnect':
| drivers/media/video/gspca/gspca.c:2324: warning: format '%s' expects type 'char *', but argument 2 has type 'int'
| make[4]: *** [drivers/media/video/gspca/gspca.o] Error 1
| make[3]: *** [drivers/media/video/gspca] Error 2
| make[2]: *** [drivers/media/video] Error 2
| make[1]: *** [drivers/media] Error 2
| make: *** [drivers] Error 2
| + die 'oe_runmake failed'
| + oefatal 'oe_runmake failed'
| + echo FATAL: 'oe_runmake failed'
| FATAL: oe_runmake failed
| + exit 1
NOTE: package linux-omap-psp-2.6.32-r100c+gitr5fc29e7b2a76a64a739f857858ef0b98294aa155: task do_compileconfigs: Failed
ERROR: Function 'do_compileconfigs' failed (see /home/dave/setup-scripts/build/tmp-angstrom_2008_1/work/beagleboard-angstrom-linux-gnueabi/linux-omap-psp-2.6.32-r100c+gitr5fc29e7b2a76a64a739f857858ef0b98294aa155/temp/log.do_compileconfigs.6497 for further information)
ERROR: Task 12 (/home/dave/setup-scripts/sources/openembedded/recipes/linux/linux-omap-psp_2.6.32.bb, do_compileconfigs) failed with exit code '1'
ERROR: '/home/dave/setup-scripts/sources/openembedded/recipes/linux/linux-omap-psp_2.6.32.bb' failed

So I found the best way to fix these compile errors is to jump onto the git history and look at kernel patches merges from the master tree. For my errors I narrowed it down to a particular kernel patch:

USB: rename usb_buffer_alloc() and usb_buffer_free() users
Daniel Mack [Mon, 12 Apr 2010 11:17:25 +0000 (13:17 +0200)]
For more clearance what the functions actually do,
usb_buffer_alloc() is renamed to usb_alloc_coherent()
usb_buffer_free() is renamed to usb_free_coherent()
They should only be used in code which really needs DMA coherency. All call sites have been changed accordingly, except for staging drivers.

After successful compliation, I checked that the patch was applied by checking the logs (OE temp folder, log.do_patch) :

NOTE: Applying patch 'update_gspca.patch' (../sources/openembedded/recipes/linux/linux-omap-psp-2.6.32/update_gspca.patch)

Then I copy the new kernel + modules to the SD then boot it up! Once it has booted I can check the info on the module to see the updated version:

root@beagleboard:~# modinfo gspca_ov534
+ modinfo gspca_ov534
filename:       /lib/modules/2.6.32/kernel/drivers/media/video/gspca/gspca_ov534.ko
license:        GPL
description:    GSPCA/OV534 USB Camera Driver
author:         Antonio Ospite <ospite@studenti.unina.it>
srcversion:     43331721D0931CE8AD7191A
alias:          usb:v06F8p3002d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1415p2000d*dc*dsc*dp*ic*isc*ip*
depends:        gspca_main
vermagic:       2.6.32 preempt mod_unload modversions ARMv7
root@beagleboard:~#

Lets give it a try using gstreamer:

Great! The auto-white balance is working. So here we have the Playstation eye plugged into a BeagleBoard -xM capturing video with the latest drivers on the 2.6.32 kernel.

References:
[1] http://nuigroup.com/forums/viewthread/4079/
[2] http://linuxtv.org/wiki/index.php/How_to_Obtain,_Build_and_Install_V4L-DVB_Device_Drivers

Update 2011-06-20
As requested: gspca kernel objects for BeagleBoard 2.6.32 Kernel (current as of 2011-06-12): LINK

avatar

About Dave

"if it's not on fire, it's usually a software problem"