pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bts/+/18902 )
Change subject: power_ramp: Add support to get callback when ramping process completes ...................................................................... power_ramp: Add support to get callback when ramping process completes It will be used in forthcoming commits to feed FSM events once the ramping process completes. Change-Id: I778dc215cf6055b93658670cc12e78ad2e51f85e --- M include/osmo-bts/tx_power.h M src/common/bts_ctrl_commands.c M src/common/tx_power.c M src/osmo-bts-octphy/l1_oml.c M src/osmo-bts-sysmo/oml.c M src/osmo-bts-sysmo/sysmobts_vty.c M src/osmo-bts-trx/l1_if.c M tests/tx_power/tx_power_test.c 8 files changed, 20 insertions(+), 12 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/02/18902/1 diff --git a/include/osmo-bts/tx_power.h b/include/osmo-bts/tx_power.h index 8f33100..4d0457b 100644 --- a/include/osmo-bts/tx_power.h +++ b/include/osmo-bts/tx_power.h @@ -20,6 +20,8 @@ struct pa_calibration calib; }; +typedef void (*ramp_compl_cb_t)(struct gsm_bts_trx *trx); + /* Transmit power related parameters of a transceiver */ struct trx_power_params { /* specified maximum output of TRX at full power, has to be @@ -55,6 +57,8 @@ unsigned int step_size_mdB; unsigned int step_interval_sec; struct osmo_timer_list step_timer; + /* call-back called when target is reached */ + ramp_compl_cb_t compl_cb; } ramp; }; @@ -73,7 +77,7 @@ int get_p_trxout_actual_mdBm(struct gsm_bts_trx *trx, uint8_t bs_power_red); int get_p_trxout_actual_mdBm_lchan(struct gsm_lchan *lchan); -int power_ramp_start(struct gsm_bts_trx *trx, int p_total_tgt_mdBm, int bypass); +int power_ramp_start(struct gsm_bts_trx *trx, int p_total_tgt_mdBm, int bypass, ramp_compl_cb_t ramp_compl_cb); void power_trx_change_compl(struct gsm_bts_trx *trx, int p_trxout_cur_mdBm); diff --git a/src/common/bts_ctrl_commands.c b/src/common/bts_ctrl_commands.c index 0d31890..faaba6a 100644 --- a/src/common/bts_ctrl_commands.c +++ b/src/common/bts_ctrl_commands.c @@ -57,7 +57,7 @@ tpp->thermal_attenuation_mdB = val; - power_ramp_start(trx, tpp->p_total_cur_mdBm, 0); + power_ramp_start(trx, tpp->p_total_cur_mdBm, 0, NULL); return get_therm_att(cmd, data); } diff --git a/src/common/tx_power.c b/src/common/tx_power.c index db3121d..c8e961f 100644 --- a/src/common/tx_power.c +++ b/src/common/tx_power.c @@ -210,8 +210,11 @@ struct trx_power_params *tpp = &trx->power_params; /* we had finished in last loop iteration */ - if (!first && tpp->ramp.attenuation_mdB == 0) + if (!first && tpp->ramp.attenuation_mdB == 0) { + if (tpp->ramp.compl_cb) + tpp->ramp.compl_cb(trx); return; + } if (we_are_ramping_up(trx)) { /* ramp up power -> ramp down attenuation */ @@ -236,7 +239,7 @@ } -int power_ramp_start(struct gsm_bts_trx *trx, int p_total_tgt_mdBm, int bypass) +int power_ramp_start(struct gsm_bts_trx *trx, int p_total_tgt_mdBm, int bypass, ramp_compl_cb_t ramp_compl_cb) { struct trx_power_params *tpp = &trx->power_params; @@ -259,6 +262,7 @@ /* set the new target */ tpp->p_total_tgt_mdBm = p_total_tgt_mdBm; + tpp->ramp.compl_cb = ramp_compl_cb; if (we_are_ramping_up(trx)) { if (tpp->p_total_tgt_mdBm <= tpp->ramp.max_initial_pout_mdBm) { diff --git a/src/osmo-bts-octphy/l1_oml.c b/src/osmo-bts-octphy/l1_oml.c index 9c5dd19..7718605 100644 --- a/src/osmo-bts-octphy/l1_oml.c +++ b/src/osmo-bts-octphy/l1_oml.c @@ -1740,7 +1740,7 @@ struct gsm_bts_trx *trx = obj; /*struct octphy_hdl *fl1h = trx_octphy_hdl(trx); */ - power_ramp_start(trx, get_p_target_mdBm(trx, 0), 0); + power_ramp_start(trx, get_p_target_mdBm(trx, 0), 0, NULL); } return oml_fom_ack_nack(msg, 0); } diff --git a/src/osmo-bts-sysmo/oml.c b/src/osmo-bts-sysmo/oml.c index 3533597..c3bf8b6 100644 --- a/src/osmo-bts-sysmo/oml.c +++ b/src/osmo-bts-sysmo/oml.c @@ -358,7 +358,7 @@ #endif /* Begin to ramp up the power */ - power_ramp_start(trx, get_p_target_mdBm(trx, 0), 0); + power_ramp_start(trx, get_p_target_mdBm(trx, 0), 0, NULL); return opstart_compl(&trx->mo, l1_msg); } @@ -1743,7 +1743,7 @@ /* Did we go through MphInit yet? If yes fire and forget */ if (fl1h->hLayer1) - power_ramp_start(trx, get_p_target_mdBm(trx, 0), 0); + power_ramp_start(trx, get_p_target_mdBm(trx, 0), 0, NULL); } /* FIXME: we actually need to send a ACK or NACK for the OML message */ diff --git a/src/osmo-bts-sysmo/sysmobts_vty.c b/src/osmo-bts-sysmo/sysmobts_vty.c index 23f69a0..0653f01 100644 --- a/src/osmo-bts-sysmo/sysmobts_vty.c +++ b/src/osmo-bts-sysmo/sysmobts_vty.c @@ -362,7 +362,7 @@ int power = atoi(argv[1]); struct gsm_bts_trx *trx = gsm_bts_trx_num(vty_bts, trx_nr); - power_ramp_start(trx, to_mdB(power), 1); + power_ramp_start(trx, to_mdB(power), 1, NULL); return CMD_SUCCESS; } diff --git a/src/osmo-bts-trx/l1_if.c b/src/osmo-bts-trx/l1_if.c index 07f6e7a..ea3dcfa 100644 --- a/src/osmo-bts-trx/l1_if.c +++ b/src/osmo-bts-trx/l1_if.c @@ -144,9 +144,9 @@ struct trx_l1h *l1h = pinst->u.osmotrx.hdl; if (l1h->config.forced_max_power_red == -1) - power_ramp_start(trx, get_p_nominal_mdBm(trx), 0); + power_ramp_start(trx, get_p_nominal_mdBm(trx), 0, NULL); else - power_ramp_start(trx, get_p_max_out_mdBm(trx) - to_mdB(l1h->config.forced_max_power_red), 1); + power_ramp_start(trx, get_p_max_out_mdBm(trx) - to_mdB(l1h->config.forced_max_power_red), 1, NULL); } /* Sets the nominal power, in dB */ @@ -478,7 +478,7 @@ is already running. Otherwise skip, power ramping will be started after TRX is running */ if (plink->u.osmotrx.powered && l1h->config.forced_max_power_red == -1) - power_ramp_start(pinst->trx, get_p_nominal_mdBm(pinst->trx), 0); + power_ramp_start(pinst->trx, get_p_nominal_mdBm(pinst->trx), 0, NULL); return 0; } diff --git a/tests/tx_power/tx_power_test.c b/tests/tx_power/tx_power_test.c index aaa34ea..02c940f 100644 --- a/tests/tx_power/tx_power_test.c +++ b/tests/tx_power/tx_power_test.c @@ -200,7 +200,7 @@ trx->power_params.ramp.step_interval_sec = 0; /* speedup test */ trx->max_power_red = 0; - power_ramp_start(trx, to_mdB(dBm), 0); + power_ramp_start(trx, to_mdB(dBm), 0, NULL); } int main(int argc, char **argv) -- To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/18902 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Change-Id: I778dc215cf6055b93658670cc12e78ad2e51f85e Gerrit-Change-Number: 18902 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pes...@sysmocom.de> Gerrit-MessageType: newchange