Commit 437919d9 authored by Martin Braun's avatar Martin Braun

rfnoc: Add update_graph() API call

Blocks that change scaling, tick rate, or sampling rate can now notify
the graph to update streamers. Before, this was handled only by
mult_usrp, and only for DDC and DUC blocks.
parent f90f5725
//
// Copyright 2014-2016 Ettus Research LLC
// Copyright 2018 Ettus Research, a National Instruments Company
// Copyright 2019 Ettus Research, a National Instruments Brand
//
// SPDX-License-Identifier: GPL-3.0-or-later
//
......@@ -20,6 +21,11 @@
#include <map>
#include <set>
namespace uhd { namespace usrp {
// Forward declaration for friend clause
class device3_impl;
}}
namespace uhd { namespace rfnoc {
#define UHD_RFNOC_BLOCK_TRACE() UHD_LOGGER_TRACE("RFNOC")
......@@ -39,6 +45,7 @@ public:
typedef boost::weak_ptr<node_ctrl_base> wptr;
typedef std::map<size_t, wptr> node_map_t;
typedef std::pair<size_t, wptr> node_map_pair_t;
typedef boost::function<void(void)> graph_update_cb_t;
/***********************************************************************
* Node control
......@@ -238,7 +245,18 @@ protected:
*/
virtual void _register_upstream_node(node_ctrl_base::sptr upstream_node, size_t port);
/*! Initiate the update graph callback
*
* Call this from your block when you've changed one of these:
* - sampling rate
* - scaling
* - tick rate
*/
void update_graph() { _graph_update_cb(); }
private:
friend class uhd::usrp::device3_impl;
/*! Implements the search algorithm for find_downstream_node() and
* find_upstream_node().
*
......@@ -264,6 +282,11 @@ private:
value_type NULL_VALUE,
const std::set<boost::shared_ptr<T> >& exclude_nodes);
void set_graph_update_cb(graph_update_cb_t graph_update_cb)
{
_graph_update_cb = graph_update_cb;
}
/*! Stores the remote port number of a downstream connection.
*/
std::map<size_t, size_t> _upstream_ports;
......@@ -272,6 +295,8 @@ private:
*/
std::map<size_t, size_t> _downstream_ports;
graph_update_cb_t _graph_update_cb;
}; /* class node_ctrl_base */
}} /* namespace uhd::rfnoc */
......
......@@ -52,11 +52,12 @@ public:
.set_coercer([this, chan](const double value) {
return this->set_output_rate(value, chan);
})
.set(default_output_rate);
.set(default_output_rate)
.add_coerced_subscriber([this](const double) { update_graph(); });
_tree->access<double>(get_arg_path("input_rate/value", chan))
.add_coerced_subscriber([this, chan](const double rate) {
this->set_input_rate(rate, chan);
});
.add_coerced_subscriber(
[this, chan](const double rate) { this->set_input_rate(rate, chan); })
.add_coerced_subscriber([this](const double) { update_graph(); });
// Legacy properties (for backward compat w/ multi_usrp)
const uhd::fs_path dsp_base_path = _root_path / "legacy_api" / chan;
......
......@@ -53,11 +53,13 @@ public:
.set_coercer([this, chan](const double value) {
return this->set_input_rate(value, chan);
})
.set(default_input_rate);
.set(default_input_rate)
.add_coerced_subscriber([this](const double) { update_graph(); });
_tree->access<double>(get_arg_path("output_rate/value", chan))
.add_coerced_subscriber([this, chan](const double rate) {
this->set_output_rate(rate, chan);
});
})
.add_coerced_subscriber([this](const double) { update_graph(); });
// Legacy properties (for backward compat w/ multi_usrp)
const uhd::fs_path dsp_base_path = _root_path / "legacy_api" / chan;
......
......@@ -406,9 +406,6 @@ public:
.set(rate);
}
}
// Update streamers:
boost::dynamic_pointer_cast<uhd::usrp::device3_impl>(_device)
->update_rx_streamers();
}
void set_tx_rate(const double rate, const size_t chan)
......@@ -458,9 +455,6 @@ public:
.set(rate);
}
}
// Update streamers:
boost::dynamic_pointer_cast<uhd::usrp::device3_impl>(_device)
->update_tx_streamers();
}
private: // types
......
......@@ -165,6 +165,11 @@ void device3_impl::enumerate_rfnoc_blocks(size_t device_index,
boost::lock_guard<boost::mutex> lock(_block_ctrl_mutex);
_rfnoc_block_ctrl.push_back(
uhd::rfnoc::block_ctrl_base::make(make_args, noc_id));
_rfnoc_block_ctrl.back()->set_graph_update_cb([this]() {
UHD_LOG_WARNING("DEVICE3", "Updating Streamers");
update_rx_streamers();
update_tx_streamers();
});
}
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment