aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/frontends/tda18271-fe.c
diff options
context:
space:
mode:
authorMichael Krufky <mkrufky@linuxtv.org>2008-04-22 13:46:06 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-04-24 13:07:52 -0400
commitc293d0a72ecb9dd09037cdf4a9089e455404cf4a (patch)
tree829b7197ff957f3364831b5bd45c483c2148ff03 /drivers/media/dvb/frontends/tda18271-fe.c
parent5555309c9adcf9bb7f6b449ef45b09d5c26ef4ae (diff)
V4L/DVB (7384): tda18271: store FM_RFn setting in struct tda18271_std_map_item
All standard related configuration is stored within struct tda18271_std_map_item. Pass a pointer to this structure rather than its individual members. Signed-off-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/dvb/frontends/tda18271-fe.c')
-rw-r--r--drivers/media/dvb/frontends/tda18271-fe.c76
1 files changed, 29 insertions, 47 deletions
diff --git a/drivers/media/dvb/frontends/tda18271-fe.c b/drivers/media/dvb/frontends/tda18271-fe.c
index bb0a65310b71..fef225abee96 100644
--- a/drivers/media/dvb/frontends/tda18271-fe.c
+++ b/drivers/media/dvb/frontends/tda18271-fe.c
@@ -37,8 +37,8 @@ static LIST_HEAD(hybrid_tuner_instance_list);
37/*---------------------------------------------------------------------*/ 37/*---------------------------------------------------------------------*/
38 38
39static int tda18271_channel_configuration(struct dvb_frontend *fe, 39static int tda18271_channel_configuration(struct dvb_frontend *fe,
40 u32 ifc, u32 freq, u32 bw, u8 std, 40 struct tda18271_std_map_item *map,
41 int radio) 41 u32 freq, u32 bw)
42{ 42{
43 struct tda18271_priv *priv = fe->tuner_priv; 43 struct tda18271_priv *priv = fe->tuner_priv;
44 unsigned char *regs = priv->tda18271_regs; 44 unsigned char *regs = priv->tda18271_regs;
@@ -48,7 +48,7 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe,
48 48
49 /* set standard */ 49 /* set standard */
50 regs[R_EP3] &= ~0x1f; /* clear std bits */ 50 regs[R_EP3] &= ~0x1f; /* clear std bits */
51 regs[R_EP3] |= std; 51 regs[R_EP3] |= map->std_bits;
52 52
53 /* set cal mode to normal */ 53 /* set cal mode to normal */
54 regs[R_EP4] &= ~0x03; 54 regs[R_EP4] &= ~0x03;
@@ -66,10 +66,9 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe,
66 break; 66 break;
67 } 67 }
68 68
69 if (radio) 69 /* update FM_RFn */
70 regs[R_EP4] |= 0x80; 70 regs[R_EP4] &= ~0x80;
71 else 71 regs[R_EP4] |= map->fm_rfn << 7;
72 regs[R_EP4] &= ~0x80;
73 72
74 /* update RF_TOP / IF_TOP */ 73 /* update RF_TOP / IF_TOP */
75 switch (priv->mode) { 74 switch (priv->mode) {
@@ -114,7 +113,7 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe,
114 113
115 /* --------------------------------------------------------------- */ 114 /* --------------------------------------------------------------- */
116 115
117 N = freq + ifc; 116 N = map->if_freq * 1000 + freq;
118 117
119 /* FIXME: assumes master */ 118 /* FIXME: assumes master */
120 tda18271_calc_main_pll(fe, N); 119 tda18271_calc_main_pll(fe, N);
@@ -728,12 +727,12 @@ static int tda18271_init(struct dvb_frontend *fe)
728} 727}
729 728
730static int tda18271_tune(struct dvb_frontend *fe, 729static int tda18271_tune(struct dvb_frontend *fe,
731 u32 ifc, u32 freq, u32 bw, u8 std, int radio) 730 struct tda18271_std_map_item *map, u32 freq, u32 bw)
732{ 731{
733 struct tda18271_priv *priv = fe->tuner_priv; 732 struct tda18271_priv *priv = fe->tuner_priv;
734 733
735 tda_dbg("freq = %d, ifc = %d, bw = %d, std = 0x%02x\n", 734 tda_dbg("freq = %d, ifc = %d, bw = %d, std = 0x%02x\n",
736 freq, ifc, bw, std); 735 freq, map->if_freq, bw, map->std_bits);
737 736
738 tda18271_init(fe); 737 tda18271_init(fe);
739 738
@@ -747,7 +746,7 @@ static int tda18271_tune(struct dvb_frontend *fe,
747 tda18271c2_rf_tracking_filters_correction(fe, freq); 746 tda18271c2_rf_tracking_filters_correction(fe, freq);
748 break; 747 break;
749 } 748 }
750 tda18271_channel_configuration(fe, ifc, freq, bw, std, radio); 749 tda18271_channel_configuration(fe, map, freq, bw);
751 750
752 mutex_unlock(&priv->lock); 751 mutex_unlock(&priv->lock);
753 752
@@ -761,9 +760,8 @@ static int tda18271_set_params(struct dvb_frontend *fe,
761{ 760{
762 struct tda18271_priv *priv = fe->tuner_priv; 761 struct tda18271_priv *priv = fe->tuner_priv;
763 struct tda18271_std_map *std_map = &priv->std; 762 struct tda18271_std_map *std_map = &priv->std;
763 struct tda18271_std_map_item *map;
764 int ret; 764 int ret;
765 u8 std;
766 u16 sgIF;
767 u32 bw, freq = params->frequency; 765 u32 bw, freq = params->frequency;
768 766
769 priv->mode = TDA18271_DIGITAL; 767 priv->mode = TDA18271_DIGITAL;
@@ -772,13 +770,11 @@ static int tda18271_set_params(struct dvb_frontend *fe,
772 switch (params->u.vsb.modulation) { 770 switch (params->u.vsb.modulation) {
773 case VSB_8: 771 case VSB_8:
774 case VSB_16: 772 case VSB_16:
775 std = std_map->atsc_6.std_bits; 773 map = &std_map->atsc_6;
776 sgIF = std_map->atsc_6.if_freq;
777 break; 774 break;
778 case QAM_64: 775 case QAM_64:
779 case QAM_256: 776 case QAM_256:
780 std = std_map->qam_6.std_bits; 777 map = &std_map->qam_6;
781 sgIF = std_map->qam_6.if_freq;
782 break; 778 break;
783 default: 779 default:
784 tda_warn("modulation not set!\n"); 780 tda_warn("modulation not set!\n");
@@ -793,18 +789,15 @@ static int tda18271_set_params(struct dvb_frontend *fe,
793 switch (params->u.ofdm.bandwidth) { 789 switch (params->u.ofdm.bandwidth) {
794 case BANDWIDTH_6_MHZ: 790 case BANDWIDTH_6_MHZ:
795 bw = 6000000; 791 bw = 6000000;
796 std = std_map->dvbt_6.std_bits; 792 map = &std_map->dvbt_6;
797 sgIF = std_map->dvbt_6.if_freq;
798 break; 793 break;
799 case BANDWIDTH_7_MHZ: 794 case BANDWIDTH_7_MHZ:
800 bw = 7000000; 795 bw = 7000000;
801 std = std_map->dvbt_7.std_bits; 796 map = &std_map->dvbt_7;
802 sgIF = std_map->dvbt_7.if_freq;
803 break; 797 break;
804 case BANDWIDTH_8_MHZ: 798 case BANDWIDTH_8_MHZ:
805 bw = 8000000; 799 bw = 8000000;
806 std = std_map->dvbt_8.std_bits; 800 map = &std_map->dvbt_8;
807 sgIF = std_map->dvbt_8.if_freq;
808 break; 801 break;
809 default: 802 default:
810 tda_warn("bandwidth not set!\n"); 803 tda_warn("bandwidth not set!\n");
@@ -819,7 +812,7 @@ static int tda18271_set_params(struct dvb_frontend *fe,
819 if (fe->ops.analog_ops.standby) 812 if (fe->ops.analog_ops.standby)
820 fe->ops.analog_ops.standby(fe); 813 fe->ops.analog_ops.standby(fe);
821 814
822 ret = tda18271_tune(fe, sgIF * 1000, freq, bw, std, 0); 815 ret = tda18271_tune(fe, map, freq, bw);
823 816
824 if (ret < 0) 817 if (ret < 0)
825 goto fail; 818 goto fail;
@@ -836,57 +829,46 @@ static int tda18271_set_analog_params(struct dvb_frontend *fe,
836{ 829{
837 struct tda18271_priv *priv = fe->tuner_priv; 830 struct tda18271_priv *priv = fe->tuner_priv;
838 struct tda18271_std_map *std_map = &priv->std; 831 struct tda18271_std_map *std_map = &priv->std;
832 struct tda18271_std_map_item *map;
839 char *mode; 833 char *mode;
840 int ret, radio = 0; 834 int ret;
841 u8 std;
842 u16 sgIF;
843 u32 freq = params->frequency * 62500; 835 u32 freq = params->frequency * 62500;
844 836
845 priv->mode = TDA18271_ANALOG; 837 priv->mode = TDA18271_ANALOG;
846 838
847 if (params->mode == V4L2_TUNER_RADIO) { 839 if (params->mode == V4L2_TUNER_RADIO) {
848 radio = 1;
849 freq = freq / 1000; 840 freq = freq / 1000;
850 std = std_map->fm_radio.std_bits; 841 map = &std_map->fm_radio;
851 sgIF = std_map->fm_radio.if_freq;
852 mode = "fm"; 842 mode = "fm";
853 } else if (params->std & V4L2_STD_MN) { 843 } else if (params->std & V4L2_STD_MN) {
854 std = std_map->atv_mn.std_bits; 844 map = &std_map->atv_mn;
855 sgIF = std_map->atv_mn.if_freq;
856 mode = "MN"; 845 mode = "MN";
857 } else if (params->std & V4L2_STD_B) { 846 } else if (params->std & V4L2_STD_B) {
858 std = std_map->atv_b.std_bits; 847 map = &std_map->atv_b;
859 sgIF = std_map->atv_b.if_freq;
860 mode = "B"; 848 mode = "B";
861 } else if (params->std & V4L2_STD_GH) { 849 } else if (params->std & V4L2_STD_GH) {
862 std = std_map->atv_gh.std_bits; 850 map = &std_map->atv_gh;
863 sgIF = std_map->atv_gh.if_freq;
864 mode = "GH"; 851 mode = "GH";
865 } else if (params->std & V4L2_STD_PAL_I) { 852 } else if (params->std & V4L2_STD_PAL_I) {
866 std = std_map->atv_i.std_bits; 853 map = &std_map->atv_i;
867 sgIF = std_map->atv_i.if_freq;
868 mode = "I"; 854 mode = "I";
869 } else if (params->std & V4L2_STD_DK) { 855 } else if (params->std & V4L2_STD_DK) {
870 std = std_map->atv_dk.std_bits; 856 map = &std_map->atv_dk;
871 sgIF = std_map->atv_dk.if_freq;
872 mode = "DK"; 857 mode = "DK";
873 } else if (params->std & V4L2_STD_SECAM_L) { 858 } else if (params->std & V4L2_STD_SECAM_L) {
874 std = std_map->atv_l.std_bits; 859 map = &std_map->atv_l;
875 sgIF = std_map->atv_l.if_freq;
876 mode = "L"; 860 mode = "L";
877 } else if (params->std & V4L2_STD_SECAM_LC) { 861 } else if (params->std & V4L2_STD_SECAM_LC) {
878 std = std_map->atv_lc.std_bits; 862 map = &std_map->atv_lc;
879 sgIF = std_map->atv_lc.if_freq;
880 mode = "L'"; 863 mode = "L'";
881 } else { 864 } else {
882 std = std_map->atv_i.std_bits; 865 map = &std_map->atv_i;
883 sgIF = std_map->atv_i.if_freq;
884 mode = "xx"; 866 mode = "xx";
885 } 867 }
886 868
887 tda_dbg("setting tda18271 to system %s\n", mode); 869 tda_dbg("setting tda18271 to system %s\n", mode);
888 870
889 ret = tda18271_tune(fe, sgIF * 1000, freq, 0, std, radio); 871 ret = tda18271_tune(fe, map, freq, 0);
890 872
891 if (ret < 0) 873 if (ret < 0)
892 goto fail; 874 goto fail;