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

Commit 393344f6 authored by Michael Buesch's avatar Michael Buesch Committed by John W. Linville
Browse files

[PATCH] bcm43xx: fix txpower reporting in WE.

parent 67093a65
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -525,6 +525,8 @@ struct bcm43xx_radioinfo {
	 * 3: tx_CTL2
	 * 3: tx_CTL2
	 */
	 */
	u16 txpower[4];
	u16 txpower[4];
	/* Desired TX power in dBm Q5.2 */
	u16 txpower_desired;
	/* Current Interference Mitigation mode */
	/* Current Interference Mitigation mode */
	int interfmode;
	int interfmode;
	/* Stack of saved values from the Interference Mitigation code */
	/* Stack of saved values from the Interference Mitigation code */
+4 −0
Original line number Original line Diff line number Diff line
@@ -793,6 +793,10 @@ static int bcm43xx_read_radioinfo(struct bcm43xx_private *bcm)
		bcm->current_core->radio->txpower[2] = 3;
		bcm->current_core->radio->txpower[2] = 3;
	else
	else
		bcm->current_core->radio->txpower[2] = 0;
		bcm->current_core->radio->txpower[2] = 0;
	if (bcm->current_core->phy->type == BCM43xx_PHYTYPE_A)
		bcm->current_core->radio->txpower_desired = bcm->sprom.maxpower_aphy;
	else
		bcm->current_core->radio->txpower_desired = bcm->sprom.maxpower_bgphy;


	/* Initialize the in-memory nrssi Lookup Table. */
	/* Initialize the in-memory nrssi Lookup Table. */
	for (i = 0; i < 64; i++)
	for (i = 0; i < 64; i++)
+2 −7
Original line number Original line Diff line number Diff line
@@ -1768,14 +1768,9 @@ void bcm43xx_phy_xmitpower(struct bcm43xx_private *bcm)
			where REG is the max power as per the regulatory domain
			where REG is the max power as per the regulatory domain
		*/
		*/


		/*TODO: Get desired_pwr from wx_handlers or the stack
		desired_pwr = limit_value(radio->txpower_desired, 0, max_pwr);
		limit_value(desired_pwr, 0, max_pwr);
		/* Check if we need to adjust the current power. */
		*/

		desired_pwr = max_pwr; /* remove this when we have a real desired_pwr */

		pwr_adjust = desired_pwr - estimated_pwr;
		pwr_adjust = desired_pwr - estimated_pwr;

		radio_att_delta = -(pwr_adjust + 7) >> 3;
		radio_att_delta = -(pwr_adjust + 7) >> 3;
		baseband_att_delta = -(pwr_adjust >> 1) - (4 * radio_att_delta);
		baseband_att_delta = -(pwr_adjust >> 1) - (4 * radio_att_delta);
		if ((radio_att_delta == 0) && (baseband_att_delta == 0)) {
		if ((radio_att_delta == 0) && (baseband_att_delta == 0)) {
+36 −8
Original line number Original line Diff line number Diff line
@@ -484,21 +484,40 @@ static int bcm43xx_wx_set_xmitpower(struct net_device *net_dev,
				    char *extra)
				    char *extra)
{
{
	struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
	struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
	struct bcm43xx_radioinfo *radio;
	struct bcm43xx_phyinfo *phy;
	unsigned long flags;
	unsigned long flags;
	int err = -ENODEV;
	int err = -ENODEV;
	u16 maxpower;


	wx_enter();
	wx_enter();


	if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM) {
		printk(PFX KERN_ERR "TX power not in dBm.\n");
		return -EOPNOTSUPP;
	}

	spin_lock_irqsave(&bcm->lock, flags);
	spin_lock_irqsave(&bcm->lock, flags);
	if (!bcm->initialized)
	if (!bcm->initialized)
		goto out_unlock;
		goto out_unlock;
	if (data->power.disabled != (!(bcm->current_core->radio->enabled))) {
	radio = bcm->current_core->radio;
		if (data->power.disabled)
	phy = bcm->current_core->phy;
	if (data->txpower.disabled != (!(radio->enabled))) {
		if (data->txpower.disabled)
			bcm43xx_radio_turn_off(bcm);
			bcm43xx_radio_turn_off(bcm);
		else
		else
			bcm43xx_radio_turn_on(bcm);
			bcm43xx_radio_turn_on(bcm);
	}
	}
	//TODO: set txpower.
	if (data->txpower.value > 0) {
		/* desired and maxpower dBm values are in Q5.2 */
		if (phy->type == BCM43xx_PHYTYPE_A)
			maxpower = bcm->sprom.maxpower_aphy;
		else
			maxpower = bcm->sprom.maxpower_bgphy;
		radio->txpower_desired = limit_value(data->txpower.value << 2,
						     0, maxpower);
		bcm43xx_phy_xmitpower(bcm);
	}
	err = 0;
	err = 0;


out_unlock:
out_unlock:
@@ -513,18 +532,27 @@ static int bcm43xx_wx_get_xmitpower(struct net_device *net_dev,
				    char *extra)
				    char *extra)
{
{
	struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
	struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
	struct bcm43xx_radioinfo *radio;
	unsigned long flags;
	unsigned long flags;
	int err = -ENODEV;


	wx_enter();
	wx_enter();


	spin_lock_irqsave(&bcm->lock, flags);
	spin_lock_irqsave(&bcm->lock, flags);
//TODO	data->power.value = ???
	if (!bcm->initialized)
	data->power.fixed = 1;
		goto out_unlock;
	data->power.flags = IW_TXPOW_DBM;
	radio = bcm->current_core->radio;
	data->power.disabled = !(bcm->current_core->radio->enabled);
	/* desired dBm value is in Q5.2 */
	data->txpower.value = radio->txpower_desired >> 2;
	data->txpower.fixed = 1;
	data->txpower.flags = IW_TXPOW_DBM;
	data->txpower.disabled = !(radio->enabled);

	err = 0;
out_unlock:
	spin_unlock_irqrestore(&bcm->lock, flags);
	spin_unlock_irqrestore(&bcm->lock, flags);


	return 0;
	return err;
}
}


static int bcm43xx_wx_set_retry(struct net_device *net_dev,
static int bcm43xx_wx_set_retry(struct net_device *net_dev,