Skip to content

Commit

Permalink
Add support for Octo flow sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
dflemstr committed Mar 29, 2024
1 parent d505e0e commit cc88ba1
Showing 1 changed file with 30 additions and 16 deletions.
46 changes: 30 additions & 16 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 @@ -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;
Expand Down Expand Up @@ -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 +
Expand All @@ -1098,8 +1105,8 @@ 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:
Expand Down Expand Up @@ -1183,6 +1190,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 +
Expand Down Expand Up @@ -2506,6 +2515,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 */
Expand Down Expand Up @@ -2943,15 +2954,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

0 comments on commit cc88ba1

Please sign in to comment.