summaryrefslogtreecommitdiff
path: root/cesar/ce/rx
diff options
context:
space:
mode:
authordufour2009-07-21 13:06:45 +0000
committerdufour2009-07-21 13:06:45 +0000
commitcf2928f494e34c0d17a8cd6277a8927e695d358f (patch)
treeab52b1d62ac60db8dc98cdeca4f0aadacad9cd14 /cesar/ce/rx
parent727d165863d601043f48b0ed985b5006e17200fc (diff)
* ce/rx/bitloading:
- move, rename and fix the function to compute the mean of NSR. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@5046 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/ce/rx')
-rw-r--r--cesar/ce/rx/bitloading/Module2
-rw-r--r--cesar/ce/rx/bitloading/inc/bitloading.h53
-rw-r--r--cesar/ce/rx/bitloading/inc/nsr.h9
-rw-r--r--cesar/ce/rx/bitloading/src/bitloading.c60
-rw-r--r--cesar/ce/rx/bitloading/src/nsr.c28
5 files changed, 38 insertions, 114 deletions
diff --git a/cesar/ce/rx/bitloading/Module b/cesar/ce/rx/bitloading/Module
index 5049dfc398..3957cf1ebb 100644
--- a/cesar/ce/rx/bitloading/Module
+++ b/cesar/ce/rx/bitloading/Module
@@ -1 +1 @@
-SOURCES := initial.c bitloading.c nsr.c
+SOURCES := initial.c nsr.c
diff --git a/cesar/ce/rx/bitloading/inc/bitloading.h b/cesar/ce/rx/bitloading/inc/bitloading.h
deleted file mode 100644
index 6bfe89b1a0..0000000000
--- a/cesar/ce/rx/bitloading/inc/bitloading.h
+++ /dev/null
@@ -1,53 +0,0 @@
-#ifndef ce_rx_bitloading_inc_bitloading_h
-#define ce_rx_bitloading_inc_bitloading_h
-/* Cesar project {{{
- *
- * Copyright (C) 2009 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file ce/rx/bitloading/inc/bitloading.h
- * \brief Bit loading computing for the CE RX (private declaration part).
- * \ingroup ce_rx
- *
- * The bit loading is responsible to compute the tone maps.
- * They are two kinds of bit loading:
- * - initial or static: this is done on the initial channel estimation with
- * the sounds data emitted by the peer.
- * - dynamic: it creates new tone maps based on initial one.
- */
-
-#include "ce/rx/rx.h"
-#include "ce/rx/inc/measure.h"
-#include "hal/phy/pbdma.h"
-#include "mac/common/sta.h"
-
-/**
- * Number of intervals.
- * For the moment, this is a fixed number.
- */
-#define CE_RX_BITLOADING_INTERVAL_COUNT 2
-
-BEGIN_DECLS
-
-/**
- * Update the bit loading module.
- * \param ce_rx the CE RX context.
- * \param measure the measure to process.
- */
-void
-ce_rx_bitloading_update (ce_rx_t *ce_rx, ce_rx_measure_mbox_t *measure);
-
-/**
- * Generate initial tone map.
- * \param ce_rx the CE RX context.
- * \param sta the MAC store STA.
- */
-void
-ce_rx_bitloading_generate_initial (ce_rx_t *ce_rx, sta_t *sta);
-
-END_DECLS
-
-#endif /* ce_rx_bitloading_inc_bitloading_h */
diff --git a/cesar/ce/rx/bitloading/inc/nsr.h b/cesar/ce/rx/bitloading/inc/nsr.h
index 21941a286d..8b53b58a6f 100644
--- a/cesar/ce/rx/bitloading/inc/nsr.h
+++ b/cesar/ce/rx/bitloading/inc/nsr.h
@@ -89,6 +89,15 @@ void
ce_rx_bl_nsr_sum_add (ce_rx_bitloading_t *bl, phy_chandata_t *chan_data,
uint chan_data_count);
+/**
+ * Compute the mean of the NSR sum.
+ * \param bl the bit loading context of the station.
+ *
+ * This function compute the mean on the whole NSR sum.
+ */
+void
+ce_rx_bl_nsr_compute_mean (ce_rx_bitloading_t *bl);
+
END_DECLS
#endif /* ce_rx_bitloading_inc_nsr_h */
diff --git a/cesar/ce/rx/bitloading/src/bitloading.c b/cesar/ce/rx/bitloading/src/bitloading.c
deleted file mode 100644
index a33327b20a..0000000000
--- a/cesar/ce/rx/bitloading/src/bitloading.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2009 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file ce/rx/bitloading/src/bitloading.c
- * \brief Bit loading computing for the CE RX (private implementation part).
- * \ingroup ce_rx
- */
-#include "common/std.h"
-
-#include "lib/slab.h"
-#include "ce/rx/bitloading/inc/bitloading.h"
-#include "ce/rx/bitloading/inc/nsr.h"
-
-void
-ce_rx_bitloading_generate_initial (ce_rx_t *ce_rx, sta_t *sta)
-{
- /* Check parameters. */
- dbg_assert (ce_rx);
- dbg_assert (sta);
-
- /* Compute the mean. */
- /* To prevent too many divisions that can be long for the processor, we
- * replace them by a multiplication and a shift.
- * div = a / b <=> div = a * k / 2^m.
- * k = (1 << m) / mean_count; m = 29. */
- const u8 m = 29;
- const uint k = (1 << m) / sta->ce_rx_bt.mean_count;
-
- /* Go through the sum. */
- uint i;
- uint blk_count = 0;
- bool finished = false;
- blk_t *cur_blk = &sta->ce_rx_bt.noise_nrj;
- u32 *mean_noise_nrj;
- /* Go through each block of block of sum of noise NRJ. */
- while (!finished)
- {
- /* Get mean noise NRJ (the sum in fact). */
- mean_noise_nrj = (u32 *) cur_blk->data;
- /* Go through each entry of the current block. */
- for (i = 0; i < BLK_SIZE / CE_RX_BITLOADING_NOISE_NRJ_SIZE; i++)
- {
- /* Compute the initial mean. */
- mean_noise_nrj[i] = mean_noise_nrj[i] * (u64) k / (1 << m);
- }
- /* Next mean noise NRJ if we are not at the end. */
- if (++blk_count == sta->ce_rx_bt.noise_nrj_blk_count)
- finished = true;
- else
- cur_blk = cur_blk->next;
- }
- /* TODO:
- - compute BER vs SNR table, sort it, and use it to build the tone map.
- */
-}
diff --git a/cesar/ce/rx/bitloading/src/nsr.c b/cesar/ce/rx/bitloading/src/nsr.c
index 04a15cede0..57949ddd1d 100644
--- a/cesar/ce/rx/bitloading/src/nsr.c
+++ b/cesar/ce/rx/bitloading/src/nsr.c
@@ -145,3 +145,31 @@ ce_rx_bl_nsr_sum_add (ce_rx_bitloading_t *bl, phy_chandata_t *chan_data,
finished = true;
}
}
+
+void
+ce_rx_bl_nsr_compute_mean (ce_rx_bitloading_t *bl)
+{
+ /* Check parameter. */
+ dbg_assert (bl);
+
+ /* Go through each block of NSR sum. */
+ blk_t *blk = &bl->noise_nrj;
+ uint i;
+ for (i = 0; i < bl->noise_nrj_blk_count; i++)
+ {
+ /* Sanity check. */
+ dbg_assert (blk);
+ /* Get current NSR sum. */
+ u32 *cur_sum_nsr = (u32 *) blk->data;
+ uint j;
+ /* Go through each sum of NSR of this block. */
+ for (j = 0; j < BLK_SIZE / CE_RX_BITLOADING_NOISE_NRJ_SIZE; j++)
+ {
+ /* Compute mean. */
+ cur_sum_nsr[j] = ce_rx_bl_nsr_mean (cur_sum_nsr[j],
+ bl->mean_count);
+ }
+ /* Next block. */
+ blk = blk->next;
+ }
+}