summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSylvain Munaut <tnt@246tNt.com>2010-09-26 22:00:16 +0200
committerSylvain Munaut <tnt@246tNt.com>2010-09-28 08:04:18 +0200
commitd227b37f1220a01e2e2b8b218a3754af225e7ef1 (patch)
treec58eefedaab421ffa275b09b180cd610b7d81f39
parent732f102cc2ffd52f9013bc770fcaf36c3d04ddf5 (diff)
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 <tnt@246tNt.com>
-rw-r--r--src/target/firmware/include/layer1/prim.h2
-rw-r--r--src/target/firmware/layer1/prim_rx_nb.c4
-rw-r--r--src/target/firmware/layer1/prim_tx_nb.c18
-rw-r--r--src/target/firmware/layer1/prim_utils.c32
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 3d368ff6..e9823ded 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 3b647fa6..6b5ce57f 100644
--- a/src/target/firmware/layer1/prim_rx_nb.c
+++ b/src/target/firmware/layer1/prim_rx_nb.c
@@ -46,6 +46,7 @@
#include <layer1/tpu_window.h>
#include <layer1/l23_api.h>
#include <layer1/rfch.h>
+#include <layer1/prim.h>
#include <l1ctl_proto.h>
@@ -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 cea0b9cb..584996b4 100644
--- a/src/target/firmware/layer1/prim_tx_nb.c
+++ b/src/target/firmware/layer1/prim_tx_nb.c
@@ -47,6 +47,7 @@
#include <layer1/tpu_window.h>
#include <layer1/l23_api.h>
#include <layer1/rfch.h>
+#include <layer1/prim.h>
#include <l1ctl_proto.h>
@@ -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 4f77eba8..5d6c71c7 100644
--- a/src/target/firmware/layer1/prim_utils.c
+++ b/src/target/firmware/layer1/prim_utils.c
@@ -22,6 +22,7 @@
#include <stdint.h>
+#include <osmocore/msgb.h>
#include <layer1/sync.h>
@@ -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;
+ }
+}