diff --git a/topology/pre-process-class.c b/topology/pre-process-class.c index b039716..909865a 100644 --- a/topology/pre-process-class.c +++ b/topology/pre-process-class.c @@ -207,3 +207,30 @@ snd_config_type_t tplg_class_get_attribute_type(struct tplg_pre_processor *tplg_ return SND_CONFIG_TYPE_INTEGER; } + +/* get token_ref for attribute with name attr_name in the class */ +const char *tplg_class_get_attribute_token_ref(struct tplg_pre_processor *tplg_pp, + snd_config_t *class, const char *attr_name) +{ + snd_config_t *attributes, *attr, *token_ref; + const char *token; + int ret; + + ret = snd_config_search(class, "DefineAttribute", &attributes); + if (ret < 0) + return NULL; + + ret = snd_config_search(attributes, attr_name, &attr); + if (ret < 0) + return NULL; + + ret = snd_config_search(attr, "token_ref", &token_ref); + if (ret < 0) + return NULL; + + ret = snd_config_get_string(token_ref, &token); + if (ret < 0) + return NULL; + + return token; +} diff --git a/topology/pre-processor.h b/topology/pre-processor.h index 17a7dd5..81063b7 100644 --- a/topology/pre-processor.h +++ b/topology/pre-processor.h @@ -39,6 +39,8 @@ const char *tplg_class_get_unique_attribute_name(struct tplg_pre_processor *tplg snd_config_t *class); snd_config_type_t tplg_class_get_attribute_type(struct tplg_pre_processor *tplg_pp, snd_config_t *attr); +const char *tplg_class_get_attribute_token_ref(struct tplg_pre_processor *tplg_pp, + snd_config_t *class, const char *attr_name); /* config helpers */ snd_config_t *tplg_find_config(snd_config_t *config, const char *name);