diff options
| author | Michael Sevakis <jethead71@rockbox.org> | 2012-05-03 15:54:48 +0200 |
|---|---|---|
| committer | Nils Wallménius <nils@rockbox.org> | 2012-05-03 23:47:46 +0200 |
| commit | dbe5e5f2df24a0dbe650561c0b42ce982346534c (patch) | |
| tree | 65dffbf75406724b6772c79acaf6e2bff8c2ffcb /apps | |
| parent | 00cf2ce711c87cc6a3d44bce44e3b1b67a188e56 (diff) | |
| download | rockbox-dbe5e5f2df24a0dbe650561c0b42ce982346534c.zip rockbox-dbe5e5f2df24a0dbe650561c0b42ce982346534c.tar.gz rockbox-dbe5e5f2df24a0dbe650561c0b42ce982346534c.tar.bz2 rockbox-dbe5e5f2df24a0dbe650561c0b42ce982346534c.tar.xz | |
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>
Diffstat (limited to 'apps')
| -rw-r--r-- | apps/rbcodecconfig.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/apps/rbcodecconfig.h b/apps/rbcodecconfig.h index 6c7a074..ff9fc41 100644 --- a/apps/rbcodecconfig.h +++ b/apps/rbcodecconfig.h @@ -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 |