topology: pre-process-class: Add function to look up attribute definition in class

Add a helper function look up attribute definition in the
"DefineAttribute" config in the class definition.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Ranjani Sridharan 2021-04-23 12:35:56 -07:00 committed by Jaroslav Kysela
parent c832f48404
commit 1422c09afd
2 changed files with 27 additions and 0 deletions

View file

@ -66,3 +66,28 @@ snd_config_t *tplg_class_lookup(struct tplg_pre_processor *tplg_pp, snd_config_t
free(class_config_id); free(class_config_id);
return class_cfg; 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;
}

View file

@ -28,6 +28,8 @@ void tplg_pp_config_debug(struct tplg_pre_processor *tplg_pp, snd_config_t *cfg)
/* class helpers */ /* class helpers */
snd_config_t *tplg_class_lookup(struct tplg_pre_processor *tplg_pp, snd_config_t *cfg); 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 */ /* config helpers */
snd_config_t *tplg_find_config(snd_config_t *config, const char *name); snd_config_t *tplg_find_config(snd_config_t *config, const char *name);