add getters for direct sampling and offset tuning mode

Signed-off-by: Steve Markgraf <steve@steve-m.de>
master
Steve Markgraf 12 years ago
parent 22549e0da0
commit 9b8b0e53f6
  1. 17
      include/rtl-sdr.h
  2. 19
      src/librtlsdr.c

@ -241,6 +241,15 @@ RTLSDR_API int rtlsdr_set_agc_mode(rtlsdr_dev_t *dev, int on);
*/
RTLSDR_API int rtlsdr_set_direct_sampling(rtlsdr_dev_t *dev, int on);
/*!
* Get state of the direct sampling mode
*
* \param dev the device handle given by rtlsdr_open()
* \return -1 on error, 0 means disabled, 1 I-ADC input enabled
* 2 Q-ADC input enabled
*/
RTLSDR_API int rtlsdr_get_direct_sampling(rtlsdr_dev_t *dev);
/*!
* Enable or disable offset tuning for zero-IF tuners, which allows to avoid
* problems caused by the DC offset of the ADCs and 1/f noise.
@ -251,6 +260,14 @@ RTLSDR_API int rtlsdr_set_direct_sampling(rtlsdr_dev_t *dev, int on);
*/
RTLSDR_API int rtlsdr_set_offset_tuning(rtlsdr_dev_t *dev, int on);
/*!
* Get state of the offset tuning mode
*
* \param dev the device handle given by rtlsdr_open()
* \return -1 on error, 0 means disabled, 1 enabled
*/
RTLSDR_API int rtlsdr_get_offset_tuning(rtlsdr_dev_t *dev);
/* streaming functions */
RTLSDR_API int rtlsdr_reset_buffer(rtlsdr_dev_t *dev);

@ -1020,6 +1020,14 @@ int rtlsdr_set_direct_sampling(rtlsdr_dev_t *dev, int on)
return r;
}
int rtlsdr_get_direct_sampling(rtlsdr_dev_t *dev)
{
if (!dev)
return -1;
return dev->direct_sampling;
}
int rtlsdr_set_offset_tuning(rtlsdr_dev_t *dev, int on)
{
int r = 0;
@ -1030,6 +1038,9 @@ int rtlsdr_set_offset_tuning(rtlsdr_dev_t *dev, int on)
if (dev->tuner_type == RTLSDR_TUNER_R820T)
return -2;
if (dev->direct_sampling)
return -3;
/* based on keenerds 1/f noise measurements */
dev->offs_freq = on ? ((dev->rate / 2) * 170 / 100) : 0;
r |= rtlsdr_set_if_freq(dev, dev->offs_freq);
@ -1045,6 +1056,14 @@ int rtlsdr_set_offset_tuning(rtlsdr_dev_t *dev, int on)
return r;
}
int rtlsdr_get_offset_tuning(rtlsdr_dev_t *dev)
{
if (!dev)
return -1;
return (dev->offs_freq) ? 1 : 0;
}
static rtlsdr_dongle_t *find_known_device(uint16_t vid, uint16_t pid)
{
unsigned int i;

Loading…
Cancel
Save