Update bulgarian.lang by Zahari Yurukov
[maemo-rb.git] / firmware / export / pcm-internal.h
blob397cf6832fee179892f8a9caf8cde2e3e8aa397b
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 void pcm_do_peak_calculation(struct pcm_peaks *peaks, bool active,
33 const void *addr, int count);
35 /** The following are for internal use between pcm.c and target-
36 specific portion **/
37 static FORCE_INLINE enum pcm_dma_status pcm_call_status_cb(
38 pcm_status_callback_type callback, enum pcm_dma_status status)
40 if (!callback)
41 return status;
43 return callback(status);
46 static FORCE_INLINE enum pcm_dma_status
47 pcm_play_dma_status_callback(enum pcm_dma_status status)
49 extern enum pcm_dma_status
50 (* volatile pcm_play_status_callback)(enum pcm_dma_status);
51 return pcm_call_status_cb(pcm_play_status_callback, status);
54 /* Called by the bottom layer ISR when more data is needed. Returns true
55 * if a new buffer is available, false otherwise. */
56 bool pcm_play_dma_complete_callback(enum pcm_dma_status status,
57 const void **addr, size_t *size);
59 extern unsigned long pcm_curr_sampr;
60 extern unsigned long pcm_sampr;
61 extern int pcm_fsel;
63 #ifdef HAVE_PCM_DMA_ADDRESS
64 void * pcm_dma_addr(void *addr);
65 #endif
67 extern volatile bool pcm_playing;
68 extern volatile bool pcm_paused;
70 void pcm_play_dma_lock(void);
71 void pcm_play_dma_unlock(void);
72 void pcm_play_dma_init(void) INIT_ATTR;
73 void pcm_play_dma_postinit(void);
74 void pcm_play_dma_start(const void *addr, size_t size);
75 void pcm_play_dma_stop(void);
76 void pcm_play_dma_pause(bool pause);
77 const void * pcm_play_dma_get_peak_buffer(int *count);
79 void pcm_dma_apply_settings(void);
81 #ifdef HAVE_RECORDING
83 /* DMA transfer in is currently active */
84 extern volatile bool pcm_recording;
86 /* APIs implemented in the target-specific portion */
87 void pcm_rec_dma_init(void);
88 void pcm_rec_dma_close(void);
89 void pcm_rec_dma_start(void *addr, size_t size);
90 void pcm_rec_dma_stop(void);
91 const void * pcm_rec_dma_get_peak_buffer(void);
93 static FORCE_INLINE enum pcm_dma_status
94 pcm_rec_dma_status_callback(enum pcm_dma_status status)
96 extern enum pcm_dma_status
97 (* volatile pcm_rec_status_callback)(enum pcm_dma_status);
98 return pcm_call_status_cb(pcm_rec_status_callback, status);
102 /* Called by the bottom layer ISR when more data is needed. Returns true
103 * if a new buffer is available, false otherwise. */
104 bool pcm_rec_dma_complete_callback(enum pcm_dma_status status,
105 void **addr, size_t *size);
107 #ifdef HAVE_PCM_REC_DMA_ADDRESS
108 #define pcm_rec_dma_addr(addr) pcm_dma_addr(addr)
109 #else
110 #define pcm_rec_dma_addr(addr) addr
111 #endif
113 #endif /* HAVE_RECORDING */
115 #endif /* PCM_INTERNAL_H */