From d37bf24d9011addbfbd40942a4e9bbf26de7df00 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Thu, 23 May 2013 13:58:51 -0400 Subject: 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 Tested-by: Michael Sevakis --- lib/rbcodec/dsp/dsp_core.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'lib/rbcodec/dsp/dsp_core.c') 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, intptr_t value) { bool multi = setting < DSP_PROC_SETTING; - struct dsp_proc_slot *s = multi ? dsp->proc_slots : - find_proc_slot(dsp, setting - DSP_PROC_SETTING); + struct dsp_proc_slot *s; + + if (multi) + { + /* Message to all enabled stages */ + if (dsp_sample_io_configure(&dsp->io_data, setting, &value)) + return value; /* To I/O only */ + + s = dsp->proc_slots; + } + else + { + /* Message to a particular stage */ + s = find_proc_slot(dsp, setting - DSP_PROC_SETTING); + } while (s != NULL) { @@ -117,7 +130,7 @@ static intptr_t proc_broadcast(struct dsp_config *dsp, unsigned int setting, s = s->next; } - return multi ? 1 : 0; + return 0; } /* Add an item to the enabled list */ @@ -244,6 +257,12 @@ void dsp_proc_enable(struct dsp_config *dsp, enum dsp_proc_ids id, proc_db_entry(s)->configure(&s->proc_entry, dsp, DSP_PROC_CLOSE, 0); } +/* Is the stage specified by the id currently enabled? */ +bool dsp_proc_enabled(struct dsp_config *dsp, enum dsp_proc_ids id) +{ + return (dsp->proc_mask_enabled & BIT_N(id)) != 0; +} + /* Activate or deactivate a stage */ void dsp_proc_activate(struct dsp_config *dsp, enum dsp_proc_ids id, bool activate) @@ -454,7 +473,6 @@ void dsp_process(struct dsp_config *dsp, struct dsp_buffer *src, intptr_t dsp_configure(struct dsp_config *dsp, unsigned int setting, intptr_t value) { - dsp_sample_io_configure(&dsp->io_data, setting, value); return proc_broadcast(dsp, setting, value); } @@ -497,7 +515,8 @@ void INIT_ATTR dsp_init(void) count = slot_count[i]; dsp->slot_free_mask = MASK_N(uint32_t, count, shift); - dsp_sample_io_configure(&dsp->io_data, DSP_INIT, i); + intptr_t value = i; + dsp_sample_io_configure(&dsp->io_data, DSP_INIT, &value); /* Notify each db entry of global init for each DSP */ for (unsigned int j = 0; j < DSP_NUM_PROC_STAGES; j++) -- cgit v1.2.3