trxcon: move AMR mode setting to l1sched_lchan_set_amr_cfg()
Change-Id: Ia9504d6194a4aac6256f7d4caf73eb42bb58563e
This commit is contained in:
parent
5ed15cb937
commit
4052c00efb
|
@ -436,6 +436,8 @@ enum l1sched_lchan_type l1sched_chan_nr2lchan_type(uint8_t chan_nr,
|
|||
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,
|
||||
|
|
|
@ -452,6 +452,33 @@ int l1sched_set_lchans(struct l1sched_ts *ts, uint8_t chan_nr,
|
|||
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];
|
||||
|
|
|
@ -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 @@ static void trxcon_st_dedicated_action(struct osmo_fsm_inst *fi,
|
|||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue