diff options
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-agn-calib.c')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-agn-calib.c | 65 |
1 files changed, 62 insertions, 3 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c index 02c7c65ee86a..72d6297602b8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c | |||
@@ -98,7 +98,7 @@ int iwl_send_calib_results(struct iwl_priv *priv) | |||
98 | hcmd.len[0] = priv->calib_results[i].buf_len; | 98 | hcmd.len[0] = priv->calib_results[i].buf_len; |
99 | hcmd.data[0] = priv->calib_results[i].buf; | 99 | hcmd.data[0] = priv->calib_results[i].buf; |
100 | hcmd.dataflags[0] = IWL_HCMD_DFL_NOCOPY; | 100 | hcmd.dataflags[0] = IWL_HCMD_DFL_NOCOPY; |
101 | ret = trans_send_cmd(priv, &hcmd); | 101 | ret = trans_send_cmd(&priv->trans, &hcmd); |
102 | if (ret) { | 102 | if (ret) { |
103 | IWL_ERR(priv, "Error %d iteration %d\n", | 103 | IWL_ERR(priv, "Error %d iteration %d\n", |
104 | ret, i); | 104 | ret, i); |
@@ -484,7 +484,7 @@ static int iwl_sensitivity_write(struct iwl_priv *priv) | |||
484 | memcpy(&(priv->sensitivity_tbl[0]), &(cmd.table[0]), | 484 | memcpy(&(priv->sensitivity_tbl[0]), &(cmd.table[0]), |
485 | sizeof(u16)*HD_TABLE_SIZE); | 485 | sizeof(u16)*HD_TABLE_SIZE); |
486 | 486 | ||
487 | return trans_send_cmd(priv, &cmd_out); | 487 | return trans_send_cmd(&priv->trans, &cmd_out); |
488 | } | 488 | } |
489 | 489 | ||
490 | /* Prepare a SENSITIVITY_CMD, send to uCode if values have changed */ | 490 | /* Prepare a SENSITIVITY_CMD, send to uCode if values have changed */ |
@@ -548,7 +548,7 @@ static int iwl_enhance_sensitivity_write(struct iwl_priv *priv) | |||
548 | &(cmd.enhance_table[HD_INA_NON_SQUARE_DET_OFDM_INDEX]), | 548 | &(cmd.enhance_table[HD_INA_NON_SQUARE_DET_OFDM_INDEX]), |
549 | sizeof(u16)*ENHANCE_HD_TABLE_ENTRIES); | 549 | sizeof(u16)*ENHANCE_HD_TABLE_ENTRIES); |
550 | 550 | ||
551 | return trans_send_cmd(priv, &cmd_out); | 551 | return trans_send_cmd(&priv->trans, &cmd_out); |
552 | } | 552 | } |
553 | 553 | ||
554 | void iwl_init_sensitivity(struct iwl_priv *priv) | 554 | void iwl_init_sensitivity(struct iwl_priv *priv) |
@@ -840,6 +840,65 @@ static void iwl_find_disconn_antenna(struct iwl_priv *priv, u32* average_sig, | |||
840 | active_chains); | 840 | active_chains); |
841 | } | 841 | } |
842 | 842 | ||
843 | static void iwlagn_gain_computation(struct iwl_priv *priv, | ||
844 | u32 average_noise[NUM_RX_CHAINS], | ||
845 | u16 min_average_noise_antenna_i, | ||
846 | u32 min_average_noise, | ||
847 | u8 default_chain) | ||
848 | { | ||
849 | int i; | ||
850 | s32 delta_g; | ||
851 | struct iwl_chain_noise_data *data = &priv->chain_noise_data; | ||
852 | |||
853 | /* | ||
854 | * Find Gain Code for the chains based on "default chain" | ||
855 | */ | ||
856 | for (i = default_chain + 1; i < NUM_RX_CHAINS; i++) { | ||
857 | if ((data->disconn_array[i])) { | ||
858 | data->delta_gain_code[i] = 0; | ||
859 | continue; | ||
860 | } | ||
861 | |||
862 | delta_g = (priv->cfg->base_params->chain_noise_scale * | ||
863 | ((s32)average_noise[default_chain] - | ||
864 | (s32)average_noise[i])) / 1500; | ||
865 | |||
866 | /* bound gain by 2 bits value max, 3rd bit is sign */ | ||
867 | data->delta_gain_code[i] = | ||
868 | min(abs(delta_g), | ||
869 | (long) CHAIN_NOISE_MAX_DELTA_GAIN_CODE); | ||
870 | |||
871 | if (delta_g < 0) | ||
872 | /* | ||
873 | * set negative sign ... | ||
874 | * note to Intel developers: This is uCode API format, | ||
875 | * not the format of any internal device registers. | ||
876 | * Do not change this format for e.g. 6050 or similar | ||
877 | * devices. Change format only if more resolution | ||
878 | * (i.e. more than 2 bits magnitude) is needed. | ||
879 | */ | ||
880 | data->delta_gain_code[i] |= (1 << 2); | ||
881 | } | ||
882 | |||
883 | IWL_DEBUG_CALIB(priv, "Delta gains: ANT_B = %d ANT_C = %d\n", | ||
884 | data->delta_gain_code[1], data->delta_gain_code[2]); | ||
885 | |||
886 | if (!data->radio_write) { | ||
887 | struct iwl_calib_chain_noise_gain_cmd cmd; | ||
888 | |||
889 | memset(&cmd, 0, sizeof(cmd)); | ||
890 | |||
891 | iwl_set_calib_hdr(&cmd.hdr, | ||
892 | priv->phy_calib_chain_noise_gain_cmd); | ||
893 | cmd.delta_gain_1 = data->delta_gain_code[1]; | ||
894 | cmd.delta_gain_2 = data->delta_gain_code[2]; | ||
895 | trans_send_cmd_pdu(&priv->trans, REPLY_PHY_CALIBRATION_CMD, | ||
896 | CMD_ASYNC, sizeof(cmd), &cmd); | ||
897 | |||
898 | data->radio_write = 1; | ||
899 | data->state = IWL_CHAIN_NOISE_CALIBRATED; | ||
900 | } | ||
901 | } | ||
843 | 902 | ||
844 | /* | 903 | /* |
845 | * Accumulate 16 beacons of signal and noise statistics for each of | 904 | * Accumulate 16 beacons of signal and noise statistics for each of |