aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bts-trx/sched_utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/osmo-bts-trx/sched_utils.h')
-rw-r--r--src/osmo-bts-trx/sched_utils.h76
1 files changed, 73 insertions, 3 deletions
diff --git a/src/osmo-bts-trx/sched_utils.h b/src/osmo-bts-trx/sched_utils.h
index 4a1aaf5f..f76e49bb 100644
--- a/src/osmo-bts-trx/sched_utils.h
+++ b/src/osmo-bts-trx/sched_utils.h
@@ -23,6 +23,8 @@
#include <stdint.h>
#include <errno.h>
+#include <stdbool.h>
+#include <osmo-bts/scheduler.h>
extern void *tall_bts_ctx;
@@ -35,8 +37,76 @@ static inline uint16_t compute_ber10k(int n_bits_total, int n_errors)
return 10000 * n_errors / n_bits_total;
}
-/* determine if the FN is transmitting a CMR (1) or not (0) */
-static inline int fn_is_codec_mode_request(uint32_t fn)
+/*! determine whether an uplink AMR block is CMI according to 3GPP TS 45.009.
+ * \param[in] fn_begin frame number of the beginning of the block.
+ * \returns true in case of CMI; false otherwise. */
+static inline bool ul_amr_fn_is_cmi(uint32_t fn_begin)
{
- return (((fn + 4) % 26) >> 2) & 1;
+ switch (fn_begin % 26) {
+ /*! See also: 3GPP TS 45.009, section 3.2.1.3 Transmitter/Receiver Synchronisation */
+ /* valid for AHS subslot 0 and AFS: */
+ case 0:
+ case 8:
+ case 17:
+ /* valid for AHS subslot 1: */
+ case 1:
+ case 9:
+ case 18:
+ return true;
+ break;
+ /* Complementary values for sanity check */
+ /* valid for AHS subslot 0 and AFS: */
+ case 4:
+ case 13:
+ case 21:
+ /* valid for AHS subslot 1: */
+ case 5:
+ case 14:
+ case 22:
+ return false;
+ break;
+ default:
+ LOGP(DL1P, LOGL_DEBUG,
+ "uplink frame number fn_begin=%u does not mark the beginning of a voice block!\n", fn_begin);
+ OSMO_ASSERT(false);
+ return false;
+ break;
+ }
+}
+
+/*! determine the whether a downlink AMR block is CMI according to 3GPP TS 45.009.
+ * \param[in] fn_begin frame number of the beginning of the block.
+ * \returns true in case of CMI; false otherwise. */
+static inline bool dl_amr_fn_is_cmi(uint32_t fn_begin)
+{
+ switch (fn_begin % 26) {
+ /*! See also: 3GPP TS 45.009, section 3.2.1.3 Transmitter/Receiver Synchronisation */
+ /* valid for AHS subslot 0 and AFS: */
+ case 4:
+ case 13:
+ case 21:
+ /* valid for AHS subslot 1: */
+ case 5:
+ case 14:
+ case 22:
+ return true;
+ break;
+ /* Complementary values for sanity check */
+ /* valid for AHS subslot 0 and AFS: */
+ case 0:
+ case 8:
+ case 17:
+ /* valid for AHS subslot 1: */
+ case 1:
+ case 9:
+ case 18:
+ return false;
+ break;
+ default:
+ LOGP(DL1P, LOGL_DEBUG,
+ "downlink frame number fn_begin=%u does not mark the beginning of a voice block!\n", fn_begin);
+ OSMO_ASSERT(false);
+ return false;
+ break;
+ }
}