Colour targets: Revert an optimisation from almost 18 months ago that actually turned...
[Rockbox.git] / firmware / export / pcm.h
blob97a1939dbb571acdd950c88c5941aa9fd00d5e9f
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2005 by Linus Nielsen Feltzing
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 ****************************************************************************/
21 #ifndef PCM_PLAYBACK_H
22 #define PCM_PLAYBACK_H
24 #include <sys/types.h>
26 /** RAW PCM routines used with playback and recording **/
28 /* Typedef for registered callback */
29 typedef void (*pcm_more_callback_type)(unsigned char **start,
30 size_t *size);
31 typedef int (*pcm_more_callback_type2)(int status);
33 /* set the pcm frequency - use values in hw_sampr_list
34 * use -1 for the default frequency
36 void pcm_set_frequency(unsigned int frequency);
37 /* apply settings to hardware immediately */
38 void pcm_apply_settings(void);
40 /** RAW PCM playback routines **/
42 /* Reenterable locks for locking and unlocking the playback interrupt */
43 void pcm_play_lock(void);
44 void pcm_play_unlock(void);
46 void pcm_init(void);
47 void pcm_postinit(void);
49 /* This is for playing "raw" PCM data */
50 void pcm_play_data(pcm_more_callback_type get_more,
51 unsigned char* start, size_t size);
53 void pcm_calculate_peaks(int *left, int *right);
54 size_t pcm_get_bytes_waiting(void);
56 void pcm_play_stop(void);
57 void pcm_mute(bool mute);
58 void pcm_play_pause(bool play);
59 bool pcm_is_paused(void);
60 bool pcm_is_playing(void);
62 /** The following are for internal use between pcm.c and target-
63 specific portion **/
65 extern unsigned long pcm_curr_sampr;
67 /* the registered callback function to ask for more mp3 data */
68 extern volatile pcm_more_callback_type pcm_callback_for_more;
69 extern volatile bool pcm_playing;
70 extern volatile bool pcm_paused;
72 void pcm_play_dma_lock(void);
73 void pcm_play_dma_unlock(void);
74 void pcm_play_dma_init(void);
75 void pcm_play_dma_start(const void *addr, size_t size);
76 void pcm_play_dma_stop(void);
77 void pcm_play_dma_pause(bool pause);
78 void pcm_play_dma_stopped_callback(void);
79 const void * pcm_play_dma_get_peak_buffer(int *count);
81 #ifdef HAVE_RECORDING
83 /** RAW PCM recording routines **/
85 /* Reenterable locks for locking and unlocking the recording interrupt */
86 void pcm_rec_lock(void);
87 void pcm_rec_unlock(void);
89 /* Initialize pcm recording interface */
90 void pcm_init_recording(void);
91 /* Uninitialze pcm recording interface */
92 void pcm_close_recording(void);
94 /* Start recording "raw" PCM data */
95 void pcm_record_data(pcm_more_callback_type2 more_ready,
96 void *start, size_t size);
98 /* Stop tranferring data into supplied buffer */
99 void pcm_stop_recording(void);
101 /* Continue transferring data in - call during interrupt handler */
102 void pcm_record_more(void *start, size_t size);
104 void pcm_calculate_rec_peaks(int *left, int *right);
106 /** The following are for internal use between pcm.c and target-
107 specific portion **/
108 extern volatile const void *pcm_rec_peak_addr;
109 /* the registered callback function for when more data is available */
110 extern volatile pcm_more_callback_type2 pcm_callback_more_ready;
111 /* DMA transfer in is currently active */
112 extern volatile bool pcm_recording;
114 /* APIs implemented in the target-specific portion */
115 void pcm_rec_dma_init(void);
116 void pcm_rec_dma_close(void);
117 void pcm_rec_dma_start(void *addr, size_t size);
118 void pcm_rec_dma_stop(void);
119 void pcm_rec_dma_stopped_callback(void);
120 const void * pcm_rec_dma_get_peak_buffer(int *count);
122 #endif /* HAVE_RECORDING */
124 #endif /* PCM_PLAYBACK_H */