summaryrefslogtreecommitdiff
path: root/gr-uhd/lib/usrp_source_impl.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gr-uhd/lib/usrp_source_impl.cc')
-rw-r--r--gr-uhd/lib/usrp_source_impl.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/gr-uhd/lib/usrp_source_impl.cc b/gr-uhd/lib/usrp_source_impl.cc
index c840c43db1..a4ff3107b6 100644
--- a/gr-uhd/lib/usrp_source_impl.cc
+++ b/gr-uhd/lib/usrp_source_impl.cc
@@ -154,12 +154,16 @@ namespace gr {
void usrp_source_impl::set_normalized_gain(double norm_gain, size_t chan)
{
+#ifdef UHD_USRP_MULTI_USRP_NORMALIZED_GAIN
+ _dev->set_normalized_rx_gain(norm_gain, chan);
+#else
if (norm_gain > 1.0 || norm_gain < 0.0) {
throw std::runtime_error("Normalized gain out of range, must be in [0, 1].");
}
::uhd::gain_range_t gain_range = get_gain_range(chan);
double abs_gain = (norm_gain * (gain_range.stop() - gain_range.start())) + gain_range.start();
set_gain(abs_gain, chan);
+#endif
}
double
@@ -179,6 +183,9 @@ namespace gr {
double
usrp_source_impl::get_normalized_gain(size_t chan)
{
+#ifdef UHD_USRP_MULTI_USRP_NORMALIZED_GAIN
+ return _dev->get_normalized_rx_gain(chan);
+#else
::uhd::gain_range_t gain_range = get_gain_range(chan);
double norm_gain =
(get_gain(chan) - gain_range.start()) /
@@ -187,6 +194,7 @@ namespace gr {
if (norm_gain > 1.0) return 1.0;
if (norm_gain < 0.0) return 0.0;
return norm_gain;
+#endif
}
std::vector<std::string>