]> git.alsa-project.org Git - alsa-utils.git/commitdiff
topology: pre-process-base: add support for VendorToken objects
authorRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Mon, 26 Apr 2021 18:55:22 +0000 (11:55 -0700)
committerJaroslav Kysela <perex@perex.cz>
Tue, 25 May 2021 16:26:51 +0000 (18:26 +0200)
Add support for pre-processing VendorToken objects.
For ex:
Object.Base.VendorToken."sof_tkn_dai" {
dmac_config 153
dai_type 154
index 155
direction 156
}

would be converted to:

SectionVendorTokens."sof_tkn_dai" {
dmac_config 153
dai_type 154
index 155
direction 156
}

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
topology/pre-process-object.c

index 0777e8a58d9d8dfcd62057ad752c7536c1014cfc..6988f8edf69cdfa02526672d1f90476eda429752 100644 (file)
 #include "topology.h"
 #include "pre-processor.h"
 
+/* Parse VendorToken object, create the "SectionVendorToken" and save it */
+int tplg_build_vendor_token_object(struct tplg_pre_processor *tplg_pp,
+                              snd_config_t *obj_cfg, snd_config_t *parent)
+{
+       snd_config_iterator_t i, next;
+       snd_config_t *vtop, *n, *obj;
+       const char *name;
+       int ret;
+
+       ret = tplg_build_object_from_template(tplg_pp, obj_cfg, &vtop, NULL, false);
+       if (ret < 0)
+               return ret;
+
+       ret = snd_config_get_id(vtop, &name);
+       if (ret < 0)
+               return ret;
+
+       /* add the tuples */
+       obj = tplg_object_get_instance_config(tplg_pp, obj_cfg);
+       snd_config_for_each(i, next, obj) {
+               snd_config_t *dst;
+               const char *id;
+
+               n = snd_config_iterator_entry(i);
+
+               if (snd_config_get_id(n, &id) < 0)
+                       continue;
+
+               if (!strcmp(id, "name"))
+                       continue;
+
+               ret = snd_config_copy(&dst, n);
+               if (ret < 0) {
+                       SNDERR("Error copying config node %s for '%s'\n", id, name);
+                       return ret;
+               }
+
+               ret = snd_config_add(vtop, dst);
+               if (ret < 0) {
+                       snd_config_delete(dst);
+                       SNDERR("Error adding vendortoken %s for %s\n", id, name);
+                       return ret;
+               }
+       }
+
+       return ret;
+}
+
 int tplg_parent_update(struct tplg_pre_processor *tplg_pp, snd_config_t *parent,
                          const char *section_name, const char *item_name)
 {
@@ -805,6 +853,7 @@ const struct config_template_items data_config = {
 const struct build_function_map object_build_map[] = {
        {"Base", "manifest", "SectionManifest", &tplg_build_generic_object, NULL},
        {"Base", "data", "SectionData", &tplg_build_data_object, &data_config},
+       {"Base", "VendorToken", "SectionVendorTokens", &tplg_build_vendor_token_object, NULL},
 };
 
 static const struct build_function_map *tplg_object_get_map(struct tplg_pre_processor *tplg_pp,