aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.cpp
diff options
context:
space:
mode:
authorTrung N Tran <trung.tran@ettus.com>2018-01-04 11:32:24 -0800
committerMartin Braun <martin.braun@ettus.com>2018-01-12 16:26:03 -0800
commit00402669d08b206f3b0367f5f4e3383d25e7944b (patch)
tree1ab5948382dde42f164499ce8e1cd68c3c4d959c /host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.cpp
parent7ffea3746be77cf926db946987ee83d48a33c798 (diff)
downloaduhd-00402669d08b206f3b0367f5f4e3383d25e7944b.tar.gz
uhd-00402669d08b206f3b0367f5f4e3383d25e7944b.tar.bz2
uhd-00402669d08b206f3b0367f5f4e3383d25e7944b.zip
mg: add facility that handle individual gain
-Create name for each gain/att element -Create property tree entry for each gain and their handlers. -Create gain profile that control how gain distributed. Right now, it is either "default" or "manual".
Diffstat (limited to 'host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.cpp')
-rw-r--r--host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.cpp89
1 files changed, 89 insertions, 0 deletions
diff --git a/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.cpp b/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.cpp
index 2c7121c5c..eb4894e19 100644
--- a/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.cpp
+++ b/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.cpp
@@ -412,6 +412,50 @@ double magnesium_radio_ctrl_impl::set_tx_gain(
return coerced_gain;
}
+double magnesium_radio_ctrl_impl::_set_tx_gain(
+ const std::string &name,
+ const double gain,
+ const size_t chan
+) {
+ std::lock_guard<std::mutex> l(_set_lock);
+ UHD_LOG_TRACE(unique_id(),
+ "_set_tx_gain(name=" << name << ", gain=" << gain << ", chan=" << chan << ")");
+ if (name == MAGNESIUM_GAIN1){
+ _ad9371_att[TX_DIRECTION] = gain;
+ }else if (name == MAGNESIUM_GAIN2){
+ _dsa_att[TX_DIRECTION] = gain;
+ }else if (name == MAGNESIUM_AMP){
+ _amp_bypass[TX_DIRECTION] = gain == 0.0;
+ }else {
+ throw uhd::value_error("Could not find gain element " + name);
+ }
+ UHD_LOG_TRACE(unique_id(),
+ "_set_tx_gain calling update gain");
+ this->_set_all_gain(
+ this->_get_all_gain(chan, TX_DIRECTION),
+ this->get_tx_frequency(chan),
+ chan,
+ TX_DIRECTION
+ );
+ return gain; // not really any coreced here for individual gain
+}
+
+double magnesium_radio_ctrl_impl::_get_tx_gain(
+ const std::string &name,
+ const size_t chan
+) {
+ std::lock_guard<std::mutex> l(_set_lock);
+ if (name == MAGNESIUM_GAIN1){
+ return _ad9371_att[TX_DIRECTION];
+ }else if (name == MAGNESIUM_GAIN2){
+ return _dsa_att[TX_DIRECTION];
+ }else if (name == MAGNESIUM_AMP){
+ return _amp_bypass[TX_DIRECTION]? AMP_MIN_GAIN : AMP_MAX_GAIN;
+ }else {
+ throw uhd::value_error("Could not find gain element " + name);
+ }
+}
+
double magnesium_radio_ctrl_impl::set_rx_gain(
const double gain,
const size_t chan
@@ -429,6 +473,51 @@ double magnesium_radio_ctrl_impl::set_rx_gain(
return coerced_gain;
}
+double magnesium_radio_ctrl_impl::_set_rx_gain(
+ const std::string &name,
+ const double gain,
+ const size_t chan
+) {
+ std::lock_guard<std::mutex> l(_set_lock);
+ UHD_LOG_TRACE(unique_id(),
+ "_set_rx_gain(name=" << name << ", gain=" << gain << ", chan=" << chan << ")");
+ if (name == MAGNESIUM_GAIN1){
+ _ad9371_att[RX_DIRECTION] = gain;
+ }else if (name == MAGNESIUM_GAIN2){
+ _dsa_att[RX_DIRECTION] = gain;
+ }else if (name == MAGNESIUM_AMP){
+ _amp_bypass[RX_DIRECTION] = gain == 0.0;
+ }else {
+ throw uhd::value_error("Could not find gain element " + name);
+ }
+ UHD_LOG_TRACE(unique_id(),
+ "_set_rx_gain calling update gain");
+ this->_set_all_gain(
+ this->_get_all_gain(chan, RX_DIRECTION),
+ this->get_rx_frequency(chan),
+ chan,
+ RX_DIRECTION
+ );
+ return gain; // not really any coreced here for individual gain
+}
+
+double magnesium_radio_ctrl_impl::_get_rx_gain(
+ const std::string &name,
+ const size_t chan
+) {
+ std::lock_guard<std::mutex> l(_set_lock);
+
+ if (name == MAGNESIUM_GAIN1){
+ return _ad9371_att[RX_DIRECTION];
+ }else if (name == MAGNESIUM_GAIN2){
+ return _dsa_att[RX_DIRECTION];
+ }else if (name == MAGNESIUM_AMP){
+ return _amp_bypass[RX_DIRECTION]? AMP_MIN_GAIN : AMP_MAX_GAIN;
+ }else{
+ throw uhd::value_error("Could not find gain element " + name);
+ }
+}
+
std::vector<std::string> magnesium_radio_ctrl_impl::get_rx_lo_names(
const size_t /*chan*/
) {