Commit graph

6 commits

Author SHA1 Message Date
Ranjani Sridharan
571d1fe871 topology: pre-process-object: add data section for attributes with token reference
Objects that have attributes with token_ref need
to have separate SectionData and SectionVendorTuples
for each unique token_ref based on the attribute_sets
in the object's attribute_set_list.

Add the tplg_pp_add_object_data()
function to add the data[] refs in the object and also
the respective SectionData and SectionVendorTuples.

For example for the pga object:

Object.Widget.pga."0" {
	pipeline_id 2
	format s24le
	type pga
	no_pm 1
	uuid    "7e:67:7e:b7:f4:5f:88:41:af:14:fb:a8:bd:bf:8"
	period_sink_count 2
	period_source_count 2
	ramp_step_ms 250
        ramp_step_type "linear"
	mixer.0 {
		....
	}
	mixer.0.name "2 Master Playback Volume"
}

The following sections will be added:
SectionWidget.'pga.2.0' {
	index 2
	type pga
	no_pm 1
	mixer [
		"2 Master Playback Volume"
	]
	bytes [
	]
	data [
		"pga.2.0.sof_tkn_comp.word"
		"pga.2.0.sof_tkn_comp.string"
		"pga.2.0.sof_tkn_comp.uuid"
		"pga.2.0.sof_tkn_volume.word"
	]
}

SectionData."pga.2.0.sof_tkn_comp.word" {
	tuples	"pga.2.0.sof_tkn_comp.word"
}

SectionData."pga.2.0.sof_tkn_comp.string" {
	tuples	"pga.2.0.sof_tkn_comp.string"
}

SectionData."pga.2.0.sof_tkn_comp.uuid" {
	tuples	"pga.2.0.sof_tkn_comp.uuid"
}

SectionData."pga.2.0.sof_tkn_volume.word" {
	tuples	"pga.2.0.sof_tkn_volume.word"
}

SectionVendorTuples."pga.2.0.sof_tkn_comp.word" {
	tokens	"sof_tkn_comp"
	tuples."word" {
		period_source_count	"2"
		period_sink_count	"2"
	}
}

SectionVendorTuples."pga.2.0.sof_tkn_comp.string" {
	tokens	"sof_tkn_comp"
	tuples."string" {
		format	"s24le"
	}
}

SectionVendorTuples."pga.2.0.sof_tkn_comp.uuid" {
	tokens	"sof_tkn_comp"
	tuples."uuid" {
		uuid	"7e:67:7e:b7:f4:5f:88:41:af:14:fb:a8:bd:bf:8"
	}
}

SectionVendorTuples."pga.2.0.sof_tkn_volume.word" {
	tokens	"sof_tkn_volume"
	tuples."word" {
		ramp_step_ms	"250"
		ramp_step_type	"0"
	}
}

Note that the ramp_step_type of "linear" is converted
to the tuple value 0.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-05-25 18:26:51 +02:00
Ranjani Sridharan
d999c267d3 topology: pre-process-object: Add support for processing Manifest object
The pre-processor converts the Topology2.0 objects into
the relevant sections by looking for attributes defined
in the template config for the section and reading the
attribute values from the object instance config.

The structure struct build_function_map contains the
mapping of the build function to use for each object
based on the type and name for the class that the object
belongs to. The manifest object is the simplest with
no attributes. So, the build function simply creates
a new Section called SectionManifest which will be
populated with the data section in the following patches.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-05-25 18:26:51 +02:00
Ranjani Sridharan
1ca07d8dbc topology: pre-process-object: construct object name from its constructor attributes
An object's name is derived from its constructor attribute
values separated by '.'. For example, the name for the
host widget objects is derived from its index and direction
attribute values as follows:
Object.Widget.host."playback" {
	index 2
}

The name for the host widget object would be host.2.playback.

Alternatively, if the object has a name attribute, the class
definition may skip the constructor attributes and the name attribute
value will be used instead.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-05-25 18:26:51 +02:00
Ranjani Sridharan
b2e85be668 topology: pre-process-object: check attribute validity
Attributes can have constraints set for valid values, min
or max values. If the attribute value is set in an object,
the value must be validated against the set constraints.

An example for attribute constraint would be:
DefineAttribute."direction" {
		constraints {
			valid_values [
				"playback"
				"capture"
			]
			tuple_values [
				0
				1
			]
		}
}

where the tuple_values array would translate the valid_values of
playback as 0 and capture as 1.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-05-25 18:26:51 +02:00
Ranjani Sridharan
624c814c65 topology/pre-process-object: update object config with attributes
Object attributes can be set in multiple places. Search for
the attribute value in the following order:
1. Value set in object instance
2. Default value set in the object's class definition
3. Inherited value from the parent object
4. Value set in the object instance embedded in the parent object
5. Value set in the object instance embedded in the parent class definition

Mandatory attributes must be found in one of the above, resulting
in an error if not found.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-05-25 18:26:51 +02:00
Ranjani Sridharan
4d413567b0 topology: pre-process-object: Add support for pre-processing Objects
Add support for pre-processing object instances in the input
config. An object's attributes can be set in multiple places
such as, within the object instance, default values in the class
defnition, inherited from a parent object or explicitly set
in a parent object. Before converting the object config into
the relevant section in the existing syntax, all the attribute
values must be consolidated into one place so that it is easy
to verify if all mandatory attributes are set.
Also, the name of the object will be constructed from the
attributes defined in the attributes.constructor[] config
in the class definition and the unique attribute's value
must be set from the value passed in the object instance.

This patch create a temporary config for each object instance
and populates its unique attribute value. The rest of the steps
will be added in the following patches.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-05-25 18:26:51 +02:00