Lines Matching +full:gain +full:- +full:offset

1 // SPDX-License-Identifier: ISC
13 mt76x2_adjust_high_lna_gain(struct mt76x02_dev *dev, int reg, s8 offset) in mt76x2_adjust_high_lna_gain() argument
15 s8 gain; in mt76x2_adjust_high_lna_gain() local
17 gain = FIELD_GET(MT_BBP_AGC_LNA_HIGH_GAIN, in mt76x2_adjust_high_lna_gain()
19 gain -= offset / 2; in mt76x2_adjust_high_lna_gain()
20 mt76_rmw_field(dev, MT_BBP(AGC, reg), MT_BBP_AGC_LNA_HIGH_GAIN, gain); in mt76x2_adjust_high_lna_gain()
24 mt76x2_adjust_agc_gain(struct mt76x02_dev *dev, int reg, s8 offset) in mt76x2_adjust_agc_gain() argument
26 s8 gain; in mt76x2_adjust_agc_gain() local
28 gain = FIELD_GET(MT_BBP_AGC_GAIN, mt76_rr(dev, MT_BBP(AGC, reg))); in mt76x2_adjust_agc_gain()
29 gain += offset; in mt76x2_adjust_agc_gain()
30 mt76_rmw_field(dev, MT_BBP(AGC, reg), MT_BBP_AGC_GAIN, gain); in mt76x2_adjust_agc_gain()
35 s8 *gain_adj = dev->cal.rx.high_gain; in mt76x2_apply_gain_adj()
124 for (i = 0; i < sizeof(r->all); i++) { in mt76x2_get_min_rate_power()
125 if (!r->all[i]) in mt76x2_get_min_rate_power()
129 ret = min(ret, r->all[i]); in mt76x2_get_min_rate_power()
131 ret = r->all[i]; in mt76x2_get_min_rate_power()
139 enum nl80211_chan_width width = dev->mphy.chandef.width; in mt76x2_phy_set_txpower()
140 struct ieee80211_channel *chan = dev->mphy.chandef.chan; in mt76x2_phy_set_txpower()
144 int base_power, gain; in mt76x2_phy_set_txpower() local
155 mt76x02_limit_rate_power(&t, dev->txpower_conf); in mt76x2_phy_set_txpower()
156 dev->mphy.txpower_cur = mt76x02_get_max_rate_power(&t); in mt76x2_phy_set_txpower()
159 delta = base_power - txp.target_power; in mt76x2_phy_set_txpower()
163 gain = min(txp_0, txp_1); in mt76x2_phy_set_txpower()
164 if (gain < 0) { in mt76x2_phy_set_txpower()
165 base_power -= gain; in mt76x2_phy_set_txpower()
166 txp_0 -= gain; in mt76x2_phy_set_txpower()
167 txp_1 -= gain; in mt76x2_phy_set_txpower()
168 } else if (gain > 0x2f) { in mt76x2_phy_set_txpower()
169 base_power -= gain - 0x2f; in mt76x2_phy_set_txpower()
174 mt76x02_add_rate_power_offset(&t, -base_power); in mt76x2_phy_set_txpower()
175 dev->target_power = txp.target_power; in mt76x2_phy_set_txpower()
176 dev->target_power_delta[0] = txp_0 - txp.chain[0].target_power; in mt76x2_phy_set_txpower()
177 dev->target_power_delta[1] = txp_1 - txp.chain[0].target_power; in mt76x2_phy_set_txpower()
178 dev->rate_power = t; in mt76x2_phy_set_txpower()
205 struct ieee80211_channel *chan = dev->mphy.chandef.chan; in mt76x2_phy_tssi_compensate()
209 if (!dev->cal.tssi_cal_done) in mt76x2_phy_tssi_compensate()
212 if (!dev->cal.tssi_comp_pending) { in mt76x2_phy_tssi_compensate()
216 dev->cal.tssi_comp_pending = true; in mt76x2_phy_tssi_compensate()
221 dev->cal.tssi_comp_pending = false; in mt76x2_phy_tssi_compensate()
224 if (mt76x02_ext_pa_enabled(dev, chan->band)) in mt76x2_phy_tssi_compensate()
234 if (t.pa_mode || dev->cal.dpd_cal_done || dev->ed_tx_blocked) in mt76x2_phy_tssi_compensate()
238 mt76x02_mcu_calibrate(dev, MCU_CAL_DPD, chan->hw_value); in mt76x2_phy_tssi_compensate()
239 dev->cal.dpd_cal_done = true; in mt76x2_phy_tssi_compensate()
250 gain_val[0] = dev->cal.agc_gain_cur[0] - dev->cal.agc_gain_adjust; in mt76x2_phy_set_gain_val()
251 gain_val[1] = dev->cal.agc_gain_cur[1] - dev->cal.agc_gain_adjust; in mt76x2_phy_set_gain_val()
255 dev->mphy.chandef.width >= NL80211_CHAN_WIDTH_40) in mt76x2_phy_set_gain_val()
259 dev->mphy.chandef.chan->band == NL80211_BAND_2GHZ && in mt76x2_phy_set_gain_val()
260 dev->mphy.chandef.width < NL80211_CHAN_WIDTH_40) in mt76x2_phy_set_gain_val()
270 if (dev->mphy.chandef.chan->flags & IEEE80211_CHAN_RADAR) in mt76x2_phy_set_gain_val()
276 u8 *gain = dev->cal.agc_gain_init; in mt76x2_phy_update_channel_gain() local
283 dev->cal.avg_rssi_all = mt76_get_min_avg_rssi(&dev->mt76, false); in mt76x2_phy_update_channel_gain()
284 if (!dev->cal.avg_rssi_all) in mt76x2_phy_update_channel_gain()
285 dev->cal.avg_rssi_all = -75; in mt76x2_phy_update_channel_gain()
287 low_gain = (dev->cal.avg_rssi_all > mt76x02_get_rssi_gain_thresh(dev)) + in mt76x2_phy_update_channel_gain()
288 (dev->cal.avg_rssi_all > mt76x02_get_low_rssi_gain_thresh(dev)); in mt76x2_phy_update_channel_gain()
290 gain_change = dev->cal.low_gain < 0 || in mt76x2_phy_update_channel_gain()
291 (dev->cal.low_gain & 2) ^ (low_gain & 2); in mt76x2_phy_update_channel_gain()
292 dev->cal.low_gain = low_gain; in mt76x2_phy_update_channel_gain()
300 if (dev->mphy.chandef.width == NL80211_CHAN_WIDTH_80) { in mt76x2_phy_update_channel_gain()
318 if (dev->mphy.chandef.chan->band == NL80211_BAND_2GHZ) in mt76x2_phy_update_channel_gain()
322 else if (dev->mphy.chandef.width == NL80211_CHAN_WIDTH_80) in mt76x2_phy_update_channel_gain()
332 dev->cal.agc_gain_adjust = 0; in mt76x2_phy_update_channel_gain()
336 dev->cal.agc_gain_adjust = low_gain_delta; in mt76x2_phy_update_channel_gain()
342 dev->cal.agc_gain_cur[0] = gain[0] - gain_delta; in mt76x2_phy_update_channel_gain()
343 dev->cal.agc_gain_cur[1] = gain[1] - gain_delta; in mt76x2_phy_update_channel_gain()