From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.167.169 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796057121; b=CDMpRISwANzUi4vSni7mYLi3MHwVU4MxVlf5xSMJ3SutXGoEFhKeJdapnFyIiW9eHThg pa/fTFLAZ2y4DJMP7+7j+gnTBYwjVB7FJFm+QS4rsSG87JqnNFp9fXhMI4XwfSN93s/Xn SK8AA07wDPilVElD2IWzpTEd0Wwzr9LuRn/H/U0ZIFcxpqNRixRM2GN6m9nCt6yxzt2fE kJw1xhkHiZ5n7tMKO9OaBri7QF4oMTeG62QugytM5NZEYJwXICoFOv5DFTY2fZwn9pwYU xdTxKsXv3r/79swduD3hH85pO1tuuFT9obxiWWvNP6Y1R/r2HNz/QR5STCxGIeMzIHg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796057121; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=NV3NMQTqOGv9mAxFoCotDbqXuCBpwzu1WzLgecZDMDg=; b=49ZDCQq9oGNhFa2UdwjCVuBNj5fBFIZeJPQ4u0k8G1Pb2AlXAS+vYlP1sibzcDQW1e2T t0qn+P3fk50qfonxcrCs5tErmp4RAQ42ZN+G1pdCPQWWfBLZbuNJ5b89qeDNhuid92V54 uUM0RhjaPMrdJoCL35PEIrQ+zO5gWI/uTsXnpdHLLR8OFcv3Vc7O6ZrHJ4cb5FhPWZdOg 6EnH9HMqV3GZNmIOYSImQYVd06KxdrmSxFaE9EXmz19ioKItanmIUDVRdNaTuR2cnArDB AnEAjJs85A5sOlUM31IGea39YHglyX04REcppGPE21xQ5kUTXLDeBpuyj0iPbO/Pbbw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=JZTYwK+R; arc=none smtp.remote-ip=209.85.167.169 Received: from mail-oi1-f169.google.com (mail-oi1-f169.google.com [209.85.167.169]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41804606A33A for ; Mon, 30 Nov 2026 16:45:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 41804606A33A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=JZTYwK+R Received: by mail-oi1-f169.google.com with SMTP id 5614622812f47-57ed36fe509so342353b6e.3 for ; Mon, 30 Nov 2026 08:45:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796057120; x=1796661920; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=NV3NMQTqOGv9mAxFoCotDbqXuCBpwzu1WzLgecZDMDg=; b=JZTYwK+RPyuh/hTqtnr4GJ1HKYAwkhIb2DYgo3b+zqwhLRhK/CsGKkp9s7Si3HQ4Ob RjsuKR9YwlP3OCgIsupIUXgDXuTb6kBziKXe9lk21Uc8I2CsSUOmokyW5FEoz/HQzgQK La4IX1XUHbya43OWwaMrkscYpu37aGk0bI/q2/RfJ0P62BJBGgP47BiBjCtC44Z/lf46 OsN4Zxxci2/9ArK6iwwdhsPgOfBKbvZ29bmdOsysCUl1vqc52WoP2YTY6rGg6aC4Hkn4 CWRPDhAACAINnj9B9pOZWui3K5qvKFRAF9hJzEWlVmeBkoYw15NOQej5rRfyiXj2BiHz Tf+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796057120; x=1796661920; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=NV3NMQTqOGv9mAxFoCotDbqXuCBpwzu1WzLgecZDMDg=; b=0HpCAHj0ZQ6lIwTby06FEUjyAXvUV1ZcphbYx4SJeOce6blJ+eW3hrL9Vr5iZWb214 njf/GiNniwSw+znSeYMB5s4/xd4/T8ws8B7Q5dXj4TMXX1JFyLlPzAwBrtBVJ0uB3nqc X39BefUqFHwvU2HJ0dTlaYWdf+co+zHerYp4xVbTNAb8ToLSeqjooBsCnzA9XwU5whyh kq3uB9EtVvSSU7c9xhC58EkjZGJEphgtajDJLslYIsU+QIsGxll/TlMbtgOw9HNfbHtn r+WUJWmsSL2KPnCbBp2tGh+mBirnVC8vK0UZQjI3Po8jRj6NSGg+4LGojbV2PwQel7Pe DLNQ== X-Forwarded-Encrypted: i=1; AL+hErGsuOyunxdJy2dLZhNlbIf6IvPYL4o+eV7zO9jUppxebKsyMQkmKPM/a38ndCOzzXUeJ69yvhFAP3I1RFo=@vger.kernel.org X-Gm-Message-State: APuU4Z/gCR+xHiqdLA5KGRNKwcKit/VzKb6QN9f/tHP/h8jvGhnMI+kA 5fB5b1nMGlFSckxE5AEDeszwifjw+vzvj8lfqdeKIrOWzeLsAZHhAP2Y X-Gm-Gg: AZFdTZdzC6xjRFp2rAaK+WgQYV9V7m/aaG8pvSVMaHEXni1le6x1D2rLS7Ah1NePj+P XKu+UFXjduHmns/idbOwC+Nz03fb4Not2a8NyzMNmv8yR62QoUZnQpaYE61zWfZU9HYaxGQ+0mT IpasrMrScSgKea1RElfcVbi8jKPkZx/S9wgU9Y1ag9lCr/kEAcVbgN01ebDm+GieU4m8OR+LN61 v4AudsIxG2P1H1NwvyH7ZMbC8AQSZW95QVPRBo6TS7yKNR8Y8doT3D4ncP+djfwss7TcDLgWO3o vHxwxvOB9P+/O2p+a2eqCU2GQLhWRGK/BX6wLL43Wcvpez7DWh0SbYRXisFfb7KfcyHV+A4bjNb k2mhlY8i4oh4/Oft7RiXIYZ3jXR76Ee9ZvaUgr3+E1OHbBoZah2AmfuzofWpCfwPzG8Bh3rWKBP ngjuoi7NFb5KWCLmRnngwBmhaEYuG9Kmr/cpmN2Fs2+8+J4enurHnr5HowT+v2SOYBMGOmZgP7V 8+oMt6vA27hnnj9HElMtPXxtye1vxjc7sEH7FTgsKxuHDSPLXtEiPbbvlvItE69CRrTOVHRIMqF F6ycR44awAIe45gJkhbcqz2q1+R8FCkxXTBwlJ0KjA3qWQ== X-Received: by 2002:a05:6808:2391:b0:4d6:9153:2966 with SMTP id 5614622812f47-57a0a5191c1mr32953666b6e.55.1796057120004; Mon, 30 Nov 2026 08:45:20 -0800 (PST) Received: from localhost.localdomain ([2600:1702:4ff0:baa0:5054:ff:fe3d:4ddb]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-4bc5f7ae7dcsm28002053fac.8.2026.11.30.08.45.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 08:45:19 -0800 (PST) From: Will Porter To: Takashi Iwai , Jaroslav Kysela Cc: Christian Ruppert , linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Neil Andrews , Nikita Tarasov Subject: [PATCH v2 15/21] ALSA: mixer_audient: Create matrix programmatically Date: Mon, 30 Nov 2026 10:44:22 -0600 Message-ID: <20261130164428.2930348-16-mrwillporter@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261130164428.2930348-1-mrwillporter@gmail.com> References: <20261130164428.2930348-1-mrwillporter@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Christian Ruppert 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 Co-developed-by: Will Porter Signed-off-by: Will Porter --- sound/usb/mixer_audient.c | 77 +++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 43 deletions(-) diff --git a/sound/usb/mixer_audient.c b/sound/usb/mixer_audient.c index 6c625b4734c47..56a9b9c04b369 100644 --- a/sound/usb/mixer_audient.c +++ b/sound/usb/mixer_audient.c @@ -105,7 +105,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; @@ -134,48 +134,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, @@ -193,13 +151,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 */ }; @@ -645,6 +617,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; @@ -659,5 +633,22 @@ int snd_audient_controls_create(struct usb_mixer_interface *mixer) return ret; } + if (info->matrix_names) { + 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.47.3