From d6c1322d85e31b3880e90df305e9d96d8fb2ae58 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sat, 31 Oct 2026 23:28:01 +1100 Subject: [PATCH 1/2] media: apple: ave: encode on the M4 Pro The M4 Pro boots Linux from a 26.6.2 (25G83) stub, so iBoot preloads the 25G83 build of the AVE firmware for its chip: TEXT 0x14c000, CRC 0x68d5f9f6. That is the build the A18 Pro runs (0x69c54454), compiled for the M4 Pro, and its command parser takes the same Config, Open, Start and Process layout. The macOS 25G83 driver builds identical commands for both chips. What differs is the chip identity. The M4 Pro is AVE device 27 with device type 25 (the A18 Pro is 29 and 27). Its coprocessor uses the same registers and start sequence as the A18 Pro. Select the existing layout for this CRC, and give the T6041 match data the coprocessor registers, device ID, device type, the A18 Pro boot argument, timebase and VCBAR encoding, and the qualified boot flag. Other firmware builds are still refused, the macOS 27.0 one included (TEXT 0x154000), whose commands are laid out differently. Assisted-by: LLM Signed-off-by: Ryan Murray --- drivers/media/platform/apple/ave/ave-drv.c | 14 +++++++++++++- drivers/media/platform/apple/ave/ave-fw.c | 1 + drivers/media/platform/apple/ave/ave-layout.c | 6 +++++- drivers/media/platform/apple/ave/ave.h | 2 ++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/apple/ave/ave-drv.c b/drivers/media/platform/apple/ave/ave-drv.c index 908ada4ce87a1..246d49d91b864 100644 --- a/drivers/media/platform/apple/ave/ave-drv.c +++ b/drivers/media/platform/apple/ave/ave-drv.c @@ -81,11 +81,23 @@ const struct ave_variant ave_t8112 = { .boot_qualified = true, }; -/* CRC, boot-config words and coprocessor start registers remain unqualified. */ +/* + * The M4 Pro (T6040 in the ADT, apple,t6041 in the DT) starts its encoder + * like the A18 Pro: same coprocessor registers and boot sequence, its own + * device ID and type. + */ static const struct ave_variant ave_t6041 = { + .regs = &ave_coproc_v40, .fw_text_size = 0x14c000, .fw_data_size = 0x12c000, + .boot_device_id = 27, + .boot_arg_value = AVE_COPROC_BOOT_ARG_VALUE, + .timebase_multiplier = 1, + .vcbar_mask = U64_MAX, + .vcbar_flags = AVE_COPROC_VCBAR_VALID, + .device_type = 25, .lfs_ref_scale = 2, + .boot_qualified = true, }; static const struct ave_variant ave_t8140 = { diff --git a/drivers/media/platform/apple/ave/ave-fw.c b/drivers/media/platform/apple/ave/ave-fw.c index 705588b918ce7..4311e8874a6c1 100644 --- a/drivers/media/platform/apple/ave/ave-fw.c +++ b/drivers/media/platform/apple/ave/ave-fw.c @@ -36,6 +36,7 @@ static const u32 ave_known_text_crc[] = { 0x2ce7359e, /* AppleAVE2FW 9003.78.0 */ 0x69c54454, /* AppleAVE2FW 9003.78.0 (macOS 26.0.x) */ + AVE_FW_TEXT_CRC_T6040_25G83, /* AppleAVE2FW 9003.78.0 / T6040 */ 0x460c7a7c, /* AppleAVE2FW 6070.11.1 / T6000 */ 0x25bfd039, /* AppleAVE2FW 6070.11.1 / T8112 */ }; diff --git a/drivers/media/platform/apple/ave/ave-layout.c b/drivers/media/platform/apple/ave/ave-layout.c index 91c50ea083f70..30d4d07d3abbd 100644 --- a/drivers/media/platform/apple/ave/ave-layout.c +++ b/drivers/media/platform/apple/ave/ave-layout.c @@ -529,7 +529,11 @@ const struct ave_fw_layout ave_layout_6070_11_1 = { const struct ave_fw_layout *ave_layout_for_crc(u32 crc) { - if (crc == AVE_FW_TEXT_CRC_9003_78_0) + /* + * The M4 Pro gets the same 25G83 firmware build as the A18 Pro, built + * for its own chip, and speaks the same command layout. + */ + if (crc == AVE_FW_TEXT_CRC_9003_78_0 || crc == AVE_FW_TEXT_CRC_T6040_25G83) return &ave_layout_9003_78_0; if (crc == 0x460c7a7c || crc == 0x25bfd039) return &ave_layout_6070_11_1; diff --git a/drivers/media/platform/apple/ave/ave.h b/drivers/media/platform/apple/ave/ave.h index 47a8de278011c..8358e7d26fe3e 100644 --- a/drivers/media/platform/apple/ave/ave.h +++ b/drivers/media/platform/apple/ave/ave.h @@ -127,6 +127,8 @@ enum ave_opcode { /* The firmware build whose command layouts the driver generates */ #define AVE_FW_TEXT_CRC_9003_78_0 0x69c54454 +/* The M4 Pro (T6040) build of the same 25G83 firmware. */ +#define AVE_FW_TEXT_CRC_T6040_25G83 0x68d5f9f6 struct ave_ctx; From e89b8449e53c887e450576e86644576e3ba8cca3 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sat, 31 Oct 2026 23:28:01 +1100 Subject: [PATCH 2/2] arm64: dts: apple: t6040-j616s: enable the video encoder Enable the AVE encoder on the J616s together with its two DARTs and the six VENC power domains it sits in. The loader disables the node again when the firmware is not preloaded or cannot be reserved. Both AVE DARTs get a 4 GiB DMA window above the firmware at 0x100_0000_0000. The ADT gives these DARTs a 0x100_0000_0000 + 0x300_0000_0000 VM range, and macOS keeps every encoder address in 0x100_xxxx_xxxx. A 4K session needs about 180 MiB of encoder buffers before its frame queues, so the 256 MiB the A18 Pro DT uses is not enough. Assisted-by: LLM Signed-off-by: Ryan Murray --- arch/arm64/boot/dts/apple/t6040-j616s.dts | 37 +++++++++++++++++++++++ arch/arm64/boot/dts/apple/t6040.dtsi | 4 +-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/arch/arm64/boot/dts/apple/t6040-j616s.dts b/arch/arm64/boot/dts/apple/t6040-j616s.dts index 760840b14e37a..25cded4aa83df 100644 --- a/arch/arm64/boot/dts/apple/t6040-j616s.dts +++ b/arch/arm64/boot/dts/apple/t6040-j616s.dts @@ -4512,6 +4512,43 @@ }; }; +/* The video encoder, its DARTs and its power domains. */ +&ps_venc0_sys { + status = "okay"; +}; + +&ps_venc0_dma { + status = "okay"; +}; + +&ps_venc0_pipe4 { + status = "okay"; +}; + +&ps_venc0_pipe5 { + status = "okay"; +}; + +&ps_venc0_me0 { + status = "okay"; +}; + +&ps_venc0_me1 { + status = "okay"; +}; + +&ave0_dart0 { + status = "okay"; +}; + +&ave0_dart1 { + status = "okay"; +}; + +&ave { + status = "okay"; +}; + #include "t6040-j616s-usb3.dtsi" /* External display chain, all disabled: the gate in drivers/soc/apple/display-gate.c enables it. */ diff --git a/arch/arm64/boot/dts/apple/t6040.dtsi b/arch/arm64/boot/dts/apple/t6040.dtsi index 8377a06f610f2..a33ef2e0abf83 100644 --- a/arch/arm64/boot/dts/apple/t6040.dtsi +++ b/arch/arm64/boot/dts/apple/t6040.dtsi @@ -1885,7 +1885,7 @@ compatible = "apple,t6041-dart", "apple,t8110-dart"; reg = <0x2 0x83080000 0x0 0xc000>; #iommu-cells = <1>; - apple,dma-range = <0x100 0x0 0x300 0x0>; + apple,dma-range = <0x100 0x00004000 0x0 0xffffc000>; interrupt-parent = <&aic>; interrupts = ; power-domains = <&ps_venc0_sys>; @@ -1896,7 +1896,7 @@ compatible = "apple,t6041-dart", "apple,t8110-dart"; reg = <0x2 0x830a0000 0x0 0xc000>; #iommu-cells = <1>; - apple,dma-range = <0x100 0x0 0x300 0x0>; + apple,dma-range = <0x100 0x00004000 0x0 0xffffc000>; interrupt-parent = <&aic>; interrupts = ; power-domains = <&ps_venc0_sys>;