aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor@chromium.org>2019-09-13 15:03:16 -0700
committerJiri Kosina <jkosina@suse.cz>2019-10-01 16:13:49 +0200
commit79085c7dd24b7acd546f5b283d3f2319a9edbbd8 (patch)
treedcc26f651d33fb96a576e28aaca1b292d519820b /drivers/hid
parentHID: google: whiskers: more robust tablet mode detection (diff)
downloadlinux-dev-79085c7dd24b7acd546f5b283d3f2319a9edbbd8.tar.xz
linux-dev-79085c7dd24b7acd546f5b283d3f2319a9edbbd8.zip
HID: google: whiskers: signal tablet mode switch on disconnect
Currently, the tablet mode switch that takes two signals as its input: base attached switch from the EC and some GMR signal from whiskers when it's folded over. This tablet mode switch is then sent to Chrome, which changes the UI. However, there are some units which have a lot of leakage on the ADC pins that the EC uses to determine whether or not a base is attached. This can result in the base being physically detached, but the EC thinking that it's still attached. The user would then be stuck in laptop mode and wouldn't be able to rotate their display. To work around this let's send "tablet mode" signal when we remove HID interface, which normally happens when we physically disconnect whiskers. Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid')
-rw-r--r--drivers/hid/hid-google-hammer.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/drivers/hid/hid-google-hammer.c b/drivers/hid/hid-google-hammer.c
index 4f64f93ddfcb..3dc6116c8f76 100644
--- a/drivers/hid/hid-google-hammer.c
+++ b/drivers/hid/hid-google-hammer.c
@@ -498,11 +498,33 @@ static int hammer_probe(struct hid_device *hdev,
static void hammer_remove(struct hid_device *hdev)
{
+ unsigned long flags;
+
if (hdev->product == USB_DEVICE_ID_GOOGLE_WHISKERS &&
- hammer_is_keyboard_interface(hdev))
+ hammer_is_keyboard_interface(hdev)) {
hid_hw_close(hdev);
+ /*
+ * If we are disconnecting then most likely Whiskers is
+ * being removed. Even if it is not removed, without proper
+ * keyboard we should not stay in clamshell mode.
+ *
+ * The reason for doing it here and not waiting for signal
+ * from EC, is that on some devices there are high leakage
+ * on Whiskers pins and we do not detect disconnect reliably,
+ * resulting in devices being stuck in clamshell mode.
+ */
+ spin_lock_irqsave(&cbas_ec_lock, flags);
+ if (cbas_ec.input && cbas_ec.base_present) {
+ input_report_switch(cbas_ec.input, SW_TABLET_MODE, 1);
+ input_sync(cbas_ec.input);
+ }
+ cbas_ec.base_present = false;
+ spin_unlock_irqrestore(&cbas_ec_lock, flags);
+ }
+
hammer_unregister_leds(hdev);
+
hid_hw_stop(hdev);
}