summaryrefslogtreecommitdiff
path: root/cesar/ce
diff options
context:
space:
mode:
authordufour2009-09-09 13:08:39 +0000
committerdufour2009-09-09 13:08:39 +0000
commite78630b0ec087538da9aa135963f8aedf6d5f96f (patch)
tree18a080d40abf8df40232aeda328694d4b9046a74 /cesar/ce
parentc98ef1e37d36238700752aba8c5dd92f9b8b4c16 (diff)
* ce/rx/cp:
- add macros to read two tone map at the same time. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@5469 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/ce')
-rw-r--r--cesar/ce/rx/cp/src/mme.c175
1 files changed, 109 insertions, 66 deletions
diff --git a/cesar/ce/rx/cp/src/mme.c b/cesar/ce/rx/cp/src/mme.c
index af3b14365f..21252c4dd1 100644
--- a/cesar/ce/rx/cp/src/mme.c
+++ b/cesar/ce/rx/cp/src/mme.c
@@ -23,6 +23,110 @@
#include "ce/rx/cp/inc/mme.h"
#include "ce/rx/cp/inc/cp.h"
+/**
+ * Macro to through each tone of two tone maps, using a mask and read two
+ * tones.
+ * \param tm1 the first tone map to read (tonemap_t).
+ * \param tm2 the second tone map to read (tonemap_t).
+ * \param tonemask the tone map to read (u32 *).
+ * \param tone1 the first tone read.
+ * \param tone2 the second tone read.
+ * This macro is divided in two macros. Here is an example of to use it.
+ * \code
+ * tonemap_t *tm_old;
+ * tonemap_t *tm_new;
+ * tonemask_info_t ti;
+ * uint t1, t2;
+ * CE_RX_CP_READ_BEGIN (tm_old, tm_new, ti.tonemask, t1, t2)
+ * {
+ * printf ("%d\n", tone);
+ * }
+ * CE_RX_CP_READ_END;
+ * \endcode
+ */
+#define CE_RX_CP_READ_BEGIN(tm1, tm2, tonemask, tone1, tone2) \
+do { \
+ /* Store tone map. */ \
+ tonemap_t *tonemap_[2]; \
+ tonemap_[0] = (tm1); \
+ tonemap_[1] = (tm2); \
+ /* Index in the tone map in term of tone words. */ \
+ uint tm_tone_word_index_; \
+ /* Maximum index in the tone map in term of tone words. \
+ * This will evolve during the loop (because the block will change). */ \
+ uint tm_tone_word_max_; \
+ /* Index by group of 8 tones. A mask is stored on 1 bit. Every 32 bits, \
+ * of tone masks, we have 32 tones. A tone is stored on 4 bits. On a \
+ * word of tone map, we have 8 tones. This index represents the current \
+ * words (of 8 tones) of the tone map by group of 4. */ \
+ uint tm_tone_group_by_word_mask_; \
+ /* Pointer to the current word of 4 tones of the tone map. */ \
+ u32 *tm_[2]; \
+ /* Pointer to the current word of 32 tones mask. */ \
+ u32 *tk_; \
+ \
+ /* Initialization. */ \
+ tm_[0] = (u32 *) tonemap_[0]->tmdma_desc_head->data; \
+ tm_[1] = (u32 *) tonemap_[1]->tmdma_desc_head->data; \
+ tk_ = (tonemask); \
+ \
+ /* This loop will go through each block. So basically, it will be run \
+ * only two times. */ \
+ for (tm_tone_word_index_ = 0, tm_tone_word_max_ = BLK_SIZE / 4; \
+ tm_tone_word_index_ < PHY_TONEMAP_WORDS; \
+ /* After the list loop is over, second loop must be called until no \
+ * more word remains. */ \
+ tm_tone_word_max_ = PHY_TONEMAP_WORDS) \
+ { \
+ /* Loop on the whole current block until we have read all the words \
+ of tone. */ \
+ for (; tm_tone_word_index_ < tm_tone_word_max_;) \
+ { \
+ /* Current 32 masks. */ \
+ u32 tk_cur_ = *tk_; \
+ /* This loop goes through each word of tone map by group of 4. \
+ */ \
+ for (tm_tone_group_by_word_mask_ = 0; \
+ tm_tone_group_by_word_mask_ < 4; \
+ /* Increase tm_tone_word_index_ too. */ \
+ tm_tone_group_by_word_mask_++, tm_tone_word_index_++) \
+ { \
+ /* Index of a tone in a word of tones. */ \
+ uint tm_tone_index_; \
+ /* The 8 tones of the word. */ \
+ u32 tm_tone_[2]; \
+ tm_tone_[0] = *tm_[0]; \
+ tm_tone_[1] = *tm_[1]; \
+ for (tm_tone_index_ = 8; \
+ tm_tone_index_ > 0; \
+ tm_tone_index_--) \
+ { \
+ if (!(tk_cur_ & 0x1)) \
+ { \
+ (tone1) = tm_tone_[0] & 0xF; \
+ (tone2) = tm_tone_[1] & 0xF;
+
+#define CE_RX_CP_READ_END \
+ } \
+ /* Next tone. */ \
+ tm_tone_[0] >>= 4; \
+ tm_tone_[1] >>= 4; \
+ /* Next tone mask bit. */ \
+ tk_cur_ >>= 1; \
+ } \
+ /* Next group of tone (grouped by word). */ \
+ tm_[0]++; \
+ tm_[1]++; \
+ } \
+ /* Next group of 32 masks. */ \
+ tk_++; \
+ } \
+ /* Get next block. */ \
+ tm_[0] = (u32 *) tonemap_[0]->tmdma_desc_head->next->data; \
+ tm_[1] = (u32 *) tonemap_[1]->tmdma_desc_head->next->data; \
+ } \
+} while (0)
+
u16
ce_rx_cp_mme_tone_map_size_with_rle (tonemap_t *tm, tonemask_info_t *tonemask)
{
@@ -70,75 +174,14 @@ ce_rx_cp_mme_tone_map_size_with_update (tonemap_t *old_tm, tonemap_t *new_tm,
dbg_assert (new_tm);
dbg_assert (tonemask);
u16 size = 0;
- uint i, j;
- u8 new_mod, old_mod;
- /* Current tone mask word. */
- u32 tonemask_word;
- const u32* tonemask_word_ptr = tonemask->tonemask;
- /* Access to tone maps. */
- bitstream_t bt_old_tm;
- bitstream_read_init (&bt_old_tm, old_tm->tmdma_desc_head->data,
- BLK_SIZE);
- /* Set-up the callback. */
- bitstream_init_buffer_cb (&bt_old_tm,
- ce_tonemap_buffer_exhausted,
- old_tm->tmdma_desc_head->next->data);
- bitstream_t bt_new_tm;
- bitstream_read_init (&bt_new_tm, new_tm->tmdma_desc_head->data,
- BLK_SIZE);
- /* Set-up the callback. */
- bitstream_init_buffer_cb (&bt_new_tm,
- ce_tonemap_buffer_exhausted,
- new_tm->tmdma_desc_head->next->data);
+ u8 mod1, mod2;
- /* Go through each group of 32 tones. */
- for (i = 0; i < PHY_CARRIER_NB / 32; i++)
- {
- /* Get current tone mask word. */
- tonemask_word = *(tonemask_word_ptr++);
- /* Go through each tone of this group of 32 tones. */
- for (j = 32; j; j--)
- {
- old_mod = bitstream_read (&bt_old_tm, 4);
- new_mod = bitstream_read (&bt_new_tm, 4);
- /* Get the mask for the tone of the current group of 32
- tones. */
- if ((tonemask_word & 0x1) == 0)
- {
- /* Same modulation? */
- if (old_mod != new_mod)
- {
- size += 16;
- }
- }
- /* Next tone in the current group of 32 tones. */
- tonemask_word >>= 1;
- }
- }
- /* A group of less than 32 tones? */
- if (PHY_CARRIER_NB % 32)
+ CE_RX_CP_READ_BEGIN (old_tm, new_tm, tonemask->tonemask, mod1, mod2)
{
- /* Get current tone mask word. */
- tonemask_word = *(tonemask_word_ptr++);
- /* Go through each tone of this group of 32 tones. */
- for (j = PHY_CARRIER_NB % 32; j; j--)
- {
- old_mod = bitstream_read (&bt_old_tm, 4);
- new_mod = bitstream_read (&bt_new_tm, 4);
- /* Get the mask for the tone of the current group of 32
- tones. */
- if ((tonemask_word & 0x1) == 0)
- {
- /* Same modulation? */
- if (old_mod != new_mod)
- {
- size += 16;
- }
- }
- /* Next tone in the current group of 32 tones. */
- tonemask_word >>= 1;
- }
+ if (mod1 != mod2)
+ size += 16;
}
+ CE_RX_CP_READ_END;
/* Return computed size. */
return size;