multi-arfcn, trx: fix infinite energy threshold bug

This fixes a bug where the energy threshold may reach infinity.

The transceiver energy detection threshold increase is
dependent on elapsed frames and the previous false detection
time. If we assume a (0,0) start time with the actual start
time - randomly determined - it's possible to get very
large elapsed frame counts at start. Once the threshold hits
'inf' further calculations are impossible and transceiver
is locked out from use.

Use the actual start time for initializing variables so
we avoid this scenario.

Signed-off-by: Thomas Tsou <ttsou@vt.edu>
multi-arfcn, sigproc: remove complex conjugation on filter reversal

Do not conjugate the filter taps when storing in reverse. The
current taps are real value only, so there is no effect with this
change; it is only for correctness purposes.

We store the taps in reverse to avoid reversing the input sequence
of the convolution.

Signed-off-by: Thomas Tsou <ttsou@vt.edu>
multi-arfcn, sigproc: remove unused and untested calls

Index shift for convolution purposes is not needed for channelizing
and/or resampling support. When convolution is revisited for
delay and interpolation purposes, a different approach will be
used.

Signed-off-by: Thomas Tsou <ttsou@vt.edu>
multi-arfcn, trx: attach FIFO's internally in transceiver

The original split-transceiver abstraction did not maintain
internal instances of the radio interface or drive loop.
The FIFO's were attached through external calls. The control
loop, however, made such an approach overly difficult, so
the transceiver now maintains pointers to the aforementioned
objects. In doing so, we no longer need external attachment
calls to setup the FIFO's.

Signed-off-by: Thomas Tsou <ttsou@vt.edu>
transceiver, uhd: dynamically allocate async event thread

Similar to the previous commit titled,

"multi-arfcn, trx: allocate threads on heap and fix thread release"

there is the potential for a segfault on exit if the event thread
is never started. As before, address the issue by initializing
the Thread pointer with NULL and later allocating the object
immediately prior to use.

On stop or exit, allow the thread to exit by checking a condition
variable. If device is stopped or never started, the same variable
can be checked for state, which avoids attempts to deallocate an
empty pointer.

If there is a better method to shutdown / deallocate using the
OpenBTS thread library, please let me know.

Signed-off-by: Thomas Tsou <ttsou@vt.edu>
multi-arfcn, trx: create transceivers based on command line arg

Move from the hard coded case of 3 transceiver instances to a
command line determined value. 'M' potential channels will be
compiled into the build depending on preprocessor selections
in radioParams.h. The command line argument must be less M.

Channels are selected starting from 0, which is centered on the
RF tuning frequency. Subsequent channels are selected by shifting
outward from 0 (center) in a left before right pattern. Default
channel spacing is 400 kHz. The ordering for supported cases of
1, 5, and 10 path channelizers is as follows.

CHAN_M = 1

    { 0 }

CHAN_M = 5

    { 0, 1, 4, 2, 3 }

CHAN_M = 10

    { 0, 1, 9, 2, 8, 3, 7, 4, 6, 5}

Note: Channel 5 for the 10 channel case sits on the Nyquist
frequency and is therefor unusable.

Signed-off-by: Thomas Tsou <ttsou@vt.edu>
multi-arfcn, core: use transceiver command line option in main

OpenBTS main() still needs manual configuration for multi-channel
use, although the transceiver can now be configured through the
command line.

Signed-off-by: Thomas Tsou <ttsou@vt.edu>
multi-arfcn, uhd: make tx amplitude dependent on number of ARFCN's

The default amplitude setting will cause the signal to splatter
when the number of ARFCN's used is high. This occurs because the
amplitude is set for a single channel only and does not account
for the composite signal at the output of the synthesis filter.

The previous default value - 30% of full dynamic range - was
likely too low given that constant GMSK is used. Increase the
single channel value to 50%. In the multi-ARFCN case, divide
this amplitude setting by the number ARFCN being used.

Signed-off-by: Thomas Tsou <ttsou@vt.edu>
uhd: fix local overflow handling of buffer reads

This patches fixes the hypothetical bug in the read out of the
intermediate sample buffer after a local overflow condition.

Local overflows - occurring in the intermediate storage buffer
and not the UHD transport - should never occur; the existence
of a local overflow indicates a significant error elsewhere in
the system. For example, if timestamps or timing offsets are
ridiculously off, such errors may occur.

Nonetheless, handle errors anyways by taking the modulo value
of the calculated read index to stay within the buffer and avoid
segmentation faulting.