acer-wireless.c 1.8 KB

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