summaryrefslogtreecommitdiff
path: root/cesar/ce/rx/bitloading/src/bitloading.c
diff options
context:
space:
mode:
authorJerome Jutteau2010-09-22 14:55:06 +0200
committerJerome Jutteau2010-10-05 16:30:25 +0200
commit08e2d39b46b24e5ce11b5290bfd88fb15c64f401 (patch)
treed791349ee2ce7de775c532267b5be9555d4f4f1a /cesar/ce/rx/bitloading/src/bitloading.c
parent0d4c44167f6ce1e7a9e2d7e0a1b67b93456328ca (diff)
cesar/ce/rx/bl: compute the number of shift in a optimisation table, refs #1881
Added function to count the number of shift to perform on the optimisation table. It depends of the action to perform (update +/-).
Diffstat (limited to 'cesar/ce/rx/bitloading/src/bitloading.c')
-rw-r--r--cesar/ce/rx/bitloading/src/bitloading.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/cesar/ce/rx/bitloading/src/bitloading.c b/cesar/ce/rx/bitloading/src/bitloading.c
index 18594da7c2..891b159b50 100644
--- a/cesar/ce/rx/bitloading/src/bitloading.c
+++ b/cesar/ce/rx/bitloading/src/bitloading.c
@@ -318,3 +318,61 @@ ce_rx_bl_compute_tone_map_iterative (const u64 bpt_initial[PHY_FEC_RATE_NB],
return tm[good];
}
+ce_rx_bl_tone_map_update_actions_t
+ce_rx_bl_tone_map_update_action (u64 ber_target,
+ u64 means[CE_RX_BL_BER_SLIDING_MEAN_NB])
+{
+ /* Default action. */
+ ce_rx_bl_tone_map_update_actions_t action = CE_RX_BL_TONE_MAP_UPDATE_NONE;
+
+ /* Fast mean above target ? */
+ if (means[CE_RX_BL_BER_SLIDING_MEAN_FAST] > ber_target)
+ action = CE_RX_BL_TONE_MAP_UPDATE_MINUS;
+ else
+ {
+ /* Computing middle zone where no action is performed. */
+ u64 middle_limit = ber_target
+ - (u64) (ber_target / CE_RX_BL_TONE_MAP_UPDATE_MIDDLE_PERCENTAGE);
+ /* Are we located inside this middle zone ? */
+ if (means[CE_RX_BL_BER_SLIDING_MEAN_FAST] < middle_limit
+ && means[CE_RX_BL_BER_SLIDING_MEAN_SLOW] < middle_limit)
+ action = CE_RX_BL_TONE_MAP_UPDATE_PLUS;
+ }
+ return action;
+}
+
+u16
+ce_rx_bl_tone_map_update_count (ce_rx_bl_tone_map_update_actions_t action,
+ u64 ber_target,
+ u64 means[CE_RX_BL_BER_SLIDING_MEAN_NB])
+{
+ dbg_assert (action < CE_RX_BL_TONE_MAP_UPDATE_NB);
+ dbg_assert (ber_target != 0);
+
+ s16 coeff;
+ s8 multi;
+
+ /* Adjust parameters depending on the action. */
+ if (action == CE_RX_BL_TONE_MAP_UPDATE_MINUS)
+ {
+ coeff = CE_RX_BL_TONE_MAP_UPDATE_MINUS_COEFF;
+ multi = 1;
+ }
+ else if (action == CE_RX_BL_TONE_MAP_UPDATE_PLUS)
+ {
+ coeff = CE_RX_BL_TONE_MAP_UPDATE_PLUS_COEFF;
+ multi = -1;
+ }
+ else
+ return 0;
+
+ /* Number of carriers we may shift in the optimisation table. */
+ u64 nb =
+ multi * ROUND_DIV (coeff *
+ MAX (means[CE_RX_BL_BER_SLIDING_MEAN_FAST],
+ means[CE_RX_BL_BER_SLIDING_MEAN_SLOW]),
+ ber_target) - (multi * coeff) + 1;
+
+ /* Return value must be <= PHY_CARRIER_NB (max shift value). */
+ return (nb > PHY_CARRIER_NB ? PHY_CARRIER_NB : nb);
+}