diff --git a/Documentation/devicetree/bindings/media/apple,prores.yaml b/Documentation/devicetree/bindings/media/apple,prores.yaml index 0446d7aa9599..6d9c2231222c 100644 --- a/Documentation/devicetree/bindings/media/apple,prores.yaml +++ b/Documentation/devicetree/bindings/media/apple,prores.yaml @@ -12,9 +12,10 @@ maintainers: description: | The APR is a directly programmed ProRes engine with its own DART. Jobs are descriptors in a DMA ring; the engine signals completion with an - interrupt. On T6041 and T6050 a per-machine initialization table, - apple/prores-t6041-init.bin or apple/prores-t6050-init.bin, takes the - place of any rows built into the driver. Other supported variants have no + interrupt. On T8132, T6041 and T6050 a per-machine initialization table, + apple/prores-t8132-init.bin, apple/prores-t6041-init.bin or + apple/prores-t6050-init.bin, takes the place of any rows built into the + driver. Other supported variants have no firmware. The engine's power domain also resets it. diff --git a/arch/arm64/boot/dts/apple/t8132-j604.dts b/arch/arm64/boot/dts/apple/t8132-j604.dts index 0ac0e9240a3d..e7d6be189255 100644 --- a/arch/arm64/boot/dts/apple/t8132-j604.dts +++ b/arch/arm64/boot/dts/apple/t8132-j604.dts @@ -638,3 +638,15 @@ &jack_codec { cirrus,ring-sense-detect; }; + +/* + * ProRes: the engine and its DART. The driver binds the T8132 engine whenever + * apple/prores-t8132-init.bin is installed and leaves it off without it. + */ +&dart_apr0 { + status = "okay"; +}; + +&apr { + status = "okay"; +}; diff --git a/arch/arm64/boot/dts/apple/t8132-peripherals.dtsi b/arch/arm64/boot/dts/apple/t8132-peripherals.dtsi index a3fb9d53331b..f8a5a351d011 100644 --- a/arch/arm64/boot/dts/apple/t8132-peripherals.dtsi +++ b/arch/arm64/boot/dts/apple/t8132-peripherals.dtsi @@ -443,6 +443,7 @@ reg = <0x2 0x81000000 0x0 0x4000>, <0x2 0x80000000 0x0 0x1000000>, <0x2 0x810c0000 0x0 0x4000>; + reg-names = "core", "wrapper", "aux"; interrupt-parent = <&aic>; interrupts = , ; diff --git a/drivers/media/platform/apple/prores/Kconfig b/drivers/media/platform/apple/prores/Kconfig index d41429f7757e..27ffadcfcad5 100644 --- a/drivers/media/platform/apple/prores/Kconfig +++ b/drivers/media/platform/apple/prores/Kconfig @@ -9,10 +9,11 @@ config VIDEO_APPLE_PRORES select VIDEOBUF2_DMA_CONTIG help V4L2 memory-to-memory driver for the ProRes encoder engine (APR) - in Apple M1 Pro (T6000), M4 Pro (T6041), M5 (T8142), M5 Pro/Max - (T6050) and A18 Pro (T8140) SoCs. On T6041, T8142 and T6050 a - per-machine apple/prores--init.bin takes the place of the - built-in initialization rows. It encodes 8 + in Apple M1 Pro (T6000), M4 (T8132), M4 Pro (T6041), M5 (T8142), + M5 Pro/Max (T6050) and A18 Pro (T8140) SoCs. On T6041, T8142 and + T6050 a per-machine apple/prores--init.bin takes the place of + the built-in initialization rows; T8132 has no built-in rows and + binds only with apple/prores-t8132-init.bin. It encodes 8 and 16 bit 4:2:2 and 4:4:4 frames to ProRes 422 Proxy, LT, 422, HQ, 4444 and 4444 XQ. diff --git a/drivers/media/platform/apple/prores/apple-prores-drv.c b/drivers/media/platform/apple/prores/apple-prores-drv.c index e5f7d939297c..f75dd6d5b3d2 100644 --- a/drivers/media/platform/apple/prores/apple-prores-drv.c +++ b/drivers/media/platform/apple/prores/apple-prores-drv.c @@ -1045,6 +1045,22 @@ static const struct apr_variant apr_t6041 = { .apri = &apri_t6041, }; +/* T6041's engine and windows, with T8132's own wrapper table; no built-in rows. */ +static const struct apr_variant apr_t8132 = { + .build_desc = apr_build_desc, + .stats = { + { APR_REG_STATS0_LO, APR_REG_STATS0_HI, APR_REG_STATS0_SIZE }, + { APR_REG_STATS1_LO, APR_REG_STATS1_HI, APR_REG_STATS1_SIZE }, + }, + .reg_names = { "core", "wrapper", "aux" }, + .num_regs = 3, + .num_irqs = 1, + .ring_bytes = APR_RING_BYTES, + .desc_bytes = APR_DESC_BYTES, + .firmware_name = APRI_T8132_FIRMWARE_NAME, + .apri = &apri_t8132, +}; + /* T6041's engine plus the SCODEC control window. */ static const struct apr_variant apr_t6050 = { .build_desc = apr_build_desc, @@ -2162,6 +2178,7 @@ static const struct of_device_id apr_of_match[] = { { .compatible = "apple,t6000-prores", .data = &apr_t6000 }, { .compatible = "apple,t6041-prores", .data = &apr_t6041 }, { .compatible = "apple,t6050-prores", .data = &apr_t6050 }, + { .compatible = "apple,t8132-prores", .data = &apr_t8132 }, { .compatible = "apple,t8140-prores", .data = &apr_t8140 }, { .compatible = "apple,t8142-prores", .data = &apr_t8142 }, { } @@ -2183,4 +2200,5 @@ MODULE_DESCRIPTION("Apple ProRes encoder"); MODULE_LICENSE("GPL"); MODULE_FIRMWARE(APRI_T6041_FIRMWARE_NAME); MODULE_FIRMWARE(APRI_T6050_FIRMWARE_NAME); +MODULE_FIRMWARE(APRI_T8132_FIRMWARE_NAME); MODULE_FIRMWARE(APRI_T8142_FIRMWARE_NAME); diff --git a/drivers/media/platform/apple/prores/apple-prores-fw.c b/drivers/media/platform/apple/prores/apple-prores-fw.c index 2b1b9f227c89..66b64c4ddbcf 100644 --- a/drivers/media/platform/apple/prores/apple-prores-fw.c +++ b/drivers/media/platform/apple/prores/apple-prores-fw.c @@ -24,6 +24,10 @@ static_assert(APRI_T6050_FIRMWARE_SIZE == APRI_HEADER_SIZE + APRI_T6050_BLOCKS * APRI_BLOCK_HEADER_SIZE + (APRI_SYSTEM_COUNT + APRI_CORE_COUNT + APRI_WRAPPER_COUNT + APRI_CONTROL_COUNT) * APRI_ENTRY_SIZE); +static_assert(APRI_T8132_FIRMWARE_SIZE == + APRI_HEADER_SIZE + APRI_T6041_BLOCKS * APRI_BLOCK_HEADER_SIZE + + (APRI_SYSTEM_COUNT + APRI_CORE_COUNT + APRI_T8132_WRAPPER_COUNT) * + APRI_ENTRY_SIZE); static_assert(APRI_T8142_FIRMWARE_SIZE == APRI_HEADER_SIZE + APRI_T8142_BLOCKS * APRI_BLOCK_HEADER_SIZE + @@ -50,6 +54,16 @@ const struct apri_layout apri_t6050 = { }; EXPORT_SYMBOL_IF_KUNIT(apri_t6050); +/* T8132 has T6041's three blocks; its wrapper table is 48 rows. */ +const struct apri_layout apri_t8132 = { + .soc = 0x8132, + .blocks = APRI_T6041_BLOCKS, + .size = APRI_T8132_FIRMWARE_SIZE, + .counts = { APRI_SYSTEM_COUNT, APRI_CORE_COUNT, APRI_T8132_WRAPPER_COUNT }, + .limits = { 0x4000, 0x4000, 0x1000000 }, +}; +EXPORT_SYMBOL_IF_KUNIT(apri_t8132); + /* * T8142 has T6050's four blocks. macOS 27.2.1 on a J815 writes the same 82 * system, 80 core and 12 control offsets, and 38 wrapper rows. diff --git a/drivers/media/platform/apple/prores/apple-prores-test.c b/drivers/media/platform/apple/prores/apple-prores-test.c index 7e5479327142..7e6fdd60199f 100644 --- a/drivers/media/platform/apple/prores/apple-prores-test.c +++ b/drivers/media/platform/apple/prores/apple-prores-test.c @@ -442,6 +442,47 @@ static void apr_test_apri_t6050(struct kunit *test) KUNIT_EXPECT_EQ(test, apr_parse_init(&apri_t6050, data, pos, init), -EINVAL); } +/* A T8132 container: T6041's blocks with a 48-row wrapper table. */ +static void apr_test_apri_t8132(struct kunit *test) +{ + static const u32 counts[APRI_T6041_BLOCKS] = { + APRI_SYSTEM_COUNT, APRI_CORE_COUNT, APRI_T8132_WRAPPER_COUNT, + }; + struct apr_init_data *init = kunit_kzalloc(test, sizeof(*init), GFP_KERNEL); + u8 *data = kunit_kzalloc(test, APRI_T8132_FIRMWARE_SIZE, GFP_KERNEL); + size_t pos = 16; + u32 block, entry; + + KUNIT_ASSERT_NOT_NULL(test, init); + KUNIT_ASSERT_NOT_NULL(test, data); + memcpy(data, "APRI", 4); + put_unaligned_le32(1, data + 4); + put_unaligned_le32(0x8132, data + 8); + put_unaligned_le32(APRI_T6041_BLOCKS, data + 12); + for (block = 0; block < APRI_T6041_BLOCKS; block++) { + put_unaligned_le32(block + 1, data + pos); + put_unaligned_le32(counts[block], data + pos + 4); + pos += 8; + for (entry = 0; entry < counts[block]; entry++, pos += 12) { + put_unaligned_le32(entry * 4, data + pos); + put_unaligned_le32(0xffffffff, data + pos + 4); + put_unaligned_le32(entry, data + pos + 8); + } + } + KUNIT_ASSERT_EQ(test, pos, (size_t)APRI_T8132_FIRMWARE_SIZE); + KUNIT_EXPECT_EQ(test, apr_parse_init(&apri_t8132, data, pos, init), 0); + KUNIT_EXPECT_EQ(test, init->blocks[APRI_WRAPPER_BLOCK].count, + (u32)APRI_T8132_WRAPPER_COUNT); + /* T6041 does not take it, nor T8132 a T6041 SoC field. */ + KUNIT_EXPECT_EQ(test, apr_parse_init(&apri_t6041, data, pos, init), -EINVAL); + put_unaligned_le32(0x6041, data + 8); + KUNIT_EXPECT_EQ(test, apr_parse_init(&apri_t8132, data, pos, init), -EINVAL); + put_unaligned_le32(0x8132, data + 8); + /* A wrapper row past its window. */ + put_unaligned_le32(0x1000000, data + pos - 12); + KUNIT_EXPECT_EQ(test, apr_parse_init(&apri_t8132, data, pos, init), -EINVAL); +} + /* A T8142 container: T6050's blocks with a 38-row wrapper. */ static void apr_test_apri_t8142(struct kunit *test) { @@ -578,6 +619,7 @@ static struct kunit_case apr_test_cases[] = { KUNIT_CASE(apr_test_output), KUNIT_CASE(apr_test_apri_valid), KUNIT_CASE(apr_test_apri_t6050), + KUNIT_CASE(apr_test_apri_t8132), KUNIT_CASE(apr_test_apri_t8142), KUNIT_CASE(apr_test_apri_header_rejects), KUNIT_CASE(apr_test_apri_shape_rejects), diff --git a/drivers/media/platform/apple/prores/apple-prores.h b/drivers/media/platform/apple/prores/apple-prores.h index aa909be80883..67bf19c93370 100644 --- a/drivers/media/platform/apple/prores/apple-prores.h +++ b/drivers/media/platform/apple/prores/apple-prores.h @@ -57,12 +57,16 @@ #define APRI_T6041_FIRMWARE_SIZE 2728 #define APRI_T6050_FIRMWARE_NAME "apple/prores-t6050-init.bin" #define APRI_T6050_FIRMWARE_SIZE 2880 +#define APRI_T8132_FIRMWARE_NAME "apple/prores-t8132-init.bin" +#define APRI_T8132_FIRMWARE_SIZE 2560 #define APRI_T8142_FIRMWARE_NAME "apple/prores-t8142-init.bin" #define APRI_T8142_FIRMWARE_SIZE 2592 #define APRI_SYSTEM_COUNT 82 #define APRI_CORE_COUNT 80 #define APRI_WRAPPER_COUNT 62 #define APRI_CONTROL_COUNT 12 +/* T8132 brings up its AXI wrapper with fewer rows than T6041 */ +#define APRI_T8132_WRAPPER_COUNT 48 /* T8142's AXI-to-fabric wrapper takes 38 rows where T6041 and T6050 take 62. */ #define APRI_T8142_WRAPPER_COUNT 38 #define APRI_MAX_COUNT APRI_SYSTEM_COUNT @@ -171,6 +175,7 @@ int apr_build_desc_v0(const struct apr_frame *f, u8 *desc); int apr_check_output(const u8 *out, size_t capacity, u32 *frame_bytes); extern const struct apri_layout apri_t6041; extern const struct apri_layout apri_t6050; +extern const struct apri_layout apri_t8132; extern const struct apri_layout apri_t8142; int apr_parse_init(const struct apri_layout *layout, const u8 *data, size_t size, struct apr_init_data *init); diff --git a/drivers/media/platform/apple/prores/t6041-apri.rst b/drivers/media/platform/apple/prores/t6041-apri.rst index ebd9c03bb96a..3ebc28c49652 100644 --- a/drivers/media/platform/apple/prores/t6041-apri.rst +++ b/drivers/media/platform/apple/prores/t6041-apri.rst @@ -55,6 +55,16 @@ The container deliberately has no MMIO addresses, selectors, power policy, or arbitrary write commands. File integrity is the responsibility of the package that installs the per-Mac file. +T8132 +===== + +``apple/prores-t8132-init.bin`` is the T6041 container with ``soc = 0x8132`` +and a wrapper block of 48 entries instead of 62: 2,560 bytes in all. macOS +brings up the T8132 engine with read-modify-write tables of 82 (SCODEC +system), 80 (core) and 48 (AXI wrapper) rows, below ``+0x4040`` in the +wrapper window. The driver has no built-in T8132 rows, so that engine probes +only with the file. + T6050 =====