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
,
45 CODEC_SET_FILEBUF_WATERMARK
= 1,
61 DSP_CALLBACK_SET_PRESCALE
= 0,
62 DSP_CALLBACK_SET_BASS
,
63 DSP_CALLBACK_SET_TREBLE
,
64 DSP_CALLBACK_SET_CHANNEL_CONFIG
,
65 DSP_CALLBACK_SET_STEREO_WIDTH
68 /* A bunch of fixed point assembler helper macros */
69 #if defined(CPU_COLDFIRE)
70 /* These macros use the Coldfire EMAC extension and need the MACSR flags set
71 * to fractional mode with no rounding.
74 /* Multiply two S.31 fractional integers and return the sign bit and the
75 * 31 most significant bits of the result.
77 #define FRACMUL(x, y) \
80 asm ("mac.l %[a], %[b], %%acc0\n\t" \
81 "movclr.l %%acc0, %[t]\n\t" \
82 : [t] "=r" (t) : [a] "r" (x), [b] "r" (y)); \
86 /* Multiply two S.31 fractional integers, and return the 32 most significant
87 * bits after a shift left by the constant z. NOTE: Only works for shifts of
90 #define FRACMUL_SHL(x, y, z) \
93 asm ("mac.l %[a], %[b], %%acc0\n\t" \
94 "moveq.l %[d], %[t]\n\t" \
95 "move.l %%accext01, %[t2]\n\t" \
96 "and.l %[mask], %[t2]\n\t" \
97 "lsr.l %[t], %[t2]\n\t" \
98 "movclr.l %%acc0, %[t]\n\t" \
99 "asl.l %[c], %[t]\n\t" \
100 "or.l %[t2], %[t]\n\t" \
101 : [t] "=&d" (t), [t2] "=&d" (t2) \
102 : [a] "r" (x), [b] "r" (y), [mask] "d" (0xff), \
103 [c] "i" ((z)), [d] "i" (8 - (z))); \
107 #elif defined(CPU_ARM)
109 /* Multiply two S.31 fractional integers and return the sign bit and the
110 * 31 most significant bits of the result.
112 #define FRACMUL(x, y) \
115 asm ("smull %[t], %[t2], %[a], %[b]\n\t" \
116 "mov %[t2], %[t2], asl #1\n\t" \
117 "orr %[t], %[t2], %[t], lsr #31\n\t" \
118 : [t] "=&r" (t), [t2] "=&r" (t2) \
119 : [a] "r" (x), [b] "r" (y)); \
123 /* Multiply two S.31 fractional integers, and return the 32 most significant
124 * bits after a shift left by the constant z.
126 #define FRACMUL_SHL(x, y, z) \
129 asm ("smull %[t], %[t2], %[a], %[b]\n\t" \
130 "mov %[t2], %[t2], asl %[c]\n\t" \
131 "orr %[t], %[t2], %[t], lsr %[d]\n\t" \
132 : [t] "=&r" (t), [t2] "=&r" (t2) \
133 : [a] "r" (x), [b] "r" (y), \
134 [c] "M" ((z) + 1), [d] "M" (31 - (z))); \
140 #define FRACMUL(x, y) (long) (((((long long) (x)) * ((long long) (y))) >> 31))
141 #define FRACMUL_SHL(x, y, z) \
142 ((long)(((((long long) (x)) * ((long long) (y))) >> (31 - (z)))))
146 #define DIV64(x, y, z) (long)(((long long)(x) << (z))/(y))
150 int dsp_process(struct dsp_config
*dsp
, char *dest
,
151 const char *src
[], int count
);
152 int dsp_input_count(struct dsp_config
*dsp
, int count
);
153 int dsp_output_count(struct dsp_config
*dsp
, int count
);
154 intptr_t dsp_configure(struct dsp_config
*dsp
, int setting
,
156 void dsp_set_replaygain(void);
157 void dsp_set_crossfeed(bool enable
);
158 void dsp_set_crossfeed_direct_gain(int gain
);
159 void dsp_set_crossfeed_cross_params(long lf_gain
, long hf_gain
,
161 void dsp_set_eq(bool enable
);
162 void dsp_set_eq_precut(int precut
);
163 void dsp_set_eq_coefs(int band
);
164 void sound_set_pitch(int r
);
165 int sound_get_pitch(void);
166 int dsp_callback(int msg
, intptr_t param
);
167 void dsp_dither_enable(bool enable
);