[fpc-pascal] nested macros in C headers

Bernd prof7bit at googlemail.com
Sun May 1 00:59:11 CEST 2011

2011/4/24 Paulo Costa <paco at fe.up.pt>:

> Probably you are right. Let me know how does it works for you. Historically,
> we had a V4L unit for Kylix that was used with a Bt878 Frame Grabber and we
> had to build the new component when we wanted to use the USB cameras. Back
> then, some drivers were not available as V4L2.

I had some more time to look into this now, read some more
documentation and looked into the 5dpo sources.

Actually it really seems to be a full featured v4l2 implementation,
unfortunately I have only one v4l2 device to test it and the driver of
this device itself seems broken/incomplete. This diver will accept a
lot of different format settings without complaining but send its data
always as the same (probably jpeg) that I was not yet able to decode.
Other Applications have problems with this diver too.

The problem with v4l as I see it now is that it does not really define
a nice standard that could be easily used by the application. Only the
handshaking and camera settings are standardized, the actual data is
allowed to be transmitted in any of a myriad of possible formats, the
kernel guys don't like (don't allow) format conversion in kernel
space, so the driver just pumps the raw data from the camera to the
application. The application itself must be able to handle a zillion
of different video formats and encodings. Therefore it seems (from
what I understand so far) there exists a set of libraries that can (or
should) be used to wrap the raw v4l device into something that is
more application friendly and attempts to solve this problem.

This is what I will investigate next.

Currently I have an old v4l1 device with no existing v4l2 driver, so I
needed some way to access a v4l1 device. The units from 5dpo do not
contain the needed definitions to use v4l1, only v4l2.

So I wrote a bare bones minimal v4l1 unit from scratch, manually
translating the headers from the FreeBSD (better documentation)
videodev.h file, that contains only the absolute minimum that is
needed to open a v4l1 camera, set the image settings (brightness, etc)
and grab frames. Fortunately my camera outputs uncompressed RGB24

I am attaching the unit for documentation purposes (its really legacy
stuff, no new devices use v4l1 nowadays but there are still some old
cameras around needed for special purposes), maybe somebody else will
stumble over this while searching for the same problem. It also
contains a class with some methods that demonstrates how to open the
cam and grab images, I have used it in this current form to
sucessfully grab streaming images from an old QuickCam Express that
uses the qc-usb driver on kernel  2.6.24.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: v4l1.pas
Type: text/x-pascal
Size: 34397 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20110501/573db764/attachment.pas>

More information about the fpc-pascal mailing list