diff options
| -rw-r--r-- | drivers/platform/x86/Kconfig | 11 | ||||
| -rw-r--r-- | drivers/platform/x86/Makefile | 1 | ||||
| -rw-r--r-- | drivers/platform/x86/hp-wireless.c | 132 |
3 files changed, 144 insertions, 0 deletions
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index a698b928327d..5ae65c11d544 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig | |||
| @@ -197,6 +197,17 @@ config HP_ACCEL | |||
| 197 | To compile this driver as a module, choose M here: the module will | 197 | To compile this driver as a module, choose M here: the module will |
| 198 | be called hp_accel. | 198 | be called hp_accel. |
| 199 | 199 | ||
| 200 | config HP_WIRELESS | ||
| 201 | tristate "HP WIRELESS" | ||
| 202 | depends on ACPI | ||
| 203 | depends on INPUT | ||
| 204 | help | ||
| 205 | This driver provides supports for new HP wireless button for Windows 8. | ||
| 206 | On such systems the driver should load automatically (via ACPI alias). | ||
| 207 | |||
| 208 | To compile this driver as a module, choose M here: the module will | ||
| 209 | be called hp-wireless. | ||
| 210 | |||
| 200 | config HP_WMI | 211 | config HP_WMI |
| 201 | tristate "HP WMI extras" | 212 | tristate "HP WMI extras" |
| 202 | depends on ACPI_WMI | 213 | depends on ACPI_WMI |
diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile index 79bd3c49be3d..9b87cfc42b84 100644 --- a/drivers/platform/x86/Makefile +++ b/drivers/platform/x86/Makefile | |||
| @@ -16,6 +16,7 @@ obj-$(CONFIG_DELL_WMI_AIO) += dell-wmi-aio.o | |||
| 16 | obj-$(CONFIG_ACER_WMI) += acer-wmi.o | 16 | obj-$(CONFIG_ACER_WMI) += acer-wmi.o |
| 17 | obj-$(CONFIG_ACERHDF) += acerhdf.o | 17 | obj-$(CONFIG_ACERHDF) += acerhdf.o |
| 18 | obj-$(CONFIG_HP_ACCEL) += hp_accel.o | 18 | obj-$(CONFIG_HP_ACCEL) += hp_accel.o |
| 19 | obj-$(CONFIG_HP_WIRELESS) += hp-wireless.o | ||
| 19 | obj-$(CONFIG_HP_WMI) += hp-wmi.o | 20 | obj-$(CONFIG_HP_WMI) += hp-wmi.o |
| 20 | obj-$(CONFIG_AMILO_RFKILL) += amilo-rfkill.o | 21 | obj-$(CONFIG_AMILO_RFKILL) += amilo-rfkill.o |
| 21 | obj-$(CONFIG_TC1100_WMI) += tc1100-wmi.o | 22 | obj-$(CONFIG_TC1100_WMI) += tc1100-wmi.o |
diff --git a/drivers/platform/x86/hp-wireless.c b/drivers/platform/x86/hp-wireless.c new file mode 100644 index 000000000000..415348fc1210 --- /dev/null +++ b/drivers/platform/x86/hp-wireless.c | |||
| @@ -0,0 +1,132 @@ | |||
| 1 | /* | ||
| 2 | * hp-wireless button for Windows 8 | ||
| 3 | * | ||
| 4 | * Copyright (C) 2014 Alex Hung <alex.hung@canonical.com> | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2 of the License, or | ||
| 9 | * (at your option) any later version. | ||
| 10 | * | ||
| 11 | * This program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License along | ||
| 17 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
| 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 19 | */ | ||
| 20 | |||
| 21 | #include <linux/kernel.h> | ||
| 22 | #include <linux/module.h> | ||
| 23 | #include <linux/init.h> | ||
| 24 | #include <linux/input.h> | ||
| 25 | #include <linux/platform_device.h> | ||
| 26 | #include <linux/acpi.h> | ||
| 27 | #include <acpi/acpi_bus.h> | ||
| 28 | |||
| 29 | MODULE_LICENSE("GPL"); | ||
| 30 | MODULE_AUTHOR("Alex Hung"); | ||
| 31 | MODULE_ALIAS("acpi*:HPQ6001:*"); | ||
| 32 | |||
| 33 | static struct input_dev *hpwl_input_dev; | ||
| 34 | |||
| 35 | static const struct acpi_device_id hpwl_ids[] = { | ||
| 36 | {"HPQ6001", 0}, | ||
| 37 | {"", 0}, | ||
| 38 | }; | ||
| 39 | |||
| 40 | static int hp_wireless_input_setup(void) | ||
| 41 | { | ||
| 42 | int err; | ||
| 43 | |||
| 44 | hpwl_input_dev = input_allocate_device(); | ||
| 45 | if (!hpwl_input_dev) | ||
| 46 | return -ENOMEM; | ||
| 47 | |||
| 48 | hpwl_input_dev->name = "HP Wireless hotkeys"; | ||
| 49 | hpwl_input_dev->phys = "hpq6001/input0"; | ||
| 50 | hpwl_input_dev->id.bustype = BUS_HOST; | ||
| 51 | hpwl_input_dev->evbit[0] = BIT(EV_KEY); | ||
| 52 | set_bit(KEY_RFKILL, hpwl_input_dev->keybit); | ||
| 53 | |||
| 54 | err = input_register_device(hpwl_input_dev); | ||
| 55 | if (err) | ||
| 56 | goto err_free_dev; | ||
| 57 | |||
| 58 | return 0; | ||
| 59 | |||
| 60 | err_free_dev: | ||
| 61 | input_free_device(hpwl_input_dev); | ||
| 62 | return err; | ||
| 63 | } | ||
| 64 | |||
| 65 | static void hp_wireless_input_destroy(void) | ||
| 66 | { | ||
| 67 | input_unregister_device(hpwl_input_dev); | ||
| 68 | } | ||
| 69 | |||
| 70 | static void hpwl_notify(struct acpi_device *acpi_dev, u32 event) | ||
| 71 | { | ||
| 72 | if (event != 0x80) { | ||
| 73 | pr_info("Received unknown event (0x%x)\n", event); | ||
| 74 | return; | ||
| 75 | } | ||
| 76 | |||
| 77 | input_report_key(hpwl_input_dev, KEY_RFKILL, 1); | ||
| 78 | input_sync(hpwl_input_dev); | ||
| 79 | input_report_key(hpwl_input_dev, KEY_RFKILL, 0); | ||
| 80 | input_sync(hpwl_input_dev); | ||
| 81 | } | ||
| 82 | |||
| 83 | static int hpwl_add(struct acpi_device *device) | ||
| 84 | { | ||
| 85 | int err; | ||
| 86 | |||
| 87 | err = hp_wireless_input_setup(); | ||
| 88 | return err; | ||
| 89 | } | ||
| 90 | |||
| 91 | static int hpwl_remove(struct acpi_device *device) | ||
| 92 | { | ||
| 93 | hp_wireless_input_destroy(); | ||
| 94 | return 0; | ||
| 95 | } | ||
| 96 | |||
| 97 | static struct acpi_driver hpwl_driver = { | ||
| 98 | .name = "hp-wireless", | ||
| 99 | .owner = THIS_MODULE, | ||
| 100 | .ids = hpwl_ids, | ||
| 101 | .ops = { | ||
| 102 | .add = hpwl_add, | ||
| 103 | .remove = hpwl_remove, | ||
| 104 | .notify = hpwl_notify, | ||
| 105 | }, | ||
| 106 | }; | ||
| 107 | |||
| 108 | static int __init hpwl_init(void) | ||
| 109 | { | ||
| 110 | int err; | ||
| 111 | |||
| 112 | pr_info("Initializing HPQ6001 module\n"); | ||
| 113 | err = acpi_bus_register_driver(&hpwl_driver); | ||
| 114 | if (err) { | ||
| 115 | pr_err("Unable to register HP wireless control driver.\n"); | ||
| 116 | goto error_acpi_register; | ||
| 117 | } | ||
| 118 | |||
| 119 | return 0; | ||
| 120 | |||
| 121 | error_acpi_register: | ||
| 122 | return err; | ||
| 123 | } | ||
| 124 | |||
| 125 | static void __exit hpwl_exit(void) | ||
| 126 | { | ||
| 127 | pr_info("Exiting HPQ6001 module\n"); | ||
| 128 | acpi_bus_unregister_driver(&hpwl_driver); | ||
| 129 | } | ||
| 130 | |||
| 131 | module_init(hpwl_init); | ||
| 132 | module_exit(hpwl_exit); | ||
