From e033fc3d7f6d3baad76af9c5aa9f7f3aaeffab39 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 17 Aug 2011 17:09:55 -0700 Subject: usrp: use the frontend BW to clip the overall tune range --- host/lib/usrp/multi_usrp.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp index 49cbe522f..d0141108e 100644 --- a/host/lib/usrp/multi_usrp.cpp +++ b/host/lib/usrp/multi_usrp.cpp @@ -65,6 +65,18 @@ static void do_tune_freq_warning_message( } } +static meta_range_t make_overall_tune_range( + const meta_range_t &fe_range, + const meta_range_t &dsp_range, + const double bw +){ + return meta_range_t( + fe_range.start() + std::max(dsp_range.start(), -bw), + fe_range.stop() + std::min(dsp_range.stop(), bw), + dsp_range.step() + ); +} + /*********************************************************************** * Gain helper functions **********************************************************************/ @@ -442,9 +454,11 @@ public: } freq_range_t get_rx_freq_range(size_t chan){ - meta_range_t range = _tree->access(rx_rf_fe_root(chan) / "freq" / "range").get(); - meta_range_t dsp_range = _tree->access(rx_dsp_root(chan) / "freq" / "range").get(); - return meta_range_t(range.start() + dsp_range.start(), range.stop() + dsp_range.stop(), dsp_range.step()); + return make_overall_tune_range( + _tree->access(rx_rf_fe_root(chan) / "freq" / "range").get(), + _tree->access(rx_dsp_root(chan) / "freq" / "range").get(), + this->get_rx_bandwidth(chan) + ); } void set_rx_gain(double gain, const std::string &name, size_t chan){ @@ -550,9 +564,11 @@ public: } freq_range_t get_tx_freq_range(size_t chan){ - meta_range_t range = _tree->access(tx_rf_fe_root(chan) / "freq" / "range").get(); - meta_range_t dsp_range = _tree->access(tx_dsp_root(chan) / "freq" / "range").get(); - return meta_range_t(range.start() + dsp_range.start(), range.stop() + dsp_range.stop(), dsp_range.step()); + return make_overall_tune_range( + _tree->access(tx_rf_fe_root(chan) / "freq" / "range").get(), + _tree->access(tx_dsp_root(chan) / "freq" / "range").get(), + this->get_tx_bandwidth(chan) + ); } void set_tx_gain(double gain, const std::string &name, size_t chan){ -- cgit v1.2.3