aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb-frontends/rtl2832.c
diff options
context:
space:
mode:
authorAntti Palosaari <crope@iki.fi>2012-08-21 18:56:20 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-09-15 08:30:10 -0400
commit0ce67a2a59b26dd1b087115141c71ddd89514b77 (patch)
treeec7995bf0441d1251b4c216b5ed4af510f6f3dd3 /drivers/media/dvb-frontends/rtl2832.c
parente1f43269710daf3ab0d8d0da428f7f647c11676d (diff)
[media] rtl2832: implement .get_frontend()
Copied from rtl2830. Cc: Thomas Mair <thomas.mair86@googlemail.com> Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb-frontends/rtl2832.c')
-rw-r--r--drivers/media/dvb-frontends/rtl2832.c113
1 files changed, 113 insertions, 0 deletions
diff --git a/drivers/media/dvb-frontends/rtl2832.c b/drivers/media/dvb-frontends/rtl2832.c
index 18e1ae38b2df..6e28444d6526 100644
--- a/drivers/media/dvb-frontends/rtl2832.c
+++ b/drivers/media/dvb-frontends/rtl2832.c
@@ -636,6 +636,118 @@ err:
636 return ret; 636 return ret;
637} 637}
638 638
639static int rtl2832_get_frontend(struct dvb_frontend *fe)
640{
641 struct rtl2832_priv *priv = fe->demodulator_priv;
642 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
643 int ret;
644 u8 buf[3];
645
646 if (priv->sleeping)
647 return 0;
648
649 ret = rtl2832_rd_regs(priv, 0x3c, 3, buf, 2);
650 if (ret)
651 goto err;
652
653 ret = rtl2832_rd_reg(priv, 0x51, 3, &buf[2]);
654 if (ret)
655 goto err;
656
657 dbg("%s: TPS=%*ph", __func__, 3, buf);
658
659 switch ((buf[0] >> 2) & 3) {
660 case 0:
661 c->modulation = QPSK;
662 break;
663 case 1:
664 c->modulation = QAM_16;
665 break;
666 case 2:
667 c->modulation = QAM_64;
668 break;
669 }
670
671 switch ((buf[2] >> 2) & 1) {
672 case 0:
673 c->transmission_mode = TRANSMISSION_MODE_2K;
674 break;
675 case 1:
676 c->transmission_mode = TRANSMISSION_MODE_8K;
677 }
678
679 switch ((buf[2] >> 0) & 3) {
680 case 0:
681 c->guard_interval = GUARD_INTERVAL_1_32;
682 break;
683 case 1:
684 c->guard_interval = GUARD_INTERVAL_1_16;
685 break;
686 case 2:
687 c->guard_interval = GUARD_INTERVAL_1_8;
688 break;
689 case 3:
690 c->guard_interval = GUARD_INTERVAL_1_4;
691 break;
692 }
693
694 switch ((buf[0] >> 4) & 7) {
695 case 0:
696 c->hierarchy = HIERARCHY_NONE;
697 break;
698 case 1:
699 c->hierarchy = HIERARCHY_1;
700 break;
701 case 2:
702 c->hierarchy = HIERARCHY_2;
703 break;
704 case 3:
705 c->hierarchy = HIERARCHY_4;
706 break;
707 }
708
709 switch ((buf[1] >> 3) & 7) {
710 case 0:
711 c->code_rate_HP = FEC_1_2;
712 break;
713 case 1:
714 c->code_rate_HP = FEC_2_3;
715 break;
716 case 2:
717 c->code_rate_HP = FEC_3_4;
718 break;
719 case 3:
720 c->code_rate_HP = FEC_5_6;
721 break;
722 case 4:
723 c->code_rate_HP = FEC_7_8;
724 break;
725 }
726
727 switch ((buf[1] >> 0) & 7) {
728 case 0:
729 c->code_rate_LP = FEC_1_2;
730 break;
731 case 1:
732 c->code_rate_LP = FEC_2_3;
733 break;
734 case 2:
735 c->code_rate_LP = FEC_3_4;
736 break;
737 case 3:
738 c->code_rate_LP = FEC_5_6;
739 break;
740 case 4:
741 c->code_rate_LP = FEC_7_8;
742 break;
743 }
744
745 return 0;
746err:
747 dbg("%s: failed=%d", __func__, ret);
748 return ret;
749}
750
639static int rtl2832_read_status(struct dvb_frontend *fe, fe_status_t *status) 751static int rtl2832_read_status(struct dvb_frontend *fe, fe_status_t *status)
640{ 752{
641 struct rtl2832_priv *priv = fe->demodulator_priv; 753 struct rtl2832_priv *priv = fe->demodulator_priv;
@@ -749,6 +861,7 @@ static struct dvb_frontend_ops rtl2832_ops = {
749 .get_tune_settings = rtl2832_get_tune_settings, 861 .get_tune_settings = rtl2832_get_tune_settings,
750 862
751 .set_frontend = rtl2832_set_frontend, 863 .set_frontend = rtl2832_set_frontend,
864 .get_frontend = rtl2832_get_frontend,
752 865
753 .read_status = rtl2832_read_status, 866 .read_status = rtl2832_read_status,
754 .i2c_gate_ctrl = rtl2832_i2c_gate_ctrl, 867 .i2c_gate_ctrl = rtl2832_i2c_gate_ctrl,