diff --git a/topology/pre-process-class.c b/topology/pre-process-class.c index 9e7f4fc..cd4c7c3 100644 --- a/topology/pre-process-class.c +++ b/topology/pre-process-class.c @@ -66,3 +66,28 @@ snd_config_t *tplg_class_lookup(struct tplg_pre_processor *tplg_pp, snd_config_t free(class_config_id); return class_cfg; } + +/* find the attribute config by name in the class definition */ +snd_config_t *tplg_class_find_attribute_by_name(struct tplg_pre_processor *tplg_pp, + snd_config_t *class, const char *name) +{ + snd_config_t *attr = NULL; + const char *class_id; + char *attr_str; + int ret; + + if (snd_config_get_id(class, &class_id) < 0) + return NULL; + + attr_str = tplg_snprintf("DefineAttribute.%s", name); + if (!attr_str) + return NULL; + + ret = snd_config_search(class, attr_str, &attr); + if (ret < 0) + SNDERR("No definition for attribute '%s' in class '%s'\n", + name, class_id); + + free(attr_str); + return attr; +} diff --git a/topology/pre-processor.h b/topology/pre-processor.h index 8c32ce3..d7d1b11 100644 --- a/topology/pre-processor.h +++ b/topology/pre-processor.h @@ -28,6 +28,8 @@ void tplg_pp_config_debug(struct tplg_pre_processor *tplg_pp, snd_config_t *cfg) /* class helpers */ snd_config_t *tplg_class_lookup(struct tplg_pre_processor *tplg_pp, snd_config_t *cfg); +snd_config_t *tplg_class_find_attribute_by_name(struct tplg_pre_processor *tplg_pp, + snd_config_t *class, const char *name); /* config helpers */ snd_config_t *tplg_find_config(snd_config_t *config, const char *name);