Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Init fixes and caps lock led support #14

Merged
merged 7 commits into from
Apr 25, 2017

Conversation

roadrunner2
Copy link
Contributor

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.

There were two issues here. First was the missing delays after each
transaction. The value used here (100us) was derived from the
'spiCSDelay' value found in the DSDT (the value given there is 10, but
with no units - experimentation found that 100us was the minimum value
at which things were stable, so assuming the unit is 10us). This then
removed the need for reducing the clock frequency, which in turn appears
to fix slow keyboard issues on MacBook8,1 (2015 model).

The second issue was an extra cs-change after sending the init message
and before receiving the status. The code comment was actually correct,
but the code didn't do what the comment said.

Lastly, this introduces a separate buffer to receive the status response
from the write.
The _DSM function for the spi device returns a structure with an
spiCSDelay field, so we now use that value instead of the hardcoded
one. Note that on all MacBook(Pro)'s tested so far (MacBook8,1,
MacBook9,1, and MacBookPro13,*) the same value (10) is returned.
Otherwise they don't get displayed in dmesg until the next log message
flushes the buffer.
@cb22
Copy link
Owner

cb22 commented Apr 24, 2017

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
Copy link
Contributor Author

@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
Copy link
Contributor

Dunedan commented Apr 24, 2017

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

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
Copy link
Contributor

Dunedan commented Apr 24, 2017

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
Copy link
Contributor Author

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

@roadrunner2
Copy link
Contributor Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants