Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4784a3cc authored by Stanislaw Gruszka's avatar Stanislaw Gruszka Committed by Felix Fietkau
Browse files

mt76x02: assure we update gain after scan



Assure that after we initialize dev->cal.low_gain to -1 this
will cause update gain calibration. Otherwise this might or
might not happen depending on value of second bit of low_gain
and values read from registers in mt76x02_phy_adjust_vga_gain().

Signed-off-by: default avatarStanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent f1b8ee35
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -1082,7 +1082,8 @@ mt76x0_phy_update_channel_gain(struct mt76x02_dev *dev)
	low_gain = (dev->cal.avg_rssi_all > mt76x02_get_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));
		   (dev->cal.avg_rssi_all > mt76x02_get_low_rssi_gain_thresh(dev));


	gain_change = (dev->cal.low_gain & 2) ^ (low_gain & 2);
	gain_change = dev->cal.low_gain < 0 ||
		      (dev->cal.low_gain & 2) ^ (low_gain & 2);
	dev->cal.low_gain = low_gain;
	dev->cal.low_gain = low_gain;


	if (!gain_change) {
	if (!gain_change) {
+4 −1
Original line number Original line Diff line number Diff line
@@ -555,9 +555,12 @@ void mt76x02_sw_scan_complete(struct ieee80211_hw *hw,
	if (mt76_is_mmio(dev))
	if (mt76_is_mmio(dev))
		tasklet_enable(&dev->pre_tbtt_tasklet);
		tasklet_enable(&dev->pre_tbtt_tasklet);


	if (dev->cal.gain_init_done)
	if (dev->cal.gain_init_done) {
		/* Restore AGC gain and resume calibration after scanning. */
		dev->cal.low_gain = -1;
		ieee80211_queue_delayed_work(hw, &dev->cal_work, 0);
		ieee80211_queue_delayed_work(hw, &dev->cal_work, 0);
	}
	}
}
EXPORT_SYMBOL_GPL(mt76x02_sw_scan_complete);
EXPORT_SYMBOL_GPL(mt76x02_sw_scan_complete);


int mt76x02_get_txpower(struct ieee80211_hw *hw,
int mt76x02_get_txpower(struct ieee80211_hw *hw,
+2 −1
Original line number Original line Diff line number Diff line
@@ -289,7 +289,8 @@ void mt76x2_phy_update_channel_gain(struct mt76x02_dev *dev)
	low_gain = (dev->cal.avg_rssi_all > mt76x02_get_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));
		   (dev->cal.avg_rssi_all > mt76x02_get_low_rssi_gain_thresh(dev));


	gain_change = (dev->cal.low_gain & 2) ^ (low_gain & 2);
	gain_change = dev->cal.low_gain < 0 ||
		      (dev->cal.low_gain & 2) ^ (low_gain & 2);
	dev->cal.low_gain = low_gain;
	dev->cal.low_gain = low_gain;


	if (!gain_change) {
	if (!gain_change) {