[media] dvb-frontends/cxd2841er: make ASCOT use optional
authorDaniel Scheller <d.scheller@gmx.net>
Sun, 9 Apr 2017 19:38:19 +0000 (16:38 -0300)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Tue, 20 Jun 2017 12:50:06 +0000 (09:50 -0300)
The Sony CXD28xx demods may have other tuner types attached to them (e.g.
NXP TDA18212), so don't mandatorily configure and enable the ASCOT
functionality, but make this conditional by a config flag.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Acked-by: Abylay Ospan <aospan@netup.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/dvb-frontends/cxd2841er.c
drivers/media/dvb-frontends/cxd2841er.h
drivers/media/pci/netup_unidvb/netup_unidvb_core.c

index 52813625a62514b6a2e3d26d84668dfea503cf95..3644a32772323cd0a2902c9f30bd706de7c58cf7 100644 (file)
@@ -2277,7 +2277,8 @@ static int cxd2841er_sleep_tc_to_active_t2_band(struct cxd2841er_priv *priv,
                /* Group delay equaliser settings for
                 * ASCOT2D, ASCOT2E and ASCOT3 tuners
                 */
-               cxd2841er_write_regs(priv, I2C_SLVT,
+               if (priv->flags & CXD2841ER_ASCOT)
+                       cxd2841er_write_regs(priv, I2C_SLVT,
                                0xA6, itbCoef8bw[priv->xtal], 14);
                /* <IF freq setting> */
                ifhz = cxd2841er_get_if_hz(priv, 4800000);
@@ -2306,7 +2307,8 @@ static int cxd2841er_sleep_tc_to_active_t2_band(struct cxd2841er_priv *priv,
                /* Group delay equaliser settings for
                 * ASCOT2D, ASCOT2E and ASCOT3 tuners
                 */
-               cxd2841er_write_regs(priv, I2C_SLVT,
+               if (priv->flags & CXD2841ER_ASCOT)
+                       cxd2841er_write_regs(priv, I2C_SLVT,
                                0xA6, itbCoef7bw[priv->xtal], 14);
                /* <IF freq setting> */
                ifhz = cxd2841er_get_if_hz(priv, 4200000);
@@ -2335,7 +2337,8 @@ static int cxd2841er_sleep_tc_to_active_t2_band(struct cxd2841er_priv *priv,
                /* Group delay equaliser settings for
                 * ASCOT2D, ASCOT2E and ASCOT3 tuners
                 */
-               cxd2841er_write_regs(priv, I2C_SLVT,
+               if (priv->flags & CXD2841ER_ASCOT)
+                       cxd2841er_write_regs(priv, I2C_SLVT,
                                0xA6, itbCoef6bw[priv->xtal], 14);
                /* <IF freq setting> */
                ifhz = cxd2841er_get_if_hz(priv, 3600000);
@@ -2364,7 +2367,8 @@ static int cxd2841er_sleep_tc_to_active_t2_band(struct cxd2841er_priv *priv,
                /* Group delay equaliser settings for
                 * ASCOT2D, ASCOT2E and ASCOT3 tuners
                 */
-               cxd2841er_write_regs(priv, I2C_SLVT,
+               if (priv->flags & CXD2841ER_ASCOT)
+                       cxd2841er_write_regs(priv, I2C_SLVT,
                                0xA6, itbCoef5bw[priv->xtal], 14);
                /* <IF freq setting> */
                ifhz = cxd2841er_get_if_hz(priv, 3600000);
@@ -2393,7 +2397,8 @@ static int cxd2841er_sleep_tc_to_active_t2_band(struct cxd2841er_priv *priv,
                /* Group delay equaliser settings for
                 * ASCOT2D, ASCOT2E and ASCOT3 tuners
                 */
-               cxd2841er_write_regs(priv, I2C_SLVT,
+               if (priv->flags & CXD2841ER_ASCOT)
+                       cxd2841er_write_regs(priv, I2C_SLVT,
                                0xA6, itbCoef17bw[priv->xtal], 14);
                /* <IF freq setting> */
                ifhz = cxd2841er_get_if_hz(priv, 3500000);
@@ -2493,7 +2498,8 @@ static int cxd2841er_sleep_tc_to_active_t_band(
                /* Group delay equaliser settings for
                 * ASCOT2D, ASCOT2E and ASCOT3 tuners
                */
-               cxd2841er_write_regs(priv, I2C_SLVT,
+               if (priv->flags & CXD2841ER_ASCOT)
+                       cxd2841er_write_regs(priv, I2C_SLVT,
                                0xA6, itbCoef8bw[priv->xtal], 14);
                /* <IF freq setting> */
                ifhz = cxd2841er_get_if_hz(priv, 4800000);
@@ -2529,7 +2535,8 @@ static int cxd2841er_sleep_tc_to_active_t_band(
                /* Group delay equaliser settings for
                 * ASCOT2D, ASCOT2E and ASCOT3 tuners
                */
-               cxd2841er_write_regs(priv, I2C_SLVT,
+               if (priv->flags & CXD2841ER_ASCOT)
+                       cxd2841er_write_regs(priv, I2C_SLVT,
                                0xA6, itbCoef7bw[priv->xtal], 14);
                /* <IF freq setting> */
                ifhz = cxd2841er_get_if_hz(priv, 4200000);
@@ -2565,7 +2572,8 @@ static int cxd2841er_sleep_tc_to_active_t_band(
                /* Group delay equaliser settings for
                 * ASCOT2D, ASCOT2E and ASCOT3 tuners
                */
-               cxd2841er_write_regs(priv, I2C_SLVT,
+               if (priv->flags & CXD2841ER_ASCOT)
+                       cxd2841er_write_regs(priv, I2C_SLVT,
                                0xA6, itbCoef6bw[priv->xtal], 14);
                /* <IF freq setting> */
                ifhz = cxd2841er_get_if_hz(priv, 3600000);
@@ -2601,7 +2609,8 @@ static int cxd2841er_sleep_tc_to_active_t_band(
                /* Group delay equaliser settings for
                 * ASCOT2D, ASCOT2E and ASCOT3 tuners
                */
-               cxd2841er_write_regs(priv, I2C_SLVT,
+               if (priv->flags & CXD2841ER_ASCOT)
+                       cxd2841er_write_regs(priv, I2C_SLVT,
                                0xA6, itbCoef5bw[priv->xtal], 14);
                /* <IF freq setting> */
                ifhz = cxd2841er_get_if_hz(priv, 3600000);
@@ -2703,7 +2712,8 @@ static int cxd2841er_sleep_tc_to_active_i_band(
                cxd2841er_write_regs(priv, I2C_SLVT,
                                0x9F, nominalRate8bw[priv->xtal], 5);
                /*  Group delay equaliser settings for ASCOT tuners optimized */
-               cxd2841er_write_regs(priv, I2C_SLVT,
+               if (priv->flags & CXD2841ER_ASCOT)
+                       cxd2841er_write_regs(priv, I2C_SLVT,
                                0xA6, itbCoef8bw[priv->xtal], 14);
 
                /* IF freq setting */
@@ -2733,7 +2743,8 @@ static int cxd2841er_sleep_tc_to_active_i_band(
                cxd2841er_write_regs(priv, I2C_SLVT,
                                0x9F, nominalRate7bw[priv->xtal], 5);
                /*  Group delay equaliser settings for ASCOT tuners optimized */
-               cxd2841er_write_regs(priv, I2C_SLVT,
+               if (priv->flags & CXD2841ER_ASCOT)
+                       cxd2841er_write_regs(priv, I2C_SLVT,
                                0xA6, itbCoef7bw[priv->xtal], 14);
 
                /* IF freq setting */
@@ -2763,7 +2774,8 @@ static int cxd2841er_sleep_tc_to_active_i_band(
                cxd2841er_write_regs(priv, I2C_SLVT,
                                0x9F, nominalRate6bw[priv->xtal], 5);
                /*  Group delay equaliser settings for ASCOT tuners optimized */
-               cxd2841er_write_regs(priv, I2C_SLVT,
+               if (priv->flags & CXD2841ER_ASCOT)
+                       cxd2841er_write_regs(priv, I2C_SLVT,
                                0xA6, itbCoef6bw[priv->xtal], 14);
 
                /* IF freq setting */
@@ -2826,16 +2838,18 @@ static int cxd2841er_sleep_tc_to_active_c_band(struct cxd2841er_priv *priv,
        switch (bandwidth) {
        case 8000000:
        case 7000000:
-               cxd2841er_write_regs(
-                       priv, I2C_SLVT, 0xa6,
-                       bw7_8mhz_b10_a6, sizeof(bw7_8mhz_b10_a6));
+               if (priv->flags & CXD2841ER_ASCOT)
+                       cxd2841er_write_regs(
+                               priv, I2C_SLVT, 0xa6,
+                               bw7_8mhz_b10_a6, sizeof(bw7_8mhz_b10_a6));
                ifhz = cxd2841er_get_if_hz(priv, 4900000);
                iffreq = cxd2841er_calc_iffreq(ifhz);
                break;
        case 6000000:
-               cxd2841er_write_regs(
-                       priv, I2C_SLVT, 0xa6,
-                       bw6mhz_b10_a6, sizeof(bw6mhz_b10_a6));
+               if (priv->flags & CXD2841ER_ASCOT)
+                       cxd2841er_write_regs(
+                               priv, I2C_SLVT, 0xa6,
+                               bw6mhz_b10_a6, sizeof(bw6mhz_b10_a6));
                ifhz = cxd2841er_get_if_hz(priv, 3700000);
                iffreq = cxd2841er_calc_iffreq(ifhz);
                break;
@@ -2924,8 +2938,9 @@ static int cxd2841er_sleep_tc_to_active_t(struct cxd2841er_priv *priv,
        cxd2841er_write_reg(priv, I2C_SLVT, 0x6a, 0x50);
        /* Set SLV-T Bank : 0x10 */
        cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x10);
-       /* ASCOT setting ON */
-       cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xa5, 0x01, 0x01);
+       /* ASCOT setting */
+       cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xa5,
+               ((priv->flags & CXD2841ER_ASCOT) ? 0x01 : 0x00), 0x01);
        /* Set SLV-T Bank : 0x18 */
        cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x18);
        /* Pre-RS BER moniter setting */
@@ -3002,8 +3017,9 @@ static int cxd2841er_sleep_tc_to_active_t2(struct cxd2841er_priv *priv,
        cxd2841er_write_reg(priv, I2C_SLVT, 0x6a, 0x50);
        /* Set SLV-T Bank : 0x10 */
        cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x10);
-       /* ASCOT setting ON */
-       cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xa5, 0x01, 0x01);
+       /* ASCOT setting */
+       cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xa5,
+               ((priv->flags & CXD2841ER_ASCOT) ? 0x01 : 0x00), 0x01);
        /* Set SLV-T Bank : 0x20 */
        cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x20);
        /* Acquisition optimization setting */
@@ -3140,8 +3156,9 @@ static int cxd2841er_sleep_tc_to_active_i(struct cxd2841er_priv *priv,
        cxd2841er_write_regs(priv, I2C_SLVT, 0x43, data, 2);
        /* Enable ADC 4 */
        cxd2841er_write_reg(priv, I2C_SLVX, 0x18, 0x00);
-       /* ASCOT setting ON */
-       cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xa5, 0x01, 0x01);
+       /* ASCOT setting */
+       cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xa5,
+               ((priv->flags & CXD2841ER_ASCOT) ? 0x01 : 0x00), 0x01);
        /* FEC Auto Recovery setting */
        cxd2841er_set_reg_bits(priv, I2C_SLVT, 0x30, 0x01, 0x01);
        cxd2841er_set_reg_bits(priv, I2C_SLVT, 0x31, 0x00, 0x01);
@@ -3225,8 +3242,9 @@ static int cxd2841er_sleep_tc_to_active_c(struct cxd2841er_priv *priv,
        cxd2841er_write_reg(priv, I2C_SLVT, 0x6a, 0x48);
        /* Set SLV-T Bank : 0x10 */
        cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x10);
-       /* ASCOT setting ON */
-       cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xa5, 0x01, 0x01);
+       /* ASCOT setting */
+       cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xa5,
+               ((priv->flags & CXD2841ER_ASCOT) ? 0x01 : 0x00), 0x01);
        /* Set SLV-T Bank : 0x40 */
        cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x40);
        /* Demod setting */
index 58fbd987f47f09a92e08a1746d5002ae945c60d5..90ced9733ab9a43daa78420939f28c2e37817b18 100644 (file)
@@ -27,6 +27,7 @@
 #define CXD2841ER_USE_GATECTRL 1       /* bit 0 */
 #define CXD2841ER_AUTO_IFHZ    2       /* bit 1 */
 #define CXD2841ER_TS_SERIAL    4       /* bit 2 */
+#define CXD2841ER_ASCOT                8       /* bit 3 */
 
 enum cxd2841er_xtal {
        SONY_XTAL_20500, /* 20.5 MHz */
index 48b9cd7739881b85637071f616185a7231581622..5c0a4e614413de623962ab59657aa4418d01fa8d 100644 (file)
@@ -123,7 +123,7 @@ static void netup_unidvb_queue_cleanup(struct netup_dma *dma);
 static struct cxd2841er_config demod_config = {
        .i2c_addr = 0xc8,
        .xtal = SONY_XTAL_24000,
-       .flags = CXD2841ER_USE_GATECTRL
+       .flags = CXD2841ER_USE_GATECTRL | CXD2841ER_ASCOT
 };
 
 static struct horus3a_config horus3a_conf = {