fixeria has submitted this change. ( https://gerrit.osmocom.org/c/osmocom-bb/+/31115 )
Change subject: trxcon: move AMR mode setting to l1sched_lchan_set_amr_cfg() ......................................................................
trxcon: move AMR mode setting to l1sched_lchan_set_amr_cfg()
Change-Id: Ia9504d6194a4aac6256f7d4caf73eb42bb58563e --- M src/host/trxcon/include/osmocom/bb/l1sched/l1sched.h M src/host/trxcon/src/sched_trx.c M src/host/trxcon/src/trxcon_fsm.c 3 files changed, 34 insertions(+), 24 deletions(-)
Approvals: Jenkins Builder: Verified pespin: Looks good to me, but someone else must approve osmith: Looks good to me, but someone else must approve fixeria: Looks good to me, approved
diff --git a/src/host/trxcon/include/osmocom/bb/l1sched/l1sched.h b/src/host/trxcon/include/osmocom/bb/l1sched/l1sched.h index 4b743ca..0ea1ba0 100644 --- a/src/host/trxcon/include/osmocom/bb/l1sched/l1sched.h +++ b/src/host/trxcon/include/osmocom/bb/l1sched/l1sched.h @@ -436,6 +436,8 @@ void l1sched_deactivate_all_lchans(struct l1sched_ts *ts); int l1sched_set_lchans(struct l1sched_ts *ts, uint8_t chan_nr, int active, uint8_t tch_mode, uint8_t tsc); +int l1sched_lchan_set_amr_cfg(struct l1sched_lchan_state *lchan, + uint8_t codecs_bitmask, uint8_t start_codec); int l1sched_activate_lchan(struct l1sched_ts *ts, enum l1sched_lchan_type chan); int l1sched_deactivate_lchan(struct l1sched_ts *ts, enum l1sched_lchan_type chan); struct l1sched_lchan_state *l1sched_find_lchan(struct l1sched_ts *ts, diff --git a/src/host/trxcon/src/sched_trx.c b/src/host/trxcon/src/sched_trx.c index d2040c5..267f128 100644 --- a/src/host/trxcon/src/sched_trx.c +++ b/src/host/trxcon/src/sched_trx.c @@ -452,6 +452,33 @@ return rc; }
+int l1sched_lchan_set_amr_cfg(struct l1sched_lchan_state *lchan, + uint8_t codecs_bitmask, uint8_t start_codec) +{ + int n = 0; + int acum = 0; + int pos; + + while ((pos = ffs(codecs_bitmask)) != 0) { + acum += pos; + LOGP_LCHANC(lchan, LOGL_DEBUG, "AMR codec[%u] = %u\n", n, acum - 1); + lchan->amr.codec[n++] = acum - 1; + codecs_bitmask >>= pos; + } + if (n == 0) { + LOGP_LCHANC(lchan, LOGL_ERROR, "Empty AMR codec mode bitmask!\n"); + return -EINVAL; + } + + lchan->amr.codecs = n; + lchan->amr.dl_ft = start_codec; + lchan->amr.dl_cmr = start_codec; + lchan->amr.ul_ft = start_codec; + lchan->amr.ul_cmr = start_codec; + + return 0; +} + int l1sched_activate_lchan(struct l1sched_ts *ts, enum l1sched_lchan_type chan) { const struct l1sched_lchan_desc *lchan_desc = &l1sched_lchan_desc[chan]; diff --git a/src/host/trxcon/src/trxcon_fsm.c b/src/host/trxcon/src/trxcon_fsm.c index e3224a9..186c04b 100644 --- a/src/host/trxcon/src/trxcon_fsm.c +++ b/src/host/trxcon/src/trxcon_fsm.c @@ -35,7 +35,6 @@ #include <osmocom/bb/trxcon/phyif.h> #include <osmocom/bb/trxcon/l1ctl.h> #include <osmocom/bb/l1sched/l1sched.h> -#include <osmocom/bb/l1sched/logging.h>
#define S(x) (1 << (x))
@@ -449,32 +448,14 @@ /* Omit inactive channels */ if (!lchan->active) continue; - lchan->tch_mode = req->mode; if (req->mode == GSM48_CMODE_SPEECH_AMR) { - uint8_t bmask = req->amr.codecs_bitmask; - int n = 0; - int acum = 0; - int pos; - while ((pos = ffs(bmask)) != 0) { - acum += pos; - LOGPFSML(fi, LOGL_DEBUG, - LOGP_LCHAN_NAME_FMT " AMR codec[%u] = %u\n", - LOGP_LCHAN_NAME_ARGS(lchan), n, acum - 1); - lchan->amr.codec[n++] = acum - 1; - bmask >>= pos; - } - if (n == 0) { - LOGPFSML(fi, LOGL_ERROR, - LOGP_LCHAN_NAME_FMT " Empty AMR codec mode bitmask!\n", - LOGP_LCHAN_NAME_ARGS(lchan)); + int rc = l1sched_lchan_set_amr_cfg(lchan, + req->amr.codecs_bitmask, + req->amr.start_codec); + if (rc) continue; - } - lchan->amr.codecs = n; - lchan->amr.dl_ft = req->amr.start_codec; - lchan->amr.dl_cmr = req->amr.start_codec; - lchan->amr.ul_ft = req->amr.start_codec; - lchan->amr.ul_cmr = req->amr.start_codec; } + lchan->tch_mode = req->mode; req->applied = true; } }