src.nth.io/

summaryrefslogtreecommitdiff
path: root/main/display.h
diff options
context:
space:
mode:
authorLuke Hoersten <[email protected]>2026-06-15 07:50:23 -0500
committerLuke Hoersten <[email protected]>2026-06-15 07:50:23 -0500
commit3f53ced44ea112a39eec70216c8c72fa6867726e (patch)
tree785c527e1f9215d98725ed94992e9e700ed3c5c3 /main/display.h
parentb3217b9dbb731ec69cd1ebde201aa2178143d961 (diff)
firmware: double-buffer the panel + zero-copy decode → ~22 fps ceiling
Per-frame paint cost drops from ~24 ms to ~45 µs (≈500× faster) by enabling num_fbs=2 on the DPI panel and decoding straight into the back framebuffer. Measured on the bench: before: lock=7us ttfb=370us body=40ms dec=6ms paint=24ms post=35us = ~70ms / ~14fps after : lock=7us ttfb=330us body=38ms dec=6ms paint=42us post=25us = ~45ms / ~22fps How the win actually lands: - num_fbs=2 in the esp_lcd_dpi_panel_config_t makes the IDF driver allocate two framebuffers and stream from one while we fill the other. - display_back_buffer() returns the inactive fb pointer + its size. - jpeg_decoder_decode() now accepts a caller-provided destination buffer instead of owning its own scratch. http_api passes the panel back-fb so the hardware JPEG decoder writes BGR888 pixels straight into where the DSI will eventually scan from. Zero memcpy in the hot path. - display_flip_back_buffer() calls esp_lcd_panel_draw_bitmap with the fb pointer. Because the buffer is inside the panel's own fb range, the IDF driver skips its memcpy and just does a cache writeback + swaps cur_fb_index. The actual flip happens on the next vsync, asynchronously — the call returns in microseconds. The remaining ceiling is network body time (~38 ms for ~210 KB JPEGs) and the hardware decoder (~6 ms). Per-viewport JPEG quality (smaller files = shorter body) is the next lever; everything firmware-side is already at or near floor. Also drop the old static jpeg output scratch + JPEG_DECODER_MAX_OUTPUT_BYTES constant — nothing references them anymore.
Diffstat (limited to 'main/display.h')
-rw-r--r--main/display.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/main/display.h b/main/display.h
index 5f939b9..0ecff4d 100644
--- a/main/display.h
+++ b/main/display.h
@@ -43,4 +43,18 @@ esp_err_t display_present_rgb565(const uint16_t *src,
// hand it straight to esp_lcd_panel_draw_bitmap. No CPU pixel work, no
// format conversion, no rotation — Scrypted is responsible for sending
// the buffer pre-rotated and pre-scaled to panel-native dimensions.
+// If the buffer happens to be one of the panel's own framebuffers
+// (see display_back_buffer / display_flip_back_buffer below), the IDF
+// driver skips the memcpy entirely; otherwise it copies via CPU.
esp_err_t display_present_bgr888(const void *bgr888);
+
+// Double-buffer accessors for the zero-memcpy /frame path. The DPI
+// panel owns two BGR888 framebuffers; `display_back_buffer` hands back
+// the one that is NOT currently being streamed by the DSI engine so
+// callers (the JPEG decoder) can fill it in place. When the buffer is
+// ready, `display_flip_back_buffer` swaps it in — turns into a cache
+// writeback + index swap inside the IDF driver (no memcpy).
+// `out_size` (if non-null) is set to the buffer's byte size, useful
+// for passing to jpeg_decoder_process as its output capacity.
+void *display_back_buffer(size_t *out_size);
+esp_err_t display_flip_back_buffer(void);