From a195ac60c3c4f250748e2fa6fdd2eda7d39e6c59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Flemstr=C3=B6m?= Date: Fri, 29 Mar 2024 19:06:58 +0100 Subject: [PATCH] Add support for Octo flow sensor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: David Flemström --- aquacomputer_d5next.c | 47 ++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/aquacomputer_d5next.c b/aquacomputer_d5next.c index ef540d7..a9247a4 100644 --- a/aquacomputer_d5next.c +++ b/aquacomputer_d5next.c @@ -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 }; @@ -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", @@ -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", @@ -850,6 +854,8 @@ static int aqc_get_ctrl_data(struct aqc_data *priv) if (ret < 0) ret = -ENODATA; + print_hex_dump_bytes("ctrl_report: ", DUMP_PREFIX_OFFSET, priv->buffer, priv->buffer_size); + priv->last_ctrl_report_op = ktime_get(); return ret; @@ -1074,6 +1080,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 + @@ -1098,8 +1105,9 @@ 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) + /* Special case for Quadro/Octo flow sensor */ + if ((priv->kind == quadro || priv->kind == octo) && + channel == priv->num_fans) return 0644; break; default: @@ -1183,6 +1191,8 @@ static int aqc_legacy_read(struct aqc_data *priv) if (ret < 0) goto unlock_and_return; + print_hex_dump_bytes("ctrl_report: ", DUMP_PREFIX_OFFSET, priv->buffer, priv->buffer_size); + /* Temperature sensor readings */ for (i = 0; i < priv->num_temp_sensors; i++) { sensor_value = get_unaligned_le16(priv->buffer + priv->temp_sensor_start_offset + @@ -2506,6 +2516,8 @@ static int aqc_raw_event(struct hid_device *hdev, struct hid_report *report, u8 if (report->id != STATUS_REPORT_ID) return 0; + print_hex_dump_bytes("status_report: ", DUMP_PREFIX_OFFSET, data, size); + priv = hid_get_drvdata(hdev); /* Info provided with every report */ @@ -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;