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