public inbox for linux-input@vger.kernel.org
 help / color / mirror / Atom feed
From: Sriman Achanta <srimanachanta@gmail.com>
To: Jiri Kosina <jikos@kernel.org>, Benjamin Tissoires <bentiss@kernel.org>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	Bastien Nocera <hadess@hadess.net>,
	Simon Wood <simon@mungewell.org>,
	Christian Mayer <git@mayer-bgk.de>,
	Sriman Achanta <srimanachanta@gmail.com>
Subject: [PATCH v3 06/18] HID: steelseries: Add ALSA sound card infrastructure
Date: Fri, 27 Feb 2026 18:50:30 -0500	[thread overview]
Message-ID: <20260227235042.410062-7-srimanachanta@gmail.com> (raw)
In-Reply-To: <20260227235042.410062-1-srimanachanta@gmail.com>

Register an ALSA sound card for each supported Arctis headset to expose
headset-specific audio controls to userspace. The card is created in
steelseries_snd_register() and freed in steelseries_snd_unregister(),
both guarded by a module compatibility check so that registration only
occurs when both SND and HID_STEELSERIES are built-in or are both
modules, avoiding a dependency mismatch.

The Kconfig entry is updated to add SND as a dependency. Subsequent
commits build on this infrastructure to register mixer controls.

Signed-off-by: Sriman Achanta <srimanachanta@gmail.com>
---
 drivers/hid/Kconfig           |  2 +-
 drivers/hid/hid-steelseries.c | 52 +++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 1 deletion(-)

diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 29f05d4b7e30..fcdb5406159a 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -1139,7 +1139,7 @@ config STEAM_FF
 
 config HID_STEELSERIES
 	tristate "Steelseries devices support"
-	depends on USB_HID
+	depends on USB_HID && SND
 	help
 	Support for Steelseries SRW-S1 steering wheel, and the Steelseries
 	Arctis headset family (Arctis 1, Arctis 7, Arctis 7+, Arctis 9,
diff --git a/drivers/hid/hid-steelseries.c b/drivers/hid/hid-steelseries.c
index d8ece8449255..b7f932cde98d 100644
--- a/drivers/hid/hid-steelseries.c
+++ b/drivers/hid/hid-steelseries.c
@@ -16,6 +16,7 @@
 #include <linux/power_supply.h>
 #include <linux/workqueue.h>
 #include <linux/spinlock.h>
+#include <sound/core.h>
 
 #include "hid-ids.h"
 
@@ -50,6 +51,8 @@ struct steelseries_device {
 	u8 battery_capacity;
 	bool battery_charging;
 
+	struct snd_card *card;
+
 	spinlock_t lock;
 	bool removed;
 };
@@ -830,6 +833,43 @@ static int steelseries_battery_register(struct steelseries_device *sd)
 	return 0;
 }
 
+#if IS_BUILTIN(CONFIG_SND) || \
+	(IS_MODULE(CONFIG_SND) && IS_MODULE(CONFIG_HID_STEELSERIES))
+
+static int steelseries_snd_register(struct steelseries_device *sd)
+{
+	struct hid_device *hdev = sd->hdev;
+	int ret;
+
+	ret = snd_card_new(&hdev->dev, -1, "SteelSeries", THIS_MODULE,
+			   0, &sd->card);
+	if (ret < 0)
+		return ret;
+
+	sd->card->private_data = sd;
+	strscpy(sd->card->driver, "SteelSeries");
+	strscpy(sd->card->shortname, hdev->name);
+	snprintf(sd->card->longname, sizeof(sd->card->longname),
+		"%s at USB %s", hdev->name, dev_name(&hdev->dev));
+
+	ret = snd_card_register(sd->card);
+	if (ret < 0) {
+		snd_card_free(sd->card);
+		sd->card = NULL;
+		return ret;
+	}
+
+	return 0;
+}
+
+static void steelseries_snd_unregister(struct steelseries_device *sd)
+{
+	if (sd->card)
+		snd_card_free(sd->card);
+}
+
+#endif
+
 static int steelseries_raw_event(struct hid_device *hdev,
 				 struct hid_report *report, u8 *data, int size)
 {
@@ -975,6 +1015,13 @@ static int steelseries_probe(struct hid_device *hdev,
 				hid_warn(hdev, "Failed to register battery: %d\n", ret);
 		}
 
+#if IS_BUILTIN(CONFIG_SND) || \
+	(IS_MODULE(CONFIG_SND) && IS_MODULE(CONFIG_HID_STEELSERIES))
+		ret = steelseries_snd_register(sd);
+		if (ret < 0)
+			hid_warn(hdev, "Failed to register sound card: %d\n", ret);
+#endif
+
 		INIT_DELAYED_WORK(&sd->status_work, steelseries_status_timer_work_handler);
 		schedule_delayed_work(&sd->status_work, msecs_to_jiffies(100));
 
@@ -1048,6 +1095,11 @@ static void steelseries_remove(struct hid_device *hdev)
 				hid_set_drvdata(sibling, NULL);
 		}
 
+#if IS_BUILTIN(CONFIG_SND) || \
+	(IS_MODULE(CONFIG_SND) && IS_MODULE(CONFIG_HID_STEELSERIES))
+		steelseries_snd_unregister(sd);
+#endif
+
 		spin_lock_irqsave(&sd->lock, flags);
 		sd->removed = true;
 		spin_unlock_irqrestore(&sd->lock, flags);
-- 
2.53.0


  parent reply	other threads:[~2026-02-27 23:50 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-27 23:50 [PATCH v3 00/18] HID: steelseries: Add support for Arctis headset lineup Sriman Achanta
2026-02-27 23:50 ` [PATCH v3 01/18] HID: steelseries: Fix ARCTIS_1_X device mislabeling Sriman Achanta
2026-03-03 10:58   ` Bastien Nocera
2026-02-27 23:50 ` [PATCH v3 02/18] HID: hid-ids: Add SteelSeries Arctis headset device IDs Sriman Achanta
2026-02-27 23:50 ` [PATCH v3 03/18] HID: quirks: Add additional " Sriman Achanta
2026-03-03 10:58   ` Bastien Nocera
2026-02-27 23:50 ` [PATCH v3 04/18] HID: steelseries: Add async support and unify device definitions Sriman Achanta
2026-03-03 10:58   ` Bastien Nocera
2026-02-27 23:50 ` [PATCH v3 05/18] HID: steelseries: Update Kconfig help text for expanded headset support Sriman Achanta
2026-02-27 23:50 ` Sriman Achanta [this message]
2026-03-03 10:58   ` [PATCH v3 06/18] HID: steelseries: Add ALSA sound card infrastructure Bastien Nocera
2026-02-27 23:50 ` [PATCH v3 07/18] HID: steelseries: Add ChatMix ALSA mixer controls Sriman Achanta
2026-02-27 23:50 ` [PATCH v3 08/18] HID: steelseries: Add mic mute ALSA mixer control Sriman Achanta
2026-02-27 23:50 ` [PATCH v3 09/18] HID: steelseries: Add Bluetooth state sysfs attributes Sriman Achanta
2026-03-03 10:58   ` Bastien Nocera
2026-02-27 23:50 ` [PATCH v3 10/18] HID: steelseries: Add settings poll infrastructure Sriman Achanta
2026-03-03 10:58   ` Bastien Nocera
2026-02-27 23:50 ` [PATCH v3 11/18] HID: steelseries: Add sidetone ALSA mixer control Sriman Achanta
2026-02-27 23:50 ` [PATCH v3 12/18] HID: steelseries: Add mic volume " Sriman Achanta
2026-02-27 23:50 ` [PATCH v3 13/18] HID: steelseries: Add volume limiter " Sriman Achanta
2026-02-27 23:50 ` [PATCH v3 14/18] HID: steelseries: Add Bluetooth call audio ducking control Sriman Achanta
2026-03-03 10:59   ` Bastien Nocera
2026-02-27 23:50 ` [PATCH v3 15/18] HID: steelseries: Add inactive time sysfs attribute Sriman Achanta
2026-03-03 10:59   ` Bastien Nocera
2026-02-27 23:50 ` [PATCH v3 16/18] HID: steelseries: Add Bluetooth auto-enable " Sriman Achanta
2026-02-27 23:50 ` [PATCH v3 17/18] HID: steelseries: Add mic mute LED brightness control Sriman Achanta
2026-02-27 23:50 ` [PATCH v3 18/18] HID: steelseries: Document sysfs ABI Sriman Achanta
2026-03-03 10:58   ` Bastien Nocera
2026-03-03 10:59 ` [PATCH v3 00/18] HID: steelseries: Add support for Arctis headset lineup Bastien Nocera

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=20260227235042.410062-7-srimanachanta@gmail.com \
    --to=srimanachanta@gmail.com \
    --cc=bentiss@kernel.org \
    --cc=git@mayer-bgk.de \
    --cc=hadess@hadess.net \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=simon@mungewell.org \
    /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