2fe38858516b6441c1eddd93769988f547b96cc1
[safe/jmp/linux-2.6] / 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 #include <linux/videodev2.h>
20
21 #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
32 #define VFL_TYPE_GRABBER        0
33 #define VFL_TYPE_VBI            1
34 #define VFL_TYPE_RADIO          2
35 #define VFL_TYPE_VTX            3
36
37 struct v4l2_ioctl_callbacks;
38
39 /*
40  * Newer version of video_device, handled by videodev2.c
41  *      This version moves redundant code from video device code to
42  *      the common handler
43  */
44
45 struct video_device
46 {
47         /* device ops */
48         const struct file_operations *fops;
49
50         /* sysfs */
51         struct device dev;              /* v4l device */
52         struct device *parent;          /* device parent */
53
54         /* device info */
55         char name[32];
56         int type;                       /* v4l1 */
57         int type2;                      /* v4l2 */
58         int minor;
59         /* attribute to diferentiate multiple indexs on one physical device */
60         int index;
61
62         int debug;                      /* Activates debug level*/
63
64         /* Video standard vars */
65         v4l2_std_id tvnorms;            /* Supported tv norms */
66         v4l2_std_id current_norm;       /* Current tvnorm */
67
68         /* callbacks */
69         void (*release)(struct video_device *vfd);
70
71         /* ioctl callbacks */
72         const struct v4l2_ioctl_ops *ioctl_ops;
73
74 #ifdef OBSOLETE_DEVDATA /* to be removed soon */
75         /* dev->driver_data will be used instead some day.
76          * Use the video_{get|set}_drvdata() helper functions,
77          * so the switch over will be transparent for you.
78          * Or use {pci|usb}_{get|set}_drvdata() directly. */
79         void *priv;
80 #endif
81
82         /* for videodev.c intenal usage -- please don't touch */
83         int users;                     /* video_exclusive_{open|close} ... */
84         struct mutex lock;             /* ... helper function uses these   */
85 };
86
87 /* Class-dev to video-device */
88 #define to_video_device(cd) container_of(cd, struct video_device, dev)
89
90 /* Version 2 functions */
91 extern int video_register_device(struct video_device *vfd, int type, int nr);
92 int video_register_device_index(struct video_device *vfd, int type, int nr,
93                                         int index);
94 void video_unregister_device(struct video_device *);
95
96 /* helper functions to alloc / release struct video_device, the
97    later can be used for video_device->release() */
98 struct video_device *video_device_alloc(void);
99 void video_device_release(struct video_device *vfd);
100
101 #ifdef OBSOLETE_DEVDATA /* to be removed soon */
102 /* helper functions to access driver private data. */
103 static inline void *video_get_drvdata(struct video_device *dev)
104 {
105         return dev->priv;
106 }
107
108 static inline void video_set_drvdata(struct video_device *dev, void *data)
109 {
110         dev->priv = data;
111 }
112
113 /* Obsolete stuff - Still needed for radio devices and obsolete drivers */
114 extern struct video_device* video_devdata(struct file*);
115 extern int video_exclusive_open(struct inode *inode, struct file *file);
116 extern int video_exclusive_release(struct inode *inode, struct file *file);
117 #endif
118
119 #endif /* _V4L2_DEV_H */