android: lcd_update/_rect() changes
[maemo-rb.git] / firmware / export / pcm-internal.h
blobabe3fe08dc56f118cba383e514bb4fe0b6071963
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 **/
44 static FORCE_INLINE enum pcm_dma_status pcm_call_status_cb(
45 pcm_status_callback_type callback, enum pcm_dma_status status)
47 if (!callback)
48 return status;
50 return callback(status);
53 static FORCE_INLINE enum pcm_dma_status
54 pcm_play_dma_status_callback(enum pcm_dma_status status)
56 extern enum pcm_dma_status
57 (* volatile pcm_play_status_callback)(enum pcm_dma_status);
58 return pcm_call_status_cb(pcm_play_status_callback, status);
61 /* Called by the bottom layer ISR when more data is needed. Returns true
62 * if a new buffer is available, false otherwise. */
63 bool pcm_play_dma_complete_callback(enum pcm_dma_status status,
64 const void **addr, size_t *size);
66 extern unsigned long pcm_curr_sampr;
67 extern unsigned long pcm_sampr;
68 extern int pcm_fsel;
70 #ifdef HAVE_PCM_DMA_ADDRESS
71 void * pcm_dma_addr(void *addr);
72 #endif
74 extern volatile bool pcm_playing;
75 extern volatile bool pcm_paused;
77 void pcm_play_dma_lock(void);
78 void pcm_play_dma_unlock(void);
79 void pcm_play_dma_init(void) INIT_ATTR;
80 void pcm_play_dma_postinit(void);
81 void pcm_play_dma_start(const void *addr, size_t size);
82 void pcm_play_dma_stop(void);
83 void pcm_play_dma_pause(bool pause);
84 const void * pcm_play_dma_get_peak_buffer(int *count);
86 void pcm_dma_apply_settings(void);
88 #ifdef HAVE_RECORDING
90 /* DMA transfer in is currently active */
91 extern volatile bool pcm_recording;
93 /* APIs implemented in the target-specific portion */
94 void pcm_rec_dma_init(void);
95 void pcm_rec_dma_close(void);
96 void pcm_rec_dma_start(void *addr, size_t size);
97 void pcm_rec_dma_stop(void);
98 const void * pcm_rec_dma_get_peak_buffer(void);
100 static FORCE_INLINE enum pcm_dma_status
101 pcm_rec_dma_status_callback(enum pcm_dma_status status)
103 extern enum pcm_dma_status
104 (* volatile pcm_rec_status_callback)(enum pcm_dma_status);
105 return pcm_call_status_cb(pcm_rec_status_callback, status);
109 /* Called by the bottom layer ISR when more data is needed. Returns true
110 * if a new buffer is available, false otherwise. */
111 bool pcm_rec_dma_complete_callback(enum pcm_dma_status status,
112 void **addr, size_t *size);
114 #ifdef HAVE_PCM_REC_DMA_ADDRESS
115 #define pcm_rec_dma_addr(addr) pcm_dma_addr(addr)
116 #else
117 #define pcm_rec_dma_addr(addr) addr
118 #endif
120 #endif /* HAVE_RECORDING */
122 #endif /* PCM_INTERNAL_H */