summaryrefslogtreecommitdiff
path: root/src/drivers/include
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-09-26 17:23:34 +1000
committerjacqueline <me@jacqueline.id.au>2023-09-26 17:23:34 +1000
commit8608f9367fc29e498f42f5249aa248dd2044d567 (patch)
treec8564bfe6bbc6c5a9413bbd29b4e52f2cf3bd35c /src/drivers/include
parent4d99d22e10a3cb2a421da1618c127128816613c9 (diff)
downloadtangara-fw-8608f9367fc29e498f42f5249aa248dd2044d567.tar.gz
Tune buffer sizes and locations for I2S
Diffstat (limited to 'src/drivers/include')
-rw-r--r--src/drivers/include/i2s_dac.hpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/drivers/include/i2s_dac.hpp b/src/drivers/include/i2s_dac.hpp
index 6bc5b6a4..b61f7989 100644
--- a/src/drivers/include/i2s_dac.hpp
+++ b/src/drivers/include/i2s_dac.hpp
@@ -18,7 +18,6 @@
#include "esp_err.h"
#include "freertos/FreeRTOS.h"
#include "freertos/portmacro.h"
-#include "freertos/ringbuf.h"
#include "freertos/stream_buffer.h"
#include "result.hpp"
#include "span.hpp"
@@ -28,6 +27,13 @@
namespace drivers {
+// DMA max buffer size for I2S is 4092. We normalise to 2-channel, 16 bit
+// audio, which gives us a max of 4092 / 2 / 2 (16 bits) frames. This in turn
+// means that at 48kHz, we have about 21ms of budget to fill each buffer.
+// We base this off of the maximum DMA size in order to minimise the amount of
+// work the CPU has to do to service the DMA callbacks.
+constexpr size_t kI2SBufferLengthFrames = 1023;
+
/**
* Interface for a DAC that receives PCM samples over I2S.
*/