From 963ccb9badab05d0f18d8306c0e9ece420e99fbd Mon Sep 17 00:00:00 2001
From: "Raymond.Knopp" <raymond.knopp@eurecom.fr>
Date: Thu, 17 Nov 2016 11:57:14 +0100
Subject: [PATCH] some changes for tx-gain setting

---
 targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp | 21 ++++++-------------
 .../CONF/enb.band7.tm1.lmssdr.conf            |  2 +-
 2 files changed, 7 insertions(+), 16 deletions(-)

diff --git a/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp b/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp
index c1e3cb81c1..3abcbbac5a 100644
--- a/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp
+++ b/targets/ARCH/LMSSDR/USERSPACE/LIB/lms_lib.cpp
@@ -131,18 +131,8 @@ void set_rx_gain_offset(openair0_config_t *openair0_cfg, int chain_index) {
  */
 int trx_lms_set_gains(openair0_device* device, openair0_config_t *openair0_cfg) {
 
- /* double gv = openair0_cfg[0].rx_gain[0] - openair0_cfg[0].rx_gain_offset[0];
-
-  if (gv > 31) {
-    printf("RX Gain 0 too high, reduce by %f dB\n",gv-31);
-    gv = 31;
-  }
-  if (gv < 0) {
-    printf("RX Gain 0 too low, increase by %f dB\n",-gv);
-    gv = 0;
-  }
-  printf("[LMS] Setting 7002M G_PGA_RBB to %d\n", (uint16_t)gv);
-  LMS_WriteParam(lms_device,LMS7param(G_PGA_RBB),(uint16_t)gv);*/
+  LMS_SetNormalizedGain(lms_device, LMS_CH_TX, 0, openair0_cfg[0].tx_gain[0]/100.0);
+  LMS_SetNormalizedGain(lms_device, LMS_CH_RX, 0, openair0_cfg[0].rx_gain[0]/openair0_cfg[0].rx_gain_offset[0]);
 
   return(0);
 }
@@ -209,10 +199,8 @@ int trx_lms_start(openair0_device *device){
     LMS_SetAntenna(lms_device, LMS_CH_RX, 0, 3);
     LMS_SetAntenna(lms_device, LMS_CH_TX, 0, 2);
 
-    trx_lms_set_gains(device, device->openair0_cfg);
-    /*LMS_SetNormalizedGain(lms_device, LMS_CH_TX, 0, 0.175);
-    LMS_SetNormalizedGain(lms_device, LMS_CH_RX, 0, 0.65);*/
 
+    
     for (int i = 0; i< device->openair0_cfg->rx_num_channels; i++)
     {
         if (LMS_SetLPFBW(lms_device,LMS_CH_RX,i,device->openair0_cfg->rx_bw)!=0)
@@ -239,6 +227,9 @@ int trx_lms_start(openair0_device *device){
     tx_stream.throughputVsLatency = 0.1;
     tx_stream.dataFmt = lms_stream_t::LMS_FMT_I12;
     tx_stream.isTx = true;
+
+    trx_lms_set_gains(device, device->openair0_cfg);
+
     if (LMS_SetupStream(lms_device, &tx_stream)!=0)
         printf("TX stream setup failed %s\n",LMS_GetLastErrorMessage());
 
diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.lmssdr.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.lmssdr.conf
index b0ef9e0374..d912b1a102 100644
--- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.lmssdr.conf
+++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.lmssdr.conf
@@ -39,7 +39,7 @@ eNBs =
 			   nb_antennas_ports				      = 1;
                            nb_antennas_tx          			      = 1;
                            nb_antennas_rx          			      = 1; 
-			   tx_gain                                            = 60;
+			   tx_gain                                            = 100;
 			   rx_gain                                            = 111;
                            prach_root              			      = 0;
                            prach_config_index      			      = 0;
-- 
GitLab