mirror of
https://github.com/rtlsdrblog/rtl-sdr-blog.git
synced 2024-11-13 22:12:52 +01:00
only enable auto-ds switching if ds mode from a UI is 0
This commit is contained in:
parent
ef7651cc92
commit
c79775f4b6
@ -29,6 +29,13 @@ extern "C" {
|
|||||||
|
|
||||||
typedef struct rtlsdr_dev rtlsdr_dev_t;
|
typedef struct rtlsdr_dev rtlsdr_dev_t;
|
||||||
|
|
||||||
|
enum rtlsdr_ds_mode {
|
||||||
|
RTLSDR_DS_IQ = 0, /* I/Q quadrature sampling of tuner output */
|
||||||
|
RTLSDR_DS_I, /* 1: direct sampling on I branch: usually not connected */
|
||||||
|
RTLSDR_DS_Q, /* 2: direct sampling on Q branch: HF on rtl-sdr v3 dongle */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
RTLSDR_API uint32_t rtlsdr_get_device_count(void);
|
RTLSDR_API uint32_t rtlsdr_get_device_count(void);
|
||||||
|
|
||||||
RTLSDR_API const char* rtlsdr_get_device_name(uint32_t index);
|
RTLSDR_API const char* rtlsdr_get_device_name(uint32_t index);
|
||||||
@ -302,6 +309,7 @@ RTLSDR_API int rtlsdr_set_agc_mode(rtlsdr_dev_t *dev, int on);
|
|||||||
* \param on 0 means disabled, 1 I-ADC input enabled, 2 Q-ADC input enabled
|
* \param on 0 means disabled, 1 I-ADC input enabled, 2 Q-ADC input enabled
|
||||||
* \return 0 on success
|
* \return 0 on success
|
||||||
*/
|
*/
|
||||||
|
int _rtlsdr_set_direct_sampling(rtlsdr_dev_t *dev, int on);
|
||||||
RTLSDR_API int rtlsdr_set_direct_sampling(rtlsdr_dev_t *dev, int on);
|
RTLSDR_API int rtlsdr_set_direct_sampling(rtlsdr_dev_t *dev, int on);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -122,6 +122,7 @@ struct rtlsdr_dev {
|
|||||||
char manufact[256];
|
char manufact[256];
|
||||||
char product[256];
|
char product[256];
|
||||||
int force_bt;
|
int force_bt;
|
||||||
|
enum rtlsdr_ds_mode direct_sampling_mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
void rtlsdr_set_gpio_bit(rtlsdr_dev_t *dev, uint8_t gpio, int val);
|
void rtlsdr_set_gpio_bit(rtlsdr_dev_t *dev, uint8_t gpio, int val);
|
||||||
@ -896,8 +897,12 @@ int rtlsdr_set_center_freq(rtlsdr_dev_t *dev, uint32_t freq)
|
|||||||
if (last_ds < 0)
|
if (last_ds < 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/* Check if direct sampling should be enabled */
|
/* Check if direct sampling should be enabled.
|
||||||
dev->direct_sampling = (freq < 28800000 && dev->tuner_type == RTLSDR_TUNER_R820T) ? 2 : 0;
|
* Also only enable auto switch if ds mode is 0 (aka None, or standard mode)
|
||||||
|
*/
|
||||||
|
if(dev->direct_sampling_mode == 0) {
|
||||||
|
dev->direct_sampling = (freq < 28800000 && dev->tuner_type == RTLSDR_TUNER_R820T) ? 2 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (dev->direct_sampling) {
|
if (dev->direct_sampling) {
|
||||||
rtlsdr_set_i2c_repeater(dev, 0);
|
rtlsdr_set_i2c_repeater(dev, 0);
|
||||||
@ -917,7 +922,7 @@ int rtlsdr_set_center_freq(rtlsdr_dev_t *dev, uint32_t freq)
|
|||||||
* the previous frequency back again
|
* the previous frequency back again
|
||||||
*/
|
*/
|
||||||
if (last_ds != dev->direct_sampling) {
|
if (last_ds != dev->direct_sampling) {
|
||||||
return rtlsdr_set_direct_sampling(dev, dev->direct_sampling);
|
return _rtlsdr_set_direct_sampling(dev, dev->direct_sampling);
|
||||||
}
|
}
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
@ -1191,7 +1196,15 @@ int rtlsdr_set_agc_mode(rtlsdr_dev_t *dev, int on)
|
|||||||
return rtlsdr_demod_write_reg(dev, 0, 0x19, on ? 0x25 : 0x05, 1);
|
return rtlsdr_demod_write_reg(dev, 0, 0x19, on ? 0x25 : 0x05, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int rtlsdr_set_direct_sampling(rtlsdr_dev_t *dev, int on)
|
int rtlsdr_set_direct_sampling(rtlsdr_dev_t *dev, int on)
|
||||||
|
{
|
||||||
|
/* When the UI sets the ds mode, remember the mode set */
|
||||||
|
dev->direct_sampling_mode = (enum rtlsdr_ds_mode)on;
|
||||||
|
return _rtlsdr_set_direct_sampling(dev, on);
|
||||||
|
}
|
||||||
|
|
||||||
|
int _rtlsdr_set_direct_sampling(rtlsdr_dev_t *dev, int on)
|
||||||
{
|
{
|
||||||
int r = 0;
|
int r = 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user