diff options
author | Rafał Miłecki <zajec5@gmail.com> | 2010-01-25 18:59:59 +0100 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-01-25 16:36:31 -0500 |
commit | 986504540306137dfc90a936f9f25086d15621c5 (patch) | |
tree | e41a8ea05d14152054f07fe3c4bd2fbc3c7836bb /drivers/net/wireless/b43/phy_common.c | |
parent | 3ed0fac3b56504aaaa3d800e7891ed4a7068b85c (diff) | |
download | talos-obmc-linux-986504540306137dfc90a936f9f25086d15621c5.tar.gz talos-obmc-linux-986504540306137dfc90a936f9f25086d15621c5.zip |
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/phy_common.c')
-rw-r--r-- | drivers/net/wireless/b43/phy_common.c | 38 |
1 files changed, 38 insertions, 0 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) { b43_write16(dev, B43_MMIO_PHY0, on ? 0 : 0xF4); } + +struct b43_c32 b43_cordic(int theta) +{ + u32 arctg[] = { 2949120, 1740967, 919879, 466945, 234379, 117304, + 58666, 29335, 14668, 7334, 3667, 1833, 917, 458, + 229, 115, 57, 29, }; + int i, tmp, signx = 1, angle = 0; + struct b43_c32 ret = { .i = 39797, .q = 0, }; + + theta = clamp_t(int, theta, -180, 180); + + if (theta > 90) { + theta -= 180; + signx = -1; + } else if (theta < -90) { + theta += 180; + signx = -1; + } + + for (i = 0; i <= 17; i++) { + if (theta > angle) { + tmp = ret.i - (ret.q >> i); + ret.q += ret.i >> i; + ret.i = tmp; + angle += arctg[i]; + } else { + tmp = ret.i + (ret.q >> i); + ret.q -= ret.i >> i; + ret.i = tmp; + angle -= arctg[i]; + } + } + + ret.i *= signx; + ret.q *= signx; + + return ret; +} |