aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Markgraf <steve@steve-m.de>2012-09-16 16:24:58 +0200
committerSteve Markgraf <steve@steve-m.de>2012-09-16 16:24:58 +0200
commit01d8d308fc42ab781d3f32cecb4d2bed3a673b70 (patch)
treea7ff9896fd478d4d18d27ef94fc8fa3d52e182f8
parent519406264ce27459c6380dcf8dfa8c7b511d8e1b (diff)
disable second ADC in IF mode, make input selectable in DS-mode
Signed-off-by: Steve Markgraf <steve@steve-m.de>
-rw-r--r--include/rtl-sdr.h2
-rw-r--r--src/librtlsdr.c18
2 files changed, 18 insertions, 2 deletions
diff --git a/include/rtl-sdr.h b/include/rtl-sdr.h
index 98c9992..956b62b 100644
--- a/include/rtl-sdr.h
+++ b/include/rtl-sdr.h
@@ -236,7 +236,7 @@ RTLSDR_API int rtlsdr_set_agc_mode(rtlsdr_dev_t *dev, int on);
* (xtal frequency of the RTL2832).
*
* \param dev the device handle given by rtlsdr_open()
- * \param direct sampling mode, 1 means enabled, 0 disabled
+ * \param on 0 means disabled, 1 I-ADC input enabled, 2 Q-ADC input enabled
* \return 0 on success
*/
RTLSDR_API int rtlsdr_set_direct_sampling(rtlsdr_dev_t *dev, int on);
diff --git a/src/librtlsdr.c b/src/librtlsdr.c
index f9aae37..529ab4f 100644
--- a/src/librtlsdr.c
+++ b/src/librtlsdr.c
@@ -955,6 +955,13 @@ int rtlsdr_set_direct_sampling(rtlsdr_dev_t *dev, int on)
/* disable spectrum inversion */
r |= rtlsdr_demod_write_reg(dev, 1, 0x15, 0x00, 1);
+ /* only enable In-phase ADC input */
+ r |= rtlsdr_demod_write_reg(dev, 0, 0x08, 0x4d, 1);
+
+ /* swap I and Q ADC, this allows to select between two inputs */
+ if (on > 1)
+ r |= rtlsdr_demod_write_reg(dev, 0, 0x06, 0x90, 1);
+
fprintf(stderr, "Enabled direct sampling mode\n");
dev->direct_sampling = 1;
} else {
@@ -970,10 +977,16 @@ int rtlsdr_set_direct_sampling(rtlsdr_dev_t *dev, int on)
/* enable spectrum inversion */
r |= rtlsdr_demod_write_reg(dev, 1, 0x15, 0x01, 1);
} else {
+ /* enable In-phase + Quadrature ADC input */
+ r |= rtlsdr_demod_write_reg(dev, 0, 0x08, 0xcd, 1);
+
/* Enable Zero-IF mode */
- rtlsdr_demod_write_reg(dev, 1, 0xb1, 0x1b, 1);
+ r |= rtlsdr_demod_write_reg(dev, 1, 0xb1, 0x1b, 1);
}
+ /* opt_adc_iq = 0, default ADC_I/ADC_Q datapath */
+ r |= rtlsdr_demod_write_reg(dev, 0, 0x06, 0x80, 1);
+
fprintf(stderr, "Disabled direct sampling mode\n");
dev->direct_sampling = 0;
}
@@ -1193,6 +1206,9 @@ int rtlsdr_open(rtlsdr_dev_t **out_dev, uint32_t index)
/* disable Zero-IF mode */
rtlsdr_demod_write_reg(dev, 1, 0xb1, 0x1a, 1);
+ /* only enable In-phase ADC input */
+ rtlsdr_demod_write_reg(dev, 0, 0x08, 0x4d, 1);
+
/* the R820T uses 3.57 MHz IF for the DVB-T 6 MHz mode, and
* 4.57 MHz for the 8 MHz mode */
rtlsdr_set_if_freq(dev, R820T_IF_FREQ);