mtwifi-cfg: add support for mtk dbdc chip cfgs

This commit is contained in:
hanwckf 2023-12-08 00:20:27 +08:00
parent f7eaac3baf
commit 202f16e915
4 changed files with 54 additions and 3 deletions

View File

@ -109,6 +109,12 @@ function cfg2dat(cfg)
end
end
function set_dev_dat(dats, dat, cfg)
if cfg ~= nil then
dats[dat] = cfg2dat(cfg)
end
end
function set_dat(dats, apidx, dat, cfg)
if cfg ~= nil then
dats[dat] = utils.token_set(dats[dat], apidx, cfg2dat(cfg))
@ -227,6 +233,39 @@ function mtwifi_cfg_iwpriv_hook(cfg)
end
end
function set_chip_cfg(cfg, dats)
local dev_dats
local uci
local dat_key
if not cfg.config.dbdc_main then return end
for k,v in pairs(defs.chip_cfgs) do
uci = k
dat_key = v[1]
-- reset chip cfgs to default
dats[dat_key] = v[2]
-- setup current dev cfg
set_dev_dat(dats, dat_key, cfg.config[uci])
end
-- setup other dev cfg
for k,v in pairs(l1dat.devname_ridx) do
if k ~= cfg.device then
dev_dats = load_profile(v.profile_path)
if dev_dats then
for _,j in pairs(defs.chip_cfgs) do
dat_key = j[1]
set_dev_dat(dev_dats, dat_key, dats[dat_key])
end
save_profile(dev_dats, v.profile_path)
end
end
end
end
function mtwifi_cfg_setup(argv)
local cfg = cjson.decode(argv)
@ -291,6 +330,9 @@ function mtwifi_cfg_setup(argv)
end
end
-- setup chip cfgs
set_chip_cfg(cfg, dats)
-- setup dev cfgs
if cfg.config.twt then
dats.TWTSupport = cfg.config.twt

View File

@ -81,6 +81,12 @@ mtwifi_defs.vif_acl = {
["AccessControlList"] = "",
}
mtwifi_defs.chip_cfgs = {
-- uci config = dat config, default value
["beacon_int"] = { "BeaconPeriod" , "100"},
["dtim_period"] = { "DtimPeriod", "1"},
}
mtwifi_defs.reinstall_cfgs = {
"BssidNum", "WHNAT", "E2pAccessMode",
"HT_RxStream", "HT_TxStream", "WdsEnable"

View File

@ -7,7 +7,7 @@ append DRIVERS "mtwifi"
detect_mtwifi() {
local idx ifname
local band hwmode htmode htbsscoex ssid
local band hwmode htmode htbsscoex ssid dbdc_main
if [ -d "/sys/module/mt_wifi" ]; then
dev_list="$(l1util list)"
for dev in $dev_list; do
@ -21,12 +21,14 @@ detect_mtwifi() {
htmode="HE40"
htbsscoex="1"
ssid="ImmortalWrt-2.4G"
dbdc_main="1"
else
band="5g"
hwmode="11a"
htmode="HE160"
htbsscoex="0"
ssid="ImmortalWrt-5G"
dbdc_main="0"
fi
uci -q batch <<-EOF
set wireless.${dev}=wifi-device
@ -34,6 +36,7 @@ detect_mtwifi() {
set wireless.${dev}.phy=${ifname}
set wireless.${dev}.hwmode=${hwmode}
set wireless.${dev}.band=${band}
set wireless.${dev}.dbdc_main=${dbdc_main}
set wireless.${dev}.channel=auto
set wireless.${dev}.txpower=100
set wireless.${dev}.htmode=${htmode}

View File

@ -14,8 +14,8 @@ MTWIFI_MAX_APCLI_IDX=0
MTWIFI_CFG_IFNAME_KEY="mtwifi_ifname"
drv_mtwifi_init_device_config() {
config_add_int txpower
config_add_boolean mu_beamformer
config_add_int txpower beacon_int dtim_period
config_add_boolean mu_beamformer dbdc_main
config_add_string country twt
}