layer1: remove 'l1s_cb' and l1_signal mechanism
authorHarald Welte <laforge@gnumonks.org>
Fri, 7 May 2010 14:56:09 +0000 (16:56 +0200)
committerHarald Welte <laforge@gnumonks.org>
Mon, 17 May 2010 07:23:35 +0000 (09:23 +0200)
the l1s signal was an old mechanism between l1test and the layer1
before we introduced the L1CTL protocol.  This commit removes all
leftover references to it.

It also disables the l1test app, as it would no longer work without
major modifications (using l1ctl from within the phone).

src/target/firmware/Makefile
src/target/firmware/apps/layer1/main.c
src/target/firmware/include/layer1/sync.h
src/target/firmware/layer1/prim_pm.c
src/target/firmware/layer1/prim_rx_nb.c
src/target/firmware/layer1/sync.c

index 7c6ba7a..43aca7c 100644 (file)
@@ -23,7 +23,7 @@ ramload_LDS=board/common/compal_ramload.lds
 osmoload_LDS=board/common/compal_osmoload.lds
 
 # List of all applications (add yours here!)
-APPLICATIONS=hello_world l1test compal_dump compal_dsp_dump layer1 loader
+APPLICATIONS=hello_world compal_dump compal_dsp_dump layer1 loader
 
 # Things that go in all applications
 ANY_APP_OBJS+=$(START:.S=.o) $(ABB_OBJS) $(RF_OBJS) $(DISPLAY_OBJS) $(FLASH_OBJS)
index 7281d17..bc968b4 100644 (file)
@@ -64,17 +64,6 @@ const char *hr = "==============================================================
 
 /* MAIN program **************************************************************/
 
-/* completion call-back for the L1 Sync Pwer Measurement */
-static void l1s_signal_cb(struct l1_signal *sig)
-{
-       switch (sig->signum) {
-       case L1_SIG_PM:
-               break;
-       case L1_SIG_NB:
-               break;
-       }
-}
-
 static void key_handler(enum key_codes code, enum key_states state);
 
 int main(void)
@@ -97,7 +86,6 @@ int main(void)
        display_puts("layer1.bin");
 
        layer1_init();
-       l1s_set_handler(&l1s_signal_cb);
 
        tpu_frame_irq_en(1, 1);
 
index fc8b777..4b2de31 100644 (file)
@@ -95,11 +95,6 @@ struct l1s_state {
 
 extern struct l1s_state l1s;
 
-enum l1_sig_num {
-       L1_SIG_PM,      /* Power Measurement */
-       L1_SIG_NB,      /* Normal Burst */
-};
-
 struct l1s_meas_hdr {
        uint16_t snr;           /* signal/noise ratio */
        int16_t toa_qbit;       /* time of arrival (qbits) */
@@ -107,27 +102,6 @@ struct l1s_meas_hdr {
        int16_t freq_err;       /* Frequency error in Hz */
 };
 
-struct l1_signal {
-       uint16_t signum;
-       uint16_t arfcn;
-       union {
-               struct {
-                       int16_t dbm8[2];
-               } pm;
-               struct {
-                       struct l1s_meas_hdr meas[4];
-                       uint16_t crc;
-                       uint16_t fire;
-                       uint16_t num_biterr;
-                       uint8_t frame[24];
-               } nb;
-       };
-};
-
-typedef void (*l1s_cb_t)(struct l1_signal *sig);
-
-void l1s_set_handler(l1s_cb_t handler);
-
 int16_t l1s_snr_int(uint16_t snr);
 uint16_t l1s_snr_fract(uint16_t snr);
 
@@ -162,8 +136,6 @@ void layer1_init(void);
 #define ANG2FREQ_SCALING       (2<<15) /* 2^15 scaling factor for fx1.15 */
 #define ANGLE_TO_FREQ(angle)   ((int16_t)angle * BITFREQ_DIV_PI / ANG2FREQ_SCALING)
 
-extern l1s_cb_t l1s_cb;
-
 void l1s_reset_hw(void);
 void synchronize_tdma(struct l1_cell_info *cinfo);
 void l1s_time_inc(struct gsm_time *time, uint32_t delta_fn);
index 85fc8d1..8d05ad9 100644 (file)
@@ -80,7 +80,6 @@ static int l1s_pm_resp(__unused uint8_t p1, __unused uint8_t p2,
 {
        struct l1ctl_pm_resp *pmr;
        uint16_t pm_level[2];
-       struct l1_signal sig;
 
        putchart('p');
 
@@ -90,12 +89,6 @@ static int l1s_pm_resp(__unused uint8_t p1, __unused uint8_t p2,
                agc_inp_dbm8_by_pm(pm_level[0])/8,
                agc_inp_dbm8_by_pm(pm_level[1])/8, arfcn);
 
-       /* build and deliver signal */
-       sig.signum = L1_SIG_PM;
-       sig.arfcn = arfcn;
-       sig.pm.dbm8[0] = agc_inp_dbm8_by_pm(pm_level[0]);
-       sig.pm.dbm8[1] = agc_inp_dbm8_by_pm(pm_level[1]);
-
        if (!l1s.pm.msg)
                l1s.pm.msg = l1ctl_msgb_alloc(L1CTL_PM_RESP);
 
index bd29974..3f909b7 100644 (file)
 
 #include <l1a_l23_interface.h>
 
+struct l1s_rxnb_state {
+       struct l1s_meas_hdr meas[4];
+       uint16_t crc;
+       uint16_t fire;
+       uint16_t num_biterr;
+       uint8_t frame[24]
+};
+
+static struct l1s_rxnb_state rxnb;
 
 static int l1s_nb_resp(__unused uint8_t p1, uint8_t burst_id, uint16_t p3)
 {
-       static struct l1_signal _nb_sig, *sig = &_nb_sig;
        uint8_t mf_task_id = p3 & 0xff;
        uint8_t mf_task_flags = p3 >> 8;
        struct msgb *msg;
@@ -71,17 +79,17 @@ static int l1s_nb_resp(__unused uint8_t p1, uint8_t burst_id, uint16_t p3)
                return 0;
        }
 
-       sig->nb.meas[burst_id].toa_qbit = dsp_api.db_r->a_serv_demod[D_TOA];
-       sig->nb.meas[burst_id].pm_dbm8 = dsp_api.db_r->a_serv_demod[D_PM] >> 3;
-       sig->nb.meas[burst_id].freq_err =
+       rxnb.meas[burst_id].toa_qbit = dsp_api.db_r->a_serv_demod[D_TOA];
+       rxnb.meas[burst_id].pm_dbm8 = dsp_api.db_r->a_serv_demod[D_PM] >> 3;
+       rxnb.meas[burst_id].freq_err =
                        ANGLE_TO_FREQ(dsp_api.db_r->a_serv_demod[D_ANGLE]);
-       sig->nb.meas[burst_id].snr = dsp_api.db_r->a_serv_demod[D_SNR];
+       rxnb.meas[burst_id].snr = dsp_api.db_r->a_serv_demod[D_SNR];
 
        /* feed computed frequency error into AFC loop */
-       if (sig->nb.meas[burst_id].snr > AFC_SNR_THRESHOLD)
-               afc_input(sig->nb.meas[burst_id].freq_err, rf_arfcn, 1);
+       if (rxnb.meas[burst_id].snr > AFC_SNR_THRESHOLD)
+               afc_input(rxnb.meas[burst_id].freq_err, rf_arfcn, 1);
        else
-               afc_input(sig->nb.meas[burst_id].freq_err, rf_arfcn, 0);
+               afc_input(rxnb.meas[burst_id].freq_err, rf_arfcn, 0);
 
        /* 4th burst, get frame data */
        if (dsp_api.db_r->d_burst_d == 3) {
@@ -92,21 +100,16 @@ static int l1s_nb_resp(__unused uint8_t p1, uint8_t burst_id, uint16_t p3)
                int32_t avg_dbm8 = 0;
                uint8_t i, j;
 
-               sig->signum = L1_SIG_NB;
-               sig->nb.num_biterr = dsp_api.ndb->a_cd[2] & 0xffff;
-               sig->nb.crc = ((dsp_api.ndb->a_cd[0] & 0xffff) & ((1 << B_FIRE1) | (1 << B_FIRE0))) >> B_FIRE0;
-               sig->nb.fire = ((dsp_api.ndb->a_cd[0] & 0xffff) & (1 << B_FIRE1)) >> B_FIRE1;
+               rxnb.num_biterr = dsp_api.ndb->a_cd[2] & 0xffff;
+               rxnb.crc = ((dsp_api.ndb->a_cd[0] & 0xffff) & ((1 << B_FIRE1) | (1 << B_FIRE0))) >> B_FIRE0;
+               rxnb.fire = ((dsp_api.ndb->a_cd[0] & 0xffff) & (1 << B_FIRE1)) >> B_FIRE1;
 
                /* copy actual data, skipping the information block [0,1,2] */
                for (j = 0,i = 3; i < 15; i++) {
-                       sig->nb.frame[j++] = dsp_api.ndb->a_cd[i] & 0xFF;
-                       sig->nb.frame[j++] = (dsp_api.ndb->a_cd[i] >> 8) & 0xFF;
+                       rxnb.frame[j++] = dsp_api.ndb->a_cd[i] & 0xFF;
+                       rxnb.frame[j++] = (dsp_api.ndb->a_cd[i] >> 8) & 0xFF;
                }
 
-               /* actually issue the signal */
-               if (l1s_cb)
-                       l1s_cb(sig);
-
                /* place it in the queue for the layer2 */
                msg = l1_create_l2_msg(L1CTL_DATA_IND, l1s.current_time.fn-4,
                                        0, rf_arfcn);
@@ -125,15 +128,15 @@ static int l1s_nb_resp(__unused uint8_t p1, uint8_t burst_id, uint16_t p3)
 
                /* compute average snr and rx level */
                for (i = 0; i < 4; ++i) {
-                       avg_snr += sig->nb.meas[i].snr;
-                       avg_dbm8 += sig->nb.meas[i].pm_dbm8;
+                       avg_snr += rxnb.meas[i].snr;
+                       avg_dbm8 += rxnb.meas[i].pm_dbm8;
                }
                dl->snr = avg_snr / 4;
                dl->rx_level = (avg_dbm8 / (8*4)) + 110;
 
                /* copy the actual payload data */
                for (i = 0; i < 23; ++i)
-                       di->data[i] = sig->nb.frame[i];
+                       di->data[i] = rxnb.frame[i];
                l1_queue_for_l2(msg);
 
                /* clear downlink task */
index 9ca37ef..fe47cd0 100644 (file)
 
 struct l1s_state l1s;
 
-l1s_cb_t l1s_cb = NULL;
-
-void l1s_set_handler(l1s_cb_t cb)
-{
-       l1s_cb = cb;
-}
-
 void l1s_time_inc(struct gsm_time *time, uint32_t delta_fn)
 {
        ADD_MODULO(time->fn, delta_fn, GSM_MAX_FN);