1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2005 by Linus Nielsen Feltzing
11 * Copyright (C) 2011 by Michael Sevakis
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ****************************************************************************/
22 #ifndef PCM_INTERNAL_H
23 #define PCM_INTERNAL_H
27 /* Cheapo buffer align macro to align to the 16-16 PCM size */
28 #define ALIGN_AUDIOBUF(start, size) \
29 ({ (start) = (void *)(((uintptr_t)(start) + 3) & ~3); \
39 void pcm_do_peak_calculation(struct pcm_peaks
*peaks
, bool active
,
40 const void *addr
, int count
);
42 /** The following are for internal use between pcm.c and target-
45 /* Called by the bottom layer ISR when more data is needed. Returns non-
46 * zero size if more data is to be played. Setting start to NULL
48 void pcm_play_get_more_callback(void **start
, size_t *size
);
50 /* Called by the bottom layer ISR after next transfer has begun in order
51 to fill more data for next "get more" callback to implement double-buffered
52 callbacks - except for a couple ASM handlers, help drivers to implement
53 this functionality with minimal overhead */
54 static FORCE_INLINE
void pcm_play_dma_started_callback(void)
56 extern void (* pcm_play_dma_started
)(void);
57 void (* callback
)(void) = pcm_play_dma_started
;
62 extern unsigned long pcm_curr_sampr
;
63 extern unsigned long pcm_sampr
;
66 #ifdef HAVE_PCM_DMA_ADDRESS
67 void * pcm_dma_addr(void *addr
);
70 extern volatile bool pcm_playing
;
71 extern volatile bool pcm_paused
;
73 void pcm_play_dma_lock(void);
74 void pcm_play_dma_unlock(void);
75 void pcm_play_dma_init(void) INIT_ATTR
;
76 void pcm_play_dma_postinit(void);
77 void pcm_play_dma_start(const void *addr
, size_t size
);
78 void pcm_play_dma_stop(void);
79 void pcm_play_dma_pause(bool pause
);
80 const void * pcm_play_dma_get_peak_buffer(int *count
);
82 void pcm_dma_apply_settings(void);
86 /* DMA transfer in is currently active */
87 extern volatile bool pcm_recording
;
89 /* APIs implemented in the target-specific portion */
90 void pcm_rec_dma_init(void);
91 void pcm_rec_dma_close(void);
92 void pcm_rec_dma_start(void *addr
, size_t size
);
93 void pcm_rec_dma_record_more(void *start
, size_t size
);
94 void pcm_rec_dma_stop(void);
95 const void * pcm_rec_dma_get_peak_buffer(void);
97 #endif /* HAVE_RECORDING */
99 #endif /* PCM_INTERNAL_H */