blob: 97a1939dbb571acdd950c88c5941aa9fd00d5e9f [file] [log] [blame]
Michael Sevakis6077e5b2007-10-06 22:27:27 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2005 by Linus Nielsen Feltzing
11 *
Daniel Stenberg2acc0ac2008-06-28 18:10:04 +000012 * 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.
Michael Sevakis6077e5b2007-10-06 22:27:27 +000016 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#ifndef PCM_PLAYBACK_H
22#define PCM_PLAYBACK_H
23
24#include <sys/types.h>
25
26/** RAW PCM routines used with playback and recording **/
27
28/* Typedef for registered callback */
29typedef void (*pcm_more_callback_type)(unsigned char **start,
30 size_t *size);
31typedef int (*pcm_more_callback_type2)(int status);
32
33/* set the pcm frequency - use values in hw_sampr_list
34 * use -1 for the default frequency
35 */
36void pcm_set_frequency(unsigned int frequency);
37/* apply settings to hardware immediately */
38void pcm_apply_settings(void);
39
40/** RAW PCM playback routines **/
41
42/* Reenterable locks for locking and unlocking the playback interrupt */
43void pcm_play_lock(void);
44void pcm_play_unlock(void);
45
46void pcm_init(void);
47void pcm_postinit(void);
48
49/* This is for playing "raw" PCM data */
50void pcm_play_data(pcm_more_callback_type get_more,
51 unsigned char* start, size_t size);
52
53void pcm_calculate_peaks(int *left, int *right);
54size_t pcm_get_bytes_waiting(void);
55
56void pcm_play_stop(void);
57void pcm_mute(bool mute);
58void pcm_play_pause(bool play);
59bool pcm_is_paused(void);
60bool pcm_is_playing(void);
61
62/** The following are for internal use between pcm.c and target-
63 specific portion **/
64
65extern unsigned long pcm_curr_sampr;
66
67/* the registered callback function to ask for more mp3 data */
68extern volatile pcm_more_callback_type pcm_callback_for_more;
69extern volatile bool pcm_playing;
70extern volatile bool pcm_paused;
71
72void pcm_play_dma_lock(void);
73void pcm_play_dma_unlock(void);
74void pcm_play_dma_init(void);
75void pcm_play_dma_start(const void *addr, size_t size);
76void pcm_play_dma_stop(void);
77void pcm_play_dma_pause(bool pause);
78void pcm_play_dma_stopped_callback(void);
79const void * pcm_play_dma_get_peak_buffer(int *count);
80
81#ifdef HAVE_RECORDING
82
83/** RAW PCM recording routines **/
84
85/* Reenterable locks for locking and unlocking the recording interrupt */
86void pcm_rec_lock(void);
87void pcm_rec_unlock(void);
88
89/* Initialize pcm recording interface */
90void pcm_init_recording(void);
91/* Uninitialze pcm recording interface */
92void pcm_close_recording(void);
93
94/* Start recording "raw" PCM data */
95void pcm_record_data(pcm_more_callback_type2 more_ready,
96 void *start, size_t size);
97
98/* Stop tranferring data into supplied buffer */
99void pcm_stop_recording(void);
100
101/* Continue transferring data in - call during interrupt handler */
102void pcm_record_more(void *start, size_t size);
103
104void pcm_calculate_rec_peaks(int *left, int *right);
105
106/** The following are for internal use between pcm.c and target-
107 specific portion **/
108extern volatile const void *pcm_rec_peak_addr;
109/* the registered callback function for when more data is available */
110extern volatile pcm_more_callback_type2 pcm_callback_more_ready;
111/* DMA transfer in is currently active */
112extern volatile bool pcm_recording;
113
114/* APIs implemented in the target-specific portion */
115void pcm_rec_dma_init(void);
116void pcm_rec_dma_close(void);
117void pcm_rec_dma_start(void *addr, size_t size);
118void pcm_rec_dma_stop(void);
119void pcm_rec_dma_stopped_callback(void);
120const void * pcm_rec_dma_get_peak_buffer(int *count);
121
122#endif /* HAVE_RECORDING */
123
124#endif /* PCM_PLAYBACK_H */