Compare commits

..

No commits in common. "82f289d6e7b77b83a69c5152e4b4855d487068ba" and "cc41a3207954a003e40424fcd88aa28657c92ad5" have entirely different histories.

7 changed files with 200 additions and 125 deletions

19
debian/changelog vendored
View File

@ -1,22 +1,3 @@
system76-dkms (1.0.21-jdm1) jammy; urgency=medium
* Disable integration with the nv_hda driver
-- Jesse McDonald <jesse@jessemcdonald.info> Tue, 25 Nov 2025 00:25:19 -0600
system76-dkms (1.0.21) jammy; urgency=medium
* Add oryp13
-- Tim Crawford <tcrawford@system76.com> Tue, 16 Sep 2025 13:04:08 -0600
system76-dkms (1.0.20) focal; urgency=medium
* Refactor code
* Add addw5
-- Jeremy Soller <jeremy@system76.com> Tue, 01 Jul 2025 11:27:12 -0600
system76-dkms (1.0.19) focal; urgency=medium
* Add serw14

View File

@ -1,8 +1,20 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* ap_led.c
*
* Copyright (C) 2017 Jeremy Soller <jeremy@system76.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 enum led_brightness ap_led_brightness = 1;
@ -53,7 +65,7 @@ static struct led_classdev ap_led = {
static ssize_t ap_led_invert_show(struct device *dev, struct device_attribute *attr, char *buf)
{
return sysfs_emit(buf, "%d\n", (int)ap_led_invert);
return sprintf(buf, "%d\n", (int)ap_led_invert);
}
static ssize_t ap_led_invert_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size)
@ -98,13 +110,12 @@ static int __init ap_led_init(struct device *dev)
{
int err;
err = devm_led_classdev_register(dev, &ap_led);
if (err < 0) {
err = led_classdev_register(dev, &ap_led);
if (unlikely(err)) {
return err;
}
err = device_create_file(ap_led.dev, &ap_led_invert_dev_attr);
if (err < 0) {
if (device_create_file(ap_led.dev, &ap_led_invert_dev_attr) != 0) {
pr_err("failed to create ap_led_invert\n");
}
@ -116,4 +127,8 @@ static int __init ap_led_init(struct device *dev)
static void __exit ap_led_exit(void)
{
device_remove_file(ap_led.dev, &ap_led_invert_dev_attr);
if (!IS_ERR_OR_NULL(ap_led.dev)) {
led_classdev_unregister(&ap_led);
}
}

View File

@ -1,10 +1,22 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* fan.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/>.
*/
#define EXPERIMENTAL
@ -15,13 +27,12 @@ struct s76_hwmon {
struct device *dev;
};
static struct s76_hwmon *s76_hwmon;
static struct s76_hwmon *s76_hwmon = NULL;
static int s76_read_fan(int idx)
{
u8 value;
int raw_rpm;
ec_read(0xd0 + 0x2 * idx, &value);
raw_rpm = value << 8;
ec_read(0xd1 + 0x2 * idx, &value);
@ -34,7 +45,6 @@ static int s76_read_fan(int idx)
static int s76_read_pwm(int idx)
{
u8 value;
ec_read(0xce + idx, &value);
return value;
}
@ -42,23 +52,26 @@ static int s76_read_pwm(int idx)
static int s76_write_pwm(int idx, u8 duty)
{
u8 values[] = {idx + 1, duty};
return ec_transaction(0x99, values, sizeof(values), NULL, 0);
}
static int s76_write_pwm_auto(int idx)
{
u8 values[] = {0xff, idx + 1};
return ec_transaction(0x99, values, sizeof(values), NULL, 0);
}
static ssize_t s76_hwmon_show_name(struct device *dev,
struct device_attribute *attr, char *buf)
{
return sprintf(buf, S76_DRIVER_NAME "\n");
}
static ssize_t s76_hwmon_show_fan_input(struct device *dev,
struct device_attribute *attr, char *buf)
{
int index = to_sensor_dev_attr(attr)->index;
return sysfs_emit(buf, "%i\n", s76_read_fan(index));
return sprintf(buf, "%i\n", s76_read_fan(index));
}
static ssize_t s76_hwmon_show_fan_label(struct device *dev,
@ -66,9 +79,9 @@ static ssize_t s76_hwmon_show_fan_label(struct device *dev,
{
switch (to_sensor_dev_attr(attr)->index) {
case 0:
return sysfs_emit(buf, "CPU fan\n");
return sprintf(buf, "CPU fan\n");
case 1:
return sysfs_emit(buf, "GPU fan\n");
return sprintf(buf, "GPU fan\n");
}
return 0;
}
@ -79,8 +92,7 @@ static ssize_t s76_hwmon_show_pwm(struct device *dev,
struct device_attribute *attr, char *buf)
{
int index = to_sensor_dev_attr(attr)->index;
return sysfs_emit(buf, "%i\n", s76_read_pwm(index));
return sprintf(buf, "%i\n", s76_read_pwm(index));
}
static ssize_t s76_hwmon_set_pwm(struct device *dev,
@ -106,8 +118,7 @@ static ssize_t s76_hwmon_show_pwm_enable(struct device *dev,
struct device_attribute *attr, char *buf)
{
int index = to_sensor_dev_attr(attr)->index;
return sysfs_emit(buf, "%i\n", pwm_enabled[index]);
return sprintf(buf, "%i\n", pwm_enabled[index]);
}
static ssize_t s76_hwmon_set_pwm_enable(struct device *dev,
@ -148,15 +159,14 @@ static ssize_t s76_hwmon_show_temp1_input(struct device *dev,
struct device_attribute *attr, char *buf)
{
u8 value;
ec_read(0x07, &value);
return sysfs_emit(buf, "%i\n", value * 1000);
return sprintf(buf, "%i\n", value * 1000);
}
static ssize_t s76_hwmon_show_temp1_label(struct device *dev,
struct device_attribute *attr, char *buf)
{
return sysfs_emit(buf, "CPU temperature\n");
return sprintf(buf, "CPU temperature\n");
}
#ifdef EXPERIMENTAL
@ -164,36 +174,37 @@ static ssize_t s76_hwmon_show_temp2_input(struct device *dev,
struct device_attribute *attr, char *buf)
{
u8 value;
ec_read(0xcd, &value);
return sysfs_emit(buf, "%i\n", value * 1000);
return sprintf(buf, "%i\n", value * 1000);
}
static ssize_t s76_hwmon_show_temp2_label(struct device *dev,
struct device_attribute *attr, char *buf)
{
return sysfs_emit(buf, "GPU temperature\n");
return sprintf(buf, "GPU temperature\n");
}
#endif
static SENSOR_DEVICE_ATTR(fan1_input, 0444, s76_hwmon_show_fan_input, NULL, 0);
static SENSOR_DEVICE_ATTR(fan1_label, 0444, s76_hwmon_show_fan_label, NULL, 0);
static SENSOR_DEVICE_ATTR(pwm1, 0644, s76_hwmon_show_pwm, s76_hwmon_set_pwm, 0);
static SENSOR_DEVICE_ATTR(pwm1_enable, 0644, s76_hwmon_show_pwm_enable, s76_hwmon_set_pwm_enable, 0);
static SENSOR_DEVICE_ATTR(name, S_IRUGO, s76_hwmon_show_name, NULL, 0);
static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, s76_hwmon_show_fan_input, NULL, 0);
static SENSOR_DEVICE_ATTR(fan1_label, S_IRUGO, s76_hwmon_show_fan_label, NULL, 0);
static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, s76_hwmon_show_pwm, s76_hwmon_set_pwm, 0);
static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, s76_hwmon_show_pwm_enable, s76_hwmon_set_pwm_enable, 0);
#ifdef EXPERIMENTAL
static SENSOR_DEVICE_ATTR(fan2_input, 0444, s76_hwmon_show_fan_input, NULL, 1);
static SENSOR_DEVICE_ATTR(fan2_label, 0444, s76_hwmon_show_fan_label, NULL, 1);
static SENSOR_DEVICE_ATTR(pwm2, 0644, s76_hwmon_show_pwm, s76_hwmon_set_pwm, 1);
static SENSOR_DEVICE_ATTR(pwm2_enable, 0644, s76_hwmon_show_pwm_enable, s76_hwmon_set_pwm_enable, 1);
static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, s76_hwmon_show_fan_input, NULL, 1);
static SENSOR_DEVICE_ATTR(fan2_label, S_IRUGO, s76_hwmon_show_fan_label, NULL, 1);
static SENSOR_DEVICE_ATTR(pwm2, S_IRUGO | S_IWUSR, s76_hwmon_show_pwm, s76_hwmon_set_pwm, 1);
static SENSOR_DEVICE_ATTR(pwm2_enable, S_IRUGO | S_IWUSR, s76_hwmon_show_pwm_enable, s76_hwmon_set_pwm_enable, 1);
#endif
static SENSOR_DEVICE_ATTR(temp1_input, 0444, s76_hwmon_show_temp1_input, NULL, 0);
static SENSOR_DEVICE_ATTR(temp1_label, 0444, s76_hwmon_show_temp1_label, NULL, 0);
static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, s76_hwmon_show_temp1_input, NULL, 0);
static SENSOR_DEVICE_ATTR(temp1_label, S_IRUGO, s76_hwmon_show_temp1_label, NULL, 0);
#ifdef EXPERIMENTAL
static SENSOR_DEVICE_ATTR(temp2_input, 0444, s76_hwmon_show_temp2_input, NULL, 1);
static SENSOR_DEVICE_ATTR(temp2_label, 0444, s76_hwmon_show_temp2_label, NULL, 1);
static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, s76_hwmon_show_temp2_input, NULL, 1);
static SENSOR_DEVICE_ATTR(temp2_label, S_IRUGO, s76_hwmon_show_temp2_label, NULL, 1);
#endif
static struct attribute *hwmon_default_attributes[] = {
&sensor_dev_attr_name.dev_attr.attr,
&sensor_dev_attr_fan1_input.dev_attr.attr,
&sensor_dev_attr_fan1_label.dev_attr.attr,
&sensor_dev_attr_pwm1.dev_attr.attr,
@ -213,10 +224,9 @@ static struct attribute *hwmon_default_attributes[] = {
NULL
};
static const struct attribute_group hwmon_default_group = {
static const struct attribute_group hwmon_default_attrgroup = {
.attrs = hwmon_default_attributes,
};
__ATTRIBUTE_GROUPS(hwmon_default);
static int s76_hwmon_reboot_callback(struct notifier_block *nb,
unsigned long action, void *data)
@ -234,16 +244,23 @@ static struct notifier_block s76_hwmon_reboot_notifier = {
static int s76_hwmon_init(struct device *dev)
{
s76_hwmon = devm_kzalloc(dev, sizeof(*s76_hwmon), GFP_KERNEL);
int ret;
s76_hwmon = kzalloc(sizeof(*s76_hwmon), GFP_KERNEL);
if (!s76_hwmon)
return -ENOMEM;
s76_hwmon->dev = devm_hwmon_device_register_with_groups(dev, S76_DRIVER_NAME, NULL, hwmon_default_groups);
s76_hwmon->dev = hwmon_device_register(dev);
if (IS_ERR(s76_hwmon->dev)) {
return PTR_ERR(s76_hwmon->dev);
ret = PTR_ERR(s76_hwmon->dev);
s76_hwmon->dev = NULL;
return ret;
}
(void)devm_register_reboot_notifier(dev, &s76_hwmon_reboot_notifier);
ret = sysfs_create_group(&s76_hwmon->dev->kobj, &hwmon_default_attrgroup);
if (ret)
return ret;
register_reboot_notifier(&s76_hwmon_reboot_notifier);
s76_write_pwm_auto(0);
#ifdef EXPERIMENTAL
s76_write_pwm_auto(1);
@ -253,13 +270,16 @@ static int s76_hwmon_init(struct device *dev)
static int s76_hwmon_fini(struct device *dev)
{
if (!s76_hwmon || IS_ERR_OR_NULL(s76_hwmon->dev))
if (!s76_hwmon || !s76_hwmon->dev)
return 0;
s76_write_pwm_auto(0);
#ifdef EXPERIMENTAL
s76_write_pwm_auto(1);
#endif
unregister_reboot_notifier(&s76_hwmon_reboot_notifier);
sysfs_remove_group(&s76_hwmon->dev->kobj, &hwmon_default_attrgroup);
hwmon_device_unregister(s76_hwmon->dev);
kfree(s76_hwmon);
return 0;
}

View File

@ -1,10 +1,22 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* input.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/>.
*/
#define AIRPLANE_KEY KEY_WLAN
@ -39,7 +51,7 @@ static const struct kernel_param_ops param_ops_poll_freq = {
static unsigned char param_poll_freq = POLL_FREQ_DEFAULT;
#define param_check_poll_freq param_check_byte
module_param_named(poll_freq, param_poll_freq, poll_freq, 0400);
module_param_named(poll_freq, param_poll_freq, poll_freq, S_IRUSR);
MODULE_PARM_DESC(poll_freq, "Set polling frequency");
static struct task_struct *s76_input_polling_task;
@ -108,7 +120,7 @@ static int s76_input_open(struct input_dev *dev)
s76_input_polling_thread,
NULL, "system76-polld");
if (IS_ERR(s76_input_polling_task)) {
if (unlikely(IS_ERR(s76_input_polling_task))) {
res = PTR_ERR(s76_input_polling_task);
s76_input_polling_task = NULL;
pr_err("Could not create polling thread: %d\n", res);
@ -121,7 +133,7 @@ static int s76_input_open(struct input_dev *dev)
static void s76_input_close(struct input_dev *dev)
{
if (IS_ERR_OR_NULL(s76_input_polling_task)) {
if (unlikely(IS_ERR_OR_NULL(s76_input_polling_task))) {
return;
}
@ -131,10 +143,11 @@ static void s76_input_close(struct input_dev *dev)
static int __init s76_input_init(struct device *dev)
{
int err;
u8 byte;
s76_input_device = devm_input_allocate_device(dev);
if (!s76_input_device) {
s76_input_device = input_allocate_device();
if (unlikely(!s76_input_device)) {
pr_err("Error allocating input device\n");
return -ENOMEM;
}
@ -142,8 +155,8 @@ static int __init s76_input_init(struct device *dev)
s76_input_device->name = "System76 Hotkeys";
s76_input_device->phys = "system76/input0";
s76_input_device->id.bustype = BUS_HOST;
s76_input_device->dev.parent = dev;
set_bit(EV_KEY, s76_input_device->evbit);
if (driver_flags & DRIVER_AP_KEY) {
set_bit(AIRPLANE_KEY, s76_input_device->keybit);
ec_read(0xDB, &byte);
@ -156,5 +169,26 @@ static int __init s76_input_init(struct device *dev)
s76_input_device->open = s76_input_open;
s76_input_device->close = s76_input_close;
return input_register_device(s76_input_device);
err = input_register_device(s76_input_device);
if (unlikely(err)) {
pr_err("Error registering input device\n");
goto err_free_input_device;
}
return 0;
err_free_input_device:
input_free_device(s76_input_device);
return err;
}
static void __exit s76_input_exit(void)
{
if (unlikely(!s76_input_device)) {
return;
}
input_unregister_device(s76_input_device);
s76_input_device = NULL;
}

View File

@ -1,8 +1,20 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* kb_led.c
*
* Copyright (C) 2017 Jeremy Soller <jeremy@system76.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/>.
*/
#define SET_KB_LED 0x67
@ -19,7 +31,7 @@ enum kb_led_region {
KB_LED_REGION_EXTRA,
};
static enum led_brightness kb_led_brightness;
static enum led_brightness kb_led_brightness = 0;
static enum led_brightness kb_led_toggle_brightness = 72;
@ -32,7 +44,7 @@ static union kb_led_color kb_led_regions[] = {
{ .rgb = 0xFFFFFF }
};
static int kb_led_colors_i;
static int kb_led_colors_i = 0;
static union kb_led_color kb_led_colors[] = {
{ .rgb = 0xFFFFFF },
@ -51,7 +63,7 @@ static enum led_brightness kb_led_get(struct led_classdev *led_cdev)
static int kb_led_set(struct led_classdev *led_cdev, enum led_brightness value)
{
pr_debug("%s %d\n", __func__, (int)value);
pr_debug("kb_led_set %d\n", (int)value);
if (!s76_wmbb(SET_KB_LED, 0xF4000000 | value, NULL)) {
kb_led_brightness = value;
@ -101,7 +113,7 @@ static void kb_led_color_set(enum kb_led_region region, union kb_led_color color
acpi_status status;
u8 *buf;
buf = kzalloc(8, GFP_KERNEL);
buf = (u8 *)kzalloc(8, GFP_KERNEL);
pr_debug("%s %d %06X\n", __func__, (int)region, (int)color.rgb);
@ -167,7 +179,7 @@ static struct led_classdev kb_led = {
static ssize_t kb_led_color_show(enum kb_led_region region, char *buf)
{
return sysfs_emit(buf, "%06X\n", (int)kb_led_regions[region].rgb);
return sprintf(buf, "%06X\n", (int)kb_led_regions[region].rgb);
}
static ssize_t kb_led_color_store(enum kb_led_region region, const char *buf, size_t size)
@ -268,21 +280,21 @@ static struct device_attribute kb_led_color_extra_dev_attr = {
static void kb_led_enable(void)
{
pr_debug("%s\n", __func__);
pr_debug("kb_led_enable\n");
s76_wmbb(SET_KB_LED, 0xE007F001, NULL);
}
static void kb_led_disable(void)
{
pr_debug("%s\n", __func__);
pr_debug("kb_led_disable\n");
s76_wmbb(SET_KB_LED, 0xE0003001, NULL);
}
static void kb_led_suspend(void)
{
pr_debug("%s\n", __func__);
pr_debug("kb_led_suspend\n");
// Disable keyboard backlight
kb_led_disable();
@ -292,7 +304,7 @@ static void kb_led_resume(void)
{
enum kb_led_region region;
pr_debug("%s\n", __func__);
pr_debug("kb_led_resume\n");
// Disable keyboard backlight
kb_led_disable();
@ -316,7 +328,7 @@ static int __init kb_led_init(struct device *dev)
{
int err;
err = devm_led_classdev_register(dev, &kb_led);
err = led_classdev_register(dev, &kb_led);
if (unlikely(err)) {
return err;
}
@ -348,11 +360,15 @@ static void __exit kb_led_exit(void)
device_remove_file(kb_led.dev, &kb_led_color_right_dev_attr);
device_remove_file(kb_led.dev, &kb_led_color_center_dev_attr);
device_remove_file(kb_led.dev, &kb_led_color_left_dev_attr);
if (!IS_ERR_OR_NULL(kb_led.dev)) {
led_classdev_unregister(&kb_led);
}
}
static void kb_wmi_brightness(enum led_brightness value)
{
pr_debug("%s %d\n", __func__, (int)value);
pr_debug("kb_wmi_brightness %d\n", (int)value);
kb_led_set(&kb_led, value);
led_classdev_notify_brightness_hw_changed(&kb_led, value);

View File

@ -1,7 +1,19 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/* Based on bbswitch,
* Copyright (C) 2011-2013 Bumblebee Project
* Author: Peter Wu <lekensteyn@gmail.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/>.
*/
enum {
@ -11,7 +23,7 @@ enum {
};
static struct pci_dev *dis_dev;
static struct pci_dev *sub_dev;
static struct pci_dev *sub_dev = NULL;
// Returns 1 if the card is disabled, 0 if enabled
static int is_card_disabled(void)
@ -24,7 +36,7 @@ static int is_card_disabled(void)
// read config word at 0x488
pci_read_config_dword(dis_dev, 0x488, &cfg_word);
if ((cfg_word & 0x2000000) == 0x2000000) {
if ((cfg_word & 0x2000000)==0x2000000) {
// check for subdevice. read first config dword of sub function 1
while ((tmp_dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, tmp_dev)) != NULL) {
int pci_class = tmp_dev->class >> 8;
@ -40,7 +52,7 @@ static int is_card_disabled(void)
if (sub_dev == NULL) {
pr_info("No NVIDIA audio device found, unsetting config bit.\n");
cfg_word |= 0x2000000;
cfg_word|=0x2000000;
pci_write_config_dword(dis_dev, 0x488, cfg_word);
return 1;
}
@ -54,7 +66,6 @@ static int is_card_disabled(void)
static void nv_hda_off(void)
{
u32 cfg_word;
if (is_card_disabled()) {
return;
}
@ -67,7 +78,7 @@ static void nv_hda_off(void)
// setting bit to turn off
pci_read_config_dword(dis_dev, 0x488, &cfg_word);
cfg_word &= 0xfdffffff;
cfg_word&=0xfdffffff;
pci_write_config_dword(dis_dev, 0x488, cfg_word);
}
@ -84,7 +95,7 @@ static void nv_hda_on(void)
// read,set bit, write config word at 0x488
pci_read_config_dword(dis_dev, 0x488, &cfg_word);
cfg_word |= 0x2000000;
cfg_word|=0x2000000;
pci_write_config_dword(dis_dev, 0x488, cfg_word);
//pci_scan_single_device

View File

@ -1,10 +1,22 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* system76.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/>.
*/
#define S76_DRIVER_NAME KBUILD_MODNAME
@ -49,7 +61,7 @@
#define DRIVER_INPUT (DRIVER_AP_KEY | DRIVER_OLED)
static uint64_t driver_flags;
static uint64_t driver_flags = 0;
struct platform_device *s76_platform_device;
@ -91,11 +103,9 @@ static int s76_wmbb(u32 method_id, u32 arg, u32 *retval)
#include "input.c"
#include "kb-led.c"
#include "hwmon.c"
#ifdef S76_WANTS_NV_HDA
#include "nv_hda.c"
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 12, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,12,0)
static void s76_wmi_notify(union acpi_object *obj, void *context)
#else
static void s76_wmi_notify(u32 value, void *context)
@ -103,9 +113,9 @@ static void s76_wmi_notify(u32 value, void *context)
{
u32 event;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 12, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,12,0)
if (obj->type != ACPI_TYPE_INTEGER) {
pr_debug("Unexpected WMI event (%0#6x)\n", obj->type);
pr_debug("Unexpected WMI event (%0#6x)\n", obj);
return;
}
#else
@ -200,12 +210,10 @@ static int __init s76_probe(struct platform_device *dev)
}
#endif
#ifdef S76_WANTS_NV_HDA
err = nv_hda_init(&dev->dev);
if (unlikely(err)) {
pr_err("Could not register NVIDIA audio device\n");
}
#endif
err = wmi_install_notify_handler(S76_EVENT_GUID, s76_wmi_notify, NULL);
if (unlikely(ACPI_FAILURE(err))) {
@ -224,7 +232,7 @@ static int __init s76_probe(struct platform_device *dev)
return 0;
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 11, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,11,0)
static void s76_remove(struct platform_device *dev)
#else
static int s76_remove(struct platform_device *dev)
@ -232,14 +240,15 @@ static int s76_remove(struct platform_device *dev)
{
wmi_remove_notify_handler(S76_EVENT_GUID);
#ifdef S76_WANTS_NV_HDA
nv_hda_exit();
#endif
#ifdef S76_HAS_HWMON
if (driver_flags & DRIVER_HWMON) {
s76_hwmon_fini(&dev->dev);
}
#endif
if (driver_flags & DRIVER_INPUT) {
s76_input_exit();
}
if (driver_flags & (DRIVER_KB_LED_WMI | DRIVER_KB_LED)) {
kb_led_exit();
}
@ -247,14 +256,14 @@ static int s76_remove(struct platform_device *dev)
ap_led_exit();
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 11, 0)
#if LINUX_VERSION_CODE < KERNEL_VERSION(6,11,0)
return 0;
#endif
}
static int s76_suspend(struct device *dev)
static int s76_suspend(struct platform_device *dev, pm_message_t status)
{
pr_debug("%s\n", __func__);
pr_debug("s76_suspend\n");
if (driver_flags & (DRIVER_KB_LED_WMI | DRIVER_KB_LED)) {
kb_led_suspend();
@ -263,9 +272,9 @@ static int s76_suspend(struct device *dev)
return 0;
}
static int s76_resume(struct device *dev)
static int s76_resume(struct platform_device *dev)
{
pr_debug("%s\n", __func__);
pr_debug("s76_resume\n");
msleep(2000);
@ -287,22 +296,13 @@ static int s76_resume(struct device *dev)
return 0;
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0)
static DEFINE_SIMPLE_DEV_PM_OPS(s76_pm, s76_suspend, s76_resume);
#else
static SIMPLE_DEV_PM_OPS(s76_pm, s76_suspend, s76_resume);
#endif
static struct platform_driver s76_platform_driver = {
.remove = s76_remove,
.suspend = s76_suspend,
.resume = s76_resume,
.driver = {
.name = S76_DRIVER_NAME,
.owner = THIS_MODULE,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0)
.pm = pm_sleep_ptr(&s76_pm),
#else
.pm = pm_ptr(&s76_pm),
#endif
},
};
@ -338,7 +338,6 @@ static struct dmi_system_id s76_dmi_table[] __initdata = {
DMI_TABLE_LEGACY("bonw13", DRIVER_HWMON | DRIVER_KB_LED_WMI),
DMI_TABLE("addw1", DRIVER_AP_LED | DRIVER_KB_LED_WMI | DRIVER_OLED),
DMI_TABLE("addw2", DRIVER_AP_LED | DRIVER_KB_LED_WMI | DRIVER_OLED),
DMI_TABLE("addw5", DRIVER_HWMON | DRIVER_KB_LED_WMI),
DMI_TABLE("bonw15-b", DRIVER_HWMON | DRIVER_KB_LED_WMI),
DMI_TABLE("bonw16", DRIVER_HWMON | DRIVER_KB_LED_WMI),
DMI_TABLE("darp5", DRIVER_AP_LED | DRIVER_HWMON | DRIVER_KB_LED_WMI),
@ -358,7 +357,6 @@ static struct dmi_system_id s76_dmi_table[] __initdata = {
DMI_TABLE("oryp4-b", DRIVER_AP_KEY | DRIVER_AP_LED | DRIVER_HWMON | DRIVER_KB_LED_WMI),
DMI_TABLE("oryp5", DRIVER_AP_LED | DRIVER_HWMON | DRIVER_KB_LED_WMI),
DMI_TABLE("oryp6", DRIVER_AP_LED | DRIVER_KB_LED_WMI),
DMI_TABLE("oryp13", DRIVER_AP_KEY | DRIVER_HWMON | DRIVER_KB_LED_WMI),
DMI_TABLE("pang10", DRIVER_AP_KEY | DRIVER_AP_WMI | DRIVER_KB_LED_WMI),
DMI_TABLE("pang11", DRIVER_AP_KEY | DRIVER_AP_WMI | DRIVER_KB_LED_WMI),
DMI_TABLE("serw11", DRIVER_AP_KEY | DRIVER_AP_LED | DRIVER_HWMON | DRIVER_KB_LED_WMI),
@ -394,7 +392,7 @@ static int __init s76_init(void)
s76_platform_device =
platform_create_bundle(&s76_platform_driver, s76_probe, NULL, 0, NULL, 0);
if (IS_ERR(s76_platform_device)) {
if (unlikely(IS_ERR(s76_platform_device))) {
return PTR_ERR(s76_platform_device);
}