Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
17 changes: 13 additions & 4 deletions pkgbuilds/iptsd/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

pkgname=iptsd
pkgver=3.1.0
pkgrel=3
pkgrel=4
pkgdesc="Userspace daemon for Surface touchscreens and pens (Intel Precise Touch & Stylus and SPI digitizers)"
arch=('aarch64')
url="https://github.com/linux-surface/iptsd"
Expand All @@ -16,10 +16,14 @@ options=('!debug')
_commit=a83bc1232f7096f8b33b50fdbda249cd640de670
source=("iptsd::git+https://github.com/linux-surface/iptsd.git#commit=${_commit}"
'README.package.md'
'iptsd-romulus15-resume.service')
'iptsd-romulus15-resume.service'
'iptsd-romulus15-boot'
'iptsd-romulus15-boot.service')
sha256sums=('13b805164b0ae60901dd1f2a36ea62b661367fe6e00676d9487a0584fc6adbda'
'f8f291ad19d3ece0e9ffde852146ea2d3bface410af79746959ed03802d30a41'
'dd0380e4d4faa10c0cc70cbf25791e6dee7ad9df1582b17151d3a20ef9784c12')
'0f88842cecd0acb32ab90ae260e28dce83dffee8898c47ae4c63dae62575b8a0'
'dd0380e4d4faa10c0cc70cbf25791e6dee7ad9df1582b17151d3a20ef9784c12'
'b4f81b2c280f006cc2b1f47d940257b081c891d90a8792adef79cbf1197b0f61'
'c19fcb77917ed3269cd2127525dd759854ba4bbdafc56601a74f6129bcb5e248')

prepare() {
# Upstream starts iptsd only on "add". A later "change" event, such as the
Expand All @@ -43,4 +47,9 @@ package() {
install -d "$pkgdir/usr/lib/systemd/system/suspend.target.wants"
ln -s ../iptsd-romulus15-resume.service \
"$pkgdir/usr/lib/systemd/system/suspend.target.wants/iptsd-romulus15-resume.service"
install -Dm755 iptsd-romulus15-boot -t "$pkgdir/usr/lib/iptsd"
install -Dm644 iptsd-romulus15-boot.service -t "$pkgdir/usr/lib/systemd/system"
install -d "$pkgdir/usr/lib/systemd/system/multi-user.target.wants"
ln -s ../iptsd-romulus15-boot.service \
"$pkgdir/usr/lib/systemd/system/multi-user.target.wants/iptsd-romulus15-boot.service"
}
2 changes: 2 additions & 0 deletions pkgbuilds/iptsd/README.package.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ The packaged udev rule also runs on "change" events. Upstream's runs only on "ad

On the Surface Laptop 7 15" (Snapdragon X Elite), the touchpad needs iptsd for two-finger scroll, pinch and two-finger tap. It resets during resume and comes back in its mouse mode, and a running iptsd doesn't notice, so `iptsd-romulus15-resume.service` restarts iptsd after a suspend. It does nothing on any other machine. Press to click doesn't register under iptsd yet.

On some boots of the same laptop the pad stops answering for a few seconds just as its HID device is re-bound to hid-multitouch. iptsd's udev rule then finds it silent and never starts iptsd, so the pad stays in its mouse mode until the rule runs again. `iptsd-romulus15-boot.service` waits, checks whether iptsd runs for the touchpad and re-runs the rule until it does. Seen on 3 of 7 boots on one laptop. It does nothing on any other machine.

## Retirement

Drop once Arch Linux ARM packages iptsd, or once the Surface Pro 11's pen and the Surface Laptop 7's touchpad work through the kernel alone.
39 changes: 39 additions & 0 deletions pkgbuilds/iptsd/iptsd-romulus15-boot
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

# Start iptsd for the Surface Laptop 7 15" touchpad when its start at boot was
# lost. Run by iptsd-romulus15-boot.service.
#
# At boot the touchpad's HID device is bound to hid-generic and then re-bound
# to hid-multitouch. iptsd starts on the first binding and is stopped by the
# re-bind, and on some boots the pad then stops answering for about five
# seconds (spi_hid logs "failed to set report" and "Response timed out").
# iptsd's udev rule runs iptsd-check-device against the silent pad, gets no
# answer and does not ask for iptsd again, so the pad stays in its mouse mode.
# Re-running the rule once the pad answers starts iptsd.

touchpad_id="045E:0C77"

touchpad_hidraw() {
local node
for node in /sys/class/hidraw/hidraw*; do
if [[ $(readlink -f "$node/device") == *":$touchpad_id."* ]]; then
echo "${node##*/}"
return 0
fi
done
return 1
}

for attempt in {1..8}; do
sleep 5
hidraw=$(touchpad_hidraw) || continue
if systemctl is-active --quiet "iptsd@dev-$hidraw.service"; then
echo "iptsd is running for the touchpad ($hidraw) after $((attempt - 1)) retries"
exit 0
fi
echo "iptsd is not running for the touchpad ($hidraw); re-running its udev rule (attempt $attempt)"
udevadm trigger --action=change "/dev/$hidraw"
done

echo "iptsd did not start for the touchpad" >&2
exit 1
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
10 changes: 10 additions & 0 deletions pkgbuilds/iptsd/iptsd-romulus15-boot.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# On some boots of the Surface Laptop 7 15" iptsd's udev rule finds the
# touchpad not answering and never starts iptsd, so the pad stays in its mouse
# mode. This starts it once the pad answers again. See iptsd-romulus15-boot.
[Unit]
Description=Start iptsd for the touchpad after boot on the Surface Laptop 7 15"
ConditionFirmware=device-tree-compatible(microsoft,romulus15)

[Service]
Type=oneshot
ExecStart=/usr/lib/iptsd/iptsd-romulus15-boot
8 changes: 8 additions & 0 deletions pkgbuilds/iptsd/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,12 @@ grep -q 'ConditionFirmware=device-tree-compatible(microsoft,romulus15)' \
grep -q 'suspend.target.wants/iptsd-romulus15-resume.service' "$package_dir/PKGBUILD" ||
fail "the resume restart is enabled by the package"

grep -q 'ConditionFirmware=device-tree-compatible(microsoft,romulus15)' \
"$package_dir/iptsd-romulus15-boot.service" ||
fail "the boot-time start stays off every machine but the Surface Laptop 7 15\""
grep -q 'multi-user.target.wants/iptsd-romulus15-boot.service' "$package_dir/PKGBUILD" ||
fail "the boot-time start is enabled by the package"
bash -n "$package_dir/iptsd-romulus15-boot" ||
fail "the boot-time start script has valid syntax"

echo "ok - iptsd builds pinned upstream source against Arch libraries"
Loading