diff --git a/hal/rtl8812a/rtl8812a_dm.c b/hal/rtl8812a/rtl8812a_dm.c index 5c62e4e..377505e 100755 --- a/hal/rtl8812a/rtl8812a_dm.c +++ b/hal/rtl8812a/rtl8812a_dm.c @@ -496,6 +496,7 @@ void rtl8812_init_dm_priv(IN PADAPTER Adapter) PHYDM_InitDebugSetting(podmpriv); pHalData->TxPwrInPercentage = TX_PWR_PERCENTAGE_3; + pHalData->CurrentTxPwrIdx = 18; } diff --git a/hal/rtl8812a/rtl8812a_phycfg.c b/hal/rtl8812a/rtl8812a_phycfg.c index 8f7a4d8..675b908 100755 --- a/hal/rtl8812a/rtl8812a_phycfg.c +++ b/hal/rtl8812a/rtl8812a_phycfg.c @@ -546,7 +546,8 @@ phy_TxPwrAdjInPercentage( if(*pTxPwrIdx > RF6052_MAX_TX_PWR) *pTxPwrIdx = RF6052_MAX_TX_PWR; - + +#if 0 // // NEC Spec: dB = 10*log(X/Y), X: target value, Y: default value. // For example: TxPower 50%, 10*log(50/100)=(nearly)-3dB @@ -564,7 +565,9 @@ phy_TxPwrAdjInPercentage( { *pTxPwrIdx -=6; } - +#endif + *pTxPwrIdx += pHalData->CurrentTxPwrIdx; + *pTxPwrIdx -= 18; if(*pTxPwrIdx > RF6052_MAX_TX_PWR) // Avoid underflow condition. *pTxPwrIdx = RF6052_MAX_TX_PWR; } @@ -720,7 +723,7 @@ PHY_GetTxPowerIndex_8812A( if ( txPower % 2 == 1 && !IS_NORMAL_CHIP(pHalData->VersionID)) --txPower; - //DBG_871X("Final Tx Power(RF-%c, Channel: %d) = %d(0x%X)\n", ((RFPath==0)?'A':'B'), Channel,txPower, txPower); + DBG_871X("Final Tx Power(RF-%c, Channel: %d) = %d(0x%X)\n", ((RFPath==0)?'A':'B'), Channel,txPower, txPower); return (u8) txPower; } diff --git a/include/hal_data.h b/include/hal_data.h index 4145af7..d616ef7 100644 --- a/include/hal_data.h +++ b/include/hal_data.h @@ -386,6 +386,7 @@ typedef struct hal_com_data u8 CurrentOfdm24GTxPwrIdx; u8 CurrentBW2024GTxPwrIdx; u8 CurrentBW4024GTxPwrIdx; + u8 CurrentTxPwrIdx; // Read/write are allow for following hardware information variables u8 pwrGroupCnt; diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index cca0c0d..fc2b40d 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -32,6 +32,7 @@ #endif /* Linux kernel >= 4.0.0 */ #include +#include #define RTW_MAX_MGMT_TX_CNT (8) #define RTW_MAX_MGMT_TX_MS_GAS (500) @@ -3441,11 +3442,25 @@ static int cfg80211_rtw_set_txpower(struct wiphy *wiphy, struct wireless_dev *wdev, #endif #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) || defined(COMPAT_KERNEL_RELEASE) - enum nl80211_tx_power_setting type, int mbm) + enum nl80211_tx_power_setting type, #else - enum tx_power_setting type, int dbm) + enum tx_power_setting type, #endif + int value) { + _adapter *padapter = wiphy_to_adapter(wiphy); + HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) || defined(COMPAT_KERNEL_RELEASE) + value /= 100; +#endif + + if(value < 0) + value = 0; + if(value > 40) + value = 40; + + pHalData->CurrentTxPwrIdx = value; + #if 0 struct iwm_priv *iwm = wiphy_to_iwm(wiphy); int ret; @@ -3472,7 +3487,6 @@ static int cfg80211_rtw_set_txpower(struct wiphy *wiphy, return -EOPNOTSUPP; } #endif - DBG_8192C("%s\n", __func__); return 0; } @@ -3482,9 +3496,10 @@ static int cfg80211_rtw_get_txpower(struct wiphy *wiphy, #endif int *dbm) { - DBG_8192C("%s\n", __func__); + _adapter *padapter = wiphy_to_adapter(wiphy); + HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); - *dbm = (12); + *dbm = pHalData->CurrentTxPwrIdx; return 0; }