Fix warning about missing newline at the EOF
[maemo-rb.git] / firmware / export / pcm-internal.h
blob89d895fe4bd08796677cf995a19a7cf605dd9574
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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
25 #include "config.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); \
30 (size) &= ~3; })
32 struct pcm_peaks
34 long period;
35 long tick;
36 uint16_t val[2];
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-
43 specific portion **/
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
47 * forces stop. */
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;
58 if (callback)
59 callback();
62 extern unsigned long pcm_curr_sampr;
63 extern unsigned long pcm_sampr;
64 extern int pcm_fsel;
66 #ifdef HAVE_PCM_DMA_ADDRESS
67 void * pcm_dma_addr(void *addr);
68 #endif
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);
84 #ifdef HAVE_RECORDING
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 */