aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2013-05-28 12:04:44 -0400
committerJohn W. Linville <linville@tuxdriver.com>2013-05-29 15:22:42 -0400
commit9c8426fc79eef00464d33e774085395cac41d091 (patch)
treeb260e611319bbe1165f8879922c60e0afbb071a1 /drivers
parentb338f74e33e33616e8fe498b5b09da8a84a7b218 (diff)
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: Felix Fietkau <nbd@openwrt.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_paprd.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
index 09c1f9da67a0..6343cc91953e 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
@@ -454,6 +454,8 @@ static bool create_pa_curve(u32 *data_L, u32 *data_U, u32 *pa_table, u16 *gain)
454 if (accum_cnt <= thresh_accum_cnt) 454 if (accum_cnt <= thresh_accum_cnt)
455 continue; 455 continue;
456 456
457 max_index++;
458
457 /* sum(tx amplitude) */ 459 /* sum(tx amplitude) */
458 accum_tx = ((data_L[i] >> 16) & 0xffff) | 460 accum_tx = ((data_L[i] >> 16) & 0xffff) |
459 ((data_U[i] & 0x7ff) << 16); 461 ((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 470
469 accum_tx <<= scale_factor; 471 accum_tx <<= scale_factor;
470 accum_rx <<= scale_factor; 472 accum_rx <<= scale_factor;
471 x_est[i + 1] = (((accum_tx + accum_cnt) / accum_cnt) + 32) >> 473 x_est[max_index] =
472 scale_factor; 474 (((accum_tx + accum_cnt) / accum_cnt) + 32) >>
475 scale_factor;
473 476
474 Y[i + 1] = ((((accum_rx + accum_cnt) / accum_cnt) + 32) >> 477 Y[max_index] =
478 ((((accum_rx + accum_cnt) / accum_cnt) + 32) >>
475 scale_factor) + 479 scale_factor) +
476 (1 << scale_factor) * max_index + 16; 480 (1 << scale_factor) * i + 16;
477 481
478 if (accum_ang >= (1 << 26)) 482 if (accum_ang >= (1 << 26))
479 accum_ang -= 1 << 27; 483 accum_ang -= 1 << 27;
480 484
481 theta[i + 1] = ((accum_ang * (1 << scale_factor)) + accum_cnt) / 485 theta[max_index] =
482 accum_cnt; 486 ((accum_ang * (1 << scale_factor)) + accum_cnt) /
483 487 accum_cnt;
484 max_index++;
485 } 488 }
486 489
487 /* 490 /*