From 5dccb687189a497619b9deb21f6613d09f481f78 Mon Sep 17 00:00:00 2001
From: Florian Kaltenberger <florian.kaltenberger@eurecom.fr>
Date: Fri, 7 Nov 2014 15:54:13 +0000
Subject: [PATCH] removing old calibration files and just leaving 2 for the
 rxgains for exmimo2 revision 2a and 2b. use option -F to select either one.
 default is revision 2b.

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@6002 818b1a75-f10b-46b9-bf7c-635c3b92a50f
---
 targets/RT/USER/enb2tx_850rflo.lime           |  1 -
 targets/RT/USER/enb2txrflo.lime               |  1 -
 targets/RT/USER/enb2txrxg.lime                |  9 ------
 targets/RT/USER/enb2txtxg.lime                |  5 ---
 targets/RT/USER/enb4txrflo.lime               |  1 -
 targets/RT/USER/enb4txrxg.lime                |  3 --
 targets/RT/USER/ex2_2rfdc.lime                |  1 -
 targets/RT/USER/ex2_2rflo.lime                |  1 -
 targets/RT/USER/ex2_2txg.lime                 |  6 ----
 targets/RT/USER/ex2_850rfdc.lime              |  2 --
 targets/RT/USER/ex2_850rflo.lime              |  1 -
 targets/RT/USER/ex2_850txg.lime               |  6 ----
 .../{ex2_2rxg.lime => exmimo2_2arxg.lime}     |  6 ++--
 .../{ex2_850rxg.lime => exmimo2_2brxg.lime}   |  6 ++--
 targets/RT/USER/lte-softmodem.c               | 31 ++++++++++++++++---
 15 files changed, 32 insertions(+), 48 deletions(-)
 delete mode 100644 targets/RT/USER/enb2tx_850rflo.lime
 delete mode 100644 targets/RT/USER/enb2txrflo.lime
 delete mode 100644 targets/RT/USER/enb2txrxg.lime
 delete mode 100644 targets/RT/USER/enb2txtxg.lime
 delete mode 100644 targets/RT/USER/enb4txrflo.lime
 delete mode 100644 targets/RT/USER/enb4txrxg.lime
 delete mode 100644 targets/RT/USER/ex2_2rfdc.lime
 delete mode 100644 targets/RT/USER/ex2_2rflo.lime
 delete mode 100644 targets/RT/USER/ex2_2txg.lime
 delete mode 100644 targets/RT/USER/ex2_850rfdc.lime
 delete mode 100644 targets/RT/USER/ex2_850rflo.lime
 delete mode 100644 targets/RT/USER/ex2_850txg.lime
 rename targets/RT/USER/{ex2_2rxg.lime => exmimo2_2arxg.lime} (88%)
 rename targets/RT/USER/{ex2_850rxg.lime => exmimo2_2brxg.lime} (88%)

diff --git a/targets/RT/USER/enb2tx_850rflo.lime b/targets/RT/USER/enb2tx_850rflo.lime
deleted file mode 100644
index 778d07a9b5..0000000000
--- a/targets/RT/USER/enb2tx_850rflo.lime
+++ /dev/null
@@ -1 +0,0 @@
-8254992   8254992   8257340   8257340
\ No newline at end of file
diff --git a/targets/RT/USER/enb2txrflo.lime b/targets/RT/USER/enb2txrflo.lime
deleted file mode 100644
index 6907a298c7..0000000000
--- a/targets/RT/USER/enb2txrflo.lime
+++ /dev/null
@@ -1 +0,0 @@
-8254744   8255063   8257340   8257340
diff --git a/targets/RT/USER/enb2txrxg.lime b/targets/RT/USER/enb2txrxg.lime
deleted file mode 100644
index 7b7a2962d8..0000000000
--- a/targets/RT/USER/enb2txrxg.lime
+++ /dev/null
@@ -1,9 +0,0 @@
-# this file contains the calibration values to compute the RSSI
-# we can use three different gain stages (high, low, med) as well as a gain factor for fine tuning
-# the three lines in this file gives the total rx gain in dB for the three gain stages if the rx gain is set to 30dB
-# high gain
-138 138 138 138
-# med gain
-129 129 129 129
-# low gain
-120 120 120 120
diff --git a/targets/RT/USER/enb2txtxg.lime b/targets/RT/USER/enb2txtxg.lime
deleted file mode 100644
index acc8d23c62..0000000000
--- a/targets/RT/USER/enb2txtxg.lime
+++ /dev/null
@@ -1,5 +0,0 @@
-# For the TX, we need to set the tx gain values such that the transmitted power on all antennas is the same
-# tx gain (dB)
-25 19 25 25 
-# total tx power (dBm)
-17
diff --git a/targets/RT/USER/enb4txrflo.lime b/targets/RT/USER/enb4txrflo.lime
deleted file mode 100644
index 6e794ce437..0000000000
--- a/targets/RT/USER/enb4txrflo.lime
+++ /dev/null
@@ -1 +0,0 @@
-8255067 8254810 8257340 8257340
diff --git a/targets/RT/USER/enb4txrxg.lime b/targets/RT/USER/enb4txrxg.lime
deleted file mode 100644
index b296e67b71..0000000000
--- a/targets/RT/USER/enb4txrxg.lime
+++ /dev/null
@@ -1,3 +0,0 @@
-133 133 133 133
-127 127 127 127
-120 120 120 120
diff --git a/targets/RT/USER/ex2_2rfdc.lime b/targets/RT/USER/ex2_2rfdc.lime
deleted file mode 100644
index ced3d41e44..0000000000
--- a/targets/RT/USER/ex2_2rfdc.lime
+++ /dev/null
@@ -1 +0,0 @@
-34689   34756   36300   36999
diff --git a/targets/RT/USER/ex2_2rflo.lime b/targets/RT/USER/ex2_2rflo.lime
deleted file mode 100644
index 487b30edf6..0000000000
--- a/targets/RT/USER/ex2_2rflo.lime
+++ /dev/null
@@ -1 +0,0 @@
-8256036   8256804   8257340   8257340
diff --git a/targets/RT/USER/ex2_2txg.lime b/targets/RT/USER/ex2_2txg.lime
deleted file mode 100644
index f92a3e8e45..0000000000
--- a/targets/RT/USER/ex2_2txg.lime
+++ /dev/null
@@ -1,6 +0,0 @@
-# For the TX, we need to set the tx gain values such that the transmitted power on all antennas is the same
-# tx gain (dB)
-# 25 19 25 25 
-10 10 10 10
-# total tx power (dBm)
-17
diff --git a/targets/RT/USER/ex2_850rfdc.lime b/targets/RT/USER/ex2_850rfdc.lime
deleted file mode 100644
index fbcd8e8f49..0000000000
--- a/targets/RT/USER/ex2_850rfdc.lime
+++ /dev/null
@@ -1,2 +0,0 @@
-33421   36226   34957   37000
-
diff --git a/targets/RT/USER/ex2_850rflo.lime b/targets/RT/USER/ex2_850rflo.lime
deleted file mode 100644
index 9739db22bb..0000000000
--- a/targets/RT/USER/ex2_850rflo.lime
+++ /dev/null
@@ -1 +0,0 @@
-8254212   8256991   8257340   8257340
diff --git a/targets/RT/USER/ex2_850txg.lime b/targets/RT/USER/ex2_850txg.lime
deleted file mode 100644
index f77d765463..0000000000
--- a/targets/RT/USER/ex2_850txg.lime
+++ /dev/null
@@ -1,6 +0,0 @@
-# For the TX, we need to set the tx gain values such that the transmitted power on all antennas is the same
-# tx gain (dB)
-# 25 19 25 25 
-0 0 0 0
-# total tx power (dBm)
-17
diff --git a/targets/RT/USER/ex2_2rxg.lime b/targets/RT/USER/exmimo2_2arxg.lime
similarity index 88%
rename from targets/RT/USER/ex2_2rxg.lime
rename to targets/RT/USER/exmimo2_2arxg.lime
index 282cf4efc1..0c24ef9992 100644
--- a/targets/RT/USER/ex2_2rxg.lime
+++ b/targets/RT/USER/exmimo2_2arxg.lime
@@ -3,8 +3,8 @@
 # the three lines in this file gives the total rx gain in dB for the three gain stages if the rx gain is set to 30dB
 # this is for Express MIMO2 without any additional RF frontend
 # high gain
-124 124 124 124
+103 107 106 104
 # med gain
-118 118 118 118 
+98 101 100 98
 # low gain (byp)
-109 109 109 109
+94 97 96 94
diff --git a/targets/RT/USER/ex2_850rxg.lime b/targets/RT/USER/exmimo2_2brxg.lime
similarity index 88%
rename from targets/RT/USER/ex2_850rxg.lime
rename to targets/RT/USER/exmimo2_2brxg.lime
index 282cf4efc1..e99c738cd0 100644
--- a/targets/RT/USER/ex2_850rxg.lime
+++ b/targets/RT/USER/exmimo2_2brxg.lime
@@ -3,8 +3,8 @@
 # the three lines in this file gives the total rx gain in dB for the three gain stages if the rx gain is set to 30dB
 # this is for Express MIMO2 without any additional RF frontend
 # high gain
-124 124 124 124
+128 128 128 126
 # med gain
-118 118 118 118 
+122 123 123 120
 # low gain (byp)
-109 109 109 109
+116 117 116 116
diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c
index b6f6762707..4db607408c 100644
--- a/targets/RT/USER/lte-softmodem.c
+++ b/targets/RT/USER/lte-softmodem.c
@@ -2400,20 +2400,20 @@ static void get_options (int argc, char **argv) {
   int clock_src;
 #endif
   int CC_id;
+  char rxg_fname[256], line[1000];
+  FILE *rxg_fd;
+  int l;
 
   const Enb_properties_array_t *enb_properties;
   
   enum long_option_e {
     LONG_OPTION_START = 0x100, /* Start after regular single char options */
-    
     LONG_OPTION_ULSCH_MAX_CONSECUTIVE_ERRORS,
     LONG_OPTION_CALIB_UE_RX,
     LONG_OPTION_CALIB_UE_RX_MED,
     LONG_OPTION_CALIB_UE_RX_BYP,
-    
     LONG_OPTION_DEBUG_UE_PRACH,
-    
-    LONG_OPTION_NO_L2_CONNECT,
+    LONG_OPTION_NO_L2_CONNECT
   };
   
   static const struct option long_options[] = {
@@ -2425,7 +2425,7 @@ static void get_options (int argc, char **argv) {
     {"no-L2-connect",   no_argument,        NULL, LONG_OPTION_NO_L2_CONNECT},
     {NULL, 0, NULL, 0}};
   
-  while ((c = getopt_long (argc, argv, "C:dK:g:G:qO:m:SUVRMr:s:t:",long_options,NULL)) != -1) {
+  while ((c = getopt_long (argc, argv, "C:dK:g:F:G:qO:m:SUVRMr:s:t:",long_options,NULL)) != -1) {
     switch (c) {
     case LONG_OPTION_ULSCH_MAX_CONSECUTIVE_ERRORS:
       ULSCH_max_consecutive_errors = atoi(optarg);
@@ -2553,6 +2553,27 @@ static void get_options (int argc, char **argv) {
     case 'g':
       glog_level=atoi(optarg); // value between 1 - 9
       break;
+
+    case 'F':
+      sprintf(rxg_fname,"%srxg.lime",optarg);
+      rxg_fd = fopen(rxg_fname,"r");
+      if (rxg_fd) {
+	printf("Loading RX Gain parameters from %s\n",rxg_fname);
+	l=0;
+	while (fgets(line, sizeof(line), rxg_fd)) {
+	  if ((strlen(line)==0) || (*line == '#')) continue; //ignore empty or comment lines
+	  else {
+	    if (l==0) sscanf(line,"%d %d %d %d",&rxg_max[0],&rxg_max[1],&rxg_max[2],&rxg_max[3]);
+	    if (l==1) sscanf(line,"%d %d %d %d",&rxg_med[0],&rxg_med[1],&rxg_med[2],&rxg_med[3]);
+	    if (l==2) sscanf(line,"%d %d %d %d",&rxg_byp[0],&rxg_byp[1],&rxg_byp[2],&rxg_byp[3]);
+	    l++;
+	  }
+	}
+      }
+      else 
+	printf("%s not found, running with defaults\n",rxg_fname);
+      break;
+      
     case 'G':
       glog_verbosity=atoi(optarg);// value from 0, 0x5, 0x15, 0x35, 0x75
       break;
-- 
GitLab