From af62c72e2d6db960405eb1bd8d50206d1600c392 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Thu, 28 Oct 2021 12:07:10 +0200 Subject: [PATCH] alsactl: suppress no device 'errors' for UCM This patch adds --ucm-nodev (or -X) option to get those messages back. The code works only with library 1.2.6+. By default, these messages are suppressed: alsactl[xxx]: alsa-lib parser.c:242:(error_node) UCM is not supported for this HDA model (HDA Intel PCH...) alsactl[xxx]: alsa-lib main.c:1405:(snd_use_case_mgr_open) error: failed to import hw:0 use case configuration -6 Fixes: https://github.com/alsa-project/alsa-utils/issues/111 Link: https://lore.kernel.org/alsa-devel/20211027144008.27002-1-tiwai@suse.de/ Link: https://github.com/alsa-project/alsa-lib/commit/23198a72cd4f8f8759e650362b4adb485fc9fb12 Signed-off-by: Jaroslav Kysela --- alsactl/alsactl.c | 9 +++++++++ alsactl/alsactl.h | 1 + alsactl/init_ucm.c | 5 +++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/alsactl/alsactl.c b/alsactl/alsactl.c index 05738fb..ecc5d28 100644 --- a/alsactl/alsactl.c +++ b/alsactl/alsactl.c @@ -102,6 +102,9 @@ static struct arg args[] = { #ifdef HAVE_ALSA_USE_CASE_H { 'D', "ucm-defaults", "execute also the UCM 'defaults' section" }, { 'U', "no-ucm", "don't init with UCM" }, +#if SND_LIB_VER(1, 2, 5) < SND_LIB_VERSION +{ 'X', "ucm-nodev", "show UCM no device errors" }, +#endif #endif { HEADER, NULL, "Available commands:" }, { CARDCMD, "store", "save current driver setup for one or each soundcards" }, @@ -253,6 +256,9 @@ int main(int argc, char *argv[]) struct option *long_option; char *short_option; +#if SND_LIB_VER(1, 2, 5) >= SND_LIB_VERSION + initflags |= FLAG_UCM_NODEV; +#endif long_option = calloc(ARRAY_SIZE(args), sizeof(struct option)); if (long_option == NULL) exit(EXIT_FAILURE); @@ -328,6 +334,9 @@ int main(int argc, char *argv[]) case 'U': initflags |= FLAG_UCM_DISABLED; break; + case 'X': + initflags |= FLAG_UCM_NODEV; + break; case 'r': statefile = optarg; break; diff --git a/alsactl/alsactl.h b/alsactl/alsactl.h index bbdf6c8..d0dd7eb 100644 --- a/alsactl/alsactl.h +++ b/alsactl/alsactl.h @@ -39,6 +39,7 @@ void error_handler(const char *file, int line, const char *function, int err, co #define FLAG_UCM_FBOOT (1<<1) #define FLAG_UCM_BOOT (1<<2) #define FLAG_UCM_DEFAULTS (1<<3) +#define FLAG_UCM_NODEV (1<<4) void snd_card_iterator_init(struct snd_card_iterator *iter, int cardno); int snd_card_iterator_sinit(struct snd_card_iterator *iter, const char *cardname); diff --git a/alsactl/init_ucm.c b/alsactl/init_ucm.c index b326601..be635c4 100644 --- a/alsactl/init_ucm.c +++ b/alsactl/init_ucm.c @@ -34,13 +34,14 @@ int init_ucm(int flags, int cardno) { snd_use_case_mgr_t *uc_mgr; - char id[32]; + char id[32], *nodev; int err; if (flags & FLAG_UCM_DISABLED) return -ENXIO; - snprintf(id, sizeof(id), "hw:%d", cardno); + nodev = (flags & FLAG_UCM_NODEV) ? "" : "-"; + snprintf(id, sizeof(id), "%shw:%d", nodev, cardno); err = snd_use_case_mgr_open(&uc_mgr, id); if (err < 0) return err; -- 2.47.1