diff options
author | Kevin Lo <kevlo@cvs.openbsd.org> | 2018-12-07 01:53:21 +0000 |
---|---|---|
committer | Kevin Lo <kevlo@cvs.openbsd.org> | 2018-12-07 01:53:21 +0000 |
commit | 80ee5289937512da97bb3d586b96b4c42a44eb4b (patch) | |
tree | 0278b107aecbb08d45503382a8fd15d71c7ccda6 /sys/dev | |
parent | 58776864df354c72cca8da06ce0f4da25eca7e6d (diff) |
Handle 2 Tx chains in the computation of transmit power for the RTL8192EU.
While here sort vendors.
Tested by jmatthew@
ok stsp@, jmatthew@
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/ic/r92creg.h | 14 | ||||
-rw-r--r-- | sys/dev/ic/rtwn.c | 24 | ||||
-rw-r--r-- | sys/dev/usb/if_urtwn.c | 6 |
3 files changed, 32 insertions, 12 deletions
diff --git a/sys/dev/ic/r92creg.h b/sys/dev/ic/r92creg.h index 6adabc733ef..531d449cf52 100644 --- a/sys/dev/ic/r92creg.h +++ b/sys/dev/ic/r92creg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: r92creg.h,v 1.22 2018/12/04 10:47:32 jmatthew Exp $ */ +/* $OpenBSD: r92creg.h,v 1.23 2018/12/07 01:53:20 kevlo Exp $ */ /*- * Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr> @@ -1235,7 +1235,17 @@ struct r92e_tx_pwr { #define R92E_ROM_TXPWR_HT20_DIFF_S 4 #define R92E_ROM_TXPWR_OFDM_DIFF_M 0x0f #define R92E_ROM_TXPWR_OFDM_DIFF_S 0 - uint16_t pwr_diff[3]; + + struct { + uint8_t ht40_ht20_tx_pwr_diff; +#define R92E_ROM_TXPWR_HT40_DIFF_M 0xf0 +#define R92E_ROM_TXPWR_HT40_DIFF_S 4 +#define R92E_ROM_TXPWR_HT20_2S_DIFF_M 0x0f +#define R92E_ROM_TXPWR_HT20_2S_DIFF_S 0 + + uint8_t ofdm_cck_tx_pwr_diff; + } __packed pwr_diff[3]; + uint8_t reserved[24]; } __packed; diff --git a/sys/dev/ic/rtwn.c b/sys/dev/ic/rtwn.c index ad1fa0b9884..2eb5a08324f 100644 --- a/sys/dev/ic/rtwn.c +++ b/sys/dev/ic/rtwn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtwn.c,v 1.42 2018/12/04 10:47:32 jmatthew Exp $ */ +/* $OpenBSD: rtwn.c,v 1.43 2018/12/07 01:53:20 kevlo Exp $ */ /*- * Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr> @@ -2192,7 +2192,7 @@ rtwn_r92e_get_txpower(struct rtwn_softc *sc, int chain, struct ieee80211com *ic = &sc->sc_ic; struct r92e_rom *rom = &sc->sc_r92e_rom; struct r92e_tx_pwr *txpwr; - uint8_t cckpow, ofdmpow; + uint8_t cckpow, htpow, htpow2s = 0, ofdmpow; int8_t diff; int ridx, chan, group; @@ -2224,23 +2224,33 @@ rtwn_r92e_get_txpower(struct rtwn_softc *sc, int chain, power[ridx] = R92C_MAX_TX_PWR; } + htpow = txpwr->ht40_tx_pwr[group]; + /* Compute per-OFDM rate Tx power. */ diff = RTWN_SIGN4TO8(MS(txpwr->ht20_ofdm_tx_pwr_diff, R92E_ROM_TXPWR_OFDM_DIFF)); - ofdmpow = txpwr->ht40_tx_pwr[group] + diff; + ofdmpow = htpow + diff; for (ridx = RTWN_RIDX_OFDM6; ridx <= RTWN_RIDX_OFDM54; ridx++) { power[ridx] = ofdmpow; if (power[ridx] > R92C_MAX_TX_PWR) power[ridx] = R92C_MAX_TX_PWR; } - /* Compute per-MCS Tx power. */ /* XXX apparently need to handle tx chains here? */ - if (extc == NULL) + /* Compute per-MCS Tx power. */ + if (extc == NULL) { diff = RTWN_SIGN4TO8(MS(txpwr->ht20_ofdm_tx_pwr_diff, R92E_ROM_TXPWR_HT20_DIFF)); + htpow += diff; + if (sc->ntxchains > 1) { + diff = RTWN_SIGN4TO8(MS( + txpwr->pwr_diff[0].ht40_ht20_tx_pwr_diff, + R92E_ROM_TXPWR_HT20_2S_DIFF)); + htpow2s = htpow + diff; + } + } - for (ridx = RTWN_RIDX_MCS0; ridx < RTWN_RIDX_MCS8; ridx++) { - power[ridx] = txpwr->ht40_tx_pwr[group] + diff; + for (ridx = RTWN_RIDX_MCS0; ridx < RTWN_RIDX_MCS15; ridx++) { + power[ridx] = (ridx < RTWN_RIDX_MCS8) ? htpow : htpow2s; if (power[ridx] > R92C_MAX_TX_PWR) power[ridx] = R92C_MAX_TX_PWR; } diff --git a/sys/dev/usb/if_urtwn.c b/sys/dev/usb/if_urtwn.c index 43d924c69c9..73a5d0c3194 100644 --- a/sys/dev/usb/if_urtwn.c +++ b/sys/dev/usb/if_urtwn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_urtwn.c,v 1.80 2018/12/04 10:47:32 jmatthew Exp $ */ +/* $OpenBSD: if_urtwn.c,v 1.81 2018/12/07 01:53:20 kevlo Exp $ */ /*- * Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr> @@ -330,8 +330,8 @@ static const struct urtwn_type { URTWN_DEV_8188EU(REALTEK, RTL8188EU), URTWN_DEV_8188EU(TPLINK, RTL8188EUS), /* URTWN_RTL8192EU */ - URTWN_DEV_8192EU(REALTEK, RTL8192EU), - URTWN_DEV_8192EU(DLINK, DWA131E1) + URTWN_DEV_8192EU(DLINK, DWA131E1), + URTWN_DEV_8192EU(REALTEK, RTL8192EU) }; #define urtwn_lookup(v, p) \ |