Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetoot...
[cascardo/linux.git] / drivers / platform / x86 / asus-nb-wmi.c
index adecc1c..26e4cbc 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/input/sparse-keymap.h>
 #include <linux/fb.h>
 #include <linux/dmi.h>
+#include <linux/i8042.h>
 
 #include "asus-wmi.h"
 
@@ -55,10 +56,34 @@ MODULE_PARM_DESC(wapf, "WAPF value");
 
 static struct quirk_entry *quirks;
 
+static bool asus_q500a_i8042_filter(unsigned char data, unsigned char str,
+                             struct serio *port)
+{
+       static bool extended;
+       bool ret = false;
+
+       if (str & I8042_STR_AUXDATA)
+               return false;
+
+       if (unlikely(data == 0xe1)) {
+               extended = true;
+               ret = true;
+       } else if (unlikely(extended)) {
+               extended = false;
+               ret = true;
+       }
+
+       return ret;
+}
+
 static struct quirk_entry quirk_asus_unknown = {
        .wapf = 0,
 };
 
+static struct quirk_entry quirk_asus_q500a = {
+       .i8042_filter = asus_q500a_i8042_filter,
+};
+
 /*
  * For those machines that need software to control bt/wifi status
  * and can't adjust brightness through ACPI interface
@@ -87,6 +112,10 @@ static struct quirk_entry quirk_no_rfkill_wapf4 = {
        .no_rfkill = true,
 };
 
+static struct quirk_entry quirk_asus_ux303ub = {
+       .wmi_backlight_native = true,
+};
+
 static int dmi_matched(const struct dmi_system_id *dmi)
 {
        quirks = dmi->driver_data;
@@ -94,6 +123,15 @@ static int dmi_matched(const struct dmi_system_id *dmi)
 }
 
 static const struct dmi_system_id asus_quirks[] = {
+       {
+               .callback = dmi_matched,
+               .ident = "ASUSTeK COMPUTER INC. Q500A",
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "Q500A"),
+               },
+               .driver_data = &quirk_asus_q500a,
+       },
        {
                .callback = dmi_matched,
                .ident = "ASUSTeK COMPUTER INC. U32U",
@@ -351,11 +389,22 @@ static const struct dmi_system_id asus_quirks[] = {
                },
                .driver_data = &quirk_no_rfkill,
        },
+       {
+               .callback = dmi_matched,
+               .ident = "ASUSTeK COMPUTER INC. UX303UB",
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "UX303UB"),
+               },
+               .driver_data = &quirk_asus_ux303ub,
+       },
        {},
 };
 
 static void asus_nb_wmi_quirks(struct asus_wmi_driver *driver)
 {
+       int ret;
+
        quirks = &quirk_asus_unknown;
        dmi_check_system(asus_quirks);
 
@@ -367,6 +416,15 @@ static void asus_nb_wmi_quirks(struct asus_wmi_driver *driver)
                quirks->wapf = wapf;
        else
                wapf = quirks->wapf;
+
+       if (quirks->i8042_filter) {
+               ret = i8042_install_filter(quirks->i8042_filter);
+               if (ret) {
+                       pr_warn("Unable to install key filter\n");
+                       return;
+               }
+               pr_info("Using i8042 filter function for receiving events\n");
+       }
 }
 
 static const struct key_entry asus_nb_wmi_keymap[] = {