Skip to content

Commit

Permalink
Add OpenHD channel overrides, and power overides but #if 0'd out
Browse files Browse the repository at this point in the history
  • Loading branch information
peteallenm committed Aug 9, 2024
1 parent 7e7a495 commit c7e1c51
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
4 changes: 4 additions & 0 deletions include/drv_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -2230,4 +2230,8 @@ int rtw_suspend_free_assoc_resource(_adapter *padapter);
#include <pci_hal.h>
#endif

// OpenHD crda workaround
int get_openhd_override_channel(void);
int get_openhd_override_tx_power_mbm(void);

#endif /* __DRV_TYPES_H__ */
27 changes: 25 additions & 2 deletions os_dep/linux/ioctl_cfg80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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"
Expand All @@ -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);
Expand Down
14 changes: 14 additions & 0 deletions os_dep/linux/os_intfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
}

0 comments on commit c7e1c51

Please sign in to comment.