From 22549e0da01c08d1cab99ce76702d93c15711e4d Mon Sep 17 00:00:00 2001 From: Steve Markgraf Date: Sun, 7 Oct 2012 16:24:18 +0200 Subject: [PATCH] rtlsdr_set_direct_sampling(): fix issue when switching between inputs Switching back from input 2 to 1 didn't work. Signed-off-by: Steve Markgraf --- src/librtlsdr.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/librtlsdr.c b/src/librtlsdr.c index 4b3ef07..75dd1f3 100644 --- a/src/librtlsdr.c +++ b/src/librtlsdr.c @@ -982,11 +982,10 @@ int rtlsdr_set_direct_sampling(rtlsdr_dev_t *dev, int on) 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); + r |= rtlsdr_demod_write_reg(dev, 0, 0x06, (on > 1) ? 0x90 : 0x80, 1); - fprintf(stderr, "Enabled direct sampling mode\n"); - dev->direct_sampling = 1; + fprintf(stderr, "Enabled direct sampling mode, input %i\n", on); + dev->direct_sampling = on; } else { if (dev->tuner && dev->tuner->init) { rtlsdr_set_i2c_repeater(dev, 1); @@ -1016,6 +1015,8 @@ int rtlsdr_set_direct_sampling(rtlsdr_dev_t *dev, int on) dev->direct_sampling = 0; } + r |= rtlsdr_set_center_freq(dev, dev->freq); + return r; }