Forked from naddeoa/xps-touchscreen-workaround.service
Last active
June 19, 2017 14:49
-
-
Save abehmiel/5a40419bac341db93fb5f8ea0e057796 to your computer and use it in GitHub Desktop.
XPS Linux workarounds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment