25 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
27 #include <linux/kernel.h>
28 #include <linux/module.h>
30 #include <linux/types.h>
38 #include <linux/rfkill.h>
41 #include <linux/slab.h>
42 #include <linux/input.h>
57 #define ACER_AMW0_WRITE 0x9610
62 #define ACER_AMW0_WIRELESS_MASK 0x35
63 #define ACER_AMW0_BLUETOOTH_MASK 0x34
64 #define ACER_AMW0_MAILLED_MASK 0x31
69 #define ACER_WMID_GET_WIRELESS_METHODID 1
70 #define ACER_WMID_GET_BLUETOOTH_METHODID 2
71 #define ACER_WMID_GET_BRIGHTNESS_METHODID 3
72 #define ACER_WMID_SET_WIRELESS_METHODID 4
73 #define ACER_WMID_SET_BLUETOOTH_METHODID 5
74 #define ACER_WMID_SET_BRIGHTNESS_METHODID 6
75 #define ACER_WMID_GET_THREEG_METHODID 10
76 #define ACER_WMID_SET_THREEG_METHODID 11
81 #define AMW0_GUID1 "67C3371D-95A3-4C37-BB61-DD47B491DAAB"
82 #define AMW0_GUID2 "431F16ED-0C2B-444C-B267-27DEB140CF9C"
83 #define WMID_GUID1 "6AF4F258-B401-42FD-BE91-3D4AC2D7C0D3"
84 #define WMID_GUID2 "95764E09-FB56-4E83-B31A-37761F60994A"
85 #define WMID_GUID3 "61EF69EA-865C-4BC3-A502-A0DEBA0CB531"
90 #define ACERWMID_EVENT_GUID "676AA15E-6A47-4D9F-A2CC-1E6D18D14026"
92 MODULE_ALIAS(
"wmi:67C3371D-95A3-4C37-BB61-DD47B491DAAB");
93 MODULE_ALIAS(
"wmi:6AF4F258-B401-42FD-BE91-3D4AC2D7C0D3");
94 MODULE_ALIAS(
"wmi:676AA15E-6A47-4D9F-A2CC-1E6D18D14026");
101 static const struct key_entry acer_wmi_keymap[] = {
133 static struct input_dev *acer_wmi_input_dev;
134 static struct input_dev *acer_wmi_accel_dev;
146 #define ACER_WMID3_GDS_WIRELESS (1<<0)
147 #define ACER_WMID3_GDS_THREEG (1<<6)
148 #define ACER_WMID3_GDS_WIMAX (1<<7)
149 #define ACER_WMID3_GDS_BLUETOOTH (1<<11)
200 #define ACER_CAP_MAILLED (1<<0)
201 #define ACER_CAP_WIRELESS (1<<1)
202 #define ACER_CAP_BLUETOOTH (1<<2)
203 #define ACER_CAP_BRIGHTNESS (1<<3)
204 #define ACER_CAP_THREEG (1<<4)
205 #define ACER_CAP_ACCEL (1<<5)
206 #define ACER_CAP_ANY (0xFFFFFFFF)
218 #define ACER_DEFAULT_WIRELESS 0
219 #define ACER_DEFAULT_BLUETOOTH 0
220 #define ACER_DEFAULT_MAILLED 0
221 #define ACER_DEFAULT_THREEG 0
223 static int max_brightness = 0xF;
225 static int mailled = -1;
227 static int threeg = -1;
228 static int force_series;
229 static bool ec_raw_mode;
230 static bool has_type_aa;
257 static struct rfkill *wireless_rfkill;
258 static struct rfkill *bluetooth_rfkill;
259 static struct rfkill *threeg_rfkill;
260 static bool rfkill_inited;
295 static void set_quirks(
void)
309 quirks = dmi->driver_data;
316 static struct quirk_entry quirk_acer_aspire_1520 = {
320 static struct quirk_entry quirk_acer_travelmate_2490 = {
325 static struct quirk_entry quirk_medion_md_98300 = {
329 static struct quirk_entry quirk_fujitsu_amilo_li_1718 = {
333 static struct quirk_entry quirk_lenovo_ideapad_s205 = {
340 .ident =
"Acer Aspire One (SSD)",
347 .ident =
"Acer Aspire One (HDD)",
358 .callback = dmi_matched,
359 .ident =
"Acer Aspire 1360",
364 .driver_data = &quirk_acer_aspire_1520,
367 .callback = dmi_matched,
368 .ident =
"Acer Aspire 1520",
373 .driver_data = &quirk_acer_aspire_1520,
376 .callback = dmi_matched,
377 .ident =
"Acer Aspire 3100",
382 .driver_data = &quirk_acer_travelmate_2490,
385 .callback = dmi_matched,
386 .ident =
"Acer Aspire 3610",
391 .driver_data = &quirk_acer_travelmate_2490,
394 .callback = dmi_matched,
395 .ident =
"Acer Aspire 5100",
400 .driver_data = &quirk_acer_travelmate_2490,
403 .callback = dmi_matched,
404 .ident =
"Acer Aspire 5610",
409 .driver_data = &quirk_acer_travelmate_2490,
412 .callback = dmi_matched,
413 .ident =
"Acer Aspire 5630",
418 .driver_data = &quirk_acer_travelmate_2490,
421 .callback = dmi_matched,
422 .ident =
"Acer Aspire 5650",
427 .driver_data = &quirk_acer_travelmate_2490,
430 .callback = dmi_matched,
431 .ident =
"Acer Aspire 5680",
436 .driver_data = &quirk_acer_travelmate_2490,
439 .callback = dmi_matched,
440 .ident =
"Acer Aspire 9110",
445 .driver_data = &quirk_acer_travelmate_2490,
448 .callback = dmi_matched,
449 .ident =
"Acer TravelMate 2490",
454 .driver_data = &quirk_acer_travelmate_2490,
457 .callback = dmi_matched,
458 .ident =
"Acer TravelMate 4200",
463 .driver_data = &quirk_acer_travelmate_2490,
466 .callback = dmi_matched,
467 .ident =
"Fujitsu Siemens Amilo Li 1718",
472 .driver_data = &quirk_fujitsu_amilo_li_1718,
475 .callback = dmi_matched,
476 .ident =
"Medion MD 98300",
481 .driver_data = &quirk_medion_md_98300,
484 .callback = dmi_matched,
485 .ident =
"Lenovo Ideapad S205",
490 .driver_data = &quirk_lenovo_ideapad_s205,
493 .callback = dmi_matched,
494 .ident =
"Lenovo Ideapad S205 (Brazos)",
499 .driver_data = &quirk_lenovo_ideapad_s205,
502 .callback = dmi_matched,
503 .ident =
"Lenovo 3000 N200",
508 .driver_data = &quirk_fujitsu_amilo_li_1718,
513 static int video_set_backlight_video_vendor(
const struct dmi_system_id *
d)
516 pr_info(
"Brightness must be controlled by generic video driver\n");
520 static const struct dmi_system_id video_vendor_dmi_table[] = {
522 .callback = video_set_backlight_video_vendor,
523 .ident =
"Acer TravelMate 4750",
530 .callback = video_set_backlight_video_vendor,
531 .ident =
"Acer Extensa 5235",
538 .callback = video_set_backlight_video_vendor,
539 .ident =
"Acer TravelMate 5760",
546 .callback = video_set_backlight_video_vendor,
547 .ident =
"Acer Aspire 5750",
557 static void find_quirks(
void)
561 }
else if (force_series == 2490) {
562 quirks = &quirk_acer_travelmate_2490;
566 quirks = &quirk_unknown;
575 static bool has_cap(
u32 cap)
626 *value = (result >> 7) & 0x1;
636 *value = result & 0x1;
642 *value = result & 0x1;
648 *value = result & 0x1;
654 *value = (result >> 2) & 0x1;
664 *value = (result >> 4) & 0x1;
689 args.ebx = value ? (1<<8) : 0;
709 if (value > max_brightness)
721 return wmab_execute(&args,
NULL);
735 status = wmab_execute(&args, &out);
756 static int AMW0_set_cap_acpi_check_device_found;
761 AMW0_set_cap_acpi_check_device_found = 1;
773 static int AMW0_set_cap_acpi_check_device(
void)
777 for (
id = norfkill_ids;
id->
id[0];
id++)
780 return AMW0_set_cap_acpi_check_device_found;
796 if ((quirks != &quirk_unknown) ||
797 !AMW0_set_cap_acpi_check_device())
805 args.ebx = 0xa2 << 8;
808 status = wmab_execute(&args, &out);
831 status = wmab_execute(&args, &out);
933 status = WMI_execute_u32(method_id, 0, &result);
948 if (value > max_brightness)
971 param = value ? 0x92 : 0x93;
981 return WMI_execute_u32(method_id, (
u32)value,
NULL);
1012 if (obj->
buffer.length != 8) {
1022 pr_warn(
"Get 0x%x Device Status failed: 0x%x - 0x%x\n",
1049 return wmid3_get_device_status(value, device);
1091 if (obj->
buffer.length != 8) {
1101 pr_warn(
"Get Current Device Status failed: 0x%x - 0x%x\n",
1108 set_params.
devices = (
value) ? (devices | device) : (devices & ~device);
1122 if (obj->
buffer.length != 4) {
1132 pr_warn(
"Set Device Status failed: 0x%x - 0x%x\n",
1156 return wmid3_set_device_status(value, device);
1164 if (header->
type != 0xAA)
1170 pr_info(
"Function bitmap for Communication Button: 0x%x\n",
1199 devices = *((
u32 *) obj->
buffer.pointer);
1207 pr_info(
"Function bitmap for Communication Device: 0x%x\n", devices);
1215 if (!(devices & 0x20))
1216 max_brightness = 0x9;
1238 switch (interface->
type) {
1240 status = AMW0_get_u32(value, cap);
1244 status = AMW0_get_u32(value, cap);
1248 status = WMID_get_u32(value, cap);
1254 status = wmid_v2_get_u32(value, cap);
1256 status = WMID_get_u32(value, cap);
1268 switch (interface->
type) {
1270 return AMW0_set_u32(value, cap);
1273 return AMW0_set_u32(value, cap);
1283 status = WMID_set_u32(value, cap);
1287 return AMW0_set_u32(value, cap);
1290 return WMID_set_u32(value, cap);
1295 return wmid_v2_set_u32(value, cap);
1297 return WMID_set_u32(value, cap);
1305 static void __init acer_commandline_init(
void)
1313 if (!has_type_aa && threeg >= 0)
1315 if (brightness >= 0)
1322 static void mail_led_set(
struct led_classdev *led_cdev,
1329 .name =
"acer-wmi::mail",
1330 .brightness_set = mail_led_set,
1338 static void acer_led_exit(
void)
1358 int intensity = bd->
props.brightness;
1371 .get_brightness = read_brightness,
1372 .update_status = update_bl_status,
1375 static int __devinit acer_backlight_init(
struct device *
dev)
1382 props.max_brightness = max_brightness;
1386 pr_err(
"Could not register Acer backlight device\n");
1387 acer_backlight_device =
NULL;
1391 acer_backlight_device = bd;
1394 bd->
props.brightness = read_brightness(bd);
1395 backlight_update_status(bd);
1399 static void acer_backlight_exit(
void)
1409 static int acer_gsensor_init(
void)
1415 output.
length =
sizeof(out_obj);
1424 static int acer_gsensor_open(
struct input_dev *input)
1426 return acer_gsensor_init();
1429 static int acer_gsensor_event(
void)
1438 output.
length =
sizeof(out_obj);
1445 if (out_obj->package.count != 4)
1448 input_report_abs(acer_wmi_accel_dev,
ABS_X,
1449 (
s16)out_obj->package.elements[0].integer.value);
1450 input_report_abs(acer_wmi_accel_dev,
ABS_Y,
1451 (
s16)out_obj->package.elements[1].integer.value);
1452 input_report_abs(acer_wmi_accel_dev,
ABS_Z,
1453 (
s16)out_obj->package.elements[2].integer.value);
1454 input_sync(acer_wmi_accel_dev);
1493 static int acer_rfkill_set(
void *
data,
bool blocked)
1496 u32 cap = (
unsigned long)data;
1498 if (rfkill_inited) {
1499 status = set_u32(!blocked, cap);
1507 static const struct rfkill_ops acer_rfkill_ops = {
1508 .set_block = acer_rfkill_set,
1511 static struct rfkill *acer_rfkill_register(
struct device *dev,
1516 struct rfkill *rfkill_dev;
1522 (
void *)(
unsigned long)cap);
1526 status = get_u32(&state, cap);
1531 return ERR_PTR(err);
1540 static int acer_rfkill_init(
struct device *dev)
1547 if (IS_ERR(wireless_rfkill)) {
1548 err = PTR_ERR(wireless_rfkill);
1549 goto error_wireless;
1554 bluetooth_rfkill = acer_rfkill_register(dev,
1557 if (IS_ERR(bluetooth_rfkill)) {
1558 err = PTR_ERR(bluetooth_rfkill);
1559 goto error_bluetooth;
1564 threeg_rfkill = acer_rfkill_register(dev,
1567 if (IS_ERR(threeg_rfkill)) {
1568 err = PTR_ERR(threeg_rfkill);
1573 rfkill_inited =
true;
1596 static void acer_rfkill_exit(
void)
1622 static ssize_t show_bool_threeg(
struct device *dev,
1628 pr_info(
"This threeg sysfs will be removed in 2012 - used by: %s\n",
1632 return sprintf(buf,
"%u\n", result);
1633 return sprintf(buf,
"Read error\n");
1636 static ssize_t set_bool_threeg(
struct device *dev,
1641 pr_info(
"This threeg sysfs will be removed in 2012 - used by: %s\n",
1653 pr_info(
"This interface sysfs will be removed in 2012 - used by: %s\n",
1655 switch (interface->
type) {
1657 return sprintf(buf,
"AMW0\n");
1659 return sprintf(buf,
"AMW0 v2\n");
1661 return sprintf(buf,
"WMID\n");
1663 return sprintf(buf,
"WMID v2\n");
1665 return sprintf(buf,
"Error!\n");
1671 static void acer_wmi_notify(
u32 value,
void *
context)
1678 const struct key_entry *
key;
1681 if (status !=
AE_OK) {
1682 pr_warn(
"bad event status 0x%x\n", status);
1691 pr_warn(
"Unknown response received %d\n", obj->
type);
1695 if (obj->
buffer.length != 8) {
1707 pr_debug(
"device state: 0x%x\n", device_state);
1709 key = sparse_keymap_entry_from_scancode(acer_wmi_input_dev,
1712 pr_warn(
"Unknown key number - 0x%x\n",
1715 switch (key->keycode) {
1729 sparse_keymap_report_entry(acer_wmi_input_dev, key,
1734 acer_gsensor_event();
1737 pr_warn(
"Unknown function number - %d - %d\n",
1765 if (obj->
buffer.length != 4) {
1777 static int acer_wmi_enable_ec_raw(
void)
1783 .commun_devices = 0xFFFF,
1788 status = wmid3_set_lm_mode(¶ms, &return_value);
1791 pr_warn(
"Enabling EC raw mode failed: 0x%x - 0x%x\n",
1795 pr_info(
"Enabled EC raw mode\n");
1800 static int acer_wmi_enable_lm(
void)
1806 .commun_devices = 0xFFFF,
1811 status = wmid3_set_lm_mode(¶ms, &return_value);
1814 pr_warn(
"Enabling Launch Manager failed: 0x%x - 0x%x\n",
1828 static int __init acer_wmi_get_handle(
const char *name,
const char *prop,
1838 (
void *)name, &handle);
1848 static int __init acer_wmi_accel_setup(
void)
1852 err = acer_wmi_get_handle(
"SENR",
"BST0001", &gsensor_handle);
1858 acer_wmi_accel_dev = input_allocate_device();
1859 if (!acer_wmi_accel_dev)
1862 acer_wmi_accel_dev->open = acer_gsensor_open;
1864 acer_wmi_accel_dev->name =
"Acer BMA150 accelerometer";
1865 acer_wmi_accel_dev->phys =
"wmi/input1";
1866 acer_wmi_accel_dev->id.bustype =
BUS_HOST;
1868 input_set_abs_params(acer_wmi_accel_dev,
ABS_X, -16384, 16384, 0, 0);
1869 input_set_abs_params(acer_wmi_accel_dev,
ABS_Y, -16384, 16384, 0, 0);
1870 input_set_abs_params(acer_wmi_accel_dev,
ABS_Z, -16384, 16384, 0, 0);
1872 err = input_register_device(acer_wmi_accel_dev);
1879 input_free_device(acer_wmi_accel_dev);
1883 static void acer_wmi_accel_destroy(
void)
1885 input_unregister_device(acer_wmi_accel_dev);
1888 static int __init acer_wmi_input_setup(
void)
1893 acer_wmi_input_dev = input_allocate_device();
1894 if (!acer_wmi_input_dev)
1897 acer_wmi_input_dev->name =
"Acer WMI hotkeys";
1898 acer_wmi_input_dev->phys =
"wmi/input0";
1899 acer_wmi_input_dev->id.bustype =
BUS_HOST;
1901 err = sparse_keymap_setup(acer_wmi_input_dev, acer_wmi_keymap,
NULL);
1906 acer_wmi_notify,
NULL);
1909 goto err_free_keymap;
1912 err = input_register_device(acer_wmi_input_dev);
1914 goto err_uninstall_notifier;
1918 err_uninstall_notifier:
1921 sparse_keymap_free(acer_wmi_input_dev);
1923 input_free_device(acer_wmi_input_dev);
1927 static void acer_wmi_input_destroy(
void)
1930 sparse_keymap_free(acer_wmi_input_dev);
1931 input_unregister_device(acer_wmi_input_dev);
1937 static u32 get_wmid_devices(
void)
1952 devices = *((
u32 *) obj->
buffer.pointer);
1969 err = acer_led_init(&device->
dev);
1975 err = acer_backlight_init(&device->
dev);
1977 goto error_brightness;
1980 err = acer_rfkill_init(&device->
dev);
1988 acer_backlight_exit();
2001 acer_backlight_exit();
2007 static int acer_suspend(
struct device *dev)
2029 static int acer_resume(
struct device *dev)
2043 acer_gsensor_init();
2067 .probe = acer_platform_probe,
2068 .remove = acer_platform_remove,
2069 .shutdown = acer_platform_shutdown,
2084 static int create_sysfs(
void)
2096 &dev_attr_interface);
2103 remove_sysfs(acer_platform_device);
2107 static void remove_debugfs(
void)
2113 static int create_debugfs(
void)
2116 if (!interface->
debug.root) {
2117 pr_err(
"Failed to create debugfs directory");
2122 interface->
debug.root,
2123 &interface->
debug.wmid_devices);
2124 if (!interface->
debug.devices)
2134 static int __init acer_wmi_init(
void)
2138 pr_info(
"Acer Laptop ACPI-WMI Extras\n");
2141 pr_info(
"Blacklisted hardware detected - not loading\n");
2151 interface = &AMW0_V2_interface;
2154 interface = &wmid_interface;
2157 interface = &wmid_v2_interface;
2163 if (!has_type_aa &&
ACPI_FAILURE(WMID_set_capabilities())) {
2164 pr_err(
"Unable to detect available WMID devices\n");
2170 pr_err(
"No WMID device detection method found\n");
2175 interface = &AMW0_interface;
2178 pr_err(
"Unable to detect available AMW0 devices\n");
2184 AMW0_find_mailled();
2187 pr_err(
"No or unsupported WMI interface, unable to load\n");
2197 pr_info(
"Brightness must be controlled by acpi video driver\n");
2199 pr_info(
"Disabling ACPI video driver\n");
2206 pr_err(
"Cannot enable EC raw mode\n");
2210 pr_err(
"Cannot enable Launch Manager mode\n");
2213 }
else if (ec_raw_mode) {
2214 pr_info(
"No WMID EC raw mode enable method\n");
2218 err = acer_wmi_input_setup();
2223 acer_wmi_accel_setup();
2227 pr_err(
"Unable to register platform driver\n");
2228 goto error_platform_register;
2232 if (!acer_platform_device) {
2234 goto error_device_alloc;
2239 goto error_device_add;
2241 err = create_sysfs();
2243 goto error_create_sys;
2246 interface->
debug.wmid_devices = get_wmid_devices();
2247 err = create_debugfs();
2249 goto error_create_debugfs;
2253 acer_commandline_init();
2257 error_create_debugfs:
2258 remove_sysfs(acer_platform_device);
2265 error_platform_register:
2267 acer_wmi_input_destroy();
2269 acer_wmi_accel_destroy();
2274 static void __exit acer_wmi_exit(
void)
2277 acer_wmi_input_destroy();
2280 acer_wmi_accel_destroy();
2282 remove_sysfs(acer_platform_device);
2287 pr_info(
"Acer Laptop WMI Extras unloaded\n");