fixeria has uploaded this change for review. (
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, 32 insertions(+), 24 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/15/31115/1
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..0c37f35 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))
@@ -451,29 +450,9 @@
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));
- 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;
+ l1sched_lchan_set_amr_cfg(lchan,
+ req->amr.codecs_bitmask,
+ req->amr.start_codec);
}
req->applied = true;
}
--
To view, visit
https://gerrit.osmocom.org/c/osmocom-bb/+/31115
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: Ia9504d6194a4aac6256f7d4caf73eb42bb58563e
Gerrit-Change-Number: 31115
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-MessageType: newchange