From c7e1c5102e6aa144ba80a7dbbfd5ec1ebb4aab06 Mon Sep 17 00:00:00 2001 From: Pete A Date: Fri, 9 Aug 2024 22:32:38 +0100 Subject: [PATCH] Add OpenHD channel overrides, and power overides but #if 0'd out --- include/drv_types.h | 4 ++++ os_dep/linux/ioctl_cfg80211.c | 27 +++++++++++++++++++++++++-- os_dep/linux/os_intfs.c | 14 ++++++++++++++ 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/include/drv_types.h b/include/drv_types.h index 2e49c32..f5a7b1c 100644 --- a/include/drv_types.h +++ b/include/drv_types.h @@ -2230,4 +2230,8 @@ int rtw_suspend_free_assoc_resource(_adapter *padapter); #include #endif +// OpenHD crda workaround +int get_openhd_override_channel(void); +int get_openhd_override_tx_power_mbm(void); + #endif /* __DRV_TYPES_H__ */ diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index ea294e8..788af3f 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -4815,6 +4815,7 @@ static int cfg80211_rtw_set_txpower(struct wiphy *wiphy, struct rtw_wiphy_data *wiphy_data = rtw_wiphy_priv(wiphy); _adapter *adapter = wiphy_to_adapter(wiphy); int ret = -EOPNOTSUPP; + int openhd_override_tx_power_mbm=0; #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0)) if (wdev) { @@ -4862,6 +4863,19 @@ static int cfg80211_rtw_set_txpower(struct wiphy *wiphy, default: RTW_WARN(FUNC_WIPHY_FMT" unknown type:%d\n", FUNC_WIPHY_ARG(wiphy), type); } +// OpenHD +#if 0 + openhd_override_tx_power_mbm=get_openhd_override_tx_power_mbm(); + if(openhd_override_tx_power_mbm){ + wiphy_data->txpwr_total_lmt_mbm = UNSPECIFIED_MBM; + wiphy_data->txpwr_total_target_mbm= openhd_override_tx_power_mbm; + // If the chip cannot do the requested tx power, the driver just seems to set tx power index 63" + RTW_WARN("Using openhd_override_tx_power_mbm %d",openhd_override_tx_power_mbm); + } + #endif + RTW_WARN(FUNC_WIPHY_FMT" OpenHD cf80211 tx power %s txpwr_total_lmt_mbm:%d txpwr_total_target_mbm%d openhd_override_tx_power_mbm:%d\n", FUNC_WIPHY_ARG(wiphy) + , nl80211_tx_power_setting_str(type), wiphy_data->txpwr_total_lmt_mbm,wiphy_data->txpwr_total_target_mbm, + openhd_override_tx_power_mbm); if (ret == 0) rtw_run_in_thread_cmd_wait(adapter, ((void *)(rtw_update_txpwr_level_all_hwband)), adapter_to_dvobj(adapter), 2000); @@ -7312,6 +7326,7 @@ static int cfg80211_rtw_set_monitor_channel(struct wiphy *wiphy _adapter *padapter = wiphy_to_adapter(wiphy); u8 target_channal, target_offset, target_width, ht_option; + int openhd_override_channel=0; #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0)) #ifdef CONFIG_DEBUG_CFG80211 RTW_INFO("center_freq %u Mhz ch %u width %u freq1 %u freq2 %u\n" @@ -7335,9 +7350,17 @@ static int cfg80211_rtw_set_monitor_channel(struct wiphy *wiphy rtw_get_chbw_from_nl80211_channel_type(chan, channel_type, &ht_option, &target_channal, &target_width, &target_offset); #endif - RTW_INFO(FUNC_ADPT_FMT" ch:%d bw:%d, offset:%d\n", + openhd_override_channel=get_openhd_override_channel(); + if(openhd_override_channel){ + target_channal=openhd_override_channel; + RTW_WARN("OpenHD: using openhd_override_channel"); + } + + if(true){ + RTW_WARN(FUNC_ADPT_FMT" ch:%d bw:%d, offset:%d OpenHD channel debug override:%d\n", FUNC_ADPT_ARG(padapter), target_channal, - target_width, target_offset); + target_width, target_offset,openhd_override_channel); + } rtw_set_chbw_cmd(padapter, target_channal, target_width, target_offset, RTW_CMDF_WAIT_ACK); diff --git a/os_dep/linux/os_intfs.c b/os_dep/linux/os_intfs.c index 423ba2c..31a0b34 100644 --- a/os_dep/linux/os_intfs.c +++ b/os_dep/linux/os_intfs.c @@ -1139,6 +1139,13 @@ static void rtw_regsty_load_tx_ac_lifetime(struct registry_priv *regsty) } } #endif +// OpenHD params +int openhd_override_channel = 0; +module_param(openhd_override_channel, int, 0644); +MODULE_PARM_DESC(openhd_override_channel, "OpenHD easy (CRDA workaround)"); +int openhd_override_tx_power_mbm = 0; +module_param(openhd_override_tx_power_mbm, int, 0644); +MODULE_PARM_DESC(openhd_override_tx_power_mbm, "OpenHD easy (CRDA workaround)"); void rtw_regsty_load_target_tx_power(struct registry_priv *regsty) { @@ -5985,3 +5992,10 @@ int rtw_vendor_ie_set_api(struct net_device *dev, char *extra) EXPORT_SYMBOL(rtw_vendor_ie_set_api); #endif + +int get_openhd_override_channel(void){ + return openhd_override_channel; +} +int get_openhd_override_tx_power_mbm(void){ + return openhd_override_tx_power_mbm; +}