]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/media/common/tuners/tda18271-fe.c
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4
[mv-sheeva.git] / drivers / media / common / tuners / tda18271-fe.c
index ecb65802725fd0131f5bc82d3170498f0735ff21..b2e15456d5f36600c32c78542c42d7188634071a 100644 (file)
@@ -1185,10 +1185,10 @@ static int tda18271_get_id(struct dvb_frontend *fe)
        return ret;
 }
 
-static int tda18271_set_config(struct dvb_frontend *fe, void *priv_cfg)
+static int tda18271_setup_configuration(struct dvb_frontend *fe,
+                                       struct tda18271_config *cfg)
 {
        struct tda18271_priv *priv = fe->tuner_priv;
-       struct tda18271_config *cfg = (struct tda18271_config *) priv_cfg;
 
        priv->gate = (cfg) ? cfg->gate : TDA18271_GATE_AUTO;
        priv->role = (cfg) ? cfg->role : TDA18271_MASTER;
@@ -1198,6 +1198,28 @@ static int tda18271_set_config(struct dvb_frontend *fe, void *priv_cfg)
        priv->output_opt = (cfg) ?
                cfg->output_opt : TDA18271_OUTPUT_LT_XT_ON;
 
+       return 0;
+}
+
+static inline int tda18271_need_cal_on_startup(struct tda18271_config *cfg)
+{
+       /* tda18271_cal_on_startup == -1 when cal module option is unset */
+       return ((tda18271_cal_on_startup == -1) ?
+               /* honor configuration setting */
+               ((cfg) && (cfg->rf_cal_on_startup)) :
+               /* module option overrides configuration setting */
+               (tda18271_cal_on_startup)) ? 1 : 0;
+}
+
+static int tda18271_set_config(struct dvb_frontend *fe, void *priv_cfg)
+{
+       struct tda18271_config *cfg = (struct tda18271_config *) priv_cfg;
+
+       tda18271_setup_configuration(fe, cfg);
+
+       if (tda18271_need_cal_on_startup(cfg))
+               tda18271_init(fe);
+
        /* override default std map with values in config struct */
        if ((cfg) && (cfg->std_map))
                tda18271_update_std_map(fe, cfg->std_map);
@@ -1238,24 +1260,10 @@ struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr,
        case 0:
                goto fail;
        case 1:
-       {
                /* new tuner instance */
-               int rf_cal_on_startup;
-
                fe->tuner_priv = priv;
 
-               tda18271_set_config(fe, cfg);
-
-               /* tda18271_cal_on_startup == -1 when cal
-                * module option is unset */
-               if (tda18271_cal_on_startup == -1) {
-                       /* honor attach-time configuration */
-                       rf_cal_on_startup =
-                               ((cfg) && (cfg->rf_cal_on_startup)) ? 1 : 0;
-               } else {
-                       /* module option overrides attach configuration */
-                       rf_cal_on_startup = tda18271_cal_on_startup;
-               }
+               tda18271_setup_configuration(fe, cfg);
 
                priv->cal_initialized = false;
                mutex_init(&priv->lock);
@@ -1269,12 +1277,12 @@ struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr,
                mutex_lock(&priv->lock);
                tda18271_init_regs(fe);
 
-               if ((rf_cal_on_startup) && (priv->id == TDA18271HDC2))
+               if ((tda18271_need_cal_on_startup(cfg)) &&
+                   (priv->id == TDA18271HDC2))
                        tda18271c2_rf_cal_init(fe);
 
                mutex_unlock(&priv->lock);
                break;
-       }
        default:
                /* existing tuner instance */
                fe->tuner_priv = priv;
@@ -1294,9 +1302,15 @@ struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr,
                        if (cfg->std_map)
                                tda18271_update_std_map(fe, cfg->std_map);
                }
+               if (tda18271_need_cal_on_startup(cfg))
+                       tda18271_init(fe);
                break;
        }
 
+       /* override default std map with values in config struct */
+       if ((cfg) && (cfg->std_map))
+               tda18271_update_std_map(fe, cfg->std_map);
+
        mutex_unlock(&tda18271_list_mutex);
 
        memcpy(&fe->ops.tuner_ops, &tda18271_tuner_ops,
@@ -1316,7 +1330,7 @@ EXPORT_SYMBOL_GPL(tda18271_attach);
 MODULE_DESCRIPTION("NXP TDA18271HD analog / digital tuner driver");
 MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>");
 MODULE_LICENSE("GPL");
-MODULE_VERSION("0.3");
+MODULE_VERSION("0.4");
 
 /*
  * Overrides for Emacs so that we follow Linus's tabbing style.