aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx88
diff options
context:
space:
mode:
authorMiroslav Sustek <sustmidown@centrum.cz>2009-04-06 19:07:04 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-06-16 18:14:19 -0400
commit7561300a7cea56b61fa28b36d40cdfab22af38bd (patch)
treeb51ac6a211adfd23bc9125e78cadb1b0af0b5616 /drivers/media/video/cx88
parent2325a6b98609b6559ce5da7528fc0f5a6d0d8e9b (diff)
V4L/DVB (11441): cx88-dsp: fixing 64bit math
cx88-dsp: fixing 64bit math on 32bit kernels Some gcc versions report the missing of __divdi3 [mchehab.redhat.com: CodingStyle fixes] Signed-off-by: Miroslav Sustek <sustmidown@centrum.cz> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/cx88')
-rw-r--r--drivers/media/video/cx88/cx88-dsp.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/drivers/media/video/cx88/cx88-dsp.c b/drivers/media/video/cx88/cx88-dsp.c
index a78286e853c3..3e5eaf3fe2a6 100644
--- a/drivers/media/video/cx88/cx88-dsp.c
+++ b/drivers/media/video/cx88/cx88-dsp.c
@@ -22,6 +22,7 @@
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/jiffies.h> 24#include <linux/jiffies.h>
25#include <asm/div64.h>
25 26
26#include "cx88.h" 27#include "cx88.h"
27#include "cx88-reg.h" 28#include "cx88-reg.h"
@@ -100,13 +101,25 @@ static u32 int_goertzel(s16 x[], u32 N, u32 freq)
100 s32 s_prev2 = 0; 101 s32 s_prev2 = 0;
101 s32 coeff = 2*int_cos(freq); 102 s32 coeff = 2*int_cos(freq);
102 u32 i; 103 u32 i;
104
105 u64 tmp;
106 u32 divisor;
107
103 for (i = 0; i < N; i++) { 108 for (i = 0; i < N; i++) {
104 s32 s = x[i] + ((s64)coeff*s_prev/32768) - s_prev2; 109 s32 s = x[i] + ((s64)coeff*s_prev/32768) - s_prev2;
105 s_prev2 = s_prev; 110 s_prev2 = s_prev;
106 s_prev = s; 111 s_prev = s;
107 } 112 }
108 return (u32)(((s64)s_prev2*s_prev2 + (s64)s_prev*s_prev - 113
109 (s64)coeff*s_prev2*s_prev/32768)/N/N); 114 tmp = (s64)s_prev2 * s_prev2 + (s64)s_prev * s_prev -
115 (s64)coeff * s_prev2 * s_prev / 32768;
116
117 /* XXX: N must be low enough so that N*N fits in s32.
118 * Else we need two divisions. */
119 divisor = N * N;
120 do_div(tmp, divisor);
121
122 return (u32) tmp;
110} 123}
111 124
112static u32 freq_magnitude(s16 x[], u32 N, u32 freq) 125static u32 freq_magnitude(s16 x[], u32 N, u32 freq)