diff --git a/README.md b/README.md index 535b1c5..da0c5ef 100644 --- a/README.md +++ b/README.md @@ -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 +``` diff --git a/system76_acpi.c b/system76_acpi.c index 61b8e9d..2fd7e0f 100644 --- a/system76_acpi.c +++ b/system76_acpi.c @@ -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[] = { @@ -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; @@ -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) { @@ -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