sleep 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/sh
  2. case $1 in
  3. pre) # unload the modules before going to sleep
  4. # Disable bluetooth if no device is connected
  5. if ps cax | grep bluetoothd && ! bluetoothctl info; then
  6. bluetoothctl power off
  7. fi
  8. ## Disable bluetooth regardless if devices are connected (see notes below)
  9. # if ps cax | grep bluetoothd; then
  10. # bluetoothctl power off
  11. # fi
  12. ## IPTS: see notes below
  13. ## > Remove IPTS from ME side
  14. # modprobe -r ipts_surface
  15. # modprobe -r intel_ipts
  16. # modprobe -r mei_hdcp
  17. # modprobe -r mei_me
  18. # modprobe -r mei
  19. ## > Remove IPTS from i915 side
  20. # for i in $(find /sys/kernel/debug/dri -name i915_intel_ipts_cleanup); do
  21. # echo 1 > $i
  22. # done
  23. ;;
  24. post) # re-load modules after resume
  25. ## IPTS: see notes below
  26. ## > Load IPTS from i915 side
  27. # for i in $(find /sys/kernel/debug/dri -name i915_intel_ipts_init); do
  28. # echo 1 > $i
  29. # done
  30. ## > Load IPTS from ME side
  31. # modprobe mei
  32. # modprobe mei_me
  33. # modprobe mei_hdcp
  34. # modprobe intel_ipts
  35. # modprobe ipts_surface
  36. # Restart bluetooth
  37. if ps cax | grep bluetoothd; then
  38. bluetoothctl power on
  39. fi
  40. ;;
  41. esac
  42. # Notes:
  43. #
  44. # - For IPTS, see
  45. # > https://github.com/jakeday/linux-surface/issues/544#issuecomment-519126757
  46. # for an explanation/discussion. We do not unload/reload modules for now as
  47. # the IPTS drivers should be able to resume/suspend without this. If you
  48. # experience any issues on suspend/resume, please file an appropriate issue or
  49. # join the discussion linked above so that we can fix it. As a temporary
  50. # workaround, you may want to uncomment the IPTS-related lines above.
  51. #
  52. # - For bluetooth: If you have spontaneous wakeups, you may want to disable
  53. # bluetooth completely, regardless if any devices are connected or not, by
  54. # removing the `! bluetoothctl info;` part as indicated in the comment (e.g.
  55. # comment-out the original check and comment-in the one below). Note that you
  56. # may be required to re-connect your devices after resume if you choose this
  57. # change.