Lines Matching +full:noise +full:- +full:sensitive

1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
3 * Copyright (C) 2005-2014 Intel Corporation
8 #include "iwl-trans.h"
41 list_for_each_entry(res, &priv->calib_results, list) { in iwl_send_calib_results()
44 hcmd.len[0] = res->cmd_len; in iwl_send_calib_results()
45 hcmd.data[0] = &res->cmd; in iwl_send_calib_results()
50 ret, res->cmd.hdr.op_code); in iwl_send_calib_results()
64 return -ENOMEM; in iwl_calib_set()
68 return -ENOMEM; in iwl_calib_set()
69 res->cmd = *cmd; in iwl_calib_set()
70 memcpy(res->cmd.data, cmd->data, len); in iwl_calib_set()
71 res->cmd_len = struct_size(cmd, data, len); in iwl_calib_set()
73 list_for_each_entry(tmp, &priv->calib_results, list) { in iwl_calib_set()
74 if (tmp->cmd.hdr.op_code == res->cmd.hdr.op_code) { in iwl_calib_set()
75 list_replace(&tmp->list, &res->list); in iwl_calib_set()
82 list_add_tail(&res->list, &priv->calib_results); in iwl_calib_set()
91 list_for_each_entry_safe(res, tmp, &priv->calib_results, list) { in iwl_calib_free_results()
92 list_del(&res->list); in iwl_calib_free_results()
102 * but then determines that they are either noise, or transmissions
103 * from a distant wireless network (also "noise", really) that get
107 * high that our DSP gets too busy trying to lock onto non-network
108 * activity/noise. */
123 /* "false_alarms" values below are cross-multiplications to assess the in iwl_sens_energy_cck()
126 * (some should be expected if rx is sensitive enough) in a in iwl_sens_energy_cck()
129 * MIN_FA/fixed-time < false_alarms/actual-rx-time < MAX_FA/beacon-time in iwl_sens_energy_cck()
136 const struct iwl_sensitivity_ranges *ranges = priv->hw_params.sens; in iwl_sens_energy_cck()
138 data = &(priv->sensitivity_data); in iwl_sens_energy_cck()
140 data->nrg_auto_corr_silence_diff = 0; in iwl_sens_energy_cck()
143 * This is background noise, which may include transmissions from other in iwl_sens_energy_cck()
145 silence_rssi_a = (u8)((rx_info->beacon_silence_rssi_a & in iwl_sens_energy_cck()
147 silence_rssi_b = (u8)((rx_info->beacon_silence_rssi_b & in iwl_sens_energy_cck()
149 silence_rssi_c = (u8)((rx_info->beacon_silence_rssi_c & in iwl_sens_energy_cck()
155 /* Store silence rssi in 20-beacon history table */ in iwl_sens_energy_cck()
156 data->nrg_silence_rssi[data->nrg_silence_idx] = max_silence_rssi; in iwl_sens_energy_cck()
157 data->nrg_silence_idx++; in iwl_sens_energy_cck()
158 if (data->nrg_silence_idx >= NRG_NUM_PREV_STAT_L) in iwl_sens_energy_cck()
159 data->nrg_silence_idx = 0; in iwl_sens_energy_cck()
163 val = data->nrg_silence_rssi[i]; in iwl_sens_energy_cck()
166 IWL_DEBUG_CALIB(priv, "silence a %u, b %u, c %u, 20-bcn max %u\n", in iwl_sens_energy_cck()
172 * Save it in 10-beacon history table. */ in iwl_sens_energy_cck()
173 i = data->nrg_energy_idx; in iwl_sens_energy_cck()
174 val = min(rx_info->beacon_energy_b, rx_info->beacon_energy_c); in iwl_sens_energy_cck()
175 data->nrg_value[i] = min(rx_info->beacon_energy_a, val); in iwl_sens_energy_cck()
177 data->nrg_energy_idx++; in iwl_sens_energy_cck()
178 if (data->nrg_energy_idx >= 10) in iwl_sens_energy_cck()
179 data->nrg_energy_idx = 0; in iwl_sens_energy_cck()
185 max_nrg_cck = data->nrg_value[0]; in iwl_sens_energy_cck()
187 max_nrg_cck = (u32) max(max_nrg_cck, (data->nrg_value[i])); in iwl_sens_energy_cck()
190 IWL_DEBUG_CALIB(priv, "rx energy a %u, b %u, c %u, 10-bcn max/min %u\n", in iwl_sens_energy_cck()
191 rx_info->beacon_energy_a, rx_info->beacon_energy_b, in iwl_sens_energy_cck()
192 rx_info->beacon_energy_c, max_nrg_cck - 6); in iwl_sens_energy_cck()
194 /* Count number of consecutive beacons with fewer-than-desired in iwl_sens_energy_cck()
197 data->num_in_cck_no_fa++; in iwl_sens_energy_cck()
199 data->num_in_cck_no_fa = 0; in iwl_sens_energy_cck()
201 data->num_in_cck_no_fa); in iwl_sens_energy_cck()
205 (data->auto_corr_cck > AUTO_CORR_MAX_TH_CCK)) { in iwl_sens_energy_cck()
209 data->nrg_curr_state = IWL_FA_TOO_MANY; in iwl_sens_energy_cck()
211 data->nrg_silence_ref = silence_ref; in iwl_sens_energy_cck()
215 data->nrg_th_cck = data->nrg_th_cck - NRG_STEP_CCK; in iwl_sens_energy_cck()
218 data->nrg_curr_state = IWL_FA_TOO_FEW; in iwl_sens_energy_cck()
222 data->nrg_auto_corr_silence_diff = (s32)data->nrg_silence_ref - in iwl_sens_energy_cck()
227 data->nrg_auto_corr_silence_diff); in iwl_sens_energy_cck()
235 if ((data->nrg_prev_state != IWL_FA_TOO_MANY) && in iwl_sens_energy_cck()
236 ((data->nrg_auto_corr_silence_diff > NRG_DIFF) || in iwl_sens_energy_cck()
237 (data->num_in_cck_no_fa > MAX_NUMBER_CCK_NO_FA))) { in iwl_sens_energy_cck()
241 val = data->nrg_th_cck + NRG_STEP_CCK; in iwl_sens_energy_cck()
242 data->nrg_th_cck = min((u32)ranges->min_nrg_cck, val); in iwl_sens_energy_cck()
250 data->nrg_curr_state = IWL_FA_GOOD_RANGE; in iwl_sens_energy_cck()
253 data->nrg_silence_ref = silence_ref; in iwl_sens_energy_cck()
258 if (data->nrg_prev_state == IWL_FA_TOO_MANY) { in iwl_sens_energy_cck()
260 if (data->nrg_th_cck > (max_nrg_cck + NRG_MARGIN)) in iwl_sens_energy_cck()
261 data->nrg_th_cck -= NRG_MARGIN; in iwl_sens_energy_cck()
263 data->nrg_th_cck = max_nrg_cck; in iwl_sens_energy_cck()
272 data->nrg_th_cck = max(max_nrg_cck, data->nrg_th_cck); in iwl_sens_energy_cck()
273 IWL_DEBUG_CALIB(priv, "new nrg_th_cck %u\n", data->nrg_th_cck); in iwl_sens_energy_cck()
275 data->nrg_prev_state = data->nrg_curr_state; in iwl_sens_energy_cck()
277 /* Auto-correlation CCK algorithm */ in iwl_sens_energy_cck()
281 * so the DSP won't be disturbed by the noise in iwl_sens_energy_cck()
283 if (data->auto_corr_cck < AUTO_CORR_MAX_TH_CCK) in iwl_sens_energy_cck()
284 data->auto_corr_cck = AUTO_CORR_MAX_TH_CCK + 1; in iwl_sens_energy_cck()
286 val = data->auto_corr_cck + AUTO_CORR_STEP_CCK; in iwl_sens_energy_cck()
287 data->auto_corr_cck = in iwl_sens_energy_cck()
288 min((u32)ranges->auto_corr_max_cck, val); in iwl_sens_energy_cck()
290 val = data->auto_corr_cck_mrc + AUTO_CORR_STEP_CCK; in iwl_sens_energy_cck()
291 data->auto_corr_cck_mrc = in iwl_sens_energy_cck()
292 min((u32)ranges->auto_corr_max_cck_mrc, val); in iwl_sens_energy_cck()
294 ((data->nrg_auto_corr_silence_diff > NRG_DIFF) || in iwl_sens_energy_cck()
295 (data->num_in_cck_no_fa > MAX_NUMBER_CCK_NO_FA))) { in iwl_sens_energy_cck()
298 val = data->auto_corr_cck - AUTO_CORR_STEP_CCK; in iwl_sens_energy_cck()
299 data->auto_corr_cck = in iwl_sens_energy_cck()
300 max((u32)ranges->auto_corr_min_cck, val); in iwl_sens_energy_cck()
301 val = data->auto_corr_cck_mrc - AUTO_CORR_STEP_CCK; in iwl_sens_energy_cck()
302 data->auto_corr_cck_mrc = in iwl_sens_energy_cck()
303 max((u32)ranges->auto_corr_min_cck_mrc, val); in iwl_sens_energy_cck()
319 const struct iwl_sensitivity_ranges *ranges = priv->hw_params.sens; in iwl_sens_auto_corr_ofdm()
321 data = &(priv->sensitivity_data); in iwl_sens_auto_corr_ofdm()
329 val = data->auto_corr_ofdm + AUTO_CORR_STEP_OFDM; in iwl_sens_auto_corr_ofdm()
330 data->auto_corr_ofdm = in iwl_sens_auto_corr_ofdm()
331 min((u32)ranges->auto_corr_max_ofdm, val); in iwl_sens_auto_corr_ofdm()
333 val = data->auto_corr_ofdm_mrc + AUTO_CORR_STEP_OFDM; in iwl_sens_auto_corr_ofdm()
334 data->auto_corr_ofdm_mrc = in iwl_sens_auto_corr_ofdm()
335 min((u32)ranges->auto_corr_max_ofdm_mrc, val); in iwl_sens_auto_corr_ofdm()
337 val = data->auto_corr_ofdm_x1 + AUTO_CORR_STEP_OFDM; in iwl_sens_auto_corr_ofdm()
338 data->auto_corr_ofdm_x1 = in iwl_sens_auto_corr_ofdm()
339 min((u32)ranges->auto_corr_max_ofdm_x1, val); in iwl_sens_auto_corr_ofdm()
341 val = data->auto_corr_ofdm_mrc_x1 + AUTO_CORR_STEP_OFDM; in iwl_sens_auto_corr_ofdm()
342 data->auto_corr_ofdm_mrc_x1 = in iwl_sens_auto_corr_ofdm()
343 min((u32)ranges->auto_corr_max_ofdm_mrc_x1, val); in iwl_sens_auto_corr_ofdm()
352 val = data->auto_corr_ofdm - AUTO_CORR_STEP_OFDM; in iwl_sens_auto_corr_ofdm()
353 data->auto_corr_ofdm = in iwl_sens_auto_corr_ofdm()
354 max((u32)ranges->auto_corr_min_ofdm, val); in iwl_sens_auto_corr_ofdm()
356 val = data->auto_corr_ofdm_mrc - AUTO_CORR_STEP_OFDM; in iwl_sens_auto_corr_ofdm()
357 data->auto_corr_ofdm_mrc = in iwl_sens_auto_corr_ofdm()
358 max((u32)ranges->auto_corr_min_ofdm_mrc, val); in iwl_sens_auto_corr_ofdm()
360 val = data->auto_corr_ofdm_x1 - AUTO_CORR_STEP_OFDM; in iwl_sens_auto_corr_ofdm()
361 data->auto_corr_ofdm_x1 = in iwl_sens_auto_corr_ofdm()
362 max((u32)ranges->auto_corr_min_ofdm_x1, val); in iwl_sens_auto_corr_ofdm()
364 val = data->auto_corr_ofdm_mrc_x1 - AUTO_CORR_STEP_OFDM; in iwl_sens_auto_corr_ofdm()
365 data->auto_corr_ofdm_mrc_x1 = in iwl_sens_auto_corr_ofdm()
366 max((u32)ranges->auto_corr_min_ofdm_mrc_x1, val); in iwl_sens_auto_corr_ofdm()
379 cpu_to_le16((u16)data->auto_corr_ofdm); in iwl_prepare_legacy_sensitivity_tbl()
381 cpu_to_le16((u16)data->auto_corr_ofdm_mrc); in iwl_prepare_legacy_sensitivity_tbl()
383 cpu_to_le16((u16)data->auto_corr_ofdm_x1); in iwl_prepare_legacy_sensitivity_tbl()
385 cpu_to_le16((u16)data->auto_corr_ofdm_mrc_x1); in iwl_prepare_legacy_sensitivity_tbl()
388 cpu_to_le16((u16)data->auto_corr_cck); in iwl_prepare_legacy_sensitivity_tbl()
390 cpu_to_le16((u16)data->auto_corr_cck_mrc); in iwl_prepare_legacy_sensitivity_tbl()
393 cpu_to_le16((u16)data->nrg_th_cck); in iwl_prepare_legacy_sensitivity_tbl()
395 cpu_to_le16((u16)data->nrg_th_ofdm); in iwl_prepare_legacy_sensitivity_tbl()
398 cpu_to_le16(data->barker_corr_th_min); in iwl_prepare_legacy_sensitivity_tbl()
400 cpu_to_le16(data->barker_corr_th_min_mrc); in iwl_prepare_legacy_sensitivity_tbl()
402 cpu_to_le16(data->nrg_th_cca); in iwl_prepare_legacy_sensitivity_tbl()
405 data->auto_corr_ofdm, data->auto_corr_ofdm_mrc, in iwl_prepare_legacy_sensitivity_tbl()
406 data->auto_corr_ofdm_x1, data->auto_corr_ofdm_mrc_x1, in iwl_prepare_legacy_sensitivity_tbl()
407 data->nrg_th_ofdm); in iwl_prepare_legacy_sensitivity_tbl()
410 data->auto_corr_cck, data->auto_corr_cck_mrc, in iwl_prepare_legacy_sensitivity_tbl()
411 data->nrg_th_cck); in iwl_prepare_legacy_sensitivity_tbl()
426 data = &(priv->sensitivity_data); in iwl_sensitivity_write()
436 if (!memcmp(&cmd.table[0], &(priv->sensitivity_tbl[0]), in iwl_sensitivity_write()
443 memcpy(&(priv->sensitivity_tbl[0]), &(cmd.table[0]), in iwl_sensitivity_write()
461 data = &(priv->sensitivity_data); in iwl_enhance_sensitivity_write()
467 if (priv->lib->hd_v2) { in iwl_enhance_sensitivity_write()
519 if (!memcmp(&cmd.enhance_table[0], &(priv->sensitivity_tbl[0]), in iwl_enhance_sensitivity_write()
522 &(priv->enhance_sensitivity_tbl[0]), in iwl_enhance_sensitivity_write()
529 memcpy(&(priv->sensitivity_tbl[0]), &(cmd.enhance_table[0]), in iwl_enhance_sensitivity_write()
531 memcpy(&(priv->enhance_sensitivity_tbl[0]), in iwl_enhance_sensitivity_write()
543 const struct iwl_sensitivity_ranges *ranges = priv->hw_params.sens; in iwl_init_sensitivity()
545 if (priv->calib_disabled & IWL_SENSITIVITY_CALIB_DISABLED) in iwl_init_sensitivity()
551 data = &(priv->sensitivity_data); in iwl_init_sensitivity()
558 data->num_in_cck_no_fa = 0; in iwl_init_sensitivity()
559 data->nrg_curr_state = IWL_FA_TOO_MANY; in iwl_init_sensitivity()
560 data->nrg_prev_state = IWL_FA_TOO_MANY; in iwl_init_sensitivity()
561 data->nrg_silence_ref = 0; in iwl_init_sensitivity()
562 data->nrg_silence_idx = 0; in iwl_init_sensitivity()
563 data->nrg_energy_idx = 0; in iwl_init_sensitivity()
566 data->nrg_value[i] = 0; in iwl_init_sensitivity()
569 data->nrg_silence_rssi[i] = 0; in iwl_init_sensitivity()
571 data->auto_corr_ofdm = ranges->auto_corr_min_ofdm; in iwl_init_sensitivity()
572 data->auto_corr_ofdm_mrc = ranges->auto_corr_min_ofdm_mrc; in iwl_init_sensitivity()
573 data->auto_corr_ofdm_x1 = ranges->auto_corr_min_ofdm_x1; in iwl_init_sensitivity()
574 data->auto_corr_ofdm_mrc_x1 = ranges->auto_corr_min_ofdm_mrc_x1; in iwl_init_sensitivity()
575 data->auto_corr_cck = AUTO_CORR_CCK_MIN_VAL_DEF; in iwl_init_sensitivity()
576 data->auto_corr_cck_mrc = ranges->auto_corr_min_cck_mrc; in iwl_init_sensitivity()
577 data->nrg_th_cck = ranges->nrg_th_cck; in iwl_init_sensitivity()
578 data->nrg_th_ofdm = ranges->nrg_th_ofdm; in iwl_init_sensitivity()
579 data->barker_corr_th_min = ranges->barker_corr_th_min; in iwl_init_sensitivity()
580 data->barker_corr_th_min_mrc = ranges->barker_corr_th_min_mrc; in iwl_init_sensitivity()
581 data->nrg_th_cca = ranges->nrg_th_cca; in iwl_init_sensitivity()
583 data->last_bad_plcp_cnt_ofdm = 0; in iwl_init_sensitivity()
584 data->last_fa_cnt_ofdm = 0; in iwl_init_sensitivity()
585 data->last_bad_plcp_cnt_cck = 0; in iwl_init_sensitivity()
586 data->last_fa_cnt_cck = 0; in iwl_init_sensitivity()
588 if (priv->fw->enhance_sensitivity_table) in iwl_init_sensitivity()
609 if (priv->calib_disabled & IWL_SENSITIVITY_CALIB_DISABLED) in iwl_sensitivity_calibration()
612 data = &(priv->sensitivity_data); in iwl_sensitivity_calibration()
615 IWL_DEBUG_CALIB(priv, "<< - not associated\n"); in iwl_sensitivity_calibration()
619 spin_lock_bh(&priv->statistics.lock); in iwl_sensitivity_calibration()
620 rx_info = &priv->statistics.rx_non_phy; in iwl_sensitivity_calibration()
621 ofdm = &priv->statistics.rx_ofdm; in iwl_sensitivity_calibration()
622 cck = &priv->statistics.rx_cck; in iwl_sensitivity_calibration()
623 if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) { in iwl_sensitivity_calibration()
625 spin_unlock_bh(&priv->statistics.lock); in iwl_sensitivity_calibration()
630 rx_enable_time = le32_to_cpu(rx_info->channel_load); in iwl_sensitivity_calibration()
631 fa_cck = le32_to_cpu(cck->false_alarm_cnt); in iwl_sensitivity_calibration()
632 fa_ofdm = le32_to_cpu(ofdm->false_alarm_cnt); in iwl_sensitivity_calibration()
633 bad_plcp_cck = le32_to_cpu(cck->plcp_err); in iwl_sensitivity_calibration()
634 bad_plcp_ofdm = le32_to_cpu(ofdm->plcp_err); in iwl_sensitivity_calibration()
637 le32_to_cpu(rx_info->beacon_silence_rssi_a); in iwl_sensitivity_calibration()
639 le32_to_cpu(rx_info->beacon_silence_rssi_b); in iwl_sensitivity_calibration()
641 le32_to_cpu(rx_info->beacon_silence_rssi_c); in iwl_sensitivity_calibration()
643 le32_to_cpu(rx_info->beacon_energy_a); in iwl_sensitivity_calibration()
645 le32_to_cpu(rx_info->beacon_energy_b); in iwl_sensitivity_calibration()
647 le32_to_cpu(rx_info->beacon_energy_c); in iwl_sensitivity_calibration()
649 spin_unlock_bh(&priv->statistics.lock); in iwl_sensitivity_calibration()
661 if (data->last_bad_plcp_cnt_cck > bad_plcp_cck) in iwl_sensitivity_calibration()
662 data->last_bad_plcp_cnt_cck = bad_plcp_cck; in iwl_sensitivity_calibration()
664 bad_plcp_cck -= data->last_bad_plcp_cnt_cck; in iwl_sensitivity_calibration()
665 data->last_bad_plcp_cnt_cck += bad_plcp_cck; in iwl_sensitivity_calibration()
668 if (data->last_bad_plcp_cnt_ofdm > bad_plcp_ofdm) in iwl_sensitivity_calibration()
669 data->last_bad_plcp_cnt_ofdm = bad_plcp_ofdm; in iwl_sensitivity_calibration()
671 bad_plcp_ofdm -= data->last_bad_plcp_cnt_ofdm; in iwl_sensitivity_calibration()
672 data->last_bad_plcp_cnt_ofdm += bad_plcp_ofdm; in iwl_sensitivity_calibration()
675 if (data->last_fa_cnt_ofdm > fa_ofdm) in iwl_sensitivity_calibration()
676 data->last_fa_cnt_ofdm = fa_ofdm; in iwl_sensitivity_calibration()
678 fa_ofdm -= data->last_fa_cnt_ofdm; in iwl_sensitivity_calibration()
679 data->last_fa_cnt_ofdm += fa_ofdm; in iwl_sensitivity_calibration()
682 if (data->last_fa_cnt_cck > fa_cck) in iwl_sensitivity_calibration()
683 data->last_fa_cnt_cck = fa_cck; in iwl_sensitivity_calibration()
685 fa_cck -= data->last_fa_cnt_cck; in iwl_sensitivity_calibration()
686 data->last_fa_cnt_cck += fa_cck; in iwl_sensitivity_calibration()
698 if (priv->fw->enhance_sensitivity_table) in iwl_sensitivity_calibration()
727 average_sig[0] = data->chain_signal_a / IWL_CAL_NUM_BEACONS; in iwl_find_disconn_antenna()
728 average_sig[1] = data->chain_signal_b / IWL_CAL_NUM_BEACONS; in iwl_find_disconn_antenna()
729 average_sig[2] = data->chain_signal_c / IWL_CAL_NUM_BEACONS; in iwl_find_disconn_antenna()
755 s32 rssi_delta = (max_average_sig - average_sig[i]); in iwl_find_disconn_antenna()
760 data->disconn_array[i] = 1; in iwl_find_disconn_antenna()
765 i, rssi_delta, data->disconn_array[i]); in iwl_find_disconn_antenna()
779 active_chains &= priv->nvm_data->valid_rx_ant; in iwl_find_disconn_antenna()
784 * priv->hw_setting.valid_tx_ant */ in iwl_find_disconn_antenna()
786 if (!(priv->nvm_data->valid_tx_ant & ant_msk)) in iwl_find_disconn_antenna()
790 if (data->disconn_array[i] == 0) in iwl_find_disconn_antenna()
793 if (num_tx_chains == priv->hw_params.tx_chains_num && in iwl_find_disconn_antenna()
794 data->disconn_array[i]) { in iwl_find_disconn_antenna()
800 find_first_chain(priv->nvm_data->valid_tx_ant); in iwl_find_disconn_antenna()
801 data->disconn_array[first_chain] = 0; in iwl_find_disconn_antenna()
804 "All Tx chains are disconnected W/A - declare %d as connected\n", in iwl_find_disconn_antenna()
810 if (active_chains != priv->nvm_data->valid_rx_ant && in iwl_find_disconn_antenna()
811 active_chains != priv->chain_noise_data.active_chains) in iwl_find_disconn_antenna()
816 priv->nvm_data->valid_rx_ant); in iwl_find_disconn_antenna()
819 data->active_chains = active_chains; in iwl_find_disconn_antenna()
830 struct iwl_chain_noise_data *data = &priv->chain_noise_data; in iwlagn_gain_computation()
836 if ((data->disconn_array[i])) { in iwlagn_gain_computation()
837 data->delta_gain_code[i] = 0; in iwlagn_gain_computation()
841 delta_g = (priv->lib->chain_noise_scale * in iwlagn_gain_computation()
842 ((s32)average_noise[default_chain] - in iwlagn_gain_computation()
846 data->delta_gain_code[i] = in iwlagn_gain_computation()
858 data->delta_gain_code[i] |= (1 << 2); in iwlagn_gain_computation()
862 data->delta_gain_code[1], data->delta_gain_code[2]); in iwlagn_gain_computation()
864 if (!data->radio_write) { in iwlagn_gain_computation()
870 priv->phy_calib_chain_noise_gain_cmd); in iwlagn_gain_computation()
871 cmd.delta_gain_1 = data->delta_gain_code[1]; in iwlagn_gain_computation()
872 cmd.delta_gain_2 = data->delta_gain_code[2]; in iwlagn_gain_computation()
876 data->radio_write = 1; in iwlagn_gain_computation()
877 data->state = IWL_CHAIN_NOISE_CALIBRATED; in iwlagn_gain_computation()
882 * Accumulate 16 beacons of signal and noise statistics for each of
883 * 3 receivers/antennas/rx-chains, then figure out:
909 * MULTI-FIXME: in iwl_chain_noise_calibration()
913 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; in iwl_chain_noise_calibration()
915 if (priv->calib_disabled & IWL_CHAIN_NOISE_CALIB_DISABLED) in iwl_chain_noise_calibration()
918 data = &(priv->chain_noise_data); in iwl_chain_noise_calibration()
924 if (data->state != IWL_CHAIN_NOISE_ACCUMULATE) { in iwl_chain_noise_calibration()
925 if (data->state == IWL_CHAIN_NOISE_ALIVE) in iwl_chain_noise_calibration()
926 IWL_DEBUG_CALIB(priv, "Wait for noise calib reset\n"); in iwl_chain_noise_calibration()
930 spin_lock_bh(&priv->statistics.lock); in iwl_chain_noise_calibration()
932 rx_info = &priv->statistics.rx_non_phy; in iwl_chain_noise_calibration()
934 if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) { in iwl_chain_noise_calibration()
936 spin_unlock_bh(&priv->statistics.lock); in iwl_chain_noise_calibration()
940 rxon_band24 = !!(ctx->staging.flags & RXON_FLG_BAND_24G_MSK); in iwl_chain_noise_calibration()
941 rxon_chnum = le16_to_cpu(ctx->staging.channel); in iwl_chain_noise_calibration()
943 !!(priv->statistics.flag & STATISTICS_REPLY_FLG_BAND_24G_MSK); in iwl_chain_noise_calibration()
944 stat_chnum = le32_to_cpu(priv->statistics.flag) >> 16; in iwl_chain_noise_calibration()
951 spin_unlock_bh(&priv->statistics.lock); in iwl_chain_noise_calibration()
959 chain_noise_a = le32_to_cpu(rx_info->beacon_silence_rssi_a) & in iwl_chain_noise_calibration()
961 chain_noise_b = le32_to_cpu(rx_info->beacon_silence_rssi_b) & in iwl_chain_noise_calibration()
963 chain_noise_c = le32_to_cpu(rx_info->beacon_silence_rssi_c) & in iwl_chain_noise_calibration()
966 chain_sig_a = le32_to_cpu(rx_info->beacon_rssi_a) & IN_BAND_FILTER; in iwl_chain_noise_calibration()
967 chain_sig_b = le32_to_cpu(rx_info->beacon_rssi_b) & IN_BAND_FILTER; in iwl_chain_noise_calibration()
968 chain_sig_c = le32_to_cpu(rx_info->beacon_rssi_c) & IN_BAND_FILTER; in iwl_chain_noise_calibration()
970 spin_unlock_bh(&priv->statistics.lock); in iwl_chain_noise_calibration()
972 data->beacon_count++; in iwl_chain_noise_calibration()
974 data->chain_noise_a = (chain_noise_a + data->chain_noise_a); in iwl_chain_noise_calibration()
975 data->chain_noise_b = (chain_noise_b + data->chain_noise_b); in iwl_chain_noise_calibration()
976 data->chain_noise_c = (chain_noise_c + data->chain_noise_c); in iwl_chain_noise_calibration()
978 data->chain_signal_a = (chain_sig_a + data->chain_signal_a); in iwl_chain_noise_calibration()
979 data->chain_signal_b = (chain_sig_b + data->chain_signal_b); in iwl_chain_noise_calibration()
980 data->chain_signal_c = (chain_sig_c + data->chain_signal_c); in iwl_chain_noise_calibration()
983 rxon_chnum, rxon_band24, data->beacon_count); in iwl_chain_noise_calibration()
991 * 2) Differential gain (using silence noise) to balance receivers */ in iwl_chain_noise_calibration()
992 if (data->beacon_count != IWL_CAL_NUM_BEACONS) in iwl_chain_noise_calibration()
996 if (priv->lib->bt_params && in iwl_chain_noise_calibration()
997 priv->lib->bt_params->advanced_bt_coexist) { in iwl_chain_noise_calibration()
1000 data->active_chains = priv->nvm_data->valid_rx_ant; in iwl_chain_noise_calibration()
1002 if (!(data->active_chains & (1<<i))) in iwl_chain_noise_calibration()
1003 data->disconn_array[i] = 1; in iwl_chain_noise_calibration()
1007 /* Analyze noise for rx balance */ in iwl_chain_noise_calibration()
1008 average_noise[0] = data->chain_noise_a / IWL_CAL_NUM_BEACONS; in iwl_chain_noise_calibration()
1009 average_noise[1] = data->chain_noise_b / IWL_CAL_NUM_BEACONS; in iwl_chain_noise_calibration()
1010 average_noise[2] = data->chain_noise_c / IWL_CAL_NUM_BEACONS; in iwl_chain_noise_calibration()
1013 if (!(data->disconn_array[i]) && in iwl_chain_noise_calibration()
1016 * lower noise values so far: */ in iwl_chain_noise_calibration()
1031 find_first_chain(priv->nvm_data->valid_rx_ant)); in iwl_chain_noise_calibration()
1038 data->state = IWL_CHAIN_NOISE_DONE; in iwl_chain_noise_calibration()
1045 memset(&(priv->sensitivity_data), 0, in iwl_reset_run_time_calib()
1047 memset(&(priv->chain_noise_data), 0, in iwl_reset_run_time_calib()
1050 priv->chain_noise_data.delta_gain_code[i] = in iwl_reset_run_time_calib()