From 432ba39c26582a84d0e10603d927e2662171f733 Mon Sep 17 00:00:00 2001 From: Akhil Date: Tue, 24 Nov 2026 16:22:49 +0000 Subject: [PATCH 1/4] media: apple: ave: start the T8132 encoder firmware from the 26.6.2 stub ave_t8132 takes the encoder firmware that the macOS 27.2 (26B123) stub preloads. With the 26.6.2 (25G83) stub the bootloader preloads another build, encoder firmware 9003.78.0, with TEXT 0x148000 and DATA 0x12c000 (ADT ave segment-ranges), and the probe refuses it with "unexpected firmware segment sizes". The capability table in that TEXT has device 26, type 24 as its default target. Started with the same coprocessor registers and start sequence as the 27.2 build, it boots as device 26, accepts the handshake for type 24 and runs H.264 and HEVC sessions with the 9003.78.0 command layout, as on the M4 Pro and M4 Max. Its TEXT CRC, with the per-boot word at 0x4224 zeroed, is 9308d2ab: on the MacBook Air (J713) the word reads zero on every boot so far, on the Mac mini (J773g) it differs per boot. Add the build as ave_t8132_25g83, chained from ave_t8132 through next_build so that the reserved segment sizes select it, add its TEXT CRC to the known list and map it to the 9003.78.0 layout. A KUnit case checks that both stubs' sizes select their own build, start fields and layout. Signed-off-by: Akhil --- .../media/platform/apple/ave/ave-abi-test.c | 43 +++++++++++++++++++ drivers/media/platform/apple/ave/ave-drv.c | 28 ++++++++++++ drivers/media/platform/apple/ave/ave-fw.c | 1 + drivers/media/platform/apple/ave/ave-layout.c | 5 ++- drivers/media/platform/apple/ave/ave.h | 5 +++ 5 files changed, 81 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/apple/ave/ave-abi-test.c b/drivers/media/platform/apple/ave/ave-abi-test.c index 72b7d969169c3..0b765963dce82 100644 --- a/drivers/media/platform/apple/ave/ave-abi-test.c +++ b/drivers/media/platform/apple/ave/ave-abi-test.c @@ -1561,6 +1561,48 @@ static void ave_t8112_26b123_build(struct kunit *test) &ave_layout_6070_11_1); } +/* + * The M4 with the 26.6.2 stub: its segment sizes select the 9003.78.0 build + * (device 26, handshake type 24, the 9003.78.0 layout); the 27.2 stub's sizes + * keep ave_t8132 (device 23, type 23, the 26B123 layout). + */ +static void ave_t8132_25g83_build(struct kunit *test) +{ + const struct ave_variant *n = ave_t8132.next_build; + + KUNIT_ASSERT_NOT_NULL(test, n); + KUNIT_EXPECT_PTR_EQ(test, ave_fw_select_build(&ave_t8132, 0x154000, 0x12c000), + &ave_t8132); + KUNIT_EXPECT_PTR_EQ(test, ave_fw_select_build(&ave_t8132, 0x148000, 0x12c000), n); + /* The near misses fall back to ave_t8132 and are refused by size. */ + KUNIT_EXPECT_PTR_EQ(test, ave_fw_select_build(&ave_t8132, 0x148000, 0x130000), + &ave_t8132); + /* Each stub's sizes match its own build, so the selection is not a miss. */ + KUNIT_EXPECT_TRUE(test, ave_fw_sizes_match(&ave_t8132, 0x154000, 0x12c000)); + KUNIT_EXPECT_FALSE(test, ave_fw_sizes_match(&ave_t8132, 0x148000, 0x130000)); + KUNIT_EXPECT_FALSE(test, ave_fw_sizes_match(n, 0x154000, 0x12c000)); + KUNIT_EXPECT_TRUE(test, ave_fw_sizes_match(n, 0x148000, 0x12c000)); + KUNIT_EXPECT_NULL(test, n->next_build); + KUNIT_EXPECT_TRUE(test, n->boot_qualified); + KUNIT_EXPECT_PTR_EQ(test, n->regs, ave_t8132.regs); + KUNIT_EXPECT_EQ(test, n->boot_device_id, 26U); + KUNIT_EXPECT_EQ(test, n->device_type, 24U); + KUNIT_EXPECT_EQ(test, ave_t8132.boot_device_id, 23U); + KUNIT_EXPECT_EQ(test, ave_t8132.device_type, 23U); + KUNIT_EXPECT_EQ(test, n->boot_arg_value, ave_t8132.boot_arg_value); + KUNIT_EXPECT_EQ(test, n->timebase_multiplier, 1U); + KUNIT_EXPECT_EQ(test, n->vcbar_flags, ave_t8132.vcbar_flags); + KUNIT_EXPECT_EQ(test, n->vcbar_mask, ave_t8132.vcbar_mask); + KUNIT_EXPECT_EQ(test, n->lfs_ref_scale, 2U); + KUNIT_EXPECT_EQ(test, n->text_link_cell, 0U); + /* The Mac mini's loader sets the word at TEXT 0x4224 on every boot. */ + KUNIT_EXPECT_EQ(test, n->text_boot_word, 0x4224U); + KUNIT_EXPECT_EQ(test, n->text_crc, AVE_FW_TEXT_CRC_T8132_25G83); + KUNIT_EXPECT_PTR_EQ(test, ave_layout_for_crc(n->text_crc), &ave_layout_9003_78_0); + KUNIT_EXPECT_PTR_EQ(test, ave_layout_for_crc(ave_t8132.text_crc), + &ave_layout_26b123); +} + static void ave_t6041_text_boot_word(struct kunit *test) { const u32 off = ave_t6041.text_boot_word, size = off + 0x100; @@ -1635,6 +1677,7 @@ static struct kunit_case ave_abi_cases[] = { KUNIT_CASE(ave_m3_probe_only), KUNIT_CASE(ave_26b123_layout), KUNIT_CASE(ave_t8112_26b123_build), + KUNIT_CASE(ave_t8132_25g83_build), {} }; diff --git a/drivers/media/platform/apple/ave/ave-drv.c b/drivers/media/platform/apple/ave/ave-drv.c index a5897fe998f6c..18d5bc2412eed 100644 --- a/drivers/media/platform/apple/ave/ave-drv.c +++ b/drivers/media/platform/apple/ave/ave-drv.c @@ -166,6 +166,32 @@ static const struct ave_variant ave_t8122 = { .boot_qualified = true, }; +/* + * The M4 (T8132) with the 26.6.2 (25G83) stub: the bootloader preloads TEXT + * 0x148000 and DATA 0x12c000, TEXT CRC 9308d2ab (encoder firmware 9003.78.0) + * with the per-boot word at 0x4224 zeroed. The MacBook Air (J713) has read + * that CRC with the word as loaded on every boot so far; on the Mac mini + * (J773g) the word differs per boot. The capability table in that TEXT has + * device 26, type 24 as its default target: with the M4 Pro's coprocessor + * and start it boots as device 26, takes handshake type 24 and speaks the + * 9003.78.0 command layout. + */ +static const struct ave_variant ave_t8132_25g83 = { + .regs = &ave_coproc_v40, + .fw_text_size = 0x148000, + .fw_data_size = 0x12c000, + .boot_device_id = 26, + .boot_arg_value = AVE_COPROC_BOOT_ARG_VALUE, + .timebase_multiplier = 1, + .vcbar_mask = U64_MAX, + .vcbar_flags = AVE_COPROC_VCBAR_VALID, + .device_type = 24, + .lfs_ref_scale = 2, + .text_crc = AVE_FW_TEXT_CRC_T8132_25G83, + .text_boot_word = 0x4224, + .boot_qualified = true, +}; + /* * The M4 (T8132) with the macOS 27.2 (26B123) stub: the bootloader preloads * TEXT 0x154000 and DATA 0x12c000, TEXT CRC 99fc929a with the per-boot word @@ -173,6 +199,7 @@ static const struct ave_variant ave_t8122 = { * others set it on every boot (the Mac mini, J773g, raw CRC f641c64b), so an * unknown CRC is retried with it zeroed. The coprocessor and its start are * the M4 Pro's; this build boots as device 23 and takes handshake type 23. + * The 26.6.2 stub's build, selected by its segment sizes, is ave_t8132_25g83. */ const struct ave_variant ave_t8132 = { .regs = &ave_coproc_v40, @@ -188,6 +215,7 @@ const struct ave_variant ave_t8132 = { .text_crc = AVE_FW_TEXT_CRC_T8132_26B123, .text_boot_word = 0x4224, .boot_qualified = true, + .next_build = &ave_t8132_25g83, }; 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 49f1da033411f..bdcfa67f3b4b8 100644 --- a/drivers/media/platform/apple/ave/ave-fw.c +++ b/drivers/media/platform/apple/ave/ave-fw.c @@ -40,6 +40,7 @@ static const u32 ave_known_text_crc[] = { 0x69c54454, /* encoder firmware 9003.78.0 (macOS 26.0.x) */ AVE_FW_TEXT_CRC_T6040_25G83, /* encoder firmware 9003.78.0 / T6040 */ AVE_FW_TEXT_CRC_T6041_25G83, /* encoder firmware 9003.78.0 / M4 Max */ + AVE_FW_TEXT_CRC_T8132_25G83, /* encoder firmware 9003.78.0 / T8132 */ AVE_FW_TEXT_CRC_T6050_26A428, /* encoder firmware macOS 27.0 26A428 / T6050 */ AVE_FW_TEXT_CRC_T6050_26C5035, /* encoder firmware macOS 27.3 26C5035r / T6050 */ AVE_FW_TEXT_CRC_T8142_26A428, /* encoder firmware 9013.45.1, macOS 27.0 26A428 / T8142 */ diff --git a/drivers/media/platform/apple/ave/ave-layout.c b/drivers/media/platform/apple/ave/ave-layout.c index 377406027f9ab..8c84643a2c453 100644 --- a/drivers/media/platform/apple/ave/ave-layout.c +++ b/drivers/media/platform/apple/ave/ave-layout.c @@ -974,9 +974,12 @@ const struct ave_fw_layout *ave_layout_for_crc(u32 crc) /* * The M4 Pro and M4 Max get the same 25G83 firmware build as the * A18 Pro, built for their own chips, and speak the same command layout. + * So does the M4 (T8132) with the 26.6.2 stub: on J713, H.264 and HEVC + * sessions with this layout encode streams that decode correctly. */ if (crc == AVE_FW_TEXT_CRC_9003_78_0 || crc == AVE_FW_TEXT_CRC_T6040_25G83 || - crc == AVE_FW_TEXT_CRC_T6041_25G83) + crc == AVE_FW_TEXT_CRC_T6041_25G83 || + crc == AVE_FW_TEXT_CRC_T8132_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 a0bda7749166a..e09413b500608 100644 --- a/drivers/media/platform/apple/ave/ave.h +++ b/drivers/media/platform/apple/ave/ave.h @@ -182,6 +182,11 @@ enum ave_opcode { #define AVE_FW_TEXT_CRC_T8142_26A428 0x8a3784bd /* The M4 (T8132) build preloaded by the macOS 27.2 (26B123) stub. */ #define AVE_FW_TEXT_CRC_T8132_26B123 0x99fc929a +/* + * The M4 (T8132) build of encoder firmware 9003.78.0, preloaded by the + * 26.6.2 (25G83) stub, with the per-boot word at TEXT 0x4224 zeroed. + */ +#define AVE_FW_TEXT_CRC_T8132_25G83 0x9308d2ab /* The M3 (T8122) build preloaded by the macOS 27.2 (26B123) stub. */ #define AVE_FW_TEXT_CRC_T8122_26B123 0x918d70d3 /* From 340a4770bb339d564b89c25e59f7edcefadb45b8 Mon Sep 17 00:00:00 2001 From: Akhil Date: Tue, 24 Nov 2026 16:22:49 +0000 Subject: [PATCH 2/4] arm64: dts: apple: t8132-j773g: enable the video encoder Enable the AVE encoder, its two DARTs and its six VENC power domains on the Mac mini (M4, J773g), as t8132-j713-j715.dtsi does for the MacBook Air. State the VENC domains in the board tree rather than relying on the T8132 PMGR policy for a domain the board leaves without a status: on a Mac mini M4 (J773g) running an earlier tree, the VENC domains came up disabled that way, and the encoder DARTs deferred until the probe timed out. Tested on a J773g with the 26.6.2 stub, on an earlier revision of this series (before its rebase onto main): H.264 and HEVC 1080p encode at 45.3/46.3 dB PSNR, all frames decodable, no DART faults. Signed-off-by: Akhil --- arch/arm64/boot/dts/apple/t8132-j773g.dts | 36 +++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/arch/arm64/boot/dts/apple/t8132-j773g.dts b/arch/arm64/boot/dts/apple/t8132-j773g.dts index 2a8ca64d3a638..cefd81346f817 100644 --- a/arch/arm64/boot/dts/apple/t8132-j773g.dts +++ b/arch/arm64/boot/dts/apple/t8132-j773g.dts @@ -297,3 +297,39 @@ &avd { status = "okay"; }; + +&ps_venc_sys { + status = "okay"; +}; + +&ps_venc_dma { + status = "okay"; +}; + +&ps_venc_pipe4 { + status = "okay"; +}; + +&ps_venc_pipe5 { + status = "okay"; +}; + +&ps_venc_me0 { + status = "okay"; +}; + +&ps_venc_me1 { + status = "okay"; +}; + +&dart_ave0 { + status = "okay"; +}; + +&dart_ave1 { + status = "okay"; +}; + +&ave { + status = "okay"; +}; From f5b9d7e92fa67b71411d52c58449b6061c44db81 Mon Sep 17 00:00:00 2001 From: Akhil Date: Tue, 24 Nov 2026 16:22:49 +0000 Subject: [PATCH 3/4] arm64: dts: apple: t8132-j604: enable the video encoder Enable the AVE encoder, its two DARTs and its six VENC power domains on the MacBook Pro (14-inch, M4, J604), as t8132-j713-j715.dtsi does for the MacBook Air. State the VENC domains in the board tree rather than relying on the T8132 PMGR policy for a domain the board leaves without a status: on a Mac mini M4 (J773g) running an earlier tree, the VENC domains came up disabled that way, and the encoder DARTs deferred until the probe timed out. Untested on J604: the encoder, its DARTs and power domains are T8132 SoC blocks, the same as on the MacBook Air M4 (J713) and the Mac mini M4 (J773g), where this configuration encodes. Signed-off-by: Akhil --- arch/arm64/boot/dts/apple/t8132-j604.dts | 36 ++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/arch/arm64/boot/dts/apple/t8132-j604.dts b/arch/arm64/boot/dts/apple/t8132-j604.dts index e5ce3b6286b3f..28c4d747ed142 100644 --- a/arch/arm64/boot/dts/apple/t8132-j604.dts +++ b/arch/arm64/boot/dts/apple/t8132-j604.dts @@ -373,6 +373,42 @@ status = "okay"; }; +&ps_venc_sys { + status = "okay"; +}; + +&ps_venc_dma { + status = "okay"; +}; + +&ps_venc_pipe4 { + status = "okay"; +}; + +&ps_venc_pipe5 { + status = "okay"; +}; + +&ps_venc_me0 { + status = "okay"; +}; + +&ps_venc_me1 { + status = "okay"; +}; + +&dart_ave0 { + status = "okay"; +}; + +&dart_ave1 { + status = "okay"; +}; + +&ave { + status = "okay"; +}; + #include "t8132-j604-atcphy-tunables.dtsi" /* From beb3be60f2317d0ffe866d17a72d5059952098aa Mon Sep 17 00:00:00 2001 From: Akhil Date: Tue, 24 Nov 2026 16:22:50 +0000 Subject: [PATCH 4/4] arm64: dts: apple: t8132-j623-j624: enable the video encoder Enable the AVE encoder, its two DARTs and its six VENC power domains on the iMac (24-inch, M4, J623 and J624), as t8132-j713-j715.dtsi does for the MacBook Air. State the VENC domains in the board tree rather than relying on the T8132 PMGR policy for a domain the board leaves without a status: on a Mac mini M4 (J773g) running an earlier tree, the VENC domains came up disabled that way, and the encoder DARTs deferred until the probe timed out. Untested on J623/J624: the encoder, its DARTs and power domains are T8132 SoC blocks, the same as on the MacBook Air M4 (J713) and the Mac mini M4 (J773g), where this configuration encodes. Signed-off-by: Akhil --- .../arm64/boot/dts/apple/t8132-j623-j624.dtsi | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/arch/arm64/boot/dts/apple/t8132-j623-j624.dtsi b/arch/arm64/boot/dts/apple/t8132-j623-j624.dtsi index ec07e49b3da46..e0a2dbe82fc75 100644 --- a/arch/arm64/boot/dts/apple/t8132-j623-j624.dtsi +++ b/arch/arm64/boot/dts/apple/t8132-j623-j624.dtsi @@ -91,3 +91,39 @@ &avd { status = "okay"; }; + +&ps_venc_sys { + status = "okay"; +}; + +&ps_venc_dma { + status = "okay"; +}; + +&ps_venc_pipe4 { + status = "okay"; +}; + +&ps_venc_pipe5 { + status = "okay"; +}; + +&ps_venc_me0 { + status = "okay"; +}; + +&ps_venc_me1 { + status = "okay"; +}; + +&dart_ave0 { + status = "okay"; +}; + +&dart_ave1 { + status = "okay"; +}; + +&ave { + status = "okay"; +};