diff options
author | Bimow Chen <Bimow.Chen@ite.com.tw> | 2014-10-01 07:28:54 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2014-11-04 18:19:12 -0200 |
commit | 3adec272425f6bb72375436b9dd67b0f5a7f7eef (patch) | |
tree | 8d63726fd20f8d04bdae4daafa21c49a579e35f6 /drivers/media/dvb-frontends/af9033.c | |
parent | 45c3cbb18462b76848476da596b8c1647929ab1f (diff) | |
download | linux-next-3adec272425f6bb72375436b9dd67b0f5a7f7eef.tar.gz |
[media] af9033: fix DVBv3 signal strength value not correct issue
Register 0x800048 is not dB measure but relative scale. Fix it and conform to NorDig specifications.
Signed-off-by: Bimow Chen <Bimow.Chen@ite.com.tw>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/dvb-frontends/af9033.c')
-rw-r--r-- | drivers/media/dvb-frontends/af9033.c | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/drivers/media/dvb-frontends/af9033.c b/drivers/media/dvb-frontends/af9033.c index 63a89c1c59ff..2b3d2f06c01b 100644 --- a/drivers/media/dvb-frontends/af9033.c +++ b/drivers/media/dvb-frontends/af9033.c @@ -862,16 +862,43 @@ static int af9033_read_snr(struct dvb_frontend *fe, u16 *snr) static int af9033_read_signal_strength(struct dvb_frontend *fe, u16 *strength) { struct af9033_dev *dev = fe->demodulator_priv; - int ret; - u8 strength2; + struct dtv_frontend_properties *c = &dev->fe.dtv_property_cache; + int ret, tmp, power_real; + u8 u8tmp, gain_offset, buf[7]; - /* read signal strength of 0-100 scale */ - ret = af9033_rd_reg(dev, 0x800048, &strength2); - if (ret < 0) - goto err; + if (dev->is_af9035) { + ret = af9033_rd_reg(dev, 0x80004a, &u8tmp); + /* scale value to 0x0000-0xffff */ + *strength = u8tmp * 0xffff / 100; + } else { + ret = af9033_rd_reg(dev, 0x8000f7, &u8tmp); + ret |= af9033_rd_regs(dev, 0x80f900, buf, 7); + + if (c->frequency <= 300000000) + gain_offset = 7; /* VHF */ + else + gain_offset = 4; /* UHF */ + + power_real = (u8tmp - 100 - gain_offset) - + power_reference[((buf[3] >> 0) & 3)][((buf[6] >> 0) & 7)]; + + if (power_real < -15) + tmp = 0; + else if ((power_real >= -15) && (power_real < 0)) + tmp = (2 * (power_real + 15)) / 3; + else if ((power_real >= 0) && (power_real < 20)) + tmp = 4 * power_real + 10; + else if ((power_real >= 20) && (power_real < 35)) + tmp = (2 * (power_real - 20)) / 3 + 90; + else + tmp = 100; + + /* scale value to 0x0000-0xffff */ + *strength = tmp * 0xffff / 100; + } - /* scale value to 0x0000-0xffff */ - *strength = strength2 * 0xffff / 100; + if (ret) + goto err; return 0; |