diff options
author | Martin Braun <martin.braun@ettus.com> | 2020-05-12 13:44:05 -0700 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2020-06-10 12:44:10 -0500 |
commit | 0af68addaa7d2b2abb362b3b9f941b37b4b692e8 (patch) | |
tree | ff706faf7979d90a94d0e6a22a8873dfd6722953 /host | |
parent | dac56ff0dcf35c4bf8ecb1e127465f6f726de737 (diff) | |
download | uhd-0af68addaa7d2b2abb362b3b9f941b37b4b692e8.tar.gz uhd-0af68addaa7d2b2abb362b3b9f941b37b4b692e8.tar.bz2 uhd-0af68addaa7d2b2abb362b3b9f941b37b4b692e8.zip |
radio_control: Provide default implementations for ref power APIs
The various implementations for the reference power APIs are always the
same, assuming the existence of a pwr_cal_mgr object. We therefore store
references to power cal managers in radio_control_impl, which radios can
choose to populate. The APIs then don't have to be reimplemented in the
various radio classes, unless they want to for whatever reason.
Diffstat (limited to 'host')
-rw-r--r-- | host/lib/include/uhdlib/rfnoc/radio_control_impl.hpp | 8 | ||||
-rw-r--r-- | host/lib/rfnoc/radio_control_impl.cpp | 61 |
2 files changed, 47 insertions, 22 deletions
diff --git a/host/lib/include/uhdlib/rfnoc/radio_control_impl.hpp b/host/lib/include/uhdlib/rfnoc/radio_control_impl.hpp index db723a6f6..956280007 100644 --- a/host/lib/include/uhdlib/rfnoc/radio_control_impl.hpp +++ b/host/lib/include/uhdlib/rfnoc/radio_control_impl.hpp @@ -9,6 +9,7 @@ #include <uhd/rfnoc/defaults.hpp> #include <uhd/rfnoc/multichan_register_iface.hpp> #include <uhd/rfnoc/radio_control.hpp> +#include <uhdlib/usrp/common/pwr_cal_mgr.hpp> #include <unordered_map> #include <mutex> @@ -310,6 +311,13 @@ protected: //! Block-specific register interface multichan_register_iface _radio_reg_iface; + //! Power manager for RX power cal. If the radio doesn't have a power API, + // simply leave these empty. + std::vector<uhd::usrp::pwr_cal_mgr::sptr> _rx_pwr_mgr; + //! Power manager for TX power cal. If the radio doesn't have a power API, + // simply leave these empty. + std::vector<uhd::usrp::pwr_cal_mgr::sptr> _tx_pwr_mgr; + private: //! Validator for the async messages // diff --git a/host/lib/rfnoc/radio_control_impl.cpp b/host/lib/rfnoc/radio_control_impl.cpp index c6eac11f8..cd914852d 100644 --- a/host/lib/rfnoc/radio_control_impl.cpp +++ b/host/lib/rfnoc/radio_control_impl.cpp @@ -403,26 +403,32 @@ double radio_control_impl::set_rx_gain( return set_rx_gain(gain, chan); } -bool radio_control_impl::has_rx_power_reference(const size_t) +bool radio_control_impl::has_rx_power_reference(const size_t chan) { - return false; + return _rx_pwr_mgr.empty() ? false : _rx_pwr_mgr.at(chan)->has_power_data(); } -bool radio_control_impl::has_tx_power_reference(const size_t) +bool radio_control_impl::has_tx_power_reference(const size_t chan) { - return false; + return _tx_pwr_mgr.empty() ? false : _tx_pwr_mgr.at(chan)->has_power_data(); } -void radio_control_impl::set_rx_power_reference(const double, const size_t) +void radio_control_impl::set_rx_power_reference(const double power_dbm, const size_t chan) { - throw uhd::not_implemented_error( - "set_rx_power_reference() is not supported on this radio!"); + if (_rx_pwr_mgr.empty()) { + throw uhd::not_implemented_error( + "set_rx_power_reference() is not supported on this radio!"); + } + _rx_pwr_mgr.at(chan)->set_power(power_dbm); } -void radio_control_impl::set_tx_power_reference(const double, const size_t) +void radio_control_impl::set_tx_power_reference(const double power_dbm, const size_t chan) { - throw uhd::not_implemented_error( - "set_tx_power_reference() is not supported on this radio!"); + if (_tx_pwr_mgr.empty()) { + throw uhd::not_implemented_error( + "set_tx_power_reference() is not supported on this radio!"); + } + _tx_pwr_mgr.at(chan)->set_power(power_dbm); } void radio_control_impl::set_rx_agc(const bool, const size_t) @@ -596,30 +602,41 @@ uhd::meta_range_t radio_control_impl::get_rx_bandwidth_range(size_t chan) const return result; } -double radio_control_impl::get_rx_power_reference(const size_t) +double radio_control_impl::get_rx_power_reference(const size_t chan) { - throw uhd::not_implemented_error( - "get_rx_power_reference() is not supported on this radio!"); - return 0.0; + if (_rx_pwr_mgr.empty()) { + throw uhd::not_implemented_error( + "get_rx_power_reference() is not supported on this radio!"); + } + return _rx_pwr_mgr.at(chan)->get_power(); } -double radio_control_impl::get_tx_power_reference(const size_t) +double radio_control_impl::get_tx_power_reference(const size_t chan) { - throw uhd::not_implemented_error( - "get_tx_power_reference() is not supported on this radio!"); - return 0.0; + if (_tx_pwr_mgr.empty()) { + throw uhd::not_implemented_error( + "get_tx_power_reference() is not supported on this radio!"); + } + return _tx_pwr_mgr.at(chan)->get_power(); } -std::vector<std::string> radio_control_impl::get_rx_power_ref_keys(const size_t) +std::vector<std::string> radio_control_impl::get_rx_power_ref_keys(const size_t chan) { - return {}; + if (_rx_pwr_mgr.empty()) { + return {}; + } + return {_rx_pwr_mgr.at(chan)->get_key(), _rx_pwr_mgr.at(chan)->get_serial()}; } -std::vector<std::string> radio_control_impl::get_tx_power_ref_keys(const size_t) +std::vector<std::string> radio_control_impl::get_tx_power_ref_keys(const size_t chan) { - return {}; + if (_tx_pwr_mgr.empty()) { + return {}; + } + return {_tx_pwr_mgr.at(chan)->get_key(), _tx_pwr_mgr.at(chan)->get_serial()}; } + /****************************************************************************** * LO Default API *****************************************************************************/ |