Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
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 <media/media-device.h>
31
32#define DVB_MAJOR 212
33
34#if defined(CONFIG_DVB_MAX_ADAPTERS) && CONFIG_DVB_MAX_ADAPTERS > 0
35 #define DVB_MAX_ADAPTERS CONFIG_DVB_MAX_ADAPTERS
36#else
37 #define DVB_MAX_ADAPTERS 8
38#endif
39
40#define DVB_UNSET (-1)
41
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
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")
57
58struct dvb_frontend;
59
60struct dvb_adapter {
61 int num;
62 struct list_head list_head;
63 struct list_head device_list;
64 const char *name;
65 u8 proposed_mac [6];
66 void* priv;
67
68 struct device *device;
69
70 struct module *module;
71
72 int mfe_shared; /* indicates mutually exclusive frontends */
73 struct dvb_device *mfe_dvbdev; /* frontend device in use */
74 struct mutex mfe_lock; /* access lock for thread creation */
75
76#if defined(CONFIG_MEDIA_CONTROLLER_DVB)
77 struct media_device *mdev;
78#endif
79};
80
81
82struct dvb_device {
83 struct list_head list_head;
84 const struct file_operations *fops;
85 struct dvb_adapter *adapter;
86 int type;
87 int minor;
88 u32 id;
89
90 /* in theory, 'users' can vanish now,
91 but I don't want to change too much now... */
92 int readers;
93 int writers;
94 int users;
95
96 wait_queue_head_t wait_queue;
97 /* don't really need those !? -- FIXME: use video_usercopy */
98 int (*kernel_ioctl)(struct file *file, unsigned int cmd, void *arg);
99
100 /* Needed for media controller register/unregister */
101#if defined(CONFIG_MEDIA_CONTROLLER_DVB)
102 const char *name;
103
104 /* Allocated and filled inside dvbdev.c */
105 struct media_entity *entity;
106 struct media_pad *pads;
107#endif
108
109 void *priv;
110};
111
112
113extern int dvb_register_adapter(struct dvb_adapter *adap, const char *name,
114 struct module *module, struct device *device,
115 short *adapter_nums);
116extern int dvb_unregister_adapter (struct dvb_adapter *adap);
117
118extern int dvb_register_device (struct dvb_adapter *adap,
119 struct dvb_device **pdvbdev,
120 const struct dvb_device *template,
121 void *priv,
122 int type);
123
124extern void dvb_unregister_device (struct dvb_device *dvbdev);
125
126#ifdef CONFIG_MEDIA_CONTROLLER_DVB
127void dvb_create_media_graph(struct dvb_adapter *adap);
128static inline void dvb_register_media_controller(struct dvb_adapter *adap,
129 struct media_device *mdev)
130{
131 adap->mdev = mdev;
132}
133
134#else
135static inline void dvb_create_media_graph(struct dvb_adapter *adap) {}
136#define dvb_register_media_controller(a, b) {}
137#endif
138
139extern int dvb_generic_open (struct inode *inode, struct file *file);
140extern int dvb_generic_release (struct inode *inode, struct file *file);
141extern long dvb_generic_ioctl (struct file *file,
142 unsigned int cmd, unsigned long arg);
143
144/* we don't mess with video_usercopy() any more,
145we simply define out own dvb_usercopy(), which will hopefully become
146generic_usercopy() someday... */
147
148extern int dvb_usercopy(struct file *file, unsigned int cmd, unsigned long arg,
149 int (*func)(struct file *file, unsigned int cmd, void *arg));
150
151/** generic DVB attach function. */
152#ifdef CONFIG_MEDIA_ATTACH
153#define dvb_attach(FUNCTION, ARGS...) ({ \
154 void *__r = NULL; \
155 typeof(&FUNCTION) __a = symbol_request(FUNCTION); \
156 if (__a) { \
157 __r = (void *) __a(ARGS); \
158 if (__r == NULL) \
159 symbol_put(FUNCTION); \
160 } else { \
161 printk(KERN_ERR "DVB: Unable to find symbol "#FUNCTION"()\n"); \
162 } \
163 __r; \
164})
165
166#define dvb_detach(FUNC) symbol_put_addr(FUNC)
167
168#else
169#define dvb_attach(FUNCTION, ARGS...) ({ \
170 FUNCTION(ARGS); \
171})
172
173#define dvb_detach(FUNC) {}
174
175#endif
176
177#endif /* #ifndef _DVBDEV_H_ */