Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions install/hardware/all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ run_logged "$OMARCHY_INSTALL/hardware/lenovo/fix-yoga-pro7-bass-speakers.sh"
run_logged "$OMARCHY_INSTALL/hardware/lenovo/yoga-slim7x.sh"
run_logged "$OMARCHY_INSTALL/hardware/lenovo/thinkpad-t14s-camera.sh"
run_logged "$OMARCHY_INSTALL/hardware/microsoft/surface-pro-11.sh"
run_logged "$OMARCHY_INSTALL/hardware/microsoft/surface-laptop8.sh"

run_logged "$OMARCHY_INSTALL/hardware/fix-bcm43xx.sh"
run_logged "$OMARCHY_INSTALL/hardware/fix-surface-keyboard.sh"
Expand Down
61 changes: 61 additions & 0 deletions install/hardware/microsoft/surface-laptop8.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Microsoft Surface Laptop 8 (13.8-inch, Snapdragon X2 Elite) board-specific setup.

mkinitcpio_dir=${OMARCHY_SURFACE_LAPTOP8_MKINITCPIO_DIR:-/etc/mkinitcpio.conf.d}

if omarchy-hw-aarch64-qualcomm && omarchy-hw-match-device-tree microsoft,surface-laptop8; then
echo "Detected Microsoft Surface Laptop 8, applying board-specific support..."

# Bring up the panel and the keyboard before disk unlock. As in
# qualcomm/initramfs.sh, the ? skips a module a kernel does not have, so its
# image still builds.
# - msm needs the GPU and its clock and power controllers before the panel
# comes up, and none of these is a module dependency of it.
# - The display waits for the pmic_glink alternate-mode bridges and the USB4
# host mux, which thunderbolt_qcom registers from linux-omarchy 7.3-5 (in
# thunderbolt before that); the panel waits for its PWM backlight.
# - pmic_glink runs on the SOCCP, which the boot firmware starts and
# qcom_q6v5_pas attaches to. Unlike the Surface Pro 11, the panel needs it,
# so it is listed here. firmware.sh's blacklist for a USB root disk still
# applies in the initramfs, so with the root disk on USB the panel has no
# pmic_glink at disk unlock.
# - The keyboard is a HID device behind the Surface Aggregator Module.
mkdir -p "$mkinitcpio_dir"
cat >"$mkinitcpio_dir/surface-laptop8-initramfs.conf" <<'CONF'
MODULES+=(msm? panel_edp? phy_qcom_edp? gpucc_glymur? gxclkctl_kaanapali?
qrtr? qcom_q6v5_pas? thunderbolt? thunderbolt_qcom? thunderbolt_platform? pmic_glink? pmic_glink_altmode?
ucsi_glink? leds_qcom_lpg? pwm_bl? surface_aggregator? surface_aggregator_registry?
surface_hid_core? surface_hid? nvme?)

# qcom_q6v5_pas starts the ADSP and CDSP from the initramfs and does not retry
# once the root filesystem is up, so their firmware, which qcom-firmware-extract
# copies from Windows, goes in the image too. msm requests the GPU's startup
# pair when the display starts but declares no firmware for this GPU.
# Search like the kernel does: each suffix in every directory, then the next.
for firmware in \
qcom/gen80100_sqe.fw \
qcom/gen80100_gmu.bin \
qcom/glymur/microsoft/surface-laptop8/qcadsp8480.mbn \
qcom/glymur/microsoft/surface-laptop8/adsp_dtbs.elf \
qcom/glymur/microsoft/surface-laptop8/qccdsp8480.mbn \
qcom/glymur/microsoft/surface-laptop8/cdsp_dtbs.elf; do
for suffix in '' .zst .xz; do
for directory in "${OMARCHY_SURFACE_LAPTOP8_FIRMWARE_ROOT:-/usr/lib/firmware}/updates" \
"${OMARCHY_SURFACE_LAPTOP8_FIRMWARE_ROOT:-/usr/lib/firmware}"; do
if [[ -f $directory/$firmware$suffix ]]; then
FILES+=("$directory/$firmware$suffix")
break 2
fi
done
done
done
unset firmware directory suffix
CONF

# Wi-Fi board data, audio, the device tree's hardware ID, sleep and touchpad.
omarchy-pkg-add surface-laptop-8-support

# USB4 docks: the router firmware is copied out of the Windows USB4 driver;
# thunderbolt_qcom declares it, so mkinitcpio adds it to the image. Without
# Windows on the disk it is not found and USB4 stays off.
surface-laptop8-usb4-firmware --no-rebuild || true
fi
3 changes: 3 additions & 0 deletions install/omarchy-other.packages
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ iptsd
surface-pro-11-sensors
surface-pro-11-support

# Surface Laptop 8 (Snapdragon) support packages
surface-laptop-8-support

# Dell laptop support packages
dell-xps-touchpad-haptics
dell-xps13-sidecar-amps
Expand Down
82 changes: 82 additions & 0 deletions test/shell.d/surface-laptop8-hardware-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/bin/bash

set -euo pipefail

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

setup="$ROOT/install/hardware/microsoft/surface-laptop8.sh"
scratch=$(mktemp -d)
trap 'rm -rf "$scratch"' EXIT

bash -n "$setup" || fail "Surface Laptop 8 hardware script has valid syntax"
grep -Fxq 'run_logged "$OMARCHY_INSTALL/hardware/microsoft/surface-laptop8.sh"' "$ROOT/install/hardware/all.sh" ||
fail "Surface Laptop 8 setup runs with the other hardware scripts"
# The installer is offline, so the ISO's mirror must carry what the setup adds.
grep -Fxq surface-laptop-8-support "$ROOT/install/omarchy-other.packages" ||
fail "the ISO can supply surface-laptop-8-support offline"
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved

require_platform_fixtures "the Surface Laptop 8 setup"

run_setup() (
set -eE
local dir=$1
PATH="$ROOT/bin:$PATH"
omarchy-hw-aarch64-qualcomm() { return 0; }
omarchy-pkg-add() { printf 'add %s\n' "$*" >>"$dir/packages.log"; }
surface-laptop8-usb4-firmware() { printf 'usb4 %s\n' "$*" >>"$dir/packages.log"; return 2; }

OMARCHY_PROC_ROOT="$dir/proc" \
OMARCHY_SURFACE_LAPTOP8_MKINITCPIO_DIR="$dir/mkinitcpio.conf.d" \
source "$setup"
)

compatible() {
mkdir -p "$1/proc/device-tree"
printf '%b' "$2" >"$1/proc/device-tree/compatible"
}

matching="$scratch/matching"
compatible "$matching" 'microsoft,surface-laptop8\0qcom,mahua\0'
run_setup "$matching" >/dev/null
[[ $(<"$matching/packages.log") == $'add surface-laptop-8-support\nusb4 --no-rebuild' ]] ||
fail "Surface Laptop 8 setup adds its hardware support, then copies the USB4 router firmware without stopping on failure"

(
firmware_root="$scratch/firmware"
board=qcom/glymur/microsoft/surface-laptop8
mkdir -p "$firmware_root/$board" "$firmware_root/updates/$board"
touch "$firmware_root/qcom/gen80100_sqe.fw.zst" "$firmware_root/qcom/gen80100_gmu.bin.xz" \
"$firmware_root/$board/qcadsp8480.mbn" "$firmware_root/updates/$board/qcadsp8480.mbn" \
"$firmware_root/updates/$board/adsp_dtbs.elf" "$firmware_root/updates/$board/qccdsp8480.mbn" \
"$firmware_root/$board/cdsp_dtbs.elf"
MODULES=() FILES=()
OMARCHY_SURFACE_LAPTOP8_FIRMWARE_ROOT="$firmware_root" \
source "$matching/mkinitcpio.conf.d/surface-laptop8-initramfs.conf"

for module in msm panel_edp gpucc_glymur qcom_q6v5_pas thunderbolt thunderbolt_qcom pmic_glink pmic_glink_altmode pwm_bl surface_hid nvme; do
[[ " ${MODULES[*]%\?} " == *" $module "* ]] ||
fail "the Surface Laptop 8 initramfs loads $module before disk unlock"
done
for module in "${MODULES[@]}"; do
[[ $module == *\? ]] || fail "$module is optional, so a kernel without it still builds its image"
done

expected=(
"$firmware_root/qcom/gen80100_sqe.fw.zst"
"$firmware_root/qcom/gen80100_gmu.bin.xz"
"$firmware_root/updates/$board/qcadsp8480.mbn"
"$firmware_root/updates/$board/adsp_dtbs.elf"
"$firmware_root/updates/$board/qccdsp8480.mbn"
"$firmware_root/$board/cdsp_dtbs.elf"
)
[[ ${FILES[*]} == "${expected[*]}" ]] ||
fail "early firmware prefers extracted copies, accepts compressed packaged firmware and skips what is missing"
)

other="$scratch/other"
compatible "$other" 'lenovo,yoga-slim7x\0qcom,x1e80100\0'
run_setup "$other" >/dev/null
[[ ! -e $other/packages.log && ! -e $other/mkinitcpio.conf.d ]] ||
fail "other Snapdragon laptops are left alone"

pass "Surface Laptop 8 setup configures only this laptop"
Loading