Skip to content
Closed
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
22 changes: 12 additions & 10 deletions install/hardware/intel/video-acceleration.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# This installs hardware video acceleration for Intel GPUs

if INTEL_GPU=$(lspci | grep -iE 'vga|3d|display' | grep -i 'intel'); then
# HD Graphics / Iris / Xe / Arc / Non-Arc Panther Lake use intel-media-driver + VPL
if [[ ${INTEL_GPU,,} =~ (hd\ graphics|uhd\ graphics|xe|iris|arc|panther\ lake) ]]; then
omarchy-pkg-add intel-media-driver libvpl vpl-gpu-rt
elif [[ ${INTEL_GPU,,} =~ "gma" ]]; then
# Older generations from 2008 to ~2014-2017 use libva-intel-driver
omarchy-pkg-add libva-intel-driver
fi
# This installs hardware video acceleration for Intel GPUs.
#
# GPU generation can't be reliably told apart from the lspci name alone: "HD
# Graphics" is Intel's marketing name for both Gen7 (Ivy Bridge, needs the i965
# driver) and Gen8+ (Broadwell and later, needs iHD), and some older
# generations (Ironlake, Sandy Bridge, Haswell-ULT) don't say "HD Graphics" or
# "gma" at all, so they matched neither branch here and got no driver.
# Rather than chase the naming with a generation table, install both drivers;
# libva probes them in order at runtime and uses whichever one initializes for
# the GPU it finds, so this is correct on every generation without a table.
if lspci | grep -iE 'VGA compatible controller|3D controller|Display controller' | grep -qi 'intel'; then
omarchy-pkg-add intel-media-driver libva-intel-driver libvpl vpl-gpu-rt
fi
14 changes: 14 additions & 0 deletions migrations/1787689809.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
echo "Install libva-intel-driver alongside intel-media-driver for Intel GPU video acceleration"

# install/hardware/intel/video-acceleration.sh used to pick a single VA-API
# driver by matching the GPU's marketing name from lspci. "HD Graphics" names
# both Gen7 (Ivy Bridge, needs libva-intel-driver/i965) and Gen8+ (Broadwell+,
# needs intel-media-driver/iHD) parts, and some older generations (Ironlake,
# Sandy Bridge, Haswell-ULT) matched neither branch and got no driver at all.
# Existing installs on the wrong side of that regex are left with a driver
# that fails to initialize (or none), and this repair doesn't run itself, so
# bring them in line with the new install-time behavior: install both
# drivers and let libva pick the one that actually works for the GPU present.
if lspci | grep -iE 'VGA compatible controller|3D controller|Display controller' | grep -qi 'intel'; then
omarchy-pkg-add intel-media-driver libva-intel-driver libvpl vpl-gpu-rt
fi
89 changes: 89 additions & 0 deletions test/shell.d/intel-video-acceleration-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/bin/bash

set -euo pipefail

source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"

leaf="$ROOT/install/hardware/intel/video-acceleration.sh"
migration=$(grep -l 'intel-media-driver libva-intel-driver' "$ROOT"/migrations/*.sh | head -1)

[[ -n $migration ]] || fail "a migration brings existing installs onto both VA-API drivers"
pass "a migration brings existing installs onto both VA-API drivers"

test_tmp=$(mktemp -d)
trap 'rm -rf "$test_tmp"' EXIT
mkdir -p "$test_tmp/bin"

cat >"$test_tmp/bin/lspci" <<'SH'
#!/bin/bash
printf '%s\n' "${TEST_LSPCI_LINE:-00:02.0 VGA compatible controller: Intel Corporation Ivy Bridge mobile GT2 [HD Graphics 4000] (rev 09)}"
SH

cat >"$test_tmp/bin/omarchy-pkg-add" <<'SH'
#!/bin/bash
printf 'pkg-add %s\n' "$*" >>"$CALL_LOG"
SH

chmod +x "$test_tmp/bin"/*

call_log="$test_tmp/calls.log"

run_leaf() {
: >"$call_log"
PATH="$test_tmp/bin:$PATH" \
CALL_LOG="$call_log" \
TEST_LSPCI_LINE="${1-}" \
bash -c 'source "$1"' bash "$leaf"
}

# Ivy Bridge "HD Graphics 4000" used to match the same name-based branch as
# Broadwell+ and get only intel-media-driver, which can't decode on Gen7 and
# leaves vaInitialize failing outright (confirmed on real Ivy Bridge hardware
# in basecamp/omarchy#7866). Installing both drivers means libva's own
# fallback probing picks the one that actually initializes, regardless of
# generation.
run_leaf
grep -q 'pkg-add intel-media-driver libva-intel-driver libvpl vpl-gpu-rt' "$call_log" ||
fail "the leaf installs both VA-API drivers on Ivy Bridge HD Graphics 4000"
pass "the leaf installs both VA-API drivers on Ivy Bridge HD Graphics 4000"

# Haswell-ULT and other older parts that don't say "HD Graphics" or "gma" at
# all used to match neither branch and got no driver installed.
run_leaf "00:02.0 VGA compatible controller: Intel Corporation Haswell-ULT Integrated Graphics Controller (rev 0b)"
grep -q 'pkg-add intel-media-driver libva-intel-driver libvpl vpl-gpu-rt' "$call_log" ||
fail "the leaf installs both VA-API drivers on hardware with no name match"
pass "the leaf installs both VA-API drivers on hardware with no name match"

run_leaf "00:02.0 VGA compatible controller: NVIDIA Corporation GA104M"
[[ -s $call_log ]] && fail "the leaf no-ops on non-Intel GPUs"
pass "the leaf no-ops on non-Intel GPUs"

# A PCI bus address like "3d:00.0" contains "3d" as plain text, and an
# unrelated Intel device sitting at that address (not a GPU) also contains
# "Intel" in its description. Detection has to key off the actual PCI class
# name, not a bare substring, or a device like this triggers installing the
# video-acceleration stack for no GPU at all.
run_leaf "3d:00.0 Non-Volatile memory controller: Intel Corporation NVMe SSD Controller"
[[ -s $call_log ]] && fail "the leaf no-ops on a non-GPU Intel device at a bus address containing 3d"
pass "the leaf no-ops on a non-GPU Intel device at a bus address containing 3d"

run_migration() {
: >"$call_log"
PATH="$test_tmp/bin:$PATH" \
CALL_LOG="$call_log" \
TEST_LSPCI_LINE="${1-}" \
bash -euo pipefail "$migration" >/dev/null
}

run_migration
grep -q 'pkg-add intel-media-driver libva-intel-driver libvpl vpl-gpu-rt' "$call_log" ||
fail "the migration brings existing Intel installs onto both VA-API drivers"
pass "the migration brings existing Intel installs onto both VA-API drivers"

run_migration "00:02.0 VGA compatible controller: NVIDIA Corporation GA104M"
[[ -s $call_log ]] && fail "the migration no-ops on non-Intel GPUs"
pass "the migration no-ops on non-Intel GPUs"

run_migration "3d:00.0 Non-Volatile memory controller: Intel Corporation NVMe SSD Controller"
[[ -s $call_log ]] && fail "the migration no-ops on a non-GPU Intel device at a bus address containing 3d"
pass "the migration no-ops on a non-GPU Intel device at a bus address containing 3d"