Miika Pekkarinen | d8cb703 | 2005-06-26 19:41:29 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
| 10 | * Copyright (C) 2005 Miika Pekkarinen |
| 11 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame] | 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. |
Miika Pekkarinen | d8cb703 | 2005-06-26 19:41:29 +0000 | [diff] [blame] | 16 | * |
| 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 Pekkarinen | d8cb703 | 2005-06-26 19:41:29 +0000 | [diff] [blame] | 26 | #include <stdbool.h> |
| 27 | |
| 28 | #define NATIVE_FREQUENCY 44100 |
Jeffrey Goode | cf19ba5 | 2009-09-25 15:46:38 +0000 | [diff] [blame] | 29 | |
Michael Sevakis | 36175ac | 2007-02-19 02:49:26 +0000 | [diff] [blame] | 30 | enum |
| 31 | { |
| 32 | STEREO_INTERLEAVED = 0, |
| 33 | STEREO_NONINTERLEAVED, |
| 34 | STEREO_MONO, |
| 35 | STEREO_NUM_MODES, |
| 36 | }; |
Miika Pekkarinen | d8cb703 | 2005-06-26 19:41:29 +0000 | [diff] [blame] | 37 | |
Michael Sevakis | d4e904b | 2007-02-24 17:06:36 +0000 | [diff] [blame] | 38 | enum |
| 39 | { |
Michael Sevakis | 99617d7 | 2007-11-18 17:12:19 +0000 | [diff] [blame] | 40 | CODEC_IDX_AUDIO = 0, |
| 41 | CODEC_IDX_VOICE, |
| 42 | }; |
| 43 | |
| 44 | enum |
| 45 | { |
Björn Stenberg | 6427d12 | 2009-01-10 21:10:56 +0000 | [diff] [blame] | 46 | DSP_MYDSP = 1, |
Thom Johansen | f60e620 | 2005-09-21 13:09:10 +0000 | [diff] [blame] | 47 | DSP_SET_FREQUENCY, |
| 48 | DSP_SWITCH_FREQUENCY, |
Thom Johansen | f60e620 | 2005-09-21 13:09:10 +0000 | [diff] [blame] | 49 | DSP_SET_SAMPLE_DEPTH, |
| 50 | DSP_SET_STEREO_MODE, |
| 51 | DSP_RESET, |
Michael Sevakis | bbef13e | 2006-11-26 12:02:47 +0000 | [diff] [blame] | 52 | DSP_FLUSH, |
Thom Johansen | f60e620 | 2005-09-21 13:09:10 +0000 | [diff] [blame] | 53 | DSP_SET_TRACK_GAIN, |
| 54 | DSP_SET_ALBUM_GAIN, |
| 55 | DSP_SET_TRACK_PEAK, |
Marcoen Hirschberg | e13fad3 | 2005-11-14 21:56:56 +0000 | [diff] [blame] | 56 | DSP_SET_ALBUM_PEAK, |
| 57 | DSP_CROSSFEED |
Thom Johansen | f60e620 | 2005-09-21 13:09:10 +0000 | [diff] [blame] | 58 | }; |
| 59 | |
Michael Sevakis | 1ab9d14 | 2012-02-08 14:55:37 -0500 | [diff] [blame] | 60 | |
| 61 | /**************************************************************************** |
| 62 | * NOTE: Any assembly routines that use these structures must be updated |
| 63 | * if current data members are moved or changed. |
| 64 | */ |
| 65 | struct 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 | */ |
| 86 | struct 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 Sevakis | 99617d7 | 2007-11-18 17:12:19 +0000 | [diff] [blame] | 98 | struct dsp_config; |
| 99 | |
| 100 | int dsp_process(struct dsp_config *dsp, char *dest, |
| 101 | const char *src[], int count); |
| 102 | int dsp_input_count(struct dsp_config *dsp, int count); |
| 103 | int dsp_output_count(struct dsp_config *dsp, int count); |
| 104 | intptr_t dsp_configure(struct dsp_config *dsp, int setting, |
| 105 | intptr_t value); |
Jeffrey Goode | faa47bf | 2009-10-22 00:59:42 +0000 | [diff] [blame] | 106 | int get_replaygain_mode(bool have_track_gain, bool have_album_gain); |
Michael Sevakis | d4e904b | 2007-02-24 17:06:36 +0000 | [diff] [blame] | 107 | void dsp_set_replaygain(void); |
Marcoen Hirschberg | e13fad3 | 2005-11-14 21:56:56 +0000 | [diff] [blame] | 108 | void dsp_set_crossfeed(bool enable); |
Thom Johansen | 8238b49 | 2006-04-11 13:49:05 +0000 | [diff] [blame] | 109 | void dsp_set_crossfeed_direct_gain(int gain); |
Michael Sevakis | 99617d7 | 2007-11-18 17:12:19 +0000 | [diff] [blame] | 110 | void dsp_set_crossfeed_cross_params(long lf_gain, long hf_gain, |
| 111 | long cutoff); |
Dan Everton | daebff8 | 2006-03-28 21:19:30 +0000 | [diff] [blame] | 112 | void dsp_set_eq(bool enable); |
| 113 | void dsp_set_eq_precut(int precut); |
| 114 | void dsp_set_eq_coefs(int band); |
Thom Johansen | 3547700 | 2006-10-27 20:41:33 +0000 | [diff] [blame] | 115 | void dsp_dither_enable(bool enable); |
Steve Bavin | fb23807 | 2009-06-12 07:20:50 +0000 | [diff] [blame] | 116 | void dsp_timestretch_enable(bool enable); |
Steve Bavin | d6ad019 | 2009-06-16 07:10:05 +0000 | [diff] [blame] | 117 | bool dsp_timestretch_available(void); |
Alexander Levin | cc7c665 | 2009-07-11 16:46:19 +0000 | [diff] [blame] | 118 | void sound_set_pitch(int32_t r); |
| 119 | int32_t sound_get_pitch(void); |
| 120 | void dsp_set_timestretch(int32_t percent); |
| 121 | int32_t dsp_get_timestretch(void); |
Steve Bavin | d6ad019 | 2009-06-16 07:10:05 +0000 | [diff] [blame] | 122 | int dsp_callback(int msg, intptr_t param); |
Jeffrey Goode | a604345 | 2011-10-05 04:44:56 +0000 | [diff] [blame] | 123 | void dsp_set_compressor(void); |
Thom Johansen | b0960ae | 2006-03-21 23:20:17 +0000 | [diff] [blame] | 124 | |
Miika Pekkarinen | d8cb703 | 2005-06-26 19:41:29 +0000 | [diff] [blame] | 125 | #endif |