]> git.alsa-project.org Git - alsa-lib.git/commitdiff
ucm: add ValueGlobals section to the top configuration file
authorJaroslav Kysela <perex@perex.cz>
Mon, 1 Dec 2025 15:39:15 +0000 (16:39 +0100)
committerJaroslav Kysela <perex@perex.cz>
Thu, 4 Dec 2025 11:11:41 +0000 (12:11 +0100)
BootCardGroup and BootCardSyncTime variables should not be listed
by default in _identifiers. Handle them differently using
ValueGlobals section.

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
src/ucm/utils.c

index cde7dcadf957d347ce5e48e5cfea076593480361..21a39a3469e96725e1d68ae5005e01c1d2360910 100644 (file)
@@ -1144,7 +1144,7 @@ static int boot_wait(snd_use_case_mgr_t *uc_mgr, int *_primary_card)
        if (_primary_card)
                *_primary_card = -1;
 
-       err = get_value1(uc_mgr, &boot_card_sync_time, &uc_mgr->value_list, "BootCardSyncTime");
+       err = get_value1(uc_mgr, &boot_card_sync_time, &uc_mgr->global_value_list, "BootCardSyncTime");
        if (err == 0 && boot_card_sync_time != NULL) {
                long sync_time;
                if (safe_strtol(boot_card_sync_time, &sync_time) == 0 && sync_time > 0 && sync_time <= 240) {
@@ -1764,6 +1764,7 @@ int snd_use_case_mgr_open(snd_use_case_mgr_t **uc_mgr,
        INIT_LIST_HEAD(&mgr->boot_list);
        INIT_LIST_HEAD(&mgr->default_list);
        INIT_LIST_HEAD(&mgr->value_list);
+       INIT_LIST_HEAD(&mgr->global_value_list);
        INIT_LIST_HEAD(&mgr->active_modifiers);
        INIT_LIST_HEAD(&mgr->active_devices);
        INIT_LIST_HEAD(&mgr->ctl_list);
@@ -2542,6 +2543,10 @@ static int get_value(snd_use_case_mgr_t *uc_mgr,
        if (err >= 0 || err != -ENOENT)
                return err;
 
+       err = get_value1(uc_mgr, value, &uc_mgr->global_value_list, identifier);
+       if (err >= 0 || err != -ENOENT)
+               return err;
+
        return -ENOENT;
 }
 
index 9787c84b76b6ab75d9f4a9aca7225bb31235c77f..a76be77657a6f432b74426b9178b2b8e73085a97 100644 (file)
@@ -3161,17 +3161,17 @@ static int parse_master_file(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg)
        if (err < 0)
                return err;
 
-       /* parse ValueDefaults first */
-       err = snd_config_search(cfg, "ValueDefaults", &n);
+       /* parse ValueGlobals first */
+       err = snd_config_search(cfg, "ValueGlobals", &n);
        if (err == 0) {
-               err = parse_value(uc_mgr, &uc_mgr->value_list, n);
+               err = parse_value(uc_mgr, &uc_mgr->global_value_list, n);
                if (err < 0) {
-                       snd_error(UCM, "failed to parse ValueDefaults");
+                       snd_error(UCM, "failed to parse ValueGlobals");
                        return err;
                }
        }
 
-       err = uc_mgr_check_value(&uc_mgr->value_list, "BootCardGroup");
+       err = uc_mgr_check_value(&uc_mgr->global_value_list, "BootCardGroup");
        if (err == 0) {
                uc_mgr->card_group = true;
                /* if we are in boot, skip the main parsing loop */
@@ -3231,9 +3231,18 @@ static int parse_master_file(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg)
 
                /* ValueDefaults is now parsed at the top of this function */
                if (strcmp(id, "ValueDefaults") == 0) {
+                       err = parse_value(uc_mgr, &uc_mgr->value_list, n);
+                       if (err < 0) {
+                               snd_error(UCM, "failed to parse ValueDefaults");
+                               return err;
+                       }
                        continue;
                }
 
+               /* ValueGlobals is parsed at the top of this function */
+               if (strcmp(id, "ValueGlobals") == 0)
+                       continue;
+
                /* alsa-lib configuration */
                if (uc_mgr->conf_format > 3 && strcmp(id, "LibraryConfig") == 0) {
                        err = parse_libconfig(uc_mgr, n);
index aa796b37d25e3662d4160beae0c7148a8a4436cd..5fac99e45d5a0dc7e25d27eeaefcfd5c7301924a 100644 (file)
@@ -464,7 +464,7 @@ boot).
 
 #### Boot Synchronization (Syntax 8+)
 
-The *BootCardGroup* value in *ValueDefaults* allows multiple sound cards to coordinate
+The *BootCardGroup* value in *ValueGlobals* allows multiple sound cards to coordinate
 their boot sequences. This value is detected at boot (alsactl/udev/systemd) time. Boot
 tools can provide boot synchronization information through a control element named
 'Boot' with 64-bit integer type. When present, the UCM library uses this control element
@@ -477,7 +477,7 @@ The 'Boot' control element contains:
 
 The UCM open call waits until the boot timeout has passed or until restore state
 is notified through the synchronization Boot element. The timeout defaults to 30 seconds
-and can be customized using 'BootCardSyncTime' in 'ValueDefaults' (maximum 240 seconds).
+and can be customized using 'BootCardSyncTime' in 'ValueGlobals' (maximum 240 seconds).
 
 If the 'Boot' control element is not present, no boot synchronization is performed.
 
@@ -488,7 +488,7 @@ cards appropriately.
 Example configuration:
 
 ~~~{.html}
-ValueDefaults {
+ValueGlobals {
   BootCardGroup "amd-acp"
   BootCardSyncTime 10 # seconds
 }
index 8fd996ff1a4a88435211ec07915b5572546ec981..8b3da74ff215d1ce01c83f5c349b52349e25fe00 100644 (file)
@@ -262,6 +262,9 @@ struct snd_use_case_mgr {
        /* default settings - value list */
        struct list_head value_list;
 
+       /* global value list */
+       struct list_head global_value_list;
+
        /* current status */
        struct use_case_verb *active_verb;
        struct list_head active_devices;
index 712ef6136f07d3b8823a2b40233de959fee70fef..68a7521e65cf5267113c9fc1719d9380f73ebb4a 100644 (file)
@@ -807,6 +807,7 @@ void uc_mgr_free_verb(snd_use_case_mgr_t *uc_mgr)
        uc_mgr_free_sequence(&uc_mgr->boot_list);
        uc_mgr_free_sequence(&uc_mgr->default_list);
        uc_mgr_free_value(&uc_mgr->value_list);
+       uc_mgr_free_value(&uc_mgr->global_value_list);
        uc_mgr_free_value(&uc_mgr->variable_list);
        free(uc_mgr->comment);
        free(uc_mgr->conf_dir_name);