Commit 9301ca90 authored by Felix Fietkau's avatar Felix Fietkau Committed by John W. Linville

ath9k_hw: set ANI firstep as absolute values instead of relative

On older chips, the INI value differ in similar ways as cycpwr_thr1, so
convert it to absolute values as well.

Since the ANI algorithm is different here compared to the old
implementation (fewer steps, controlled at a different point in time),
it makes sense to use values similar to what would be applied for newer
chips, just without relying on INI defaults.
Signed-off-by: default avatarFelix Fietkau <nbd@openwrt.org>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 28327fd0
...@@ -917,7 +917,7 @@ static bool ar5008_hw_ani_control_new(struct ath_hw *ah, ...@@ -917,7 +917,7 @@ static bool ar5008_hw_ani_control_new(struct ath_hw *ah,
struct ath_common *common = ath9k_hw_common(ah); struct ath_common *common = ath9k_hw_common(ah);
struct ath9k_channel *chan = ah->curchan; struct ath9k_channel *chan = ah->curchan;
struct ar5416AniState *aniState = &ah->ani; struct ar5416AniState *aniState = &ah->ani;
s32 value, value2; s32 value;
switch (cmd & ah->ani_function) { switch (cmd & ah->ani_function) {
case ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION:{ case ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION:{
...@@ -1004,42 +1004,11 @@ static bool ar5008_hw_ani_control_new(struct ath_hw *ah, ...@@ -1004,42 +1004,11 @@ static bool ar5008_hw_ani_control_new(struct ath_hw *ah,
case ATH9K_ANI_FIRSTEP_LEVEL:{ case ATH9K_ANI_FIRSTEP_LEVEL:{
u32 level = param; u32 level = param;
if (level >= ARRAY_SIZE(firstep_table)) { value = level * 2;
ath_dbg(common, ANI,
"ATH9K_ANI_FIRSTEP_LEVEL: level out of range (%u > %zu)\n",
level, ARRAY_SIZE(firstep_table));
return false;
}
/*
* make register setting relative to default
* from INI file & cap value
*/
value = firstep_table[level] -
firstep_table[ATH9K_ANI_FIRSTEP_LVL] +
aniState->iniDef.firstep;
if (value < ATH9K_SIG_FIRSTEP_SETTING_MIN)
value = ATH9K_SIG_FIRSTEP_SETTING_MIN;
if (value > ATH9K_SIG_FIRSTEP_SETTING_MAX)
value = ATH9K_SIG_FIRSTEP_SETTING_MAX;
REG_RMW_FIELD(ah, AR_PHY_FIND_SIG, REG_RMW_FIELD(ah, AR_PHY_FIND_SIG,
AR_PHY_FIND_SIG_FIRSTEP, AR_PHY_FIND_SIG_FIRSTEP, value);
value);
/*
* we need to set first step low register too
* make register setting relative to default
* from INI file & cap value
*/
value2 = firstep_table[level] -
firstep_table[ATH9K_ANI_FIRSTEP_LVL] +
aniState->iniDef.firstepLow;
if (value2 < ATH9K_SIG_FIRSTEP_SETTING_MIN)
value2 = ATH9K_SIG_FIRSTEP_SETTING_MIN;
if (value2 > ATH9K_SIG_FIRSTEP_SETTING_MAX)
value2 = ATH9K_SIG_FIRSTEP_SETTING_MAX;
REG_RMW_FIELD(ah, AR_PHY_FIND_SIG_LOW, REG_RMW_FIELD(ah, AR_PHY_FIND_SIG_LOW,
AR_PHY_FIND_SIG_FIRSTEP_LOW, value2); AR_PHY_FIND_SIG_FIRSTEP_LOW, value);
if (level != aniState->firstepLevel) { if (level != aniState->firstepLevel) {
ath_dbg(common, ANI, ath_dbg(common, ANI,
...@@ -1056,7 +1025,7 @@ static bool ar5008_hw_ani_control_new(struct ath_hw *ah, ...@@ -1056,7 +1025,7 @@ static bool ar5008_hw_ani_control_new(struct ath_hw *ah,
aniState->firstepLevel, aniState->firstepLevel,
level, level,
ATH9K_ANI_FIRSTEP_LVL, ATH9K_ANI_FIRSTEP_LVL,
value2, value,
aniState->iniDef.firstepLow); aniState->iniDef.firstepLow);
if (level > aniState->firstepLevel) if (level > aniState->firstepLevel)
ah->stats.ast_ani_stepup++; ah->stats.ast_ani_stepup++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment