| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010 Atheros Communications Inc. | 2 * Copyright (c) 2010 Atheros Communications Inc. |
| 3 * | 3 * |
| 4 * Permission to use, copy, modify, and/or distribute this software for any | 4 * Permission to use, copy, modify, and/or distribute this software for any |
| 5 * purpose with or without fee is hereby granted, provided that the above | 5 * purpose with or without fee is hereby granted, provided that the above |
| 6 * copyright notice and this permission notice appear in all copies. | 6 * copyright notice and this permission notice appear in all copies. |
| 7 * | 7 * |
| 8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | 8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | 9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | 10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 scale_factor = 8; | 340 scale_factor = 8; |
| 341 | 341 |
| 342 /* low signal gain */ | 342 /* low signal gain */ |
| 343 if (x_est[6] == x_est[3]) | 343 if (x_est[6] == x_est[3]) |
| 344 return false; | 344 return false; |
| 345 | 345 |
| 346 G_fxp = | 346 G_fxp = |
| 347 (((Y[6] - Y[3]) * 1 << scale_factor) + | 347 (((Y[6] - Y[3]) * 1 << scale_factor) + |
| 348 (x_est[6] - x_est[3])) / (x_est[6] - x_est[3]); | 348 (x_est[6] - x_est[3])) / (x_est[6] - x_est[3]); |
| 349 | 349 |
| 350 /* prevent division by zero */ |
| 351 if (G_fxp == 0) |
| 352 return false; |
| 353 |
| 350 Y_intercept = | 354 Y_intercept = |
| 351 (G_fxp * (x_est[0] - x_est[3]) + | 355 (G_fxp * (x_est[0] - x_est[3]) + |
| 352 (1 << scale_factor)) / (1 << scale_factor) + Y[3]; | 356 (1 << scale_factor)) / (1 << scale_factor) + Y[3]; |
| 353 | 357 |
| 354 for (i = 0; i <= max_index; i++) | 358 for (i = 0; i <= max_index; i++) |
| 355 y_est[i] = Y[i] - Y_intercept; | 359 y_est[i] = Y[i] - Y_intercept; |
| 356 | 360 |
| 357 for (i = 0; i <= 3; i++) { | 361 for (i = 0; i <= 3; i++) { |
| 358 y_est[i] = i * 32; | 362 y_est[i] = i * 32; |
| 359 | |
| 360 /* prevent division by zero */ | |
| 361 if (G_fxp == 0) | |
| 362 return false; | |
| 363 | |
| 364 x_est[i] = ((y_est[i] * 1 << scale_factor) + G_fxp) / G_fxp; | 363 x_est[i] = ((y_est[i] * 1 << scale_factor) + G_fxp) / G_fxp; |
| 365 } | 364 } |
| 366 | 365 |
| 366 if (y_est[max_index] == 0) |
| 367 return false; |
| 368 |
| 367 x_est_fxp1_nonlin = | 369 x_est_fxp1_nonlin = |
| 368 x_est[max_index] - ((1 << scale_factor) * y_est[max_index] + | 370 x_est[max_index] - ((1 << scale_factor) * y_est[max_index] + |
| 369 G_fxp) / G_fxp; | 371 G_fxp) / G_fxp; |
| 370 | 372 |
| 371 order_x_by_y = | 373 order_x_by_y = |
| 372 (x_est_fxp1_nonlin + y_est[max_index]) / y_est[max_index]; | 374 (x_est_fxp1_nonlin + y_est[max_index]) / y_est[max_index]; |
| 373 | 375 |
| 374 if (order_x_by_y == 0) | 376 if (order_x_by_y == 0) |
| 375 M = 10; | 377 M = 10; |
| 376 else if (order_x_by_y == 1) | 378 else if (order_x_by_y == 1) |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 beta_raw = beta_raw + B1_tmp[i] * x_tilde[i]; | 452 beta_raw = beta_raw + B1_tmp[i] * x_tilde[i]; |
| 451 alpha_raw = alpha_raw + B2_tmp[i] * x_tilde[i]; | 453 alpha_raw = alpha_raw + B2_tmp[i] * x_tilde[i]; |
| 452 } | 454 } |
| 453 | 455 |
| 454 scale_B = | 456 scale_B = |
| 455 ((sum_y_quad / scale_factor) * (L + 1) - | 457 ((sum_y_quad / scale_factor) * (L + 1) - |
| 456 (sum_y_sqr / scale_factor) * sum_y_sqr) * scale_factor; | 458 (sum_y_sqr / scale_factor) * sum_y_sqr) * scale_factor; |
| 457 | 459 |
| 458 Q_scale_B = find_proper_scale(find_expn(abs(scale_B)), 10); | 460 Q_scale_B = find_proper_scale(find_expn(abs(scale_B)), 10); |
| 459 scale_B = scale_B / (1 << Q_scale_B); | 461 scale_B = scale_B / (1 << Q_scale_B); |
| 462 if (scale_B == 0) |
| 463 return false; |
| 460 Q_beta = find_proper_scale(find_expn(abs(beta_raw)), 10); | 464 Q_beta = find_proper_scale(find_expn(abs(beta_raw)), 10); |
| 461 Q_alpha = find_proper_scale(find_expn(abs(alpha_raw)), 10); | 465 Q_alpha = find_proper_scale(find_expn(abs(alpha_raw)), 10); |
| 462 beta_raw = beta_raw / (1 << Q_beta); | 466 beta_raw = beta_raw / (1 << Q_beta); |
| 463 alpha_raw = alpha_raw / (1 << Q_alpha); | 467 alpha_raw = alpha_raw / (1 << Q_alpha); |
| 464 alpha = (alpha_raw << 10) / scale_B; | 468 alpha = (alpha_raw << 10) / scale_B; |
| 465 beta = (beta_raw << 10) / scale_B; | 469 beta = (beta_raw << 10) / scale_B; |
| 466 order_1 = 3 * M - Q_x - Q_B1 - Q_beta + 10 + Q_scale_B; | 470 order_1 = 3 * M - Q_x - Q_B1 - Q_beta + 10 + Q_scale_B; |
| 467 order_2 = 3 * M - Q_x - Q_B2 - Q_alpha + 10 + Q_scale_B; | 471 order_2 = 3 * M - Q_x - Q_B2 - Q_alpha + 10 + Q_scale_B; |
| 468 order1_5x = order_1 / 5; | 472 order1_5x = order_1 / 5; |
| 469 order2_3x = order_2 / 3; | 473 order2_3x = order_2 / 3; |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 return 0; | 710 return 0; |
| 707 } | 711 } |
| 708 EXPORT_SYMBOL(ar9003_paprd_init_table); | 712 EXPORT_SYMBOL(ar9003_paprd_init_table); |
| 709 | 713 |
| 710 bool ar9003_paprd_is_done(struct ath_hw *ah) | 714 bool ar9003_paprd_is_done(struct ath_hw *ah) |
| 711 { | 715 { |
| 712 return !!REG_READ_FIELD(ah, AR_PHY_PAPRD_TRAINER_STAT1, | 716 return !!REG_READ_FIELD(ah, AR_PHY_PAPRD_TRAINER_STAT1, |
| 713 AR_PHY_PAPRD_TRAINER_STAT1_PAPRD_TRAIN_DONE); | 717 AR_PHY_PAPRD_TRAINER_STAT1_PAPRD_TRAIN_DONE); |
| 714 } | 718 } |
| 715 EXPORT_SYMBOL(ar9003_paprd_is_done); | 719 EXPORT_SYMBOL(ar9003_paprd_is_done); |
| OLD | NEW |