ucm: parse SectionOnce section in the master UCM configuration file

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2020-05-14 16:03:00 +02:00
parent 750a3d9fd8
commit e0da1d2a2a
3 changed files with 41 additions and 4 deletions

View file

@ -1510,6 +1510,26 @@ static int parse_master_section(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg,
return parse_verb_file(uc_mgr, use_case_name, comment, file);
}
/*
* parse controls which should be run only at initial boot
*/
static int parse_controls_once(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg)
{
int err;
if (!list_empty(&uc_mgr->once_list)) {
uc_error("Once list is not empty");
return -EINVAL;
}
err = parse_sequence(uc_mgr, &uc_mgr->once_list, cfg);
if (err < 0) {
uc_error("Unable to parse SectionOnce");
return err;
}
return 0;
}
/*
* parse controls
*/
@ -1558,11 +1578,16 @@ static int parse_controls(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg)
* CaptureCTL "hw:CARD=0"
* }
*
* # The initial boot (run once) configuration.
*
* SectionOnce {
* cset "name='Master Playback Switch',index=2 1,1"
* cset "name='Master Playback Volume',index=2 25,25"
* }
*
* # This file also stores the default sound card state.
*
* SectionDefaults [
* cset "name='Master Playback Switch',index=2 1,1"
* cset "name='Master Playback Volume',index=2 25,25"
* cset "name='Master Mono Playback',index=1 0"
* cset "name='Master Mono Playback Volume',index=1 0"
* cset "name='PCM Switch',index=2 1,1"
@ -1636,6 +1661,14 @@ static int parse_master_file(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg)
continue;
}
/* find default control values section (first boot only) */
if (strcmp(id, "SectionOnce") == 0) {
err = parse_controls_once(uc_mgr, n);
if (err < 0)
return err;
continue;
}
/* find default control values section and parse it */
if (strcmp(id, "SectionDefaults") == 0) {
err = parse_controls(uc_mgr, n);

View file

@ -221,6 +221,9 @@ struct snd_use_case_mgr {
/* use case verb, devices and modifier configs parsed from files */
struct list_head verb_list;
/* boot settings - sequence */
struct list_head once_list;
/* default settings - sequence */
struct list_head default_list;

View file

@ -567,6 +567,7 @@ void uc_mgr_free_verb(snd_use_case_mgr_t *uc_mgr)
list_del(&verb->list);
free(verb);
}
uc_mgr_free_sequence(&uc_mgr->once_list);
uc_mgr_free_sequence(&uc_mgr->default_list);
uc_mgr_free_value(&uc_mgr->value_list);
free(uc_mgr->comment);