List:       linux-video
Subject:    V4L2 update
From:       Bill Dirks <dirks () rendition ! com>
Date:       1999-03-18 4:30:15

New V4L2 files and documentation is available on the V4L2 site:
http://millennium.diads.com/bdirks/v4l2.htm

The big new thing is the v4l backward compatibility layer so v4l apps
can work with V4L2 drivers. The v4l compability is largely untested, but
I thought it would be useful to make what I had available. I haven't
attempted mmapped capture yet.

Changes:
- Videodev.h combines v4l and V4L2 symbols. The v4l stuff is all based
on version 2.2.1.

- I've added a few more controls, red/blue balance, gamma, etc.

- The numerical values of the V4L2 ioctls have all been changed to
guarantee there are no conflicts with v4l. All V4L2 drivers and
applications will have to be recompiled. None of the symbol names are
changed, so it is still source code compatible.

- Driver writers, the driver v4l2_device.ioctl method call is changed!
The prototype is the same, but the 'arg' argument now points to a
temporary buffer in kernel memory (when 'arg' is a pointer). You no
longer need to make little temp variables in your ioctl function and do
all those copy_*_user() calls. For example code that looked like:

case VIDIOC_IOCTL:
{
	struct v4l2_structure obj;
	if (copy_from_user(&obj, arg, sizeof(obj)))
		return -EFAULT;
	dev->field = obj.field;
	obj.field2 = zzz;
	if (copy_to_user(arg, &obj, sizeof(obj)))
		return -EFAULT;
	return 0;
}

Now looks like:

case VIDIOC_IOCTL:
{
	struct v4l2_structure *obj = arg;
	dev->field = obj->field;
	obj->field2 = zzz;
	return 0;
}

If your driver is like mine, you should be able to delete about 50 lines
of code. :-)

- About the v4l compatibility: It just translates ioctls. All incoming
ioctl calls are passed to the driver first. If the driver returns
-ENOIOCTLCMD, then the ioctl code is inspected and if it is a v4l ioctl
then translate_ioctl() is called. A V4L2 driver can handle a v4l ioctl
if desired. A V4L2 driver can also disable a v4l ioctl by returning
-EINVAL for it (or any other error code besides -ENOIOCTLCMD).
Translate_ioctl() works by converting v4l ioctl codes and arguments into
equivalent (or similar :) V4L2 ioctl commands. I won't go into the
details, you can take a peek at videodev.c if you're curious.

In fact, if somebody would like to take a look at it, try it out, it
would be really great to have another pair of eyeballs on it...

Bill.


-- 
         To unsubscribe: mail video4linux-list-request@redhat.com with 
                       "unsubscribe" as the Subject.