Commit 9c8426fc authored by Felix Fietkau's avatar Felix Fietkau Committed by John W. Linville

ath9k_hw: fix PA predistortion miscalibration

If any bins from the training data are skipped (i != max_index), the
calculated compensation curve gets distorted, and the signal will be
wildly overamplified. This may be the cause of the reported hardware
damage that was caused by PA predistortion (because of which PAPRD was
disabled by default).

When calculating the x_est, Y, theta values, the use of max_index and i
was reversed. i points to the bin index whereas max_index refers to the
index of the calculated arrays.

Note that PA predistortion is still disabled, it will be re-enabled
after it has been properly validated.
Signed-off-by: default avatarFelix Fietkau <nbd@openwrt.org>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent b338f74e
...@@ -454,6 +454,8 @@ static bool create_pa_curve(u32 *data_L, u32 *data_U, u32 *pa_table, u16 *gain) ...@@ -454,6 +454,8 @@ static bool create_pa_curve(u32 *data_L, u32 *data_U, u32 *pa_table, u16 *gain)
if (accum_cnt <= thresh_accum_cnt) if (accum_cnt <= thresh_accum_cnt)
continue; continue;
max_index++;
/* sum(tx amplitude) */ /* sum(tx amplitude) */
accum_tx = ((data_L[i] >> 16) & 0xffff) | accum_tx = ((data_L[i] >> 16) & 0xffff) |
((data_U[i] & 0x7ff) << 16); ((data_U[i] & 0x7ff) << 16);
...@@ -468,20 +470,21 @@ static bool create_pa_curve(u32 *data_L, u32 *data_U, u32 *pa_table, u16 *gain) ...@@ -468,20 +470,21 @@ static bool create_pa_curve(u32 *data_L, u32 *data_U, u32 *pa_table, u16 *gain)
accum_tx <<= scale_factor; accum_tx <<= scale_factor;
accum_rx <<= scale_factor; accum_rx <<= scale_factor;
x_est[i + 1] = (((accum_tx + accum_cnt) / accum_cnt) + 32) >> x_est[max_index] =
scale_factor; (((accum_tx + accum_cnt) / accum_cnt) + 32) >>
scale_factor;
Y[i + 1] = ((((accum_rx + accum_cnt) / accum_cnt) + 32) >> Y[max_index] =
((((accum_rx + accum_cnt) / accum_cnt) + 32) >>
scale_factor) + scale_factor) +
(1 << scale_factor) * max_index + 16; (1 << scale_factor) * i + 16;
if (accum_ang >= (1 << 26)) if (accum_ang >= (1 << 26))
accum_ang -= 1 << 27; accum_ang -= 1 << 27;
theta[i + 1] = ((accum_ang * (1 << scale_factor)) + accum_cnt) / theta[max_index] =
accum_cnt; ((accum_ang * (1 << scale_factor)) + accum_cnt) /
accum_cnt;
max_index++;
} }
/* /*
......
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