bladerf_common: cleanup on set_gain_mode

Turns out that source/sink_impl already handle the AGC->MGC gain
preservation, so this was redundant and counterproductive.

Also DRY the code a bit.
gr3.7
Ryan Tucker 6 years ago committed by Dimitri Stolnikov
parent 3523097e00
commit 07babe997d
  1. 19
      lib/bladerf/bladerf_common.cc

@ -809,22 +809,11 @@ osmosdr::gain_range_t bladerf_common::get_gain_range( const std::string & name,
bool bladerf_common::set_gain_mode( bool automatic, size_t chan )
{
int ret = 0;
bladerf_gain_mode mode = automatic ? BLADERF_GAIN_DEFAULT : BLADERF_GAIN_MGC;
if (automatic) {
ret = bladerf_set_gain_mode( _dev.get(),
static_cast<bladerf_channel>(chan),
BLADERF_GAIN_DEFAULT );
} else {
/* read the gain (presumably automatic), switch to MGC, then set the
* gain to that value to minimize surprise */
double gain = get_gain(chan);
ret = bladerf_set_gain_mode( _dev.get(),
static_cast<bladerf_channel>(chan),
BLADERF_GAIN_MGC );
if (!ret) {
set_gain(gain, chan);
}
}
ret = bladerf_set_gain_mode( _dev.get(),
static_cast<bladerf_channel>(chan),
mode );
if( ret ) {
throw std::runtime_error( std::string(__FUNCTION__) + " " +

Loading…
Cancel
Save