alsactl: Add ucm support for the FixedBootSequence

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2021-03-10 19:26:51 +01:00
parent 7f5622c106
commit 9a2115b5cc
5 changed files with 32 additions and 22 deletions

View 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);

View 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);

View 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) {

View 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,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

View 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;