[osmo-bts,2/5] osmo-bts-sysmo/utils.c: Added a function for calculate the power transmitter
diff mbox

Message ID 1398685224-19161-1-git-send-email-anayuso@sysmocom.de
State Changes Requested
Headers show

Commit Message

Alvaro Neira April 28, 2014, 11:40 a.m. UTC
From: Álvaro Neira Ayuso <anayuso@sysmocom.de>

Signed-off-by: Alvaro Neira Ayuso <anayuso@sysmocom.de>
---
 src/osmo-bts-sysmo/oml.c   |    4 ++--
 src/osmo-bts-sysmo/utils.c |   11 +++++++++++
 src/osmo-bts-sysmo/utils.h |    1 +
 3 files changed, 14 insertions(+), 2 deletions(-)

Patch
diff mbox

diff --git a/src/osmo-bts-sysmo/oml.c b/src/osmo-bts-sysmo/oml.c
index 1543f85..4ebf664 100644
--- a/src/osmo-bts-sysmo/oml.c
+++ b/src/osmo-bts-sysmo/oml.c
@@ -323,7 +323,7 @@  static int trx_init(struct gsm_bts_trx *trx)
 	dev_par->u16BcchArfcn = trx->bts->c0->arfcn;
 	dev_par->u8NbTsc = trx->bts->bsic & 7;
 	dev_par->fRxPowerLevel = fl1h->ul_power_target;
-	dev_par->fTxPowerLevel = trx->nominal_power - trx->max_power_red;
+	dev_par->fTxPowerLevel = sysmobts_get_power_trx(trx);
 	LOGP(DL1C, LOGL_NOTICE, "Init TRX (ARFCN %u, TSC %u, RxPower % 2f dBm, "
 		"TxPower % 2.2f dBm\n", dev_par->u16Arfcn, dev_par->u8NbTsc,
 		dev_par->fRxPowerLevel, dev_par->fTxPowerLevel);
@@ -1544,7 +1544,7 @@  int bts_model_apply_oml(struct gsm_bts *bts, struct msgb *msg,
 
 		/* Did we go through MphInit yet? If yes fire and forget */
 		if (fl1h->hLayer1)
-			l1if_set_txpower(fl1h, trx->nominal_power - trx->max_power_red);
+			l1if_set_txpower(fl1h, sysmobts_get_power_trx(trx));
 	}
 
 	/* FIXME: we actaully need to send a ACK or NACK for the OML message */
diff --git a/src/osmo-bts-sysmo/utils.c b/src/osmo-bts-sysmo/utils.c
index f576eef..af1e5d2 100644
--- a/src/osmo-bts-sysmo/utils.c
+++ b/src/osmo-bts-sysmo/utils.c
@@ -136,3 +136,14 @@  int sysmobts_get_nominal_power(struct gsm_bts_trx *trx)
 	}
 	return -1;
 }
+
+int sysmobts_get_power_trx(struct gsm_bts_trx *trx)
+{
+	int power_transmitter = trx->nominal_power - trx->max_power_red;
+	power_transmitter -= trx->power_reduce;
+
+	if (power_transmitter < 0)
+		power_transmitter = 0;
+
+	return power_transmitter;
+}
diff --git a/src/osmo-bts-sysmo/utils.h b/src/osmo-bts-sysmo/utils.h
index ff41437..aef774c 100644
--- a/src/osmo-bts-sysmo/utils.h
+++ b/src/osmo-bts-sysmo/utils.h
@@ -12,4 +12,5 @@  int sysmobts_select_femto_band(struct gsm_bts_trx *trx, uint16_t arfcn);
 
 int sysmobts_get_nominal_power(struct gsm_bts_trx *trx);
 
+int sysmobts_get_power_trx(struct gsm_bts_trx *trx);
 #endif