aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <vyanitskiy@sysmocom.de>2022-11-01 01:04:25 +0700
committerVadim Yanitskiy <vyanitskiy@sysmocom.de>2022-11-01 01:04:25 +0700
commitc33ff98d39b00c50dfef8def65f161a87e7f96c6 (patch)
treeaad98b8aa70369f189a8c47f3854d34ab3f8f61b
parentaa8779b8243ec1d11ca80a45fddf0756b3cfc3c6 (diff)
osmo-bts-trx: use lookup tables for checking AMR CMI/CMR on Downlink
-rw-r--r--src/osmo-bts-trx/sched_lchan_tchf.c18
-rw-r--r--src/osmo-bts-trx/sched_lchan_tchh.c15
2 files changed, 30 insertions, 3 deletions
diff --git a/src/osmo-bts-trx/sched_lchan_tchf.c b/src/osmo-bts-trx/sched_lchan_tchf.c
index bf6703a9..6a6331f7 100644
--- a/src/osmo-bts-trx/sched_lchan_tchf.c
+++ b/src/osmo-bts-trx/sched_lchan_tchf.c
@@ -61,6 +61,15 @@ static const uint8_t sched_tchf_ul_amr_cmi_map[26] = {
[24] = 1, /* TCH/F: a=17 / h=24 */
};
+/* TDMA frame number of burst 'a' should be used as the table index. */
+static const uint8_t sched_tchf_dl_amr_cmi_map[26] = {
+ [4] = 1, /* TCH/F: a=4 */
+ [13] = 1, /* TCH/F: a=13 */
+ [21] = 1, /* TCH/F: a=21 */
+};
+
+extern const uint8_t sched_tchh_dl_amr_cmi_map[26];
+
/*! \brief a single TCH/F burst was received by the PHY, process it */
int rx_tchf_fn(struct l1sched_ts *l1ts, const struct trx_ul_burst_ind *bi)
{
@@ -392,7 +401,7 @@ struct msgb *tch_dl_dequeue(struct l1sched_ts *l1ts, struct trx_dl_burst_req *br
enum osmo_amr_type ft_codec;
enum osmo_amr_quality bfi;
int8_t sti, cmi;
- bool amr_is_cmr = !dl_amr_fn_is_cmi(br->fn);
+ bool amr_is_cmr;
if (rsl_cmode != RSL_CMOD_SPD_SPEECH) {
LOGL1SB(DL1P, LOGL_NOTICE, l1ts, br, "Dropping speech frame, "
@@ -430,6 +439,10 @@ struct msgb *tch_dl_dequeue(struct l1sched_ts *l1ts, struct trx_dl_burst_req *br
"Codec (FT = %d) of RTP frame not in list\n", ft_codec);
goto free_bad_msg;
}
+ if (br->chan == TRXC_TCHF)
+ amr_is_cmr = !sched_tchf_dl_amr_cmi_map[br->fn % 26];
+ else /* TRXC_TCHH_0 or TRXC_TCHH_1 */
+ amr_is_cmr = !sched_tchh_dl_amr_cmi_map[br->fn % 26];
if (amr_is_cmr && chan_state->dl_ft != ft) {
LOGL1SB(DL1P, LOGL_NOTICE, l1ts, br, "Codec (FT = %d) "
" of RTP cannot be changed now, but in next frame\n", ft_codec);
@@ -514,7 +527,8 @@ int tx_tchf_fn(struct l1sched_ts *l1ts, struct trx_dl_burst_req *br)
* the first FN 0,8,17 defines that CMR is included in frame.
*/
gsm0503_tch_afs_encode(*bursts_p, msg->l2h + sizeof(struct amr_hdr),
- msgb_l2len(msg) - sizeof(struct amr_hdr), !dl_amr_fn_is_cmi(br->fn),
+ msgb_l2len(msg) - sizeof(struct amr_hdr),
+ !sched_tchf_dl_amr_cmi_map[br->fn % 26],
chan_state->codec, chan_state->codecs,
chan_state->dl_ft,
chan_state->dl_cmr);
diff --git a/src/osmo-bts-trx/sched_lchan_tchh.c b/src/osmo-bts-trx/sched_lchan_tchh.c
index 17073e02..37fd59d7 100644
--- a/src/osmo-bts-trx/sched_lchan_tchh.c
+++ b/src/osmo-bts-trx/sched_lchan_tchh.c
@@ -66,6 +66,18 @@ static const uint8_t sched_tchh_ul_amr_cmi_map[26] = {
[3] = 1, /* TCH/H(1): a=18 / d=24 / f=3 */
};
+/* TDMA frame number of burst 'a' should be used as the table index.
+ * This mapping is valid for both FACCH/H(0) and FACCH/H(1). */
+const uint8_t sched_tchh_dl_amr_cmi_map[26] = {
+ [4] = 1, /* TCH/H(0): a=4 */
+ [13] = 1, /* TCH/H(0): a=13 */
+ [21] = 1, /* TCH/H(0): a=21 */
+
+ [5] = 1, /* TCH/H(1): a=5 */
+ [14] = 1, /* TCH/H(1): a=14 */
+ [22] = 1, /* TCH/H(1): a=22 */
+};
+
/* 3GPP TS 45.002, table 1 in clause 7: Mapping tables.
* TDMA frame number of burst 'f' is always used as the table index. */
static const uint8_t sched_tchh_ul_facch_map[26] = {
@@ -439,7 +451,8 @@ int tx_tchh_fn(struct l1sched_ts *l1ts, struct trx_dl_burst_req *br)
* in frame, the first FN 0,8,17 or 1,9,18 defines that CMR is
* included in frame. */
gsm0503_tch_ahs_encode(*bursts_p, msg->l2h + sizeof(struct amr_hdr),
- msgb_l2len(msg) - sizeof(struct amr_hdr), !dl_amr_fn_is_cmi(br->fn),
+ msgb_l2len(msg) - sizeof(struct amr_hdr),
+ !sched_tchh_dl_amr_cmi_map[br->fn % 26],
chan_state->codec, chan_state->codecs,
chan_state->dl_ft,
chan_state->dl_cmr);