]> git.alsa-project.org Git - alsa-lib.git/commitdiff
ucm: implement disdevall sequence command
authorJaroslav Kysela <perex@perex.cz>
Tue, 24 May 2022 14:28:21 +0000 (16:28 +0200)
committerJaroslav Kysela <perex@perex.cz>
Tue, 24 May 2022 14:28:23 +0000 (16:28 +0200)
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>
src/ucm/main.c
src/ucm/parser.c
src/ucm/ucm_confdoc.h
src/ucm/ucm_local.h

index 730872c2187438e2d3368fa07dbae2a7fa4c06ca..4302f63b427a6820006f90399891db5d1f46f966 100644 (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;
index 4bbd13e8700049a21319f4254d50a82a39c521b7..dd49298830db0beb306541d68a984ae5786642e4 100644 (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;
index 42c331b6140c7f72efa90bf00d81b8996f8f2199..27ec722efb71a8c8565735c711ed7fd1c9388627 100644 (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
index 8c36e8b990b2b42644ad9593ccce6bed02fe308c..fc249058abc70f76d6bb0050ed6d0c71a99ac55b 100644 (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;