Subscribe via RSS

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.


About stevenh

Trains... trains... trains... + Electronics + Japan.
Comments (9) Trackbacks (0)
  1. Thank you! It’s worked for me!
    ID 05ca:1830 Ricoh Co., Ltd Visual Communication Camera VGP-VCC2 [R5U870]
    Linux Dmitry-Laptop 3.16.0-31-generic #41~14.04.1-Ubuntu SMP Wed Feb 11 19:30:43 UTC 2015 i686 i686 i686 GNU/Linux

  2. Great, it works!!
    I was searching the whole web to get a working driver for the built-in webcam (ID 05ca:1832 Ricoh Co., Ltd Visual Communication Camera VGP-VCC3 [R5U870]) of my Vaio-UX180P running Linux Mint Mate 17.1 (Rebecca), 3.13.0-37-generic #64-Ubuntu SMP Mon Sep 22 21:30:01 UTC 2014 i686 i686 i686 GNU/Linux

    Many thanks for your solution!
    …and greetings from Bavaria/Germany! :)


    • Sebastian,

      Glad you found this helpful. Note that at the very start I provide the link to the updated driver. Mine is more of a proof-of-concept, so make sure you use the real one.


      • The funny thing is I DID use the latest github file from above link before, but somehow it didn’t work here. So I continued my search and stumbled on your page. No idea why it didn’t work from the official repo… :P


  3. I get a problem installing the driver, can u help me please.
    pepi@pepi-VGN-SZ3VWP-X:~/Downloads/r5u870$ make
    make -C /lib/modules/4.4.0-31-generic/build M=/home/pepi/Downloads/r5u870 V=0 modules
    make[1]: Entering directory ‘/usr/src/linux-headers-4.4.0-31-generic’
    CC [M] /home/pepi/Downloads/r5u870/usbcam/usbcam_fops.o
    /home/pepi/Downloads/r5u870/usbcam/usbcam_fops.c: In function ‘usbcam_v4l_open’:
    /home/pepi/Downloads/r5u870/usbcam/usbcam_fops.c:138:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
    struct usbcam_dev *udp;
    /home/pepi/Downloads/r5u870/usbcam/usbcam_fops.c:34:37: warning: statement with no effect [-Wunused-value]
    #define usb_autopm_put_interface(x) (0)
    /home/pepi/Downloads/r5u870/usbcam/usbcam_fops.c:243:20: note: in expansion of macro ‘usb_autopm_put_interface’
    if (autopm_ref) { usb_autopm_put_interface(udp->ud_intf); }
    /home/pepi/Downloads/r5u870/usbcam/usbcam_fops.c: In function ‘usbcam_v4l_release’:
    /home/pepi/Downloads/r5u870/usbcam/usbcam_fops.c:34:37: warning: statement with no effect [-Wunused-value]
    #define usb_autopm_put_interface(x) (0)
    /home/pepi/Downloads/r5u870/usbcam/usbcam_fops.c:279:3: note: in expansion of macro ‘usb_autopm_put_interface’
    /home/pepi/Downloads/r5u870/usbcam/usbcam_fops.c: In function ‘usbcam_v4l_ioctl’:
    /home/pepi/Downloads/r5u870/usbcam/usbcam_fops.c:1196:27: warning: unused variable ‘udp’ [-Wunused-variable]
    struct usbcam_dev *udp = ufp->ufh_dev;
    /home/pepi/Downloads/r5u870/usbcam/usbcam_fops.c: At top level:
    /home/pepi/Downloads/r5u870/usbcam/usbcam_fops.c:1230:2: error: unknown field ‘ioctl’ specified in initializer
    .ioctl = usbcam_v4l_ioctl,
    /home/pepi/Downloads/r5u870/usbcam/usbcam_fops.c:1230:12: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
    .ioctl = usbcam_v4l_ioctl,
    /home/pepi/Downloads/r5u870/usbcam/usbcam_fops.c:1230:12: note: (near initialization for ‘’)
    /home/pepi/Downloads/r5u870/usbcam/usbcam_fops.c:1232:2: error: unknown field ‘compat_ioctl’ specified in initializer
    .compat_ioctl = v4l_compat_ioctl32,
    /home/pepi/Downloads/r5u870/usbcam/usbcam_fops.c:1232:18: error: ‘v4l_compat_ioctl32’ undeclared here (not in a function)
    .compat_ioctl = v4l_compat_ioctl32,
    /home/pepi/Downloads/r5u870/usbcam/usbcam_fops.c:63:20: warning: ‘v4l_ioctl_names’ defined but not used [-Wunused-variable]
    const static char *v4l_ioctl_names[] = {
    /home/pepi/Downloads/r5u870/usbcam/usbcam_fops.c:948:13: warning: ‘usbcam_v4l_int_ioctl’ defined but not used [-Wunused-function]
    static long usbcam_v4l_int_ioctl(struct file *filp,
    scripts/ recipe for target ‘/home/pepi/Downloads/r5u870/usbcam/usbcam_fops.o’ failed
    make[3]: *** [/home/pepi/Downloads/r5u870/usbcam/usbcam_fops.o] Error 1
    scripts/ recipe for target ‘/home/pepi/Downloads/r5u870/usbcam’ failed
    make[2]: *** [/home/pepi/Downloads/r5u870/usbcam] Error 2
    Makefile:1403: recipe for target ‘_module_/home/pepi/Downloads/r5u870’ failed
    make[1]: *** [_module_/home/pepi/Downloads/r5u870] Error 2
    make[1]: Leaving directory ‘/usr/src/linux-headers-4.4.0-31-generic’
    Makefile:36: recipe for target ‘all’ failed
    make: *** [all] Error 2

    • Pepi,

      Looks like Kernel 4.4 has introduced more changes that this isn’t going to work on.
      Have you checked if the changes in the github repo work?
      If not, then I might find a chance to look at this again…


  4. Hi, Steven.
    Are you going to try to fix the driver, or i need to get back to windows. This was the first time that i used Linux but without a webcam i cant work with him.


Leave a comment

No trackbacks yet.