From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.167.181 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796057121; b=nJXddeZgu2sTL/x+ec8F4MrM5Le425flCEnmJQzHVVCptGCXCsY8roFyrnqS6v9AxyDV tzQyDeLZ84HtYm1/vYHgCM7z90pFlyawUPSw/LZLbECRCVLzNl9NeDBO+jlYVGe5gD6Co VJSilqc9YtLNlX1wKixNKc7n+t/QsvIO+N4uA91jUqX00U4iF0S5lM4ydTsci4bcPR/Rj WewdcOq+FROj8F299nxxHv+6nNKi2cLlW5PXUkELdIpdgqGEDiAHwxelYBhM4JkQmIstr x33WKpIeVgFYnFk7wyI10/tWbHW0V0kuw6RkedLWoUSR1eIGPOA2WJMK0KmdVd+3syQ== 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=SPjb4mCkWJB0ZbA2EAo2jNK/a1LV/9a8ilbAnxdvjnPy4e+rMkoaSZc5y5aRw9uNQvve MKrot2/vuVQTO7KiyZfs1juzGGRwhbCNha7mM8t+LueEK4NltZyRHylLMXwYB3zT/yCD7 is9BfFtZx9oxsyYmcnYwSX+KBdhFRxaoHYtALvirh879lNa5hPICYBXtOZhIh/1D5qey0 7Rf0g+uVdkibzaG30X892p64mCbEQ/h0eS+bjcJdl/bzgLqFbhB0cW/DnauDNTzcWnIkQ JhAfyQPZAn2iGCy2g8SN3JySJjD2jFIXoV7wLwNlkOVr7ErG30xHyPnNL4/aNlpCVwg== 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.181 Received: from mail-oi1-f181.google.com (mail-oi1-f181.google.com [209.85.167.181]) (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 3526A606A680 for ; Mon, 30 Nov 2026 16:45:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3526A606A680 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-f181.google.com with SMTP id 5614622812f47-53dda625f63so6948596b6e.1 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=KG+aVr3GXe2wDhskg/SA5ygXouVzeclGn9OxweLwgTDJaqM7SQb266tw8j9ynpBOsi 01VraVeDa6Ktpg+0JCyRYQQ/joiLuKxAvNADK+JjGi90q+4/vA9CQ2KkIKN+WkdbHlF6 0SqrDYx0eSt1XA4XZ01QOGJqAy59ZYBf76LZRu2Mh7dRoqJF0Z2wX//C76zetXNoKG/r qt+9xVPCGb5J0u4CvS30cljsTryuz4mJVu0cbY6MBpW+mt5Czg8f+hw7Weqnwi7HnG27 qo032lob7C5SFqdKhK8G4Eru5RwqqgyHWucNuQWTvwcGL8yUMME/YLnrI+YMZORLmLK7 sNpA== X-Forwarded-Encrypted: i=1; AL+hErEiCRrvnCx+Zr9mAIJ6rpLt9apWB0wY1SZR0pp8MtKAEjkhplc+7eCu7N4n3wkgT9lr6CLYDA31TcbZ1w==@vger.kernel.org X-Gm-Message-State: APuU4Z8WBHp/CebWnPCQuN8UKPAOMcMJugBKNzWxE9bC0bk1vrMHmvct hBnwdTsY5p4pDDlajuqdzY4NklUyuxM/67hJHefGBpZgF4Ihb2USpwF+2XHiM98L X-Gm-Gg: AZFdTZeSSkAnwLP1ytkJ8LBFey5Or6fi1rGjtRmVku5vX8/hduMOeqnYoQsJfjtnszY ZJ1taRPh7BUhAX5ZS5DYCvALuM1hX7FPf3TD/gf8WPzB8x04iw2fYyr8ZGegMj9nPkmLWcsGi16 kJiPQVjIKmtx+uhk9unKwrwrPCxSQ6EyOT8HLDY7wCFjeF4lcRcEk4C8VvkChpnhwuTfrIaFY9a 4k6JLFlfcXvFaKgXvQJ4wFAGiwW5r9ZYarFBHd/Yp3Oi89Wo0VFfXiHkZPKpX+Tg8l5WYdIumMI HyvnnI5dnmSE2q2PCYkt8WIwreRj/Tp+4k7WsvK6l/aVQpSEVl+Su4Kf+csH2NIBsug+UsSPszT UiD8+K+t9f2z1ItDXUIR8t8Vg3TeF3DC+9/J8sAqyCTRPJcD78uB7Dvp1e7/F62S3GWi6cn20lN s1FnQU7x9MqvGbfeasMdJcr8aBqU5ZgBbJEA5qXvQ3PsHP5WoP/LubuoMNVaAdxCRk2EkHDKHAJ 0ZlVa0ZVs3B0LTOUFCjMmHYMLPjwy9Z9HNg6dp2SK2IJZd2vUeJHhJGk1qtNUZB8gEnDuXTPHD5 KpJGWdxfZ0WJYkPaZEF1jcPi3Fu83e8eBHj2mDGcvVsutA== 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-sound@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