blob: 3c59c0a3ee0f0f2d57a895f853d6915c37d39822 [file] [log] [blame]
Dave Airlie99b38b42010-12-06 12:43:33 +10001/*
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>
Lv Zheng8b484632013-12-03 08:49:16 +080023#include <linux/acpi.h>
Dave Airlie99b38b42010-12-06 12:43:33 +100024
25MODULE_AUTHOR("Dave Airlie");
26MODULE_DESCRIPTION("MXM WMI Driver");
27MODULE_LICENSE("GPL");
28
29#define MXM_WMMX_GUID "F6CB5C3C-9CAE-4EBD-B577-931EA32A2CC0"
30
31MODULE_ALIAS("wmi:"MXM_WMMX_GUID);
32
33#define MXM_WMMX_FUNC_MXDS 0x5344584D /* "MXDS" */
Dave Airlie000703f2011-05-09 11:40:25 +100034#define MXM_WMMX_FUNC_MXMX 0x53445344 /* "MXMX" */
Dave Airlie99b38b42010-12-06 12:43:33 +100035
36struct mxds_args {
37 u32 func;
38 u32 args;
39 u32 xarg;
40};
41
42int mxm_wmi_call_mxds(int adapter)
43{
44 struct mxds_args args = {
45 .func = MXM_WMMX_FUNC_MXDS,
46 .args = 0,
47 .xarg = 1,
48 };
49 struct acpi_buffer input = { (acpi_size)sizeof(args), &args };
50 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
51 acpi_status status;
52
53 printk("calling mux switch %d\n", adapter);
Dave Airlie000703f2011-05-09 11:40:25 +100054
Dave Airlie99b38b42010-12-06 12:43:33 +100055 status = wmi_evaluate_method(MXM_WMMX_GUID, 0x1, adapter, &input,
56 &output);
57
58 if (ACPI_FAILURE(status))
59 return status;
60
61 printk("mux switched %d\n", status);
62 return 0;
63
64}
65EXPORT_SYMBOL_GPL(mxm_wmi_call_mxds);
66
Dave Airlie000703f2011-05-09 11:40:25 +100067int mxm_wmi_call_mxmx(int adapter)
68{
69 struct mxds_args args = {
70 .func = MXM_WMMX_FUNC_MXMX,
71 .args = 0,
72 .xarg = 1,
73 };
74 struct acpi_buffer input = { (acpi_size)sizeof(args), &args };
75 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
76 acpi_status status;
77
78 printk("calling mux switch %d\n", adapter);
79
80 status = wmi_evaluate_method(MXM_WMMX_GUID, 0x1, adapter, &input,
81 &output);
82
83 if (ACPI_FAILURE(status))
84 return status;
85
86 printk("mux mutex set switched %d\n", status);
87 return 0;
88
89}
90EXPORT_SYMBOL_GPL(mxm_wmi_call_mxmx);
91
Dave Airlie99b38b42010-12-06 12:43:33 +100092bool mxm_wmi_supported(void)
93{
94 bool guid_valid;
95 guid_valid = wmi_has_guid(MXM_WMMX_GUID);
96 return guid_valid;
97}
98EXPORT_SYMBOL_GPL(mxm_wmi_supported);
99
100static int __init mxm_wmi_init(void)
101{
102 return 0;
103}
104
105static void __exit mxm_wmi_exit(void)
106{
107}
108
109module_init(mxm_wmi_init);
110module_exit(mxm_wmi_exit);