topology: pre-process-class: add function to look up token_ref for an attribute in class

Some attributes may have the token_ref set which is
used to look up the token value for the tuple data
that is appended to the object's private data.

For example, in the buffer widget object:
	DefineAttribute."size" {
		# Token reference and type
		token_ref	"sof_tkn_buffer.word"
	}

The token_ref must include the reference to the vendor
token object name followed by the type of the tuple.

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 13:41:45 -07:00 committed by Jaroslav Kysela
parent d8e9466e59
commit 963578af1e
2 changed files with 29 additions and 0 deletions

View file

@ -207,3 +207,30 @@ snd_config_type_t tplg_class_get_attribute_type(struct tplg_pre_processor *tplg_
return SND_CONFIG_TYPE_INTEGER; 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;
}

View file

@ -39,6 +39,8 @@ const char *tplg_class_get_unique_attribute_name(struct tplg_pre_processor *tplg
snd_config_t *class); snd_config_t *class);
snd_config_type_t tplg_class_get_attribute_type(struct tplg_pre_processor *tplg_pp, snd_config_type_t tplg_class_get_attribute_type(struct tplg_pre_processor *tplg_pp,
snd_config_t *attr); 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 */ /* 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);