ucm: implement disdevall sequence command

It is useful to run all disable sequences for all
UCM devices in a verb to ensure the valid, expected
initial state.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2022-05-24 16:28:21 +02:00
parent 0ba999591b
commit 4119e33d28
4 changed files with 39 additions and 2 deletions

View file

@ -694,6 +694,31 @@ static int run_device_sequence(snd_use_case_mgr_t *uc_mgr, struct use_case_verb
&uc_mgr->value_list);
}
static int run_device_all_sequence(snd_use_case_mgr_t *uc_mgr, struct use_case_verb *verb)
{
struct use_case_device *device;
struct list_head *pos;
int err;
if (verb == NULL) {
uc_error("error: disdevall must be executed inside the verb context");
return -ENOENT;
}
list_for_each(pos, &verb->device_list) {
device = list_entry(pos, struct use_case_device, list);
err = execute_sequence(uc_mgr, verb,
&device->disable_list,
&device->value_list,
&verb->value_list,
&uc_mgr->value_list);
if (err < 0)
return err;
}
return 0;
}
/**
* \brief Execute the sequence
* \param uc_mgr Use case manager
@ -866,6 +891,11 @@ shell_retry:
if (err < 0)
goto __fail;
break;
case SEQUENCE_ELEMENT_TYPE_DEV_DISABLE_ALL:
err = run_device_all_sequence(uc_mgr, verb);
if (err < 0)
goto __fail;
break;
default:
uc_error("unknown sequence command %i", s->type);
break;

View file

@ -1106,6 +1106,11 @@ device:
continue;
}
if (strcmp(cmd, "disdevall") == 0) {
curr->type = SEQUENCE_ELEMENT_TYPE_DEV_DISABLE_ALL;
continue;
}
if (strcmp(cmd, "cset-bin-file") == 0) {
curr->type = SEQUENCE_ELEMENT_TYPE_CSET_BIN_FILE;
goto cset;

View file

@ -222,8 +222,9 @@ SectionModifier."Capture Voice" {
Command name | Description
---------------|----------------------------------------------
enadev2 | execute device enable sequence
disdev2 | execute device disable sequence
enadev2 ARG | execute device enable sequence
disdev2 ARG | execute device disable sequence
disdevall "" | execute device disable sequence for all devices in verb
cdev ARG | ALSA control device name for snd_ctl_open()
cset ARG | ALSA control set - snd_ctl_ascii_elem_id_parse() + snd_ctl_ascii_value_parse()
cset-new ARG | Create new ALSA user control element - snd_ctl_ascii_elem_id_parse() + description

View file

@ -59,6 +59,7 @@
#define SEQUENCE_ELEMENT_TYPE_CFGSAVE 12
#define SEQUENCE_ELEMENT_TYPE_DEV_ENABLE_SEQ 13
#define SEQUENCE_ELEMENT_TYPE_DEV_DISABLE_SEQ 14
#define SEQUENCE_ELEMENT_TYPE_DEV_DISABLE_ALL 15
struct ucm_value {
struct list_head list;