aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2013-02-14 12:22:42 +0100
committerHarald Welte <laforge@gnumonks.org>2015-09-22 16:41:26 +0200
commitb9880bc81289fa13b12801abcfc77fe6e83b8a94 (patch)
tree63fed901ddd797879725593a6f2531d1540e1b07
parentd10eaee4cce04aee4907b87e5bd73b9d866061b7 (diff)
TRX: Allow transcoding of TCH FR with MSB first (RTP) or LSB first (E1)
-rw-r--r--src/osmo-bts-trx/scheduler.c7
-rw-r--r--src/osmo-bts-trx/tch_fr.c18
-rw-r--r--src/osmo-bts-trx/tch_fr.h5
-rw-r--r--tests/bursts/bursts_test.c4
4 files changed, 21 insertions, 13 deletions
diff --git a/src/osmo-bts-trx/scheduler.c b/src/osmo-bts-trx/scheduler.c
index d5c7bb5..f65a702 100644
--- a/src/osmo-bts-trx/scheduler.c
+++ b/src/osmo-bts-trx/scheduler.c
@@ -759,9 +759,10 @@ static const ubit_t *tx_tchf_fn(struct trx_l1h *l1h, uint8_t tn, uint32_t fn,
/* encode bursts (priorize FACCH) */
if (msg_facch)
- tch_fr_encode(*bursts_p, msg_facch->l2h, msgb_l2len(msg_facch));
+ tch_fr_encode(*bursts_p, msg_facch->l2h, msgb_l2len(msg_facch),
+ 1);
else
- tch_fr_encode(*bursts_p, msg_tch->l2h, msgb_l2len(msg_tch));
+ tch_fr_encode(*bursts_p, msg_tch->l2h, msgb_l2len(msg_tch), 1);
/* unlink and free message */
if (msg_tch)
@@ -1079,7 +1080,7 @@ static int rx_tchf_fn(struct trx_l1h *l1h, uint8_t tn, uint32_t fn,
/* decode
* also shift buffer by 4 bursts for interleaving */
- rc = tch_fr_decode(tch_data, *bursts_p);
+ rc = tch_fr_decode(tch_data, *bursts_p, 1);
memcpy(*bursts_p, *bursts_p + 464, 464);
if (rc < 0) {
LOGP(DL1C, LOGL_NOTICE, "Received bad TCH frame at fn=%u "
diff --git a/src/osmo-bts-trx/tch_fr.c b/src/osmo-bts-trx/tch_fr.c
index 16fc854..23130e9 100644
--- a/src/osmo-bts-trx/tch_fr.c
+++ b/src/osmo-bts-trx/tch_fr.c
@@ -274,7 +274,7 @@ tch_fr_reorder(ubit_t *u, ubit_t *d, ubit_t *p)
}
int
-tch_fr_decode(uint8_t *tch_data, sbit_t *bursts)
+tch_fr_decode(uint8_t *tch_data, sbit_t *bursts, int network_order)
{
sbit_t iB[912], cB[456], h;
ubit_t conv[185], b[260], d[260], p[3];
@@ -300,9 +300,12 @@ tch_fr_decode(uint8_t *tch_data, sbit_t *bursts)
if (rv)
return -1;
- tch_fr_d_to_b(b, d);
+ if (network_order) {
+ tch_fr_d_to_b(b, d);
- tch_fr_reassemble(tch_data, b);
+ tch_fr_reassemble(tch_data, b);
+ } else
+ tch_fr_d_to_b(tch_data, d);
len = 33;
} else {
@@ -317,7 +320,7 @@ tch_fr_decode(uint8_t *tch_data, sbit_t *bursts)
}
int
-tch_fr_encode(ubit_t *bursts, uint8_t *tch_data, int len)
+tch_fr_encode(ubit_t *bursts, uint8_t *tch_data, int len, int network_order)
{
ubit_t iB[912], cB[456], h;
ubit_t conv[185], b[260], d[260], p[3];
@@ -325,9 +328,12 @@ tch_fr_encode(ubit_t *bursts, uint8_t *tch_data, int len)
switch (len) {
case 33: /* TCH FR */
- tch_fr_disassemble(b, tch_data);
+ if (network_order) {
+ tch_fr_disassemble(b, tch_data);
- tch_fr_b_to_d(d, b);
+ tch_fr_b_to_d(d, b);
+ } else
+ tch_fr_b_to_d(d, tch_data);
osmo_crc8gen_set_bits(&tch_fr_crc3, d, 50, p);
diff --git a/src/osmo-bts-trx/tch_fr.h b/src/osmo-bts-trx/tch_fr.h
index 68a9318..0141457 100644
--- a/src/osmo-bts-trx/tch_fr.h
+++ b/src/osmo-bts-trx/tch_fr.h
@@ -1,7 +1,8 @@
#ifndef _TCH_FR_H
#define _TCH_FR_H
-int tch_fr_decode(uint8_t *tch_data, sbit_t *bursts);
-int tch_fr_encode(ubit_t *bursts, uint8_t *tch_data, int len);
+int tch_fr_decode(uint8_t *tch_data, sbit_t *bursts, int network_order);
+int tch_fr_encode(ubit_t *bursts, uint8_t *tch_data, int len,
+ int network_order);
#endif /* _TCH_FR_H */
diff --git a/tests/bursts/bursts_test.c b/tests/bursts/bursts_test.c
index 9e64e3f..9fc7df0 100644
--- a/tests/bursts/bursts_test.c
+++ b/tests/bursts/bursts_test.c
@@ -191,7 +191,7 @@ static void test_fr(uint8_t *speech, int len)
printd("Encoding: %s\n", osmo_hexdump(speech, len));
/* encode */
- tch_fr_encode(bursts_u, speech, len);
+ tch_fr_encode(bursts_u, speech, len, 1);
printd("U-Bits:\n");
printd("%s %02x %02x ", osmo_hexdump(bursts_u, 57),
@@ -246,7 +246,7 @@ static void test_fr(uint8_t *speech, int len)
printd("%s\n", osmo_hexdump((uint8_t *)bursts_s + 59 + 812, 57));
/* decode */
- rc = tch_fr_decode(result, bursts_s);
+ rc = tch_fr_decode(result, bursts_s, 1);
ASSERT_TRUE(rc == len);