Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
138aa88
media: apple: avd: publish shared frame queue contract
RyanTheTide Oct 31, 2026
02c13a1
media: apple: avd: introduce owned frame slots and backend transports
RyanTheTide Oct 31, 2026
bf09ea0
media: apple: avd: exercise queue ownership and document transport gaps
RyanTheTide Oct 31, 2026
e621658
media: apple: avd: tighten slot teardown and backend buffer ownership
RyanTheTide Oct 31, 2026
0b31a30
media: apple: avd: polish queue test configuration and formatting
RyanTheTide Oct 31, 2026
8f5f714
media: apple: avd: preserve open firmware capability filtering
RyanTheTide Oct 31, 2026
3f25108
media: apple: avd: retain legacy HEVC held-buffer submissions
RyanTheTide Oct 31, 2026
c6f63da
media: apple: avd: reserve m2m dispatch capacity and defer CPU prepar…
RyanTheTide Oct 31, 2026
a116172
media: apple: avd: reject failed native request setup
RyanTheTide Oct 31, 2026
3be5408
media: apple: avd: coordinate frame queue runtime and system power
RyanTheTide Oct 31, 2026
911061f
media: apple: avd: keep the host IRQ closed while powered off
RyanTheTide Oct 31, 2026
38ef5b9
media: apple: avd: replay PIODMA setup and restore DART on recovery
RyanTheTide Oct 31, 2026
0eaf595
media: apple: avd: centralize boot replay for open transports
RyanTheTide Oct 31, 2026
e2e4736
Merge branch avd/power-idle into avd/rewrite-integ
RyanTheTide Oct 31, 2026
dcaa34c
media: apple: avd: cap Apple frames in flight at the FIFO count
RyanTheTide Oct 31, 2026
829bcab
media: apple: avd: advertise T6040 HEVC with h265-capable firmware
RyanTheTide Oct 31, 2026
44f86ac
media: apple: avd: poll the VP queue level instead of a fixed sleep
RyanTheTide Oct 31, 2026
0a83a87
media: apple: avd: queued transport for the open firmware
RyanTheTide Oct 31, 2026
415972f
media: apple: avd: clear the queue info block before each firmware boot
RyanTheTide Oct 31, 2026
71a03d2
media: apple: avd: overlap H.264 pictures on the queued transport
RyanTheTide Oct 31, 2026
b94a760
media: apple: avd: overlap HEVC pictures and gate held-back codecs on…
RyanTheTide Oct 31, 2026
2d0d23f
media: apple: avd: give the queue host test a dma_addr_t
RyanTheTide Oct 31, 2026
7c878fb
media: apple: avd: never wait for the IRQ thread while it may need qu…
RyanTheTide Oct 31, 2026
3eac43b
media: apple: avd: kick PP for every VP DONE on the legacy transport
RyanTheTide Oct 31, 2026
c5f9ad8
media: apple: avd: do not pop an empty firmware mailbox
RyanTheTide Oct 31, 2026
58e286e
media: apple: avd: log each decoder recovery step
RyanTheTide Oct 31, 2026
2f4cdb5
Merge aurora-wip aa07c003da03 into avd/rewrite-integ
RyanTheTide Oct 31, 2026
422060f
media: apple: avd: stop a decoder error storm instead of resetting in…
RyanTheTide Oct 31, 2026
e329d37
media: apple: avd: accept FFmpeg's HEVC slice layout
RyanTheTide Oct 31, 2026
f158937
media: apple: avd: include bitfield.h for the instruction macros
RyanTheTide Oct 31, 2026
11138e4
media: apple: avd: check the DART state before logging recovery
RyanTheTide Oct 31, 2026
01de6ce
media: apple: avd: dispatch m2m jobs in order instead of reserving on…
RyanTheTide Oct 31, 2026
01e8ce8
media: apple: avd: tolerate backends without max_inflight in the queue
RyanTheTide Oct 31, 2026
9043840
media: apple: avd: harden decoder access against machine-wide hangs
RyanTheTide Oct 31, 2026
d826cca
media: apple: avd: wait for a closing stream's frames instead of rese…
RyanTheTide Oct 31, 2026
037449e
media: apple: avd: stream queued programs into SRAM with 32-bit stores
RyanTheTide Oct 31, 2026
9844fa5
media: apple: avd: close queued transport ownership and ring gaps
RyanTheTide Nov 1, 2026
6e3a36c
media: v4l2-mem2mem: support detached buffers for pipelined dispatch
RyanTheTide Nov 1, 2026
49a89ec
Merge aurora-wip 05292477 into avd/rewrite-integ
RyanTheTide Nov 1, 2026
9b125f8
media: apple: avd: require the saved queued FIFO and audit bank addre…
RyanTheTide Nov 1, 2026
cbbe442
Merge aurora-wip f41ac3de into avd/rewrite-integ
RyanTheTide Nov 1, 2026
f2fff71
media: apple: avd: release VP9 probability dependencies at VP DONE
RyanTheTide Nov 1, 2026
8cc0f39
tools: asahi: test the rewritten AVD capability parser
RyanTheTide Nov 1, 2026
a1b7685
media: apple: avd: publish VP9 banks after initialization
RyanTheTide Nov 1, 2026
9df30b7
media: apple: avd: tests: point at the avd-fw VP DONE commit
RyanTheTide Nov 1, 2026
6910946
media: apple: avd: tests: point at the avd-fw queue IRQ fix commit
RyanTheTide Nov 1, 2026
2f9bd00
media: apple: avd: overlap AV1 pictures with immutable tail inputs
RyanTheTide Nov 1, 2026
655227d
Revert "media: apple: avd: overlap AV1 pictures with immutable tail i…
RyanTheTide Nov 1, 2026
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
5 changes: 2 additions & 3 deletions drivers/media/platform/apple/avd/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ config VIDEO_APPLE_AVD_KUNIT_TEST
default KUNIT_ALL_TESTS
help
Build KUnit tests for the Apple video decoder. They exercise the
checks that the H.264 path makes on the slices that userspace
queues, such as finding the slice data after the slice header,
at the limits and one past them.
H.264 slice bounds, frame-slot ownership, and runtime power management,
including suspend gating and resubmission after firmware resume.

If unsure, say N.
8 changes: 5 additions & 3 deletions drivers/media/platform/apple/avd/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# SPDX-License-Identifier: GPL-2.0-only

apple-avd-y := avd-drv.o avd-v4l2.o avd-hw.o avd-h264.o avd-vp9.o avd-hevc.o \
avd-av1.o avd-av1-entropymode.o
apple-avd-$(CONFIG_VIDEO_APPLE_AVD_KUNIT_TEST) += avd-h264-test.o
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
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
141 changes: 141 additions & 0 deletions drivers/media/platform/apple/avd/avd-apple-protocol.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/* SPDX-License-Identifier: GPL-2.0-only OR MIT */
#ifndef AVD_APPLE_PROTOCOL_H_
#define AVD_APPLE_PROTOCOL_H_

#include <linux/errno.h>
#include <linux/types.h>

#include "avd-queue.h"

#define AVD_APPLE_INBOX_BASE 0x01482cf8
#define AVD_APPLE_COMMAND_SIZE 0x60
#define AVD_APPLE_RESULT_WORDS 20
#define AVD_APPLE_SHADOW_SIZE 64

/*
* [C] Expected address notification, from the MIT V3 trace_avd.py precedent.
* Keep this rule in one place for correction by the Borage capture.
*/
#define AVD_APPLE_NOTIFY_BASE AVD_APPLE_INBOX_BASE

/* SPEC 5.1: only these session opcodes have proved builders. */
static inline int
avd_apple_session_command(u32 cmd[24], u32 client, u32 opcode,
u32 property, u32 value)
{
unsigned int i;

if (client >= 1024 || (opcode != 0 && opcode != 2 && opcode != 5 && opcode != 6))
return -EINVAL;
for (i = 0; i < 24; i++)
cmd[i] = 0;
cmd[0] = opcode | (client << 16);
if (opcode == 6) {
cmd[1] = property;
cmd[2] = value;
}
return 0;
}

static inline int avd_apple_decode_prefix(struct avd_frame *f, u32 client,
u32 selector, u32 work_sequence)
{
unsigned int i;

if (f->idx >= AVD_MAX_FRAMES || client >= 1024 || selector >= 16 || work_sequence >= 4)
return -EINVAL;
for (i = 0; i < 24; i++)
f->cmd[i] = 0;
f->cmd[0] = 1 | (selector << 10) | (client << 22);
f->cmd[1] = f->idx | (work_sequence << 16);
f->cmd[3] = f->frame_num;
return 0;
}

struct avd_apple_reply_layout {
u8 type_word;
u8 type_shift;
u32 type_mask;
u8 client_word;
u8 client_shift;
u32 client_mask;
u8 frame_word;
u8 status_word;
u32 done_type;
bool verified;
};

struct avd_apple_reply {
u32 type;
u32 client;
u32 frame;
int status;
};

static inline int
avd_apple_parse_reply(const u32 *record, size_t words,
const struct avd_apple_reply_layout *layout,
struct avd_apple_reply *reply)
{
if (words != AVD_APPLE_RESULT_WORDS)
return -EMSGSIZE;
if (!layout->verified)
return -EOPNOTSUPP;
if (layout->type_word >= words || layout->client_word >= words ||
layout->frame_word >= words || layout->status_word >= words ||
layout->type_shift >= 32 || layout->client_shift >= 32 ||
!layout->type_mask || !layout->client_mask || layout->done_type == 7)
return -EINVAL;
reply->type = (record[layout->type_word] >> layout->type_shift) & layout->type_mask;
reply->client = (record[layout->client_word] >> layout->client_shift) & layout->client_mask;
reply->frame = record[layout->frame_word];
/* SPEC 4.3: type 7 is parsing/VP done, never final buffer ownership. */
if (reply->type == 7)
return -EINPROGRESS;
if (reply->type != layout->done_type)
return -ENOMSG;
reply->status = record[layout->status_word] ? -EIO : 0;
return 0;
}

static inline u32 avd_apple_notification(unsigned int slot)
{
return AVD_APPLE_NOTIFY_BASE + AVD_APPLE_COMMAND_SIZE * slot;
}

struct avd_apple_hw {
const char *fw_name;
/* All offsets below are relative to a DT-owned "apple" resource. */
u32 aperture_origin;
u32 imem;
u32 imem_size;
u32 version_offset;
u32 itcm_start;
u32 itcm_end;
u32 itcm_clear;
u32 itcm_clear_value;
u32 itcm_enable;
u32 itcm_enable_value;
u32 link_setup;
u32 link_setup_value;
u32 link_state;
u32 link_up;
u32 link_up_value;
u32 ready;
u32 notify;
u32 receive;
u32 receive_status;
u32 receive_pending;
u32 receive_ack;
u32 receive_ack_value;
u32 inbox_consumer;
u32 result_base;
struct avd_apple_reply_layout reply;
/* Match-data fact, never a module parameter or a userspace setting. */
bool verified;
};

extern const struct avd_apple_hw avd_borage_hw;
extern const u8 avd_borage_config[64];

#endif /* AVD_APPLE_PROTOCOL_H_ */
8 changes: 8 additions & 0 deletions drivers/media/platform/apple/avd/avd-av1.c
Original file line number Diff line number Diff line change
Expand Up @@ -1525,6 +1525,13 @@ static enum avd_image_fmt avd_av1_get_image_fmt(struct avd_ctx *ctx,
#undef BIT_DEPTH
}

static unsigned int avd_av1_pp_kicks(struct avd_ctx *ctx)
{
struct avd_av1_ctx *priv = ctx->priv;

return max_t(int, priv->submit_num, 1);
}

static void avd_av1_submit(struct avd_ctx *ctx)
{
struct avd_av1_ctx *av1_ctx = ctx->priv;
Expand Down Expand Up @@ -1580,6 +1587,7 @@ const struct avd_coded_fmt_ops avd_av1_fmt_ops = {
.stop = avd_av1_stop,
.run = avd_av1_run,
.submit = avd_av1_submit,
.pp_kicks = avd_av1_pp_kicks,
.try_ctrl = avd_av1_try_ctrl,
.get_image_fmt = avd_av1_get_image_fmt,
};
Loading