PageRenderTime 64ms CodeModel.GetById 16ms RepoModel.GetById 2ms app.codeStats 1ms

/drivers/platform/x86/eeepc-wmi.c

https://bitbucket.org/slukk/jb-tsm-kernel-4.2
C | 170 lines | 111 code | 25 blank | 34 comment | 6 complexity | a28d2d79e6ef4fe4fee8370a3d04ece3 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0
  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. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  27. #include <linux/kernel.h>
  28. #include <linux/module.h>
  29. #include <linux/init.h>
  30. #include <linux/input.h>
  31. #include <linux/input/sparse-keymap.h>
  32. #include <linux/dmi.h>
  33. #include <acpi/acpi_bus.h>
  34. #include "asus-wmi.h"
  35. #define EEEPC_WMI_FILE "eeepc-wmi"
  36. MODULE_AUTHOR("Corentin Chary <corentincj@iksaif.net>");
  37. MODULE_DESCRIPTION("Eee PC WMI Hotkey Driver");
  38. MODULE_LICENSE("GPL");
  39. #define EEEPC_ACPI_HID "ASUS010" /* old _HID used in eeepc-laptop */
  40. #define EEEPC_WMI_EVENT_GUID "ABBC0F72-8EA1-11D1-00A0-C90629100000"
  41. MODULE_ALIAS("wmi:"EEEPC_WMI_EVENT_GUID);
  42. static bool hotplug_wireless;
  43. module_param(hotplug_wireless, bool, 0444);
  44. MODULE_PARM_DESC(hotplug_wireless,
  45. "Enable hotplug for wireless device. "
  46. "If your laptop needs that, please report to "
  47. "acpi4asus-user@lists.sourceforge.net.");
  48. static const struct key_entry eeepc_wmi_keymap[] = {
  49. /* Sleep already handled via generic ACPI code */
  50. { KE_KEY, 0x30, { KEY_VOLUMEUP } },
  51. { KE_KEY, 0x31, { KEY_VOLUMEDOWN } },
  52. { KE_KEY, 0x32, { KEY_MUTE } },
  53. { KE_KEY, 0x5c, { KEY_F15 } }, /* Power Gear key */
  54. { KE_KEY, 0x5d, { KEY_WLAN } },
  55. { KE_KEY, 0x6b, { KEY_TOUCHPAD_TOGGLE } }, /* Toggle Touchpad */
  56. { KE_KEY, 0x82, { KEY_CAMERA } },
  57. { KE_KEY, 0x83, { KEY_CAMERA_ZOOMIN } },
  58. { KE_KEY, 0x88, { KEY_WLAN } },
  59. { KE_KEY, 0xbd, { KEY_CAMERA } },
  60. { KE_KEY, 0xcc, { KEY_SWITCHVIDEOMODE } },
  61. { KE_KEY, 0xe0, { KEY_PROG1 } }, /* Task Manager */
  62. { KE_KEY, 0xe1, { KEY_F14 } }, /* Change Resolution */
  63. { KE_KEY, 0xe8, { KEY_SCREENLOCK } },
  64. { KE_KEY, 0xe9, { KEY_BRIGHTNESS_ZERO } },
  65. { KE_KEY, 0xeb, { KEY_CAMERA_ZOOMOUT } },
  66. { KE_KEY, 0xec, { KEY_CAMERA_UP } },
  67. { KE_KEY, 0xed, { KEY_CAMERA_DOWN } },
  68. { KE_KEY, 0xee, { KEY_CAMERA_LEFT } },
  69. { KE_KEY, 0xef, { KEY_CAMERA_RIGHT } },
  70. { KE_END, 0},
  71. };
  72. static acpi_status eeepc_wmi_parse_device(acpi_handle handle, u32 level,
  73. void *context, void **retval)
  74. {
  75. pr_warn("Found legacy ATKD device (%s)\n", EEEPC_ACPI_HID);
  76. *(bool *)context = true;
  77. return AE_CTRL_TERMINATE;
  78. }
  79. static int eeepc_wmi_check_atkd(void)
  80. {
  81. acpi_status status;
  82. bool found = false;
  83. status = acpi_get_devices(EEEPC_ACPI_HID, eeepc_wmi_parse_device,
  84. &found, NULL);
  85. if (ACPI_FAILURE(status) || !found)
  86. return 0;
  87. return -1;
  88. }
  89. static int eeepc_wmi_probe(struct platform_device *pdev)
  90. {
  91. if (eeepc_wmi_check_atkd()) {
  92. pr_warn("WMI device present, but legacy ATKD device is also "
  93. "present and enabled\n");
  94. pr_warn("You probably booted with acpi_osi=\"Linux\" or "
  95. "acpi_osi=\"!Windows 2009\"\n");
  96. pr_warn("Can't load eeepc-wmi, use default acpi_osi "
  97. "(preferred) or eeepc-laptop\n");
  98. return -EBUSY;
  99. }
  100. return 0;
  101. }
  102. static void eeepc_dmi_check(struct asus_wmi_driver *driver)
  103. {
  104. const char *model;
  105. model = dmi_get_system_info(DMI_PRODUCT_NAME);
  106. if (!model)
  107. return;
  108. /*
  109. * Whitelist for wlan hotplug
  110. *
  111. * Asus 1000H needs the current hotplug code to handle
  112. * Fn+F2 correctly. We may add other Asus here later, but
  113. * it seems that most of the laptops supported by asus-wmi
  114. * don't need to be on this list
  115. */
  116. if (strcmp(model, "1000H") == 0) {
  117. driver->hotplug_wireless = true;
  118. pr_info("wlan hotplug enabled\n");
  119. }
  120. }
  121. static void eeepc_wmi_quirks(struct asus_wmi_driver *driver)
  122. {
  123. driver->hotplug_wireless = hotplug_wireless;
  124. eeepc_dmi_check(driver);
  125. }
  126. static struct asus_wmi_driver asus_wmi_driver = {
  127. .name = EEEPC_WMI_FILE,
  128. .owner = THIS_MODULE,
  129. .event_guid = EEEPC_WMI_EVENT_GUID,
  130. .keymap = eeepc_wmi_keymap,
  131. .input_name = "Eee PC WMI hotkeys",
  132. .input_phys = EEEPC_WMI_FILE "/input0",
  133. .probe = eeepc_wmi_probe,
  134. .quirks = eeepc_wmi_quirks,
  135. };
  136. static int __init eeepc_wmi_init(void)
  137. {
  138. return asus_wmi_register_driver(&asus_wmi_driver);
  139. }
  140. static void __exit eeepc_wmi_exit(void)
  141. {
  142. asus_wmi_unregister_driver(&asus_wmi_driver);
  143. }
  144. module_init(eeepc_wmi_init);
  145. module_exit(eeepc_wmi_exit);