From 12673d9290319d2453fedd806ddf248d3d5586e3 Mon Sep 17 00:00:00 2001 From: Lane Kolbly Date: Thu, 18 Jun 2020 17:46:06 -0500 Subject: uhd: Split radio_control into rf_control interfaces These rf_control interfaces allow easier implementation of radio controls as well as allowing easier sharing of code for implementing e.g. gain_profile. --- .../include/uhdlib/rfnoc/radio_control_impl.hpp | 5 ++ .../uhdlib/rfnoc/rf_control/dboard_iface.hpp | 41 +++++++++++ .../uhdlib/rfnoc/rf_control/gain_profile_iface.hpp | 86 ++++++++++++++++++++++ 3 files changed, 132 insertions(+) create mode 100644 host/lib/include/uhdlib/rfnoc/rf_control/dboard_iface.hpp create mode 100644 host/lib/include/uhdlib/rfnoc/rf_control/gain_profile_iface.hpp (limited to 'host/lib/include') diff --git a/host/lib/include/uhdlib/rfnoc/radio_control_impl.hpp b/host/lib/include/uhdlib/rfnoc/radio_control_impl.hpp index f60319d32..2a93fbfa5 100644 --- a/host/lib/include/uhdlib/rfnoc/radio_control_impl.hpp +++ b/host/lib/include/uhdlib/rfnoc/radio_control_impl.hpp @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include #include @@ -322,6 +324,9 @@ protected: // simply leave these empty. std::vector _tx_pwr_mgr; + rf_control::gain_profile_iface::sptr _tx_gain_profile_api; + rf_control::gain_profile_iface::sptr _rx_gain_profile_api; + private: //! Validator for the async messages // diff --git a/host/lib/include/uhdlib/rfnoc/rf_control/dboard_iface.hpp b/host/lib/include/uhdlib/rfnoc/rf_control/dboard_iface.hpp new file mode 100644 index 000000000..1651a1580 --- /dev/null +++ b/host/lib/include/uhdlib/rfnoc/rf_control/dboard_iface.hpp @@ -0,0 +1,41 @@ +// +// Copyright 2020 Ettus Research, a National Instruments Brand +// +// SPDX-License-Identifier: GPL-3.0-or-later +// + +#pragma once + +#include +#include +#include +#include + +namespace uhd { namespace rfnoc { namespace rf_control { + +/*! Interface that daughterboards expose to the motherboard radio_control + * + * This interface contains everything required for a daughterboard to implement + * all the methods required for radio_control. For the most part, this class + * just includes accessors to objects which implement the required functionality. + * This class also directly implements core_iface for the remainder. + */ +class dboard_iface : public core_iface +{ +public: + using sptr = std::shared_ptr; + + virtual ~dboard_iface() = default; + + virtual gain_profile_iface::sptr get_tx_gain_profile_api() = 0; + virtual gain_profile_iface::sptr get_rx_gain_profile_api() = 0; + + virtual size_t get_chan_from_dboard_fe( + const std::string&, uhd::direction_t) const = 0; + virtual std::string get_dboard_fe_from_chan(size_t chan, uhd::direction_t) const = 0; + + virtual std::vector& get_pwr_mgr( + uhd::direction_t trx) = 0; +}; + +}}} // namespace uhd::rfnoc::rf_control diff --git a/host/lib/include/uhdlib/rfnoc/rf_control/gain_profile_iface.hpp b/host/lib/include/uhdlib/rfnoc/rf_control/gain_profile_iface.hpp new file mode 100644 index 000000000..f93a42936 --- /dev/null +++ b/host/lib/include/uhdlib/rfnoc/rf_control/gain_profile_iface.hpp @@ -0,0 +1,86 @@ +// +// Copyright 2020 Ettus Research, a National Instruments Brand +// +// SPDX-License-Identifier: GPL-3.0-or-later +// + +#pragma once + +#include +#include +#include + +namespace uhd { namespace rfnoc { namespace rf_control { + +/*! Interface for gain profile API commands + * + * This interface contains methods to configure the current gain profile of the + * device. Note that this interface is RX/TX agnostic, it does not provide + * specialized methods for RX and TX. + */ +class gain_profile_iface +{ +public: + using sptr = std::shared_ptr; + + virtual ~gain_profile_iface() = default; + + /*! Return a list of TX gain profiles for this radio + */ + virtual std::vector get_gain_profile_names(const size_t chan) const = 0; + + /*! Set the gain profile + */ + virtual void set_gain_profile(const std::string& profile, const size_t chan) = 0; + + /*! Return the gain profile + */ + virtual std::string get_gain_profile(const size_t chan) const = 0; +}; + +/*! "Default" implementation for gain_profile_iface + * + * This class implements gain_profile_iface such that the device is always + * and can only be configured using a single "default" gain profile. Setting + * a gain profile which is not the default profile is an error, and getting the + * gain profile will always return the default profile. + */ +class default_gain_profile : public gain_profile_iface +{ +public: + std::vector get_gain_profile_names(const size_t chan) const override; + + void set_gain_profile(const std::string& profile, const size_t chan) override; + std::string get_gain_profile(const size_t chan) const override; + +private: + static const std::string DEFAULT_GAIN_PROFILE; +}; + +/*! "Enumerated" implementation for gain_profile_iface + * + * This class implements gain_profile_iface so that the gain profile can only be + * one of several different enumerated values. Setting an invalid gain profile + * is an error. Retrieving a gain profile will always return one of the + * enumerated gain profiles. + */ +class enumerated_gain_profile : public gain_profile_iface +{ +public: + enumerated_gain_profile(const std::vector& possible_profiles, + const std::string& default_profile, + size_t num_channels); + + void set_gain_profile(const std::string& profile, const size_t chan) override; + + std::string get_gain_profile(const size_t chan) const override; + + std::vector get_gain_profile_names(const size_t) const override; + +private: + std::vector _possible_profiles; + + std::vector _gain_profile; +}; + +}}} // namespace uhd::rfnoc::rf_control -- cgit v1.2.3