]> git.alsa-project.org Git - alsa-utils.git/commitdiff
topology: pre-process-dapm: add support for widget control objects
authorRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Mon, 26 Apr 2021 20:03:57 +0000 (13:03 -0700)
committerJaroslav Kysela <perex@perex.cz>
Tue, 25 May 2021 16:26:51 +0000 (18:26 +0200)
Add support for pre-processing mixer and byte control objects.
For ex: a pga widget with a mixer control as follows:

Object.pga"0" {
...
mixer.0 {
index 2
max 32
name "2 MasterPlaybackControl"
Object.Base.channel."fl" {
shift 0
}
Object.Base.channel."fr" {
}

Object.Base.tlv."vtlv_m64s2" {
Object.Base.scale."m64s2" {
mute 1
}
}

Object.Base.ops."ctl" {
info  "volsw"
#256 binds the mixer control to volume get/put handlers
get  256
put  256
}

access [
read_write
tlv_read
]
}
}

Would be converted to:

SectionControlMixer.'2 Master Playback Volume' {
index 2
max 32
channel {
fl {
reg 1
}
fr {
reg 1
shift 1
}
}
tlv "vtlv_m64s2"
ops.0 {
info volsw
get 256
put 256
}
access [
read_write
tlv_read
]
}

and the SectionWidget for pga.2.0 would be updated to add the mixer references as follows:
SectionWidget.'pga.2.0' {
...
mixer [
"2 Master Playback Volume"
]
}

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 fa1b64cf0f5fef05bf62a0211fd8effe120aa7f6..63dd1fba488c26d56e825ab5903d583157c2fd48 100644 (file)
@@ -92,3 +92,40 @@ int tplg_build_tlv_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_
 
        return tplg_parent_update(tplg_pp, parent, "tlv", name);
 }
+
+static int tplg_build_control(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
+                             snd_config_t *parent, char *type)
+{
+       snd_config_t *cfg, *obj;
+       const char *name;
+       int ret;
+
+       obj = tplg_object_get_instance_config(tplg_pp, obj_cfg);
+
+       /* get control name */
+       ret = snd_config_search(obj, "name", &cfg);
+       if (ret < 0)
+               return 0;
+
+       ret = snd_config_get_string(cfg, &name);
+       if (ret < 0)
+               return ret;
+
+       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, type, name);
+}
+
+int tplg_build_mixer_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, "mixer");
+}
+
+int tplg_build_bytes_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, "bytes");
+}
index c7c23ff6577ae135020464bfc8041b417a6cb342..8e49be8f0bcebd7292ff1d10d070c83531784690 100644 (file)
@@ -858,6 +858,15 @@ static int tplg_build_generic_object(struct tplg_pre_processor *tplg_pp, snd_con
        return ret;
 }
 
+const struct config_template_items mixer_control_config = {
+       .int_config_ids = {"index", "max", "invert"},
+       .compound_config_ids = {"access"}
+};
+
+const struct config_template_items bytes_control_config = {
+       .int_config_ids = {"index", "base", "num_regs", "max", "mask"},
+};
+
 const struct config_template_items scale_config = {
        .int_config_ids = {"min", "step", "mute"},
 };
@@ -891,6 +900,10 @@ const struct build_function_map object_build_map[] = {
        {"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},
+       {"Control", "mixer", "SectionControlMixer", &tplg_build_mixer_control,
+        &mixer_control_config},
+       {"Control", "bytes", "SectionControlBytes", &tplg_build_bytes_control,
+        &bytes_control_config},
 };
 
 static const struct build_function_map *tplg_object_get_map(struct tplg_pre_processor *tplg_pp,
index 1e1bca5c85868a684282a580c7268c54b30707d6..e89fad6bcd5b484d0447f7d71443ffc4e0f58599 100644 (file)
@@ -61,6 +61,10 @@ int tplg_build_ops_object(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_
                              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_build_mixer_control(struct tplg_pre_processor *tplg_pp, snd_config_t *obj_cfg,
+                             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_parent_update(struct tplg_pre_processor *tplg_pp, snd_config_t *parent,
                          const char *section_name, const char *item_name);