Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
14 changes: 14 additions & 0 deletions Documentation/admin-guide/media/apple-ave.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ build the device binds, but starting a stream fails with ``ENOTSUPP`` and a
message naming the checksum, until that build's command layout has been
checked.

T6000 (M1 Pro) and T8112 (M2) have probe-only support in this driver. Their
device tree nodes and both encoder DARTs remain disabled. The firmware
handoff must reserve their preloaded TEXT (0xd0000 bytes) and DATA
(0x128000 bytes), preserve the ADT remap addresses and export both CRCs.
An enabled node with a valid handoff may bind, but encoding is refused with
an informational message until per-SoC command constants, MCC DSID and the
firmware CRCs have been qualified. The T8140 command constants are never a
fallback for these devices. Enabling a node alone does not enable encoding.

The shared Start layout uses a smaller LFS reference surface on both
pre-M4 devices: at 1920x1080 its exact descriptor size is 0x85200 for AVC
and 0x1fe00 for HEVC, before the DMA allocation is page rounded. The
``apple-ave-sizes`` KUnit suite checks these sizes and alignment boundaries.

With debugfs mounted, ``apple-ave/last_start_h264``,
``last_start_hevc``, ``last_process0_h264`` and ``last_process0_hevc`` hold the
last Start command built and the first Process command of the last session,
Expand Down
6 changes: 4 additions & 2 deletions Documentation/devicetree/bindings/media/apple,t8140-ave.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ maintainers:
- Miguel Cruz <7362641+Acelogic@users.noreply.github.com>

description: |
The T6041 and T8140 AVE coprocessors encode video using firmware preloaded by the
bootloader. Its two DART instances translate the same stream. The
The T6000, T6041, T8112 and T8140 AVE coprocessors encode video using firmware
preloaded by the bootloader. Its two DART instances translate the same stream. The
bootloader supplies two reserved firmware regions and their IOVA mappings.

properties:
compatible:
enum:
- apple,t6000-ave
- apple,t6041-ave
- apple,t8112-ave
- apple,t8140-ave

reg:
Expand Down
1 change: 1 addition & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -2808,6 +2808,7 @@ L: linux-media@vger.kernel.org
S: Maintained
W: https://aurora-silicon.github.io
F: Documentation/admin-guide/media/apple-ave.rst
F: Documentation/devicetree/bindings/media/apple,t8140-ave.yaml
F: drivers/media/platform/apple/ave/

ARM/APPLE QSPIMC DRIVER
Expand Down
39 changes: 39 additions & 0 deletions arch/arm64/boot/dts/apple/t600x-die0.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,45 @@

&SOC_NODE {

ave_dart1: iommu@20d030000 {
compatible = "apple,t6000-dart";
reg = <0x2 0x0d030000 0 0x4000>;
interrupt-parent = <&aic>;
interrupts = <AIC_IRQ 0 1028 IRQ_TYPE_LEVEL_HIGH>;
power-domains = <&ps_venc_sys>;
#iommu-cells = <1>;
status = "disabled";
};

ave_dart0: iommu@20d040000 {
compatible = "apple,t6000-dart";
reg = <0x2 0x0d040000 0 0x4000>;
interrupt-parent = <&aic>;
interrupts = <AIC_IRQ 0 1028 IRQ_TYPE_LEVEL_HIGH>;
power-domains = <&ps_venc_sys>;
#iommu-cells = <1>;
status = "disabled";
};

ave: video-codec@20d100000 {
compatible = "apple,t6000-ave";
reg = <0x2 0x0d100000 0 0x45c000>,
<0x2 0x0d050000 0 0x8000>,
<0x2 0x0d800000 0 0x800000>;
reg-names = "codec", "mailbox", "coproc";
interrupt-parent = <&aic>;
interrupts = <AIC_IRQ 0 1031 IRQ_TYPE_LEVEL_HIGH>,
<AIC_IRQ 0 1025 IRQ_TYPE_LEVEL_HIGH>,
<AIC_IRQ 0 1024 IRQ_TYPE_LEVEL_HIGH>,
<AIC_IRQ 0 1027 IRQ_TYPE_LEVEL_HIGH>,
<AIC_IRQ 0 1026 IRQ_TYPE_LEVEL_HIGH>;
power-domains = <&ps_venc_dma>, <&ps_venc_pipe4>,
<&ps_venc_pipe5>, <&ps_venc_me0>, <&ps_venc_me1>;
power-domain-names = "dma", "pipe4", "pipe5", "me0", "me1";
iommus = <&ave_dart0 0>, <&ave_dart1 0>;
status = "disabled";
};

ane_dart0: iommu@285800000 {
compatible = "apple,t6000-dart";
reg = <0x2 0x85800000 0x0 0x4000>;
Expand Down
39 changes: 39 additions & 0 deletions arch/arm64/boot/dts/apple/t8112.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,45 @@
/* Required to get >32-bit DMA via DARTs */
dma-ranges = <0 0 0 0 0xffffffff 0xffffc000>;

ave_dart0: iommu@67030000 {
compatible = "apple,t8112-dart", "apple,t8110-dart";
reg = <0 0x67030000 0 0x4000>;
interrupt-parent = <&aic>;
interrupts = <AIC_IRQ 689 IRQ_TYPE_LEVEL_HIGH>;
power-domains = <&ps_venc_sys>;
#iommu-cells = <1>;
status = "disabled";
};

ave_dart1: iommu@67040000 {
compatible = "apple,t8112-dart", "apple,t8110-dart";
reg = <0 0x67040000 0 0x4000>;
interrupt-parent = <&aic>;
interrupts = <AIC_IRQ 689 IRQ_TYPE_LEVEL_HIGH>;
power-domains = <&ps_venc_sys>;
#iommu-cells = <1>;
status = "disabled";
};

ave: video-codec@67100000 {
compatible = "apple,t8112-ave";
reg = <0 0x67100000 0 0x45c000>,
<0 0x67050000 0 0x8000>,
<0 0x67800000 0 0x800000>;
reg-names = "codec", "mailbox", "coproc";
interrupt-parent = <&aic>;
interrupts = <AIC_IRQ 692 IRQ_TYPE_LEVEL_HIGH>,
<AIC_IRQ 686 IRQ_TYPE_LEVEL_HIGH>,
<AIC_IRQ 685 IRQ_TYPE_LEVEL_HIGH>,
<AIC_IRQ 688 IRQ_TYPE_LEVEL_HIGH>,
<AIC_IRQ 687 IRQ_TYPE_LEVEL_HIGH>;
power-domains = <&ps_venc_dma>, <&ps_venc_pipe4>,
<&ps_venc_pipe5>, <&ps_venc_me0>, <&ps_venc_me1>;
power-domain-names = "dma", "pipe4", "pipe5", "me0", "me1";
iommus = <&ave_dart0 0>, <&ave_dart1 0>;
status = "disabled";
};

gpu: gpu@206400000 {
compatible = "apple,agx-t8112", "apple,agx-g14g";
reg = <0x2 0x6400000 0 0x40000>,
Expand Down
7 changes: 7 additions & 0 deletions drivers/media/platform/apple/ave/.kunitconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CONFIG_KUNIT=y
CONFIG_EXPERT=y
CONFIG_NO_IOMEM=n
CONFIG_MEDIA_SUPPORT=y
CONFIG_MEDIA_SUPPORT_FILTER=n
CONFIG_MEDIA_PLATFORM_DRIVERS=y
CONFIG_VIDEO_APPLE_AVE_KUNIT_TEST=y
12 changes: 12 additions & 0 deletions drivers/media/platform/apple/ave/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,21 @@ config VIDEO_APPLE_AVE
help
V4L2 memory-to-memory driver for the AVE H.264/HEVC encoder in
Apple T8140 (A18 Pro) SoCs, as in the MacBook Neo.
T6000 (M1 Pro) and T8112 (M2) have probe-only support; encoding
requires qualified firmware command constants.

The encoder firmware is loaded by the bootloader; the driver builds
every command itself. See Documentation/admin-guide/media/apple-ave.rst.

To compile this driver as a module, choose M here: the module
will be called apple-ave.

config VIDEO_APPLE_AVE_KUNIT_TEST
tristate "KUnit tests for Apple AVE buffer sizing" if !KUNIT_ALL_TESTS
depends on KUNIT
default KUNIT_ALL_TESTS
help
Test the exact LFS reference descriptor sizes for pre-M4 and T8140
encoders, including picture alignment boundaries and the reference
1920x1080 AVC and HEVC sizes. The tests do not need an encoder or
any firmware and can run independently of the AVE driver.
1 change: 1 addition & 0 deletions drivers/media/platform/apple/ave/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

obj-$(CONFIG_VIDEO_APPLE_AVE) += apple-ave.o
apple-ave-y := ave-drv.o ave-fw.o ave-ipc.o ave-cmd.o ave-image.o ave-sess.o ave-v4l2.o
obj-$(CONFIG_VIDEO_APPLE_AVE_KUNIT_TEST) += ave-sizes-test.o
48 changes: 47 additions & 1 deletion drivers/media/platform/apple/ave/ave-drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,55 @@
#include <linux/iommu.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/pm_domain.h>
#include <linux/pm_runtime.h>

#include "ave.h"
#include "ave-regs.h"

#define AVE_AUTOSUSPEND_MS 2000

static const struct ave_coproc_regs ave_coproc_v40 = {
.vcbar = AVE_COPROC_VCBAR,
.timebase_freq = AVE_COPROC_TIMEBASE_FREQ,
.timebase = AVE_COPROC_TIMEBASE,
.ctrl = AVE_COPROC_CTRL,
.status = AVE_COPROC_STATUS,
.boot_arg = AVE_COPROC_BOOT_ARG,
.keep_mappings = AVE_COPROC_KEEP_MAPPINGS,
};

/* Pre-M4 wire layouts are shared; their command constants still need traces. */
static const struct ave_variant ave_t6000 = {
.regs = &ave_coproc_v40,
.fw_text_size = 0xd0000,
.fw_data_size = 0x128000,
.boot_device_id = 11,
.device_type = 9,
.lfs_ref_scale = 1,
};

static const struct ave_variant ave_t8112 = {
.regs = &ave_coproc_v40,
.fw_text_size = 0xd0000,
.fw_data_size = 0x128000,
.boot_device_id = 15,
.device_type = 13,
.lfs_ref_scale = 1,
};

static const struct ave_variant ave_t8140 = {
.regs = &ave_coproc_v40,
.fw_text_size = 0x14c000,
.fw_data_size = 0x130000,
.boot_device_id = 29,
.device_type = 27,
.lfs_ref_scale = 2,
.encoding_text_crc = AVE_FW_TEXT_CRC_9003_78_0,
};

/*
* debugfs: apple-ave/last_start_{h264,hevc} hold the last Start built and
* last_process0_{h264,hevc} the first Process of the last session, so the
Expand Down Expand Up @@ -84,6 +125,9 @@ static int ave_probe(struct platform_device *pdev)
if (!ave)
return -ENOMEM;
ave->dev = dev;
ave->variant = of_device_get_match_data(dev);
if (!ave->variant)
return -ENODEV;
mutex_init(&ave->hw_lock);
platform_set_drvdata(pdev, ave);

Expand Down Expand Up @@ -202,7 +246,9 @@ static const struct dev_pm_ops ave_pm_ops = {
};

static const struct of_device_id ave_of_match[] = {
{ .compatible = "apple,t8140-ave" },
{ .compatible = "apple,t6000-ave", .data = &ave_t6000 },
{ .compatible = "apple,t8112-ave", .data = &ave_t8112 },
{ .compatible = "apple,t8140-ave", .data = &ave_t8140 },
{ }
};
MODULE_DEVICE_TABLE(of, ave_of_match);
Expand Down
Loading
Loading