2022-06-08 23:46:35 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
/* Copyright(c) 2007 - 2011 Realtek Corporation. */
|
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* This file is for 92CE/92CU dynamic mechanism only */
|
2013-05-19 04:28:07 +00:00
|
|
|
#define _RTL8188E_DM_C_
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
#include "../include/osdep_service.h"
|
|
|
|
#include "../include/drv_types.h"
|
|
|
|
#include "../include/rtl8188e_hal.h"
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* Initialize GPIO setting registers */
|
2013-08-08 05:41:21 +00:00
|
|
|
static void dm_InitGPIOSetting(struct adapter *Adapter)
|
2013-05-19 04:28:07 +00:00
|
|
|
{
|
|
|
|
u8 tmp1byte;
|
|
|
|
|
|
|
|
tmp1byte = rtw_read8(Adapter, REG_GPIO_MUXCFG);
|
|
|
|
tmp1byte &= (GPIOSEL_GPIO | ~GPIOSEL_ENBT);
|
|
|
|
|
|
|
|
rtw_write8(Adapter, REG_GPIO_MUXCFG, tmp1byte);
|
|
|
|
}
|
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* */
|
|
|
|
/* functions */
|
|
|
|
/* */
|
2013-08-08 05:41:21 +00:00
|
|
|
static void Update_ODM_ComInfo_88E(struct adapter *Adapter)
|
2013-05-19 04:28:07 +00:00
|
|
|
{
|
|
|
|
struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv;
|
|
|
|
struct mlme_priv *pmlmepriv = &Adapter->mlmepriv;
|
|
|
|
struct pwrctrl_priv *pwrctrlpriv = &Adapter->pwrctrlpriv;
|
2022-06-08 23:46:35 +00:00
|
|
|
struct hal_data_8188e *hal_data = &Adapter->haldata;
|
|
|
|
struct odm_dm_struct *dm_odm = &hal_data->odmpriv;
|
2013-08-08 05:41:21 +00:00
|
|
|
struct dm_priv *pdmpriv = &hal_data->dmpriv;
|
2013-05-19 04:28:07 +00:00
|
|
|
int i;
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
pdmpriv->InitODMFlag = ODM_BB_RSSI_MONITOR;
|
2013-08-08 05:41:21 +00:00
|
|
|
if (hal_data->AntDivCfg)
|
2013-05-19 04:28:07 +00:00
|
|
|
pdmpriv->InitODMFlag |= ODM_BB_ANT_DIV;
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
dm_odm->SupportAbility = pdmpriv->InitODMFlag;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
dm_odm->pWirelessMode = &pmlmeext->cur_wireless_mode;
|
|
|
|
dm_odm->pSecChOffset = &hal_data->nCur40MhzPrimeSC;
|
|
|
|
dm_odm->pBandWidth = &hal_data->CurrentChannelBW;
|
|
|
|
dm_odm->pChannel = &hal_data->CurrentChannel;
|
|
|
|
dm_odm->pbScanInProcess = &pmlmepriv->bScanInProcess;
|
|
|
|
dm_odm->pbPowerSaving = &pwrctrlpriv->bpower_saving;
|
2013-08-08 05:41:21 +00:00
|
|
|
|
|
|
|
ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_RF_ANTENNA_TYPE, hal_data->TRxAntDivType);
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_STA; i++)
|
2022-06-08 23:46:35 +00:00
|
|
|
dm_odm->pODM_StaInfo[i] = NULL;
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
void rtl8188e_InitHalDm(struct adapter *Adapter)
|
2013-05-19 04:28:07 +00:00
|
|
|
{
|
2022-06-08 23:46:35 +00:00
|
|
|
struct hal_data_8188e *hal_data = &Adapter->haldata;
|
|
|
|
struct odm_dm_struct *dm_odm = &hal_data->odmpriv;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
|
|
|
dm_InitGPIOSetting(Adapter);
|
|
|
|
Update_ODM_ComInfo_88E(Adapter);
|
2013-08-08 05:41:21 +00:00
|
|
|
ODM_DMInit(dm_odm);
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
void rtl8188e_HalDmWatchDog(struct adapter *Adapter)
|
2013-05-19 04:28:07 +00:00
|
|
|
{
|
2022-06-08 23:46:35 +00:00
|
|
|
u8 hw_init_completed = Adapter->hw_init_completed;
|
|
|
|
struct hal_data_8188e *hal_data = &Adapter->haldata;
|
|
|
|
struct mlme_priv *pmlmepriv = &Adapter->mlmepriv;
|
|
|
|
u8 bLinked = false;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
if (!hw_init_completed)
|
2022-06-08 23:46:35 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if ((check_fwstate(pmlmepriv, WIFI_AP_STATE)) ||
|
|
|
|
(check_fwstate(pmlmepriv, WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE))) {
|
|
|
|
if (Adapter->stapriv.asoc_sta_count > 2)
|
|
|
|
bLinked = true;
|
|
|
|
} else {/* Station mode */
|
|
|
|
if (check_fwstate(pmlmepriv, _FW_LINKED))
|
|
|
|
bLinked = true;
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
hal_data->odmpriv.bLinked = bLinked;
|
|
|
|
ODM_DMWatchdog(&hal_data->odmpriv);
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
void rtl8188e_init_dm_priv(struct adapter *Adapter)
|
2013-05-19 04:28:07 +00:00
|
|
|
{
|
2022-06-08 23:46:35 +00:00
|
|
|
struct hal_data_8188e *hal_data = &Adapter->haldata;
|
2013-08-08 05:41:21 +00:00
|
|
|
struct dm_priv *pdmpriv = &hal_data->dmpriv;
|
2022-06-08 23:46:35 +00:00
|
|
|
struct odm_dm_struct *dm_odm = &hal_data->odmpriv;
|
2013-08-08 05:41:21 +00:00
|
|
|
|
2014-12-13 04:43:35 +00:00
|
|
|
memset(pdmpriv, 0, sizeof(struct dm_priv));
|
2022-06-08 23:46:35 +00:00
|
|
|
memset(dm_odm, 0, sizeof(*dm_odm));
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
dm_odm->Adapter = Adapter;
|
|
|
|
ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_MP_TEST_CHIP, IS_NORMAL_CHIP(hal_data->VersionID));
|
|
|
|
ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_RF_ANTENNA_TYPE, hal_data->TRxAntDivType);
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* Add new function to reset the state of antenna diversity before link. */
|
|
|
|
/* Compare RSSI for deciding antenna */
|
2013-08-08 05:41:21 +00:00
|
|
|
void AntDivCompare8188E(struct adapter *Adapter, struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src)
|
2013-05-19 04:28:07 +00:00
|
|
|
{
|
2022-06-08 23:46:35 +00:00
|
|
|
struct hal_data_8188e *hal_data = &Adapter->haldata;
|
2013-08-08 05:41:21 +00:00
|
|
|
|
|
|
|
if (0 != hal_data->AntDivCfg) {
|
2013-07-10 18:25:07 +00:00
|
|
|
/* select optimum_antenna for before linked =>For antenna diversity */
|
2013-08-08 05:41:21 +00:00
|
|
|
if (dst->Rssi >= src->Rssi) {/* keep org parameter */
|
2013-05-19 04:28:07 +00:00
|
|
|
src->Rssi = dst->Rssi;
|
|
|
|
src->PhyInfo.Optimum_antenna = dst->PhyInfo.Optimum_antenna;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* Add new function to reset the state of antenna diversity before link. */
|
2013-08-08 05:41:21 +00:00
|
|
|
u8 AntDivBeforeLink8188E(struct adapter *Adapter)
|
2013-05-19 04:28:07 +00:00
|
|
|
{
|
2022-06-08 23:46:35 +00:00
|
|
|
struct hal_data_8188e *hal_data = &Adapter->haldata;
|
2013-08-08 05:41:21 +00:00
|
|
|
struct odm_dm_struct *dm_odm = &hal_data->odmpriv;
|
|
|
|
struct sw_ant_switch *dm_swat_tbl = &dm_odm->DM_SWAT_Table;
|
2022-06-08 23:46:35 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &Adapter->mlmepriv;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* Condition that does not need to use antenna diversity. */
|
2013-08-08 05:41:21 +00:00
|
|
|
if (hal_data->AntDivCfg == 0)
|
2013-05-26 03:02:10 +00:00
|
|
|
return false;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
if (check_fwstate(pmlmepriv, _FW_LINKED))
|
2013-05-26 03:02:10 +00:00
|
|
|
return false;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
if (dm_swat_tbl->SWAS_NoLink_State == 0) {
|
2013-07-10 18:25:07 +00:00
|
|
|
/* switch channel */
|
2013-08-08 05:41:21 +00:00
|
|
|
dm_swat_tbl->SWAS_NoLink_State = 1;
|
|
|
|
dm_swat_tbl->CurAntenna = (dm_swat_tbl->CurAntenna == Antenna_A) ? Antenna_B : Antenna_A;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-08 05:41:21 +00:00
|
|
|
rtw_antenna_select_cmd(Adapter, dm_swat_tbl->CurAntenna, false);
|
2013-05-26 03:02:10 +00:00
|
|
|
return true;
|
2013-07-10 18:25:07 +00:00
|
|
|
} else {
|
2013-08-08 05:41:21 +00:00
|
|
|
dm_swat_tbl->SWAS_NoLink_State = 0;
|
2013-05-26 03:02:10 +00:00
|
|
|
return false;
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
|
|
|
}
|