From 632bfd75cd8ebd689f728f2231ad2bd3d34600b8 Mon Sep 17 00:00:00 2001 From: evilphish Date: Sat, 21 Oct 2017 19:52:27 +0200 Subject: [PATCH] preliminary txpower test --- hal/rtl8812a/rtl8812a_dm.c | 3 +++ os_dep/linux/ioctl_cfg80211.c | 27 ++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/hal/rtl8812a/rtl8812a_dm.c b/hal/rtl8812a/rtl8812a_dm.c index 8ab3799..36a7a3f 100644 --- a/hal/rtl8812a/rtl8812a_dm.c +++ b/hal/rtl8812a/rtl8812a_dm.c @@ -457,8 +457,11 @@ void rtl8812_init_dm_priv(IN PADAPTER Adapter) Init_ODM_ComInfo_8812(Adapter); ODM_InitAllTimers(podmpriv); + + pHalData->CurrentTxPwrIdx = 18; } + void rtl8812_deinit_dm_priv(IN PADAPTER Adapter) { PHAL_DATA_TYPE pHalData = GET_HAL_DATA(Adapter); diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index 0ae4ac9..603f6a6 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -3163,6 +3163,27 @@ static int cfg80211_rtw_set_txpower(struct wiphy *wiphy, enum tx_power_setting type, int dbm) #endif { + + _adapter *padapter = wiphy_to_adapter(wiphy); + HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); + int value; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) || defined(COMPAT_KERNEL_RELEASE) + value = mbm/100; +#else + value = dbm; +#endif + + if(value < 0) + value = 0; + if(value > 40) + value = 40; + + if(type == NL80211_TX_POWER_FIXED) { + pHalData->CurrentTxPwrIdx = value; + rtw_hal_set_tx_power_level(padapter, pHalData->CurrentChannel); + } else + return -EOPNOTSUPP; + #if 0 struct iwm_priv *iwm = wiphy_to_iwm(wiphy); int ret; @@ -3199,9 +3220,13 @@ static int cfg80211_rtw_get_txpower(struct wiphy *wiphy, #endif int *dbm) { + _adapter *padapter = wiphy_to_adapter(wiphy); + HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); + RTW_INFO("%s\n", __func__); - *dbm = (12); + *dbm = pHalData->CurrentTxPwrIdx; + //*dbm = (12); return 0; }