More cleanup
This commit is contained in:
parent
4d498a203a
commit
5cb0a4f693
45
dmi.c
45
dmi.c
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* dmi.c
|
||||
*
|
||||
* Copyright (C) 2017 Jeremy Soller <jeremy@system76.com>
|
||||
* Copyright (C) 2014-2016 Arnoud Willemsen <mail@lynthium.com>
|
||||
* Copyright (C) 2013-2015 TUXEDO Computers GmbH <tux@tuxedocomputers.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
static int __init s76_dmi_matched(const struct dmi_system_id *id)
|
||||
{
|
||||
S76_INFO("Model %s found\n", id->ident);
|
||||
kb_backlight.ops = id->driver_data;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#define DMI_TABLE(PRODUCT, DATA) { \
|
||||
.ident = "System76 " PRODUCT, \
|
||||
.matches = { \
|
||||
DMI_MATCH(DMI_SYS_VENDOR, "System76"), \
|
||||
DMI_MATCH(DMI_PRODUCT_VERSION, PRODUCT), \
|
||||
}, \
|
||||
.callback = s76_dmi_matched, \
|
||||
.driver_data = &DATA, \
|
||||
}
|
||||
|
||||
static struct dmi_system_id s76_dmi_table[] __initdata = {
|
||||
DMI_TABLE("bonw13", kb_full_color_with_extra_ops),
|
||||
{}
|
||||
};
|
||||
|
||||
MODULE_DEVICE_TABLE(dmi, s76_dmi_table);
|
||||
16
kb.c
16
kb.c
|
|
@ -273,7 +273,7 @@ static void kb_full_color__set_color(unsigned left, unsigned center,
|
|||
cmd |= kb_colors[left].value.r << 8;
|
||||
cmd |= kb_colors[left].value.g << 0;
|
||||
|
||||
if (!s76_wmi_evaluate_wmbb_method(SET_KB_LED, cmd, NULL))
|
||||
if (!s76_wmbb(SET_KB_LED, cmd, NULL))
|
||||
kb_backlight.color.left = left;
|
||||
|
||||
cmd = 0xF1000000;
|
||||
|
|
@ -281,7 +281,7 @@ static void kb_full_color__set_color(unsigned left, unsigned center,
|
|||
cmd |= kb_colors[center].value.r << 8;
|
||||
cmd |= kb_colors[center].value.g << 0;
|
||||
|
||||
if (!s76_wmi_evaluate_wmbb_method(SET_KB_LED, cmd, NULL))
|
||||
if (!s76_wmbb(SET_KB_LED, cmd, NULL))
|
||||
kb_backlight.color.center = center;
|
||||
|
||||
cmd = 0xF2000000;
|
||||
|
|
@ -289,7 +289,7 @@ static void kb_full_color__set_color(unsigned left, unsigned center,
|
|||
cmd |= kb_colors[right].value.r << 8;
|
||||
cmd |= kb_colors[right].value.g << 0;
|
||||
|
||||
if (!s76_wmi_evaluate_wmbb_method(SET_KB_LED, cmd, NULL))
|
||||
if (!s76_wmbb(SET_KB_LED, cmd, NULL))
|
||||
kb_backlight.color.right = right;
|
||||
|
||||
if (kb_backlight.extra == KB_HAS_EXTRA_TRUE) {
|
||||
|
|
@ -298,7 +298,7 @@ static void kb_full_color__set_color(unsigned left, unsigned center,
|
|||
cmd |= kb_colors[extra].value.r << 8;
|
||||
cmd |= kb_colors[extra].value.g << 0;
|
||||
|
||||
if(!s76_wmi_evaluate_wmbb_method(SET_KB_LED, cmd, NULL))
|
||||
if(!s76_wmbb(SET_KB_LED, cmd, NULL))
|
||||
kb_backlight.color.extra = extra;
|
||||
}
|
||||
|
||||
|
|
@ -311,7 +311,7 @@ static void kb_full_color__set_brightness(unsigned i)
|
|||
|
||||
i = clamp_t(unsigned, i, 0, ARRAY_SIZE(lvl_to_raw) - 1);
|
||||
|
||||
if (!s76_wmi_evaluate_wmbb_method(SET_KB_LED,
|
||||
if (!s76_wmbb(SET_KB_LED,
|
||||
0xF4000000 | lvl_to_raw[i], NULL))
|
||||
kb_backlight.brightness = i;
|
||||
}
|
||||
|
|
@ -331,7 +331,7 @@ static void kb_full_color__set_mode(unsigned mode)
|
|||
|
||||
BUG_ON(mode >= ARRAY_SIZE(cmds));
|
||||
|
||||
s76_wmi_evaluate_wmbb_method(SET_KB_LED, 0x10000000, NULL);
|
||||
s76_wmbb(SET_KB_LED, 0x10000000, NULL);
|
||||
|
||||
if (mode == KB_MODE_CUSTOM) {
|
||||
kb_full_color__set_color(kb_backlight.color.left,
|
||||
|
|
@ -342,7 +342,7 @@ static void kb_full_color__set_mode(unsigned mode)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!s76_wmi_evaluate_wmbb_method(SET_KB_LED, cmds[mode], NULL))
|
||||
if (!s76_wmbb(SET_KB_LED, cmds[mode], NULL))
|
||||
kb_backlight.mode = mode;
|
||||
}
|
||||
|
||||
|
|
@ -363,7 +363,7 @@ static void kb_full_color__set_state(enum kb_state state)
|
|||
BUG();
|
||||
}
|
||||
|
||||
if (!s76_wmi_evaluate_wmbb_method(SET_KB_LED, cmd, NULL))
|
||||
if (!s76_wmbb(SET_KB_LED, cmd, NULL))
|
||||
kb_backlight.state = state;
|
||||
}
|
||||
|
||||
|
|
|
|||
122
system76.c
122
system76.c
|
|
@ -60,9 +60,7 @@
|
|||
|
||||
struct platform_device *s76_platform_device;
|
||||
|
||||
static int s76_wmi_evaluate_wmbb_method(u32 method_id, u32 arg,
|
||||
u32 *retval)
|
||||
{
|
||||
static int s76_wmbb(u32 method_id, u32 arg, u32 *retval) {
|
||||
struct acpi_buffer in = { (acpi_size) sizeof(arg), &arg };
|
||||
struct acpi_buffer out = { ACPI_ALLOCATE_BUFFER, NULL };
|
||||
union acpi_object *obj;
|
||||
|
|
@ -71,45 +69,121 @@ static int s76_wmi_evaluate_wmbb_method(u32 method_id, u32 arg,
|
|||
|
||||
S76_DEBUG("%0#4x IN : %0#6x\n", method_id, arg);
|
||||
|
||||
status = wmi_evaluate_method(S76_GET_GUID, 0x01,
|
||||
method_id, &in, &out);
|
||||
status = wmi_evaluate_method(S76_GET_GUID, 0x01, method_id, &in, &out);
|
||||
|
||||
if (unlikely(ACPI_FAILURE(status)))
|
||||
goto exit;
|
||||
if (unlikely(ACPI_FAILURE(status))) {
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
obj = (union acpi_object *) out.pointer;
|
||||
if (obj && obj->type == ACPI_TYPE_INTEGER)
|
||||
if (obj && obj->type == ACPI_TYPE_INTEGER) {
|
||||
tmp = (u32) obj->integer.value;
|
||||
else
|
||||
} else {
|
||||
tmp = 0;
|
||||
}
|
||||
|
||||
S76_DEBUG("%0#4x OUT: %0#6x (IN: %0#6x)\n", method_id, tmp, arg);
|
||||
|
||||
if (likely(retval))
|
||||
if (likely(retval)) {
|
||||
*retval = tmp;
|
||||
}
|
||||
|
||||
kfree(obj);
|
||||
|
||||
exit:
|
||||
if (unlikely(ACPI_FAILURE(status)))
|
||||
return -EIO;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include "led.c"
|
||||
#include "input.c"
|
||||
|
||||
#include "kb.c"
|
||||
|
||||
#include "wmi.c"
|
||||
|
||||
#include "fan.c"
|
||||
|
||||
#include "dmi.c"
|
||||
static void s76_wmi_notify(u32 value, void *context) {
|
||||
u32 event;
|
||||
|
||||
static int __init s76_init(void)
|
||||
{
|
||||
if (value != 0xD0) {
|
||||
S76_INFO("Unexpected WMI event (%0#6x)\n", value);
|
||||
return;
|
||||
}
|
||||
|
||||
s76_wmbb(GET_EVENT, 0, &event);
|
||||
|
||||
S76_INFO("WMI event code (%x)\n", event);
|
||||
|
||||
switch (event) {
|
||||
case 0xF4:
|
||||
s76_input_airplane_wmi();
|
||||
break;
|
||||
default:
|
||||
kb_wmi(event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static int s76_probe(struct platform_device *dev) {
|
||||
int status;
|
||||
|
||||
status = wmi_install_notify_handler(S76_EVENT_GUID, s76_wmi_notify, NULL);
|
||||
if (unlikely(ACPI_FAILURE(status))) {
|
||||
S76_ERROR("Could not register WMI notify handler (%0#6x)\n", status);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
if (kb_backlight.ops) {
|
||||
kb_backlight.ops->init();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int s76_remove(struct platform_device *dev) {
|
||||
wmi_remove_notify_handler(S76_EVENT_GUID);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int s76_resume(struct platform_device *dev) {
|
||||
if (kb_backlight.ops && kb_backlight.state == KB_STATE_ON) {
|
||||
kb_backlight.ops->set_mode(kb_backlight.mode);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct platform_driver s76_platform_driver = {
|
||||
.remove = s76_remove,
|
||||
.resume = s76_resume,
|
||||
.driver = {
|
||||
.name = S76_DRIVER_NAME,
|
||||
.owner = THIS_MODULE,
|
||||
},
|
||||
};
|
||||
|
||||
static int __init s76_dmi_matched(const struct dmi_system_id *id) {
|
||||
S76_INFO("Model %s found\n", id->ident);
|
||||
kb_backlight.ops = id->driver_data;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#define DMI_TABLE(PRODUCT, DATA) { \
|
||||
.ident = "System76 " PRODUCT, \
|
||||
.matches = { \
|
||||
DMI_MATCH(DMI_SYS_VENDOR, "System76"), \
|
||||
DMI_MATCH(DMI_PRODUCT_VERSION, PRODUCT), \
|
||||
}, \
|
||||
.callback = s76_dmi_matched, \
|
||||
.driver_data = &DATA, \
|
||||
}
|
||||
|
||||
static struct dmi_system_id s76_dmi_table[] __initdata = {
|
||||
DMI_TABLE("bonw13", kb_full_color_ops),
|
||||
{}
|
||||
};
|
||||
|
||||
MODULE_DEVICE_TABLE(dmi, s76_dmi_table);
|
||||
|
||||
static int __init s76_init(void) {
|
||||
int err;
|
||||
|
||||
switch (param_kb_color_num) {
|
||||
|
|
@ -133,8 +207,7 @@ static int __init s76_init(void)
|
|||
}
|
||||
|
||||
s76_platform_device =
|
||||
platform_create_bundle(&s76_platform_driver,
|
||||
s76_wmi_probe, NULL, 0, NULL, 0);
|
||||
platform_create_bundle(&s76_platform_driver, s76_probe, NULL, 0, NULL, 0);
|
||||
|
||||
if (unlikely(IS_ERR(s76_platform_device))) {
|
||||
return PTR_ERR(s76_platform_device);
|
||||
|
|
@ -173,8 +246,7 @@ static int __init s76_init(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void __exit s76_exit(void)
|
||||
{
|
||||
static void __exit s76_exit(void) {
|
||||
#ifdef S76_HAS_HWMON
|
||||
s76_hwmon_fini(&s76_platform_device->dev);
|
||||
#endif
|
||||
|
|
|
|||
84
wmi.c
84
wmi.c
|
|
@ -1,84 +0,0 @@
|
|||
/*
|
||||
* wmi.c
|
||||
*
|
||||
* Copyright (C) 2017 Jeremy Soller <jeremy@system76.com>
|
||||
* Copyright (C) 2014-2016 Arnoud Willemsen <mail@lynthium.com>
|
||||
* Copyright (C) 2013-2015 TUXEDO Computers GmbH <tux@tuxedocomputers.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
static void s76_wmi_notify(u32 value, void *context)
|
||||
{
|
||||
u32 event;
|
||||
|
||||
if (value != 0xD0) {
|
||||
S76_INFO("Unexpected WMI event (%0#6x)\n", value);
|
||||
return;
|
||||
}
|
||||
|
||||
s76_wmi_evaluate_wmbb_method(GET_EVENT, 0, &event);
|
||||
|
||||
S76_INFO("WMI event code (%x)\n", event);
|
||||
|
||||
switch (event) {
|
||||
case 0xF4:
|
||||
s76_input_airplane_wmi();
|
||||
break;
|
||||
default:
|
||||
kb_wmi(event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static int s76_wmi_probe(struct platform_device *dev)
|
||||
{
|
||||
int status;
|
||||
|
||||
status = wmi_install_notify_handler(S76_EVENT_GUID,
|
||||
s76_wmi_notify, NULL);
|
||||
if (unlikely(ACPI_FAILURE(status))) {
|
||||
S76_ERROR("Could not register WMI notify handler (%0#6x)\n",
|
||||
status);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
if (kb_backlight.ops)
|
||||
kb_backlight.ops->init();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int s76_wmi_remove(struct platform_device *dev)
|
||||
{
|
||||
wmi_remove_notify_handler(S76_EVENT_GUID);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int s76_wmi_resume(struct platform_device *dev)
|
||||
{
|
||||
if (kb_backlight.ops && kb_backlight.state == KB_STATE_ON)
|
||||
kb_backlight.ops->set_mode(kb_backlight.mode);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct platform_driver s76_platform_driver = {
|
||||
.remove = s76_wmi_remove,
|
||||
.resume = s76_wmi_resume,
|
||||
.driver = {
|
||||
.name = S76_DRIVER_NAME,
|
||||
.owner = THIS_MODULE,
|
||||
},
|
||||
};
|
||||
Loading…
Reference in New Issue