|
|
|
@ -113,6 +113,7 @@ struct rtlsdr_dev { |
|
|
|
|
rtlsdr_tuner_iface_t *tuner; |
|
|
|
|
uint32_t tun_xtal; /* Hz */ |
|
|
|
|
uint32_t freq; /* Hz */ |
|
|
|
|
uint32_t bw; |
|
|
|
|
uint32_t offs_freq; /* Hz */ |
|
|
|
|
int corr; /* ppm */ |
|
|
|
|
int gain; /* tenth dB */ |
|
|
|
@ -1008,6 +1009,24 @@ int rtlsdr_get_tuner_gains(rtlsdr_dev_t *dev, int *gains) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int rtlsdr_set_tuner_bandwidth(rtlsdr_dev_t *dev, uint32_t bw) |
|
|
|
|
{ |
|
|
|
|
int r = 0; |
|
|
|
|
|
|
|
|
|
if (!dev || !dev->tuner) |
|
|
|
|
return -1; |
|
|
|
|
|
|
|
|
|
if (dev->tuner->set_bw) { |
|
|
|
|
rtlsdr_set_i2c_repeater(dev, 1); |
|
|
|
|
r = dev->tuner->set_bw(dev, bw > 0 ? bw : dev->rate); |
|
|
|
|
rtlsdr_set_i2c_repeater(dev, 0); |
|
|
|
|
if (r) |
|
|
|
|
return r; |
|
|
|
|
dev->bw = bw; |
|
|
|
|
} |
|
|
|
|
return r; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int rtlsdr_set_tuner_gain(rtlsdr_dev_t *dev, int gain) |
|
|
|
|
{ |
|
|
|
|
int r = 0; |
|
|
|
@ -1095,14 +1114,14 @@ int rtlsdr_set_sample_rate(rtlsdr_dev_t *dev, uint32_t samp_rate) |
|
|
|
|
if ( ((double)samp_rate) != real_rate ) |
|
|
|
|
fprintf(stderr, "Exact sample rate is: %f Hz\n", real_rate); |
|
|
|
|
|
|
|
|
|
dev->rate = (uint32_t)real_rate; |
|
|
|
|
|
|
|
|
|
if (dev->tuner && dev->tuner->set_bw) { |
|
|
|
|
rtlsdr_set_i2c_repeater(dev, 1); |
|
|
|
|
dev->tuner->set_bw(dev, (int)real_rate); |
|
|
|
|
dev->tuner->set_bw(dev, dev->bw > 0 ? dev->bw : dev->rate); |
|
|
|
|
rtlsdr_set_i2c_repeater(dev, 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
dev->rate = (uint32_t)real_rate; |
|
|
|
|
|
|
|
|
|
tmp = (rsamp_ratio >> 16); |
|
|
|
|
r |= rtlsdr_demod_write_reg(dev, 1, 0x9f, tmp, 2); |
|
|
|
|
tmp = rsamp_ratio & 0xffff; |
|
|
|
@ -1219,6 +1238,7 @@ int rtlsdr_get_direct_sampling(rtlsdr_dev_t *dev) |
|
|
|
|
int rtlsdr_set_offset_tuning(rtlsdr_dev_t *dev, int on) |
|
|
|
|
{ |
|
|
|
|
int r = 0; |
|
|
|
|
int bw; |
|
|
|
|
|
|
|
|
|
if (!dev) |
|
|
|
|
return -1; |
|
|
|
@ -1236,7 +1256,14 @@ int rtlsdr_set_offset_tuning(rtlsdr_dev_t *dev, int on) |
|
|
|
|
|
|
|
|
|
if (dev->tuner && dev->tuner->set_bw) { |
|
|
|
|
rtlsdr_set_i2c_repeater(dev, 1); |
|
|
|
|
dev->tuner->set_bw(dev, on ? (2 * dev->offs_freq) : dev->rate); |
|
|
|
|
if (on) { |
|
|
|
|
bw = 2 * dev->offs_freq; |
|
|
|
|
} else if (dev->bw > 0) { |
|
|
|
|
bw = dev->bw; |
|
|
|
|
} else { |
|
|
|
|
bw = dev->rate; |
|
|
|
|
} |
|
|
|
|
dev->tuner->set_bw(dev, bw); |
|
|
|
|
rtlsdr_set_i2c_repeater(dev, 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|