Skip to contentSkip to conversation

e4000: fix PLL calc error in 32-bit arch

PATCH Antti Palosaari 3 participants 3 messages Sep 2, 2013 1 message not in the archive Media (V4L/DVB)

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Testers?

Here is tree:
http://git.linuxtv.org/anttip/media_tree.git/shortlog/refs/heads/e4000_fix_3.11

I assume all of you have been running 32-bit arch as that bug is related to 32-bit overflow.

regards
Antti

Quoted 30 lines · Antti Palosaari

Fix long-lasting error that causes tuning failure to some frequencies on 32-bit arch.

Special thanks goes to Damien CABROL who finally find root of the bug. Also big thanks to Jacek Konieczny for donating non-working device.

---
  drivers/media/tuners/e4000.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/tuners/e4000.c +1 -1
index 1b33ed3..a88f757 100644
@@ -232,7 +232,7 @@ static int e4000_set_params(struct dvb_frontend *fe)
  	 * or more.
  	 */
  	f_VCO = c->frequency * e4000_pll_lut[i].mul;
-	sigma_delta = 0x10000UL * (f_VCO % priv->cfg->clock) / priv->cfg->clock;
+	sigma_delta = div_u64(0x10000ULL * (f_VCO % priv->cfg->clock), priv->cfg->clock);
  	buf[0] = f_VCO / priv->cfg->clock;
  	buf[1] = (sigma_delta >> 0) & 0xff;
  	buf[2] = (sigma_delta >> 8) & 0xff;
Signature · 1 line
http://palosaari.fi/
#2 lore raw

Thanks! Works like a charm here with TerraTec Cinergy T Stick RC (Rev. 3). And you're right, I'm running 32-bit.

Regards,
jan.

Am 02.09.2013 18:26, schrieb Antti Palosaari:

Quoted 48 lines

Testers?

Here is tree:
http://git.linuxtv.org/anttip/media_tree.git/shortlog/refs/heads/e4000_fix_3.11

I assume all of you have been running 32-bit arch as that bug is related to 32-bit overflow.

regards
Antti

Quoted 32 lines · Antti Palosaari

Fix long-lasting error that causes tuning failure to some frequencies on 32-bit arch.

Special thanks goes to Damien CABROL who finally find root of the bug. Also big thanks to Jacek Konieczny for donating non-working device.

---
  drivers/media/tuners/e4000.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/tuners/e4000.c +1 -1
index 1b33ed3..a88f757 100644
@@ -232,7 +232,7 @@ static int e4000_set_params(struct dvb_frontend *fe)
       * or more.
       */
      f_VCO = c->frequency * e4000_pll_lut[i].mul;
-    sigma_delta = 0x10000UL * (f_VCO % priv->cfg->clock) /
 priv->cfg->clock;
+    sigma_delta = div_u64(0x10000ULL * (f_VCO % priv->cfg->clock),
 priv->cfg->clock);
      buf[0] = f_VCO / priv->cfg->clock;
      buf[1] = (sigma_delta >> 0) & 0xff;
      buf[2] = (sigma_delta >> 8) & 0xff;