1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2006 Thom Johansen
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
23 lea.l (-11*4, %sp), %sp
24 movem.l %d2-%d7/%a2-%a6, (%sp) | save clobbered regs
25 move.l (11*4+8, %sp), %a5 | fetch filter structure address
26 movem.l (11*4+16, %sp), %d6-%d7 | load num. channels and shift count
27 subq.l #1, %d7 | EMAC gives us one free shift
28 movem.l (%a5), %a0-%a4 | load coefs
29 lea.l (5*4, %a5), %a5 | point to filter history
32 move.l (11*4+4, %sp), %a6 | load input channel pointer
33 addq.l #4, (11*4+4, %sp) | point x to next channel
35 move.l (11*4+12, %sp), %d5 | number of samples
36 movem.l (%a5), %d0-%d3 | load filter history
38 /* Direct form 1 filtering code. We assume DSP has put EMAC in frac mode.
39 y[n] = b0*x[i] + b1*x[i - 1] + b2*x[i - 2] + a1*y[i - 1] + a2*y[i - 2],
40 where y[] is output and x[] is input. This is performed out of order
41 to do parallel load of input value.
43 mac.l %a2, %d1, %acc0 | acc = b2*x[i - 2]
44 move.l %d0, %d1 | fix input history
45 mac.l %a1, %d0, (%a6), %d0, %acc0 | acc += b1*x[i - 1], x[i] -> d0
46 mac.l %a0, %d0, %acc0 | acc += b0*x[i]
47 mac.l %a3, %d2, %acc0 | acc += a1*y[i - 1]
48 mac.l %a4, %d3, %acc0 | acc += a2*y[i - 2]
49 move.l %d2, %d3 | fix output history
50 movclr.l %acc0, %d2 | fetch and write result
51 asl.l %d7, %d2 | restore fixed point format
52 move.l %d2, (%a6)+ | save result
53 subq.l #1, %d5 | are we done with this channel?
56 movem.l %d0-%d3, (%a5) | save history back to struct
57 lea.l (4*4, %a5), %a5 | point to next channel's history
58 subq.l #1, %d6 | have we processed both channels?
61 movem.l (%sp), %d2-%d7/%a2-%a6
62 lea.l (11*4, %sp), %sp