Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 25ef9f55 authored by Antti Palosaari's avatar Antti Palosaari Committed by Mauro Carvalho Chehab
Browse files

[media] rtl2832: implement DVBv5 signal strength statistics



Estimate signal strength from IF digital AGC.

Signed-off-by: default avatarAntti Palosaari <crope@iki.fi>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 084330b7
Loading
Loading
Loading
Loading
+20 −0
Original line number Original line Diff line number Diff line
@@ -474,6 +474,8 @@ static int rtl2832_init(struct dvb_frontend *fe)
		goto err;
		goto err;
#endif
#endif
	/* init stats here in order signal app which stats are supported */
	/* init stats here in order signal app which stats are supported */
	c->strength.len = 1;
	c->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
	c->cnr.len = 1;
	c->cnr.len = 1;
	c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
	c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
	c->post_bit_error.len = 1;
	c->post_bit_error.len = 1;
@@ -823,6 +825,24 @@ static void rtl2832_stat_work(struct work_struct *work)


	dev_dbg(&client->dev, "\n");
	dev_dbg(&client->dev, "\n");


	/* signal strength */
	if (dev->fe_status & FE_HAS_SIGNAL) {
		/* read digital AGC */
		ret = rtl2832_bulk_read(client, 0x305, &u8tmp, 1);
		if (ret)
			goto err;

		dev_dbg(&client->dev, "digital agc=%02x", u8tmp);

		u8tmp = ~u8tmp;
		u16tmp = u8tmp << 8 | u8tmp << 0;

		c->strength.stat[0].scale = FE_SCALE_RELATIVE;
		c->strength.stat[0].uvalue = u16tmp;
	} else {
		c->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
	}

	/* CNR */
	/* CNR */
	if (dev->fe_status & FE_HAS_VITERBI) {
	if (dev->fe_status & FE_HAS_VITERBI) {
		unsigned hierarchy, constellation;
		unsigned hierarchy, constellation;