aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rtl/rtl_source_c.cc
diff options
context:
space:
mode:
authorSteve Markgraf <steve@steve-m.de>2012-09-16 17:01:32 +0200
committerSteve Markgraf <steve@steve-m.de>2012-09-16 17:01:32 +0200
commit0f25daec618c31852c320baf9ef42d54d75fe545 (patch)
tree68d89c9cd7b801903680638562f8b7dc1a3393f4 /lib/rtl/rtl_source_c.cc
parent36a92a92bf127506295aba030b43b9715a692c8c (diff)
rtl: add direct_samp as device parameter
This can be used to enable the direct sampling mode of an rtlsdr stick, e.g.: For input 1 (In-phase ADC): rtl=0,direct_samp=1 For input 2 (Quadrature ADC): rtl=0,direct_samp=2 Signed-off-by: Steve Markgraf <steve@steve-m.de>
Diffstat (limited to 'lib/rtl/rtl_source_c.cc')
-rw-r--r--lib/rtl/rtl_source_c.cc11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/rtl/rtl_source_c.cc b/lib/rtl/rtl_source_c.cc
index 0ca49af..9ca6d64 100644
--- a/lib/rtl/rtl_source_c.cc
+++ b/lib/rtl/rtl_source_c.cc
@@ -88,7 +88,7 @@ rtl_source_c::rtl_source_c (const std::string &args)
_skipped(0)
{
int ret;
- unsigned int dev_index = 0, rtl_freq = 0, tuner_freq = 0;
+ unsigned int dev_index = 0, rtl_freq = 0, tuner_freq = 0, direct_samp = 0;
dict_t dict = params_to_dict(args);
@@ -101,6 +101,9 @@ rtl_source_c::rtl_source_c (const std::string &args)
if (dict.count("tuner_xtal"))
tuner_freq = (unsigned int)boost::lexical_cast< double >( dict["tuner_xtal"] );
+ if (dict.count("direct_samp"))
+ direct_samp = boost::lexical_cast< unsigned int >( dict["direct_samp"] );
+
_buf_num = BUF_NUM;
_buf_head = _buf_used = _buf_offset = 0;
_samp_avail = BUF_SIZE / BYTES_PER_SAMPLE;
@@ -160,6 +163,12 @@ rtl_source_c::rtl_source_c (const std::string &args)
if (ret < 0)
throw std::runtime_error("Failed to set agc mode.");
+ if (direct_samp) {
+ ret = rtlsdr_set_direct_sampling(_dev, direct_samp);
+ if (ret < 0)
+ throw std::runtime_error("Failed to enable direct sampling mode.");
+ }
+
ret = rtlsdr_reset_buffer( _dev );
if (ret < 0)
throw std::runtime_error("Failed to reset usb buffers.");