aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r--drivers/net/wireless/b43/phy_common.c19
-rw-r--r--drivers/net/wireless/b43/phy_common.h4
-rw-r--r--drivers/net/wireless/b43/phy_lp.c7
3 files changed, 21 insertions, 9 deletions
diff --git a/drivers/net/wireless/b43/phy_common.c b/drivers/net/wireless/b43/phy_common.c
index 446c41bb1e9f..8f7d7eff2d80 100644
--- a/drivers/net/wireless/b43/phy_common.c
+++ b/drivers/net/wireless/b43/phy_common.c
@@ -422,21 +422,28 @@ void b43_phyop_switch_analog_generic(struct b43_wldev *dev, bool on)
422 b43_write16(dev, B43_MMIO_PHY0, on ? 0 : 0xF4); 422 b43_write16(dev, B43_MMIO_PHY0, on ? 0 : 0xF4);
423} 423}
424 424
425/* http://bcm-v4.sipsolutions.net/802.11/PHY/Cordic */
425struct b43_c32 b43_cordic(int theta) 426struct b43_c32 b43_cordic(int theta)
426{ 427{
427 u32 arctg[] = { 2949120, 1740967, 919879, 466945, 234379, 117304, 428 u32 arctg[] = { 2949120, 1740967, 919879, 466945, 234379, 117304,
428 58666, 29335, 14668, 7334, 3667, 1833, 917, 458, 429 58666, 29335, 14668, 7334, 3667, 1833, 917, 458,
429 229, 115, 57, 29, }; 430 229, 115, 57, 29, };
430 int i, tmp, signx = 1, angle = 0; 431 u8 i;
432 s32 tmp;
433 s8 signx = 1;
434 u32 angle = 0;
431 struct b43_c32 ret = { .i = 39797, .q = 0, }; 435 struct b43_c32 ret = { .i = 39797, .q = 0, };
432 436
433 theta = clamp_t(int, theta, -180, 180); 437 while (theta > (180 << 16))
438 theta -= (360 << 16);
439 while (theta < -(180 << 16))
440 theta += (360 << 16);
434 441
435 if (theta > 90) { 442 if (theta > (90 << 16)) {
436 theta -= 180; 443 theta -= (180 << 16);
437 signx = -1; 444 signx = -1;
438 } else if (theta < -90) { 445 } else if (theta < -(90 << 16)) {
439 theta += 180; 446 theta += (180 << 16);
440 signx = -1; 447 signx = -1;
441 } 448 }
442 449
diff --git a/drivers/net/wireless/b43/phy_common.h b/drivers/net/wireless/b43/phy_common.h
index 9e4de47d0608..bd480b481bfc 100644
--- a/drivers/net/wireless/b43/phy_common.h
+++ b/drivers/net/wireless/b43/phy_common.h
@@ -8,6 +8,10 @@ struct b43_wldev;
8/* Complex number using 2 32-bit signed integers */ 8/* Complex number using 2 32-bit signed integers */
9struct b43_c32 { s32 i, q; }; 9struct b43_c32 { s32 i, q; };
10 10
11#define CORDIC_CONVERT(value) (((value) >= 0) ? \
12 ((((value) >> 15) + 1) >> 1) : \
13 -((((-(value)) >> 15) + 1) >> 1))
14
11/* PHY register routing bits */ 15/* PHY register routing bits */
12#define B43_PHYROUTE 0x0C00 /* PHY register routing bits mask */ 16#define B43_PHYROUTE 0x0C00 /* PHY register routing bits mask */
13#define B43_PHYROUTE_BASE 0x0000 /* Base registers */ 17#define B43_PHYROUTE_BASE 0x0000 /* Base registers */
diff --git a/drivers/net/wireless/b43/phy_lp.c b/drivers/net/wireless/b43/phy_lp.c
index 453585073437..185219e0a552 100644
--- a/drivers/net/wireless/b43/phy_lp.c
+++ b/drivers/net/wireless/b43/phy_lp.c
@@ -1784,7 +1784,8 @@ static void lpphy_start_tx_tone(struct b43_wldev *dev, s32 freq, u16 max)
1784{ 1784{
1785 struct b43_phy_lp *lpphy = dev->phy.lp; 1785 struct b43_phy_lp *lpphy = dev->phy.lp;
1786 u16 buf[64]; 1786 u16 buf[64];
1787 int i, samples = 0, angle = 0, rotation = (9 * freq) / 500; 1787 int i, samples = 0, angle = 0;
1788 int rotation = (((36 * freq) / 20) << 16) / 100;
1788 struct b43_c32 sample; 1789 struct b43_c32 sample;
1789 1790
1790 lpphy->tx_tone_freq = freq; 1791 lpphy->tx_tone_freq = freq;
@@ -1803,8 +1804,8 @@ static void lpphy_start_tx_tone(struct b43_wldev *dev, s32 freq, u16 max)
1803 for (i = 0; i < samples; i++) { 1804 for (i = 0; i < samples; i++) {
1804 sample = b43_cordic(angle); 1805 sample = b43_cordic(angle);
1805 angle += rotation; 1806 angle += rotation;
1806 buf[i] = ((sample.i * max) & 0xFF) << 8; 1807 buf[i] = CORDIC_CONVERT((sample.i * max) & 0xFF) << 8;
1807 buf[i] |= (sample.q * max) & 0xFF; 1808 buf[i] |= CORDIC_CONVERT((sample.q * max) & 0xFF);
1808 } 1809 }
1809 1810
1810 b43_lptab_write_bulk(dev, B43_LPTAB16(5, 0), samples, buf); 1811 b43_lptab_write_bulk(dev, B43_LPTAB16(5, 0), samples, buf);