asus-nb-wmi.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Asus Notebooks WMI hotkey driver
  3. *
  4. * Copyright(C) 2010 Corentin Chary <corentin.chary@gmail.com>
  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 as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  21. #include <linux/kernel.h>
  22. #include <linux/module.h>
  23. #include <linux/init.h>
  24. #include <linux/input.h>
  25. #include <linux/input/sparse-keymap.h>
  26. #include "asus-wmi.h"
  27. #define ASUS_NB_WMI_FILE "asus-nb-wmi"
  28. MODULE_AUTHOR("Corentin Chary <corentincj@iksaif.net>");
  29. MODULE_DESCRIPTION("Asus Notebooks WMI Hotkey Driver");
  30. MODULE_LICENSE("GPL");
  31. #define ASUS_NB_WMI_EVENT_GUID "0B3CBB35-E3C2-45ED-91C2-4C5A6D195D1C"
  32. MODULE_ALIAS("wmi:"ASUS_NB_WMI_EVENT_GUID);
  33. static const struct key_entry asus_nb_wmi_keymap[] = {
  34. { KE_KEY, 0x30, { KEY_VOLUMEUP } },
  35. { KE_KEY, 0x31, { KEY_VOLUMEDOWN } },
  36. { KE_KEY, 0x32, { KEY_MUTE } },
  37. { KE_KEY, 0x33, { KEY_DISPLAYTOGGLE } }, /* LCD on */
  38. { KE_KEY, 0x34, { KEY_DISPLAY_OFF } }, /* LCD off */
  39. { KE_KEY, 0x40, { KEY_PREVIOUSSONG } },
  40. { KE_KEY, 0x41, { KEY_NEXTSONG } },
  41. { KE_KEY, 0x43, { KEY_STOPCD } },
  42. { KE_KEY, 0x45, { KEY_PLAYPAUSE } },
  43. { KE_KEY, 0x4c, { KEY_MEDIA } },
  44. { KE_KEY, 0x50, { KEY_EMAIL } },
  45. { KE_KEY, 0x51, { KEY_WWW } },
  46. { KE_KEY, 0x55, { KEY_CALC } },
  47. { KE_KEY, 0x5C, { KEY_F15 } }, /* Power Gear key */
  48. { KE_KEY, 0x5D, { KEY_WLAN } },
  49. { KE_KEY, 0x5E, { KEY_WLAN } },
  50. { KE_KEY, 0x5F, { KEY_WLAN } },
  51. { KE_KEY, 0x60, { KEY_SWITCHVIDEOMODE } },
  52. { KE_KEY, 0x61, { KEY_SWITCHVIDEOMODE } },
  53. { KE_KEY, 0x62, { KEY_SWITCHVIDEOMODE } },
  54. { KE_KEY, 0x63, { KEY_SWITCHVIDEOMODE } },
  55. { KE_KEY, 0x6B, { KEY_TOUCHPAD_TOGGLE } },
  56. { KE_KEY, 0x7E, { KEY_BLUETOOTH } },
  57. { KE_KEY, 0x7D, { KEY_BLUETOOTH } },
  58. { KE_KEY, 0x82, { KEY_CAMERA } },
  59. { KE_KEY, 0x88, { KEY_RFKILL } },
  60. { KE_KEY, 0x8A, { KEY_PROG1 } },
  61. { KE_KEY, 0x95, { KEY_MEDIA } },
  62. { KE_KEY, 0x99, { KEY_PHONE } },
  63. { KE_KEY, 0xb5, { KEY_CALC } },
  64. { KE_KEY, 0xc4, { KEY_KBDILLUMUP } },
  65. { KE_KEY, 0xc5, { KEY_KBDILLUMDOWN } },
  66. { KE_END, 0},
  67. };
  68. static struct asus_wmi_driver asus_nb_wmi_driver = {
  69. .name = ASUS_NB_WMI_FILE,
  70. .owner = THIS_MODULE,
  71. .event_guid = ASUS_NB_WMI_EVENT_GUID,
  72. .keymap = asus_nb_wmi_keymap,
  73. .input_name = "Asus WMI hotkeys",
  74. .input_phys = ASUS_NB_WMI_FILE "/input0",
  75. };
  76. static int __init asus_nb_wmi_init(void)
  77. {
  78. return asus_wmi_register_driver(&asus_nb_wmi_driver);
  79. }
  80. static void __exit asus_nb_wmi_exit(void)
  81. {
  82. asus_wmi_unregister_driver(&asus_nb_wmi_driver);
  83. }
  84. module_init(asus_nb_wmi_init);
  85. module_exit(asus_nb_wmi_exit);