2005-06-26 19:41:29 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005 Miika Pekkarinen
|
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef _DSP_H
|
|
|
|
#define _DSP_H
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
#define NATIVE_FREQUENCY 44100
|
2007-02-19 02:49:26 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
STEREO_INTERLEAVED = 0,
|
|
|
|
STEREO_NONINTERLEAVED,
|
|
|
|
STEREO_MONO,
|
|
|
|
STEREO_NUM_MODES,
|
|
|
|
};
|
2005-06-26 19:41:29 +00:00
|
|
|
|
2007-11-18 17:12:19 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
CODEC_IDX_AUDIO = 0,
|
|
|
|
CODEC_IDX_VOICE,
|
|
|
|
};
|
|
|
|
|
2007-02-24 17:06:36 +00:00
|
|
|
enum
|
|
|
|
{
|
2005-09-21 13:09:10 +00:00
|
|
|
CODEC_SET_FILEBUF_WATERMARK = 1,
|
2007-11-18 17:12:19 +00:00
|
|
|
DSP_MYDSP,
|
2005-09-21 13:09:10 +00:00
|
|
|
DSP_SET_FREQUENCY,
|
|
|
|
DSP_SWITCH_FREQUENCY,
|
|
|
|
DSP_SET_SAMPLE_DEPTH,
|
|
|
|
DSP_SET_STEREO_MODE,
|
|
|
|
DSP_RESET,
|
2006-11-26 12:02:47 +00:00
|
|
|
DSP_FLUSH,
|
2005-09-21 13:09:10 +00:00
|
|
|
DSP_SET_TRACK_GAIN,
|
|
|
|
DSP_SET_ALBUM_GAIN,
|
|
|
|
DSP_SET_TRACK_PEAK,
|
2005-11-14 21:56:56 +00:00
|
|
|
DSP_SET_ALBUM_PEAK,
|
|
|
|
DSP_CROSSFEED
|
2005-09-21 13:09:10 +00:00
|
|
|
};
|
|
|
|
|
2007-02-26 00:41:26 +00:00
|
|
|
enum {
|
|
|
|
DSP_CALLBACK_SET_PRESCALE = 0,
|
|
|
|
DSP_CALLBACK_SET_BASS,
|
2007-03-07 19:11:16 +00:00
|
|
|
DSP_CALLBACK_SET_TREBLE,
|
|
|
|
DSP_CALLBACK_SET_CHANNEL_CONFIG,
|
|
|
|
DSP_CALLBACK_SET_STEREO_WIDTH
|
2007-02-26 00:41:26 +00:00
|
|
|
};
|
|
|
|
|
2007-02-05 01:01:15 +00:00
|
|
|
/* A bunch of fixed point assembler helper macros */
|
2007-05-10 13:16:08 +00:00
|
|
|
#if defined(CPU_COLDFIRE)
|
2007-02-15 22:51:45 +00:00
|
|
|
/* These macros use the Coldfire EMAC extension and need the MACSR flags set
|
|
|
|
* to fractional mode with no rounding.
|
|
|
|
*/
|
2007-02-05 01:01:15 +00:00
|
|
|
|
|
|
|
/* Multiply two S.31 fractional integers and return the sign bit and the
|
|
|
|
* 31 most significant bits of the result.
|
|
|
|
*/
|
|
|
|
#define FRACMUL(x, y) \
|
|
|
|
({ \
|
|
|
|
long t; \
|
2007-02-15 22:51:45 +00:00
|
|
|
asm ("mac.l %[a], %[b], %%acc0\n\t" \
|
|
|
|
"movclr.l %%acc0, %[t]\n\t" \
|
|
|
|
: [t] "=r" (t) : [a] "r" (x), [b] "r" (y)); \
|
2007-02-05 01:01:15 +00:00
|
|
|
t; \
|
|
|
|
})
|
|
|
|
|
|
|
|
/* Multiply two S.31 fractional integers, and return the 32 most significant
|
|
|
|
* bits after a shift left by the constant z. NOTE: Only works for shifts of
|
2008-04-08 21:44:07 +00:00
|
|
|
* 1 to 8 on Coldfire!
|
2007-02-05 01:01:15 +00:00
|
|
|
*/
|
|
|
|
#define FRACMUL_SHL(x, y, z) \
|
|
|
|
({ \
|
|
|
|
long t, t2; \
|
2007-02-15 22:51:45 +00:00
|
|
|
asm ("mac.l %[a], %[b], %%acc0\n\t" \
|
|
|
|
"moveq.l %[d], %[t]\n\t" \
|
|
|
|
"move.l %%accext01, %[t2]\n\t" \
|
|
|
|
"and.l %[mask], %[t2]\n\t" \
|
|
|
|
"lsr.l %[t], %[t2]\n\t" \
|
|
|
|
"movclr.l %%acc0, %[t]\n\t" \
|
|
|
|
"asl.l %[c], %[t]\n\t" \
|
|
|
|
"or.l %[t2], %[t]\n\t" \
|
|
|
|
: [t] "=&d" (t), [t2] "=&d" (t2) \
|
|
|
|
: [a] "r" (x), [b] "r" (y), [mask] "d" (0xff), \
|
|
|
|
[c] "i" ((z)), [d] "i" (8 - (z))); \
|
2007-02-05 01:01:15 +00:00
|
|
|
t; \
|
|
|
|
})
|
|
|
|
|
2007-05-10 13:16:08 +00:00
|
|
|
#elif defined(CPU_ARM)
|
2007-02-05 01:01:15 +00:00
|
|
|
|
|
|
|
/* Multiply two S.31 fractional integers and return the sign bit and the
|
|
|
|
* 31 most significant bits of the result.
|
|
|
|
*/
|
|
|
|
#define FRACMUL(x, y) \
|
|
|
|
({ \
|
2007-02-15 22:51:45 +00:00
|
|
|
long t, t2; \
|
|
|
|
asm ("smull %[t], %[t2], %[a], %[b]\n\t" \
|
|
|
|
"mov %[t2], %[t2], asl #1\n\t" \
|
|
|
|
"orr %[t], %[t2], %[t], lsr #31\n\t" \
|
|
|
|
: [t] "=&r" (t), [t2] "=&r" (t2) \
|
|
|
|
: [a] "r" (x), [b] "r" (y)); \
|
2007-02-05 01:01:15 +00:00
|
|
|
t; \
|
|
|
|
})
|
|
|
|
|
|
|
|
/* Multiply two S.31 fractional integers, and return the 32 most significant
|
|
|
|
* bits after a shift left by the constant z.
|
|
|
|
*/
|
|
|
|
#define FRACMUL_SHL(x, y, z) \
|
|
|
|
({ \
|
2007-02-15 22:51:45 +00:00
|
|
|
long t, t2; \
|
|
|
|
asm ("smull %[t], %[t2], %[a], %[b]\n\t" \
|
|
|
|
"mov %[t2], %[t2], asl %[c]\n\t" \
|
|
|
|
"orr %[t], %[t2], %[t], lsr %[d]\n\t" \
|
|
|
|
: [t] "=&r" (t), [t2] "=&r" (t2) \
|
|
|
|
: [a] "r" (x), [b] "r" (y), \
|
|
|
|
[c] "M" ((z) + 1), [d] "M" (31 - (z))); \
|
2007-02-05 01:01:15 +00:00
|
|
|
t; \
|
|
|
|
})
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define FRACMUL(x, y) (long) (((((long long) (x)) * ((long long) (y))) >> 31))
|
2007-02-15 22:51:45 +00:00
|
|
|
#define FRACMUL_SHL(x, y, z) \
|
|
|
|
((long)(((((long long) (x)) * ((long long) (y))) >> (31 - (z)))))
|
2007-02-05 01:01:15 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define DIV64(x, y, z) (long)(((long long)(x) << (z))/(y))
|
|
|
|
|
2007-11-18 17:12:19 +00:00
|
|
|
struct dsp_config;
|
|
|
|
|
|
|
|
int dsp_process(struct dsp_config *dsp, char *dest,
|
|
|
|
const char *src[], int count);
|
|
|
|
int dsp_input_count(struct dsp_config *dsp, int count);
|
|
|
|
int dsp_output_count(struct dsp_config *dsp, int count);
|
|
|
|
intptr_t dsp_configure(struct dsp_config *dsp, int setting,
|
|
|
|
intptr_t value);
|
2007-02-24 17:06:36 +00:00
|
|
|
void dsp_set_replaygain(void);
|
2005-11-14 21:56:56 +00:00
|
|
|
void dsp_set_crossfeed(bool enable);
|
2006-04-11 13:49:05 +00:00
|
|
|
void dsp_set_crossfeed_direct_gain(int gain);
|
2007-11-18 17:12:19 +00:00
|
|
|
void dsp_set_crossfeed_cross_params(long lf_gain, long hf_gain,
|
|
|
|
long cutoff);
|
2006-03-28 21:19:30 +00:00
|
|
|
void dsp_set_eq(bool enable);
|
|
|
|
void dsp_set_eq_precut(int precut);
|
|
|
|
void dsp_set_eq_coefs(int band);
|
2005-11-28 22:26:20 +00:00
|
|
|
void sound_set_pitch(int r);
|
|
|
|
int sound_get_pitch(void);
|
2007-02-26 00:41:26 +00:00
|
|
|
int dsp_callback(int msg, intptr_t param);
|
2006-10-27 20:41:33 +00:00
|
|
|
void dsp_dither_enable(bool enable);
|
2006-03-21 23:20:17 +00:00
|
|
|
|
2005-06-26 19:41:29 +00:00
|
|
|
#endif
|