media: lgdt330x: move *read_status functions
authorMauro Carvalho Chehab <mchehab@s-opensource.com>
Fri, 9 Mar 2018 15:53:33 +0000 (10:53 -0500)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Fri, 4 May 2018 15:10:57 +0000 (11:10 -0400)
In preparation to implement DVBv5 stats on this driver, move
the *read_status functions to happen after SNR and signal
strength routines.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/dvb-frontends/lgdt330x.c

index c7355282bb3ec96af1eef67a9c4c19c0de77c6ff..bb61b4fb1df1f518f54a514de29714ebd32e6094 100644 (file)
@@ -472,133 +472,6 @@ static int lgdt330x_get_frontend(struct dvb_frontend *fe,
        return 0;
 }
 
-static int lgdt3302_read_status(struct dvb_frontend *fe,
-                               enum fe_status *status)
-{
-       struct lgdt330x_state *state = fe->demodulator_priv;
-       u8 buf[3];
-
-       *status = 0; /* Reset status result */
-
-       /* AGC status register */
-       i2c_read_demod_bytes(state, AGC_STATUS, buf, 1);
-       dprintk(state, "AGC_STATUS = 0x%02x\n", buf[0]);
-       if ((buf[0] & 0x0c) == 0x8) {
-               /*
-                * Test signal does not exist flag
-                * as well as the AGC lock flag.
-                */
-               *status |= FE_HAS_SIGNAL;
-       }
-
-       /*
-        * You must set the Mask bits to 1 in the IRQ_MASK in order
-        * to see that status bit in the IRQ_STATUS register.
-        * This is done in SwReset();
-        */
-
-       /* signal status */
-       i2c_read_demod_bytes(state, TOP_CONTROL, buf, sizeof(buf));
-       dprintk(state,
-               "TOP_CONTROL = 0x%02x, IRO_MASK = 0x%02x, IRQ_STATUS = 0x%02x\n",
-               buf[0], buf[1], buf[2]);
-
-       /* sync status */
-       if ((buf[2] & 0x03) == 0x01)
-               *status |= FE_HAS_SYNC;
-
-       /* FEC error status */
-       if ((buf[2] & 0x0c) == 0x08)
-               *status |= FE_HAS_LOCK | FE_HAS_VITERBI;
-
-       /* Carrier Recovery Lock Status Register */
-       i2c_read_demod_bytes(state, CARRIER_LOCK, buf, 1);
-       dprintk(state, "CARRIER_LOCK = 0x%02x\n", buf[0]);
-       switch (state->current_modulation) {
-       case QAM_256:
-       case QAM_64:
-               /* Need to understand why there are 3 lock levels here */
-               if ((buf[0] & 0x07) == 0x07)
-                       *status |= FE_HAS_CARRIER;
-               break;
-       case VSB_8:
-               if ((buf[0] & 0x80) == 0x80)
-                       *status |= FE_HAS_CARRIER;
-               break;
-       default:
-               dev_warn(&state->client->dev,
-                        "%s: Modulation set to unsupported value\n",
-                        __func__);
-       }
-
-       return 0;
-}
-
-static int lgdt3303_read_status(struct dvb_frontend *fe,
-                               enum fe_status *status)
-{
-       struct lgdt330x_state *state = fe->demodulator_priv;
-       int err;
-       u8 buf[3];
-
-       *status = 0; /* Reset status result */
-
-       /* lgdt3303 AGC status register */
-       err = i2c_read_demod_bytes(state, 0x58, buf, 1);
-       if (err < 0)
-               return err;
-
-       dprintk(state, "AGC_STATUS = 0x%02x\n", buf[0]);
-       if ((buf[0] & 0x21) == 0x01) {
-               /*
-                * Test input signal does not exist flag
-                * as well as the AGC lock flag.
-                */
-               *status |= FE_HAS_SIGNAL;
-       }
-
-       /* Carrier Recovery Lock Status Register */
-       i2c_read_demod_bytes(state, CARRIER_LOCK, buf, 1);
-       dprintk(state, "CARRIER_LOCK = 0x%02x\n", buf[0]);
-       switch (state->current_modulation) {
-       case QAM_256:
-       case QAM_64:
-               /* Need to understand why there are 3 lock levels here */
-               if ((buf[0] & 0x07) == 0x07)
-                       *status |= FE_HAS_CARRIER;
-               else
-                       break;
-               i2c_read_demod_bytes(state, 0x8a, buf, 1);
-               dprintk(state, "QAM LOCK = 0x%02x\n", buf[0]);
-
-               if ((buf[0] & 0x04) == 0x04)
-                       *status |= FE_HAS_SYNC;
-               if ((buf[0] & 0x01) == 0x01)
-                       *status |= FE_HAS_LOCK;
-               if ((buf[0] & 0x08) == 0x08)
-                       *status |= FE_HAS_VITERBI;
-               break;
-       case VSB_8:
-               if ((buf[0] & 0x80) == 0x80)
-                       *status |= FE_HAS_CARRIER;
-               else
-                       break;
-               i2c_read_demod_bytes(state, 0x38, buf, 1);
-               dprintk(state, "8-VSB LOCK = 0x%02x\n", buf[0]);
-
-               if ((buf[0] & 0x02) == 0x00)
-                       *status |= FE_HAS_SYNC;
-               if ((buf[0] & 0xfd) == 0x01)
-                       *status |= FE_HAS_VITERBI | FE_HAS_LOCK;
-               break;
-       default:
-               dev_warn(&state->client->dev,
-                        "%s: Modulation set to unsupported value\n",
-                        __func__);
-       }
-       return 0;
-}
-
 /*
  * Calculate SNR estimation (scaled by 2^24)
  *
@@ -754,6 +627,134 @@ static int lgdt330x_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
        return 0;
 }
 
+
+static int lgdt3302_read_status(struct dvb_frontend *fe,
+                               enum fe_status *status)
+{
+       struct lgdt330x_state *state = fe->demodulator_priv;
+       u8 buf[3];
+
+       *status = 0; /* Reset status result */
+
+       /* AGC status register */
+       i2c_read_demod_bytes(state, AGC_STATUS, buf, 1);
+       dprintk(state, "AGC_STATUS = 0x%02x\n", buf[0]);
+       if ((buf[0] & 0x0c) == 0x8) {
+               /*
+                * Test signal does not exist flag
+                * as well as the AGC lock flag.
+                */
+               *status |= FE_HAS_SIGNAL;
+       }
+
+       /*
+        * You must set the Mask bits to 1 in the IRQ_MASK in order
+        * to see that status bit in the IRQ_STATUS register.
+        * This is done in SwReset();
+        */
+
+       /* signal status */
+       i2c_read_demod_bytes(state, TOP_CONTROL, buf, sizeof(buf));
+       dprintk(state,
+               "TOP_CONTROL = 0x%02x, IRO_MASK = 0x%02x, IRQ_STATUS = 0x%02x\n",
+               buf[0], buf[1], buf[2]);
+
+       /* sync status */
+       if ((buf[2] & 0x03) == 0x01)
+               *status |= FE_HAS_SYNC;
+
+       /* FEC error status */
+       if ((buf[2] & 0x0c) == 0x08)
+               *status |= FE_HAS_LOCK | FE_HAS_VITERBI;
+
+       /* Carrier Recovery Lock Status Register */
+       i2c_read_demod_bytes(state, CARRIER_LOCK, buf, 1);
+       dprintk(state, "CARRIER_LOCK = 0x%02x\n", buf[0]);
+       switch (state->current_modulation) {
+       case QAM_256:
+       case QAM_64:
+               /* Need to understand why there are 3 lock levels here */
+               if ((buf[0] & 0x07) == 0x07)
+                       *status |= FE_HAS_CARRIER;
+               break;
+       case VSB_8:
+               if ((buf[0] & 0x80) == 0x80)
+                       *status |= FE_HAS_CARRIER;
+               break;
+       default:
+               dev_warn(&state->client->dev,
+                        "%s: Modulation set to unsupported value\n",
+                        __func__);
+       }
+
+       return 0;
+}
+
+static int lgdt3303_read_status(struct dvb_frontend *fe,
+                               enum fe_status *status)
+{
+       struct lgdt330x_state *state = fe->demodulator_priv;
+       int err;
+       u8 buf[3];
+
+       *status = 0; /* Reset status result */
+
+       /* lgdt3303 AGC status register */
+       err = i2c_read_demod_bytes(state, 0x58, buf, 1);
+       if (err < 0)
+               return err;
+
+       dprintk(state, "AGC_STATUS = 0x%02x\n", buf[0]);
+       if ((buf[0] & 0x21) == 0x01) {
+               /*
+                * Test input signal does not exist flag
+                * as well as the AGC lock flag.
+                */
+               *status |= FE_HAS_SIGNAL;
+       }
+
+       /* Carrier Recovery Lock Status Register */
+       i2c_read_demod_bytes(state, CARRIER_LOCK, buf, 1);
+       dprintk(state, "CARRIER_LOCK = 0x%02x\n", buf[0]);
+       switch (state->current_modulation) {
+       case QAM_256:
+       case QAM_64:
+               /* Need to understand why there are 3 lock levels here */
+               if ((buf[0] & 0x07) == 0x07)
+                       *status |= FE_HAS_CARRIER;
+               else
+                       break;
+               i2c_read_demod_bytes(state, 0x8a, buf, 1);
+               dprintk(state, "QAM LOCK = 0x%02x\n", buf[0]);
+
+               if ((buf[0] & 0x04) == 0x04)
+                       *status |= FE_HAS_SYNC;
+               if ((buf[0] & 0x01) == 0x01)
+                       *status |= FE_HAS_LOCK;
+               if ((buf[0] & 0x08) == 0x08)
+                       *status |= FE_HAS_VITERBI;
+               break;
+       case VSB_8:
+               if ((buf[0] & 0x80) == 0x80)
+                       *status |= FE_HAS_CARRIER;
+               else
+                       break;
+               i2c_read_demod_bytes(state, 0x38, buf, 1);
+               dprintk(state, "8-VSB LOCK = 0x%02x\n", buf[0]);
+
+               if ((buf[0] & 0x02) == 0x00)
+                       *status |= FE_HAS_SYNC;
+               if ((buf[0] & 0xfd) == 0x01)
+                       *status |= FE_HAS_VITERBI | FE_HAS_LOCK;
+               break;
+       default:
+               dev_warn(&state->client->dev,
+                        "%s: Modulation set to unsupported value\n",
+                        __func__);
+       }
+       return 0;
+}
+
 static int
 lgdt330x_get_tune_settings(struct dvb_frontend *fe,
                           struct dvb_frontend_tune_settings *fe_tune_settings)