Hi Mauro, I was able to test your patch with vivid sdr tone generation. It calls sin/cos functions with radians as argument. I find that the sine wave generated using fixp_sin32_rad() show discontinuities, especially around 90, 180 degrees. After debugging it further, these discontinuities seems to be originating due to division of negative number. Please find it below On 17/12/14 7:12 pm, "Mauro Carvalho Chehab" <mchehab@xxxxxxxxxxxxxxx> wrote: > >+ */ >+static inline s32 fixp_sin32_rad(u32 radians, u32 twopi) > { >+ int degrees; >+ s32 v1, v2, dx, dy; >+ s64 tmp; >+ degrees = (radians * 360) / twopi; Not sure if we should use higher precision here. But just a question - in case, caller function uses higher precision for representing radians, (radians * 360) can probably overflow, right ? So, could we possibly specify on max precision for representing radian fraction cannot be more than 18 bits. >+ v1 = fixp_sin32(degrees); >+ v2 = fixp_sin32(degrees + 1); >+ dx = twopi / 360; >+ dy = v2 - v1; >+ tmp = radians - (degrees * twopi) / 360; Same as above. >+ tmp *= dy; >+ do_div(tmp, dx); tmp can go negative. do_div() cannot handle negative number. We could probably avoid do_div and do tmp / dx here. If we want to use do_div(), we could still do it by modifying radian to degree calculation. tmp goes negative when the slope sine waveform is negative, that is 2nd and 3rd quadrant. We could avoid it by deciding the quadrant based on radians and then calling fixp_sin32(). I modified the function on lines of fixp_sin32() and tested. It works fine. Attaching a diff for fixp-arith.h for with the this change to avoid negative values of tmp in fixp_sin32_rad(). >2.1.0 >
Attachment:
fixp-arith.diff
Description: fixp-arith.diff