From 56f17c4164bf4e8a7b6996b0a5c2670d0917de25 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Sun, 29 Apr 2012 17:31:30 -0400 Subject: Make rbcodec/dsp includes more specific. Change-Id: Idb6af40df26f5b8499a40e8b98602261ef227044 --- apps/beep.c | 2 +- apps/bookmark.c | 1 - apps/codec_thread.c | 2 +- apps/gui/pitchscreen.c | 1 - apps/gui/quickscreen.c | 1 - apps/gui/skin_engine/skin_tokens.c | 1 - apps/gui/skin_engine/skin_touchsupport.c | 2 +- apps/gui/wps.c | 1 - apps/menus/eq_menu.c | 2 +- apps/menus/playback_menu.c | 1 - apps/menus/recording_menu.c | 1 - apps/menus/sound_menu.c | 1 - apps/pcmbuf.c | 2 +- apps/plugin.h | 3 +- apps/screens.c | 4 - apps/settings.c | 2 +- apps/settings.h | 2 +- apps/settings_list.c | 1 - apps/voice_thread.c | 2 +- firmware/pcm_mixer.c | 2 +- firmware/sound.c | 2 - lib/rbcodec/codecs/codecs.h | 3 +- lib/rbcodec/codecs/lib/codeclib.c | 1 - lib/rbcodec/dsp/channel_mode.c | 3 +- lib/rbcodec/dsp/compressor.c | 12 +-- lib/rbcodec/dsp/crossfeed.c | 9 +- lib/rbcodec/dsp/dsp.h | 176 ------------------------------- lib/rbcodec/dsp/dsp_core.c | 2 +- lib/rbcodec/dsp/dsp_core.h | 173 ++++++++++++++++++++++++++++++ lib/rbcodec/dsp/dsp_misc.c | 9 +- lib/rbcodec/dsp/dsp_proc_entry.h | 3 +- lib/rbcodec/dsp/dsp_proc_settings.h | 2 - lib/rbcodec/dsp/dsp_sample_input.c | 2 +- lib/rbcodec/dsp/dsp_sample_output.c | 2 +- lib/rbcodec/dsp/eq.c | 6 +- lib/rbcodec/dsp/lin_resample.c | 4 +- lib/rbcodec/dsp/pga.c | 2 +- lib/rbcodec/dsp/tdspeed.c | 4 +- lib/rbcodec/dsp/tone_controls.c | 8 +- lib/rbcodec/test/warble.c | 2 +- 40 files changed, 220 insertions(+), 239 deletions(-) delete mode 100644 lib/rbcodec/dsp/dsp.h create mode 100644 lib/rbcodec/dsp/dsp_core.h diff --git a/apps/beep.c b/apps/beep.c index 0152900..8ac7ccf 100644 --- a/apps/beep.c +++ b/apps/beep.c @@ -21,7 +21,7 @@ #include "config.h" #include "system.h" #include "settings.h" -#include "dsp.h" +#include "dsp_core.h" /* for NATIVE_FREQUENCY */ #include "pcm.h" #include "pcm_mixer.h" #include "misc.h" diff --git a/apps/bookmark.c b/apps/bookmark.c index e0325b3..a6e454f 100644 --- a/apps/bookmark.c +++ b/apps/bookmark.c @@ -42,7 +42,6 @@ #include "plugin.h" #include "file.h" #include "filefuncs.h" -#include "dsp.h" #define MAX_BOOKMARKS 10 #define MAX_BOOKMARK_SIZE 350 diff --git a/apps/codec_thread.c b/apps/codec_thread.c index 17ca980..dd745d3 100644 --- a/apps/codec_thread.c +++ b/apps/codec_thread.c @@ -28,7 +28,7 @@ #include "pcmbuf.h" #include "playback.h" #include "buffering.h" -#include "dsp.h" +#include "dsp_core.h" #include "metadata.h" #include "settings.h" diff --git a/apps/gui/pitchscreen.c b/apps/gui/pitchscreen.c index 13da415..200033b 100644 --- a/apps/gui/pitchscreen.c +++ b/apps/gui/pitchscreen.c @@ -26,7 +26,6 @@ #include /* for abs() */ #include "config.h" #include "action.h" -#include "dsp.h" #include "sound.h" #include "pcmbuf.h" #include "lang.h" diff --git a/apps/gui/quickscreen.c b/apps/gui/quickscreen.c index 965fe67..6e50d61 100644 --- a/apps/gui/quickscreen.c +++ b/apps/gui/quickscreen.c @@ -30,7 +30,6 @@ #include "settings_list.h" #include "lang.h" #include "playlist.h" -#include "dsp.h" #include "viewport.h" #include "audio.h" #include "quickscreen.h" diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c index 1bb5b8e..0f5deed 100644 --- a/apps/gui/skin_engine/skin_tokens.c +++ b/apps/gui/skin_engine/skin_tokens.c @@ -49,7 +49,6 @@ /* Image stuff */ #include "albumart.h" #endif -#include "dsp.h" #include "playlist.h" #if CONFIG_CODEC == SWCODEC #include "playback.h" diff --git a/apps/gui/skin_engine/skin_touchsupport.c b/apps/gui/skin_engine/skin_touchsupport.c index 59687bd..a52a884 100644 --- a/apps/gui/skin_engine/skin_touchsupport.c +++ b/apps/gui/skin_engine/skin_touchsupport.c @@ -32,7 +32,7 @@ #include "lang.h" #include "splash.h" #include "playlist.h" -#include "dsp.h" +#include "dsp_misc.h" /** Disarms all touchregions. */ void skin_disarm_touchregions(struct wps_data *data) diff --git a/apps/gui/wps.c b/apps/gui/wps.c index 313ac2c..88918e1 100644 --- a/apps/gui/wps.c +++ b/apps/gui/wps.c @@ -61,7 +61,6 @@ #include "viewport.h" #include "pcmbuf.h" #include "option_select.h" -#include "dsp.h" #include "playlist_viewer.h" #include "wps.h" #include "statusbar-skinned.h" diff --git a/apps/menus/eq_menu.c b/apps/menus/eq_menu.c index 60b2687..7ece92e 100644 --- a/apps/menus/eq_menu.c +++ b/apps/menus/eq_menu.c @@ -38,7 +38,7 @@ #include "talk.h" #include "misc.h" #include "sound.h" -#include "dsp.h" +#include "dsp_proc_settings.h" #include "tree.h" #include "screen_access.h" #include "keyboard.h" diff --git a/apps/menus/playback_menu.c b/apps/menus/playback_menu.c index 17b7e57..d1d9995 100644 --- a/apps/menus/playback_menu.c +++ b/apps/menus/playback_menu.c @@ -31,7 +31,6 @@ #include "sound_menu.h" #include "kernel.h" #include "playlist.h" -#include "dsp.h" #include "scrobbler.h" #include "audio.h" #include "cuesheet.h" diff --git a/apps/menus/recording_menu.c b/apps/menus/recording_menu.c index 3eeb8bc..21686ab 100644 --- a/apps/menus/recording_menu.c +++ b/apps/menus/recording_menu.c @@ -53,7 +53,6 @@ #include "splash.h" #if CONFIG_CODEC == SWCODEC #include "metadata.h" -#include "dsp.h" #include "menus/eq_menu.h" #ifdef HAVE_RECORDING #include "enc_config.h" diff --git a/apps/menus/sound_menu.c b/apps/menus/sound_menu.c index 0817304..8090257 100644 --- a/apps/menus/sound_menu.c +++ b/apps/menus/sound_menu.c @@ -34,7 +34,6 @@ #include "menu_common.h" #include "splash.h" #include "kernel.h" -#include "dsp.h" /***********************************/ /* SOUND MENU */ diff --git a/apps/pcmbuf.c b/apps/pcmbuf.c index 9cedae0..9754f13 100644 --- a/apps/pcmbuf.c +++ b/apps/pcmbuf.c @@ -40,7 +40,7 @@ #include "settings.h" #include "audio.h" #include "voice_thread.h" -#include "dsp.h" +#include "dsp_core.h" /* This is the target fill size of chunks on the pcm buffer Can be any number of samples but power of two sizes make for faster and diff --git a/apps/plugin.h b/apps/plugin.h index 3820c7e..588a012 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -75,7 +75,8 @@ void* plugin_get_buffer(size_t *buffer_size); #if (CONFIG_CODEC == SWCODEC) #include "pcm_mixer.h" #include "dsp-util.h" -#include "dsp.h" +#include "dsp_core.h" +#include "dsp_proc_settings.h" #include "codecs.h" #include "playback.h" #include "codec_thread.h" diff --git a/apps/screens.c b/apps/screens.c index 866ec58..d02f29b 100644 --- a/apps/screens.c +++ b/apps/screens.c @@ -55,10 +55,6 @@ #include "language.h" #include "replaygain.h" -#if CONFIG_CODEC == SWCODEC -#include "dsp.h" -#endif - #if defined(ARCHOS_FMRECORDER) || defined(ARCHOS_RECORDERV2) #include "adc.h" #endif diff --git a/apps/settings.c b/apps/settings.c index 49d239a..d481bc5 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -80,7 +80,7 @@ struct user_settings global_settings; struct system_status global_status; #if CONFIG_CODEC == SWCODEC -#include "dsp.h" +#include "dsp_proc_settings.h" #include "playback.h" #ifdef HAVE_RECORDING #include "enc_config.h" diff --git a/apps/settings.h b/apps/settings.h index 4d94ca8..0713468 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -32,7 +32,7 @@ #include "button.h" #if CONFIG_CODEC == SWCODEC #include "audio.h" -#include "dsp.h" +#include "dsp_proc_settings.h" #endif #include "rbpaths.h" diff --git a/apps/settings_list.c b/apps/settings_list.c index 82cccd8..5f4adde 100644 --- a/apps/settings_list.c +++ b/apps/settings_list.c @@ -33,7 +33,6 @@ #include "settings.h" #include "settings_list.h" #include "usb.h" -#include "dsp.h" #include "audio.h" #include "power.h" #include "powermgmt.h" diff --git a/apps/voice_thread.c b/apps/voice_thread.c index cff703a..48c6f48 100644 --- a/apps/voice_thread.c +++ b/apps/voice_thread.c @@ -23,7 +23,7 @@ #include "thread.h" #include "voice_thread.h" #include "talk.h" -#include "dsp.h" +#include "dsp_core.h" #include "audio.h" #include "playback.h" #include "pcmbuf.h" diff --git a/firmware/pcm_mixer.c b/firmware/pcm_mixer.c index 00891f3..c3e7ffa 100644 --- a/firmware/pcm_mixer.c +++ b/firmware/pcm_mixer.c @@ -25,7 +25,7 @@ #include "pcm.h" #include "pcm-internal.h" #include "pcm_mixer.h" -#include "dsp.h" +#include "dsp_core.h" /* For NATIVE_FREQUENCY */ /* Channels use standard-style PCM callback interface but a latency of one frame by double-buffering is introduced in order to facilitate mixing and diff --git a/firmware/sound.c b/firmware/sound.c index 99db789..e442e87 100644 --- a/firmware/sound.c +++ b/firmware/sound.c @@ -783,8 +783,6 @@ int sound_val2phys(int setting, int value) /* This function works by telling the decoder that we have another crystal frequency than we actually have. It will adjust its internal parameters and the result is that the audio is played at another pitch. - - The pitch value precision is based on PITCH_SPEED_PRECISION (in dsp.h) */ static int last_pitch = PITCH_SPEED_100; diff --git a/lib/rbcodec/codecs/codecs.h b/lib/rbcodec/codecs/codecs.h index d4a51a4..91ce869 100644 --- a/lib/rbcodec/codecs/codecs.h +++ b/lib/rbcodec/codecs/codecs.h @@ -42,7 +42,8 @@ #ifdef HAVE_RECORDING #include "pcm_record.h" #endif -#include "dsp.h" +#include "dsp_core.h" +#include "dsp_misc.h" #include "dsp-util.h" #endif diff --git a/lib/rbcodec/codecs/lib/codeclib.c b/lib/rbcodec/codecs/lib/codeclib.c index 4ca6c8c..4859da3 100644 --- a/lib/rbcodec/codecs/lib/codeclib.c +++ b/lib/rbcodec/codecs/lib/codeclib.c @@ -23,7 +23,6 @@ #include #include "codecs.h" -#include "dsp.h" #include "codeclib.h" #include "metadata.h" #include "dsp_proc_entry.h" diff --git a/lib/rbcodec/dsp/channel_mode.c b/lib/rbcodec/dsp/channel_mode.c index 5b67888..5259b46 100644 --- a/lib/rbcodec/dsp/channel_mode.c +++ b/lib/rbcodec/dsp/channel_mode.c @@ -21,12 +21,11 @@ ****************************************************************************/ #include "config.h" #include "system.h" -#include "dsp.h" -#include "settings.h" #include "sound.h" #include "fixedpoint.h" #include "fracmul.h" #include "dsp_proc_entry.h" +#include "channel_mode.h" #if 0 /* SOUND_CHAN_STEREO mode is a noop so has no function - just outline one for diff --git a/lib/rbcodec/dsp/compressor.c b/lib/rbcodec/dsp/compressor.c index 8441cd6..22a60e4 100644 --- a/lib/rbcodec/dsp/compressor.c +++ b/lib/rbcodec/dsp/compressor.c @@ -19,17 +19,17 @@ * ****************************************************************************/ #include "config.h" -#include "system.h" +#include +#include #include "fixedpoint.h" #include "fracmul.h" -#include "dsp.h" #include /* Define LOGF_ENABLE to enable logf output in this file */ /*#define LOGF_ENABLE*/ #include "logf.h" - #include "dsp_proc_entry.h" +#include "compressor.h" static struct compressor_settings curr_set; /* Cached settings */ @@ -228,10 +228,10 @@ static bool compressor_update(const struct compressor_settings *settings) logf("\nGain factors:"); for (int i = 1; i <= 65; i++) { - debugf("%02d: %.6f ", i, (float)comp_curve[i] / UNITY); - if (i % 4 == 0) debugf("\n"); + DEBUGF("%02d: %.6f ", i, (float)comp_curve[i] / UNITY); + if (i % 4 == 0) DEBUGF("\n"); } - debugf("\n"); + DEBUGF("\n"); #endif /* if using auto peak, then makeup gain is max offset - diff --git a/lib/rbcodec/dsp/crossfeed.c b/lib/rbcodec/dsp/crossfeed.c index ecb5564..344adda 100644 --- a/lib/rbcodec/dsp/crossfeed.c +++ b/lib/rbcodec/dsp/crossfeed.c @@ -20,14 +20,15 @@ * ****************************************************************************/ #include "config.h" -#include "system.h" -#include "dsp.h" -#include "dsp_filter.h" +#include +#include #include "fixedpoint.h" #include "fracmul.h" #include "replaygain.h" -#include #include "dsp_proc_entry.h" +#include "dsp_filter.h" +#include "crossfeed.h" +#include /* Implemented here or in target assembly code */ void crossfeed_process(struct dsp_proc_entry *this, struct dsp_buffer **buf_p); diff --git a/lib/rbcodec/dsp/dsp.h b/lib/rbcodec/dsp/dsp.h deleted file mode 100644 index feac4aa..0000000 --- a/lib/rbcodec/dsp/dsp.h +++ /dev/null @@ -1,176 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2005 Miika Pekkarinen - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#ifndef _DSP_H -#define _DSP_H - -struct dsp_config; - -/* Include all this junk here for now */ -#include "dsp_proc_settings.h" - -enum dsp_ids -{ - CODEC_IDX_AUDIO, - CODEC_IDX_VOICE, - DSP_COUNT, -}; - -enum dsp_settings -{ - DSP_INIT, /* For dsp_init */ - DSP_RESET, - DSP_SET_FREQUENCY, - DSP_SWITCH_FREQUENCY = DSP_SET_FREQUENCY, /* deprecated */ - DSP_SET_SAMPLE_DEPTH, - DSP_SET_STEREO_MODE, - DSP_FLUSH, - DSP_PROC_INIT, - DSP_PROC_CLOSE, - DSP_PROC_SETTING, /* stage-specific should be this + id */ -}; - -#define NATIVE_FREQUENCY 44100 /* internal/output sample rate */ - -enum dsp_stereo_modes -{ - STEREO_INTERLEAVED, - STEREO_NONINTERLEAVED, - STEREO_MONO, - STEREO_NUM_MODES, -}; - -/* Format into for the buffer (if .valid == true) */ -struct sample_format -{ - uint8_t changed; /* 00h: 0=no change, 1=changed (is also index) */ - uint8_t num_channels; /* 01h: number of channels of data */ - uint8_t frac_bits; /* 02h: number of fractional bits */ - uint8_t output_scale; /* 03h: output scaling shift */ - int32_t frequency; /* 04h: pitch-adjusted sample rate */ - int32_t codec_frequency; /* 08h: codec-specifed sample rate */ - /* 0ch */ -}; - -/* Compare format data only */ -#define EQU_SAMPLE_FORMAT(f1, f2) \ - (!memcmp(&(f1).num_channels, &(f2).num_channels, \ - sizeof (f1) - sizeof ((f1).changed))) - -static inline void format_change_set(struct sample_format *f) - { f->changed = 1; } -static inline void format_change_ack(struct sample_format *f) - { f->changed = 0; } - -/* Used by ASM routines - keep field order or else fix the functions */ -struct dsp_buffer -{ - int32_t remcount; /* 00h: Samples in buffer (In, Int, Out) */ - union - { - const void *pin[2]; /* 04h: Channel pointers (In) */ - int32_t *p32[2]; /* 04h: Channel pointers (Int) */ - int16_t *p16out; /* 04h: DSP output buffer (Out) */ - }; - union - { - uint32_t proc_mask; /* 0Ch: In-place effects already appled to buffer - in order to avoid double-processing. Set - to zero on new buffer before passing to - DSP. */ - int bufcount; /* 0Ch: Buffer length/dest buffer remaining - Basically, pay no attention unless it's - *your* new buffer and is used internally - or is specifically the final output - buffer. */ - }; - struct sample_format format; /* 10h: Buffer format data */ - /* 1ch */ -}; - -/* Remove samples from input buffer (In). Sample size is specified. - Provided to dsp_process(). */ -static inline void dsp_advance_buffer_input(struct dsp_buffer *buf, - int by_count, - size_t size_each) -{ - buf->remcount -= by_count; - buf->pin[0] += by_count * size_each; - buf->pin[1] += by_count * size_each; -} - -/* Add samples to output buffer and update remaining space (Out). - Provided to dsp_process() */ -static inline void dsp_advance_buffer_output(struct dsp_buffer *buf, - int by_count) -{ - buf->bufcount -= by_count; - buf->remcount += by_count; - buf->p16out += 2 * by_count; /* Interleaved stereo */ -} - -/* Remove samples from internal input buffer (In, Int). - Provided to dsp_process() or by another processing stage. */ -static inline void dsp_advance_buffer32(struct dsp_buffer *buf, - int by_count) -{ - buf->remcount -= by_count; - buf->p32[0] += by_count; - buf->p32[1] += by_count; -} - -/** For use by processing stages **/ - -#define DSP_PRINT_FORMAT(name, id, format) \ - DEBUGF("DSP format- " #name "\n" \ - " id:%d chg:%c ch:%u fb:%u os:%u hz:%u chz:%u\n", \ - (int)id, \ - (format).changed ? 'y' : 'n', \ - (unsigned int)(format).num_channels, \ - (unsigned int)(format).frac_bits, \ - (unsigned int)(format).output_scale, \ - (unsigned int)(format).frequency, \ - (unsigned int)(format).codec_frequency); - -/* Get DSP pointer */ -struct dsp_config * dsp_get_config(enum dsp_ids id); - -/* Get DSP id */ -enum dsp_ids dsp_get_id(const struct dsp_config *dsp); - -#if 0 /* Not needed now but enable if something must know this */ -/* Is the DSP processing a buffer? */ -bool dsp_is_busy(const struct dsp_config *dsp); -#endif /* 0 */ - -/** General DSP processing **/ - -/* Process the given buffer - see implementation in dsp.c for more */ -void dsp_process(struct dsp_config *dsp, struct dsp_buffer *src, - struct dsp_buffer *dst); - -/* Change DSP settings */ -intptr_t dsp_configure(struct dsp_config *dsp, unsigned int setting, - intptr_t value); - -/* One-time startup init that must come before settings reset/apply */ -void dsp_init(void); - -#endif /* _DSP_H */ diff --git a/lib/rbcodec/dsp/dsp_core.c b/lib/rbcodec/dsp/dsp_core.c index 84fe64a..4a7c478 100644 --- a/lib/rbcodec/dsp/dsp_core.c +++ b/lib/rbcodec/dsp/dsp_core.c @@ -21,7 +21,7 @@ ****************************************************************************/ #include "config.h" #include "system.h" -#include "dsp.h" +#include "dsp_core.h" #include "dsp_sample_io.h" #include diff --git a/lib/rbcodec/dsp/dsp_core.h b/lib/rbcodec/dsp/dsp_core.h new file mode 100644 index 0000000..0119da8 --- /dev/null +++ b/lib/rbcodec/dsp/dsp_core.h @@ -0,0 +1,173 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2005 Miika Pekkarinen + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#ifndef _DSP_H +#define _DSP_H + +struct dsp_config; + +enum dsp_ids +{ + CODEC_IDX_AUDIO, + CODEC_IDX_VOICE, + DSP_COUNT, +}; + +enum dsp_settings +{ + DSP_INIT, /* For dsp_init */ + DSP_RESET, + DSP_SET_FREQUENCY, + DSP_SWITCH_FREQUENCY = DSP_SET_FREQUENCY, /* deprecated */ + DSP_SET_SAMPLE_DEPTH, + DSP_SET_STEREO_MODE, + DSP_FLUSH, + DSP_PROC_INIT, + DSP_PROC_CLOSE, + DSP_PROC_SETTING, /* stage-specific should be this + id */ +}; + +#define NATIVE_FREQUENCY 44100 /* internal/output sample rate */ + +enum dsp_stereo_modes +{ + STEREO_INTERLEAVED, + STEREO_NONINTERLEAVED, + STEREO_MONO, + STEREO_NUM_MODES, +}; + +/* Format into for the buffer (if .valid == true) */ +struct sample_format +{ + uint8_t changed; /* 00h: 0=no change, 1=changed (is also index) */ + uint8_t num_channels; /* 01h: number of channels of data */ + uint8_t frac_bits; /* 02h: number of fractional bits */ + uint8_t output_scale; /* 03h: output scaling shift */ + int32_t frequency; /* 04h: pitch-adjusted sample rate */ + int32_t codec_frequency; /* 08h: codec-specifed sample rate */ + /* 0ch */ +}; + +/* Compare format data only */ +#define EQU_SAMPLE_FORMAT(f1, f2) \ + (!memcmp(&(f1).num_channels, &(f2).num_channels, \ + sizeof (f1) - sizeof ((f1).changed))) + +static inline void format_change_set(struct sample_format *f) + { f->changed = 1; } +static inline void format_change_ack(struct sample_format *f) + { f->changed = 0; } + +/* Used by ASM routines - keep field order or else fix the functions */ +struct dsp_buffer +{ + int32_t remcount; /* 00h: Samples in buffer (In, Int, Out) */ + union + { + const void *pin[2]; /* 04h: Channel pointers (In) */ + int32_t *p32[2]; /* 04h: Channel pointers (Int) */ + int16_t *p16out; /* 04h: DSP output buffer (Out) */ + }; + union + { + uint32_t proc_mask; /* 0Ch: In-place effects already appled to buffer + in order to avoid double-processing. Set + to zero on new buffer before passing to + DSP. */ + int bufcount; /* 0Ch: Buffer length/dest buffer remaining + Basically, pay no attention unless it's + *your* new buffer and is used internally + or is specifically the final output + buffer. */ + }; + struct sample_format format; /* 10h: Buffer format data */ + /* 1ch */ +}; + +/* Remove samples from input buffer (In). Sample size is specified. + Provided to dsp_process(). */ +static inline void dsp_advance_buffer_input(struct dsp_buffer *buf, + int by_count, + size_t size_each) +{ + buf->remcount -= by_count; + buf->pin[0] += by_count * size_each; + buf->pin[1] += by_count * size_each; +} + +/* Add samples to output buffer and update remaining space (Out). + Provided to dsp_process() */ +static inline void dsp_advance_buffer_output(struct dsp_buffer *buf, + int by_count) +{ + buf->bufcount -= by_count; + buf->remcount += by_count; + buf->p16out += 2 * by_count; /* Interleaved stereo */ +} + +/* Remove samples from internal input buffer (In, Int). + Provided to dsp_process() or by another processing stage. */ +static inline void dsp_advance_buffer32(struct dsp_buffer *buf, + int by_count) +{ + buf->remcount -= by_count; + buf->p32[0] += by_count; + buf->p32[1] += by_count; +} + +/** For use by processing stages **/ + +#define DSP_PRINT_FORMAT(name, id, format) \ + DEBUGF("DSP format- " #name "\n" \ + " id:%d chg:%c ch:%u fb:%u os:%u hz:%u chz:%u\n", \ + (int)id, \ + (format).changed ? 'y' : 'n', \ + (unsigned int)(format).num_channels, \ + (unsigned int)(format).frac_bits, \ + (unsigned int)(format).output_scale, \ + (unsigned int)(format).frequency, \ + (unsigned int)(format).codec_frequency); + +/* Get DSP pointer */ +struct dsp_config * dsp_get_config(enum dsp_ids id); + +/* Get DSP id */ +enum dsp_ids dsp_get_id(const struct dsp_config *dsp); + +#if 0 /* Not needed now but enable if something must know this */ +/* Is the DSP processing a buffer? */ +bool dsp_is_busy(const struct dsp_config *dsp); +#endif /* 0 */ + +/** General DSP processing **/ + +/* Process the given buffer - see implementation in dsp.c for more */ +void dsp_process(struct dsp_config *dsp, struct dsp_buffer *src, + struct dsp_buffer *dst); + +/* Change DSP settings */ +intptr_t dsp_configure(struct dsp_config *dsp, unsigned int setting, + intptr_t value); + +/* One-time startup init that must come before settings reset/apply */ +void dsp_init(void); + +#endif /* _DSP_H */ diff --git a/lib/rbcodec/dsp/dsp_misc.c b/lib/rbcodec/dsp/dsp_misc.c index 7b45891..a98a7e4 100644 --- a/lib/rbcodec/dsp/dsp_misc.c +++ b/lib/rbcodec/dsp/dsp_misc.c @@ -22,15 +22,14 @@ * ****************************************************************************/ #include "config.h" -#include "system.h" -#include "dsp.h" -#include "dsp_sample_io.h" -#include "replaygain.h" #include "sound.h" #include "settings.h" #include "fixedpoint.h" -#include +#include "replaygain.h" #include "dsp_proc_entry.h" +#include "dsp_sample_io.h" +#include "dsp_misc.h" +#include /** Firmware callback interface **/ diff --git a/lib/rbcodec/dsp/dsp_proc_entry.h b/lib/rbcodec/dsp/dsp_proc_entry.h index 8bdfe5e..c534437 100644 --- a/lib/rbcodec/dsp/dsp_proc_entry.h +++ b/lib/rbcodec/dsp/dsp_proc_entry.h @@ -90,7 +90,8 @@ struct dsp_proc_db_entry; #include "dsp_proc_database.h" struct dsp_proc_entry; -enum dsp_proc_ids; + +#include "dsp_core.h" /* DSP sample transform function prototype */ typedef void (*dsp_proc_fn_type)(struct dsp_proc_entry *this, diff --git a/lib/rbcodec/dsp/dsp_proc_settings.h b/lib/rbcodec/dsp/dsp_proc_settings.h index bade579..10bc671 100644 --- a/lib/rbcodec/dsp/dsp_proc_settings.h +++ b/lib/rbcodec/dsp/dsp_proc_settings.h @@ -21,8 +21,6 @@ #ifndef DSP_PROC_SETTINGS_H #define DSP_PROC_SETTINGS_H -struct dsp_config; - /* Collect all headers together */ #include "channel_mode.h" #include "compressor.h" diff --git a/lib/rbcodec/dsp/dsp_sample_input.c b/lib/rbcodec/dsp/dsp_sample_input.c index 84127e1..97b4ec2 100644 --- a/lib/rbcodec/dsp/dsp_sample_input.c +++ b/lib/rbcodec/dsp/dsp_sample_input.c @@ -21,7 +21,7 @@ ****************************************************************************/ #include "config.h" #include "system.h" -#include "dsp.h" +#include "dsp_core.h" #include "dsp_sample_io.h" #if 1 diff --git a/lib/rbcodec/dsp/dsp_sample_output.c b/lib/rbcodec/dsp/dsp_sample_output.c index 47fde04..4a8050b 100644 --- a/lib/rbcodec/dsp/dsp_sample_output.c +++ b/lib/rbcodec/dsp/dsp_sample_output.c @@ -21,7 +21,7 @@ ****************************************************************************/ #include "config.h" #include "system.h" -#include "dsp.h" +#include "dsp_core.h" #include "dsp_sample_io.h" #include "dsp-util.h" #include diff --git a/lib/rbcodec/dsp/eq.c b/lib/rbcodec/dsp/eq.c index 4e7df9b..a9e200f 100644 --- a/lib/rbcodec/dsp/eq.c +++ b/lib/rbcodec/dsp/eq.c @@ -23,11 +23,13 @@ #include "system.h" #include "fixedpoint.h" #include "fracmul.h" -#include "dsp.h" #include "dsp_filter.h" +#include "dsp_proc_entry.h" +#include "dsp_core.h" +#include "eq.h" +#include "pga.h" #include "replaygain.h" #include -#include "dsp_proc_entry.h" /** * Current setup is one lowshelf filters three peaking filters and one diff --git a/lib/rbcodec/dsp/lin_resample.c b/lib/rbcodec/dsp/lin_resample.c index c8be3cb..b3855ec 100644 --- a/lib/rbcodec/dsp/lin_resample.c +++ b/lib/rbcodec/dsp/lin_resample.c @@ -21,12 +21,10 @@ ****************************************************************************/ #include "config.h" #include "system.h" -#include "dsp.h" #include "fracmul.h" #include "fixedpoint.h" -#include "dsp_sample_io.h" -#include #include "dsp_proc_entry.h" +#include /** * Linear interpolation resampling that introduces a one sample delay because diff --git a/lib/rbcodec/dsp/pga.c b/lib/rbcodec/dsp/pga.c index c2c29cc..de852d0 100644 --- a/lib/rbcodec/dsp/pga.c +++ b/lib/rbcodec/dsp/pga.c @@ -21,11 +21,11 @@ ****************************************************************************/ #include "config.h" #include "system.h" -#include "dsp.h" #include "dsp-util.h" #include "fixedpoint.h" #include "fracmul.h" #include "dsp_proc_entry.h" +#include "pga.h" /* Implemented here or in target assembly code */ void pga_process(struct dsp_proc_entry *this, struct dsp_buffer **buf_p); diff --git a/lib/rbcodec/dsp/tdspeed.c b/lib/rbcodec/dsp/tdspeed.c index 3aa8acc..82b6b0e 100644 --- a/lib/rbcodec/dsp/tdspeed.c +++ b/lib/rbcodec/dsp/tdspeed.c @@ -24,11 +24,9 @@ #include "system.h" #include "sound.h" #include "core_alloc.h" -#include "system.h" -#include "tdspeed.h" -#include "settings.h" #include "dsp-util.h" #include "dsp_proc_entry.h" +#include "tdspeed.h" #define assert(cond) diff --git a/lib/rbcodec/dsp/tone_controls.c b/lib/rbcodec/dsp/tone_controls.c index 0bd4a44..922c966 100644 --- a/lib/rbcodec/dsp/tone_controls.c +++ b/lib/rbcodec/dsp/tone_controls.c @@ -20,11 +20,13 @@ * ****************************************************************************/ #include "config.h" -#include "system.h" -#include "dsp.h" -#include +#include +#include +#include #include "dsp_proc_entry.h" #include "dsp_filter.h" +#include "tone_controls.h" +#include /* These apply to all DSP streams to remain as consistant as possible with * the behavior of hardware tone controls */ diff --git a/lib/rbcodec/test/warble.c b/lib/rbcodec/test/warble.c index 8b55502..5e2e980 100644 --- a/lib/rbcodec/test/warble.c +++ b/lib/rbcodec/test/warble.c @@ -35,7 +35,7 @@ #include "codecs.h" #include "core_alloc.h" /* core_allocator_init */ #include "debug.h" -#include "dsp.h" +#include "dsp_core.h" #include "metadata.h" #include "settings.h" #include "sound.h" -- cgit v1.1