mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 11:18:45 +07:00
mt76x2: initialize channel power limits at probe time
This allows user space to query the real hardware limits directly Signed-off-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
This commit is contained in:
parent
60e2434c5f
commit
984ea50324
@ -483,6 +483,17 @@ void mt76x2_get_rate_power(struct mt76x2_dev *dev, struct mt76_rate_power *t,
|
|||||||
t->vht[8] = t->vht[9] = mt76x2_rate_power_val(val >> 8);
|
t->vht[8] = t->vht[9] = mt76x2_rate_power_val(val >> 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int mt76x2_get_max_rate_power(struct mt76_rate_power *r)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
s8 ret = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < sizeof(r->all); i++)
|
||||||
|
ret = max(ret, r->all[i]);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mt76x2_get_power_info_2g(struct mt76x2_dev *dev, struct mt76x2_tx_power_info *t,
|
mt76x2_get_power_info_2g(struct mt76x2_dev *dev, struct mt76x2_tx_power_info *t,
|
||||||
struct ieee80211_channel *chan, int chain, int offset)
|
struct ieee80211_channel *chan, int chain, int offset)
|
||||||
|
@ -148,6 +148,7 @@ mt76x2_eeprom_get(struct mt76x2_dev *dev, enum mt76x2_eeprom_field field)
|
|||||||
|
|
||||||
void mt76x2_get_rate_power(struct mt76x2_dev *dev, struct mt76_rate_power *t,
|
void mt76x2_get_rate_power(struct mt76x2_dev *dev, struct mt76_rate_power *t,
|
||||||
struct ieee80211_channel *chan);
|
struct ieee80211_channel *chan);
|
||||||
|
int mt76x2_get_max_rate_power(struct mt76_rate_power *r);
|
||||||
void mt76x2_get_power_info(struct mt76x2_dev *dev,
|
void mt76x2_get_power_info(struct mt76x2_dev *dev,
|
||||||
struct mt76x2_tx_power_info *t,
|
struct mt76x2_tx_power_info *t,
|
||||||
struct ieee80211_channel *chan);
|
struct ieee80211_channel *chan);
|
||||||
|
@ -760,6 +760,34 @@ static void mt76x2_led_set_brightness(struct led_classdev *led_cdev,
|
|||||||
mt76x2_led_set_config(mt76, 0xff, 0);
|
mt76x2_led_set_config(mt76, 0xff, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
mt76x2_init_txpower(struct mt76x2_dev *dev,
|
||||||
|
struct ieee80211_supported_band *sband)
|
||||||
|
{
|
||||||
|
struct ieee80211_channel *chan;
|
||||||
|
struct mt76x2_tx_power_info txp;
|
||||||
|
struct mt76_rate_power t = {};
|
||||||
|
int target_power;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < sband->n_channels; i++) {
|
||||||
|
chan = &sband->channels[i];
|
||||||
|
|
||||||
|
mt76x2_get_power_info(dev, &txp, chan);
|
||||||
|
|
||||||
|
target_power = max_t(int, (txp.chain[0].target_power +
|
||||||
|
txp.chain[0].delta),
|
||||||
|
(txp.chain[1].target_power +
|
||||||
|
txp.chain[1].delta));
|
||||||
|
|
||||||
|
mt76x2_get_rate_power(dev, &t, chan);
|
||||||
|
|
||||||
|
chan->max_power = mt76x2_get_max_rate_power(&t) +
|
||||||
|
target_power;
|
||||||
|
chan->max_power /= 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int mt76x2_register_device(struct mt76x2_dev *dev)
|
int mt76x2_register_device(struct mt76x2_dev *dev)
|
||||||
{
|
{
|
||||||
struct ieee80211_hw *hw = mt76_hw(dev);
|
struct ieee80211_hw *hw = mt76_hw(dev);
|
||||||
@ -828,6 +856,8 @@ int mt76x2_register_device(struct mt76x2_dev *dev)
|
|||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
mt76x2_init_debugfs(dev);
|
mt76x2_init_debugfs(dev);
|
||||||
|
mt76x2_init_txpower(dev, &dev->mt76.sband_2g.sband);
|
||||||
|
mt76x2_init_txpower(dev, &dev->mt76.sband_5g.sband);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -102,18 +102,6 @@ mt76x2_limit_rate_power(struct mt76_rate_power *r, int limit)
|
|||||||
r->all[i] = limit;
|
r->all[i] = limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
mt76x2_get_max_power(struct mt76_rate_power *r)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
s8 ret = 0;
|
|
||||||
|
|
||||||
for (i = 0; i < sizeof(r->all); i++)
|
|
||||||
ret = max(ret, r->all[i]);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void mt76x2_phy_set_txpower(struct mt76x2_dev *dev)
|
void mt76x2_phy_set_txpower(struct mt76x2_dev *dev)
|
||||||
{
|
{
|
||||||
enum nl80211_chan_width width = dev->mt76.chandef.width;
|
enum nl80211_chan_width width = dev->mt76.chandef.width;
|
||||||
@ -136,7 +124,7 @@ void mt76x2_phy_set_txpower(struct mt76x2_dev *dev)
|
|||||||
mt76x2_add_rate_power_offset(&t, txp.chain[0].target_power +
|
mt76x2_add_rate_power_offset(&t, txp.chain[0].target_power +
|
||||||
txp.chain[0].delta);
|
txp.chain[0].delta);
|
||||||
mt76x2_limit_rate_power(&t, dev->txpower_conf);
|
mt76x2_limit_rate_power(&t, dev->txpower_conf);
|
||||||
dev->txpower_cur = mt76x2_get_max_power(&t);
|
dev->txpower_cur = mt76x2_get_max_rate_power(&t);
|
||||||
mt76x2_add_rate_power_offset(&t, -(txp.chain[0].target_power +
|
mt76x2_add_rate_power_offset(&t, -(txp.chain[0].target_power +
|
||||||
txp.chain[0].delta + delta));
|
txp.chain[0].delta + delta));
|
||||||
dev->target_power = txp.chain[0].target_power;
|
dev->target_power = txp.chain[0].target_power;
|
||||||
|
Loading…
Reference in New Issue
Block a user