Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src-draft/trunk]: src/sys/dev/usb Fix rssi calculations for 88C/EUS variants...
details: https://anonhg.NetBSD.org/src-all/rev/976873c79d92
branches: trunk
changeset: 375785:976873c79d92
user: Nathanial Sloss <nat%netbsd.org@localhost>
date: Thu Jul 21 16:58:28 2022 +1000
description:
Fix rssi calculations for 88C/EUS variants and 92EU from openbsd.
diffstat:
sys/dev/usb/if_urtwn.c | 53 ++++++++++++-------------------------------------
1 files changed, 13 insertions(+), 40 deletions(-)
diffs (70 lines):
diff -r 51f34edb7704 -r 976873c79d92 sys/dev/usb/if_urtwn.c
--- a/sys/dev/usb/if_urtwn.c Sun Jun 19 12:40:00 2022 +0200
+++ b/sys/dev/usb/if_urtwn.c Thu Jul 21 16:58:28 2022 +1000
@@ -2107,53 +2107,26 @@ urtwn_get_rssi(struct urtwn_softc *sc, i
static int8_t
urtwn_r88e_get_rssi(struct urtwn_softc *sc, int rate, void *physt)
{
- struct r92c_rx_phystat *phy;
- struct r88e_rx_cck *cck;
- uint8_t cck_agc_rpt, lna_idx, vga_idx;
+ static const int8_t cckoff[] = { 20, 14, 10, -4, -16, -22, -38, -40 };
+ struct r88e_rx_phystat *phy;
+ uint8_t rpt;
int8_t rssi;
URTWNHIST_FUNC();
URTWNHIST_CALLARGS("rate=%jd", rate, 0, 0, 0);
- rssi = 0;
+ phy = (struct r88e_rx_phystat *)physt;
+
if (rate <= 3) {
- cck = (struct r88e_rx_cck *)physt;
- cck_agc_rpt = cck->agc_rpt;
- lna_idx = (cck_agc_rpt & 0xe0) >> 5;
- vga_idx = cck_agc_rpt & 0x1f;
- switch (lna_idx) {
- case 7:
- if (vga_idx <= 27)
- rssi = -100 + 2* (27 - vga_idx);
- else
- rssi = -100;
- break;
- case 6:
- rssi = -48 + 2 * (2 - vga_idx);
- break;
- case 5:
- rssi = -42 + 2 * (7 - vga_idx);
- break;
- case 4:
- rssi = -36 + 2 * (7 - vga_idx);
- break;
- case 3:
- rssi = -24 + 2 * (7 - vga_idx);
- break;
- case 2:
- rssi = -12 + 2 * (5 - vga_idx);
- break;
- case 1:
- rssi = 8 - (2 * vga_idx);
- break;
- case 0:
- rssi = 14 - (2 * vga_idx);
- break;
+ rpt = (phy->agc_rpt >> 5) & 0x7;
+ rssi = (phy->agc_rpt & 0x1f) << 1;
+ if (sc->sc_uw.uw_flags & URTWN_FLAG_CCK_HIPWR) {
+ if (rpt == 2)
+ rssi -= 6;
}
- rssi += 6;
- } else { /* OFDM/HT. */
- phy = (struct r92c_rx_phystat *)physt;
- rssi = ((le32toh(phy->phydw1) >> 1) & 0x7f) - 110;
+ rssi = (phy->agc_rpt & 0x1f) > 27 ? -94 : cckoff[rpt] - rssi;
+ } else { /* OFDM/HT. */
+ rssi = ((le32toh(phy->sq_rpt) >> 1) & 0x7f) - 110;
}
return rssi;
}
Home |
Main Index |
Thread Index |
Old Index