rbcodec: Hooks for target specific functions in dsp_process loop
Use them to move tick counting, yielding and coldfire macsr handling code to a rockbox specific file. Change-Id: Id7417dc98c08a342eba45ba56b044a276e50564b Reviewed-on: http://gerrit.rockbox.org/229 Tested-by: Nils Wallménius <nils@rockbox.org> Reviewed-by: Nils Wallménius <nils@rockbox.org>
This commit is contained in:
parent
00cf2ce711
commit
dbe5e5f2df
3 changed files with 74 additions and 47 deletions
|
@ -17,6 +17,58 @@
|
|||
* {,U}INT{8,16,32,64}_{MIN,MAX} */
|
||||
#include "system.h"
|
||||
|
||||
/* Structure to record some info during processing call */
|
||||
struct dsp_loop_context
|
||||
{
|
||||
long last_yield;
|
||||
#ifdef CPU_COLDFIRE
|
||||
unsigned long old_macsr;
|
||||
#endif
|
||||
};
|
||||
|
||||
static inline void dsp_process_start(struct dsp_loop_context *ctx)
|
||||
{
|
||||
/* At least perform one yield before starting */
|
||||
ctx->last_yield = current_tick;
|
||||
yield();
|
||||
#if defined(CPU_COLDFIRE)
|
||||
/* set emac unit for dsp processing, and save old macsr, we're running in
|
||||
codec thread context at this point, so can't clobber it */
|
||||
ctx->old_macsr = coldfire_get_macsr();
|
||||
coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void dsp_process_loop(struct dsp_loop_context *ctx)
|
||||
{
|
||||
/* Yield at least once each tick */
|
||||
long tick = current_tick;
|
||||
if (TIME_AFTER(tick, ctx->last_yield))
|
||||
{
|
||||
ctx->last_yield = tick;
|
||||
yield();
|
||||
}
|
||||
}
|
||||
|
||||
static inline void dsp_process_end(struct dsp_loop_context *ctx)
|
||||
{
|
||||
#if defined(CPU_COLDFIRE)
|
||||
/* set old macsr again */
|
||||
coldfire_set_macsr(ctx->old_macsr);
|
||||
#endif
|
||||
(void)ctx;
|
||||
}
|
||||
|
||||
#define DSP_PROCESS_START() \
|
||||
struct dsp_loop_context __ctx; \
|
||||
dsp_process_start(&__ctx)
|
||||
|
||||
#define DSP_PROCESS_LOOP() \
|
||||
dsp_process_loop(&__ctx)
|
||||
|
||||
#define DSP_PROCESS_END() \
|
||||
dsp_process_end(&__ctx)
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
****************************************************************************/
|
||||
#include "config.h"
|
||||
#include "system.h"
|
||||
#include "platform.h"
|
||||
#include "dsp_core.h"
|
||||
#include "dsp_sample_io.h"
|
||||
#include <sys/types.h>
|
||||
|
@ -52,9 +53,6 @@ struct dsp_config
|
|||
active/enabled stages */
|
||||
|
||||
/** Misc. extra stuff **/
|
||||
#ifdef CPU_COLDFIRE
|
||||
unsigned long old_macsr; /* Old macsr value to restore */
|
||||
#endif
|
||||
#if 0 /* Not needed now but enable if something must know this */
|
||||
bool processing; /* DSP is processing (to thwart inopportune
|
||||
buffer moves) */
|
||||
|
@ -350,31 +348,12 @@ bool dsp_proc_call(struct dsp_proc_entry *this, struct dsp_buffer **buf_p,
|
|||
return false;
|
||||
}
|
||||
|
||||
static inline void dsp_process_start(struct dsp_config *dsp)
|
||||
{
|
||||
#if defined(CPU_COLDFIRE)
|
||||
/* set emac unit for dsp processing, and save old macsr, we're running in
|
||||
codec thread context at this point, so can't clobber it */
|
||||
dsp->old_macsr = coldfire_get_macsr();
|
||||
coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE);
|
||||
#endif
|
||||
#if 0 /* Not needed now but enable if something must know this */
|
||||
dsp->processing = true;
|
||||
#endif
|
||||
(void)dsp;
|
||||
}
|
||||
|
||||
static inline void dsp_process_end(struct dsp_config *dsp)
|
||||
{
|
||||
#if 0 /* Not needed now but enable if something must know this */
|
||||
dsp->processing = false;
|
||||
#endif
|
||||
#if defined(CPU_COLDFIRE)
|
||||
/* set old macsr again */
|
||||
coldfire_set_macsr(dsp->old_macsr);
|
||||
#endif
|
||||
(void)dsp;
|
||||
}
|
||||
#ifndef DSP_PROCESS_START
|
||||
/* These do nothing if not previously defined */
|
||||
#define DSP_PROCESS_START()
|
||||
#define DSP_PROCESS_LOOP()
|
||||
#define DSP_PROCESS_END()
|
||||
#endif /* !DSP_PROCESS_START */
|
||||
|
||||
/**
|
||||
* dsp_process:
|
||||
|
@ -429,11 +408,10 @@ void dsp_process(struct dsp_config *dsp, struct dsp_buffer *src,
|
|||
return;
|
||||
}
|
||||
|
||||
/* At least perform one yield before starting */
|
||||
long last_yield = current_tick;
|
||||
yield();
|
||||
|
||||
dsp_process_start(dsp);
|
||||
DSP_PROCESS_START();
|
||||
#if 0 /* Not needed now but enable if something must know this */
|
||||
dsp->processing = true;
|
||||
#endif
|
||||
|
||||
/* Tag input with codec-specified sample format */
|
||||
src->format = dsp->io_data.format;
|
||||
|
@ -478,16 +456,14 @@ void dsp_process(struct dsp_config *dsp, struct dsp_buffer *src,
|
|||
dsp_advance_buffer32(buf, outcount);
|
||||
dsp_advance_buffer_output(dst, outcount);
|
||||
|
||||
/* Yield at least once each tick */
|
||||
long tick = current_tick;
|
||||
if (TIME_AFTER(tick, last_yield))
|
||||
{
|
||||
last_yield = tick;
|
||||
yield();
|
||||
}
|
||||
DSP_PROCESS_LOOP();
|
||||
} /* while */
|
||||
|
||||
dsp_process_end(dsp);
|
||||
#if 0 /* Not needed now but enable if something must know this */
|
||||
dsp->process = false;
|
||||
#endif
|
||||
|
||||
DSP_PROCESS_END();
|
||||
}
|
||||
|
||||
intptr_t dsp_configure(struct dsp_config *dsp, unsigned int setting,
|
||||
|
|
|
@ -45,11 +45,6 @@
|
|||
/***************** EXPORTED *****************/
|
||||
|
||||
struct user_settings global_settings;
|
||||
volatile long current_tick = 0;
|
||||
|
||||
void yield(void)
|
||||
{
|
||||
}
|
||||
|
||||
int set_irq_level(int level)
|
||||
{
|
||||
|
@ -601,6 +596,10 @@ static void ci_logf(const char *fmt, ...)
|
|||
}
|
||||
#endif
|
||||
|
||||
static void ci_yield(void)
|
||||
{
|
||||
}
|
||||
|
||||
static void commit_dcache(void) {}
|
||||
static void commit_discard_dcache(void) {}
|
||||
static void commit_discard_idcache(void) {}
|
||||
|
@ -626,7 +625,7 @@ static struct codec_api ci = {
|
|||
ci_should_loop,
|
||||
|
||||
ci_sleep,
|
||||
yield,
|
||||
ci_yield,
|
||||
|
||||
#if NUM_CORES > 1
|
||||
ci_create_thread,
|
||||
|
|
Loading…
Reference in a new issue