asus-wireless.c 2.1 KB

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