[media] tuner-core: don't set has_signal/get_afc if not supported
authorHans Verkuil <hans.verkuil@cisco.com>
Mon, 25 Mar 2013 11:14:13 +0000 (08:14 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 25 Mar 2013 18:10:39 +0000 (15:10 -0300)
If the tuner frontend does not support get_rf_strength, then don't set
the has_signal callback. Ditto for get_afc.
Both callbacks overwrite the signal and afc fields of struct v4l2_tuner
but that should only happen if the tuner can actually detect this. If
it can't, then it should leave those fields alone so other subdevices
can try and detect the signal/afc.
This fixes the bug where the au8522 detected a signal and then tuner-core
overwrote it with 0 since the xc5000 tuner does not support get_rf_strength.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/v4l2-core/tuner-core.c

index f775768d088d40822e940dec45cfe735e7cb5e5d..dd8a803fb111740ed34e075f2e1efe4981d7b67c 100644 (file)
@@ -253,7 +253,7 @@ static int fe_set_config(struct dvb_frontend *fe, void *priv_cfg)
 
 static void tuner_status(struct dvb_frontend *fe);
 
-static struct analog_demod_ops tuner_analog_ops = {
+static const struct analog_demod_ops tuner_analog_ops = {
        .set_params     = fe_set_params,
        .standby        = fe_standby,
        .has_signal     = fe_has_signal,
@@ -453,6 +453,11 @@ static void set_type(struct i2c_client *c, unsigned int type,
                memcpy(analog_ops, &tuner_analog_ops,
                       sizeof(struct analog_demod_ops));
 
+               if (fe_tuner_ops->get_rf_strength == NULL)
+                       analog_ops->has_signal = NULL;
+               if (fe_tuner_ops->get_afc == NULL)
+                       analog_ops->get_afc = NULL;
+
        } else {
                t->name = analog_ops->info.name;
        }