diff --git a/topology/pre-process-dapm.c b/topology/pre-process-dapm.c index 372ac65..fa1b64c 100644 --- a/topology/pre-process-dapm.c +++ b/topology/pre-process-dapm.c @@ -26,6 +26,53 @@ #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) { diff --git a/topology/pre-process-object.c b/topology/pre-process-object.c index 64e1689..c7c23ff 100644 --- a/topology/pre-process-object.c +++ b/topology/pre-process-object.c @@ -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}, }; diff --git a/topology/pre-processor.h b/topology/pre-processor.h index 34fb723..1e1bca5 100644 --- a/topology/pre-processor.h +++ b/topology/pre-processor.h @@ -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);