summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-09-05 10:12:15 +1000
committerjacqueline <me@jacqueline.id.au>2023-09-05 10:12:15 +1000
commit02c1eb4be35559c127368d1419ebb79e9f23f3c3 (patch)
tree10be21d2cfbb9130644e00d70b4f573106932036 /src
parent0032896251d8ddc6c2775495445da8fceffba98e (diff)
downloadtangara-fw-02c1eb4be35559c127368d1419ebb79e9f23f3c3.tar.gz
Tweak display DMA buffer size
Diffstat (limited to 'src')
-rw-r--r--src/drivers/display.cpp7
-rw-r--r--src/drivers/spi.cpp6
2 files changed, 6 insertions, 7 deletions
diff --git a/src/drivers/display.cpp b/src/drivers/display.cpp
index 0664638b..7ab7b3e8 100644
--- a/src/drivers/display.cpp
+++ b/src/drivers/display.cpp
@@ -14,6 +14,7 @@
#include "assert.h"
#include "driver/gpio.h"
#include "driver/ledc.h"
+#include "driver/spi_common.h"
#include "driver/spi_master.h"
#include "esp_attr.h"
#include "esp_err.h"
@@ -47,16 +48,16 @@ static const gpio_num_t kDisplayCs = GPIO_NUM_22;
/*
* The size of each of our two display buffers. This is fundamentally a balance
* between performance and memory usage. LVGL docs recommend a buffer 1/10th the
- * size of the screen is the best tradeoff.
+ * size of the screen is the best tradeoff, but we instead just use the max DMA
+ * buffer size.
* We use two buffers so that one can be flushed to the screen at the same time
* as the other is being drawn.
*/
-static const int kDisplayBufferSize = (kDisplayWidth * kDisplayHeight) / 10;
+static const int kDisplayBufferSize = SPI_MAX_DMA_LEN;
// Allocate both buffers in static memory to ensure that they're in DRAM, with
// minimal fragmentation. We most cases we always need these buffers anyway, so
// it's not a memory hit we can avoid.
-// Note: 128 * 160 / 10 * 2 bpp * 2 buffers = 8 KiB
DMA_ATTR static lv_color_t sBuffer1[kDisplayBufferSize];
DMA_ATTR static lv_color_t sBuffer2[kDisplayBufferSize];
diff --git a/src/drivers/spi.cpp b/src/drivers/spi.cpp
index b31d1460..93bf9cde 100644
--- a/src/drivers/spi.cpp
+++ b/src/drivers/spi.cpp
@@ -35,12 +35,10 @@ esp_err_t init_spi(void) {
.data7_io_num = -1,
// Use the DMA default size. The display requires larger buffers, but it
- // manages its down use of DMA-capable memory.
- .max_transfer_sz = 128 * 16 * 2, // TODO: hmm
+ // manages its own use of DMA-capable memory.
+ .max_transfer_sz = 4096,
.flags = SPICOMMON_BUSFLAG_MASTER | SPICOMMON_BUSFLAG_IOMUX_PINS,
.intr_flags = ESP_INTR_FLAG_LOWMED | ESP_INTR_FLAG_IRAM,
- //.intr_flags = ESP_INTR_FLAG_LOWMED | ESP_INTR_FLAG_SHARED |
- // ESP_INTR_FLAG_IRAM,
};
if (esp_err_t err = spi_bus_initialize(kSpiHost, &config, SPI_DMA_CH_AUTO)) {