topology: pre-process-dapm: add support for widget control objects

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>
This commit is contained in:
Ranjani Sridharan
2021-04-26 13:03:57 -07:00
committed by Jaroslav Kysela
parent 082015dc95
commit 79033ceae4
3 changed files with 54 additions and 0 deletions
+37
View 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");
}
+13
View 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,
+4
View 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);