cb22 / macbook12-spi-driver

WIP input driver for the SPI touchpad / keyboard found in the 12" MacBook (MacBook8,1 + MacBook9,1)
GNU General Public License v2.0
300 stars 106 forks source link

Init fixes and caps lock led support #14

Closed roadrunner2 closed 7 years ago

roadrunner2 commented 7 years ago

Apologies for sending this in one pull request, but I'm too lazy to try and tear things apart. The two big features where are the fixes to make trackpad initialization reliable, and to toggle the caps-locks led. Besides that there are some cleanups/re-factorings that I hope are acceptable.

This should fix issues #6 and #3, and is also related to #9.

cb22 commented 7 years ago

Great! This looks good to me. I'm without my laptop for a little bit (screen issue getting fixed), so I can't test it out myself - but if you're satisfied, then I'm happy to merge it in.

roadrunner2 commented 7 years ago

@cb22 I'm reasonably happy with the changes, but it would nevertheless be good if somebody could test them on a MacBook (8 or 9), in particular the caps-lock led functionality (the traces I based it off are from a MacBookPro13,* - it's quite likely they're the same on the MacBook's, but it's just not been tested there).

Dunedan commented 7 years ago

Really awesome work. Hit the caps lock key multiple times today just to see the fancy LED light up. :smile:

Looking at the diff the SPI init and the caps lock LED commands look pretty similar. Any idea if there are additional commands available?

Dunedan commented 7 years ago

One probably pretty minor issue I noticed: When reloading the applespi driver the Xorg.0.log gets filled with the following message for a few milliseconds:

[ 38290.618] (EE) Apple SPI Touchpad: Read error 19
roadrunner2 commented 7 years ago

@cb22 Everything has been confirmed working on a MacBook8 (see #9), so from my side I'm happy now.

roadrunner2 commented 7 years ago

@Dunedan Yes, the structure of the commands are quite similar - I've been able to deduce a few more things about the structures of the messages in general (e.g. I understand the 8-byte header now, and know how to detect and deal with continued messages, such as occur when more than 6 fingers are pressed), and plan to submit a pull to make use of that and do a little less black-magic bit banging. And in fact there are some other commands in the traces @tudorbarascu sent, but I haven't tried to see what they do.

As to the error: hmm, errno 19 is ENODEV, and those are Xorg messages, so not sure there's anything in the driver that can be done about this.