1
0
mirror of https://github.com/aircrack-ng/rtl8812au.git synced 2024-11-30 00:47:38 +00:00
rtl8812au/hal/phydm/halrf/halphyrf_ce.c

921 lines
30 KiB
C
Raw Normal View History

2018-06-22 16:48:32 +00:00
/******************************************************************************
*
2018-08-24 20:52:34 +00:00
* Copyright(c) 2007 - 2017 Realtek Corporation.
2018-06-22 16:48:32 +00:00
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2018-08-24 20:52:34 +00:00
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
2018-06-22 16:48:32 +00:00
* more details.
*
2018-08-24 20:52:34 +00:00
* The full GNU General Public License is included in this distribution in the
* file called LICENSE.
*
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
* Hsinchu 300, Taiwan.
*
* Larry Finger <Larry.Finger@lwfinger.net>
*
2018-06-22 16:48:32 +00:00
*****************************************************************************/
#include "mp_precomp.h"
#include "phydm_precomp.h"
2019-05-24 19:43:57 +00:00
#define CALCULATE_SWINGTALBE_OFFSET(_offset, _direction, _size, _delta_thermal)\
do { \
u32 __offset = (u32)_offset; \
u32 __size = (u32)_size; \
for (__offset = 0; __offset < __size; __offset++) { \
if (_delta_thermal < \
thermal_threshold[_direction][__offset]) { \
if (__offset != 0) \
__offset--; \
break; \
} \
} \
if (__offset >= __size) \
__offset = __size - 1; \
2018-06-22 16:48:32 +00:00
} while (0)
2019-05-24 19:43:57 +00:00
void configure_txpower_track(void *dm_void, struct txpwrtrack_cfg *config)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-06-22 16:48:32 +00:00
#if RTL8192E_SUPPORT
2018-08-24 20:52:34 +00:00
if (dm->support_ic_type == ODM_RTL8192E)
configure_txpower_track_8192e(config);
2018-06-22 16:48:32 +00:00
#endif
#if RTL8821A_SUPPORT
2018-08-24 20:52:34 +00:00
if (dm->support_ic_type == ODM_RTL8821)
configure_txpower_track_8821a(config);
2018-06-22 16:48:32 +00:00
#endif
#if RTL8812A_SUPPORT
2018-08-24 20:52:34 +00:00
if (dm->support_ic_type == ODM_RTL8812)
configure_txpower_track_8812a(config);
2018-06-22 16:48:32 +00:00
#endif
#if RTL8188E_SUPPORT
2018-08-24 20:52:34 +00:00
if (dm->support_ic_type == ODM_RTL8188E)
configure_txpower_track_8188e(config);
2018-06-22 16:48:32 +00:00
#endif
#if RTL8723B_SUPPORT
2018-08-24 20:52:34 +00:00
if (dm->support_ic_type == ODM_RTL8723B)
configure_txpower_track_8723b(config);
2018-06-22 16:48:32 +00:00
#endif
#if RTL8814A_SUPPORT
2018-08-24 20:52:34 +00:00
if (dm->support_ic_type == ODM_RTL8814A)
configure_txpower_track_8814a(config);
2018-06-22 16:48:32 +00:00
#endif
#if RTL8703B_SUPPORT
2018-08-24 20:52:34 +00:00
if (dm->support_ic_type == ODM_RTL8703B)
configure_txpower_track_8703b(config);
2018-06-22 16:48:32 +00:00
#endif
#if RTL8188F_SUPPORT
2018-08-24 20:52:34 +00:00
if (dm->support_ic_type == ODM_RTL8188F)
configure_txpower_track_8188f(config);
2018-06-22 16:48:32 +00:00
#endif
#if RTL8723D_SUPPORT
2018-08-24 20:52:34 +00:00
if (dm->support_ic_type == ODM_RTL8723D)
configure_txpower_track_8723d(config);
2018-06-22 16:48:32 +00:00
#endif
2019-05-24 19:43:57 +00:00
/*@ JJ ADD 20161014 */
2018-06-22 16:48:32 +00:00
#if RTL8710B_SUPPORT
2018-08-24 20:52:34 +00:00
if (dm->support_ic_type == ODM_RTL8710B)
configure_txpower_track_8710b(config);
2018-06-22 16:48:32 +00:00
#endif
#if RTL8822B_SUPPORT
2018-08-24 20:52:34 +00:00
if (dm->support_ic_type == ODM_RTL8822B)
configure_txpower_track_8822b(config);
2018-06-22 16:48:32 +00:00
#endif
#if RTL8821C_SUPPORT
2018-08-24 20:52:34 +00:00
if (dm->support_ic_type == ODM_RTL8821C)
configure_txpower_track_8821c(config);
2018-06-22 16:48:32 +00:00
#endif
2019-05-24 19:43:57 +00:00
#if RTL8192F_SUPPORT
if (dm->support_ic_type == ODM_RTL8192F)
configure_txpower_track_8192f(config);
#endif
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
/*@ **********************************************************************
2018-06-22 16:48:32 +00:00
* <20121113, Kordan> This function should be called when tx_agc changed.
* Otherwise the previous compensation is gone, because we record the
* delta of temperature between two TxPowerTracking watch dogs.
*
* NOTE: If Tx BB swing or Tx scaling is varified during run-time, still
* need to call this function.
2019-05-24 19:43:57 +00:00
* **********************************************************************
*/
void odm_clear_txpowertracking_state(void *dm_void)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct _hal_rf_ *rf = &dm->rf_table;
u8 p = 0;
struct dm_rf_calibration_struct *cali_info = &dm->rf_calibrate_info;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
cali_info->bb_swing_idx_cck_base = cali_info->default_cck_index;
cali_info->bb_swing_idx_cck = cali_info->default_cck_index;
dm->rf_calibrate_info.CCK_index = 0;
2018-06-22 16:48:32 +00:00
for (p = RF_PATH_A; p < MAX_RF_PATH; ++p) {
2019-05-24 19:43:57 +00:00
cali_info->bb_swing_idx_ofdm_base[p]
= cali_info->default_ofdm_index;
2018-08-24 20:52:34 +00:00
cali_info->bb_swing_idx_ofdm[p] = cali_info->default_ofdm_index;
cali_info->OFDM_index[p] = cali_info->default_ofdm_index;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
cali_info->power_index_offset[p] = 0;
cali_info->delta_power_index[p] = 0;
cali_info->delta_power_index_last[p] = 0;
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
/* Initial Mix mode power tracking*/
cali_info->absolute_ofdm_swing_idx[p] = 0;
2018-08-24 20:52:34 +00:00
cali_info->remnant_ofdm_swing_idx[p] = 0;
cali_info->kfree_offset[p] = 0;
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
/* Initial Mix mode power tracking*/
cali_info->modify_tx_agc_flag_path_a = false;
cali_info->modify_tx_agc_flag_path_b = false;
cali_info->modify_tx_agc_flag_path_c = false;
cali_info->modify_tx_agc_flag_path_d = false;
2018-08-24 20:52:34 +00:00
cali_info->remnant_cck_swing_idx = 0;
2019-05-24 19:43:57 +00:00
cali_info->thermal_value = rf->eeprom_thermal;
cali_info->modify_tx_agc_value_cck = 0;
cali_info->modify_tx_agc_value_ofdm = 0;
}
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
void odm_get_tracking_table(void *dm_void, u8 thermal_value, u8 delta)
{
struct dm_struct *dm = (struct dm_struct *)dm_void;
struct dm_rf_calibration_struct *cali_info = &dm->rf_calibrate_info;
struct _hal_rf_ *rf = &dm->rf_table;
struct txpwrtrack_cfg c = {0};
u8 p;
/* 4 1. TWO tables decide the final index of OFDM/CCK swing table. */
u8 *pwrtrk_tab_up_a = NULL;
u8 *pwrtrk_tab_down_a = NULL;
u8 *pwrtrk_tab_up_b = NULL;
u8 *pwrtrk_tab_down_b = NULL;
/*for 8814 add by Yu Chen*/
u8 *pwrtrk_tab_up_c = NULL;
u8 *pwrtrk_tab_down_c = NULL;
u8 *pwrtrk_tab_up_d = NULL;
u8 *pwrtrk_tab_down_d = NULL;
/*for Xtal Offset by James.Tung*/
s8 *xtal_tab_up = NULL;
s8 *xtal_tab_down = NULL;
configure_txpower_track(dm, &c);
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
(*c.get_delta_swing_table)(dm,
(u8 **)&pwrtrk_tab_up_a,
(u8 **)&pwrtrk_tab_down_a,
(u8 **)&pwrtrk_tab_up_b,
(u8 **)&pwrtrk_tab_down_b);
if (dm->support_ic_type & ODM_RTL8814A) /*for 8814 path C & D*/
(*c.get_delta_swing_table8814only)(dm,
(u8 **)&pwrtrk_tab_up_c,
(u8 **)&pwrtrk_tab_down_c,
(u8 **)&pwrtrk_tab_up_d,
(u8 **)&pwrtrk_tab_down_d);
/*for Xtal Offset*/
if (dm->support_ic_type &
(ODM_RTL8703B | ODM_RTL8723D | ODM_RTL8710B | ODM_RTL8192F))
(*c.get_delta_swing_xtal_table)(dm,
(s8 **)&xtal_tab_up,
(s8 **)&xtal_tab_down);
if (thermal_value > rf->eeprom_thermal) {
for (p = RF_PATH_A; p < c.rf_path_count; p++) {
/*recording power index offset*/
cali_info->delta_power_index_last[p] =
cali_info->delta_power_index[p];
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"******Temp is higher******\n");
switch (p) {
case RF_PATH_B:
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"pwrtrk_tab_up_b[%d] = %d\n", delta,
pwrtrk_tab_up_b[delta]);
cali_info->delta_power_index[p] =
pwrtrk_tab_up_b[delta];
cali_info->absolute_ofdm_swing_idx[p] =
pwrtrk_tab_up_b[delta];
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"absolute_ofdm_swing_idx[PATH_B] = %d\n",
cali_info->absolute_ofdm_swing_idx[p]);
break;
case RF_PATH_C:
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"pwrtrk_tab_up_c[%d] = %d\n", delta,
pwrtrk_tab_up_c[delta]);
cali_info->delta_power_index[p] =
pwrtrk_tab_up_c[delta];
cali_info->absolute_ofdm_swing_idx[p] =
pwrtrk_tab_up_c[delta];
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"absolute_ofdm_swing_idx[PATH_C] = %d\n",
cali_info->absolute_ofdm_swing_idx[p]);
break;
case RF_PATH_D:
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"pwrtrk_tab_up_d[%d] = %d\n", delta,
pwrtrk_tab_up_d[delta]);
cali_info->delta_power_index[p] =
pwrtrk_tab_up_d[delta];
cali_info->absolute_ofdm_swing_idx[p] =
pwrtrk_tab_up_d[delta];
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"absolute_ofdm_swing_idx[PATH_D] = %d\n",
cali_info->absolute_ofdm_swing_idx[p]);
break;
default:
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"pwrtrk_tab_up_a[%d] = %d\n", delta,
pwrtrk_tab_up_a[delta]);
cali_info->delta_power_index[p] =
pwrtrk_tab_up_a[delta];
cali_info->absolute_ofdm_swing_idx[p] =
pwrtrk_tab_up_a[delta];
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"absolute_ofdm_swing_idx[PATH_A] = %d\n",
cali_info->absolute_ofdm_swing_idx[p]);
break;
}
}
/* @JJ ADD 20161014 */
/*Save xtal_offset from Xtal table*/
if (dm->support_ic_type &
(ODM_RTL8703B | ODM_RTL8723D | ODM_RTL8710B |
ODM_RTL8192F)) {
/*recording last Xtal offset*/
cali_info->xtal_offset_last = cali_info->xtal_offset;
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"[Xtal] xtal_tab_up[%d] = %d\n",
delta, xtal_tab_up[delta]);
cali_info->xtal_offset = xtal_tab_up[delta];
if (cali_info->xtal_offset_last != xtal_tab_up[delta])
cali_info->xtal_offset_eanble = 1;
}
} else {
for (p = RF_PATH_A; p < c.rf_path_count; p++) {
/*recording power index offset*/
cali_info->delta_power_index_last[p] =
cali_info->delta_power_index[p];
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"******Temp is lower******\n");
switch (p) {
case RF_PATH_B:
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"pwrtrk_tab_down_b[%d] = %d\n", delta,
pwrtrk_tab_down_b[delta]);
cali_info->delta_power_index[p] =
-1 * pwrtrk_tab_down_b[delta];
cali_info->absolute_ofdm_swing_idx[p] =
-1 * pwrtrk_tab_down_b[delta];
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"absolute_ofdm_swing_idx[PATH_B] = %d\n",
cali_info->absolute_ofdm_swing_idx[p]);
break;
case RF_PATH_C:
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"pwrtrk_tab_down_c[%d] = %d\n", delta,
pwrtrk_tab_down_c[delta]);
cali_info->delta_power_index[p] =
-1 * pwrtrk_tab_down_c[delta];
cali_info->absolute_ofdm_swing_idx[p] =
-1 * pwrtrk_tab_down_c[delta];
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"absolute_ofdm_swing_idx[PATH_C] = %d\n",
cali_info->absolute_ofdm_swing_idx[p]);
break;
case RF_PATH_D:
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"pwrtrk_tab_down_d[%d] = %d\n", delta,
pwrtrk_tab_down_d[delta]);
cali_info->delta_power_index[p] =
-1 * pwrtrk_tab_down_d[delta];
cali_info->absolute_ofdm_swing_idx[p] =
-1 * pwrtrk_tab_down_d[delta];
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"absolute_ofdm_swing_idx[PATH_D] = %d\n",
cali_info->absolute_ofdm_swing_idx[p]);
break;
default:
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"pwrtrk_tab_down_a[%d] = %d\n", delta,
pwrtrk_tab_down_a[delta]);
cali_info->delta_power_index[p] =
-1 * pwrtrk_tab_down_a[delta];
cali_info->absolute_ofdm_swing_idx[p] =
-1 * pwrtrk_tab_down_a[delta];
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"absolute_ofdm_swing_idx[PATH_A] = %d\n",
cali_info->absolute_ofdm_swing_idx[p]);
break;
}
}
/* @JJ ADD 20161014 */
if (dm->support_ic_type &
(ODM_RTL8703B | ODM_RTL8723D | ODM_RTL8710B |
ODM_RTL8192F)) {
/*recording last Xtal offset*/
cali_info->xtal_offset_last = cali_info->xtal_offset;
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"[Xtal] xtal_tab_down[%d] = %d\n", delta,
xtal_tab_down[delta]);
/*Save xtal_offset from Xtal table*/
cali_info->xtal_offset = xtal_tab_down[delta];
if (cali_info->xtal_offset_last != xtal_tab_down[delta])
cali_info->xtal_offset_eanble = 1;
}
}
}
void odm_pwrtrk_method(void *dm_void)
{
struct dm_struct *dm = (struct dm_struct *)dm_void;
u8 p, idxforchnl = 0;
struct txpwrtrack_cfg c = {0};
configure_txpower_track(dm, &c);
if (dm->support_ic_type &
(ODM_RTL8188E | ODM_RTL8192E | ODM_RTL8821 | ODM_RTL8812 |
ODM_RTL8723B | ODM_RTL8814A | ODM_RTL8703B | ODM_RTL8188F |
ODM_RTL8822B | ODM_RTL8723D | ODM_RTL8821C | ODM_RTL8710B |
ODM_RTL8192F)) {
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"***Enter PwrTrk MIX_MODE***\n");
for (p = RF_PATH_A; p < c.rf_path_count; p++)
(*c.odm_tx_pwr_track_set_pwr)(dm, MIX_MODE, p, 0);
} else {
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"***Enter PwrTrk BBSWING_MODE***\n");
for (p = RF_PATH_A; p < c.rf_path_count; p++)
(*c.odm_tx_pwr_track_set_pwr)
(dm, BBSWING, p, idxforchnl);
}
2018-06-22 16:48:32 +00:00
}
#if (DM_ODM_SUPPORT_TYPE & ODM_AP)
2019-05-24 19:43:57 +00:00
void odm_txpowertracking_callback_thermal_meter(struct dm_struct *dm)
2018-08-24 20:52:34 +00:00
#elif (DM_ODM_SUPPORT_TYPE == ODM_CE)
2019-05-24 19:43:57 +00:00
void odm_txpowertracking_callback_thermal_meter(void *dm_void)
2018-06-22 16:48:32 +00:00
#else
2019-05-24 19:43:57 +00:00
void odm_txpowertracking_callback_thermal_meter(void *adapter)
2018-06-22 16:48:32 +00:00
#endif
{
#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
2019-05-24 19:43:57 +00:00
HAL_DATA_TYPE *hal_data = GET_HAL_DATA(((PADAPTER)adapter));
struct dm_struct *dm = &hal_data->DM_OutSrc;
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE == ODM_CE)
2018-08-24 20:52:34 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-06-22 16:48:32 +00:00
#endif
2019-05-24 19:43:57 +00:00
struct _hal_rf_ *rf = &dm->rf_table;
struct dm_rf_calibration_struct *cali_info = &dm->rf_calibrate_info;
struct dm_iqk_info *iqk_info = &dm->IQK_info;
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
u8 thermal_value = 0, delta, delta_lck, delta_iqk, p = 0, i = 0;
u8 thermal_value_avg_count = 0;
u32 thermal_value_avg = 0, regc80, regcd0, regcd4, regab4;
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
/* OFDM BB Swing should be less than +3.0dB, required by Arthur */
#if 0
u8 OFDM_min_index = 0;
2018-06-22 16:48:32 +00:00
#endif
2019-05-24 19:43:57 +00:00
#if 0
/* get_right_chnl_place_for_iqk(hal_data->current_channel) */
#endif
u8 power_tracking_type = rf->pwt_type;
s8 thermal_value_temp = 0;
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
struct txpwrtrack_cfg c = {0};
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
/* @4 2. Initialization ( 7 steps in total ) */
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
configure_txpower_track(dm, &c);
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
cali_info->txpowertracking_callback_cnt++;
2018-08-24 20:52:34 +00:00
cali_info->is_txpowertracking_init = true;
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"\n\n\n===>%s bbsw_idx_cck_base=%d\n",
__func__, cali_info->bb_swing_idx_cck_base);
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"bbsw_idx_ofdm_base[A]=%d default_ofdm_idx=%d\n",
cali_info->bb_swing_idx_ofdm_base[RF_PATH_A],
cali_info->default_ofdm_index);
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"cali_info->txpowertrack_control=%d, rf->eeprom_thermal %d\n",
cali_info->txpowertrack_control, rf->eeprom_thermal);
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
/* 0x42: RF Reg[15:10] 88E */
thermal_value =
(u8)odm_get_rf_reg(dm, RF_PATH_A, c.thermal_reg_addr, 0xfc00);
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
thermal_value_temp = thermal_value + phydm_get_thermal_offset(dm);
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"thermal_value_temp(%d) = ther_value(%d) + pwr_trim_ther(%d)\n",
thermal_value_temp, thermal_value,
phydm_get_thermal_offset(dm));
2018-06-22 16:48:32 +00:00
if (thermal_value_temp > 63)
thermal_value = 63;
else if (thermal_value_temp < 0)
thermal_value = 0;
else
thermal_value = thermal_value_temp;
2019-05-24 19:43:57 +00:00
/*@add log by zhao he, check c80/c94/c14/ca0 value*/
if (dm->support_ic_type &
(ODM_RTL8723D | ODM_RTL8710B)) {
regc80 = odm_get_bb_reg(dm, R_0xc80, MASKDWORD);
regcd0 = odm_get_bb_reg(dm, R_0xcd0, MASKDWORD);
regcd4 = odm_get_bb_reg(dm, R_0xcd4, MASKDWORD);
regab4 = odm_get_bb_reg(dm, R_0xab4, 0x000007FF);
RF_DBG(dm, DBG_RF_IQK,
"0xc80 = 0x%x 0xcd0 = 0x%x 0xcd4 = 0x%x 0xab4 = 0x%x\n",
regc80, regcd0, regcd4, regab4);
2018-06-22 16:48:32 +00:00
}
2018-08-24 20:52:34 +00:00
if (!cali_info->txpowertrack_control)
2018-06-22 16:48:32 +00:00
return;
2019-05-24 19:43:57 +00:00
if (rf->eeprom_thermal == 0xff) {
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"no pg, hal_data->eeprom_thermal_meter = 0x%x\n",
rf->eeprom_thermal);
2018-06-22 16:48:32 +00:00
return;
}
2019-05-24 19:43:57 +00:00
/*@4 3. Initialize ThermalValues of rf_calibrate_info*/
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
if (cali_info->is_reloadtxpowerindex)
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"reload ofdm index for band switch\n");
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
/*@4 4. Calculate average thermal meter*/
cali_info->thermal_value_avg[cali_info->thermal_value_avg_index]
= thermal_value;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
cali_info->thermal_value_avg_index++;
2019-05-24 19:43:57 +00:00
/*Average times = c.average_thermal_num*/
if (cali_info->thermal_value_avg_index == c.average_thermal_num)
2018-08-24 20:52:34 +00:00
cali_info->thermal_value_avg_index = 0;
2018-06-22 16:48:32 +00:00
for (i = 0; i < c.average_thermal_num; i++) {
2018-08-24 20:52:34 +00:00
if (cali_info->thermal_value_avg[i]) {
thermal_value_avg += cali_info->thermal_value_avg[i];
2018-06-22 16:48:32 +00:00
thermal_value_avg_count++;
}
}
2019-05-24 19:43:57 +00:00
/* Calculate Average thermal_value after average enough times */
if (thermal_value_avg_count) {
thermal_value =
(u8)(thermal_value_avg / thermal_value_avg_count);
cali_info->thermal_value_delta
= thermal_value - rf->eeprom_thermal;
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"AVG Thermal Meter = 0x%X, EFUSE Thermal base = 0x%X\n",
thermal_value, rf->eeprom_thermal);
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
/* @4 5. Calculate delta, delta_lck, delta_iqk. */
/* "delta" here is used to determine thermal value changes or not. */
if (thermal_value > cali_info->thermal_value)
delta = thermal_value - cali_info->thermal_value;
else
delta = cali_info->thermal_value - thermal_value;
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
if (thermal_value > cali_info->thermal_value_lck)
delta_lck = thermal_value - cali_info->thermal_value_lck;
else
delta_lck = cali_info->thermal_value_lck - thermal_value;
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
if (thermal_value > cali_info->thermal_value_iqk)
delta_iqk = thermal_value - cali_info->thermal_value_iqk;
else
delta_iqk = cali_info->thermal_value_iqk - thermal_value;
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"(delta, delta_lck, delta_iqk) = (%d, %d, %d)\n", delta,
delta_lck, delta_iqk);
/*@4 6. If necessary, do LCK.*/
/* Wait sacn to do LCK by RF Jenyu*/
if (!(*dm->is_scan_in_process) && !iqk_info->rfk_forbidden) {
/* Delta temperature is equal to or larger than 20 centigrade.*/
if (delta_lck >= c.threshold_iqk) {
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"delta_lck(%d) >= threshold_iqk(%d)\n",
delta_lck, c.threshold_iqk);
2018-08-24 20:52:34 +00:00
cali_info->thermal_value_lck = thermal_value;
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
/*Use RTLCK, close power tracking driver LCK*/
/*8821 don't do LCK*/
if (!(dm->support_ic_type &
(ODM_RTL8821 | ODM_RTL8814A | ODM_RTL8822B)) &&
c.phy_lc_calibrate) {
2018-08-24 20:52:34 +00:00
(*c.phy_lc_calibrate)(dm);
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"do pwrtrk lck\n");
2018-06-22 16:48:32 +00:00
}
}
}
2019-05-24 19:43:57 +00:00
/*@3 7. If necessary, move the index of swing table to adjust Tx power.*/
/* "delta" here is used to record the absolute value of difference. */
2018-08-24 20:52:34 +00:00
if (delta > 0 && cali_info->txpowertrack_control) {
2019-05-24 19:43:57 +00:00
if (thermal_value > rf->eeprom_thermal)
delta = thermal_value - rf->eeprom_thermal;
else
delta = rf->eeprom_thermal - thermal_value;
2018-06-22 16:48:32 +00:00
if (delta >= TXPWR_TRACK_TABLE_SIZE)
delta = TXPWR_TRACK_TABLE_SIZE - 1;
2019-05-24 19:43:57 +00:00
odm_get_tracking_table(dm, thermal_value, delta);
2018-06-22 16:48:32 +00:00
for (p = RF_PATH_A; p < c.rf_path_count; p++) {
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"\n[path-%d] Calculate pwr_idx_offset\n", p);
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
/*If Thermal value changes but table value is the same*/
if (cali_info->delta_power_index[p] ==
cali_info->delta_power_index_last[p])
2018-08-24 20:52:34 +00:00
cali_info->power_index_offset[p] = 0;
2018-06-22 16:48:32 +00:00
else
2019-05-24 19:43:57 +00:00
cali_info->power_index_offset[p] =
cali_info->delta_power_index[p] -
cali_info->delta_power_index_last[p];
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"path-%d pwridx_diff%d=pwr_idx%d - last_idx%d\n",
p, cali_info->power_index_offset[p],
cali_info->delta_power_index[p],
cali_info->delta_power_index_last[p]);
#if 0
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
cali_info->OFDM_index[p] = cali_info->bb_swing_idx_ofdm_base[p] + cali_info->power_index_offset[p];
cali_info->CCK_index = cali_info->bb_swing_idx_cck_base + cali_info->power_index_offset[p];
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
cali_info->bb_swing_idx_cck = cali_info->CCK_index;
cali_info->bb_swing_idx_ofdm[p] = cali_info->OFDM_index[p];
2018-06-22 16:48:32 +00:00
/*************Print BB Swing base and index Offset*************/
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"The 'CCK' final index(%d) = BaseIndex(%d) + power_index_offset(%d)\n",
cali_info->bb_swing_idx_cck,
cali_info->bb_swing_idx_cck_base,
cali_info->power_index_offset[p]);
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"The 'OFDM' final index(%d) = BaseIndex[%d](%d) + power_index_offset(%d)\n",
cali_info->bb_swing_idx_ofdm[p], p,
cali_info->bb_swing_idx_ofdm_base[p],
cali_info->power_index_offset[p]);
2018-06-22 16:48:32 +00:00
/*4 7.1 Handle boundary conditions of index.*/
2018-08-24 20:52:34 +00:00
if (cali_info->OFDM_index[p] > c.swing_table_size_ofdm - 1)
cali_info->OFDM_index[p] = c.swing_table_size_ofdm - 1;
else if (cali_info->OFDM_index[p] <= OFDM_min_index)
cali_info->OFDM_index[p] = OFDM_min_index;
2019-05-24 19:43:57 +00:00
#endif
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
#if 0
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"\n\n========================================================================================================\n");
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
if (cali_info->CCK_index > c.swing_table_size_cck - 1)
cali_info->CCK_index = c.swing_table_size_cck - 1;
else if (cali_info->CCK_index <= 0)
cali_info->CCK_index = 0;
2019-05-24 19:43:57 +00:00
#endif
2018-06-22 16:48:32 +00:00
} else {
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"Thermal is unchanged thermal=%d last_thermal=%d\n",
thermal_value,
cali_info->thermal_value);
2018-06-22 16:48:32 +00:00
for (p = RF_PATH_A; p < c.rf_path_count; p++)
2018-08-24 20:52:34 +00:00
cali_info->power_index_offset[p] = 0;
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
#if 0
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"TxPowerTracking: [CCK] Swing Current index: %d, Swing base index: %d\n",
cali_info->CCK_index,
cali_info->bb_swing_idx_cck_base); /*Print Swing base & current*/
2018-06-22 16:48:32 +00:00
for (p = RF_PATH_A; p < c.rf_path_count; p++) {
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"TxPowerTracking: [OFDM] Swing Current index: %d, Swing base index[%d]: %d\n",
cali_info->OFDM_index[p], p,
cali_info->bb_swing_idx_ofdm_base[p]);
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
#endif
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
if ((dm->support_ic_type & ODM_RTL8814A)) {
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_TX_PWR_TRACK, "power_tracking_type=%d\n",
power_tracking_type);
2018-06-22 16:48:32 +00:00
if (power_tracking_type == 0) {
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"***Enter PwrTrk MIX_MODE***\n");
2018-06-22 16:48:32 +00:00
for (p = RF_PATH_A; p < c.rf_path_count; p++)
2019-05-24 19:43:57 +00:00
(*c.odm_tx_pwr_track_set_pwr)
(dm, MIX_MODE, p, 0);
2018-06-22 16:48:32 +00:00
} else if (power_tracking_type == 1) {
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"***Enter PwrTrk MIX(2G) TSSI(5G) MODE***\n");
2018-06-22 16:48:32 +00:00
for (p = RF_PATH_A; p < c.rf_path_count; p++)
2019-05-24 19:43:57 +00:00
(*c.odm_tx_pwr_track_set_pwr)
(dm, MIX_2G_TSSI_5G_MODE, p, 0);
2018-06-22 16:48:32 +00:00
} else if (power_tracking_type == 2) {
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"***Enter PwrTrk MIX(5G) TSSI(2G)MODE***\n");
2018-06-22 16:48:32 +00:00
for (p = RF_PATH_A; p < c.rf_path_count; p++)
2019-05-24 19:43:57 +00:00
(*c.odm_tx_pwr_track_set_pwr)
(dm, MIX_5G_TSSI_2G_MODE, p, 0);
2018-06-22 16:48:32 +00:00
} else if (power_tracking_type == 3) {
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"***Enter PwrTrk TSSI MODE***\n");
2018-06-22 16:48:32 +00:00
for (p = RF_PATH_A; p < c.rf_path_count; p++)
2019-05-24 19:43:57 +00:00
(*c.odm_tx_pwr_track_set_pwr)
(dm, TSSI_MODE, p, 0);
2018-06-22 16:48:32 +00:00
}
2018-08-24 20:52:34 +00:00
} else if ((cali_info->power_index_offset[RF_PATH_A] != 0 ||
2019-05-24 19:43:57 +00:00
cali_info->power_index_offset[RF_PATH_B] != 0 ||
cali_info->power_index_offset[RF_PATH_C] != 0 ||
cali_info->power_index_offset[RF_PATH_D] != 0)) {
#if 0
2018-06-22 16:48:32 +00:00
/* 4 7.2 Configure the Swing Table to adjust Tx Power. */
2019-05-24 19:43:57 +00:00
/*Always true after Tx Power is adjusted by power tracking.*/
cali_info->is_tx_power_changed = true;
/* 2012/04/23 MH According to Luke's suggestion, we can not write BB digital
* to increase TX power. Otherwise, EVM will be bad.
*
* 2012/04/25 MH Add for tx power tracking to set tx power in tx agc for 88E.
*/
2018-08-24 20:52:34 +00:00
if (thermal_value > cali_info->thermal_value) {
2018-06-22 16:48:32 +00:00
for (p = RF_PATH_A; p < c.rf_path_count; p++) {
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"Temperature Increasing(%d): delta_pi: %d, delta_t: %d, Now_t: %d, EFUSE_t: %d, Last_t: %d\n",
p, cali_info->power_index_offset[p],
delta, thermal_value, rf->eeprom_thermal,
cali_info->thermal_value);
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
} else if (thermal_value < cali_info->thermal_value) { /*Low temperature*/
2018-06-22 16:48:32 +00:00
for (p = RF_PATH_A; p < c.rf_path_count; p++) {
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"Temperature Decreasing(%d): delta_pi: %d, delta_t: %d, Now_t: %d, EFUSE_t: %d, Last_t: %d\n",
p, cali_info->power_index_offset[p],
delta, thermal_value, rf->eeprom_thermal,
cali_info->thermal_value);
2018-06-22 16:48:32 +00:00
}
}
2019-05-24 19:43:57 +00:00
#endif
2018-06-22 16:48:32 +00:00
#if !(DM_ODM_SUPPORT_TYPE & ODM_AP)
2019-05-24 19:43:57 +00:00
if (thermal_value > rf->eeprom_thermal) {
2018-06-22 16:48:32 +00:00
#else
2019-05-24 19:43:57 +00:00
if (thermal_value > dm->priv->pmib->dot11RFEntry.ther) {
2018-06-22 16:48:32 +00:00
#endif
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"Temperature(%d) higher than PG value(%d)\n",
thermal_value, rf->eeprom_thermal);
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
odm_pwrtrk_method(dm);
2018-06-22 16:48:32 +00:00
} else {
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"Temperature(%d) lower than PG value(%d)\n",
thermal_value, rf->eeprom_thermal);
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
odm_pwrtrk_method(dm);
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
#if 0
/*Record last time Power Tracking result as base.*/
cali_info->bb_swing_idx_cck_base = cali_info->bb_swing_idx_cck;
2018-06-22 16:48:32 +00:00
for (p = RF_PATH_A; p < c.rf_path_count; p++)
2018-08-24 20:52:34 +00:00
cali_info->bb_swing_idx_ofdm_base[p] = cali_info->bb_swing_idx_ofdm[p];
2018-06-22 16:48:32 +00:00
#endif
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"cali_info->thermal_value = %d thermal_value= %d\n",
cali_info->thermal_value, thermal_value);
}
/*Record last Power Tracking Thermal value*/
cali_info->thermal_value = thermal_value;
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
if (dm->support_ic_type &
(ODM_RTL8703B | ODM_RTL8723D | ODM_RTL8192F | ODM_RTL8710B)) {
if (cali_info->xtal_offset_eanble != 0 &&
cali_info->txpowertrack_control &&
rf->eeprom_thermal != 0xff) {
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"**********Enter Xtal Tracking**********\n");
2018-06-22 16:48:32 +00:00
#if !(DM_ODM_SUPPORT_TYPE & ODM_AP)
2019-05-24 19:43:57 +00:00
if (thermal_value > rf->eeprom_thermal) {
2018-06-22 16:48:32 +00:00
#else
2018-08-24 20:52:34 +00:00
if (thermal_value > dm->priv->pmib->dot11RFEntry.ther) {
2018-06-22 16:48:32 +00:00
#endif
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"Temperature(%d) higher than PG (%d)\n",
thermal_value, rf->eeprom_thermal);
2018-08-24 20:52:34 +00:00
(*c.odm_txxtaltrack_set_xtal)(dm);
2018-06-22 16:48:32 +00:00
} else {
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"Temperature(%d) lower than PG (%d)\n",
thermal_value, rf->eeprom_thermal);
2018-08-24 20:52:34 +00:00
(*c.odm_txxtaltrack_set_xtal)(dm);
2018-06-22 16:48:32 +00:00
}
}
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"**********End Xtal Tracking**********\n");
2018-06-22 16:48:32 +00:00
}
#if !(DM_ODM_SUPPORT_TYPE & ODM_AP)
/* Wait sacn to do IQK by RF Jenyu*/
2019-05-24 19:43:57 +00:00
if (!(*dm->is_scan_in_process) && !iqk_info->rfk_forbidden &&
!cali_info->is_iqk_in_progress) {
if (!(dm->support_ic_type & ODM_RTL8723B)) {
/*Delta temperature is equal or larger than 20 Celsius*/
/*When threshold is 8*/
if (delta_iqk >= c.threshold_iqk) {
2018-08-24 20:52:34 +00:00
cali_info->thermal_value_iqk = thermal_value;
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"delta_iqk(%d) >= threshold_iqk(%d)\n",
delta_iqk, c.threshold_iqk);
(*c.do_iqk)(dm, delta_iqk, thermal_value, 8);
RF_DBG(dm, DBG_RF_TX_PWR_TRACK,
"do pwrtrk iqk\n");
2018-06-22 16:48:32 +00:00
}
}
}
2019-05-24 19:43:57 +00:00
#if 0
2018-08-24 20:52:34 +00:00
if (cali_info->dpk_thermal[RF_PATH_A] != 0) {
2018-06-22 16:48:32 +00:00
if (diff_DPK[RF_PATH_A] >= c.threshold_dpk) {
2019-05-24 19:43:57 +00:00
odm_set_bb_reg(dm, R_0x82c, BIT(31), 0x1);
odm_set_bb_reg(dm, R_0xcc4, BIT(14) | BIT(13) | BIT(12) | BIT(11) | BIT(10), (diff_DPK[RF_PATH_A] / c.threshold_dpk));
odm_set_bb_reg(dm, R_0x82c, BIT(31), 0x0);
2018-06-22 16:48:32 +00:00
} else if ((diff_DPK[RF_PATH_A] <= -1 * c.threshold_dpk)) {
s32 value = 0x20 + (diff_DPK[RF_PATH_A] / c.threshold_dpk);
2019-05-24 19:43:57 +00:00
odm_set_bb_reg(dm, R_0x82c, BIT(31), 0x1);
odm_set_bb_reg(dm, R_0xcc4, BIT(14) | BIT(13) | BIT(12) | BIT(11) | BIT(10), value);
odm_set_bb_reg(dm, R_0x82c, BIT(31), 0x0);
2018-06-22 16:48:32 +00:00
} else {
2019-05-24 19:43:57 +00:00
odm_set_bb_reg(dm, R_0x82c, BIT(31), 0x1);
odm_set_bb_reg(dm, R_0xcc4, BIT(14) | BIT(13) | BIT(12) | BIT(11) | BIT(10), 0);
odm_set_bb_reg(dm, R_0x82c, BIT(31), 0x0);
2018-06-22 16:48:32 +00:00
}
}
2018-08-24 20:52:34 +00:00
if (cali_info->dpk_thermal[RF_PATH_B] != 0) {
2018-06-22 16:48:32 +00:00
if (diff_DPK[RF_PATH_B] >= c.threshold_dpk) {
2019-05-24 19:43:57 +00:00
odm_set_bb_reg(dm, R_0x82c, BIT(31), 0x1);
odm_set_bb_reg(dm, R_0xec4, BIT(14) | BIT(13) | BIT(12) | BIT(11) | BIT(10), (diff_DPK[RF_PATH_B] / c.threshold_dpk));
odm_set_bb_reg(dm, R_0x82c, BIT(31), 0x0);
2018-06-22 16:48:32 +00:00
} else if ((diff_DPK[RF_PATH_B] <= -1 * c.threshold_dpk)) {
s32 value = 0x20 + (diff_DPK[RF_PATH_B] / c.threshold_dpk);
2019-05-24 19:43:57 +00:00
odm_set_bb_reg(dm, R_0x82c, BIT(31), 0x1);
odm_set_bb_reg(dm, R_0xec4, BIT(14) | BIT(13) | BIT(12) | BIT(11) | BIT(10), value);
odm_set_bb_reg(dm, R_0x82c, BIT(31), 0x0);
2018-06-22 16:48:32 +00:00
} else {
2019-05-24 19:43:57 +00:00
odm_set_bb_reg(dm, R_0x82c, BIT(31), 0x1);
odm_set_bb_reg(dm, R_0xec4, BIT(14) | BIT(13) | BIT(12) | BIT(11) | BIT(10), 0);
odm_set_bb_reg(dm, R_0x82c, BIT(31), 0x0);
2018-06-22 16:48:32 +00:00
}
}
2019-05-24 19:43:57 +00:00
#endif
2018-06-22 16:48:32 +00:00
#endif
2019-05-24 19:43:57 +00:00
RF_DBG(dm, DBG_RF_TX_PWR_TRACK, "<===%s\n", __func__);
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
cali_info->tx_powercount = 0;
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
/*@3============================================================
2018-06-22 16:48:32 +00:00
* 3 IQ Calibration
2019-05-24 19:43:57 +00:00
* 3============================================================
*/
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
void odm_reset_iqk_result(void *dm_void)
2018-06-22 16:48:32 +00:00
{
}
2019-05-24 19:43:57 +00:00
2018-06-22 16:48:32 +00:00
#if !(DM_ODM_SUPPORT_TYPE & ODM_AP)
u8 odm_get_right_chnl_place_for_iqk(u8 chnl)
{
2019-05-24 19:43:57 +00:00
u8 channel_all[ODM_TARGET_CHNL_NUM_2G_5G] = {
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64,
100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122,
124, 126, 128, 130, 132, 134, 136, 138, 140,
149, 151, 153, 155, 157, 159, 161, 163, 165};
u8 place = chnl;
2018-06-22 16:48:32 +00:00
if (chnl > 14) {
for (place = 14; place < sizeof(channel_all); place++) {
if (channel_all[place] == chnl)
return place - 13;
}
}
return 0;
}
#endif
2019-05-24 19:43:57 +00:00
void odm_iq_calibrate(struct dm_struct *dm)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
void *adapter = dm->adapter;
struct dm_iqk_info *iqk_info = &dm->IQK_info;
2018-06-22 16:48:32 +00:00
#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
2018-08-24 20:52:34 +00:00
if (*dm->is_fcs_mode_enable)
2018-06-22 16:48:32 +00:00
return;
#endif
#if (DM_ODM_SUPPORT_TYPE & (ODM_CE))
if (IS_HARDWARE_TYPE_8812AU(adapter))
return;
#endif
2019-05-24 19:43:57 +00:00
if (dm->is_linked && !iqk_info->rfk_forbidden) {
if ((*dm->channel != dm->pre_channel) &&
(!*dm->is_scan_in_process)) {
2018-08-24 20:52:34 +00:00
dm->pre_channel = *dm->channel;
dm->linked_interval = 0;
2018-06-22 16:48:32 +00:00
}
2018-08-24 20:52:34 +00:00
if (dm->linked_interval < 3)
dm->linked_interval++;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
if (dm->linked_interval == 2)
halrf_iqk_trigger(dm, false);
2019-05-24 19:43:57 +00:00
} else {
2018-08-24 20:52:34 +00:00
dm->linked_interval = 0;
2019-05-24 19:43:57 +00:00
}
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
void phydm_rf_init(void *dm_void)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-08-24 20:52:34 +00:00
odm_txpowertracking_init(dm);
2018-06-22 16:48:32 +00:00
#if (DM_ODM_SUPPORT_TYPE & (ODM_WIN | ODM_CE))
2018-08-24 20:52:34 +00:00
odm_clear_txpowertracking_state(dm);
2018-06-22 16:48:32 +00:00
#endif
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
#if (RTL8814A_SUPPORT == 1)
2018-08-24 20:52:34 +00:00
if (dm->support_ic_type & ODM_RTL8814A)
phy_iq_calibrate_8814a_init(dm);
2018-06-22 16:48:32 +00:00
#endif
#endif
}
2019-05-24 19:43:57 +00:00
void phydm_rf_watchdog(void *dm_void)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-06-22 16:48:32 +00:00
#if (DM_ODM_SUPPORT_TYPE & (ODM_WIN | ODM_CE))
2018-08-24 20:52:34 +00:00
odm_txpowertracking_check(dm);
2019-05-24 19:43:57 +00:00
#if 0
/*if (dm->support_ic_type & ODM_IC_11AC_SERIES)*/
/*odm_iq_calibrate(dm);*/
#endif
2018-06-22 16:48:32 +00:00
#endif
}