asus-wmi: store backlight power status for AIO machine
[firefly-linux-kernel-4.4.55.git] / drivers / platform / x86 / eeepc-wmi.c
index 9f6e64302b457b04fb0871524e9ac906af34399f..9f8ccf9f590d96b106e8c8bb83be08246a471c16 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/input.h>
 #include <linux/input/sparse-keymap.h>
 #include <linux/dmi.h>
+#include <linux/fb.h>
 #include <acpi/acpi_bus.h>
 
 #include "asus-wmi.h"
@@ -48,6 +49,7 @@ MODULE_LICENSE("GPL");
 
 MODULE_ALIAS("wmi:"EEEPC_WMI_EVENT_GUID);
 
+static struct quirk_entry *quirks;
 static bool hotplug_wireless;
 
 module_param(hotplug_wireless, bool, 0444);
@@ -84,9 +86,73 @@ static const struct key_entry eeepc_wmi_keymap[] = {
        { KE_KEY, 0xed, { KEY_CAMERA_DOWN } },
        { KE_KEY, 0xee, { KEY_CAMERA_LEFT } },
        { KE_KEY, 0xef, { KEY_CAMERA_RIGHT } },
+       { KE_KEY, 0xf3, { KEY_MENU } },
+       { KE_KEY, 0xf5, { KEY_HOMEPAGE } },
+       { KE_KEY, 0xf6, { KEY_ESC } },
        { KE_END, 0},
 };
 
+static struct quirk_entry quirk_asus_unknown = {
+};
+
+static struct quirk_entry quirk_asus_1000h = {
+       .hotplug_wireless = true,
+};
+
+static struct quirk_entry quirk_asus_et2012_type1 = {
+       .store_backlight_power = true,
+};
+
+static struct quirk_entry quirk_asus_et2012_type3 = {
+       .scalar_panel_brightness = true,
+       .store_backlight_power = true,
+};
+
+static int dmi_matched(const struct dmi_system_id *dmi)
+{
+       char *model;
+       quirks = dmi->driver_data;
+
+       model = (char *)dmi->matches[1].substr;
+       if (unlikely(strncmp(model, "ET2012", 6) == 0)) {
+               const struct dmi_device *dev = NULL;
+               char oemstring[30];
+               while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING,
+                                             NULL, dev))) {
+                       if (sscanf(dev->name, "AEMS%24c", oemstring) == 1) {
+                               if (oemstring[18] == '1')
+                                       quirks = &quirk_asus_et2012_type1;
+                               else if (oemstring[18] == '3')
+                                       quirks = &quirk_asus_et2012_type3;
+                               break;
+                       }
+               }
+       }
+       return 1;
+}
+
+static struct dmi_system_id asus_quirks[] = {
+       {
+               .callback = dmi_matched,
+               .ident = "ASUSTeK Computer INC. 1000H",
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer INC."),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "1000H"),
+               },
+               .driver_data = &quirk_asus_1000h,
+       },
+       {
+               .callback = dmi_matched,
+               .ident = "ASUSTeK Computer INC. ET2012E/I",
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer INC."),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "ET2012"),
+               },
+               .driver_data = &quirk_asus_unknown,
+       },
+       {},
+};
+
 static void eeepc_wmi_key_filter(struct asus_wmi_driver *asus_wmi, int *code,
                                 unsigned int *value, bool *autorelease)
 {
@@ -141,33 +207,14 @@ static int eeepc_wmi_probe(struct platform_device *pdev)
        return 0;
 }
 
-static void eeepc_dmi_check(struct asus_wmi_driver *driver)
-{
-       const char *model;
-
-       model = dmi_get_system_info(DMI_PRODUCT_NAME);
-       if (!model)
-               return;
-
-       /*
-        * Whitelist for wlan hotplug
-        *
-        * Asus 1000H needs the current hotplug code to handle
-        * Fn+F2 correctly. We may add other Asus here later, but
-        * it seems that most of the laptops supported by asus-wmi
-        * don't need to be on this list
-        */
-       if (strcmp(model, "1000H") == 0) {
-               driver->hotplug_wireless = true;
-               pr_info("wlan hotplug enabled\n");
-       }
-}
-
 static void eeepc_wmi_quirks(struct asus_wmi_driver *driver)
 {
-       driver->hotplug_wireless = hotplug_wireless;
        driver->wapf = -1;
-       eeepc_dmi_check(driver);
+       driver->panel_power = FB_BLANK_UNBLANK;
+       driver->quirks = &quirk_asus_unknown;
+       driver->quirks->hotplug_wireless = hotplug_wireless;
+       dmi_check_system(asus_quirks);
+       driver->quirks = quirks;
 }
 
 static struct asus_wmi_driver asus_wmi_driver = {
@@ -179,7 +226,7 @@ static struct asus_wmi_driver asus_wmi_driver = {
        .input_phys = EEEPC_WMI_FILE "/input0",
        .key_filter = eeepc_wmi_key_filter,
        .probe = eeepc_wmi_probe,
-       .quirks = eeepc_wmi_quirks,
+       .detect_quirks = eeepc_wmi_quirks,
 };