Subscribe via RSS
10Aug/1420

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 peppermintos.com 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]  [c164b8c3] dump_stack+0x41/0x52
[  440.621072]  [c10567ee] warn_slowpath_common+0x7e/0xa0
[  440.621084]  [f8f4b54f] ? __video_register_device+0x4ff/0x540 [videodev]
[  440.621094]  [f8f4b54f] ? __video_register_device+0x4ff/0x540 [videodev]
[  440.621100]  [c10568b2] warn_slowpath_null+0x22/0x30
[  440.621111]  [f8f4b54f] __video_register_device+0x4ff/0x540 [videodev]
[  440.621120]  [f8abd7f4] usbcam_usb_probe+0x334/0x590 [usbcam]
[  440.621128]  [c14a98b3] usb_probe_interface+0x193/0x2b0
[  440.621136]  [c140730a] ? driver_sysfs_add+0x5a/0x80
[  440.621141]  [c1407975] driver_probe_device+0x105/0x380
[  440.621147]  [c14a9089] ? usb_match_id+0x49/0x60
[  440.621153]  [c14a9166] ? usb_device_match+0x46/0x80
[  440.621158]  [c1407ca1] __driver_attach+0x71/0x80
[  440.621164]  [c1407c30] ? __device_attach+0x40/0x40
[  440.621169]  [c1405dd7] bus_for_each_dev+0x47/0x80
[  440.621175]  [c14073de] driver_attach+0x1e/0x20
[  440.621180]  [c1407c30] ? __device_attach+0x40/0x40
[  440.621186]  [c1407037] bus_add_driver+0x157/0x230
[  440.621192]  [c1408269] driver_register+0x59/0xe0
[  440.621197]  [c14a8317] usb_register_driver+0x67/0x140
[  440.621205]  [f8abcc42] ? usbcam_register_mod+0x62/0x210 [usbcam]
[  440.621213]  [f8abcd92] usbcam_register_mod+0x1b2/0x210 [usbcam]
[  440.621221]  [f8421000] ? 0xf8420fff
[  440.621228]  [f842105a] usbcam_minidrv_init+0x5a/0x1000 [r5u870]
[  440.621235]  [c1002122] do_one_initcall+0xd2/0x190
[  440.621241]  [f8421000] ? 0xf8420fff
[  440.621248]  [c104c87f] ? set_memory_nx+0x5f/0x70
[  440.621256]  [c164769a] ? set_section_ro_nx+0x54/0x59
[  440.621263]  [c10c3e9a] load_module+0x111a/0x18e0
[  440.621274]  [c10c47c5] SyS_finit_module+0x75/0xc0
[  440.621281]  [c11396db] ? vm_mmap_pgoff+0x7b/0xa0
[  440.621294]  [c1659bcd] 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.

camera

Download the driver here: R5U870 0.11.7.
To install all the required libraries to build: apt-get install build-essential linux-headers-`uname -r`.

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