summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Schodet2013-03-25 14:52:19 +0100
committerNicolas Schodet2013-04-05 15:43:43 +0200
commit5c9dc5b72aa4d671332badf3c5c2ff10c8553dbf (patch)
tree0aea9b31bd8000b26b3a39475a155c00f0814e38
parent6b4a520839b4fecaa51c6448414b1911edc5cca6 (diff)
cesar/hal/phy: add amplitude map limits, refs #3911
-rw-r--r--cesar/hal/phy/inc/tonemask.h5
-rw-r--r--cesar/hal/phy/src/phy.c18
-rw-r--r--cesar/hal/phy/src/tonemask.c19
-rw-r--r--cesar/hal/phy/test/tonemask/src/test_tonemask.c35
4 files changed, 69 insertions, 8 deletions
diff --git a/cesar/hal/phy/inc/tonemask.h b/cesar/hal/phy/inc/tonemask.h
index f2af794019..1c6a37bc8e 100644
--- a/cesar/hal/phy/inc/tonemask.h
+++ b/cesar/hal/phy/inc/tonemask.h
@@ -23,9 +23,12 @@ BEGIN_DECLS
* \param tonemask tonemask data
* \param ampmap room to store amplitude map (same size as tonemap,
* PHY_TONEMAP_WORDS)
+ * \param first first carrier to enable, or 0
+ * \param last last carrier to enable or 0
*/
void
-phy_tonemask_to_ampmap (const u32 *tonemask, u32 *ampmap);
+phy_tonemask_to_ampmap (const u32 *tonemask, u32 *ampmap,
+ uint first, uint last);
/**
* Compute HP10 tonemask which corresponds to tonemask.
diff --git a/cesar/hal/phy/src/phy.c b/cesar/hal/phy/src/phy.c
index c2cc692ccf..8f0ed47e3c 100644
--- a/cesar/hal/phy/src/phy.c
+++ b/cesar/hal/phy/src/phy.c
@@ -131,6 +131,10 @@ struct phy_tunable_t
uint delta_res_coef_internal;
/** External delta accumulation coefficient. */
uint delta_res_coef_external;
+ /** First activated carrier in ampmap or 0. */
+ uint ampmap_first_carrier;
+ /** Last activated carrier in ampmap or 0. */
+ uint ampmap_last_carrier;
};
typedef struct phy_tunable_t phy_tunable_t;
@@ -165,6 +169,8 @@ static phy_tunable_t phy_tunable =
0,
PHY_PARAM_CHANNEL_ESTIM_COEF__COEF_RES_DELTA_INTERNAL,
PHY_PARAM_CHANNEL_ESTIM_COEF__COEF_RES_DELTA_EXTERNAL,
+ 0,
+ 0,
};
#if MODULE_INCLUDED (hal_clk)
@@ -563,6 +569,14 @@ phy_init_tunable_param (phy_t *ctx)
&phy_tunable.delta_res_coef_external,
LIB_STATS_ACCESS_WRITE_ONLY,
LIB_STATS_DEBUG);
+ lib_stats_set_stat_value_notype ("AMPMAP_FIRST_CARRIER",
+ &phy_tunable.ampmap_first_carrier,
+ LIB_STATS_ACCESS_WRITE_ONLY,
+ LIB_STATS_DEBUG);
+ lib_stats_set_stat_value_notype ("AMPMAP_LAST_CARRIER",
+ &phy_tunable.ampmap_last_carrier,
+ LIB_STATS_ACCESS_WRITE_ONLY,
+ LIB_STATS_DEBUG);
lib_stats_set_stat_value_notype ("CAP_MASK",
&ctx->cap_mask,
LIB_STATS_ACCESS_WRITE_ONLY,
@@ -904,7 +918,9 @@ phy_set_tonemask (phy_t *ctx, u32 *tonemask, uint carrier_nb)
/* Send amplitude map. */
static phy_tmdma_desc_t am0, am1;
static u32 ampmap[PHY_TONEMAP_WORDS];
- phy_tonemask_to_ampmap (tonemask, ampmap);
+ phy_tonemask_to_ampmap (tonemask, ampmap,
+ phy_tunable.ampmap_first_carrier,
+ phy_tunable.ampmap_last_carrier);
am0.next = ARCH_CPU_TO_DMA (&am1);
am0.data = ARCH_CPU_TO_DMA (ampmap);
am0.size_words = BLK_SIZE / 4;
diff --git a/cesar/hal/phy/src/tonemask.c b/cesar/hal/phy/src/tonemask.c
index 6f47d319f6..00ab0e297f 100644
--- a/cesar/hal/phy/src/tonemask.c
+++ b/cesar/hal/phy/src/tonemask.c
@@ -16,19 +16,28 @@
#include "hal/phy/inc/tonemask.h"
void
-phy_tonemask_to_ampmap (const u32 *tonemask, u32 *ampmap)
+phy_tonemask_to_ampmap (const u32 *tonemask, u32 *ampmap,
+ uint first, uint last)
{
- uint i, j;
+ uint i, j, index;
u32 tmw = 0, amw;
- for (i = 0; i < PHY_TONEMAP_WORDS; i++)
+ dbg_assert (first == 0
+ || (first >= PHY_CARRIER_OFFSET
+ && first < PHY_CARRIER_OFFSET + PHY_CARRIER_NB));
+ dbg_assert (last == 0
+ || (last >= PHY_CARRIER_OFFSET
+ && last < PHY_CARRIER_OFFSET + PHY_CARRIER_NB));
+ first = first ? first - PHY_CARRIER_OFFSET : 0;
+ last = last ? last - PHY_CARRIER_OFFSET : PHY_CARRIER_NB;
+ for (i = 0, index = 0; i < PHY_TONEMAP_WORDS; i++)
{
if (i % 4 == 0)
tmw = *tonemask++;
amw = 0;
- for (j = 0; j < 8; j++)
+ for (j = 0; j < 8; j++, index++)
{
amw >>= 4;
- if (tmw & 1)
+ if ((tmw & 1) || index < first || index > last)
amw |= 0xf0000000;
tmw >>= 1;
}
diff --git a/cesar/hal/phy/test/tonemask/src/test_tonemask.c b/cesar/hal/phy/test/tonemask/src/test_tonemask.c
index 65b7278f88..adc8114792 100644
--- a/cesar/hal/phy/test/tonemask/src/test_tonemask.c
+++ b/cesar/hal/phy/test/tonemask/src/test_tonemask.c
@@ -27,6 +27,8 @@ ampmap_test_suite (test_t t)
{
test_suite_begin (t, "ampmap");
test_case_begin (t, "basic");
+ test_tonemask_carrier_offset = 74;
+ test_tonemask_carrier_nb = PHY_TONEMASK_WORDS * 32;
test_begin (t, "pattern")
{
u32 tonemask[PHY_TONEMASK_WORDS];
@@ -35,7 +37,7 @@ ampmap_test_suite (test_t t)
memset (ampmap, 0x42, sizeof (ampmap));
tonemask[0] = 0xaa55f00f;
tonemask[PHY_TONEMASK_WORDS - 1] = 0xaa55f00f;
- phy_tonemask_to_ampmap (tonemask, ampmap);
+ phy_tonemask_to_ampmap (tonemask, ampmap, 0, 0);
test_fail_unless (ampmap[0] == 0x0000ffff);
test_fail_unless (ampmap[1] == 0xffff0000);
test_fail_unless (ampmap[2] == 0x0f0f0f0f);
@@ -45,6 +47,37 @@ ampmap_test_suite (test_t t)
test_fail_unless (ampmap[PHY_TONEMAP_WORDS - 2] == 0x0f0f0f0f);
test_fail_unless (ampmap[PHY_TONEMAP_WORDS - 1] == 0xf0f0f0f0);
} test_end;
+ test_begin (t, "limits")
+ {
+ u32 tonemask[PHY_TONEMASK_WORDS];
+ u32 ampmap[PHY_TONEMAP_WORDS];
+ memset (tonemask, 0, sizeof (tonemask));
+ memset (ampmap, 0x42, sizeof (ampmap));
+ tonemask[0] = 0xaa55f00f;
+ tonemask[1] = 0x00000000;
+ tonemask[PHY_TONEMASK_WORDS - 2] = 0x00000000;
+ tonemask[PHY_TONEMASK_WORDS - 1] = 0xaa55f00f;
+ phy_tonemask_to_ampmap (tonemask, ampmap,
+ PHY_CARRIER_OFFSET + 42,
+ PHY_CARRIER_OFFSET
+ + PHY_TONEMASK_WORDS * 32 - 42 - 1);
+ test_fail_unless (ampmap[0] == 0xffffffff);
+ test_fail_unless (ampmap[1] == 0xffffffff);
+ test_fail_unless (ampmap[2] == 0xffffffff);
+ test_fail_unless (ampmap[3] == 0xffffffff);
+ test_fail_unless (ampmap[4] == 0xffffffff);
+ test_fail_unless (ampmap[5] == 0x000000ff);
+ test_fail_unless (ampmap[6] == 0x00000000);
+ test_fail_unless (ampmap[7] == 0x00000000);
+ test_fail_unless (ampmap[PHY_TONEMAP_WORDS - 8] == 0x00000000);
+ test_fail_unless (ampmap[PHY_TONEMAP_WORDS - 7] == 0x00000000);
+ test_fail_unless (ampmap[PHY_TONEMAP_WORDS - 6] == 0xff000000);
+ test_fail_unless (ampmap[PHY_TONEMAP_WORDS - 5] == 0xffffffff);
+ test_fail_unless (ampmap[PHY_TONEMAP_WORDS - 4] == 0xffffffff);
+ test_fail_unless (ampmap[PHY_TONEMAP_WORDS - 3] == 0xffffffff);
+ test_fail_unless (ampmap[PHY_TONEMAP_WORDS - 2] == 0xffffffff);
+ test_fail_unless (ampmap[PHY_TONEMAP_WORDS - 1] == 0xffffffff);
+ } test_end;
}
void