1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#include <linux/kernel.h>
21#include <linux/module.h>
22#include <linux/init.h>
23#include <linux/mxm-wmi.h>
24#include <linux/acpi.h>
25
26MODULE_AUTHOR("Dave Airlie");
27MODULE_DESCRIPTION("MXM WMI Driver");
28MODULE_LICENSE("GPL");
29
30#define MXM_WMMX_GUID "F6CB5C3C-9CAE-4EBD-B577-931EA32A2CC0"
31
32MODULE_ALIAS("wmi:"MXM_WMMX_GUID);
33
34#define MXM_WMMX_FUNC_MXDS 0x5344584D
35#define MXM_WMMX_FUNC_MXMX 0x53445344
36
37struct mxds_args {
38 u32 func;
39 u32 args;
40 u32 xarg;
41};
42
43int mxm_wmi_call_mxds(int adapter)
44{
45 struct mxds_args args = {
46 .func = MXM_WMMX_FUNC_MXDS,
47 .args = 0,
48 .xarg = 1,
49 };
50 struct acpi_buffer input = { (acpi_size)sizeof(args), &args };
51 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
52 acpi_status status;
53
54 printk("calling mux switch %d\n", adapter);
55
56 status = wmi_evaluate_method(MXM_WMMX_GUID, 0x0, adapter, &input,
57 &output);
58
59 if (ACPI_FAILURE(status))
60 return status;
61
62 printk("mux switched %d\n", status);
63 return 0;
64
65}
66EXPORT_SYMBOL_GPL(mxm_wmi_call_mxds);
67
68int mxm_wmi_call_mxmx(int adapter)
69{
70 struct mxds_args args = {
71 .func = MXM_WMMX_FUNC_MXMX,
72 .args = 0,
73 .xarg = 1,
74 };
75 struct acpi_buffer input = { (acpi_size)sizeof(args), &args };
76 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
77 acpi_status status;
78
79 printk("calling mux switch %d\n", adapter);
80
81 status = wmi_evaluate_method(MXM_WMMX_GUID, 0x0, adapter, &input,
82 &output);
83
84 if (ACPI_FAILURE(status))
85 return status;
86
87 printk("mux mutex set switched %d\n", status);
88 return 0;
89
90}
91EXPORT_SYMBOL_GPL(mxm_wmi_call_mxmx);
92
93bool mxm_wmi_supported(void)
94{
95 bool guid_valid;
96 guid_valid = wmi_has_guid(MXM_WMMX_GUID);
97 return guid_valid;
98}
99EXPORT_SYMBOL_GPL(mxm_wmi_supported);
100
101static int __init mxm_wmi_init(void)
102{
103 return 0;
104}
105
106static void __exit mxm_wmi_exit(void)
107{
108}
109
110module_init(mxm_wmi_init);
111module_exit(mxm_wmi_exit);
112