Skip to content

I2S classic-ESP32 unified path: Phases 2, 4-8 (follow-up to #3509) #3512

Closed

Description

@zackees

Goal

Follow-up to #3509 Phase 3 (merged as #3511 — IDF 6 enable via i2s_ll_* compat shim). Consolidates the remaining architectural work from #3509 into one issue so the two paths for the classic-ESP32 I2S peripheral collapse into a single production surface with WROOM bench validation.

Scope

Phase 2 — Move DMA + ISR machinery into modern peripheral impl

Rewrite I2sPeripheralEsp32DevEsp::transmit() from a synchronous-callback stub into a real DMA descriptor chain kick + esp_intr_alloc ISR handler. Reference: i2s_esp32dev.cpp.hpp:444-491 for the working register sequence, interruptHandler() for the ISR pattern.

Key architectural question the refactor must resolve: streaming refill callback vs. done-only callback. The classic driver's ISR fires per-buffer during transmit and calls ClocklessI2S::fillBuffer() to encode the next 8-pixel row into the just-emptied DMA buffer. The modern peripheral interface (ii2s_peripheral_esp32dev.h) documents registerTransmitCallback as a done-only ISR hook. Options:

  1. Extend the peripheral interface to support a streaming callback (breaks the mock semantics — 66 host tests would need updating).
  2. Have the peripheral own the ping-pong buffer internally and only fire the completion callback when the whole stream drains (requires the whole encoded stream to fit in one continuous buffer — not viable for 24-strip parallel).
  3. Split the surface: registerTransmitCallback stays for done, add registerBufferRefillCallback for streaming. Both concrete impls (real + mock) implement both hooks.

Recommend option 3 — preserves existing tests, cleanly extends the interface, matches how ObjectFLED's LPUART path handles the same problem.

Phase 4 — Wire ClocklessI2S<> template through the peripheral interface

Legacy addLeds<WS2812, PIN, GRB>() currently instantiates ClocklessI2S<> which pokes Path A globals directly. Rewrite so ClocklessI2S::init() obtains a fl::Singleton<I2sPeripheralEsp32DevEsp>::instance() and uses the peripheral interface for initialize/allocateBuffer/transmit/waitTransmitDone. Result: one hardware access surface, two user-facing entry points.

Ping-pong buffer refill in the ISR lives in the peripheral impl (unchanged behavior), but the fillBuffer callback goes through registerBufferRefillCallback() (new — see Phase 2 option 3) instead of a raw file-scope function-pointer global.

Phase 5 — Re-include modern peripheral impl in unity build

Once Phase 2 lands and the real DMA/ISR machinery is in I2sPeripheralEsp32DevEsp, remove the UNITY_BUILD_EXCLUDE(...) marker from i2s_peripheral_esp32dev_esp.cpp.hpp and add the include to _build.cpp.hpp. The ADC: CONFLICT! collision documented in Phase 1 was specifically about driver/i2s.h in the Stage 2 (#3476) impl, NOT driver/gpio.h in the current Stage 4 file — the exclude is over-conservative and can lift.

Phase 6 — Global state → Singleton migration

Once the peripheral owns the DMA state, the 10+ file-scope globals in i2s_esp32dev.cpp.hpp become peripheral-instance state. Migrating storage into Singleton<I2sPeripheralEsp32DevEsp>::instance() handles storage-elision naturally per FastLED's convention. Removes the FL_LINT_ALLOW_GLOBAL_FILE(...) marker. Closes #3489.

Phase 7 — WROOM autoresearch loopback

Phase 8 — README

src/platforms/esp/32/drivers/i2s/README.md documenting the unified path, the peripheral interface, the LL-API version-gate (in i2s_periph_compat.h), and the loopback test.

Acceptance criteria

  • I2sPeripheralEsp32DevEsp::transmit() does real DMA+ISR — no more synchronous-callback stub (Phase 2)
  • ClocklessI2S<> uses the peripheral interface — no direct globals (Phase 4)
  • i2s_peripheral_esp32dev_esp.cpp.hpp back in unity build, no UNITY_BUILD_EXCLUDE marker (Phase 5)
  • i2s_esp32dev.cpp.hpp has no file-scope statics — closes singleton: migrate i2s_esp32dev driver state — 19 hits, ISR pattern (Tier 2a) #3489, removes FL_LINT_ALLOW_GLOBAL_FILE marker (Phase 6)
  • bash autoresearch --i2s decodes a 4+ strip WS2812B loopback on WROOM against IDF 4.x and 5.x (Phase 7)
  • Modern FastLED.add<Channel::create<Bus::FLEX_IO, 0>()> path also drives real WS2812 output (proves both entry points hit the same peripheral)
  • bash test --cpp — all host tests green
  • README updated (Phase 8)

Reference material

Blockers

Activity

  1. added
    type: feature
    priority: medium
    platform: esp32
    area: drivers
    on Jul 1, 2026
  2. zackees commented on Jul 1, 2026

    @zackees
    MemberAuthor

    Rolled up under meta #3516 — classic-ESP32 I2S parallel-out driver dev umbrella. See the meta for landing order (this issue's Phase 2 runs AFTER #3515 Phases A-D confirm the current Yves driver works on all three IDF versions).

  3. zackees commented on Jul 1, 2026

    @zackees
    MemberAuthor

    Closed by #3526 series — architectural approach superseded

    This issue planned to unify the two coexisting I2S paths (Yves ClocklessI2S<> + modern channel-manager) by moving Yves's DMA/ISR machinery INTO the modern peripheral impl, then rewiring ClocklessI2S<> to consume the modern interface.

    That plan was explicitly rejected during a user architectural review that led to #3526. Rationale: Yves's per-chipset bit-pattern encoder (i2s_define_bit_patterns + variable pulses per bit) is fundamentally different from the wave8/wave3 general-clockless pattern PARLIO established — the two shouldn't share machinery.

    #3526 was filed to build the modern I2S engine as a fresh implementation in the shape of PARLIO (fixed pixel clock, per-channel wave8 byte-LUT). All the acceptance criteria of this issue were addressed there, via a different route:

    This issue's Phase #3526 equivalent Status
    Phase 2 (move DMA/ISR into peripheral) Phase 2b step A + B + C — direct register writes, lldesc_t + esp_intr_alloc() ISR + routeLanePin ✅ Merged (#3556, #3557, #3558)
    Phase 4 (rewire ClocklessI2S<> through peripheral) Phase 2d slot swap — BusTraits<Bus::FLEX_IO, 0> → modern engine; ClocklessI2S<> DELETED entirely at Phase 2e ✅ Merged (#3559 + #3564)
    Phase 5 (unity build re-include) Included in Phase 2e's _build.cpp.hpp cleanup ✅ Merged (#3564)
    Phase 6 (singleton migration) Phase 2e — I2sPeripheralEsp32DevEsp is fl::Singleton<>; Yves globals deleted with the files. Closes #3489. ✅ Merged (#3564)
    Phase 8 (README) README rewritten for the modern architecture with Yves attribution ✅ Merged (#3565)

    Phase 4's original goal was to keep ClocklessI2S<> working. #3526 chose the harder path: delete the Yves files and force users to migrate to the modern API. The -DFASTLED_ESP32_I2S=1 opt-in is gone; users get the modern engine via FastLED.setExclusiveDriver<fl::Bus::FLEX_IO, 0>().

    Every line of Yves code that this issue depended on (i2s_esp32dev.{h,cpp.hpp}, clockless_i2s_esp32.{h,cpp.hpp}, ~1287 LOC total) was deleted at Phase 2e (2026-07-01) with proper Yves Bazin attribution preserved in the modern engine's docstrings. Bench verified boots + RPC after every merge.

    Remaining scope not addressed by #3526 (tracked separately):

  4. moved this from Triage to Done in FastLED Trackeron Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: driversplatform: esp32priority: mediumtype: feature

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions