From d227b37f1220a01e2e2b8b218a3754af225e7ef1 Mon Sep 17 00:00:00 2001 From: Sylvain Munaut Date: Sun, 26 Sep 2010 22:00:16 +0200 Subject: [PATCH] fw/layer1: Add support for proper meas. report (and use in prim_tx_nb) Rewritten based on an original patch by Andreas.Eversberg. Signed-off-by: Sylvain Munaut --- src/target/firmware/include/layer1/prim.h | 2 ++ src/target/firmware/layer1/prim_rx_nb.c | 4 +++ src/target/firmware/layer1/prim_tx_nb.c | 18 ++++--------- src/target/firmware/layer1/prim_utils.c | 32 +++++++++++++++++++++++ 4 files changed, 43 insertions(+), 13 deletions(-) diff --git a/src/target/firmware/include/layer1/prim.h b/src/target/firmware/include/layer1/prim.h index 3d368ff..e9823de 100644 --- a/src/target/firmware/include/layer1/prim.h +++ b/src/target/firmware/include/layer1/prim.h @@ -9,6 +9,8 @@ struct l1ctl_fbsb_req; /* Utils */ const uint8_t *pu_get_idle_frame(void); +void pu_update_rx_level(uint8_t rx_level); +const uint8_t *pu_get_meas_frame(void); /* Primitives tests/requests */ void l1s_fb_test(uint8_t base_fn, uint8_t fb_mode); diff --git a/src/target/firmware/layer1/prim_rx_nb.c b/src/target/firmware/layer1/prim_rx_nb.c index 3b647fa..6b5ce57 100644 --- a/src/target/firmware/layer1/prim_rx_nb.c +++ b/src/target/firmware/layer1/prim_rx_nb.c @@ -46,6 +46,7 @@ #include #include #include +#include #include @@ -142,6 +143,9 @@ static int l1s_nb_resp(__unused uint8_t p1, uint8_t burst_id, uint16_t p3) rxnb.dl->fire_crc = ((dsp_api.ndb->a_cd[0] & 0xffff) & ((1 << B_FIRE1) | (1 << B_FIRE0))) >> B_FIRE0; + /* update rx level for pm report */ + pu_update_rx_level(rxnb.dl->rx_level); + /* copy actual data, skipping the information block [0,1,2] */ for (j = 0,i = 3; i < 15; i++) { rxnb.di->data[j++] = dsp_api.ndb->a_cd[i] & 0xFF; diff --git a/src/target/firmware/layer1/prim_tx_nb.c b/src/target/firmware/layer1/prim_tx_nb.c index cea0b9c..584996b 100644 --- a/src/target/firmware/layer1/prim_tx_nb.c +++ b/src/target/firmware/layer1/prim_tx_nb.c @@ -47,6 +47,7 @@ #include #include #include +#include #include @@ -82,7 +83,6 @@ static int l1s_tx_cmd(uint8_t p1, uint8_t burst_id, uint16_t p3) /* before sending first of the four bursts, copy data to API ram */ if (burst_id == 0) { uint16_t *info_ptr = dsp_api.ndb->a_cu; - struct llist_head *tx_queue; struct msgb *msg; const uint8_t *data; int i; @@ -91,20 +91,12 @@ static int l1s_tx_cmd(uint8_t p1, uint8_t burst_id, uint16_t p3) /* distinguish between DCCH and ACCH */ if (mf_task_flags & MF_F_SACCH) { puts("SACCH queue "); - tx_queue = &l1s.tx_queue[L1S_CHAN_SACCH]; + msg = msgb_dequeue(&l1s.tx_queue[L1S_CHAN_SACCH]); + data = msg ? msg->l3h : pu_get_meas_frame(); } else { puts("SDCCH queue "); - tx_queue = &l1s.tx_queue[L1S_CHAN_MAIN]; - } - msg = msgb_dequeue(tx_queue); - - /* If the TX queue is empty, send idle pattern */ - if (!msg) { - puts("TX idle pattern\n"); - data = pu_get_idle_frame(); - } else { - puts("TX uplink msg\n"); - data = msg->l3h; + msg = msgb_dequeue(&l1s.tx_queue[L1S_CHAN_MAIN]); + data = msg ? msg->l3h : pu_get_idle_frame(); } /* Fill data block Header */ diff --git a/src/target/firmware/layer1/prim_utils.c b/src/target/firmware/layer1/prim_utils.c index 4f77eba..5d6c71c 100644 --- a/src/target/firmware/layer1/prim_utils.c +++ b/src/target/firmware/layer1/prim_utils.c @@ -22,6 +22,7 @@ #include +#include #include @@ -35,8 +36,39 @@ static const uint8_t ubUui[23] = { 0x2b, 0x2b, 0x2b, 0x2b }; +static uint8_t ubMeas[23] = { + /* L1 SAACH pseudo-header */ + 0x0f, 0x00, + + /* lapdm header */ + 0x01, 0x03, 0x49, + + /* Measurement report */ + 0x06, 0x15, 0x36, 0x36, 0x01, 0xC0, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00 +}; + const uint8_t *pu_get_idle_frame(void) { return ubUui; } + +void pu_update_rx_level(uint8_t rx_level) +{ + ubMeas[7] = ubMeas[8] = rx_level; +} + +const uint8_t *pu_get_meas_frame(void) +{ + if (l1s.tx_meas) { + return l1s.tx_meas->l3h; + } else { + /* Update L1 SAACH pseudo-header */ + ubMeas[0] = l1s.tx_power; + ubMeas[1] = l1s.ta; + + return ubMeas; + } +} -- 2.20.1