Merge pull request #1792 from CvH/8.2-mb-fixes

media_build: add upstream patches
This commit is contained in:
Christian Hewitt 2017-07-15 18:36:11 +04:00 committed by GitHub
commit 738daa9499
8 changed files with 2001 additions and 6 deletions

View File

@ -292,6 +292,7 @@ CONFIG_DVB_USB_TBS5880=m
CONFIG_DVB_USB_TBS5220=m
CONFIG_DVB_USB_TBS5881=m
CONFIG_DVB_USB_TBS5520=m
CONFIG_DVB_USB_TBS5580=m
CONFIG_DVB_USB_TBS5927=m
CONFIG_DVB_USB_TBS5520SE=m
CONFIG_DVB_USB_V2=m

View File

@ -289,6 +289,7 @@ CONFIG_DVB_USB_TBS5880=m
CONFIG_DVB_USB_TBS5220=m
CONFIG_DVB_USB_TBS5881=m
CONFIG_DVB_USB_TBS5520=m
CONFIG_DVB_USB_TBS5580=m
CONFIG_DVB_USB_TBS5927=m
CONFIG_DVB_USB_TBS5520SE=m
CONFIG_DVB_USB_V2=m
@ -585,6 +586,7 @@ CONFIG_MISC_DEVICES=y
CONFIG_ALTERA_STAPL=m
# CONFIG_STAGING is not set
# RPi DVB Hat
CONFIG_DVB_CXD2820R=m
CONFIG_DVB_CXD2841ER=m
CONFIG_DVB_CXD2880=m

View File

@ -1,17 +1,22 @@
--- a/backports/backports.txt
+++ b/backports/backports.txt
@@ -25,6 +25,14 @@
@@ -25,6 +25,19 @@ add api_version.patch
add pr_fmt.patch
add debug.patch
add drx39xxj.patch
+add linux-202-lnbp22_patch_for_more_power_if_rotor.patch
+add linux-203-stb0899_enable_low_symbol_rate.patch
+add linux-052-XBOX_remote_support.patch
+add linux-054-nuvoton_revert_d7b290a1056c5564eec8a1b169c6e84ff3.6.114c13.patch
+add linux-057-Removed-MCE-customer-code-restriction-in-rc6-decode.patch
+add linux-062-imon_pad_ignore_diagonal.patch
+add linux-202-lnbp22_patch_for_more_power_if_rotor.patch
+add linux-203-stb0899_enable_low_symbol_rate.patch
+add linux-260-fix-for-kernel-4.11.patch
+add linux-261-fix-for-kernel-4.11-dibusb-license.patch
+add linux-262-fix-for-kernel-4.11-hauppauge_dualhd_second_tuner_support.patch
+add linux-263-fix-for-kernel-4.11-tbs5580-support.patch
+add linux-264-fix-for-kernel-4.11-lirc-fixes.patch
+add linux-265-fix-for-kernel-4.11-cinergy-s2-dual-support.patch
+add cxd2880-support.patch
[4.8.255]
add v4.8_user_pages_flag.patch
[4.10.255]
add v4.10_sched_signal.patch

View File

@ -0,0 +1,23 @@
From 79312c5d61429a32761412be85ad7a84bfaa3b5c Mon Sep 17 00:00:00 2001
From: Ben Hutchings <ben@decadent.org.uk>
Date: Fri, 17 Feb 2017 22:30:51 -0200
Subject: dvb-usb-dibusb-mc-common: Add MODULE_LICENSE
dvb-usb-dibusb-mc-common is licensed under GPLv2, and if we don't say
so then it won't even load since it needs a GPL-only symbol.
Fixes: e91455a1495a ("[media] dvb-usb: split out common parts of dibusb")
diff --git a/drivers/media/usb/dvb-usb/dibusb-mc-common.c b/drivers/media/usb/dvb-usb/dibusb-mc-common.c
index c989cac..0c2bc97 100644
--- a/drivers/media/usb/dvb-usb/dibusb-mc-common.c
+++ b/drivers/media/usb/dvb-usb/dibusb-mc-common.c
@@ -11,6 +11,8 @@
#include "dibusb.h"
+MODULE_LICENSE("GPL");
+
/* 3000MC/P stuff */
// Config Adjacent channels Perf -cal22
static struct dibx000_agc_config dib3000p_mt2060_agc_config = {

View File

@ -0,0 +1,587 @@
From: Brad Love <hidden@email.co>
Date: Sun, 16 Apr 2017 00:13:39 -0500
Subject: Hauppauge DualHD DVB/ATSC second tuner support
https://github.com/b-rad-NDi/Ubuntu-media-tree-kernel-builder/tree/master/patches/ubuntu-zesty-4.10.0/extra
diff --git a/drivers/media/dvb-frontends/lgdt3306a.c b/drivers/media/dvb-frontends/lgdt3306a.c
index c9b1eb3..c50769f 100644
--- a/drivers/media/dvb-frontends/lgdt3306a.c
+++ b/drivers/media/dvb-frontends/lgdt3306a.c
@@ -624,6 +624,9 @@ static int lgdt3306a_set_modulation(struct lgdt3306a_state *state,
case QAM_256:
ret = lgdt3306a_set_qam(state, QAM_256);
break;
+ case QAM_AUTO:
+ ret = lgdt3306a_set_qam(state, QAM_64);
+ break;
default:
return -EINVAL;
}
@@ -649,6 +652,7 @@ static int lgdt3306a_agc_setup(struct lgdt3306a_state *state,
break;
case QAM_64:
case QAM_256:
+ case QAM_AUTO:
break;
default:
return -EINVAL;
@@ -703,6 +707,7 @@ static int lgdt3306a_spectral_inversion(struct lgdt3306a_state *state,
break;
case QAM_64:
case QAM_256:
+ case QAM_AUTO:
/* Auto ok for QAM */
ret = lgdt3306a_set_inversion_auto(state, 1);
break;
@@ -726,6 +731,7 @@ static int lgdt3306a_set_if(struct lgdt3306a_state *state,
break;
case QAM_64:
case QAM_256:
+ case QAM_AUTO:
if_freq_khz = state->cfg->qam_if_khz;
break;
default:
@@ -1644,6 +1650,9 @@ static int lgdt3306a_read_signal_strength(struct dvb_frontend *fe,
case QAM_256:
ref_snr = 2800; /* 28dB */
break;
+ case QAM_AUTO:
+ ref_snr = 2200; /* 22dB */
+ break;
default:
return -EINVAL;
}
diff --git a/drivers/media/usb/em28xx/em28xx-cards.c b/drivers/media/usb/em28xx/em28xx-cards.c
index 146341a..d2e5b8d 100644
--- a/drivers/media/usb/em28xx/em28xx-cards.c
+++ b/drivers/media/usb/em28xx/em28xx-cards.c
@@ -508,8 +508,10 @@ static struct em28xx_reg_seq plex_px_bcud[] = {
};
/*
- * 2040:0265 Hauppauge WinTV-dualHD DVB
- * 2040:026d Hauppauge WinTV-dualHD ATSC/QAM
+ * 2040:0265 Hauppauge WinTV-dualHD DVB ISOC
+ * 2040:8265 Hauppauge WinTV-dualHD DVB Bulk
+ * 2040:026d Hauppauge WinTV-dualHD ATSC/QAM ISOC
+ * 2040:826d Hauppauge WinTV-dualHD ATSC/QAM Bulk
* reg 0x80/0x84:
* GPIO_0: Yellow LED tuner 1, 0=on, 1=off
* GPIO_1: Green LED tuner 1, 0=on, 1=off
@@ -2376,7 +2378,8 @@ struct em28xx_board em28xx_boards[] = {
.has_dvb = 1,
},
/*
- * 2040:0265 Hauppauge WinTV-dualHD (DVB version).
+ * 2040:0265 Hauppauge WinTV-dualHD (DVB version) ISOC.
+ * 2040:8265 Hauppauge WinTV-dualHD (DVB version) BULK.
* Empia EM28274, 2x Silicon Labs Si2168, 2x Silicon Labs Si2157
*/
[EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_DVB] = {
@@ -2387,11 +2390,13 @@ struct em28xx_board em28xx_boards[] = {
.tuner_type = TUNER_ABSENT,
.tuner_gpio = hauppauge_dualhd_dvb,
.has_dvb = 1,
+ .has_dual_ts = 1,
.ir_codes = RC_MAP_HAUPPAUGE,
.leds = hauppauge_dualhd_leds,
},
/*
- * 2040:026d Hauppauge WinTV-dualHD (model 01595 - ATSC/QAM).
+ * 2040:026d Hauppauge WinTV-dualHD (model 01595 - ATSC/QAM) ISOC.
+ * 2040:826d Hauppauge WinTV-dualHD (model 01595 - ATSC/QAM) BULK.
* Empia EM28274, 2x LG LGDT3306A, 2x Silicon Labs Si2157
*/
[EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_01595] = {
@@ -2402,6 +2407,7 @@ struct em28xx_board em28xx_boards[] = {
.tuner_type = TUNER_ABSENT,
.tuner_gpio = hauppauge_dualhd_dvb,
.has_dvb = 1,
+ .has_dual_ts = 1,
.ir_codes = RC_MAP_HAUPPAUGE,
.leds = hauppauge_dualhd_leds,
},
@@ -2530,8 +2536,12 @@ struct usb_device_id em28xx_id_table[] = {
.driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850 },
{ USB_DEVICE(0x2040, 0x0265),
.driver_info = EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_DVB },
+ { USB_DEVICE(0x2040, 0x8265),
+ .driver_info = EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_DVB },
{ USB_DEVICE(0x2040, 0x026d),
.driver_info = EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_01595 },
+ { USB_DEVICE(0x2040, 0x826d),
+ .driver_info = EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_01595 },
{ USB_DEVICE(0x0438, 0xb002),
.driver_info = EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600 },
{ USB_DEVICE(0x2001, 0xf112),
@@ -3222,7 +3232,8 @@ static void em28xx_release_resources(struct em28xx *dev)
em28xx_i2c_unregister(dev, 1);
em28xx_i2c_unregister(dev, 0);
- usb_put_dev(udev);
+ if(dev->ts == PRIMARY_TS)
+ usb_put_dev(udev);
/* Mark device as unused */
clear_bit(dev->devno, em28xx_devused);
@@ -3415,6 +3426,34 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev,
return 0;
}
+int em28xx_duplicate_dev(struct em28xx *dev)
+{
+ int nr;
+ struct em28xx *sec_dev = kzalloc(sizeof(*sec_dev), GFP_KERNEL);
+ if (sec_dev == NULL) {
+ dev->dev_next = NULL;
+ return -ENOMEM;
+ }
+ memcpy(sec_dev, dev, sizeof(sizeof(*sec_dev)));
+ /* Check to see next free device and mark as used */
+ do {
+ nr = find_first_zero_bit(em28xx_devused, EM28XX_MAXBOARDS);
+ if (nr >= EM28XX_MAXBOARDS) {
+ /* No free device slots */
+ printk(DRIVER_NAME ": Supports only %i em28xx boards.\n",
+ EM28XX_MAXBOARDS);
+ kfree(sec_dev);
+ dev->dev_next = NULL;
+ return -ENOMEM;
+ }
+ } while (test_and_set_bit(nr, em28xx_devused));
+ sec_dev->devno = nr;
+ snprintf(sec_dev->name, 28, "em28xx #%d", nr);
+ sec_dev->dev_next = NULL;
+ dev->dev_next = sec_dev;
+ return 0;
+}
+
/* high bandwidth multiplier, as encoded in highspeed endpoint descriptors */
#define hb_mult(wMaxPacketSize) (1 + (((wMaxPacketSize) >> 11) & 0x03))
@@ -3428,7 +3467,8 @@ static int em28xx_usb_probe(struct usb_interface *interface,
struct usb_device *udev;
struct em28xx *dev = NULL;
int retval;
- bool has_vendor_audio = false, has_video = false, has_dvb = false;
+ bool has_vendor_audio = false, has_video = false;
+ bool has_dvb = false, has_dvb_ts2 = false;
int i, nr, try_bulk;
const int ifnum = interface->altsetting[0].desc.bInterfaceNumber;
char *speed;
@@ -3534,6 +3574,19 @@ static int em28xx_usb_probe(struct usb_interface *interface,
}
}
break;
+ case 0x85:
+ if (usb_endpoint_xfer_isoc(e)) {
+ if (size > dev->dvb_max_pkt_size_isoc_ts2) {
+ has_dvb_ts2 = true; /* see NOTE (~) */
+ dev->dvb_ep_isoc_ts2 = e->bEndpointAddress;
+ dev->dvb_max_pkt_size_isoc_ts2 = size;
+ dev->dvb_alt_isoc = i;
+ }
+ } else {
+ has_dvb_ts2 = true;
+ dev->dvb_ep_bulk_ts2 = e->bEndpointAddress;
+ }
+ break;
}
}
/* NOTE:
@@ -3615,6 +3668,10 @@ static int em28xx_usb_probe(struct usb_interface *interface,
dev->has_video = has_video;
dev->ifnum = ifnum;
+ dev->ts = PRIMARY_TS;
+ snprintf(dev->name, 28, "em28xx");
+ dev->dev_next = NULL;
+
if (has_vendor_audio) {
dev_err(&interface->dev,
"Audio interface %i found (Vendor Class)\n", ifnum);
@@ -3694,6 +3751,61 @@ static int em28xx_usb_probe(struct usb_interface *interface,
dev->dvb_xfer_bulk ? "bulk" : "isoc");
}
+ if(dev->board.has_dual_ts && em28xx_duplicate_dev(dev) == 0)
+ {
+ dev->dev_next->ts = SECONDARY_TS;
+ dev->dev_next->alt = -1;
+ dev->dev_next->is_audio_only = has_vendor_audio && !(has_video || has_dvb);
+ dev->dev_next->has_video = false;
+ dev->dev_next->ifnum = ifnum;
+ dev->dev_next->model = id->driver_info;
+
+ mutex_init(&dev->dev_next->lock);
+ retval = em28xx_init_dev(dev->dev_next, udev, interface, dev->dev_next->devno);
+ if (retval) {
+ goto err_free;
+ }
+
+ if (usb_xfer_mode < 0) {
+ if (dev->dev_next->board.is_webcam)
+ try_bulk = 1;
+ else
+ try_bulk = 0;
+ } else {
+ try_bulk = usb_xfer_mode > 0;
+ }
+
+ /* Select USB transfer types to use */
+ if (has_dvb) {
+ if (!dev->dvb_ep_isoc_ts2 || (try_bulk && dev->dvb_ep_bulk_ts2))
+ dev->dev_next->dvb_xfer_bulk = 1;
+ dev_info(&dev->intf->dev, "dvb ts2 set to %s mode.\n",
+ dev->dev_next->dvb_xfer_bulk ? "bulk" : "isoc");
+ }
+
+ dev->dev_next->dvb_ep_isoc = dev->dvb_ep_isoc_ts2;
+ dev->dev_next->dvb_ep_bulk = dev->dvb_ep_bulk_ts2;
+ dev->dev_next->dvb_max_pkt_size_isoc = dev->dvb_max_pkt_size_isoc_ts2;
+ dev->dev_next->dvb_alt_isoc = dev->dvb_alt_isoc;
+
+ /* Configuare hardware to support TS2*/
+ if(dev->dvb_xfer_bulk) {
+ /* The ep4 and ep5 are configuared for BULK */
+ em28xx_write_reg(dev, 0x0b, 0x96);
+ mdelay(100);
+ em28xx_write_reg(dev, 0x0b, 0x80);
+ mdelay(100);
+ } else {
+ /* The ep4 and ep5 are configuared for ISO */
+ em28xx_write_reg(dev, 0x0b, 0x96);
+ mdelay(100);
+ em28xx_write_reg(dev, 0x0b, 0x82);
+ mdelay(100);
+ }
+
+ kref_init(&dev->dev_next->ref);
+ }
+
kref_init(&dev->ref);
request_modules(dev);
@@ -3736,15 +3848,28 @@ static void em28xx_usb_disconnect(struct usb_interface *interface)
if (!dev)
return;
+ if(dev->dev_next!=NULL) {
+ dev->dev_next->disconnected = 1;
+ dev_info(&dev->intf->dev, "Disconnecting %s\n", dev->dev_next->name);
+ flush_request_modules(dev->dev_next);
+ }
+
dev->disconnected = 1;
- dev_err(&dev->intf->dev, "Disconnecting\n");
+ dev_err(&dev->intf->dev, "Disconnecting %s\n", dev->name);
flush_request_modules(dev);
em28xx_close_extension(dev);
+ if(dev->dev_next!=NULL)
+ em28xx_release_resources(dev->dev_next);
em28xx_release_resources(dev);
+
+ if(dev->dev_next!=NULL) {
+ kref_put(&dev->dev_next->ref, em28xx_free_device);
+ dev->dev_next = NULL;
+ }
kref_put(&dev->ref, em28xx_free_device);
}
diff --git a/drivers/media/usb/em28xx/em28xx-core.c b/drivers/media/usb/em28xx/em28xx-core.c
index 1d0d8cc..ca0ddd5 100644
--- a/drivers/media/usb/em28xx/em28xx-core.c
+++ b/drivers/media/usb/em28xx/em28xx-core.c
@@ -638,10 +638,39 @@ int em28xx_capture_start(struct em28xx *dev, int start)
dev->chip_id == CHIP_ID_EM28174 ||
dev->chip_id == CHIP_ID_EM28178) {
/* The Transport Stream Enable Register moved in em2874 */
- rc = em28xx_write_reg_bits(dev, EM2874_R5F_TS_ENABLE,
- start ?
- EM2874_TS1_CAPTURE_ENABLE : 0x00,
- EM2874_TS1_CAPTURE_ENABLE);
+ if(dev->dvb_xfer_bulk) {
+ /* TS1 Maximum Transfer Size = 188 * EM28XX_DVB_BULK_PACKET_MULTIPLIER */
+ em28xx_write_reg(dev, EM2874_R5D_TS1_PKT_SIZE, 0xef);
+ } else {
+ /* TS1 Maximum Transfer Size = 188 * 5 */
+ em28xx_write_reg(dev, EM2874_R5D_TS1_PKT_SIZE, 0x05);
+ }
+
+ if(dev->board.has_dual_ts) {
+ if(start) {
+ if(dev->dvb_xfer_bulk) {
+ /* TS2 Maximum Transfer Size = 188 * EM28XX_DVB_BULK_PACKET_MULTIPLIER */
+ em28xx_write_reg(dev, EM2874_R5E_TS2_PKT_SIZE, 0xef);
+ } else {
+ /* TS2 Maximum Transfer Size = 188 * 5 */
+ em28xx_write_reg(dev, EM2874_R5E_TS2_PKT_SIZE, 0x05);
+ }
+ rc = em28xx_write_reg_bits(dev, EM2874_R5F_TS_ENABLE,
+ (EM2874_TS1_CAPTURE_ENABLE | EM2874_TS2_CAPTURE_ENABLE),
+ (EM2874_TS1_CAPTURE_ENABLE | EM2874_TS2_CAPTURE_ENABLE));
+ } else {
+ if(dev->ts == PRIMARY_TS) {
+ rc = em28xx_toggle_reg_bits(dev, EM2874_R5F_TS_ENABLE, EM2874_TS1_CAPTURE_ENABLE);
+ } else {
+ rc = em28xx_toggle_reg_bits(dev, EM2874_R5F_TS_ENABLE, EM2874_TS2_CAPTURE_ENABLE);
+ }
+ }
+ } else {
+ rc = em28xx_write_reg_bits(dev, EM2874_R5F_TS_ENABLE,
+ start ?
+ EM2874_TS1_CAPTURE_ENABLE : 0x00,
+ EM2874_TS1_CAPTURE_ENABLE);
+ }
} else {
/* FIXME: which is the best order? */
/* video registers are sampled by VREF */
@@ -1077,7 +1106,11 @@ int em28xx_register_extension(struct em28xx_ops *ops)
mutex_lock(&em28xx_devlist_mutex);
list_add_tail(&ops->next, &em28xx_extension_devlist);
list_for_each_entry(dev, &em28xx_devlist, devlist) {
- ops->init(dev);
+ if (ops->init) {
+ ops->init(dev);
+ if(dev->dev_next!=NULL)
+ ops->init(dev->dev_next);
+ }
}
mutex_unlock(&em28xx_devlist_mutex);
pr_info("em28xx: Registered (%s) extension\n", ops->name);
@@ -1091,7 +1124,11 @@ void em28xx_unregister_extension(struct em28xx_ops *ops)
mutex_lock(&em28xx_devlist_mutex);
list_for_each_entry(dev, &em28xx_devlist, devlist) {
- ops->fini(dev);
+ if (ops->fini) {
+ if(dev->dev_next!=NULL)
+ ops->fini(dev->dev_next);
+ ops->fini(dev);
+ }
}
list_del(&ops->next);
mutex_unlock(&em28xx_devlist_mutex);
@@ -1106,8 +1143,11 @@ void em28xx_init_extension(struct em28xx *dev)
mutex_lock(&em28xx_devlist_mutex);
list_add_tail(&dev->devlist, &em28xx_devlist);
list_for_each_entry(ops, &em28xx_extension_devlist, next) {
- if (ops->init)
+ if (ops->init) {
ops->init(dev);
+ if(dev->dev_next!=NULL)
+ ops->init(dev->dev_next);
+ }
}
mutex_unlock(&em28xx_devlist_mutex);
}
@@ -1118,8 +1158,11 @@ void em28xx_close_extension(struct em28xx *dev)
mutex_lock(&em28xx_devlist_mutex);
list_for_each_entry(ops, &em28xx_extension_devlist, next) {
- if (ops->fini)
+ if (ops->fini) {
+ if(dev->dev_next!=NULL)
+ ops->fini(dev->dev_next);
ops->fini(dev);
+ }
}
list_del(&dev->devlist);
mutex_unlock(&em28xx_devlist_mutex);
@@ -1134,6 +1177,8 @@ int em28xx_suspend_extension(struct em28xx *dev)
list_for_each_entry(ops, &em28xx_extension_devlist, next) {
if (ops->suspend)
ops->suspend(dev);
+ if(dev->dev_next!=NULL)
+ ops->suspend(dev->dev_next);
}
mutex_unlock(&em28xx_devlist_mutex);
return 0;
@@ -1148,6 +1193,8 @@ int em28xx_resume_extension(struct em28xx *dev)
list_for_each_entry(ops, &em28xx_extension_devlist, next) {
if (ops->resume)
ops->resume(dev);
+ if(dev->dev_next!=NULL)
+ ops->resume(dev->dev_next);
}
mutex_unlock(&em28xx_devlist_mutex);
return 0;
diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c b/drivers/media/usb/em28xx/em28xx-dvb.c
index 82edd37..e10b1ac 100644
--- a/drivers/media/usb/em28xx/em28xx-dvb.c
+++ b/drivers/media/usb/em28xx/em28xx-dvb.c
@@ -199,13 +199,13 @@ static int em28xx_start_streaming(struct em28xx_dvb *dvb)
int rc;
struct em28xx_i2c_bus *i2c_bus = dvb->adapter.priv;
struct em28xx *dev = i2c_bus->dev;
- struct usb_device *udev = interface_to_usbdev(dev->intf);
+// struct usb_device *udev = interface_to_usbdev(dev->intf);
int dvb_max_packet_size, packet_multiplier, dvb_alt;
if (dev->dvb_xfer_bulk) {
if (!dev->dvb_ep_bulk)
return -ENODEV;
- dvb_max_packet_size = 512; /* USB 2.0 spec */
+ dvb_max_packet_size = 188;
packet_multiplier = EM28XX_DVB_BULK_PACKET_MULTIPLIER;
dvb_alt = 0;
} else { /* isoc */
@@ -218,7 +218,8 @@ static int em28xx_start_streaming(struct em28xx_dvb *dvb)
dvb_alt = dev->dvb_alt_isoc;
}
- usb_set_interface(udev, dev->ifnum, dvb_alt);
+ /* moved to em28xx_dvb_init*/
+ //usb_set_interface(udev, dev->ifnum, dvb_alt);
rc = em28xx_set_mode(dev, EM28XX_DIGITAL_MODE);
if (rc < 0)
return rc;
@@ -1128,8 +1129,9 @@ static void em28xx_unregister_dvb(struct em28xx_dvb *dvb)
static int em28xx_dvb_init(struct em28xx *dev)
{
- int result = 0;
+ int result = 0, dvb_alt = 0;
struct em28xx_dvb *dvb;
+ struct usb_device *udev;
if (dev->is_audio_only) {
/* Shouldn't initialize IR for this interface */
@@ -1155,7 +1157,7 @@ static int em28xx_dvb_init(struct em28xx *dev)
result = em28xx_alloc_urbs(dev, EM28XX_DIGITAL_MODE,
dev->dvb_xfer_bulk,
EM28XX_DVB_NUM_BUFS,
- 512,
+ 188,
EM28XX_DVB_BULK_PACKET_MULTIPLIER);
} else {
result = em28xx_alloc_urbs(dev, EM28XX_DIGITAL_MODE,
@@ -1913,7 +1915,8 @@ static int em28xx_dvb_init(struct em28xx *dev)
si2168_config.ts_mode = SI2168_TS_SERIAL;
memset(&info, 0, sizeof(struct i2c_board_info));
strlcpy(info.type, "si2168", I2C_NAME_SIZE);
- info.addr = 0x64;
+ if(dev->ts == PRIMARY_TS) info.addr = 0x64;
+ else info.addr = 0x67;
info.platform_data = &si2168_config;
request_module(info.type);
client = i2c_new_device(&dev->i2c_adap[dev->def_i2c_bus], &info);
@@ -1939,7 +1942,8 @@ static int em28xx_dvb_init(struct em28xx *dev)
#endif
memset(&info, 0, sizeof(struct i2c_board_info));
strlcpy(info.type, "si2157", I2C_NAME_SIZE);
- info.addr = 0x60;
+ if(dev->ts == PRIMARY_TS) info.addr = 0x60;
+ else info.addr = 0x63;
info.platform_data = &si2157_config;
request_module(info.type);
client = i2c_new_device(adapter, &info);
@@ -1975,7 +1979,8 @@ static int em28xx_dvb_init(struct em28xx *dev)
lgdt3306a_config.fe = &dvb->fe[0];
lgdt3306a_config.i2c_adapter = &adapter;
strlcpy(info.type, "lgdt3306a", sizeof(info.type));
- info.addr = 0x59;
+ if(dev->ts == PRIMARY_TS) info.addr = 0x59;
+ else info.addr = 0x0e;
info.platform_data = &lgdt3306a_config;
request_module(info.type);
client = i2c_new_device(&dev->i2c_adap[dev->def_i2c_bus],
@@ -2002,7 +2007,8 @@ static int em28xx_dvb_init(struct em28xx *dev)
#endif
memset(&info, 0, sizeof(struct i2c_board_info));
strlcpy(info.type, "si2157", sizeof(info.type));
- info.addr = 0x60;
+ if(dev->ts == PRIMARY_TS) info.addr = 0x60;
+ else info.addr = 0x62;
info.platform_data = &si2157_config;
request_module(info.type);
@@ -2045,6 +2051,14 @@ static int em28xx_dvb_init(struct em28xx *dev)
if (result < 0)
goto out_free;
+ if (dev->dvb_xfer_bulk) {
+ dvb_alt = 0;
+ } else { /* isoc */
+ dvb_alt = dev->dvb_alt_isoc;
+ }
+
+ udev = interface_to_usbdev(dev->intf);
+ usb_set_interface(udev, dev->ifnum, dvb_alt);
dev_info(&dev->intf->dev, "DVB extension successfully initialized\n");
kref_get(&dev->ref);
diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h
index e8d97d5..132638e 100644
--- a/drivers/media/usb/em28xx/em28xx.h
+++ b/drivers/media/usb/em28xx/em28xx.h
@@ -190,7 +190,7 @@
USB 2.0 spec says bulk packet size is always 512 bytes
*/
#define EM28XX_BULK_PACKET_MULTIPLIER 384
-#define EM28XX_DVB_BULK_PACKET_MULTIPLIER 384
+#define EM28XX_DVB_BULK_PACKET_MULTIPLIER 240
#define EM28XX_INTERLACED_DEFAULT 1
@@ -216,6 +216,9 @@
/* max. number of button state polling addresses */
#define EM28XX_NUM_BUTTON_ADDRESSES_MAX 5
+#define PRIMARY_TS 0
+#define SECONDARY_TS 1
+
enum em28xx_mode {
EM28XX_SUSPEND,
EM28XX_ANALOG_MODE,
@@ -456,6 +459,7 @@ struct em28xx_board {
unsigned int mts_firmware:1;
unsigned int max_range_640_480:1;
unsigned int has_dvb:1;
+ unsigned int has_dual_ts:1;
unsigned int is_webcam:1;
unsigned int valid:1;
unsigned int has_ir_i2c:1;
@@ -620,6 +624,7 @@ struct em28xx {
unsigned int is_audio_only:1;
enum em28xx_int_audio_type int_audio_type;
enum em28xx_usb_audio_type usb_audio_type;
+ unsigned char name[32];
struct em28xx_board board;
@@ -681,6 +686,8 @@ struct em28xx {
u8 ifnum; /* number of the assigned usb interface */
u8 analog_ep_isoc; /* address of isoc endpoint for analog */
u8 analog_ep_bulk; /* address of bulk endpoint for analog */
+ u8 dvb_ep_isoc_ts2; /* address of isoc endpoint for DVB TS2*/
+ u8 dvb_ep_bulk_ts2; /* address of bulk endpoint for DVB TS2*/
u8 dvb_ep_isoc; /* address of isoc endpoint for DVB */
u8 dvb_ep_bulk; /* address of bulk endpoint for DVB */
int alt; /* alternate setting */
@@ -694,6 +701,8 @@ struct em28xx {
int dvb_alt_isoc; /* alternate setting for DVB isoc transfers */
unsigned int dvb_max_pkt_size_isoc; /* isoc max packet size of the
selected DVB ep at dvb_alt */
+ unsigned int dvb_max_pkt_size_isoc_ts2; /* isoc max packet size of the
+ selected DVB ep at dvb_alt */
unsigned int dvb_xfer_bulk:1; /* use bulk instead of isoc
transfers for DVB */
char urb_buf[URB_MAX_CTRL_SIZE]; /* urb control msg buffer */
@@ -725,6 +734,9 @@ struct em28xx {
struct media_entity input_ent[MAX_EM28XX_INPUT];
struct media_pad input_pad[MAX_EM28XX_INPUT];
#endif
+
+ struct em28xx *dev_next;
+ int ts;
};
#define kref_to_dev(d) container_of(d, struct em28xx, ref)
--
2.7.4

View File

@ -0,0 +1,983 @@
From 31df469c9e23ec37696dd4e6421cb2e2d8f00f77 Mon Sep 17 00:00:00 2001
From: zdl <823469641@qq.com>
Date: Tue, 11 Jul 2017 18:40:23 +0800
Subject: [PATCH] added support for TBS5580 CI box
---
diff --git a/drivers/media/usb/dvb-usb/Kconfig b/drivers/media/usb/dvb-usb/Kconfig
index bf31d7cab1d5..ecc7de956035 100644
--- a/drivers/media/usb/dvb-usb/Kconfig
+++ b/drivers/media/usb/dvb-usb/Kconfig
@@ -440,6 +440,15 @@ config DVB_USB_TBS5520se
help
Say Y here to support the Turbosight TBS5520se USB2 DVB-T/T2/C/C2/S/S2/S2x device
+config DVB_USB_TBS5580
+ tristate "Turbosight TBS5580 CI support"
+ depends on DVB_USB
+ select DVB_SI2183 if MEDIA_SUBDRV_AUTOSELECT
+ select MEDIA_TUNER_SI2157 if MEDIA_SUBDRV_AUTOSELECT
+ select MEDIA_TUNER_AV201X if MEDIA_SUBDRV_AUTOSELECT
+ help
+ Say Y here to support the Turbosight TBS5580 CI USB2 DVB-T/T2/C/C2/S/S2/S2x device
+
config DVB_USB_TBS5927
tristate "TurboSight TBS5927 DVB-S2 USB2.0 support"
depends on DVB_USB
diff --git a/drivers/media/usb/dvb-usb/Makefile b/drivers/media/usb/dvb-usb/Makefile
index ab69673cc4b7..f5872191f45f 100644
--- a/drivers/media/usb/dvb-usb/Makefile
+++ b/drivers/media/usb/dvb-usb/Makefile
@@ -115,6 +115,9 @@ obj-$(CONFIG_DVB_USB_TBS5520) += dvb-usb-tbs5520.o
dvb-usb-tbs5520se-objs = tbs5520se.o
obj-$(CONFIG_DVB_USB_TBS5520se) += dvb-usb-tbs5520se.o
+dvb-usb-tbs5580-objs = tbs5580.o
+obj-$(CONFIG_DVB_USB_TBS5580) += dvb-usb-tbs5580.o
+
dvb-usb-tbs5927-objs = tbs5927.o
obj-$(CONFIG_DVB_USB_TBS5927) += dvb-usb-tbs5927.o
diff --git a/drivers/media/usb/dvb-usb/tbs5580.c b/drivers/media/usb/dvb-usb/tbs5580.c
new file mode 100644
index 000000000000..4f47dc2cf64f
--- /dev/null
+++ b/drivers/media/usb/dvb-usb/tbs5580.c
@@ -0,0 +1,789 @@
+/*
+ * TurboSight TBS 5580se driver
+ *
+ * Copyright (c) 2017 Davin zhang <smiledavin@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, version 2.
+ *
+ */
+
+#include <linux/version.h>
+#include "tbs5580.h"
+#include "si2183.h"
+#include "si2157.h"
+#include "av201x.h"
+#include "dvb_ca_en50221.h"
+
+#define TBS5580_READ_MSG 0
+#define TBS5580_WRITE_MSG 1
+
+#define TBS5580_VOLTAGE_CTRL (0x1800)
+
+
+struct tbs5580_state {
+ struct i2c_client *i2c_client_demod;
+ struct i2c_client *i2c_client_tuner;
+ struct dvb_ca_en50221 ca;
+ struct mutex ca_mutex;
+};
+
+static struct av201x_config tbs5580_av201x_cfg = {
+ .i2c_address = 0x62,
+ .id = ID_AV2018,
+ .xtal_freq = 27000,
+};
+
+/* debug */
+static int dvb_usb_tbs5580_debug;
+module_param_named(debug, dvb_usb_tbs5580_debug, int, 0644);
+MODULE_PARM_DESC(debug, "set debugging level (1=info 2=xfer (or-able))."
+ DVB_USB_DEBUG_STATUS);
+
+DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
+
+static int tbs5580_op_rw(struct usb_device *dev, u8 request, u16 value,
+ u16 index, u8 * data, u16 len, int flags)
+{
+ int ret;
+ u8 u8buf[len];
+
+ unsigned int pipe = (flags == TBS5580_READ_MSG) ?
+ usb_rcvctrlpipe(dev, 0) : usb_sndctrlpipe(dev, 0);
+ u8 request_type = (flags == TBS5580_READ_MSG) ? USB_DIR_IN :
+ USB_DIR_OUT;
+
+ if (flags == TBS5580_WRITE_MSG)
+ memcpy(u8buf, data, len);
+ ret = usb_control_msg(dev, pipe, request, request_type |
+ USB_TYPE_VENDOR, value, index , u8buf, len, 2000);
+
+ if (flags == TBS5580_READ_MSG)
+ memcpy(data, u8buf, len);
+ return ret;
+}
+
+static int tbs5580_read_attribute_mem(struct dvb_ca_en50221 *ca,
+ int slot, int address)
+{
+ struct dvb_usb_device *d = (struct dvb_usb_device *)ca->data;
+ struct tbs5580_state *state = (struct tbs5580_state *)d->priv;
+ u8 buf[4], rbuf[3];
+ int ret;
+
+ if (0 != slot)
+ return -EINVAL;
+
+ buf[0] = 1;
+ buf[1] = 0;
+ buf[2] = (address >> 8) & 0x0f;
+ buf[3] = address;
+
+ //msleep(10);
+
+ mutex_lock(&state->ca_mutex);
+
+ ret = tbs5580_op_rw(d->udev, 0xa4, 0, 0,
+ buf, 4, TBS5580_WRITE_MSG);
+
+ //msleep(1);
+
+ ret = tbs5580_op_rw(d->udev, 0xa5, 0, 0,
+ rbuf, 1, TBS5580_READ_MSG);
+
+ mutex_unlock(&state->ca_mutex);
+
+ if (ret < 0)
+ return ret;
+
+ return rbuf[0];
+}
+
+static int tbs5580_write_attribute_mem(struct dvb_ca_en50221 *ca,
+ int slot, int address, u8 value)
+{
+ struct dvb_usb_device *d = (struct dvb_usb_device *)ca->data;
+ struct tbs5580_state *state = (struct tbs5580_state *)d->priv;
+ u8 buf[5];//, rbuf[1];
+ int ret;
+
+ if (0 != slot)
+ return -EINVAL;
+
+ buf[0] = 1;
+ buf[1] = 0;
+ buf[2] = (address >> 8) & 0x0f;
+ buf[3] = address;
+ buf[4] = value;
+
+ mutex_lock(&state->ca_mutex);
+
+ ret = tbs5580_op_rw(d->udev, 0xa2, 0, 0,
+ buf, 5, TBS5580_WRITE_MSG);
+
+ //msleep(1);
+
+ //ret = tbs5580_op_rw(d->udev, 0xa5, 0, 0,
+ // rbuf, 1, TBS5580_READ_MSG);
+
+ mutex_unlock(&state->ca_mutex);
+
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
+static int tbs5580_read_cam_control(struct dvb_ca_en50221 *ca, int slot,
+ u8 address)
+{
+ struct dvb_usb_device *d = (struct dvb_usb_device *)ca->data;
+ struct tbs5580_state *state = (struct tbs5580_state *)d->priv;
+ u8 buf[4], rbuf[1];
+ int ret;
+
+ if (0 != slot)
+ return -EINVAL;
+
+ buf[0] = 1;
+ buf[1] = 1;
+ buf[2] = (address >> 8) & 0x0f;
+ buf[3] = address;
+
+ mutex_lock(&state->ca_mutex);
+
+ ret = tbs5580_op_rw(d->udev, 0xa4, 0, 0,
+ buf, 4, TBS5580_WRITE_MSG);
+
+ //msleep(10);
+
+ ret = tbs5580_op_rw(d->udev, 0xa5, 0, 0,
+ rbuf, 1, TBS5580_READ_MSG);
+
+ mutex_unlock(&state->ca_mutex);
+
+ if (ret < 0)
+ return ret;
+
+ return rbuf[0];
+}
+
+static int tbs5580_write_cam_control(struct dvb_ca_en50221 *ca, int slot,
+ u8 address, u8 value)
+{
+ struct dvb_usb_device *d = (struct dvb_usb_device *)ca->data;
+ struct tbs5580_state *state = (struct tbs5580_state *)d->priv;
+ u8 buf[5];//, rbuf[1];
+ int ret;
+
+ if (0 != slot)
+ return -EINVAL;
+
+ buf[0] = 1;
+ buf[1] = 1;
+ buf[2] = (address >> 8) & 0x0f;
+ buf[3] = address;
+ buf[4] = value;
+
+ mutex_lock(&state->ca_mutex);
+
+ ret = tbs5580_op_rw(d->udev, 0xa2, 0, 0,
+ buf, 5, TBS5580_WRITE_MSG);
+
+ //msleep(1);
+
+ //ret = tbs5580_op_rw(d->udev, 0xa5, 0, 0,
+ // rbuf, 1, TBS5580_READ_MSG);
+
+ mutex_unlock(&state->ca_mutex);
+
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
+static int tbs5580_set_video_port(struct dvb_ca_en50221 *ca,
+ int slot, int enable)
+{
+ struct dvb_usb_device *d = (struct dvb_usb_device *)ca->data;
+ struct tbs5580_state *state = (struct tbs5580_state *)d->priv;
+ u8 buf[2];
+ int ret;
+
+ if (0 != slot)
+ return -EINVAL;
+
+ buf[0] = 2;
+ buf[1] = enable;
+
+ mutex_lock(&state->ca_mutex);
+
+ ret = tbs5580_op_rw(d->udev, 0xa6, 0, 0,
+ buf, 2, TBS5580_WRITE_MSG);
+
+ mutex_unlock(&state->ca_mutex);
+
+ if (ret < 0)
+ return ret;
+
+ if (enable != buf[1]) {
+ err("CI not %sabled.", enable ? "en" : "dis");
+ return -EIO;
+ }
+
+ info("CI %sabled.", enable ? "en" : "dis");
+ return 0;
+}
+
+static int tbs5580_slot_shutdown(struct dvb_ca_en50221 *ca, int slot)
+{
+ return tbs5580_set_video_port(ca, slot, /* enable */ 0);
+}
+
+static int tbs5580_slot_ts_enable(struct dvb_ca_en50221 *ca, int slot)
+{
+ return tbs5580_set_video_port(ca, slot, /* enable */ 1);
+}
+
+static int tbs5580_slot_reset(struct dvb_ca_en50221 *ca, int slot)
+{
+ struct dvb_usb_device *d = (struct dvb_usb_device *)ca->data;
+ struct tbs5580_state *state = (struct tbs5580_state *)d->priv;
+ u8 buf[2];
+ int ret;
+
+ if (0 != slot) {
+ return -EINVAL;
+ }
+
+ buf[0] = 1;
+ buf[1] = 0;
+
+ mutex_lock (&state->ca_mutex);
+
+ ret = tbs5580_op_rw(d->udev, 0xa6, 0, 0,
+ buf, 2, TBS5580_WRITE_MSG);
+
+ msleep (5);
+
+ buf[1] = 1;
+
+ ret = tbs5580_op_rw(d->udev, 0xa6, 0, 0,
+ buf, 2, TBS5580_WRITE_MSG);
+
+ msleep (1400);
+
+ mutex_unlock (&state->ca_mutex);
+
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
+static int tbs5580_poll_slot_status(struct dvb_ca_en50221 *ca,
+ int slot, int open)
+{
+ struct dvb_usb_device *d = (struct dvb_usb_device *)ca->data;
+ struct tbs5580_state *state = (struct tbs5580_state *)d->priv;
+ u8 buf[3];
+
+ if (0 != slot)
+ return -EINVAL;
+
+ mutex_lock(&state->ca_mutex);
+
+ tbs5580_op_rw(d->udev, 0xa8, 0, 0,
+ buf, 3, TBS5580_READ_MSG);
+
+ mutex_unlock(&state->ca_mutex);
+
+ if ((1 == buf[2]) && (1 == buf[1]) && (0xa9 == buf[0])) {
+ return (DVB_CA_EN50221_POLL_CAM_PRESENT |
+ DVB_CA_EN50221_POLL_CAM_READY);
+ } else {
+ return 0;
+ }
+}
+
+static void tbs5580_uninit(struct dvb_usb_device *d)
+{
+ struct tbs5580_state *state;
+
+ if (NULL == d)
+ return;
+
+ state = (struct tbs5580_state *)d->priv;
+ if (NULL == state)
+ return;
+
+ if (NULL == state->ca.data)
+ return;
+
+ /* Error ignored. */
+ tbs5580_set_video_port(&state->ca, /* slot */ 0, /* enable */ 0);
+
+ dvb_ca_en50221_release(&state->ca);
+
+ memset(&state->ca, 0, sizeof(state->ca));
+}
+
+static int tbs5580_init(struct dvb_usb_adapter *a)
+{
+
+ struct dvb_usb_device *d = a->dev;
+ struct tbs5580_state *state = (struct tbs5580_state *)d->priv;
+ int ret;
+
+ state->ca.owner = THIS_MODULE;
+ state->ca.read_attribute_mem = tbs5580_read_attribute_mem;
+ state->ca.write_attribute_mem = tbs5580_write_attribute_mem;
+ state->ca.read_cam_control = tbs5580_read_cam_control;
+ state->ca.write_cam_control = tbs5580_write_cam_control;
+ state->ca.slot_reset = tbs5580_slot_reset;
+ state->ca.slot_shutdown = tbs5580_slot_shutdown;
+ state->ca.slot_ts_enable = tbs5580_slot_ts_enable;
+ state->ca.poll_slot_status = tbs5580_poll_slot_status;
+ state->ca.data = d;
+
+ ret = dvb_ca_en50221_init (&a->dvb_adap, &state->ca,
+ /* flags */ 0, /* n_slots */ 1);
+
+ if (0 != ret) {
+ err ("Cannot initialize CI: Error %d.", ret);
+ memset (&state->ca, 0, sizeof (state->ca));
+ return ret;
+ }
+
+ info ("CI initialized.");
+
+ ret = tbs5580_poll_slot_status(&state->ca, 0, 0);
+ if (0 == ret)
+ tbs5580_set_video_port(&state->ca, /* slot */ 0, /* enable */ 0);
+
+ return 0;
+}
+
+/* I2C */
+static int tbs5580_i2c_transfer(struct i2c_adapter *adap,
+ struct i2c_msg msg[], int num)
+{
+ struct dvb_usb_device *d = i2c_get_adapdata(adap);
+ struct tbs5580_state *state = (struct tbs5580_state *)d->priv;
+ int i = 0;
+ u8 buf6[20];
+ u8 inbuf[20];
+
+ if (!d)
+ return -ENODEV;
+ mutex_lock(&state->ca_mutex);
+ if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
+ return -EAGAIN;
+
+ switch (num) {
+ case 2:
+ buf6[0]=msg[1].len;//lenth
+ buf6[1]=msg[0].addr<<1;//demod addr
+ //register
+ buf6[2] = msg[0].buf[0];
+
+ tbs5580_op_rw(d->udev, 0x90, 0, 0,
+ buf6, 3, TBS5580_WRITE_MSG);
+ //msleep(5);
+ tbs5580_op_rw(d->udev, 0x91, 0, 0,
+ inbuf, buf6[0], TBS5580_READ_MSG);
+ memcpy(msg[1].buf, inbuf, msg[1].len);
+ break;
+ case 1:
+ switch (msg[0].addr) {
+ case 0x67:
+ case 0x62:
+ case 0x61:
+ if (msg[0].flags == 0) {
+ buf6[0] = msg[0].len+1;//lenth
+ buf6[1] = msg[0].addr<<1;//addr
+ for(i=0;i<msg[0].len;i++) {
+ buf6[2+i] = msg[0].buf[i];//register
+ }
+ tbs5580_op_rw(d->udev, 0x80, 0, 0,
+ buf6, msg[0].len+2, TBS5580_WRITE_MSG);
+ } else {
+ buf6[0] = msg[0].len;//length
+ buf6[1] = (msg[0].addr<<1) | 0x01;//addr
+ tbs5580_op_rw(d->udev, 0x93, 0, 0,
+ buf6, 2, TBS5580_WRITE_MSG);
+ //msleep(5);
+ tbs5580_op_rw(d->udev, 0x91, 0, 0,
+ inbuf, buf6[0], TBS5580_READ_MSG);
+ memcpy(msg[0].buf, inbuf, msg[0].len);
+ }
+ //msleep(3);
+ break;
+ case (TBS5580_VOLTAGE_CTRL):
+ buf6[0] = 3;
+ buf6[1] = msg[0].buf[0];
+ tbs5580_op_rw(d->udev, 0x8a, 0, 0,
+ buf6, 2, TBS5580_WRITE_MSG);
+ break;
+ }
+
+ break;
+ }
+
+ mutex_unlock(&d->i2c_mutex);
+ mutex_unlock(&state->ca_mutex);
+ return num;
+}
+
+static u32 tbs5580_i2c_func(struct i2c_adapter *adapter)
+{
+ return I2C_FUNC_I2C;
+}
+
+static struct i2c_algorithm tbs5580_i2c_algo = {
+ .master_xfer = tbs5580_i2c_transfer,
+ .functionality = tbs5580_i2c_func,
+};
+
+static int tbs5580_set_voltage(struct dvb_frontend *fe,
+ enum fe_sec_voltage voltage)
+{
+ static u8 command_13v[1] = {0x00};
+ static u8 command_18v[1] = {0x01};
+ struct i2c_msg msg[] = {
+ {.addr = TBS5580_VOLTAGE_CTRL, .flags = 0,
+ .buf = command_13v, .len = 1},
+ };
+
+ struct dvb_usb_adapter *udev_adap =
+ (struct dvb_usb_adapter *)(fe->dvb->priv);
+ if (voltage == SEC_VOLTAGE_18)
+ msg[0].buf = command_18v;
+
+
+ i2c_transfer(&udev_adap->dev->i2c_adap, msg, 1);
+
+ return 0;
+}
+
+static int tbs5580_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
+{
+ int i,ret;
+ u8 ibuf[3] = {0, 0,0};
+ u8 eeprom[256], eepromline[16];
+
+ for (i = 0; i < 256; i++) {
+ ibuf[0]=1;//lenth
+ ibuf[1]=0xa0;//eeprom addr
+ ibuf[2]=i;//register
+ ret = tbs5580_op_rw(d->udev, 0x90, 0, 0,
+ ibuf, 3, TBS5580_WRITE_MSG);
+ ret = tbs5580_op_rw(d->udev, 0x91, 0, 0,
+ ibuf, 1, TBS5580_READ_MSG);
+ if (ret < 0) {
+ err("read eeprom failed.");
+ return -1;
+ } else {
+ eepromline[i%16] = ibuf[0];
+ eeprom[i] = ibuf[0];
+ }
+
+ if ((i % 16) == 15) {
+ deb_xfer("%02x: ", i - 15);
+ debug_dump(eepromline, 16, deb_xfer);
+ }
+ }
+ memcpy(mac, eeprom + 16, 6);
+ return 0;
+};
+
+static struct dvb_usb_device_properties tbs5580_properties;
+
+static int tbs5580_frontend_attach(struct dvb_usb_adapter *adap)
+{
+ struct dvb_usb_device *d = adap->dev;
+ struct tbs5580_state *st = d->priv;
+ struct i2c_adapter *adapter;
+ struct i2c_client *client_demod;
+ struct i2c_client *client_tuner;
+ struct i2c_board_info info;
+ struct si2183_config si2183_config;
+ struct si2157_config si2157_config;
+ u8 buf[20];
+
+ mutex_init(&st->ca_mutex);
+ /* attach frontend */
+ memset(&si2183_config,0,sizeof(si2183_config));
+ si2183_config.i2c_adapter = &adapter;
+ si2183_config.fe = &adap->fe_adap[0].fe;
+ si2183_config.ts_mode = SI2183_TS_PARALLEL;
+ si2183_config.ts_clock_gapped = true;
+ si2183_config.rf_in = 0;
+ si2183_config.RF_switch = NULL;
+ si2183_config.agc_mode = 0x5 ;
+ memset(&info, 0, sizeof(struct i2c_board_info));
+ strlcpy(info.type, "si2183", I2C_NAME_SIZE);
+ info.addr = 0x67;
+ info.platform_data = &si2183_config;
+ request_module(info.type);
+ client_demod = i2c_new_device(&d->i2c_adap, &info);
+ if (client_demod == NULL || client_demod->dev.driver == NULL)
+ return -ENODEV;
+
+ if (!try_module_get(client_demod->dev.driver->owner)) {
+ i2c_unregister_device(client_demod);
+ return -ENODEV;
+ }
+ st->i2c_client_demod = client_demod;
+
+ /* dvb core doesn't support 2 tuners for 1 demod so
+ we split the adapter in 2 frontends */
+
+ adap->fe_adap[0].fe2 = &adap->fe_adap[0]._fe2;
+ memcpy(adap->fe_adap[0].fe2, adap->fe_adap[0].fe, sizeof(struct dvb_frontend));
+
+ /* terrestrial tuner */
+ memset(adap->fe_adap[0].fe->ops.delsys, 0, MAX_DELSYS);
+ adap->fe_adap[0].fe->ops.delsys[0] = SYS_DVBT;
+ adap->fe_adap[0].fe->ops.delsys[1] = SYS_DVBT2;
+ adap->fe_adap[0].fe->ops.delsys[2] = SYS_DVBC_ANNEX_A;
+ adap->fe_adap[0].fe->ops.delsys[3] = SYS_ISDBT;
+ adap->fe_adap[0].fe->ops.delsys[4] = SYS_DVBC_ANNEX_B;
+
+ /* attach ter tuner */
+ memset(&si2157_config, 0, sizeof(si2157_config));
+ si2157_config.fe = adap->fe_adap[0].fe;
+ si2157_config.if_port = 1;
+ memset(&info, 0, sizeof(struct i2c_board_info));
+ strlcpy(info.type, "si2157", I2C_NAME_SIZE);
+ info.addr = 0x61;
+ info.platform_data = &si2157_config;
+ request_module(info.type);
+ client_tuner = i2c_new_device(adapter, &info);
+ if (client_tuner == NULL || client_tuner->dev.driver == NULL) {
+ module_put(client_demod->dev.driver->owner);
+ i2c_unregister_device(client_demod);
+ return -ENODEV;
+ }
+ if (!try_module_get(client_tuner->dev.driver->owner)) {
+ i2c_unregister_device(client_tuner);
+ module_put(client_demod->dev.driver->owner);
+ i2c_unregister_device(client_demod);
+ return -ENODEV;
+ }
+
+ st->i2c_client_tuner = client_tuner;
+
+ /*attach SAT tuner*/
+ memset(adap->fe_adap[0].fe2->ops.delsys, 0, MAX_DELSYS);
+ adap->fe_adap[0].fe2->ops.delsys[0] = SYS_DVBS;
+ adap->fe_adap[0].fe2->ops.delsys[1] = SYS_DVBS2;
+ adap->fe_adap[0].fe2->ops.delsys[2] = SYS_DSS;
+ adap->fe_adap[0].fe2->id = 1;
+
+ if (dvb_attach(av201x_attach, adap->fe_adap[0].fe2, &tbs5580_av201x_cfg,
+ adapter) == NULL) {
+ return -ENODEV;
+ }
+ else {
+ buf[0] = 1;
+ buf[1] = 0;
+ tbs5580_op_rw(d->udev, 0x8a, 0, 0,
+ buf, 2, TBS5580_WRITE_MSG);
+
+ adap->fe_adap[0].fe2->ops.set_voltage = tbs5580_set_voltage;
+
+ }
+
+ buf[0] = 0;
+ buf[1] = 0;
+ tbs5580_op_rw(d->udev, 0xb7, 0, 0,
+ buf, 2, TBS5580_WRITE_MSG);
+ buf[0] = 8;
+ buf[1] = 1;
+ tbs5580_op_rw(d->udev, 0x8a, 0, 0,
+ buf, 2, TBS5580_WRITE_MSG);
+
+ tbs5580_init(adap);
+
+ strlcpy(adap->fe_adap[0].fe->ops.info.name,d->props.devices[0].name,52);
+ strcat(adap->fe_adap[0].fe->ops.info.name," DVB-T/T2/C/C2/ISDB-T");
+ strlcpy(adap->fe_adap[0].fe2->ops.info.name,d->props.devices[0].name,52);
+ strcat(adap->fe_adap[0].fe2->ops.info.name," DVB-S/S2/S2X");
+
+ return 0;
+}
+
+static struct usb_device_id tbs5580_table[] = {
+ {USB_DEVICE(0x734c, 0x5580)},
+ { }
+};
+
+MODULE_DEVICE_TABLE(usb, tbs5580_table);
+
+static int tbs5580_load_firmware(struct usb_device *dev,
+ const struct firmware *frmwr)
+{
+ u8 *b, *p;
+ int ret = 0, i;
+ u8 reset;
+ const struct firmware *fw;
+ switch (dev->descriptor.idProduct) {
+ case 0x5580:
+ ret = request_firmware(&fw, tbs5580_properties.firmware, &dev->dev);
+ if (ret != 0) {
+ err("did not find the firmware file. (%s) "
+ "Please see linux/Documentation/dvb/ for more details "
+ "on firmware-problems.", tbs5580_properties.firmware);
+ return ret;
+ }
+ break;
+ default:
+ fw = frmwr;
+ break;
+ }
+ info("start downloading TBS5580 firmware");
+ p = kmalloc(fw->size, GFP_KERNEL);
+ reset = 1;
+ /*stop the CPU*/
+ tbs5580_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1, TBS5580_WRITE_MSG);
+ tbs5580_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1, TBS5580_WRITE_MSG);
+
+ if (p != NULL) {
+ memcpy(p, fw->data, fw->size);
+ for (i = 0; i < fw->size; i += 0x40) {
+ b = (u8 *) p + i;
+ if (tbs5580_op_rw(dev, 0xa0, i, 0, b , 0x40,
+ TBS5580_WRITE_MSG) != 0x40) {
+ err("error while transferring firmware");
+ ret = -EINVAL;
+ break;
+ }
+ }
+ /* restart the CPU */
+ reset = 0;
+ if (ret || tbs5580_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1,
+ TBS5580_WRITE_MSG) != 1) {
+ err("could not restart the USB controller CPU.");
+ ret = -EINVAL;
+ }
+ if (ret || tbs5580_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1,
+ TBS5580_WRITE_MSG) != 1) {
+ err("could not restart the USB controller CPU.");
+ ret = -EINVAL;
+ }
+
+ msleep(100);
+ kfree(p);
+ }
+ return ret;
+}
+
+static struct dvb_usb_device_properties tbs5580_properties = {
+ .caps = DVB_USB_IS_AN_I2C_ADAPTER,
+ .usb_ctrl = DEVICE_SPECIFIC,
+ .firmware = "dvb-usb-id5580.fw",
+ .size_of_priv = sizeof(struct tbs5580_state),
+ .no_reconnect = 1,
+
+ .i2c_algo = &tbs5580_i2c_algo,
+
+ .generic_bulk_ctrl_endpoint = 0x81,
+ /* parameter for the MPEG2-data transfer */
+ .num_adapters = 1,
+ .download_firmware = tbs5580_load_firmware,
+ .read_mac_address = tbs5580_read_mac_address,
+ .adapter = {{
+ .num_frontends = 1,
+ .fe = {{
+ .frontend_attach = tbs5580_frontend_attach,
+ .streaming_ctrl = NULL,
+ .tuner_attach = NULL,
+ .stream = {
+ .type = USB_BULK,
+ .count = 8,
+ .endpoint = 0x82,
+ .u = {
+ .bulk = {
+ .buffersize = 4096,
+ }
+ }
+ },
+ }},
+ }},
+
+ .num_device_descs = 1,
+ .devices = {
+ {"TBS 5580 CI USB2.0",
+ {&tbs5580_table[0], NULL},
+ {NULL},
+ }
+ }
+};
+
+static int tbs5580_probe(struct usb_interface *intf,
+ const struct usb_device_id *id)
+{
+ if (0 == dvb_usb_device_init(intf, &tbs5580_properties,
+ THIS_MODULE, NULL, adapter_nr)) {
+ return 0;
+ }
+ return -ENODEV;
+}
+
+static void tbs5580_disconnect(struct usb_interface *intf)
+{
+
+ struct dvb_usb_device *d = usb_get_intfdata(intf);
+#if 0
+ struct tbs5580_state *st = d->priv;
+ struct i2c_client *client;
+
+ /* remove I2C client for tuner */
+ client = st->i2c_client_tuner;
+ if (client) {
+ module_put(client->dev.driver->owner);
+ i2c_unregister_device(client);
+ }
+
+ /* remove I2C client for demodulator */
+ client = st->i2c_client_demod;
+ if (client) {
+ module_put(client->dev.driver->owner);
+ i2c_unregister_device(client);
+ }
+#endif
+ tbs5580_uninit(d);
+ dvb_usb_device_exit(intf);
+}
+
+static struct usb_driver tbs5580_driver = {
+ .name = "tbs5580",
+ .probe = tbs5580_probe,
+ .disconnect = tbs5580_disconnect,
+ .id_table = tbs5580_table,
+};
+
+static int __init tbs5580_module_init(void)
+{
+ int ret = usb_register(&tbs5580_driver);
+ if (ret)
+ err("usb_register failed. Error number %d", ret);
+
+ return ret;
+}
+
+static void __exit tbs5580_module_exit(void)
+{
+ usb_deregister(&tbs5580_driver);
+}
+
+module_init(tbs5580_module_init);
+module_exit(tbs5580_module_exit);
+
+MODULE_AUTHOR("Davin zhang <smiledavin@gmail.com>");
+MODULE_DESCRIPTION("TurboSight TBS 5580 driver");
+MODULE_VERSION("1.0");
+MODULE_LICENSE("GPL");
diff --git a/drivers/media/usb/dvb-usb/tbs5580.h b/drivers/media/usb/dvb-usb/tbs5580.h
new file mode 100644
index 000000000000..e83b34c42941
--- /dev/null
+++ b/drivers/media/usb/dvb-usb/tbs5580.h
@@ -0,0 +1,8 @@
+#ifndef _TBS5580_H_
+#define _TBS5580_H_
+
+#define DVB_USB_LOG_PREFIX "tbs5580"
+#include "dvb-usb.h"
+
+#define deb_xfer(args...) dprintk(dvb_usb_tbs5580_debug, 0x02, args)
+#endif
diff --git a/drivers/media/dvb-frontends/si2183.c b/drivers/media/dvb-frontends/si2183.c
index d6cdff8..ea1dee0 100644
--- a/drivers/media/dvb-frontends/si2183.c
+++ b/drivers/media/dvb-frontends/si2183.c
@@ -75,6 +75,7 @@ struct si2183_dev {
bool ts_clock_inv;
bool ts_clock_gapped;
+ u8 agc_mode;
int fef_pin;
bool fef_inv;
int agc_pin;
@@ -427,10 +428,20 @@ static int si2183_set_dvbc(struct dvb_frontend *fe)
{
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
struct i2c_client *client = fe->demodulator_priv;
+ struct si2183_dev *dev = i2c_get_clientdata(client);
struct si2183_cmd cmd;
int ret;
u16 prop;
+ memcpy(cmd.args, "\x89\x41\x06\x12\x0\x0", 6);
+ cmd.args[1]= (dev->agc_mode &0x07)<<4 |0x1;
+ cmd.wlen = 6;
+ cmd.rlen = 3;
+ ret = si2183_cmd_execute(client, &cmd);
+ if(ret){
+ printk("Ter AGC set error !");
+ }
+
/* dvb-c mode */
prop = 0x38;
ret = si2183_set_prop(client, SI2183_PROP_MODE, &prop);
@@ -551,11 +562,22 @@ static int si2183_set_dvbs(struct dvb_frontend *fe)
{
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
struct i2c_client *client = fe->demodulator_priv;
+ struct si2183_dev *dev = i2c_get_clientdata(client);
struct si2183_cmd cmd;
int ret;
u16 prop;
u32 pls_mode, pls_code;
-
+
+ /*set SAT agc*/
+ memcpy(cmd.args, "\x8a\x1d\x12\x0\x0\x0", 6);
+ cmd.args[1]= dev->agc_mode|0x18;
+ cmd.wlen = 6;
+ cmd.rlen = 3;
+ ret = si2183_cmd_execute(client, &cmd);
+ if(ret){
+ printk("AGC set error !");
+ }
+
/* set mode */
prop = 0x8;
switch (c->delivery_system) {
@@ -627,10 +649,20 @@ static int si2183_set_dvbt(struct dvb_frontend *fe)
{
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
struct i2c_client *client = fe->demodulator_priv;
+ struct si2183_dev *dev = i2c_get_clientdata(client);
struct si2183_cmd cmd;
int ret;
u16 prop;
+ memcpy(cmd.args, "\x89\x41\x06\x12\x0\x0", 6);
+ cmd.args[1]= (dev->agc_mode &0x07)<<4 |0x1;
+ cmd.wlen = 6;
+ cmd.rlen = 3;
+ ret = si2183_cmd_execute(client, &cmd);
+ if(ret){
+ printk("Ter AGC set error !");
+ }
+
if (c->bandwidth_hz == 0) {
return -EINVAL;
} else if (c->bandwidth_hz <= 2000000)
@@ -696,9 +728,21 @@ static int si2183_set_isdbt(struct dvb_frontend *fe)
{
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
struct i2c_client *client = fe->demodulator_priv;
+ struct si2183_dev *dev = i2c_get_clientdata(client);
+ struct si2183_cmd cmd;
+
int ret;
u16 prop;
+ memcpy(cmd.args, "\x89\x41\x06\x12\x0\x0", 6);
+ cmd.args[1]= (dev->agc_mode &0x07)<<4 |0x1;
+ cmd.wlen = 6;
+ cmd.rlen = 3;
+ ret = si2183_cmd_execute(client, &cmd);
+ if(ret){
+ printk("Ter AGC set error !");
+ }
+
if (c->bandwidth_hz == 0) {
return -EINVAL;
} else if (c->bandwidth_hz <= 2000000)
@@ -1520,6 +1564,7 @@ static int si2183_probe(struct i2c_client *client,
dev->ts_mode = config->ts_mode;
dev->ts_clock_inv = config->ts_clock_inv;
dev->ts_clock_gapped = config->ts_clock_gapped;
+ dev->agc_mode = config->agc_mode;
dev->fef_pin = config->fef_pin;
dev->fef_inv = config->fef_inv;
dev->agc_pin = config->agc_pin;
diff --git a/drivers/media/dvb-frontends/si2183.h b/drivers/media/dvb-frontends/si2183.h
index 106e11c..410bbc9 100644
--- a/drivers/media/dvb-frontends/si2183.h
+++ b/drivers/media/dvb-frontends/si2183.h
@@ -43,6 +43,8 @@ struct si2183_config {
/* TS clock gapped */
bool ts_clock_gapped;
+ /*agc*/
+ u8 agc_mode;
/* Tuner control pins */
#define SI2183_MP_NOT_USED 1
diff --git a/drivers/media/pci/tbsecp3/tbsecp3-dvb.c b/drivers/media/pci/tbsecp3/tbsecp3-dvb.c
index 99aef3d..1d1c8b9 100644
--- a/drivers/media/pci/tbsecp3/tbsecp3-dvb.c
+++ b/drivers/media/pci/tbsecp3/tbsecp3-dvb.c
@@ -533,6 +533,7 @@ static int tbsecp3_frontend_attach(struct tbsecp3_adapter *adapter)
memset(&info, 0, sizeof(struct i2c_board_info));
strlcpy(info.type, "si2183", I2C_NAME_SIZE);
info.addr = adapter->nr ? 0x64 : 0x67;
+ si2183_config.agc_mode = adapter->nr? 0x4 : 0x5;
info.platform_data = &si2183_config;
request_module(info.type);
client_demod = i2c_new_device(i2c, &info);

View File

@ -0,0 +1,125 @@
From 959112523138c3bf5bec5f9fbe7d8abdc47b64a8 Mon Sep 17 00:00:00 2001
From: Sean Young <sean@mess.org>
Date: Tue, 16 May 2017 04:56:14 -0300
Subject: [PATCH 1/3] sir_ir: infinite loop in interrupt handler
Since this driver does no detection of hardware, it might be used with
a non-sir port. Escape out if we are spinning.
---
drivers/media/rc/sir_ir.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/media/rc/sir_ir.c b/drivers/media/rc/sir_ir.c
index e12ec50..90a5f8f 100644
--- a/drivers/media/rc/sir_ir.c
+++ b/drivers/media/rc/sir_ir.c
@@ -183,9 +183,15 @@ static irqreturn_t sir_interrupt(int irq, void *dev_id)
static unsigned long delt;
unsigned long deltintr;
unsigned long flags;
+ int counter = 0;
int iir, lsr;
while ((iir = inb(io + UART_IIR) & UART_IIR_ID)) {
+ if (++counter > 256) {
+ dev_err(&sir_ir_dev->dev, "Trapped in interrupt");
+ break;
+ }
+
switch (iir & UART_IIR_ID) { /* FIXME toto treba preriedit */
case UART_IIR_MSI:
(void)inb(io + UART_MSR);
--
2.7.4
From d94fc69844e6a29c6784fd3919d0b7f70d101f38 Mon Sep 17 00:00:00 2001
From: Sean Young <sean@mess.org>
Date: Wed, 24 May 2017 06:24:51 -0300
Subject: [PATCH 2/3] rc-core: race condition during ir_raw_event_register()
A rc device can call ir_raw_event_handle() after rc_allocate_device(),
but before rc_register_device() has completed. This is racey because
rcdev->raw is set before rcdev->raw->thread has a valid value.
---
drivers/media/rc/rc-ir-raw.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/media/rc/rc-ir-raw.c b/drivers/media/rc/rc-ir-raw.c
index 90f66dc..a2fc1a1 100644
--- a/drivers/media/rc/rc-ir-raw.c
+++ b/drivers/media/rc/rc-ir-raw.c
@@ -211,7 +211,7 @@ EXPORT_SYMBOL_GPL(ir_raw_event_set_idle);
*/
void ir_raw_event_handle(struct rc_dev *dev)
{
- if (!dev->raw)
+ if (!dev->raw || !dev->raw->thread)
return;
wake_up_process(dev->raw->thread);
@@ -490,6 +490,7 @@ int ir_raw_event_register(struct rc_dev *dev)
{
int rc;
struct ir_raw_handler *handler;
+ struct task_struct *thread;
if (!dev)
return -EINVAL;
@@ -507,13 +508,15 @@ int ir_raw_event_register(struct rc_dev *dev)
* because the event is coming from userspace
*/
if (dev->driver_type != RC_DRIVER_IR_RAW_TX) {
- dev->raw->thread = kthread_run(ir_raw_event_thread, dev->raw,
- "rc%u", dev->minor);
+ thread = kthread_run(ir_raw_event_thread, dev->raw, "rc%u",
+ dev->minor);
- if (IS_ERR(dev->raw->thread)) {
- rc = PTR_ERR(dev->raw->thread);
+ if (IS_ERR(thread)) {
+ rc = PTR_ERR(thread);
goto out;
}
+
+ dev->raw->thread = thread;
}
mutex_lock(&ir_raw_handler_lock);
--
2.7.4
From 4f1ed809ea2e402e6efe5f689412972d23fec201 Mon Sep 17 00:00:00 2001
From: Sean Young <sean@mess.org>
Date: Tue, 11 Jul 2017 10:47:37 +0100
Subject: [PATCH 3/3] lirc: LIRC_GET_REC_RESOLUTION should return microseconds
Since commit e8f4818895b3 ("[media] lirc: advertise
LIRC_CAN_GET_REC_RESOLUTION and improve") lircd uses the ioctl
LIRC_GET_REC_RESOLUTION to determine the shortest pulse or space that
the hardware can detect. This breaks decoding in lirc because lircd
expects the answer in microseconds, but nanoseconds is returned.
---
drivers/media/rc/ir-lirc-codec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c
index de85f1d..c01b655 100644
--- a/drivers/media/rc/ir-lirc-codec.c
+++ b/drivers/media/rc/ir-lirc-codec.c
@@ -266,7 +266,7 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd,
if (!dev->rx_resolution)
return -ENOTTY;
- val = dev->rx_resolution;
+ val = dev->rx_resolution / 1000;
break;
case LIRC_SET_WIDEBAND_RECEIVER:
--
2.7.4

View File

@ -0,0 +1,269 @@
From e5cf2bd5f2236379e0c2f55453b1c09470976da7 Mon Sep 17 00:00:00 2001
From: CrazyCat <crazycat69@narod.ru>
Date: Wed, 5 Jul 2017 00:38:23 +0300
Subject: [PATCH 1/2] dw2102: Terratec Cinergy S2 PCIe Dual support.
---
drivers/media/usb/dvb-usb/dw2102.c | 67 ++++++++++++++++++++++++++++++++++----
1 file changed, 60 insertions(+), 7 deletions(-)
diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
index aee9182..e06f60e 100644
--- a/drivers/media/usb/dvb-usb/dw2102.c
+++ b/drivers/media/usb/dvb-usb/dw2102.c
@@ -1761,13 +1761,14 @@ enum dw2102_table_entry {
TEVII_S632,
TERRATEC_CINERGY_S2_R2,
TERRATEC_CINERGY_S2_R3,
- TERRATEC_CINERGY_S2_R4,
GOTVIEW_SAT_HD,
GENIATECH_T220,
GENIATECH_T220A,
TECHNOTREND_S2_4600,
TEVII_S482_1,
TEVII_S482_2,
+ TERRATEC_DUAL_1,
+ TERRATEC_DUAL_2,
TEVII_S662
};
@@ -1791,7 +1792,6 @@ static struct usb_device_id dw2102_table[] = {
[TEVII_S632] = {USB_DEVICE(0x9022, USB_PID_TEVII_S632)},
[TERRATEC_CINERGY_S2_R2] = {USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_S2_R2)},
[TERRATEC_CINERGY_S2_R3] = {USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_S2_R3)},
- [TERRATEC_CINERGY_S2_R4] = {USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_S2_R4)},
[GOTVIEW_SAT_HD] = {USB_DEVICE(0x1FE1, USB_PID_GOTVIEW_SAT_HD)},
[GENIATECH_T220] = {USB_DEVICE(0x1f4d, 0xD220)},
[GENIATECH_T220A] = {USB_DEVICE(0x0572, 0xC686)},
@@ -1799,6 +1799,8 @@ static struct usb_device_id dw2102_table[] = {
USB_PID_TECHNOTREND_CONNECT_S2_4600)},
[TEVII_S482_1] = {USB_DEVICE(0x9022, 0xd483)},
[TEVII_S482_2] = {USB_DEVICE(0x9022, 0xd484)},
+ [TERRATEC_DUAL_1] = {USB_DEVICE(0x153B,0x1181)},
+ [TERRATEC_DUAL_2] = {USB_DEVICE(0x153B,0x1182)},
[TEVII_S662] = {USB_DEVICE(0x9022, USB_PID_TEVII_S662)},
{ }
};
@@ -2208,7 +2210,7 @@ static struct dvb_usb_device_properties su3000_properties = {
}},
}
},
- .num_device_descs = 7,
+ .num_device_descs = 6,
.devices = {
{ "SU3000HD DVB-S USB2.0",
{ &dw2102_table[GENIATECH_SU3000], NULL },
@@ -2234,10 +2236,6 @@ static struct dvb_usb_device_properties su3000_properties = {
{ &dw2102_table[TERRATEC_CINERGY_S2_R3], NULL },
{ NULL },
},
- { "Terratec Cinergy S2 USB HD Rev.4",
- { &dw2102_table[TERRATEC_CINERGY_S2_R4], NULL },
- { NULL },
- },
}
};
@@ -2445,6 +2443,59 @@ static struct dvb_usb_device_properties tevii_properties = {
}
};
+static struct dvb_usb_device_properties terratec_properties = {
+ .caps = DVB_USB_IS_AN_I2C_ADAPTER,
+ .usb_ctrl = DEVICE_SPECIFIC,
+ .size_of_priv = sizeof(struct dw2102_state),
+ .power_ctrl = su3000_power_ctrl,
+ .num_adapters = 1,
+ .identify_state = su3000_identify_state,
+ .i2c_algo = &su3000_i2c_algo,
+
+ .rc.core = {
+ .rc_interval = 250,
+ .rc_codes = RC_MAP_TERRATEC_CINERGY_S2_DUAL,
+ .module_name = "dw2102",
+ .allowed_protos = RC_BIT_NEC,
+ .rc_query = su3000_rc_query,
+ },
+
+ .read_mac_address = su3000_read_mac_address,
+
+ .generic_bulk_ctrl_endpoint = 0x01,
+
+ .adapter = {
+ {
+ .num_frontends = 1,
+ .fe = {{
+ .streaming_ctrl = su3000_streaming_ctrl,
+ .frontend_attach = su3000_frontend_attach,
+ .stream = {
+ .type = USB_BULK,
+ .count = 8,
+ .endpoint = 0x82,
+ .u = {
+ .bulk = {
+ .buffersize = 4096,
+ }
+ }
+ }
+ } },
+ }
+ },
+ .num_device_descs = 2,
+ .devices = {
+ { "Terratec Cinergy S2 Dual (tuner 1)",
+ { &dw2102_table[TERRATEC_DUAL_1], NULL },
+ { NULL },
+ },
+ { "Terratec Cinergy S2 Dual (tuner 2)",
+ { &dw2102_table[TERRATEC_DUAL_2], NULL },
+ { NULL },
+ },
+ }
+};
+
static int dw2102_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{
@@ -2525,6 +2576,8 @@ static int dw2102_probe(struct usb_interface *intf,
0 == dvb_usb_device_init(intf, &tt_s2_4600_properties,
THIS_MODULE, NULL, adapter_nr) ||
0 == dvb_usb_device_init(intf, &tevii_properties,
+ THIS_MODULE, NULL, adapter_nr) ||
+ 0 == dvb_usb_device_init(intf, &terratec_properties,
THIS_MODULE, NULL, adapter_nr))
return 0;
--
2.7.4
From 2a826fa54da3804813d86e8af56e446456352496 Mon Sep 17 00:00:00 2001
From: CrazyCat <crazycat69@narod.ru>
Date: Wed, 5 Jul 2017 00:38:58 +0300
Subject: [PATCH 2/2] Added RC keymap for Terratec Cinergy S2 PCIe Dual.
---
drivers/media/rc/keymaps/Makefile | 1 +
.../media/rc/keymaps/rc-terratec-cinergy-s2-dual.c | 85 ++++++++++++++++++++++
include/media/rc-map.h | 1 +
3 files changed, 87 insertions(+)
create mode 100644 drivers/media/rc/keymaps/rc-terratec-cinergy-s2-dual.c
diff --git a/drivers/media/rc/keymaps/Makefile b/drivers/media/rc/keymaps/Makefile
index 2945f99..13f368b 100644
--- a/drivers/media/rc/keymaps/Makefile
+++ b/drivers/media/rc/keymaps/Makefile
@@ -96,6 +96,7 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \
rc-terratec-cinergy-xs.o \
rc-terratec-slim.o \
rc-terratec-slim-2.o \
+ rc-terratec-cinergy-s2-dual.o \
rc-tevii-nec.o \
rc-tivo.o \
rc-total-media-in-hand.o \
diff --git a/drivers/media/rc/keymaps/rc-terratec-cinergy-s2-dual.c b/drivers/media/rc/keymaps/rc-terratec-cinergy-s2-dual.c
new file mode 100644
index 0000000..f8dbcfa
--- /dev/null
+++ b/drivers/media/rc/keymaps/rc-terratec-cinergy-s2-dual.c
@@ -0,0 +1,85 @@
+/* keytable for Terratec Cinergy S2 Dual Remote Controller
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <media/rc-map.h>
+#include <linux/module.h>
+
+static struct rc_map_table terratec_cinergy_s2_dual[] = {
+ { 0xf841, KEY_MENU },
+ { 0xf801, KEY_POWER },
+ { 0xf842, KEY_OPEN },
+ { 0x0002, KEY_1 },
+ { 0x0003, KEY_2 },
+ { 0x0004, KEY_3 },
+ { 0xf843, KEY_SUBTITLE },
+ { 0x0005, KEY_4 },
+ { 0x0006, KEY_5 },
+ { 0x0007, KEY_6 },
+ { 0xf844, KEY_TEXT },
+ { 0x0008, KEY_7 },
+ { 0x0009, KEY_8 },
+ { 0x000A, KEY_9 },
+ { 0xf845, KEY_DELETE },
+ { 0xf80b, KEY_SWITCHVIDEOMODE },
+ { 0xf80c, KEY_0 },
+ { 0xf80d, KEY_AB },
+ { 0xf846, KEY_TUNER },
+ { 0xf847, KEY_DVD },
+ { 0xf849, KEY_PVR },
+ { 0xf84a, KEY_AUDIO },
+ { 0xf84b, KEY_TIME },
+ { 0xf810, KEY_UP },
+ { 0xf811, KEY_LEFT },
+ { 0xf812, KEY_OK },
+ { 0xf813, KEY_RIGHT },
+ { 0xf814, KEY_DOWN },
+ { 0xf80f, KEY_EPG },
+ { 0xf816, KEY_INFO },
+ { 0xf84d, KEY_BACK },
+ { 0xf81c, KEY_VOLUMEUP },
+ { 0xf84c, KEY_PLAY },
+ { 0xf81b, KEY_CHANNELUP },
+ { 0xf81e, KEY_VOLUMEDOWN },
+ { 0xf81d, KEY_MUTE },
+ { 0xf81f, KEY_CHANNELDOWN },
+ { 0xf817, KEY_RED },
+ { 0xf818, KEY_GREEN },
+ { 0xf819, KEY_YELLOW },
+ { 0xf81A, KEY_BLUE },
+ { 0xf858, KEY_RECORD },
+ { 0xf848, KEY_STOP },
+ { 0xf840, KEY_PAUSE },
+ { 0xf85a, KEY_LAST },
+ { 0xf861, KEY_REWIND },
+ { 0xf954, KEY_FASTFORWARD },
+ { 0xf85c, KEY_NEXT },
+};
+
+static struct rc_map_list terratec_cinergy_s2_dual_map = {
+ .map = {
+ .scan = terratec_cinergy_s2_dual,
+ .size = ARRAY_SIZE(terratec_cinergy_s2_dual),
+ .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */
+ .name = RC_MAP_TERRATEC_CINERGY_S2_DUAL,
+ }
+};
+
+static int __init init_rc_map_terratec_cinergy_s2_dual(void)
+{
+ return rc_map_register(&terratec_cinergy_s2_dual_map);
+}
+
+static void __exit exit_rc_map_terratec_cinergy_s2_dual(void)
+{
+ rc_map_unregister(&terratec_cinergy_s2_dual_map);
+}
+
+module_init(init_rc_map_terratec_cinergy_s2_dual);
+module_exit(exit_rc_map_terratec_cinergy_s2_dual);
+
+MODULE_LICENSE("GPL");
diff --git a/include/media/rc-map.h b/include/media/rc-map.h
index 1a815a5..dcb98ef 100644
--- a/include/media/rc-map.h
+++ b/include/media/rc-map.h
@@ -299,6 +299,7 @@ struct rc_map *rc_map_get(const char *name);
#define RC_MAP_TERRATEC_CINERGY_XS "rc-terratec-cinergy-xs"
#define RC_MAP_TERRATEC_SLIM "rc-terratec-slim"
#define RC_MAP_TERRATEC_SLIM_2 "rc-terratec-slim-2"
+#define RC_MAP_TERRATEC_CINERGY_S2_DUAL "rc-terratec-cinergy-s2-dual"
#define RC_MAP_TEVII_NEC "rc-tevii-nec"
#define RC_MAP_TIVO "rc-tivo"
#define RC_MAP_TOTAL_MEDIA_IN_HAND "rc-total-media-in-hand"
--
2.7.4