Skip to content

Commit 6832d11

Browse files
trsqrmchehab
authored andcommitted
[media] cxusb: Add support for TechnoTrend TT-connect CT2-4650 CI
TechnoTrend TT-connect CT2-4650 CI (0b48:3012) is an USB DVB-T2/C tuner with the following components: USB interface: Cypress CY7C68013A-56LTXC Demodulator: Silicon Labs Si2168-A20 Tuner: Silicon Labs Si2158-A20 CI chip: CIMaX SP2HF The firmware for the tuner is the same as for TechnoTrend TT-TVStick CT2-4400. See https://www.mail-archive.com/linux-media@vger.kernel.org/msg76944.html The demodulator needs a firmware that can be extracted from the Windows drivers. File ttConnect4650_64.sys should be extracted from http://www.tt-downloads.de/bda-treiber_4.1.0.4.zip (MD5 sum below). 3464bfc37a47b4032568718bacba23fb ttConnect4650_64.sys Then the firmware can be extracted: dd if=ttConnect4650_64.sys ibs=1 skip=273376 count=6424 of=dvb-demod-si2168-a20-01.fw The SP2 CI module requires a definition of a function cxusb_tt_ct2_4650_ci_ctrl that is passed on to the SP2 driver and called back for CAM operations. [crope@iki.fi: meld USB ID define patch to this] Signed-off-by: Olli Salonen <olli.salonen@iki.fi> Reviewed-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
1 parent 868736a commit 6832d11

4 files changed

Lines changed: 97 additions & 2 deletions

File tree

‎drivers/media/dvb-core/dvb-usb-ids.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@
244244
#define USB_PID_TECHNOTREND_CONNECT_S2400 0x3006
245245
#define USB_PID_TECHNOTREND_CONNECT_S2400_8KEEPROM 0x3009
246246
#define USB_PID_TECHNOTREND_CONNECT_CT3650 0x300d
247+
#define USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI 0x3012
247248
#define USB_PID_TECHNOTREND_TVSTICK_CT2_4400 0x3014
248249
#define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY 0x005a
249250
#define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2 0x0081

‎drivers/media/usb/dvb-usb/Kconfig‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ config DVB_USB_CXUSB
130130

131131
Medion MD95700 hybrid USB2.0 device.
132132
DViCO FusionHDTV (Bluebird) USB2.0 devices
133-
TechnoTrend TVStick CT2-4400
133+
TechnoTrend TVStick CT2-4400 and CT2-4650 CI devices
134134

135135
config DVB_USB_M920X
136136
tristate "Uli m920x DVB-T USB2.0 support"

‎drivers/media/usb/dvb-usb/cxusb.c‎

Lines changed: 91 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include "atbm8830.h"
4545
#include "si2168.h"
4646
#include "si2157.h"
47+
#include "sp2.h"
4748

4849
/* Max transfer size done by I2C transfer functions */
4950
#define MAX_XFER_SIZE 80
@@ -672,6 +673,37 @@ static struct rc_map_table rc_map_d680_dmb_table[] = {
672673
{ 0x0025, KEY_POWER },
673674
};
674675

676+
static int cxusb_tt_ct2_4650_ci_ctrl(void *priv, u8 read, int addr,
677+
u8 data, int *mem)
678+
{
679+
struct dvb_usb_device *d = priv;
680+
u8 wbuf[3];
681+
u8 rbuf[2];
682+
int ret;
683+
684+
wbuf[0] = (addr >> 8) & 0xff;
685+
wbuf[1] = addr & 0xff;
686+
687+
if (read) {
688+
ret = cxusb_ctrl_msg(d, CMD_SP2_CI_READ, wbuf, 2, rbuf, 2);
689+
} else {
690+
wbuf[2] = data;
691+
ret = cxusb_ctrl_msg(d, CMD_SP2_CI_WRITE, wbuf, 3, rbuf, 1);
692+
}
693+
694+
if (ret)
695+
goto err;
696+
697+
if (read)
698+
*mem = rbuf[1];
699+
700+
return 0;
701+
err:
702+
deb_info("%s: ci usb write returned %d\n", __func__, ret);
703+
return ret;
704+
705+
}
706+
675707
static int cxusb_dee1601_demod_init(struct dvb_frontend* fe)
676708
{
677709
static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x28 };
@@ -1350,9 +1382,12 @@ static int cxusb_tt_ct2_4400_attach(struct dvb_usb_adapter *adap)
13501382
struct i2c_adapter *adapter;
13511383
struct i2c_client *client_demod;
13521384
struct i2c_client *client_tuner;
1385+
struct i2c_client *client_ci;
13531386
struct i2c_board_info info;
13541387
struct si2168_config si2168_config;
13551388
struct si2157_config si2157_config;
1389+
struct sp2_config sp2_config;
1390+
u8 o[2], i;
13561391

13571392
/* reset the tuner */
13581393
if (cxusb_tt_ct2_4400_gpio_tuner(d, 0) < 0) {
@@ -1409,6 +1444,48 @@ static int cxusb_tt_ct2_4400_attach(struct dvb_usb_adapter *adap)
14091444

14101445
st->i2c_client_tuner = client_tuner;
14111446

1447+
/* initialize CI */
1448+
if (d->udev->descriptor.idProduct ==
1449+
USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI) {
1450+
1451+
memcpy(o, "\xc0\x01", 2);
1452+
cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, &i, 1);
1453+
msleep(100);
1454+
1455+
memcpy(o, "\xc0\x00", 2);
1456+
cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, &i, 1);
1457+
msleep(100);
1458+
1459+
memset(&sp2_config, 0, sizeof(sp2_config));
1460+
sp2_config.dvb_adap = &adap->dvb_adap;
1461+
sp2_config.priv = d;
1462+
sp2_config.ci_control = cxusb_tt_ct2_4650_ci_ctrl;
1463+
memset(&info, 0, sizeof(struct i2c_board_info));
1464+
strlcpy(info.type, "sp2", I2C_NAME_SIZE);
1465+
info.addr = 0x40;
1466+
info.platform_data = &sp2_config;
1467+
request_module(info.type);
1468+
client_ci = i2c_new_device(&d->i2c_adap, &info);
1469+
if (client_ci == NULL || client_ci->dev.driver == NULL) {
1470+
module_put(client_tuner->dev.driver->owner);
1471+
i2c_unregister_device(client_tuner);
1472+
module_put(client_demod->dev.driver->owner);
1473+
i2c_unregister_device(client_demod);
1474+
return -ENODEV;
1475+
}
1476+
if (!try_module_get(client_ci->dev.driver->owner)) {
1477+
i2c_unregister_device(client_ci);
1478+
module_put(client_tuner->dev.driver->owner);
1479+
i2c_unregister_device(client_tuner);
1480+
module_put(client_demod->dev.driver->owner);
1481+
i2c_unregister_device(client_demod);
1482+
return -ENODEV;
1483+
}
1484+
1485+
st->i2c_client_ci = client_ci;
1486+
1487+
}
1488+
14121489
return 0;
14131490
}
14141491

@@ -1538,6 +1615,13 @@ static void cxusb_disconnect(struct usb_interface *intf)
15381615
struct cxusb_state *st = d->priv;
15391616
struct i2c_client *client;
15401617

1618+
/* remove I2C client for CI */
1619+
client = st->i2c_client_ci;
1620+
if (client) {
1621+
module_put(client->dev.driver->owner);
1622+
i2c_unregister_device(client);
1623+
}
1624+
15411625
/* remove I2C client for tuner */
15421626
client = st->i2c_client_tuner;
15431627
if (client) {
@@ -1577,6 +1661,7 @@ static struct usb_device_id cxusb_table [] = {
15771661
{ USB_DEVICE(USB_VID_CONEXANT, USB_PID_CONEXANT_D680_DMB) },
15781662
{ USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_D689) },
15791663
{ USB_DEVICE(USB_VID_TECHNOTREND, USB_PID_TECHNOTREND_TVSTICK_CT2_4400) },
1664+
{ USB_DEVICE(USB_VID_TECHNOTREND, USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI) },
15801665
{} /* Terminating entry */
15811666
};
15821667
MODULE_DEVICE_TABLE (usb, cxusb_table);
@@ -2266,13 +2351,18 @@ static struct dvb_usb_device_properties cxusb_tt_ct2_4400_properties = {
22662351
.rc_interval = 150,
22672352
},
22682353

2269-
.num_device_descs = 1,
2354+
.num_device_descs = 2,
22702355
.devices = {
22712356
{
22722357
"TechnoTrend TVStick CT2-4400",
22732358
{ NULL },
22742359
{ &cxusb_table[20], NULL },
22752360
},
2361+
{
2362+
"TechnoTrend TT-connect CT2-4650 CI",
2363+
{ NULL },
2364+
{ &cxusb_table[21], NULL },
2365+
},
22762366
}
22772367
};
22782368

‎drivers/media/usb/dvb-usb/cxusb.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,14 @@
2828
#define CMD_ANALOG 0x50
2929
#define CMD_DIGITAL 0x51
3030

31+
#define CMD_SP2_CI_WRITE 0x70
32+
#define CMD_SP2_CI_READ 0x71
33+
3134
struct cxusb_state {
3235
u8 gpio_write_state[3];
3336
struct i2c_client *i2c_client_demod;
3437
struct i2c_client *i2c_client_tuner;
38+
struct i2c_client *i2c_client_ci;
3539
};
3640

3741
#endif

0 commit comments

Comments
 (0)