diff --git a/drivers/media/platform/apple/ave/ave-drv.c b/drivers/media/platform/apple/ave/ave-drv.c index 1f1aedcd8b48a..61bdb862ad929 100644 --- a/drivers/media/platform/apple/ave/ave-drv.c +++ b/drivers/media/platform/apple/ave/ave-drv.c @@ -188,7 +188,8 @@ static const struct ave_variant ave_t6050 = { /* * The M5 (T8142) with the macOS 27.0 stub runs the 26A428 build of the * firmware compiled for its chip (AppleAVE2FW_H17G, 9013.45.1, the version - * T6050 runs): TEXT 0x154000 and DATA 0x12c000, TEXT CRC 8a3784bd. + * T6050 runs): TEXT 0x154000 and DATA 0x12c000, TEXT CRC 8a3784bd. The 27.2 + * stub's build (9013.55.1) has the same segment sizes, so its CRC selects it. * * The chip identity comes from AppleAVE2's soc-id table (ADT ave soc-id * "t8142"): device 27, generation 16. The 26A428 firmware carries the same @@ -197,10 +198,18 @@ static const struct ave_variant ave_t6050 = { * T6050's SVE register block, so the idle word at mailbox +0x118 is cleared * before the start as there. The coprocessor is the A18 Pro's. */ +static const struct ave_fw_build ave_t8142_builds[] = { + { "26A428", 0x154000, 0x12c000, AVE_FW_TEXT_CRC_T8142_26A428 }, + /* macOS 27.2 (and 27.2.1): CRC from the image, 26A428's command layout. */ + { "26B123", 0x154000, 0x12c000, AVE_FW_TEXT_CRC_T8142_26B123 }, +}; + static const struct ave_variant ave_t8142 = { .regs = &ave_coproc_v40, .fw_text_size = 0x154000, .fw_data_size = 0x12c000, + .builds = ave_t8142_builds, + .build_count = ARRAY_SIZE(ave_t8142_builds), .boot_device_id = 27, .boot_arg_value = AVE_COPROC_BOOT_ARG_VALUE, .timebase_multiplier = 1, diff --git a/drivers/media/platform/apple/ave/ave-fw.c b/drivers/media/platform/apple/ave/ave-fw.c index 8dce45575ba45..52cd41e7d3dc7 100644 --- a/drivers/media/platform/apple/ave/ave-fw.c +++ b/drivers/media/platform/apple/ave/ave-fw.c @@ -44,6 +44,7 @@ static const u32 ave_known_text_crc[] = { AVE_FW_TEXT_CRC_T6050_26C5035, /* AppleAVE2FW, macOS 27.3 26C5035r / T6050 */ AVE_FW_TEXT_CRC_T8142_26A428, /* AppleAVE2FW 9013.45.1, macOS 27.0 26A428 / T8142 */ AVE_FW_TEXT_CRC_T8122_26B123, /* AppleAVE2FW, macOS 27.2 26B123 / T8122 */ + AVE_FW_TEXT_CRC_T8142_26B123, /* AppleAVE2FW 9013.55.1, macOS 27.2 26B123 / T8142 */ 0x460c7a7c, /* AppleAVE2FW 6070.11.1 / T6000 */ 0x25bfd039, /* AppleAVE2FW 6070.11.1 / T8112 */ }; @@ -218,12 +219,16 @@ static int ave_fw_text_id(struct ave_dev *ave, u32 *crc) return ret; } -/* The variant's build with these segment sizes, or NULL. */ +/* + * The variant's build with these segment sizes and, unless crc is 0, this + * TEXT CRC, or NULL. Builds may share segment sizes; the CRC tells them apart. + */ static const struct ave_fw_build *ave_fw_find_build(const struct ave_variant *v, - size_t text, size_t data) + size_t text, size_t data, u32 crc) { for (unsigned int i = 0; i < v->build_count; i++) - if (text == v->builds[i].text_size && data == v->builds[i].data_size) + if (text == v->builds[i].text_size && data == v->builds[i].data_size && + (!crc || crc == v->builds[i].text_crc)) return &v->builds[i]; return NULL; } @@ -252,7 +257,7 @@ int ave_fw_probe(struct ave_dev *ave) if (ave->variant->build_count) { build = ave_fw_find_build(ave->variant, ave->text.size, - ave->data.size); + ave->data.size, 0); if (!build) return dev_err_probe(dev, -EINVAL, "unexpected firmware segment sizes (TEXT %#zx DATA %#zx)\n", @@ -304,6 +309,16 @@ int ave_fw_probe(struct ave_dev *ave) return dev_err_probe(dev, ret, "firmware text link cell is not the DATA address\n"); known |= ave_fw_known_crc(text_crc); + if (build) { + const struct ave_fw_build *same_size = + ave_fw_find_build(ave->variant, ave->text.size, + ave->data.size, text_crc); + + if (same_size) { + build = same_size; + want_crc = build->text_crc; + } + } if (!known || (want_crc && text_crc != want_crc)) return dev_err_probe(dev, -ENODEV, "unsupported firmware (text CRC %08x)\n", diff --git a/drivers/media/platform/apple/ave/ave-layout.c b/drivers/media/platform/apple/ave/ave-layout.c index 7f739b2601c10..66ea4918f0d59 100644 --- a/drivers/media/platform/apple/ave/ave-layout.c +++ b/drivers/media/platform/apple/ave/ave-layout.c @@ -997,5 +997,13 @@ const struct ave_fw_layout *ave_layout_for_crc(u32 crc) if (crc == AVE_FW_TEXT_CRC_T8132_26B123 || crc == AVE_FW_TEXT_CRC_T8122_26B123) return &ave_layout_26b123; + /* + * The M5's macOS 27.2 build (9013.55.1), between 26A428 and the 27.3 + * beta, speaks 26A428's layout: on the J815's 27.2 stub, H.264 + * Baseline (ffmpeg), H.264 and HEVC with B-frames (v4l2-ctl) encode + * with it. + */ + if (crc == AVE_FW_TEXT_CRC_T8142_26B123) + return &ave_layout_26a428; return NULL; } diff --git a/drivers/media/platform/apple/ave/ave.h b/drivers/media/platform/apple/ave/ave.h index dc6c86a6664cb..26996032d4ac6 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_T8132_26B123 0x99fc929a /* The M3 (T8122) build preloaded by the macOS 27.2 (26B123) stub. */ #define AVE_FW_TEXT_CRC_T8122_26B123 0x918d70d3 +/* + * The M5 build of macOS 27.2 (26B123; 27.2.1 26B131 ships it unchanged), + * AppleAVE2FW 9013.55.1: TEXT 0x154000, DATA 0x12c000, as 26A428's. + */ +#define AVE_FW_TEXT_CRC_T8142_26B123 0x24eb4625 struct ave_ctx;