Skip to content

HID: apple-mtp-haptic: let the click strength be set at run time - #1959

Draft
IronsideXXVI wants to merge 1 commit into
aurora-silicon:mainfrom
IronsideXXVI:j604-mtp-haptic-click-param
Draft

IronsideXXVI wants to merge 1 commit into
aurora-silicon:mainfrom
IronsideXXVI:j604-mtp-haptic-click-param

Conversation

@IronsideXXVI

@IronsideXXVI IronsideXXVI commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

What: Add a click_strength sysfs attribute (<press>,<release>, 1-255 each) on the apple-mtp-haptic actuator's HID device. It is written to the actuator at once and again at every resume, over the device tree's apple,click-strength. This way a new machine's value can be found without rebuilding the DT and rebooting. 0,0 (the default) sets nothing: with no DT value the driver does not even read the actuator, exactly as today. The ABI is documented in sysfs-driver-hid-apple-mtp-haptic.

Tested: J604 (M4 MacBook Pro 14", no apple,click-strength) with the earlier module-parameter version our kernels carry: with the default, the actuator strength reads back unchanged (0x23 / 0x13). The sysfs version in this head (5fb6397) has not booted on the J604 yet. On top of integration/aurora fc05050, checkpatch --strict shows 0 errors and 0 checks, with one warning for the new ABI file (MAINTAINERS), and it builds clean on 110861f.

Risk: two-way · Macs with a device-controlled haptic actuator. Nothing changes until a value is written.

Not yet: The J604 row with this head's sysfs attribute. Then the J604 DT values follow as a device tree change.

Full description

The click strength of a device-controlled actuator comes from the device tree (apple,click-strength), and a machine without that property keeps the firmware's faint boot strength. Finding the right value for a new machine means rebuilding the device tree and rebooting for every try.

This adds a click_strength attribute on the actuator's HID device, read and written as <press>,<release> (1-255 each; documented in Documentation/ABI/testing/sysfs-driver-hid-apple-mtp-haptic). A value is written to the actuator at once and again at every resume, over the device tree's values. Each half is parsed with kstrtou8(), so a value out of range or with trailing characters is refused, and a write that does not reach the actuator returns the error. Setting only one of the two is refused too.

0,0, the default, means no strength is set here: with no device tree value and nothing set, the driver does not even read the actuator, exactly as today; a strength set and then cleared goes back to the firmware's boot strength, saved at the first read. The setting, the boot strengths and the lock live in each actuator's drvdata, so a second actuator gets its own. There is no module parameter.

Once the J604's values are found this way, they follow as a device tree change.

Tested:

  • On the J604 (MacBook Pro 14" M4, T8132, no apple,click-strength yet), the earlier module-parameter version of this, which our kernels carry: with the default, the actuator's strength reads back unchanged (0x23 / 0x13), so nothing changes until a value is set.
  • The sysfs version in this head has not been booted on the J604 yet. I'll add that row here when it has.

Checked on top of integration/aurora fc05050:

  • checkpatch --strict: 0 errors, 0 checks; one warning, for the new ABI file (MAINTAINERS).
  • Builds clean on 110861f (Ryan's check above).

@RyanTheTide

Copy link
Copy Markdown
Contributor

click_strength in hid-apple-mtp-haptic.c is a writable module parameter that reprograms the actuator at run time. Click strength is a per-device user setting, so it belongs in a sysfs attribute on the haptic HID device (or the input force-feedback interface), where it can be set per device and userspace settings can find it. The device tree value stays the default. Until then this should stay a draft.

@RyanTheTide
RyanTheTide marked this pull request as draft November 20, 2026 23:55

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review of the draft. I agree with Ryan: a writable module parameter that reprograms the actuator is the wrong interface, and a per-device sysfs attribute (or the force-feedback interface) is the right one. A few notes for that version:

  • Per-device state. apple_taptic_actuator and apple_taptic_boot_strength[] are module-global, so a second actuator would share one boot strength and never get a setting. Keep them in the device's drvdata.
  • Format type. sscanf(val, "%i,%i", ...) reads into unsigned int. %u matches the type; or use kstrtou8() on each half.
  • Where the J604's default comes from. The DT default should come from macOS rather than from trying values by feel. A trace of the actuator writes at macOS's default (Medium) click setting gives apple,click-strength with a source; the sysfs knob then only moves a user away from it.

@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

Thanks. The next version moves to a per-device sysfs attribute with the state in drvdata, fixes the format type, and takes the J604 default from a trace of the actuator writes at macOS's default (Medium) click setting.

@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

Pushed f5b6fff on top. The click_strength module parameter is gone:

  • Each actuator keeps its own state in drvdata: the firmware's boot strengths, the strength set for it, and a lock.
  • The setting is a click_strength attribute on the actuator's HID device (/sys/bus/hid/drivers/hid-apple-mtp-haptic/<dev>/click_strength, <press>,<release>), documented in Documentation/ABI/testing/sysfs-driver-hid-apple-mtp-haptic.
  • Each half is parsed with kstrtou8(), and a write that does not reach the actuator returns the error.
  • The device tree's apple,click-strength stays the default; 0,0 still means nothing is set here.

The J604 default still waits for the read at macOS's default (Medium) click setting on this machine. It will go into the J604 dts as its own commit, with that source, and this stays a draft until then.

@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

Read on this machine's macOS (27.2, run as a guest under the hypervisor) at the default Medium click setting (FirstClickThreshold 1, ActuationStrength unset):

report bytes strength
0x21 21 01 -
0x22 (press) 22 01 23 a8 03 02 22 48 49 01 04 60 17 2d 03 02 18 32 1e 0x23
0x23 (release) 23 01 13 90 0x13

Press 0x23 and release 0x13 are the same values the firmware has at boot under Linux. So reading the reports does not show macOS writing a strength there, and what macOS sends to the actuator on each click still needs a trace. I'm setting that up next.

One thing the read does show: 0x21 reads 01, and 01 is what the driver writes to 0x21 to put the actuator in host-controlled mode. If that byte is the mode, macOS drives each click itself with output report 0x53, and 0x22/0x23 are not what it plays. The trace should settle that too.

Until then the J604 dts sets no apple,click-strength (its actuator node stays empty), so the driver leaves the firmware's 0x23/0x13 alone. Those are also what macOS's reports show at Medium, and I don't want a value in the dts without a source for it.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Nothing like this is on 110861f: hid-apple-mtp-haptic.c is unchanged since this branch's base. Both commits apply cleanly on 110861f. The net diff now has the per-device click_strength sysfs attribute and no module parameter, as the review asked. @IronsideXXVI, please squash the two commits so the module-parameter version is not in the history, and update the PR body, which still describes the module parameter. The J604 values can then follow as a device tree change.

Build check of 110861f plus this change (arm64, LLVM=1, Image, dtbs and every directory it touches, Fedora config plus asahi.config): builds, no warnings in the files it touches.

The click strength of a device-controlled actuator comes from the device
tree (apple,click-strength), and a machine without that property keeps
the firmware's faint boot strength. Finding the right value for a new
machine means rebuilding the device tree and rebooting for every try.

Add a click_strength attribute on the actuator's HID device, read and
written as <press>,<release>. A value is written to the actuator at once
and again at every resume, over the device tree's values. Each half is
parsed with kstrtou8(), so a value out of range or with trailing
characters is refused, and a write that does not reach the actuator
returns the error. 0,0, the default, means that no strength is set here:
with no device tree value and nothing set, the driver does not read the
actuator at all, as before; a strength set and then cleared goes back to
the firmware's boot strength, saved at the first read.

The setting and the state behind it (the boot strengths and the lock
that serialises the probe, resume and sysfs writes) live in each
actuator's drvdata, so a second actuator gets a setting of its own.

Signed-off-by: Dylan Ironside <[email protected]>
@IronsideXXVI
IronsideXXVI force-pushed the j604-mtp-haptic-click-param branch from 361092b to 5fb6397 Compare November 23, 2026 17:47
@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

@RyanTheTide thanks, both are done on 5fb6397:

  1. Squash. The two commits are now one. Its tree is the same as the old head 361092b (git diff 361092b2 5fb6397a is empty), so the module-parameter version is no longer in the history. host-tests passes on this head.
  2. Body. Updated. It now describes the per-device click_strength sysfs attribute and says there is no module parameter.

As the body says, the J604 values will follow as a device tree change once they're found. The sysfs version has not been booted on the J604 yet, and I'll add that row here when it has.

@RyanTheTide

Copy link
Copy Markdown
Contributor

@IronsideXXVI checking open drafts today. To come out of draft, this still needs:

  • It conflicts with main. Merge main in or rebase (no force push needed: a merge commit is fine).
  • Then a test run at the final head on a Mac with the hardware it touches, and mark it ready for review.

If it's no longer needed, say so here and we'll close it. Otherwise it stays open as a draft until these are done.

This branch has not been deployed

No deployments
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