diff --git a/arch/arm64/boot/dts/apple/t8132-j604.dts b/arch/arm64/boot/dts/apple/t8132-j604.dts index 6078f58f49dfa..8019dd4493dea 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" /* diff --git a/arch/arm64/boot/dts/apple/t8132-j623-j624.dtsi b/arch/arm64/boot/dts/apple/t8132-j623-j624.dtsi index d2ce7a07bfabb..1a80e45a12942 100644 --- a/arch/arm64/boot/dts/apple/t8132-j623-j624.dtsi +++ b/arch/arm64/boot/dts/apple/t8132-j623-j624.dtsi @@ -92,6 +92,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"; +}; + /* * ADT /arm-io/spi4/dp855: the panel timing controller. The J623 and J624 * ADTs give the same chip select as the M4 laptops (spi4 function-spi_cs0, diff --git a/arch/arm64/boot/dts/apple/t8132-j773g.dts b/arch/arm64/boot/dts/apple/t8132-j773g.dts index e60d755e355cb..dac7bc9f69db0 100644 --- a/arch/arm64/boot/dts/apple/t8132-j773g.dts +++ b/arch/arm64/boot/dts/apple/t8132-j773g.dts @@ -427,6 +427,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"; +}; + /* The J773g ADT has no DP855 on spi4. */ &spi4 { /delete-node/ panel-timing-controller@0; diff --git a/drivers/media/platform/apple/ave/ave-abi-test.c b/drivers/media/platform/apple/ave/ave-abi-test.c index 296f6cba2572f..d313db63405b5 100644 --- a/drivers/media/platform/apple/ave/ave-abi-test.c +++ b/drivers/media/platform/apple/ave/ave-abi-test.c @@ -1633,6 +1633,51 @@ 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_ASSERT_EQ(test, n->build_count, 1U); + KUNIT_EXPECT_EQ(test, n->builds[0].text_boot_word, 0x4224U); + KUNIT_EXPECT_EQ(test, n->builds[0].text_crc, AVE_FW_TEXT_CRC_T8132_25G83); + KUNIT_EXPECT_PTR_EQ(test, ave_layout_for_crc(n->builds[0].text_crc), + &ave_layout_9003_78_0); + KUNIT_ASSERT_EQ(test, ave_t8132.build_count, 1U); + KUNIT_EXPECT_PTR_EQ(test, ave_layout_for_crc(ave_t8132.builds[0].text_crc), + &ave_layout_26b123); +} + /* * The M4 Max with the 27.2 stub: its segment sizes select the 27.2 build's * own start (device 25, handshake type 25) and the 26B123 layout; 25G83 @@ -1992,6 +2037,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), KUNIT_CASE(ave_t6041_26b123_build), KUNIT_CASE(ave_hevc_bframe_extra_bits), KUNIT_CASE(ave_t8103_26b123_build), diff --git a/drivers/media/platform/apple/ave/ave-drv.c b/drivers/media/platform/apple/ave/ave-drv.c index c0f6dd664f0df..a633ef05ba588 100644 --- a/drivers/media/platform/apple/ave/ave-drv.c +++ b/drivers/media/platform/apple/ave/ave-drv.c @@ -241,6 +241,34 @@ 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_fw_build ave_t8132_25g83_builds[] = { + { "25G83", 0x148000, 0x12c000, AVE_FW_TEXT_CRC_T8132_25G83, 0x4224 }, +}; + +static const struct ave_variant ave_t8132_25g83 = { + .regs = &ave_coproc_v40, + .builds = ave_t8132_25g83_builds, + .build_count = ARRAY_SIZE(ave_t8132_25g83_builds), + .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, + .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 @@ -248,6 +276,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. */ static const struct ave_fw_build ave_t8132_builds[] = { { "26B123", 0x154000, 0x12c000, AVE_FW_TEXT_CRC_T8132_26B123, 0x4224 }, @@ -265,6 +294,7 @@ const struct ave_variant ave_t8132 = { .device_type = 23, .lfs_ref_scale = 2, .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 7d10df6e0f098..c06f6ea660952 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_T6041_26B123, /* encoder firmware macOS 27.2 26B123 / M4 Max */ 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 */ diff --git a/drivers/media/platform/apple/ave/ave-layout.c b/drivers/media/platform/apple/ave/ave-layout.c index 17bd3579dd17a..d2097c83c81a7 100644 --- a/drivers/media/platform/apple/ave/ave-layout.c +++ b/drivers/media/platform/apple/ave/ave-layout.c @@ -986,9 +986,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 98a378a360d75..d17e0707608cc 100644 --- a/drivers/media/platform/apple/ave/ave.h +++ b/drivers/media/platform/apple/ave/ave.h @@ -200,6 +200,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 /*