Commit Graph

144 Commits

Author SHA1 Message Date
Ronald Tschalär 7886031230 applespi: Remove unnecessary include.
Thanks to Lukas Wunner for catching that.
2019-01-14 00:56:08 -08:00
Ronald Tschalär 20947da541 applespi: Trivial return status check fix.
efivar_entry_set_safe() returns standard status codes, not efi ones.
2019-01-10 23:28:34 -08:00
Ronald Tschalär ec293d593e applespi: Fix hang trying to remove module after read failure.
We weren't clearing the read/write-in-progress flags if reading an spi
packet failed, which could leave those set indefinitely, making it
impossible to remove the module.
2018-12-30 20:13:16 -08:00
Ronald Tschalär d49f7ad758 applespi: Add missing malloc failure check in probe. 2018-12-03 22:17:19 -08:00
Ronald Tschalär f2558da20f applespi: Don't set input capabilities already set by mt core.
The multitouch core already sets these capabilities, together with a
bunch of others. Furthermore, since it also generates those events but
we don't, it's best to leave the setting of those capabilities to the
mt core in the first place.
2018-11-29 23:17:53 -08:00
Ronald Tschalär ee4f27c033 applespi: Enable the keyboard and touchpad for system wake by default.
Keyboards in particular are usually expected to wake a device from sleep
by default, but since this keyboard is attached to SPI (as opposed to,
say USB) this isn't the case here. So explicitly enable it for wake.
2018-11-26 21:37:09 -08:00
Ronald Tschalär 8e9e3cc89b applespi: Explicitly turn off caps-lock led on suspend.
It will stay on while the system is suspended otherwise.

Note that we don't need to explicitly turn it back on again on resume,
as the higher layers will do that for us.
2018-10-29 15:02:14 -07:00
Ronald Tschalär 5fe2065bd0 applespi: Ignore GPE's from wakeup.
If system wakeup via keyboard/touchpad is enabled, then the GPE is
(re)enabled by the core just before going to sleep, and consequently
when a key is pressed to wake up the system the key-release generates
another GPE which our handler then receives (before the core can
re-disable the GPE). Since the SPI device is not ready, this results
in an ugly error message in dmesg.

So we now remember when we're suspended and just ignore all GPE's while
in that state.
2018-10-29 15:02:14 -07:00
Ronald Tschalär f09ae09862 applespi: Make sure SPI is enabled before GPE is.
Otherwise we might try to handle an interrupt on a non-enabled SPI
device.
2018-10-29 15:02:14 -07:00
Ronald Tschalär 8b5ec9ecf4 applespi: Avoid unnecessary delay in common cases.
Most operations are reads (i.e. keyboard and touchpad events);
furthermore the read-write-change delay is only necessary when actually
switching between read and write operations. So putting the delay after
each read is in most cases unnecessary. Hence this moves the delay to
the start of the writes instead (note that because each write is
followed by a read, it follows that each write is preceded by a read,
and so the delay at the start of the write is always necessary).
2018-10-29 15:02:14 -07:00
Ronald Tschalär ca624b7b49 applespi: Get touchpad model id from touchpad itself.
An info command is now sent to the touchpad during initialization, the
result of which contains a model id (or so we think). The model id is
then used instead of the dmi info to look up the touchpad dimensions
(that information does not appear to be present in the info command
results, unfortunately). This makes the lookup more robust for future
laptops that use the same touchpads.

Additionally, the input device's vendor and product id fields are now
filled in, using Synaptics' USB vendor id for the vendor id and the
above model id for the product id. The choice of vendor id is based on
the fact that that is what is used in the kernel rmi4 driver too (see
drivers/input/rmi4/rmi_driver.h).

This addresses #64.
2018-10-29 15:02:14 -07:00
Ronald Tschalär 8aebf482da applespi: Add option to swap fn key with a modifier key.
Only the fn key can be swapped, because the key is handled specially in
the driver - for all other key remappings use the console and desktop
key mapping mechanisms.

This closes #59.
2018-10-29 15:02:14 -07:00
Ronald Tschalär 6ef2af501d applespi: Preserve keyboard backlight level across reboots.
While desktop environments will also do this, this restores the
backlight level during early boot when, for example, the disk password
is being queried for.

Note that while Apple stores various settings in the EFI vars, they do
not store the keyboard backlight level there (and hence don't restore it
till the desktop comes up). I.e. there is no existing EFI var to use to
save this value, so this creates/uses a new one.
2018-10-29 15:02:14 -07:00
Ronald Tschalär d590d3aac9 applespi: Reset state properly on error in continuation packet. 2018-10-29 15:02:14 -07:00
Ronald Tschalär 445433e2ed applespi: Minor renaming of init command to mt-init.
This is a little more precise.
2018-10-29 03:02:14 -07:00
Ronald Tschalär 4b0dd0c3e8 applespi: Update comment to reflect all MB(P) models this driver is for. 2018-10-29 03:02:14 -07:00
Ronald Tschalär b26063bf71 applespi: Remove unnecessary struct alignment attributes.
These are gcc specific, but gcc by default already generates the
alignment and packing we want.
2018-10-29 03:02:14 -07:00
Ronald Tschalär d6e846a9a2 applespi: Minor coding style fixes. 2018-10-29 03:02:14 -07:00
Ronald Tschalär 29239b299a applespi: Don't set up any runtime-pm callbacks.
We aren't doing any runtime power management (and don't need to), and
even if we were it's unlikely our current suspend/resume callbacks
would be appropriate.

Furthermore, since our suspend/resume callbacks are not for runtime
power management, they don't need to (and should not) be inside
CONFIG_PM ifdef's.
2018-09-16 00:18:16 -07:00
Federico Lorenzi aeb7ca96ea Merge pull request #63 from roadrunner2/small-fixes
Small fixes
2018-03-14 11:19:57 +02:00
Federico Lorenzi 030150077d Merge pull request #62 from roadrunner2/handle-rollover-overflow
applespi: Handle key rollover overflow.
2018-03-14 11:19:17 +02:00
Ronald Tschalär 917d8bc68b applespi: Verify crc before verifying fields.
Minor, but we shouldn't really be looking at anything inside a message
before verifying the crc.
2018-03-04 01:57:17 -08:00
Ronald Tschalär 3e04fc1020 applespi: Fix spelling mistake in comment. 2018-03-04 01:57:16 -08:00
Ronald Tschalär 02ccb27643 applespi: Handle key rollover overflow.
The keyboard sends an all keys = 1 keyboard event when an overflow is
detected, which we need to detect and ignore.

This fixes #53.
2018-03-04 01:53:52 -08:00
Federico Lorenzi c98c6722c0 Merge pull request #56 from roadrunner2/fixes-and-message-structure-detailing
Fixes and message structure detailing
2018-01-04 19:56:36 +02:00