Restore reg_07 after setting the sample rate on Elan firmware 0x381f17 - #68
Open
arvedviehweger wants to merge 1 commit into
Open
arvedviehweger wants to merge 1 commit into
arvedviehweger wants to merge 1 commit into
Conversation
elantechSetupPS2 puts hardware version 4 touchpads into absolute mode by writing reg_07, and then sends a set sample rate command. On firmware 0x381f17 that command clears reg_07, so the touchpad drops back to relative mode before data reporting is even enabled. The driver still parses the stream as 6 byte v4 packets. Byte 0 of a standard relative packet always has bit 3 set, which is exactly what the non-CRC sanity check in elantechPacketCheckV4 rejects, so every packet is discarded as PACKET_UNKNOWN. The touchpad attaches and looks correct in IORegistry, but reports no motion and no clicks at all. Write reg_07 back after the sample rate command. Data reporting is moved into a separate request afterwards so the register write still happens while the touchpad is quiet. Linux fixes this the same way through a set_rate hook, see elantech_set_rate_restore_reg_07. Fixes: acidanthera/bugtracker#1220
Author
|
If anyone would like to give it a go here is the ZIP file attached to this comment which includes the kext. |
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes acidanthera/bugtracker#1220
Problem
On Elan hardware version 4 touchpads with firmware
0x381f17, the touchpad attaches and looks entirely healthy in IORegistry — correct logical/physical ranges,VoodooInputSupported, trackpad preferences applied — but it reports no motion and no clicks at all.elantechSetupPS2enables absolute mode by writingreg_07, and then sends a set sample rate command as part of the resolution/rate request:This firmware loses
reg_07on a set rate command, so absolute mode is gone before data reporting is even switched on.The driver keeps parsing the stream as 6 byte v4 packets. Since 6 is a multiple of the 3 byte relative packet size, the alignment stays stable and
packet[0]is always a real relative byte 0, which always has bit 3 set. That is precisely what the non-CRC branch of the sanity check inelantechPacketCheckV4rejects:Every packet is therefore discarded as
PACKET_UNKNOWNand no input ever reaches VoodooInput.For reference,
0x381f17resolves tocrc_enabled = 0(fw_version & 0x4000 == 0) andic_version = 8, so this is the branch that applies.Fix
Write
reg_07back after the sample rate command, gated on the affected firmware.Linux carries the same quirk for exactly this firmware, installing a
set_ratehook that rewrites the register after every rate change (elantech_set_rate_restore_reg_07indrivers/input/mouse/elantech.c):VoodooPS2 has no
set_rateindirection, and the only set rate call site is this one request, so the hook collapses into a single conditional write.kDP_Enableis moved out of that request and issued separately afterwards, so the register write still happens while the touchpad is quiet.elantechWriteRegsends its own multi-command PS/2 sequence, and running that against an already streaming touchpad risks interleaving with data packets.There was already a commented-out sketch of the Linux hook at this spot; it is replaced by the working implementation.
Scope
reg_07restore is gated oninfo.fw_version == 0x381f17. No other device executes it — short-circuit evaluation meanselantechWriteRegis not even called.elantechSetupPS2(start,kPS2M_resetTouchpad,setDevicePowerState) already calledsetTouchPadEnable(true)immediately afterwards, sokDP_Enablewas being sent twice before this change and still is — no change in that behaviour.elantechSetupPS2.Testing
Tested on an ASUS TP500LN (Elan v4, fw
381f17, bus 0), the same hardware as the linked issue. The touchpad went from completely unresponsive to fully working, including multi-finger gestures. Release build of all targets succeeds.Note that the unrelated
VoodooPS2Trackpad: Identify TouchPad command returned incorrect byte 2 (of 3): 0x04line in that issue is emitted by the Synaptics probe correctly rejecting a non-Synaptics device, and is unrelated to this bug.