Repository navigation
Description
Summary
The ESP32-S3 LCD_CAM I80 bus driver needs ISR-driven chunked DMA streaming for both SPI chipsets (APA102, SK9822) and clockless protocols (WS2812, SK6812). This driver replaces the legacy "I2S" driver on ESP32-S3 (the ESP32-S3 has no I2S LED peripheral -- the existing I2S driver is a misnomer that actually wraps LCD_CAM). The "I2S" name is only retained for the original ESP32dev which has a real I2S peripheral.
Current State
SPI path -- working (Phase 1 partial)
ChannelDriverLcdSpirefactored for ISR-driven chunked DMA with 3-buffer ringisrChunkDone()transposes next chunk and submits on DMA completion- Mock's
simulateTransmitComplete()drains full callback chain - All 296 tests pass (ASAN/LSAN/UBSAN clean, lint clean)
- 10 new chunked streaming test cases added
What needs fixing in SPI path
- Chunk size too large:
kDefaultChunkInputBytes = 2048(32KB per ring slot). Should cap at ~100 LEDs = ~400 source bytes = ~6.4KB per ring slot. - No wave8 usage: Uses naive
transposeToWords()bit loop instead of optimized wave8 LUT transposition.
Clockless path -- not yet started
The existing "I2S" driver (src/platforms/esp/32/drivers/i2s/) is the LCD_CAM clockless driver misnamed as I2S. It will be replaced by a new clockless path in the LCD driver with ISR-driven chunked DMA.
Architecture
The "I2S" naming confusion
On ESP32dev (original): There is a real I2S peripheral used for LED driving. The I2S driver name is correct.
On ESP32-S3: There is no I2S LED peripheral. The existing "I2S" driver (ChannelEngineI2S) actually wraps the LCD_CAM I80 bus via esp_lcd_panel_io. This is a misnomer. The new LCD driver replaces it with a properly named implementation.
| Platform | Real peripheral | Current driver name | New driver |
|---|---|---|---|
| ESP32dev | I2S | ChannelEngineI2S (correct) |
Keep as-is |
| ESP32-S3 | LCD_CAM I80 | ChannelEngineI2S (misnomer) |
Replace with LCD driver |
Two drivers sharing infrastructure (Option B)
Separate ChannelDriverLcdSpi and ChannelDriverLcdClockless that share:
- Unified peripheral interface (merging the nearly-identical
ILcdSpiPeripheralandII2sLcdCamPeripheral) - Ring buffer + ISR context types
- ISR callback chain mechanism
- Separate encoding paths
The encoding paths are fundamentally different:
| SPI (APA102) | Clockless wave3 | Clockless wave8 | |
|---|---|---|---|
| Source byte | 1 byte | 1 byte | 1 byte |
| Output per byte | 8 u16 words (16 bytes) | 24 u16 words (48 bytes) | 64 u16 words (128 bytes) |
| Expansion ratio | 16x | 48x | 128x |
| 100 LEDs DMA/slot | ~6.4KB | ~14KB | ~38KB |
| 3-ring total | ~19KB | ~43KB | ~115KB |
Chunk Sizing
Cap at 100 LEDs worth of pre-computed data per ring buffer slot:
| Protocol | Bytes/LED | Source bytes (100 LEDs) | DMA bytes/slot | 3-ring total |
|---|---|---|---|---|
| SPI (APA102) | 4 | 408 | ~6.5KB | ~19KB |
| Clockless wave3 | 3 | 300 | ~14KB | ~43KB |
| Clockless wave8 | 3 | 300 | ~38KB | ~115KB |
wave8 vs wave3 for clockless
| wave3 (current LCD_CAM approach) | wave8 | |
|---|---|---|
| Memory per LED | 72 bytes (3B x 24) | 192 bytes (3B x 64) |
| Timing precision | 3 levels per bit | 8 levels per bit |
| PCLK for WS2812 | ~2.4 MHz | ~6.4 MHz |
| ISR transpose time | Faster (less data) | Slower (more data) |
| Compatibility | Proven in current LCD_CAM driver | Proven in SPI/PARLIO |
Recommendation: Support both. wave3 as default (memory efficient), wave8 as opt-in for timing-sensitive applications.
Next Steps
Immediate (SPI path fixes)
- Reduce
kDefaultChunkInputBytesto cap at ~100 LEDs (~400 bytes for APA102) - Replace naive
transposeToWords()with wave8-style LUT transposition
Design phase (clockless path)
- Unify peripheral interfaces (
ILcdSpiPeripheral+II2sLcdCamPeripheral-> shared interface) - Define clockless encoding API (wave3 default, wave8 opt-in)
- Plan channel_manager_esp32 priority changes (new LCD clockless replaces misnamed I2S on S3)
Implementation (clockless path)
- Implement
ChannelDriverLcdClocklesswith ISR-driven chunked DMA - Use wave3/wave8 encoding in ISR callback
- Mock + unit tests (Phase 1)
- Comprehensive sweep tests (Phase 2)
Hardware validation (Phase 3)
- trans_queue_depth research on ESP32-S3 LCD_CAM I80 bus
- AutoResearch validation with bridged I/O ESP32-S3
- SPI path:
bash autoresearch --i2s --lanes 1-4 --strip-sizes tiny,small,medium,large - Clockless path: similar sweep
Open Research
trans_queue_depth > 1 on ESP32-S3 LCD_CAM
- Test depth=2 and depth=3 with chained
esp_lcd_panel_io_tx_color()calls - Check for FSM limitations similar to PARLIO on ESP32-C6
- If depth > 1 works: zero-gap streaming via hardware queuing
- If depth = 1 only: measure inter-chunk gap, implement software ring restart
ESP peripheral ISR safety
Current transmit() uses FreeRTOS semaphore (not ISR-safe). For ISR-driven chunking on real hardware, need a lightweight non-blocking submit path.
Related
- PARLIO driver (ISR streaming reference):
src/platforms/esp/32/drivers/parlio/ - Legacy "I2S" driver (LCD_CAM misnomer, being replaced on S3):
src/platforms/esp/32/drivers/i2s/ - SPI clockless driver (wave8, ESP32dev only):
src/platforms/esp/32/drivers/spi/ - LCD RGB driver (ESP32-P4 only):
src/platforms/esp/32/drivers/lcd_cam/ - Wave8 infrastructure:
src/fl/channels/wave8.h,detail/wave8.hpp - ESP32-S3: I2S driver starves websockets, SPI output incorrect, Audio driver FPS impact #2254 -- ESP32-S3 driver issues
- Inefficient SPI Data Transmission for APA102 / SK9822 LEDs on ESP32 #1609 -- Inefficient SPI data transmission
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTriage
Activity
feat(esp32-s3): ISR-driven chunked DMA for LCD_CAM SPI and clockless …
feat(esp32-s3): ISR-driven chunked DMA for LCD_CAM SPI and clockless …
zackees commentedon Apr 17, 2026
will fix #1961