1e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary/*
2e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary * Eee PC WMI hotkey driver
3e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary *
4e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary * Copyright(C) 2010 Intel Corporation.
557ab7dae27fae6a492ec968dc543106685adcad5Corentin Chary * Copyright(C) 2010-2011 Corentin Chary <corentin.chary@gmail.com>
6e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary *
7e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary * Portions based on wistron_btns.c:
8e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary * Copyright (C) 2005 Miloslav Trmac <mitr@volny.cz>
9e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary * Copyright (C) 2005 Bernhard Rosenkraenzer <bero@arklinux.org>
10e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary * Copyright (C) 2005 Dmitry Torokhov <dtor@mail.ru>
11e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary *
12e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary *  This program is free software; you can redistribute it and/or modify
13e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary *  it under the terms of the GNU General Public License as published by
14e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary *  the Free Software Foundation; either version 2 of the License, or
15e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary *  (at your option) any later version.
16e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary *
17e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary *  This program is distributed in the hope that it will be useful,
18e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary *  but WITHOUT ANY WARRANTY; without even the implied warranty of
19e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary *  GNU General Public License for more details.
21e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary *
22e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary *  You should have received a copy of the GNU General Public License
23e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary *  along with this program; if not, write to the Free Software
24e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary */
26e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary
27e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
28e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary
29e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary#include <linux/kernel.h>
30e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary#include <linux/module.h>
31e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary#include <linux/init.h>
32e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary#include <linux/input.h>
33e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary#include <linux/input/sparse-keymap.h>
34e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary#include <linux/dmi.h>
356e0044bedc1fc94a61cc32fa25dcab9a4e4a9218AceLan Kao#include <linux/fb.h>
36e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary#include <acpi/acpi_bus.h>
37e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary
38e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary#include "asus-wmi.h"
39e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary
40e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary#define	EEEPC_WMI_FILE	"eeepc-wmi"
41e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary
42e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin CharyMODULE_AUTHOR("Corentin Chary <corentincj@iksaif.net>");
43e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin CharyMODULE_DESCRIPTION("Eee PC WMI Hotkey Driver");
44e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin CharyMODULE_LICENSE("GPL");
45e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary
46e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary#define EEEPC_ACPI_HID		"ASUS010" /* old _HID used in eeepc-laptop */
47e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary
48e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary#define EEEPC_WMI_EVENT_GUID	"ABBC0F72-8EA1-11D1-00A0-C90629100000"
49e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary
50e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin CharyMODULE_ALIAS("wmi:"EEEPC_WMI_EVENT_GUID);
51e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary
52e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Charystatic bool hotplug_wireless;
53e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary
54e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Charymodule_param(hotplug_wireless, bool, 0444);
55e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin CharyMODULE_PARM_DESC(hotplug_wireless,
56e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary		 "Enable hotplug for wireless device. "
57e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary		 "If your laptop needs that, please report to "
58e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary		 "acpi4asus-user@lists.sourceforge.net.");
59e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary
606ae8b807371ba8d5b42648721c528582295136f7Seth Forshee/* Values for T101MT "Home" key */
616ae8b807371ba8d5b42648721c528582295136f7Seth Forshee#define HOME_PRESS	0xe4
626ae8b807371ba8d5b42648721c528582295136f7Seth Forshee#define HOME_HOLD	0xea
636ae8b807371ba8d5b42648721c528582295136f7Seth Forshee#define HOME_RELEASE	0xe5
646ae8b807371ba8d5b42648721c528582295136f7Seth Forshee
65e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Charystatic const struct key_entry eeepc_wmi_keymap[] = {
66e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary	/* Sleep already handled via generic ACPI code */
67e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary	{ KE_KEY, 0x30, { KEY_VOLUMEUP } },
68e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary	{ KE_KEY, 0x31, { KEY_VOLUMEDOWN } },
69e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary	{ KE_KEY, 0x32, { KEY_MUTE } },
70e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary	{ KE_KEY, 0x5c, { KEY_F15 } }, /* Power Gear key */
71e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary	{ KE_KEY, 0x5d, { KEY_WLAN } },
723b3e73f7d879f914f25605f74a71c2dad34bc329Keng-Yu Lin	{ KE_KEY, 0x6b, { KEY_TOUCHPAD_TOGGLE } }, /* Toggle Touchpad */
73e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary	{ KE_KEY, 0x82, { KEY_CAMERA } },
745f8540094d23b8886d671ff1faf875b698e2f299Corentin Chary	{ KE_KEY, 0x83, { KEY_CAMERA_ZOOMIN } },
75e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary	{ KE_KEY, 0x88, { KEY_WLAN } },
769481472559b3ecd366390786628c2fb211d1477bCorentin Chary	{ KE_KEY, 0xbd, { KEY_CAMERA } },
77e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary	{ KE_KEY, 0xcc, { KEY_SWITCHVIDEOMODE } },
78e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary	{ KE_KEY, 0xe0, { KEY_PROG1 } }, /* Task Manager */
79e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary	{ KE_KEY, 0xe1, { KEY_F14 } }, /* Change Resolution */
806ae8b807371ba8d5b42648721c528582295136f7Seth Forshee	{ KE_KEY, HOME_PRESS, { KEY_CONFIG } }, /* Home/Express gate key */
819481472559b3ecd366390786628c2fb211d1477bCorentin Chary	{ KE_KEY, 0xe8, { KEY_SCREENLOCK } },
82e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary	{ KE_KEY, 0xe9, { KEY_BRIGHTNESS_ZERO } },
835f8540094d23b8886d671ff1faf875b698e2f299Corentin Chary	{ KE_KEY, 0xeb, { KEY_CAMERA_ZOOMOUT } },
845f8540094d23b8886d671ff1faf875b698e2f299Corentin Chary	{ KE_KEY, 0xec, { KEY_CAMERA_UP } },
855f8540094d23b8886d671ff1faf875b698e2f299Corentin Chary	{ KE_KEY, 0xed, { KEY_CAMERA_DOWN } },
865f8540094d23b8886d671ff1faf875b698e2f299Corentin Chary	{ KE_KEY, 0xee, { KEY_CAMERA_LEFT } },
875f8540094d23b8886d671ff1faf875b698e2f299Corentin Chary	{ KE_KEY, 0xef, { KEY_CAMERA_RIGHT } },
88eb649a818abab4b0a8bb8b00d174ad9acf0a8a5aChih-Wei Huang	{ KE_KEY, 0xf3, { KEY_MENU } },
89eb649a818abab4b0a8bb8b00d174ad9acf0a8a5aChih-Wei Huang	{ KE_KEY, 0xf5, { KEY_HOMEPAGE } },
90eb649a818abab4b0a8bb8b00d174ad9acf0a8a5aChih-Wei Huang	{ KE_KEY, 0xf6, { KEY_ESC } },
91e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary	{ KE_END, 0},
92e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary};
93e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary
94c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kaostatic struct quirk_entry quirk_asus_unknown = {
95c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao};
96c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao
97c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kaostatic struct quirk_entry quirk_asus_1000h = {
98c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao	.hotplug_wireless = true,
99c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao};
100c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao
1016e0044bedc1fc94a61cc32fa25dcab9a4e4a9218AceLan Kaostatic struct quirk_entry quirk_asus_et2012_type1 = {
1026e0044bedc1fc94a61cc32fa25dcab9a4e4a9218AceLan Kao	.store_backlight_power = true,
1036e0044bedc1fc94a61cc32fa25dcab9a4e4a9218AceLan Kao};
1046e0044bedc1fc94a61cc32fa25dcab9a4e4a9218AceLan Kao
105c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kaostatic struct quirk_entry quirk_asus_et2012_type3 = {
106c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao	.scalar_panel_brightness = true,
1076e0044bedc1fc94a61cc32fa25dcab9a4e4a9218AceLan Kao	.store_backlight_power = true,
108c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao};
109c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao
110c55d995dd3cebffdeb2b7eff8acc813c56d62c97Corentin Charystatic struct quirk_entry *quirks;
111c55d995dd3cebffdeb2b7eff8acc813c56d62c97Corentin Chary
1127a61d0207465e41b7dbe3a25f628ddef24572c6fCorentin Charystatic void et2012_quirks(void)
1137a61d0207465e41b7dbe3a25f628ddef24572c6fCorentin Chary{
1147a61d0207465e41b7dbe3a25f628ddef24572c6fCorentin Chary	const struct dmi_device *dev = NULL;
1157a61d0207465e41b7dbe3a25f628ddef24572c6fCorentin Chary	char oemstring[30];
1167a61d0207465e41b7dbe3a25f628ddef24572c6fCorentin Chary
1177a61d0207465e41b7dbe3a25f628ddef24572c6fCorentin Chary	while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) {
1187a61d0207465e41b7dbe3a25f628ddef24572c6fCorentin Chary		if (sscanf(dev->name, "AEMS%24c", oemstring) == 1) {
1197a61d0207465e41b7dbe3a25f628ddef24572c6fCorentin Chary			if (oemstring[18] == '1')
1207a61d0207465e41b7dbe3a25f628ddef24572c6fCorentin Chary				quirks = &quirk_asus_et2012_type1;
1217a61d0207465e41b7dbe3a25f628ddef24572c6fCorentin Chary			else if (oemstring[18] == '3')
1227a61d0207465e41b7dbe3a25f628ddef24572c6fCorentin Chary				quirks = &quirk_asus_et2012_type3;
1237a61d0207465e41b7dbe3a25f628ddef24572c6fCorentin Chary			break;
1247a61d0207465e41b7dbe3a25f628ddef24572c6fCorentin Chary		}
1257a61d0207465e41b7dbe3a25f628ddef24572c6fCorentin Chary	}
1267a61d0207465e41b7dbe3a25f628ddef24572c6fCorentin Chary}
1277a61d0207465e41b7dbe3a25f628ddef24572c6fCorentin Chary
128c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kaostatic int dmi_matched(const struct dmi_system_id *dmi)
129c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao{
130c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao	char *model;
1317a61d0207465e41b7dbe3a25f628ddef24572c6fCorentin Chary
132c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao	quirks = dmi->driver_data;
133c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao
134c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao	model = (char *)dmi->matches[1].substr;
1357a61d0207465e41b7dbe3a25f628ddef24572c6fCorentin Chary	if (unlikely(strncmp(model, "ET2012", 6) == 0))
1367a61d0207465e41b7dbe3a25f628ddef24572c6fCorentin Chary		et2012_quirks();
1377a61d0207465e41b7dbe3a25f628ddef24572c6fCorentin Chary
138c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao	return 1;
139c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao}
140c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao
141c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kaostatic struct dmi_system_id asus_quirks[] = {
142c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao	{
143c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao		.callback = dmi_matched,
144c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao		.ident = "ASUSTeK Computer INC. 1000H",
145c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao		.matches = {
146c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer INC."),
147c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao			DMI_MATCH(DMI_PRODUCT_NAME, "1000H"),
148c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao		},
149c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao		.driver_data = &quirk_asus_1000h,
150c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao	},
151c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao	{
152c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao		.callback = dmi_matched,
153c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao		.ident = "ASUSTeK Computer INC. ET2012E/I",
154c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao		.matches = {
155c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer INC."),
156c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao			DMI_MATCH(DMI_PRODUCT_NAME, "ET2012"),
157c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao		},
158c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao		.driver_data = &quirk_asus_unknown,
159c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao	},
160c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao	{},
161c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao};
162c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao
1636ae8b807371ba8d5b42648721c528582295136f7Seth Forsheestatic void eeepc_wmi_key_filter(struct asus_wmi_driver *asus_wmi, int *code,
1646ae8b807371ba8d5b42648721c528582295136f7Seth Forshee				 unsigned int *value, bool *autorelease)
1656ae8b807371ba8d5b42648721c528582295136f7Seth Forshee{
1666ae8b807371ba8d5b42648721c528582295136f7Seth Forshee	switch (*code) {
1676ae8b807371ba8d5b42648721c528582295136f7Seth Forshee	case HOME_PRESS:
1686ae8b807371ba8d5b42648721c528582295136f7Seth Forshee		*value = 1;
1696ae8b807371ba8d5b42648721c528582295136f7Seth Forshee		*autorelease = 0;
1706ae8b807371ba8d5b42648721c528582295136f7Seth Forshee		break;
1716ae8b807371ba8d5b42648721c528582295136f7Seth Forshee	case HOME_HOLD:
1726ae8b807371ba8d5b42648721c528582295136f7Seth Forshee		*code = ASUS_WMI_KEY_IGNORE;
1736ae8b807371ba8d5b42648721c528582295136f7Seth Forshee		break;
1746ae8b807371ba8d5b42648721c528582295136f7Seth Forshee	case HOME_RELEASE:
1756ae8b807371ba8d5b42648721c528582295136f7Seth Forshee		*code = HOME_PRESS;
1766ae8b807371ba8d5b42648721c528582295136f7Seth Forshee		*value = 0;
1776ae8b807371ba8d5b42648721c528582295136f7Seth Forshee		*autorelease = 0;
1786ae8b807371ba8d5b42648721c528582295136f7Seth Forshee		break;
1796ae8b807371ba8d5b42648721c528582295136f7Seth Forshee	}
1806ae8b807371ba8d5b42648721c528582295136f7Seth Forshee}
1816ae8b807371ba8d5b42648721c528582295136f7Seth Forshee
182e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Charystatic acpi_status eeepc_wmi_parse_device(acpi_handle handle, u32 level,
183e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary						 void *context, void **retval)
184e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary{
18522441ffeed17b94b28bd7c609f2cdb24d11e81f3Joe Perches	pr_warn("Found legacy ATKD device (%s)\n", EEEPC_ACPI_HID);
186e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary	*(bool *)context = true;
187e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary	return AE_CTRL_TERMINATE;
188e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary}
189e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary
190e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Charystatic int eeepc_wmi_check_atkd(void)
191e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary{
192e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary	acpi_status status;
193e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary	bool found = false;
194e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary
195e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary	status = acpi_get_devices(EEEPC_ACPI_HID, eeepc_wmi_parse_device,
196e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary				  &found, NULL);
197e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary
198e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary	if (ACPI_FAILURE(status) || !found)
199e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary		return 0;
200e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary	return -1;
201e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary}
202e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary
203e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Charystatic int eeepc_wmi_probe(struct platform_device *pdev)
204e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary{
205e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary	if (eeepc_wmi_check_atkd()) {
20622441ffeed17b94b28bd7c609f2cdb24d11e81f3Joe Perches		pr_warn("WMI device present, but legacy ATKD device is also "
20722441ffeed17b94b28bd7c609f2cdb24d11e81f3Joe Perches			"present and enabled\n");
20822441ffeed17b94b28bd7c609f2cdb24d11e81f3Joe Perches		pr_warn("You probably booted with acpi_osi=\"Linux\" or "
20922441ffeed17b94b28bd7c609f2cdb24d11e81f3Joe Perches			"acpi_osi=\"!Windows 2009\"\n");
21022441ffeed17b94b28bd7c609f2cdb24d11e81f3Joe Perches		pr_warn("Can't load eeepc-wmi, use default acpi_osi "
21122441ffeed17b94b28bd7c609f2cdb24d11e81f3Joe Perches			"(preferred) or eeepc-laptop\n");
212e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary		return -EBUSY;
213e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary	}
214e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary	return 0;
215e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary}
216e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary
217e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Charystatic void eeepc_wmi_quirks(struct asus_wmi_driver *driver)
218e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary{
219c55d995dd3cebffdeb2b7eff8acc813c56d62c97Corentin Chary	quirks = &quirk_asus_unknown;
220c55d995dd3cebffdeb2b7eff8acc813c56d62c97Corentin Chary	quirks->hotplug_wireless = hotplug_wireless;
221c55d995dd3cebffdeb2b7eff8acc813c56d62c97Corentin Chary
222c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao	dmi_check_system(asus_quirks);
223c55d995dd3cebffdeb2b7eff8acc813c56d62c97Corentin Chary
224c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao	driver->quirks = quirks;
225c55d995dd3cebffdeb2b7eff8acc813c56d62c97Corentin Chary	driver->quirks->wapf = -1;
226c55d995dd3cebffdeb2b7eff8acc813c56d62c97Corentin Chary	driver->panel_power = FB_BLANK_UNBLANK;
227e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary}
228e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary
229e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Charystatic struct asus_wmi_driver asus_wmi_driver = {
230e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary	.name = EEEPC_WMI_FILE,
231e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary	.owner = THIS_MODULE,
232e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary	.event_guid = EEEPC_WMI_EVENT_GUID,
233e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary	.keymap = eeepc_wmi_keymap,
234e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary	.input_name = "Eee PC WMI hotkeys",
235e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary	.input_phys = EEEPC_WMI_FILE "/input0",
2366ae8b807371ba8d5b42648721c528582295136f7Seth Forshee	.key_filter = eeepc_wmi_key_filter,
237e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary	.probe = eeepc_wmi_probe,
238c87992d1fa51a6a3d8f0e980ca4d2bdec7e78a17AceLan Kao	.detect_quirks = eeepc_wmi_quirks,
239e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary};
240e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary
241e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary
242e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Charystatic int __init eeepc_wmi_init(void)
243e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary{
244e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary	return asus_wmi_register_driver(&asus_wmi_driver);
245e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary}
246e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary
247e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Charystatic void __exit eeepc_wmi_exit(void)
248e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary{
249e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary	asus_wmi_unregister_driver(&asus_wmi_driver);
250e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary}
251e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Chary
252e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Charymodule_init(eeepc_wmi_init);
253e12e6d94db24e9050821965aa75c95e8d2c65f10Corentin Charymodule_exit(eeepc_wmi_exit);
254