aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bts-trx/sched_lchan_tchh.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/osmo-bts-trx/sched_lchan_tchh.c')
-rw-r--r--src/osmo-bts-trx/sched_lchan_tchh.c44
1 files changed, 35 insertions, 9 deletions
diff --git a/src/osmo-bts-trx/sched_lchan_tchh.c b/src/osmo-bts-trx/sched_lchan_tchh.c
index 4f03bd12..366c625c 100644
--- a/src/osmo-bts-trx/sched_lchan_tchh.c
+++ b/src/osmo-bts-trx/sched_lchan_tchh.c
@@ -72,6 +72,7 @@ int rx_tchh_fn(struct l1sched_ts *l1ts, const struct trx_ul_burst_ind *bi)
uint8_t is_sub = 0;
uint8_t ft;
bool mask_stolen_tch_block = false;
+ bool fn_is_cmi;
/* If handover RACH detection is turned on, treat this burst as an Access Burst.
* Handle NOPE.ind as usually to ensure proper Uplink measurement reporting. */
@@ -164,10 +165,21 @@ int rx_tchh_fn(struct l1sched_ts *l1ts, const struct trx_ul_burst_ind *bi)
break;
}
+ /* Calculate the frame number where the block begins */
+ if (bi->fn % 13 < 4)
+ fn_tch_end = GSM_TDMA_FN_SUB(bi->fn, 5);
+ else
+ fn_tch_end = GSM_TDMA_FN_SUB(bi->fn, 4);
+ if (lchan->nr == 0)
+ fn_begin = gsm0502_fn_remap(fn_tch_end, FN_REMAP_TCH_H0);
+ else
+ fn_begin = gsm0502_fn_remap(fn_tch_end, FN_REMAP_TCH_H1);
+ fn_is_cmi = ul_amr_fn_is_cmi(fn_begin);
+
/* See comment in function rx_tchf_fn() */
amr = 2;
rc = gsm0503_tch_ahs_decode_dtx(tch_data + amr, *bursts_p,
- fn_is_odd, fn_is_odd, chan_state->codec,
+ fn_is_odd, !fn_is_cmi, chan_state->codec,
chan_state->codecs, &chan_state->ul_ft,
&chan_state->ul_cmr, &n_errors, &n_bits_total, &chan_state->amr_last_dtx);
@@ -210,7 +222,7 @@ int rx_tchh_fn(struct l1sched_ts *l1ts, const struct trx_ul_burst_ind *bi)
/* only good speech frames get rtp header */
if (rc != GSM_MACBLOCK_LEN && rc >= 4) {
if (chan_state->amr_last_dtx == AMR_OTHER) {
- ft = chan_state->codec[chan_state->ul_cmr];
+ ft = chan_state->codec[chan_state->ul_ft];
} else {
/* SID frames will always get Frame Type Index 8 (AMR_SID) */
ft = AMR_SID;
@@ -305,8 +317,8 @@ bfi:
break;
case GSM48_CMODE_SPEECH_AMR: /* AMR */
rc = osmo_amr_rtp_enc(tch_data,
- chan_state->codec[chan_state->dl_cmr],
- chan_state->codec[chan_state->dl_ft],
+ chan_state->codec[chan_state->ul_cmr],
+ chan_state->codec[chan_state->ul_ft],
AMR_BAD);
if (rc < 2) {
LOGL1SB(DL1P, LOGL_ERROR, l1ts, bi,
@@ -343,7 +355,6 @@ compose_l1sap:
fn_tch_end = GSM_TDMA_FN_SUB(bi->fn, 5);
else
fn_tch_end = GSM_TDMA_FN_SUB(bi->fn, 4);
-
if (lchan->nr == 0)
fn_begin = gsm0502_fn_remap(fn_tch_end, FN_REMAP_TCH_H0);
else
@@ -364,7 +375,9 @@ compose_l1sap:
return _sched_compose_tch_ind(l1ts, fn_begin, bi->chan, tch_data, rc,
/* FIXME: what should we use for BFI here? */
bfi_flag ? bi->toa256 : meas_avg.toa256, ber10k,
- bfi_flag ? bi->rssi : meas_avg.rssi, is_sub);
+ bfi_flag ? bi->rssi : meas_avg.rssi,
+ bfi_flag ? bi->ci_cb : meas_avg.ci_cb,
+ is_sub);
}
/* common section for generation of TCH bursts (TCH/H and TCH/F).
@@ -384,7 +397,7 @@ int tx_tchh_fn(struct l1sched_ts *l1ts, struct trx_dl_burst_req *br)
/* send burst, if we already got a frame */
if (br->bid > 0) {
if (!*bursts_p)
- return 0;
+ return -ENODEV;
goto send_burst;
}
@@ -417,9 +430,16 @@ int tx_tchh_fn(struct l1sched_ts *l1ts, struct trx_dl_burst_req *br)
}
}
- /* no message at all */
+ /* no message at all, send a dummy L2 frame on FACCH */
if (!msg_tch && !msg_facch && !chan_state->dl_ongoing_facch) {
+ static const uint8_t dummy[GSM_MACBLOCK_LEN] = {
+ 0x03, 0x03, 0x01, /* TODO: use randomized padding */
+ 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b,
+ 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b,
+ };
+
LOGL1SB(DL1P, LOGL_INFO, l1ts, br, "No TCH or FACCH prim for transmit.\n");
+ gsm0503_tch_hr_encode(*bursts_p, dummy, sizeof(dummy));
goto send_burst;
}
@@ -427,6 +447,7 @@ int tx_tchh_fn(struct l1sched_ts *l1ts, struct trx_dl_burst_req *br)
if (msg_facch) {
gsm0503_tch_hr_encode(*bursts_p, msg_facch->l2h, msgb_l2len(msg_facch));
chan_state->dl_ongoing_facch = 1; /* first of two TCH frames */
+ chan_state->dl_facch_bursts = 6;
} else if (chan_state->dl_ongoing_facch) /* second of two TCH frames */
chan_state->dl_ongoing_facch = 0; /* we are done with FACCH */
else if (tch_mode == GSM48_CMODE_SPEECH_AMR)
@@ -434,7 +455,7 @@ 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_tch->l2h + 2,
- msgb_l2len(msg_tch) - 2, fn_is_codec_mode_request(br->fn),
+ msgb_l2len(msg_tch) - 2, !dl_amr_fn_is_cmi(br->fn),
chan_state->codec, chan_state->codecs,
chan_state->dl_ft,
chan_state->dl_cmr);
@@ -456,6 +477,11 @@ send_burst:
br->burst_len = GSM_BURST_LEN;
+ if (chan_state->dl_facch_bursts > 0) {
+ chan_state->dl_facch_bursts--;
+ br->flags |= TRX_BR_F_FACCH;
+ }
+
LOGL1SB(DL1P, LOGL_DEBUG, l1ts, br, "Transmitting burst=%u.\n", br->bid);
return 0;