]> git.alsa-project.org Git - alsa-utils.git/commitdiff
topology: pre-process-dapm: Add support for tlv objects
authorRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Mon, 26 Apr 2021 19:49:51 +0000 (12:49 -0700)
committerJaroslav Kysela <perex@perex.cz>
Tue, 25 May 2021 16:26:51 +0000 (18:26 +0200)
Add support for pre-processing TLV objects
For example:

Object.Base.tlv."vtlv_m64s2" {}

will be converted to:

SectionTLV.'vtlv_m64s2' {}

And the mixer controle section will be updated to add
the reference to the tlv object.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
topology/Makefile.am
topology/pre-process-dapm.c [new file with mode: 0644]
topology/pre-process-object.c
topology/pre-processor.h

index 8efbf4f358de6c59ba847993a2a52ca272683670..7c9392cc3200e920a742d29fe19d0b55b668150a 100644 (file)
@@ -8,7 +8,8 @@ endif
 %.1: %.rst
        rst2man $< > $@
 
-alsatplg_SOURCES = topology.c pre-processor.c pre-process-class.c pre-process-object.c
+alsatplg_SOURCES = topology.c pre-processor.c pre-process-class.c pre-process-object.c \
+                   pre-process-dapm.c
 
 noinst_HEADERS = topology.h pre-processor.h
 
diff --git a/topology/pre-process-dapm.c b/topology/pre-process-dapm.c
new file mode 100644 (file)
index 0000000..372ac65
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+  Copyright(c) 2021 Intel Corporation
+  All rights reserved.
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of version 2 of the GNU General Public License as
+  published by the Free Software Foundation.
+
+  This program is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+  The full GNU General Public License is included in this distribution
+  in the file called LICENSE.GPL.
+*/
+#include <errno.h>
+#include <stdio.h>
+#include <alsa/input.h>
+#include <alsa/output.h>
+#include <alsa/conf.h>
+#include <alsa/error.h>
+#include "topology.h"
+#include "pre-processor.h"
+
+int tplg_build_tlv_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
+                             snd_config_t *parent)
+{
+       snd_config_t *cfg;
+       const char *name;
+       int ret;
+
+       cfg = tplg_object_get_instance_config(tplg_pp, obj_cfg);
+
+       name = tplg_object_get_name(tplg_pp, cfg);
+       if (!name)
+               return -EINVAL;
+
+       ret = tplg_build_object_from_template(tplg_pp, obj_cfg, &cfg, NULL, false);
+       if (ret < 0)
+               return ret;
+
+       return tplg_parent_update(tplg_pp, parent, "tlv", name);
+}
index 22f4d484a6bbe8e7fef355a4f1dca757fc5ef377..64e1689f998c7415396b8f0be89cdf82aa721823 100644 (file)
@@ -113,6 +113,18 @@ int tplg_parent_update(struct tplg_pre_processor *tplg_pp, snd_config_t *parent,
                return ret;
 
        /* get section config */
+       if (!strcmp(section_name, "tlv")) {
+               ret = tplg_config_make_add(&item_config, section_name,
+                                         SND_CONFIG_TYPE_STRING, cfg);
+               if (ret < 0) {
+                       SNDERR("Error creating section config widget %s for %s\n",
+                              section_name, parent_name);
+                       return ret;
+               }
+
+               return snd_config_set_string(item_config, item_name);
+       }
+
        ret = snd_config_search(cfg, section_name, &item_config);
        if (ret < 0) {
                ret = tplg_config_make_add(&item_config, section_name,
@@ -859,6 +871,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", "tlv", "SectionTLV", &tplg_build_tlv_object, NULL},
        {"Base", "VendorToken", "SectionVendorTokens", &tplg_build_vendor_token_object, NULL},
        {"Widget", "", "SectionWidget", &tplg_build_generic_object, &widget_config},
 };
index c6d2df812bff19249670ef5ae021bb75309e83bb..34fb72362a469b46597990027598e9a5191692bc 100644 (file)
@@ -53,6 +53,8 @@ void tplg_pp_config_debug(struct tplg_pre_processor *tplg_pp, snd_config_t *cfg)
 int tplg_build_object_from_template(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
                                    snd_config_t **wtop, snd_config_t *top_config,
                                    bool skip_name);
+int tplg_build_tlv_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
+                             snd_config_t *parent);
 int tplg_parent_update(struct tplg_pre_processor *tplg_pp, snd_config_t *parent,
                          const char *section_name, const char *item_name);