summaryrefslogtreecommitdiffstats
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 @@
#include "config.h"
+#ifdef HAVE_SW_VOLUME_CONTROL
+/* Default settings - architecture may have other optimal values */
+
+#define PCM_FACTOR_BITS 15 /* Allows -73 to +6dB gain, sans 64-bit math */
+#define PCM_PLAY_DBL_BUF_SAMPLES 1024 /* Max 4KByte chunks */
+#define PCM_DBL_BUF_BSS /* In DRAM, uncached may be better */
+#define PCM_FACTOR_MIN 0x00000 /* Minimum final factor */
+#define PCM_FACTOR_MAX 0x10000 /* Maximum final factor */
+
+#define PCM_FACTOR_UNITY (1 << PCM_FACTOR_BITS)
+#endif /* HAVE_SW_VOLUME_CONTROL */
+
+#define PCM_SAMPLE_SIZE (2 * sizeof (int16_t))
/* Cheapo buffer align macro to align to the 16-16 PCM size */
#define ALIGN_AUDIOBUF(start, size) \
({ (start) = (void *)(((uintptr_t)(start) + 3) & ~3); \
@@ -34,6 +47,23 @@ void pcm_do_peak_calculation(struct pcm_peaks *peaks, bool active,
/** The following are for internal use between pcm.c and target-
specific portion **/
+/* Call registered callback to obtain next buffer */
+static inline bool pcm_get_more_int(const void **addr, size_t *size)
+{
+ extern volatile pcm_play_callback_type pcm_callback_for_more;
+ pcm_play_callback_type get_more = pcm_callback_for_more;
+
+ if (UNLIKELY(!get_more))
+ return false;
+
+ *addr = NULL;
+ *size = 0;
+ get_more(addr, size);
+ ALIGN_AUDIOBUF(*addr, *size);
+
+ return *addr && *size;
+}
+
static FORCE_INLINE enum pcm_dma_status pcm_call_status_cb(
pcm_status_callback_type callback, enum pcm_dma_status status)
{
@@ -43,14 +73,34 @@ static FORCE_INLINE enum pcm_dma_status pcm_call_status_cb(
return callback(status);
}
-static FORCE_INLINE enum pcm_dma_status
-pcm_play_dma_status_callback(enum pcm_dma_status status)
+static FORCE_INLINE enum pcm_dma_status pcm_play_call_status_cb(
+ enum pcm_dma_status status)
{
extern enum pcm_dma_status
(* volatile pcm_play_status_callback)(enum pcm_dma_status);
return pcm_call_status_cb(pcm_play_status_callback, status);
}
+static FORCE_INLINE enum pcm_dma_status
+pcm_play_dma_status_callback(enum pcm_dma_status status)
+{
+#ifdef HAVE_SW_VOLUME_CONTROL
+ extern enum pcm_dma_status
+ pcm_play_dma_status_callback_int(enum pcm_dma_status status);
+ return pcm_play_dma_status_callback_int(status);
+#else
+ return pcm_play_call_status_cb(status);
+#endif /* HAVE_SW_VOLUME_CONTROL */
+}
+
+#ifdef HAVE_SW_VOLUME_CONTROL
+void pcm_play_dma_start_int(const void *addr, size_t size);
+void pcm_play_dma_pause_int(bool pause);
+void pcm_play_dma_stop_int(void);
+void pcm_play_stop_int(void);
+const void *pcm_play_dma_get_peak_buffer_int(int *count);
+#endif /* HAVE_SW_VOLUME_CONTROL */
+
/* Called by the bottom layer ISR when more data is needed. Returns true
* if a new buffer is available, false otherwise. */
bool pcm_play_dma_complete_callback(enum pcm_dma_status status,