aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Markgraf <steve@steve-m.de>2012-07-07 18:59:48 (UTC)
committerSteve Markgraf <steve@steve-m.de>2012-07-07 19:06:38 (UTC)
commitf3cf83e3d7cc86218a1d7f6f4ed7ae3ad46f2105 (patch)
tree78804729c750332f1c109dca60912cc479995e59
parent98d1b864b6dc40131808280df1bf0db149cba942 (diff)
disable DAGC by default, add control function
This adds rtlsdr_set_agc_mode() to enable/disable it. Thanks to Leif Asbrink for finding this setting. Signed-off-by: Steve Markgraf <steve@steve-m.de>
-rw-r--r--include/rtl-sdr.h9
-rw-r--r--src/librtlsdr.c15
2 files changed, 21 insertions, 3 deletions
diff --git a/include/rtl-sdr.h b/include/rtl-sdr.h
index a7a3ee9..7de8455 100644
--- a/include/rtl-sdr.h
+++ b/include/rtl-sdr.h
@@ -206,6 +206,15 @@ RTLSDR_API uint32_t rtlsdr_get_sample_rate(rtlsdr_dev_t *dev);
*/
RTLSDR_API int rtlsdr_set_testmode(rtlsdr_dev_t *dev, int on);
+/*!
+ * Enable or disable the internal digital AGC of the RTL2832.
+ *
+ * \param dev the device handle given by rtlsdr_open()
+ * \param digital AGC mode, 1 means enabled, 0 disabled
+ * \return 0 on success
+ */
+RTLSDR_API int rtlsdr_set_agc_mode(rtlsdr_dev_t *dev, int on);
+
/* streaming functions */
RTLSDR_API int rtlsdr_reset_buffer(rtlsdr_dev_t *dev);
diff --git a/src/librtlsdr.c b/src/librtlsdr.c
index adb9530..0853767 100644
--- a/src/librtlsdr.c
+++ b/src/librtlsdr.c
@@ -485,12 +485,13 @@ void rtlsdr_init_baseband(rtlsdr_dev_t *dev)
for (i = 0; i < sizeof (fir_coeff); i++)
rtlsdr_demod_write_reg(dev, 1, 0x1c + i, fir_coeff[i], 1);
- rtlsdr_demod_write_reg(dev, 0, 0x19, 0x25, 1);
+ /* enable SDR mode, disable DAGC (bit 5) */
+ rtlsdr_demod_write_reg(dev, 0, 0x19, 0x05, 1);
/* init FSM state-holding register */
rtlsdr_demod_write_reg(dev, 1, 0x93, 0xf0, 1);
- /* disable AGC (en_dagc, bit 0) */
+ /* disable AGC (en_dagc, bit 0) (this seems to have no effect) */
rtlsdr_demod_write_reg(dev, 1, 0x11, 0x00, 1);
/* disable PID filter (enable_PID = 0) */
@@ -842,7 +843,15 @@ int rtlsdr_set_testmode(rtlsdr_dev_t *dev, int on)
if (!dev)
return -1;
- return rtlsdr_demod_write_reg(dev, 0, 0x19, on ? 0x23 : 0x25 , 1);
+ return rtlsdr_demod_write_reg(dev, 0, 0x19, on ? 0x03 : 0x05, 1);
+}
+
+int rtlsdr_set_agc_mode(rtlsdr_dev_t *dev, int on)
+{
+ if (!dev)
+ return -1;
+
+ return rtlsdr_demod_write_reg(dev, 0, 0x19, on ? 0x25 : 0x05, 1);
}
static rtlsdr_dongle_t *find_known_device(uint16_t vid, uint16_t pid)