usb: add support for hardware handled SET ADDR/CONFIG
[maemo-rb.git] / apps / rbcodecconfig.h
blobff9fc41342fb39cf5c6fdb284ad20d349686da9f
1 #ifndef RBCODECCONFIG_H_INCLUDED
2 #define RBCODECCONFIG_H_INCLUDED
4 #include "config.h"
6 #ifndef __ASSEMBLER__
8 /* NULL, offsetof, size_t */
9 #include <stddef.h>
11 /* ssize_t, off_t, open, close, read, lseek, SEEK_SET, SEEK_CUR, SEEK_END,
12 * O_RDONLY, O_WRONLY, O_CREAT, O_APPEND, MAX_PATH, filesize */
13 #include "file.h"
15 /* {,u}int{8,16,32,64}_t, , intptr_t, uintptr_t, bool, true, false, swap16,
16 * swap32, hto{be,le}{16,32}, {be,le}toh{16,32}, ROCKBOX_{BIG,LITTLE}_ENDIAN,
17 * {,U}INT{8,16,32,64}_{MIN,MAX} */
18 #include "system.h"
20 /* Structure to record some info during processing call */
21 struct dsp_loop_context
23 long last_yield;
24 #ifdef CPU_COLDFIRE
25 unsigned long old_macsr;
26 #endif
29 static inline void dsp_process_start(struct dsp_loop_context *ctx)
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
42 static inline void dsp_process_loop(struct dsp_loop_context *ctx)
44 /* Yield at least once each tick */
45 long tick = current_tick;
46 if (TIME_AFTER(tick, ctx->last_yield))
48 ctx->last_yield = tick;
49 yield();
53 static inline void dsp_process_end(struct dsp_loop_context *ctx)
55 #if defined(CPU_COLDFIRE)
56 /* set old macsr again */
57 coldfire_set_macsr(ctx->old_macsr);
58 #endif
59 (void)ctx;
62 #define DSP_PROCESS_START() \
63 struct dsp_loop_context __ctx; \
64 dsp_process_start(&__ctx)
66 #define DSP_PROCESS_LOOP() \
67 dsp_process_loop(&__ctx)
69 #define DSP_PROCESS_END() \
70 dsp_process_end(&__ctx)
72 #endif
74 #endif