mirror of
https://github.com/rtlsdrblog/rtl-sdr-blog.git
synced 2024-11-10 04:37:37 +01:00
add auto enable direct sampling when tuned below 28.8 MHz
This commit is contained in:
parent
65c8e96bb2
commit
0979750e9e
@ -125,6 +125,7 @@ struct rtlsdr_dev {
|
||||
|
||||
void rtlsdr_set_gpio_bit(rtlsdr_dev_t *dev, uint8_t gpio, int val);
|
||||
static int rtlsdr_set_if_freq(rtlsdr_dev_t *dev, uint32_t freq);
|
||||
static int rtlsdr_update_ds(rtlsdr_dev_t *dev, uint32_t freq);
|
||||
|
||||
/* generic tuner interface functions, shall be moved to the tuner implementations */
|
||||
int e4000_init(void *dev) {
|
||||
@ -888,6 +889,8 @@ int rtlsdr_set_center_freq(rtlsdr_dev_t *dev, uint32_t freq)
|
||||
if (!dev || !dev->tuner)
|
||||
return -1;
|
||||
|
||||
rtlsdr_update_ds(dev, freq);
|
||||
|
||||
if (dev->direct_sampling) {
|
||||
r = rtlsdr_set_if_freq(dev, freq);
|
||||
} else if (dev->tuner && dev->tuner->set_freq) {
|
||||
@ -1225,6 +1228,28 @@ int rtlsdr_set_direct_sampling(rtlsdr_dev_t *dev, int on)
|
||||
return r;
|
||||
}
|
||||
|
||||
static int rtlsdr_update_ds(rtlsdr_dev_t *dev, uint32_t freq)
|
||||
{
|
||||
int new_ds;
|
||||
int curr_ds;
|
||||
|
||||
if (!dev)
|
||||
return -1;
|
||||
|
||||
curr_ds = rtlsdr_get_direct_sampling(dev);
|
||||
if (curr_ds < 0)
|
||||
return 1;
|
||||
|
||||
new_ds = freq < 28800000 ? 2 : 0;
|
||||
dev->direct_sampling = new_ds;
|
||||
|
||||
if (curr_ds != new_ds) {
|
||||
return rtlsdr_set_direct_sampling(dev, new_ds);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rtlsdr_get_direct_sampling(rtlsdr_dev_t *dev)
|
||||
{
|
||||
if (!dev)
|
||||
|
Loading…
Reference in New Issue
Block a user