[media] tda8290: change magic LNA config values to enum
authorOndrej Zary <linux@rainbow-software.org>
Sat, 6 Apr 2013 17:29:29 +0000 (14:29 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 8 Apr 2013 10:05:15 +0000 (07:05 -0300)
Use enum instead of magic values for LNA config in tda8290.
Update tda827x, tda18271 and saa7134 to use the enum too.

Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/pci/saa7134/saa7134-cards.c
drivers/media/tuners/tda18271-fe.c
drivers/media/tuners/tda827x.c
drivers/media/tuners/tda827x.h
drivers/media/tuners/tda8290.c
drivers/media/tuners/tda8290.h

index 67e06e178e98ba2a28c7d7277cec381ed609e259..d45e7f6ff332203785171a3aa6c915ac0e1a9950 100644 (file)
@@ -2765,7 +2765,7 @@ struct saa7134_board saa7134_boards[] = {
                .radio_type     = UNSET,
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
-               .tda829x_conf   = { .lna_cfg = 0 },
+               .tda829x_conf   = { .lna_cfg = TDA8290_LNA_OFF },
                .mpeg           = SAA7134_MPEG_DVB,
                .gpiomask       = 0x0200000,
                .inputs = {{
@@ -3296,7 +3296,7 @@ struct saa7134_board saa7134_boards[] = {
                .radio_type     = UNSET,
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
-               .tda829x_conf   = { .lna_cfg = 1 },
+               .tda829x_conf   = { .lna_cfg = TDA8290_LNA_GP0_HIGH_ON },
                .mpeg           = SAA7134_MPEG_DVB,
                .gpiomask       = 0x000200000,
                .inputs         = {{
@@ -3400,7 +3400,7 @@ struct saa7134_board saa7134_boards[] = {
                .radio_type     = UNSET,
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
-               .tda829x_conf   = { .lna_cfg = 1 },
+               .tda829x_conf   = { .lna_cfg = TDA8290_LNA_GP0_HIGH_ON },
                .mpeg           = SAA7134_MPEG_DVB,
                .gpiomask       = 0x0200100,
                .inputs         = {{
@@ -3431,7 +3431,7 @@ struct saa7134_board saa7134_boards[] = {
                .radio_type     = UNSET,
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
-               .tda829x_conf   = { .lna_cfg = 3 },
+               .tda829x_conf   = { .lna_cfg = TDA8290_LNA_ON_BRIDGE },
                .mpeg           = SAA7134_MPEG_DVB,
                .ts_type        = SAA7134_MPEG_TS_SERIAL,
                .ts_force_val   = 1,
@@ -3464,7 +3464,7 @@ struct saa7134_board saa7134_boards[] = {
                .radio_type     = UNSET,
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
-               .tda829x_conf   = { .lna_cfg = 3 },
+               .tda829x_conf   = { .lna_cfg = TDA8290_LNA_ON_BRIDGE },
                .mpeg           = SAA7134_MPEG_DVB,
                .ts_type        = SAA7134_MPEG_TS_SERIAL,
                .gpiomask       = 0x0800100, /* GPIO 21 is an INPUT */
@@ -3688,7 +3688,7 @@ struct saa7134_board saa7134_boards[] = {
                .radio_type     = UNSET,
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
-               .tda829x_conf   = { .lna_cfg = 2 },
+               .tda829x_conf   = { .lna_cfg = TDA8290_LNA_GP0_HIGH_OFF },
                .mpeg           = SAA7134_MPEG_DVB,
                .gpiomask       = 0x0200000,
                .inputs = {{
@@ -3741,7 +3741,7 @@ struct saa7134_board saa7134_boards[] = {
                .radio_type     = UNSET,
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
-               .tda829x_conf   = { .lna_cfg = 2 },
+               .tda829x_conf   = { .lna_cfg = TDA8290_LNA_GP0_HIGH_OFF },
                .mpeg           = SAA7134_MPEG_DVB,
                .gpiomask       = 0x0200000,
                .inputs = {{
@@ -3759,7 +3759,7 @@ struct saa7134_board saa7134_boards[] = {
                .radio_type     = UNSET,
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
-               .tda829x_conf   = { .lna_cfg = 2 },
+               .tda829x_conf   = { .lna_cfg = TDA8290_LNA_GP0_HIGH_OFF },
                .gpiomask       = 1 << 21,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs         = {{
@@ -3892,7 +3892,7 @@ struct saa7134_board saa7134_boards[] = {
                .radio_type     = UNSET,
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
-               .tda829x_conf   = { .lna_cfg = 0 },
+               .tda829x_conf   = { .lna_cfg = TDA8290_LNA_OFF },
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs = {{
                        .name   = name_tv, /* FIXME: analog tv untested */
@@ -3908,7 +3908,7 @@ struct saa7134_board saa7134_boards[] = {
                .radio_type     = UNSET,
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
-               .tda829x_conf   = { .lna_cfg = 2 },
+               .tda829x_conf   = { .lna_cfg = TDA8290_LNA_GP0_HIGH_OFF },
                .gpiomask       = 0x020200000,
                .inputs         = {{
                        .name = name_tv,
@@ -3942,7 +3942,7 @@ struct saa7134_board saa7134_boards[] = {
                .radio_type     = UNSET,
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
-               .tda829x_conf   = { .lna_cfg = 0 },
+               .tda829x_conf   = { .lna_cfg = TDA8290_LNA_OFF },
                .gpiomask       = 0x020200000,
                .inputs         = {{
                        .name = name_tv,
@@ -4742,7 +4742,7 @@ struct saa7134_board saa7134_boards[] = {
                .radio_type     = UNSET,
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
-               .tda829x_conf   = { .lna_cfg = 2 },
+               .tda829x_conf   = { .lna_cfg = TDA8290_LNA_GP0_HIGH_OFF },
                .mpeg           = SAA7134_MPEG_DVB,
                .gpiomask       = 0x0200000,
                .inputs = {{
@@ -4828,7 +4828,7 @@ struct saa7134_board saa7134_boards[] = {
                .radio_type   = UNSET,
                .tuner_addr   = ADDR_UNSET,
                .radio_addr   = ADDR_UNSET,
-               .tda829x_conf = { .lna_cfg = 0 },
+               .tda829x_conf = { .lna_cfg = TDA8290_LNA_OFF },
                .mpeg         = SAA7134_MPEG_DVB,
                .inputs       = {{
                        .name = name_tv,
@@ -4852,7 +4852,7 @@ struct saa7134_board saa7134_boards[] = {
                .radio_type     = UNSET,
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
-               .tda829x_conf   = { .lna_cfg = 2 },
+               .tda829x_conf   = { .lna_cfg = TDA8290_LNA_GP0_HIGH_OFF },
                .mpeg           = SAA7134_MPEG_DVB,
                .gpiomask       = 0x0200000,
                .inputs = { {
@@ -5062,7 +5062,7 @@ struct saa7134_board saa7134_boards[] = {
                .radio_type     = UNSET,
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
-               .tda829x_conf   = { .lna_cfg = 2 },
+               .tda829x_conf   = { .lna_cfg = TDA8290_LNA_GP0_HIGH_OFF },
                .gpiomask       = 1 << 21,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs         = {{
@@ -5092,7 +5092,7 @@ struct saa7134_board saa7134_boards[] = {
                .radio_type     = UNSET,
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
-               .tda829x_conf   = { .lna_cfg = 2 },
+               .tda829x_conf   = { .lna_cfg = TDA8290_LNA_GP0_HIGH_OFF },
                .gpiomask       = 1 << 21,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs         = {{
@@ -5181,7 +5181,7 @@ struct saa7134_board saa7134_boards[] = {
                .radio_type     = UNSET,
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
-               .tda829x_conf   = { .lna_cfg = 0 },
+               .tda829x_conf   = { .lna_cfg = TDA8290_LNA_OFF },
                .mpeg           = SAA7134_MPEG_DVB,
                .gpiomask       = 0x0200000,
                .inputs = { {
@@ -5411,7 +5411,7 @@ struct saa7134_board saa7134_boards[] = {
                .radio_type     = UNSET,
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
-               .tda829x_conf   = { .lna_cfg = 0 },
+               .tda829x_conf   = { .lna_cfg = TDA8290_LNA_OFF },
                .mpeg           = SAA7134_MPEG_DVB,
                .ts_type        = SAA7134_MPEG_TS_PARALLEL,
                .inputs         = {{
@@ -5634,7 +5634,7 @@ struct saa7134_board saa7134_boards[] = {
                .audio_clock    = 0x00187de7,
                .tuner_type     = TUNER_PHILIPS_TDA8290,
                .radio_type     = UNSET,
-               .tda829x_conf   = { .lna_cfg = 3 },
+               .tda829x_conf   = { .lna_cfg = TDA8290_LNA_ON_BRIDGE },
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
                .gpiomask       = 0x02050000,
@@ -5802,7 +5802,8 @@ struct saa7134_board saa7134_boards[] = {
                .radio_type     = UNSET,
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
-               .tda829x_conf   = { .lna_cfg = 0, .no_i2c_gate = 1,
+               .tda829x_conf   = { .lna_cfg = TDA8290_LNA_OFF,
+                                   .no_i2c_gate = 1,
                                    .tda18271_std_map = &aver_a706_std_map },
                .gpiomask       = 1 << 11,
                .mpeg           = SAA7134_MPEG_DVB,
index e7786862dab2e4af7775bec7b8197d794ec094d8..4995b890c164cf2078e0c92558dc524777f57243 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/delay.h>
 #include <linux/videodev2.h>
 #include "tda18271-priv.h"
+#include "tda8290.h"
 
 int tda18271_debug;
 module_param_named(debug, tda18271_debug, int, 0644);
@@ -867,12 +868,12 @@ static int tda18271_agc(struct dvb_frontend *fe)
        int ret = 0;
 
        switch (priv->config) {
-       case 0:
+       case TDA8290_LNA_OFF:
                /* no external agc configuration required */
                if (tda18271_debug & DBG_ADV)
                        tda_dbg("no agc configuration provided\n");
                break;
-       case 3:
+       case TDA8290_LNA_ON_BRIDGE:
                /* switch with GPIO of saa713x */
                tda_dbg("invoking callback\n");
                if (fe->callback)
@@ -881,8 +882,8 @@ static int tda18271_agc(struct dvb_frontend *fe)
                                           TDA18271_CALLBACK_CMD_AGC_ENABLE,
                                           priv->mode);
                break;
-       case 1:
-       case 2:
+       case TDA8290_LNA_GP0_HIGH_ON:
+       case TDA8290_LNA_GP0_HIGH_OFF:
        default:
                /* n/a - currently not supported */
                tda_err("unsupported configuration: %d\n", priv->config);
index a0d17626747096b081d81add3ed5e072d964fd60..73453a255cdcc2c565e84b92559cff58d207d1b8 100644 (file)
@@ -479,10 +479,10 @@ static void tda827xa_lna_gain(struct dvb_frontend *fe, int high,
                        dprintk("setting LNA to low gain\n");
        }
        switch (priv->cfg->config) {
-       case 0: /* no LNA */
+       case TDA8290_LNA_OFF: /* no LNA */
                break;
-       case 1: /* switch is GPIO 0 of tda8290 */
-       case 2:
+       case TDA8290_LNA_GP0_HIGH_ON: /* switch is GPIO 0 of tda8290 */
+       case TDA8290_LNA_GP0_HIGH_OFF:
                if (params == NULL) {
                        gp_func = 0;
                        arg  = 0;
@@ -499,11 +499,11 @@ static void tda827xa_lna_gain(struct dvb_frontend *fe, int high,
                                     DVB_FRONTEND_COMPONENT_TUNER,
                                     gp_func, arg);
                buf[1] = high ? 0 : 1;
-               if (priv->cfg->config == 2)
+               if (priv->cfg->config == TDA8290_LNA_GP0_HIGH_OFF)
                        buf[1] = high ? 1 : 0;
                tuner_transfer(fe, &msg, 1);
                break;
-       case 3: /* switch with GPIO of saa713x */
+       case TDA8290_LNA_ON_BRIDGE: /* switch with GPIO of saa713x */
                if (fe->callback)
                        fe->callback(priv->i2c_adap->algo_data,
                                     DVB_FRONTEND_COMPONENT_TUNER, 0, high);
index 9432b5b6121bcc4c5fd5ffade153be5c1628d1dc..b64292152baf535831e0ce77902308f13a6dedb7 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <linux/i2c.h>
 #include "dvb_frontend.h"
+#include "tda8290.h"
 
 struct tda827x_config
 {
@@ -34,7 +35,7 @@ struct tda827x_config
        int (*sleep) (struct dvb_frontend *fe);
 
        /* interface to tda829x driver */
-       unsigned int config;
+       enum tda8290_lna config;
        int          switch_addr;
 
        void (*agcf)(struct dvb_frontend *fe);
index c1ade88d1fa820fbcb528b7f524f8e4253f4238c..20cc7dad6b4e8f5de0e04ac75e0680ebc11640f2 100644 (file)
@@ -496,7 +496,8 @@ static void tda8290_init_if(struct dvb_frontend *fe)
        unsigned char set_GP00_CF[] = { 0x20, 0x01 };
        unsigned char set_GP01_CF[] = { 0x20, 0x0B };
 
-       if ((priv->cfg.config == 1) || (priv->cfg.config == 2))
+       if ((priv->cfg.config == TDA8290_LNA_GP0_HIGH_ON) ||
+           (priv->cfg.config == TDA8290_LNA_GP0_HIGH_OFF))
                tuner_i2c_xfer_send(&priv->i2c_props, set_GP00_CF, 2);
        else
                tuner_i2c_xfer_send(&priv->i2c_props, set_GP01_CF, 2);
index 97f1d0f848ef9280922770ce517958323f6940ec..cf96e585785e37bae9ebe15f5feecb75c240eb22 100644 (file)
 #include "dvb_frontend.h"
 #include "tda18271.h"
 
+enum tda8290_lna {
+       TDA8290_LNA_OFF = 0,
+       TDA8290_LNA_GP0_HIGH_ON = 1,
+       TDA8290_LNA_GP0_HIGH_OFF = 2,
+       TDA8290_LNA_ON_BRIDGE = 3,
+};
+
 struct tda829x_config {
-       unsigned int lna_cfg;
+       enum tda8290_lna lna_cfg;
 
        unsigned int probe_tuner:1;
 #define TDA829X_PROBE_TUNER 0