aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt73usb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt73usb.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c52
1 files changed, 24 insertions, 28 deletions
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index ae3b31d0d511..b5443148d621 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -924,21 +924,27 @@ static void rt73usb_link_stats(struct rt2x00_dev *rt2x00dev,
924 qual->false_cca = rt2x00_get_field32(reg, STA_CSR1_FALSE_CCA_ERROR); 924 qual->false_cca = rt2x00_get_field32(reg, STA_CSR1_FALSE_CCA_ERROR);
925} 925}
926 926
927static inline void rt73usb_set_vgc(struct rt2x00_dev *rt2x00dev, u8 vgc_level)
928{
929 if (rt2x00dev->link.vgc_level != vgc_level) {
930 rt73usb_bbp_write(rt2x00dev, 17, vgc_level);
931 rt2x00dev->link.vgc_level = vgc_level;
932 rt2x00dev->link.vgc_level_reg = vgc_level;
933 }
934}
935
927static void rt73usb_reset_tuner(struct rt2x00_dev *rt2x00dev) 936static void rt73usb_reset_tuner(struct rt2x00_dev *rt2x00dev)
928{ 937{
929 rt73usb_bbp_write(rt2x00dev, 17, 0x20); 938 rt73usb_set_vgc(rt2x00dev, 0x20);
930 rt2x00dev->link.vgc_level = 0x20;
931} 939}
932 940
933static void rt73usb_link_tuner(struct rt2x00_dev *rt2x00dev) 941static void rt73usb_link_tuner(struct rt2x00_dev *rt2x00dev)
934{ 942{
935 int rssi = rt2x00_get_link_rssi(&rt2x00dev->link); 943 struct link *link = &rt2x00dev->link;
936 u8 r17; 944 int rssi = rt2x00_get_link_rssi(link);
937 u8 up_bound; 945 u8 up_bound;
938 u8 low_bound; 946 u8 low_bound;
939 947
940 rt73usb_bbp_read(rt2x00dev, 17, &r17);
941
942 /* 948 /*
943 * Determine r17 bounds. 949 * Determine r17 bounds.
944 */ 950 */
@@ -979,8 +985,7 @@ static void rt73usb_link_tuner(struct rt2x00_dev *rt2x00dev)
979 * Special big-R17 for very short distance 985 * Special big-R17 for very short distance
980 */ 986 */
981 if (rssi > -35) { 987 if (rssi > -35) {
982 if (r17 != 0x60) 988 rt73usb_set_vgc(rt2x00dev, 0x60);
983 rt73usb_bbp_write(rt2x00dev, 17, 0x60);
984 return; 989 return;
985 } 990 }
986 991
@@ -988,8 +993,7 @@ static void rt73usb_link_tuner(struct rt2x00_dev *rt2x00dev)
988 * Special big-R17 for short distance 993 * Special big-R17 for short distance
989 */ 994 */
990 if (rssi >= -58) { 995 if (rssi >= -58) {
991 if (r17 != up_bound) 996 rt73usb_set_vgc(rt2x00dev, up_bound);
992 rt73usb_bbp_write(rt2x00dev, 17, up_bound);
993 return; 997 return;
994 } 998 }
995 999
@@ -997,9 +1001,7 @@ static void rt73usb_link_tuner(struct rt2x00_dev *rt2x00dev)
997 * Special big-R17 for middle-short distance 1001 * Special big-R17 for middle-short distance
998 */ 1002 */
999 if (rssi >= -66) { 1003 if (rssi >= -66) {
1000 low_bound += 0x10; 1004 rt73usb_set_vgc(rt2x00dev, low_bound + 0x10);
1001 if (r17 != low_bound)
1002 rt73usb_bbp_write(rt2x00dev, 17, low_bound);
1003 return; 1005 return;
1004 } 1006 }
1005 1007
@@ -1007,8 +1009,7 @@ static void rt73usb_link_tuner(struct rt2x00_dev *rt2x00dev)
1007 * Special mid-R17 for middle distance 1009 * Special mid-R17 for middle distance
1008 */ 1010 */
1009 if (rssi >= -74) { 1011 if (rssi >= -74) {
1010 if (r17 != (low_bound + 0x10)) 1012 rt73usb_set_vgc(rt2x00dev, low_bound + 0x08);
1011 rt73usb_bbp_write(rt2x00dev, 17, low_bound + 0x08);
1012 return; 1013 return;
1013 } 1014 }
1014 1015
@@ -1020,8 +1021,8 @@ static void rt73usb_link_tuner(struct rt2x00_dev *rt2x00dev)
1020 if (low_bound > up_bound) 1021 if (low_bound > up_bound)
1021 up_bound = low_bound; 1022 up_bound = low_bound;
1022 1023
1023 if (r17 > up_bound) { 1024 if (link->vgc_level > up_bound) {
1024 rt73usb_bbp_write(rt2x00dev, 17, up_bound); 1025 rt73usb_set_vgc(rt2x00dev, up_bound);
1025 return; 1026 return;
1026 } 1027 }
1027 1028
@@ -1031,17 +1032,12 @@ dynamic_cca_tune:
1031 * r17 does not yet exceed upper limit, continue and base 1032 * r17 does not yet exceed upper limit, continue and base
1032 * the r17 tuning on the false CCA count. 1033 * the r17 tuning on the false CCA count.
1033 */ 1034 */
1034 if (rt2x00dev->link.qual.false_cca > 512 && r17 < up_bound) { 1035 if ((link->qual.false_cca > 512) && (link->vgc_level < up_bound))
1035 r17 += 4; 1036 rt73usb_set_vgc(rt2x00dev,
1036 if (r17 > up_bound) 1037 min_t(u8, link->vgc_level + 4, up_bound));
1037 r17 = up_bound; 1038 else if ((link->qual.false_cca < 100) && (link->vgc_level > low_bound))
1038 rt73usb_bbp_write(rt2x00dev, 17, r17); 1039 rt73usb_set_vgc(rt2x00dev,
1039 } else if (rt2x00dev->link.qual.false_cca < 100 && r17 > low_bound) { 1040 max_t(u8, link->vgc_level - 4, low_bound));
1040 r17 -= 4;
1041 if (r17 < low_bound)
1042 r17 = low_bound;
1043 rt73usb_bbp_write(rt2x00dev, 17, r17);
1044 }
1045} 1041}
1046 1042
1047/* 1043/*