|
44 | 44 | #include "atbm8830.h" |
45 | 45 | #include "si2168.h" |
46 | 46 | #include "si2157.h" |
| 47 | +#include "sp2.h" |
47 | 48 |
|
48 | 49 | /* Max transfer size done by I2C transfer functions */ |
49 | 50 | #define MAX_XFER_SIZE 80 |
@@ -672,6 +673,37 @@ static struct rc_map_table rc_map_d680_dmb_table[] = { |
672 | 673 | { 0x0025, KEY_POWER }, |
673 | 674 | }; |
674 | 675 |
|
| 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 | + |
675 | 707 | static int cxusb_dee1601_demod_init(struct dvb_frontend* fe) |
676 | 708 | { |
677 | 709 | static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x28 }; |
@@ -1350,9 +1382,12 @@ static int cxusb_tt_ct2_4400_attach(struct dvb_usb_adapter *adap) |
1350 | 1382 | struct i2c_adapter *adapter; |
1351 | 1383 | struct i2c_client *client_demod; |
1352 | 1384 | struct i2c_client *client_tuner; |
| 1385 | + struct i2c_client *client_ci; |
1353 | 1386 | struct i2c_board_info info; |
1354 | 1387 | struct si2168_config si2168_config; |
1355 | 1388 | struct si2157_config si2157_config; |
| 1389 | + struct sp2_config sp2_config; |
| 1390 | + u8 o[2], i; |
1356 | 1391 |
|
1357 | 1392 | /* reset the tuner */ |
1358 | 1393 | 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) |
1409 | 1444 |
|
1410 | 1445 | st->i2c_client_tuner = client_tuner; |
1411 | 1446 |
|
| 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 | + |
1412 | 1489 | return 0; |
1413 | 1490 | } |
1414 | 1491 |
|
@@ -1538,6 +1615,13 @@ static void cxusb_disconnect(struct usb_interface *intf) |
1538 | 1615 | struct cxusb_state *st = d->priv; |
1539 | 1616 | struct i2c_client *client; |
1540 | 1617 |
|
| 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 | + |
1541 | 1625 | /* remove I2C client for tuner */ |
1542 | 1626 | client = st->i2c_client_tuner; |
1543 | 1627 | if (client) { |
@@ -1577,6 +1661,7 @@ static struct usb_device_id cxusb_table [] = { |
1577 | 1661 | { USB_DEVICE(USB_VID_CONEXANT, USB_PID_CONEXANT_D680_DMB) }, |
1578 | 1662 | { USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_D689) }, |
1579 | 1663 | { USB_DEVICE(USB_VID_TECHNOTREND, USB_PID_TECHNOTREND_TVSTICK_CT2_4400) }, |
| 1664 | + { USB_DEVICE(USB_VID_TECHNOTREND, USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI) }, |
1580 | 1665 | {} /* Terminating entry */ |
1581 | 1666 | }; |
1582 | 1667 | MODULE_DEVICE_TABLE (usb, cxusb_table); |
@@ -2266,13 +2351,18 @@ static struct dvb_usb_device_properties cxusb_tt_ct2_4400_properties = { |
2266 | 2351 | .rc_interval = 150, |
2267 | 2352 | }, |
2268 | 2353 |
|
2269 | | - .num_device_descs = 1, |
| 2354 | + .num_device_descs = 2, |
2270 | 2355 | .devices = { |
2271 | 2356 | { |
2272 | 2357 | "TechnoTrend TVStick CT2-4400", |
2273 | 2358 | { NULL }, |
2274 | 2359 | { &cxusb_table[20], NULL }, |
2275 | 2360 | }, |
| 2361 | + { |
| 2362 | + "TechnoTrend TT-connect CT2-4650 CI", |
| 2363 | + { NULL }, |
| 2364 | + { &cxusb_table[21], NULL }, |
| 2365 | + }, |
2276 | 2366 | } |
2277 | 2367 | }; |
2278 | 2368 |
|
|
0 commit comments