diff options
Diffstat (limited to 'firmware/export/pcm.h')
-rw-r--r-- | firmware/export/pcm.h | 122 |
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 */ | ||
27 | typedef void (*pcm_more_callback_type)(unsigned char **start, | ||
28 | size_t *size); | ||
29 | typedef 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 | */ | ||
34 | void pcm_set_frequency(unsigned int frequency); | ||
35 | /* apply settings to hardware immediately */ | ||
36 | void pcm_apply_settings(void); | ||
37 | |||
38 | /** RAW PCM playback routines **/ | ||
39 | |||
40 | /* Reenterable locks for locking and unlocking the playback interrupt */ | ||
41 | void pcm_play_lock(void); | ||
42 | void pcm_play_unlock(void); | ||
43 | |||
44 | void pcm_init(void); | ||
45 | void pcm_postinit(void); | ||
46 | |||
47 | /* This is for playing "raw" PCM data */ | ||
48 | void pcm_play_data(pcm_more_callback_type get_more, | ||
49 | unsigned char* start, size_t size); | ||
50 | |||
51 | void pcm_calculate_peaks(int *left, int *right); | ||
52 | size_t pcm_get_bytes_waiting(void); | ||
53 | |||
54 | void pcm_play_stop(void); | ||
55 | void pcm_mute(bool mute); | ||
56 | void pcm_play_pause(bool play); | ||
57 | bool pcm_is_paused(void); | ||
58 | bool pcm_is_playing(void); | ||
59 | |||
60 | /** The following are for internal use between pcm.c and target- | ||
61 | specific portion **/ | ||
62 | |||
63 | extern unsigned long pcm_curr_sampr; | ||
64 | |||
65 | /* the registered callback function to ask for more mp3 data */ | ||
66 | extern volatile pcm_more_callback_type pcm_callback_for_more; | ||
67 | extern volatile bool pcm_playing; | ||
68 | extern volatile bool pcm_paused; | ||
69 | |||
70 | void pcm_play_dma_lock(void); | ||
71 | void pcm_play_dma_unlock(void); | ||
72 | void pcm_play_dma_init(void); | ||
73 | void pcm_play_dma_start(const void *addr, size_t size); | ||
74 | void pcm_play_dma_stop(void); | ||
75 | void pcm_play_dma_pause(bool pause); | ||
76 | void pcm_play_dma_stopped_callback(void); | ||
77 | const 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 */ | ||
84 | void pcm_rec_lock(void); | ||
85 | void pcm_rec_unlock(void); | ||
86 | |||
87 | /* Initialize pcm recording interface */ | ||
88 | void pcm_init_recording(void); | ||
89 | /* Uninitialze pcm recording interface */ | ||
90 | void pcm_close_recording(void); | ||
91 | |||
92 | /* Start recording "raw" PCM data */ | ||
93 | void pcm_record_data(pcm_more_callback_type2 more_ready, | ||
94 | void *start, size_t size); | ||
95 | |||
96 | /* Stop tranferring data into supplied buffer */ | ||
97 | void pcm_stop_recording(void); | ||
98 | |||
99 | /* Continue transferring data in - call during interrupt handler */ | ||
100 | void pcm_record_more(void *start, size_t size); | ||
101 | |||
102 | void pcm_calculate_rec_peaks(int *left, int *right); | ||
103 | |||
104 | /** The following are for internal use between pcm.c and target- | ||
105 | specific portion **/ | ||
106 | extern volatile const void *pcm_rec_peak_addr; | ||
107 | /* the registered callback function for when more data is available */ | ||
108 | extern volatile pcm_more_callback_type2 pcm_callback_more_ready; | ||
109 | /* DMA transfer in is currently active */ | ||
110 | extern volatile bool pcm_recording; | ||
111 | |||
112 | /* APIs implemented in the target-specific portion */ | ||
113 | void pcm_rec_dma_init(void); | ||
114 | void pcm_rec_dma_close(void); | ||
115 | void pcm_rec_dma_start(void *addr, size_t size); | ||
116 | void pcm_rec_dma_stop(void); | ||
117 | void pcm_rec_dma_stopped_callback(void); | ||
118 | const void * pcm_rec_dma_get_peak_buffer(int *count); | ||
119 | |||
120 | #endif /* HAVE_RECORDING */ | ||
121 | |||
122 | #endif /* PCM_PLAYBACK_H */ | ||