roadrunner2 / macbook12-spi-driver

Input driver for the SPI touchpad / keyboard found in the 12" MacBook (MacBook8,1 + MacBook9,1) and 2016 through 2018 Macbook Pro's (MacBookPro13,* and 14,*); a Touch Bar driver is also available.
GNU General Public License v2.0
251 stars 49 forks source link

Touchbar doesn't start after Suspend #47

Open joax opened 4 years ago

joax commented 4 years ago

Branch: "mbp15"

MBP 2019 15" - Model A1990

$ uname -a Linux joax-ubuntu 5.6.9 #8 SMP Thu May 14 16:02:50 PDT 2020 x86_64 x86_64 x86_64 GNU/Linux

When starting Ubuntu, including this driver, the Touchbar works as intended. But when Ubuntu suspends, the Touchbar is lost.

Reproduce:

  1. Close the laptop lid
  2. Wait 1 minute
  3. Open laptop lid

When opening, the Touchbar is not active. The following log is on /var/log/syslog:

May 17 20:43:14 joax-ubuntu kernel: [ 6415.967830] apple-ib-touchbar 0003:05AC:8302.0007: tb: Failed to set touch bar display to 4 (-113)
May 17 20:43:14 joax-ubuntu kernel: [ 6415.967831] apple-ib-touchbar 0003:05AC:8302.0007: tb: Touchbar suspended.
joax commented 4 years ago

I was able to make it work by patching the file. I know this might not be the desired fix so I won't send it as merge request:

@@ -1419,6 +1476,7 @@ static struct hid_driver appletb_hid_driver = {
        .input_configured = appletb_input_configured,
 #ifdef CONFIG_PM
        .suspend = appletb_suspend,
+       .resume = appletb_reset_resume,
        .reset_resume = appletb_reset_resume,
 #endif
 };

With this change, the touchbar does work again back from Suspend. The only missing piece is the keyboard brightness which I don't think has to do with this driver, but with how the keyboard is brought back on resume (BCE driver perhaps?). Still researching that.

Edited:

I was able to bring the keyboard back-light as well by restarting upower on wake of sleep by adding the following file /lib/systemd/system-sleep/upower-onwake:

#!/bin/sh

# Restart UPower

case "$1" in
        post)
          sleep 5
          /usr/sbin/service upower restart
                ;;
esac

You could add a line as well to restore the backlight level. I chose not to.