Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v5.2-rc5 100 lines 2.0 kB view raw
1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * Airplane mode button for HP & Xiaomi laptops 4 * 5 * Copyright (C) 2014-2017 Alex Hung <alex.hung@canonical.com> 6 */ 7 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> 15 16MODULE_LICENSE("GPL"); 17MODULE_AUTHOR("Alex Hung"); 18MODULE_ALIAS("acpi*:HPQ6001:*"); 19MODULE_ALIAS("acpi*:WSTADEF:*"); 20 21static struct input_dev *hpwl_input_dev; 22 23static const struct acpi_device_id hpwl_ids[] = { 24 {"HPQ6001", 0}, 25 {"WSTADEF", 0}, 26 {"", 0}, 27}; 28 29static int hp_wireless_input_setup(void) 30{ 31 int err; 32 33 hpwl_input_dev = input_allocate_device(); 34 if (!hpwl_input_dev) 35 return -ENOMEM; 36 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); 42 43 err = input_register_device(hpwl_input_dev); 44 if (err) 45 goto err_free_dev; 46 47 return 0; 48 49err_free_dev: 50 input_free_device(hpwl_input_dev); 51 return err; 52} 53 54static void hp_wireless_input_destroy(void) 55{ 56 input_unregister_device(hpwl_input_dev); 57} 58 59static void hpwl_notify(struct acpi_device *acpi_dev, u32 event) 60{ 61 if (event != 0x80) { 62 pr_info("Received unknown event (0x%x)\n", event); 63 return; 64 } 65 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); 70} 71 72static int hpwl_add(struct acpi_device *device) 73{ 74 int err; 75 76 err = hp_wireless_input_setup(); 77 if (err) 78 pr_err("Failed to setup hp wireless hotkeys\n"); 79 80 return err; 81} 82 83static int hpwl_remove(struct acpi_device *device) 84{ 85 hp_wireless_input_destroy(); 86 return 0; 87} 88 89static struct acpi_driver hpwl_driver = { 90 .name = "hp-wireless", 91 .owner = THIS_MODULE, 92 .ids = hpwl_ids, 93 .ops = { 94 .add = hpwl_add, 95 .remove = hpwl_remove, 96 .notify = hpwl_notify, 97 }, 98}; 99 100module_acpi_driver(hpwl_driver);