Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduction to Topology2.0 #3983

Closed
wants to merge 12 commits into from
Closed

Conversation

ranj063
Copy link
Collaborator

@ranj063 ranj063 commented Mar 30, 2021


# Array of "input-file-name;output-file-name;"
set(TPLGS
"sof-cnl-nocodec\;sof-cnl-nocodec\;"
Copy link
Collaborator

@marc-hb marc-hb Mar 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned on the chat, you can't have ${input}.conf == ${output}.conf, no build system will support that.

I suggest sof-cnl-nocodec_output.conf or something.

@marc-hb
Copy link
Collaborator

marc-hb commented Mar 31, 2021

There were a number of CI issues recently (#3992 and others). @ranj063 please git commit --amend and force-push the same code if you want to re-trigger everything.

    About
    -----

    This is a high level keyword extension on top of the existing ALSA
    conf topology format designed to:

    1) Simplify the ALSA conf topology definitions by providing high level
       "classes" so topology designers need to write less config for common
       object definitions.

    2) Allow simple reuse of objects. Define once and reuse (like M4) with
       the ability to alter objects configuration attributes from defaults.

    3) Allow data type and value verification. This is not done today and
       frequently crops up in FW bug reports.

    Common Topology Classes
    -----------------------

    Topology today has some common classes that are often reused throughout
    with slightly altered configurations. i.e. widgets (components),
    pipelines, dais and controls.

    This PR introduces the high level concept of reusable "class" like
    definition for a AIF_IN/AIF_OUT type object that can be used to create
    topology objects.

    Common Topology Attributes
    --------------------------
    Topology defines a lot of attributes per object with different types
    and constraints. Today there is no easy way to validate type or
    constraints and this can lead to many hard to find problems in FW at
    runtime.

    A new keyword "DefineAttribute" has been added to define attribute
    type, size, min value, max value, enum_values. This then allows
    alsatplg to validate each topology object attribute.

    Topology Classes define the list of attributes that they use and
    whether the attribute is mandatory, can be overridden by parent users
    or is immutable. This also helps alsatplg emit the appropriate errors
    for attribute misuse.

    Common Topology Arguments
    -------------------------

    Arguments are used to pass essential data needed for instantiating an
    object particularly needed for the object name. A new keyword
    "DefineArgument" has been added to define the arguments. The order in
    which the arguments are defined determines the name for the widget.
    For example, in the case of the host widget, the name would be
    constructed as "host.1.playback" where "1" is the pipeline_id argument
    value and "playback" is the direction argument value.

    Attribute Inheritance:
    ----------------------
    One of the key features of Topology2.0 is howthe attribute values are
    propagated from a parent object to a child object. This is accomplished
    by adding attributes/arguments with the same name for a parent and an
    object. By doing so, when creating a child object, the value for the
    common attribute is populated from the parent. If the value is provided
    in the child object instance, then it overrides the value coming from
    the parent.

    ALSA Conf Parser
    ----------------

    All the changes being proposed and discussed here must be 100%
    compliant with the ALSA conf parser. i.e. no syntax changes or
    changes to semantics for any existing keyword.

    It's intended that there will be NO changes to the ALSA conf parser
    (unless new keywords require this ?) and all topology building
    changes will be in the alsatplg compiler.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Add the class definition for DAI widgets. A DAI widget
can be instantiated as follows:
Object.Widget.dai."playback" {
	type			SSP
	index			"1"
	period_sink_count	"2"
	period_source_count	"0"
	widget_type		"dai_in"
}

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Add the definition for the buffer class. A buffer object
can be instantiated as follows:
Object.Widget.buffer."N" {
	pipeline_id	1
	index	0
	size	384
	caps	"host"
}

where 'N' is a unique instance number for the buffer object within
the same alsaconf node.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Add the class definition for PGA widget. It can be
instantiated as follows:
        Object.Widget.pga."N" {
                pipeline_id     1
                index           0
        }

Where N is the unique instance number for pga widget in the same
alsaconf node.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Add the class definition for a mixer control.
A mixer control can be instantiated as follows:
	Object.Control.mixer."0" {
		Object.Base.channel."fr" {
			shift	0
		}
		Object.Base.channel."fl" {}

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

		Object.ops."ctl" {
			info	"volsw"
			get	256
			put	256
		}
	}

Also add the other commonly used class definitions that
will be used to instantiate the mixer object such as,
channel, TLV, ops, scale etc.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Add the volume and switch mixer control objects for the
PGA class. The mixers will be added to the PGA widget
if the pga widget is instantiated with the volume_mixer_name
and switch_mixer_name attributes set.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Add a route class that will be used for creating DAPM routes
between widgets. A route can be between 2 widgets or between a
widget and pipeline endpoint as follows:
	Object.Base.route."N" {
		source	"dai.SSP.1.dai.capture"
		sink	"buffer.0.1"
	}

	Object.Base.route."N" {
		source	"buffer.2.1"
		sink	"pga.2.0"
	}

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Add 2 pipeline classes for Volume playback and Volume Capture.
Each of these classes includes the widget objects, their connections
and define attributes for the pipeline.

A volume playback pipeline can be instanted as follows:
Object.Pipeline.pipeline-volume-playback."2" {
	channels	2
	channels_min	2
	channels_max	2
	rate		48000
	rate_min	48000
	rate_max	48000
	format			"s32le"
}

Every pipeline class is associated with a pipeline widget, so
add the class definition for the pipeline widget as well.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Add the definitions SSP DAI and the hw_config classes.

These are used for instantiating the DAI objects in the
top-level topology file as follows:
Object.Dai.SSP."0" {
	index			0
	direction		"duplex"
	stream_name		"NoCodec-0"
	id 			0
	default_hw_config	0
	format			"s24le"
	quirks			"lbm_mode"
	sample_bits		24
	Object.Base.hw_config."0" {
		id		0
		mclk_freq	24000000
		bclk_freq	4800000
		tdm_slot_width	25
	}

	#Add DAI widgets
	Object.Widget.dai."playback" {
		direction		"playback"
		period_source_count	2
		period_sink_count	0
	}

	Object.Widget.dai."capture" {
		direction		"capture"
		period_source_count	0
		period_sink_count	2
	}
}

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Add class definitions for PCM, PCM Capabilities and FE DAI objects.
These can be instantiated as:
	Object.PCM.pcm."N" {
		name	"Headset"
		direction	"capture"
		Object.fe_dai."Port 0" {
			id	"0"
		}
		Object.PCM.pcm_caps."capture" {
			capabilities "Port0 Capture"
			formats                 "S32_LE,S24_LE,S16_LE"
		        rate_min                48000
			rate_max                48000
		        channels_min            2
			channels_max            2
		        periods_min             2

		}
	}

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
These will be used to add the ABI to the topology
manifest section.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Add a simple machine topology showing 2 pipelines,
an SSP DAI and the connections between the DAI
endpoints and the pipeline endpoints.

Add the manifest and data objects for adding ABI to the
generated tplg file. Also add support for building
the topology2 conf files.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
@gkbldcig
Copy link
Collaborator

Can one of the admins verify this patch?

@lgirdwood lgirdwood added this to the v1.9 milestone May 24, 2021
@lgirdwood
Copy link
Member

For v1.9 - a reminder to merge after ALSA changes merged.

@marc-hb
Copy link
Collaborator

marc-hb commented Jun 7, 2021

This PR should land the new .tplg files in the sof/tools/build_tools/topology2/ build directory. M4 topology files currently land in sof/tools/build_tools/topology/.

Here's a proposition to implement a gradual transition for topology v1 to v2 once this PR is merged.

  • Topology v1 keeps building as usual, no change
  • After building both, build-tools.sh copies the entire sof/tools/build_tools/topology/ to sof/tools/build_tools/topology-v1/ as a backup and for anyone or anything that wants to compare v1 and v2
  • Then a gradually growing subset of topology2/*.tplg files overwrites the topology/*.tplg files of the same name. This can be done with simple, version-controlled rsync --ignore-times --include-from=active_v2_topologies.txt
  • Users start using v2 files without having to change a single line of code.

git churn is minimized.

@lgirdwood
Copy link
Member

@marc-hb I assume you will do an update to build_tools.sh

@marc-hb
Copy link
Collaborator

marc-hb commented Jun 8, 2021

No I was just answering an off-line question, sorry for the confusion.

@ranj063
Copy link
Collaborator Author

ranj063 commented Jun 12, 2021

closing this for now. Will post a new PR with smaller commits

@ranj063 ranj063 closed this Jun 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants