Commit graph

13 commits

Author SHA1 Message Date
Ranjani Sridharan
68dd54784a topology: pre-processor: Add support for enum controls
Add support for adding enum controls in the topology pre-processor.

Closes: https://github.com/alsa-project/alsa-utils/pull/236
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-10-17 13:24:11 +02:00
Ranjani Sridharan
90f5967178 topology: pre-processor: Move the call to expand variables
Remove the call to snd_config_expand_custom() to expand the top-level
input config. And replace it with calls to snd_config_evaluate_string()
for each non-compound config while processing individual objects. This
will allow retreving variable definitions from object attribute values
and global definitions.

Add a new field "current_obj_cfg" to hold the current object config
being pre-processed.

This will facilitate adding simple math expressions for computing
attribute values for objects based on other attributes. For ex: we can
set the expression for buffer size as follows:

buffer_size "$[($in_channels * 48) * 4]"

The buffer_size attribute value will be computed with the attribute
value "in_channels" based on the expression above. So if $in_channels =
2, buffer_size will be evaluated to 384.

Additionally this change also permits computing attribute values based
on previously computed values. For example:

buffer_size "$[($in_channels * 48) * 4]"
dma_buffer_size "$[$buffer_size * 2]"

dma_buffer_size will be computed as 768. Note that the order of
definitions for buffer_size and dma_buffer_size matters because the
evaluation for dma_buffer_size depends on the evaluation of buffer_size.
In order to conform to this, the tplg_object_copy_and_add_param() is
modified to add attribute configs from class config to an object using
snd_config_before() instead of snd_config_add().

With this change, we no longer need to set the auto_attr_updater for
buffer type widget objects. So remove it.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-12-19 20:32:38 +01:00
Jaroslav Kysela
1a32420577 alsatplg: use standard include/asoundlib.h instead direct headers
BugLink: https://github.com/alsa-project/alsa-lib/pull/169
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-09-03 08:49:03 +02:00
Ranjani Sridharan
b13a940618 pre-process-dapm: add data section for kcontrols
Allow support for adding data section for kcontrols.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-08-23 16:49:56 +02:00
Ranjani Sridharan
268f599d24 pre-process-dapm: fix source and sink for DAPM routes
Switch source and sink widgets in the DAPM route.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-08-23 16:49:56 +02:00
Chao Song
b848786f42 topology: pre-process-dapm: update automatic attributes for buffer
Add the function to compute the value for the
"size" automatic attribute in the buffer objects.

Signed-off-by: Chao Song <chao.song@linux.intel.com>
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-08-23 16:49:56 +02:00
Jaroslav Kysela
c58f981e15 topology: fix few coverity detected defects
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-04 10:19:41 +02:00
Chao Song
3d7a6facd9 topology: fix potential null pointer from strchr
This patch adds check to the return pointer from strchr,
because it may be null and cause segment fault, if component
is not properly constructed.

Fixes: https://github.com/alsa-project/alsa-utils/pull/91
Signed-off-by: Chao Song <chao.song@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-02 16:55:57 +02:00
Jaroslav Kysela
8037d4812e topology: some whitespace fixups
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-05-25 18:36:46 +02:00
Ranjani Sridharan
758e4dba81 topology: pre-process-dapm: add support for route objects
DAPM route objects such as:
Object.Base.route."1" {
	source	"dai.SSP.0.dai.capture"
	sink	"buffer.2.1"
}

will be converted to:

SectionGraph."Endpoint.route.1" {
	index 0
	lines [
		"dai.SSP.0.capture, , buffer.2.1"
	]
}

If the source/sink names are references to objects within a parent pipeline
object, the index attribute value can be skipped and it will be
populated when the object is pre-processed

Object.Pipeline.volume-capture."1" {
	Object.Base.route."1" {
		source	"pga..0"
		sink	"buffer..0"
	}
}

The reference pga..0 will need to be resolved to
get the widget name pga.1.0 and buffer..0 will
be resolved to buffer.1.0 before creating the SectionGraph as follows:

SectionGraph."volume-capture.1.route.1" {
	index 2
	lines [
		"pga.1.0, , buffer.1.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
79033ceae4 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>
2021-05-25 18:26:51 +02:00
Ranjani Sridharan
082015dc95 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>
2021-05-25 18:26:51 +02:00
Ranjani Sridharan
96b5e5a875 topology: pre-process-dapm: Add support for tlv objects
Add support for pre-processing TLV objects
For example:

	Object.Base.tlv."vtlv_m64s2" {}

will be converted to:

SectionTLV.'vtlv_m64s2' {}

And the mixer controle section will be updated to add
the reference to the tlv object.

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