diff --git a/plugins/samplesource/soapysdrinput/soapysdrinput.cpp b/plugins/samplesource/soapysdrinput/soapysdrinput.cpp index a74f111f2..fa591af87 100644 --- a/plugins/samplesource/soapysdrinput/soapysdrinput.cpp +++ b/plugins/samplesource/soapysdrinput/soapysdrinput.cpp @@ -973,6 +973,54 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo } } + if ((m_settings.m_autoDCCorrection != settings.m_autoDCCorrection) || force) + { + if ((dev != 0) && hasDCAutoCorrection()) + { + try + { + dev->setDCOffsetMode(SOAPY_SDR_RX, requestedChannel, settings.m_autoDCCorrection); + qDebug("SoapySDRInput::applySettings: %s DC auto correction", settings.m_autoGain ? "set" : "unset"); + } + catch (const std::exception &ex) + { + qCritical("SoapySDRInput::applySettings: cannot %s DC auto correction", settings.m_autoGain ? "set" : "unset"); + } + } + } + + if ((m_settings.m_dcCorrection != settings.m_dcCorrection) || force) + { + if ((dev != 0) && hasDCCorrectionValue()) + { + try + { + dev->setDCOffset(SOAPY_SDR_RX, requestedChannel, settings.m_dcCorrection); + qDebug("SoapySDRInput::applySettings: DC offset correction set to (%lf, %lf)", settings.m_dcCorrection.real(), settings.m_dcCorrection.imag()); + } + catch (const std::exception &ex) + { + qCritical("SoapySDRInput::applySettings: cannot set DC offset correction to (%lf, %lf)", settings.m_dcCorrection.real(), settings.m_dcCorrection.imag()); + } + } + } + + if ((m_settings.m_iqCorrection != settings.m_iqCorrection) || force) + { + if ((dev != 0) && hasIQCorrectionValue()) + { + try + { + dev->setIQBalance(SOAPY_SDR_RX, requestedChannel, settings.m_iqCorrection); + qDebug("SoapySDRInput::applySettings: IQ balance correction set to (%lf, %lf)", settings.m_iqCorrection.real(), settings.m_iqCorrection.imag()); + } + catch (const std::exception &ex) + { + qCritical("SoapySDRInput::applySettings: cannot set IQ balance correction to (%lf, %lf)", settings.m_iqCorrection.real(), settings.m_iqCorrection.imag()); + } + } + } + if (forwardChangeOwnDSP) { int sampleRate = settings.m_devSampleRate/(1<{0,0}; + m_iqCorrection = std::complex{0,0}; } QByteArray SoapySDRInputSettings::serialize() const @@ -65,6 +67,10 @@ QByteArray SoapySDRInputSettings::serialize() const s.writeBool(14, m_autoGain); s.writeBool(15, m_autoDCCorrection); s.writeBool(16, m_autoIQCorrection); + s.writeDouble(17, m_dcCorrection.real()); + s.writeDouble(18, m_dcCorrection.imag()); + s.writeDouble(19, m_iqCorrection.real()); + s.writeDouble(20, m_iqCorrection.imag()); return s.final(); } @@ -83,6 +89,7 @@ bool SoapySDRInputSettings::deserialize(const QByteArray& data) { int intval; QByteArray blob; + double realval, imagval; d.readS32(1, &m_devSampleRate, 1024000); d.readU32(2, &m_log2Decim, 0); @@ -103,6 +110,12 @@ bool SoapySDRInputSettings::deserialize(const QByteArray& data) d.readBool(14, &m_autoGain, false); d.readBool(15, &m_autoDCCorrection, false); d.readBool(16, &m_autoIQCorrection, false); + d.readDouble(17, &realval, 0); + d.readDouble(18, &imagval, 0); + m_dcCorrection = std::complex{realval, imagval}; + d.readDouble(19, &realval, 0); + d.readDouble(20, &imagval, 0); + m_iqCorrection = std::complex{realval, imagval}; return true; } diff --git a/plugins/samplesource/soapysdrinput/soapysdrinputsettings.h b/plugins/samplesource/soapysdrinput/soapysdrinputsettings.h index f2df1821b..4bbb2db47 100644 --- a/plugins/samplesource/soapysdrinput/soapysdrinputsettings.h +++ b/plugins/samplesource/soapysdrinput/soapysdrinputsettings.h @@ -46,8 +46,8 @@ struct SoapySDRInputSettings { bool m_autoGain; bool m_autoDCCorrection; bool m_autoIQCorrection; - std::complex m_dcCorrection; - std::complex m_iqCorrection; + std::complex m_dcCorrection; + std::complex m_iqCorrection; SoapySDRInputSettings(); void resetToDefaults();