Repository navigation
HID: apple-mtp-haptic: let the click strength be set at run time - #1959
IronsideXXVI wants to merge 1 commit into
Conversation
|
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. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
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_actuatorandapple_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 intounsigned int.%umatches the type; or usekstrtou8()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-strengthwith a source; the sysfs knob then only moves a user away from it.
|
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. |
|
Pushed f5b6fff on top. The click_strength module parameter is gone:
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. |
|
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):
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 Until then the J604 dts sets no |
f5b6fff to
361092b
Compare
|
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]>
361092b to
5fb6397
Compare
|
@RyanTheTide thanks, both are done on 5fb6397:
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. |
|
@IronsideXXVI checking open drafts today. To come out of draft, this still needs:
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. |
What: Add a
click_strengthsysfs 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'sapple,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 insysfs-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 ofintegration/aurorafc05050, 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_strengthattribute on the actuator's HID device, read and written as<press>,<release>(1-255 each; documented inDocumentation/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 withkstrtou8(), 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:
apple,click-strengthyet), 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.Checked on top of
integration/aurorafc05050: