[PATCH] bcm43xx: fix nrssi_threshold calculation.

patch by doctorzoidberg.

Signed-off-by: Michael Buesch <mbuesch@freenet.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
Michael Buesch 2006-03-22 17:58:47 +01:00 committed by John W. Linville
parent e382c234cb
commit cf017e1b6f
1 changed files with 33 additions and 39 deletions

View File

@ -782,41 +782,30 @@ void bcm43xx_calc_nrssi_threshold(struct bcm43xx_private *bcm)
{ {
struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm); struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm); struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
s16 threshold; s32 threshold;
s32 a, b; s32 a, b;
int tmp;
s16 tmp16; s16 tmp16;
u16 tmp_u16; u16 tmp_u16;
switch (phy->type) { switch (phy->type) {
case BCM43xx_PHYTYPE_B: { case BCM43xx_PHYTYPE_B: {
int radiotype = 0;
if (phy->rev < 2)
return;
if (radio->version != 0x2050) if (radio->version != 0x2050)
return; return;
if (!(bcm->sprom.boardflags & BCM43xx_BFL_RSSI)) if (!(bcm->sprom.boardflags & BCM43xx_BFL_RSSI))
return; return;
tmp = radio->revision; if (radio->revision >= 6) {
if ((radio->manufact == 0x175 && tmp == 5) || threshold = (radio->nrssi[1] - radio->nrssi[0]) * 32;
(radio->manufact == 0x17F && (tmp == 3 || tmp == 4))) threshold += 20 * (radio->nrssi[0] + 1);
radiotype = 1; threshold /= 40;
} else
if (radiotype == 1) {
threshold = radio->nrssi[1] - 5; threshold = radio->nrssi[1] - 5;
} else {
threshold = 40 * radio->nrssi[0];
threshold += 33 * (radio->nrssi[1] - radio->nrssi[0]);
threshold += 20;
threshold /= 10;
}
threshold = limit_value(threshold, 0, 0x3E); threshold = limit_value(threshold, 0, 0x3E);
bcm43xx_phy_read(bcm, 0x0020); /* dummy read */ bcm43xx_phy_read(bcm, 0x0020); /* dummy read */
bcm43xx_phy_write(bcm, 0x0020, (((u16)threshold) << 8) | 0x001C); bcm43xx_phy_write(bcm, 0x0020, (((u16)threshold) << 8) | 0x001C);
if (radiotype == 1) { if (radio->revision >= 6) {
bcm43xx_phy_write(bcm, 0x0087, 0x0E0D); bcm43xx_phy_write(bcm, 0x0087, 0x0E0D);
bcm43xx_phy_write(bcm, 0x0086, 0x0C0B); bcm43xx_phy_write(bcm, 0x0086, 0x0C0B);
bcm43xx_phy_write(bcm, 0x0085, 0x0A09); bcm43xx_phy_write(bcm, 0x0085, 0x0A09);
@ -844,33 +833,38 @@ void bcm43xx_calc_nrssi_threshold(struct bcm43xx_private *bcm)
& 0xF000) | 0x0AED); & 0xF000) | 0x0AED);
} }
} else { } else {
tmp = radio->interfmode; if (radio->interfmode == BCM43xx_RADIO_INTERFMODE_NONWLAN) {
if (tmp == BCM43xx_RADIO_INTERFMODE_NONWLAN) { a = 0xE;
a = -13; b = 0xA;
b = -17; } else if (!radio->aci_wlan_automatic && radio->aci_enable) {
} else if (tmp == BCM43xx_RADIO_INTERFMODE_NONE && a = 0x13;
!radio->aci_enable) { b = 0x12;
a = -13;
b = -10;
} else { } else {
a = -8; a = 0xE;
b = -9; b = 0x11;
} }
a += 0x1B;
a *= radio->nrssi[1] - radio->nrssi[0];
a += radio->nrssi[0] * 0x40;
a /= 64;
b += 0x1B;
b *= radio->nrssi[1] - radio->nrssi[0];
b += radio->nrssi[0] * 0x40;
b /= 64;
a = a * (radio->nrssi[1] - radio->nrssi[0]);
a += (radio->nrssi[0] << 6);
if (a < 32)
a += 31;
else
a += 32;
a = a >> 6;
a = limit_value(a, -31, 31); a = limit_value(a, -31, 31);
b = b * (radio->nrssi[1] - radio->nrssi[0]);
b += (radio->nrssi[0] << 6);
if (b < 32)
b += 31;
else
b += 32;
b = b >> 6;
b = limit_value(b, -31, 31); b = limit_value(b, -31, 31);
tmp_u16 = bcm43xx_phy_read(bcm, 0x048A) & 0xF000; tmp_u16 = bcm43xx_phy_read(bcm, 0x048A) & 0xF000;
tmp_u16 |= ((u32)a & 0x003F); tmp_u16 |= ((u32)b & 0x0000003F);
tmp_u16 |= (((u32)b & 0x003F) << 6); tmp_u16 |= (((u32)a & 0x0000003F) << 6);
bcm43xx_phy_write(bcm, 0x048A, tmp_u16); bcm43xx_phy_write(bcm, 0x048A, tmp_u16);
} }
break; break;