]> git.alsa-project.org Git - alsa-utils.git/commitdiff
alsactl: Add ucm support for the FixedBootSequence
authorJaroslav Kysela <perex@perex.cz>
Wed, 10 Mar 2021 18:26:51 +0000 (19:26 +0100)
committerJaroslav Kysela <perex@perex.cz>
Thu, 11 Mar 2021 08:23:31 +0000 (09:23 +0100)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
alsactl/alsactl.c
alsactl/alsactl.h
alsactl/init_parse.c
alsactl/init_ucm.c
alsactl/state.c

index cc984e9bae8d239d7c02f6c3df56f22b542a46f9..c8000877ea4be0bf486d373fdbbaf47403257d5d 100644 (file)
@@ -420,7 +420,7 @@ int main(int argc, char *argv[])
        snd_lib_error_set_handler(error_handler);
 
        if (!strcmp(cmd, "init")) {
-               res = init(initfile, initflags, cardname);
+               res = init(initfile, initflags | FLAG_UCM_FBOOT | FLAG_UCM_BOOT, cardname);
                snd_config_update_free_global();
        } else if (!strcmp(cmd, "store")) {
                res = save_state(cfgfile, cardname);
index 119e3b4b850efe9bf6ffa7c4af218d6e7dcb83cd..0e24d609f9ba8c6d594cdce123fcc801b76d4423 100644 (file)
@@ -28,7 +28,9 @@ void error_handler(const char *file, int line, const char *function, int err, co
 #endif 
 
 #define FLAG_UCM_DISABLED      (1<<0)
-#define FLAG_UCM_DEFAULTS      (1<<1)
+#define FLAG_UCM_FBOOT         (1<<1)
+#define FLAG_UCM_BOOT          (1<<2)
+#define FLAG_UCM_DEFAULTS      (1<<3)
 
 int load_configuration(const char *file, snd_config_t **top, int *open_failed);
 int init(const char *file, int flags, const char *cardname);
index e7b352c2aad1c5ff202fc09ad1d07888bf1eb261..4034b4d384b3ce79efc8dc8f2aedc631129c586b 100644 (file)
@@ -1765,11 +1765,9 @@ int init(const char *filename, int flags, const char *cardname)
                                break;
                        }
                        first = 0;
-                       if (!(flags & FLAG_UCM_DISABLED)) {
-                               err = init_ucm(flags, card);
-                               if (err == 0)
-                                       continue;
-                       }
+                       err = init_ucm(flags, card);
+                       if (err == 0)
+                               continue;
                        err = init_space(&space, card);
                        if (err == 0) {
                                space->rootdir = new_root_dir(filename);
@@ -1792,11 +1790,9 @@ int init(const char *filename, int flags, const char *cardname)
                        error("Cannot find soundcard '%s'...", cardname);
                        goto error;
                }
-               if (!(flags & FLAG_UCM_DISABLED)) {
-                       err = init_ucm(flags, card);
-                       if (err == 0)
-                               return 0;
-               }
+               err = init_ucm(flags, card);
+               if (err == 0)
+                       return 0;
                memset(&space, 0, sizeof(space));
                err = init_space(&space, card);
                if (err == 0) {
index 6468c9d59443e0aa9c08b44e47f62c6a8f2d05b4..9ac8db03c1d4038d88c052432ac89114df6bad3c 100644 (file)
@@ -28,7 +28,8 @@
 #include <alsa/use-case.h>
 
 /*
- * Keep it as simple as possible. Execute commands from the SectionOnce only.
+ * Keep it as simple as possible. Execute commands from the
+ * FixedBootSequence and BootSequence only.
  */
 int init_ucm(int flags, int cardno)
 {
@@ -36,17 +37,24 @@ int init_ucm(int flags, int cardno)
        char id[32];
        int err;
 
+       if (flags & FLAG_UCM_DISABLED)
+               return -ENXIO;
+
        snprintf(id, sizeof(id), "hw:%d", cardno);
        err = snd_use_case_mgr_open(&uc_mgr, id);
        if (err < 0)
                return err;
-       err = snd_use_case_set(uc_mgr, "_boot", NULL);
-       if (err < 0)
-               goto _error;
-       if ((flags & FLAG_UCM_DEFAULTS) != 0) {
-               err = snd_use_case_set(uc_mgr, "_defaults", NULL);
+       if (flags & FLAG_UCM_FBOOT) {
+               err = snd_use_case_set(uc_mgr, "_fboot", NULL);
+               if (err < 0)
+                       goto _error;
+       }
+       if (flags & FLAG_UCM_BOOT) {
+               err = snd_use_case_set(uc_mgr, "_boot", NULL);
                if (err < 0)
                        goto _error;
+               if ((flags & FLAG_UCM_DEFAULTS) != 0)
+                       err = snd_use_case_set(uc_mgr, "_defaults", NULL);
        }
 _error:
        snd_use_case_mgr_close(uc_mgr);
@@ -57,7 +65,7 @@ _error:
 
 int init_ucm(int flags, int cardno)
 {
-       return 0;
+       return -ENXIO;
 }
 
 #endif
index 71e5465f9be6f0dc49fc52452ae31545ab175db1..e39e8789a445816d7ecadfd33945fe8cbf4147bd 100644 (file)
@@ -1682,7 +1682,7 @@ single:
                        if (!do_init)
                                break;
                        sprintf(cardname1, "%i", card);
-                       err = init(initfile, initflags, cardname1);
+                       err = init(initfile, initflags | FLAG_UCM_FBOOT | FLAG_UCM_BOOT, cardname1);
                        if (err < 0) {
                                finalerr = err;
                                initfailed(card, "init", err);
@@ -1718,10 +1718,12 @@ single:
                                break;
                        }
                        first = 0;
+                       /* error is ignored */
+                       init_ucm(initflags | FLAG_UCM_FBOOT, card);
                        /* do a check if controls matches state file */
                        if (do_init && set_controls(card, config, 0)) {
                                sprintf(cardname1, "%i", card);
-                               err = init(initfile, initflags, cardname1);
+                               err = init(initfile, initflags | FLAG_UCM_BOOT, cardname1);
                                if (err < 0) {
                                        initfailed(card, "init", err);
                                        finalerr = err;
@@ -1742,9 +1744,11 @@ single:
                        err = -ENODEV;
                        goto out;
                }
+               /* error is ignored */
+               init_ucm(initflags | FLAG_UCM_FBOOT, cardno);
                /* do a check if controls matches state file */
                if (do_init && set_controls(cardno, config, 0)) {
-                       err = init(initfile, initflags, cardname);
+                       err = init(initfile, initflags | FLAG_UCM_BOOT, cardname);
                        if (err < 0) {
                                initfailed(cardno, "init", err);
                                finalerr = err;