diff options
author | Thomas Mair <thomas.mair86@googlemail.com> | 2012-05-18 13:47:41 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-07-05 11:58:16 -0400 |
commit | 5cf6631e52ac76e4051fd29db46092f36ab1ff84 (patch) | |
tree | b7980c7d427bff174968aaf2085aa7ddf1a59298 /drivers/media/dvb/dvb-usb | |
parent | 298f18a3e2e078c796d3f852091fbe961fbca806 (diff) |
[media] rtl28xxu: support for the rtl2832 demod driver
This only adds support for the Terratec Cinergy T Stick Black device.
Changes from previous patches:
- fixed compiler warnings
- added fc0013 tuner handling to this patch
Signed-off-by: Thomas Mair <thomas.mair86@googlemail.com>
Acked-by: Antti Palosaari <crope@iki.fi>
Reviewed-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb/dvb-usb')
-rw-r--r-- | drivers/media/dvb/dvb-usb/Kconfig | 3 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/dvb-usb-ids.h | 1 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/rtl28xxu.c | 450 |
3 files changed, 429 insertions, 25 deletions
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig index a26949336b3d..c2161565023a 100644 --- a/drivers/media/dvb/dvb-usb/Kconfig +++ b/drivers/media/dvb/dvb-usb/Kconfig | |||
@@ -418,9 +418,12 @@ config DVB_USB_RTL28XXU | |||
418 | tristate "Realtek RTL28xxU DVB USB support" | 418 | tristate "Realtek RTL28xxU DVB USB support" |
419 | depends on DVB_USB && EXPERIMENTAL | 419 | depends on DVB_USB && EXPERIMENTAL |
420 | select DVB_RTL2830 | 420 | select DVB_RTL2830 |
421 | select DVB_RTL2832 | ||
421 | select MEDIA_TUNER_QT1010 if !MEDIA_TUNER_CUSTOMISE | 422 | select MEDIA_TUNER_QT1010 if !MEDIA_TUNER_CUSTOMISE |
422 | select MEDIA_TUNER_MT2060 if !MEDIA_TUNER_CUSTOMISE | 423 | select MEDIA_TUNER_MT2060 if !MEDIA_TUNER_CUSTOMISE |
423 | select MEDIA_TUNER_MXL5005S if !MEDIA_TUNER_CUSTOMISE | 424 | select MEDIA_TUNER_MXL5005S if !MEDIA_TUNER_CUSTOMISE |
425 | select MEDIA_TUNER_FC0012 if !MEDIA_TUNER_CUSTOMISE | ||
426 | select MEDIA_TUNER_FC0013 if !MEDIA_TUNER_CUSTOMISE | ||
424 | help | 427 | help |
425 | Say Y here to support the Realtek RTL28xxU DVB USB receiver. | 428 | Say Y here to support the Realtek RTL28xxU DVB USB receiver. |
426 | 429 | ||
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h index 7a6160bf54ba..cd9254cc2721 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h | |||
@@ -160,6 +160,7 @@ | |||
160 | #define USB_PID_TERRATEC_CINERGY_T_STICK 0x0093 | 160 | #define USB_PID_TERRATEC_CINERGY_T_STICK 0x0093 |
161 | #define USB_PID_TERRATEC_CINERGY_T_STICK_RC 0x0097 | 161 | #define USB_PID_TERRATEC_CINERGY_T_STICK_RC 0x0097 |
162 | #define USB_PID_TERRATEC_CINERGY_T_STICK_DUAL_RC 0x0099 | 162 | #define USB_PID_TERRATEC_CINERGY_T_STICK_DUAL_RC 0x0099 |
163 | #define USB_PID_TERRATEC_CINERGY_T_STICK_BLACK_REV1 0x00a9 | ||
163 | #define USB_PID_TWINHAN_VP7041_COLD 0x3201 | 164 | #define USB_PID_TWINHAN_VP7041_COLD 0x3201 |
164 | #define USB_PID_TWINHAN_VP7041_WARM 0x3202 | 165 | #define USB_PID_TWINHAN_VP7041_WARM 0x3202 |
165 | #define USB_PID_TWINHAN_VP7020_COLD 0x3203 | 166 | #define USB_PID_TWINHAN_VP7020_COLD 0x3203 |
diff --git a/drivers/media/dvb/dvb-usb/rtl28xxu.c b/drivers/media/dvb/dvb-usb/rtl28xxu.c index 41e1f5537f44..9889c46666ab 100644 --- a/drivers/media/dvb/dvb-usb/rtl28xxu.c +++ b/drivers/media/dvb/dvb-usb/rtl28xxu.c | |||
@@ -3,6 +3,7 @@ | |||
3 | * | 3 | * |
4 | * Copyright (C) 2009 Antti Palosaari <crope@iki.fi> | 4 | * Copyright (C) 2009 Antti Palosaari <crope@iki.fi> |
5 | * Copyright (C) 2011 Antti Palosaari <crope@iki.fi> | 5 | * Copyright (C) 2011 Antti Palosaari <crope@iki.fi> |
6 | * Copyright (C) 2012 Thomas Mair <thomas.mair86@googlemail.com> | ||
6 | * | 7 | * |
7 | * This program is free software; you can redistribute it and/or modify | 8 | * 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 | * it under the terms of the GNU General Public License as published by |
@@ -22,10 +23,13 @@ | |||
22 | #include "rtl28xxu.h" | 23 | #include "rtl28xxu.h" |
23 | 24 | ||
24 | #include "rtl2830.h" | 25 | #include "rtl2830.h" |
26 | #include "rtl2832.h" | ||
25 | 27 | ||
26 | #include "qt1010.h" | 28 | #include "qt1010.h" |
27 | #include "mt2060.h" | 29 | #include "mt2060.h" |
28 | #include "mxl5005s.h" | 30 | #include "mxl5005s.h" |
31 | #include "fc0012.h" | ||
32 | #include "fc0013.h" | ||
29 | 33 | ||
30 | /* debug */ | 34 | /* debug */ |
31 | static int dvb_usb_rtl28xxu_debug; | 35 | static int dvb_usb_rtl28xxu_debug; |
@@ -381,34 +385,159 @@ err: | |||
381 | return ret; | 385 | return ret; |
382 | } | 386 | } |
383 | 387 | ||
388 | static struct rtl2832_config rtl28xxu_rtl2832_fc0012_config = { | ||
389 | .i2c_addr = 0x10, /* 0x20 */ | ||
390 | .xtal = 28800000, | ||
391 | .if_dvbt = 0, | ||
392 | .tuner = TUNER_RTL2832_FC0012 | ||
393 | }; | ||
394 | |||
395 | static struct rtl2832_config rtl28xxu_rtl2832_fc0013_config = { | ||
396 | .i2c_addr = 0x10, /* 0x20 */ | ||
397 | .xtal = 28800000, | ||
398 | .if_dvbt = 0, | ||
399 | .tuner = TUNER_RTL2832_FC0013 | ||
400 | }; | ||
401 | |||
402 | static int rtl2832u_fc0012_tuner_callback(struct dvb_usb_device *d, | ||
403 | int cmd, int arg) | ||
404 | { | ||
405 | int ret; | ||
406 | u8 val; | ||
407 | |||
408 | deb_info("%s cmd=%d arg=%d\n", __func__, cmd, arg); | ||
409 | switch (cmd) { | ||
410 | case FC_FE_CALLBACK_VHF_ENABLE: | ||
411 | /* set output values */ | ||
412 | ret = rtl2831_rd_reg(d, SYS_GPIO_OUT_VAL, &val); | ||
413 | if (ret) | ||
414 | goto err; | ||
415 | |||
416 | if (arg) | ||
417 | val &= 0xbf; /* set GPIO6 low */ | ||
418 | else | ||
419 | val |= 0x40; /* set GPIO6 high */ | ||
420 | |||
421 | |||
422 | ret = rtl2831_wr_reg(d, SYS_GPIO_OUT_VAL, val); | ||
423 | if (ret) | ||
424 | goto err; | ||
425 | break; | ||
426 | default: | ||
427 | ret = -EINVAL; | ||
428 | goto err; | ||
429 | } | ||
430 | return 0; | ||
431 | |||
432 | err: | ||
433 | err("%s: failed=%d\n", __func__, ret); | ||
434 | |||
435 | return ret; | ||
436 | } | ||
437 | |||
438 | |||
439 | static int rtl2832u_fc0013_tuner_callback(struct dvb_usb_device *d, | ||
440 | int cmd, int arg) | ||
441 | { | ||
442 | /* TODO implement*/ | ||
443 | return 0; | ||
444 | } | ||
445 | |||
446 | static int rtl2832u_tuner_callback(struct dvb_usb_device *d, int cmd, int arg) | ||
447 | { | ||
448 | struct rtl28xxu_priv *priv = d->priv; | ||
449 | |||
450 | switch (priv->tuner) { | ||
451 | case TUNER_RTL2832_FC0012: | ||
452 | return rtl2832u_fc0012_tuner_callback(d, cmd, arg); | ||
453 | |||
454 | case TUNER_RTL2832_FC0013: | ||
455 | return rtl2832u_fc0013_tuner_callback(d, cmd, arg); | ||
456 | default: | ||
457 | break; | ||
458 | } | ||
459 | |||
460 | return -ENODEV; | ||
461 | } | ||
462 | |||
463 | static int rtl2832u_frontend_callback(void *adapter_priv, int component, | ||
464 | int cmd, int arg) | ||
465 | { | ||
466 | struct i2c_adapter *adap = adapter_priv; | ||
467 | struct dvb_usb_device *d = i2c_get_adapdata(adap); | ||
468 | |||
469 | switch (component) { | ||
470 | case DVB_FRONTEND_COMPONENT_TUNER: | ||
471 | return rtl2832u_tuner_callback(d, cmd, arg); | ||
472 | default: | ||
473 | break; | ||
474 | } | ||
475 | |||
476 | return -EINVAL; | ||
477 | } | ||
478 | |||
479 | |||
480 | |||
481 | |||
384 | static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap) | 482 | static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap) |
385 | { | 483 | { |
386 | int ret; | 484 | int ret; |
387 | struct rtl28xxu_priv *priv = adap->dev->priv; | 485 | struct rtl28xxu_priv *priv = adap->dev->priv; |
388 | u8 buf[1]; | 486 | struct rtl2832_config *rtl2832_config; |
487 | |||
488 | u8 buf[2], val; | ||
389 | /* open RTL2832U/RTL2832 I2C gate */ | 489 | /* open RTL2832U/RTL2832 I2C gate */ |
390 | struct rtl28xxu_req req_gate_open = {0x0120, 0x0011, 0x0001, "\x18"}; | 490 | struct rtl28xxu_req req_gate_open = {0x0120, 0x0011, 0x0001, "\x18"}; |
391 | /* close RTL2832U/RTL2832 I2C gate */ | 491 | /* close RTL2832U/RTL2832 I2C gate */ |
392 | struct rtl28xxu_req req_gate_close = {0x0120, 0x0011, 0x0001, "\x10"}; | 492 | struct rtl28xxu_req req_gate_close = {0x0120, 0x0011, 0x0001, "\x10"}; |
493 | /* for FC0012 tuner probe */ | ||
494 | struct rtl28xxu_req req_fc0012 = {0x00c6, CMD_I2C_RD, 1, buf}; | ||
495 | /* for FC0013 tuner probe */ | ||
496 | struct rtl28xxu_req req_fc0013 = {0x00c6, CMD_I2C_RD, 1, buf}; | ||
497 | /* for MT2266 tuner probe */ | ||
498 | struct rtl28xxu_req req_mt2266 = {0x00c0, CMD_I2C_RD, 1, buf}; | ||
393 | /* for FC2580 tuner probe */ | 499 | /* for FC2580 tuner probe */ |
394 | struct rtl28xxu_req req_fc2580 = {0x01ac, CMD_I2C_RD, 1, buf}; | 500 | struct rtl28xxu_req req_fc2580 = {0x01ac, CMD_I2C_RD, 1, buf}; |
501 | /* for MT2063 tuner probe */ | ||
502 | struct rtl28xxu_req req_mt2063 = {0x00c0, CMD_I2C_RD, 1, buf}; | ||
503 | /* for MAX3543 tuner probe */ | ||
504 | struct rtl28xxu_req req_max3543 = {0x00c0, CMD_I2C_RD, 1, buf}; | ||
505 | /* for TUA9001 tuner probe */ | ||
506 | struct rtl28xxu_req req_tua9001 = {0x7ec0, CMD_I2C_RD, 2, buf}; | ||
507 | /* for MXL5007T tuner probe */ | ||
508 | struct rtl28xxu_req req_mxl5007t = {0xd9c0, CMD_I2C_RD, 1, buf}; | ||
509 | /* for E4000 tuner probe */ | ||
510 | struct rtl28xxu_req req_e4000 = {0x02c8, CMD_I2C_RD, 1, buf}; | ||
511 | /* for TDA18272 tuner probe */ | ||
512 | struct rtl28xxu_req req_tda18272 = {0x00c0, CMD_I2C_RD, 2, buf}; | ||
395 | 513 | ||
396 | deb_info("%s:\n", __func__); | 514 | deb_info("%s:\n", __func__); |
397 | 515 | ||
398 | /* GPIO direction */ | 516 | |
399 | ret = rtl2831_wr_reg(adap->dev, SYS_GPIO_DIR, 0x0a); | 517 | ret = rtl2831_rd_reg(adap->dev, SYS_GPIO_DIR, &val); |
400 | if (ret) | 518 | if (ret) |
401 | goto err; | 519 | goto err; |
402 | 520 | ||
403 | /* enable as output GPIO0, GPIO2, GPIO4 */ | 521 | val &= 0xbf; |
404 | ret = rtl2831_wr_reg(adap->dev, SYS_GPIO_OUT_EN, 0x15); | 522 | |
523 | ret = rtl2831_wr_reg(adap->dev, SYS_GPIO_DIR, val); | ||
405 | if (ret) | 524 | if (ret) |
406 | goto err; | 525 | goto err; |
407 | 526 | ||
408 | ret = rtl2831_wr_reg(adap->dev, SYS_DEMOD_CTL, 0xe8); | 527 | |
528 | /* enable as output GPIO3 and GPIO6*/ | ||
529 | ret = rtl2831_rd_reg(adap->dev, SYS_GPIO_OUT_EN, &val); | ||
409 | if (ret) | 530 | if (ret) |
410 | goto err; | 531 | goto err; |
411 | 532 | ||
533 | val |= 0x48; | ||
534 | |||
535 | ret = rtl2831_wr_reg(adap->dev, SYS_GPIO_OUT_EN, val); | ||
536 | if (ret) | ||
537 | goto err; | ||
538 | |||
539 | |||
540 | |||
412 | /* | 541 | /* |
413 | * Probe used tuner. We need to know used tuner before demod attach | 542 | * Probe used tuner. We need to know used tuner before demod attach |
414 | * since there is some demod params needed to set according to tuner. | 543 | * since there is some demod params needed to set according to tuner. |
@@ -419,25 +548,108 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap) | |||
419 | if (ret) | 548 | if (ret) |
420 | goto err; | 549 | goto err; |
421 | 550 | ||
551 | priv->tuner = TUNER_NONE; | ||
552 | |||
553 | /* check FC0012 ID register; reg=00 val=a1 */ | ||
554 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_fc0012); | ||
555 | if (ret == 0 && buf[0] == 0xa1) { | ||
556 | priv->tuner = TUNER_RTL2832_FC0012; | ||
557 | rtl2832_config = &rtl28xxu_rtl2832_fc0012_config; | ||
558 | info("%s: FC0012 tuner found", __func__); | ||
559 | goto found; | ||
560 | } | ||
561 | |||
562 | /* check FC0013 ID register; reg=00 val=a3 */ | ||
563 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_fc0013); | ||
564 | if (ret == 0 && buf[0] == 0xa3) { | ||
565 | priv->tuner = TUNER_RTL2832_FC0013; | ||
566 | rtl2832_config = &rtl28xxu_rtl2832_fc0013_config; | ||
567 | info("%s: FC0013 tuner found", __func__); | ||
568 | goto found; | ||
569 | } | ||
570 | |||
571 | /* check MT2266 ID register; reg=00 val=85 */ | ||
572 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_mt2266); | ||
573 | if (ret == 0 && buf[0] == 0x85) { | ||
574 | priv->tuner = TUNER_RTL2832_MT2266; | ||
575 | /* TODO implement tuner */ | ||
576 | info("%s: MT2266 tuner found", __func__); | ||
577 | goto unsupported; | ||
578 | } | ||
579 | |||
422 | /* check FC2580 ID register; reg=01 val=56 */ | 580 | /* check FC2580 ID register; reg=01 val=56 */ |
423 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_fc2580); | 581 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_fc2580); |
424 | if (ret == 0 && buf[0] == 0x56) { | 582 | if (ret == 0 && buf[0] == 0x56) { |
425 | priv->tuner = TUNER_RTL2832_FC2580; | 583 | priv->tuner = TUNER_RTL2832_FC2580; |
426 | deb_info("%s: FC2580\n", __func__); | 584 | /* TODO implement tuner */ |
427 | goto found; | 585 | info("%s: FC2580 tuner found", __func__); |
428 | } else { | 586 | goto unsupported; |
429 | deb_info("%s: FC2580 probe failed=%d - %02x\n", | 587 | } |
430 | __func__, ret, buf[0]); | 588 | |
589 | /* check MT2063 ID register; reg=00 val=9e || 9c */ | ||
590 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_mt2063); | ||
591 | if (ret == 0 && (buf[0] == 0x9e || buf[0] == 0x9c)) { | ||
592 | priv->tuner = TUNER_RTL2832_MT2063; | ||
593 | /* TODO implement tuner */ | ||
594 | info("%s: MT2063 tuner found", __func__); | ||
595 | goto unsupported; | ||
596 | } | ||
597 | |||
598 | /* check MAX3543 ID register; reg=00 val=38 */ | ||
599 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_max3543); | ||
600 | if (ret == 0 && buf[0] == 0x38) { | ||
601 | priv->tuner = TUNER_RTL2832_MAX3543; | ||
602 | /* TODO implement tuner */ | ||
603 | info("%s: MAX3534 tuner found", __func__); | ||
604 | goto unsupported; | ||
431 | } | 605 | } |
432 | 606 | ||
607 | /* check TUA9001 ID register; reg=7e val=2328 */ | ||
608 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_tua9001); | ||
609 | if (ret == 0 && buf[0] == 0x23 && buf[1] == 0x28) { | ||
610 | priv->tuner = TUNER_RTL2832_TUA9001; | ||
611 | /* TODO implement tuner */ | ||
612 | info("%s: TUA9001 tuner found", __func__); | ||
613 | goto unsupported; | ||
614 | } | ||
615 | |||
616 | /* check MXL5007R ID register; reg=d9 val=14 */ | ||
617 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_mxl5007t); | ||
618 | if (ret == 0 && buf[0] == 0x14) { | ||
619 | priv->tuner = TUNER_RTL2832_MXL5007T; | ||
620 | /* TODO implement tuner */ | ||
621 | info("%s: MXL5007T tuner found", __func__); | ||
622 | goto unsupported; | ||
623 | } | ||
624 | |||
625 | /* check E4000 ID register; reg=02 val=40 */ | ||
626 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_e4000); | ||
627 | if (ret == 0 && buf[0] == 0x40) { | ||
628 | priv->tuner = TUNER_RTL2832_E4000; | ||
629 | /* TODO implement tuner */ | ||
630 | info("%s: E4000 tuner found", __func__); | ||
631 | goto unsupported; | ||
632 | } | ||
633 | |||
634 | /* check TDA18272 ID register; reg=00 val=c760 */ | ||
635 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_tda18272); | ||
636 | if (ret == 0 && (buf[0] == 0xc7 || buf[1] == 0x60)) { | ||
637 | priv->tuner = TUNER_RTL2832_TDA18272; | ||
638 | /* TODO implement tuner */ | ||
639 | info("%s: TDA18272 tuner found", __func__); | ||
640 | goto unsupported; | ||
641 | } | ||
642 | |||
643 | unsupported: | ||
433 | /* close demod I2C gate */ | 644 | /* close demod I2C gate */ |
434 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_gate_close); | 645 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_gate_close); |
435 | if (ret) | 646 | if (ret) |
436 | goto err; | 647 | goto err; |
437 | 648 | ||
438 | /* tuner not found */ | 649 | /* tuner not found */ |
650 | deb_info("No compatible tuner found"); | ||
439 | ret = -ENODEV; | 651 | ret = -ENODEV; |
440 | goto err; | 652 | return ret; |
441 | 653 | ||
442 | found: | 654 | found: |
443 | /* close demod I2C gate */ | 655 | /* close demod I2C gate */ |
@@ -446,9 +658,18 @@ found: | |||
446 | goto err; | 658 | goto err; |
447 | 659 | ||
448 | /* attach demodulator */ | 660 | /* attach demodulator */ |
449 | /* TODO: */ | 661 | adap->fe_adap[0].fe = dvb_attach(rtl2832_attach, rtl2832_config, |
662 | &adap->dev->i2c_adap); | ||
663 | if (adap->fe_adap[0].fe == NULL) { | ||
664 | ret = -ENODEV; | ||
665 | goto err; | ||
666 | } | ||
667 | |||
668 | /* set fe callbacks */ | ||
669 | adap->fe_adap[0].fe->callback = rtl2832u_frontend_callback; | ||
450 | 670 | ||
451 | return ret; | 671 | return ret; |
672 | |||
452 | err: | 673 | err: |
453 | deb_info("%s: failed=%d\n", __func__, ret); | 674 | deb_info("%s: failed=%d\n", __func__, ret); |
454 | return ret; | 675 | return ret; |
@@ -531,10 +752,24 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap) | |||
531 | deb_info("%s:\n", __func__); | 752 | deb_info("%s:\n", __func__); |
532 | 753 | ||
533 | switch (priv->tuner) { | 754 | switch (priv->tuner) { |
534 | case TUNER_RTL2832_FC2580: | 755 | case TUNER_RTL2832_FC0012: |
535 | /* TODO: */ | 756 | fe = dvb_attach(fc0012_attach, adap->fe_adap[0].fe, |
536 | fe = NULL; | 757 | &adap->dev->i2c_adap, 0xc6>>1, 0, FC_XTAL_28_8_MHZ); |
758 | |||
759 | /* since fc0012 includs reading the signal strength delegate | ||
760 | * that to the tuner driver */ | ||
761 | adap->fe_adap[0].fe->ops.read_signal_strength = adap->fe_adap[0]. | ||
762 | fe->ops.tuner_ops.get_rf_strength; | ||
763 | return 0; | ||
537 | break; | 764 | break; |
765 | case TUNER_RTL2832_FC0013: | ||
766 | fe = dvb_attach(fc0013_attach, adap->fe_adap[0].fe, | ||
767 | &adap->dev->i2c_adap, 0xc6>>1, 0, FC_XTAL_28_8_MHZ); | ||
768 | |||
769 | /* fc0013 also supports signal strength reading */ | ||
770 | adap->fe_adap[0].fe->ops.read_signal_strength = adap->fe_adap[0] | ||
771 | .fe->ops.tuner_ops.get_rf_strength; | ||
772 | return 0; | ||
538 | default: | 773 | default: |
539 | fe = NULL; | 774 | fe = NULL; |
540 | err("unknown tuner=%d", priv->tuner); | 775 | err("unknown tuner=%d", priv->tuner); |
@@ -551,7 +786,7 @@ err: | |||
551 | return ret; | 786 | return ret; |
552 | } | 787 | } |
553 | 788 | ||
554 | static int rtl28xxu_streaming_ctrl(struct dvb_usb_adapter *adap , int onoff) | 789 | static int rtl2831u_streaming_ctrl(struct dvb_usb_adapter *adap , int onoff) |
555 | { | 790 | { |
556 | int ret; | 791 | int ret; |
557 | u8 buf[2], gpio; | 792 | u8 buf[2], gpio; |
@@ -586,7 +821,33 @@ err: | |||
586 | return ret; | 821 | return ret; |
587 | } | 822 | } |
588 | 823 | ||
589 | static int rtl28xxu_power_ctrl(struct dvb_usb_device *d, int onoff) | 824 | static int rtl2832u_streaming_ctrl(struct dvb_usb_adapter *adap , int onoff) |
825 | { | ||
826 | int ret; | ||
827 | u8 buf[2]; | ||
828 | |||
829 | deb_info("%s: onoff=%d\n", __func__, onoff); | ||
830 | |||
831 | |||
832 | if (onoff) { | ||
833 | buf[0] = 0x00; | ||
834 | buf[1] = 0x00; | ||
835 | } else { | ||
836 | buf[0] = 0x10; /* stall EPA */ | ||
837 | buf[1] = 0x02; /* reset EPA */ | ||
838 | } | ||
839 | |||
840 | ret = rtl2831_wr_regs(adap->dev, USB_EPA_CTL, buf, 2); | ||
841 | if (ret) | ||
842 | goto err; | ||
843 | |||
844 | return ret; | ||
845 | err: | ||
846 | deb_info("%s: failed=%d\n", __func__, ret); | ||
847 | return ret; | ||
848 | } | ||
849 | |||
850 | static int rtl2831u_power_ctrl(struct dvb_usb_device *d, int onoff) | ||
590 | { | 851 | { |
591 | int ret; | 852 | int ret; |
592 | u8 gpio, sys0; | 853 | u8 gpio, sys0; |
@@ -634,6 +895,128 @@ err: | |||
634 | return ret; | 895 | return ret; |
635 | } | 896 | } |
636 | 897 | ||
898 | static int rtl2832u_power_ctrl(struct dvb_usb_device *d, int onoff) | ||
899 | { | ||
900 | int ret; | ||
901 | u8 val; | ||
902 | |||
903 | deb_info("%s: onoff=%d\n", __func__, onoff); | ||
904 | |||
905 | if (onoff) { | ||
906 | /* set output values */ | ||
907 | ret = rtl2831_rd_reg(d, SYS_GPIO_OUT_VAL, &val); | ||
908 | if (ret) | ||
909 | goto err; | ||
910 | |||
911 | val |= 0x08; | ||
912 | val &= 0xef; | ||
913 | |||
914 | ret = rtl2831_wr_reg(d, SYS_GPIO_OUT_VAL, val); | ||
915 | if (ret) | ||
916 | goto err; | ||
917 | |||
918 | /* demod_ctl_1 */ | ||
919 | ret = rtl2831_rd_reg(d, SYS_DEMOD_CTL1, &val); | ||
920 | if (ret) | ||
921 | goto err; | ||
922 | |||
923 | val &= 0xef; | ||
924 | |||
925 | ret = rtl2831_wr_reg(d, SYS_DEMOD_CTL1, val); | ||
926 | if (ret) | ||
927 | goto err; | ||
928 | |||
929 | /* demod control */ | ||
930 | /* PLL enable */ | ||
931 | ret = rtl2831_rd_reg(d, SYS_DEMOD_CTL, &val); | ||
932 | if (ret) | ||
933 | goto err; | ||
934 | |||
935 | /* bit 7 to 1 */ | ||
936 | val |= 0x80; | ||
937 | |||
938 | ret = rtl2831_wr_reg(d, SYS_DEMOD_CTL, val); | ||
939 | if (ret) | ||
940 | goto err; | ||
941 | |||
942 | /* demod HW reset */ | ||
943 | ret = rtl2831_rd_reg(d, SYS_DEMOD_CTL, &val); | ||
944 | if (ret) | ||
945 | goto err; | ||
946 | /* bit 5 to 0 */ | ||
947 | val &= 0xdf; | ||
948 | |||
949 | ret = rtl2831_wr_reg(d, SYS_DEMOD_CTL, val); | ||
950 | if (ret) | ||
951 | goto err; | ||
952 | |||
953 | ret = rtl2831_rd_reg(d, SYS_DEMOD_CTL, &val); | ||
954 | if (ret) | ||
955 | goto err; | ||
956 | |||
957 | val |= 0x20; | ||
958 | |||
959 | ret = rtl2831_wr_reg(d, SYS_DEMOD_CTL, val); | ||
960 | if (ret) | ||
961 | goto err; | ||
962 | |||
963 | mdelay(5); | ||
964 | |||
965 | /*enable ADC_Q and ADC_I */ | ||
966 | ret = rtl2831_rd_reg(d, SYS_DEMOD_CTL, &val); | ||
967 | if (ret) | ||
968 | goto err; | ||
969 | |||
970 | val |= 0x48; | ||
971 | |||
972 | ret = rtl2831_wr_reg(d, SYS_DEMOD_CTL, val); | ||
973 | if (ret) | ||
974 | goto err; | ||
975 | |||
976 | |||
977 | } else { | ||
978 | /* demod_ctl_1 */ | ||
979 | ret = rtl2831_rd_reg(d, SYS_DEMOD_CTL1, &val); | ||
980 | if (ret) | ||
981 | goto err; | ||
982 | |||
983 | val |= 0x0c; | ||
984 | |||
985 | ret = rtl2831_wr_reg(d, SYS_DEMOD_CTL1, val); | ||
986 | if (ret) | ||
987 | goto err; | ||
988 | |||
989 | /* set output values */ | ||
990 | ret = rtl2831_rd_reg(d, SYS_GPIO_OUT_VAL, &val); | ||
991 | if (ret) | ||
992 | goto err; | ||
993 | |||
994 | val |= 0x10; | ||
995 | |||
996 | ret = rtl2831_wr_reg(d, SYS_GPIO_OUT_VAL, val); | ||
997 | if (ret) | ||
998 | goto err; | ||
999 | |||
1000 | /* demod control */ | ||
1001 | ret = rtl2831_rd_reg(d, SYS_DEMOD_CTL, &val); | ||
1002 | if (ret) | ||
1003 | goto err; | ||
1004 | |||
1005 | val &= 0x37; | ||
1006 | |||
1007 | ret = rtl2831_wr_reg(d, SYS_DEMOD_CTL, val); | ||
1008 | if (ret) | ||
1009 | goto err; | ||
1010 | |||
1011 | } | ||
1012 | |||
1013 | return ret; | ||
1014 | err: | ||
1015 | deb_info("%s: failed=%d\n", __func__, ret); | ||
1016 | return ret; | ||
1017 | } | ||
1018 | |||
1019 | |||
637 | static int rtl2831u_rc_query(struct dvb_usb_device *d) | 1020 | static int rtl2831u_rc_query(struct dvb_usb_device *d) |
638 | { | 1021 | { |
639 | int ret, i; | 1022 | int ret, i; |
@@ -771,6 +1154,7 @@ enum rtl28xxu_usb_table_entry { | |||
771 | RTL2831U_0BDA_2831, | 1154 | RTL2831U_0BDA_2831, |
772 | RTL2831U_14AA_0160, | 1155 | RTL2831U_14AA_0160, |
773 | RTL2831U_14AA_0161, | 1156 | RTL2831U_14AA_0161, |
1157 | RTL2832U_0CCD_00A9, | ||
774 | }; | 1158 | }; |
775 | 1159 | ||
776 | static struct usb_device_id rtl28xxu_table[] = { | 1160 | static struct usb_device_id rtl28xxu_table[] = { |
@@ -783,6 +1167,8 @@ static struct usb_device_id rtl28xxu_table[] = { | |||
783 | USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_FREECOM_DVBT_2)}, | 1167 | USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_FREECOM_DVBT_2)}, |
784 | 1168 | ||
785 | /* RTL2832U */ | 1169 | /* RTL2832U */ |
1170 | [RTL2832U_0CCD_00A9] = { | ||
1171 | USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_STICK_BLACK_REV1)}, | ||
786 | {} /* terminating entry */ | 1172 | {} /* terminating entry */ |
787 | }; | 1173 | }; |
788 | 1174 | ||
@@ -805,7 +1191,7 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { | |||
805 | { | 1191 | { |
806 | .frontend_attach = rtl2831u_frontend_attach, | 1192 | .frontend_attach = rtl2831u_frontend_attach, |
807 | .tuner_attach = rtl2831u_tuner_attach, | 1193 | .tuner_attach = rtl2831u_tuner_attach, |
808 | .streaming_ctrl = rtl28xxu_streaming_ctrl, | 1194 | .streaming_ctrl = rtl2831u_streaming_ctrl, |
809 | .stream = { | 1195 | .stream = { |
810 | .type = USB_BULK, | 1196 | .type = USB_BULK, |
811 | .count = 6, | 1197 | .count = 6, |
@@ -821,7 +1207,7 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { | |||
821 | } | 1207 | } |
822 | }, | 1208 | }, |
823 | 1209 | ||
824 | .power_ctrl = rtl28xxu_power_ctrl, | 1210 | .power_ctrl = rtl2831u_power_ctrl, |
825 | 1211 | ||
826 | .rc.core = { | 1212 | .rc.core = { |
827 | .protocol = RC_TYPE_NEC, | 1213 | .protocol = RC_TYPE_NEC, |
@@ -867,7 +1253,7 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { | |||
867 | { | 1253 | { |
868 | .frontend_attach = rtl2832u_frontend_attach, | 1254 | .frontend_attach = rtl2832u_frontend_attach, |
869 | .tuner_attach = rtl2832u_tuner_attach, | 1255 | .tuner_attach = rtl2832u_tuner_attach, |
870 | .streaming_ctrl = rtl28xxu_streaming_ctrl, | 1256 | .streaming_ctrl = rtl2832u_streaming_ctrl, |
871 | .stream = { | 1257 | .stream = { |
872 | .type = USB_BULK, | 1258 | .type = USB_BULK, |
873 | .count = 6, | 1259 | .count = 6, |
@@ -883,7 +1269,7 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { | |||
883 | } | 1269 | } |
884 | }, | 1270 | }, |
885 | 1271 | ||
886 | .power_ctrl = rtl28xxu_power_ctrl, | 1272 | .power_ctrl = rtl2832u_power_ctrl, |
887 | 1273 | ||
888 | .rc.core = { | 1274 | .rc.core = { |
889 | .protocol = RC_TYPE_NEC, | 1275 | .protocol = RC_TYPE_NEC, |
@@ -896,10 +1282,13 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { | |||
896 | 1282 | ||
897 | .i2c_algo = &rtl28xxu_i2c_algo, | 1283 | .i2c_algo = &rtl28xxu_i2c_algo, |
898 | 1284 | ||
899 | .num_device_descs = 0, /* disabled as no support for RTL2832 */ | 1285 | .num_device_descs = 1, |
900 | .devices = { | 1286 | .devices = { |
901 | { | 1287 | { |
902 | .name = "Realtek RTL2832U reference design", | 1288 | .name = "Terratec Cinergy T Stick Black", |
1289 | .warm_ids = { | ||
1290 | &rtl28xxu_table[RTL2832U_0CCD_00A9], | ||
1291 | }, | ||
903 | }, | 1292 | }, |
904 | } | 1293 | } |
905 | }, | 1294 | }, |
@@ -910,6 +1299,7 @@ static int rtl28xxu_probe(struct usb_interface *intf, | |||
910 | const struct usb_device_id *id) | 1299 | const struct usb_device_id *id) |
911 | { | 1300 | { |
912 | int ret, i; | 1301 | int ret, i; |
1302 | u8 val; | ||
913 | int properties_count = ARRAY_SIZE(rtl28xxu_properties); | 1303 | int properties_count = ARRAY_SIZE(rtl28xxu_properties); |
914 | struct dvb_usb_device *d; | 1304 | struct dvb_usb_device *d; |
915 | struct usb_device *udev; | 1305 | struct usb_device *udev; |
@@ -954,15 +1344,24 @@ static int rtl28xxu_probe(struct usb_interface *intf, | |||
954 | if (ret) | 1344 | if (ret) |
955 | goto err; | 1345 | goto err; |
956 | 1346 | ||
1347 | |||
957 | /* init USB endpoints */ | 1348 | /* init USB endpoints */ |
958 | ret = rtl2831_wr_reg(d, USB_SYSCTL_0, 0x09); | 1349 | ret = rtl2831_rd_reg(d, USB_SYSCTL_0, &val); |
1350 | if (ret) | ||
1351 | goto err; | ||
1352 | |||
1353 | /* enable DMA and Full Packet Mode*/ | ||
1354 | val |= 0x09; | ||
1355 | ret = rtl2831_wr_reg(d, USB_SYSCTL_0, val); | ||
959 | if (ret) | 1356 | if (ret) |
960 | goto err; | 1357 | goto err; |
961 | 1358 | ||
1359 | /* set EPA maximum packet size to 0x0200 */ | ||
962 | ret = rtl2831_wr_regs(d, USB_EPA_MAXPKT, "\x00\x02\x00\x00", 4); | 1360 | ret = rtl2831_wr_regs(d, USB_EPA_MAXPKT, "\x00\x02\x00\x00", 4); |
963 | if (ret) | 1361 | if (ret) |
964 | goto err; | 1362 | goto err; |
965 | 1363 | ||
1364 | /* change EPA FIFO length */ | ||
966 | ret = rtl2831_wr_regs(d, USB_EPA_FIFO_CFG, "\x14\x00\x00\x00", 4); | 1365 | ret = rtl2831_wr_regs(d, USB_EPA_FIFO_CFG, "\x14\x00\x00\x00", 4); |
967 | if (ret) | 1366 | if (ret) |
968 | goto err; | 1367 | goto err; |
@@ -1007,4 +1406,5 @@ module_exit(rtl28xxu_module_exit); | |||
1007 | 1406 | ||
1008 | MODULE_DESCRIPTION("Realtek RTL28xxU DVB USB driver"); | 1407 | MODULE_DESCRIPTION("Realtek RTL28xxU DVB USB driver"); |
1009 | MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>"); | 1408 | MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>"); |
1409 | MODULE_AUTHOR("Thomas Mair <thomas.mair86@googlemail.com>"); | ||
1010 | MODULE_LICENSE("GPL"); | 1410 | MODULE_LICENSE("GPL"); |