The patch number 10876 was added via Michael Krufky <[email protected]>
to http://linuxtv.org/hg/v4l-dvb master development tree.

Kernel patches in this development tree may be modified to be backward
compatible with older kernels. Compatibility modifications will be
removed before inclusion into the mainstream Kernel

If anyone has any objections, please let us know by sending a message to:
        Linux Media Mailing List <[email protected]>

------

From: Michael Krufky  <[email protected]>
tda18271: add support for AGC configuration via tuner callback


The tda827x driver supports a feature that the tda18271 driver was lacking
until now.  This patch adds support for device-level configuration via the
tuner callback configuration interface.

Priority: normal

Signed-off-by: Michael Krufky <[email protected]>


---

 linux/drivers/media/common/tuners/tda18271-fe.c   |   37 ++++++++++++++
 linux/drivers/media/common/tuners/tda18271-priv.h |    6 --
 linux/drivers/media/common/tuners/tda18271.h      |   10 +++
 linux/drivers/media/common/tuners/tda8290.c       |    1 
 4 files changed, 49 insertions(+), 5 deletions(-)

diff -r 91f9c6c451f7 -r 9090626b8464 
linux/drivers/media/common/tuners/tda18271-fe.c
--- a/linux/drivers/media/common/tuners/tda18271-fe.c   Mon Mar 02 09:39:13 
2009 -0300
+++ b/linux/drivers/media/common/tuners/tda18271-fe.c   Wed Mar 04 17:42:06 
2009 -0500
@@ -819,6 +819,38 @@ fail:
        return ret;
 }
 
+/* ------------------------------------------------------------------ */
+
+static int tda18271_agc(struct dvb_frontend *fe)
+{
+       struct tda18271_priv *priv = fe->tuner_priv;
+       int ret = 0;
+
+       switch (priv->config) {
+       case 0:
+               /* no LNA */
+               tda_dbg("no agc configuration provided\n");
+               break;
+       case 3:
+               /* switch with GPIO of saa713x */
+               tda_dbg("invoking callback\n");
+               if (fe->callback)
+                       ret = fe->callback(priv->i2c_props.adap->algo_data,
+                                          DVB_FRONTEND_COMPONENT_TUNER,
+                                          TDA18271_CALLBACK_CMD_AGC_ENABLE,
+                                          priv->mode);
+               break;
+       case 1:
+       case 2:
+       default:
+               /* n/a - currently not supported */
+               tda_err("unsupported configuration: %d\n", priv->config);
+               ret = -EINVAL;
+               break;
+       }
+       return ret;
+}
+
 static int tda18271_tune(struct dvb_frontend *fe,
                         struct tda18271_std_map_item *map, u32 freq, u32 bw)
 {
@@ -827,6 +859,10 @@ static int tda18271_tune(struct dvb_fron
 
        tda_dbg("freq = %d, ifc = %d, bw = %d, agc_mode = %d, std = %d\n",
                freq, map->if_freq, bw, map->agc_mode, map->std);
+
+       ret = tda18271_agc(fe);
+       if (tda_fail(ret))
+               tda_warn("failed to configure agc\n");
 
        ret = tda18271_init(fe);
        if (tda_fail(ret))
@@ -1160,6 +1196,7 @@ struct dvb_frontend *tda18271_attach(str
                /* new tuner instance */
                priv->gate = (cfg) ? cfg->gate : TDA18271_GATE_AUTO;
                priv->role = (cfg) ? cfg->role : TDA18271_MASTER;
+               priv->config = (cfg) ? cfg->config : 0;
                priv->cal_initialized = false;
                mutex_init(&priv->lock);
 
diff -r 91f9c6c451f7 -r 9090626b8464 
linux/drivers/media/common/tuners/tda18271-priv.h
--- a/linux/drivers/media/common/tuners/tda18271-priv.h Mon Mar 02 09:39:13 
2009 -0300
+++ b/linux/drivers/media/common/tuners/tda18271-priv.h Wed Mar 04 17:42:06 
2009 -0500
@@ -92,11 +92,6 @@ enum tda18271_pll {
        TDA18271_CAL_PLL,
 };
 
-enum tda18271_mode {
-       TDA18271_ANALOG,
-       TDA18271_DIGITAL,
-};
-
 struct tda18271_map_layout;
 
 enum tda18271_ver {
@@ -115,6 +110,7 @@ struct tda18271_priv {
        enum tda18271_i2c_gate gate;
        enum tda18271_ver id;
 
+       unsigned int config; /* interface to saa713x / tda829x */
        unsigned int tm_rfcal;
        unsigned int cal_initialized:1;
        unsigned int small_i2c:1;
diff -r 91f9c6c451f7 -r 9090626b8464 
linux/drivers/media/common/tuners/tda18271.h
--- a/linux/drivers/media/common/tuners/tda18271.h      Mon Mar 02 09:39:13 
2009 -0300
+++ b/linux/drivers/media/common/tuners/tda18271.h      Wed Mar 04 17:42:06 
2009 -0500
@@ -79,6 +79,16 @@ struct tda18271_config {
 
        /* some i2c providers cant write all 39 registers at once */
        unsigned int small_i2c:1;
+
+       /* interface to saa713x / tda829x */
+       unsigned int config;
+};
+
+#define TDA18271_CALLBACK_CMD_AGC_ENABLE 0
+
+enum tda18271_mode {
+       TDA18271_ANALOG = 0,
+       TDA18271_DIGITAL,
 };
 
 #if defined(CONFIG_MEDIA_TUNER_TDA18271) || 
(defined(CONFIG_MEDIA_TUNER_TDA18271_MODULE) && defined(MODULE))
diff -r 91f9c6c451f7 -r 9090626b8464 linux/drivers/media/common/tuners/tda8290.c
--- a/linux/drivers/media/common/tuners/tda8290.c       Mon Mar 02 09:39:13 
2009 -0300
+++ b/linux/drivers/media/common/tuners/tda8290.c       Wed Mar 04 17:42:06 
2009 -0500
@@ -647,6 +647,7 @@ static int tda829x_find_tuner(struct dvb
 
        if ((data == 0x83) || (data == 0x84)) {
                priv->ver |= TDA18271;
+               tda829x_tda18271_config.config = priv->cfg.config;
                dvb_attach(tda18271_attach, fe, priv->tda827x_addr,
                           priv->i2c_props.adap, &tda829x_tda18271_config);
        } else {


---

Patch is available at: 
http://linuxtv.org/hg/v4l-dvb/rev/9090626b8464d283f690dfaef8ae57b37ec11bc9

_______________________________________________
linuxtv-commits mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to