aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/include
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/include
parent72e9ba55d6b144d456a644cb47f40522022d4fb6 (diff)
downloaduhd-4e391500b54a22dbaae8692750ec25ae8a97ee6d.tar.gz
uhd-4e391500b54a22dbaae8692750ec25ae8a97ee6d.tar.bz2
uhd-4e391500b54a22dbaae8692750ec25ae8a97ee6d.zip
host: Implement nameless_gain_mixin
Diffstat (limited to 'host/lib/include')
-rw-r--r--host/lib/include/uhdlib/rfnoc/rf_control/nameless_gain_mixin.hpp58
-rw-r--r--host/lib/include/uhdlib/usrp/dboard/zbx/zbx_dboard.hpp26
2 files changed, 68 insertions, 16 deletions
diff --git a/host/lib/include/uhdlib/rfnoc/rf_control/nameless_gain_mixin.hpp b/host/lib/include/uhdlib/rfnoc/rf_control/nameless_gain_mixin.hpp
new file mode 100644
index 000000000..149623352
--- /dev/null
+++ b/host/lib/include/uhdlib/rfnoc/rf_control/nameless_gain_mixin.hpp
@@ -0,0 +1,58 @@
+//
+// Copyright 2021 Ettus Research, a National Instruments Brand
+//
+// SPDX-License-Identifier: GPL-3.0-or-later
+//
+
+#pragma once
+
+#include <uhd/property_tree.hpp>
+#include <uhd/rfnoc/rf_control/core_iface.hpp>
+#include <uhd/types/direction.hpp>
+#include <unordered_map>
+#include <functional>
+#include <memory>
+#include <string>
+#include <vector>
+
+namespace uhd { namespace rfnoc { namespace rf_control {
+
+/*! Partially implements core_iface for the gain functions which take no name parameter
+ */
+class nameless_gain_mixin : virtual public core_iface
+{
+public:
+ using name_selector =
+ std::function<std::string(const uhd::direction_t trx, const size_t chan)>;
+
+ /*! Sets the name selector for the mixin. The closure receives the direction
+ * of the call and the channel, and returns the gain to use for the call. The
+ * name selector may simply return a string, or may do a more complex algorithm.
+ */
+ nameless_gain_mixin(name_selector name_selector);
+
+ virtual ~nameless_gain_mixin() = default;
+
+ double set_tx_gain(const double gain, const size_t chan) override;
+ double get_tx_gain(const size_t chan) override;
+
+ double set_rx_gain(const double gain, const size_t chan) override;
+ double get_rx_gain(const size_t chan) override;
+
+ // Getting the gain ranges is a bit different - these always use the empty name
+ gain_range_t get_tx_gain_range(const size_t chan) const override;
+ gain_range_t get_rx_gain_range(const size_t chan) const override;
+
+private:
+ name_selector _name_selector;
+
+ using core_iface::get_tx_gain;
+ using core_iface::get_tx_gain_range;
+ using core_iface::set_tx_gain;
+
+ using core_iface::get_rx_gain;
+ using core_iface::get_rx_gain_range;
+ using core_iface::set_rx_gain;
+};
+
+}}} // namespace uhd::rfnoc::rf_control
diff --git a/host/lib/include/uhdlib/usrp/dboard/zbx/zbx_dboard.hpp b/host/lib/include/uhdlib/usrp/dboard/zbx/zbx_dboard.hpp
index 6e1d31381..60666fd83 100644
--- a/host/lib/include/uhdlib/usrp/dboard/zbx/zbx_dboard.hpp
+++ b/host/lib/include/uhdlib/usrp/dboard/zbx/zbx_dboard.hpp
@@ -22,6 +22,7 @@
#include <uhdlib/experts/expert_factory.hpp>
#include <uhdlib/rfnoc/rf_control/dboard_iface.hpp>
#include <uhdlib/rfnoc/rf_control/antenna_iface.hpp>
+#include <uhdlib/rfnoc/rf_control/nameless_gain_mixin.hpp>
#include <uhdlib/usrp/common/mpmd_mb_controller.hpp>
#include <uhdlib/usrp/common/pwr_cal_mgr.hpp>
#include <uhdlib/usrp/common/rpc.hpp>
@@ -43,7 +44,8 @@ const static uint16_t ZBX_PID = 0x4002;
*/
class zbx_dboard_impl :
public uhd::usrp::x400::x400_dboard_iface,
- public uhd::rfnoc::rf_control::antenna_radio_control_mixin
+ public uhd::rfnoc::rf_control::antenna_radio_control_mixin,
+ public uhd::rfnoc::rf_control::nameless_gain_mixin
{
public:
using sptr = std::shared_ptr<zbx_dboard_impl>;
@@ -140,28 +142,20 @@ public:
.get();
}
- double set_tx_gain(const double gain, const size_t chan) override;
+ using core_iface::set_tx_gain;
+ using core_iface::get_tx_gain;
+ using core_iface::set_rx_gain;
+ using core_iface::get_rx_gain;
+ using core_iface::get_tx_gain_range;
+ using core_iface::get_rx_gain_range;
+
double set_tx_gain(
const double gain, const std::string& name, const size_t chan) override;
- double set_rx_gain(const double gain, const size_t chan) override;
double set_rx_gain(
const double gain, const std::string& name, const size_t chan) override;
- double get_rx_gain(const size_t chan) override;
- double get_tx_gain(const size_t chan) override;
double get_rx_gain(const std::string& name, const size_t chan) override;
double get_tx_gain(const std::string& name, const size_t chan) override;
- uhd::gain_range_t get_tx_gain_range(const size_t /*chan*/) const override
- {
- return ZBX_TX_GAIN_RANGE;
- }
- uhd::gain_range_t get_rx_gain_range(const size_t /*chan*/) const override
- {
- // 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;
- }
-
// LO Property Getters
std::vector<std::string> get_tx_lo_names(const size_t /*chan*/) const override
{