]> git.alsa-project.org Git - alsa-utils.git/commitdiff
topology: pre-processor: Add support for enum controls
authorRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Mon, 11 Sep 2023 15:18:15 +0000 (08:18 -0700)
committerJaroslav Kysela <perex@perex.cz>
Tue, 17 Oct 2023 11:24:11 +0000 (13:24 +0200)
Add support for adding enum controls in the topology pre-processor.

Closes: https://github.com/alsa-project/alsa-utils/pull/236
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 9355a861757d7b3de0f97030070f25d6d3963e6b..78944a6d98013b8299293461c230b07e3ac73510 100644 (file)
@@ -70,6 +70,26 @@ int tplg_build_channel_object(struct tplg_pre_processor *tplg_pp, snd_config_t *
        return tplg_build_base_object(tplg_pp, obj_cfg, parent, false);
 }
 
+int tplg_build_text_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, "texts", name);
+}
+
 int tplg_build_tlv_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
                              snd_config_t *parent)
 {
@@ -131,6 +151,12 @@ int tplg_build_bytes_control(struct tplg_pre_processor *tplg_pp, snd_config_t *o
        return tplg_build_control(tplg_pp, obj_cfg, parent, "bytes");
 }
 
+int tplg_build_enum_control(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
+                            snd_config_t *parent)
+{
+       return tplg_build_control(tplg_pp, obj_cfg, parent, "enum");
+}
+
 /*
  * Widget names for pipeline endpoints can be of the following type:
  * "class.<constructor args separated by .> ex: pga.0.1, buffer.1.1 etc
index 61cc85fbc43df4d7046a61f97e86267d929bf35c..34b92033435cfa9ba5541cf6ad69de7454796c08 100644 (file)
@@ -117,7 +117,7 @@ int tplg_parent_update(struct tplg_pre_processor *tplg_pp, snd_config_t *parent,
                return ret;
 
        /* get section config */
-       if (!strcmp(section_name, "tlv")) {
+       if (!strcmp(section_name, "tlv") || !strcmp(section_name, "texts")) {
                /* set tlv name if config exists already */
                ret = snd_config_search(cfg, section_name, &item_config);
                        if (ret < 0) {
@@ -1038,6 +1038,15 @@ const struct config_template_items bytes_control_config = {
        .compound_config_ids = {"access"}
 };
 
+const struct config_template_items enum_control_config = {
+       .int_config_ids = {"index"},
+       .compound_config_ids = {"access"}
+};
+
+const struct config_template_items text_config = {
+       .compound_config_ids = {"values"}
+};
+
 const struct config_template_items scale_config = {
        .int_config_ids = {"min", "step", "mute"},
 };
@@ -1073,6 +1082,7 @@ const struct build_function_map object_build_map[] = {
        {"Base", "ops", "ops" ,&tplg_build_ops_object, NULL, &ops_config},
        {"Base", "extops", "extops" ,&tplg_build_ops_object, NULL, &ops_config},
        {"Base", "channel", "channel", &tplg_build_channel_object, NULL, &channel_config},
+       {"Base", "text", "SectionText", &tplg_build_text_object, NULL, &text_config},
        {"Base", "VendorToken", "SectionVendorTokens", &tplg_build_vendor_token_object,
         NULL, NULL},
        {"Base", "hw_config", "SectionHWConfig", &tplg_build_hw_cfg_object, NULL,
@@ -1085,6 +1095,8 @@ const struct build_function_map object_build_map[] = {
         &mixer_control_config},
        {"Control", "bytes", "SectionControlBytes", &tplg_build_bytes_control, NULL,
         &bytes_control_config},
+        {"Control", "enum", "SectionControlEnum", &tplg_build_enum_control, NULL,
+        &enum_control_config},
        {"Dai", "", "SectionBE", &tplg_build_generic_object, NULL, &be_dai_config},
        {"PCM", "pcm", "SectionPCM", &tplg_build_generic_object, NULL, &pcm_config},
        {"PCM", "pcm_caps", "SectionPCMCapabilities", &tplg_build_pcm_caps_object,
index 878653d4c84945d68362566b7d19265e845d99b0..3a8a4bc3b1a836dc68a2b461a961ac87efd2670e 100644 (file)
@@ -70,6 +70,10 @@ int tplg_build_mixer_control(struct tplg_pre_processor *tplg_pp, snd_config_t *o
                              snd_config_t *parent);
 int tplg_build_bytes_control(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
                              snd_config_t *parent);
+int tplg_build_enum_control(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
+                            snd_config_t *parent);
+int tplg_build_text_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
+                          snd_config_t *parent);
 int tplg_build_dapm_route_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
                              snd_config_t *parent);
 int tplg_build_hw_cfg_object(struct tplg_pre_processor *tplg_pp,