diff --git a/doc/img/RTLSDR_plugin.png b/doc/img/RTLSDR_plugin.png
index 17a979ef3..1a99604de 100644
Binary files a/doc/img/RTLSDR_plugin.png and b/doc/img/RTLSDR_plugin.png differ
diff --git a/plugins/samplesource/rtlsdr/readme.md b/plugins/samplesource/rtlsdr/readme.md
index 144e2447c..c086f574a 100644
--- a/plugins/samplesource/rtlsdr/readme.md
+++ b/plugins/samplesource/rtlsdr/readme.md
@@ -76,6 +76,8 @@ The I/Q stream from the RTLSDR ADC is doensampled by a power of two before being
Use this checkbox to activate the special RTLSDR direct sampling. This can be used to tune to HF frequencies.
-
9: RF gain
+9: RF gain and AGC
-This is the RF gain setting in dB. The values are defined in the RTLSDR device and generally are: 0.0, 0.9, 1.4, 2.7, 3.7, 7.7, 8.7, 12.5, 14.4, 15.7, 16.6, 19.7, 20.7, 22.9, 25.4, 28.0, 29.7, 32.8, 33.8, 36.4, 37.2, 38.6, 40.2, 42.1, 43.4, 43.9, 44.5, 48.0, 49.6
\ No newline at end of file
+The slider sets RF gain in dB. The values are defined in the RTLSDR device and generally are: 0.0, 0.9, 1.4, 2.7, 3.7, 7.7, 8.7, 12.5, 14.4, 15.7, 16.6, 19.7, 20.7, 22.9, 25.4, 28.0, 29.7, 32.8, 33.8, 36.4, 37.2, 38.6, 40.2, 42.1, 43.4, 43.9, 44.5, 48.0, 49.6
+
+The AGC checkbox can be used to switch on or off the RTL2838 AGC. This is independent of the gain setting as this AGC acts after the gain block.
\ No newline at end of file
diff --git a/plugins/samplesource/rtlsdr/rtlsdrgui.cpp b/plugins/samplesource/rtlsdr/rtlsdrgui.cpp
index e08acaff8..4174444d0 100644
--- a/plugins/samplesource/rtlsdr/rtlsdrgui.cpp
+++ b/plugins/samplesource/rtlsdr/rtlsdrgui.cpp
@@ -407,6 +407,12 @@ void RTLSDRGui::on_checkBox_stateChanged(int state)
sendSettings();
}
+void RTLSDRGui::on_agc_stateChanged(int state)
+{
+ m_settings.m_agc = (state == Qt::Checked);
+ sendSettings();
+}
+
void RTLSDRGui::on_sampleRate_changed(quint64 value)
{
m_settings.m_devSampleRate = value;
diff --git a/plugins/samplesource/rtlsdr/rtlsdrgui.h b/plugins/samplesource/rtlsdr/rtlsdrgui.h
index ca72beff4..1f9139971 100644
--- a/plugins/samplesource/rtlsdr/rtlsdrgui.h
+++ b/plugins/samplesource/rtlsdr/rtlsdrgui.h
@@ -80,6 +80,7 @@ private slots:
void on_gain_valueChanged(int value);
void on_sampleRate_currentIndexChanged(int index);
void on_checkBox_stateChanged(int state);
+ void on_agc_stateChanged(int state);
void on_startStop_toggled(bool checked);
void on_record_toggled(bool checked);
void updateHardware();
diff --git a/plugins/samplesource/rtlsdr/rtlsdrgui.ui b/plugins/samplesource/rtlsdr/rtlsdrgui.ui
index ec8a52775..d56fa26f4 100644
--- a/plugins/samplesource/rtlsdr/rtlsdrgui.ui
+++ b/plugins/samplesource/rtlsdr/rtlsdrgui.ui
@@ -483,6 +483,16 @@
3
+ -
+
+
+ Toggles RTLSDR AGC
+
+
+ AGC
+
+
+
-
diff --git a/plugins/samplesource/rtlsdr/rtlsdrinput.cpp b/plugins/samplesource/rtlsdr/rtlsdrinput.cpp
index 669f678a9..3d04d2c77 100644
--- a/plugins/samplesource/rtlsdr/rtlsdrinput.cpp
+++ b/plugins/samplesource/rtlsdr/rtlsdrinput.cpp
@@ -256,6 +256,18 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, bool force)
{
bool forwardChange = false;
+ if ((m_settings.m_agc != settings.m_agc) || force)
+ {
+ if (rtlsdr_set_agc_mode(m_dev, settings.m_agc ? 1 : 0) < 0)
+ {
+ qCritical("could not set AGC mode %s", settings.m_agc ? "on" : "off");
+ }
+ else
+ {
+ m_settings.m_agc = settings.m_agc;
+ }
+ }
+
if ((m_settings.m_gain != settings.m_gain) || force)
{
m_settings.m_gain = settings.m_gain;
diff --git a/plugins/samplesource/rtlsdr/rtlsdrplugin.cpp b/plugins/samplesource/rtlsdr/rtlsdrplugin.cpp
index 915f9ce1d..7b3e734fa 100644
--- a/plugins/samplesource/rtlsdr/rtlsdrplugin.cpp
+++ b/plugins/samplesource/rtlsdr/rtlsdrplugin.cpp
@@ -11,7 +11,7 @@
const PluginDescriptor RTLSDRPlugin::m_pluginDescriptor = {
QString("RTL-SDR Input"),
- QString("3.5.0"),
+ QString("3.5.2"),
QString("(c) Edouard Griffiths, F4EXB"),
QString("https://github.com/f4exb/sdrangel"),
true,
diff --git a/plugins/samplesource/rtlsdr/rtlsdrsettings.cpp b/plugins/samplesource/rtlsdr/rtlsdrsettings.cpp
index 930218c2c..edf29351d 100644
--- a/plugins/samplesource/rtlsdr/rtlsdrsettings.cpp
+++ b/plugins/samplesource/rtlsdr/rtlsdrsettings.cpp
@@ -34,6 +34,7 @@ void RTLSDRSettings::resetToDefaults()
m_fcPos = FC_POS_CENTER;
m_dcBlock = false;
m_iqImbalance = false;
+ m_agc = false;
}
QByteArray RTLSDRSettings::serialize() const
@@ -48,6 +49,7 @@ QByteArray RTLSDRSettings::serialize() const
s.writeS32(7, (int) m_fcPos);
s.writeS32(8, m_devSampleRate);
s.writeBool(9, m_lowSampleRate);
+ s.writeBool(10, m_agc);
return s.final();
}
@@ -75,6 +77,7 @@ bool RTLSDRSettings::deserialize(const QByteArray& data)
m_fcPos = (fcPos_t) intval;
d.readS32(8, &m_devSampleRate, 1024*1000);
d.readBool(9, &m_lowSampleRate, false);
+ d.readBool(10, &m_agc, false);
return true;
}
diff --git a/plugins/samplesource/rtlsdr/rtlsdrsettings.h b/plugins/samplesource/rtlsdr/rtlsdrsettings.h
index ee8331c00..ff257de71 100644
--- a/plugins/samplesource/rtlsdr/rtlsdrsettings.h
+++ b/plugins/samplesource/rtlsdr/rtlsdrsettings.h
@@ -33,6 +33,7 @@ struct RTLSDRSettings {
fcPos_t m_fcPos;
bool m_dcBlock;
bool m_iqImbalance;
+ bool m_agc;
RTLSDRSettings();
void resetToDefaults();