Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=735f0b9af1748602bb7f3a8009c31cf5f133eec8
Commit:     735f0b9af1748602bb7f3a8009c31cf5f133eec8
Parent:     8fb3b9f7a9e0420150bf6cb8a3c20f45d372cce4
Author:     Michael Krufky <[EMAIL PROTECTED]>
AuthorDate: Fri Aug 31 16:39:39 2007 -0300
Committer:  Mauro Carvalho Chehab <[EMAIL PROTECTED]>
CommitDate: Tue Oct 9 22:07:45 2007 -0300

    V4L/DVB (6137): tuner-simple: add get_rf_strength and improve status 
reading efficiency
    
    Signed-off-by: Michael Krufky <[EMAIL PROTECTED]>
    Signed-off-by: Mauro Carvalho Chehab <[EMAIL PROTECTED]>
---
 drivers/media/video/tuner-simple.c |   58 ++++++++++++++++++++++-------------
 1 files changed, 36 insertions(+), 22 deletions(-)

diff --git a/drivers/media/video/tuner-simple.c 
b/drivers/media/video/tuner-simple.c
index 2dbd91c..7b93d3b 100644
--- a/drivers/media/video/tuner-simple.c
+++ b/drivers/media/video/tuner-simple.c
@@ -102,7 +102,7 @@ struct tuner_simple_priv {
 
 /* ---------------------------------------------------------------------- */
 
-static int tuner_getstatus(struct dvb_frontend *fe)
+static int tuner_read_status(struct dvb_frontend *fe)
 {
        struct tuner_simple_priv *priv = fe->tuner_priv;
        unsigned char byte;
@@ -113,47 +113,60 @@ static int tuner_getstatus(struct dvb_frontend *fe)
        return byte;
 }
 
-static int tuner_signal(struct dvb_frontend *fe)
+static inline int tuner_signal(const int status)
 {
-       return (tuner_getstatus(fe) & TUNER_SIGNAL) << 13;
+       return (status & TUNER_SIGNAL) << 13;
 }
 
-static int tuner_stereo(struct dvb_frontend *fe)
+static inline int tuner_stereo(const int type, const int status)
 {
-       struct tuner_simple_priv *priv = fe->tuner_priv;
-
-       int stereo, status;
-
-       status = tuner_getstatus(fe);
-
-       switch (priv->type) {
+       switch (type) {
                case TUNER_PHILIPS_FM1216ME_MK3:
                case TUNER_PHILIPS_FM1236_MK3:
                case TUNER_PHILIPS_FM1256_IH3:
                case TUNER_LG_NTSC_TAPE:
-                       stereo = ((status & TUNER_SIGNAL) == TUNER_STEREO_MK3);
-                       break;
+                       return ((status & TUNER_SIGNAL) == TUNER_STEREO_MK3);
                default:
-                       stereo = status & TUNER_STEREO;
+                       return status & TUNER_STEREO;
        }
+}
 
-       return stereo;
+static inline int tuner_islocked(const int status)
+{
+       return (status & TUNER_FL);
+}
+
+static inline int tuner_afcstatus(const int status)
+{
+       return (status & TUNER_AFC) - 2;
 }
 
 
 static int simple_get_status(struct dvb_frontend *fe, u32 *status)
 {
        struct tuner_simple_priv *priv = fe->tuner_priv;
-       int signal = tuner_signal(fe);
+       int tuner_status = tuner_read_status(fe);
 
        *status = 0;
 
-       if (signal)
+       if (tuner_islocked(tuner_status))
                *status = TUNER_STATUS_LOCKED;
-       if (tuner_stereo(fe))
+       if (tuner_stereo(priv->type, tuner_status))
                *status |= TUNER_STATUS_STEREO;
 
-       tuner_dbg("tuner-simple: Signal strength: %d\n", signal);
+       tuner_dbg("AFC Status: %d\n", tuner_afcstatus(tuner_status));
+
+       return 0;
+}
+
+static int simple_get_rf_strength(struct dvb_frontend *fe, u16 *strength)
+{
+       struct tuner_simple_priv *priv = fe->tuner_priv;
+       int signal = tuner_signal(tuner_read_status(fe));
+
+       *strength = signal;
+
+       tuner_dbg("Signal strength: %d\n", signal);
 
        return 0;
 }
@@ -580,9 +593,10 @@ static int simple_get_frequency(struct dvb_frontend *fe, 
u32 *frequency)
 
 static struct dvb_tuner_ops simple_tuner_ops = {
        .set_analog_params = simple_set_params,
-       .release        = simple_release,
-       .get_frequency  = simple_get_frequency,
-       .get_status     = simple_get_status,
+       .release           = simple_release,
+       .get_frequency     = simple_get_frequency,
+       .get_status        = simple_get_status,
+       .get_rf_strength   = simple_get_rf_strength,
 };
 
 struct dvb_frontend *simple_tuner_attach(struct dvb_frontend *fe,
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to