diff options
author | Dimitri Stolnikov <horiz0n@gmx.net> | 2013-02-16 15:01:29 +0100 |
---|---|---|
committer | Dimitri Stolnikov <horiz0n@gmx.net> | 2013-02-16 15:01:29 +0100 |
commit | 864712bad0bea7544c6f9d4d4c09c42058073d51 (patch) | |
tree | fef717c6215c8a97c76f16372b4bff7ec2f33446 /lib | |
parent | d4de9d18c1912c85bac6c8b89d2154fdc14b562d (diff) |
rtl: add named gain stage "IF"
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rtl/rtl_source_c.cc | 39 | ||||
-rw-r--r-- | lib/rtl/rtl_source_c.h | 1 |
2 files changed, 37 insertions, 3 deletions
diff --git a/lib/rtl/rtl_source_c.cc b/lib/rtl/rtl_source_c.cc index 302c993..9f8e5a4 100644 --- a/lib/rtl/rtl_source_c.cc +++ b/lib/rtl/rtl_source_c.cc @@ -87,6 +87,7 @@ rtl_source_c::rtl_source_c (const std::string &args) _running(true), _no_tuner(false), _auto_gain(false), + _if_gain(0), _skipped(0) { int ret; @@ -499,11 +500,17 @@ double rtl_source_c::get_freq_corr( size_t chan ) std::vector<std::string> rtl_source_c::get_gain_names( size_t chan ) { - std::vector< std::string > gains; + std::vector< std::string > names; - gains += "LNA"; + names += "LNA"; - return gains; + if ( _dev ) { + if ( rtlsdr_get_tuner_type(_dev) == RTLSDR_TUNER_E4000 ) { + names += "IF"; + } + } + + return names; } osmosdr::gain_range_t rtl_source_c::get_gain_range( size_t chan ) @@ -526,6 +533,16 @@ osmosdr::gain_range_t rtl_source_c::get_gain_range( size_t chan ) osmosdr::gain_range_t rtl_source_c::get_gain_range( const std::string & name, size_t chan ) { + if ( "IF" == name ) { + if ( _dev ) { + if ( rtlsdr_get_tuner_type(_dev) == RTLSDR_TUNER_E4000 ) { + return osmosdr::gain_range_t(3, 56, 1); + } else { + return osmosdr::gain_range_t(); + } + } + } + return get_gain_range( chan ); } @@ -560,6 +577,10 @@ double rtl_source_c::set_gain( double gain, size_t chan ) double rtl_source_c::set_gain( double gain, const std::string & name, size_t chan) { + if ( "IF" == name ) { + return set_if_gain( gain, chan ); + } + return set_gain( gain, chan ); } @@ -573,11 +594,22 @@ double rtl_source_c::get_gain( size_t chan ) double rtl_source_c::get_gain( const std::string & name, size_t chan ) { + if ( "IF" == name ) { + return _if_gain; + } + return get_gain( chan ); } double rtl_source_c::set_if_gain(double gain, size_t chan) { + if ( _dev ) { + if ( rtlsdr_get_tuner_type(_dev) != RTLSDR_TUNER_E4000 ) { + _if_gain = 0; + return _if_gain; + } + } + std::vector< osmosdr::gain_range_t > if_gains; if_gains += osmosdr::gain_range_t(-3, 6, 9); @@ -630,6 +662,7 @@ double rtl_source_c::set_if_gain(double gain, size_t chan) } } + _if_gain = gain; return gain; } diff --git a/lib/rtl/rtl_source_c.h b/lib/rtl/rtl_source_c.h index 13782ee..86d6a39 100644 --- a/lib/rtl/rtl_source_c.h +++ b/lib/rtl/rtl_source_c.h @@ -136,6 +136,7 @@ private: bool _no_tuner; bool _auto_gain; + double _if_gain; unsigned int _skipped; }; |