]> git.alsa-project.org Git - alsa-utils.git/commitdiff
topology: pre-process-class: add function to look up token_ref for an attribute in...
authorRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Fri, 23 Apr 2021 20:41:45 +0000 (13:41 -0700)
committerJaroslav Kysela <perex@perex.cz>
Tue, 25 May 2021 16:26:51 +0000 (18:26 +0200)
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>
topology/pre-process-class.c
topology/pre-processor.h

index b039716cc317f4e15d918505611eec9fbb1adbcc..909865ad02d6869079f17145ca921ce531925d44 100644 (file)
@@ -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;
+}
index 17a7dd569f2eaa93ce67062f5e1b05b3cf4ad7d4..81063b7702779759a04da5ea7be2ff76ae9ef423 100644 (file)
@@ -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);