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

mbp15 branch - Touch bar works but doesn't visually change the fn-mode when FN key is pressed (since kernel 5.6.7) #46

Open mfvianna opened 4 years ago

mfvianna commented 4 years ago

I'm using the mbp15 branch. Until kernel 5.6.6, the module works well (except that sometimes it doesn't refresh the touchbar visually when the fn key is pressed or released - I opened another issue for that #44).

Since kernel 5.6.7 (tested 5.6.7, 5.6.8 and 5.6.11), the module compiles well, does enable the touch bar but it never visually changes the touch bar (although the meaning of the keys does change when the FN key is pressed or released) In this case, from kernels >=5.6.7, an error message is generated in dmesg every time the fn key is pressed or released (after 2 secs):

[ 261.659012] apple-ib-touchbar 0003:05AC:8302.0007: tb: Failed to set touch bar mode to 2 (-110)

Update: In one boot (in dozens), it simply worked, so this should be something in the initialization. (the only time that it worked, the issue never happened, until I booted again... :-/)

berrfred commented 4 years ago

Same behaviour here on my mbp15 but it is still working properly with 5.6.7, then I updated to 5.6.13 and the described visual problem "appeared"... got it to work with 5.6.13 only once a couple of days ago and at the next boot the problem was there again.

apple-ib-touchbar 0003:05AC:8302.0007: tb: Failed to set touch bar mode to 2 (-110)

mfvianna commented 4 years ago

@roadrunner2 , I'd like to help debug and fix this issue, that affects this branches for all kernel versions since 5.6.7, but I don't know where to start

mfvianna commented 4 years ago

I could not find the root cause so far, but I could find a workaround. Some discoveries:

@roadrunner2 , could you please take a look at this issue or shed some light?

@berrfred , I set up a workaround that consists in removing the _apple_ibtb module before shutdown. For achieving that I created a simple systemd service that runs rmmod _apple_ibtb before shutdown/reboot. But for this to start working you will have to boot at least once in 5.6.6 so that the "persistent across boots" state gets activated. It seems that not removing the module puts the touchbar in a "locked" not working state. Booting 5.6.6 cleans it as long as you remove the module before rebooting. MacOS seems to be able to recover from this locked state but also seems to restore it as it got it before rebooting, so it doesn't serve as a state cleaner

OBS: issue #44, although similar, seems to be unrelated and is not fixed with this workaround.

berrfred commented 4 years ago

I could reproduce your workaround with 5.6.7 that has always been working for me:

mfvianna commented 4 years ago

Since the module code is not documented and a have limited free time to investigate I could not yet find where the initialization and termination codes are or understand the meaning of each variable. Although I'm an experienced C developer, I'm not much familiarized with kernel coding. I guess though, based on these recent discoveries, that there is some action in the termination code that could be added to the module initialization that could reset the touch bar and make it to work on all situations.

SentToDevNull commented 4 years ago

Here's some additional info for this bug. When apple-ib-tb isn't unloaded before reboot, triggering the bug, all keys on the touchpad work EXCEPT the XF86XK_Audio* keys (which aren't detected properly; tested with xev). It's pretty interesting behavior, so I thought I'd mention it.