From 66dfd40e8ff1cecfaf8ef3779a9558d74b05120a Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Mon, 1 Dec 2025 16:39:15 +0100 Subject: [PATCH] ucm: add ValueGlobals section to the top configuration file BootCardGroup and BootCardSyncTime variables should not be listed by default in _identifiers. Handle them differently using ValueGlobals section. Signed-off-by: Jaroslav Kysela --- src/ucm/main.c | 7 ++++++- src/ucm/parser.c | 19 ++++++++++++++----- src/ucm/ucm_confdoc.h | 6 +++--- src/ucm/ucm_local.h | 3 +++ src/ucm/utils.c | 1 + 5 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/ucm/main.c b/src/ucm/main.c index cde7dcad..21a39a34 100644 --- a/src/ucm/main.c +++ b/src/ucm/main.c @@ -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; } diff --git a/src/ucm/parser.c b/src/ucm/parser.c index 9787c84b..a76be776 100644 --- a/src/ucm/parser.c +++ b/src/ucm/parser.c @@ -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); diff --git a/src/ucm/ucm_confdoc.h b/src/ucm/ucm_confdoc.h index aa796b37..5fac99e4 100644 --- a/src/ucm/ucm_confdoc.h +++ b/src/ucm/ucm_confdoc.h @@ -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 } diff --git a/src/ucm/ucm_local.h b/src/ucm/ucm_local.h index 8fd996ff..8b3da74f 100644 --- a/src/ucm/ucm_local.h +++ b/src/ucm/ucm_local.h @@ -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; diff --git a/src/ucm/utils.c b/src/ucm/utils.c index 712ef613..68a7521e 100644 --- a/src/ucm/utils.c +++ b/src/ucm/utils.c @@ -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); -- 2.47.3