Skip to content

Add haptic-control functionality to Apple M2's MTP touchpad - #573

Open
hex-64 wants to merge 32 commits into
AsahiLinux:asahifrom
hex-64:asahi-haptic-touchpad
Open

Add haptic-control functionality to Apple M2's MTP touchpad#573
hex-64 wants to merge 32 commits into
AsahiLinux:asahifrom
hex-64:asahi-haptic-touchpad

Conversation

@hex-64

@hex-64 hex-64 commented Aug 20, 2026

Copy link
Copy Markdown

This merge request adds a new driver into the kernel to allow for the userspace to custom control the haptic effects of the apple MTP trackpad and follows the convention for haptic touchpad functionality as specified in [1].

Set the INPUT_PROP_PRESSUREPAD property within the MTP trackpad device indicating that this device is a haptic touchpad, and set the FF_HAPTIC capability to indicate that force feedback haptic effects can be uploaded to the trackpad [2]. Userspace can thus choose to upload force feedback effects to the touchpad, which would trigger it to switch into "Host controlled" mode, where the touchpad will no longer click unless signalled to do so by userspace.

This patch uses an unconventional means of doing so, by writing a separate loadable module for the haptic actuator. This is because the haptic actuator is considered a separate device on MTP trackpads, whereas haptics for HUTRR63 (And the other kernel drivers) considers the haptic actuator and the touchpad to be the very same device. Therefore, to conform to the standardized interface in [1] this patch creates a separate driver for the separate HID device, and is designed such that commands to the actuator are sent through the touchpad.

This changeset is relevant because allowing userspace control of the haptics allows for user control of:
1. Click feedback intensity
2. Sensitivity of when clicks trigger
3. Configuring "Force Touch"-like deep click functionality

The specific hardware commands and their fields have been reverse engineered on my own machine (Macbook Pro 2023 M2 Max) using the m1n1 hypervisor. The changes have not been tested on any other machine.

See also [3] where discussions were previously had on some of the specifics of the hardware

[1] https://lore.kernel.org/all/20250818-support-forcepads-v3-0-e4f9ab0add84@google.com/T/#m12f9be6691015fb9b2e834248c368e5f90
[2] https://docs.kernel.org/input/event-codes.html#input-prop-pressurepad
[3] https://gitlab.freedesktop.org/libinput/libinput/-/work_items/1027

WhatAmISupposedToPutHere and others added 29 commits August 5, 2026 20:32
The SMC firmware included in macOS 27 changed the size of BCF0 key from
4 to 1 bytes. This key is used for indicating that battery state is
critically low. In addition, B0RM key has changed endianness.

Reviewed-by: Sven Peter <sven@kernel.org>
Reviewed-by: Joshua Peisach <jpeisach@ubuntu.com>
Reviewed-by: Janne Grunau <j@jannau.net>
Cc: stable@vger.kernel.org
Fixes: 0ebf821 ("power: supply: Add macsmc-power driver for Apple Silicon")
Signed-off-by: Sasha Finkelstein <k@chaosmail.tech>
Link: https://patch.msgid.link/20260712-gate-power-v4-1-aa59c6583247@chaosmail.tech
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Certain Broadcom bluetooth chips (bcm4377/bcm4378/bcm438) need ACL
streams carrying audio to be set as "high priority" using a vendor
specific command to prevent 10-ish second-long dropouts whenever
something does a device scan. This patch sends the command when the
socket priority is set to TC_PRIO_INTERACTIVE, as BlueZ does for audio.

Signed-off-by: Sasha Finkelstein <fnkl.kernel@gmail.com>
The current approach of silently disabling all rust drivers if the
toolchain is missing results in users that try to compile their own
kernels getting a "successful" build and then being confused about where
did their drivers go. In comparison, missing openssl results in a build
failure, not a disappearance of everything that depends on it.

This also means that allyesconfig will depend on rust, but since the
rust experiment concluded with "rust is here to stay", i believe that
allyesconfig should be building rust drivers too.

Signed-off-by: Sasha Finkelstein <k@chaosmail.tech>
Apple M3 Pro and Max devices are using 'gp00' keys for GPIO in addition
to 'gP00' keys. Add a second compatible to handle this keys with an
additional macsmc-gpio instance.

Signed-off-by: Janne Grunau <j@jannau.net>
Add support for SMC GPIO keys with a lower letter 'p' via the
"apple,smc-low-gpio" compatible. This adds support for a second
macsmc-gpio controller using 'gp00' keys.
These keys are used on Apple M3 Pro and Max MacBooks in the controller
for keyboard and trackpad and for the built-in DisplayPort to HDMI
converter.

Signed-off-by: Janne Grunau <j@jannau.net>
Apple M3 Pro and Max devices are using 'gp00' keys for GPIO in addition
to 'gP00' keys. These keys are handled by an additional macsmc-gpio
instance using the "apple,smc-low-gpio" compatible.

Signed-off-by: Janne Grunau <j@jannau.net>
@hex-64
hex-64 force-pushed the asahi-haptic-touchpad branch from fc9e273 to 87b7a9a Compare August 20, 2026 14:44
@hex-64
hex-64 force-pushed the asahi-haptic-touchpad branch from 87b7a9a to 3e34e34 Compare August 20, 2026 14:48
@hex-64

hex-64 commented Aug 20, 2026

Copy link
Copy Markdown
Author

See https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1508 for an example of a userspace program that uses this functionality

@chadmed chadmed left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also follow kernel commit message convention, it makes our life easier when upstreaming. This should be split into multiple commits, at least one adding the new driver and another integrating it into hid-magicmouse.

Comment thread drivers/hid/hid-magicmouse.c Outdated
Comment thread drivers/hid/hid-magicmouse.c Outdated
Comment thread drivers/hid/hid-magicmouse.c Outdated
Comment thread drivers/hid/hid-apple-haptic.c Outdated
Comment thread drivers/hid/Kconfig Outdated
Comment thread drivers/hid/hid-magicmouse.c Outdated
Comment thread drivers/hid/hid-magicmouse.c Outdated
Comment thread drivers/hid/hid-magicmouse.c Outdated
Comment thread include/linux/soc/apple/actuator.h Outdated
Comment thread include/linux/soc/apple/actuator.h Outdated
dchid_set_report() always sends HID_OUTPUT_REPORT regardless of the
report type requested by the caller. Inline it into its sole caller
and forward rtype directly, so SET_REPORT works correctly for feature
reports too, not just output reports, and to simplify function calls.

Signed-off-by: Yicong Hui <yicong@ycstuff.net>
@hex-64
hex-64 force-pushed the asahi-haptic-touchpad branch from 3e34e34 to 94951f1 Compare August 21, 2026 18:53
@hex-64

hex-64 commented Aug 21, 2026

Copy link
Copy Markdown
Author

Please also follow kernel commit message convention, it makes our life easier when upstreaming. This should be split into multiple commits, at least one adding the new driver and another integrating it into hid-magicmouse.

Hi! Thanks for the feedback, how's this now?

@hex-64
hex-64 requested a review from chadmed August 21, 2026 18:55
Adds a driver to control the actuator of the MTP touchpad's actuator
for M2 and later devices.

The specific hardware commands and their fields have been reverse
engineered on my own machine (Macbook Pro 2023 M2 Max) using the m1n1
hypervisor.

Signed-off-by: Yicong Hui <yicong@ycstuff.net>
@hex-64
hex-64 force-pushed the asahi-haptic-touchpad branch 2 times, most recently from 570d6f5 to 89e4a79 Compare August 21, 2026 19:24
Integrate the MTP actuator driver with the MTP trackpad driver to expose
new functionality that allows userspace to control the haptic effects
of the touchpad actuator as a force feedback device, following the
convention for haptic touchpad functionality as specified in [1].

Set the INPUT_PROP_PRESSUREPAD property within the MTP trackpad device
indicating that this device is a haptic touchpad, and set the FF_HAPTIC
capability to indicate that force feedback haptic effects can be
uploaded to the trackpad [2]. Userspace can thus choose to upload force
feedback effects to the touchpad, which would trigger it to switch into
"Host controlled" mode, where the touchpad will no longer click unless
signalled to do so by userspace.

This patch uses an unconventional means of doing so, by writing a
separate loadable module for the haptic actuator. This is because
the haptic actuator is considered a separate device on MTP trackpads,
whereas haptics for HUTRR63 (And the other kernel drivers) considers the
haptic actuator and the touchpad to be the very same device. Therefore,
to conform to the standardized interface in [1] this patch creates a
separate driver for the separate HID device, and is designed such that
commands to the actuator are sent through the touchpad.

This changeset is relevant because allowing userspace control of the
haptics allows for user control of:
    1. Click feedback intensity
    2. Sensitivity of when clicks trigger
    3. Configuring "Force Touch"-like deep click functionality

[1] https://lore.kernel.org/all/20250818-support-forcepads-v3-0-e4f9ab0add84@google.com/T/#m12f9be6691015fb9b2e834248c368e5f90
[2] https://docs.kernel.org/input/event-codes.html#input-prop-pressurepad

Signed-off-by: Yicong Hui <yicong@ycstuff.net>
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.

4 participants