aboutsummaryrefslogtreecommitdiffstats
path: root/src/common/soapy.c
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2017-03-18 09:30:26 +0100
committerAndreas Eversberg <jolly@eversberg.eu>2017-05-15 21:46:27 +0200
commit9dda9e1efc2ff5b820438524c666900f93fe3a72 (patch)
treee43aa8afb434e394ded1b5ff7198fc103dd7e641 /src/common/soapy.c
parent1445ca2facfebfb175ff6234a3ab27b21123d2d7 (diff)
SDR: Add option to set IF bandwidth. If not defined, sampling rate is used.
Diffstat (limited to 'src/common/soapy.c')
-rw-r--r--src/common/soapy.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/common/soapy.c b/src/common/soapy.c
index 76e213e..1f56456 100644
--- a/src/common/soapy.c
+++ b/src/common/soapy.c
@@ -35,9 +35,9 @@ static double samplerate;
static long long rx_count = 0;
static long long tx_count = 0;
-int soapy_open(const char *device_args, double tx_frequency, double rx_frequency, double rate, double rx_gain, double tx_gain)
+int soapy_open(const char *device_args, double tx_frequency, double rx_frequency, double rate, double rx_gain, double tx_gain, double bandwidth)
{
- double got_frequency, got_rate, got_gain;
+ double got_frequency, got_rate, got_gain, got_bandwidth;
size_t channel = 0;
char *arg_string = strdup(device_args), *key, *val;
SoapySDRKwargs args;
@@ -144,6 +144,32 @@ int soapy_open(const char *device_args, double tx_frequency, double rx_frequency
return -EINVAL;
}
+ /* set bandwidth */
+ if (SoapySDRDevice_setBandwidth(sdr, SOAPY_SDR_TX, channel, bandwidth) != 0) {
+ PDEBUG(DUHD, DEBUG_ERROR, "Failed to set TX bandwidth to %.0f Hz\n", bandwidth);
+ soapy_close();
+ return -EIO;
+ }
+ if (SoapySDRDevice_setBandwidth(sdr, SOAPY_SDR_RX, channel, bandwidth) != 0) {
+ PDEBUG(DUHD, DEBUG_ERROR, "Failed to set RX bandwidth to %.0f Hz\n", bandwidth);
+ soapy_close();
+ return -EIO;
+ }
+
+ /* see what bandwidth actually is */
+ got_bandwidth = SoapySDRDevice_getBandwidth(sdr, SOAPY_SDR_TX, channel);
+ if (got_bandwidth != bandwidth) {
+ PDEBUG(DUHD, DEBUG_ERROR, "Given TX bandwidth %.0f Hz is not supported, try %0.f Hz\n", bandwidth, got_bandwidth);
+ soapy_close();
+ return -EINVAL;
+ }
+ got_bandwidth = SoapySDRDevice_getBandwidth(sdr, SOAPY_SDR_RX, channel);
+ if (got_bandwidth != bandwidth) {
+ PDEBUG(DUHD, DEBUG_ERROR, "Given RX bandwidth %.0f Hz is not supported, try %0.f Hz\n", bandwidth, got_bandwidth);
+ soapy_close();
+ return -EINVAL;
+ }
+
/* set up streamer */
if (SoapySDRDevice_setupStream(sdr, &txStream, SOAPY_SDR_TX, SOAPY_SDR_CF32, &channel, 1, NULL) != 0) {
PDEBUG(DUHD, DEBUG_ERROR, "Failed to set TX streamer args\n");