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