linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/7] rt2800: use BBP_R1 for setting tx power
@ 2012-10-05 11:44 Stanislaw Gruszka
  2012-10-05 11:44 ` [PATCH 2/7] rt2800: limit TX_PWR_CFG_ values to 0xc Stanislaw Gruszka
                   ` (6 more replies)
  0 siblings, 7 replies; 12+ messages in thread
From: Stanislaw Gruszka @ 2012-10-05 11:44 UTC (permalink / raw)
  To: John W. Linville; +Cc: linux-wireless, users, Stanislaw Gruszka

TX power delta can be negative. TX_PWR_CFG_ registers allow to set delta
only in range between 0 dBm and 15 dBm (4 bits for each rate). Se we
need to use BBP_R1 to configure negative deltas.

Not utilize +6 dBm increasing BBP_R1 option for safety reason. For now,
this can be used for devices, which export maximum allowed TX power
value.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Acked-by: Helmut Schaa <helmut.schaa@googlemail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
---
 drivers/net/wireless/rt2x00/rt2800lib.c |   27 +++++++++++++++++++--------
 1 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index 540c94f..a849a39 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -2570,13 +2570,10 @@ static void rt2800_config_txpower(struct rt2x00_dev *rt2x00dev,
 				  enum ieee80211_band band,
 				  int power_level)
 {
-	u8 txpower;
+	u8 txpower, r1;
 	u16 eeprom;
-	int i, is_rate_b;
-	u32 reg;
-	u8 r1;
-	u32 offset;
-	int delta;
+	u32 reg, offset;
+	int i, is_rate_b, delta, power_ctrl;
 
 	/*
 	 * Calculate HT40 compensation delta
@@ -2589,10 +2586,24 @@ static void rt2800_config_txpower(struct rt2x00_dev *rt2x00dev,
 	delta += rt2800_get_gain_calibration_delta(rt2x00dev);
 
 	/*
-	 * set to normal bbp tx power control mode: +/- 0dBm
+	 * BBP_R1 controls TX power for all rates, it allow to set the following
+	 * gains -12, -6, 0, +6 dBm by setting values 2, 1, 0, 3 respectively.
+	 *
+	 * TODO: we do not use +6 dBm option to do not increase power beyond
+	 * regulatory limit, however this could be utilized for devices with
+	 * CAPABILITY_POWER_LIMIT.
 	 */
 	rt2800_bbp_read(rt2x00dev, 1, &r1);
-	rt2x00_set_field8(&r1, BBP1_TX_POWER_CTRL, 0);
+	if (delta <= -12) {
+		power_ctrl = 2;
+		delta += 12;
+	} else if (delta <= -6) {
+		power_ctrl = 1;
+		delta += 6;
+	} else {
+		power_ctrl = 0;
+	}
+	rt2x00_set_field8(&r1, BBP1_TX_POWER_CTRL, power_ctrl);
 	rt2800_bbp_write(rt2x00dev, 1, r1);
 	offset = TX_PWR_CFG_0;
 
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2012-10-13  9:44 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-05 11:44 [PATCH 1/7] rt2800: use BBP_R1 for setting tx power Stanislaw Gruszka
2012-10-05 11:44 ` [PATCH 2/7] rt2800: limit TX_PWR_CFG_ values to 0xc Stanislaw Gruszka
2012-10-05 11:44 ` [PATCH 3/7] rt2800: compensate tx power also for non 11b rates on 2GHz Stanislaw Gruszka
2012-10-05 11:44 ` [PATCH 4/7] rt2800: use eeprom OFDM 6M TX power as criterion Stanislaw Gruszka
2012-10-05 11:44 ` [PATCH 5/7] rt2800: pass channel pointer to rt2800_config_txpower Stanislaw Gruszka
2012-10-05 11:44 ` [PATCH 6/7] rt2800: allow to reduce tx power on devices not exporting power limit Stanislaw Gruszka
2012-10-05 11:44 ` [PATCH 7/7] rt2800: comment tx power settings Stanislaw Gruszka
2012-10-05 16:27 ` [rt2x00-users] [PATCH 1/7] rt2800: use BBP_R1 for setting tx power Andreas Hartmann
2012-10-08  9:15   ` Stanislaw Gruszka
2012-10-13  6:47     ` Andreas Hartmann
2012-10-13  7:57       ` Stanislaw Gruszka
2012-10-13  9:42         ` Andreas Hartmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).