linux-surface / kernel

Linux kernel with modifications for Microsoft Surface devices.
Other
124 stars 34 forks source link

hid/multitouch: Add support for surface pro type cover tablet switch #119

Closed PJungkamp closed 2 years ago

PJungkamp commented 2 years ago

The Surface Pro Type Cover has several non standard HID usages in it's hid report descriptor. I noticed that, upon folding the typecover back, a vendor specfic range of 4 32 bit integer hid usages is transmitted. Only the first byte of the message seems to convey reliable information about the keyboard state.

0x22 => Normal (keys enabled) 0x33 => Folded back (keys disabled) 0x53 => Rotated left/right side up (keys disabled) 0x13 => Cover closed (keys disabled) 0x43 => Folded back and Tablet upside down (keys disabled) This list may not be exhaustive.

The tablet mode switch will be disabled for a value of 0x22 and enabled on any other value.

qzed commented 2 years ago

Code looks good to me. Couple of style issues though and missing punctuation in comments (small things, really). Can you run checkpatch (./scripts/checkpatch.pl --strict <patchfile> from kernel source root directory, use git format-patch -1 to get a patch) and address those remarks?

After that I think you could also try rebasing (needs a rebase due to the typecover backlight patch) and submitting it upstream.

PJungkamp commented 2 years ago

Should I rebase against a revision before the backlight patch was applied? I modified the code the backlight patch introduced since it fit the problem, so I depend on its presence. (I changed get_type_cover_backlight_field(...) to get_type_cover_field(...) since a field search is needed for both patches)

I'll correct the formatting within the next few days.

qzed commented 2 years ago

Should I rebase against a revision before the backlight patch was applied?

For upstreaming, yes. For the PR here I think it's better/easier if you keep it as-is.

PJungkamp commented 2 years ago

I've rebased onto 5.17-surface-devel and finally fixed the formatting issues. I'll open a pull request for the 5.17-surface-devel branch and close this one.