Skip to content

drm/apple: external DP/HDMI audio on firmware-27 classic-layout DCPs (Mac mini M2) - #3050

Draft
RyanTheTide wants to merge 4 commits into
mainfrom
m2mini/v27-classic-audio
Draft

RyanTheTide wants to merge 4 commits into
mainfrom
m2mini/v27-classic-audio

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 24, 2026 •

Copy link
Copy Markdown

Problem

On the Mac mini M2 (J473) with 27.2 firmware, external HDMI and DisplayPort audio did not work. Both DP audio cards existed, but the audio service never started, the ELD stayed empty, both jacks read off and PipeWire offered no HDMI output.

dcp_is_v27_external() matched every firmware-27 DCP that has DPTX ports. It is meant for the T6050 and firmware-27 T6041 DCPEXTs, whose audio service is the desktop one (compact EPIC on endpoint 0x2b). The T8112 DCPs on 27.2 advertise the classic layout instead. On them 0x2b only carries dcpdptx-hdcp-interface, and the audio service is dcpav-audio-interface-epic on endpoint 0x29, the same place macOS binds it on this machine (our own ioreg capture of the J473 on 27.2). The driver waited on 0x2b for a service that never comes.

With that fixed, a second problem showed up. The HDMI DCP's firmware stops and restarts its audio service while the display link is set up again at boot. A PCM open in that window failed, PipeWire's one probe of that card fell in it, and the HDMI output never got its HiFi profile.

Change

  • Take the desktop audio role only when the DCP's DPTX ports are on DPTX_ENDPOINT_V2 as set at probe, i.e. firmware 27's own layout. Every other firmware-27 DCP uses the classic audio service on AV_ENDPOINT with the firmware-27 command table. The value is read as set at probe, because the DP audio driver binds before the DCP starts and both sides must agree on the role. There is no new SoC, board or firmware check: the role follows the endpoint layout the driver already keeps.
  • When the sink's elements cannot be read, dcp_pcm_open() opens the PCM as for an unplugged sink instead of failing. Unplugged sinks already open this way for the same reason: userspace drops an output for good if the first open fails.

Testing

  • J473 boot with both commits (production Stage 2, default command line): both cards have HiFi active, [Out] HDMI1 available, jacks on and valid ELDs at boot, with no PipeWire restart. The firmware refused the sink-info reads at the moment WirePlumber probed the HDMI card, and the open fallback kept its profile. Enforcing, 0 AVC, 0 failed units.
  • J473 on the default command line and production Stage 2, with kernel integration/aurora 7946d189 + linux#2853 + linux#2868 + linux#2953 and the first commit as an appledrm module. Both DCPs announce DCPAVAudioInterface on endpoint 0x29 and start the audio service with plugged:1. Both HDMI/DP Jack controls read on. Both ELDs are valid: the Acer QG270 S3 (HDMI) and the MSI behind the USB-C converter each report LPCM, 2 channels, 32/44.1/48 kHz, 16/20/24 bit. PipeWire offered HiFi with an available HDMI port and a sink on the USB-C card. The HDMI card got HiFi only after a PipeWire restart, which the second commit addresses.
  • Host: tools/asahi/dcpaud-open-fallback-tests.py runs the real dcp_pcm_open() over five cases and kills two mutations. The Apple DCP host suite passes, including the EDID fixture, which inlines dcp_is_v27_external(). Apple DRM KUnit: 117 passed, 1 skipped. appledrm builds with W=1 against the fleet tree.
  • No audio was played. These are read-backs only.

Still to run

  • A protected playback row on each port (speakerguardd is not involved: these are the monitors' own speakers), to check the firmware-27 classic link data. macOS describes the stream by format here, as on T6050.
  • The ELD monitor name can still be empty right after boot, until the reconnect that follows the modeset (cosmetic).
  • A no-regression row on a 13.x/14.x HDMI Mac and on the J616s/Neo (desktop audio path, unchanged by this predicate).
Evidence and detail
  • macOS 27.2 on the J473 (our own ioreg capture, reference/adt/20261122-j473-272-display/ioreg-service.txt): endpoint node DCPEndpoint10 (0x29) carries dcpav-video-interface-epic and dcpav-audio-interface-epic, with an audio driver bound per monitor. 0x2b is dcpdptx-hdcp-interface only.
  • Linux before the fix: AFK[ep:2b]: unable to match compact service dispext*:dcpdptx-hdcp-interface, no ep:29 line, no starting audio service.
  • Linux after (row r15): AFK[ep:29]: new service DCPAVAudioInterface and av_service_connect: starting audio service, plugged:1 on both DCPs. On the HDMI DCP the service is announced again at about 15 s and 21 s, and one group 1 cmd 16 read returns 0xe00002d7 in between. That is the window the second commit covers.
  • Row r15c, same boot, with WirePlumber and PipeWire restarted after the service settled: both cards show HiFi available and [Out] HDMI1 available.
  • Evidence is on the lab store under traces/display/20261124-m2mini-display-full/r15 and r15c.

Assisted-by: LLM (Claude:Opus 5.5)

dcp_is_v27_external() was true for every firmware-27 DCP with DPTX
ports. It is meant for the T6050 and firmware-27 T6041 DCPEXTs, whose
ports are on DPTX_ENDPOINT_V2 and whose DP/HDMI audio service is the
desktop one, compact EPIC on endpoint 0x2b.

The T8112 DCPs (Mac mini M2) on 27.2 firmware advertise the classic
layout, ports on DPTX_ENDPOINT. On them 0x2b announces only
dcpdptx-hdcp-interface, and the audio service is the classic
dcpav-audio-interface-epic on AV_ENDPOINT (0x29), as macOS binds it on
the same machine. Taking the desktop role there waited on 0x2b for an
audio service that never comes: no audio service started, the ELD
stayed empty, and the HDMI and DP jacks stayed off.

Take the desktop role only where the DPTX ports are on
DPTX_ENDPOINT_V2 as set at probe, so that the DP audio driver, which
binds before the DCP starts, sees the same role as the DCP. Every other
firmware-27 DCP takes the classic audio service on AV_ENDPOINT with the
firmware-27 command table.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
PipeWire and PulseAudio probe a PCM once when its card appears and drop
the output for good if the open fails, which is why an unplugged sink
already opens with a fixed hardware description.

A plugged sink's open reads its elements and product attributes from the
DCP audio service. On the Mac mini M2 (27.2 firmware) the HDMI DCP's
firmware announces that service again while the display link is set up
again at boot, and stops and restarts it meanwhile; a read in that window
fails. The open failed with it, PipeWire's first probe of that card fell
in the window, and the HDMI output never got its HiFi profile, although
the ELD and jack came up a few seconds later. A restart of PipeWire after
that showed the profile and an available HDMI port on both cards.

Open as for an unplugged sink when the sink info cannot be read. The
stream then runs as an unplugged one does, until the next open.

tools/asahi/dcpaud-open-fallback-tests.py runs the real dcp_pcm_open()
over plugged, unplugged, restarting and refused sinks and a DMA failure,
and kills two mutations.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Author

Independent review at cf3d0b9b973e7e6c76b0dcd34ac4a61733a13711. I replayed the exact five-case PCM-open fixture successfully. The endpoint change accounts for the two J473 jack and ELD readbacks. Two questions still affect working output.

  • The same predicate also selects the link encoding and native lifecycle in av.c. With the corrected classic endpoint, J473 now takes the legacy dcp_audiosrv_prepare() and dcp_audiosrv_startlink() calls with the full cookie. The PR reports a format-based link on this firmware. Please show which link payload it accepts, and select that independently of endpoint layout if the classic service uses the format payload. A profile and valid ELD cover enumeration only.
  • The PCM fallback turns every remote failure into a successful open for the void stream. The fixture explicitly expects this for -EIO. A service restart can deserve the unplugged probe behavior, while a stable service that rejects the request leaves a profile present and the opened stream silent until close. Please distinguish service unavailability or a generation change from a persistent error and cover both in the fixture.

R15d on J473 can settle the profile-at-boot symptom. The classic 13.x/14.x and desktop-role regression rows are still needed after the final source change.

Assisted-by: LLM (Codex)

@RyanTheTide

Copy link
Copy Markdown
Author

J473 boot row with both commits (fc96d3c3 + cf3d0b9b as an appledrm module on integration/aurora 7946d189 + linux#2853 + linux#2868 + linux#2953, production Stage 2, default command line). Read-backs only, nothing was played:

  • At boot, with no PipeWire restart, both DP audio cards have the HiFi profile active, [Out] HDMI1 available and a sink each. Both HDMI/DP Jack controls read on, and both ELDs are valid.
  • The HDMI DCP's firmware refused the element and product-attribute reads (group 1 cmd 16, group 0 cmd 11, retcode 0xe00002d7) at the same second WirePlumber probed the card. That is the window the second commit covers, and this time the card kept its profile.
  • Enforcing, 0 AVC, 0 failed units. Production was restored afterwards.

Follow-up, cosmetic: in this boot the ELD monitor name was still empty when the snapshot was taken. The name arrives with the reconnect after the mode is set, and an earlier row showed QG270 S3 after that. Playback rows are still to run.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-PR §1–§6 review at cf3d0b9b973e7e6c76b0dcd34ac4a61733a13711 against integration/aurora (c67c44a5ca).

Blockers

  1. Merge conflict & missing exact-head CI

    • The PR is currently CONFLICTING with integration/aurora in tools/asahi/run-host-tests.py (where dpavserv-admission-tests.py landed in the same hunk), and cf3d0b9b97 has 0 check runs / 0 commit statuses. Rebase onto current integration/aurora (which also now carries #2853 and #2868) and get clean exact-head CI.
  2. Code correctness — dcp_pcm_open() fallback breaks the open_unplugged ⇒ !dcpaud_connection_up() invariant (drivers/gpu/drm/apple/audio.c)

    • Previously, dcpaud->open_unplugged could only be true when !dcpaud->connected at open time, so dcpaud_connection_up(dcpaud) was guaranteed false for the lifetime of that open. Setting dcpaud->open_unplugged = true on dcpaud_read_remote_info() < 0 while dcpaud->connected == true leaves dcpaud->open_cookie == dcpaud->connection_cookie, so dcpaud_connection_up() returns true for an open_unplugged stream:
      • Classic path (dcp_pcm_hw_free, audio.c:599): only checks if (!dcpaud_connection_up(dcpaud)) and omits dcpaud->open_unplugged. When WirePlumber closes/frees after hitting the fallback, dcp_pcm_prepare() was skipped, yet dcp_pcm_hw_free() sends a spurious dcp_audiosrv_unprepare() RPC (group 0 cmd 11). This already fired in the latest J473 boot log (group 0 cmd 11, retcode 0xe00002d7 — product attributes is group 1 cmd 18, which wasn't reached after group 1 cmd 16 failed; group 0 cmd 11 is cmds.unprepare).
      • Native-link path (dcp_pcm_native_trigger / dcp_pcm_native_start, audio.c:1181,1254): dcp_pcm_native_open() calls dcp_pcm_open(), so native-link Macs (T6030 / T6041 / T6050 / J700) inherit this fallback. If dcpaud_read_remote_info() fails while connected, dcp_pcm_native_hw_params() and dcp_pcm_native_prepare() skip dcpaud_select_cookie(), DMA slave config, and dcpaud_link_prepare() because open_unplugged is true, but dcp_pcm_native_start() does not check dcpaud->open_unplugged at all (only !dcpaud_connection_up(), which is true). Starting that stream will call dcpaud_link_prepare() / DCP_AUDIO_LINK_START with a zero/stale selected_cookie and unconfigured DMA.
    • Broad error masking (§2): catching every ret < 0 from dcpaud_read_remote_info() turns persistent or transport/allocation failures (-ENOMEM, -ETIMEDOUT, persistent -EIO) into a silently succeeding void stream. Distinguish transient service unavailability/restart from persistent errors, guard both dcp_pcm_hw_free() and dcp_pcm_native_start() (or invalidate open_cookie / handle open_unplugged consistently across all PCM ops), and extend tools/asahi/dcpaud-open-fallback-tests.py beyond dcp_pcm_open() alone to cover hw_free and native-start behavior.
    • Also worth checking in drivers/gpu/drm/apple/av.c: on the classic path, av_audiosrv_init() / av_audiosrv_teardown() never clear asrv->is_open, and __av_service_disconnect() returns early if asrv->srv is already NULL. If the firmware replaces DCPAVAudioInterface while asrv->is_open stays true, av_service_connect() skips cmds.open on the new instance.
  3. Code correctness & ABI — dcp_is_v27_external() conflates endpoint layout (0x2b vs 0x29) with link payload & lifecycle (drivers/gpu/drm/apple/dcp-internal.h, drivers/gpu/drm/apple/av.c)

    • Returning false from dcp_is_v27_external() on J473 switches not only the endpoint/transport (0x29 classic EPIC vs 0x2b compact EPIC in av.c:1404 and afk.c:530,539), but also turns off dcp_audiosrv_native_link() (av.c:309,322), dcp_audiosrv_link_by_format() (av.c:314,564), and av_v27_start() (av.c:873,1079).
    • That sends J473 through legacy dcp_audiosrv_prepare() / dcp_audiosrv_startlink() with a 24-byte ElementData cookie (and 16 KiB DCPAUD_ELEMENTS_MAXSIZE), whereas the PR notes "macOS describes the stream by format here, as on T6050" and playback has not been tested yet. Prove working playback on both ports and decouple link payload/lifecycle selection from endpoint layout if firmware-27 classic requires format-based links.
    • Minor config note: av.c:1455 still guards case DCP_FIRMWARE_V_27_0: under #if IS_ENABLED(CONFIG_DRM_APPLE_DCP_T6030_AUDIO), so disabling that option breaks classic firmware-27 audio with -ENODEV.
  4. §1 No model gating — dcp->hw.dptx_endpoint == DPTX_ENDPOINT_V2 at probe acts as a two-SoC allowlist and silently changes other firmware-27 dcpexts

    • At probe, dcp->hw.dptx_endpoint = DPTX_ENDPOINT_V2 is only populated for apple,t6050-dcpext and apple,t6041-dcpext (dcp.c:7626,10431). Every other compatible leaves dptx_endpoint == 0 (which dcp-internal.h:316 and dptxep.c:1645 define as firmware 27's default DPTX_ENDPOINT_V2 unless dcp_v27_dptx_layout() overrides it from RTKit's endpoint map) or DPTX_ENDPOINT (apple,t8142-dcpext).
    • Consequently, this predicate silently flips t8142-dcpext (M5 Air / J704) and t8122-dcpext (M3 on 27.2) out of dcp_is_v27_external() without any hardware evidence on those machines, and misclassifies any future firmware-27 dcpext relying on the 0 default. Either derive the audio endpoint/role from what the firmware advertises (or a dedicated capability/DT property rather than overloading probe-time dptx_endpoint), or prove and document behavior on t8142-dcpext and t8122-dcpext as well.
  5. §5 Evidence — incomplete for a non-draft PR

    • The J473 two-commit boot row (r15d) confirms read-back enumeration and 0 AVC / 0 failed units, but:
      • Actual DP/HDMI audio playback on both J473 ports has not been run yet (and group 0 cmd 11 failed with 0xe00002d7 in that boot).
      • Missing regression rows (0 SELinux denials, 0 failed units, 0 new kernel errors) on the rebased head for: J473 playback, a 13.x/14.x HDMI Mac, a desktop-role firmware-27 Mac (t6050 / t6041 / J616s), and the newly affected t8142-dcpext / t8122-dcpext if their predicate result changes.
    • Until those rows and exact-head CI land (or while the fix is still in progress), please convert to draft or land the fixes + evidence before merge.

Passing Checklist Items

  • §3 Safety: Pass — external DP/HDMI digital audio only; no speaker amp / speakerguardd or hardcoded safety limits touched.
  • §4 Clean-room & Attribution: Pass — both commits carry human author/committer (Ryan Murray <ryan@aurorasilicon.org>) and human Signed-off-by: with zero AI trailers; based on own ioreg capture and lab traces; PR body includes Assisted-by:.
  • §6 Naming: Pass — no Honeykrisp/hk/m1n1 naming violations; new host test follows the existing tools/asahi/ harness layout.

Assisted-by: LLM (Gemini 4 Neon)

@RyanTheTide
RyanTheTide marked this pull request as draft November 24, 2026 07:56
Takes linux#2853, #2868 and #2953. The only conflict is the host-test
registry, where both sides add entries.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The previous change opened a PCM as unplugged on any failure to read the
sink info. That masked persistent errors as a silent stream, and it left
the open's cookie live, so dcp_pcm_hw_free() and the native start took
the sink as connected for a stream that never prepared a link.

What fails at boot on the Mac mini M2 is a call to an audio service
instance the firmware is replacing: it refuses it as offline and
publishes the successor within a second, as dcp_audiosrv_open() already
handles for the open itself. Do the same for the sink info: when the
read fails and a successor is published within AV_AUDIOSRV_REPLACE_MS,
take the sink as the successor reports it and read again from it.

Only a service that is gone (-ENODEV) still opens as unplugged, and
with a cookie no connection has, so no stream op of that open takes the
sink as connected. Any other failure fails the open as before.

The host test runs the real dcp_pcm_open() and dcpaud_connection_up()
over nine cases and kills four mutations.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Author

Thanks for the reviews. The PR stays a draft. State at 82a27e5e:

1. Conflict. Fixed with a merge of integration/aurora (04e94d27). Only the host-test registry conflicted.

2. PCM open fallback. Reworked in 82a27e5e. Errors are no longer turned into a successful open across the board:

  • If the sink-info read fails and the firmware publishes a successor instance within AV_AUDIOSRV_REPLACE_MS, the open re-samples the connection and reads again from the successor. This is the same wait dcp_audiosrv_open() already does.
  • Only a service that is gone (-ENODEV) opens as unplugged, and its open cookie is set to one no connection has. dcpaud_connection_up() is then false for that open, so dcp_pcm_hw_free() and the native start treat it as unplugged.
  • Every other error (a stable refusal, -ENOMEM and so on) fails the open as before.
  • The fixture now builds the real dcp_pcm_open() and dcpaud_connection_up(). It runs nine cases and kills four mutations. The DCP host suites pass locally (61/61).
  • On the J473 (fleet87 + this branch as a module), the HDMI DCP's audio instance refused the element read as Offline at 15.89 s. The successor arrived 0.2 s later, the read was retried, and both HDMI/DP sinks were present.

3. Link payload and lifecycle. You were right that enumeration proves nothing about playback. I ran a silent row: 4 s of zero samples through each sink on fleet87. It fails, but before the link question can even be tested:

  • On the first DMA slave config, the SIO coprocessor crashed: RTKit: co-processor has crashed, Fifo allocation overflow 2048:0.
  • After that, the USB-C card sat in RUNNING with hw_ptr 0, and the HDMI card's dmaengine_slave_config returned -22.
  • Before this PR, audio never got as far as DMA on 27.2, so this was hidden.
  • Whether firmware-27 classic needs the format link payload and the v27 lifecycle can only be tested once the SIO FIFO setup works on this firmware. If it does need them, the payload and lifecycle predicates will be split from the endpoint choice, as you suggest.

4. t8142 / t8122 dcpext. I checked what the predicate change does there:

  • Both are USB-C only (apple,connector-type = "USB-C"), and neither has a DP audio node in its DT. avep_init() therefore returns before starting any audio service.
  • The other user, dcp_cec_init_avep(), requires an HDMI-A fixed connector.
  • So the predicate changes no behaviour on them today. I will still look at deriving the role from the firmware's advertised endpoints rather than the probe-time layout when the payload split above happens.

The av.c is_open point on the classic path and the CONFIG_DRM_APPLE_DCP_T6030_AUDIO guard on the firmware-27 command table are noted for the same rework.

Evidence: traces/display/20261124-m2mini-display-full/audio-a1 on the lab store, with the kit in kits/test/20261124-m2mdf-audio87.

@RyanTheTide

Copy link
Copy Markdown
Author

Playback update: the SIO crash comes from the boot loader, not this PR. The J473's 27.2 SIO firmware speaks protocol 10, but aura built it the earlier table layout. With the protocol-10 layout (aurora-silicon/aura#495, tested as a trial Stage 2), zero-sample streams run on both HDMI/DP cards with this PR's appledrm module. The DMA pointer advances at 48 kHz, both DMA channel configs succeed, and the firmware accepts the classic link (ElementData cookie). There is no SIO crash, and the row stayed Enforcing with 0 AVC and 0 failed units. Evidence is traces/display/20261124-m2mini-display-full/audio-a3 on the lab store.

So on the J473, firmware-27 classic takes the existing cookie link payload and lifecycle. No format-based link split is needed for this machine. Still open before ready: a playback row with real audio, and the 13.x/desktop-role regression rows.

@RyanTheTide

Copy link
Copy Markdown
Author

Re-review at 82a27e5e91eb2eb794f244366b6a1ebd42c9b21c. The source now retries when a successor instance is published. It still returns a persistent negative error, with the unplugged probe case limited to -ENODEV. This addresses my concern about concealing a stable service failure.

I checked A3’s J473 receipt. With the trial Aura SIO tables, the classic cookie route was accepted and both display PCM streams returned 0. Each pointer advanced from 31,744 to 200,192 frames during the silent run, with no SIO crash. That answers the link payload question for the tested pair. The production signed Aura path and active external-display peer receipts remain to run.

Assisted-by: LLM (Codex)

@RyanTheTide

Copy link
Copy Markdown
Author

Playback path, production shape (audio-a4): this PR's head 82a27e5e as a module, plus the SIO fix in its final form (no firmware-version selector). The boot loader passes both SIO table layouts (aurora-silicon/aura#495 at e6d3b082), and the SIO driver sends the one that matches the protocol the firmware reports (#3051). On the J473 (27.2): "SIO protocol v10", and both HDMI/DP PCMs stream zero samples (hw_ptr 31232 to 199680 in 4.2 s, pw-cat rc 0, slave config 0) with no SIO crash. Enforcing, 0 AVC.

A -20 dBFS tone row into the monitors' 3.5 mm jacks played (rc 0 on both), but the buildbox line-in recorded nothing on either channel. That cable needs a physical check before an audible-content proof is possible.

Assisted-by: LLM (Claude:Opus 5.5)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants