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>
This commit is contained in:
Steve Markgraf 2012-09-16 17:01:32 +02:00
parent 36a92a92bf
commit 0f25daec61
1 changed files with 10 additions and 1 deletions

View File

@ -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.");