Make bin2c ensure that the generated C arrays are 32bit aligned. Building nrv2e_d8...
[kugel-rb.git] / firmware / export / pcm.h
blobb9ad913100d46f6d740d2a769859ef7068c6a79a
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 #define DMA_REC_ERROR_DMA (-1)
27 #ifdef HAVE_SPDIF_REC
28 #define DMA_REC_ERROR_SPDIF (-2)
29 #endif
31 /** Warnings **/
32 /* pcm (dma) buffer has overflowed */
33 #define PCMREC_W_PCM_BUFFER_OVF 0x00000001
34 /* encoder output buffer has overflowed */
35 #define PCMREC_W_ENC_BUFFER_OVF 0x00000002
36 /** Errors **/
37 /* failed to load encoder */
38 #define PCMREC_E_LOAD_ENCODER 0x80001000
39 /* error originating in encoder */
40 #define PCMREC_E_ENCODER 0x80002000
41 /* filename queue has desynced from stream markers */
42 #define PCMREC_E_FNQ_DESYNC 0x80004000
43 /* I/O error has occurred */
44 #define PCMREC_E_IO 0x80008000
45 #ifdef DEBUG
46 /* encoder has written past end of allotted space */
47 #define PCMREC_E_CHUNK_OVF 0x80010000
48 #endif /* DEBUG */
50 /** RAW PCM routines used with playback and recording **/
52 /* Typedef for registered callback */
53 typedef void (*pcm_more_callback_type)(unsigned char **start,
54 size_t *size);
55 typedef int (*pcm_more_callback_type2)(int status);
57 /* set the pcm frequency - use values in hw_sampr_list
58 * use -1 for the default frequency
60 void pcm_set_frequency(unsigned int samplerate);
61 /* apply settings to hardware immediately */
62 void pcm_apply_settings(void);
64 /** RAW PCM playback routines **/
66 /* Reenterable locks for locking and unlocking the playback interrupt */
67 void pcm_play_lock(void);
68 void pcm_play_unlock(void);
70 void pcm_init(void);
71 void pcm_postinit(void);
73 /* This is for playing "raw" PCM data */
74 void pcm_play_data(pcm_more_callback_type get_more,
75 unsigned char* start, size_t size);
77 void pcm_calculate_peaks(int *left, int *right);
78 const void* pcm_get_peak_buffer(int* count);
79 size_t pcm_get_bytes_waiting(void);
81 void pcm_play_stop(void);
82 void pcm_mute(bool mute);
83 void pcm_play_pause(bool play);
84 bool pcm_is_paused(void);
85 bool pcm_is_playing(void);
87 /** The following are for internal use between pcm.c and target-
88 specific portion **/
90 extern unsigned long pcm_curr_sampr;
91 extern unsigned long pcm_sampr;
92 extern int pcm_fsel;
94 #ifdef HAVE_PCM_DMA_ADDRESS
95 void * pcm_dma_addr(void *addr);
96 #endif
98 /* the registered callback function to ask for more mp3 data */
99 extern volatile pcm_more_callback_type pcm_callback_for_more;
100 extern volatile bool pcm_playing;
101 extern volatile bool pcm_paused;
103 void pcm_play_dma_lock(void);
104 void pcm_play_dma_unlock(void);
105 void pcm_play_dma_init(void);
106 void pcm_play_dma_start(const void *addr, size_t size);
107 void pcm_play_dma_stop(void);
108 void pcm_play_dma_pause(bool pause);
109 void pcm_play_dma_stopped_callback(void);
110 const void * pcm_play_dma_get_peak_buffer(int *count);
112 void pcm_dma_apply_settings(void);
114 #ifdef HAVE_RECORDING
116 /** RAW PCM recording routines **/
118 /* Reenterable locks for locking and unlocking the recording interrupt */
119 void pcm_rec_lock(void);
120 void pcm_rec_unlock(void);
122 /* Initialize pcm recording interface */
123 void pcm_init_recording(void);
124 /* Uninitialze pcm recording interface */
125 void pcm_close_recording(void);
127 /* Start recording "raw" PCM data */
128 void pcm_record_data(pcm_more_callback_type2 more_ready,
129 void *start, size_t size);
131 /* Stop tranferring data into supplied buffer */
132 void pcm_stop_recording(void);
134 /* Is pcm currently recording? */
135 bool pcm_is_recording(void);
137 /* Continue transferring data in - call during interrupt handler */
138 void pcm_record_more(void *start, size_t size);
140 void pcm_calculate_rec_peaks(int *left, int *right);
142 /** The following are for internal use between pcm.c and target-
143 specific portion **/
144 extern volatile const void *pcm_rec_peak_addr;
145 /* the registered callback function for when more data is available */
146 extern volatile pcm_more_callback_type2 pcm_callback_more_ready;
147 /* DMA transfer in is currently active */
148 extern volatile bool pcm_recording;
150 /* APIs implemented in the target-specific portion */
151 void pcm_rec_dma_init(void);
152 void pcm_rec_dma_close(void);
153 void pcm_rec_dma_start(void *addr, size_t size);
154 void pcm_rec_dma_stop(void);
155 void pcm_rec_dma_stopped_callback(void);
156 const void * pcm_rec_dma_get_peak_buffer(int *count);
158 #endif /* HAVE_RECORDING */
160 #endif /* PCM_PLAYBACK_H */