x86/mm/pat: Don't report PAT on CPUs that don't support it
[linux/fpc-iii.git] / drivers / media / dvb-core / dvbdev.h
blob49189392cf3b9c22907ff9ff17c610a4b86a4ff3
1 /*
2 * dvbdev.h
4 * Copyright (C) 2000 Ralph Metzler & Marcus Metzler
5 * for convergence integrated media GmbH
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.
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.
19 #ifndef _DVBDEV_H_
20 #define _DVBDEV_H_
22 #include <linux/types.h>
23 #include <linux/poll.h>
24 #include <linux/fs.h>
25 #include <linux/list.h>
26 #include <media/media-device.h>
28 #define DVB_MAJOR 212
30 #if defined(CONFIG_DVB_MAX_ADAPTERS) && CONFIG_DVB_MAX_ADAPTERS > 0
31 #define DVB_MAX_ADAPTERS CONFIG_DVB_MAX_ADAPTERS
32 #else
33 #define DVB_MAX_ADAPTERS 16
34 #endif
36 #define DVB_UNSET (-1)
38 #define DVB_DEVICE_VIDEO 0
39 #define DVB_DEVICE_AUDIO 1
40 #define DVB_DEVICE_SEC 2
41 #define DVB_DEVICE_FRONTEND 3
42 #define DVB_DEVICE_DEMUX 4
43 #define DVB_DEVICE_DVR 5
44 #define DVB_DEVICE_CA 6
45 #define DVB_DEVICE_NET 7
46 #define DVB_DEVICE_OSD 8
48 #define DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr) \
49 static short adapter_nr[] = \
50 {[0 ... (DVB_MAX_ADAPTERS - 1)] = DVB_UNSET }; \
51 module_param_array(adapter_nr, short, NULL, 0444); \
52 MODULE_PARM_DESC(adapter_nr, "DVB adapter numbers")
54 struct dvb_frontend;
56 /**
57 * struct dvb_adapter - represents a Digital TV adapter using Linux DVB API
59 * @num: Number of the adapter
60 * @list_head: List with the DVB adapters
61 * @device_list: List with the DVB devices
62 * @name: Name of the adapter
63 * @proposed_mac: proposed MAC address for the adapter
64 * @priv: private data
65 * @device: pointer to struct device
66 * @module: pointer to struct module
67 * @mfe_shared: mfe shared: indicates mutually exclusive frontends
68 * Thie usage of this flag is currently deprecated
69 * @mfe_dvbdev: Frontend device in use, in the case of MFE
70 * @mfe_lock: Lock to prevent using the other frontends when MFE is
71 * used.
72 * @mdev: pointer to struct media_device, used when the media
73 * controller is used.
74 * @conn: RF connector. Used only if the device has no separate
75 * tuner.
76 * @conn_pads: pointer to struct media_pad associated with @conn;
78 struct dvb_adapter {
79 int num;
80 struct list_head list_head;
81 struct list_head device_list;
82 const char *name;
83 u8 proposed_mac [6];
84 void* priv;
86 struct device *device;
88 struct module *module;
90 int mfe_shared; /* indicates mutually exclusive frontends */
91 struct dvb_device *mfe_dvbdev; /* frontend device in use */
92 struct mutex mfe_lock; /* access lock for thread creation */
94 #if defined(CONFIG_MEDIA_CONTROLLER_DVB)
95 struct media_device *mdev;
96 struct media_entity *conn;
97 struct media_pad *conn_pads;
98 #endif
102 * struct dvb_device - represents a DVB device node
104 * @list_head: List head with all DVB devices
105 * @fops: pointer to struct file_operations
106 * @adapter: pointer to the adapter that holds this device node
107 * @type: type of the device: DVB_DEVICE_SEC, DVB_DEVICE_FRONTEND,
108 * DVB_DEVICE_DEMUX, DVB_DEVICE_DVR, DVB_DEVICE_CA, DVB_DEVICE_NET
109 * @minor: devnode minor number. Major number is always DVB_MAJOR.
110 * @id: device ID number, inside the adapter
111 * @readers: Initialized by the caller. Each call to open() in Read Only mode
112 * decreases this counter by one.
113 * @writers: Initialized by the caller. Each call to open() in Read/Write
114 * mode decreases this counter by one.
115 * @users: Initialized by the caller. Each call to open() in any mode
116 * decreases this counter by one.
117 * @wait_queue: wait queue, used to wait for certain events inside one of
118 * the DVB API callers
119 * @kernel_ioctl: callback function used to handle ioctl calls from userspace.
120 * @name: Name to be used for the device at the Media Controller
121 * @entity: pointer to struct media_entity associated with the device node
122 * @pads: pointer to struct media_pad associated with @entity;
123 * @priv: private data
124 * @intf_devnode: Pointer to media_intf_devnode. Used by the dvbdev core to
125 * store the MC device node interface
126 * @tsout_num_entities: Number of Transport Stream output entities
127 * @tsout_entity: array with MC entities associated to each TS output node
128 * @tsout_pads: array with the source pads for each @tsout_entity
130 * This structure is used by the DVB core (frontend, CA, net, demux) in
131 * order to create the device nodes. Usually, driver should not initialize
132 * this struct diretly.
134 struct dvb_device {
135 struct list_head list_head;
136 const struct file_operations *fops;
137 struct dvb_adapter *adapter;
138 int type;
139 int minor;
140 u32 id;
142 /* in theory, 'users' can vanish now,
143 but I don't want to change too much now... */
144 int readers;
145 int writers;
146 int users;
148 wait_queue_head_t wait_queue;
149 /* don't really need those !? -- FIXME: use video_usercopy */
150 int (*kernel_ioctl)(struct file *file, unsigned int cmd, void *arg);
152 /* Needed for media controller register/unregister */
153 #if defined(CONFIG_MEDIA_CONTROLLER_DVB)
154 const char *name;
156 /* Allocated and filled inside dvbdev.c */
157 struct media_intf_devnode *intf_devnode;
159 unsigned tsout_num_entities;
160 struct media_entity *entity, *tsout_entity;
161 struct media_pad *pads, *tsout_pads;
162 #endif
164 void *priv;
168 * dvb_register_adapter - Registers a new DVB adapter
170 * @adap: pointer to struct dvb_adapter
171 * @name: Adapter's name
172 * @module: initialized with THIS_MODULE at the caller
173 * @device: pointer to struct device that corresponds to the device driver
174 * @adapter_nums: Array with a list of the numbers for @dvb_register_adapter;
175 * to select among them. Typically, initialized with:
176 * DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nums)
178 int dvb_register_adapter(struct dvb_adapter *adap, const char *name,
179 struct module *module, struct device *device,
180 short *adapter_nums);
183 * dvb_unregister_adapter - Unregisters a DVB adapter
185 * @adap: pointer to struct dvb_adapter
187 int dvb_unregister_adapter(struct dvb_adapter *adap);
190 * dvb_register_device - Registers a new DVB device
192 * @adap: pointer to struct dvb_adapter
193 * @pdvbdev: pointer to the place where the new struct dvb_device will be
194 * stored
195 * @template: Template used to create &pdvbdev;
196 * @priv: private data
197 * @type: type of the device: %DVB_DEVICE_SEC, %DVB_DEVICE_FRONTEND,
198 * %DVB_DEVICE_DEMUX, %DVB_DEVICE_DVR, %DVB_DEVICE_CA,
199 * %DVB_DEVICE_NET
200 * @demux_sink_pads: Number of demux outputs, to be used to create the TS
201 * outputs via the Media Controller.
203 int dvb_register_device(struct dvb_adapter *adap,
204 struct dvb_device **pdvbdev,
205 const struct dvb_device *template,
206 void *priv,
207 int type,
208 int demux_sink_pads);
211 * dvb_remove_device - Remove a registered DVB device
213 * This does not free memory. To do that, call dvb_free_device().
215 * @dvbdev: pointer to struct dvb_device
217 void dvb_remove_device(struct dvb_device *dvbdev);
220 * dvb_free_device - Free memory occupied by a DVB device.
222 * Call dvb_unregister_device() before calling this function.
224 * @dvbdev: pointer to struct dvb_device
226 void dvb_free_device(struct dvb_device *dvbdev);
229 * dvb_unregister_device - Unregisters a DVB device
231 * This is a combination of dvb_remove_device() and dvb_free_device().
232 * Using this function is usually a mistake, and is often an indicator
233 * for a use-after-free bug (when a userspace process keeps a file
234 * handle to a detached device).
236 * @dvbdev: pointer to struct dvb_device
238 void dvb_unregister_device(struct dvb_device *dvbdev);
240 #ifdef CONFIG_MEDIA_CONTROLLER_DVB
242 * dvb_create_media_graph - Creates media graph for the Digital TV part of the
243 * device.
245 * @adap: pointer to struct dvb_adapter
246 * @create_rf_connector: if true, it creates the RF connector too
248 * This function checks all DVB-related functions at the media controller
249 * entities and creates the needed links for the media graph. It is
250 * capable of working with multiple tuners or multiple frontends, but it
251 * won't create links if the device has multiple tuners and multiple frontends
252 * or if the device has multiple muxes. In such case, the caller driver should
253 * manually create the remaining links.
255 __must_check int dvb_create_media_graph(struct dvb_adapter *adap,
256 bool create_rf_connector);
258 static inline void dvb_register_media_controller(struct dvb_adapter *adap,
259 struct media_device *mdev)
261 adap->mdev = mdev;
264 static inline struct media_device
265 *dvb_get_media_controller(struct dvb_adapter *adap)
267 return adap->mdev;
269 #else
270 static inline
271 int dvb_create_media_graph(struct dvb_adapter *adap,
272 bool create_rf_connector)
274 return 0;
276 #define dvb_register_media_controller(a, b) {}
277 #define dvb_get_media_controller(a) NULL
278 #endif
280 int dvb_generic_open (struct inode *inode, struct file *file);
281 int dvb_generic_release (struct inode *inode, struct file *file);
282 long dvb_generic_ioctl (struct file *file,
283 unsigned int cmd, unsigned long arg);
285 /* we don't mess with video_usercopy() any more,
286 we simply define out own dvb_usercopy(), which will hopefully become
287 generic_usercopy() someday... */
289 int dvb_usercopy(struct file *file, unsigned int cmd, unsigned long arg,
290 int (*func)(struct file *file, unsigned int cmd, void *arg));
292 /** generic DVB attach function. */
293 #ifdef CONFIG_MEDIA_ATTACH
294 #define dvb_attach(FUNCTION, ARGS...) ({ \
295 void *__r = NULL; \
296 typeof(&FUNCTION) __a = symbol_request(FUNCTION); \
297 if (__a) { \
298 __r = (void *) __a(ARGS); \
299 if (__r == NULL) \
300 symbol_put(FUNCTION); \
301 } else { \
302 printk(KERN_ERR "DVB: Unable to find symbol "#FUNCTION"()\n"); \
304 __r; \
307 #define dvb_detach(FUNC) symbol_put_addr(FUNC)
309 #else
310 #define dvb_attach(FUNCTION, ARGS...) ({ \
311 FUNCTION(ARGS); \
314 #define dvb_detach(FUNC) {}
316 #endif
318 #endif /* #ifndef _DVBDEV_H_ */