summaryrefslogtreecommitdiff
path: root/cesar/ce
diff options
context:
space:
mode:
authordufour2009-09-17 12:54:24 +0000
committerdufour2009-09-17 12:54:24 +0000
commit721c8d7ed0d5ec3922aa2393a3cbbd05fd3fb690 (patch)
tree5aae790f98aac36ee4e972613a646793e9854c3e /cesar/ce
parent35487e616a9ca59fa4b777aa3eb27397611e60f8 (diff)
* mac/common, ce/tx:
- add new functions to handle intervals (append, clear and commit), - update CE/TX to use it, - update comments to better understand the intervals list management. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@5594 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/ce')
-rw-r--r--cesar/ce/tx/inc/mme.h4
-rw-r--r--cesar/ce/tx/src/mme.c91
2 files changed, 38 insertions, 57 deletions
diff --git a/cesar/ce/tx/inc/mme.h b/cesar/ce/tx/inc/mme.h
index 59a6a3f1c9..abe82e884e 100644
--- a/cesar/ce/tx/inc/mme.h
+++ b/cesar/ce/tx/inc/mme.h
@@ -113,12 +113,12 @@ ce_tx_mme_read_tmi_av_list (cp_t *ctx, bitstream_t *mme_bitstream,
* \param ctx Control Plane context.
* \param mme_bitstream bitstream of CE MME (CM_CHAN_EST.IND or
* CM_TM_UPDATE.IND).
- * \param interval_list intervals list.
+ * \param tms set of tone maps with the intervals lists inside.
* \return true if the interval list is valid, false otherwise.
*/
bool
ce_tx_mme_read_interval_list (cp_t *ctx, bitstream_t *mme_bitstream,
- tonemap_intervals_t *interval_list);
+ tonemaps_t *tms);
/**
* Get the Tone Map if there is one.
diff --git a/cesar/ce/tx/src/mme.c b/cesar/ce/tx/src/mme.c
index b1e1e7478e..439bf74758 100644
--- a/cesar/ce/tx/src/mme.c
+++ b/cesar/ce/tx/src/mme.c
@@ -18,6 +18,7 @@
#include "cp/mme.h"
#include "cp/msg/msg.h"
#include "mac/common/timings.h"
+#include "mac/common/interval.h"
#include "ce/common/mme.h"
#include "ce/common/mod.h"
@@ -62,29 +63,6 @@ ce_tx_check_tmi (u8 tmi_av)
return true;
}
-/**
- * Switch interval used for tone maps.
- * \param sta_tms the tone maps used by a STA.
- *
- * This function emulate an atomic switch.
- */
-static inline void
-ce_tx_set_new_interval_list (tonemaps_t *sta_tms)
-{
- /* Check parameters. */
- dbg_assert (sta_tms);
-
- /* Update intervals version before switching intervals. */
- sta_tms->intervals_temp->version = sta_tms->intervals->version + 1;
- /* Switch intervals list. */
- sta_tms->intervals = sta_tms->intervals_temp;
- /* Reset temporary intervals list. */
- if (sta_tms->intervals == &sta_tms->swap_intervals[0])
- sta_tms->intervals_temp = &sta_tms->swap_intervals[1];
- else
- sta_tms->intervals_temp = &sta_tms->swap_intervals[0];
-}
-
bool
ce_tx_mme_read_tmi (cp_t *ctx, bitstream_t *mme_bitstream, u8* tmi_av)
{
@@ -197,49 +175,51 @@ ce_tx_mme_read_tmi_av_list (cp_t *ctx, bitstream_t *mme_bitstream,
bool
ce_tx_mme_read_interval_list (cp_t *ctx, bitstream_t *mme_bitstream,
- tonemap_intervals_t *interval_list)
+ tonemaps_t *tms)
{
/* Check parameters. */
dbg_assert (ctx);
dbg_assert (mme_bitstream);
- dbg_assert (interval_list);
+ /* Not directly using tms. */
/* Get the number of intervals. */
- interval_list->intervals_nb = bitstream_read (mme_bitstream, 8);
- if (interval_list->intervals_nb > TONEMAP_INTERVAL_NB)
+ u8 int_count = bitstream_read (mme_bitstream, 8);
+ if (int_count > TONEMAP_INTERVAL_NB)
/* Error. */
return false;
+ if (int_count == 0)
+ return true;
+
+ /* Clear. */
+ mac_interval_clear (tms);
+
/* Compute the beacon period in Allocation Time Unit. */
uint beacon_period_length_atu
= MAC_TCK_TO_ATU (cp_pwl_get_beacon_period_ntb (ctx));
/* Read the list of intervals. */
- u8 index;
- for (index = 0; index < interval_list->intervals_nb; index++)
+ u8 index, last_index = 0;
+ u16 offset_atu = 0;
+ for (index = 0; index < int_count; index++)
{
- /* Read End Time of interval. */
- interval_list->interval[index].end_offset_atu
- = bitstream_read (mme_bitstream, 16);
- /* Interval should be in the beacon period (except for the last
- one). */
- if ((interval_list->interval[index].end_offset_atu
- >= beacon_period_length_atu
- && index != (interval_list->intervals_nb - 1))
- || (interval_list->interval[index].end_offset_atu
- < beacon_period_length_atu
- && index == (interval_list->intervals_nb - 1)))
- /* Error. */
- return false;
- /* Read TMI to use for this interval. */
- interval_list->interval[index].tmi
- = bitstream_read (mme_bitstream, 8);
- if (interval_list->interval[index].tmi >= 0x20
- && interval_list->interval[index].tmi <= 0xFD)
+ /* TODO:
+ * - handle case where at least two intervals are over beacon period.
+ * - handle case where TMI of intervals list does not exists.
+ */
+ offset_atu = bitstream_read (mme_bitstream, 16);
+ u8 tmi = bitstream_read (mme_bitstream, 8);
+ last_index = mac_interval_append (tms, offset_atu, tmi);
+ if (last_index == 0)
/* Error. */
return false;
}
- /* No error. */
- return true;
+ /* Check count is correct and last interval is over beacon period. */
+ if (last_index != int_count
+ || beacon_period_length_atu > offset_atu)
+ return false;
+ else
+ /* No error. */
+ return true;
}
bool
@@ -530,6 +510,7 @@ ce_tx_cm_chan_est_ind_receive (cp_t *ctx, cp_mme_rx_t *mme)
ce_tx_clean_tonemaps (sta_s_tx_tonemap);
/* Decode CM_CHAN_EST.IND MME. */
+
ce_cm_chan_est_ind_header header;
u32 tmi_av_list;
@@ -575,8 +556,8 @@ ce_tx_cm_chan_est_ind_receive (cp_t *ctx, cp_mme_rx_t *mme)
}
/* Get the interval list. */
- if (!ce_tx_mme_read_interval_list
- (ctx, &mme->bitstream, sta_s_tx_tonemap->intervals_temp))
+ if (!ce_tx_mme_read_interval_list (ctx, &mme->bitstream,
+ sta_s_tx_tonemap))
{
blk_release (sta_s);
/* Error while decoding MME. */
@@ -660,7 +641,7 @@ ce_tx_cm_chan_est_ind_receive (cp_t *ctx, cp_mme_rx_t *mme)
/* Reset bitmap field for sound complete. */
sta_s_tx_tonemap->tm_sound_complete_bitmap = 0;
/* Update intervals list. */
- ce_tx_set_new_interval_list (sta_s_tx_tonemap);
+ mac_interval_commit_changes (sta_s_tx_tonemap);
/* Update valid list of tone map interval by
* removing unused tone map. This must be done
* after switching tone map intervals. */
@@ -742,8 +723,8 @@ ce_tx_cm_tm_update_ind_receive (cp_t *ctx, cp_mme_rx_t *mme)
}
/* Get the interval list. */
- if (!ce_tx_mme_read_interval_list
- (ctx, &mme->bitstream, sta_s_tx_tonemap->intervals_temp))
+ if (!ce_tx_mme_read_interval_list (ctx, &mme->bitstream,
+ sta_s_tx_tonemap))
{
/* Error while decoding MME. */
blk_release (sta_s);
@@ -825,7 +806,7 @@ ce_tx_cm_tm_update_ind_receive (cp_t *ctx, cp_mme_rx_t *mme)
/* Reset bitmap field for sound complete. */
sta_s_tx_tonemap->tm_sound_complete_bitmap = 0;
/* Update intervals list. */
- ce_tx_set_new_interval_list (sta_s_tx_tonemap);
+ mac_interval_commit_changes (sta_s_tx_tonemap);
/* Update valid list of tone map interval by
* removing unused tone map. This must be done
* after switching tone map intervals. */