Skip to content

media: apple: avd: introduce frame slots and backend transport foundation - #701

Merged
RyanTheTide merged 9 commits into
aurora-wipfrom
avd/rewrite-core
Nov 1, 2026
Merged

RyanTheTide merged 9 commits into
aurora-wipfrom
avd/rewrite-core

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

AVD currently ties buffer ownership and mem2mem scheduling to one job context. This draft moves ownership into a 16-slot pool with generation tags, per-frame deadlines, inbox retry and ordered retirement per context. Existing codecs run through the open-firmware compatibility backend; their instruction programs now belong to the frame slot.

The shared avd-queue.h was published verbatim first in 138aa88. Subsequent changes only extend that interface. No firmware image is included.

This is an incomplete foundation draft, not ready for merge or hardware deployment:

  • The deployed open firmware remains limited to one frame and retains its host PP kick. Native frame programs need the queued avd-fw ABI before they can run through that backend.
  • Borage command builders, boot/load framework, inbox and completion handling are present, but Apple activation is disabled in T6040 match data. The clean specification lacks the ITCM/version register offsets, mailbox link writes, result area and final reply layout. avd-protocol.rst records those gaps. The synthetic parser test layout is explicitly not a Borage wire layout.
  • H.264 and HEVC queues advertising HOLD_CAPTURE_BUF retain mem2mem scheduling until retire because V4L2 currently warns unconditionally on job_finish() for them. Other queues release scheduling at submit. A separate V4L2 API change is needed to lift that restriction.

Validation: KUnit tests are supplied for dispatch reservation, slot states, tag reuse rejection, per-context retirement order, watchdog wrap, inbox-full retry, command builders and completion parsing. A host harness is supplied to exercise the production helpers over 100,000 shuffled operations; it has not run. Strict checkpatch reports 0 errors, 0 warnings and 0 checks on the new implementation/test C and helper headers. The verbatim shared contract retains its supplied comment-style warnings. Buildbox requests h-46772, h-46781 and h-46789 were auto-approved, then refused by the build volume STOP/free-space guard. Final source retry h-46793 targets a116172 and remains auto-approved, awaiting controller execution. Tests and arm64 W=1/WERROR compilation are not yet claimed as passing.

Lead hardware checks, after build verification and integration (all target access must use the controller, explicit device identity and policy approval): stage the agreed synthetic samples at /tmp/avd-samples, then run the commands below through the lead's approved J616s execute request. These commands play no audio and have no usage/presence gates.

set -eu
uname -r
v4l2-ctl --list-devices
for codec in h264 vp9 av1; do
  case "$codec" in
    h264) parser=h264parse; decoder=v4l2slh264dec ;;
    vp9) parser=vp9parse; decoder=v4l2slvp9dec ;;
    av1) parser=av1parse; decoder=v4l2slav1dec ;;
  esac
  gst-inspect-1.0 "$decoder" >/dev/null
  gst-launch-1.0 -q filesrc location="/tmp/avd-samples/$codec-1080.mp4" ! qtdemux ! "$parser" ! "$decoder" ! videoconvert ! video/x-raw,format=I420 ! filesink location="/tmp/avd-$codec-hw.i420"
  ffmpeg -v error -i "/tmp/avd-samples/$codec-1080.mp4" -an -pix_fmt yuv420p -fps_mode passthrough -f rawvideo -y "/tmp/avd-$codec-sw.i420"
  cmp "/tmp/avd-$codec-hw.i420" "/tmp/avd-$codec-sw.i420"
done
dmesg | tail -200

Also required before lifting draft status: tagged queue-depth 1/2/4/8/16, two concurrent contexts, streamoff with RESERVED and SUBMITTED slots, timeout/reset injection, stale/duplicate completion injection, idle/resume and suspend/resume. Those need the queued firmware integration; the compatibility backend cannot prove 16-frame operation. Apple boot checks additionally need the missing clean register ledger and capture-verified reply fields.

Rollback: restore the previous tested kernel and separately installed open firmware. There are no DT changes, embedded Apple bytes, local machine overrides, module parameters or target writes in this draft.

Keep the legacy open firmware serialized while moving program storage and completion ownership into tagged frame slots. Leave Borage activation dependent on the register and completion facts absent from the clean specification.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
Add deterministic host tests against production helpers and KUnit coverage of slot reuse, ordered retirement, watchdog wrap, inbox retry, command builders and completion parsing. Track the unproved Borage fields explicitly and preserve session generations over firmware reboot.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
Remove contexts from the scheduling list before releasing their m2m state, reject already-scheduled jobs during teardown, and keep Apple fp pointers absent on the open backend. Preserve tagged slots over inbox-full retries and avoid periodic watchdog wakeups when only submitted frames remain.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
Keep the CODECS trailer intersection with the SoC capability table when selecting the open backend. Bound firmware copies by the mapped code resource.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
Only the H.264 compatibility builder explicitly completes held slice requests during preparation. Continue submitting legacy HEVC requests that retain their capture buffer.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
…ation

Prevent queued contexts from observing the same free capacity. Run preparation on a context work item because m2m try_schedule can invoke device_run synchronously while the queue mutex is held. Drain that work before freeing the context.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant