mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-07-25 11:34:09 -04:00
IQ swap: initial implementation in plugins
This commit is contained in:
@@ -53,7 +53,7 @@ MESSAGE_CLASS_DEFINITION(LimeSDRInput::MsgStartStop, Message)
|
||||
LimeSDRInput::LimeSDRInput(DeviceAPI *deviceAPI) :
|
||||
m_deviceAPI(deviceAPI),
|
||||
m_settings(),
|
||||
m_limeSDRInputThread(0),
|
||||
m_limeSDRInputThread(nullptr),
|
||||
m_deviceDescription("LimeSDRInput"),
|
||||
m_running(false),
|
||||
m_channelAcquired(false)
|
||||
@@ -422,7 +422,7 @@ bool LimeSDRInput::start()
|
||||
applySettings(m_settings, true);
|
||||
|
||||
m_limeSDRInputThread->setLog2Decimation(m_settings.m_log2SoftDecim);
|
||||
|
||||
m_limeSDRInputThread->setIQOrder(m_settings.m_iqOrder);
|
||||
m_limeSDRInputThread->startWork();
|
||||
|
||||
m_deviceShared.m_thread = m_limeSDRInputThread;
|
||||
@@ -439,7 +439,7 @@ void LimeSDRInput::stop()
|
||||
{
|
||||
m_limeSDRInputThread->stopWork();
|
||||
delete m_limeSDRInputThread;
|
||||
m_limeSDRInputThread = 0;
|
||||
m_limeSDRInputThread = nullptr;
|
||||
}
|
||||
|
||||
m_deviceShared.m_thread = 0;
|
||||
@@ -1096,6 +1096,15 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_settings.m_iqOrder != settings.m_iqOrder) || force)
|
||||
{
|
||||
reverseAPIKeys.append("iqOrder");
|
||||
|
||||
if (m_limeSDRInputThread) {
|
||||
m_limeSDRInputThread->setIQOrder(settings.m_iqOrder);
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_settings.m_antennaPath != settings.m_antennaPath) || force)
|
||||
{
|
||||
reverseAPIKeys.append("antennaPath");
|
||||
|
||||
@@ -46,6 +46,7 @@ void LimeSDRInputSettings::resetToDefaults()
|
||||
m_extClockFreq = 10000000; // 10 MHz
|
||||
m_transverterMode = false;
|
||||
m_transverterDeltaFrequency = 0;
|
||||
m_iqOrder = true;
|
||||
m_fileRecordName = "";
|
||||
m_gpioDir = 0;
|
||||
m_gpioPins = 0;
|
||||
@@ -85,6 +86,7 @@ QByteArray LimeSDRInputSettings::serialize() const
|
||||
s.writeString(25, m_reverseAPIAddress);
|
||||
s.writeU32(26, m_reverseAPIPort);
|
||||
s.writeU32(27, m_reverseAPIDeviceIndex);
|
||||
s.writeBool(28, m_iqOrder);
|
||||
return s.final();
|
||||
}
|
||||
|
||||
@@ -141,6 +143,7 @@ bool LimeSDRInputSettings::deserialize(const QByteArray& data)
|
||||
|
||||
d.readU32(27, &uintval, 0);
|
||||
m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval;
|
||||
d.readBool(28, &m_iqOrder, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ struct LimeSDRInputSettings
|
||||
uint32_t m_extClockFreq; //!< Frequency (Hz) of external clock source
|
||||
bool m_transverterMode;
|
||||
qint64 m_transverterDeltaFrequency;
|
||||
bool m_iqOrder;
|
||||
QString m_fileRecordName;
|
||||
uint8_t m_gpioDir; //!< GPIO pin direction LSB first; 0 input, 1 output
|
||||
uint8_t m_gpioPins; //!< GPIO pins to write; LSB first
|
||||
|
||||
@@ -27,7 +27,8 @@ LimeSDRInputThread::LimeSDRInputThread(lms_stream_t* stream, SampleSinkFifo* sam
|
||||
m_stream(stream),
|
||||
m_convertBuffer(DeviceLimeSDR::blockSize),
|
||||
m_sampleFifo(sampleFifo),
|
||||
m_log2Decim(0)
|
||||
m_log2Decim(0),
|
||||
m_iqOrder(true)
|
||||
{
|
||||
std::fill(m_buf, m_buf + 2*DeviceLimeSDR::blockSize, 0);
|
||||
}
|
||||
@@ -94,39 +95,43 @@ void LimeSDRInputThread::run()
|
||||
break;
|
||||
}
|
||||
|
||||
callback(m_buf, 2 * res);
|
||||
if (m_iqOrder) {
|
||||
callbackIQ(m_buf, 2 * res);
|
||||
} else {
|
||||
callbackQI(m_buf, 2 * res);
|
||||
}
|
||||
}
|
||||
|
||||
m_running = false;
|
||||
}
|
||||
|
||||
// Decimate according to specified log2 (ex: log2=4 => decim=16)
|
||||
void LimeSDRInputThread::callback(const qint16* buf, qint32 len)
|
||||
void LimeSDRInputThread::callbackIQ(const qint16* buf, qint32 len)
|
||||
{
|
||||
SampleVector::iterator it = m_convertBuffer.begin();
|
||||
|
||||
switch (m_log2Decim)
|
||||
{
|
||||
case 0:
|
||||
m_decimators.decimate1(&it, buf, len);
|
||||
m_decimatorsIQ.decimate1(&it, buf, len);
|
||||
break;
|
||||
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;
|
||||
@@ -135,3 +140,36 @@ void LimeSDRInputThread::callback(const qint16* buf, qint32 len)
|
||||
m_sampleFifo->write(m_convertBuffer.begin(), it);
|
||||
}
|
||||
|
||||
void LimeSDRInputThread::callbackQI(const qint16* buf, qint32 len)
|
||||
{
|
||||
SampleVector::iterator it = m_convertBuffer.begin();
|
||||
|
||||
switch (m_log2Decim)
|
||||
{
|
||||
case 0:
|
||||
m_decimatorsQI.decimate1(&it, buf, len);
|
||||
break;
|
||||
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;
|
||||
}
|
||||
|
||||
m_sampleFifo->write(m_convertBuffer.begin(), it);
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ public:
|
||||
virtual void setDeviceSampleRate(int sampleRate) { (void) sampleRate; }
|
||||
virtual bool isRunning() { return m_running; }
|
||||
void setLog2Decimation(unsigned int log2_decim);
|
||||
void setIQOrder(bool iqOrder) { m_iqOrder = iqOrder; }
|
||||
|
||||
private:
|
||||
QMutex m_startWaitMutex;
|
||||
@@ -54,11 +55,14 @@ private:
|
||||
SampleSinkFifo* m_sampleFifo;
|
||||
|
||||
unsigned int m_log2Decim; // soft decimation
|
||||
bool m_iqOrder;
|
||||
|
||||
Decimators<qint32, qint16, SDR_RX_SAMP_SZ, 12> m_decimators;
|
||||
Decimators<qint32, qint16, SDR_RX_SAMP_SZ, 12, true> m_decimatorsIQ;
|
||||
Decimators<qint32, qint16, SDR_RX_SAMP_SZ, 12, false> m_decimatorsQI;
|
||||
|
||||
void run();
|
||||
void callback(const qint16* buf, qint32 len);
|
||||
void callbackIQ(const qint16* buf, qint32 len);
|
||||
void callbackQI(const qint16* buf, qint32 len);
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user