mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2026-03-14 05:33:43 -04:00
ucm: add _fboot / FixedBootSequence
Actually, the BootSequence is executed only when the driver controls (identifiers or value types) are changed. It may be handy to have also a sequence which is executed at _each_ boot without any condition. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
266618088a
commit
9c194a0ba7
5 changed files with 59 additions and 1 deletions
|
|
@ -418,7 +418,10 @@ int snd_use_case_geti(snd_use_case_mgr_t *uc_mgr,
|
||||||
* \return Zero if success, otherwise a negative error code
|
* \return Zero if success, otherwise a negative error code
|
||||||
*
|
*
|
||||||
* Known identifiers:
|
* Known identifiers:
|
||||||
|
* - _fboot - execute the fixed boot sequence (value = NULL)
|
||||||
* - _boot - execute the boot sequence (value = NULL)
|
* - _boot - execute the boot sequence (value = NULL)
|
||||||
|
* - only when driver controls identifiers are changed
|
||||||
|
* (otherwise the old control values are restored)
|
||||||
* - _defaults - execute the 'defaults' sequence (value = NULL)
|
* - _defaults - execute the 'defaults' sequence (value = NULL)
|
||||||
* - _verb - set current verb = value
|
* - _verb - set current verb = value
|
||||||
* - _enadev - enable given device = value
|
* - _enadev - enable given device = value
|
||||||
|
|
|
||||||
|
|
@ -594,6 +594,8 @@ static int check_empty_configuration(snd_use_case_mgr_t *uc_mgr)
|
||||||
}
|
}
|
||||||
if (!list_empty(&uc_mgr->verb_list))
|
if (!list_empty(&uc_mgr->verb_list))
|
||||||
return 0;
|
return 0;
|
||||||
|
if (!list_empty(&uc_mgr->fixedboot_list))
|
||||||
|
return 0;
|
||||||
if (!list_empty(&uc_mgr->boot_list))
|
if (!list_empty(&uc_mgr->boot_list))
|
||||||
return 0;
|
return 0;
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
|
|
@ -993,6 +995,7 @@ int snd_use_case_mgr_open(snd_use_case_mgr_t **uc_mgr,
|
||||||
if (mgr == NULL)
|
if (mgr == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
INIT_LIST_HEAD(&mgr->verb_list);
|
INIT_LIST_HEAD(&mgr->verb_list);
|
||||||
|
INIT_LIST_HEAD(&mgr->fixedboot_list);
|
||||||
INIT_LIST_HEAD(&mgr->boot_list);
|
INIT_LIST_HEAD(&mgr->boot_list);
|
||||||
INIT_LIST_HEAD(&mgr->default_list);
|
INIT_LIST_HEAD(&mgr->default_list);
|
||||||
INIT_LIST_HEAD(&mgr->value_list);
|
INIT_LIST_HEAD(&mgr->value_list);
|
||||||
|
|
@ -1886,6 +1889,24 @@ int snd_use_case_geti(snd_use_case_mgr_t *uc_mgr,
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int set_fixedboot_user(snd_use_case_mgr_t *uc_mgr,
|
||||||
|
const char *value)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
|
||||||
|
if (value != NULL && *value) {
|
||||||
|
uc_error("error: wrong value for _fboot (%s)", value);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
err = execute_sequence(uc_mgr, &uc_mgr->fixedboot_list,
|
||||||
|
&uc_mgr->value_list, NULL, NULL);
|
||||||
|
if (err < 0) {
|
||||||
|
uc_error("Unable to execute force boot sequence");
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
static int set_boot_user(snd_use_case_mgr_t *uc_mgr,
|
static int set_boot_user(snd_use_case_mgr_t *uc_mgr,
|
||||||
const char *value)
|
const char *value)
|
||||||
{
|
{
|
||||||
|
|
@ -2125,7 +2146,9 @@ int snd_use_case_set(snd_use_case_mgr_t *uc_mgr,
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
pthread_mutex_lock(&uc_mgr->mutex);
|
pthread_mutex_lock(&uc_mgr->mutex);
|
||||||
if (strcmp(identifier, "_boot") == 0)
|
if (strcmp(identifier, "_fboot") == 0)
|
||||||
|
err = set_fixedboot_user(uc_mgr, value);
|
||||||
|
else if (strcmp(identifier, "_boot") == 0)
|
||||||
err = set_boot_user(uc_mgr, value);
|
err = set_boot_user(uc_mgr, value);
|
||||||
else if (strcmp(identifier, "_defaults") == 0)
|
else if (strcmp(identifier, "_defaults") == 0)
|
||||||
err = set_defaults_user(uc_mgr, value);
|
err = set_defaults_user(uc_mgr, value);
|
||||||
|
|
|
||||||
|
|
@ -1739,6 +1739,26 @@ __error:
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* parse controls which should be run only at initial boot (forcefully)
|
||||||
|
*/
|
||||||
|
static int parse_controls_fixedboot(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
|
||||||
|
if (!list_empty(&uc_mgr->fixedboot_list)) {
|
||||||
|
uc_error("FixedBoot list is not empty");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
err = parse_sequence(uc_mgr, &uc_mgr->fixedboot_list, cfg);
|
||||||
|
if (err < 0) {
|
||||||
|
uc_error("Unable to parse FixedBootSequence");
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* parse controls which should be run only at initial boot
|
* parse controls which should be run only at initial boot
|
||||||
*/
|
*/
|
||||||
|
|
@ -1891,6 +1911,14 @@ static int parse_master_file(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* find default control values section (force boot sequence only) */
|
||||||
|
if (strcmp(id, "FixedBootSequence") == 0) {
|
||||||
|
err = parse_controls_fixedboot(uc_mgr, n);
|
||||||
|
if (err < 0)
|
||||||
|
return err;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* find default control values section (first boot only) */
|
/* find default control values section (first boot only) */
|
||||||
if (strcmp(id, "BootSequence") == 0) {
|
if (strcmp(id, "BootSequence") == 0) {
|
||||||
err = parse_controls_boot(uc_mgr, n);
|
err = parse_controls_boot(uc_mgr, n);
|
||||||
|
|
|
||||||
|
|
@ -222,6 +222,9 @@ struct snd_use_case_mgr {
|
||||||
/* use case verb, devices and modifier configs parsed from files */
|
/* use case verb, devices and modifier configs parsed from files */
|
||||||
struct list_head verb_list;
|
struct list_head verb_list;
|
||||||
|
|
||||||
|
/* force boot settings - sequence */
|
||||||
|
struct list_head fixedboot_list;
|
||||||
|
|
||||||
/* boot settings - sequence */
|
/* boot settings - sequence */
|
||||||
struct list_head boot_list;
|
struct list_head boot_list;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -692,6 +692,7 @@ void uc_mgr_free_verb(snd_use_case_mgr_t *uc_mgr)
|
||||||
list_del(&verb->list);
|
list_del(&verb->list);
|
||||||
free(verb);
|
free(verb);
|
||||||
}
|
}
|
||||||
|
uc_mgr_free_sequence(&uc_mgr->fixedboot_list);
|
||||||
uc_mgr_free_sequence(&uc_mgr->boot_list);
|
uc_mgr_free_sequence(&uc_mgr->boot_list);
|
||||||
uc_mgr_free_sequence(&uc_mgr->default_list);
|
uc_mgr_free_sequence(&uc_mgr->default_list);
|
||||||
uc_mgr_free_value(&uc_mgr->value_list);
|
uc_mgr_free_value(&uc_mgr->value_list);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue