63 #include <linux/slab.h>
109 IWL_ERR(priv,
"Error %d on calib cmd %d\n",
110 ret, res->
hdr.op_code);
131 if (tmp->
hdr.op_code == res->
hdr.op_code) {
132 list_replace(&tmp->
list, &res->
list);
173 u8 max_silence_rssi = 0;
175 u8 silence_rssi_a = 0;
176 u8 silence_rssi_b = 0;
177 u8 silence_rssi_c = 0;
189 u32 false_alarms = norm_fa * 200 * 1024;
209 val =
max(silence_rssi_b, silence_rssi_c);
210 max_silence_rssi =
max(silence_rssi_a, (
u8) val);
221 silence_ref =
max(silence_ref, val);
224 silence_rssi_a, silence_rssi_b, silence_rssi_c,
243 for (i = 1; i < 10; i++)
247 IWL_DEBUG_CALIB(priv,
"rx energy a %u, b %u, c %u, 10-bcn max/min %u\n",
253 if (false_alarms < min_false_alarms)
261 if ((false_alarms > max_false_alarms) &&
264 false_alarms, max_false_alarms);
274 }
else if (false_alarms < min_false_alarms) {
283 false_alarms, min_false_alarms,
335 if (false_alarms > min_false_alarms) {
350 }
else if ((false_alarms < min_false_alarms) &&
367 static int iwl_sens_auto_corr_ofdm(
struct iwl_priv *priv,
372 u32 false_alarms = norm_fa * 200 * 1024;
381 if (false_alarms > max_false_alarms) {
384 false_alarms, max_false_alarms);
404 else if (false_alarms < min_false_alarms) {
407 false_alarms, min_false_alarms);
426 min_false_alarms, false_alarms, max_false_alarms);
431 static void iwl_prepare_legacy_sensitivity_tbl(
struct iwl_priv *priv,
461 IWL_DEBUG_CALIB(priv,
"ofdm: ac %u mrc %u x1 %u mrc_x1 %u thresh %u\n",
472 static int iwl_sensitivity_write(
struct iwl_priv *priv)
487 iwl_prepare_legacy_sensitivity_tbl(priv, data, &
cmd.table[0]);
501 sizeof(
u16)*HD_TABLE_SIZE);
507 static int iwl_enhance_sensitivity_write(
struct iwl_priv *priv)
522 iwl_prepare_legacy_sensitivity_tbl(priv, data, &
cmd.enhance_table[0]);
524 if (priv->
cfg->base_params->hd_v2) {
577 sizeof(
u16)*HD_TABLE_SIZE) &&
587 sizeof(
u16)*HD_TABLE_SIZE);
590 sizeof(
u16)*ENHANCE_HD_TABLE_ENTRIES);
622 for (i = 0; i < 10; i++)
645 if (priv->
fw->enhance_sensitivity_table)
646 ret |= iwl_enhance_sensitivity_write(priv);
648 ret |= iwl_sensitivity_write(priv);
671 if (!iwl_is_any_associated(priv)) {
710 if (!rx_enable_time) {
747 norm_fa_ofdm = fa_ofdm + bad_plcp_ofdm;
748 norm_fa_cck = fa_cck + bad_plcp_cck;
750 IWL_DEBUG_CALIB(priv,
"cck: fa %u badp %u ofdm: fa %u badp %u\n", fa_cck,
751 bad_plcp_cck, fa_ofdm, bad_plcp_ofdm);
753 iwl_sens_auto_corr_ofdm(priv, norm_fa_ofdm, rx_enable_time);
754 iwl_sens_energy_cck(priv, norm_fa_cck, rx_enable_time, &statis);
755 if (priv->
fw->enhance_sensitivity_table)
756 iwl_enhance_sensitivity_write(priv);
758 iwl_sensitivity_write(priv);
761 static inline u8 find_first_chain(
u8 mask)
774 static void iwl_find_disconn_antenna(
struct iwl_priv *priv,
u32* average_sig,
777 u32 active_chains = 0;
779 u16 max_average_sig_antenna_i;
788 if (average_sig[0] >= average_sig[1]) {
789 max_average_sig = average_sig[0];
790 max_average_sig_antenna_i = 0;
791 active_chains = (1 << max_average_sig_antenna_i);
793 max_average_sig = average_sig[1];
794 max_average_sig_antenna_i = 1;
795 active_chains = (1 << max_average_sig_antenna_i);
798 if (average_sig[2] >= max_average_sig) {
799 max_average_sig = average_sig[2];
800 max_average_sig_antenna_i = 2;
801 active_chains = (1 << max_average_sig_antenna_i);
805 average_sig[0], average_sig[1], average_sig[2]);
807 max_average_sig, max_average_sig_antenna_i);
811 if (i != max_average_sig_antenna_i) {
812 s32 rssi_delta = (max_average_sig - average_sig[
i]);
819 active_chains |= (1 <<
i);
821 "disconn_array[i] = %d\n",
842 u8 ant_msk = (1 <<
i);
850 if (num_tx_chains == priv->
hw_params.tx_chains_num &&
859 active_chains |=
BIT(first_chain);
861 "All Tx chains are disconnected W/A - declare %d as connected\n",
867 if (active_chains != priv->
eeprom_data->valid_rx_ant &&
870 "Detected that not all antennas are connected! "
871 "Connected: %#x, valid: %#x.\n",
881 static void iwlagn_gain_computation(
struct iwl_priv *priv,
882 u32 average_noise[NUM_RX_CHAINS],
898 delta_g = (priv->
cfg->base_params->chain_noise_scale *
899 ((
s32)average_noise[default_chain] -
900 (
s32)average_noise[
i])) / 1500;
927 iwl_set_calib_hdr(&
cmd.hdr,
1006 if ((rxon_chnum != stat_chnum) || (rxon_band24 != stat_band24)) {
1008 rxon_chnum, rxon_band24);
1043 chain_sig_a, chain_sig_b, chain_sig_c);
1045 chain_noise_a, chain_noise_b, chain_noise_c);
1054 if (priv->
cfg->bt_params &&
1055 priv->
cfg->bt_params->advanced_bt_coexist) {
1063 iwl_find_disconn_antenna(priv, average_sig, data);
1072 (average_noise[i] <= min_average_noise)) {
1075 min_average_noise = average_noise[
i];
1076 min_average_noise_antenna_i =
i;
1081 average_noise[0], average_noise[1],
1085 min_average_noise, min_average_noise_antenna_i);
1087 iwlagn_gain_computation(
1088 priv, average_noise,
1089 find_first_chain(priv->
eeprom_data->valid_rx_ant));