mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-08-14 23:43:43 -04:00
IQ swap: initial implementation in plugins
This commit is contained in:
@@ -54,7 +54,7 @@ RTLSDRInput::RTLSDRInput(DeviceAPI *deviceAPI) :
|
||||
m_deviceAPI(deviceAPI),
|
||||
m_settings(),
|
||||
m_dev(0),
|
||||
m_rtlSDRThread(0),
|
||||
m_rtlSDRThread(nullptr),
|
||||
m_deviceDescription(),
|
||||
m_running(false)
|
||||
{
|
||||
@@ -207,7 +207,7 @@ bool RTLSDRInput::start()
|
||||
m_rtlSDRThread->setSamplerate(m_settings.m_devSampleRate);
|
||||
m_rtlSDRThread->setLog2Decimation(m_settings.m_log2Decim);
|
||||
m_rtlSDRThread->setFcPos((int) m_settings.m_fcPos);
|
||||
|
||||
m_rtlSDRThread->setIQOrder(m_settings.m_iqOrder);
|
||||
m_rtlSDRThread->startWork();
|
||||
|
||||
mutexLocker.unlock();
|
||||
@@ -233,11 +233,11 @@ void RTLSDRInput::stop()
|
||||
{
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
|
||||
if (m_rtlSDRThread != 0)
|
||||
if (m_rtlSDRThread)
|
||||
{
|
||||
m_rtlSDRThread->stopWork();
|
||||
delete m_rtlSDRThread;
|
||||
m_rtlSDRThread = 0;
|
||||
m_rtlSDRThread = nullptr;
|
||||
}
|
||||
|
||||
m_running = false;
|
||||
@@ -434,7 +434,7 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, bool force)
|
||||
reverseAPIKeys.append("log2Decim");
|
||||
forwardChange = true;
|
||||
|
||||
if (m_rtlSDRThread != 0) {
|
||||
if (m_rtlSDRThread) {
|
||||
m_rtlSDRThread->setLog2Decimation(settings.m_log2Decim);
|
||||
}
|
||||
|
||||
@@ -445,7 +445,7 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, bool force)
|
||||
{
|
||||
reverseAPIKeys.append("fcPos");
|
||||
|
||||
if (m_rtlSDRThread != 0) {
|
||||
if (m_rtlSDRThread) {
|
||||
m_rtlSDRThread->setFcPos((int) settings.m_fcPos);
|
||||
}
|
||||
|
||||
@@ -465,6 +465,15 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, bool force)
|
||||
reverseAPIKeys.append("transverterDeltaFrequency");
|
||||
}
|
||||
|
||||
if ((m_settings.m_iqOrder != settings.m_iqOrder) || force)
|
||||
{
|
||||
reverseAPIKeys.append("iqOrder");
|
||||
|
||||
if (m_rtlSDRThread) {
|
||||
m_rtlSDRThread->setIQOrder(settings.m_iqOrder);
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_settings.m_centerFrequency != settings.m_centerFrequency)
|
||||
|| (m_settings.m_fcPos != settings.m_fcPos)
|
||||
|| (m_settings.m_log2Decim != settings.m_log2Decim)
|
||||
|
||||
@@ -38,6 +38,7 @@ void RTLSDRSettings::resetToDefaults()
|
||||
m_agc = false;
|
||||
m_noModMode = false;
|
||||
m_transverterMode = false;
|
||||
m_iqOrder = true;
|
||||
m_transverterDeltaFrequency = 0;
|
||||
m_rfBandwidth = 2500 * 1000; // Hz
|
||||
m_fileRecordName = "";
|
||||
@@ -70,6 +71,7 @@ QByteArray RTLSDRSettings::serialize() const
|
||||
s.writeString(17, m_reverseAPIAddress);
|
||||
s.writeU32(18, m_reverseAPIPort);
|
||||
s.writeU32(19, m_reverseAPIDeviceIndex);
|
||||
s.writeBool(20, m_iqOrder);
|
||||
|
||||
return s.final();
|
||||
}
|
||||
@@ -116,6 +118,7 @@ bool RTLSDRSettings::deserialize(const QByteArray& data)
|
||||
|
||||
d.readU32(19, &utmp, 0);
|
||||
m_reverseAPIDeviceIndex = utmp > 99 ? 99 : utmp;
|
||||
d.readBool(20, &m_iqOrder, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ struct RTLSDRSettings {
|
||||
bool m_agc;
|
||||
bool m_noModMode;
|
||||
bool m_transverterMode;
|
||||
bool m_iqOrder;
|
||||
qint64 m_transverterDeltaFrequency;
|
||||
quint32 m_rfBandwidth; //!< RF filter bandwidth in Hz
|
||||
QString m_fileRecordName;
|
||||
|
||||
@@ -32,7 +32,8 @@ RTLSDRThread::RTLSDRThread(rtlsdr_dev_t* dev, SampleSinkFifo* sampleFifo, QObjec
|
||||
m_sampleFifo(sampleFifo),
|
||||
m_samplerate(288000),
|
||||
m_log2Decim(4),
|
||||
m_fcPos(0)
|
||||
m_fcPos(0),
|
||||
m_iqOrder(true)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -89,13 +90,13 @@ void RTLSDRThread::run()
|
||||
}
|
||||
|
||||
// Decimate according to specified log2 (ex: log2=4 => decim=16)
|
||||
void RTLSDRThread::callback(const quint8* buf, qint32 len)
|
||||
void RTLSDRThread::callbackIQ(const quint8* buf, qint32 len)
|
||||
{
|
||||
SampleVector::iterator it = m_convertBuffer.begin();
|
||||
|
||||
if (m_log2Decim == 0)
|
||||
{
|
||||
m_decimators.decimate1(&it, buf, len);
|
||||
m_decimatorsIQ.decimate1(&it, buf, len);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -104,22 +105,22 @@ void RTLSDRThread::callback(const quint8* buf, qint32 len)
|
||||
switch (m_log2Decim)
|
||||
{
|
||||
case 1:
|
||||
m_decimators.decimate2_inf(&it, buf, len);
|
||||
m_decimatorsIQ.decimate2_inf(&it, buf, len);
|
||||
break;
|
||||
case 2:
|
||||
m_decimators.decimate4_inf(&it, buf, len);
|
||||
m_decimatorsIQ.decimate4_inf(&it, buf, len);
|
||||
break;
|
||||
case 3:
|
||||
m_decimators.decimate8_inf(&it, buf, len);
|
||||
m_decimatorsIQ.decimate8_inf(&it, buf, len);
|
||||
break;
|
||||
case 4:
|
||||
m_decimators.decimate16_inf(&it, buf, len);
|
||||
m_decimatorsIQ.decimate16_inf(&it, buf, len);
|
||||
break;
|
||||
case 5:
|
||||
m_decimators.decimate32_inf(&it, buf, len);
|
||||
m_decimatorsIQ.decimate32_inf(&it, buf, len);
|
||||
break;
|
||||
case 6:
|
||||
m_decimators.decimate64_inf(&it, buf, len);
|
||||
m_decimatorsIQ.decimate64_inf(&it, buf, len);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -130,22 +131,22 @@ void RTLSDRThread::callback(const quint8* buf, qint32 len)
|
||||
switch (m_log2Decim)
|
||||
{
|
||||
case 1:
|
||||
m_decimators.decimate2_sup(&it, buf, len);
|
||||
m_decimatorsIQ.decimate2_sup(&it, buf, len);
|
||||
break;
|
||||
case 2:
|
||||
m_decimators.decimate4_sup(&it, buf, len);
|
||||
m_decimatorsIQ.decimate4_sup(&it, buf, len);
|
||||
break;
|
||||
case 3:
|
||||
m_decimators.decimate8_sup(&it, buf, len);
|
||||
m_decimatorsIQ.decimate8_sup(&it, buf, len);
|
||||
break;
|
||||
case 4:
|
||||
m_decimators.decimate16_sup(&it, buf, len);
|
||||
m_decimatorsIQ.decimate16_sup(&it, buf, len);
|
||||
break;
|
||||
case 5:
|
||||
m_decimators.decimate32_sup(&it, buf, len);
|
||||
m_decimatorsIQ.decimate32_sup(&it, buf, len);
|
||||
break;
|
||||
case 6:
|
||||
m_decimators.decimate64_sup(&it, buf, len);
|
||||
m_decimatorsIQ.decimate64_sup(&it, buf, len);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -156,22 +157,118 @@ void RTLSDRThread::callback(const quint8* buf, qint32 len)
|
||||
switch (m_log2Decim)
|
||||
{
|
||||
case 1:
|
||||
m_decimators.decimate2_cen(&it, buf, len);
|
||||
m_decimatorsIQ.decimate2_cen(&it, buf, len);
|
||||
break;
|
||||
case 2:
|
||||
m_decimators.decimate4_cen(&it, buf, len);
|
||||
m_decimatorsIQ.decimate4_cen(&it, buf, len);
|
||||
break;
|
||||
case 3:
|
||||
m_decimators.decimate8_cen(&it, buf, len);
|
||||
m_decimatorsIQ.decimate8_cen(&it, buf, len);
|
||||
break;
|
||||
case 4:
|
||||
m_decimators.decimate16_cen(&it, buf, len);
|
||||
m_decimatorsIQ.decimate16_cen(&it, buf, len);
|
||||
break;
|
||||
case 5:
|
||||
m_decimators.decimate32_cen(&it, buf, len);
|
||||
m_decimatorsIQ.decimate32_cen(&it, buf, len);
|
||||
break;
|
||||
case 6:
|
||||
m_decimators.decimate64_cen(&it, buf, len);
|
||||
m_decimatorsIQ.decimate64_cen(&it, buf, len);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_sampleFifo->write(m_convertBuffer.begin(), it);
|
||||
|
||||
if(!m_running)
|
||||
rtlsdr_cancel_async(m_dev);
|
||||
}
|
||||
|
||||
void RTLSDRThread::callbackQI(const quint8* buf, qint32 len)
|
||||
{
|
||||
SampleVector::iterator it = m_convertBuffer.begin();
|
||||
|
||||
if (m_log2Decim == 0)
|
||||
{
|
||||
m_decimatorsQI.decimate1(&it, buf, len);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_fcPos == 0) // Infradyne
|
||||
{
|
||||
switch (m_log2Decim)
|
||||
{
|
||||
case 1:
|
||||
m_decimatorsQI.decimate2_inf(&it, buf, len);
|
||||
break;
|
||||
case 2:
|
||||
m_decimatorsQI.decimate4_inf(&it, buf, len);
|
||||
break;
|
||||
case 3:
|
||||
m_decimatorsQI.decimate8_inf(&it, buf, len);
|
||||
break;
|
||||
case 4:
|
||||
m_decimatorsQI.decimate16_inf(&it, buf, len);
|
||||
break;
|
||||
case 5:
|
||||
m_decimatorsQI.decimate32_inf(&it, buf, len);
|
||||
break;
|
||||
case 6:
|
||||
m_decimatorsQI.decimate64_inf(&it, buf, len);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (m_fcPos == 1) // Supradyne
|
||||
{
|
||||
switch (m_log2Decim)
|
||||
{
|
||||
case 1:
|
||||
m_decimatorsQI.decimate2_sup(&it, buf, len);
|
||||
break;
|
||||
case 2:
|
||||
m_decimatorsQI.decimate4_sup(&it, buf, len);
|
||||
break;
|
||||
case 3:
|
||||
m_decimatorsQI.decimate8_sup(&it, buf, len);
|
||||
break;
|
||||
case 4:
|
||||
m_decimatorsQI.decimate16_sup(&it, buf, len);
|
||||
break;
|
||||
case 5:
|
||||
m_decimatorsQI.decimate32_sup(&it, buf, len);
|
||||
break;
|
||||
case 6:
|
||||
m_decimatorsQI.decimate64_sup(&it, buf, len);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else // Centered
|
||||
{
|
||||
switch (m_log2Decim)
|
||||
{
|
||||
case 1:
|
||||
m_decimatorsQI.decimate2_cen(&it, buf, len);
|
||||
break;
|
||||
case 2:
|
||||
m_decimatorsQI.decimate4_cen(&it, buf, len);
|
||||
break;
|
||||
case 3:
|
||||
m_decimatorsQI.decimate8_cen(&it, buf, len);
|
||||
break;
|
||||
case 4:
|
||||
m_decimatorsQI.decimate16_cen(&it, buf, len);
|
||||
break;
|
||||
case 5:
|
||||
m_decimatorsQI.decimate32_cen(&it, buf, len);
|
||||
break;
|
||||
case 6:
|
||||
m_decimatorsQI.decimate64_cen(&it, buf, len);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -187,7 +284,12 @@ void RTLSDRThread::callback(const quint8* buf, qint32 len)
|
||||
|
||||
void RTLSDRThread::callbackHelper(unsigned char* buf, uint32_t len, void* ctx)
|
||||
{
|
||||
RTLSDRThread* thread = (RTLSDRThread*)ctx;
|
||||
thread->callback(buf, len);
|
||||
RTLSDRThread* thread = (RTLSDRThread*) ctx;
|
||||
|
||||
if (thread->m_iqOrder) {
|
||||
thread->callbackIQ(buf, len);
|
||||
} else {
|
||||
thread->callbackQI(buf, len);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ public:
|
||||
void setSamplerate(int samplerate);
|
||||
void setLog2Decimation(unsigned int log2_decim);
|
||||
void setFcPos(int fcPos);
|
||||
void setIQOrder(bool iqOrder) { m_iqOrder = iqOrder; }
|
||||
|
||||
private:
|
||||
QMutex m_startWaitMutex;
|
||||
@@ -52,11 +53,14 @@ private:
|
||||
int m_samplerate;
|
||||
unsigned int m_log2Decim;
|
||||
int m_fcPos;
|
||||
bool m_iqOrder;
|
||||
|
||||
DecimatorsU<qint32, quint8, SDR_RX_SAMP_SZ, 8, 127> m_decimators;
|
||||
DecimatorsU<qint32, quint8, SDR_RX_SAMP_SZ, 8, 127, true> m_decimatorsIQ;
|
||||
DecimatorsU<qint32, quint8, SDR_RX_SAMP_SZ, 8, 127, false> m_decimatorsQI;
|
||||
|
||||
void run();
|
||||
void callback(const quint8* buf, qint32 len);
|
||||
void callbackIQ(const quint8* buf, qint32 len);
|
||||
void callbackQI(const quint8* buf, qint32 len);
|
||||
|
||||
static void callbackHelper(unsigned char* buf, uint32_t len, void* ctx);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user