]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
media: dvb-frontends/stv0367: initial DDB DVBv5 stats, implement ucblocks
authorDaniel Scheller <d.scheller@gmx.net>
Wed, 21 Jun 2017 19:45:41 +0000 (16:45 -0300)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Sat, 24 Jun 2017 20:42:18 +0000 (17:42 -0300)
This adds the basics to stv0367ddb_read_status() to be able to properly
provide signal statistics in DVBv5 format. Also adds UCB readout and
provides those values. Also, don't return -EINVAL in ddb_read_status()
if active_demod_state indicates no delivery system.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/dvb-frontends/stv0367.c

index b42b99ad4d3fd62a987c8c89396d7e5685d05b09..9c6f41be91447f61aa08adcdae450f15afe5fc4e 100644 (file)
@@ -2980,21 +2980,59 @@ static int stv0367ddb_set_frontend(struct dvb_frontend *fe)
        return -EINVAL;
 }
 
+static void stv0367ddb_read_ucblocks(struct dvb_frontend *fe)
+{
+       struct stv0367_state *state = fe->demodulator_priv;
+       struct dtv_frontend_properties *p = &fe->dtv_property_cache;
+       u32 ucblocks = 0;
+
+       switch (state->activedemod) {
+       case demod_ter:
+               stv0367ter_read_ucblocks(fe, &ucblocks);
+               break;
+       case demod_cab:
+               stv0367cab_read_ucblcks(fe, &ucblocks);
+               break;
+       default:
+               p->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
+               return;
+       }
+
+       p->block_error.stat[0].scale = FE_SCALE_COUNTER;
+       p->block_error.stat[0].uvalue = ucblocks;
+}
+
 static int stv0367ddb_read_status(struct dvb_frontend *fe,
                                  enum fe_status *status)
 {
        struct stv0367_state *state = fe->demodulator_priv;
+       struct dtv_frontend_properties *p = &fe->dtv_property_cache;
+       int ret;
 
        switch (state->activedemod) {
        case demod_ter:
-               return stv0367ter_read_status(fe, status);
+               ret = stv0367ter_read_status(fe, status);
+               break;
        case demod_cab:
-               return stv0367cab_read_status(fe, status);
-       default:
+               ret = stv0367cab_read_status(fe, status);
                break;
+       default:
+               return 0;
        }
 
-       return -EINVAL;
+       /* stop and report on *_read_status failure */
+       if (ret)
+               return ret;
+
+       /* stop if demod isn't locked */
+       if (!(*status & FE_HAS_LOCK)) {
+               p->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
+               return ret;
+       }
+
+       stv0367ddb_read_ucblocks(fe);
+
+       return 0;
 }
 
 static int stv0367ddb_get_frontend(struct dvb_frontend *fe,
@@ -3035,6 +3073,7 @@ static int stv0367ddb_sleep(struct dvb_frontend *fe)
 static int stv0367ddb_init(struct stv0367_state *state)
 {
        struct stv0367ter_state *ter_state = state->ter_state;
+       struct dtv_frontend_properties *p = &state->fe.dtv_property_cache;
 
        stv0367_writereg(state, R367TER_TOPCTRL, 0x10);
 
@@ -3109,6 +3148,13 @@ static int stv0367ddb_init(struct stv0367_state *state)
        ter_state->first_lock = 0;
        ter_state->unlock_counter = 2;
 
+       p->strength.len = 1;
+       p->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
+       p->cnr.len = 1;
+       p->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
+       p->block_error.len = 1;
+       p->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
+
        return 0;
 }