1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2005 by Linus Nielsen Feltzing
12 * 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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
21 #ifndef PCM_PLAYBACK_H
22 #define PCM_PLAYBACK_H
24 #include <string.h> /* size_t */
27 #define DMA_REC_ERROR_DMA (-1)
29 #define DMA_REC_ERROR_SPDIF (-2)
32 /** RAW PCM routines used with playback and recording **/
34 /* Typedef for registered callbacks */
35 typedef void (*pcm_play_callback_type
)(unsigned char **start
,
37 typedef void (*pcm_rec_callback_type
)(int status
, void **start
, size_t *size
);
39 /* set the pcm frequency - use values in hw_sampr_list
40 * when CONFIG_SAMPR_TYPES is #defined, or-in SAMPR_TYPE_* fields with
41 * frequency value. SAMPR_TYPE_PLAY is 0 and the default if none is
43 #ifdef CONFIG_SAMPR_TYPES
45 unsigned int pcm_sampr_type_rec_to_play(unsigned int samplerate
);
47 #endif /* CONFIG_SAMPR_TYPES */
49 void pcm_set_frequency(unsigned int samplerate
);
50 /* apply settings to hardware immediately */
51 void pcm_apply_settings(void);
53 /** RAW PCM playback routines **/
55 /* Reenterable locks for locking and unlocking the playback interrupt */
56 void pcm_play_lock(void);
57 void pcm_play_unlock(void);
59 void pcm_init(void) INIT_ATTR
;
60 void pcm_postinit(void);
61 bool pcm_is_initialized(void);
63 /* This is for playing "raw" PCM data */
64 void pcm_play_data(pcm_play_callback_type get_more
,
65 unsigned char* start
, size_t size
);
67 void pcm_calculate_peaks(int *left
, int *right
);
68 const void* pcm_get_peak_buffer(int* count
);
69 size_t pcm_get_bytes_waiting(void);
71 void pcm_play_stop(void);
72 void pcm_play_pause(bool play
);
73 bool pcm_is_paused(void);
74 bool pcm_is_playing(void);
76 void pcm_play_set_dma_started_callback(void (* callback
)(void));
80 /** RAW PCM recording routines **/
82 /* Reenterable locks for locking and unlocking the recording interrupt */
83 void pcm_rec_lock(void);
84 void pcm_rec_unlock(void);
86 /* Initialize pcm recording interface */
87 void pcm_init_recording(void);
88 /* Uninitialize pcm recording interface */
89 void pcm_close_recording(void);
91 /* Start recording "raw" PCM data */
92 void pcm_record_data(pcm_rec_callback_type more_ready
,
93 void *start
, size_t size
);
95 /* Stop tranferring data into supplied buffer */
96 void pcm_stop_recording(void);
98 /* Is pcm currently recording? */
99 bool pcm_is_recording(void);
101 /* Called by bottom layer ISR when transfer is complete. Returns non-zero
102 * size if successful. Setting start to NULL forces stop. */
103 void pcm_rec_more_ready_callback(int status
, void **start
, size_t *size
);
105 void pcm_calculate_rec_peaks(int *left
, int *right
);
107 #endif /* HAVE_RECORDING */
109 #endif /* PCM_PLAYBACK_H */