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