Skip to content

Commit

Permalink
tuner_e4k: allow frequencies above INT_MAX
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Markgraf <[email protected]>
  • Loading branch information
steve-m committed May 10, 2012
1 parent 8402124 commit 2ed8375
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion include/tuner_e4k.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ int e4k_mixer_gain_set(struct e4k_state *e4k, int8_t value);
int e4k_commonmode_set(struct e4k_state *e4k, int8_t value);
int e4k_tune_freq(struct e4k_state *e4k, uint32_t freq);
int e4k_tune_params(struct e4k_state *e4k, struct e4k_pll_params *p);
int e4k_compute_pll_params(struct e4k_pll_params *oscp, uint32_t fosc, uint32_t intended_flo);
uint32_t e4k_compute_pll_params(struct e4k_pll_params *oscp, uint32_t fosc, uint32_t intended_flo);
int e4k_if_filter_bw_get(struct e4k_state *e4k, enum e4k_if_filter filter);
int e4k_if_filter_bw_set(struct e4k_state *e4k, enum e4k_if_filter filter,
uint32_t bandwidth);
Expand Down
14 changes: 7 additions & 7 deletions src/tuner_e4k.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ static uint64_t compute_fvco(uint32_t f_osc, uint8_t z, uint16_t x)
return fvco;
}

static int compute_flo(uint32_t f_osc, uint8_t z, uint16_t x, uint8_t r)
static uint32_t compute_flo(uint32_t f_osc, uint8_t z, uint16_t x, uint8_t r)
{
uint64_t fvco = compute_fvco(f_osc, z, x);
if (fvco == 0)
Expand Down Expand Up @@ -459,9 +459,9 @@ static int e4k_band_set(struct e4k_state *e4k, enum e4k_band band)
* \param[in] fosc Clock input frequency applied to the chip (Hz)
* \param[in] intended_flo target tuning frequency (Hz)
* \returns actual PLL frequency, as close as possible to intended_flo,
* negative in case of error
* 0 in case of error
*/
int e4k_compute_pll_params(struct e4k_pll_params *oscp, uint32_t fosc, uint32_t intended_flo)
uint32_t e4k_compute_pll_params(struct e4k_pll_params *oscp, uint32_t fosc, uint32_t intended_flo)
{
uint32_t i;
uint8_t r = 2;
Expand All @@ -473,7 +473,7 @@ int e4k_compute_pll_params(struct e4k_pll_params *oscp, uint32_t fosc, uint32_t
oscp->r_idx = 0;

if (!is_fosc_valid(fosc))
return -EINVAL;
return 0;

for(i = 0; i < ARRAY_SIZE(pll_vars); ++i) {
if(intended_flo < pll_vars[i].freq) {
Expand Down Expand Up @@ -556,13 +556,13 @@ int e4k_tune_params(struct e4k_state *e4k, struct e4k_pll_params *p)
*/
int e4k_tune_freq(struct e4k_state *e4k, uint32_t freq)
{
int rc, i;
uint32_t rc;
struct e4k_pll_params p;

/* determine PLL parameters */
rc = e4k_compute_pll_params(&p, e4k->vco.fosc, freq);
if (rc < 0)
return rc;
if (!rc)
return -EINVAL;

/* actually tune to those parameters */
rc = e4k_tune_params(e4k, &p);
Expand Down

0 comments on commit 2ed8375

Please sign in to comment.