1*10f8113eSArend van Spriel /* 2*10f8113eSArend van Spriel * Copyright (c) 2011 Broadcom Corporation 3*10f8113eSArend van Spriel * 4*10f8113eSArend van Spriel * Permission to use, copy, modify, and/or distribute this software for any 5*10f8113eSArend van Spriel * purpose with or without fee is hereby granted, provided that the above 6*10f8113eSArend van Spriel * copyright notice and this permission notice appear in all copies. 7*10f8113eSArend van Spriel * 8*10f8113eSArend van Spriel * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9*10f8113eSArend van Spriel * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10*10f8113eSArend van Spriel * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 11*10f8113eSArend van Spriel * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12*10f8113eSArend van Spriel * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 13*10f8113eSArend van Spriel * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 14*10f8113eSArend van Spriel * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15*10f8113eSArend van Spriel */ 16*10f8113eSArend van Spriel #ifndef __CORDIC_H_ 17*10f8113eSArend van Spriel #define __CORDIC_H_ 18*10f8113eSArend van Spriel 19*10f8113eSArend van Spriel #include <linux/types.h> 20*10f8113eSArend van Spriel 21*10f8113eSArend van Spriel /** 22*10f8113eSArend van Spriel * struct cordic_iq - i/q coordinate. 23*10f8113eSArend van Spriel * 24*10f8113eSArend van Spriel * @i: real part of coordinate (in phase). 25*10f8113eSArend van Spriel * @q: imaginary part of coordinate (quadrature). 26*10f8113eSArend van Spriel */ 27*10f8113eSArend van Spriel struct cordic_iq { 28*10f8113eSArend van Spriel s32 i; 29*10f8113eSArend van Spriel s32 q; 30*10f8113eSArend van Spriel }; 31*10f8113eSArend van Spriel 32*10f8113eSArend van Spriel /** 33*10f8113eSArend van Spriel * cordic_calc_iq() - calculates the i/q coordinate for given angle. 34*10f8113eSArend van Spriel * 35*10f8113eSArend van Spriel * @theta: angle in degrees for which i/q coordinate is to be calculated. 36*10f8113eSArend van Spriel * @coord: function output parameter holding the i/q coordinate. 37*10f8113eSArend van Spriel * 38*10f8113eSArend van Spriel * The function calculates the i/q coordinate for a given angle using 39*10f8113eSArend van Spriel * cordic algorithm. The coordinate consists of a real (i) and an 40*10f8113eSArend van Spriel * imaginary (q) part. The real part is essentially the cosine of the 41*10f8113eSArend van Spriel * angle and the imaginary part is the sine of the angle. The returned 42*10f8113eSArend van Spriel * values are scaled by 2^16 for precision. The range for theta is 43*10f8113eSArend van Spriel * for -180 degrees to +180 degrees. Passed values outside this range are 44*10f8113eSArend van Spriel * converted before doing the actual calculation. 45*10f8113eSArend van Spriel */ 46*10f8113eSArend van Spriel struct cordic_iq cordic_calc_iq(s32 theta); 47*10f8113eSArend van Spriel 48*10f8113eSArend van Spriel #endif /* __CORDIC_H_ */ 49