Merge branch 'master' of ssh://master.kernel.org/pub/scm/linux/kernel/git/mchehab...
[linux-2.6] / drivers / media / dvb / dvb-core / dvbdev.h
1 /*
2  * dvbdev.h
3  *
4  * Copyright (C) 2000 Ralph Metzler & Marcus Metzler
5  *                    for convergence integrated media GmbH
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Lesser Public License
9  * as published by the Free Software Foundation; either version 2.1
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20  *
21  */
22
23 #ifndef _DVBDEV_H_
24 #define _DVBDEV_H_
25
26 #include <linux/types.h>
27 #include <linux/poll.h>
28 #include <linux/fs.h>
29 #include <linux/list.h>
30 #include <linux/smp_lock.h>
31
32 #define DVB_MAJOR 212
33
34 #define DVB_DEVICE_VIDEO      0
35 #define DVB_DEVICE_AUDIO      1
36 #define DVB_DEVICE_SEC        2
37 #define DVB_DEVICE_FRONTEND   3
38 #define DVB_DEVICE_DEMUX      4
39 #define DVB_DEVICE_DVR        5
40 #define DVB_DEVICE_CA         6
41 #define DVB_DEVICE_NET        7
42 #define DVB_DEVICE_OSD        8
43
44
45 struct dvb_adapter {
46         int num;
47         struct list_head list_head;
48         struct list_head device_list;
49         const char *name;
50         u8 proposed_mac [6];
51         void* priv;
52
53         struct device *device;
54
55         struct module *module;
56 };
57
58
59 struct dvb_device {
60         struct list_head list_head;
61         struct file_operations *fops;
62         struct dvb_adapter *adapter;
63         int type;
64         u32 id;
65
66         /* in theory, 'users' can vanish now,
67            but I don't want to change too much now... */
68         int readers;
69         int writers;
70         int users;
71
72         wait_queue_head_t         wait_queue;
73         /* don't really need those !? -- FIXME: use video_usercopy  */
74         int (*kernel_ioctl)(struct inode *inode, struct file *file,
75                             unsigned int cmd, void *arg);
76
77         void *priv;
78 };
79
80
81 extern int dvb_register_adapter (struct dvb_adapter *adap, const char *name, struct module *module, struct device *device);
82 extern int dvb_unregister_adapter (struct dvb_adapter *adap);
83
84 extern int dvb_register_device (struct dvb_adapter *adap,
85                                 struct dvb_device **pdvbdev,
86                                 const struct dvb_device *template,
87                                 void *priv,
88                                 int type);
89
90 extern void dvb_unregister_device (struct dvb_device *dvbdev);
91
92 extern int dvb_generic_open (struct inode *inode, struct file *file);
93 extern int dvb_generic_release (struct inode *inode, struct file *file);
94 extern int dvb_generic_ioctl (struct inode *inode, struct file *file,
95                               unsigned int cmd, unsigned long arg);
96
97 /* we don't mess with video_usercopy() any more,
98 we simply define out own dvb_usercopy(), which will hopefully become
99 generic_usercopy()  someday... */
100
101 extern int dvb_usercopy(struct inode *inode, struct file *file,
102                             unsigned int cmd, unsigned long arg,
103                             int (*func)(struct inode *inode, struct file *file,
104                             unsigned int cmd, void *arg));
105
106 /** generic DVB attach function. */
107 #ifdef CONFIG_DVB_CORE_ATTACH
108 #define dvb_attach(FUNCTION, ARGS...) ({ \
109         void *__r = NULL; \
110         typeof(&FUNCTION) __a = symbol_request(FUNCTION); \
111         if (__a) { \
112                 __r = (void *) __a(ARGS); \
113                 if (__r == NULL) \
114                         symbol_put(FUNCTION); \
115         } else { \
116                 printk(KERN_ERR "DVB: Unable to find symbol "#FUNCTION"()\n"); \
117         } \
118         __r; \
119 })
120
121 #else
122 #define dvb_attach(FUNCTION, ARGS...) ({ \
123         FUNCTION(ARGS); \
124 })
125
126 #endif
127
128 #endif /* #ifndef _DVBDEV_H_ */