Hello Jenkins Builder, I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/2186 to look at the new patch set (#2). radioInterface: Remove UmTRX 'diversity' option The 'diversity' option was an experimental 2 antenna receiver implementation for UmTRX. The implementation has not been maintained and current working status is unknown. In addition to code rot, Coverity is triggering errors in the associated code sections. Removal of code cleans up many cases of special handling that were necessary to accommodate the implementation. Change-Id: I46752ccf5dbcffbec806081dec03e69a0fbdcdb7 --- M Transceiver52M/Makefile.am M Transceiver52M/UHDDevice.cpp M Transceiver52M/USRPDevice.cpp M Transceiver52M/osmo-trx.cpp M Transceiver52M/radioDevice.h M Transceiver52M/radioInterface.cpp M Transceiver52M/radioInterface.h D Transceiver52M/radioInterfaceDiversity.cpp M Transceiver52M/sigProcLib.cpp 9 files changed, 13 insertions(+), 400 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/86/2186/2 diff --git a/Transceiver52M/Makefile.am b/Transceiver52M/Makefile.am index 68cdf74..c2ab9ca 100644 --- a/Transceiver52M/Makefile.am +++ b/Transceiver52M/Makefile.am @@ -67,8 +67,7 @@ $(COMMON_SOURCES) \ Resampler.cpp \ radioInterfaceResamp.cpp \ - radioInterfaceMulti.cpp \ - radioInterfaceDiversity.cpp + radioInterfaceMulti.cpp bin_PROGRAMS = osmo-trx diff --git a/Transceiver52M/UHDDevice.cpp b/Transceiver52M/UHDDevice.cpp index c5ea4c1..ce6d1be 100644 --- a/Transceiver52M/UHDDevice.cpp +++ b/Transceiver52M/UHDDevice.cpp @@ -139,16 +139,6 @@ #define NUM_UHD_OFFSETS (sizeof(uhd_offsets)/sizeof(uhd_offsets[0])) /* - * Offset handling for special cases. Currently used for UmTRX dual channel - * diversity receiver only. - */ -static struct uhd_dev_offset special_offsets[] = { - { UMTRX, 1, 1, 8.0875e-5, "UmTRX diversity, 1 SPS" }, - { UMTRX, 4, 1, 5.2103e-5, "UmTRX diversity, 4 SPS" }, -}; - - -/* * Select sample rate based on device type and requested samples-per-symbol. * The base rate is either GSM symbol rate, 270.833 kHz, or the minimum * usable channel spacing of 400 kHz. @@ -156,15 +146,6 @@ static double select_rate(uhd_dev_type type, int sps, RadioDevice::InterfaceType iface) { - if (iface == RadioDevice::DIVERSITY) { - if (type == UMTRX) - return GSMRATE * 4; - - LOG(ALERT) << "Diversity supported on UmTRX only"; - return -9999.99; - } - - if ((sps != 4) && (sps != 1)) return -9999.99; @@ -499,30 +480,13 @@ return 0.0; } - /* Special cases (e.g. diversity receiver) */ - if (iface == DIVERSITY) { - if ((dev_type != UMTRX) || (rx_sps != 1)) { - LOG(ALERT) << "Unsupported device configuration"; - return 0.0; - } - - switch (tx_sps) { - case 1: - offset = &special_offsets[0]; + /* Search for matching offset value */ + for (size_t i = 0; i < NUM_UHD_OFFSETS; i++) { + if ((dev_type == uhd_offsets[i].type) && + (tx_sps == uhd_offsets[i].tx_sps) && + (rx_sps == uhd_offsets[i].rx_sps)) { + offset = &uhd_offsets[i]; break; - case 4: - default: - offset = &special_offsets[1]; - } - } else { - /* Search for matching offset value */ - for (size_t i = 0; i < NUM_UHD_OFFSETS; i++) { - if ((dev_type == uhd_offsets[i].type) && - (tx_sps == uhd_offsets[i].tx_sps) && - (rx_sps == uhd_offsets[i].rx_sps)) { - offset = &uhd_offsets[i]; - break; - } } } @@ -860,9 +824,6 @@ double _rx_rate = select_rate(dev_type, rx_sps, iface); double _tx_rate = select_rate(dev_type, tx_sps, iface); - if (iface == DIVERSITY) - _rx_rate = select_rate(dev_type, 1, iface); - if ((_tx_rate < 0.0) || (_rx_rate < 0.0)) return -1; if (set_rates(_tx_rate, _rx_rate) < 0) @@ -873,8 +834,7 @@ // Setting LMS6002D LPF to 500kHz gives us the best signal quality for (size_t i = 0; i < chans; i++) { usrp_dev->set_tx_bandwidth(500*1000*2, i); - if (iface != DIVERSITY) - usrp_dev->set_rx_bandwidth(500*1000*2, i); + usrp_dev->set_rx_bandwidth(500*1000*2, i); } } else if (dev_type == LIMESDR) { for (size_t i = 0; i < chans; i++) { @@ -917,8 +877,6 @@ // Print configuration LOG(INFO) << "\n" << usrp_dev->get_pp_string(); - if (iface == DIVERSITY) - return DIVERSITY; if (iface == MULTI_ARFCN) return MULTI_ARFCN; diff --git a/Transceiver52M/USRPDevice.cpp b/Transceiver52M/USRPDevice.cpp index 1092600..3d20411 100644 --- a/Transceiver52M/USRPDevice.cpp +++ b/Transceiver52M/USRPDevice.cpp @@ -601,7 +601,7 @@ #endif RadioDevice *RadioDevice::make(size_t tx_sps, size_t rx_sps, - size_t chans, bool diversity, double) + size_t chans, double) { return new USRPDevice(tx_sps); } diff --git a/Transceiver52M/osmo-trx.cpp b/Transceiver52M/osmo-trx.cpp index e07fd8e..40e482a 100644 --- a/Transceiver52M/osmo-trx.cpp +++ b/Transceiver52M/osmo-trx.cpp @@ -72,7 +72,6 @@ bool extref; bool gpsref; Transceiver::FillerType filler; - bool diversity; bool mcbts; double offset; double rssi_offset; @@ -101,7 +100,6 @@ } edgestr = config->edge ? "Enabled" : "Disabled"; - divstr = config->diversity ? "Enabled" : "Disabled"; mcstr = config->mcbts ? "Enabled" : "Disabled"; if (config->extref) @@ -142,7 +140,6 @@ ost << " Reference............... " << refstr << std::endl; ost << " C0 Filler Table......... " << fillstr << std::endl; ost << " Multi-Carrier........... " << mcstr << std::endl; - ost << " Diversity............... " << divstr << std::endl; ost << " Tuning offset........... " << config->offset << std::endl; ost << " RSSI to dBm offset...... " << config->rssi_offset << std::endl; ost << " Swap channels........... " << config->swap_channels << std::endl; @@ -172,12 +169,6 @@ case RadioDevice::RESAMP_100M: radio = new RadioInterfaceResamp(usrp, config->tx_sps, config->rx_sps); - break; - case RadioDevice::DIVERSITY: - - - radio = new RadioInterfaceDiversity(usrp, config->tx_sps, - config->chans); break; case RadioDevice::MULTI_ARFCN: radio = new RadioInterfaceMulti(usrp, config->tx_sps, @@ -257,7 +248,6 @@ " -i IP address of GSM core\n" " -p Base port number\n" " -e Enable EDGE receiver\n" - " -d Enable dual channel diversity receiver (deprecated)\n" " -m Enable multi-ARFCN transceiver (default=disabled)\n" " -x Enable external 10 MHz reference\n" " -g Enable GPSDO reference\n" @@ -288,7 +278,6 @@ config->gpsref = false; config->filler = Transceiver::FILLER_ZERO; config->mcbts = false; - config->diversity = false; config->offset = 0.0; config->rssi_offset = 0.0; config->swap_channels = false; @@ -317,9 +306,6 @@ break; case 'm': config->mcbts = true; - break; - case 'd': - config->diversity = true; break; case 'x': config->extref = true; @@ -371,24 +357,6 @@ if (config->gpsref && config->extref) { printf("External and GPSDO references unavailable at the same time\n\n"); goto bad_config; - } - - /* Special restrictions on (deprecated) diversity configuration */ - if (config->diversity) { - if (config->mcbts || config->edge) { - std::cout << "Multi-carrier/EDGE diversity unsupported" << std::endl; - goto bad_config; - } - - if (config->rx_sps != 1) { - std::cout << "Diversity only supported with 1 SPS" << std::endl; - goto bad_config; - } - - if (config->chans != 2) { - std::cout << "Diversity only supported with 2 channels" << std::endl; - goto bad_config; - } } if (config->edge && (config->filler == Transceiver::FILLER_NORM_RAND)) diff --git a/Transceiver52M/radioDevice.h b/Transceiver52M/radioDevice.h index 711d678..3624c58 100644 --- a/Transceiver52M/radioDevice.h +++ b/Transceiver52M/radioDevice.h @@ -41,7 +41,6 @@ RESAMP_64M, RESAMP_100M, MULTI_ARFCN, - DIVERSITY, }; enum ReferenceType { diff --git a/Transceiver52M/radioInterface.cpp b/Transceiver52M/radioInterface.cpp index 7a84430..d44f39d 100644 --- a/Transceiver52M/radioInterface.cpp +++ b/Transceiver52M/radioInterface.cpp @@ -31,11 +31,10 @@ #define NUMCHUNKS 4 RadioInterface::RadioInterface(RadioDevice *wRadio, size_t tx_sps, - size_t rx_sps, size_t chans, size_t diversity, + size_t rx_sps, size_t chans, int wReceiveOffset, GSM::Time wStartTime) : mRadio(wRadio), mSPSTx(tx_sps), mSPSRx(rx_sps), mChans(chans), - mMIMO(diversity), underrun(false), overrun(false), - receiveOffset(wReceiveOffset), mOn(false) + underrun(false), overrun(false), receiveOffset(wReceiveOffset), mOn(false) { mClock.set(wStartTime); } diff --git a/Transceiver52M/radioInterface.h b/Transceiver52M/radioInterface.h index f77cf9e..97f1e70 100644 --- a/Transceiver52M/radioInterface.h +++ b/Transceiver52M/radioInterface.h @@ -86,8 +86,8 @@ /** constructor */ RadioInterface(RadioDevice* wRadio, size_t tx_sps, size_t rx_sps, - size_t chans = 1, size_t diversity = 1, - int receiveOffset = 3, GSM::Time wStartTime = GSM::Time(0)); + size_t chans = 1, int receiveOffset = 3, + GSM::Time wStartTime = GSM::Time(0)); /** destructor */ virtual ~RadioInterface(); @@ -191,26 +191,4 @@ bool tuneTx(double freq, size_t chan); bool tuneRx(double freq, size_t chan); double setRxGain(double dB, size_t chan); -}; - -class RadioInterfaceDiversity : public RadioInterface { -public: - RadioInterfaceDiversity(RadioDevice* wRadio, size_t tx_sps, size_t chans); - - ~RadioInterfaceDiversity(); - - bool init(int type); - void close(); - bool tuneRx(double freq, size_t chan); - -private: - Resampler *dnsampler; - std::vector<float> phases; - signalVector *outerRecvBuffer; - - bool mDiversity; - double mFreqSpacing; - - bool setupDiversityChannels(); - void pullBuffer(); }; diff --git a/Transceiver52M/radioInterfaceDiversity.cpp b/Transceiver52M/radioInterfaceDiversity.cpp deleted file mode 100644 index c78310c..0000000 --- a/Transceiver52M/radioInterfaceDiversity.cpp +++ /dev/null @@ -1,243 +0,0 @@ -/* - * SSE Convolution - * Copyright (C) 2013 Thomas Tsou <t...@tsou.cc> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <radioInterface.h> -#include <Logger.h> - -#include "Resampler.h" - -extern "C" { -#include "convert.h" -} - -/* Resampling parameters for 64 MHz clocking */ -#define RESAMP_64M_INRATE 20 -#define RESAMP_64M_OUTRATE 80 - -/* Downlink block size */ -#define CHUNK 625 - -/* Universal resampling parameters */ -#define NUMCHUNKS 48 - -/* - * Resampling filter bandwidth scaling factor - * This narrows the filter cutoff relative to the output bandwidth - * of the polyphase resampler. At 4 samples-per-symbol using the - * 2 pulse Laurent GMSK approximation gives us below 0.5 degrees - * RMS phase error at the resampler output. - */ -#define RESAMP_TX4_FILTER 0.45 - -static size_t resamp_inrate = 0; -static size_t resamp_inchunk = 0; -static size_t resamp_outrate = 0; -static size_t resamp_outchunk = 0; - -RadioInterfaceDiversity::RadioInterfaceDiversity(RadioDevice *wRadio, - size_t tx_sps, size_t chans) - : RadioInterface(wRadio, tx_sps, 1, chans, 2), outerRecvBuffer(NULL), - mDiversity(false), mFreqSpacing(0.0) -{ -} - -RadioInterfaceDiversity::~RadioInterfaceDiversity() -{ - close(); -} - -void RadioInterfaceDiversity::close() -{ - delete outerRecvBuffer; - delete dnsampler; - - dnsampler = NULL; - outerRecvBuffer = NULL; - - if (recvBuffer.size()) - recvBuffer[0] = NULL; - - RadioInterface::close(); -} - -bool RadioInterfaceDiversity::setupDiversityChannels() -{ - size_t inner_rx_len; - - /* Inner and outer rates */ - resamp_inrate = RESAMP_64M_INRATE; - resamp_outrate = RESAMP_64M_OUTRATE; - resamp_inchunk = resamp_inrate * 4; - resamp_outchunk = resamp_outrate * 4; - - /* Buffer lengths */ - inner_rx_len = NUMCHUNKS * resamp_inchunk; - - /* Inside buffer must hold at least 2 bursts */ - if (inner_rx_len < 157 * mSPSRx * 2) { - LOG(ALERT) << "Invalid inner buffer size " << inner_rx_len; - return false; - } - - dnsampler = new Resampler(resamp_inrate, resamp_outrate); - if (!dnsampler->init()) { - LOG(ALERT) << "Rx resampler failed to initialize"; - return false; - } - - /* One Receive buffer and downsampler per diversity channel */ - for (size_t i = 0; i < mMIMO * mChans; i++) { - recvBuffer[i] = new RadioBuffer(NUMCHUNKS, - resamp_inchunk, 0, false); - } - - return true; -} - -/* Initialize I/O specific objects */ -bool RadioInterfaceDiversity::init(int type) -{ - int outer_rx_len; - - if ((mMIMO != 2) || (mChans != 2)) { - LOG(ALERT) << "Unsupported channel configuration " << mChans; - return false; - } - - /* Resize for channel combination */ - sendBuffer.resize(mChans); - recvBuffer.resize(mChans * mMIMO); - convertSendBuffer.resize(mChans); - convertRecvBuffer.resize(mChans); - mReceiveFIFO.resize(mChans); - phases.resize(mChans); - - if (!setupDiversityChannels()) - return false; - - outer_rx_len = resamp_outchunk; - - for (size_t i = 0; i < mChans; i++) { - /* Full rate float and integer outer receive buffers */ - convertRecvBuffer[i] = new short[outer_rx_len * 2]; - - /* Send buffers (not-resampled) */ - sendBuffer[i] = new RadioBuffer(NUMCHUNKS, CHUNK * mSPSTx, 0, true); - convertSendBuffer[i] = new short[CHUNK * mSPSTx * 2]; - } - - outerRecvBuffer = new signalVector(outer_rx_len, dnsampler->len()); - - return true; -} - -bool RadioInterfaceDiversity::tuneRx(double freq, size_t chan) -{ - double f0, f1; - - if (chan > 1) - return false; - - if (!mRadio->setRxFreq(freq, chan)) - return false; - - f0 = mRadio->getRxFreq(0); - f1 = mRadio->getRxFreq(1); - - mFreqSpacing = f1 - f0; - - if (abs(mFreqSpacing) <= 600e3) - mDiversity = true; - else - mDiversity = false; - - return true; -} - -/* Receive a timestamped chunk from the device */ -void RadioInterfaceDiversity::pullBuffer() -{ - bool local_underrun; - int rc, num, path0, path1; - signalVector *shift, *base; - float *in, *out, rate = -mFreqSpacing * 2.0 * M_PI / 1.08333333e6; - - if (recvBuffer[0]->getFreeSegments() <= 0) - return; - - /* Outer buffer access size is fixed */ - num = mRadio->readSamples(convertRecvBuffer, - resamp_outchunk, - &overrun, - readTimestamp, - &local_underrun); - if ((size_t) num != resamp_outchunk) { - LOG(ALERT) << "Receive error " << num; - return; - } - - for (size_t i = 0; i < mChans; i++) { - convert_short_float((float *) outerRecvBuffer->begin(), - convertRecvBuffer[i], 2 * resamp_outchunk); - - if (!i) { - path0 = 0; - path1 = 2; - } else { - path0 = 3; - path1 = 1; - } - - /* Diversity path 1 */ - base = outerRecvBuffer; - in = (float *) base->begin(); - out = (float *) recvBuffer[path0]->getWriteSegment(); - - rc = dnsampler->rotate(in, resamp_outchunk, - out, resamp_inchunk); - if (rc < 0) { - LOG(ALERT) << "Sample rate downsampling error"; - } - - /* Enable path 2 if Nyquist bandwidth is sufficient */ - if (!mDiversity) - continue; - - /* Diversity path 2 */ - shift = new signalVector(base->size(), base->getStart()); - in = (float *) shift->begin(); - out = (float *) recvBuffer[path1]->getWriteSegment(); - - rate = i ? -rate : rate; - if (!frequencyShift(shift, base, rate, phases[i], &phases[i])) { - LOG(ALERT) << "Frequency shift failed"; - } - - rc = dnsampler->rotate(in, resamp_outchunk, - out, resamp_inchunk); - if (rc < 0) { - LOG(ALERT) << "Sample rate downsampling error"; - } - - delete shift; - } - - underrun |= local_underrun; - readTimestamp += (TIMESTAMP) resamp_outchunk; -} diff --git a/Transceiver52M/sigProcLib.cpp b/Transceiver52M/sigProcLib.cpp index 4c2222c..ce062a4 100644 --- a/Transceiver52M/sigProcLib.cpp +++ b/Transceiver52M/sigProcLib.cpp @@ -654,51 +654,6 @@ return pulse; } -signalVector* frequencyShift(signalVector *y, - signalVector *x, - float freq, - float startPhase, - float *finalPhase) -{ - - if (!x) return NULL; - - if (y==NULL) { - y = new signalVector(x->size()); - y->isReal(x->isReal()); - if (y==NULL) return NULL; - } - - if (y->size() < x->size()) return NULL; - - float phase = startPhase; - signalVector::iterator yP = y->begin(); - signalVector::iterator xPEnd = x->end(); - signalVector::iterator xP = x->begin(); - - if (x->isReal()) { - while (xP < xPEnd) { - (*yP++) = expjLookup(phase)*( (xP++)->real() ); - phase += freq; - } - } - else { - while (xP < xPEnd) { - (*yP++) = (*xP++)*expjLookup(phase); - phase += freq; - if (phase > 2 * M_PI) - phase -= 2 * M_PI; - else if (phase < -2 * M_PI) - phase += 2 * M_PI; - } - } - - - if (finalPhase) *finalPhase = phase; - - return y; -} - signalVector* reverseConjugate(signalVector *b) { signalVector *tmp = new signalVector(b->size()); -- To view, visit https://gerrit.osmocom.org/2186 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I46752ccf5dbcffbec806081dec03e69a0fbdcdb7 Gerrit-PatchSet: 2 Gerrit-Project: osmo-trx Gerrit-Branch: master Gerrit-Owner: Tom Tsou <t...@tsou.cc> Gerrit-Reviewer: Jenkins Builder