summaryrefslogtreecommitdiff
path: root/drivers/media/pci/ddbridge
diff options
context:
space:
mode:
authorDaniel Scheller <d.scheller@gmx.net>2018-06-23 11:36:06 -0400
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>2018-07-30 16:23:12 -0400
commit3c7d591121c3f5cb97abb9c5dd2a9c2bd8532674 (patch)
treebf1530e171ae15b8d75443fecaf665b7ec1cf67d /drivers/media/pci/ddbridge
parent3addf0fa820b3da34e0c0e532167afcee8089a3b (diff)
media: ddbridge/mci: read and report signal strength and SNR
Implement querying signal statistics from the MCI and report this data in read_status() as DVBv5 statistics. Picked up from the upstream dddvb GIT. Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Diffstat (limited to 'drivers/media/pci/ddbridge')
-rw-r--r--drivers/media/pci/ddbridge/ddbridge-mci.c47
1 files changed, 46 insertions, 1 deletions
diff --git a/drivers/media/pci/ddbridge/ddbridge-mci.c b/drivers/media/pci/ddbridge/ddbridge-mci.c
index 46b20b06e2a6..7d402861fa9e 100644
--- a/drivers/media/pci/ddbridge/ddbridge-mci.c
+++ b/drivers/media/pci/ddbridge/ddbridge-mci.c
@@ -155,6 +155,47 @@ static void release(struct dvb_frontend *fe)
kfree(state);
}
+static int get_info(struct dvb_frontend *fe)
+{
+ int stat;
+ struct mci *state = fe->demodulator_priv;
+ struct mci_command cmd;
+
+ memset(&cmd, 0, sizeof(cmd));
+ cmd.command = MCI_CMD_GETSIGNALINFO;
+ cmd.demod = state->demod;
+ stat = mci_cmd(state, &cmd, &state->signal_info);
+ return stat;
+}
+
+static int get_snr(struct dvb_frontend *fe)
+{
+ struct mci *state = fe->demodulator_priv;
+ struct dtv_frontend_properties *p = &fe->dtv_property_cache;
+
+ p->cnr.len = 1;
+ p->cnr.stat[0].scale = FE_SCALE_DECIBEL;
+ p->cnr.stat[0].svalue =
+ (s64)state->signal_info.dvbs2_signal_info.signal_to_noise
+ * 10;
+ return 0;
+}
+
+static int get_strength(struct dvb_frontend *fe)
+{
+ struct mci *state = fe->demodulator_priv;
+ struct dtv_frontend_properties *p = &fe->dtv_property_cache;
+ s32 str;
+
+ str = 100000 -
+ (state->signal_info.dvbs2_signal_info.channel_power
+ * 10 + 108750);
+ p->strength.len = 1;
+ p->strength.stat[0].scale = FE_SCALE_DECIBEL;
+ p->strength.stat[0].svalue = str;
+ return 0;
+}
+
static int read_status(struct dvb_frontend *fe, enum fe_status *status)
{
int stat;
@@ -168,10 +209,14 @@ static int read_status(struct dvb_frontend *fe, enum fe_status *status)
if (stat)
return stat;
*status = 0x00;
+ get_info(fe);
+ get_strength(fe);
if (res.status == SX8_DEMOD_WAIT_MATYPE)
*status = 0x0f;
- if (res.status == SX8_DEMOD_LOCKED)
+ if (res.status == SX8_DEMOD_LOCKED) {
*status = 0x1f;
+ get_snr(fe);
+ }
return stat;
}