summaryrefslogtreecommitdiffstats
path: root/host/lib
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib')
-rw-r--r--host/lib/usrp/misc_utils.cpp4
-rw-r--r--host/lib/utils/gain_group.cpp26
2 files changed, 24 insertions, 6 deletions
diff --git a/host/lib/usrp/misc_utils.cpp b/host/lib/usrp/misc_utils.cpp
index 05308baba..499a6ebfb 100644
--- a/host/lib/usrp/misc_utils.cpp
+++ b/host/lib/usrp/misc_utils.cpp
@@ -95,7 +95,7 @@ gain_group::sptr usrp::make_gain_group(
fcns.get_range = boost::bind(&get_subdev_gain_range, subdev, name);
fcns.get_value = boost::bind(&get_subdev_gain, subdev, name);
fcns.set_value = boost::bind(&set_subdev_gain, subdev, name, _1);
- gg->register_fcns(fcns, subdev_gain_priority);
+ gg->register_fcns(name, fcns, subdev_gain_priority);
}
//add all the codec gains last (antenna to dsp order)
BOOST_FOREACH(const std::string &name, codec[CODEC_PROP_GAIN_NAMES].as<prop_names_t>()){
@@ -119,7 +119,7 @@ gain_group::sptr usrp::make_gain_group(
fcns.set_value = boost::bind(&set_codec_gain_q, codec, name, _1);
break;
}
- gg->register_fcns(fcns, codec_gain_priority);
+ gg->register_fcns(name, fcns, codec_gain_priority);
}
return gg;
}
diff --git a/host/lib/utils/gain_group.cpp b/host/lib/utils/gain_group.cpp
index 078fe56b2..54146726a 100644
--- a/host/lib/utils/gain_group.cpp
+++ b/host/lib/utils/gain_group.cpp
@@ -63,7 +63,9 @@ public:
/*NOP*/
}
- gain_range_t get_range(void){
+ gain_range_t get_range(const std::string &name){
+ if (not name.empty()) return _name_to_fcns[name].get_range();
+
float overall_min = 0, overall_max = 0, overall_step = 0;
BOOST_FOREACH(const gain_fcns_t &fcns, get_all_fcns()){
const gain_range_t range = fcns.get_range();
@@ -76,7 +78,9 @@ public:
return gain_range_t(overall_min, overall_max, overall_step);
}
- float get_value(void){
+ float get_value(const std::string &name){
+ if (not name.empty()) return _name_to_fcns[name].get_value();
+
float overall_gain = 0;
BOOST_FOREACH(const gain_fcns_t &fcns, get_all_fcns()){
overall_gain += fcns.get_value();
@@ -84,7 +88,9 @@ public:
return overall_gain;
}
- void set_value(float gain){
+ void set_value(float gain, const std::string &name){
+ if (not name.empty()) return _name_to_fcns[name].set_value(gain);
+
std::vector<gain_fcns_t> all_fcns = get_all_fcns();
if (all_fcns.size() == 0) return; //nothing to set!
@@ -140,10 +146,21 @@ public:
}
}
+ const std::vector<std::string> get_names(void){
+ return _name_to_fcns.keys();
+ }
+
void register_fcns(
- const gain_fcns_t &gain_fcns, size_t priority
+ const std::string &name,
+ const gain_fcns_t &gain_fcns,
+ size_t priority
){
+ if (name.empty() or _name_to_fcns.has_key(name)){
+ //ensure the name name is unique and non-empty
+ return register_fcns(name + "_", gain_fcns, priority);
+ }
_registry[priority].push_back(gain_fcns);
+ _name_to_fcns[name] = gain_fcns;
}
private:
@@ -158,6 +175,7 @@ private:
}
uhd::dict<size_t, std::vector<gain_fcns_t> > _registry;
+ uhd::dict<std::string, gain_fcns_t> _name_to_fcns;
};
/***********************************************************************