fw/layer1: Add support for proper meas. report (and use in prim_tx_nb)
authorSylvain Munaut <tnt@246tNt.com>
Sun, 26 Sep 2010 20:00:16 +0000 (22:00 +0200)
committerSylvain Munaut <tnt@246tNt.com>
Tue, 28 Sep 2010 06:04:18 +0000 (08:04 +0200)
Rewritten based on an original patch by Andreas.Eversberg.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
src/target/firmware/include/layer1/prim.h
src/target/firmware/layer1/prim_rx_nb.c
src/target/firmware/layer1/prim_tx_nb.c
src/target/firmware/layer1/prim_utils.c

index 3d368ff..e9823de 100644 (file)
@@ -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);
index 3b647fa..6b5ce57 100644 (file)
@@ -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;
index cea0b9c..584996b 100644 (file)
@@ -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 */
index 4f77eba..5d6c71c 100644 (file)
@@ -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;
+       }
+}