Commit e028b61b authored by Gerd Knorr's avatar Gerd Knorr Committed by Linus Torvalds

[PATCH] add v4l2 api

This adds the v4l2 API to the linux kernel.

The first, original video4linux API has a number of design bugs.  They
are fixed in this new API revision.  It already exists for quite some
time.  Last weeks it got a number of cleanups based on the experiences
of the last years (drop stuff nobody uses, fix some inconsistencies).
We consider it being in a pretty good shape now and like to see it in
2.6.

This patch is basically the header file with all the structs and ioctls
in there.  A small module with some helper functions for v4l2 drivers is
included too.  Related updates (bttv, ...) will follow as separate
patches.
parent b7649ef7
......@@ -12,9 +12,14 @@ config VIDEO_DEV
this are available from
<ftp://ftp.uk.linux.org/pub/linux/video4linux/>.
If you are interested in writing a driver for such an audio/video
device or user software interacting with such a driver, please read
the file <file:Documentation/video4linux/API.html>.
This kernel includes support for the new Video for Linux Two API,
(V4L2) as well as the original system. Drivers and applications
need to be rewritten to use V4L2, but drivers for popular cards
and applications for most video capture functions already exist.
Documentation for the original API is included in the file
Documentation/video4linux/API.html. Documentation for V4L2 is
available on the web at http://bytesex.org/v4l/
This driver is also available as a module called videodev.o ( = code
which can be inserted in and removed from the running kernel
......
......@@ -5,13 +5,14 @@
# All of the (potential) objects that export symbols.
# This list comes from 'grep -l EXPORT_SYMBOL *.[hc]'.
export-objs := videodev.o bttv-if.o cpia.o video-buf.o
export-objs := videodev.o v4l2-common.o \
bttv-if.o cpia.o video-buf.o
bttv-objs := bttv-driver.o bttv-cards.o bttv-if.o \
bttv-risc.o bttv-vbi.o
zoran-objs := zr36120.o zr36120_i2c.o zr36120_mem.o
obj-$(CONFIG_VIDEO_DEV) += videodev.o
obj-$(CONFIG_VIDEO_DEV) += videodev.o v4l2-common.o
obj-$(CONFIG_VIDEO_BT848) += bttv.o msp3400.o tvaudio.o \
tda7432.o tda9875.o tuner.o video-buf.o
......
/*
* Video for Linux Two
*
* A generic video device interface for the LINUX operating system
* using a set of device structures/vectors for low level operations.
*
* This file replaces the videodev.c file that comes with the
* regular kernel distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
* Author: Bill Dirks <bdirks@pacbell.net>
* based on code by Alan Cox, <alan@cymru.net>
*
*/
/*
* Video capture interface for Linux
*
* A generic video device interface for the LINUX operating system
* using a set of device structures/vectors for low level operations.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
* Author: Alan Cox, <alan@redhat.com>
*
* Fixes:
*/
/*
* Video4linux 1/2 integration by Justin Schoeman
* <justin@suntiger.ee.up.ac.za>
* 2.4 PROCFS support ported from 2.4 kernels by
* Iaki Garca Etxebarria <garetxe@euskalnet.net>
* Makefile fix by "W. Michael Petullo" <mike@flyn.org>
* 2.4 devfs support ported from 2.4 kernels by
* Dan Merillat <dan@merillat.org>
* Added Gerd Knorrs v4l1 enhancements (Justin Schoeman)
*/
#include <linux/config.h>
#include <linux/version.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/smp_lock.h>
#include <linux/mm.h>
#include <linux/string.h>
#include <linux/errno.h>
#include <asm/uaccess.h>
#include <asm/system.h>
#include <asm/pgtable.h>
#include <asm/io.h>
#include <asm/div64.h>
#ifdef CONFIG_KMOD
#include <linux/kmod.h>
#endif
#if defined(CONFIG_UST) || defined(CONFIG_UST_MODULE)
#include <linux/ust.h>
#endif
#include <linux/videodev.h>
MODULE_AUTHOR("Bill Dirks, Justin Schoeman, Gerd Knorr");
MODULE_DESCRIPTION("misc helper functions for v4l2 device drivers");
MODULE_LICENSE("GPL");
/*
*
* V 4 L 2 D R I V E R H E L P E R A P I
*
*/
/*
* Video Standard Operations (contributed by Michael Schimek)
*/
/* This is the recommended method to deal with the framerate fields. More
sophisticated drivers will access the fields directly. */
unsigned int
v4l2_video_std_fps(struct v4l2_standard *vs)
{
if (vs->frameperiod.numerator > 0)
return (((vs->frameperiod.denominator << 8) /
vs->frameperiod.numerator) +
(1 << 7)) / (1 << 8);
return 0;
}
/* Fill in the fields of a v4l2_standard structure according to the
'id' and 'transmission' parameters. Returns negative on error. */
int v4l2_video_std_construct(struct v4l2_standard *vs,
int id, char *name)
{
memset(vs, 0, sizeof(struct v4l2_standard));
vs->id = id;
if (id & (V4L2_STD_NTSC | V4L2_STD_PAL_M)) {
vs->frameperiod.numerator = 1001;
vs->frameperiod.denominator = 30000;
vs->framelines = 525;
} else {
vs->frameperiod.numerator = 1;
vs->frameperiod.denominator = 25;
vs->framelines = 625;
}
strncpy(vs->name,name,sizeof(vs->name));
return 0;
}
/* ----------------------------------------------------------------- */
char *v4l2_field_names[] = {
[V4L2_FIELD_ANY] = "any",
[V4L2_FIELD_NONE] = "none",
[V4L2_FIELD_TOP] = "top",
[V4L2_FIELD_BOTTOM] = "bottom",
[V4L2_FIELD_INTERLACED] = "interlaced",
[V4L2_FIELD_SEQ_TB] = "seq-tb",
[V4L2_FIELD_SEQ_BT] = "seq-bt",
[V4L2_FIELD_ALTERNATE] = "alternate",
};
char *v4l2_type_names[] = {
[V4L2_BUF_TYPE_VIDEO_CAPTURE] = "video-cap",
[V4L2_BUF_TYPE_VIDEO_OVERLAY] = "video-over",
[V4L2_BUF_TYPE_VIDEO_OUTPUT] = "video-out",
[V4L2_BUF_TYPE_VBI_CAPTURE] = "vbi-cap",
[V4L2_BUF_TYPE_VBI_OUTPUT] = "vbi-out",
};
char *v4l2_ioctl_names[256] = {
#if __GNUC__ >= 3
[0 ... 255] = "UNKNOWN",
#endif
[_IOC_NR(VIDIOC_QUERYCAP)] = "VIDIOC_QUERYCAP",
[_IOC_NR(VIDIOC_RESERVED)] = "VIDIOC_RESERVED",
[_IOC_NR(VIDIOC_ENUM_FMT)] = "VIDIOC_ENUM_FMT",
[_IOC_NR(VIDIOC_G_FMT)] = "VIDIOC_G_FMT",
[_IOC_NR(VIDIOC_S_FMT)] = "VIDIOC_S_FMT",
#if 0
[_IOC_NR(VIDIOC_G_COMP)] = "VIDIOC_G_COMP",
[_IOC_NR(VIDIOC_S_COMP)] = "VIDIOC_S_COMP",
#endif
[_IOC_NR(VIDIOC_REQBUFS)] = "VIDIOC_REQBUFS",
[_IOC_NR(VIDIOC_QUERYBUF)] = "VIDIOC_QUERYBUF",
[_IOC_NR(VIDIOC_G_FBUF)] = "VIDIOC_G_FBUF",
[_IOC_NR(VIDIOC_S_FBUF)] = "VIDIOC_S_FBUF",
[_IOC_NR(VIDIOC_OVERLAY)] = "VIDIOC_OVERLAY",
[_IOC_NR(VIDIOC_QBUF)] = "VIDIOC_QBUF",
[_IOC_NR(VIDIOC_DQBUF)] = "VIDIOC_DQBUF",
[_IOC_NR(VIDIOC_STREAMON)] = "VIDIOC_STREAMON",
[_IOC_NR(VIDIOC_STREAMOFF)] = "VIDIOC_STREAMOFF",
[_IOC_NR(VIDIOC_G_PARM)] = "VIDIOC_G_PARM",
[_IOC_NR(VIDIOC_S_PARM)] = "VIDIOC_S_PARM",
[_IOC_NR(VIDIOC_G_STD)] = "VIDIOC_G_STD",
[_IOC_NR(VIDIOC_S_STD)] = "VIDIOC_S_STD",
[_IOC_NR(VIDIOC_ENUMSTD)] = "VIDIOC_ENUMSTD",
[_IOC_NR(VIDIOC_ENUMINPUT)] = "VIDIOC_ENUMINPUT",
[_IOC_NR(VIDIOC_G_CTRL)] = "VIDIOC_G_CTRL",
[_IOC_NR(VIDIOC_S_CTRL)] = "VIDIOC_S_CTRL",
[_IOC_NR(VIDIOC_G_TUNER)] = "VIDIOC_G_TUNER",
[_IOC_NR(VIDIOC_S_TUNER)] = "VIDIOC_S_TUNER",
[_IOC_NR(VIDIOC_G_AUDIO)] = "VIDIOC_G_AUDIO",
[_IOC_NR(VIDIOC_S_AUDIO)] = "VIDIOC_S_AUDIO",
[_IOC_NR(VIDIOC_QUERYCTRL)] = "VIDIOC_QUERYCTRL",
[_IOC_NR(VIDIOC_QUERYMENU)] = "VIDIOC_QUERYMENU",
[_IOC_NR(VIDIOC_G_INPUT)] = "VIDIOC_G_INPUT",
[_IOC_NR(VIDIOC_S_INPUT)] = "VIDIOC_S_INPUT",
[_IOC_NR(VIDIOC_G_OUTPUT)] = "VIDIOC_G_OUTPUT",
[_IOC_NR(VIDIOC_S_OUTPUT)] = "VIDIOC_S_OUTPUT",
[_IOC_NR(VIDIOC_ENUMOUTPUT)] = "VIDIOC_ENUMOUTPUT",
[_IOC_NR(VIDIOC_G_AUDOUT)] = "VIDIOC_G_AUDOUT",
[_IOC_NR(VIDIOC_S_AUDOUT)] = "VIDIOC_S_AUDOUT",
[_IOC_NR(VIDIOC_G_MODULATOR)] = "VIDIOC_G_MODULATOR",
[_IOC_NR(VIDIOC_S_MODULATOR)] = "VIDIOC_S_MODULATOR",
[_IOC_NR(VIDIOC_G_FREQUENCY)] = "VIDIOC_G_FREQUENCY",
[_IOC_NR(VIDIOC_S_FREQUENCY)] = "VIDIOC_S_FREQUENCY",
[_IOC_NR(VIDIOC_CROPCAP)] = "VIDIOC_CROPCAP",
[_IOC_NR(VIDIOC_G_CROP)] = "VIDIOC_G_CROP",
[_IOC_NR(VIDIOC_S_CROP)] = "VIDIOC_S_CROP",
[_IOC_NR(VIDIOC_G_JPEGCOMP)] = "VIDIOC_G_JPEGCOMP",
[_IOC_NR(VIDIOC_S_JPEGCOMP)] = "VIDIOC_S_JPEGCOMP",
[_IOC_NR(VIDIOC_QUERYSTD)] = "VIDIOC_QUERYSTD",
[_IOC_NR(VIDIOC_TRY_FMT)] = "VIDIOC_TRY_FMT",
};
/* ----------------------------------------------------------------- */
EXPORT_SYMBOL(v4l2_video_std_fps);
EXPORT_SYMBOL(v4l2_video_std_construct);
EXPORT_SYMBOL(v4l2_field_names);
EXPORT_SYMBOL(v4l2_type_names);
EXPORT_SYMBOL(v4l2_ioctl_names);
/*
* Local variables:
* c-basic-offset: 8
* End:
*/
......@@ -4,10 +4,10 @@
#include <linux/types.h>
#include <linux/version.h>
#if 0
#if 1
/*
* v4l2 is still work-in-progress, integration planed for 2.5.x
* v4l2 project homepage: http://www.thedirks.org/v4l2/
* documentation: http://bytesex.org/v4l/
* patches available from: http://bytesex.org/patches/
*/
# define HAVE_V4L2 1
......@@ -32,10 +32,7 @@ struct video_device
int minor;
/* new interface -- we will use file_operations directly
* like soundcore does.
* kernel_ioctl() will be called by video_generic_ioctl.
* video_generic_ioctl() does the userspace copying of the
* ioctl arguments */
* like soundcore does. */
struct file_operations *fops;
void *priv; /* Used to be 'private' but that upsets C++ */
......@@ -397,7 +394,7 @@ struct video_code
#define VID_HARDWARE_PWC 31 /* Philips webcams */
#define VID_HARDWARE_MEYE 32 /* Sony Vaio MotionEye cameras */
#define VID_HARDWARE_CPIA2 33
#define VID_HARDWARE_VICAM 34
#define VID_HARDWARE_VICAM 34
#endif /* __LINUX_VIDEODEV_H */
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment