Subscribe via RSS

Hawksburn Station

Boredom made me hold the finger on the trigger....

Hawksburn Comeng

Who would've thought animated GIFs would ever be cool again?


r5u870 for v4l2 (Linux Kernel > 3.8?)

Update: 3pei has updated the driver to work on the latest linux releases. View his github repo here or download here.
Big thanks!

The Ricoh U5870 is a USB2.0-Video Interface Controller compliant with USB2.0 Video Class. The built-in series regulators allow power supply from 3.3V power to the R5U870 and the CMOS Sensor Module. In addition, coming in CSP package, the R5U870 is the best solution for a compact USB Camera Module.
The R5U870 comes with audio interface; MIC connection by using Audio Codec connections is possible.
This driver seems to have been left for dead... it's no longer needed as the r5u87x has replaced it for all UVM cameras. Unfortunately, the older WDM drivers still need this one and it hadn't been updated for the newest kernels or video-for-linux 2.

There have been many attempts to keep this driver alive here, here, here, here, here and here.

I have a Sony Vaio UX490N. It has a Ricoh Co., Ltd - Sony Visual Communication Camera VGP-VCC3 [R5U870] and it is WDM. It cannot use the r5u87x driver. The r5u870 exists around the web... but I couldn't find one that would work out-of-the-box on Linux Mint 17. PCNetSpec over at the forums posted information and an updated driver. Unfortunately, this driver threw an error on initialisation:

[  440.587372] Linux video capture interface: v2.00
[  440.620480] usbcam: registering driver r5u870 0.11.3
[  440.620532] r5u870-0: Detected Sony VGP-VCC3
[  440.620920] ------------[ cut here ]------------
[  440.620939] WARNING: CPU: 0 PID: 2467 at /build/buildd/linux-3.13.0/drivers/media/v4l2-core/v4l2-dev.c:779 __video_register_device+0x4ff/0x540 [videodev]()
[  440.620943] Modules linked in: r5u870(OF+) usbcam(OF) videobuf_dma_sg videobuf_core videodev ctr ccm hid_generic snd_hda_codec_realtek snd_hda_intel snd_hda_codec snd_hwdep snd_pcm snd_page_alloc dm_multipath coretemp scsi_dh snd_seq_midi snd_seq_midi_event snd_rawmidi kvm joydev arc4 snd_seq pcmcia iwl3945 serio_raw iwlegacy snd_seq_device tifm_7xx1 mac80211 snd_timer usbhid yenta_socket tifm_core pcmcia_rsrc snd btusb hid lpc_ich cfg80211 pcmcia_core soundcore bnep rfcomm bluetooth sony_laptop binfmt_misc mac_hid parport_pc ppdev lp parport dm_mirror dm_region_hash dm_log i915 i2c_algo_bit drm_kms_helper firewire_ohci psmouse(OF) firewire_core crc_itu_t drm sky2 video [last unloaded: videobuf_core]
[  440.621020] CPU: 0 PID: 2467 Comm: modprobe Tainted: GF       W  O 3.13.0-24-generic #47-Ubuntu
[  440.621023] Hardware name: Sony Corporation VGN-UX490N/VAIO                            , BIOS R0112N2 12/05/2007
[  440.621027]  00000000 00000000 e9fe5be4 c164b8c3 00000000 e9fe5c14 c10567ee c1826ffc
[  440.621036]  00000000 000009a3 f8f5a598 0000030b f8f4b54f f8f4b54f f2a7a800 ffffffff
[  440.621044]  00000000 e9fe5c24 c10568b2 00000009 00000000 e9fe5c50 f8f4b54f 00000002
[  440.621052] Call Trace:
[  440.621063]  [] dump_stack+0x41/0x52
[  440.621072]  [] warn_slowpath_common+0x7e/0xa0
[  440.621084]  [] ? __video_register_device+0x4ff/0x540 [videodev]
[  440.621094]  [] ? __video_register_device+0x4ff/0x540 [videodev]
[  440.621100]  [] warn_slowpath_null+0x22/0x30
[  440.621111]  [] __video_register_device+0x4ff/0x540 [videodev]
[  440.621120]  [] usbcam_usb_probe+0x334/0x590 [usbcam]
[  440.621128]  [] usb_probe_interface+0x193/0x2b0
[  440.621136]  [] ? driver_sysfs_add+0x5a/0x80
[  440.621141]  [] driver_probe_device+0x105/0x380
[  440.621147]  [] ? usb_match_id+0x49/0x60
[  440.621153]  [] ? usb_device_match+0x46/0x80
[  440.621158]  [] __driver_attach+0x71/0x80
[  440.621164]  [] ? __device_attach+0x40/0x40
[  440.621169]  [] bus_for_each_dev+0x47/0x80
[  440.621175]  [] driver_attach+0x1e/0x20
[  440.621180]  [] ? __device_attach+0x40/0x40
[  440.621186]  [] bus_add_driver+0x157/0x230
[  440.621192]  [] driver_register+0x59/0xe0
[  440.621197]  [] usb_register_driver+0x67/0x140
[  440.621205]  [] ? usbcam_register_mod+0x62/0x210 [usbcam]
[  440.621213]  [] usbcam_register_mod+0x1b2/0x210 [usbcam]
[  440.621221]  [] ? 0xf8420fff
[  440.621228]  [] usbcam_minidrv_init+0x5a/0x1000 [r5u870]
[  440.621235]  [] do_one_initcall+0xd2/0x190
[  440.621241]  [] ? 0xf8420fff
[  440.621248]  [] ? set_memory_nx+0x5f/0x70
[  440.621256]  [] ? set_section_ro_nx+0x54/0x59
[  440.621263]  [] load_module+0x111a/0x18e0
[  440.621274]  [] SyS_finit_module+0x75/0xc0
[  440.621281]  [] ? vm_mmap_pgoff+0x7b/0xa0
[  440.621294]  [] sysenter_do_call+0x12/0x28
[  440.621298] ---[ end trace bab7f9cdd3a1dbaa ]---
[  440.621301] r5u870-0: usbcam_usb_probe: video_register_device failed
[  440.621317] r5u870: probe of 1-6:1.0 failed with error -22
[  440.623343] usbcore: registered new interface driver r5u870

The WARN indicates that there were assertions on entering the function. Inspecting the function shows that there are two WARNs to check for valid input data:

795         /* the release callback MUST be present */
796         if (WARN_ON(!vdev->release))
797                 return -EINVAL;
798         /* the v4l2_dev pointer MUST be present */
799         if (WARN_ON(!vdev->v4l2_dev))
800                 return -EINVAL;

So... guesswork.. which of these is null? Am guessing it's the v4l2_dev. We've done nothing to initialise it. Further investigation of other, more updated drivers showed that we had to call v4l2_device_register prior to video_register_device.

        #include <media/v4l2-device.h>
        struct v4l2_device v4l2_dev_tmp;
        res = v4l2_device_register(&intf->dev, &v4l2_dev_tmp);
        if (res < 0) {
                usbcam_err(udp, "Could not register v4l2 device\n");
                goto out;
        udp->ud_vdev.v4l2_dev = &v4l2_dev_tmp;

The results were quite startling at 0100 hours.


Download the driver here: R5U870 0.11.7.

Check that hideous screenshot... the best part? That number on the Cheese window was a count-down timer... I pressed the 'Capture' hawdware button and Cheese responded by starting a 3-second count-down timer, resulting in taking a photo.

Next I want the button to open Cheese if it isn't already. I'll do this in another post.

...further to this... I'll next want to get the camera switch working for the Vaio UX. I'll be debugging it over in this post.


Linux Mint 17 on the Sony Vaio UX490N UMPC

Right, this thing is powerful... Windows Vista came installed as default and there was no other choice than to replace with a Linux Distro. I scoured Distrowatch for a valid distribution, but had already had Linux Mint in mind.

Linux Mint

Linux Mint is fork of Ubuntu which is a distribution based on Debian.


Due to the age of the hardware, 32-bit was chosen and the ISO was downloaded. I then acquired a tool named Rufus which allows you to easily smush an ISO onto a USB stick. This stick is then bootable and we can install our distro.

The actual installation of Mint is painless... of course, you need to know how to partition and or WIPE all of your data, but that's something that I already expect you to know. One nice point is that if you choose "side-by-side" then the installer will resize your primary partition. I should check that the base Vista installation still works!



Sure, the UX is damn handy... but the thumb-typing can be really tiresome... even if our new shells have auto-complete. Due to this, you may want to remote in from your desktop via SSH. By default, SSH isn't installed. Run the following to install it. Yes, note that we install 'ssh'... I initially expected to install sshd, but the ssh package includes this.

sudo apt-get install ssh

Press 'yes' when prompted to download the additional packages. apt-get just warns you if there are dependencies over the single package you asked for.
You can now log in to your machine on port 22. Use the account you created when you installed Mint.



dmesg gets spammed with eth0 link-up, link-down messages. I imagine the device is in the unit and the dock provides the physical port?
Either way, disable it permanently:

sudo nano /etc/rc.local

Add the following line:

sudo ifconfig eth0 down

Just before 'exit 0'. File should then look like:

#!/bin/sh -e
# rc.local
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
# In order to enable or disable this script just change the execution
# bits.
# By default this script does nothing.

sudo ifconfig eth0 down

exit 0


The Vaio UX comes with a Gunze touchscreen. This works out of the box, but isn't correct calibrated by default. Once you have Mint installed, run the following in a shell:

sudo apt-get install xinput-calibrator

Once this is installed, we can now run it to get our touchscreen aligned.
Note the underscore in the executable, whereas the package had a hyphen!


Follow the on-screen prompts. Touch the points with the stylus when asked.
You'll then be provided a configuration to store against X11:

Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "GUNZE USB Touch Panel"
        Option  "Calibration"   "34 992 34 970"
        Option  "SwapAxes"      "0"

There'll be a whole lot of output... it'll even tell you where to store the configuration. Unfortunately the location they specify is incorrect. Mint wants the file in a different area. Copy the section that matches the chunk above (chances are it's exactly the same) into the clipboard and then run the following:

sudo nano /usr/share/X11/xorg.conf.d/99-calibration.conf

Paste the configuration you copied and save your file.
Reboot your device just for fun... your touchscreen should now behave as expected when you touch the furthest corners!

ALPS Trackpoint

This wasn't fun... Under windows, you can disable the 'tapping'. This, just like a touchpad (of which the trackpoint is not) is the action of hitting the device with a single, focused prod. The expectation is then a 'left mouse button' click. As stated, you can easily disable this in windows, but you don't get that option out of the box on Mint.

I started hacking apart the xf86-input-evdev, but realised that disabling mouse buttons on the trackpoint meant the left-hand physical buttons were also switched off.

Fortunately, our friend Lawrence Wu on github has hacked the psmouse kernel driver for us. He's lowered the sensitivity so that our taps need to be serious in order to be registered.

The driver is managed by dkms which allows a substitute driver to be loaded in replacement of the built-in kernel driver. Below are the instructions for doing so. (Note that these have been copied and annotated from Lawrence's page. All credit to him! We thank you a lot!)

cd /usr/src/
sudo wget
sudo unzip
sudo rm
sudo mv psmouse-ux-master psmouse-ux
sudo dkms add -m psmouse -v ux
sudo dkms build -m psmouse -v ux
sudo dkms install -m psmouse -v ux

At this point, as long as there has been no errors... then DKMS has hold of a tasty new psmouse driver for your trackpoint.
Let's swap it in. It's as simple as unloading the current psmouse, then reloading it. The original kernel driver is currently loaded and will be unloaded:

sudo modprobe -r psmouse

You'll note from here that your mouse doesn't work... we've removed the link from the hardware to the windowing system. Mouse events are no longer making it through the pipes... now... let's reload what seems to be the same driver.

sudo modprobe psmouse

No output... no messages... just a mouse cursor! Try your hardest to make that little rodent 'tap'!...


There wasn't been an up-to-date driver... so I further modified the driver from PCNetSpec's post. See more information on how this happened here. Meanwhile, the instructions are as follows:

(Please disregard the warnings... I'll fix these at a later date.)

unzip r5u870
cd r5u870/
sudo make install
sudo modprobe r5u870

Note: This is still a work in progress... Once it's working here, I'll post the final instructions.


Project 6029 – Canberra

My old stomping ground... I'd spent a few late nights at the museum as a volunteer back in the day... great group of people (minimal infighting) and a great atmosphere of work getting done. We were restoring carriage roofs at the time (didn't know that you could use tar to weather-seal a carriage) and had heard murmurings of an effort to restore 'the biggest steam engine in the southern hemisphere'.

I had also heard that they were to shut the Cooma branch of the railway, as there was no funding... how were they going to possibly going to get funds to restore something a lot costlier?

Well... 8 years later, they did... they have... it works... Their blog is here. The latest photo album is here.
All photos credit to Howard Moffatt.

Update as at 13/08/2014... It turns out they're already running the loco through to the main line. Credit to Trent Nicholson for this photo:


Introducing my new Sony Vaio UX490N

Have wanted one of these things for ages... finally bought one on eBay.
There used to be tons of them in Sofmap in Denden Town, Osaka.... but they were too dear for what was offered.


DSC04012 DSC04013 DSC04024

See my other posts under the 'Vaio UX' Category for instructions, hints, etc...

Tagged as: , , , , No Comments