Linux Audio

Check our new training course

Loading...
v3.5.6
 
  1/*
  2 * Eee PC WMI hotkey driver
  3 *
  4 * Copyright(C) 2010 Intel Corporation.
  5 * Copyright(C) 2010-2011 Corentin Chary <corentin.chary@gmail.com>
  6 *
  7 * Portions based on wistron_btns.c:
  8 * Copyright (C) 2005 Miloslav Trmac <mitr@volny.cz>
  9 * Copyright (C) 2005 Bernhard Rosenkraenzer <bero@arklinux.org>
 10 * Copyright (C) 2005 Dmitry Torokhov <dtor@mail.ru>
 11 *
 12 *  This program is free software; you can redistribute it and/or modify
 13 *  it under the terms of the GNU General Public License as published by
 14 *  the Free Software Foundation; either version 2 of the License, or
 15 *  (at your option) any later version.
 16 *
 17 *  This program is distributed in the hope that it will be useful,
 18 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 19 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 20 *  GNU General Public License for more details.
 21 *
 22 *  You should have received a copy of the GNU General Public License
 23 *  along with this program; if not, write to the Free Software
 24 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 25 */
 26
 27#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 28
 29#include <linux/kernel.h>
 30#include <linux/module.h>
 31#include <linux/init.h>
 32#include <linux/input.h>
 33#include <linux/input/sparse-keymap.h>
 34#include <linux/dmi.h>
 35#include <linux/fb.h>
 36#include <acpi/acpi_bus.h>
 37
 38#include "asus-wmi.h"
 39
 40#define	EEEPC_WMI_FILE	"eeepc-wmi"
 41
 42MODULE_AUTHOR("Corentin Chary <corentincj@iksaif.net>");
 43MODULE_DESCRIPTION("Eee PC WMI Hotkey Driver");
 44MODULE_LICENSE("GPL");
 45
 46#define EEEPC_ACPI_HID		"ASUS010" /* old _HID used in eeepc-laptop */
 47
 48#define EEEPC_WMI_EVENT_GUID	"ABBC0F72-8EA1-11D1-00A0-C90629100000"
 49
 50MODULE_ALIAS("wmi:"EEEPC_WMI_EVENT_GUID);
 51
 52static bool hotplug_wireless;
 53
 54module_param(hotplug_wireless, bool, 0444);
 55MODULE_PARM_DESC(hotplug_wireless,
 56		 "Enable hotplug for wireless device. "
 57		 "If your laptop needs that, please report to "
 58		 "acpi4asus-user@lists.sourceforge.net.");
 59
 60/* Values for T101MT "Home" key */
 61#define HOME_PRESS	0xe4
 62#define HOME_HOLD	0xea
 63#define HOME_RELEASE	0xe5
 64
 65static const struct key_entry eeepc_wmi_keymap[] = {
 
 
 66	/* Sleep already handled via generic ACPI code */
 67	{ KE_KEY, 0x30, { KEY_VOLUMEUP } },
 68	{ KE_KEY, 0x31, { KEY_VOLUMEDOWN } },
 69	{ KE_KEY, 0x32, { KEY_MUTE } },
 70	{ KE_KEY, 0x5c, { KEY_F15 } }, /* Power Gear key */
 71	{ KE_KEY, 0x5d, { KEY_WLAN } },
 72	{ KE_KEY, 0x6b, { KEY_TOUCHPAD_TOGGLE } }, /* Toggle Touchpad */
 73	{ KE_KEY, 0x82, { KEY_CAMERA } },
 74	{ KE_KEY, 0x83, { KEY_CAMERA_ZOOMIN } },
 75	{ KE_KEY, 0x88, { KEY_WLAN } },
 76	{ KE_KEY, 0xbd, { KEY_CAMERA } },
 77	{ KE_KEY, 0xcc, { KEY_SWITCHVIDEOMODE } },
 78	{ KE_KEY, 0xe0, { KEY_PROG1 } }, /* Task Manager */
 79	{ KE_KEY, 0xe1, { KEY_F14 } }, /* Change Resolution */
 80	{ KE_KEY, HOME_PRESS, { KEY_CONFIG } }, /* Home/Express gate key */
 81	{ KE_KEY, 0xe8, { KEY_SCREENLOCK } },
 82	{ KE_KEY, 0xe9, { KEY_BRIGHTNESS_ZERO } },
 83	{ KE_KEY, 0xeb, { KEY_CAMERA_ZOOMOUT } },
 84	{ KE_KEY, 0xec, { KEY_CAMERA_UP } },
 85	{ KE_KEY, 0xed, { KEY_CAMERA_DOWN } },
 86	{ KE_KEY, 0xee, { KEY_CAMERA_LEFT } },
 87	{ KE_KEY, 0xef, { KEY_CAMERA_RIGHT } },
 88	{ KE_KEY, 0xf3, { KEY_MENU } },
 89	{ KE_KEY, 0xf5, { KEY_HOMEPAGE } },
 90	{ KE_KEY, 0xf6, { KEY_ESC } },
 91	{ KE_END, 0},
 92};
 93
 94static struct quirk_entry quirk_asus_unknown = {
 95};
 96
 97static struct quirk_entry quirk_asus_1000h = {
 98	.hotplug_wireless = true,
 99};
100
101static struct quirk_entry quirk_asus_et2012_type1 = {
102	.store_backlight_power = true,
103};
104
105static struct quirk_entry quirk_asus_et2012_type3 = {
106	.scalar_panel_brightness = true,
107	.store_backlight_power = true,
108};
109
 
 
 
 
 
110static struct quirk_entry *quirks;
111
112static void et2012_quirks(void)
113{
114	const struct dmi_device *dev = NULL;
115	char oemstring[30];
116
117	while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) {
118		if (sscanf(dev->name, "AEMS%24c", oemstring) == 1) {
119			if (oemstring[18] == '1')
120				quirks = &quirk_asus_et2012_type1;
121			else if (oemstring[18] == '3')
122				quirks = &quirk_asus_et2012_type3;
123			break;
124		}
125	}
126}
127
128static int dmi_matched(const struct dmi_system_id *dmi)
129{
130	char *model;
131
132	quirks = dmi->driver_data;
133
134	model = (char *)dmi->matches[1].substr;
135	if (unlikely(strncmp(model, "ET2012", 6) == 0))
136		et2012_quirks();
137
138	return 1;
139}
140
141static struct dmi_system_id asus_quirks[] = {
142	{
143		.callback = dmi_matched,
144		.ident = "ASUSTeK Computer INC. 1000H",
145		.matches = {
146			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer INC."),
147			DMI_MATCH(DMI_PRODUCT_NAME, "1000H"),
148		},
149		.driver_data = &quirk_asus_1000h,
150	},
151	{
152		.callback = dmi_matched,
153		.ident = "ASUSTeK Computer INC. ET2012E/I",
154		.matches = {
155			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer INC."),
156			DMI_MATCH(DMI_PRODUCT_NAME, "ET2012"),
157		},
158		.driver_data = &quirk_asus_unknown,
159	},
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160	{},
161};
162
163static void eeepc_wmi_key_filter(struct asus_wmi_driver *asus_wmi, int *code,
164				 unsigned int *value, bool *autorelease)
165{
166	switch (*code) {
167	case HOME_PRESS:
168		*value = 1;
169		*autorelease = 0;
170		break;
171	case HOME_HOLD:
172		*code = ASUS_WMI_KEY_IGNORE;
173		break;
174	case HOME_RELEASE:
175		*code = HOME_PRESS;
176		*value = 0;
177		*autorelease = 0;
178		break;
179	}
180}
181
182static acpi_status eeepc_wmi_parse_device(acpi_handle handle, u32 level,
183						 void *context, void **retval)
184{
185	pr_warn("Found legacy ATKD device (%s)\n", EEEPC_ACPI_HID);
186	*(bool *)context = true;
187	return AE_CTRL_TERMINATE;
188}
189
190static int eeepc_wmi_check_atkd(void)
191{
192	acpi_status status;
193	bool found = false;
194
195	status = acpi_get_devices(EEEPC_ACPI_HID, eeepc_wmi_parse_device,
196				  &found, NULL);
197
198	if (ACPI_FAILURE(status) || !found)
199		return 0;
200	return -1;
201}
202
203static int eeepc_wmi_probe(struct platform_device *pdev)
204{
205	if (eeepc_wmi_check_atkd()) {
 
206		pr_warn("WMI device present, but legacy ATKD device is also "
207			"present and enabled\n");
208		pr_warn("You probably booted with acpi_osi=\"Linux\" or "
209			"acpi_osi=\"!Windows 2009\"\n");
210		pr_warn("Can't load eeepc-wmi, use default acpi_osi "
211			"(preferred) or eeepc-laptop\n");
212		return -EBUSY;
213	}
214	return 0;
215}
216
217static void eeepc_wmi_quirks(struct asus_wmi_driver *driver)
218{
219	quirks = &quirk_asus_unknown;
220	quirks->hotplug_wireless = hotplug_wireless;
221
222	dmi_check_system(asus_quirks);
223
224	driver->quirks = quirks;
225	driver->quirks->wapf = -1;
226	driver->panel_power = FB_BLANK_UNBLANK;
227}
228
229static struct asus_wmi_driver asus_wmi_driver = {
230	.name = EEEPC_WMI_FILE,
231	.owner = THIS_MODULE,
232	.event_guid = EEEPC_WMI_EVENT_GUID,
233	.keymap = eeepc_wmi_keymap,
234	.input_name = "Eee PC WMI hotkeys",
235	.input_phys = EEEPC_WMI_FILE "/input0",
236	.key_filter = eeepc_wmi_key_filter,
237	.probe = eeepc_wmi_probe,
238	.detect_quirks = eeepc_wmi_quirks,
239};
240
241
242static int __init eeepc_wmi_init(void)
243{
244	return asus_wmi_register_driver(&asus_wmi_driver);
245}
246
247static void __exit eeepc_wmi_exit(void)
248{
249	asus_wmi_unregister_driver(&asus_wmi_driver);
250}
251
252module_init(eeepc_wmi_init);
253module_exit(eeepc_wmi_exit);
v5.14.15
  1// SPDX-License-Identifier: GPL-2.0-or-later
  2/*
  3 * Eee PC WMI hotkey driver
  4 *
  5 * Copyright(C) 2010 Intel Corporation.
  6 * Copyright(C) 2010-2011 Corentin Chary <corentin.chary@gmail.com>
  7 *
  8 * Portions based on wistron_btns.c:
  9 * Copyright (C) 2005 Miloslav Trmac <mitr@volny.cz>
 10 * Copyright (C) 2005 Bernhard Rosenkraenzer <bero@arklinux.org>
 11 * Copyright (C) 2005 Dmitry Torokhov <dtor@mail.ru>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 12 */
 13
 14#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 15
 16#include <linux/kernel.h>
 17#include <linux/module.h>
 18#include <linux/init.h>
 19#include <linux/input.h>
 20#include <linux/input/sparse-keymap.h>
 21#include <linux/dmi.h>
 22#include <linux/fb.h>
 23#include <linux/acpi.h>
 24
 25#include "asus-wmi.h"
 26
 27#define	EEEPC_WMI_FILE	"eeepc-wmi"
 28
 29MODULE_AUTHOR("Corentin Chary <corentin.chary@gmail.com>");
 30MODULE_DESCRIPTION("Eee PC WMI Hotkey Driver");
 31MODULE_LICENSE("GPL");
 32
 33#define EEEPC_ACPI_HID		"ASUS010" /* old _HID used in eeepc-laptop */
 34
 35#define EEEPC_WMI_EVENT_GUID	"ABBC0F72-8EA1-11D1-00A0-C90629100000"
 36
 37MODULE_ALIAS("wmi:"EEEPC_WMI_EVENT_GUID);
 38
 39static bool hotplug_wireless;
 40
 41module_param(hotplug_wireless, bool, 0444);
 42MODULE_PARM_DESC(hotplug_wireless,
 43		 "Enable hotplug for wireless device. "
 44		 "If your laptop needs that, please report to "
 45		 "acpi4asus-user@lists.sourceforge.net.");
 46
 47/* Values for T101MT "Home" key */
 48#define HOME_PRESS	0xe4
 49#define HOME_HOLD	0xea
 50#define HOME_RELEASE	0xe5
 51
 52static const struct key_entry eeepc_wmi_keymap[] = {
 53	{ KE_KEY, ASUS_WMI_BRN_DOWN, { KEY_BRIGHTNESSDOWN } },
 54	{ KE_KEY, ASUS_WMI_BRN_UP, { KEY_BRIGHTNESSUP } },
 55	/* Sleep already handled via generic ACPI code */
 56	{ KE_KEY, 0x30, { KEY_VOLUMEUP } },
 57	{ KE_KEY, 0x31, { KEY_VOLUMEDOWN } },
 58	{ KE_KEY, 0x32, { KEY_MUTE } },
 59	{ KE_KEY, 0x5c, { KEY_F15 } }, /* Power Gear key */
 60	{ KE_KEY, 0x5d, { KEY_WLAN } },
 61	{ KE_KEY, 0x6b, { KEY_TOUCHPAD_TOGGLE } }, /* Toggle Touchpad */
 62	{ KE_KEY, 0x82, { KEY_CAMERA } },
 63	{ KE_KEY, 0x83, { KEY_CAMERA_ZOOMIN } },
 64	{ KE_KEY, 0x88, { KEY_WLAN } },
 65	{ KE_KEY, 0xbd, { KEY_CAMERA } },
 66	{ KE_KEY, 0xcc, { KEY_SWITCHVIDEOMODE } },
 67	{ KE_KEY, 0xe0, { KEY_PROG1 } }, /* Task Manager */
 68	{ KE_KEY, 0xe1, { KEY_F14 } }, /* Change Resolution */
 69	{ KE_KEY, HOME_PRESS, { KEY_CONFIG } }, /* Home/Express gate key */
 70	{ KE_KEY, 0xe8, { KEY_SCREENLOCK } },
 71	{ KE_KEY, 0xe9, { KEY_DISPLAYTOGGLE } },
 72	{ KE_KEY, 0xeb, { KEY_CAMERA_ZOOMOUT } },
 73	{ KE_KEY, 0xec, { KEY_CAMERA_UP } },
 74	{ KE_KEY, 0xed, { KEY_CAMERA_DOWN } },
 75	{ KE_KEY, 0xee, { KEY_CAMERA_LEFT } },
 76	{ KE_KEY, 0xef, { KEY_CAMERA_RIGHT } },
 77	{ KE_KEY, 0xf3, { KEY_MENU } },
 78	{ KE_KEY, 0xf5, { KEY_HOMEPAGE } },
 79	{ KE_KEY, 0xf6, { KEY_ESC } },
 80	{ KE_END, 0},
 81};
 82
 83static struct quirk_entry quirk_asus_unknown = {
 84};
 85
 86static struct quirk_entry quirk_asus_1000h = {
 87	.hotplug_wireless = true,
 88};
 89
 90static struct quirk_entry quirk_asus_et2012_type1 = {
 91	.store_backlight_power = true,
 92};
 93
 94static struct quirk_entry quirk_asus_et2012_type3 = {
 95	.scalar_panel_brightness = true,
 96	.store_backlight_power = true,
 97};
 98
 99static struct quirk_entry quirk_asus_x101ch = {
100	/* We need this when ACPI function doesn't do this well */
101	.wmi_backlight_power = true,
102};
103
104static struct quirk_entry *quirks;
105
106static void et2012_quirks(void)
107{
108	const struct dmi_device *dev = NULL;
109	char oemstring[30];
110
111	while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) {
112		if (sscanf(dev->name, "AEMS%24c", oemstring) == 1) {
113			if (oemstring[18] == '1')
114				quirks = &quirk_asus_et2012_type1;
115			else if (oemstring[18] == '3')
116				quirks = &quirk_asus_et2012_type3;
117			break;
118		}
119	}
120}
121
122static int dmi_matched(const struct dmi_system_id *dmi)
123{
124	char *model;
125
126	quirks = dmi->driver_data;
127
128	model = (char *)dmi->matches[1].substr;
129	if (unlikely(strncmp(model, "ET2012", 6) == 0))
130		et2012_quirks();
131
132	return 1;
133}
134
135static const struct dmi_system_id asus_quirks[] = {
136	{
137		.callback = dmi_matched,
138		.ident = "ASUSTeK Computer INC. 1000H",
139		.matches = {
140			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer INC."),
141			DMI_MATCH(DMI_PRODUCT_NAME, "1000H"),
142		},
143		.driver_data = &quirk_asus_1000h,
144	},
145	{
146		.callback = dmi_matched,
147		.ident = "ASUSTeK Computer INC. ET2012E/I",
148		.matches = {
149			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer INC."),
150			DMI_MATCH(DMI_PRODUCT_NAME, "ET2012"),
151		},
152		.driver_data = &quirk_asus_unknown,
153	},
154	{
155		.callback = dmi_matched,
156		.ident = "ASUSTeK Computer INC. X101CH",
157		.matches = {
158			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
159			DMI_MATCH(DMI_PRODUCT_NAME, "X101CH"),
160		},
161		.driver_data = &quirk_asus_x101ch,
162	},
163	{
164		.callback = dmi_matched,
165		.ident = "ASUSTeK Computer INC. 1015CX",
166		.matches = {
167			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
168			DMI_MATCH(DMI_PRODUCT_NAME, "1015CX"),
169		},
170		.driver_data = &quirk_asus_x101ch,
171	},
172	{},
173};
174
175static void eeepc_wmi_key_filter(struct asus_wmi_driver *asus_wmi, int *code,
176				 unsigned int *value, bool *autorelease)
177{
178	switch (*code) {
179	case HOME_PRESS:
180		*value = 1;
181		*autorelease = 0;
182		break;
183	case HOME_HOLD:
184		*code = ASUS_WMI_KEY_IGNORE;
185		break;
186	case HOME_RELEASE:
187		*code = HOME_PRESS;
188		*value = 0;
189		*autorelease = 0;
190		break;
191	}
192}
193
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194static int eeepc_wmi_probe(struct platform_device *pdev)
195{
196	if (acpi_dev_found(EEEPC_ACPI_HID)) {
197		pr_warn("Found legacy ATKD device (%s)\n", EEEPC_ACPI_HID);
198		pr_warn("WMI device present, but legacy ATKD device is also "
199			"present and enabled\n");
200		pr_warn("You probably booted with acpi_osi=\"Linux\" or "
201			"acpi_osi=\"!Windows 2009\"\n");
202		pr_warn("Can't load eeepc-wmi, use default acpi_osi "
203			"(preferred) or eeepc-laptop\n");
204		return -EBUSY;
205	}
206	return 0;
207}
208
209static void eeepc_wmi_quirks(struct asus_wmi_driver *driver)
210{
211	quirks = &quirk_asus_unknown;
212	quirks->hotplug_wireless = hotplug_wireless;
213
214	dmi_check_system(asus_quirks);
215
216	driver->quirks = quirks;
217	driver->quirks->wapf = -1;
218	driver->panel_power = FB_BLANK_UNBLANK;
219}
220
221static struct asus_wmi_driver asus_wmi_driver = {
222	.name = EEEPC_WMI_FILE,
223	.owner = THIS_MODULE,
224	.event_guid = EEEPC_WMI_EVENT_GUID,
225	.keymap = eeepc_wmi_keymap,
226	.input_name = "Eee PC WMI hotkeys",
227	.input_phys = EEEPC_WMI_FILE "/input0",
228	.key_filter = eeepc_wmi_key_filter,
229	.probe = eeepc_wmi_probe,
230	.detect_quirks = eeepc_wmi_quirks,
231};
232
233
234static int __init eeepc_wmi_init(void)
235{
236	return asus_wmi_register_driver(&asus_wmi_driver);
237}
238
239static void __exit eeepc_wmi_exit(void)
240{
241	asus_wmi_unregister_driver(&asus_wmi_driver);
242}
243
244module_init(eeepc_wmi_init);
245module_exit(eeepc_wmi_exit);