Skip to content

Commit

Permalink
mt76: move rssi_gain_thresh routines in mt76x02-lib module
Browse files Browse the repository at this point in the history
Move mt76x2_get_rssi_gain_thresh and mt76x2_get_low_rssi_gain_thresh
routines in mt76x02-lib module in order to be reused by mt76x0 driver
for dynamic vga calibration

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
  • Loading branch information
Lorenzo Bianconi authored and Felix Fietkau committed Oct 13, 2018
1 parent 66a34c6 commit b225a9b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
26 changes: 26 additions & 0 deletions drivers/net/wireless/mediatek/mt76/mt76x02_phy.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,32 @@

#include "mt76x02_regs.h"

static inline int
mt76x02_get_rssi_gain_thresh(struct mt76x02_dev *dev)
{
switch (dev->mt76.chandef.width) {
case NL80211_CHAN_WIDTH_80:
return -62;
case NL80211_CHAN_WIDTH_40:
return -65;
default:
return -68;
}
}

static inline int
mt76x02_get_low_rssi_gain_thresh(struct mt76x02_dev *dev)
{
switch (dev->mt76.chandef.width) {
case NL80211_CHAN_WIDTH_80:
return -76;
case NL80211_CHAN_WIDTH_40:
return -79;
default:
return -82;
}
}

void mt76x02_add_rate_power_offset(struct mt76_rate_power *r, int offset);
void mt76x02_phy_set_txpower(struct mt76x02_dev *dev, int txp_0, int txp_2);
void mt76x02_limit_rate_power(struct mt76_rate_power *r, int limit);
Expand Down
30 changes: 2 additions & 28 deletions drivers/net/wireless/mediatek/mt76/mt76x2/pci_phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,32 +131,6 @@ mt76x2_get_agc_gain(struct mt76x02_dev *dev, u8 *dest)
dest[1] = mt76_get_field(dev, MT_BBP(AGC, 9), MT_BBP_AGC_GAIN);
}

static int
mt76x2_get_rssi_gain_thresh(struct mt76x02_dev *dev)
{
switch (dev->mt76.chandef.width) {
case NL80211_CHAN_WIDTH_80:
return -62;
case NL80211_CHAN_WIDTH_40:
return -65;
default:
return -68;
}
}

static int
mt76x2_get_low_rssi_gain_thresh(struct mt76x02_dev *dev)
{
switch (dev->mt76.chandef.width) {
case NL80211_CHAN_WIDTH_80:
return -76;
case NL80211_CHAN_WIDTH_40:
return -79;
default:
return -82;
}
}

static void
mt76x2_phy_set_gain_val(struct mt76x02_dev *dev)
{
Expand Down Expand Up @@ -212,8 +186,8 @@ mt76x2_phy_update_channel_gain(struct mt76x02_dev *dev)

dev->cal.avg_rssi_all = mt76x02_phy_get_min_avg_rssi(dev);

low_gain = (dev->cal.avg_rssi_all > mt76x2_get_rssi_gain_thresh(dev)) +
(dev->cal.avg_rssi_all > mt76x2_get_low_rssi_gain_thresh(dev));
low_gain = (dev->cal.avg_rssi_all > mt76x02_get_rssi_gain_thresh(dev)) +
(dev->cal.avg_rssi_all > mt76x02_get_low_rssi_gain_thresh(dev));

gain_change = (dev->cal.low_gain & 2) ^ (low_gain & 2);
dev->cal.low_gain = low_gain;
Expand Down

0 comments on commit b225a9b

Please sign in to comment.