summaryrefslogtreecommitdiffstats
path: root/drivers/media/video/tea5767.c
diff options
context:
space:
mode:
authorMichael Krufky <mkrufky@linuxtv.org>2007-08-31 16:40:14 -0300
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-10-09 22:07:49 -0300
commit6b897f2c3982af51134ba83f4b6de71d28d35944 (patch)
treec042c0dc48408f45e7c54b528fdb222119bc2e97 /drivers/media/video/tea5767.c
parentfd443f7444180c1cd9cbcb816ebf65c8b8e35301 (diff)
downloadop-kernel-dev-6b897f2c3982af51134ba83f4b6de71d28d35944.zip
op-kernel-dev-6b897f2c3982af51134ba83f4b6de71d28d35944.tar.gz
V4L/DVB (6139): tea5767: 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>
Diffstat (limited to 'drivers/media/video/tea5767.c')
-rw-r--r--drivers/media/video/tea5767.c63
1 files changed, 41 insertions, 22 deletions
diff --git a/drivers/media/video/tea5767.c b/drivers/media/video/tea5767.c
index cf908d8..71df419 100644
--- a/drivers/media/video/tea5767.c
+++ b/drivers/media/video/tea5767.c
@@ -264,48 +264,66 @@ static int set_radio_freq(struct dvb_frontend *fe,
return 0;
}
-static int tea5767_signal(struct dvb_frontend *fe)
+static int tea5767_read_status(struct dvb_frontend *fe, char *buffer)
{
- unsigned char buffer[5];
- int rc;
struct tea5767_priv *priv = fe->tuner_priv;
+ int rc;
- memset(buffer, 0, sizeof(buffer));
- if (5 != (rc = tuner_i2c_xfer_recv(&priv->i2c_props, buffer, 5)))
+ memset(buffer, 0, 5);
+ if (5 != (rc = tuner_i2c_xfer_recv(&priv->i2c_props, buffer, 5))) {
tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc);
+ return -EREMOTEIO;
+ }
- return ((buffer[3] & TEA5767_ADC_LEVEL_MASK) << 8);
+ return 0;
}
-static int tea5767_stereo(struct dvb_frontend *fe)
+static inline int tea5767_signal(struct dvb_frontend *fe, const char *buffer)
{
- unsigned char buffer[5];
- int rc;
struct tea5767_priv *priv = fe->tuner_priv;
- memset(buffer, 0, sizeof(buffer));
- if (5 != (rc = tuner_i2c_xfer_recv(&priv->i2c_props, buffer, 5)))
- tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc);
+ int signal = ((buffer[3] & TEA5767_ADC_LEVEL_MASK) << 8);
+
+ tuner_dbg("Signal strength: %d\n", signal);
+
+ return signal;
+}
- rc = buffer[2] & TEA5767_STEREO_MASK;
+static inline int tea5767_stereo(struct dvb_frontend *fe, const char *buffer)
+{
+ struct tea5767_priv *priv = fe->tuner_priv;
- tuner_dbg("radio ST GET = %02x\n", rc);
+ int stereo = buffer[2] & TEA5767_STEREO_MASK;
- return ((buffer[2] & TEA5767_STEREO_MASK) ? V4L2_TUNER_SUB_STEREO : 0);
+ tuner_dbg("Radio ST GET = %02x\n", stereo);
+
+ return (stereo ? V4L2_TUNER_SUB_STEREO : 0);
}
static int tea5767_get_status(struct dvb_frontend *fe, u32 *status)
{
- struct tea5767_priv *priv = fe->tuner_priv;
- int signal = tea5767_signal(fe);
+ unsigned char buffer[5];
+
*status = 0;
- if (signal)
- *status = TUNER_STATUS_LOCKED;
- if (tea5767_stereo(fe))
- *status |= TUNER_STATUS_STEREO;
+ if (0 == tea5767_read_status(fe, buffer)) {
+ if (tea5767_signal(fe, buffer))
+ *status = TUNER_STATUS_LOCKED;
+ if (tea5767_stereo(fe, buffer))
+ *status |= TUNER_STATUS_STEREO;
+ }
+
+ return 0;
+}
+
+static int tea5767_get_rf_strength(struct dvb_frontend *fe, u16 *strength)
+{
+ unsigned char buffer[5];
+
+ *strength = 0;
- tuner_dbg("tea5767: Signal strength: %d\n", signal);
+ if (0 == tea5767_read_status(fe, buffer))
+ *strength = tea5767_signal(fe, buffer);
return 0;
}
@@ -393,6 +411,7 @@ static struct dvb_tuner_ops tea5767_tuner_ops = {
.release = tea5767_release,
.get_frequency = tea5767_get_frequency,
.get_status = tea5767_get_status,
+ .get_rf_strength = tea5767_get_rf_strength,
};
struct dvb_frontend *tea5767_attach(struct dvb_frontend *fe,
OpenPOWER on IntegriCloud