diff options
23 files changed, 1017 insertions, 1005 deletions
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig index 0a3c35399bea..135f287510c7 100644 --- a/drivers/media/dvb/dvb-usb/Kconfig +++ b/drivers/media/dvb/dvb-usb/Kconfig @@ -39,20 +39,8 @@ config DVB_USB_DIBUSB_MB Support for USB 1.1 and 2.0 DVB-T receivers based on reference designs made by DiBcom (<http://www.dibcom.fr>) equipped with a DiB3000M-B demodulator. - Devices supported by this driver: - Artec T1 USB1.1 boxes - Avermedia AverTV DVBT USB1.1 - Compro Videomate DVB-U2000 - DVB-T USB - DiBcom USB1.1 reference devices (non-public) - Grandtec DVB-T USB - Hama DVB-T USB1.1-Box - KWorld/JetWay/ADSTech V-Stream XPERT DTV - DVB-T USB1.1 and USB2.0 - TwinhanDTV Magic Box (VP7041e) - TwinhanDTV USB-Ter (VP7041) - Ultima Electronic/Artec T1 USB TVBOX - - The VP7041 seems to be identical to "CTS Portable" (Chinese - Television System). + For an up-to-date list of devices supported by this driver, have a look + on the Linux-DVB Wiki at www.linuxtv.org. Say Y if you own such a device and want to use it. You should build it as a module. @@ -69,12 +57,28 @@ config DVB_USB_DIBUSB_MC select DVB_DIB3000MC select DVB_TUNER_MT2060 help - Support for 2.0 DVB-T receivers based on reference designs made by + Support for USB2.0 DVB-T receivers based on reference designs made by DiBcom (<http://www.dibcom.fr>) equipped with a DiB3000M-C/P demodulator. - Devices supported by this driver: - Artec T1 USB2.0 boxes - DiBcom USB2.0 reference devices (non-public) + For an up-to-date list of devices supported by this driver, have a look + on the Linux-DVB Wiki at www.linuxtv.org. + + Say Y if you own such a device and want to use it. You should build it as + a module. + +config DVB_USB_DIB0700 + tristate "DiBcom DiB0700 USB DVB devices (see help for supported devices)" + depends on DVB_USB + select DVB_DIB7000M + select DVB_TUNER_MT2060 + help + Support for USB2.0/1.1 DVB receivers based on the DiB0700 USB bridge. The + USB bridge is also present in devices having the DiB7700 DVB-T-USB + silicon. This chip can be found in devices offered by Hauppauge, + Avermedia and other big and small companies. + + For an up-to-date list of devices supported by this driver, have a look + on the Linux-DVB Wiki at www.linuxtv.org. Say Y if you own such a device and want to use it. You should build it as a module. diff --git a/drivers/media/dvb/dvb-usb/Makefile b/drivers/media/dvb/dvb-usb/Makefile index 9643f56c7fe9..275cbc2925c4 100644 --- a/drivers/media/dvb/dvb-usb/Makefile +++ b/drivers/media/dvb/dvb-usb/Makefile @@ -1,4 +1,4 @@ -dvb-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 +dvb-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 obj-$(CONFIG_DVB_USB) += dvb-usb.o dvb-usb-vp7045-objs = vp7045.o vp7045-fe.o @@ -36,4 +36,6 @@ obj-$(CONFIG_DVB_USB_DIGITV) += dvb-usb-digitv.o dvb-usb-cxusb-objs = cxusb.o obj-$(CONFIG_DVB_USB_CXUSB) += dvb-usb-cxusb.o +dvb-usb-dib0700-objs = dib0700_core.o dib0700_devices.o + EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/ diff --git a/drivers/media/dvb/dvb-usb/a800.c b/drivers/media/dvb/dvb-usb/a800.c index df0c384bd4ca..2ed3eb62d787 100644 --- a/drivers/media/dvb/dvb-usb/a800.c +++ b/drivers/media/dvb/dvb-usb/a800.c @@ -27,7 +27,8 @@ static int a800_power_ctrl(struct dvb_usb_device *d, int onoff) } /* assure to put cold to 0 for iManufacturer == 1 */ -static int a800_identify_state(struct usb_device *udev, struct dvb_usb_properties *props,struct dvb_usb_device_description **desc, int *cold) +static int a800_identify_state(struct usb_device *udev, struct dvb_usb_device_properties *props, + struct dvb_usb_device_description **desc, int *cold) { *cold = udev->descriptor.iManufacturer != 1; return 0; @@ -88,7 +89,7 @@ static int a800_rc_query(struct dvb_usb_device *d, u32 *event, int *state) } /* USB Driver stuff */ -static struct dvb_usb_properties a800_properties; +static struct dvb_usb_device_properties a800_properties; static int a800_probe(struct usb_interface *intf, const struct usb_device_id *id) @@ -104,35 +105,27 @@ static struct usb_device_id a800_table [] = { }; MODULE_DEVICE_TABLE (usb, a800_table); -static struct dvb_usb_properties a800_properties = { - .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF | DVB_USB_IS_AN_I2C_ADAPTER, - .pid_filter_count = 32, +static struct dvb_usb_device_properties a800_properties = { + .caps = DVB_USB_IS_AN_I2C_ADAPTER, .usb_ctrl = CYPRESS_FX2, - .firmware = "dvb-usb-avertv-a800-02.fw", - .size_of_priv = sizeof(struct dibusb_state), - + .num_adapters = 1, + .adapter = { + { + .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, + .pid_filter_count = 32, .streaming_ctrl = dibusb2_0_streaming_ctrl, .pid_filter = dibusb_pid_filter, .pid_filter_ctrl = dibusb_pid_filter_ctrl, - .power_ctrl = a800_power_ctrl, + .frontend_attach = dibusb_dib3000mc_frontend_attach, .tuner_attach = dibusb_dib3000mc_tuner_attach, - .identify_state = a800_identify_state, - - .rc_interval = DEFAULT_RC_INTERVAL, - .rc_key_map = a800_rc_keys, - .rc_key_map_size = ARRAY_SIZE(a800_rc_keys), - .rc_query = a800_rc_query, - .i2c_algo = &dibusb_i2c_algo, - - .generic_bulk_ctrl_endpoint = 0x01, /* parameter for the MPEG2-data transfer */ - .urb = { - .type = DVB_USB_BULK, + .stream = { + .type = USB_BULK, .count = 7, .endpoint = 0x06, .u = { @@ -142,6 +135,21 @@ static struct dvb_usb_properties a800_properties = { } }, + .size_of_priv = sizeof(struct dibusb_state), + }, + }, + + .power_ctrl = a800_power_ctrl, + .identify_state = a800_identify_state, + + .rc_interval = DEFAULT_RC_INTERVAL, + .rc_key_map = a800_rc_keys, + .rc_key_map_size = ARRAY_SIZE(a800_rc_keys), + .rc_query = a800_rc_query, + + .i2c_algo = &dibusb_i2c_algo, + + .generic_bulk_ctrl_endpoint = 0x01, .num_device_descs = 1, .devices = { { "AVerMedia AverTV DVB-T USB 2.0 (A800)", diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c index c710c0176e07..5ebfa3f08546 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) return 0; } -static int cxusb_streaming_ctrl(struct dvb_usb_device *d, int onoff) +static int cxusb_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) { u8 buf[2] = { 0x03, 0x00 }; if (onoff) - cxusb_ctrl_msg(d,CMD_STREAMING_ON, buf, 2, NULL, 0); + cxusb_ctrl_msg(adap->dev, CMD_STREAMING_ON, buf, 2, NULL, 0); else - cxusb_ctrl_msg(d,CMD_STREAMING_OFF, NULL, 0, NULL, 0); + cxusb_ctrl_msg(adap->dev, CMD_STREAMING_OFF, NULL, 0, NULL, 0); return 0; } @@ -327,8 +327,8 @@ static int cxusb_mt352_demod_init(struct dvb_frontend* fe) static int cxusb_lgh064f_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep) { - struct dvb_usb_device *d = fe->dvb->priv; - return lg_h06xf_pll_set(fe, &d->i2c_adap, fep); + struct dvb_usb_adapter *adap = fe->dvb->priv; + return lg_h06xf_pll_set(fe, &adap->dev->i2c_adap, fep); } static struct cx22702_config cxusb_cx22702_config = { @@ -359,98 +359,99 @@ static struct mt352_config cxusb_mt352_config = { }; /* Callbacks for DVB USB */ -static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_device *d) +static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_adapter *adap) { u8 bpll[4] = { 0x0b, 0xdc, 0x9c, 0xa0 }; - d->pll_addr = 0x61; - memcpy(d->pll_init, bpll, 4); - d->pll_desc = &dvb_pll_fmd1216me; + adap->pll_addr = 0x61; + memcpy(adap->pll_init, bpll, 4); + adap->pll_desc = &dvb_pll_fmd1216me; - d->fe->ops.tuner_ops.init = dvb_usb_tuner_init_i2c; - d->fe->ops.tuner_ops.set_params = dvb_usb_tuner_set_params_i2c; + adap->fe->ops.tuner_ops.init = dvb_usb_tuner_init_i2c; + adap->fe->ops.tuner_ops.set_params = dvb_usb_tuner_set_params_i2c; return 0; } -static int cxusb_dee1601_tuner_attach(struct dvb_usb_device *d) +static int cxusb_dee1601_tuner_attach(struct dvb_usb_adapter *adap) { - d->pll_addr = 0x61; - d->pll_desc = &dvb_pll_thomson_dtt7579; - d->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs; + adap->pll_addr = 0x61; + adap->pll_desc = &dvb_pll_thomson_dtt7579; + adap->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs; return 0; } -static int cxusb_lgz201_tuner_attach(struct dvb_usb_device *d) +static int cxusb_lgz201_tuner_attach(struct dvb_usb_adapter *adap) { - d->pll_addr = 0x61; - d->pll_desc = &dvb_pll_lg_z201; - d->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs; + adap->pll_addr = 0x61; + adap->pll_desc = &dvb_pll_lg_z201; + adap->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs; return 0; } -static int cxusb_dtt7579_tuner_attach(struct dvb_usb_device *d) +static int cxusb_dtt7579_tuner_attach(struct dvb_usb_adapter *adap) { - d->pll_addr = 0x60; - d->pll_desc = &dvb_pll_thomson_dtt7579; - d->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs; + adap->pll_addr = 0x60; + adap->pll_desc = &dvb_pll_thomson_dtt7579; + adap->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs; return 0; } -static int cxusb_lgdt3303_tuner_attach(struct dvb_usb_device *d) +static int cxusb_lgdt3303_tuner_attach(struct dvb_usb_adapter *adap) { - d->fe->ops.tuner_ops.set_params = cxusb_lgh064f_tuner_set_params; + adap->fe->ops.tuner_ops.set_params = cxusb_lgh064f_tuner_set_params; return 0; } -static int cxusb_cx22702_frontend_attach(struct dvb_usb_device *d) +static int cxusb_cx22702_frontend_attach(struct dvb_usb_adapter *adap) { u8 b; - if (usb_set_interface(d->udev,0,6) < 0) + if (usb_set_interface(adap->dev->udev, 0, 6) < 0) err("set interface failed"); - cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, &b, 1); + cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, &b, 1); - if ((d->fe = dvb_attach(cx22702_attach, &cxusb_cx22702_config, &d->i2c_adap)) != NULL) + if ((adap->fe = dvb_attach(cx22702_attach, &cxusb_cx22702_config, &adap->dev->i2c_adap)) != NULL) return 0; return -EIO; } -static int cxusb_lgdt3303_frontend_attach(struct dvb_usb_device *d) +static int cxusb_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap) { - if (usb_set_interface(d->udev,0,7) < 0) + if (usb_set_interface(adap->dev->udev, 0, 7) < 0) err("set interface failed"); - cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, NULL, 0); + cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0); - if ((d->fe = dvb_attach(lgdt330x_attach, &cxusb_lgdt3303_config, &d->i2c_adap)) != NULL) + if ((adap->fe = dvb_attach(lgdt330x_attach, &cxusb_lgdt3303_config, &adap->dev->i2c_adap)) != NULL) return 0; return -EIO; } -static int cxusb_mt352_frontend_attach(struct dvb_usb_device *d) -{ /* used in both lgz201 and th7579 */ - if (usb_set_interface(d->udev,0,0) < 0) +static int cxusb_mt352_frontend_attach(struct dvb_usb_adapter *adap) +{ + /* used in both lgz201 and th7579 */ + if (usb_set_interface(adap->dev->udev, 0, 0) < 0) err("set interface failed"); - cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, NULL, 0); + cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0); - if ((d->fe = dvb_attach(mt352_attach, &cxusb_mt352_config, &d->i2c_adap)) != NULL) + if ((adap->fe = dvb_attach(mt352_attach, &cxusb_mt352_config, &adap->dev->i2c_adap)) != NULL) return 0; return -EIO; } -static int cxusb_dee1601_frontend_attach(struct dvb_usb_device *d) +static int cxusb_dee1601_frontend_attach(struct dvb_usb_adapter *adap) { - if (usb_set_interface(d->udev,0,0) < 0) + if (usb_set_interface(adap->dev->udev, 0, 0) < 0) err("set interface failed"); - cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, NULL, 0); + cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0); - if (((d->fe = dvb_attach(mt352_attach, &cxusb_dee1601_config, &d->i2c_adap)) != NULL) || - ((d->fe = dvb_attach(zl10353_attach, &cxusb_zl10353_dee1601_config, &d->i2c_adap)) != NULL)) + if (((adap->fe = dvb_attach(mt352_attach, &cxusb_dee1601_config, &adap->dev->i2c_adap)) != NULL) || + ((adap->fe = dvb_attach(zl10353_attach, &cxusb_zl10353_dee1601_config, &adap->dev->i2c_adap)) != NULL)) return 0; return -EIO; @@ -480,11 +481,11 @@ static int bluebird_patch_dvico_firmware_download(struct usb_device *udev, const } /* DVB USB Driver stuff */ -static struct dvb_usb_properties cxusb_medion_properties; -static struct dvb_usb_properties cxusb_bluebird_lgh064f_properties; -static struct dvb_usb_properties cxusb_bluebird_dee1601_properties; -static struct dvb_usb_properties cxusb_bluebird_lgz201_properties; -static struct dvb_usb_properties cxusb_bluebird_dtt7579_properties; +static struct dvb_usb_device_properties cxusb_medion_properties; +static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties; +static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties; +static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties; +static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties; static int cxusb_probe(struct usb_interface *intf, const struct usb_device_id *id) @@ -516,24 +517,22 @@ static struct usb_device_id cxusb_table [] = { }; MODULE_DEVICE_TABLE (usb, cxusb_table); -static struct dvb_usb_properties cxusb_medion_properties = { +static struct dvb_usb_device_properties cxusb_medion_properties = { .caps = DVB_USB_IS_AN_I2C_ADAPTER, .usb_ctrl = CYPRESS_FX2, .size_of_priv = sizeof(struct cxusb_state), + .num_adapters = 1, + .adapter = { + { .streaming_ctrl = cxusb_streaming_ctrl, - .power_ctrl = cxusb_power_ctrl, .frontend_attach = cxusb_cx22702_frontend_attach, .tuner_attach = cxusb_fmd1216me_tuner_attach, - - .i2c_algo = &cxusb_i2c_algo, - - .generic_bulk_ctrl_endpoint = 0x01, /* parameter for the MPEG2-data transfer */ - .urb = { - .type = DVB_USB_BULK, + .stream = { + .type = USB_BULK, .count = 5, .endpoint = 0x02, .u = { @@ -543,6 +542,14 @@ static struct dvb_usb_properties cxusb_medion_properties = { } }, + }, + }, + .power_ctrl = cxusb_power_ctrl, + + .i2c_algo = &cxusb_i2c_algo, + + .generic_bulk_ctrl_endpoint = 0x01, + .num_device_descs = 1, .devices = { { "Medion MD95700 (MDUSBTV-HYBRID)", @@ -552,7 +559,7 @@ static struct dvb_usb_properties cxusb_medion_properties = { } }; -static struct dvb_usb_properties cxusb_bluebird_lgh064f_properties = { +static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties = { .caps = DVB_USB_IS_AN_I2C_ADAPTER, .usb_ctrl = DEVICE_SPECIFIC, @@ -563,22 +570,16 @@ static struct dvb_usb_properties cxusb_bluebird_lgh064f_properties = { .size_of_priv = sizeof(struct cxusb_state), + .num_adapters = 1, + .adapter = { + { .streaming_ctrl = cxusb_streaming_ctrl, - .power_ctrl = cxusb_bluebird_power_ctrl, .frontend_attach = cxusb_lgdt3303_frontend_attach, .tuner_attach = cxusb_lgdt3303_tuner_attach, - .i2c_algo = &cxusb_i2c_algo, - - .rc_interval = 100, - .rc_key_map = dvico_portable_rc_keys, - .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys), - .rc_query = cxusb_rc_query, - - .generic_bulk_ctrl_endpoint = 0x01, /* parameter for the MPEG2-data transfer */ - .urb = { - .type = DVB_USB_BULK, + .stream = { + .type = USB_BULK, .count = 5, .endpoint = 0x02, .u = { @@ -587,6 +588,19 @@ static struct dvb_usb_properties cxusb_bluebird_lgh064f_properties = { } } }, + }, + }, + + .power_ctrl = cxusb_bluebird_power_ctrl, + + .i2c_algo = &cxusb_i2c_algo, + + .rc_interval = 100, + .rc_key_map = dvico_portable_rc_keys, + .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys), + .rc_query = cxusb_rc_query, + + .generic_bulk_ctrl_endpoint = 0x01, .num_device_descs = 1, .devices = { @@ -597,7 +611,7 @@ static struct dvb_usb_properties cxusb_bluebird_lgh064f_properties = { } }; -static struct dvb_usb_properties cxusb_bluebird_dee1601_properties = { +static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties = { .caps = DVB_USB_IS_AN_I2C_ADAPTER, .usb_ctrl = DEVICE_SPECIFIC, @@ -608,22 +622,15 @@ static struct dvb_usb_properties cxusb_bluebird_dee1601_properties = { .size_of_priv = sizeof(struct cxusb_state), + .num_adapters = 1, + .adapter = { + { .streaming_ctrl = cxusb_streaming_ctrl, - .power_ctrl = cxusb_bluebird_power_ctrl, .frontend_attach = cxusb_dee1601_frontend_attach, .tuner_attach = cxusb_dee1601_tuner_attach, - - .i2c_algo = &cxusb_i2c_algo, - - .rc_interval = 150, - .rc_key_map = dvico_mce_rc_keys, - .rc_key_map_size = ARRAY_SIZE(dvico_mce_rc_keys), - .rc_query = cxusb_rc_query, - - .generic_bulk_ctrl_endpoint = 0x01, /* parameter for the MPEG2-data transfer */ - .urb = { - .type = DVB_USB_BULK, + .stream = { + .type = USB_BULK, .count = 5, .endpoint = 0x04, .u = { @@ -632,6 +639,19 @@ static struct dvb_usb_properties cxusb_bluebird_dee1601_properties = { } } }, + }, + }, + + .power_ctrl = cxusb_bluebird_power_ctrl, + + .i2c_algo = &cxusb_i2c_algo, + + .rc_interval = 150, + .rc_key_map = dvico_mce_rc_keys, + .rc_key_map_size = ARRAY_SIZE(dvico_mce_rc_keys), + .rc_query = cxusb_rc_query, + + .generic_bulk_ctrl_endpoint = 0x01, .num_device_descs = 2, .devices = { @@ -646,7 +666,7 @@ static struct dvb_usb_properties cxusb_bluebird_dee1601_properties = { } }; -static struct dvb_usb_properties cxusb_bluebird_lgz201_properties = { +static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties = { .caps = DVB_USB_IS_AN_I2C_ADAPTER, .usb_ctrl = DEVICE_SPECIFIC, @@ -657,22 +677,16 @@ static struct dvb_usb_properties cxusb_bluebird_lgz201_properties = { .size_of_priv = sizeof(struct cxusb_state), + .num_adapters = 2, + .adapter = { + { .streaming_ctrl = cxusb_streaming_ctrl, - .power_ctrl = cxusb_bluebird_power_ctrl, .frontend_attach = cxusb_mt352_frontend_attach, .tuner_attach = cxusb_lgz201_tuner_attach, - .i2c_algo = &cxusb_i2c_algo, - - .rc_interval = 100, - .rc_key_map = dvico_portable_rc_keys, - .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys), - .rc_query = cxusb_rc_query, - - .generic_bulk_ctrl_endpoint = 0x01, /* parameter for the MPEG2-data transfer */ - .urb = { - .type = DVB_USB_BULK, + .stream = { + .type = USB_BULK, .count = 5, .endpoint = 0x04, .u = { @@ -681,7 +695,18 @@ static struct dvb_usb_properties cxusb_bluebird_lgz201_properties = { } } }, + }, + }, + .power_ctrl = cxusb_bluebird_power_ctrl, + + .i2c_algo = &cxusb_i2c_algo, + .rc_interval = 100, + .rc_key_map = dvico_portable_rc_keys, + .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys), + .rc_query = cxusb_rc_query, + + .generic_bulk_ctrl_endpoint = 0x01, .num_device_descs = 1, .devices = { { "DViCO FusionHDTV DVB-T USB (LGZ201)", @@ -691,7 +716,7 @@ static struct dvb_usb_properties cxusb_bluebird_lgz201_properties = { } }; -static struct dvb_usb_properties cxusb_bluebird_dtt7579_properties = { +static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties = { .caps = DVB_USB_IS_AN_I2C_ADAPTER, .usb_ctrl = DEVICE_SPECIFIC, @@ -702,22 +727,16 @@ static struct dvb_usb_properties cxusb_bluebird_dtt7579_properties = { .size_of_priv = sizeof(struct cxusb_state), + .num_adapters = 1, + .adapter = { + { .streaming_ctrl = cxusb_streaming_ctrl, - .power_ctrl = cxusb_bluebird_power_ctrl, .frontend_attach = cxusb_mt352_frontend_attach, .tuner_attach = cxusb_dtt7579_tuner_attach, - .i2c_algo = &cxusb_i2c_algo, - - .rc_interval = 100, - .rc_key_map = dvico_portable_rc_keys, - .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys), - .rc_query = cxusb_rc_query, - - .generic_bulk_ctrl_endpoint = 0x01, /* parameter for the MPEG2-data transfer */ - .urb = { - .type = DVB_USB_BULK, + .stream = { + .type = USB_BULK, .count = 5, .endpoint = 0x04, .u = { @@ -726,6 +745,18 @@ static struct dvb_usb_properties cxusb_bluebird_dtt7579_properties = { } } }, + }, + }, + .power_ctrl = cxusb_bluebird_power_ctrl, + + .i2c_algo = &cxusb_i2c_algo, + + .rc_interval = 100, + .rc_key_map = dvico_portable_rc_keys, + .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys), + .rc_query = cxusb_rc_query, + + .generic_bulk_ctrl_endpoint = 0x01, .num_device_descs = 1, .devices = { diff --git a/drivers/media/dvb/dvb-usb/dibusb-common.c b/drivers/media/dvb/dvb-usb/dibusb-common.c index 124e25ac53b3..5f8afec96a3b 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"); #define deb_info(args...) dprintk(debug,0x01,args) /* common stuff used by the different dibusb modules */ -int dibusb_streaming_ctrl(struct dvb_usb_device *d, int onoff) +int dibusb_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) { - if (d->priv != NULL) { - struct dibusb_state *st = d->priv; + if (adap->priv != NULL) { + struct dibusb_state *st = adap->priv; if (st->ops.fifo_ctrl != NULL) - if (st->ops.fifo_ctrl(d->fe,onoff)) { + if (st->ops.fifo_ctrl(adap->fe,onoff)) { err("error while controlling the fifo of the demod."); return -ENODEV; } @@ -32,23 +32,23 @@ int dibusb_streaming_ctrl(struct dvb_usb_device *d, int onoff) } EXPORT_SYMBOL(dibusb_streaming_ctrl); -int dibusb_pid_filter(struct dvb_usb_device *d, int index, u16 pid, int onoff) +int dibusb_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid, int onoff) { - if (d->priv != NULL) { - struct dibusb_state *st = d->priv; + if (adap->priv != NULL) { + struct dibusb_state *st = adap->priv; if (st->ops.pid_ctrl != NULL) - st->ops.pid_ctrl(d->fe,index,pid,onoff); + st->ops.pid_ctrl(adap->fe,index,pid,onoff); } return 0; } EXPORT_SYMBOL(dibusb_pid_filter); -int dibusb_pid_filter_ctrl(struct dvb_usb_device *d, int onoff) +int dibusb_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff) { - if (d->priv != NULL) { - struct dibusb_state *st = d->priv; + if (adap->priv != NULL) { + struct dibusb_state *st = adap->priv; if (st->ops.pid_parse != NULL) - if (st->ops.pid_parse(d->fe,onoff) < 0) + if (st->ops.pid_parse(adap->fe,onoff) < 0) err("could not handle pid_parser"); } return 0; @@ -68,24 +68,24 @@ int dibusb_power_ctrl(struct dvb_usb_device *d, int onoff) } EXPORT_SYMBOL(dibusb_power_ctrl); -int dibusb2_0_streaming_ctrl(struct dvb_usb_device *d, int onoff) +int dibusb2_0_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) { u8 b[3] = { 0 }; int ret; - if ((ret = dibusb_streaming_ctrl(d,onoff)) < 0) + if ((ret = dibusb_streaming_ctrl(adap,onoff)) < 0) return ret; if (onoff) { b[0] = DIBUSB_REQ_SET_STREAMING_MODE; b[1] = 0x00; - if ((ret = dvb_usb_generic_write(d,b,2)) < 0) + if ((ret = dvb_usb_generic_write(adap->dev,b,2)) < 0) return ret; } b[0] = DIBUSB_REQ_SET_IOCTL; b[1] = onoff ? DIBUSB_IOCTL_CMD_ENABLE_STREAM : DIBUSB_IOCTL_CMD_DISABLE_STREAM; - return dvb_usb_generic_write(d,b,3); + return dvb_usb_generic_write(adap->dev,b,3); } EXPORT_SYMBOL(dibusb2_0_streaming_ctrl); @@ -228,12 +228,12 @@ static struct dib3000mc_config mod3000p_dib3000p_config = { .output_mpeg2_in_188_bytes = 1, }; -int dibusb_dib3000mc_frontend_attach(struct dvb_usb_device *d) +int dibusb_dib3000mc_frontend_attach(struct dvb_usb_adapter *adap) { - if (dib3000mc_attach(&d->i2c_adap, 1, DEFAULT_DIB3000P_I2C_ADDRESS, 0, &mod3000p_dib3000p_config, &d->fe) == 0 || - dib3000mc_attach(&d->i2c_adap, 1, DEFAULT_DIB3000MC_I2C_ADDRESS, 0, &mod3000p_dib3000p_config, &d->fe) == 0) { - if (d->priv != NULL) { - struct dibusb_state *st = d->priv; + if (dib3000mc_attach(&adap->dev->i2c_adap, 1, DEFAULT_DIB3000P_I2C_ADDRESS, 0, &mod3000p_dib3000p_config, &adap->fe) == 0 || + dib3000mc_attach(&adap->dev->i2c_adap, 1, DEFAULT_DIB3000MC_I2C_ADDRESS, 0, &mod3000p_dib3000p_config, &adap->fe) == 0) { + if (adap->priv != NULL) { + struct dibusb_state *st = adap->priv; st->ops.pid_parse = dib3000mc_pid_parse; st->ops.pid_ctrl = dib3000mc_pid_control; } @@ -247,20 +247,20 @@ static struct mt2060_config stk3000p_mt2060_config = { 0x60 }; -int dibusb_dib3000mc_tuner_attach (struct dvb_usb_device *d) +int dibusb_dib3000mc_tuner_attach (struct dvb_usb_adapter *adap) { - struct dibusb_state *st = d->priv; + struct dibusb_state *st = adap->priv; int ret; u8 a,b; u16 if1 = 1220; struct i2c_adapter *tun_i2c; // First IF calibration for Liteon Sticks - if (d->udev->descriptor.idVendor == USB_VID_LITEON && - d->udev->descriptor.idProduct == USB_PID_LITEON_DVB_T_WARM) { + if (adap->dev->udev->descriptor.idVendor == USB_VID_LITEON && + adap->dev->udev->descriptor.idProduct == USB_PID_LITEON_DVB_T_WARM) { - dibusb_read_eeprom_byte(d,0x7E,&a); - dibusb_read_eeprom_byte(d,0x7F,&b); + dibusb_read_eeprom_byte(adap->dev,0x7E,&a); + dibusb_read_eeprom_byte(adap->dev,0x7F,&b); if (a == 0x00) if1 += b; @@ -269,14 +269,14 @@ int dibusb_dib3000mc_tuner_attach (struct dvb_usb_device *d) else warn("LITE-ON DVB-T: Strange IF1 calibration :%2X %2X\n", a, b); - } else if (d->udev->descriptor.idVendor == USB_VID_DIBCOM && - d->udev->descriptor.idProduct == USB_PID_DIBCOM_MOD3001_WARM) { + } else if (adap->dev->udev->descriptor.idVendor == USB_VID_DIBCOM && + adap->dev->udev->descriptor.idProduct == USB_PID_DIBCOM_MOD3001_WARM) { u8 desc; - dibusb_read_eeprom_byte(d, 7, &desc); + dibusb_read_eeprom_byte(adap->dev, 7, &desc); if (desc == 2) { a = 127; do { - dibusb_read_eeprom_byte(d, a, &desc); + dibusb_read_eeprom_byte(adap->dev, a, &desc); a--; } while (a > 7 && (desc == 0xff || desc == 0x00)); if (desc & 0x80) @@ -286,15 +286,15 @@ int dibusb_dib3000mc_tuner_attach (struct dvb_usb_device *d) } } - tun_i2c = dib3000mc_get_tuner_i2c_master(d->fe, 1); - if ((ret = mt2060_attach(d->fe, tun_i2c, &stk3000p_mt2060_config, if1)) != 0) { + tun_i2c = dib3000mc_get_tuner_i2c_master(adap->fe, 1); + if ((ret = mt2060_attach(adap->fe, tun_i2c, &stk3000p_mt2060_config, if1)) != 0) { /* not found - use panasonic pll parameters */ - if (dvb_pll_attach(d->fe, 0x60, tun_i2c, &dvb_pll_env57h1xd5) == NULL) + if (dvb_pll_attach(adap->fe, 0x60, tun_i2c, &dvb_pll_env57h1xd5) == NULL) return -ENOMEM; } else { st->mt2060_present = 1; /* set the correct parameters for the dib3000p */ - dib3000mc_set_config(d->fe, &stk3000p_dib3000p_config); + dib3000mc_set_config(adap->fe, &stk3000p_dib3000p_config); } return 0; } diff --git a/drivers/media/dvb/dvb-usb/dibusb-mb.c b/drivers/media/dvb/dvb-usb/dibusb-mb.c index effd34cc4b02..4fe363e48352 100644 --- a/drivers/media/dvb/dvb-usb/dibusb-mb.c +++ b/drivers/media/dvb/dvb-usb/dibusb-mb.c @@ -14,35 +14,35 @@ */ #include "dibusb.h" -static int dibusb_dib3000mb_frontend_attach(struct dvb_usb_device *d) +static int dibusb_dib3000mb_frontend_attach(struct dvb_usb_adapter *adap) { struct dib3000_config demod_cfg; - struct dibusb_state *st = d->priv; + struct dibusb_state *st = adap->priv; demod_cfg.demod_address = 0x8; - if ((d->fe = dib3000mb_attach(&demod_cfg,&d->i2c_adap,&st->ops)) == NULL) + if ((adap->fe = dib3000mb_attach(&demod_cfg,&adap->dev->i2c_adap,&st->ops)) == NULL) return -ENODEV; - d->fe->ops.tuner_ops.init = dvb_usb_tuner_init_i2c; - d->fe->ops.tuner_ops.set_params = dvb_usb_tuner_set_params_i2c; + adap->fe->ops.tuner_ops.init = dvb_usb_tuner_init_i2c; + adap->fe->ops.tuner_ops.set_params = dvb_usb_tuner_set_params_i2c; - d->tuner_pass_ctrl = st->ops.tuner_pass_ctrl; + adap->tuner_pass_ctrl = st->ops.tuner_pass_ctrl; return 0; } -static int dibusb_thomson_tuner_attach(struct dvb_usb_device *d) +static int dibusb_thomson_tuner_attach(struct dvb_usb_adapter *adap) { - d->pll_addr = 0x61; - d->pll_desc = &dvb_pll_tua6010xs; + adap->pll_addr = 0x61; + adap->pll_desc = &dvb_pll_tua6010xs; return 0; } /* Some of the Artec 1.1 device aren't equipped with the default tuner * (Thomson Cable), but with a Panasonic ENV77H11D5. This function figures * this out. */ -static int dibusb_tuner_probe_and_attach(struct dvb_usb_device *d) +static int dibusb_tuner_probe_and_attach(struct dvb_usb_adapter *adap) { u8 b[2] = { 0,0 }, b2[1]; int ret = 0; @@ -54,36 +54,36 @@ static int dibusb_tuner_probe_and_attach(struct dvb_usb_device *d) /* the Panasonic sits on I2C addrass 0x60, the Thomson on 0x61 */ msg[0].addr = msg[1].addr = 0x60; - if (d->tuner_pass_ctrl) - d->tuner_pass_ctrl(d->fe,1,msg[0].addr); + if (adap->tuner_pass_ctrl) + adap->tuner_pass_ctrl(adap->fe,1,msg[0].addr); - if (i2c_transfer (&d->i2c_adap, msg, 2) != 2) { + if (i2c_transfer(&adap->dev->i2c_adap, msg, 2) != 2) { err("tuner i2c write failed."); ret = -EREMOTEIO; } - if (d->tuner_pass_ctrl) - d->tuner_pass_ctrl(d->fe,0,msg[0].addr); + if (adap->tuner_pass_ctrl) + adap->tuner_pass_ctrl(adap->fe,0,msg[0].addr); if (b2[0] == 0xfe) { info("This device has the Thomson Cable onboard. Which is default."); - dibusb_thomson_tuner_attach(d); + dibusb_thomson_tuner_attach(adap); } else { u8 bpll[4] = { 0x0b, 0xf5, 0x85, 0xab }; info("This device has the Panasonic ENV77H11D5 onboard."); - d->pll_addr = 0x60; - memcpy(d->pll_init,bpll,4); - d->pll_desc = &dvb_pll_tda665x; + adap->pll_addr = 0x60; + memcpy(adap->pll_init,bpll,4); + adap->pll_desc = &dvb_pll_tda665x; } return ret; } /* USB Driver stuff */ -static struct dvb_usb_properties dibusb1_1_properties; -static struct dvb_usb_properties dibusb1_1_an2235_properties; -static struct dvb_usb_properties dibusb2_0b_properties; -static struct dvb_usb_properties artec_t1_usb2_properties; +static struct dvb_usb_device_properties dibusb1_1_properties; +static struct dvb_usb_device_properties dibusb1_1_an2235_properties; +static struct dvb_usb_device_properties dibusb2_0b_properties; +static struct dvb_usb_device_properties artec_t1_usb2_properties; static int dibusb_probe(struct usb_interface *intf, const struct usb_device_id *id) @@ -150,34 +150,28 @@ static struct usb_device_id dibusb_dib3000mb_table [] = { }; MODULE_DEVICE_TABLE (usb, dibusb_dib3000mb_table); -static struct dvb_usb_properties dibusb1_1_properties = { - .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF | DVB_USB_IS_AN_I2C_ADAPTER, - .pid_filter_count = 16, +static struct dvb_usb_device_properties dibusb1_1_properties = { + .caps = DVB_USB_IS_AN_I2C_ADAPTER, .usb_ctrl = CYPRESS_AN2135, .firmware = "dvb-usb-dibusb-5.0.0.11.fw", - .size_of_priv = sizeof(struct dibusb_state), + .num_adapters = 1, + .adapter = { + { + .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, + .pid_filter_count = 16, .streaming_ctrl = dibusb_streaming_ctrl, .pid_filter = dibusb_pid_filter, .pid_filter_ctrl = dibusb_pid_filter_ctrl, - .power_ctrl = dibusb_power_ctrl, .frontend_attach = dibusb_dib3000mb_frontend_attach, .tuner_attach = dibusb_tuner_probe_and_attach, - .rc_interval = DEFAULT_RC_INTERVAL, - .rc_key_map = dibusb_rc_keys, - .rc_key_map_size = 111, /* wow, that is ugly ... I want to load it to the driver dynamically */ - .rc_query = dibusb_rc_query, - - .i2c_algo = &dibusb_i2c_algo, - - .generic_bulk_ctrl_endpoint = 0x01, /* parameter for the MPEG2-data transfer */ - .urb = { - .type = DVB_USB_BULK, + .stream = { + .type = USB_BULK, .count = 7, .endpoint = 0x02, .u = { @@ -186,6 +180,20 @@ static struct dvb_usb_properties dibusb1_1_properties = { } } }, + .size_of_priv = sizeof(struct dibusb_state), + } + }, + + .power_ctrl = dibusb_power_ctrl, + + .rc_interval = DEFAULT_RC_INTERVAL, + .rc_key_map = dibusb_rc_keys, + .rc_key_map_size = 111, /* wow, that is ugly ... I want to load it to the driver dynamically */ + .rc_query = dibusb_rc_query, + + .i2c_algo = &dibusb_i2c_algo, + + .generic_bulk_ctrl_endpoint = 0x01, .num_device_descs = 9, .devices = { @@ -228,34 +236,27 @@ static struct dvb_usb_properties dibusb1_1_properties = { } }; -static struct dvb_usb_properties dibusb1_1_an2235_properties = { - .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF | DVB_USB_IS_AN_I2C_ADAPTER, - .pid_filter_count = 16, - +static struct dvb_usb_device_properties dibusb1_1_an2235_properties = { + .caps = DVB_USB_IS_AN_I2C_ADAPTER, .usb_ctrl = CYPRESS_AN2235, .firmware = "dvb-usb-dibusb-an2235-01.fw", - .size_of_priv = sizeof(struct dibusb_state), + .num_adapters = 1, + .adapter = { + { + .caps = DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF | DVB_USB_ADAP_HAS_PID_FILTER, + .pid_filter_count = 16, .streaming_ctrl = dibusb_streaming_ctrl, .pid_filter = dibusb_pid_filter, .pid_filter_ctrl = dibusb_pid_filter_ctrl, - .power_ctrl = dibusb_power_ctrl, .frontend_attach = dibusb_dib3000mb_frontend_attach, .tuner_attach = dibusb_tuner_probe_and_attach, - .rc_interval = DEFAULT_RC_INTERVAL, - .rc_key_map = dibusb_rc_keys, - .rc_key_map_size = 111, /* wow, that is ugly ... I want to load it to the driver dynamically */ - .rc_query = dibusb_rc_query, - - .i2c_algo = &dibusb_i2c_algo, - - .generic_bulk_ctrl_endpoint = 0x01, /* parameter for the MPEG2-data transfer */ - .urb = { - .type = DVB_USB_BULK, + .stream = { + .type = USB_BULK, .count = 7, .endpoint = 0x02, .u = { @@ -264,6 +265,19 @@ static struct dvb_usb_properties dibusb1_1_an2235_properties = { } } }, + .size_of_priv = sizeof(struct dibusb_state), + }, + }, + .power_ctrl = dibusb_power_ctrl, + + .rc_interval = DEFAULT_RC_INTERVAL, + .rc_key_map = dibusb_rc_keys, + .rc_key_map_size = 111, /* wow, that is ugly ... I want to load it to the driver dynamically */ + .rc_query = dibusb_rc_query, + + .i2c_algo = &dibusb_i2c_algo, + + .generic_bulk_ctrl_endpoint = 0x01, #ifdef CONFIG_DVB_USB_DIBUSB_MB_FAULTY .num_device_descs = 2, @@ -285,34 +299,27 @@ static struct dvb_usb_properties dibusb1_1_an2235_properties = { } }; -static struct dvb_usb_properties dibusb2_0b_properties = { - .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF | DVB_USB_IS_AN_I2C_ADAPTER, - .pid_filter_count = 16, +static struct dvb_usb_device_properties dibusb2_0b_properties = { + .caps = DVB_USB_IS_AN_I2C_ADAPTER, .usb_ctrl = CYPRESS_FX2, .firmware = "dvb-usb-adstech-usb2-02.fw", - .size_of_priv = sizeof(struct dibusb_state), + .num_adapters = 1, + .adapter = { + { + .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, + .pid_filter_count = 16, .streaming_ctrl = dibusb2_0_streaming_ctrl, .pid_filter = dibusb_pid_filter, .pid_filter_ctrl = dibusb_pid_filter_ctrl, - .power_ctrl = dibusb2_0_power_ctrl, .frontend_attach = dibusb_dib3000mb_frontend_attach, .tuner_attach = dibusb_thomson_tuner_attach, - - .rc_interval = DEFAULT_RC_INTERVAL, - .rc_key_map = dibusb_rc_keys, - .rc_key_map_size = 111, /* wow, that is ugly ... I want to load it to the driver dynamically */ - .rc_query = dibusb_rc_query, - - .i2c_algo = &dibusb_i2c_algo, - - .generic_bulk_ctrl_endpoint = 0x01, /* parameter for the MPEG2-data transfer */ - .urb = { - .type = DVB_USB_BULK, + .stream = { + .type = USB_BULK, .count = 7, .endpoint = 0x06, .u = { @@ -321,6 +328,19 @@ static struct dvb_usb_properties dibusb2_0b_properties = { } } }, + .size_of_priv = sizeof(struct dibusb_state), + } + }, + .power_ctrl = dibusb2_0_power_ctrl, + + .rc_interval = DEFAULT_RC_INTERVAL, + .rc_key_map = dibusb_rc_keys, + .rc_key_map_size = 111, /* wow, that is ugly ... I want to load it to the driver dynamically */ + .rc_query = dibusb_rc_query, + + .i2c_algo = &dibusb_i2c_algo, + + .generic_bulk_ctrl_endpoint = 0x01, .num_device_descs = 2, .devices = { @@ -336,34 +356,27 @@ static struct dvb_usb_properties dibusb2_0b_properties = { } }; -static struct dvb_usb_properties artec_t1_usb2_properties = { - .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF | DVB_USB_IS_AN_I2C_ADAPTER, - .pid_filter_count = 16, +static struct dvb_usb_device_properties artec_t1_usb2_properties = { + .caps = DVB_USB_IS_AN_I2C_ADAPTER, .usb_ctrl = CYPRESS_FX2, .firmware = "dvb-usb-dibusb-6.0.0.8.fw", - .size_of_priv = sizeof(struct dibusb_state), + .num_adapters = 1, + .adapter = { + { + .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, + .pid_filter_count = 16, .streaming_ctrl = dibusb2_0_streaming_ctrl, .pid_filter = dibusb_pid_filter, .pid_filter_ctrl = dibusb_pid_filter_ctrl, - .power_ctrl = dibusb2_0_power_ctrl, .frontend_attach = dibusb_dib3000mb_frontend_attach, .tuner_attach = dibusb_tuner_probe_and_attach, - - .rc_interval = DEFAULT_RC_INTERVAL, - .rc_key_map = dibusb_rc_keys, - .rc_key_map_size = 111, /* wow, that is ugly ... I want to load it to the driver dynamically */ - .rc_query = dibusb_rc_query, - - .i2c_algo = &dibusb_i2c_algo, - - .generic_bulk_ctrl_endpoint = 0x01, /* parameter for the MPEG2-data transfer */ - .urb = { - .type = DVB_USB_BULK, + .stream = { + .type = USB_BULK, .count = 7, .endpoint = 0x06, .u = { @@ -372,6 +385,19 @@ static struct dvb_usb_properties artec_t1_usb2_properties = { } } }, + .size_of_priv = sizeof(struct dibusb_state), + } + }, + .power_ctrl = dibusb2_0_power_ctrl, + + .rc_interval = DEFAULT_RC_INTERVAL, + .rc_key_map = dibusb_rc_keys, + .rc_key_map_size = 111, /* wow, that is ugly ... I want to load it to the driver dynamically */ + .rc_query = dibusb_rc_query, + + .i2c_algo = &dibusb_i2c_algo, + + .generic_bulk_ctrl_endpoint = 0x01, .num_device_descs = 1, .devices = { diff --git a/drivers/media/dvb/dvb-usb/dibusb-mc.c b/drivers/media/dvb/dvb-usb/dibusb-mc.c index eca4082a61ae..d823e7d5b260 100644 --- a/drivers/media/dvb/dvb-usb/dibusb-mc.c +++ b/drivers/media/dvb/dvb-usb/dibusb-mc.c @@ -15,7 +15,7 @@ #include "dibusb.h" /* USB Driver stuff */ -static struct dvb_usb_properties dibusb_mc_properties; +static struct dvb_usb_device_properties dibusb_mc_properties; static int dibusb_mc_probe(struct usb_interface *intf, const struct usb_device_id *id) @@ -43,33 +43,27 @@ static struct usb_device_id dibusb_dib3000mc_table [] = { }; MODULE_DEVICE_TABLE (usb, dibusb_dib3000mc_table); -static struct dvb_usb_properties dibusb_mc_properties = { - .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF | DVB_USB_IS_AN_I2C_ADAPTER, - .pid_filter_count = 32, +static struct dvb_usb_device_properties dibusb_mc_properties = { + .caps = DVB_USB_IS_AN_I2C_ADAPTER, .usb_ctrl = CYPRESS_FX2, .firmware = "dvb-usb-dibusb-6.0.0.8.fw", - .size_of_priv = sizeof(struct dibusb_state), + .num_adapters = 1, + .adapter = { + { + .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, + .pid_filter_count = 32, .streaming_ctrl = dibusb2_0_streaming_ctrl, .pid_filter = dibusb_pid_filter, .pid_filter_ctrl = dibusb_pid_filter_ctrl, - .power_ctrl = dibusb2_0_power_ctrl, .frontend_attach = dibusb_dib3000mc_frontend_attach, .tuner_attach = dibusb_dib3000mc_tuner_attach, - .rc_interval = DEFAULT_RC_INTERVAL, - .rc_key_map = dibusb_rc_keys, - .rc_key_map_size = 111, /* FIXME */ - .rc_query = dibusb_rc_query, - - .i2c_algo = &dibusb_i2c_algo, - - .generic_bulk_ctrl_endpoint = 0x01, /* parameter for the MPEG2-data transfer */ - .urb = { - .type = DVB_USB_BULK, + .stream = { + .type = USB_BULK, .count = 7, .endpoint = 0x06, .u = { @@ -78,6 +72,19 @@ static struct dvb_usb_properties dibusb_mc_properties = { } } }, + .size_of_priv = sizeof(struct dibusb_state), + } + }, + .power_ctrl = dibusb2_0_power_ctrl, + + .rc_interval = DEFAULT_RC_INTERVAL, + .rc_key_map = dibusb_rc_keys, + .rc_key_map_size = 111, /* FIXME */ + .rc_query = dibusb_rc_query, + + .i2c_algo = &dibusb_i2c_algo, + + .generic_bulk_ctrl_endpoint = 0x01, .num_device_descs = 7, .devices = { diff --git a/drivers/media/dvb/dvb-usb/dibusb.h b/drivers/media/dvb/dvb-usb/dibusb.h index a43f87480cf6..5153fb943da1 100644 --- a/drivers/media/dvb/dvb-usb/dibusb.h +++ b/drivers/media/dvb/dvb-usb/dibusb.h @@ -107,14 +107,15 @@ struct dibusb_state { extern struct i2c_algorithm dibusb_i2c_algo; -extern int dibusb_dib3000mc_frontend_attach(struct dvb_usb_device *); -extern int dibusb_dib3000mc_tuner_attach (struct dvb_usb_device *); +extern int dibusb_dib3000mc_frontend_attach(struct dvb_usb_adapter *); +extern int dibusb_dib3000mc_tuner_attach (struct dvb_usb_adapter *); + +extern int dibusb_streaming_ctrl(struct dvb_usb_adapter *, int); +extern int dibusb_pid_filter(struct dvb_usb_adapter *, int, u16, int); +extern int dibusb_pid_filter_ctrl(struct dvb_usb_adapter *, int); +extern int dibusb2_0_streaming_ctrl(struct dvb_usb_adapter *, int); -extern int dibusb_streaming_ctrl(struct dvb_usb_device *, int); -extern int dibusb_pid_filter(struct dvb_usb_device *, int, u16, int); -extern int dibusb_pid_filter_ctrl(struct dvb_usb_device *, int); extern int dibusb_power_ctrl(struct dvb_usb_device *, int); -extern int dibusb2_0_streaming_ctrl(struct dvb_usb_device *, int); extern int dibusb2_0_power_ctrl(struct dvb_usb_device *, int); #define DEFAULT_RC_INTERVAL 150 diff --git a/drivers/media/dvb/dvb-usb/digitv.c b/drivers/media/dvb/dvb-usb/digitv.c index 015854487308..8fb34375c1fb 100644 --- a/drivers/media/dvb/dvb-usb/digitv.c +++ b/drivers/media/dvb/dvb-usb/digitv.c @@ -83,7 +83,7 @@ static struct i2c_algorithm digitv_i2c_algo = { /* Callbacks for DVB USB */ static int digitv_identify_state (struct usb_device *udev, struct - dvb_usb_properties *props, struct dvb_usb_device_description **desc, + dvb_usb_device_properties *props, struct dvb_usb_device_description **desc, int *cold) { *cold = udev->descriptor.iManufacturer == 0 && udev->descriptor.iProduct == 0; @@ -116,33 +116,33 @@ static struct mt352_config digitv_mt352_config = { static int digitv_nxt6000_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep) { - struct dvb_usb_device *d = fe->dvb->priv; + struct dvb_usb_adapter *adap = fe->dvb->priv; u8 b[5]; dvb_usb_tuner_calc_regs(fe,fep,b, 5); - return digitv_ctrl_msg(d,USB_WRITE_TUNER,0,&b[1],4,NULL,0); + return digitv_ctrl_msg(adap->dev, USB_WRITE_TUNER, 0, &b[1], 4, NULL, 0); } static struct nxt6000_config digitv_nxt6000_config = { .clock_inversion = 1, }; -static int digitv_frontend_attach(struct dvb_usb_device *d) +static int digitv_frontend_attach(struct dvb_usb_adapter *adap) { - if ((d->fe = dvb_attach(mt352_attach, &digitv_mt352_config, &d->i2c_adap)) != NULL) { - d->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs; + if ((adap->fe = dvb_attach(mt352_attach, &digitv_mt352_config, &adap->dev->i2c_adap)) != NULL) { + adap->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs; return 0; } - if ((d->fe = dvb_attach(nxt6000_attach, &digitv_nxt6000_config, &d->i2c_adap)) != NULL) { - d->fe->ops.tuner_ops.set_params = digitv_nxt6000_tuner_set_params; + if ((adap->fe = dvb_attach(nxt6000_attach, &digitv_nxt6000_config, &adap->dev->i2c_adap)) != NULL) { + adap->fe->ops.tuner_ops.set_params = digitv_nxt6000_tuner_set_params; return 0; } return -EIO; } -static int digitv_tuner_attach(struct dvb_usb_device *d) +static int digitv_tuner_attach(struct dvb_usb_adapter *adap) { - d->pll_addr = 0x60; - d->pll_desc = &dvb_pll_tded4; + adap->pll_addr = 0x60; + adap->pll_desc = &dvb_pll_tded4; return 0; } @@ -238,7 +238,7 @@ static int digitv_rc_query(struct dvb_usb_device *d, u32 *event, int *state) } /* DVB USB Driver stuff */ -static struct dvb_usb_properties digitv_properties; +static struct dvb_usb_device_properties digitv_properties; static int digitv_probe(struct usb_interface *intf, const struct usb_device_id *id) @@ -265,30 +265,21 @@ static struct usb_device_id digitv_table [] = { }; MODULE_DEVICE_TABLE (usb, digitv_table); -static struct dvb_usb_properties digitv_properties = { +static struct dvb_usb_device_properties digitv_properties = { .caps = DVB_USB_IS_AN_I2C_ADAPTER, .usb_ctrl = CYPRESS_FX2, .firmware = "dvb-usb-digitv-02.fw", - .size_of_priv = 0, - + .num_adapters = 1, + .adapter = { + { .frontend_attach = digitv_frontend_attach, .tuner_attach = digitv_tuner_attach, - .rc_interval = 1000, - .rc_key_map = digitv_rc_keys, - .rc_key_map_size = ARRAY_SIZE(digitv_rc_keys), - .rc_query = digitv_rc_query, - - .identify_state = digitv_identify_state, - - .i2c_algo = &digitv_i2c_algo, - - .generic_bulk_ctrl_endpoint = 0x01, /* parameter for the MPEG2-data transfer */ - .urb = { - .type = DVB_USB_BULK, + .stream = { + .type = USB_BULK, .count = 7, .endpoint = 0x02, .u = { @@ -297,6 +288,18 @@ static struct dvb_usb_properties digitv_properties = { } } }, + } + }, + .identify_state = digitv_identify_state, + + .rc_interval = 1000, + .rc_key_map = digitv_rc_keys, + .rc_key_map_size = ARRAY_SIZE(digitv_rc_keys), + .rc_query = digitv_rc_query, + + .i2c_algo = &digitv_i2c_algo, + + .generic_bulk_ctrl_endpoint = 0x01, .num_device_descs = 1, .devices = { diff --git a/drivers/media/dvb/dvb-usb/dtt200u.c b/drivers/media/dvb/dvb-usb/dtt200u.c index 27af4e436479..b834db74e77c 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) return 0; } -static int dtt200u_streaming_ctrl(struct dvb_usb_device *d, int onoff) +static int dtt200u_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) { u8 b_streaming[2] = { SET_STREAMING, onoff }; u8 b_rst_pid = RESET_PID_FILTER; - dvb_usb_generic_write(d,b_streaming,2); + dvb_usb_generic_write(adap->dev, b_streaming, 2); if (onoff == 0) - dvb_usb_generic_write(d,&b_rst_pid,1); + dvb_usb_generic_write(adap->dev, &b_rst_pid, 1); return 0; } -static int dtt200u_pid_filter(struct dvb_usb_device *d, int index, u16 pid, int onoff) +static int dtt200u_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid, int onoff) { u8 b_pid[4]; pid = onoff ? pid : 0; @@ -50,7 +50,7 @@ static int dtt200u_pid_filter(struct dvb_usb_device *d, int index, u16 pid, int b_pid[2] = pid & 0xff; b_pid[3] = (pid >> 8) & 0x1f; - return dvb_usb_generic_write(d,b_pid,4); + return dvb_usb_generic_write(adap->dev, b_pid, 4); } /* remote control */ @@ -86,16 +86,16 @@ static int dtt200u_rc_query(struct dvb_usb_device *d, u32 *event, int *state) return 0; } -static int dtt200u_frontend_attach(struct dvb_usb_device *d) +static int dtt200u_frontend_attach(struct dvb_usb_adapter *adap) { - d->fe = dtt200u_fe_attach(d); + adap->fe = dtt200u_fe_attach(adap); return 0; } -static struct dvb_usb_properties dtt200u_properties; -static struct dvb_usb_properties wt220u_fc_properties; -static struct dvb_usb_properties wt220u_properties; -static struct dvb_usb_properties wt220u_zl0353_properties; +static struct dvb_usb_device_properties dtt200u_properties; +static struct dvb_usb_device_properties wt220u_fc_properties; +static struct dvb_usb_device_properties wt220u_properties; +static struct dvb_usb_device_properties wt220u_zl0353_properties; static int dtt200u_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) @@ -123,28 +123,22 @@ static struct usb_device_id dtt200u_usb_table [] = { }; MODULE_DEVICE_TABLE(usb, dtt200u_usb_table); -static struct dvb_usb_properties dtt200u_properties = { - .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_NEED_PID_FILTERING, - .pid_filter_count = 15, - +static struct dvb_usb_device_properties dtt200u_properties = { .usb_ctrl = CYPRESS_FX2, .firmware = "dvb-usb-dtt200u-01.fw", - .power_ctrl = dtt200u_power_ctrl, + .num_adapters = 1, + .adapter = { + { + .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_NEED_PID_FILTERING, + .pid_filter_count = 15, + .streaming_ctrl = dtt200u_streaming_ctrl, .pid_filter = dtt200u_pid_filter, .frontend_attach = dtt200u_frontend_attach, - - .rc_interval = 300, - .rc_key_map = dtt200u_rc_keys, - .rc_key_map_size = ARRAY_SIZE(dtt200u_rc_keys), - .rc_query = dtt200u_rc_query, - - .generic_bulk_ctrl_endpoint = 0x01, - /* parameter for the MPEG2-data transfer */ - .urb = { - .type = DVB_USB_BULK, + .stream = { + .type = USB_BULK, .count = 7, .endpoint = 0x02, .u = { @@ -153,6 +147,16 @@ static struct dvb_usb_properties dtt200u_properties = { } } }, + } + }, + .power_ctrl = dtt200u_power_ctrl, + + .rc_interval = 300, + .rc_key_map = dtt200u_rc_keys, + .rc_key_map_size = ARRAY_SIZE(dtt200u_rc_keys), + .rc_query = dtt200u_rc_query, + + .generic_bulk_ctrl_endpoint = 0x01, .num_device_descs = 1, .devices = { @@ -164,28 +168,22 @@ static struct dvb_usb_properties dtt200u_properties = { } }; -static struct dvb_usb_properties wt220u_properties = { - .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_NEED_PID_FILTERING, - .pid_filter_count = 15, - +static struct dvb_usb_device_properties wt220u_properties = { .usb_ctrl = CYPRESS_FX2, .firmware = "dvb-usb-wt220u-02.fw", - .power_ctrl = dtt200u_power_ctrl, + .num_adapters = 1, + .adapter = { + { + .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_NEED_PID_FILTERING, + .pid_filter_count = 15, + .streaming_ctrl = dtt200u_streaming_ctrl, .pid_filter = dtt200u_pid_filter, .frontend_attach = dtt200u_frontend_attach, - - .rc_interval = 300, - .rc_key_map = dtt200u_rc_keys, - .rc_key_map_size = ARRAY_SIZE(dtt200u_rc_keys), - .rc_query = dtt200u_rc_query, - - .generic_bulk_ctrl_endpoint = 0x01, - /* parameter for the MPEG2-data transfer */ - .urb = { - .type = DVB_USB_BULK, + .stream = { + .type = USB_BULK, .count = 7, .endpoint = 0x02, .u = { @@ -194,6 +192,16 @@ static struct dvb_usb_properties wt220u_properties = { } } }, + } + }, + .power_ctrl = dtt200u_power_ctrl, + + .rc_interval = 300, + .rc_key_map = dtt200u_rc_keys, + .rc_key_map_size = ARRAY_SIZE(dtt200u_rc_keys), + .rc_query = dtt200u_rc_query, + + .generic_bulk_ctrl_endpoint = 0x01, .num_device_descs = 1, .devices = { @@ -205,36 +213,40 @@ static struct dvb_usb_properties wt220u_properties = { } }; -static struct dvb_usb_properties wt220u_fc_properties = { - .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_NEED_PID_FILTERING, - .pid_filter_count = 15, - +static struct dvb_usb_device_properties wt220u_fc_properties = { .usb_ctrl = CYPRESS_FX2, .firmware = "dvb-usb-wt220u-fc03.fw", - .power_ctrl = dtt200u_power_ctrl, + .num_adapters = 1, + .adapter = { + { + .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_NEED_PID_FILTERING, + .pid_filter_count = 15, + .streaming_ctrl = dtt200u_streaming_ctrl, .pid_filter = dtt200u_pid_filter, .frontend_attach = dtt200u_frontend_attach, - - .rc_interval = 300, - .rc_key_map = dtt200u_rc_keys, - .rc_key_map_size = ARRAY_SIZE(dtt200u_rc_keys), - .rc_query = dtt200u_rc_query, - - .generic_bulk_ctrl_endpoint = 0x01, - /* parameter for the MPEG2-data transfer */ - .urb = { - .type = DVB_USB_BULK, + .stream = { + .type = USB_BULK, .count = 7, - .endpoint = 0x86, + .endpoint = 0x06, .u = { .bulk = { .buffersize = 4096, } } }, + } + }, + .power_ctrl = dtt200u_power_ctrl, + + .rc_interval = 300, + .rc_key_map = dtt200u_rc_keys, + .rc_key_map_size = ARRAY_SIZE(dtt200u_rc_keys), + .rc_query = dtt200u_rc_query, + + .generic_bulk_ctrl_endpoint = 0x01, .num_device_descs = 1, .devices = { @@ -246,28 +258,22 @@ static struct dvb_usb_properties wt220u_fc_properties = { } }; -static struct dvb_usb_properties wt220u_zl0353_properties = { - .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_NEED_PID_FILTERING, - .pid_filter_count = 15, - +static struct dvb_usb_device_properties wt220u_zl0353_properties = { .usb_ctrl = CYPRESS_FX2, .firmware = "dvb-usb-wt220u-zl0353-01.fw", - .power_ctrl = dtt200u_power_ctrl, + .num_adapters = 1, + .adapter = { + { + .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_NEED_PID_FILTERING, + .pid_filter_count = 15, + .streaming_ctrl = dtt200u_streaming_ctrl, .pid_filter = dtt200u_pid_filter, .frontend_attach = dtt200u_frontend_attach, - - .rc_interval = 300, - .rc_key_map = dtt200u_rc_keys, - .rc_key_map_size = ARRAY_SIZE(dtt200u_rc_keys), - .rc_query = dtt200u_rc_query, - - .generic_bulk_ctrl_endpoint = 0x01, - /* parameter for the MPEG2-data transfer */ - .urb = { - .type = DVB_USB_BULK, + .stream = { + .type = USB_BULK, .count = 7, .endpoint = 0x02, .u = { @@ -276,6 +282,16 @@ static struct dvb_usb_properties wt220u_zl0353_properties = { } } }, + } + }, + .power_ctrl = dtt200u_power_ctrl, + + .rc_interval = 300, + .rc_key_map = dtt200u_rc_keys, + .rc_key_map_size = ARRAY_SIZE(dtt200u_rc_keys), + .rc_query = dtt200u_rc_query, + + .generic_bulk_ctrl_endpoint = 0x01, .num_device_descs = 1, .devices = { diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-common.h b/drivers/media/dvb/dvb-usb/dvb-usb-common.h index a3460bf2d9fa..35ab68f6dcf6 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-common.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-common.h @@ -14,31 +14,36 @@ extern int dvb_usb_debug; extern int dvb_usb_disable_rc_polling; -#define deb_info(args...) dprintk(dvb_usb_debug,0x01,args) -#define deb_xfer(args...) dprintk(dvb_usb_debug,0x02,args) -#define deb_pll(args...) dprintk(dvb_usb_debug,0x04,args) -#define deb_ts(args...) dprintk(dvb_usb_debug,0x08,args) -#define deb_err(args...) dprintk(dvb_usb_debug,0x10,args) -#define deb_rc(args...) dprintk(dvb_usb_debug,0x20,args) -#define deb_fw(args...) dprintk(dvb_usb_debug,0x40,args) -#define deb_mem(args...) dprintk(dvb_usb_debug,0x80,args) +#define deb_info(args...) dprintk(dvb_usb_debug,0x001,args) +#define deb_xfer(args...) dprintk(dvb_usb_debug,0x002,args) +#define deb_pll(args...) dprintk(dvb_usb_debug,0x004,args) +#define deb_ts(args...) dprintk(dvb_usb_debug,0x008,args) +#define deb_err(args...) dprintk(dvb_usb_debug,0x010,args) +#define deb_rc(args...) dprintk(dvb_usb_debug,0x020,args) +#define deb_fw(args...) dprintk(dvb_usb_debug,0x040,args) +#define deb_mem(args...) dprintk(dvb_usb_debug,0x080,args) +#define deb_uxfer(args...) dprintk(dvb_usb_debug,0x100,args) /* commonly used methods */ -extern int dvb_usb_download_firmware(struct usb_device *, struct dvb_usb_properties *); +extern int dvb_usb_download_firmware(struct usb_device *, struct dvb_usb_device_properties *); -extern int dvb_usb_urb_submit(struct dvb_usb_device *); -extern int dvb_usb_urb_kill(struct dvb_usb_device *); -extern int dvb_usb_urb_init(struct dvb_usb_device *); -extern int dvb_usb_urb_exit(struct dvb_usb_device *); +extern int dvb_usb_device_power_ctrl(struct dvb_usb_device *d, int onoff); + +extern int usb_urb_init(struct usb_data_stream *stream, struct usb_data_stream_properties *props); +extern int usb_urb_exit(struct usb_data_stream *stream); +extern int usb_urb_submit(struct usb_data_stream *stream); +extern int usb_urb_kill(struct usb_data_stream *stream); + +extern int dvb_usb_adapter_stream_init(struct dvb_usb_adapter *adap); +extern int dvb_usb_adapter_stream_exit(struct dvb_usb_adapter *adap); extern int dvb_usb_i2c_init(struct dvb_usb_device *); extern int dvb_usb_i2c_exit(struct dvb_usb_device *); -extern int dvb_usb_dvb_init(struct dvb_usb_device *); -extern int dvb_usb_dvb_exit(struct dvb_usb_device *); - -extern int dvb_usb_fe_init(struct dvb_usb_device *); -extern int dvb_usb_fe_exit(struct dvb_usb_device *); +extern int dvb_usb_adapter_dvb_init(struct dvb_usb_adapter *adap); +extern int dvb_usb_adapter_dvb_exit(struct dvb_usb_adapter *adap); +extern int dvb_usb_adapter_frontend_init(struct dvb_usb_adapter *adap); +extern int dvb_usb_adapter_frontend_exit(struct dvb_usb_adapter *adap); extern int dvb_usb_remote_init(struct dvb_usb_device *); extern int dvb_usb_remote_exit(struct dvb_usb_device *); diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c b/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c index fe6208ada903..4561a672da92 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c +++ b/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c @@ -1,6 +1,6 @@ /* dvb-usb-dvb.c is part of the DVB USB library. * - * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) + * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de) * see dvb-usb-init.c for copyright information. * * This file contains functions for initializing and handling the @@ -8,55 +8,55 @@ */ #include "dvb-usb-common.h" +/* does the complete input transfer handling */ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff) { - struct dvb_usb_device *d = dvbdmxfeed->demux->priv; + struct dvb_usb_adapter *adap = dvbdmxfeed->demux->priv; int newfeedcount,ret; - if (d == NULL) + if (adap == NULL) return -ENODEV; - newfeedcount = d->feedcount + (onoff ? 1 : -1); + newfeedcount = adap->feedcount + (onoff ? 1 : -1); - /* - * stop feed before setting a new pid if there will be no pid anymore - */ + /* stop feed before setting a new pid if there will be no pid anymore */ if (newfeedcount == 0) { deb_ts("stop feeding\n"); - dvb_usb_urb_kill(d); + usb_urb_kill(&adap->stream); - if (d->props.streaming_ctrl != NULL) - if ((ret = d->props.streaming_ctrl(d,0))) + if (adap->props.streaming_ctrl != NULL) + if ((ret = adap->props.streaming_ctrl(adap,0))) err("error while stopping stream."); - } - d->feedcount = newfeedcount; + adap->feedcount = newfeedcount; /* activate the pid on the device specific pid_filter */ - deb_ts("setting pid: %5d %04x at index %d '%s'\n",dvbdmxfeed->pid,dvbdmxfeed->pid,dvbdmxfeed->index,onoff ? "on" : "off"); - if (d->props.caps & DVB_USB_HAS_PID_FILTER && - d->pid_filtering && - d->props.pid_filter != NULL) - d->props.pid_filter(d,dvbdmxfeed->index,dvbdmxfeed->pid,onoff); + deb_ts("setting pid (%s): %5d %04x at index %d '%s'\n",adap->pid_filtering ? + "yes" : "no", dvbdmxfeed->pid,dvbdmxfeed->pid,dvbdmxfeed->index,onoff ? + "on" : "off"); + if (adap->props.caps & DVB_USB_ADAP_HAS_PID_FILTER && + adap->pid_filtering && + adap->props.pid_filter != NULL) + adap->props.pid_filter(adap, dvbdmxfeed->index, dvbdmxfeed->pid,onoff); /* start the feed if this was the first feed and there is still a feed * for reception. */ - if (d->feedcount == onoff && d->feedcount > 0) { + if (adap->feedcount == onoff && adap->feedcount > 0) { deb_ts("submitting all URBs\n"); - dvb_usb_urb_submit(d); + usb_urb_submit(&adap->stream); deb_ts("controlling pid parser\n"); - if (d->props.caps & DVB_USB_HAS_PID_FILTER && - d->props.caps & DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF && - d->props.pid_filter_ctrl != NULL) - if (d->props.pid_filter_ctrl(d,d->pid_filtering) < 0) + if (adap->props.caps & DVB_USB_ADAP_HAS_PID_FILTER && + adap->props.caps & DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF && + adap->props.pid_filter_ctrl != NULL) + if (adap->props.pid_filter_ctrl(adap,adap->pid_filtering) < 0) err("could not handle pid_parser"); deb_ts("start feeding\n"); - if (d->props.streaming_ctrl != NULL) - if (d->props.streaming_ctrl(d,1)) { + if (adap->props.streaming_ctrl != NULL) + if (adap->props.streaming_ctrl(adap,1)) { err("error while enabling fifo."); return -ENODEV; } @@ -77,134 +77,130 @@ static int dvb_usb_stop_feed(struct dvb_demux_feed *dvbdmxfeed) return dvb_usb_ctrl_feed(dvbdmxfeed,0); } -int dvb_usb_dvb_init(struct dvb_usb_device *d) +int dvb_usb_adapter_dvb_init(struct dvb_usb_adapter *adap) { int ret; - if ((ret = dvb_register_adapter(&d->dvb_adap, d->desc->name, - d->owner, &d->udev->dev)) < 0) { + if ((ret = dvb_register_adapter(&adap->dvb_adap, adap->dev->desc->name, + adap->dev->owner, &adap->dev->udev->dev)) < 0) { deb_info("dvb_register_adapter failed: error %d", ret); goto err; } - d->dvb_adap.priv = d; - - if (d->props.read_mac_address) { - if (d->props.read_mac_address(d,d->dvb_adap.proposed_mac) == 0) - info("MAC address: %02x:%02x:%02x:%02x:%02x:%02x",d->dvb_adap.proposed_mac[0], - d->dvb_adap.proposed_mac[1],d->dvb_adap.proposed_mac[2], - d->dvb_adap.proposed_mac[3],d->dvb_adap.proposed_mac[4], - d->dvb_adap.proposed_mac[5]); + adap->dvb_adap.priv = adap; + + if (adap->dev->props.read_mac_address) { + if (adap->dev->props.read_mac_address(adap->dev,adap->dvb_adap.proposed_mac) == 0) + info("MAC address: %02x:%02x:%02x:%02x:%02x:%02x",adap->dvb_adap.proposed_mac[0], + adap->dvb_adap.proposed_mac[1], adap->dvb_adap.proposed_mac[2], + adap->dvb_adap.proposed_mac[3], adap->dvb_adap.proposed_mac[4], + adap->dvb_adap.proposed_mac[5]); else err("MAC address reading failed."); } - d->demux.dmx.capabilities = DMX_TS_FILTERING | DMX_SECTION_FILTERING; - d->demux.priv = d; + adap->demux.dmx.capabilities = DMX_TS_FILTERING | DMX_SECTION_FILTERING; + adap->demux.priv = adap; - d->demux.feednum = d->demux.filternum = d->max_feed_count; - d->demux.start_feed = dvb_usb_start_feed; - d->demux.stop_feed = dvb_usb_stop_feed; - d->demux.write_to_decoder = NULL; - if ((ret = dvb_dmx_init(&d->demux)) < 0) { + adap->demux.feednum = adap->demux.filternum = adap->max_feed_count; + adap->demux.start_feed = dvb_usb_start_feed; + adap->demux.stop_feed = dvb_usb_stop_feed; + adap->demux.write_to_decoder = NULL; + if ((ret = dvb_dmx_init(&adap->demux)) < 0) { err("dvb_dmx_init failed: error %d",ret); goto err_dmx; } - d->dmxdev.filternum = d->demux.filternum; - d->dmxdev.demux = &d->demux.dmx; - d->dmxdev.capabilities = 0; - if ((ret = dvb_dmxdev_init(&d->dmxdev, &d->dvb_adap)) < 0) { + adap->dmxdev.filternum = adap->demux.filternum; + adap->dmxdev.demux = &adap->demux.dmx; + adap->dmxdev.capabilities = 0; + if ((ret = dvb_dmxdev_init(&adap->dmxdev, &adap->dvb_adap)) < 0) { err("dvb_dmxdev_init failed: error %d",ret); goto err_dmx_dev; } - dvb_net_init(&d->dvb_adap, &d->dvb_net, &d->demux.dmx); + dvb_net_init(&adap->dvb_adap, &adap->dvb_net, &adap->demux.dmx); - d->state |= DVB_USB_STATE_DVB; + adap->state |= DVB_USB_ADAP_STATE_DVB; return 0; err_dmx_dev: - dvb_dmx_release(&d->demux); + dvb_dmx_release(&adap->demux); err_dmx: - dvb_unregister_adapter(&d->dvb_adap); + dvb_unregister_adapter(&adap->dvb_adap); err: return ret; } -int dvb_usb_dvb_exit(struct dvb_usb_device *d) +int dvb_usb_adapter_dvb_exit(struct dvb_usb_adapter *adap) { - if (d->state & DVB_USB_STATE_DVB) { + if (adap->state & DVB_USB_ADAP_STATE_DVB) { deb_info("unregistering DVB part\n"); - dvb_net_release(&d->dvb_net); - d->demux.dmx.close(&d->demux.dmx); - dvb_dmxdev_release(&d->dmxdev); - dvb_dmx_release(&d->demux); - dvb_unregister_adapter(&d->dvb_adap); - d->state &= ~DVB_USB_STATE_DVB; + dvb_net_release(&adap->dvb_net); + adap->demux.dmx.close(&adap->demux.dmx); + dvb_dmxdev_release(&adap->dmxdev); + dvb_dmx_release(&adap->demux); + dvb_unregister_adapter(&adap->dvb_adap); + adap->state &= ~DVB_USB_ADAP_STATE_DVB; } return 0; } static int dvb_usb_fe_wakeup(struct dvb_frontend *fe) { - struct dvb_usb_device *d = fe->dvb->priv; + struct dvb_usb_adapter *adap = fe->dvb->priv; - if (d->props.power_ctrl) - d->props.power_ctrl(d,1); + dvb_usb_device_power_ctrl(adap->dev, 1); - if (d->fe_init) - d->fe_init(fe); + if (adap->fe_init) + adap->fe_init(fe); return 0; } static int dvb_usb_fe_sleep(struct dvb_frontend *fe) { - struct dvb_usb_device *d = fe->dvb->priv; + struct dvb_usb_adapter *adap = fe->dvb->priv; - if (d->fe_sleep) - d->fe_sleep(fe); + if (adap->fe_sleep) + adap->fe_sleep(fe); - if (d->props.power_ctrl) - d->props.power_ctrl(d,0); - - return 0; + return dvb_usb_device_power_ctrl(adap->dev, 0); } -int dvb_usb_fe_init(struct dvb_usb_device* d) +int dvb_usb_adapter_frontend_init(struct dvb_usb_adapter *adap) { - if (d->props.frontend_attach == NULL) { - err("strange: '%s' doesn't want to attach a frontend.",d->desc->name); + if (adap->props.frontend_attach == NULL) { + err("strange: '%s' #%d doesn't want to attach a frontend.",adap->dev->desc->name, adap->id); return 0; } /* re-assign sleep and wakeup functions */ - if (d->props.frontend_attach(d) == 0 && d->fe != NULL) { - d->fe_init = d->fe->ops.init; d->fe->ops.init = dvb_usb_fe_wakeup; - d->fe_sleep = d->fe->ops.sleep; d->fe->ops.sleep = dvb_usb_fe_sleep; + if (adap->props.frontend_attach(adap) == 0 && adap->fe != NULL) { + adap->fe_init = adap->fe->ops.init; adap->fe->ops.init = dvb_usb_fe_wakeup; + adap->fe_sleep = adap->fe->ops.sleep; adap->fe->ops.sleep = dvb_usb_fe_sleep; - if (dvb_register_frontend(&d->dvb_adap, d->fe)) { + if (dvb_register_frontend(&adap->dvb_adap, adap->fe)) { err("Frontend registration failed."); - dvb_frontend_detach(d->fe); - d->fe = NULL; + dvb_frontend_detach(adap->fe); + adap->fe = NULL; return -ENODEV; } /* only attach the tuner if the demod is there */ - if (d->props.tuner_attach != NULL) - d->props.tuner_attach(d); + if (adap->props.tuner_attach != NULL) + adap->props.tuner_attach(adap); } else - err("no frontend was attached by '%s'",d->desc->name); + err("no frontend was attached by '%s'",adap->dev->desc->name); return 0; } -int dvb_usb_fe_exit(struct dvb_usb_device *d) +int dvb_usb_adapter_frontend_exit(struct dvb_usb_adapter *adap) { - if (d->fe != NULL) { - dvb_unregister_frontend(d->fe); - dvb_frontend_detach(d->fe); + if (adap->fe != NULL) { + dvb_unregister_frontend(adap->fe); + dvb_frontend_detach(adap->fe); } return 0; } diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-firmware.c b/drivers/media/dvb/dvb-usb/dvb-usb-firmware.c index 9222b0a81f74..122ff8157d18 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 @@ /* dvb-usb-firmware.c is part of the DVB USB library. * - * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) + * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de) * see dvb-usb-init.c for copyright information. * * 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 } EXPORT_SYMBOL(usb_cypress_load_firmware); -int dvb_usb_download_firmware(struct usb_device *udev, struct dvb_usb_properties *props) +int dvb_usb_download_firmware(struct usb_device *udev, struct dvb_usb_device_properties *props) { int ret; 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 6b611a725093..55ba020386c9 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c +++ b/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c @@ -1,6 +1,6 @@ /* dvb-usb-i2c.c is part of the DVB USB library. * - * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) + * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de) * see dvb-usb-init.c for copyright information. * * This file contains functions for (de-)initializing an I2C adapter. @@ -48,48 +48,48 @@ int dvb_usb_i2c_exit(struct dvb_usb_device *d) int dvb_usb_tuner_init_i2c(struct dvb_frontend *fe) { - struct dvb_usb_device *d = fe->dvb->priv; - struct i2c_msg msg = { .addr = d->pll_addr, .flags = 0, .buf = d->pll_init, .len = 4 }; + struct dvb_usb_adapter *adap = fe->dvb->priv; + struct i2c_msg msg = { .addr = adap->pll_addr, .flags = 0, .buf = adap->pll_init, .len = 4 }; int ret = 0; /* if pll_desc is not used */ - if (d->pll_desc == NULL) + if (adap->pll_desc == NULL) return 0; - if (d->tuner_pass_ctrl) - d->tuner_pass_ctrl(fe,1,d->pll_addr); + if (adap->tuner_pass_ctrl) + adap->tuner_pass_ctrl(fe, 1, adap->pll_addr); - deb_pll("pll init: %x\n",d->pll_addr); - deb_pll("pll-buf: %x %x %x %x\n",d->pll_init[0],d->pll_init[1], - d->pll_init[2],d->pll_init[3]); + deb_pll("pll init: %x\n",adap->pll_addr); + deb_pll("pll-buf: %x %x %x %x\n",adap->pll_init[0], adap->pll_init[1], + adap->pll_init[2], adap->pll_init[3]); if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 1); - if (i2c_transfer (&d->i2c_adap, &msg, 1) != 1) { + if (i2c_transfer (&adap->dev->i2c_adap, &msg, 1) != 1) { err("tuner i2c write failed for pll_init."); ret = -EREMOTEIO; } msleep(1); - if (d->tuner_pass_ctrl) - d->tuner_pass_ctrl(fe,0,d->pll_addr); + if (adap->tuner_pass_ctrl) + adap->tuner_pass_ctrl(fe,0,adap->pll_addr); return ret; } EXPORT_SYMBOL(dvb_usb_tuner_init_i2c); int dvb_usb_tuner_calc_regs(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep, u8 *b, int buf_len) { - struct dvb_usb_device *d = fe->dvb->priv; + struct dvb_usb_adapter *adap = fe->dvb->priv; if (buf_len != 5) return -EINVAL; - if (d->pll_desc == NULL) + if (adap->pll_desc == NULL) return 0; - deb_pll("pll addr: %x, freq: %d %p\n",d->pll_addr,fep->frequency,d->pll_desc); + deb_pll("pll addr: %x, freq: %d %p\n",adap->pll_addr, fep->frequency, adap->pll_desc); - b[0] = d->pll_addr; - dvb_pll_configure(d->pll_desc,&b[1],fep->frequency,fep->u.ofdm.bandwidth); + b[0] = adap->pll_addr; + dvb_pll_configure(adap->pll_desc, &b[1], fep->frequency, fep->u.ofdm.bandwidth); deb_pll("pll-buf: %x %x %x %x %x\n",b[0],b[1],b[2],b[3],b[4]); @@ -99,26 +99,27 @@ EXPORT_SYMBOL(dvb_usb_tuner_calc_regs); int dvb_usb_tuner_set_params_i2c(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep) { - struct dvb_usb_device *d = fe->dvb->priv; + struct dvb_usb_adapter *adap = fe->dvb->priv; int ret = 0; u8 b[5]; - struct i2c_msg msg = { .addr = d->pll_addr, .flags = 0, .buf = &b[1], .len = 4 }; + struct i2c_msg msg = { .addr = adap->pll_addr, .flags = 0, .buf = &b[1], .len = 4 }; dvb_usb_tuner_calc_regs(fe,fep,b,5); - if (d->tuner_pass_ctrl) - d->tuner_pass_ctrl(fe,1,d->pll_addr); + if (adap->tuner_pass_ctrl) + adap->tuner_pass_ctrl(fe, 1, adap->pll_addr); if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 1); - if (i2c_transfer (&d->i2c_adap, &msg, 1) != 1) { + + if (i2c_transfer(&adap->dev->i2c_adap, &msg, 1) != 1) { err("tuner i2c write failed for pll_set."); ret = -EREMOTEIO; } msleep(1); - if (d->tuner_pass_ctrl) - d->tuner_pass_ctrl(fe,0,d->pll_addr); + if (adap->tuner_pass_ctrl) + adap->tuner_pass_ctrl(fe, 0, adap->pll_addr); return ret; } diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-init.c b/drivers/media/dvb/dvb-usb/dvb-usb-init.c index a1705ecb9a54..6babdcd4c1ab 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 @@ * * dvb-usb-init.c * - * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) + * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -16,21 +16,105 @@ /* debug */ int dvb_usb_debug; module_param_named(debug,dvb_usb_debug, int, 0644); -MODULE_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); +MODULE_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); int dvb_usb_disable_rc_polling; module_param_named(disable_rc_polling, dvb_usb_disable_rc_polling, int, 0644); MODULE_PARM_DESC(disable_rc_polling, "disable remote control polling (default: 0)."); +static int dvb_usb_force_pid_filter_usage; +module_param_named(force_pid_filter_usage, dvb_usb_force_pid_filter_usage, int, 0444); +MODULE_PARM_DESC(disable_rc_polling, "force all dvb-usb-devices to use a PID filter, if any (default: 0)."); + +static int dvb_usb_adapter_init(struct dvb_usb_device *d) +{ + struct dvb_usb_adapter *adap; + int ret,n; + + for (n = 0; n < d->props.num_adapters; n++) { + adap = &d->adapter[n]; + adap->dev = d; + adap->id = n; + + memcpy(&adap->props, &d->props.adapter[n], sizeof(struct dvb_usb_adapter_properties)); + +/* speed - when running at FULL speed we need a HW PID filter */ + if (d->udev->speed == USB_SPEED_FULL && !(adap->props.caps & DVB_USB_ADAP_HAS_PID_FILTER)) { + err("This USB2.0 device cannot be run on a USB1.1 port. (it lacks a hardware PID filter)"); + return -ENODEV; + } + + if ((d->udev->speed == USB_SPEED_FULL && adap->props.caps & DVB_USB_ADAP_HAS_PID_FILTER) || + (adap->props.caps & DVB_USB_ADAP_NEED_PID_FILTERING)) { + info("will use the device's hardware PID filter (table count: %d).",adap->props.pid_filter_count); + adap->pid_filtering = 1; + adap->max_feed_count = adap->props.pid_filter_count; + } else { + info("will pass the complete MPEG2 transport stream to the software demuxer."); + adap->pid_filtering = 0; + adap->max_feed_count = 255; + } + + if (!adap->pid_filtering && + dvb_usb_force_pid_filter_usage && + adap->props.caps & DVB_USB_ADAP_HAS_PID_FILTER) { + info("pid filter enabled by module option."); + adap->pid_filtering = 1; + adap->max_feed_count = adap->props.pid_filter_count; + } + + if (adap->props.size_of_priv > 0) { + adap->priv = kzalloc(adap->props.size_of_priv,GFP_KERNEL); + if (adap->priv == NULL) { + err("no memory for priv for adapter %d.",n); + return -ENOMEM; + } + } + + if ((ret = dvb_usb_adapter_stream_init(adap)) || + (ret = dvb_usb_adapter_dvb_init(adap)) || + (ret = dvb_usb_adapter_frontend_init(adap))) { + return ret; + } + + d->num_adapters_initialized++; + d->state |= DVB_USB_STATE_DVB; + } + + /* + * when reloading the driver w/o replugging the device + * sometimes a timeout occures, this helps + */ + if (d->props.generic_bulk_ctrl_endpoint != 0) { + usb_clear_halt(d->udev,usb_sndbulkpipe(d->udev,d->props.generic_bulk_ctrl_endpoint)); + usb_clear_halt(d->udev,usb_rcvbulkpipe(d->udev,d->props.generic_bulk_ctrl_endpoint)); + } + + return 0; +} + +static int dvb_usb_adapter_exit(struct dvb_usb_device *d) +{ + int n; + for (n = 0; n < d->num_adapters_initialized; n++) { + dvb_usb_adapter_frontend_exit(&d->adapter[n]); + dvb_usb_adapter_dvb_exit(&d->adapter[n]); + dvb_usb_adapter_stream_exit(&d->adapter[n]); + kfree(d->adapter[n].priv); + } + d->num_adapters_initialized = 0; + d->state &= ~DVB_USB_STATE_DVB; + return 0; +} + + /* general initialization functions */ static int dvb_usb_exit(struct dvb_usb_device *d) { deb_info("state before exiting everything: %x\n",d->state); dvb_usb_remote_exit(d); - dvb_usb_fe_exit(d); + dvb_usb_adapter_exit(d); dvb_usb_i2c_exit(d); - dvb_usb_dvb_exit(d); - dvb_usb_urb_exit(d); deb_info("state should be zero now: %x\n",d->state); d->state = DVB_USB_STATE_INIT; kfree(d->priv); @@ -47,32 +131,19 @@ static int dvb_usb_init(struct dvb_usb_device *d) d->state = DVB_USB_STATE_INIT; -/* check the capabilities and set appropriate variables */ - -/* speed - when running at FULL speed we need a HW PID filter */ - if (d->udev->speed == USB_SPEED_FULL && !(d->props.caps & DVB_USB_HAS_PID_FILTER)) { - err("This USB2.0 device cannot be run on a USB1.1 port. (it lacks a hardware PID filter)"); - return -ENODEV; + if (d->props.size_of_priv > 0) { + d->priv = kzalloc(d->props.size_of_priv,GFP_KERNEL); + if (d->priv == NULL) { + err("no memory for priv in 'struct dvb_usb_device'"); + return -ENOMEM; } - - if ((d->udev->speed == USB_SPEED_FULL && d->props.caps & DVB_USB_HAS_PID_FILTER) || - (d->props.caps & DVB_USB_NEED_PID_FILTERING)) { - info("will use the device's hardware PID filter (table count: %d).",d->props.pid_filter_count); - d->pid_filtering = 1; - d->max_feed_count = d->props.pid_filter_count; - } else { - info("will pass the complete MPEG2 transport stream to the software demuxer."); - d->pid_filtering = 0; - d->max_feed_count = 255; } - if (d->props.power_ctrl) - d->props.power_ctrl(d,1); +/* check the capabilities and set appropriate variables */ + dvb_usb_device_power_ctrl(d, 1); - if ((ret = dvb_usb_urb_init(d)) || - (ret = dvb_usb_dvb_init(d)) || - (ret = dvb_usb_i2c_init(d)) || - (ret = dvb_usb_fe_init(d))) { + if ((ret = dvb_usb_i2c_init(d)) || + (ret = dvb_usb_adapter_init(d))) { dvb_usb_exit(d); return ret; } @@ -80,14 +151,13 @@ static int dvb_usb_init(struct dvb_usb_device *d) if ((ret = dvb_usb_remote_init(d))) err("could not initialize remote control."); - if (d->props.power_ctrl) - d->props.power_ctrl(d,0); + dvb_usb_device_power_ctrl(d, 0); return 0; } /* determine the name and the state of the just found USB device */ -static struct dvb_usb_device_description * dvb_usb_find_device(struct usb_device *udev,struct dvb_usb_properties *props, int *cold) +static struct dvb_usb_device_description * dvb_usb_find_device(struct usb_device *udev,struct dvb_usb_device_properties *props, int *cold) { int i,j; struct dvb_usb_device_description *desc = NULL; @@ -125,11 +195,20 @@ static struct dvb_usb_device_description * dvb_usb_find_device(struct usb_device return desc; } +int dvb_usb_device_power_ctrl(struct dvb_usb_device *d, int onoff) +{ + if (d->powered == !onoff) { + d->powered = onoff; + if (d->props.power_ctrl) + return d->props.power_ctrl(d, onoff); + } + return 0; +} + /* * USB */ - -int dvb_usb_device_init(struct usb_interface *intf, struct dvb_usb_properties +int dvb_usb_device_init(struct usb_interface *intf, struct dvb_usb_device_properties *props, struct module *owner,struct dvb_usb_device **du) { 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 } d->udev = udev; - memcpy(&d->props,props,sizeof(struct dvb_usb_properties)); + memcpy(&d->props,props,sizeof(struct dvb_usb_device_properties)); d->desc = desc; d->owner = owner; - if (d->props.size_of_priv > 0) { - d->priv = kzalloc(d->props.size_of_priv,GFP_KERNEL); - if (d->priv == NULL) { - err("no memory for priv in 'struct dvb_usb_device'"); - kfree(d); - return -ENOMEM; - } - } - usb_set_intfdata(intf, d); if (du != NULL) @@ -204,7 +274,7 @@ void dvb_usb_device_exit(struct usb_interface *intf) } EXPORT_SYMBOL(dvb_usb_device_exit); -MODULE_VERSION("0.3"); +MODULE_VERSION("1.0"); MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>"); MODULE_DESCRIPTION("A library module containing commonly used USB and DVB function USB DVB devices"); MODULE_LICENSE("GPL"); diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c index 380b2a45ee4c..0a3a0b6c2350 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c +++ b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c @@ -1,6 +1,6 @@ /* dvb-usb-remote.c is part of the DVB USB library. * - * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) + * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de) * see dvb-usb-init.c for copyright information. * * This file contains functions for initializing the the input-device and for handling remote-control-queries. diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-urb.c b/drivers/media/dvb/dvb-usb/dvb-usb-urb.c index 88b283731bb8..0aed7fd60623 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 @@ /* dvb-usb-urb.c is part of the DVB USB library. * - * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) + * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de) * see dvb-usb-init.c for copyright information. * - * This file contains functions for initializing and handling the + * This file keeps functions for initializing and handling the * USB and URB stuff. */ #include "dvb-usb-common.h" @@ -64,260 +64,22 @@ int dvb_usb_generic_write(struct dvb_usb_device *d, u8 *buf, u16 len) } EXPORT_SYMBOL(dvb_usb_generic_write); - -/* URB stuff for streaming */ -static void dvb_usb_urb_complete(struct urb *urb, struct pt_regs *ptregs) -{ - struct dvb_usb_device *d = urb->context; - int ptype = usb_pipetype(urb->pipe); - int i; - u8 *b; - - deb_ts("'%s' urb completed. feedcount: %d, status: %d, length: %d/%d, pack_num: %d, errors: %d\n", - ptype == PIPE_ISOCHRONOUS ? "isoc" : "bulk", d->feedcount, - urb->status,urb->actual_length,urb->transfer_buffer_length, - urb->number_of_packets,urb->error_count); - - switch (urb->status) { - case 0: /* success */ - break; - case -ECONNRESET: /* kill */ - case -ENOENT: - case -ESHUTDOWN: - return; - default: /* error */ - deb_ts("urb completition error %d.", urb->status); - break; - } - - if (d->feedcount > 0) { - if (d->state & DVB_USB_STATE_DVB) { - switch (ptype) { - case PIPE_ISOCHRONOUS: - b = (u8 *) urb->transfer_buffer; - for (i = 0; i < urb->number_of_packets; i++) { - if (urb->iso_frame_desc[i].status != 0) - deb_ts("iso frame descriptor has an error: %d\n",urb->iso_frame_desc[i].status); - else if (urb->iso_frame_desc[i].actual_length > 0) { - dvb_dmx_swfilter(&d->demux,b + urb->iso_frame_desc[i].offset, - urb->iso_frame_desc[i].actual_length); - } - urb->iso_frame_desc[i].status = 0; - urb->iso_frame_desc[i].actual_length = 0; - } - debug_dump(b,20,deb_ts); - break; - case PIPE_BULK: - if (urb->actual_length > 0) - dvb_dmx_swfilter(&d->demux, (u8 *) urb->transfer_buffer,urb->actual_length); - break; - default: - err("unkown endpoint type in completition handler."); - return; - } - } - } - - usb_submit_urb(urb,GFP_ATOMIC); -} - -int dvb_usb_urb_kill(struct dvb_usb_device *d) -{ - int i; - for (i = 0; i < d->urbs_submitted; i++) { - deb_ts("killing URB no. %d.\n",i); - - /* stop the URB */ - usb_kill_urb(d->urb_list[i]); - } - d->urbs_submitted = 0; - return 0; -} - -int dvb_usb_urb_submit(struct dvb_usb_device *d) -{ - int i,ret; - for (i = 0; i < d->urbs_initialized; i++) { - deb_ts("submitting URB no. %d\n",i); - if ((ret = usb_submit_urb(d->urb_list[i],GFP_ATOMIC))) { - err("could not submit URB no. %d - get them all back",i); - dvb_usb_urb_kill(d); - return ret; - } - d->urbs_submitted++; - } - return 0; -} - -static int dvb_usb_free_stream_buffers(struct dvb_usb_device *d) -{ - if (d->state & DVB_USB_STATE_URB_BUF) { - while (d->buf_num) { - d->buf_num--; - deb_mem("freeing buffer %d\n",d->buf_num); - usb_buffer_free(d->udev, d->buf_size, - d->buf_list[d->buf_num], d->dma_addr[d->buf_num]); - } - kfree(d->buf_list); - kfree(d->dma_addr); - } - - d->state &= ~DVB_USB_STATE_URB_BUF; - - return 0; -} - -static int dvb_usb_allocate_stream_buffers(struct dvb_usb_device *d, int num, unsigned long size) -{ - d->buf_num = 0; - d->buf_size = size; - - deb_mem("all in all I will use %lu bytes for streaming\n",num*size); - - if ((d->buf_list = kcalloc(num, sizeof(u8 *), GFP_ATOMIC)) == NULL) - return -ENOMEM; - - if ((d->dma_addr = kcalloc(num, sizeof(dma_addr_t), GFP_ATOMIC)) == NULL) { - kfree(d->buf_list); - return -ENOMEM; - } - - d->state |= DVB_USB_STATE_URB_BUF; - - for (d->buf_num = 0; d->buf_num < num; d->buf_num++) { - deb_mem("allocating buffer %d\n",d->buf_num); - if (( d->buf_list[d->buf_num] = - usb_buffer_alloc(d->udev, size, SLAB_ATOMIC, - &d->dma_addr[d->buf_num]) ) == NULL) { - deb_mem("not enough memory for urb-buffer allocation.\n"); - dvb_usb_free_stream_buffers(d); - return -ENOMEM; - } - deb_mem("buffer %d: %p (dma: %llu)\n", - d->buf_num, d->buf_list[d->buf_num], - (unsigned long long)d->dma_addr[d->buf_num]); - memset(d->buf_list[d->buf_num],0,size); - } - deb_mem("allocation successful\n"); - - return 0; -} - -static int dvb_usb_bulk_urb_init(struct dvb_usb_device *d) +static void dvb_usb_data_complete(struct usb_data_stream *stream, u8 *buffer, size_t length) { - int i; - - if ((i = dvb_usb_allocate_stream_buffers(d,d->props.urb.count, - d->props.urb.u.bulk.buffersize)) < 0) - return i; - - /* allocate the URBs */ - for (i = 0; i < d->props.urb.count; i++) { - if ((d->urb_list[i] = usb_alloc_urb(0,GFP_ATOMIC)) == NULL) - return -ENOMEM; - - usb_fill_bulk_urb( d->urb_list[i], d->udev, - usb_rcvbulkpipe(d->udev,d->props.urb.endpoint), - d->buf_list[i], - d->props.urb.u.bulk.buffersize, - dvb_usb_urb_complete, d); - - d->urb_list[i]->transfer_flags = 0; - d->urbs_initialized++; - } - return 0; + struct dvb_usb_adapter *adap = stream->user_priv; + if (adap->feedcount > 0 && adap->state & DVB_USB_ADAP_STATE_DVB) + dvb_dmx_swfilter(&adap->demux, buffer, length); } -static int dvb_usb_isoc_urb_init(struct dvb_usb_device *d) +int dvb_usb_adapter_stream_init(struct dvb_usb_adapter *adap) { - int i,j; - - if ((i = dvb_usb_allocate_stream_buffers(d,d->props.urb.count, - d->props.urb.u.isoc.framesize*d->props.urb.u.isoc.framesperurb)) < 0) - return i; - - /* allocate the URBs */ - for (i = 0; i < d->props.urb.count; i++) { - struct urb *urb; - int frame_offset = 0; - if ((d->urb_list[i] = - usb_alloc_urb(d->props.urb.u.isoc.framesperurb,GFP_ATOMIC)) == NULL) - return -ENOMEM; - - urb = d->urb_list[i]; - - urb->dev = d->udev; - urb->context = d; - urb->complete = dvb_usb_urb_complete; - urb->pipe = usb_rcvisocpipe(d->udev,d->props.urb.endpoint); - urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP; - urb->interval = d->props.urb.u.isoc.interval; - urb->number_of_packets = d->props.urb.u.isoc.framesperurb; - urb->transfer_buffer_length = d->buf_size; - urb->transfer_buffer = d->buf_list[i]; - urb->transfer_dma = d->dma_addr[i]; - - for (j = 0; j < d->props.urb.u.isoc.framesperurb; j++) { - urb->iso_frame_desc[j].offset = frame_offset; - urb->iso_frame_desc[j].length = d->props.urb.u.isoc.framesize; - frame_offset += d->props.urb.u.isoc.framesize; - } - - d->urbs_initialized++; - } - return 0; - -} - -int dvb_usb_urb_init(struct dvb_usb_device *d) -{ - /* - * when reloading the driver w/o replugging the device - * sometimes a timeout occures, this helps - */ - if (d->props.generic_bulk_ctrl_endpoint != 0) { - usb_clear_halt(d->udev,usb_sndbulkpipe(d->udev,d->props.generic_bulk_ctrl_endpoint)); - usb_clear_halt(d->udev,usb_rcvbulkpipe(d->udev,d->props.generic_bulk_ctrl_endpoint)); - } - usb_clear_halt(d->udev,usb_rcvbulkpipe(d->udev,d->props.urb.endpoint)); - - /* allocate the array for the data transfer URBs */ - d->urb_list = kzalloc(d->props.urb.count * sizeof(struct urb *),GFP_KERNEL); - if (d->urb_list == NULL) - return -ENOMEM; - d->state |= DVB_USB_STATE_URB_LIST; - - switch (d->props.urb.type) { - case DVB_USB_BULK: - return dvb_usb_bulk_urb_init(d); - case DVB_USB_ISOC: - return dvb_usb_isoc_urb_init(d); - default: - err("unkown URB-type for data transfer."); - return -EINVAL; - } + adap->stream.udev = adap->dev->udev; + adap->stream.complete = dvb_usb_data_complete; + adap->stream.user_priv = adap; + return usb_urb_init(&adap->stream, &adap->props.stream); } -int dvb_usb_urb_exit(struct dvb_usb_device *d) +int dvb_usb_adapter_stream_exit(struct dvb_usb_adapter *adap) { - int i; - - dvb_usb_urb_kill(d); - - if (d->state & DVB_USB_STATE_URB_LIST) { - for (i = 0; i < d->urbs_initialized; i++) { - if (d->urb_list[i] != NULL) { - deb_mem("freeing URB no. %d.\n",i); - /* free the URBs */ - usb_free_urb(d->urb_list[i]); - } - } - d->urbs_initialized = 0; - /* free the urb array */ - kfree(d->urb_list); - d->state &= ~DVB_USB_STATE_URB_LIST; - } - - dvb_usb_free_stream_buffers(d); - return 0; + return usb_urb_exit(&adap->stream); } diff --git a/drivers/media/dvb/dvb-usb/dvb-usb.h b/drivers/media/dvb/dvb-usb/dvb-usb.h index 97f8ea962438..5546554d3876 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb.h @@ -1,9 +1,11 @@ /* dvb-usb.h is part of the DVB USB library. * - * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) + * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de) * see dvb-usb-init.c for copyright information. * * the headerfile, all dvb-usb-drivers have to include. + * + * TODO: clean-up the structures for unused fields and update the comments */ #ifndef __DVB_USB_H__ #define __DVB_USB_H__ @@ -84,36 +86,83 @@ struct dvb_usb_rc_key { }; struct dvb_usb_device; +struct dvb_usb_adapter; +struct usb_data_stream; /** - * struct dvb_usb_properties - properties of a dvb-usb-device + * Properties of USB streaming - TODO this structure does not belong here actually + * describes the kind of USB transfer used for MPEG2-TS-streaming. + * (BULK or ISOC) + */ +struct usb_data_stream_properties { +#define USB_BULK 1 +#define USB_ISOC 2 + int type; + int count; + int endpoint; + + union { + struct { + int buffersize; /* per URB */ + } bulk; + struct { + int framesperurb; + int framesize; + int interval; + } isoc; + } u; +}; + +/** + * struct dvb_usb_adapter_properties - properties of a dvb-usb-adapter. + * A DVB-USB-Adapter is basically a dvb_adapter which is present on a USB-device. * @caps: capabilities of the DVB USB device. * @pid_filter_count: number of PID filter position in the optional hardware * PID-filter. - * + * @streaming_crtl: called to start and stop the MPEG2-TS streaming of the + * device (not URB submitting/killing). + * @pid_filter_ctrl: called to en/disable the PID filter, if any. + * @pid_filter: called to set/unset a PID for filtering. + * @frontend_attach: called to attach the possible frontends (fill fe-field + * of struct dvb_usb_device). + * @tuner_attach: called to attach the correct tuner and to fill pll_addr, + * pll_desc and pll_init_buf of struct dvb_usb_device). + * @stream: configuration of the USB streaming + */ +struct dvb_usb_adapter_properties { +#define DVB_USB_ADAP_HAS_PID_FILTER 0x01 +#define DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF 0x02 +#define DVB_USB_ADAP_NEED_PID_FILTERING 0x04 + int caps; + int pid_filter_count; + + int (*streaming_ctrl) (struct dvb_usb_adapter *, int); + int (*pid_filter_ctrl) (struct dvb_usb_adapter *, int); + int (*pid_filter) (struct dvb_usb_adapter *, int, u16, int); + + int (*frontend_attach) (struct dvb_usb_adapter *); + int (*tuner_attach) (struct dvb_usb_adapter *); + + struct usb_data_stream_properties stream; + + int size_of_priv; +}; + +/** + * struct dvb_usb_device_properties - properties of a dvb-usb-device * @usb_ctrl: which USB device-side controller is in use. Needed for firmware * download. * @firmware: name of the firmware file. * @download_firmware: called to download the firmware when the usb_ctrl is * DEVICE_SPECIFIC. * @no_reconnect: device doesn't do a reconnect after downloading the firmware, - so do the warm initialization right after it - + * so do the warm initialization right after it + * * @size_of_priv: how many bytes shall be allocated for the private field * of struct dvb_usb_device. * * @power_ctrl: called to enable/disable power of the device. - * @streaming_crtl: called to start and stop the MPEG2-TS streaming of the - * device (not URB submitting/killing). - * @pid_filter_ctrl: called to en/disable the PID filter, if any. - * @pid_filter: called to set/unset a PID for filtering. - * * @read_mac_address: called to read the MAC address of the device. - * - * @frontend_attach: called to attach the possible frontends (fill fe-field - * of struct dvb_usb_device). - * @tuner_attach: called to attach the correct tuner and to fill pll_addr, - * pll_desc and pll_init_buf of struct dvb_usb_device). * @identify_state: called to determine the state (cold or warm), when it * is not distinguishable by the USB IDs. * @@ -130,21 +179,15 @@ struct dvb_usb_device; * is non-zero, one can use dvb_usb_generic_rw and dvb_usb_generic_write- * helper functions. * - * @urb: describes the kind of USB transfer used for MPEG2-TS-streaming. - * (BULK or ISOC) - * * @num_device_descs: number of struct dvb_usb_device_description in @devices * @devices: array of struct dvb_usb_device_description compatibles with these * properties. */ -struct dvb_usb_properties { +#define MAX_NO_OF_ADAPTER_PER_DEVICE 2 +struct dvb_usb_device_properties { -#define DVB_USB_HAS_PID_FILTER 0x01 -#define DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF 0x02 -#define DVB_USB_NEED_PID_FILTERING 0x04 -#define DVB_USB_IS_AN_I2C_ADAPTER 0x08 +#define DVB_USB_IS_AN_I2C_ADAPTER 0x01 int caps; - int pid_filter_count; #define DEVICE_SPECIFIC 0 #define CYPRESS_AN2135 1 @@ -157,16 +200,12 @@ struct dvb_usb_properties { int size_of_priv; - int (*power_ctrl) (struct dvb_usb_device *, int); - int (*streaming_ctrl) (struct dvb_usb_device *, int); - int (*pid_filter_ctrl) (struct dvb_usb_device *, int); - int (*pid_filter) (struct dvb_usb_device *, int, u16, int); + int num_adapters; + struct dvb_usb_adapter_properties adapter[MAX_NO_OF_ADAPTER_PER_DEVICE]; + int (*power_ctrl) (struct dvb_usb_device *, int); int (*read_mac_address) (struct dvb_usb_device *, u8 []); - int (*frontend_attach) (struct dvb_usb_device *); - int (*tuner_attach) (struct dvb_usb_device *); - - int (*identify_state) (struct usb_device *, struct dvb_usb_properties *, + int (*identify_state) (struct usb_device *, struct dvb_usb_device_properties *, struct dvb_usb_device_description **, int *); /* remote control properties */ @@ -182,40 +221,12 @@ struct dvb_usb_properties { int generic_bulk_ctrl_endpoint; - struct { -#define DVB_USB_BULK 1 -#define DVB_USB_ISOC 2 - int type; - int count; - int endpoint; - - union { - struct { - int buffersize; /* per URB */ - } bulk; - struct { - int framesperurb; - int framesize; - int interval; - } isoc; - } u; - } urb; - int num_device_descs; struct dvb_usb_device_description devices[9]; }; - /** - * struct dvb_usb_device - object of a DVB USB device - * @props: copy of the struct dvb_usb_properties this device belongs to. - * @desc: pointer to the device's struct dvb_usb_device_description. - * @state: initialization and runtime state of the device. - * - * @udev: pointer to the device's struct usb_device. - * @urb_list: array of dynamically allocated struct urb for the MPEG2-TS- - * streaming. - * + * struct usb_data_stream - generic object of an USB stream * @buf_num: number of buffer allocated. * @buf_size: size of each buffer in buf_list. * @buf_list: array containing all allocate buffers for streaming. @@ -224,19 +235,44 @@ struct dvb_usb_properties { * @urbs_initialized: number of URBs initialized. * @urbs_submitted: number of URBs submitted. * + * TODO put this in the correct place. + */ +#define MAX_NO_URBS_FOR_DATA_STREAM 10 +struct usb_data_stream { + struct usb_device *udev; + struct usb_data_stream_properties props; + +#define USB_STATE_INIT 0x00 +#define USB_STATE_URB_BUF 0x01 + int state; + + void (*complete) (struct usb_data_stream *, u8 *, size_t); + + struct urb *urb_list[MAX_NO_URBS_FOR_DATA_STREAM]; + + int buf_num; + unsigned long buf_size; + u8 *buf_list[MAX_NO_URBS_FOR_DATA_STREAM]; + dma_addr_t dma_addr[MAX_NO_URBS_FOR_DATA_STREAM]; + + int urbs_initialized; + int urbs_submitted; + + void *user_priv; +}; + +/** + * struct dvb_usb_adapter - a DVB adapter on a USB device + * @id: index of this adapter (starting with 0). + * * @feedcount: number of reqested feeds (used for streaming-activation) * @pid_filtering: is hardware pid_filtering used or not. * - * @usb_mutex: semaphore of USB control messages (reading needs two messages) - * @i2c_mutex: semaphore for i2c-transfers - * - * @i2c_adap: device's i2c_adapter if it uses I2CoverUSB * @pll_addr: I2C address of the tuner for programming * @pll_init: array containing the initialization buffer * @pll_desc: pointer to the appropriate struct dvb_pll_desc * * @tuner_pass_ctrl: called to (de)activate tuner passthru of the demod or the board - * * @dvb_adap: device's dvb_adapter. * @dmxdev: device's dmxdev. * @demux: device's software demuxer. @@ -246,6 +282,56 @@ struct dvb_usb_properties { * device * @fe_sleep: rerouted frontend-sleep function. * @fe_init: rerouted frontend-init (wakeup) function. + * @stream: the usb data stream. + */ +struct dvb_usb_adapter { + struct dvb_usb_device *dev; + struct dvb_usb_adapter_properties props; + +#define DVB_USB_ADAP_STATE_INIT 0x000 +#define DVB_USB_ADAP_STATE_DVB 0x001 + int state; + + int id; + + int feedcount; + int pid_filtering; + + /* tuner programming information */ + u8 pll_addr; + u8 pll_init[4]; + struct dvb_pll_desc *pll_desc; + int (*tuner_pass_ctrl) (struct dvb_frontend *, int, u8); + + /* dvb */ + struct dvb_adapter dvb_adap; + struct dmxdev dmxdev; + struct dvb_demux demux; + struct dvb_net dvb_net; + struct dvb_frontend *fe; + int max_feed_count; + + int (*fe_sleep) (struct dvb_frontend *); + int (*fe_init) (struct dvb_frontend *); + + struct usb_data_stream stream; + + void *priv; +}; + +/** + * struct dvb_usb_device - object of a DVB USB device + * @props: copy of the struct dvb_usb_properties this device belongs to. + * @desc: pointer to the device's struct dvb_usb_device_description. + * @state: initialization and runtime state of the device. + * + * @udev: pointer to the device's struct usb_device. + * + * @usb_mutex: semaphore of USB control messages (reading needs two messages) + * @i2c_mutex: semaphore for i2c-transfers + * + * @i2c_adap: device's i2c_adapter if it uses I2CoverUSB + * * @rc_input_dev: input device for the remote control. * @rc_query_work: struct work_struct frequent rc queries * @last_event: last triggered event @@ -255,32 +341,18 @@ struct dvb_usb_properties { * in size_of_priv of dvb_usb_properties). */ struct dvb_usb_device { - struct dvb_usb_properties props; + struct dvb_usb_device_properties props; struct dvb_usb_device_description *desc; -#define DVB_USB_STATE_INIT 0x000 -#define DVB_USB_STATE_URB_LIST 0x001 -#define DVB_USB_STATE_URB_BUF 0x002 -#define DVB_USB_STATE_DVB 0x004 -#define DVB_USB_STATE_I2C 0x008 -#define DVB_USB_STATE_REMOTE 0x010 -#define DVB_USB_STATE_URB_SUBMIT 0x020 - int state; - - /* usb */ struct usb_device *udev; - struct urb **urb_list; - - int buf_num; - unsigned long buf_size; - u8 **buf_list; - dma_addr_t *dma_addr; - int urbs_initialized; - int urbs_submitted; +#define DVB_USB_STATE_INIT 0x000 +#define DVB_USB_STATE_I2C 0x001 +#define DVB_USB_STATE_DVB 0x002 +#define DVB_USB_STATE_REMOTE 0x004 + int state; - int feedcount; - int pid_filtering; + int powered; /* locking */ struct mutex usb_mutex; @@ -289,22 +361,8 @@ struct dvb_usb_device { struct mutex i2c_mutex; struct i2c_adapter i2c_adap; - /* tuner programming information */ - u8 pll_addr; - u8 pll_init[4]; - struct dvb_pll_desc *pll_desc; - int (*tuner_pass_ctrl)(struct dvb_frontend *, int, u8); - - /* dvb */ - struct dvb_adapter dvb_adap; - struct dmxdev dmxdev; - struct dvb_demux demux; - struct dvb_net dvb_net; - struct dvb_frontend* fe; - int max_feed_count; - - int (*fe_sleep) (struct dvb_frontend *); - int (*fe_init) (struct dvb_frontend *); + int num_adapters_initialized; + struct dvb_usb_adapter adapter[MAX_NO_OF_ADAPTER_PER_DEVICE]; /* remote control */ struct input_dev *rc_input_dev; @@ -318,7 +376,7 @@ struct dvb_usb_device { void *priv; }; -extern int dvb_usb_device_init(struct usb_interface *, struct dvb_usb_properties *, struct module *, struct dvb_usb_device **); +extern int dvb_usb_device_init(struct usb_interface *, struct dvb_usb_device_properties *, struct module *, struct dvb_usb_device **); extern void dvb_usb_device_exit(struct usb_interface *); /* 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 9a98f3fdae31..334269bd065d 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) } -static int gp8psk_streaming_ctrl(struct dvb_usb_device *d, int onoff) +static int gp8psk_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) { - return gp8psk_usb_out_op(d, ARM_TRANSFER, onoff, 0 , NULL, 0); + return gp8psk_usb_out_op(adap->dev, ARM_TRANSFER, onoff, 0 , NULL, 0); } -static int gp8psk_frontend_attach(struct dvb_usb_device *d) +static int gp8psk_frontend_attach(struct dvb_usb_adapter *adap) { - d->fe = gp8psk_fe_attach(d); - + adap->fe = gp8psk_fe_attach(adap->dev); return 0; } -static struct dvb_usb_properties gp8psk_properties; +static struct dvb_usb_device_properties gp8psk_properties; static int gp8psk_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) @@ -188,20 +187,18 @@ static struct usb_device_id gp8psk_usb_table [] = { }; MODULE_DEVICE_TABLE(usb, gp8psk_usb_table); -static struct dvb_usb_properties gp8psk_properties = { - .caps = 0, - +static struct dvb_usb_device_properties gp8psk_properties = { .usb_ctrl = CYPRESS_FX2, .firmware = "dvb-usb-gp8psk-01.fw", + .num_adapters = 1, + .adapter = { + { .streaming_ctrl = gp8psk_streaming_ctrl, - .power_ctrl = gp8psk_power_ctrl, .frontend_attach = gp8psk_frontend_attach, - - .generic_bulk_ctrl_endpoint = 0x01, /* parameter for the MPEG2-data transfer */ - .urb = { - .type = DVB_USB_BULK, + .stream = { + .type = USB_BULK, .count = 7, .endpoint = 0x82, .u = { @@ -210,6 +207,11 @@ static struct dvb_usb_properties gp8psk_properties = { } } }, + } + }, + .power_ctrl = gp8psk_power_ctrl, + + .generic_bulk_ctrl_endpoint = 0x01, .num_device_descs = 1, .devices = { diff --git a/drivers/media/dvb/dvb-usb/nova-t-usb2.c b/drivers/media/dvb/dvb-usb/nova-t-usb2.c index 79f0a02ce987..a9219bf69b89 100644 --- a/drivers/media/dvb/dvb-usb/nova-t-usb2.c +++ b/drivers/media/dvb/dvb-usb/nova-t-usb2.c @@ -135,7 +135,7 @@ static int nova_t_read_mac_address (struct dvb_usb_device *d, u8 mac[6]) } /* USB Driver stuff */ -static struct dvb_usb_properties nova_t_properties; +static struct dvb_usb_device_properties nova_t_properties; static int nova_t_probe(struct usb_interface *intf, const struct usb_device_id *id) @@ -151,34 +151,27 @@ static struct usb_device_id nova_t_table [] = { }; MODULE_DEVICE_TABLE(usb, nova_t_table); -static struct dvb_usb_properties nova_t_properties = { - .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF | DVB_USB_IS_AN_I2C_ADAPTER, - .pid_filter_count = 32, +static struct dvb_usb_device_properties nova_t_properties = { + .caps = DVB_USB_IS_AN_I2C_ADAPTER, .usb_ctrl = CYPRESS_FX2, .firmware = "dvb-usb-nova-t-usb2-02.fw", - .size_of_priv = sizeof(struct dibusb_state), + .num_adapters = 1, + .adapter = { + { + .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, + .pid_filter_count = 32, .streaming_ctrl = dibusb2_0_streaming_ctrl, .pid_filter = dibusb_pid_filter, .pid_filter_ctrl = dibusb_pid_filter_ctrl, - .power_ctrl = dibusb2_0_power_ctrl, .frontend_attach = dibusb_dib3000mc_frontend_attach, .tuner_attach = dibusb_dib3000mc_tuner_attach, - .read_mac_address = nova_t_read_mac_address, - - .rc_interval = 100, - .rc_key_map = haupp_rc_keys, - .rc_key_map_size = ARRAY_SIZE(haupp_rc_keys), - .rc_query = nova_t_rc_query, - .i2c_algo = &dibusb_i2c_algo, - - .generic_bulk_ctrl_endpoint = 0x01, /* parameter for the MPEG2-data transfer */ - .urb = { - .type = DVB_USB_BULK, + .stream = { + .type = USB_BULK, .count = 7, .endpoint = 0x06, .u = { @@ -188,6 +181,22 @@ static struct dvb_usb_properties nova_t_properties = { } }, + .size_of_priv = sizeof(struct dibusb_state), + } + }, + + .power_ctrl = dibusb2_0_power_ctrl, + .read_mac_address = nova_t_read_mac_address, + + .rc_interval = 100, + .rc_key_map = haupp_rc_keys, + .rc_key_map_size = ARRAY_SIZE(haupp_rc_keys), + .rc_query = nova_t_rc_query, + + .i2c_algo = &dibusb_i2c_algo, + + .generic_bulk_ctrl_endpoint = 0x01, + .num_device_descs = 1, .devices = { { "Hauppauge WinTV-NOVA-T usb2", diff --git a/drivers/media/dvb/dvb-usb/umt-010.c b/drivers/media/dvb/dvb-usb/umt-010.c index 418a0b707151..f9941ea88b3e 100644 --- a/drivers/media/dvb/dvb-usb/umt-010.c +++ b/drivers/media/dvb/dvb-usb/umt-010.c @@ -50,7 +50,7 @@ static int umt_mt352_demod_init(struct dvb_frontend *fe) return 0; } -static int umt_mt352_frontend_attach(struct dvb_usb_device *d) +static int umt_mt352_frontend_attach(struct dvb_usb_adapter *adap) { struct mt352_config umt_config; @@ -58,21 +58,21 @@ static int umt_mt352_frontend_attach(struct dvb_usb_device *d) umt_config.demod_init = umt_mt352_demod_init; umt_config.demod_address = 0xf; - d->fe = dvb_attach(mt352_attach, &umt_config, &d->i2c_adap); + adap->fe = dvb_attach(mt352_attach, &umt_config, &adap->dev->i2c_adap); return 0; } -static int umt_tuner_attach (struct dvb_usb_device *d) +static int umt_tuner_attach (struct dvb_usb_adapter *adap) { - d->pll_addr = 0x61; - d->pll_desc = &dvb_pll_tua6034; - d->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs; + adap->pll_addr = 0x61; + adap->pll_desc = &dvb_pll_tua6034; + adap->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs; return 0; } /* USB Driver stuff */ -static struct dvb_usb_properties umt_properties; +static struct dvb_usb_device_properties umt_properties; static int umt_probe(struct usb_interface *intf, const struct usb_device_id *id) @@ -90,25 +90,22 @@ static struct usb_device_id umt_table [] = { }; MODULE_DEVICE_TABLE (usb, umt_table); -static struct dvb_usb_properties umt_properties = { +static struct dvb_usb_device_properties umt_properties = { .caps = DVB_USB_IS_AN_I2C_ADAPTER, .usb_ctrl = CYPRESS_FX2, .firmware = "dvb-usb-umt-010-02.fw", - .size_of_priv = sizeof(struct dibusb_state), - + .num_adapters = 1, + .adapter = { + { .streaming_ctrl = dibusb2_0_streaming_ctrl, - .power_ctrl = dibusb_power_ctrl, .frontend_attach = umt_mt352_frontend_attach, .tuner_attach = umt_tuner_attach, - .i2c_algo = &dibusb_i2c_algo, - - .generic_bulk_ctrl_endpoint = 0x01, /* parameter for the MPEG2-data transfer */ - .urb = { - .type = DVB_USB_BULK, + .stream = { + .type = USB_BULK, .count = 20, .endpoint = 0x06, .u = { @@ -118,6 +115,15 @@ static struct dvb_usb_properties umt_properties = { } }, + .size_of_priv = sizeof(struct dibusb_state), + } + }, + .power_ctrl = dibusb_power_ctrl, + + .i2c_algo = &dibusb_i2c_algo, + + .generic_bulk_ctrl_endpoint = 0x01, + .num_device_descs = 1, .devices = { { "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 b2f098a2d5f7..fdab2562bf5d 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, return ret; } -static int vp702x_pid_filter(struct dvb_usb_device *d, int index, u16 pid, int onoff) +static int vp702x_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid, int onoff) { - struct vp702x_state *st = d->priv; + struct vp702x_state *st = adap->priv; u8 buf[9]; if (onoff) { @@ -122,7 +122,7 @@ static int vp702x_pid_filter(struct dvb_usb_device *d, int index, u16 pid, int o st->pid_table[index*2] = st->pid_table[index*2+1] = 0; } - return vp702x_usb_inout_cmd(d,SET_PID_FILTER,st->pid_table,17,buf,9,10); + return vp702x_usb_inout_cmd(adap->dev,SET_PID_FILTER,st->pid_table,17,buf,9,10); } static 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]) return 0; } -static int vp702x_frontend_attach(struct dvb_usb_device *d) +static int vp702x_frontend_attach(struct dvb_usb_adapter *adap) { u8 buf[9] = { 0 }; - if (vp702x_usb_inout_cmd(d, GET_SYSTEM_STRING, NULL, 0, buf, 9, 10)) + if (vp702x_usb_inout_cmd(adap->dev, GET_SYSTEM_STRING, NULL, 0, buf, 9, 10)) return -EIO; buf[8] = '\0'; info("system string: %s",&buf[1]); - d->fe = vp702x_fe_attach(d); + adap->fe = vp702x_fe_attach(adap->dev); return 0; } -static struct dvb_usb_properties vp702x_properties; +static struct dvb_usb_device_properties vp702x_properties; static int vp702x_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) @@ -211,28 +211,21 @@ static struct usb_device_id vp702x_usb_table [] = { }; MODULE_DEVICE_TABLE(usb, vp702x_usb_table); -static struct dvb_usb_properties vp702x_properties = { - .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_NEED_PID_FILTERING, - .pid_filter_count = 8, /* !!! */ - +static struct dvb_usb_device_properties vp702x_properties = { .usb_ctrl = CYPRESS_FX2, .firmware = "dvb-usb-vp702x-01.fw", + .num_adapters = 1, + .adapter = { + { + .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_NEED_PID_FILTERING, + .pid_filter_count = 8, /* !!! */ + .pid_filter = vp702x_pid_filter, - .power_ctrl = vp702x_power_ctrl, .frontend_attach = vp702x_frontend_attach, - .read_mac_address = vp702x_read_mac_addr, - - .rc_key_map = vp702x_rc_keys, - .rc_key_map_size = ARRAY_SIZE(vp702x_rc_keys), - .rc_interval = 400, - .rc_query = vp702x_rc_query, - - .size_of_priv = sizeof(struct vp702x_state), - /* parameter for the MPEG2-data transfer */ - .urb = { - .type = DVB_USB_BULK, + .stream = { + .type = USB_BULK, .count = 7, .endpoint = 0x02, .u = { @@ -241,6 +234,16 @@ static struct dvb_usb_properties vp702x_properties = { } } }, + .size_of_priv = sizeof(struct vp702x_state), + }, + }, + .power_ctrl = vp702x_power_ctrl, + .read_mac_address = vp702x_read_mac_addr, + + .rc_key_map = vp702x_rc_keys, + .rc_key_map_size = ARRAY_SIZE(vp702x_rc_keys), + .rc_interval = 400, + .rc_query = vp702x_rc_query, .num_device_descs = 2, .devices = { diff --git a/drivers/media/dvb/dvb-usb/vp7045.c b/drivers/media/dvb/dvb-usb/vp7045.c index 8ea3834a6cf8..b4cf002703a7 100644 --- a/drivers/media/dvb/dvb-usb/vp7045.c +++ b/drivers/media/dvb/dvb-usb/vp7045.c @@ -169,31 +169,31 @@ static int vp7045_read_mac_addr(struct dvb_usb_device *d,u8 mac[6]) return vp7045_read_eeprom(d,mac, 6, MAC_0_ADDR); } -static int vp7045_frontend_attach(struct dvb_usb_device *d) +static int vp7045_frontend_attach(struct dvb_usb_adapter *adap) { u8 buf[255] = { 0 }; - vp7045_usb_op(d,VENDOR_STRING_READ,NULL,0,buf,20,0); + vp7045_usb_op(adap->dev,VENDOR_STRING_READ,NULL,0,buf,20,0); buf[10] = '\0'; deb_info("firmware says: %s ",buf); - vp7045_usb_op(d,PRODUCT_STRING_READ,NULL,0,buf,20,0); + vp7045_usb_op(adap->dev,PRODUCT_STRING_READ,NULL,0,buf,20,0); buf[10] = '\0'; deb_info("%s ",buf); - vp7045_usb_op(d,FW_VERSION_READ,NULL,0,buf,20,0); + vp7045_usb_op(adap->dev,FW_VERSION_READ,NULL,0,buf,20,0); buf[10] = '\0'; deb_info("v%s\n",buf); /* Dump the EEPROM */ /* vp7045_read_eeprom(d,buf, 255, FX2_ID_ADDR); */ - d->fe = vp7045_fe_attach(d); + adap->fe = vp7045_fe_attach(adap->dev); return 0; } -static struct dvb_usb_properties vp7045_properties; +static struct dvb_usb_device_properties vp7045_properties; static int vp7045_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) @@ -210,24 +210,17 @@ static struct usb_device_id vp7045_usb_table [] = { }; MODULE_DEVICE_TABLE(usb, vp7045_usb_table); -static struct dvb_usb_properties vp7045_properties = { - .caps = 0, - +static struct dvb_usb_device_properties vp7045_properties = { .usb_ctrl = CYPRESS_FX2, .firmware = "dvb-usb-vp7045-01.fw", - .power_ctrl = vp7045_power_ctrl, + .num_adapters = 1, + .adapter = { + { .frontend_attach = vp7045_frontend_attach, - .read_mac_address = vp7045_read_mac_addr, - - .rc_interval = 400, - .rc_key_map = vp7045_rc_keys, - .rc_key_map_size = ARRAY_SIZE(vp7045_rc_keys), - .rc_query = vp7045_rc_query, - /* parameter for the MPEG2-data transfer */ - .urb = { - .type = DVB_USB_BULK, + .stream = { + .type = USB_BULK, .count = 7, .endpoint = 0x02, .u = { @@ -236,6 +229,15 @@ static struct dvb_usb_properties vp7045_properties = { } } }, + } + }, + .power_ctrl = vp7045_power_ctrl, + .read_mac_address = vp7045_read_mac_addr, + + .rc_interval = 400, + .rc_key_map = vp7045_rc_keys, + .rc_key_map_size = ARRAY_SIZE(vp7045_rc_keys), + .rc_query = vp7045_rc_query, .num_device_descs = 2, .devices = { |