From: HyeongJun An <sammiee5311@gmail.com>
To: broonie@kernel.org, tiwai@suse.com
Cc: perex@perex.cz, shuah@kernel.org, linux-sound@vger.kernel.org,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
HyeongJun An <sammiee5311@gmail.com>
Subject: [PATCH] selftests/alsa: Check that dB scaled controls are named Volume
Date: Mon, 30 Nov 2026 17:54:14 +0900 [thread overview]
Message-ID: <20261130085414.1348615-1-sammiee5311@gmail.com> (raw)
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
next reply other threads:[~2026-11-30 8:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 8:54 HyeongJun An [this message]
2026-12-02 16:04 ` Takashi Iwai
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=20261130085414.1348615-1-sammiee5311@gmail.com \
--to=sammiee5311@gmail.com \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=shuah@kernel.org \
--cc=tiwai@suse.com \
/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
all inboxes | Powered by JetHome®