-
-
Save naddeoa/16d07928e3d5d60960aa91dc67f0ad32 to your computer and use it in GitHub Desktop.
[Unit] | |
Description=Potentially dangerous fix touchscreen after resume on the XPS 13 9350 | |
After=suspend.target | |
[Service] | |
Type=simple | |
ExecStart=/home/anthony/path/to/xps-touchscreen-workaround.sh | |
[Install] | |
WantedBy=suspend.target | |
#!/bin/bash | |
# Create a kill switch that will break this script when the installed kernel version breaks. There | |
# is already a patch for this in the linux kernel. No telling how something like this will interract | |
# with that. If your new kernel version still doesn't have the fix then update the WORKS_ON_KERNEL value | |
# with `uname -r` and the script will work again. | |
# | |
# Maililng list with patch: https://marc.info/?l=linux-gpio&m=147610677825233&w=2 | |
# Commit on github: https://github.com/torvalds/linux/commit/c538b9436751a0be2e1246b48353bc23156bdbcc | |
WORKS_ON_KERNEL="4.4.0-47-generic" | |
if ! [ "$WORKS_ON_KERNEL" = "`uname -r`" ]; then | |
echo "The kernel is no longer $WORKS_ON_KERNEL. This script has an 'if' that stops it from working when the kernel changes because the actual fix for this issue might be in your new kernel. If it isn't, then modify $0 to allow it to keep running." | |
exit 1 | |
fi | |
# On the XPS 13 9350, my pin is 103. Run the netire command without awk to see full output | |
PIN_NUMBER=`grep CPU_GP_1 /sys/kernel/debug/pinctrl/INT344B\:00/pins | awk '{print $2}'` | |
# This is the pin ranges. You need it to use the start of the ranges to properly address the right pin | |
STARTING_PIN=`cat /sys/kernel/debug/pinctrl/INT344B\:00/gpio-ranges | sed -n 's/.*GPIOS.*\[\(.*\) -.*PINS.*/\1/p'` | |
# This is the pin that we're actually going to request modifying | |
EFFECTIVE_PIN=$((STARTING_PIN + PIN_NUMBER)) | |
echo "Determined $EFFECTIVE_PIN was the right pin because CPU_GP_1 was $PIN_NUMBER and the gpio range starts at $STARTING_PIN" | |
# First, we lock it | |
echo $EFFECTIVE_PIN > /sys/class/gpio/export | |
# Then, we set it to high (1). The entire issue was caused by it being set to low (0) by mistake during suspend | |
echo high > "/sys/class/gpio/gpio$EFFECTIVE_PIN/direction" | |
# Then we release the lock | |
echo $EFFECTIVE_PIN > /sys/class/gpio/unexport | |
Thank you very much for this!!!
Of course.
I should also say that the script is hard coded to work on kernel version 4.4.0-47-generic because that is what Ubuntu 16.04 LTS is currently (what I'm running). There isn't anything magical about that. If you're on a different kernel then just run uname -r
and use that instead. It is just a safety precaution to make sure that this script stops working when the real fix rolls out.
Thank you very much for this!
Fixed the issue on my XPS 9360 running Ubuntu 16.06 on kernel 4.4.0-47-generic
Thanks! Works on xubuntu 16.04 on 4.4.0-47-generic.
Works for me! Thank you very much. I did notice that the kernel developer's patch seems to be in a 4.9 kernel. Any chance Canonical/Dell backports it to the 4.4?
I'm on Elementary OS (a distro based on Ubuntu 16.04) and XPS 9350 Touchscreen works perfectly for me with 4.4.0-57-generic kernel. You can check it out if it'll work for you as well.
Very nice, works for me on XPS 13 9350 and Ubuntu 16.10 (4.8.0-22-generic).
Thank you very much for providing this fix!
@naddeoa How did you find out what GPIO is responsible for enabling the Display? I have a Thinkpad X1 Yoga Gen 3 with the same issue. The touchscreen does not work after resume. It also does not show up in lsusb
. Do you think that a similar solution could work for my machine too?
You can do something like this to install the systemd init script.