diff --git a/devices/plutosdr/deviceplutosdrbox.cpp b/devices/plutosdr/deviceplutosdrbox.cpp index 1fce4e2ae..c5fe3b496 100644 --- a/devices/plutosdr/deviceplutosdrbox.cpp +++ b/devices/plutosdr/deviceplutosdrbox.cpp @@ -653,6 +653,22 @@ void DevicePlutoSDRBox::closeSecondTx() if (m_txChannels.size() > 3) { disableChannel(m_txChannels.at(3), m_txMask); } } +// Other applications (e.g. SoapyPlutoSDR) may leave an LO powered down, and the Tx LO +// stays up in FDD mode even with no stream running, so set the LO state explicitly +void DevicePlutoSDRBox::setRxLOPowerdown(bool powerdown) +{ + std::vector params; + params.push_back(std::string("out_altvoltage0_RX_LO_powerdown=") + (powerdown ? "1" : "0")); + set_params(DEVICE_PHY, params); +} + +void DevicePlutoSDRBox::setTxLOPowerdown(bool powerdown) +{ + std::vector params; + params.push_back(std::string("out_altvoltage1_TX_LO_powerdown=") + (powerdown ? "1" : "0")); + set_params(DEVICE_PHY, params); +} + struct iio_buffer *DevicePlutoSDRBox::createRxBuffer(unsigned int size, bool cyclic) { #ifdef LIBIIO_V1 diff --git a/devices/plutosdr/deviceplutosdrbox.h b/devices/plutosdr/deviceplutosdrbox.h index a5a65d25b..9229b0e4e 100644 --- a/devices/plutosdr/deviceplutosdrbox.h +++ b/devices/plutosdr/deviceplutosdrbox.h @@ -93,6 +93,8 @@ public: void closeTx(); //!< Close first Tx (Tx0) void closeSecondRx(); //!< Close second Rx (Rx1) void closeSecondTx(); //!< Close second Tx (Tx1) + void setRxLOPowerdown(bool powerdown); //!< Power down (true) or up (false) the Rx LO + void setTxLOPowerdown(bool powerdown); //!< Power down (true) or up (false) the Tx LO int getNbRx() const { return m_rxChannels.size() / 2; } int getNbTx() const { return m_txChannels.size() / 2; } int getRxSampleBytes() const { return m_rxSampleBytes; } diff --git a/plugins/samplemimo/plutosdrmimo/plutosdrmimo.cpp b/plugins/samplemimo/plutosdrmimo/plutosdrmimo.cpp index a6b5ab79e..2094f710c 100644 --- a/plugins/samplemimo/plutosdrmimo/plutosdrmimo.cpp +++ b/plugins/samplemimo/plutosdrmimo/plutosdrmimo.cpp @@ -138,6 +138,8 @@ bool PlutoSDRMIMO::openDevice() } } + m_plutoParams->getBox()->setTxLOPowerdown(true); // do not radiate LO leakage until Tx is started + return true; } @@ -181,6 +183,7 @@ bool PlutoSDRMIMO::startRx() } qDebug("PlutoSDRMIMO::startRx"); + m_plutoParams->getBox()->setRxLOPowerdown(false); m_sourceThread = new PlutoSDRMIThread(m_plutoParams->getBox()); connect(m_sourceThread, &PlutoSDRMIThread::error, this, &PlutoSDRMIMO::handleError, Qt::QueuedConnection); @@ -220,6 +223,7 @@ bool PlutoSDRMIMO::startTx() } qDebug("PlutoSDRMIMO::startTx"); + m_plutoParams->getBox()->setTxLOPowerdown(false); m_sinkThread = new PlutoSDRMOThread(m_plutoParams->getBox()); connect(m_sinkThread, &PlutoSDRMOThread::error, this, &PlutoSDRMIMO::handleError, Qt::QueuedConnection); @@ -272,6 +276,7 @@ void PlutoSDRMIMO::stopRx() m_plutoParams->getBox()->deleteRxBuffer(); m_plutoTxBuffer = nullptr; + m_plutoParams->getBox()->setRxLOPowerdown(true); } void PlutoSDRMIMO::stopTx() @@ -303,6 +308,7 @@ void PlutoSDRMIMO::stopTx() m_plutoParams->getBox()->deleteTxBuffer(); m_plutoRxBuffer = nullptr; + m_plutoParams->getBox()->setTxLOPowerdown(true); } void PlutoSDRMIMO::handleError(int errorCode) diff --git a/plugins/samplesink/plutosdroutput/plutosdroutput.cpp b/plugins/samplesink/plutosdroutput/plutosdroutput.cpp index c52d45ed8..cb6206185 100644 --- a/plugins/samplesink/plutosdroutput/plutosdroutput.cpp +++ b/plugins/samplesink/plutosdroutput/plutosdroutput.cpp @@ -124,6 +124,8 @@ bool PlutoSDROutput::start() return false; } + m_deviceShared.m_deviceParams->getBox()->setTxLOPowerdown(false); + // start / stop streaming is done in the thread. m_plutoSDROutputThread = new PlutoSDROutputThread(PLUTOSDR_BLOCKSIZE_SAMPLES, m_deviceShared.m_deviceParams->getBox(), &m_sampleSourceFifo); @@ -172,6 +174,10 @@ void PlutoSDROutput::stop() delete m_plutoSDROutputThread; m_plutoSDROutputThread = nullptr; } + + if (m_deviceShared.m_deviceParams && m_deviceShared.m_deviceParams->getBox()) { + m_deviceShared.m_deviceParams->getBox()->setTxLOPowerdown(true); + } } void PlutoSDROutput::handleError(int errorCode) @@ -193,6 +199,10 @@ void PlutoSDROutput::handleError(int errorCode) m_plutoSDROutputThread = nullptr; } + if (m_deviceShared.m_deviceParams && m_deviceShared.m_deviceParams->getBox()) { + m_deviceShared.m_deviceParams->getBox()->setTxLOPowerdown(true); + } + const QString errorMessage = tr("Radio needs a restart: %1 (%2)") .arg(strerror(-errorCode)) @@ -398,6 +408,7 @@ bool PlutoSDROutput::openDevice() } m_plutoTxBuffer = plutoBox->createTxBuffer(PLUTOSDR_BLOCKSIZE_SAMPLES, false); // PlutoSDR buffer size is counted in number of (I,Q) samples + plutoBox->setTxLOPowerdown(true); // do not radiate LO leakage until started return true; } diff --git a/plugins/samplesource/plutosdrinput/plutosdrinput.cpp b/plugins/samplesource/plutosdrinput/plutosdrinput.cpp index 87633906a..c8b97e630 100644 --- a/plugins/samplesource/plutosdrinput/plutosdrinput.cpp +++ b/plugins/samplesource/plutosdrinput/plutosdrinput.cpp @@ -124,6 +124,8 @@ bool PlutoSDRInput::start() return false; } + m_deviceShared.m_deviceParams->getBox()->setRxLOPowerdown(false); + // start / stop streaming is done in the thread. m_plutoSDRInputThread = new PlutoSDRInputThread(PLUTOSDR_BLOCKSIZE_SAMPLES, m_deviceShared.m_deviceParams->getBox(), &m_sampleFifo); @@ -173,6 +175,10 @@ void PlutoSDRInput::stop() delete m_plutoSDRInputThread; m_plutoSDRInputThread = nullptr; } + + if (m_deviceShared.m_deviceParams && m_deviceShared.m_deviceParams->getBox()) { + m_deviceShared.m_deviceParams->getBox()->setRxLOPowerdown(true); + } } void PlutoSDRInput::handleError(int errorCode)