#include "odm_precomp.h"
void ConfigureTxpowerTrack(struct dm_odm_t *pDM_Odm, struct txpwrtrack_cfg *pConfig)
{
ConfigureTxpowerTrack_8723B(pConfig);
}
void ODM_ClearTxPowerTrackingState(struct dm_odm_t *pDM_Odm)
{
struct hal_com_data *pHalData = GET_HAL_DATA(pDM_Odm->Adapter);
u8 p = 0;
pDM_Odm->BbSwingIdxCckBase = pDM_Odm->DefaultCckIndex;
pDM_Odm->BbSwingIdxCck = pDM_Odm->DefaultCckIndex;
pDM_Odm->RFCalibrateInfo.CCK_index = 0;
for (p = RF_PATH_A; p < MAX_RF_PATH; ++p) {
pDM_Odm->BbSwingIdxOfdmBase[p] = pDM_Odm->DefaultOfdmIndex;
pDM_Odm->BbSwingIdxOfdm[p] = pDM_Odm->DefaultOfdmIndex;
pDM_Odm->RFCalibrateInfo.OFDM_index[p] = pDM_Odm->DefaultOfdmIndex;
pDM_Odm->RFCalibrateInfo.PowerIndexOffset[p] = 0;
pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[p] = 0;
pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[p] = 0;
pDM_Odm->RFCalibrateInfo.PowerIndexOffset[p] = 0;
pDM_Odm->Absolute_OFDMSwingIdx[p] = 0;
pDM_Odm->Remnant_OFDMSwingIdx[p] = 0;
}
pDM_Odm->Modify_TxAGC_Flag_PathA = false;
pDM_Odm->Modify_TxAGC_Flag_PathB = false;
pDM_Odm->Remnant_CCKSwingIdx = 0;
pDM_Odm->RFCalibrateInfo.ThermalValue = pHalData->EEPROMThermalMeter;
pDM_Odm->RFCalibrateInfo.ThermalValue_IQK = pHalData->EEPROMThermalMeter;
pDM_Odm->RFCalibrateInfo.ThermalValue_LCK = pHalData->EEPROMThermalMeter;
}
void ODM_TXPowerTrackingCallback_ThermalMeter(struct adapter *Adapter)
{
struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
u8 ThermalValue = 0, delta, delta_LCK, p = 0, i = 0;
u8 ThermalValue_AVG_count = 0;
u32 ThermalValue_AVG = 0;
u8 OFDM_min_index = 0;
u8 Indexforchannel = 0;
struct txpwrtrack_cfg c;
u8 *deltaSwingTableIdx_TUP_A;
u8 *deltaSwingTableIdx_TDOWN_A;
u8 *deltaSwingTableIdx_TUP_B;
u8 *deltaSwingTableIdx_TDOWN_B;
ConfigureTxpowerTrack(pDM_Odm, &c);
(*c.GetDeltaSwingTable)(
pDM_Odm,
(u8 **)&deltaSwingTableIdx_TUP_A,
(u8 **)&deltaSwingTableIdx_TDOWN_A,
(u8 **)&deltaSwingTableIdx_TUP_B,
(u8 **)&deltaSwingTableIdx_TDOWN_B
);
pDM_Odm->RFCalibrateInfo.TXPowerTrackingCallbackCnt++;
pDM_Odm->RFCalibrateInfo.bTXPowerTrackingInit = true;
ThermalValue = (u8)PHY_QueryRFReg(pDM_Odm->Adapter, RF_PATH_A, c.ThermalRegAddr, 0xfc00);
if (
!pDM_Odm->RFCalibrateInfo.TxPowerTrackControl ||
pHalData->EEPROMThermalMeter == 0 ||
pHalData->EEPROMThermalMeter == 0xFF
)
return;
pDM_Odm->RFCalibrateInfo.ThermalValue_AVG[pDM_Odm->RFCalibrateInfo.ThermalValue_AVG_index] = ThermalValue;
pDM_Odm->RFCalibrateInfo.ThermalValue_AVG_index++;
if (pDM_Odm->RFCalibrateInfo.ThermalValue_AVG_index == c.AverageThermalNum)
pDM_Odm->RFCalibrateInfo.ThermalValue_AVG_index = 0;
for (i = 0; i < c.AverageThermalNum; i++) {
if (pDM_Odm->RFCalibrateInfo.ThermalValue_AVG[i]) {
ThermalValue_AVG += pDM_Odm->RFCalibrateInfo.ThermalValue_AVG[i];
ThermalValue_AVG_count++;
}
}
if (ThermalValue_AVG_count) {
ThermalValue = (u8)(ThermalValue_AVG / ThermalValue_AVG_count);
}
delta =
(ThermalValue > pDM_Odm->RFCalibrateInfo.ThermalValue) ?
(ThermalValue - pDM_Odm->RFCalibrateInfo.ThermalValue) :
(pDM_Odm->RFCalibrateInfo.ThermalValue - ThermalValue);
delta_LCK =
(ThermalValue > pDM_Odm->RFCalibrateInfo.ThermalValue_LCK) ?
(ThermalValue - pDM_Odm->RFCalibrateInfo.ThermalValue_LCK) :
(pDM_Odm->RFCalibrateInfo.ThermalValue_LCK - ThermalValue);
if (delta_LCK >= c.Threshold_IQK) {
pDM_Odm->RFCalibrateInfo.ThermalValue_LCK = ThermalValue;
if (c.PHY_LCCalibrate)
(*c.PHY_LCCalibrate)(pDM_Odm);
}
if (delta > 0 && pDM_Odm->RFCalibrateInfo.TxPowerTrackControl) {
delta =
ThermalValue > pHalData->EEPROMThermalMeter ?
(ThermalValue - pHalData->EEPROMThermalMeter) :
(pHalData->EEPROMThermalMeter - ThermalValue);
if (delta >= TXPWR_TRACK_TABLE_SIZE)
delta = TXPWR_TRACK_TABLE_SIZE - 1;
if (ThermalValue > pHalData->EEPROMThermalMeter) {
pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[RF_PATH_A] =
pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[RF_PATH_A];
pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[RF_PATH_A] =
deltaSwingTableIdx_TUP_A[delta];
pDM_Odm->Absolute_OFDMSwingIdx[RF_PATH_A] =
deltaSwingTableIdx_TUP_A[delta];
if (c.RfPathCount > 1) {
pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[RF_PATH_B] =
pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[RF_PATH_B];
pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[RF_PATH_B] =
deltaSwingTableIdx_TUP_B[delta];
pDM_Odm->Absolute_OFDMSwingIdx[RF_PATH_B] =
deltaSwingTableIdx_TUP_B[delta];
}
} else {
pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[RF_PATH_A] =
pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[RF_PATH_A];
pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[RF_PATH_A] =
-1 * deltaSwingTableIdx_TDOWN_A[delta];
pDM_Odm->Absolute_OFDMSwingIdx[RF_PATH_A] =
-1 * deltaSwingTableIdx_TDOWN_A[delta];
if (c.RfPathCount > 1) {
pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[RF_PATH_B] =
pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[RF_PATH_B];
pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[RF_PATH_B] =
-1 * deltaSwingTableIdx_TDOWN_B[delta];
pDM_Odm->Absolute_OFDMSwingIdx[RF_PATH_B] =
-1 * deltaSwingTableIdx_TDOWN_B[delta];
}
}
for (p = RF_PATH_A; p < c.RfPathCount; p++) {
if (
pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[p] ==
pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[p]
)
pDM_Odm->RFCalibrateInfo.PowerIndexOffset[p] = 0;
else
pDM_Odm->RFCalibrateInfo.PowerIndexOffset[p] = pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[p] - pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[p];
pDM_Odm->RFCalibrateInfo.OFDM_index[p] =
pDM_Odm->BbSwingIdxOfdmBase[p] +
pDM_Odm->RFCalibrateInfo.PowerIndexOffset[p];
pDM_Odm->RFCalibrateInfo.CCK_index =
pDM_Odm->BbSwingIdxCckBase +
pDM_Odm->RFCalibrateInfo.PowerIndexOffset[p];
pDM_Odm->BbSwingIdxCck =
pDM_Odm->RFCalibrateInfo.CCK_index;
pDM_Odm->BbSwingIdxOfdm[p] =
pDM_Odm->RFCalibrateInfo.OFDM_index[p];
if (pDM_Odm->RFCalibrateInfo.OFDM_index[p] > c.SwingTableSize_OFDM-1)
pDM_Odm->RFCalibrateInfo.OFDM_index[p] = c.SwingTableSize_OFDM-1;
else if (pDM_Odm->RFCalibrateInfo.OFDM_index[p] < OFDM_min_index)
pDM_Odm->RFCalibrateInfo.OFDM_index[p] = OFDM_min_index;
}
if (pDM_Odm->RFCalibrateInfo.CCK_index > c.SwingTableSize_CCK-1)
pDM_Odm->RFCalibrateInfo.CCK_index = c.SwingTableSize_CCK-1;
} else {
for (p = RF_PATH_A; p < c.RfPathCount; p++)
pDM_Odm->RFCalibrateInfo.PowerIndexOffset[p] = 0;
}
for (p = RF_PATH_A; p < c.RfPathCount; p++) {
}
if (
(pDM_Odm->RFCalibrateInfo.PowerIndexOffset[RF_PATH_A] != 0 ||
pDM_Odm->RFCalibrateInfo.PowerIndexOffset[RF_PATH_B] != 0) &&
pDM_Odm->RFCalibrateInfo.TxPowerTrackControl
) {
pDM_Odm->RFCalibrateInfo.bTxPowerChanged = true;
if (ThermalValue > pHalData->EEPROMThermalMeter) {
for (p = RF_PATH_A; p < c.RfPathCount; p++)
(*c.ODM_TxPwrTrackSetPwr)(pDM_Odm, MIX_MODE, p, 0);
} else {
for (p = RF_PATH_A; p < c.RfPathCount; p++)
(*c.ODM_TxPwrTrackSetPwr)(pDM_Odm, MIX_MODE, p, Indexforchannel);
}
pDM_Odm->BbSwingIdxCckBase = pDM_Odm->BbSwingIdxCck;
for (p = RF_PATH_A; p < c.RfPathCount; p++)
pDM_Odm->BbSwingIdxOfdmBase[p] = pDM_Odm->BbSwingIdxOfdm[p];
pDM_Odm->RFCalibrateInfo.ThermalValue = ThermalValue;
}
pDM_Odm->RFCalibrateInfo.TXPowercount = 0;
}