aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/char/.gitignore1
-rw-r--r--drivers/char/Kconfig30
-rw-r--r--drivers/char/Makefile6
-rw-r--r--drivers/char/ite_gpio.c419
-rw-r--r--drivers/char/qtronixmap.c_shipped265
-rw-r--r--drivers/char/qtronixmap.map287
-rw-r--r--drivers/char/watchdog/Kconfig21
-rw-r--r--drivers/char/watchdog/Makefile1
-rw-r--r--drivers/char/watchdog/iTCO_wdt.c735
-rw-r--r--drivers/char/watchdog/pnx4008_wdt.c2
-rw-r--r--drivers/ide/Kconfig9
-rw-r--r--drivers/ide/pci/Makefile1
-rw-r--r--drivers/ide/pci/it8172.c307
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.c10
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.h1
-rw-r--r--drivers/media/dvb/dvb-usb/Kconfig41
-rw-r--r--drivers/media/dvb/dvb-usb/Makefile5
-rw-r--r--drivers/media/dvb/dvb-usb/a800.c48
-rw-r--r--drivers/media/dvb/dvb-usb/cxusb.c257
-rw-r--r--drivers/media/dvb/dvb-usb/dib0700.h49
-rw-r--r--drivers/media/dvb/dvb-usb/dib0700_core.c279
-rw-r--r--drivers/media/dvb/dvb-usb/dib0700_devices.c212
-rw-r--r--drivers/media/dvb/dvb-usb/dib07x0.h21
-rw-r--r--drivers/media/dvb/dvb-usb/dibusb-common.c71
-rw-r--r--drivers/media/dvb/dvb-usb/dibusb-mb.c198
-rw-r--r--drivers/media/dvb/dvb-usb/dibusb-mc.c40
-rw-r--r--drivers/media/dvb/dvb-usb/dibusb.h13
-rw-r--r--drivers/media/dvb/dvb-usb/digitv.c57
-rw-r--r--drivers/media/dvb/dvb-usb/dtt200u.c160
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-common.h41
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-dvb.c170
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-firmware.c10
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-i2c.c49
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-ids.h17
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-init.c165
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-remote.c2
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-urb.c268
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb.h280
-rw-r--r--drivers/media/dvb/dvb-usb/gp8psk.c32
-rw-r--r--drivers/media/dvb/dvb-usb/nova-t-usb2.c43
-rw-r--r--drivers/media/dvb/dvb-usb/umt-010.c38
-rw-r--r--drivers/media/dvb/dvb-usb/usb-urb.c242
-rw-r--r--drivers/media/dvb/dvb-usb/vp702x-fe.c39
-rw-r--r--drivers/media/dvb/dvb-usb/vp702x.c204
-rw-r--r--drivers/media/dvb/dvb-usb/vp702x.h2
-rw-r--r--drivers/media/dvb/dvb-usb/vp7045.c40
-rw-r--r--drivers/media/dvb/frontends/cx24123.c4
-rw-r--r--drivers/media/dvb/frontends/dib3000mc.c238
-rw-r--r--drivers/media/dvb/frontends/dib3000mc.h8
-rw-r--r--drivers/media/dvb/frontends/mt2060.c17
-rw-r--r--drivers/media/dvb/frontends/mt2060.h4
-rw-r--r--drivers/media/video/Kconfig130
-rw-r--r--drivers/media/video/bt8xx/bttv-cards.c2
-rw-r--r--drivers/media/video/cx88/cx88-blackbird.c4
-rw-r--r--drivers/media/video/cx88/cx88-cards.c81
-rw-r--r--drivers/media/video/cx88/cx88-core.c9
-rw-r--r--drivers/media/video/cx88/cx88-dvb.c2
-rw-r--r--drivers/media/video/cx88/cx88-i2c.c4
-rw-r--r--drivers/media/video/cx88/cx88-mpeg.c13
-rw-r--r--drivers/media/video/cx88/cx88-tvaudio.c4
-rw-r--r--drivers/media/video/cx88/cx88-video.c3
-rw-r--r--drivers/media/video/cx88/cx88.h17
-rw-r--r--drivers/media/video/ir-kbd-i2c.c19
-rw-r--r--drivers/media/video/msp3400-driver.c2
-rw-r--r--drivers/media/video/msp3400-driver.h1
-rw-r--r--drivers/media/video/msp3400-kthreads.c5
-rw-r--r--drivers/media/video/pvrusb2/Kconfig13
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c37
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.h8
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-i2c-chips-v4l2.c4
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-v4l2.c125
-rw-r--r--drivers/media/video/saa7134/saa7134-cards.c36
-rw-r--r--drivers/media/video/saa7134/saa7134-dvb.c1
-rw-r--r--drivers/media/video/saa7134/saa7134-input.c1
-rw-r--r--drivers/media/video/saa7134/saa7134.h1
-rw-r--r--drivers/media/video/video-buf.c7
76 files changed, 3196 insertions, 2792 deletions
diff --git a/drivers/char/.gitignore b/drivers/char/.gitignore
index 73dfdcebfbba..83683a2d8e6a 100644
--- a/drivers/char/.gitignore
+++ b/drivers/char/.gitignore
@@ -1,3 +1,2 @@
1consolemap_deftbl.c 1consolemap_deftbl.c
2defkeymap.c 2defkeymap.c
3qtronixmap.c
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index bde1c665d9f4..0e6f35fcc2eb 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -371,36 +371,6 @@ config AU1000_SERIAL_CONSOLE
371 If you have an Alchemy AU1000 processor (MIPS based) and you want 371 If you have an Alchemy AU1000 processor (MIPS based) and you want
372 to use a console on a serial port, say Y. Otherwise, say N. 372 to use a console on a serial port, say Y. Otherwise, say N.
373 373
374config QTRONIX_KEYBOARD
375 bool "Enable Qtronix 990P Keyboard Support"
376 depends on IT8712
377 help
378 Images of Qtronix keyboards are at
379 <http://www.qtronix.com/keyboard.html>.
380
381config IT8172_CIR
382 bool
383 depends on QTRONIX_KEYBOARD
384 default y
385
386config IT8172_SCR0
387 bool "Enable Smart Card Reader 0 Support "
388 depends on IT8712
389 help
390 Say Y here to support smart-card reader 0 (SCR0) on the Integrated
391 Technology Express, Inc. ITE8172 SBC. Vendor page at
392 <http://www.ite.com.tw/ia/brief_it8172bsp.htm>; picture of the
393 board at <http://www.mvista.com/partners/semiconductor/ite.html>.
394
395config IT8172_SCR1
396 bool "Enable Smart Card Reader 1 Support "
397 depends on IT8712
398 help
399 Say Y here to support smart-card reader 1 (SCR1) on the Integrated
400 Technology Express, Inc. ITE8172 SBC. Vendor page at
401 <http://www.ite.com.tw/ia/brief_it8172bsp.htm>; picture of the
402 board at <http://www.mvista.com/partners/semiconductor/ite.html>.
403
404config A2232 374config A2232
405 tristate "Commodore A2232 serial support (EXPERIMENTAL)" 375 tristate "Commodore A2232 serial support (EXPERIMENTAL)"
406 depends on EXPERIMENTAL && ZORRO && BROKEN_ON_SMP 376 depends on EXPERIMENTAL && ZORRO && BROKEN_ON_SMP
diff --git a/drivers/char/Makefile b/drivers/char/Makefile
index 19114df59bbd..777cad045094 100644
--- a/drivers/char/Makefile
+++ b/drivers/char/Makefile
@@ -102,7 +102,7 @@ obj-$(CONFIG_HANGCHECK_TIMER) += hangcheck-timer.o
102obj-$(CONFIG_TCG_TPM) += tpm/ 102obj-$(CONFIG_TCG_TPM) += tpm/
103 103
104# Files generated that shall be removed upon make clean 104# Files generated that shall be removed upon make clean
105clean-files := consolemap_deftbl.c defkeymap.c qtronixmap.c 105clean-files := consolemap_deftbl.c defkeymap.c
106 106
107quiet_cmd_conmk = CONMK $@ 107quiet_cmd_conmk = CONMK $@
108 cmd_conmk = scripts/conmakehash $< > $@ 108 cmd_conmk = scripts/conmakehash $< > $@
@@ -112,8 +112,6 @@ $(obj)/consolemap_deftbl.c: $(src)/$(FONTMAPFILE)
112 112
113$(obj)/defkeymap.o: $(obj)/defkeymap.c 113$(obj)/defkeymap.o: $(obj)/defkeymap.c
114 114
115$(obj)/qtronixmap.o: $(obj)/qtronixmap.c
116
117# Uncomment if you're changing the keymap and have an appropriate 115# Uncomment if you're changing the keymap and have an appropriate
118# loadkeys version for the map. By default, we'll use the shipped 116# loadkeys version for the map. By default, we'll use the shipped
119# versions. 117# versions.
@@ -121,7 +119,7 @@ $(obj)/qtronixmap.o: $(obj)/qtronixmap.c
121 119
122ifdef GENERATE_KEYMAP 120ifdef GENERATE_KEYMAP
123 121
124$(obj)/defkeymap.c $(obj)/qtronixmap.c: $(obj)/%.c: $(src)/%.map 122$(obj)/defkeymap.c $(obj)/%.c: $(src)/%.map
125 loadkeys --mktable $< > $@.tmp 123 loadkeys --mktable $< > $@.tmp
126 sed -e 's/^static *//' $@.tmp > $@ 124 sed -e 's/^static *//' $@.tmp > $@
127 rm $@.tmp 125 rm $@.tmp
diff --git a/drivers/char/ite_gpio.c b/drivers/char/ite_gpio.c
deleted file mode 100644
index ef14b6d1bc74..000000000000
--- a/drivers/char/ite_gpio.c
+++ /dev/null
@@ -1,419 +0,0 @@
1/*
2 * FILE NAME ite_gpio.c
3 *
4 * BRIEF MODULE DESCRIPTION
5 * API for ITE GPIO device.
6 * Driver for ITE GPIO device.
7 *
8 * Author: MontaVista Software, Inc. <source@mvista.com>
9 * Hai-Pao Fan <haipao@mvista.com>
10 *
11 * Copyright 2001 MontaVista Software Inc.
12 *
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the
15 * Free Software Foundation; either version 2 of the License, or (at your
16 * option) any later version.
17 *
18 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
19 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
21 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
24 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 * You should have received a copy of the GNU General Public License along
30 * with this program; if not, write to the Free Software Foundation, Inc.,
31 * 675 Mass Ave, Cambridge, MA 02139, USA.
32 */
33#include <linux/module.h>
34#include <linux/types.h>
35#include <linux/kernel.h>
36#include <linux/miscdevice.h>
37#include <linux/init.h>
38#include <linux/ioport.h>
39#include <asm/uaccess.h>
40#include <asm/addrspace.h>
41#include <asm/it8172/it8172_int.h>
42#include <linux/sched.h>
43#include <linux/ite_gpio.h>
44
45#define ite_gpio_base 0x14013800
46
47#define ITE_GPADR (*(volatile __u8 *)(0x14013800 + KSEG1))
48#define ITE_GPBDR (*(volatile __u8 *)(0x14013808 + KSEG1))
49#define ITE_GPCDR (*(volatile __u8 *)(0x14013810 + KSEG1))
50#define ITE_GPACR (*(volatile __u16 *)(0x14013802 + KSEG1))
51#define ITE_GPBCR (*(volatile __u16 *)(0x1401380a + KSEG1))
52#define ITE_GPCCR (*(volatile __u16 *)(0x14013812 + KSEG1))
53#define ITE_GPAICR (*(volatile __u16 *)(0x14013804 + KSEG1))
54#define ITE_GPBICR (*(volatile __u16 *)(0x1401380c + KSEG1))
55#define ITE_GPCICR (*(volatile __u16 *)(0x14013814 + KSEG1))
56#define ITE_GPAISR (*(volatile __u8 *)(0x14013806 + KSEG1))
57#define ITE_GPBISR (*(volatile __u8 *)(0x1401380e + KSEG1))
58#define ITE_GPCISR (*(volatile __u8 *)(0x14013816 + KSEG1))
59#define ITE_GCR (*(volatile __u8 *)(0x14013818 + KSEG1))
60
61#define MAX_GPIO_LINE 21
62static int ite_gpio_irq=IT8172_GPIO_IRQ;
63
64static long ite_irq_counter[MAX_GPIO_LINE];
65wait_queue_head_t ite_gpio_wait[MAX_GPIO_LINE];
66static int ite_gpio_irq_pending[MAX_GPIO_LINE];
67
68static int ite_gpio_debug=0;
69#define DEB(x) if (ite_gpio_debug>=1) x
70
71int ite_gpio_in(__u32 device, __u32 mask, volatile __u32 *data)
72{
73 DEB(printk("ite_gpio_in mask=0x%x\n",mask));
74
75 switch (device) {
76 case ITE_GPIO_PORTA:
77 ITE_GPACR = (__u16)mask; /* 0xffff */
78 *data = ITE_GPADR;
79 break;
80 case ITE_GPIO_PORTB:
81 ITE_GPBCR = (__u16)mask; /* 0xffff */
82 *data = ITE_GPBDR;
83 break;
84 case ITE_GPIO_PORTC:
85 ITE_GPCCR = (__u16)mask; /* 0x03ff */
86 *data = ITE_GPCDR;
87 break;
88 default:
89 return -EFAULT;
90 }
91
92 return 0;
93}
94
95
96int ite_gpio_out(__u32 device, __u32 mask, __u32 data)
97{
98 switch (device) {
99 case ITE_GPIO_PORTA:
100 ITE_GPACR = (__u16)mask; /* 0x5555 */
101 ITE_GPADR = (__u8)data;
102 break;
103 case ITE_GPIO_PORTB:
104 ITE_GPBCR = (__u16)mask; /* 0x5555 */
105 ITE_GPBDR = (__u8)data;
106 break;
107 case ITE_GPIO_PORTC:
108 ITE_GPCCR = (__u16)mask; /* 0x0155 */
109 ITE_GPCDR = (__u8)data;
110 break;
111 default:
112 return -EFAULT;
113 }
114
115 return 0;
116}
117
118int ite_gpio_int_ctrl(__u32 device, __u32 mask, __u32 data)
119{
120 switch (device) {
121 case ITE_GPIO_PORTA:
122 ITE_GPAICR = (ITE_GPAICR & ~mask) | (data & mask);
123 break;
124 case ITE_GPIO_PORTB:
125 ITE_GPBICR = (ITE_GPBICR & ~mask) | (data & mask);
126 break;
127 case ITE_GPIO_PORTC:
128 ITE_GPCICR = (ITE_GPCICR & ~mask) | (data & mask);
129 break;
130 default:
131 return -EFAULT;
132 }
133
134 return 0;
135}
136
137int ite_gpio_in_status(__u32 device, __u32 mask, volatile __u32 *data)
138{
139 int ret=-1;
140
141 if ((MAX_GPIO_LINE > *data) && (*data >= 0))
142 ret=ite_gpio_irq_pending[*data];
143
144 DEB(printk("ite_gpio_in_status %d ret=%d\n",*data, ret));
145
146 switch (device) {
147 case ITE_GPIO_PORTA:
148 *data = ITE_GPAISR & mask;
149 break;
150 case ITE_GPIO_PORTB:
151 *data = ITE_GPBISR & mask;
152 break;
153 case ITE_GPIO_PORTC:
154 *data = ITE_GPCISR & mask;
155 break;
156 default:
157 return -EFAULT;
158 }
159
160 return ret;
161}
162
163int ite_gpio_out_status(__u32 device, __u32 mask, __u32 data)
164{
165 switch (device) {
166 case ITE_GPIO_PORTA:
167 ITE_GPAISR = (ITE_GPAISR & ~mask) | (data & mask);
168 break;
169 case ITE_GPIO_PORTB:
170 ITE_GPBISR = (ITE_GPBISR & ~mask) | (data & mask);
171 break;
172 case ITE_GPIO_PORTC:
173 ITE_GPCISR = (ITE_GPCISR & ~mask) | (data & mask);
174 break;
175 default:
176 return -EFAULT;
177 }
178
179 return 0;
180}
181
182int ite_gpio_gen_ctrl(__u32 device, __u32 mask, __u32 data)
183{
184 ITE_GCR = (ITE_GCR & ~mask) | (data & mask);
185
186 return 0;
187}
188
189int ite_gpio_int_wait (__u32 device, __u32 mask, __u32 data)
190{
191 int i,line=0, ret=0;
192 unsigned long flags;
193
194 switch (device) {
195 case ITE_GPIO_PORTA:
196 line = data & mask;
197 break;
198 case ITE_GPIO_PORTB:
199 line = (data & mask) <<8;
200 break;
201 case ITE_GPIO_PORTC:
202 line = (data & mask) <<16;
203 break;
204 }
205 for (i=MAX_GPIO_LINE-1; i >= 0; i--) {
206 if ( (line) & (1 << i))
207 break;
208 }
209
210 DEB(printk("wait device=0x%d mask=0x%x data=0x%x index %d\n",
211 device, mask, data, i));
212
213 if (line & ~(1<<i))
214 return -EFAULT;
215
216 if (ite_gpio_irq_pending[i]==1)
217 return -EFAULT;
218
219 save_flags (flags);
220 cli();
221 ite_gpio_irq_pending[i] = 1;
222 ret = interruptible_sleep_on_timeout(&ite_gpio_wait[i], 3*HZ);
223 restore_flags (flags);
224 ite_gpio_irq_pending[i] = 0;
225
226 return ret;
227}
228
229EXPORT_SYMBOL(ite_gpio_in);
230EXPORT_SYMBOL(ite_gpio_out);
231EXPORT_SYMBOL(ite_gpio_int_ctrl);
232EXPORT_SYMBOL(ite_gpio_in_status);
233EXPORT_SYMBOL(ite_gpio_out_status);
234EXPORT_SYMBOL(ite_gpio_gen_ctrl);
235EXPORT_SYMBOL(ite_gpio_int_wait);
236
237static int ite_gpio_open(struct inode *inode, struct file *file)
238{
239 return 0;
240}
241
242
243static int ite_gpio_release(struct inode *inode, struct file *file)
244{
245 return 0;
246}
247
248
249static int ite_gpio_ioctl(struct inode *inode, struct file *file,
250 unsigned int cmd, unsigned long arg)
251{
252 static struct ite_gpio_ioctl_data ioctl_data;
253
254 if (copy_from_user(&ioctl_data, (struct ite_gpio_ioctl_data *)arg,
255 sizeof(ioctl_data)))
256 return -EFAULT;
257 if ((ioctl_data.device < ITE_GPIO_PORTA) ||
258 (ioctl_data.device > ITE_GPIO_PORTC) )
259 return -EFAULT;
260
261 switch(cmd) {
262 case ITE_GPIO_IN:
263 if (ite_gpio_in(ioctl_data.device, ioctl_data.mask,
264 &ioctl_data.data))
265 return -EFAULT;
266
267 if (copy_to_user((struct ite_gpio_ioctl_data *)arg,
268 &ioctl_data, sizeof(ioctl_data)))
269 return -EFAULT;
270 break;
271
272 case ITE_GPIO_OUT:
273 return ite_gpio_out(ioctl_data.device,
274 ioctl_data.mask, ioctl_data.data);
275 break;
276
277 case ITE_GPIO_INT_CTRL:
278 return ite_gpio_int_ctrl(ioctl_data.device,
279 ioctl_data.mask, ioctl_data.data);
280 break;
281
282 case ITE_GPIO_IN_STATUS:
283 if (ite_gpio_in_status(ioctl_data.device, ioctl_data.mask,
284 &ioctl_data.data))
285 return -EFAULT;
286 if (copy_to_user((struct ite_gpio_ioctl_data *)arg,
287 &ioctl_data, sizeof(ioctl_data)))
288 return -EFAULT;
289 break;
290
291 case ITE_GPIO_OUT_STATUS:
292 return ite_gpio_out_status(ioctl_data.device,
293 ioctl_data.mask, ioctl_data.data);
294 break;
295
296 case ITE_GPIO_GEN_CTRL:
297 return ite_gpio_gen_ctrl(ioctl_data.device,
298 ioctl_data.mask, ioctl_data.data);
299 break;
300
301 case ITE_GPIO_INT_WAIT:
302 return ite_gpio_int_wait(ioctl_data.device,
303 ioctl_data.mask, ioctl_data.data);
304 break;
305
306 default:
307 return -ENOIOCTLCMD;
308
309 }
310
311 return 0;
312}
313
314static void ite_gpio_irq_handler(int this_irq, void *dev_id,
315 struct pt_regs *regs)
316{
317 int i,line;
318
319 line = ITE_GPCISR & 0x1f;
320 for (i=4; i >=0; i--) {
321 if ( line & (1 << i)) {
322 ++ite_irq_counter[i+16];
323 ite_gpio_irq_pending[i+16] = 2;
324 wake_up_interruptible(&ite_gpio_wait[i+16]);
325
326DEB(printk("interrupt 0x%x %d\n", &ite_gpio_wait[i+16], i+16));
327
328 ITE_GPCISR = ITE_GPCISR & (1<<i);
329 return;
330 }
331 }
332 line = ITE_GPBISR;
333 for (i=7; i >= 0; i--) {
334 if ( line & (1 << i)) {
335 ++ite_irq_counter[i+8];
336 ite_gpio_irq_pending[i+8] = 2;
337 wake_up_interruptible(&ite_gpio_wait[i+8]);
338
339DEB(printk("interrupt 0x%x %d\n",ITE_GPBISR, i+8));
340
341 ITE_GPBISR = ITE_GPBISR & (1<<i);
342 return;
343 }
344 }
345 line = ITE_GPAISR;
346 for (i=7; i >= 0; i--) {
347 if ( line & (1 << i)) {
348 ++ite_irq_counter[i];
349 ite_gpio_irq_pending[i] = 2;
350 wake_up_interruptible(&ite_gpio_wait[i]);
351
352DEB(printk("interrupt 0x%x %d\n",ITE_GPAISR, i));
353
354 ITE_GPAISR = ITE_GPAISR & (1<<i);
355 return;
356 }
357 }
358}
359
360static const struct file_operations ite_gpio_fops = {
361 .owner = THIS_MODULE,
362 .ioctl = ite_gpio_ioctl,
363 .open = ite_gpio_open,
364 .release = ite_gpio_release,
365};
366
367static struct miscdevice ite_gpio_miscdev = {
368 MISC_DYNAMIC_MINOR,
369 "ite_gpio",
370 &ite_gpio_fops
371};
372
373int __init ite_gpio_init(void)
374{
375 int i;
376
377 if (misc_register(&ite_gpio_miscdev))
378 return -ENODEV;
379
380 if (!request_region(ite_gpio_base, 0x1c, "ITE GPIO"))
381 {
382 misc_deregister(&ite_gpio_miscdev);
383 return -EIO;
384 }
385
386 /* initialize registers */
387 ITE_GPACR = 0xffff;
388 ITE_GPBCR = 0xffff;
389 ITE_GPCCR = 0xffff;
390 ITE_GPAICR = 0x00ff;
391 ITE_GPBICR = 0x00ff;
392 ITE_GPCICR = 0x00ff;
393 ITE_GCR = 0;
394
395 for (i = 0; i < MAX_GPIO_LINE; i++) {
396 ite_gpio_irq_pending[i]=0;
397 init_waitqueue_head(&ite_gpio_wait[i]);
398 }
399
400 if (request_irq(ite_gpio_irq, ite_gpio_irq_handler, IRQF_SHARED, "gpio", 0) < 0) {
401 misc_deregister(&ite_gpio_miscdev);
402 release_region(ite_gpio_base, 0x1c);
403 return 0;
404 }
405
406 printk("GPIO at 0x%x (irq = %d)\n", ite_gpio_base, ite_gpio_irq);
407
408 return 0;
409}
410
411static void __exit ite_gpio_exit(void)
412{
413 misc_deregister(&ite_gpio_miscdev);
414}
415
416module_init(ite_gpio_init);
417module_exit(ite_gpio_exit);
418
419MODULE_LICENSE("GPL");
diff --git a/drivers/char/qtronixmap.c_shipped b/drivers/char/qtronixmap.c_shipped
deleted file mode 100644
index 1e2b92b7d57a..000000000000
--- a/drivers/char/qtronixmap.c_shipped
+++ /dev/null
@@ -1,265 +0,0 @@
1
2/* Do not edit this file! It was automatically generated by */
3/* loadkeys --mktable defkeymap.map > defkeymap.c */
4
5#include <linux/types.h>
6#include <linux/keyboard.h>
7#include <linux/kd.h>
8
9u_short plain_map[NR_KEYS] = {
10 0xf200, 0xf060, 0xf031, 0xf032, 0xf033, 0xf034, 0xf035, 0xf036,
11 0xf037, 0xf038, 0xf039, 0xf030, 0xf02d, 0xf03d, 0xf200, 0xf07f,
12 0xf009, 0xfb71, 0xfb77, 0xfb65, 0xfb72, 0xfb74, 0xfb79, 0xfb75,
13 0xfb69, 0xfb6f, 0xfb70, 0xf05b, 0xf05d, 0xf05c, 0xf207, 0xfb61,
14 0xfb73, 0xfb64, 0xfb66, 0xfb67, 0xfb68, 0xfb6a, 0xfb6b, 0xfb6c,
15 0xf03b, 0xf027, 0xf060, 0xf201, 0xf700, 0xf200, 0xfb7a, 0xfb78,
16 0xfb63, 0xfb76, 0xfb62, 0xfb6e, 0xfb6d, 0xf02c, 0xf02e, 0xf02f,
17 0xf200, 0xf700, 0xf702, 0xf200, 0xf703, 0xf020, 0xf703, 0xf200,
18 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
19 0xf200, 0xf200, 0xf200, 0xf115, 0xf07f, 0xf200, 0xf200, 0xf601,
20 0xf200, 0xf200, 0xf200, 0xf603, 0xf600, 0xf118, 0xf119, 0xf200,
21 0xf200, 0xf602, 0xf208, 0xf02d, 0xf02b, 0xf30c, 0xf02e, 0xf30d,
22 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
23 0xf200, 0xf200, 0xf200, 0xf117, 0xf600, 0xf200, 0xf01b, 0xf200,
24 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107,
25 0xf108, 0xf109, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200,
26};
27
28u_short shift_map[NR_KEYS] = {
29 0xf200, 0xf07e, 0xf021, 0xf040, 0xf023, 0xf024, 0xf025, 0xf05e,
30 0xf026, 0xf02a, 0xf028, 0xf029, 0xf05f, 0xf02b, 0xf200, 0xf07f,
31 0xf009, 0xfb51, 0xfb57, 0xfb45, 0xfb52, 0xfb54, 0xfb59, 0xfb55,
32 0xfb49, 0xfb4f, 0xfb50, 0xf07b, 0xf07d, 0xf07c, 0xf207, 0xfb41,
33 0xfb53, 0xfb44, 0xfb46, 0xfb47, 0xfb48, 0xfb4a, 0xfb4b, 0xfb4c,
34 0xf03a, 0xf022, 0xf07e, 0xf201, 0xf700, 0xf200, 0xfb5a, 0xfb58,
35 0xfb43, 0xfb56, 0xfb42, 0xfb4e, 0xfb4d, 0xf03c, 0xf03e, 0xf03f,
36 0xf200, 0xf700, 0xf702, 0xf200, 0xf703, 0xf020, 0xf703, 0xf200,
37 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
38 0xf200, 0xf200, 0xf200, 0xf115, 0xf07f, 0xf200, 0xf200, 0xf601,
39 0xf200, 0xf200, 0xf200, 0xf603, 0xf600, 0xf20b, 0xf20a, 0xf200,
40 0xf200, 0xf602, 0xf213, 0xf02d, 0xf02b, 0xf30c, 0xf02e, 0xf30d,
41 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
42 0xf200, 0xf200, 0xf200, 0xf117, 0xf600, 0xf200, 0xf01b, 0xf200,
43 0xf10a, 0xf10b, 0xf10c, 0xf10d, 0xf10e, 0xf10f, 0xf110, 0xf111,
44 0xf112, 0xf113, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200,
45};
46
47u_short altgr_map[NR_KEYS] = {
48 0xf200, 0xf200, 0xf200, 0xf040, 0xf200, 0xf024, 0xf200, 0xf200,
49 0xf07b, 0xf05b, 0xf05d, 0xf07d, 0xf05c, 0xf200, 0xf200, 0xf200,
50 0xf200, 0xfb71, 0xfb77, 0xfb65, 0xfb72, 0xfb74, 0xfb79, 0xfb75,
51 0xfb69, 0xfb6f, 0xfb70, 0xf200, 0xf200, 0xf200, 0xf207, 0xfb61,
52 0xfb73, 0xfb64, 0xfb66, 0xfb67, 0xfb68, 0xfb6a, 0xfb6b, 0xfb6c,
53 0xf200, 0xf200, 0xf200, 0xf201, 0xf700, 0xf200, 0xfb7a, 0xfb78,
54 0xfb63, 0xfb76, 0xfb62, 0xfb6e, 0xfb6d, 0xf200, 0xf200, 0xf200,
55 0xf200, 0xf700, 0xf702, 0xf200, 0xf703, 0xf200, 0xf703, 0xf200,
56 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
57 0xf200, 0xf200, 0xf200, 0xf115, 0xf07f, 0xf200, 0xf200, 0xf601,
58 0xf200, 0xf200, 0xf200, 0xf603, 0xf600, 0xf118, 0xf119, 0xf200,
59 0xf200, 0xf602, 0xf208, 0xf02d, 0xf02b, 0xf30c, 0xf02e, 0xf30d,
60 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
61 0xf200, 0xf200, 0xf200, 0xf117, 0xf600, 0xf200, 0xf200, 0xf200,
62 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510, 0xf511, 0xf512, 0xf513,
63 0xf514, 0xf515, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200,
64};
65
66u_short ctrl_map[NR_KEYS] = {
67 0xf200, 0xf200, 0xf200, 0xf000, 0xf01b, 0xf01c, 0xf01d, 0xf01e,
68 0xf01f, 0xf07f, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf200, 0xf008,
69 0xf200, 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015,
70 0xf009, 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf01c, 0xf207, 0xf001,
71 0xf013, 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c,
72 0xf007, 0xf000, 0xf200, 0xf201, 0xf700, 0xf200, 0xf01a, 0xf018,
73 0xf003, 0xf016, 0xf002, 0xf00e, 0xf20e, 0xf07f, 0xf200, 0xf200,
74 0xf200, 0xf700, 0xf702, 0xf200, 0xf703, 0xf000, 0xf703, 0xf200,
75 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
76 0xf200, 0xf200, 0xf200, 0xf115, 0xf07f, 0xf200, 0xf200, 0xf601,
77 0xf200, 0xf200, 0xf200, 0xf603, 0xf600, 0xf118, 0xf119, 0xf200,
78 0xf200, 0xf602, 0xf208, 0xf02d, 0xf02b, 0xf30c, 0xf02e, 0xf30d,
79 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
80 0xf200, 0xf200, 0xf200, 0xf117, 0xf600, 0xf200, 0xf200, 0xf200,
81 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107,
82 0xf108, 0xf109, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200,
83};
84
85u_short shift_ctrl_map[NR_KEYS] = {
86 0xf200, 0xf200, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf200,
87 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf200, 0xf200,
88 0xf200, 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015,
89 0xf009, 0xf00f, 0xf010, 0xf200, 0xf200, 0xf200, 0xf207, 0xf001,
90 0xf013, 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c,
91 0xf200, 0xf200, 0xf200, 0xf201, 0xf700, 0xf200, 0xf01a, 0xf018,
92 0xf003, 0xf016, 0xf002, 0xf00e, 0xf00d, 0xf200, 0xf200, 0xf200,
93 0xf200, 0xf700, 0xf702, 0xf200, 0xf703, 0xf200, 0xf703, 0xf200,
94 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
95 0xf200, 0xf200, 0xf200, 0xf115, 0xf07f, 0xf200, 0xf200, 0xf601,
96 0xf200, 0xf200, 0xf200, 0xf603, 0xf600, 0xf118, 0xf119, 0xf200,
97 0xf200, 0xf602, 0xf208, 0xf02d, 0xf02b, 0xf30c, 0xf02e, 0xf30d,
98 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
99 0xf200, 0xf200, 0xf200, 0xf117, 0xf600, 0xf200, 0xf200, 0xf200,
100 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
101 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200,
102};
103
104u_short alt_map[NR_KEYS] = {
105 0xf200, 0xf81b, 0xf831, 0xf832, 0xf833, 0xf834, 0xf835, 0xf836,
106 0xf837, 0xf838, 0xf839, 0xf830, 0xf82d, 0xf83d, 0xf200, 0xf87f,
107 0xf809, 0xf871, 0xf877, 0xf865, 0xf872, 0xf874, 0xf879, 0xf875,
108 0xf869, 0xf86f, 0xf870, 0xf85b, 0xf85d, 0xf85c, 0xf207, 0xf861,
109 0xf873, 0xf864, 0xf866, 0xf867, 0xf868, 0xf86a, 0xf86b, 0xf83b,
110 0xf827, 0xf860, 0xf200, 0xf80d, 0xf700, 0xf200, 0xf87a, 0xf878,
111 0xf863, 0xf876, 0xf862, 0xf82c, 0xf82e, 0xf82f, 0xf200, 0xf200,
112 0xf200, 0xf700, 0xf702, 0xf200, 0xf703, 0xf820, 0xf703, 0xf200,
113 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
114 0xf200, 0xf200, 0xf200, 0xf115, 0xf07f, 0xf200, 0xf200, 0xf210,
115 0xf200, 0xf200, 0xf200, 0xf603, 0xf600, 0xf118, 0xf119, 0xf200,
116 0xf200, 0xf211, 0xf208, 0xf02d, 0xf02b, 0xf30c, 0xf02e, 0xf30d,
117 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
118 0xf200, 0xf200, 0xf200, 0xf117, 0xf600, 0xf200, 0xf200, 0xf200,
119 0xf500, 0xf501, 0xf502, 0xf503, 0xf504, 0xf505, 0xf506, 0xf507,
120 0xf508, 0xf509, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200,
121};
122
123u_short ctrl_alt_map[NR_KEYS] = {
124 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
125 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
126 0xf200, 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815,
127 0xf809, 0xf80f, 0xf810, 0xf200, 0xf200, 0xf200, 0xf207, 0xf801,
128 0xf813, 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c,
129 0xf200, 0xf200, 0xf200, 0xf201, 0xf700, 0xf200, 0xf81a, 0xf818,
130 0xf803, 0xf816, 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf200, 0xf200,
131 0xf200, 0xf700, 0xf702, 0xf200, 0xf703, 0xf200, 0xf703, 0xf200,
132 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
133 0xf200, 0xf200, 0xf200, 0xf115, 0xf07f, 0xf200, 0xf200, 0xf601,
134 0xf200, 0xf200, 0xf200, 0xf603, 0xf600, 0xf118, 0xf119, 0xf200,
135 0xf200, 0xf602, 0xf208, 0xf02d, 0xf02b, 0xf30c, 0xf02e, 0xf30d,
136 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
137 0xf200, 0xf200, 0xf200, 0xf117, 0xf600, 0xf200, 0xf200, 0xf200,
138 0xf500, 0xf501, 0xf502, 0xf503, 0xf504, 0xf505, 0xf506, 0xf507,
139 0xf508, 0xf509, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200,
140};
141
142ushort *key_maps[MAX_NR_KEYMAPS] = {
143 plain_map, shift_map, altgr_map, 0,
144 ctrl_map, shift_ctrl_map, 0, 0,
145 alt_map, 0, 0, 0,
146 ctrl_alt_map, 0
147};
148
149unsigned int keymap_count = 7;
150
151
152/*
153 * Philosophy: most people do not define more strings, but they who do
154 * often want quite a lot of string space. So, we statically allocate
155 * the default and allocate dynamically in chunks of 512 bytes.
156 */
157
158char func_buf[] = {
159 '\033', '[', '[', 'A', 0,
160 '\033', '[', '[', 'B', 0,
161 '\033', '[', '[', 'C', 0,
162 '\033', '[', '[', 'D', 0,
163 '\033', '[', '[', 'E', 0,
164 '\033', '[', '1', '7', '~', 0,
165 '\033', '[', '1', '8', '~', 0,
166 '\033', '[', '1', '9', '~', 0,
167 '\033', '[', '2', '0', '~', 0,
168 '\033', '[', '2', '1', '~', 0,
169 '\033', '[', '2', '3', '~', 0,
170 '\033', '[', '2', '4', '~', 0,
171 '\033', '[', '2', '5', '~', 0,
172 '\033', '[', '2', '6', '~', 0,
173 '\033', '[', '2', '8', '~', 0,
174 '\033', '[', '2', '9', '~', 0,
175 '\033', '[', '3', '1', '~', 0,
176 '\033', '[', '3', '2', '~', 0,
177 '\033', '[', '3', '3', '~', 0,
178 '\033', '[', '3', '4', '~', 0,
179 '\033', '[', '1', '~', 0,
180 '\033', '[', '2', '~', 0,
181 '\033', '[', '3', '~', 0,
182 '\033', '[', '4', '~', 0,
183 '\033', '[', '5', '~', 0,
184 '\033', '[', '6', '~', 0,
185 '\033', '[', 'M', 0,
186 '\033', '[', 'P', 0,
187};
188
189
190char *funcbufptr = func_buf;
191int funcbufsize = sizeof(func_buf);
192int funcbufleft = 0; /* space left */
193
194char *func_table[MAX_NR_FUNC] = {
195 func_buf + 0,
196 func_buf + 5,
197 func_buf + 10,
198 func_buf + 15,
199 func_buf + 20,
200 func_buf + 25,
201 func_buf + 31,
202 func_buf + 37,
203 func_buf + 43,
204 func_buf + 49,
205 func_buf + 55,
206 func_buf + 61,
207 func_buf + 67,
208 func_buf + 73,
209 func_buf + 79,
210 func_buf + 85,
211 func_buf + 91,
212 func_buf + 97,
213 func_buf + 103,
214 func_buf + 109,
215 func_buf + 115,
216 func_buf + 120,
217 func_buf + 125,
218 func_buf + 130,
219 func_buf + 135,
220 func_buf + 140,
221 func_buf + 145,
222 0,
223 0,
224 func_buf + 149,
225 0,
226};
227
228struct kbdiacr accent_table[MAX_DIACR] = {
229 {'`', 'A', 'À'}, {'`', 'a', 'à'},
230 {'\'', 'A', 'Á'}, {'\'', 'a', 'á'},
231 {'^', 'A', 'Â'}, {'^', 'a', 'â'},
232 {'~', 'A', 'Ã'}, {'~', 'a', 'ã'},
233 {'"', 'A', 'Ä'}, {'"', 'a', 'ä'},
234 {'O', 'A', 'Å'}, {'o', 'a', 'å'},
235 {'0', 'A', 'Å'}, {'0', 'a', 'å'},
236 {'A', 'A', 'Å'}, {'a', 'a', 'å'},
237 {'A', 'E', 'Æ'}, {'a', 'e', 'æ'},
238 {',', 'C', 'Ç'}, {',', 'c', 'ç'},
239 {'`', 'E', 'È'}, {'`', 'e', 'è'},
240 {'\'', 'E', 'É'}, {'\'', 'e', 'é'},
241 {'^', 'E', 'Ê'}, {'^', 'e', 'ê'},
242 {'"', 'E', 'Ë'}, {'"', 'e', 'ë'},
243 {'`', 'I', 'Ì'}, {'`', 'i', 'ì'},
244 {'\'', 'I', 'Í'}, {'\'', 'i', 'í'},
245 {'^', 'I', 'Î'}, {'^', 'i', 'î'},
246 {'"', 'I', 'Ï'}, {'"', 'i', 'ï'},
247 {'-', 'D', 'Ð'}, {'-', 'd', 'ð'},
248 {'~', 'N', 'Ñ'}, {'~', 'n', 'ñ'},
249 {'`', 'O', 'Ò'}, {'`', 'o', 'ò'},
250 {'\'', 'O', 'Ó'}, {'\'', 'o', 'ó'},
251 {'^', 'O', 'Ô'}, {'^', 'o', 'ô'},
252 {'~', 'O', 'Õ'}, {'~', 'o', 'õ'},
253 {'"', 'O', 'Ö'}, {'"', 'o', 'ö'},
254 {'/', 'O', 'Ø'}, {'/', 'o', 'ø'},
255 {'`', 'U', 'Ù'}, {'`', 'u', 'ù'},
256 {'\'', 'U', 'Ú'}, {'\'', 'u', 'ú'},
257 {'^', 'U', 'Û'}, {'^', 'u', 'û'},
258 {'"', 'U', 'Ü'}, {'"', 'u', 'ü'},
259 {'\'', 'Y', 'Ý'}, {'\'', 'y', 'ý'},
260 {'T', 'H', 'Þ'}, {'t', 'h', 'þ'},
261 {'s', 's', 'ß'}, {'"', 'y', 'ÿ'},
262 {'s', 'z', 'ß'}, {'i', 'j', 'ÿ'},
263};
264
265unsigned int accent_table_size = 68;
diff --git a/drivers/char/qtronixmap.map b/drivers/char/qtronixmap.map
deleted file mode 100644
index 8d1ff5c1e281..000000000000
--- a/drivers/char/qtronixmap.map
+++ /dev/null
@@ -1,287 +0,0 @@
1# Default kernel keymap. This uses 7 modifier combinations.
2keymaps 0-2,4-5,8,12
3# Change the above line into
4# keymaps 0-2,4-6,8,12
5# in case you want the entries
6# altgr control keycode 83 = Boot
7# altgr control keycode 111 = Boot
8# below.
9#
10# In fact AltGr is used very little, and one more keymap can
11# be saved by mapping AltGr to Alt (and adapting a few entries):
12# keycode 100 = Alt
13#
14keycode 1 = grave asciitilde
15 alt keycode 1 = Meta_Escape
16keycode 2 = one exclam
17 alt keycode 2 = Meta_one
18keycode 3 = two at at
19 control keycode 3 = nul
20 shift control keycode 3 = nul
21 alt keycode 3 = Meta_two
22keycode 4 = three numbersign
23 control keycode 4 = Escape
24 alt keycode 4 = Meta_three
25keycode 5 = four dollar dollar
26 control keycode 5 = Control_backslash
27 alt keycode 5 = Meta_four
28keycode 6 = five percent
29 control keycode 6 = Control_bracketright
30 alt keycode 6 = Meta_five
31keycode 7 = six asciicircum
32 control keycode 7 = Control_asciicircum
33 alt keycode 7 = Meta_six
34keycode 8 = seven ampersand braceleft
35 control keycode 8 = Control_underscore
36 alt keycode 8 = Meta_seven
37keycode 9 = eight asterisk bracketleft
38 control keycode 9 = Delete
39 alt keycode 9 = Meta_eight
40keycode 10 = nine parenleft bracketright
41 alt keycode 10 = Meta_nine
42keycode 11 = zero parenright braceright
43 alt keycode 11 = Meta_zero
44keycode 12 = minus underscore backslash
45 control keycode 12 = Control_underscore
46 shift control keycode 12 = Control_underscore
47 alt keycode 12 = Meta_minus
48keycode 13 = equal plus
49 alt keycode 13 = Meta_equal
50keycode 15 = Delete Delete
51 control keycode 15 = BackSpace
52 alt keycode 15 = Meta_Delete
53keycode 16 = Tab Tab
54 alt keycode 16 = Meta_Tab
55keycode 17 = q
56keycode 18 = w
57keycode 19 = e
58keycode 20 = r
59keycode 21 = t
60keycode 22 = y
61keycode 23 = u
62keycode 24 = i
63keycode 25 = o
64keycode 26 = p
65keycode 27 = bracketleft braceleft
66 control keycode 27 = Escape
67 alt keycode 27 = Meta_bracketleft
68keycode 28 = bracketright braceright
69 control keycode 28 = Control_bracketright
70 alt keycode 28 = Meta_bracketright
71keycode 29 = backslash bar
72 control keycode 29 = Control_backslash
73 alt keycode 29 = Meta_backslash
74keycode 30 = Caps_Lock
75keycode 31 = a
76keycode 32 = s
77keycode 33 = d
78keycode 34 = f
79keycode 35 = g
80keycode 36 = h
81keycode 37 = j
82keycode 38 = k
83keycode 39 = l
84keycode 40 = semicolon colon
85 alt keycode 39 = Meta_semicolon
86keycode 41 = apostrophe quotedbl
87 control keycode 40 = Control_g
88 alt keycode 40 = Meta_apostrophe
89keycode 42 = grave asciitilde
90 control keycode 41 = nul
91 alt keycode 41 = Meta_grave
92keycode 43 = Return
93 alt keycode 43 = Meta_Control_m
94keycode 44 = Shift
95keycode 46 = z
96keycode 47 = x
97keycode 48 = c
98keycode 49 = v
99keycode 50 = b
100keycode 51 = n
101keycode 52 = m
102keycode 53 = comma less
103 alt keycode 51 = Meta_comma
104keycode 54 = period greater
105 control keycode 52 = Compose
106 alt keycode 52 = Meta_period
107keycode 55 = slash question
108 control keycode 53 = Delete
109 alt keycode 53 = Meta_slash
110keycode 57 = Shift
111keycode 58 = Control
112keycode 60 = Alt
113keycode 61 = space space
114 control keycode 61 = nul
115 alt keycode 61 = Meta_space
116keycode 62 = Alt
117
118keycode 75 = Insert
119keycode 76 = Delete
120
121keycode 83 = Up
122keycode 84 = Down
123
124keycode 85 = Prior
125 shift keycode 85 = Scroll_Backward
126keycode 86 = Next
127 shift keycode 86 = Scroll_Forward
128keycode 89 = Right
129 alt keycode 89 = Incr_Console
130keycode 79 = Left
131 alt keycode 79 = Decr_Console
132
133keycode 90 = Num_Lock
134 shift keycode 90 = Bare_Num_Lock
135
136keycode 91 = minus
137keycode 92 = plus
138keycode 93 = KP_Multiply
139keycode 94 = period
140keycode 95 = KP_Divide
141
142keycode 107 = Select
143keycode 108 = Down
144
145keycode 110 = Escape Escape
146 alt keycode 1 = Meta_Escape
147
148keycode 112 = F1 F11 Console_13
149 control keycode 112 = F1
150 alt keycode 112 = Console_1
151 control alt keycode 112 = Console_1
152keycode 113 = F2 F12 Console_14
153 control keycode 113 = F2
154 alt keycode 113 = Console_2
155 control alt keycode 113 = Console_2
156keycode 114 = F3 F13 Console_15
157 control keycode 114 = F3
158 alt keycode 114 = Console_3
159 control alt keycode 114 = Console_3
160keycode 115 = F4 F14 Console_16
161 control keycode 115 = F4
162 alt keycode 115 = Console_4
163 control alt keycode 115 = Console_4
164keycode 116 = F5 F15 Console_17
165 control keycode 116 = F5
166 alt keycode 116 = Console_5
167 control alt keycode 116 = Console_5
168keycode 117 = F6 F16 Console_18
169 control keycode 117 = F6
170 alt keycode 117 = Console_6
171 control alt keycode 117 = Console_6
172keycode 118 = F7 F17 Console_19
173 control keycode 118 = F7
174 alt keycode 118 = Console_7
175 control alt keycode 118 = Console_7
176keycode 119 = F8 F18 Console_20
177 control keycode 119 = F8
178 alt keycode 119 = Console_8
179 control alt keycode 119 = Console_8
180keycode 120 = F9 F19 Console_21
181 control keycode 120 = F9
182 alt keycode 120 = Console_9
183 control alt keycode 120 = Console_9
184keycode 121 = F10 F20 Console_22
185 control keycode 121 = F10
186 alt keycode 121 = Console_10
187 control alt keycode 121 = Console_10
188
189keycode 126 = Pause
190
191
192string F1 = "\033[[A"
193string F2 = "\033[[B"
194string F3 = "\033[[C"
195string F4 = "\033[[D"
196string F5 = "\033[[E"
197string F6 = "\033[17~"
198string F7 = "\033[18~"
199string F8 = "\033[19~"
200string F9 = "\033[20~"
201string F10 = "\033[21~"
202string F11 = "\033[23~"
203string F12 = "\033[24~"
204string F13 = "\033[25~"
205string F14 = "\033[26~"
206string F15 = "\033[28~"
207string F16 = "\033[29~"
208string F17 = "\033[31~"
209string F18 = "\033[32~"
210string F19 = "\033[33~"
211string F20 = "\033[34~"
212string Find = "\033[1~"
213string Insert = "\033[2~"
214string Remove = "\033[3~"
215string Select = "\033[4~"
216string Prior = "\033[5~"
217string Next = "\033[6~"
218string Macro = "\033[M"
219string Pause = "\033[P"
220compose '`' 'A' to 'À'
221compose '`' 'a' to 'à'
222compose '\'' 'A' to 'Á'
223compose '\'' 'a' to 'á'
224compose '^' 'A' to 'Â'
225compose '^' 'a' to 'â'
226compose '~' 'A' to 'Ã'
227compose '~' 'a' to 'ã'
228compose '"' 'A' to 'Ä'
229compose '"' 'a' to 'ä'
230compose 'O' 'A' to 'Å'
231compose 'o' 'a' to 'å'
232compose '0' 'A' to 'Å'
233compose '0' 'a' to 'å'
234compose 'A' 'A' to 'Å'
235compose 'a' 'a' to 'å'
236compose 'A' 'E' to 'Æ'
237compose 'a' 'e' to 'æ'
238compose ',' 'C' to 'Ç'
239compose ',' 'c' to 'ç'
240compose '`' 'E' to 'È'
241compose '`' 'e' to 'è'
242compose '\'' 'E' to 'É'
243compose '\'' 'e' to 'é'
244compose '^' 'E' to 'Ê'
245compose '^' 'e' to 'ê'
246compose '"' 'E' to 'Ë'
247compose '"' 'e' to 'ë'
248compose '`' 'I' to 'Ì'
249compose '`' 'i' to 'ì'
250compose '\'' 'I' to 'Í'
251compose '\'' 'i' to 'í'
252compose '^' 'I' to 'Î'
253compose '^' 'i' to 'î'
254compose '"' 'I' to 'Ï'
255compose '"' 'i' to 'ï'
256compose '-' 'D' to 'Ð'
257compose '-' 'd' to 'ð'
258compose '~' 'N' to 'Ñ'
259compose '~' 'n' to 'ñ'
260compose '`' 'O' to 'Ò'
261compose '`' 'o' to 'ò'
262compose '\'' 'O' to 'Ó'
263compose '\'' 'o' to 'ó'
264compose '^' 'O' to 'Ô'
265compose '^' 'o' to 'ô'
266compose '~' 'O' to 'Õ'
267compose '~' 'o' to 'õ'
268compose '"' 'O' to 'Ö'
269compose '"' 'o' to 'ö'
270compose '/' 'O' to 'Ø'
271compose '/' 'o' to 'ø'
272compose '`' 'U' to 'Ù'
273compose '`' 'u' to 'ù'
274compose '\'' 'U' to 'Ú'
275compose '\'' 'u' to 'ú'
276compose '^' 'U' to 'Û'
277compose '^' 'u' to 'û'
278compose '"' 'U' to 'Ü'
279compose '"' 'u' to 'ü'
280compose '\'' 'Y' to 'Ý'
281compose '\'' 'y' to 'ý'
282compose 'T' 'H' to 'Þ'
283compose 't' 'h' to 'þ'
284compose 's' 's' to 'ß'
285compose '"' 'y' to 'ÿ'
286compose 's' 'z' to 'ß'
287compose 'i' 'j' to 'ÿ'
diff --git a/drivers/char/watchdog/Kconfig b/drivers/char/watchdog/Kconfig
index 06f3fa2fe877..89e46d6dfc4e 100644
--- a/drivers/char/watchdog/Kconfig
+++ b/drivers/char/watchdog/Kconfig
@@ -316,6 +316,27 @@ config I8XX_TCO
316 To compile this driver as a module, choose M here: the 316 To compile this driver as a module, choose M here: the
317 module will be called i8xx_tco. 317 module will be called i8xx_tco.
318 318
319config ITCO_WDT
320 tristate "Intel TCO Timer/Watchdog (EXPERIMENTAL)"
321 depends on WATCHDOG && (X86 || IA64) && PCI && EXPERIMENTAL
322 ---help---
323 Hardware driver for the intel TCO timer based watchdog devices.
324 These drivers are included in the Intel 82801 I/O Controller
325 Hub family 'from ICH0 up to ICH7) and in the Intel 6300ESB
326 controller hub.
327
328 The TCO (Total Cost of Ownership) timer is a watchdog timer
329 that will reboot the machine after its second expiration. The
330 expiration time can be configured with the "heartbeat" parameter.
331
332 On some motherboards the driver may fail to reset the chipset's
333 NO_REBOOT flag which prevents the watchdog from rebooting the
334 machine. If this is the case you will get a kernel message like
335 "failed to reset NO_REBOOT flag, reboot disabled by hardware".
336
337 To compile this driver as a module, choose M here: the
338 module will be called iTCO_wdt.
339
319config SC1200_WDT 340config SC1200_WDT
320 tristate "National Semiconductor PC87307/PC97307 (ala SC1200) Watchdog" 341 tristate "National Semiconductor PC87307/PC97307 (ala SC1200) Watchdog"
321 depends on WATCHDOG && X86 342 depends on WATCHDOG && X86
diff --git a/drivers/char/watchdog/Makefile b/drivers/char/watchdog/Makefile
index 6ffca7cb56ab..7f70abad465a 100644
--- a/drivers/char/watchdog/Makefile
+++ b/drivers/char/watchdog/Makefile
@@ -47,6 +47,7 @@ obj-$(CONFIG_IBMASR) += ibmasr.o
47obj-$(CONFIG_WAFER_WDT) += wafer5823wdt.o 47obj-$(CONFIG_WAFER_WDT) += wafer5823wdt.o
48obj-$(CONFIG_I6300ESB_WDT) += i6300esb.o 48obj-$(CONFIG_I6300ESB_WDT) += i6300esb.o
49obj-$(CONFIG_I8XX_TCO) += i8xx_tco.o 49obj-$(CONFIG_I8XX_TCO) += i8xx_tco.o
50obj-$(CONFIG_ITCO_WDT) += iTCO_wdt.o
50obj-$(CONFIG_SC1200_WDT) += sc1200wdt.o 51obj-$(CONFIG_SC1200_WDT) += sc1200wdt.o
51obj-$(CONFIG_SCx200_WDT) += scx200_wdt.o 52obj-$(CONFIG_SCx200_WDT) += scx200_wdt.o
52obj-$(CONFIG_60XX_WDT) += sbc60xxwdt.o 53obj-$(CONFIG_60XX_WDT) += sbc60xxwdt.o
diff --git a/drivers/char/watchdog/iTCO_wdt.c b/drivers/char/watchdog/iTCO_wdt.c
new file mode 100644
index 000000000000..8f89948832fc
--- /dev/null
+++ b/drivers/char/watchdog/iTCO_wdt.c
@@ -0,0 +1,735 @@
1/*
2 * intel TCO Watchdog Driver (Used in i82801 and i6300ESB chipsets)
3 *
4 * (c) Copyright 2006 Wim Van Sebroeck <wim@iguana.be>.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 *
11 * Neither Wim Van Sebroeck nor Iguana vzw. admit liability nor
12 * provide warranty for any of this software. This material is
13 * provided "AS-IS" and at no charge.
14 *
15 * The TCO watchdog is implemented in the following I/O controller hubs:
16 * (See the intel documentation on http://developer.intel.com.)
17 * 82801AA (ICH) : document number 290655-003, 290677-014,
18 * 82801AB (ICHO) : document number 290655-003, 290677-014,
19 * 82801BA (ICH2) : document number 290687-002, 298242-027,
20 * 82801BAM (ICH2-M) : document number 290687-002, 298242-027,
21 * 82801CA (ICH3-S) : document number 290733-003, 290739-013,
22 * 82801CAM (ICH3-M) : document number 290716-001, 290718-007,
23 * 82801DB (ICH4) : document number 290744-001, 290745-020,
24 * 82801DBM (ICH4-M) : document number 252337-001, 252663-005,
25 * 82801E (C-ICH) : document number 273599-001, 273645-002,
26 * 82801EB (ICH5) : document number 252516-001, 252517-003,
27 * 82801ER (ICH5R) : document number 252516-001, 252517-003,
28 * 82801FB (ICH6) : document number 301473-002, 301474-007,
29 * 82801FR (ICH6R) : document number 301473-002, 301474-007,
30 * 82801FBM (ICH6-M) : document number 301473-002, 301474-007,
31 * 82801FW (ICH6W) : document number 301473-001, 301474-007,
32 * 82801FRW (ICH6RW) : document number 301473-001, 301474-007,
33 * 82801GB (ICH7) : document number 307013-002, 307014-009,
34 * 82801GR (ICH7R) : document number 307013-002, 307014-009,
35 * 82801GDH (ICH7DH) : document number 307013-002, 307014-009,
36 * 82801GBM (ICH7-M) : document number 307013-002, 307014-009,
37 * 82801GHM (ICH7-M DH) : document number 307013-002, 307014-009,
38 * 6300ESB (6300ESB) : document number 300641-003
39 */
40
41/*
42 * Includes, defines, variables, module parameters, ...
43 */
44
45/* Module and version information */
46#define DRV_NAME "iTCO_wdt"
47#define DRV_VERSION "1.00"
48#define DRV_RELDATE "30-Jul-2006"
49#define PFX DRV_NAME ": "
50
51/* Includes */
52#include <linux/config.h> /* For CONFIG_WATCHDOG_NOWAYOUT/... */
53#include <linux/module.h> /* For module specific items */
54#include <linux/moduleparam.h> /* For new moduleparam's */
55#include <linux/types.h> /* For standard types (like size_t) */
56#include <linux/errno.h> /* For the -ENODEV/... values */
57#include <linux/kernel.h> /* For printk/panic/... */
58#include <linux/miscdevice.h> /* For MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR) */
59#include <linux/watchdog.h> /* For the watchdog specific items */
60#include <linux/init.h> /* For __init/__exit/... */
61#include <linux/fs.h> /* For file operations */
62#include <linux/platform_device.h> /* For platform_driver framework */
63#include <linux/pci.h> /* For pci functions */
64#include <linux/ioport.h> /* For io-port access */
65#include <linux/spinlock.h> /* For spin_lock/spin_unlock/... */
66
67#include <asm/uaccess.h> /* For copy_to_user/put_user/... */
68#include <asm/io.h> /* For inb/outb/... */
69
70/* TCO related info */
71enum iTCO_chipsets {
72 TCO_ICH = 0, /* ICH */
73 TCO_ICH0, /* ICH0 */
74 TCO_ICH2, /* ICH2 */
75 TCO_ICH2M, /* ICH2-M */
76 TCO_ICH3, /* ICH3-S */
77 TCO_ICH3M, /* ICH3-M */
78 TCO_ICH4, /* ICH4 */
79 TCO_ICH4M, /* ICH4-M */
80 TCO_CICH, /* C-ICH */
81 TCO_ICH5, /* ICH5 & ICH5R */
82 TCO_6300ESB, /* 6300ESB */
83 TCO_ICH6, /* ICH6 & ICH6R */
84 TCO_ICH6M, /* ICH6-M */
85 TCO_ICH6W, /* ICH6W & ICH6RW */
86 TCO_ICH7, /* ICH7 & ICH7R */
87 TCO_ICH7M, /* ICH7-M */
88 TCO_ICH7MDH, /* ICH7-M DH */
89};
90
91static struct {
92 char *name;
93 unsigned int iTCO_version;
94} iTCO_chipset_info[] __devinitdata = {
95 {"ICH", 1},
96 {"ICH0", 1},
97 {"ICH2", 1},
98 {"ICH2-M", 1},
99 {"ICH3-S", 1},
100 {"ICH3-M", 1},
101 {"ICH4", 1},
102 {"ICH4-M", 1},
103 {"C-ICH", 1},
104 {"ICH5 or ICH5R", 1},
105 {"6300ESB", 1},
106 {"ICH6 or ICH6R", 2},
107 {"ICH6-M", 2},
108 {"ICH6W or ICH6RW", 2},
109 {"ICH7 or ICH7R", 2},
110 {"ICH7-M", 2},
111 {"ICH7-M DH", 2},
112 {NULL,0}
113};
114
115/*
116 * This data only exists for exporting the supported PCI ids
117 * via MODULE_DEVICE_TABLE. We do not actually register a
118 * pci_driver, because the I/O Controller Hub has also other
119 * functions that probably will be registered by other drivers.
120 */
121static struct pci_device_id iTCO_wdt_pci_tbl[] = {
122 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AA_0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH },
123 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AB_0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH0 },
124 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH2 },
125 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_10, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH2M },
126 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH3 },
127 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_12, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH3M },
128 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH4 },
129 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_12, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH4M },
130 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801E_0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_CICH },
131 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH5 },
132 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_6300ESB },
133 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH6 },
134 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH6M },
135 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH6W },
136 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH7 },
137 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH7M },
138 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_31, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH7MDH },
139 { 0, }, /* End of list */
140};
141MODULE_DEVICE_TABLE (pci, iTCO_wdt_pci_tbl);
142
143/* Address definitions for the TCO */
144#define TCOBASE iTCO_wdt_private.ACPIBASE + 0x60 /* TCO base address */
145#define SMI_EN iTCO_wdt_private.ACPIBASE + 0x30 /* SMI Control and Enable Register */
146
147#define TCO_RLD TCOBASE + 0x00 /* TCO Timer Reload and Current Value */
148#define TCOv1_TMR TCOBASE + 0x01 /* TCOv1 Timer Initial Value */
149#define TCO_DAT_IN TCOBASE + 0x02 /* TCO Data In Register */
150#define TCO_DAT_OUT TCOBASE + 0x03 /* TCO Data Out Register */
151#define TCO1_STS TCOBASE + 0x04 /* TCO1 Status Register */
152#define TCO2_STS TCOBASE + 0x06 /* TCO2 Status Register */
153#define TCO1_CNT TCOBASE + 0x08 /* TCO1 Control Register */
154#define TCO2_CNT TCOBASE + 0x0a /* TCO2 Control Register */
155#define TCOv2_TMR TCOBASE + 0x12 /* TCOv2 Timer Initial Value */
156
157/* internal variables */
158static unsigned long is_active;
159static char expect_release;
160static struct { /* this is private data for the iTCO_wdt device */
161 unsigned int iTCO_version; /* TCO version/generation */
162 unsigned long ACPIBASE; /* The cards ACPIBASE address (TCOBASE = ACPIBASE+0x60) */
163 unsigned long __iomem *gcs; /* NO_REBOOT flag is Memory-Mapped GCS register bit 5 (TCO version 2) */
164 spinlock_t io_lock; /* the lock for io operations */
165 struct pci_dev *pdev; /* the PCI-device */
166} iTCO_wdt_private;
167
168static struct platform_device *iTCO_wdt_platform_device; /* the watchdog platform device */
169
170/* module parameters */
171#define WATCHDOG_HEARTBEAT 30 /* 30 sec default heartbeat */
172static int heartbeat = WATCHDOG_HEARTBEAT; /* in seconds */
173module_param(heartbeat, int, 0);
174MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (2<heartbeat<39 (TCO v1) or 613 (TCO v2), default=" __MODULE_STRING(WATCHDOG_HEARTBEAT) ")");
175
176static int nowayout = WATCHDOG_NOWAYOUT;
177module_param(nowayout, int, 0);
178MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)");
179
180/*
181 * Some TCO specific functions
182 */
183
184static inline unsigned int seconds_to_ticks(int seconds)
185{
186 /* the internal timer is stored as ticks which decrement
187 * every 0.6 seconds */
188 return (seconds * 10) / 6;
189}
190
191static void iTCO_wdt_set_NO_REBOOT_bit(void)
192{
193 u32 val32;
194
195 /* Set the NO_REBOOT bit: this disables reboots */
196 if (iTCO_wdt_private.iTCO_version == 2) {
197 val32 = readl(iTCO_wdt_private.gcs);
198 val32 |= 0x00000020;
199 writel(val32, iTCO_wdt_private.gcs);
200 } else if (iTCO_wdt_private.iTCO_version == 1) {
201 pci_read_config_dword(iTCO_wdt_private.pdev, 0xd4, &val32);
202 val32 |= 0x00000002;
203 pci_write_config_dword(iTCO_wdt_private.pdev, 0xd4, val32);
204 }
205}
206
207static int iTCO_wdt_unset_NO_REBOOT_bit(void)
208{
209 int ret = 0;
210 u32 val32;
211
212 /* Unset the NO_REBOOT bit: this enables reboots */
213 if (iTCO_wdt_private.iTCO_version == 2) {
214 val32 = readl(iTCO_wdt_private.gcs);
215 val32 &= 0xffffffdf;
216 writel(val32, iTCO_wdt_private.gcs);
217
218 val32 = readl(iTCO_wdt_private.gcs);
219 if (val32 & 0x00000020)
220 ret = -EIO;
221 } else if (iTCO_wdt_private.iTCO_version == 1) {
222 pci_read_config_dword(iTCO_wdt_private.pdev, 0xd4, &val32);
223 val32 &= 0xfffffffd;
224 pci_write_config_dword(iTCO_wdt_private.pdev, 0xd4, val32);
225
226 pci_read_config_dword(iTCO_wdt_private.pdev, 0xd4, &val32);
227 if (val32 & 0x00000002)
228 ret = -EIO;
229 }
230
231 return ret; /* returns: 0 = OK, -EIO = Error */
232}
233
234static int iTCO_wdt_start(void)
235{
236 unsigned int val;
237
238 spin_lock(&iTCO_wdt_private.io_lock);
239
240 /* disable chipset's NO_REBOOT bit */
241 if (iTCO_wdt_unset_NO_REBOOT_bit()) {
242 printk(KERN_ERR PFX "failed to reset NO_REBOOT flag, reboot disabled by hardware\n");
243 return -EIO;
244 }
245
246 /* Bit 11: TCO Timer Halt -> 0 = The TCO timer is enabled to count */
247 val = inw(TCO1_CNT);
248 val &= 0xf7ff;
249 outw(val, TCO1_CNT);
250 val = inw(TCO1_CNT);
251 spin_unlock(&iTCO_wdt_private.io_lock);
252
253 if (val & 0x0800)
254 return -1;
255 return 0;
256}
257
258static int iTCO_wdt_stop(void)
259{
260 unsigned int val;
261
262 spin_lock(&iTCO_wdt_private.io_lock);
263
264 /* Bit 11: TCO Timer Halt -> 1 = The TCO timer is disabled */
265 val = inw(TCO1_CNT);
266 val |= 0x0800;
267 outw(val, TCO1_CNT);
268 val = inw(TCO1_CNT);
269
270 /* Set the NO_REBOOT bit to prevent later reboots, just for sure */
271 iTCO_wdt_set_NO_REBOOT_bit();
272
273 spin_unlock(&iTCO_wdt_private.io_lock);
274
275 if ((val & 0x0800) == 0)
276 return -1;
277 return 0;
278}
279
280static int iTCO_wdt_keepalive(void)
281{
282 spin_lock(&iTCO_wdt_private.io_lock);
283
284 /* Reload the timer by writing to the TCO Timer Counter register */
285 if (iTCO_wdt_private.iTCO_version == 2) {
286 outw(0x01, TCO_RLD);
287 } else if (iTCO_wdt_private.iTCO_version == 1) {
288 outb(0x01, TCO_RLD);
289 }
290
291 spin_unlock(&iTCO_wdt_private.io_lock);
292 return 0;
293}
294
295static int iTCO_wdt_set_heartbeat(int t)
296{
297 unsigned int val16;
298 unsigned char val8;
299 unsigned int tmrval;
300
301 tmrval = seconds_to_ticks(t);
302 /* from the specs: */
303 /* "Values of 0h-3h are ignored and should not be attempted" */
304 if (tmrval < 0x04)
305 return -EINVAL;
306 if (((iTCO_wdt_private.iTCO_version == 2) && (tmrval > 0x3ff)) ||
307 ((iTCO_wdt_private.iTCO_version == 1) && (tmrval > 0x03f)))
308 return -EINVAL;
309
310 /* Write new heartbeat to watchdog */
311 if (iTCO_wdt_private.iTCO_version == 2) {
312 spin_lock(&iTCO_wdt_private.io_lock);
313 val16 = inw(TCOv2_TMR);
314 val16 &= 0xfc00;
315 val16 |= tmrval;
316 outw(val16, TCOv2_TMR);
317 val16 = inw(TCOv2_TMR);
318 spin_unlock(&iTCO_wdt_private.io_lock);
319
320 if ((val16 & 0x3ff) != tmrval)
321 return -EINVAL;
322 } else if (iTCO_wdt_private.iTCO_version == 1) {
323 spin_lock(&iTCO_wdt_private.io_lock);
324 val8 = inb(TCOv1_TMR);
325 val8 &= 0xc0;
326 val8 |= (tmrval & 0xff);
327 outb(val8, TCOv1_TMR);
328 val8 = inb(TCOv1_TMR);
329 spin_unlock(&iTCO_wdt_private.io_lock);
330
331 if ((val8 & 0x3f) != tmrval)
332 return -EINVAL;
333 }
334
335 heartbeat = t;
336 return 0;
337}
338
339static int iTCO_wdt_get_timeleft (int *time_left)
340{
341 unsigned int val16;
342 unsigned char val8;
343
344 /* read the TCO Timer */
345 if (iTCO_wdt_private.iTCO_version == 2) {
346 spin_lock(&iTCO_wdt_private.io_lock);
347 val16 = inw(TCO_RLD);
348 val16 &= 0x3ff;
349 spin_unlock(&iTCO_wdt_private.io_lock);
350
351 *time_left = (val16 * 6) / 10;
352 } else if (iTCO_wdt_private.iTCO_version == 1) {
353 spin_lock(&iTCO_wdt_private.io_lock);
354 val8 = inb(TCO_RLD);
355 val8 &= 0x3f;
356 spin_unlock(&iTCO_wdt_private.io_lock);
357
358 *time_left = (val8 * 6) / 10;
359 }
360 return 0;
361}
362
363/*
364 * /dev/watchdog handling
365 */
366
367static int iTCO_wdt_open (struct inode *inode, struct file *file)
368{
369 /* /dev/watchdog can only be opened once */
370 if (test_and_set_bit(0, &is_active))
371 return -EBUSY;
372
373 /*
374 * Reload and activate timer
375 */
376 iTCO_wdt_keepalive();
377 iTCO_wdt_start();
378 return nonseekable_open(inode, file);
379}
380
381static int iTCO_wdt_release (struct inode *inode, struct file *file)
382{
383 /*
384 * Shut off the timer.
385 */
386 if (expect_release == 42) {
387 iTCO_wdt_stop();
388 } else {
389 printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n");
390 iTCO_wdt_keepalive();
391 }
392 clear_bit(0, &is_active);
393 expect_release = 0;
394 return 0;
395}
396
397static ssize_t iTCO_wdt_write (struct file *file, const char __user *data,
398 size_t len, loff_t * ppos)
399{
400 /* See if we got the magic character 'V' and reload the timer */
401 if (len) {
402 if (!nowayout) {
403 size_t i;
404
405 /* note: just in case someone wrote the magic character
406 * five months ago... */
407 expect_release = 0;
408
409 /* scan to see whether or not we got the magic character */
410 for (i = 0; i != len; i++) {
411 char c;
412 if (get_user(c, data+i))
413 return -EFAULT;
414 if (c == 'V')
415 expect_release = 42;
416 }
417 }
418
419 /* someone wrote to us, we should reload the timer */
420 iTCO_wdt_keepalive();
421 }
422 return len;
423}
424
425static int iTCO_wdt_ioctl (struct inode *inode, struct file *file,
426 unsigned int cmd, unsigned long arg)
427{
428 int new_options, retval = -EINVAL;
429 int new_heartbeat;
430 int time_left;
431 void __user *argp = (void __user *)arg;
432 int __user *p = argp;
433 static struct watchdog_info ident = {
434 .options = WDIOF_SETTIMEOUT |
435 WDIOF_KEEPALIVEPING |
436 WDIOF_MAGICCLOSE,
437 .firmware_version = 0,
438 .identity = DRV_NAME,
439 };
440
441 switch (cmd) {
442 case WDIOC_GETSUPPORT:
443 return copy_to_user(argp, &ident,
444 sizeof (ident)) ? -EFAULT : 0;
445
446 case WDIOC_GETSTATUS:
447 case WDIOC_GETBOOTSTATUS:
448 return put_user(0, p);
449
450 case WDIOC_KEEPALIVE:
451 iTCO_wdt_keepalive();
452 return 0;
453
454 case WDIOC_SETOPTIONS:
455 {
456 if (get_user(new_options, p))
457 return -EFAULT;
458
459 if (new_options & WDIOS_DISABLECARD) {
460 iTCO_wdt_stop();
461 retval = 0;
462 }
463
464 if (new_options & WDIOS_ENABLECARD) {
465 iTCO_wdt_keepalive();
466 iTCO_wdt_start();
467 retval = 0;
468 }
469
470 return retval;
471 }
472
473 case WDIOC_SETTIMEOUT:
474 {
475 if (get_user(new_heartbeat, p))
476 return -EFAULT;
477
478 if (iTCO_wdt_set_heartbeat(new_heartbeat))
479 return -EINVAL;
480
481 iTCO_wdt_keepalive();
482 /* Fall */
483 }
484
485 case WDIOC_GETTIMEOUT:
486 return put_user(heartbeat, p);
487
488 case WDIOC_GETTIMELEFT:
489 {
490 if (iTCO_wdt_get_timeleft(&time_left))
491 return -EINVAL;
492
493 return put_user(time_left, p);
494 }
495
496 default:
497 return -ENOTTY;
498 }
499}
500
501/*
502 * Kernel Interfaces
503 */
504
505static struct file_operations iTCO_wdt_fops = {
506 .owner = THIS_MODULE,
507 .llseek = no_llseek,
508 .write = iTCO_wdt_write,
509 .ioctl = iTCO_wdt_ioctl,
510 .open = iTCO_wdt_open,
511 .release = iTCO_wdt_release,
512};
513
514static struct miscdevice iTCO_wdt_miscdev = {
515 .minor = WATCHDOG_MINOR,
516 .name = "watchdog",
517 .fops = &iTCO_wdt_fops,
518};
519
520/*
521 * Init & exit routines
522 */
523
524static int iTCO_wdt_init(struct pci_dev *pdev, const struct pci_device_id *ent, struct platform_device *dev)
525{
526 int ret;
527 u32 base_address;
528 unsigned long RCBA;
529 unsigned long val32;
530
531 /*
532 * Find the ACPI/PM base I/O address which is the base
533 * for the TCO registers (TCOBASE=ACPIBASE + 0x60)
534 * ACPIBASE is bits [15:7] from 0x40-0x43
535 */
536 pci_read_config_dword(pdev, 0x40, &base_address);
537 base_address &= 0x00007f80;
538 if (base_address == 0x00000000) {
539 /* Something's wrong here, ACPIBASE has to be set */
540 printk(KERN_ERR PFX "failed to get TCOBASE address\n");
541 pci_dev_put(pdev);
542 return -ENODEV;
543 }
544 iTCO_wdt_private.iTCO_version = iTCO_chipset_info[ent->driver_data].iTCO_version;
545 iTCO_wdt_private.ACPIBASE = base_address;
546 iTCO_wdt_private.pdev = pdev;
547
548 /* Get the Memory-Mapped GCS register, we need it for the NO_REBOOT flag (TCO v2) */
549 /* To get access to it you have to read RCBA from PCI Config space 0xf0
550 and use it as base. GCS = RCBA + ICH6_GCS(0x3410). */
551 if (iTCO_wdt_private.iTCO_version == 2) {
552 pci_read_config_dword(pdev, 0xf0, &base_address);
553 RCBA = base_address & 0xffffc000;
554 iTCO_wdt_private.gcs = ioremap((RCBA + 0x3410),4);
555 }
556
557 /* Check chipset's NO_REBOOT bit */
558 if (iTCO_wdt_unset_NO_REBOOT_bit()) {
559 printk(KERN_ERR PFX "failed to reset NO_REBOOT flag, reboot disabled by hardware\n");
560 ret = -ENODEV; /* Cannot reset NO_REBOOT bit */
561 goto out;
562 }
563
564 /* Set the NO_REBOOT bit to prevent later reboots, just for sure */
565 iTCO_wdt_set_NO_REBOOT_bit();
566
567 /* Set the TCO_EN bit in SMI_EN register */
568 if (!request_region(SMI_EN, 4, "iTCO_wdt")) {
569 printk(KERN_ERR PFX "I/O address 0x%04lx already in use\n",
570 SMI_EN );
571 ret = -EIO;
572 goto out;
573 }
574 val32 = inl(SMI_EN);
575 val32 &= 0xffffdfff; /* Turn off SMI clearing watchdog */
576 outl(val32, SMI_EN);
577 release_region(SMI_EN, 4);
578
579 /* The TCO I/O registers reside in a 32-byte range pointed to by the TCOBASE value */
580 if (!request_region (TCOBASE, 0x20, "iTCO_wdt")) {
581 printk (KERN_ERR PFX "I/O address 0x%04lx already in use\n",
582 TCOBASE);
583 ret = -EIO;
584 goto out;
585 }
586
587 printk(KERN_INFO PFX "Found a %s TCO device (Version=%d, TCOBASE=0x%04lx)\n",
588 iTCO_chipset_info[ent->driver_data].name,
589 iTCO_chipset_info[ent->driver_data].iTCO_version,
590 TCOBASE);
591
592 /* Clear out the (probably old) status */
593 outb(0, TCO1_STS);
594 outb(3, TCO2_STS);
595
596 /* Make sure the watchdog is not running */
597 iTCO_wdt_stop();
598
599 /* Check that the heartbeat value is within it's range ; if not reset to the default */
600 if (iTCO_wdt_set_heartbeat(heartbeat)) {
601 iTCO_wdt_set_heartbeat(WATCHDOG_HEARTBEAT);
602 printk(KERN_INFO PFX "heartbeat value must be 2<heartbeat<39 (TCO v1) or 613 (TCO v2), using %d\n",
603 heartbeat);
604 }
605
606 ret = misc_register(&iTCO_wdt_miscdev);
607 if (ret != 0) {
608 printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
609 WATCHDOG_MINOR, ret);
610 goto unreg_region;
611 }
612
613 printk (KERN_INFO PFX "initialized. heartbeat=%d sec (nowayout=%d)\n",
614 heartbeat, nowayout);
615
616 return 0;
617
618unreg_region:
619 release_region (TCOBASE, 0x20);
620out:
621 if (iTCO_wdt_private.iTCO_version == 2)
622 iounmap(iTCO_wdt_private.gcs);
623 pci_dev_put(iTCO_wdt_private.pdev);
624 iTCO_wdt_private.ACPIBASE = 0;
625 return ret;
626}
627
628static void iTCO_wdt_cleanup(void)
629{
630 /* Stop the timer before we leave */
631 if (!nowayout)
632 iTCO_wdt_stop();
633
634 /* Deregister */
635 misc_deregister(&iTCO_wdt_miscdev);
636 release_region(TCOBASE, 0x20);
637 if (iTCO_wdt_private.iTCO_version == 2)
638 iounmap(iTCO_wdt_private.gcs);
639 pci_dev_put(iTCO_wdt_private.pdev);
640 iTCO_wdt_private.ACPIBASE = 0;
641}
642
643static int iTCO_wdt_probe(struct platform_device *dev)
644{
645 int found = 0;
646 struct pci_dev *pdev = NULL;
647 const struct pci_device_id *ent;
648
649 spin_lock_init(&iTCO_wdt_private.io_lock);
650
651 for_each_pci_dev(pdev) {
652 ent = pci_match_id(iTCO_wdt_pci_tbl, pdev);
653 if (ent) {
654 if (!(iTCO_wdt_init(pdev, ent, dev))) {
655 found++;
656 break;
657 }
658 }
659 }
660
661 if (!found) {
662 printk(KERN_INFO PFX "No card detected\n");
663 return -ENODEV;
664 }
665
666 return 0;
667}
668
669static int iTCO_wdt_remove(struct platform_device *dev)
670{
671 if (iTCO_wdt_private.ACPIBASE)
672 iTCO_wdt_cleanup();
673
674 return 0;
675}
676
677static void iTCO_wdt_shutdown(struct platform_device *dev)
678{
679 iTCO_wdt_stop();
680}
681
682#define iTCO_wdt_suspend NULL
683#define iTCO_wdt_resume NULL
684
685static struct platform_driver iTCO_wdt_driver = {
686 .probe = iTCO_wdt_probe,
687 .remove = iTCO_wdt_remove,
688 .shutdown = iTCO_wdt_shutdown,
689 .suspend = iTCO_wdt_suspend,
690 .resume = iTCO_wdt_resume,
691 .driver = {
692 .owner = THIS_MODULE,
693 .name = DRV_NAME,
694 },
695};
696
697static int __init iTCO_wdt_init_module(void)
698{
699 int err;
700
701 printk(KERN_INFO PFX "Intel TCO WatchDog Timer Driver v%s (%s)\n",
702 DRV_VERSION, DRV_RELDATE);
703
704 err = platform_driver_register(&iTCO_wdt_driver);
705 if (err)
706 return err;
707
708 iTCO_wdt_platform_device = platform_device_register_simple(DRV_NAME, -1, NULL, 0);
709 if (IS_ERR(iTCO_wdt_platform_device)) {
710 err = PTR_ERR(iTCO_wdt_platform_device);
711 goto unreg_platform_driver;
712 }
713
714 return 0;
715
716unreg_platform_driver:
717 platform_driver_unregister(&iTCO_wdt_driver);
718 return err;
719}
720
721static void __exit iTCO_wdt_cleanup_module(void)
722{
723 platform_device_unregister(iTCO_wdt_platform_device);
724 platform_driver_unregister(&iTCO_wdt_driver);
725 printk(KERN_INFO PFX "Watchdog Module Unloaded.\n");
726}
727
728module_init(iTCO_wdt_init_module);
729module_exit(iTCO_wdt_cleanup_module);
730
731MODULE_AUTHOR("Wim Van Sebroeck <wim@iguana.be>");
732MODULE_DESCRIPTION("Intel TCO WatchDog Timer Driver");
733MODULE_VERSION(DRV_VERSION);
734MODULE_LICENSE("GPL");
735MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
diff --git a/drivers/char/watchdog/pnx4008_wdt.c b/drivers/char/watchdog/pnx4008_wdt.c
index e7f0450a939d..db2731ba88e3 100644
--- a/drivers/char/watchdog/pnx4008_wdt.c
+++ b/drivers/char/watchdog/pnx4008_wdt.c
@@ -184,7 +184,7 @@ static int
184pnx4008_wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, 184pnx4008_wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
185 unsigned long arg) 185 unsigned long arg)
186{ 186{
187 int ret = -ENOIOCTLCMD; 187 int ret = -ENOTTY;
188 int time; 188 int time;
189 189
190 switch (cmd) { 190 switch (cmd) {
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index abcabb295592..0c68d0f0d8e5 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -614,15 +614,6 @@ config BLK_DEV_PIIX
614 the kernel to change PIO, DMA and UDMA speeds and to configure 614 the kernel to change PIO, DMA and UDMA speeds and to configure
615 the chip to optimum performance. 615 the chip to optimum performance.
616 616
617config BLK_DEV_IT8172
618 bool "IT8172 IDE support"
619 depends on (MIPS_ITE8172 || MIPS_IVR)
620 help
621 Say Y here to support the on-board IDE controller on the Integrated
622 Technology Express, Inc. ITE8172 SBC. Vendor page at
623 <http://www.ite.com.tw/ia/brief_it8172bsp.htm>; picture of the
624 board at <http://www.mvista.com/partners/semiconductor/ite.html>.
625
626config BLK_DEV_IT821X 617config BLK_DEV_IT821X
627 tristate "IT821X IDE support" 618 tristate "IT821X IDE support"
628 help 619 help
diff --git a/drivers/ide/pci/Makefile b/drivers/ide/pci/Makefile
index 640a54b09b5a..fef08960aa4c 100644
--- a/drivers/ide/pci/Makefile
+++ b/drivers/ide/pci/Makefile
@@ -12,7 +12,6 @@ obj-$(CONFIG_BLK_DEV_CY82C693) += cy82c693.o
12obj-$(CONFIG_BLK_DEV_HPT34X) += hpt34x.o 12obj-$(CONFIG_BLK_DEV_HPT34X) += hpt34x.o
13obj-$(CONFIG_BLK_DEV_HPT366) += hpt366.o 13obj-$(CONFIG_BLK_DEV_HPT366) += hpt366.o
14#obj-$(CONFIG_BLK_DEV_HPT37X) += hpt37x.o 14#obj-$(CONFIG_BLK_DEV_HPT37X) += hpt37x.o
15obj-$(CONFIG_BLK_DEV_IT8172) += it8172.o
16obj-$(CONFIG_BLK_DEV_IT821X) += it821x.o 15obj-$(CONFIG_BLK_DEV_IT821X) += it821x.o
17obj-$(CONFIG_BLK_DEV_JMICRON) += jmicron.o 16obj-$(CONFIG_BLK_DEV_JMICRON) += jmicron.o
18obj-$(CONFIG_BLK_DEV_NS87415) += ns87415.o 17obj-$(CONFIG_BLK_DEV_NS87415) += ns87415.o
diff --git a/drivers/ide/pci/it8172.c b/drivers/ide/pci/it8172.c
deleted file mode 100644
index 0fc89fafad65..000000000000
--- a/drivers/ide/pci/it8172.c
+++ /dev/null
@@ -1,307 +0,0 @@
1/*
2 *
3 * BRIEF MODULE DESCRIPTION
4 * IT8172 IDE controller support
5 *
6 * Copyright 2000 MontaVista Software Inc.
7 * Author: MontaVista Software, Inc.
8 * stevel@mvista.com or source@mvista.com
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
16 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
18 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
21 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
22 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 * You should have received a copy of the GNU General Public License along
27 * with this program; if not, write to the Free Software Foundation, Inc.,
28 * 675 Mass Ave, Cambridge, MA 02139, USA.
29 */
30
31#include <linux/module.h>
32#include <linux/types.h>
33#include <linux/kernel.h>
34#include <linux/ioport.h>
35#include <linux/pci.h>
36#include <linux/hdreg.h>
37#include <linux/ide.h>
38#include <linux/delay.h>
39#include <linux/init.h>
40
41#include <asm/io.h>
42#include <asm/it8172/it8172_int.h>
43
44/*
45 * Prototypes
46 */
47static u8 it8172_ratemask (ide_drive_t *drive)
48{
49 return 1;
50}
51
52static void it8172_tune_drive (ide_drive_t *drive, u8 pio)
53{
54 ide_hwif_t *hwif = HWIF(drive);
55 struct pci_dev *dev = hwif->pci_dev;
56 int is_slave = (&hwif->drives[1] == drive);
57 unsigned long flags;
58 u16 drive_enables;
59 u32 drive_timing;
60
61 pio = ide_get_best_pio_mode(drive, pio, 4, NULL);
62 spin_lock_irqsave(&ide_lock, flags);
63 pci_read_config_word(dev, 0x40, &drive_enables);
64 pci_read_config_dword(dev, 0x44, &drive_timing);
65
66 /*
67 * FIX! The DIOR/DIOW pulse width and recovery times in port 0x44
68 * are being left at the default values of 8 PCI clocks (242 nsec
69 * for a 33 MHz clock). These can be safely shortened at higher
70 * PIO modes. The DIOR/DIOW pulse width and recovery times only
71 * apply to PIO modes, not to the DMA modes.
72 */
73
74 /*
75 * Enable port 0x44. The IT8172G spec is confused; it calls
76 * this register the "Slave IDE Timing Register", but in fact,
77 * it controls timing for both master and slave drives.
78 */
79 drive_enables |= 0x4000;
80
81 if (is_slave) {
82 drive_enables &= 0xc006;
83 if (pio > 1)
84 /* enable prefetch and IORDY sample-point */
85 drive_enables |= 0x0060;
86 } else {
87 drive_enables &= 0xc060;
88 if (pio > 1)
89 /* enable prefetch and IORDY sample-point */
90 drive_enables |= 0x0006;
91 }
92
93 pci_write_config_word(dev, 0x40, drive_enables);
94 spin_unlock_irqrestore(&ide_lock, flags);
95}
96
97static u8 it8172_dma_2_pio (u8 xfer_rate)
98{
99 switch(xfer_rate) {
100 case XFER_UDMA_5:
101 case XFER_UDMA_4:
102 case XFER_UDMA_3:
103 case XFER_UDMA_2:
104 case XFER_UDMA_1:
105 case XFER_UDMA_0:
106 case XFER_MW_DMA_2:
107 case XFER_PIO_4:
108 return 4;
109 case XFER_MW_DMA_1:
110 case XFER_PIO_3:
111 return 3;
112 case XFER_SW_DMA_2:
113 case XFER_PIO_2:
114 return 2;
115 case XFER_MW_DMA_0:
116 case XFER_SW_DMA_1:
117 case XFER_SW_DMA_0:
118 case XFER_PIO_1:
119 case XFER_PIO_0:
120 case XFER_PIO_SLOW:
121 default:
122 return 0;
123 }
124}
125
126static int it8172_tune_chipset (ide_drive_t *drive, u8 xferspeed)
127{
128 ide_hwif_t *hwif = HWIF(drive);
129 struct pci_dev *dev = hwif->pci_dev;
130 u8 speed = ide_rate_filter(it8172_ratemask(drive), xferspeed);
131 int a_speed = 3 << (drive->dn * 4);
132 int u_flag = 1 << drive->dn;
133 int u_speed = 0;
134 u8 reg48, reg4a;
135
136 pci_read_config_byte(dev, 0x48, &reg48);
137 pci_read_config_byte(dev, 0x4a, &reg4a);
138
139 /*
140 * Setting the DMA cycle time to 2 or 3 PCI clocks (60 and 91 nsec
141 * at 33 MHz PCI clock) seems to cause BadCRC errors during DMA
142 * transfers on some drives, even though both numbers meet the minimum
143 * ATAPI-4 spec of 73 and 54 nsec for UDMA 1 and 2 respectively.
144 * So the faster times are just commented out here. The good news is
145 * that the slower cycle time has very little affect on transfer
146 * performance.
147 */
148
149 switch(speed) {
150 case XFER_UDMA_4:
151 case XFER_UDMA_2: //u_speed = 2 << (drive->dn * 4); break;
152 case XFER_UDMA_5:
153 case XFER_UDMA_3:
154 case XFER_UDMA_1: //u_speed = 1 << (drive->dn * 4); break;
155 case XFER_UDMA_0: u_speed = 0 << (drive->dn * 4); break;
156 case XFER_MW_DMA_2:
157 case XFER_MW_DMA_1:
158 case XFER_MW_DMA_0:
159 case XFER_SW_DMA_2: break;
160 case XFER_PIO_4:
161 case XFER_PIO_3:
162 case XFER_PIO_2:
163 case XFER_PIO_0: break;
164 default: return -1;
165 }
166
167 if (speed >= XFER_UDMA_0) {
168 pci_write_config_byte(dev, 0x48, reg48 | u_flag);
169 reg4a &= ~a_speed;
170 pci_write_config_byte(dev, 0x4a, reg4a | u_speed);
171 } else {
172 pci_write_config_byte(dev, 0x48, reg48 & ~u_flag);
173 pci_write_config_byte(dev, 0x4a, reg4a & ~a_speed);
174 }
175
176 it8172_tune_drive(drive, it8172_dma_2_pio(speed));
177 return (ide_config_drive_speed(drive, speed));
178}
179
180static int it8172_config_chipset_for_dma (ide_drive_t *drive)
181{
182 u8 speed = ide_dma_speed(drive, it8172_ratemask(drive));
183
184 if (!(speed)) {
185 u8 tspeed = ide_get_best_pio_mode(drive, 255, 4, NULL);
186 speed = it8172_dma_2_pio(XFER_PIO_0 + tspeed);
187 }
188
189 (void) it8172_tune_chipset(drive, speed);
190 return ide_dma_enable(drive);
191}
192
193static int it8172_config_drive_xfer_rate (ide_drive_t *drive)
194{
195 ide_hwif_t *hwif = HWIF(drive);
196 struct hd_driveid *id = drive->id;
197
198 drive->init_speed = 0;
199
200 if (id && (id->capability & 1) && drive->autodma) {
201
202 if (ide_use_dma(drive)) {
203 if (it8172_config_chipset_for_dma(drive))
204 return hwif->ide_dma_on(drive);
205 }
206
207 goto fast_ata_pio;
208
209 } else if ((id->capability & 8) || (id->field_valid & 2)) {
210fast_ata_pio:
211 it8172_tune_drive(drive, 5);
212 return hwif->ide_dma_off_quietly(drive);
213 }
214 /* IORDY not supported */
215 return 0;
216}
217
218static unsigned int __devinit init_chipset_it8172 (struct pci_dev *dev, const char *name)
219{
220 unsigned char progif;
221
222 /*
223 * Place both IDE interfaces into PCI "native" mode
224 */
225 pci_read_config_byte(dev, PCI_CLASS_PROG, &progif);
226 pci_write_config_byte(dev, PCI_CLASS_PROG, progif | 0x05);
227
228 return IT8172_IDE_IRQ;
229}
230
231
232static void __devinit init_hwif_it8172 (ide_hwif_t *hwif)
233{
234 struct pci_dev* dev = hwif->pci_dev;
235 unsigned long cmdBase, ctrlBase;
236
237 hwif->autodma = 0;
238 hwif->tuneproc = &it8172_tune_drive;
239 hwif->speedproc = &it8172_tune_chipset;
240
241 cmdBase = dev->resource[0].start;
242 ctrlBase = dev->resource[1].start;
243
244 ide_init_hwif_ports(&hwif->hw, cmdBase, ctrlBase | 2, NULL);
245 memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->io_ports));
246 hwif->noprobe = 0;
247
248 if (!hwif->dma_base) {
249 hwif->drives[0].autotune = 1;
250 hwif->drives[1].autotune = 1;
251 return;
252 }
253
254 hwif->atapi_dma = 1;
255 hwif->ultra_mask = 0x07;
256 hwif->mwdma_mask = 0x06;
257 hwif->swdma_mask = 0x04;
258
259 hwif->ide_dma_check = &it8172_config_drive_xfer_rate;
260 if (!noautodma)
261 hwif->autodma = 1;
262 hwif->drives[0].autodma = hwif->autodma;
263 hwif->drives[1].autodma = hwif->autodma;
264}
265
266static ide_pci_device_t it8172_chipsets[] __devinitdata = {
267 { /* 0 */
268 .name = "IT8172G",
269 .init_chipset = init_chipset_it8172,
270 .init_hwif = init_hwif_it8172,
271 .channels = 2,
272 .autodma = AUTODMA,
273 .enablebits = {{0x00,0x00,0x00}, {0x40,0x00,0x01}},
274 .bootable = ON_BOARD,
275 }
276};
277
278static int __devinit it8172_init_one(struct pci_dev *dev, const struct pci_device_id *id)
279{
280 if ((!(PCI_FUNC(dev->devfn) & 1) ||
281 (!((dev->class >> 8) == PCI_CLASS_STORAGE_IDE))))
282 return -ENODEV; /* IT8172 is more than an IDE controller */
283 return ide_setup_pci_device(dev, &it8172_chipsets[id->driver_data]);
284}
285
286static struct pci_device_id it8172_pci_tbl[] = {
287 { PCI_VENDOR_ID_ITE, PCI_DEVICE_ID_ITE_IT8172G, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
288 { 0, },
289};
290MODULE_DEVICE_TABLE(pci, it8172_pci_tbl);
291
292static struct pci_driver driver = {
293 .name = "IT8172_IDE",
294 .id_table = it8172_pci_tbl,
295 .probe = it8172_init_one,
296};
297
298static int it8172_ide_init(void)
299{
300 return ide_pci_register_driver(&driver);
301}
302
303module_init(it8172_ide_init);
304
305MODULE_AUTHOR("SteveL@mvista.com");
306MODULE_DESCRIPTION("PCI driver module for ITE 8172 IDE");
307MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
index 3dd5dbafb330..53304e6991ac 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -1014,6 +1014,13 @@ static int dvb_frontend_open(struct inode *inode, struct file *file)
1014 if ((ret = dvb_generic_open (inode, file)) < 0) 1014 if ((ret = dvb_generic_open (inode, file)) < 0)
1015 return ret; 1015 return ret;
1016 1016
1017 if (fe->ops.ts_bus_ctrl) {
1018 if ((ret = fe->ops.ts_bus_ctrl (fe, 1)) < 0) {
1019 dvb_generic_release (inode, file);
1020 return ret;
1021 }
1022 }
1023
1017 if ((file->f_flags & O_ACCMODE) != O_RDONLY) { 1024 if ((file->f_flags & O_ACCMODE) != O_RDONLY) {
1018 1025
1019 /* normal tune mode when opened R/W */ 1026 /* normal tune mode when opened R/W */
@@ -1043,6 +1050,9 @@ static int dvb_frontend_release(struct inode *inode, struct file *file)
1043 if ((file->f_flags & O_ACCMODE) != O_RDONLY) 1050 if ((file->f_flags & O_ACCMODE) != O_RDONLY)
1044 fepriv->release_jiffies = jiffies; 1051 fepriv->release_jiffies = jiffies;
1045 1052
1053 if (fe->ops.ts_bus_ctrl)
1054 fe->ops.ts_bus_ctrl (fe, 0);
1055
1046 return dvb_generic_release (inode, file); 1056 return dvb_generic_release (inode, file);
1047} 1057}
1048 1058
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.h b/drivers/media/dvb/dvb-core/dvb_frontend.h
index e5d5028b3694..f233d78bc364 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.h
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.h
@@ -129,6 +129,7 @@ struct dvb_frontend_ops {
129 int (*enable_high_lnb_voltage)(struct dvb_frontend* fe, long arg); 129 int (*enable_high_lnb_voltage)(struct dvb_frontend* fe, long arg);
130 int (*dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned long cmd); 130 int (*dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned long cmd);
131 int (*i2c_gate_ctrl)(struct dvb_frontend* fe, int enable); 131 int (*i2c_gate_ctrl)(struct dvb_frontend* fe, int enable);
132 int (*ts_bus_ctrl)(struct dvb_frontend* fe, int acquire);
132 133
133 struct dvb_tuner_ops tuner_ops; 134 struct dvb_tuner_ops tuner_ops;
134}; 135};
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig
index 0a3c35399bea..67cefdd2334a 100644
--- a/drivers/media/dvb/dvb-usb/Kconfig
+++ b/drivers/media/dvb/dvb-usb/Kconfig
@@ -39,20 +39,8 @@ config DVB_USB_DIBUSB_MB
39 Support for USB 1.1 and 2.0 DVB-T receivers based on reference designs made by 39 Support for USB 1.1 and 2.0 DVB-T receivers based on reference designs made by
40 DiBcom (<http://www.dibcom.fr>) equipped with a DiB3000M-B demodulator. 40 DiBcom (<http://www.dibcom.fr>) equipped with a DiB3000M-B demodulator.
41 41
42 Devices supported by this driver: 42 For an up-to-date list of devices supported by this driver, have a look
43 Artec T1 USB1.1 boxes 43 on the Linux-DVB Wiki at www.linuxtv.org.
44 Avermedia AverTV DVBT USB1.1
45 Compro Videomate DVB-U2000 - DVB-T USB
46 DiBcom USB1.1 reference devices (non-public)
47 Grandtec DVB-T USB
48 Hama DVB-T USB1.1-Box
49 KWorld/JetWay/ADSTech V-Stream XPERT DTV - DVB-T USB1.1 and USB2.0
50 TwinhanDTV Magic Box (VP7041e)
51 TwinhanDTV USB-Ter (VP7041)
52 Ultima Electronic/Artec T1 USB TVBOX
53
54 The VP7041 seems to be identical to "CTS Portable" (Chinese
55 Television System).
56 44
57 Say Y if you own such a device and want to use it. You should build it as 45 Say Y if you own such a device and want to use it. You should build it as
58 a module. 46 a module.
@@ -69,12 +57,29 @@ config DVB_USB_DIBUSB_MC
69 select DVB_DIB3000MC 57 select DVB_DIB3000MC
70 select DVB_TUNER_MT2060 58 select DVB_TUNER_MT2060
71 help 59 help
72 Support for 2.0 DVB-T receivers based on reference designs made by 60 Support for USB2.0 DVB-T receivers based on reference designs made by
73 DiBcom (<http://www.dibcom.fr>) equipped with a DiB3000M-C/P demodulator. 61 DiBcom (<http://www.dibcom.fr>) equipped with a DiB3000M-C/P demodulator.
74 62
75 Devices supported by this driver: 63 For an up-to-date list of devices supported by this driver, have a look
76 Artec T1 USB2.0 boxes 64 on the Linux-DVB Wiki at www.linuxtv.org.
77 DiBcom USB2.0 reference devices (non-public) 65
66 Say Y if you own such a device and want to use it. You should build it as
67 a module.
68
69config DVB_USB_DIB0700
70 tristate "DiBcom DiB0700 USB DVB devices (see help for supported devices)"
71 depends on DVB_USB
72 select DVB_DIB7000M
73 select DVB_DIB3000MC
74 select DVB_TUNER_MT2060
75 help
76 Support for USB2.0/1.1 DVB receivers based on the DiB0700 USB bridge. The
77 USB bridge is also present in devices having the DiB7700 DVB-T-USB
78 silicon. This chip can be found in devices offered by Hauppauge,
79 Avermedia and other big and small companies.
80
81 For an up-to-date list of devices supported by this driver, have a look
82 on the Linux-DVB Wiki at www.linuxtv.org.
78 83
79 Say Y if you own such a device and want to use it. You should build it as 84 Say Y if you own such a device and want to use it. You should build it as
80 a module. 85 a module.
diff --git a/drivers/media/dvb/dvb-usb/Makefile b/drivers/media/dvb/dvb-usb/Makefile
index 9643f56c7fe9..e239107998e5 100644
--- a/drivers/media/dvb/dvb-usb/Makefile
+++ b/drivers/media/dvb/dvb-usb/Makefile
@@ -1,4 +1,4 @@
1dvb-usb-objs = dvb-usb-firmware.o dvb-usb-init.o dvb-usb-urb.o dvb-usb-i2c.o dvb-usb-dvb.o dvb-usb-remote.o 1dvb-usb-objs = dvb-usb-firmware.o dvb-usb-init.o dvb-usb-urb.o dvb-usb-i2c.o dvb-usb-dvb.o dvb-usb-remote.o usb-urb.o
2obj-$(CONFIG_DVB_USB) += dvb-usb.o 2obj-$(CONFIG_DVB_USB) += dvb-usb.o
3 3
4dvb-usb-vp7045-objs = vp7045.o vp7045-fe.o 4dvb-usb-vp7045-objs = vp7045.o vp7045-fe.o
@@ -36,4 +36,7 @@ obj-$(CONFIG_DVB_USB_DIGITV) += dvb-usb-digitv.o
36dvb-usb-cxusb-objs = cxusb.o 36dvb-usb-cxusb-objs = cxusb.o
37obj-$(CONFIG_DVB_USB_CXUSB) += dvb-usb-cxusb.o 37obj-$(CONFIG_DVB_USB_CXUSB) += dvb-usb-cxusb.o
38 38
39dvb-usb-dib0700-objs = dib0700_core.o dib0700_devices.o
40obj-$(CONFIG_DVB_USB_DIB0700) += dvb-usb-dib0700.o
41
39EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/ 42EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/
diff --git a/drivers/media/dvb/dvb-usb/a800.c b/drivers/media/dvb/dvb-usb/a800.c
index df0c384bd4ca..2ed3eb62d787 100644
--- a/drivers/media/dvb/dvb-usb/a800.c
+++ b/drivers/media/dvb/dvb-usb/a800.c
@@ -27,7 +27,8 @@ static int a800_power_ctrl(struct dvb_usb_device *d, int onoff)
27} 27}
28 28
29/* assure to put cold to 0 for iManufacturer == 1 */ 29/* assure to put cold to 0 for iManufacturer == 1 */
30static int a800_identify_state(struct usb_device *udev, struct dvb_usb_properties *props,struct dvb_usb_device_description **desc, int *cold) 30static int a800_identify_state(struct usb_device *udev, struct dvb_usb_device_properties *props,
31 struct dvb_usb_device_description **desc, int *cold)
31{ 32{
32 *cold = udev->descriptor.iManufacturer != 1; 33 *cold = udev->descriptor.iManufacturer != 1;
33 return 0; 34 return 0;
@@ -88,7 +89,7 @@ static int a800_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
88} 89}
89 90
90/* USB Driver stuff */ 91/* USB Driver stuff */
91static struct dvb_usb_properties a800_properties; 92static struct dvb_usb_device_properties a800_properties;
92 93
93static int a800_probe(struct usb_interface *intf, 94static int a800_probe(struct usb_interface *intf,
94 const struct usb_device_id *id) 95 const struct usb_device_id *id)
@@ -104,35 +105,27 @@ static struct usb_device_id a800_table [] = {
104}; 105};
105MODULE_DEVICE_TABLE (usb, a800_table); 106MODULE_DEVICE_TABLE (usb, a800_table);
106 107
107static struct dvb_usb_properties a800_properties = { 108static struct dvb_usb_device_properties a800_properties = {
108 .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF | DVB_USB_IS_AN_I2C_ADAPTER, 109 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
109 .pid_filter_count = 32,
110 110
111 .usb_ctrl = CYPRESS_FX2, 111 .usb_ctrl = CYPRESS_FX2,
112
113 .firmware = "dvb-usb-avertv-a800-02.fw", 112 .firmware = "dvb-usb-avertv-a800-02.fw",
114 113
115 .size_of_priv = sizeof(struct dibusb_state), 114 .num_adapters = 1,
116 115 .adapter = {
116 {
117 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
118 .pid_filter_count = 32,
117 .streaming_ctrl = dibusb2_0_streaming_ctrl, 119 .streaming_ctrl = dibusb2_0_streaming_ctrl,
118 .pid_filter = dibusb_pid_filter, 120 .pid_filter = dibusb_pid_filter,
119 .pid_filter_ctrl = dibusb_pid_filter_ctrl, 121 .pid_filter_ctrl = dibusb_pid_filter_ctrl,
120 .power_ctrl = a800_power_ctrl, 122
121 .frontend_attach = dibusb_dib3000mc_frontend_attach, 123 .frontend_attach = dibusb_dib3000mc_frontend_attach,
122 .tuner_attach = dibusb_dib3000mc_tuner_attach, 124 .tuner_attach = dibusb_dib3000mc_tuner_attach,
123 .identify_state = a800_identify_state,
124
125 .rc_interval = DEFAULT_RC_INTERVAL,
126 .rc_key_map = a800_rc_keys,
127 .rc_key_map_size = ARRAY_SIZE(a800_rc_keys),
128 .rc_query = a800_rc_query,
129 125
130 .i2c_algo = &dibusb_i2c_algo,
131
132 .generic_bulk_ctrl_endpoint = 0x01,
133 /* parameter for the MPEG2-data transfer */ 126 /* parameter for the MPEG2-data transfer */
134 .urb = { 127 .stream = {
135 .type = DVB_USB_BULK, 128 .type = USB_BULK,
136 .count = 7, 129 .count = 7,
137 .endpoint = 0x06, 130 .endpoint = 0x06,
138 .u = { 131 .u = {
@@ -142,6 +135,21 @@ static struct dvb_usb_properties a800_properties = {
142 } 135 }
143 }, 136 },
144 137
138 .size_of_priv = sizeof(struct dibusb_state),
139 },
140 },
141
142 .power_ctrl = a800_power_ctrl,
143 .identify_state = a800_identify_state,
144
145 .rc_interval = DEFAULT_RC_INTERVAL,
146 .rc_key_map = a800_rc_keys,
147 .rc_key_map_size = ARRAY_SIZE(a800_rc_keys),
148 .rc_query = a800_rc_query,
149
150 .i2c_algo = &dibusb_i2c_algo,
151
152 .generic_bulk_ctrl_endpoint = 0x01,
145 .num_device_descs = 1, 153 .num_device_descs = 1,
146 .devices = { 154 .devices = {
147 { "AVerMedia AverTV DVB-T USB 2.0 (A800)", 155 { "AVerMedia AverTV DVB-T USB 2.0 (A800)",
diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c
index c710c0176e07..43f39069ef34 100644
--- a/drivers/media/dvb/dvb-usb/cxusb.c
+++ b/drivers/media/dvb/dvb-usb/cxusb.c
@@ -161,13 +161,13 @@ static int cxusb_bluebird_power_ctrl(struct dvb_usb_device *d, int onoff)
161 return 0; 161 return 0;
162} 162}
163 163
164static int cxusb_streaming_ctrl(struct dvb_usb_device *d, int onoff) 164static int cxusb_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
165{ 165{
166 u8 buf[2] = { 0x03, 0x00 }; 166 u8 buf[2] = { 0x03, 0x00 };
167 if (onoff) 167 if (onoff)
168 cxusb_ctrl_msg(d,CMD_STREAMING_ON, buf, 2, NULL, 0); 168 cxusb_ctrl_msg(adap->dev, CMD_STREAMING_ON, buf, 2, NULL, 0);
169 else 169 else
170 cxusb_ctrl_msg(d,CMD_STREAMING_OFF, NULL, 0, NULL, 0); 170 cxusb_ctrl_msg(adap->dev, CMD_STREAMING_OFF, NULL, 0, NULL, 0);
171 171
172 return 0; 172 return 0;
173} 173}
@@ -327,8 +327,8 @@ static int cxusb_mt352_demod_init(struct dvb_frontend* fe)
327static int cxusb_lgh064f_tuner_set_params(struct dvb_frontend *fe, 327static int cxusb_lgh064f_tuner_set_params(struct dvb_frontend *fe,
328 struct dvb_frontend_parameters *fep) 328 struct dvb_frontend_parameters *fep)
329{ 329{
330 struct dvb_usb_device *d = fe->dvb->priv; 330 struct dvb_usb_adapter *adap = fe->dvb->priv;
331 return lg_h06xf_pll_set(fe, &d->i2c_adap, fep); 331 return lg_h06xf_pll_set(fe, &adap->dev->i2c_adap, fep);
332} 332}
333 333
334static struct cx22702_config cxusb_cx22702_config = { 334static struct cx22702_config cxusb_cx22702_config = {
@@ -359,98 +359,99 @@ static struct mt352_config cxusb_mt352_config = {
359}; 359};
360 360
361/* Callbacks for DVB USB */ 361/* Callbacks for DVB USB */
362static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_device *d) 362static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_adapter *adap)
363{ 363{
364 u8 bpll[4] = { 0x0b, 0xdc, 0x9c, 0xa0 }; 364 u8 bpll[4] = { 0x0b, 0xdc, 0x9c, 0xa0 };
365 d->pll_addr = 0x61; 365 adap->pll_addr = 0x61;
366 memcpy(d->pll_init, bpll, 4); 366 memcpy(adap->pll_init, bpll, 4);
367 d->pll_desc = &dvb_pll_fmd1216me; 367 adap->pll_desc = &dvb_pll_fmd1216me;
368 368
369 d->fe->ops.tuner_ops.init = dvb_usb_tuner_init_i2c; 369 adap->fe->ops.tuner_ops.init = dvb_usb_tuner_init_i2c;
370 d->fe->ops.tuner_ops.set_params = dvb_usb_tuner_set_params_i2c; 370 adap->fe->ops.tuner_ops.set_params = dvb_usb_tuner_set_params_i2c;
371 371
372 return 0; 372 return 0;
373} 373}
374 374
375static int cxusb_dee1601_tuner_attach(struct dvb_usb_device *d) 375static int cxusb_dee1601_tuner_attach(struct dvb_usb_adapter *adap)
376{ 376{
377 d->pll_addr = 0x61; 377 adap->pll_addr = 0x61;
378 d->pll_desc = &dvb_pll_thomson_dtt7579; 378 adap->pll_desc = &dvb_pll_thomson_dtt7579;
379 d->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs; 379 adap->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs;
380 return 0; 380 return 0;
381} 381}
382 382
383static int cxusb_lgz201_tuner_attach(struct dvb_usb_device *d) 383static int cxusb_lgz201_tuner_attach(struct dvb_usb_adapter *adap)
384{ 384{
385 d->pll_addr = 0x61; 385 adap->pll_addr = 0x61;
386 d->pll_desc = &dvb_pll_lg_z201; 386 adap->pll_desc = &dvb_pll_lg_z201;
387 d->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs; 387 adap->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs;
388 return 0; 388 return 0;
389} 389}
390 390
391static int cxusb_dtt7579_tuner_attach(struct dvb_usb_device *d) 391static int cxusb_dtt7579_tuner_attach(struct dvb_usb_adapter *adap)
392{ 392{
393 d->pll_addr = 0x60; 393 adap->pll_addr = 0x60;
394 d->pll_desc = &dvb_pll_thomson_dtt7579; 394 adap->pll_desc = &dvb_pll_thomson_dtt7579;
395 d->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs; 395 adap->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs;
396 return 0; 396 return 0;
397} 397}
398 398
399static int cxusb_lgdt3303_tuner_attach(struct dvb_usb_device *d) 399static int cxusb_lgdt3303_tuner_attach(struct dvb_usb_adapter *adap)
400{ 400{
401 d->fe->ops.tuner_ops.set_params = cxusb_lgh064f_tuner_set_params; 401 adap->fe->ops.tuner_ops.set_params = cxusb_lgh064f_tuner_set_params;
402 return 0; 402 return 0;
403} 403}
404 404
405static int cxusb_cx22702_frontend_attach(struct dvb_usb_device *d) 405static int cxusb_cx22702_frontend_attach(struct dvb_usb_adapter *adap)
406{ 406{
407 u8 b; 407 u8 b;
408 if (usb_set_interface(d->udev,0,6) < 0) 408 if (usb_set_interface(adap->dev->udev, 0, 6) < 0)
409 err("set interface failed"); 409 err("set interface failed");
410 410
411 cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, &b, 1); 411 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, &b, 1);
412 412
413 if ((d->fe = dvb_attach(cx22702_attach, &cxusb_cx22702_config, &d->i2c_adap)) != NULL) 413 if ((adap->fe = dvb_attach(cx22702_attach, &cxusb_cx22702_config, &adap->dev->i2c_adap)) != NULL)
414 return 0; 414 return 0;
415 415
416 return -EIO; 416 return -EIO;
417} 417}
418 418
419static int cxusb_lgdt3303_frontend_attach(struct dvb_usb_device *d) 419static int cxusb_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap)
420{ 420{
421 if (usb_set_interface(d->udev,0,7) < 0) 421 if (usb_set_interface(adap->dev->udev, 0, 7) < 0)
422 err("set interface failed"); 422 err("set interface failed");
423 423
424 cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, NULL, 0); 424 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
425 425
426 if ((d->fe = dvb_attach(lgdt330x_attach, &cxusb_lgdt3303_config, &d->i2c_adap)) != NULL) 426 if ((adap->fe = dvb_attach(lgdt330x_attach, &cxusb_lgdt3303_config, &adap->dev->i2c_adap)) != NULL)
427 return 0; 427 return 0;
428 428
429 return -EIO; 429 return -EIO;
430} 430}
431 431
432static int cxusb_mt352_frontend_attach(struct dvb_usb_device *d) 432static int cxusb_mt352_frontend_attach(struct dvb_usb_adapter *adap)
433{ /* used in both lgz201 and th7579 */ 433{
434 if (usb_set_interface(d->udev,0,0) < 0) 434 /* used in both lgz201 and th7579 */
435 if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
435 err("set interface failed"); 436 err("set interface failed");
436 437
437 cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, NULL, 0); 438 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
438 439
439 if ((d->fe = dvb_attach(mt352_attach, &cxusb_mt352_config, &d->i2c_adap)) != NULL) 440 if ((adap->fe = dvb_attach(mt352_attach, &cxusb_mt352_config, &adap->dev->i2c_adap)) != NULL)
440 return 0; 441 return 0;
441 442
442 return -EIO; 443 return -EIO;
443} 444}
444 445
445static int cxusb_dee1601_frontend_attach(struct dvb_usb_device *d) 446static int cxusb_dee1601_frontend_attach(struct dvb_usb_adapter *adap)
446{ 447{
447 if (usb_set_interface(d->udev,0,0) < 0) 448 if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
448 err("set interface failed"); 449 err("set interface failed");
449 450
450 cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, NULL, 0); 451 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
451 452
452 if (((d->fe = dvb_attach(mt352_attach, &cxusb_dee1601_config, &d->i2c_adap)) != NULL) || 453 if (((adap->fe = dvb_attach(mt352_attach, &cxusb_dee1601_config, &adap->dev->i2c_adap)) != NULL) ||
453 ((d->fe = dvb_attach(zl10353_attach, &cxusb_zl10353_dee1601_config, &d->i2c_adap)) != NULL)) 454 ((adap->fe = dvb_attach(zl10353_attach, &cxusb_zl10353_dee1601_config, &adap->dev->i2c_adap)) != NULL))
454 return 0; 455 return 0;
455 456
456 return -EIO; 457 return -EIO;
@@ -480,11 +481,11 @@ static int bluebird_patch_dvico_firmware_download(struct usb_device *udev, const
480} 481}
481 482
482/* DVB USB Driver stuff */ 483/* DVB USB Driver stuff */
483static struct dvb_usb_properties cxusb_medion_properties; 484static struct dvb_usb_device_properties cxusb_medion_properties;
484static struct dvb_usb_properties cxusb_bluebird_lgh064f_properties; 485static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties;
485static struct dvb_usb_properties cxusb_bluebird_dee1601_properties; 486static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties;
486static struct dvb_usb_properties cxusb_bluebird_lgz201_properties; 487static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties;
487static struct dvb_usb_properties cxusb_bluebird_dtt7579_properties; 488static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties;
488 489
489static int cxusb_probe(struct usb_interface *intf, 490static int cxusb_probe(struct usb_interface *intf,
490 const struct usb_device_id *id) 491 const struct usb_device_id *id)
@@ -504,36 +505,36 @@ static struct usb_device_id cxusb_table [] = {
504 { USB_DEVICE(USB_VID_MEDION, USB_PID_MEDION_MD95700) }, 505 { USB_DEVICE(USB_VID_MEDION, USB_PID_MEDION_MD95700) },
505 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_COLD) }, 506 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_COLD) },
506 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_WARM) }, 507 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_WARM) },
507 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DEE1601_COLD) }, 508 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_COLD) },
508 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DEE1601_WARM) }, 509 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_WARM) },
509 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_COLD) }, 510 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_COLD) },
510 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_WARM) }, 511 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_WARM) },
511 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_COLD) }, 512 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_COLD) },
512 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_WARM) }, 513 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_WARM) },
513 { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DEE1601_COLD) }, 514 { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_COLD) },
514 { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DEE1601_WARM) }, 515 { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_WARM) },
516 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_COLD) },
517 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_WARM) },
515 {} /* Terminating entry */ 518 {} /* Terminating entry */
516}; 519};
517MODULE_DEVICE_TABLE (usb, cxusb_table); 520MODULE_DEVICE_TABLE (usb, cxusb_table);
518 521
519static struct dvb_usb_properties cxusb_medion_properties = { 522static struct dvb_usb_device_properties cxusb_medion_properties = {
520 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 523 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
521 524
522 .usb_ctrl = CYPRESS_FX2, 525 .usb_ctrl = CYPRESS_FX2,
523 526
524 .size_of_priv = sizeof(struct cxusb_state), 527 .size_of_priv = sizeof(struct cxusb_state),
525 528
529 .num_adapters = 1,
530 .adapter = {
531 {
526 .streaming_ctrl = cxusb_streaming_ctrl, 532 .streaming_ctrl = cxusb_streaming_ctrl,
527 .power_ctrl = cxusb_power_ctrl,
528 .frontend_attach = cxusb_cx22702_frontend_attach, 533 .frontend_attach = cxusb_cx22702_frontend_attach,
529 .tuner_attach = cxusb_fmd1216me_tuner_attach, 534 .tuner_attach = cxusb_fmd1216me_tuner_attach,
530
531 .i2c_algo = &cxusb_i2c_algo,
532
533 .generic_bulk_ctrl_endpoint = 0x01,
534 /* parameter for the MPEG2-data transfer */ 535 /* parameter for the MPEG2-data transfer */
535 .urb = { 536 .stream = {
536 .type = DVB_USB_BULK, 537 .type = USB_BULK,
537 .count = 5, 538 .count = 5,
538 .endpoint = 0x02, 539 .endpoint = 0x02,
539 .u = { 540 .u = {
@@ -543,6 +544,14 @@ static struct dvb_usb_properties cxusb_medion_properties = {
543 } 544 }
544 }, 545 },
545 546
547 },
548 },
549 .power_ctrl = cxusb_power_ctrl,
550
551 .i2c_algo = &cxusb_i2c_algo,
552
553 .generic_bulk_ctrl_endpoint = 0x01,
554
546 .num_device_descs = 1, 555 .num_device_descs = 1,
547 .devices = { 556 .devices = {
548 { "Medion MD95700 (MDUSBTV-HYBRID)", 557 { "Medion MD95700 (MDUSBTV-HYBRID)",
@@ -552,7 +561,7 @@ static struct dvb_usb_properties cxusb_medion_properties = {
552 } 561 }
553}; 562};
554 563
555static struct dvb_usb_properties cxusb_bluebird_lgh064f_properties = { 564static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties = {
556 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 565 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
557 566
558 .usb_ctrl = DEVICE_SPECIFIC, 567 .usb_ctrl = DEVICE_SPECIFIC,
@@ -563,22 +572,16 @@ static struct dvb_usb_properties cxusb_bluebird_lgh064f_properties = {
563 572
564 .size_of_priv = sizeof(struct cxusb_state), 573 .size_of_priv = sizeof(struct cxusb_state),
565 574
575 .num_adapters = 1,
576 .adapter = {
577 {
566 .streaming_ctrl = cxusb_streaming_ctrl, 578 .streaming_ctrl = cxusb_streaming_ctrl,
567 .power_ctrl = cxusb_bluebird_power_ctrl,
568 .frontend_attach = cxusb_lgdt3303_frontend_attach, 579 .frontend_attach = cxusb_lgdt3303_frontend_attach,
569 .tuner_attach = cxusb_lgdt3303_tuner_attach, 580 .tuner_attach = cxusb_lgdt3303_tuner_attach,
570 581
571 .i2c_algo = &cxusb_i2c_algo,
572
573 .rc_interval = 100,
574 .rc_key_map = dvico_portable_rc_keys,
575 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
576 .rc_query = cxusb_rc_query,
577
578 .generic_bulk_ctrl_endpoint = 0x01,
579 /* parameter for the MPEG2-data transfer */ 582 /* parameter for the MPEG2-data transfer */
580 .urb = { 583 .stream = {
581 .type = DVB_USB_BULK, 584 .type = USB_BULK,
582 .count = 5, 585 .count = 5,
583 .endpoint = 0x02, 586 .endpoint = 0x02,
584 .u = { 587 .u = {
@@ -587,6 +590,19 @@ static struct dvb_usb_properties cxusb_bluebird_lgh064f_properties = {
587 } 590 }
588 } 591 }
589 }, 592 },
593 },
594 },
595
596 .power_ctrl = cxusb_bluebird_power_ctrl,
597
598 .i2c_algo = &cxusb_i2c_algo,
599
600 .rc_interval = 100,
601 .rc_key_map = dvico_portable_rc_keys,
602 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
603 .rc_query = cxusb_rc_query,
604
605 .generic_bulk_ctrl_endpoint = 0x01,
590 606
591 .num_device_descs = 1, 607 .num_device_descs = 1,
592 .devices = { 608 .devices = {
@@ -597,7 +613,7 @@ static struct dvb_usb_properties cxusb_bluebird_lgh064f_properties = {
597 } 613 }
598}; 614};
599 615
600static struct dvb_usb_properties cxusb_bluebird_dee1601_properties = { 616static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties = {
601 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 617 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
602 618
603 .usb_ctrl = DEVICE_SPECIFIC, 619 .usb_ctrl = DEVICE_SPECIFIC,
@@ -608,22 +624,15 @@ static struct dvb_usb_properties cxusb_bluebird_dee1601_properties = {
608 624
609 .size_of_priv = sizeof(struct cxusb_state), 625 .size_of_priv = sizeof(struct cxusb_state),
610 626
627 .num_adapters = 1,
628 .adapter = {
629 {
611 .streaming_ctrl = cxusb_streaming_ctrl, 630 .streaming_ctrl = cxusb_streaming_ctrl,
612 .power_ctrl = cxusb_bluebird_power_ctrl,
613 .frontend_attach = cxusb_dee1601_frontend_attach, 631 .frontend_attach = cxusb_dee1601_frontend_attach,
614 .tuner_attach = cxusb_dee1601_tuner_attach, 632 .tuner_attach = cxusb_dee1601_tuner_attach,
615
616 .i2c_algo = &cxusb_i2c_algo,
617
618 .rc_interval = 150,
619 .rc_key_map = dvico_mce_rc_keys,
620 .rc_key_map_size = ARRAY_SIZE(dvico_mce_rc_keys),
621 .rc_query = cxusb_rc_query,
622
623 .generic_bulk_ctrl_endpoint = 0x01,
624 /* parameter for the MPEG2-data transfer */ 633 /* parameter for the MPEG2-data transfer */
625 .urb = { 634 .stream = {
626 .type = DVB_USB_BULK, 635 .type = USB_BULK,
627 .count = 5, 636 .count = 5,
628 .endpoint = 0x04, 637 .endpoint = 0x04,
629 .u = { 638 .u = {
@@ -632,8 +641,21 @@ static struct dvb_usb_properties cxusb_bluebird_dee1601_properties = {
632 } 641 }
633 } 642 }
634 }, 643 },
644 },
645 },
646
647 .power_ctrl = cxusb_bluebird_power_ctrl,
635 648
636 .num_device_descs = 2, 649 .i2c_algo = &cxusb_i2c_algo,
650
651 .rc_interval = 150,
652 .rc_key_map = dvico_mce_rc_keys,
653 .rc_key_map_size = ARRAY_SIZE(dvico_mce_rc_keys),
654 .rc_query = cxusb_rc_query,
655
656 .generic_bulk_ctrl_endpoint = 0x01,
657
658 .num_device_descs = 3,
637 .devices = { 659 .devices = {
638 { "DViCO FusionHDTV DVB-T Dual USB", 660 { "DViCO FusionHDTV DVB-T Dual USB",
639 { &cxusb_table[3], NULL }, 661 { &cxusb_table[3], NULL },
@@ -643,10 +665,14 @@ static struct dvb_usb_properties cxusb_bluebird_dee1601_properties = {
643 { &cxusb_table[9], NULL }, 665 { &cxusb_table[9], NULL },
644 { &cxusb_table[10], NULL }, 666 { &cxusb_table[10], NULL },
645 }, 667 },
668 { "DViCO FusionHDTV DVB-T Dual Digital 2",
669 { &cxusb_table[11], NULL },
670 { &cxusb_table[12], NULL },
671 },
646 } 672 }
647}; 673};
648 674
649static struct dvb_usb_properties cxusb_bluebird_lgz201_properties = { 675static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties = {
650 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 676 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
651 677
652 .usb_ctrl = DEVICE_SPECIFIC, 678 .usb_ctrl = DEVICE_SPECIFIC,
@@ -657,22 +683,16 @@ static struct dvb_usb_properties cxusb_bluebird_lgz201_properties = {
657 683
658 .size_of_priv = sizeof(struct cxusb_state), 684 .size_of_priv = sizeof(struct cxusb_state),
659 685
686 .num_adapters = 2,
687 .adapter = {
688 {
660 .streaming_ctrl = cxusb_streaming_ctrl, 689 .streaming_ctrl = cxusb_streaming_ctrl,
661 .power_ctrl = cxusb_bluebird_power_ctrl,
662 .frontend_attach = cxusb_mt352_frontend_attach, 690 .frontend_attach = cxusb_mt352_frontend_attach,
663 .tuner_attach = cxusb_lgz201_tuner_attach, 691 .tuner_attach = cxusb_lgz201_tuner_attach,
664 692
665 .i2c_algo = &cxusb_i2c_algo,
666
667 .rc_interval = 100,
668 .rc_key_map = dvico_portable_rc_keys,
669 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
670 .rc_query = cxusb_rc_query,
671
672 .generic_bulk_ctrl_endpoint = 0x01,
673 /* parameter for the MPEG2-data transfer */ 693 /* parameter for the MPEG2-data transfer */
674 .urb = { 694 .stream = {
675 .type = DVB_USB_BULK, 695 .type = USB_BULK,
676 .count = 5, 696 .count = 5,
677 .endpoint = 0x04, 697 .endpoint = 0x04,
678 .u = { 698 .u = {
@@ -681,7 +701,18 @@ static struct dvb_usb_properties cxusb_bluebird_lgz201_properties = {
681 } 701 }
682 } 702 }
683 }, 703 },
704 },
705 },
706 .power_ctrl = cxusb_bluebird_power_ctrl,
707
708 .i2c_algo = &cxusb_i2c_algo,
684 709
710 .rc_interval = 100,
711 .rc_key_map = dvico_portable_rc_keys,
712 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
713 .rc_query = cxusb_rc_query,
714
715 .generic_bulk_ctrl_endpoint = 0x01,
685 .num_device_descs = 1, 716 .num_device_descs = 1,
686 .devices = { 717 .devices = {
687 { "DViCO FusionHDTV DVB-T USB (LGZ201)", 718 { "DViCO FusionHDTV DVB-T USB (LGZ201)",
@@ -691,7 +722,7 @@ static struct dvb_usb_properties cxusb_bluebird_lgz201_properties = {
691 } 722 }
692}; 723};
693 724
694static struct dvb_usb_properties cxusb_bluebird_dtt7579_properties = { 725static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties = {
695 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 726 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
696 727
697 .usb_ctrl = DEVICE_SPECIFIC, 728 .usb_ctrl = DEVICE_SPECIFIC,
@@ -702,22 +733,16 @@ static struct dvb_usb_properties cxusb_bluebird_dtt7579_properties = {
702 733
703 .size_of_priv = sizeof(struct cxusb_state), 734 .size_of_priv = sizeof(struct cxusb_state),
704 735
736 .num_adapters = 1,
737 .adapter = {
738 {
705 .streaming_ctrl = cxusb_streaming_ctrl, 739 .streaming_ctrl = cxusb_streaming_ctrl,
706 .power_ctrl = cxusb_bluebird_power_ctrl,
707 .frontend_attach = cxusb_mt352_frontend_attach, 740 .frontend_attach = cxusb_mt352_frontend_attach,
708 .tuner_attach = cxusb_dtt7579_tuner_attach, 741 .tuner_attach = cxusb_dtt7579_tuner_attach,
709 742
710 .i2c_algo = &cxusb_i2c_algo,
711
712 .rc_interval = 100,
713 .rc_key_map = dvico_portable_rc_keys,
714 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
715 .rc_query = cxusb_rc_query,
716
717 .generic_bulk_ctrl_endpoint = 0x01,
718 /* parameter for the MPEG2-data transfer */ 743 /* parameter for the MPEG2-data transfer */
719 .urb = { 744 .stream = {
720 .type = DVB_USB_BULK, 745 .type = USB_BULK,
721 .count = 5, 746 .count = 5,
722 .endpoint = 0x04, 747 .endpoint = 0x04,
723 .u = { 748 .u = {
@@ -726,6 +751,18 @@ static struct dvb_usb_properties cxusb_bluebird_dtt7579_properties = {
726 } 751 }
727 } 752 }
728 }, 753 },
754 },
755 },
756 .power_ctrl = cxusb_bluebird_power_ctrl,
757
758 .i2c_algo = &cxusb_i2c_algo,
759
760 .rc_interval = 100,
761 .rc_key_map = dvico_portable_rc_keys,
762 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
763 .rc_query = cxusb_rc_query,
764
765 .generic_bulk_ctrl_endpoint = 0x01,
729 766
730 .num_device_descs = 1, 767 .num_device_descs = 1,
731 .devices = { 768 .devices = {
diff --git a/drivers/media/dvb/dvb-usb/dib0700.h b/drivers/media/dvb/dvb-usb/dib0700.h
new file mode 100644
index 000000000000..ac84347f9d4c
--- /dev/null
+++ b/drivers/media/dvb/dvb-usb/dib0700.h
@@ -0,0 +1,49 @@
1/* Linux driver for devices based on the DiBcom DiB0700 USB bridge
2 *
3 * This program is free software; you can redistribute it and/or modify it
4 * under the terms of the GNU General Public License as published by the Free
5 * Software Foundation, version 2.
6 *
7 * Copyright (C) 2005-6 DiBcom, SA
8 */
9#ifndef _DIB0700_H_
10#define _DIB0700_H_
11
12#define DVB_USB_LOG_PREFIX "dib0700"
13#include "dvb-usb.h"
14
15#include "dib07x0.h"
16
17extern int dvb_usb_dib0700_debug;
18#define deb_info(args...) dprintk(dvb_usb_dib0700_debug,0x01,args)
19#define deb_fw(args...) dprintk(dvb_usb_dib0700_debug,0x02,args)
20#define deb_fwdata(args...) dprintk(dvb_usb_dib0700_debug,0x04,args)
21#define deb_data(args...) dprintk(dvb_usb_dib0700_debug,0x08,args)
22
23#define REQUEST_I2C_READ 0x2
24#define REQUEST_I2C_WRITE 0x3
25#define REQUEST_POLL_RC 0x4
26#define REQUEST_JUMPRAM 0x8
27#define REQUEST_SET_GPIO 0xC
28#define REQUEST_ENABLE_VIDEO 0xF
29 // 1 Byte: 4MSB(1 = enable streaming, 0 = disable streaming) 4LSB(Video Mode: 0 = MPEG2 188Bytes, 1 = Analog)
30 // 2 Byte: MPEG2 mode: 4MSB(1 = Master Mode, 0 = Slave Mode) 4LSB(Channel 1 = bit0, Channel 2 = bit1)
31 // 2 Byte: Analog mode: 4MSB(0 = 625 lines, 1 = 525 lines) 4LSB( " " )
32
33struct dib0700_state {
34 u8 channel_state;
35 u16 mt2060_if1[2];
36};
37
38extern int dib0700_set_gpio(struct dvb_usb_device *, enum dib07x0_gpios gpio, u8 gpio_dir, u8 gpio_val);
39extern int dib0700_download_firmware(struct usb_device *udev, const struct firmware *fw);
40extern int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff);
41extern struct i2c_algorithm dib0700_i2c_algo;
42extern int dib0700_identify_state(struct usb_device *udev, struct dvb_usb_device_properties *props,
43 struct dvb_usb_device_description **desc, int *cold);
44
45extern int dib0700_device_count;
46extern struct dvb_usb_device_properties dib0700_devices[];
47extern struct usb_device_id dib0700_usb_id_table[];
48
49#endif
diff --git a/drivers/media/dvb/dvb-usb/dib0700_core.c b/drivers/media/dvb/dvb-usb/dib0700_core.c
new file mode 100644
index 000000000000..dca6c6985661
--- /dev/null
+++ b/drivers/media/dvb/dvb-usb/dib0700_core.c
@@ -0,0 +1,279 @@
1/* Linux driver for devices based on the DiBcom DiB0700 USB bridge
2 *
3 * This program is free software; you can redistribute it and/or modify it
4 * under the terms of the GNU General Public License as published by the Free
5 * Software Foundation, version 2.
6 *
7 * Copyright (C) 2005-6 DiBcom, SA
8 */
9#include "dib0700.h"
10
11/* debug */
12int dvb_usb_dib0700_debug;
13module_param_named(debug,dvb_usb_dib0700_debug, int, 0644);
14MODULE_PARM_DESC(debug, "set debugging level (1=info,2=fw,4=fwdata,8=data (or-able))." DVB_USB_DEBUG_STATUS);
15
16/* expecting rx buffer: request data[0] data[1] ... data[2] */
17static int dib0700_ctrl_wr(struct dvb_usb_device *d, u8 *tx, u8 txlen)
18{
19 int status;
20
21 deb_data(">>> ");
22 debug_dump(tx,txlen,deb_data);
23
24 status = usb_control_msg(d->udev, usb_sndctrlpipe(d->udev,0),
25 tx[0], USB_TYPE_VENDOR | USB_DIR_OUT, 0, 0, tx, txlen,
26 USB_CTRL_GET_TIMEOUT);
27
28 if (status != txlen)
29 deb_data("ep 0 write error (status = %d, len: %d)\n",status,txlen);
30
31 return status < 0 ? status : 0;
32}
33
34/* expecting tx buffer: request data[0] ... data[n] (n <= 4) */
35static int dib0700_ctrl_rd(struct dvb_usb_device *d, u8 *tx, u8 txlen, u8 *rx, u8 rxlen)
36{
37 u16 index, value;
38 int status;
39
40 if (txlen < 2) {
41 err("tx buffer length is smaller than 2. Makes no sense.");
42 return -EINVAL;
43 }
44 if (txlen > 4) {
45 err("tx buffer length is larger than 4. Not supported.");
46 return -EINVAL;
47 }
48
49 deb_data(">>> ");
50 debug_dump(tx,txlen,deb_data);
51
52 value = ((txlen - 2) << 8) | tx[1];
53 index = 0;
54 if (txlen > 2)
55 index |= (tx[2] << 8);
56 if (txlen > 3)
57 index |= tx[3];
58
59 /* think about swapping here */
60 value = le16_to_cpu(value);
61 index = le16_to_cpu(index);
62
63 status = usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev,0), tx[0],
64 USB_TYPE_VENDOR | USB_DIR_IN, value, index, rx, rxlen,
65 USB_CTRL_GET_TIMEOUT);
66
67 if (status < 0)
68 deb_info("ep 0 read error (status = %d)\n",status);
69
70 deb_data("<<< ");
71 debug_dump(rx,rxlen,deb_data);
72
73 return status; /* length in case of success */
74}
75
76int dib0700_set_gpio(struct dvb_usb_device *d, enum dib07x0_gpios gpio, u8 gpio_dir, u8 gpio_val)
77{
78 u8 buf[3] = { REQUEST_SET_GPIO, gpio, ((gpio_dir & 0x01) << 7) | ((gpio_val & 0x01) << 6) };
79 return dib0700_ctrl_wr(d,buf,3);
80}
81
82/*
83 * I2C master xfer function
84 */
85static int dib0700_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg *msg,int num)
86{
87 struct dvb_usb_device *d = i2c_get_adapdata(adap);
88 int i,len;
89 u8 buf[255];
90
91 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
92 return -EAGAIN;
93
94 for (i = 0; i < num; i++) {
95 /* fill in the address */
96 buf[1] = (msg[i].addr << 1);
97 /* fill the buffer */
98 memcpy(&buf[2], msg[i].buf, msg[i].len);
99
100 /* write/read request */
101 if (i+1 < num && (msg[i+1].flags & I2C_M_RD)) {
102 buf[0] = REQUEST_I2C_READ;
103 buf[1] |= 1;
104
105 /* special thing in the current firmware: when length is zero the read-failed */
106 if ((len = dib0700_ctrl_rd(d, buf, msg[i].len + 2, msg[i+1].buf, msg[i+1].len)) <= 0) {
107 deb_info("I2C read failed on address %x\n", msg[i].addr);
108 break;
109 }
110
111 msg[i+1].len = len;
112
113 i++;
114 } else {
115 buf[0] = REQUEST_I2C_WRITE;
116 if (dib0700_ctrl_wr(d, buf, msg[i].len + 2) < 0)
117 break;
118 }
119 }
120
121 mutex_unlock(&d->i2c_mutex);
122 return i;
123}
124
125static u32 dib0700_i2c_func(struct i2c_adapter *adapter)
126{
127 return I2C_FUNC_I2C;
128}
129
130struct i2c_algorithm dib0700_i2c_algo = {
131 .master_xfer = dib0700_i2c_xfer,
132 .functionality = dib0700_i2c_func,
133};
134
135int dib0700_identify_state(struct usb_device *udev, struct dvb_usb_device_properties *props,
136 struct dvb_usb_device_description **desc, int *cold)
137{
138 u8 buf[3] = { REQUEST_SET_GPIO, 4, (GPIO_IN << 7) | (0 << 6) }; // GPIO4 is save - used for I2C
139 *cold = usb_control_msg(udev, usb_sndctrlpipe(udev,0),
140 buf[0], USB_TYPE_VENDOR | USB_DIR_OUT, 0, 0, buf, 3, USB_CTRL_GET_TIMEOUT) != 3;
141
142 deb_info("cold: %d\n", *cold);
143 return 0;
144}
145
146static int dib0700_jumpram(struct usb_device *udev, u32 address)
147{
148 int ret, actlen;
149 u8 buf[8] = { REQUEST_JUMPRAM, 0, 0, 0,
150 (address >> 24) & 0xff,
151 (address >> 16) & 0xff,
152 (address >> 8) & 0xff,
153 address & 0xff };
154
155 if ((ret = usb_bulk_msg(udev, usb_sndbulkpipe(udev, 0x01),buf,8,&actlen,1000)) < 0) {
156 deb_fw("jumpram to 0x%x failed\n",address);
157 return ret;
158 }
159 if (actlen != 8) {
160 deb_fw("jumpram to 0x%x failed\n",address);
161 return -EIO;
162 }
163 return 0;
164}
165
166int dib0700_download_firmware(struct usb_device *udev, const struct firmware *fw)
167{
168 struct hexline hx;
169 int pos = 0, ret, act_len;
170
171 u8 buf[260];
172
173 while ((ret = dvb_usb_get_hexline(fw, &hx, &pos)) > 0) {
174 deb_fwdata("writing to address 0x%08x (buffer: 0x%02x %02x)\n",hx.addr, hx.len, hx.chk);
175
176 buf[0] = hx.len;
177 buf[1] = (hx.addr >> 8) & 0xff;
178 buf[2] = hx.addr & 0xff;
179 buf[3] = hx.type;
180 memcpy(&buf[4],hx.data,hx.len);
181 buf[4+hx.len] = hx.chk;
182
183 ret = usb_bulk_msg(udev,
184 usb_sndbulkpipe(udev, 0x01),
185 buf,
186 hx.len + 5,
187 &act_len,
188 1000);
189
190 if (ret < 0) {
191 err("firmware download failed at %d with %d",pos,ret);
192 return ret;
193 }
194 }
195
196 if (ret == 0) {
197 /* start the firmware */
198 if ((ret = dib0700_jumpram(udev, 0x70000000)) == 0) {
199 info("firmware started successfully.");
200 msleep(100);
201 }
202 } else
203 ret = -EIO;
204
205 return ret;
206}
207
208int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
209{
210 struct dib0700_state *st = adap->dev->priv;
211 u8 b[4];
212
213 b[0] = REQUEST_ENABLE_VIDEO;
214 b[1] = 0x00;
215 b[2] = (0x01 << 4); /* Master mode */
216 b[3] = 0x00;
217
218 deb_info("modifying (%d) streaming state for %d\n", onoff, adap->id);
219
220 if (onoff)
221 st->channel_state |= 1 << adap->id;
222 else
223 st->channel_state &= ~(1 << adap->id);
224
225 b[2] |= st->channel_state;
226
227 if (st->channel_state) /* if at least one channel is active */
228 b[1] = (0x01 << 4) | 0x00;
229
230 deb_info("data for streaming: %x %x\n",b[1],b[2]);
231
232 return dib0700_ctrl_wr(adap->dev, b, 4);
233}
234
235static int dib0700_probe(struct usb_interface *intf,
236 const struct usb_device_id *id)
237{
238 int i;
239
240 for (i = 0; i < dib0700_device_count; i++)
241 if (dvb_usb_device_init(intf, &dib0700_devices[i], THIS_MODULE, NULL) == 0)
242 return 0;
243
244 return -ENODEV;
245}
246
247static struct usb_driver dib0700_driver = {
248 .name = "dvb_usb_dib0700",
249 .probe = dib0700_probe,
250 .disconnect = dvb_usb_device_exit,
251 .id_table = dib0700_usb_id_table,
252};
253
254/* module stuff */
255static int __init dib0700_module_init(void)
256{
257 int result;
258 info("loaded with support for %d different device-types", dib0700_device_count);
259 if ((result = usb_register(&dib0700_driver))) {
260 err("usb_register failed. Error number %d",result);
261 return result;
262 }
263
264 return 0;
265}
266
267static void __exit dib0700_module_exit(void)
268{
269 /* deregister this driver from the USB subsystem */
270 usb_deregister(&dib0700_driver);
271}
272
273module_init (dib0700_module_init);
274module_exit (dib0700_module_exit);
275
276MODULE_AUTHOR("Patrick Boettcher <pboettcher@dibcom.fr>");
277MODULE_DESCRIPTION("Driver for devices based on DiBcom DiB0700 - USB bridge");
278MODULE_VERSION("1.0");
279MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/dvb-usb/dib0700_devices.c b/drivers/media/dvb/dvb-usb/dib0700_devices.c
new file mode 100644
index 000000000000..e473bfed226b
--- /dev/null
+++ b/drivers/media/dvb/dvb-usb/dib0700_devices.c
@@ -0,0 +1,212 @@
1/* Linux driver for devices based on the DiBcom DiB0700 USB bridge
2 *
3 * This program is free software; you can redistribute it and/or modify it
4 * under the terms of the GNU General Public License as published by the Free
5 * Software Foundation, version 2.
6 *
7 * Copyright (C) 2005-6 DiBcom, SA
8 */
9#include "dib0700.h"
10
11#include "dib3000mc.h"
12#include "mt2060.h"
13
14static int force_lna_activation;
15module_param(force_lna_activation, int, 0644);
16MODULE_PARM_DESC(force_lna_activation, "force the activation of Low-Noise-Amplifyer(s) (LNA), "
17 "if applicable for the device (default: 0=automatic/off).");
18
19/* Hauppauge Nova-T 500
20 * has a LNA on GPIO0 which is enabled by setting 1 */
21static struct mt2060_config bristol_mt2060_config[2] = {
22 {
23 .i2c_address = 0x60,
24 .clock_out = 3,
25 }, {
26 .i2c_address = 0x61,
27 }
28};
29
30static struct dibx000_agc_config bristol_dib3000p_mt2060_agc_config = {
31 .band_caps = BAND_VHF | BAND_UHF,
32 .setup = (1 << 8) | (5 << 5) | (0 << 4) | (0 << 3) | (0 << 2) | (2 << 0),
33
34 .agc1_max = 42598,
35 .agc1_min = 17694,
36 .agc2_max = 45875,
37 .agc2_min = 0,
38
39 .agc1_pt1 = 0,
40 .agc1_pt2 = 59,
41
42 .agc1_slope1 = 0,
43 .agc1_slope2 = 69,
44
45 .agc2_pt1 = 0,
46 .agc2_pt2 = 59,
47
48 .agc2_slope1 = 111,
49 .agc2_slope2 = 28,
50};
51
52static struct dib3000mc_config bristol_dib3000mc_config[2] = {
53 { .agc = &bristol_dib3000p_mt2060_agc_config,
54 .max_time = 0x196,
55 .ln_adc_level = 0x1cc7,
56 .output_mpeg2_in_188_bytes = 1,
57 },
58 { .agc = &bristol_dib3000p_mt2060_agc_config,
59 .max_time = 0x196,
60 .ln_adc_level = 0x1cc7,
61 .output_mpeg2_in_188_bytes = 1,
62 }
63};
64
65static int bristol_frontend_attach(struct dvb_usb_adapter *adap)
66{
67 struct dib0700_state *st = adap->dev->priv;
68 if (adap->id == 0) {
69 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10);
70 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); msleep(10);
71 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10);
72 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(10);
73
74 if (force_lna_activation)
75 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
76 else
77 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 0);
78
79 if (dib3000mc_i2c_enumeration(&adap->dev->i2c_adap, 2, DEFAULT_DIB3000P_I2C_ADDRESS, bristol_dib3000mc_config) != 0) {
80 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10);
81 return -ENODEV;
82 }
83 }
84 st->mt2060_if1[adap->id] = 1220;
85 return (adap->fe = dvb_attach(dib3000mc_attach, &adap->dev->i2c_adap,
86 (10 + adap->id) << 1, &bristol_dib3000mc_config[adap->id])) == NULL ? -ENODEV : 0;
87}
88
89static int bristol_tuner_attach(struct dvb_usb_adapter *adap)
90{
91 struct dib0700_state *st = adap->dev->priv;
92 struct i2c_adapter *tun_i2c = dib3000mc_get_tuner_i2c_master(adap->fe, 1);
93 return dvb_attach(mt2060_attach,adap->fe, tun_i2c, &bristol_mt2060_config[adap->id],
94 st->mt2060_if1[adap->id]) == NULL ? -ENODEV : 0;
95}
96
97/* STK7700P: Hauppauge Nova-T Stick, AVerMedia Volar */
98/*
99static struct mt2060_config stk7000p_mt2060_config = {
100 0x60
101};
102*/
103
104static int stk7700p_frontend_attach(struct dvb_usb_adapter *adap)
105{
106 /* unless there is no real power management in DVB - we leave the device on GPIO6 */
107 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10);
108 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); msleep(10);
109 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(10);
110 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10);
111
112// adap->fe = dib7000m_attach(&adap->dev->i2c_adap, &stk7700p_dib7000m_config, 18);
113 return 0;
114}
115
116static int stk7700p_tuner_attach(struct dvb_usb_adapter *adap)
117{
118// tun_i2c = dib7000m_get_tuner_i2c_master(adap->fe, 1);
119// return mt2060_attach(adap->fe, tun_i2c, &stk3000p_mt2060_config, if1);
120 return 0;
121}
122
123struct usb_device_id dib0700_usb_id_table[] = {
124 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P) },
125 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500) },
126 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_2) },
127 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK) },
128 { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR) },
129 { } /* Terminating entry */
130};
131MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
132
133#define DIB0700_DEFAULT_DEVICE_PROPERTIES \
134 .caps = DVB_USB_IS_AN_I2C_ADAPTER, \
135 .usb_ctrl = DEVICE_SPECIFIC, \
136 .firmware = "dvb-usb-dib0700-01.fw", \
137 .download_firmware = dib0700_download_firmware, \
138 .no_reconnect = 1, \
139 .size_of_priv = sizeof(struct dib0700_state), \
140 .i2c_algo = &dib0700_i2c_algo, \
141 .identify_state = dib0700_identify_state
142
143#define DIB0700_DEFAULT_STREAMING_CONFIG(ep) \
144 .streaming_ctrl = dib0700_streaming_ctrl, \
145 .stream = { \
146 .type = USB_BULK, \
147 .count = 4, \
148 .endpoint = ep, \
149 .u = { \
150 .bulk = { \
151 .buffersize = 39480, \
152 } \
153 } \
154 }
155
156struct dvb_usb_device_properties dib0700_devices[] = {
157 {
158 DIB0700_DEFAULT_DEVICE_PROPERTIES,
159
160 .num_adapters = 1,
161 .adapter = {
162 {
163 .frontend_attach = stk7700p_frontend_attach,
164 .tuner_attach = stk7700p_tuner_attach,
165
166 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
167 },
168 },
169
170 .num_device_descs = 3,
171 .devices = {
172 { "DiBcom STK7700P reference design",
173 { &dib0700_usb_id_table[0], NULL },
174 { NULL },
175 },
176 { "Hauppauge Nova-T Stick",
177 { &dib0700_usb_id_table[3], NULL },
178 { NULL },
179 },
180 { "AVerMedia AVerTV DVB-T Volar",
181 { &dib0700_usb_id_table[4], NULL },
182 { NULL },
183 },
184 }
185 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
186
187 .num_adapters = 2,
188 .adapter = {
189 {
190 .frontend_attach = bristol_frontend_attach,
191 .tuner_attach = bristol_tuner_attach,
192
193 DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
194 }, {
195 .frontend_attach = bristol_frontend_attach,
196 .tuner_attach = bristol_tuner_attach,
197
198 DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
199 }
200 },
201
202 .num_device_descs = 1,
203 .devices = {
204 { "Hauppauge Nova-T 500 Dual DVB-T",
205 { &dib0700_usb_id_table[1], &dib0700_usb_id_table[2], NULL },
206 { NULL },
207 },
208 }
209 }
210};
211
212int dib0700_device_count = ARRAY_SIZE(dib0700_devices);
diff --git a/drivers/media/dvb/dvb-usb/dib07x0.h b/drivers/media/dvb/dvb-usb/dib07x0.h
new file mode 100644
index 000000000000..7e62c1018520
--- /dev/null
+++ b/drivers/media/dvb/dvb-usb/dib07x0.h
@@ -0,0 +1,21 @@
1#ifndef _DIB07X0_H_
2#define _DIB07X0_H_
3
4enum dib07x0_gpios {
5 GPIO0 = 0,
6 GPIO1 = 2,
7 GPIO2 = 3,
8 GPIO3 = 4,
9 GPIO4 = 5,
10 GPIO5 = 6,
11 GPIO6 = 8,
12 GPIO7 = 10,
13 GPIO8 = 11,
14 GPIO9 = 14,
15 GPIO10 = 15,
16};
17
18#define GPIO_IN 0
19#define GPIO_OUT 1
20
21#endif
diff --git a/drivers/media/dvb/dvb-usb/dibusb-common.c b/drivers/media/dvb/dvb-usb/dibusb-common.c
index 124e25ac53b3..fd3a9902f98d 100644
--- a/drivers/media/dvb/dvb-usb/dibusb-common.c
+++ b/drivers/media/dvb/dvb-usb/dibusb-common.c
@@ -18,12 +18,12 @@ MODULE_LICENSE("GPL");
18#define deb_info(args...) dprintk(debug,0x01,args) 18#define deb_info(args...) dprintk(debug,0x01,args)
19 19
20/* common stuff used by the different dibusb modules */ 20/* common stuff used by the different dibusb modules */
21int dibusb_streaming_ctrl(struct dvb_usb_device *d, int onoff) 21int dibusb_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
22{ 22{
23 if (d->priv != NULL) { 23 if (adap->priv != NULL) {
24 struct dibusb_state *st = d->priv; 24 struct dibusb_state *st = adap->priv;
25 if (st->ops.fifo_ctrl != NULL) 25 if (st->ops.fifo_ctrl != NULL)
26 if (st->ops.fifo_ctrl(d->fe,onoff)) { 26 if (st->ops.fifo_ctrl(adap->fe,onoff)) {
27 err("error while controlling the fifo of the demod."); 27 err("error while controlling the fifo of the demod.");
28 return -ENODEV; 28 return -ENODEV;
29 } 29 }
@@ -32,23 +32,23 @@ int dibusb_streaming_ctrl(struct dvb_usb_device *d, int onoff)
32} 32}
33EXPORT_SYMBOL(dibusb_streaming_ctrl); 33EXPORT_SYMBOL(dibusb_streaming_ctrl);
34 34
35int dibusb_pid_filter(struct dvb_usb_device *d, int index, u16 pid, int onoff) 35int dibusb_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid, int onoff)
36{ 36{
37 if (d->priv != NULL) { 37 if (adap->priv != NULL) {
38 struct dibusb_state *st = d->priv; 38 struct dibusb_state *st = adap->priv;
39 if (st->ops.pid_ctrl != NULL) 39 if (st->ops.pid_ctrl != NULL)
40 st->ops.pid_ctrl(d->fe,index,pid,onoff); 40 st->ops.pid_ctrl(adap->fe,index,pid,onoff);
41 } 41 }
42 return 0; 42 return 0;
43} 43}
44EXPORT_SYMBOL(dibusb_pid_filter); 44EXPORT_SYMBOL(dibusb_pid_filter);
45 45
46int dibusb_pid_filter_ctrl(struct dvb_usb_device *d, int onoff) 46int dibusb_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff)
47{ 47{
48 if (d->priv != NULL) { 48 if (adap->priv != NULL) {
49 struct dibusb_state *st = d->priv; 49 struct dibusb_state *st = adap->priv;
50 if (st->ops.pid_parse != NULL) 50 if (st->ops.pid_parse != NULL)
51 if (st->ops.pid_parse(d->fe,onoff) < 0) 51 if (st->ops.pid_parse(adap->fe,onoff) < 0)
52 err("could not handle pid_parser"); 52 err("could not handle pid_parser");
53 } 53 }
54 return 0; 54 return 0;
@@ -68,24 +68,24 @@ int dibusb_power_ctrl(struct dvb_usb_device *d, int onoff)
68} 68}
69EXPORT_SYMBOL(dibusb_power_ctrl); 69EXPORT_SYMBOL(dibusb_power_ctrl);
70 70
71int dibusb2_0_streaming_ctrl(struct dvb_usb_device *d, int onoff) 71int dibusb2_0_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
72{ 72{
73 u8 b[3] = { 0 }; 73 u8 b[3] = { 0 };
74 int ret; 74 int ret;
75 75
76 if ((ret = dibusb_streaming_ctrl(d,onoff)) < 0) 76 if ((ret = dibusb_streaming_ctrl(adap,onoff)) < 0)
77 return ret; 77 return ret;
78 78
79 if (onoff) { 79 if (onoff) {
80 b[0] = DIBUSB_REQ_SET_STREAMING_MODE; 80 b[0] = DIBUSB_REQ_SET_STREAMING_MODE;
81 b[1] = 0x00; 81 b[1] = 0x00;
82 if ((ret = dvb_usb_generic_write(d,b,2)) < 0) 82 if ((ret = dvb_usb_generic_write(adap->dev,b,2)) < 0)
83 return ret; 83 return ret;
84 } 84 }
85 85
86 b[0] = DIBUSB_REQ_SET_IOCTL; 86 b[0] = DIBUSB_REQ_SET_IOCTL;
87 b[1] = onoff ? DIBUSB_IOCTL_CMD_ENABLE_STREAM : DIBUSB_IOCTL_CMD_DISABLE_STREAM; 87 b[1] = onoff ? DIBUSB_IOCTL_CMD_ENABLE_STREAM : DIBUSB_IOCTL_CMD_DISABLE_STREAM;
88 return dvb_usb_generic_write(d,b,3); 88 return dvb_usb_generic_write(adap->dev,b,3);
89} 89}
90EXPORT_SYMBOL(dibusb2_0_streaming_ctrl); 90EXPORT_SYMBOL(dibusb2_0_streaming_ctrl);
91 91
@@ -228,12 +228,12 @@ static struct dib3000mc_config mod3000p_dib3000p_config = {
228 .output_mpeg2_in_188_bytes = 1, 228 .output_mpeg2_in_188_bytes = 1,
229}; 229};
230 230
231int dibusb_dib3000mc_frontend_attach(struct dvb_usb_device *d) 231int dibusb_dib3000mc_frontend_attach(struct dvb_usb_adapter *adap)
232{ 232{
233 if (dib3000mc_attach(&d->i2c_adap, 1, DEFAULT_DIB3000P_I2C_ADDRESS, 0, &mod3000p_dib3000p_config, &d->fe) == 0 || 233 if ((adap->fe = dvb_attach(dib3000mc_attach, &adap->dev->i2c_adap, DEFAULT_DIB3000P_I2C_ADDRESS, &mod3000p_dib3000p_config)) != NULL ||
234 dib3000mc_attach(&d->i2c_adap, 1, DEFAULT_DIB3000MC_I2C_ADDRESS, 0, &mod3000p_dib3000p_config, &d->fe) == 0) { 234 (adap->fe = dvb_attach(dib3000mc_attach, &adap->dev->i2c_adap, DEFAULT_DIB3000MC_I2C_ADDRESS, &mod3000p_dib3000p_config)) != NULL) {
235 if (d->priv != NULL) { 235 if (adap->priv != NULL) {
236 struct dibusb_state *st = d->priv; 236 struct dibusb_state *st = adap->priv;
237 st->ops.pid_parse = dib3000mc_pid_parse; 237 st->ops.pid_parse = dib3000mc_pid_parse;
238 st->ops.pid_ctrl = dib3000mc_pid_control; 238 st->ops.pid_ctrl = dib3000mc_pid_control;
239 } 239 }
@@ -247,20 +247,19 @@ static struct mt2060_config stk3000p_mt2060_config = {
247 0x60 247 0x60
248}; 248};
249 249
250int dibusb_dib3000mc_tuner_attach (struct dvb_usb_device *d) 250int dibusb_dib3000mc_tuner_attach(struct dvb_usb_adapter *adap)
251{ 251{
252 struct dibusb_state *st = d->priv; 252 struct dibusb_state *st = adap->priv;
253 int ret;
254 u8 a,b; 253 u8 a,b;
255 u16 if1 = 1220; 254 u16 if1 = 1220;
256 struct i2c_adapter *tun_i2c; 255 struct i2c_adapter *tun_i2c;
257 256
258 // First IF calibration for Liteon Sticks 257 // First IF calibration for Liteon Sticks
259 if (d->udev->descriptor.idVendor == USB_VID_LITEON && 258 if (adap->dev->udev->descriptor.idVendor == USB_VID_LITEON &&
260 d->udev->descriptor.idProduct == USB_PID_LITEON_DVB_T_WARM) { 259 adap->dev->udev->descriptor.idProduct == USB_PID_LITEON_DVB_T_WARM) {
261 260
262 dibusb_read_eeprom_byte(d,0x7E,&a); 261 dibusb_read_eeprom_byte(adap->dev,0x7E,&a);
263 dibusb_read_eeprom_byte(d,0x7F,&b); 262 dibusb_read_eeprom_byte(adap->dev,0x7F,&b);
264 263
265 if (a == 0x00) 264 if (a == 0x00)
266 if1 += b; 265 if1 += b;
@@ -269,14 +268,14 @@ int dibusb_dib3000mc_tuner_attach (struct dvb_usb_device *d)
269 else 268 else
270 warn("LITE-ON DVB-T: Strange IF1 calibration :%2X %2X\n", a, b); 269 warn("LITE-ON DVB-T: Strange IF1 calibration :%2X %2X\n", a, b);
271 270
272 } else if (d->udev->descriptor.idVendor == USB_VID_DIBCOM && 271 } else if (adap->dev->udev->descriptor.idVendor == USB_VID_DIBCOM &&
273 d->udev->descriptor.idProduct == USB_PID_DIBCOM_MOD3001_WARM) { 272 adap->dev->udev->descriptor.idProduct == USB_PID_DIBCOM_MOD3001_WARM) {
274 u8 desc; 273 u8 desc;
275 dibusb_read_eeprom_byte(d, 7, &desc); 274 dibusb_read_eeprom_byte(adap->dev, 7, &desc);
276 if (desc == 2) { 275 if (desc == 2) {
277 a = 127; 276 a = 127;
278 do { 277 do {
279 dibusb_read_eeprom_byte(d, a, &desc); 278 dibusb_read_eeprom_byte(adap->dev, a, &desc);
280 a--; 279 a--;
281 } while (a > 7 && (desc == 0xff || desc == 0x00)); 280 } while (a > 7 && (desc == 0xff || desc == 0x00));
282 if (desc & 0x80) 281 if (desc & 0x80)
@@ -286,15 +285,15 @@ int dibusb_dib3000mc_tuner_attach (struct dvb_usb_device *d)
286 } 285 }
287 } 286 }
288 287
289 tun_i2c = dib3000mc_get_tuner_i2c_master(d->fe, 1); 288 tun_i2c = dib3000mc_get_tuner_i2c_master(adap->fe, 1);
290 if ((ret = mt2060_attach(d->fe, tun_i2c, &stk3000p_mt2060_config, if1)) != 0) { 289 if (dvb_attach(mt2060_attach, adap->fe, tun_i2c, &stk3000p_mt2060_config, if1) == NULL) {
291 /* not found - use panasonic pll parameters */ 290 /* not found - use panasonic pll parameters */
292 if (dvb_pll_attach(d->fe, 0x60, tun_i2c, &dvb_pll_env57h1xd5) == NULL) 291 if (dvb_attach(dvb_pll_attach, adap->fe, 0x60, tun_i2c, &dvb_pll_env57h1xd5) == NULL)
293 return -ENOMEM; 292 return -ENOMEM;
294 } else { 293 } else {
295 st->mt2060_present = 1; 294 st->mt2060_present = 1;
296 /* set the correct parameters for the dib3000p */ 295 /* set the correct parameters for the dib3000p */
297 dib3000mc_set_config(d->fe, &stk3000p_dib3000p_config); 296 dib3000mc_set_config(adap->fe, &stk3000p_dib3000p_config);
298 } 297 }
299 return 0; 298 return 0;
300} 299}
diff --git a/drivers/media/dvb/dvb-usb/dibusb-mb.c b/drivers/media/dvb/dvb-usb/dibusb-mb.c
index effd34cc4b02..4fe363e48352 100644
--- a/drivers/media/dvb/dvb-usb/dibusb-mb.c
+++ b/drivers/media/dvb/dvb-usb/dibusb-mb.c
@@ -14,35 +14,35 @@
14 */ 14 */
15#include "dibusb.h" 15#include "dibusb.h"
16 16
17static int dibusb_dib3000mb_frontend_attach(struct dvb_usb_device *d) 17static int dibusb_dib3000mb_frontend_attach(struct dvb_usb_adapter *adap)
18{ 18{
19 struct dib3000_config demod_cfg; 19 struct dib3000_config demod_cfg;
20 struct dibusb_state *st = d->priv; 20 struct dibusb_state *st = adap->priv;
21 21
22 demod_cfg.demod_address = 0x8; 22 demod_cfg.demod_address = 0x8;
23 23
24 if ((d->fe = dib3000mb_attach(&demod_cfg,&d->i2c_adap,&st->ops)) == NULL) 24 if ((adap->fe = dib3000mb_attach(&demod_cfg,&adap->dev->i2c_adap,&st->ops)) == NULL)
25 return -ENODEV; 25 return -ENODEV;
26 26
27 d->fe->ops.tuner_ops.init = dvb_usb_tuner_init_i2c; 27 adap->fe->ops.tuner_ops.init = dvb_usb_tuner_init_i2c;
28 d->fe->ops.tuner_ops.set_params = dvb_usb_tuner_set_params_i2c; 28 adap->fe->ops.tuner_ops.set_params = dvb_usb_tuner_set_params_i2c;
29 29
30 d->tuner_pass_ctrl = st->ops.tuner_pass_ctrl; 30 adap->tuner_pass_ctrl = st->ops.tuner_pass_ctrl;
31 31
32 return 0; 32 return 0;
33} 33}
34 34
35static int dibusb_thomson_tuner_attach(struct dvb_usb_device *d) 35static int dibusb_thomson_tuner_attach(struct dvb_usb_adapter *adap)
36{ 36{
37 d->pll_addr = 0x61; 37 adap->pll_addr = 0x61;
38 d->pll_desc = &dvb_pll_tua6010xs; 38 adap->pll_desc = &dvb_pll_tua6010xs;
39 return 0; 39 return 0;
40} 40}
41 41
42/* Some of the Artec 1.1 device aren't equipped with the default tuner 42/* Some of the Artec 1.1 device aren't equipped with the default tuner
43 * (Thomson Cable), but with a Panasonic ENV77H11D5. This function figures 43 * (Thomson Cable), but with a Panasonic ENV77H11D5. This function figures
44 * this out. */ 44 * this out. */
45static int dibusb_tuner_probe_and_attach(struct dvb_usb_device *d) 45static int dibusb_tuner_probe_and_attach(struct dvb_usb_adapter *adap)
46{ 46{
47 u8 b[2] = { 0,0 }, b2[1]; 47 u8 b[2] = { 0,0 }, b2[1];
48 int ret = 0; 48 int ret = 0;
@@ -54,36 +54,36 @@ static int dibusb_tuner_probe_and_attach(struct dvb_usb_device *d)
54 /* the Panasonic sits on I2C addrass 0x60, the Thomson on 0x61 */ 54 /* the Panasonic sits on I2C addrass 0x60, the Thomson on 0x61 */
55 msg[0].addr = msg[1].addr = 0x60; 55 msg[0].addr = msg[1].addr = 0x60;
56 56
57 if (d->tuner_pass_ctrl) 57 if (adap->tuner_pass_ctrl)
58 d->tuner_pass_ctrl(d->fe,1,msg[0].addr); 58 adap->tuner_pass_ctrl(adap->fe,1,msg[0].addr);
59 59
60 if (i2c_transfer (&d->i2c_adap, msg, 2) != 2) { 60 if (i2c_transfer(&adap->dev->i2c_adap, msg, 2) != 2) {
61 err("tuner i2c write failed."); 61 err("tuner i2c write failed.");
62 ret = -EREMOTEIO; 62 ret = -EREMOTEIO;
63 } 63 }
64 64
65 if (d->tuner_pass_ctrl) 65 if (adap->tuner_pass_ctrl)
66 d->tuner_pass_ctrl(d->fe,0,msg[0].addr); 66 adap->tuner_pass_ctrl(adap->fe,0,msg[0].addr);
67 67
68 if (b2[0] == 0xfe) { 68 if (b2[0] == 0xfe) {
69 info("This device has the Thomson Cable onboard. Which is default."); 69 info("This device has the Thomson Cable onboard. Which is default.");
70 dibusb_thomson_tuner_attach(d); 70 dibusb_thomson_tuner_attach(adap);
71 } else { 71 } else {
72 u8 bpll[4] = { 0x0b, 0xf5, 0x85, 0xab }; 72 u8 bpll[4] = { 0x0b, 0xf5, 0x85, 0xab };
73 info("This device has the Panasonic ENV77H11D5 onboard."); 73 info("This device has the Panasonic ENV77H11D5 onboard.");
74 d->pll_addr = 0x60; 74 adap->pll_addr = 0x60;
75 memcpy(d->pll_init,bpll,4); 75 memcpy(adap->pll_init,bpll,4);
76 d->pll_desc = &dvb_pll_tda665x; 76 adap->pll_desc = &dvb_pll_tda665x;
77 } 77 }
78 78
79 return ret; 79 return ret;
80} 80}
81 81
82/* USB Driver stuff */ 82/* USB Driver stuff */
83static struct dvb_usb_properties dibusb1_1_properties; 83static struct dvb_usb_device_properties dibusb1_1_properties;
84static struct dvb_usb_properties dibusb1_1_an2235_properties; 84static struct dvb_usb_device_properties dibusb1_1_an2235_properties;
85static struct dvb_usb_properties dibusb2_0b_properties; 85static struct dvb_usb_device_properties dibusb2_0b_properties;
86static struct dvb_usb_properties artec_t1_usb2_properties; 86static struct dvb_usb_device_properties artec_t1_usb2_properties;
87 87
88static int dibusb_probe(struct usb_interface *intf, 88static int dibusb_probe(struct usb_interface *intf,
89 const struct usb_device_id *id) 89 const struct usb_device_id *id)
@@ -150,34 +150,28 @@ static struct usb_device_id dibusb_dib3000mb_table [] = {
150}; 150};
151MODULE_DEVICE_TABLE (usb, dibusb_dib3000mb_table); 151MODULE_DEVICE_TABLE (usb, dibusb_dib3000mb_table);
152 152
153static struct dvb_usb_properties dibusb1_1_properties = { 153static struct dvb_usb_device_properties dibusb1_1_properties = {
154 .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF | DVB_USB_IS_AN_I2C_ADAPTER, 154 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
155 .pid_filter_count = 16,
156 155
157 .usb_ctrl = CYPRESS_AN2135, 156 .usb_ctrl = CYPRESS_AN2135,
158 157
159 .firmware = "dvb-usb-dibusb-5.0.0.11.fw", 158 .firmware = "dvb-usb-dibusb-5.0.0.11.fw",
160 159
161 .size_of_priv = sizeof(struct dibusb_state), 160 .num_adapters = 1,
161 .adapter = {
162 {
163 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
164 .pid_filter_count = 16,
162 165
163 .streaming_ctrl = dibusb_streaming_ctrl, 166 .streaming_ctrl = dibusb_streaming_ctrl,
164 .pid_filter = dibusb_pid_filter, 167 .pid_filter = dibusb_pid_filter,
165 .pid_filter_ctrl = dibusb_pid_filter_ctrl, 168 .pid_filter_ctrl = dibusb_pid_filter_ctrl,
166 .power_ctrl = dibusb_power_ctrl,
167 .frontend_attach = dibusb_dib3000mb_frontend_attach, 169 .frontend_attach = dibusb_dib3000mb_frontend_attach,
168 .tuner_attach = dibusb_tuner_probe_and_attach, 170 .tuner_attach = dibusb_tuner_probe_and_attach,
169 171
170 .rc_interval = DEFAULT_RC_INTERVAL,
171 .rc_key_map = dibusb_rc_keys,
172 .rc_key_map_size = 111, /* wow, that is ugly ... I want to load it to the driver dynamically */
173 .rc_query = dibusb_rc_query,
174
175 .i2c_algo = &dibusb_i2c_algo,
176
177 .generic_bulk_ctrl_endpoint = 0x01,
178 /* parameter for the MPEG2-data transfer */ 172 /* parameter for the MPEG2-data transfer */
179 .urb = { 173 .stream = {
180 .type = DVB_USB_BULK, 174 .type = USB_BULK,
181 .count = 7, 175 .count = 7,
182 .endpoint = 0x02, 176 .endpoint = 0x02,
183 .u = { 177 .u = {
@@ -186,6 +180,20 @@ static struct dvb_usb_properties dibusb1_1_properties = {
186 } 180 }
187 } 181 }
188 }, 182 },
183 .size_of_priv = sizeof(struct dibusb_state),
184 }
185 },
186
187 .power_ctrl = dibusb_power_ctrl,
188
189 .rc_interval = DEFAULT_RC_INTERVAL,
190 .rc_key_map = dibusb_rc_keys,
191 .rc_key_map_size = 111, /* wow, that is ugly ... I want to load it to the driver dynamically */
192 .rc_query = dibusb_rc_query,
193
194 .i2c_algo = &dibusb_i2c_algo,
195
196 .generic_bulk_ctrl_endpoint = 0x01,
189 197
190 .num_device_descs = 9, 198 .num_device_descs = 9,
191 .devices = { 199 .devices = {
@@ -228,34 +236,27 @@ static struct dvb_usb_properties dibusb1_1_properties = {
228 } 236 }
229}; 237};
230 238
231static struct dvb_usb_properties dibusb1_1_an2235_properties = { 239static struct dvb_usb_device_properties dibusb1_1_an2235_properties = {
232 .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF | DVB_USB_IS_AN_I2C_ADAPTER, 240 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
233 .pid_filter_count = 16,
234
235 .usb_ctrl = CYPRESS_AN2235, 241 .usb_ctrl = CYPRESS_AN2235,
236 242
237 .firmware = "dvb-usb-dibusb-an2235-01.fw", 243 .firmware = "dvb-usb-dibusb-an2235-01.fw",
238 244
239 .size_of_priv = sizeof(struct dibusb_state), 245 .num_adapters = 1,
246 .adapter = {
247 {
248 .caps = DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF | DVB_USB_ADAP_HAS_PID_FILTER,
249 .pid_filter_count = 16,
240 250
241 .streaming_ctrl = dibusb_streaming_ctrl, 251 .streaming_ctrl = dibusb_streaming_ctrl,
242 .pid_filter = dibusb_pid_filter, 252 .pid_filter = dibusb_pid_filter,
243 .pid_filter_ctrl = dibusb_pid_filter_ctrl, 253 .pid_filter_ctrl = dibusb_pid_filter_ctrl,
244 .power_ctrl = dibusb_power_ctrl,
245 .frontend_attach = dibusb_dib3000mb_frontend_attach, 254 .frontend_attach = dibusb_dib3000mb_frontend_attach,
246 .tuner_attach = dibusb_tuner_probe_and_attach, 255 .tuner_attach = dibusb_tuner_probe_and_attach,
247 256
248 .rc_interval = DEFAULT_RC_INTERVAL,
249 .rc_key_map = dibusb_rc_keys,
250 .rc_key_map_size = 111, /* wow, that is ugly ... I want to load it to the driver dynamically */
251 .rc_query = dibusb_rc_query,
252
253 .i2c_algo = &dibusb_i2c_algo,
254
255 .generic_bulk_ctrl_endpoint = 0x01,
256 /* parameter for the MPEG2-data transfer */ 257 /* parameter for the MPEG2-data transfer */
257 .urb = { 258 .stream = {
258 .type = DVB_USB_BULK, 259 .type = USB_BULK,
259 .count = 7, 260 .count = 7,
260 .endpoint = 0x02, 261 .endpoint = 0x02,
261 .u = { 262 .u = {
@@ -264,6 +265,19 @@ static struct dvb_usb_properties dibusb1_1_an2235_properties = {
264 } 265 }
265 } 266 }
266 }, 267 },
268 .size_of_priv = sizeof(struct dibusb_state),
269 },
270 },
271 .power_ctrl = dibusb_power_ctrl,
272
273 .rc_interval = DEFAULT_RC_INTERVAL,
274 .rc_key_map = dibusb_rc_keys,
275 .rc_key_map_size = 111, /* wow, that is ugly ... I want to load it to the driver dynamically */
276 .rc_query = dibusb_rc_query,
277
278 .i2c_algo = &dibusb_i2c_algo,
279
280 .generic_bulk_ctrl_endpoint = 0x01,
267 281
268#ifdef CONFIG_DVB_USB_DIBUSB_MB_FAULTY 282#ifdef CONFIG_DVB_USB_DIBUSB_MB_FAULTY
269 .num_device_descs = 2, 283 .num_device_descs = 2,
@@ -285,34 +299,27 @@ static struct dvb_usb_properties dibusb1_1_an2235_properties = {
285 } 299 }
286}; 300};
287 301
288static struct dvb_usb_properties dibusb2_0b_properties = { 302static struct dvb_usb_device_properties dibusb2_0b_properties = {
289 .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF | DVB_USB_IS_AN_I2C_ADAPTER, 303 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
290 .pid_filter_count = 16,
291 304
292 .usb_ctrl = CYPRESS_FX2, 305 .usb_ctrl = CYPRESS_FX2,
293 306
294 .firmware = "dvb-usb-adstech-usb2-02.fw", 307 .firmware = "dvb-usb-adstech-usb2-02.fw",
295 308
296 .size_of_priv = sizeof(struct dibusb_state), 309 .num_adapters = 1,
310 .adapter = {
311 {
312 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
313 .pid_filter_count = 16,
297 314
298 .streaming_ctrl = dibusb2_0_streaming_ctrl, 315 .streaming_ctrl = dibusb2_0_streaming_ctrl,
299 .pid_filter = dibusb_pid_filter, 316 .pid_filter = dibusb_pid_filter,
300 .pid_filter_ctrl = dibusb_pid_filter_ctrl, 317 .pid_filter_ctrl = dibusb_pid_filter_ctrl,
301 .power_ctrl = dibusb2_0_power_ctrl,
302 .frontend_attach = dibusb_dib3000mb_frontend_attach, 318 .frontend_attach = dibusb_dib3000mb_frontend_attach,
303 .tuner_attach = dibusb_thomson_tuner_attach, 319 .tuner_attach = dibusb_thomson_tuner_attach,
304
305 .rc_interval = DEFAULT_RC_INTERVAL,
306 .rc_key_map = dibusb_rc_keys,
307 .rc_key_map_size = 111, /* wow, that is ugly ... I want to load it to the driver dynamically */
308 .rc_query = dibusb_rc_query,
309
310 .i2c_algo = &dibusb_i2c_algo,
311
312 .generic_bulk_ctrl_endpoint = 0x01,
313 /* parameter for the MPEG2-data transfer */ 320 /* parameter for the MPEG2-data transfer */
314 .urb = { 321 .stream = {
315 .type = DVB_USB_BULK, 322 .type = USB_BULK,
316 .count = 7, 323 .count = 7,
317 .endpoint = 0x06, 324 .endpoint = 0x06,
318 .u = { 325 .u = {
@@ -321,6 +328,19 @@ static struct dvb_usb_properties dibusb2_0b_properties = {
321 } 328 }
322 } 329 }
323 }, 330 },
331 .size_of_priv = sizeof(struct dibusb_state),
332 }
333 },
334 .power_ctrl = dibusb2_0_power_ctrl,
335
336 .rc_interval = DEFAULT_RC_INTERVAL,
337 .rc_key_map = dibusb_rc_keys,
338 .rc_key_map_size = 111, /* wow, that is ugly ... I want to load it to the driver dynamically */
339 .rc_query = dibusb_rc_query,
340
341 .i2c_algo = &dibusb_i2c_algo,
342
343 .generic_bulk_ctrl_endpoint = 0x01,
324 344
325 .num_device_descs = 2, 345 .num_device_descs = 2,
326 .devices = { 346 .devices = {
@@ -336,34 +356,27 @@ static struct dvb_usb_properties dibusb2_0b_properties = {
336 } 356 }
337}; 357};
338 358
339static struct dvb_usb_properties artec_t1_usb2_properties = { 359static struct dvb_usb_device_properties artec_t1_usb2_properties = {
340 .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF | DVB_USB_IS_AN_I2C_ADAPTER, 360 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
341 .pid_filter_count = 16,
342 361
343 .usb_ctrl = CYPRESS_FX2, 362 .usb_ctrl = CYPRESS_FX2,
344 363
345 .firmware = "dvb-usb-dibusb-6.0.0.8.fw", 364 .firmware = "dvb-usb-dibusb-6.0.0.8.fw",
346 365
347 .size_of_priv = sizeof(struct dibusb_state), 366 .num_adapters = 1,
367 .adapter = {
368 {
369 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
370 .pid_filter_count = 16,
348 371
349 .streaming_ctrl = dibusb2_0_streaming_ctrl, 372 .streaming_ctrl = dibusb2_0_streaming_ctrl,
350 .pid_filter = dibusb_pid_filter, 373 .pid_filter = dibusb_pid_filter,
351 .pid_filter_ctrl = dibusb_pid_filter_ctrl, 374 .pid_filter_ctrl = dibusb_pid_filter_ctrl,
352 .power_ctrl = dibusb2_0_power_ctrl,
353 .frontend_attach = dibusb_dib3000mb_frontend_attach, 375 .frontend_attach = dibusb_dib3000mb_frontend_attach,
354 .tuner_attach = dibusb_tuner_probe_and_attach, 376 .tuner_attach = dibusb_tuner_probe_and_attach,
355
356 .rc_interval = DEFAULT_RC_INTERVAL,
357 .rc_key_map = dibusb_rc_keys,
358 .rc_key_map_size = 111, /* wow, that is ugly ... I want to load it to the driver dynamically */
359 .rc_query = dibusb_rc_query,
360
361 .i2c_algo = &dibusb_i2c_algo,
362
363 .generic_bulk_ctrl_endpoint = 0x01,
364 /* parameter for the MPEG2-data transfer */ 377 /* parameter for the MPEG2-data transfer */
365 .urb = { 378 .stream = {
366 .type = DVB_USB_BULK, 379 .type = USB_BULK,
367 .count = 7, 380 .count = 7,
368 .endpoint = 0x06, 381 .endpoint = 0x06,
369 .u = { 382 .u = {
@@ -372,6 +385,19 @@ static struct dvb_usb_properties artec_t1_usb2_properties = {
372 } 385 }
373 } 386 }
374 }, 387 },
388 .size_of_priv = sizeof(struct dibusb_state),
389 }
390 },
391 .power_ctrl = dibusb2_0_power_ctrl,
392
393 .rc_interval = DEFAULT_RC_INTERVAL,
394 .rc_key_map = dibusb_rc_keys,
395 .rc_key_map_size = 111, /* wow, that is ugly ... I want to load it to the driver dynamically */
396 .rc_query = dibusb_rc_query,
397
398 .i2c_algo = &dibusb_i2c_algo,
399
400 .generic_bulk_ctrl_endpoint = 0x01,
375 401
376 .num_device_descs = 1, 402 .num_device_descs = 1,
377 .devices = { 403 .devices = {
diff --git a/drivers/media/dvb/dvb-usb/dibusb-mc.c b/drivers/media/dvb/dvb-usb/dibusb-mc.c
index eca4082a61ae..a0fd37efc04b 100644
--- a/drivers/media/dvb/dvb-usb/dibusb-mc.c
+++ b/drivers/media/dvb/dvb-usb/dibusb-mc.c
@@ -15,7 +15,7 @@
15#include "dibusb.h" 15#include "dibusb.h"
16 16
17/* USB Driver stuff */ 17/* USB Driver stuff */
18static struct dvb_usb_properties dibusb_mc_properties; 18static struct dvb_usb_device_properties dibusb_mc_properties;
19 19
20static int dibusb_mc_probe(struct usb_interface *intf, 20static int dibusb_mc_probe(struct usb_interface *intf,
21 const struct usb_device_id *id) 21 const struct usb_device_id *id)
@@ -43,33 +43,26 @@ static struct usb_device_id dibusb_dib3000mc_table [] = {
43}; 43};
44MODULE_DEVICE_TABLE (usb, dibusb_dib3000mc_table); 44MODULE_DEVICE_TABLE (usb, dibusb_dib3000mc_table);
45 45
46static struct dvb_usb_properties dibusb_mc_properties = { 46static struct dvb_usb_device_properties dibusb_mc_properties = {
47 .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF | DVB_USB_IS_AN_I2C_ADAPTER, 47 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
48 .pid_filter_count = 32,
49 48
50 .usb_ctrl = CYPRESS_FX2, 49 .usb_ctrl = CYPRESS_FX2,
51 .firmware = "dvb-usb-dibusb-6.0.0.8.fw", 50 .firmware = "dvb-usb-dibusb-6.0.0.8.fw",
52 51
53 .size_of_priv = sizeof(struct dibusb_state), 52 .num_adapters = 1,
54 53 .adapter = {
54 {
55 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
56 .pid_filter_count = 32,
55 .streaming_ctrl = dibusb2_0_streaming_ctrl, 57 .streaming_ctrl = dibusb2_0_streaming_ctrl,
56 .pid_filter = dibusb_pid_filter, 58 .pid_filter = dibusb_pid_filter,
57 .pid_filter_ctrl = dibusb_pid_filter_ctrl, 59 .pid_filter_ctrl = dibusb_pid_filter_ctrl,
58 .power_ctrl = dibusb2_0_power_ctrl,
59 .frontend_attach = dibusb_dib3000mc_frontend_attach, 60 .frontend_attach = dibusb_dib3000mc_frontend_attach,
60 .tuner_attach = dibusb_dib3000mc_tuner_attach, 61 .tuner_attach = dibusb_dib3000mc_tuner_attach,
61 62
62 .rc_interval = DEFAULT_RC_INTERVAL,
63 .rc_key_map = dibusb_rc_keys,
64 .rc_key_map_size = 111, /* FIXME */
65 .rc_query = dibusb_rc_query,
66
67 .i2c_algo = &dibusb_i2c_algo,
68
69 .generic_bulk_ctrl_endpoint = 0x01,
70 /* parameter for the MPEG2-data transfer */ 63 /* parameter for the MPEG2-data transfer */
71 .urb = { 64 .stream = {
72 .type = DVB_USB_BULK, 65 .type = USB_BULK,
73 .count = 7, 66 .count = 7,
74 .endpoint = 0x06, 67 .endpoint = 0x06,
75 .u = { 68 .u = {
@@ -78,6 +71,19 @@ static struct dvb_usb_properties dibusb_mc_properties = {
78 } 71 }
79 } 72 }
80 }, 73 },
74 .size_of_priv = sizeof(struct dibusb_state),
75 }
76 },
77 .power_ctrl = dibusb2_0_power_ctrl,
78
79 .rc_interval = DEFAULT_RC_INTERVAL,
80 .rc_key_map = dibusb_rc_keys,
81 .rc_key_map_size = 111, /* FIXME */
82 .rc_query = dibusb_rc_query,
83
84 .i2c_algo = &dibusb_i2c_algo,
85
86 .generic_bulk_ctrl_endpoint = 0x01,
81 87
82 .num_device_descs = 7, 88 .num_device_descs = 7,
83 .devices = { 89 .devices = {
diff --git a/drivers/media/dvb/dvb-usb/dibusb.h b/drivers/media/dvb/dvb-usb/dibusb.h
index a43f87480cf6..5153fb943da1 100644
--- a/drivers/media/dvb/dvb-usb/dibusb.h
+++ b/drivers/media/dvb/dvb-usb/dibusb.h
@@ -107,14 +107,15 @@ struct dibusb_state {
107 107
108extern struct i2c_algorithm dibusb_i2c_algo; 108extern struct i2c_algorithm dibusb_i2c_algo;
109 109
110extern int dibusb_dib3000mc_frontend_attach(struct dvb_usb_device *); 110extern int dibusb_dib3000mc_frontend_attach(struct dvb_usb_adapter *);
111extern int dibusb_dib3000mc_tuner_attach (struct dvb_usb_device *); 111extern int dibusb_dib3000mc_tuner_attach (struct dvb_usb_adapter *);
112
113extern int dibusb_streaming_ctrl(struct dvb_usb_adapter *, int);
114extern int dibusb_pid_filter(struct dvb_usb_adapter *, int, u16, int);
115extern int dibusb_pid_filter_ctrl(struct dvb_usb_adapter *, int);
116extern int dibusb2_0_streaming_ctrl(struct dvb_usb_adapter *, int);
112 117
113extern int dibusb_streaming_ctrl(struct dvb_usb_device *, int);
114extern int dibusb_pid_filter(struct dvb_usb_device *, int, u16, int);
115extern int dibusb_pid_filter_ctrl(struct dvb_usb_device *, int);
116extern int dibusb_power_ctrl(struct dvb_usb_device *, int); 118extern int dibusb_power_ctrl(struct dvb_usb_device *, int);
117extern int dibusb2_0_streaming_ctrl(struct dvb_usb_device *, int);
118extern int dibusb2_0_power_ctrl(struct dvb_usb_device *, int); 119extern int dibusb2_0_power_ctrl(struct dvb_usb_device *, int);
119 120
120#define DEFAULT_RC_INTERVAL 150 121#define DEFAULT_RC_INTERVAL 150
diff --git a/drivers/media/dvb/dvb-usb/digitv.c b/drivers/media/dvb/dvb-usb/digitv.c
index 015854487308..8fb34375c1fb 100644
--- a/drivers/media/dvb/dvb-usb/digitv.c
+++ b/drivers/media/dvb/dvb-usb/digitv.c
@@ -83,7 +83,7 @@ static struct i2c_algorithm digitv_i2c_algo = {
83 83
84/* Callbacks for DVB USB */ 84/* Callbacks for DVB USB */
85static int digitv_identify_state (struct usb_device *udev, struct 85static int digitv_identify_state (struct usb_device *udev, struct
86 dvb_usb_properties *props, struct dvb_usb_device_description **desc, 86 dvb_usb_device_properties *props, struct dvb_usb_device_description **desc,
87 int *cold) 87 int *cold)
88{ 88{
89 *cold = udev->descriptor.iManufacturer == 0 && udev->descriptor.iProduct == 0; 89 *cold = udev->descriptor.iManufacturer == 0 && udev->descriptor.iProduct == 0;
@@ -116,33 +116,33 @@ static struct mt352_config digitv_mt352_config = {
116 116
117static int digitv_nxt6000_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep) 117static int digitv_nxt6000_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep)
118{ 118{
119 struct dvb_usb_device *d = fe->dvb->priv; 119 struct dvb_usb_adapter *adap = fe->dvb->priv;
120 u8 b[5]; 120 u8 b[5];
121 dvb_usb_tuner_calc_regs(fe,fep,b, 5); 121 dvb_usb_tuner_calc_regs(fe,fep,b, 5);
122 return digitv_ctrl_msg(d,USB_WRITE_TUNER,0,&b[1],4,NULL,0); 122 return digitv_ctrl_msg(adap->dev, USB_WRITE_TUNER, 0, &b[1], 4, NULL, 0);
123} 123}
124 124
125static struct nxt6000_config digitv_nxt6000_config = { 125static struct nxt6000_config digitv_nxt6000_config = {
126 .clock_inversion = 1, 126 .clock_inversion = 1,
127}; 127};
128 128
129static int digitv_frontend_attach(struct dvb_usb_device *d) 129static int digitv_frontend_attach(struct dvb_usb_adapter *adap)
130{ 130{
131 if ((d->fe = dvb_attach(mt352_attach, &digitv_mt352_config, &d->i2c_adap)) != NULL) { 131 if ((adap->fe = dvb_attach(mt352_attach, &digitv_mt352_config, &adap->dev->i2c_adap)) != NULL) {
132 d->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs; 132 adap->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs;
133 return 0; 133 return 0;
134 } 134 }
135 if ((d->fe = dvb_attach(nxt6000_attach, &digitv_nxt6000_config, &d->i2c_adap)) != NULL) { 135 if ((adap->fe = dvb_attach(nxt6000_attach, &digitv_nxt6000_config, &adap->dev->i2c_adap)) != NULL) {
136 d->fe->ops.tuner_ops.set_params = digitv_nxt6000_tuner_set_params; 136 adap->fe->ops.tuner_ops.set_params = digitv_nxt6000_tuner_set_params;
137 return 0; 137 return 0;
138 } 138 }
139 return -EIO; 139 return -EIO;
140} 140}
141 141
142static int digitv_tuner_attach(struct dvb_usb_device *d) 142static int digitv_tuner_attach(struct dvb_usb_adapter *adap)
143{ 143{
144 d->pll_addr = 0x60; 144 adap->pll_addr = 0x60;
145 d->pll_desc = &dvb_pll_tded4; 145 adap->pll_desc = &dvb_pll_tded4;
146 return 0; 146 return 0;
147} 147}
148 148
@@ -238,7 +238,7 @@ static int digitv_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
238} 238}
239 239
240/* DVB USB Driver stuff */ 240/* DVB USB Driver stuff */
241static struct dvb_usb_properties digitv_properties; 241static struct dvb_usb_device_properties digitv_properties;
242 242
243static int digitv_probe(struct usb_interface *intf, 243static int digitv_probe(struct usb_interface *intf,
244 const struct usb_device_id *id) 244 const struct usb_device_id *id)
@@ -265,30 +265,21 @@ static struct usb_device_id digitv_table [] = {
265}; 265};
266MODULE_DEVICE_TABLE (usb, digitv_table); 266MODULE_DEVICE_TABLE (usb, digitv_table);
267 267
268static struct dvb_usb_properties digitv_properties = { 268static struct dvb_usb_device_properties digitv_properties = {
269 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 269 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
270 270
271 .usb_ctrl = CYPRESS_FX2, 271 .usb_ctrl = CYPRESS_FX2,
272 .firmware = "dvb-usb-digitv-02.fw", 272 .firmware = "dvb-usb-digitv-02.fw",
273 273
274 .size_of_priv = 0, 274 .num_adapters = 1,
275 275 .adapter = {
276 {
276 .frontend_attach = digitv_frontend_attach, 277 .frontend_attach = digitv_frontend_attach,
277 .tuner_attach = digitv_tuner_attach, 278 .tuner_attach = digitv_tuner_attach,
278 279
279 .rc_interval = 1000,
280 .rc_key_map = digitv_rc_keys,
281 .rc_key_map_size = ARRAY_SIZE(digitv_rc_keys),
282 .rc_query = digitv_rc_query,
283
284 .identify_state = digitv_identify_state,
285
286 .i2c_algo = &digitv_i2c_algo,
287
288 .generic_bulk_ctrl_endpoint = 0x01,
289 /* parameter for the MPEG2-data transfer */ 280 /* parameter for the MPEG2-data transfer */
290 .urb = { 281 .stream = {
291 .type = DVB_USB_BULK, 282 .type = USB_BULK,
292 .count = 7, 283 .count = 7,
293 .endpoint = 0x02, 284 .endpoint = 0x02,
294 .u = { 285 .u = {
@@ -297,6 +288,18 @@ static struct dvb_usb_properties digitv_properties = {
297 } 288 }
298 } 289 }
299 }, 290 },
291 }
292 },
293 .identify_state = digitv_identify_state,
294
295 .rc_interval = 1000,
296 .rc_key_map = digitv_rc_keys,
297 .rc_key_map_size = ARRAY_SIZE(digitv_rc_keys),
298 .rc_query = digitv_rc_query,
299
300 .i2c_algo = &digitv_i2c_algo,
301
302 .generic_bulk_ctrl_endpoint = 0x01,
300 303
301 .num_device_descs = 1, 304 .num_device_descs = 1,
302 .devices = { 305 .devices = {
diff --git a/drivers/media/dvb/dvb-usb/dtt200u.c b/drivers/media/dvb/dvb-usb/dtt200u.c
index 27af4e436479..fa43a41d753b 100644
--- a/drivers/media/dvb/dvb-usb/dtt200u.c
+++ b/drivers/media/dvb/dvb-usb/dtt200u.c
@@ -28,19 +28,19 @@ static int dtt200u_power_ctrl(struct dvb_usb_device *d, int onoff)
28 return 0; 28 return 0;
29} 29}
30 30
31static int dtt200u_streaming_ctrl(struct dvb_usb_device *d, int onoff) 31static int dtt200u_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
32{ 32{
33 u8 b_streaming[2] = { SET_STREAMING, onoff }; 33 u8 b_streaming[2] = { SET_STREAMING, onoff };
34 u8 b_rst_pid = RESET_PID_FILTER; 34 u8 b_rst_pid = RESET_PID_FILTER;
35 35
36 dvb_usb_generic_write(d,b_streaming,2); 36 dvb_usb_generic_write(adap->dev, b_streaming, 2);
37 37
38 if (onoff == 0) 38 if (onoff == 0)
39 dvb_usb_generic_write(d,&b_rst_pid,1); 39 dvb_usb_generic_write(adap->dev, &b_rst_pid, 1);
40 return 0; 40 return 0;
41} 41}
42 42
43static int dtt200u_pid_filter(struct dvb_usb_device *d, int index, u16 pid, int onoff) 43static int dtt200u_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid, int onoff)
44{ 44{
45 u8 b_pid[4]; 45 u8 b_pid[4];
46 pid = onoff ? pid : 0; 46 pid = onoff ? pid : 0;
@@ -50,7 +50,7 @@ static int dtt200u_pid_filter(struct dvb_usb_device *d, int index, u16 pid, int
50 b_pid[2] = pid & 0xff; 50 b_pid[2] = pid & 0xff;
51 b_pid[3] = (pid >> 8) & 0x1f; 51 b_pid[3] = (pid >> 8) & 0x1f;
52 52
53 return dvb_usb_generic_write(d,b_pid,4); 53 return dvb_usb_generic_write(adap->dev, b_pid, 4);
54} 54}
55 55
56/* remote control */ 56/* remote control */
@@ -86,16 +86,16 @@ static int dtt200u_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
86 return 0; 86 return 0;
87} 87}
88 88
89static int dtt200u_frontend_attach(struct dvb_usb_device *d) 89static int dtt200u_frontend_attach(struct dvb_usb_adapter *adap)
90{ 90{
91 d->fe = dtt200u_fe_attach(d); 91 adap->fe = dtt200u_fe_attach(adap->dev);
92 return 0; 92 return 0;
93} 93}
94 94
95static struct dvb_usb_properties dtt200u_properties; 95static struct dvb_usb_device_properties dtt200u_properties;
96static struct dvb_usb_properties wt220u_fc_properties; 96static struct dvb_usb_device_properties wt220u_fc_properties;
97static struct dvb_usb_properties wt220u_properties; 97static struct dvb_usb_device_properties wt220u_properties;
98static struct dvb_usb_properties wt220u_zl0353_properties; 98static struct dvb_usb_device_properties wt220u_zl0353_properties;
99 99
100static int dtt200u_usb_probe(struct usb_interface *intf, 100static int dtt200u_usb_probe(struct usb_interface *intf,
101 const struct usb_device_id *id) 101 const struct usb_device_id *id)
@@ -123,28 +123,22 @@ static struct usb_device_id dtt200u_usb_table [] = {
123}; 123};
124MODULE_DEVICE_TABLE(usb, dtt200u_usb_table); 124MODULE_DEVICE_TABLE(usb, dtt200u_usb_table);
125 125
126static struct dvb_usb_properties dtt200u_properties = { 126static struct dvb_usb_device_properties dtt200u_properties = {
127 .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_NEED_PID_FILTERING,
128 .pid_filter_count = 15,
129
130 .usb_ctrl = CYPRESS_FX2, 127 .usb_ctrl = CYPRESS_FX2,
131 .firmware = "dvb-usb-dtt200u-01.fw", 128 .firmware = "dvb-usb-dtt200u-01.fw",
132 129
133 .power_ctrl = dtt200u_power_ctrl, 130 .num_adapters = 1,
131 .adapter = {
132 {
133 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_NEED_PID_FILTERING,
134 .pid_filter_count = 15,
135
134 .streaming_ctrl = dtt200u_streaming_ctrl, 136 .streaming_ctrl = dtt200u_streaming_ctrl,
135 .pid_filter = dtt200u_pid_filter, 137 .pid_filter = dtt200u_pid_filter,
136 .frontend_attach = dtt200u_frontend_attach, 138 .frontend_attach = dtt200u_frontend_attach,
137
138 .rc_interval = 300,
139 .rc_key_map = dtt200u_rc_keys,
140 .rc_key_map_size = ARRAY_SIZE(dtt200u_rc_keys),
141 .rc_query = dtt200u_rc_query,
142
143 .generic_bulk_ctrl_endpoint = 0x01,
144
145 /* parameter for the MPEG2-data transfer */ 139 /* parameter for the MPEG2-data transfer */
146 .urb = { 140 .stream = {
147 .type = DVB_USB_BULK, 141 .type = USB_BULK,
148 .count = 7, 142 .count = 7,
149 .endpoint = 0x02, 143 .endpoint = 0x02,
150 .u = { 144 .u = {
@@ -153,6 +147,16 @@ static struct dvb_usb_properties dtt200u_properties = {
153 } 147 }
154 } 148 }
155 }, 149 },
150 }
151 },
152 .power_ctrl = dtt200u_power_ctrl,
153
154 .rc_interval = 300,
155 .rc_key_map = dtt200u_rc_keys,
156 .rc_key_map_size = ARRAY_SIZE(dtt200u_rc_keys),
157 .rc_query = dtt200u_rc_query,
158
159 .generic_bulk_ctrl_endpoint = 0x01,
156 160
157 .num_device_descs = 1, 161 .num_device_descs = 1,
158 .devices = { 162 .devices = {
@@ -164,28 +168,22 @@ static struct dvb_usb_properties dtt200u_properties = {
164 } 168 }
165}; 169};
166 170
167static struct dvb_usb_properties wt220u_properties = { 171static struct dvb_usb_device_properties wt220u_properties = {
168 .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_NEED_PID_FILTERING,
169 .pid_filter_count = 15,
170
171 .usb_ctrl = CYPRESS_FX2, 172 .usb_ctrl = CYPRESS_FX2,
172 .firmware = "dvb-usb-wt220u-02.fw", 173 .firmware = "dvb-usb-wt220u-02.fw",
173 174
174 .power_ctrl = dtt200u_power_ctrl, 175 .num_adapters = 1,
176 .adapter = {
177 {
178 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_NEED_PID_FILTERING,
179 .pid_filter_count = 15,
180
175 .streaming_ctrl = dtt200u_streaming_ctrl, 181 .streaming_ctrl = dtt200u_streaming_ctrl,
176 .pid_filter = dtt200u_pid_filter, 182 .pid_filter = dtt200u_pid_filter,
177 .frontend_attach = dtt200u_frontend_attach, 183 .frontend_attach = dtt200u_frontend_attach,
178
179 .rc_interval = 300,
180 .rc_key_map = dtt200u_rc_keys,
181 .rc_key_map_size = ARRAY_SIZE(dtt200u_rc_keys),
182 .rc_query = dtt200u_rc_query,
183
184 .generic_bulk_ctrl_endpoint = 0x01,
185
186 /* parameter for the MPEG2-data transfer */ 184 /* parameter for the MPEG2-data transfer */
187 .urb = { 185 .stream = {
188 .type = DVB_USB_BULK, 186 .type = USB_BULK,
189 .count = 7, 187 .count = 7,
190 .endpoint = 0x02, 188 .endpoint = 0x02,
191 .u = { 189 .u = {
@@ -194,6 +192,16 @@ static struct dvb_usb_properties wt220u_properties = {
194 } 192 }
195 } 193 }
196 }, 194 },
195 }
196 },
197 .power_ctrl = dtt200u_power_ctrl,
198
199 .rc_interval = 300,
200 .rc_key_map = dtt200u_rc_keys,
201 .rc_key_map_size = ARRAY_SIZE(dtt200u_rc_keys),
202 .rc_query = dtt200u_rc_query,
203
204 .generic_bulk_ctrl_endpoint = 0x01,
197 205
198 .num_device_descs = 1, 206 .num_device_descs = 1,
199 .devices = { 207 .devices = {
@@ -205,36 +213,40 @@ static struct dvb_usb_properties wt220u_properties = {
205 } 213 }
206}; 214};
207 215
208static struct dvb_usb_properties wt220u_fc_properties = { 216static struct dvb_usb_device_properties wt220u_fc_properties = {
209 .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_NEED_PID_FILTERING,
210 .pid_filter_count = 15,
211
212 .usb_ctrl = CYPRESS_FX2, 217 .usb_ctrl = CYPRESS_FX2,
213 .firmware = "dvb-usb-wt220u-fc03.fw", 218 .firmware = "dvb-usb-wt220u-fc03.fw",
214 219
215 .power_ctrl = dtt200u_power_ctrl, 220 .num_adapters = 1,
221 .adapter = {
222 {
223 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_NEED_PID_FILTERING,
224 .pid_filter_count = 15,
225
216 .streaming_ctrl = dtt200u_streaming_ctrl, 226 .streaming_ctrl = dtt200u_streaming_ctrl,
217 .pid_filter = dtt200u_pid_filter, 227 .pid_filter = dtt200u_pid_filter,
218 .frontend_attach = dtt200u_frontend_attach, 228 .frontend_attach = dtt200u_frontend_attach,
219
220 .rc_interval = 300,
221 .rc_key_map = dtt200u_rc_keys,
222 .rc_key_map_size = ARRAY_SIZE(dtt200u_rc_keys),
223 .rc_query = dtt200u_rc_query,
224
225 .generic_bulk_ctrl_endpoint = 0x01,
226
227 /* parameter for the MPEG2-data transfer */ 229 /* parameter for the MPEG2-data transfer */
228 .urb = { 230 .stream = {
229 .type = DVB_USB_BULK, 231 .type = USB_BULK,
230 .count = 7, 232 .count = 7,
231 .endpoint = 0x86, 233 .endpoint = 0x06,
232 .u = { 234 .u = {
233 .bulk = { 235 .bulk = {
234 .buffersize = 4096, 236 .buffersize = 4096,
235 } 237 }
236 } 238 }
237 }, 239 },
240 }
241 },
242 .power_ctrl = dtt200u_power_ctrl,
243
244 .rc_interval = 300,
245 .rc_key_map = dtt200u_rc_keys,
246 .rc_key_map_size = ARRAY_SIZE(dtt200u_rc_keys),
247 .rc_query = dtt200u_rc_query,
248
249 .generic_bulk_ctrl_endpoint = 0x01,
238 250
239 .num_device_descs = 1, 251 .num_device_descs = 1,
240 .devices = { 252 .devices = {
@@ -246,28 +258,22 @@ static struct dvb_usb_properties wt220u_fc_properties = {
246 } 258 }
247}; 259};
248 260
249static struct dvb_usb_properties wt220u_zl0353_properties = { 261static struct dvb_usb_device_properties wt220u_zl0353_properties = {
250 .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_NEED_PID_FILTERING,
251 .pid_filter_count = 15,
252
253 .usb_ctrl = CYPRESS_FX2, 262 .usb_ctrl = CYPRESS_FX2,
254 .firmware = "dvb-usb-wt220u-zl0353-01.fw", 263 .firmware = "dvb-usb-wt220u-zl0353-01.fw",
255 264
256 .power_ctrl = dtt200u_power_ctrl, 265 .num_adapters = 1,
266 .adapter = {
267 {
268 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_NEED_PID_FILTERING,
269 .pid_filter_count = 15,
270
257 .streaming_ctrl = dtt200u_streaming_ctrl, 271 .streaming_ctrl = dtt200u_streaming_ctrl,
258 .pid_filter = dtt200u_pid_filter, 272 .pid_filter = dtt200u_pid_filter,
259 .frontend_attach = dtt200u_frontend_attach, 273 .frontend_attach = dtt200u_frontend_attach,
260
261 .rc_interval = 300,
262 .rc_key_map = dtt200u_rc_keys,
263 .rc_key_map_size = ARRAY_SIZE(dtt200u_rc_keys),
264 .rc_query = dtt200u_rc_query,
265
266 .generic_bulk_ctrl_endpoint = 0x01,
267
268 /* parameter for the MPEG2-data transfer */ 274 /* parameter for the MPEG2-data transfer */
269 .urb = { 275 .stream = {
270 .type = DVB_USB_BULK, 276 .type = USB_BULK,
271 .count = 7, 277 .count = 7,
272 .endpoint = 0x02, 278 .endpoint = 0x02,
273 .u = { 279 .u = {
@@ -276,6 +282,16 @@ static struct dvb_usb_properties wt220u_zl0353_properties = {
276 } 282 }
277 } 283 }
278 }, 284 },
285 }
286 },
287 .power_ctrl = dtt200u_power_ctrl,
288
289 .rc_interval = 300,
290 .rc_key_map = dtt200u_rc_keys,
291 .rc_key_map_size = ARRAY_SIZE(dtt200u_rc_keys),
292 .rc_query = dtt200u_rc_query,
293
294 .generic_bulk_ctrl_endpoint = 0x01,
279 295
280 .num_device_descs = 1, 296 .num_device_descs = 1,
281 .devices = { 297 .devices = {
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-common.h b/drivers/media/dvb/dvb-usb/dvb-usb-common.h
index a3460bf2d9fa..35ab68f6dcf6 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-common.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-common.h
@@ -14,31 +14,36 @@
14extern int dvb_usb_debug; 14extern int dvb_usb_debug;
15extern int dvb_usb_disable_rc_polling; 15extern int dvb_usb_disable_rc_polling;
16 16
17#define deb_info(args...) dprintk(dvb_usb_debug,0x01,args) 17#define deb_info(args...) dprintk(dvb_usb_debug,0x001,args)
18#define deb_xfer(args...) dprintk(dvb_usb_debug,0x02,args) 18#define deb_xfer(args...) dprintk(dvb_usb_debug,0x002,args)
19#define deb_pll(args...) dprintk(dvb_usb_debug,0x04,args) 19#define deb_pll(args...) dprintk(dvb_usb_debug,0x004,args)
20#define deb_ts(args...) dprintk(dvb_usb_debug,0x08,args) 20#define deb_ts(args...) dprintk(dvb_usb_debug,0x008,args)
21#define deb_err(args...) dprintk(dvb_usb_debug,0x10,args) 21#define deb_err(args...) dprintk(dvb_usb_debug,0x010,args)
22#define deb_rc(args...) dprintk(dvb_usb_debug,0x20,args) 22#define deb_rc(args...) dprintk(dvb_usb_debug,0x020,args)
23#define deb_fw(args...) dprintk(dvb_usb_debug,0x40,args) 23#define deb_fw(args...) dprintk(dvb_usb_debug,0x040,args)
24#define deb_mem(args...) dprintk(dvb_usb_debug,0x80,args) 24#define deb_mem(args...) dprintk(dvb_usb_debug,0x080,args)
25#define deb_uxfer(args...) dprintk(dvb_usb_debug,0x100,args)
25 26
26/* commonly used methods */ 27/* commonly used methods */
27extern int dvb_usb_download_firmware(struct usb_device *, struct dvb_usb_properties *); 28extern int dvb_usb_download_firmware(struct usb_device *, struct dvb_usb_device_properties *);
28 29
29extern int dvb_usb_urb_submit(struct dvb_usb_device *); 30extern int dvb_usb_device_power_ctrl(struct dvb_usb_device *d, int onoff);
30extern int dvb_usb_urb_kill(struct dvb_usb_device *); 31
31extern int dvb_usb_urb_init(struct dvb_usb_device *); 32extern int usb_urb_init(struct usb_data_stream *stream, struct usb_data_stream_properties *props);
32extern int dvb_usb_urb_exit(struct dvb_usb_device *); 33extern int usb_urb_exit(struct usb_data_stream *stream);
34extern int usb_urb_submit(struct usb_data_stream *stream);
35extern int usb_urb_kill(struct usb_data_stream *stream);
36
37extern int dvb_usb_adapter_stream_init(struct dvb_usb_adapter *adap);
38extern int dvb_usb_adapter_stream_exit(struct dvb_usb_adapter *adap);
33 39
34extern int dvb_usb_i2c_init(struct dvb_usb_device *); 40extern int dvb_usb_i2c_init(struct dvb_usb_device *);
35extern int dvb_usb_i2c_exit(struct dvb_usb_device *); 41extern int dvb_usb_i2c_exit(struct dvb_usb_device *);
36 42
37extern int dvb_usb_dvb_init(struct dvb_usb_device *); 43extern int dvb_usb_adapter_dvb_init(struct dvb_usb_adapter *adap);
38extern int dvb_usb_dvb_exit(struct dvb_usb_device *); 44extern int dvb_usb_adapter_dvb_exit(struct dvb_usb_adapter *adap);
39 45extern int dvb_usb_adapter_frontend_init(struct dvb_usb_adapter *adap);
40extern int dvb_usb_fe_init(struct dvb_usb_device *); 46extern int dvb_usb_adapter_frontend_exit(struct dvb_usb_adapter *adap);
41extern int dvb_usb_fe_exit(struct dvb_usb_device *);
42 47
43extern int dvb_usb_remote_init(struct dvb_usb_device *); 48extern int dvb_usb_remote_init(struct dvb_usb_device *);
44extern int dvb_usb_remote_exit(struct dvb_usb_device *); 49extern int dvb_usb_remote_exit(struct dvb_usb_device *);
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c b/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c
index fe6208ada903..4561a672da92 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c
@@ -1,6 +1,6 @@
1/* dvb-usb-dvb.c is part of the DVB USB library. 1/* dvb-usb-dvb.c is part of the DVB USB library.
2 * 2 *
3 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) 3 * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de)
4 * see dvb-usb-init.c for copyright information. 4 * see dvb-usb-init.c for copyright information.
5 * 5 *
6 * This file contains functions for initializing and handling the 6 * This file contains functions for initializing and handling the
@@ -8,55 +8,55 @@
8 */ 8 */
9#include "dvb-usb-common.h" 9#include "dvb-usb-common.h"
10 10
11/* does the complete input transfer handling */
11static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff) 12static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff)
12{ 13{
13 struct dvb_usb_device *d = dvbdmxfeed->demux->priv; 14 struct dvb_usb_adapter *adap = dvbdmxfeed->demux->priv;
14 int newfeedcount,ret; 15 int newfeedcount,ret;
15 16
16 if (d == NULL) 17 if (adap == NULL)
17 return -ENODEV; 18 return -ENODEV;
18 19
19 newfeedcount = d->feedcount + (onoff ? 1 : -1); 20 newfeedcount = adap->feedcount + (onoff ? 1 : -1);
20 21
21 /* 22 /* stop feed before setting a new pid if there will be no pid anymore */
22 * stop feed before setting a new pid if there will be no pid anymore
23 */
24 if (newfeedcount == 0) { 23 if (newfeedcount == 0) {
25 deb_ts("stop feeding\n"); 24 deb_ts("stop feeding\n");
26 dvb_usb_urb_kill(d); 25 usb_urb_kill(&adap->stream);
27 26
28 if (d->props.streaming_ctrl != NULL) 27 if (adap->props.streaming_ctrl != NULL)
29 if ((ret = d->props.streaming_ctrl(d,0))) 28 if ((ret = adap->props.streaming_ctrl(adap,0)))
30 err("error while stopping stream."); 29 err("error while stopping stream.");
31
32 } 30 }
33 31
34 d->feedcount = newfeedcount; 32 adap->feedcount = newfeedcount;
35 33
36 /* activate the pid on the device specific pid_filter */ 34 /* activate the pid on the device specific pid_filter */
37 deb_ts("setting pid: %5d %04x at index %d '%s'\n",dvbdmxfeed->pid,dvbdmxfeed->pid,dvbdmxfeed->index,onoff ? "on" : "off"); 35 deb_ts("setting pid (%s): %5d %04x at index %d '%s'\n",adap->pid_filtering ?
38 if (d->props.caps & DVB_USB_HAS_PID_FILTER && 36 "yes" : "no", dvbdmxfeed->pid,dvbdmxfeed->pid,dvbdmxfeed->index,onoff ?
39 d->pid_filtering && 37 "on" : "off");
40 d->props.pid_filter != NULL) 38 if (adap->props.caps & DVB_USB_ADAP_HAS_PID_FILTER &&
41 d->props.pid_filter(d,dvbdmxfeed->index,dvbdmxfeed->pid,onoff); 39 adap->pid_filtering &&
40 adap->props.pid_filter != NULL)
41 adap->props.pid_filter(adap, dvbdmxfeed->index, dvbdmxfeed->pid,onoff);
42 42
43 /* start the feed if this was the first feed and there is still a feed 43 /* start the feed if this was the first feed and there is still a feed
44 * for reception. 44 * for reception.
45 */ 45 */
46 if (d->feedcount == onoff && d->feedcount > 0) { 46 if (adap->feedcount == onoff && adap->feedcount > 0) {
47 deb_ts("submitting all URBs\n"); 47 deb_ts("submitting all URBs\n");
48 dvb_usb_urb_submit(d); 48 usb_urb_submit(&adap->stream);
49 49
50 deb_ts("controlling pid parser\n"); 50 deb_ts("controlling pid parser\n");
51 if (d->props.caps & DVB_USB_HAS_PID_FILTER && 51 if (adap->props.caps & DVB_USB_ADAP_HAS_PID_FILTER &&
52 d->props.caps & DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF && 52 adap->props.caps & DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF &&
53 d->props.pid_filter_ctrl != NULL) 53 adap->props.pid_filter_ctrl != NULL)
54 if (d->props.pid_filter_ctrl(d,d->pid_filtering) < 0) 54 if (adap->props.pid_filter_ctrl(adap,adap->pid_filtering) < 0)
55 err("could not handle pid_parser"); 55 err("could not handle pid_parser");
56 56
57 deb_ts("start feeding\n"); 57 deb_ts("start feeding\n");
58 if (d->props.streaming_ctrl != NULL) 58 if (adap->props.streaming_ctrl != NULL)
59 if (d->props.streaming_ctrl(d,1)) { 59 if (adap->props.streaming_ctrl(adap,1)) {
60 err("error while enabling fifo."); 60 err("error while enabling fifo.");
61 return -ENODEV; 61 return -ENODEV;
62 } 62 }
@@ -77,134 +77,130 @@ static int dvb_usb_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
77 return dvb_usb_ctrl_feed(dvbdmxfeed,0); 77 return dvb_usb_ctrl_feed(dvbdmxfeed,0);
78} 78}
79 79
80int dvb_usb_dvb_init(struct dvb_usb_device *d) 80int dvb_usb_adapter_dvb_init(struct dvb_usb_adapter *adap)
81{ 81{
82 int ret; 82 int ret;
83 83
84 if ((ret = dvb_register_adapter(&d->dvb_adap, d->desc->name, 84 if ((ret = dvb_register_adapter(&adap->dvb_adap, adap->dev->desc->name,
85 d->owner, &d->udev->dev)) < 0) { 85 adap->dev->owner, &adap->dev->udev->dev)) < 0) {
86 deb_info("dvb_register_adapter failed: error %d", ret); 86 deb_info("dvb_register_adapter failed: error %d", ret);
87 goto err; 87 goto err;
88 } 88 }
89 d->dvb_adap.priv = d; 89 adap->dvb_adap.priv = adap;
90 90
91 if (d->props.read_mac_address) { 91 if (adap->dev->props.read_mac_address) {
92 if (d->props.read_mac_address(d,d->dvb_adap.proposed_mac) == 0) 92 if (adap->dev->props.read_mac_address(adap->dev,adap->dvb_adap.proposed_mac) == 0)
93 info("MAC address: %02x:%02x:%02x:%02x:%02x:%02x",d->dvb_adap.proposed_mac[0], 93 info("MAC address: %02x:%02x:%02x:%02x:%02x:%02x",adap->dvb_adap.proposed_mac[0],
94 d->dvb_adap.proposed_mac[1],d->dvb_adap.proposed_mac[2], 94 adap->dvb_adap.proposed_mac[1], adap->dvb_adap.proposed_mac[2],
95 d->dvb_adap.proposed_mac[3],d->dvb_adap.proposed_mac[4], 95 adap->dvb_adap.proposed_mac[3], adap->dvb_adap.proposed_mac[4],
96 d->dvb_adap.proposed_mac[5]); 96 adap->dvb_adap.proposed_mac[5]);
97 else 97 else
98 err("MAC address reading failed."); 98 err("MAC address reading failed.");
99 } 99 }
100 100
101 101
102 d->demux.dmx.capabilities = DMX_TS_FILTERING | DMX_SECTION_FILTERING; 102 adap->demux.dmx.capabilities = DMX_TS_FILTERING | DMX_SECTION_FILTERING;
103 d->demux.priv = d; 103 adap->demux.priv = adap;
104 104
105 d->demux.feednum = d->demux.filternum = d->max_feed_count; 105 adap->demux.feednum = adap->demux.filternum = adap->max_feed_count;
106 d->demux.start_feed = dvb_usb_start_feed; 106 adap->demux.start_feed = dvb_usb_start_feed;
107 d->demux.stop_feed = dvb_usb_stop_feed; 107 adap->demux.stop_feed = dvb_usb_stop_feed;
108 d->demux.write_to_decoder = NULL; 108 adap->demux.write_to_decoder = NULL;
109 if ((ret = dvb_dmx_init(&d->demux)) < 0) { 109 if ((ret = dvb_dmx_init(&adap->demux)) < 0) {
110 err("dvb_dmx_init failed: error %d",ret); 110 err("dvb_dmx_init failed: error %d",ret);
111 goto err_dmx; 111 goto err_dmx;
112 } 112 }
113 113
114 d->dmxdev.filternum = d->demux.filternum; 114 adap->dmxdev.filternum = adap->demux.filternum;
115 d->dmxdev.demux = &d->demux.dmx; 115 adap->dmxdev.demux = &adap->demux.dmx;
116 d->dmxdev.capabilities = 0; 116 adap->dmxdev.capabilities = 0;
117 if ((ret = dvb_dmxdev_init(&d->dmxdev, &d->dvb_adap)) < 0) { 117 if ((ret = dvb_dmxdev_init(&adap->dmxdev, &adap->dvb_adap)) < 0) {
118 err("dvb_dmxdev_init failed: error %d",ret); 118 err("dvb_dmxdev_init failed: error %d",ret);
119 goto err_dmx_dev; 119 goto err_dmx_dev;
120 } 120 }
121 121
122 dvb_net_init(&d->dvb_adap, &d->dvb_net, &d->demux.dmx); 122 dvb_net_init(&adap->dvb_adap, &adap->dvb_net, &adap->demux.dmx);
123 123
124 d->state |= DVB_USB_STATE_DVB; 124 adap->state |= DVB_USB_ADAP_STATE_DVB;
125 return 0; 125 return 0;
126 126
127err_dmx_dev: 127err_dmx_dev:
128 dvb_dmx_release(&d->demux); 128 dvb_dmx_release(&adap->demux);
129err_dmx: 129err_dmx:
130 dvb_unregister_adapter(&d->dvb_adap); 130 dvb_unregister_adapter(&adap->dvb_adap);
131err: 131err:
132 return ret; 132 return ret;
133} 133}
134 134
135int dvb_usb_dvb_exit(struct dvb_usb_device *d) 135int dvb_usb_adapter_dvb_exit(struct dvb_usb_adapter *adap)
136{ 136{
137 if (d->state & DVB_USB_STATE_DVB) { 137 if (adap->state & DVB_USB_ADAP_STATE_DVB) {
138 deb_info("unregistering DVB part\n"); 138 deb_info("unregistering DVB part\n");
139 dvb_net_release(&d->dvb_net); 139 dvb_net_release(&adap->dvb_net);
140 d->demux.dmx.close(&d->demux.dmx); 140 adap->demux.dmx.close(&adap->demux.dmx);
141 dvb_dmxdev_release(&d->dmxdev); 141 dvb_dmxdev_release(&adap->dmxdev);
142 dvb_dmx_release(&d->demux); 142 dvb_dmx_release(&adap->demux);
143 dvb_unregister_adapter(&d->dvb_adap); 143 dvb_unregister_adapter(&adap->dvb_adap);
144 d->state &= ~DVB_USB_STATE_DVB; 144 adap->state &= ~DVB_USB_ADAP_STATE_DVB;
145 } 145 }
146 return 0; 146 return 0;
147} 147}
148 148
149static int dvb_usb_fe_wakeup(struct dvb_frontend *fe) 149static int dvb_usb_fe_wakeup(struct dvb_frontend *fe)
150{ 150{
151 struct dvb_usb_device *d = fe->dvb->priv; 151 struct dvb_usb_adapter *adap = fe->dvb->priv;
152 152
153 if (d->props.power_ctrl) 153 dvb_usb_device_power_ctrl(adap->dev, 1);
154 d->props.power_ctrl(d,1);
155 154
156 if (d->fe_init) 155 if (adap->fe_init)
157 d->fe_init(fe); 156 adap->fe_init(fe);
158 157
159 return 0; 158 return 0;
160} 159}
161 160
162static int dvb_usb_fe_sleep(struct dvb_frontend *fe) 161static int dvb_usb_fe_sleep(struct dvb_frontend *fe)
163{ 162{
164 struct dvb_usb_device *d = fe->dvb->priv; 163 struct dvb_usb_adapter *adap = fe->dvb->priv;
165 164
166 if (d->fe_sleep) 165 if (adap->fe_sleep)
167 d->fe_sleep(fe); 166 adap->fe_sleep(fe);
168 167
169 if (d->props.power_ctrl) 168 return dvb_usb_device_power_ctrl(adap->dev, 0);
170 d->props.power_ctrl(d,0);
171
172 return 0;
173} 169}
174 170
175int dvb_usb_fe_init(struct dvb_usb_device* d) 171int dvb_usb_adapter_frontend_init(struct dvb_usb_adapter *adap)
176{ 172{
177 if (d->props.frontend_attach == NULL) { 173 if (adap->props.frontend_attach == NULL) {
178 err("strange: '%s' doesn't want to attach a frontend.",d->desc->name); 174 err("strange: '%s' #%d doesn't want to attach a frontend.",adap->dev->desc->name, adap->id);
179 return 0; 175 return 0;
180 } 176 }
181 177
182 /* re-assign sleep and wakeup functions */ 178 /* re-assign sleep and wakeup functions */
183 if (d->props.frontend_attach(d) == 0 && d->fe != NULL) { 179 if (adap->props.frontend_attach(adap) == 0 && adap->fe != NULL) {
184 d->fe_init = d->fe->ops.init; d->fe->ops.init = dvb_usb_fe_wakeup; 180 adap->fe_init = adap->fe->ops.init; adap->fe->ops.init = dvb_usb_fe_wakeup;
185 d->fe_sleep = d->fe->ops.sleep; d->fe->ops.sleep = dvb_usb_fe_sleep; 181 adap->fe_sleep = adap->fe->ops.sleep; adap->fe->ops.sleep = dvb_usb_fe_sleep;
186 182
187 if (dvb_register_frontend(&d->dvb_adap, d->fe)) { 183 if (dvb_register_frontend(&adap->dvb_adap, adap->fe)) {
188 err("Frontend registration failed."); 184 err("Frontend registration failed.");
189 dvb_frontend_detach(d->fe); 185 dvb_frontend_detach(adap->fe);
190 d->fe = NULL; 186 adap->fe = NULL;
191 return -ENODEV; 187 return -ENODEV;
192 } 188 }
193 189
194 /* only attach the tuner if the demod is there */ 190 /* only attach the tuner if the demod is there */
195 if (d->props.tuner_attach != NULL) 191 if (adap->props.tuner_attach != NULL)
196 d->props.tuner_attach(d); 192 adap->props.tuner_attach(adap);
197 } else 193 } else
198 err("no frontend was attached by '%s'",d->desc->name); 194 err("no frontend was attached by '%s'",adap->dev->desc->name);
199 195
200 return 0; 196 return 0;
201} 197}
202 198
203int dvb_usb_fe_exit(struct dvb_usb_device *d) 199int dvb_usb_adapter_frontend_exit(struct dvb_usb_adapter *adap)
204{ 200{
205 if (d->fe != NULL) { 201 if (adap->fe != NULL) {
206 dvb_unregister_frontend(d->fe); 202 dvb_unregister_frontend(adap->fe);
207 dvb_frontend_detach(d->fe); 203 dvb_frontend_detach(adap->fe);
208 } 204 }
209 return 0; 205 return 0;
210} 206}
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-firmware.c b/drivers/media/dvb/dvb-usb/dvb-usb-firmware.c
index 9222b0a81f74..e1112e39fb63 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-firmware.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-firmware.c
@@ -1,6 +1,6 @@
1/* dvb-usb-firmware.c is part of the DVB USB library. 1/* dvb-usb-firmware.c is part of the DVB USB library.
2 * 2 *
3 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) 3 * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de)
4 * see dvb-usb-init.c for copyright information. 4 * see dvb-usb-init.c for copyright information.
5 * 5 *
6 * This file contains functions for downloading the firmware to Cypress FX 1 and 2 based devices. 6 * This file contains functions for downloading the firmware to Cypress FX 1 and 2 based devices.
@@ -24,9 +24,6 @@ static struct usb_cypress_controller cypress[] = {
24 { .id = CYPRESS_FX2, .name = "Cypress FX2", .cpu_cs_register = 0xe600 }, 24 { .id = CYPRESS_FX2, .name = "Cypress FX2", .cpu_cs_register = 0xe600 },
25}; 25};
26 26
27static int dvb_usb_get_hexline(const struct firmware *fw, struct hexline *hx,
28 int *pos);
29
30/* 27/*
31 * load a firmware packet to the device 28 * load a firmware packet to the device
32 */ 29 */
@@ -78,7 +75,7 @@ int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw
78} 75}
79EXPORT_SYMBOL(usb_cypress_load_firmware); 76EXPORT_SYMBOL(usb_cypress_load_firmware);
80 77
81int dvb_usb_download_firmware(struct usb_device *udev, struct dvb_usb_properties *props) 78int dvb_usb_download_firmware(struct usb_device *udev, struct dvb_usb_device_properties *props)
82{ 79{
83 int ret; 80 int ret;
84 const struct firmware *fw = NULL; 81 const struct firmware *fw = NULL;
@@ -115,7 +112,7 @@ int dvb_usb_download_firmware(struct usb_device *udev, struct dvb_usb_properties
115 return ret; 112 return ret;
116} 113}
117 114
118static int dvb_usb_get_hexline(const struct firmware *fw, struct hexline *hx, 115int dvb_usb_get_hexline(const struct firmware *fw, struct hexline *hx,
119 int *pos) 116 int *pos)
120{ 117{
121 u8 *b = (u8 *) &fw->data[*pos]; 118 u8 *b = (u8 *) &fw->data[*pos];
@@ -146,3 +143,4 @@ static int dvb_usb_get_hexline(const struct firmware *fw, struct hexline *hx,
146 143
147 return *pos; 144 return *pos;
148} 145}
146EXPORT_SYMBOL(dvb_usb_get_hexline);
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c b/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c
index 6b611a725093..55ba020386c9 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c
@@ -1,6 +1,6 @@
1/* dvb-usb-i2c.c is part of the DVB USB library. 1/* dvb-usb-i2c.c is part of the DVB USB library.
2 * 2 *
3 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) 3 * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de)
4 * see dvb-usb-init.c for copyright information. 4 * see dvb-usb-init.c for copyright information.
5 * 5 *
6 * This file contains functions for (de-)initializing an I2C adapter. 6 * This file contains functions for (de-)initializing an I2C adapter.
@@ -48,48 +48,48 @@ int dvb_usb_i2c_exit(struct dvb_usb_device *d)
48 48
49int dvb_usb_tuner_init_i2c(struct dvb_frontend *fe) 49int dvb_usb_tuner_init_i2c(struct dvb_frontend *fe)
50{ 50{
51 struct dvb_usb_device *d = fe->dvb->priv; 51 struct dvb_usb_adapter *adap = fe->dvb->priv;
52 struct i2c_msg msg = { .addr = d->pll_addr, .flags = 0, .buf = d->pll_init, .len = 4 }; 52 struct i2c_msg msg = { .addr = adap->pll_addr, .flags = 0, .buf = adap->pll_init, .len = 4 };
53 int ret = 0; 53 int ret = 0;
54 54
55 /* if pll_desc is not used */ 55 /* if pll_desc is not used */
56 if (d->pll_desc == NULL) 56 if (adap->pll_desc == NULL)
57 return 0; 57 return 0;
58 58
59 if (d->tuner_pass_ctrl) 59 if (adap->tuner_pass_ctrl)
60 d->tuner_pass_ctrl(fe,1,d->pll_addr); 60 adap->tuner_pass_ctrl(fe, 1, adap->pll_addr);
61 61
62 deb_pll("pll init: %x\n",d->pll_addr); 62 deb_pll("pll init: %x\n",adap->pll_addr);
63 deb_pll("pll-buf: %x %x %x %x\n",d->pll_init[0],d->pll_init[1], 63 deb_pll("pll-buf: %x %x %x %x\n",adap->pll_init[0], adap->pll_init[1],
64 d->pll_init[2],d->pll_init[3]); 64 adap->pll_init[2], adap->pll_init[3]);
65 65
66 if (fe->ops.i2c_gate_ctrl) 66 if (fe->ops.i2c_gate_ctrl)
67 fe->ops.i2c_gate_ctrl(fe, 1); 67 fe->ops.i2c_gate_ctrl(fe, 1);
68 if (i2c_transfer (&d->i2c_adap, &msg, 1) != 1) { 68 if (i2c_transfer (&adap->dev->i2c_adap, &msg, 1) != 1) {
69 err("tuner i2c write failed for pll_init."); 69 err("tuner i2c write failed for pll_init.");
70 ret = -EREMOTEIO; 70 ret = -EREMOTEIO;
71 } 71 }
72 msleep(1); 72 msleep(1);
73 73
74 if (d->tuner_pass_ctrl) 74 if (adap->tuner_pass_ctrl)
75 d->tuner_pass_ctrl(fe,0,d->pll_addr); 75 adap->tuner_pass_ctrl(fe,0,adap->pll_addr);
76 return ret; 76 return ret;
77} 77}
78EXPORT_SYMBOL(dvb_usb_tuner_init_i2c); 78EXPORT_SYMBOL(dvb_usb_tuner_init_i2c);
79 79
80int dvb_usb_tuner_calc_regs(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep, u8 *b, int buf_len) 80int dvb_usb_tuner_calc_regs(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep, u8 *b, int buf_len)
81{ 81{
82 struct dvb_usb_device *d = fe->dvb->priv; 82 struct dvb_usb_adapter *adap = fe->dvb->priv;
83 83
84 if (buf_len != 5) 84 if (buf_len != 5)
85 return -EINVAL; 85 return -EINVAL;
86 if (d->pll_desc == NULL) 86 if (adap->pll_desc == NULL)
87 return 0; 87 return 0;
88 88
89 deb_pll("pll addr: %x, freq: %d %p\n",d->pll_addr,fep->frequency,d->pll_desc); 89 deb_pll("pll addr: %x, freq: %d %p\n",adap->pll_addr, fep->frequency, adap->pll_desc);
90 90
91 b[0] = d->pll_addr; 91 b[0] = adap->pll_addr;
92 dvb_pll_configure(d->pll_desc,&b[1],fep->frequency,fep->u.ofdm.bandwidth); 92 dvb_pll_configure(adap->pll_desc, &b[1], fep->frequency, fep->u.ofdm.bandwidth);
93 93
94 deb_pll("pll-buf: %x %x %x %x %x\n",b[0],b[1],b[2],b[3],b[4]); 94 deb_pll("pll-buf: %x %x %x %x %x\n",b[0],b[1],b[2],b[3],b[4]);
95 95
@@ -99,26 +99,27 @@ EXPORT_SYMBOL(dvb_usb_tuner_calc_regs);
99 99
100int dvb_usb_tuner_set_params_i2c(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep) 100int dvb_usb_tuner_set_params_i2c(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep)
101{ 101{
102 struct dvb_usb_device *d = fe->dvb->priv; 102 struct dvb_usb_adapter *adap = fe->dvb->priv;
103 int ret = 0; 103 int ret = 0;
104 u8 b[5]; 104 u8 b[5];
105 struct i2c_msg msg = { .addr = d->pll_addr, .flags = 0, .buf = &b[1], .len = 4 }; 105 struct i2c_msg msg = { .addr = adap->pll_addr, .flags = 0, .buf = &b[1], .len = 4 };
106 106
107 dvb_usb_tuner_calc_regs(fe,fep,b,5); 107 dvb_usb_tuner_calc_regs(fe,fep,b,5);
108 108
109 if (d->tuner_pass_ctrl) 109 if (adap->tuner_pass_ctrl)
110 d->tuner_pass_ctrl(fe,1,d->pll_addr); 110 adap->tuner_pass_ctrl(fe, 1, adap->pll_addr);
111 111
112 if (fe->ops.i2c_gate_ctrl) 112 if (fe->ops.i2c_gate_ctrl)
113 fe->ops.i2c_gate_ctrl(fe, 1); 113 fe->ops.i2c_gate_ctrl(fe, 1);
114 if (i2c_transfer (&d->i2c_adap, &msg, 1) != 1) { 114
115 if (i2c_transfer(&adap->dev->i2c_adap, &msg, 1) != 1) {
115 err("tuner i2c write failed for pll_set."); 116 err("tuner i2c write failed for pll_set.");
116 ret = -EREMOTEIO; 117 ret = -EREMOTEIO;
117 } 118 }
118 msleep(1); 119 msleep(1);
119 120
120 if (d->tuner_pass_ctrl) 121 if (adap->tuner_pass_ctrl)
121 d->tuner_pass_ctrl(fe,0,d->pll_addr); 122 adap->tuner_pass_ctrl(fe, 0, adap->pll_addr);
122 123
123 return ret; 124 return ret;
124} 125}
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
index 57a10de1d3dd..4d6b069536ce 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
@@ -52,8 +52,7 @@
52#define USB_PID_DIBCOM_MOD3000_WARM 0x0bb9 52#define USB_PID_DIBCOM_MOD3000_WARM 0x0bb9
53#define USB_PID_DIBCOM_MOD3001_COLD 0x0bc6 53#define USB_PID_DIBCOM_MOD3001_COLD 0x0bc6
54#define USB_PID_DIBCOM_MOD3001_WARM 0x0bc7 54#define USB_PID_DIBCOM_MOD3001_WARM 0x0bc7
55#define USB_PID_DIBCOM_STK7700 0x1e14 55#define USB_PID_DIBCOM_STK7700P 0x1e14
56#define USB_PID_DIBCOM_STK7700_REENUM 0x1e15
57#define USB_PID_DIBCOM_ANCHOR_2135_COLD 0x2131 56#define USB_PID_DIBCOM_ANCHOR_2135_COLD 0x2131
58#define USB_PID_GRANDTEC_DVBT_USB_COLD 0x0fa0 57#define USB_PID_GRANDTEC_DVBT_USB_COLD 0x0fa0
59#define USB_PID_GRANDTEC_DVBT_USB_WARM 0x0fa1 58#define USB_PID_GRANDTEC_DVBT_USB_WARM 0x0fa1
@@ -95,6 +94,10 @@
95#define USB_PID_WT220U_ZL0353_WARM 0x022b 94#define USB_PID_WT220U_ZL0353_WARM 0x022b
96#define USB_PID_WINTV_NOVA_T_USB2_COLD 0x9300 95#define USB_PID_WINTV_NOVA_T_USB2_COLD 0x9300
97#define USB_PID_WINTV_NOVA_T_USB2_WARM 0x9301 96#define USB_PID_WINTV_NOVA_T_USB2_WARM 0x9301
97#define USB_PID_HAUPPAUGE_NOVA_T_500 0x9941
98#define USB_PID_HAUPPAUGE_NOVA_T_500_2 0x9950
99#define USB_PID_HAUPPAUGE_NOVA_T_STICK 0x7050
100#define USB_PID_AVERMEDIA_VOLAR 0x1234
98#define USB_PID_NEBULA_DIGITV 0x0201 101#define USB_PID_NEBULA_DIGITV 0x0201
99#define USB_PID_DVICO_BLUEBIRD_LGDT 0xd820 102#define USB_PID_DVICO_BLUEBIRD_LGDT 0xd820
100#define USB_PID_DVICO_BLUEBIRD_LG064F_COLD 0xd500 103#define USB_PID_DVICO_BLUEBIRD_LG064F_COLD 0xd500
@@ -103,10 +106,12 @@
103#define USB_PID_DVICO_BLUEBIRD_LGZ201_WARM 0xdb01 106#define USB_PID_DVICO_BLUEBIRD_LGZ201_WARM 0xdb01
104#define USB_PID_DVICO_BLUEBIRD_TH7579_COLD 0xdb10 107#define USB_PID_DVICO_BLUEBIRD_TH7579_COLD 0xdb10
105#define USB_PID_DVICO_BLUEBIRD_TH7579_WARM 0xdb11 108#define USB_PID_DVICO_BLUEBIRD_TH7579_WARM 0xdb11
106#define USB_PID_DVICO_BLUEBIRD_DEE1601_COLD 0xdb50 109#define USB_PID_DVICO_BLUEBIRD_DUAL_1_COLD 0xdb50
107#define USB_PID_DVICO_BLUEBIRD_DEE1601_WARM 0xdb51 110#define USB_PID_DVICO_BLUEBIRD_DUAL_1_WARM 0xdb51
108#define USB_PID_DIGITALNOW_BLUEBIRD_DEE1601_COLD 0xdb54 111#define USB_PID_DVICO_BLUEBIRD_DUAL_2_COLD 0xdb58
109#define USB_PID_DIGITALNOW_BLUEBIRD_DEE1601_WARM 0xdb55 112#define USB_PID_DVICO_BLUEBIRD_DUAL_2_WARM 0xdb59
113#define USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_COLD 0xdb54
114#define USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_WARM 0xdb55
110#define USB_PID_MEDION_MD95700 0x0932 115#define USB_PID_MEDION_MD95700 0x0932
111#define USB_PID_KYE_DVB_T_COLD 0x701e 116#define USB_PID_KYE_DVB_T_COLD 0x701e
112#define USB_PID_KYE_DVB_T_WARM 0x701f 117#define USB_PID_KYE_DVB_T_WARM 0x701f
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-init.c b/drivers/media/dvb/dvb-usb/dvb-usb-init.c
index a1705ecb9a54..ffdde83d1e77 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-init.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-init.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * dvb-usb-init.c 4 * dvb-usb-init.c
5 * 5 *
6 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) 6 * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de)
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify it 8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the Free 9 * under the terms of the GNU General Public License as published by the Free
@@ -16,21 +16,105 @@
16/* debug */ 16/* debug */
17int dvb_usb_debug; 17int dvb_usb_debug;
18module_param_named(debug,dvb_usb_debug, int, 0644); 18module_param_named(debug,dvb_usb_debug, int, 0644);
19MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,pll=4,ts=8,err=16,rc=32,fw=64 (or-able))." DVB_USB_DEBUG_STATUS); 19MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,pll=4,ts=8,err=16,rc=32,fw=64,mem=128,uxfer=256 (or-able))." DVB_USB_DEBUG_STATUS);
20 20
21int dvb_usb_disable_rc_polling; 21int dvb_usb_disable_rc_polling;
22module_param_named(disable_rc_polling, dvb_usb_disable_rc_polling, int, 0644); 22module_param_named(disable_rc_polling, dvb_usb_disable_rc_polling, int, 0644);
23MODULE_PARM_DESC(disable_rc_polling, "disable remote control polling (default: 0)."); 23MODULE_PARM_DESC(disable_rc_polling, "disable remote control polling (default: 0).");
24 24
25static int dvb_usb_force_pid_filter_usage;
26module_param_named(force_pid_filter_usage, dvb_usb_force_pid_filter_usage, int, 0444);
27MODULE_PARM_DESC(disable_rc_polling, "force all dvb-usb-devices to use a PID filter, if any (default: 0).");
28
29static int dvb_usb_adapter_init(struct dvb_usb_device *d)
30{
31 struct dvb_usb_adapter *adap;
32 int ret,n;
33
34 for (n = 0; n < d->props.num_adapters; n++) {
35 adap = &d->adapter[n];
36 adap->dev = d;
37 adap->id = n;
38
39 memcpy(&adap->props, &d->props.adapter[n], sizeof(struct dvb_usb_adapter_properties));
40
41/* speed - when running at FULL speed we need a HW PID filter */
42 if (d->udev->speed == USB_SPEED_FULL && !(adap->props.caps & DVB_USB_ADAP_HAS_PID_FILTER)) {
43 err("This USB2.0 device cannot be run on a USB1.1 port. (it lacks a hardware PID filter)");
44 return -ENODEV;
45 }
46
47 if ((d->udev->speed == USB_SPEED_FULL && adap->props.caps & DVB_USB_ADAP_HAS_PID_FILTER) ||
48 (adap->props.caps & DVB_USB_ADAP_NEED_PID_FILTERING)) {
49 info("will use the device's hardware PID filter (table count: %d).",adap->props.pid_filter_count);
50 adap->pid_filtering = 1;
51 adap->max_feed_count = adap->props.pid_filter_count;
52 } else {
53 info("will pass the complete MPEG2 transport stream to the software demuxer.");
54 adap->pid_filtering = 0;
55 adap->max_feed_count = 255;
56 }
57
58 if (!adap->pid_filtering &&
59 dvb_usb_force_pid_filter_usage &&
60 adap->props.caps & DVB_USB_ADAP_HAS_PID_FILTER) {
61 info("pid filter enabled by module option.");
62 adap->pid_filtering = 1;
63 adap->max_feed_count = adap->props.pid_filter_count;
64 }
65
66 if (adap->props.size_of_priv > 0) {
67 adap->priv = kzalloc(adap->props.size_of_priv,GFP_KERNEL);
68 if (adap->priv == NULL) {
69 err("no memory for priv for adapter %d.",n);
70 return -ENOMEM;
71 }
72 }
73
74 if ((ret = dvb_usb_adapter_stream_init(adap)) ||
75 (ret = dvb_usb_adapter_dvb_init(adap)) ||
76 (ret = dvb_usb_adapter_frontend_init(adap))) {
77 return ret;
78 }
79
80 d->num_adapters_initialized++;
81 d->state |= DVB_USB_STATE_DVB;
82 }
83
84 /*
85 * when reloading the driver w/o replugging the device
86 * sometimes a timeout occures, this helps
87 */
88 if (d->props.generic_bulk_ctrl_endpoint != 0) {
89 usb_clear_halt(d->udev,usb_sndbulkpipe(d->udev,d->props.generic_bulk_ctrl_endpoint));
90 usb_clear_halt(d->udev,usb_rcvbulkpipe(d->udev,d->props.generic_bulk_ctrl_endpoint));
91 }
92
93 return 0;
94}
95
96static int dvb_usb_adapter_exit(struct dvb_usb_device *d)
97{
98 int n;
99 for (n = 0; n < d->num_adapters_initialized; n++) {
100 dvb_usb_adapter_frontend_exit(&d->adapter[n]);
101 dvb_usb_adapter_dvb_exit(&d->adapter[n]);
102 dvb_usb_adapter_stream_exit(&d->adapter[n]);
103 kfree(d->adapter[n].priv);
104 }
105 d->num_adapters_initialized = 0;
106 d->state &= ~DVB_USB_STATE_DVB;
107 return 0;
108}
109
110
25/* general initialization functions */ 111/* general initialization functions */
26static int dvb_usb_exit(struct dvb_usb_device *d) 112static int dvb_usb_exit(struct dvb_usb_device *d)
27{ 113{
28 deb_info("state before exiting everything: %x\n",d->state); 114 deb_info("state before exiting everything: %x\n",d->state);
29 dvb_usb_remote_exit(d); 115 dvb_usb_remote_exit(d);
30 dvb_usb_fe_exit(d); 116 dvb_usb_adapter_exit(d);
31 dvb_usb_i2c_exit(d); 117 dvb_usb_i2c_exit(d);
32 dvb_usb_dvb_exit(d);
33 dvb_usb_urb_exit(d);
34 deb_info("state should be zero now: %x\n",d->state); 118 deb_info("state should be zero now: %x\n",d->state);
35 d->state = DVB_USB_STATE_INIT; 119 d->state = DVB_USB_STATE_INIT;
36 kfree(d->priv); 120 kfree(d->priv);
@@ -47,32 +131,19 @@ static int dvb_usb_init(struct dvb_usb_device *d)
47 131
48 d->state = DVB_USB_STATE_INIT; 132 d->state = DVB_USB_STATE_INIT;
49 133
50/* check the capabilities and set appropriate variables */ 134 if (d->props.size_of_priv > 0) {
51 135 d->priv = kzalloc(d->props.size_of_priv,GFP_KERNEL);
52/* speed - when running at FULL speed we need a HW PID filter */ 136 if (d->priv == NULL) {
53 if (d->udev->speed == USB_SPEED_FULL && !(d->props.caps & DVB_USB_HAS_PID_FILTER)) { 137 err("no memory for priv in 'struct dvb_usb_device'");
54 err("This USB2.0 device cannot be run on a USB1.1 port. (it lacks a hardware PID filter)"); 138 return -ENOMEM;
55 return -ENODEV; 139 }
56 }
57
58 if ((d->udev->speed == USB_SPEED_FULL && d->props.caps & DVB_USB_HAS_PID_FILTER) ||
59 (d->props.caps & DVB_USB_NEED_PID_FILTERING)) {
60 info("will use the device's hardware PID filter (table count: %d).",d->props.pid_filter_count);
61 d->pid_filtering = 1;
62 d->max_feed_count = d->props.pid_filter_count;
63 } else {
64 info("will pass the complete MPEG2 transport stream to the software demuxer.");
65 d->pid_filtering = 0;
66 d->max_feed_count = 255;
67 } 140 }
68 141
69 if (d->props.power_ctrl) 142/* check the capabilities and set appropriate variables */
70 d->props.power_ctrl(d,1); 143 dvb_usb_device_power_ctrl(d, 1);
71 144
72 if ((ret = dvb_usb_urb_init(d)) || 145 if ((ret = dvb_usb_i2c_init(d)) ||
73 (ret = dvb_usb_dvb_init(d)) || 146 (ret = dvb_usb_adapter_init(d))) {
74 (ret = dvb_usb_i2c_init(d)) ||
75 (ret = dvb_usb_fe_init(d))) {
76 dvb_usb_exit(d); 147 dvb_usb_exit(d);
77 return ret; 148 return ret;
78 } 149 }
@@ -80,14 +151,13 @@ static int dvb_usb_init(struct dvb_usb_device *d)
80 if ((ret = dvb_usb_remote_init(d))) 151 if ((ret = dvb_usb_remote_init(d)))
81 err("could not initialize remote control."); 152 err("could not initialize remote control.");
82 153
83 if (d->props.power_ctrl) 154 dvb_usb_device_power_ctrl(d, 0);
84 d->props.power_ctrl(d,0);
85 155
86 return 0; 156 return 0;
87} 157}
88 158
89/* determine the name and the state of the just found USB device */ 159/* determine the name and the state of the just found USB device */
90static struct dvb_usb_device_description * dvb_usb_find_device(struct usb_device *udev,struct dvb_usb_properties *props, int *cold) 160static struct dvb_usb_device_description * dvb_usb_find_device(struct usb_device *udev,struct dvb_usb_device_properties *props, int *cold)
91{ 161{
92 int i,j; 162 int i,j;
93 struct dvb_usb_device_description *desc = NULL; 163 struct dvb_usb_device_description *desc = NULL;
@@ -125,11 +195,25 @@ static struct dvb_usb_device_description * dvb_usb_find_device(struct usb_device
125 return desc; 195 return desc;
126} 196}
127 197
198int dvb_usb_device_power_ctrl(struct dvb_usb_device *d, int onoff)
199{
200 if (onoff)
201 d->powered++;
202 else
203 d->powered--;
204
205 if (d->powered == 0 || (onoff && d->powered == 1)) { // when switching from 1 to 0 or from 0 to 1
206 deb_info("power control: %d\n", onoff);
207 if (d->props.power_ctrl)
208 return d->props.power_ctrl(d, onoff);
209 }
210 return 0;
211}
212
128/* 213/*
129 * USB 214 * USB
130 */ 215 */
131 216int dvb_usb_device_init(struct usb_interface *intf, struct dvb_usb_device_properties
132int dvb_usb_device_init(struct usb_interface *intf, struct dvb_usb_properties
133 *props, struct module *owner,struct dvb_usb_device **du) 217 *props, struct module *owner,struct dvb_usb_device **du)
134{ 218{
135 struct usb_device *udev = interface_to_usbdev(intf); 219 struct usb_device *udev = interface_to_usbdev(intf);
@@ -149,7 +233,7 @@ int dvb_usb_device_init(struct usb_interface *intf, struct dvb_usb_properties
149 if (cold) { 233 if (cold) {
150 info("found a '%s' in cold state, will try to load a firmware",desc->name); 234 info("found a '%s' in cold state, will try to load a firmware",desc->name);
151 ret = dvb_usb_download_firmware(udev,props); 235 ret = dvb_usb_download_firmware(udev,props);
152 if (!props->no_reconnect) 236 if (!props->no_reconnect || ret != 0)
153 return ret; 237 return ret;
154 } 238 }
155 239
@@ -161,19 +245,10 @@ int dvb_usb_device_init(struct usb_interface *intf, struct dvb_usb_properties
161 } 245 }
162 246
163 d->udev = udev; 247 d->udev = udev;
164 memcpy(&d->props,props,sizeof(struct dvb_usb_properties)); 248 memcpy(&d->props,props,sizeof(struct dvb_usb_device_properties));
165 d->desc = desc; 249 d->desc = desc;
166 d->owner = owner; 250 d->owner = owner;
167 251
168 if (d->props.size_of_priv > 0) {
169 d->priv = kzalloc(d->props.size_of_priv,GFP_KERNEL);
170 if (d->priv == NULL) {
171 err("no memory for priv in 'struct dvb_usb_device'");
172 kfree(d);
173 return -ENOMEM;
174 }
175 }
176
177 usb_set_intfdata(intf, d); 252 usb_set_intfdata(intf, d);
178 253
179 if (du != NULL) 254 if (du != NULL)
@@ -204,7 +279,7 @@ void dvb_usb_device_exit(struct usb_interface *intf)
204} 279}
205EXPORT_SYMBOL(dvb_usb_device_exit); 280EXPORT_SYMBOL(dvb_usb_device_exit);
206 281
207MODULE_VERSION("0.3"); 282MODULE_VERSION("1.0");
208MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>"); 283MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
209MODULE_DESCRIPTION("A library module containing commonly used USB and DVB function USB DVB devices"); 284MODULE_DESCRIPTION("A library module containing commonly used USB and DVB function USB DVB devices");
210MODULE_LICENSE("GPL"); 285MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
index 380b2a45ee4c..0a3a0b6c2350 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
@@ -1,6 +1,6 @@
1/* dvb-usb-remote.c is part of the DVB USB library. 1/* dvb-usb-remote.c is part of the DVB USB library.
2 * 2 *
3 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) 3 * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de)
4 * see dvb-usb-init.c for copyright information. 4 * see dvb-usb-init.c for copyright information.
5 * 5 *
6 * This file contains functions for initializing the the input-device and for handling remote-control-queries. 6 * This file contains functions for initializing the the input-device and for handling remote-control-queries.
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-urb.c b/drivers/media/dvb/dvb-usb/dvb-usb-urb.c
index 88b283731bb8..5cef12a07f72 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-urb.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-urb.c
@@ -1,9 +1,9 @@
1/* dvb-usb-urb.c is part of the DVB USB library. 1/* dvb-usb-urb.c is part of the DVB USB library.
2 * 2 *
3 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) 3 * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de)
4 * see dvb-usb-init.c for copyright information. 4 * see dvb-usb-init.c for copyright information.
5 * 5 *
6 * This file contains functions for initializing and handling the 6 * This file keeps functions for initializing and handling the
7 * USB and URB stuff. 7 * USB and URB stuff.
8 */ 8 */
9#include "dvb-usb-common.h" 9#include "dvb-usb-common.h"
@@ -64,260 +64,32 @@ int dvb_usb_generic_write(struct dvb_usb_device *d, u8 *buf, u16 len)
64} 64}
65EXPORT_SYMBOL(dvb_usb_generic_write); 65EXPORT_SYMBOL(dvb_usb_generic_write);
66 66
67 67static void dvb_usb_data_complete(struct usb_data_stream *stream, u8 *buffer, size_t length)
68/* URB stuff for streaming */
69static void dvb_usb_urb_complete(struct urb *urb, struct pt_regs *ptregs)
70{
71 struct dvb_usb_device *d = urb->context;
72 int ptype = usb_pipetype(urb->pipe);
73 int i;
74 u8 *b;
75
76 deb_ts("'%s' urb completed. feedcount: %d, status: %d, length: %d/%d, pack_num: %d, errors: %d\n",
77 ptype == PIPE_ISOCHRONOUS ? "isoc" : "bulk", d->feedcount,
78 urb->status,urb->actual_length,urb->transfer_buffer_length,
79 urb->number_of_packets,urb->error_count);
80
81 switch (urb->status) {
82 case 0: /* success */
83 break;
84 case -ECONNRESET: /* kill */
85 case -ENOENT:
86 case -ESHUTDOWN:
87 return;
88 default: /* error */
89 deb_ts("urb completition error %d.", urb->status);
90 break;
91 }
92
93 if (d->feedcount > 0) {
94 if (d->state & DVB_USB_STATE_DVB) {
95 switch (ptype) {
96 case PIPE_ISOCHRONOUS:
97 b = (u8 *) urb->transfer_buffer;
98 for (i = 0; i < urb->number_of_packets; i++) {
99 if (urb->iso_frame_desc[i].status != 0)
100 deb_ts("iso frame descriptor has an error: %d\n",urb->iso_frame_desc[i].status);
101 else if (urb->iso_frame_desc[i].actual_length > 0) {
102 dvb_dmx_swfilter(&d->demux,b + urb->iso_frame_desc[i].offset,
103 urb->iso_frame_desc[i].actual_length);
104 }
105 urb->iso_frame_desc[i].status = 0;
106 urb->iso_frame_desc[i].actual_length = 0;
107 }
108 debug_dump(b,20,deb_ts);
109 break;
110 case PIPE_BULK:
111 if (urb->actual_length > 0)
112 dvb_dmx_swfilter(&d->demux, (u8 *) urb->transfer_buffer,urb->actual_length);
113 break;
114 default:
115 err("unkown endpoint type in completition handler.");
116 return;
117 }
118 }
119 }
120
121 usb_submit_urb(urb,GFP_ATOMIC);
122}
123
124int dvb_usb_urb_kill(struct dvb_usb_device *d)
125{
126 int i;
127 for (i = 0; i < d->urbs_submitted; i++) {
128 deb_ts("killing URB no. %d.\n",i);
129
130 /* stop the URB */
131 usb_kill_urb(d->urb_list[i]);
132 }
133 d->urbs_submitted = 0;
134 return 0;
135}
136
137int dvb_usb_urb_submit(struct dvb_usb_device *d)
138{
139 int i,ret;
140 for (i = 0; i < d->urbs_initialized; i++) {
141 deb_ts("submitting URB no. %d\n",i);
142 if ((ret = usb_submit_urb(d->urb_list[i],GFP_ATOMIC))) {
143 err("could not submit URB no. %d - get them all back",i);
144 dvb_usb_urb_kill(d);
145 return ret;
146 }
147 d->urbs_submitted++;
148 }
149 return 0;
150}
151
152static int dvb_usb_free_stream_buffers(struct dvb_usb_device *d)
153{
154 if (d->state & DVB_USB_STATE_URB_BUF) {
155 while (d->buf_num) {
156 d->buf_num--;
157 deb_mem("freeing buffer %d\n",d->buf_num);
158 usb_buffer_free(d->udev, d->buf_size,
159 d->buf_list[d->buf_num], d->dma_addr[d->buf_num]);
160 }
161 kfree(d->buf_list);
162 kfree(d->dma_addr);
163 }
164
165 d->state &= ~DVB_USB_STATE_URB_BUF;
166
167 return 0;
168}
169
170static int dvb_usb_allocate_stream_buffers(struct dvb_usb_device *d, int num, unsigned long size)
171{
172 d->buf_num = 0;
173 d->buf_size = size;
174
175 deb_mem("all in all I will use %lu bytes for streaming\n",num*size);
176
177 if ((d->buf_list = kcalloc(num, sizeof(u8 *), GFP_ATOMIC)) == NULL)
178 return -ENOMEM;
179
180 if ((d->dma_addr = kcalloc(num, sizeof(dma_addr_t), GFP_ATOMIC)) == NULL) {
181 kfree(d->buf_list);
182 return -ENOMEM;
183 }
184
185 d->state |= DVB_USB_STATE_URB_BUF;
186
187 for (d->buf_num = 0; d->buf_num < num; d->buf_num++) {
188 deb_mem("allocating buffer %d\n",d->buf_num);
189 if (( d->buf_list[d->buf_num] =
190 usb_buffer_alloc(d->udev, size, SLAB_ATOMIC,
191 &d->dma_addr[d->buf_num]) ) == NULL) {
192 deb_mem("not enough memory for urb-buffer allocation.\n");
193 dvb_usb_free_stream_buffers(d);
194 return -ENOMEM;
195 }
196 deb_mem("buffer %d: %p (dma: %llu)\n",
197 d->buf_num, d->buf_list[d->buf_num],
198 (unsigned long long)d->dma_addr[d->buf_num]);
199 memset(d->buf_list[d->buf_num],0,size);
200 }
201 deb_mem("allocation successful\n");
202
203 return 0;
204}
205
206static int dvb_usb_bulk_urb_init(struct dvb_usb_device *d)
207{ 68{
208 int i; 69 struct dvb_usb_adapter *adap = stream->user_priv;
209 70 if (adap->feedcount > 0 && adap->state & DVB_USB_ADAP_STATE_DVB)
210 if ((i = dvb_usb_allocate_stream_buffers(d,d->props.urb.count, 71 dvb_dmx_swfilter(&adap->demux, buffer, length);
211 d->props.urb.u.bulk.buffersize)) < 0)
212 return i;
213
214 /* allocate the URBs */
215 for (i = 0; i < d->props.urb.count; i++) {
216 if ((d->urb_list[i] = usb_alloc_urb(0,GFP_ATOMIC)) == NULL)
217 return -ENOMEM;
218
219 usb_fill_bulk_urb( d->urb_list[i], d->udev,
220 usb_rcvbulkpipe(d->udev,d->props.urb.endpoint),
221 d->buf_list[i],
222 d->props.urb.u.bulk.buffersize,
223 dvb_usb_urb_complete, d);
224
225 d->urb_list[i]->transfer_flags = 0;
226 d->urbs_initialized++;
227 }
228 return 0;
229} 72}
230 73
231static int dvb_usb_isoc_urb_init(struct dvb_usb_device *d) 74static void dvb_usb_data_complete_204(struct usb_data_stream *stream, u8 *buffer, size_t length)
232{ 75{
233 int i,j; 76 struct dvb_usb_adapter *adap = stream->user_priv;
234 77 if (adap->feedcount > 0 && adap->state & DVB_USB_ADAP_STATE_DVB)
235 if ((i = dvb_usb_allocate_stream_buffers(d,d->props.urb.count, 78 dvb_dmx_swfilter_204(&adap->demux, buffer, length);
236 d->props.urb.u.isoc.framesize*d->props.urb.u.isoc.framesperurb)) < 0)
237 return i;
238
239 /* allocate the URBs */
240 for (i = 0; i < d->props.urb.count; i++) {
241 struct urb *urb;
242 int frame_offset = 0;
243 if ((d->urb_list[i] =
244 usb_alloc_urb(d->props.urb.u.isoc.framesperurb,GFP_ATOMIC)) == NULL)
245 return -ENOMEM;
246
247 urb = d->urb_list[i];
248
249 urb->dev = d->udev;
250 urb->context = d;
251 urb->complete = dvb_usb_urb_complete;
252 urb->pipe = usb_rcvisocpipe(d->udev,d->props.urb.endpoint);
253 urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP;
254 urb->interval = d->props.urb.u.isoc.interval;
255 urb->number_of_packets = d->props.urb.u.isoc.framesperurb;
256 urb->transfer_buffer_length = d->buf_size;
257 urb->transfer_buffer = d->buf_list[i];
258 urb->transfer_dma = d->dma_addr[i];
259
260 for (j = 0; j < d->props.urb.u.isoc.framesperurb; j++) {
261 urb->iso_frame_desc[j].offset = frame_offset;
262 urb->iso_frame_desc[j].length = d->props.urb.u.isoc.framesize;
263 frame_offset += d->props.urb.u.isoc.framesize;
264 }
265
266 d->urbs_initialized++;
267 }
268 return 0;
269
270} 79}
271 80
272int dvb_usb_urb_init(struct dvb_usb_device *d) 81int dvb_usb_adapter_stream_init(struct dvb_usb_adapter *adap)
273{ 82{
274 /* 83 adap->stream.udev = adap->dev->udev;
275 * when reloading the driver w/o replugging the device 84 if (adap->props.caps & DVB_USB_ADAP_RECEIVES_204_BYTE_TS)
276 * sometimes a timeout occures, this helps 85 adap->stream.complete = dvb_usb_data_complete_204;
277 */ 86 else
278 if (d->props.generic_bulk_ctrl_endpoint != 0) { 87 adap->stream.complete = dvb_usb_data_complete;
279 usb_clear_halt(d->udev,usb_sndbulkpipe(d->udev,d->props.generic_bulk_ctrl_endpoint)); 88 adap->stream.user_priv = adap;
280 usb_clear_halt(d->udev,usb_rcvbulkpipe(d->udev,d->props.generic_bulk_ctrl_endpoint)); 89 return usb_urb_init(&adap->stream, &adap->props.stream);
281 }
282 usb_clear_halt(d->udev,usb_rcvbulkpipe(d->udev,d->props.urb.endpoint));
283
284 /* allocate the array for the data transfer URBs */
285 d->urb_list = kzalloc(d->props.urb.count * sizeof(struct urb *),GFP_KERNEL);
286 if (d->urb_list == NULL)
287 return -ENOMEM;
288 d->state |= DVB_USB_STATE_URB_LIST;
289
290 switch (d->props.urb.type) {
291 case DVB_USB_BULK:
292 return dvb_usb_bulk_urb_init(d);
293 case DVB_USB_ISOC:
294 return dvb_usb_isoc_urb_init(d);
295 default:
296 err("unkown URB-type for data transfer.");
297 return -EINVAL;
298 }
299} 90}
300 91
301int dvb_usb_urb_exit(struct dvb_usb_device *d) 92int dvb_usb_adapter_stream_exit(struct dvb_usb_adapter *adap)
302{ 93{
303 int i; 94 return usb_urb_exit(&adap->stream);
304
305 dvb_usb_urb_kill(d);
306
307 if (d->state & DVB_USB_STATE_URB_LIST) {
308 for (i = 0; i < d->urbs_initialized; i++) {
309 if (d->urb_list[i] != NULL) {
310 deb_mem("freeing URB no. %d.\n",i);
311 /* free the URBs */
312 usb_free_urb(d->urb_list[i]);
313 }
314 }
315 d->urbs_initialized = 0;
316 /* free the urb array */
317 kfree(d->urb_list);
318 d->state &= ~DVB_USB_STATE_URB_LIST;
319 }
320
321 dvb_usb_free_stream_buffers(d);
322 return 0;
323} 95}
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb.h b/drivers/media/dvb/dvb-usb/dvb-usb.h
index 97f8ea962438..376c45a8e779 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb.h
@@ -1,9 +1,11 @@
1/* dvb-usb.h is part of the DVB USB library. 1/* dvb-usb.h is part of the DVB USB library.
2 * 2 *
3 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) 3 * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de)
4 * see dvb-usb-init.c for copyright information. 4 * see dvb-usb-init.c for copyright information.
5 * 5 *
6 * the headerfile, all dvb-usb-drivers have to include. 6 * the headerfile, all dvb-usb-drivers have to include.
7 *
8 * TODO: clean-up the structures for unused fields and update the comments
7 */ 9 */
8#ifndef __DVB_USB_H__ 10#ifndef __DVB_USB_H__
9#define __DVB_USB_H__ 11#define __DVB_USB_H__
@@ -84,36 +86,84 @@ struct dvb_usb_rc_key {
84}; 86};
85 87
86struct dvb_usb_device; 88struct dvb_usb_device;
89struct dvb_usb_adapter;
90struct usb_data_stream;
91
92/**
93 * Properties of USB streaming - TODO this structure should be somewhere else
94 * describes the kind of USB transfer used for data-streaming.
95 * (BULK or ISOC)
96 */
97struct usb_data_stream_properties {
98#define USB_BULK 1
99#define USB_ISOC 2
100 int type;
101 int count;
102 int endpoint;
103
104 union {
105 struct {
106 int buffersize; /* per URB */
107 } bulk;
108 struct {
109 int framesperurb;
110 int framesize;
111 int interval;
112 } isoc;
113 } u;
114};
87 115
88/** 116/**
89 * struct dvb_usb_properties - properties of a dvb-usb-device 117 * struct dvb_usb_adapter_properties - properties of a dvb-usb-adapter.
118 * A DVB-USB-Adapter is basically a dvb_adapter which is present on a USB-device.
90 * @caps: capabilities of the DVB USB device. 119 * @caps: capabilities of the DVB USB device.
91 * @pid_filter_count: number of PID filter position in the optional hardware 120 * @pid_filter_count: number of PID filter position in the optional hardware
92 * PID-filter. 121 * PID-filter.
93 * 122 * @streaming_crtl: called to start and stop the MPEG2-TS streaming of the
123 * device (not URB submitting/killing).
124 * @pid_filter_ctrl: called to en/disable the PID filter, if any.
125 * @pid_filter: called to set/unset a PID for filtering.
126 * @frontend_attach: called to attach the possible frontends (fill fe-field
127 * of struct dvb_usb_device).
128 * @tuner_attach: called to attach the correct tuner and to fill pll_addr,
129 * pll_desc and pll_init_buf of struct dvb_usb_device).
130 * @stream: configuration of the USB streaming
131 */
132struct dvb_usb_adapter_properties {
133#define DVB_USB_ADAP_HAS_PID_FILTER 0x01
134#define DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF 0x02
135#define DVB_USB_ADAP_NEED_PID_FILTERING 0x04
136#define DVB_USB_ADAP_RECEIVES_204_BYTE_TS 0x08
137 int caps;
138 int pid_filter_count;
139
140 int (*streaming_ctrl) (struct dvb_usb_adapter *, int);
141 int (*pid_filter_ctrl) (struct dvb_usb_adapter *, int);
142 int (*pid_filter) (struct dvb_usb_adapter *, int, u16, int);
143
144 int (*frontend_attach) (struct dvb_usb_adapter *);
145 int (*tuner_attach) (struct dvb_usb_adapter *);
146
147 struct usb_data_stream_properties stream;
148
149 int size_of_priv;
150};
151
152/**
153 * struct dvb_usb_device_properties - properties of a dvb-usb-device
94 * @usb_ctrl: which USB device-side controller is in use. Needed for firmware 154 * @usb_ctrl: which USB device-side controller is in use. Needed for firmware
95 * download. 155 * download.
96 * @firmware: name of the firmware file. 156 * @firmware: name of the firmware file.
97 * @download_firmware: called to download the firmware when the usb_ctrl is 157 * @download_firmware: called to download the firmware when the usb_ctrl is
98 * DEVICE_SPECIFIC. 158 * DEVICE_SPECIFIC.
99 * @no_reconnect: device doesn't do a reconnect after downloading the firmware, 159 * @no_reconnect: device doesn't do a reconnect after downloading the firmware,
100 so do the warm initialization right after it 160 * so do the warm initialization right after it
101 161 *
102 * @size_of_priv: how many bytes shall be allocated for the private field 162 * @size_of_priv: how many bytes shall be allocated for the private field
103 * of struct dvb_usb_device. 163 * of struct dvb_usb_device.
104 * 164 *
105 * @power_ctrl: called to enable/disable power of the device. 165 * @power_ctrl: called to enable/disable power of the device.
106 * @streaming_crtl: called to start and stop the MPEG2-TS streaming of the
107 * device (not URB submitting/killing).
108 * @pid_filter_ctrl: called to en/disable the PID filter, if any.
109 * @pid_filter: called to set/unset a PID for filtering.
110 *
111 * @read_mac_address: called to read the MAC address of the device. 166 * @read_mac_address: called to read the MAC address of the device.
112 *
113 * @frontend_attach: called to attach the possible frontends (fill fe-field
114 * of struct dvb_usb_device).
115 * @tuner_attach: called to attach the correct tuner and to fill pll_addr,
116 * pll_desc and pll_init_buf of struct dvb_usb_device).
117 * @identify_state: called to determine the state (cold or warm), when it 167 * @identify_state: called to determine the state (cold or warm), when it
118 * is not distinguishable by the USB IDs. 168 * is not distinguishable by the USB IDs.
119 * 169 *
@@ -130,50 +180,40 @@ struct dvb_usb_device;
130 * is non-zero, one can use dvb_usb_generic_rw and dvb_usb_generic_write- 180 * is non-zero, one can use dvb_usb_generic_rw and dvb_usb_generic_write-
131 * helper functions. 181 * helper functions.
132 * 182 *
133 * @urb: describes the kind of USB transfer used for MPEG2-TS-streaming.
134 * (BULK or ISOC)
135 *
136 * @num_device_descs: number of struct dvb_usb_device_description in @devices 183 * @num_device_descs: number of struct dvb_usb_device_description in @devices
137 * @devices: array of struct dvb_usb_device_description compatibles with these 184 * @devices: array of struct dvb_usb_device_description compatibles with these
138 * properties. 185 * properties.
139 */ 186 */
140struct dvb_usb_properties { 187#define MAX_NO_OF_ADAPTER_PER_DEVICE 2
188struct dvb_usb_device_properties {
141 189
142#define DVB_USB_HAS_PID_FILTER 0x01 190#define DVB_USB_IS_AN_I2C_ADAPTER 0x01
143#define DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF 0x02
144#define DVB_USB_NEED_PID_FILTERING 0x04
145#define DVB_USB_IS_AN_I2C_ADAPTER 0x08
146 int caps; 191 int caps;
147 int pid_filter_count;
148 192
149#define DEVICE_SPECIFIC 0 193#define DEVICE_SPECIFIC 0
150#define CYPRESS_AN2135 1 194#define CYPRESS_AN2135 1
151#define CYPRESS_AN2235 2 195#define CYPRESS_AN2235 2
152#define CYPRESS_FX2 3 196#define CYPRESS_FX2 3
153 int usb_ctrl; 197 int usb_ctrl;
198 int (*download_firmware) (struct usb_device *, const struct firmware *);
154 const char firmware[FIRMWARE_NAME_MAX]; 199 const char firmware[FIRMWARE_NAME_MAX];
155 int (*download_firmware) (struct usb_device *, const struct firmware *); 200 int no_reconnect;
156 int no_reconnect;
157 201
158 int size_of_priv; 202 int size_of_priv;
159 203
160 int (*power_ctrl) (struct dvb_usb_device *, int); 204 int num_adapters;
161 int (*streaming_ctrl) (struct dvb_usb_device *, int); 205 struct dvb_usb_adapter_properties adapter[MAX_NO_OF_ADAPTER_PER_DEVICE];
162 int (*pid_filter_ctrl) (struct dvb_usb_device *, int);
163 int (*pid_filter) (struct dvb_usb_device *, int, u16, int);
164 206
207 int (*power_ctrl) (struct dvb_usb_device *, int);
165 int (*read_mac_address) (struct dvb_usb_device *, u8 []); 208 int (*read_mac_address) (struct dvb_usb_device *, u8 []);
166 int (*frontend_attach) (struct dvb_usb_device *); 209 int (*identify_state) (struct usb_device *, struct dvb_usb_device_properties *,
167 int (*tuner_attach) (struct dvb_usb_device *);
168
169 int (*identify_state) (struct usb_device *, struct dvb_usb_properties *,
170 struct dvb_usb_device_description **, int *); 210 struct dvb_usb_device_description **, int *);
171 211
172/* remote control properties */ 212/* remote control properties */
173#define REMOTE_NO_KEY_PRESSED 0x00 213#define REMOTE_NO_KEY_PRESSED 0x00
174#define REMOTE_KEY_PRESSED 0x01 214#define REMOTE_KEY_PRESSED 0x01
175#define REMOTE_KEY_REPEAT 0x02 215#define REMOTE_KEY_REPEAT 0x02
176 struct dvb_usb_rc_key *rc_key_map; 216 struct dvb_usb_rc_key *rc_key_map;
177 int rc_key_map_size; 217 int rc_key_map_size;
178 int (*rc_query) (struct dvb_usb_device *, u32 *, int *); 218 int (*rc_query) (struct dvb_usb_device *, u32 *, int *);
179 int rc_interval; 219 int rc_interval;
@@ -182,40 +222,12 @@ struct dvb_usb_properties {
182 222
183 int generic_bulk_ctrl_endpoint; 223 int generic_bulk_ctrl_endpoint;
184 224
185 struct {
186#define DVB_USB_BULK 1
187#define DVB_USB_ISOC 2
188 int type;
189 int count;
190 int endpoint;
191
192 union {
193 struct {
194 int buffersize; /* per URB */
195 } bulk;
196 struct {
197 int framesperurb;
198 int framesize;
199 int interval;
200 } isoc;
201 } u;
202 } urb;
203
204 int num_device_descs; 225 int num_device_descs;
205 struct dvb_usb_device_description devices[9]; 226 struct dvb_usb_device_description devices[9];
206}; 227};
207 228
208
209/** 229/**
210 * struct dvb_usb_device - object of a DVB USB device 230 * struct usb_data_stream - generic object of an USB stream
211 * @props: copy of the struct dvb_usb_properties this device belongs to.
212 * @desc: pointer to the device's struct dvb_usb_device_description.
213 * @state: initialization and runtime state of the device.
214 *
215 * @udev: pointer to the device's struct usb_device.
216 * @urb_list: array of dynamically allocated struct urb for the MPEG2-TS-
217 * streaming.
218 *
219 * @buf_num: number of buffer allocated. 231 * @buf_num: number of buffer allocated.
220 * @buf_size: size of each buffer in buf_list. 232 * @buf_size: size of each buffer in buf_list.
221 * @buf_list: array containing all allocate buffers for streaming. 233 * @buf_list: array containing all allocate buffers for streaming.
@@ -223,18 +235,40 @@ struct dvb_usb_properties {
223 * 235 *
224 * @urbs_initialized: number of URBs initialized. 236 * @urbs_initialized: number of URBs initialized.
225 * @urbs_submitted: number of URBs submitted. 237 * @urbs_submitted: number of URBs submitted.
238 */
239#define MAX_NO_URBS_FOR_DATA_STREAM 10
240struct usb_data_stream {
241 struct usb_device *udev;
242 struct usb_data_stream_properties props;
243
244#define USB_STATE_INIT 0x00
245#define USB_STATE_URB_BUF 0x01
246 int state;
247
248 void (*complete) (struct usb_data_stream *, u8 *, size_t);
249
250 struct urb *urb_list[MAX_NO_URBS_FOR_DATA_STREAM];
251 int buf_num;
252 unsigned long buf_size;
253 u8 *buf_list[MAX_NO_URBS_FOR_DATA_STREAM];
254 dma_addr_t dma_addr[MAX_NO_URBS_FOR_DATA_STREAM];
255
256 int urbs_initialized;
257 int urbs_submitted;
258
259 void *user_priv;
260};
261
262/**
263 * struct dvb_usb_adapter - a DVB adapter on a USB device
264 * @id: index of this adapter (starting with 0).
226 * 265 *
227 * @feedcount: number of reqested feeds (used for streaming-activation) 266 * @feedcount: number of reqested feeds (used for streaming-activation)
228 * @pid_filtering: is hardware pid_filtering used or not. 267 * @pid_filtering: is hardware pid_filtering used or not.
229 * 268 *
230 * @usb_mutex: semaphore of USB control messages (reading needs two messages)
231 * @i2c_mutex: semaphore for i2c-transfers
232 *
233 * @i2c_adap: device's i2c_adapter if it uses I2CoverUSB
234 * @pll_addr: I2C address of the tuner for programming 269 * @pll_addr: I2C address of the tuner for programming
235 * @pll_init: array containing the initialization buffer 270 * @pll_init: array containing the initialization buffer
236 * @pll_desc: pointer to the appropriate struct dvb_pll_desc 271 * @pll_desc: pointer to the appropriate struct dvb_pll_desc
237 *
238 * @tuner_pass_ctrl: called to (de)activate tuner passthru of the demod or the board 272 * @tuner_pass_ctrl: called to (de)activate tuner passthru of the demod or the board
239 * 273 *
240 * @dvb_adap: device's dvb_adapter. 274 * @dvb_adap: device's dvb_adapter.
@@ -244,8 +278,62 @@ struct dvb_usb_properties {
244 * @dvb_frontend: device's frontend. 278 * @dvb_frontend: device's frontend.
245 * @max_feed_count: how many feeds can be handled simultaneously by this 279 * @max_feed_count: how many feeds can be handled simultaneously by this
246 * device 280 * device
281 *
282 * @fe_init: rerouted frontend-init (wakeup) function.
247 * @fe_sleep: rerouted frontend-sleep function. 283 * @fe_sleep: rerouted frontend-sleep function.
248 * @fe_init: rerouted frontend-init (wakeup) function. 284 *
285 * @stream: the usb data stream.
286 */
287struct dvb_usb_adapter {
288 struct dvb_usb_device *dev;
289 struct dvb_usb_adapter_properties props;
290
291#define DVB_USB_ADAP_STATE_INIT 0x000
292#define DVB_USB_ADAP_STATE_DVB 0x001
293 int state;
294
295 u8 id;
296
297 int feedcount;
298 int pid_filtering;
299
300 /* tuner programming information */
301 u8 pll_addr;
302 u8 pll_init[4];
303 struct dvb_pll_desc *pll_desc;
304 int (*tuner_pass_ctrl) (struct dvb_frontend *, int, u8);
305
306 /* dvb */
307 struct dvb_adapter dvb_adap;
308 struct dmxdev dmxdev;
309 struct dvb_demux demux;
310 struct dvb_net dvb_net;
311 struct dvb_frontend *fe;
312 int max_feed_count;
313
314 int (*fe_init) (struct dvb_frontend *);
315 int (*fe_sleep) (struct dvb_frontend *);
316
317 struct usb_data_stream stream;
318
319 void *priv;
320};
321
322/**
323 * struct dvb_usb_device - object of a DVB USB device
324 * @props: copy of the struct dvb_usb_properties this device belongs to.
325 * @desc: pointer to the device's struct dvb_usb_device_description.
326 * @state: initialization and runtime state of the device.
327 *
328 * @powered: indicated whether the device is power or not.
329 * Powered is in/decremented for each call to modify the state.
330 * @udev: pointer to the device's struct usb_device.
331 *
332 * @usb_mutex: semaphore of USB control messages (reading needs two messages)
333 * @i2c_mutex: semaphore for i2c-transfers
334 *
335 * @i2c_adap: device's i2c_adapter if it uses I2CoverUSB
336 *
249 * @rc_input_dev: input device for the remote control. 337 * @rc_input_dev: input device for the remote control.
250 * @rc_query_work: struct work_struct frequent rc queries 338 * @rc_query_work: struct work_struct frequent rc queries
251 * @last_event: last triggered event 339 * @last_event: last triggered event
@@ -255,32 +343,18 @@ struct dvb_usb_properties {
255 * in size_of_priv of dvb_usb_properties). 343 * in size_of_priv of dvb_usb_properties).
256 */ 344 */
257struct dvb_usb_device { 345struct dvb_usb_device {
258 struct dvb_usb_properties props; 346 struct dvb_usb_device_properties props;
259 struct dvb_usb_device_description *desc; 347 struct dvb_usb_device_description *desc;
260 348
261#define DVB_USB_STATE_INIT 0x000
262#define DVB_USB_STATE_URB_LIST 0x001
263#define DVB_USB_STATE_URB_BUF 0x002
264#define DVB_USB_STATE_DVB 0x004
265#define DVB_USB_STATE_I2C 0x008
266#define DVB_USB_STATE_REMOTE 0x010
267#define DVB_USB_STATE_URB_SUBMIT 0x020
268 int state;
269
270 /* usb */
271 struct usb_device *udev; 349 struct usb_device *udev;
272 struct urb **urb_list;
273 350
274 int buf_num; 351#define DVB_USB_STATE_INIT 0x000
275 unsigned long buf_size; 352#define DVB_USB_STATE_I2C 0x001
276 u8 **buf_list; 353#define DVB_USB_STATE_DVB 0x002
277 dma_addr_t *dma_addr; 354#define DVB_USB_STATE_REMOTE 0x004
278 355 int state;
279 int urbs_initialized;
280 int urbs_submitted;
281 356
282 int feedcount; 357 int powered;
283 int pid_filtering;
284 358
285 /* locking */ 359 /* locking */
286 struct mutex usb_mutex; 360 struct mutex usb_mutex;
@@ -289,22 +363,8 @@ struct dvb_usb_device {
289 struct mutex i2c_mutex; 363 struct mutex i2c_mutex;
290 struct i2c_adapter i2c_adap; 364 struct i2c_adapter i2c_adap;
291 365
292 /* tuner programming information */ 366 int num_adapters_initialized;
293 u8 pll_addr; 367 struct dvb_usb_adapter adapter[MAX_NO_OF_ADAPTER_PER_DEVICE];
294 u8 pll_init[4];
295 struct dvb_pll_desc *pll_desc;
296 int (*tuner_pass_ctrl)(struct dvb_frontend *, int, u8);
297
298 /* dvb */
299 struct dvb_adapter dvb_adap;
300 struct dmxdev dmxdev;
301 struct dvb_demux demux;
302 struct dvb_net dvb_net;
303 struct dvb_frontend* fe;
304 int max_feed_count;
305
306 int (*fe_sleep) (struct dvb_frontend *);
307 int (*fe_init) (struct dvb_frontend *);
308 368
309 /* remote control */ 369 /* remote control */
310 struct input_dev *rc_input_dev; 370 struct input_dev *rc_input_dev;
@@ -318,7 +378,7 @@ struct dvb_usb_device {
318 void *priv; 378 void *priv;
319}; 379};
320 380
321extern int dvb_usb_device_init(struct usb_interface *, struct dvb_usb_properties *, struct module *, struct dvb_usb_device **); 381extern int dvb_usb_device_init(struct usb_interface *, struct dvb_usb_device_properties *, struct module *, struct dvb_usb_device **);
322extern void dvb_usb_device_exit(struct usb_interface *); 382extern void dvb_usb_device_exit(struct usb_interface *);
323 383
324/* the generic read/write method for device control */ 384/* the generic read/write method for device control */
@@ -342,5 +402,7 @@ struct hexline {
342 u8 chk; 402 u8 chk;
343}; 403};
344extern int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type); 404extern int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type);
405extern int dvb_usb_get_hexline(const struct firmware *fw, struct hexline *hx, int *pos);
406
345 407
346#endif 408#endif
diff --git a/drivers/media/dvb/dvb-usb/gp8psk.c b/drivers/media/dvb/dvb-usb/gp8psk.c
index 9a98f3fdae31..7375eb20166d 100644
--- a/drivers/media/dvb/dvb-usb/gp8psk.c
+++ b/drivers/media/dvb/dvb-usb/gp8psk.c
@@ -161,19 +161,18 @@ static int gp8psk_power_ctrl(struct dvb_usb_device *d, int onoff)
161} 161}
162 162
163 163
164static int gp8psk_streaming_ctrl(struct dvb_usb_device *d, int onoff) 164static int gp8psk_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
165{ 165{
166 return gp8psk_usb_out_op(d, ARM_TRANSFER, onoff, 0 , NULL, 0); 166 return gp8psk_usb_out_op(adap->dev, ARM_TRANSFER, onoff, 0 , NULL, 0);
167} 167}
168 168
169static int gp8psk_frontend_attach(struct dvb_usb_device *d) 169static int gp8psk_frontend_attach(struct dvb_usb_adapter *adap)
170{ 170{
171 d->fe = gp8psk_fe_attach(d); 171 adap->fe = gp8psk_fe_attach(adap->dev);
172
173 return 0; 172 return 0;
174} 173}
175 174
176static struct dvb_usb_properties gp8psk_properties; 175static struct dvb_usb_device_properties gp8psk_properties;
177 176
178static int gp8psk_usb_probe(struct usb_interface *intf, 177static int gp8psk_usb_probe(struct usb_interface *intf,
179 const struct usb_device_id *id) 178 const struct usb_device_id *id)
@@ -188,20 +187,18 @@ static struct usb_device_id gp8psk_usb_table [] = {
188}; 187};
189MODULE_DEVICE_TABLE(usb, gp8psk_usb_table); 188MODULE_DEVICE_TABLE(usb, gp8psk_usb_table);
190 189
191static struct dvb_usb_properties gp8psk_properties = { 190static struct dvb_usb_device_properties gp8psk_properties = {
192 .caps = 0,
193
194 .usb_ctrl = CYPRESS_FX2, 191 .usb_ctrl = CYPRESS_FX2,
195 .firmware = "dvb-usb-gp8psk-01.fw", 192 .firmware = "dvb-usb-gp8psk-01.fw",
196 193
194 .num_adapters = 1,
195 .adapter = {
196 {
197 .streaming_ctrl = gp8psk_streaming_ctrl, 197 .streaming_ctrl = gp8psk_streaming_ctrl,
198 .power_ctrl = gp8psk_power_ctrl,
199 .frontend_attach = gp8psk_frontend_attach, 198 .frontend_attach = gp8psk_frontend_attach,
200
201 .generic_bulk_ctrl_endpoint = 0x01,
202 /* parameter for the MPEG2-data transfer */ 199 /* parameter for the MPEG2-data transfer */
203 .urb = { 200 .stream = {
204 .type = DVB_USB_BULK, 201 .type = USB_BULK,
205 .count = 7, 202 .count = 7,
206 .endpoint = 0x82, 203 .endpoint = 0x82,
207 .u = { 204 .u = {
@@ -210,6 +207,11 @@ static struct dvb_usb_properties gp8psk_properties = {
210 } 207 }
211 } 208 }
212 }, 209 },
210 }
211 },
212 .power_ctrl = gp8psk_power_ctrl,
213
214 .generic_bulk_ctrl_endpoint = 0x01,
213 215
214 .num_device_descs = 1, 216 .num_device_descs = 1,
215 .devices = { 217 .devices = {
@@ -217,7 +219,7 @@ static struct dvb_usb_properties gp8psk_properties = {
217 .cold_ids = { &gp8psk_usb_table[0], NULL }, 219 .cold_ids = { &gp8psk_usb_table[0], NULL },
218 .warm_ids = { &gp8psk_usb_table[1], NULL }, 220 .warm_ids = { &gp8psk_usb_table[1], NULL },
219 }, 221 },
220 { 0 }, 222 { NULL },
221 } 223 }
222}; 224};
223 225
diff --git a/drivers/media/dvb/dvb-usb/nova-t-usb2.c b/drivers/media/dvb/dvb-usb/nova-t-usb2.c
index 79f0a02ce987..a9219bf69b89 100644
--- a/drivers/media/dvb/dvb-usb/nova-t-usb2.c
+++ b/drivers/media/dvb/dvb-usb/nova-t-usb2.c
@@ -135,7 +135,7 @@ static int nova_t_read_mac_address (struct dvb_usb_device *d, u8 mac[6])
135} 135}
136 136
137/* USB Driver stuff */ 137/* USB Driver stuff */
138static struct dvb_usb_properties nova_t_properties; 138static struct dvb_usb_device_properties nova_t_properties;
139 139
140static int nova_t_probe(struct usb_interface *intf, 140static int nova_t_probe(struct usb_interface *intf,
141 const struct usb_device_id *id) 141 const struct usb_device_id *id)
@@ -151,34 +151,27 @@ static struct usb_device_id nova_t_table [] = {
151}; 151};
152MODULE_DEVICE_TABLE(usb, nova_t_table); 152MODULE_DEVICE_TABLE(usb, nova_t_table);
153 153
154static struct dvb_usb_properties nova_t_properties = { 154static struct dvb_usb_device_properties nova_t_properties = {
155 .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF | DVB_USB_IS_AN_I2C_ADAPTER, 155 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
156 .pid_filter_count = 32,
157 156
158 .usb_ctrl = CYPRESS_FX2, 157 .usb_ctrl = CYPRESS_FX2,
159 .firmware = "dvb-usb-nova-t-usb2-02.fw", 158 .firmware = "dvb-usb-nova-t-usb2-02.fw",
160 159
161 .size_of_priv = sizeof(struct dibusb_state), 160 .num_adapters = 1,
161 .adapter = {
162 {
163 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
164 .pid_filter_count = 32,
162 165
163 .streaming_ctrl = dibusb2_0_streaming_ctrl, 166 .streaming_ctrl = dibusb2_0_streaming_ctrl,
164 .pid_filter = dibusb_pid_filter, 167 .pid_filter = dibusb_pid_filter,
165 .pid_filter_ctrl = dibusb_pid_filter_ctrl, 168 .pid_filter_ctrl = dibusb_pid_filter_ctrl,
166 .power_ctrl = dibusb2_0_power_ctrl,
167 .frontend_attach = dibusb_dib3000mc_frontend_attach, 169 .frontend_attach = dibusb_dib3000mc_frontend_attach,
168 .tuner_attach = dibusb_dib3000mc_tuner_attach, 170 .tuner_attach = dibusb_dib3000mc_tuner_attach,
169 .read_mac_address = nova_t_read_mac_address,
170
171 .rc_interval = 100,
172 .rc_key_map = haupp_rc_keys,
173 .rc_key_map_size = ARRAY_SIZE(haupp_rc_keys),
174 .rc_query = nova_t_rc_query,
175 171
176 .i2c_algo = &dibusb_i2c_algo,
177
178 .generic_bulk_ctrl_endpoint = 0x01,
179 /* parameter for the MPEG2-data transfer */ 172 /* parameter for the MPEG2-data transfer */
180 .urb = { 173 .stream = {
181 .type = DVB_USB_BULK, 174 .type = USB_BULK,
182 .count = 7, 175 .count = 7,
183 .endpoint = 0x06, 176 .endpoint = 0x06,
184 .u = { 177 .u = {
@@ -188,6 +181,22 @@ static struct dvb_usb_properties nova_t_properties = {
188 } 181 }
189 }, 182 },
190 183
184 .size_of_priv = sizeof(struct dibusb_state),
185 }
186 },
187
188 .power_ctrl = dibusb2_0_power_ctrl,
189 .read_mac_address = nova_t_read_mac_address,
190
191 .rc_interval = 100,
192 .rc_key_map = haupp_rc_keys,
193 .rc_key_map_size = ARRAY_SIZE(haupp_rc_keys),
194 .rc_query = nova_t_rc_query,
195
196 .i2c_algo = &dibusb_i2c_algo,
197
198 .generic_bulk_ctrl_endpoint = 0x01,
199
191 .num_device_descs = 1, 200 .num_device_descs = 1,
192 .devices = { 201 .devices = {
193 { "Hauppauge WinTV-NOVA-T usb2", 202 { "Hauppauge WinTV-NOVA-T usb2",
diff --git a/drivers/media/dvb/dvb-usb/umt-010.c b/drivers/media/dvb/dvb-usb/umt-010.c
index 418a0b707151..f9941ea88b3e 100644
--- a/drivers/media/dvb/dvb-usb/umt-010.c
+++ b/drivers/media/dvb/dvb-usb/umt-010.c
@@ -50,7 +50,7 @@ static int umt_mt352_demod_init(struct dvb_frontend *fe)
50 return 0; 50 return 0;
51} 51}
52 52
53static int umt_mt352_frontend_attach(struct dvb_usb_device *d) 53static int umt_mt352_frontend_attach(struct dvb_usb_adapter *adap)
54{ 54{
55 struct mt352_config umt_config; 55 struct mt352_config umt_config;
56 56
@@ -58,21 +58,21 @@ static int umt_mt352_frontend_attach(struct dvb_usb_device *d)
58 umt_config.demod_init = umt_mt352_demod_init; 58 umt_config.demod_init = umt_mt352_demod_init;
59 umt_config.demod_address = 0xf; 59 umt_config.demod_address = 0xf;
60 60
61 d->fe = dvb_attach(mt352_attach, &umt_config, &d->i2c_adap); 61 adap->fe = dvb_attach(mt352_attach, &umt_config, &adap->dev->i2c_adap);
62 62
63 return 0; 63 return 0;
64} 64}
65 65
66static int umt_tuner_attach (struct dvb_usb_device *d) 66static int umt_tuner_attach (struct dvb_usb_adapter *adap)
67{ 67{
68 d->pll_addr = 0x61; 68 adap->pll_addr = 0x61;
69 d->pll_desc = &dvb_pll_tua6034; 69 adap->pll_desc = &dvb_pll_tua6034;
70 d->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs; 70 adap->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs;
71 return 0; 71 return 0;
72} 72}
73 73
74/* USB Driver stuff */ 74/* USB Driver stuff */
75static struct dvb_usb_properties umt_properties; 75static struct dvb_usb_device_properties umt_properties;
76 76
77static int umt_probe(struct usb_interface *intf, 77static int umt_probe(struct usb_interface *intf,
78 const struct usb_device_id *id) 78 const struct usb_device_id *id)
@@ -90,25 +90,22 @@ static struct usb_device_id umt_table [] = {
90}; 90};
91MODULE_DEVICE_TABLE (usb, umt_table); 91MODULE_DEVICE_TABLE (usb, umt_table);
92 92
93static struct dvb_usb_properties umt_properties = { 93static struct dvb_usb_device_properties umt_properties = {
94 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 94 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
95 95
96 .usb_ctrl = CYPRESS_FX2, 96 .usb_ctrl = CYPRESS_FX2,
97 .firmware = "dvb-usb-umt-010-02.fw", 97 .firmware = "dvb-usb-umt-010-02.fw",
98 98
99 .size_of_priv = sizeof(struct dibusb_state), 99 .num_adapters = 1,
100 100 .adapter = {
101 {
101 .streaming_ctrl = dibusb2_0_streaming_ctrl, 102 .streaming_ctrl = dibusb2_0_streaming_ctrl,
102 .power_ctrl = dibusb_power_ctrl,
103 .frontend_attach = umt_mt352_frontend_attach, 103 .frontend_attach = umt_mt352_frontend_attach,
104 .tuner_attach = umt_tuner_attach, 104 .tuner_attach = umt_tuner_attach,
105 105
106 .i2c_algo = &dibusb_i2c_algo,
107
108 .generic_bulk_ctrl_endpoint = 0x01,
109 /* parameter for the MPEG2-data transfer */ 106 /* parameter for the MPEG2-data transfer */
110 .urb = { 107 .stream = {
111 .type = DVB_USB_BULK, 108 .type = USB_BULK,
112 .count = 20, 109 .count = 20,
113 .endpoint = 0x06, 110 .endpoint = 0x06,
114 .u = { 111 .u = {
@@ -118,6 +115,15 @@ static struct dvb_usb_properties umt_properties = {
118 } 115 }
119 }, 116 },
120 117
118 .size_of_priv = sizeof(struct dibusb_state),
119 }
120 },
121 .power_ctrl = dibusb_power_ctrl,
122
123 .i2c_algo = &dibusb_i2c_algo,
124
125 .generic_bulk_ctrl_endpoint = 0x01,
126
121 .num_device_descs = 1, 127 .num_device_descs = 1,
122 .devices = { 128 .devices = {
123 { "Hanftek UMT-010 DVB-T USB2.0", 129 { "Hanftek UMT-010 DVB-T USB2.0",
diff --git a/drivers/media/dvb/dvb-usb/usb-urb.c b/drivers/media/dvb/dvb-usb/usb-urb.c
new file mode 100644
index 000000000000..8728cf347a71
--- /dev/null
+++ b/drivers/media/dvb/dvb-usb/usb-urb.c
@@ -0,0 +1,242 @@
1/* usb-urb.c is part of the DVB USB library.
2 *
3 * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de)
4 * see dvb-usb-init.c for copyright information.
5 *
6 * This file keeps functions for initializing and handling the
7 * BULK and ISOC USB data transfers in a generic way.
8 * Can be used for DVB-only and also, that's the plan, for
9 * Hybrid USB devices (analog and DVB).
10 */
11#include "dvb-usb-common.h"
12
13/* URB stuff for streaming */
14static void usb_urb_complete(struct urb *urb, struct pt_regs *ptregs)
15{
16 struct usb_data_stream *stream = urb->context;
17 int ptype = usb_pipetype(urb->pipe);
18 int i;
19 u8 *b;
20
21 deb_uxfer("'%s' urb completed. status: %d, length: %d/%d, pack_num: %d, errors: %d\n",
22 ptype == PIPE_ISOCHRONOUS ? "isoc" : "bulk",
23 urb->status,urb->actual_length,urb->transfer_buffer_length,
24 urb->number_of_packets,urb->error_count);
25
26 switch (urb->status) {
27 case 0: /* success */
28 case -ETIMEDOUT: /* NAK */
29 break;
30 case -ECONNRESET: /* kill */
31 case -ENOENT:
32 case -ESHUTDOWN:
33 return;
34 default: /* error */
35 deb_ts("urb completition error %d.\n", urb->status);
36 break;
37 }
38
39 b = (u8 *) urb->transfer_buffer;
40 switch (ptype) {
41 case PIPE_ISOCHRONOUS:
42 for (i = 0; i < urb->number_of_packets; i++) {
43
44 if (urb->iso_frame_desc[i].status != 0)
45 deb_ts("iso frame descriptor has an error: %d\n",urb->iso_frame_desc[i].status);
46 else if (urb->iso_frame_desc[i].actual_length > 0)
47 stream->complete(stream, b + urb->iso_frame_desc[i].offset, urb->iso_frame_desc[i].actual_length);
48
49 urb->iso_frame_desc[i].status = 0;
50 urb->iso_frame_desc[i].actual_length = 0;
51 }
52 debug_dump(b,20,deb_uxfer);
53 break;
54 case PIPE_BULK:
55 if (urb->actual_length > 0)
56 stream->complete(stream, b, urb->actual_length);
57 break;
58 default:
59 err("unkown endpoint type in completition handler.");
60 return;
61 }
62 usb_submit_urb(urb,GFP_ATOMIC);
63}
64
65int usb_urb_kill(struct usb_data_stream *stream)
66{
67 int i;
68 for (i = 0; i < stream->urbs_submitted; i++) {
69 deb_ts("killing URB no. %d.\n",i);
70
71 /* stop the URB */
72 usb_kill_urb(stream->urb_list[i]);
73 }
74 stream->urbs_submitted = 0;
75 return 0;
76}
77
78int usb_urb_submit(struct usb_data_stream *stream)
79{
80 int i,ret;
81 for (i = 0; i < stream->urbs_initialized; i++) {
82 deb_ts("submitting URB no. %d\n",i);
83 if ((ret = usb_submit_urb(stream->urb_list[i],GFP_ATOMIC))) {
84 err("could not submit URB no. %d - get them all back",i);
85 usb_urb_kill(stream);
86 return ret;
87 }
88 stream->urbs_submitted++;
89 }
90 return 0;
91}
92
93static int usb_free_stream_buffers(struct usb_data_stream *stream)
94{
95 if (stream->state & USB_STATE_URB_BUF) {
96 while (stream->buf_num) {
97 stream->buf_num--;
98 deb_mem("freeing buffer %d\n",stream->buf_num);
99 usb_buffer_free(stream->udev, stream->buf_size,
100 stream->buf_list[stream->buf_num], stream->dma_addr[stream->buf_num]);
101 }
102 }
103
104 stream->state &= ~USB_STATE_URB_BUF;
105
106 return 0;
107}
108
109static int usb_allocate_stream_buffers(struct usb_data_stream *stream, int num, unsigned long size)
110{
111 stream->buf_num = 0;
112 stream->buf_size = size;
113
114 deb_mem("all in all I will use %lu bytes for streaming\n",num*size);
115
116 for (stream->buf_num = 0; stream->buf_num < num; stream->buf_num++) {
117 deb_mem("allocating buffer %d\n",stream->buf_num);
118 if (( stream->buf_list[stream->buf_num] =
119 usb_buffer_alloc(stream->udev, size, SLAB_ATOMIC,
120 &stream->dma_addr[stream->buf_num]) ) == NULL) {
121 deb_mem("not enough memory for urb-buffer allocation.\n");
122 usb_free_stream_buffers(stream);
123 return -ENOMEM;
124 }
125 deb_mem("buffer %d: %p (dma: %u)\n",
126 stream->buf_num, stream->buf_list[stream->buf_num], stream->dma_addr[stream->buf_num]);
127 memset(stream->buf_list[stream->buf_num],0,size);
128 stream->state |= USB_STATE_URB_BUF;
129 }
130 deb_mem("allocation successful\n");
131
132 return 0;
133}
134
135static int usb_bulk_urb_init(struct usb_data_stream *stream)
136{
137 int i;
138
139 if ((i = usb_allocate_stream_buffers(stream,stream->props.count,
140 stream->props.u.bulk.buffersize)) < 0)
141 return i;
142
143 /* allocate the URBs */
144 for (i = 0; i < stream->props.count; i++) {
145 if ((stream->urb_list[i] = usb_alloc_urb(0,GFP_ATOMIC)) == NULL)
146 return -ENOMEM;
147
148 usb_fill_bulk_urb( stream->urb_list[i], stream->udev,
149 usb_rcvbulkpipe(stream->udev,stream->props.endpoint),
150 stream->buf_list[i],
151 stream->props.u.bulk.buffersize,
152 usb_urb_complete, stream);
153
154 stream->urb_list[i]->transfer_flags = 0;
155 stream->urbs_initialized++;
156 }
157 return 0;
158}
159
160static int usb_isoc_urb_init(struct usb_data_stream *stream)
161{
162 int i,j;
163
164 if ((i = usb_allocate_stream_buffers(stream,stream->props.count,
165 stream->props.u.isoc.framesize*stream->props.u.isoc.framesperurb)) < 0)
166 return i;
167
168 /* allocate the URBs */
169 for (i = 0; i < stream->props.count; i++) {
170 struct urb *urb;
171 int frame_offset = 0;
172 if ((stream->urb_list[i] =
173 usb_alloc_urb(stream->props.u.isoc.framesperurb,GFP_ATOMIC)) == NULL)
174 return -ENOMEM;
175
176 urb = stream->urb_list[i];
177
178 urb->dev = stream->udev;
179 urb->context = stream;
180 urb->complete = usb_urb_complete;
181 urb->pipe = usb_rcvisocpipe(stream->udev,stream->props.endpoint);
182 urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP;
183 urb->interval = stream->props.u.isoc.interval;
184 urb->number_of_packets = stream->props.u.isoc.framesperurb;
185 urb->transfer_buffer_length = stream->buf_size;
186 urb->transfer_buffer = stream->buf_list[i];
187 urb->transfer_dma = stream->dma_addr[i];
188
189 for (j = 0; j < stream->props.u.isoc.framesperurb; j++) {
190 urb->iso_frame_desc[j].offset = frame_offset;
191 urb->iso_frame_desc[j].length = stream->props.u.isoc.framesize;
192 frame_offset += stream->props.u.isoc.framesize;
193 }
194
195 stream->urbs_initialized++;
196 }
197 return 0;
198}
199
200int usb_urb_init(struct usb_data_stream *stream, struct usb_data_stream_properties *props)
201{
202 if (stream == NULL || props == NULL)
203 return -EINVAL;
204
205 memcpy(&stream->props, props, sizeof(*props));
206
207 usb_clear_halt(stream->udev,usb_rcvbulkpipe(stream->udev,stream->props.endpoint));
208
209 if (stream->complete == NULL) {
210 err("there is no data callback - this doesn't make sense.");
211 return -EINVAL;
212 }
213
214 switch (stream->props.type) {
215 case USB_BULK:
216 return usb_bulk_urb_init(stream);
217 case USB_ISOC:
218 return usb_isoc_urb_init(stream);
219 default:
220 err("unkown URB-type for data transfer.");
221 return -EINVAL;
222 }
223}
224
225int usb_urb_exit(struct usb_data_stream *stream)
226{
227 int i;
228
229 usb_urb_kill(stream);
230
231 for (i = 0; i < stream->urbs_initialized; i++) {
232 if (stream->urb_list[i] != NULL) {
233 deb_mem("freeing URB no. %d.\n",i);
234 /* free the URBs */
235 usb_free_urb(stream->urb_list[i]);
236 }
237 }
238 stream->urbs_initialized = 0;
239
240 usb_free_stream_buffers(stream);
241 return 0;
242}
diff --git a/drivers/media/dvb/dvb-usb/vp702x-fe.c b/drivers/media/dvb/dvb-usb/vp702x-fe.c
index d4da494132ec..3ecb2e0ce80f 100644
--- a/drivers/media/dvb/dvb-usb/vp702x-fe.c
+++ b/drivers/media/dvb/dvb-usb/vp702x-fe.c
@@ -24,6 +24,8 @@ struct vp702x_fe_state {
24 struct dvb_frontend fe; 24 struct dvb_frontend fe;
25 struct dvb_usb_device *d; 25 struct dvb_usb_device *d;
26 26
27 struct dvb_frontend_ops ops;
28
27 fe_sec_voltage_t voltage; 29 fe_sec_voltage_t voltage;
28 fe_sec_tone_mode_t tone_mode; 30 fe_sec_tone_mode_t tone_mode;
29 31
@@ -72,9 +74,6 @@ static int vp702x_fe_read_status(struct dvb_frontend* fe, fe_status_t *status)
72 else 74 else
73 *status = 0; 75 *status = 0;
74 76
75 deb_fe("real state: %x\n",*status);
76 *status = 0x1f;
77
78 if (*status & FE_HAS_LOCK) 77 if (*status & FE_HAS_LOCK)
79 st->status_check_interval = 1000; 78 st->status_check_interval = 1000;
80 else 79 else
@@ -171,8 +170,6 @@ static int vp702x_fe_set_frontend(struct dvb_frontend* fe,
171 st->status_check_interval = 250; 170 st->status_check_interval = 250;
172 st->next_status_check = jiffies; 171 st->next_status_check = jiffies;
173 172
174 vp702x_usb_in_op(st->d, RESET_TUNER, 0, 0, NULL, 0);
175 msleep(30);
176 vp702x_usb_inout_op(st->d,cmd,8,ibuf,10,100); 173 vp702x_usb_inout_op(st->d,cmd,8,ibuf,10,100);
177 174
178 if (ibuf[2] == 0 && ibuf[3] == 0) 175 if (ibuf[2] == 0 && ibuf[3] == 0)
@@ -183,6 +180,20 @@ static int vp702x_fe_set_frontend(struct dvb_frontend* fe,
183 return 0; 180 return 0;
184} 181}
185 182
183static int vp702x_fe_init(struct dvb_frontend *fe)
184{
185 struct vp702x_fe_state *st = fe->demodulator_priv;
186 deb_fe("%s\n",__FUNCTION__);
187 vp702x_usb_in_op(st->d, RESET_TUNER, 0, 0, NULL, 0);
188 return 0;
189}
190
191static int vp702x_fe_sleep(struct dvb_frontend *fe)
192{
193 deb_fe("%s\n",__FUNCTION__);
194 return 0;
195}
196
186static int vp702x_fe_get_frontend(struct dvb_frontend* fe, 197static int vp702x_fe_get_frontend(struct dvb_frontend* fe,
187 struct dvb_frontend_parameters *fep) 198 struct dvb_frontend_parameters *fep)
188{ 199{
@@ -193,8 +204,8 @@ static int vp702x_fe_get_frontend(struct dvb_frontend* fe,
193static int vp702x_fe_send_diseqc_msg (struct dvb_frontend* fe, 204static int vp702x_fe_send_diseqc_msg (struct dvb_frontend* fe,
194 struct dvb_diseqc_master_cmd *m) 205 struct dvb_diseqc_master_cmd *m)
195{ 206{
196 struct vp702x_fe_state *st = fe->demodulator_priv; 207 //struct vp702x_fe_state *st = fe->demodulator_priv;
197 u8 cmd[8],ibuf[10]; 208 u8 cmd[8];//,ibuf[10];
198 memset(cmd,0,8); 209 memset(cmd,0,8);
199 210
200 deb_fe("%s\n",__FUNCTION__); 211 deb_fe("%s\n",__FUNCTION__);
@@ -207,12 +218,12 @@ static int vp702x_fe_send_diseqc_msg (struct dvb_frontend* fe,
207 memcpy(&cmd[3], m->msg, m->msg_len); 218 memcpy(&cmd[3], m->msg, m->msg_len);
208 cmd[7] = vp702x_chksum(cmd,0,7); 219 cmd[7] = vp702x_chksum(cmd,0,7);
209 220
210 vp702x_usb_inout_op(st->d,cmd,8,ibuf,10,100); 221// vp702x_usb_inout_op(st->d,cmd,8,ibuf,10,100);
211 222
212 if (ibuf[2] == 0 && ibuf[3] == 0) 223// if (ibuf[2] == 0 && ibuf[3] == 0)
213 deb_fe("diseqc cmd failed.\n"); 224// deb_fe("diseqc cmd failed.\n");
214 else 225// else
215 deb_fe("diseqc cmd succeeded.\n"); 226// deb_fe("diseqc cmd succeeded.\n");
216 227
217 return 0; 228 return 0;
218} 229}
@@ -318,8 +329,8 @@ static struct dvb_frontend_ops vp702x_fe_ops = {
318 }, 329 },
319 .release = vp702x_fe_release, 330 .release = vp702x_fe_release,
320 331
321 .init = NULL, 332 .init = vp702x_fe_init,
322 .sleep = NULL, 333 .sleep = vp702x_fe_sleep,
323 334
324 .set_frontend = vp702x_fe_set_frontend, 335 .set_frontend = vp702x_fe_set_frontend,
325 .get_frontend = vp702x_fe_get_frontend, 336 .get_frontend = vp702x_fe_get_frontend,
diff --git a/drivers/media/dvb/dvb-usb/vp702x.c b/drivers/media/dvb/dvb-usb/vp702x.c
index b2f098a2d5f7..02bd61aaac66 100644
--- a/drivers/media/dvb/dvb-usb/vp702x.c
+++ b/drivers/media/dvb/dvb-usb/vp702x.c
@@ -22,50 +22,54 @@ module_param_named(debug,dvb_usb_vp702x_debug, int, 0644);
22MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,rc=4 (or-able))." DVB_USB_DEBUG_STATUS); 22MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,rc=4 (or-able))." DVB_USB_DEBUG_STATUS);
23 23
24struct vp702x_state { 24struct vp702x_state {
25 u8 pid_table[17]; /* [16] controls the pid_table state */ 25 int pid_filter_count;
26 int pid_filter_can_bypass;
27 u8 pid_filter_state;
28};
29
30struct vp702x_device_state {
31 u8 power_state;
26}; 32};
27 33
28/* check for mutex FIXME */ 34/* check for mutex FIXME */
29int vp702x_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen) 35int vp702x_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen)
30{ 36{
31 int ret = 0,try = 0; 37 int ret = -1;
32 38
33 while (ret >= 0 && ret != blen && try < 3) {
34 ret = usb_control_msg(d->udev, 39 ret = usb_control_msg(d->udev,
35 usb_rcvctrlpipe(d->udev,0), 40 usb_rcvctrlpipe(d->udev,0),
36 req, 41 req,
37 USB_TYPE_VENDOR | USB_DIR_IN, 42 USB_TYPE_VENDOR | USB_DIR_IN,
38 value,index,b,blen, 43 value,index,b,blen,
39 2000); 44 2000);
40 deb_info("reading number %d (ret: %d)\n",try,ret);
41 try++;
42 }
43 45
44 if (ret < 0 || ret != blen) { 46 if (ret < 0) {
45 warn("usb in operation failed."); 47 warn("usb in operation failed. (%d)", ret);
46 ret = -EIO; 48 ret = -EIO;
47 } else 49 } else
48 ret = 0; 50 ret = 0;
49 51
50 deb_xfer("in: req. %x, val: %x, ind: %x, buffer: ",req,value,index); 52
53 deb_xfer("in: req. %02x, val: %04x, ind: %04x, buffer: ",req,value,index);
51 debug_dump(b,blen,deb_xfer); 54 debug_dump(b,blen,deb_xfer);
52 55
53 return ret; 56 return ret;
54} 57}
55 58
56static int vp702x_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value, 59int vp702x_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value,
57 u16 index, u8 *b, int blen) 60 u16 index, u8 *b, int blen)
58{ 61{
59 deb_xfer("out: req. %x, val: %x, ind: %x, buffer: ",req,value,index); 62 int ret;
63 deb_xfer("out: req. %02x, val: %04x, ind: %04x, buffer: ",req,value,index);
60 debug_dump(b,blen,deb_xfer); 64 debug_dump(b,blen,deb_xfer);
61 65
62 if (usb_control_msg(d->udev, 66 if ((ret = usb_control_msg(d->udev,
63 usb_sndctrlpipe(d->udev,0), 67 usb_sndctrlpipe(d->udev,0),
64 req, 68 req,
65 USB_TYPE_VENDOR | USB_DIR_OUT, 69 USB_TYPE_VENDOR | USB_DIR_OUT,
66 value,index,b,blen, 70 value,index,b,blen,
67 2000) != blen) { 71 2000)) != blen) {
68 warn("usb out operation failed."); 72 warn("usb out operation failed. (%d)",ret);
69 return -EIO; 73 return -EIO;
70 } else 74 } else
71 return 0; 75 return 0;
@@ -78,12 +82,10 @@ int vp702x_usb_inout_op(struct dvb_usb_device *d, u8 *o, int olen, u8 *i, int il
78 if ((ret = mutex_lock_interruptible(&d->usb_mutex))) 82 if ((ret = mutex_lock_interruptible(&d->usb_mutex)))
79 return ret; 83 return ret;
80 84
81 if ((ret = vp702x_usb_out_op(d,REQUEST_OUT,0,0,o,olen)) < 0) 85 ret = vp702x_usb_out_op(d,REQUEST_OUT,0,0,o,olen);
82 goto unlock;
83 msleep(msec); 86 msleep(msec);
84 ret = vp702x_usb_in_op(d,REQUEST_IN,0,0,i,ilen); 87 ret = vp702x_usb_in_op(d,REQUEST_IN,0,0,i,ilen);
85 88
86unlock:
87 mutex_unlock(&d->usb_mutex); 89 mutex_unlock(&d->usb_mutex);
88 90
89 return ret; 91 return ret;
@@ -108,29 +110,65 @@ static int vp702x_usb_inout_cmd(struct dvb_usb_device *d, u8 cmd, u8 *o,
108 return ret; 110 return ret;
109} 111}
110 112
111static int vp702x_pid_filter(struct dvb_usb_device *d, int index, u16 pid, int onoff) 113static int vp702x_set_pld_mode(struct dvb_usb_adapter *adap, u8 bypass)
114{
115 u8 buf[16] = { 0 };
116 return vp702x_usb_in_op(adap->dev, 0xe0, (bypass << 8) | 0x0e, 0, buf, 16);
117}
118
119static int vp702x_set_pld_state(struct dvb_usb_adapter *adap, u8 state)
120{
121 u8 buf[16] = { 0 };
122 return vp702x_usb_in_op(adap->dev, 0xe0, (state << 8) | 0x0f, 0, buf, 16);
123}
124
125static int vp702x_set_pid(struct dvb_usb_adapter *adap, u16 pid, u8 id, int onoff)
112{ 126{
113 struct vp702x_state *st = d->priv; 127 struct vp702x_state *st = adap->priv;
114 u8 buf[9]; 128 u8 buf[16] = { 0 };
115 129
116 if (onoff) { 130 if (onoff)
117 st->pid_table[16] |= 1 << index; 131 st->pid_filter_state |= (1 << id);
118 st->pid_table[index*2] = (pid >> 8) & 0xff; 132 else {
119 st->pid_table[index*2+1] = pid & 0xff; 133 st->pid_filter_state &= ~(1 << id);
120 } else { 134 pid = 0xffff;
121 st->pid_table[16] &= ~(1 << index);
122 st->pid_table[index*2] = st->pid_table[index*2+1] = 0;
123 } 135 }
124 136
125 return vp702x_usb_inout_cmd(d,SET_PID_FILTER,st->pid_table,17,buf,9,10); 137 id = 0x10 + id*2;
138
139 vp702x_set_pld_state(adap, st->pid_filter_state);
140 vp702x_usb_in_op(adap->dev, 0xe0, (((pid >> 8) & 0xff) << 8) | (id), 0, buf, 16);
141 vp702x_usb_in_op(adap->dev, 0xe0, (((pid ) & 0xff) << 8) | (id+1), 0, buf, 16);
142 return 0;
126} 143}
127 144
128static int vp702x_power_ctrl(struct dvb_usb_device *d, int onoff) 145
146static int vp702x_init_pid_filter(struct dvb_usb_adapter *adap)
129{ 147{
130 vp702x_usb_in_op(d,RESET_TUNER,0,0,NULL,0); 148 struct vp702x_state *st = adap->priv;
149 int i;
150 u8 b[10] = { 0 };
151
152 st->pid_filter_count = 8;
153 st->pid_filter_can_bypass = 1;
154 st->pid_filter_state = 0x00;
155
156 vp702x_set_pld_mode(adap, 1); // bypass
157
158 for (i = 0; i < st->pid_filter_count; i++)
159 vp702x_set_pid(adap, 0xffff, i, 1);
131 160
132 vp702x_usb_in_op(d,SET_TUNER_POWER_REQ,0,onoff,NULL,0); 161 vp702x_usb_in_op(adap->dev, 0xb5, 3, 0, b, 10);
133 return vp702x_usb_in_op(d,SET_TUNER_POWER_REQ,0,onoff,NULL,0); 162 vp702x_usb_in_op(adap->dev, 0xb5, 0, 0, b, 10);
163 vp702x_usb_in_op(adap->dev, 0xb5, 1, 0, b, 10);
164
165 //vp702x_set_pld_mode(d, 0); // filter
166 return 0;
167}
168
169static int vp702x_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
170{
171 return 0;
134} 172}
135 173
136/* keys for the enclosed remote control */ 174/* keys for the enclosed remote control */
@@ -166,74 +204,83 @@ static int vp702x_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
166 return 0; 204 return 0;
167} 205}
168 206
207int vp702x_power_ctrl(struct dvb_usb_device *d, int onoff)
208{
209 struct vp702x_device_state *st = d->priv;
210
211 if (st->power_state == 0 && onoff)
212 vp702x_usb_out_op(d, SET_TUNER_POWER_REQ, 1, 7, NULL, 0);
213 else if (st->power_state == 1 && onoff == 0)
214 vp702x_usb_out_op(d, SET_TUNER_POWER_REQ, 0, 7, NULL, 0);
215
216 st->power_state = onoff;
217
218 return 0;
219}
220
169static int vp702x_read_mac_addr(struct dvb_usb_device *d,u8 mac[6]) 221static int vp702x_read_mac_addr(struct dvb_usb_device *d,u8 mac[6])
170{ 222{
171 u8 macb[9]; 223 u8 i;
172 if (vp702x_usb_inout_cmd(d, GET_MAC_ADDRESS, NULL, 0, macb, 9, 10)) 224 for (i = 6; i < 12; i++)
173 return -EIO; 225 vp702x_usb_in_op(d, READ_EEPROM_REQ, i, 1, &mac[i - 6], 1);
174 memcpy(mac,&macb[3],6);
175 return 0; 226 return 0;
176} 227}
177 228
178static int vp702x_frontend_attach(struct dvb_usb_device *d) 229static int vp702x_frontend_attach(struct dvb_usb_adapter *adap)
179{ 230{
180 u8 buf[9] = { 0 }; 231 u8 buf[10] = { 0 };
232
233 vp702x_usb_out_op(adap->dev, SET_TUNER_POWER_REQ, 0, 7, NULL, 0);
181 234
182 if (vp702x_usb_inout_cmd(d, GET_SYSTEM_STRING, NULL, 0, buf, 9, 10)) 235 if (vp702x_usb_inout_cmd(adap->dev, GET_SYSTEM_STRING, NULL, 0, buf, 10, 10))
183 return -EIO; 236 return -EIO;
184 237
185 buf[8] = '\0'; 238 buf[9] = '\0';
186 info("system string: %s",&buf[1]); 239 info("system string: %s",&buf[1]);
187 240
188 d->fe = vp702x_fe_attach(d); 241 vp702x_init_pid_filter(adap);
242
243 adap->fe = vp702x_fe_attach(adap->dev);
244 vp702x_usb_out_op(adap->dev, SET_TUNER_POWER_REQ, 1, 7, NULL, 0);
245
189 return 0; 246 return 0;
190} 247}
191 248
192static struct dvb_usb_properties vp702x_properties; 249static struct dvb_usb_device_properties vp702x_properties;
193 250
194static int vp702x_usb_probe(struct usb_interface *intf, 251static int vp702x_usb_probe(struct usb_interface *intf,
195 const struct usb_device_id *id) 252 const struct usb_device_id *id)
196{ 253{
197 struct usb_device *udev = interface_to_usbdev(intf);
198
199 usb_clear_halt(udev,usb_sndctrlpipe(udev,0));
200 usb_clear_halt(udev,usb_rcvctrlpipe(udev,0));
201
202 return dvb_usb_device_init(intf,&vp702x_properties,THIS_MODULE,NULL); 254 return dvb_usb_device_init(intf,&vp702x_properties,THIS_MODULE,NULL);
203} 255}
204 256
205static struct usb_device_id vp702x_usb_table [] = { 257static struct usb_device_id vp702x_usb_table [] = {
206 { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7021_COLD) }, 258 { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7021_COLD) },
207 { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7021_WARM) }, 259// { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7020_COLD) },
208 { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7020_COLD) }, 260// { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7020_WARM) },
209 { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7020_WARM) },
210 { 0 }, 261 { 0 },
211}; 262};
212MODULE_DEVICE_TABLE(usb, vp702x_usb_table); 263MODULE_DEVICE_TABLE(usb, vp702x_usb_table);
213 264
214static struct dvb_usb_properties vp702x_properties = { 265static struct dvb_usb_device_properties vp702x_properties = {
215 .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_NEED_PID_FILTERING,
216 .pid_filter_count = 8, /* !!! */
217
218 .usb_ctrl = CYPRESS_FX2, 266 .usb_ctrl = CYPRESS_FX2,
219 .firmware = "dvb-usb-vp702x-01.fw", 267 .firmware = "dvb-usb-vp702x-02.fw",
268 .no_reconnect = 1,
220 269
221 .pid_filter = vp702x_pid_filter, 270 .size_of_priv = sizeof(struct vp702x_device_state),
222 .power_ctrl = vp702x_power_ctrl,
223 .frontend_attach = vp702x_frontend_attach,
224 .read_mac_address = vp702x_read_mac_addr,
225 271
226 .rc_key_map = vp702x_rc_keys, 272 .num_adapters = 1,
227 .rc_key_map_size = ARRAY_SIZE(vp702x_rc_keys), 273 .adapter = {
228 .rc_interval = 400, 274 {
229 .rc_query = vp702x_rc_query, 275 .caps = DVB_USB_ADAP_RECEIVES_204_BYTE_TS,
230 276
231 .size_of_priv = sizeof(struct vp702x_state), 277 .streaming_ctrl = vp702x_streaming_ctrl,
278 .frontend_attach = vp702x_frontend_attach,
232 279
233 /* parameter for the MPEG2-data transfer */ 280 /* parameter for the MPEG2-data transfer */
234 .urb = { 281 .stream = {
235 .type = DVB_USB_BULK, 282 .type = USB_BULK,
236 .count = 7, 283 .count = 10,
237 .endpoint = 0x02, 284 .endpoint = 0x02,
238 .u = { 285 .u = {
239 .bulk = { 286 .bulk = {
@@ -241,24 +288,33 @@ static struct dvb_usb_properties vp702x_properties = {
241 } 288 }
242 } 289 }
243 }, 290 },
291 .size_of_priv = sizeof(struct vp702x_state),
292 }
293 },
294 .read_mac_address = vp702x_read_mac_addr,
295
296 .rc_key_map = vp702x_rc_keys,
297 .rc_key_map_size = ARRAY_SIZE(vp702x_rc_keys),
298 .rc_interval = 400,
299 .rc_query = vp702x_rc_query,
244 300
245 .num_device_descs = 2, 301 .num_device_descs = 1,
246 .devices = { 302 .devices = {
247 { .name = "TwinhanDTV StarBox DVB-S USB2.0 (VP7021)", 303 { .name = "TwinhanDTV StarBox DVB-S USB2.0 (VP7021)",
248 .cold_ids = { &vp702x_usb_table[0], NULL }, 304 .cold_ids = { &vp702x_usb_table[0], NULL },
249 .warm_ids = { &vp702x_usb_table[1], NULL }, 305 .warm_ids = { NULL },
250 }, 306 },
251 { .name = "TwinhanDTV StarBox DVB-S USB2.0 (VP7020)", 307/* { .name = "TwinhanDTV StarBox DVB-S USB2.0 (VP7020)",
252 .cold_ids = { &vp702x_usb_table[2], NULL }, 308 .cold_ids = { &vp702x_usb_table[2], NULL },
253 .warm_ids = { &vp702x_usb_table[3], NULL }, 309 .warm_ids = { &vp702x_usb_table[3], NULL },
254 }, 310 },
255 { 0 }, 311*/ { NULL },
256 } 312 }
257}; 313};
258 314
259/* usb specific object needed to register this driver with the usb subsystem */ 315/* usb specific object needed to register this driver with the usb subsystem */
260static struct usb_driver vp702x_usb_driver = { 316static struct usb_driver vp702x_usb_driver = {
261 .name = "dvb-usb-vp702x", 317 .name = "dvb_usb_vp702x",
262 .probe = vp702x_usb_probe, 318 .probe = vp702x_usb_probe,
263 .disconnect = dvb_usb_device_exit, 319 .disconnect = dvb_usb_device_exit,
264 .id_table = vp702x_usb_table, 320 .id_table = vp702x_usb_table,
@@ -287,5 +343,5 @@ module_exit(vp702x_usb_module_exit);
287 343
288MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>"); 344MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
289MODULE_DESCRIPTION("Driver for Twinhan StarBox DVB-S USB2.0 and clones"); 345MODULE_DESCRIPTION("Driver for Twinhan StarBox DVB-S USB2.0 and clones");
290MODULE_VERSION("1.0-alpha"); 346MODULE_VERSION("1.0");
291MODULE_LICENSE("GPL"); 347MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/dvb-usb/vp702x.h b/drivers/media/dvb/dvb-usb/vp702x.h
index c2f97f96c21f..25a9dee4c824 100644
--- a/drivers/media/dvb/dvb-usb/vp702x.h
+++ b/drivers/media/dvb/dvb-usb/vp702x.h
@@ -102,5 +102,7 @@ extern struct dvb_frontend * vp702x_fe_attach(struct dvb_usb_device *d);
102 102
103extern int vp702x_usb_inout_op(struct dvb_usb_device *d, u8 *o, int olen, u8 *i, int ilen, int msec); 103extern int vp702x_usb_inout_op(struct dvb_usb_device *d, u8 *o, int olen, u8 *i, int ilen, int msec);
104extern int vp702x_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen); 104extern int vp702x_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen);
105extern int vp702x_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen);
106extern int vp702x_power_ctrl(struct dvb_usb_device *d, int onoff);
105 107
106#endif 108#endif
diff --git a/drivers/media/dvb/dvb-usb/vp7045.c b/drivers/media/dvb/dvb-usb/vp7045.c
index 8ea3834a6cf8..b4cf002703a7 100644
--- a/drivers/media/dvb/dvb-usb/vp7045.c
+++ b/drivers/media/dvb/dvb-usb/vp7045.c
@@ -169,31 +169,31 @@ static int vp7045_read_mac_addr(struct dvb_usb_device *d,u8 mac[6])
169 return vp7045_read_eeprom(d,mac, 6, MAC_0_ADDR); 169 return vp7045_read_eeprom(d,mac, 6, MAC_0_ADDR);
170} 170}
171 171
172static int vp7045_frontend_attach(struct dvb_usb_device *d) 172static int vp7045_frontend_attach(struct dvb_usb_adapter *adap)
173{ 173{
174 u8 buf[255] = { 0 }; 174 u8 buf[255] = { 0 };
175 175
176 vp7045_usb_op(d,VENDOR_STRING_READ,NULL,0,buf,20,0); 176 vp7045_usb_op(adap->dev,VENDOR_STRING_READ,NULL,0,buf,20,0);
177 buf[10] = '\0'; 177 buf[10] = '\0';
178 deb_info("firmware says: %s ",buf); 178 deb_info("firmware says: %s ",buf);
179 179
180 vp7045_usb_op(d,PRODUCT_STRING_READ,NULL,0,buf,20,0); 180 vp7045_usb_op(adap->dev,PRODUCT_STRING_READ,NULL,0,buf,20,0);
181 buf[10] = '\0'; 181 buf[10] = '\0';
182 deb_info("%s ",buf); 182 deb_info("%s ",buf);
183 183
184 vp7045_usb_op(d,FW_VERSION_READ,NULL,0,buf,20,0); 184 vp7045_usb_op(adap->dev,FW_VERSION_READ,NULL,0,buf,20,0);
185 buf[10] = '\0'; 185 buf[10] = '\0';
186 deb_info("v%s\n",buf); 186 deb_info("v%s\n",buf);
187 187
188/* Dump the EEPROM */ 188/* Dump the EEPROM */
189/* vp7045_read_eeprom(d,buf, 255, FX2_ID_ADDR); */ 189/* vp7045_read_eeprom(d,buf, 255, FX2_ID_ADDR); */
190 190
191 d->fe = vp7045_fe_attach(d); 191 adap->fe = vp7045_fe_attach(adap->dev);
192 192
193 return 0; 193 return 0;
194} 194}
195 195
196static struct dvb_usb_properties vp7045_properties; 196static struct dvb_usb_device_properties vp7045_properties;
197 197
198static int vp7045_usb_probe(struct usb_interface *intf, 198static int vp7045_usb_probe(struct usb_interface *intf,
199 const struct usb_device_id *id) 199 const struct usb_device_id *id)
@@ -210,24 +210,17 @@ static struct usb_device_id vp7045_usb_table [] = {
210}; 210};
211MODULE_DEVICE_TABLE(usb, vp7045_usb_table); 211MODULE_DEVICE_TABLE(usb, vp7045_usb_table);
212 212
213static struct dvb_usb_properties vp7045_properties = { 213static struct dvb_usb_device_properties vp7045_properties = {
214 .caps = 0,
215
216 .usb_ctrl = CYPRESS_FX2, 214 .usb_ctrl = CYPRESS_FX2,
217 .firmware = "dvb-usb-vp7045-01.fw", 215 .firmware = "dvb-usb-vp7045-01.fw",
218 216
219 .power_ctrl = vp7045_power_ctrl, 217 .num_adapters = 1,
218 .adapter = {
219 {
220 .frontend_attach = vp7045_frontend_attach, 220 .frontend_attach = vp7045_frontend_attach,
221 .read_mac_address = vp7045_read_mac_addr,
222
223 .rc_interval = 400,
224 .rc_key_map = vp7045_rc_keys,
225 .rc_key_map_size = ARRAY_SIZE(vp7045_rc_keys),
226 .rc_query = vp7045_rc_query,
227
228 /* parameter for the MPEG2-data transfer */ 221 /* parameter for the MPEG2-data transfer */
229 .urb = { 222 .stream = {
230 .type = DVB_USB_BULK, 223 .type = USB_BULK,
231 .count = 7, 224 .count = 7,
232 .endpoint = 0x02, 225 .endpoint = 0x02,
233 .u = { 226 .u = {
@@ -236,6 +229,15 @@ static struct dvb_usb_properties vp7045_properties = {
236 } 229 }
237 } 230 }
238 }, 231 },
232 }
233 },
234 .power_ctrl = vp7045_power_ctrl,
235 .read_mac_address = vp7045_read_mac_addr,
236
237 .rc_interval = 400,
238 .rc_key_map = vp7045_rc_keys,
239 .rc_key_map_size = ARRAY_SIZE(vp7045_rc_keys),
240 .rc_query = vp7045_rc_query,
239 241
240 .num_device_descs = 2, 242 .num_device_descs = 2,
241 .devices = { 243 .devices = {
diff --git a/drivers/media/dvb/frontends/cx24123.c b/drivers/media/dvb/frontends/cx24123.c
index 62d69a6ea699..a356d28fc3bb 100644
--- a/drivers/media/dvb/frontends/cx24123.c
+++ b/drivers/media/dvb/frontends/cx24123.c
@@ -553,8 +553,8 @@ static int cx24123_pll_calculate(struct dvb_frontend* fe, struct dvb_frontend_pa
553 ndiv = ( ((p->frequency * vco_div * 10) / (2 * XTAL / 1000)) / 32) & 0x1ff; 553 ndiv = ( ((p->frequency * vco_div * 10) / (2 * XTAL / 1000)) / 32) & 0x1ff;
554 adiv = ( ((p->frequency * vco_div * 10) / (2 * XTAL / 1000)) % 32) & 0x1f; 554 adiv = ( ((p->frequency * vco_div * 10) / (2 * XTAL / 1000)) % 32) & 0x1f;
555 555
556 if (adiv == 0) 556 if (adiv == 0 && ndiv > 0)
557 ndiv++; 557 ndiv--;
558 558
559 /* control bits 11, refdiv 11, charge pump polarity 1, charge pump current, ndiv, adiv */ 559 /* control bits 11, refdiv 11, charge pump polarity 1, charge pump current, ndiv, adiv */
560 state->pllarg = (3 << 19) | (3 << 17) | (1 << 16) | (pump << 14) | (ndiv << 5) | adiv; 560 state->pllarg = (3 << 19) | (3 << 17) | (1 << 16) | (pump << 14) | (ndiv << 5) | adiv;
diff --git a/drivers/media/dvb/frontends/dib3000mc.c b/drivers/media/dvb/frontends/dib3000mc.c
index cc28417fa33a..ccc813b525d6 100644
--- a/drivers/media/dvb/frontends/dib3000mc.c
+++ b/drivers/media/dvb/frontends/dib3000mc.c
@@ -37,6 +37,8 @@ struct dib3000mc_state {
37 37
38 struct dibx000_i2c_master i2c_master; 38 struct dibx000_i2c_master i2c_master;
39 39
40 u32 timf;
41
40 fe_bandwidth_t current_bandwidth; 42 fe_bandwidth_t current_bandwidth;
41 43
42 u16 dev_id; 44 u16 dev_id;
@@ -92,50 +94,31 @@ static int dib3000mc_identify(struct dib3000mc_state *state)
92 94
93static int dib3000mc_set_timing(struct dib3000mc_state *state, s16 nfft, u8 bw, u8 update_offset) 95static int dib3000mc_set_timing(struct dib3000mc_state *state, s16 nfft, u8 bw, u8 update_offset)
94{ 96{
95/* 97 u32 timf;
96 u32 timf_msb, timf_lsb, i;
97 int tim_sgn ;
98 LUInt comp1, comp2, comp ;
99// u32 tim_offset ;
100 comp = 27700 * BW_INDEX_TO_KHZ(bw) / 1000;
101 timf_msb = (comp >> 16) & 0x00FF;
102 timf_lsb = comp & 0xFFFF;
103
104 // Update the timing offset ;
105 if (update_offset) {
106 if (state->timing_offset_comp_done == 0) {
107 usleep(200000);
108 state->timing_offset_comp_done = 1;
109 }
110 tim_offset = dib3000mc_read_word(state, 416);
111 if ((tim_offset & 0x2000) == 0x2000)
112 tim_offset |= 0xC000; // PB: This only works if tim_offset is s16 - weird
113
114 if (nfft == 0)
115 tim_offset = tim_offset << 2; // PB: Do not store the offset for different things in one variable
116 state->timing_offset += tim_offset;
117 }
118 tim_offset = state->timing_offset;
119 98
120 if (tim_offset < 0) { 99 if (state->timf == 0) {
121 tim_sgn = 1; 100 timf = 1384402; // default value for 8MHz
122 tim_offset = -tim_offset; 101 if (update_offset)
102 msleep(200); // first time we do an update
123 } else 103 } else
124 tim_sgn = 0; 104 timf = state->timf;
125 105
126 comp1 = tim_offset * timf_lsb; 106 timf *= (BW_INDEX_TO_KHZ(bw) / 1000);
127 comp2 = tim_offset * timf_msb;
128 comp = ((comp1 >> 16) + comp2) >> 7;
129 107
130 if (tim_sgn == 0) 108 if (update_offset) {
131 comp = timf_msb * (1<<16) + timf_lsb + comp; 109 s16 tim_offs = dib3000mc_read_word(state, 416);
132 else 110
133 comp = timf_msb * (1<<16) + timf_lsb - comp; 111 if (tim_offs & 0x2000)
112 tim_offs -= 0x4000;
134 113
135 timf_msb = (comp>>16)&0xFF ; 114 if (nfft == 0)
136 timf_lsb = comp&0xFFFF; 115 tim_offs *= 4;
137*/ 116
138 u32 timf = 1384402 * (BW_INDEX_TO_KHZ(bw) / 1000); 117 timf += tim_offs;
118 state->timf = timf / (BW_INDEX_TO_KHZ(bw) / 1000);
119 }
120
121 dprintk("timf: %d\n", timf);
139 122
140 dib3000mc_write_word(state, 23, timf >> 16); 123 dib3000mc_write_word(state, 23, timf >> 16);
141 dib3000mc_write_word(state, 24, timf & 0xffff); 124 dib3000mc_write_word(state, 24, timf & 0xffff);
@@ -143,15 +126,18 @@ static int dib3000mc_set_timing(struct dib3000mc_state *state, s16 nfft, u8 bw,
143 return 0; 126 return 0;
144} 127}
145 128
146static int dib3000mc_setup_pwm3_state(struct dib3000mc_state *state) 129static int dib3000mc_setup_pwm_state(struct dib3000mc_state *state)
147{ 130{
131 u16 reg_51, reg_52 = state->cfg->agc->setup & 0xfefb;
148 if (state->cfg->pwm3_inversion) { 132 if (state->cfg->pwm3_inversion) {
149 dib3000mc_write_word(state, 51, (2 << 14) | (0 << 10) | (7 << 6) | (2 << 2) | (2 << 0)); 133 reg_51 = (2 << 14) | (0 << 10) | (7 << 6) | (2 << 2) | (2 << 0);
150 dib3000mc_write_word(state, 52, (0 << 8) | (5 << 5) | (1 << 4) | (1 << 3) | (1 << 2) | (2 << 0)); 134 reg_52 |= (1 << 2);
151 } else { 135 } else {
152 dib3000mc_write_word(state, 51, (2 << 14) | (4 << 10) | (7 << 6) | (2 << 2) | (2 << 0)); 136 reg_51 = (2 << 14) | (4 << 10) | (7 << 6) | (2 << 2) | (2 << 0);
153 dib3000mc_write_word(state, 52, (1 << 8) | (5 << 5) | (1 << 4) | (1 << 3) | (0 << 2) | (2 << 0)); 137 reg_52 |= (1 << 8);
154 } 138 }
139 dib3000mc_write_word(state, 51, reg_51);
140 dib3000mc_write_word(state, 52, reg_52);
155 141
156 if (state->cfg->use_pwm3) 142 if (state->cfg->use_pwm3)
157 dib3000mc_write_word(state, 245, (1 << 3) | (1 << 0)); 143 dib3000mc_write_word(state, 245, (1 << 3) | (1 << 0));
@@ -326,10 +312,10 @@ static int dib3000mc_init(struct dvb_frontend *demod)
326 dib3000mc_write_word(state, 175, 0x0000); 312 dib3000mc_write_word(state, 175, 0x0000);
327 dib3000mc_write_word(state, 1032, 0x012C); 313 dib3000mc_write_word(state, 1032, 0x012C);
328 } 314 }
329 dib3000mc_write_word(state, 1033, 0); 315 dib3000mc_write_word(state, 1033, 0x0000);
330 316
331 // P_clk_cfg 317 // P_clk_cfg
332 dib3000mc_write_word(state, 1037, 12592); 318 dib3000mc_write_word(state, 1037, 0x3130);
333 319
334 // other configurations 320 // other configurations
335 321
@@ -350,7 +336,7 @@ static int dib3000mc_init(struct dvb_frontend *demod)
350 dib3000mc_write_word(state, 50, 0x8000); 336 dib3000mc_write_word(state, 50, 0x8000);
351 337
352 // agc setup misc 338 // agc setup misc
353 dib3000mc_setup_pwm3_state(state); 339 dib3000mc_setup_pwm_state(state);
354 340
355 // P_agc_counter_lock 341 // P_agc_counter_lock
356 dib3000mc_write_word(state, 53, 0x87); 342 dib3000mc_write_word(state, 53, 0x87);
@@ -426,10 +412,9 @@ static int dib3000mc_sleep(struct dvb_frontend *demod)
426{ 412{
427 struct dib3000mc_state *state = demod->demodulator_priv; 413 struct dib3000mc_state *state = demod->demodulator_priv;
428 414
429 dib3000mc_write_word(state, 1037, dib3000mc_read_word(state, 1037) | 0x0003);
430 dib3000mc_write_word(state, 1031, 0xFFFF); 415 dib3000mc_write_word(state, 1031, 0xFFFF);
431 dib3000mc_write_word(state, 1032, 0xFFFF); 416 dib3000mc_write_word(state, 1032, 0xFFFF);
432 dib3000mc_write_word(state, 1033, 0xFFF4); // **** Bin2 417 dib3000mc_write_word(state, 1033, 0xFFF0);
433 418
434 return 0; 419 return 0;
435} 420}
@@ -539,6 +524,7 @@ static int dib3000mc_autosearch_start(struct dvb_frontend *demod, struct dibx000
539 524
540 reg = dib3000mc_read_word(state, 0); 525 reg = dib3000mc_read_word(state, 0);
541 dib3000mc_write_word(state, 0, reg | (1 << 8)); 526 dib3000mc_write_word(state, 0, reg | (1 << 8));
527 dib3000mc_read_word(state, 511);
542 dib3000mc_write_word(state, 0, reg); 528 dib3000mc_write_word(state, 0, reg);
543 529
544 return 0; 530 return 0;
@@ -578,59 +564,9 @@ static int dib3000mc_tune(struct dvb_frontend *demod, struct dibx000_ofdm_channe
578 dib3000mc_write_word(state, 33, 6); 564 dib3000mc_write_word(state, 33, 6);
579 } 565 }
580 566
581 // if (lock) 567 if (dib3000mc_read_word(state, 509) & 0x80)
582 // dib3000mc_set_timing(state, ch->nfft, ch->Bw, 1); 568 dib3000mc_set_timing(state, ch->nfft, ch->Bw, 1);
583
584 return 0;
585}
586
587static int dib3000mc_demod_output_mode(struct dvb_frontend *demod, int mode)
588{
589 struct dib3000mc_state *state = demod->demodulator_priv;
590 return dib3000mc_set_output_mode(state, mode);
591}
592
593static int dib3000mc_i2c_enumeration(struct dvb_frontend *demod[], int no_of_demods, u8 default_addr)
594{
595 struct dib3000mc_state *st;
596 int k,ret=0;
597 u8 new_addr;
598
599 static u8 DIB3000MC_I2C_ADDRESS[] = {20,22,24,26};
600
601 for (k = no_of_demods-1; k >= 0; k--) {
602 st = demod[k]->demodulator_priv;
603
604 /* designated i2c address */
605 new_addr = DIB3000MC_I2C_ADDRESS[k];
606
607 st->i2c_addr = new_addr;
608 if (dib3000mc_identify(st) != 0) {
609 st->i2c_addr = default_addr;
610 if (dib3000mc_identify(st) != 0) {
611 dprintk("-E- DiB3000P/MC #%d: not identified\n", k);
612 return -EINVAL;
613 }
614 }
615
616 /* turn on div_out */
617 dib3000mc_demod_output_mode(demod[k], OUTMODE_MPEG2_PAR_CONT_CLK);
618
619 // set new i2c address and force divstr (Bit 1) to value 0 (Bit 0)
620 ret |= dib3000mc_write_word(st, 1024, (new_addr << 3) | 0x1);
621 st->i2c_addr = new_addr;
622 }
623
624 for (k = 0; k < no_of_demods; k++) {
625 st = demod[k]->demodulator_priv;
626
627 ret |= dib3000mc_write_word(st, 1024, st->i2c_addr << 3);
628
629 /* turn off data output */
630 dib3000mc_demod_output_mode(demod[k],OUTMODE_HIGH_Z);
631 dib3000mc_write_word(st, 769, (1 << 7) );
632 569
633 }
634 return 0; 570 return 0;
635} 571}
636 572
@@ -826,61 +762,79 @@ void dib3000mc_set_config(struct dvb_frontend *fe, struct dib3000mc_config *cfg)
826} 762}
827EXPORT_SYMBOL(dib3000mc_set_config); 763EXPORT_SYMBOL(dib3000mc_set_config);
828 764
829static struct dvb_frontend_ops dib3000mc_ops; 765int dib3000mc_i2c_enumeration(struct i2c_adapter *i2c, int no_of_demods, u8 default_addr, struct dib3000mc_config cfg[])
830
831int dib3000mc_attach(struct i2c_adapter *i2c_adap, int no_of_demods, u8 default_addr, u8 do_i2c_enum, struct dib3000mc_config cfg[], struct dvb_frontend *demod[])
832{ 766{
833 struct dib3000mc_state *st; 767 struct dib3000mc_state st = { .i2c_adap = i2c };
834 int k, num=0; 768 int k;
835 769 u8 new_addr;
836 if (no_of_demods < 1)
837 return -EINVAL;
838 770
839 for (k = 0; k < no_of_demods; k++) { 771 static u8 DIB3000MC_I2C_ADDRESS[] = {20,22,24,26};
840 st = kzalloc(sizeof(struct dib3000mc_state), GFP_KERNEL);
841 if (st == NULL)
842 goto error;
843 772
844 num++; 773 for (k = no_of_demods-1; k >= 0; k--) {
774 st.cfg = &cfg[k];
845 775
846 st->cfg = &cfg[k]; 776 /* designated i2c address */
847 // st->gpio_val = cfg[k].gpio_val; 777 new_addr = DIB3000MC_I2C_ADDRESS[k];
848 // st->gpio_dir = cfg[k].gpio_dir; 778 st.i2c_addr = new_addr;
849 st->i2c_adap = i2c_adap; 779 if (dib3000mc_identify(&st) != 0) {
780 st.i2c_addr = default_addr;
781 if (dib3000mc_identify(&st) != 0) {
782 dprintk("-E- DiB3000P/MC #%d: not identified\n", k);
783 return -ENODEV;
784 }
785 }
850 786
851 demod[k] = &st->demod; 787 dib3000mc_set_output_mode(&st, OUTMODE_MPEG2_PAR_CONT_CLK);
852 demod[k]->demodulator_priv = st;
853 memcpy(&st->demod.ops, &dib3000mc_ops, sizeof(struct dvb_frontend_ops));
854 788
855// INIT_COMPONENT_REGISTER_ACCESS(&st->register_access, 12, 16, dib7000p_register_read, dib7000p_register_write, st); 789 // set new i2c address and force divstr (Bit 1) to value 0 (Bit 0)
856// demod[k]->register_access = &st->register_access; 790 dib3000mc_write_word(&st, 1024, (new_addr << 3) | 0x1);
791 st.i2c_addr = new_addr;
857 } 792 }
858 793
859 if (do_i2c_enum) { 794 for (k = 0; k < no_of_demods; k++) {
860 if (dib3000mc_i2c_enumeration(demod,no_of_demods,default_addr) != 0) 795 st.cfg = &cfg[k];
861 goto error; 796 st.i2c_addr = DIB3000MC_I2C_ADDRESS[k];
862 } else {
863 st = demod[0]->demodulator_priv;
864 st->i2c_addr = default_addr;
865 if (dib3000mc_identify(st) != 0)
866 goto error;
867 }
868 797
869 for (k = 0; k < num; k++) { 798 dib3000mc_write_word(&st, 1024, st.i2c_addr << 3);
870 st = demod[k]->demodulator_priv;
871 dibx000_init_i2c_master(&st->i2c_master, DIB3000MC, st->i2c_adap, st->i2c_addr);
872 }
873 799
800 /* turn off data output */
801 dib3000mc_set_output_mode(&st, OUTMODE_HIGH_Z);
802 }
874 return 0; 803 return 0;
804}
805EXPORT_SYMBOL(dib3000mc_i2c_enumeration);
806
807static struct dvb_frontend_ops dib3000mc_ops;
808
809struct dvb_frontend * dib3000mc_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib3000mc_config *cfg)
810{
811 struct dvb_frontend *demod;
812 struct dib3000mc_state *st;
813 st = kzalloc(sizeof(struct dib3000mc_state), GFP_KERNEL);
814 if (st == NULL)
815 return NULL;
816
817 st->cfg = cfg;
818 st->i2c_adap = i2c_adap;
819 st->i2c_addr = i2c_addr;
820
821 demod = &st->demod;
822 demod->demodulator_priv = st;
823 memcpy(&st->demod.ops, &dib3000mc_ops, sizeof(struct dvb_frontend_ops));
824
825 if (dib3000mc_identify(st) != 0)
826 goto error;
827
828 dibx000_init_i2c_master(&st->i2c_master, DIB3000MC, st->i2c_adap, st->i2c_addr);
829
830 dib3000mc_write_word(st, 1037, 0x3130);
831
832 return demod;
875 833
876error: 834error:
877 for (k = 0; k < num; k++) { 835 kfree(st);
878 kfree(demod[k]->demodulator_priv); 836 return NULL;
879 demod[k] = NULL;
880 }
881 return -EINVAL;
882} 837}
883
884EXPORT_SYMBOL(dib3000mc_attach); 838EXPORT_SYMBOL(dib3000mc_attach);
885 839
886static struct dvb_frontend_ops dib3000mc_ops = { 840static struct dvb_frontend_ops dib3000mc_ops = {
diff --git a/drivers/media/dvb/frontends/dib3000mc.h b/drivers/media/dvb/frontends/dib3000mc.h
index fd0b2e755993..b198cd5b1843 100644
--- a/drivers/media/dvb/frontends/dib3000mc.h
+++ b/drivers/media/dvb/frontends/dib3000mc.h
@@ -37,17 +37,17 @@ struct dib3000mc_config {
37#define DEFAULT_DIB3000P_I2C_ADDRESS 24 37#define DEFAULT_DIB3000P_I2C_ADDRESS 24
38 38
39#if defined(CONFIG_DVB_DIB3000MC) || defined(CONFIG_DVB_DIB3000MC_MODULE) 39#if defined(CONFIG_DVB_DIB3000MC) || defined(CONFIG_DVB_DIB3000MC_MODULE)
40extern int dib3000mc_attach(struct i2c_adapter *i2c_adap, int no_of_demods, u8 default_addr, 40extern struct dvb_frontend * dib3000mc_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib3000mc_config *cfg);
41 u8 do_i2c_enum, struct dib3000mc_config cfg[], struct dvb_frontend *demod[]);
42#else 41#else
43static inline struct dvb_frontend* dib3000mc_attach(const struct dib3000_config* config, 42static inline struct dvb_frontend * dib3000mc_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib3000mc_config *cfg)
44 struct i2c_adapter* i2c, struct dib_fe_xfer_ops *xfer_ops)
45{ 43{
46 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); 44 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
47 return NULL; 45 return NULL;
48} 46}
49#endif // CONFIG_DVB_DIB3000MC 47#endif // CONFIG_DVB_DIB3000MC
50 48
49extern int dib3000mc_i2c_enumeration(struct i2c_adapter *i2c, int no_of_demods, u8 default_addr, struct dib3000mc_config cfg[]);
50
51extern struct i2c_adapter * dib3000mc_get_tuner_i2c_master(struct dvb_frontend *demod, int gating); 51extern struct i2c_adapter * dib3000mc_get_tuner_i2c_master(struct dvb_frontend *demod, int gating);
52 52
53extern int dib3000mc_pid_control(struct dvb_frontend *fe, int index, int pid,int onoff); 53extern int dib3000mc_pid_control(struct dvb_frontend *fe, int index, int pid,int onoff);
diff --git a/drivers/media/dvb/frontends/mt2060.c b/drivers/media/dvb/frontends/mt2060.c
index 508ec1b6d1fb..450fad8d9b65 100644
--- a/drivers/media/dvb/frontends/mt2060.c
+++ b/drivers/media/dvb/frontends/mt2060.c
@@ -247,6 +247,9 @@ static void mt2060_calibrate(struct mt2060_priv *priv)
247 if (mt2060_writeregs(priv,mt2060_config2,sizeof(mt2060_config2))) 247 if (mt2060_writeregs(priv,mt2060_config2,sizeof(mt2060_config2)))
248 return; 248 return;
249 249
250 /* initialize the clock output */
251 mt2060_writereg(priv, REG_VGAG, (priv->cfg->clock_out << 6) | 0x30);
252
250 do { 253 do {
251 b |= (1 << 6); // FM1SS; 254 b |= (1 << 6); // FM1SS;
252 mt2060_writereg(priv, REG_LO2C1,b); 255 mt2060_writereg(priv, REG_LO2C1,b);
@@ -294,13 +297,13 @@ static int mt2060_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth)
294static int mt2060_init(struct dvb_frontend *fe) 297static int mt2060_init(struct dvb_frontend *fe)
295{ 298{
296 struct mt2060_priv *priv = fe->tuner_priv; 299 struct mt2060_priv *priv = fe->tuner_priv;
297 return mt2060_writereg(priv, REG_VGAG,0x33); 300 return mt2060_writereg(priv, REG_VGAG, (priv->cfg->clock_out << 6) | 0x33);
298} 301}
299 302
300static int mt2060_sleep(struct dvb_frontend *fe) 303static int mt2060_sleep(struct dvb_frontend *fe)
301{ 304{
302 struct mt2060_priv *priv = fe->tuner_priv; 305 struct mt2060_priv *priv = fe->tuner_priv;
303 return mt2060_writereg(priv, REG_VGAG,0x30); 306 return mt2060_writereg(priv, REG_VGAG, (priv->cfg->clock_out << 6) | 0x30);
304} 307}
305 308
306static int mt2060_release(struct dvb_frontend *fe) 309static int mt2060_release(struct dvb_frontend *fe)
@@ -329,14 +332,14 @@ static const struct dvb_tuner_ops mt2060_tuner_ops = {
329}; 332};
330 333
331/* This functions tries to identify a MT2060 tuner by reading the PART/REV register. This is hasty. */ 334/* This functions tries to identify a MT2060 tuner by reading the PART/REV register. This is hasty. */
332int mt2060_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2060_config *cfg, u16 if1) 335struct dvb_frontend * mt2060_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2060_config *cfg, u16 if1)
333{ 336{
334 struct mt2060_priv *priv = NULL; 337 struct mt2060_priv *priv = NULL;
335 u8 id = 0; 338 u8 id = 0;
336 339
337 priv = kzalloc(sizeof(struct mt2060_priv), GFP_KERNEL); 340 priv = kzalloc(sizeof(struct mt2060_priv), GFP_KERNEL);
338 if (priv == NULL) 341 if (priv == NULL)
339 return -ENOMEM; 342 return NULL;
340 343
341 priv->cfg = cfg; 344 priv->cfg = cfg;
342 priv->i2c = i2c; 345 priv->i2c = i2c;
@@ -344,12 +347,12 @@ int mt2060_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt206
344 347
345 if (mt2060_readreg(priv,REG_PART_REV,&id) != 0) { 348 if (mt2060_readreg(priv,REG_PART_REV,&id) != 0) {
346 kfree(priv); 349 kfree(priv);
347 return -ENODEV; 350 return NULL;
348 } 351 }
349 352
350 if (id != PART_REV) { 353 if (id != PART_REV) {
351 kfree(priv); 354 kfree(priv);
352 return -ENODEV; 355 return NULL;
353 } 356 }
354 printk(KERN_INFO "MT2060: successfully identified (IF1 = %d)\n", if1); 357 printk(KERN_INFO "MT2060: successfully identified (IF1 = %d)\n", if1);
355 memcpy(&fe->ops.tuner_ops, &mt2060_tuner_ops, sizeof(struct dvb_tuner_ops)); 358 memcpy(&fe->ops.tuner_ops, &mt2060_tuner_ops, sizeof(struct dvb_tuner_ops));
@@ -358,7 +361,7 @@ int mt2060_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt206
358 361
359 mt2060_calibrate(priv); 362 mt2060_calibrate(priv);
360 363
361 return 0; 364 return fe;
362} 365}
363EXPORT_SYMBOL(mt2060_attach); 366EXPORT_SYMBOL(mt2060_attach);
364 367
diff --git a/drivers/media/dvb/frontends/mt2060.h b/drivers/media/dvb/frontends/mt2060.h
index c58b03e82345..34a37c2b556f 100644
--- a/drivers/media/dvb/frontends/mt2060.h
+++ b/drivers/media/dvb/frontends/mt2060.h
@@ -27,9 +27,9 @@ struct i2c_adapter;
27 27
28struct mt2060_config { 28struct mt2060_config {
29 u8 i2c_address; 29 u8 i2c_address;
30 /* Shall we add settings for the discrete outputs ? */ 30 u8 clock_out; /* 0 = off, 1 = CLK/4, 2 = CLK/2, 3 = CLK/1 */
31}; 31};
32 32
33extern int mt2060_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2060_config *cfg, u16 if1); 33extern struct dvb_frontend * mt2060_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2060_config *cfg, u16 if1);
34 34
35#endif 35#endif
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index f6779a422f1b..afb734df6e05 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -36,7 +36,7 @@ config VIDEO_HELPER_CHIPS_AUTO
36menu "Encoders/decoders and other helper chips" 36menu "Encoders/decoders and other helper chips"
37 depends on VIDEO_DEV && !VIDEO_HELPER_CHIPS_AUTO 37 depends on VIDEO_DEV && !VIDEO_HELPER_CHIPS_AUTO
38 38
39comment "Audio Decoders" 39comment "Audio decoders"
40 40
41config VIDEO_TVAUDIO 41config VIDEO_TVAUDIO
42 tristate "Simple audio decoder chips" 42 tristate "Simple audio decoder chips"
@@ -51,7 +51,7 @@ config VIDEO_TVAUDIO
51 module will be called tvaudio. 51 module will be called tvaudio.
52 52
53config VIDEO_TDA7432 53config VIDEO_TDA7432
54 tristate "Philips TDA7432 audio processor chip" 54 tristate "Philips TDA7432 audio processor"
55 depends on VIDEO_V4L1 && I2C 55 depends on VIDEO_V4L1 && I2C
56 ---help--- 56 ---help---
57 Support for tda7432 audio decoder chip found on some bt8xx boards. 57 Support for tda7432 audio decoder chip found on some bt8xx boards.
@@ -60,7 +60,7 @@ config VIDEO_TDA7432
60 module will be called tda7432. 60 module will be called tda7432.
61 61
62config VIDEO_TDA9840 62config VIDEO_TDA9840
63 tristate "Philips TDA9840 audio processor chip" 63 tristate "Philips TDA9840 audio processor"
64 depends on VIDEO_DEV && I2C 64 depends on VIDEO_DEV && I2C
65 ---help--- 65 ---help---
66 Support for tda9840 audio decoder chip found on some Zoran boards. 66 Support for tda9840 audio decoder chip found on some Zoran boards.
@@ -69,7 +69,7 @@ config VIDEO_TDA9840
69 module will be called tda9840. 69 module will be called tda9840.
70 70
71config VIDEO_TDA9875 71config VIDEO_TDA9875
72 tristate "Philips TDA9875 audio processor chip" 72 tristate "Philips TDA9875 audio processor"
73 depends on VIDEO_V4L1 && I2C 73 depends on VIDEO_V4L1 && I2C
74 ---help--- 74 ---help---
75 Support for tda9875 audio decoder chip found on some bt8xx boards. 75 Support for tda9875 audio decoder chip found on some bt8xx boards.
@@ -78,7 +78,7 @@ config VIDEO_TDA9875
78 module will be called tda9875. 78 module will be called tda9875.
79 79
80config VIDEO_TEA6415C 80config VIDEO_TEA6415C
81 tristate "Philips TEA6415C audio processor chip" 81 tristate "Philips TEA6415C audio processor"
82 depends on VIDEO_DEV && I2C 82 depends on VIDEO_DEV && I2C
83 ---help--- 83 ---help---
84 Support for tea6415c audio decoder chip found on some bt8xx boards. 84 Support for tea6415c audio decoder chip found on some bt8xx boards.
@@ -87,7 +87,7 @@ config VIDEO_TEA6415C
87 module will be called tea6415c. 87 module will be called tea6415c.
88 88
89config VIDEO_TEA6420 89config VIDEO_TEA6420
90 tristate "Philips TEA6420 audio processor chip" 90 tristate "Philips TEA6420 audio processor"
91 depends on VIDEO_DEV && I2C 91 depends on VIDEO_DEV && I2C
92 ---help--- 92 ---help---
93 Support for tea6420 audio decoder chip found on some bt8xx boards. 93 Support for tea6420 audio decoder chip found on some bt8xx boards.
@@ -143,64 +143,10 @@ config VIDEO_WM8739
143 To compile this driver as a module, choose M here: the 143 To compile this driver as a module, choose M here: the
144 module will be called wm8739. 144 module will be called wm8739.
145 145
146comment "MPEG video encoders"
147
148config VIDEO_CX2341X
149 tristate "Conexant CX2341x MPEG encoders"
150 depends on VIDEO_V4L2 && EXPERIMENTAL
151 ---help---
152 Support for the Conexant CX23416 MPEG encoders
153 and CX23415 MPEG encoder/decoders.
154
155 This module currently supports the encoding functions only.
156
157 To compile this driver as a module, choose M here: the
158 module will be called cx2341x.
159
160source "drivers/media/video/cx25840/Kconfig"
161
162comment "Video encoders"
163
164config VIDEO_SAA7127
165 tristate "Philips SAA7127/9 digital video encoders"
166 depends on VIDEO_V4L2 && I2C && EXPERIMENTAL
167 ---help---
168 Support for the Philips SAA7127/9 digital video encoders.
169
170 To compile this driver as a module, choose M here: the
171 module will be called saa7127.
172
173config VIDEO_SAA7185
174 tristate "Philips SAA7185 video encoder"
175 depends on VIDEO_V4L1 && I2C
176 ---help---
177 Support for the Philips SAA7185 video encoder.
178
179 To compile this driver as a module, choose M here: the
180 module will be called saa7185.
181
182config VIDEO_ADV7170
183 tristate "Analog Devices ADV7170 video encoder driver"
184 depends on VIDEO_V4L1 && I2C
185 ---help---
186 Support for the Analog Devices ADV7170 video encoder driver
187
188 To compile this driver as a module, choose M here: the
189 module will be called adv7170.
190
191config VIDEO_ADV7175
192 tristate "Analog Devices ADV7175 video encoder driver"
193 depends on VIDEO_V4L1 && I2C
194 ---help---
195 Support for the Analog Devices ADV7175 video encoder driver
196
197 To compile this driver as a module, choose M here: the
198 module will be called adv7175.
199
200comment "Video decoders" 146comment "Video decoders"
201 147
202config VIDEO_BT819 148config VIDEO_BT819
203 tristate "BT819A VideoStream Decoder" 149 tristate "BT819A VideoStream decoder"
204 depends on VIDEO_V4L1 && I2C 150 depends on VIDEO_V4L1 && I2C
205 ---help--- 151 ---help---
206 Support for BT819A video decoder. 152 Support for BT819A video decoder.
@@ -209,7 +155,7 @@ config VIDEO_BT819
209 module will be called bt819. 155 module will be called bt819.
210 156
211config VIDEO_BT856 157config VIDEO_BT856
212 tristate "BT856 VideoStream Decoder" 158 tristate "BT856 VideoStream decoder"
213 depends on VIDEO_V4L1 && I2C 159 depends on VIDEO_V4L1 && I2C
214 ---help--- 160 ---help---
215 Support for BT856 video decoder. 161 Support for BT856 video decoder.
@@ -218,7 +164,7 @@ config VIDEO_BT856
218 module will be called bt856. 164 module will be called bt856.
219 165
220config VIDEO_BT866 166config VIDEO_BT866
221 tristate "BT866 VideoStream Decoder" 167 tristate "BT866 VideoStream decoder"
222 depends on VIDEO_V4L1 && I2C 168 depends on VIDEO_V4L1 && I2C
223 ---help--- 169 ---help---
224 Support for BT866 video decoder. 170 Support for BT866 video decoder.
@@ -295,7 +241,7 @@ config VIDEO_TVP5150
295 module will be called tvp5150. 241 module will be called tvp5150.
296 242
297config VIDEO_VPX3220 243config VIDEO_VPX3220
298 tristate "vpx3220a, vpx3216b & vpx3214c video decoder driver" 244 tristate "vpx3220a, vpx3216b & vpx3214c video decoders"
299 depends on VIDEO_V4L1 && I2C 245 depends on VIDEO_V4L1 && I2C
300 ---help--- 246 ---help---
301 Support for VPX322x video decoders. 247 Support for VPX322x video decoders.
@@ -303,6 +249,62 @@ config VIDEO_VPX3220
303 To compile this driver as a module, choose M here: the 249 To compile this driver as a module, choose M here: the
304 module will be called vpx3220. 250 module will be called vpx3220.
305 251
252comment "Video and audio decoders"
253
254source "drivers/media/video/cx25840/Kconfig"
255
256comment "MPEG video encoders"
257
258config VIDEO_CX2341X
259 tristate "Conexant CX2341x MPEG encoders"
260 depends on VIDEO_V4L2 && EXPERIMENTAL
261 ---help---
262 Support for the Conexant CX23416 MPEG encoders
263 and CX23415 MPEG encoder/decoders.
264
265 This module currently supports the encoding functions only.
266
267 To compile this driver as a module, choose M here: the
268 module will be called cx2341x.
269
270comment "Video encoders"
271
272config VIDEO_SAA7127
273 tristate "Philips SAA7127/9 digital video encoders"
274 depends on VIDEO_V4L2 && I2C && EXPERIMENTAL
275 ---help---
276 Support for the Philips SAA7127/9 digital video encoders.
277
278 To compile this driver as a module, choose M here: the
279 module will be called saa7127.
280
281config VIDEO_SAA7185
282 tristate "Philips SAA7185 video encoder"
283 depends on VIDEO_V4L1 && I2C
284 ---help---
285 Support for the Philips SAA7185 video encoder.
286
287 To compile this driver as a module, choose M here: the
288 module will be called saa7185.
289
290config VIDEO_ADV7170
291 tristate "Analog Devices ADV7170 video encoder"
292 depends on VIDEO_V4L1 && I2C
293 ---help---
294 Support for the Analog Devices ADV7170 video encoder driver
295
296 To compile this driver as a module, choose M here: the
297 module will be called adv7170.
298
299config VIDEO_ADV7175
300 tristate "Analog Devices ADV7175 video encoder"
301 depends on VIDEO_V4L1 && I2C
302 ---help---
303 Support for the Analog Devices ADV7175 video encoder driver
304
305 To compile this driver as a module, choose M here: the
306 module will be called adv7175.
307
306comment "Video improvement chips" 308comment "Video improvement chips"
307 309
308config VIDEO_UPD64031A 310config VIDEO_UPD64031A
diff --git a/drivers/media/video/bt8xx/bttv-cards.c b/drivers/media/video/bt8xx/bttv-cards.c
index d23a42b1504f..a84903e0d810 100644
--- a/drivers/media/video/bt8xx/bttv-cards.c
+++ b/drivers/media/video/bt8xx/bttv-cards.c
@@ -2000,7 +2000,7 @@ struct tvcard bttv_tvcards[] = {
2000 .no_msp34xx = 1, 2000 .no_msp34xx = 1,
2001 .no_tda9875 = 1, 2001 .no_tda9875 = 1,
2002 .no_tda7432 = 1, 2002 .no_tda7432 = 1,
2003 .muxsel = { 3, 0, 1, 2 }, 2003 .muxsel = { 3, 1 },
2004 .pll = PLL_28, 2004 .pll = PLL_28,
2005 .no_gpioirq = 1, 2005 .no_gpioirq = 1,
2006 .has_dvb = 1, 2006 .has_dvb = 1,
diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c
index a7921f9d45d8..46738321adaf 100644
--- a/drivers/media/video/cx88/cx88-blackbird.c
+++ b/drivers/media/video/cx88/cx88-blackbird.c
@@ -896,7 +896,7 @@ static int mpeg_do_ioctl(struct inode *inode, struct file *file,
896 snprintf(name, sizeof(name), "%s/2", core->name); 896 snprintf(name, sizeof(name), "%s/2", core->name);
897 printk("%s/2: ============ START LOG STATUS ============\n", 897 printk("%s/2: ============ START LOG STATUS ============\n",
898 core->name); 898 core->name);
899 cx88_call_i2c_clients(core, VIDIOC_LOG_STATUS, 0); 899 cx88_call_i2c_clients(core, VIDIOC_LOG_STATUS, NULL);
900 cx2341x_log_status(&dev->params, name); 900 cx2341x_log_status(&dev->params, name);
901 printk("%s/2: ============= END LOG STATUS =============\n", 901 printk("%s/2: ============= END LOG STATUS =============\n",
902 core->name); 902 core->name);
@@ -1086,7 +1086,7 @@ static int __devinit blackbird_probe(struct pci_dev *pci_dev,
1086 return -EINVAL; 1086 return -EINVAL;
1087 1087
1088 err = -ENODEV; 1088 err = -ENODEV;
1089 if (!cx88_boards[core->board].blackbird) 1089 if (!(cx88_boards[core->board].mpeg & CX88_MPEG_BLACKBIRD))
1090 goto fail_core; 1090 goto fail_core;
1091 1091
1092 err = -ENOMEM; 1092 err = -ENOMEM;
diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c
index 6214eb823b29..af71d4225c76 100644
--- a/drivers/media/video/cx88/cx88-cards.c
+++ b/drivers/media/video/cx88/cx88-cards.c
@@ -294,7 +294,7 @@ struct cx88_board cx88_boards[] = {
294 .type = CX88_RADIO, 294 .type = CX88_RADIO,
295 .gpio0 = 0x0000bd62, 295 .gpio0 = 0x0000bd62,
296 }, 296 },
297 .blackbird = 1, 297 .mpeg = CX88_MPEG_BLACKBIRD,
298 }, 298 },
299 [CX88_BOARD_IODATA_GVVCP3PCI] = { 299 [CX88_BOARD_IODATA_GVVCP3PCI] = {
300 .name = "IODATA GV-VCP3/PCI", 300 .name = "IODATA GV-VCP3/PCI",
@@ -358,7 +358,7 @@ struct cx88_board cx88_boards[] = {
358 .type = CX88_RADIO, 358 .type = CX88_RADIO,
359 .gpio0 = 0x0000fde2, 359 .gpio0 = 0x0000fde2,
360 }, 360 },
361 .blackbird = 1, 361 .mpeg = CX88_MPEG_BLACKBIRD,
362 }, 362 },
363 [CX88_BOARD_MSI_TVANYWHERE] = { 363 [CX88_BOARD_MSI_TVANYWHERE] = {
364 .name = "MSI TV-@nywhere", 364 .name = "MSI TV-@nywhere",
@@ -401,7 +401,7 @@ struct cx88_board cx88_boards[] = {
401 .gpio0 = 0x0700, 401 .gpio0 = 0x0700,
402 .gpio2 = 0x0101, 402 .gpio2 = 0x0101,
403 }}, 403 }},
404 .dvb = 1, 404 .mpeg = CX88_MPEG_DVB,
405 }, 405 },
406 [CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1] = { 406 [CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1] = {
407 .name = "DViCO FusionHDTV DVB-T1", 407 .name = "DViCO FusionHDTV DVB-T1",
@@ -418,7 +418,7 @@ struct cx88_board cx88_boards[] = {
418 .vmux = 2, 418 .vmux = 2,
419 .gpio0 = 0x000027df, 419 .gpio0 = 0x000027df,
420 }}, 420 }},
421 .dvb = 1, 421 .mpeg = CX88_MPEG_DVB,
422 }, 422 },
423 [CX88_BOARD_KWORLD_LTV883] = { 423 [CX88_BOARD_KWORLD_LTV883] = {
424 .name = "KWorld LTV883RF", 424 .name = "KWorld LTV883RF",
@@ -488,7 +488,7 @@ struct cx88_board cx88_boards[] = {
488 .vmux = 2, 488 .vmux = 2,
489 .gpio0 = 0x0f00, 489 .gpio0 = 0x0f00,
490 }}, 490 }},
491 .dvb = 1, 491 .mpeg = CX88_MPEG_DVB,
492 }, 492 },
493 [CX88_BOARD_HAUPPAUGE_DVB_T1] = { 493 [CX88_BOARD_HAUPPAUGE_DVB_T1] = {
494 .name = "Hauppauge Nova-T DVB-T", 494 .name = "Hauppauge Nova-T DVB-T",
@@ -500,7 +500,7 @@ struct cx88_board cx88_boards[] = {
500 .type = CX88_VMUX_DVB, 500 .type = CX88_VMUX_DVB,
501 .vmux = 0, 501 .vmux = 0,
502 }}, 502 }},
503 .dvb = 1, 503 .mpeg = CX88_MPEG_DVB,
504 }, 504 },
505 [CX88_BOARD_CONEXANT_DVB_T1] = { 505 [CX88_BOARD_CONEXANT_DVB_T1] = {
506 .name = "Conexant DVB-T reference design", 506 .name = "Conexant DVB-T reference design",
@@ -512,7 +512,7 @@ struct cx88_board cx88_boards[] = {
512 .type = CX88_VMUX_DVB, 512 .type = CX88_VMUX_DVB,
513 .vmux = 0, 513 .vmux = 0,
514 }}, 514 }},
515 .dvb = 1, 515 .mpeg = CX88_MPEG_DVB,
516 }, 516 },
517 [CX88_BOARD_PROVIDEO_PV259] = { 517 [CX88_BOARD_PROVIDEO_PV259] = {
518 .name = "Provideo PV259", 518 .name = "Provideo PV259",
@@ -524,7 +524,7 @@ struct cx88_board cx88_boards[] = {
524 .type = CX88_VMUX_TELEVISION, 524 .type = CX88_VMUX_TELEVISION,
525 .vmux = 0, 525 .vmux = 0,
526 }}, 526 }},
527 .blackbird = 1, 527 .mpeg = CX88_MPEG_BLACKBIRD,
528 }, 528 },
529 [CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS] = { 529 [CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS] = {
530 .name = "DViCO FusionHDTV DVB-T Plus", 530 .name = "DViCO FusionHDTV DVB-T Plus",
@@ -541,7 +541,7 @@ struct cx88_board cx88_boards[] = {
541 .vmux = 2, 541 .vmux = 2,
542 .gpio0 = 0x000027df, 542 .gpio0 = 0x000027df,
543 }}, 543 }},
544 .dvb = 1, 544 .mpeg = CX88_MPEG_DVB,
545 }, 545 },
546 [CX88_BOARD_DNTV_LIVE_DVB_T] = { 546 [CX88_BOARD_DNTV_LIVE_DVB_T] = {
547 .name = "digitalnow DNTV Live! DVB-T", 547 .name = "digitalnow DNTV Live! DVB-T",
@@ -560,7 +560,7 @@ struct cx88_board cx88_boards[] = {
560 .gpio0 = 0x00000700, 560 .gpio0 = 0x00000700,
561 .gpio2 = 0x00000101, 561 .gpio2 = 0x00000101,
562 }}, 562 }},
563 .dvb = 1, 563 .mpeg = CX88_MPEG_DVB,
564 }, 564 },
565 [CX88_BOARD_PCHDTV_HD3000] = { 565 [CX88_BOARD_PCHDTV_HD3000] = {
566 .name = "pcHDTV HD3000 HDTV", 566 .name = "pcHDTV HD3000 HDTV",
@@ -599,7 +599,7 @@ struct cx88_board cx88_boards[] = {
599 .gpio2 = 0x00000000, 599 .gpio2 = 0x00000000,
600 .gpio3 = 0x00000000, 600 .gpio3 = 0x00000000,
601 }, 601 },
602 .dvb = 1, 602 .mpeg = CX88_MPEG_DVB,
603 }, 603 },
604 [CX88_BOARD_HAUPPAUGE_ROSLYN] = { 604 [CX88_BOARD_HAUPPAUGE_ROSLYN] = {
605 // entry added by Kaustubh D. Bhalerao <bhalerao.1@osu.edu> 605 // entry added by Kaustubh D. Bhalerao <bhalerao.1@osu.edu>
@@ -633,7 +633,7 @@ struct cx88_board cx88_boards[] = {
633 .gpio0 = 0xed96, 633 .gpio0 = 0xed96,
634 .gpio2 = 0x00ff, 634 .gpio2 = 0x00ff,
635 }, 635 },
636 .blackbird = 1, 636 .mpeg = CX88_MPEG_BLACKBIRD,
637 }, 637 },
638 [CX88_BOARD_DIGITALLOGIC_MEC] = { 638 [CX88_BOARD_DIGITALLOGIC_MEC] = {
639 .name = "Digital-Logic MICROSPACE Entertainment Center (MEC)", 639 .name = "Digital-Logic MICROSPACE Entertainment Center (MEC)",
@@ -659,7 +659,7 @@ struct cx88_board cx88_boards[] = {
659 .type = CX88_RADIO, 659 .type = CX88_RADIO,
660 .gpio0 = 0x00009d00, 660 .gpio0 = 0x00009d00,
661 }, 661 },
662 .blackbird = 1, 662 .mpeg = CX88_MPEG_BLACKBIRD,
663 }, 663 },
664 [CX88_BOARD_IODATA_GVBCTV7E] = { 664 [CX88_BOARD_IODATA_GVBCTV7E] = {
665 .name = "IODATA GV/BCTV7E", 665 .name = "IODATA GV/BCTV7E",
@@ -727,7 +727,7 @@ struct cx88_board cx88_boards[] = {
727 .vmux = 2, 727 .vmux = 2,
728 .gpio0 = 0x97e9, 728 .gpio0 = 0x97e9,
729 }}, 729 }},
730 .dvb = 1, 730 .mpeg = CX88_MPEG_DVB,
731 }, 731 },
732 [CX88_BOARD_ADSTECH_DVB_T_PCI] = { 732 [CX88_BOARD_ADSTECH_DVB_T_PCI] = {
733 .name = "ADS Tech Instant TV DVB-T PCI", 733 .name = "ADS Tech Instant TV DVB-T PCI",
@@ -746,7 +746,7 @@ struct cx88_board cx88_boards[] = {
746 .gpio0 = 0x0700, 746 .gpio0 = 0x0700,
747 .gpio2 = 0x0101, 747 .gpio2 = 0x0101,
748 }}, 748 }},
749 .dvb = 1, 749 .mpeg = CX88_MPEG_DVB,
750 }, 750 },
751 [CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1] = { 751 [CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1] = {
752 .name = "TerraTec Cinergy 1400 DVB-T", 752 .name = "TerraTec Cinergy 1400 DVB-T",
@@ -755,7 +755,7 @@ struct cx88_board cx88_boards[] = {
755 .type = CX88_VMUX_DVB, 755 .type = CX88_VMUX_DVB,
756 .vmux = 0, 756 .vmux = 0,
757 }}, 757 }},
758 .dvb = 1, 758 .mpeg = CX88_MPEG_DVB,
759 }, 759 },
760 [CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD] = { 760 [CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD] = {
761 .name = "DViCO FusionHDTV 5 Gold", 761 .name = "DViCO FusionHDTV 5 Gold",
@@ -777,7 +777,7 @@ struct cx88_board cx88_boards[] = {
777 .vmux = 2, 777 .vmux = 2,
778 .gpio0 = 0x87f9, 778 .gpio0 = 0x87f9,
779 }}, 779 }},
780 .dvb = 1, 780 .mpeg = CX88_MPEG_DVB,
781 }, 781 },
782 [CX88_BOARD_AVERMEDIA_ULTRATV_MC_550] = { 782 [CX88_BOARD_AVERMEDIA_ULTRATV_MC_550] = {
783 .name = "AverMedia UltraTV Media Center PCI 550", 783 .name = "AverMedia UltraTV Media Center PCI 550",
@@ -786,7 +786,7 @@ struct cx88_board cx88_boards[] = {
786 .tuner_addr = ADDR_UNSET, 786 .tuner_addr = ADDR_UNSET,
787 .radio_addr = ADDR_UNSET, 787 .radio_addr = ADDR_UNSET,
788 .tda9887_conf = TDA9887_PRESENT, 788 .tda9887_conf = TDA9887_PRESENT,
789 .blackbird = 1, 789 .mpeg = CX88_MPEG_BLACKBIRD,
790 .input = {{ 790 .input = {{
791 .type = CX88_VMUX_COMPOSITE1, 791 .type = CX88_VMUX_COMPOSITE1,
792 .vmux = 0, 792 .vmux = 0,
@@ -854,7 +854,7 @@ struct cx88_board cx88_boards[] = {
854 .gpio2 = 0x00000001, 854 .gpio2 = 0x00000001,
855 .gpio3 = 0x00000000, 855 .gpio3 = 0x00000000,
856 }}, 856 }},
857 .dvb = 1, 857 .mpeg = CX88_MPEG_DVB,
858 }, 858 },
859 [CX88_BOARD_WINFAST_DTV1000] = { 859 [CX88_BOARD_WINFAST_DTV1000] = {
860 .name = "WinFast DTV1000-T", 860 .name = "WinFast DTV1000-T",
@@ -866,7 +866,7 @@ struct cx88_board cx88_boards[] = {
866 .type = CX88_VMUX_DVB, 866 .type = CX88_VMUX_DVB,
867 .vmux = 0, 867 .vmux = 0,
868 }}, 868 }},
869 .dvb = 1, 869 .mpeg = CX88_MPEG_DVB,
870 }, 870 },
871 [CX88_BOARD_AVERTV_303] = { 871 [CX88_BOARD_AVERTV_303] = {
872 .name = "AVerTV 303 (M126)", 872 .name = "AVerTV 303 (M126)",
@@ -914,7 +914,7 @@ struct cx88_board cx88_boards[] = {
914 .type = CX88_VMUX_SVIDEO, 914 .type = CX88_VMUX_SVIDEO,
915 .vmux = 2, 915 .vmux = 2,
916 }}, 916 }},
917 .dvb = 1, 917 .mpeg = CX88_MPEG_DVB,
918 }, 918 },
919 [CX88_BOARD_HAUPPAUGE_NOVASE2_S1] = { 919 [CX88_BOARD_HAUPPAUGE_NOVASE2_S1] = {
920 .name = "Hauppauge Nova-SE2 DVB-S", 920 .name = "Hauppauge Nova-SE2 DVB-S",
@@ -926,7 +926,7 @@ struct cx88_board cx88_boards[] = {
926 .type = CX88_VMUX_DVB, 926 .type = CX88_VMUX_DVB,
927 .vmux = 0, 927 .vmux = 0,
928 }}, 928 }},
929 .dvb = 1, 929 .mpeg = CX88_MPEG_DVB,
930 }, 930 },
931 [CX88_BOARD_KWORLD_DVBS_100] = { 931 [CX88_BOARD_KWORLD_DVBS_100] = {
932 .name = "KWorld DVB-S 100", 932 .name = "KWorld DVB-S 100",
@@ -944,7 +944,7 @@ struct cx88_board cx88_boards[] = {
944 .type = CX88_VMUX_SVIDEO, 944 .type = CX88_VMUX_SVIDEO,
945 .vmux = 2, 945 .vmux = 2,
946 }}, 946 }},
947 .dvb = 1, 947 .mpeg = CX88_MPEG_DVB,
948 }, 948 },
949 [CX88_BOARD_HAUPPAUGE_HVR1100] = { 949 [CX88_BOARD_HAUPPAUGE_HVR1100] = {
950 .name = "Hauppauge WinTV-HVR1100 DVB-T/Hybrid", 950 .name = "Hauppauge WinTV-HVR1100 DVB-T/Hybrid",
@@ -964,7 +964,7 @@ struct cx88_board cx88_boards[] = {
964 .vmux = 2, 964 .vmux = 2,
965 }}, 965 }},
966 /* fixme: Add radio support */ 966 /* fixme: Add radio support */
967 .dvb = 1, 967 .mpeg = CX88_MPEG_DVB,
968 }, 968 },
969 [CX88_BOARD_HAUPPAUGE_HVR1100LP] = { 969 [CX88_BOARD_HAUPPAUGE_HVR1100LP] = {
970 .name = "Hauppauge WinTV-HVR1100 DVB-T/Hybrid (Low Profile)", 970 .name = "Hauppauge WinTV-HVR1100 DVB-T/Hybrid (Low Profile)",
@@ -981,7 +981,7 @@ struct cx88_board cx88_boards[] = {
981 .vmux = 1, 981 .vmux = 1,
982 }}, 982 }},
983 /* fixme: Add radio support */ 983 /* fixme: Add radio support */
984 .dvb = 1, 984 .mpeg = CX88_MPEG_DVB,
985 }, 985 },
986 [CX88_BOARD_DNTV_LIVE_DVB_T_PRO] = { 986 [CX88_BOARD_DNTV_LIVE_DVB_T_PRO] = {
987 .name = "digitalnow DNTV Live! DVB-T Pro", 987 .name = "digitalnow DNTV Live! DVB-T Pro",
@@ -1008,7 +1008,7 @@ struct cx88_board cx88_boards[] = {
1008 .type = CX88_RADIO, 1008 .type = CX88_RADIO,
1009 .gpio0 = 0xf80808, 1009 .gpio0 = 0xf80808,
1010 }, 1010 },
1011 .dvb = 1, 1011 .mpeg = CX88_MPEG_DVB,
1012 }, 1012 },
1013 [CX88_BOARD_KWORLD_DVB_T_CX22702] = { 1013 [CX88_BOARD_KWORLD_DVB_T_CX22702] = {
1014 /* Kworld V-stream Xpert DVB-T with Thomson tuner */ 1014 /* Kworld V-stream Xpert DVB-T with Thomson tuner */
@@ -1030,7 +1030,7 @@ struct cx88_board cx88_boards[] = {
1030 .gpio0 = 0x0700, 1030 .gpio0 = 0x0700,
1031 .gpio2 = 0x0101, 1031 .gpio2 = 0x0101,
1032 }}, 1032 }},
1033 .dvb = 1, 1033 .mpeg = CX88_MPEG_DVB,
1034 }, 1034 },
1035 [CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL] = { 1035 [CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL] = {
1036 .name = "DViCO FusionHDTV DVB-T Dual Digital", 1036 .name = "DViCO FusionHDTV DVB-T Dual Digital",
@@ -1047,7 +1047,7 @@ struct cx88_board cx88_boards[] = {
1047 .vmux = 2, 1047 .vmux = 2,
1048 .gpio0 = 0x000067df, 1048 .gpio0 = 0x000067df,
1049 }}, 1049 }},
1050 .dvb = 1, 1050 .mpeg = CX88_MPEG_DVB,
1051 }, 1051 },
1052 [CX88_BOARD_KWORLD_HARDWARE_MPEG_TV_XPERT] = { 1052 [CX88_BOARD_KWORLD_HARDWARE_MPEG_TV_XPERT] = {
1053 /* FIXME: Audio not working for s-video / composite inputs. */ 1053 /* FIXME: Audio not working for s-video / composite inputs. */
@@ -1075,7 +1075,7 @@ struct cx88_board cx88_boards[] = {
1075 .gpio0 = 0x3de6, 1075 .gpio0 = 0x3de6,
1076 .gpio2 = 0x00ff, 1076 .gpio2 = 0x00ff,
1077 }, 1077 },
1078 .blackbird = 1, 1078 .mpeg = CX88_MPEG_BLACKBIRD,
1079 }, 1079 },
1080 [CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID] = { 1080 [CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID] = {
1081 .name = "DViCO FusionHDTV DVB-T Hybrid", 1081 .name = "DViCO FusionHDTV DVB-T Hybrid",
@@ -1096,7 +1096,7 @@ struct cx88_board cx88_boards[] = {
1096 .vmux = 2, 1096 .vmux = 2,
1097 .gpio0 = 0x0000a75b, 1097 .gpio0 = 0x0000a75b,
1098 }}, 1098 }},
1099 .dvb = 1, 1099 .mpeg = CX88_MPEG_DVB,
1100 }, 1100 },
1101 [CX88_BOARD_PCHDTV_HD5500] = { 1101 [CX88_BOARD_PCHDTV_HD5500] = {
1102 .name = "pcHDTV HD5500 HDTV", 1102 .name = "pcHDTV HD5500 HDTV",
@@ -1118,7 +1118,7 @@ struct cx88_board cx88_boards[] = {
1118 .vmux = 2, 1118 .vmux = 2,
1119 .gpio0 = 0x87f9, 1119 .gpio0 = 0x87f9,
1120 }}, 1120 }},
1121 .dvb = 1, 1121 .mpeg = CX88_MPEG_DVB,
1122 }, 1122 },
1123 [CX88_BOARD_KWORLD_MCE200_DELUXE] = { 1123 [CX88_BOARD_KWORLD_MCE200_DELUXE] = {
1124 /* FIXME: tested TV input only, disabled composite, 1124 /* FIXME: tested TV input only, disabled composite,
@@ -1134,7 +1134,7 @@ struct cx88_board cx88_boards[] = {
1134 .vmux = 0, 1134 .vmux = 0,
1135 .gpio0 = 0x0000BDE6 1135 .gpio0 = 0x0000BDE6
1136 }}, 1136 }},
1137 .blackbird = 1, 1137 .mpeg = CX88_MPEG_BLACKBIRD,
1138 }, 1138 },
1139 [CX88_BOARD_PIXELVIEW_PLAYTV_P7000] = { 1139 [CX88_BOARD_PIXELVIEW_PLAYTV_P7000] = {
1140 /* FIXME: SVideo, Composite and FM inputs are untested */ 1140 /* FIXME: SVideo, Composite and FM inputs are untested */
@@ -1150,7 +1150,7 @@ struct cx88_board cx88_boards[] = {
1150 .vmux = 0, 1150 .vmux = 0,
1151 .gpio0 = 0x5da6, 1151 .gpio0 = 0x5da6,
1152 }}, 1152 }},
1153 .blackbird = 1, 1153 .mpeg = CX88_MPEG_BLACKBIRD,
1154 }, 1154 },
1155 [CX88_BOARD_NPGTECH_REALTV_TOP10FM] = { 1155 [CX88_BOARD_NPGTECH_REALTV_TOP10FM] = {
1156 .name = "NPG Tech Real TV FM Top 10", 1156 .name = "NPG Tech Real TV FM Top 10",
@@ -1192,7 +1192,7 @@ struct cx88_board cx88_boards[] = {
1192 .gpio2 = 0x00017304, 1192 .gpio2 = 0x00017304,
1193 .gpio3 = 0x02000000, 1193 .gpio3 = 0x02000000,
1194 }}, 1194 }},
1195 .dvb = 1, 1195 .mpeg = CX88_MPEG_DVB,
1196 }, 1196 },
1197 [CX88_BOARD_GENIATECH_DVBS] = { 1197 [CX88_BOARD_GENIATECH_DVBS] = {
1198 .name = "Geniatech DVB-S", 1198 .name = "Geniatech DVB-S",
@@ -1207,7 +1207,7 @@ struct cx88_board cx88_boards[] = {
1207 .type = CX88_VMUX_COMPOSITE1, 1207 .type = CX88_VMUX_COMPOSITE1,
1208 .vmux = 1, 1208 .vmux = 1,
1209 }}, 1209 }},
1210 .dvb = 1, 1210 .mpeg = CX88_MPEG_DVB,
1211 }, 1211 },
1212 [CX88_BOARD_HAUPPAUGE_HVR3000] = { 1212 [CX88_BOARD_HAUPPAUGE_HVR3000] = {
1213 /* FIXME: Add dvb & radio support */ 1213 /* FIXME: Add dvb & radio support */
@@ -1287,6 +1287,7 @@ struct cx88_board cx88_boards[] = {
1287 .tuner_addr = ADDR_UNSET, 1287 .tuner_addr = ADDR_UNSET,
1288 .radio_addr = ADDR_UNSET, 1288 .radio_addr = ADDR_UNSET,
1289 .tda9887_conf = TDA9887_PRESENT, 1289 .tda9887_conf = TDA9887_PRESENT,
1290 .audio_chip = AUDIO_CHIP_WM8775,
1290 .input = {{ 1291 .input = {{
1291 .type = CX88_VMUX_TELEVISION, 1292 .type = CX88_VMUX_TELEVISION,
1292 .vmux = 0, 1293 .vmux = 0,
@@ -1301,7 +1302,7 @@ struct cx88_board cx88_boards[] = {
1301 .gpio0 = 0xe780, 1302 .gpio0 = 0xe780,
1302 }}, 1303 }},
1303 /* fixme: Add radio support */ 1304 /* fixme: Add radio support */
1304 .dvb = 1, 1305 .mpeg = CX88_MPEG_DVB,
1305 }, 1306 },
1306}; 1307};
1307const unsigned int cx88_bcount = ARRAY_SIZE(cx88_boards); 1308const unsigned int cx88_bcount = ARRAY_SIZE(cx88_boards);
@@ -1581,6 +1582,14 @@ struct cx88_subid cx88_subids[] = {
1581 .subvendor = 0x107d, 1582 .subvendor = 0x107d,
1582 .subdevice = 0x6632, 1583 .subdevice = 0x6632,
1583 .card = CX88_BOARD_LEADTEK_PVR2000, 1584 .card = CX88_BOARD_LEADTEK_PVR2000,
1585 },{
1586 .subvendor = 0x12ab,
1587 .subdevice = 0x2300, /* Club3D Zap TV2100 */
1588 .card = CX88_BOARD_KWORLD_DVB_T_CX22702,
1589 },{
1590 .subvendor = 0x0070,
1591 .subdevice = 0x9000,
1592 .card = CX88_BOARD_HAUPPAUGE_DVB_T1,
1584 }, 1593 },
1585}; 1594};
1586const unsigned int cx88_idcount = ARRAY_SIZE(cx88_subids); 1595const unsigned int cx88_idcount = ARRAY_SIZE(cx88_subids);
diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c
index f379ede3049a..4b655f2ef278 100644
--- a/drivers/media/video/cx88/cx88-core.c
+++ b/drivers/media/video/cx88/cx88-core.c
@@ -658,13 +658,6 @@ static unsigned int inline norm_fsc8(struct cx88_tvnorm *norm)
658 return (norm->id & V4L2_STD_625_50) ? pal : ntsc; 658 return (norm->id & V4L2_STD_625_50) ? pal : ntsc;
659} 659}
660 660
661static unsigned int inline norm_notchfilter(struct cx88_tvnorm *norm)
662{
663 return (norm->id & V4L2_STD_625_50)
664 ? HLNotchFilter135PAL
665 : HLNotchFilter135NTSC;
666}
667
668static unsigned int inline norm_htotal(struct cx88_tvnorm *norm) 661static unsigned int inline norm_htotal(struct cx88_tvnorm *norm)
669{ 662{
670 /* Should always be Line Draw Time / (4*FSC) */ 663 /* Should always be Line Draw Time / (4*FSC) */
@@ -937,7 +930,7 @@ int cx88_set_tvnorm(struct cx88_core *core, struct cx88_tvnorm *norm)
937 // htotal 930 // htotal
938 tmp64 = norm_htotal(norm) * (u64)vdec_clock; 931 tmp64 = norm_htotal(norm) * (u64)vdec_clock;
939 do_div(tmp64, fsc8); 932 do_div(tmp64, fsc8);
940 htotal = (u32)tmp64 | (norm_notchfilter(norm) << 11); 933 htotal = (u32)tmp64 | (HLNotchFilter4xFsc << 11);
941 dprintk(1,"set_tvnorm: MO_HTOTAL 0x%08x [old=0x%08x,htotal=%d]\n", 934 dprintk(1,"set_tvnorm: MO_HTOTAL 0x%08x [old=0x%08x,htotal=%d]\n",
942 htotal, cx_read(MO_HTOTAL), (u32)tmp64); 935 htotal, cx_read(MO_HTOTAL), (u32)tmp64);
943 cx_write(MO_HTOTAL, htotal); 936 cx_write(MO_HTOTAL, htotal);
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index c87041dee21e..bd0c8797f26d 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -802,7 +802,7 @@ static int __devinit dvb_probe(struct pci_dev *pci_dev,
802 return -EINVAL; 802 return -EINVAL;
803 803
804 err = -ENODEV; 804 err = -ENODEV;
805 if (!cx88_boards[core->board].dvb) 805 if (!(cx88_boards[core->board].mpeg & CX88_MPEG_DVB))
806 goto fail_core; 806 goto fail_core;
807 807
808 err = -ENOMEM; 808 err = -ENOMEM;
diff --git a/drivers/media/video/cx88/cx88-i2c.c b/drivers/media/video/cx88/cx88-i2c.c
index 27b5dbb2ca1a..88af23a93870 100644
--- a/drivers/media/video/cx88/cx88-i2c.c
+++ b/drivers/media/video/cx88/cx88-i2c.c
@@ -145,7 +145,7 @@ void cx88_call_i2c_clients(struct cx88_core *core, unsigned int cmd, void *arg)
145 if (0 != core->i2c_rc) 145 if (0 != core->i2c_rc)
146 return; 146 return;
147 147
148 if (core->dvbdev) { 148 if ( (core->dvbdev) && (core->dvbdev->dvb.frontend) ) {
149 if (core->dvbdev->dvb.frontend->ops.i2c_gate_ctrl) 149 if (core->dvbdev->dvb.frontend->ops.i2c_gate_ctrl)
150 core->dvbdev->dvb.frontend->ops.i2c_gate_ctrl(core->dvbdev->dvb.frontend, 1); 150 core->dvbdev->dvb.frontend->ops.i2c_gate_ctrl(core->dvbdev->dvb.frontend, 1);
151 151
@@ -220,7 +220,7 @@ int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci)
220 220
221 if (core->tuner_type != TUNER_ABSENT) 221 if (core->tuner_type != TUNER_ABSENT)
222 core->i2c_adap.class |= I2C_CLASS_TV_ANALOG; 222 core->i2c_adap.class |= I2C_CLASS_TV_ANALOG;
223 if (cx88_boards[core->board].dvb) 223 if (cx88_boards[core->board].mpeg & CX88_MPEG_DVB)
224 core->i2c_adap.class |= I2C_CLASS_TV_DIGITAL; 224 core->i2c_adap.class |= I2C_CLASS_TV_DIGITAL;
225 225
226 core->i2c_adap.dev.parent = &pci->dev; 226 core->i2c_adap.dev.parent = &pci->dev;
diff --git a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c
index 138a4f692501..d6d980774c21 100644
--- a/drivers/media/video/cx88/cx88-mpeg.c
+++ b/drivers/media/video/cx88/cx88-mpeg.c
@@ -65,8 +65,17 @@ static int cx8802_start_dma(struct cx8802_dev *dev,
65 65
66 /* FIXME: this needs a review. 66 /* FIXME: this needs a review.
67 * also: move to cx88-blackbird + cx88-dvb source files? */ 67 * also: move to cx88-blackbird + cx88-dvb source files? */
68 if (cx88_boards[core->board].mpeg == (CX88_MPEG_DVB | CX88_MPEG_BLACKBIRD) ) {
69 /* Report a warning until the mini driver patch is applied,
70 * else the following conditions will set the dma registers incorrectly.
71 * This will be removed in the next major patch and changes to the conditions
72 * will be made.
73 */
74 printk(KERN_INFO "%s() board->(CX88_MPEG_DVB | CX88_MPEG_BLACKBIRD) is invalid\n", __FUNCTION__);
75 return -EINVAL;
76 }
68 77
69 if (cx88_boards[core->board].dvb) { 78 if (cx88_boards[core->board].mpeg & CX88_MPEG_DVB) {
70 /* negedge driven & software reset */ 79 /* negedge driven & software reset */
71 cx_write(TS_GEN_CNTRL, 0x0040 | dev->ts_gen_cntrl); 80 cx_write(TS_GEN_CNTRL, 0x0040 | dev->ts_gen_cntrl);
72 udelay(100); 81 udelay(100);
@@ -92,7 +101,7 @@ static int cx8802_start_dma(struct cx8802_dev *dev,
92 udelay(100); 101 udelay(100);
93 } 102 }
94 103
95 if (cx88_boards[core->board].blackbird) { 104 if (cx88_boards[core->board].mpeg & CX88_MPEG_BLACKBIRD) {
96 cx_write(MO_PINMUX_IO, 0x88); /* enable MPEG parallel IO */ 105 cx_write(MO_PINMUX_IO, 0x88); /* enable MPEG parallel IO */
97 106
98 cx_write(TS_GEN_CNTRL, 0x46); /* punctured clock TS & posedge driven & software reset */ 107 cx_write(TS_GEN_CNTRL, 0x46); /* punctured clock TS & posedge driven & software reset */
diff --git a/drivers/media/video/cx88/cx88-tvaudio.c b/drivers/media/video/cx88/cx88-tvaudio.c
index 741e7c5e69ec..58ba9f773524 100644
--- a/drivers/media/video/cx88/cx88-tvaudio.c
+++ b/drivers/media/video/cx88/cx88-tvaudio.c
@@ -142,7 +142,7 @@ static void set_audio_finish(struct cx88_core *core, u32 ctl)
142 cx_write(AUD_RATE_THRES_DMD, 0x000000C0); 142 cx_write(AUD_RATE_THRES_DMD, 0x000000C0);
143 cx88_start_audio_dma(core); 143 cx88_start_audio_dma(core);
144 144
145 if (cx88_boards[core->board].blackbird) { 145 if (cx88_boards[core->board].mpeg & CX88_MPEG_BLACKBIRD) {
146 /* sets sound input from external adc */ 146 /* sets sound input from external adc */
147 switch (core->board) { 147 switch (core->board) {
148 case CX88_BOARD_HAUPPAUGE_ROSLYN: 148 case CX88_BOARD_HAUPPAUGE_ROSLYN:
@@ -164,7 +164,7 @@ static void set_audio_finish(struct cx88_core *core, u32 ctl)
164 cx_write(AUD_I2SCNTL, 0); 164 cx_write(AUD_I2SCNTL, 0);
165 /* cx_write(AUD_APB_IN_RATE_ADJ, 0); */ 165 /* cx_write(AUD_APB_IN_RATE_ADJ, 0); */
166 } 166 }
167 if ((always_analog) || (!cx88_boards[core->board].blackbird)) { 167 if ((always_analog) || (!(cx88_boards[core->board].mpeg & CX88_MPEG_BLACKBIRD))) {
168 ctl |= EN_DAC_ENABLE; 168 ctl |= EN_DAC_ENABLE;
169 cx_write(AUD_CTL, ctl); 169 cx_write(AUD_CTL, ctl);
170 } 170 }
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index fbc79e9842aa..cb0c0eea20f9 100644
--- a/drivers/media/video/cx88/cx88-video.c
+++ b/drivers/media/video/cx88/cx88-video.c
@@ -1928,6 +1928,9 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
1928 if (TUNER_ABSENT != core->tuner_type) 1928 if (TUNER_ABSENT != core->tuner_type)
1929 request_module("tuner"); 1929 request_module("tuner");
1930 1930
1931 if (cx88_boards[ core->board ].audio_chip == AUDIO_CHIP_WM8775)
1932 request_module("wm8775");
1933
1931 /* register v4l devices */ 1934 /* register v4l devices */
1932 dev->video_dev = cx88_vdev_init(core,dev->pci, 1935 dev->video_dev = cx88_vdev_init(core,dev->pci,
1933 &cx8800_video_template,"video"); 1936 &cx8800_video_template,"video");
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index 89f12e273b7f..3bc91aad4fe5 100644
--- a/drivers/media/video/cx88/cx88.h
+++ b/drivers/media/video/cx88/cx88.h
@@ -30,6 +30,7 @@
30#include <media/tveeprom.h> 30#include <media/tveeprom.h>
31#include <media/video-buf.h> 31#include <media/video-buf.h>
32#include <media/cx2341x.h> 32#include <media/cx2341x.h>
33#include <media/audiochip.h>
33#include <media/video-buf-dvb.h> 34#include <media/video-buf-dvb.h>
34 35
35#include "btcx-risc.h" 36#include "btcx-risc.h"
@@ -39,12 +40,6 @@
39#include <linux/mutex.h> 40#include <linux/mutex.h>
40#define CX88_VERSION_CODE KERNEL_VERSION(0,0,6) 41#define CX88_VERSION_CODE KERNEL_VERSION(0,0,6)
41 42
42#ifndef TRUE
43# define TRUE (1==1)
44#endif
45#ifndef FALSE
46# define FALSE (1==0)
47#endif
48#define UNSET (-1U) 43#define UNSET (-1U)
49 44
50#define CX88_MAXBOARDS 8 45#define CX88_MAXBOARDS 8
@@ -73,6 +68,12 @@ enum cx88_deemph_type {
73 FM_DEEMPH_75 68 FM_DEEMPH_75
74}; 69};
75 70
71enum cx88_board_type {
72 CX88_BOARD_NONE = 0,
73 CX88_MPEG_DVB,
74 CX88_MPEG_BLACKBIRD
75};
76
76/* ----------------------------------------------------------- */ 77/* ----------------------------------------------------------- */
77/* tv norms */ 78/* tv norms */
78 79
@@ -230,8 +231,8 @@ struct cx88_board {
230 int tda9887_conf; 231 int tda9887_conf;
231 struct cx88_input input[MAX_CX88_INPUT]; 232 struct cx88_input input[MAX_CX88_INPUT];
232 struct cx88_input radio; 233 struct cx88_input radio;
233 unsigned int blackbird:1; 234 enum cx88_board_type mpeg;
234 unsigned int dvb:1; 235 enum audiochip audio_chip;
235}; 236};
236 237
237struct cx88_subid { 238struct cx88_subid {
diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c
index fba30a40e9c6..1457b1602221 100644
--- a/drivers/media/video/ir-kbd-i2c.c
+++ b/drivers/media/video/ir-kbd-i2c.c
@@ -64,23 +64,32 @@ MODULE_PARM_DESC(hauppauge, "Specify Hauppauge remote: 0=black, 1=grey (defaults
64static int get_key_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) 64static int get_key_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
65{ 65{
66 unsigned char buf[3]; 66 unsigned char buf[3];
67 int start, toggle, dev, code; 67 int start, range, toggle, dev, code;
68 68
69 /* poll IR chip */ 69 /* poll IR chip */
70 if (3 != i2c_master_recv(&ir->c,buf,3)) 70 if (3 != i2c_master_recv(&ir->c,buf,3))
71 return -EIO; 71 return -EIO;
72 72
73 /* split rc5 data block ... */ 73 /* split rc5 data block ... */
74 start = (buf[0] >> 6) & 3; 74 start = (buf[0] >> 7) & 1;
75 range = (buf[0] >> 6) & 1;
75 toggle = (buf[0] >> 5) & 1; 76 toggle = (buf[0] >> 5) & 1;
76 dev = buf[0] & 0x1f; 77 dev = buf[0] & 0x1f;
77 code = (buf[1] >> 2) & 0x3f; 78 code = (buf[1] >> 2) & 0x3f;
78 79
79 if (3 != start) 80 /* rc5 has two start bits
81 * the first bit must be one
82 * the second bit defines the command range (1 = 0-63, 0 = 64 - 127)
83 */
84 if (!start)
80 /* no key pressed */ 85 /* no key pressed */
81 return 0; 86 return 0;
82 dprintk(1,"ir hauppauge (rc5): s%d t%d dev=%d code=%d\n", 87
83 start, toggle, dev, code); 88 if (!range)
89 code += 64;
90
91 dprintk(1,"ir hauppauge (rc5): s%d r%d t%d dev=%d code=%d\n",
92 start, range, toggle, dev, code);
84 93
85 /* return key */ 94 /* return key */
86 *ir_key = code; 95 *ir_key = code;
diff --git a/drivers/media/video/msp3400-driver.c b/drivers/media/video/msp3400-driver.c
index 56246b8578f3..cf43df3fe708 100644
--- a/drivers/media/video/msp3400-driver.c
+++ b/drivers/media/video/msp3400-driver.c
@@ -904,6 +904,8 @@ static int msp_attach(struct i2c_adapter *adapter, int address, int kind)
904 state->has_virtual_dolby_surround = msp_revision == 'G' && msp_prod_lo == 1; 904 state->has_virtual_dolby_surround = msp_revision == 'G' && msp_prod_lo == 1;
905 /* Has Virtual Dolby Surround & Dolby Pro Logic: only in msp34x2 */ 905 /* Has Virtual Dolby Surround & Dolby Pro Logic: only in msp34x2 */
906 state->has_dolby_pro_logic = msp_revision == 'G' && msp_prod_lo == 2; 906 state->has_dolby_pro_logic = msp_revision == 'G' && msp_prod_lo == 2;
907 /* The msp343xG supports BTSC only and cannot do Automatic Standard Detection. */
908 state->force_btsc = msp_family == 3 && msp_revision == 'G' && msp_prod_hi == 3;
907 909
908 state->opmode = opmode; 910 state->opmode = opmode;
909 if (state->opmode == OPMODE_AUTO) { 911 if (state->opmode == OPMODE_AUTO) {
diff --git a/drivers/media/video/msp3400-driver.h b/drivers/media/video/msp3400-driver.h
index 545e4ac094f2..7531efa1615e 100644
--- a/drivers/media/video/msp3400-driver.h
+++ b/drivers/media/video/msp3400-driver.h
@@ -64,6 +64,7 @@ struct msp_state {
64 u8 has_sound_processing; 64 u8 has_sound_processing;
65 u8 has_virtual_dolby_surround; 65 u8 has_virtual_dolby_surround;
66 u8 has_dolby_pro_logic; 66 u8 has_dolby_pro_logic;
67 u8 force_btsc;
67 68
68 int radio; 69 int radio;
69 int opmode; 70 int opmode;
diff --git a/drivers/media/video/msp3400-kthreads.c b/drivers/media/video/msp3400-kthreads.c
index ed02ff811388..4c7f85b566a0 100644
--- a/drivers/media/video/msp3400-kthreads.c
+++ b/drivers/media/video/msp3400-kthreads.c
@@ -960,9 +960,10 @@ int msp34xxg_thread(void *data)
960 960
961 /* setup the chip*/ 961 /* setup the chip*/
962 msp34xxg_reset(client); 962 msp34xxg_reset(client);
963 state->std = state->radio ? 0x40 : msp_standard; 963 state->std = state->radio ? 0x40 :
964 /* start autodetect */ 964 (state->force_btsc && msp_standard == 1) ? 32 : msp_standard;
965 msp_write_dem(client, 0x20, state->std); 965 msp_write_dem(client, 0x20, state->std);
966 /* start autodetect */
966 if (state->std != 1) 967 if (state->std != 1)
967 goto unmute; 968 goto unmute;
968 969
diff --git a/drivers/media/video/pvrusb2/Kconfig b/drivers/media/video/pvrusb2/Kconfig
index a52171ef6134..5645c9318890 100644
--- a/drivers/media/video/pvrusb2/Kconfig
+++ b/drivers/media/video/pvrusb2/Kconfig
@@ -18,8 +18,8 @@ config VIDEO_PVRUSB2_29XXX
18 select VIDEO_SAA711X 18 select VIDEO_SAA711X
19 select VIDEO_MSP3400 19 select VIDEO_MSP3400
20 ---help--- 20 ---help---
21 This option enables support for WinTV-PVR USB2 devices whose 21 This option enables support for WinTV-PVR USB2 devices whose
22 model number is of the form "29xxx" (leading prefix of "29" 22 model number is of the form "29xxx" (leading prefix of "29"
23 followed by 3 digits). 23 followed by 3 digits).
24 To see if you may need this option, examine the white 24 To see if you may need this option, examine the white
25 sticker on the underside of your device. 25 sticker on the underside of your device.
@@ -37,14 +37,9 @@ config VIDEO_PVRUSB2_24XXX
37 form "24xxx" (leading prefix of "24" followed by 3 digits). 37 form "24xxx" (leading prefix of "24" followed by 3 digits).
38 To see if you may need this option, examine the white 38 To see if you may need this option, examine the white
39 sticker on the underside of your device. Enabling this 39 sticker on the underside of your device. Enabling this
40 option will not harm support for older devices, however it 40 option will not harm support for older devices.
41 is a separate option because of the experimental nature of
42 this new feature.
43 41
44 If you are in doubt, say N. 42 If you are in doubt, say Y.
45
46 Note: This feature is _very_ experimental. You have been
47 warned.
48 43
49config VIDEO_PVRUSB2_SYSFS 44config VIDEO_PVRUSB2_SYSFS
50 bool "pvrusb2 sysfs support (EXPERIMENTAL)" 45 bool "pvrusb2 sysfs support (EXPERIMENTAL)"
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index 88604365777c..3d8cd0daf6a9 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -24,6 +24,7 @@
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/firmware.h> 25#include <linux/firmware.h>
26#include <linux/videodev2.h> 26#include <linux/videodev2.h>
27#include <media/v4l2-common.h>
27#include <asm/semaphore.h> 28#include <asm/semaphore.h>
28#include "pvrusb2.h" 29#include "pvrusb2.h"
29#include "pvrusb2-std.h" 30#include "pvrusb2-std.h"
@@ -3131,6 +3132,42 @@ static int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw)
3131} 3132}
3132 3133
3133 3134
3135int pvr2_hdw_register_access(struct pvr2_hdw *hdw,
3136 u32 chip_id,unsigned long reg_id,
3137 int setFl,u32 *val_ptr)
3138{
3139#ifdef CONFIG_VIDEO_ADV_DEBUG
3140 struct list_head *item;
3141 struct pvr2_i2c_client *cp;
3142 struct v4l2_register req;
3143 int stat = 0;
3144 int okFl = 0;
3145
3146 req.i2c_id = chip_id;
3147 req.reg = reg_id;
3148 if (setFl) req.val = *val_ptr;
3149 mutex_lock(&hdw->i2c_list_lock); do {
3150 list_for_each(item,&hdw->i2c_clients) {
3151 cp = list_entry(item,struct pvr2_i2c_client,list);
3152 if (cp->client->driver->id != chip_id) continue;
3153 stat = pvr2_i2c_client_cmd(
3154 cp,(setFl ? VIDIOC_INT_S_REGISTER :
3155 VIDIOC_INT_G_REGISTER),&req);
3156 if (!setFl) *val_ptr = req.val;
3157 okFl = !0;
3158 break;
3159 }
3160 } while (0); mutex_unlock(&hdw->i2c_list_lock);
3161 if (okFl) {
3162 return stat;
3163 }
3164 return -EINVAL;
3165#else
3166 return -ENOSYS;
3167#endif
3168}
3169
3170
3134/* 3171/*
3135 Stuff for Emacs to see, in order to encourage consistent editing style: 3172 Stuff for Emacs to see, in order to encourage consistent editing style:
3136 *** Local Variables: *** 3173 *** Local Variables: ***
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.h b/drivers/media/video/pvrusb2/pvrusb2-hdw.h
index fd931b5da490..29979bb2a768 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.h
@@ -211,6 +211,14 @@ int pvr2_hdw_v4l_get_minor_number(struct pvr2_hdw *);
211/* Store the v4l minor device number */ 211/* Store the v4l minor device number */
212void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *,int); 212void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *,int);
213 213
214/* Direct read/write access to chip's registers:
215 chip_id - unique id of chip (e.g. I2C_DRIVERD_xxxx)
216 reg_id - register number to access
217 setFl - true to set the register, false to read it
218 val_ptr - storage location for source / result. */
219int pvr2_hdw_register_access(struct pvr2_hdw *,
220 u32 chip_id,unsigned long reg_id,
221 int setFl,u32 *val_ptr);
214 222
215/* The following entry points are all lower level things you normally don't 223/* The following entry points are all lower level things you normally don't
216 want to worry about. */ 224 want to worry about. */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-i2c-chips-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-i2c-chips-v4l2.c
index ed3e8105292a..05121666b9ba 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-i2c-chips-v4l2.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-i2c-chips-v4l2.c
@@ -19,6 +19,7 @@
19 * 19 *
20 */ 20 */
21 21
22#include <linux/kernel.h>
22#include "pvrusb2-i2c-core.h" 23#include "pvrusb2-i2c-core.h"
23#include "pvrusb2-hdw-internal.h" 24#include "pvrusb2-hdw-internal.h"
24#include "pvrusb2-debug.h" 25#include "pvrusb2-debug.h"
@@ -89,7 +90,8 @@ void pvr2_i2c_probe(struct pvr2_hdw *hdw,struct pvr2_i2c_client *cp)
89 90
90const struct pvr2_i2c_op *pvr2_i2c_get_op(unsigned int idx) 91const struct pvr2_i2c_op *pvr2_i2c_get_op(unsigned int idx)
91{ 92{
92 if (idx >= sizeof(ops)/sizeof(ops[0])) return 0; 93 if (idx >= ARRAY_SIZE(ops))
94 return NULL;
93 return ops[idx]; 95 return ops[idx];
94} 96}
95 97
diff --git a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
index 3608c2f81df9..97e974d9b9c3 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
@@ -29,27 +29,17 @@
29#include "pvrusb2-v4l2.h" 29#include "pvrusb2-v4l2.h"
30#include "pvrusb2-ioread.h" 30#include "pvrusb2-ioread.h"
31#include <linux/videodev2.h> 31#include <linux/videodev2.h>
32#include <media/v4l2-dev.h>
32#include <media/v4l2-common.h> 33#include <media/v4l2-common.h>
33 34
34struct pvr2_v4l2_dev; 35struct pvr2_v4l2_dev;
35struct pvr2_v4l2_fh; 36struct pvr2_v4l2_fh;
36struct pvr2_v4l2; 37struct pvr2_v4l2;
37 38
38/* V4L no longer provide the ability to set / get a private context pointer
39 (i.e. video_get_drvdata / video_set_drvdata), which means we have to
40 concoct our own context locating mechanism. Supposedly this is intended
41 to simplify driver implementation. It's not clear to me how that can
42 possibly be true. Our solution here is to maintain a lookup table of
43 our context instances, indexed by the minor device number of the V4L
44 device. See pvr2_v4l2_open() for some implications of this approach. */
45static struct pvr2_v4l2_dev *devices[256];
46static DEFINE_MUTEX(device_lock);
47
48struct pvr2_v4l2_dev { 39struct pvr2_v4l2_dev {
40 struct video_device devbase; /* MUST be first! */
49 struct pvr2_v4l2 *v4lp; 41 struct pvr2_v4l2 *v4lp;
50 struct video_device *vdev;
51 struct pvr2_context_stream *stream; 42 struct pvr2_context_stream *stream;
52 int ctxt_idx;
53 enum pvr2_config config; 43 enum pvr2_config config;
54}; 44};
55 45
@@ -74,7 +64,7 @@ struct pvr2_v4l2 {
74 struct v4l2_prio_state prio; 64 struct v4l2_prio_state prio;
75 65
76 /* streams */ 66 /* streams */
77 struct pvr2_v4l2_dev video_dev; 67 struct pvr2_v4l2_dev *vdev;
78}; 68};
79 69
80static int video_nr[PVR_NUM] = {[0 ... PVR_NUM-1] = -1}; 70static int video_nr[PVR_NUM] = {[0 ... PVR_NUM-1] = -1};
@@ -671,6 +661,20 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file,
671 ret = 0; 661 ret = 0;
672 break; 662 break;
673 } 663 }
664#ifdef CONFIG_VIDEO_ADV_DEBUG
665 case VIDIOC_INT_G_REGISTER:
666 case VIDIOC_INT_S_REGISTER:
667 {
668 u32 val;
669 struct v4l2_register *req = (struct v4l2_register *)arg;
670 if (cmd == VIDIOC_INT_S_REGISTER) val = req->val;
671 ret = pvr2_hdw_register_access(
672 hdw,req->i2c_id,req->reg,
673 cmd == VIDIOC_INT_S_REGISTER,&val);
674 if (cmd == VIDIOC_INT_G_REGISTER) req->val = val;
675 break;
676 }
677#endif
674 678
675 default : 679 default :
676 ret = v4l_compat_translate_ioctl(inode,file,cmd, 680 ret = v4l_compat_translate_ioctl(inode,file,cmd,
@@ -704,21 +708,22 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file,
704static void pvr2_v4l2_dev_destroy(struct pvr2_v4l2_dev *dip) 708static void pvr2_v4l2_dev_destroy(struct pvr2_v4l2_dev *dip)
705{ 709{
706 printk(KERN_INFO "pvrusb2: unregistering device video%d [%s]\n", 710 printk(KERN_INFO "pvrusb2: unregistering device video%d [%s]\n",
707 dip->vdev->minor,pvr2_config_get_name(dip->config)); 711 dip->devbase.minor,pvr2_config_get_name(dip->config));
708 if (dip->ctxt_idx >= 0) { 712
709 mutex_lock(&device_lock); 713 /* Paranoia */
710 devices[dip->ctxt_idx] = NULL; 714 dip->v4lp = 0;
711 dip->ctxt_idx = -1; 715 dip->stream = 0;
712 mutex_unlock(&device_lock); 716
713 } 717 /* Actual deallocation happens later when all internal references
714 video_unregister_device(dip->vdev); 718 are gone. */
719 video_unregister_device(&dip->devbase);
715} 720}
716 721
717 722
718static void pvr2_v4l2_destroy_no_lock(struct pvr2_v4l2 *vp) 723static void pvr2_v4l2_destroy_no_lock(struct pvr2_v4l2 *vp)
719{ 724{
720 pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw,-1); 725 pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw,-1);
721 pvr2_v4l2_dev_destroy(&vp->video_dev); 726 pvr2_v4l2_dev_destroy(vp->vdev);
722 727
723 pvr2_trace(PVR2_TRACE_STRUCT,"Destroying pvr2_v4l2 id=%p",vp); 728 pvr2_trace(PVR2_TRACE_STRUCT,"Destroying pvr2_v4l2 id=%p",vp);
724 pvr2_channel_done(&vp->channel); 729 pvr2_channel_done(&vp->channel);
@@ -726,6 +731,14 @@ static void pvr2_v4l2_destroy_no_lock(struct pvr2_v4l2 *vp)
726} 731}
727 732
728 733
734static void pvr2_video_device_release(struct video_device *vdev)
735{
736 struct pvr2_v4l2_dev *dev;
737 dev = container_of(vdev,struct pvr2_v4l2_dev,devbase);
738 kfree(dev);
739}
740
741
729static void pvr2_v4l2_internal_check(struct pvr2_channel *chp) 742static void pvr2_v4l2_internal_check(struct pvr2_channel *chp)
730{ 743{
731 struct pvr2_v4l2 *vp; 744 struct pvr2_v4l2 *vp;
@@ -797,40 +810,12 @@ static int pvr2_v4l2_release(struct inode *inode, struct file *file)
797 810
798static int pvr2_v4l2_open(struct inode *inode, struct file *file) 811static int pvr2_v4l2_open(struct inode *inode, struct file *file)
799{ 812{
800 struct pvr2_v4l2_dev *dip = NULL; /* Our own context pointer */ 813 struct pvr2_v4l2_dev *dip; /* Our own context pointer */
801 struct pvr2_v4l2_fh *fhp; 814 struct pvr2_v4l2_fh *fhp;
802 struct pvr2_v4l2 *vp; 815 struct pvr2_v4l2 *vp;
803 struct pvr2_hdw *hdw; 816 struct pvr2_hdw *hdw;
804 817
805 mutex_lock(&device_lock); 818 dip = container_of(video_devdata(file),struct pvr2_v4l2_dev,devbase);
806 /* MCI 7-Jun-2006 Even though we're just doing what amounts to an
807 atomic read of the device mapping array here, we still need the
808 mutex. The problem is that there is a tiny race possible when
809 we register the device. We can't update the device mapping
810 array until after the device has been registered, owing to the
811 fact that we can't know the minor device number until after the
812 registration succeeds. And if another thread tries to open the
813 device in the window of time after registration but before the
814 map is updated, then it will get back an erroneous null pointer
815 and the open will result in a spurious failure. The only way to
816 prevent that is to (a) be inside the mutex here before we access
817 the array, and (b) cover the entire registration process later
818 on with this same mutex. Thus if we get inside the mutex here,
819 then we can be assured that the registration process actually
820 completed correctly. This is an unhappy complication from the
821 use of global data in a driver that lives in a preemptible
822 environment. It sure would be nice if the video device itself
823 had a means for storing and retrieving a local context pointer.
824 Oh wait. It did. But now it's gone. Silly me. */
825 {
826 unsigned int midx = iminor(file->f_dentry->d_inode);
827 if (midx < sizeof(devices)/sizeof(devices[0])) {
828 dip = devices[midx];
829 }
830 }
831 mutex_unlock(&device_lock);
832
833 if (!dip) return -ENODEV; /* Should be impossible but I'm paranoid */
834 819
835 vp = dip->v4lp; 820 vp = dip->v4lp;
836 hdw = vp->channel.hdw; 821 hdw = vp->channel.hdw;
@@ -1060,38 +1045,24 @@ static void pvr2_v4l2_dev_init(struct pvr2_v4l2_dev *dip,
1060 return; 1045 return;
1061 } 1046 }
1062 1047
1063 dip->vdev = video_device_alloc(); 1048 memcpy(&dip->devbase,&vdev_template,sizeof(vdev_template));
1064 if (!dip->vdev) { 1049 dip->devbase.release = pvr2_video_device_release;
1065 err("Alloc of pvrusb2 v4l video device failed");
1066 return;
1067 }
1068
1069 memcpy(dip->vdev,&vdev_template,sizeof(vdev_template));
1070 dip->vdev->release = video_device_release;
1071 mutex_lock(&device_lock);
1072 1050
1073 mindevnum = -1; 1051 mindevnum = -1;
1074 unit_number = pvr2_hdw_get_unit_number(vp->channel.mc_head->hdw); 1052 unit_number = pvr2_hdw_get_unit_number(vp->channel.mc_head->hdw);
1075 if ((unit_number >= 0) && (unit_number < PVR_NUM)) { 1053 if ((unit_number >= 0) && (unit_number < PVR_NUM)) {
1076 mindevnum = video_nr[unit_number]; 1054 mindevnum = video_nr[unit_number];
1077 } 1055 }
1078 if ((video_register_device(dip->vdev, v4l_type, mindevnum) < 0) && 1056 if ((video_register_device(&dip->devbase, v4l_type, mindevnum) < 0) &&
1079 (video_register_device(dip->vdev, v4l_type, -1) < 0)) { 1057 (video_register_device(&dip->devbase, v4l_type, -1) < 0)) {
1080 err("Failed to register pvrusb2 v4l video device"); 1058 err("Failed to register pvrusb2 v4l video device");
1081 } else { 1059 } else {
1082 printk(KERN_INFO "pvrusb2: registered device video%d [%s]\n", 1060 printk(KERN_INFO "pvrusb2: registered device video%d [%s]\n",
1083 dip->vdev->minor,pvr2_config_get_name(dip->config)); 1061 dip->devbase.minor,pvr2_config_get_name(dip->config));
1084 }
1085
1086 if ((dip->vdev->minor < sizeof(devices)/sizeof(devices[0])) &&
1087 (devices[dip->vdev->minor] == NULL)) {
1088 dip->ctxt_idx = dip->vdev->minor;
1089 devices[dip->ctxt_idx] = dip;
1090 } 1062 }
1091 mutex_unlock(&device_lock);
1092 1063
1093 pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw, 1064 pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw,
1094 dip->vdev->minor); 1065 dip->devbase.minor);
1095} 1066}
1096 1067
1097 1068
@@ -1102,15 +1073,19 @@ struct pvr2_v4l2 *pvr2_v4l2_create(struct pvr2_context *mnp)
1102 vp = kmalloc(sizeof(*vp),GFP_KERNEL); 1073 vp = kmalloc(sizeof(*vp),GFP_KERNEL);
1103 if (!vp) return vp; 1074 if (!vp) return vp;
1104 memset(vp,0,sizeof(*vp)); 1075 memset(vp,0,sizeof(*vp));
1105 vp->video_dev.ctxt_idx = -1; 1076 vp->vdev = kmalloc(sizeof(*vp->vdev),GFP_KERNEL);
1077 if (!vp->vdev) {
1078 kfree(vp);
1079 return 0;
1080 }
1081 memset(vp->vdev,0,sizeof(*vp->vdev));
1106 pvr2_channel_init(&vp->channel,mnp); 1082 pvr2_channel_init(&vp->channel,mnp);
1107 pvr2_trace(PVR2_TRACE_STRUCT,"Creating pvr2_v4l2 id=%p",vp); 1083 pvr2_trace(PVR2_TRACE_STRUCT,"Creating pvr2_v4l2 id=%p",vp);
1108 1084
1109 vp->channel.check_func = pvr2_v4l2_internal_check; 1085 vp->channel.check_func = pvr2_v4l2_internal_check;
1110 1086
1111 /* register streams */ 1087 /* register streams */
1112 pvr2_v4l2_dev_init(&vp->video_dev,vp,pvr2_config_mpeg); 1088 pvr2_v4l2_dev_init(vp->vdev,vp,pvr2_config_mpeg);
1113
1114 1089
1115 return vp; 1090 return vp;
1116} 1091}
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c
index aa1db509f3d4..fe3c83ca3de3 100644
--- a/drivers/media/video/saa7134/saa7134-cards.c
+++ b/drivers/media/video/saa7134/saa7134-cards.c
@@ -2965,6 +2965,35 @@ struct saa7134_board saa7134_boards[] = {
2965 .amux = LINE1, 2965 .amux = LINE1,
2966 }, 2966 },
2967 }, 2967 },
2968 [SAA7134_BOARD_AVERMEDIA_A16AR] = {
2969 /* Petr Baudis <pasky@ucw.cz> */
2970 .name = "AVerMedia TV Hybrid A16AR",
2971 .audio_clock = 0x187de7,
2972 .tuner_type = TUNER_PHILIPS_TDA8290, /* untested */
2973 .radio_type = TUNER_TEA5767, /* untested */
2974 .tuner_addr = ADDR_UNSET,
2975 .radio_addr = ADDR_UNSET,
2976 .tda9887_conf = TDA9887_PRESENT,
2977 .mpeg = SAA7134_MPEG_DVB,
2978 .inputs = {{
2979 .name = name_tv,
2980 .vmux = 1,
2981 .amux = TV,
2982 .tv = 1,
2983 },{
2984 .name = name_comp1,
2985 .vmux = 3,
2986 .amux = LINE2,
2987 },{
2988 .name = name_svideo,
2989 .vmux = 8,
2990 .amux = LINE1,
2991 }},
2992 .radio = {
2993 .name = name_radio,
2994 .amux = LINE1,
2995 },
2996 },
2968}; 2997};
2969 2998
2970const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards); 2999const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards);
@@ -3562,6 +3591,12 @@ struct pci_device_id saa7134_pci_tbl[] = {
3562 .subdevice = 0x2003, 3591 .subdevice = 0x2003,
3563 .driver_data = SAA7134_BOARD_PROTEUS_2309, 3592 .driver_data = SAA7134_BOARD_PROTEUS_2309,
3564 },{ 3593 },{
3594 .vendor = PCI_VENDOR_ID_PHILIPS,
3595 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
3596 .subvendor = 0x1461,
3597 .subdevice = 0x2c00,
3598 .driver_data = SAA7134_BOARD_AVERMEDIA_A16AR,
3599 },{
3565 /* --- boards without eeprom + subsystem ID --- */ 3600 /* --- boards without eeprom + subsystem ID --- */
3566 .vendor = PCI_VENDOR_ID_PHILIPS, 3601 .vendor = PCI_VENDOR_ID_PHILIPS,
3567 .device = PCI_DEVICE_ID_PHILIPS_SAA7134, 3602 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
@@ -3703,6 +3738,7 @@ int saa7134_board_init1(struct saa7134_dev *dev)
3703 saa_writeb(SAA7134_GPIO_GPMODE3, 0x08); 3738 saa_writeb(SAA7134_GPIO_GPMODE3, 0x08);
3704 saa_writeb(SAA7134_GPIO_GPSTATUS3, 0x00); 3739 saa_writeb(SAA7134_GPIO_GPSTATUS3, 0x00);
3705 break; 3740 break;
3741 case SAA7134_BOARD_AVERMEDIA_A16AR:
3706 case SAA7134_BOARD_AVERMEDIA_CARDBUS: 3742 case SAA7134_BOARD_AVERMEDIA_CARDBUS:
3707 /* power-up tuner chip */ 3743 /* power-up tuner chip */
3708 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0xffffffff, 0xffffffff); 3744 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0xffffffff, 0xffffffff);
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c
index b6881541e704..fb741fa465a5 100644
--- a/drivers/media/video/saa7134/saa7134-dvb.c
+++ b/drivers/media/video/saa7134/saa7134-dvb.c
@@ -1055,6 +1055,7 @@ static int dvb_init(struct saa7134_dev *dev)
1055 } 1055 }
1056 break; 1056 break;
1057 case SAA7134_BOARD_AVERMEDIA_777: 1057 case SAA7134_BOARD_AVERMEDIA_777:
1058 case SAA7134_BOARD_AVERMEDIA_A16AR:
1058 printk("%s: avertv 777 dvb setup\n",dev->name); 1059 printk("%s: avertv 777 dvb setup\n",dev->name);
1059 dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777, 1060 dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
1060 &dev->i2c_adap); 1061 &dev->i2c_adap);
diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c
index f7ea857d5d73..ff5991136f4e 100644
--- a/drivers/media/video/saa7134/saa7134-input.c
+++ b/drivers/media/video/saa7134/saa7134-input.c
@@ -185,6 +185,7 @@ int saa7134_input_init1(struct saa7134_dev *dev)
185 case SAA7134_BOARD_AVERMEDIA_STUDIO_305: 185 case SAA7134_BOARD_AVERMEDIA_STUDIO_305:
186 case SAA7134_BOARD_AVERMEDIA_STUDIO_307: 186 case SAA7134_BOARD_AVERMEDIA_STUDIO_307:
187 case SAA7134_BOARD_AVERMEDIA_GO_007_FM: 187 case SAA7134_BOARD_AVERMEDIA_GO_007_FM:
188 case SAA7134_BOARD_AVERMEDIA_A16AR:
188 ir_codes = ir_codes_avermedia; 189 ir_codes = ir_codes_avermedia;
189 mask_keycode = 0x0007C8; 190 mask_keycode = 0x0007C8;
190 mask_keydown = 0x000010; 191 mask_keydown = 0x000010;
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h
index 7db7b9705953..701a90942108 100644
--- a/drivers/media/video/saa7134/saa7134.h
+++ b/drivers/media/video/saa7134/saa7134.h
@@ -226,6 +226,7 @@ struct saa7134_format {
226#define SAA7134_BOARD_MEDION_MD8800_QUADRO 96 226#define SAA7134_BOARD_MEDION_MD8800_QUADRO 96
227#define SAA7134_BOARD_FLYDVBS_LR300 97 227#define SAA7134_BOARD_FLYDVBS_LR300 97
228#define SAA7134_BOARD_PROTEUS_2309 98 228#define SAA7134_BOARD_PROTEUS_2309 98
229#define SAA7134_BOARD_AVERMEDIA_A16AR 99
229 230
230#define SAA7134_MAXBOARDS 8 231#define SAA7134_MAXBOARDS 8
231#define SAA7134_INPUT_MAX 8 232#define SAA7134_INPUT_MAX 8
diff --git a/drivers/media/video/video-buf.c b/drivers/media/video/video-buf.c
index acc5ea936687..f429f49901b9 100644
--- a/drivers/media/video/video-buf.c
+++ b/drivers/media/video/video-buf.c
@@ -365,7 +365,12 @@ videobuf_iolock(struct videobuf_queue* q, struct videobuf_buffer *vb,
365 if (NULL == fbuf) 365 if (NULL == fbuf)
366 return -EINVAL; 366 return -EINVAL;
367 /* FIXME: need sanity checks for vb->boff */ 367 /* FIXME: need sanity checks for vb->boff */
368 bus = (dma_addr_t)fbuf->base + vb->boff; 368 /*
369 * Using a double cast to avoid compiler warnings when
370 * building for PAE. Compiler doesn't like direct casting
371 * of a 32 bit ptr to 64 bit integer.
372 */
373 bus = (dma_addr_t)(unsigned long)fbuf->base + vb->boff;
369 pages = PAGE_ALIGN(vb->size) >> PAGE_SHIFT; 374 pages = PAGE_ALIGN(vb->size) >> PAGE_SHIFT;
370 err = videobuf_dma_init_overlay(&vb->dma,PCI_DMA_FROMDEVICE, 375 err = videobuf_dma_init_overlay(&vb->dma,PCI_DMA_FROMDEVICE,
371 bus, pages); 376 bus, pages);