changeset 84:1cda9bc89011

l1_ctl.c: l1ctl_afc() reconstructed
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Sat, 02 Apr 2016 07:56:24 +0000
parents 43dd68d8d891
children eca8d5f642fd
files chipsetsw/layer1/cfile/l1_ctl.c
diffstat 1 files changed, 65 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/chipsetsw/layer1/cfile/l1_ctl.c	Wed Mar 30 06:28:32 2016 +0000
+++ b/chipsetsw/layer1/cfile/l1_ctl.c	Sat Apr 02 07:56:24 2016 +0000
@@ -339,7 +339,9 @@
     static UWORD32 M_Count;
     static WORD32  psi_avg[C_PSI_AVG_SIZE_D+1]; // Data history array
     static WORD16  B_Count;                     // Counter for consecutive SNR below C_thr_snr
-    UWORD16 L = 10433;                          // Gain algo2
+    #if 0	/* LoCosto added var */
+      UWORD16 L = 10433;                          // Gain algo2
+    #endif
     static UWORD16 first_avg;
     static UWORD16 good_snr;
 
@@ -353,13 +355,13 @@
     UWORD8 physical_band_id;
 #endif
 
-
+#if 0	/* LoCosto added var init */
 //Set AFC close loop gain for ALGO_AFC_LQG_PREDICTOR.
 if(l1_mode==I_MODE)//MS is in Idle mode
 L = 41732; //F0.20 L=41732/2^20 = 0.04
 else //All other modes than Idle
 L = 10433; //F0.20 L=10433/2^20 = 0.01
-
+#endif
 
 #if (L1_FF_MULTIBAND == 0)
 
@@ -620,10 +622,12 @@
             case AFC_INIT_MIN     :
             quant_avg = 0;
             M_Count = 0;
-                for (i = 0; i <= C_PSI_AVG_SIZE_D ; i++)  //omaps00090550
-                    psi_avg[i] = 0;
-                first_avg = 1;
-                good_snr = 0;
+#if 0	/* present in LoCosto but not in TCS211 */
+            for (i = 0; i <= C_PSI_AVG_SIZE_D ; i++)  //omaps00090550
+                psi_avg[i] = 0;
+#endif
+            first_avg = 1;
+            good_snr = 0;
 
             // DAC search algorithm is as follows - up to 12 attempts are made
             // DAC search algorithm uses three values : DAC_center -> DAC_max -> DAC_min ->
@@ -694,11 +698,21 @@
                     ((WORD32) (((WORD32)(var_32 + (1<<18))) / (1<<19)));
                 var_16 = var_16 * 8;
 #endif
+
+              #if 0	/* LoCosto code with saturation */
                 if (var_16 > C_max_step)
                     psi_quant = Add_Sat_sign_16b(psi_quant,C_max_step);
                 else if (var_16 < C_min_step)
                     psi_quant = Add_Sat_sign_16b(psi_quant,C_min_step);
                 else psi_quant = Add_Sat_sign_16b(psi_quant,var_16); /* F13.3 */
+              #else	/* matching TCS211 */
+                if (var_16 > C_max_step)
+                    psi_quant += C_max_step;
+                else if (var_16 < C_min_step)
+                    psi_quant += C_min_step;
+                else psi_quant += var_16; /* F13.3 */
+              #endif
+
                 /* F0.32 * F13.3 = F5.35    */
                 psi_past[C_N_del]=Mult_40b(l1_config.params.psi_st_32,psi_quant, &guardout);
                 /*  (F13.3<<16 )+(F5.35>>16) = F13.19 */
@@ -788,11 +802,18 @@
                     /* Phi = angle - Phi_32*/
                     Phi_32 = ((WORD32) angle << 4) - Phi_32;
                     /* F1.15 * 4 = F13.19 */
-		    Phi = (WORD16)((WORD32)((WORD32)(Phi_32 + (1<<3)))/ (1<<4)); /* F17.15 */
+                    #if 0	/* LoCosto code */
+                      Phi = (WORD16)((WORD32)((WORD32)(Phi_32 + (1<<3)))/ (1<<4)); /* F17.15 */
+                    #else	/* TCS211 reconstruction */
+                      Phi = Phi_32 >> 4;
+                    #endif
                     /* (F0.20 * F1.15) >> 16 = F13.19 */
-                    var_32 = (L * Phi + (1<<15)) >> 16;
-                    psi_past[C_N_del] = Add_Sat_sign_32b(psi_past[C_N_del],var_32);
-
+                    #if 0	/* LoCosto code with saturation and L */
+                      var_32 = (L * Phi + (1<<15)) >> 16;
+                      psi_past[C_N_del] = Add_Sat_sign_32b(psi_past[C_N_del],var_32);
+                    #else	/* matching TCS211 */
+                      psi_past[C_N_del] += (10433 * Phi) >> 16;
+                    #endif
 
                 }
                 else
@@ -826,9 +847,14 @@
                             // Predict with 1st order estimation
                             if (l1_config.params.rgap_algo >= 1)
                             {
+                            #if 0	/* LoCosto code with saturation */
                                  psi_past[C_N_del] = Add_Sat_sign_32b(psi_past[C_N_del],
                                      ((quant_avg * (l1_config.params.rgap_bad_snr_count_B))/(C_MSIZE))
                                      );
+                            #else	/* matching TCS211 */
+                                 psi_past[C_N_del] +=
+                                     ((quant_avg * (l1_config.params.rgap_bad_snr_count_B))/(C_MSIZE));
+                            #endif
                             }
 
                             B_Count= B_Count - l1_config.params.rgap_bad_snr_count_B;
@@ -848,7 +874,11 @@
                 /* Quantize psi value */
 
                 /* F0.19 * 16.0 = F16.19 */
-                var_32 = Sat_Mult_20sign_16unsign(psi_past[C_N_del],l1_config.params.psi_st_inv);
+                #if 0	/* LoCosto code */
+                  var_32 = Sat_Mult_20sign_16unsign(psi_past[C_N_del],l1_config.params.psi_st_inv);
+                #else	/* TCS211 reconstruction */
+		  var_32 = psi_past[C_N_del] * l1_config.params.psi_st_inv;
+                #endif
 
 #if(RF_FAM == 61)
                 /* In order to implement the NINT function for a F13.3,*/
@@ -889,10 +919,12 @@
 
         quant_avg = 0;
         M_Count = 0;
-            for (i = 0; i <=C_PSI_AVG_SIZE_D ; i++)   //omaps00090550
-                psi_avg[i] = 0;
-            first_avg = 1;
-            good_snr = 0;
+#if 0	/* present in LoCosto but not in TCS211 */
+        for (i = 0; i <=C_PSI_AVG_SIZE_D ; i++)   //omaps00090550
+            psi_avg[i] = 0;
+#endif
+        first_avg = 1;
+        good_snr = 0;
 
         // DAC search algorithm is as follows - up to 12 attempts are made
         // DAC search algorithm uses three values : DAC_center -> DAC_max -> DAC_min ->
@@ -967,14 +999,20 @@
           quotient=(WORD16)((WORD32)(((WORD32)(var_32+(1<<18)))/(1<<19)));
           var_16=quotient*8;
 #endif
+
+#if 0	/* LoCosto code with saturation */
           if (var_16>C_max_step)
             Psi_quant[C_N_del]=Add_Sat_sign_16b(Psi_quant[C_N_del],C_max_step);
-           else
-           if(var_16<C_min_step)
-             Psi_quant[C_N_del]=Add_Sat_sign_16b(Psi_quant[C_N_del],C_min_step);
-           else Psi_quant[C_N_del]=Add_Sat_sign_16b(Psi_quant[C_N_del],var_16);     /* F13.3                  */
-
-
+          else if (var_16<C_min_step)
+            Psi_quant[C_N_del]=Add_Sat_sign_16b(Psi_quant[C_N_del],C_min_step);
+          else Psi_quant[C_N_del]=Add_Sat_sign_16b(Psi_quant[C_N_del],var_16);     /* F13.3                  */
+#else	/* matching TCS211 */
+          if (var_16>C_max_step)
+            Psi_quant[C_N_del] += C_max_step;
+          else if (var_16<C_min_step)
+            Psi_quant[C_N_del] += C_min_step;
+          else Psi_quant[C_N_del] += var_16;     /* F13.3                  */
+#endif
 
                  /* F0.32 * F13.3 = F5.35    */
          Psi=Mult_40b(l1_config.params.psi_st_32,Psi_quant[C_N_del], &guardout);
@@ -1093,7 +1131,11 @@
            var1=(WORD32)var1<<8;
            /* var2 is an unsigned variable, var1 contains signed guard*/
            /* bits.                                                   */
-           var2=  ((WORD32)(denom)/(num));  //omaps00090550
+           #if 0	/* fixed LoCosto code */
+             var2=  ((WORD32)(denom)/(num));  //omaps00090550
+           #else	/* matching TCS211 */
+             var2=  denom / num;
+           #endif
            K = (var1+var2)<<1;             /* F1.39 / F12.20 = F13.19 */
                                            /* F13.19 << 1 = F12.20    */