]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/net/wireless/b43/phy_common.c
drm/ttm: using kmalloc/kfree requires including slab.h
[mv-sheeva.git] / drivers / net / wireless / b43 / phy_common.c
index 75b26e175e8fc9028da8084fac5eebb9bca3f92b..8f7d7eff2d803a79649e4a340f15a6d806089adb 100644 (file)
@@ -421,3 +421,48 @@ void b43_phyop_switch_analog_generic(struct b43_wldev *dev, bool on)
 {
        b43_write16(dev, B43_MMIO_PHY0, on ? 0 : 0xF4);
 }
+
+/* http://bcm-v4.sipsolutions.net/802.11/PHY/Cordic */
+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, };
+       u8 i;
+       s32 tmp;
+       s8 signx = 1;
+       u32 angle = 0;
+       struct b43_c32 ret = { .i = 39797, .q = 0, };
+
+       while (theta > (180 << 16))
+               theta -= (360 << 16);
+       while (theta < -(180 << 16))
+               theta += (360 << 16);
+
+       if (theta > (90 << 16)) {
+               theta -= (180 << 16);
+               signx = -1;
+       } else if (theta < -(90 << 16)) {
+               theta += (180 << 16);
+               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;
+}