Skip to content

Commit 82fed28

Browse files
add build and install instructions to README, make fan speeds writable
1 parent a88dcce commit 82fed28

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
# System76 ACPI Driver (DKMS)
22

33
This provides the system76_acpi in-tree driver for systems missing it.
4+
5+
## Building .deb from source
6+
```bash
7+
sudo dpkg-buildpackage -b -uc -us
8+
```
9+
10+
## Installing from built .deb
11+
```bash
12+
sudo dpkg -i ../system76-acpi-dkms_1.0.2_amd64.deb
13+
```

system76_acpi.c

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ struct system76_data {
3737
union acpi_object *ntmp;
3838
struct input_dev *input;
3939
bool has_open_ec;
40+
int fan_duty;
4041
};
4142

4243
static const struct acpi_device_id device_ids[] = {
@@ -498,12 +499,12 @@ static umode_t thermal_is_visible(const void *drvdata, enum hwmon_sensor_types t
498499
const struct system76_data *data = drvdata;
499500

500501
switch (type) {
501-
case hwmon_fan:
502502
case hwmon_pwm:
503503
if (system76_name(data->nfan, channel))
504-
return 0444;
504+
return 0644;
505505
break;
506506

507+
case hwmon_fan:
507508
case hwmon_temp:
508509
if (system76_name(data->ntmp, channel))
509510
return 0444;
@@ -560,6 +561,31 @@ static int thermal_read(struct device *dev, enum hwmon_sensor_types type, u32 at
560561
return -EOPNOTSUPP;
561562
}
562563

564+
static int thermal_write(struct device *dev, enum hwmon_sensor_types type, u32 attr,
565+
int channel, long val)
566+
{
567+
struct system76_data *data = dev_get_drvdata(dev);
568+
int raw;
569+
570+
switch (type) {
571+
case hwmon_pwm:
572+
if (attr == hwmon_pwm_input) {
573+
char method[5];
574+
snprintf(method, sizeof method, "SFD%d", channel);
575+
576+
data->fan_duty = val;
577+
578+
return system76_set(data, method, (int)data->fan_duty);
579+
}
580+
break;
581+
582+
default:
583+
return -EOPNOTSUPP;
584+
}
585+
586+
return -EOPNOTSUPP;
587+
}
588+
563589
static int thermal_read_string(struct device *dev, enum hwmon_sensor_types type, u32 attr,
564590
int channel, const char **str)
565591
{
@@ -593,6 +619,7 @@ static const struct hwmon_ops thermal_ops = {
593619
.is_visible = thermal_is_visible,
594620
.read = thermal_read,
595621
.read_string = thermal_read_string,
622+
.write = thermal_write,
596623
};
597624

598625
// Allocate up to 8 fans and temperatures

0 commit comments

Comments
 (0)