From: Leonard Anderweit <leonard.anderweit@gmail.com>
To: linux-hwmon@vger.kernel.org
Cc: Aleksa Savic <savicaleksa83@gmail.com>,
Jack Doan <me@jackdoan.com>, Jean Delvare <jdelvare@suse.com>,
Guenter Roeck <linux@roeck-us.net>,
Jonathan Corbet <corbet@lwn.net>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
Leonard Anderweit <leonard.anderweit@gmail.com>
Subject: [PATCH v2 4/6] hwmon: (aquacomputer_d5next) Add infrastructure for Aquaero control reports
Date: Tue, 14 Feb 2023 23:02:19 +0100 [thread overview]
Message-ID: <20230214220221.15003-5-leonard.anderweit@gmail.com> (raw)
In-Reply-To: <20230214220221.15003-1-leonard.anderweit@gmail.com>
Add information on the Aquacomputer Aquaero control report and disable the
control report checksum for Aquaero. The Aquaero does not use the checksum so
it must be disabled to avoid overwriting the last two bytes of the control
report.
Signed-off-by: Leonard Anderweit <leonard.anderweit@gmail.com>
---
drivers/hwmon/aquacomputer_d5next.c | 31 ++++++++++++++++++++++++-----
1 file changed, 26 insertions(+), 5 deletions(-)
diff --git a/drivers/hwmon/aquacomputer_d5next.c b/drivers/hwmon/aquacomputer_d5next.c
index 535d2fc0e55c..eb185318098a 100644
--- a/drivers/hwmon/aquacomputer_d5next.c
+++ b/drivers/hwmon/aquacomputer_d5next.c
@@ -56,6 +56,7 @@ static const char *const aqc_device_names[] = {
#define SERIAL_PART_OFFSET 2
#define CTRL_REPORT_ID 0x03
+#define AQUAERO_CTRL_REPORT_ID 0x0b
/* The HID report that the official software always sends
* after writing values, currently same for all devices
@@ -67,6 +68,14 @@ static u8 secondary_ctrl_report[] = {
0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x34, 0xC6
};
+/* Secondary HID report values for Aquaero */
+#define AQUAERO_SECONDARY_CTRL_REPORT_ID 0x06
+#define AQUAERO_SECONDARY_CTRL_REPORT_SIZE 0x07
+
+static u8 aquaero_secondary_ctrl_report[] = {
+ 0x06, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00
+};
+
/* Report IDs for legacy devices */
#define POWERADJUST3_STATUS_REPORT_ID 0x03
@@ -94,6 +103,7 @@ static u8 secondary_ctrl_report[] = {
#define AQUAERO_NUM_VIRTUAL_SENSORS 8
#define AQUAERO_NUM_CALC_VIRTUAL_SENSORS 4
#define AQUAERO_NUM_FLOW_SENSORS 2
+#define AQUAERO_CTRL_REPORT_SIZE 0xa93
/* Sensor report offsets for Aquaero fan controllers */
#define AQUAERO_SENSOR_START 0x65
@@ -531,12 +541,16 @@ static int aqc_send_ctrl_data(struct aqc_data *priv)
int ret;
u16 checksum;
- /* Init and xorout value for CRC-16/USB is 0xffff */
- checksum = crc16(0xffff, priv->buffer + priv->checksum_start, priv->checksum_length);
- checksum ^= 0xffff;
+ /* Checksum is not needed for Aquaero */
+ if (priv->kind != aquaero) {
+ /* Init and xorout value for CRC-16/USB is 0xffff */
+ checksum = crc16(0xffff, priv->buffer + priv->checksum_start,
+ priv->checksum_length);
+ checksum ^= 0xffff;
- /* Place the new checksum at the end of the report */
- put_unaligned_be16(checksum, priv->buffer + priv->checksum_offset);
+ /* Place the new checksum at the end of the report */
+ put_unaligned_be16(checksum, priv->buffer + priv->checksum_offset);
+ }
/* Send the patched up report back to the device */
ret = hid_hw_raw_request(priv->hdev, priv->ctrl_report_id, priv->buffer, priv->buffer_size,
@@ -1280,6 +1294,8 @@ static int aqc_probe(struct hid_device *hdev, const struct hid_device_id *id)
priv->num_flow_sensors = AQUAERO_NUM_FLOW_SENSORS;
priv->flow_sensors_start_offset = AQUAERO_FLOW_SENSORS_START;
+ priv->buffer_size = AQUAERO_CTRL_REPORT_SIZE;
+
priv->temp_label = label_temp_sensors;
priv->virtual_temp_label = label_virtual_temp_sensors;
priv->calc_virt_temp_label = label_aquaero_calc_temp_sensors;
@@ -1443,6 +1459,11 @@ static int aqc_probe(struct hid_device *hdev, const struct hid_device_id *id)
priv->firmware_version_offset = AQUAERO_FIRMWARE_VERSION;
priv->fan_structure = &aqc_aquaero_fan_structure;
+
+ priv->ctrl_report_id = AQUAERO_CTRL_REPORT_ID;
+ priv->secondary_ctrl_report_id = AQUAERO_SECONDARY_CTRL_REPORT_ID;
+ priv->secondary_ctrl_report_size = AQUAERO_SECONDARY_CTRL_REPORT_SIZE;
+ priv->secondary_ctrl_report = aquaero_secondary_ctrl_report;
break;
case poweradjust3:
priv->status_report_id = POWERADJUST3_STATUS_REPORT_ID;
--
2.39.1
next prev parent reply other threads:[~2023-02-14 22:02 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-14 22:02 [PATCH v2 0/6] hwmon: (aquacomputer_d5next) Add Aquacomputer Aquaero control Leonard Anderweit
2023-02-14 22:02 ` [PATCH v2 1/6] hwmon: (aquacomputer_d5next) Support one byte control values Leonard Anderweit
2023-03-12 17:41 ` Guenter Roeck
2023-02-14 22:02 ` [PATCH v2 2/6] hwmon: (aquacomputer_d5next) Support writing multiple control values at once Leonard Anderweit
2023-03-12 17:42 ` Guenter Roeck
2023-02-14 22:02 ` [PATCH v2 3/6] hwmon: (aquacomputer_d5next) Device dependent control report settings Leonard Anderweit
2023-03-12 17:43 ` Guenter Roeck
2023-02-14 22:02 ` Leonard Anderweit [this message]
2023-03-12 17:44 ` [PATCH v2 4/6] hwmon: (aquacomputer_d5next) Add infrastructure for Aquaero control reports Guenter Roeck
2023-02-14 22:02 ` [PATCH v2 5/6] hwmon: (aquacomputer_d5next) Add temperature offset control for Aquaero Leonard Anderweit
2023-03-12 17:45 ` Guenter Roeck
2023-02-14 22:02 ` [PATCH v2 6/6] hwmon: (aquacomputer_d5next) Add fan PWM " Leonard Anderweit
2023-03-12 17:48 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230214220221.15003-5-leonard.anderweit@gmail.com \
--to=leonard.anderweit@gmail.com \
--cc=corbet@lwn.net \
--cc=jdelvare@suse.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=me@jackdoan.com \
--cc=savicaleksa83@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox