From patchwork Sun Jan 12 11:44:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Mayer X-Patchwork-Id: 13936334 X-Patchwork-Delegate: jikos@jikos.cz Received: from relay.yourmailgateway.de (relay.yourmailgateway.de [188.68.63.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1431F1AA1C0; Sun, 12 Jan 2025 11:55:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=188.68.63.98 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736682953; cv=none; b=avf0oeVPo+ZwZeB+dLdvDQXSXj18+rbTHWMduCjxafqcPHMQWV46nHfu2be4oDoBEKqzNOPH9Kv7Aei4fALHINcRUjgqRsjM3N2yzWKpgmAwTSxwp55Isf5KG+6aMdyb83VSZVG9jc2nBimzVW1ITqpGsDOEatc7WaEkYO2dVUg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736682953; c=relaxed/simple; bh=c2Qg2W4Am2s9tSAVlOTM0t3lcWgTk5K8kLoKH6k09mE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y5OYMA38NDgsEF4guQZ2OtcabZlPQZMTNh4HcP/XPry3Txp+W8dsvkVLfUG/fwaPJmHcQGORNI7Z/MAeTknnOQvqKCYf8pcZu/+2CidmTngfhj8vCFwxBh7sKgs2STR4t2z5gRvVs1n7i4tvt8Uy7GnShANgJYcOVz5II+isUUg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mayer-bgk.de; spf=pass smtp.mailfrom=mayer-bgk.de; dkim=pass (2048-bit key) header.d=mayer-bgk.de header.i=@mayer-bgk.de header.b=Atqjg4Lj; arc=none smtp.client-ip=188.68.63.98 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mayer-bgk.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mayer-bgk.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mayer-bgk.de header.i=@mayer-bgk.de header.b="Atqjg4Lj" Received: from mors-relay-2501.netcup.net (localhost [127.0.0.1]) by mors-relay-2501.netcup.net (Postfix) with ESMTPS id 4YWD9M4Npvz635j; Sun, 12 Jan 2025 12:45:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mayer-bgk.de; s=key2; t=1736682343; bh=c2Qg2W4Am2s9tSAVlOTM0t3lcWgTk5K8kLoKH6k09mE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Atqjg4LjmHRLYLzSWTwZhK/pCP6TnhMO9x1zIYfN+7WKS7WvYyQIfQqc2nTsdPQe6 ahwXQ0LtW+ED1ki32rbnrMWtWM8iO69dDNzml7ig8N0kQIyd62zn9w7mB71v66JIrm lppkWhIc20Cqe6EhNQUbPAGaTBB1Rr8uVbZE5/LqkrgPF64WiPZRvo+Mb6UUxYpiEA G+LDFbI3S+GfgEqH9EKBUff3mz+DL/QgEP3VoUwpX9s8U2K480q5h7LoFhk65r6MBu VuPzaYF0lldRpklR27iEMWQ6v60aokavpdpgiQMjon2UyRYkoQJRafijrn1j+OvgtM XQC2mSnCNXlvA== Received: from policy01-mors.netcup.net (unknown [46.38.225.35]) by mors-relay-2501.netcup.net (Postfix) with ESMTPS id 4YWD9M3gSFz4xpN; Sun, 12 Jan 2025 12:45:43 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at policy01-mors.netcup.net X-Spam-Flag: NO X-Spam-Score: -2.898 X-Spam-Level: Received: from mxe85d.netcup.net (unknown [10.243.12.53]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by policy01-mors.netcup.net (Postfix) with ESMTPS id 4YWD9L749Sz8tXV; Sun, 12 Jan 2025 12:45:42 +0100 (CET) Received: from localhost.localdomain (ipbcc1eb64.dynamic.kabel-deutschland.de [188.193.235.100]) by mxe85d.netcup.net (Postfix) with ESMTPSA id 65D521C0241; Sun, 12 Jan 2025 12:45:38 +0100 (CET) Authentication-Results: mxe85d; spf=pass (sender IP is 188.193.235.100) smtp.mailfrom=git@mayer-bgk.de smtp.helo=localhost.localdomain Received-SPF: pass (mxe85d: connection is authenticated) From: Christian Mayer To: linux-input@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Jiri Kosina , Benjamin Tissoires , Bastien Nocera , Christian Mayer Subject: [PATCH v2 1/5] HID: steelseries: preparation for adding SteelSeries Arctis 9 support Date: Sun, 12 Jan 2025 11:44:02 +0000 Message-ID: <20250112114438.2196-2-git@mayer-bgk.de> X-Mailer: git-send-email 2.48.0 In-Reply-To: <20250112114438.2196-1-git@mayer-bgk.de> References: <20250112114438.2196-1-git@mayer-bgk.de> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-PPP-Message-ID: <173668233876.12485.7873896203491597199@mxe85d.netcup.net> X-Rspamd-Queue-Id: 65D521C0241 X-Rspamd-Server: rspamd-worker-8404 X-NC-CID: SmvnBteQws+En2bXzbvavnvXrkXHiCL+CnCnDsAI4rY5auiYX7c= Refactor code and add calls to hid_hw_open/hid_hw_closed in preparation for adding support for the SteelSeries Arctis 9 headset. Signed-off-by: Christian Mayer --- drivers/hid/hid-steelseries.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/hid/hid-steelseries.c b/drivers/hid/hid-steelseries.c index f9ff5be94309..dc4ab55d7c22 100644 --- a/drivers/hid/hid-steelseries.c +++ b/drivers/hid/hid-steelseries.c @@ -377,20 +377,21 @@ static void steelseries_srws1_remove(struct hid_device *hdev) #define ARCTIS_1_BATTERY_RESPONSE_LEN 8 static const char arctis_1_battery_request[] = { 0x06, 0x12 }; -static int steelseries_headset_arctis_1_fetch_battery(struct hid_device *hdev) +static int steelseries_headset_request_battery(struct hid_device *hdev, + const char *request, size_t len) { u8 *write_buf; int ret; /* Request battery information */ - write_buf = kmemdup(arctis_1_battery_request, sizeof(arctis_1_battery_request), GFP_KERNEL); + write_buf = kmemdup(request, len, GFP_KERNEL); if (!write_buf) return -ENOMEM; - ret = hid_hw_raw_request(hdev, arctis_1_battery_request[0], - write_buf, sizeof(arctis_1_battery_request), + hid_dbg(hdev, "Sending battery request report"); + ret = hid_hw_raw_request(hdev, request[0], write_buf, len, HID_OUTPUT_REPORT, HID_REQ_SET_REPORT); - if (ret < (int)sizeof(arctis_1_battery_request)) { + if (ret < (int)len) { hid_err(hdev, "hid_hw_raw_request() failed with %d\n", ret); ret = -ENODATA; } @@ -404,7 +405,8 @@ static void steelseries_headset_fetch_battery(struct hid_device *hdev) int ret = 0; if (sd->quirks & STEELSERIES_ARCTIS_1) - ret = steelseries_headset_arctis_1_fetch_battery(hdev); + ret = steelseries_headset_request_battery(hdev, + arctis_1_battery_request, sizeof(arctis_1_battery_request)); if (ret < 0) hid_dbg(hdev, @@ -554,6 +556,10 @@ static int steelseries_probe(struct hid_device *hdev, const struct hid_device_id if (ret) return ret; + ret = hid_hw_open(hdev); + if (ret) + return ret; + if (steelseries_headset_battery_register(sd) < 0) hid_err(sd->hdev, "Failed to register battery for headset\n"); @@ -580,6 +586,7 @@ static void steelseries_remove(struct hid_device *hdev) cancel_delayed_work_sync(&sd->battery_work); + hid_hw_close(hdev); hid_hw_stop(hdev); } From patchwork Sun Jan 12 11:44:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Mayer X-Patchwork-Id: 13936332 X-Patchwork-Delegate: jikos@jikos.cz Received: from relay.yourmailgateway.de (relay.yourmailgateway.de [46.38.247.119]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F1D7C1AA7A6; Sun, 12 Jan 2025 11:54:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.38.247.119 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736682866; cv=none; b=PnYje93D6yYDNHL4Pz3UIbvLnzrF1BUVIBBZvfp4q79g9g1qKVaGTdWMunfXwVDzZ3Xl3E6Yh259RcT02EZej7ITWkMmfavakXvRnlpT6R+/9iXuiPy4O6pDUsjpstmzOHZbSOh0eZ1ea1zOGFObClb6bjjCUcKVQTbIn75iuhM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736682866; c=relaxed/simple; bh=nqBlht6PLkjaqE1mMZtDv1vYeIhXn3G/s/GZRuYr2mY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UWa5EbZ8SLy8yad11S1V3uycJbHTWIhgSuUp9sJyG8PO8gPoeysYJWYcMmzfuOPzZ2oX6qfUAL2DAIcV6J5NnN1uNkL+knhf6Jk8U8v1XdPf9va7VCHdfehDVdiO9FNmHQKLElrbf/Drd8IX5xALsvXPFQ9ZNDp33SUgo9af0w8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mayer-bgk.de; spf=pass smtp.mailfrom=mayer-bgk.de; dkim=pass (2048-bit key) header.d=mayer-bgk.de header.i=@mayer-bgk.de header.b=ZWpfD/jG; arc=none smtp.client-ip=46.38.247.119 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mayer-bgk.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mayer-bgk.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mayer-bgk.de header.i=@mayer-bgk.de header.b="ZWpfD/jG" Received: from mors-relay-8404.netcup.net (localhost [127.0.0.1]) by mors-relay-8404.netcup.net (Postfix) with ESMTPS id 4YWD9S2VyDz82nZ; Sun, 12 Jan 2025 12:45:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mayer-bgk.de; s=key2; t=1736682348; bh=nqBlht6PLkjaqE1mMZtDv1vYeIhXn3G/s/GZRuYr2mY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZWpfD/jGBRbHYXu3zuMQQa8Ico/IGykst9L/qEwTAS75cndDwxtJrP9WB7Fls2qFq mMRqEZLkzPWRXqSkKKchvXXMCfClJY3pUNrvxUnkGFnHMROdFX3Vteg3vBwzNUgx++ 15XIGsbynijoVLGRCdQZjb6oEglTN5D5I9uMJl6ZZ8jRp2MYXgZQ0m2P8x2t9l7Qty JR3DfiSTtcD6/MKJWGiRjXEKu4pXSgyT3ApifNSWqIVKYeIo9Fr63oUpcmuM3LbzfV tfsf++8uJF7aBw37TmJlNIjDieZthw4+azpOLgX7pIvGSaew99zp5EA78h7cTDBDsZ SQFCijLN2y3hQ== Received: from policy01-mors.netcup.net (unknown [46.38.225.35]) by mors-relay-8404.netcup.net (Postfix) with ESMTPS id 4YWD9S26CDz4y3x; Sun, 12 Jan 2025 12:45:48 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at policy01-mors.netcup.net X-Spam-Flag: NO X-Spam-Score: -2.898 X-Spam-Level: Received: from mxe85d.netcup.net (unknown [10.243.12.53]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by policy01-mors.netcup.net (Postfix) with ESMTPS id 4YWD9R46Mjz8tYH; Sun, 12 Jan 2025 12:45:47 +0100 (CET) Received: from localhost.localdomain (ipbcc1eb64.dynamic.kabel-deutschland.de [188.193.235.100]) by mxe85d.netcup.net (Postfix) with ESMTPSA id F19251C020D; Sun, 12 Jan 2025 12:45:42 +0100 (CET) Authentication-Results: mxe85d; spf=pass (sender IP is 188.193.235.100) smtp.mailfrom=git@mayer-bgk.de smtp.helo=localhost.localdomain Received-SPF: pass (mxe85d: connection is authenticated) From: Christian Mayer To: linux-input@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Jiri Kosina , Benjamin Tissoires , Bastien Nocera , Christian Mayer Subject: [PATCH v2 2/5] HID: steelseries: add SteelSeries Arctis 9 support Date: Sun, 12 Jan 2025 11:44:03 +0000 Message-ID: <20250112114438.2196-3-git@mayer-bgk.de> X-Mailer: git-send-email 2.48.0 In-Reply-To: <20250112114438.2196-1-git@mayer-bgk.de> References: <20250112114438.2196-1-git@mayer-bgk.de> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-PPP-Message-ID: <173668234333.17581.6933279873829176323@mxe85d.netcup.net> X-Rspamd-Queue-Id: F19251C020D X-Rspamd-Server: rspamd-worker-8404 X-NC-CID: NY/xQFHmUdNfwij+wdW7HViO+ollAXLm1SUNq+QDkplxjiiZN3s= Add support for the SteelSeries Arctis 9 headset. This driver will export the battery information like it already does for the Arcits 1 headset. Signed-off-by: Christian Mayer --- drivers/hid/hid-steelseries.c | 64 +++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/drivers/hid/hid-steelseries.c b/drivers/hid/hid-steelseries.c index dc4ab55d7c22..2b98db7f8911 100644 --- a/drivers/hid/hid-steelseries.c +++ b/drivers/hid/hid-steelseries.c @@ -19,6 +19,7 @@ #define STEELSERIES_SRWS1 BIT(0) #define STEELSERIES_ARCTIS_1 BIT(1) +#define STEELSERIES_ARCTIS_9 BIT(2) struct steelseries_device { struct hid_device *hdev; @@ -375,7 +376,9 @@ static void steelseries_srws1_remove(struct hid_device *hdev) #define STEELSERIES_HEADSET_BATTERY_TIMEOUT_MS 3000 #define ARCTIS_1_BATTERY_RESPONSE_LEN 8 +#define ARCTIS_9_BATTERY_RESPONSE_LEN 64 static const char arctis_1_battery_request[] = { 0x06, 0x12 }; +static const char arctis_9_battery_request[] = { 0x00, 0x20 }; static int steelseries_headset_request_battery(struct hid_device *hdev, const char *request, size_t len) @@ -395,6 +398,7 @@ static int steelseries_headset_request_battery(struct hid_device *hdev, hid_err(hdev, "hid_hw_raw_request() failed with %d\n", ret); ret = -ENODATA; } + kfree(write_buf); return ret; } @@ -407,6 +411,9 @@ static void steelseries_headset_fetch_battery(struct hid_device *hdev) if (sd->quirks & STEELSERIES_ARCTIS_1) ret = steelseries_headset_request_battery(hdev, arctis_1_battery_request, sizeof(arctis_1_battery_request)); + else if (sd->quirks & STEELSERIES_ARCTIS_9) + ret = steelseries_headset_request_battery(hdev, + arctis_9_battery_request, sizeof(arctis_9_battery_request)); if (ret < 0) hid_dbg(hdev, @@ -522,9 +529,22 @@ static int steelseries_headset_battery_register(struct steelseries_device *sd) INIT_DELAYED_WORK(&sd->battery_work, steelseries_headset_battery_timer_tick); steelseries_headset_fetch_battery(sd->hdev); + if (sd->quirks & STEELSERIES_ARCTIS_9) { + /* The first fetch_battery request can remain unanswered in some cases */ + schedule_delayed_work(&sd->battery_work, + msecs_to_jiffies(STEELSERIES_HEADSET_BATTERY_TIMEOUT_MS)); + } + return 0; } +static bool steelseries_is_vendor_usage_page(struct hid_device *hdev, uint8_t usage_page) +{ + return hdev->rdesc[0] == 0x06 && + hdev->rdesc[1] == usage_page && + hdev->rdesc[2] == 0xff; +} + static int steelseries_probe(struct hid_device *hdev, const struct hid_device_id *id) { struct steelseries_device *sd; @@ -550,6 +570,10 @@ static int steelseries_probe(struct hid_device *hdev, const struct hid_device_id if (ret) return ret; + if (sd->quirks & STEELSERIES_ARCTIS_9 && + !steelseries_is_vendor_usage_page(hdev, 0xc0)) + return -ENODEV; + spin_lock_init(&sd->lock); ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); @@ -606,6 +630,15 @@ static const __u8 *steelseries_srws1_report_fixup(struct hid_device *hdev, return rdesc; } +static uint8_t steelseries_headset_map_capacity(uint8_t capacity, uint8_t min_in, uint8_t max_in) +{ + if (capacity >= max_in) + return 100; + if (capacity <= min_in) + return 0; + return (capacity - min_in) * 100 / (max_in - min_in); +} + static int steelseries_headset_raw_event(struct hid_device *hdev, struct hid_report *report, u8 *read_buf, int size) @@ -637,6 +670,32 @@ static int steelseries_headset_raw_event(struct hid_device *hdev, } } + if (sd->quirks & STEELSERIES_ARCTIS_9) { + hid_dbg(sd->hdev, + "Parsing raw event for Arctis 9 headset (%*ph)\n", size, read_buf); + if (size < ARCTIS_9_BATTERY_RESPONSE_LEN) { + if (!delayed_work_pending(&sd->battery_work)) + goto request_battery; + return 0; + } + + if (read_buf[0] == 0xaa && read_buf[1] == 0x01) { + connected = true; + + /* + * Found no official documentation about min and max. + * Values defined by testing. + */ + capacity = steelseries_headset_map_capacity(read_buf[3], 0x68, 0x9d); + } else { + /* + * Device is off and sends the last known status read_buf[1] == 0x03 or + * there is no known status of the device read_buf[0] == 0x55 + */ + connected = false; + } + } + if (connected != sd->headset_connected) { hid_dbg(sd->hdev, "Connected status changed from %sconnected to %sconnected\n", @@ -672,6 +731,10 @@ static const struct hid_device_id steelseries_devices[] = { HID_USB_DEVICE(USB_VENDOR_ID_STEELSERIES, 0x12b6), .driver_data = STEELSERIES_ARCTIS_1 }, + { /* SteelSeries Arctis 9 Wireless for XBox */ + HID_USB_DEVICE(USB_VENDOR_ID_STEELSERIES, 0x12c2), + .driver_data = STEELSERIES_ARCTIS_9 }, + { } }; MODULE_DEVICE_TABLE(hid, steelseries_devices); @@ -690,3 +753,4 @@ MODULE_DESCRIPTION("HID driver for Steelseries devices"); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Bastien Nocera "); MODULE_AUTHOR("Simon Wood "); +MODULE_AUTHOR("Christian Mayer "); From patchwork Sun Jan 12 11:44:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Mayer X-Patchwork-Id: 13936328 X-Patchwork-Delegate: jikos@jikos.cz Received: from relay.yourmailgateway.de (relay.yourmailgateway.de [185.244.194.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF30F24B254; Sun, 12 Jan 2025 11:45:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.244.194.184 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736682362; cv=none; b=HoGJt8e9q8GLHMzCyfFxYNhDYrZuc6kq1PZTnIRTfwBsVsvfk+rvX7frzJaSq1CLD4IDzYa6Job0OLqsSEjnVLZHnDlSfrdsHDmJQhcbdjzKOCQvfPMkEjedsJQmyAfUZZUsH5Y7OcS6x+dNN7zUfnQC7fG+Al8rjLb1abX1qrs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736682362; c=relaxed/simple; bh=rTEVsmoC9nP3W3gZ2WPh+yMqQSQCcCzHCt8rTbkZLu4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fSOjdVV5XGadFYybu+mTUP76pXf0RUzyQ/llGFOZPwFNNLbY2LQtmwL8k/h2KitjIqKOs62FLHRqtHQ9zOGGaWtpZTOYNB0G6rLCcKPkxSYkrq7QwyXQ5nTTKTvLRJiRwLCItxTvmYwSFyTaQ2uyyHp8YC0u3mjX1rUwKtuIAcg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mayer-bgk.de; spf=pass smtp.mailfrom=mayer-bgk.de; dkim=pass (2048-bit key) header.d=mayer-bgk.de header.i=@mayer-bgk.de header.b=b4kR6zGp; arc=none smtp.client-ip=185.244.194.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mayer-bgk.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mayer-bgk.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mayer-bgk.de header.i=@mayer-bgk.de header.b="b4kR6zGp" Received: from relay01-mors.netcup.net (localhost [127.0.0.1]) by relay01-mors.netcup.net (Postfix) with ESMTPS id 4YWD9X4H58z91DF; Sun, 12 Jan 2025 12:45:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mayer-bgk.de; s=key2; t=1736682352; bh=rTEVsmoC9nP3W3gZ2WPh+yMqQSQCcCzHCt8rTbkZLu4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b4kR6zGp2pO2tZAUrj0jI2v4SxQ4VAqg62nmC603WdR5UkkG3+jfdWqO+HsFw9vTu aEtE2XNQ+z7UpNc2xD8QiYjNIx9cGv3Mp0XbJ8TbxYXwzHmSAUxtnodQOdRTbfKror KX3fhjfrHAYDCSl74rX8SL+nSXHCjiD5r9pcXnMdOfM3BHj3FRRTD94tCqXWw5nHfi FWf7FCjZ9Vb2WEUo722psgrn7EmAEMcKehE9AaZzfXfvXSpcnZlNeQcuO0AXQILqlx vZF8IvarhmQzKCJH0Hq7/oBEWG6wrACjDVIl3po85T0fKf50cJIbW3RwD8hahKFupa +Cz349Nc2A0cQ== Received: from policy02-mors.netcup.net (unknown [46.38.225.35]) by relay01-mors.netcup.net (Postfix) with ESMTPS id 4YWD9X3bXwz7xcw; Sun, 12 Jan 2025 12:45:52 +0100 (CET) Received: from mxe85d.netcup.net (unknown [10.243.12.53]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by policy02-mors.netcup.net (Postfix) with ESMTPS id 4YWD9X1Zd1z8sb8; Sun, 12 Jan 2025 12:45:52 +0100 (CET) Received: from localhost.localdomain (ipbcc1eb64.dynamic.kabel-deutschland.de [188.193.235.100]) by mxe85d.netcup.net (Postfix) with ESMTPSA id 8CEEF1C0241; Sun, 12 Jan 2025 12:45:47 +0100 (CET) Authentication-Results: mxe85d; spf=pass (sender IP is 188.193.235.100) smtp.mailfrom=git@mayer-bgk.de smtp.helo=localhost.localdomain Received-SPF: pass (mxe85d: connection is authenticated) From: Christian Mayer To: linux-input@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Jiri Kosina , Benjamin Tissoires , Bastien Nocera , Christian Mayer Subject: [PATCH v2 3/5] HID: steelseries: export charging state for the SteelSeries Arctis 9 headset Date: Sun, 12 Jan 2025 11:44:04 +0000 Message-ID: <20250112114438.2196-4-git@mayer-bgk.de> X-Mailer: git-send-email 2.48.0 In-Reply-To: <20250112114438.2196-1-git@mayer-bgk.de> References: <20250112114438.2196-1-git@mayer-bgk.de> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-PPP-Message-ID: <173668234791.24538.18307518253673257588@mxe85d.netcup.net> X-Rspamd-Queue-Id: 8CEEF1C0241 X-Rspamd-Server: rspamd-worker-8404 X-NC-CID: qbWT0wvedST9Z/DdjiD4GT/TKurJM+OedzuvxIBJ5UMlGNe5jT8= The Arctis 9 headset provides the information if the power cable is plugged in and charging via the battery report. This information can be exported. Signed-off-by: Christian Mayer --- drivers/hid/hid-steelseries.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/hid/hid-steelseries.c b/drivers/hid/hid-steelseries.c index 2b98db7f8911..2ee1a6f01852 100644 --- a/drivers/hid/hid-steelseries.c +++ b/drivers/hid/hid-steelseries.c @@ -33,6 +33,7 @@ struct steelseries_device { struct power_supply *battery; uint8_t battery_capacity; bool headset_connected; + bool battery_charging; }; #if IS_BUILTIN(CONFIG_LEDS_CLASS) || \ @@ -450,9 +451,12 @@ static int steelseries_headset_battery_get_property(struct power_supply *psy, val->intval = 1; break; case POWER_SUPPLY_PROP_STATUS: - val->intval = sd->headset_connected ? - POWER_SUPPLY_STATUS_DISCHARGING : - POWER_SUPPLY_STATUS_UNKNOWN; + if (sd->headset_connected) { + val->intval = sd->battery_charging ? + POWER_SUPPLY_STATUS_CHARGING : + POWER_SUPPLY_STATUS_DISCHARGING; + } else + val->intval = POWER_SUPPLY_STATUS_UNKNOWN; break; case POWER_SUPPLY_PROP_SCOPE: val->intval = POWER_SUPPLY_SCOPE_DEVICE; @@ -514,6 +518,7 @@ static int steelseries_headset_battery_register(struct steelseries_device *sd) /* avoid the warning of 0% battery while waiting for the first info */ steelseries_headset_set_wireless_status(sd->hdev, false); sd->battery_capacity = 100; + sd->battery_charging = false; sd->battery = devm_power_supply_register(&sd->hdev->dev, &sd->battery_desc, &battery_cfg); @@ -646,6 +651,7 @@ static int steelseries_headset_raw_event(struct hid_device *hdev, struct steelseries_device *sd = hid_get_drvdata(hdev); int capacity = sd->battery_capacity; bool connected = sd->headset_connected; + bool charging = sd->battery_charging; unsigned long flags; /* Not a headset */ @@ -681,6 +687,7 @@ static int steelseries_headset_raw_event(struct hid_device *hdev, if (read_buf[0] == 0xaa && read_buf[1] == 0x01) { connected = true; + charging = read_buf[4] == 0x01; /* * Found no official documentation about min and max. @@ -693,6 +700,7 @@ static int steelseries_headset_raw_event(struct hid_device *hdev, * there is no known status of the device read_buf[0] == 0x55 */ connected = false; + charging = false; } } @@ -713,6 +721,15 @@ static int steelseries_headset_raw_event(struct hid_device *hdev, power_supply_changed(sd->battery); } + if (charging != sd->battery_charging) { + hid_dbg(sd->hdev, + "Battery charging status changed from %scharging to %scharging\n", + sd->battery_charging ? "" : "not ", + charging ? "" : "not "); + sd->battery_charging = charging; + power_supply_changed(sd->battery); + } + request_battery: spin_lock_irqsave(&sd->lock, flags); if (!sd->removed) From patchwork Sun Jan 12 11:44:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Mayer X-Patchwork-Id: 13936333 X-Patchwork-Delegate: jikos@jikos.cz Received: from relay.yourmailgateway.de (relay.yourmailgateway.de [188.68.63.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F26711AA1C0; Sun, 12 Jan 2025 11:55:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=188.68.63.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736682903; cv=none; b=AOFvdXaMVV5doG0lQJT86JPh8h/1odxNIoa+fMdDB5f9AGpfc4KevRxUW56FNy+HMA/1pP/oOqbQV7NhzokPTKsLGq15LjberQaOw5b/EYEGCEiSeCwJ4VjjJuFwSkbTBWJrHOfjt/mdPiIJBWq75GY748S1OrLres9Zvq8TwnI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736682903; c=relaxed/simple; bh=h2jJMA4mrHQMGvfB4zJKFlu4n261Lxg9g8UMza6F5P0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hsjR16rM31LsoLsicWW0qBsCZBlobvH5lS/04cnxRnikD+9tPl29a1WV7mL7XRHGF46JkwqPxdKGJu7NzqVWz1D12J8wXSnVz4QdEYyjzI0+KTrF+aGt/DobdGV+OkhySqO8YyMtQctC4IqY+v8oiLOaXGTve8fNmHGDlWTQzYc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mayer-bgk.de; spf=pass smtp.mailfrom=mayer-bgk.de; dkim=pass (2048-bit key) header.d=mayer-bgk.de header.i=@mayer-bgk.de header.b=RRLUYKLD; arc=none smtp.client-ip=188.68.63.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mayer-bgk.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mayer-bgk.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mayer-bgk.de header.i=@mayer-bgk.de header.b="RRLUYKLD" Received: from mors-relay8203.netcup.net (localhost [127.0.0.1]) by mors-relay8203.netcup.net (Postfix) with ESMTPS id 4YWD9d2193z8bWt; Sun, 12 Jan 2025 11:45:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mayer-bgk.de; s=key2; t=1736682357; bh=h2jJMA4mrHQMGvfB4zJKFlu4n261Lxg9g8UMza6F5P0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RRLUYKLDr8hqsLC2cQexSyu9FV4jhKwEvPiwVC+wzwOWEzUYn4jerfHZc4A4AsppR 8OnBRlKYAU1hICsBQAplQKOO3NRZnOBKqF2/Ep9YPClEagf27ZPNMqY44rfKWos0yb PiFv2az75sAlkDYsWjbmyO7NhLaQxhPmrfM9PwuWRFj3nqwE5LEyFsJ2BBv3yuKuRN uQ7Kk6s3jwS7MzlMRKW0GfvPgNjZEABzZ6527x9j2VzCkaMStUm6GbDC2ADqQ2KCMZ EXo1YvHPGz6vsRA0Vi2V3WVQgnPcdrfccajsn0YeHnyiyf+J+wpwPW4Fsz8QmNsplh 6VMITISbQT8hw== Received: from policy01-mors.netcup.net (unknown [46.38.225.35]) by mors-relay8203.netcup.net (Postfix) with ESMTPS id 4YWD9d1H7Sz8bWb; Sun, 12 Jan 2025 11:45:57 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at policy01-mors.netcup.net X-Spam-Flag: NO X-Spam-Score: -2.898 X-Spam-Level: Received: from mxe85d.netcup.net (unknown [10.243.12.53]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by policy01-mors.netcup.net (Postfix) with ESMTPS id 4YWD9c51v6z8tYM; Sun, 12 Jan 2025 12:45:56 +0100 (CET) Received: from localhost.localdomain (ipbcc1eb64.dynamic.kabel-deutschland.de [188.193.235.100]) by mxe85d.netcup.net (Postfix) with ESMTPSA id 1FF5F1C020D; Sun, 12 Jan 2025 12:45:52 +0100 (CET) Authentication-Results: mxe85d; spf=pass (sender IP is 188.193.235.100) smtp.mailfrom=git@mayer-bgk.de smtp.helo=localhost.localdomain Received-SPF: pass (mxe85d: connection is authenticated) From: Christian Mayer To: linux-input@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Jiri Kosina , Benjamin Tissoires , Bastien Nocera , Christian Mayer Subject: [PATCH v2 4/5] HID: steelseries: export model and manufacturer Date: Sun, 12 Jan 2025 11:44:05 +0000 Message-ID: <20250112114438.2196-5-git@mayer-bgk.de> X-Mailer: git-send-email 2.48.0 In-Reply-To: <20250112114438.2196-1-git@mayer-bgk.de> References: <20250112114438.2196-1-git@mayer-bgk.de> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-PPP-Message-ID: <173668235247.32019.8018917105283969233@mxe85d.netcup.net> X-Rspamd-Queue-Id: 1FF5F1C020D X-Rspamd-Server: rspamd-worker-8404 X-NC-CID: rSRxbZDr/iU+29iRTISce5l6spE3dxZfBna+fQCbD0NsqXY4rBU= Export model and manufacturer with the power supply properties. This helps identifing the device in the battery overview. In the case of the Arctis 9 headset, the manufacturer is prefixed twice in the device name. Signed-off-by: Christian Mayer --- drivers/hid/hid-steelseries.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/hid/hid-steelseries.c b/drivers/hid/hid-steelseries.c index 2ee1a6f01852..1a935802880a 100644 --- a/drivers/hid/hid-steelseries.c +++ b/drivers/hid/hid-steelseries.c @@ -439,6 +439,9 @@ static void steelseries_headset_battery_timer_tick(struct work_struct *work) steelseries_headset_fetch_battery(hdev); } +#define STEELSERIES_PREFIX "SteelSeries " +#define STEELSERIES_PREFIX_LEN strlen(STEELSERIES_PREFIX) + static int steelseries_headset_battery_get_property(struct power_supply *psy, enum power_supply_property psp, union power_supply_propval *val) @@ -447,6 +450,14 @@ static int steelseries_headset_battery_get_property(struct power_supply *psy, int ret = 0; switch (psp) { + case POWER_SUPPLY_PROP_MODEL_NAME: + val->strval = sd->hdev->name; + while (!strncmp(val->strval, STEELSERIES_PREFIX, STEELSERIES_PREFIX_LEN)) + val->strval += STEELSERIES_PREFIX_LEN; + break; + case POWER_SUPPLY_PROP_MANUFACTURER: + val->strval = "SteelSeries"; + break; case POWER_SUPPLY_PROP_PRESENT: val->intval = 1; break; @@ -490,6 +501,8 @@ steelseries_headset_set_wireless_status(struct hid_device *hdev, } static enum power_supply_property steelseries_headset_battery_props[] = { + POWER_SUPPLY_PROP_MODEL_NAME, + POWER_SUPPLY_PROP_MANUFACTURER, POWER_SUPPLY_PROP_PRESENT, POWER_SUPPLY_PROP_STATUS, POWER_SUPPLY_PROP_SCOPE, From patchwork Sun Jan 12 11:44:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Mayer X-Patchwork-Id: 13936329 X-Patchwork-Delegate: jikos@jikos.cz Received: from relay.yourmailgateway.de (relay.yourmailgateway.de [188.68.63.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 970A41ACECA; Sun, 12 Jan 2025 11:46:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=188.68.63.162 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736682365; cv=none; b=pJETQegvsOGIsz8Dmnw/XMAHkF1adB219j4drI1EOLp1gKI0YmBnxPEQkCWcSHnwv9o8bD5YUBptioZid6FcOFWc7Kq1tzgsKUXa6dWfEQcH903hurIH9jN4DoPdn+yx3nca5vLySUnMQktDIaHRtwvVC10NnVx63FM5oaYOZGw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736682365; c=relaxed/simple; bh=Byet0scy3vn+n34qIvg/D+B8GMepJS3vmBmJBmXrP30=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eA+d8hDu5oLsaz67Va2UtW485Sfgn892h2RX8cYdVNX7bFy289yZDl597c+gGS/Zi/FMJ0Rjn2QPE67i5iaSeUltpvFUX171AKMTP8/T4SbDoAVJjkyt4kmvG/JDPoaz1u3jL8mPs+5gPScuSE+HgWAhaB02VE1RfLwhMQz38M4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mayer-bgk.de; spf=pass smtp.mailfrom=mayer-bgk.de; dkim=pass (2048-bit key) header.d=mayer-bgk.de header.i=@mayer-bgk.de header.b=VZ3310pG; arc=none smtp.client-ip=188.68.63.162 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mayer-bgk.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mayer-bgk.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mayer-bgk.de header.i=@mayer-bgk.de header.b="VZ3310pG" Received: from mors-relay-8201.netcup.net (localhost [127.0.0.1]) by mors-relay-8201.netcup.net (Postfix) with ESMTPS id 4YWD9j5d3Cz3w6T; Sun, 12 Jan 2025 12:46:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mayer-bgk.de; s=key2; t=1736682361; bh=Byet0scy3vn+n34qIvg/D+B8GMepJS3vmBmJBmXrP30=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VZ3310pG5QZBJteAEuviMvy0ywxWD7BBfXmRlxEfXfaCXHIRod9onOMxRs3YzCFjA 1P2kz+gZEB7eg0CPNKB81pKFvBQ3VldpX88DyhIzLBH3MSjAIF193iFBzMFmagxNGl 0BgUKNVFC7QS89U2Rf9fi7U6v/qvIVbKiTYMoWw8Dl6d5z5FWrIWYDfOBgrHn5fnfH bYjhjZupnl2jdS9/Fvv2+2u6/A9rPbu5wNdkn1ii/WP5kI5f64rMaPNMazr2jDVOjZ KPZknRlDI6uf6aJj5LOPA0A9MSLmGJTtnTlC2yyjR9PKzAr8HFDBk4WMjFjWkQqp/p 3JBhsis97JY9A== Received: from policy01-mors.netcup.net (unknown [46.38.225.35]) by mors-relay-8201.netcup.net (Postfix) with ESMTPS id 4YWD9j4tZbz3w5q; Sun, 12 Jan 2025 12:46:01 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at policy01-mors.netcup.net X-Spam-Flag: NO X-Spam-Score: -2.898 X-Spam-Level: Received: from mxe85d.netcup.net (unknown [10.243.12.53]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by policy01-mors.netcup.net (Postfix) with ESMTPS id 4YWD9j25cKz8t3w; Sun, 12 Jan 2025 12:46:01 +0100 (CET) Received: from localhost.localdomain (ipbcc1eb64.dynamic.kabel-deutschland.de [188.193.235.100]) by mxe85d.netcup.net (Postfix) with ESMTPSA id AB33E1C0241; Sun, 12 Jan 2025 12:45:56 +0100 (CET) Authentication-Results: mxe85d; spf=pass (sender IP is 188.193.235.100) smtp.mailfrom=git@mayer-bgk.de smtp.helo=localhost.localdomain Received-SPF: pass (mxe85d: connection is authenticated) From: Christian Mayer To: linux-input@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Jiri Kosina , Benjamin Tissoires , Bastien Nocera , Christian Mayer Subject: [PATCH v2 5/5] HID: steelseries: remove unnecessary return Date: Sun, 12 Jan 2025 11:44:06 +0000 Message-ID: <20250112114438.2196-6-git@mayer-bgk.de> X-Mailer: git-send-email 2.48.0 In-Reply-To: <20250112114438.2196-1-git@mayer-bgk.de> References: <20250112114438.2196-1-git@mayer-bgk.de> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-PPP-Message-ID: <173668235707.6976.8796768661026332211@mxe85d.netcup.net> X-Rspamd-Queue-Id: AB33E1C0241 X-Rspamd-Server: rspamd-worker-8404 X-NC-CID: eVNMYVQgFdpy11FtfIqa+qH4fcOqWptNQDRVQGyOaahlvG2MlEg= Remove unnecessary return in a void function. Signed-off-by: Christian Mayer --- drivers/hid/hid-steelseries.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/hid/hid-steelseries.c b/drivers/hid/hid-steelseries.c index 1a935802880a..d4bd7848b8c6 100644 --- a/drivers/hid/hid-steelseries.c +++ b/drivers/hid/hid-steelseries.c @@ -370,7 +370,6 @@ static void steelseries_srws1_remove(struct hid_device *hdev) hid_hw_stop(hdev); kfree(drv_data); - return; } #endif