Commit | Line | Data |
---|---|---|
1da177e4 LT |
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> | |
a0246e02 | 30 | #include <media/media-device.h> |
1da177e4 LT |
31 | |
32 | #define DVB_MAJOR 212 | |
33 | ||
4457ef1d | 34 | #if defined(CONFIG_DVB_MAX_ADAPTERS) && CONFIG_DVB_MAX_ADAPTERS > 0 |
d4c02ef9 | 35 | #define DVB_MAX_ADAPTERS CONFIG_DVB_MAX_ADAPTERS |
4457ef1d | 36 | #else |
d4c02ef9 | 37 | #define DVB_MAX_ADAPTERS 8 |
4457ef1d | 38 | #endif |
78e92006 JG |
39 | |
40 | #define DVB_UNSET (-1) | |
41 | ||
1da177e4 LT |
42 | #define DVB_DEVICE_VIDEO 0 |
43 | #define DVB_DEVICE_AUDIO 1 | |
44 | #define DVB_DEVICE_SEC 2 | |
45 | #define DVB_DEVICE_FRONTEND 3 | |
46 | #define DVB_DEVICE_DEMUX 4 | |
47 | #define DVB_DEVICE_DVR 5 | |
48 | #define DVB_DEVICE_CA 6 | |
49 | #define DVB_DEVICE_NET 7 | |
50 | #define DVB_DEVICE_OSD 8 | |
51 | ||
78e92006 JG |
52 | #define DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr) \ |
53 | static short adapter_nr[] = \ | |
54 | {[0 ... (DVB_MAX_ADAPTERS - 1)] = DVB_UNSET }; \ | |
55 | module_param_array(adapter_nr, short, NULL, 0444); \ | |
56 | MODULE_PARM_DESC(adapter_nr, "DVB adapter numbers") | |
1da177e4 | 57 | |
9133aee0 MK |
58 | struct dvb_frontend; |
59 | ||
d071c833 MCC |
60 | /** |
61 | * struct dvb_adapter - represents a Digital TV adapter using Linux DVB API | |
62 | * | |
63 | * @num: Number of the adapter | |
64 | * @list_head: List with the DVB adapters | |
65 | * @device_list: List with the DVB devices | |
66 | * @name: Name of the adapter | |
67 | * @proposed_mac: proposed MAC address for the adapter | |
68 | * @priv: private data | |
69 | * @device: pointer to struct device | |
70 | * @module: pointer to struct module | |
71 | * @mfe_shared: mfe shared: indicates mutually exclusive frontends | |
72 | * Thie usage of this flag is currently deprecated | |
73 | * @mfe_dvbdev: Frontend device in use, in the case of MFE | |
74 | * @mfe_lock: Lock to prevent using the other frontends when MFE is | |
75 | * used. | |
76 | * @mdev: pointer to struct media_device, used when the media | |
77 | * controller is used. | |
78 | */ | |
1da177e4 LT |
79 | struct dvb_adapter { |
80 | int num; | |
81 | struct list_head list_head; | |
82 | struct list_head device_list; | |
83 | const char *name; | |
84 | u8 proposed_mac [6]; | |
85 | void* priv; | |
86 | ||
d09dbf92 AQ |
87 | struct device *device; |
88 | ||
1da177e4 | 89 | struct module *module; |
59b1842d DB |
90 | |
91 | int mfe_shared; /* indicates mutually exclusive frontends */ | |
92 | struct dvb_device *mfe_dvbdev; /* frontend device in use */ | |
93 | struct mutex mfe_lock; /* access lock for thread creation */ | |
a0246e02 MCC |
94 | |
95 | #if defined(CONFIG_MEDIA_CONTROLLER_DVB) | |
96 | struct media_device *mdev; | |
97 | #endif | |
1da177e4 LT |
98 | }; |
99 | ||
d071c833 MCC |
100 | /** |
101 | * struct dvb_device - represents a DVB device node | |
102 | * | |
103 | * @list_head: List head with all DVB devices | |
104 | * @fops: pointer to struct file_operations | |
105 | * @adapter: pointer to the adapter that holds this device node | |
106 | * @type: type of the device: DVB_DEVICE_SEC, DVB_DEVICE_FRONTEND, | |
107 | * DVB_DEVICE_DEMUX, DVB_DEVICE_DVR, DVB_DEVICE_CA, DVB_DEVICE_NET | |
108 | * @minor: devnode minor number. Major number is always DVB_MAJOR. | |
109 | * @id: device ID number, inside the adapter | |
110 | * @readers: Initialized by the caller. Each call to open() in Read Only mode | |
111 | * decreases this counter by one. | |
112 | * @writers: Initialized by the caller. Each call to open() in Read/Write | |
113 | * mode decreases this counter by one. | |
114 | * @users: Initialized by the caller. Each call to open() in any mode | |
115 | * decreases this counter by one. | |
116 | * @wait_queue: wait queue, used to wait for certain events inside one of | |
117 | * the DVB API callers | |
118 | * @kernel_ioctl: callback function used to handle ioctl calls from userspace. | |
119 | * @name: Name to be used for the device at the Media Controller | |
120 | * @entity: pointer to struct media_entity associated with the device node | |
121 | * @pads: pointer to struct media_pad associated with @entity; | |
122 | * @priv: private data | |
123 | * | |
124 | * This structure is used by the DVB core (frontend, CA, net, demux) in | |
125 | * order to create the device nodes. Usually, driver should not initialize | |
126 | * this struct diretly. | |
127 | */ | |
1da177e4 LT |
128 | struct dvb_device { |
129 | struct list_head list_head; | |
784e29d2 | 130 | const struct file_operations *fops; |
1da177e4 LT |
131 | struct dvb_adapter *adapter; |
132 | int type; | |
5dd3f307 | 133 | int minor; |
1da177e4 LT |
134 | u32 id; |
135 | ||
136 | /* in theory, 'users' can vanish now, | |
137 | but I don't want to change too much now... */ | |
138 | int readers; | |
139 | int writers; | |
140 | int users; | |
141 | ||
ca5be9cd | 142 | wait_queue_head_t wait_queue; |
afd1a0c9 | 143 | /* don't really need those !? -- FIXME: use video_usercopy */ |
16ef8def | 144 | int (*kernel_ioctl)(struct file *file, unsigned int cmd, void *arg); |
1da177e4 | 145 | |
a0246e02 MCC |
146 | /* Needed for media controller register/unregister */ |
147 | #if defined(CONFIG_MEDIA_CONTROLLER_DVB) | |
148 | const char *name; | |
149 | ||
172e9d3c | 150 | /* Allocated and filled inside dvbdev.c */ |
a0246e02 | 151 | struct media_entity *entity; |
8211b187 | 152 | struct media_intf_devnode *intf_devnode; |
172e9d3c | 153 | struct media_pad *pads; |
a0246e02 MCC |
154 | #endif |
155 | ||
1da177e4 LT |
156 | void *priv; |
157 | }; | |
158 | ||
d071c833 MCC |
159 | /** |
160 | * dvb_register_adapter - Registers a new DVB adapter | |
161 | * | |
162 | * @adap: pointer to struct dvb_adapter | |
163 | * @name: Adapter's name | |
164 | * @module: initialized with THIS_MODULE at the caller | |
165 | * @device: pointer to struct device that corresponds to the device driver | |
166 | * @adapter_nums: Array with a list of the numbers for @dvb_register_adapter; | |
167 | * to select among them. Typically, initialized with: | |
168 | * DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nums) | |
169 | */ | |
170 | int dvb_register_adapter(struct dvb_adapter *adap, const char *name, | |
171 | struct module *module, struct device *device, | |
172 | short *adapter_nums); | |
1da177e4 | 173 | |
d071c833 MCC |
174 | /** |
175 | * dvb_unregister_adapter - Unregisters a DVB adapter | |
176 | * | |
177 | * @adap: pointer to struct dvb_adapter | |
178 | */ | |
179 | int dvb_unregister_adapter(struct dvb_adapter *adap); | |
1da177e4 | 180 | |
d071c833 MCC |
181 | /** |
182 | * dvb_register_device - Registers a new DVB device | |
183 | * | |
184 | * @adap: pointer to struct dvb_adapter | |
185 | * @pdvbdev: pointer to the place where the new struct dvb_device will be | |
186 | * stored | |
187 | * @template: Template used to create &pdvbdev; | |
d071c833 MCC |
188 | * @priv: private data |
189 | * @type: type of the device: DVB_DEVICE_SEC, DVB_DEVICE_FRONTEND, | |
190 | * DVB_DEVICE_DEMUX, DVB_DEVICE_DVR, DVB_DEVICE_CA, DVB_DEVICE_NET | |
191 | */ | |
192 | int dvb_register_device(struct dvb_adapter *adap, | |
193 | struct dvb_device **pdvbdev, | |
194 | const struct dvb_device *template, | |
195 | void *priv, | |
196 | int type); | |
197 | ||
198 | /** | |
199 | * dvb_unregister_device - Unregisters a DVB device | |
200 | * | |
201 | * @dvbdev: pointer to struct dvb_device | |
202 | */ | |
203 | void dvb_unregister_device(struct dvb_device *dvbdev); | |
480884b6 MCC |
204 | |
205 | #ifdef CONFIG_MEDIA_CONTROLLER_DVB | |
206 | void dvb_create_media_graph(struct dvb_adapter *adap); | |
89a2c1d6 MCC |
207 | static inline void dvb_register_media_controller(struct dvb_adapter *adap, |
208 | struct media_device *mdev) | |
209 | { | |
210 | adap->mdev = mdev; | |
211 | } | |
212 | ||
480884b6 MCC |
213 | #else |
214 | static inline void dvb_create_media_graph(struct dvb_adapter *adap) {} | |
89a2c1d6 | 215 | #define dvb_register_media_controller(a, b) {} |
480884b6 | 216 | #endif |
1da177e4 | 217 | |
d071c833 MCC |
218 | int dvb_generic_open (struct inode *inode, struct file *file); |
219 | int dvb_generic_release (struct inode *inode, struct file *file); | |
220 | long dvb_generic_ioctl (struct file *file, | |
1da177e4 LT |
221 | unsigned int cmd, unsigned long arg); |
222 | ||
223 | /* we don't mess with video_usercopy() any more, | |
224 | we simply define out own dvb_usercopy(), which will hopefully become | |
225 | generic_usercopy() someday... */ | |
226 | ||
d071c833 MCC |
227 | int dvb_usercopy(struct file *file, unsigned int cmd, unsigned long arg, |
228 | int (*func)(struct file *file, unsigned int cmd, void *arg)); | |
1da177e4 | 229 | |
d9955060 | 230 | /** generic DVB attach function. */ |
149ef72d | 231 | #ifdef CONFIG_MEDIA_ATTACH |
d9955060 AQ |
232 | #define dvb_attach(FUNCTION, ARGS...) ({ \ |
233 | void *__r = NULL; \ | |
234 | typeof(&FUNCTION) __a = symbol_request(FUNCTION); \ | |
235 | if (__a) { \ | |
236 | __r = (void *) __a(ARGS); \ | |
237 | if (__r == NULL) \ | |
238 | symbol_put(FUNCTION); \ | |
239 | } else { \ | |
240 | printk(KERN_ERR "DVB: Unable to find symbol "#FUNCTION"()\n"); \ | |
241 | } \ | |
242 | __r; \ | |
243 | }) | |
244 | ||
4647f487 MCC |
245 | #define dvb_detach(FUNC) symbol_put_addr(FUNC) |
246 | ||
d9955060 AQ |
247 | #else |
248 | #define dvb_attach(FUNCTION, ARGS...) ({ \ | |
249 | FUNCTION(ARGS); \ | |
250 | }) | |
251 | ||
4647f487 MCC |
252 | #define dvb_detach(FUNC) {} |
253 | ||
d9955060 AQ |
254 | #endif |
255 | ||
1da177e4 | 256 | #endif /* #ifndef _DVBDEV_H_ */ |