bugfix: avoid printing "PLL not locked" when frequency is not initialized

* see https://github.com/librtlsdr/librtlsdr/issues/57
* it's necessary to remember the rf_frequency,
 from last r82xx_set_freq() call

Signed-off-by: hayati ayguen <h_ayguen@web.de>
development
hayati ayguen 2020-08-18 16:01:51 -07:00
parent dc1e5a1618
commit 220d41c55f
2 changed files with 15 additions and 3 deletions

View File

@ -83,8 +83,10 @@ struct r82xx_priv {
uint8_t override_mask[NUM_REGS]; uint8_t override_mask[NUM_REGS];
enum r82xx_xtal_cap_value xtal_cap_sel; enum r82xx_xtal_cap_value xtal_cap_sel;
uint16_t pll; /* kHz */ uint16_t pll; /* kHz */
uint32_t int_freq; uint32_t rf_freq; /* frequency from r82xx_set_freq() */
int32_t if_band_center_freq; uint32_t int_freq; /* if frequency at which to deliver towards RTL2832U */
int32_t if_band_center_freq; /* frequency relative to zero IF,
* on which the band center shall be positioned */
uint8_t fil_cal_code; uint8_t fil_cal_code;
uint8_t input; uint8_t input;
int has_lock; int has_lock;

View File

@ -704,6 +704,7 @@ static int r82xx_set_mux(struct r82xx_priv *priv, uint32_t freq)
static int r82xx_set_pll(struct r82xx_priv *priv, uint32_t freq) static int r82xx_set_pll(struct r82xx_priv *priv, uint32_t freq)
{ {
/* freq == tuner's LO frequency */
int rc, i; int rc, i;
uint64_t vco_freq; uint64_t vco_freq;
uint64_t vco_div; uint64_t vco_div;
@ -847,10 +848,16 @@ static int r82xx_set_pll(struct r82xx_priv *priv, uint32_t freq)
} }
if (!(data[2] & 0x40)) { if (!(data[2] & 0x40)) {
fprintf(stderr, "[R82XX] PLL not locked for %u Hz!\n", freq); if ( priv->rf_freq )
fprintf(stderr, "[R82XX] PLL not locked at Tuner LO %u Hz for RF %u Hz!\n",
freq, priv->rf_freq);
priv->has_lock = 0; priv->has_lock = 0;
return 0; return 0;
} }
#if 0
else
fprintf(stderr, "[R82XX] PLL locked at Tuner LO %u Hz for RF %u Hz!\n", freq, priv->rf_freq);
#endif
priv->has_lock = 1; priv->has_lock = 1;
@ -1566,6 +1573,8 @@ int r82xx_set_freq(struct r82xx_priv *priv, uint32_t freq)
else else
lo_freq = freq + priv->int_freq + priv->if_band_center_freq; lo_freq = freq + priv->int_freq + priv->if_band_center_freq;
priv->rf_freq = freq;
#if 0 #if 0
fprintf(stderr, "%s(freq = %u) @ %s--> intfreq %u, ifcenter %d --> f %u\n" fprintf(stderr, "%s(freq = %u) @ %s--> intfreq %u, ifcenter %d --> f %u\n"
, __FUNCTION__, (unsigned)freq, (priv->sideband ? "USB" : "LSB") , __FUNCTION__, (unsigned)freq, (priv->sideband ? "USB" : "LSB")
@ -1660,6 +1669,7 @@ int r82xx_init(struct r82xx_priv *priv)
/* TODO: R828D might need r82xx_xtal_check() */ /* TODO: R828D might need r82xx_xtal_check() */
priv->xtal_cap_sel = XTAL_HIGH_CAP_0P; priv->xtal_cap_sel = XTAL_HIGH_CAP_0P;
priv->rf_freq = 0;
priv->if_band_center_freq = 0; priv->if_band_center_freq = 0;
priv->last_if_mode = 0; priv->last_if_mode = 0;