summaryrefslogtreecommitdiff
path: root/firmware/export/pcm_mixer.h
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/export/pcm_mixer.h')
-rw-r--r--firmware/export/pcm_mixer.h102
1 files changed, 102 insertions, 0 deletions
diff --git a/firmware/export/pcm_mixer.h b/firmware/export/pcm_mixer.h
new file mode 100644
index 0000000000..3b420e1320
--- /dev/null
+++ b/firmware/export/pcm_mixer.h
@@ -0,0 +1,102 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2011 by Michael Sevakis
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef PCM_MIXER_H
23#define PCM_MIXER_H
24
25/** Simple config **/
26
27/* Length of PCM frames (always) */
28#if CONFIG_CPU == PP5002
29/* There's far less time to do mixing because HW FIFOs are short */
30#define MIX_FRAME_SAMPLES 64
31#else
32/* Assume HW DMA engine is available or sufficient latency exists in the
33 PCM pathway */
34#define MIX_FRAME_SAMPLES 256
35#endif
36
37#if defined(CPU_COLDFIRE) || defined(CPU_PP)
38/* For Coldfire, it's just faster
39 For PortalPlayer, this also avoids more expensive cache coherency */
40#define DOWNMIX_BUF_IBSS IBSS_ATTR
41#else
42/* Otherwise can't DMA from IRAM, IRAM is pointless or worse */
43#define DOWNMIX_BUF_IBSS
44#endif
45
46
47/** Definitions **/
48
49/* Channels are preassigned for simplicity */
50enum pcm_mixer_channel
51{
52 PCM_MIXER_CHAN_PLAYBACK = 0,
53 PCM_MIXER_CHAN_VOICE,
54#ifndef HAVE_HARDWARE_BEEP
55 PCM_MIXER_CHAN_BEEP,
56#endif
57 /* Add new channel indexes above this line */
58 PCM_MIXER_NUM_CHANNELS,
59};
60
61/* Channel playback states */
62enum channel_status
63{
64 CHANNEL_STOPPED = 0,
65 CHANNEL_PLAYING,
66 CHANNEL_PAUSED,
67};
68
69#define MIX_AMP_UNITY 0x00010000
70#define MIX_AMP_MUTE 0x00000000
71
72
73/** Public interfaces **/
74
75/* Start playback on a channel */
76void mixer_channel_play_data(enum pcm_mixer_channel channel,
77 pcm_play_callback_type get_more,
78 unsigned char *start, size_t size);
79
80/* Pause or resume a channel (when started) */
81void mixer_channel_play_pause(enum pcm_mixer_channel channel, bool play);
82
83/* Stop playback on a channel */
84void mixer_channel_stop(enum pcm_mixer_channel channel);
85
86/* Set channel's amplitude factor */
87void mixer_channel_set_amplitude(enum pcm_mixer_channel channel,
88 unsigned int amplitude);
89
90/* Return channel's playback status */
91enum channel_status mixer_channel_status(enum pcm_mixer_channel channel);
92
93/* Returns amount data remaining in channel before next callback */
94size_t mixer_channel_get_bytes_waiting(enum pcm_mixer_channel channel);
95
96/* Return pointer to channel's playing audio data and the size remaining */
97void * mixer_channel_get_buffer(enum pcm_mixer_channel channel, int *count);
98
99/* Stop ALL channels and PCM and reset state */
100void mixer_reset(void);
101
102#endif /* PCM_MIXER_H */