diff options
author | Michael Buesch <mbuesch@freenet.de> | 2006-02-05 09:28:20 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2006-03-27 11:18:30 -0500 |
commit | 393344f67b598aaed594b9006e9eaa44ab62caa0 (patch) | |
tree | 1662df544434f228eb2d728d2a0c43722a4bff11 | |
parent | 67093a65c08dc45374f642b1ec1b86e7095a4dc8 (diff) |
[PATCH] bcm43xx: fix txpower reporting in WE.
Signed-off-by: Michael Buesch <mbuesch@freenet.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | drivers/net/wireless/bcm43xx/bcm43xx.h | 2 | ||||
-rw-r--r-- | drivers/net/wireless/bcm43xx/bcm43xx_main.c | 4 | ||||
-rw-r--r-- | drivers/net/wireless/bcm43xx/bcm43xx_phy.c | 9 | ||||
-rw-r--r-- | drivers/net/wireless/bcm43xx/bcm43xx_wx.c | 44 |
4 files changed, 44 insertions, 15 deletions
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx.h b/drivers/net/wireless/bcm43xx/bcm43xx.h index 7b97d8bf79ed..981d563f5738 100644 --- a/drivers/net/wireless/bcm43xx/bcm43xx.h +++ b/drivers/net/wireless/bcm43xx/bcm43xx.h | |||
@@ -525,6 +525,8 @@ struct bcm43xx_radioinfo { | |||
525 | * 3: tx_CTL2 | 525 | * 3: tx_CTL2 |
526 | */ | 526 | */ |
527 | u16 txpower[4]; | 527 | u16 txpower[4]; |
528 | /* Desired TX power in dBm Q5.2 */ | ||
529 | u16 txpower_desired; | ||
528 | /* Current Interference Mitigation mode */ | 530 | /* Current Interference Mitigation mode */ |
529 | int interfmode; | 531 | int interfmode; |
530 | /* Stack of saved values from the Interference Mitigation code */ | 532 | /* Stack of saved values from the Interference Mitigation code */ |
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_main.c b/drivers/net/wireless/bcm43xx/bcm43xx_main.c index 1051a49ddafe..8e08c41f86de 100644 --- a/drivers/net/wireless/bcm43xx/bcm43xx_main.c +++ b/drivers/net/wireless/bcm43xx/bcm43xx_main.c | |||
@@ -793,6 +793,10 @@ static int bcm43xx_read_radioinfo(struct bcm43xx_private *bcm) | |||
793 | bcm->current_core->radio->txpower[2] = 3; | 793 | bcm->current_core->radio->txpower[2] = 3; |
794 | else | 794 | else |
795 | bcm->current_core->radio->txpower[2] = 0; | 795 | bcm->current_core->radio->txpower[2] = 0; |
796 | if (bcm->current_core->phy->type == BCM43xx_PHYTYPE_A) | ||
797 | bcm->current_core->radio->txpower_desired = bcm->sprom.maxpower_aphy; | ||
798 | else | ||
799 | bcm->current_core->radio->txpower_desired = bcm->sprom.maxpower_bgphy; | ||
796 | 800 | ||
797 | /* Initialize the in-memory nrssi Lookup Table. */ | 801 | /* Initialize the in-memory nrssi Lookup Table. */ |
798 | for (i = 0; i < 64; i++) | 802 | for (i = 0; i < 64; i++) |
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_phy.c b/drivers/net/wireless/bcm43xx/bcm43xx_phy.c index d90f207b2473..d3c2fc1df375 100644 --- a/drivers/net/wireless/bcm43xx/bcm43xx_phy.c +++ b/drivers/net/wireless/bcm43xx/bcm43xx_phy.c | |||
@@ -1768,14 +1768,9 @@ void bcm43xx_phy_xmitpower(struct bcm43xx_private *bcm) | |||
1768 | where REG is the max power as per the regulatory domain | 1768 | where REG is the max power as per the regulatory domain |
1769 | */ | 1769 | */ |
1770 | 1770 | ||
1771 | /*TODO: Get desired_pwr from wx_handlers or the stack | 1771 | desired_pwr = limit_value(radio->txpower_desired, 0, max_pwr); |
1772 | limit_value(desired_pwr, 0, max_pwr); | 1772 | /* Check if we need to adjust the current power. */ |
1773 | */ | ||
1774 | |||
1775 | desired_pwr = max_pwr; /* remove this when we have a real desired_pwr */ | ||
1776 | |||
1777 | pwr_adjust = desired_pwr - estimated_pwr; | 1773 | pwr_adjust = desired_pwr - estimated_pwr; |
1778 | |||
1779 | radio_att_delta = -(pwr_adjust + 7) >> 3; | 1774 | radio_att_delta = -(pwr_adjust + 7) >> 3; |
1780 | baseband_att_delta = -(pwr_adjust >> 1) - (4 * radio_att_delta); | 1775 | baseband_att_delta = -(pwr_adjust >> 1) - (4 * radio_att_delta); |
1781 | if ((radio_att_delta == 0) && (baseband_att_delta == 0)) { | 1776 | if ((radio_att_delta == 0) && (baseband_att_delta == 0)) { |
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_wx.c b/drivers/net/wireless/bcm43xx/bcm43xx_wx.c index c1d788d50f49..bed7cfbe81d3 100644 --- a/drivers/net/wireless/bcm43xx/bcm43xx_wx.c +++ b/drivers/net/wireless/bcm43xx/bcm43xx_wx.c | |||
@@ -484,21 +484,40 @@ static int bcm43xx_wx_set_xmitpower(struct net_device *net_dev, | |||
484 | char *extra) | 484 | char *extra) |
485 | { | 485 | { |
486 | struct bcm43xx_private *bcm = bcm43xx_priv(net_dev); | 486 | struct bcm43xx_private *bcm = bcm43xx_priv(net_dev); |
487 | struct bcm43xx_radioinfo *radio; | ||
488 | struct bcm43xx_phyinfo *phy; | ||
487 | unsigned long flags; | 489 | unsigned long flags; |
488 | int err = -ENODEV; | 490 | int err = -ENODEV; |
491 | u16 maxpower; | ||
489 | 492 | ||
490 | wx_enter(); | 493 | wx_enter(); |
491 | 494 | ||
495 | if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM) { | ||
496 | printk(PFX KERN_ERR "TX power not in dBm.\n"); | ||
497 | return -EOPNOTSUPP; | ||
498 | } | ||
499 | |||
492 | spin_lock_irqsave(&bcm->lock, flags); | 500 | spin_lock_irqsave(&bcm->lock, flags); |
493 | if (!bcm->initialized) | 501 | if (!bcm->initialized) |
494 | goto out_unlock; | 502 | goto out_unlock; |
495 | if (data->power.disabled != (!(bcm->current_core->radio->enabled))) { | 503 | radio = bcm->current_core->radio; |
496 | if (data->power.disabled) | 504 | phy = bcm->current_core->phy; |
505 | if (data->txpower.disabled != (!(radio->enabled))) { | ||
506 | if (data->txpower.disabled) | ||
497 | bcm43xx_radio_turn_off(bcm); | 507 | bcm43xx_radio_turn_off(bcm); |
498 | else | 508 | else |
499 | bcm43xx_radio_turn_on(bcm); | 509 | bcm43xx_radio_turn_on(bcm); |
500 | } | 510 | } |
501 | //TODO: set txpower. | 511 | if (data->txpower.value > 0) { |
512 | /* desired and maxpower dBm values are in Q5.2 */ | ||
513 | if (phy->type == BCM43xx_PHYTYPE_A) | ||
514 | maxpower = bcm->sprom.maxpower_aphy; | ||
515 | else | ||
516 | maxpower = bcm->sprom.maxpower_bgphy; | ||
517 | radio->txpower_desired = limit_value(data->txpower.value << 2, | ||
518 | 0, maxpower); | ||
519 | bcm43xx_phy_xmitpower(bcm); | ||
520 | } | ||
502 | err = 0; | 521 | err = 0; |
503 | 522 | ||
504 | out_unlock: | 523 | out_unlock: |
@@ -513,18 +532,27 @@ static int bcm43xx_wx_get_xmitpower(struct net_device *net_dev, | |||
513 | char *extra) | 532 | char *extra) |
514 | { | 533 | { |
515 | struct bcm43xx_private *bcm = bcm43xx_priv(net_dev); | 534 | struct bcm43xx_private *bcm = bcm43xx_priv(net_dev); |
535 | struct bcm43xx_radioinfo *radio; | ||
516 | unsigned long flags; | 536 | unsigned long flags; |
537 | int err = -ENODEV; | ||
517 | 538 | ||
518 | wx_enter(); | 539 | wx_enter(); |
519 | 540 | ||
520 | spin_lock_irqsave(&bcm->lock, flags); | 541 | spin_lock_irqsave(&bcm->lock, flags); |
521 | //TODO data->power.value = ??? | 542 | if (!bcm->initialized) |
522 | data->power.fixed = 1; | 543 | goto out_unlock; |
523 | data->power.flags = IW_TXPOW_DBM; | 544 | radio = bcm->current_core->radio; |
524 | data->power.disabled = !(bcm->current_core->radio->enabled); | 545 | /* desired dBm value is in Q5.2 */ |
546 | data->txpower.value = radio->txpower_desired >> 2; | ||
547 | data->txpower.fixed = 1; | ||
548 | data->txpower.flags = IW_TXPOW_DBM; | ||
549 | data->txpower.disabled = !(radio->enabled); | ||
550 | |||
551 | err = 0; | ||
552 | out_unlock: | ||
525 | spin_unlock_irqrestore(&bcm->lock, flags); | 553 | spin_unlock_irqrestore(&bcm->lock, flags); |
526 | 554 | ||
527 | return 0; | 555 | return err; |
528 | } | 556 | } |
529 | 557 | ||
530 | static int bcm43xx_wx_set_retry(struct net_device *net_dev, | 558 | static int bcm43xx_wx_set_retry(struct net_device *net_dev, |