diff --git a/apps/settings.c b/apps/settings.c index 0984143dbb..b04b91cc66 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -722,9 +722,6 @@ void settings_apply_pm_range(void) void sound_settings_apply(void) { -#if CONFIG_CODEC == SWCODEC - audiohw_swcodec_set_callback(dsp_callback); -#endif #ifdef AUDIOHW_HAVE_BASS sound_set(SOUND_BASS, global_settings.bass); #endif diff --git a/firmware/drivers/audio/audiohw-swcodec.c b/firmware/drivers/audio/audiohw-swcodec.c index 9cfc2ce413..6c86bdfaa4 100644 --- a/firmware/drivers/audio/audiohw-swcodec.c +++ b/firmware/drivers/audio/audiohw-swcodec.c @@ -21,56 +21,51 @@ #include "config.h" #include "system.h" #include "sound.h" +#ifdef HAVE_SW_TONE_CONTROLS +#include "tone_controls.h" +#endif +#include "channel_mode.h" #include "dsp_misc.h" -/* Linking audio hardware calls to SWCODEC DSP emulation */ - -static audiohw_swcodec_cb_type callback = NULL; - -void audiohw_swcodec_set_callback(audiohw_swcodec_cb_type func) -{ - callback = func; -} - -/** Functions exported by audiohw.h **/ +/** Functions exported by audiohw.h but implemented in DSP **/ void audiohw_set_channel(int value) { - callback(DSP_CALLBACK_SET_CHANNEL_CONFIG, value); + channel_mode_set_config(value); } void audiohw_set_stereo_width(int value) { - callback(DSP_CALLBACK_SET_STEREO_WIDTH, value); + channel_mode_custom_set_width(value); } #ifdef HAVE_SW_TONE_CONTROLS void audiohw_set_bass(int value) { - callback(DSP_CALLBACK_SET_BASS, value*10); + tone_set_bass(value*10); } void audiohw_set_treble(int value) { - callback(DSP_CALLBACK_SET_TREBLE, value*10); + tone_set_treble(value*10); } #endif /* HAVE_SW_TONE_CONTROLS */ #ifndef AUDIOHW_HAVE_PRESCALER void audiohw_set_prescaler(int value) { - callback(DSP_CALLBACK_SET_PRESCALE, value); + tone_set_prescale(value); } #endif /* AUDIOHW_HAVE_PRESCALER */ #ifdef HAVE_PITCHCONTROL void audiohw_set_pitch(int32_t value) { - callback(DSP_CALLBACK_SET_PITCH, value); + dsp_set_pitch(value); } int32_t audiohw_get_pitch(void) { - return callback(DSP_CALLBACK_GET_PITCH, 0); + return dsp_get_pitch(); } #endif /* HAVE_PITCHCONTROL */ diff --git a/firmware/export/audiohw.h b/firmware/export/audiohw.h index 28fa1b08d6..d1579b5b93 100644 --- a/firmware/export/audiohw.h +++ b/firmware/export/audiohw.h @@ -529,11 +529,6 @@ void audiohw_set_stereo_width(int val); void audiohw_enable_speaker(bool on); #endif /* HAVE_SPEAKER */ -#if CONFIG_CODEC == SWCODEC -typedef int (*audiohw_swcodec_cb_type)(int msg, intptr_t param); -void audiohw_swcodec_set_callback(audiohw_swcodec_cb_type func); -#endif /* CONFIG_CODEC == SWCODEC */ - /** * Some setting are the same for every codec and can be defined here. */ diff --git a/lib/rbcodec/dsp/dsp_misc.c b/lib/rbcodec/dsp/dsp_misc.c index a19ef52883..40d198ff50 100644 --- a/lib/rbcodec/dsp/dsp_misc.c +++ b/lib/rbcodec/dsp/dsp_misc.c @@ -116,7 +116,7 @@ static void dsp_pitch_update(struct dsp_config *dsp) fp_div(pitch_ratio, PITCH_SPEED_100, 16)); } -static void dsp_set_pitch(int32_t percent) +void dsp_set_pitch(int32_t percent) { if (percent <= 0) percent = PITCH_SPEED_100; @@ -128,50 +128,12 @@ static void dsp_set_pitch(int32_t percent) dsp_pitch_update(dsp_get_config(CODEC_IDX_AUDIO)); } -#endif /* HAVE_PITCHCONTROL */ - -/** Firmware callback interface **/ - -/* Hook back from firmware/ part of audio, which can't/shouldn't call apps/ - * code directly. */ -int dsp_callback(int msg, intptr_t param) +int32_t dsp_get_pitch(void) { - int retval = 0; - - switch (msg) - { -#ifdef HAVE_SW_TONE_CONTROLS - case DSP_CALLBACK_SET_PRESCALE: - tone_set_prescale(param); - break; - case DSP_CALLBACK_SET_BASS: - tone_set_bass(param); - break; - case DSP_CALLBACK_SET_TREBLE: - tone_set_treble(param); - break; -#endif /* HAVE_SW_TONE_CONTROLS */ - case DSP_CALLBACK_SET_CHANNEL_CONFIG: - channel_mode_set_config(param); - break; - case DSP_CALLBACK_SET_STEREO_WIDTH: - channel_mode_custom_set_width(param); - break; -#ifdef HAVE_PITCHCONTROL - case DSP_CALLBACK_SET_PITCH: - dsp_set_pitch(param); - break; - case DSP_CALLBACK_GET_PITCH: - retval = pitch_ratio; - break; -#endif /* HAVE_PITCHCONTROL */ - default: - break; - } - - return retval; + return pitch_ratio; } +#endif /* HAVE_PITCHCONTROL */ static void INIT_ATTR misc_dsp_init(struct dsp_config *dsp, enum dsp_ids dsp_id) diff --git a/lib/rbcodec/dsp/dsp_misc.h b/lib/rbcodec/dsp/dsp_misc.h index 2583f495c3..2fed9400f2 100644 --- a/lib/rbcodec/dsp/dsp_misc.h +++ b/lib/rbcodec/dsp/dsp_misc.h @@ -54,18 +54,9 @@ struct dsp_replay_gains void dsp_replaygain_set_settings(const struct replaygain_settings *settings); -/* Callback for firmware layers to interface */ -enum -{ - DSP_CALLBACK_SET_PRESCALE = 0, - DSP_CALLBACK_SET_BASS, - DSP_CALLBACK_SET_TREBLE, - DSP_CALLBACK_SET_CHANNEL_CONFIG, - DSP_CALLBACK_SET_STEREO_WIDTH, - DSP_CALLBACK_SET_PITCH, - DSP_CALLBACK_GET_PITCH, -}; - -int dsp_callback(int msg, intptr_t param); +#ifdef HAVE_PITCHCONTROL +void dsp_set_pitch(int32_t pitch); +int32_t dsp_get_pitch(void); +#endif /* HAVE_PITCHCONTROL */ #endif /* DSP_MISC_H */ diff --git a/lib/rbcodec/test/warble.c b/lib/rbcodec/test/warble.c index 6aabf95d17..735fa2511f 100644 --- a/lib/rbcodec/test/warble.c +++ b/lib/rbcodec/test/warble.c @@ -387,7 +387,7 @@ static void perform_config(void) } else if (!strncmp(name, "offset=", 7)) { ci.id3->offset = atoi(val); } else if (!strncmp(name, "rate=", 5)) { - dsp_callback(DSP_CALLBACK_SET_PITCH, atof(val) * PITCH_SPEED_100); + dsp_set_pitch(atof(val) * PITCH_SPEED_100); } else if (!strncmp(name, "seek=", 5)) { codec_action = CODEC_ACTION_SEEK_TIME; codec_action_param = atoi(val);