1
0
Fork 0
mirror of https://github.com/alsa-project/alsa-utils synced 2025-01-06 06:46:40 +01:00

topology: pre-process-dapm: add support for scale/ops/channel objects

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>
This commit is contained in:
Ranjani Sridharan 2021-04-26 12:55:26 -07:00 committed by Jaroslav Kysela
parent 96b5e5a875
commit 082015dc95
3 changed files with 70 additions and 0 deletions

View file

@ -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)
{

View 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},
};

View 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);