aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/dvb/dvb-usb/Kconfig40
-rw-r--r--drivers/media/dvb/dvb-usb/Makefile4
-rw-r--r--drivers/media/dvb/dvb-usb/a800.c48
-rw-r--r--drivers/media/dvb/dvb-usb/cxusb.c241
-rw-r--r--drivers/media/dvb/dvb-usb/dibusb-common.c70
-rw-r--r--drivers/media/dvb/dvb-usb/dibusb-mb.c198
-rw-r--r--drivers/media/dvb/dvb-usb/dibusb-mc.c39
-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.c4
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-i2c.c49
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-init.c156
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-remote.c2
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-urb.c264
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb.h266
-rw-r--r--drivers/media/dvb/dvb-usb/gp8psk.c30
-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/vp702x.c49
-rw-r--r--drivers/media/dvb/dvb-usb/vp7045.c40
23 files changed, 1017 insertions, 1005 deletions
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig
index 0a3c35399be..135f287510c 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,28 @@ 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_TUNER_MT2060
74 help
75 Support for USB2.0/1.1 DVB receivers based on the DiB0700 USB bridge. The
76 USB bridge is also present in devices having the DiB7700 DVB-T-USB
77 silicon. This chip can be found in devices offered by Hauppauge,
78 Avermedia and other big and small companies.
79
80 For an up-to-date list of devices supported by this driver, have a look
81 on the Linux-DVB Wiki at www.linuxtv.org.
78 82
79 Say Y if you own such a device and want to use it. You should build it as 83 Say Y if you own such a device and want to use it. You should build it as
80 a module. 84 a module.
diff --git a/drivers/media/dvb/dvb-usb/Makefile b/drivers/media/dvb/dvb-usb/Makefile
index 9643f56c7fe..275cbc2925c 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,6 @@ 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
40
39EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/ 41EXTRA_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 df0c384bd4c..2ed3eb62d78 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 c710c0176e0..5ebfa3f0854 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)
@@ -516,24 +517,22 @@ static struct usb_device_id cxusb_table [] = {
516}; 517};
517MODULE_DEVICE_TABLE (usb, cxusb_table); 518MODULE_DEVICE_TABLE (usb, cxusb_table);
518 519
519static struct dvb_usb_properties cxusb_medion_properties = { 520static struct dvb_usb_device_properties cxusb_medion_properties = {
520 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 521 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
521 522
522 .usb_ctrl = CYPRESS_FX2, 523 .usb_ctrl = CYPRESS_FX2,
523 524
524 .size_of_priv = sizeof(struct cxusb_state), 525 .size_of_priv = sizeof(struct cxusb_state),
525 526
527 .num_adapters = 1,
528 .adapter = {
529 {
526 .streaming_ctrl = cxusb_streaming_ctrl, 530 .streaming_ctrl = cxusb_streaming_ctrl,
527 .power_ctrl = cxusb_power_ctrl,
528 .frontend_attach = cxusb_cx22702_frontend_attach, 531 .frontend_attach = cxusb_cx22702_frontend_attach,
529 .tuner_attach = cxusb_fmd1216me_tuner_attach, 532 .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 */ 533 /* parameter for the MPEG2-data transfer */
535 .urb = { 534 .stream = {
536 .type = DVB_USB_BULK, 535 .type = USB_BULK,
537 .count = 5, 536 .count = 5,
538 .endpoint = 0x02, 537 .endpoint = 0x02,
539 .u = { 538 .u = {
@@ -543,6 +542,14 @@ static struct dvb_usb_properties cxusb_medion_properties = {
543 } 542 }
544 }, 543 },
545 544
545 },
546 },
547 .power_ctrl = cxusb_power_ctrl,
548
549 .i2c_algo = &cxusb_i2c_algo,
550
551 .generic_bulk_ctrl_endpoint = 0x01,
552
546 .num_device_descs = 1, 553 .num_device_descs = 1,
547 .devices = { 554 .devices = {
548 { "Medion MD95700 (MDUSBTV-HYBRID)", 555 { "Medion MD95700 (MDUSBTV-HYBRID)",
@@ -552,7 +559,7 @@ static struct dvb_usb_properties cxusb_medion_properties = {
552 } 559 }
553}; 560};
554 561
555static struct dvb_usb_properties cxusb_bluebird_lgh064f_properties = { 562static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties = {
556 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 563 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
557 564
558 .usb_ctrl = DEVICE_SPECIFIC, 565 .usb_ctrl = DEVICE_SPECIFIC,
@@ -563,22 +570,16 @@ static struct dvb_usb_properties cxusb_bluebird_lgh064f_properties = {
563 570
564 .size_of_priv = sizeof(struct cxusb_state), 571 .size_of_priv = sizeof(struct cxusb_state),
565 572
573 .num_adapters = 1,
574 .adapter = {
575 {
566 .streaming_ctrl = cxusb_streaming_ctrl, 576 .streaming_ctrl = cxusb_streaming_ctrl,
567 .power_ctrl = cxusb_bluebird_power_ctrl,
568 .frontend_attach = cxusb_lgdt3303_frontend_attach, 577 .frontend_attach = cxusb_lgdt3303_frontend_attach,
569 .tuner_attach = cxusb_lgdt3303_tuner_attach, 578 .tuner_attach = cxusb_lgdt3303_tuner_attach,
570 579
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 */ 580 /* parameter for the MPEG2-data transfer */
580 .urb = { 581 .stream = {
581 .type = DVB_USB_BULK, 582 .type = USB_BULK,
582 .count = 5, 583 .count = 5,
583 .endpoint = 0x02, 584 .endpoint = 0x02,
584 .u = { 585 .u = {
@@ -587,6 +588,19 @@ static struct dvb_usb_properties cxusb_bluebird_lgh064f_properties = {
587 } 588 }
588 } 589 }
589 }, 590 },
591 },
592 },
593
594 .power_ctrl = cxusb_bluebird_power_ctrl,
595
596 .i2c_algo = &cxusb_i2c_algo,
597
598 .rc_interval = 100,
599 .rc_key_map = dvico_portable_rc_keys,
600 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
601 .rc_query = cxusb_rc_query,
602
603 .generic_bulk_ctrl_endpoint = 0x01,
590 604
591 .num_device_descs = 1, 605 .num_device_descs = 1,
592 .devices = { 606 .devices = {
@@ -597,7 +611,7 @@ static struct dvb_usb_properties cxusb_bluebird_lgh064f_properties = {
597 } 611 }
598}; 612};
599 613
600static struct dvb_usb_properties cxusb_bluebird_dee1601_properties = { 614static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties = {
601 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 615 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
602 616
603 .usb_ctrl = DEVICE_SPECIFIC, 617 .usb_ctrl = DEVICE_SPECIFIC,
@@ -608,22 +622,15 @@ static struct dvb_usb_properties cxusb_bluebird_dee1601_properties = {
608 622
609 .size_of_priv = sizeof(struct cxusb_state), 623 .size_of_priv = sizeof(struct cxusb_state),
610 624
625 .num_adapters = 1,
626 .adapter = {
627 {
611 .streaming_ctrl = cxusb_streaming_ctrl, 628 .streaming_ctrl = cxusb_streaming_ctrl,
612 .power_ctrl = cxusb_bluebird_power_ctrl,
613 .frontend_attach = cxusb_dee1601_frontend_attach, 629 .frontend_attach = cxusb_dee1601_frontend_attach,
614 .tuner_attach = cxusb_dee1601_tuner_attach, 630 .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 */ 631 /* parameter for the MPEG2-data transfer */
625 .urb = { 632 .stream = {
626 .type = DVB_USB_BULK, 633 .type = USB_BULK,
627 .count = 5, 634 .count = 5,
628 .endpoint = 0x04, 635 .endpoint = 0x04,
629 .u = { 636 .u = {
@@ -632,6 +639,19 @@ static struct dvb_usb_properties cxusb_bluebird_dee1601_properties = {
632 } 639 }
633 } 640 }
634 }, 641 },
642 },
643 },
644
645 .power_ctrl = cxusb_bluebird_power_ctrl,
646
647 .i2c_algo = &cxusb_i2c_algo,
648
649 .rc_interval = 150,
650 .rc_key_map = dvico_mce_rc_keys,
651 .rc_key_map_size = ARRAY_SIZE(dvico_mce_rc_keys),
652 .rc_query = cxusb_rc_query,
653
654 .generic_bulk_ctrl_endpoint = 0x01,
635 655
636 .num_device_descs = 2, 656 .num_device_descs = 2,
637 .devices = { 657 .devices = {
@@ -646,7 +666,7 @@ static struct dvb_usb_properties cxusb_bluebird_dee1601_properties = {
646 } 666 }
647}; 667};
648 668
649static struct dvb_usb_properties cxusb_bluebird_lgz201_properties = { 669static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties = {
650 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 670 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
651 671
652 .usb_ctrl = DEVICE_SPECIFIC, 672 .usb_ctrl = DEVICE_SPECIFIC,
@@ -657,22 +677,16 @@ static struct dvb_usb_properties cxusb_bluebird_lgz201_properties = {
657 677
658 .size_of_priv = sizeof(struct cxusb_state), 678 .size_of_priv = sizeof(struct cxusb_state),
659 679
680 .num_adapters = 2,
681 .adapter = {
682 {
660 .streaming_ctrl = cxusb_streaming_ctrl, 683 .streaming_ctrl = cxusb_streaming_ctrl,
661 .power_ctrl = cxusb_bluebird_power_ctrl,
662 .frontend_attach = cxusb_mt352_frontend_attach, 684 .frontend_attach = cxusb_mt352_frontend_attach,
663 .tuner_attach = cxusb_lgz201_tuner_attach, 685 .tuner_attach = cxusb_lgz201_tuner_attach,
664 686
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 */ 687 /* parameter for the MPEG2-data transfer */
674 .urb = { 688 .stream = {
675 .type = DVB_USB_BULK, 689 .type = USB_BULK,
676 .count = 5, 690 .count = 5,
677 .endpoint = 0x04, 691 .endpoint = 0x04,
678 .u = { 692 .u = {
@@ -681,7 +695,18 @@ static struct dvb_usb_properties cxusb_bluebird_lgz201_properties = {
681 } 695 }
682 } 696 }
683 }, 697 },
698 },
699 },
700 .power_ctrl = cxusb_bluebird_power_ctrl,
701
702 .i2c_algo = &cxusb_i2c_algo,
684 703
704 .rc_interval = 100,
705 .rc_key_map = dvico_portable_rc_keys,
706 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
707 .rc_query = cxusb_rc_query,
708
709 .generic_bulk_ctrl_endpoint = 0x01,
685 .num_device_descs = 1, 710 .num_device_descs = 1,
686 .devices = { 711 .devices = {
687 { "DViCO FusionHDTV DVB-T USB (LGZ201)", 712 { "DViCO FusionHDTV DVB-T USB (LGZ201)",
@@ -691,7 +716,7 @@ static struct dvb_usb_properties cxusb_bluebird_lgz201_properties = {
691 } 716 }
692}; 717};
693 718
694static struct dvb_usb_properties cxusb_bluebird_dtt7579_properties = { 719static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties = {
695 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 720 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
696 721
697 .usb_ctrl = DEVICE_SPECIFIC, 722 .usb_ctrl = DEVICE_SPECIFIC,
@@ -702,22 +727,16 @@ static struct dvb_usb_properties cxusb_bluebird_dtt7579_properties = {
702 727
703 .size_of_priv = sizeof(struct cxusb_state), 728 .size_of_priv = sizeof(struct cxusb_state),
704 729
730 .num_adapters = 1,
731 .adapter = {
732 {
705 .streaming_ctrl = cxusb_streaming_ctrl, 733 .streaming_ctrl = cxusb_streaming_ctrl,
706 .power_ctrl = cxusb_bluebird_power_ctrl,
707 .frontend_attach = cxusb_mt352_frontend_attach, 734 .frontend_attach = cxusb_mt352_frontend_attach,
708 .tuner_attach = cxusb_dtt7579_tuner_attach, 735 .tuner_attach = cxusb_dtt7579_tuner_attach,
709 736
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 */ 737 /* parameter for the MPEG2-data transfer */
719 .urb = { 738 .stream = {
720 .type = DVB_USB_BULK, 739 .type = USB_BULK,
721 .count = 5, 740 .count = 5,
722 .endpoint = 0x04, 741 .endpoint = 0x04,
723 .u = { 742 .u = {
@@ -726,6 +745,18 @@ static struct dvb_usb_properties cxusb_bluebird_dtt7579_properties = {
726 } 745 }
727 } 746 }
728 }, 747 },
748 },
749 },
750 .power_ctrl = cxusb_bluebird_power_ctrl,
751
752 .i2c_algo = &cxusb_i2c_algo,
753
754 .rc_interval = 100,
755 .rc_key_map = dvico_portable_rc_keys,
756 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
757 .rc_query = cxusb_rc_query,
758
759 .generic_bulk_ctrl_endpoint = 0x01,
729 760
730 .num_device_descs = 1, 761 .num_device_descs = 1,
731 .devices = { 762 .devices = {
diff --git a/drivers/media/dvb/dvb-usb/dibusb-common.c b/drivers/media/dvb/dvb-usb/dibusb-common.c
index 124e25ac53b..5f8afec96a3 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 (dib3000mc_attach(&adap->dev->i2c_adap, 1, DEFAULT_DIB3000P_I2C_ADDRESS, 0, &mod3000p_dib3000p_config, &adap->fe) == 0 ||
234 dib3000mc_attach(&d->i2c_adap, 1, DEFAULT_DIB3000MC_I2C_ADDRESS, 0, &mod3000p_dib3000p_config, &d->fe) == 0) { 234 dib3000mc_attach(&adap->dev->i2c_adap, 1, DEFAULT_DIB3000MC_I2C_ADDRESS, 0, &mod3000p_dib3000p_config, &adap->fe) == 0) {
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,20 @@ 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; 253 int ret;
254 u8 a,b; 254 u8 a,b;
255 u16 if1 = 1220; 255 u16 if1 = 1220;
256 struct i2c_adapter *tun_i2c; 256 struct i2c_adapter *tun_i2c;
257 257
258 // First IF calibration for Liteon Sticks 258 // First IF calibration for Liteon Sticks
259 if (d->udev->descriptor.idVendor == USB_VID_LITEON && 259 if (adap->dev->udev->descriptor.idVendor == USB_VID_LITEON &&
260 d->udev->descriptor.idProduct == USB_PID_LITEON_DVB_T_WARM) { 260 adap->dev->udev->descriptor.idProduct == USB_PID_LITEON_DVB_T_WARM) {
261 261
262 dibusb_read_eeprom_byte(d,0x7E,&a); 262 dibusb_read_eeprom_byte(adap->dev,0x7E,&a);
263 dibusb_read_eeprom_byte(d,0x7F,&b); 263 dibusb_read_eeprom_byte(adap->dev,0x7F,&b);
264 264
265 if (a == 0x00) 265 if (a == 0x00)
266 if1 += b; 266 if1 += b;
@@ -269,14 +269,14 @@ int dibusb_dib3000mc_tuner_attach (struct dvb_usb_device *d)
269 else 269 else
270 warn("LITE-ON DVB-T: Strange IF1 calibration :%2X %2X\n", a, b); 270 warn("LITE-ON DVB-T: Strange IF1 calibration :%2X %2X\n", a, b);
271 271
272 } else if (d->udev->descriptor.idVendor == USB_VID_DIBCOM && 272 } else if (adap->dev->udev->descriptor.idVendor == USB_VID_DIBCOM &&
273 d->udev->descriptor.idProduct == USB_PID_DIBCOM_MOD3001_WARM) { 273 adap->dev->udev->descriptor.idProduct == USB_PID_DIBCOM_MOD3001_WARM) {
274 u8 desc; 274 u8 desc;
275 dibusb_read_eeprom_byte(d, 7, &desc); 275 dibusb_read_eeprom_byte(adap->dev, 7, &desc);
276 if (desc == 2) { 276 if (desc == 2) {
277 a = 127; 277 a = 127;
278 do { 278 do {
279 dibusb_read_eeprom_byte(d, a, &desc); 279 dibusb_read_eeprom_byte(adap->dev, a, &desc);
280 a--; 280 a--;
281 } while (a > 7 && (desc == 0xff || desc == 0x00)); 281 } while (a > 7 && (desc == 0xff || desc == 0x00));
282 if (desc & 0x80) 282 if (desc & 0x80)
@@ -286,15 +286,15 @@ int dibusb_dib3000mc_tuner_attach (struct dvb_usb_device *d)
286 } 286 }
287 } 287 }
288 288
289 tun_i2c = dib3000mc_get_tuner_i2c_master(d->fe, 1); 289 tun_i2c = dib3000mc_get_tuner_i2c_master(adap->fe, 1);
290 if ((ret = mt2060_attach(d->fe, tun_i2c, &stk3000p_mt2060_config, if1)) != 0) { 290 if ((ret = mt2060_attach(adap->fe, tun_i2c, &stk3000p_mt2060_config, if1)) != 0) {
291 /* not found - use panasonic pll parameters */ 291 /* not found - use panasonic pll parameters */
292 if (dvb_pll_attach(d->fe, 0x60, tun_i2c, &dvb_pll_env57h1xd5) == NULL) 292 if (dvb_pll_attach(adap->fe, 0x60, tun_i2c, &dvb_pll_env57h1xd5) == NULL)
293 return -ENOMEM; 293 return -ENOMEM;
294 } else { 294 } else {
295 st->mt2060_present = 1; 295 st->mt2060_present = 1;
296 /* set the correct parameters for the dib3000p */ 296 /* set the correct parameters for the dib3000p */
297 dib3000mc_set_config(d->fe, &stk3000p_dib3000p_config); 297 dib3000mc_set_config(adap->fe, &stk3000p_dib3000p_config);
298 } 298 }
299 return 0; 299 return 0;
300} 300}
diff --git a/drivers/media/dvb/dvb-usb/dibusb-mb.c b/drivers/media/dvb/dvb-usb/dibusb-mb.c
index effd34cc4b0..4fe363e4835 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 eca4082a61a..d823e7d5b26 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,27 @@ 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),
54 52
53 .num_adapters = 1,
54 .adapter = {
55 {
56 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
57 .pid_filter_count = 32,
55 .streaming_ctrl = dibusb2_0_streaming_ctrl, 58 .streaming_ctrl = dibusb2_0_streaming_ctrl,
56 .pid_filter = dibusb_pid_filter, 59 .pid_filter = dibusb_pid_filter,
57 .pid_filter_ctrl = dibusb_pid_filter_ctrl, 60 .pid_filter_ctrl = dibusb_pid_filter_ctrl,
58 .power_ctrl = dibusb2_0_power_ctrl,
59 .frontend_attach = dibusb_dib3000mc_frontend_attach, 61 .frontend_attach = dibusb_dib3000mc_frontend_attach,
60 .tuner_attach = dibusb_dib3000mc_tuner_attach, 62 .tuner_attach = dibusb_dib3000mc_tuner_attach,
61 63
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 */ 64 /* parameter for the MPEG2-data transfer */
71 .urb = { 65 .stream = {
72 .type = DVB_USB_BULK, 66 .type = USB_BULK,
73 .count = 7, 67 .count = 7,
74 .endpoint = 0x06, 68 .endpoint = 0x06,
75 .u = { 69 .u = {
@@ -78,6 +72,19 @@ static struct dvb_usb_properties dibusb_mc_properties = {
78 } 72 }
79 } 73 }
80 }, 74 },
75 .size_of_priv = sizeof(struct dibusb_state),
76 }
77 },
78 .power_ctrl = dibusb2_0_power_ctrl,
79
80 .rc_interval = DEFAULT_RC_INTERVAL,
81 .rc_key_map = dibusb_rc_keys,
82 .rc_key_map_size = 111, /* FIXME */
83 .rc_query = dibusb_rc_query,
84
85 .i2c_algo = &dibusb_i2c_algo,
86
87 .generic_bulk_ctrl_endpoint = 0x01,
81 88
82 .num_device_descs = 7, 89 .num_device_descs = 7,
83 .devices = { 90 .devices = {
diff --git a/drivers/media/dvb/dvb-usb/dibusb.h b/drivers/media/dvb/dvb-usb/dibusb.h
index a43f87480cf..5153fb943da 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 01585448730..8fb34375c1f 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 27af4e43647..b834db74e77 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);
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 a3460bf2d9f..35ab68f6dcf 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 fe6208ada90..4561a672da9 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 9222b0a81f7..122ff8157d1 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.
@@ -78,7 +78,7 @@ int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw
78} 78}
79EXPORT_SYMBOL(usb_cypress_load_firmware); 79EXPORT_SYMBOL(usb_cypress_load_firmware);
80 80
81int dvb_usb_download_firmware(struct usb_device *udev, struct dvb_usb_properties *props) 81int dvb_usb_download_firmware(struct usb_device *udev, struct dvb_usb_device_properties *props)
82{ 82{
83 int ret; 83 int ret;
84 const struct firmware *fw = NULL; 84 const struct firmware *fw = NULL;
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c b/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c
index 6b611a72509..55ba020386c 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-init.c b/drivers/media/dvb/dvb-usb/dvb-usb-init.c
index a1705ecb9a5..6babdcd4c1a 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;
56 } 139 }
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,20 @@ 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 (d->powered == !onoff) {
201 d->powered = onoff;
202 if (d->props.power_ctrl)
203 return d->props.power_ctrl(d, onoff);
204 }
205 return 0;
206}
207
128/* 208/*
129 * USB 209 * USB
130 */ 210 */
131 211int 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) 212 *props, struct module *owner,struct dvb_usb_device **du)
134{ 213{
135 struct usb_device *udev = interface_to_usbdev(intf); 214 struct usb_device *udev = interface_to_usbdev(intf);
@@ -161,19 +240,10 @@ int dvb_usb_device_init(struct usb_interface *intf, struct dvb_usb_properties
161 } 240 }
162 241
163 d->udev = udev; 242 d->udev = udev;
164 memcpy(&d->props,props,sizeof(struct dvb_usb_properties)); 243 memcpy(&d->props,props,sizeof(struct dvb_usb_device_properties));
165 d->desc = desc; 244 d->desc = desc;
166 d->owner = owner; 245 d->owner = owner;
167 246
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); 247 usb_set_intfdata(intf, d);
178 248
179 if (du != NULL) 249 if (du != NULL)
@@ -204,7 +274,7 @@ void dvb_usb_device_exit(struct usb_interface *intf)
204} 274}
205EXPORT_SYMBOL(dvb_usb_device_exit); 275EXPORT_SYMBOL(dvb_usb_device_exit);
206 276
207MODULE_VERSION("0.3"); 277MODULE_VERSION("1.0");
208MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>"); 278MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
209MODULE_DESCRIPTION("A library module containing commonly used USB and DVB function USB DVB devices"); 279MODULE_DESCRIPTION("A library module containing commonly used USB and DVB function USB DVB devices");
210MODULE_LICENSE("GPL"); 280MODULE_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 380b2a45ee4..0a3a0b6c235 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 88b283731bb..0aed7fd6062 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,22 @@ 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) 74int dvb_usb_adapter_stream_init(struct dvb_usb_adapter *adap)
232{ 75{
233 int i,j; 76 adap->stream.udev = adap->dev->udev;
234 77 adap->stream.complete = dvb_usb_data_complete;
235 if ((i = dvb_usb_allocate_stream_buffers(d,d->props.urb.count, 78 adap->stream.user_priv = adap;
236 d->props.urb.u.isoc.framesize*d->props.urb.u.isoc.framesperurb)) < 0) 79 return usb_urb_init(&adap->stream, &adap->props.stream);
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}
271
272int dvb_usb_urb_init(struct dvb_usb_device *d)
273{
274 /*
275 * when reloading the driver w/o replugging the device
276 * sometimes a timeout occures, this helps
277 */
278 if (d->props.generic_bulk_ctrl_endpoint != 0) {
279 usb_clear_halt(d->udev,usb_sndbulkpipe(d->udev,d->props.generic_bulk_ctrl_endpoint));
280 usb_clear_halt(d->udev,usb_rcvbulkpipe(d->udev,d->props.generic_bulk_ctrl_endpoint));
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} 80}
300 81
301int dvb_usb_urb_exit(struct dvb_usb_device *d) 82int dvb_usb_adapter_stream_exit(struct dvb_usb_adapter *adap)
302{ 83{
303 int i; 84 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} 85}
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb.h b/drivers/media/dvb/dvb-usb/dvb-usb.h
index 97f8ea96243..5546554d387 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,83 @@ 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;
87 91
88/** 92/**
89 * struct dvb_usb_properties - properties of a dvb-usb-device 93 * Properties of USB streaming - TODO this structure does not belong here actually
94 * describes the kind of USB transfer used for MPEG2-TS-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};
115
116/**
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 int caps;
137 int pid_filter_count;
138
139 int (*streaming_ctrl) (struct dvb_usb_adapter *, int);
140 int (*pid_filter_ctrl) (struct dvb_usb_adapter *, int);
141 int (*pid_filter) (struct dvb_usb_adapter *, int, u16, int);
142
143 int (*frontend_attach) (struct dvb_usb_adapter *);
144 int (*tuner_attach) (struct dvb_usb_adapter *);
145
146 struct usb_data_stream_properties stream;
147
148 int size_of_priv;
149};
150
151/**
152 * 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 153 * @usb_ctrl: which USB device-side controller is in use. Needed for firmware
95 * download. 154 * download.
96 * @firmware: name of the firmware file. 155 * @firmware: name of the firmware file.
97 * @download_firmware: called to download the firmware when the usb_ctrl is 156 * @download_firmware: called to download the firmware when the usb_ctrl is
98 * DEVICE_SPECIFIC. 157 * DEVICE_SPECIFIC.
99 * @no_reconnect: device doesn't do a reconnect after downloading the firmware, 158 * @no_reconnect: device doesn't do a reconnect after downloading the firmware,
100 so do the warm initialization right after it 159 * so do the warm initialization right after it
101 160 *
102 * @size_of_priv: how many bytes shall be allocated for the private field 161 * @size_of_priv: how many bytes shall be allocated for the private field
103 * of struct dvb_usb_device. 162 * of struct dvb_usb_device.
104 * 163 *
105 * @power_ctrl: called to enable/disable power of the device. 164 * @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. 165 * @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 166 * @identify_state: called to determine the state (cold or warm), when it
118 * is not distinguishable by the USB IDs. 167 * is not distinguishable by the USB IDs.
119 * 168 *
@@ -130,21 +179,15 @@ struct dvb_usb_device;
130 * is non-zero, one can use dvb_usb_generic_rw and dvb_usb_generic_write- 179 * is non-zero, one can use dvb_usb_generic_rw and dvb_usb_generic_write-
131 * helper functions. 180 * helper functions.
132 * 181 *
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 182 * @num_device_descs: number of struct dvb_usb_device_description in @devices
137 * @devices: array of struct dvb_usb_device_description compatibles with these 183 * @devices: array of struct dvb_usb_device_description compatibles with these
138 * properties. 184 * properties.
139 */ 185 */
140struct dvb_usb_properties { 186#define MAX_NO_OF_ADAPTER_PER_DEVICE 2
187struct dvb_usb_device_properties {
141 188
142#define DVB_USB_HAS_PID_FILTER 0x01 189#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; 190 int caps;
147 int pid_filter_count;
148 191
149#define DEVICE_SPECIFIC 0 192#define DEVICE_SPECIFIC 0
150#define CYPRESS_AN2135 1 193#define CYPRESS_AN2135 1
@@ -157,16 +200,12 @@ struct dvb_usb_properties {
157 200
158 int size_of_priv; 201 int size_of_priv;
159 202
160 int (*power_ctrl) (struct dvb_usb_device *, int); 203 int num_adapters;
161 int (*streaming_ctrl) (struct dvb_usb_device *, int); 204 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 205
206 int (*power_ctrl) (struct dvb_usb_device *, int);
165 int (*read_mac_address) (struct dvb_usb_device *, u8 []); 207 int (*read_mac_address) (struct dvb_usb_device *, u8 []);
166 int (*frontend_attach) (struct dvb_usb_device *); 208 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 *); 209 struct dvb_usb_device_description **, int *);
171 210
172/* remote control properties */ 211/* remote control properties */
@@ -182,40 +221,12 @@ struct dvb_usb_properties {
182 221
183 int generic_bulk_ctrl_endpoint; 222 int generic_bulk_ctrl_endpoint;
184 223
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; 224 int num_device_descs;
205 struct dvb_usb_device_description devices[9]; 225 struct dvb_usb_device_description devices[9];
206}; 226};
207 227
208
209/** 228/**
210 * struct dvb_usb_device - object of a DVB USB device 229 * 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. 230 * @buf_num: number of buffer allocated.
220 * @buf_size: size of each buffer in buf_list. 231 * @buf_size: size of each buffer in buf_list.
221 * @buf_list: array containing all allocate buffers for streaming. 232 * @buf_list: array containing all allocate buffers for streaming.
@@ -224,19 +235,44 @@ struct dvb_usb_properties {
224 * @urbs_initialized: number of URBs initialized. 235 * @urbs_initialized: number of URBs initialized.
225 * @urbs_submitted: number of URBs submitted. 236 * @urbs_submitted: number of URBs submitted.
226 * 237 *
238 * TODO put this in the correct place.
239 */
240#define MAX_NO_URBS_FOR_DATA_STREAM 10
241struct usb_data_stream {
242 struct usb_device *udev;
243 struct usb_data_stream_properties props;
244
245#define USB_STATE_INIT 0x00
246#define USB_STATE_URB_BUF 0x01
247 int state;
248
249 void (*complete) (struct usb_data_stream *, u8 *, size_t);
250
251 struct urb *urb_list[MAX_NO_URBS_FOR_DATA_STREAM];
252
253 int buf_num;
254 unsigned long buf_size;
255 u8 *buf_list[MAX_NO_URBS_FOR_DATA_STREAM];
256 dma_addr_t dma_addr[MAX_NO_URBS_FOR_DATA_STREAM];
257
258 int urbs_initialized;
259 int urbs_submitted;
260
261 void *user_priv;
262};
263
264/**
265 * struct dvb_usb_adapter - a DVB adapter on a USB device
266 * @id: index of this adapter (starting with 0).
267 *
227 * @feedcount: number of reqested feeds (used for streaming-activation) 268 * @feedcount: number of reqested feeds (used for streaming-activation)
228 * @pid_filtering: is hardware pid_filtering used or not. 269 * @pid_filtering: is hardware pid_filtering used or not.
229 * 270 *
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 271 * @pll_addr: I2C address of the tuner for programming
235 * @pll_init: array containing the initialization buffer 272 * @pll_init: array containing the initialization buffer
236 * @pll_desc: pointer to the appropriate struct dvb_pll_desc 273 * @pll_desc: pointer to the appropriate struct dvb_pll_desc
237 * 274 *
238 * @tuner_pass_ctrl: called to (de)activate tuner passthru of the demod or the board 275 * @tuner_pass_ctrl: called to (de)activate tuner passthru of the demod or the board
239 *
240 * @dvb_adap: device's dvb_adapter. 276 * @dvb_adap: device's dvb_adapter.
241 * @dmxdev: device's dmxdev. 277 * @dmxdev: device's dmxdev.
242 * @demux: device's software demuxer. 278 * @demux: device's software demuxer.
@@ -246,6 +282,56 @@ struct dvb_usb_properties {
246 * device 282 * device
247 * @fe_sleep: rerouted frontend-sleep function. 283 * @fe_sleep: rerouted frontend-sleep function.
248 * @fe_init: rerouted frontend-init (wakeup) function. 284 * @fe_init: rerouted frontend-init (wakeup) function.
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 int 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_sleep) (struct dvb_frontend *);
315 int (*fe_init) (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 * @udev: pointer to the device's struct usb_device.
329 *
330 * @usb_mutex: semaphore of USB control messages (reading needs two messages)
331 * @i2c_mutex: semaphore for i2c-transfers
332 *
333 * @i2c_adap: device's i2c_adapter if it uses I2CoverUSB
334 *
249 * @rc_input_dev: input device for the remote control. 335 * @rc_input_dev: input device for the remote control.
250 * @rc_query_work: struct work_struct frequent rc queries 336 * @rc_query_work: struct work_struct frequent rc queries
251 * @last_event: last triggered event 337 * @last_event: last triggered event
@@ -255,32 +341,18 @@ struct dvb_usb_properties {
255 * in size_of_priv of dvb_usb_properties). 341 * in size_of_priv of dvb_usb_properties).
256 */ 342 */
257struct dvb_usb_device { 343struct dvb_usb_device {
258 struct dvb_usb_properties props; 344 struct dvb_usb_device_properties props;
259 struct dvb_usb_device_description *desc; 345 struct dvb_usb_device_description *desc;
260 346
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; 347 struct usb_device *udev;
272 struct urb **urb_list;
273
274 int buf_num;
275 unsigned long buf_size;
276 u8 **buf_list;
277 dma_addr_t *dma_addr;
278 348
279 int urbs_initialized; 349#define DVB_USB_STATE_INIT 0x000
280 int urbs_submitted; 350#define DVB_USB_STATE_I2C 0x001
351#define DVB_USB_STATE_DVB 0x002
352#define DVB_USB_STATE_REMOTE 0x004
353 int state;
281 354
282 int feedcount; 355 int powered;
283 int pid_filtering;
284 356
285 /* locking */ 357 /* locking */
286 struct mutex usb_mutex; 358 struct mutex usb_mutex;
@@ -289,22 +361,8 @@ struct dvb_usb_device {
289 struct mutex i2c_mutex; 361 struct mutex i2c_mutex;
290 struct i2c_adapter i2c_adap; 362 struct i2c_adapter i2c_adap;
291 363
292 /* tuner programming information */ 364 int num_adapters_initialized;
293 u8 pll_addr; 365 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 366
309 /* remote control */ 367 /* remote control */
310 struct input_dev *rc_input_dev; 368 struct input_dev *rc_input_dev;
@@ -318,7 +376,7 @@ struct dvb_usb_device {
318 void *priv; 376 void *priv;
319}; 377};
320 378
321extern int dvb_usb_device_init(struct usb_interface *, struct dvb_usb_properties *, struct module *, struct dvb_usb_device **); 379extern 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 *); 380extern void dvb_usb_device_exit(struct usb_interface *);
323 381
324/* the generic read/write method for device control */ 382/* the generic read/write method for device control */
diff --git a/drivers/media/dvb/dvb-usb/gp8psk.c b/drivers/media/dvb/dvb-usb/gp8psk.c
index 9a98f3fdae3..334269bd065 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 = {
diff --git a/drivers/media/dvb/dvb-usb/nova-t-usb2.c b/drivers/media/dvb/dvb-usb/nova-t-usb2.c
index 79f0a02ce98..a9219bf69b8 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 418a0b70715..f9941ea88b3 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/vp702x.c b/drivers/media/dvb/dvb-usb/vp702x.c
index b2f098a2d5f..fdab2562bf5 100644
--- a/drivers/media/dvb/dvb-usb/vp702x.c
+++ b/drivers/media/dvb/dvb-usb/vp702x.c
@@ -108,9 +108,9 @@ static int vp702x_usb_inout_cmd(struct dvb_usb_device *d, u8 cmd, u8 *o,
108 return ret; 108 return ret;
109} 109}
110 110
111static int vp702x_pid_filter(struct dvb_usb_device *d, int index, u16 pid, int onoff) 111static int vp702x_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid, int onoff)
112{ 112{
113 struct vp702x_state *st = d->priv; 113 struct vp702x_state *st = adap->priv;
114 u8 buf[9]; 114 u8 buf[9];
115 115
116 if (onoff) { 116 if (onoff) {
@@ -122,7 +122,7 @@ static int vp702x_pid_filter(struct dvb_usb_device *d, int index, u16 pid, int o
122 st->pid_table[index*2] = st->pid_table[index*2+1] = 0; 122 st->pid_table[index*2] = st->pid_table[index*2+1] = 0;
123 } 123 }
124 124
125 return vp702x_usb_inout_cmd(d,SET_PID_FILTER,st->pid_table,17,buf,9,10); 125 return vp702x_usb_inout_cmd(adap->dev,SET_PID_FILTER,st->pid_table,17,buf,9,10);
126} 126}
127 127
128static int vp702x_power_ctrl(struct dvb_usb_device *d, int onoff) 128static int vp702x_power_ctrl(struct dvb_usb_device *d, int onoff)
@@ -175,21 +175,21 @@ static int vp702x_read_mac_addr(struct dvb_usb_device *d,u8 mac[6])
175 return 0; 175 return 0;
176} 176}
177 177
178static int vp702x_frontend_attach(struct dvb_usb_device *d) 178static int vp702x_frontend_attach(struct dvb_usb_adapter *adap)
179{ 179{
180 u8 buf[9] = { 0 }; 180 u8 buf[9] = { 0 };
181 181
182 if (vp702x_usb_inout_cmd(d, GET_SYSTEM_STRING, NULL, 0, buf, 9, 10)) 182 if (vp702x_usb_inout_cmd(adap->dev, GET_SYSTEM_STRING, NULL, 0, buf, 9, 10))
183 return -EIO; 183 return -EIO;
184 184
185 buf[8] = '\0'; 185 buf[8] = '\0';
186 info("system string: %s",&buf[1]); 186 info("system string: %s",&buf[1]);
187 187
188 d->fe = vp702x_fe_attach(d); 188 adap->fe = vp702x_fe_attach(adap->dev);
189 return 0; 189 return 0;
190} 190}
191 191
192static struct dvb_usb_properties vp702x_properties; 192static struct dvb_usb_device_properties vp702x_properties;
193 193
194static int vp702x_usb_probe(struct usb_interface *intf, 194static int vp702x_usb_probe(struct usb_interface *intf,
195 const struct usb_device_id *id) 195 const struct usb_device_id *id)
@@ -211,28 +211,21 @@ static struct usb_device_id vp702x_usb_table [] = {
211}; 211};
212MODULE_DEVICE_TABLE(usb, vp702x_usb_table); 212MODULE_DEVICE_TABLE(usb, vp702x_usb_table);
213 213
214static struct dvb_usb_properties vp702x_properties = { 214static 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, 215 .usb_ctrl = CYPRESS_FX2,
219 .firmware = "dvb-usb-vp702x-01.fw", 216 .firmware = "dvb-usb-vp702x-01.fw",
220 217
218 .num_adapters = 1,
219 .adapter = {
220 {
221 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_NEED_PID_FILTERING,
222 .pid_filter_count = 8, /* !!! */
223
221 .pid_filter = vp702x_pid_filter, 224 .pid_filter = vp702x_pid_filter,
222 .power_ctrl = vp702x_power_ctrl,
223 .frontend_attach = vp702x_frontend_attach, 225 .frontend_attach = vp702x_frontend_attach,
224 .read_mac_address = vp702x_read_mac_addr,
225
226 .rc_key_map = vp702x_rc_keys,
227 .rc_key_map_size = ARRAY_SIZE(vp702x_rc_keys),
228 .rc_interval = 400,
229 .rc_query = vp702x_rc_query,
230
231 .size_of_priv = sizeof(struct vp702x_state),
232
233 /* parameter for the MPEG2-data transfer */ 226 /* parameter for the MPEG2-data transfer */
234 .urb = { 227 .stream = {
235 .type = DVB_USB_BULK, 228 .type = USB_BULK,
236 .count = 7, 229 .count = 7,
237 .endpoint = 0x02, 230 .endpoint = 0x02,
238 .u = { 231 .u = {
@@ -241,6 +234,16 @@ static struct dvb_usb_properties vp702x_properties = {
241 } 234 }
242 } 235 }
243 }, 236 },
237 .size_of_priv = sizeof(struct vp702x_state),
238 },
239 },
240 .power_ctrl = vp702x_power_ctrl,
241 .read_mac_address = vp702x_read_mac_addr,
242
243 .rc_key_map = vp702x_rc_keys,
244 .rc_key_map_size = ARRAY_SIZE(vp702x_rc_keys),
245 .rc_interval = 400,
246 .rc_query = vp702x_rc_query,
244 247
245 .num_device_descs = 2, 248 .num_device_descs = 2,
246 .devices = { 249 .devices = {
diff --git a/drivers/media/dvb/dvb-usb/vp7045.c b/drivers/media/dvb/dvb-usb/vp7045.c
index 8ea3834a6cf..b4cf002703a 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 = {