mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] selftests/alsa: Check that dB scaled controls are named Volume
@ 2026-11-30  8:54 HyeongJun An
  2026-12-02 16:04 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: HyeongJun An @ 2026-11-30  8:54 UTC (permalink / raw)
  To: broonie, tiwai
  Cc: perex, shuah, linux-sound, linux-kselftest, linux-kernel, HyeongJun An

control-names.rst gives Volume as the function of a control that sets
a gain, and new drivers keep naming such controls "... Gain" or
similar. mixer-test only checks the Switch suffix, so it does not
report them.

Fail the name test for a writeable integer control that has a dB scale
but does not end in " Volume". Read-only controls such as meters are
left alone.

Signed-off-by: HyeongJun An <sammiee5311@gmail.com>
---
I checked the control lists in recent mixer-test logs from the LAVA lab
at lava.sirena.org.uk (8 boards) against the drivers, and found none
that the new check would fail.

On a Dell Latitude 9420, "rt714 FU0C Boost" and "rt714 FU0E Boost" from
rt715-sdca now fail it. The other SDCA codec drivers name these controls
"... Boost Volume". Nothing else changes on that machine, and the channel
map controls, which have a TLV but no dB scale, still pass. The DMIC
Boost controls of the older rt715 driver would fail too, and
alsa-ucm-conf uses those names.

Tested there, and on HDA and snd-dummy with two user controls that have
a dB scale: "Injected Gain" fails and "Injected Volume" passes.

Prepared with Claude Code (Claude Opus 5.5).

 tools/testing/selftests/alsa/mixer-test.c | 25 +++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/tools/testing/selftests/alsa/mixer-test.c b/tools/testing/selftests/alsa/mixer-test.c
index 966ef83354b9..eabbe8dfd1c9 100644
--- a/tools/testing/selftests/alsa/mixer-test.c
+++ b/tools/testing/selftests/alsa/mixer-test.c
@@ -490,6 +490,21 @@ static bool strend(const char *haystack, const char *needle)
 	return strcmp(haystack + haystack_len - needle_len, needle) == 0;
 }
 
+static bool ctl_has_db_scale(struct ctl_data *ctl)
+{
+	unsigned int tlv[256];
+	long min, max;
+
+	if (!snd_ctl_elem_info_is_tlv_readable(ctl->info))
+		return false;
+	if (snd_ctl_elem_tlv_read(ctl->card->handle, ctl->id, tlv, sizeof(tlv)) < 0)
+		return false;
+
+	min = snd_ctl_elem_info_get_min(ctl->info);
+	max = snd_ctl_elem_info_get_max(ctl->info);
+	return snd_tlv_get_dB_range(tlv, min, max, &min, &max) == 0;
+}
+
 static void test_ctl_name(struct ctl_data *ctl)
 {
 	bool name_ok = true;
@@ -516,6 +531,16 @@ static void test_ctl_name(struct ctl_data *ctl)
 		}
 	}
 
+	/* Writeable integer controls with a dB scale should end in Volume */
+	if (snd_ctl_elem_info_get_type(ctl->info) == SND_CTL_ELEM_TYPE_INTEGER &&
+	    snd_ctl_elem_info_is_writable(ctl->info) && ctl_has_db_scale(ctl)) {
+		if (!strend(ctl->name, " Volume")) {
+			ksft_print_msg("%d.%d %s has a dB scale but is not a Volume\n",
+				       ctl->card->card, ctl->elem, ctl->name);
+			name_ok = false;
+		}
+	}
+
 	ksft_test_result(name_ok, "name.%s.%d\n",
 			 ctl->card->card_name, ctl->elem);
 }
-- 
2.43.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] selftests/alsa: Check that dB scaled controls are named Volume
  2026-11-30  8:54 [PATCH] selftests/alsa: Check that dB scaled controls are named Volume HyeongJun An
@ 2026-12-02 16:04 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2026-12-02 16:04 UTC (permalink / raw)
  To: HyeongJun An
  Cc: broonie, tiwai, perex, shuah, linux-sound, linux-kselftest, linux-kernel

On Mon, 30 Nov 2026 09:54:14 +0100,
HyeongJun An wrote:
> 
> control-names.rst gives Volume as the function of a control that sets
> a gain, and new drivers keep naming such controls "... Gain" or
> similar. mixer-test only checks the Switch suffix, so it does not
> report them.
> 
> Fail the name test for a writeable integer control that has a dB scale
> but does not end in " Volume". Read-only controls such as meters are
> left alone.
> 
> Signed-off-by: HyeongJun An <sammiee5311@gmail.com>

Applied to for-next branch.  Thanks.


Takashi

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-02 16:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-30  8:54 [PATCH] selftests/alsa: Check that dB scaled controls are named Volume HyeongJun An
2026-12-02 16:04 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®