]> git.alsa-project.org Git - alsa-utils.git/commitdiff
alsactl: suppress no device 'errors' for UCM
authorJaroslav Kysela <perex@perex.cz>
Thu, 28 Oct 2021 10:07:10 +0000 (12:07 +0200)
committerJaroslav Kysela <perex@perex.cz>
Thu, 28 Oct 2021 10:16:11 +0000 (12:16 +0200)
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 <perex@perex.cz>
alsactl/alsactl.c
alsactl/alsactl.h
alsactl/init_ucm.c

index 05738fb6b35f1b732a85ee2f3e3fe73e79009e6f..ecc5d28624446b8477441f970ad4bb2b065a775b 100644 (file)
@@ -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;
index bbdf6c88baebe6efd1c60957245c2307c719dd7f..d0dd7ebc883636e7cde05fa4680e611d9096a3c9 100644 (file)
@@ -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);
index b3266010fb02ae9d19bb63379527872d1774325b..be635c44a3731b63ee256382e438d6186f61127c 100644 (file)
 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;