platform/x86: intel-hid: Add alternative method to enable switches
authorElia Devito <eliadevito@gmail.com>
Fri, 4 Dec 2020 16:02:35 +0000 (17:02 +0100)
committerHans de Goede <hdegoede@redhat.com>
Mon, 7 Dec 2020 16:40:40 +0000 (17:40 +0100)
Some convertible have unreliable VGBS return, in these cases we enable
support when receiving the first event.

Signed-off-by: Elia Devito <eliadevito@gmail.com>
Link: https://lore.kernel.org/r/20201204160234.36832-1-elia@xvalue.it
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
drivers/platform/x86/intel-hid.c

index c69c2cc1e0798a724418b44f4876c7f92abd6257..66ccdc17a64dca686d622ace5d7c08f36a4525ff 100644 (file)
@@ -435,6 +435,19 @@ static void notify_handler(acpi_handle handle, u32 event, void *context)
        struct platform_device *device = context;
        struct intel_hid_priv *priv = dev_get_drvdata(&device->dev);
        unsigned long long ev_index;
+       int err;
+
+       /*
+        * Some convertible have unreliable VGBS return which could cause incorrect
+        * SW_TABLET_MODE report, in these cases we enable support when receiving
+        * the first event instead of during driver setup.
+        */
+       if (!priv->switches && (event == 0xcc || event == 0xcd)) {
+               dev_info(&device->dev, "switch event received, enable switches supports\n");
+               err = intel_hid_switches_setup(device);
+               if (err)
+                       pr_err("Failed to setup Intel HID switches\n");
+       }
 
        if (priv->wakeup_mode) {
                /*