From d692b6e054b25474615401dcaf33209c03923e9d Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Sat, 16 Feb 2013 14:28:25 +0100 Subject: [PATCH] TRX: Replaced GSM 06.10 ordering table by table in libosmocodec --- configure.ac | 1 + src/osmo-bts-trx/Makefile.am | 4 +-- src/osmo-bts-trx/gsm0503_coding.c | 46 +++++++++++++++++++++---------- src/osmo-bts-trx/gsm0503_tables.c | 22 --------------- src/osmo-bts-trx/gsm0503_tables.h | 1 - tests/bursts/Makefile.am | 4 +-- 6 files changed, 37 insertions(+), 41 deletions(-) diff --git a/configure.ac b/configure.ac index d3fcff286..60421b824 100644 --- a/configure.ac +++ b/configure.ac @@ -28,6 +28,7 @@ PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 0.3.3) PKG_CHECK_MODULES(LIBOSMOCTRL, libosmoctrl) PKG_CHECK_MODULES(LIBOSMOABIS, libosmoabis) PKG_CHECK_MODULES(LIBGPS, libgps) +PKG_CHECK_MODULES(LIBOSMOCODEC, libosmocodec) AC_MSG_CHECKING([whether to enable sysmocom-bts hardware support]) AC_ARG_ENABLE(sysmocom-bts, diff --git a/src/osmo-bts-trx/Makefile.am b/src/osmo-bts-trx/Makefile.am index d5021c924..28221d153 100644 --- a/src/osmo-bts-trx/Makefile.am +++ b/src/osmo-bts-trx/Makefile.am @@ -1,6 +1,6 @@ INCLUDES = $(all_includes) -I$(top_srcdir)/include -I$(OPENBSC_INCDIR) -AM_CFLAGS = -Wall -fno-strict-aliasing $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(LIBOSMOTRAU_CFLAGS) $(LIBOSMOABIS_CFLAGS) -LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS) $(LIBOSMOTRAU_LIBS) $(LIBOSMOABIS_LIBS) -lortp +AM_CFLAGS = -Wall -fno-strict-aliasing $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOCODEC_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(LIBOSMOTRAU_CFLAGS) $(LIBOSMOABIS_CFLAGS) +LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOCODEC_LIBS) $(LIBOSMOVTY_LIBS) $(LIBOSMOTRAU_LIBS) $(LIBOSMOABIS_LIBS) -lortp EXTRA_DIST = trx_if.h l1_if.h scheduler.h gsm0503_parity.h gsm0503_conv.h gsm0503_interleaving.h gsm0503_mapping.h gsm0503_coding.h gsm0503_tables.h diff --git a/src/osmo-bts-trx/gsm0503_coding.c b/src/osmo-bts-trx/gsm0503_coding.c index 2d3f7705f..c7fe28db9 100644 --- a/src/osmo-bts-trx/gsm0503_coding.c +++ b/src/osmo-bts-trx/gsm0503_coding.c @@ -7,6 +7,7 @@ #include #include #include +#include #include "gsm0503_conv.h" #include "gsm0503_parity.h" @@ -302,12 +303,24 @@ int pdtch_encode(ubit_t *bursts, uint8_t *l2_data, uint8_t l2_len) * GSM TCH/F FR transcoding */ -static void tch_fr_reassemble(uint8_t *tch_data, ubit_t *b_bits) +static void tch_fr_reassemble(uint8_t *tch_data, ubit_t *b_bits, int net_order) { int i, j, k, l, o; tch_data[0] = 0xd << 4; memset(tch_data + 1, 0, 32); + + if (net_order) { + i = 0; /* counts bits */ + j = 4; /* counts output bits */ + while (i < 260) { + tch_data[j>>3] |= (b_bits[i] << (7-(j&7))); + i++; + j++; + } + return; + } + /* reassemble d-bits */ i = 0; /* counts bits */ j = 4; /* counts output bits */ @@ -327,10 +340,21 @@ static void tch_fr_reassemble(uint8_t *tch_data, ubit_t *b_bits) /* rearrange according to Table 2 of TS 05.03 */ } -static void tch_fr_disassemble(ubit_t *b_bits, uint8_t *tch_data) +static void tch_fr_disassemble(ubit_t *b_bits, uint8_t *tch_data, int net_order) { int i, j, k, l, o; + if (net_order) { + i = 0; /* counts bits */ + j = 4; /* counts output bits */ + while (i < 260) { + b_bits[i] = (tch_data[j>>3] >> (7-(j&7))) & 1; + i++; + j++; + } + return; + } + i = 0; /* counts bits */ j = 4; /* counts input bits */ k = gsm0503_gsm_fr_map[0]-1; /* current number bit in element */ @@ -353,7 +377,7 @@ static void tch_fr_d_to_b(ubit_t *b_bits, ubit_t *d_bits) int i; for (i = 0; i < 260; i++) - b_bits[gsm0503_d_to_b_index[i]] = d_bits[i]; + b_bits[gsm610_bitorder[i]] = d_bits[i]; } static void tch_fr_b_to_d(ubit_t *d_bits, ubit_t *b_bits) @@ -361,7 +385,7 @@ static void tch_fr_b_to_d(ubit_t *d_bits, ubit_t *b_bits) int i; for (i = 0; i < 260; i++) - d_bits[i] = b_bits[gsm0503_d_to_b_index[i]]; + d_bits[i] = b_bits[gsm610_bitorder[i]]; } static void tch_fr_unreorder(ubit_t *d, ubit_t *p, ubit_t *u) @@ -414,12 +438,9 @@ int tch_fr_decode(uint8_t *tch_data, sbit_t *bursts, int net_order) if (rv) return -1; - if (net_order) { - tch_fr_d_to_b(b, d); + tch_fr_d_to_b(b, d); - tch_fr_reassemble(tch_data, b); - } else - tch_fr_d_to_b(tch_data, d); + tch_fr_reassemble(tch_data, b, net_order); len = 33; } else { @@ -441,12 +462,9 @@ int tch_fr_encode(ubit_t *bursts, uint8_t *tch_data, int len, int net_order) switch (len) { case 33: /* TCH FR */ - if (net_order) { - tch_fr_disassemble(b, tch_data); + tch_fr_disassemble(b, tch_data, net_order); - tch_fr_b_to_d(d, b); - } else - tch_fr_b_to_d(d, tch_data); + tch_fr_b_to_d(d, b); osmo_crc8gen_set_bits(&gsm0503_tch_fr_crc3, d, 50, p); diff --git a/src/osmo-bts-trx/gsm0503_tables.c b/src/osmo-bts-trx/gsm0503_tables.c index c4a3dff26..0e3e0d052 100644 --- a/src/osmo-bts-trx/gsm0503_tables.c +++ b/src/osmo-bts-trx/gsm0503_tables.c @@ -115,25 +115,3 @@ const uint8_t gsm0503_gsm_fr_map[76] = { 3, 3, 3, 3 }; - -/* b(0..259) from d(0..259) according to (corrected) Table 2 of T 05.03 */ -const uint16_t gsm0503_d_to_b_index[260] = { - 5, 52,108,164,220, 4, 11, 16, 3, 10, 15, 21, 42, 98,154,210, - 51,107,163,219, 9, 25, 29, 41, 97,153,209, 40, 96,152,208, 39, - 95,151,207, 38, 94,150,206, 50,106,162,218, 2, 20, 32, 37, 93, - 149,205, 24, 28, 44,100,156,212, 36, 92,148,204, 46,102,158,214, - 1, 8, 14, 35, 19, 23, 31, 43, 99,155,211, 49,105,161,217, 55, - 58, 61, 64, 67, 70, 73, 76, 79, 82, 85, 88, 91,111,114,117,120, - 123,126,129,132,135,138,141,144,147,167,170,173,176,179,182,185, - 188,191,194,197,200,203,223,226,229,232,235,238,241,244,247,250, - 253,256,259, 45,101,157,213, 48,104,160,216, 54, 57, 60, 63, 66, - 69, 72, 75, 78, 81, 84, 87, 90,110,113,116,119,122,125,128,131, - 134,137,140,143,146,166,169,172,175,178,181,184,187,190,193,196, - 199,202,222,225,228,231,234,237,240,243,246,249,252,255,258, 0, - 7, 13, 27, 30, 34, 33, 12, 18, 17, 22, 47,103,159,215, 53, 56, - 59, 62, 65, 68, 71, 74, 77, 80, 83, 86, 89,109,112,115,118,121, - 124,127,130,133,136,139,142,145,165,168,171,174,177,180,183,186, - 189,192,195,198,201,221,224,227,230,233,236,239,242,245,248,251, - 254,257, 6, 26, -}; - diff --git a/src/osmo-bts-trx/gsm0503_tables.h b/src/osmo-bts-trx/gsm0503_tables.h index abeff2d79..827fded4b 100644 --- a/src/osmo-bts-trx/gsm0503_tables.h +++ b/src/osmo-bts-trx/gsm0503_tables.h @@ -9,6 +9,5 @@ extern const sbit_t gsm0503_usf2twelve_sbit[8][12]; extern const uint8_t gsm0503_puncture_cs2[588]; extern const uint8_t gsm0503_puncture_cs3[676]; extern const uint8_t gsm0503_gsm_fr_map[76]; -extern const uint16_t gsm0503_d_to_b_index[260]; #endif /* _0503_TABLES_H */ diff --git a/tests/bursts/Makefile.am b/tests/bursts/Makefile.am index c3c04067b..992bbb140 100644 --- a/tests/bursts/Makefile.am +++ b/tests/bursts/Makefile.am @@ -1,6 +1,6 @@ INCLUDES = $(all_includes) -I$(top_srcdir)/include -I$(OPENBSC_INCDIR) -AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) -LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) +AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOCODEC_CFLAGS) +LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOCODEC_LIBS) noinst_PROGRAMS = bursts_test EXTRA_DIST = bursts_test.ok