aboutsummaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
Diffstat (limited to 'host')
-rw-r--r--host/lib/usrp/dboard/magnesium/magnesium_ad9371_iface.cpp47
-rw-r--r--host/lib/usrp/dboard/magnesium/magnesium_radio_control.cpp81
-rw-r--r--host/lib/usrp/dboard/magnesium/magnesium_radio_control.hpp4
3 files changed, 107 insertions, 25 deletions
diff --git a/host/lib/usrp/dboard/magnesium/magnesium_ad9371_iface.cpp b/host/lib/usrp/dboard/magnesium/magnesium_ad9371_iface.cpp
index 3683fae47..3bb0aeea6 100644
--- a/host/lib/usrp/dboard/magnesium/magnesium_ad9371_iface.cpp
+++ b/host/lib/usrp/dboard/magnesium/magnesium_ad9371_iface.cpp
@@ -17,9 +17,23 @@ namespace {
*/
std::string _get_which(const direction_t dir, const size_t chan)
{
- UHD_ASSERT_THROW(dir == RX_DIRECTION or dir == TX_DIRECTION);
- UHD_ASSERT_THROW(chan == 0 or chan == 1);
- return str(boost::format("%s%d") % (dir == RX_DIRECTION ? "RX" : "TX") % (chan + 1));
+ UHD_ASSERT_THROW(dir == RX_DIRECTION || dir == TX_DIRECTION);
+ UHD_ASSERT_THROW(chan == 0 || chan == 1);
+ return (dir == RX_DIRECTION ? "RX" : "TX") + std::to_string(chan + 1);
+}
+
+/*! Return a valid 'which' string for use with AD9371 API duplex calls
+ *
+ * Extends _get_which by additionally allowing duplex values
+ */
+std::string _get_which_duplex(const direction_t dir, const size_t chan)
+{
+ if (dir == RX_DIRECTION || dir == TX_DIRECTION) {
+ return _get_which(dir, chan);
+ }
+ UHD_ASSERT_THROW(dir == DX_DIRECTION);
+ UHD_ASSERT_THROW(chan == 0 || chan == 1);
+ return "DX" + std::to_string(chan + 1);
}
} // namespace
@@ -59,12 +73,23 @@ double magnesium_ad9371_iface::set_gain(
// return 0.0;
}
+/*! brief Sets the frontend bandwidth settings for the dboard. Requires
+ * re-initializing the dboard, so it may take a significant amount of time.
+ *
+ * \param bandwidth target rf bandwidth value
+ * \param chan -not important- the bandwidth settings affect both channels on
+ * the dboard
+ * \param dir specifies which path to set the bandwidth filters for. Supports
+ * rx, tx, or dx for both
+ * \return actual rf bandwidth value
+ */
double magnesium_ad9371_iface::set_bandwidth(
const double bandwidth, const size_t chan, const direction_t dir)
{
- auto const which = _get_which(dir, chan);
- auto retval = request<double>("set_bw_filter", which, bandwidth);
- UHD_LOG_TRACE(_log_prefix, _rpc_prefix << "set_bw_filter returned " << retval);
+ const auto which = _get_which_duplex(dir, chan);
+ const auto retval =
+ request<double>(MAGNESIUM_TUNE_TIMEOUT, "set_bandwidth", which, bandwidth);
+ UHD_LOG_TRACE(_log_prefix, _rpc_prefix << "set_bandwidth returned " << retval);
return retval;
}
@@ -84,12 +109,12 @@ double magnesium_ad9371_iface::get_gain(const size_t chan, const direction_t dir
return retval;
}
-double magnesium_ad9371_iface::get_bandwidth(
- const size_t /*chan*/, const direction_t /*dir*/)
+double magnesium_ad9371_iface::get_bandwidth(const size_t chan, const direction_t dir)
{
- // TODO: implement
- UHD_LOG_WARNING(_log_prefix, "Ignoring attempt to get bandwidth");
- return 0.0;
+ const auto which = _get_which(dir, chan);
+ const auto retval = request<double>("get_bandwidth", which);
+ UHD_LOG_TRACE(_log_prefix, _rpc_prefix << "get_bandwidth returned " << retval);
+ return retval;
}
std::string magnesium_ad9371_iface::set_lo_source(
diff --git a/host/lib/usrp/dboard/magnesium/magnesium_radio_control.cpp b/host/lib/usrp/dboard/magnesium/magnesium_radio_control.cpp
index a2de485e3..8e2463721 100644
--- a/host/lib/usrp/dboard/magnesium/magnesium_radio_control.cpp
+++ b/host/lib/usrp/dboard/magnesium/magnesium_radio_control.cpp
@@ -122,6 +122,8 @@ magnesium_radio_control_impl::magnesium_radio_control_impl(make_args_ptr make_ar
UHD_ASSERT_THROW(_n3xx_timekeeper);
_rpcc = _n310_mb_control->get_rpc_client();
UHD_ASSERT_THROW(_rpcc);
+ _mpm_compat_num = _rpcc->request<std::vector<size_t>>("get_mpm_compat_num");
+ UHD_ASSERT_THROW(_mpm_compat_num.size() == 2);
_init_defaults();
_init_mpm();
@@ -356,28 +358,79 @@ double magnesium_radio_control_impl::set_rx_frequency(
return radio_control_impl::get_rx_frequency(chan);
}
-double magnesium_radio_control_impl::set_rx_bandwidth(
+double magnesium_radio_control_impl::set_tx_bandwidth(
const double bandwidth, const size_t chan)
{
std::lock_guard<std::recursive_mutex> l(_set_lock);
- _ad9371->set_bandwidth(bandwidth, chan, RX_DIRECTION);
- // FIXME: setting analog bandwidth on AD9371 take no effect.
- // Remove this warning when ADI can confirm that it works.
- RFNOC_LOG_WARNING("set_rx_bandwidth take no effect on AD9371. "
- "Default analog bandwidth is 100MHz");
- return AD9371_RX_MAX_BANDWIDTH;
+
+ if (_mpm_compat_num[0] < 4 || (_mpm_compat_num[0] == 4 && _mpm_compat_num[1] < 1)) {
+ RFNOC_LOG_WARNING("Setting tx bandwidth not supported. Please upgrade MPM to a "
+ "minimum version of 4.1.");
+ radio_control_impl::set_tx_bandwidth(bandwidth, 1 - chan);
+ return radio_control_impl::set_tx_bandwidth(bandwidth, chan);
+ }
+
+ const auto curr_bw = get_tx_bandwidth(chan);
+ if (fp_compare_epsilon<double>(curr_bw) == bandwidth) {
+ return curr_bw;
+ }
+
+ // TX frontend components should be deactivated before running init_cals
+ const auto tx_atr_bits =
+ _cpld->get_tx_atr_bits(magnesium_cpld_ctrl::BOTH, magnesium_cpld_ctrl::IDLE);
+ _reset_tx_frontend(magnesium_cpld_ctrl::BOTH);
+
+ RFNOC_LOG_INFO(
+ "Re-initializing dboard to apply bandwidth settings. This may take some time.");
+ const auto ret = _ad9371->set_bandwidth(bandwidth, chan, TX_DIRECTION);
+ RFNOC_LOG_INFO("Bandwidth settings applied: " + std::to_string(ret));
+
+ // Restore TX frontend components to previous state
+ _cpld->set_tx_atr_bits(
+ magnesium_cpld_ctrl::BOTH, magnesium_cpld_ctrl::IDLE, tx_atr_bits);
+
+ // Save the updated bandwidth settings for both channels
+ radio_control_impl::set_tx_bandwidth(bandwidth, 1 - chan);
+ return radio_control_impl::set_tx_bandwidth(ret, chan);
}
-double magnesium_radio_control_impl::set_tx_bandwidth(
+double magnesium_radio_control_impl::set_rx_bandwidth(
const double bandwidth, const size_t chan)
{
std::lock_guard<std::recursive_mutex> l(_set_lock);
- _ad9371->set_bandwidth(bandwidth, chan, TX_DIRECTION);
- // FIXME: setting analog bandwidth on AD9371 take no effect.
- // Remove this warning when ADI can confirm that it works.
- RFNOC_LOG_WARNING("set_tx_bandwidth take no effect on AD9371. "
- "Default analog bandwidth is 100MHz");
- return AD9371_TX_MAX_BANDWIDTH;
+
+ if (_mpm_compat_num[0] < 4 || (_mpm_compat_num[0] == 4 && _mpm_compat_num[1] < 1)) {
+ RFNOC_LOG_WARNING("Setting rx bandwidth not supported. Please upgrade MPM to a "
+ "minimum version of 4.1.");
+ radio_control_impl::set_rx_bandwidth(bandwidth, 1 - chan);
+ return radio_control_impl::set_rx_bandwidth(bandwidth, chan);
+ }
+
+ const auto curr_bw = get_rx_bandwidth(chan);
+ if (fp_compare_epsilon<double>(curr_bw) == bandwidth) {
+ return curr_bw;
+ }
+
+ // TX frontend components should be deactivated before running init_cals
+ //
+ // We want to avoid any TX signals coming out of the frontend. This is
+ // necessary even during RX calibration.
+ const auto tx_atr_bits =
+ _cpld->get_tx_atr_bits(magnesium_cpld_ctrl::BOTH, magnesium_cpld_ctrl::IDLE);
+ _reset_tx_frontend(magnesium_cpld_ctrl::BOTH);
+
+ RFNOC_LOG_INFO(
+ "Re-initializing dboard to apply bandwidth settings. This may take some time.");
+ const auto ret = _ad9371->set_bandwidth(bandwidth, chan, RX_DIRECTION);
+ RFNOC_LOG_INFO("Bandwidth settings applied: " + std::to_string(ret));
+
+ // Restore TX frontend components to previous state
+ _cpld->set_tx_atr_bits(
+ magnesium_cpld_ctrl::BOTH, magnesium_cpld_ctrl::IDLE, tx_atr_bits);
+
+ // Save the updated bandwidth settings for both channels
+ radio_control_impl::set_rx_bandwidth(bandwidth, 1 - chan);
+ return radio_control_impl::set_rx_bandwidth(ret, chan);
}
double magnesium_radio_control_impl::set_tx_gain(const double gain, const size_t chan)
diff --git a/host/lib/usrp/dboard/magnesium/magnesium_radio_control.hpp b/host/lib/usrp/dboard/magnesium/magnesium_radio_control.hpp
index edc417cfe..5ac1ca245 100644
--- a/host/lib/usrp/dboard/magnesium/magnesium_radio_control.hpp
+++ b/host/lib/usrp/dboard/magnesium/magnesium_radio_control.hpp
@@ -279,6 +279,9 @@ private:
/**************************************************************************
* Private attributes
*************************************************************************/
+ //! MPM Compatibility number {MAJOR, MINOR}
+ std::vector<size_t> _mpm_compat_num;
+
//! Locks access to setter APIs
std::recursive_mutex _set_lock;
@@ -345,6 +348,7 @@ private:
//! Low band enable
std::map<direction_t, bool> _is_low_band = {
{RX_DIRECTION, false}, {TX_DIRECTION, false}};
+
//! AD9371 gain
double _ad9371_rx_gain = 0.0;
double _ad9371_tx_gain = 0.0;