aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/alsa/mixer-test.c
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2021-12-10 18:54:09 +0000
committerTakashi Iwai <tiwai@suse.de>2021-12-12 10:04:29 +0100
commit7cc994f27e84cc94ce612d201c78763f93eab2c4 (patch)
tree8abf24af4cd3b896114eac4380339af15818011c /tools/testing/selftests/alsa/mixer-test.c
parentkselftest: alsa: Add simplistic test for ALSA mixer controls kselftest (diff)
downloadlinux-dev-7cc994f27e84cc94ce612d201c78763f93eab2c4.tar.xz
linux-dev-7cc994f27e84cc94ce612d201c78763f93eab2c4.zip
kselftest: alsa: optimization for SNDRV_CTL_ELEM_ACCESS_VOLATILE
The volatile attribute of control element means that the hardware can voluntarily change the state of control element independent of any operation by software. ALSA control core necessarily sends notification to userspace subscribers for any change from userspace application, while it doesn't for the hardware's voluntary change. This commit adds optimization for the attribute. Even if read value is different from written value, the test reports success as long as the target control element has the attribute. On the other hand, the difference is itself reported for developers' convenience. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/Ya7TAHdMe9i41bsC@workstation [Fix comment style as suggested by Shuah -- broonie] Reviewed-by: Shuah Khan <skhan@linuxfoundation.org> Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20211210185410.740009-3-broonie@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'tools/testing/selftests/alsa/mixer-test.c')
-rw-r--r--tools/testing/selftests/alsa/mixer-test.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/tools/testing/selftests/alsa/mixer-test.c b/tools/testing/selftests/alsa/mixer-test.c
index ab51cf7b9e03..f65a9046e708 100644
--- a/tools/testing/selftests/alsa/mixer-test.c
+++ b/tools/testing/selftests/alsa/mixer-test.c
@@ -307,9 +307,15 @@ bool show_mismatch(struct ctl_data *ctl, int index,
}
if (expected_int != read_int) {
- ksft_print_msg("%s.%d expected %lld but read %lld\n",
- ctl->name, index, expected_int, read_int);
- return true;
+ /*
+ * NOTE: The volatile attribute means that the hardware
+ * can voluntarily change the state of control element
+ * independent of any operation by software.
+ */
+ bool is_volatile = snd_ctl_elem_info_is_volatile(ctl->info);
+ ksft_print_msg("%s.%d expected %lld but read %lld, is_volatile %d\n",
+ ctl->name, index, expected_int, read_int, is_volatile);
+ return !is_volatile;
} else {
return false;
}