atjboottool: add missing copyright headers
[maemo-rb.git] / firmware / export / pcm.h
blobfdd46237a66727ceb1fcfac162a1d0f95abc9398
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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 */
25 #include <inttypes.h> /* uint32_t */
26 #include "config.h"
28 enum pcm_dma_status
30 #ifdef HAVE_SPDIF_REC
31 PCM_DMAST_ERR_SPDIF = -2,
32 #endif
33 PCM_DMAST_ERR_DMA = -1,
34 PCM_DMAST_OK = 0,
35 PCM_DMAST_STARTED = 1,
38 /** RAW PCM routines used with playback and recording **/
40 /* Typedef for registered data callback */
41 typedef void (*pcm_play_callback_type)(const void **start, size_t *size);
43 /* Typedef for registered status callback */
44 typedef enum pcm_dma_status (*pcm_status_callback_type)(enum pcm_dma_status status);
46 /* set the pcm frequency - use values in hw_sampr_list
47 * when CONFIG_SAMPR_TYPES is #defined, or-in SAMPR_TYPE_* fields with
48 * frequency value. SAMPR_TYPE_PLAY is 0 and the default if none is
49 * specified. */
50 #ifdef CONFIG_SAMPR_TYPES
51 #ifdef SAMPR_TYPE_REC
52 unsigned int pcm_sampr_type_rec_to_play(unsigned int samplerate);
53 #endif
54 #endif /* CONFIG_SAMPR_TYPES */
56 void pcm_set_frequency(unsigned int samplerate);
57 /* apply settings to hardware immediately */
58 void pcm_apply_settings(void);
60 /** RAW PCM playback routines **/
62 /* Reenterable locks for locking and unlocking the playback interrupt */
63 void pcm_play_lock(void);
64 void pcm_play_unlock(void);
66 void pcm_init(void) INIT_ATTR;
67 void pcm_postinit(void);
68 bool pcm_is_initialized(void);
70 /* This is for playing "raw" PCM data */
71 void pcm_play_data(pcm_play_callback_type get_more,
72 pcm_status_callback_type status_cb,
73 const void *start, size_t size);
75 /* Kept internally for global PCM and used by mixer's verion of peak
76 calculation */
77 struct pcm_peaks
79 uint32_t left; /* Left peak value */
80 uint32_t right; /* Right peak value */
81 long period; /* For tracking calling period */
82 long tick; /* Last tick called */
85 void pcm_calculate_peaks(int *left, int *right);
86 const void* pcm_get_peak_buffer(int* count);
87 size_t pcm_get_bytes_waiting(void);
89 void pcm_play_stop(void);
90 void pcm_play_pause(bool play);
91 bool pcm_is_paused(void);
92 bool pcm_is_playing(void);
94 #ifdef HAVE_RECORDING
96 /** RAW PCM recording routines **/
98 /* Typedef for registered data callback */
99 typedef void (*pcm_rec_callback_type)(void **start, size_t *size);
101 /* Reenterable locks for locking and unlocking the recording interrupt */
102 void pcm_rec_lock(void);
103 void pcm_rec_unlock(void);
105 /* Initialize pcm recording interface */
106 void pcm_init_recording(void);
107 /* Uninitialize pcm recording interface */
108 void pcm_close_recording(void);
110 /* Start recording "raw" PCM data */
111 void pcm_record_data(pcm_rec_callback_type more_ready,
112 pcm_status_callback_type status_cb,
113 void *start, size_t size);
115 /* Stop tranferring data into supplied buffer */
116 void pcm_stop_recording(void);
118 /* Is pcm currently recording? */
119 bool pcm_is_recording(void);
121 void pcm_calculate_rec_peaks(int *left, int *right);
123 #endif /* HAVE_RECORDING */
125 #endif /* PCM_PLAYBACK_H */