diff --git a/alsactl/alsactl.c b/alsactl/alsactl.c index cc984e9..c800087 100644 --- a/alsactl/alsactl.c +++ b/alsactl/alsactl.c @@ -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); diff --git a/alsactl/alsactl.h b/alsactl/alsactl.h index 119e3b4..0e24d60 100644 --- a/alsactl/alsactl.h +++ b/alsactl/alsactl.h @@ -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); diff --git a/alsactl/init_parse.c b/alsactl/init_parse.c index e7b352c..4034b4d 100644 --- a/alsactl/init_parse.c +++ b/alsactl/init_parse.c @@ -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) { diff --git a/alsactl/init_ucm.c b/alsactl/init_ucm.c index 6468c9d..9ac8db0 100644 --- a/alsactl/init_ucm.c +++ b/alsactl/init_ucm.c @@ -28,7 +28,8 @@ #include /* - * 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,18 +37,25 @@ 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); return err; @@ -57,7 +65,7 @@ _error: int init_ucm(int flags, int cardno) { - return 0; + return -ENXIO; } #endif diff --git a/alsactl/state.c b/alsactl/state.c index 71e5465..e39e878 100644 --- a/alsactl/state.c +++ b/alsactl/state.c @@ -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;