blob: 2a00f649f854596ad13a04f1fd3f7a5d70a2bc2e [file] [log] [blame]
Miika Pekkarinend8cb7032005-06-26 19:41:29 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2005 Miika Pekkarinen
11 *
Daniel Stenberg2acc0ac2008-06-28 18:10:04 +000012 * 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.
Miika Pekkarinend8cb7032005-06-26 19:41:29 +000016 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef _DSP_H
23#define _DSP_H
24
25#include <stdlib.h>
Miika Pekkarinend8cb7032005-06-26 19:41:29 +000026#include <stdbool.h>
27
28#define NATIVE_FREQUENCY 44100
Jeffrey Goodecf19ba52009-09-25 15:46:38 +000029
Michael Sevakis36175ac2007-02-19 02:49:26 +000030enum
31{
32 STEREO_INTERLEAVED = 0,
33 STEREO_NONINTERLEAVED,
34 STEREO_MONO,
35 STEREO_NUM_MODES,
36};
Miika Pekkarinend8cb7032005-06-26 19:41:29 +000037
Michael Sevakisd4e904b2007-02-24 17:06:36 +000038enum
39{
Michael Sevakis99617d72007-11-18 17:12:19 +000040 CODEC_IDX_AUDIO = 0,
41 CODEC_IDX_VOICE,
42};
43
44enum
45{
Björn Stenberg6427d122009-01-10 21:10:56 +000046 DSP_MYDSP = 1,
Thom Johansenf60e6202005-09-21 13:09:10 +000047 DSP_SET_FREQUENCY,
48 DSP_SWITCH_FREQUENCY,
Thom Johansenf60e6202005-09-21 13:09:10 +000049 DSP_SET_SAMPLE_DEPTH,
50 DSP_SET_STEREO_MODE,
51 DSP_RESET,
Michael Sevakisbbef13e2006-11-26 12:02:47 +000052 DSP_FLUSH,
Thom Johansenf60e6202005-09-21 13:09:10 +000053 DSP_SET_TRACK_GAIN,
54 DSP_SET_ALBUM_GAIN,
55 DSP_SET_TRACK_PEAK,
Marcoen Hirschberge13fad32005-11-14 21:56:56 +000056 DSP_SET_ALBUM_PEAK,
57 DSP_CROSSFEED
Thom Johansenf60e6202005-09-21 13:09:10 +000058};
59
Michael Sevakis1ab9d142012-02-08 14:55:37 -050060
61/****************************************************************************
62 * NOTE: Any assembly routines that use these structures must be updated
63 * if current data members are moved or changed.
64 */
65struct resample_data
66{
67 uint32_t delta; /* 00h */
68 uint32_t phase; /* 04h */
69 int32_t last_sample[2]; /* 08h */
70 /* 10h */
71};
72
73/* This is for passing needed data to external dsp routines. If another
74 * dsp parameter needs to be passed, add to the end of the structure
75 * and remove from dsp_config.
76 * If another function type becomes assembly/external and requires dsp
77 * config info, add a pointer paramter of type "struct dsp_data *".
78 * If removing something from other than the end, reserve the spot or
79 * else update every implementation for every target.
80 * Be sure to add the offset of the new member for easy viewing as well. :)
81 * It is the first member of dsp_config and all members can be accessesed
82 * through the main aggregate but this is intended to make a safe haven
83 * for these items whereas the c part can be rearranged at will. dsp_data
84 * could even moved within dsp_config without disurbing the order.
85 */
86struct dsp_data
87{
88 int output_scale; /* 00h */
89 int num_channels; /* 04h */
90 struct resample_data resample_data; /* 08h */
91 int32_t clip_min; /* 18h */
92 int32_t clip_max; /* 1ch */
93 int32_t gain; /* 20h - Note that this is in S8.23 format. */
94 int frac_bits; /* 24h */
95 /* 28h */
96};
97
Michael Sevakis99617d72007-11-18 17:12:19 +000098struct dsp_config;
99
100int dsp_process(struct dsp_config *dsp, char *dest,
101 const char *src[], int count);
102int dsp_input_count(struct dsp_config *dsp, int count);
103int dsp_output_count(struct dsp_config *dsp, int count);
104intptr_t dsp_configure(struct dsp_config *dsp, int setting,
105 intptr_t value);
Jeffrey Goodefaa47bf2009-10-22 00:59:42 +0000106int get_replaygain_mode(bool have_track_gain, bool have_album_gain);
Michael Sevakisd4e904b2007-02-24 17:06:36 +0000107void dsp_set_replaygain(void);
Marcoen Hirschberge13fad32005-11-14 21:56:56 +0000108void dsp_set_crossfeed(bool enable);
Thom Johansen8238b492006-04-11 13:49:05 +0000109void dsp_set_crossfeed_direct_gain(int gain);
Michael Sevakis99617d72007-11-18 17:12:19 +0000110void dsp_set_crossfeed_cross_params(long lf_gain, long hf_gain,
111 long cutoff);
Dan Evertondaebff82006-03-28 21:19:30 +0000112void dsp_set_eq(bool enable);
113void dsp_set_eq_precut(int precut);
114void dsp_set_eq_coefs(int band);
Thom Johansen35477002006-10-27 20:41:33 +0000115void dsp_dither_enable(bool enable);
Steve Bavinfb238072009-06-12 07:20:50 +0000116void dsp_timestretch_enable(bool enable);
Steve Bavind6ad0192009-06-16 07:10:05 +0000117bool dsp_timestretch_available(void);
Alexander Levincc7c6652009-07-11 16:46:19 +0000118void sound_set_pitch(int32_t r);
119int32_t sound_get_pitch(void);
120void dsp_set_timestretch(int32_t percent);
121int32_t dsp_get_timestretch(void);
Steve Bavind6ad0192009-06-16 07:10:05 +0000122int dsp_callback(int msg, intptr_t param);
Jeffrey Goodea6043452011-10-05 04:44:56 +0000123void dsp_set_compressor(void);
Thom Johansenb0960ae2006-03-21 23:20:17 +0000124
Miika Pekkarinend8cb7032005-06-26 19:41:29 +0000125#endif