diff options
author | Antti Palosaari <crope@iki.fi> | 2016-08-08 15:54:10 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2016-09-22 10:38:41 -0300 |
commit | fcd09f6592cc1d55dea1571297ad88b9024de80c (patch) | |
tree | b1eac6d196783e100a99454b3f04da0dd84447ef /drivers/media/dvb-frontends/cxd2820r_t.c | |
parent | 7d4b64028c4bc8db01047b852777dbded4635de6 (diff) | |
download | linux-fcd09f6592cc1d55dea1571297ad88b9024de80c.tar.gz linux-fcd09f6592cc1d55dea1571297ad88b9024de80c.tar.bz2 linux-fcd09f6592cc1d55dea1571297ad88b9024de80c.zip |
[media] cxd2820r: improve IF frequency setting
Use 64-bit calculation.
Return error if tuner does not provide get_if_frequency() callback.
All currently used tuners has it.
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/dvb-frontends/cxd2820r_t.c')
-rw-r--r-- | drivers/media/dvb-frontends/cxd2820r_t.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/drivers/media/dvb-frontends/cxd2820r_t.c b/drivers/media/dvb-frontends/cxd2820r_t.c index 75ce7d8ded00..67cc33bc3c35 100644 --- a/drivers/media/dvb-frontends/cxd2820r_t.c +++ b/drivers/media/dvb-frontends/cxd2820r_t.c @@ -26,8 +26,8 @@ int cxd2820r_set_frontend_t(struct dvb_frontend *fe) struct cxd2820r_priv *priv = fe->demodulator_priv; struct dtv_frontend_properties *c = &fe->dtv_property_cache; int ret, i, bw_i; - u32 if_freq, if_ctl; - u64 num; + unsigned int utmp; + u32 if_frequency; u8 buf[3], bw_param; u8 bw_params1[][5] = { { 0x17, 0xea, 0xaa, 0xaa, 0xaa }, /* 6 MHz */ @@ -93,21 +93,20 @@ int cxd2820r_set_frontend_t(struct dvb_frontend *fe) /* program IF frequency */ if (fe->ops.tuner_ops.get_if_frequency) { - ret = fe->ops.tuner_ops.get_if_frequency(fe, &if_freq); + ret = fe->ops.tuner_ops.get_if_frequency(fe, &if_frequency); if (ret) goto error; - } else - if_freq = 0; - - dev_dbg(&priv->i2c->dev, "%s: if_freq=%d\n", __func__, if_freq); - - num = if_freq / 1000; /* Hz => kHz */ - num *= 0x1000000; - if_ctl = DIV_ROUND_CLOSEST_ULL(num, 41000); - buf[0] = ((if_ctl >> 16) & 0xff); - buf[1] = ((if_ctl >> 8) & 0xff); - buf[2] = ((if_ctl >> 0) & 0xff); + dev_dbg(&priv->i2c->dev, "%s: if_frequency=%u\n", __func__, + if_frequency); + } else { + ret = -EINVAL; + goto error; + } + utmp = DIV_ROUND_CLOSEST_ULL((u64)if_frequency * 0x1000000, CXD2820R_CLK); + buf[0] = (utmp >> 16) & 0xff; + buf[1] = (utmp >> 8) & 0xff; + buf[2] = (utmp >> 0) & 0xff; ret = cxd2820r_wr_regs(priv, 0x000b6, buf, 3); if (ret) goto error; |