From b7dc02e8e17a36064bb8da285b57f80a313833c9 Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Wed, 27 Feb 2013 09:47:48 +0100 Subject: Set slot types for calypso BTS, handle filler table accordingly Scheduling of NB/AB/SB/FB depends on given slot type by transceiver application. --- include/l1ctl_proto.h | 1 + src/target/firmware/apps/trx/trx.c | 49 +++++++++++++++++++++---------- src/target/firmware/include/layer1/sync.h | 1 + src/target/firmware/layer1/l23_api.c | 8 ++++- src/target/firmware/layer1/prim_bts.c | 6 +++- src/target/firmware/layer1/trx_dummy.c | 5 ++++ 6 files changed, 52 insertions(+), 18 deletions(-) diff --git a/include/l1ctl_proto.h b/include/l1ctl_proto.h index 86aaa5f4..97b24db5 100644 --- a/include/l1ctl_proto.h +++ b/include/l1ctl_proto.h @@ -310,6 +310,7 @@ struct l1ctl_traffic_req { /* BTS mode: config */ struct l1ctl_bts_mode { uint8_t enabled; + uint8_t type[8]; uint8_t bsic; uint16_t band_arfcn; uint8_t gain; diff --git a/src/target/firmware/apps/trx/trx.c b/src/target/firmware/apps/trx/trx.c index d48fdbbf..8e5c89f7 100644 --- a/src/target/firmware/apps/trx/trx.c +++ b/src/target/firmware/apps/trx/trx.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "burst_queue.h" @@ -35,31 +36,43 @@ BURST_QUEUE_STATIC(g_bq, 8, 512, static) /* Filler table */ -static struct burst_data fill_tn0[51]; +static struct burst_data fill[8][52]; +static uint8_t fill_size[8]; /* TRX Helpers **************************************************************/ static void -trx_init_filler(void) +trx_init_filler(uint8_t tn, uint8_t type) { int i; - for (i=0; i<51; i++) { - if ((i % 51) == 50) - fill_tn0[i].type = BURST_DUMMY; - else if (((i % 51) % 10) == 0) - fill_tn0[i].type = BURST_FB; - else if (((i % 51) % 10) == 1) - fill_tn0[i].type = BURST_SB; - else - fill_tn0[i].type = BURST_DUMMY; + if ((type >> 1) == 2) { + for (i=0; i<51; i++) { + if ((i % 51) == 50) + fill[tn][i].type = BURST_DUMMY; + else if (((i % 51) % 10) == 0) + fill[tn][i].type = BURST_FB; + else if (((i % 51) % 10) == 1) + fill[tn][i].type = BURST_SB; + else + fill[tn][i].type = BURST_DUMMY; + } + fill_size[tn] = 51; + } else if ((type >> 1) == 3) { + for (i=0; i<51; i++) + fill[tn][i].type = BURST_DUMMY; + fill_size[tn] = 51; + } else { + for (i=0; i<52; i++) + fill[tn][i].type = BURST_DUMMY; + fill_size[tn] = 52; } } static void trx_discarded_burst(struct burst_data *burst, - int head, uint32_t fn, __unused void *data) + int head, uint32_t fn, uint8_t tn, __unused void *data) { /* Only TN=0 */ if (head) @@ -69,7 +82,7 @@ trx_discarded_burst(struct burst_data *burst, printf("STALE BURST %" PRIu32 "\n", fn); /* Still copy to the filler table */ - memcpy(&fill_tn0[fn % 51], burst, sizeof(struct burst_data)); + memcpy(&fill[tn][fn % fill_size[tn]], burst, sizeof(struct burst_data)); } @@ -78,12 +91,15 @@ trx_discarded_burst(struct burst_data *burst, void trx_init(void) { + int i; + /* Init burst queue */ bq_reset(&g_bq); bq_set_discard_fn(&g_bq, trx_discarded_burst, NULL); /* Init filler table */ - trx_init_filler(); + for (i = 0; i < 8; i++) + trx_init_filler(i, l1s.bts.type[i]); } int @@ -119,12 +135,13 @@ trx_get_burst(uint32_t fn, uint8_t tn, uint8_t *data) if (burst) { /* New burst: Copy to fill table & use it */ - memcpy(&fill_tn0[fn % 51], burst, sizeof(struct burst_data)); + memcpy(&fill[tn][fn % fill_size[tn]], burst, + sizeof(struct burst_data)); // printf("O %d %d %p\n", fn, g_bq.used, burst); } else { /* No data, just use the one from fill table */ - burst = &fill_tn0[fn % 51]; + burst = &fill[tn][fn % fill_size[tn]]; } rc = burst->type; diff --git a/src/target/firmware/include/layer1/sync.h b/src/target/firmware/include/layer1/sync.h index cfa7ae4d..79124cfc 100644 --- a/src/target/firmware/include/layer1/sync.h +++ b/src/target/firmware/include/layer1/sync.h @@ -157,6 +157,7 @@ struct l1s_state { /* bts mode */ struct { + uint8_t type[8]; uint16_t arfcn; uint8_t bsic; uint8_t gain; diff --git a/src/target/firmware/layer1/l23_api.c b/src/target/firmware/layer1/l23_api.c index 39062201..c6baaabf 100644 --- a/src/target/firmware/layer1/l23_api.c +++ b/src/target/firmware/layer1/l23_api.c @@ -603,12 +603,18 @@ static int l1ctl_bts_mode(struct msgb *msg) l1s.tx_power = ms_pwr_ctl_lvl(gsm_arfcn2band(l1s.bts.arfcn), 15); - printf("BTS MODE: %u %u\n", l1s.bts.bsic, l1s.bts.arfcn); + printf("BTS MODE: %u %u {%u}\n", l1s.bts.bsic, l1s.bts.arfcn, + bm->type[0]); l1a_mftask_set(0); if (bm->enabled) { + int i; + mframe_enable(MF_TASK_BTS_SYNC); mframe_enable(MF_TASK_BTS); + for (i = 0; i < 8; i++) + l1s.bts.type[i] = bm->type[i]; + trx_init(); l1s.bts.gain = bm->gain; } else { mframe_enable(MF_TASK_BCCH_NORM); diff --git a/src/target/firmware/layer1/prim_bts.c b/src/target/firmware/layer1/prim_bts.c index 92f455b0..d02fa068 100644 --- a/src/target/firmware/layer1/prim_bts.c +++ b/src/target/firmware/layer1/prim_bts.c @@ -251,7 +251,11 @@ l1s_bts_cmd(uint8_t p1, uint8_t p2, uint16_t p3) t3 = t3 - 1; /* Select which type of burst */ - if ((t3 >= 14) && (t3 <= 36)) + if ((l1s.bts.type[0] >> 1) != 2) + db->rx[0].cmd = DSP_EXT_RX_CMD_NB; + else if ((t3 >= 14) && (t3 <= 36)) + db->rx[0].cmd = DSP_EXT_RX_CMD_AB; + else if ((t3 == 4) || (t3 == 5)) db->rx[0].cmd = DSP_EXT_RX_CMD_AB; else if ((t3 == 45) || (t3 == 46)) db->rx[0].cmd = DSP_EXT_RX_CMD_AB; diff --git a/src/target/firmware/layer1/trx_dummy.c b/src/target/firmware/layer1/trx_dummy.c index 44ca4f17..b5ebc41b 100644 --- a/src/target/firmware/layer1/trx_dummy.c +++ b/src/target/firmware/layer1/trx_dummy.c @@ -40,3 +40,8 @@ trx_put_burst(uint32_t fn, uint8_t tn, uint8_t type, uint8_t *data) { return 0; } + +void +trx_init(void) +{ +} -- cgit v1.2.3