aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorAntti Palosaari <crope@iki.fi>2014-12-23 11:14:36 -0500
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-02-03 13:25:24 -0500
commitd0f232e823af54a2554e371b5c96189facb1434b (patch)
treea9b8c944463defbda2233a1b191a9856cc01e0ba /drivers/media
parentc56222a6b25c24f211ecefd6ecc1003a7cb075d4 (diff)
[media] rtl28xxu: add heuristic to detect chip type
Detect automatically whether chip is old RTL2831U or newer RTL2832U/RTL2832P. Detection is based I2C command that is found only from newer RTL2832U models. Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/usb/dvb-usb-v2/rtl28xxu.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index b0d2467398f2..5bc77745b737 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -523,6 +523,35 @@ err:
523 return ret; 523 return ret;
524} 524}
525 525
526static int rtl28xxu_identify_state(struct dvb_usb_device *d, const char **name)
527{
528 struct rtl28xxu_dev *dev = d_to_priv(d);
529 int ret;
530 struct rtl28xxu_req req_demod_i2c = {0x0020, CMD_I2C_DA_RD, 0, NULL};
531
532 dev_dbg(&d->intf->dev, "\n");
533
534 /*
535 * Detect chip type using I2C command that is not supported
536 * by old RTL2831U.
537 */
538 ret = rtl28xxu_ctrl_msg(d, &req_demod_i2c);
539 if (ret == -EPIPE) {
540 dev->chip_id = CHIP_ID_RTL2831U;
541 } else if (ret == 0) {
542 dev->chip_id = CHIP_ID_RTL2832U;
543 } else {
544 dev_err(&d->intf->dev, "chip type detection failed %d\n", ret);
545 goto err;
546 }
547 dev_dbg(&d->intf->dev, "chip_id=%u\n", dev->chip_id);
548
549 return WARM;
550err:
551 dev_dbg(&d->intf->dev, "failed=%d\n", ret);
552 return ret;
553}
554
526static const struct rtl2830_platform_data rtl2830_mt2060_platform_data = { 555static const struct rtl2830_platform_data rtl2830_mt2060_platform_data = {
527 .clk = 28800000, 556 .clk = 28800000,
528 .spec_inv = 1, 557 .spec_inv = 1,
@@ -1590,6 +1619,7 @@ static const struct dvb_usb_device_properties rtl2831u_props = {
1590 .adapter_nr = adapter_nr, 1619 .adapter_nr = adapter_nr,
1591 .size_of_priv = sizeof(struct rtl28xxu_dev), 1620 .size_of_priv = sizeof(struct rtl28xxu_dev),
1592 1621
1622 .identify_state = rtl28xxu_identify_state,
1593 .power_ctrl = rtl2831u_power_ctrl, 1623 .power_ctrl = rtl2831u_power_ctrl,
1594 .i2c_algo = &rtl28xxu_i2c_algo, 1624 .i2c_algo = &rtl28xxu_i2c_algo,
1595 .read_config = rtl2831u_read_config, 1625 .read_config = rtl2831u_read_config,
@@ -1620,6 +1650,7 @@ static const struct dvb_usb_device_properties rtl2832u_props = {
1620 .adapter_nr = adapter_nr, 1650 .adapter_nr = adapter_nr,
1621 .size_of_priv = sizeof(struct rtl28xxu_dev), 1651 .size_of_priv = sizeof(struct rtl28xxu_dev),
1622 1652
1653 .identify_state = rtl28xxu_identify_state,
1623 .power_ctrl = rtl2832u_power_ctrl, 1654 .power_ctrl = rtl2832u_power_ctrl,
1624 .frontend_ctrl = rtl2832u_frontend_ctrl, 1655 .frontend_ctrl = rtl2832u_frontend_ctrl,
1625 .i2c_algo = &rtl28xxu_i2c_algo, 1656 .i2c_algo = &rtl28xxu_i2c_algo,