blob: 9ec721e26532531e69d5a1decb5da4926b402282 [file] [log] [blame]
João Paulo Rechi Vitaf6a6bba2016-01-05 11:16:53 -05001/*
2 * Asus Wireless Radio Control Driver
3 *
4 * Copyright (C) 2015-2016 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/kernel.h>
12#include <linux/module.h>
13#include <linux/init.h>
14#include <linux/types.h>
15#include <linux/acpi.h>
16#include <linux/input.h>
17#include <linux/pci_ids.h>
18
19struct asus_wireless_data {
20 struct input_dev *idev;
21};
22
23static void asus_wireless_notify(struct acpi_device *adev, u32 event)
24{
25 struct asus_wireless_data *data = acpi_driver_data(adev);
26
27 dev_dbg(&adev->dev, "event=%#x\n", event);
28 if (event != 0x88) {
29 dev_notice(&adev->dev, "Unknown ASHS event: %#x\n", event);
30 return;
31 }
32 input_report_key(data->idev, KEY_RFKILL, 1);
33 input_report_key(data->idev, KEY_RFKILL, 0);
34 input_sync(data->idev);
35}
36
37static int asus_wireless_add(struct acpi_device *adev)
38{
39 struct asus_wireless_data *data;
40
41 data = devm_kzalloc(&adev->dev, sizeof(*data), GFP_KERNEL);
42 if (!data)
43 return -ENOMEM;
44 adev->driver_data = data;
45
46 data->idev = devm_input_allocate_device(&adev->dev);
47 if (!data->idev)
48 return -ENOMEM;
49 data->idev->name = "Asus Wireless Radio Control";
50 data->idev->phys = "asus-wireless/input0";
51 data->idev->id.bustype = BUS_HOST;
52 data->idev->id.vendor = PCI_VENDOR_ID_ASUSTEK;
53 set_bit(EV_KEY, data->idev->evbit);
54 set_bit(KEY_RFKILL, data->idev->keybit);
55 return input_register_device(data->idev);
56}
57
58static int asus_wireless_remove(struct acpi_device *adev)
59{
60 return 0;
61}
62
63static const struct acpi_device_id device_ids[] = {
João Paulo Rechi Vitab0a095f2016-01-05 08:26:01 -050064 {"ATK4001", 0},
João Paulo Rechi Vitaf6a6bba2016-01-05 11:16:53 -050065 {"ATK4002", 0},
66 {"", 0},
67};
68MODULE_DEVICE_TABLE(acpi, device_ids);
69
70static struct acpi_driver asus_wireless_driver = {
71 .name = "Asus Wireless Radio Control Driver",
72 .class = "hotkey",
73 .ids = device_ids,
74 .ops = {
75 .add = asus_wireless_add,
76 .remove = asus_wireless_remove,
77 .notify = asus_wireless_notify,
78 },
79};
80module_acpi_driver(asus_wireless_driver);
81
82MODULE_DESCRIPTION("Asus Wireless Radio Control Driver");
83MODULE_AUTHOR("João Paulo Rechi Vita <jprvita@gmail.com>");
84MODULE_LICENSE("GPL");