Compare commits

...

10 Commits

Author SHA1 Message Date
Jesse D. McDonald 82f289d6e7 Disable mandatory integration with NV HDA driver 2025-11-25 06:25:48 +00:00
Tim Crawford d3d9ce28c6 Add oryp13
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2025-09-22 20:40:59 -06:00
Jeremy Soller 79f5488fd2
1.0.20 2025-07-01 11:27:51 -06:00
Tim Crawford 44aa423b2c Add addw5
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2025-07-01 17:26:05 +00:00
Tim Crawford 293de8964e
Move suspend/resume functions to dev_pm_ops
Replace deprecated interface functions with newer PM interface.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2025-06-16 14:00:44 -06:00
Tim Crawford 3fa766c549
Fix pr_debug format error
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2025-06-16 14:00:44 -06:00
Tim Crawford e457babab4
Use devres
Allow kernel to handle removal of devices when driver is unloaded.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2025-06-09 15:44:44 -06:00
Tim Crawford 9c210e3060
hwmon: Replace deprecated function
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2025-06-09 15:27:09 -06:00
Tim Crawford cc4802bd26
Replace sprintf with sysfs_emit
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2025-06-06 16:56:48 -06:00
Tim Crawford dd00fe93ca
Address checkpatch issues
- Convert license blocks to SPDX ID tags
- Remove unlikely from IS_ERR calls
- Replace hard-coded function names with __func__
- Replace symbolic permissions with octals
- Add blank lines after declarations
- Do not initialize statics to 0
- Remove unneeded cast from kzalloc
- Add missing spacing around values

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2025-06-06 16:50:13 -06:00
7 changed files with 125 additions and 200 deletions

19
debian/changelog vendored
View File

@ -1,3 +1,22 @@
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,20 +1,8 @@
// 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;
@ -65,7 +53,7 @@ static struct led_classdev ap_led = {
static ssize_t ap_led_invert_show(struct device *dev, struct device_attribute *attr, char *buf)
{
return sprintf(buf, "%d\n", (int)ap_led_invert);
return sysfs_emit(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)
@ -110,12 +98,13 @@ static int __init ap_led_init(struct device *dev)
{
int err;
err = led_classdev_register(dev, &ap_led);
if (unlikely(err)) {
err = devm_led_classdev_register(dev, &ap_led);
if (err < 0) {
return err;
}
if (device_create_file(ap_led.dev, &ap_led_invert_dev_attr) != 0) {
err = device_create_file(ap_led.dev, &ap_led_invert_dev_attr);
if (err < 0) {
pr_err("failed to create ap_led_invert\n");
}
@ -127,8 +116,4 @@ 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,22 +1,10 @@
// 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
@ -27,12 +15,13 @@ struct s76_hwmon {
struct device *dev;
};
static struct s76_hwmon *s76_hwmon = NULL;
static struct s76_hwmon *s76_hwmon;
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);
@ -45,6 +34,7 @@ static int s76_read_fan(int idx)
static int s76_read_pwm(int idx)
{
u8 value;
ec_read(0xce + idx, &value);
return value;
}
@ -52,26 +42,23 @@ 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");
return ec_transaction(0x99, values, sizeof(values), NULL, 0);
}
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 sprintf(buf, "%i\n", s76_read_fan(index));
return sysfs_emit(buf, "%i\n", s76_read_fan(index));
}
static ssize_t s76_hwmon_show_fan_label(struct device *dev,
@ -79,9 +66,9 @@ static ssize_t s76_hwmon_show_fan_label(struct device *dev,
{
switch (to_sensor_dev_attr(attr)->index) {
case 0:
return sprintf(buf, "CPU fan\n");
return sysfs_emit(buf, "CPU fan\n");
case 1:
return sprintf(buf, "GPU fan\n");
return sysfs_emit(buf, "GPU fan\n");
}
return 0;
}
@ -92,7 +79,8 @@ 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 sprintf(buf, "%i\n", s76_read_pwm(index));
return sysfs_emit(buf, "%i\n", s76_read_pwm(index));
}
static ssize_t s76_hwmon_set_pwm(struct device *dev,
@ -118,7 +106,8 @@ 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 sprintf(buf, "%i\n", pwm_enabled[index]);
return sysfs_emit(buf, "%i\n", pwm_enabled[index]);
}
static ssize_t s76_hwmon_set_pwm_enable(struct device *dev,
@ -159,14 +148,15 @@ static ssize_t s76_hwmon_show_temp1_input(struct device *dev,
struct device_attribute *attr, char *buf)
{
u8 value;
ec_read(0x07, &value);
return sprintf(buf, "%i\n", value * 1000);
return sysfs_emit(buf, "%i\n", value * 1000);
}
static ssize_t s76_hwmon_show_temp1_label(struct device *dev,
struct device_attribute *attr, char *buf)
{
return sprintf(buf, "CPU temperature\n");
return sysfs_emit(buf, "CPU temperature\n");
}
#ifdef EXPERIMENTAL
@ -174,37 +164,36 @@ static ssize_t s76_hwmon_show_temp2_input(struct device *dev,
struct device_attribute *attr, char *buf)
{
u8 value;
ec_read(0xcd, &value);
return sprintf(buf, "%i\n", value * 1000);
return sysfs_emit(buf, "%i\n", value * 1000);
}
static ssize_t s76_hwmon_show_temp2_label(struct device *dev,
struct device_attribute *attr, char *buf)
{
return sprintf(buf, "GPU temperature\n");
return sysfs_emit(buf, "GPU temperature\n");
}
#endif
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);
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);
#ifdef EXPERIMENTAL
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);
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);
#endif
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);
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);
#ifdef EXPERIMENTAL
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);
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);
#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,
@ -224,9 +213,10 @@ static struct attribute *hwmon_default_attributes[] = {
NULL
};
static const struct attribute_group hwmon_default_attrgroup = {
static const struct attribute_group hwmon_default_group = {
.attrs = hwmon_default_attributes,
};
__ATTRIBUTE_GROUPS(hwmon_default);
static int s76_hwmon_reboot_callback(struct notifier_block *nb,
unsigned long action, void *data)
@ -244,23 +234,16 @@ static struct notifier_block s76_hwmon_reboot_notifier = {
static int s76_hwmon_init(struct device *dev)
{
int ret;
s76_hwmon = kzalloc(sizeof(*s76_hwmon), GFP_KERNEL);
s76_hwmon = devm_kzalloc(dev, sizeof(*s76_hwmon), GFP_KERNEL);
if (!s76_hwmon)
return -ENOMEM;
s76_hwmon->dev = hwmon_device_register(dev);
s76_hwmon->dev = devm_hwmon_device_register_with_groups(dev, S76_DRIVER_NAME, NULL, hwmon_default_groups);
if (IS_ERR(s76_hwmon->dev)) {
ret = PTR_ERR(s76_hwmon->dev);
s76_hwmon->dev = NULL;
return ret;
return PTR_ERR(s76_hwmon->dev);
}
ret = sysfs_create_group(&s76_hwmon->dev->kobj, &hwmon_default_attrgroup);
if (ret)
return ret;
register_reboot_notifier(&s76_hwmon_reboot_notifier);
(void)devm_register_reboot_notifier(dev, &s76_hwmon_reboot_notifier);
s76_write_pwm_auto(0);
#ifdef EXPERIMENTAL
s76_write_pwm_auto(1);
@ -270,16 +253,13 @@ static int s76_hwmon_init(struct device *dev)
static int s76_hwmon_fini(struct device *dev)
{
if (!s76_hwmon || !s76_hwmon->dev)
if (!s76_hwmon || IS_ERR_OR_NULL(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,22 +1,10 @@
// 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
@ -51,7 +39,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, S_IRUSR);
module_param_named(poll_freq, param_poll_freq, poll_freq, 0400);
MODULE_PARM_DESC(poll_freq, "Set polling frequency");
static struct task_struct *s76_input_polling_task;
@ -120,7 +108,7 @@ static int s76_input_open(struct input_dev *dev)
s76_input_polling_thread,
NULL, "system76-polld");
if (unlikely(IS_ERR(s76_input_polling_task))) {
if (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);
@ -133,7 +121,7 @@ static int s76_input_open(struct input_dev *dev)
static void s76_input_close(struct input_dev *dev)
{
if (unlikely(IS_ERR_OR_NULL(s76_input_polling_task))) {
if (IS_ERR_OR_NULL(s76_input_polling_task)) {
return;
}
@ -143,11 +131,10 @@ 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 = input_allocate_device();
if (unlikely(!s76_input_device)) {
s76_input_device = devm_input_allocate_device(dev);
if (!s76_input_device) {
pr_err("Error allocating input device\n");
return -ENOMEM;
}
@ -155,8 +142,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);
@ -169,26 +156,5 @@ static int __init s76_input_init(struct device *dev)
s76_input_device->open = s76_input_open;
s76_input_device->close = s76_input_close;
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;
return input_register_device(s76_input_device);
}

View File

@ -1,20 +1,8 @@
// 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
@ -31,7 +19,7 @@ enum kb_led_region {
KB_LED_REGION_EXTRA,
};
static enum led_brightness kb_led_brightness = 0;
static enum led_brightness kb_led_brightness;
static enum led_brightness kb_led_toggle_brightness = 72;
@ -44,7 +32,7 @@ static union kb_led_color kb_led_regions[] = {
{ .rgb = 0xFFFFFF }
};
static int kb_led_colors_i = 0;
static int kb_led_colors_i;
static union kb_led_color kb_led_colors[] = {
{ .rgb = 0xFFFFFF },
@ -63,7 +51,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("kb_led_set %d\n", (int)value);
pr_debug("%s %d\n", __func__, (int)value);
if (!s76_wmbb(SET_KB_LED, 0xF4000000 | value, NULL)) {
kb_led_brightness = value;
@ -113,7 +101,7 @@ static void kb_led_color_set(enum kb_led_region region, union kb_led_color color
acpi_status status;
u8 *buf;
buf = (u8 *)kzalloc(8, GFP_KERNEL);
buf = kzalloc(8, GFP_KERNEL);
pr_debug("%s %d %06X\n", __func__, (int)region, (int)color.rgb);
@ -179,7 +167,7 @@ static struct led_classdev kb_led = {
static ssize_t kb_led_color_show(enum kb_led_region region, char *buf)
{
return sprintf(buf, "%06X\n", (int)kb_led_regions[region].rgb);
return sysfs_emit(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)
@ -280,21 +268,21 @@ static struct device_attribute kb_led_color_extra_dev_attr = {
static void kb_led_enable(void)
{
pr_debug("kb_led_enable\n");
pr_debug("%s\n", __func__);
s76_wmbb(SET_KB_LED, 0xE007F001, NULL);
}
static void kb_led_disable(void)
{
pr_debug("kb_led_disable\n");
pr_debug("%s\n", __func__);
s76_wmbb(SET_KB_LED, 0xE0003001, NULL);
}
static void kb_led_suspend(void)
{
pr_debug("kb_led_suspend\n");
pr_debug("%s\n", __func__);
// Disable keyboard backlight
kb_led_disable();
@ -304,7 +292,7 @@ static void kb_led_resume(void)
{
enum kb_led_region region;
pr_debug("kb_led_resume\n");
pr_debug("%s\n", __func__);
// Disable keyboard backlight
kb_led_disable();
@ -328,7 +316,7 @@ static int __init kb_led_init(struct device *dev)
{
int err;
err = led_classdev_register(dev, &kb_led);
err = devm_led_classdev_register(dev, &kb_led);
if (unlikely(err)) {
return err;
}
@ -360,15 +348,11 @@ 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("kb_wmi_brightness %d\n", (int)value);
pr_debug("%s %d\n", __func__, (int)value);
kb_led_set(&kb_led, value);
led_classdev_notify_brightness_hw_changed(&kb_led, value);

View File

@ -1,19 +1,7 @@
// 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 {
@ -23,7 +11,7 @@ enum {
};
static struct pci_dev *dis_dev;
static struct pci_dev *sub_dev = NULL;
static struct pci_dev *sub_dev;
// Returns 1 if the card is disabled, 0 if enabled
static int is_card_disabled(void)
@ -36,7 +24,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;
@ -52,7 +40,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;
}
@ -66,8 +54,9 @@ static int is_card_disabled(void)
static void nv_hda_off(void)
{
u32 cfg_word;
if (is_card_disabled()) {
return;
return;
}
// remove device
@ -78,7 +67,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);
}
@ -95,7 +84,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,22 +1,10 @@
// 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
@ -61,7 +49,7 @@
#define DRIVER_INPUT (DRIVER_AP_KEY | DRIVER_OLED)
static uint64_t driver_flags = 0;
static uint64_t driver_flags;
struct platform_device *s76_platform_device;
@ -103,9 +91,11 @@ 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)
@ -113,9 +103,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);
pr_debug("Unexpected WMI event (%0#6x)\n", obj->type);
return;
}
#else
@ -210,10 +200,12 @@ 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))) {
@ -232,7 +224,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)
@ -240,15 +232,14 @@ 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();
}
@ -256,14 +247,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 platform_device *dev, pm_message_t status)
static int s76_suspend(struct device *dev)
{
pr_debug("s76_suspend\n");
pr_debug("%s\n", __func__);
if (driver_flags & (DRIVER_KB_LED_WMI | DRIVER_KB_LED)) {
kb_led_suspend();
@ -272,9 +263,9 @@ static int s76_suspend(struct platform_device *dev, pm_message_t status)
return 0;
}
static int s76_resume(struct platform_device *dev)
static int s76_resume(struct device *dev)
{
pr_debug("s76_resume\n");
pr_debug("%s\n", __func__);
msleep(2000);
@ -296,13 +287,22 @@ static int s76_resume(struct platform_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,6 +338,7 @@ 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),
@ -357,6 +358,7 @@ 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),
@ -392,7 +394,7 @@ static int __init s76_init(void)
s76_platform_device =
platform_create_bundle(&s76_platform_driver, s76_probe, NULL, 0, NULL, 0);
if (unlikely(IS_ERR(s76_platform_device))) {
if (IS_ERR(s76_platform_device)) {
return PTR_ERR(s76_platform_device);
}