From cefca72c53f80dd483ac53a405b9e8870c1da10e Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Sun, 3 Nov 2019 16:22:04 -0500 Subject: [PATCH] Override setGain and getGainRange to avoid changing RFGR. SDRPlay's "RFGR" is actually a mode selector for the front-end LNA. It does *not* have units of dB. (In fact, it is frequency-dependent.) As a result, the default gain allocation algorithm does not apply and only IFGR should be used for adjusting the overall system gain. --- Settings.cpp | 18 ++++++++++++++++++ SoapySDRPlay.hpp | 6 ++++++ 2 files changed, 24 insertions(+) diff --git a/Settings.cpp b/Settings.cpp index 8f6d5c6..0f929d1 100644 --- a/Settings.cpp +++ b/Settings.cpp @@ -653,6 +653,12 @@ void SoapySDRPlay::setGain(const int direction, const size_t channel, const std: } } +void SoapySDRPlay::setGain(const int direction, const size_t channel, const double value) +{ + // Only IFGR should be used for adjusting the overall system gain. + this->setGain(direction, channel, "IFGR", value); +} + double SoapySDRPlay::getGain(const int direction, const size_t channel, const std::string &name) const { std::lock_guard lock(_general_state_mutex); @@ -669,6 +675,12 @@ double SoapySDRPlay::getGain(const int direction, const size_t channel, const st return 0; } +double SoapySDRPlay::getGain(const int direction, const size_t channel) const +{ + // Only IFGR should be used for adjusting the overall system gain. + return this->getGain(direction, channel, "IFGR"); +} + SoapySDR::Range SoapySDRPlay::getGainRange(const int direction, const size_t channel, const std::string &name) const { if (name == "IFGR") @@ -698,6 +710,12 @@ SoapySDR::Range SoapySDRPlay::getGainRange(const int direction, const size_t cha return SoapySDR::Range(20, 59); } +SoapySDR::Range SoapySDRPlay::getGainRange(const int direction, const size_t channel) const +{ + // Only IFGR should be used for adjusting the overall system gain. + return this->getGainRange(direction, channel, "IFGR"); +} + /******************************************************************* * Frequency API ******************************************************************/ diff --git a/SoapySDRPlay.hpp b/SoapySDRPlay.hpp index 086e73e..5009356 100644 --- a/SoapySDRPlay.hpp +++ b/SoapySDRPlay.hpp @@ -146,10 +146,16 @@ class SoapySDRPlay: public SoapySDR::Device void setGain(const int direction, const size_t channel, const std::string &name, const double value); + void setGain(const int direction, const size_t channel, const double value); + double getGain(const int direction, const size_t channel, const std::string &name) const; + double getGain(const int direction, const size_t channel) const; + SoapySDR::Range getGainRange(const int direction, const size_t channel, const std::string &name) const; + SoapySDR::Range getGainRange(const int direction, const size_t channel) const; + /******************************************************************* * Frequency API ******************************************************************/