summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/settings.c3
-rw-r--r--firmware/drivers/audio/audiohw-swcodec.c29
-rw-r--r--firmware/export/audiohw.h5
-rw-r--r--lib/rbcodec/dsp/dsp_misc.c46
-rw-r--r--lib/rbcodec/dsp/dsp_misc.h17
-rw-r--r--lib/rbcodec/test/warble.c2
6 files changed, 21 insertions, 81 deletions
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)
722 722
723void sound_settings_apply(void) 723void sound_settings_apply(void)
724{ 724{
725#if CONFIG_CODEC == SWCODEC
726 audiohw_swcodec_set_callback(dsp_callback);
727#endif
728#ifdef AUDIOHW_HAVE_BASS 725#ifdef AUDIOHW_HAVE_BASS
729 sound_set(SOUND_BASS, global_settings.bass); 726 sound_set(SOUND_BASS, global_settings.bass);
730#endif 727#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 @@
21#include "config.h" 21#include "config.h"
22#include "system.h" 22#include "system.h"
23#include "sound.h" 23#include "sound.h"
24#ifdef HAVE_SW_TONE_CONTROLS
25#include "tone_controls.h"
26#endif
27#include "channel_mode.h"
24#include "dsp_misc.h" 28#include "dsp_misc.h"
25 29
26/* Linking audio hardware calls to SWCODEC DSP emulation */ 30/** Functions exported by audiohw.h but implemented in DSP **/
27
28static audiohw_swcodec_cb_type callback = NULL;
29
30void audiohw_swcodec_set_callback(audiohw_swcodec_cb_type func)
31{
32 callback = func;
33}
34
35/** Functions exported by audiohw.h **/
36 31
37void audiohw_set_channel(int value) 32void audiohw_set_channel(int value)
38{ 33{
39 callback(DSP_CALLBACK_SET_CHANNEL_CONFIG, value); 34 channel_mode_set_config(value);
40} 35}
41 36
42void audiohw_set_stereo_width(int value) 37void audiohw_set_stereo_width(int value)
43{ 38{
44 callback(DSP_CALLBACK_SET_STEREO_WIDTH, value); 39 channel_mode_custom_set_width(value);
45} 40}
46 41
47#ifdef HAVE_SW_TONE_CONTROLS 42#ifdef HAVE_SW_TONE_CONTROLS
48void audiohw_set_bass(int value) 43void audiohw_set_bass(int value)
49{ 44{
50 callback(DSP_CALLBACK_SET_BASS, value*10); 45 tone_set_bass(value*10);
51} 46}
52 47
53void audiohw_set_treble(int value) 48void audiohw_set_treble(int value)
54{ 49{
55 callback(DSP_CALLBACK_SET_TREBLE, value*10); 50 tone_set_treble(value*10);
56} 51}
57#endif /* HAVE_SW_TONE_CONTROLS */ 52#endif /* HAVE_SW_TONE_CONTROLS */
58 53
59#ifndef AUDIOHW_HAVE_PRESCALER 54#ifndef AUDIOHW_HAVE_PRESCALER
60void audiohw_set_prescaler(int value) 55void audiohw_set_prescaler(int value)
61{ 56{
62 callback(DSP_CALLBACK_SET_PRESCALE, value); 57 tone_set_prescale(value);
63} 58}
64#endif /* AUDIOHW_HAVE_PRESCALER */ 59#endif /* AUDIOHW_HAVE_PRESCALER */
65 60
66#ifdef HAVE_PITCHCONTROL 61#ifdef HAVE_PITCHCONTROL
67void audiohw_set_pitch(int32_t value) 62void audiohw_set_pitch(int32_t value)
68{ 63{
69 callback(DSP_CALLBACK_SET_PITCH, value); 64 dsp_set_pitch(value);
70} 65}
71 66
72int32_t audiohw_get_pitch(void) 67int32_t audiohw_get_pitch(void)
73{ 68{
74 return callback(DSP_CALLBACK_GET_PITCH, 0); 69 return dsp_get_pitch();
75} 70}
76#endif /* HAVE_PITCHCONTROL */ 71#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);
529void audiohw_enable_speaker(bool on); 529void audiohw_enable_speaker(bool on);
530#endif /* HAVE_SPEAKER */ 530#endif /* HAVE_SPEAKER */
531 531
532#if CONFIG_CODEC == SWCODEC
533typedef int (*audiohw_swcodec_cb_type)(int msg, intptr_t param);
534void audiohw_swcodec_set_callback(audiohw_swcodec_cb_type func);
535#endif /* CONFIG_CODEC == SWCODEC */
536
537/** 532/**
538 * Some setting are the same for every codec and can be defined here. 533 * Some setting are the same for every codec and can be defined here.
539 */ 534 */
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)
116 fp_div(pitch_ratio, PITCH_SPEED_100, 16)); 116 fp_div(pitch_ratio, PITCH_SPEED_100, 16));
117} 117}
118 118
119static void dsp_set_pitch(int32_t percent) 119void dsp_set_pitch(int32_t percent)
120{ 120{
121 if (percent <= 0) 121 if (percent <= 0)
122 percent = PITCH_SPEED_100; 122 percent = PITCH_SPEED_100;
@@ -128,50 +128,12 @@ static void dsp_set_pitch(int32_t percent)
128 128
129 dsp_pitch_update(dsp_get_config(CODEC_IDX_AUDIO)); 129 dsp_pitch_update(dsp_get_config(CODEC_IDX_AUDIO));
130} 130}
131#endif /* HAVE_PITCHCONTROL */
132
133
134/** Firmware callback interface **/
135 131
136/* Hook back from firmware/ part of audio, which can't/shouldn't call apps/ 132int32_t dsp_get_pitch(void)
137 * code directly. */
138int dsp_callback(int msg, intptr_t param)
139{ 133{
140 int retval = 0; 134 return pitch_ratio;
141
142 switch (msg)
143 {
144#ifdef HAVE_SW_TONE_CONTROLS
145 case DSP_CALLBACK_SET_PRESCALE:
146 tone_set_prescale(param);
147 break;
148 case DSP_CALLBACK_SET_BASS:
149 tone_set_bass(param);
150 break;
151 case DSP_CALLBACK_SET_TREBLE:
152 tone_set_treble(param);
153 break;
154#endif /* HAVE_SW_TONE_CONTROLS */
155 case DSP_CALLBACK_SET_CHANNEL_CONFIG:
156 channel_mode_set_config(param);
157 break;
158 case DSP_CALLBACK_SET_STEREO_WIDTH:
159 channel_mode_custom_set_width(param);
160 break;
161#ifdef HAVE_PITCHCONTROL
162 case DSP_CALLBACK_SET_PITCH:
163 dsp_set_pitch(param);
164 break;
165 case DSP_CALLBACK_GET_PITCH:
166 retval = pitch_ratio;
167 break;
168#endif /* HAVE_PITCHCONTROL */
169 default:
170 break;
171 }
172
173 return retval;
174} 135}
136#endif /* HAVE_PITCHCONTROL */
175 137
176static void INIT_ATTR misc_dsp_init(struct dsp_config *dsp, 138static void INIT_ATTR misc_dsp_init(struct dsp_config *dsp,
177 enum dsp_ids dsp_id) 139 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
54 54
55void dsp_replaygain_set_settings(const struct replaygain_settings *settings); 55void dsp_replaygain_set_settings(const struct replaygain_settings *settings);
56 56
57/* Callback for firmware layers to interface */ 57#ifdef HAVE_PITCHCONTROL
58enum 58void dsp_set_pitch(int32_t pitch);
59{ 59int32_t dsp_get_pitch(void);
60 DSP_CALLBACK_SET_PRESCALE = 0, 60#endif /* HAVE_PITCHCONTROL */
61 DSP_CALLBACK_SET_BASS,
62 DSP_CALLBACK_SET_TREBLE,
63 DSP_CALLBACK_SET_CHANNEL_CONFIG,
64 DSP_CALLBACK_SET_STEREO_WIDTH,
65 DSP_CALLBACK_SET_PITCH,
66 DSP_CALLBACK_GET_PITCH,
67};
68
69int dsp_callback(int msg, intptr_t param);
70 61
71#endif /* DSP_MISC_H */ 62#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)
387 } else if (!strncmp(name, "offset=", 7)) { 387 } else if (!strncmp(name, "offset=", 7)) {
388 ci.id3->offset = atoi(val); 388 ci.id3->offset = atoi(val);
389 } else if (!strncmp(name, "rate=", 5)) { 389 } else if (!strncmp(name, "rate=", 5)) {
390 dsp_callback(DSP_CALLBACK_SET_PITCH, atof(val) * PITCH_SPEED_100); 390 dsp_set_pitch(atof(val) * PITCH_SPEED_100);
391 } else if (!strncmp(name, "seek=", 5)) { 391 } else if (!strncmp(name, "seek=", 5)) {
392 codec_action = CODEC_ACTION_SEEK_TIME; 392 codec_action = CODEC_ACTION_SEEK_TIME;
393 codec_action_param = atoi(val); 393 codec_action_param = atoi(val);