broadcom-wl: add default tx and rx antennas
[15.05/openwrt.git] / package / kernel / broadcom-wl / files / lib / wifi / broadcom.sh
index 9416f77..69e3132 100644 (file)
@@ -108,16 +108,19 @@ disable_broadcom() {
 
                # make sure all of the devices are disabled in the driver
                local ifdown=
-               local vif
+               local bssmax=$(wlc ifname "$device" bssmax)
+               local vif=$((${bssmax:-4} - 1))
                append ifdown "down" "$N"
                append ifdown "wds none" "$N"
-               for vif in 3 2 1 0; do
+               while [ $vif -ge 0 ]; do
                        append ifdown "vif $vif" "$N"
                        append ifdown "enabled 0" "$N"
+                       vif=$(($vif - 1))
                done
 
                wlc ifname "$device" stdin <<EOF
 $ifdown
+leddc 0xffff
 EOF
        )
        true
@@ -205,12 +208,21 @@ enable_broadcom() {
                esac
        }
 
+       local leddc=$(wlc ifname "$device" leddc)
+       [ "$leddc" -eq 0xffff ] || {
+               leddc=0x005a000a;
+       }
+
        local _c=0
        local nas="$(which nas)"
        local if_pre_up if_up nas_cmd
        local vif vif_pre_up vif_post_up vif_do_up vif_txpower
+       local bssmax=$(wlc ifname "$device" bssmax)
+       bssmax=${bssmax:-4}
 
        for vif in $vifs; do
+               [ $_c -ge $bssmax ] && break
+
                config_get vif_txpower "$vif" txpower
 
                local mode
@@ -352,6 +364,7 @@ enable_broadcom() {
                [ "$ifname" != "${ifname##${device}-}" ] && if_cmd="if_up"
                append $if_cmd "macaddr=\$(wlc ifname '$ifname' cur_etheraddr)" ";$N"
                append $if_cmd "ifconfig '$ifname' \${macaddr:+hw ether \$macaddr}" ";$N"
+               append if_up "ifconfig '$ifname' up" ";$N"
 
                local net_cfg="$(find_net_config "$vif")"
                [ -z "$net_cfg" ] || {
@@ -377,6 +390,7 @@ band ${band:-0}
 ${nmode:+nmode $nmode}
 ${nmode:+${nreqd:+nreqd $nreqd}}
 ${gmode:+gmode $gmode}
+leddc $leddc
 apsta $apsta
 ap $ap
 ${mssid:+mssid $mssid}
@@ -436,7 +450,8 @@ detect_broadcom() {
 config wifi-device  wl${i}
        option type     broadcom
        option channel  ${channel:-11}
-
+       option txantenna 3
+       option rxantenna 3
        # REMOVE THIS LINE TO ENABLE WIFI:
        option disabled 1