diff options
author | Rafał Miłecki <zajec5@gmail.com> | 2010-01-25 12:59:59 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-01-25 16:36:31 -0500 |
commit | 986504540306137dfc90a936f9f25086d15621c5 (patch) | |
tree | e41a8ea05d14152054f07fe3c4bd2fbc3c7836bb /drivers/net/wireless/b43 | |
parent | 3ed0fac3b56504aaaa3d800e7891ed4a7068b85c (diff) |
b43: make cordic common (LP-PHY and N-PHY need it)
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/b43')
-rw-r--r-- | drivers/net/wireless/b43/phy_common.c | 38 | ||||
-rw-r--r-- | drivers/net/wireless/b43/phy_common.h | 3 | ||||
-rw-r--r-- | drivers/net/wireless/b43/phy_lp.c | 45 |
3 files changed, 43 insertions, 43 deletions
diff --git a/drivers/net/wireless/b43/phy_common.c b/drivers/net/wireless/b43/phy_common.c index 75b26e175e8f..446c41bb1e9f 100644 --- a/drivers/net/wireless/b43/phy_common.c +++ b/drivers/net/wireless/b43/phy_common.c | |||
@@ -421,3 +421,41 @@ void b43_phyop_switch_analog_generic(struct b43_wldev *dev, bool on) | |||
421 | { | 421 | { |
422 | b43_write16(dev, B43_MMIO_PHY0, on ? 0 : 0xF4); | 422 | b43_write16(dev, B43_MMIO_PHY0, on ? 0 : 0xF4); |
423 | } | 423 | } |
424 | |||
425 | struct b43_c32 b43_cordic(int theta) | ||
426 | { | ||
427 | u32 arctg[] = { 2949120, 1740967, 919879, 466945, 234379, 117304, | ||
428 | 58666, 29335, 14668, 7334, 3667, 1833, 917, 458, | ||
429 | 229, 115, 57, 29, }; | ||
430 | int i, tmp, signx = 1, angle = 0; | ||
431 | struct b43_c32 ret = { .i = 39797, .q = 0, }; | ||
432 | |||
433 | theta = clamp_t(int, theta, -180, 180); | ||
434 | |||
435 | if (theta > 90) { | ||
436 | theta -= 180; | ||
437 | signx = -1; | ||
438 | } else if (theta < -90) { | ||
439 | theta += 180; | ||
440 | signx = -1; | ||
441 | } | ||
442 | |||
443 | for (i = 0; i <= 17; i++) { | ||
444 | if (theta > angle) { | ||
445 | tmp = ret.i - (ret.q >> i); | ||
446 | ret.q += ret.i >> i; | ||
447 | ret.i = tmp; | ||
448 | angle += arctg[i]; | ||
449 | } else { | ||
450 | tmp = ret.i + (ret.q >> i); | ||
451 | ret.q -= ret.i >> i; | ||
452 | ret.i = tmp; | ||
453 | angle -= arctg[i]; | ||
454 | } | ||
455 | } | ||
456 | |||
457 | ret.i *= signx; | ||
458 | ret.q *= signx; | ||
459 | |||
460 | return ret; | ||
461 | } | ||
diff --git a/drivers/net/wireless/b43/phy_common.h b/drivers/net/wireless/b43/phy_common.h index f635f9e4f83d..9e4de47d0608 100644 --- a/drivers/net/wireless/b43/phy_common.h +++ b/drivers/net/wireless/b43/phy_common.h | |||
@@ -5,6 +5,8 @@ | |||
5 | 5 | ||
6 | struct b43_wldev; | 6 | struct b43_wldev; |
7 | 7 | ||
8 | /* Complex number using 2 32-bit signed integers */ | ||
9 | struct b43_c32 { s32 i, q; }; | ||
8 | 10 | ||
9 | /* PHY register routing bits */ | 11 | /* PHY register routing bits */ |
10 | #define B43_PHYROUTE 0x0C00 /* PHY register routing bits mask */ | 12 | #define B43_PHYROUTE 0x0C00 /* PHY register routing bits mask */ |
@@ -421,5 +423,6 @@ int b43_phy_shm_tssi_read(struct b43_wldev *dev, u16 shm_offset); | |||
421 | */ | 423 | */ |
422 | void b43_phyop_switch_analog_generic(struct b43_wldev *dev, bool on); | 424 | void b43_phyop_switch_analog_generic(struct b43_wldev *dev, bool on); |
423 | 425 | ||
426 | struct b43_c32 b43_cordic(int theta); | ||
424 | 427 | ||
425 | #endif /* LINUX_B43_PHY_COMMON_H_ */ | 428 | #endif /* LINUX_B43_PHY_COMMON_H_ */ |
diff --git a/drivers/net/wireless/b43/phy_lp.c b/drivers/net/wireless/b43/phy_lp.c index b58d6cf26580..453585073437 100644 --- a/drivers/net/wireless/b43/phy_lp.c +++ b/drivers/net/wireless/b43/phy_lp.c | |||
@@ -1767,47 +1767,6 @@ out: | |||
1767 | return ret; | 1767 | return ret; |
1768 | } | 1768 | } |
1769 | 1769 | ||
1770 | /* Complex number using 2 32-bit signed integers */ | ||
1771 | typedef struct {s32 i, q;} lpphy_c32; | ||
1772 | |||
1773 | static lpphy_c32 lpphy_cordic(int theta) | ||
1774 | { | ||
1775 | u32 arctg[] = { 2949120, 1740967, 919879, 466945, 234379, 117304, | ||
1776 | 58666, 29335, 14668, 7334, 3667, 1833, 917, 458, | ||
1777 | 229, 115, 57, 29, }; | ||
1778 | int i, tmp, signx = 1, angle = 0; | ||
1779 | lpphy_c32 ret = { .i = 39797, .q = 0, }; | ||
1780 | |||
1781 | theta = clamp_t(int, theta, -180, 180); | ||
1782 | |||
1783 | if (theta > 90) { | ||
1784 | theta -= 180; | ||
1785 | signx = -1; | ||
1786 | } else if (theta < -90) { | ||
1787 | theta += 180; | ||
1788 | signx = -1; | ||
1789 | } | ||
1790 | |||
1791 | for (i = 0; i <= 17; i++) { | ||
1792 | if (theta > angle) { | ||
1793 | tmp = ret.i - (ret.q >> i); | ||
1794 | ret.q += ret.i >> i; | ||
1795 | ret.i = tmp; | ||
1796 | angle += arctg[i]; | ||
1797 | } else { | ||
1798 | tmp = ret.i + (ret.q >> i); | ||
1799 | ret.q -= ret.i >> i; | ||
1800 | ret.i = tmp; | ||
1801 | angle -= arctg[i]; | ||
1802 | } | ||
1803 | } | ||
1804 | |||
1805 | ret.i *= signx; | ||
1806 | ret.q *= signx; | ||
1807 | |||
1808 | return ret; | ||
1809 | } | ||
1810 | |||
1811 | static void lpphy_run_samples(struct b43_wldev *dev, u16 samples, u16 loops, | 1770 | static void lpphy_run_samples(struct b43_wldev *dev, u16 samples, u16 loops, |
1812 | u16 wait) | 1771 | u16 wait) |
1813 | { | 1772 | { |
@@ -1826,7 +1785,7 @@ static void lpphy_start_tx_tone(struct b43_wldev *dev, s32 freq, u16 max) | |||
1826 | struct b43_phy_lp *lpphy = dev->phy.lp; | 1785 | struct b43_phy_lp *lpphy = dev->phy.lp; |
1827 | u16 buf[64]; | 1786 | u16 buf[64]; |
1828 | int i, samples = 0, angle = 0, rotation = (9 * freq) / 500; | 1787 | int i, samples = 0, angle = 0, rotation = (9 * freq) / 500; |
1829 | lpphy_c32 sample; | 1788 | struct b43_c32 sample; |
1830 | 1789 | ||
1831 | lpphy->tx_tone_freq = freq; | 1790 | lpphy->tx_tone_freq = freq; |
1832 | 1791 | ||
@@ -1842,7 +1801,7 @@ static void lpphy_start_tx_tone(struct b43_wldev *dev, s32 freq, u16 max) | |||
1842 | } | 1801 | } |
1843 | 1802 | ||
1844 | for (i = 0; i < samples; i++) { | 1803 | for (i = 0; i < samples; i++) { |
1845 | sample = lpphy_cordic(angle); | 1804 | sample = b43_cordic(angle); |
1846 | angle += rotation; | 1805 | angle += rotation; |
1847 | buf[i] = ((sample.i * max) & 0xFF) << 8; | 1806 | buf[i] = ((sample.i * max) & 0xFF) << 8; |
1848 | buf[i] |= (sample.q * max) & 0xFF; | 1807 | buf[i] |= (sample.q * max) & 0xFF; |