1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2005 Miika Pekkarinen
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 ****************************************************************************/
26 #define NATIVE_FREQUENCY 44100
29 STEREO_INTERLEAVED
= 0,
30 STEREO_NONINTERLEAVED
,
43 CODEC_SET_FILEBUF_WATERMARK
= 1,
59 DSP_CALLBACK_SET_PRESCALE
= 0,
60 DSP_CALLBACK_SET_BASS
,
61 DSP_CALLBACK_SET_TREBLE
,
62 DSP_CALLBACK_SET_CHANNEL_CONFIG
,
63 DSP_CALLBACK_SET_STEREO_WIDTH
66 /* A bunch of fixed point assembler helper macros */
67 #if defined(CPU_COLDFIRE)
68 /* These macros use the Coldfire EMAC extension and need the MACSR flags set
69 * to fractional mode with no rounding.
72 /* Multiply two S.31 fractional integers and return the sign bit and the
73 * 31 most significant bits of the result.
75 #define FRACMUL(x, y) \
78 asm ("mac.l %[a], %[b], %%acc0\n\t" \
79 "movclr.l %%acc0, %[t]\n\t" \
80 : [t] "=r" (t) : [a] "r" (x), [b] "r" (y)); \
84 /* Multiply two S.31 fractional integers, and return the 32 most significant
85 * bits after a shift left by the constant z. NOTE: Only works for shifts of
88 #define FRACMUL_SHL(x, y, z) \
91 asm ("mac.l %[a], %[b], %%acc0\n\t" \
92 "moveq.l %[d], %[t]\n\t" \
93 "move.l %%accext01, %[t2]\n\t" \
94 "and.l %[mask], %[t2]\n\t" \
95 "lsr.l %[t], %[t2]\n\t" \
96 "movclr.l %%acc0, %[t]\n\t" \
97 "asl.l %[c], %[t]\n\t" \
98 "or.l %[t2], %[t]\n\t" \
99 : [t] "=&d" (t), [t2] "=&d" (t2) \
100 : [a] "r" (x), [b] "r" (y), [mask] "d" (0xff), \
101 [c] "i" ((z)), [d] "i" (8 - (z))); \
105 #elif defined(CPU_ARM)
107 /* Multiply two S.31 fractional integers and return the sign bit and the
108 * 31 most significant bits of the result.
110 #define FRACMUL(x, y) \
113 asm ("smull %[t], %[t2], %[a], %[b]\n\t" \
114 "mov %[t2], %[t2], asl #1\n\t" \
115 "orr %[t], %[t2], %[t], lsr #31\n\t" \
116 : [t] "=&r" (t), [t2] "=&r" (t2) \
117 : [a] "r" (x), [b] "r" (y)); \
121 /* Multiply two S.31 fractional integers, and return the 32 most significant
122 * bits after a shift left by the constant z.
124 #define FRACMUL_SHL(x, y, z) \
127 asm ("smull %[t], %[t2], %[a], %[b]\n\t" \
128 "mov %[t2], %[t2], asl %[c]\n\t" \
129 "orr %[t], %[t2], %[t], lsr %[d]\n\t" \
130 : [t] "=&r" (t), [t2] "=&r" (t2) \
131 : [a] "r" (x), [b] "r" (y), \
132 [c] "M" ((z) + 1), [d] "M" (31 - (z))); \
138 #define FRACMUL(x, y) (long) (((((long long) (x)) * ((long long) (y))) >> 31))
139 #define FRACMUL_SHL(x, y, z) \
140 ((long)(((((long long) (x)) * ((long long) (y))) >> (31 - (z)))))
144 #define DIV64(x, y, z) (long)(((long long)(x) << (z))/(y))
148 int dsp_process(struct dsp_config
*dsp
, char *dest
,
149 const char *src
[], int count
);
150 int dsp_input_count(struct dsp_config
*dsp
, int count
);
151 int dsp_output_count(struct dsp_config
*dsp
, int count
);
152 intptr_t dsp_configure(struct dsp_config
*dsp
, int setting
,
154 void dsp_set_replaygain(void);
155 void dsp_set_crossfeed(bool enable
);
156 void dsp_set_crossfeed_direct_gain(int gain
);
157 void dsp_set_crossfeed_cross_params(long lf_gain
, long hf_gain
,
159 void dsp_set_eq(bool enable
);
160 void dsp_set_eq_precut(int precut
);
161 void dsp_set_eq_coefs(int band
);
162 void sound_set_pitch(int r
);
163 int sound_get_pitch(void);
164 int dsp_callback(int msg
, intptr_t param
);
165 void dsp_dither_enable(bool enable
);