aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb
diff options
context:
space:
mode:
authorMichael Krufky <mkrufky@linuxtv.org>2008-01-05 22:55:21 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-01-25 16:04:42 -0500
commitccbac9bb174db457181f5f58fecf9cbc3020ea1d (patch)
treede5b29979d06149858ade5d1ac44fb72b6de5fd6 /drivers/media/dvb
parent09f83c4fc06b02597ad4458c2a6675b0872f0b5c (diff)
V4L/DVB (6978): tda18271: store frequency and bandwidth after successful tune
Store last tuned frequency & bandwidth after successful tune. Clean up tune functions -- remove pointer to tune function in state structure, instead call tune function based on priv->id. Signed-off-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r--drivers/media/dvb/frontends/tda18271-fe.c46
-rw-r--r--drivers/media/dvb/frontends/tda18271-priv.h3
2 files changed, 38 insertions, 11 deletions
diff --git a/drivers/media/dvb/frontends/tda18271-fe.c b/drivers/media/dvb/frontends/tda18271-fe.c
index 1a86c9f7a7e4..c1da16ad07e7 100644
--- a/drivers/media/dvb/frontends/tda18271-fe.c
+++ b/drivers/media/dvb/frontends/tda18271-fe.c
@@ -770,6 +770,23 @@ static int tda18271c1_tune(struct dvb_frontend *fe,
770 return 0; 770 return 0;
771} 771}
772 772
773static inline int tda18271_tune(struct dvb_frontend *fe,
774 u32 ifc, u32 freq, u32 bw, u8 std)
775{
776 struct tda18271_priv *priv = fe->tuner_priv;
777 int ret = -EINVAL;
778
779 switch (priv->id) {
780 case TDA18271HDC1:
781 ret = tda18271c1_tune(fe, ifc, freq, bw, std);
782 break;
783 case TDA18271HDC2:
784 ret = tda18271c2_tune(fe, ifc, freq, bw, std);
785 break;
786 }
787 return ret;
788}
789
773/* ------------------------------------------------------------------ */ 790/* ------------------------------------------------------------------ */
774 791
775static int tda18271_set_params(struct dvb_frontend *fe, 792static int tda18271_set_params(struct dvb_frontend *fe,
@@ -777,12 +794,11 @@ static int tda18271_set_params(struct dvb_frontend *fe,
777{ 794{
778 struct tda18271_priv *priv = fe->tuner_priv; 795 struct tda18271_priv *priv = fe->tuner_priv;
779 struct tda18271_std_map *std_map = &priv->std; 796 struct tda18271_std_map *std_map = &priv->std;
797 int ret;
780 u8 std; 798 u8 std;
781 u16 sgIF; 799 u16 sgIF;
782 u32 bw, freq = params->frequency; 800 u32 bw, freq = params->frequency;
783 801
784 BUG_ON(!priv->tune);
785
786 priv->mode = TDA18271_DIGITAL; 802 priv->mode = TDA18271_DIGITAL;
787 803
788 /* see table 22 */ 804 /* see table 22 */
@@ -833,7 +849,16 @@ static int tda18271_set_params(struct dvb_frontend *fe,
833 return -EINVAL; 849 return -EINVAL;
834 } 850 }
835 851
836 return priv->tune(fe, sgIF * 1000, freq, bw, std); 852 ret = tda18271_tune(fe, sgIF * 1000, freq, bw, std);
853
854 if (ret < 0)
855 goto fail;
856
857 priv->frequency = freq;
858 priv->bandwidth = (fe->ops.info.type == FE_OFDM) ?
859 params->u.ofdm.bandwidth : 0;
860fail:
861 return ret;
837} 862}
838 863
839static int tda18271_set_analog_params(struct dvb_frontend *fe, 864static int tda18271_set_analog_params(struct dvb_frontend *fe,
@@ -842,12 +867,11 @@ static int tda18271_set_analog_params(struct dvb_frontend *fe,
842 struct tda18271_priv *priv = fe->tuner_priv; 867 struct tda18271_priv *priv = fe->tuner_priv;
843 struct tda18271_std_map *std_map = &priv->std; 868 struct tda18271_std_map *std_map = &priv->std;
844 char *mode; 869 char *mode;
870 int ret;
845 u8 std; 871 u8 std;
846 u16 sgIF; 872 u16 sgIF;
847 u32 freq = params->frequency * 62500; 873 u32 freq = params->frequency * 62500;
848 874
849 BUG_ON(!priv->tune);
850
851 priv->mode = TDA18271_ANALOG; 875 priv->mode = TDA18271_ANALOG;
852 876
853 if (params->std & V4L2_STD_MN) { 877 if (params->std & V4L2_STD_MN) {
@@ -886,7 +910,15 @@ static int tda18271_set_analog_params(struct dvb_frontend *fe,
886 910
887 tda_dbg("setting tda18271 to system %s\n", mode); 911 tda_dbg("setting tda18271 to system %s\n", mode);
888 912
889 return priv->tune(fe, sgIF * 1000, freq, 0, std); 913 ret = tda18271_tune(fe, sgIF * 1000, freq, 0, std);
914
915 if (ret < 0)
916 goto fail;
917
918 priv->frequency = freq;
919 priv->bandwidth = 0;
920fail:
921 return ret;
890} 922}
891 923
892static int tda18271_release(struct dvb_frontend *fe) 924static int tda18271_release(struct dvb_frontend *fe)
@@ -986,12 +1018,10 @@ static int tda18271_get_id(struct dvb_frontend *fe)
986 case 3: 1018 case 3:
987 name = "TDA18271HD/C1"; 1019 name = "TDA18271HD/C1";
988 priv->id = TDA18271HDC1; 1020 priv->id = TDA18271HDC1;
989 priv->tune = tda18271c1_tune;
990 break; 1021 break;
991 case 4: 1022 case 4:
992 name = "TDA18271HD/C2"; 1023 name = "TDA18271HD/C2";
993 priv->id = TDA18271HDC2; 1024 priv->id = TDA18271HDC2;
994 priv->tune = tda18271c2_tune;
995 break; 1025 break;
996 default: 1026 default:
997 name = "Unknown device"; 1027 name = "Unknown device";
diff --git a/drivers/media/dvb/frontends/tda18271-priv.h b/drivers/media/dvb/frontends/tda18271-priv.h
index 7b06e0599dc5..b4d1ab770ca2 100644
--- a/drivers/media/dvb/frontends/tda18271-priv.h
+++ b/drivers/media/dvb/frontends/tda18271-priv.h
@@ -112,9 +112,6 @@ struct tda18271_priv {
112 struct tda18271_std_map std; 112 struct tda18271_std_map std;
113 struct tda18271_rf_tracking_filter_cal rf_cal_state[8]; 113 struct tda18271_rf_tracking_filter_cal rf_cal_state[8];
114 114
115 int (*tune) (struct dvb_frontend *fe,
116 u32 ifc, u32 freq, u32 bw, u8 std);
117
118 u32 frequency; 115 u32 frequency;
119 u32 bandwidth; 116 u32 bandwidth;
120}; 117};