Skip to content

Commit

Permalink
add build and install instructions to README, make fan speeds writable
Browse files Browse the repository at this point in the history
  • Loading branch information
curiousercreative committed Oct 17, 2022
1 parent a88dcce commit 82fed28
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# System76 ACPI Driver (DKMS)

This provides the system76_acpi in-tree driver for systems missing it.

## Building .deb from source
```bash
sudo dpkg-buildpackage -b -uc -us
```

## Installing from built .deb
```bash
sudo dpkg -i ../system76-acpi-dkms_1.0.2_amd64.deb
```
31 changes: 29 additions & 2 deletions system76_acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ struct system76_data {
union acpi_object *ntmp;
struct input_dev *input;
bool has_open_ec;
int fan_duty;
};

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

switch (type) {
case hwmon_fan:
case hwmon_pwm:
if (system76_name(data->nfan, channel))
return 0444;
return 0644;
break;

case hwmon_fan:
case hwmon_temp:
if (system76_name(data->ntmp, channel))
return 0444;
Expand Down Expand Up @@ -560,6 +561,31 @@ static int thermal_read(struct device *dev, enum hwmon_sensor_types type, u32 at
return -EOPNOTSUPP;
}

static int thermal_write(struct device *dev, enum hwmon_sensor_types type, u32 attr,
int channel, long val)
{
struct system76_data *data = dev_get_drvdata(dev);
int raw;

switch (type) {
case hwmon_pwm:
if (attr == hwmon_pwm_input) {
char method[5];
snprintf(method, sizeof method, "SFD%d", channel);

data->fan_duty = val;

return system76_set(data, method, (int)data->fan_duty);
}
break;

default:
return -EOPNOTSUPP;
}

return -EOPNOTSUPP;
}

static int thermal_read_string(struct device *dev, enum hwmon_sensor_types type, u32 attr,
int channel, const char **str)
{
Expand Down Expand Up @@ -593,6 +619,7 @@ static const struct hwmon_ops thermal_ops = {
.is_visible = thermal_is_visible,
.read = thermal_read,
.read_string = thermal_read_string,
.write = thermal_write,
};

// Allocate up to 8 fans and temperatures
Expand Down

0 comments on commit 82fed28

Please sign in to comment.