summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/rbcodecconfig.h52
-rw-r--r--lib/rbcodec/dsp/dsp_core.c58
-rw-r--r--lib/rbcodec/test/warble.c11
3 files changed, 74 insertions, 47 deletions
diff --git a/apps/rbcodecconfig.h b/apps/rbcodecconfig.h
index 6c7a0749f0..ff9fc41342 100644
--- a/apps/rbcodecconfig.h
+++ b/apps/rbcodecconfig.h
@@ -17,6 +17,58 @@
17 * {,U}INT{8,16,32,64}_{MIN,MAX} */ 17 * {,U}INT{8,16,32,64}_{MIN,MAX} */
18#include "system.h" 18#include "system.h"
19 19
20/* Structure to record some info during processing call */
21struct dsp_loop_context
22{
23 long last_yield;
24#ifdef CPU_COLDFIRE
25 unsigned long old_macsr;
26#endif
27};
28
29static inline void dsp_process_start(struct dsp_loop_context *ctx)
30{
31 /* At least perform one yield before starting */
32 ctx->last_yield = current_tick;
33 yield();
34#if defined(CPU_COLDFIRE)
35 /* set emac unit for dsp processing, and save old macsr, we're running in
36 codec thread context at this point, so can't clobber it */
37 ctx->old_macsr = coldfire_get_macsr();
38 coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE);
39#endif
40}
41
42static inline void dsp_process_loop(struct dsp_loop_context *ctx)
43{
44 /* Yield at least once each tick */
45 long tick = current_tick;
46 if (TIME_AFTER(tick, ctx->last_yield))
47 {
48 ctx->last_yield = tick;
49 yield();
50 }
51}
52
53static inline void dsp_process_end(struct dsp_loop_context *ctx)
54{
55#if defined(CPU_COLDFIRE)
56 /* set old macsr again */
57 coldfire_set_macsr(ctx->old_macsr);
58#endif
59 (void)ctx;
60}
61
62#define DSP_PROCESS_START() \
63 struct dsp_loop_context __ctx; \
64 dsp_process_start(&__ctx)
65
66#define DSP_PROCESS_LOOP() \
67 dsp_process_loop(&__ctx)
68
69#define DSP_PROCESS_END() \
70 dsp_process_end(&__ctx)
71
20#endif 72#endif
21 73
22#endif 74#endif
diff --git a/lib/rbcodec/dsp/dsp_core.c b/lib/rbcodec/dsp/dsp_core.c
index 44e53eb891..175b9c1c64 100644
--- a/lib/rbcodec/dsp/dsp_core.c
+++ b/lib/rbcodec/dsp/dsp_core.c
@@ -21,6 +21,7 @@
21 ****************************************************************************/ 21 ****************************************************************************/
22#include "config.h" 22#include "config.h"
23#include "system.h" 23#include "system.h"
24#include "platform.h"
24#include "dsp_core.h" 25#include "dsp_core.h"
25#include "dsp_sample_io.h" 26#include "dsp_sample_io.h"
26#include <sys/types.h> 27#include <sys/types.h>
@@ -52,9 +53,6 @@ struct dsp_config
52 active/enabled stages */ 53 active/enabled stages */
53 54
54 /** Misc. extra stuff **/ 55 /** Misc. extra stuff **/
55#ifdef CPU_COLDFIRE
56 unsigned long old_macsr; /* Old macsr value to restore */
57#endif
58#if 0 /* Not needed now but enable if something must know this */ 56#if 0 /* Not needed now but enable if something must know this */
59 bool processing; /* DSP is processing (to thwart inopportune 57 bool processing; /* DSP is processing (to thwart inopportune
60 buffer moves) */ 58 buffer moves) */
@@ -350,31 +348,12 @@ bool dsp_proc_call(struct dsp_proc_entry *this, struct dsp_buffer **buf_p,
350 return false; 348 return false;
351} 349}
352 350
353static inline void dsp_process_start(struct dsp_config *dsp) 351#ifndef DSP_PROCESS_START
354{ 352/* These do nothing if not previously defined */
355#if defined(CPU_COLDFIRE) 353#define DSP_PROCESS_START()
356 /* set emac unit for dsp processing, and save old macsr, we're running in 354#define DSP_PROCESS_LOOP()
357 codec thread context at this point, so can't clobber it */ 355#define DSP_PROCESS_END()
358 dsp->old_macsr = coldfire_get_macsr(); 356#endif /* !DSP_PROCESS_START */
359 coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE);
360#endif
361#if 0 /* Not needed now but enable if something must know this */
362 dsp->processing = true;
363#endif
364 (void)dsp;
365}
366
367static inline void dsp_process_end(struct dsp_config *dsp)
368{
369#if 0 /* Not needed now but enable if something must know this */
370 dsp->processing = false;
371#endif
372#if defined(CPU_COLDFIRE)
373 /* set old macsr again */
374 coldfire_set_macsr(dsp->old_macsr);
375#endif
376 (void)dsp;
377}
378 357
379/** 358/**
380 * dsp_process: 359 * dsp_process:
@@ -429,11 +408,10 @@ void dsp_process(struct dsp_config *dsp, struct dsp_buffer *src,
429 return; 408 return;
430 } 409 }
431 410
432 /* At least perform one yield before starting */ 411 DSP_PROCESS_START();
433 long last_yield = current_tick; 412#if 0 /* Not needed now but enable if something must know this */
434 yield(); 413 dsp->processing = true;
435 414#endif
436 dsp_process_start(dsp);
437 415
438 /* Tag input with codec-specified sample format */ 416 /* Tag input with codec-specified sample format */
439 src->format = dsp->io_data.format; 417 src->format = dsp->io_data.format;
@@ -478,16 +456,14 @@ void dsp_process(struct dsp_config *dsp, struct dsp_buffer *src,
478 dsp_advance_buffer32(buf, outcount); 456 dsp_advance_buffer32(buf, outcount);
479 dsp_advance_buffer_output(dst, outcount); 457 dsp_advance_buffer_output(dst, outcount);
480 458
481 /* Yield at least once each tick */ 459 DSP_PROCESS_LOOP();
482 long tick = current_tick;
483 if (TIME_AFTER(tick, last_yield))
484 {
485 last_yield = tick;
486 yield();
487 }
488 } /* while */ 460 } /* while */
489 461
490 dsp_process_end(dsp); 462#if 0 /* Not needed now but enable if something must know this */
463 dsp->process = false;
464#endif
465
466 DSP_PROCESS_END();
491} 467}
492 468
493intptr_t dsp_configure(struct dsp_config *dsp, unsigned int setting, 469intptr_t dsp_configure(struct dsp_config *dsp, unsigned int setting,
diff --git a/lib/rbcodec/test/warble.c b/lib/rbcodec/test/warble.c
index 53d360d89e..ea8efcffca 100644
--- a/lib/rbcodec/test/warble.c
+++ b/lib/rbcodec/test/warble.c
@@ -45,11 +45,6 @@
45/***************** EXPORTED *****************/ 45/***************** EXPORTED *****************/
46 46
47struct user_settings global_settings; 47struct user_settings global_settings;
48volatile long current_tick = 0;
49
50void yield(void)
51{
52}
53 48
54int set_irq_level(int level) 49int set_irq_level(int level)
55{ 50{
@@ -601,6 +596,10 @@ static void ci_logf(const char *fmt, ...)
601} 596}
602#endif 597#endif
603 598
599static void ci_yield(void)
600{
601}
602
604static void commit_dcache(void) {} 603static void commit_dcache(void) {}
605static void commit_discard_dcache(void) {} 604static void commit_discard_dcache(void) {}
606static void commit_discard_idcache(void) {} 605static void commit_discard_idcache(void) {}
@@ -626,7 +625,7 @@ static struct codec_api ci = {
626 ci_should_loop, 625 ci_should_loop,
627 626
628 ci_sleep, 627 ci_sleep,
629 yield, 628 ci_yield,
630 629
631#if NUM_CORES > 1 630#if NUM_CORES > 1
632 ci_create_thread, 631 ci_create_thread,