Skip to content
Merged
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
1 change: 1 addition & 0 deletions install/hardware/all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,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-laptop-7.sh"
run_logged "$OMARCHY_INSTALL/hardware/microsoft/surface-laptop8.sh"

run_logged "$OMARCHY_INSTALL/hardware/fix-bcm43xx.sh"
Expand Down
48 changes: 48 additions & 0 deletions install/hardware/microsoft/surface-laptop-7.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Microsoft Surface Laptop 7 15" (Snapdragon X Elite) board-specific setup.
# The 13.8" model runs another device tree and has not been tested.

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

if omarchy-hw-aarch64-qualcomm && omarchy-hw-match-device-tree microsoft,romulus15; then
echo "Detected Microsoft Surface Laptop 7 15\", applying board-specific support..."

# Bring up the panel and the keyboard before disk unlock. Without this the
# unlock prompt is black and takes no keys from the built-in keyboard. As in
# qualcomm/initramfs.sh, the ? skips a module a kernel does not have, so its
# image still builds.
# - The display driver waits for the USB-C DisplayPort chain, so that loads
# early too, with the IPC router and PD mapper pmic_glink needs.
# - The panel is a generic eDP one lit by a PWM backlight, whose PWM comes
# from the PMIC's LPG block.
# - The keyboard is a HID device behind the Surface Aggregator Module.
mkdir -p "$mkinitcpio_dir"
cat >"$mkinitcpio_dir/surface-laptop-7-initramfs.conf" <<'CONF'
MODULES+=(msm? dispcc_x1e80100? gpucc_x1e80100? phy_qcom_edp? panel_edp?
pwm_bl? leds_qcom_lpg? phy_qcom_qmp_combo? ps883x? qrtr? qcom_pd_mapper?
pmic_glink? pmic_glink_altmode? surface_aggregator?
surface_aggregator_registry? surface_hid_core? surface_hid?)

# The Adreno X1's microcode, requested once when the display driver loads
# early. The board-signed zap shader is included by qcom-firmware-extract.
# Search like the kernel does: each suffix in every directory, then the next.
for firmware in qcom/gen70500_sqe.fw qcom/gen70500_gmu.bin; do
for suffix in '' .zst .xz; do
for directory in "${OMARCHY_SURFACE_LAPTOP7_FIRMWARE_ROOT:-/usr/lib/firmware}/updates" \
"${OMARCHY_SURFACE_LAPTOP7_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

# microsoft-surface-snapdragon-addresses gives Wi-Fi and Bluetooth the
# laptop's own addresses: without it Wi-Fi takes a new placeholder address on
# every boot and Bluetooth has no controller. iptsd gives the touchpad
# two-finger scroll, pinch and two-finger tap, which the kernel alone, running
# the pad as a mouse, does not; pressing the pad stops registering as a click.
omarchy-pkg-add microsoft-surface-snapdragon-addresses iptsd
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
fi
3 changes: 3 additions & 0 deletions install/omarchy-other.packages
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ iptsd
microsoft-surface-pro-11-sensors
microsoft-surface-pro-11-support

# Surface Laptop 7 15" (Snapdragon) support packages; iptsd is listed above
microsoft-surface-snapdragon-addresses

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

Expand Down
33 changes: 33 additions & 0 deletions migrations/1794718518.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
echo "Set up the Surface Laptop 7 15\" on installs made before its board setup"

# See install/hardware/microsoft/surface-laptop-7.sh. It loads the panel and
# keyboard drivers early and installs microsoft-surface-snapdragon-addresses
# and iptsd, then the boot image is rebuilt to pick up the drivers. Rerunning
# the setup rewrites the same file and skips what is installed.
rebuild_marker=/var/lib/omarchy/migrations/1794718518

if ! omarchy-hw-aarch64-qualcomm || ! omarchy-hw-match-device-tree microsoft,romulus15; then
exit 0
fi

sudo env PATH="$PATH" OMARCHY_PATH="$OMARCHY_PATH" bash -euo pipefail -c '
source "$OMARCHY_PATH/install/hardware/microsoft/surface-laptop-7.sh"
'

# A marker records the machine-wide rebuild: another user's run must not repeat
# it, while a missing marker still retries an interrupted rebuild.
if [[ ! -e $rebuild_marker ]]; then
rebuild_log=$(mktemp)
trap 'rm -f "$rebuild_log"' EXIT
sudo limine-mkinitcpio 2>&1 | tee "$rebuild_log"

# limine-mkinitcpio reports a kernel it could not rebuild and still exits 0.
# That image lacks the early drivers, so the migration stays pending.
if grep -q 'mkinitcpio failed for kernel' "$rebuild_log"; then
echo "A boot image was not rebuilt. Fix the error above, then run omarchy-migrate again before rebooting." >&2
exit 1
fi

sudo install -Dm644 /dev/null "$rebuild_marker"
omarchy-state set reboot-required
fi
67 changes: 67 additions & 0 deletions test/shell.d/surface-laptop-7-hardware-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash

set -euo pipefail

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

setup="$ROOT/install/hardware/microsoft/surface-laptop-7.sh"
scratch=$(mktemp -d)
trap 'rm -rf "$scratch"' EXIT
Comment on lines +5 to +9

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Hardware tests split across suites

This adds a separate hardware test file even though hardware-quirks-test.sh already covers Surface hardware and board-specific boot setup. AGENTS.md requires extending the area's existing test file rather than adding another *-test.sh. Move the useful board checks into that suite before merging and reuse its shared setup.

File Used: AGENTS.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept it as its own file because the two sibling boards do the same: surface-laptop8-hardware-test.sh and surface-pro-11-hardware-test.sh each test one board script, with the same shape as this one, and hardware-quirks-test.sh covers the shared quirks. Happy to fold it into that suite if a maintainer prefers it there.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right—the sibling Surface Laptop 8 and Surface Pro 11 tests establish a clear precedent for keeping board-setup tests in their own files, while hardware-quirks-test.sh covers shared quirks. I applied the general AGENTS guidance too broadly; I’d withdraw the request to fold this test into that suite. If a maintainer prefers consolidation, that can be handled as a project-specific preference.

Should I remember this distinction for future reviews: dedicated board-setup tests may live alongside hardware-quirks-test.sh, which remains for shared quirks?

Tip: You can customize Greptile's behavior for this repo with .greptile/rules.md and .greptile/config.json.


bash -n "$setup" || fail "Surface Laptop 7 hardware script has valid syntax"

require_platform_fixtures "the Surface Laptop 7 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"; }

OMARCHY_PROC_ROOT="$dir/proc" \
OMARCHY_SURFACE_LAPTOP7_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,romulus15\0qcom,x1e80100\0'
run_setup "$matching" >/dev/null
[[ $(<"$matching/packages.log") == 'add microsoft-surface-snapdragon-addresses iptsd' ]] ||
fail "Surface Laptop 7 15\" setup adds its Wi-Fi and Bluetooth addresses and iptsd"

(
firmware_root="$scratch/firmware"
mkdir -p "$firmware_root/qcom" "$firmware_root/updates/qcom"
touch "$firmware_root/qcom/gen70500_sqe.fw.zst" "$firmware_root/updates/qcom/gen70500_sqe.fw"
MODULES=() FILES=()
OMARCHY_SURFACE_LAPTOP7_FIRMWARE_ROOT="$firmware_root" \
source "$matching/mkinitcpio.conf.d/surface-laptop-7-initramfs.conf"

for module in "${MODULES[@]}"; do
[[ $module == *\? ]] || fail "$module is optional, so a kernel without it still builds its image"
done

for module in pwm_bl leds_qcom_lpg surface_aggregator surface_aggregator_registry surface_hid; do
[[ " ${MODULES[*]} " == *" $module? "* ]] ||
fail "$module loads early, for the backlight and the keyboard at disk unlock"
done

[[ ${FILES[*]} == "$firmware_root/updates/qcom/gen70500_sqe.fw" ]] ||
fail "early firmware prefers extracted copies and skips what is missing"
)

for other in 'microsoft,romulus13\0qcom,x1e80100\0' 'lenovo,yoga-slim7x\0qcom,x1e80100\0'; do
dir="$scratch/other-${other%%\\0*}"
compatible "$dir" "$other"
run_setup "$dir" >/dev/null
[[ ! -e $dir/packages.log && ! -e $dir/mkinitcpio.conf.d ]] ||
fail "${other%%\\0*} is left alone"
done

pass "Surface Laptop 7 setup configures only the 15\" model"
Loading