From 0954fe387b4fa77da8745ca3e81d1c37aa392569 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Fri, 30 Oct 2026 14:37:07 +0000 Subject: [PATCH 1/2] kboot: hand off the AVE firmware on the M4 Pro too dt_set_ave() only ran on the T8140 and looked the encoder up by its A18 Pro path. The T6040 DT already describes the encoder (apple,t6041-ave at /video-codec@283100000, disabled), and iBoot preloads its firmware the same way: the ADT node /arm-io/ave0 is pre-loaded with __TEXT and __DATA segments remapped at 0x100_0000_0000, like /arm-io/ave on the A18 Pro. Find the DT node by its compatible instead of a chip check and a fixed path, and take the ADT node from /arm-io/ave or /arm-io/ave0. The checks, the reservation and the CRC export are unchanged, and the node is only ever disabled here, never enabled, so the T6040 encoder stays off until the kernel driver supports it. Assisted-by: LLM Signed-off-by: Ryan Murray --- src/kboot.c | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/src/kboot.c b/src/kboot.c index 285a03022..ff93d4fe6 100644 --- a/src/kboot.c +++ b/src/kboot.c @@ -2715,18 +2715,29 @@ static int dt_reserve_asc_firmware(const char *adt_path, const char *adt_path_al return dt_reserve_asc_segments(adt_path, adt_path_alt, fdt_path, remap, base, false); } -static int dt_set_ave(void) -{ - if (chip_id != T8140) - return 0; +/* + * The AVE video encoder runs firmware that iBoot preloads. The ADT calls the + * encoder "ave" on the A18 Pro and "ave0" on the M4 Pro. The DT node is found + * by its compatible, so describing a SoC's encoder is all it takes. + */ +static const char *const ave_compatibles[] = { + "apple,t8140-ave", + "apple,t6041-ave", +}; - const char *path = "/soc/video-codec@285100000"; - int node = fdt_path_offset(dt, path); - if (node < 0) - return 0; +static int dt_set_ave_node(int node) +{ + char path[64]; + if (fdt_get_path(dt, node, path, sizeof(path))) + bail("FDT: AVE node path too long\n"); const char *reason = "invalid ADT firmware segments"; - int anode = adt_path_offset(adt, "/arm-io/ave"); + const char *adt_path = "/arm-io/ave"; + int anode = adt_path_offset(adt, adt_path); + if (anode < 0) { + adt_path = "/arm-io/ave0"; + anode = adt_path_offset(adt, adt_path); + } if (anode < 0) { reason = "ADT node absent"; goto disable; @@ -2794,7 +2805,7 @@ static int dt_set_ave(void) for (size_t i = 0; i < count; i++) crcs[i] = tinf_crc32((void *)seg[i].phys, seg[i].size); - if (dt_reserve_asc_firmware("/arm-io/ave", NULL, path, true, 0)) { + if (dt_reserve_asc_firmware(adt_path, NULL, path, true, 0)) { reason = "firmware reservation failed"; goto disable; } @@ -2818,6 +2829,16 @@ static int dt_set_ave(void) return 0; } +static int dt_set_ave(void) +{ + for (size_t i = 0; i < ARRAY_SIZE(ave_compatibles); i++) { + int node = fdt_node_offset_by_compatible(dt, -1, ave_compatibles[i]); + if (node >= 0) + return dt_set_ave_node(node); + } + return 0; +} + static const char dcpext_aliases[][8] = { "dcpext", "dcpext0", "dcpext1", "dcpext2", "dcpext3", "dcpext4", "dcpext5", "dcpext6", "dcpext7", From 5e2cf88112a96544bc270a516ed89cafd3a8410f Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sat, 31 Oct 2026 22:16:19 +1100 Subject: [PATCH 2/2] kboot: hand off the AVE firmware on the M1 Pro and M2 too The T6000 and T8112 DTs describe the encoder (apple,t6000-ave and apple,t8112-ave, disabled), and iBoot preloads its firmware the same way as on the A18 Pro and M4 Pro: /arm-io/ave0 on the M1 Pro, /arm-io/ave on the M2, pre-loaded, with __TEXT and __DATA segment ranges. On the M2 the remap address differs from the physical one, which the reservation already takes from the ADT. Reserve the segments and export their CRCs on these SoCs too, so the driver can tell which firmware build it is talking to. The node is still only ever disabled here, never enabled. Assisted-by: LLM Signed-off-by: Ryan Murray --- src/kboot.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/kboot.c b/src/kboot.c index ff93d4fe6..868c0aff3 100644 --- a/src/kboot.c +++ b/src/kboot.c @@ -2717,10 +2717,13 @@ static int dt_reserve_asc_firmware(const char *adt_path, const char *adt_path_al /* * The AVE video encoder runs firmware that iBoot preloads. The ADT calls the - * encoder "ave" on the A18 Pro and "ave0" on the M4 Pro. The DT node is found - * by its compatible, so describing a SoC's encoder is all it takes. + * encoder "ave" on the M2 and A18 Pro and "ave0" on the M1 Pro/Max and M4 Pro. + * The DT node is found by its compatible, so describing a SoC's encoder is all + * it takes. */ static const char *const ave_compatibles[] = { + "apple,t6000-ave", + "apple,t8112-ave", "apple,t8140-ave", "apple,t6041-ave", };