summaryrefslogtreecommitdiff
path: root/firmware/export/pcm-internal.h
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/export/pcm-internal.h')
-rw-r--r--firmware/export/pcm-internal.h54
1 files changed, 52 insertions, 2 deletions
diff --git a/firmware/export/pcm-internal.h b/firmware/export/pcm-internal.h
index 397cf6832f..03e5c5e6e7 100644
--- a/firmware/export/pcm-internal.h
+++ b/firmware/export/pcm-internal.h
@@ -24,6 +24,19 @@
24 24
25#include "config.h" 25#include "config.h"
26 26
27#ifdef HAVE_SW_VOLUME_CONTROL
28/* Default settings - architecture may have other optimal values */
29
30#define PCM_FACTOR_BITS 15 /* Allows -73 to +6dB gain, sans 64-bit math */
31#define PCM_PLAY_DBL_BUF_SAMPLES 1024 /* Max 4KByte chunks */
32#define PCM_DBL_BUF_BSS /* In DRAM, uncached may be better */
33#define PCM_FACTOR_MIN 0x00000 /* Minimum final factor */
34#define PCM_FACTOR_MAX 0x10000 /* Maximum final factor */
35
36#define PCM_FACTOR_UNITY (1 << PCM_FACTOR_BITS)
37#endif /* HAVE_SW_VOLUME_CONTROL */
38
39#define PCM_SAMPLE_SIZE (2 * sizeof (int16_t))
27/* Cheapo buffer align macro to align to the 16-16 PCM size */ 40/* Cheapo buffer align macro to align to the 16-16 PCM size */
28#define ALIGN_AUDIOBUF(start, size) \ 41#define ALIGN_AUDIOBUF(start, size) \
29 ({ (start) = (void *)(((uintptr_t)(start) + 3) & ~3); \ 42 ({ (start) = (void *)(((uintptr_t)(start) + 3) & ~3); \
@@ -34,6 +47,23 @@ void pcm_do_peak_calculation(struct pcm_peaks *peaks, bool active,
34 47
35/** The following are for internal use between pcm.c and target- 48/** The following are for internal use between pcm.c and target-
36 specific portion **/ 49 specific portion **/
50/* Call registered callback to obtain next buffer */
51static inline bool pcm_get_more_int(const void **addr, size_t *size)
52{
53 extern volatile pcm_play_callback_type pcm_callback_for_more;
54 pcm_play_callback_type get_more = pcm_callback_for_more;
55
56 if (UNLIKELY(!get_more))
57 return false;
58
59 *addr = NULL;
60 *size = 0;
61 get_more(addr, size);
62 ALIGN_AUDIOBUF(*addr, *size);
63
64 return *addr && *size;
65}
66
37static FORCE_INLINE enum pcm_dma_status pcm_call_status_cb( 67static FORCE_INLINE enum pcm_dma_status pcm_call_status_cb(
38 pcm_status_callback_type callback, enum pcm_dma_status status) 68 pcm_status_callback_type callback, enum pcm_dma_status status)
39{ 69{
@@ -43,14 +73,34 @@ static FORCE_INLINE enum pcm_dma_status pcm_call_status_cb(
43 return callback(status); 73 return callback(status);
44} 74}
45 75
46static FORCE_INLINE enum pcm_dma_status 76static FORCE_INLINE enum pcm_dma_status pcm_play_call_status_cb(
47pcm_play_dma_status_callback(enum pcm_dma_status status) 77 enum pcm_dma_status status)
48{ 78{
49 extern enum pcm_dma_status 79 extern enum pcm_dma_status
50 (* volatile pcm_play_status_callback)(enum pcm_dma_status); 80 (* volatile pcm_play_status_callback)(enum pcm_dma_status);
51 return pcm_call_status_cb(pcm_play_status_callback, status); 81 return pcm_call_status_cb(pcm_play_status_callback, status);
52} 82}
53 83
84static FORCE_INLINE enum pcm_dma_status
85pcm_play_dma_status_callback(enum pcm_dma_status status)
86{
87#ifdef HAVE_SW_VOLUME_CONTROL
88 extern enum pcm_dma_status
89 pcm_play_dma_status_callback_int(enum pcm_dma_status status);
90 return pcm_play_dma_status_callback_int(status);
91#else
92 return pcm_play_call_status_cb(status);
93#endif /* HAVE_SW_VOLUME_CONTROL */
94}
95
96#ifdef HAVE_SW_VOLUME_CONTROL
97void pcm_play_dma_start_int(const void *addr, size_t size);
98void pcm_play_dma_pause_int(bool pause);
99void pcm_play_dma_stop_int(void);
100void pcm_play_stop_int(void);
101const void *pcm_play_dma_get_peak_buffer_int(int *count);
102#endif /* HAVE_SW_VOLUME_CONTROL */
103
54/* Called by the bottom layer ISR when more data is needed. Returns true 104/* Called by the bottom layer ISR when more data is needed. Returns true
55 * if a new buffer is available, false otherwise. */ 105 * if a new buffer is available, false otherwise. */
56bool pcm_play_dma_complete_callback(enum pcm_dma_status status, 106bool pcm_play_dma_complete_callback(enum pcm_dma_status status,