]> git.alsa-project.org Git - alsa-utils.git/commitdiff
topology: pre-process-dapm: add support for scale/ops/channel objects
authorRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Mon, 26 Apr 2021 19:55:26 +0000 (12:55 -0700)
committerJaroslav Kysela <perex@perex.cz>
Tue, 25 May 2021 16:26:51 +0000 (18:26 +0200)
Add support for pre-processing scale/ops/channel objects
and adding the converted config to the relevant sections.

For ex:
Object.Base.channel."fl" {
shift 0
reg 1
}
Object.Base.channel."fr" {
reg 1
shift 1
}

Will be converted to:

channel {
fl {
reg 1
shift 0
}
fr {
reg 1
shift 1
}
}

And added to the SectionControlMixer that this object belongs to.

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

index 372ac6561519a0ae46df14f1800ec93376437e72..fa1b64cf0f5fef05bf62a0211fd8effe120aa7f6 100644 (file)
 #include "topology.h"
 #include "pre-processor.h"
 
+int tplg_build_base_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
+                          snd_config_t *parent, bool skip_name)
+{
+       snd_config_t *top, *parent_obj, *cfg, *dest;
+       const char *parent_name;
+
+       /* find parent section config */
+       top = tplg_object_get_section(tplg_pp, parent);
+       if (!top)
+               return -EINVAL;
+
+       parent_obj = tplg_object_get_instance_config(tplg_pp, parent);
+
+       /* get parent name */
+       parent_name = tplg_object_get_name(tplg_pp, parent_obj);
+       if (!parent_name)
+               return 0;
+
+       /* find parent config with name */
+       dest = tplg_find_config(top, parent_name);
+       if (!dest) {
+               SNDERR("Cannot find parent config %s\n", parent_name);
+               return -EINVAL;
+       }
+
+       /* build config from template and add to parent */
+       return tplg_build_object_from_template(tplg_pp, obj_cfg, &cfg, dest, skip_name);
+}
+
+int tplg_build_scale_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
+                             snd_config_t *parent)
+{
+       return tplg_build_base_object(tplg_pp, obj_cfg, parent, true);
+}
+
+int tplg_build_ops_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
+                             snd_config_t *parent)
+{
+       return tplg_build_base_object(tplg_pp, obj_cfg, parent, false);
+}
+
+int tplg_build_channel_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
+                             snd_config_t *parent)
+{
+       return tplg_build_base_object(tplg_pp, obj_cfg, parent, false);
+}
+
 int tplg_build_tlv_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
                              snd_config_t *parent)
 {
index 64e1689f998c7415396b8f0be89cdf82aa721823..c7c23ff6577ae135020464bfc8041b417a6cb342 100644 (file)
@@ -858,6 +858,19 @@ static int tplg_build_generic_object(struct tplg_pre_processor *tplg_pp, snd_con
        return ret;
 }
 
+const struct config_template_items scale_config = {
+       .int_config_ids = {"min", "step", "mute"},
+};
+
+const struct config_template_items ops_config = {
+       .int_config_ids = {"get", "put"},
+       .string_config_ids = {"info"},
+};
+
+const struct config_template_items channel_config = {
+       .int_config_ids = {"reg", "shift"},
+};
+
 const struct config_template_items widget_config = {
        .int_config_ids = {"index", "no_pm", "shift", "invert", "subseq", "event_type",
                            "event_flags"},
@@ -872,6 +885,10 @@ 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", "scale", "scale", &tplg_build_scale_object, &scale_config},
+       {"Base", "ops", "ops" ,&tplg_build_ops_object, &ops_config},
+       {"Base", "extops", "extops" ,&tplg_build_ops_object, &ops_config},
+       {"Base", "channel", "channel", &tplg_build_channel_object, &channel_config},
        {"Base", "VendorToken", "SectionVendorTokens", &tplg_build_vendor_token_object, NULL},
        {"Widget", "", "SectionWidget", &tplg_build_generic_object, &widget_config},
 };
index 34fb72362a469b46597990027598e9a5191692bc..1e1bca5c85868a684282a580c7268c54b30707d6 100644 (file)
@@ -55,6 +55,12 @@ int tplg_build_object_from_template(struct tplg_pre_processor *tplg_pp, snd_conf
                                    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_build_scale_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
+                             snd_config_t *parent);
+int tplg_build_ops_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
+                             snd_config_t *parent);
+int tplg_build_channel_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);