Bug 101100 - Also detect when the Lid Switch is wrong if there are no cover attached (Surface 3 infamous issues)
Summary: Also detect when the Lid Switch is wrong if there are no cover attached (Surf...
Status: RESOLVED WONTFIX
Alias: None
Product: Wayland
Classification: Unclassified
Component: libinput (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Peter Hutterer
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-19 12:25 UTC by Benjamin Tissoires
Modified: 2017-06-02 03:12 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Benjamin Tissoires 2017-05-19 12:25:39 UTC
On the Surface 3, we have some very nice features: if there is no cover attached, the Lid Switch input node might report that it is closed.

Well, obviously there is no reason for it to believe such thing, but still.

libinput should detect when there is a Lid Switch but no internal keyboard is attached. In this situation, it should force the Lid Switch state to "open".
Comment 1 Peter Hutterer 2017-05-22 06:06:35 UTC
hmm, the only way to do this 'reliably' would be to have a timer on init that calls back at some point in the future and checks if we have seen the keyboard yet. We can't rely on the device order or any sort of timing during startup but the timer doesn't fill me with confidence either. Is this a real problem?

What is fixable is to force the state open whenever the paired keyboard is removed.
Comment 2 Benjamin Tissoires 2017-05-22 16:58:57 UTC
I just realize we have a conflict here:
- on boot, the LID switch state might be wrong if there are no cover attached (reported as closed)
- when closing the LID, the keyboard gets detached, meaning if we send the open event, we might wake up the tablet
Comment 3 Peter Hutterer 2017-05-23 03:01:18 UTC
hmm, we can't really detect 'boot' versus 'suspend', or at least not reliably enough. There is a libinput_resume() and libinput_suspend() but they're not really guarantees because we may create a new context instead. And e.g. the xorg driver doesn't use those at all.
Comment 4 Benjamin Tissoires 2017-05-24 03:57:00 UTC
Well, right, we might not be able to detect this situation reliably.

One thing to take into account is that the cover gets detached at the USB level when it's closed. In the same fashion, there is a signal within the kernel that notifies the touchscreen that the cover is closed.

So that means that if we ever receive any event from any internal device (touchscreen, touchchpad or keyboard), then the lid is opened.

I don't think we can get around this particular issue reliably, so let's close it and try to enhance the heuristic.

(Note that the Surface 3 has a kernel module with a reliable LID switch, surface3-wmi, but this bug was to fix all the line of similar laptops that tend to have broken LID switch).
Comment 5 Peter Hutterer 2017-05-24 04:24:06 UTC
We could add detection of touches, but I'm not 100% that works reliably either. We likely get ghost touches when the lid is closed (I guess).

Either way, closing this for now, it's quite niche, can't be done reliably and there's a kernel module for at least the S3 already. That's good enough for me to move this bug off my todo list :)
Comment 6 Benjamin Tissoires 2017-05-24 08:46:57 UTC
(In reply to Peter Hutterer from comment #5)
> We could add detection of touches, but I'm not 100% that works reliably
> either. We likely get ghost touches when the lid is closed (I guess).

Actually, the idea was to prevent the kernel from emitting touches when the LID is closed (given it knows reliably this information in this particular state).

Still, RESOLVED works for me :)
Comment 7 Peter Hutterer 2017-06-02 03:12:18 UTC
oops, I accidentally pushed the commit as d35d122eb1 and the revert for it as 0c428d6b7. At least we have the source if we need it in the future


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.