1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
From 96cbba8b76c42bf9212b43edf20188f4fc512d97 Mon Sep 17 00:00:00 2001
From: int10h <12619481+brianmwaters@users.noreply.github.com>
Date: Tue, 14 Nov 2023 10:38:07 +0000
Subject: [PATCH 05/12] Add support for disabling PLL dithering (#68)
---
CMakeLists.txt | 6 +++++-
Settings.cpp | 27 +++++++++++++++++++++++++++
SoapyRTLSDR.hpp | 2 +-
3 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4763d75..2824d93 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -51,14 +51,18 @@ if (APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wc++11-extensions")
endif(APPLE)
-# check if rtlsdr library includes support for bias-tee
+# check if rtlsdr library includes support for bias-tee and dithering
include(CheckFunctionExists)
set(CMAKE_REQUIRED_LIBRARIES ${RTLSDR_LIBRARIES})
check_function_exists(rtlsdr_set_bias_tee HAS_RTLSDR_SET_BIAS_TEE)
+check_function_exists(rtlsdr_set_dithering HAS_RTLSDR_SET_DITHERING)
unset(CMAKE_REQUIRED_LIBRARIES)
if (HAS_RTLSDR_SET_BIAS_TEE)
add_definitions(-DHAS_RTLSDR_SET_BIAS_TEE)
endif()
+if (HAS_RTLSDR_SET_DITHERING)
+ add_definitions(-DHAS_RTLSDR_SET_DITHERING)
+endif()
set(OTHER_LIBS "" CACHE STRING "Other libraries")
diff --git a/Settings.cpp b/Settings.cpp
index 420ae1a..fc75814 100644
--- a/Settings.cpp
+++ b/Settings.cpp
@@ -47,6 +47,9 @@ SoapyRTLSDR::SoapyRTLSDR(const SoapySDR::Kwargs &args):
testMode(false),
#if HAS_RTLSDR_SET_BIAS_TEE
biasTee(false),
+#endif
+#if HAS_RTLSDR_SET_DITHERING
+ dithering(true),
#endif
ticks(false),
bufferedElems(0),
@@ -634,6 +637,18 @@ SoapySDR::ArgInfoList SoapyRTLSDR::getSettingInfo(void) const
setArgs.push_back(biasTeeArg);
#endif
+#if HAS_RTLSDR_SET_DITHERING
+ SoapySDR::ArgInfo ditheringArg;
+
+ ditheringArg.key = "dithering";
+ ditheringArg.value = "true";
+ ditheringArg.name = "Dithering";
+ ditheringArg.description = "RTL-SDR Dithering Mode";
+ ditheringArg.type = SoapySDR::ArgInfo::BOOL;
+
+ setArgs.push_back(ditheringArg);
+#endif
+
SoapySDR_logf(SOAPY_SDR_DEBUG, "SETARGS?");
return setArgs;
@@ -685,6 +700,14 @@ void SoapyRTLSDR::writeSetting(const std::string &key, const std::string &value)
rtlsdr_set_bias_tee(dev, biasTee ? 1 : 0);
}
#endif
+#if HAS_RTLSDR_SET_DITHERING
+ else if (key == "dithering")
+ {
+ dithering = (value == "true") ? true : false;
+ SoapySDR_logf(SOAPY_SDR_DEBUG, "RTL-SDR dithering mode: %s", dithering ? "true" : "false");
+ rtlsdr_set_dithering(dev, dithering ? 1 : 0);
+ }
+#endif
}
std::string SoapyRTLSDR::readSetting(const std::string &key) const
@@ -702,6 +725,10 @@ std::string SoapyRTLSDR::readSetting(const std::string &key) const
#if HAS_RTLSDR_SET_BIAS_TEE
} else if (key == "biastee") {
return biasTee?"true":"false";
+#endif
+#if HAS_RTLSDR_SET_DITHERING
+ } else if (key == "dithering") {
+ return dithering?"true":"false";
#endif
}
diff --git a/SoapyRTLSDR.hpp b/SoapyRTLSDR.hpp
index 3add942..0fa2571 100644
--- a/SoapyRTLSDR.hpp
+++ b/SoapyRTLSDR.hpp
@@ -247,7 +247,7 @@ private:
uint32_t sampleRate, centerFrequency, bandwidth;
int ppm, directSamplingMode;
size_t numBuffers, bufferLength, asyncBuffs;
- bool iqSwap, gainMode, offsetMode, digitalAGC, testMode, biasTee;
+ bool iqSwap, gainMode, offsetMode, digitalAGC, testMode, biasTee, dithering;
double IFGain[6], tunerGain;
std::atomic<long long> ticks;
--
2.47.3
|