aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/dvb-usb
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/dvb-usb')
-rw-r--r--drivers/media/dvb/dvb-usb/Kconfig13
-rw-r--r--drivers/media/dvb/dvb-usb/Makefile3
-rw-r--r--drivers/media/dvb/dvb-usb/af9015.c495
-rw-r--r--drivers/media/dvb/dvb-usb/af9035.c1242
-rw-r--r--drivers/media/dvb/dvb-usb/af9035.h113
-rw-r--r--drivers/media/dvb/dvb-usb/dib0700_core.c24
-rw-r--r--drivers/media/dvb/dvb-usb/dib0700_devices.c7
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-ids.h12
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-urb.c12
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb.h3
-rw-r--r--drivers/media/dvb/dvb-usb/dw2102.c76
-rw-r--r--drivers/media/dvb/dvb-usb/it913x.c4
-rw-r--r--drivers/media/dvb/dvb-usb/lmedm04.c5
-rw-r--r--drivers/media/dvb/dvb-usb/mxl111sf-tuner.c1
-rw-r--r--drivers/media/dvb/dvb-usb/mxl111sf.c850
-rw-r--r--drivers/media/dvb/dvb-usb/rtl28xxu.c28
16 files changed, 2510 insertions, 378 deletions
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig
index 63bf45679f98..a26949336b3d 100644
--- a/drivers/media/dvb/dvb-usb/Kconfig
+++ b/drivers/media/dvb/dvb-usb/Kconfig
@@ -409,6 +409,7 @@ config DVB_USB_MXL111SF
409 tristate "MxL111SF DTV USB2.0 support" 409 tristate "MxL111SF DTV USB2.0 support"
410 depends on DVB_USB 410 depends on DVB_USB
411 select DVB_LGDT3305 if !DVB_FE_CUSTOMISE 411 select DVB_LGDT3305 if !DVB_FE_CUSTOMISE
412 select DVB_LG2160 if !DVB_FE_CUSTOMISE
412 select VIDEO_TVEEPROM 413 select VIDEO_TVEEPROM
413 help 414 help
414 Say Y here to support the MxL111SF USB2.0 DTV receiver. 415 Say Y here to support the MxL111SF USB2.0 DTV receiver.
@@ -422,3 +423,15 @@ config DVB_USB_RTL28XXU
422 select MEDIA_TUNER_MXL5005S if !MEDIA_TUNER_CUSTOMISE 423 select MEDIA_TUNER_MXL5005S if !MEDIA_TUNER_CUSTOMISE
423 help 424 help
424 Say Y here to support the Realtek RTL28xxU DVB USB receiver. 425 Say Y here to support the Realtek RTL28xxU DVB USB receiver.
426
427config DVB_USB_AF9035
428 tristate "Afatech AF9035 DVB-T USB2.0 support"
429 depends on DVB_USB
430 select DVB_AF9033
431 select MEDIA_TUNER_TUA9001 if !MEDIA_TUNER_CUSTOMISE
432 select MEDIA_TUNER_FC0011 if !MEDIA_TUNER_CUSTOMISE
433 select MEDIA_TUNER_MXL5007T if !MEDIA_TUNER_CUSTOMISE
434 select MEDIA_TUNER_TDA18218 if !MEDIA_TUNER_CUSTOMISE
435 help
436 Say Y here to support the Afatech AF9035 based DVB USB receiver.
437
diff --git a/drivers/media/dvb/dvb-usb/Makefile b/drivers/media/dvb/dvb-usb/Makefile
index b76acb5387e6..b667ac39a4e3 100644
--- a/drivers/media/dvb/dvb-usb/Makefile
+++ b/drivers/media/dvb/dvb-usb/Makefile
@@ -110,6 +110,9 @@ obj-$(CONFIG_DVB_USB_MXL111SF) += mxl111sf-tuner.o
110dvb-usb-rtl28xxu-objs = rtl28xxu.o 110dvb-usb-rtl28xxu-objs = rtl28xxu.o
111obj-$(CONFIG_DVB_USB_RTL28XXU) += dvb-usb-rtl28xxu.o 111obj-$(CONFIG_DVB_USB_RTL28XXU) += dvb-usb-rtl28xxu.o
112 112
113dvb-usb-af9035-objs = af9035.o
114obj-$(CONFIG_DVB_USB_AF9035) += dvb-usb-af9035.o
115
113ccflags-y += -I$(srctree)/drivers/media/dvb/dvb-core 116ccflags-y += -I$(srctree)/drivers/media/dvb/dvb-core
114ccflags-y += -I$(srctree)/drivers/media/dvb/frontends/ 117ccflags-y += -I$(srctree)/drivers/media/dvb/frontends/
115# due to tuner-xc3028 118# due to tuner-xc3028
diff --git a/drivers/media/dvb/dvb-usb/af9015.c b/drivers/media/dvb/dvb-usb/af9015.c
index 7e70ea50ef26..677fed79b01e 100644
--- a/drivers/media/dvb/dvb-usb/af9015.c
+++ b/drivers/media/dvb/dvb-usb/af9015.c
@@ -244,8 +244,7 @@ static int af9015_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
244 u8 uninitialized_var(mbox), addr_len; 244 u8 uninitialized_var(mbox), addr_len;
245 struct req_t req; 245 struct req_t req;
246 246
247/* TODO: implement bus lock 247/*
248
249The bus lock is needed because there is two tuners both using same I2C-address. 248The bus lock is needed because there is two tuners both using same I2C-address.
250Due to that the only way to select correct tuner is use demodulator I2C-gate. 249Due to that the only way to select correct tuner is use demodulator I2C-gate.
251 250
@@ -789,7 +788,7 @@ static void af9015_set_remote_config(struct usb_device *udev,
789 /* try to load remote based USB ID */ 788 /* try to load remote based USB ID */
790 if (!props->rc.core.rc_codes) 789 if (!props->rc.core.rc_codes)
791 props->rc.core.rc_codes = af9015_rc_setup_match( 790 props->rc.core.rc_codes = af9015_rc_setup_match(
792 (vid << 16) + pid, af9015_rc_setup_usbids); 791 (vid << 16) | pid, af9015_rc_setup_usbids);
793 792
794 /* try to load remote based USB iManufacturer string */ 793 /* try to load remote based USB iManufacturer string */
795 if (!props->rc.core.rc_codes && vid == USB_VID_AFATECH) { 794 if (!props->rc.core.rc_codes && vid == USB_VID_AFATECH) {
@@ -1220,8 +1219,8 @@ static int af9015_af9013_frontend_attach(struct dvb_usb_adapter *adap)
1220 } 1219 }
1221 1220
1222 /* attach demodulator */ 1221 /* attach demodulator */
1223 adap->fe_adap[0].fe = dvb_attach(af9013_attach, &af9015_af9013_config[adap->id], 1222 adap->fe_adap[0].fe = dvb_attach(af9013_attach,
1224 &adap->dev->i2c_adap); 1223 &af9015_af9013_config[adap->id], &adap->dev->i2c_adap);
1225 1224
1226 /* 1225 /*
1227 * AF9015 firmware does not like if it gets interrupted by I2C adapter 1226 * AF9015 firmware does not like if it gets interrupted by I2C adapter
@@ -1324,14 +1323,15 @@ static int af9015_tuner_attach(struct dvb_usb_adapter *adap)
1324 switch (af9015_af9013_config[adap->id].tuner) { 1323 switch (af9015_af9013_config[adap->id].tuner) {
1325 case AF9013_TUNER_MT2060: 1324 case AF9013_TUNER_MT2060:
1326 case AF9013_TUNER_MT2060_2: 1325 case AF9013_TUNER_MT2060_2:
1327 ret = dvb_attach(mt2060_attach, adap->fe_adap[0].fe, &adap->dev->i2c_adap, 1326 ret = dvb_attach(mt2060_attach, adap->fe_adap[0].fe,
1328 &af9015_mt2060_config, 1327 &adap->dev->i2c_adap, &af9015_mt2060_config,
1329 af9015_config.mt2060_if1[adap->id]) 1328 af9015_config.mt2060_if1[adap->id])
1330 == NULL ? -ENODEV : 0; 1329 == NULL ? -ENODEV : 0;
1331 break; 1330 break;
1332 case AF9013_TUNER_QT1010: 1331 case AF9013_TUNER_QT1010:
1333 case AF9013_TUNER_QT1010A: 1332 case AF9013_TUNER_QT1010A:
1334 ret = dvb_attach(qt1010_attach, adap->fe_adap[0].fe, &adap->dev->i2c_adap, 1333 ret = dvb_attach(qt1010_attach, adap->fe_adap[0].fe,
1334 &adap->dev->i2c_adap,
1335 &af9015_qt1010_config) == NULL ? -ENODEV : 0; 1335 &af9015_qt1010_config) == NULL ? -ENODEV : 0;
1336 break; 1336 break;
1337 case AF9013_TUNER_TDA18271: 1337 case AF9013_TUNER_TDA18271:
@@ -1434,69 +1434,85 @@ enum af9015_usb_table_entry {
1434}; 1434};
1435 1435
1436static struct usb_device_id af9015_usb_table[] = { 1436static struct usb_device_id af9015_usb_table[] = {
1437 [AFATECH_9015] = 1437 [AFATECH_9015] = {
1438 {USB_DEVICE(USB_VID_AFATECH, USB_PID_AFATECH_AF9015_9015)}, 1438 USB_DEVICE(USB_VID_AFATECH, USB_PID_AFATECH_AF9015_9015)},
1439 [AFATECH_9016] = 1439 [AFATECH_9016] = {
1440 {USB_DEVICE(USB_VID_AFATECH, USB_PID_AFATECH_AF9015_9016)}, 1440 USB_DEVICE(USB_VID_AFATECH, USB_PID_AFATECH_AF9015_9016)},
1441 [WINFAST_DTV_GOLD] = 1441 [WINFAST_DTV_GOLD] = {
1442 {USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_GOLD)}, 1442 USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_GOLD)},
1443 [PINNACLE_PCTV_71E] = 1443 [PINNACLE_PCTV_71E] = {
1444 {USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV71E)}, 1444 USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV71E)},
1445 [KWORLD_PLUSTV_399U] = 1445 [KWORLD_PLUSTV_399U] = {
1446 {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_399U)}, 1446 USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_399U)},
1447 [TINYTWIN] = {USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TINYTWIN)}, 1447 [TINYTWIN] = {
1448 [AZUREWAVE_TU700] = 1448 USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TINYTWIN)},
1449 {USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_AZUREWAVE_AD_TU700)}, 1449 [AZUREWAVE_TU700] = {
1450 [TERRATEC_AF9015] = {USB_DEVICE(USB_VID_TERRATEC, 1450 USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_AZUREWAVE_AD_TU700)},
1451 [TERRATEC_AF9015] = {
1452 USB_DEVICE(USB_VID_TERRATEC,
1451 USB_PID_TERRATEC_CINERGY_T_USB_XE_REV2)}, 1453 USB_PID_TERRATEC_CINERGY_T_USB_XE_REV2)},
1452 [KWORLD_PLUSTV_PC160] = 1454 [KWORLD_PLUSTV_PC160] = {
1453 {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_PC160_2T)}, 1455 USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_PC160_2T)},
1454 [AVERTV_VOLAR_X] = 1456 [AVERTV_VOLAR_X] = {
1455 {USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_X)}, 1457 USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_X)},
1456 [XTENSIONS_380U] = 1458 [XTENSIONS_380U] = {
1457 {USB_DEVICE(USB_VID_XTENSIONS, USB_PID_XTENSIONS_XD_380)}, 1459 USB_DEVICE(USB_VID_XTENSIONS, USB_PID_XTENSIONS_XD_380)},
1458 [MSI_DIGIVOX_DUO] = 1460 [MSI_DIGIVOX_DUO] = {
1459 {USB_DEVICE(USB_VID_MSI_2, USB_PID_MSI_DIGIVOX_DUO)}, 1461 USB_DEVICE(USB_VID_MSI_2, USB_PID_MSI_DIGIVOX_DUO)},
1460 [AVERTV_VOLAR_X_REV2] = 1462 [AVERTV_VOLAR_X_REV2] = {
1461 {USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_X_2)}, 1463 USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_X_2)},
1462 [TELESTAR_STARSTICK_2] = 1464 [TELESTAR_STARSTICK_2] = {
1463 {USB_DEVICE(USB_VID_TELESTAR, USB_PID_TELESTAR_STARSTICK_2)}, 1465 USB_DEVICE(USB_VID_TELESTAR, USB_PID_TELESTAR_STARSTICK_2)},
1464 [AVERMEDIA_A309_USB] = 1466 [AVERMEDIA_A309_USB] = {
1465 {USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A309)}, 1467 USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A309)},
1466 [MSI_DIGIVOX_MINI_III] = 1468 [MSI_DIGIVOX_MINI_III] = {
1467 {USB_DEVICE(USB_VID_MSI_2, USB_PID_MSI_DIGI_VOX_MINI_III)}, 1469 USB_DEVICE(USB_VID_MSI_2, USB_PID_MSI_DIGI_VOX_MINI_III)},
1468 [KWORLD_E396] = {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_395U)}, 1470 [KWORLD_E396] = {
1469 [KWORLD_E39B] = {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_395U_2)}, 1471 USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_395U)},
1470 [KWORLD_E395] = {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_395U_3)}, 1472 [KWORLD_E39B] = {
1471 [TREKSTOR_DVBT] = {USB_DEVICE(USB_VID_AFATECH, USB_PID_TREKSTOR_DVBT)}, 1473 USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_395U_2)},
1472 [AVERTV_A850] = {USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A850)}, 1474 [KWORLD_E395] = {
1473 [AVERTV_A805] = {USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A805)}, 1475 USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_395U_3)},
1474 [CONCEPTRONIC_CTVDIGRCU] = 1476 [TREKSTOR_DVBT] = {
1475 {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_CONCEPTRONIC_CTVDIGRCU)}, 1477 USB_DEVICE(USB_VID_AFATECH, USB_PID_TREKSTOR_DVBT)},
1476 [KWORLD_MC810] = {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_MC810)}, 1478 [AVERTV_A850] = {
1477 [GENIUS_TVGO_DVB_T03] = 1479 USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A850)},
1478 {USB_DEVICE(USB_VID_KYE, USB_PID_GENIUS_TVGO_DVB_T03)}, 1480 [AVERTV_A805] = {
1479 [KWORLD_399U_2] = {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_399U_2)}, 1481 USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A805)},
1480 [KWORLD_PC160_T] = 1482 [CONCEPTRONIC_CTVDIGRCU] = {
1481 {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_PC160_T)}, 1483 USB_DEVICE(USB_VID_KWORLD_2, USB_PID_CONCEPTRONIC_CTVDIGRCU)},
1482 [SVEON_STV20] = {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_SVEON_STV20)}, 1484 [KWORLD_MC810] = {
1483 [TINYTWIN_2] = {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_TINYTWIN_2)}, 1485 USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_MC810)},
1484 [WINFAST_DTV2000DS] = 1486 [GENIUS_TVGO_DVB_T03] = {
1485 {USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV2000DS)}, 1487 USB_DEVICE(USB_VID_KYE, USB_PID_GENIUS_TVGO_DVB_T03)},
1486 [KWORLD_UB383_T] = 1488 [KWORLD_399U_2] = {
1487 {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_UB383_T)}, 1489 USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_399U_2)},
1488 [KWORLD_E39A] = 1490 [KWORLD_PC160_T] = {
1489 {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_395U_4)}, 1491 USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_PC160_T)},
1490 [AVERMEDIA_A815M] = 1492 [SVEON_STV20] = {
1491 {USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A815M)}, 1493 USB_DEVICE(USB_VID_KWORLD_2, USB_PID_SVEON_STV20)},
1492 [CINERGY_T_STICK_RC] = {USB_DEVICE(USB_VID_TERRATEC, 1494 [TINYTWIN_2] = {
1495 USB_DEVICE(USB_VID_KWORLD_2, USB_PID_TINYTWIN_2)},
1496 [WINFAST_DTV2000DS] = {
1497 USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV2000DS)},
1498 [KWORLD_UB383_T] = {
1499 USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_UB383_T)},
1500 [KWORLD_E39A] = {
1501 USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_395U_4)},
1502 [AVERMEDIA_A815M] = {
1503 USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A815M)},
1504 [CINERGY_T_STICK_RC] = {
1505 USB_DEVICE(USB_VID_TERRATEC,
1493 USB_PID_TERRATEC_CINERGY_T_STICK_RC)}, 1506 USB_PID_TERRATEC_CINERGY_T_STICK_RC)},
1494 [CINERGY_T_DUAL_RC] = {USB_DEVICE(USB_VID_TERRATEC, 1507 [CINERGY_T_DUAL_RC] = {
1508 USB_DEVICE(USB_VID_TERRATEC,
1495 USB_PID_TERRATEC_CINERGY_T_STICK_DUAL_RC)}, 1509 USB_PID_TERRATEC_CINERGY_T_STICK_DUAL_RC)},
1496 [AVERTV_A850T] = 1510 [AVERTV_A850T] = {
1497 {USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A850T)}, 1511 USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A850T)},
1498 [TINYTWIN_3] = {USB_DEVICE(USB_VID_GTEK, USB_PID_TINYTWIN_3)}, 1512 [TINYTWIN_3] = {
1499 [SVEON_STV22] = {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_SVEON_STV22)}, 1513 USB_DEVICE(USB_VID_GTEK, USB_PID_TINYTWIN_3)},
1514 [SVEON_STV22] = {
1515 USB_DEVICE(USB_VID_KWORLD_2, USB_PID_SVEON_STV22)},
1500 { } 1516 { }
1501}; 1517};
1502MODULE_DEVICE_TABLE(usb, af9015_usb_table); 1518MODULE_DEVICE_TABLE(usb, af9015_usb_table);
@@ -1516,43 +1532,44 @@ static struct dvb_usb_device_properties af9015_properties[] = {
1516 .num_adapters = 2, 1532 .num_adapters = 2,
1517 .adapter = { 1533 .adapter = {
1518 { 1534 {
1519 .num_frontends = 1, 1535 .num_frontends = 1,
1520 .fe = {{ 1536 .fe = {
1521 .caps = DVB_USB_ADAP_HAS_PID_FILTER | 1537 {
1522 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, 1538 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
1523 1539 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
1524 .pid_filter_count = 32, 1540
1525 .pid_filter = af9015_pid_filter, 1541 .pid_filter_count = 32,
1526 .pid_filter_ctrl = af9015_pid_filter_ctrl, 1542 .pid_filter = af9015_pid_filter,
1527 1543 .pid_filter_ctrl = af9015_pid_filter_ctrl,
1528 .frontend_attach = 1544
1529 af9015_af9013_frontend_attach, 1545 .frontend_attach = af9015_af9013_frontend_attach,
1530 .tuner_attach = af9015_tuner_attach, 1546 .tuner_attach = af9015_tuner_attach,
1531 .stream = { 1547 .stream = {
1532 .type = USB_BULK, 1548 .type = USB_BULK,
1533 .count = 6, 1549 .count = 6,
1534 .endpoint = 0x84, 1550 .endpoint = 0x84,
1551 },
1552 }
1535 }, 1553 },
1536 }},
1537 }, 1554 },
1538 { 1555 {
1539 .num_frontends = 1, 1556 .num_frontends = 1,
1540 .fe = {{ 1557 .fe = {
1541 .frontend_attach = 1558 {
1542 af9015_af9013_frontend_attach, 1559 .frontend_attach = af9015_af9013_frontend_attach,
1543 .tuner_attach = af9015_tuner_attach, 1560 .tuner_attach = af9015_tuner_attach,
1544 .stream = { 1561 .stream = {
1545 .type = USB_BULK, 1562 .type = USB_BULK,
1546 .count = 6, 1563 .count = 6,
1547 .endpoint = 0x85, 1564 .endpoint = 0x85,
1548 .u = { 1565 .u = {
1549 .bulk = { 1566 .bulk = {
1550 .buffersize = 1567 .buffersize = TS_USB20_FRAME_SIZE,
1551 TS_USB20_FRAME_SIZE, 1568 }
1552 } 1569 }
1570 },
1553 } 1571 }
1554 }, 1572 },
1555 }},
1556 } 1573 }
1557 }, 1574 },
1558 1575
@@ -1575,102 +1592,67 @@ static struct dvb_usb_device_properties af9015_properties[] = {
1575 .cold_ids = { 1592 .cold_ids = {
1576 &af9015_usb_table[AFATECH_9015], 1593 &af9015_usb_table[AFATECH_9015],
1577 &af9015_usb_table[AFATECH_9016], 1594 &af9015_usb_table[AFATECH_9016],
1578 NULL
1579 }, 1595 },
1580 .warm_ids = {NULL}, 1596 }, {
1581 },
1582 {
1583 .name = "Leadtek WinFast DTV Dongle Gold", 1597 .name = "Leadtek WinFast DTV Dongle Gold",
1584 .cold_ids = { 1598 .cold_ids = {
1585 &af9015_usb_table[WINFAST_DTV_GOLD], 1599 &af9015_usb_table[WINFAST_DTV_GOLD],
1586 NULL
1587 }, 1600 },
1588 .warm_ids = {NULL}, 1601 }, {
1589 },
1590 {
1591 .name = "Pinnacle PCTV 71e", 1602 .name = "Pinnacle PCTV 71e",
1592 .cold_ids = { 1603 .cold_ids = {
1593 &af9015_usb_table[PINNACLE_PCTV_71E], 1604 &af9015_usb_table[PINNACLE_PCTV_71E],
1594 NULL
1595 }, 1605 },
1596 .warm_ids = {NULL}, 1606 }, {
1597 },
1598 {
1599 .name = "KWorld PlusTV Dual DVB-T Stick " \ 1607 .name = "KWorld PlusTV Dual DVB-T Stick " \
1600 "(DVB-T 399U)", 1608 "(DVB-T 399U)",
1601 .cold_ids = { 1609 .cold_ids = {
1602 &af9015_usb_table[KWORLD_PLUSTV_399U], 1610 &af9015_usb_table[KWORLD_PLUSTV_399U],
1603 &af9015_usb_table[KWORLD_399U_2], 1611 &af9015_usb_table[KWORLD_399U_2],
1604 NULL
1605 }, 1612 },
1606 .warm_ids = {NULL}, 1613 }, {
1607 },
1608 {
1609 .name = "DigitalNow TinyTwin DVB-T Receiver", 1614 .name = "DigitalNow TinyTwin DVB-T Receiver",
1610 .cold_ids = { 1615 .cold_ids = {
1611 &af9015_usb_table[TINYTWIN], 1616 &af9015_usb_table[TINYTWIN],
1612 &af9015_usb_table[TINYTWIN_2], 1617 &af9015_usb_table[TINYTWIN_2],
1613 &af9015_usb_table[TINYTWIN_3], 1618 &af9015_usb_table[TINYTWIN_3],
1614 NULL
1615 }, 1619 },
1616 .warm_ids = {NULL}, 1620 }, {
1617 },
1618 {
1619 .name = "TwinHan AzureWave AD-TU700(704J)", 1621 .name = "TwinHan AzureWave AD-TU700(704J)",
1620 .cold_ids = { 1622 .cold_ids = {
1621 &af9015_usb_table[AZUREWAVE_TU700], 1623 &af9015_usb_table[AZUREWAVE_TU700],
1622 NULL
1623 }, 1624 },
1624 .warm_ids = {NULL}, 1625 }, {
1625 },
1626 {
1627 .name = "TerraTec Cinergy T USB XE", 1626 .name = "TerraTec Cinergy T USB XE",
1628 .cold_ids = { 1627 .cold_ids = {
1629 &af9015_usb_table[TERRATEC_AF9015], 1628 &af9015_usb_table[TERRATEC_AF9015],
1630 NULL
1631 }, 1629 },
1632 .warm_ids = {NULL}, 1630 }, {
1633 },
1634 {
1635 .name = "KWorld PlusTV Dual DVB-T PCI " \ 1631 .name = "KWorld PlusTV Dual DVB-T PCI " \
1636 "(DVB-T PC160-2T)", 1632 "(DVB-T PC160-2T)",
1637 .cold_ids = { 1633 .cold_ids = {
1638 &af9015_usb_table[KWORLD_PLUSTV_PC160], 1634 &af9015_usb_table[KWORLD_PLUSTV_PC160],
1639 NULL
1640 }, 1635 },
1641 .warm_ids = {NULL}, 1636 }, {
1642 },
1643 {
1644 .name = "AVerMedia AVerTV DVB-T Volar X", 1637 .name = "AVerMedia AVerTV DVB-T Volar X",
1645 .cold_ids = { 1638 .cold_ids = {
1646 &af9015_usb_table[AVERTV_VOLAR_X], 1639 &af9015_usb_table[AVERTV_VOLAR_X],
1647 NULL
1648 }, 1640 },
1649 .warm_ids = {NULL}, 1641 }, {
1650 },
1651 {
1652 .name = "TerraTec Cinergy T Stick RC", 1642 .name = "TerraTec Cinergy T Stick RC",
1653 .cold_ids = { 1643 .cold_ids = {
1654 &af9015_usb_table[CINERGY_T_STICK_RC], 1644 &af9015_usb_table[CINERGY_T_STICK_RC],
1655 NULL
1656 }, 1645 },
1657 .warm_ids = {NULL}, 1646 }, {
1658 },
1659 {
1660 .name = "TerraTec Cinergy T Stick Dual RC", 1647 .name = "TerraTec Cinergy T Stick Dual RC",
1661 .cold_ids = { 1648 .cold_ids = {
1662 &af9015_usb_table[CINERGY_T_DUAL_RC], 1649 &af9015_usb_table[CINERGY_T_DUAL_RC],
1663 NULL
1664 }, 1650 },
1665 .warm_ids = {NULL}, 1651 }, {
1666 },
1667 {
1668 .name = "AverMedia AVerTV Red HD+ (A850T)", 1652 .name = "AverMedia AVerTV Red HD+ (A850T)",
1669 .cold_ids = { 1653 .cold_ids = {
1670 &af9015_usb_table[AVERTV_A850T], 1654 &af9015_usb_table[AVERTV_A850T],
1671 NULL
1672 }, 1655 },
1673 .warm_ids = {NULL},
1674 }, 1656 },
1675 } 1657 }
1676 }, { 1658 }, {
@@ -1686,43 +1668,44 @@ static struct dvb_usb_device_properties af9015_properties[] = {
1686 .num_adapters = 2, 1668 .num_adapters = 2,
1687 .adapter = { 1669 .adapter = {
1688 { 1670 {
1689 .num_frontends = 1, 1671 .num_frontends = 1,
1690 .fe = {{ 1672 .fe = {
1691 .caps = DVB_USB_ADAP_HAS_PID_FILTER | 1673 {
1692 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, 1674 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
1693 1675 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
1694 .pid_filter_count = 32, 1676
1695 .pid_filter = af9015_pid_filter, 1677 .pid_filter_count = 32,
1696 .pid_filter_ctrl = af9015_pid_filter_ctrl, 1678 .pid_filter = af9015_pid_filter,
1697 1679 .pid_filter_ctrl = af9015_pid_filter_ctrl,
1698 .frontend_attach = 1680
1699 af9015_af9013_frontend_attach, 1681 .frontend_attach = af9015_af9013_frontend_attach,
1700 .tuner_attach = af9015_tuner_attach, 1682 .tuner_attach = af9015_tuner_attach,
1701 .stream = { 1683 .stream = {
1702 .type = USB_BULK, 1684 .type = USB_BULK,
1703 .count = 6, 1685 .count = 6,
1704 .endpoint = 0x84, 1686 .endpoint = 0x84,
1687 },
1688 }
1705 }, 1689 },
1706 }},
1707 }, 1690 },
1708 { 1691 {
1709 .num_frontends = 1, 1692 .num_frontends = 1,
1710 .fe = {{ 1693 .fe = {
1711 .frontend_attach = 1694 {
1712 af9015_af9013_frontend_attach, 1695 .frontend_attach = af9015_af9013_frontend_attach,
1713 .tuner_attach = af9015_tuner_attach, 1696 .tuner_attach = af9015_tuner_attach,
1714 .stream = { 1697 .stream = {
1715 .type = USB_BULK, 1698 .type = USB_BULK,
1716 .count = 6, 1699 .count = 6,
1717 .endpoint = 0x85, 1700 .endpoint = 0x85,
1718 .u = { 1701 .u = {
1719 .bulk = { 1702 .bulk = {
1720 .buffersize = 1703 .buffersize = TS_USB20_FRAME_SIZE,
1721 TS_USB20_FRAME_SIZE, 1704 }
1722 } 1705 }
1706 },
1723 } 1707 }
1724 }, 1708 },
1725 }},
1726 } 1709 }
1727 }, 1710 },
1728 1711
@@ -1744,51 +1727,33 @@ static struct dvb_usb_device_properties af9015_properties[] = {
1744 .name = "Xtensions XD-380", 1727 .name = "Xtensions XD-380",
1745 .cold_ids = { 1728 .cold_ids = {
1746 &af9015_usb_table[XTENSIONS_380U], 1729 &af9015_usb_table[XTENSIONS_380U],
1747 NULL
1748 }, 1730 },
1749 .warm_ids = {NULL}, 1731 }, {
1750 },
1751 {
1752 .name = "MSI DIGIVOX Duo", 1732 .name = "MSI DIGIVOX Duo",
1753 .cold_ids = { 1733 .cold_ids = {
1754 &af9015_usb_table[MSI_DIGIVOX_DUO], 1734 &af9015_usb_table[MSI_DIGIVOX_DUO],
1755 NULL
1756 }, 1735 },
1757 .warm_ids = {NULL}, 1736 }, {
1758 },
1759 {
1760 .name = "Fujitsu-Siemens Slim Mobile USB DVB-T", 1737 .name = "Fujitsu-Siemens Slim Mobile USB DVB-T",
1761 .cold_ids = { 1738 .cold_ids = {
1762 &af9015_usb_table[AVERTV_VOLAR_X_REV2], 1739 &af9015_usb_table[AVERTV_VOLAR_X_REV2],
1763 NULL
1764 }, 1740 },
1765 .warm_ids = {NULL}, 1741 }, {
1766 },
1767 {
1768 .name = "Telestar Starstick 2", 1742 .name = "Telestar Starstick 2",
1769 .cold_ids = { 1743 .cold_ids = {
1770 &af9015_usb_table[TELESTAR_STARSTICK_2], 1744 &af9015_usb_table[TELESTAR_STARSTICK_2],
1771 NULL
1772 }, 1745 },
1773 .warm_ids = {NULL}, 1746 }, {
1774 },
1775 {
1776 .name = "AVerMedia A309", 1747 .name = "AVerMedia A309",
1777 .cold_ids = { 1748 .cold_ids = {
1778 &af9015_usb_table[AVERMEDIA_A309_USB], 1749 &af9015_usb_table[AVERMEDIA_A309_USB],
1779 NULL
1780 }, 1750 },
1781 .warm_ids = {NULL}, 1751 }, {
1782 },
1783 {
1784 .name = "MSI Digi VOX mini III", 1752 .name = "MSI Digi VOX mini III",
1785 .cold_ids = { 1753 .cold_ids = {
1786 &af9015_usb_table[MSI_DIGIVOX_MINI_III], 1754 &af9015_usb_table[MSI_DIGIVOX_MINI_III],
1787 NULL
1788 }, 1755 },
1789 .warm_ids = {NULL}, 1756 }, {
1790 },
1791 {
1792 .name = "KWorld USB DVB-T TV Stick II " \ 1757 .name = "KWorld USB DVB-T TV Stick II " \
1793 "(VS-DVB-T 395U)", 1758 "(VS-DVB-T 395U)",
1794 .cold_ids = { 1759 .cold_ids = {
@@ -1796,34 +1761,23 @@ static struct dvb_usb_device_properties af9015_properties[] = {
1796 &af9015_usb_table[KWORLD_E39B], 1761 &af9015_usb_table[KWORLD_E39B],
1797 &af9015_usb_table[KWORLD_E395], 1762 &af9015_usb_table[KWORLD_E395],
1798 &af9015_usb_table[KWORLD_E39A], 1763 &af9015_usb_table[KWORLD_E39A],
1799 NULL
1800 }, 1764 },
1801 .warm_ids = {NULL}, 1765 }, {
1802 },
1803 {
1804 .name = "TrekStor DVB-T USB Stick", 1766 .name = "TrekStor DVB-T USB Stick",
1805 .cold_ids = { 1767 .cold_ids = {
1806 &af9015_usb_table[TREKSTOR_DVBT], 1768 &af9015_usb_table[TREKSTOR_DVBT],
1807 NULL
1808 }, 1769 },
1809 .warm_ids = {NULL}, 1770 }, {
1810 },
1811 {
1812 .name = "AverMedia AVerTV Volar Black HD " \ 1771 .name = "AverMedia AVerTV Volar Black HD " \
1813 "(A850)", 1772 "(A850)",
1814 .cold_ids = { 1773 .cold_ids = {
1815 &af9015_usb_table[AVERTV_A850], 1774 &af9015_usb_table[AVERTV_A850],
1816 NULL
1817 }, 1775 },
1818 .warm_ids = {NULL}, 1776 }, {
1819 },
1820 {
1821 .name = "Sveon STV22 Dual USB DVB-T Tuner HDTV", 1777 .name = "Sveon STV22 Dual USB DVB-T Tuner HDTV",
1822 .cold_ids = { 1778 .cold_ids = {
1823 &af9015_usb_table[SVEON_STV22], 1779 &af9015_usb_table[SVEON_STV22],
1824 NULL
1825 }, 1780 },
1826 .warm_ids = {NULL},
1827 }, 1781 },
1828 } 1782 }
1829 }, { 1783 }, {
@@ -1839,43 +1793,44 @@ static struct dvb_usb_device_properties af9015_properties[] = {
1839 .num_adapters = 2, 1793 .num_adapters = 2,
1840 .adapter = { 1794 .adapter = {
1841 { 1795 {
1842 .num_frontends = 1, 1796 .num_frontends = 1,
1843 .fe = {{ 1797 .fe = {
1844 .caps = DVB_USB_ADAP_HAS_PID_FILTER | 1798 {
1845 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, 1799 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
1846 1800 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
1847 .pid_filter_count = 32, 1801
1848 .pid_filter = af9015_pid_filter, 1802 .pid_filter_count = 32,
1849 .pid_filter_ctrl = af9015_pid_filter_ctrl, 1803 .pid_filter = af9015_pid_filter,
1850 1804 .pid_filter_ctrl = af9015_pid_filter_ctrl,
1851 .frontend_attach = 1805
1852 af9015_af9013_frontend_attach, 1806 .frontend_attach = af9015_af9013_frontend_attach,
1853 .tuner_attach = af9015_tuner_attach, 1807 .tuner_attach = af9015_tuner_attach,
1854 .stream = { 1808 .stream = {
1855 .type = USB_BULK, 1809 .type = USB_BULK,
1856 .count = 6, 1810 .count = 6,
1857 .endpoint = 0x84, 1811 .endpoint = 0x84,
1812 },
1813 }
1858 }, 1814 },
1859 }},
1860 }, 1815 },
1861 { 1816 {
1862 .num_frontends = 1, 1817 .num_frontends = 1,
1863 .fe = {{ 1818 .fe = {
1864 .frontend_attach = 1819 {
1865 af9015_af9013_frontend_attach, 1820 .frontend_attach = af9015_af9013_frontend_attach,
1866 .tuner_attach = af9015_tuner_attach, 1821 .tuner_attach = af9015_tuner_attach,
1867 .stream = { 1822 .stream = {
1868 .type = USB_BULK, 1823 .type = USB_BULK,
1869 .count = 6, 1824 .count = 6,
1870 .endpoint = 0x85, 1825 .endpoint = 0x85,
1871 .u = { 1826 .u = {
1872 .bulk = { 1827 .bulk = {
1873 .buffersize = 1828 .buffersize = TS_USB20_FRAME_SIZE,
1874 TS_USB20_FRAME_SIZE, 1829 }
1875 } 1830 }
1831 },
1876 } 1832 }
1877 }, 1833 },
1878 }},
1879 } 1834 }
1880 }, 1835 },
1881 1836
@@ -1897,76 +1852,50 @@ static struct dvb_usb_device_properties af9015_properties[] = {
1897 .name = "AverMedia AVerTV Volar GPS 805 (A805)", 1852 .name = "AverMedia AVerTV Volar GPS 805 (A805)",
1898 .cold_ids = { 1853 .cold_ids = {
1899 &af9015_usb_table[AVERTV_A805], 1854 &af9015_usb_table[AVERTV_A805],
1900 NULL
1901 }, 1855 },
1902 .warm_ids = {NULL}, 1856 }, {
1903 },
1904 {
1905 .name = "Conceptronic USB2.0 DVB-T CTVDIGRCU " \ 1857 .name = "Conceptronic USB2.0 DVB-T CTVDIGRCU " \
1906 "V3.0", 1858 "V3.0",
1907 .cold_ids = { 1859 .cold_ids = {
1908 &af9015_usb_table[CONCEPTRONIC_CTVDIGRCU], 1860 &af9015_usb_table[CONCEPTRONIC_CTVDIGRCU],
1909 NULL
1910 }, 1861 },
1911 .warm_ids = {NULL}, 1862 }, {
1912 },
1913 {
1914 .name = "KWorld Digial MC-810", 1863 .name = "KWorld Digial MC-810",
1915 .cold_ids = { 1864 .cold_ids = {
1916 &af9015_usb_table[KWORLD_MC810], 1865 &af9015_usb_table[KWORLD_MC810],
1917 NULL
1918 }, 1866 },
1919 .warm_ids = {NULL}, 1867 }, {
1920 },
1921 {
1922 .name = "Genius TVGo DVB-T03", 1868 .name = "Genius TVGo DVB-T03",
1923 .cold_ids = { 1869 .cold_ids = {
1924 &af9015_usb_table[GENIUS_TVGO_DVB_T03], 1870 &af9015_usb_table[GENIUS_TVGO_DVB_T03],
1925 NULL
1926 }, 1871 },
1927 .warm_ids = {NULL}, 1872 }, {
1928 },
1929 {
1930 .name = "KWorld PlusTV DVB-T PCI Pro Card " \ 1873 .name = "KWorld PlusTV DVB-T PCI Pro Card " \
1931 "(DVB-T PC160-T)", 1874 "(DVB-T PC160-T)",
1932 .cold_ids = { 1875 .cold_ids = {
1933 &af9015_usb_table[KWORLD_PC160_T], 1876 &af9015_usb_table[KWORLD_PC160_T],
1934 NULL
1935 }, 1877 },
1936 .warm_ids = {NULL}, 1878 }, {
1937 },
1938 {
1939 .name = "Sveon STV20 Tuner USB DVB-T HDTV", 1879 .name = "Sveon STV20 Tuner USB DVB-T HDTV",
1940 .cold_ids = { 1880 .cold_ids = {
1941 &af9015_usb_table[SVEON_STV20], 1881 &af9015_usb_table[SVEON_STV20],
1942 NULL
1943 }, 1882 },
1944 .warm_ids = {NULL}, 1883 }, {
1945 },
1946 {
1947 .name = "Leadtek WinFast DTV2000DS", 1884 .name = "Leadtek WinFast DTV2000DS",
1948 .cold_ids = { 1885 .cold_ids = {
1949 &af9015_usb_table[WINFAST_DTV2000DS], 1886 &af9015_usb_table[WINFAST_DTV2000DS],
1950 NULL
1951 }, 1887 },
1952 .warm_ids = {NULL}, 1888 }, {
1953 },
1954 {
1955 .name = "KWorld USB DVB-T Stick Mobile " \ 1889 .name = "KWorld USB DVB-T Stick Mobile " \
1956 "(UB383-T)", 1890 "(UB383-T)",
1957 .cold_ids = { 1891 .cold_ids = {
1958 &af9015_usb_table[KWORLD_UB383_T], 1892 &af9015_usb_table[KWORLD_UB383_T],
1959 NULL
1960 }, 1893 },
1961 .warm_ids = {NULL}, 1894 }, {
1962 },
1963 {
1964 .name = "AverMedia AVerTV Volar M (A815Mac)", 1895 .name = "AverMedia AVerTV Volar M (A815Mac)",
1965 .cold_ids = { 1896 .cold_ids = {
1966 &af9015_usb_table[AVERMEDIA_A815M], 1897 &af9015_usb_table[AVERMEDIA_A815M],
1967 NULL
1968 }, 1898 },
1969 .warm_ids = {NULL},
1970 }, 1899 },
1971 } 1900 }
1972 }, 1901 },
@@ -2019,5 +1948,5 @@ static struct usb_driver af9015_usb_driver = {
2019module_usb_driver(af9015_usb_driver); 1948module_usb_driver(af9015_usb_driver);
2020 1949
2021MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>"); 1950MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>");
2022MODULE_DESCRIPTION("Driver for Afatech AF9015 DVB-T"); 1951MODULE_DESCRIPTION("Afatech AF9015 driver");
2023MODULE_LICENSE("GPL"); 1952MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/dvb-usb/af9035.c b/drivers/media/dvb/dvb-usb/af9035.c
new file mode 100644
index 000000000000..e83b39d3993c
--- /dev/null
+++ b/drivers/media/dvb/dvb-usb/af9035.c
@@ -0,0 +1,1242 @@
1/*
2 * Afatech AF9035 DVB USB driver
3 *
4 * Copyright (C) 2009 Antti Palosaari <crope@iki.fi>
5 * Copyright (C) 2012 Antti Palosaari <crope@iki.fi>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 */
21
22#include "af9035.h"
23
24DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
25static DEFINE_MUTEX(af9035_usb_mutex);
26static struct dvb_usb_device_properties af9035_properties[2];
27static int af9035_properties_count = ARRAY_SIZE(af9035_properties);
28
29static u16 af9035_checksum(const u8 *buf, size_t len)
30{
31 size_t i;
32 u16 checksum = 0;
33
34 for (i = 1; i < len; i++) {
35 if (i % 2)
36 checksum += buf[i] << 8;
37 else
38 checksum += buf[i];
39 }
40 checksum = ~checksum;
41
42 return checksum;
43}
44
45static int af9035_ctrl_msg(struct usb_device *udev, struct usb_req *req)
46{
47#define BUF_LEN 64
48#define REQ_HDR_LEN 4 /* send header size */
49#define ACK_HDR_LEN 3 /* rece header size */
50#define CHECKSUM_LEN 2
51#define USB_TIMEOUT 2000
52
53 int ret, msg_len, act_len;
54 u8 buf[BUF_LEN];
55 static u8 seq; /* packet sequence number */
56 u16 checksum, tmp_checksum;
57
58 /* buffer overflow check */
59 if (req->wlen > (BUF_LEN - REQ_HDR_LEN - CHECKSUM_LEN) ||
60 req->rlen > (BUF_LEN - ACK_HDR_LEN - CHECKSUM_LEN)) {
61 pr_debug("%s: too much data wlen=%d rlen=%d\n", __func__,
62 req->wlen, req->rlen);
63 return -EINVAL;
64 }
65
66 if (mutex_lock_interruptible(&af9035_usb_mutex) < 0)
67 return -EAGAIN;
68
69 buf[0] = REQ_HDR_LEN + req->wlen + CHECKSUM_LEN - 1;
70 buf[1] = req->mbox;
71 buf[2] = req->cmd;
72 buf[3] = seq++;
73 if (req->wlen)
74 memcpy(&buf[4], req->wbuf, req->wlen);
75
76 /* calc and add checksum */
77 checksum = af9035_checksum(buf, buf[0] - 1);
78 buf[buf[0] - 1] = (checksum >> 8);
79 buf[buf[0] - 0] = (checksum & 0xff);
80
81 msg_len = REQ_HDR_LEN + req->wlen + CHECKSUM_LEN ;
82
83 /* send req */
84 ret = usb_bulk_msg(udev, usb_sndbulkpipe(udev, 0x02), buf, msg_len,
85 &act_len, USB_TIMEOUT);
86 if (ret < 0)
87 err("bulk message failed=%d (%d/%d)", ret, msg_len, act_len);
88 else
89 if (act_len != msg_len)
90 ret = -EIO; /* all data is not send */
91 if (ret < 0)
92 goto err_mutex_unlock;
93
94 /* no ack for those packets */
95 if (req->cmd == CMD_FW_DL)
96 goto exit_mutex_unlock;
97
98 /* receive ack and data if read req */
99 msg_len = ACK_HDR_LEN + req->rlen + CHECKSUM_LEN;
100 ret = usb_bulk_msg(udev, usb_rcvbulkpipe(udev, 0x81), buf, msg_len,
101 &act_len, USB_TIMEOUT);
102 if (ret < 0) {
103 err("recv bulk message failed=%d", ret);
104 ret = -EIO;
105 goto err_mutex_unlock;
106 }
107
108 if (act_len != msg_len) {
109 err("recv bulk message truncated (%d != %d)", act_len, msg_len);
110 ret = -EIO;
111 goto err_mutex_unlock;
112 }
113
114 /* verify checksum */
115 checksum = af9035_checksum(buf, act_len - 2);
116 tmp_checksum = (buf[act_len - 2] << 8) | buf[act_len - 1];
117 if (tmp_checksum != checksum) {
118 err("%s: command=%02x checksum mismatch (%04x != %04x)",
119 __func__, req->cmd, tmp_checksum, checksum);
120 ret = -EIO;
121 goto err_mutex_unlock;
122 }
123
124 /* check status */
125 if (buf[2]) {
126 pr_debug("%s: command=%02x failed fw error=%d\n", __func__,
127 req->cmd, buf[2]);
128 ret = -EIO;
129 goto err_mutex_unlock;
130 }
131
132 /* read request, copy returned data to return buf */
133 if (req->rlen)
134 memcpy(req->rbuf, &buf[ACK_HDR_LEN], req->rlen);
135
136err_mutex_unlock:
137exit_mutex_unlock:
138 mutex_unlock(&af9035_usb_mutex);
139
140 return ret;
141}
142
143/* write multiple registers */
144static int af9035_wr_regs(struct dvb_usb_device *d, u32 reg, u8 *val, int len)
145{
146 u8 wbuf[6 + len];
147 u8 mbox = (reg >> 16) & 0xff;
148 struct usb_req req = { CMD_MEM_WR, mbox, sizeof(wbuf), wbuf, 0, NULL };
149
150 wbuf[0] = len;
151 wbuf[1] = 2;
152 wbuf[2] = 0;
153 wbuf[3] = 0;
154 wbuf[4] = (reg >> 8) & 0xff;
155 wbuf[5] = (reg >> 0) & 0xff;
156 memcpy(&wbuf[6], val, len);
157
158 return af9035_ctrl_msg(d->udev, &req);
159}
160
161/* read multiple registers */
162static int af9035_rd_regs(struct dvb_usb_device *d, u32 reg, u8 *val, int len)
163{
164 u8 wbuf[] = { len, 2, 0, 0, (reg >> 8) & 0xff, reg & 0xff };
165 u8 mbox = (reg >> 16) & 0xff;
166 struct usb_req req = { CMD_MEM_RD, mbox, sizeof(wbuf), wbuf, len, val };
167
168 return af9035_ctrl_msg(d->udev, &req);
169}
170
171/* write single register */
172static int af9035_wr_reg(struct dvb_usb_device *d, u32 reg, u8 val)
173{
174 return af9035_wr_regs(d, reg, &val, 1);
175}
176
177/* read single register */
178static int af9035_rd_reg(struct dvb_usb_device *d, u32 reg, u8 *val)
179{
180 return af9035_rd_regs(d, reg, val, 1);
181}
182
183/* write single register with mask */
184static int af9035_wr_reg_mask(struct dvb_usb_device *d, u32 reg, u8 val,
185 u8 mask)
186{
187 int ret;
188 u8 tmp;
189
190 /* no need for read if whole reg is written */
191 if (mask != 0xff) {
192 ret = af9035_rd_regs(d, reg, &tmp, 1);
193 if (ret)
194 return ret;
195
196 val &= mask;
197 tmp &= ~mask;
198 val |= tmp;
199 }
200
201 return af9035_wr_regs(d, reg, &val, 1);
202}
203
204static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
205 struct i2c_msg msg[], int num)
206{
207 struct dvb_usb_device *d = i2c_get_adapdata(adap);
208 struct state *state = d->priv;
209 int ret;
210
211 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
212 return -EAGAIN;
213
214 /*
215 * I2C sub header is 5 bytes long. Meaning of those bytes are:
216 * 0: data len
217 * 1: I2C addr << 1
218 * 2: reg addr len
219 * byte 3 and 4 can be used as reg addr
220 * 3: reg addr MSB
221 * used when reg addr len is set to 2
222 * 4: reg addr LSB
223 * used when reg addr len is set to 1 or 2
224 *
225 * For the simplify we do not use register addr at all.
226 * NOTE: As a firmware knows tuner type there is very small possibility
227 * there could be some tuner I2C hacks done by firmware and this may
228 * lead problems if firmware expects those bytes are used.
229 */
230 if (num == 2 && !(msg[0].flags & I2C_M_RD) &&
231 (msg[1].flags & I2C_M_RD)) {
232 if (msg[0].len > 40 || msg[1].len > 40) {
233 /* TODO: correct limits > 40 */
234 ret = -EOPNOTSUPP;
235 } else if (msg[0].addr == state->af9033_config[0].i2c_addr) {
236 /* integrated demod */
237 u32 reg = msg[0].buf[0] << 16 | msg[0].buf[1] << 8 |
238 msg[0].buf[2];
239 ret = af9035_rd_regs(d, reg, &msg[1].buf[0],
240 msg[1].len);
241 } else {
242 /* I2C */
243 u8 buf[5 + msg[0].len];
244 struct usb_req req = { CMD_I2C_RD, 0, sizeof(buf),
245 buf, msg[1].len, msg[1].buf };
246 buf[0] = msg[1].len;
247 buf[1] = msg[0].addr << 1;
248 buf[2] = 0x00; /* reg addr len */
249 buf[3] = 0x00; /* reg addr MSB */
250 buf[4] = 0x00; /* reg addr LSB */
251 memcpy(&buf[5], msg[0].buf, msg[0].len);
252 ret = af9035_ctrl_msg(d->udev, &req);
253 }
254 } else if (num == 1 && !(msg[0].flags & I2C_M_RD)) {
255 if (msg[0].len > 40) {
256 /* TODO: correct limits > 40 */
257 ret = -EOPNOTSUPP;
258 } else if (msg[0].addr == state->af9033_config[0].i2c_addr) {
259 /* integrated demod */
260 u32 reg = msg[0].buf[0] << 16 | msg[0].buf[1] << 8 |
261 msg[0].buf[2];
262 ret = af9035_wr_regs(d, reg, &msg[0].buf[3],
263 msg[0].len - 3);
264 } else {
265 /* I2C */
266 u8 buf[5 + msg[0].len];
267 struct usb_req req = { CMD_I2C_WR, 0, sizeof(buf), buf,
268 0, NULL };
269 buf[0] = msg[0].len;
270 buf[1] = msg[0].addr << 1;
271 buf[2] = 0x00; /* reg addr len */
272 buf[3] = 0x00; /* reg addr MSB */
273 buf[4] = 0x00; /* reg addr LSB */
274 memcpy(&buf[5], msg[0].buf, msg[0].len);
275 ret = af9035_ctrl_msg(d->udev, &req);
276 }
277 } else {
278 /*
279 * We support only two kind of I2C transactions:
280 * 1) 1 x read + 1 x write
281 * 2) 1 x write
282 */
283 ret = -EOPNOTSUPP;
284 }
285
286 mutex_unlock(&d->i2c_mutex);
287
288 if (ret < 0)
289 return ret;
290 else
291 return num;
292}
293
294static u32 af9035_i2c_functionality(struct i2c_adapter *adapter)
295{
296 return I2C_FUNC_I2C;
297}
298
299static struct i2c_algorithm af9035_i2c_algo = {
300 .master_xfer = af9035_i2c_master_xfer,
301 .functionality = af9035_i2c_functionality,
302};
303
304#define AF9035_POLL 250
305static int af9035_rc_query(struct dvb_usb_device *d)
306{
307 unsigned int key;
308 unsigned char b[4];
309 int ret;
310 struct usb_req req = { CMD_IR_GET, 0, 0, NULL, 4, b };
311
312 ret = af9035_ctrl_msg(d->udev, &req);
313 if (ret < 0)
314 goto err;
315
316 if ((b[2] + b[3]) == 0xff) {
317 if ((b[0] + b[1]) == 0xff) {
318 /* NEC */
319 key = b[0] << 8 | b[2];
320 } else {
321 /* ext. NEC */
322 key = b[0] << 16 | b[1] << 8 | b[2];
323 }
324 } else {
325 key = b[0] << 24 | b[1] << 16 | b[2] << 8 | b[3];
326 }
327
328 rc_keydown(d->rc_dev, key, 0);
329
330err:
331 /* ignore errors */
332 return 0;
333}
334
335static int af9035_init(struct dvb_usb_device *d)
336{
337 struct state *state = d->priv;
338 int ret, i;
339 u16 frame_size = 87 * 188 / 4;
340 u8 packet_size = 512 / 4;
341 struct reg_val_mask tab[] = {
342 { 0x80f99d, 0x01, 0x01 },
343 { 0x80f9a4, 0x01, 0x01 },
344 { 0x00dd11, 0x00, 0x20 },
345 { 0x00dd11, 0x00, 0x40 },
346 { 0x00dd13, 0x00, 0x20 },
347 { 0x00dd13, 0x00, 0x40 },
348 { 0x00dd11, 0x20, 0x20 },
349 { 0x00dd88, (frame_size >> 0) & 0xff, 0xff},
350 { 0x00dd89, (frame_size >> 8) & 0xff, 0xff},
351 { 0x00dd0c, packet_size, 0xff},
352 { 0x00dd11, state->dual_mode << 6, 0x40 },
353 { 0x00dd8a, (frame_size >> 0) & 0xff, 0xff},
354 { 0x00dd8b, (frame_size >> 8) & 0xff, 0xff},
355 { 0x00dd0d, packet_size, 0xff },
356 { 0x80f9a3, 0x00, 0x01 },
357 { 0x80f9cd, 0x00, 0x01 },
358 { 0x80f99d, 0x00, 0x01 },
359 { 0x80f9a4, 0x00, 0x01 },
360 };
361
362 pr_debug("%s: USB speed=%d frame_size=%04x packet_size=%02x\n",
363 __func__, d->udev->speed, frame_size, packet_size);
364
365 /* init endpoints */
366 for (i = 0; i < ARRAY_SIZE(tab); i++) {
367 ret = af9035_wr_reg_mask(d, tab[i].reg, tab[i].val,
368 tab[i].mask);
369 if (ret < 0)
370 goto err;
371 }
372
373 return 0;
374
375err:
376 pr_debug("%s: failed=%d\n", __func__, ret);
377
378 return ret;
379}
380
381static int af9035_identify_state(struct usb_device *udev,
382 struct dvb_usb_device_properties *props,
383 struct dvb_usb_device_description **desc,
384 int *cold)
385{
386 int ret;
387 u8 wbuf[1] = { 1 };
388 u8 rbuf[4];
389 struct usb_req req = { CMD_FW_QUERYINFO, 0, sizeof(wbuf), wbuf,
390 sizeof(rbuf), rbuf };
391
392 ret = af9035_ctrl_msg(udev, &req);
393 if (ret < 0)
394 goto err;
395
396 pr_debug("%s: reply=%02x %02x %02x %02x\n", __func__,
397 rbuf[0], rbuf[1], rbuf[2], rbuf[3]);
398 if (rbuf[0] || rbuf[1] || rbuf[2] || rbuf[3])
399 *cold = 0;
400 else
401 *cold = 1;
402
403 return 0;
404
405err:
406 pr_debug("%s: failed=%d\n", __func__, ret);
407
408 return ret;
409}
410
411static int af9035_download_firmware(struct usb_device *udev,
412 const struct firmware *fw)
413{
414 int ret, i, j, len;
415 u8 wbuf[1];
416 u8 rbuf[4];
417 struct usb_req req = { 0, 0, 0, NULL, 0, NULL };
418 struct usb_req req_fw_dl = { CMD_FW_DL, 0, 0, wbuf, 0, NULL };
419 struct usb_req req_fw_ver = { CMD_FW_QUERYINFO, 0, 1, wbuf, 4, rbuf } ;
420 u8 hdr_core;
421 u16 hdr_addr, hdr_data_len, hdr_checksum;
422 #define MAX_DATA 58
423 #define HDR_SIZE 7
424
425 /*
426 * Thanks to Daniel Glöckner <daniel-gl@gmx.net> about that info!
427 *
428 * byte 0: MCS 51 core
429 * There are two inside the AF9035 (1=Link and 2=OFDM) with separate
430 * address spaces
431 * byte 1-2: Big endian destination address
432 * byte 3-4: Big endian number of data bytes following the header
433 * byte 5-6: Big endian header checksum, apparently ignored by the chip
434 * Calculated as ~(h[0]*256+h[1]+h[2]*256+h[3]+h[4]*256)
435 */
436
437 for (i = fw->size; i > HDR_SIZE;) {
438 hdr_core = fw->data[fw->size - i + 0];
439 hdr_addr = fw->data[fw->size - i + 1] << 8;
440 hdr_addr |= fw->data[fw->size - i + 2] << 0;
441 hdr_data_len = fw->data[fw->size - i + 3] << 8;
442 hdr_data_len |= fw->data[fw->size - i + 4] << 0;
443 hdr_checksum = fw->data[fw->size - i + 5] << 8;
444 hdr_checksum |= fw->data[fw->size - i + 6] << 0;
445
446 pr_debug("%s: core=%d addr=%04x data_len=%d checksum=%04x\n",
447 __func__, hdr_core, hdr_addr, hdr_data_len,
448 hdr_checksum);
449
450 if (((hdr_core != 1) && (hdr_core != 2)) ||
451 (hdr_data_len > i)) {
452 pr_debug("%s: bad firmware\n", __func__);
453 break;
454 }
455
456 /* download begin packet */
457 req.cmd = CMD_FW_DL_BEGIN;
458 ret = af9035_ctrl_msg(udev, &req);
459 if (ret < 0)
460 goto err;
461
462 /* download firmware packet(s) */
463 for (j = HDR_SIZE + hdr_data_len; j > 0; j -= MAX_DATA) {
464 len = j;
465 if (len > MAX_DATA)
466 len = MAX_DATA;
467 req_fw_dl.wlen = len;
468 req_fw_dl.wbuf = (u8 *) &fw->data[fw->size - i +
469 HDR_SIZE + hdr_data_len - j];
470 ret = af9035_ctrl_msg(udev, &req_fw_dl);
471 if (ret < 0)
472 goto err;
473 }
474
475 /* download end packet */
476 req.cmd = CMD_FW_DL_END;
477 ret = af9035_ctrl_msg(udev, &req);
478 if (ret < 0)
479 goto err;
480
481 i -= hdr_data_len + HDR_SIZE;
482
483 pr_debug("%s: data uploaded=%zu\n", __func__, fw->size - i);
484 }
485
486 /* firmware loaded, request boot */
487 req.cmd = CMD_FW_BOOT;
488 ret = af9035_ctrl_msg(udev, &req);
489 if (ret < 0)
490 goto err;
491
492 /* ensure firmware starts */
493 wbuf[0] = 1;
494 ret = af9035_ctrl_msg(udev, &req_fw_ver);
495 if (ret < 0)
496 goto err;
497
498 if (!(rbuf[0] || rbuf[1] || rbuf[2] || rbuf[3])) {
499 info("firmware did not run");
500 ret = -ENODEV;
501 goto err;
502 }
503
504 info("firmware version=%d.%d.%d.%d", rbuf[0], rbuf[1], rbuf[2],
505 rbuf[3]);
506
507 return 0;
508
509err:
510 pr_debug("%s: failed=%d\n", __func__, ret);
511
512 return ret;
513}
514
515static int af9035_download_firmware_it9135(struct usb_device *udev,
516 const struct firmware *fw)
517{
518 int ret, i, i_prev;
519 u8 wbuf[1];
520 u8 rbuf[4];
521 struct usb_req req = { 0, 0, 0, NULL, 0, NULL };
522 struct usb_req req_fw_dl = { CMD_FW_SCATTER_WR, 0, 0, NULL, 0, NULL };
523 struct usb_req req_fw_ver = { CMD_FW_QUERYINFO, 0, 1, wbuf, 4, rbuf } ;
524 #define HDR_SIZE 7
525
526 /*
527 * There seems to be following firmware header. Meaning of bytes 0-3
528 * is unknown.
529 *
530 * 0: 3
531 * 1: 0, 1
532 * 2: 0
533 * 3: 1, 2, 3
534 * 4: addr MSB
535 * 5: addr LSB
536 * 6: count of data bytes ?
537 */
538
539 for (i = HDR_SIZE, i_prev = 0; i <= fw->size; i++) {
540 if (i == fw->size ||
541 (fw->data[i + 0] == 0x03 &&
542 (fw->data[i + 1] == 0x00 ||
543 fw->data[i + 1] == 0x01) &&
544 fw->data[i + 2] == 0x00)) {
545 req_fw_dl.wlen = i - i_prev;
546 req_fw_dl.wbuf = (u8 *) &fw->data[i_prev];
547 i_prev = i;
548 ret = af9035_ctrl_msg(udev, &req_fw_dl);
549 if (ret < 0)
550 goto err;
551
552 pr_debug("%s: data uploaded=%d\n", __func__, i);
553 }
554 }
555
556 /* firmware loaded, request boot */
557 req.cmd = CMD_FW_BOOT;
558 ret = af9035_ctrl_msg(udev, &req);
559 if (ret < 0)
560 goto err;
561
562 /* ensure firmware starts */
563 wbuf[0] = 1;
564 ret = af9035_ctrl_msg(udev, &req_fw_ver);
565 if (ret < 0)
566 goto err;
567
568 if (!(rbuf[0] || rbuf[1] || rbuf[2] || rbuf[3])) {
569 info("firmware did not run");
570 ret = -ENODEV;
571 goto err;
572 }
573
574 info("firmware version=%d.%d.%d.%d", rbuf[0], rbuf[1], rbuf[2],
575 rbuf[3]);
576
577 return 0;
578
579err:
580 pr_debug("%s: failed=%d\n", __func__, ret);
581
582 return ret;
583}
584
585/* abuse that callback as there is no better one for reading eeprom */
586static int af9035_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
587{
588 struct state *state = d->priv;
589 int ret, i, eeprom_shift = 0;
590 u8 tmp;
591 u16 tmp16;
592
593 /* check if there is dual tuners */
594 ret = af9035_rd_reg(d, EEPROM_DUAL_MODE, &tmp);
595 if (ret < 0)
596 goto err;
597
598 state->dual_mode = tmp;
599 pr_debug("%s: dual mode=%d\n", __func__, state->dual_mode);
600
601 for (i = 0; i < af9035_properties[0].num_adapters; i++) {
602 /* tuner */
603 ret = af9035_rd_reg(d, EEPROM_1_TUNER_ID + eeprom_shift, &tmp);
604 if (ret < 0)
605 goto err;
606
607 state->af9033_config[i].tuner = tmp;
608 pr_debug("%s: [%d]tuner=%02x\n", __func__, i, tmp);
609
610 switch (tmp) {
611 case AF9033_TUNER_TUA9001:
612 case AF9033_TUNER_FC0011:
613 case AF9033_TUNER_MXL5007T:
614 case AF9033_TUNER_TDA18218:
615 state->af9033_config[i].spec_inv = 1;
616 break;
617 default:
618 warn("tuner ID=%02x not supported, please report!",
619 tmp);
620 };
621
622 /* tuner IF frequency */
623 ret = af9035_rd_reg(d, EEPROM_1_IFFREQ_L + eeprom_shift, &tmp);
624 if (ret < 0)
625 goto err;
626
627 tmp16 = tmp;
628
629 ret = af9035_rd_reg(d, EEPROM_1_IFFREQ_H + eeprom_shift, &tmp);
630 if (ret < 0)
631 goto err;
632
633 tmp16 |= tmp << 8;
634
635 pr_debug("%s: [%d]IF=%d\n", __func__, i, tmp16);
636
637 eeprom_shift = 0x10; /* shift for the 2nd tuner params */
638 }
639
640 /* get demod clock */
641 ret = af9035_rd_reg(d, 0x00d800, &tmp);
642 if (ret < 0)
643 goto err;
644
645 tmp = (tmp >> 0) & 0x0f;
646
647 for (i = 0; i < af9035_properties[0].num_adapters; i++)
648 state->af9033_config[i].clock = clock_lut[tmp];
649
650 ret = af9035_rd_reg(d, EEPROM_IR_MODE, &tmp);
651 if (ret < 0)
652 goto err;
653 pr_debug("%s: ir_mode=%02x\n", __func__, tmp);
654
655 /* don't activate rc if in HID mode or if not available */
656 if (tmp == 5) {
657 ret = af9035_rd_reg(d, EEPROM_IR_TYPE, &tmp);
658 if (ret < 0)
659 goto err;
660 pr_debug("%s: ir_type=%02x\n", __func__, tmp);
661
662 switch (tmp) {
663 case 0: /* NEC */
664 default:
665 d->props.rc.core.protocol = RC_TYPE_NEC;
666 d->props.rc.core.allowed_protos = RC_TYPE_NEC;
667 break;
668 case 1: /* RC6 */
669 d->props.rc.core.protocol = RC_TYPE_RC6;
670 d->props.rc.core.allowed_protos = RC_TYPE_RC6;
671 break;
672 }
673 d->props.rc.core.rc_query = af9035_rc_query;
674 }
675
676 return 0;
677
678err:
679 pr_debug("%s: failed=%d\n", __func__, ret);
680
681 return ret;
682}
683
684/* abuse that callback as there is no better one for reading eeprom */
685static int af9035_read_mac_address_it9135(struct dvb_usb_device *d, u8 mac[6])
686{
687 struct state *state = d->priv;
688 int ret, i;
689 u8 tmp;
690
691 state->dual_mode = false;
692
693 /* get demod clock */
694 ret = af9035_rd_reg(d, 0x00d800, &tmp);
695 if (ret < 0)
696 goto err;
697
698 tmp = (tmp >> 0) & 0x0f;
699
700 for (i = 0; i < af9035_properties[0].num_adapters; i++)
701 state->af9033_config[i].clock = clock_lut_it9135[tmp];
702
703 return 0;
704
705err:
706 pr_debug("%s: failed=%d\n", __func__, ret);
707
708 return ret;
709}
710
711static int af9035_fc0011_tuner_callback(struct dvb_usb_device *d,
712 int cmd, int arg)
713{
714 int ret;
715
716 switch (cmd) {
717 case FC0011_FE_CALLBACK_POWER:
718 /* Tuner enable */
719 ret = af9035_wr_reg_mask(d, 0xd8eb, 1, 1);
720 if (ret < 0)
721 goto err;
722
723 ret = af9035_wr_reg_mask(d, 0xd8ec, 1, 1);
724 if (ret < 0)
725 goto err;
726
727 ret = af9035_wr_reg_mask(d, 0xd8ed, 1, 1);
728 if (ret < 0)
729 goto err;
730
731 /* LED */
732 ret = af9035_wr_reg_mask(d, 0xd8d0, 1, 1);
733 if (ret < 0)
734 goto err;
735
736 ret = af9035_wr_reg_mask(d, 0xd8d1, 1, 1);
737 if (ret < 0)
738 goto err;
739
740 usleep_range(10000, 50000);
741 break;
742 case FC0011_FE_CALLBACK_RESET:
743 ret = af9035_wr_reg(d, 0xd8e9, 1);
744 if (ret < 0)
745 goto err;
746
747 ret = af9035_wr_reg(d, 0xd8e8, 1);
748 if (ret < 0)
749 goto err;
750
751 ret = af9035_wr_reg(d, 0xd8e7, 1);
752 if (ret < 0)
753 goto err;
754
755 usleep_range(10000, 20000);
756
757 ret = af9035_wr_reg(d, 0xd8e7, 0);
758 if (ret < 0)
759 goto err;
760
761 usleep_range(10000, 20000);
762 break;
763 default:
764 ret = -EINVAL;
765 goto err;
766 }
767
768 return 0;
769
770err:
771 pr_debug("%s: failed=%d\n", __func__, ret);
772
773 return ret;
774}
775
776static int af9035_tuner_callback(struct dvb_usb_device *d, int cmd, int arg)
777{
778 struct state *state = d->priv;
779
780 switch (state->af9033_config[0].tuner) {
781 case AF9033_TUNER_FC0011:
782 return af9035_fc0011_tuner_callback(d, cmd, arg);
783 default:
784 break;
785 }
786
787 return -ENODEV;
788}
789
790static int af9035_frontend_callback(void *adapter_priv, int component,
791 int cmd, int arg)
792{
793 struct i2c_adapter *adap = adapter_priv;
794 struct dvb_usb_device *d = i2c_get_adapdata(adap);
795
796 switch (component) {
797 case DVB_FRONTEND_COMPONENT_TUNER:
798 return af9035_tuner_callback(d, cmd, arg);
799 default:
800 break;
801 }
802
803 return -EINVAL;
804}
805
806static int af9035_frontend_attach(struct dvb_usb_adapter *adap)
807{
808 struct state *state = adap->dev->priv;
809 int ret;
810
811 if (!state->af9033_config[adap->id].tuner) {
812 /* unsupported tuner */
813 ret = -ENODEV;
814 goto err;
815 }
816
817 if (adap->id == 0) {
818 state->af9033_config[0].ts_mode = AF9033_TS_MODE_USB;
819 state->af9033_config[1].ts_mode = AF9033_TS_MODE_SERIAL;
820
821 ret = af9035_wr_reg(adap->dev, 0x00417f,
822 state->af9033_config[1].i2c_addr);
823 if (ret < 0)
824 goto err;
825
826 ret = af9035_wr_reg(adap->dev, 0x00d81a,
827 state->dual_mode);
828 if (ret < 0)
829 goto err;
830 }
831
832 /* attach demodulator */
833 adap->fe_adap[0].fe = dvb_attach(af9033_attach,
834 &state->af9033_config[adap->id], &adap->dev->i2c_adap);
835 if (adap->fe_adap[0].fe == NULL) {
836 ret = -ENODEV;
837 goto err;
838 }
839
840 /* disable I2C-gate */
841 adap->fe_adap[0].fe->ops.i2c_gate_ctrl = NULL;
842 adap->fe_adap[0].fe->callback = af9035_frontend_callback;
843
844 return 0;
845
846err:
847 pr_debug("%s: failed=%d\n", __func__, ret);
848
849 return ret;
850}
851
852static struct tua9001_config af9035_tua9001_config = {
853 .i2c_addr = 0x60,
854};
855
856static const struct fc0011_config af9035_fc0011_config = {
857 .i2c_address = 0x60,
858};
859
860static struct mxl5007t_config af9035_mxl5007t_config = {
861 .xtal_freq_hz = MxL_XTAL_24_MHZ,
862 .if_freq_hz = MxL_IF_4_57_MHZ,
863 .invert_if = 0,
864 .loop_thru_enable = 0,
865 .clk_out_enable = 0,
866 .clk_out_amp = MxL_CLKOUT_AMP_0_94V,
867};
868
869static struct tda18218_config af9035_tda18218_config = {
870 .i2c_address = 0x60,
871 .i2c_wr_max = 21,
872};
873
874static int af9035_tuner_attach(struct dvb_usb_adapter *adap)
875{
876 struct state *state = adap->dev->priv;
877 int ret;
878 struct dvb_frontend *fe;
879
880 switch (state->af9033_config[adap->id].tuner) {
881 case AF9033_TUNER_TUA9001:
882 /* AF9035 gpiot3 = TUA9001 RESETN
883 AF9035 gpiot2 = TUA9001 RXEN */
884
885 /* configure gpiot2 and gpiot2 as output */
886 ret = af9035_wr_reg_mask(adap->dev, 0x00d8ec, 0x01, 0x01);
887 if (ret < 0)
888 goto err;
889
890 ret = af9035_wr_reg_mask(adap->dev, 0x00d8ed, 0x01, 0x01);
891 if (ret < 0)
892 goto err;
893
894 ret = af9035_wr_reg_mask(adap->dev, 0x00d8e8, 0x01, 0x01);
895 if (ret < 0)
896 goto err;
897
898 ret = af9035_wr_reg_mask(adap->dev, 0x00d8e9, 0x01, 0x01);
899 if (ret < 0)
900 goto err;
901
902 /* reset tuner */
903 ret = af9035_wr_reg_mask(adap->dev, 0x00d8e7, 0x00, 0x01);
904 if (ret < 0)
905 goto err;
906
907 usleep_range(2000, 20000);
908
909 ret = af9035_wr_reg_mask(adap->dev, 0x00d8e7, 0x01, 0x01);
910 if (ret < 0)
911 goto err;
912
913 /* activate tuner RX */
914 /* TODO: use callback for TUA9001 RXEN */
915 ret = af9035_wr_reg_mask(adap->dev, 0x00d8eb, 0x01, 0x01);
916 if (ret < 0)
917 goto err;
918
919 /* attach tuner */
920 fe = dvb_attach(tua9001_attach, adap->fe_adap[0].fe,
921 &adap->dev->i2c_adap, &af9035_tua9001_config);
922 break;
923 case AF9033_TUNER_FC0011:
924 fe = dvb_attach(fc0011_attach, adap->fe_adap[0].fe,
925 &adap->dev->i2c_adap, &af9035_fc0011_config);
926 break;
927 case AF9033_TUNER_MXL5007T:
928 ret = af9035_wr_reg(adap->dev, 0x00d8e0, 1);
929 if (ret < 0)
930 goto err;
931 ret = af9035_wr_reg(adap->dev, 0x00d8e1, 1);
932 if (ret < 0)
933 goto err;
934 ret = af9035_wr_reg(adap->dev, 0x00d8df, 0);
935 if (ret < 0)
936 goto err;
937
938 msleep(30);
939
940 ret = af9035_wr_reg(adap->dev, 0x00d8df, 1);
941 if (ret < 0)
942 goto err;
943
944 msleep(300);
945
946 ret = af9035_wr_reg(adap->dev, 0x00d8c0, 1);
947 if (ret < 0)
948 goto err;
949 ret = af9035_wr_reg(adap->dev, 0x00d8c1, 1);
950 if (ret < 0)
951 goto err;
952 ret = af9035_wr_reg(adap->dev, 0x00d8bf, 0);
953 if (ret < 0)
954 goto err;
955 ret = af9035_wr_reg(adap->dev, 0x00d8b4, 1);
956 if (ret < 0)
957 goto err;
958 ret = af9035_wr_reg(adap->dev, 0x00d8b5, 1);
959 if (ret < 0)
960 goto err;
961 ret = af9035_wr_reg(adap->dev, 0x00d8b3, 1);
962 if (ret < 0)
963 goto err;
964
965 /* attach tuner */
966 fe = dvb_attach(mxl5007t_attach, adap->fe_adap[0].fe,
967 &adap->dev->i2c_adap, 0x60, &af9035_mxl5007t_config);
968 break;
969 case AF9033_TUNER_TDA18218:
970 /* attach tuner */
971 fe = dvb_attach(tda18218_attach, adap->fe_adap[0].fe,
972 &adap->dev->i2c_adap, &af9035_tda18218_config);
973 break;
974 default:
975 fe = NULL;
976 }
977
978 if (fe == NULL) {
979 ret = -ENODEV;
980 goto err;
981 }
982
983 return 0;
984
985err:
986 pr_debug("%s: failed=%d\n", __func__, ret);
987
988 return ret;
989}
990
991enum af9035_id_entry {
992 AF9035_15A4_9035,
993 AF9035_15A4_1000,
994 AF9035_15A4_1001,
995 AF9035_15A4_1002,
996 AF9035_15A4_1003,
997 AF9035_0CCD_0093,
998 AF9035_07CA_A835,
999 AF9035_07CA_B835,
1000 AF9035_07CA_1867,
1001 AF9035_07CA_A867,
1002 AF9035_07CA_0825,
1003};
1004
1005static struct usb_device_id af9035_id[] = {
1006 [AF9035_15A4_9035] = {
1007 USB_DEVICE(USB_VID_AFATECH, USB_PID_AFATECH_AF9035_9035)},
1008 [AF9035_15A4_1000] = {
1009 USB_DEVICE(USB_VID_AFATECH, USB_PID_AFATECH_AF9035_1000)},
1010 [AF9035_15A4_1001] = {
1011 USB_DEVICE(USB_VID_AFATECH, USB_PID_AFATECH_AF9035_1001)},
1012 [AF9035_15A4_1002] = {
1013 USB_DEVICE(USB_VID_AFATECH, USB_PID_AFATECH_AF9035_1002)},
1014 [AF9035_15A4_1003] = {
1015 USB_DEVICE(USB_VID_AFATECH, USB_PID_AFATECH_AF9035_1003)},
1016 [AF9035_0CCD_0093] = {
1017 USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_STICK)},
1018 [AF9035_07CA_A835] = {
1019 USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A835)},
1020 [AF9035_07CA_B835] = {
1021 USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_B835)},
1022 [AF9035_07CA_1867] = {
1023 USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_1867)},
1024 [AF9035_07CA_A867] = {
1025 USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A867)},
1026 [AF9035_07CA_0825] = {
1027 USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_TWINSTAR)},
1028 {},
1029};
1030
1031MODULE_DEVICE_TABLE(usb, af9035_id);
1032
1033static struct dvb_usb_device_properties af9035_properties[] = {
1034 {
1035 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1036
1037 .usb_ctrl = DEVICE_SPECIFIC,
1038 .download_firmware = af9035_download_firmware,
1039 .firmware = "dvb-usb-af9035-02.fw",
1040 .no_reconnect = 1,
1041
1042 .size_of_priv = sizeof(struct state),
1043
1044 .num_adapters = 1,
1045 .adapter = {
1046 {
1047 .num_frontends = 1,
1048 .fe = {
1049 {
1050 .frontend_attach = af9035_frontend_attach,
1051 .tuner_attach = af9035_tuner_attach,
1052 .stream = {
1053 .type = USB_BULK,
1054 .count = 6,
1055 .endpoint = 0x84,
1056 .u = {
1057 .bulk = {
1058 .buffersize = (87 * 188),
1059 }
1060 }
1061 }
1062 }
1063 }
1064 }
1065 },
1066
1067 .identify_state = af9035_identify_state,
1068 .read_mac_address = af9035_read_mac_address,
1069
1070 .i2c_algo = &af9035_i2c_algo,
1071
1072 .rc.core = {
1073 .protocol = RC_TYPE_UNKNOWN,
1074 .module_name = "af9035",
1075 .rc_query = NULL,
1076 .rc_interval = AF9035_POLL,
1077 .allowed_protos = RC_TYPE_UNKNOWN,
1078 .rc_codes = RC_MAP_EMPTY,
1079 },
1080 .num_device_descs = 5,
1081 .devices = {
1082 {
1083 .name = "Afatech AF9035 reference design",
1084 .cold_ids = {
1085 &af9035_id[AF9035_15A4_9035],
1086 &af9035_id[AF9035_15A4_1000],
1087 &af9035_id[AF9035_15A4_1001],
1088 &af9035_id[AF9035_15A4_1002],
1089 &af9035_id[AF9035_15A4_1003],
1090 },
1091 }, {
1092 .name = "TerraTec Cinergy T Stick",
1093 .cold_ids = {
1094 &af9035_id[AF9035_0CCD_0093],
1095 },
1096 }, {
1097 .name = "AVerMedia AVerTV Volar HD/PRO (A835)",
1098 .cold_ids = {
1099 &af9035_id[AF9035_07CA_A835],
1100 &af9035_id[AF9035_07CA_B835],
1101 },
1102 }, {
1103 .name = "AVerMedia HD Volar (A867)",
1104 .cold_ids = {
1105 &af9035_id[AF9035_07CA_1867],
1106 &af9035_id[AF9035_07CA_A867],
1107 },
1108 }, {
1109 .name = "AVerMedia Twinstar (A825)",
1110 .cold_ids = {
1111 &af9035_id[AF9035_07CA_0825],
1112 },
1113 },
1114 }
1115 },
1116 {
1117 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1118
1119 .usb_ctrl = DEVICE_SPECIFIC,
1120 .download_firmware = af9035_download_firmware_it9135,
1121 .firmware = "dvb-usb-it9135-01.fw",
1122 .no_reconnect = 1,
1123
1124 .size_of_priv = sizeof(struct state),
1125
1126 .num_adapters = 1,
1127 .adapter = {
1128 {
1129 .num_frontends = 1,
1130 .fe = {
1131 {
1132 .frontend_attach = af9035_frontend_attach,
1133 .tuner_attach = af9035_tuner_attach,
1134 .stream = {
1135 .type = USB_BULK,
1136 .count = 6,
1137 .endpoint = 0x84,
1138 .u = {
1139 .bulk = {
1140 .buffersize = (87 * 188),
1141 }
1142 }
1143 }
1144 }
1145 }
1146 }
1147 },
1148
1149 .identify_state = af9035_identify_state,
1150 .read_mac_address = af9035_read_mac_address_it9135,
1151
1152 .i2c_algo = &af9035_i2c_algo,
1153
1154 .num_device_descs = 0, /* disabled as no support for IT9135 */
1155 .devices = {
1156 {
1157 .name = "ITE Tech. IT9135 reference design",
1158 },
1159 }
1160 },
1161};
1162
1163static int af9035_usb_probe(struct usb_interface *intf,
1164 const struct usb_device_id *id)
1165{
1166 int ret, i;
1167 struct dvb_usb_device *d = NULL;
1168 struct usb_device *udev;
1169 bool found;
1170
1171 pr_debug("%s: interface=%d\n", __func__,
1172 intf->cur_altsetting->desc.bInterfaceNumber);
1173
1174 /* interface 0 is used by DVB-T receiver and
1175 interface 1 is for remote controller (HID) */
1176 if (intf->cur_altsetting->desc.bInterfaceNumber != 0)
1177 return 0;
1178
1179 /* Dynamic USB ID support. Replaces first device ID with current one. */
1180 udev = interface_to_usbdev(intf);
1181
1182 for (i = 0, found = false; i < ARRAY_SIZE(af9035_id) - 1; i++) {
1183 if (af9035_id[i].idVendor ==
1184 le16_to_cpu(udev->descriptor.idVendor) &&
1185 af9035_id[i].idProduct ==
1186 le16_to_cpu(udev->descriptor.idProduct)) {
1187 found = true;
1188 break;
1189 }
1190 }
1191
1192 if (!found) {
1193 pr_debug("%s: using dynamic ID %04x:%04x\n", __func__,
1194 le16_to_cpu(udev->descriptor.idVendor),
1195 le16_to_cpu(udev->descriptor.idProduct));
1196 af9035_properties[0].devices[0].cold_ids[0]->idVendor =
1197 le16_to_cpu(udev->descriptor.idVendor);
1198 af9035_properties[0].devices[0].cold_ids[0]->idProduct =
1199 le16_to_cpu(udev->descriptor.idProduct);
1200 }
1201
1202
1203 for (i = 0; i < af9035_properties_count; i++) {
1204 ret = dvb_usb_device_init(intf, &af9035_properties[i],
1205 THIS_MODULE, &d, adapter_nr);
1206
1207 if (ret == -ENODEV)
1208 continue;
1209 else
1210 break;
1211 }
1212
1213 if (ret < 0)
1214 goto err;
1215
1216 if (d) {
1217 ret = af9035_init(d);
1218 if (ret < 0)
1219 goto err;
1220 }
1221
1222 return 0;
1223
1224err:
1225 pr_debug("%s: failed=%d\n", __func__, ret);
1226
1227 return ret;
1228}
1229
1230/* usb specific object needed to register this driver with the usb subsystem */
1231static struct usb_driver af9035_usb_driver = {
1232 .name = "dvb_usb_af9035",
1233 .probe = af9035_usb_probe,
1234 .disconnect = dvb_usb_device_exit,
1235 .id_table = af9035_id,
1236};
1237
1238module_usb_driver(af9035_usb_driver);
1239
1240MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>");
1241MODULE_DESCRIPTION("Afatech AF9035 driver");
1242MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/dvb-usb/af9035.h b/drivers/media/dvb/dvb-usb/af9035.h
new file mode 100644
index 000000000000..481a1a43dd2a
--- /dev/null
+++ b/drivers/media/dvb/dvb-usb/af9035.h
@@ -0,0 +1,113 @@
1/*
2 * Afatech AF9035 DVB USB driver
3 *
4 * Copyright (C) 2009 Antti Palosaari <crope@iki.fi>
5 * Copyright (C) 2012 Antti Palosaari <crope@iki.fi>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 */
21
22#ifndef AF9035_H
23#define AF9035_H
24
25/* prefix for dvb-usb log writings */
26#define DVB_USB_LOG_PREFIX "af9035"
27
28#include "dvb-usb.h"
29#include "af9033.h"
30#include "tua9001.h"
31#include "fc0011.h"
32#include "mxl5007t.h"
33#include "tda18218.h"
34
35struct reg_val {
36 u32 reg;
37 u8 val;
38};
39
40struct reg_val_mask {
41 u32 reg;
42 u8 val;
43 u8 mask;
44};
45
46struct usb_req {
47 u8 cmd;
48 u8 mbox;
49 u8 wlen;
50 u8 *wbuf;
51 u8 rlen;
52 u8 *rbuf;
53};
54
55struct state {
56 bool dual_mode;
57
58 struct af9033_config af9033_config[2];
59};
60
61u32 clock_lut[] = {
62 20480000, /* FPGA */
63 16384000, /* 16.38 MHz */
64 20480000, /* 20.48 MHz */
65 36000000, /* 36.00 MHz */
66 30000000, /* 30.00 MHz */
67 26000000, /* 26.00 MHz */
68 28000000, /* 28.00 MHz */
69 32000000, /* 32.00 MHz */
70 34000000, /* 34.00 MHz */
71 24000000, /* 24.00 MHz */
72 22000000, /* 22.00 MHz */
73 12000000, /* 12.00 MHz */
74};
75
76u32 clock_lut_it9135[] = {
77 12000000, /* 12.00 MHz */
78 20480000, /* 20.48 MHz */
79 36000000, /* 36.00 MHz */
80 30000000, /* 30.00 MHz */
81 26000000, /* 26.00 MHz */
82 28000000, /* 28.00 MHz */
83 32000000, /* 32.00 MHz */
84 34000000, /* 34.00 MHz */
85 24000000, /* 24.00 MHz */
86 22000000, /* 22.00 MHz */
87};
88
89/* EEPROM locations */
90#define EEPROM_IR_MODE 0x430d
91#define EEPROM_DUAL_MODE 0x4326
92#define EEPROM_IR_TYPE 0x4329
93#define EEPROM_1_IFFREQ_L 0x432d
94#define EEPROM_1_IFFREQ_H 0x432e
95#define EEPROM_1_TUNER_ID 0x4331
96#define EEPROM_2_IFFREQ_L 0x433d
97#define EEPROM_2_IFFREQ_H 0x433e
98#define EEPROM_2_TUNER_ID 0x4341
99
100/* USB commands */
101#define CMD_MEM_RD 0x00
102#define CMD_MEM_WR 0x01
103#define CMD_I2C_RD 0x02
104#define CMD_I2C_WR 0x03
105#define CMD_IR_GET 0x18
106#define CMD_FW_DL 0x21
107#define CMD_FW_QUERYINFO 0x22
108#define CMD_FW_BOOT 0x23
109#define CMD_FW_DL_BEGIN 0x24
110#define CMD_FW_DL_END 0x25
111#define CMD_FW_SCATTER_WR 0x29
112
113#endif
diff --git a/drivers/media/dvb/dvb-usb/dib0700_core.c b/drivers/media/dvb/dvb-usb/dib0700_core.c
index 02290c60f72f..7e9e00fae04e 100644
--- a/drivers/media/dvb/dvb-usb/dib0700_core.c
+++ b/drivers/media/dvb/dvb-usb/dib0700_core.c
@@ -32,7 +32,7 @@ int dib0700_get_version(struct dvb_usb_device *d, u32 *hwversion,
32 32
33 if (mutex_lock_interruptible(&d->usb_mutex) < 0) { 33 if (mutex_lock_interruptible(&d->usb_mutex) < 0) {
34 err("could not acquire lock"); 34 err("could not acquire lock");
35 return 0; 35 return -EINTR;
36 } 36 }
37 37
38 ret = usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev, 0), 38 ret = usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev, 0),
@@ -118,7 +118,7 @@ int dib0700_set_gpio(struct dvb_usb_device *d, enum dib07x0_gpios gpio, u8 gpio_
118 118
119 if (mutex_lock_interruptible(&d->usb_mutex) < 0) { 119 if (mutex_lock_interruptible(&d->usb_mutex) < 0) {
120 err("could not acquire lock"); 120 err("could not acquire lock");
121 return 0; 121 return -EINTR;
122 } 122 }
123 123
124 st->buf[0] = REQUEST_SET_GPIO; 124 st->buf[0] = REQUEST_SET_GPIO;
@@ -139,7 +139,7 @@ static int dib0700_set_usb_xfer_len(struct dvb_usb_device *d, u16 nb_ts_packets)
139 if (st->fw_version >= 0x10201) { 139 if (st->fw_version >= 0x10201) {
140 if (mutex_lock_interruptible(&d->usb_mutex) < 0) { 140 if (mutex_lock_interruptible(&d->usb_mutex) < 0) {
141 err("could not acquire lock"); 141 err("could not acquire lock");
142 return 0; 142 return -EINTR;
143 } 143 }
144 144
145 st->buf[0] = REQUEST_SET_USB_XFER_LEN; 145 st->buf[0] = REQUEST_SET_USB_XFER_LEN;
@@ -178,7 +178,7 @@ static int dib0700_i2c_xfer_new(struct i2c_adapter *adap, struct i2c_msg *msg,
178 /* Ensure nobody else hits the i2c bus while we're sending our 178 /* Ensure nobody else hits the i2c bus while we're sending our
179 sequence of messages, (such as the remote control thread) */ 179 sequence of messages, (such as the remote control thread) */
180 if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 180 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
181 return -EAGAIN; 181 return -EINTR;
182 182
183 for (i = 0; i < num; i++) { 183 for (i = 0; i < num; i++) {
184 if (i == 0) { 184 if (i == 0) {
@@ -228,7 +228,8 @@ static int dib0700_i2c_xfer_new(struct i2c_adapter *adap, struct i2c_msg *msg,
228 /* Write request */ 228 /* Write request */
229 if (mutex_lock_interruptible(&d->usb_mutex) < 0) { 229 if (mutex_lock_interruptible(&d->usb_mutex) < 0) {
230 err("could not acquire lock"); 230 err("could not acquire lock");
231 return 0; 231 mutex_unlock(&d->i2c_mutex);
232 return -EINTR;
232 } 233 }
233 st->buf[0] = REQUEST_NEW_I2C_WRITE; 234 st->buf[0] = REQUEST_NEW_I2C_WRITE;
234 st->buf[1] = msg[i].addr << 1; 235 st->buf[1] = msg[i].addr << 1;
@@ -271,10 +272,11 @@ static int dib0700_i2c_xfer_legacy(struct i2c_adapter *adap,
271 int i,len; 272 int i,len;
272 273
273 if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 274 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
274 return -EAGAIN; 275 return -EINTR;
275 if (mutex_lock_interruptible(&d->usb_mutex) < 0) { 276 if (mutex_lock_interruptible(&d->usb_mutex) < 0) {
276 err("could not acquire lock"); 277 err("could not acquire lock");
277 return 0; 278 mutex_unlock(&d->i2c_mutex);
279 return -EINTR;
278 } 280 }
279 281
280 for (i = 0; i < num; i++) { 282 for (i = 0; i < num; i++) {
@@ -369,7 +371,7 @@ static int dib0700_set_clock(struct dvb_usb_device *d, u8 en_pll,
369 371
370 if (mutex_lock_interruptible(&d->usb_mutex) < 0) { 372 if (mutex_lock_interruptible(&d->usb_mutex) < 0) {
371 err("could not acquire lock"); 373 err("could not acquire lock");
372 return 0; 374 return -EINTR;
373 } 375 }
374 376
375 st->buf[0] = REQUEST_SET_CLOCK; 377 st->buf[0] = REQUEST_SET_CLOCK;
@@ -401,7 +403,7 @@ int dib0700_set_i2c_speed(struct dvb_usb_device *d, u16 scl_kHz)
401 403
402 if (mutex_lock_interruptible(&d->usb_mutex) < 0) { 404 if (mutex_lock_interruptible(&d->usb_mutex) < 0) {
403 err("could not acquire lock"); 405 err("could not acquire lock");
404 return 0; 406 return -EINTR;
405 } 407 }
406 408
407 st->buf[0] = REQUEST_SET_I2C_PARAM; 409 st->buf[0] = REQUEST_SET_I2C_PARAM;
@@ -561,7 +563,7 @@ int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
561 563
562 if (mutex_lock_interruptible(&adap->dev->usb_mutex) < 0) { 564 if (mutex_lock_interruptible(&adap->dev->usb_mutex) < 0) {
563 err("could not acquire lock"); 565 err("could not acquire lock");
564 return 0; 566 return -EINTR;
565 } 567 }
566 568
567 st->buf[0] = REQUEST_ENABLE_VIDEO; 569 st->buf[0] = REQUEST_ENABLE_VIDEO;
@@ -611,7 +613,7 @@ int dib0700_change_protocol(struct rc_dev *rc, u64 rc_type)
611 613
612 if (mutex_lock_interruptible(&d->usb_mutex) < 0) { 614 if (mutex_lock_interruptible(&d->usb_mutex) < 0) {
613 err("could not acquire lock"); 615 err("could not acquire lock");
614 return 0; 616 return -EINTR;
615 } 617 }
616 618
617 st->buf[0] = REQUEST_SET_RC; 619 st->buf[0] = REQUEST_SET_RC;
diff --git a/drivers/media/dvb/dvb-usb/dib0700_devices.c b/drivers/media/dvb/dvb-usb/dib0700_devices.c
index f9e966aa26e7..510001da6e83 100644
--- a/drivers/media/dvb/dvb-usb/dib0700_devices.c
+++ b/drivers/media/dvb/dvb-usb/dib0700_devices.c
@@ -3569,6 +3569,7 @@ struct usb_device_id dib0700_usb_id_table[] = {
3569 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE7090E) }, 3569 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE7090E) },
3570 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE7790E) }, 3570 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE7790E) },
3571/* 80 */{ USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE8096P) }, 3571/* 80 */{ USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE8096P) },
3572 { USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT_2) },
3572 { 0 } /* Terminating entry */ 3573 { 0 } /* Terminating entry */
3573}; 3574};
3574MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table); 3575MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
@@ -3832,7 +3833,7 @@ struct dvb_usb_device_properties dib0700_devices[] = {
3832 }, 3833 },
3833 }, 3834 },
3834 3835
3835 .num_device_descs = 11, 3836 .num_device_descs = 12,
3836 .devices = { 3837 .devices = {
3837 { "DiBcom STK7070P reference design", 3838 { "DiBcom STK7070P reference design",
3838 { &dib0700_usb_id_table[15], NULL }, 3839 { &dib0700_usb_id_table[15], NULL },
@@ -3878,6 +3879,10 @@ struct dvb_usb_device_properties dib0700_devices[] = {
3878 { &dib0700_usb_id_table[50], NULL }, 3879 { &dib0700_usb_id_table[50], NULL },
3879 { NULL }, 3880 { NULL },
3880 }, 3881 },
3882 { "Elgato EyeTV DTT rev. 2",
3883 { &dib0700_usb_id_table[81], NULL },
3884 { NULL },
3885 },
3881 }, 3886 },
3882 3887
3883 .rc.core = { 3888 .rc.core = {
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
index 397d8f232731..7a6160bf54ba 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
@@ -76,6 +76,11 @@
76#define USB_PID_AFATECH_AF9005 0x9020 76#define USB_PID_AFATECH_AF9005 0x9020
77#define USB_PID_AFATECH_AF9015_9015 0x9015 77#define USB_PID_AFATECH_AF9015_9015 0x9015
78#define USB_PID_AFATECH_AF9015_9016 0x9016 78#define USB_PID_AFATECH_AF9015_9016 0x9016
79#define USB_PID_AFATECH_AF9035_1000 0x1000
80#define USB_PID_AFATECH_AF9035_1001 0x1001
81#define USB_PID_AFATECH_AF9035_1002 0x1002
82#define USB_PID_AFATECH_AF9035_1003 0x1003
83#define USB_PID_AFATECH_AF9035_9035 0x9035
79#define USB_PID_TREKSTOR_DVBT 0x901b 84#define USB_PID_TREKSTOR_DVBT 0x901b
80#define USB_VID_ALINK_DTU 0xf170 85#define USB_VID_ALINK_DTU 0xf170
81#define USB_PID_ANSONIC_DVBT_USB 0x6000 86#define USB_PID_ANSONIC_DVBT_USB 0x6000
@@ -152,6 +157,7 @@
152#define USB_PID_KWORLD_VSTREAM_WARM 0x17df 157#define USB_PID_KWORLD_VSTREAM_WARM 0x17df
153#define USB_PID_TERRATEC_CINERGY_T_USB_XE 0x0055 158#define USB_PID_TERRATEC_CINERGY_T_USB_XE 0x0055
154#define USB_PID_TERRATEC_CINERGY_T_USB_XE_REV2 0x0069 159#define USB_PID_TERRATEC_CINERGY_T_USB_XE_REV2 0x0069
160#define USB_PID_TERRATEC_CINERGY_T_STICK 0x0093
155#define USB_PID_TERRATEC_CINERGY_T_STICK_RC 0x0097 161#define USB_PID_TERRATEC_CINERGY_T_STICK_RC 0x0097
156#define USB_PID_TERRATEC_CINERGY_T_STICK_DUAL_RC 0x0099 162#define USB_PID_TERRATEC_CINERGY_T_STICK_DUAL_RC 0x0099
157#define USB_PID_TWINHAN_VP7041_COLD 0x3201 163#define USB_PID_TWINHAN_VP7041_COLD 0x3201
@@ -221,6 +227,11 @@
221#define USB_PID_AVERMEDIA_A850T 0x850b 227#define USB_PID_AVERMEDIA_A850T 0x850b
222#define USB_PID_AVERMEDIA_A805 0xa805 228#define USB_PID_AVERMEDIA_A805 0xa805
223#define USB_PID_AVERMEDIA_A815M 0x815a 229#define USB_PID_AVERMEDIA_A815M 0x815a
230#define USB_PID_AVERMEDIA_A835 0xa835
231#define USB_PID_AVERMEDIA_B835 0xb835
232#define USB_PID_AVERMEDIA_1867 0x1867
233#define USB_PID_AVERMEDIA_A867 0xa867
234#define USB_PID_AVERMEDIA_TWINSTAR 0x0825
224#define USB_PID_TECHNOTREND_CONNECT_S2400 0x3006 235#define USB_PID_TECHNOTREND_CONNECT_S2400 0x3006
225#define USB_PID_TECHNOTREND_CONNECT_CT3650 0x300d 236#define USB_PID_TECHNOTREND_CONNECT_CT3650 0x300d
226#define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY 0x005a 237#define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY 0x005a
@@ -327,6 +338,7 @@
327#define USB_PID_MYGICA_D689 0xd811 338#define USB_PID_MYGICA_D689 0xd811
328#define USB_PID_ELGATO_EYETV_DIVERSITY 0x0011 339#define USB_PID_ELGATO_EYETV_DIVERSITY 0x0011
329#define USB_PID_ELGATO_EYETV_DTT 0x0021 340#define USB_PID_ELGATO_EYETV_DTT 0x0021
341#define USB_PID_ELGATO_EYETV_DTT_2 0x003f
330#define USB_PID_ELGATO_EYETV_DTT_Dlx 0x0020 342#define USB_PID_ELGATO_EYETV_DTT_Dlx 0x0020
331#define USB_PID_ELGATO_EYETV_SAT 0x002a 343#define USB_PID_ELGATO_EYETV_SAT 0x002a
332#define USB_PID_DVB_T_USB_STICK_HIGH_SPEED_COLD 0x5000 344#define USB_PID_DVB_T_USB_STICK_HIGH_SPEED_COLD 0x5000
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-urb.c b/drivers/media/dvb/dvb-usb/dvb-usb-urb.c
index 53a5c30b51b2..5c8f651344fc 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-urb.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-urb.c
@@ -80,6 +80,14 @@ static void dvb_usb_data_complete_204(struct usb_data_stream *stream, u8 *buffer
80 dvb_dmx_swfilter_204(&adap->demux, buffer, length); 80 dvb_dmx_swfilter_204(&adap->demux, buffer, length);
81} 81}
82 82
83static void dvb_usb_data_complete_raw(struct usb_data_stream *stream,
84 u8 *buffer, size_t length)
85{
86 struct dvb_usb_adapter *adap = stream->user_priv;
87 if (adap->feedcount > 0 && adap->state & DVB_USB_ADAP_STATE_DVB)
88 dvb_dmx_swfilter_raw(&adap->demux, buffer, length);
89}
90
83int dvb_usb_adapter_stream_init(struct dvb_usb_adapter *adap) 91int dvb_usb_adapter_stream_init(struct dvb_usb_adapter *adap)
84{ 92{
85 int i, ret = 0; 93 int i, ret = 0;
@@ -90,6 +98,10 @@ int dvb_usb_adapter_stream_init(struct dvb_usb_adapter *adap)
90 adap->fe_adap[i].stream.complete = 98 adap->fe_adap[i].stream.complete =
91 dvb_usb_data_complete_204; 99 dvb_usb_data_complete_204;
92 else 100 else
101 if (adap->props.fe[i].caps & DVB_USB_ADAP_RECEIVES_RAW_PAYLOAD)
102 adap->fe_adap[i].stream.complete =
103 dvb_usb_data_complete_raw;
104 else
93 adap->fe_adap[i].stream.complete = dvb_usb_data_complete; 105 adap->fe_adap[i].stream.complete = dvb_usb_data_complete;
94 adap->fe_adap[i].stream.user_priv = adap; 106 adap->fe_adap[i].stream.user_priv = adap;
95 ret = usb_urb_init(&adap->fe_adap[i].stream, 107 ret = usb_urb_init(&adap->fe_adap[i].stream,
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb.h b/drivers/media/dvb/dvb-usb/dvb-usb.h
index 6d7d13f9ce68..99f94409efa1 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb.h
@@ -141,6 +141,7 @@ struct dvb_usb_adapter_fe_properties {
141#define DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF 0x02 141#define DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF 0x02
142#define DVB_USB_ADAP_NEED_PID_FILTERING 0x04 142#define DVB_USB_ADAP_NEED_PID_FILTERING 0x04
143#define DVB_USB_ADAP_RECEIVES_204_BYTE_TS 0x08 143#define DVB_USB_ADAP_RECEIVES_204_BYTE_TS 0x08
144#define DVB_USB_ADAP_RECEIVES_RAW_PAYLOAD 0x10
144 int caps; 145 int caps;
145 int pid_filter_count; 146 int pid_filter_count;
146 147
@@ -156,7 +157,7 @@ struct dvb_usb_adapter_fe_properties {
156 int size_of_priv; 157 int size_of_priv;
157}; 158};
158 159
159#define MAX_NO_OF_FE_PER_ADAP 2 160#define MAX_NO_OF_FE_PER_ADAP 3
160struct dvb_usb_adapter_properties { 161struct dvb_usb_adapter_properties {
161 int size_of_priv; 162 int size_of_priv;
162 163
diff --git a/drivers/media/dvb/dvb-usb/dw2102.c b/drivers/media/dvb/dvb-usb/dw2102.c
index 451c5a7adfb2..9382895b1b88 100644
--- a/drivers/media/dvb/dvb-usb/dw2102.c
+++ b/drivers/media/dvb/dvb-usb/dw2102.c
@@ -148,7 +148,7 @@ static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
148 int num) 148 int num)
149{ 149{
150 struct dvb_usb_device *d = i2c_get_adapdata(adap); 150 struct dvb_usb_device *d = i2c_get_adapdata(adap);
151 int i = 0, ret = 0; 151 int i = 0;
152 u8 buf6[] = {0x2c, 0x05, 0xc0, 0, 0, 0, 0}; 152 u8 buf6[] = {0x2c, 0x05, 0xc0, 0, 0, 0, 0};
153 u16 value; 153 u16 value;
154 154
@@ -162,7 +162,7 @@ static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
162 /* read stv0299 register */ 162 /* read stv0299 register */
163 value = msg[0].buf[0];/* register */ 163 value = msg[0].buf[0];/* register */
164 for (i = 0; i < msg[1].len; i++) { 164 for (i = 0; i < msg[1].len; i++) {
165 ret = dw210x_op_rw(d->udev, 0xb5, value + i, 0, 165 dw210x_op_rw(d->udev, 0xb5, value + i, 0,
166 buf6, 2, DW210X_READ_MSG); 166 buf6, 2, DW210X_READ_MSG);
167 msg[1].buf[i] = buf6[0]; 167 msg[1].buf[i] = buf6[0];
168 } 168 }
@@ -174,7 +174,7 @@ static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
174 buf6[0] = 0x2a; 174 buf6[0] = 0x2a;
175 buf6[1] = msg[0].buf[0]; 175 buf6[1] = msg[0].buf[0];
176 buf6[2] = msg[0].buf[1]; 176 buf6[2] = msg[0].buf[1];
177 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0, 177 dw210x_op_rw(d->udev, 0xb2, 0, 0,
178 buf6, 3, DW210X_WRITE_MSG); 178 buf6, 3, DW210X_WRITE_MSG);
179 break; 179 break;
180 case 0x60: 180 case 0x60:
@@ -187,17 +187,17 @@ static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
187 buf6[4] = msg[0].buf[1]; 187 buf6[4] = msg[0].buf[1];
188 buf6[5] = msg[0].buf[2]; 188 buf6[5] = msg[0].buf[2];
189 buf6[6] = msg[0].buf[3]; 189 buf6[6] = msg[0].buf[3];
190 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0, 190 dw210x_op_rw(d->udev, 0xb2, 0, 0,
191 buf6, 7, DW210X_WRITE_MSG); 191 buf6, 7, DW210X_WRITE_MSG);
192 } else { 192 } else {
193 /* read from tuner */ 193 /* read from tuner */
194 ret = dw210x_op_rw(d->udev, 0xb5, 0, 0, 194 dw210x_op_rw(d->udev, 0xb5, 0, 0,
195 buf6, 1, DW210X_READ_MSG); 195 buf6, 1, DW210X_READ_MSG);
196 msg[0].buf[0] = buf6[0]; 196 msg[0].buf[0] = buf6[0];
197 } 197 }
198 break; 198 break;
199 case (DW2102_RC_QUERY): 199 case (DW2102_RC_QUERY):
200 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0, 200 dw210x_op_rw(d->udev, 0xb8, 0, 0,
201 buf6, 2, DW210X_READ_MSG); 201 buf6, 2, DW210X_READ_MSG);
202 msg[0].buf[0] = buf6[0]; 202 msg[0].buf[0] = buf6[0];
203 msg[0].buf[1] = buf6[1]; 203 msg[0].buf[1] = buf6[1];
@@ -205,7 +205,7 @@ static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
205 case (DW2102_VOLTAGE_CTRL): 205 case (DW2102_VOLTAGE_CTRL):
206 buf6[0] = 0x30; 206 buf6[0] = 0x30;
207 buf6[1] = msg[0].buf[0]; 207 buf6[1] = msg[0].buf[0];
208 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0, 208 dw210x_op_rw(d->udev, 0xb2, 0, 0,
209 buf6, 2, DW210X_WRITE_MSG); 209 buf6, 2, DW210X_WRITE_MSG);
210 break; 210 break;
211 } 211 }
@@ -221,7 +221,6 @@ static int dw2102_serit_i2c_transfer(struct i2c_adapter *adap,
221 struct i2c_msg msg[], int num) 221 struct i2c_msg msg[], int num)
222{ 222{
223 struct dvb_usb_device *d = i2c_get_adapdata(adap); 223 struct dvb_usb_device *d = i2c_get_adapdata(adap);
224 int ret = 0;
225 u8 buf6[] = {0, 0, 0, 0, 0, 0, 0}; 224 u8 buf6[] = {0, 0, 0, 0, 0, 0, 0};
226 225
227 if (!d) 226 if (!d)
@@ -235,10 +234,10 @@ static int dw2102_serit_i2c_transfer(struct i2c_adapter *adap,
235 buf6[0] = msg[0].addr << 1; 234 buf6[0] = msg[0].addr << 1;
236 buf6[1] = msg[0].len; 235 buf6[1] = msg[0].len;
237 buf6[2] = msg[0].buf[0]; 236 buf6[2] = msg[0].buf[0];
238 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0, 237 dw210x_op_rw(d->udev, 0xc2, 0, 0,
239 buf6, msg[0].len + 2, DW210X_WRITE_MSG); 238 buf6, msg[0].len + 2, DW210X_WRITE_MSG);
240 /* read si2109 register */ 239 /* read si2109 register */
241 ret = dw210x_op_rw(d->udev, 0xc3, 0xd0, 0, 240 dw210x_op_rw(d->udev, 0xc3, 0xd0, 0,
242 buf6, msg[1].len + 2, DW210X_READ_MSG); 241 buf6, msg[1].len + 2, DW210X_READ_MSG);
243 memcpy(msg[1].buf, buf6 + 2, msg[1].len); 242 memcpy(msg[1].buf, buf6 + 2, msg[1].len);
244 243
@@ -250,11 +249,11 @@ static int dw2102_serit_i2c_transfer(struct i2c_adapter *adap,
250 buf6[0] = msg[0].addr << 1; 249 buf6[0] = msg[0].addr << 1;
251 buf6[1] = msg[0].len; 250 buf6[1] = msg[0].len;
252 memcpy(buf6 + 2, msg[0].buf, msg[0].len); 251 memcpy(buf6 + 2, msg[0].buf, msg[0].len);
253 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0, buf6, 252 dw210x_op_rw(d->udev, 0xc2, 0, 0, buf6,
254 msg[0].len + 2, DW210X_WRITE_MSG); 253 msg[0].len + 2, DW210X_WRITE_MSG);
255 break; 254 break;
256 case(DW2102_RC_QUERY): 255 case(DW2102_RC_QUERY):
257 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0, 256 dw210x_op_rw(d->udev, 0xb8, 0, 0,
258 buf6, 2, DW210X_READ_MSG); 257 buf6, 2, DW210X_READ_MSG);
259 msg[0].buf[0] = buf6[0]; 258 msg[0].buf[0] = buf6[0];
260 msg[0].buf[1] = buf6[1]; 259 msg[0].buf[1] = buf6[1];
@@ -262,7 +261,7 @@ static int dw2102_serit_i2c_transfer(struct i2c_adapter *adap,
262 case(DW2102_VOLTAGE_CTRL): 261 case(DW2102_VOLTAGE_CTRL):
263 buf6[0] = 0x30; 262 buf6[0] = 0x30;
264 buf6[1] = msg[0].buf[0]; 263 buf6[1] = msg[0].buf[0];
265 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0, 264 dw210x_op_rw(d->udev, 0xb2, 0, 0,
266 buf6, 2, DW210X_WRITE_MSG); 265 buf6, 2, DW210X_WRITE_MSG);
267 break; 266 break;
268 } 267 }
@@ -276,7 +275,6 @@ static int dw2102_serit_i2c_transfer(struct i2c_adapter *adap,
276static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num) 275static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
277{ 276{
278 struct dvb_usb_device *d = i2c_get_adapdata(adap); 277 struct dvb_usb_device *d = i2c_get_adapdata(adap);
279 int ret = 0;
280 278
281 if (!d) 279 if (!d)
282 return -ENODEV; 280 return -ENODEV;
@@ -291,10 +289,10 @@ static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg ms
291 obuf[0] = msg[0].addr << 1; 289 obuf[0] = msg[0].addr << 1;
292 obuf[1] = msg[0].len; 290 obuf[1] = msg[0].len;
293 obuf[2] = msg[0].buf[0]; 291 obuf[2] = msg[0].buf[0];
294 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0, 292 dw210x_op_rw(d->udev, 0xc2, 0, 0,
295 obuf, msg[0].len + 2, DW210X_WRITE_MSG); 293 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
296 /* second read registers */ 294 /* second read registers */
297 ret = dw210x_op_rw(d->udev, 0xc3, 0xd1 , 0, 295 dw210x_op_rw(d->udev, 0xc3, 0xd1 , 0,
298 ibuf, msg[1].len + 2, DW210X_READ_MSG); 296 ibuf, msg[1].len + 2, DW210X_READ_MSG);
299 memcpy(msg[1].buf, ibuf + 2, msg[1].len); 297 memcpy(msg[1].buf, ibuf + 2, msg[1].len);
300 298
@@ -308,7 +306,7 @@ static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg ms
308 obuf[0] = msg[0].addr << 1; 306 obuf[0] = msg[0].addr << 1;
309 obuf[1] = msg[0].len; 307 obuf[1] = msg[0].len;
310 memcpy(obuf + 2, msg[0].buf, msg[0].len); 308 memcpy(obuf + 2, msg[0].buf, msg[0].len);
311 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0, 309 dw210x_op_rw(d->udev, 0xc2, 0, 0,
312 obuf, msg[0].len + 2, DW210X_WRITE_MSG); 310 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
313 break; 311 break;
314 } 312 }
@@ -318,13 +316,13 @@ static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg ms
318 obuf[0] = msg[0].addr << 1; 316 obuf[0] = msg[0].addr << 1;
319 obuf[1] = msg[0].len; 317 obuf[1] = msg[0].len;
320 memcpy(obuf + 2, msg[0].buf, msg[0].len); 318 memcpy(obuf + 2, msg[0].buf, msg[0].len);
321 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0, 319 dw210x_op_rw(d->udev, 0xc2, 0, 0,
322 obuf, msg[0].len + 2, DW210X_WRITE_MSG); 320 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
323 break; 321 break;
324 } 322 }
325 case(DW2102_RC_QUERY): { 323 case(DW2102_RC_QUERY): {
326 u8 ibuf[2]; 324 u8 ibuf[2];
327 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0, 325 dw210x_op_rw(d->udev, 0xb8, 0, 0,
328 ibuf, 2, DW210X_READ_MSG); 326 ibuf, 2, DW210X_READ_MSG);
329 memcpy(msg[0].buf, ibuf , 2); 327 memcpy(msg[0].buf, ibuf , 2);
330 break; 328 break;
@@ -333,7 +331,7 @@ static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg ms
333 u8 obuf[2]; 331 u8 obuf[2];
334 obuf[0] = 0x30; 332 obuf[0] = 0x30;
335 obuf[1] = msg[0].buf[0]; 333 obuf[1] = msg[0].buf[0];
336 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0, 334 dw210x_op_rw(d->udev, 0xb2, 0, 0,
337 obuf, 2, DW210X_WRITE_MSG); 335 obuf, 2, DW210X_WRITE_MSG);
338 break; 336 break;
339 } 337 }
@@ -349,7 +347,6 @@ static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg ms
349static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num) 347static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
350{ 348{
351 struct dvb_usb_device *d = i2c_get_adapdata(adap); 349 struct dvb_usb_device *d = i2c_get_adapdata(adap);
352 int ret = 0;
353 int len, i, j; 350 int len, i, j;
354 351
355 if (!d) 352 if (!d)
@@ -361,7 +358,7 @@ static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], i
361 switch (msg[j].addr) { 358 switch (msg[j].addr) {
362 case(DW2102_RC_QUERY): { 359 case(DW2102_RC_QUERY): {
363 u8 ibuf[2]; 360 u8 ibuf[2];
364 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0, 361 dw210x_op_rw(d->udev, 0xb8, 0, 0,
365 ibuf, 2, DW210X_READ_MSG); 362 ibuf, 2, DW210X_READ_MSG);
366 memcpy(msg[j].buf, ibuf , 2); 363 memcpy(msg[j].buf, ibuf , 2);
367 break; 364 break;
@@ -370,7 +367,7 @@ static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], i
370 u8 obuf[2]; 367 u8 obuf[2];
371 obuf[0] = 0x30; 368 obuf[0] = 0x30;
372 obuf[1] = msg[j].buf[0]; 369 obuf[1] = msg[j].buf[0];
373 ret = dw210x_op_rw(d->udev, 0xb2, 0, 0, 370 dw210x_op_rw(d->udev, 0xb2, 0, 0,
374 obuf, 2, DW210X_WRITE_MSG); 371 obuf, 2, DW210X_WRITE_MSG);
375 break; 372 break;
376 } 373 }
@@ -382,7 +379,7 @@ static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], i
382 if (msg[j].flags == I2C_M_RD) { 379 if (msg[j].flags == I2C_M_RD) {
383 /* read registers */ 380 /* read registers */
384 u8 ibuf[msg[j].len + 2]; 381 u8 ibuf[msg[j].len + 2];
385 ret = dw210x_op_rw(d->udev, 0xc3, 382 dw210x_op_rw(d->udev, 0xc3,
386 (msg[j].addr << 1) + 1, 0, 383 (msg[j].addr << 1) + 1, 0,
387 ibuf, msg[j].len + 2, 384 ibuf, msg[j].len + 2,
388 DW210X_READ_MSG); 385 DW210X_READ_MSG);
@@ -402,7 +399,7 @@ static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], i
402 do { 399 do {
403 memcpy(obuf + 3, msg[j].buf + i, 400 memcpy(obuf + 3, msg[j].buf + i,
404 (len > 16 ? 16 : len)); 401 (len > 16 ? 16 : len));
405 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0, 402 dw210x_op_rw(d->udev, 0xc2, 0, 0,
406 obuf, (len > 16 ? 16 : len) + 3, 403 obuf, (len > 16 ? 16 : len) + 3,
407 DW210X_WRITE_MSG); 404 DW210X_WRITE_MSG);
408 i += 16; 405 i += 16;
@@ -414,7 +411,7 @@ static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], i
414 obuf[0] = msg[j].addr << 1; 411 obuf[0] = msg[j].addr << 1;
415 obuf[1] = msg[j].len; 412 obuf[1] = msg[j].len;
416 memcpy(obuf + 2, msg[j].buf, msg[j].len); 413 memcpy(obuf + 2, msg[j].buf, msg[j].len);
417 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0, 414 dw210x_op_rw(d->udev, 0xc2, 0, 0,
418 obuf, msg[j].len + 2, 415 obuf, msg[j].len + 2,
419 DW210X_WRITE_MSG); 416 DW210X_WRITE_MSG);
420 } 417 }
@@ -432,7 +429,7 @@ static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
432 int num) 429 int num)
433{ 430{
434 struct dvb_usb_device *d = i2c_get_adapdata(adap); 431 struct dvb_usb_device *d = i2c_get_adapdata(adap);
435 int ret = 0, i; 432 int i;
436 433
437 if (!d) 434 if (!d)
438 return -ENODEV; 435 return -ENODEV;
@@ -447,10 +444,10 @@ static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
447 obuf[0] = msg[0].addr << 1; 444 obuf[0] = msg[0].addr << 1;
448 obuf[1] = msg[0].len; 445 obuf[1] = msg[0].len;
449 obuf[2] = msg[0].buf[0]; 446 obuf[2] = msg[0].buf[0];
450 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0, 447 dw210x_op_rw(d->udev, 0xc2, 0, 0,
451 obuf, msg[0].len + 2, DW210X_WRITE_MSG); 448 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
452 /* second read registers */ 449 /* second read registers */
453 ret = dw210x_op_rw(d->udev, 0xc3, 0x19 , 0, 450 dw210x_op_rw(d->udev, 0xc3, 0x19 , 0,
454 ibuf, msg[1].len + 2, DW210X_READ_MSG); 451 ibuf, msg[1].len + 2, DW210X_READ_MSG);
455 memcpy(msg[1].buf, ibuf + 2, msg[1].len); 452 memcpy(msg[1].buf, ibuf + 2, msg[1].len);
456 453
@@ -465,13 +462,13 @@ static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
465 obuf[0] = msg[0].addr << 1; 462 obuf[0] = msg[0].addr << 1;
466 obuf[1] = msg[0].len; 463 obuf[1] = msg[0].len;
467 memcpy(obuf + 2, msg[0].buf, msg[0].len); 464 memcpy(obuf + 2, msg[0].buf, msg[0].len);
468 ret = dw210x_op_rw(d->udev, 0xc2, 0, 0, 465 dw210x_op_rw(d->udev, 0xc2, 0, 0,
469 obuf, msg[0].len + 2, DW210X_WRITE_MSG); 466 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
470 break; 467 break;
471 } 468 }
472 case(DW2102_RC_QUERY): { 469 case(DW2102_RC_QUERY): {
473 u8 ibuf[2]; 470 u8 ibuf[2];
474 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0, 471 dw210x_op_rw(d->udev, 0xb8, 0, 0,
475 ibuf, 2, DW210X_READ_MSG); 472 ibuf, 2, DW210X_READ_MSG);
476 memcpy(msg[0].buf, ibuf , 2); 473 memcpy(msg[0].buf, ibuf , 2);
477 break; 474 break;
@@ -496,7 +493,6 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
496{ 493{
497 struct dvb_usb_device *d = i2c_get_adapdata(adap); 494 struct dvb_usb_device *d = i2c_get_adapdata(adap);
498 struct usb_device *udev; 495 struct usb_device *udev;
499 int ret = 0;
500 int len, i, j; 496 int len, i, j;
501 497
502 if (!d) 498 if (!d)
@@ -509,7 +505,7 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
509 switch (msg[j].addr) { 505 switch (msg[j].addr) {
510 case (DW2102_RC_QUERY): { 506 case (DW2102_RC_QUERY): {
511 u8 ibuf[5]; 507 u8 ibuf[5];
512 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0, 508 dw210x_op_rw(d->udev, 0xb8, 0, 0,
513 ibuf, 5, DW210X_READ_MSG); 509 ibuf, 5, DW210X_READ_MSG);
514 memcpy(msg[j].buf, ibuf + 3, 2); 510 memcpy(msg[j].buf, ibuf + 3, 2);
515 break; 511 break;
@@ -519,11 +515,11 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
519 515
520 obuf[0] = 1; 516 obuf[0] = 1;
521 obuf[1] = msg[j].buf[1];/* off-on */ 517 obuf[1] = msg[j].buf[1];/* off-on */
522 ret = dw210x_op_rw(d->udev, 0x8a, 0, 0, 518 dw210x_op_rw(d->udev, 0x8a, 0, 0,
523 obuf, 2, DW210X_WRITE_MSG); 519 obuf, 2, DW210X_WRITE_MSG);
524 obuf[0] = 3; 520 obuf[0] = 3;
525 obuf[1] = msg[j].buf[0];/* 13v-18v */ 521 obuf[1] = msg[j].buf[0];/* 13v-18v */
526 ret = dw210x_op_rw(d->udev, 0x8a, 0, 0, 522 dw210x_op_rw(d->udev, 0x8a, 0, 0,
527 obuf, 2, DW210X_WRITE_MSG); 523 obuf, 2, DW210X_WRITE_MSG);
528 break; 524 break;
529 } 525 }
@@ -532,7 +528,7 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
532 528
533 obuf[0] = 5; 529 obuf[0] = 5;
534 obuf[1] = msg[j].buf[0]; 530 obuf[1] = msg[j].buf[0];
535 ret = dw210x_op_rw(d->udev, 0x8a, 0, 0, 531 dw210x_op_rw(d->udev, 0x8a, 0, 0,
536 obuf, 2, DW210X_WRITE_MSG); 532 obuf, 2, DW210X_WRITE_MSG);
537 break; 533 break;
538 } 534 }
@@ -545,7 +541,7 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
545 if (msg[j].flags == I2C_M_RD) { 541 if (msg[j].flags == I2C_M_RD) {
546 /* read registers */ 542 /* read registers */
547 u8 ibuf[msg[j].len]; 543 u8 ibuf[msg[j].len];
548 ret = dw210x_op_rw(d->udev, 0x91, 0, 0, 544 dw210x_op_rw(d->udev, 0x91, 0, 0,
549 ibuf, msg[j].len, 545 ibuf, msg[j].len,
550 DW210X_READ_MSG); 546 DW210X_READ_MSG);
551 memcpy(msg[j].buf, ibuf, msg[j].len); 547 memcpy(msg[j].buf, ibuf, msg[j].len);
@@ -563,7 +559,7 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
563 do { 559 do {
564 memcpy(obuf + 3, msg[j].buf + i, 560 memcpy(obuf + 3, msg[j].buf + i,
565 (len > 16 ? 16 : len)); 561 (len > 16 ? 16 : len));
566 ret = dw210x_op_rw(d->udev, 0x80, 0, 0, 562 dw210x_op_rw(d->udev, 0x80, 0, 0,
567 obuf, (len > 16 ? 16 : len) + 3, 563 obuf, (len > 16 ? 16 : len) + 3,
568 DW210X_WRITE_MSG); 564 DW210X_WRITE_MSG);
569 i += 16; 565 i += 16;
@@ -575,7 +571,7 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
575 obuf[0] = msg[j + 1].len; 571 obuf[0] = msg[j + 1].len;
576 obuf[1] = (msg[j].addr << 1); 572 obuf[1] = (msg[j].addr << 1);
577 memcpy(obuf + 2, msg[j].buf, msg[j].len); 573 memcpy(obuf + 2, msg[j].buf, msg[j].len);
578 ret = dw210x_op_rw(d->udev, 574 dw210x_op_rw(d->udev,
579 udev->descriptor.idProduct == 575 udev->descriptor.idProduct ==
580 0x7500 ? 0x92 : 0x90, 0, 0, 576 0x7500 ? 0x92 : 0x90, 0, 0,
581 obuf, msg[j].len + 2, 577 obuf, msg[j].len + 2,
@@ -587,7 +583,7 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
587 obuf[0] = msg[j].len + 1; 583 obuf[0] = msg[j].len + 1;
588 obuf[1] = (msg[j].addr << 1); 584 obuf[1] = (msg[j].addr << 1);
589 memcpy(obuf + 2, msg[j].buf, msg[j].len); 585 memcpy(obuf + 2, msg[j].buf, msg[j].len);
590 ret = dw210x_op_rw(d->udev, 0x80, 0, 0, 586 dw210x_op_rw(d->udev, 0x80, 0, 0,
591 obuf, msg[j].len + 2, 587 obuf, msg[j].len + 2,
592 DW210X_WRITE_MSG); 588 DW210X_WRITE_MSG);
593 break; 589 break;
diff --git a/drivers/media/dvb/dvb-usb/it913x.c b/drivers/media/dvb/dvb-usb/it913x.c
index 482d249ca7f3..6244fe9d1a3a 100644
--- a/drivers/media/dvb/dvb-usb/it913x.c
+++ b/drivers/media/dvb/dvb-usb/it913x.c
@@ -81,7 +81,7 @@ static int it913x_bulk_write(struct usb_device *dev,
81 for (i = 0; i < IT913X_RETRY; i++) { 81 for (i = 0; i < IT913X_RETRY; i++) {
82 ret = usb_bulk_msg(dev, usb_sndbulkpipe(dev, pipe), 82 ret = usb_bulk_msg(dev, usb_sndbulkpipe(dev, pipe),
83 snd, len , &actual_l, IT913X_SND_TIMEOUT); 83 snd, len , &actual_l, IT913X_SND_TIMEOUT);
84 if (ret == 0 || ret != -EBUSY || ret != -ETIMEDOUT) 84 if (ret != -EBUSY && ret != -ETIMEDOUT)
85 break; 85 break;
86 } 86 }
87 87
@@ -99,7 +99,7 @@ static int it913x_bulk_read(struct usb_device *dev,
99 for (i = 0; i < IT913X_RETRY; i++) { 99 for (i = 0; i < IT913X_RETRY; i++) {
100 ret = usb_bulk_msg(dev, usb_rcvbulkpipe(dev, pipe), 100 ret = usb_bulk_msg(dev, usb_rcvbulkpipe(dev, pipe),
101 rev, len , &actual_l, IT913X_RCV_TIMEOUT); 101 rev, len , &actual_l, IT913X_RCV_TIMEOUT);
102 if (ret == 0 || ret != -EBUSY || ret != -ETIMEDOUT) 102 if (ret != -EBUSY && ret != -ETIMEDOUT)
103 break; 103 break;
104 } 104 }
105 105
diff --git a/drivers/media/dvb/dvb-usb/lmedm04.c b/drivers/media/dvb/dvb-usb/lmedm04.c
index 5dde06d066ff..25d1031460f8 100644
--- a/drivers/media/dvb/dvb-usb/lmedm04.c
+++ b/drivers/media/dvb/dvb-usb/lmedm04.c
@@ -373,7 +373,7 @@ static int lme2510_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff)
373 struct lme2510_state *st = adap->dev->priv; 373 struct lme2510_state *st = adap->dev->priv;
374 static u8 clear_pid_reg[] = LME_ALL_PIDS; 374 static u8 clear_pid_reg[] = LME_ALL_PIDS;
375 static u8 rbuf[1]; 375 static u8 rbuf[1];
376 int ret; 376 int ret = 0;
377 377
378 deb_info(1, "PID Clearing Filter"); 378 deb_info(1, "PID Clearing Filter");
379 379
@@ -1205,14 +1205,13 @@ static int lme2510_probe(struct usb_interface *intf,
1205 const struct usb_device_id *id) 1205 const struct usb_device_id *id)
1206{ 1206{
1207 struct usb_device *udev = interface_to_usbdev(intf); 1207 struct usb_device *udev = interface_to_usbdev(intf);
1208 int ret = 0;
1209 1208
1210 usb_reset_configuration(udev); 1209 usb_reset_configuration(udev);
1211 1210
1212 usb_set_interface(udev, intf->cur_altsetting->desc.bInterfaceNumber, 1); 1211 usb_set_interface(udev, intf->cur_altsetting->desc.bInterfaceNumber, 1);
1213 1212
1214 if (udev->speed != USB_SPEED_HIGH) { 1213 if (udev->speed != USB_SPEED_HIGH) {
1215 ret = usb_reset_device(udev); 1214 usb_reset_device(udev);
1216 info("DEV Failed to connect in HIGH SPEED mode"); 1215 info("DEV Failed to connect in HIGH SPEED mode");
1217 return -ENODEV; 1216 return -ENODEV;
1218 } 1217 }
diff --git a/drivers/media/dvb/dvb-usb/mxl111sf-tuner.c b/drivers/media/dvb/dvb-usb/mxl111sf-tuner.c
index 72db6eef4b9c..74da5bb1ce99 100644
--- a/drivers/media/dvb/dvb-usb/mxl111sf-tuner.c
+++ b/drivers/media/dvb/dvb-usb/mxl111sf-tuner.c
@@ -284,6 +284,7 @@ static int mxl111sf_tuner_set_params(struct dvb_frontend *fe)
284 284
285 switch (delsys) { 285 switch (delsys) {
286 case SYS_ATSC: 286 case SYS_ATSC:
287 case SYS_ATSCMH:
287 bw = 0; /* ATSC */ 288 bw = 0; /* ATSC */
288 break; 289 break;
289 case SYS_DVBC_ANNEX_B: 290 case SYS_DVBC_ANNEX_B:
diff --git a/drivers/media/dvb/dvb-usb/mxl111sf.c b/drivers/media/dvb/dvb-usb/mxl111sf.c
index 81305de2fea5..cd842798f5af 100644
--- a/drivers/media/dvb/dvb-usb/mxl111sf.c
+++ b/drivers/media/dvb/dvb-usb/mxl111sf.c
@@ -21,6 +21,7 @@
21#include "mxl111sf-tuner.h" 21#include "mxl111sf-tuner.h"
22 22
23#include "lgdt3305.h" 23#include "lgdt3305.h"
24#include "lg2160.h"
24 25
25int dvb_usb_mxl111sf_debug; 26int dvb_usb_mxl111sf_debug;
26module_param_named(debug, dvb_usb_mxl111sf_debug, int, 0644); 27module_param_named(debug, dvb_usb_mxl111sf_debug, int, 0644);
@@ -31,6 +32,10 @@ int dvb_usb_mxl111sf_isoc;
31module_param_named(isoc, dvb_usb_mxl111sf_isoc, int, 0644); 32module_param_named(isoc, dvb_usb_mxl111sf_isoc, int, 0644);
32MODULE_PARM_DESC(isoc, "enable usb isoc xfer (0=bulk, 1=isoc)."); 33MODULE_PARM_DESC(isoc, "enable usb isoc xfer (0=bulk, 1=isoc).");
33 34
35int dvb_usb_mxl111sf_spi;
36module_param_named(spi, dvb_usb_mxl111sf_spi, int, 0644);
37MODULE_PARM_DESC(spi, "use spi rather than tp for data xfer (0=tp, 1=spi).");
38
34#define ANT_PATH_AUTO 0 39#define ANT_PATH_AUTO 0
35#define ANT_PATH_EXTERNAL 1 40#define ANT_PATH_EXTERNAL 1
36#define ANT_PATH_INTERNAL 2 41#define ANT_PATH_INTERNAL 2
@@ -340,7 +345,6 @@ static int mxl111sf_ep6_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
340 struct mxl111sf_state *state = d->priv; 345 struct mxl111sf_state *state = d->priv;
341 struct mxl111sf_adap_state *adap_state = adap->fe_adap[adap->active_fe].priv; 346 struct mxl111sf_adap_state *adap_state = adap->fe_adap[adap->active_fe].priv;
342 int ret = 0; 347 int ret = 0;
343 u8 tmp;
344 348
345 deb_info("%s(%d)\n", __func__, onoff); 349 deb_info("%s(%d)\n", __func__, onoff);
346 350
@@ -361,6 +365,33 @@ static int mxl111sf_ep6_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
361 return ret; 365 return ret;
362} 366}
363 367
368static int mxl111sf_ep5_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
369{
370 struct dvb_usb_device *d = adap->dev;
371 struct mxl111sf_state *state = d->priv;
372 int ret = 0;
373
374 deb_info("%s(%d)\n", __func__, onoff);
375
376 if (onoff) {
377 ret = mxl111sf_enable_usb_output(state);
378 mxl_fail(ret);
379
380 ret = mxl111sf_init_i2s_port(state, 200);
381 mxl_fail(ret);
382 ret = mxl111sf_config_i2s(state, 0, 15);
383 mxl_fail(ret);
384 } else {
385 ret = mxl111sf_disable_i2s_port(state);
386 mxl_fail(ret);
387 }
388 if (state->chip_rev > MXL111SF_V6)
389 ret = mxl111sf_config_spi(state, onoff);
390 mxl_fail(ret);
391
392 return ret;
393}
394
364static int mxl111sf_ep4_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) 395static int mxl111sf_ep4_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
365{ 396{
366 struct dvb_usb_device *d = adap->dev; 397 struct dvb_usb_device *d = adap->dev;
@@ -453,6 +484,255 @@ fail:
453 return ret; 484 return ret;
454} 485}
455 486
487static struct lg2160_config hauppauge_lg2160_config = {
488 .lg_chip = LG2160,
489 .i2c_addr = 0x1c >> 1,
490 .deny_i2c_rptr = 1,
491 .spectral_inversion = 0,
492 .if_khz = 6000,
493};
494
495static int mxl111sf_lg2160_frontend_attach(struct dvb_usb_adapter *adap)
496{
497 struct dvb_usb_device *d = adap->dev;
498 struct mxl111sf_state *state = d->priv;
499 int fe_id = adap->num_frontends_initialized;
500 struct mxl111sf_adap_state *adap_state = adap->fe_adap[fe_id].priv;
501 int ret;
502
503 deb_adv("%s()\n", __func__);
504
505 /* save a pointer to the dvb_usb_device in device state */
506 state->d = d;
507 adap_state->alt_mode = (dvb_usb_mxl111sf_isoc) ? 2 : 1;
508 state->alt_mode = adap_state->alt_mode;
509
510 if (usb_set_interface(adap->dev->udev, 0, state->alt_mode) < 0)
511 err("set interface failed");
512
513 state->gpio_mode = MXL111SF_GPIO_MOD_MH;
514 adap_state->gpio_mode = state->gpio_mode;
515 adap_state->device_mode = MXL_TUNER_MODE;
516 adap_state->ep6_clockphase = 1;
517
518 ret = mxl1x1sf_soft_reset(state);
519 if (mxl_fail(ret))
520 goto fail;
521 ret = mxl111sf_init_tuner_demod(state);
522 if (mxl_fail(ret))
523 goto fail;
524
525 ret = mxl1x1sf_set_device_mode(state, adap_state->device_mode);
526 if (mxl_fail(ret))
527 goto fail;
528
529 ret = mxl111sf_enable_usb_output(state);
530 if (mxl_fail(ret))
531 goto fail;
532 ret = mxl1x1sf_top_master_ctrl(state, 1);
533 if (mxl_fail(ret))
534 goto fail;
535
536 ret = mxl111sf_init_port_expander(state);
537 if (mxl_fail(ret))
538 goto fail;
539 ret = mxl111sf_gpio_mode_switch(state, state->gpio_mode);
540 if (mxl_fail(ret))
541 goto fail;
542
543 ret = get_chip_info(state);
544 if (mxl_fail(ret))
545 goto fail;
546
547 adap->fe_adap[fe_id].fe = dvb_attach(lg2160_attach,
548 &hauppauge_lg2160_config,
549 &adap->dev->i2c_adap);
550 if (adap->fe_adap[fe_id].fe) {
551 adap_state->fe_init = adap->fe_adap[fe_id].fe->ops.init;
552 adap->fe_adap[fe_id].fe->ops.init = mxl111sf_adap_fe_init;
553 adap_state->fe_sleep = adap->fe_adap[fe_id].fe->ops.sleep;
554 adap->fe_adap[fe_id].fe->ops.sleep = mxl111sf_adap_fe_sleep;
555 return 0;
556 }
557 ret = -EIO;
558fail:
559 return ret;
560}
561
562static struct lg2160_config hauppauge_lg2161_1019_config = {
563 .lg_chip = LG2161_1019,
564 .i2c_addr = 0x1c >> 1,
565 .deny_i2c_rptr = 1,
566 .spectral_inversion = 0,
567 .if_khz = 6000,
568 .output_if = 2, /* LG2161_OIF_SPI_MAS */
569};
570
571static struct lg2160_config hauppauge_lg2161_1040_config = {
572 .lg_chip = LG2161_1040,
573 .i2c_addr = 0x1c >> 1,
574 .deny_i2c_rptr = 1,
575 .spectral_inversion = 0,
576 .if_khz = 6000,
577 .output_if = 4, /* LG2161_OIF_SPI_MAS */
578};
579
580static int mxl111sf_lg2161_frontend_attach(struct dvb_usb_adapter *adap)
581{
582 struct dvb_usb_device *d = adap->dev;
583 struct mxl111sf_state *state = d->priv;
584 int fe_id = adap->num_frontends_initialized;
585 struct mxl111sf_adap_state *adap_state = adap->fe_adap[fe_id].priv;
586 int ret;
587
588 deb_adv("%s()\n", __func__);
589
590 /* save a pointer to the dvb_usb_device in device state */
591 state->d = d;
592 adap_state->alt_mode = (dvb_usb_mxl111sf_isoc) ? 2 : 1;
593 state->alt_mode = adap_state->alt_mode;
594
595 if (usb_set_interface(adap->dev->udev, 0, state->alt_mode) < 0)
596 err("set interface failed");
597
598 state->gpio_mode = MXL111SF_GPIO_MOD_MH;
599 adap_state->gpio_mode = state->gpio_mode;
600 adap_state->device_mode = MXL_TUNER_MODE;
601 adap_state->ep6_clockphase = 1;
602
603 ret = mxl1x1sf_soft_reset(state);
604 if (mxl_fail(ret))
605 goto fail;
606 ret = mxl111sf_init_tuner_demod(state);
607 if (mxl_fail(ret))
608 goto fail;
609
610 ret = mxl1x1sf_set_device_mode(state, adap_state->device_mode);
611 if (mxl_fail(ret))
612 goto fail;
613
614 ret = mxl111sf_enable_usb_output(state);
615 if (mxl_fail(ret))
616 goto fail;
617 ret = mxl1x1sf_top_master_ctrl(state, 1);
618 if (mxl_fail(ret))
619 goto fail;
620
621 ret = mxl111sf_init_port_expander(state);
622 if (mxl_fail(ret))
623 goto fail;
624 ret = mxl111sf_gpio_mode_switch(state, state->gpio_mode);
625 if (mxl_fail(ret))
626 goto fail;
627
628 ret = get_chip_info(state);
629 if (mxl_fail(ret))
630 goto fail;
631
632 adap->fe_adap[fe_id].fe = dvb_attach(lg2160_attach,
633 (MXL111SF_V8_200 == state->chip_rev) ?
634 &hauppauge_lg2161_1040_config :
635 &hauppauge_lg2161_1019_config,
636 &adap->dev->i2c_adap);
637 if (adap->fe_adap[fe_id].fe) {
638 adap_state->fe_init = adap->fe_adap[fe_id].fe->ops.init;
639 adap->fe_adap[fe_id].fe->ops.init = mxl111sf_adap_fe_init;
640 adap_state->fe_sleep = adap->fe_adap[fe_id].fe->ops.sleep;
641 adap->fe_adap[fe_id].fe->ops.sleep = mxl111sf_adap_fe_sleep;
642 return 0;
643 }
644 ret = -EIO;
645fail:
646 return ret;
647}
648
649static struct lg2160_config hauppauge_lg2161_1019_ep6_config = {
650 .lg_chip = LG2161_1019,
651 .i2c_addr = 0x1c >> 1,
652 .deny_i2c_rptr = 1,
653 .spectral_inversion = 0,
654 .if_khz = 6000,
655 .output_if = 1, /* LG2161_OIF_SERIAL_TS */
656};
657
658static struct lg2160_config hauppauge_lg2161_1040_ep6_config = {
659 .lg_chip = LG2161_1040,
660 .i2c_addr = 0x1c >> 1,
661 .deny_i2c_rptr = 1,
662 .spectral_inversion = 0,
663 .if_khz = 6000,
664 .output_if = 7, /* LG2161_OIF_SERIAL_TS */
665};
666
667static int mxl111sf_lg2161_ep6_frontend_attach(struct dvb_usb_adapter *adap)
668{
669 struct dvb_usb_device *d = adap->dev;
670 struct mxl111sf_state *state = d->priv;
671 int fe_id = adap->num_frontends_initialized;
672 struct mxl111sf_adap_state *adap_state = adap->fe_adap[fe_id].priv;
673 int ret;
674
675 deb_adv("%s()\n", __func__);
676
677 /* save a pointer to the dvb_usb_device in device state */
678 state->d = d;
679 adap_state->alt_mode = (dvb_usb_mxl111sf_isoc) ? 2 : 1;
680 state->alt_mode = adap_state->alt_mode;
681
682 if (usb_set_interface(adap->dev->udev, 0, state->alt_mode) < 0)
683 err("set interface failed");
684
685 state->gpio_mode = MXL111SF_GPIO_MOD_MH;
686 adap_state->gpio_mode = state->gpio_mode;
687 adap_state->device_mode = MXL_TUNER_MODE;
688 adap_state->ep6_clockphase = 0;
689
690 ret = mxl1x1sf_soft_reset(state);
691 if (mxl_fail(ret))
692 goto fail;
693 ret = mxl111sf_init_tuner_demod(state);
694 if (mxl_fail(ret))
695 goto fail;
696
697 ret = mxl1x1sf_set_device_mode(state, adap_state->device_mode);
698 if (mxl_fail(ret))
699 goto fail;
700
701 ret = mxl111sf_enable_usb_output(state);
702 if (mxl_fail(ret))
703 goto fail;
704 ret = mxl1x1sf_top_master_ctrl(state, 1);
705 if (mxl_fail(ret))
706 goto fail;
707
708 ret = mxl111sf_init_port_expander(state);
709 if (mxl_fail(ret))
710 goto fail;
711 ret = mxl111sf_gpio_mode_switch(state, state->gpio_mode);
712 if (mxl_fail(ret))
713 goto fail;
714
715 ret = get_chip_info(state);
716 if (mxl_fail(ret))
717 goto fail;
718
719 adap->fe_adap[fe_id].fe = dvb_attach(lg2160_attach,
720 (MXL111SF_V8_200 == state->chip_rev) ?
721 &hauppauge_lg2161_1040_ep6_config :
722 &hauppauge_lg2161_1019_ep6_config,
723 &adap->dev->i2c_adap);
724 if (adap->fe_adap[fe_id].fe) {
725 adap_state->fe_init = adap->fe_adap[fe_id].fe->ops.init;
726 adap->fe_adap[fe_id].fe->ops.init = mxl111sf_adap_fe_init;
727 adap_state->fe_sleep = adap->fe_adap[fe_id].fe->ops.sleep;
728 adap->fe_adap[fe_id].fe->ops.sleep = mxl111sf_adap_fe_sleep;
729 return 0;
730 }
731 ret = -EIO;
732fail:
733 return ret;
734}
735
456static struct mxl111sf_demod_config mxl_demod_config = { 736static struct mxl111sf_demod_config mxl_demod_config = {
457 .read_reg = mxl111sf_read_reg, 737 .read_reg = mxl111sf_read_reg,
458 .write_reg = mxl111sf_write_reg, 738 .write_reg = mxl111sf_write_reg,
@@ -650,6 +930,18 @@ static struct dvb_usb_device_properties mxl111sf_dvbt_bulk_properties;
650static struct dvb_usb_device_properties mxl111sf_dvbt_isoc_properties; 930static struct dvb_usb_device_properties mxl111sf_dvbt_isoc_properties;
651static struct dvb_usb_device_properties mxl111sf_atsc_bulk_properties; 931static struct dvb_usb_device_properties mxl111sf_atsc_bulk_properties;
652static struct dvb_usb_device_properties mxl111sf_atsc_isoc_properties; 932static struct dvb_usb_device_properties mxl111sf_atsc_isoc_properties;
933static struct dvb_usb_device_properties mxl111sf_atsc_mh_bulk_properties;
934static struct dvb_usb_device_properties mxl111sf_atsc_mh_isoc_properties;
935static struct dvb_usb_device_properties mxl111sf_mh_bulk_properties;
936static struct dvb_usb_device_properties mxl111sf_mh_isoc_properties;
937static struct dvb_usb_device_properties mxl111sf_mercury_spi_bulk_properties;
938static struct dvb_usb_device_properties mxl111sf_mercury_spi_isoc_properties;
939static struct dvb_usb_device_properties mxl111sf_mercury_tp_bulk_properties;
940static struct dvb_usb_device_properties mxl111sf_mercury_tp_isoc_properties;
941static struct dvb_usb_device_properties mxl111sf_mercury_mh_spi_bulk_properties;
942static struct dvb_usb_device_properties mxl111sf_mercury_mh_spi_isoc_properties;
943static struct dvb_usb_device_properties mxl111sf_mercury_mh_tp_bulk_properties;
944static struct dvb_usb_device_properties mxl111sf_mercury_mh_tp_isoc_properties;
653 945
654static int mxl111sf_probe(struct usb_interface *intf, 946static int mxl111sf_probe(struct usb_interface *intf,
655 const struct usb_device_id *id) 947 const struct usb_device_id *id)
@@ -664,12 +956,50 @@ static int mxl111sf_probe(struct usb_interface *intf,
664 THIS_MODULE, &d, adapter_nr) || 956 THIS_MODULE, &d, adapter_nr) ||
665 0 == dvb_usb_device_init(intf, 957 0 == dvb_usb_device_init(intf,
666 &mxl111sf_atsc_isoc_properties, 958 &mxl111sf_atsc_isoc_properties,
959 THIS_MODULE, &d, adapter_nr) ||
960 0 == dvb_usb_device_init(intf,
961 &mxl111sf_atsc_mh_isoc_properties,
962 THIS_MODULE, &d, adapter_nr) ||
963 0 == dvb_usb_device_init(intf,
964 &mxl111sf_mh_isoc_properties,
965 THIS_MODULE, &d, adapter_nr) ||
966 ((dvb_usb_mxl111sf_spi) &&
967 (0 == dvb_usb_device_init(intf,
968 &mxl111sf_mercury_spi_isoc_properties,
969 THIS_MODULE, &d, adapter_nr) ||
970 0 == dvb_usb_device_init(intf,
971 &mxl111sf_mercury_mh_spi_isoc_properties,
972 THIS_MODULE, &d, adapter_nr))) ||
973 0 == dvb_usb_device_init(intf,
974 &mxl111sf_mercury_tp_isoc_properties,
975 THIS_MODULE, &d, adapter_nr) ||
976 0 == dvb_usb_device_init(intf,
977 &mxl111sf_mercury_mh_tp_isoc_properties,
667 THIS_MODULE, &d, adapter_nr))) || 978 THIS_MODULE, &d, adapter_nr))) ||
668 0 == dvb_usb_device_init(intf, 979 0 == dvb_usb_device_init(intf,
669 &mxl111sf_dvbt_bulk_properties, 980 &mxl111sf_dvbt_bulk_properties,
670 THIS_MODULE, &d, adapter_nr) || 981 THIS_MODULE, &d, adapter_nr) ||
671 0 == dvb_usb_device_init(intf, 982 0 == dvb_usb_device_init(intf,
672 &mxl111sf_atsc_bulk_properties, 983 &mxl111sf_atsc_bulk_properties,
984 THIS_MODULE, &d, adapter_nr) ||
985 0 == dvb_usb_device_init(intf,
986 &mxl111sf_atsc_mh_bulk_properties,
987 THIS_MODULE, &d, adapter_nr) ||
988 0 == dvb_usb_device_init(intf,
989 &mxl111sf_mh_bulk_properties,
990 THIS_MODULE, &d, adapter_nr) ||
991 ((dvb_usb_mxl111sf_spi) &&
992 (0 == dvb_usb_device_init(intf,
993 &mxl111sf_mercury_spi_bulk_properties,
994 THIS_MODULE, &d, adapter_nr) ||
995 0 == dvb_usb_device_init(intf,
996 &mxl111sf_mercury_mh_spi_bulk_properties,
997 THIS_MODULE, &d, adapter_nr))) ||
998 0 == dvb_usb_device_init(intf,
999 &mxl111sf_mercury_tp_bulk_properties,
1000 THIS_MODULE, &d, adapter_nr) ||
1001 0 == dvb_usb_device_init(intf,
1002 &mxl111sf_mercury_mh_tp_bulk_properties,
673 THIS_MODULE, &d, adapter_nr) || 0) { 1003 THIS_MODULE, &d, adapter_nr) || 0) {
674 1004
675 struct mxl111sf_state *state = d->priv; 1005 struct mxl111sf_state *state = d->priv;
@@ -787,6 +1117,36 @@ MODULE_DEVICE_TABLE(usb, mxl111sf_table);
787 } \ 1117 } \
788 } 1118 }
789 1119
1120#define MXL111SF_EP5_BULK_STREAMING_CONFIG \
1121 .size_of_priv = sizeof(struct mxl111sf_adap_state), \
1122 .streaming_ctrl = mxl111sf_ep5_streaming_ctrl, \
1123 .stream = { \
1124 .type = USB_BULK, \
1125 .count = 5, \
1126 .endpoint = 0x05, \
1127 .u = { \
1128 .bulk = { \
1129 .buffersize = 8192, \
1130 } \
1131 } \
1132 }
1133
1134#define MXL111SF_EP5_ISOC_STREAMING_CONFIG \
1135 .size_of_priv = sizeof(struct mxl111sf_adap_state), \
1136 .streaming_ctrl = mxl111sf_ep5_streaming_ctrl, \
1137 .stream = { \
1138 .type = USB_ISOC, \
1139 .count = 5, \
1140 .endpoint = 0x05, \
1141 .u = { \
1142 .isoc = { \
1143 .framesperurb = 96, \
1144 .framesize = 200, \
1145 .interval = 1, \
1146 } \
1147 } \
1148 }
1149
790#define MXL111SF_EP6_BULK_STREAMING_CONFIG \ 1150#define MXL111SF_EP6_BULK_STREAMING_CONFIG \
791 .size_of_priv = sizeof(struct mxl111sf_adap_state), \ 1151 .size_of_priv = sizeof(struct mxl111sf_adap_state), \
792 .streaming_ctrl = mxl111sf_ep6_streaming_ctrl, \ 1152 .streaming_ctrl = mxl111sf_ep6_streaming_ctrl, \
@@ -848,7 +1208,7 @@ static struct dvb_usb_device_properties mxl111sf_dvbt_bulk_properties = {
848 } }, 1208 } },
849 }, 1209 },
850 }, 1210 },
851 .num_device_descs = 4, 1211 .num_device_descs = 3,
852 .devices = { 1212 .devices = {
853 { "Hauppauge 126xxx DVBT (bulk)", 1213 { "Hauppauge 126xxx DVBT (bulk)",
854 { NULL }, 1214 { NULL },
@@ -866,11 +1226,6 @@ static struct dvb_usb_device_properties mxl111sf_dvbt_bulk_properties = {
866 &mxl111sf_table[24], &mxl111sf_table[26], 1226 &mxl111sf_table[24], &mxl111sf_table[26],
867 NULL }, 1227 NULL },
868 }, 1228 },
869 { "Hauppauge 126xxx (tp-bulk)",
870 { NULL },
871 { &mxl111sf_table[28], &mxl111sf_table[30],
872 NULL },
873 },
874 } 1229 }
875}; 1230};
876 1231
@@ -890,7 +1245,7 @@ static struct dvb_usb_device_properties mxl111sf_dvbt_isoc_properties = {
890 } }, 1245 } },
891 }, 1246 },
892 }, 1247 },
893 .num_device_descs = 4, 1248 .num_device_descs = 3,
894 .devices = { 1249 .devices = {
895 { "Hauppauge 126xxx DVBT (isoc)", 1250 { "Hauppauge 126xxx DVBT (isoc)",
896 { NULL }, 1251 { NULL },
@@ -908,11 +1263,6 @@ static struct dvb_usb_device_properties mxl111sf_dvbt_isoc_properties = {
908 &mxl111sf_table[24], &mxl111sf_table[26], 1263 &mxl111sf_table[24], &mxl111sf_table[26],
909 NULL }, 1264 NULL },
910 }, 1265 },
911 { "Hauppauge 126xxx (tp-isoc)",
912 { NULL },
913 { &mxl111sf_table[28], &mxl111sf_table[30],
914 NULL },
915 },
916 } 1266 }
917}; 1267};
918 1268
@@ -923,33 +1273,159 @@ static struct dvb_usb_device_properties mxl111sf_atsc_bulk_properties = {
923 .adapter = { 1273 .adapter = {
924 { 1274 {
925 .fe_ioctl_override = mxl111sf_fe_ioctl_override, 1275 .fe_ioctl_override = mxl111sf_fe_ioctl_override,
926 .num_frontends = 2, 1276 .num_frontends = 1,
927 .fe = {{ 1277 .fe = {{
928 .frontend_attach = mxl111sf_lgdt3305_frontend_attach, 1278 .frontend_attach = mxl111sf_lgdt3305_frontend_attach,
929 .tuner_attach = mxl111sf_attach_tuner, 1279 .tuner_attach = mxl111sf_attach_tuner,
930 1280
931 MXL111SF_EP6_BULK_STREAMING_CONFIG, 1281 MXL111SF_EP6_BULK_STREAMING_CONFIG,
1282 }},
932 }, 1283 },
1284 },
1285 .num_device_descs = 2,
1286 .devices = {
1287 { "Hauppauge 126xxx ATSC (bulk)",
1288 { NULL },
1289 { &mxl111sf_table[1], &mxl111sf_table[5],
1290 NULL },
1291 },
1292 { "Hauppauge 117xxx ATSC (bulk)",
1293 { NULL },
1294 { &mxl111sf_table[12],
1295 NULL },
1296 },
1297 }
1298};
1299
1300static struct dvb_usb_device_properties mxl111sf_atsc_isoc_properties = {
1301 MXL111SF_DEFAULT_DEVICE_PROPERTIES,
1302
1303 .num_adapters = 1,
1304 .adapter = {
933 { 1305 {
934 .frontend_attach = mxl111sf_attach_demod, 1306 .fe_ioctl_override = mxl111sf_fe_ioctl_override,
1307 .num_frontends = 1,
1308 .fe = {{
1309 .frontend_attach = mxl111sf_lgdt3305_frontend_attach,
935 .tuner_attach = mxl111sf_attach_tuner, 1310 .tuner_attach = mxl111sf_attach_tuner,
936 1311
937 MXL111SF_EP4_BULK_STREAMING_CONFIG, 1312 MXL111SF_EP6_ISOC_STREAMING_CONFIG,
938 }}, 1313 }},
939 }, 1314 },
940 }, 1315 },
941 .num_device_descs = 6, 1316 .num_device_descs = 2,
942 .devices = { 1317 .devices = {
943 { "Hauppauge 126xxx ATSC (bulk)", 1318 { "Hauppauge 126xxx ATSC (isoc)",
944 { NULL }, 1319 { NULL },
945 { &mxl111sf_table[1], &mxl111sf_table[5], 1320 { &mxl111sf_table[1], &mxl111sf_table[5],
946 NULL }, 1321 NULL },
947 }, 1322 },
948 { "Hauppauge 117xxx ATSC (bulk)", 1323 { "Hauppauge 117xxx ATSC (isoc)",
949 { NULL }, 1324 { NULL },
950 { &mxl111sf_table[12], 1325 { &mxl111sf_table[12],
951 NULL }, 1326 NULL },
952 }, 1327 },
1328 }
1329};
1330
1331static struct dvb_usb_device_properties mxl111sf_mh_bulk_properties = {
1332 MXL111SF_DEFAULT_DEVICE_PROPERTIES,
1333
1334 .num_adapters = 1,
1335 .adapter = {
1336 {
1337 .fe_ioctl_override = mxl111sf_fe_ioctl_override,
1338 .num_frontends = 1,
1339 .fe = {{
1340 .caps = DVB_USB_ADAP_RECEIVES_RAW_PAYLOAD,
1341
1342 .frontend_attach = mxl111sf_lg2160_frontend_attach,
1343 .tuner_attach = mxl111sf_attach_tuner,
1344
1345 MXL111SF_EP5_BULK_STREAMING_CONFIG,
1346 }},
1347 },
1348 },
1349 .num_device_descs = 2,
1350 .devices = {
1351 { "HCW 126xxx (bulk)",
1352 { NULL },
1353 { &mxl111sf_table[2], &mxl111sf_table[6],
1354 NULL },
1355 },
1356 { "HCW 117xxx (bulk)",
1357 { NULL },
1358 { &mxl111sf_table[13],
1359 NULL },
1360 },
1361 }
1362};
1363
1364static struct dvb_usb_device_properties mxl111sf_mh_isoc_properties = {
1365 MXL111SF_DEFAULT_DEVICE_PROPERTIES,
1366
1367 .num_adapters = 1,
1368 .adapter = {
1369 {
1370 .fe_ioctl_override = mxl111sf_fe_ioctl_override,
1371 .num_frontends = 1,
1372 .fe = {{
1373 .caps = DVB_USB_ADAP_RECEIVES_RAW_PAYLOAD,
1374
1375 .frontend_attach = mxl111sf_lg2160_frontend_attach,
1376 .tuner_attach = mxl111sf_attach_tuner,
1377
1378 MXL111SF_EP5_ISOC_STREAMING_CONFIG,
1379 }},
1380 },
1381 },
1382 .num_device_descs = 2,
1383 .devices = {
1384 { "HCW 126xxx (isoc)",
1385 { NULL },
1386 { &mxl111sf_table[2], &mxl111sf_table[6],
1387 NULL },
1388 },
1389 { "HCW 117xxx (isoc)",
1390 { NULL },
1391 { &mxl111sf_table[13],
1392 NULL },
1393 },
1394 }
1395};
1396
1397static struct dvb_usb_device_properties mxl111sf_atsc_mh_bulk_properties = {
1398 MXL111SF_DEFAULT_DEVICE_PROPERTIES,
1399
1400 .num_adapters = 1,
1401 .adapter = {
1402 {
1403 .fe_ioctl_override = mxl111sf_fe_ioctl_override,
1404 .num_frontends = 3,
1405 .fe = {{
1406 .frontend_attach = mxl111sf_lgdt3305_frontend_attach,
1407 .tuner_attach = mxl111sf_attach_tuner,
1408
1409 MXL111SF_EP6_BULK_STREAMING_CONFIG,
1410 },
1411 {
1412 .frontend_attach = mxl111sf_attach_demod,
1413 .tuner_attach = mxl111sf_attach_tuner,
1414
1415 MXL111SF_EP4_BULK_STREAMING_CONFIG,
1416 },
1417 {
1418 .caps = DVB_USB_ADAP_RECEIVES_RAW_PAYLOAD,
1419
1420 .frontend_attach = mxl111sf_lg2160_frontend_attach,
1421 .tuner_attach = mxl111sf_attach_tuner,
1422
1423 MXL111SF_EP5_BULK_STREAMING_CONFIG,
1424 }},
1425 },
1426 },
1427 .num_device_descs = 2,
1428 .devices = {
953 { "Hauppauge 126xxx ATSC+ (bulk)", 1429 { "Hauppauge 126xxx ATSC+ (bulk)",
954 { NULL }, 1430 { NULL },
955 { &mxl111sf_table[0], &mxl111sf_table[3], 1431 { &mxl111sf_table[0], &mxl111sf_table[3],
@@ -963,13 +1439,96 @@ static struct dvb_usb_device_properties mxl111sf_atsc_bulk_properties = {
963 &mxl111sf_table[32], &mxl111sf_table[33], 1439 &mxl111sf_table[32], &mxl111sf_table[33],
964 NULL }, 1440 NULL },
965 }, 1441 },
966 { "Hauppauge Mercury (tp-bulk)", 1442 }
1443};
1444
1445static struct dvb_usb_device_properties mxl111sf_atsc_mh_isoc_properties = {
1446 MXL111SF_DEFAULT_DEVICE_PROPERTIES,
1447
1448 .num_adapters = 1,
1449 .adapter = {
1450 {
1451 .fe_ioctl_override = mxl111sf_fe_ioctl_override,
1452 .num_frontends = 3,
1453 .fe = {{
1454 .frontend_attach = mxl111sf_lgdt3305_frontend_attach,
1455 .tuner_attach = mxl111sf_attach_tuner,
1456
1457 MXL111SF_EP6_ISOC_STREAMING_CONFIG,
1458 },
1459 {
1460 .frontend_attach = mxl111sf_attach_demod,
1461 .tuner_attach = mxl111sf_attach_tuner,
1462
1463 MXL111SF_EP4_ISOC_STREAMING_CONFIG,
1464 },
1465 {
1466 .caps = DVB_USB_ADAP_RECEIVES_RAW_PAYLOAD,
1467
1468 .frontend_attach = mxl111sf_lg2160_frontend_attach,
1469 .tuner_attach = mxl111sf_attach_tuner,
1470
1471 MXL111SF_EP5_ISOC_STREAMING_CONFIG,
1472 }},
1473 },
1474 },
1475 .num_device_descs = 2,
1476 .devices = {
1477 { "Hauppauge 126xxx ATSC+ (isoc)",
1478 { NULL },
1479 { &mxl111sf_table[0], &mxl111sf_table[3],
1480 &mxl111sf_table[7], &mxl111sf_table[9],
1481 &mxl111sf_table[10], NULL },
1482 },
1483 { "Hauppauge 117xxx ATSC+ (isoc)",
1484 { NULL },
1485 { &mxl111sf_table[11], &mxl111sf_table[14],
1486 &mxl111sf_table[16], &mxl111sf_table[17],
1487 &mxl111sf_table[32], &mxl111sf_table[33],
1488 NULL },
1489 },
1490 }
1491};
1492
1493static struct dvb_usb_device_properties mxl111sf_mercury_spi_bulk_properties = {
1494 MXL111SF_DEFAULT_DEVICE_PROPERTIES,
1495
1496 .num_adapters = 1,
1497 .adapter = {
1498 {
1499 .fe_ioctl_override = mxl111sf_fe_ioctl_override,
1500 .num_frontends = 3,
1501 .fe = {{
1502 .frontend_attach = mxl111sf_lgdt3305_frontend_attach,
1503 .tuner_attach = mxl111sf_attach_tuner,
1504
1505 MXL111SF_EP6_BULK_STREAMING_CONFIG,
1506 },
1507 {
1508 .frontend_attach = mxl111sf_attach_demod,
1509 .tuner_attach = mxl111sf_attach_tuner,
1510
1511 MXL111SF_EP4_BULK_STREAMING_CONFIG,
1512 },
1513 {
1514 .caps = DVB_USB_ADAP_RECEIVES_RAW_PAYLOAD,
1515
1516 .frontend_attach = mxl111sf_lg2161_frontend_attach,
1517 .tuner_attach = mxl111sf_attach_tuner,
1518
1519 MXL111SF_EP5_BULK_STREAMING_CONFIG,
1520 }},
1521 },
1522 },
1523 .num_device_descs = 2,
1524 .devices = {
1525 { "Hauppauge Mercury (spi-bulk)",
967 { NULL }, 1526 { NULL },
968 { &mxl111sf_table[19], &mxl111sf_table[21], 1527 { &mxl111sf_table[19], &mxl111sf_table[21],
969 &mxl111sf_table[23], &mxl111sf_table[25], 1528 &mxl111sf_table[23], &mxl111sf_table[25],
970 &mxl111sf_table[27], NULL }, 1529 NULL },
971 }, 1530 },
972 { "Hauppauge WinTV-Aero-M", 1531 { "Hauppauge WinTV-Aero-M (spi-bulk)",
973 { NULL }, 1532 { NULL },
974 { &mxl111sf_table[29], &mxl111sf_table[31], 1533 { &mxl111sf_table[29], &mxl111sf_table[31],
975 NULL }, 1534 NULL },
@@ -977,14 +1536,14 @@ static struct dvb_usb_device_properties mxl111sf_atsc_bulk_properties = {
977 } 1536 }
978}; 1537};
979 1538
980static struct dvb_usb_device_properties mxl111sf_atsc_isoc_properties = { 1539static struct dvb_usb_device_properties mxl111sf_mercury_spi_isoc_properties = {
981 MXL111SF_DEFAULT_DEVICE_PROPERTIES, 1540 MXL111SF_DEFAULT_DEVICE_PROPERTIES,
982 1541
983 .num_adapters = 1, 1542 .num_adapters = 1,
984 .adapter = { 1543 .adapter = {
985 { 1544 {
986 .fe_ioctl_override = mxl111sf_fe_ioctl_override, 1545 .fe_ioctl_override = mxl111sf_fe_ioctl_override,
987 .num_frontends = 2, 1546 .num_frontends = 3,
988 .fe = {{ 1547 .fe = {{
989 .frontend_attach = mxl111sf_lgdt3305_frontend_attach, 1548 .frontend_attach = mxl111sf_lgdt3305_frontend_attach,
990 .tuner_attach = mxl111sf_attach_tuner, 1549 .tuner_attach = mxl111sf_attach_tuner,
@@ -996,34 +1555,111 @@ static struct dvb_usb_device_properties mxl111sf_atsc_isoc_properties = {
996 .tuner_attach = mxl111sf_attach_tuner, 1555 .tuner_attach = mxl111sf_attach_tuner,
997 1556
998 MXL111SF_EP4_ISOC_STREAMING_CONFIG, 1557 MXL111SF_EP4_ISOC_STREAMING_CONFIG,
1558 },
1559 {
1560 .caps = DVB_USB_ADAP_RECEIVES_RAW_PAYLOAD,
1561
1562 .frontend_attach = mxl111sf_lg2161_frontend_attach,
1563 .tuner_attach = mxl111sf_attach_tuner,
1564
1565 MXL111SF_EP5_ISOC_STREAMING_CONFIG,
999 }}, 1566 }},
1000 }, 1567 },
1001 }, 1568 },
1002 .num_device_descs = 6, 1569 .num_device_descs = 2,
1003 .devices = { 1570 .devices = {
1004 { "Hauppauge 126xxx ATSC (isoc)", 1571 { "Hauppauge Mercury (spi-isoc)",
1005 { NULL }, 1572 { NULL },
1006 { &mxl111sf_table[1], &mxl111sf_table[5], 1573 { &mxl111sf_table[19], &mxl111sf_table[21],
1574 &mxl111sf_table[23], &mxl111sf_table[25],
1007 NULL }, 1575 NULL },
1008 }, 1576 },
1009 { "Hauppauge 117xxx ATSC (isoc)", 1577 { "Hauppauge WinTV-Aero-M (spi-isoc)",
1010 { NULL }, 1578 { NULL },
1011 { &mxl111sf_table[12], 1579 { &mxl111sf_table[29], &mxl111sf_table[31],
1012 NULL }, 1580 NULL },
1013 }, 1581 },
1014 { "Hauppauge 126xxx ATSC+ (isoc)", 1582 }
1583};
1584
1585static struct dvb_usb_device_properties mxl111sf_mercury_tp_bulk_properties = {
1586 MXL111SF_DEFAULT_DEVICE_PROPERTIES,
1587
1588 .num_adapters = 1,
1589 .adapter = {
1590 {
1591 .fe_ioctl_override = mxl111sf_fe_ioctl_override,
1592 .num_frontends = 3,
1593 .fe = {{
1594 .frontend_attach = mxl111sf_lgdt3305_frontend_attach,
1595 .tuner_attach = mxl111sf_attach_tuner,
1596
1597 MXL111SF_EP6_BULK_STREAMING_CONFIG,
1598 },
1599 {
1600 .frontend_attach = mxl111sf_attach_demod,
1601 .tuner_attach = mxl111sf_attach_tuner,
1602
1603 MXL111SF_EP4_BULK_STREAMING_CONFIG,
1604 },
1605 {
1606 .caps = DVB_USB_ADAP_RECEIVES_RAW_PAYLOAD,
1607
1608 .frontend_attach = mxl111sf_lg2161_ep6_frontend_attach,
1609 .tuner_attach = mxl111sf_attach_tuner,
1610
1611 MXL111SF_EP6_BULK_STREAMING_CONFIG,
1612 }},
1613 },
1614 },
1615 .num_device_descs = 2,
1616 .devices = {
1617 { "Hauppauge Mercury (tp-bulk)",
1015 { NULL }, 1618 { NULL },
1016 { &mxl111sf_table[0], &mxl111sf_table[3], 1619 { &mxl111sf_table[19], &mxl111sf_table[21],
1017 &mxl111sf_table[7], &mxl111sf_table[9], 1620 &mxl111sf_table[23], &mxl111sf_table[25],
1018 &mxl111sf_table[10], NULL }, 1621 &mxl111sf_table[27], NULL },
1019 }, 1622 },
1020 { "Hauppauge 117xxx ATSC+ (isoc)", 1623 { "Hauppauge WinTV-Aero-M",
1021 { NULL }, 1624 { NULL },
1022 { &mxl111sf_table[11], &mxl111sf_table[14], 1625 { &mxl111sf_table[29], &mxl111sf_table[31],
1023 &mxl111sf_table[16], &mxl111sf_table[17],
1024 &mxl111sf_table[32], &mxl111sf_table[33],
1025 NULL }, 1626 NULL },
1026 }, 1627 },
1628 }
1629};
1630
1631static struct dvb_usb_device_properties mxl111sf_mercury_tp_isoc_properties = {
1632 MXL111SF_DEFAULT_DEVICE_PROPERTIES,
1633
1634 .num_adapters = 1,
1635 .adapter = {
1636 {
1637 .fe_ioctl_override = mxl111sf_fe_ioctl_override,
1638 .num_frontends = 3,
1639 .fe = {{
1640 .frontend_attach = mxl111sf_lgdt3305_frontend_attach,
1641 .tuner_attach = mxl111sf_attach_tuner,
1642
1643 MXL111SF_EP6_ISOC_STREAMING_CONFIG,
1644 },
1645 {
1646 .frontend_attach = mxl111sf_attach_demod,
1647 .tuner_attach = mxl111sf_attach_tuner,
1648
1649 MXL111SF_EP4_ISOC_STREAMING_CONFIG,
1650 },
1651 {
1652 .caps = DVB_USB_ADAP_RECEIVES_RAW_PAYLOAD,
1653
1654 .frontend_attach = mxl111sf_lg2161_ep6_frontend_attach,
1655 .tuner_attach = mxl111sf_attach_tuner,
1656
1657 MXL111SF_EP6_ISOC_STREAMING_CONFIG,
1658 }},
1659 },
1660 },
1661 .num_device_descs = 2,
1662 .devices = {
1027 { "Hauppauge Mercury (tp-isoc)", 1663 { "Hauppauge Mercury (tp-isoc)",
1028 { NULL }, 1664 { NULL },
1029 { &mxl111sf_table[19], &mxl111sf_table[21], 1665 { &mxl111sf_table[19], &mxl111sf_table[21],
@@ -1038,6 +1674,146 @@ static struct dvb_usb_device_properties mxl111sf_atsc_isoc_properties = {
1038 } 1674 }
1039}; 1675};
1040 1676
1677static
1678struct dvb_usb_device_properties mxl111sf_mercury_mh_tp_bulk_properties = {
1679 MXL111SF_DEFAULT_DEVICE_PROPERTIES,
1680
1681 .num_adapters = 1,
1682 .adapter = {
1683 {
1684 .fe_ioctl_override = mxl111sf_fe_ioctl_override,
1685 .num_frontends = 2,
1686 .fe = {{
1687 .frontend_attach = mxl111sf_attach_demod,
1688 .tuner_attach = mxl111sf_attach_tuner,
1689
1690 MXL111SF_EP4_BULK_STREAMING_CONFIG,
1691 },
1692 {
1693 .caps = DVB_USB_ADAP_RECEIVES_RAW_PAYLOAD,
1694
1695 .frontend_attach = mxl111sf_lg2161_ep6_frontend_attach,
1696 .tuner_attach = mxl111sf_attach_tuner,
1697
1698 MXL111SF_EP6_BULK_STREAMING_CONFIG,
1699 }},
1700 },
1701 },
1702 .num_device_descs = 1,
1703 .devices = {
1704 { "Hauppauge 126xxx (tp-bulk)",
1705 { NULL },
1706 { &mxl111sf_table[28], &mxl111sf_table[30],
1707 NULL },
1708 },
1709 }
1710};
1711
1712static
1713struct dvb_usb_device_properties mxl111sf_mercury_mh_tp_isoc_properties = {
1714 MXL111SF_DEFAULT_DEVICE_PROPERTIES,
1715
1716 .num_adapters = 1,
1717 .adapter = {
1718 {
1719 .fe_ioctl_override = mxl111sf_fe_ioctl_override,
1720 .num_frontends = 2,
1721 .fe = {{
1722 .frontend_attach = mxl111sf_attach_demod,
1723 .tuner_attach = mxl111sf_attach_tuner,
1724
1725 MXL111SF_EP4_ISOC_STREAMING_CONFIG,
1726 },
1727 {
1728 .caps = DVB_USB_ADAP_RECEIVES_RAW_PAYLOAD,
1729
1730 .frontend_attach = mxl111sf_lg2161_ep6_frontend_attach,
1731 .tuner_attach = mxl111sf_attach_tuner,
1732
1733 MXL111SF_EP6_ISOC_STREAMING_CONFIG,
1734 }},
1735 },
1736 },
1737 .num_device_descs = 1,
1738 .devices = {
1739 { "Hauppauge 126xxx (tp-isoc)",
1740 { NULL },
1741 { &mxl111sf_table[28], &mxl111sf_table[30],
1742 NULL },
1743 },
1744 }
1745};
1746
1747static
1748struct dvb_usb_device_properties mxl111sf_mercury_mh_spi_bulk_properties = {
1749 MXL111SF_DEFAULT_DEVICE_PROPERTIES,
1750
1751 .num_adapters = 1,
1752 .adapter = {
1753 {
1754 .fe_ioctl_override = mxl111sf_fe_ioctl_override,
1755 .num_frontends = 2,
1756 .fe = {{
1757 .frontend_attach = mxl111sf_attach_demod,
1758 .tuner_attach = mxl111sf_attach_tuner,
1759
1760 MXL111SF_EP4_BULK_STREAMING_CONFIG,
1761 },
1762 {
1763 .caps = DVB_USB_ADAP_RECEIVES_RAW_PAYLOAD,
1764
1765 .frontend_attach = mxl111sf_lg2161_frontend_attach,
1766 .tuner_attach = mxl111sf_attach_tuner,
1767
1768 MXL111SF_EP5_BULK_STREAMING_CONFIG,
1769 }},
1770 },
1771 },
1772 .num_device_descs = 1,
1773 .devices = {
1774 { "Hauppauge 126xxx (spi-bulk)",
1775 { NULL },
1776 { &mxl111sf_table[28], &mxl111sf_table[30],
1777 NULL },
1778 },
1779 }
1780};
1781
1782static
1783struct dvb_usb_device_properties mxl111sf_mercury_mh_spi_isoc_properties = {
1784 MXL111SF_DEFAULT_DEVICE_PROPERTIES,
1785
1786 .num_adapters = 1,
1787 .adapter = {
1788 {
1789 .fe_ioctl_override = mxl111sf_fe_ioctl_override,
1790 .num_frontends = 2,
1791 .fe = {{
1792 .frontend_attach = mxl111sf_attach_demod,
1793 .tuner_attach = mxl111sf_attach_tuner,
1794
1795 MXL111SF_EP4_ISOC_STREAMING_CONFIG,
1796 },
1797 {
1798 .caps = DVB_USB_ADAP_RECEIVES_RAW_PAYLOAD,
1799
1800 .frontend_attach = mxl111sf_lg2161_frontend_attach,
1801 .tuner_attach = mxl111sf_attach_tuner,
1802
1803 MXL111SF_EP5_ISOC_STREAMING_CONFIG,
1804 }},
1805 },
1806 },
1807 .num_device_descs = 1,
1808 .devices = {
1809 { "Hauppauge 126xxx (spi-isoc)",
1810 { NULL },
1811 { &mxl111sf_table[28], &mxl111sf_table[30],
1812 NULL },
1813 },
1814 }
1815};
1816
1041static struct usb_driver mxl111sf_driver = { 1817static struct usb_driver mxl111sf_driver = {
1042 .name = "dvb_usb_mxl111sf", 1818 .name = "dvb_usb_mxl111sf",
1043 .probe = mxl111sf_probe, 1819 .probe = mxl111sf_probe,
diff --git a/drivers/media/dvb/dvb-usb/rtl28xxu.c b/drivers/media/dvb/dvb-usb/rtl28xxu.c
index 8f4736a10fc8..41e1f5537f44 100644
--- a/drivers/media/dvb/dvb-usb/rtl28xxu.c
+++ b/drivers/media/dvb/dvb-usb/rtl28xxu.c
@@ -322,6 +322,9 @@ static int rtl2831u_frontend_attach(struct dvb_usb_adapter *adap)
322 * since there is some demod params needed to set according to tuner. 322 * since there is some demod params needed to set according to tuner.
323 */ 323 */
324 324
325 /* demod needs some time to wake up */
326 msleep(20);
327
325 /* open demod I2C gate */ 328 /* open demod I2C gate */
326 ret = rtl28xxu_ctrl_msg(adap->dev, &req_gate); 329 ret = rtl28xxu_ctrl_msg(adap->dev, &req_gate);
327 if (ret) 330 if (ret)
@@ -909,6 +912,8 @@ static int rtl28xxu_probe(struct usb_interface *intf,
909 int ret, i; 912 int ret, i;
910 int properties_count = ARRAY_SIZE(rtl28xxu_properties); 913 int properties_count = ARRAY_SIZE(rtl28xxu_properties);
911 struct dvb_usb_device *d; 914 struct dvb_usb_device *d;
915 struct usb_device *udev;
916 bool found;
912 917
913 deb_info("%s: interface=%d\n", __func__, 918 deb_info("%s: interface=%d\n", __func__,
914 intf->cur_altsetting->desc.bInterfaceNumber); 919 intf->cur_altsetting->desc.bInterfaceNumber);
@@ -916,6 +921,29 @@ static int rtl28xxu_probe(struct usb_interface *intf,
916 if (intf->cur_altsetting->desc.bInterfaceNumber != 0) 921 if (intf->cur_altsetting->desc.bInterfaceNumber != 0)
917 return 0; 922 return 0;
918 923
924 /* Dynamic USB ID support. Replaces first device ID with current one .*/
925 udev = interface_to_usbdev(intf);
926
927 for (i = 0, found = false; i < ARRAY_SIZE(rtl28xxu_table) - 1; i++) {
928 if (rtl28xxu_table[i].idVendor ==
929 le16_to_cpu(udev->descriptor.idVendor) &&
930 rtl28xxu_table[i].idProduct ==
931 le16_to_cpu(udev->descriptor.idProduct)) {
932 found = true;
933 break;
934 }
935 }
936
937 if (!found) {
938 deb_info("%s: using dynamic ID %04x:%04x\n", __func__,
939 le16_to_cpu(udev->descriptor.idVendor),
940 le16_to_cpu(udev->descriptor.idProduct));
941 rtl28xxu_properties[0].devices[0].warm_ids[0]->idVendor =
942 le16_to_cpu(udev->descriptor.idVendor);
943 rtl28xxu_properties[0].devices[0].warm_ids[0]->idProduct =
944 le16_to_cpu(udev->descriptor.idProduct);
945 }
946
919 for (i = 0; i < properties_count; i++) { 947 for (i = 0; i < properties_count; i++) {
920 ret = dvb_usb_device_init(intf, &rtl28xxu_properties[i], 948 ret = dvb_usb_device_init(intf, &rtl28xxu_properties[i],
921 THIS_MODULE, &d, adapter_nr); 949 THIS_MODULE, &d, adapter_nr);