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.

Comments (20) 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! :)

    Piepsi
    (Sebastian)

    • 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.

      Steven.

      • 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

        Piepsi

    • Piepsi: I see you’re running Linux on your 180P. I just was able to revive mine, after years of power plug problems. I’ve got Lubuntu 17.10 loaded, but am struggling with the Alps TouchPad TouchPoint problem where moving the cursor drags/selects on screen text/icons/etc. How did you work your way around this?
      Don

        • Thanks, got it working, just need to have a script run on startup and I’ll be happy. While opening up UX, discovered my HDD ribbon cable had a split. So HDD rendered inoperable. Went through the trouble of now booting off a USB3.0 device and things are well. I was unable to find anyone/anywhere that I could secure a new/replacement ribbon cable for the (ZIF?) HDD. Awaiting a new battery pack, and hoping that the USB HDD will give me longer battery life, but for now tethered to AC.

          Have tried your camera fix, but no luck. When attempting make I get a string of errors.

          • Glad to hear!
            The compile instructions here are probably way out-of-date… will have to try it again myself and work out the errors.
            I’ll report back when I’ve tried it.

  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’
    usb_autopm_put_interface(udp->ud_intf);
    ^
    /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 ‘usbcam_v4l_fops_template.open’)
    /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/Makefile.build:258: 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/Makefile.build:403: 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…

      Steven.

  4. Pepi:
    My UX-180P is running like a champ Lubuntu 17.10. I did have the Touchpad working, able to go to the extreme corners with a pointer) but then a kernel update blew that. I guess I can live without using the pointer/touchpad screen, but want to ask for any help on another issue.

    If I execute SUSPEND from the Lubuntu menu, the UX does appear to go to sleep, but when re-awaking it appears disk, fan, everything but the screen awakens. Any advice?

    I also enabled HIBERNATE, which appeared to work (momentarily turning everything off) but then awakened on its own and came right back to where I was. I’m getting ready for a trip to Europe and would like to take the UX along as (using the USB as HD extends by battery life beyond 4-hours.

    Anything would be much appreciated.
    Don

  5. Steven
    I have an old Sony Vaio VGN-TZ37GN that I am trying to revive. I have installed the latest version of Kubuntu (previously tried Mint) and cannot get the onboard camera to work. I have tried many suggested solutions online but most lead to dead links for the files etc.

    How do I install the driver you posted the link to? The readme in the zip file seems to indicate that this version of the Sony Vaio is not supported.

    thanks for any assistance.
    Joe

    • Hi Joseph,
      I’ve fixed the link here so it can be downloaded again. But I don’t know if this will support your laptop. I really did love that version on the Vaio!
      I’ll try and do some research during the week, but I’m very surprised that the most recent distributions don’t just work?!
      Steven.

      • Indeed more recent distros ruined it!
        I have tried many dristros with AHS 5 kernel and Latest 4.19.xx and cannot do anything anymore.

        I’m also on the same boat as others, I’m waiting for your help @stevenh

  6. Hi! This link is broken https://modelrail.otenko.com/vaio-ux/vaio-ux-camera-switch-for-linux
    Is there any information on how to switch cameras?

    • cpu,
      Apologies, it seems I had an intention to debug the windows driver and work out how to enable the rear camera, but I never got around to it.
      I’ve cleaned up the post to remove the dreams which never occurred.
      Steven.

      • Any ideas how this can be done? I have never done reverse engineering of a drewer before. What can you advise as a starting point?


Leave a comment


*

No trackbacks yet.