blob: 93a9470d3f0c7c19d3d9391bdc37a27ac66a7e6e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 Torvalds1da177e2005-04-16 15:20:36 -070030
31#define DVB_MAJOR 212
32
Janne Grunau4457ef12009-09-01 19:15:39 -030033#if defined(CONFIG_DVB_MAX_ADAPTERS) && CONFIG_DVB_MAX_ADAPTERS > 0
Mauro Carvalho Chehabd4c02ef2009-09-19 09:45:22 -030034 #define DVB_MAX_ADAPTERS CONFIG_DVB_MAX_ADAPTERS
Janne Grunau4457ef12009-09-01 19:15:39 -030035#else
Mauro Carvalho Chehabd4c02ef2009-09-19 09:45:22 -030036 #define DVB_MAX_ADAPTERS 8
Janne Grunau4457ef12009-09-01 19:15:39 -030037#endif
Janne Grunau78e92002008-04-09 19:13:13 -030038
39#define DVB_UNSET (-1)
40
Linus Torvalds1da177e2005-04-16 15:20:36 -070041#define DVB_DEVICE_VIDEO 0
42#define DVB_DEVICE_AUDIO 1
43#define DVB_DEVICE_SEC 2
44#define DVB_DEVICE_FRONTEND 3
45#define DVB_DEVICE_DEMUX 4
46#define DVB_DEVICE_DVR 5
47#define DVB_DEVICE_CA 6
48#define DVB_DEVICE_NET 7
49#define DVB_DEVICE_OSD 8
50
Janne Grunau78e92002008-04-09 19:13:13 -030051#define DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr) \
52 static short adapter_nr[] = \
53 {[0 ... (DVB_MAX_ADAPTERS - 1)] = DVB_UNSET }; \
54 module_param_array(adapter_nr, short, NULL, 0444); \
55 MODULE_PARM_DESC(adapter_nr, "DVB adapter numbers")
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
Michael Krufky9133aee2009-05-23 18:00:59 -030057struct dvb_frontend;
58
Linus Torvalds1da177e2005-04-16 15:20:36 -070059struct dvb_adapter {
60 int num;
61 struct list_head list_head;
62 struct list_head device_list;
63 const char *name;
64 u8 proposed_mac [6];
65 void* priv;
66
Andrew de Quinceyd09dbf92006-04-10 09:27:37 -030067 struct device *device;
68
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 struct module *module;
Darron Broad59b18422008-10-11 11:44:05 -030070
71 int mfe_shared; /* indicates mutually exclusive frontends */
72 struct dvb_device *mfe_dvbdev; /* frontend device in use */
73 struct mutex mfe_lock; /* access lock for thread creation */
Linus Torvalds1da177e2005-04-16 15:20:36 -070074};
75
76
77struct dvb_device {
78 struct list_head list_head;
Jan Engelhardt784e29d2009-01-11 06:12:43 -030079 const struct file_operations *fops;
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 struct dvb_adapter *adapter;
81 int type;
Andreas Oberritter5dd3f302008-10-23 12:11:19 -030082 int minor;
Linus Torvalds1da177e2005-04-16 15:20:36 -070083 u32 id;
84
85 /* in theory, 'users' can vanish now,
86 but I don't want to change too much now... */
87 int readers;
88 int writers;
89 int users;
90
Markus Rechbergerca5be9c2007-04-14 10:18:58 -030091 wait_queue_head_t wait_queue;
Mauro Carvalho Chehabafd1a0c2005-12-12 00:37:27 -080092 /* don't really need those !? -- FIXME: use video_usercopy */
Arnd Bergmann16ef8de2010-04-27 00:24:00 +020093 int (*kernel_ioctl)(struct file *file, unsigned int cmd, void *arg);
Linus Torvalds1da177e2005-04-16 15:20:36 -070094
95 void *priv;
96};
97
98
Janne Grunau78e92002008-04-09 19:13:13 -030099extern int dvb_register_adapter(struct dvb_adapter *adap, const char *name,
100 struct module *module, struct device *device,
101 short *adapter_nums);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102extern int dvb_unregister_adapter (struct dvb_adapter *adap);
103
104extern int dvb_register_device (struct dvb_adapter *adap,
105 struct dvb_device **pdvbdev,
106 const struct dvb_device *template,
107 void *priv,
108 int type);
109
110extern void dvb_unregister_device (struct dvb_device *dvbdev);
111
112extern int dvb_generic_open (struct inode *inode, struct file *file);
113extern int dvb_generic_release (struct inode *inode, struct file *file);
Arnd Bergmann16ef8de2010-04-27 00:24:00 +0200114extern long dvb_generic_ioctl (struct file *file,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 unsigned int cmd, unsigned long arg);
116
117/* we don't mess with video_usercopy() any more,
118we simply define out own dvb_usercopy(), which will hopefully become
119generic_usercopy() someday... */
120
Arnd Bergmann16ef8de2010-04-27 00:24:00 +0200121extern int dvb_usercopy(struct file *file, unsigned int cmd, unsigned long arg,
122 int (*func)(struct file *file, unsigned int cmd, void *arg));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123
Andrew de Quinceyd9955062006-08-08 09:10:08 -0300124/** generic DVB attach function. */
Mauro Carvalho Chehab149ef722008-04-29 21:38:46 -0300125#ifdef CONFIG_MEDIA_ATTACH
Andrew de Quinceyd9955062006-08-08 09:10:08 -0300126#define dvb_attach(FUNCTION, ARGS...) ({ \
127 void *__r = NULL; \
128 typeof(&FUNCTION) __a = symbol_request(FUNCTION); \
129 if (__a) { \
130 __r = (void *) __a(ARGS); \
131 if (__r == NULL) \
132 symbol_put(FUNCTION); \
133 } else { \
134 printk(KERN_ERR "DVB: Unable to find symbol "#FUNCTION"()\n"); \
135 } \
136 __r; \
137})
138
Andrew de Quinceyd9955062006-08-08 09:10:08 -0300139#else
140#define dvb_attach(FUNCTION, ARGS...) ({ \
141 FUNCTION(ARGS); \
142})
143
Andrew de Quinceyd9955062006-08-08 09:10:08 -0300144#endif
145
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146#endif /* #ifndef _DVBDEV_H_ */