Skip to content

Instantly share code, notes, and snippets.

@Tyrrrz
Last active March 15, 2026 16:18
Show Gist options
  • Select an option

  • Save Tyrrrz/bc895a294c322334080a345c5cf54506 to your computer and use it in GitHub Desktop.

Select an option

Save Tyrrrz/bc895a294c322334080a345c5cf54506 to your computer and use it in GitHub Desktop.
Fix AMD SFH Accelerometer (screen rotation) on HP x360 laptops on Linux

HP Envy x360 — Auto-rotation on Ubuntu (GNOME + Wayland)

Tested on: HP Envy x360 2-in-1 Laptop 15-fh0xxx, Ubuntu with GNOME on Wayland.

The Problem

The AMD Sensor Fusion Hub (SFH) driver loads on boot before the PCIe hardware is fully ready, causing it to miss the accelerometer. The fix is to force the correct sensor mask and reload the module before the display manager starts.

Fix

1. Create a modprobe config to set the sensor mask:

sudo mkdir -p /etc/modprobe.d/
echo "options amd_sfh sensor_mask=1" | sudo tee /etc/modprobe.d/amd_sfh.conf
sudo update-initramfs -u

2. Create a systemd service to reload the module before GNOME starts:

sudo nano /etc/systemd/system/amd-sfh-fix.service
[Unit]
Description=Fix AMD SFH (accelerometer) sensor mask
Before=display-manager.service
After=systemd-udev-settle.service

[Service]
Type=oneshot
ExecStart=/bin/sh -c 'modprobe -r amd_sfh; sleep 2; modprobe amd_sfh'
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable amd-sfh-fix.service
sudo reboot

After reboot, iio-sensor-proxy should automatically detect the accelerometer and GNOME extensions like Screen Rotate will work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment