diff --git a/pkgbuilds/alsa-ucm-conf-aurora/.omarchy/package.json b/pkgbuilds/alsa-ucm-conf-aurora/.omarchy/package.json new file mode 100644 index 0000000000..60d6ab2ad9 --- /dev/null +++ b/pkgbuilds/alsa-ucm-conf-aurora/.omarchy/package.json @@ -0,0 +1,7 @@ +{ + "source": "local", + "channels": [ + "edge" + ], + "sync": false +} diff --git a/pkgbuilds/alsa-ucm-conf-aurora/PKGBUILD b/pkgbuilds/alsa-ucm-conf-aurora/PKGBUILD new file mode 100644 index 0000000000..43e6a76a0d --- /dev/null +++ b/pkgbuilds/alsa-ucm-conf-aurora/PKGBUILD @@ -0,0 +1,21 @@ +pkgname=alsa-ucm-conf-aurora +pkgver=10.aurora2 +pkgrel=1 +pkgdesc='Aurora Apple Silicon ALSA profiles including J700' +arch=('any') +groups=('omarchy-platform-apple-silicon') +url='https://github.com/aurora-silicon/alsa-ucm-conf-asahi' +license=('BSD-3-Clause') +_commit=e55107ad9ba220a2772dbe4d55438cd1ec669288 +makedepends=('git') +depends=('alsa-ucm-conf') +provides=("alsa-ucm-conf-asahi=$pkgver" "alsa-ucm-conf-asahi-aurora=$pkgver") +conflicts=('alsa-ucm-conf-asahi' 'alsa-ucm-conf-asahi-aurora') +replaces=('alsa-ucm-conf-asahi-aurora') +source=("ucm::git+$url.git#commit=$_commit") +sha256sums=('SKIP') +package() { + install -d "$pkgdir/usr/share/alsa" + cp -a ucm/ucm2 "$pkgdir/usr/share/alsa/" + install -Dm644 ucm/LICENSE.asahi "$pkgdir/usr/share/licenses/$pkgname/LICENSE" +} diff --git a/pkgbuilds/aura/.omarchy/package.json b/pkgbuilds/aura/.omarchy/package.json new file mode 100644 index 0000000000..60d6ab2ad9 --- /dev/null +++ b/pkgbuilds/aura/.omarchy/package.json @@ -0,0 +1,7 @@ +{ + "source": "local", + "channels": [ + "edge" + ], + "sync": false +} diff --git a/pkgbuilds/aura/PKGBUILD b/pkgbuilds/aura/PKGBUILD new file mode 100644 index 0000000000..6edd34e768 --- /dev/null +++ b/pkgbuilds/aura/PKGBUILD @@ -0,0 +1,43 @@ +# Aurora bootloader; ordinary updates refresh ESP Stage 2, never enroll Stage 1. +pkgname=aura +pkgver=0.1.0.r20261014 +pkgrel=1 +pkgdesc='Aurora Silicon bootloader for Apple Silicon' +arch=('aarch64') +groups=('omarchy-platform-apple-silicon') +url='https://github.com/aurora-silicon/aura' +license=('MIT' 'GPL-2.0-only') +_commit=c4331a90ef324eab33d34d1515d7e42748a293ab +_compat=1.6.1.aurora19 +provides=("m1n1=$_compat" "m1n1-aurora=$_compat" "m1n1-neo=$_compat") +conflicts=('m1n1' 'm1n1-aurora' 'm1n1-neo') +replaces=('m1n1-neo') +depends=('asahi-scripts>=20260127.1' 'uboot-aurora') +makedepends=('git' 'clang' 'lld' 'llvm' 'rustup' 'make' 'python') +options=('!strip' '!debug') +source=("aura::git+$url.git#commit=$_commit") +sha256sums=('SKIP') +prepare() { + rustup toolchain install 1.85.0 --profile minimal --target aarch64-unknown-none-softfloat + [[ $(git -C aura rev-parse HEAD) == "$_commit" ]] +} +build() { + cd aura + export RUSTUP_TOOLCHAIN=1.85.0 + make clean + make -j"${OMARCHY_BUILD_JOBS:-10}" RELEASE=1 CHAINLOADING=1 USE_CLANG=1 BUILTIN_LOGO=aurora + install -Dm644 build/aura.bin "$srcdir/stage1/aura-raw.bin" + install -Dm644 build/aura.macho "$srcdir/stage1/aura.macho" + make clean + make -j"${OMARCHY_BUILD_JOBS:-10}" RELEASE=1 CHAINLOADING=1 ESP_STAGE2=1 USE_CLANG=1 BUILTIN_LOGO=aurora +} +package() { + install -Dm644 aura/build/aura.bin "$pkgdir/usr/lib/asahi-boot/m1n1.bin" + install -d "$pkgdir/usr/lib/m1n1-neo" + ln -s ../asahi-boot/m1n1.bin "$pkgdir/usr/lib/m1n1-neo/m1n1.bin" + install -Dm644 stage1/aura-raw.bin "$pkgdir/usr/share/aura/stage1/aura-raw.bin" + install -Dm644 stage1/aura.macho "$pkgdir/usr/share/aura/stage1/aura.macho" + install -Dm644 aura/LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE" + install -m644 aura/3rdparty_licenses/* "$pkgdir/usr/share/licenses/$pkgname/" + install -Dm644 "$startdir/build-qualification.json" "$pkgdir/usr/share/doc/aura/build-qualification.json" +} diff --git a/pkgbuilds/aura/build-qualification.json b/pkgbuilds/aura/build-qualification.json new file mode 100644 index 0000000000..59d4803fe7 --- /dev/null +++ b/pkgbuilds/aura/build-qualification.json @@ -0,0 +1,6 @@ +{ + "source_commit": "c4331a90ef324eab33d34d1515d7e42748a293ab", + "hardware_tested": false, + "stage1_auto_enrollment": false, + "publication_gate": "native build, matched Stage1/Stage2 Neo boot, repair and upgrade qualification" +} diff --git a/pkgbuilds/aurora-audio/.omarchy/package.json b/pkgbuilds/aurora-audio/.omarchy/package.json new file mode 100644 index 0000000000..60d6ab2ad9 --- /dev/null +++ b/pkgbuilds/aurora-audio/.omarchy/package.json @@ -0,0 +1,7 @@ +{ + "source": "local", + "channels": [ + "edge" + ], + "sync": false +} diff --git a/pkgbuilds/aurora-audio/PKGBUILD b/pkgbuilds/aurora-audio/PKGBUILD new file mode 100644 index 0000000000..e902858653 --- /dev/null +++ b/pkgbuilds/aurora-audio/PKGBUILD @@ -0,0 +1,21 @@ +pkgname=aurora-audio +pkgver=4.1.aurora2 +pkgrel=1 +pkgdesc='Aurora Apple Silicon PipeWire/WirePlumber DSP profiles including J700' +arch=('any') +groups=('omarchy-platform-apple-silicon') +url='https://github.com/aurora-silicon/asahi-audio' +license=('MIT') +_commit=b2da7512e9bfcd5837355d2393f3c43219acf6b9 +makedepends=('git' 'make') +depends=('alsa-ucm-conf-aurora' 'pipewire-audio' 'wireplumber' 'bankstown' + 'lsp-plugins-lv2' 'speakersafetyd' 'speakerguardd') +provides=("asahi-audio=$pkgver" "asahi-audio-aurora=$pkgver") +conflicts=('asahi-audio' 'asahi-audio-aurora') +replaces=('asahi-audio-aurora') +source=("asahi-audio::git+$url.git#commit=$_commit") +sha256sums=('SKIP') +package() { + make -C asahi-audio install DESTDIR="$pkgdir" PREFIX=/usr + install -Dm644 asahi-audio/LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE" +} diff --git a/pkgbuilds/aurora-bless/.omarchy/package.json b/pkgbuilds/aurora-bless/.omarchy/package.json new file mode 100644 index 0000000000..60d6ab2ad9 --- /dev/null +++ b/pkgbuilds/aurora-bless/.omarchy/package.json @@ -0,0 +1,7 @@ +{ + "source": "local", + "channels": [ + "edge" + ], + "sync": false +} diff --git a/pkgbuilds/aurora-bless/PKGBUILD b/pkgbuilds/aurora-bless/PKGBUILD new file mode 100644 index 0000000000..eedd9fdfb4 --- /dev/null +++ b/pkgbuilds/aurora-bless/PKGBUILD @@ -0,0 +1,29 @@ +pkgname=aurora-bless +pkgver=0.4.4.aurora2 +pkgrel=1 +pkgdesc='Aurora Apple Silicon startup-volume selector with Neo NVRAM support' +arch=('aarch64') +groups=('omarchy-platform-apple-silicon') +url='https://github.com/aurora-silicon/aurora-bless' +license=('MIT') +_commit=727b5895db67bd40aa66c41485c6a8f482d2a917 +provides=("asahi-bless=$pkgver") +conflicts=('asahi-bless') +makedepends=('git' 'rust' 'cargo') +source=("aurora-bless::git+$url.git#commit=$_commit") +sha256sums=('SKIP') +build() { + cd aurora-bless + cargo build --locked --release -p asahi-bless ${CARGO_TARGET:+--target "$CARGO_TARGET"} +} +check() { + cd aurora-bless + cargo test --locked -p asahi-bless -p apple-nvram -p asahi-nvram +} +package() { + local bin=aurora-bless/target/release/asahi-bless + if [[ -n ${CARGO_TARGET:-} ]]; then bin=aurora-bless/target/$CARGO_TARGET/release/asahi-bless; fi + install -Dm755 "$bin" "$pkgdir/usr/bin/aurora-bless" + ln -s aurora-bless "$pkgdir/usr/bin/asahi-bless" + install -Dm644 aurora-bless/LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE" +} diff --git a/pkgbuilds/libfprint-git/PKGBUILD b/pkgbuilds/libfprint-git/PKGBUILD index 19c137583b..11577b1784 100644 --- a/pkgbuilds/libfprint-git/PKGBUILD +++ b/pkgbuilds/libfprint-git/PKGBUILD @@ -13,10 +13,17 @@ # The driver accepts only /dev/sep-bio interface version 4 # (AURORA_BIO_IFACE_VERSION): a kernel that bumps it turns Touch ID off until # this patch follows, so move the two together. +# +# The Touch ID sensor is in the power button, which a closed lid covers. +# aurora-lid-covered-readers.patch makes libfprint drop such a reader while the +# lid is closed and bring it back when it opens, so in clamshell mode sudo, +# polkit and the lock screen go straight to the password instead of waiting +# for a finger. It follows the lid switch, which fprintd's sandbox must be +# allowed to read (fprintd-lid-switch.conf). pkgname=libfprint-git pkgver=1.94.100.r10.g6f9479c -pkgrel=3 +pkgrel=5 # Retain the epoch used to supersede the previously published untested build. epoch=1 pkgdesc="Library for fingerprint readers (pinned upstream snapshot with FocalTech and Synaptics 06cb:010b support, and Apple Touch ID on aarch64)" @@ -54,12 +61,20 @@ source=( "git+https://gitlab.freedesktop.org/libfprint/libfprint.git#commit=6f9479c3d55f847c1b3769f28ceb99227f9858cf" "focaltech_moc-add-pid-0xA97A.patch" ) -source_aarch64=("aurora-apple-sep.patch") +source_aarch64=( + "aurora-apple-sep.patch" + "aurora-lid-covered-readers.patch" + "fprintd-lid-switch.conf" +) b2sums=( 'SKIP' 'SKIP' ) -b2sums_aarch64=('ec577996066baf6db6d741763abd681aae5556d52a8b67f7a52a60a4df7015c5d1edf3637835e563b2fb0edde2499173d61c50717b621f6bddf94a1f700075e5') +b2sums_aarch64=( + 'ec577996066baf6db6d741763abd681aae5556d52a8b67f7a52a60a4df7015c5d1edf3637835e563b2fb0edde2499173d61c50717b621f6bddf94a1f700075e5' + 'bdd60159c572c00eeb62b86b01305858d44cef867e3bd156839da9cd85bb2950623e3759ff3534f795ea6c9ae18ab02af13e864c98f24203f507c2a50d0a2300' + '73a87f8f53136e8c49b16568aa77acf9bd2a5913c57e4793320d109ba2a11ce7b3d21b7fac8a8b1ff7ce94b738eddca120c026c8d79e320cf3ff5eede83ba30b' +) pkgver() { cd libfprint @@ -79,9 +94,13 @@ prepare() { # Skipped only when every hunk is already in: a tree a failed run left # half-patched fails here instead of building. - if [[ $CARCH == "aarch64" ]] && - ! patch -p1 -R --dry-run --silent --force < "$srcdir/aurora-apple-sep.patch" >/dev/null 2>&1; then - patch -p1 --forward < "$srcdir/aurora-apple-sep.patch" + if [[ $CARCH == "aarch64" ]]; then + local p + for p in aurora-apple-sep.patch aurora-lid-covered-readers.patch; do + if ! patch -p1 -R --dry-run --silent --force < "$srcdir/$p" >/dev/null 2>&1; then + patch -p1 --forward < "$srcdir/$p" + fi + done fi } @@ -100,6 +119,11 @@ check() { package() { meson install -C build --destdir "$pkgdir" + + if [[ $CARCH == "aarch64" ]]; then + install -Dm644 "$srcdir/fprintd-lid-switch.conf" \ + "$pkgdir/usr/lib/systemd/system/fprintd.service.d/50-libfprint-lid-switch.conf" + fi } # vim:set sw=2 sts=-1 et: diff --git a/pkgbuilds/libfprint-git/aurora-lid-covered-readers.patch b/pkgbuilds/libfprint-git/aurora-lid-covered-readers.patch new file mode 100644 index 0000000000..4c9a3fb864 --- /dev/null +++ b/pkgbuilds/libfprint-git/aurora-lid-covered-readers.patch @@ -0,0 +1,1357 @@ +From fce9096466851808f66e9eca35ab1083caaac10f Mon Sep 17 00:00:00 2001 +From: Ryan Murray +Date: Thu, 15 Oct 2026 13:24:45 +1100 +Subject: [PATCH] Hide lid-covered readers while the lid is closed + +A reader built into a laptop's base -- in the palm rest, the keyboard or +the power button -- cannot be touched while the lid is closed. libfprint +still reported it, so in clamshell mode every sudo, polkit request and +lock screen offered the fingerprint and then waited for a finger that +could not come. + +Let a driver say its sensor is covered by the lid +(FpDeviceClass:covered_by_lid). FpContext then follows the lid switches +(SW_LID input devices, read with EVIOCGSW) and removes such a device +while a lid is closed: fpi_device_remove() fails a running operation as +FP_DEVICE_ERROR_REMOVED, and the context drops the device once its user +has closed it. The udev match is kept, so the device is probed again, +and announced through device-added, as soon as the lid opens. A device +matched while the lid is closed is only probed once it opens. Without a +lid switch nothing changes. + +fprintd already follows device-added and device-removed. pam_fprintd +finds no device and returns PAM_AUTHINFO_UNAVAIL at once, so sudo and +polkit go straight to the password without a fingerprint prompt or a +delay; lock screens that ask fprintd for a reader see none. + +The aurora driver sets the flag. When it is removed it cancels the +enclave operation in flight and refuses to arm the sensor again, so a +verify waiting when the lid closes ends promptly as verify-disconnected +and pam_fprintd moves on to the password. + +Also release the misc devices left over after udev matching. + +A reader can be removed while the system sleeps: the lid closes during +sleep, and the machine wakes from an external keyboard with the lid +still closed. fp_device_resume() then answered FP_DEVICE_ERROR_REMOVED +but left the device suspended, so the close its user still had to do +failed as busy. The context never dropped the device, fprintd kept +listing a reader that fails everything, and no new one appeared when +the lid opened. Resuming a removed device now ends its suspension. + +FpiLidSwitch dispatches in the thread-default main context it was made +in, like the rest of libfprint. + +test-lid-switch follows real uinput lid switches (skipped without +/dev/uinput and a running udev): one that appears late, bounces and goes +away while closed, two at once, no leaked fds, and a thread-default +context. test-fpi-device covers a device removed while suspended. + +Assisted-by: LLM +Signed-off-by: Ryan Murray +--- + libfprint/drivers/aurora/aurora.c | 56 +++++ + libfprint/fp-context.c | 273 ++++++++++++++++++++++-- + libfprint/fp-device.c | 4 + + libfprint/fpi-device.h | 8 + + libfprint/fpi-lid-switch.c | 336 ++++++++++++++++++++++++++++++ + libfprint/fpi-lid-switch.h | 29 +++ + libfprint/meson.build | 8 +- + tests/meson.build | 7 + + tests/test-fpi-device.c | 38 ++++ + tests/test-lid-switch.c | 306 +++++++++++++++++++++++++++ + 10 files changed, 1047 insertions(+), 18 deletions(-) + create mode 100644 libfprint/fpi-lid-switch.c + create mode 100644 libfprint/fpi-lid-switch.h + create mode 100644 tests/test-lid-switch.c + +diff --git a/libfprint/drivers/aurora/aurora.c b/libfprint/drivers/aurora/aurora.c +index ea09de74..80938d12 100644 +--- a/libfprint/drivers/aurora/aurora.c ++++ b/libfprint/drivers/aurora/aurora.c +@@ -119,6 +119,16 @@ aurora_label_from_print (FpPrint *print, guint8 *label_out, GError **error) + return TRUE; + } + ++/* Set once a closed lid has covered the sensor: see aurora_removed_cb(). */ ++static gboolean ++aurora_is_removed (FpDevice *device) ++{ ++ gboolean removed = FALSE; ++ ++ g_object_get (device, "removed", &removed, NULL); ++ return removed; ++} ++ + static void + aurora_stop_watch (FpiDeviceAurora *self) + { +@@ -293,6 +303,12 @@ aurora_open (FpDevice *device) + FpiDeviceAurora *self = FPI_DEVICE_AURORA (device); + const gchar *path; + ++ if (aurora_is_removed (device)) ++ { ++ fpi_device_open_complete (device, fpi_device_error_new (FP_DEVICE_ERROR_REMOVED)); ++ return; ++ } ++ + path = fpi_device_get_udev_data (device, FPI_DEVICE_UDEV_SUBTYPE_MISC); + if (path == NULL) + { +@@ -352,6 +368,27 @@ aurora_cancel (FpDevice *device) + ioctl (self->fd, AURORA_BIO_CANCEL); + } + ++/* The sensor is in the power button, so a closed lid covers it, and the ++ * context removes this device then (covered_by_lid below). An operation still ++ * waiting for a finger can never finish: cancel it in the enclave, and libfprint ++ * completes it as FP_DEVICE_ERROR_REMOVED, which fprintd reports as ++ * verify-disconnected and pam_fprintd answers by moving on to the password. ++ * The device stays open until its user releases it; refuse anything that would ++ * arm the sensor again in the meantime. */ ++static void ++aurora_removed_cb (FpDevice *device, GParamSpec *pspec, gpointer user_data) ++{ ++ FpiDeviceAurora *self = FPI_DEVICE_AURORA (device); ++ ++ if (!aurora_is_removed (device)) ++ return; ++ ++ fp_dbg ("device removed%s", self->watch_id != 0 ? "; cancelling the running operation" : ""); ++ ++ if (self->watch_id != 0) ++ aurora_cancel (device); ++} ++ + static void + aurora_report_guidance (FpDevice *device, guint32 guidance, gboolean active) + { +@@ -447,6 +484,12 @@ aurora_enroll (FpDevice *device) + g_autoptr(GError) error = NULL; + FpPrint *print = NULL; + ++ if (aurora_is_removed (device)) ++ { ++ fpi_device_enroll_complete (device, NULL, fpi_device_error_new (FP_DEVICE_ERROR_REMOVED)); ++ return; ++ } ++ + fpi_device_get_enroll_data (device, &print); + + if (!aurora_label_from_print (print, start.label, &error)) +@@ -691,6 +734,16 @@ aurora_match_start (FpDevice *device) + } + } + ++ if (aurora_is_removed (device)) ++ { ++ error = fpi_device_error_new (FP_DEVICE_ERROR_REMOVED); ++ if (action == FPI_DEVICE_ACTION_VERIFY) ++ fpi_device_verify_complete (device, g_steal_pointer (&error)); ++ else ++ fpi_device_identify_complete (device, g_steal_pointer (&error)); ++ return; ++ } ++ + /* A fresh nonce per operation is what makes the result non-replayable. If we + * cannot get one we must not fall back to anything weaker. */ + if (getrandom (self->nonce, sizeof (self->nonce), 0) != (gssize) sizeof (self->nonce)) +@@ -820,6 +873,8 @@ fpi_device_aurora_init (FpiDeviceAurora *self) + self->fd = -1; + self->watch_id = 0; + self->nonce_valid = FALSE; ++ ++ g_signal_connect (self, "notify::removed", G_CALLBACK (aurora_removed_cb), NULL); + } + + static void +@@ -855,6 +910,7 @@ fpi_device_aurora_class_init (FpiDeviceAuroraClass *klass) + dev_class->scan_type = FP_SCAN_TYPE_PRESS; + dev_class->nr_enroll_stages = 8; + dev_class->temp_hot_seconds = -1; ++ dev_class->covered_by_lid = TRUE; + + dev_class->probe = aurora_probe; + dev_class->open = aurora_open; +diff --git a/libfprint/fp-context.c b/libfprint/fp-context.c +index 6fdf53b4..2c072053 100644 +--- a/libfprint/fp-context.c ++++ b/libfprint/fp-context.c +@@ -29,6 +29,7 @@ + + #ifdef HAVE_UDEV + #include ++#include "fpi-lid-switch.h" + #endif + + /** +@@ -55,6 +56,11 @@ typedef struct + + GArray *drivers; + GPtrArray *devices; ++ ++#ifdef HAVE_UDEV ++ FpiLidSwitch *lid; ++ GPtrArray *lid_covered; ++#endif + } FpContextPrivate; + + G_DEFINE_TYPE_WITH_PRIVATE (FpContext, fp_context, G_TYPE_OBJECT) +@@ -96,17 +102,67 @@ typedef struct + GSource *source; + } RemoveDeviceData; + ++#ifdef HAVE_UDEV ++/* A udev device whose sensor a closed lid covers (FpDeviceClass:covered_by_lid). ++ * ++ * Nobody can touch such a sensor while the lid is closed, so the device is ++ * removed then, and anyone asking for a reader sees none instead of one that ++ * waits for a finger that cannot come. This record outlives the FpDevice ++ * instances made from it, so the device can be probed again once the lid ++ * opens. */ ++typedef struct ++{ ++ FpContext *context; /* NULL once the context is gone */ ++ GType driver; ++ guint64 driver_data; ++ gchar *spidev_path; ++ gchar *hidraw_path; ++ gchar *misc_path; ++ FpDevice *device; /* current instance, until the context drops it */ ++ gboolean probing; ++} LidCoveredDevice; ++ ++static void lid_covered_probe (FpContext *context, ++ LidCoveredDevice *covered); ++#endif ++ + static gboolean + remove_device_idle_cb (RemoveDeviceData *data) + { + FpContextPrivate *priv = fp_context_get_instance_private (data->context); + guint idx = 0; + ++#ifdef HAVE_UDEV ++ LidCoveredDevice *covered = NULL; ++ guint i; ++#endif ++ + g_return_val_if_fail (g_ptr_array_find (priv->devices, data->device, &idx), G_SOURCE_REMOVE); + ++#ifdef HAVE_UDEV ++ for (i = 0; priv->lid_covered && i < priv->lid_covered->len; i++) ++ { ++ LidCoveredDevice *c = g_ptr_array_index (priv->lid_covered, i); ++ ++ if (c->device == data->device) ++ { ++ c->device = NULL; ++ covered = c; ++ break; ++ } ++ } ++#endif ++ + g_signal_emit (data->context, signals[DEVICE_REMOVED_SIGNAL], 0, data->device); + g_ptr_array_remove_index_fast (priv->devices, idx); + ++#ifdef HAVE_UDEV ++ /* The lid may have opened again while the old instance was still open. It ++ * is gone now, so the node is free for a new one. */ ++ if (covered && !fpi_lid_switch_get_closed (priv->lid)) ++ lid_covered_probe (data->context, covered); ++#endif ++ + return G_SOURCE_REMOVE; + } + +@@ -166,6 +222,21 @@ device_removed_cb (FpContext *context, FpDevice *device) + } + } + ++static void ++add_device (FpContext *context, FpDevice *device) ++{ ++ FpContextPrivate *priv = fp_context_get_instance_private (context); ++ ++ g_ptr_array_add (priv->devices, device); ++ ++ g_signal_connect_object (device, "removed", ++ (GCallback) device_removed_cb, ++ context, ++ G_CONNECT_SWAPPED); ++ ++ g_signal_emit (context, signals[DEVICE_ADDED_SIGNAL], 0, device); ++} ++ + static void + async_device_init_done_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) + { +@@ -189,16 +260,159 @@ async_device_init_done_cb (GObject *source_object, GAsyncResult *res, gpointer u + return; + } + +- g_ptr_array_add (priv->devices, device); ++ add_device (context, device); ++} + +- g_signal_connect_object (device, "removed", +- (GCallback) device_removed_cb, +- context, +- G_CONNECT_SWAPPED); ++#ifdef HAVE_UDEV ++static void ++lid_covered_device_free (LidCoveredDevice *covered) ++{ ++ g_free (covered->spidev_path); ++ g_free (covered->hidraw_path); ++ g_free (covered->misc_path); ++} + +- g_signal_emit (context, signals[DEVICE_ADDED_SIGNAL], 0, device); ++static void ++lid_covered_device_release (LidCoveredDevice *covered) ++{ ++ g_rc_box_release_full (covered, (GDestroyNotify) lid_covered_device_free); + } + ++static void ++lid_covered_init_done_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) ++{ ++ LidCoveredDevice *covered = user_data; ++ g_autoptr(GError) error = NULL; ++ g_autoptr(FpDevice) device = NULL; ++ FpContextPrivate *priv; ++ ++ device = FP_DEVICE (g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), ++ res, &error)); ++ ++ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) || !covered->context) ++ { ++ lid_covered_device_release (covered); ++ return; ++ } ++ ++ priv = fp_context_get_instance_private (covered->context); ++ priv->pending_devices--; ++ covered->probing = FALSE; ++ ++ if (error) ++ { ++ g_message ("Ignoring device due to initialization error: %s", error->message); ++ } ++ else if (fpi_lid_switch_get_closed (priv->lid)) ++ { ++ /* The lid closed while the device was being probed. */ ++ fp_dbg ("Lid closed during probe; %s stays hidden", ++ fp_device_get_driver (device)); ++ } ++ else ++ { ++ covered->device = device; ++ add_device (covered->context, g_steal_pointer (&device)); ++ } ++ ++ lid_covered_device_release (covered); ++} ++ ++static void ++lid_covered_probe (FpContext *context, LidCoveredDevice *covered) ++{ ++ FpContextPrivate *priv = fp_context_get_instance_private (context); ++ ++ if (covered->device || covered->probing) ++ return; ++ ++ covered->probing = TRUE; ++ priv->pending_devices++; ++ g_async_initable_new_async (covered->driver, ++ G_PRIORITY_LOW, ++ priv->cancellable, ++ lid_covered_init_done_cb, ++ g_rc_box_acquire (covered), ++ "fpi-driver-data", covered->driver_data, ++ "fpi-udev-data-spidev", covered->spidev_path, ++ "fpi-udev-data-hidraw", covered->hidraw_path, ++ "fpi-udev-data-misc", covered->misc_path, ++ NULL); ++} ++ ++static void ++lid_closed_changed_cb (FpContext *context) ++{ ++ FpContextPrivate *priv = fp_context_get_instance_private (context); ++ gboolean closed = fpi_lid_switch_get_closed (priv->lid); ++ guint i; ++ ++ for (i = 0; i < priv->lid_covered->len; i++) ++ { ++ LidCoveredDevice *covered = g_ptr_array_index (priv->lid_covered, i); ++ ++ if (!closed) ++ { ++ /* Probed now if the old instance is gone, else once it is. */ ++ lid_covered_probe (context, covered); ++ } ++ else if (covered->device) ++ { ++ gboolean removed; ++ ++ g_object_get (covered->device, "removed", &removed, NULL); ++ if (!removed) ++ { ++ fp_dbg ("Lid closed; removing %s", fp_device_get_driver (covered->device)); ++ /* The context drops the device once its user has closed it. */ ++ fpi_device_remove (covered->device); ++ } ++ } ++ } ++} ++ ++static void ++add_lid_covered_device (FpContext *context, ++ GType driver, ++ guint64 driver_data, ++ const gchar *spidev_path, ++ const gchar *hidraw_path, ++ const gchar *misc_path) ++{ ++ FpContextPrivate *priv = fp_context_get_instance_private (context); ++ LidCoveredDevice *covered; ++ ++ if (!priv->lid) ++ { ++ priv->lid = fpi_lid_switch_new (); ++ priv->lid_covered = g_ptr_array_new_with_free_func ((GDestroyNotify) lid_covered_device_release); ++ g_signal_connect_object (priv->lid, "notify::closed", ++ G_CALLBACK (lid_closed_changed_cb), ++ context, ++ G_CONNECT_SWAPPED); ++ } ++ ++ covered = g_rc_box_new0 (LidCoveredDevice); ++ covered->context = context; ++ covered->driver = driver; ++ covered->driver_data = driver_data; ++ covered->spidev_path = g_strdup (spidev_path); ++ covered->hidraw_path = g_strdup (hidraw_path); ++ covered->misc_path = g_strdup (misc_path); ++ g_ptr_array_add (priv->lid_covered, covered); ++ ++ if (fpi_lid_switch_get_closed (priv->lid)) ++ { ++ g_autoptr(FpDeviceClass) cls = g_type_class_ref (driver); ++ ++ fp_info ("The lid covers the %s sensor; it appears once the lid opens", cls->id); ++ return; ++ } ++ ++ lid_covered_probe (context, covered); ++} ++#endif ++ + static void + usb_device_added_cb (FpContext *self, GUsbDevice *device, GUsbContext *usb_ctx) + { +@@ -287,6 +501,20 @@ fp_context_finalize (GObject *object) + + g_cancellable_cancel (priv->cancellable); + g_clear_object (&priv->cancellable); ++ ++#ifdef HAVE_UDEV ++ if (priv->lid_covered) ++ { ++ guint i; ++ ++ /* Probes still in flight hold their own reference. */ ++ for (i = 0; i < priv->lid_covered->len; i++) ++ ((LidCoveredDevice *) g_ptr_array_index (priv->lid_covered, i))->context = NULL; ++ } ++ g_clear_pointer (&priv->lid_covered, g_ptr_array_unref); ++ g_clear_object (&priv->lid); ++#endif ++ + g_clear_pointer (&priv->drivers, g_array_unref); + g_clear_pointer (&priv->devices, g_ptr_array_unref); + +@@ -545,17 +773,27 @@ fp_context_enumerate (FpContext *context) + if (matched_misc == NULL) + continue; + } +- priv->pending_devices++; +- g_async_initable_new_async (driver, +- G_PRIORITY_LOW, +- priv->cancellable, +- async_device_init_done_cb, +- context, +- "fpi-driver-data", entry->driver_data, +- "fpi-udev-data-spidev", (matched_spidev ? g_udev_device_get_device_file (matched_spidev->data) : NULL), +- "fpi-udev-data-hidraw", (matched_hidraw ? g_udev_device_get_device_file (matched_hidraw->data) : NULL), +- "fpi-udev-data-misc", (matched_misc ? g_udev_device_get_device_file (matched_misc->data) : NULL), +- NULL); ++ if (cls->covered_by_lid) ++ { ++ add_lid_covered_device (context, driver, entry->driver_data, ++ (matched_spidev ? g_udev_device_get_device_file (matched_spidev->data) : NULL), ++ (matched_hidraw ? g_udev_device_get_device_file (matched_hidraw->data) : NULL), ++ (matched_misc ? g_udev_device_get_device_file (matched_misc->data) : NULL)); ++ } ++ else ++ { ++ priv->pending_devices++; ++ g_async_initable_new_async (driver, ++ G_PRIORITY_LOW, ++ priv->cancellable, ++ async_device_init_done_cb, ++ context, ++ "fpi-driver-data", entry->driver_data, ++ "fpi-udev-data-spidev", (matched_spidev ? g_udev_device_get_device_file (matched_spidev->data) : NULL), ++ "fpi-udev-data-hidraw", (matched_hidraw ? g_udev_device_get_device_file (matched_hidraw->data) : NULL), ++ "fpi-udev-data-misc", (matched_misc ? g_udev_device_get_device_file (matched_misc->data) : NULL), ++ NULL); ++ } + /* remove entries from list to avoid conflicts */ + if (matched_spidev) + { +@@ -578,6 +816,7 @@ fp_context_enumerate (FpContext *context) + /* free all unused elemnts in both lists */ + g_list_foreach (spidev_devices, (GFunc) g_object_unref, NULL); + g_list_foreach (hidraw_devices, (GFunc) g_object_unref, NULL); ++ g_list_foreach (misc_devices, (GFunc) g_object_unref, NULL); + } + #endif + +diff --git a/libfprint/fp-device.c b/libfprint/fp-device.c +index 70b10f1f..f488f71b 100644 +--- a/libfprint/fp-device.c ++++ b/libfprint/fp-device.c +@@ -1092,6 +1092,10 @@ fp_device_resume (FpDevice *device, + + if (priv->is_removed) + { ++ /* There is nothing left to resume, but the device must not stay ++ * suspended: its user still has to close it, and a suspended device ++ * refuses that as busy, so it would never be released. */ ++ priv->is_suspended = FALSE; + g_task_return_error (task, + fpi_device_error_new (FP_DEVICE_ERROR_REMOVED)); + return; +diff --git a/libfprint/fpi-device.h b/libfprint/fpi-device.h +index 7671ad6a..db872952 100644 +--- a/libfprint/fpi-device.h ++++ b/libfprint/fpi-device.h +@@ -96,6 +96,11 @@ struct _FpIdEntry + * after being mostly cold. Set to -1 if the device can be always-on. + * @temp_cold_seconds: Assumed time in seconds for the device to be mostly cold + * after having been too hot to operate. ++ * @covered_by_lid: The sensor is built into a laptop's base (e.g. its keyboard ++ * or power button), so nobody can touch it while the lid is closed. #FpContext ++ * then removes the device, and probes it again once the lid opens. Only ++ * udev devices support this. A driver that sets it must fail a running ++ * operation promptly when the device is removed. + * @usb_discover: Class method to check whether a USB device is supported by + * the driver. Should return 0 if the device is unsupported and a positive + * score otherwise. The default score is 50 and the driver with the highest +@@ -168,6 +173,9 @@ struct _FpDeviceClass + gint32 temp_hot_seconds; + gint32 temp_cold_seconds; + ++ /* The sensor sits in a laptop's base, where a closed lid covers it */ ++ gboolean covered_by_lid; ++ + /* Callbacks */ + gint (*usb_discover) (GUsbDevice *usb_device); + void (*probe) (FpDevice *device); +diff --git a/libfprint/fpi-lid-switch.c b/libfprint/fpi-lid-switch.c +new file mode 100644 +index 00000000..cad71632 +--- /dev/null ++++ b/libfprint/fpi-lid-switch.c +@@ -0,0 +1,336 @@ ++/* ++ * Laptop lid switch tracking ++ * Copyright (C) 2026 Ryan Murray ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ++ */ ++ ++#define FP_COMPONENT "lid" ++#include ++ ++#include "fpi-lid-switch.h" ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++/* ++ * FpiLidSwitch follows every input device that reports SW_LID and says ++ * whether the lid is closed. The kernel's switch state (EVIOCGSW) is the ++ * truth: events only tell us when to read it again, so a dropped event or a ++ * SYN_DROPPED cannot leave a stale state behind. Without a lid switch the ++ * lid counts as open, which keeps desktops and external readers unaffected. ++ * ++ * Lid switches can appear late (a platform driver loading after the daemon ++ * started), so input hotplug is followed as well. ++ */ ++ ++#define BITS_PER_LONG (sizeof (unsigned long) * 8) ++#define NLONGS(x) (((x) + BITS_PER_LONG - 1) / BITS_PER_LONG) ++ ++typedef struct ++{ ++ gchar *path; ++ gint fd; ++ GSource *source; ++} FpiLidInput; ++ ++struct _FpiLidSwitch ++{ ++ GObject parent; ++ ++ GMainContext *context; /* the thread-default context at creation */ ++ GUdevClient *udev_client; ++ GHashTable *inputs; /* device file -> FpiLidInput */ ++ gboolean closed; ++}; ++ ++enum { ++ PROP_0, ++ PROP_CLOSED, ++ N_PROPS ++}; ++static GParamSpec *properties[N_PROPS]; ++ ++G_DEFINE_TYPE (FpiLidSwitch, fpi_lid_switch, G_TYPE_OBJECT) ++ ++static gboolean ++test_bit (guint bit, const unsigned long *array) ++{ ++ return !!(array[bit / BITS_PER_LONG] & (1UL << (bit % BITS_PER_LONG))); ++} ++ ++static void ++lid_input_free (FpiLidInput *input) ++{ ++ if (input->source) ++ { ++ g_source_destroy (input->source); ++ g_clear_pointer (&input->source, g_source_unref); ++ } ++ if (input->fd >= 0) ++ close (input->fd); ++ g_free (input->path); ++ g_free (input); ++} ++ ++static void ++lid_switch_update (FpiLidSwitch *self) ++{ ++ GHashTableIter iter; ++ FpiLidInput *input; ++ gboolean closed = FALSE; ++ ++ g_hash_table_iter_init (&iter, self->inputs); ++ while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &input)) ++ { ++ unsigned long state[NLONGS (SW_CNT)] = { 0 }; ++ ++ if (ioctl (input->fd, EVIOCGSW (sizeof (state)), state) < 0) ++ { ++ fp_dbg ("Cannot read switch state of %s: %s", input->path, g_strerror (errno)); ++ continue; ++ } ++ ++ /* Any closed lid covers the sensor. */ ++ if (test_bit (SW_LID, state)) ++ closed = TRUE; ++ } ++ ++ if (closed == self->closed) ++ return; ++ ++ self->closed = closed; ++ fp_info ("Lid %s", closed ? "closed" : "opened"); ++ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_CLOSED]); ++} ++ ++static gboolean ++lid_input_ready_cb (gint fd, GIOCondition condition, gpointer user_data) ++{ ++ FpiLidSwitch *self = FPI_LID_SWITCH (user_data); ++ struct input_event events[16]; ++ FpiLidInput *input = NULL; ++ GHashTableIter iter; ++ gboolean gone = (condition & (G_IO_HUP | G_IO_ERR)) != 0; ++ ++ g_hash_table_iter_init (&iter, self->inputs); ++ while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &input)) ++ if (input->fd == fd) ++ break; ++ ++ /* Drain; the content does not matter, the state is read back below. */ ++ while (!gone) ++ { ++ gssize len = read (fd, events, sizeof (events)); ++ ++ if (len > 0) ++ continue; ++ if (len < 0 && errno == EINTR) ++ continue; ++ if (len < 0 && errno == EAGAIN) ++ break; ++ ++ gone = TRUE; ++ } ++ ++ if (gone) ++ { ++ if (input != NULL) ++ { ++ fp_dbg ("Lid switch %s went away", input->path); ++ g_hash_table_remove (self->inputs, input->path); ++ lid_switch_update (self); ++ } ++ return G_SOURCE_REMOVE; ++ } ++ ++ lid_switch_update (self); ++ return G_SOURCE_CONTINUE; ++} ++ ++static void ++lid_switch_add_input (FpiLidSwitch *self, GUdevDevice *udev_device) ++{ ++ unsigned long sw_bits[NLONGS (SW_CNT)] = { 0 }; ++ const gchar *path = g_udev_device_get_device_file (udev_device); ++ FpiLidInput *input; ++ gint fd; ++ ++ if (path == NULL || !g_str_has_prefix (path, "/dev/input/event")) ++ return; ++ ++ if (g_hash_table_contains (self->inputs, path)) ++ return; ++ ++ /* With a udev database, only open devices that have switches at all; ++ * without one, fall back to asking the device. */ ++ if (g_udev_device_has_property (udev_device, "ID_INPUT") && ++ !g_udev_device_get_property_as_boolean (udev_device, "ID_INPUT_SWITCH")) ++ return; ++ ++ fd = open (path, O_RDONLY | O_NONBLOCK | O_CLOEXEC); ++ if (fd < 0) ++ { ++ fp_dbg ("Cannot open %s: %s", path, g_strerror (errno)); ++ return; ++ } ++ ++ if (ioctl (fd, EVIOCGBIT (EV_SW, sizeof (sw_bits)), sw_bits) < 0 || ++ !test_bit (SW_LID, sw_bits)) ++ { ++ close (fd); ++ return; ++ } ++ ++ input = g_new0 (FpiLidInput, 1); ++ input->path = g_strdup (path); ++ input->fd = fd; ++ /* Like the rest of libfprint, and like the GUdevClient above, dispatch in ++ * the thread-default main context of whoever created us. */ ++ input->source = g_unix_fd_source_new (fd, G_IO_IN | G_IO_HUP | G_IO_ERR); ++ g_source_set_callback (input->source, G_SOURCE_FUNC (lid_input_ready_cb), self, NULL); ++ g_source_attach (input->source, self->context); ++ g_hash_table_insert (self->inputs, input->path, input); ++ ++ fp_dbg ("Following lid switch %s (%s)", path, ++ g_udev_device_get_sysfs_attr (udev_device, "device/name") ? : "unnamed"); ++} ++ ++static void ++lid_switch_uevent_cb (GUdevClient *client, ++ const gchar *action, ++ GUdevDevice *udev_device, ++ gpointer user_data) ++{ ++ FpiLidSwitch *self = FPI_LID_SWITCH (user_data); ++ const gchar *path = g_udev_device_get_device_file (udev_device); ++ ++ if (path == NULL) ++ return; ++ ++ if (g_str_equal (action, "add") || g_str_equal (action, "change")) ++ lid_switch_add_input (self, udev_device); ++ else if (g_str_equal (action, "remove")) ++ g_hash_table_remove (self->inputs, path); ++ else ++ return; ++ ++ lid_switch_update (self); ++} ++ ++static void ++fpi_lid_switch_get_property (GObject *object, ++ guint prop_id, ++ GValue *value, ++ GParamSpec *pspec) ++{ ++ FpiLidSwitch *self = FPI_LID_SWITCH (object); ++ ++ switch (prop_id) ++ { ++ case PROP_CLOSED: ++ g_value_set_boolean (value, self->closed); ++ break; ++ ++ default: ++ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); ++ } ++} ++ ++static void ++fpi_lid_switch_dispose (GObject *object) ++{ ++ FpiLidSwitch *self = FPI_LID_SWITCH (object); ++ ++ if (self->udev_client) ++ g_signal_handlers_disconnect_by_data (self->udev_client, self); ++ g_clear_object (&self->udev_client); ++ g_clear_pointer (&self->inputs, g_hash_table_unref); ++ g_clear_pointer (&self->context, g_main_context_unref); ++ ++ G_OBJECT_CLASS (fpi_lid_switch_parent_class)->dispose (object); ++} ++ ++static void ++fpi_lid_switch_class_init (FpiLidSwitchClass *klass) ++{ ++ GObjectClass *object_class = G_OBJECT_CLASS (klass); ++ ++ object_class->get_property = fpi_lid_switch_get_property; ++ object_class->dispose = fpi_lid_switch_dispose; ++ ++ properties[PROP_CLOSED] = ++ g_param_spec_boolean ("closed", ++ "Closed", ++ "Whether a laptop lid is closed", ++ FALSE, ++ G_PARAM_STATIC_STRINGS | G_PARAM_READABLE); ++ ++ g_object_class_install_properties (object_class, N_PROPS, properties); ++} ++ ++static void ++fpi_lid_switch_init (FpiLidSwitch *self) ++{ ++ const gchar * const subsystems[] = { "input", NULL }; ++ GList *devices, *l; ++ ++ self->context = g_main_context_ref_thread_default (); ++ self->inputs = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, ++ (GDestroyNotify) lid_input_free); ++ ++ self->udev_client = g_udev_client_new (subsystems); ++ g_signal_connect (self->udev_client, "uevent", ++ G_CALLBACK (lid_switch_uevent_cb), self); ++ ++ devices = g_udev_client_query_by_subsystem (self->udev_client, "input"); ++ for (l = devices; l; l = l->next) ++ lid_switch_add_input (self, l->data); ++ g_list_free_full (devices, g_object_unref); ++ ++ lid_switch_update (self); ++} ++ ++/** ++ * fpi_lid_switch_new: ++ * ++ * Follow the laptop lid switches of the system. ++ * ++ * Returns: (transfer full): a new #FpiLidSwitch ++ */ ++FpiLidSwitch * ++fpi_lid_switch_new (void) ++{ ++ return g_object_new (FPI_TYPE_LID_SWITCH, NULL); ++} ++ ++/** ++ * fpi_lid_switch_get_closed: ++ * @self: a #FpiLidSwitch ++ * ++ * Returns: %TRUE if a lid is closed, %FALSE if it is open or there is none ++ */ ++gboolean ++fpi_lid_switch_get_closed (FpiLidSwitch *self) ++{ ++ g_return_val_if_fail (FPI_IS_LID_SWITCH (self), FALSE); ++ ++ return self->closed; ++} +diff --git a/libfprint/fpi-lid-switch.h b/libfprint/fpi-lid-switch.h +new file mode 100644 +index 00000000..e51fd631 +--- /dev/null ++++ b/libfprint/fpi-lid-switch.h +@@ -0,0 +1,29 @@ ++/* ++ * Laptop lid switch tracking ++ * Copyright (C) 2026 Ryan Murray ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ++ */ ++ ++#pragma once ++ ++#include ++ ++#define FPI_TYPE_LID_SWITCH (fpi_lid_switch_get_type ()) ++G_DECLARE_FINAL_TYPE (FpiLidSwitch, fpi_lid_switch, FPI, LID_SWITCH, GObject) ++ ++FpiLidSwitch *fpi_lid_switch_new (void); ++ ++gboolean fpi_lid_switch_get_closed (FpiLidSwitch *self); +diff --git a/libfprint/meson.build b/libfprint/meson.build +index 400c5b74..e0dc170b 100644 +--- a/libfprint/meson.build ++++ b/libfprint/meson.build +@@ -6,6 +6,12 @@ if have_spi + spi_sources = ['fpi-spi-transfer.c'] + endif + ++lid_sources = [] ++ ++if libfprint_conf.has('HAVE_UDEV') ++ lid_sources = ['fpi-lid-switch.c'] ++endif ++ + libfprint_sources = [ + 'fp-context.c', + 'fp-device.c', +@@ -25,7 +31,7 @@ libfprint_private_sources = [ + 'fpi-print.c', + 'fpi-ssm.c', + 'fpi-usb-transfer.c', +-] + spi_sources ++] + spi_sources + lid_sources + + libfprint_public_headers = [ + 'fp-context.h', +diff --git a/tests/meson.build b/tests/meson.build +index d218e04d..5bf9f17c 100644 +--- a/tests/meson.build ++++ b/tests/meson.build +@@ -322,6 +322,13 @@ if 'virtual_image' in drivers + ] + endif + ++# Makes uinput lid switches: skipped without /dev/uinput access and udev ++if libfprint_conf.has('HAVE_UDEV') ++ unit_tests += [ ++ 'lid-switch', ++ ] ++endif ++ + unit_tests_deps = { 'fpi-assembling' : [cairo_dep] } + + foreach test_name: unit_tests +diff --git a/tests/test-fpi-device.c b/tests/test-fpi-device.c +index 165532d7..0b9b3b9e 100644 +--- a/tests/test-fpi-device.c ++++ b/tests/test-fpi-device.c +@@ -2834,6 +2834,43 @@ test_driver_identify_suspend_while_idle (void) + g_assert_no_error (error); + } + ++static void ++on_removed_set_flag (gboolean *flag) ++{ ++ *flag = TRUE; ++} ++ ++/* A device removed while the system sleeps, such as a reader that a closed ++ * lid covers, must still be closable after resume. */ ++static void ++test_driver_removed_while_suspended (void) ++{ ++ g_autoptr(FpAutoResetClass) dev_class = auto_reset_device_class (); ++ g_autoptr(FpDevice) device = NULL; ++ g_autoptr(GError) error = NULL; ++ gboolean removed_emitted = FALSE; ++ ++ device = g_object_new (FPI_TYPE_DEVICE_FAKE, NULL); ++ g_signal_connect_swapped (device, "removed", G_CALLBACK (on_removed_set_flag), &removed_emitted); ++ g_assert_true (fp_device_open_sync (device, NULL, NULL)); ++ ++ g_assert_true (fp_device_suspend_sync (device, NULL, &error)); ++ g_assert_no_error (error); ++ ++ fpi_device_remove (device); ++ g_assert_true (removed_emitted); ++ ++ fp_device_resume_sync (device, NULL, &error); ++ g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_REMOVED); ++ g_clear_error (&error); ++ ++ /* Closing reports the removal, but must close the device rather than ++ * refuse as busy. */ ++ fp_device_close_sync (device, NULL, &error); ++ g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_REMOVED); ++ g_assert_false (fp_device_is_open (device)); ++} ++ + static void + test_driver_identify_warmup_cooldown (void) + { +@@ -4155,6 +4192,7 @@ main (int argc, char *argv[]) + g_test_add_func ("/driver/identify/suspend_succeeds", test_driver_identify_suspend_succeeds); + g_test_add_func ("/driver/identify/suspend_busy_error", test_driver_identify_suspend_busy_error); + g_test_add_func ("/driver/identify/suspend_while_idle", test_driver_identify_suspend_while_idle); ++ g_test_add_func ("/driver/removed_while_suspended", test_driver_removed_while_suspended); + + g_test_add_func ("/driver/identify/warmup_cooldown", test_driver_identify_warmup_cooldown); + +diff --git a/tests/test-lid-switch.c b/tests/test-lid-switch.c +new file mode 100644 +index 00000000..ef3f6d36 +--- /dev/null ++++ b/tests/test-lid-switch.c +@@ -0,0 +1,306 @@ ++/* ++ * FpiLidSwitch tests, with uinput lid switches ++ * Copyright (C) 2026 Ryan Murray ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ++ */ ++ ++/* ++ * These tests make real lid switches with uinput, so they need write access ++ * to /dev/uinput and a running udev; without either they are skipped. They ++ * also need a system whose own lid, if it has one, is open. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include ++ ++#include "fpi-lid-switch.h" ++ ++#define LID_TIMEOUT_US (5 * G_USEC_PER_SEC) ++ ++typedef struct ++{ ++ gint fd; ++} TestLid; ++ ++static TestLid * ++test_lid_new (const gchar *name) ++{ ++ struct uinput_setup setup = { 0 }; ++ TestLid *lid; ++ gint fd; ++ ++ fd = open ("/dev/uinput", O_WRONLY | O_NONBLOCK | O_CLOEXEC); ++ if (fd < 0) ++ return NULL; ++ ++ setup.id.bustype = BUS_VIRTUAL; ++ g_strlcpy (setup.name, name, sizeof (setup.name)); ++ ++ if (ioctl (fd, UI_SET_EVBIT, EV_SW) < 0 || ++ ioctl (fd, UI_SET_SWBIT, SW_LID) < 0 || ++ ioctl (fd, UI_DEV_SETUP, &setup) < 0 || ++ ioctl (fd, UI_DEV_CREATE) < 0) ++ { ++ close (fd); ++ return NULL; ++ } ++ ++ lid = g_new0 (TestLid, 1); ++ lid->fd = fd; ++ return lid; ++} ++ ++static void ++test_lid_emit (TestLid *lid, guint16 type, guint16 code, gint32 value) ++{ ++ struct input_event ev = { 0 }; ++ ++ ev.type = type; ++ ev.code = code; ++ ev.value = value; ++ g_assert_cmpint (write (lid->fd, &ev, sizeof (ev)), ==, sizeof (ev)); ++} ++ ++static void ++test_lid_set_closed (TestLid *lid, gboolean closed) ++{ ++ test_lid_emit (lid, EV_SW, SW_LID, closed); ++ test_lid_emit (lid, EV_SYN, SYN_REPORT, 0); ++} ++ ++static void ++test_lid_free (TestLid *lid) ++{ ++ ioctl (lid->fd, UI_DEV_DESTROY); ++ close (lid->fd); ++ g_free (lid); ++} ++ ++G_DEFINE_AUTOPTR_CLEANUP_FUNC (TestLid, test_lid_free) ++ ++/* Iterate @context until @self says @closed, for at most LID_TIMEOUT_US. */ ++static gboolean ++wait_for_closed (GMainContext *context, FpiLidSwitch *self, gboolean closed) ++{ ++ gint64 deadline = g_get_monotonic_time () + LID_TIMEOUT_US; ++ ++ while (fpi_lid_switch_get_closed (self) != closed) ++ { ++ if (g_get_monotonic_time () > deadline) ++ return FALSE; ++ if (!g_main_context_iteration (context, FALSE)) ++ g_usleep (10000); ++ } ++ ++ return TRUE; ++} ++ ++/* Settle for a while and check @self never says anything but @closed. */ ++static gboolean ++stays_closed (GMainContext *context, FpiLidSwitch *self, gboolean closed) ++{ ++ gint64 deadline = g_get_monotonic_time () + G_USEC_PER_SEC / 2; ++ ++ while (g_get_monotonic_time () < deadline) ++ { ++ if (fpi_lid_switch_get_closed (self) != closed) ++ return FALSE; ++ if (!g_main_context_iteration (context, FALSE)) ++ g_usleep (10000); ++ } ++ ++ return fpi_lid_switch_get_closed (self) == closed; ++} ++ ++static guint ++count_open_fds (void) ++{ ++ g_autoptr(GDir) dir = g_dir_open ("/proc/self/fd", 0, NULL); ++ guint n = 0; ++ ++ g_assert_nonnull (dir); ++ while (g_dir_read_name (dir)) ++ n++; ++ return n; ++} ++ ++static gboolean ++skip_unless_usable (void) ++{ ++ g_autoptr(FpiLidSwitch) lid = NULL; ++ ++ if (access ("/dev/uinput", W_OK) != 0) ++ { ++ g_test_skip ("needs write access to /dev/uinput"); ++ return TRUE; ++ } ++ ++ if (access ("/run/udev/control", F_OK) != 0) ++ { ++ g_test_skip ("needs a running udev"); ++ return TRUE; ++ } ++ ++ lid = fpi_lid_switch_new (); ++ if (fpi_lid_switch_get_closed (lid)) ++ { ++ g_test_skip ("this system's own lid is closed"); ++ return TRUE; ++ } ++ ++ return FALSE; ++} ++ ++/* A switch that appears after we started, bounces, and goes away again. */ ++static void ++test_lid_switch_hotplug (void) ++{ ++ g_autoptr(FpiLidSwitch) self = NULL; ++ g_autoptr(TestLid) lid = NULL; ++ guint fds_before; ++ ++ if (skip_unless_usable ()) ++ return; ++ ++ fds_before = count_open_fds (); ++ self = fpi_lid_switch_new (); ++ g_assert_false (fpi_lid_switch_get_closed (self)); ++ ++ lid = test_lid_new ("libfprint test lid"); ++ g_assert_nonnull (lid); ++ ++ test_lid_set_closed (lid, TRUE); ++ g_assert_true (wait_for_closed (NULL, self, TRUE)); ++ ++ /* Bounce */ ++ test_lid_set_closed (lid, FALSE); ++ test_lid_set_closed (lid, TRUE); ++ test_lid_set_closed (lid, FALSE); ++ g_assert_true (wait_for_closed (NULL, self, FALSE)); ++ g_assert_true (stays_closed (NULL, self, FALSE)); ++ ++ /* A switch that goes away while closed no longer counts */ ++ test_lid_set_closed (lid, TRUE); ++ g_assert_true (wait_for_closed (NULL, self, TRUE)); ++ g_clear_pointer (&lid, test_lid_free); ++ g_assert_true (wait_for_closed (NULL, self, FALSE)); ++ ++ g_clear_object (&self); ++ while (g_main_context_iteration (NULL, FALSE)) ++ continue; ++ g_assert_cmpuint (count_open_fds (), ==, fds_before); ++} ++ ++/* Any closed lid counts, as for logind. */ ++static void ++test_lid_switch_two_lids (void) ++{ ++ g_autoptr(FpiLidSwitch) self = NULL; ++ g_autoptr(TestLid) a = NULL; ++ g_autoptr(TestLid) b = NULL; ++ ++ if (skip_unless_usable ()) ++ return; ++ ++ a = test_lid_new ("libfprint test lid A"); ++ b = test_lid_new ("libfprint test lid B"); ++ g_assert_nonnull (a); ++ g_assert_nonnull (b); ++ ++ self = fpi_lid_switch_new (); ++ ++ /* Both must be followed before we go on */ ++ test_lid_set_closed (a, TRUE); ++ g_assert_true (wait_for_closed (NULL, self, TRUE)); ++ test_lid_set_closed (a, FALSE); ++ g_assert_true (wait_for_closed (NULL, self, FALSE)); ++ test_lid_set_closed (b, TRUE); ++ g_assert_true (wait_for_closed (NULL, self, TRUE)); ++ ++ test_lid_set_closed (a, TRUE); ++ test_lid_set_closed (b, FALSE); ++ g_assert_true (stays_closed (NULL, self, TRUE)); ++ ++ test_lid_set_closed (a, FALSE); ++ g_assert_true (wait_for_closed (NULL, self, FALSE)); ++} ++ ++static gpointer ++lid_thread_func (gpointer user_data) ++{ ++ TestLid *lid = user_data; ++ g_autoptr(GMainContext) context = g_main_context_new (); ++ g_autoptr(FpiLidSwitch) self = NULL; ++ gboolean ok; ++ ++ g_main_context_push_thread_default (context); ++ ++ self = fpi_lid_switch_new (); ++ g_assert_false (fpi_lid_switch_get_closed (self)); ++ ++ test_lid_set_closed (lid, TRUE); ++ ok = wait_for_closed (context, self, TRUE); ++ ++ g_clear_object (&self); ++ g_main_context_pop_thread_default (context); ++ ++ return GINT_TO_POINTER (ok); ++} ++ ++/* Like the rest of libfprint, the switch must dispatch in the thread-default ++ * main context of the thread that made it, not in the global default one. */ ++static void ++test_lid_switch_thread_default_context (void) ++{ ++ g_autoptr(TestLid) lid = NULL; ++ g_autoptr(FpiLidSwitch) settle = NULL; ++ GThread *thread; ++ ++ if (skip_unless_usable ()) ++ return; ++ ++ lid = test_lid_new ("libfprint test lid"); ++ g_assert_nonnull (lid); ++ ++ /* Wait until udev knows the switch, so the thread finds it at once. */ ++ settle = fpi_lid_switch_new (); ++ test_lid_set_closed (lid, TRUE); ++ g_assert_true (wait_for_closed (NULL, settle, TRUE)); ++ test_lid_set_closed (lid, FALSE); ++ g_assert_true (wait_for_closed (NULL, settle, FALSE)); ++ g_clear_object (&settle); ++ ++ thread = g_thread_new ("lid", lid_thread_func, lid); ++ g_assert_true (GPOINTER_TO_INT (g_thread_join (thread))); ++} ++ ++int ++main (int argc, char *argv[]) ++{ ++ g_test_init (&argc, &argv, NULL); ++ ++ g_test_add_func ("/lid-switch/hotplug", test_lid_switch_hotplug); ++ g_test_add_func ("/lid-switch/two-lids", test_lid_switch_two_lids); ++ g_test_add_func ("/lid-switch/thread-default-context", test_lid_switch_thread_default_context); ++ ++ return g_test_run (); ++} +-- +2.50.1 (Apple Git-155) + diff --git a/pkgbuilds/libfprint-git/fprintd-lid-switch.conf b/pkgbuilds/libfprint-git/fprintd-lid-switch.conf new file mode 100644 index 0000000000..41ffac037b --- /dev/null +++ b/pkgbuilds/libfprint-git/fprintd-lid-switch.conf @@ -0,0 +1,6 @@ +# libfprint hides a fingerprint reader that a closed laptop lid covers, and +# follows the lid switch for that. fprintd's sandbox allows only the devices +# it names, so let it read input devices. libfprint opens only those that +# report switches, read-only. +[Service] +DeviceAllow=char-input r diff --git a/pkgbuilds/linux-aurora/.omarchy/package.json b/pkgbuilds/linux-aurora/.omarchy/package.json index 04e6ea9d02..60d6ab2ad9 100644 --- a/pkgbuilds/linux-aurora/.omarchy/package.json +++ b/pkgbuilds/linux-aurora/.omarchy/package.json @@ -1,5 +1,7 @@ { "source": "local", - "skip_build": true, - "channels": ["edge"] + "channels": [ + "edge" + ], + "sync": false } diff --git a/pkgbuilds/linux-aurora/PKGBUILD b/pkgbuilds/linux-aurora/PKGBUILD index 721801adfe..c8b8124311 100644 --- a/pkgbuilds/linux-aurora/PKGBUILD +++ b/pkgbuilds/linux-aurora/PKGBUILD @@ -9,37 +9,38 @@ # cold-boot qualification on M1 and M2. _auroraver=7.1.12 -_aurorarel=2 -pkgrel=11 +_aurorarel=5 +pkgrel=1 # Immutable pin on aurora-silicon/linux (branch aurora-wip). Every bump is a -# PR that moves _commit and the archive checksum; the pinned commit is cold-boot -# qualified on MacBook Pro 14" M1 Pro (j314s) and 16" M2 Max (j416c) first. -_commit=2439016d2e8d3a0d8aebcd243f29604a91f201c9 - +# PR that moves _commit; its cold-boot qualification is recorded in +# docs/aurora-edge.md before channel publication. 5f6c917 merges #301, which +# leaves the firmware-owned J700 DISP_CPU domain alone: without it the Neo +# does not boot. +_commit=5f6c917f2c824b3c87497e8bd7dd92a6de0efe60 + +# Any m1n1 1.6.1 loads these device trees. The Neo's own Stage 2 comes from the +# image, so the floor stays where M1 and M2 users' m1n1-aurora already meets it. _m1n1_version=1.6.1 pkgbase=linux-aurora -_srcname=linux-${_commit} +_srcname=linux _kernelname=${pkgbase#linux} _desc="AArch64 Apple Silicon (Aurora kernel)" pkgver="${_auroraver}.aurora${_aurorarel}" arch=('aarch64') +groups=('omarchy-platform-apple-silicon') url="https://github.com/aurora-silicon/linux" license=('GPL2') makedepends=( - base-devel bc dtc kmod libelf pahole cpio perl rustup rust-bindgen tar xz xmlto python + base-devel bc dtc kmod libelf pahole cpio perl rustup clang llvm lld clang18 llvm18 lld18 + tar xz xmlto python git patch ) options=('!strip') -source=( - https://github.com/aurora-silicon/linux/archive/${_commit}.tar.gz - config # the main kernel config file - rust-toolchain.toml -) -sha256sums=('6347354537148120fc5448afcb8671a558ce336f731c70690cd88062a903f84d' - 'e8f3818e6bfa70166dd5caff228a0becfdd5d4f0165b589efa38150fd0b59cc9' - '2a95563bb9f5b216cc3c170a17e9471448bc63a7084bdd67df23d074939b366c') +source=("linux::git+https://github.com/aurora-silicon/linux.git#commit=${_commit}" + rust-toolchain.toml bindgen-kernel.py) +sha256sums=('SKIP' '443a9c4613172ea352f49b114818a1d75ab048ec4bd2d75b388a7ab3a8a1f046' '84a03d5fea19cae243c89f50c1736c639622d25d4d1de8d7d53ebd8f603c0f62') # Kbuild takes ARCH literally and knows arm64, not aarch64. export ARCH=arm64 @@ -65,14 +66,28 @@ prepare() { echo "Pinning the Rust toolchain..." cp ../rust-toolchain.toml . - echo "Creating build directories..." + # ALARM's clang18, llvm18 and lld18 install their tools under this prefix only. + export LLVM="${AURORA_LLVM:-/usr/lib/llvm18/bin/}" + local clang_command="clang${LLVM}" + [[ $LLVM != */ ]] || clang_command="${LLVM}clang" + "$clang_command" --version | head -1 | grep -Eq 'clang version 18\.' || { + echo 'linux-aurora requires the qualified LLVM 18 build environment' >&2; return 1; + } + rustup toolchain install 1.99.0 --profile minimal + RUSTUP_TOOLCHAIN=1.99.0 python3 tools/aurora-bindgen/build.py --output-dir "$srcdir/private-bindgen" + export AURORA_BINDGEN_REAL="$srcdir/private-bindgen/rust-bindgen-0.73.2/target/release/bindgen" + export BINDGEN="$srcdir/bindgen-kernel.py" + export RUSTUP_TOOLCHAIN=1.85.0 + rustup toolchain install 1.85.0 --profile minimal --component rust-src mkdir -p build/base - - echo "Setting config (base)..." - cp ../config build/base/.config - make olddefconfig prepare O=$PWD/build/base - diff -u ../config build/base/.config || : - make -s kernelrelease O=$PWD/build/base > build/base/version + make O="$PWD/build/base" defconfig + scripts/kconfig/merge_config.sh -m -O "$PWD/build/base" build/base/.config arch/arm64/configs/asahi.config + make O="$PWD/build/base" olddefconfig + scripts/kconfig/merge_config.sh -m -O "$PWD/build/base" build/base/.config arch/arm64/configs/j700-radio.config arch/arm64/configs/j700.config + make O="$PWD/build/base" olddefconfig + scripts/kconfig/merge_config.sh -m -O "$PWD/build/base" build/base/.config arch/arm64/configs/j700-device-parity.config + make O="$PWD/build/base" olddefconfig prepare + make -s O="$PWD/build/base" kernelrelease > build/base/version echo "Prepared $pkgbase version $( tools.ini + + _meson mesa build "${_options[@]}" --native-file tools.ini \ + -Dllvm=disabled -Dspirv-tools=disabled -Dmesa-clc=system -Dprecomp-compiler=system \ + -Dbuild-tests=false + meson compile -C build -j "${OMARCHY_BUILD_JOBS:-10}" + DESTDIR="$srcdir/mesa-stage" meson install -C build --no-rebuild +} +check() { + # Mesa's own tests stay off: at this commit hk_sampler_bias_test undefines + # NDEBUG and calls nir_validate_shader, so it links only in debug builds. + # Nothing packaged may follow the system's LLVM or SPIRV-Tools. + ! find "$srcdir/mesa-stage" -name '*.so*' -type f -exec readelf -d {} + | + grep -E 'NEEDED.*(libLLVM|libSPIRV-Tools)' +} +package_mesa-aurora() { + pkgdesc='Aurora native Asahi Gallium and Zink OpenGL drivers' + depends=('expat' 'glibc' 'gcc-libs' 'libdrm' 'libglvnd' 'libx11' 'libxcb' 'libxext' + 'libxshmfence' 'libxxf86vm' 'lm_sensors' 'wayland' 'zlib' 'zstd') + provides=("mesa=$epoch:$pkgver" 'mesa-libgl' 'opengl-driver' 'libgbm.so') + conflicts=('mesa') + cp -a "$srcdir/mesa-stage/usr" "$pkgdir/" + rm "$pkgdir/usr/lib/libvulkan_asahi.so" + rm "$pkgdir"/usr/share/vulkan/icd.d/*asahi*.json + rmdir "$pkgdir/usr/share/vulkan/icd.d" "$pkgdir/usr/share/vulkan" 2>/dev/null || true + +} +package_vulkan-aurora() { + pkgdesc='Aurora Honeykrisp Vulkan driver' + depends=('expat' 'glibc' 'gcc-libs' 'libdrm' 'libdisplay-info' 'libx11' 'libxcb' + 'libxshmfence' 'systemd-libs' 'vulkan-icd-loader' 'wayland' + 'xcb-util-keysyms' 'zlib' 'zstd') + provides=("vulkan-asahi=$epoch:$pkgver" "vulkan-asahi-aurora=$epoch:$pkgver" 'vulkan-driver') + conflicts=('vulkan-asahi' 'vulkan-asahi-aurora') + replaces=('vulkan-asahi-aurora') + install -Dm755 "$srcdir/mesa-stage/usr/lib/libvulkan_asahi.so" "$pkgdir/usr/lib/libvulkan_asahi.so" + install -d "$pkgdir/usr/share/vulkan/icd.d" + cp -a "$srcdir"/mesa-stage/usr/share/vulkan/icd.d/*asahi*.json "$pkgdir/usr/share/vulkan/icd.d/" +} diff --git a/pkgbuilds/omarchy-aurora-firmware/.omarchy/package.json b/pkgbuilds/omarchy-aurora-firmware/.omarchy/package.json new file mode 100644 index 0000000000..60d6ab2ad9 --- /dev/null +++ b/pkgbuilds/omarchy-aurora-firmware/.omarchy/package.json @@ -0,0 +1,7 @@ +{ + "source": "local", + "channels": [ + "edge" + ], + "sync": false +} diff --git a/pkgbuilds/omarchy-aurora-firmware/20-aurora-vendor-order.conf b/pkgbuilds/omarchy-aurora-firmware/20-aurora-vendor-order.conf new file mode 100644 index 0000000000..715a95e512 --- /dev/null +++ b/pkgbuilds/omarchy-aurora-firmware/20-aurora-vendor-order.conf @@ -0,0 +1,5 @@ +[Unit] +Before=display-manager.service NetworkManager.service iwd.service + +[Service] +ExecStartPost=/usr/lib/omarchy/initcpio/aurora-peripheral-firmware.sh diff --git a/pkgbuilds/omarchy-aurora-firmware/86-aurora-regdom-fallback.rules b/pkgbuilds/omarchy-aurora-firmware/86-aurora-regdom-fallback.rules new file mode 100644 index 0000000000..44942cc581 --- /dev/null +++ b/pkgbuilds/omarchy-aurora-firmware/86-aurora-regdom-fallback.rules @@ -0,0 +1 @@ +ACTION=="add", SUBSYSTEM=="ieee80211", DRIVERS=="mt7932-fullmac", TAG+="systemd", ENV{SYSTEMD_WANTS}+="aurora-regdom-fallback.service" diff --git a/pkgbuilds/omarchy-aurora-firmware/95-aurora-vendor-order.conf b/pkgbuilds/omarchy-aurora-firmware/95-aurora-vendor-order.conf new file mode 100644 index 0000000000..d721890434 --- /dev/null +++ b/pkgbuilds/omarchy-aurora-firmware/95-aurora-vendor-order.conf @@ -0,0 +1,2 @@ +# Include the per-machine firmware ordering service in every rebuilt initrd. +HOOKS+=(aurora-vendor-order) diff --git a/pkgbuilds/omarchy-aurora-firmware/PKGBUILD b/pkgbuilds/omarchy-aurora-firmware/PKGBUILD new file mode 100644 index 0000000000..ca001282ff --- /dev/null +++ b/pkgbuilds/omarchy-aurora-firmware/PKGBUILD @@ -0,0 +1,27 @@ +pkgname=omarchy-aurora-firmware +pkgver=20261014 +pkgrel=1 +pkgdesc='Order Apple peripheral admission after device firmware extraction' +arch=('aarch64') +groups=('omarchy-platform-apple-silicon') +license=('MIT') +url='https://github.com/aurora-silicon/omarchy-mac' +depends=('bash' 'iw' 'kmod' 'omarchy-mac-boot' 'linux-aurora>=7.1.12.aurora5') +source=(aurora-firmware-order.conf aurora-peripheral-firmware.sh + aurora-peripheral-firmware.service aurora-vendor-order.install + 95-aurora-vendor-order.conf aurora-vendor-order-cryptsetup.conf + 20-aurora-vendor-order.conf aurora-regdom-fallback + aurora-regdom-fallback.service 86-aurora-regdom-fallback.rules) +sha256sums=('e6338787cc03c7704589df20f7551ac17bc2ae25aa2f8df3b6d9532a1c5b79f9' '70f1fcc7890963fe9d7efda0da6f917557a7278371586c4fc2962c1b1c7cc197' '328c689685f21bb760f3bea7984b42060a04f6a386d4a35b8237de95328ccc31' '2747dcac56d8a7b631add820b07b931c44b92c3112fbd697c2c5d2a6896df888' '8ef54ee9d0f438864f2a99bbb8c0cf53aa8b7e0e217bd74b2fd324ff0b882a32' '298c2abc4c0e11ab03470209b4ff93c184eed40d3cf9e1913e41ba0ea0179837' 'e200d1cf003d60eca4a825aec9475f36dd8db6a5a8805eaac93e3fecfa0b3cb0' '29980d1d73742ea2e418c4e10e20e64a1554936946cd9e81a1f07d05c34ab8f6' '5aeb12c046553b53e5edd75a7c94a082e8c4edc4ee1226f5163d5ce9774f4d3c' '3b994ae27fd1a14ccd569cfc103b205807fe262fe2487446de02d870455e1ec8') +package() { + install -Dm644 aurora-firmware-order.conf "$pkgdir/usr/lib/modprobe.d/aurora-firmware-order.conf" + install -Dm755 aurora-peripheral-firmware.sh "$pkgdir/usr/lib/omarchy/initcpio/aurora-peripheral-firmware.sh" + install -Dm644 aurora-peripheral-firmware.service "$pkgdir/usr/lib/systemd/system/aurora-peripheral-firmware.service" + install -Dm755 aurora-vendor-order.install "$pkgdir/usr/lib/initcpio/install/aurora-vendor-order" + install -Dm644 95-aurora-vendor-order.conf "$pkgdir/etc/mkinitcpio.conf.d/95-aurora-vendor-order.conf" + install -Dm644 aurora-vendor-order-cryptsetup.conf "$pkgdir/usr/lib/omarchy/initcpio/aurora-vendor-order-cryptsetup.conf" + install -Dm644 20-aurora-vendor-order.conf "$pkgdir/usr/lib/systemd/system/omarchy-vendor-firmware.service.d/20-aurora-vendor-order.conf" + install -Dm755 aurora-regdom-fallback "$pkgdir/usr/lib/omarchy/aurora-regdom-fallback" + install -Dm644 aurora-regdom-fallback.service "$pkgdir/usr/lib/systemd/system/aurora-regdom-fallback.service" + install -Dm644 86-aurora-regdom-fallback.rules "$pkgdir/usr/lib/udev/rules.d/86-aurora-regdom-fallback.rules" +} diff --git a/pkgbuilds/omarchy-aurora-firmware/aurora-firmware-order.conf b/pkgbuilds/omarchy-aurora-firmware/aurora-firmware-order.conf new file mode 100644 index 0000000000..b0bf7d909c --- /dev/null +++ b/pkgbuilds/omarchy-aurora-firmware/aurora-firmware-order.conf @@ -0,0 +1,6 @@ +# These drivers request per-machine files during probe. The initrd's +# aurora-peripheral-firmware.service loads them explicitly after extraction. +# A blacklist stops modalias autoload; explicit modprobe still works. +blacklist aop +blacklist mt7932-fullmac +blacklist mt7932_bt_pcie diff --git a/pkgbuilds/omarchy-aurora-firmware/aurora-peripheral-firmware.service b/pkgbuilds/omarchy-aurora-firmware/aurora-peripheral-firmware.service new file mode 100644 index 0000000000..0669cbce6f --- /dev/null +++ b/pkgbuilds/omarchy-aurora-firmware/aurora-peripheral-firmware.service @@ -0,0 +1,12 @@ +[Unit] +Description=Load Apple peripherals after per-machine firmware is available +DefaultDependencies=no +Wants=omarchy-vendorfw-initrd.service +After=omarchy-vendorfw-initrd.service +Before=cryptsetup-pre.target initrd-root-device.target +Conflicts=shutdown.target + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/usr/lib/omarchy/initcpio/aurora-peripheral-firmware.sh diff --git a/pkgbuilds/omarchy-aurora-firmware/aurora-peripheral-firmware.sh b/pkgbuilds/omarchy-aurora-firmware/aurora-peripheral-firmware.sh new file mode 100644 index 0000000000..327d957b1f --- /dev/null +++ b/pkgbuilds/omarchy-aurora-firmware/aurora-peripheral-firmware.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# Never reset a running device. Repeated modprobe of a loaded module is inert. +set -eu +firmware_root=${AURORA_FIRMWARE_ROOT:-/lib/firmware} +compatible=${AURORA_DT_COMPATIBLE:-/sys/firmware/devicetree/base/compatible} +modprobe_command=${AURORA_MODPROBE:-modprobe} + +has_firmware() { + [ -s "$firmware_root/vendor/$1" ] || [ -s "$firmware_root/$1" ] +} + +neo=false +if grep -aq 'apple,j700' "$compatible"; then + neo=true + if has_firmware apple/j700-aop-als-cal.bin; then + "$modprobe_command" aop + else + echo 'Aurora: ALS calibration missing; Neo AOP probe deferred' >&2 + fi + radio_ready=true + for name in \ + mediatek/mt7932/IZUBA_WIFI_MT7932_patch_mcu_1_2_hdr.bin \ + mediatek/mt7932/IZUBA_W7932_2.bin \ + mediatek/mt7932/ppr.bin mediatek/mt7932/oca2.bin \ + mediatek/mt7932/wcal.bin mediatek/mt7932/config-original.bin \ + mediatek/MT7932B0_OS_TypeB_0.1.44.0_241001003711.bin \ + mediatek/MT7932B1_OS_TypeB_0.1.133.0_260128190103.bin \ + mediatek/MT7932_PTB_IzubaA_0.1.0.0_20251021141303.ptx \ + mediatek/j700-mt7932-btcal.bin mediatek/j700-mt7932-bdaddr.bin \ + mediatek/mt7932/policy/US.bin mediatek/mt7932/policy/world-XZ.bin; do + if ! has_firmware "$name"; then + echo "Aurora: required firmware is missing: $name; peripheral probe deferred" >&2 + radio_ready=false + fi + done +fi + +if "$neo"; then + if "$radio_ready"; then "$modprobe_command" mt7932-fullmac; fi +else + # Preserve ordinary non-Neo admission even if vendor extraction failed. + "$modprobe_command" aop +fi +# Bluetooth is deliberately admitted later by its existing gated PCI service, +# after root firmware extraction. It is not necessary to unlock the root disk. diff --git a/pkgbuilds/omarchy-aurora-firmware/aurora-regdom-fallback b/pkgbuilds/omarchy-aurora-firmware/aurora-regdom-fallback new file mode 100644 index 0000000000..4a4e4e0bf7 --- /dev/null +++ b/pkgbuilds/omarchy-aurora-firmware/aurora-regdom-fallback @@ -0,0 +1,20 @@ +#!/bin/bash +# The MT7932 radio takes its regulatory policy from +# /usr/lib/firmware/mediatek/mt7932/policy/.bin and stays blocked for +# a country without one. Whenever the regulatory domain lands on such a +# country, switch to the world domain, whose policy is world-XZ.bin, so the +# radio comes up with the most restrictive rules instead of not at all. +policy=/usr/lib/firmware/mediatek/mt7932/policy + +fall_back() { + local country + country=$(iw reg get | awk '$1 == "country" { sub(":", "", $2); print $2; exit }') + [[ $country =~ ^[A-Z]{2}$ && ! -e $policy/$country.bin ]] || return 0 + echo "No MT7932 policy for $country; using the world regulatory domain" + iw reg set 00 +} + +fall_back +iw event | while read -r line; do + [[ $line == *"regulatory domain change"* ]] && fall_back +done diff --git a/pkgbuilds/omarchy-aurora-firmware/aurora-regdom-fallback.service b/pkgbuilds/omarchy-aurora-firmware/aurora-regdom-fallback.service new file mode 100644 index 0000000000..8777ffa187 --- /dev/null +++ b/pkgbuilds/omarchy-aurora-firmware/aurora-regdom-fallback.service @@ -0,0 +1,6 @@ +[Unit] +Description=World regulatory domain for countries without an MT7932 policy + +[Service] +ExecStart=/usr/lib/omarchy/aurora-regdom-fallback +Restart=on-failure diff --git a/pkgbuilds/omarchy-aurora-firmware/aurora-vendor-order-cryptsetup.conf b/pkgbuilds/omarchy-aurora-firmware/aurora-vendor-order-cryptsetup.conf new file mode 100644 index 0000000000..1f13f836bf --- /dev/null +++ b/pkgbuilds/omarchy-aurora-firmware/aurora-vendor-order-cryptsetup.conf @@ -0,0 +1,3 @@ +[Unit] +Wants=aurora-peripheral-firmware.service +After=aurora-peripheral-firmware.service diff --git a/pkgbuilds/omarchy-aurora-firmware/aurora-vendor-order.install b/pkgbuilds/omarchy-aurora-firmware/aurora-vendor-order.install new file mode 100644 index 0000000000..dd12ec92a1 --- /dev/null +++ b/pkgbuilds/omarchy-aurora-firmware/aurora-vendor-order.install @@ -0,0 +1,26 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +build() { + add_binary bash + add_binary modprobe + add_binary grep + add_module aop + add_module aop_als + add_module mt7932-fullmac + # The policies come with the image, not a package; a missing one must not fail + # the build. aurora-peripheral-firmware.sh then defers the radio instead. + local policy + for policy in /usr/lib/firmware/mediatek/mt7932/policy/{US,world-XZ}.bin; do + [[ ! -e $policy ]] || add_file "$policy" + done + add_file /usr/lib/modprobe.d/aurora-firmware-order.conf + add_file /usr/lib/omarchy/initcpio/aurora-peripheral-firmware.sh + add_file /usr/lib/systemd/system/aurora-peripheral-firmware.service + add_symlink /usr/lib/systemd/system/sysinit.target.wants/aurora-peripheral-firmware.service ../aurora-peripheral-firmware.service + add_symlink /usr/lib/systemd/system/initrd-root-device.target.wants/aurora-peripheral-firmware.service ../aurora-peripheral-firmware.service + add_file /usr/lib/omarchy/initcpio/aurora-vendor-order-cryptsetup.conf \ + /usr/lib/systemd/system/systemd-cryptsetup@.service.d/aurora-vendor-order.conf +} +help() { + echo 'Load AOP and Neo Wi-Fi only after the ESP vendor firmware is extracted.' +} diff --git a/pkgbuilds/speakerguardd/.omarchy/package.json b/pkgbuilds/speakerguardd/.omarchy/package.json new file mode 100644 index 0000000000..60d6ab2ad9 --- /dev/null +++ b/pkgbuilds/speakerguardd/.omarchy/package.json @@ -0,0 +1,7 @@ +{ + "source": "local", + "channels": [ + "edge" + ], + "sync": false +} diff --git a/pkgbuilds/speakerguardd/50-j700-guard.conf b/pkgbuilds/speakerguardd/50-j700-guard.conf new file mode 100644 index 0000000000..08518cfb7e --- /dev/null +++ b/pkgbuilds/speakerguardd/50-j700-guard.conf @@ -0,0 +1,2 @@ +[Service] +ExecCondition=/usr/lib/speakerguardd/use-feedback-guard diff --git a/pkgbuilds/speakerguardd/PKGBUILD b/pkgbuilds/speakerguardd/PKGBUILD new file mode 100644 index 0000000000..28974dd529 --- /dev/null +++ b/pkgbuilds/speakerguardd/PKGBUILD @@ -0,0 +1,49 @@ +pkgname=speakerguardd +pkgver=0.1.0.aurora2 +pkgrel=1 +pkgdesc='Apple speaker feed-forward protection with J700 profile' +arch=('aarch64') +groups=('omarchy-platform-apple-silicon') +url='https://github.com/aurora-silicon/speakerguardd' +license=('MIT') +_commit=e03febfe52a540e9255036a01e18030e0a5135f9 +makedepends=('git' 'rust' 'cargo' 'python' 'alsa-lib' 'pkgconf') +depends=('glibc' 'gcc-libs' 'alsa-lib') +source=("speakerguardd::git+$url.git#commit=$_commit" use-feedback-guard 50-j700-guard.conf) +sha256sums=('SKIP' 'bd2da656ad1dff69a0d64bb3a33d5eb4681b3573dcbfe098f405d8979bb436b5' '5bcc720660327927702f730719cd12fec8f0cf0e21991f158d08f4a733d71a81') +prepare() { + python3 - <<'PYUNIT' +from pathlib import Path +p = Path('speakerguardd/speakerguardd.service') +s = p.read_text() +for old, new in [ + ('ExecStart=/usr/bin/speakerguardd -c /usr/share/speakerguardd', 'ExecStart=/usr/bin/speakerguardd -c /usr/share/speakerguardd -C AppleJ700'), + ('Description=Speaker Protection Daemon (feed-forward)', 'Description=Speaker Protection Daemon (feed-forward)\nStartLimitIntervalSec=60\nStartLimitBurst=10'), + ('StartLimitInterval=60\nStartLimitBurst=10\n', ''), +]: + if s.count(old) != 1: + raise SystemExit('Pinned speaker unit changed: ' + old.splitlines()[0]) + s = s.replace(old, new, 1) +p.write_text(s) +PYUNIT +} +build() { + cd speakerguardd + cargo build --locked --release ${CARGO_TARGET:+--target "$CARGO_TARGET"} +} +check() { + cd speakerguardd + cargo test --locked +} +package() { + local binary=speakerguardd/target/release/speakerguardd + if [[ -n ${CARGO_TARGET:-} ]]; then binary=speakerguardd/target/$CARGO_TARGET/release/speakerguardd; fi + install -Dm755 "$binary" "$pkgdir/usr/bin/speakerguardd" + install -d "$pkgdir/usr/share" + cp -a speakerguardd/conf "$pkgdir/usr/share/speakerguardd" + install -Dm644 speakerguardd/speakerguardd.service "$pkgdir/usr/lib/systemd/system/speakerguardd.service" + install -Dm644 speakerguardd/95-speakerguardd.rules "$pkgdir/usr/lib/udev/rules.d/95-speakerguardd.rules" + install -Dm755 use-feedback-guard "$pkgdir/usr/lib/speakerguardd/use-feedback-guard" + install -Dm644 50-j700-guard.conf "$pkgdir/usr/lib/systemd/system/speakersafetyd.service.d/50-j700-guard.conf" + install -Dm644 speakerguardd/LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE" +} diff --git a/pkgbuilds/speakerguardd/use-feedback-guard b/pkgbuilds/speakerguardd/use-feedback-guard new file mode 100755 index 0000000000..24979b0a73 --- /dev/null +++ b/pkgbuilds/speakerguardd/use-feedback-guard @@ -0,0 +1,4 @@ +#!/bin/sh +test -r /proc/device-tree/compatible || exit 0 +tr '\000' '\n' < /proc/device-tree/compatible | grep -Fxq apple,j700 && exit 1 +exit 0 diff --git a/pkgbuilds/uboot-aurora/.omarchy/package.json b/pkgbuilds/uboot-aurora/.omarchy/package.json new file mode 100644 index 0000000000..60d6ab2ad9 --- /dev/null +++ b/pkgbuilds/uboot-aurora/.omarchy/package.json @@ -0,0 +1,7 @@ +{ + "source": "local", + "channels": [ + "edge" + ], + "sync": false +} diff --git a/pkgbuilds/uboot-aurora/PKGBUILD b/pkgbuilds/uboot-aurora/PKGBUILD new file mode 100644 index 0000000000..0afa30c423 --- /dev/null +++ b/pkgbuilds/uboot-aurora/PKGBUILD @@ -0,0 +1,28 @@ +pkgname=uboot-aurora +pkgver=2026.07.aurora2 +pkgrel=1 +pkgdesc='Aurora common Apple Silicon U-Boot with Neo MTP handoff' +arch=('aarch64') +groups=('omarchy-platform-apple-silicon') +url='https://github.com/aurora-silicon/u-boot' +license=('GPL-2.0-or-later') +_commit=0cb6fed6a10512d1013a4a80b6d83c3d56140f2f +provides=("uboot-asahi=$pkgver") +conflicts=('uboot-asahi' 'uboot-asahi-j700') +replaces=('uboot-asahi-j700') +makedepends=('git' 'bc' 'dtc' 'python' 'python-pyelftools' 'swig' 'openssl') +options=('!strip' '!debug') +source=("u-boot::git+$url.git#commit=$_commit") +sha256sums=('SKIP') +build() { + cd u-boot + make O=build-aurora CROSS_COMPILE="${CROSS_COMPILE:-}" PYTHON3=/usr/bin/python3 apple_m1_defconfig + make O=build-aurora CROSS_COMPILE="${CROSS_COMPILE:-}" PYTHON3=/usr/bin/python3 -j"${OMARCHY_BUILD_JOBS:-10}" +} +package() { + install -Dm644 u-boot/build-aurora/u-boot-nodtb.bin "$pkgdir/usr/lib/asahi-boot/u-boot-nodtb.bin" + install -d "$pkgdir/usr/lib/asahi-boot-j700" + ln -s ../asahi-boot/u-boot-nodtb.bin "$pkgdir/usr/lib/asahi-boot-j700/u-boot-nodtb.bin" + install -Dm644 u-boot/Licenses/gpl-2.0.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE" + # DTBs come from linux-aurora; generated u-boot.dtb is the default J274 tree. +} diff --git a/tests/aurora-edge/metadata.py b/tests/aurora-edge/metadata.py new file mode 100644 index 0000000000..0aa92a4ed9 --- /dev/null +++ b/tests/aurora-edge/metadata.py @@ -0,0 +1,101 @@ +#!/usr/bin/env python3 +"""Check edge-only recipes and their declared compatibility upgrade versions.""" +import json +from pathlib import Path +import subprocess +import unittest + +ROOT = Path(__file__).resolve().parents[2] +NAMES = ['linux-aurora', 'mesa-aurora', 'aura', 'uboot-aurora', 'aurora-bless', + 'speakerguardd', 'aurora-audio', 'alsa-ucm-conf-aurora', 'omarchy-aurora-firmware'] + + +def srcinfo(name): + output = subprocess.check_output(['makepkg', '--printsrcinfo'], cwd=ROOT / 'pkgbuilds' / name, text=True) + base, packages, current = {}, {}, None + for raw in output.splitlines(): + if ' = ' not in raw: + continue + key, value = raw.strip().split(' = ', 1) + if key == 'pkgname': + current = packages.setdefault(value, {k: list(v) for k, v in base.items()}) + else: + (base if current is None else current).setdefault(key, []).append(value) + return packages + + +class EdgeMetadataTests(unittest.TestCase): + def test_canonical_names_and_previous_draft_upgrades(self): + for name in NAMES: + for canonical in srcinfo(name): + self.assertNotIn('asahi', canonical) + for new, old in [('aurora-audio', 'asahi-audio-aurora'), + ('alsa-ucm-conf-aurora', 'alsa-ucm-conf-asahi-aurora'), + ('vulkan-aurora', 'vulkan-asahi-aurora')]: + package = srcinfo('mesa-aurora' if new == 'vulkan-aurora' else new)[new] + for field in ['conflicts', 'replaces']: + self.assertIn(old, package[field]) + self.assertTrue(any(p.startswith(old + '=') for p in package['provides'])) + + def test_only_edge_and_no_automatic_source_tracking(self): + for name in NAMES: + with self.subTest(name=name): + value = json.loads((ROOT / 'pkgbuilds' / name / '.omarchy/package.json').read_text()) + self.assertEqual(value['channels'], ['edge']) + self.assertFalse(value['sync']) + self.assertEqual(value['source'], 'local') + self.assertNotIn('release_ring', value) + + def test_stock_names_are_provided_but_never_replaced(self): + # A replaces= on a stock name swaps it on every machine using [omarchy], + # including Qualcomm and generic aarch64 ones, at their next update. + for new, old in [('mesa-aurora', 'mesa'), ('vulkan-aurora', 'vulkan-asahi'), + ('aurora-bless', 'asahi-bless'), ('uboot-aurora', 'uboot-asahi'), + ('aurora-audio', 'asahi-audio'), + ('alsa-ucm-conf-aurora', 'alsa-ucm-conf-asahi'), ('aura', 'm1n1'), + ('aura', 'm1n1-aurora')]: + base = 'mesa-aurora' if new.startswith('vulkan-') else new + package = srcinfo(base)[new] + self.assertIn(old, package['conflicts']) + self.assertNotIn(old, package.get('replaces', [])) + if old != 'm1n1-aurora': + self.assertTrue(any(p.startswith(old + '=') for p in package['provides'])) + + def test_kernel_replaces_nothing(self): + # linux-aurora sets its relations inside generated package functions, + # which --printsrcinfo does not see. + recipe = (ROOT / 'pkgbuilds' / 'linux-aurora' / 'PKGBUILD').read_text() + self.assertNotIn('replaces=', recipe) + + def test_every_recipe_is_apple_silicon_only(self): + for name in NAMES: + for package in srcinfo(name).values(): + self.assertEqual(package['groups'], ['omarchy-platform-apple-silicon']) + + def test_mesa_follows_neither_llvm_nor_spirv_tools(self): + for package in srcinfo('mesa-aurora').values(): + for dependency in ['llvm-libs', 'spirv-tools']: + self.assertNotIn(dependency, package['depends']) + + def test_mesa_epoch_and_existing_neo_versions_upgrade(self): + installed = {'mesa-aurora': '1:26.3.0_devel-932.a0bcbcb28528', + 'linux-aurora': '7.1.12.aurora4-20261013.d08fd52e1619', + 'speakerguardd': '0.1.0.aurora1-e03febfe52a5'} + for name, old in installed.items(): + package = srcinfo(name)[name] + prefix = package.get('epoch', ['0'])[0] + ':' + new = prefix + package['pkgver'][0] + '-' + package['pkgrel'][0] + self.assertGreater(int(subprocess.check_output(['vercmp', new, old], text=True)), 0) + self.assertEqual(srcinfo('mesa-aurora')['mesa-aurora']['epoch'], ['1']) + + def test_aura_independent_version_satisfies_legacy_kernel_dependency(self): + package = srcinfo('aura')['aura'] + compatibility = next(p.split('=', 1)[1] for p in package['provides'] if p.startswith('m1n1=')) + self.assertGreaterEqual(int(subprocess.check_output(['vercmp', compatibility, '1.6.1.aurora19'], text=True)), 0) + for old in ['m1n1', 'm1n1-aurora', 'm1n1-neo']: + self.assertIn(old, package['conflicts']) + self.assertEqual(package['replaces'], ['m1n1-neo']) + + +if __name__ == '__main__': + unittest.main()