V4L/DVB (4065): Several improvements at videodev.c
Videodev now is capable of better handling V4L2 api, by processing V4L2 ioctls and using callbacks to the driver. The drivers should be migrated to the newer way and the older one will be obsoleted soon. Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
This commit is contained in:
parent
7565ab082d
commit
401998fa96
@ -25,6 +25,7 @@
|
|||||||
#include <linux/videodev2.h>
|
#include <linux/videodev2.h>
|
||||||
#include <linux/kdev_t.h>
|
#include <linux/kdev_t.h>
|
||||||
|
|
||||||
|
#include <media/v4l2-common.h>
|
||||||
#include <media/tuner.h>
|
#include <media/tuner.h>
|
||||||
#include <media/tveeprom.h>
|
#include <media/tveeprom.h>
|
||||||
#include <media/video-buf.h>
|
#include <media/video-buf.h>
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
#include <asm/io.h>
|
#include <asm/io.h>
|
||||||
|
|
||||||
|
#include <media/v4l2-common.h>
|
||||||
#include <media/tuner.h>
|
#include <media/tuner.h>
|
||||||
#include <media/ir-common.h>
|
#include <media/ir-common.h>
|
||||||
#include <media/ir-kbd-i2c.h>
|
#include <media/ir-kbd-i2c.h>
|
||||||
|
@ -59,6 +59,7 @@
|
|||||||
#include <asm/io.h>
|
#include <asm/io.h>
|
||||||
#include <asm/div64.h>
|
#include <asm/div64.h>
|
||||||
#include <linux/video_decoder.h>
|
#include <linux/video_decoder.h>
|
||||||
|
#define __OLD_VIDIOC_ /* To allow fixing old calls*/
|
||||||
#include <media/v4l2-common.h>
|
#include <media/v4l2-common.h>
|
||||||
|
|
||||||
#ifdef CONFIG_KMOD
|
#ifdef CONFIG_KMOD
|
||||||
@ -424,7 +425,9 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg)
|
|||||||
case TUNER_SET_TYPE_ADDR:
|
case TUNER_SET_TYPE_ADDR:
|
||||||
case TUNER_SET_STANDBY:
|
case TUNER_SET_STANDBY:
|
||||||
case TDA9887_SET_CONFIG:
|
case TDA9887_SET_CONFIG:
|
||||||
|
#ifdef __OLD_VIDIOC_
|
||||||
case VIDIOC_OVERLAY_OLD:
|
case VIDIOC_OVERLAY_OLD:
|
||||||
|
#endif
|
||||||
case VIDIOC_STREAMOFF:
|
case VIDIOC_STREAMOFF:
|
||||||
case VIDIOC_G_OUTPUT:
|
case VIDIOC_G_OUTPUT:
|
||||||
case VIDIOC_S_OUTPUT:
|
case VIDIOC_S_OUTPUT:
|
||||||
@ -440,7 +443,9 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg)
|
|||||||
case VIDIOC_G_AUDIO:
|
case VIDIOC_G_AUDIO:
|
||||||
case VIDIOC_S_AUDIO:
|
case VIDIOC_S_AUDIO:
|
||||||
case VIDIOC_ENUMAUDIO:
|
case VIDIOC_ENUMAUDIO:
|
||||||
|
#ifdef __OLD_VIDIOC_
|
||||||
case VIDIOC_G_AUDIO_OLD:
|
case VIDIOC_G_AUDIO_OLD:
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
struct v4l2_audio *p=arg;
|
struct v4l2_audio *p=arg;
|
||||||
|
|
||||||
@ -451,7 +456,9 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg)
|
|||||||
case VIDIOC_G_AUDOUT:
|
case VIDIOC_G_AUDOUT:
|
||||||
case VIDIOC_S_AUDOUT:
|
case VIDIOC_S_AUDOUT:
|
||||||
case VIDIOC_ENUMAUDOUT:
|
case VIDIOC_ENUMAUDOUT:
|
||||||
|
#ifdef __OLD_VIDIOC_
|
||||||
case VIDIOC_G_AUDOUT_OLD:
|
case VIDIOC_G_AUDOUT_OLD:
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
struct v4l2_audioout *p=arg;
|
struct v4l2_audioout *p=arg;
|
||||||
printk ("%s: index=%d, name=%s, capability=%d, mode=%d\n", s,
|
printk ("%s: index=%d, name=%s, capability=%d, mode=%d\n", s,
|
||||||
@ -496,7 +503,9 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg)
|
|||||||
}
|
}
|
||||||
case VIDIOC_G_CTRL:
|
case VIDIOC_G_CTRL:
|
||||||
case VIDIOC_S_CTRL:
|
case VIDIOC_S_CTRL:
|
||||||
|
#ifdef __OLD_VIDIOC_
|
||||||
case VIDIOC_S_CTRL_OLD:
|
case VIDIOC_S_CTRL_OLD:
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
struct v4l2_control *p=arg;
|
struct v4l2_control *p=arg;
|
||||||
printk ("%s: id=%d, value=%d\n", s, p->id, p->value);
|
printk ("%s: id=%d, value=%d\n", s, p->id, p->value);
|
||||||
@ -511,7 +520,9 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case VIDIOC_CROPCAP:
|
case VIDIOC_CROPCAP:
|
||||||
|
#ifdef __OLD_VIDIOC_
|
||||||
case VIDIOC_CROPCAP_OLD:
|
case VIDIOC_CROPCAP_OLD:
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
struct v4l2_cropcap *p=arg;
|
struct v4l2_cropcap *p=arg;
|
||||||
/*FIXME: Should also show rect structs */
|
/*FIXME: Should also show rect structs */
|
||||||
@ -703,7 +714,9 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg)
|
|||||||
}
|
}
|
||||||
case VIDIOC_G_PARM:
|
case VIDIOC_G_PARM:
|
||||||
case VIDIOC_S_PARM:
|
case VIDIOC_S_PARM:
|
||||||
|
#ifdef __OLD_VIDIOC_
|
||||||
case VIDIOC_S_PARM_OLD:
|
case VIDIOC_S_PARM_OLD:
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
struct v4l2_streamparm *p=arg;
|
struct v4l2_streamparm *p=arg;
|
||||||
printk ("%s: type=%d\n", s, p->type);
|
printk ("%s: type=%d\n", s, p->type);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,49 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* Video for Linux version 1 - OBSOLETE
|
||||||
|
*
|
||||||
|
* Header file for v4l1 drivers and applications, for
|
||||||
|
* Linux kernels 2.2.x or 2.4.x.
|
||||||
|
*
|
||||||
|
* Provides header for legacy drivers and applications
|
||||||
|
*
|
||||||
|
* See http://linuxtv.org for more info
|
||||||
|
*
|
||||||
|
*/
|
||||||
#ifndef __LINUX_VIDEODEV_H
|
#ifndef __LINUX_VIDEODEV_H
|
||||||
#define __LINUX_VIDEODEV_H
|
#define __LINUX_VIDEODEV_H
|
||||||
|
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
|
#include <linux/poll.h>
|
||||||
|
#include <linux/fs.h>
|
||||||
|
#include <linux/device.h>
|
||||||
|
#include <linux/mutex.h>
|
||||||
|
#include <linux/compiler.h> /* need __user */
|
||||||
|
|
||||||
#define HAVE_V4L1 1
|
#define HAVE_V4L1 1
|
||||||
|
|
||||||
#include <linux/videodev2.h>
|
#include <linux/videodev2.h>
|
||||||
|
|
||||||
#ifdef __KERNEL__
|
|
||||||
|
|
||||||
#include <linux/mm.h>
|
|
||||||
|
|
||||||
extern struct video_device* video_devdata(struct file*);
|
|
||||||
|
|
||||||
#define to_video_device(cd) container_of(cd, struct video_device, class_dev)
|
|
||||||
static inline void
|
|
||||||
video_device_create_file(struct video_device *vfd,
|
|
||||||
struct class_device_attribute *attr)
|
|
||||||
{
|
|
||||||
class_device_create_file(&vfd->class_dev, attr);
|
|
||||||
}
|
|
||||||
static inline void
|
|
||||||
video_device_remove_file(struct video_device *vfd,
|
|
||||||
struct class_device_attribute *attr)
|
|
||||||
{
|
|
||||||
class_device_remove_file(&vfd->class_dev, attr);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if OBSOLETE_OWNER /* to be removed in 2.6.15 */
|
|
||||||
/* helper functions to access driver private data. */
|
|
||||||
static inline void *video_get_drvdata(struct video_device *dev)
|
|
||||||
{
|
|
||||||
return dev->priv;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void video_set_drvdata(struct video_device *dev, void *data)
|
|
||||||
{
|
|
||||||
dev->priv = data;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern int video_exclusive_open(struct inode *inode, struct file *file);
|
|
||||||
extern int video_exclusive_release(struct inode *inode, struct file *file);
|
|
||||||
#endif /* __KERNEL__ */
|
|
||||||
|
|
||||||
struct video_capability
|
struct video_capability
|
||||||
{
|
{
|
||||||
char name[32];
|
char name[32];
|
||||||
@ -363,6 +342,11 @@ struct video_code
|
|||||||
#define VID_HARDWARE_SAA7114H 37
|
#define VID_HARDWARE_SAA7114H 37
|
||||||
#define VID_HARDWARE_SN9C102 38
|
#define VID_HARDWARE_SN9C102 38
|
||||||
#define VID_HARDWARE_ARV 39
|
#define VID_HARDWARE_ARV 39
|
||||||
|
|
||||||
|
#ifdef __KERNEL__
|
||||||
|
#include <media/v4l2-dev.h>
|
||||||
|
#endif /* __KERNEL__ */
|
||||||
|
|
||||||
#endif /* __LINUX_VIDEODEV_H */
|
#endif /* __LINUX_VIDEODEV_H */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1,29 +1,23 @@
|
|||||||
#ifndef __LINUX_VIDEODEV2_H
|
|
||||||
#define __LINUX_VIDEODEV2_H
|
|
||||||
/*
|
/*
|
||||||
* Video for Linux Two
|
* Video for Linux Two
|
||||||
*
|
*
|
||||||
* Header file for v4l or V4L2 drivers and applications, for
|
* Header file for v4l or V4L2 drivers and applications
|
||||||
* Linux kernels 2.2.x or 2.4.x.
|
* with public API.
|
||||||
|
* All kernel-specific stuff were moved to media/v4l2-dev.h, so
|
||||||
|
* no #if __KERNEL tests are allowed here
|
||||||
*
|
*
|
||||||
* See http://bytesex.org/v4l/ for API specs and other
|
* See http://linuxtv.org for more info
|
||||||
* v4l2 documentation.
|
|
||||||
*
|
*
|
||||||
* Author: Bill Dirks <bdirks@pacbell.net>
|
* Author: Bill Dirks <bdirks@pacbell.net>
|
||||||
* Justin Schoeman
|
* Justin Schoeman
|
||||||
* et al.
|
* et al.
|
||||||
*/
|
*/
|
||||||
#ifdef __KERNEL__
|
#ifndef __LINUX_VIDEODEV2_H
|
||||||
|
#define __LINUX_VIDEODEV2_H
|
||||||
#include <linux/time.h> /* need struct timeval */
|
#include <linux/time.h> /* need struct timeval */
|
||||||
#include <linux/poll.h>
|
|
||||||
#include <linux/device.h>
|
|
||||||
#include <linux/mutex.h>
|
|
||||||
#endif
|
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
#include <linux/compiler.h> /* need __user */
|
#include <linux/compiler.h> /* need __user */
|
||||||
|
|
||||||
|
|
||||||
#define OBSOLETE_OWNER 1 /* It will be removed for 2.6.17 */
|
|
||||||
#define HAVE_V4L2 1
|
#define HAVE_V4L2 1
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -48,71 +42,6 @@
|
|||||||
#define VID_TYPE_MJPEG_DECODER 4096 /* Can decode MJPEG streams */
|
#define VID_TYPE_MJPEG_DECODER 4096 /* Can decode MJPEG streams */
|
||||||
#define VID_TYPE_MJPEG_ENCODER 8192 /* Can encode MJPEG streams */
|
#define VID_TYPE_MJPEG_ENCODER 8192 /* Can encode MJPEG streams */
|
||||||
|
|
||||||
#ifdef __KERNEL__
|
|
||||||
|
|
||||||
/* Minor device allocation */
|
|
||||||
#define MINOR_VFL_TYPE_GRABBER_MIN 0
|
|
||||||
#define MINOR_VFL_TYPE_GRABBER_MAX 63
|
|
||||||
#define MINOR_VFL_TYPE_RADIO_MIN 64
|
|
||||||
#define MINOR_VFL_TYPE_RADIO_MAX 127
|
|
||||||
#define MINOR_VFL_TYPE_VTX_MIN 192
|
|
||||||
#define MINOR_VFL_TYPE_VTX_MAX 223
|
|
||||||
#define MINOR_VFL_TYPE_VBI_MIN 224
|
|
||||||
#define MINOR_VFL_TYPE_VBI_MAX 255
|
|
||||||
|
|
||||||
#define VFL_TYPE_GRABBER 0
|
|
||||||
#define VFL_TYPE_VBI 1
|
|
||||||
#define VFL_TYPE_RADIO 2
|
|
||||||
#define VFL_TYPE_VTX 3
|
|
||||||
|
|
||||||
struct video_device
|
|
||||||
{
|
|
||||||
/* device info */
|
|
||||||
struct device *dev;
|
|
||||||
char name[32];
|
|
||||||
int type; /* v4l1 */
|
|
||||||
int type2; /* v4l2 */
|
|
||||||
int hardware;
|
|
||||||
int minor;
|
|
||||||
|
|
||||||
/* device ops + callbacks */
|
|
||||||
const struct file_operations *fops;
|
|
||||||
void (*release)(struct video_device *vfd);
|
|
||||||
|
|
||||||
|
|
||||||
#if OBSOLETE_OWNER /* to be removed in 2.6.15 */
|
|
||||||
/* obsolete -- fops->owner is used instead */
|
|
||||||
struct module *owner;
|
|
||||||
/* dev->driver_data will be used instead some day.
|
|
||||||
* Use the video_{get|set}_drvdata() helper functions,
|
|
||||||
* so the switch over will be transparent for you.
|
|
||||||
* Or use {pci|usb}_{get|set}_drvdata() directly. */
|
|
||||||
void *priv;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* for videodev.c intenal usage -- please don't touch */
|
|
||||||
int users; /* video_exclusive_{open|close} ... */
|
|
||||||
struct mutex lock; /* ... helper function uses these */
|
|
||||||
char devfs_name[64]; /* devfs */
|
|
||||||
struct class_device class_dev; /* sysfs */
|
|
||||||
};
|
|
||||||
|
|
||||||
#define VIDEO_MAJOR 81
|
|
||||||
|
|
||||||
extern int video_register_device(struct video_device *, int type, int nr);
|
|
||||||
extern void video_unregister_device(struct video_device *);
|
|
||||||
extern int video_usercopy(struct inode *inode, struct file *file,
|
|
||||||
unsigned int cmd, unsigned long arg,
|
|
||||||
int (*func)(struct inode *inode, struct file *file,
|
|
||||||
unsigned int cmd, void *arg));
|
|
||||||
|
|
||||||
/* helper functions to alloc / release struct video_device, the
|
|
||||||
later can be used for video_device->release() */
|
|
||||||
struct video_device *video_device_alloc(void);
|
|
||||||
void video_device_release(struct video_device *vfd);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* M I S C E L L A N E O U S
|
* M I S C E L L A N E O U S
|
||||||
*/
|
*/
|
||||||
@ -1098,6 +1027,7 @@ struct v4l2_streamparm
|
|||||||
#endif
|
#endif
|
||||||
#define VIDIOC_LOG_STATUS _IO ('V', 70)
|
#define VIDIOC_LOG_STATUS _IO ('V', 70)
|
||||||
|
|
||||||
|
#ifdef __OLD_VIDIOC_
|
||||||
/* for compatibility, will go away some day */
|
/* for compatibility, will go away some day */
|
||||||
#define VIDIOC_OVERLAY_OLD _IOWR ('V', 14, int)
|
#define VIDIOC_OVERLAY_OLD _IOWR ('V', 14, int)
|
||||||
#define VIDIOC_S_PARM_OLD _IOW ('V', 22, struct v4l2_streamparm)
|
#define VIDIOC_S_PARM_OLD _IOW ('V', 22, struct v4l2_streamparm)
|
||||||
@ -1105,57 +1035,10 @@ struct v4l2_streamparm
|
|||||||
#define VIDIOC_G_AUDIO_OLD _IOWR ('V', 33, struct v4l2_audio)
|
#define VIDIOC_G_AUDIO_OLD _IOWR ('V', 33, struct v4l2_audio)
|
||||||
#define VIDIOC_G_AUDOUT_OLD _IOWR ('V', 49, struct v4l2_audioout)
|
#define VIDIOC_G_AUDOUT_OLD _IOWR ('V', 49, struct v4l2_audioout)
|
||||||
#define VIDIOC_CROPCAP_OLD _IOR ('V', 58, struct v4l2_cropcap)
|
#define VIDIOC_CROPCAP_OLD _IOR ('V', 58, struct v4l2_cropcap)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define BASE_VIDIOC_PRIVATE 192 /* 192-255 are private */
|
#define BASE_VIDIOC_PRIVATE 192 /* 192-255 are private */
|
||||||
|
|
||||||
|
|
||||||
#ifdef __KERNEL__
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* V 4 L 2 D R I V E R H E L P E R A P I
|
|
||||||
*
|
|
||||||
* Some commonly needed functions for drivers (v4l2-common.o module)
|
|
||||||
*/
|
|
||||||
#include <linux/fs.h>
|
|
||||||
|
|
||||||
/* Video standard functions */
|
|
||||||
extern unsigned int v4l2_video_std_fps(struct v4l2_standard *vs);
|
|
||||||
extern int v4l2_video_std_construct(struct v4l2_standard *vs,
|
|
||||||
int id, char *name);
|
|
||||||
|
|
||||||
/* prority handling */
|
|
||||||
struct v4l2_prio_state {
|
|
||||||
atomic_t prios[4];
|
|
||||||
};
|
|
||||||
int v4l2_prio_init(struct v4l2_prio_state *global);
|
|
||||||
int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local,
|
|
||||||
enum v4l2_priority new);
|
|
||||||
int v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local);
|
|
||||||
int v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority *local);
|
|
||||||
enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global);
|
|
||||||
int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority *local);
|
|
||||||
|
|
||||||
/* names for fancy debug output */
|
|
||||||
extern char *v4l2_field_names[];
|
|
||||||
extern char *v4l2_type_names[];
|
|
||||||
|
|
||||||
/* Compatibility layer interface -- v4l1-compat module */
|
|
||||||
typedef int (*v4l2_kioctl)(struct inode *inode, struct file *file,
|
|
||||||
unsigned int cmd, void *arg);
|
|
||||||
|
|
||||||
#ifdef CONFIG_VIDEO_V4L1_COMPAT
|
|
||||||
int v4l_compat_translate_ioctl(struct inode *inode, struct file *file,
|
|
||||||
int cmd, void *arg, v4l2_kioctl driver_ioctl);
|
|
||||||
#else
|
|
||||||
#define v4l_compat_translate_ioctl(inode,file,cmd,arg,ioctl) -EINVAL
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* 32 Bits compatibility layer for 64 bits processors */
|
|
||||||
extern long v4l_compat_ioctl32(struct file *file, unsigned int cmd,
|
|
||||||
unsigned long arg);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __KERNEL__ */
|
|
||||||
#endif /* __LINUX_VIDEODEV2_H */
|
#endif /* __LINUX_VIDEODEV2_H */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -26,8 +26,14 @@
|
|||||||
#ifndef V4L2_COMMON_H_
|
#ifndef V4L2_COMMON_H_
|
||||||
#define V4L2_COMMON_H_
|
#define V4L2_COMMON_H_
|
||||||
|
|
||||||
|
#include <media/v4l2-dev.h>
|
||||||
|
|
||||||
/* v4l debugging and diagnostics */
|
/* v4l debugging and diagnostics */
|
||||||
|
|
||||||
|
/* Debug bitmask flags to be used on V4L2 */
|
||||||
|
#define V4L2_DEBUG_IOCTL 0x01
|
||||||
|
#define V4L2_DEBUG_IOCTL_ARG 0x02
|
||||||
|
|
||||||
/* Common printk constucts for v4l-i2c drivers. These macros create a unique
|
/* Common printk constucts for v4l-i2c drivers. These macros create a unique
|
||||||
prefix consisting of the driver name, the adapter number and the i2c
|
prefix consisting of the driver name, the adapter number and the i2c
|
||||||
address. */
|
address. */
|
||||||
|
371
include/media/v4l2-dev.h
Normal file
371
include/media/v4l2-dev.h
Normal file
@ -0,0 +1,371 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* V 4 L 2 D R I V E R H E L P E R A P I
|
||||||
|
*
|
||||||
|
* Moved from videodev2.h
|
||||||
|
*
|
||||||
|
* Some commonly needed functions for drivers (v4l2-common.o module)
|
||||||
|
*/
|
||||||
|
#ifndef _V4L2_DEV_H
|
||||||
|
#define _V4L2_DEV_H
|
||||||
|
|
||||||
|
#define OBSOLETE_OWNER 1 /* to be removed soon */
|
||||||
|
|
||||||
|
#include <linux/poll.h>
|
||||||
|
#include <linux/fs.h>
|
||||||
|
#include <linux/device.h>
|
||||||
|
#include <linux/mutex.h>
|
||||||
|
#include <linux/compiler.h> /* need __user */
|
||||||
|
#ifdef CONFIG_VIDEO_V4L1
|
||||||
|
#include <linux/videodev.h>
|
||||||
|
#else
|
||||||
|
#include <linux/videodev2.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <linux/fs.h>
|
||||||
|
|
||||||
|
#define VIDEO_MAJOR 81
|
||||||
|
/* Minor device allocation */
|
||||||
|
#define MINOR_VFL_TYPE_GRABBER_MIN 0
|
||||||
|
#define MINOR_VFL_TYPE_GRABBER_MAX 63
|
||||||
|
#define MINOR_VFL_TYPE_RADIO_MIN 64
|
||||||
|
#define MINOR_VFL_TYPE_RADIO_MAX 127
|
||||||
|
#define MINOR_VFL_TYPE_VTX_MIN 192
|
||||||
|
#define MINOR_VFL_TYPE_VTX_MAX 223
|
||||||
|
#define MINOR_VFL_TYPE_VBI_MIN 224
|
||||||
|
#define MINOR_VFL_TYPE_VBI_MAX 255
|
||||||
|
|
||||||
|
#define VFL_TYPE_GRABBER 0
|
||||||
|
#define VFL_TYPE_VBI 1
|
||||||
|
#define VFL_TYPE_RADIO 2
|
||||||
|
#define VFL_TYPE_VTX 3
|
||||||
|
|
||||||
|
const struct file_operations *fops;
|
||||||
|
|
||||||
|
/* Video standard functions */
|
||||||
|
extern unsigned int v4l2_video_std_fps(struct v4l2_standard *vs);
|
||||||
|
extern int v4l2_video_std_construct(struct v4l2_standard *vs,
|
||||||
|
int id, char *name);
|
||||||
|
|
||||||
|
/* prority handling */
|
||||||
|
struct v4l2_prio_state {
|
||||||
|
atomic_t prios[4];
|
||||||
|
};
|
||||||
|
int v4l2_prio_init(struct v4l2_prio_state *global);
|
||||||
|
int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local,
|
||||||
|
enum v4l2_priority new);
|
||||||
|
int v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local);
|
||||||
|
int v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority *local);
|
||||||
|
enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global);
|
||||||
|
int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority *local);
|
||||||
|
|
||||||
|
/* names for fancy debug output */
|
||||||
|
extern char *v4l2_field_names[];
|
||||||
|
extern char *v4l2_type_names[];
|
||||||
|
|
||||||
|
/* Compatibility layer interface -- v4l1-compat module */
|
||||||
|
typedef int (*v4l2_kioctl)(struct inode *inode, struct file *file,
|
||||||
|
unsigned int cmd, void *arg);
|
||||||
|
#ifdef CONFIG_VIDEO_V4L1_COMPAT
|
||||||
|
int v4l_compat_translate_ioctl(struct inode *inode, struct file *file,
|
||||||
|
int cmd, void *arg, v4l2_kioctl driver_ioctl);
|
||||||
|
#else
|
||||||
|
#define v4l_compat_translate_ioctl(inode,file,cmd,arg,ioctl) -EINVAL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* 32 Bits compatibility layer for 64 bits processors */
|
||||||
|
extern long v4l_compat_ioctl32(struct file *file, unsigned int cmd,
|
||||||
|
unsigned long arg);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Newer version of video_device, handled by videodev2.c
|
||||||
|
* This version moves redundant code from video device code to
|
||||||
|
* the common handler
|
||||||
|
*/
|
||||||
|
struct v4l2_tvnorm {
|
||||||
|
char *name;
|
||||||
|
v4l2_std_id id;
|
||||||
|
|
||||||
|
void *priv_data;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct video_device
|
||||||
|
{
|
||||||
|
/* device ops */
|
||||||
|
struct file_operations *fops;
|
||||||
|
|
||||||
|
/* device info */
|
||||||
|
struct device *dev;
|
||||||
|
char name[32];
|
||||||
|
int type; /* v4l1 */
|
||||||
|
int type2; /* v4l2 */
|
||||||
|
int hardware;
|
||||||
|
int minor;
|
||||||
|
|
||||||
|
int debug; /* Activates debug level*/
|
||||||
|
|
||||||
|
/* Video standard vars */
|
||||||
|
int tvnormsize; /* Size of tvnorm array */
|
||||||
|
v4l2_std_id current_norm; /* Current tvnorm */
|
||||||
|
struct v4l2_tvnorm *tvnorms;
|
||||||
|
|
||||||
|
/* callbacks */
|
||||||
|
void (*release)(struct video_device *vfd);
|
||||||
|
|
||||||
|
/* ioctl callbacks */
|
||||||
|
|
||||||
|
/* VIDIOC_QUERYCAP handler */
|
||||||
|
int (*vidioc_querycap)(struct file *file, void *fh, struct v4l2_capability *cap);
|
||||||
|
|
||||||
|
/* Priority handling */
|
||||||
|
int (*vidioc_g_priority) (struct file *file, void *fh,
|
||||||
|
enum v4l2_priority *p);
|
||||||
|
int (*vidioc_s_priority) (struct file *file, void *fh,
|
||||||
|
enum v4l2_priority p);
|
||||||
|
|
||||||
|
/* VIDIOC_ENUM_FMT handlers */
|
||||||
|
int (*vidioc_enum_fmt_cap) (struct file *file, void *fh,
|
||||||
|
struct v4l2_fmtdesc *f);
|
||||||
|
int (*vidioc_enum_fmt_overlay) (struct file *file, void *fh,
|
||||||
|
struct v4l2_fmtdesc *f);
|
||||||
|
int (*vidioc_enum_fmt_vbi) (struct file *file, void *fh,
|
||||||
|
struct v4l2_fmtdesc *f);
|
||||||
|
int (*vidioc_enum_fmt_vbi_capture) (struct file *file, void *fh,
|
||||||
|
struct v4l2_fmtdesc *f);
|
||||||
|
int (*vidioc_enum_fmt_video_output)(struct file *file, void *fh,
|
||||||
|
struct v4l2_fmtdesc *f);
|
||||||
|
int (*vidioc_enum_fmt_vbi_output) (struct file *file, void *fh,
|
||||||
|
struct v4l2_fmtdesc *f);
|
||||||
|
int (*vidioc_enum_fmt_type_private)(struct file *file, void *fh,
|
||||||
|
struct v4l2_fmtdesc *f);
|
||||||
|
|
||||||
|
/* VIDIOC_G_FMT handlers */
|
||||||
|
int (*vidioc_g_fmt_cap) (struct file *file, void *fh,
|
||||||
|
struct v4l2_format *f);
|
||||||
|
int (*vidioc_g_fmt_overlay) (struct file *file, void *fh,
|
||||||
|
struct v4l2_format *f);
|
||||||
|
int (*vidioc_g_fmt_vbi) (struct file *file, void *fh,
|
||||||
|
struct v4l2_format *f);
|
||||||
|
int (*vidioc_g_fmt_vbi_output) (struct file *file, void *fh,
|
||||||
|
struct v4l2_format *f);
|
||||||
|
int (*vidioc_g_fmt_vbi_capture)(struct file *file, void *fh,
|
||||||
|
struct v4l2_format *f);
|
||||||
|
int (*vidioc_g_fmt_video_output)(struct file *file, void *fh,
|
||||||
|
struct v4l2_format *f);
|
||||||
|
int (*vidioc_g_fmt_type_private)(struct file *file, void *fh,
|
||||||
|
struct v4l2_format *f);
|
||||||
|
|
||||||
|
/* VIDIOC_S_FMT handlers */
|
||||||
|
int (*vidioc_s_fmt_cap) (struct file *file, void *fh,
|
||||||
|
struct v4l2_format *f);
|
||||||
|
|
||||||
|
int (*vidioc_s_fmt_overlay) (struct file *file, void *fh,
|
||||||
|
struct v4l2_format *f);
|
||||||
|
int (*vidioc_s_fmt_vbi) (struct file *file, void *fh,
|
||||||
|
struct v4l2_format *f);
|
||||||
|
int (*vidioc_s_fmt_vbi_output) (struct file *file, void *fh,
|
||||||
|
struct v4l2_format *f);
|
||||||
|
int (*vidioc_s_fmt_vbi_capture)(struct file *file, void *fh,
|
||||||
|
struct v4l2_format *f);
|
||||||
|
int (*vidioc_s_fmt_video_output)(struct file *file, void *fh,
|
||||||
|
struct v4l2_format *f);
|
||||||
|
int (*vidioc_s_fmt_type_private)(struct file *file, void *fh,
|
||||||
|
struct v4l2_format *f);
|
||||||
|
|
||||||
|
/* VIDIOC_TRY_FMT handlers */
|
||||||
|
int (*vidioc_try_fmt_cap) (struct file *file, void *fh,
|
||||||
|
struct v4l2_format *f);
|
||||||
|
int (*vidioc_try_fmt_overlay) (struct file *file, void *fh,
|
||||||
|
struct v4l2_format *f);
|
||||||
|
int (*vidioc_try_fmt_vbi) (struct file *file, void *fh,
|
||||||
|
struct v4l2_format *f);
|
||||||
|
int (*vidioc_try_fmt_vbi_output) (struct file *file, void *fh,
|
||||||
|
struct v4l2_format *f);
|
||||||
|
int (*vidioc_try_fmt_vbi_capture)(struct file *file, void *fh,
|
||||||
|
struct v4l2_format *f);
|
||||||
|
int (*vidioc_try_fmt_video_output)(struct file *file, void *fh,
|
||||||
|
struct v4l2_format *f);
|
||||||
|
int (*vidioc_try_fmt_type_private)(struct file *file, void *fh,
|
||||||
|
struct v4l2_format *f);
|
||||||
|
|
||||||
|
/* Buffer handlers */
|
||||||
|
int (*vidioc_reqbufs) (struct file *file, void *fh, struct v4l2_requestbuffers *b);
|
||||||
|
int (*vidioc_querybuf)(struct file *file, void *fh, struct v4l2_buffer *b);
|
||||||
|
int (*vidioc_qbuf) (struct file *file, void *fh, struct v4l2_buffer *b);
|
||||||
|
int (*vidioc_dqbuf) (struct file *file, void *fh, struct v4l2_buffer *b);
|
||||||
|
|
||||||
|
|
||||||
|
int (*vidioc_overlay) (struct file *file, void *fh, unsigned int i);
|
||||||
|
#ifdef HAVE_V4L1
|
||||||
|
/* buffer type is struct vidio_mbuf * */
|
||||||
|
int (*vidiocgmbuf) (struct file *file, void *fh, struct video_mbuf *p);
|
||||||
|
#endif
|
||||||
|
int (*vidioc_g_fbuf) (struct file *file, void *fh,
|
||||||
|
struct v4l2_framebuffer *a);
|
||||||
|
int (*vidioc_s_fbuf) (struct file *file, void *fh,
|
||||||
|
struct v4l2_framebuffer *a);
|
||||||
|
|
||||||
|
/* Stream on/off */
|
||||||
|
int (*vidioc_streamon) (struct file *file, void *fh, enum v4l2_buf_type i);
|
||||||
|
int (*vidioc_streamoff)(struct file *file, void *fh, enum v4l2_buf_type i);
|
||||||
|
|
||||||
|
/* Standard handling
|
||||||
|
G_STD and ENUMSTD are handled by videodev.c
|
||||||
|
*/
|
||||||
|
int (*vidioc_s_std) (struct file *file, void *fh, v4l2_std_id a);
|
||||||
|
int (*vidioc_querystd) (struct file *file, void *fh, v4l2_std_id *a);
|
||||||
|
|
||||||
|
/* Input handling */
|
||||||
|
int (*vidioc_enum_input)(struct file *file, void *fh,
|
||||||
|
struct v4l2_input *inp);
|
||||||
|
int (*vidioc_g_input) (struct file *file, void *fh, unsigned int *i);
|
||||||
|
int (*vidioc_s_input) (struct file *file, void *fh, unsigned int i);
|
||||||
|
|
||||||
|
/* Output handling */
|
||||||
|
int (*vidioc_enumoutput) (struct file *file, void *fh,
|
||||||
|
struct v4l2_output *a);
|
||||||
|
int (*vidioc_g_output) (struct file *file, void *fh, unsigned int *i);
|
||||||
|
int (*vidioc_s_output) (struct file *file, void *fh, unsigned int i);
|
||||||
|
|
||||||
|
/* Control handling */
|
||||||
|
int (*vidioc_queryctrl) (struct file *file, void *fh,
|
||||||
|
struct v4l2_queryctrl *a);
|
||||||
|
int (*vidioc_g_ctrl) (struct file *file, void *fh,
|
||||||
|
struct v4l2_control *a);
|
||||||
|
int (*vidioc_s_ctrl) (struct file *file, void *fh,
|
||||||
|
struct v4l2_control *a);
|
||||||
|
int (*vidioc_querymenu) (struct file *file, void *fh,
|
||||||
|
struct v4l2_querymenu *a);
|
||||||
|
|
||||||
|
/* Audio ioctls */
|
||||||
|
int (*vidioc_enumaudio) (struct file *file, void *fh,
|
||||||
|
struct v4l2_audio *a);
|
||||||
|
int (*vidioc_g_audio) (struct file *file, void *fh,
|
||||||
|
struct v4l2_audio *a);
|
||||||
|
int (*vidioc_s_audio) (struct file *file, void *fh,
|
||||||
|
struct v4l2_audio *a);
|
||||||
|
|
||||||
|
/* Audio out ioctls */
|
||||||
|
int (*vidioc_enumaudout) (struct file *file, void *fh,
|
||||||
|
struct v4l2_audioout *a);
|
||||||
|
int (*vidioc_g_audout) (struct file *file, void *fh,
|
||||||
|
struct v4l2_audioout *a);
|
||||||
|
int (*vidioc_s_audout) (struct file *file, void *fh,
|
||||||
|
struct v4l2_audioout *a);
|
||||||
|
int (*vidioc_g_modulator) (struct file *file, void *fh,
|
||||||
|
struct v4l2_modulator *a);
|
||||||
|
int (*vidioc_s_modulator) (struct file *file, void *fh,
|
||||||
|
struct v4l2_modulator *a);
|
||||||
|
/* Crop ioctls */
|
||||||
|
int (*vidioc_cropcap) (struct file *file, void *fh,
|
||||||
|
struct v4l2_cropcap *a);
|
||||||
|
int (*vidioc_g_crop) (struct file *file, void *fh,
|
||||||
|
struct v4l2_crop *a);
|
||||||
|
int (*vidioc_s_crop) (struct file *file, void *fh,
|
||||||
|
struct v4l2_crop *a);
|
||||||
|
/* Compression ioctls */
|
||||||
|
int (*vidioc_g_mpegcomp) (struct file *file, void *fh,
|
||||||
|
struct v4l2_mpeg_compression *a);
|
||||||
|
int (*vidioc_s_mpegcomp) (struct file *file, void *fh,
|
||||||
|
struct v4l2_mpeg_compression *a);
|
||||||
|
int (*vidioc_g_jpegcomp) (struct file *file, void *fh,
|
||||||
|
struct v4l2_jpegcompression *a);
|
||||||
|
int (*vidioc_s_jpegcomp) (struct file *file, void *fh,
|
||||||
|
struct v4l2_jpegcompression *a);
|
||||||
|
|
||||||
|
/* Stream type-dependent parameter ioctls */
|
||||||
|
int (*vidioc_g_parm) (struct file *file, void *fh,
|
||||||
|
struct v4l2_streamparm *a);
|
||||||
|
int (*vidioc_s_parm) (struct file *file, void *fh,
|
||||||
|
struct v4l2_streamparm *a);
|
||||||
|
|
||||||
|
/* Tuner ioctls */
|
||||||
|
int (*vidioc_g_tuner) (struct file *file, void *fh,
|
||||||
|
struct v4l2_tuner *a);
|
||||||
|
int (*vidioc_s_tuner) (struct file *file, void *fh,
|
||||||
|
struct v4l2_tuner *a);
|
||||||
|
int (*vidioc_g_frequency) (struct file *file, void *fh,
|
||||||
|
struct v4l2_frequency *a);
|
||||||
|
int (*vidioc_s_frequency) (struct file *file, void *fh,
|
||||||
|
struct v4l2_frequency *a);
|
||||||
|
|
||||||
|
/* Sliced VBI cap */
|
||||||
|
int (*vidioc_g_sliced_vbi_cap) (struct file *file, void *fh,
|
||||||
|
struct v4l2_sliced_vbi_cap *a);
|
||||||
|
|
||||||
|
/* Log status ioctl */
|
||||||
|
int (*vidioc_log_status) (struct file *file, void *fh);
|
||||||
|
|
||||||
|
|
||||||
|
#if OBSOLETE_OWNER /* to be removed soon */
|
||||||
|
/* obsolete -- fops->owner is used instead */
|
||||||
|
struct module *owner;
|
||||||
|
/* dev->driver_data will be used instead some day.
|
||||||
|
* Use the video_{get|set}_drvdata() helper functions,
|
||||||
|
* so the switch over will be transparent for you.
|
||||||
|
* Or use {pci|usb}_{get|set}_drvdata() directly. */
|
||||||
|
void *priv;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* for videodev.c intenal usage -- please don't touch */
|
||||||
|
int users; /* video_exclusive_{open|close} ... */
|
||||||
|
struct mutex lock; /* ... helper function uses these */
|
||||||
|
char devfs_name[64]; /* devfs */
|
||||||
|
struct class_device class_dev; /* sysfs */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Version 2 functions */
|
||||||
|
extern int video_register_device(struct video_device *vfd, int type, int nr);
|
||||||
|
void video_unregister_device(struct video_device *);
|
||||||
|
extern int video_ioctl2(struct inode *inode, struct file *file,
|
||||||
|
unsigned int cmd, unsigned long arg);
|
||||||
|
|
||||||
|
/* helper functions to alloc / release struct video_device, the
|
||||||
|
later can be used for video_device->release() */
|
||||||
|
struct video_device *video_device_alloc(void);
|
||||||
|
void video_device_release(struct video_device *vfd);
|
||||||
|
|
||||||
|
/* Include support for obsoleted stuff */
|
||||||
|
extern int video_usercopy(struct inode *inode, struct file *file,
|
||||||
|
unsigned int cmd, unsigned long arg,
|
||||||
|
int (*func)(struct inode *inode, struct file *file,
|
||||||
|
unsigned int cmd, void *arg));
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef HAVE_V4L1
|
||||||
|
#include <linux/mm.h>
|
||||||
|
|
||||||
|
extern struct video_device* video_devdata(struct file*);
|
||||||
|
|
||||||
|
#define to_video_device(cd) container_of(cd, struct video_device, class_dev)
|
||||||
|
static inline void
|
||||||
|
video_device_create_file(struct video_device *vfd,
|
||||||
|
struct class_device_attribute *attr)
|
||||||
|
{
|
||||||
|
class_device_create_file(&vfd->class_dev, attr);
|
||||||
|
}
|
||||||
|
static inline void
|
||||||
|
video_device_remove_file(struct video_device *vfd,
|
||||||
|
struct class_device_attribute *attr)
|
||||||
|
{
|
||||||
|
class_device_remove_file(&vfd->class_dev, attr);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if OBSOLETE_OWNER /* to be removed soon */
|
||||||
|
/* helper functions to access driver private data. */
|
||||||
|
static inline void *video_get_drvdata(struct video_device *dev)
|
||||||
|
{
|
||||||
|
return dev->priv;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void video_set_drvdata(struct video_device *dev, void *data)
|
||||||
|
{
|
||||||
|
dev->priv = data;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern int video_exclusive_open(struct inode *inode, struct file *file);
|
||||||
|
extern int video_exclusive_release(struct inode *inode, struct file *file);
|
||||||
|
#endif /* HAVE_V4L1 */
|
||||||
|
|
||||||
|
#endif /* _V4L2_DEV_H */
|
@ -23,6 +23,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <linux/videodev2.h>
|
#include <linux/videodev2.h>
|
||||||
|
#include <linux/poll.h>
|
||||||
|
|
||||||
#define UNSET (-1U)
|
#define UNSET (-1U)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user