[media] DVB-C read signal strength added for Sony demod
authorAbylay Ospan <aospan@netup.ru>
Fri, 1 Jul 2016 02:09:48 +0000 (23:09 -0300)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Fri, 8 Jul 2016 21:55:42 +0000 (18:55 -0300)
cxd2841er_read_agc_gain_c added to obtain signal strength.
signal strength now relay on AGC value.

Signed-off-by: Abylay Ospan <aospan@netup.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/dvb-frontends/cxd2841er.c

index c960e8a..0c7d92a 100644 (file)
@@ -1656,6 +1656,21 @@ static int cxd2841er_read_snr_i(struct cxd2841er_priv *priv, u32 *snr)
        return 0;
 }
 
+static u16 cxd2841er_read_agc_gain_c(struct cxd2841er_priv *priv,
+                                       u8 delsys)
+{
+       u8 data[2];
+
+       cxd2841er_write_reg(
+               priv, I2C_SLVT, 0x00, 0x40);
+       cxd2841er_read_regs(priv, I2C_SLVT, 0x49, data, 2);
+       dev_dbg(&priv->i2c->dev,
+                       "%s(): AGC value=%u\n",
+                       __func__, (((u16)data[0] & 0x0F) << 8) |
+                       (u16)(data[1] & 0xFF));
+       return ((((u16)data[0] & 0x0F) << 8) | (u16)(data[1] & 0xFF)) << 4;
+}
+
 static u16 cxd2841er_read_agc_gain_t_t2(struct cxd2841er_priv *priv,
                                        u8 delsys)
 {
@@ -1735,6 +1750,14 @@ static void cxd2841er_read_signal_strength(struct dvb_frontend *fe)
 
        dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
        switch (p->delivery_system) {
+       case SYS_DVBC_ANNEX_A:
+       case SYS_DVBC_ANNEX_B:
+       case SYS_DVBC_ANNEX_C:
+               strength = 65535 - cxd2841er_read_agc_gain_c(
+                               priv, p->delivery_system);
+               p->strength.stat[0].scale = FE_SCALE_RELATIVE;
+               p->strength.stat[0].uvalue = strength;
+               break;
        case SYS_DVBT:
        case SYS_DVBT2:
                strength = cxd2841er_read_agc_gain_t_t2(priv,