From 05914cc0bad994953568b86ae7b1a044344a871c Mon Sep 17 00:00:00 2001 From: Jon Beniston Date: Fri, 25 Aug 2023 15:04:57 +0100 Subject: [PATCH 1/3] Fix RTLSDR E4000 gain and bandwidth settings. Add tuner type to GUI. --- external/CMakeLists.txt | 6 +++++- plugins/samplesource/rtlsdr/rtlsdrgui.cpp | 10 +++++++++ plugins/samplesource/rtlsdr/rtlsdrgui.ui | 16 +++++++++++--- plugins/samplesource/rtlsdr/rtlsdrinput.cpp | 24 +++++++++++++++++++-- plugins/samplesource/rtlsdr/rtlsdrinput.h | 3 +++ 5 files changed, 53 insertions(+), 6 deletions(-) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 99bcd7f4a5..005886f183 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -1091,7 +1091,11 @@ if (WIN32 OR APPLE) endif () # Disable pkg-config to allow LIBUSB_INCLUDE_DIRS to be used set(DISABLE_PKGCONFIG "-DCMAKE_DISABLE_FIND_PACKAGE_PkgConfig=ON") - # needs libusb + # If we want to use https://github.com/librtlsdr/librtlsdr instead of https://github.com/osmocom/rtl-sdr.git + # - Don't use DISABLE_PKGCONFIG + # - Use -DLIBUSB_INCLUDE_DIR instead of -DLIBUSB_INCLUDE_DIRS + # - Build target is rtl_sdr rather than rtlsdr + # - Use tag development otherwise it will not build with MSVC ExternalProject_Add(rtlsdr GIT_REPOSITORY https://github.com/osmocom/rtl-sdr.git GIT_TAG ${RTLSDR_TAG} diff --git a/plugins/samplesource/rtlsdr/rtlsdrgui.cpp b/plugins/samplesource/rtlsdr/rtlsdrgui.cpp index 7141df793b..654f681fff 100644 --- a/plugins/samplesource/rtlsdr/rtlsdrgui.cpp +++ b/plugins/samplesource/rtlsdr/rtlsdrgui.cpp @@ -68,6 +68,14 @@ RTLSDRGui::RTLSDRGui(DeviceUISet *deviceUISet, QWidget* parent) : m_gains = m_sampleSource->getGains(); displayGains(); + rtlsdr_tuner tunerType = m_sampleSource->getTunerType(); + // Disable widgets not relevent for this tuner + bool offsetTuningEnabled = (tunerType != RTLSDR_TUNER_R820T) && (tunerType != RTLSDR_TUNER_R828D); + if (!offsetTuningEnabled) { + ui->offsetTuning->setEnabled(false); + } + ui->tunerType->setText("Tuner: " + m_sampleSource->getTunerName()); + connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()), Qt::QueuedConnection); m_sampleSource->setMessageQueueToGUI(&m_inputMessageQueue); } @@ -474,6 +482,7 @@ void RTLSDRGui::on_checkBox_stateChanged(int state) if (state == Qt::Checked) { ui->gain->setEnabled(false); + ui->offsetTuning->setEnabled(false); m_settings.m_noModMode = true; updateFrequencyLimits(); ui->centerFrequency->setValue(7000); @@ -482,6 +491,7 @@ void RTLSDRGui::on_checkBox_stateChanged(int state) else { ui->gain->setEnabled(true); + ui->offsetTuning->setEnabled(true); m_settings.m_noModMode = false; updateFrequencyLimits(); ui->centerFrequency->setValue(434000); diff --git a/plugins/samplesource/rtlsdr/rtlsdrgui.ui b/plugins/samplesource/rtlsdr/rtlsdrgui.ui index 97977c5b7e..190f2236a9 100644 --- a/plugins/samplesource/rtlsdr/rtlsdrgui.ui +++ b/plugins/samplesource/rtlsdr/rtlsdrgui.ui @@ -500,12 +500,12 @@ - + - RTLSDR special direct sampling mode (HF Bands) + Tuner type - No-mod DS + Tuner: Unknown @@ -522,6 +522,16 @@ + + + + RTLSDR special direct sampling mode (HF Bands) + + + DS + + + diff --git a/plugins/samplesource/rtlsdr/rtlsdrinput.cpp b/plugins/samplesource/rtlsdr/rtlsdrinput.cpp index 06561caaa7..a2cf99ea55 100644 --- a/plugins/samplesource/rtlsdr/rtlsdrinput.cpp +++ b/plugins/samplesource/rtlsdr/rtlsdrinput.cpp @@ -57,6 +57,7 @@ RTLSDRInput::RTLSDRInput(DeviceAPI *deviceAPI) : m_dev(0), m_rtlSDRThread(nullptr), m_deviceDescription("RTLSDR"), + m_tunerType(RTLSDR_TUNER_UNKNOWN), m_running(false) { m_sampleFifo.setLabel(m_deviceDescription); @@ -155,7 +156,9 @@ bool RTLSDRInput::openDevice() return false; } - qInfo("RTLSDRInput::openDevice: open: %s %s, SN: %s", vendor, product, serial); + m_tunerType = rtlsdr_get_tuner_type(m_dev); + + qInfo("RTLSDRInput::openDevice: open: %s %s, SN: %s Tuner: %s", vendor, product, serial, getTunerName()); m_deviceDescription = QString("%1 (SN %2)").arg(product).arg(serial); if ((res = rtlsdr_set_sample_rate(m_dev, 1152000)) < 0) @@ -504,7 +507,8 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, const QList& getGains() const { return m_gains; } + rtlsdr_tuner getTunerType() const { return m_tunerType; } + QString getTunerName() const; void set_ds_mode(int on); static const quint64 frequencyLowRangeMin; @@ -152,6 +154,7 @@ class RTLSDRInput : public DeviceSampleSource { RTLSDRThread* m_rtlSDRThread; QString m_deviceDescription; std::vector m_gains; + rtlsdr_tuner m_tunerType; bool m_running; QNetworkAccessManager *m_networkManager; QNetworkRequest m_networkRequest; From 2c636afa675fd42a3a5d7598532d9c5c4588b195 Mon Sep 17 00:00:00 2001 From: Jon Beniston Date: Sat, 26 Aug 2023 14:25:03 +0100 Subject: [PATCH 2/3] Add support for RTLSDRBlog V4 with HF upsampler --- plugins/samplesource/rtlsdr/rtlsdrgui.cpp | 2 +- plugins/samplesource/rtlsdr/rtlsdrinput.cpp | 9 +++++++-- plugins/samplesource/rtlsdr/rtlsdrinput.h | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/plugins/samplesource/rtlsdr/rtlsdrgui.cpp b/plugins/samplesource/rtlsdr/rtlsdrgui.cpp index 654f681fff..b952fc03c8 100644 --- a/plugins/samplesource/rtlsdr/rtlsdrgui.cpp +++ b/plugins/samplesource/rtlsdr/rtlsdrgui.cpp @@ -208,7 +208,7 @@ void RTLSDRGui::updateFrequencyLimits() { // values in kHz qint64 deltaFrequency = m_settings.m_transverterMode ? m_settings.m_transverterDeltaFrequency/1000 : 0; - qint64 minLimit = (m_settings.m_noModMode ? RTLSDRInput::frequencyLowRangeMin : RTLSDRInput::frequencyHighRangeMin) + deltaFrequency; + qint64 minLimit = (m_settings.m_noModMode ? RTLSDRInput::frequencyLowRangeMin : m_sampleSource->m_frequencyHighRangeMin) + deltaFrequency; qint64 maxLimit = (m_settings.m_noModMode ? RTLSDRInput::frequencyLowRangeMax : RTLSDRInput::frequencyHighRangeMax) + deltaFrequency; if (m_settings.m_transverterMode) diff --git a/plugins/samplesource/rtlsdr/rtlsdrinput.cpp b/plugins/samplesource/rtlsdr/rtlsdrinput.cpp index a2cf99ea55..20bfee7157 100644 --- a/plugins/samplesource/rtlsdr/rtlsdrinput.cpp +++ b/plugins/samplesource/rtlsdr/rtlsdrinput.cpp @@ -44,7 +44,6 @@ MESSAGE_CLASS_DEFINITION(RTLSDRInput::MsgStartStop, Message) const quint64 RTLSDRInput::frequencyLowRangeMin = 0UL; const quint64 RTLSDRInput::frequencyLowRangeMax = 275000UL; -const quint64 RTLSDRInput::frequencyHighRangeMin = 24000UL; const quint64 RTLSDRInput::frequencyHighRangeMax = 2400000UL; const int RTLSDRInput::sampleRateLowRangeMin = 225001; const int RTLSDRInput::sampleRateLowRangeMax = 300000; @@ -158,9 +157,15 @@ bool RTLSDRInput::openDevice() m_tunerType = rtlsdr_get_tuner_type(m_dev); - qInfo("RTLSDRInput::openDevice: open: %s %s, SN: %s Tuner: %s", vendor, product, serial, getTunerName()); + qInfo("RTLSDRInput::openDevice: open: %s %s, SN: %s Tuner: %s", vendor, product, serial, qPrintable(getTunerName())); m_deviceDescription = QString("%1 (SN %2)").arg(product).arg(serial); + if ((vendor == QStringLiteral("RTLSDRBlog")) && (product == QStringLiteral("Blog V4"))) { + m_frequencyHighRangeMin = 0; + } else { + m_frequencyHighRangeMin = 24000UL; + } + if ((res = rtlsdr_set_sample_rate(m_dev, 1152000)) < 0) { qCritical("RTLSDRInput::openDevice: could not set sample rate: 1024k S/s"); diff --git a/plugins/samplesource/rtlsdr/rtlsdrinput.h b/plugins/samplesource/rtlsdr/rtlsdrinput.h index 76c0349549..a0ee55c652 100644 --- a/plugins/samplesource/rtlsdr/rtlsdrinput.h +++ b/plugins/samplesource/rtlsdr/rtlsdrinput.h @@ -139,7 +139,7 @@ class RTLSDRInput : public DeviceSampleSource { static const quint64 frequencyLowRangeMin; static const quint64 frequencyLowRangeMax; - static const quint64 frequencyHighRangeMin; + quint64 m_frequencyHighRangeMin; static const quint64 frequencyHighRangeMax; static const int sampleRateLowRangeMin; static const int sampleRateLowRangeMax; From 1442f8bb14fbde17da25ff0601a82f97ce8cdf1c Mon Sep 17 00:00:00 2001 From: Jon Beniston Date: Sat, 26 Aug 2023 14:25:33 +0100 Subject: [PATCH 3/3] Update RTLSDR driver to include RTLSDRBlog V4 support --- external/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 005886f183..f88bd122ec 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -22,7 +22,7 @@ set(MIRISDR_TAG "v2.0.0") set(LIBSIGMF_TAG "new-namespaces") set(PTHREADS4W_TAG "Version-2-11-0-release") -set(RTLSDR_TAG 5e73f90f1d85d8db2e583f3dbf1cff052d71d59b) +set(RTLSDR_TAG 1261fbb285297da08f4620b18871b6d6d9ec2a7b) set(RTLSDR_UDEV OFF) set(SOAPYSDR_TAG "soapy-sdr-0.7.1") set(SOAPYSDR_SDRPLAY_TAG "soapy-sdrplay-0.2.0")