Menu

#11 Use libv4l for zbarcam

open
nobody
None
5
2010-12-25
2010-12-06
No

Instead of having two drivers, one for v4l1 and another for v4l2, and both missing support for lots of webcams, use libv4l.

Libv4l is mainained together with upstream drivers. Every time a new webcam is added with some weird proprietary format, a decoder is added at libv4l. Due to that, _all_ V4L webcams are supported via libv4l. Also, it provides backport support to the old V4L1 API.

So, just remove v4l1.c driver and convert v4l2.c driver to use libv4l.
Tested here with several webcams supported by the latest gspca driver found at my upstream tree:
http://git.linuxtv.org/media_tree.git

Discussion

  • Mauro Carvalho Chehab

     
  • spadix

    spadix - 2010-12-10
    • status: open --> pending-rejected
     
  • spadix

    spadix - 2010-12-10

    > remove v4l1.c driver and convert v4l2.c driver

    Sorry, this doesn't make sense to me: we remove existing support and require another external dependency? As far as I understand the approach, we also lose visibility to the native camera formats, resulting in extra conversions or more expensive conversion paths.

    What would make sense is to leverage the v4l conversion library when it's available to provide support for missing conversions... I would certainly be interested in applying a patch that achieved that :)

     
  • SourceForge Robot

    • status: pending-rejected --> closed-rejected
     
  • SourceForge Robot

    This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 14 days (the time period specified by
    the administrator of this Tracker).

     
  • Mauro Carvalho Chehab

    The patch doesn't remove existing support, but, instead, it adds support for all cameras supported by the Linux Kernel.
    On my tests with about 15 different cameras, only 3 or 4 worked with the zbar, due to the lack of all those proprietary formats used by most cameras. With libv4l2, all of them worked fine.

    While the patch I sent doesn't use it, libv4l2 returns the flag V4L2_FMT_FLAG_EMULATED for the emulated formats, as an answer for VIDIOC_ENUM_FMT. So, it is possible to add a logic that will decide to use a non-emulated format if Zbar has support for it.

     
  • Mauro Carvalho Chehab

    • status: closed-rejected --> open-rejected
     
  • Mauro Carvalho Chehab

    • status: open-rejected --> open
     
  • Mauro Carvalho Chehab

    I've enclosed a patch that do the trick with the emulated flags. The second patch should be applied after the one that did the libv4l2 conversion.

    What the patch does is to try first the non-emulated formats. If none are supported, it chooses between the emulated ones.

    I tested here with two cameras. The first one is a Philips SPC230C (pac7302). This camera supports only a proprietary file format (fourcc: PJPG)

    The results with this camera are:

    $ zbarcam --nodisplay -vvvv_zbar_video_open: opened camera device /dev/video0 (fd=5)
    _zbar_v4l2_probe: USB Camera (093a:262c) on usb-0000:00:1d.0-1 driver pac7302 (version 2.11.0)
    _zbar_v4l2_probe: capabilities: CAPTURE READWRITE STREAMING
    ERROR: zbar video in v4l2_reset_crop():
    system error: querying crop support (VIDIOC_CROPCAP): Invalid argument (22)
    v4l2_probe_formats: enumerating supported formats:
    v4l2_probe_formats: [0] RGB3 : RGB3 EMULATED
    v4l2_probe_formats: [1] BGR3 : BGR3 EMULATED
    v4l2_probe_formats: [2] YU12 : YU12 EMULATED
    v4l2_probe_formats: [3] YV12 : YV12 EMULATED
    v4l2_probe_formats: Found 0 formats and 4 emulated formats.
    v4l2_probe_formats: current format: RGB3(33424752) 640 x 480 (line=0x780 size=0xe1000)
    v4l2_probe_formats: setting requested size: 40960 x 30720
    v4l2_probe_formats: final format: RGB3(33424752) 640 x 480 (line=0x780 size=0xe1000)
    _zbar_v4l2_probe: using I/O mode: MMAP
    proc_input_thread: spawned input thread
    _zbar_best_format: from YU12(32315559) to Y800(30303859)=1
    zbar_negotiate_format: YU12(32315559) -> Y800(30303859) (1)
    _zbar_best_format: from YV12(32315659) to Y800(30303859)=1
    zbar_negotiate_format: YV12(32315659) -> Y800(30303859) (1)
    _zbar_best_format: from RGB3(33424752) to Y800(30303859)=112
    zbar_negotiate_format: RGB3(33424752) -> Y800(30303859) (112)
    _zbar_best_format: from BGR3(33524742) to Y800(30303859)=112
    zbar_negotiate_format: BGR3(33524742) -> Y800(30303859) (112)
    zbar_negotiate_format: setting best format YU12(32315559) (1)
    v4l2_set_format: set new format: YU12(32315559) 640 x 480 (0x70800)
    v4l2_v4l2_mmap_buffers: mapping 4 buffers (of 4 requested)
    v4l2_v4l2_mmap_buffers: buf[0] 0x1000000 bytes @0xb2f3b000
    v4l2_v4l2_mmap_buffers: buf[1] 0x1000000 bytes @0xb3f3b000
    v4l2_v4l2_mmap_buffers: buf[2] 0x1000000 bytes @0xb4f3b000
    v4l2_v4l2_mmap_buffers: buf[3] 0x1000000 bytes @0xb5f3b000

    I tested also with an UVC camera that supports YUY format:

    $ zbarcam --nodisplay -vvvv
    _zbar_video_open: opened camera device /dev/video0 (fd=5)
    _zbar_v4l2_probe: Integrated Webcam on usb-0000:00:1a.7-3 driver uvcvideo (version 1.0.0)
    _zbar_v4l2_probe: capabilities: CAPTURE READWRITE STREAMING
    v4l2_reset_crop: crop bounds: 640 x 480 @ (0, 0)
    v4l2_reset_crop: current crop win: 640 x 480 @ (0, 0) aspect 1 / 1
    v4l2_probe_formats: enumerating supported formats:
    v4l2_probe_formats: [0] YUYV : YUV 4:2:2 (YUYV)
    v4l2_probe_formats: [1] RGB3 : RGB3 EMULATED
    v4l2_probe_formats: [2] BGR3 : BGR3 EMULATED
    v4l2_probe_formats: [3] YU12 : YU12 EMULATED
    v4l2_probe_formats: [4] YV12 : YV12 EMULATED
    v4l2_probe_formats: Found 1 formats and 4 emulated formats.
    v4l2_probe_formats: current format: YUYV(56595559) 640 x 480 (line=0x500 size=0x96000)
    _zbar_v4l2_probe: using I/O mode: MMAP
    proc_input_thread: spawned input thread
    _zbar_best_format: from YUYV(56595559) to Y800(30303859)=24
    zbar_negotiate_format: YUYV(56595559) -> Y800(30303859) (24)
    zbar_negotiate_format: setting best format YUYV(56595559) (24)
    v4l2_set_format: set new format: YUYV(56595559) 640 x 480 (0x96000)
    v4l2_v4l2_mmap_buffers: mapping 4 buffers (of 4 requested)
    v4l2_v4l2_mmap_buffers: buf[0] 0x96000 bytes @0xb6e6e000
    v4l2_v4l2_mmap_buffers: buf[1] 0x96000 bytes @0xb6dd8000
    v4l2_v4l2_mmap_buffers: buf[2] 0x96000 bytes @0xb6d42000
    v4l2_v4l2_mmap_buffers: buf[3] 0x96000 bytes @0xb6cac000

     
  • Mauro Carvalho Chehab

    Choose non-emulated formats first - version 2

     
  • Mauro Carvalho Chehab

    Version 2 changes:
    - Added some comments;
    - Free emu_formats.

     
  • Nobody/Anonymous

    With respect to V4L1 API, after years of migration to V4L2, V4L1 support will finally be removed from Linux Kernel on 2.6..38:

    http://git.linuxtv.org/media_tree.git?a=commit;h=e2981f3b2ab6865e972269b3f9ce78a698507a38

    There are only two very obsolete webcam drivers left that will either be converted to V4L2 (if one of the V4L webcam developers can put his hand on such devices) or they'll be removed on 2.6.39. Those drivers were moved to drivers/staging.

     

Log in to post a comment.