aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Krufky <mkrufky@linuxtv.org>2007-08-31 15:39:39 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-10-09 21:07:45 -0400
commit735f0b9af1748602bb7f3a8009c31cf5f133eec8 (patch)
tree101e80cb5bbea411baedc57954e38f45a90c5c66
parent8fb3b9f7a9e0420150bf6cb8a3c20f45d372cce4 (diff)
V4L/DVB (6137): tuner-simple: add get_rf_strength and improve status reading efficiency
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r--drivers/media/video/tuner-simple.c58
1 files changed, 36 insertions, 22 deletions
diff --git a/drivers/media/video/tuner-simple.c b/drivers/media/video/tuner-simple.c
index 2dbd91c8cb64..7b93d3b1f4c6 100644
--- a/drivers/media/video/tuner-simple.c
+++ b/drivers/media/video/tuner-simple.c
@@ -102,7 +102,7 @@ struct tuner_simple_priv {
102 102
103/* ---------------------------------------------------------------------- */ 103/* ---------------------------------------------------------------------- */
104 104
105static int tuner_getstatus(struct dvb_frontend *fe) 105static int tuner_read_status(struct dvb_frontend *fe)
106{ 106{
107 struct tuner_simple_priv *priv = fe->tuner_priv; 107 struct tuner_simple_priv *priv = fe->tuner_priv;
108 unsigned char byte; 108 unsigned char byte;
@@ -113,47 +113,60 @@ static int tuner_getstatus(struct dvb_frontend *fe)
113 return byte; 113 return byte;
114} 114}
115 115
116static int tuner_signal(struct dvb_frontend *fe) 116static inline int tuner_signal(const int status)
117{ 117{
118 return (tuner_getstatus(fe) & TUNER_SIGNAL) << 13; 118 return (status & TUNER_SIGNAL) << 13;
119} 119}
120 120
121static int tuner_stereo(struct dvb_frontend *fe) 121static inline int tuner_stereo(const int type, const int status)
122{ 122{
123 struct tuner_simple_priv *priv = fe->tuner_priv; 123 switch (type) {
124
125 int stereo, status;
126
127 status = tuner_getstatus(fe);
128
129 switch (priv->type) {
130 case TUNER_PHILIPS_FM1216ME_MK3: 124 case TUNER_PHILIPS_FM1216ME_MK3:
131 case TUNER_PHILIPS_FM1236_MK3: 125 case TUNER_PHILIPS_FM1236_MK3:
132 case TUNER_PHILIPS_FM1256_IH3: 126 case TUNER_PHILIPS_FM1256_IH3:
133 case TUNER_LG_NTSC_TAPE: 127 case TUNER_LG_NTSC_TAPE:
134 stereo = ((status & TUNER_SIGNAL) == TUNER_STEREO_MK3); 128 return ((status & TUNER_SIGNAL) == TUNER_STEREO_MK3);
135 break;
136 default: 129 default:
137 stereo = status & TUNER_STEREO; 130 return status & TUNER_STEREO;
138 } 131 }
132}
139 133
140 return stereo; 134static inline int tuner_islocked(const int status)
135{
136 return (status & TUNER_FL);
137}
138
139static inline int tuner_afcstatus(const int status)
140{
141 return (status & TUNER_AFC) - 2;
141} 142}
142 143
143 144
144static int simple_get_status(struct dvb_frontend *fe, u32 *status) 145static int simple_get_status(struct dvb_frontend *fe, u32 *status)
145{ 146{
146 struct tuner_simple_priv *priv = fe->tuner_priv; 147 struct tuner_simple_priv *priv = fe->tuner_priv;
147 int signal = tuner_signal(fe); 148 int tuner_status = tuner_read_status(fe);
148 149
149 *status = 0; 150 *status = 0;
150 151
151 if (signal) 152 if (tuner_islocked(tuner_status))
152 *status = TUNER_STATUS_LOCKED; 153 *status = TUNER_STATUS_LOCKED;
153 if (tuner_stereo(fe)) 154 if (tuner_stereo(priv->type, tuner_status))
154 *status |= TUNER_STATUS_STEREO; 155 *status |= TUNER_STATUS_STEREO;
155 156
156 tuner_dbg("tuner-simple: Signal strength: %d\n", signal); 157 tuner_dbg("AFC Status: %d\n", tuner_afcstatus(tuner_status));
158
159 return 0;
160}
161
162static int simple_get_rf_strength(struct dvb_frontend *fe, u16 *strength)
163{
164 struct tuner_simple_priv *priv = fe->tuner_priv;
165 int signal = tuner_signal(tuner_read_status(fe));
166
167 *strength = signal;
168
169 tuner_dbg("Signal strength: %d\n", signal);
157 170
158 return 0; 171 return 0;
159} 172}
@@ -580,9 +593,10 @@ static int simple_get_frequency(struct dvb_frontend *fe, u32 *frequency)
580 593
581static struct dvb_tuner_ops simple_tuner_ops = { 594static struct dvb_tuner_ops simple_tuner_ops = {
582 .set_analog_params = simple_set_params, 595 .set_analog_params = simple_set_params,
583 .release = simple_release, 596 .release = simple_release,
584 .get_frequency = simple_get_frequency, 597 .get_frequency = simple_get_frequency,
585 .get_status = simple_get_status, 598 .get_status = simple_get_status,
599 .get_rf_strength = simple_get_rf_strength,
586}; 600};
587 601
588struct dvb_frontend *simple_tuner_attach(struct dvb_frontend *fe, 602struct dvb_frontend *simple_tuner_attach(struct dvb_frontend *fe,