diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-04-06 23:07:04 +0000 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-04-06 23:07:04 +0000 |
commit | 644f5d383ba294f1f1b80c77a57ae0f3190813e3 (patch) | |
tree | 5dc88c085233b19064980b349c80afc4adc6e990 /linux/drivers/media/video/cx88 | |
parent | 40905aba779ffd9e3c84a2214d4fcaedc9baed7f (diff) | |
download | mediapointer-dvb-s2-644f5d383ba294f1f1b80c77a57ae0f3190813e3.tar.gz mediapointer-dvb-s2-644f5d383ba294f1f1b80c77a57ae0f3190813e3.tar.bz2 |
cx88-dsp: fixing 64bit math
From: Miroslav Sustek <sustmidown@centrum.cz>
cx88-dsp: fixing 64bit math on 32bit kernels
Some gcc versions report the missing of __divdi3
Signed-off-by: Miroslav Sustek <sustmidown@centrum.cz>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'linux/drivers/media/video/cx88')
-rw-r--r-- | linux/drivers/media/video/cx88/cx88-dsp.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/linux/drivers/media/video/cx88/cx88-dsp.c b/linux/drivers/media/video/cx88/cx88-dsp.c index da2b306c0..262bda9ec 100644 --- a/linux/drivers/media/video/cx88/cx88-dsp.c +++ b/linux/drivers/media/video/cx88/cx88-dsp.c @@ -100,13 +100,22 @@ static u32 int_goertzel(s16 x[], u32 N, u32 freq) s32 s_prev2 = 0; s32 coeff = 2*int_cos(freq); u32 i; + + s64 tmp; + u32 remainder; + for (i = 0; i < N; i++) { s32 s = x[i] + ((s64)coeff*s_prev/32768) - s_prev2; s_prev2 = s_prev; s_prev = s; } - return (u32)(((s64)s_prev2*s_prev2 + (s64)s_prev*s_prev - - (s64)coeff*s_prev2*s_prev/32768)/N/N); + + tmp = (s64)s_prev2*s_prev2 + (s64)s_prev*s_prev - + (s64)coeff*s_prev2*s_prev/32768; + + /* XXX: N must be low enough so that N*N fits in s32. + * Else we need two divisions. */ + return (u32) div_s64_rem(tmp, N*N, &remainder); } static u32 freq_magnitude(s16 x[], u32 N, u32 freq) |