summaryrefslogtreecommitdiff
path: root/lib/rbcodec/dsp/dsp_core.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2013-05-23 13:58:51 -0400
committerMichael Sevakis <jethead71@rockbox.org>2013-07-06 04:22:04 +0200
commitd37bf24d9011addbfbd40942a4e9bbf26de7df00 (patch)
treedafb7eaeb494081668a4841d490fce2bfbb2438d /lib/rbcodec/dsp/dsp_core.c
parent00faabef5e902008172e08d3bcd77683cbafef51 (diff)
downloadrockbox-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 'lib/rbcodec/dsp/dsp_core.c')
-rw-r--r--lib/rbcodec/dsp/dsp_core.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/lib/rbcodec/dsp/dsp_core.c b/lib/rbcodec/dsp/dsp_core.c
index 871ccbfd23..b0e9c8a304 100644
--- a/lib/rbcodec/dsp/dsp_core.c
+++ b/lib/rbcodec/dsp/dsp_core.c
@@ -103,8 +103,21 @@ static intptr_t proc_broadcast(struct dsp_config *dsp, unsigned int setting,
103 intptr_t value) 103 intptr_t value)
104{ 104{
105 bool multi = setting < DSP_PROC_SETTING; 105 bool multi = setting < DSP_PROC_SETTING;
106 struct dsp_proc_slot *s = multi ? dsp->proc_slots : 106 struct dsp_proc_slot *s;
107 find_proc_slot(dsp, setting - DSP_PROC_SETTING); 107
108 if (multi)
109 {
110 /* Message to all enabled stages */
111 if (dsp_sample_io_configure(&dsp->io_data, setting, &value))
112 return value; /* To I/O only */
113
114 s = dsp->proc_slots;
115 }
116 else
117 {
118 /* Message to a particular stage */
119 s = find_proc_slot(dsp, setting - DSP_PROC_SETTING);
120 }
108 121
109 while (s != NULL) 122 while (s != NULL)
110 { 123 {
@@ -117,7 +130,7 @@ static intptr_t proc_broadcast(struct dsp_config *dsp, unsigned int setting,
117 s = s->next; 130 s = s->next;
118 } 131 }
119 132
120 return multi ? 1 : 0; 133 return 0;
121} 134}
122 135
123/* Add an item to the enabled list */ 136/* Add an item to the enabled list */
@@ -244,6 +257,12 @@ void dsp_proc_enable(struct dsp_config *dsp, enum dsp_proc_ids id,
244 proc_db_entry(s)->configure(&s->proc_entry, dsp, DSP_PROC_CLOSE, 0); 257 proc_db_entry(s)->configure(&s->proc_entry, dsp, DSP_PROC_CLOSE, 0);
245} 258}
246 259
260/* Is the stage specified by the id currently enabled? */
261bool dsp_proc_enabled(struct dsp_config *dsp, enum dsp_proc_ids id)
262{
263 return (dsp->proc_mask_enabled & BIT_N(id)) != 0;
264}
265
247/* Activate or deactivate a stage */ 266/* Activate or deactivate a stage */
248void dsp_proc_activate(struct dsp_config *dsp, enum dsp_proc_ids id, 267void dsp_proc_activate(struct dsp_config *dsp, enum dsp_proc_ids id,
249 bool activate) 268 bool activate)
@@ -454,7 +473,6 @@ void dsp_process(struct dsp_config *dsp, struct dsp_buffer *src,
454intptr_t dsp_configure(struct dsp_config *dsp, unsigned int setting, 473intptr_t dsp_configure(struct dsp_config *dsp, unsigned int setting,
455 intptr_t value) 474 intptr_t value)
456{ 475{
457 dsp_sample_io_configure(&dsp->io_data, setting, value);
458 return proc_broadcast(dsp, setting, value); 476 return proc_broadcast(dsp, setting, value);
459} 477}
460 478
@@ -497,7 +515,8 @@ void INIT_ATTR dsp_init(void)
497 count = slot_count[i]; 515 count = slot_count[i];
498 dsp->slot_free_mask = MASK_N(uint32_t, count, shift); 516 dsp->slot_free_mask = MASK_N(uint32_t, count, shift);
499 517
500 dsp_sample_io_configure(&dsp->io_data, DSP_INIT, i); 518 intptr_t value = i;
519 dsp_sample_io_configure(&dsp->io_data, DSP_INIT, &value);
501 520
502 /* Notify each db entry of global init for each DSP */ 521 /* Notify each db entry of global init for each DSP */
503 for (unsigned int j = 0; j < DSP_NUM_PROC_STAGES; j++) 522 for (unsigned int j = 0; j < DSP_NUM_PROC_STAGES; j++)