diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2013-05-23 13:58:51 -0400 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2013-07-06 04:22:04 +0200 |
commit | d37bf24d9011addbfbd40942a4e9bbf26de7df00 (patch) | |
tree | dafb7eaeb494081668a4841d490fce2bfbb2438d /firmware/export/pcm_sampr.h | |
parent | 00faabef5e902008172e08d3bcd77683cbafef51 (diff) | |
download | rockbox-d37bf24d9011addbfbd40942a4e9bbf26de7df00.tar.gz rockbox-d37bf24d9011addbfbd40942a4e9bbf26de7df00.zip |
Enable setting of global output samplerate on certain targets.
Replaces the NATIVE_FREQUENCY constant with a configurable frequency.
The user may select 48000Hz if the hardware supports it. The default is
still 44100Hz and the minimum is 44100Hz. The setting is located in the
playback settings, under "Frequency".
"Frequency" was duplicated in english.lang for now to avoid having to
fix every .lang file for the moment and throwing everything out of sync
because of the new play_frequency feature in features.txt. The next
cleanup should combine it with the one included for recording and
generalize the ID label.
If the hardware doesn't support 48000Hz, no setting will be available.
On particular hardware where very high rates are practical and desireable,
the upper bound can be extended by patching.
The PCM mixer can be configured to play at the full hardware frequency
range. The DSP core can configure to the hardware minimum up to the
maximum playback setting (some buffers must be reserved according to
the maximum rate).
If only 44100Hz is supported or possible on a given target for playback,
using the DSP and mixer at other samperates is possible if the hardware
offers them.
Change-Id: I6023cf0c0baa8bc6292b6919b4dd3618a6a25622
Reviewed-on: http://gerrit.rockbox.org/479
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested-by: Michael Sevakis <jethead71@rockbox.org>
Diffstat (limited to 'firmware/export/pcm_sampr.h')
-rw-r--r-- | firmware/export/pcm_sampr.h | 56 |
1 files changed, 52 insertions, 4 deletions
diff --git a/firmware/export/pcm_sampr.h b/firmware/export/pcm_sampr.h index 01a8ed428e..dcb1bdd80f 100644 --- a/firmware/export/pcm_sampr.h +++ b/firmware/export/pcm_sampr.h | |||
@@ -20,7 +20,12 @@ | |||
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | #ifndef PCM_SAMPR_H | 22 | #ifndef PCM_SAMPR_H |
23 | |||
24 | /* File might be included for CPP config macros only. Allow it to be included | ||
25 | * again for full C declarations. */ | ||
26 | #ifndef PCM_SAMPR_CONFIG_ONLY | ||
23 | #define PCM_SAMPR_H | 27 | #define PCM_SAMPR_H |
28 | #endif | ||
24 | 29 | ||
25 | #ifndef HW_SAMPR_CAPS | 30 | #ifndef HW_SAMPR_CAPS |
26 | #define HW_SAMPR_CAPS SAMPR_CAP_44 /* if not defined, default to 44100 */ | 31 | #define HW_SAMPR_CAPS SAMPR_CAP_44 /* if not defined, default to 44100 */ |
@@ -75,11 +80,14 @@ | |||
75 | SAMPR_CAP_24 | SAMPR_CAP_22 | SAMPR_CAP_16 | \ | 80 | SAMPR_CAP_24 | SAMPR_CAP_22 | SAMPR_CAP_16 | \ |
76 | SAMPR_CAP_12 | SAMPR_CAP_11 | SAMPR_CAP_8) | 81 | SAMPR_CAP_12 | SAMPR_CAP_11 | SAMPR_CAP_8) |
77 | 82 | ||
83 | #ifndef PCM_SAMPR_CONFIG_ONLY | ||
78 | /* Master list of all "standard" rates supported. */ | 84 | /* Master list of all "standard" rates supported. */ |
79 | extern const unsigned long audio_master_sampr_list[SAMPR_NUM_FREQ]; | 85 | extern const unsigned long audio_master_sampr_list[SAMPR_NUM_FREQ]; |
86 | #endif /* PCM_SAMPR_CONFIG_ONLY */ | ||
80 | 87 | ||
81 | /** Hardware sample rates **/ | 88 | /** Hardware sample rates **/ |
82 | 89 | ||
90 | #ifndef PCM_SAMPR_CONFIG_ONLY | ||
83 | /* Enumeration of supported frequencies where 0 is the highest rate | 91 | /* Enumeration of supported frequencies where 0 is the highest rate |
84 | supported and REC_NUM_FREQUENCIES is the number available */ | 92 | supported and REC_NUM_FREQUENCIES is the number available */ |
85 | enum hw_freq_indexes | 93 | enum hw_freq_indexes |
@@ -183,14 +191,49 @@ enum hw_freq_indexes | |||
183 | #define HW_HAVE_8_(...) | 191 | #define HW_HAVE_8_(...) |
184 | #endif | 192 | #endif |
185 | HW_NUM_FREQ, | 193 | HW_NUM_FREQ, |
186 | HW_FREQ_DEFAULT = HW_FREQ_44, | ||
187 | HW_SAMPR_DEFAULT = SAMPR_44, | ||
188 | }; /* enum hw_freq_indexes */ | 194 | }; /* enum hw_freq_indexes */ |
189 | 195 | ||
190 | /* list of hardware sample rates */ | 196 | /* list of hardware sample rates */ |
191 | extern const unsigned long hw_freq_sampr[HW_NUM_FREQ]; | 197 | extern const unsigned long hw_freq_sampr[HW_NUM_FREQ]; |
198 | #endif /* PCM_SAMPR_CONFIG_ONLY */ | ||
199 | |||
200 | #define HW_FREQ_DEFAULT HW_FREQ_44 | ||
201 | #define HW_SAMPR_DEFAULT SAMPR_44 | ||
202 | |||
203 | |||
204 | #if HW_SAMPR_CAPS & SAMPR_CAP_96 | ||
205 | # define HW_SAMPR_MAX SAMPR_96 | ||
206 | #elif HW_SAMPR_CAPS & SAMPR_CAP_88 | ||
207 | # define HW_SAMPR_MAX SAMPR_88 | ||
208 | #elif HW_SAMPR_CAPS & SAMPR_CAP_64 | ||
209 | # define HW_SAMPR_MAX SAMPR_64 | ||
210 | #elif HW_SAMPR_CAPS & SAMPR_CAP_48 | ||
211 | # define HW_SAMPR_MAX SAMPR_48 | ||
212 | #else | ||
213 | # define HW_SAMPR_MAX SAMPR_44 | ||
214 | #endif | ||
215 | |||
216 | #if HW_SAMPR_CAPS & SAMPR_CAP_8 | ||
217 | # define HW_SAMPR_MIN SAMPR_8 | ||
218 | #elif HW_SAMPR_CAPS & SAMPR_CAP_11 | ||
219 | # define HW_SAMPR_MIN SAMPR_11 | ||
220 | #elif HW_SAMPR_CAPS & SAMPR_CAP_12 | ||
221 | # define HW_SAMPR_MIN SAMPR_12 | ||
222 | #elif HW_SAMPR_CAPS & SAMPR_CAP_16 | ||
223 | # define HW_SAMPR_MIN SAMPR_16 | ||
224 | #elif HW_SAMPR_CAPS & SAMPR_CAP_22 | ||
225 | # define HW_SAMPR_MIN SAMPR_22 | ||
226 | #elif HW_SAMPR_CAPS & SAMPR_CAP_24 | ||
227 | # define HW_SAMPR_MIN SAMPR_24 | ||
228 | #elif HW_SAMPR_CAPS & SAMPR_CAP_32 | ||
229 | # define HW_SAMPR_MIN SAMPR_32 | ||
230 | #else | ||
231 | # define HW_SAMPR_MIN SAMPR_44 | ||
232 | #endif | ||
192 | 233 | ||
193 | #ifdef HAVE_RECORDING | 234 | #ifdef HAVE_RECORDING |
235 | |||
236 | #ifndef PCM_SAMPR_CONFIG_ONLY | ||
194 | /* Enumeration of supported frequencies where 0 is the highest rate | 237 | /* Enumeration of supported frequencies where 0 is the highest rate |
195 | supported and REC_NUM_FREQUENCIES is the number available */ | 238 | supported and REC_NUM_FREQUENCIES is the number available */ |
196 | enum rec_freq_indexes | 239 | enum rec_freq_indexes |
@@ -296,6 +339,10 @@ enum rec_freq_indexes | |||
296 | REC_NUM_FREQ, | 339 | REC_NUM_FREQ, |
297 | }; /* enum rec_freq_indexes */ | 340 | }; /* enum rec_freq_indexes */ |
298 | 341 | ||
342 | /* List of recording supported sample rates (set or subset of master list) */ | ||
343 | extern const unsigned long rec_freq_sampr[REC_NUM_FREQ]; | ||
344 | #endif /* PCM_SAMPR_CONFIG_ONLY */ | ||
345 | |||
299 | /* Default to 44.1kHz if not otherwise specified */ | 346 | /* Default to 44.1kHz if not otherwise specified */ |
300 | #ifndef REC_FREQ_DEFAULT | 347 | #ifndef REC_FREQ_DEFAULT |
301 | #define REC_FREQ_DEFAULT REC_FREQ_44 | 348 | #define REC_FREQ_DEFAULT REC_FREQ_44 |
@@ -314,8 +361,7 @@ enum rec_freq_indexes | |||
314 | REC_HAVE_16_(",16") REC_HAVE_12_(",12") \ | 361 | REC_HAVE_16_(",16") REC_HAVE_12_(",12") \ |
315 | REC_HAVE_11_(",11") REC_HAVE_8_(",8")[1] | 362 | REC_HAVE_11_(",11") REC_HAVE_8_(",8")[1] |
316 | 363 | ||
317 | /* List of recording supported sample rates (set or subset of master list) */ | 364 | |
318 | extern const unsigned long rec_freq_sampr[REC_NUM_FREQ]; | ||
319 | #endif /* HAVE_RECORDING */ | 365 | #endif /* HAVE_RECORDING */ |
320 | 366 | ||
321 | #ifdef CONFIG_SAMPR_TYPES | 367 | #ifdef CONFIG_SAMPR_TYPES |
@@ -326,8 +372,10 @@ extern const unsigned long rec_freq_sampr[REC_NUM_FREQ]; | |||
326 | #define SAMPR_TYPE_REC (0x01 << 24) | 372 | #define SAMPR_TYPE_REC (0x01 << 24) |
327 | #endif | 373 | #endif |
328 | 374 | ||
375 | #ifndef PCM_SAMPR_CONFIG_ONLY | ||
329 | unsigned int pcm_sampr_to_hw_sampr(unsigned int samplerate, | 376 | unsigned int pcm_sampr_to_hw_sampr(unsigned int samplerate, |
330 | unsigned int type); | 377 | unsigned int type); |
378 | #endif | ||
331 | 379 | ||
332 | #else /* ndef CONFIG_SAMPR_TYPES */ | 380 | #else /* ndef CONFIG_SAMPR_TYPES */ |
333 | 381 | ||