transceiver: b100: raise minimum transmit latency value

Put a floor on the transmit latency of the B100 in order to suppress
underruns in typical conditions. Empirical data from a handful of
relatively recent machines shows that the B100 will underrun when
the transmit threshold is reduced to a time of 6 and a half frames,
so we set a minimum 7 frame threshold.

The overall benefit should be marginal and may increase the
possibility of bursts arriving stale (after the trasmit deadline),
but will reduce the number of alarming UHD related messages that
appear in the log file.

This patch is UHD and B100 specific - USRP1 is unaffected.

Signed-off-by: Thomas Tsou <ttsou@vt.edu>

git-svn-id: http://wush.net/svn/range/software/public/openbts/trunk@3980 19bc5d8c-e614-43d4-8b26-e1612bc8e597
diff --git a/Transceiver52M/Transceiver.cpp b/Transceiver52M/Transceiver.cpp
index d152b2d..caf7bf0 100644
--- a/Transceiver52M/Transceiver.cpp
+++ b/Transceiver52M/Transceiver.cpp
@@ -32,7 +32,17 @@
 #include "Transceiver.h"
 #include <Logger.h>
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 
+#define USB_LATENCY_INTRVL		(10,0)
+
+#if USE_UHD
+#  define USB_LATENCY_MIN		(6,7)
+#else
+#  define USB_LATENCY_MIN		(1,1)
+#endif
 
 Transceiver::Transceiver(int wBasePort,
 			 const char *TRXAddress,
@@ -716,8 +726,8 @@
       //   enough.  Need to increase latency by one GSM frame.
       if (mRadioInterface->getBus() == RadioDevice::USB) {
         if (mRadioInterface->isUnderrun()) {
-          // only do latency update every 10 frames, so we don't over update
-          if (radioClock->get() > mLatencyUpdateTime + GSM::Time(10,0)) {
+          // only update latency at the defined frame interval
+          if (radioClock->get() > mLatencyUpdateTime + GSM::Time(USB_LATENCY_INTRVL)) {
             mTransmitLatency = mTransmitLatency + GSM::Time(1,0);
             LOG(INFO) << "new latency: " << mTransmitLatency;
             mLatencyUpdateTime = radioClock->get();
@@ -726,7 +736,7 @@
         else {
           // if underrun hasn't occurred in the last sec (216 frames) drop
           //    transmit latency by a timeslot
-          if (mTransmitLatency > GSM::Time(1,1)) {
+          if (mTransmitLatency > GSM::Time(USB_LATENCY_MIN)) {
               if (radioClock->get() > mLatencyUpdateTime + GSM::Time(216,0)) {
               mTransmitLatency.decTN();
               LOG(INFO) << "reduced latency: " << mTransmitLatency;