Repository navigation
Add Surface Laptop 7 15" board setup #18967
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
| fi | ||
| 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 |
| 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This adds a separate hardware test file even though File Used: 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!
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 Should I remember this distinction for future reviews: dedicated board-setup tests may live alongside Tip: You can customize Greptile's behavior for this repo with |
||
|
|
||
| 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" | ||
Uh oh!
There was an error while loading. Please reload this page.