Opened 7 years ago

Closed 6 years ago

#1804 closed patch (fixed)

PATCH: use libv4l1 to add support for libv4l2 devices

Reported by: jwrdegoede Owned by:
Priority: normal Milestone: Bugs paradize
Component: Core: Input Version: master git
Severity: normal Keywords:
Cc: Difficulty: unknown
Platform(s): all Work status: Not started

Description

Short intro: I'm a long time Linux developer currently working on improving webcam support in Linux, see: http://fedoraproject.org/wiki/Features/BetterWebcamSupport

I'm one of the authors of the v4l2 rewrite of the gspca usb webcam driver framework (which supports more then 100 different cams), this v4l2 rewrite has been merged into the 2.6.27 kernel and thus will become available in the official Linux kernel soon.

One of the parts of the v4l2 rewrite has been removing conversion from various manufacturer cam specific video formats to more normal videoformats from the drivers, as this really does not belong in kernelspace.

As a result of this the gspca subdrivers can generate raw video frames in the following formats:

#define V4L2_PIX_FMT_SN9C10X v4l2_fourcc('S', '9', '1', '0') /* SN9C10x compressed bayer #define V4L2_PIX_FMT_SPCA501 v4l2_fourcc('S', '5', '0', '1') /* YUYV per line #define V4L2_PIX_FMT_SPCA505 v4l2_fourcc('S', '5', '0', '5') /* YYUV per line #define V4L2_PIX_FMT_SPCA508 v4l2_fourcc('S', '5', '0', '8') /* YUVY per line #define V4L2_PIX_FMT_SPCA561 v4l2_fourcc('S', '5', '6', '1') /* compressed GBRG bayer #define V4L2_PIX_FMT_PAC207 v4l2_fourcc('P', '2', '0', '7') /* compressed BGGR bayer

As we do not want to see each application implement (nor having to implement) support for these various formats, as we like to have one code base and only one code base for these formats. A library has been written (with me as the main author) to convert from these formats to BGR24 or YUV420. For more on this library see: http://hansdegoede.livejournal.com/3636.html

This library has 3 parts, the actual conversion lib, a library to make existing v4l2 applications use the conversion lib transparantly and a library which adds v4l1 emulation in userspace for v4l2 devices (the kernel space emulation is incomplete in many drivers).

As vlc sofar only has v4l1 support I've written a patch to use the v4l1 emulation lib, which means that with this patch not only the conversion will be handled but that vlc also will gain v4l2 support.

I've not (yet) made it so that the use of libv4l1 is conditional but doing so is trivial (assuming someone else will write the autoconf stuff)

You can get the latest version of libv4l here: http://people.atrpms.net/~hdegoede/libv4l-0.3.7.tar.gz

Note that this library is an official part of the v4l-dvb project, we just haven't gotten around yet to making a homepage for it at linuxtv.org, but if you look for example at the official v4l-dvb mercurial tree: http://linuxtv.org/hg/v4l-dvb Under v4l2-apps/lib/libv4l you will find libv4l there, a proper homepage is on my todo.

A note about the patch, the patch is actually quite simple, as libv4l1 has been designed for quick porting of existing apps to libv4l1, for this reason libv4l1 fully mimicks the raw v4l1 /dev/video interface.

All that the patch does and all that needs to be changed to use libv4l1 is replace the relevant xxx calls on /dev/video with v4l1_xxx calls.

Attachments (2)

vlc-0.8.6-libv4l1.patch (13.4 KB) - added by jwrdegoede 7 years ago.
PATCH adding support for using libv4l1 to the v4l plugin
vlc-0.9.3-libv4l2.patch (26.4 KB) - added by jwrdegoede 7 years ago.
PATCH: use libv4l2 in v4l2 plugin

Download all attachments as: .zip

Change History (4)

Changed 7 years ago by jwrdegoede

PATCH adding support for using libv4l1 to the v4l plugin

Changed 7 years ago by jwrdegoede

PATCH: use libv4l2 in v4l2 plugin

comment:1 Changed 7 years ago by jwrdegoede

Herton Ronaldo Krzesinski from mandriva has been so kind as to forward port my patch to vlc-0.9.2 attached is a version which I've then again forward ported to vlc-0.9.3 and added a few necessary fixes too. With this patch the vlc v4l2 plugin will support all the new cam formats produced by the now in the mainline gpsca v4l2 driver.

The only short coming of the current version in the patch is that it uses libv4l2 unconditionally. This can be easily fixed by doing something like this in the top of the v4l2.c file and adding the necessary autofoo stuff (libv4l2 comes with a .pc file):

#ifdef HAVE_LIBV4L2 #include <libv4l2.h> #else #define v4l2_fd_open(fd, flags) (fd) #define v4l2_close close #define v4l2_dup dup #define v4l2_ioctl ioctl #define v4l2_read read #define v4l2_mmap mmap #define v4l2_munmap munmap #endif

comment:2 Changed 6 years ago by xtophe

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.