Skip to content

Commit

Permalink
Add support for Octo flow sensor (aleksamagicka#95)
Browse files Browse the repository at this point in the history
* Makefile: refactor somewhat to enable make arg propagation

Signed-off-by: David Flemström <[email protected]>

* Add support for Octo flow sensor

Signed-off-by: David Flemström <[email protected]>

* Indent OCTO_FLOW_SENSOR_OFFSET

Signed-off-by: David Flemström <[email protected]>

* Convert if statement into switch on priv->kind

Signed-off-by: David Flemström <[email protected]>

* Remove dynamic_debug register hex dumps

Signed-off-by: David Flemström <[email protected]>

* Indicate possibility that hwmon fan channel 9 might support pulses

Signed-off-by: David Flemström <[email protected]>

* Document new flow sensor Octo registers

Signed-off-by: David Flemström <[email protected]>

* Add kernel docs entry for new fan9_pulses sysfs node

Signed-off-by: David Flemström <[email protected]>

* Mention flow sensor support for Octo in kernel docs

Signed-off-by: David Flemström <[email protected]>

---------

Signed-off-by: David Flemström <[email protected]>
  • Loading branch information
dflemstr authored Mar 29, 2024
1 parent f32f597 commit 60a2270
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 22 deletions.
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,24 @@

# external KDIR specification is supported
KDIR ?= /lib/modules/$(shell uname -r)/build
PWD ?= $(shell pwd)

SOURCES := aquacomputer_d5next.c docs/aquacomputer_d5next.rst

.PHONY: all modules modules clean checkpatch dev

all: modules

install: modules_install

modules modules_install clean:
make -C $(KDIR) M=$$PWD $@
$(MAKE) -C $(KDIR) M=$(PWD) $@

checkpatch:
$(KDIR)/scripts/checkpatch.pl --strict --no-tree $(SOURCES)

dev:
make clean
make
$(MAKE) clean
$(MAKE)
sudo rmmod aquacomputer_d5next || true
sudo insmod aquacomputer_d5next.ko
51 changes: 33 additions & 18 deletions aquacomputer_d5next.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,18 @@ static u16 aquastreamult_sensor_fan_offsets[] = { AQUASTREAMULT_FAN_OFFSET };
#define OCTO_NUM_FANS 8
#define OCTO_NUM_SENSORS 4
#define OCTO_NUM_VIRTUAL_SENSORS 16
#define OCTO_NUM_FLOW_SENSORS 1
#define OCTO_CTRL_REPORT_SIZE 0x65F

/* Sensor report offsets for the Octo */
#define OCTO_SENSOR_START 0x3D
#define OCTO_VIRTUAL_SENSORS_START 0x45
#define OCTO_FLOW_SENSOR_OFFSET 0x7B
static u16 octo_sensor_fan_offsets[] = { 0x7D, 0x8A, 0x97, 0xA4, 0xB1, 0xBE, 0xCB, 0xD8 };

/* Control report offsets for the Octo */
#define OCTO_TEMP_CTRL_OFFSET 0xA
#define OCTO_FLOW_PULSES_CTRL_OFFSET 0x6
/* Fan speed offsets (0-100%) */
static u16 octo_ctrl_fan_offsets[] = { 0x5A, 0xAF, 0x104, 0x159, 0x1AE, 0x203, 0x258, 0x2AD };

Expand Down Expand Up @@ -480,18 +483,6 @@ static const char *const label_aquaero_aquabus_temp_sensors[] = {
"Aquabus sensor 20"
};

/* Labels for Octo and Quadro (except speed) */
static const char *const label_fan_speed[] = {
"Fan 1 speed",
"Fan 2 speed",
"Fan 3 speed",
"Fan 4 speed",
"Fan 5 speed",
"Fan 6 speed",
"Fan 7 speed",
"Fan 8 speed"
};

static const char *const label_fan_power[] = {
"Fan 1 power",
"Fan 2 power",
Expand Down Expand Up @@ -534,6 +525,19 @@ static const char *const label_quadro_speeds[] = {
"Flow speed [dL/h]"
};

/* Labels for Octo */
static const char *const label_octo_speeds[] = {
"Fan 1 speed",
"Fan 2 speed",
"Fan 3 speed",
"Fan 4 speed",
"Fan 5 speed",
"Fan 6 speed",
"Fan 7 speed",
"Fan 8 speed",
"Flow speed [dL/h]",
};

/* Labels for Aquaero fan speeds */
static const char *const label_aquaero_speeds[] = {
"Fan 1 speed",
Expand Down Expand Up @@ -1074,6 +1078,7 @@ static umode_t aqc_is_visible(const void *data, enum hwmon_sensor_types type, u3
break;
case aquaero:
case quadro:
case octo:
case highflow:
/* Special case to support flow sensors */
if (channel < priv->num_fans +
Expand All @@ -1098,9 +1103,16 @@ static umode_t aqc_is_visible(const void *data, enum hwmon_sensor_types type, u3
return 0444;
break;
case hwmon_fan_pulses:
/* Special case for Quadro flow sensor */
if (priv->kind == quadro && channel == priv->num_fans)
return 0644;
/* Special case for Quadro/Octo flow sensor */
if (channel == priv->num_fans) {
switch (priv->kind) {
case quadro:
case octo:
return 0644;
default:
break;
}
}
break;
default:
break;
Expand Down Expand Up @@ -2437,7 +2449,7 @@ static const struct hwmon_channel_info * const aqc_info[] = {
HWMON_F_INPUT | HWMON_F_LABEL,
HWMON_F_INPUT | HWMON_F_LABEL,
HWMON_F_INPUT | HWMON_F_LABEL,
HWMON_F_INPUT | HWMON_F_LABEL,
HWMON_F_INPUT | HWMON_F_LABEL | HWMON_F_PULSES,
HWMON_F_INPUT | HWMON_F_LABEL,
HWMON_F_INPUT | HWMON_F_LABEL,
HWMON_F_INPUT | HWMON_F_LABEL,
Expand Down Expand Up @@ -2943,15 +2955,18 @@ static int aqc_probe(struct hid_device *hdev, const struct hid_device_id *id)
priv->temp_sensor_start_offset = OCTO_SENSOR_START;
priv->num_virtual_temp_sensors = OCTO_NUM_VIRTUAL_SENSORS;
priv->virtual_temp_sensor_start_offset = OCTO_VIRTUAL_SENSORS_START;
priv->num_flow_sensors = OCTO_NUM_FLOW_SENSORS;
priv->flow_sensors_start_offset = OCTO_FLOW_SENSOR_OFFSET;

priv->power_cycle_count_offset = AQC_POWER_CYCLES;
priv->buffer_size = OCTO_CTRL_REPORT_SIZE;
priv->temp_ctrl_offset = OCTO_TEMP_CTRL_OFFSET;
priv->ctrl_report_delay = CTRL_REPORT_DELAY;
priv->temp_ctrl_offset = OCTO_TEMP_CTRL_OFFSET;
priv->flow_pulses_ctrl_offset = OCTO_FLOW_PULSES_CTRL_OFFSET;

priv->temp_label = label_temp_sensors;
priv->virtual_temp_label = label_virtual_temp_sensors;
priv->speed_label = label_fan_speed;
priv->speed_label = label_octo_speeds;
priv->power_label = label_fan_power;
priv->voltage_label = label_fan_voltage;
priv->current_label = label_fan_current;
Expand Down
3 changes: 2 additions & 1 deletion docs/aquacomputer_d5next.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ via its physical interface.

The Octo exposes four physical and sixteen virtual temperature sensors, as well as
eight PWM controllable fans, along with their speed (in RPM), power, voltage and
current.
current. Flow sensor pulses are also available.

The Quadro exposes four physical and sixteen virtual temperature sensors, a flow
sensor and four PWM controllable fans, along with their speed (in RPM), power,
Expand Down Expand Up @@ -115,6 +115,7 @@ fan[1-4]_min Minimal fan speed (in RPM)
fan[1-4]_max Maximal fan speed (in RPM)
fan1_target Target fan speed (in RPM)
fan5_pulses Quadro flow sensor pulses
fan9_pulses Octo flow sensor pulses
power[1-8]_input Pump/fan power (in micro Watts)
in[0-7]_input Pump/fan voltage (in milli Volts)
curr[1-8]_input Pump/fan current (in milli Amperes)
Expand Down
2 changes: 2 additions & 0 deletions re-docs/PROTOCOLS.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ Here is what it's currently known to contain:
| Fan 6 substructure | 0xBE |
| Fan 7 substructure | 0xCB |
| Fan 8 substructure | 0xD8 |
| Flow sensor | 0x7B |
| Virtual temp sensor 1 | 0x45 |
| Virtual temp sensor 2 | 0x47 |
| Virtual temp sensor 3 | 0x49 |
Expand Down Expand Up @@ -231,6 +232,7 @@ Here is what it's currently known to contain:
| Fan 7 ctrl substructure | 0x258 |
| Fan 8 ctrl substructure | 0x2AD |
| Temp offset ctrl substructure | 0xA |
| Flow sensors pulses | 0x6 |
| Fan curve "hold min power" and "start boost" | {0x12, 0x1B, 0x24, 0x2D, 0x36, 0x3F, 0x48, 0x51} |
| Fan curve min power subgroup | {0x13, 0x1C, 0x25, 0x2E, 0x37, 0x40, 0x49, 0x52} |
| Fan curve max power subgroup | {0x15, 0x1E, 0x27, 0x30, 0x39, 0x42, 0x4B, 0x54} |
Expand Down

0 comments on commit 60a2270

Please sign in to comment.