summaryrefslogtreecommitdiff
path: root/firmware/export/pcm.h
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/export/pcm.h')
-rw-r--r--firmware/export/pcm.h122
1 files changed, 122 insertions, 0 deletions
diff --git a/firmware/export/pcm.h b/firmware/export/pcm.h
new file mode 100644
index 0000000000..a875479a2d
--- /dev/null
+++ b/firmware/export/pcm.h
@@ -0,0 +1,122 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2005 by Linus Nielsen Feltzing
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#ifndef PCM_PLAYBACK_H
20#define PCM_PLAYBACK_H
21
22#include <sys/types.h>
23
24/** RAW PCM routines used with playback and recording **/
25
26/* Typedef for registered callback */
27typedef void (*pcm_more_callback_type)(unsigned char **start,
28 size_t *size);
29typedef int (*pcm_more_callback_type2)(int status);
30
31/* set the pcm frequency - use values in hw_sampr_list
32 * use -1 for the default frequency
33 */
34void pcm_set_frequency(unsigned int frequency);
35/* apply settings to hardware immediately */
36void pcm_apply_settings(void);
37
38/** RAW PCM playback routines **/
39
40/* Reenterable locks for locking and unlocking the playback interrupt */
41void pcm_play_lock(void);
42void pcm_play_unlock(void);
43
44void pcm_init(void);
45void pcm_postinit(void);
46
47/* This is for playing "raw" PCM data */
48void pcm_play_data(pcm_more_callback_type get_more,
49 unsigned char* start, size_t size);
50
51void pcm_calculate_peaks(int *left, int *right);
52size_t pcm_get_bytes_waiting(void);
53
54void pcm_play_stop(void);
55void pcm_mute(bool mute);
56void pcm_play_pause(bool play);
57bool pcm_is_paused(void);
58bool pcm_is_playing(void);
59
60/** The following are for internal use between pcm.c and target-
61 specific portion **/
62
63extern unsigned long pcm_curr_sampr;
64
65/* the registered callback function to ask for more mp3 data */
66extern volatile pcm_more_callback_type pcm_callback_for_more;
67extern volatile bool pcm_playing;
68extern volatile bool pcm_paused;
69
70void pcm_play_dma_lock(void);
71void pcm_play_dma_unlock(void);
72void pcm_play_dma_init(void);
73void pcm_play_dma_start(const void *addr, size_t size);
74void pcm_play_dma_stop(void);
75void pcm_play_dma_pause(bool pause);
76void pcm_play_dma_stopped_callback(void);
77const void * pcm_play_dma_get_peak_buffer(int *count);
78
79#ifdef HAVE_RECORDING
80
81/** RAW PCM recording routines **/
82
83/* Reenterable locks for locking and unlocking the recording interrupt */
84void pcm_rec_lock(void);
85void pcm_rec_unlock(void);
86
87/* Initialize pcm recording interface */
88void pcm_init_recording(void);
89/* Uninitialze pcm recording interface */
90void pcm_close_recording(void);
91
92/* Start recording "raw" PCM data */
93void pcm_record_data(pcm_more_callback_type2 more_ready,
94 void *start, size_t size);
95
96/* Stop tranferring data into supplied buffer */
97void pcm_stop_recording(void);
98
99/* Continue transferring data in - call during interrupt handler */
100void pcm_record_more(void *start, size_t size);
101
102void pcm_calculate_rec_peaks(int *left, int *right);
103
104/** The following are for internal use between pcm.c and target-
105 specific portion **/
106extern volatile const void *pcm_rec_peak_addr;
107/* the registered callback function for when more data is available */
108extern volatile pcm_more_callback_type2 pcm_callback_more_ready;
109/* DMA transfer in is currently active */
110extern volatile bool pcm_recording;
111
112/* APIs implemented in the target-specific portion */
113void pcm_rec_dma_init(void);
114void pcm_rec_dma_close(void);
115void pcm_rec_dma_start(void *addr, size_t size);
116void pcm_rec_dma_stop(void);
117void pcm_rec_dma_stopped_callback(void);
118const void * pcm_rec_dma_get_peak_buffer(int *count);
119
120#endif /* HAVE_RECORDING */
121
122#endif /* PCM_PLAYBACK_H */