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
This commit is contained in:
Tom Tsou 2017-03-30 17:22:58 -07:00 committed by Tom Tsou
parent e51a8f029e
commit d6ae8648ff
9 changed files with 16 additions and 406 deletions

View File

@ -67,8 +67,7 @@ libtransceiver_la_SOURCES = \
$(COMMON_SOURCES) \
Resampler.cpp \
radioInterfaceResamp.cpp \
radioInterfaceMulti.cpp \
radioInterfaceDiversity.cpp
radioInterfaceMulti.cpp
bin_PROGRAMS = osmo-trx

View File

@ -138,16 +138,6 @@ static struct uhd_dev_offset uhd_offsets[] = {
};
#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
@ -156,15 +146,6 @@ static struct uhd_dev_offset special_offsets[] = {
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 @@ double uhd_device::get_dev_offset()
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 @@ int uhd_device::open(const std::string &args, int ref, bool swap_channels)
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 @@ int uhd_device::open(const std::string &args, int ref, bool swap_channels)
// 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 @@ int uhd_device::open(const std::string &args, int ref, bool swap_channels)
// Print configuration
LOG(INFO) << "\n" << usrp_dev->get_pp_string();
if (iface == DIVERSITY)
return DIVERSITY;
if (iface == MULTI_ARFCN)
return MULTI_ARFCN;

View File

@ -601,7 +601,7 @@ bool USRPDevice::setRxFreq(double wFreq) { return true;};
#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);
}

View File

@ -72,7 +72,6 @@ struct trx_config {
bool extref;
bool gpsref;
Transceiver::FillerType filler;
bool diversity;
bool mcbts;
double offset;
double rssi_offset;
@ -101,7 +100,6 @@ bool trx_setup_config(struct trx_config *config)
}
edgestr = config->edge ? "Enabled" : "Disabled";
divstr = config->diversity ? "Enabled" : "Disabled";
mcstr = config->mcbts ? "Enabled" : "Disabled";
if (config->extref)
@ -142,7 +140,6 @@ bool trx_setup_config(struct trx_config *config)
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;
@ -173,12 +170,6 @@ RadioInterface *makeRadioInterface(struct trx_config *config,
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,
config->rx_sps, config->chans);
@ -257,7 +248,6 @@ static void print_help()
" -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"
@ -289,7 +279,6 @@ static void handle_options(int argc, char **argv, struct trx_config *config)
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;
@ -319,9 +308,6 @@ static void handle_options(int argc, char **argv, struct trx_config *config)
case 'm':
config->mcbts = true;
break;
case 'd':
config->diversity = true;
break;
case 'x':
config->extref = true;
break;
@ -374,24 +360,6 @@ static void handle_options(int argc, char **argv, struct trx_config *config)
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))
config->filler = Transceiver::FILLER_EDGE_RAND;

View File

@ -41,7 +41,6 @@ class RadioDevice {
RESAMP_64M,
RESAMP_100M,
MULTI_ARFCN,
DIVERSITY,
};
enum ReferenceType {

View File

@ -31,11 +31,10 @@ extern "C" {
#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);
}
@ -47,7 +46,7 @@ RadioInterface::~RadioInterface(void)
bool RadioInterface::init(int type)
{
if ((type != RadioDevice::NORMAL) || (mMIMO > 1) || !mChans) {
if ((type != RadioDevice::NORMAL) || !mChans) {
LOG(ALERT) << "Invalid configuration";
return false;
}
@ -253,10 +252,8 @@ bool RadioInterface::driveReceiveRadio()
*/
while (recvSz > burstSize) {
for (size_t i = 0; i < mChans; i++) {
burst = new radioVector(rcvClock, burstSize, head, mMIMO);
for (size_t n = 0; n < mMIMO; n++)
unRadioifyVector(burst->getVector(n), i);
burst = new radioVector(rcvClock, burstSize, head);
unRadioifyVector(burst->getVector(), i);
if (mReceiveFIFO[i].size() < 32)
mReceiveFIFO[i].write(burst);

View File

@ -41,7 +41,6 @@ protected:
size_t mSPSTx;
size_t mSPSRx;
size_t mChans;
size_t mMIMO;
std::vector<RadioBuffer *> sendBuffer;
std::vector<RadioBuffer *> recvBuffer;
@ -86,8 +85,8 @@ public:
/** 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();
@ -192,25 +191,3 @@ public:
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();
};

View File

@ -1,243 +0,0 @@
/*
* SSE Convolution
* Copyright (C) 2013 Thomas Tsou <tom@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;
}

View File

@ -654,51 +654,6 @@ static PulseSequence *generateGSMPulse(int sps)
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());