Linux Audio

Check our new training course

Loading...
v3.1
 
  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 <acpi/acpi_bus.h>
 
 36
 37#include "asus-wmi.h"
 38
 39#define	EEEPC_WMI_FILE	"eeepc-wmi"
 40
 41MODULE_AUTHOR("Corentin Chary <corentincj@iksaif.net>");
 42MODULE_DESCRIPTION("Eee PC WMI Hotkey Driver");
 43MODULE_LICENSE("GPL");
 44
 45#define EEEPC_ACPI_HID		"ASUS010" /* old _HID used in eeepc-laptop */
 46
 47#define EEEPC_WMI_EVENT_GUID	"ABBC0F72-8EA1-11D1-00A0-C90629100000"
 48
 49MODULE_ALIAS("wmi:"EEEPC_WMI_EVENT_GUID);
 50
 51static bool hotplug_wireless;
 52
 53module_param(hotplug_wireless, bool, 0444);
 54MODULE_PARM_DESC(hotplug_wireless,
 55		 "Enable hotplug for wireless device. "
 56		 "If your laptop needs that, please report to "
 57		 "acpi4asus-user@lists.sourceforge.net.");
 58
 59/* Values for T101MT "Home" key */
 60#define HOME_PRESS	0xe4
 61#define HOME_HOLD	0xea
 62#define HOME_RELEASE	0xe5
 63
 64static const struct key_entry eeepc_wmi_keymap[] = {
 
 
 65	/* Sleep already handled via generic ACPI code */
 66	{ KE_KEY, 0x30, { KEY_VOLUMEUP } },
 67	{ KE_KEY, 0x31, { KEY_VOLUMEDOWN } },
 68	{ KE_KEY, 0x32, { KEY_MUTE } },
 69	{ KE_KEY, 0x5c, { KEY_F15 } }, /* Power Gear key */
 70	{ KE_KEY, 0x5d, { KEY_WLAN } },
 71	{ KE_KEY, 0x6b, { KEY_TOUCHPAD_TOGGLE } }, /* Toggle Touchpad */
 72	{ KE_KEY, 0x82, { KEY_CAMERA } },
 73	{ KE_KEY, 0x83, { KEY_CAMERA_ZOOMIN } },
 74	{ KE_KEY, 0x88, { KEY_WLAN } },
 75	{ KE_KEY, 0xbd, { KEY_CAMERA } },
 76	{ KE_KEY, 0xcc, { KEY_SWITCHVIDEOMODE } },
 77	{ KE_KEY, 0xe0, { KEY_PROG1 } }, /* Task Manager */
 78	{ KE_KEY, 0xe1, { KEY_F14 } }, /* Change Resolution */
 79	{ KE_KEY, HOME_PRESS, { KEY_CONFIG } }, /* Home/Express gate key */
 80	{ KE_KEY, 0xe8, { KEY_SCREENLOCK } },
 81	{ KE_KEY, 0xe9, { KEY_BRIGHTNESS_ZERO } },
 82	{ KE_KEY, 0xeb, { KEY_CAMERA_ZOOMOUT } },
 83	{ KE_KEY, 0xec, { KEY_CAMERA_UP } },
 84	{ KE_KEY, 0xed, { KEY_CAMERA_DOWN } },
 85	{ KE_KEY, 0xee, { KEY_CAMERA_LEFT } },
 86	{ KE_KEY, 0xef, { KEY_CAMERA_RIGHT } },
 
 
 
 87	{ KE_END, 0},
 88};
 89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 90static void eeepc_wmi_key_filter(struct asus_wmi_driver *asus_wmi, int *code,
 91				 unsigned int *value, bool *autorelease)
 92{
 93	switch (*code) {
 94	case HOME_PRESS:
 95		*value = 1;
 96		*autorelease = 0;
 97		break;
 98	case HOME_HOLD:
 99		*code = ASUS_WMI_KEY_IGNORE;
100		break;
101	case HOME_RELEASE:
102		*code = HOME_PRESS;
103		*value = 0;
104		*autorelease = 0;
105		break;
106	}
107}
108
109static acpi_status eeepc_wmi_parse_device(acpi_handle handle, u32 level,
110						 void *context, void **retval)
111{
112	pr_warn("Found legacy ATKD device (%s)\n", EEEPC_ACPI_HID);
113	*(bool *)context = true;
114	return AE_CTRL_TERMINATE;
115}
116
117static int eeepc_wmi_check_atkd(void)
118{
119	acpi_status status;
120	bool found = false;
121
122	status = acpi_get_devices(EEEPC_ACPI_HID, eeepc_wmi_parse_device,
123				  &found, NULL);
124
125	if (ACPI_FAILURE(status) || !found)
126		return 0;
127	return -1;
128}
129
130static int eeepc_wmi_probe(struct platform_device *pdev)
131{
132	if (eeepc_wmi_check_atkd()) {
 
133		pr_warn("WMI device present, but legacy ATKD device is also "
134			"present and enabled\n");
135		pr_warn("You probably booted with acpi_osi=\"Linux\" or "
136			"acpi_osi=\"!Windows 2009\"\n");
137		pr_warn("Can't load eeepc-wmi, use default acpi_osi "
138			"(preferred) or eeepc-laptop\n");
139		return -EBUSY;
140	}
141	return 0;
142}
143
144static void eeepc_dmi_check(struct asus_wmi_driver *driver)
145{
146	const char *model;
 
147
148	model = dmi_get_system_info(DMI_PRODUCT_NAME);
149	if (!model)
150		return;
151
152	/*
153	 * Whitelist for wlan hotplug
154	 *
155	 * Asus 1000H needs the current hotplug code to handle
156	 * Fn+F2 correctly. We may add other Asus here later, but
157	 * it seems that most of the laptops supported by asus-wmi
158	 * don't need to be on this list
159	 */
160	if (strcmp(model, "1000H") == 0) {
161		driver->hotplug_wireless = true;
162		pr_info("wlan hotplug enabled\n");
163	}
164}
165
166static void eeepc_wmi_quirks(struct asus_wmi_driver *driver)
167{
168	driver->hotplug_wireless = hotplug_wireless;
169	driver->wapf = -1;
170	eeepc_dmi_check(driver);
171}
172
173static struct asus_wmi_driver asus_wmi_driver = {
174	.name = EEEPC_WMI_FILE,
175	.owner = THIS_MODULE,
176	.event_guid = EEEPC_WMI_EVENT_GUID,
177	.keymap = eeepc_wmi_keymap,
178	.input_name = "Eee PC WMI hotkeys",
179	.input_phys = EEEPC_WMI_FILE "/input0",
180	.key_filter = eeepc_wmi_key_filter,
181	.probe = eeepc_wmi_probe,
182	.quirks = eeepc_wmi_quirks,
183};
184
185
186static int __init eeepc_wmi_init(void)
187{
188	return asus_wmi_register_driver(&asus_wmi_driver);
189}
190
191static void __exit eeepc_wmi_exit(void)
192{
193	asus_wmi_unregister_driver(&asus_wmi_driver);
194}
195
196module_init(eeepc_wmi_init);
197module_exit(eeepc_wmi_exit);
v6.2
  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 *quirks;
100
101static void et2012_quirks(void)
102{
103	const struct dmi_device *dev = NULL;
104	char oemstring[30];
105
106	while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) {
107		if (sscanf(dev->name, "AEMS%24c", oemstring) == 1) {
108			if (oemstring[18] == '1')
109				quirks = &quirk_asus_et2012_type1;
110			else if (oemstring[18] == '3')
111				quirks = &quirk_asus_et2012_type3;
112			break;
113		}
114	}
115}
116
117static int dmi_matched(const struct dmi_system_id *dmi)
118{
119	char *model;
120
121	quirks = dmi->driver_data;
122
123	model = (char *)dmi->matches[1].substr;
124	if (unlikely(strncmp(model, "ET2012", 6) == 0))
125		et2012_quirks();
126
127	return 1;
128}
129
130static const struct dmi_system_id asus_quirks[] = {
131	{
132		.callback = dmi_matched,
133		.ident = "ASUSTeK Computer INC. 1000H",
134		.matches = {
135			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer INC."),
136			DMI_MATCH(DMI_PRODUCT_NAME, "1000H"),
137		},
138		.driver_data = &quirk_asus_1000h,
139	},
140	{
141		.callback = dmi_matched,
142		.ident = "ASUSTeK Computer INC. ET2012E/I",
143		.matches = {
144			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer INC."),
145			DMI_MATCH(DMI_PRODUCT_NAME, "ET2012"),
146		},
147		.driver_data = &quirk_asus_unknown,
148	},
149	{}
150};
151
152static void eeepc_wmi_key_filter(struct asus_wmi_driver *asus_wmi, int *code,
153				 unsigned int *value, bool *autorelease)
154{
155	switch (*code) {
156	case HOME_PRESS:
157		*value = 1;
158		*autorelease = 0;
159		break;
160	case HOME_HOLD:
161		*code = ASUS_WMI_KEY_IGNORE;
162		break;
163	case HOME_RELEASE:
164		*code = HOME_PRESS;
165		*value = 0;
166		*autorelease = 0;
167		break;
168	}
169}
170
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171static int eeepc_wmi_probe(struct platform_device *pdev)
172{
173	if (acpi_dev_found(EEEPC_ACPI_HID)) {
174		pr_warn("Found legacy ATKD device (%s)\n", EEEPC_ACPI_HID);
175		pr_warn("WMI device present, but legacy ATKD device is also "
176			"present and enabled\n");
177		pr_warn("You probably booted with acpi_osi=\"Linux\" or "
178			"acpi_osi=\"!Windows 2009\"\n");
179		pr_warn("Can't load eeepc-wmi, use default acpi_osi "
180			"(preferred) or eeepc-laptop\n");
181		return -EBUSY;
182	}
183	return 0;
184}
185
186static void eeepc_wmi_quirks(struct asus_wmi_driver *driver)
187{
188	quirks = &quirk_asus_unknown;
189	quirks->hotplug_wireless = hotplug_wireless;
190
191	dmi_check_system(asus_quirks);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
193	driver->quirks = quirks;
194	driver->quirks->wapf = -1;
195	driver->panel_power = FB_BLANK_UNBLANK;
 
 
196}
197
198static struct asus_wmi_driver asus_wmi_driver = {
199	.name = EEEPC_WMI_FILE,
200	.owner = THIS_MODULE,
201	.event_guid = EEEPC_WMI_EVENT_GUID,
202	.keymap = eeepc_wmi_keymap,
203	.input_name = "Eee PC WMI hotkeys",
204	.input_phys = EEEPC_WMI_FILE "/input0",
205	.key_filter = eeepc_wmi_key_filter,
206	.probe = eeepc_wmi_probe,
207	.detect_quirks = eeepc_wmi_quirks,
208};
209
210
211static int __init eeepc_wmi_init(void)
212{
213	return asus_wmi_register_driver(&asus_wmi_driver);
214}
215
216static void __exit eeepc_wmi_exit(void)
217{
218	asus_wmi_unregister_driver(&asus_wmi_driver);
219}
220
221module_init(eeepc_wmi_init);
222module_exit(eeepc_wmi_exit);