ucm: add LibraryConfig support

This commit allows to define private alsa-lib's configuration. When
the configuration is present, the device values ("PlaybackCTL",
"CaptureCTL", "PlaybackMixer", "CaptureMixer", "CapturePCM")
are prefixed with '_ucmHEXA.' string where HEXA is replaced by the
unique hexadecimal number identifying the opened ucm manager handle.

    Syntax 4

    LibraryConfig.a_label.SubstiConfig {
            # substituted library configuration like:
            usr_share_dir "${ConfLibDir}"
    }

    LibraryConfig.b_label.Config {
            # non-substituted library configuration like:
            usr_share_dir "/usr/share/alsa"
    }

    The File counterparts:

    LibraryConfig.c_label.SubstiFile "/some/path"
    LibraryConfig.d_label.File "/some/path"

Note that for files the contents is substituted on the request,
but the file name is always substituted (useful for ${ConfDir} etc.).

The private configuration is not saved or preserved. It's life time
belongs to the opened ucm manager handle.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2021-04-12 18:09:21 +02:00
parent 3e0140088c
commit 8f5779eb3f
11 changed files with 400 additions and 36 deletions

View file

@ -222,6 +222,10 @@ struct snd_use_case_mgr {
char *conf_dir_name;
char *comment;
int conf_format;
unsigned int ucm_card_number;
/* UCM cards list */
struct list_head cards_list;
/* use case verb, devices and modifier configs parsed from files */
struct list_head verb_list;
@ -253,6 +257,9 @@ struct snd_use_case_mgr {
/* list of opened control devices */
struct list_head ctl_list;
/* local library configuration */
snd_config_t *local_config;
/* Components don't define cdev, the card device. When executing
* a sequence of a component device, ucm manager enters component
* domain and needs to provide cdev to the component. This cdev
@ -275,6 +282,7 @@ void uc_mgr_stdout(const char *fmt, ...);
const char *uc_mgr_sysfs_root(void);
const char *uc_mgr_config_dir(int format);
int uc_mgr_config_load_into(int format, const char *file, snd_config_t *cfg);
int uc_mgr_config_load(int format, const char *file, snd_config_t **cfg);
int uc_mgr_config_load_file(snd_use_case_mgr_t *uc_mgr, const char *file, snd_config_t **cfg);
int uc_mgr_import_master_config(snd_use_case_mgr_t *uc_mgr);
@ -291,6 +299,14 @@ void uc_mgr_free_transition_element(struct transition_sequence *seq);
void uc_mgr_free_verb(snd_use_case_mgr_t *uc_mgr);
void uc_mgr_free(snd_use_case_mgr_t *uc_mgr);
static inline int uc_mgr_has_local_config(snd_use_case_mgr_t *uc_mgr)
{
return uc_mgr && snd_config_iterator_first(uc_mgr->local_config);
}
int uc_mgr_card_open(snd_use_case_mgr_t *uc_mgr);
void uc_mgr_card_close(snd_use_case_mgr_t *uc_mgr);
int uc_mgr_open_ctl(snd_use_case_mgr_t *uc_mgr,
struct ctl_list **ctl_list,
const char *device,