Skip to content

Commit

Permalink
Simplify the PLL mix_div / div_num calculation, and make sure we don'…
Browse files Browse the repository at this point in the history
…t fall out of the

loop with div_num unset.
  • Loading branch information
mutability committed Aug 26, 2014
1 parent af744aa commit 6ff9ef0
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions src/tuner_r82xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,20 +493,10 @@ static int r82xx_set_pll(struct r82xx_priv *priv, uint32_t freq, uint32_t *freq_
return rc;

/* Calculate divider */
if(freq_khz < vco_min/64) vco_min /= 2;
if(freq_khz >= vco_max/2) vco_max *= 2;
while (mix_div <= 64) {
if (((freq_khz * mix_div) >= vco_min) &&
((freq_khz * mix_div) < vco_max)) {
div_buf = mix_div;
while (div_buf > 2) {
div_buf = div_buf >> 1;
div_num++;
}

for (mix_div = 2, div_num = 0; mix_div < 64; mix_div <<= 1, div_num++)
if ((freq_khz * mix_div) >= vco_min)
break;
}
mix_div = mix_div << 1;
}

if (priv->cfg->rafael_chip == CHIP_R828D)
vco_power_ref = 1;
Expand Down

0 comments on commit 6ff9ef0

Please sign in to comment.