[RFC PATCH 11/11] ALSA: mixer_audient: Create matrix programmatically
From: Christian Ruppert
Date: Sat Oct 31 2026 - 20:06:25 EST
Most Audient devices seem to have a similar mixer matrix with many
identical channels. The only difference between devices seems to be
the matrix' dimension. Create it programmatically in a loop rather
than from the controls table.
Signed-off-by: Christian Ruppert <arc@xxxxxx>
---
sound/usb/mixer_audient.c | 75 +++++++++++++++++----------------------
1 file changed, 32 insertions(+), 43 deletions(-)
diff --git a/sound/usb/mixer_audient.c b/sound/usb/mixer_audient.c
index 24b594fb1bc7..30f2f20b1dbb 100644
--- a/sound/usb/mixer_audient.c
+++ b/sound/usb/mixer_audient.c
@@ -103,7 +103,7 @@ static const struct snd_audient_ctrl_type {
struct snd_audient_ctrl {
- char *name;
+ const char *const name;
enum snd_audient_type type;
unsigned int channels;
unsigned int hwchannels;
@@ -132,48 +132,6 @@ static const struct snd_audient_ctrl snd_audient_evo4_controls[] = {
.hwchannels = 1,
.val_offs = 0,
},
- {
- .name = "Mic 1 Capture Volume",
- .type = SND_AUDIENT_TYPE_MIXER,
- .channels = 2,
- .hwchannels = 2,
- .val_offs = 0,
- },
- {
- .name = "Mic 2 Capture Volume",
- .type = SND_AUDIENT_TYPE_MIXER,
- .channels = 2,
- .hwchannels = 2,
- .val_offs = 2,
- },
- {
- .name = "Master Left Capture Volume",
- .type = SND_AUDIENT_TYPE_MIXER,
- .channels = 2,
- .hwchannels = 2,
- .val_offs = 4,
- },
- {
- .name = "Master Right Capture Volume",
- .type = SND_AUDIENT_TYPE_MIXER,
- .channels = 2,
- .hwchannels = 2,
- .val_offs = 6,
- },
- {
- .name = "Loopback Left Capture Volume",
- .type = SND_AUDIENT_TYPE_MIXER,
- .channels = 2,
- .hwchannels = 2,
- .val_offs = 8,
- },
- {
- .name = "Loopback Right Capture Volume",
- .type = SND_AUDIENT_TYPE_MIXER,
- .channels = 2,
- .hwchannels = 2,
- .val_offs = 10,
- },
{
.name = "Mic 1 Phantom Capture Switch",
.type = SND_AUDIENT_TYPE_PHANTOM,
@@ -191,13 +149,27 @@ static const struct snd_audient_ctrl snd_audient_evo4_controls[] = {
{ 0 }, /* sentinel */
};
+static const char *const snd_audient_evo4_matrix[] = {
+ "Mic 1 Capture Volume",
+ "Mic 2 Capture Volume",
+ "Master Left Capture Volume",
+ "Master Right Capture Volume",
+ "Loopback Left Capture Volume",
+ "Loopback Right Capture Volume",
+ NULL
+};
+
static const struct audient_devinfo {
u32 usb_id;
const struct snd_audient_ctrl *controls;
+ const char *const *const matrix_names;
+ const unsigned int matrix_channels;
} audient_devinfo[] = {
{
.usb_id = USB_ID(USB_AUDIENT_VID, USB_EVO4_PID),
.controls = snd_audient_evo4_controls,
+ .matrix_names = snd_audient_evo4_matrix,
+ .matrix_channels = 2,
},
{ 0 } /* sentinel */
};
@@ -626,6 +598,8 @@ int snd_audient_controls_create(struct usb_mixer_interface *mixer)
const struct audient_devinfo *info;
const struct snd_audient_ctrl *ctrl;
+ int i;
+
for (info = audient_devinfo; info->controls; info++)
if (info->usb_id == mixer->chip->usb_id)
break;
@@ -640,5 +614,20 @@ int snd_audient_controls_create(struct usb_mixer_interface *mixer)
return ret;
}
+ for (i = 0; info->matrix_names[i]; i++) {
+ const struct snd_audient_ctrl c = {
+ .name = info->matrix_names[i],
+ .type = SND_AUDIENT_TYPE_MIXER,
+ .channels = info->matrix_channels,
+ .hwchannels = info->matrix_channels,
+ .val_offs = i * info->matrix_channels,
+ };
+
+ const int ret = snd_audient_add_ctrl(mixer, &c);
+
+ if (ret < 0)
+ return ret;
+ }
+
return 0;
}
--
2.56.0