Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions arch/arm64/boot/dts/apple/t8132-j604.dts
Original file line number Diff line number Diff line change
Expand Up @@ -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"

/*
Expand Down
36 changes: 36 additions & 0 deletions arch/arm64/boot/dts/apple/t8132-j623-j624.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -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";
};
36 changes: 36 additions & 0 deletions arch/arm64/boot/dts/apple/t8132-j773g.dts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
};
43 changes: 43 additions & 0 deletions drivers/media/platform/apple/ave/ave-abi-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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),
{}
};

Expand Down
28 changes: 28 additions & 0 deletions drivers/media/platform/apple/ave/ave-drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,40 @@ 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
* at 0x4224 zeroed. Some loaders leave that word zero (the MacBook Air, J713),
* 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,
Expand All @@ -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 = {
Expand Down
1 change: 1 addition & 0 deletions drivers/media/platform/apple/ave/ave-fw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
5 changes: 4 additions & 1 deletion drivers/media/platform/apple/ave/ave-layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions drivers/media/platform/apple/ave/ave.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
/*
Expand Down
Loading