From 37d868fa936fa6f95379c5e7c00ead21d12b19ee Mon Sep 17 00:00:00 2001 From: kimocoder Date: Tue, 12 Feb 2019 18:51:41 +0100 Subject: [PATCH] Implemented txpower control --- README.md | 1 + hal/rtl8188e/rtl8188e_dm.c | 2 +- include/hal_data.h | 1 + os_dep/linux/ioctl_cfg80211.c | 26 +++++++++++++++++++++++++- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c14310c..4255af6 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ unmanaged-devices=mac:A7:A7:A7:A7:A7 * Finish the walkthrough of the base for understanding. * Fix a issue where the interface is down on startup * Fix the out of bounds reference +* Supress some debug messages (dmesg) about powersave * Add support for more platforms, RPI, generic ARM/ARM64, Odroid, PPC .. * There is a bug in monitor mode related to Network-Manager. diff --git a/hal/rtl8188e/rtl8188e_dm.c b/hal/rtl8188e/rtl8188e_dm.c index 8c3bb5b..30eab6e 100644 --- a/hal/rtl8188e/rtl8188e_dm.c +++ b/hal/rtl8188e/rtl8188e_dm.c @@ -305,7 +305,7 @@ void rtl8188e_init_dm_priv(IN PADAPTER Adapter) /* _rtw_spinlock_init(&(pHalData->odm_stainfo_lock)); */ Init_ODM_ComInfo_88E(Adapter); odm_init_all_timers(podmpriv); - + pHalData->CurrentTxPwrIdx = 13; } void rtl8188e_deinit_dm_priv(IN PADAPTER Adapter) diff --git a/include/hal_data.h b/include/hal_data.h index 0d3bb5e..35d7c2d 100755 --- a/include/hal_data.h +++ b/include/hal_data.h @@ -475,6 +475,7 @@ typedef struct hal_com_data { u8 txpwr_limit_loaded:1; u8 txpwr_limit_from_file:1; u8 rf_power_tracking_type; + u8 CurrentTxPwrIdx; /* Read/write are allow for following hardware information variables */ u8 crystal_cap; diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index 31e920d..b3abb41 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -3925,6 +3925,26 @@ 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->current_channel); +} else + return -EOPNOTSUPP; #if 0 struct iwm_priv *iwm = wiphy_to_iwm(wiphy); int ret; @@ -3961,9 +3981,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 = (12); + *dbm = pHalData->CurrentTxPwrIdx; return 0; }