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

Commit 6b457786 authored by Antti Palosaari's avatar Antti Palosaari Committed by Mauro Carvalho Chehab
Browse files

[media] af9033: wrap DVBv3 read SNR to DVBv5 CNR



Remove 'duplicate' DVBv3 read SNR implementation and return value,
calculated already by DVBv5 CNR, from the cache.

Signed-off-by: default avatarAntti Palosaari <crope@iki.fi>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 3e41313a
Loading
Loading
Loading
Loading
+6 −46
Original line number Original line Diff line number Diff line
@@ -832,55 +832,15 @@ static int af9033_read_status(struct dvb_frontend *fe, fe_status_t *status)
static int af9033_read_snr(struct dvb_frontend *fe, u16 *snr)
static int af9033_read_snr(struct dvb_frontend *fe, u16 *snr)
{
{
	struct af9033_dev *dev = fe->demodulator_priv;
	struct af9033_dev *dev = fe->demodulator_priv;
	int ret, i, len;
	struct dtv_frontend_properties *c = &dev->fe.dtv_property_cache;
	u8 buf[3], tmp;
	u32 snr_val;
	const struct val_snr *snr_lut;

	/* read value */
	ret = af9033_rd_regs(dev, 0x80002c, buf, 3);
	if (ret < 0)
		goto err;

	snr_val = (buf[2] << 16) | (buf[1] << 8) | buf[0];

	/* read current modulation */
	ret = af9033_rd_reg(dev, 0x80f903, &tmp);
	if (ret < 0)
		goto err;

	switch ((tmp >> 0) & 3) {
	case 0:
		len = ARRAY_SIZE(qpsk_snr_lut);
		snr_lut = qpsk_snr_lut;
		break;
	case 1:
		len = ARRAY_SIZE(qam16_snr_lut);
		snr_lut = qam16_snr_lut;
		break;
	case 2:
		len = ARRAY_SIZE(qam64_snr_lut);
		snr_lut = qam64_snr_lut;
		break;
	default:
		goto err;
	}

	for (i = 0; i < len; i++) {
		tmp = snr_lut[i].snr;

		if (snr_val < snr_lut[i].val)
			break;
	}


	*snr = tmp * 10; /* dB/10 */
	/* use DVBv5 CNR */
	if (c->cnr.stat[0].scale == FE_SCALE_DECIBEL)
		*snr = div_s64(c->cnr.stat[0].svalue, 100); /* 1000x => 10x */
	else
		*snr = 0;


	return 0;
	return 0;

err:
	dev_dbg(&dev->client->dev, "failed=%d\n", ret);

	return ret;
}
}


static int af9033_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
static int af9033_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
+1 −0
Original line number Original line Diff line number Diff line
@@ -24,6 +24,7 @@


#include "dvb_frontend.h"
#include "dvb_frontend.h"
#include "af9033.h"
#include "af9033.h"
#include <linux/math64.h>


struct reg_val {
struct reg_val {
	u32 reg;
	u32 reg;