1 /*
2 * Acer Wireless Radio Control Driver
3 *
4 * Copyright (C) 2017 Endless Mobile, Inc.
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 version 2 as
8 * published by the Free Software Foundation.
9 */
10
11 #include <linux/acpi.h>
12 #include <linux/input.h>
13 #include <linux/kernel.h>
14 #include <linux/module.h>
15 #include <linux/pci_ids.h>
16 #include <linux/types.h>
17
18 static const struct acpi_device_id acer_wireless_acpi_ids[] = {
19 {"10251229", 0},
20 {"", 0},
21 };
22 MODULE_DEVICE_TABLE(acpi, acer_wireless_acpi_ids);
23
acer_wireless_notify(struct acpi_device * adev,u32 event)24 static void acer_wireless_notify(struct acpi_device *adev, u32 event)
25 {
26 struct input_dev *idev = acpi_driver_data(adev);
27
28 dev_dbg(&adev->dev, "event=%#x\n", event);
29 if (event != 0x80) {
30 dev_notice(&adev->dev, "Unknown SMKB event: %#x\n", event);
31 return;
32 }
33 input_report_key(idev, KEY_RFKILL, 1);
34 input_report_key(idev, KEY_RFKILL, 0);
35 input_sync(idev);
36 }
37
acer_wireless_add(struct acpi_device * adev)38 static int acer_wireless_add(struct acpi_device *adev)
39 {
40 struct input_dev *idev;
41
42 idev = devm_input_allocate_device(&adev->dev);
43 if (!idev)
44 return -ENOMEM;
45
46 adev->driver_data = idev;
47 idev->name = "Acer Wireless Radio Control";
48 idev->phys = "acer-wireless/input0";
49 idev->id.bustype = BUS_HOST;
50 idev->id.vendor = PCI_VENDOR_ID_AI;
51 idev->id.product = 0x1229;
52 set_bit(EV_KEY, idev->evbit);
53 set_bit(KEY_RFKILL, idev->keybit);
54
55 return input_register_device(idev);
56 }
57
58 static struct acpi_driver acer_wireless_driver = {
59 .name = "Acer Wireless Radio Control Driver",
60 .class = "hotkey",
61 .ids = acer_wireless_acpi_ids,
62 .ops = {
63 .add = acer_wireless_add,
64 .notify = acer_wireless_notify,
65 },
66 };
67 module_acpi_driver(acer_wireless_driver);
68
69 MODULE_DESCRIPTION("Acer Wireless Radio Control Driver");
70 MODULE_AUTHOR("Chris Chiu <chiu@gmail.com>");
71 MODULE_LICENSE("GPL v2");
72