CHARCELL doesn't have sbs support, so disable it properly.
[maemo-rb.git] / firmware / export / pcm_mixer.h
blob69d2b894df6144becbb1edebe0d5679090c2429d
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2011 by Michael Sevakis
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #ifndef PCM_MIXER_H
23 #define PCM_MIXER_H
25 #include <sys/types.h>
27 /** Simple config **/
29 /* Length of PCM frames (always) */
30 #if CONFIG_CPU == PP5002
31 /* There's far less time to do mixing because HW FIFOs are short */
32 #define MIX_FRAME_SAMPLES 64
33 #elif (CONFIG_PLATFORM & PLATFORM_MAEMO5)
34 /* Maemo 5 needs 2048 samples for decent performance.
35 Otherwise the locking overhead inside gstreamer costs too much */
36 #define MIX_FRAME_SAMPLES 2048
37 /* Assume HW DMA engine is available or sufficient latency exists in the
38 PCM pathway */
39 #else
40 #define MIX_FRAME_SAMPLES 256
41 #endif
43 #if defined(CPU_COLDFIRE) || defined(CPU_PP)
44 /* For Coldfire, it's just faster
45 For PortalPlayer, this also avoids more expensive cache coherency */
46 #define DOWNMIX_BUF_IBSS IBSS_ATTR
47 #else
48 /* Otherwise can't DMA from IRAM, IRAM is pointless or worse */
49 #define DOWNMIX_BUF_IBSS
50 #endif
52 #if defined(CPU_COLDFIRE) || defined(CPU_PP)
53 #define MIXER_CALLBACK_ICODE ICODE_ATTR
54 #else
55 #define MIXER_CALLBACK_ICODE
56 #endif
59 /** Definitions **/
61 /* Channels are preassigned for simplicity */
62 enum pcm_mixer_channel
64 PCM_MIXER_CHAN_PLAYBACK = 0,
65 PCM_MIXER_CHAN_VOICE,
66 #ifndef HAVE_HARDWARE_BEEP
67 PCM_MIXER_CHAN_BEEP,
68 #endif
69 /* Add new channel indexes above this line */
70 PCM_MIXER_NUM_CHANNELS,
73 /* Channel playback states */
74 enum channel_status
76 CHANNEL_STOPPED = 0,
77 CHANNEL_PLAYING,
78 CHANNEL_PAUSED,
81 #define MIX_AMP_UNITY 0x00010000
82 #define MIX_AMP_MUTE 0x00000000
85 /** Public interfaces **/
87 /* Start playback on a channel */
88 void mixer_channel_play_data(enum pcm_mixer_channel channel,
89 pcm_play_callback_type get_more,
90 const void *start, size_t size);
92 /* Pause or resume a channel (when started) */
93 void mixer_channel_play_pause(enum pcm_mixer_channel channel, bool play);
95 /* Stop playback on a channel */
96 void mixer_channel_stop(enum pcm_mixer_channel channel);
98 /* Set channel's amplitude factor */
99 void mixer_channel_set_amplitude(enum pcm_mixer_channel channel,
100 unsigned int amplitude);
102 /* Return channel's playback status */
103 enum channel_status mixer_channel_status(enum pcm_mixer_channel channel);
105 /* Returns amount data remaining in channel before next callback */
106 size_t mixer_channel_get_bytes_waiting(enum pcm_mixer_channel channel);
108 /* Return pointer to channel's playing audio data and the size remaining */
109 const void * mixer_channel_get_buffer(enum pcm_mixer_channel channel, int *count);
111 /* Calculate peak values for channel */
112 void mixer_channel_calculate_peaks(enum pcm_mixer_channel channel,
113 struct pcm_peaks *peaks);
115 /* Adjust channel pointer by a given offset to support movable buffers */
116 void mixer_adjust_channel_address(enum pcm_mixer_channel channel,
117 off_t offset);
119 /* Stop ALL channels and PCM and reset state */
120 void mixer_reset(void);
122 #endif /* PCM_MIXER_H */