aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib
diff options
context:
space:
mode:
authorAshish Chaudhari <ashish@ettus.com>2016-02-19 17:42:44 -0800
committerAshish Chaudhari <ashish@ettus.com>2016-02-26 14:23:40 -0800
commit6db9ac785ca5f62e58cf792f0525b37b16a87bdf (patch)
treeb64f0fb76253531b3dc88c22a795e0f79b556df0 /host/lib
parentc03506fedd75a7fbad242d2be06123a187e66277 (diff)
downloaduhd-6db9ac785ca5f62e58cf792f0525b37b16a87bdf.tar.gz
uhd-6db9ac785ca5f62e58cf792f0525b37b16a87bdf.tar.bz2
uhd-6db9ac785ca5f62e58cf792f0525b37b16a87bdf.zip
dboards: Added ability to register a per-dboard container class
- The typical dboard classes are actually "subdev" classes i.e. there is one instance per dboard subdev (front-end). This makes it hard to implement shared functionality between multiple front-ends. - This changes adds the ability to create a container class which is created per group of subdevs and each subdev gets a pointer to the container class for cross linkage.
Diffstat (limited to 'host/lib')
-rw-r--r--host/lib/usrp/dboard_base.cpp2
-rw-r--r--host/lib/usrp/dboard_ctor_args.hpp8
-rw-r--r--host/lib/usrp/dboard_manager.cpp131
3 files changed, 101 insertions, 40 deletions
diff --git a/host/lib/usrp/dboard_base.cpp b/host/lib/usrp/dboard_base.cpp
index fe14c02b9..465b9e489 100644
--- a/host/lib/usrp/dboard_base.cpp
+++ b/host/lib/usrp/dboard_base.cpp
@@ -32,7 +32,7 @@ struct dboard_base::impl{
dboard_base::dboard_base(ctor_args_t args){
_impl = UHD_PIMPL_MAKE(impl, ());
- _impl->args = *static_cast<dboard_ctor_args_t *>(args);
+ _impl->args = dboard_ctor_args_t::cast(args);
}
std::string dboard_base::get_subdev_name(void){
diff --git a/host/lib/usrp/dboard_ctor_args.hpp b/host/lib/usrp/dboard_ctor_args.hpp
index 99c071ff8..c8e4006d1 100644
--- a/host/lib/usrp/dboard_ctor_args.hpp
+++ b/host/lib/usrp/dboard_ctor_args.hpp
@@ -26,11 +26,17 @@
namespace uhd{ namespace usrp{
- struct dboard_ctor_args_t{
+ class dboard_ctor_args_t {
+ public:
std::string sd_name;
dboard_iface::sptr db_iface;
dboard_id_t rx_id, tx_id;
property_tree::sptr rx_subtree, tx_subtree;
+ dboard_base::sptr rx_container, tx_container;
+
+ static const dboard_ctor_args_t& cast(dboard_base::ctor_args_t args) {
+ return *static_cast<dboard_ctor_args_t*>(args);
+ }
};
}} //namespace
diff --git a/host/lib/usrp/dboard_manager.cpp b/host/lib/usrp/dboard_manager.cpp
index 3a0101b17..544d6d70d 100644
--- a/host/lib/usrp/dboard_manager.cpp
+++ b/host/lib/usrp/dboard_manager.cpp
@@ -83,8 +83,8 @@ bool operator==(const dboard_key_t &lhs, const dboard_key_t &rhs){
/***********************************************************************
* storage and registering for dboards
**********************************************************************/
-//dboard registry tuple: dboard constructor, canonical name, subdev names
-typedef boost::tuple<dboard_manager::dboard_ctor_t, std::string, std::vector<std::string> > args_t;
+//dboard registry tuple: dboard constructor, canonical name, subdev names, container constructor
+typedef boost::tuple<dboard_manager::dboard_ctor_t, std::string, std::vector<std::string>, dboard_manager::dboard_ctor_t> args_t;
//map a dboard id to a dboard constructor
typedef uhd::dict<dboard_key_t, args_t> id_to_args_map_t;
@@ -92,9 +92,10 @@ UHD_SINGLETON_FCN(id_to_args_map_t, get_id_to_args_map)
static void register_dboard_key(
const dboard_key_t &dboard_key,
- dboard_manager::dboard_ctor_t dboard_ctor,
+ dboard_manager::dboard_ctor_t db_subdev_ctor,
const std::string &name,
- const std::vector<std::string> &subdev_names
+ const std::vector<std::string> &subdev_names,
+ dboard_manager::dboard_ctor_t db_container_ctor
){
UHD_LOGV(always) << "registering: " << name << std::endl;
if (get_id_to_args_map().has_key(dboard_key)){
@@ -108,45 +109,49 @@ static void register_dboard_key(
) % dboard_key.xx_id().to_string() % get_id_to_args_map()[dboard_key].get<1>()));
}
- get_id_to_args_map()[dboard_key] = args_t(dboard_ctor, name, subdev_names);
+ get_id_to_args_map()[dboard_key] = args_t(db_subdev_ctor, name, subdev_names, db_container_ctor);
}
void dboard_manager::register_dboard(
const dboard_id_t &dboard_id,
- dboard_ctor_t dboard_ctor,
+ dboard_ctor_t db_subdev_ctor,
const std::string &name,
- const std::vector<std::string> &subdev_names
+ const std::vector<std::string> &subdev_names,
+ dboard_ctor_t db_container_ctor
){
- register_dboard_key(dboard_key_t(dboard_id), dboard_ctor, name, subdev_names);
+ register_dboard_key(dboard_key_t(dboard_id), db_subdev_ctor, name, subdev_names, db_container_ctor);
}
void dboard_manager::register_dboard(
const dboard_id_t &rx_dboard_id,
const dboard_id_t &tx_dboard_id,
- dboard_ctor_t dboard_ctor,
+ dboard_ctor_t db_subdev_ctor,
const std::string &name,
- const std::vector<std::string> &subdev_names
+ const std::vector<std::string> &subdev_names,
+ dboard_ctor_t db_container_ctor
){
- register_dboard_key(dboard_key_t(rx_dboard_id, tx_dboard_id), dboard_ctor, name, subdev_names);
+ register_dboard_key(dboard_key_t(rx_dboard_id, tx_dboard_id), db_subdev_ctor, name, subdev_names, db_container_ctor);
}
void dboard_manager::register_dboard_restricted(
const dboard_id_t &dboard_id,
- dboard_ctor_t dboard_ctor,
+ dboard_ctor_t db_subdev_ctor,
const std::string &name,
- const std::vector<std::string> &subdev_names
+ const std::vector<std::string> &subdev_names,
+ dboard_ctor_t db_container_ctor
){
- register_dboard_key(dboard_key_t(dboard_id, true), dboard_ctor, name, subdev_names);
+ register_dboard_key(dboard_key_t(dboard_id, true), db_subdev_ctor, name, subdev_names, db_container_ctor);
}
void dboard_manager::register_dboard_restricted(
const dboard_id_t &rx_dboard_id,
const dboard_id_t &tx_dboard_id,
- dboard_ctor_t dboard_ctor,
+ dboard_ctor_t db_subdev_ctor,
const std::string &name,
- const std::vector<std::string> &subdev_names
+ const std::vector<std::string> &subdev_names,
+ dboard_ctor_t db_container_ctor
){
- register_dboard_key(dboard_key_t(rx_dboard_id, tx_dboard_id, true), dboard_ctor, name, subdev_names);
+ register_dboard_key(dboard_key_t(rx_dboard_id, tx_dboard_id, true), db_subdev_ctor, name, subdev_names, db_container_ctor);
}
std::string dboard_id_t::to_cname(void) const{
@@ -282,42 +287,76 @@ void dboard_manager_impl::init(
if (xcvr_dboard_key.is_xcvr()){
//extract data for the xcvr dboard key
- dboard_ctor_t dboard_ctor; std::string name; std::vector<std::string> subdevs;
- boost::tie(dboard_ctor, name, subdevs) = get_id_to_args_map()[xcvr_dboard_key];
+ dboard_ctor_t subdev_ctor; std::string name; std::vector<std::string> subdevs; dboard_ctor_t container_ctor;
+ boost::tie(subdev_ctor, name, subdevs, container_ctor) = get_id_to_args_map()[xcvr_dboard_key];
+
+ //create the container class.
+ //a container class exists per N subdevs registered in a register_dboard* call
+ db_ctor_args.sd_name = "common";
+ db_ctor_args.rx_id = rx_dboard_id;
+ db_ctor_args.tx_id = tx_dboard_id;
+ db_ctor_args.rx_subtree = subtree->subtree("rx_frontends/" + db_ctor_args.sd_name);
+ db_ctor_args.tx_subtree = subtree->subtree("tx_frontends/" + db_ctor_args.sd_name);
+ if (container_ctor) {
+ db_ctor_args.rx_container = container_ctor(&db_ctor_args);
+ } else {
+ db_ctor_args.rx_container = dboard_base::sptr();
+ }
+ db_ctor_args.tx_container = db_ctor_args.rx_container; //Same TX and RX container
//create the xcvr object for each subdevice
BOOST_FOREACH(const std::string &subdev, subdevs){
db_ctor_args.sd_name = subdev;
- db_ctor_args.rx_id = rx_dboard_id;
- db_ctor_args.tx_id = tx_dboard_id;
- db_ctor_args.rx_subtree = subtree->subtree("rx_frontends/" + subdev);
- db_ctor_args.tx_subtree = subtree->subtree("tx_frontends/" + subdev);
- dboard_base::sptr xcvr_dboard = dboard_ctor(&db_ctor_args);
+ db_ctor_args.rx_subtree = subtree->subtree("rx_frontends/" + db_ctor_args.sd_name);
+ db_ctor_args.tx_subtree = subtree->subtree("tx_frontends/" + db_ctor_args.sd_name);
+ dboard_base::sptr xcvr_dboard = subdev_ctor(&db_ctor_args);
_rx_dboards[subdev] = xcvr_dboard;
_tx_dboards[subdev] = xcvr_dboard;
+ xcvr_dboard->initialize();
+ }
+
+ //initialize the container after all subdevs have been created
+ if (container_ctor) {
+ db_ctor_args.rx_container->initialize();
}
}
//make tx and rx subdevs (separate subdevs for rx and tx dboards)
- else{
-
+ else
+ {
//force the rx key to the unknown board for bad combinations
if (rx_dboard_key.is_xcvr() or rx_dboard_key.xx_id() == dboard_id_t::none()){
rx_dboard_key = dboard_key_t(0xfff1);
}
//extract data for the rx dboard key
- dboard_ctor_t rx_dboard_ctor; std::string rx_name; std::vector<std::string> rx_subdevs;
- boost::tie(rx_dboard_ctor, rx_name, rx_subdevs) = get_id_to_args_map()[rx_dboard_key];
+ dboard_ctor_t rx_dboard_ctor; std::string rx_name; std::vector<std::string> rx_subdevs; dboard_ctor_t rx_cont_ctor;
+ boost::tie(rx_dboard_ctor, rx_name, rx_subdevs, rx_cont_ctor) = get_id_to_args_map()[rx_dboard_key];
+
+ //create the container class.
+ //a container class exists per N subdevs registered in a register_dboard* call
+ db_ctor_args.sd_name = "common";
+ db_ctor_args.rx_id = rx_dboard_id;
+ db_ctor_args.tx_id = dboard_id_t::none();
+ db_ctor_args.rx_subtree = subtree->subtree("rx_frontends/" + db_ctor_args.sd_name);
+ db_ctor_args.tx_subtree = property_tree::sptr();
+ if (rx_cont_ctor) {
+ db_ctor_args.rx_container = rx_cont_ctor(&db_ctor_args);
+ } else {
+ db_ctor_args.rx_container = dboard_base::sptr();
+ }
//make the rx subdevs
BOOST_FOREACH(const std::string &subdev, rx_subdevs){
db_ctor_args.sd_name = subdev;
- db_ctor_args.rx_id = rx_dboard_id;
- db_ctor_args.tx_id = dboard_id_t::none();
- db_ctor_args.rx_subtree = subtree->subtree("rx_frontends/" + subdev);
- db_ctor_args.tx_subtree = property_tree::sptr(); //null
+ db_ctor_args.rx_subtree = subtree->subtree("rx_frontends/" + db_ctor_args.sd_name);
_rx_dboards[subdev] = rx_dboard_ctor(&db_ctor_args);
+ _rx_dboards[subdev]->initialize();
+ }
+
+ //initialize the container after all subdevs have been created
+ if (rx_cont_ctor) {
+ db_ctor_args.rx_container->initialize();
}
//force the tx key to the unknown board for bad combinations
@@ -326,17 +365,33 @@ void dboard_manager_impl::init(
}
//extract data for the tx dboard key
- dboard_ctor_t tx_dboard_ctor; std::string tx_name; std::vector<std::string> tx_subdevs;
- boost::tie(tx_dboard_ctor, tx_name, tx_subdevs) = get_id_to_args_map()[tx_dboard_key];
+ dboard_ctor_t tx_dboard_ctor; std::string tx_name; std::vector<std::string> tx_subdevs; dboard_ctor_t tx_cont_ctor;
+ boost::tie(tx_dboard_ctor, tx_name, tx_subdevs, tx_cont_ctor) = get_id_to_args_map()[tx_dboard_key];
+
+ //create the container class.
+ //a container class exists per N subdevs registered in a register_dboard* call
+ db_ctor_args.sd_name = "common";
+ db_ctor_args.rx_id = dboard_id_t::none();
+ db_ctor_args.tx_id = tx_dboard_id;
+ db_ctor_args.rx_subtree = property_tree::sptr();
+ db_ctor_args.tx_subtree = subtree->subtree("tx_frontends/" + db_ctor_args.sd_name);
+ if (tx_cont_ctor) {
+ db_ctor_args.tx_container = tx_cont_ctor(&db_ctor_args);
+ } else {
+ db_ctor_args.tx_container = dboard_base::sptr();
+ }
//make the tx subdevs
BOOST_FOREACH(const std::string &subdev, tx_subdevs){
db_ctor_args.sd_name = subdev;
- db_ctor_args.rx_id = dboard_id_t::none();
- db_ctor_args.tx_id = tx_dboard_id;
- db_ctor_args.rx_subtree = property_tree::sptr(); //null
- db_ctor_args.tx_subtree = subtree->subtree("tx_frontends/" + subdev);
+ db_ctor_args.tx_subtree = subtree->subtree("tx_frontends/" + db_ctor_args.sd_name);
_tx_dboards[subdev] = tx_dboard_ctor(&db_ctor_args);
+ _tx_dboards[subdev]->initialize();
+ }
+
+ //initialize the container after all subdevs have been created
+ if (tx_cont_ctor) {
+ db_ctor_args.tx_container->initialize();
}
}
}