From cec93754a23130e6b30bf9cd0ffb9900e82b1f71 Mon Sep 17 00:00:00 2001 From: Dimitri Stolnikov Date: Sun, 29 Apr 2012 19:51:11 +0200 Subject: [PATCH] use default xtal freq when 0 is given --- src/rtl-sdr.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/rtl-sdr.c b/src/rtl-sdr.c index 9673eb3..c38298f 100644 --- a/src/rtl-sdr.c +++ b/src/rtl-sdr.c @@ -484,14 +484,15 @@ int rtlsdr_set_xtal_freq(rtlsdr_dev_t *dev, uint32_t rtl_freq, uint32_t tuner_fr if (!dev) return -1; - if (rtl_freq < MIN_RTL_XTAL_FREQ || rtl_freq > MAX_RTL_XTAL_FREQ) + if (rtl_freq > 0 && + (rtl_freq < MIN_RTL_XTAL_FREQ || rtl_freq > MAX_RTL_XTAL_FREQ)) return -2; if (dev->rtl_xtal != rtl_freq) { - dev->rtl_xtal = rtl_freq; + if (0 == rtl_freq) + rtl_freq = DEF_RTL_XTAL_FREQ; - if (0 == dev->rtl_xtal) - dev->rtl_xtal = DEF_RTL_XTAL_FREQ; + dev->rtl_xtal = rtl_freq; /* update xtal-dependent settings */ if (dev->rate) @@ -499,12 +500,11 @@ int rtlsdr_set_xtal_freq(rtlsdr_dev_t *dev, uint32_t rtl_freq, uint32_t tuner_fr } if (dev->tun_xtal != tuner_freq) { + if (0 == tuner_freq) + tuner_freq = dev->rtl_xtal; dev->tun_xtal = tuner_freq; - if (0 == dev->tun_xtal) - dev->tun_xtal = dev->rtl_xtal; - /* update xtal-dependent settings */ if (dev->freq) r = rtlsdr_set_center_freq(dev, dev->freq);