Merge pull request #451 from scottjones/contrib/avd

Add Apple Silicon video-decoder firmware and VA-API packages
This commit is contained in:
Marcelo Alcantara authored and GitHub committed 2026-09-23 17:34:21 +10:00
commit 09784fcc92
5 files changed
+148

No files matched your search

+9
View File
@@ -0,0 +1,9 @@
{
"source": "local",
"upstream": {
"watch": {
"pattern": "v(?P<version>[0-9]+(?:\\.[0-9]+)*)",
"git_tags": "https://github.com/AsahiLinux/avd-fw.git"
}
}
}
+51
View File
@@ -0,0 +1,51 @@
# Open replacement firmware for the Apple Video Decoder.
# Built from AsahiLinux sources, without extracting proprietary firmware.
pkgname=avd-fw
pkgver=0.1
pkgrel=1
pkgdesc='Open replacement firmware for the Apple Video Decoder (AVD) on Apple Silicon'
# This recipe uses the native ARM linker and serves Apple Silicon systems.
# Restrict both builds and publication to aarch64.
arch=('aarch64')
url='https://github.com/AsahiLinux/avd-fw'
license=('MIT')
# clang cross-compiles to arm-none-eabi out of the box, so no arm-none-eabi
# toolchain is required; llvm supplies llvm-objcopy, which meson.build looks
# up by name to turn each linked ELF into a padded raw image.
makedepends=('meson' 'clang' 'llvm')
# !buildflags is load-bearing: makepkg's CFLAGS/LDFLAGS target the aarch64 host
# and would be injected into a bare-metal Cortex-M3 build. !strip keeps makepkg
# from running the host strip over raw firmware images.
options=('!strip' '!debug' '!buildflags' '!lto')
source=("$pkgname-$pkgver.tar.gz::$url/archive/refs/tags/v$pkgver.tar.gz")
sha256sums=('2e131244275cb15c94243e41eec8a2a665ec895cfe3a818181549db991e62c67')
build() {
# The cross file selects clang, pins the host machine to cortex-m3 and sets
# libdir=lib, which lands the images in /usr/lib/firmware/apple.
#
# Optimization is pinned to match upstream's Makefile (-O2). Meson's default
# buildtype is "debug" (-O0 -g), which would ship unoptimized firmware; the
# MMIO accessors in src/util.c go through a volatile typedef, so -O2 cannot
# elide register reads or writes.
meson setup \
--cross-file "$pkgname-$pkgver/llvm.ini" \
--prefix=/usr \
-Doptimization=2 \
-Ddebug=false \
"$pkgname-$pkgver" build
meson compile -C build
}
package() {
meson install -C build --destdir "$pkgdir"
# meson installs custom_target outputs 0755; these are firmware blobs, not
# programs, and every other firmware file on the system is 0644.
chmod 644 "$pkgdir"/usr/lib/firmware/apple/*.bin
install -Dm644 "$pkgname-$pkgver/LICENSE" \
"$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
@@ -0,0 +1,12 @@
{
"source": "local",
"upstream": {
"watch": {
"git_tags": "https://github.com/sofus13/libva-v4l2_request.git",
"pattern": "(?P<version>[0-9]+(?:\\.[0-9]+)*)"
}
},
"rebuild_on": [
"libva"
]
}
+55
View File
@@ -0,0 +1,55 @@
# VA-API driver with Apple Video Decoder fixes from the sofus13 fork.
# The asahi alias lets libva discover it on Apple Silicon.
_fork=sofus13
pkgname=libva-v4l2_request-avd
pkgver=1.3
pkgrel=1
pkgdesc='VA-API driver for V4L2 stateless decoders, with Apple Video Decoder (AVD) support'
arch=('aarch64')
url="https://github.com/$_fork/libva-v4l2_request"
license=('GPL-3.0-or-later')
# The driver is a dlopen()ed plugin: it links only libc and exports the VA
# backend entry point (__vaDriverInit_1_24), so libva is a runtime rather than
# a link-time dependency -- and that symbol is versioned, so this needs a
# rebuild whenever libva's driver ABI is bumped. libdrm is only used for
# drm_fourcc.h constants at compile time.
depends=('glibc' 'libva')
makedepends=('meson' 'libdrm')
provides=('libva-v4l2_request')
conflicts=('libva-v4l2_request')
install="$pkgname.install"
source=("$pkgname-$pkgver.tar.gz::$url/archive/refs/tags/$pkgver.tar.gz")
sha256sums=('3670a1712f9f0a5a61bd44a781eba81dd9b2e0fd8271417ca8a9fbbed9dccfe9')
build() {
# driverdir is left unset so meson takes it from libva's pkg-config
# (/usr/lib/dri); the codec set is decided by configure-time checks against
# the kernel uapi headers, so linux-api-headers governs what gets built in.
# Plain meson rather than arch-meson: the latter lives in devtools, which is
# not a safe assumption outside a clean chroot. buildtype=plain hands the
# compiler makepkg's own CFLAGS/LDFLAGS, which is what arch-meson does too.
meson setup \
--prefix=/usr \
--buildtype=plain \
--wrap-mode=nodownload \
"libva-v4l2_request-$pkgver" build
meson compile -C build
}
package() {
meson install -C build --destdir "$pkgdir"
# libva picks its driver from the DRM driver name of the render node, which
# on Apple Silicon is "asahi", so it looks for asahi_drv_video.so. Nothing
# else ships that name (mesa provides no VA driver for asahi), so aliasing it
# here makes every VA-API application find the decoder with no environment
# variable at all. If mesa ever ships its own asahi_drv_video.so this will
# collide and pacman will say so at install time.
ln -sf v4l2_request_drv_video.so "$pkgdir/usr/lib/dri/asahi_drv_video.so"
install -Dm644 "libva-v4l2_request-$pkgver/COPYING" \
"$pkgdir/usr/share/licenses/$pkgname/COPYING"
install -Dm644 "libva-v4l2_request-$pkgver/README" \
"$pkgdir/usr/share/doc/$pkgname/README"
}
@@ -0,0 +1,21 @@
post_install() {
cat <<'MSG'
==> This package installs itself as asahi_drv_video.so as well, which is the
name libva looks for on Apple Silicon, so VA-API applications should pick
the decoder up with no configuration.
If something does not, select it explicitly for the session:
LIBVA_DRIVER_NAME=v4l2_request
==> Check with: vainfo
==> mpv: mpv --hwdec=vaapi video.mp4
==> Firefox: additionally needs MOZ_DISABLE_RDD_SANDBOX=1, because the RDD
sandbox blocks the /dev/video* and /dev/media* access this
driver requires. That weakens Firefox's media sandbox.
MSG
}
post_upgrade() {
post_install
}