1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Airplane mode button for HP & Xiaomi laptops
5 * Copyright (C) 2014-2017 Alex Hung <alex.hung@canonical.com>
8 #include <linux/kernel.h>
9 #include <linux/module.h>
10 #include <linux/init.h>
11 #include <linux/input.h>
12 #include <linux/platform_device.h>
13 #include <linux/acpi.h>
14 #include <acpi/acpi_bus.h>
16 MODULE_LICENSE("GPL");
17 MODULE_AUTHOR("Alex Hung");
18 MODULE_ALIAS("acpi*:HPQ6001:*");
19 MODULE_ALIAS("acpi*:WSTADEF:*");
21 static struct input_dev
*hpwl_input_dev
;
23 static const struct acpi_device_id hpwl_ids
[] = {
29 static int hp_wireless_input_setup(void)
33 hpwl_input_dev
= input_allocate_device();
37 hpwl_input_dev
->name
= "HP Wireless hotkeys";
38 hpwl_input_dev
->phys
= "hpq6001/input0";
39 hpwl_input_dev
->id
.bustype
= BUS_HOST
;
40 hpwl_input_dev
->evbit
[0] = BIT(EV_KEY
);
41 set_bit(KEY_RFKILL
, hpwl_input_dev
->keybit
);
43 err
= input_register_device(hpwl_input_dev
);
50 input_free_device(hpwl_input_dev
);
54 static void hp_wireless_input_destroy(void)
56 input_unregister_device(hpwl_input_dev
);
59 static void hpwl_notify(struct acpi_device
*acpi_dev
, u32 event
)
62 pr_info("Received unknown event (0x%x)\n", event
);
66 input_report_key(hpwl_input_dev
, KEY_RFKILL
, 1);
67 input_sync(hpwl_input_dev
);
68 input_report_key(hpwl_input_dev
, KEY_RFKILL
, 0);
69 input_sync(hpwl_input_dev
);
72 static int hpwl_add(struct acpi_device
*device
)
76 err
= hp_wireless_input_setup();
78 pr_err("Failed to setup hp wireless hotkeys\n");
83 static int hpwl_remove(struct acpi_device
*device
)
85 hp_wireless_input_destroy();
89 static struct acpi_driver hpwl_driver
= {
90 .name
= "hp-wireless",
95 .remove
= hpwl_remove
,
96 .notify
= hpwl_notify
,
100 module_acpi_driver(hpwl_driver
);