mxm-wmi.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * MXM WMI driver
  4. *
  5. * Copyright(C) 2010 Red Hat.
  6. */
  7. #include <linux/kernel.h>
  8. #include <linux/module.h>
  9. #include <linux/init.h>
  10. #include <linux/mxm-wmi.h>
  11. #include <linux/acpi.h>
  12. MODULE_AUTHOR("Dave Airlie");
  13. MODULE_DESCRIPTION("MXM WMI Driver");
  14. MODULE_LICENSE("GPL");
  15. #define MXM_WMMX_GUID "F6CB5C3C-9CAE-4EBD-B577-931EA32A2CC0"
  16. MODULE_ALIAS("wmi:"MXM_WMMX_GUID);
  17. #define MXM_WMMX_FUNC_MXDS 0x5344584D /* "MXDS" */
  18. #define MXM_WMMX_FUNC_MXMX 0x53445344 /* "MXMX" */
  19. struct mxds_args {
  20. u32 func;
  21. u32 args;
  22. u32 xarg;
  23. };
  24. int mxm_wmi_call_mxds(int adapter)
  25. {
  26. struct mxds_args args = {
  27. .func = MXM_WMMX_FUNC_MXDS,
  28. .args = 0,
  29. .xarg = 1,
  30. };
  31. struct acpi_buffer input = { (acpi_size)sizeof(args), &args };
  32. acpi_status status;
  33. printk("calling mux switch %d\n", adapter);
  34. status = wmi_evaluate_method(MXM_WMMX_GUID, 0x0, adapter, &input, NULL);
  35. if (ACPI_FAILURE(status))
  36. return status;
  37. printk("mux switched %d\n", status);
  38. return 0;
  39. }
  40. EXPORT_SYMBOL_GPL(mxm_wmi_call_mxds);
  41. int mxm_wmi_call_mxmx(int adapter)
  42. {
  43. struct mxds_args args = {
  44. .func = MXM_WMMX_FUNC_MXMX,
  45. .args = 0,
  46. .xarg = 1,
  47. };
  48. struct acpi_buffer input = { (acpi_size)sizeof(args), &args };
  49. acpi_status status;
  50. printk("calling mux switch %d\n", adapter);
  51. status = wmi_evaluate_method(MXM_WMMX_GUID, 0x0, adapter, &input, NULL);
  52. if (ACPI_FAILURE(status))
  53. return status;
  54. printk("mux mutex set switched %d\n", status);
  55. return 0;
  56. }
  57. EXPORT_SYMBOL_GPL(mxm_wmi_call_mxmx);
  58. bool mxm_wmi_supported(void)
  59. {
  60. bool guid_valid;
  61. guid_valid = wmi_has_guid(MXM_WMMX_GUID);
  62. return guid_valid;
  63. }
  64. EXPORT_SYMBOL_GPL(mxm_wmi_supported);
  65. static int __init mxm_wmi_init(void)
  66. {
  67. return 0;
  68. }
  69. static void __exit mxm_wmi_exit(void)
  70. {
  71. }
  72. module_init(mxm_wmi_init);
  73. module_exit(mxm_wmi_exit);