From aa6db0c74eddce3ba6c5cdf838c4a0785d85e5ef Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Tue, 17 Nov 2026 12:16:30 +0100 Subject: [PATCH 1/8] dt-bindings: iommu: apple,dart: describe the T8152 AVD instance The AVD Gen3 DART uses the shared TLBI aperture like the display DARTs, but Linux initializes it from an unlocked state with inactive streams. Require its PSD power domain, DMA aperture and initialization tunables. Signed-off-by: Thomas Glanzmann --- .../devicetree/bindings/iommu/apple,dart.yaml | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/iommu/apple,dart.yaml b/Documentation/devicetree/bindings/iommu/apple,dart.yaml index d7e8e332951ad..ba49a093eccee 100644 --- a/Documentation/devicetree/bindings/iommu/apple,dart.yaml +++ b/Documentation/devicetree/bindings/iommu/apple,dart.yaml @@ -33,6 +33,7 @@ properties: - apple,t8110-dart - apple,t6000-dart - apple,t8152-dart-gen3 + - apple,t8152-avd-dart - items: - const: apple,t8140-ane-dart - const: apple,t8140-dart @@ -369,7 +370,9 @@ allOf: properties: compatible: contains: - const: apple,t8152-dart-gen3 + enum: + - apple,t8152-dart-gen3 + - apple,t8152-avd-dart then: description: The T8152 Gen3 DARTs in front of the display coprocessors and their @@ -377,7 +380,9 @@ allOf: locked, and the operating system only adds page table entries in root slots that are empty at handoff. Their TLB command register answers translation queries; a stream is invalidated through the - TLB invalidation aperture instead. + TLB invalidation aperture instead. The T8152 AVD instance uses the + same invalidation aperture, but starts unlocked with inactive streams + and is initialized by the operating system after its PSD domain is on. properties: reg: minItems: 2 @@ -395,6 +400,17 @@ allOf: - const: dart - enum: [dapf, gapf, ps-wr-dis, auxiliary] + - if: + properties: + compatible: + contains: + const: apple,t8152-avd-dart + then: + required: + - power-domains + - apple,dma-range + - apple,tunable + additionalProperties: false examples: From 90d575a1a46ec7ff504de4bcacb5413e55d04fc4 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Tue, 17 Nov 2026 12:16:30 +0100 Subject: [PATCH 2/8] iommu: apple-dart: initialize the inactive T8152 AVD Gen3 DART Admit cold Gen3 setup only for the instance its apple,t8152-avd-dart compatible selects, with version 0x300, 16 streams, its PSD domain, ADT tunables and inactive streams 0..2. Clear those streams, apply their tunables and use the Gen3 TLBI aperture before enabling translation. Map the TLBI aperture before reset and select a two-level 16K page table inside a single 64 GiB high DMA window. Keep the existing locked display DART admission and all other unlocked Gen3 instances unchanged. On J873g this maps all three decoder streams for bit-exact H.264, HEVC, HEVC Main10, VP9 and AV1 decoding. Gen3 fault IRQ handling and suspend recovery remain outside this initial bring-up. Signed-off-by: Thomas Glanzmann --- drivers/iommu/apple-dart.c | 83 +++++++++++++------ .../drivers/apple/bcm4377-radio-sids.py | 1 + 2 files changed, 58 insertions(+), 26 deletions(-) diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c index b37d1ce94e618..56428e019b4ce 100644 --- a/drivers/iommu/apple-dart.c +++ b/drivers/iommu/apple-dart.c @@ -361,6 +361,7 @@ struct apple_dart_fw_tree { #define APPLE_DART_GAPF_PROTECT BIT(4) struct apple_dart { + bool cold_gen3; struct device *dev; const struct apple_dart_hw *hw; @@ -2661,6 +2662,17 @@ static int apple_dart_hw_reset(struct apple_dart *dart) struct apple_dart_stream_map stream_map; int i; + if (dart->cold_gen3) { + stream_map.dart = dart; + bitmap_zero(stream_map.sidmap, DART_MAX_STREAMS); + bitmap_set(stream_map.sidmap, 0, 3); + apple_dart_hw_disable_dma(&stream_map); + apple_dart_hw_clear_all_ttbrs(&stream_map); + apple_dart_apply_own_tunables(dart); + apple_dart_writel(dart, 7, dart->hw->enable_streams); + return dart->hw->invalidate_tlb(&stream_map); + } + if (dart->isp_host) return apple_dart_isp_host_reset(dart); if (dart->managed_sids || dart->cold_ane) @@ -3393,6 +3405,17 @@ static int __apple_dart_finalize_domain(struct apple_dart_domain *dart_domain, .iommu_dev = dart->dev, }; + if (dart->cold_gen3) { + if ((dma_min ^ dma_max) & ~DMA_BIT_MASK(36)) { + ret = -ERANGE; + goto done; + } + /* Gen3 selects the high DMA window separately from its two-level + * 16K page-table indices, as with iBoot's display streams. + */ + pgtbl_cfg.ias = 36; + } + if (dart->locked) { unsigned long *sidmap; int sid; @@ -5548,6 +5571,7 @@ static int apple_dart_probe(struct platform_device *pdev) dart->dev = dev; dart->hw = of_device_get_match_data(dev); dart->tunneled = tunneled; + dart->cold_gen3 = of_device_is_compatible(dev->of_node, "apple,t8152-avd-dart"); dart->cold_ane = of_device_is_compatible(dev->of_node, "apple,t8140-ane-dart") || of_device_is_compatible(dev->of_node, "apple,t8142-ane-dart"); if (dart->cold_ane && !IS_BUILTIN(CONFIG_APPLE_DART)) @@ -5967,6 +5991,38 @@ static int apple_dart_probe(struct platform_device *pdev) ret = -EBUSY; goto err_clk_disable; } + if (dart->hw->gen3) { + struct resource *tlbi; + + /* Cold initialization is qualified only for the AVD instance. */ + if (!dart->locked && !dart->cold_gen3) { + dev_err(dev, "Gen3 DART is not locked; cold setup is not supported\n"); + ret = -ENODEV; + goto err_clk_disable; + } + if (dart->cold_gen3 && (dart->locked || dart->version != 0x300 || + dart->num_streams != 16 || !dev->pm_domain || !dart->tunables || + (apple_dart_readl(dart, dart->hw->enable_streams) & 7))) { + ret = -EINVAL; + goto err_clk_disable; + } + /* The aperture is shared by every Gen3 DART: map, do not claim. */ + tlbi = platform_get_resource_byname(pdev, IORESOURCE_MEM, "tlbi"); + if (!tlbi || resource_size(tlbi) < 16) { + dev_err(dev, "Gen3 DART needs its TLBI aperture\n"); + ret = -EINVAL; + goto err_clk_disable; + } + dart->tlbi = devm_ioremap(dev, tlbi->start, resource_size(tlbi)); + if (!dart->tlbi) { + ret = -ENOMEM; + goto err_clk_disable; + } + dart->tlbi_route = apple_dart_readl(dart, DART_GEN3_TLBI_ROUTE) & 0xf; + dev_info(dev, "Gen3 DART, version %#x, TLBI route %u\n", + dart->version, dart->tlbi_route); + } + apple_dart_parse_sleep_list(dart, res, "apple,sleep-prepare", &dart->sleep_prepare); apple_dart_parse_sleep_list(dart, res, "apple,sleep-restore", &dart->sleep_restore); apple_dart_parse_sleep_list(dart, res, "apple,sleep-restore-late", @@ -6107,32 +6163,6 @@ static int apple_dart_probe(struct platform_device *pdev) goto err_clk_disable; } - if (dart->hw->gen3) { - struct resource *tlbi; - - /* Only an iBoot-provisioned (locked) Gen3 stream is supported. */ - if (!dart->locked) { - dev_err(dev, "Gen3 DART is not locked; cold setup is not supported\n"); - ret = -ENODEV; - goto err_clk_disable; - } - /* The aperture is shared by every Gen3 DART: map, do not claim. */ - tlbi = platform_get_resource_byname(pdev, IORESOURCE_MEM, "tlbi"); - if (!tlbi || resource_size(tlbi) < 16) { - dev_err(dev, "Gen3 DART needs its TLBI aperture\n"); - ret = -EINVAL; - goto err_clk_disable; - } - dart->tlbi = devm_ioremap(dev, tlbi->start, resource_size(tlbi)); - if (!dart->tlbi) { - ret = -ENOMEM; - goto err_clk_disable; - } - dart->tlbi_route = apple_dart_readl(dart, DART_GEN3_TLBI_ROUTE) & 0xf; - dev_info(dev, "Gen3 DART, version %#x, TLBI route %u\n", - dart->version, dart->tlbi_route); - } - /* Borrowed display state: never acknowledge someone else's fault. */ if (dart->locked && !dart->preserve_display && !dart->hw->gen3) apple_dart_drain_stale_exceptions(dart); @@ -7394,6 +7424,7 @@ static const struct dev_pm_ops apple_dart_pm_ops = { static const struct of_device_id apple_dart_of_match[] = { { .compatible = "apple,t8152-dart-gen3", .data = &apple_dart_hw_gen3 }, + { .compatible = "apple,t8152-avd-dart", .data = &apple_dart_hw_gen3 }, { .compatible = "apple,t8103-dart", .data = &apple_dart_hw_t8103 }, { .compatible = "apple,t8103-usb4-dart", .data = &apple_dart_hw_t8103_usb4 }, { .compatible = "apple,t8110-dart", .data = &apple_dart_hw_t8110 }, diff --git a/tools/testing/selftests/drivers/apple/bcm4377-radio-sids.py b/tools/testing/selftests/drivers/apple/bcm4377-radio-sids.py index e13025a6157c5..4a148b13d707d 100755 --- a/tools/testing/selftests/drivers/apple/bcm4377-radio-sids.py +++ b/tools/testing/selftests/drivers/apple/bcm4377-radio-sids.py @@ -106,6 +106,7 @@ def main(): bool four_level, per_stream, tunneled, fw_mirror, fw_handoff; bool pending, preserve_display; bool isp_host, cold_ane, live_mtp, display_dark, display_tlb_stale; + bool cold_gen3; void *tunables; unsigned long static_bypass[4]; void *dcp, *frontend[2]; From d652d40bfc0297c88f130ba6f490e71be28ec6bf Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Tue, 17 Nov 2026 12:16:30 +0100 Subject: [PATCH 3/8] media: dt-bindings: describe the T8152 Kopsia decoder Describe the Kopsia MCU, decoder, wrapper and PIODMA register apertures, its three DART streams and its shared PSD power domain. The initial transport submits from the host with the MCU halted and polls completion; it does not use the PostOffice mailbox or the legacy decoder reset line. Signed-off-by: Thomas Glanzmann --- .../bindings/media/apple,t8152-avd.yaml | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/apple,t8152-avd.yaml diff --git a/Documentation/devicetree/bindings/media/apple,t8152-avd.yaml b/Documentation/devicetree/bindings/media/apple,t8152-avd.yaml new file mode 100644 index 0000000000000..585a0a897fed7 --- /dev/null +++ b/Documentation/devicetree/bindings/media/apple,t8152-avd.yaml @@ -0,0 +1,73 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/apple,t8152-avd.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Apple T8152 Kopsia video decoder + +maintainers: + - Thomas Glanzmann + +description: + Kopsia is the T8152 stateless video decoder. Its decoder, PIODMA and + auxiliary data streams share a Gen3 DART and a PSD power domain. The host + submits codec programs with the MCU halted and polls decoder status; + the PostOffice mailbox transport is not used by this implementation. + +properties: + compatible: + const: apple,t8152-avd + + reg: + items: + - description: MCU code memory + - description: MCU control registers + - description: Decoder control registers + - description: Decoder wrapper registers + - description: PIODMA registers + + reg-names: + items: + - const: code + - const: mbox + - const: ctrl + - const: wrap + - const: dma + + iommus: + items: + - description: Decoder stream + - description: PIODMA stream + - description: Auxiliary data stream + + power-domains: + maxItems: 1 + +required: + - compatible + - reg + - reg-names + - iommus + - power-domains + +additionalProperties: false + +examples: + - | + soc { + #address-cells = <2>; + #size-cells = <2>; + + video-codec@485400000 { + compatible = "apple,t8152-avd"; + reg = <0x4 0x85400000 0x0 0x12000>, + <0x4 0x85500000 0x0 0x4000>, + <0x4 0x85100000 0x0 0x10000>, + <0x4 0x850c0000 0x0 0x4000>, + <0x4 0x85070000 0x0 0x4000>; + reg-names = "code", "mbox", "ctrl", "wrap", "dma"; + iommus = <&avd_dart 0>, <&avd_dart 1>, <&avd_dart 2>; + power-domains = <&ps_avd>; + }; + }; From ec2d4767bbb29715c0bdd66b4302955898e7424e Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Tue, 17 Nov 2026 12:16:30 +0100 Subject: [PATCH 4/8] media: apple: avd: add a polled host backend for T8152 Kopsia T8152 Kopsia retains the T8142 codec program format but uses different initialization and completion registers. Add a host backend that halts the MCU, initializes the wrapper and PIODMA, and reuses the existing codec submission and completion logic with one frame in flight. Poll VP/PP status only while a frame is active. Enable H.264, HEVC, VP9 and AV1 on this variant without an external firmware image. Retain the 128-byte H.264 MV and HEVC v5 header quirks. Disable recovery reset: the existing watchdog parks DMA and retires the decoder instead of issuing an unqualified reset. The 346 register tunables are unchanged from the MIT-licensed avd-fw v5/tier2 table. The J873g ADT's avd node carries no tunables of its own (unlike its DART's), so there is nothing T8152-specific to describe in the device tree. The table was checked on the J873g by its output: with it, H.264, HEVC, HEVC Main10, VP9 and AV1 decode bit-exact against software (60 frames each), 4K60 H.264 runs at about 150 fps, and the results stay exact across hundreds of power-domain cycles, each of which applies the table again. On J873g, forced DRM PRIME decode and download compares exactly with software for 60 frames of each codec, including HEVC Main10; mpv also renders through DRM PRIME and seeks in both directions. The decoder is runtime power-gated through its PSD domain: the backend is set up again on every resume. A DART fault (injected on the J873g) retires the decoder through the existing recovery path until the module is reloaded. PostOffice completion and suspend/resume remain outstanding. Link: https://github.com/aurora-silicon/avd-fw/blob/ea3a65cc9c0c41907e6ad2714b813e4be6858485/src/hw/tunables/tunables_v5t2.h Signed-off-by: Thomas Glanzmann --- drivers/media/platform/apple/avd/Kconfig | 4 +- drivers/media/platform/apple/avd/Makefile | 2 +- .../platform/apple/avd/avd-backend-kopsia.c | 176 +++++++++ .../platform/apple/avd/avd-backend-open.c | 24 +- drivers/media/platform/apple/avd/avd-drv.c | 53 ++- .../platform/apple/avd/avd-kopsia-tunables.h | 350 ++++++++++++++++++ drivers/media/platform/apple/avd/avd.h | 5 + 7 files changed, 595 insertions(+), 19 deletions(-) create mode 100644 drivers/media/platform/apple/avd/avd-backend-kopsia.c create mode 100644 drivers/media/platform/apple/avd/avd-kopsia-tunables.h diff --git a/drivers/media/platform/apple/avd/Kconfig b/drivers/media/platform/apple/avd/Kconfig index d3bb9763b6230..4aa061da424e6 100644 --- a/drivers/media/platform/apple/avd/Kconfig +++ b/drivers/media/platform/apple/avd/Kconfig @@ -14,7 +14,9 @@ config VIDEO_APPLE_AVD help Support the Apple Silicon stateless video decoder. - Build the decoder firmware from https://github.com/aurora-silicon/avd-fw + T8152 uses host submission and does not need a firmware image. + + For earlier SoCs, build the decoder firmware from https://github.com/aurora-silicon/avd-fw and install it under /lib/firmware/apple/. J700/T8140 uses the avd-fw-v5-t0.bin image. Firmware is supplied separately from this driver. diff --git a/drivers/media/platform/apple/avd/Makefile b/drivers/media/platform/apple/avd/Makefile index 60560dbab592a..66b8e3c61356a 100644 --- a/drivers/media/platform/apple/avd/Makefile +++ b/drivers/media/platform/apple/avd/Makefile @@ -2,7 +2,7 @@ apple-avd-y := avd-drv.o avd-v4l2.o avd-hw.o avd-pm.o avd-h264.o avd-vp9.o \ avd-hevc.o avd-av1.o avd-av1-entropymode.o avd-queue.o avd-backend-open.o \ - avd-backend-apple.o avd-backend-queue.o + avd-backend-apple.o avd-backend-queue.o avd-backend-kopsia.o apple-avd-$(CONFIG_VIDEO_APPLE_AVD_KUNIT_TEST) += avd-h264-test.o avd-queue-test.o \ avd-pm-test.o obj-$(CONFIG_VIDEO_APPLE_AVD) += apple-avd.o diff --git a/drivers/media/platform/apple/avd/avd-backend-kopsia.c b/drivers/media/platform/apple/avd/avd-backend-kopsia.c new file mode 100644 index 0000000000000..f242e90d4be8a --- /dev/null +++ b/drivers/media/platform/apple/avd/avd-backend-kopsia.c @@ -0,0 +1,176 @@ +// SPDX-License-Identifier: GPL-2.0-only OR MIT +/* + * T8152 Kopsia bring-up: host submission and polled VP/PP completion. + * + * Completion is polled because no decoder interrupt is described: the ADT's + * avd node lists only its PostOffice mailbox pair (AIC 308 and 268, mailbox + * 9's send-empty and recv-not-empty), and with the MCU halted nothing is known + * to raise them. The poll runs only while a frame is active. + */ +#include +#include +#include "avd.h" + +#define KOPSIA_STATUS(n) (0x194 + 4 * (n)) +#define KOPSIA_ERROR BIT(1) +#define KOPSIA_DONE BIT(2) +#define KOPSIA_PP 13 + +struct avd_kopsia_tunable { u32 off, mask, val; }; +#include "avd-kopsia-tunables.h" + +struct avd_kopsia { + struct avd_dev *avd; + void __iomem *wrap; + void __iomem *dma; + struct work_struct poll_work; + bool running; +}; + +static void kopsia_update(void __iomem *reg, u32 mask, u32 value) +{ + writel((readl(reg) & ~mask) | value, reg); +} + +static int avd_kopsia_boot(struct avd_dev *avd) +{ + struct avd_kopsia *k = avd->backend_priv; + unsigned int i; + + if (readl(avd->ctrl) != 0x40030) + return -ENODEV; + + /* Keep the MCU halted: this transport owns the hardware status bits. */ + writel(0xe, avd->mbox + 0x28); + kopsia_update(avd->mbox + 0x40, BIT(24), BIT(24)); + writel(0, avd->mbox + 0x104); + writel(1, k->wrap + 0x18); + writel(0, k->dma); + writel(0x20, avd->ctrl + 0x1cc); + writel(U32_MAX, avd->ctrl + 0xe6d0); + writel(U32_MAX, avd->ctrl + 0xe6d4); + writel(U32_MAX, avd->ctrl + 0xe710); + writel(U32_MAX, avd->ctrl + 0xe714); + for (i = 0; i < ARRAY_SIZE(kopsia_tunables); i++) { + const struct avd_kopsia_tunable *t = &kopsia_tunables[i]; + + kopsia_update(avd->ctrl + t->off, t->mask, t->val); + } + kopsia_update(k->wrap + 0x14, 1, 1); + kopsia_update(k->wrap + 0x18, 1, 1); + kopsia_update(k->wrap + 0x4c, 1, 1); + kopsia_update(k->dma, 2, 0); + kopsia_update(k->dma + 0x10, 0x1ff8000f, 2); + kopsia_update(k->dma + 0x14, 0x1ff8000f, 2); + kopsia_update(k->dma + 0x18, 0x1ff8000f, 3); + kopsia_update(k->dma + 0x1c, 0xf, 0); + kopsia_update(k->dma + 0x20, 0xf, 0); + for (i = 0; i <= KOPSIA_PP; i++) + writel(KOPSIA_DONE | KOPSIA_ERROR, avd->ctrl + KOPSIA_STATUS(i)); + k->running = true; + dev_info_once(avd->dev, "Kopsia host backend, decoder %#x (polled completion)\n", + readl(avd->ctrl)); + return 0; +} + +static void avd_kopsia_shutdown(struct avd_dev *avd) +{ + struct avd_kopsia *k = avd->backend_priv; + + /* Serialized against polling by queue_mutex or the idle PM reference. */ + WRITE_ONCE(k->running, false); +} + +static void avd_kopsia_poll(struct work_struct *work) +{ + struct avd_kopsia *k = container_of(work, struct avd_kopsia, poll_work); + struct avd_dev *avd = k->avd; + + for (;;) { + struct avd_frame *f; + u32 vp, status; + bool active; + + mutex_lock(&avd->queue_mutex); + f = avd->compat_active; + if (!READ_ONCE(k->running) || !f || avd->stopping || avd->faulted) { + mutex_unlock(&avd->queue_mutex); + break; + } + vp = avd->variant->vp_slot_base[f->cmd[0]]; + status = readl(avd->ctrl + KOPSIA_STATUS(vp)); + if (status & KOPSIA_ERROR) { + writel(KOPSIA_ERROR, avd->ctrl + KOPSIA_STATUS(vp)); + avd_status(avd, vp); + avd_open_complete(avd, vp); + mutex_unlock(&avd->queue_mutex); + break; + } + if (status & KOPSIA_DONE) { + writel(KOPSIA_DONE, avd->ctrl + KOPSIA_STATUS(vp)); + avd_open_complete(avd, 0x100 | vp); + } + status = readl(avd->ctrl + KOPSIA_STATUS(KOPSIA_PP)); + if (status & KOPSIA_DONE) { + writel(KOPSIA_DONE, avd->ctrl + KOPSIA_STATUS(KOPSIA_PP)); + avd_open_complete(avd, 0x1000); + } + active = avd->compat_active != NULL; + mutex_unlock(&avd->queue_mutex); + if (!active) + break; + usleep_range(100, 200); + } +} + +static int avd_kopsia_submit(struct avd_dev *avd, struct avd_frame *f) +{ + struct avd_kopsia *k = avd->backend_priv; + int ret = avd_open_submit(avd, f); + + if (!ret) + queue_work(system_dfl_wq, &k->poll_work); + return ret; +} + +static unsigned int avd_kopsia_max_inflight(struct avd_dev *avd) +{ + return 1; +} + +static void avd_kopsia_cleanup(void *data) +{ + struct avd_kopsia *k = data; + + WRITE_ONCE(k->running, false); + cancel_work_sync(&k->poll_work); +} + +static int avd_kopsia_probe(struct avd_dev *avd) +{ + struct avd_kopsia *k = devm_kzalloc(avd->dev, sizeof(*k), GFP_KERNEL); + + if (!k) + return -ENOMEM; + k->avd = avd; + k->wrap = devm_platform_ioremap_resource_byname(avd->pdev, "wrap"); + if (IS_ERR(k->wrap)) + return PTR_ERR(k->wrap); + k->dma = devm_platform_ioremap_resource_byname(avd->pdev, "dma"); + if (IS_ERR(k->dma)) + return PTR_ERR(k->dma); + INIT_WORK(&k->poll_work, avd_kopsia_poll); + avd->backend_priv = k; + return devm_add_action_or_reset(avd->dev, avd_kopsia_cleanup, k); +} + +const struct avd_backend_ops avd_kopsia_backend = { + .name = "kopsia-host", + .probe = avd_kopsia_probe, + .boot = avd_kopsia_boot, + .shutdown = avd_kopsia_shutdown, + .max_inflight = avd_kopsia_max_inflight, + .submit = avd_kopsia_submit, + .suspend = avd_pm_backend_suspend, + .resume = avd_pm_backend_resume, +}; diff --git a/drivers/media/platform/apple/avd/avd-backend-open.c b/drivers/media/platform/apple/avd/avd-backend-open.c index 525c7848b4edc..13508cc5d5272 100644 --- a/drivers/media/platform/apple/avd/avd-backend-open.c +++ b/drivers/media/platform/apple/avd/avd-backend-open.c @@ -74,7 +74,7 @@ static unsigned int avd_open_max_inflight(struct avd_dev *avd) return 1; } -static int avd_open_submit(struct avd_dev *avd, struct avd_frame *f) +int avd_open_submit(struct avd_dev *avd, struct avd_frame *f) { struct avd_ctx *ctx = f->ctx; u32 codec = f->cmd[0], vp = 0; @@ -131,13 +131,9 @@ static int avd_open_submit(struct avd_dev *avd, struct avd_frame *f) return 0; } -static irqreturn_t avd_open_irq(struct avd_dev *avd) +irqreturn_t avd_open_complete(struct avd_dev *avd, u32 status) { struct avd_frame *f = avd->compat_active; - u32 status; - - if (!avd_mbox_pop(avd, &status)) - return IRQ_HANDLED; if (!f) { /* * The old driver kicked PP for every VP DONE. A VP DONE with no @@ -177,6 +173,15 @@ static irqreturn_t avd_open_irq(struct avd_dev *avd) return IRQ_HANDLED; } +static irqreturn_t avd_open_irq(struct avd_dev *avd) +{ + u32 status; + + if (!avd_mbox_pop(avd, &status)) + return IRQ_HANDLED; + return avd_open_complete(avd, status); +} + bool avd_backend_is_open(const struct avd_dev *avd) { return avd->backend == &avd_open_backend; @@ -241,6 +246,13 @@ int avd_backend_select(struct avd_dev *avd) { int ret; + if (avd->variant->quirks & AVD_QUIRK_KOPSIA) { + avd->backend = &avd_kopsia_backend; + avd->capabilities = avd->variant->capabilities; + avd->fw_capabilities = avd->capabilities; + return avd->backend->probe(avd); + } + /* Apple probe returns -ENOENT only when no usable image is present. */ if (avd->variant->apple) { ret = avd_apple_backend.probe(avd); diff --git a/drivers/media/platform/apple/avd/avd-drv.c b/drivers/media/platform/apple/avd/avd-drv.c index 58ea3fc604d87..2b8ee0f381274 100644 --- a/drivers/media/platform/apple/avd/avd-drv.c +++ b/drivers/media/platform/apple/avd/avd-drv.c @@ -590,8 +590,35 @@ static const struct avd_variant avd_t8142_variant = { .quirks = AVD_QUIRK_HEVC_V5_HEADER | AVD_QUIRK_H264_MV_128, }; +static const struct avd_variant avd_t8152_variant = { + .vp_slots = { + [AVD_CODEC_HEVC] = 2, + [AVD_CODEC_H264] = 1, + [AVD_CODEC_VP9] = 1, + [AVD_CODEC_AV1] = 1, + }, + .vp_slot_base = { + [AVD_CODEC_HEVC] = 0, + [AVD_CODEC_H264] = 4, + [AVD_CODEC_VP9] = 8, + [AVD_CODEC_AV1] = 9, + }, + .fifo_slots = 7, + .configure_stream = t8122_configure_stream, + .capabilities = AVD_CAPABILITY_H264 | AVD_CAPABILITY_HEVC | + AVD_CAPABILITY_VP9 | AVD_CAPABILITY_AV1, + .revision = 4, + .vp_slot_offset = 0xc, + .submit_offset = 0x40, + .submit_queue_max_offset = 0x44, + .submit_queue_status_offset = 0x7c, + .quirks = AVD_QUIRK_HEVC_V5_HEADER | AVD_QUIRK_H264_MV_128 | + AVD_QUIRK_NO_RECOVERY_RESET | AVD_QUIRK_KOPSIA, +}; + /* can also be derived from a version register */ static const struct of_device_id avd_of_match[] = { + { .compatible = "apple,t8152-avd", .data = &avd_t8152_variant }, { .compatible = "apple,t8103-avd", .data = &avd_t8103_variant @@ -667,7 +694,8 @@ static int avd_probe(struct platform_device *pdev) match = of_match_node(avd_of_match, pdev->dev.of_node); avd->variant = match->data; - avd->rstc = devm_reset_control_get_exclusive(avd->dev, NULL); + avd->rstc = avd->variant->quirks & AVD_QUIRK_KOPSIA ? NULL : + devm_reset_control_get_exclusive(avd->dev, NULL); if (IS_ERR(avd->rstc)) return PTR_ERR(avd->rstc); @@ -729,16 +757,19 @@ static int avd_probe(struct platform_device *pdev) return ret; } - irq = platform_get_irq(pdev, 1); - if (irq < 0) - return irq; - avd->pm.irq = irq; - ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, - avd_irq_handler, IRQF_ONESHOT | IRQF_NO_AUTOEN, - dev_name(&pdev->dev), avd); - if (ret) { - dev_err(avd->dev, "Could not request IRQ 1"); - return ret; + /* Kopsia has no described completion interrupt; its backend polls. */ + if (!(avd->variant->quirks & AVD_QUIRK_KOPSIA)) { + irq = platform_get_irq(pdev, 1); + if (irq < 0) + return irq; + avd->pm.irq = irq; + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, + avd_irq_handler, IRQF_ONESHOT | IRQF_NO_AUTOEN, + dev_name(&pdev->dev), avd); + if (ret) { + dev_err(avd->dev, "Could not request IRQ 1"); + return ret; + } } /* diff --git a/drivers/media/platform/apple/avd/avd-kopsia-tunables.h b/drivers/media/platform/apple/avd/avd-kopsia-tunables.h new file mode 100644 index 0000000000000..95fb2d6d4792a --- /dev/null +++ b/drivers/media/platform/apple/avd/avd-kopsia-tunables.h @@ -0,0 +1,350 @@ +/* SPDX-License-Identifier: MIT */ +/* avd-fw v5/tier2 table, Copyright The Asahi Linux Contributors. */ +static const struct avd_kopsia_tunable kopsia_tunables[] = { + {0x0008, 0x80000000, 0x80000000}, /* MCTL_MODE */ + {0x1000, 0x80000000, 0x80000000}, /* HEVC_MODE */ + {0x1100, 0x80000000, 0x80000000}, /* HEVC_MODE */ + {0x1200, 0x80000000, 0x80000000}, /* HEVC_MODE */ + {0x1300, 0x80000000, 0x80000000}, /* HEVC_MODE */ + {0x1400, 0x80000000, 0x80000000}, /* H264_MODE */ + {0x1500, 0x80000000, 0x80000000}, /* H264_MODE */ + {0x1600, 0x80000000, 0x80000000}, /* H264_MODE */ + {0x1700, 0x80000000, 0x80000000}, /* H264_MODE */ + {0x1800, 0x80000000, 0x80000000}, /* VP9_MODE */ + {0x1900, 0x80000000, 0x80000000}, /* AV1_MODE */ + {0x1a00, 0x80000000, 0x80000000}, /* AV1_MODE */ + {0x1b00, 0x80000000, 0x80000000}, /* AV1_MODE */ + {0x4000, 0x80000000, 0x80000000}, /* QT_MODE */ + {0x4100, 0x80000000, 0x80000000}, /* IPMC_MODE */ + {0x4200, 0x80000000, 0x80000000}, /* LF_MODE */ + {0x4300, 0x80000000, 0x80000000}, /* MV_MODE */ + {0x4400, 0x80000000, 0x80000000}, /* TP_MODE */ + {0x4500, 0x80000000, 0x80000000}, /* PC_MODE */ + {0x4600, 0x80000000, 0x80000000}, /* SW_MODE */ + {0x4700, 0x80000000, 0x80000000}, /* LR_MODE */ + {0xc000, 0x00000001, 0x00000001}, /* VP_TOP_CLOCK_GATING */ + {0xc080, 0x800f0000, 0x80020000}, /* R_HEVC_BITS */ + {0xc084, 0x1fff1fff, 0x00000028}, /* BUF */ + {0xc090, 0x000000ff, 0x00000001}, /* EXT */ + {0xc0c0, 0x800f0000, 0x80020000}, /* R_HEVC_BITS */ + {0xc0c4, 0x1fff1fff, 0x00280028}, /* BUF */ + {0xc0d0, 0x000000ff, 0x00000002}, /* EXT */ + {0xc100, 0x800f0000, 0x80020000}, /* R_HEVC_BITS */ + {0xc104, 0x1fff1fff, 0x00500028}, /* BUF */ + {0xc110, 0x000000ff, 0x00000003}, /* EXT */ + {0xc140, 0x800f0000, 0x80020000}, /* R_HEVC_BITS */ + {0xc144, 0x1fff1fff, 0x00780028}, /* BUF */ + {0xc150, 0x000000ff, 0x00000004}, /* EXT */ + {0xc180, 0x800f0000, 0x80010000}, /* W_HEVC_INSN */ + {0xc184, 0x0fff0fff, 0x00be0028}, /* BUF */ + {0xc190, 0x000000ff, 0x00000056}, /* EXT */ + {0xc1c0, 0x800f0000, 0x80010000}, /* W_HEVC_INSN */ + {0xc1c4, 0x0fff0fff, 0x00e60028}, /* BUF */ + {0xc1d0, 0x000000ff, 0x00000057}, /* EXT */ + {0xc200, 0x800f0000, 0x80010000}, /* W_HEVC_INSN */ + {0xc204, 0x0fff0fff, 0x010e0028}, /* BUF */ + {0xc210, 0x000000ff, 0x00000058}, /* EXT */ + {0xc240, 0x800f0000, 0x80010000}, /* W_HEVC_INSN */ + {0xc244, 0x0fff0fff, 0x01360028}, /* BUF */ + {0xc250, 0x000000ff, 0x00000059}, /* EXT */ + {0xc280, 0x800f0000, 0x80020000}, /* R_H264_BITS */ + {0xc284, 0x1fff1fff, 0x00a00020}, /* BUF */ + {0xc290, 0x000000ff, 0x0000000d}, /* EXT */ + {0xc2c0, 0x800f0000, 0x80020000}, /* R_H264_BITS */ + {0xc2c4, 0x1fff1fff, 0x00c00020}, /* BUF */ + {0xc2d0, 0x000000ff, 0x0000000e}, /* EXT */ + {0xc300, 0x800f0000, 0x80020000}, /* R_H264_BITS */ + {0xc304, 0x1fff1fff, 0x00e00020}, /* BUF */ + {0xc310, 0x000000ff, 0x0000000f}, /* EXT */ + {0xc340, 0x800f0000, 0x80020000}, /* R_H264_BITS */ + {0xc344, 0x1fff1fff, 0x01000020}, /* BUF */ + {0xc350, 0x000000ff, 0x00000010}, /* EXT */ + {0xc380, 0x800f0000, 0x80020000}, /* W_H264_ABOVE_INFO */ + {0xc384, 0x0fff0fff, 0x00000004}, /* BUF */ + {0xc390, 0x000000ff, 0x00000011}, /* EXT */ + {0xc3c0, 0x800f0000, 0x80020000}, /* W_H264_ABOVE_INFO */ + {0xc3c4, 0x0fff0fff, 0x00040004}, /* BUF */ + {0xc3d0, 0x000000ff, 0x00000012}, /* EXT */ + {0xc400, 0x800f0000, 0x80020000}, /* W_H264_ABOVE_INFO */ + {0xc404, 0x0fff0fff, 0x00080004}, /* BUF */ + {0xc410, 0x000000ff, 0x00000013}, /* EXT */ + {0xc440, 0x800f0000, 0x80020000}, /* W_H264_ABOVE_INFO */ + {0xc444, 0x0fff0fff, 0x000c0004}, /* BUF */ + {0xc450, 0x000000ff, 0x00000014}, /* EXT */ + {0xc480, 0x800f0000, 0x80020000}, /* R_H264_ABOVE_INFO */ + {0xc484, 0x1fff1fff, 0x01200006}, /* BUF */ + {0xc490, 0x000000ff, 0x00000015}, /* EXT */ + {0xc4c0, 0x800f0000, 0x80020000}, /* R_H264_ABOVE_INFO */ + {0xc4c4, 0x1fff1fff, 0x01260006}, /* BUF */ + {0xc4d0, 0x000000ff, 0x00000016}, /* EXT */ + {0xc500, 0x800f0000, 0x80020000}, /* R_H264_ABOVE_INFO */ + {0xc504, 0x1fff1fff, 0x012c0006}, /* BUF */ + {0xc510, 0x000000ff, 0x00000017}, /* EXT */ + {0xc540, 0x800f0000, 0x80020000}, /* R_H264_ABOVE_INFO */ + {0xc544, 0x1fff1fff, 0x01320006}, /* BUF */ + {0xc550, 0x000000ff, 0x00000018}, /* EXT */ + {0xc580, 0x800f0000, 0x80010000}, /* W_H264_INSN */ + {0xc584, 0x0fff0fff, 0x015e0020}, /* BUF */ + {0xc590, 0x000000ff, 0x0000005a}, /* EXT */ + {0xc5c0, 0x800f0000, 0x80010000}, /* W_H264_INSN */ + {0xc5c4, 0x0fff0fff, 0x017e0020}, /* BUF */ + {0xc5d0, 0x000000ff, 0x0000005b}, /* EXT */ + {0xc600, 0x800f0000, 0x80010000}, /* W_H264_INSN */ + {0xc604, 0x0fff0fff, 0x019e0020}, /* BUF */ + {0xc610, 0x000000ff, 0x0000005c}, /* EXT */ + {0xc640, 0x800f0000, 0x80010000}, /* W_H264_INSN */ + {0xc644, 0x0fff0fff, 0x01be0020}, /* BUF */ + {0xc650, 0x000000ff, 0x0000005d}, /* EXT */ + {0xc680, 0x800f0000, 0x80020000}, /* R_VP9_BITS */ + {0xc684, 0x1fff1fff, 0x01380018}, /* BUF */ + {0xc690, 0x000000ff, 0x00000021}, /* EXT */ + {0xc6c0, 0x800f0000, 0x80020000}, /* W_VP9_ABOVE_INFO */ + {0xc6c4, 0x0fff0fff, 0x0010000a}, /* BUF */ + {0xc6d0, 0x000000ff, 0x00000022}, /* EXT */ + {0xc700, 0x800f0000, 0x80020000}, /* R_VP9_ABOVE_INFO */ + {0xc704, 0x1fff1fff, 0x0150000e}, /* BUF */ + {0xc710, 0x000000ff, 0x00000023}, /* EXT */ + {0xc740, 0x800f0000, 0x80020000}, /* W_VP9_SEG */ + {0xc744, 0x0fff0fff, 0x001a000a}, /* BUF */ + {0xc750, 0x000000ff, 0x00000024}, /* EXT */ + {0xc780, 0x800f0000, 0x80020000}, /* R_VP9_SEG */ + {0xc784, 0x1fff1fff, 0x015e000a}, /* BUF */ + {0xc790, 0x000000ff, 0x00000025}, /* EXT */ + {0xc7c0, 0x800f0000, 0x80020000}, /* W_VP9_COLOR */ + {0xc7c4, 0x0fff0fff, 0x0024000c}, /* BUF */ + {0xc7d0, 0x000000ff, 0x00000026}, /* EXT */ + {0xc800, 0x800f0000, 0x80020000}, /* R_VP9_COLOR */ + {0xc804, 0x1fff1fff, 0x01680012}, /* BUF */ + {0xc810, 0x000000ff, 0x00000027}, /* EXT */ + {0xc840, 0x800f0000, 0x80020000}, /* W_VP9_STATE */ + {0xc844, 0x0fff0fff, 0x0030000a}, /* BUF */ + {0xc850, 0x000000ff, 0x00000028}, /* EXT */ + {0xc880, 0x800f0000, 0x80020000}, /* R_VP9_STATE */ + {0xc884, 0x1fff1fff, 0x017a000a}, /* BUF */ + {0xc890, 0x000000ff, 0x00000029}, /* EXT */ + {0xc8c0, 0x800f0000, 0x80010000}, /* W_VP9_INSN */ + {0xc8c4, 0x0fff0fff, 0x01de0018}, /* BUF */ + {0xc8d0, 0x000000ff, 0x0000005e}, /* EXT */ + {0xc900, 0x800f0000, 0x80020000}, /* R_AV1_BITS */ + {0xc904, 0x1fff1fff, 0x01840016}, /* BUF */ + {0xc910, 0x000000ff, 0x0000002a}, /* EXT */ + {0xc940, 0x800f0000, 0x80020000}, /* R_AV1_BITS */ + {0xc944, 0x1fff1fff, 0x019a0016}, /* BUF */ + {0xc950, 0x000000ff, 0x0000002b}, /* EXT */ + {0xc980, 0x800f0000, 0x80020000}, /* R_AV1_BITS */ + {0xc984, 0x1fff1fff, 0x01b00016}, /* BUF */ + {0xc990, 0x000000ff, 0x0000002c}, /* EXT */ + {0xca00, 0x800f0000, 0x80020000}, /* W_AV1_ABOVE_INFO */ + {0xca04, 0x0fff0fff, 0x003a000a}, /* BUF */ + {0xca10, 0x000000ff, 0x0000002e}, /* EXT */ + {0xca40, 0x800f0000, 0x80020000}, /* W_AV1_ABOVE_INFO */ + {0xca44, 0x0fff0fff, 0x0044000a}, /* BUF */ + {0xca50, 0x000000ff, 0x0000002f}, /* EXT */ + {0xca80, 0x800f0000, 0x80020000}, /* W_AV1_ABOVE_INFO */ + {0xca84, 0x0fff0fff, 0x004e000a}, /* BUF */ + {0xca90, 0x000000ff, 0x00000030}, /* EXT */ + {0xcb00, 0x800f0000, 0x80020000}, /* R_AV1_ABOVE_INFO */ + {0xcb04, 0x1fff1fff, 0x01c60014}, /* BUF */ + {0xcb10, 0x000000ff, 0x00000032}, /* EXT */ + {0xcb40, 0x800f0000, 0x80020000}, /* R_AV1_ABOVE_INFO */ + {0xcb44, 0x1fff1fff, 0x01da0014}, /* BUF */ + {0xcb50, 0x000000ff, 0x00000033}, /* EXT */ + {0xcb80, 0x800f0000, 0x80020000}, /* R_AV1_ABOVE_INFO */ + {0xcb84, 0x1fff1fff, 0x01ee0014}, /* BUF */ + {0xcb90, 0x000000ff, 0x00000034}, /* EXT */ + {0xcc00, 0x800f0000, 0x80020000}, /* W_AV1_SEG */ + {0xcc04, 0x0fff0fff, 0x00580004}, /* BUF */ + {0xcc10, 0x000000ff, 0x00000036}, /* EXT */ + {0xcc40, 0x800f0000, 0x80020000}, /* W_AV1_SEG */ + {0xcc44, 0x0fff0fff, 0x005c0004}, /* BUF */ + {0xcc50, 0x000000ff, 0x00000037}, /* EXT */ + {0xcc80, 0x800f0000, 0x80020000}, /* W_AV1_SEG */ + {0xcc84, 0x0fff0fff, 0x00600004}, /* BUF */ + {0xcc90, 0x000000ff, 0x00000038}, /* EXT */ + {0xcd00, 0x800f0000, 0x80020000}, /* R_AV1_SEG */ + {0xcd04, 0x1fff1fff, 0x02020008}, /* BUF */ + {0xcd10, 0x000000ff, 0x0000003a}, /* EXT */ + {0xcd40, 0x800f0000, 0x80020000}, /* R_AV1_SEG */ + {0xcd44, 0x1fff1fff, 0x020a0008}, /* BUF */ + {0xcd50, 0x000000ff, 0x0000003b}, /* EXT */ + {0xcd80, 0x800f0000, 0x80020000}, /* R_AV1_SEG */ + {0xcd84, 0x1fff1fff, 0x02120008}, /* BUF */ + {0xcd90, 0x000000ff, 0x0000003c}, /* EXT */ + {0xce00, 0x800f0000, 0x80020000}, /* W_AV1_COLOR */ + {0xce04, 0x0fff0fff, 0x00640008}, /* BUF */ + {0xce10, 0x000000ff, 0x0000003e}, /* EXT */ + {0xce40, 0x800f0000, 0x80020000}, /* W_AV1_COLOR */ + {0xce44, 0x0fff0fff, 0x006c0008}, /* BUF */ + {0xce50, 0x000000ff, 0x0000003f}, /* EXT */ + {0xce80, 0x800f0000, 0x80020000}, /* W_AV1_COLOR */ + {0xce84, 0x0fff0fff, 0x00740008}, /* BUF */ + {0xce90, 0x000000ff, 0x00000040}, /* EXT */ + {0xcf00, 0x800f0000, 0x80020000}, /* R_AV1_COLOR0 */ + {0xcf04, 0x1fff1fff, 0x021a0010}, /* BUF */ + {0xcf10, 0x000000ff, 0x00000042}, /* EXT */ + {0xcf40, 0x800f0000, 0x80020000}, /* R_AV1_COLOR0 */ + {0xcf44, 0x1fff1fff, 0x022a0010}, /* BUF */ + {0xcf50, 0x000000ff, 0x00000043}, /* EXT */ + {0xcf80, 0x800f0000, 0x80020000}, /* R_AV1_COLOR0 */ + {0xcf84, 0x1fff1fff, 0x023a0010}, /* BUF */ + {0xcf90, 0x000000ff, 0x00000044}, /* EXT */ + {0xd000, 0x800f0000, 0x80020000}, /* R_AV1_COLOR1 */ + {0xd004, 0x1fff1fff, 0x024a0010}, /* BUF */ + {0xd010, 0x000000ff, 0x00000046}, /* EXT */ + {0xd040, 0x800f0000, 0x80020000}, /* R_AV1_COLOR1 */ + {0xd044, 0x1fff1fff, 0x025a0010}, /* BUF */ + {0xd050, 0x000000ff, 0x00000047}, /* EXT */ + {0xd080, 0x800f0000, 0x80020000}, /* R_AV1_COLOR1 */ + {0xd084, 0x1fff1fff, 0x026a0010}, /* BUF */ + {0xd090, 0x000000ff, 0x00000048}, /* EXT */ + {0xd100, 0x800f0000, 0x80020000}, /* R_AV1_COLOR2 */ + {0xd104, 0x1fff1fff, 0x027a0010}, /* BUF */ + {0xd110, 0x000000ff, 0x0000004a}, /* EXT */ + {0xd140, 0x800f0000, 0x80020000}, /* R_AV1_COLOR2 */ + {0xd144, 0x1fff1fff, 0x028a0010}, /* BUF */ + {0xd150, 0x000000ff, 0x0000004b}, /* EXT */ + {0xd180, 0x800f0000, 0x80020000}, /* R_AV1_COLOR2 */ + {0xd184, 0x1fff1fff, 0x029a0010}, /* BUF */ + {0xd190, 0x000000ff, 0x0000004c}, /* EXT */ + {0xd200, 0x800f0000, 0x80020000}, /* W_AV1_PROBS */ + {0xd204, 0x0fff0fff, 0x007c0016}, /* BUF */ + {0xd210, 0x000000ff, 0x0000004e}, /* EXT */ + {0xd240, 0x800f0000, 0x80020000}, /* W_AV1_PROBS */ + {0xd244, 0x0fff0fff, 0x00920016}, /* BUF */ + {0xd250, 0x000000ff, 0x0000004f}, /* EXT */ + {0xd280, 0x800f0000, 0x80020000}, /* W_AV1_PROBS */ + {0xd284, 0x0fff0fff, 0x00a80016}, /* BUF */ + {0xd290, 0x000000ff, 0x00000050}, /* EXT */ + {0xd300, 0x800f0000, 0x80020000}, /* R_AV1_PROBS */ + {0xd304, 0x1fff1fff, 0x02aa0074}, /* BUF */ + {0xd310, 0x000000ff, 0x00000052}, /* EXT */ + {0xd340, 0x800f0000, 0x80020000}, /* R_AV1_PROBS */ + {0xd344, 0x1fff1fff, 0x031e0074}, /* BUF */ + {0xd350, 0x000000ff, 0x00000053}, /* EXT */ + {0xd380, 0x800f0000, 0x80020000}, /* R_AV1_PROBS */ + {0xd384, 0x1fff1fff, 0x03920074}, /* BUF */ + {0xd390, 0x000000ff, 0x00000054}, /* EXT */ + {0xd400, 0x800f0000, 0x80010000}, /* W_AV1_INSN */ + {0xd404, 0x0fff0fff, 0x01f60016}, /* BUF */ + {0xd410, 0x000000ff, 0x0000005f}, /* EXT */ + {0xd440, 0x800f0000, 0x80010000}, /* W_AV1_INSN */ + {0xd444, 0x0fff0fff, 0x020c0016}, /* BUF */ + {0xd450, 0x000000ff, 0x00000060}, /* EXT */ + {0xd480, 0x800f0000, 0x80010000}, /* W_AV1_INSN */ + {0xd484, 0x0fff0fff, 0x02220016}, /* BUF */ + {0xd490, 0x000000ff, 0x00000061}, /* EXT */ + {0xd500, 0x800f3c00, 0x80011000}, /* R_PIPE_INSN */ + {0xd504, 0x1fff1fff, 0x040600f2}, /* BUF */ + {0xd510, 0x000000ff, 0x00000063}, /* EXT */ + {0xd540, 0x800f3c00, 0x80011000}, /* R_PIPE_INSN */ + {0xd544, 0x1fff1fff, 0x04f800f2}, /* BUF */ + {0xd550, 0x000000ff, 0x00000064}, /* EXT */ + {0xd580, 0x800f3c00, 0x80011000}, /* R_PIPE_INSN */ + {0xd584, 0x1fff1fff, 0x05ea00f2}, /* BUF */ + {0xd590, 0x000000ff, 0x00000065}, /* EXT */ + {0xd5c0, 0x800f3c00, 0x80011000}, /* R_PIPE_INSN */ + {0xd5c4, 0x1fff1fff, 0x06dc00f2}, /* BUF */ + {0xd5d0, 0x000000ff, 0x00000066}, /* EXT */ + {0xe000, 0x00000001, 0x00000001}, /* INTRA_TOP_CLOCK_GATING */ + {0xe080, 0x800f0000, 0x80020000}, /* W_IP_ABOVE_PIX */ + {0xe084, 0x0fff0fff, 0x0000001c}, /* BUF */ + {0xe090, 0x000000ff, 0x00000069}, /* EXT */ + {0xe0c0, 0x800f0000, 0x80020000}, /* R_IP_ABOVE_PIX */ + {0xe0c4, 0x1fff1fff, 0x0000002e}, /* BUF */ + {0xe0d0, 0x000000ff, 0x0000006a}, /* EXT */ + {0xe100, 0x800f0000, 0x80020000}, /* W_LF_ABOVE_PIX */ + {0xe104, 0x0fff0fff, 0x001c0054}, /* BUF */ + {0xe110, 0x000000ff, 0x00000071}, /* EXT */ + {0xe140, 0x800f0000, 0x80020000}, /* R_LF_ABOVE_PIX */ + {0xe144, 0x1fff1fff, 0x002e009e}, /* BUF */ + {0xe150, 0x000000ff, 0x00000072}, /* EXT */ + {0xe180, 0x800f0000, 0x80020000}, /* W_LF_ABOVE_INFO */ + {0xe184, 0x0fff0fff, 0x00700016}, /* BUF */ + {0xe190, 0x000000ff, 0x0000006f}, /* EXT */ + {0xe1c0, 0x800f0000, 0x80020000}, /* R_LF_ABOVE_INFO */ + {0xe1c4, 0x1fff1fff, 0x00cc0022}, /* BUF */ + {0xe1d0, 0x000000ff, 0x00000070}, /* EXT */ + {0xe200, 0x800f0000, 0x80020000}, /* W_LF_LEFT_PIX */ + {0xe204, 0x0fff0fff, 0x00860032}, /* BUF */ + {0xe210, 0x000000ff, 0x00000075}, /* EXT */ + {0xe240, 0x800f0000, 0x80020000}, /* R_LF_LEFT_PIX */ + {0xe244, 0x1fff1fff, 0x00ee0032}, /* BUF */ + {0xe250, 0x000000ff, 0x00000076}, /* EXT */ + {0xe280, 0x800f0000, 0x80020000}, /* W_LF_LEFT_INFO */ + {0xe284, 0x0fff0fff, 0x00b8000c}, /* BUF */ + {0xe290, 0x000000ff, 0x00000073}, /* EXT */ + {0xe2c0, 0x800f0000, 0x80020000}, /* R_LF_LEFT_INFO */ + {0xe2c4, 0x1fff1fff, 0x0120000c}, /* BUF */ + {0xe2d0, 0x000000ff, 0x00000074}, /* EXT */ + {0xe300, 0x800f0000, 0x80020000}, /* W_SR_LEFT_PIX */ + {0xe304, 0x0fff0fff, 0x00c40046}, /* BUF */ + {0xe310, 0x000000ff, 0x00000077}, /* EXT */ + {0xe340, 0x800f0000, 0x80020000}, /* R_SR_LEFT_PIX */ + {0xe344, 0x1fff1fff, 0x012c0046}, /* BUF */ + {0xe350, 0x000000ff, 0x00000078}, /* EXT */ + {0xe380, 0x800f0000, 0x80020000}, /* W_RF_ABOVE_INFO */ + {0xe384, 0x0fff0fff, 0x010a001a}, /* BUF */ + {0xe390, 0x000000ff, 0x00000079}, /* EXT */ + {0xe3c0, 0x800f0000, 0x80020000}, /* R_RF_ABOVE_INFO */ + {0xe3c4, 0x1fff1fff, 0x01720032}, /* BUF */ + {0xe3d0, 0x000000ff, 0x0000007a}, /* EXT */ + {0xe400, 0x800f0000, 0x80020000}, /* W_RF_LEFT_PIX */ + {0xe404, 0x0fff0fff, 0x0124002a}, /* BUF */ + {0xe410, 0x000000ff, 0x0000007d}, /* EXT */ + {0xe440, 0x800f0000, 0x80020000}, /* R_RF_LEFT_PIX */ + {0xe444, 0x1fff1fff, 0x01a4002a}, /* BUF */ + {0xe450, 0x000000ff, 0x0000007e}, /* EXT */ + {0xe480, 0x800f0000, 0x80020000}, /* W_RF_LEFT_INFO */ + {0xe484, 0x0fff0fff, 0x014e000a}, /* BUF */ + {0xe490, 0x000000ff, 0x0000007b}, /* EXT */ + {0xe4c0, 0x800f0000, 0x80020000}, /* R_RF_LEFT_INFO */ + {0xe4c4, 0x1fff1fff, 0x01ce000a}, /* BUF */ + {0xe4d0, 0x000000ff, 0x0000007c}, /* EXT */ + {0xe500, 0x800f7c00, 0x80027c00}, /* W_SW_PIX */ + {0xe504, 0x0fff0fff, 0x016800d0}, /* BUF */ + {0xe510, 0x000000ff, 0x00000085}, /* EXT */ + {0xe540, 0x800f0000, 0x80020000}, /* W_SW_LEFT */ + {0xe544, 0x0fff0fff, 0x015c000c}, /* BUF */ + {0xe550, 0x000000ff, 0x00000083}, /* EXT */ + {0xe580, 0x800f0000, 0x80020000}, /* R_SW_LEFT */ + {0xe584, 0x1fff1fff, 0x01d8000c}, /* BUF */ + {0xe590, 0x000000ff, 0x00000084}, /* EXT */ + {0xe5c0, 0x800f0000, 0x80020000}, /* W_AZ_ABOVE_PIX */ + {0xe5c4, 0x0fff0fff, 0x02380012}, /* BUF */ + {0xe5d0, 0x000000ff, 0x0000007f}, /* EXT */ + {0xe600, 0x800f0000, 0x80020000}, /* R_AZ_ABOVE_PIX */ + {0xe604, 0x1fff1fff, 0x01e40020}, /* BUF */ + {0xe610, 0x000000ff, 0x00000080}, /* EXT */ + {0xe640, 0x800f0000, 0x80020000}, /* W_AZ_LEFT_PIX */ + {0xe644, 0x0fff0fff, 0x024a006c}, /* BUF */ + {0xe650, 0x000000ff, 0x00000081}, /* EXT */ + {0xe680, 0x800f0000, 0x80020000}, /* R_AZ_LEFT_PIX */ + {0xe684, 0x1fff1fff, 0x02040060}, /* BUF */ + {0xe690, 0x000000ff, 0x00000082}, /* EXT */ + {0xe6c0, 0x800ff000, 0x80034000}, /* W_ZIP */ + {0xe6c8, 0x0fff0fff, 0x02ce009e}, /* BUF (CMP) */ + {0xe6cc, 0x0fff0fff, 0x02b6000c}, /* BUF (HDR) */ + {0xe6ec, 0x0000ffff, 0x00008789}, /* EXT */ + {0xe700, 0x800ff000, 0x80034000}, /* W_ZIP */ + {0xe708, 0x0fff0fff, 0x036c009e}, /* BUF (CMP) */ + {0xe70c, 0x0fff0fff, 0x02c2000c}, /* BUF (HDR) */ + {0xe72c, 0x0000ffff, 0x0000888a}, /* EXT */ + {0xe740, 0x800f0000, 0x80020000}, /* W_PIPE_STATS */ + {0xe744, 0x0fff0fff, 0x01580004}, /* BUF */ + {0xe750, 0x000000ff, 0x00000067}, /* EXT */ + {0xe800, 0x00000001, 0x00000001}, /* INTER_TOP_CLOCK_GATING */ + {0xe880, 0x800f0000, 0x80020000}, /* W_MV_ABOVE_INFO */ + {0xe884, 0x0fff0fff, 0x00000016}, /* BUF */ + {0xe890, 0x000000ff, 0x0000006b}, /* EXT */ + {0xe8c0, 0x800f0000, 0x80020000}, /* R_MV_ABOVE_INFO */ + {0xe8c4, 0x1fff1fff, 0x00000022}, /* BUF */ + {0xe8d0, 0x000000ff, 0x0000006c}, /* EXT */ + {0xe900, 0x800f0000, 0x80020000}, /* W_MV_COLOR */ + {0xe904, 0x0fff0fff, 0x00160022}, /* BUF */ + {0xe910, 0x000000ff, 0x0000006d}, /* EXT */ + {0xe940, 0x800f0000, 0x80020000}, /* R_MV_COLOR */ + {0xe944, 0x1fff1fff, 0x0022003e}, /* BUF */ + {0xe950, 0x000000ff, 0x0000006e}, /* EXT */ + {0xe980, 0x80ff0004, 0x80550004}, /* R_ZIP */ + {0xe9a8, 0xffffffff, 0x8d8f8c8e}, /* EXT */ +}; diff --git a/drivers/media/platform/apple/avd/avd.h b/drivers/media/platform/apple/avd/avd.h index f9fbb645b1952..7ec7d5a9fcd30 100644 --- a/drivers/media/platform/apple/avd/avd.h +++ b/drivers/media/platform/apple/avd/avd.h @@ -46,6 +46,8 @@ /* A reset after a timeout hangs the machine: stay parked and retire the decoder */ #define AVD_QUIRK_NO_RECOVERY_RESET BIT(5) +#define AVD_QUIRK_KOPSIA BIT(6) + #define VP_SLOT_NONE 255 #define INST_FIFO_SLOT_NONE 255 @@ -410,6 +412,9 @@ void avd_queue_add_ctx(struct avd_ctx *ctx); void avd_queue_del_ctx(struct avd_ctx *ctx); int avd_open_build_program(struct avd_ctx *ctx); extern const struct avd_backend_ops avd_open_backend; +extern const struct avd_backend_ops avd_kopsia_backend; +int avd_open_submit(struct avd_dev *avd, struct avd_frame *f); +irqreturn_t avd_open_complete(struct avd_dev *avd, u32 status); extern const struct avd_backend_ops avd_apple_backend; extern const struct avd_backend_ops avd_qfw_backend; struct avd_qfw; From bb61904f348574926ab2cdba43425ea53413d7a3 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Thu, 19 Nov 2026 19:29:22 +0100 Subject: [PATCH 5/8] arm64: dts: apple: t8152: describe the Kopsia video decoder Describe the T8152 Kopsia decoder in the SoC peripherals, disabled, so every T8152 board can enable it: its five register banks, PSD service 50 (apple,t8152-psd) as the power domain shared by the decoder and its DART, powered off by genpd while both are idle, and the DART as the apple,t8152-avd-dart instance with its Gen3 TLBI aperture, its initialization tunables and a 64 GiB window at 1 TiB inside the native 1..4 TiB DMA aperture. The tunables are those of the J873g's ADT. Signed-off-by: Thomas Glanzmann --- .../boot/dts/apple/t8152-peripherals.dtsi | 55 ++++++++++++++++++- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/arch/arm64/boot/dts/apple/t8152-peripherals.dtsi b/arch/arm64/boot/dts/apple/t8152-peripherals.dtsi index cab3001ab9086..d1dcb53240fc1 100644 --- a/arch/arm64/boot/dts/apple/t8152-peripherals.dtsi +++ b/arch/arm64/boot/dts/apple/t8152-peripherals.dtsi @@ -229,11 +229,62 @@ status = "disabled"; }; + /* Kopsia decoder: PSD service 50, Gen3 DART streams 0..2. */ + ps_avd: power-controller@303a13200 { + compatible = "apple,t8152-psd"; + reg = <0x3 0x03a13200 0x0 0x100>; + #power-domain-cells = <0>; + label = "avd"; + status = "disabled"; + }; + avd_dart: iommu@485020000 { - compatible = "apple,t8152-dart", "apple,t8110-dart"; - reg = <0x4 0x85020000 0x0 0x20000>; + compatible = "apple,t8152-avd-dart"; + reg = <0x4 0x85020000 0x0 0x20000>, <0x2 0x300 0x0 0x10>; + reg-names = "dart", "tlbi"; interrupts = ; #iommu-cells = <1>; + power-domains = <&ps_avd>; + /* A 64-GiB window within the ADT's 1..4-TiB DMA aperture. */ + apple,dma-range = <0x100 0x0 0x10 0x0>; + apple,tunable = < + 0x20c 0x80000121 0x80000121 + 0x220 0xf0f 0xf0f + 0x224 0xffff 0x909 + 0x300 0x1f31 0x1 + 0x308 0x3ffffffc 0x10000000 + 0x310 0x3ffffffc 0x3ffffffc + 0x800 0xf007f 0x10000 + 0x804 0xf007f 0x20002 + 0x808 0xf007f 0x50006 + 0x80c 0xf007f 0x20026 + 0x810 0xf007f 0x3002a + 0x814 0xf007f 0x40032 + 0x818 0xf007f 0x0 + 0x81c 0xf007f 0x0 + 0x820 0xf007f 0x0 + 0x824 0xf007f 0x0 + 0x828 0xf007f 0x0 + 0x82c 0xf007f 0x0 + 0x830 0xf007f 0x0 + 0x834 0xf007f 0x0 + 0x838 0xf007f 0x0 + 0x83c 0xf007f 0x0 + 0x4600 0x2 0x2 + >; + status = "disabled"; + }; + + avd: video-codec@485400000 { + compatible = "apple,t8152-avd"; + reg = <0x4 0x85400000 0x0 0x12000>, + <0x4 0x85500000 0x0 0x4000>, + <0x4 0x85100000 0x0 0x10000>, + <0x4 0x850c0000 0x0 0x4000>, + <0x4 0x85070000 0x0 0x4000>; + reg-names = "code", "mbox", "ctrl", "wrap", "dma"; + power-domains = <&ps_avd>; + iommus = <&avd_dart 0>, <&avd_dart 1>, <&avd_dart 2>; status = "disabled"; }; From 42cd7faf9034c8035594dc01c1e2186744532499 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Thu, 19 Nov 2026 19:29:27 +0100 Subject: [PATCH 6/8] arm64: dts: apple: j873: enable the Kopsia video decoder Enable the T8152 decoder, its PSD domain and its DART on the J873g. This enables the request decoder node used by FFmpeg and mpv on the M6 Mac mini. The PSD provider supplies both AVD and DART so translation is initialized only after their shared domain is powered. Signed-off-by: Thomas Glanzmann --- arch/arm64/boot/dts/apple/t8152-j873-avd.dtsi | 14 ++++++++++++++ arch/arm64/boot/dts/apple/t8152-j873g.dts | 1 + 2 files changed, 15 insertions(+) create mode 100644 arch/arm64/boot/dts/apple/t8152-j873-avd.dtsi diff --git a/arch/arm64/boot/dts/apple/t8152-j873-avd.dtsi b/arch/arm64/boot/dts/apple/t8152-j873-avd.dtsi new file mode 100644 index 0000000000000..d36cd5ef242b2 --- /dev/null +++ b/arch/arm64/boot/dts/apple/t8152-j873-avd.dtsi @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0+ OR MIT +/* J873g: the Kopsia video decoder (described in t8152-peripherals.dtsi). */ + +&ps_avd { + status = "okay"; +}; + +&avd_dart { + status = "okay"; +}; + +&avd { + status = "okay"; +}; diff --git a/arch/arm64/boot/dts/apple/t8152-j873g.dts b/arch/arm64/boot/dts/apple/t8152-j873g.dts index 169298a6c9e6c..5c229e74d5b0a 100644 --- a/arch/arm64/boot/dts/apple/t8152-j873g.dts +++ b/arch/arm64/boot/dts/apple/t8152-j873g.dts @@ -503,3 +503,4 @@ #include "t8152-j873-ethernet.dtsi" #include "t8152-j873-audio.dtsi" #include "t8152-j873-dcp.dtsi" +#include "t8152-j873-avd.dtsi" From ef8ae783ef2b48363000b8da43edcdbf9d289f88 Mon Sep 17 00:00:00 2001 From: Acelogic Date: Sun, 22 Nov 2026 23:03:55 -0500 Subject: [PATCH 7/8] media: apple: avd: reject a failed first boot on Kopsia The Kopsia backend checks the hardware ID at the first runtime resume. Propagate a failed resume before registering the media device. Preserve the existing firmware transport probe behavior. --- drivers/media/platform/apple/avd/avd-drv.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/apple/avd/avd-drv.c b/drivers/media/platform/apple/avd/avd-drv.c index 2b8ee0f381274..0233dc55a59d9 100644 --- a/drivers/media/platform/apple/avd/avd-drv.c +++ b/drivers/media/platform/apple/avd/avd-drv.c @@ -790,10 +790,15 @@ static int avd_probe(struct platform_device *pdev) * size their contexts before the first decode would power it up. */ ret = pm_runtime_resume_and_get(avd->dev); - if (ret < 0) + if (ret < 0) { + if (avd->variant->quirks & AVD_QUIRK_KOPSIA) { + dev_err_probe(avd->dev, ret, "Kopsia probe boot failed\n"); + goto err_disable_runtime_pm; + } dev_warn(avd->dev, "firmware probe boot failed: %d\n", ret); - else + } else { pm_runtime_put_autosuspend(avd->dev); + } ret = avd_v4l2_init(avd); if (ret) From e75d18571f9d248027d9772025419a13cb52423d Mon Sep 17 00:00:00 2001 From: Acelogic Date: Sun, 22 Nov 2026 23:03:55 -0500 Subject: [PATCH 8/8] media: apple: avd: release probe resources on setup errors Allocate the empty IOMMU domain after the fallible backend, DMA and power-domain setup. Cancel the queue work scheduled on runtime resume and release the empty domain when probe fails after enabling runtime PM. --- drivers/media/platform/apple/avd/avd-drv.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/media/platform/apple/avd/avd-drv.c b/drivers/media/platform/apple/avd/avd-drv.c index 0233dc55a59d9..3de3f241430f5 100644 --- a/drivers/media/platform/apple/avd/avd-drv.c +++ b/drivers/media/platform/apple/avd/avd-drv.c @@ -733,13 +733,6 @@ static int avd_probe(struct platform_device *pdev) return ret; avd->domain = iommu_get_domain_for_dev(avd->dev); - if (avd->domain) { - avd->empty_domain = iommu_paging_domain_alloc(avd->dev); - if (IS_ERR(avd->empty_domain)) { - avd->empty_domain = NULL; - dev_warn(avd->dev, "cannot alloc new empty domain"); - } - } ret = avd_backend_select(avd); if (ret) @@ -782,6 +775,13 @@ static int avd_probe(struct platform_device *pdev) if (ret) return ret; } + if (avd->domain) { + avd->empty_domain = iommu_paging_domain_alloc(avd->dev); + if (IS_ERR(avd->empty_domain)) { + avd->empty_domain = NULL; + dev_warn(avd->dev, "cannot alloc new empty domain"); + } + } avd_pm_enable(avd); /* @@ -809,6 +809,9 @@ static int avd_probe(struct platform_device *pdev) err_disable_runtime_pm: pm_runtime_dont_use_autosuspend(&pdev->dev); pm_runtime_disable(&pdev->dev); + cancel_delayed_work_sync(&avd->queue_work); + if (avd->empty_domain) + iommu_domain_free(avd->empty_domain); return ret; }