diff options
author | Antti Palosaari <crope@iki.fi> | 2014-01-27 01:13:19 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-03-14 04:25:02 -0400 |
commit | 0ed0b22dc594a533a959ed8995e69e2275af40d9 (patch) | |
tree | bed38f3c49388190ccf27337adaee3997da00af6 | |
parent | adaa616ffb697f00db9b4ccb638c5e9e719dbb7f (diff) |
[media] e4000: fix PLL calc to allow higher frequencies
There was 32-bit overflow on VCO frequency calculation which blocks
tuning to 1073 - 1104 MHz. Use 64 bit number in order to avoid VCO
frequency overflow.
After that fix device in question tunes to following range:
60 - 1104 MHz
1250 - 2207 MHz
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
-rw-r--r-- | drivers/media/tuners/e4000.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/drivers/media/tuners/e4000.c b/drivers/media/tuners/e4000.c index 3a03b026eb0c..ae52a1f4bb13 100644 --- a/drivers/media/tuners/e4000.c +++ b/drivers/media/tuners/e4000.c | |||
@@ -221,11 +221,11 @@ static int e4000_set_params(struct dvb_frontend *fe) | |||
221 | struct e4000_priv *priv = fe->tuner_priv; | 221 | struct e4000_priv *priv = fe->tuner_priv; |
222 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; | 222 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
223 | int ret, i, sigma_delta; | 223 | int ret, i, sigma_delta; |
224 | unsigned int f_vco; | 224 | u64 f_vco; |
225 | u8 buf[5], i_data[4], q_data[4]; | 225 | u8 buf[5], i_data[4], q_data[4]; |
226 | 226 | ||
227 | dev_dbg(&priv->client->dev, | 227 | dev_dbg(&priv->client->dev, |
228 | "%s: delivery_system=%d frequency=%d bandwidth_hz=%d\n", | 228 | "%s: delivery_system=%d frequency=%u bandwidth_hz=%u\n", |
229 | __func__, c->delivery_system, c->frequency, | 229 | __func__, c->delivery_system, c->frequency, |
230 | c->bandwidth_hz); | 230 | c->bandwidth_hz); |
231 | 231 | ||
@@ -248,20 +248,16 @@ static int e4000_set_params(struct dvb_frontend *fe) | |||
248 | goto err; | 248 | goto err; |
249 | } | 249 | } |
250 | 250 | ||
251 | /* | 251 | f_vco = 1ull * c->frequency * e4000_pll_lut[i].mul; |
252 | * Note: Currently f_vco overflows when c->frequency is 1 073 741 824 Hz | ||
253 | * or more. | ||
254 | */ | ||
255 | f_vco = c->frequency * e4000_pll_lut[i].mul; | ||
256 | sigma_delta = div_u64(0x10000ULL * (f_vco % priv->clock), priv->clock); | 252 | sigma_delta = div_u64(0x10000ULL * (f_vco % priv->clock), priv->clock); |
257 | buf[0] = f_vco / priv->clock; | 253 | buf[0] = div_u64(f_vco, priv->clock); |
258 | buf[1] = (sigma_delta >> 0) & 0xff; | 254 | buf[1] = (sigma_delta >> 0) & 0xff; |
259 | buf[2] = (sigma_delta >> 8) & 0xff; | 255 | buf[2] = (sigma_delta >> 8) & 0xff; |
260 | buf[3] = 0x00; | 256 | buf[3] = 0x00; |
261 | buf[4] = e4000_pll_lut[i].div; | 257 | buf[4] = e4000_pll_lut[i].div; |
262 | 258 | ||
263 | dev_dbg(&priv->client->dev, | 259 | dev_dbg(&priv->client->dev, |
264 | "%s: f_vco=%u pll div=%d sigma_delta=%04x\n", | 260 | "%s: f_vco=%llu pll div=%d sigma_delta=%04x\n", |
265 | __func__, f_vco, buf[0], sigma_delta); | 261 | __func__, f_vco, buf[0], sigma_delta); |
266 | 262 | ||
267 | ret = e4000_wr_regs(priv, 0x09, buf, 5); | 263 | ret = e4000_wr_regs(priv, 0x09, buf, 5); |