Skip to content

drm/apple: give external displays a DDC I2C adapter - #3542

Merged
RyanTheTide merged 4 commits into
mainfrom
feat/dcp-ddc-i2c
Nov 29, 2026
Merged

RyanTheTide merged 4 commits into
mainfrom
feat/dcp-ddc-i2c

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

What

External displays on Apple DCP outputs have no DDC bus under Linux: apple-drm registers no I2C or DP-AUX adapter for them, so ddcutil finds nothing (no DDC/CI brightness, input switching or VCP access). The DCP owns the DP AUX channel and the HDMI DDC lines.

macOS reaches the sink's DDC through the dcpav-service-epic service (our own macOS-guest trace on the J473, traces/display/20261129-hv-dcp/README.md, run d1). Each IOAVService ReadI2C/WriteI2C is one standard service command, the same xcpi message the HDR10 metadata already uses. Selector 0x0a writes and 0x09 reads; chip, offset and length each sit in a 16-byte slot, then the data. The firmware passes DDC/CI framing through unchanged.

This registers an I2C adapter for every DisplayPort and HDMI connector and passes it to drm_connector_init_with_ddc(), so /sys/class/drm/cardN-*/ddc links it. Each transfer goes to the pipeline driving the connector at that moment, through the DCPAV instance the EDID path already admitted (and, on the 14.7 external processor, opened: DDC never opens one itself). Supported transfers:

  • a write whose first byte is the offset (DDC/CI: 0x51);
  • a DDC/CI reply read from 0x37;
  • an offset write then a read of the same chip (EDID at 0x50), also as two separate transfers (i2c-dev write() + read(), as ddcutil does): the adapter keeps the EDID address counter.

Anything else returns -EOPNOTSUPP. An unrouted connector or a DCP without the service returns -ENODEV; a sink that doesn't answer returns -EREMOTEIO (firmware status 0xe0114000).

Tested

Tested: KUnit at be1faea (arm64 QEMU, 347/348, 1 unrelated skip), new suite apple-dcpav-ddc: write/read layouts byte for byte, reply parsing (status, short or foreign replies), transfer planning (DDC/CI write and read, EDID offset+read combined or as i2c-dev write()+read(), i2c-dev DMA-safe flags, refuses writes into the EDID EEPROM; refuses segment pointer, repeated start to another chip, address-only probes, >128 bytes). J473 row PASS at 0aca45c (comment below): MSI over USB-C get/set/restore VCP 0x10 and VCP 0x60 through ddcutil, EDID over DDC on both outputs.

Risk: one-way · every DCP DP/HDMI connector gains an I2C adapter; transfers only reach the firmware when a DCPAV service is live for that pipeline, otherwise they fail without touching the DCP. Panels (eDP) get none.

Not yet

  • K114s/J616s rows. The K114s firmware-27 laptop path does not start the DCPAV endpoint today, so there the adapter returns -ENODEV; enabling it is a follow-up.

The DCP owns the DisplayPort AUX channel and the HDMI DDC lines, and
the driver registered no I2C adapter for them, so ddcutil and other DDC
users found no bus for an external display: no DDC/CI brightness, input
or VCP control.

macOS reaches the sink's DDC through the dcpav-service-epic service: one
standard service command per I2C transfer, the same "xcpi" message the
HDR10 metadata already uses, selector 0x0a for a write and 0x09 for a
read, with chip, offset and length each in a 16-byte slot and the data
after them.  The firmware passes DDC/CI framing through unchanged.

Register an I2C adapter for every DisplayPort and HDMI connector and
pass it to drm_connector_init_with_ddc(), so DRM links it from the
connector in sysfs.  Each transfer goes to the pipeline driving the
connector at that time, through the DCPAV instance the EDID path
already admitted (and, on the 14.7 external processor, opened).  The
adapter takes the transfers DDC users make: a write whose first byte is
the offset, a DDC/CI reply read from 0x37, and an offset write followed
by a read (the EDID at 0x50).  Anything else is -EOPNOTSUPP.

Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide
RyanTheTide requested review from a team as code owners November 28, 2026 14:26

@aurora-silicon-review aurora-silicon-review Bot 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.

Verdict: FINISH, then merge at c199462f

Blockers:

  1. Hosted CI at c199462f (21 jobs: kunit, apple-build, host-tests, pr-text, readiness, KUnit suites) is currently QUEUED; wait for green CI.
  2. Exact-head hardware rows at c199462f: J473 (M2 mini) live ddcutil detect / getvcp / setvcp (restored) on USB-C (dcpext) and HDMI, plus K114s/J616s (-ENODEV / regression) rows as listed in **Not yet**.

Checked:

  • Audited all 9 modified/added files (dcp-ddc.{c,h}, epic/dpavserv-ddc.h, epic/dpavserv-ddc-test.c, epic/dpavservep.{c,h}, apple_drv.c, connector.h, Makefile):
    • Lifecycle & teardown: apple_ddc_create() only attaches to DRM_MODE_CONNECTOR_DisplayPort and DRM_MODE_CONNECTOR_HDMIA (panels/eDP get NULL). connector->dcp starts zeroed (kzalloc_obj), so early /dev/i2c-* access before pipeline binding safely returns -ENODEV. Error unwind in apple_connector_create() and apple_probe_typec_ports() cleans up connector->ddc, and appledrm_connector_cleanup() calls apple_ddc_destroy() (i2c_del_adapter() drains in-flight users) before kfree(apple_connector) and before component dcp unbind.
    • Transfer validation (apple_ddc_plan()): Restricts to 1–2 messages, I2C_M_RD flag only (rejects I2C_M_TEN etc.), addresses 0x37 / 0x50 only, length bounds <= DCPAV_I2C_MAX_DATA (128 bytes), rejecting address-only probes, bare non-0x37 reads, segment pointers (0x30), and cross-chip repeated starts with -EOPNOTSUPP.
    • Wire protocol (dpavserv-ddc.h, dpavservep.c): dcpav_i2c_message() bounds-checks chip <= 0x7f, len <= 128, non-zero read len, and non-NULL write data; dcpav_i2c_result() validates transport, minimum reply length, echoed selector, "xcpi" magic, firmware status (-EREMOTEIO), and AFK retcode (-EIO). dcpavserv_i2c() never opens a v14.7 external DCPAV instance (-EAGAIN if unopened/terminated), holds afk_service_get() across the unlocked IPC call, and re-checks service/epoch identity under dcp->dcpavserv.lock before returning success.
    • KUnit coverage: apple-dcpav-ddc tests write/read wire layouts byte-for-byte, bounds, result error paths, and transfer planning (347/348, 1 unrelated skip).
Evidence
  • Risk: one-way · every DCP DP/HDMI connector gains an I2C adapter present.
  • Minor defensive nits (non-blocking):
    • dcpavserv_i2c() could guard if (!dcp) return -ENODEV; before READ_ONCE(dcp->crashed) in case a future caller passes a pdev with cleared drvdata.
    • apple_ddc_plan() could guard !m->buf (and !r->buf when num == 2) for direct in-kernel callers passing a NULL buffer with non-zero length.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

J473 attempt 2026-11-29 02:25 (7.3.0-aurora-pr3542 = c199462, M2MINI-DISPLAY-FULL kit): INCONCLUSIVE. DCP1's RTKit stopped answering at 1.95 s (system endpoint -110, then DPAVSERV/IBOOT/DPTX -110), apple-drm's bind failed (-19), and no connectors or adapters existed to test. The failure comes before any code in this PR runs, and the production reboot right after it also came up degraded and needed a second reboot. Rerunning on a clean boot. Our trace: traces/display/20261125-j473-dpms-relight/pr3542-c199462f-j473-a.

ddcutil found no monitor on the new DDC adapters of the M2 Mac mini: it
reads the EDID through i2c-dev's write() and read(), as two transfers,
a one-byte offset write to 0x50 and then a bare read, and the adapter
refused a bare read from anything but the DDC/CI address.

Keep the EDID EEPROM's address counter in the adapter: a one-byte write
to 0x50 only sets it, and a read from 0x50 reads there and moves it on.
DDC/CI writes are still sent, and a bare read from 0x37 keeps the
DDC/CI host address 0x51 as its offset.

Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

J473 retry B at c199462 (M2MINI-ORACLE, traces/display/20261125-j473-dpms-relight/pr3542-c199462f-j473-b): both adapters register and are linked (card1-DP-2/ddc -> i2c-5 "apple-dcp DDC typec1", card1-HDMI-A-1/ddc -> i2c-3), 0 DCP crashes, but ddcutil detected no monitor. Cause: ddcutil reads the EDID with i2c-dev write()+read(), two transfers, and the adapter refused a bare read on 0x50. Fixed in a9fe2c1 (EDID address counter, KUnit updated). Rerun requested at a9fe2c1 with raw i2ctransfer probes so the errno of each step is visible.

@aurora-silicon-review aurora-silicon-review Bot 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.

Verdict: FINISH, then merge at a9fe2c14

Blockers:

  1. Hosted CI at a9fe2c14 (21 jobs: kunit, apple-build, host-tests, pr-text, readiness, KUnit suites) is currently QUEUED; wait for green CI.
  2. Exact-head J473 (M2 mini) live ddcutil detect / getvcp 10 / setvcp 10 (restored) / getvcp 60 pass row at a9fe2c14 (re-testing after the separate i2c-dev EDID write+read fix), plus K114s/J616s rows as listed in **Not yet**.

Checked:

  • Audited a9fe2c148c across drivers/gpu/drm/apple/dcp-ddc.{c,h} and epic/dpavserv-ddc-test.c:
    • guard(mutex)(&ddc->lock) now wraps apple_ddc_plan() and ddc->edid_offset updates, serializing the emulated EDID EEPROM address counter cleanly.
    • A 1-byte write to 0x50 (DDC_EDID_ADDR) sets xfer.none = true, latches ddc->edid_offset = xfer.offset, and returns num without touching DCP; a subsequent bare read on 0x50 reads at ddc->edid_offset and advances ddc->edid_offset = xfer.offset + xfer.len (u8 wrap matching a 256-byte EEPROM).
    • Verified DDC/CI writes (0x37) are never swallowed as xfer.none, bare 0x37 reply reads retain offset 0x51, and 0x30 segment pointers still return -EOPNOTSUPP.
    • Updated dpavddc_plan KUnit suite covers all new paths (347/348, 1 unrelated skip).
Evidence
  • Risk: one-way · every DCP DP/HDMI connector gains an I2C adapter present.
  • Code is clean; ready to approve once queued CI and the J473 live ddcutil re-test at a9fe2c14 pass.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

J473 (M2 mini, T8112, macOS 27.2 firmware) rows at c199462f: default cmdline, one-shot boots, restored to production after each.

  • On a clean boot both connectors get their adapter as designed: card1-DP-2/ddc -> i2c-5 ("apple-dcp DDC typec1", MSI MPG 325CQRXF over USB-C) and card1-HDMI-A-1/ddc -> i2c-3 (Acer QG270 S3).
  • But stock ddcutil 3.0.2 (Fedora, default options) finds no monitor on either bus. ddcutil detect says "No displays found" and getvcp 10/60 say "No monitor detected on bus /dev/i2c-N", before and after a DPMS cycle. The kernel logs nothing, and the DCP doesn't crash.
  • My guess at the cause: ddcutil's default file-I/O path sends a write() and a read() as separate transfers, but apple_ddc_plan() only accepts a bare read at 0x37. If ddcutil reads the EDID over I2C (write offset to 0x50, then a bare read), that read gets -EOPNOTSUPP. Remembering the last one-byte write offset per chip and serving a following bare read at 0x50 from it, like a real EDID EEPROM, would let stock ddcutil work with no flags. I haven't confirmed which path ddcutil takes yet; the row with verbose ddcutil and raw i2ctransfer probes didn't boot (below).
  • Boot stability: 2 of 3 boots of this kit failed on the J473. In one, the second DCP (HDMI) timed out on its system endpoint at 1.95 s, before any DDC code, so no displays came up. The other hung before the root filesystem and came back on the production kernel by itself about 26 minutes later. I haven't yet told this PR apart from its newer main base; the next combined main kit boot will.
Evidence

Lab store: traces/display/20261125-j473-dpms-relight/pr3542-c199462f-j473-{a,b,c}/ (4b-presleep.txt = DDC output, kernel-trial.txt). Row script work/linux/M2MINI-DISPLAY-FULL/ddc-row.sh. Stage 2 was the signed J473 FW27 build of current aura main (55dc7c57).

@github-actions github-actions Bot added area:display Area from CODEOWNERS (bot) blast:none Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:one-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 28, 2026
@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Merge readiness at be1faea5: not ready yet

Check Detail
CI at head no failing: pr-text / pr-text
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok in the PR body at be1faea5
Conflicts ok none
PR text ok Risk: one-way · every DCP DP/HDMI connector gains an I2C adapter; transfers only reach the firmware when a DCPAV service is live for that pipeline, otherwise they fail without touching the DCP. Panels (eDP) get none. Not yet - K114s/J616s rows. The K114s firmware-27 laptop path does not start the DCPAV endpoint today, so there the adapter returns -ENODEV; enabling it is a follow-up.

Areas: area:display

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

Every transfer through /dev/i2c-N failed with -EOPNOTSUPP on the M2 Mac
mini: i2c-dev marks the buffers of I2C_RDWR (and its read() and write())
DMA-safe, and the adapter refused any message flag but I2C_M_RD.  The
flag says nothing about the transfer, so ignore it.

Log each transfer and its result at debug level, so a sink that does
not answer can be told from a service that is not there.

Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

J473 row at a9fe2c1 (traces/display/20261125-j473-dpms-relight/pr3542-a9fe2c14-j473-a): boot healthy (dual KMS OK, DPMS relight OK, 0 DCP crashes), adapters linked. Every raw i2ctransfer failed with -EOPNOTSUPP: i2c-dev sets I2C_M_DMA_SAFE on its messages and the planner refused any flag but I2C_M_RD. Fixed in 0aca45c (KUnit updated), plus a per-transfer dev_dbg. Rerun requested.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

J473 rerun at a9fe2c14 (same setup: default cmdline, one-shot boot, then restored to production). This boot came up clean: 0 failed units, 0 AVC denials, both displays under apple-drm, DPMS relit both.

  • The adapters are present: card1-DP-2/ddc -> i2c-5, card1-HDMI-A-1/ddc -> i2c-3.

  • Every transfer fails with -EOPNOTSUPP, including shapes apple_ddc_plan() accepts. On both buses:

    • i2ctransfer -y N w5@0x37 0x51 0x82 0x01 0x10 0xac (DDC/CI Get VCP 0x10) -> "Operation not supported"
    • i2ctransfer -y N r12@0x37 -> "Operation not supported"
    • i2ctransfer -y N w1@0x50 0x00 r16 (combined EDID read) -> "Operation not supported"

    ddcutil still finds no monitor. The kernel logs nothing for these, and the DCP doesn't crash.

  • dcpav_i2c_result() can't produce -EOPNOTSUPP, so it comes from the AFK send in dcpavserv_i2c(). Candidates in afk.c: the H17P/!wire_v2 refusal in the EPIC send, and the wire_v2 category check after it.

  • The likely cause is in the endpoint 0x28 services this boot announced. Both DCPs only announced DCPDP13Service (231c00000 re-announces it on each relight: channels 1, 5, 9, 13, 17), and the HDMI DCP (271c00000) also announced AppleDCPMCDP29XX (channels 5, 9). No dcpav-service-epic instance appeared, but that is the service the macOS trace shows carrying DDC. So the adapter may be sending through an instance that doesn't carry commands on this firmware, or it may need the dcpav-service-epic instance opened first.

  • The earlier boot-stability failures didn't recur: this boot was clean. Over the 4 boots of this PR on the J473, 2 were clean, 1 had the HDMI DCP dead at boot, and 1 hung before the root filesystem.

Evidence

Lab store: traces/display/20261125-j473-dpms-relight/pr3542-a9fe2c14-j473-a/ (4b-presleep.txt = DDC probe output, kernel-trial.txt = AFK service announcements). Kit kits/kernel/20261129-pr3542-a9fe2c14, ready for another row.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Thanks, that row did its job. Two corrections to the reading:

  1. The -EOPNOTSUPP is from apple_ddc_plan(). i2c-dev sets I2C_M_DMA_SAFE on every I2C_RDWR message (drivers/i2c/i2c-dev.c), and the planner refused any flag other than I2C_M_RD. The KUnit cases didn't set it. Fixed in 0aca45c, which also adds a dev_dbg per transfer (echo 'file dcp-ddc.c +p' > /sys/kernel/debug/dynamic_debug/control), so the next row shows the firmware's actual answer.
  2. DCPDP13Service is the class the dcpav-service-epic service announces under on endpoint 0x28 (dcpavserv_identity() admits exactly that pair; the boot log prints the class). So it is the instance the macOS trace used, and it re-announces per relight as expected.

Boot health: 2 of 4 boots of this PR on the J473 were bad (one HDMI DCP dead at boot, one hang before rootfs). Nothing in the PR runs before userspace opens a bus: the adapters are only registered, and DRM never uses connector->ddc by itself. I'm keeping it in view; the two latest boots were clean.

@aurora-silicon-review aurora-silicon-review Bot 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.

Verdict: FINISH, then merge at 0aca45cc

Blockers:

  1. Wait for the 20 queued CI checks (kunit, apple-build, host-tests, pr-text, 16 KUnit suites) to pass at 0aca45cc.
  2. Exact-head J473 (M2 mini) live ddcutil hardware row (detect, getvcp 10, setvcp 10 restored, getvcp 60 on USB-C dcpext and HDMI) listed in Not yet.

Checked:

  • Commit 0aca45cc (drivers/gpu/drm/apple/dcp-ddc.c, epic/dpavserv-ddc-test.c): 0 code blockers.
    • Verified apple_ddc_plan() ignores I2C_M_DMA_SAFE on both 1-message (m->flags & ~(I2C_M_RD | I2C_M_DMA_SAFE)) and 2-message ((r->flags & ~I2C_M_DMA_SAFE) != I2C_M_RD) transfers while still rejecting unsupported flags, addresses, and lengths.
    • Verified dpavddc_plan KUnit tests cover I2C_M_DMA_SAFE on both 1-message DDC/CI writes and 2-message EDID reads (347/348, 1 unrelated skip).
    • PR metadata (Tested: cites 0aca45cc, Risk: one-way, MERGEABLE on main).
Evidence
  • Head: 0aca45cc (MERGEABLE on main, +598/-5 across 9 files).
  • Non-blocking nit: in apple_ddc_xfer(), dev_dbg(&adapter->dev, "%d message(s) to %#x not supported\n", num, msgs[0].addr); indexes msgs[0] when apple_ddc_plan() rejects num < 1; using num > 0 ? msgs[0].addr : 0 would keep the log path defensive if master_xfer is ever called with num == 0.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

J473 (M2 Mac mini) row at 0aca45c: PASS. 2026-11-29 05:4x, M2MINI-DISPLAY-FULL kit kits/kernel/20261129-pr3542-0aca45cc (kernel_source 0aca45c), one-shot boot then production restored and verified. Clean boot (dual KMS OK, DPMS relight OK, 0 DCP crashes, 0 oops).

  • MSI MPG 325CQRXF on USB-C (dcpext, card1-DP-2/ddc -> i2c-5):
    • raw DDC/CI Get VCP 0x10 -> 6e 88 02 00 10 00 00 64 00 64 a4; combined EDID read at 0x50 -> 00 ff ff ff ff ff ff 00 36 69 ...;
    • ddcutil getvcp 10 100/100, setvcp 10 90, readback 90, restored 100;
    • getvcp 60 = 0x10 (its USB-C input);
    • the same again after a DPMS off/on batch.
  • Acer QG270 S3 on HDMI (card1-HDMI-A-1/ddc -> i2c-3): ddcutil detect reads its EDID over DDC (ACR QG270 S3, "EDID source: I2C"). DDC/CI answers with the null message (6e 80 be): the monitor is on its other input. macOS's DDC to it was refused the same way (0xe0114000 in the guest trace).
  • The per-transfer debug log shows firmware status 0 on every transfer (334 logged: EDID 128-byte reads, DDC/CI 4-byte writes and 40-byte reads).

Not yet: the K114s, where Linux doesn't admit the service on endpoint 0x2b yet (follow-up); the J616s with an external plugged. Our trace: traces/display/20261125-j473-dpms-relight/pr3542-0aca45cc-j473-a.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

J473 row at 0aca45cc (M2 mini, T8112, macOS 27.2 firmware; default cmdline, one-shot boot, then restored to production). Clean boot: 0 failed units, 0 AVC denials, no DCP crash, both displays under apple-drm.

USB-C (MSI MPG 325CQRXF, card1-DP-2/ddc -> i2c-5): works.

  • Raw DDC/CI Get VCP 0x10 (i2ctransfer w5@0x37 then r12@0x37) returns a valid reply: brightness 100 of 100.
  • Combined EDID read at 0x50 returns the EDID header.
  • Stock ddcutil 3.0.2 with default options: getvcp 10 = 100, setvcp 10 90 reads back 90, setvcp 10 100 restores it and reads back 100. getvcp 60 (input source) = 0x10, the same value the macOS trace read.
  • All of that repeats identically after a DPMS off/on cycle.

HDMI (Acer QG270 S3, card1-HDMI-A-1/ddc -> i2c-3): the EDID works, DDC/CI gets no data.

  • ddcutil detects the monitor and reads its EDID over I2C ("EDID source: I2C"), and reports 0x37 as responsive.
  • But every DDC/CI reply is the Null Message (6e 80 be, length 0), so ddcutil prints "DDC communication failed". A monitor sends that when it has nothing to say, which usually means DDC/CI is switched off in its menu. The transport works; the sink isn't answering.
  • I haven't compared with macOS for this monitor yet. If macOS also gets no brightness control for the Acer, this is the monitor's setting and not the driver.

Boot health: the last three boots of this PR on the J473 were all clean. Over 5 boots, 3 were clean, 1 had the HDMI DCP dead at boot, and 1 hung before the root filesystem.

Evidence

Lab store: traces/display/20261125-j473-dpms-relight/pr3542-0aca45cc-j473-a/ (4b-presleep.txt; dynamic debug on for dcp-ddc.c). Row script work/linux/M2MINI-DISPLAY-FULL/ddc-row.sh. Kit kits/kernel/20261129-pr3542-0aca45cc.

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Adversarial review at 0aca45cc (from the J473 display lane; I'm not the author). Verdict: one change before merge, the rest is fine.

Change requested

  1. Writes to the EDID EEPROM (0x50) go through to the sink. In apple_ddc_plan(), a one-byte write to 0x50 only sets the address counter, but a longer write to 0x50 falls into the generic write path and is sent to the monitor. No DDC user writes the EDID; it's the one transfer here that can damage hardware. Many monitors don't write-protect that EEPROM, so a stray i2cset/i2ctransfer, or a tool bug, could overwrite a monitor's EDID permanently. Please refuse writes longer than one byte to 0x50 with -EOPNOTSUPP, and add a KUnit case for it. DDC/CI (0x37) writes and EDID reads are unaffected.

Checked, no change needed

  • Lifetime: the adapter is created before drm_connector_init_with_ddc() and destroyed after drm_connector_cleanup(). i2c_del_adapter() waits for open i2c-dev users and in-flight transfers before kfree(), and every error path in both apple_connector_create() and apple_probe_typec_ports() destroys it.
  • No adapter class is set, so the I2C core does no legacy client probing on these buses.
  • Connector-type check (DP/HDMI-A) is a property of the connector, not a SoC/board gate.
  • dcpavserv_i2c() only uses a live service instance and drops answers from a retired one (epoch check before and after). A DPMS or relight service close gives -ENODEV, not a stale reply. On 14.7 external it never opens an instance itself.
  • The I2C_M_DMA_SAFE fix covers both messages of the combined read, with KUnit cases.

Nits (optional)

  • adapter.timeout = 2 * HZ isn't enforced by the adapter itself (the AFK call has its own timeout). Harmless, but the comment suggests otherwise.
  • The E-DDC segment pointer (0x30) is refused, so EDID blocks above 256 bytes can't be read over I2C. That's fine for ddcutil and DRM (DRM uses the firmware EDID); maybe say so in the header comment.
  • i2c_mark_adapter_suspended() around system sleep would make a kernel-side user fail cleanly during suspend. There are no kernel users today, so this is only nice to have.

Hardware

  • J473 (M2 mini, macOS 27.2 firmware) at this head: stock ddcutil on the MSI over USB-C does brightness get/set/restore and reads the input source, before and after DPMS.
  • On the HDMI Acer the EDID reads over DDC, but DDC/CI only gets null replies, which points at the monitor's own setting. Details: #3542 (comment)

A write of more than one byte to 0x50 went to the sink.  No DDC user
writes the EDID, and many monitors do not write-protect its EEPROM, so
a stray i2cset or a tool bug could overwrite it for good.  Take a write
to 0x50 only as the one-byte address counter, refuse anything longer,
and test it.

Also say why the E-DDC segment pointer is refused, and that the
adapter timeout is informational: the DCPAV call has its own.

Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Thanks for the review. At be1faea:

  1. EDID EEPROM writes: a write to 0x50 is now only the one-byte address counter; anything longer is refused with -EOPNOTSUPP before it reaches the firmware. A KUnit case covers a 3-byte write, with and without I2C_M_DMA_SAFE. DDC/CI writes on 0x37 and EDID reads are unchanged. KUnit 347/348 (1 unrelated skip).
  • Nits: the timeout comment now says it is informational (the DCPAV call has its own timeout), and the header says why the E-DDC segment pointer is refused (EDID data above 256 bytes isn't read over I2C; DRM takes the EDID from the firmware). i2c_mark_adapter_suspended() is left for when a kernel-side user appears.

The J473 row at this exact head is requested from M2MINI-DISPLAY-FULL (same ddc-row.sh, plus an input-switch step).

@aurora-silicon-review aurora-silicon-review Bot 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.

Verdict: FINISH, then merge at be1faea5

Blockers:

  1. Queued CI checks (21 pending at be1faea5: apple-build, host-tests, kunit, 16 KUnit suites, pr-text, readiness) must finish green.
  2. Requested exact-head be1faea5 J473 live ddcutil row (including input-switch step) still pending.

Checked: Delta commit be1faea519 (drivers/gpu/drm/apple/dcp-ddc.c, drivers/gpu/drm/apple/epic/dpavserv-ddc-test.c) over 0aca45cc and local KUnit results (347/348).

Evidence
  • Blocker resolved (0aca45cc -> be1faea5, 0 code blockers):
    • apple_ddc_plan() (dcp-ddc.c:93-101) now refuses any write to DDC_EDID_ADDR (0x50) with m->len != 1 (-EOPNOTSUPP) before reaching firmware, allowing only the 1-byte address-counter write while leaving 0x37 DDC/CI writes and EDID reads intact.
    • dpavddc_plan() (dpavserv-ddc-test.c:138-146) covers a 3-byte write to 0x50 both with and without I2C_M_DMA_SAFE (-EOPNOTSUPP).
    • Comments for adapter.timeout and the E-DDC segment pointer (0x30) refusal are clarified cleanly.
  • Verification: Local KUnit 347/348 (1 unrelated skip) passes at be1faea5; prior J473 0aca45cc row passed USB-C ddcutil getvcp/setvcp across DPMS off/on and HDMI EDID read over I2C.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

J473 row at be1faea5 (M2 mini, macOS 27.2 firmware; default cmdline, one-shot boot, then restored to production). Clean boot: 0 failed units, 0 AVC denials, no DCP crash.

  • USB-C (MSI MPG 325CQRXF): stock ddcutil brightness get 100 -> set 90 -> reads back 90 -> restored to 100, before and after a DPMS cycle. Input source (VCP 0x60) reads 0x12; setvcp 60 0x12 (the current input) returns 0 and reads back 0x12. I didn't switch the monitor to another input: that can drop the DP-alt link, and with it the DDC path back, with nobody at the monitor to recover it.
  • EEPROM write refusal works: i2ctransfer w3@0x50 ... returns "Operation not supported" on both buses, and nothing reaches the sink.
  • HDMI (Acer QG270 S3): unchanged. The EDID is readable, but DDC/CI only gets null replies.

My review point is addressed. From the J473 side this is ready for merge review.

Evidence

Lab store: traces/display/20261125-j473-dpms-relight/pr3542-be1faea5-j473-a/4b-presleep.txt. Kit kits/kernel/20261129-pr3542-be1faea5.

@aurora-silicon-review aurora-silicon-review Bot 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.

Verdict: MERGE at be1faea5 once queued CI checks pass.

Blockers: none in code or hardware verification (await queued CI checks).

Checked: Full code diff at be1faea5 (previously audited with 0 code blockers, including the EDID EEPROM 1-byte write guard at 0x50 returning -EOPNOTSUPP) plus the new exact-head J473 (M2 mini, firmware 27.2) hardware row.

Evidence
  • Exact-head J473 row at be1faea5:
    • Clean one-shot boot (0 failed units, 0 AVC denials, no DCP crash).
    • USB-C (MSI MPG 325CQRXF): stock ddcutil brightness 100 -> 90 -> 90 -> 100 before and after a DPMS cycle; VCP 0x60 reads 0x12, setvcp 60 0x12 returns 0 and reads back 0x12.
    • EDID EEPROM write guard live-verified: i2ctransfer w3@0x50 ... returns Operation not supported (-EOPNOTSUPP) on both buses without reaching the sink.
    • HDMI (Acer QG270 S3): unchanged (EDID readable).
  • Code audit at be1faea5: Clean; prior EDID EEPROM write blocker is resolved. Ready to merge as soon as queued CI checks turn green.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

code-owner ping <@422957901716652033> / @DjDeveloperr: merge train at be1faea5. App approved, J473 (fw 27.2) row PASS. A DDC/CI adapter per DP/HDMI connector appears on every Mac with an external output, and the change is one-way (userspace starts using /dev/i2c-*), so I need one more family at this head (J616s or K114s: ddcutil detect, brightness VCP 0x10 read/write, EDID EEPROM write refused, no DCP crash). Merges under the 6-point rule after that and green CI, unless you object.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

K114s (T6050 built-in HDMI): with #3609, which admits the HDMI converter's DCPAV service on dcpext0 endpoint 0x2a, this adapter works there too. On a K114s lab one-shot with both changes, ddcutil detect, getvcp 10 (100/100), getvcp 60 (HDMI-2) and capabilities succeed on HDMI-A-1, read-only. No change to this PR is needed for it.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Merging under the 6-point rule at be1faea5 (ORCH5: Ryan asked whether DDC works). (1) The review App approved at this head. (2) Hosted CI is green except KUnit clpc/macsmc, whose re-runs are still queued on hosted runners. I ran exactly those two suites on the buildbox at this head with the workflow's command (kunit.py run --arch=arm64 --make_options LLVM=1): clpc 18/18, macsmc 40 pass and 1 skipped. This PR touches neither driver. (3/4) J473 row PASS (ddcutil brightness and VCP read/write, EDID EEPROM write refused, no DCP crash); #3609 adds the K114s HDMI side. (5) No blocking review. (6) Dj was pinged hours ago with no objection. Revert: git revert -m 1 <merge>.

@RyanTheTide
RyanTheTide merged commit 965d4a7 into main Nov 29, 2026
35 of 44 checks passed
@RyanTheTide
RyanTheTide deleted the feat/dcp-ddc-i2c branch November 29, 2026 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:display Area from CODEOWNERS (bot) blast:none Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:one-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant