Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
| 31 | #define DVB_MAJOR 212 |
| 32 | |
Janne Grunau | 78e9200 | 2008-04-09 19:13:13 -0300 | [diff] [blame] | 33 | #define DVB_MAX_ADAPTERS 8 |
| 34 | |
| 35 | #define DVB_UNSET (-1) |
| 36 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | #define DVB_DEVICE_VIDEO 0 |
| 38 | #define DVB_DEVICE_AUDIO 1 |
| 39 | #define DVB_DEVICE_SEC 2 |
| 40 | #define DVB_DEVICE_FRONTEND 3 |
| 41 | #define DVB_DEVICE_DEMUX 4 |
| 42 | #define DVB_DEVICE_DVR 5 |
| 43 | #define DVB_DEVICE_CA 6 |
| 44 | #define DVB_DEVICE_NET 7 |
| 45 | #define DVB_DEVICE_OSD 8 |
| 46 | |
Janne Grunau | 78e9200 | 2008-04-09 19:13:13 -0300 | [diff] [blame] | 47 | #define DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr) \ |
| 48 | static short adapter_nr[] = \ |
| 49 | {[0 ... (DVB_MAX_ADAPTERS - 1)] = DVB_UNSET }; \ |
| 50 | module_param_array(adapter_nr, short, NULL, 0444); \ |
| 51 | MODULE_PARM_DESC(adapter_nr, "DVB adapter numbers") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | |
| 53 | struct dvb_adapter { |
| 54 | int num; |
| 55 | struct list_head list_head; |
| 56 | struct list_head device_list; |
| 57 | const char *name; |
| 58 | u8 proposed_mac [6]; |
| 59 | void* priv; |
| 60 | |
Andrew de Quincey | d09dbf9 | 2006-04-10 09:27:37 -0300 | [diff] [blame] | 61 | struct device *device; |
| 62 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | struct module *module; |
Darron Broad | 59b1842 | 2008-10-11 11:44:05 -0300 | [diff] [blame] | 64 | |
| 65 | int mfe_shared; /* indicates mutually exclusive frontends */ |
| 66 | struct dvb_device *mfe_dvbdev; /* frontend device in use */ |
| 67 | struct mutex mfe_lock; /* access lock for thread creation */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | |
| 71 | struct dvb_device { |
| 72 | struct list_head list_head; |
Jan Engelhardt | 784e29d | 2009-01-11 06:12:43 -0300 | [diff] [blame] | 73 | const struct file_operations *fops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | struct dvb_adapter *adapter; |
| 75 | int type; |
Andreas Oberritter | 5dd3f30 | 2008-10-23 12:11:19 -0300 | [diff] [blame] | 76 | int minor; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | u32 id; |
| 78 | |
| 79 | /* in theory, 'users' can vanish now, |
| 80 | but I don't want to change too much now... */ |
| 81 | int readers; |
| 82 | int writers; |
| 83 | int users; |
| 84 | |
Markus Rechberger | ca5be9c | 2007-04-14 10:18:58 -0300 | [diff] [blame] | 85 | wait_queue_head_t wait_queue; |
Mauro Carvalho Chehab | afd1a0c | 2005-12-12 00:37:27 -0800 | [diff] [blame] | 86 | /* don't really need those !? -- FIXME: use video_usercopy */ |
| 87 | int (*kernel_ioctl)(struct inode *inode, struct file *file, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | unsigned int cmd, void *arg); |
| 89 | |
| 90 | void *priv; |
| 91 | }; |
| 92 | |
| 93 | |
Janne Grunau | 78e9200 | 2008-04-09 19:13:13 -0300 | [diff] [blame] | 94 | extern int dvb_register_adapter(struct dvb_adapter *adap, const char *name, |
| 95 | struct module *module, struct device *device, |
| 96 | short *adapter_nums); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | extern int dvb_unregister_adapter (struct dvb_adapter *adap); |
| 98 | |
| 99 | extern int dvb_register_device (struct dvb_adapter *adap, |
| 100 | struct dvb_device **pdvbdev, |
| 101 | const struct dvb_device *template, |
| 102 | void *priv, |
| 103 | int type); |
| 104 | |
| 105 | extern void dvb_unregister_device (struct dvb_device *dvbdev); |
| 106 | |
| 107 | extern int dvb_generic_open (struct inode *inode, struct file *file); |
| 108 | extern int dvb_generic_release (struct inode *inode, struct file *file); |
| 109 | extern int dvb_generic_ioctl (struct inode *inode, struct file *file, |
| 110 | unsigned int cmd, unsigned long arg); |
| 111 | |
| 112 | /* we don't mess with video_usercopy() any more, |
| 113 | we simply define out own dvb_usercopy(), which will hopefully become |
| 114 | generic_usercopy() someday... */ |
| 115 | |
| 116 | extern int dvb_usercopy(struct inode *inode, struct file *file, |
Michael Krufky | 50c25ff | 2006-01-09 15:25:34 -0200 | [diff] [blame] | 117 | unsigned int cmd, unsigned long arg, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | int (*func)(struct inode *inode, struct file *file, |
| 119 | unsigned int cmd, void *arg)); |
| 120 | |
Andrew de Quincey | d995506 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 121 | /** generic DVB attach function. */ |
Mauro Carvalho Chehab | 149ef72 | 2008-04-29 21:38:46 -0300 | [diff] [blame] | 122 | #ifdef CONFIG_MEDIA_ATTACH |
Andrew de Quincey | d995506 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 123 | #define dvb_attach(FUNCTION, ARGS...) ({ \ |
| 124 | void *__r = NULL; \ |
| 125 | typeof(&FUNCTION) __a = symbol_request(FUNCTION); \ |
| 126 | if (__a) { \ |
| 127 | __r = (void *) __a(ARGS); \ |
| 128 | if (__r == NULL) \ |
| 129 | symbol_put(FUNCTION); \ |
| 130 | } else { \ |
| 131 | printk(KERN_ERR "DVB: Unable to find symbol "#FUNCTION"()\n"); \ |
| 132 | } \ |
| 133 | __r; \ |
| 134 | }) |
| 135 | |
Andrew de Quincey | d995506 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 136 | #else |
| 137 | #define dvb_attach(FUNCTION, ARGS...) ({ \ |
| 138 | FUNCTION(ARGS); \ |
| 139 | }) |
| 140 | |
Andrew de Quincey | d995506 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 141 | #endif |
| 142 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | #endif /* #ifndef _DVBDEV_H_ */ |