]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - include/media/v4l2-dev.h
V4L/DVB (8482): videodev: move all ioctl callbacks to a new v4l2_ioctl_ops struct
[linux-2.6-omap-h63xx.git] / include / media / v4l2-dev.h
1 /*
2  *
3  *      V 4 L 2   D R I V E R   H E L P E R   A P I
4  *
5  * Moved from videodev2.h
6  *
7  *      Some commonly needed functions for drivers (v4l2-common.o module)
8  */
9 #ifndef _V4L2_DEV_H
10 #define _V4L2_DEV_H
11
12 #define OBSOLETE_OWNER   1 /* to be removed soon */
13 #define OBSOLETE_DEVDATA 1 /* to be removed soon */
14
15 #include <linux/poll.h>
16 #include <linux/fs.h>
17 #include <linux/device.h>
18 #include <linux/mutex.h>
19 #include <linux/compiler.h> /* need __user */
20 #ifdef CONFIG_VIDEO_V4L1_COMPAT
21 #include <linux/videodev.h>
22 #else
23 #include <linux/videodev2.h>
24 #endif
25
26 #define VIDEO_MAJOR     81
27 /* Minor device allocation */
28 #define MINOR_VFL_TYPE_GRABBER_MIN   0
29 #define MINOR_VFL_TYPE_GRABBER_MAX  63
30 #define MINOR_VFL_TYPE_RADIO_MIN    64
31 #define MINOR_VFL_TYPE_RADIO_MAX   127
32 #define MINOR_VFL_TYPE_VTX_MIN     192
33 #define MINOR_VFL_TYPE_VTX_MAX     223
34 #define MINOR_VFL_TYPE_VBI_MIN     224
35 #define MINOR_VFL_TYPE_VBI_MAX     255
36
37 #define VFL_TYPE_GRABBER        0
38 #define VFL_TYPE_VBI            1
39 #define VFL_TYPE_RADIO          2
40 #define VFL_TYPE_VTX            3
41
42 struct v4l2_ioctl_callbacks;
43
44 /*
45  * Newer version of video_device, handled by videodev2.c
46  *      This version moves redundant code from video device code to
47  *      the common handler
48  */
49
50 struct video_device
51 {
52         /* device ops */
53         const struct file_operations *fops;
54
55         /* sysfs */
56         struct device dev;              /* v4l device */
57         struct device *parent;          /* device parent */
58
59         /* device info */
60         char name[32];
61         int type;                       /* v4l1 */
62         int type2;                      /* v4l2 */
63         int minor;
64         /* attribute to diferentiate multiple indexs on one physical device */
65         int index;
66
67         int debug;                      /* Activates debug level*/
68
69         /* Video standard vars */
70         v4l2_std_id tvnorms;            /* Supported tv norms */
71         v4l2_std_id current_norm;       /* Current tvnorm */
72
73         /* callbacks */
74         void (*release)(struct video_device *vfd);
75
76         /* ioctl callbacks */
77         const struct v4l2_ioctl_ops *ioctl_ops;
78
79 #ifdef OBSOLETE_OWNER /* to be removed soon */
80 /* obsolete -- fops->owner is used instead */
81 struct module *owner;
82 /* dev->driver_data will be used instead some day.
83         * Use the video_{get|set}_drvdata() helper functions,
84         * so the switch over will be transparent for you.
85         * Or use {pci|usb}_{get|set}_drvdata() directly. */
86 void *priv;
87 #endif
88
89         /* for videodev.c intenal usage -- please don't touch */
90         int users;                     /* video_exclusive_{open|close} ... */
91         struct mutex lock;             /* ... helper function uses these   */
92 };
93
94 /* Class-dev to video-device */
95 #define to_video_device(cd) container_of(cd, struct video_device, dev)
96
97 /* Version 2 functions */
98 extern int video_register_device(struct video_device *vfd, int type, int nr);
99 int video_register_device_index(struct video_device *vfd, int type, int nr,
100                                         int index);
101 void video_unregister_device(struct video_device *);
102
103 /* helper functions to alloc / release struct video_device, the
104    later can be used for video_device->release() */
105 struct video_device *video_device_alloc(void);
106 void video_device_release(struct video_device *vfd);
107
108 #ifdef CONFIG_VIDEO_V4L1_COMPAT
109 #include <linux/mm.h>
110
111 static inline int __must_check
112 video_device_create_file(struct video_device *vfd,
113                          struct device_attribute *attr)
114 {
115         int ret = device_create_file(&vfd->dev, attr);
116         if (ret < 0)
117                 printk(KERN_WARNING "%s error: %d\n", __func__, ret);
118         return ret;
119 }
120 static inline void
121 video_device_remove_file(struct video_device *vfd,
122                          struct device_attribute *attr)
123 {
124         device_remove_file(&vfd->dev, attr);
125 }
126
127 #endif /* CONFIG_VIDEO_V4L1_COMPAT */
128
129 #ifdef OBSOLETE_OWNER /* to be removed soon */
130 /* helper functions to access driver private data. */
131 static inline void *video_get_drvdata(struct video_device *dev)
132 {
133         return dev->priv;
134 }
135
136 static inline void video_set_drvdata(struct video_device *dev, void *data)
137 {
138         dev->priv = data;
139 }
140
141 #endif
142
143 #ifdef OBSOLETE_DEVDATA /* to be removed soon */
144 /* Obsolete stuff - Still needed for radio devices and obsolete drivers */
145 extern struct video_device* video_devdata(struct file*);
146 extern int video_exclusive_open(struct inode *inode, struct file *file);
147 extern int video_exclusive_release(struct inode *inode, struct file *file);
148 #endif
149
150 #endif /* _V4L2_DEV_H */