mxm-wmi.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * MXM WMI driver
  3. *
  4. * Copyright(C) 2010 Red Hat.
  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. #include <linux/kernel.h>
  21. #include <linux/module.h>
  22. #include <linux/init.h>
  23. #include <acpi/acpi_bus.h>
  24. #include <acpi/acpi_drivers.h>
  25. MODULE_AUTHOR("Dave Airlie");
  26. MODULE_DESCRIPTION("MXM WMI Driver");
  27. MODULE_LICENSE("GPL");
  28. #define MXM_WMMX_GUID "F6CB5C3C-9CAE-4EBD-B577-931EA32A2CC0"
  29. MODULE_ALIAS("wmi:"MXM_WMMX_GUID);
  30. #define MXM_WMMX_FUNC_MXDS 0x5344584D /* "MXDS" */
  31. #define MXM_WMMX_FUNC_MXMX 0x53445344 /* "MXMX" */
  32. struct mxds_args {
  33. u32 func;
  34. u32 args;
  35. u32 xarg;
  36. };
  37. int mxm_wmi_call_mxds(int adapter)
  38. {
  39. struct mxds_args args = {
  40. .func = MXM_WMMX_FUNC_MXDS,
  41. .args = 0,
  42. .xarg = 1,
  43. };
  44. struct acpi_buffer input = { (acpi_size)sizeof(args), &args };
  45. struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
  46. acpi_status status;
  47. printk("calling mux switch %d\n", adapter);
  48. status = wmi_evaluate_method(MXM_WMMX_GUID, 0x1, adapter, &input,
  49. &output);
  50. if (ACPI_FAILURE(status))
  51. return status;
  52. printk("mux switched %d\n", status);
  53. return 0;
  54. }
  55. EXPORT_SYMBOL_GPL(mxm_wmi_call_mxds);
  56. int mxm_wmi_call_mxmx(int adapter)
  57. {
  58. struct mxds_args args = {
  59. .func = MXM_WMMX_FUNC_MXMX,
  60. .args = 0,
  61. .xarg = 1,
  62. };
  63. struct acpi_buffer input = { (acpi_size)sizeof(args), &args };
  64. struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
  65. acpi_status status;
  66. printk("calling mux switch %d\n", adapter);
  67. status = wmi_evaluate_method(MXM_WMMX_GUID, 0x1, adapter, &input,
  68. &output);
  69. if (ACPI_FAILURE(status))
  70. return status;
  71. printk("mux mutex set switched %d\n", status);
  72. return 0;
  73. }
  74. EXPORT_SYMBOL_GPL(mxm_wmi_call_mxmx);
  75. bool mxm_wmi_supported(void)
  76. {
  77. bool guid_valid;
  78. guid_valid = wmi_has_guid(MXM_WMMX_GUID);
  79. return guid_valid;
  80. }
  81. EXPORT_SYMBOL_GPL(mxm_wmi_supported);
  82. static int __init mxm_wmi_init(void)
  83. {
  84. return 0;
  85. }
  86. static void __exit mxm_wmi_exit(void)
  87. {
  88. }
  89. module_init(mxm_wmi_init);
  90. module_exit(mxm_wmi_exit);