1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-21 23:55:13 -05:00

BladerRF2 input support (4)

This commit is contained in:
f4exb 2018-09-24 08:43:16 +02:00
parent 945d30d91b
commit df505fcdef
4 changed files with 123 additions and 12 deletions

View File

@ -16,6 +16,8 @@
#include "devicebladerf2shared.h"
MESSAGE_CLASS_DEFINITION(DeviceBladeRF2Shared::MsgReportBuddyChange, Message)
DeviceBladeRF2Shared::DeviceBladeRF2Shared() :
m_dev(0),
m_channel(-1),

View File

@ -17,6 +17,7 @@
#ifndef DEVICES_BLADERF2_DEVICEBLADERF2SHARED_H_
#define DEVICES_BLADERF2_DEVICEBLADERF2SHARED_H_
#include "util/message.h"
#include "devicebladerf2.h"
class SampleSinkFifo;
@ -56,6 +57,35 @@ public:
virtual SampleSourceFifo *getFifo(unsigned int channel) = 0;
};
class MsgReportBuddyChange : public Message {
MESSAGE_CLASS_DECLARATION
public:
bool getBiasTee() const { return m_biasTee; }
bool getRxElseTx() const { return m_rxElseTx; }
static MsgReportBuddyChange* create(
bool biasTee,
bool rxElseTx)
{
return new MsgReportBuddyChange(
biasTee,
rxElseTx);
}
private:
bool m_biasTee;
bool m_rxElseTx; //!< tells which side initiated the message
MsgReportBuddyChange(
bool biasTee,
bool rxElseTx) :
Message(),
m_biasTee(biasTee),
m_rxElseTx(rxElseTx)
{ }
};
DeviceBladeRF2Shared();
~DeviceBladeRF2Shared();

View File

@ -431,6 +431,24 @@ bool BladeRF2Input::handleMessage(const Message& message)
return true;
}
else if (DeviceBladeRF2Shared::MsgReportBuddyChange::match(message))
{
DeviceBladeRF2Shared::MsgReportBuddyChange& report = (DeviceBladeRF2Shared::MsgReportBuddyChange&) message;
if (report.getRxElseTx())
{
m_settings.m_biasTee = report.getBiasTee();
}
if (getMessageQueueToGUI())
{
DeviceBladeRF2Shared::MsgReportBuddyChange *reportToGUI = DeviceBladeRF2Shared::MsgReportBuddyChange::create(
m_settings.m_biasTee, true);
getMessageQueueToGUI()->push(reportToGUI);
}
return true;
}
else if (MsgFileRecord::match(message))
{
MsgFileRecord& conf = (MsgFileRecord&) message;
@ -480,7 +498,9 @@ bool BladeRF2Input::handleMessage(const Message& message)
bool BladeRF2Input::applySettings(const BladeRF2InputSettings& settings, bool force)
{
bool forwardChange = false;
bool forwardChangeOwnDSP = false;
bool forwardChangeRxDSP = false;
bool forwardChangeAllDSP __attribute__((unused)) = false;
struct bladerf *dev = m_deviceShared.m_dev->getDev();
qDebug() << "BladeRF2Input::applySettings: m_dev: " << dev;
@ -493,7 +513,7 @@ bool BladeRF2Input::applySettings(const BladeRF2InputSettings& settings, bool fo
if ((m_settings.m_devSampleRate != settings.m_devSampleRate) || force)
{
forwardChange = true;
forwardChangeOwnDSP = true;
if (dev != 0)
{
@ -542,7 +562,7 @@ bool BladeRF2Input::applySettings(const BladeRF2InputSettings& settings, bool fo
if ((m_settings.m_log2Decim != settings.m_log2Decim) || force)
{
forwardChange = true;
forwardChangeOwnDSP = true;
if (m_deviceShared.m_inputThread != 0)
{
@ -563,7 +583,7 @@ bool BladeRF2Input::applySettings(const BladeRF2InputSettings& settings, bool fo
(DeviceSampleSource::fcPos_t) settings.m_fcPos,
settings.m_devSampleRate);
forwardChange = true;
forwardChangeOwnDSP = true;
if (dev != 0)
{
@ -578,7 +598,43 @@ bool BladeRF2Input::applySettings(const BladeRF2InputSettings& settings, bool fo
}
}
if (forwardChange)
if ((m_settings.m_biasTee != settings.m_biasTee) || force)
{
m_deviceShared.m_dev->setBiasTeeRx(settings.m_biasTee);
forwardChangeRxDSP = true;
}
if ((m_settings.m_globalGain != settings.m_globalGain) || force)
{
if (dev)
{
int status = bladerf_set_gain(dev, BLADERF_CHANNEL_RX(m_deviceShared.m_channel), settings.m_globalGain);
if (status < 0) {
qWarning("BladeRF2Input::applySettings: bladerf_set_gain(%d) failed: %s",
settings.m_globalGain, bladerf_strerror(status));
} else {
qDebug("BladeRF2Input::applySettings: bladerf_set_gain(%d)", settings.m_globalGain);
}
}
}
if ((m_settings.m_gainMode != settings.m_gainMode) || force)
{
if (dev)
{
int status = bladerf_set_gain_mode(dev, BLADERF_CHANNEL_RX(m_deviceShared.m_channel), (bladerf_gain_mode) settings.m_gainMode);
if (status < 0) {
qWarning("BladeRF2Input::applySettings: bladerf_set_gain_mode(%d) failed: %s",
settings.m_gainMode, bladerf_strerror(status));
} else {
qDebug("BladeRF2Input::applySettings: bladerf_set_gain_mode(%d)", settings.m_gainMode);
}
}
}
if (forwardChangeOwnDSP)
{
int sampleRate = settings.m_devSampleRate/(1<<settings.m_log2Decim);
DSPSignalNotification *notif = new DSPSignalNotification(sampleRate, settings.m_centerFrequency);
@ -586,6 +642,20 @@ bool BladeRF2Input::applySettings(const BladeRF2InputSettings& settings, bool fo
m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif);
}
if (forwardChangeRxDSP)
{
// send to source buddies
const std::vector<DeviceSourceAPI*>& sourceBuddies = m_deviceAPI->getSourceBuddies();
std::vector<DeviceSourceAPI*>::const_iterator itSource = sourceBuddies.begin();
for (; itSource != sourceBuddies.end(); ++itSource)
{
DeviceBladeRF2Shared::MsgReportBuddyChange *report = DeviceBladeRF2Shared::MsgReportBuddyChange::create(
settings.m_biasTee, true);
(*itSource)->getSampleSourceInputMessageQueue()->push(report);
}
}
m_settings = settings;
qDebug() << "BladeRF2Input::applySettings: "
@ -594,8 +664,11 @@ bool BladeRF2Input::applySettings(const BladeRF2InputSettings& settings, bool fo
<< " m_log2Decim: " << m_settings.m_log2Decim
<< " m_fcPos: " << m_settings.m_fcPos
<< " m_devSampleRate: " << m_settings.m_devSampleRate
<< " m_globalGain: " << m_settings.m_globalGain
<< " m_gainMode: " << m_settings.m_gainMode
<< " m_dcBlock: " << m_settings.m_dcBlock
<< " m_iqCorrection: " << m_settings.m_iqCorrection;
<< " m_iqCorrection: " << m_settings.m_iqCorrection
<< " m_biasTee: " << m_settings.m_biasTee;
return true;
}

View File

@ -590,9 +590,12 @@ bool LimeSDRInput::handleMessage(const Message& message)
m_settings.m_centerFrequency + ncoShift);
m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif);
DeviceLimeSDRShared::MsgReportBuddyChange *reportToGUI = DeviceLimeSDRShared::MsgReportBuddyChange::create(
m_settings.m_devSampleRate, m_settings.m_log2HardDecim, m_settings.m_centerFrequency, true);
getMessageQueueToGUI()->push(reportToGUI);
if (getMessageQueueToGUI())
{
DeviceLimeSDRShared::MsgReportBuddyChange *reportToGUI = DeviceLimeSDRShared::MsgReportBuddyChange::create(
m_settings.m_devSampleRate, m_settings.m_log2HardDecim, m_settings.m_centerFrequency, true);
getMessageQueueToGUI()->push(reportToGUI);
}
return true;
}
@ -603,9 +606,12 @@ bool LimeSDRInput::handleMessage(const Message& message)
m_settings.m_extClock = report.getExtClock();
m_settings.m_extClockFreq = report.getExtClockFeq();
DeviceLimeSDRShared::MsgReportClockSourceChange *reportToGUI = DeviceLimeSDRShared::MsgReportClockSourceChange::create(
m_settings.m_extClock, m_settings.m_extClockFreq);
getMessageQueueToGUI()->push(reportToGUI);
if (getMessageQueueToGUI())
{
DeviceLimeSDRShared::MsgReportClockSourceChange *reportToGUI = DeviceLimeSDRShared::MsgReportClockSourceChange::create(
m_settings.m_extClock, m_settings.m_extClockFreq);
getMessageQueueToGUI()->push(reportToGUI);
}
return true;
}