From patchwork Wed Jan 1 15:11:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Mayer X-Patchwork-Id: 854543 Received: from relay.yourmailgateway.de (relay.yourmailgateway.de [188.68.63.102]) (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 51E1D1773A; Wed, 1 Jan 2025 15:21:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=188.68.63.102 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735744864; cv=none; b=AwLbLKAlGzIsTjBvMWcHtiMU2l+VBSXXQNg46bn41T1ULxWDjoqOA9h0Ra+Y0EO9fecWHT0lu7GELL8IUBgCtQduuLZIId+b+DrFxIdinvMSCFI5SgZggjJDh+EXkGiK4Tq+XhGt1zdDKP4twJern/NbbSdEq//PndkQXRJYpi8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735744864; c=relaxed/simple; bh=Lw82jWC+sDQMdvgh/gtSK1iNo63N3UlmX7A6jVNWvU0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bSNq+v0MKlii0LonxCgRA2+pDFkupZrNOJ/zqU8jYU1ldsMjCIXaXwiZRAQR7qNSSHo96g8WLMW9LTDvok14gVDFSItR3zqvsqWnvhoylK4Umv2s9X4gUxDRM7QK7PgiWMc7DDjCe7mXln+hN9vJS4h31/1FxB4pns2PVSTpU+0= 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=lTOu9plA; arc=none smtp.client-ip=188.68.63.102 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="lTOu9plA" Received: from mors-relay-2502.netcup.net (localhost [127.0.0.1]) by mors-relay-2502.netcup.net (Postfix) with ESMTPS id 4YNYHx3YKrz62S0; Wed, 1 Jan 2025 16:13:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mayer-bgk.de; s=key2; t=1735744397; bh=Lw82jWC+sDQMdvgh/gtSK1iNo63N3UlmX7A6jVNWvU0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lTOu9plA9Z9wN1QR5iB20g2b5u/eSfdLm9H1i0dkNqOUkdPpKxsQ9DleGeNWVmitW raaJVZtDpoccVe3S2CLjX6+NyCVErT0rsB+Z8VjkTTxSUQhebSipE9cSmXKBnUYb7Q 6P4ICPFUhUj145SHm7EcpEiR0Avle27XrBIDxCgLSuSE8lp0GVqwcXzeFPm81T9+CE RIML4vjW3WyhvJbw+DlP5WoUCDl1wxwW1F3WVV4QrCqh+NPIMb+buXbMR1YHja4v8y hTcLp5fm03+7enWZ0HFlFy8yvXUFCi7WfQ9AUCOpQ6VBKlzlPS/PlTuHwzrjkE+Knm 6nr4xaIIuLdpA== Received: from policy02-mors.netcup.net (unknown [46.38.225.35]) by mors-relay-2502.netcup.net (Postfix) with ESMTPS id 4YNYHx2qdxz4xmv; Wed, 1 Jan 2025 16:13:17 +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 4YNYHx0HTdz8scr; Wed, 1 Jan 2025 16:13:17 +0100 (CET) Received: from localhost.localdomain (ipbcc1eb64.dynamic.kabel-deutschland.de [188.193.235.100]) by mxe85d.netcup.net (Postfix) with ESMTPSA id 3CA731C0141; Wed, 1 Jan 2025 16:13:12 +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 1/3] HID: steelseries: add SteelSeries Arctis 9 support Date: Wed, 1 Jan 2025 15:11:32 +0000 Message-ID: <20250101151209.100072-2-git@mayer-bgk.de> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250101151209.100072-1-git@mayer-bgk.de> References: <20250101151209.100072-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: <173574439273.16910.989491538067724427@mxe85d.netcup.net> X-Rspamd-Queue-Id: 3CA731C0141 X-Rspamd-Server: rspamd-worker-8404 X-NC-CID: UYo7m2rrx3b1ERG+/QDe7+mHmEZBHSNN3UZoR1j501bHHF4G0iE= 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 | 105 +++++++++++++++++++++++++++++----- 1 file changed, 90 insertions(+), 15 deletions(-) diff --git a/drivers/hid/hid-steelseries.c b/drivers/hid/hid-steelseries.c index f9ff5be94309..f102045a9b6b 100644 --- a/drivers/hid/hid-steelseries.c +++ b/drivers/hid/hid-steelseries.c @@ -18,7 +18,8 @@ #include "hid-ids.h" #define STEELSERIES_SRWS1 BIT(0) -#define STEELSERIES_ARCTIS_1 BIT(1) +#define STEELSERIES_ARCTIS_1 BIT(1) +#define STEELSERIES_ARCTIS_9 BIT(2) struct steelseries_device { struct hid_device *hdev; @@ -35,7 +36,7 @@ struct steelseries_device { }; #if IS_BUILTIN(CONFIG_LEDS_CLASS) || \ - (IS_MODULE(CONFIG_LEDS_CLASS) && IS_MODULE(CONFIG_HID_STEELSERIES)) + (IS_MODULE(CONFIG_LEDS_CLASS) && IS_MODULE(CONFIG_HID_STEELSERIES)) #define SRWS1_NUMBER_LEDS 15 struct steelseries_srws1_data { __u16 led_state; @@ -95,7 +96,7 @@ static const __u8 steelseries_srws1_rdesc_fixed[] = { 0x29, 0x11, /* Usage Maximum (11h), */ 0x95, 0x11, /* Report Count (17), */ 0x81, 0x02, /* Input (Variable), */ - /* ---- Dial patch starts here ---- */ + /* ---- Dial patch starts here ---- */ 0x05, 0x01, /* Usage Page (Desktop), */ 0x09, 0x33, /* Usage (RX), */ 0x75, 0x04, /* Report Size (4), */ @@ -108,7 +109,7 @@ static const __u8 steelseries_srws1_rdesc_fixed[] = { 0x95, 0x01, /* Report Count (1), */ 0x25, 0x03, /* Logical Maximum (3), */ 0x81, 0x02, /* Input (Variable), */ - /* ---- Dial patch ends here ---- */ + /* ---- Dial patch ends here ---- */ 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */ 0x09, 0x01, /* Usage (01h), */ 0x75, 0x04, /* Changed Report Size (4), */ @@ -125,7 +126,7 @@ static const __u8 steelseries_srws1_rdesc_fixed[] = { }; #if IS_BUILTIN(CONFIG_LEDS_CLASS) || \ - (IS_MODULE(CONFIG_LEDS_CLASS) && IS_MODULE(CONFIG_HID_STEELSERIES)) + (IS_MODULE(CONFIG_LEDS_CLASS) && IS_MODULE(CONFIG_HID_STEELSERIES)) static void steelseries_srws1_set_leds(struct hid_device *hdev, __u16 leds) { struct list_head *report_list = &hdev->report_enum[HID_OUTPUT_REPORT].report_list; @@ -368,32 +369,36 @@ static void steelseries_srws1_remove(struct hid_device *hdev) hid_hw_stop(hdev); kfree(drv_data); - return; } #endif #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_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; } + kfree(write_buf); return ret; } @@ -404,7 +409,11 @@ 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)); + 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, @@ -520,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 usagePage) +{ + return hdev->rdesc[0] == 0x06 && + hdev->rdesc[1] == usagePage && + hdev->rdesc[2] == 0xff; +} + static int steelseries_probe(struct hid_device *hdev, const struct hid_device_id *id) { struct steelseries_device *sd; @@ -537,7 +559,7 @@ static int steelseries_probe(struct hid_device *hdev, const struct hid_device_id if (sd->quirks & STEELSERIES_SRWS1) { #if IS_BUILTIN(CONFIG_LEDS_CLASS) || \ - (IS_MODULE(CONFIG_LEDS_CLASS) && IS_MODULE(CONFIG_HID_STEELSERIES)) + (IS_MODULE(CONFIG_LEDS_CLASS) && IS_MODULE(CONFIG_HID_STEELSERIES)) return steelseries_srws1_probe(hdev, id); #else return -ENODEV; @@ -548,12 +570,22 @@ 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); if (ret) return ret; + if (sd->quirks & STEELSERIES_ARCTIS_9) { + 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"); @@ -568,7 +600,7 @@ static void steelseries_remove(struct hid_device *hdev) if (sd->quirks & STEELSERIES_SRWS1) { #if IS_BUILTIN(CONFIG_LEDS_CLASS) || \ - (IS_MODULE(CONFIG_LEDS_CLASS) && IS_MODULE(CONFIG_HID_STEELSERIES)) + (IS_MODULE(CONFIG_LEDS_CLASS) && IS_MODULE(CONFIG_HID_STEELSERIES)) steelseries_srws1_remove(hdev); #endif return; @@ -580,6 +612,9 @@ static void steelseries_remove(struct hid_device *hdev) cancel_delayed_work_sync(&sd->battery_work); + if (sd->quirks & STEELSERIES_ARCTIS_9) + hid_hw_close(hdev); + hid_hw_stop(hdev); } @@ -599,6 +634,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) @@ -630,6 +674,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", @@ -663,7 +733,11 @@ static const struct hid_device_id steelseries_devices[] = { { /* SteelSeries Arctis 1 Wireless for XBox */ HID_USB_DEVICE(USB_VENDOR_ID_STEELSERIES, 0x12b6), - .driver_data = STEELSERIES_ARCTIS_1 }, + .driver_data = STEELSERIES_ARCTIS_1 }, + + { /* SteelSeries Arctis 9 Wireless for XBox */ + HID_USB_DEVICE(USB_VENDOR_ID_STEELSERIES, 0x12c2), + .driver_data = STEELSERIES_ARCTIS_9 }, { } }; @@ -683,3 +757,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 Wed Jan 1 15:11:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Mayer X-Patchwork-Id: 854779 Received: from relay.yourmailgateway.de (relay.yourmailgateway.de [188.68.63.102]) (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 2ACE41773A; Wed, 1 Jan 2025 15:20:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=188.68.63.102 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735744858; cv=none; b=amkGQYmQa8dx1OX6X/HYk6y2WgbrhNKmMFt//WfmB6pppxDznJq8CytENbtp6gtRVwGCVzFOGzWaO9xQxusOM1s1suc0dVLKW0vec9McL3WsvQ2623uU7HbcuhFdYRmTWcT+Q18SDFc62RnqjGv8/Q5qS7aOZa3bNIIVVHFN8bw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735744858; c=relaxed/simple; bh=mRmNPJKVZBfGhd9BoOamnRNpSYGw9TkH/23FsAKmGYQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LAtjv0i63iifc+NoNKnP/XuQ8HNStU0NBIH3AfYw9hH3hrOiAtNDjHtvzxbJor3m0FkoXDhDAhY1MIy56l0i73CnB6frvl434dV3PP36sPL7D4vVCytvBfF/OAiDgs0W6W9lF6ficJNKvYBxRy8ZLZ4yM5qKD0vbkDG4CLimoXg= 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=TDamURGK; arc=none smtp.client-ip=188.68.63.102 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="TDamURGK" Received: from mors-relay-2502.netcup.net (localhost [127.0.0.1]) by mors-relay-2502.netcup.net (Postfix) with ESMTPS id 4YNYJ22gDNz62SD; Wed, 1 Jan 2025 16:13:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mayer-bgk.de; s=key2; t=1735744402; bh=mRmNPJKVZBfGhd9BoOamnRNpSYGw9TkH/23FsAKmGYQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TDamURGKHIP7ycOhXfHsugj8VrQ37P+YPIjfNZtS59pMlEh08nhO3BpNLCtSGrVO9 8DVgD0zRdqAjzBZXFsi0/h4aXlrh2Bpe5W5R04iRN12DXhxQtVgE34stKheuysDRjf WbfGHrUTwY3uKAVbm/Rl7v5Z7eQ4GMF2q4vNTQqDXX06zg0Gaj0wQNk+BLRr2JW0lK IfwQ1Zbk7MTyTdL8xRNGqDItdDUz26NHAJI0c9ShwGshaKY2ED9IM/kkmi6ztXeboR wAo7hNyLsv4I/aYBEsDOB8N0HjIrYwa2RBqnRqG0jpVVRcCPeqC5LMwdftZWia7v0j T7luAWhbP0C5A== Received: from policy01-mors.netcup.net (unknown [46.38.225.35]) by mors-relay-2502.netcup.net (Postfix) with ESMTPS id 4YNYJ21ywQz4xmv; Wed, 1 Jan 2025 16:13:22 +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 4YNYJ155qgz8sfD; Wed, 1 Jan 2025 16:13:21 +0100 (CET) Received: from localhost.localdomain (ipbcc1eb64.dynamic.kabel-deutschland.de [188.193.235.100]) by mxe85d.netcup.net (Postfix) with ESMTPSA id F2A451C020D; Wed, 1 Jan 2025 16:13:16 +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 2/3] HID: steelseries: export charging state for the SteelSeries Arctis 9 headset Date: Wed, 1 Jan 2025 15:11:33 +0000 Message-ID: <20250101151209.100072-3-git@mayer-bgk.de> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250101151209.100072-1-git@mayer-bgk.de> References: <20250101151209.100072-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: <173574439748.16926.15174893276622874344@mxe85d.netcup.net> X-Rspamd-Queue-Id: F2A451C020D X-Rspamd-Server: rspamd-worker-8404 X-NC-CID: ZGOrU8rS6W4/oKjnb7prEm2Mu9W8gUXJEAv9/i5hcpAxNNFPloc= 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 f102045a9b6b..d11296bc0e1e 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); @@ -650,6 +655,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 */ @@ -685,6 +691,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. @@ -697,6 +704,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; } } @@ -717,6 +725,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 Wed Jan 1 15:11:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Mayer X-Patchwork-Id: 854544 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 941711773A; Wed, 1 Jan 2025 15:20:46 +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=1735744848; cv=none; b=X0VGLueSHz/ERWp688AaQVL7RiOoCY9w9R63K2U/A3MqESZJAunDejVx1t7SLlTU8BtY7aCpwM2xPnWk/t9NQbOx//ae+yiaBrYd7uOn36IpyDBnjRAS7Q725Ko90JVGm1d2KaHoveajqBKGJmYh3u2J2SvhTDGckXr/+yCWMS8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735744848; c=relaxed/simple; bh=Mo4dguvSlYbOPscrEKHFq1Jdv2N4VyiIK6l9zrGvRpM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I8mQPXZpEE/FQmiMoBXoySXfVQei5kwoo0Bt8SCPgRGhQnZMJcGKdHY0OAp1R9rgHFnhwXAJXEsb21WtrU0K49QizEwMbA6tL7eeJq2SapgPNV8Vl3f9rQltdOMyi1Fc882JtJHdbMA3bujajC7VE67XAcP52Q7xWM5KByt/jp0= 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=g2vpCcCz; 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="g2vpCcCz" Received: from mors-relay-2501.netcup.net (localhost [127.0.0.1]) by mors-relay-2501.netcup.net (Postfix) with ESMTPS id 4YNYJ64RtLz62sS; Wed, 1 Jan 2025 16:13:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mayer-bgk.de; s=key2; t=1735744406; bh=Mo4dguvSlYbOPscrEKHFq1Jdv2N4VyiIK6l9zrGvRpM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g2vpCcCzAMYznZt4uFo/694mkGUxik6rKUv78EekyVj41lqkuvHhXZxcqde1Iwq8n coTgktM4itYDMe4omEf8r9tZlaKvi/xaU8fRzVkvQq4mw80CgiAJFxP6QDhPyOWhvp i+ziTFHP+kp9UQjgqlT8zL+CKMcit7XoQ6ZeimZ2az34PMUZhlrmDPX38Y6RiXFB1Z GvOrTVXrLgDxRyKuKleHEjVHVEX/DTqHoNCfLpWJIpFFHZOeBYZPAGwpjalHdpajFl ZcaJqbUy4za71EbTgPKAOsHyRmOi9xT+cSxx/26V6weVCXv13ghzkTy66TxiSRQpo1 XfF150GjI/L2g== Received: from policy02-mors.netcup.net (unknown [46.38.225.35]) by mors-relay-2501.netcup.net (Postfix) with ESMTPS id 4YNYJ63htyz4xjH; Wed, 1 Jan 2025 16:13:26 +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 4YNYJ6214sz8svJ; Wed, 1 Jan 2025 16:13:26 +0100 (CET) Received: from localhost.localdomain (ipbcc1eb64.dynamic.kabel-deutschland.de [188.193.235.100]) by mxe85d.netcup.net (Postfix) with ESMTPSA id B2EC51C01F0; Wed, 1 Jan 2025 16:13:21 +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 3/3] HID: steelseries: export model and manufacturer Date: Wed, 1 Jan 2025 15:11:34 +0000 Message-ID: <20250101151209.100072-4-git@mayer-bgk.de> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250101151209.100072-1-git@mayer-bgk.de> References: <20250101151209.100072-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: <173574440207.16941.16026812623260743882@mxe85d.netcup.net> X-Rspamd-Queue-Id: B2EC51C01F0 X-Rspamd-Server: rspamd-worker-8404 X-NC-CID: 83N3//kkwUUNDdEVVHNN9QnwvXdDtGGx0TcP4LDOieGY98ZYofw= 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 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/hid/hid-steelseries.c b/drivers/hid/hid-steelseries.c index d11296bc0e1e..32e559376be4 100644 --- a/drivers/hid/hid-steelseries.c +++ b/drivers/hid/hid-steelseries.c @@ -447,6 +447,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 ", 12)) + val->strval += 12; + break; + case POWER_SUPPLY_PROP_MANUFACTURER: + val->strval = "SteelSeries"; + break; case POWER_SUPPLY_PROP_PRESENT: val->intval = 1; break; @@ -490,6 +498,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,