aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp
diff options
context:
space:
mode:
authorLane Kolbly <lane.kolbly@ni.com>2021-12-08 14:12:28 -0600
committerAaron Rossetto <aaron.rossetto@ni.com>2022-01-20 08:52:42 -0600
commit4e391500b54a22dbaae8692750ec25ae8a97ee6d (patch)
tree12907aaefb68f0d4825a8c9cb9ee2be9825d2542 /host/lib/usrp
parent72e9ba55d6b144d456a644cb47f40522022d4fb6 (diff)
downloaduhd-4e391500b54a22dbaae8692750ec25ae8a97ee6d.tar.gz
uhd-4e391500b54a22dbaae8692750ec25ae8a97ee6d.tar.bz2
uhd-4e391500b54a22dbaae8692750ec25ae8a97ee6d.zip
host: Implement nameless_gain_mixin
Diffstat (limited to 'host/lib/usrp')
-rw-r--r--host/lib/usrp/dboard/zbx/zbx_dboard.cpp88
-rw-r--r--host/lib/usrp/dboard/zbx/zbx_dboard_init.cpp4
2 files changed, 25 insertions, 67 deletions
diff --git a/host/lib/usrp/dboard/zbx/zbx_dboard.cpp b/host/lib/usrp/dboard/zbx/zbx_dboard.cpp
index 2a01425b6..9efb7ec20 100644
--- a/host/lib/usrp/dboard/zbx/zbx_dboard.cpp
+++ b/host/lib/usrp/dboard/zbx/zbx_dboard.cpp
@@ -31,7 +31,22 @@ zbx_dboard_impl::zbx_dboard_impl(register_iface& reg_iface,
uhd::usrp::zbx_rpc_iface::sptr rpcc,
uhd::rfnoc::x400::rfdc_control::sptr rfdcc,
uhd::property_tree::sptr tree)
- : _unique_id(unique_id)
+ : nameless_gain_mixin([this](const uhd::direction_t trx, size_t chan) {
+ const auto gain_profile = trx == TX_DIRECTION ?
+ _tx_gain_profile_api->get_gain_profile(chan) :
+ _rx_gain_profile_api->get_gain_profile(chan);
+ if (gain_profile == ZBX_GAIN_PROFILE_MANUAL) {
+ const std::string err_msg = "When using 'manual' gain mode, a gain name is required!";
+ RFNOC_LOG_ERROR(err_msg);
+ throw uhd::runtime_error(err_msg);
+ }
+ if (gain_profile == ZBX_GAIN_PROFILE_CPLD
+ || gain_profile == ZBX_GAIN_PROFILE_CPLD_NOATR) {
+ return ZBX_GAIN_STAGE_TABLE;
+ }
+ return ZBX_GAIN_STAGE_ALL;
+ })
+ , _unique_id(unique_id)
, _regs(reg_iface)
, _reg_base_address(reg_base_address)
, _time_accessor(time_accessor)
@@ -263,66 +278,6 @@ double zbx_dboard_impl::set_rx_gain(
return _tree->access<double>(gains_path / name / "value").set(gain).get();
}
-double zbx_dboard_impl::set_tx_gain(const double gain, const size_t chan)
-{
- const auto gain_profile = _tx_gain_profile_api->get_gain_profile(chan);
- if (gain_profile == ZBX_GAIN_PROFILE_MANUAL) {
- const std::string err_msg = "When using 'manual' gain mode, calling "
- "set_tx_gain() without a gain name is not allowed!";
- RFNOC_LOG_ERROR(err_msg);
- throw uhd::runtime_error(err_msg);
- }
- if (gain_profile == ZBX_GAIN_PROFILE_CPLD
- || gain_profile == ZBX_GAIN_PROFILE_CPLD_NOATR) {
- return set_tx_gain(gain, ZBX_GAIN_STAGE_TABLE, chan);
- }
- return set_tx_gain(gain, ZBX_GAIN_STAGE_ALL, chan);
-}
-
-double zbx_dboard_impl::set_rx_gain(const double gain, const size_t chan)
-{
- const auto gain_profile = _rx_gain_profile_api->get_gain_profile(chan);
- if (gain_profile == ZBX_GAIN_PROFILE_MANUAL) {
- const std::string err_msg = "When using 'manual' gain mode, calling "
- "set_rx_gain() without a gain name is not allowed!";
- RFNOC_LOG_ERROR(err_msg);
- throw uhd::runtime_error(err_msg);
- }
- if (gain_profile == ZBX_GAIN_PROFILE_CPLD
- || gain_profile == ZBX_GAIN_PROFILE_CPLD_NOATR) {
- return set_rx_gain(gain, ZBX_GAIN_STAGE_TABLE, chan);
- }
- return set_rx_gain(gain, ZBX_GAIN_STAGE_ALL, chan);
-}
-
-double zbx_dboard_impl::get_tx_gain(const size_t chan)
-{
- const auto gain_profile = _tx_gain_profile_api->get_gain_profile(chan);
- if (gain_profile == ZBX_GAIN_PROFILE_CPLD
- || gain_profile == ZBX_GAIN_PROFILE_CPLD_NOATR) {
- return get_tx_gain(ZBX_GAIN_STAGE_TABLE, chan);
- }
- if (gain_profile == ZBX_GAIN_PROFILE_DEFAULT) {
- return get_tx_gain(ZBX_GAIN_STAGE_ALL, chan);
- }
- throw uhd::runtime_error(
- "get_tx_gain(): When in 'manual' gain profile, a gain name is required!");
-}
-
-double zbx_dboard_impl::get_rx_gain(const size_t chan)
-{
- const auto gain_profile = _rx_gain_profile_api->get_gain_profile(chan);
- if (gain_profile == ZBX_GAIN_PROFILE_CPLD
- || gain_profile == ZBX_GAIN_PROFILE_CPLD_NOATR) {
- return get_rx_gain(ZBX_GAIN_STAGE_TABLE, chan);
- }
- if (gain_profile == ZBX_GAIN_PROFILE_DEFAULT) {
- return get_rx_gain(ZBX_GAIN_STAGE_ALL, chan);
- }
- throw uhd::runtime_error(
- "get_rx_gain(): When in 'manual' gain profile, a gain name is required!");
-}
-
double zbx_dboard_impl::get_tx_gain(const std::string& name_, const size_t chan)
{
// We have to accept the empty string for "all", because that's widely used
@@ -608,7 +563,7 @@ void zbx_dboard_impl::set_rx_agc(const bool, const size_t)
}
uhd::gain_range_t zbx_dboard_impl::get_tx_gain_range(
- const std::string& name, const size_t chan) const
+ const std::string& name, const size_t) const
{
// We have to accept the empty string for "all", because that's widely used
// (e.g. by multi_usrp)
@@ -616,11 +571,11 @@ uhd::gain_range_t zbx_dboard_impl::get_tx_gain_range(
throw uhd::value_error(
std::string("get_tx_gain_range(): Unknown gain name '") + name + "'!");
}
- return get_tx_gain_range(chan);
+ return ZBX_TX_GAIN_RANGE;
}
uhd::gain_range_t zbx_dboard_impl::get_rx_gain_range(
- const std::string& name, const size_t chan) const
+ const std::string& name, const size_t) const
{
// We have to accept the empty string for "all", because that's widely used
// (e.g. by multi_usrp)
@@ -628,7 +583,10 @@ uhd::gain_range_t zbx_dboard_impl::get_rx_gain_range(
throw uhd::value_error(
std::string("get_rx_gain_range(): Unknown gain name '") + name + "'!");
}
- return get_rx_gain_range(chan);
+
+ // FIXME This should return a ZBX_RX_LOW_FREQ_GAIN_RANGE when freq is
+ // low, but this function is const
+ return ZBX_RX_GAIN_RANGE;
}
void zbx_dboard_impl::set_rx_lo_export_enabled(bool, const std::string&, const size_t)
diff --git a/host/lib/usrp/dboard/zbx/zbx_dboard_init.cpp b/host/lib/usrp/dboard/zbx/zbx_dboard_init.cpp
index f0558f8a4..6871080ff 100644
--- a/host/lib/usrp/dboard/zbx/zbx_dboard_init.cpp
+++ b/host/lib/usrp/dboard/zbx/zbx_dboard_init.cpp
@@ -245,8 +245,8 @@ uhd::usrp::pwr_cal_mgr::sptr zbx_dboard_impl::_init_power_cal(
: get_rx_gain(ZBX_GAIN_STAGE_ALL, chan_idx);
},
[this, trx, chan_idx](const double gain) {
- trx == TX_DIRECTION ? set_tx_gain(gain, chan_idx)
- : set_rx_gain(gain, chan_idx);
+ trx == TX_DIRECTION ? this->set_tx_gain(gain, chan_idx)
+ : this->set_rx_gain(gain, chan_idx);
}},
10 /* High priority */);
/* If we had a digital (baseband) gain, we would register it here,*/