diff options
Diffstat (limited to 'lib/rbcodec/dsp')
-rw-r--r-- | lib/rbcodec/dsp/dsp_misc.c | 83 | ||||
-rw-r--r-- | lib/rbcodec/dsp/dsp_misc.h | 16 |
2 files changed, 56 insertions, 43 deletions
diff --git a/lib/rbcodec/dsp/dsp_misc.c b/lib/rbcodec/dsp/dsp_misc.c index a8c9423cfb..672212b267 100644 --- a/lib/rbcodec/dsp/dsp_misc.c +++ b/lib/rbcodec/dsp/dsp_misc.c | |||
@@ -35,38 +35,6 @@ | |||
35 | #endif | 35 | #endif |
36 | #include <string.h> | 36 | #include <string.h> |
37 | 37 | ||
38 | /** Firmware callback interface **/ | ||
39 | |||
40 | /* Hook back from firmware/ part of audio, which can't/shouldn't call apps/ | ||
41 | * code directly. */ | ||
42 | int dsp_callback(int msg, intptr_t param) | ||
43 | { | ||
44 | switch (msg) | ||
45 | { | ||
46 | #ifdef HAVE_SW_TONE_CONTROLS | ||
47 | case DSP_CALLBACK_SET_PRESCALE: | ||
48 | tone_set_prescale(param); | ||
49 | break; | ||
50 | case DSP_CALLBACK_SET_BASS: | ||
51 | tone_set_bass(param); | ||
52 | break; | ||
53 | case DSP_CALLBACK_SET_TREBLE: | ||
54 | tone_set_treble(param); | ||
55 | break; | ||
56 | #endif /* HAVE_SW_TONE_CONTROLS */ | ||
57 | case DSP_CALLBACK_SET_CHANNEL_CONFIG: | ||
58 | channel_mode_set_config(param); | ||
59 | break; | ||
60 | case DSP_CALLBACK_SET_STEREO_WIDTH: | ||
61 | channel_mode_custom_set_width(param); | ||
62 | break; | ||
63 | default: | ||
64 | break; | ||
65 | } | ||
66 | |||
67 | return 0; | ||
68 | } | ||
69 | |||
70 | /** Replaygain settings **/ | 38 | /** Replaygain settings **/ |
71 | static struct replaygain_settings current_settings; | 39 | static struct replaygain_settings current_settings; |
72 | static struct dsp_replay_gains current_gains; | 40 | static struct dsp_replay_gains current_gains; |
@@ -153,12 +121,7 @@ static void dsp_pitch_update(struct dsp_config *dsp) | |||
153 | (int64_t)pitch_ratio * data->format.codec_frequency / PITCH_SPEED_100; | 121 | (int64_t)pitch_ratio * data->format.codec_frequency / PITCH_SPEED_100; |
154 | } | 122 | } |
155 | 123 | ||
156 | int32_t sound_get_pitch(void) | 124 | static void dsp_set_pitch(int32_t percent) |
157 | { | ||
158 | return pitch_ratio; | ||
159 | } | ||
160 | |||
161 | void sound_set_pitch(int32_t percent) | ||
162 | { | 125 | { |
163 | pitch_ratio = percent > 0 ? percent : PITCH_SPEED_100; | 126 | pitch_ratio = percent > 0 ? percent : PITCH_SPEED_100; |
164 | struct dsp_config *dsp = dsp_get_config(CODEC_IDX_AUDIO); | 127 | struct dsp_config *dsp = dsp_get_config(CODEC_IDX_AUDIO); |
@@ -167,6 +130,50 @@ void sound_set_pitch(int32_t percent) | |||
167 | } | 130 | } |
168 | #endif /* HAVE_PITCHCONTROL */ | 131 | #endif /* HAVE_PITCHCONTROL */ |
169 | 132 | ||
133 | |||
134 | /** Firmware callback interface **/ | ||
135 | |||
136 | /* Hook back from firmware/ part of audio, which can't/shouldn't call apps/ | ||
137 | * code directly. */ | ||
138 | int dsp_callback(int msg, intptr_t param) | ||
139 | { | ||
140 | int retval = 0; | ||
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 | } | ||
175 | |||
176 | |||
170 | /* This is a null-processing stage that monitors as an enabled stage but never | 177 | /* This is a null-processing stage that monitors as an enabled stage but never |
171 | * becomes active in processing samples. It only hooks messages. */ | 178 | * becomes active in processing samples. It only hooks messages. */ |
172 | 179 | ||
diff --git a/lib/rbcodec/dsp/dsp_misc.h b/lib/rbcodec/dsp/dsp_misc.h index d658374eaf..2583f495c3 100644 --- a/lib/rbcodec/dsp/dsp_misc.h +++ b/lib/rbcodec/dsp/dsp_misc.h | |||
@@ -54,12 +54,18 @@ struct dsp_replay_gains | |||
54 | 54 | ||
55 | void dsp_replaygain_set_settings(const struct replaygain_settings *settings); | 55 | void dsp_replaygain_set_settings(const struct replaygain_settings *settings); |
56 | 56 | ||
57 | #ifdef HAVE_PITCHCONTROL | ||
58 | void sound_set_pitch(int32_t ratio); | ||
59 | int32_t sound_get_pitch(void); | ||
60 | #endif /* HAVE_PITCHCONTROL */ | ||
61 | |||
62 | /* Callback for firmware layers to interface */ | 57 | /* Callback for firmware layers to interface */ |
58 | enum | ||
59 | { | ||
60 | DSP_CALLBACK_SET_PRESCALE = 0, | ||
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 | |||
63 | int dsp_callback(int msg, intptr_t param); | 69 | int dsp_callback(int msg, intptr_t param); |
64 | 70 | ||
65 | #endif /* DSP_MISC_H */ | 71 | #endif /* DSP_MISC_H */ |