sigproc: Remove normal burst DFE equalizer

DFE equalizer is unused and has been experiencing code rot for
multiple years. The effect is a significant amount of baggage being
carried in the Transceiver and interfaces.

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
diff --git a/Transceiver52M/Transceiver.cpp b/Transceiver52M/Transceiver.cpp
index df41eac..48f4a19 100644
--- a/Transceiver52M/Transceiver.cpp
+++ b/Transceiver52M/Transceiver.cpp
@@ -555,89 +555,36 @@
   }
 }
 
-/* 
- * Detect RACH synchronization sequence within a burst. No equalization
- * is used or available on the RACH channel.
- */
-int Transceiver::detectRACH(TransceiverState *state,
-                            signalVector &burst,
-                            complex &amp, float &toa)
+int Transceiver::detectBurst(TransceiverState *state, signalVector &burst,
+                            complex &amp, float &toa, CorrType type)
 {
-  float threshold = 6.0;
+  float threshold = 5.0, rc = 0;
 
-  return detectRACHBurst(burst, threshold, mSPSRx, amp, toa);
+  switch (type) {
+  case TSC:
+    rc = analyzeTrafficBurst(burst, mTSC, threshold, mSPSRx,
+                             amp, toa, mMaxExpectedDelay);
+    break;
+  case RACH:
+    threshold = 6.0;
+    rc = detectRACHBurst(burst, threshold, mSPSRx, amp, toa);
+    break;
+  default:
+    LOG(ERR) << "Invalid correlation type";
+  }
+
+
+  return rc;
 }
 
-/*
- * Detect normal burst training sequence midamble. Update equalization
- * state information and channel estimate if necessary. Equalization
- * is currently disabled.
- */
-int Transceiver::detectTSC(TransceiverState *state, signalVector &burst,
-                           complex &amp, float &toa, GSM::Time &time)
-{
-  int success;
-  int tn = time.TN();
-  float chanOffset, threshold = 5.0;
-  bool needDFE = false, estimateChan = false;
-  double elapsed = time - state->chanEstimateTime[tn];
-  signalVector *chanResp;
-
-  /* Check equalization update state */
-  if (needDFE && ((elapsed > 50) || (!state->chanResponse[tn]))) {
-    delete state->DFEForward[tn];
-    delete state->DFEFeedback[tn];
-    state->DFEForward[tn] = NULL;
-    state->DFEFeedback[tn] = NULL;
-
-    estimateChan = true;
-  }
-
-  /* Detect normal burst midambles */
-  success = analyzeTrafficBurst(burst, mTSC, threshold, mSPSRx, amp,
-                                toa, mMaxExpectedDelay, estimateChan,
-                                &chanResp, &chanOffset);
-  if (success <= 0) {
-    return success;
-  }
-
-  /* Set equalizer if unabled */
-  if (needDFE && estimateChan) {
-     float noise = state->mNoiseLev;
-     state->SNRestimate[tn] = amp.norm2() / (noise * noise + 1.0);
-
-     state->chanResponse[tn] = chanResp;
-     state->chanRespOffset[tn] = chanOffset;
-     state->chanRespAmplitude[tn] = amp;
-
-     scaleVector(*chanResp, complex(1.0, 0.0) / amp);
-
-     designDFE(*chanResp, state->SNRestimate[tn],
-               7, &state->DFEForward[tn], &state->DFEFeedback[tn]);
-
-     state->chanEstimateTime[tn] = time;
-  }
-
-  return 1;
-}
 
 /*
- * Demodulate GMSK burst using equalization if requested. Otherwise
- * demodulate by direct rotation and soft slicing.
+ * Demodulate GMSK by direct rotation and soft slicing.
  */
 SoftVector *Transceiver::demodulate(TransceiverState *state,
                                     signalVector &burst, complex amp,
-                                    float toa, size_t tn, bool equalize)
+                                    float toa)
 {
-  if (equalize) {
-    scaleVector(burst, complex(1.0, 0.0) / amp);
-    return equalizeBurst(burst,
-                         toa - state->chanRespOffset[tn],
-                         mSPSRx,
-                         *state->DFEForward[tn],
-                         *state->DFEFeedback[tn]);
-  }
-
   return demodulateBurst(burst, mSPSRx, amp, toa);
 }
 
@@ -660,7 +607,6 @@
                                          size_t chan)
 {
   int success;
-  bool equalize = false;
   complex amp;
   float toa, pow, max = -1.0, avg = 0.0;
   int max_i = -1;
@@ -731,10 +677,7 @@
   }
 
   /* Detect normal or RACH bursts */
-  if (type == TSC)
-    success = detectTSC(state, *burst, amp, toa, time);
-  else
-    success = detectRACH(state, *burst, amp, toa);
+  success = detectBurst(state, *burst, amp, toa, type);
 
   /* Alert an error and exit */
   if (success <= 0) {
@@ -750,11 +693,7 @@
 
   timingOffset = toa / mSPSRx;
 
-  /* Demodulate and set output info */
-  if (equalize && (type != TSC))
-    equalize = false;
-
-  bits = demodulate(state, *burst, amp, toa, time.TN(), equalize);
+  bits = demodulate(state, *burst, amp, toa);
 
   delete radio_burst;
   return bits;
diff --git a/Transceiver52M/Transceiver.h b/Transceiver52M/Transceiver.h
index bd8ec4f..0337aab 100644
--- a/Transceiver52M/Transceiver.h
+++ b/Transceiver52M/Transceiver.h
@@ -208,20 +208,13 @@
   /** send messages over the clock socket */
   void writeClockInterface(void);
 
-  /** Detect RACH bursts */
-  int detectRACH(TransceiverState *state,
-                 signalVector &burst,
-                 complex &amp, float &toa);
+  /** Detectbursts */
+  int detectBurst(TransceiverState *state, signalVector &burst,
+                  complex &amp, float &toa, CorrType type);
 
-  /** Detect normal bursts */
-  int detectTSC(TransceiverState *state,
-                signalVector &burst,
-                complex &amp, float &toa, GSM::Time &time);
-
-  /** Demodulat burst and output soft bits */
-  SoftVector *demodulate(TransceiverState *state,
-                         signalVector &burst, complex amp,
-                         float toa, size_t tn, bool equalize);
+  /** Demodulate burst and output soft bits */
+  SoftVector *demodulate(TransceiverState *state, signalVector &burst,
+                         complex amp, float toa);
 
   int mSPSTx;                          ///< number of samples per Tx symbol
   int mSPSRx;                          ///< number of samples per Rx symbol
diff --git a/Transceiver52M/sigProcLib.cpp b/Transceiver52M/sigProcLib.cpp
index de8b1cf..8786c4a 100644
--- a/Transceiver52M/sigProcLib.cpp
+++ b/Transceiver52M/sigProcLib.cpp
@@ -1485,8 +1485,7 @@
  *   tail: Search 4 symbols + maximum expected delay
  */
 int analyzeTrafficBurst(signalVector &rxBurst, unsigned tsc, float thresh,
-                        int sps, complex &amp, float &toa, unsigned max_toa,
-                        bool chan_req, signalVector **chan, float *chan_offset)
+                        int sps, complex &amp, float &toa, unsigned max_toa)
 {
   int rc, target, head, tail;
   CorrelationSequence *sync;
@@ -1501,15 +1500,6 @@
 
   rc = detectGeneralBurst(rxBurst, thresh, sps, amp, toa,
                           target, head, tail, sync);
-
-  /* Equalization not currently supported */
-  if (rc > 0 && chan_req) {
-    *chan = new signalVector(6 * sps);
-
-    if (chan_offset)
-      *chan_offset = 0.0;
-  }
-
   return rc;
 }
 
@@ -1566,166 +1556,6 @@
   return bits;
 }
 
-// Assumes symbol-spaced sampling!!!
-// Based upon paper by Al-Dhahir and Cioffi
-bool designDFE(signalVector &channelResponse,
-	       float SNRestimate,
-	       int Nf,
-	       signalVector **feedForwardFilter,
-	       signalVector **feedbackFilter)
-{
-  
-  signalVector G0(Nf);
-  signalVector G1(Nf);
-  signalVector::iterator G0ptr = G0.begin();
-  signalVector::iterator G1ptr = G1.begin();
-  signalVector::iterator chanPtr = channelResponse.begin();
-
-  int nu = channelResponse.size()-1;
-
-  *G0ptr = 1.0/sqrtf(SNRestimate);
-  for(int j = 0; j <= nu; j++) {
-    *G1ptr = chanPtr->conj();
-    G1ptr++; chanPtr++;
-  }
-
-  signalVector *L[Nf];
-  signalVector::iterator Lptr;
-  float d = 1.0;
-  for(int i = 0; i < Nf; i++) {
-    d = G0.begin()->norm2() + G1.begin()->norm2();
-    L[i] = new signalVector(Nf+nu);
-    Lptr = L[i]->begin()+i;
-    G0ptr = G0.begin(); G1ptr = G1.begin();
-    while ((G0ptr < G0.end()) &&  (Lptr < L[i]->end())) {
-      *Lptr = (*G0ptr*(G0.begin()->conj()) + *G1ptr*(G1.begin()->conj()) )/d;
-      Lptr++;
-      G0ptr++;
-      G1ptr++;
-    }
-    complex k = (*G1.begin())/(*G0.begin());
-
-    if (i != Nf-1) {
-      signalVector G0new = G1;
-      scaleVector(G0new,k.conj());
-      addVector(G0new,G0);
-
-      signalVector G1new = G0;
-      scaleVector(G1new,k*(-1.0));
-      addVector(G1new,G1);
-      delayVector(&G1new, &G1new, -1.0);
-
-      scaleVector(G0new,1.0/sqrtf(1.0+k.norm2()));
-      scaleVector(G1new,1.0/sqrtf(1.0+k.norm2()));
-      G0 = G0new;
-      G1 = G1new;
-    }
-  }
-
-  *feedbackFilter = new signalVector(nu);
-  L[Nf-1]->segmentCopyTo(**feedbackFilter,Nf,nu);
-  scaleVector(**feedbackFilter,(complex) -1.0);
-  conjugateVector(**feedbackFilter);
-
-  signalVector v(Nf);
-  signalVector::iterator vStart = v.begin();
-  signalVector::iterator vPtr;
-  *(vStart+Nf-1) = (complex) 1.0;
-  for(int k = Nf-2; k >= 0; k--) {
-    Lptr = L[k]->begin()+k+1;
-    vPtr = vStart + k+1;
-    complex v_k = 0.0;
-    for (int j = k+1; j < Nf; j++) {
-      v_k -= (*vPtr)*(*Lptr);
-      vPtr++; Lptr++;
-    }
-     *(vStart + k) = v_k;
-  }
-
-  *feedForwardFilter = new signalVector(Nf);
-  signalVector::iterator w = (*feedForwardFilter)->end();
-  for (int i = 0; i < Nf; i++) {
-    delete L[i];
-    complex w_i = 0.0;
-    int endPt = ( nu < (Nf-1-i) ) ? nu : (Nf-1-i);
-    vPtr = vStart+i;
-    chanPtr = channelResponse.begin();
-    for (int k = 0; k < endPt+1; k++) {
-      w_i += (*vPtr)*(chanPtr->conj());
-      vPtr++; chanPtr++;
-    }
-    *--w = w_i/d;
-  }
-
-
-  return true;
-  
-}
-
-// Assumes symbol-rate sampling!!!!
-SoftVector *equalizeBurst(signalVector &rxBurst,
-		       float TOA,
-		       int sps,
-		       signalVector &w, // feedforward filter
-		       signalVector &b) // feedback filter
-{
-  signalVector *postForwardFull;
-
-  if (!delayVector(&rxBurst, &rxBurst, -TOA))
-    return NULL;
-
-  postForwardFull = convolve(&rxBurst, &w, NULL,
-                             CUSTOM, 0, rxBurst.size() + w.size() - 1);
-  if (!postForwardFull)
-    return NULL;
-
-  signalVector* postForward = new signalVector(rxBurst.size());
-  postForwardFull->segmentCopyTo(*postForward,w.size()-1,rxBurst.size());
-  delete postForwardFull;
-
-  signalVector::iterator dPtr = postForward->begin();
-  signalVector::iterator dBackPtr;
-  signalVector::iterator rotPtr = GMSKRotation4->begin();
-  signalVector::iterator revRotPtr = GMSKReverseRotation4->begin();
-
-  signalVector *DFEoutput = new signalVector(postForward->size());
-  signalVector::iterator DFEItr = DFEoutput->begin();
-
-  // NOTE: can insert the midamble and/or use midamble to estimate BER
-  for (; dPtr < postForward->end(); dPtr++) {
-    dBackPtr = dPtr-1;
-    signalVector::iterator bPtr = b.begin();
-    while ( (bPtr < b.end()) && (dBackPtr >= postForward->begin()) ) {
-      *dPtr = *dPtr + (*bPtr)*(*dBackPtr);
-      bPtr++;
-      dBackPtr--;
-    }
-    *dPtr = *dPtr * (*revRotPtr);
-    *DFEItr = *dPtr;
-    // make decision on symbol
-    *dPtr = (dPtr->real() > 0.0) ? 1.0 : -1.0;
-    //*DFEItr = *dPtr;
-    *dPtr = *dPtr * (*rotPtr);
-    DFEItr++;
-    rotPtr++;
-    revRotPtr++;
-  }
-
-  vectorSlicer(DFEoutput);
-
-  SoftVector *burstBits = new SoftVector(postForward->size());
-  SoftVector::iterator burstItr = burstBits->begin();
-  DFEItr = DFEoutput->begin();
-  for (; DFEItr < DFEoutput->end(); DFEItr++) 
-    *burstItr++ = DFEItr->real();
-
-  delete postForward;
-
-  delete DFEoutput;
-
-  return burstBits;
-}
-
 bool sigProcLibSetup()
 {
   initTrigTables();
diff --git a/Transceiver52M/sigProcLib.h b/Transceiver52M/sigProcLib.h
index c6dd172..8ff8246 100644
--- a/Transceiver52M/sigProcLib.h
+++ b/Transceiver52M/sigProcLib.h
@@ -199,10 +199,7 @@
                         int sps,
                         complex &amplitude,
                         float &TOA,
-                        unsigned maxTOA,
-                        bool requestChannel = false,
-                        signalVector** channelResponse = NULL,
-                        float *channelResponseOffset = NULL);
+                        unsigned maxTOA);
 
 /**
 	Decimate a vector.
@@ -223,35 +220,4 @@
 */
 SoftVector *demodulateBurst(signalVector &rxBurst, int sps,
                             complex channel, float TOA);
-
-/**
-	Design the necessary filters for a decision-feedback equalizer.
-	@param channelResponse The multipath channel that we're mitigating.
-	@param SNRestimate The signal-to-noise estimate of the channel, a linear value
-	@param Nf The number of taps in the feedforward filter.
-	@param feedForwardFilter The designed feed forward filter.
-	@param feedbackFilter The designed feedback filter.
-	@return True if DFE can be designed.
-*/
-bool designDFE(signalVector &channelResponse,
-	       float SNRestimate,
-	       int Nf,
-	       signalVector **feedForwardFilter,
-	       signalVector **feedbackFilter);
-
-/**
-	Equalize/demodulate a received burst via a decision-feedback equalizer.
-	@param rxBurst The received burst to be demodulated.
-	@param TOA The time-of-arrival of the received burst.
-	@param sps The number of samples per GSM symbol.
-	@param w The feed forward filter of the DFE.
-	@param b The feedback filter of the DFE.
-	@return The demodulated bit sequence.
-*/
-SoftVector *equalizeBurst(signalVector &rxBurst,
-		       float TOA,
-		       int sps,
-		       signalVector &w, 
-		       signalVector &b);
-
 #endif /* SIGPROCLIB_H */