OSDN Git Service

media: lgdt3306a: Add CNR v5 stat
authorBrad Love <brad@nextdimension.cc>
Thu, 14 Nov 2019 20:04:07 +0000 (21:04 +0100)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Tue, 21 Apr 2020 14:50:56 +0000 (16:50 +0200)
The CNR is already calculated, so populate DVBv5 CNR stat
during read_status.

Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/dvb-frontends/lgdt3306a.c

index 6c4adec..d3c330e 100644 (file)
@@ -846,6 +846,7 @@ static int lgdt3306a_fe_sleep(struct dvb_frontend *fe)
 static int lgdt3306a_init(struct dvb_frontend *fe)
 {
        struct lgdt3306a_state *state = fe->demodulator_priv;
+       struct dtv_frontend_properties *c = &fe->dtv_property_cache;
        u8 val;
        int ret;
 
@@ -997,6 +998,9 @@ static int lgdt3306a_init(struct dvb_frontend *fe)
        ret = lgdt3306a_sleep(state);
        lg_chkerr(ret);
 
+       c->cnr.len = 1;
+       c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
+
 fail:
        return ret;
 }
@@ -1597,6 +1601,7 @@ static int lgdt3306a_read_status(struct dvb_frontend *fe,
                                 enum fe_status *status)
 {
        struct lgdt3306a_state *state = fe->demodulator_priv;
+       struct dtv_frontend_properties *c = &fe->dtv_property_cache;
        u16 strength = 0;
        int ret = 0;
 
@@ -1637,6 +1642,15 @@ static int lgdt3306a_read_status(struct dvb_frontend *fe,
                default:
                        ret = -EINVAL;
                }
+
+               if (*status & FE_HAS_SYNC) {
+                       c->cnr.len = 1;
+                       c->cnr.stat[0].scale = FE_SCALE_DECIBEL;
+                       c->cnr.stat[0].svalue = lgdt3306a_calculate_snr_x100(state) * 10;
+               } else {
+                       c->cnr.len = 1;
+                       c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
+               }
        }
        return ret;
 }