aboutsummaryrefslogtreecommitdiffstats
path: root/include/media/v4l2-dev.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/media/v4l2-dev.h')
-rw-r--r--include/media/v4l2-dev.h75
1 files changed, 34 insertions, 41 deletions
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
index 2745e1afc722..a0a6b41c5e09 100644
--- a/include/media/v4l2-dev.h
+++ b/include/media/v4l2-dev.h
@@ -9,30 +9,20 @@
9#ifndef _V4L2_DEV_H 9#ifndef _V4L2_DEV_H
10#define _V4L2_DEV_H 10#define _V4L2_DEV_H
11 11
12#define OBSOLETE_DEVDATA 1 /* to be removed soon */
13
14#include <linux/poll.h> 12#include <linux/poll.h>
15#include <linux/fs.h> 13#include <linux/fs.h>
16#include <linux/device.h> 14#include <linux/device.h>
15#include <linux/cdev.h>
17#include <linux/mutex.h> 16#include <linux/mutex.h>
18#include <linux/compiler.h> /* need __user */
19#include <linux/videodev2.h> 17#include <linux/videodev2.h>
20 18
21#define VIDEO_MAJOR 81 19#define VIDEO_MAJOR 81
22/* Minor device allocation */
23#define MINOR_VFL_TYPE_GRABBER_MIN 0
24#define MINOR_VFL_TYPE_GRABBER_MAX 63
25#define MINOR_VFL_TYPE_RADIO_MIN 64
26#define MINOR_VFL_TYPE_RADIO_MAX 127
27#define MINOR_VFL_TYPE_VTX_MIN 192
28#define MINOR_VFL_TYPE_VTX_MAX 223
29#define MINOR_VFL_TYPE_VBI_MIN 224
30#define MINOR_VFL_TYPE_VBI_MAX 255
31 20
32#define VFL_TYPE_GRABBER 0 21#define VFL_TYPE_GRABBER 0
33#define VFL_TYPE_VBI 1 22#define VFL_TYPE_VBI 1
34#define VFL_TYPE_RADIO 2 23#define VFL_TYPE_RADIO 2
35#define VFL_TYPE_VTX 3 24#define VFL_TYPE_VTX 3
25#define VFL_TYPE_MAX 4
36 26
37struct v4l2_ioctl_callbacks; 27struct v4l2_ioctl_callbacks;
38 28
@@ -49,12 +39,15 @@ struct video_device
49 39
50 /* sysfs */ 40 /* sysfs */
51 struct device dev; /* v4l device */ 41 struct device dev; /* v4l device */
42 struct cdev cdev; /* character device */
43 void (*cdev_release)(struct kobject *kobj);
52 struct device *parent; /* device parent */ 44 struct device *parent; /* device parent */
53 45
54 /* device info */ 46 /* device info */
55 char name[32]; 47 char name[32];
56 int vfl_type; 48 int vfl_type;
57 int minor; 49 int minor;
50 u16 num;
58 /* attribute to differentiate multiple indices on one physical device */ 51 /* attribute to differentiate multiple indices on one physical device */
59 int index; 52 int index;
60 53
@@ -69,50 +62,50 @@ struct video_device
69 62
70 /* ioctl callbacks */ 63 /* ioctl callbacks */
71 const struct v4l2_ioctl_ops *ioctl_ops; 64 const struct v4l2_ioctl_ops *ioctl_ops;
72
73#ifdef OBSOLETE_DEVDATA /* to be removed soon */
74 /* dev->driver_data will be used instead some day.
75 * Use the video_{get|set}_drvdata() helper functions,
76 * so the switch over will be transparent for you.
77 * Or use {pci|usb}_{get|set}_drvdata() directly. */
78 void *priv;
79#endif
80
81 /* for videodev.c internal usage -- please don't touch */
82 int users; /* video_exclusive_{open|close} ... */
83 struct mutex lock; /* ... helper function uses these */
84}; 65};
85 66
86/* Class-dev to video-device */ 67/* dev to video-device */
87#define to_video_device(cd) container_of(cd, struct video_device, dev) 68#define to_video_device(cd) container_of(cd, struct video_device, dev)
88 69
89/* Version 2 functions */ 70/* Register and unregister devices. Note that if video_register_device fails,
90extern int video_register_device(struct video_device *vfd, int type, int nr); 71 the release() callback of the video_device structure is *not* called, so
91int video_register_device_index(struct video_device *vfd, int type, int nr, 72 the caller is responsible for freeing any data. Usually that means that
92 int index); 73 you call video_device_release() on failure. */
93void video_unregister_device(struct video_device *); 74int __must_check video_register_device(struct video_device *vfd, int type, int nr);
75int __must_check video_register_device_index(struct video_device *vfd,
76 int type, int nr, int index);
77void video_unregister_device(struct video_device *vfd);
94 78
95/* helper functions to alloc / release struct video_device, the 79/* helper functions to alloc/release struct video_device, the
96 later can be used for video_device->release() */ 80 latter can also be used for video_device->release(). */
97struct video_device *video_device_alloc(void); 81struct video_device * __must_check video_device_alloc(void);
82
83/* this release function frees the vfd pointer */
98void video_device_release(struct video_device *vfd); 84void video_device_release(struct video_device *vfd);
99 85
100#ifdef OBSOLETE_DEVDATA /* to be removed soon */ 86/* this release function does nothing, use when the video_device is a
87 static global struct. Note that having a static video_device is
88 a dubious construction at best. */
89void video_device_release_empty(struct video_device *vfd);
90
101/* helper functions to access driver private data. */ 91/* helper functions to access driver private data. */
102static inline void *video_get_drvdata(struct video_device *dev) 92static inline void *video_get_drvdata(struct video_device *dev)
103{ 93{
104 return dev->priv; 94 return dev_get_drvdata(&dev->dev);
105} 95}
106 96
107static inline void video_set_drvdata(struct video_device *dev, void *data) 97static inline void video_set_drvdata(struct video_device *dev, void *data)
108{ 98{
109 dev->priv = data; 99 dev_set_drvdata(&dev->dev, data);
110} 100}
111 101
112/* Obsolete stuff - Still needed for radio devices and obsolete drivers */ 102struct video_device *video_devdata(struct file *file);
113extern struct video_device* video_devdata(struct file*); 103
114extern int video_exclusive_open(struct inode *inode, struct file *file); 104/* Combine video_get_drvdata and video_devdata as this is
115extern int video_exclusive_release(struct inode *inode, struct file *file); 105 used very often. */
116#endif 106static inline void *video_drvdata(struct file *file)
107{
108 return video_get_drvdata(video_devdata(file));
109}
117 110
118#endif /* _V4L2_DEV_H */ 111#endif /* _V4L2_DEV_H */