mxm-wmi.c 2.6 KB

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