Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  * MXM WMI driver
0004  *
0005  * Copyright(C) 2010 Red Hat.
0006  */
0007 #include <linux/kernel.h>
0008 #include <linux/module.h>
0009 #include <linux/init.h>
0010 #include <linux/mxm-wmi.h>
0011 #include <linux/acpi.h>
0012 
0013 MODULE_AUTHOR("Dave Airlie");
0014 MODULE_DESCRIPTION("MXM WMI Driver");
0015 MODULE_LICENSE("GPL");
0016 
0017 #define MXM_WMMX_GUID "F6CB5C3C-9CAE-4EBD-B577-931EA32A2CC0"
0018 
0019 MODULE_ALIAS("wmi:"MXM_WMMX_GUID);
0020 
0021 #define MXM_WMMX_FUNC_MXDS 0x5344584D /* "MXDS" */
0022 #define MXM_WMMX_FUNC_MXMX 0x53445344 /* "MXMX" */
0023 
0024 struct mxds_args {
0025     u32 func;
0026     u32 args;
0027     u32 xarg;
0028 };
0029 
0030 int mxm_wmi_call_mxds(int adapter)
0031 {
0032     struct mxds_args args = {
0033         .func = MXM_WMMX_FUNC_MXDS,
0034         .args = 0,
0035         .xarg = 1,
0036     };
0037     struct acpi_buffer input = { (acpi_size)sizeof(args), &args };
0038     struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
0039     acpi_status status;
0040 
0041     printk("calling mux switch %d\n", adapter);
0042 
0043     status = wmi_evaluate_method(MXM_WMMX_GUID, 0x0, adapter, &input,
0044                      &output);
0045 
0046     if (ACPI_FAILURE(status))
0047         return status;
0048 
0049     printk("mux switched %d\n", status);
0050     return 0;
0051                 
0052 }
0053 EXPORT_SYMBOL_GPL(mxm_wmi_call_mxds);
0054 
0055 int mxm_wmi_call_mxmx(int adapter)
0056 {
0057     struct mxds_args args = {
0058         .func = MXM_WMMX_FUNC_MXMX,
0059         .args = 0,
0060         .xarg = 1,
0061     };
0062     struct acpi_buffer input = { (acpi_size)sizeof(args), &args };
0063     struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
0064     acpi_status status;
0065 
0066     printk("calling mux switch %d\n", adapter);
0067 
0068     status = wmi_evaluate_method(MXM_WMMX_GUID, 0x0, adapter, &input,
0069                      &output);
0070 
0071     if (ACPI_FAILURE(status))
0072         return status;
0073 
0074     printk("mux mutex set switched %d\n", status);
0075     return 0;
0076                 
0077 }
0078 EXPORT_SYMBOL_GPL(mxm_wmi_call_mxmx);
0079 
0080 bool mxm_wmi_supported(void)
0081 {
0082     bool guid_valid;
0083     guid_valid = wmi_has_guid(MXM_WMMX_GUID);
0084     return guid_valid;
0085 }
0086 EXPORT_SYMBOL_GPL(mxm_wmi_supported);
0087 
0088 static int __init mxm_wmi_init(void)
0089 {
0090     return 0;
0091 }
0092 
0093 static void __exit mxm_wmi_exit(void)
0094 {
0095 }
0096 
0097 module_init(mxm_wmi_init);
0098 module_exit(mxm_wmi_exit);