bool rtw_chbw_to_freq_range(u8 ch, u8 bw, u8 offset, u32 *hi, u32 *lo) { u8 c_ch; u32 freq; u32 hi_ret = 0, lo_ret = 0; int i; bool valid = _FALSE; if (hi) *hi = 0; if (lo) *lo = 0; c_ch = rtw_get_center_ch(ch, bw, offset); freq = rtw_ch2freq(c_ch); if (!freq) { rtw_warn_on(1); goto exit; } if (bw == CHANNEL_WIDTH_80) { hi_ret = freq + 40; lo_ret = freq - 40; } else if (bw == CHANNEL_WIDTH_40) { hi_ret = freq + 20; lo_ret = freq - 20; } else if (bw == CHANNEL_WIDTH_20) { hi_ret = freq + 10; lo_ret = freq - 10; } else { rtw_warn_on(1); } if (hi) *hi = hi_ret; if (lo) *lo = lo_ret; valid = _TRUE; exit: return valid; }
static void _rtw_reg_apply_flags(struct wiphy *wiphy) { #if 1 /* by channel plan */ _adapter *padapter = wiphy_to_adapter(wiphy); u8 channel_plan = padapter->mlmepriv.ChannelPlan; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; RT_CHANNEL_INFO *channel_set = pmlmeext->channel_set; u8 max_chan_nums = pmlmeext->max_chan_nums; struct ieee80211_supported_band *sband; struct ieee80211_channel *ch; unsigned int i, j; u16 channel; u32 freq; /* all channels disable */ for (i = 0; i < NUM_NL80211_BANDS; i++) { sband = wiphy->bands[i]; if (sband) { for (j = 0; j < sband->n_channels; j++) { ch = &sband->channels[j]; if (ch) ch->flags = IEEE80211_CHAN_DISABLED; } } } /* channels apply by channel plans. */ for (i = 0; i < max_chan_nums; i++) { channel = channel_set[i].ChannelNum; freq = rtw_ch2freq(channel); ch = ieee80211_get_channel(wiphy, freq); if (ch) { if (channel_set[i].ScanType == SCAN_PASSIVE #if defined(CONFIG_DFS_MASTER) && rtw_odm_dfs_domain_unknown(wiphy_to_adapter(wiphy)) #endif ) { #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0)) ch->flags = (IEEE80211_CHAN_NO_IBSS | IEEE80211_CHAN_PASSIVE_SCAN); #else ch->flags = IEEE80211_CHAN_NO_IR; #endif } else ch->flags = 0; } } #else struct ieee80211_supported_band *sband; struct ieee80211_channel *ch; unsigned int i, j; u16 channels[37] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165 }; u16 channel; u32 freq; for (i = 0; i < NUM_NL80211_BANDS; i++) { sband = wiphy->bands[i]; if (sband) for (j = 0; j < sband->n_channels; j++) { ch = &sband->channels[j]; if (ch) ch->flags = IEEE80211_CHAN_DISABLED; } } for (i = 0; i < 37; i++) { channel = channels[i]; freq = rtw_ch2freq(channel); ch = ieee80211_get_channel(wiphy, freq); if (ch) { if (channel <= 11) ch->flags = 0; else ch->flags = 0; /* IEEE80211_CHAN_PASSIVE_SCAN; */ } /* printk("%s: freq %d(%d) flag 0x%02X\n", __func__, freq, channel, ch->flags); */ } #endif }