diff --git a/plugins/samplesource/bladerf2input/bladerf2input.cpp b/plugins/samplesource/bladerf2input/bladerf2input.cpp index b83863ed1..81106de21 100644 --- a/plugins/samplesource/bladerf2input/bladerf2input.cpp +++ b/plugins/samplesource/bladerf2input/bladerf2input.cpp @@ -810,24 +810,6 @@ bool BladeRF2Input::applySettings(const BladeRF2InputSettings& settings, bool fo m_deviceShared.m_dev->setBiasTeeRx(settings.m_biasTee); } - if ((m_settings.m_globalGain != settings.m_globalGain) || force) - { - forwardChangeRxBuddies = true; - - if (dev) - { -// qDebug("BladeRF2Input::applySettings: channel: %d gain: %d", requestedChannel, settings.m_globalGain); - int status = bladerf_set_gain(dev, BLADERF_CHANNEL_RX(requestedChannel), settings.m_globalGain); - - if (status < 0) { - qWarning("BladeRF2Input::applySettings: bladerf_set_gain(%d) failed: %s", - settings.m_globalGain, bladerf_strerror(status)); - } else { - qDebug("BladeRF2Input::applySettings: bladerf_set_gain(%d)", settings.m_globalGain); - } - } - } - if ((m_settings.m_gainMode != settings.m_gainMode) || force) { forwardChangeRxBuddies = true; @@ -845,6 +827,25 @@ bool BladeRF2Input::applySettings(const BladeRF2InputSettings& settings, bool fo } } + if ((m_settings.m_globalGain != settings.m_globalGain) + || ((m_settings.m_gainMode != settings.m_gainMode) && (settings.m_gainMode == BLADERF_GAIN_MANUAL)) || force) + { + forwardChangeRxBuddies = true; + + if (dev) + { +// qDebug("BladeRF2Input::applySettings: channel: %d gain: %d", requestedChannel, settings.m_globalGain); + int status = bladerf_set_gain(dev, BLADERF_CHANNEL_RX(requestedChannel), settings.m_globalGain); + + if (status < 0) { + qWarning("BladeRF2Input::applySettings: bladerf_set_gain(%d) failed: %s", + settings.m_globalGain, bladerf_strerror(status)); + } else { + qDebug("BladeRF2Input::applySettings: bladerf_set_gain(%d)", settings.m_globalGain); + } + } + } + if (forwardChangeOwnDSP) { int sampleRate = settings.m_devSampleRate/(1<gainText->setText(tr("%1 dB").arg(m_settings.m_globalGain)); ui->gain->setValue(m_settings.m_globalGain); + if (m_settings.m_gainMode == BLADERF_GAIN_MANUAL) { + ui->gain->setEnabled(true); + } else { + ui->gain->setEnabled(false); + } + blockApplySettings(false); } @@ -310,6 +316,18 @@ void BladeRF2InputGui::on_gainMode_currentIndexChanged(int index) if (uindex < modes.size()) { BladeRF2Input::GainMode mode = modes[index]; + + if (m_settings.m_gainMode != mode.m_value) + { + if (mode.m_value == BLADERF_GAIN_MANUAL) + { + m_settings.m_globalGain = ui->gain->value(); + ui->gain->setEnabled(true); + } else { + ui->gain->setEnabled(false); + } + } + m_settings.m_gainMode = mode.m_value; sendSettings(); }