1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2005 Miika Pekkarinen
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
28 #define NATIVE_FREQUENCY 44100
31 STEREO_INTERLEAVED
= 0,
32 STEREO_NONINTERLEAVED
,
60 DSP_CALLBACK_SET_PRESCALE
= 0,
61 DSP_CALLBACK_SET_BASS
,
62 DSP_CALLBACK_SET_TREBLE
,
63 DSP_CALLBACK_SET_CHANNEL_CONFIG
,
64 DSP_CALLBACK_SET_STEREO_WIDTH
67 /* A bunch of fixed point assembler helper macros */
68 #if defined(CPU_COLDFIRE)
69 /* These macros use the Coldfire EMAC extension and need the MACSR flags set
70 * to fractional mode with no rounding.
73 /* Multiply two S.31 fractional integers and return the sign bit and the
74 * 31 most significant bits of the result.
76 #define FRACMUL(x, y) \
79 asm ("mac.l %[a], %[b], %%acc0\n\t" \
80 "movclr.l %%acc0, %[t]\n\t" \
81 : [t] "=r" (t) : [a] "r" (x), [b] "r" (y)); \
85 /* Multiply two S.31 fractional integers, and return the 32 most significant
86 * bits after a shift left by the constant z. NOTE: Only works for shifts of
89 #define FRACMUL_SHL(x, y, z) \
92 asm ("mac.l %[a], %[b], %%acc0\n\t" \
93 "moveq.l %[d], %[t]\n\t" \
94 "move.l %%accext01, %[t2]\n\t" \
95 "and.l %[mask], %[t2]\n\t" \
96 "lsr.l %[t], %[t2]\n\t" \
97 "movclr.l %%acc0, %[t]\n\t" \
98 "asl.l %[c], %[t]\n\t" \
99 "or.l %[t2], %[t]\n\t" \
100 : [t] "=&d" (t), [t2] "=&d" (t2) \
101 : [a] "r" (x), [b] "r" (y), [mask] "d" (0xff), \
102 [c] "i" ((z)), [d] "i" (8 - (z))); \
106 #elif defined(CPU_ARM)
108 /* Multiply two S.31 fractional integers and return the sign bit and the
109 * 31 most significant bits of the result.
111 #define FRACMUL(x, y) \
114 asm ("smull %[t], %[t2], %[a], %[b]\n\t" \
115 "mov %[t2], %[t2], asl #1\n\t" \
116 "orr %[t], %[t2], %[t], lsr #31\n\t" \
117 : [t] "=&r" (t), [t2] "=&r" (t2) \
118 : [a] "r" (x), [b] "r" (y)); \
122 /* Multiply two S.31 fractional integers, and return the 32 most significant
123 * bits after a shift left by the constant z.
125 #define FRACMUL_SHL(x, y, z) \
128 asm ("smull %[t], %[t2], %[a], %[b]\n\t" \
129 "mov %[t2], %[t2], asl %[c]\n\t" \
130 "orr %[t], %[t2], %[t], lsr %[d]\n\t" \
131 : [t] "=&r" (t), [t2] "=&r" (t2) \
132 : [a] "r" (x), [b] "r" (y), \
133 [c] "M" ((z) + 1), [d] "M" (31 - (z))); \
139 #define FRACMUL(x, y) (long) (((((long long) (x)) * ((long long) (y))) >> 31))
140 #define FRACMUL_SHL(x, y, z) \
141 ((long)(((((long long) (x)) * ((long long) (y))) >> (31 - (z)))))
145 #define DIV64(x, y, z) (long)(((long long)(x) << (z))/(y))
149 int dsp_process(struct dsp_config
*dsp
, char *dest
,
150 const char *src
[], int count
);
151 int dsp_input_count(struct dsp_config
*dsp
, int count
);
152 int dsp_output_count(struct dsp_config
*dsp
, int count
);
153 intptr_t dsp_configure(struct dsp_config
*dsp
, int setting
,
155 void dsp_set_replaygain(void);
156 void dsp_set_crossfeed(bool enable
);
157 void dsp_set_crossfeed_direct_gain(int gain
);
158 void dsp_set_crossfeed_cross_params(long lf_gain
, long hf_gain
,
160 void dsp_set_eq(bool enable
);
161 void dsp_set_eq_precut(int precut
);
162 void dsp_set_eq_coefs(int band
);
163 void sound_set_pitch(int r
);
164 int sound_get_pitch(void);
165 int dsp_callback(int msg
, intptr_t param
);
166 void dsp_dither_enable(bool enable
);