diff options
author | Michael Buesch <mbuesch@freenet.de> | 2006-03-22 11:58:47 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2006-03-27 11:19:43 -0500 |
commit | cf017e1b6f625978288e2cd8ede04f8185b97c08 (patch) | |
tree | 87cf4e21b65ee8e8d51456d0e4adc68e827496b9 /drivers/net | |
parent | e382c234cbc6fcd76e9ed1168c77fe88d75df73c (diff) |
[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>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/wireless/bcm43xx/bcm43xx_radio.c | 72 |
1 files changed, 33 insertions, 39 deletions
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_radio.c b/drivers/net/wireless/bcm43xx/bcm43xx_radio.c index 63aae43ba838..af5c0bff1696 100644 --- a/drivers/net/wireless/bcm43xx/bcm43xx_radio.c +++ b/drivers/net/wireless/bcm43xx/bcm43xx_radio.c | |||
@@ -782,41 +782,30 @@ void bcm43xx_calc_nrssi_threshold(struct bcm43xx_private *bcm) | |||
782 | { | 782 | { |
783 | struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm); | 783 | struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm); |
784 | struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm); | 784 | struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm); |
785 | s16 threshold; | 785 | s32 threshold; |
786 | s32 a, b; | 786 | s32 a, b; |
787 | int tmp; | ||
788 | s16 tmp16; | 787 | s16 tmp16; |
789 | u16 tmp_u16; | 788 | u16 tmp_u16; |
790 | 789 | ||
791 | switch (phy->type) { | 790 | switch (phy->type) { |
792 | case BCM43xx_PHYTYPE_B: { | 791 | case BCM43xx_PHYTYPE_B: { |
793 | int radiotype = 0; | ||
794 | |||
795 | if (phy->rev < 2) | ||
796 | return; | ||
797 | if (radio->version != 0x2050) | 792 | if (radio->version != 0x2050) |
798 | return; | 793 | return; |
799 | if (!(bcm->sprom.boardflags & BCM43xx_BFL_RSSI)) | 794 | if (!(bcm->sprom.boardflags & BCM43xx_BFL_RSSI)) |
800 | return; | 795 | return; |
801 | 796 | ||
802 | tmp = radio->revision; | 797 | if (radio->revision >= 6) { |
803 | if ((radio->manufact == 0x175 && tmp == 5) || | 798 | threshold = (radio->nrssi[1] - radio->nrssi[0]) * 32; |
804 | (radio->manufact == 0x17F && (tmp == 3 || tmp == 4))) | 799 | threshold += 20 * (radio->nrssi[0] + 1); |
805 | radiotype = 1; | 800 | threshold /= 40; |
806 | 801 | } else | |
807 | if (radiotype == 1) { | ||
808 | threshold = radio->nrssi[1] - 5; | 802 | threshold = radio->nrssi[1] - 5; |
809 | } else { | 803 | |
810 | threshold = 40 * radio->nrssi[0]; | ||
811 | threshold += 33 * (radio->nrssi[1] - radio->nrssi[0]); | ||
812 | threshold += 20; | ||
813 | threshold /= 10; | ||
814 | } | ||
815 | threshold = limit_value(threshold, 0, 0x3E); | 804 | threshold = limit_value(threshold, 0, 0x3E); |
816 | bcm43xx_phy_read(bcm, 0x0020); /* dummy read */ | 805 | bcm43xx_phy_read(bcm, 0x0020); /* dummy read */ |
817 | bcm43xx_phy_write(bcm, 0x0020, (((u16)threshold) << 8) | 0x001C); | 806 | bcm43xx_phy_write(bcm, 0x0020, (((u16)threshold) << 8) | 0x001C); |
818 | 807 | ||
819 | if (radiotype == 1) { | 808 | if (radio->revision >= 6) { |
820 | bcm43xx_phy_write(bcm, 0x0087, 0x0E0D); | 809 | bcm43xx_phy_write(bcm, 0x0087, 0x0E0D); |
821 | bcm43xx_phy_write(bcm, 0x0086, 0x0C0B); | 810 | bcm43xx_phy_write(bcm, 0x0086, 0x0C0B); |
822 | bcm43xx_phy_write(bcm, 0x0085, 0x0A09); | 811 | bcm43xx_phy_write(bcm, 0x0085, 0x0A09); |
@@ -844,33 +833,38 @@ void bcm43xx_calc_nrssi_threshold(struct bcm43xx_private *bcm) | |||
844 | & 0xF000) | 0x0AED); | 833 | & 0xF000) | 0x0AED); |
845 | } | 834 | } |
846 | } else { | 835 | } else { |
847 | tmp = radio->interfmode; | 836 | if (radio->interfmode == BCM43xx_RADIO_INTERFMODE_NONWLAN) { |
848 | if (tmp == BCM43xx_RADIO_INTERFMODE_NONWLAN) { | 837 | a = 0xE; |
849 | a = -13; | 838 | b = 0xA; |
850 | b = -17; | 839 | } else if (!radio->aci_wlan_automatic && radio->aci_enable) { |
851 | } else if (tmp == BCM43xx_RADIO_INTERFMODE_NONE && | 840 | a = 0x13; |
852 | !radio->aci_enable) { | 841 | b = 0x12; |
853 | a = -13; | ||
854 | b = -10; | ||
855 | } else { | 842 | } else { |
856 | a = -8; | 843 | a = 0xE; |
857 | b = -9; | 844 | b = 0x11; |
858 | } | 845 | } |
859 | a += 0x1B; | ||
860 | a *= radio->nrssi[1] - radio->nrssi[0]; | ||
861 | a += radio->nrssi[0] * 0x40; | ||
862 | a /= 64; | ||
863 | b += 0x1B; | ||
864 | b *= radio->nrssi[1] - radio->nrssi[0]; | ||
865 | b += radio->nrssi[0] * 0x40; | ||
866 | b /= 64; | ||
867 | 846 | ||
847 | a = a * (radio->nrssi[1] - radio->nrssi[0]); | ||
848 | a += (radio->nrssi[0] << 6); | ||
849 | if (a < 32) | ||
850 | a += 31; | ||
851 | else | ||
852 | a += 32; | ||
853 | a = a >> 6; | ||
868 | a = limit_value(a, -31, 31); | 854 | a = limit_value(a, -31, 31); |
855 | |||
856 | b = b * (radio->nrssi[1] - radio->nrssi[0]); | ||
857 | b += (radio->nrssi[0] << 6); | ||
858 | if (b < 32) | ||
859 | b += 31; | ||
860 | else | ||
861 | b += 32; | ||
862 | b = b >> 6; | ||
869 | b = limit_value(b, -31, 31); | 863 | b = limit_value(b, -31, 31); |
870 | 864 | ||
871 | tmp_u16 = bcm43xx_phy_read(bcm, 0x048A) & 0xF000; | 865 | tmp_u16 = bcm43xx_phy_read(bcm, 0x048A) & 0xF000; |
872 | tmp_u16 |= ((u32)a & 0x003F); | 866 | tmp_u16 |= ((u32)b & 0x0000003F); |
873 | tmp_u16 |= (((u32)b & 0x003F) << 6); | 867 | tmp_u16 |= (((u32)a & 0x0000003F) << 6); |
874 | bcm43xx_phy_write(bcm, 0x048A, tmp_u16); | 868 | bcm43xx_phy_write(bcm, 0x048A, tmp_u16); |
875 | } | 869 | } |
876 | break; | 870 | break; |